@digital-realty/app-shell 16.0.6 → 16.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bootstrap.js
CHANGED
|
@@ -10,4 +10,4 @@ var wo=Object.defineProperty;var Oo=(e,t,r)=>t in e?wo(e,t,{enumerable:!0,config
|
|
|
10
10
|
To resolve the conflict:`,Ei(i,t))),n=s):f.warn("A view or instrument with the name ",t.name,` has already been registered and is incompatible with another registered view.
|
|
11
11
|
`,`Details:
|
|
12
12
|
`,gi(i,t),`To resolve the conflict:
|
|
13
|
-
`,Ei(i,t))}return n}}class wl{constructor(t){c(this,"_backingStorages");c(this,"hasAttributeProcessor");this._backingStorages=t,this.hasAttributeProcessor=t.some(r=>r.hasAttributeProcessor)}record(t,r,n,s){this.hasAttributeProcessor&&n===void 0&&(n=R.active());const i=this._backingStorages;for(let o=0;o<i.length;o++)i[o].record(t,r,n,s)}}class Ol{constructor(t,r){c(this,"_buffer",new ot);c(this,"_instrumentName");c(this,"_valueType");this._instrumentName=t,this._valueType=r}observe(t,r={}){if(typeof t!="number"){f.warn(`non-number value provided to metric ${this._instrumentName}: ${t}`);return}this._valueType===X.INT&&!Number.isInteger(t)&&(f.warn(`INT value type cannot accept a floating-point value for ${this._instrumentName}, ignoring the fractional digits.`),t=Math.trunc(t),!Number.isInteger(t))||this._buffer.set(r,t)}}class Cl{constructor(){c(this,"_buffer",new Map)}observe(t,r,n={}){if(!xr(t))return;let s=this._buffer.get(t);if(s==null&&(s=new ot,this._buffer.set(t,s)),typeof r!="number"){f.warn(`non-number value provided to metric ${t._descriptor.name}: ${r}`);return}t._descriptor.valueType===X.INT&&!Number.isInteger(r)&&(f.warn(`INT value type cannot accept a floating-point value for ${t._descriptor.name}, ignoring the fractional digits.`),r=Math.trunc(r),!Number.isInteger(r))||s.set(n,r)}}class yl{constructor(){c(this,"_callbacks",[]);c(this,"_batchCallbacks",[])}addCallback(t,r){this._findCallback(t,r)>=0||this._callbacks.push({callback:t,instrument:r})}removeCallback(t,r){const n=this._findCallback(t,r);n<0||this._callbacks.splice(n,1)}addBatchCallback(t,r){const n=new Set(r.filter(xr));if(n.size===0){f.error("BatchObservableCallback is not associated with valid instruments",r);return}this._findBatchCallback(t,n)>=0||this._batchCallbacks.push({callback:t,instruments:n})}removeBatchCallback(t,r){const n=new Set(r.filter(xr)),s=this._findBatchCallback(t,n);s<0||this._batchCallbacks.splice(s,1)}async observe(t,r){const n=this._observeCallbacks(t,r),s=this._observeBatchCallbacks(t,r);return(await Promise.allSettled([...n,...s])).filter(a=>a.status==="rejected").map(a=>a.reason)}_observeCallbacks(t,r){return this._callbacks.map(async({callback:n,instrument:s})=>{const i=new Ol(s._descriptor.name,s._descriptor.valueType);let o=Promise.resolve(n(i));r!=null&&(o=Gt(o,r)),await o,s._metricStorages.forEach(a=>{a.record(i._buffer,t)})})}_observeBatchCallbacks(t,r){return this._batchCallbacks.map(async({callback:n,instruments:s})=>{const i=new Cl;let o=Promise.resolve(n(i));r!=null&&(o=Gt(o,r)),await o,s.forEach(a=>{const u=i._buffer.get(a);u!=null&&a._metricStorages.forEach(l=>{l.record(u,t)})})})}_findCallback(t,r){return this._callbacks.findIndex(n=>n.callback===t&&n.instrument===r)}_findBatchCallback(t,r){return this._batchCallbacks.findIndex(n=>n.callback===t&&Mu(n.instruments,r))}}class Pl extends fi{constructor(r,n,s,i,o){super(r);c(this,"_aggregationCardinalityLimit");c(this,"_deltaMetricStorage");c(this,"_temporalMetricStorage");c(this,"_attributesProcessor");c(this,"hasAttributeProcessor");this._aggregationCardinalityLimit=o,this._deltaMetricStorage=new mi(n,this._aggregationCardinalityLimit),this._temporalMetricStorage=new St(n,i),this._attributesProcessor=s,this.hasAttributeProcessor=s!==void 0}record(r,n,s,i){this._attributesProcessor!==void 0&&(n=this._attributesProcessor.process(n,s!=null?s:R.active())),this._deltaMetricStorage.record(r,n,i)}collect(r,n){const s=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(r,this._instrumentDescriptor,s,n)}}class Ml{constructor(t,r){c(this,"metricStorageRegistry",new hn);c(this,"observableRegistry",new yl);c(this,"meter");c(this,"_meterProviderSharedState");c(this,"_instrumentationScope");this.meter=new ml(this),this._meterProviderSharedState=t,this._instrumentationScope=r}registerMetricStorage(t){const r=this._registerMetricStorage(t,Pl);return r.length===1?r[0]:new wl(r)}registerAsyncMetricStorage(t){return this._registerMetricStorage(t,Tl)}async collect(t,r,n){const s=await this.observableRegistry.observe(r,n==null?void 0:n.timeoutMillis),i=this.metricStorageRegistry.getStorages(t);if(i.length===0)return null;const o=[];return i.forEach(a=>{const u=a.collect(t,r);u!=null&&o.push(u)}),o.length===0?{errors:s}:{scopeMetrics:{scope:this._instrumentationScope,metrics:o},errors:s}}_registerMetricStorage(t,r){let s=this._meterProviderSharedState.viewRegistry.findViews(t,this._instrumentationScope).map(i=>{const o=il(i,t),a=this.metricStorageRegistry.findOrUpdateCompatibleStorage(o);if(a!=null)return a;const u=i.aggregation.createAggregator(o),l=new r(o,u,i.attributesProcessor,this._meterProviderSharedState.metricCollectors,i.aggregationCardinalityLimit);return this.metricStorageRegistry.register(l),l});if(s.length===0){const o=this._meterProviderSharedState.selectAggregations(t.type).map(([a,u])=>{const l=this.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(a,t);if(l!=null)return l;const h=u.createAggregator(t),d=a.selectCardinalityLimit(t.type),p=new r(t,h,void 0,[a],d);return this.metricStorageRegistry.registerForCollector(a,p),p});s=s.concat(o)}return s}}class vl{constructor(t){c(this,"viewRegistry",new sl);c(this,"metricCollectors",[]);c(this,"meterSharedStates",new Map);c(this,"resource");this.resource=t}getMeterSharedState(t){const r=Pu(t);let n=this.meterSharedStates.get(r);return n==null&&(n=new Ml(this,t),this.meterSharedStates.set(r,n)),n}selectAggregations(t){const r=[];for(const n of this.metricCollectors)r.push([n,hi(n.selectAggregation(t))]);return r}}class Il{constructor(t,r){c(this,"_sharedState");c(this,"_metricReader");this._sharedState=t,this._metricReader=r}async collect(t){const r=N(Date.now()),n=[],s=[],i=Array.from(this._sharedState.meterSharedStates.values()).map(async o=>{const a=await o.collect(this,r,t);(a==null?void 0:a.scopeMetrics)!=null&&n.push(a.scopeMetrics),(a==null?void 0:a.errors)!=null&&s.push(...a.errors)});return await Promise.all(i),{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:n},errors:s}}async forceFlush(t){await this._metricReader.forceFlush(t)}async shutdown(t){await this._metricReader.shutdown(t)}selectAggregationTemporality(t){return this._metricReader.selectAggregationTemporality(t)}selectAggregation(t){return this._metricReader.selectAggregation(t)}selectCardinalityLimit(t){var r,n,s;return(s=(n=(r=this._metricReader).selectCardinalityLimit)==null?void 0:n.call(r,t))!=null?s:2e3}}const Nl=/[\^$\\.+?()[\]{}|]/g;class ye{constructor(t){c(this,"_matchAll");c(this,"_regexp");t==="*"?(this._matchAll=!0,this._regexp=/.*/):(this._matchAll=!1,this._regexp=new RegExp(ye.escapePattern(t)))}match(t){return this._matchAll?!0:this._regexp.test(t)}static escapePattern(t){return`^${t.replace(Nl,"\\$&").replace("*",".*")}$`}static hasWildcard(t){return t.includes("*")}}class _e{constructor(t){c(this,"_matchAll");c(this,"_pattern");this._matchAll=t===void 0,this._pattern=t}match(t){return!!(this._matchAll||t===this._pattern)}}class Ll{process(t,r){return t}}class xl{constructor(t){c(this,"_processors");this._processors=t}process(t,r){let n=t;for(const s of this._processors)n=s.process(n,r);return n}}function Ul(){return kl}function Dl(e){return new xl(e)}const kl=new Ll;class Bl{constructor(t){c(this,"_nameFilter");c(this,"_type");c(this,"_unitFilter");var r;this._nameFilter=new ye((r=t==null?void 0:t.name)!=null?r:"*"),this._type=t==null?void 0:t.type,this._unitFilter=new _e(t==null?void 0:t.unit)}getType(){return this._type}getNameFilter(){return this._nameFilter}getUnitFilter(){return this._unitFilter}}class Gl{constructor(t){c(this,"_nameFilter");c(this,"_versionFilter");c(this,"_schemaUrlFilter");this._nameFilter=new _e(t==null?void 0:t.name),this._versionFilter=new _e(t==null?void 0:t.version),this._schemaUrlFilter=new _e(t==null?void 0:t.schemaUrl)}getNameFilter(){return this._nameFilter}getVersionFilter(){return this._versionFilter}getSchemaUrlFilter(){return this._schemaUrlFilter}}function Fl(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}function $l(e){if(Fl(e))throw new Error("Cannot create view with no selector arguments supplied");if(e.name!=null&&((e==null?void 0:e.instrumentName)==null||ye.hasWildcard(e.instrumentName)))throw new Error("Views with a specified name must be declared with an instrument selector that selects at most one instrument per meter.")}class Vl{constructor(t){c(this,"name");c(this,"description");c(this,"aggregation");c(this,"attributesProcessor");c(this,"instrumentSelector");c(this,"meterSelector");c(this,"aggregationCardinalityLimit");var r;$l(t),t.attributesProcessors!=null?this.attributesProcessor=Dl(t.attributesProcessors):this.attributesProcessor=Ul(),this.name=t.name,this.description=t.description,this.aggregation=hi((r=t.aggregation)!=null?r:{type:B.DEFAULT}),this.instrumentSelector=new Bl({name:t.instrumentName,type:t.instrumentType,unit:t.instrumentUnit}),this.meterSelector=new Gl({name:t.meterName,version:t.meterVersion,schemaUrl:t.meterSchemaUrl}),this.aggregationCardinalityLimit=t.aggregationCardinalityLimit}}class Hl{constructor(t){c(this,"_sharedState");c(this,"_shutdown",!1);var r;if(this._sharedState=new vl((r=t==null?void 0:t.resource)!=null?r:ks()),(t==null?void 0:t.views)!=null&&t.views.length>0)for(const n of t.views)this._sharedState.viewRegistry.addView(new Vl(n));if((t==null?void 0:t.readers)!=null&&t.readers.length>0)for(const n of t.readers){const s=new Il(this._sharedState,n);n.setMetricProducer(s),this._sharedState.metricCollectors.push(s),t.sdkMetricsEnabled&&n instanceof pi&&n._setSelfObsMeterProvider(this)}}getMeter(t,r="",n={}){return this._shutdown?(f.warn("A shutdown MeterProvider cannot provide a Meter"),Mt()):this._sharedState.getMeterSharedState({name:t,version:r,schemaUrl:n.schemaUrl}).meter}async shutdown(t){if(this._shutdown){f.warn("shutdown may only be called once per MeterProvider");return}this._shutdown=!0,await Promise.all(this._sharedState.metricCollectors.map(r=>r.shutdown(t)))}async forceFlush(t){if(this._shutdown){f.warn("invalid attempt to force flush after MeterProvider shutdown");return}await Promise.all(this._sharedState.metricCollectors.map(r=>r.forceFlush(t)))}}class Ti{constructor(t){c(this,"_delegate");this._delegate=t}export(t,r){this._delegate.export(t,r)}forceFlush(){return this._delegate.forceFlush()}shutdown(){return this._delegate.shutdown()}setMetrics(t){this._delegate.setMetrics(t)}}class Si extends Error{constructor(r,n,s){super(r);c(this,"code");c(this,"name","OTLPExporterError");c(this,"data");this.data=s,this.code=n}}function zl(e){if(Number.isFinite(e)&&e>0)return e;throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${e}')`)}function jl(e){if(e!=null)return async()=>e}function ql(e,t,r){var n,s,i,o,a,u;return{timeoutMillis:zl((s=(n=e.timeoutMillis)!=null?n:t.timeoutMillis)!=null?s:r.timeoutMillis),concurrencyLimit:(o=(i=e.concurrencyLimit)!=null?i:t.concurrencyLimit)!=null?o:r.concurrencyLimit,compression:(u=(a=e.compression)!=null?a:t.compression)!=null?u:r.compression}}function Wl(){return{timeoutMillis:1e4,concurrencyLimit:30,compression:"none"}}class Xl{constructor(t){c(this,"_concurrencyLimit");c(this,"_sendingPromises",[]);this._concurrencyLimit=t}pushPromise(t){if(this.hasReachedLimit())throw new Error("Concurrency Limit reached");this._sendingPromises.push(t);const r=()=>{const n=this._sendingPromises.indexOf(t);this._sendingPromises.splice(n,1)};t.then(r,r)}hasReachedLimit(){return this._sendingPromises.length>=this._concurrencyLimit}async awaitAll(){await Promise.all(this._sendingPromises)}}function Yl(e){return new Xl(e.concurrencyLimit)}function Kl(e){return Object.prototype.hasOwnProperty.call(e,"partialSuccess")}function Ql(){return{handleResponse(e){e==null||!Kl(e)||e.partialSuccess==null||Object.keys(e.partialSuccess).length===0||f.warn("Received Partial Success response:",JSON.stringify(e.partialSuccess))}}}class Jl{constructor(t,r,n,s,i,o){c(this,"_metrics");c(this,"_diagLogger");c(this,"_transport");c(this,"_serializer");c(this,"_responseHandler");c(this,"_promiseQueue");c(this,"_timeout");this._transport=t,this._serializer=r,this._responseHandler=n,this._promiseQueue=s,this._timeout=o,this._diagLogger=f.createComponentLogger({namespace:"OTLPExportDelegate"}),this._metrics=i}export(t,r){if(this._diagLogger.debug("items to be sent",t),this._promiseQueue.hasReachedLimit()){r({code:D.FAILED,error:new Error("Concurrent export limit reached")});return}const n=this._serializer.serializeRequest(t);if(n==null){r({code:D.FAILED,error:new Error("Nothing to send")});return}const s=this._metrics.startExport(t);this._promiseQueue.pushPromise(this._transport.send(n,this._timeout).then(i=>{var o;if(i.status==="success"){if(s(void 0),i.data!=null)try{this._responseHandler.handleResponse(this._serializer.deserializeResponse(i.data))}catch(a){this._diagLogger.warn("Export succeeded but could not deserialize response - is the response specification compliant?",a,i.data)}r({code:D.SUCCESS});return}else if(i.status==="failure"&&i.error){s(i.error),r({code:D.FAILED,error:i.error});return}else i.status==="retryable"?(s("export_max_retries"),r({code:D.FAILED,error:(o=i.error)!=null?o:new Si("Export failed with retryable status")})):(s("export_failed"),r({code:D.FAILED,error:new Si("Export failed with unknown error")}))},i=>{s(i),r({code:D.FAILED,error:i})}))}forceFlush(){return this._promiseQueue.awaitAll()}setMetrics(t){this._metrics=t}async shutdown(){this._diagLogger.debug("shutdown started"),await this.forceFlush(),this._transport.shutdown()}}function Zl(e,t){return new Jl(e.transport,e.serializer,Ql(),e.promiseHandler,e.metrics,t.timeout)}function th(e,t,r,n){return Zl({transport:n,serializer:t,promiseHandler:Yl(e),metrics:r},{timeout:e.timeoutMillis})}const Ai="http.response.status_code",eh="otel.component.name",rh="otel.component.type",nh="server.address",sh="server.port",ih="error.type",oh="0.221.0",Ri=new Map;class ah{constructor(t){c(this,"inflight");c(this,"exported");c(this,"duration");c(this,"standardAttrs");c(this,"responseAttributesFromError");c(this,"helper");var l;const{componentType:r,metricsHelper:n,meterProvider:s,url:i,responseAttributesFromError:o}=t;this.responseAttributesFromError=o;const a=s?s.getMeter("@opentelemetry/otlp-exporter",oh):Mt(),u=(l=Ri.get(r))!=null?l:0;if(Ri.set(r,u+1),this.standardAttrs={[rh]:r,[eh]:`${r}/${u}`},i){let h=i;i.includes("://")||(h=`http://${i}`);try{const d=new URL(h);this.standardAttrs[nh]=d.hostname;let p;d.port?p=Number(d.port):d.protocol==="http:"?p=80:d.protocol==="https:"&&(p=443),typeof p=="number"&&(this.standardAttrs[sh]=p)}catch(d){}}this.helper=n,this.inflight=a.createUpDownCounter(`otel.sdk.exporter.${this.helper.name}.inflight`,{unit:`{${this.helper.name}}`,description:`The number of ${this.helper.name}s which were passed to the exporter, but that have not been exported yet (neither successful, nor failed).`}),this.exported=a.createCounter(`otel.sdk.exporter.${this.helper.name}.exported`,{unit:`{${this.helper.name}}`,description:`The number of ${this.helper.name}s for which the export has finished, either successful or failed.`}),this.duration=a.createHistogram("otel.sdk.exporter.operation.duration",{unit:"s",description:"The duration of exporting a batch of telemetry records.",advice:{explicitBucketBoundaries:[]}})}startExport(t){const r=this.helper.countItems(t),n=G();return this.inflight.add(r,this.standardAttrs),s=>{const i=G();this.inflight.add(-r,this.standardAttrs);const o=s?{...this.standardAttrs,[ih]:s instanceof Error?s.name:"export_failed"}:this.standardAttrs;this.exported.add(r,o);const a={...o,...this.responseAttributesFromError(s)},u=nc(pr(n,i))/1e3;this.duration.record(u,a)}}}const bi={name:"metric_data_point",countItems:e=>{let t=0;for(const r of e.scopeMetrics)for(const n of r.metrics)t+=n.dataPoints.length;return t}},ch={name:"span",countItems:e=>e.length};var wi;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.TRACE=1]="TRACE",e[e.TRACE2=2]="TRACE2",e[e.TRACE3=3]="TRACE3",e[e.TRACE4=4]="TRACE4",e[e.DEBUG=5]="DEBUG",e[e.DEBUG2=6]="DEBUG2",e[e.DEBUG3=7]="DEBUG3",e[e.DEBUG4=8]="DEBUG4",e[e.INFO=9]="INFO",e[e.INFO2=10]="INFO2",e[e.INFO3=11]="INFO3",e[e.INFO4=12]="INFO4",e[e.WARN=13]="WARN",e[e.WARN2=14]="WARN2",e[e.WARN3=15]="WARN3",e[e.WARN4=16]="WARN4",e[e.ERROR=17]="ERROR",e[e.ERROR2=18]="ERROR2",e[e.ERROR3=19]="ERROR3",e[e.ERROR4=20]="ERROR4",e[e.FATAL=21]="FATAL",e[e.FATAL2=22]="FATAL2",e[e.FATAL3=23]="FATAL3",e[e.FATAL4=24]="FATAL4"})(wi||(wi={}));class Oi{emit(t){}enabled(){return!1}}const uh=new Oi,pe=Symbol.for("io.opentelemetry.js.api.logs"),Vt=globalThis;function lh(e,t,r){return n=>n===e?t:r}const Ci=1;class hh{getLogger(t,r,n){return new Oi}}const yi=new hh;class dh{constructor(t,r,n,s){this._provider=t,this.name=r,this.version=n,this.options=s}emit(t){this._getLogger().emit(t)}enabled(t){return this._getLogger().enabled(t)}_getLogger(){if(this._delegate)return this._delegate;const t=this._provider._getDelegateLogger(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):uh}}class Pi{getLogger(t,r,n){var s;return(s=this._getDelegateLogger(t,r,n))!==null&&s!==void 0?s:new dh(this,t,r,n)}_getDelegate(){var t;return(t=this._delegate)!==null&&t!==void 0?t:yi}_setDelegate(t){this._delegate=t}_getDelegateLogger(t,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getLogger(t,r,n)}}class dn{constructor(){this._proxyLoggerProvider=new Pi}static getInstance(){return this._instance||(this._instance=new dn),this._instance}setGlobalLoggerProvider(t){return Vt[pe]?this.getLoggerProvider():(Vt[pe]=lh(Ci,t,yi),this._proxyLoggerProvider._setDelegate(t),t)}getLoggerProvider(){var t,r;return(r=(t=Vt[pe])===null||t===void 0?void 0:t.call(Vt,Ci))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(t,r,n){return this.getLoggerProvider().getLogger(t,r,n)}disable(){delete Vt[pe],this._proxyLoggerProvider=new Pi}}const Mi=dn.getInstance();function vi(e,t){const r={attributes:J(e.attributes,t),droppedAttributesCount:0},n=e.schemaUrl;return n&&n!==""&&(r.schemaUrl=n),r}function Ii(e,t){var n;const r={name:e.name,version:e.version};return e.attributes&&Object.keys(e.attributes).length>0&&(r.attributes=J(e.attributes,t),r.droppedAttributesCount=(n=e.droppedAttributesCount)!=null?n:0),r}function J(e,t){return Object.keys(e).map(r=>_h(r,e[r],t))}function _h(e,t,r){return{key:e,value:Ur(t,r)}}function Ur(e,t){const r=typeof e;if(r==="string")return{stringValue:e};if(r==="number")return Number.isInteger(e)?{intValue:e}:{doubleValue:e};if(r==="boolean")return{boolValue:e};if(e instanceof Uint8Array)return{bytesValue:t.encodeUint8Array(e)};if(Array.isArray(e)){const n=new Array(e.length);for(let s=0;s<e.length;s++)n[s]=Ur(e[s],t);return{arrayValue:{values:n}}}if(r==="object"&&e!=null){const n=Object.keys(e),s=new Array(n.length);for(let i=0;i<n.length;i++)s[i]={key:n[i],value:Ur(e[n[i]],t)};return{kvlistValue:{values:s}}}return{}}function ph(e){const t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}function fh(e){return ph(e).toString()}const mh=typeof BigInt<"u"?fh:q;function Ni(e){return e}const Li={encodeHrTime:mh,encodeSpanContext:Ni,encodeOptionalSpanContext:Ni,encodeUint8Array:e=>{if(typeof Buffer<"u")return Buffer.from(e).toString("base64");const t=new Array(e.length);for(let r=0;r<e.length;r++)t[r]=String.fromCharCode(e[r]);return btoa(t.join(""))}};var fe;(function(e){e[e.AGGREGATION_TEMPORALITY_UNSPECIFIED=0]="AGGREGATION_TEMPORALITY_UNSPECIFIED",e[e.AGGREGATION_TEMPORALITY_DELTA=1]="AGGREGATION_TEMPORALITY_DELTA",e[e.AGGREGATION_TEMPORALITY_CUMULATIVE=2]="AGGREGATION_TEMPORALITY_CUMULATIVE"})(fe||(fe={}));function gh(e,t){const r=vi(e.resource,t);return{resource:r,schemaUrl:r.schemaUrl,scopeMetrics:Eh(e.scopeMetrics,t)}}function Eh(e,t){return Array.from(e.map(r=>({scope:Ii(r.scope,t),metrics:r.metrics.map(n=>Th(n,t)),schemaUrl:r.scope.schemaUrl})))}function Th(e,t){const r={name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit},n=bh(e.aggregationTemporality);switch(e.dataPointType){case V.SUM:r.sum={aggregationTemporality:n,isMonotonic:e.isMonotonic,dataPoints:xi(e,t)};break;case V.GAUGE:r.gauge={dataPoints:xi(e,t)};break;case V.HISTOGRAM:r.histogram={aggregationTemporality:n,dataPoints:Ah(e,t)};break;case V.EXPONENTIAL_HISTOGRAM:r.exponentialHistogram={aggregationTemporality:n,dataPoints:Rh(e,t)};break}return r}function Sh(e,t,r){const n={attributes:J(e.attributes,r),startTimeUnixNano:r.encodeHrTime(e.startTime),timeUnixNano:r.encodeHrTime(e.endTime)};switch(t){case X.INT:n.asInt=e.value;break;case X.DOUBLE:n.asDouble=e.value;break}return n}function xi(e,t){return e.dataPoints.map(r=>Sh(r,e.descriptor.valueType,t))}function Ah(e,t){return e.dataPoints.map(r=>{const n=r.value;return{attributes:J(r.attributes,t),bucketCounts:n.buckets.counts,explicitBounds:n.buckets.boundaries,count:n.count,sum:n.sum,min:n.min,max:n.max,startTimeUnixNano:t.encodeHrTime(r.startTime),timeUnixNano:t.encodeHrTime(r.endTime)}})}function Rh(e,t){return e.dataPoints.map(r=>{const n=r.value;return{attributes:J(r.attributes,t),count:n.count,min:n.min,max:n.max,sum:n.sum,positive:{offset:n.positive.offset,bucketCounts:n.positive.bucketCounts},negative:{offset:n.negative.offset,bucketCounts:n.negative.bucketCounts},scale:n.scale,zeroCount:n.zeroCount,startTimeUnixNano:t.encodeHrTime(r.startTime),timeUnixNano:t.encodeHrTime(r.endTime)}})}function bh(e){switch(e){case k.DELTA:return fe.AGGREGATION_TEMPORALITY_DELTA;case k.CUMULATIVE:return fe.AGGREGATION_TEMPORALITY_CUMULATIVE}}function wh(e,t){return{resourceMetrics:e.map(r=>gh(r,t))}}const Oh={serializeRequest:e=>{const t=wh([e],Li);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};const t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(r){return f.warn(`Failed to parse metrics export response: ${r.message}. Returning empty response`),{}}}},Ch=256,yh=512;function Ui(e,t){let r=e&255|Ch;return t&&(r|=yh),r}function Ph(e,t){var i,o,a,u;const r=e.spanContext(),n=e.status,s=(i=e.parentSpanContext)!=null&&i.spanId?t.encodeSpanContext((o=e.parentSpanContext)==null?void 0:o.spanId):void 0;return{traceId:t.encodeSpanContext(r.traceId),spanId:t.encodeSpanContext(r.spanId),parentSpanId:s,traceState:(a=r.traceState)==null?void 0:a.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:J(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(l=>vh(l,t)),droppedEventsCount:e.droppedEventsCount,status:{code:n.code,message:n.message},links:e.links.map(l=>Mh(l,t)),droppedLinksCount:e.droppedLinksCount,flags:Ui(r.traceFlags,(u=e.parentSpanContext)==null?void 0:u.isRemote)}}function Mh(e,t){var r;return{attributes:e.attributes?J(e.attributes,t):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:(r=e.context.traceState)==null?void 0:r.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:Ui(e.context.traceFlags,e.context.isRemote)}}function vh(e,t){return{attributes:e.attributes?J(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Ih(e,t){return{resourceSpans:Lh(e,t)}}function Nh(e){const t=new Map;for(const r of e){let n=t.get(r.resource);n||(n=new Map,t.set(r.resource,n));const s=`${r.instrumentationScope.name}@${r.instrumentationScope.version||""}:${r.instrumentationScope.schemaUrl||""}`;let i=n.get(s);i||(i=[],n.set(s,i)),i.push(r)}return t}function Lh(e,t){const r=Nh(e),n=[],s=r.entries();let i=s.next();for(;!i.done;){const[o,a]=i.value,u=[],l=a.values();let h=l.next();for(;!h.done;){const _=h.value;if(_.length>0){const E=_.map(m=>Ph(m,t));u.push({scope:Ii(_[0].instrumentationScope,t),spans:E,schemaUrl:_[0].instrumentationScope.schemaUrl})}h=l.next()}const d=vi(o,t),p={resource:d,scopeSpans:u,schemaUrl:d.schemaUrl};n.push(p),i=s.next()}return n}const xh={serializeRequest:e=>{const t=Ih(e,Li);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};const t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(r){return f.warn(`Failed to parse trace export response: ${r.message}. Returning empty response`),{}}}},Dr=5,Uh=1e3,Dh=5e3,kh=1.5,Di=.2;function Bh(){return Math.random()*(2*Di)-Di}class Gh{constructor(t){c(this,"_transport");this._transport=t}retry(t,r,n){return new Promise((s,i)=>{setTimeout(()=>{this._transport.send(t,r).then(s,i)},n)})}async send(t,r){var a;let n=Dr,s=Uh;const i=Date.now()+r;let o=await this._transport.send(t,r);for(;o.status==="retryable"&&n>0;){n--;const u=Math.max(Math.min(s*(1+Bh()),Dh),0);s=s*kh;const l=(a=o.retryInMillis)!=null?a:u,h=i-Date.now();if(l>h)return f.info(`Export retry time ${Math.round(l)}ms exceeds remaining timeout ${Math.round(h)}ms, not retrying further.`),o;f.verbose(`Scheduling export retry in ${Math.round(l)}ms`),o=await this.retry(t,h,l)}return o.status==="success"?f.verbose(`Export succeeded after ${Dr-n} retry attempts.`):o.status==="retryable"?f.info(`Export failed after maximum retry attempts (${Dr}).`):f.info(`Export failed with non-retryable error: ${o.error}`),o}shutdown(){return this._transport.shutdown()}}function Fh(e){return new Gh(e.transport)}function $h(e){return e===429||e===502||e===503||e===504}function Vh(e){if(e==null)return;const t=Number.parseInt(e,10);if(Number.isInteger(t))return t>0?t*1e3:-1;const r=new Date(e).getTime()-Date.now();return r>=0?r:0}const Hh=60*1024,zh=9;let kr=0,me=0;class jh{constructor(t){c(this,"_parameters");this._parameters=t}async send(t,r){const n=new AbortController,s=setTimeout(()=>n.abort(),r);let i=globalThis.fetch;typeof i.__original=="function"&&(i=i.__original);const o=t.byteLength,a=kr+o>Hh,u=me>=zh,l=!a&&!u;if(l)kr+=o,me++;else{const h=a?"size limit":"count limit";f.debug(`keepalive disabled: ${(o/1024).toFixed(1)}KB payload, ${me} pending (${h})`)}try{const h=new URL(this._parameters.url),d=await i(h.href,{method:"POST",headers:await this._parameters.headers(),body:t,signal:n.signal,keepalive:l,mode:globalThis.location?globalThis.location.origin===h.origin?"same-origin":"cors":"no-cors"});if(d.status>=200&&d.status<=299)return f.debug(`export response success (status: ${d.status})`),{status:"success"};if($h(d.status)){f.warn(`export response retryable (status: ${d.status})`);const p=d.headers.get("Retry-After");return{status:"retryable",retryInMillis:Vh(p)}}return f.error(`export response failure (status: ${d.status})`),{status:"failure",error:new Error(`Fetch request failed with non-retryable status ${d.status}`)}}catch(h){return Wh(h)?(f.warn(`export request retryable (network error: ${h})`),{status:"retryable",error:new Error("Fetch request encountered a network error",{cause:h})}):(f.error(`export request failure (error: ${h})`),{status:"failure",error:new Error("Fetch request errored",{cause:h})})}finally{clearTimeout(s),l&&(kr-=o,me--)}}shutdown(){}}function qh(e){return new jh(e)}function Wh(e){return e instanceof TypeError&&!e.cause}function Xh(e,t,r){return th(e,t,r,Fh({transport:qh(e)}))}function Yh(e){const t={};return Object.entries(e!=null?e:{}).forEach(([r,n])=>{typeof n<"u"?t[r]=String(n):f.warn(`Header "${r}" has invalid value (${n}) and will be ignored`)}),t}function Kh(e,t,r){return async()=>{const n={...await r()},s={};return t!=null&&Object.assign(s,await t()),e!=null&&Object.assign(s,Yh(await e())),Object.assign(s,n)}}function Qh(e){var t;if(e!=null)try{const r=(t=globalThis.location)==null?void 0:t.href;return new URL(e,r).href}catch(r){throw new Error(`Configuration: Could not parse user-provided export URL: '${e}'`)}}function Jh(e,t,r){var n,s;return{...ql(e,t,r),headers:Kh(e.headers,t.headers,r.headers),url:(s=(n=Qh(e.url))!=null?n:t.url)!=null?s:r.url}}function Zh(e,t){return{...Wl(),headers:async()=>e,url:"http://localhost:4318/"+t}}function td(e){return typeof e.headers=="function"?e.headers:jl(e.headers)}function ed(e,t,r){return Jh({url:e.url,timeoutMillis:e.timeoutMillis,headers:td(e),concurrencyLimit:e.concurrencyLimit},{},Zh(r,t))}function ki(e,t,r,n){return new ah({componentType:e,metricsHelper:t,url:r,meterProvider:n,responseAttributesFromError:s=>{if(!s)return{[Ai]:200};if(!(s instanceof Error))return{};if(s.message.startsWith("Fetch request failed with non-retryable status ")){const i=s.message.substring(47);return{[Ai]:Number(i)}}return{}}})}function Bi(e,t,r,n,s,i,o){const a=ed(e,i,o);return Xh(a,t,ki(r,n,a.url,e.selfObsMeterProvider))}const rd="otlp_http_span_exporter";class nd extends Ti{constructor(t={}){super(Bi(t,xh,rd,ch,t.selfObsMeterProvider,"v1/traces",{"Content-Type":"application/json"}))}}var ge;(function(e){e[e.DELTA=0]="DELTA",e[e.CUMULATIVE=1]="CUMULATIVE",e[e.LOWMEMORY=2]="LOWMEMORY"})(ge||(ge={}));const Br=()=>k.CUMULATIVE,Gi=e=>{switch(e){case g.COUNTER:case g.OBSERVABLE_COUNTER:case g.GAUGE:case g.HISTOGRAM:case g.OBSERVABLE_GAUGE:return k.DELTA;case g.UP_DOWN_COUNTER:case g.OBSERVABLE_UP_DOWN_COUNTER:return k.CUMULATIVE}},Fi=e=>{switch(e){case g.COUNTER:case g.HISTOGRAM:return k.DELTA;case g.GAUGE:case g.UP_DOWN_COUNTER:case g.OBSERVABLE_UP_DOWN_COUNTER:case g.OBSERVABLE_COUNTER:case g.OBSERVABLE_GAUGE:return k.CUMULATIVE}};function sd(){const e="cumulative".toLowerCase();return e==="cumulative"?Br:e==="delta"?Gi:e==="lowmemory"?Fi:(f.warn(`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '${e}', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead.`),Br)}function id(e){return e!=null?e===ge.DELTA?Gi:e===ge.LOWMEMORY?Fi:Br:sd()}const od=Object.freeze({type:B.DEFAULT});function ad(e){var t;return(t=e==null?void 0:e.aggregationPreference)!=null?t:(()=>od)}class cd extends Ti{constructor(r,n){super(r);c(this,"_aggregationTemporalitySelector");c(this,"_aggregationSelector");this._aggregationSelector=ad(n),this._aggregationTemporalitySelector=id(n==null?void 0:n.temporalityPreference)}selectAggregation(r){return this._aggregationSelector(r)}selectAggregationTemporality(r){return this._aggregationTemporalitySelector(r)}}const $i="otlp_http_metric_exporter";class ud extends cd{constructor(r){super(Bi(r!=null?r:{},Oh,$i,bi,r==null?void 0:r.selfObsMeterProvider,"v1/metrics",{"Content-Type":"application/json"}),r);c(this,"_url");this._url=r==null?void 0:r.url}setSelfObsMeterProvider(r){this.setMetrics(ki($i,bi,this._url,r))}}function ld(e,t,r,n){for(let s=0,i=e.length;s<i;s++){const o=e[s];t&&o.setTracerProvider(t),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function hd(e){e.forEach(t=>t.disable())}function dd(e){var i,o;const t=e.tracerProvider||w.getTracerProvider(),r=e.meterProvider||rr.getMeterProvider(),n=e.loggerProvider||Mi.getLoggerProvider(),s=(o=(i=e.instrumentations)==null?void 0:i.flat())!=null?o:[];return ld(s,t,r,n),()=>{hd(s)}}let v=console.error.bind(console);function Ht(e,t,r){const n=!!e[t]&&Object.prototype.propertyIsEnumerable.call(e,t);Object.defineProperty(e,t,{configurable:!0,enumerable:n,writable:!0,value:r})}const Vi=(e,t,r)=>{if(!e||!e[t]){v("no original function "+String(t)+" to wrap");return}if(!r){v("no wrapper function"),v(new Error().stack);return}const n=e[t];if(typeof n!="function"||typeof r!="function"){v("original object and wrapper must be functions");return}const s=r(n,t);return Ht(s,"__original",n),Ht(s,"__unwrap",()=>{e[t]===s&&Ht(e,t,n)}),Ht(s,"__wrapped",!0),Ht(e,t,s),s},_d=(e,t,r)=>{if(e)Array.isArray(e)||(e=[e]);else{v("must provide one or more modules to patch"),v(new Error().stack);return}if(!(t&&Array.isArray(t))){v("must provide one or more functions to wrap on modules");return}e.forEach(n=>{t.forEach(s=>{Vi(n,s,r)})})},Hi=(e,t)=>{if(!e||!e[t]){v("no function to unwrap."),v(new Error().stack);return}const r=e[t];if(!r.__unwrap)v("no original to unwrap to -- has "+String(t)+" already been unwrapped?");else{r.__unwrap();return}},pd=(e,t)=>{if(e)Array.isArray(e)||(e=[e]);else{v("must provide one or more modules to patch"),v(new Error().stack);return}if(!(t&&Array.isArray(t))){v("must provide one or more functions to unwrap on modules");return}e.forEach(r=>{t.forEach(n=>{Hi(r,n)})})};class fd{constructor(t,r,n){c(this,"_config",{});c(this,"_tracer");c(this,"_meter");c(this,"_logger");c(this,"_diag");c(this,"instrumentationName");c(this,"instrumentationVersion");c(this,"_wrap",Vi);c(this,"_unwrap",Hi);c(this,"_massWrap",_d);c(this,"_massUnwrap",pd);this.instrumentationName=t,this.instrumentationVersion=r,this.setConfig(n),this._diag=f.createComponentLogger({namespace:t}),this._tracer=w.getTracer(t,r),this._meter=rr.getMeter(t,r),this._logger=Mi.getLogger(t,r),this._updateMetricInstruments()}get meter(){return this._meter}setMeterProvider(t){this._meter=t.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}get logger(){return this._logger}setLoggerProvider(t){this._logger=t.getLogger(this.instrumentationName,this.instrumentationVersion)}getModuleDefinitions(){var r;const t=(r=this.init())!=null?r:[];return Array.isArray(t)?t:[t]}_updateMetricInstruments(){}getConfig(){return this._config}setConfig(t){this._config={enabled:!0,...t}}setTracerProvider(t){this._tracer=t.getTracer(this.instrumentationName,this.instrumentationVersion)}get tracer(){return this._tracer}_runSpanCustomizationHook(t,r,n,s){if(t)try{t(n,s)}catch(i){this._diag.error("Error running span customization hook due to exception in handler",{triggerName:r},i)}}}class Gr extends fd{constructor(t,r,n){super(t,r,n),this._config.enabled&&this.enable()}}function zt(e,t,r){let n,s;try{s=e()}catch(i){n=i}finally{return t(n,s),s}}var jt;(function(e){e.DOCUMENT_LOAD="documentLoad",e.DOCUMENT_FETCH="documentFetch",e.RESOURCE_FETCH="resourceFetch"})(jt||(jt={}));const md="0.66.0",gd="@opentelemetry/instrumentation-document-load";var Ee;(function(e){e.FIRST_PAINT="firstPaint",e.FIRST_CONTENTFUL_PAINT="firstContentfulPaint"})(Ee||(Ee={}));const Ed=()=>{var r;const e={},t=(r=O.getEntriesByType)==null?void 0:r.call(O,"navigation")[0];if(t)Object.values(S).forEach(s=>{if(dt(t,s)){const i=t[s];typeof i=="number"&&(e[s]=i)}});else{const s=O.timing;s&&Object.values(S).forEach(o=>{if(dt(s,o)){const a=s[o];typeof a=="number"&&(e[o]=a)}})}return e},zi={"first-paint":Ee.FIRST_PAINT,"first-contentful-paint":Ee.FIRST_CONTENTFUL_PAINT},Td=e=>{var r;const t=(r=O.getEntriesByType)==null?void 0:r.call(O,"paint");t&&t.forEach(({name:n,startTime:s})=>{dt(zi,n)&&e.addEvent(zi[n],s)})};class Sd extends Gr{constructor(r={}){super(gd,md,r);c(this,"component","document-load");c(this,"version","1");c(this,"moduleName",this.component)}init(){}_onDocumentLoaded(){window.setTimeout(()=>{this._collectPerformance()})}_addResourcesSpans(r){var s;const n=(s=O.getEntriesByType)==null?void 0:s.call(O,"resource");n&&n.forEach(i=>{this._initResourceSpan(i,r)})}_collectPerformance(){const r=Array.from(document.getElementsByTagName("meta")).find(i=>i.getAttribute("name")===oe),n=Ed(),s=r&&r.content||"";R.with(U.extract(et,{traceparent:s}),()=>{var o;const i=this._startSpan(jt.DOCUMENT_LOAD,S.FETCH_START,n);i&&(R.with(w.setSpan(R.active(),i),()=>{const a=this._startSpan(jt.DOCUMENT_FETCH,S.FETCH_START,n);a&&(a.setAttribute(xt,location.href),R.with(w.setSpan(R.active(),a),()=>{var u;_t(a,n,this.getConfig().ignoreNetworkEvents),this._addCustomAttributesOnSpan(a,(u=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:u.documentFetch),this._endSpan(a,S.RESPONSE_END,n)}))}),i.setAttribute(xt,location.href),i.setAttribute(Ja,navigator.userAgent),this._addResourcesSpans(i),this.getConfig().ignoreNetworkEvents||(C(i,S.FETCH_START,n),C(i,S.UNLOAD_EVENT_START,n),C(i,S.UNLOAD_EVENT_END,n),C(i,S.DOM_INTERACTIVE,n),C(i,S.DOM_CONTENT_LOADED_EVENT_START,n),C(i,S.DOM_CONTENT_LOADED_EVENT_END,n),C(i,S.DOM_COMPLETE,n),C(i,S.LOAD_EVENT_START,n),C(i,S.LOAD_EVENT_END,n)),this.getConfig().ignorePerformancePaintEvents||Td(i),this._addCustomAttributesOnSpan(i,(o=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:o.documentLoad),this._endSpan(i,S.LOAD_EVENT_END,n))})}_endSpan(r,n,s){r&&(dt(s,n)?r.end(s[n]):r.end())}_initResourceSpan(r,n){var i;const s=this._startSpan(jt.RESOURCE_FETCH,S.FETCH_START,r,n);s&&(s.setAttribute(xt,r.name),_t(s,r,this.getConfig().ignoreNetworkEvents),this._addCustomAttributesOnResourceSpan(s,r,(i=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:i.resourceFetch),this._endSpan(s,S.RESPONSE_END,r))}_startSpan(r,n,s,i){if(dt(s,n)&&typeof s[n]=="number")return this.tracer.startSpan(r,{startTime:s[n]},i?w.setSpan(R.active(),i):void 0)}_waitForPageLoad(){window.document.readyState==="complete"?this._onDocumentLoaded():(this._onDocumentLoaded=this._onDocumentLoaded.bind(this),window.addEventListener("load",this._onDocumentLoaded))}_addCustomAttributesOnSpan(r,n){n&&zt(()=>n(r),s=>{s&&this._diag.error("addCustomAttributesOnSpan",s)})}_addCustomAttributesOnResourceSpan(r,n,s){s&&zt(()=>s(r,n),i=>{i&&this._diag.error("addCustomAttributesOnResourceSpan",i)})}enable(){window.removeEventListener("load",this._onDocumentLoaded),this._waitForPageLoad()}disable(){window.removeEventListener("load",this._onDocumentLoaded)}}const Ad="http.request.body.size",ji=f.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-fetch/utils"});function Rd(...e){if(e[0]instanceof URL||typeof e[0]=="string"){const t=e[1];if(!(t!=null&&t.body))return Promise.resolve();if(t.body instanceof ReadableStream){const{body:r,length:n}=bd(t.body);return t.body=r,n}else return Promise.resolve(Od(t.body))}else{const t=e[0];return t!=null&&t.body?t.clone().text().then(r=>Fr(r)):Promise.resolve()}}function bd(e){if(!e.pipeThrough)return ji.warn("Platform has ReadableStream but not pipeThrough!"),{body:e,length:Promise.resolve(void 0)};let t=0,r;const n=new Promise(i=>{r=i}),s=new TransformStream({start(){},async transform(i,o){const a=await i;t+=a.byteLength,o.enqueue(i)},flush(){r(t)}});return{body:e.pipeThrough(s),length:n}}function wd(e){return typeof Document<"u"&&e instanceof Document}function Od(e){if(wd(e))return new XMLSerializer().serializeToString(document).length;if(typeof e=="string")return Fr(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return yd(e);if(e instanceof URLSearchParams)return Fr(e.toString());if(e.byteLength!==void 0)return e.byteLength;ji.warn("unknown body type")}const Cd=new TextEncoder;function Fr(e){return Cd.encode(e).byteLength}function yd(e){let t=0;for(const[r,n]of e.entries())t+=r.length,n instanceof Blob?t+=n.size:t+=n.length;return t}function Pd(e){const t=vd(),r=e.toUpperCase();return r in t?r:"_OTHER"}const Md={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let $r;function vd(){return $r===void 0&&($r=Md),$r}const Id={"https:":"443","http:":"80"};function Nd(e){const t=Number(e.port||Id[e.protocol]);if(t&&!isNaN(t))return t}const qi="0.221.0",Ld=300,Wi=typeof PerformanceObserver<"u";class xd extends Gr{constructor(r={}){super("@opentelemetry/instrumentation-fetch",qi,r);c(this,"component","fetch");c(this,"version",qi);c(this,"moduleName",this.component);c(this,"_usedResources",new WeakSet);c(this,"_tasksCount",0)}init(){}_addChildSpan(r,n){const s=this.tracer.startSpan("CORS Preflight",{startTime:n[S.FETCH_START]},w.setSpan(R.active(),r));_t(s,n,this.getConfig().ignoreNetworkEvents,void 0,!0),s.end(n[S.RESPONSE_END])}_addFinalSpanAttributes(r,n){const s=K(n.url);r.setAttribute(ps,n.status),r.setAttribute(fs,s.hostname);const i=Nd(s);i&&r.setAttribute(ms,i)}_addHeaders(r,n){if(!Ys(n,this.getConfig().propagateTraceHeaderCorsUrls)){const s={};U.inject(R.active(),s),Object.keys(s).length>0&&this._diag.debug("headers inject skipped due to CORS policy");return}if(r instanceof Request)U.inject(R.active(),r.headers,{set:(s,i,o)=>s.set(i,typeof o=="string"?o:String(o))});else{const s=new Headers(r.headers);U.inject(R.active(),s,{set:(i,o,a)=>i.set(o,typeof a=="string"?a:String(a))}),r.headers=s}}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(performance.clearResourceTimings(),this._usedResources=new WeakSet)}_createSpan(r,n={}){if(Us(r,this.getConfig().ignoreUrls)){this._diag.debug("ignoring span as url matches ignored url");return}const s={},i=n.method,o=Pd(n.method||"GET"),a=o;return s[ds]=o,o!==i&&(s[_s]=i),s[xt]=r,this.tracer.startSpan(a,{kind:It.CLIENT,attributes:s})}_findResourceAndAddNetworkEvents(r,n,s){let i=n.entries;if(!i.length){if(!performance.getEntriesByType)return;i=performance.getEntriesByType("resource")}const o=Xs(n.spanUrl,n.startTime,s,i,this._usedResources,"fetch");if(o.mainRequest){const a=o.mainRequest;this._markResourceAsUsed(a);const u=o.corsPreFlightRequest;u&&(this._addChildSpan(r,u),this._markResourceAsUsed(u)),_t(r,a,this.getConfig().ignoreNetworkEvents,void 0,!0)}}_markResourceAsUsed(r){this._usedResources.add(r)}_endSpan(r,n,s){const i=N(Date.now()),o=G();this._addFinalSpanAttributes(r,s),s.status>=400&&(r.setStatus({code:j.ERROR}),r.setAttribute(Lt,String(s.status))),setTimeout(()=>{var a;(a=n.observer)==null||a.disconnect(),this._findResourceAndAddNetworkEvents(r,n,o),this._tasksCount--,this._clearResources(),r.end(i)},Ld)}_patchConstructor(){return r=>{const n=this;return function(...i){if(!n._isEnabled)return r.apply(this,i);const o=this,a=K(i[0]instanceof Request?i[0].url:String(i[0])).href;let u;i[0]instanceof Request?u=i[1]!=null?new Request(i[0],i[1]):i[0]:u=i[1]||{};const l=n._createSpan(a,u);if(!l)return r.apply(this,i);const h=n._prepareSpanData(a);n.getConfig().measureRequestSize&&Rd(...i).then(m=>{m&&l.setAttribute(Ad,m)}).catch(m=>{n._diag.warn("getFetchBodyLength",m)});function d(m,T){n._applyAttributesAfterFetch(m,u,T),n._endSpan(m,h,{status:T.status||0,statusText:T.message,url:a})}function p(m,T){n._applyAttributesAfterFetch(m,u,T),T.status>=200&&T.status<400?n._endSpan(m,h,T):n._endSpan(m,h,{status:T.status,statusText:T.statusText,url:a})}function _(m,T){try{const M=T.clone().body;if(M){const y=M.getReader(),At=()=>{y.read().then(({done:ut})=>{ut?p(m,T):At()},ut=>{d(m,ut)})};At()}else p(m,T)}catch(A){n._diag.error("Failed to read fetch response body",A),n._endSpan(m,h,{status:0,url:a})}return T}function E(m,T){try{d(m,T)}catch(A){n._diag.error("Failed to end span on fetch error",A),n._endSpan(m,h,{status:T.status||0,url:a})}throw T}return R.with(w.setSpan(R.active(),l),()=>(n._callRequestHook(l,u),n._addHeaders(u,a),n._tasksCount++,r.apply(o,u instanceof Request?[u]:[a,u]).then(_.bind(o,l),E.bind(o,l))))}}}_applyAttributesAfterFetch(r,n,s){const i=this.getConfig().applyCustomAttributesOnSpan;i&&zt(()=>i(r,n,s),o=>{o&&this._diag.error("applyCustomAttributesOnSpan",o)})}_callRequestHook(r,n){const s=this.getConfig().requestHook;s&&zt(()=>s(r,n),i=>{i&&this._diag.error("requestHook",i)})}_prepareSpanData(r){const n=G(),s=[];if(typeof PerformanceObserver!="function")return{entries:s,startTime:n,spanUrl:r};const i=new PerformanceObserver(o=>{o.getEntries().forEach(u=>{u.initiatorType==="fetch"&&u.name===r&&s.push(u)})});return i.observe({entryTypes:["resource"]}),{entries:s,observer:i,startTime:n,spanUrl:r}}enable(){if(!Wi){this._diag.warn("this instrumentation is intended for web usage only, it does not instrument server-side fetch()");return}if(!this._isEnabled){if(this._isFetchPatched){this._diag.debug("fetch constructor already patched"),this._isEnabled=!0;return}try{this._wrap(globalThis,"fetch",this._patchConstructor()),this._isFetchPatched=!0,this._isEnabled=!0}catch(r){this._diag.warn("Failed to patch globalThis.fetch; instrumentation will not be enabled. Another script may have locked globalThis.fetch via Object.defineProperty.",r)}}}disable(){Wi&&this._isEnabled&&(this._isEnabled=!1,this._usedResources=new WeakSet)}}const Ud="http.request.body.size";var W;(function(e){e.METHOD_OPEN="open",e.METHOD_SEND="send",e.EVENT_ABORT="abort",e.EVENT_ERROR="error",e.EVENT_LOAD="loaded",e.EVENT_TIMEOUT="timeout"})(W||(W={}));const Dd=f.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils"});function kd(e){return typeof Document<"u"&&e instanceof Document}function Bd(e){if(kd(e))return new XMLSerializer().serializeToString(document).length;if(typeof e=="string")return Xi(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return Fd(e);if(e instanceof URLSearchParams)return Xi(e.toString());if(e.byteLength!==void 0)return e.byteLength;Dd.warn("unknown body type")}const Gd=new TextEncoder;function Xi(e){return Gd.encode(e).byteLength}function Fd(e){let t=0;for(const[r,n]of e.entries())t+=r.length,n instanceof Blob?t+=n.size:t+=n.length;return t}function $d(e){const t=Hd(),r=e.toUpperCase();return r in t?r:"_OTHER"}const Vd={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let Vr;function Hd(){return Vr===void 0&&(Vr=Vd),Vr}const zd={"https:":"443","http:":"80"};function jd(e){const t=Number(e.port||zd[e.protocol]);if(t&&!isNaN(t))return t}const Yi="0.221.0",qd=300;class Wd extends Gr{constructor(r={}){super("@opentelemetry/instrumentation-xml-http-request",Yi,r);c(this,"component","xml-http-request");c(this,"version",Yi);c(this,"moduleName",this.component);c(this,"_tasksCount",0);c(this,"_xhrMem",new WeakMap);c(this,"_usedResources",new WeakSet)}init(){}_addHeaders(r,n){const s=K(n).href;if(!Ys(s,this.getConfig().propagateTraceHeaderCorsUrls)){const o={};U.inject(R.active(),o),Object.keys(o).length>0&&this._diag.debug("headers inject skipped due to CORS policy");return}const i={};U.inject(R.active(),i),Object.keys(i).forEach(o=>{r.setRequestHeader(o,String(i[o]))})}_addChildSpan(r,n){R.with(w.setSpan(R.active(),r),()=>{const s=this.tracer.startSpan("CORS Preflight",{startTime:n[S.FETCH_START]});_t(s,n,this.getConfig().ignoreNetworkEvents,void 0,!0),s.end(n[S.RESPONSE_END])})}_addFinalSpanAttributes(r,n){n.status&&r.setAttribute(ps,n.status)}_applyAttributesAfterXHR(r,n){const s=this.getConfig().applyCustomAttributesOnSpan;typeof s=="function"&&zt(()=>s(r,n),i=>{i&&this._diag.error("applyCustomAttributesOnSpan",i)})}_addResourceObserver(r,n){const s=this._xhrMem.get(r);!s||typeof PerformanceObserver!="function"||typeof PerformanceResourceTiming!="function"||(s.createdResources={observer:new PerformanceObserver(i=>{const o=i.getEntries(),a=K(n);o.forEach(u=>{u.initiatorType==="xmlhttprequest"&&u.name===a.href&&s.createdResources&&s.createdResources.entries.push(u)})}),entries:[]},s.createdResources.observer.observe({entryTypes:["resource"]}))}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(O.clearResourceTimings(),this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}_findResourceAndAddNetworkEvents(r,n,s,i,o){if(!s||!i||!o||!r.createdResources)return;let a=r.createdResources.entries;(!a||!a.length)&&(a=O.getEntriesByType("resource"));const u=Xs(K(s).href,i,o,a,this._usedResources);if(u.mainRequest){const l=u.mainRequest;this._markResourceAsUsed(l);const h=u.corsPreFlightRequest;h&&(this._addChildSpan(n,h),this._markResourceAsUsed(h)),_t(n,l,this.getConfig().ignoreNetworkEvents,void 0,!0)}}_cleanPreviousSpanInformation(r){const n=this._xhrMem.get(r);if(n){const s=n.callbackToRemoveEvents;s&&s(),this._xhrMem.delete(r)}}_createSpan(r,n,s){const i=K(n);if(Us(i.href,this.getConfig().ignoreUrls)){this._diag.debug("ignoring span as url matches ignored url");return}const o={},a=s,u=$d(s),l=u;o[ds]=u,u!==a&&(o[_s]=a),o[xt]=i.toString(),o[fs]=i.hostname;const h=jd(i);h&&(o[ms]=h);const d=this.tracer.startSpan(l,{kind:It.CLIENT,attributes:o});return d.addEvent(W.METHOD_OPEN),this._cleanPreviousSpanInformation(r),this._xhrMem.set(r,{span:d,spanUrl:n}),d}_markResourceAsUsed(r){this._usedResources.add(r)}_patchOpen(){return r=>{const n=this;return function(...i){if(!n._isEnabled)return r.apply(this,i);const o=i[0],a=i[1];return n._createSpan(this,a,o),r.apply(this,i)}}}_patchSend(){const r=this;function n(h,d,p,_){const E=d.callbackToRemoveEvents;typeof E=="function"&&E();const{span:m,spanUrl:T,sendStartTime:A}=d;m&&(r._findResourceAndAddNetworkEvents(d,m,T,A,p),m.addEvent(h,_),r._addFinalSpanAttributes(m,d),m.end(_),r._tasksCount--),r._clearResources()}function s(h,d,p,_){const E=r._xhrMem.get(d);if(!E)return;if(E.status=d.status,E.statusText=d.statusText,r._xhrMem.delete(d),E.span){const A=E.span;r._applyAttributesAfterXHR(A,d),p?_&&(A.setStatus({code:j.ERROR,message:_}),A.setAttribute(Lt,_)):E.status&&E.status>=400&&(A.setStatus({code:j.ERROR}),A.setAttribute(Lt,String(E.status)))}const m=G(),T=Date.now();setTimeout(()=>{n(h,E,m,T)},qd)}function i(){s(W.EVENT_ERROR,this,!0,"error")}function o(){s(W.EVENT_ABORT,this,!1)}function a(){s(W.EVENT_TIMEOUT,this,!0,"timeout")}function u(){this.status<299?s(W.EVENT_LOAD,this,!1):s(W.EVENT_ERROR,this,!1)}function l(h){h.removeEventListener("abort",o),h.removeEventListener("error",i),h.removeEventListener("load",u),h.removeEventListener("timeout",a);const d=r._xhrMem.get(h);d&&(d.callbackToRemoveEvents=void 0)}return h=>function(...p){if(!r._isEnabled)return h.apply(this,p);const _=r._xhrMem.get(this);if(!_)return h.apply(this,p);const E=_.span,m=_.spanUrl;if(E&&m){if(r.getConfig().measureRequestSize&&(p!=null&&p[0])){const T=p[0],A=Bd(T);A!==void 0&&E.setAttribute(Ud,A)}R.with(w.setSpan(R.active(),E),()=>{r._tasksCount++,_.sendStartTime=G(),E.addEvent(W.METHOD_SEND),this.addEventListener("abort",o),this.addEventListener("error",i),this.addEventListener("load",u),this.addEventListener("timeout",a),_.callbackToRemoveEvents=()=>{l(this),_.createdResources&&_.createdResources.observer.disconnect()},r._addHeaders(this,m),r._addResourceObserver(this,m)})}return h.apply(this,p)}}enable(){if(!this._isEnabled){if(this._isXhrPatched){this._diag.debug("reactivating existing patch on",this.moduleName,this.version),this._isEnabled=!0;return}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(r){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.",r)}}}disable(){this._isEnabled&&(this._isEnabled=!1,this._tasksCount=0,this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}}let Ki=-1;const pt=()=>Ki,ft=e=>{addEventListener("pageshow",t=>{t.persisted&&(Ki=t.timeStamp,e(t))},!0)},I=(e,t,r,n)=>{let s,i;return o=>{t.value>=0&&(o||n)&&(i=t.value-(s!=null?s:0),(i||s===void 0)&&(s=t.value,t.delta=i,t.rating=((a,u)=>a>u[1]?"poor":a>u[0]?"needs-improvement":"good")(t.value,r),e(t)))}},Hr=e=>{requestAnimationFrame(()=>requestAnimationFrame(e))},zr=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},qt=()=>{var e,t;return(t=(e=zr())==null?void 0:e.activationStart)!=null?t:0};let at=-1;const Qi=new Set,Ji=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,jr=e=>{if(document.visibilityState==="hidden"){if(e.type==="visibilitychange")for(const t of Qi)t();isFinite(at)||(at=e.type==="visibilitychange"?e.timeStamp:0,removeEventListener("prerenderingchange",jr,!0))}},Wt=(e=!1)=>{var t;if(e&&(at=1/0),at<0){const r=qt(),n=document.prerendering||(t=globalThis.performance.getEntriesByType("visibility-state").find(s=>s.name==="hidden"&&s.startTime>=r))==null?void 0:t.startTime;at=n!=null?n:Ji(),addEventListener("visibilitychange",jr,!0),addEventListener("prerenderingchange",jr,!0),ft(()=>{setTimeout(()=>{at=Ji()})})}return{get firstHiddenTime(){return at},onHidden(r){Qi.add(r)}}},L=(e,t=-1,r,n=0,s,i,o)=>{const a=zr(),u=(a==null?void 0:a.navigationId)||0;let l="navigate";return r?l=r:pt()>=0?l="back-forward-cache":a&&(document.prerendering||qt()>0?l="prerender":document.wasDiscarded?l="restore":a.type&&(l=a.type.replace(/_/g,"-"))),{name:e,value:t,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:l,navigationId:n||u,navigationInteractionId:s,navigationURL:i||(a==null?void 0:a.name),navigationStartTime:o||0}},Zi=new WeakMap;function Te(e,t){let r=Zi.get(t);return r||(r=new WeakMap,Zi.set(t,r)),r.get(e)||r.set(e,new t),r.get(e)}class Xd{constructor(){c(this,"t");c(this,"i",0);c(this,"o",[])}h(t){var s;if(t.hadRecentInput)return;const r=this.o[0],n=this.o.at(-1);this.i&&r&&n&&t.startTime-n.startTime<1e3&&t.startTime-r.startTime<5e3?(this.i+=t.value,this.o.push(t)):(this.i=t.value,this.o=[t]),(s=this.t)==null||s.call(this,t)}}const ct=(e,t,r={})=>{try{const n=e.filter(s=>PerformanceObserver.supportedEntryTypes.includes(s));if(n.length>0){const s=new PerformanceObserver(i=>{queueMicrotask(()=>{const o=i.getEntries();n.length>1&&o.sort((a,u)=>a.startTime+a.duration-(u.startTime+u.duration)),t(o)})});for(const i of n)s.observe({type:i,buffered:!0,...r});return s}}catch(n){}},Xt=e=>{var t,r,n;return((t=globalThis.PerformanceObserver)==null?void 0:t.supportedEntryTypes.includes("soft-navigation"))&&typeof((n=(r=globalThis.PerformanceSoftNavigation)==null?void 0:r.prototype)==null?void 0:n.getLargestInteractionContentfulPaint)=="function"&&e&&e.reportSoftNavs},to=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const r=e.keys().next().value;r!==void 0&&e.delete(r)}},eo=e=>{let t=!1;return()=>{t||(e(),t=!0)}};class Yd{constructor(){c(this,"l")}}const Se=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},qr=[1800,3e3],ro=(e,t={})=>{const r=Xt(t);Se(()=>{const n=Te(t,Yd),s=Wt();let i,o=L("FCP");const a=ct(["paint"],u=>{for(const l of u)l.name==="first-contentful-paint"&&(a.disconnect(),l.startTime<s.firstHiddenTime&&(o.value=Math.max(l.startTime-qt(),0),o.entries.push(l),o.navigationId=l.navigationId||o.navigationId,i(!0)))});a&&(i=I(e,o,qr,t.reportAllChanges),ft(u=>{o=L("FCP",-1,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,pt()),i=I(e,o,qr,t.reportAllChanges),Hr(()=>{o.value=performance.now()-u.timeStamp,i(!0)})})),r&&ct(["soft-navigation"],u=>{u.forEach(l=>{n.l&&l.navigationId&&to(n.l,l);const h=Math.max((l.presentationTime||l.paintTime||0)-l.startTime,0);o=L("FCP",h,"soft-navigation",l.navigationId,l.interactionId,l.name,l.startTime),i=I(e,o,qr,t.reportAllChanges),i(!0)})},t)})},no=[.1,.25],Kd=(e,t={})=>{const r=Wt();ro(eo(()=>{let n,s=L("CLS",0);const i=Te(t,Xd),o=(p,_,E,m,T)=>{s=L("CLS",0,p,_,E,m,T),i.i=0,n=I(e,s,no,t.reportAllChanges)},a=(p=!1)=>{i.i>s.value&&(s.value=i.i,s.entries=i.o),n(p)},u=p=>{a(!0),o("soft-navigation",p.navigationId,p.interactionId,p.name,p.startTime)},l=p=>{for(const _ of p)_.entryType!=="soft-navigation"?i.h(_):u(_);a()},h=["layout-shift"];Xt(t)&&h.push("soft-navigation");const d=ct(h,l);d&&(n=I(e,s,no,t.reportAllChanges),r.onHidden(()=>{l(d.takeRecords()),n(!0)}),ft(()=>{o("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,pt()),Hr(n)}),setTimeout(n))}))};let so=0,Wr=1/0,Ae=0;const Qd=e=>{for(const t of e)t.interactionId&&(Wr=Math.min(Wr,t.interactionId),Ae=Math.max(Ae,t.interactionId),so=Ae?(Ae-Wr)/7+1:0)};let Xr;const io=()=>{var e;return Xr?so:(e=performance.interactionCount)!=null?e:0},Jd=()=>{"interactionCount"in performance||Xr||(Xr=ct(["event"],Qd,{durationThreshold:0}))};let oo=0;class Zd{constructor(){c(this,"u",[]);c(this,"v",new Map);c(this,"m");c(this,"p")}T(){oo=io(),this.u.length=0,this.v.clear()}M(t){const r=io()-oo,n=Math.min(this.u.length-1,Math.floor(r/50));return!r||n!==-1||t!=="soft-navigation"&&t!=="back-forward-cache"?this.u[n]:{_:8,id:-1,entries:[]}}h(t){var s,i;if((s=this.m)==null||s.call(this,t),!t.interactionId&&t.entryType!=="first-input")return;const r=this.u.at(-1);let n=this.v.get(t.interactionId);if(n||this.u.length<10||t.duration>r._){if(n?t.duration>n._?(n.entries=[t],n._=t.duration):t.duration===n._&&t.startTime===n.entries[0].startTime&&n.entries.push(t):(n={id:t.interactionId,entries:[t],_:t.duration},this.v.set(n.id,n),this.u.push(n)),this.u.sort((o,a)=>a._-o._),this.u.length>10){const o=this.u.splice(10);for(const a of o)this.v.delete(a.id)}(i=this.p)==null||i.call(this,n)}}}const ao=e=>{const t="requestIdleCallback"in globalThis?1e3:0,r=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if(document.visibilityState==="hidden")e();else{const s=eo(e);let i=-1;const o=()=>{n(i),s()};addEventListener("visibilitychange",o,{once:!0,capture:!0}),i=r(()=>{removeEventListener("visibilitychange",o,{capture:!0}),s()},{timeout:t})}},co=[200,500],t_=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const r=Wt();Se(()=>{var p;Jd();let n,s=L("INP");const i=Te(t,Zd),o=(_,E,m,T,A)=>{i.T(),s=L("INP",-1,_,E,m,T,A),n=I(e,s,co,t.reportAllChanges)},a=()=>{const _=i.M(s.navigationType);_&&_._!==s.value&&(s.value=_._,s.entries=_.entries,n())},u=_=>{a(),n(!0),o("soft-navigation",_.navigationId,_.interactionId,_.name,_.startTime)},l=(_,E=!1)=>{ao(()=>{for(const m of _)m.entryType!=="soft-navigation"?i.h(m):u(m);a(),E&&n(!0)})},h=["event","first-input"];Xt(t)&&h.push("soft-navigation");const d=ct(h,l,{...t,durationThreshold:(p=t.durationThreshold)!=null?p:40});n=I(e,s,co,t.reportAllChanges),d&&(r.onHidden(()=>{l(d.takeRecords(),!0)}),ft(()=>{o("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,pt())}))})};class e_{constructor(){c(this,"m");c(this,"l")}h(t){var r;(r=this.m)==null||r.call(this,t)}}const Yr=[2500,4e3],r_=(e,t={})=>{let r=!1;const n=Xt(t);Se(()=>{let s,i=Wt(),o=L("LCP");const a=Te(t,e_),u=(_,E,m,T,A)=>{o=L("LCP",-1,_,E,m,T,A),s=I(e,o,Yr,t.reportAllChanges),r=!1,_==="soft-navigation"&&(i=Wt(!0))},l=_=>{var m;a.l&&_.navigationId&&to(a.l,_),r||s(!0),u("soft-navigation",_.navigationId,_.interactionId,_.name,_.startTime);const E=(m=_.getLargestInteractionContentfulPaint)==null?void 0:m.call(_);E&&h([E])},h=_=>{var E;t.reportAllChanges||n||(_=_.slice(-1));for(const m of _){if(!m)continue;if(m.entryType==="soft-navigation"){l(m);continue}let T=0,A=[],M=m.startTime;if(m.entryType==="largest-contentful-paint")T=Math.max(m.startTime-qt(),0),a.h(m),A=[m];else if(m.entryType==="interaction-contentful-paint"){const y=m;if(!o.navigationId||"interactionId"in y&&y.interactionId!=o.navigationInteractionId)continue;M=((E=y.largestContentfulPaint)==null?void 0:E.renderTime)||0,T=Math.max(M-m.startTime,0),y.largestContentfulPaint&&(a.h(y.largestContentfulPaint),A=[y.largestContentfulPaint])}M<i.firstHiddenTime&&(o.value=T,o.entries=A,s())}},d=["largest-contentful-paint"];n&&d.push("interaction-contentful-paint","soft-navigation");const p=ct(d,h);if(p){s=I(e,o,Yr,t.reportAllChanges);const _=["keydown","click","visibilitychange"],E=m=>{if(m.isTrusted&&!r){const T=o.id;ao(()=>{if(!r){if(!n){p.disconnect();for(const A of _)removeEventListener(A,E,{capture:!0})}T===o.id&&(r=!0,s(!0))}})}};for(const m of _)addEventListener(m,E,{capture:!0});ft(m=>{u("back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,pt()),s=I(e,o,Yr,t.reportAllChanges),Hr(()=>{o.value=performance.now()-m.timeStamp,r=!0,s(!0)})})}})},Kr=[800,1800],Qr=e=>{document.prerendering?Se(()=>Qr(e)):document.readyState!=="complete"?addEventListener("load",()=>Qr(e),!0):setTimeout(e)},n_=(e,t={})=>{const r=Xt(t);let n=L("TTFB"),s=I(e,n,Kr,t.reportAllChanges);Qr(()=>{const i=zr();if(i){const o=i.responseStart;n.value=Math.max(o-qt(),0),n.entries=[i],s(!0),ft(()=>{n=L("TTFB",0,"back-forward-cache",n.navigationId,n.navigationInteractionId,n.navigationURL,pt()),s=I(e,n,Kr,t.reportAllChanges),s(!0)}),r&&ct(["soft-navigation"],a=>{a.forEach(u=>{u.navigationId&&(n=L("TTFB",0,"soft-navigation",u.navigationId,u.interactionId,u.name,u.startTime),n.entries=[u],s=I(e,n,Kr,t.reportAllChanges),s(!0))})},t)}})},s_=3e4,i_=[{register:r_,name:"web_vitals.lcp",unit:"ms",boundaries:[100,250,500,1e3,1500,2e3,2500,3e3,4e3,6e3,8e3,12e3]},{register:t_,name:"web_vitals.inp",unit:"ms",boundaries:[8,16,40,75,100,150,200,300,500,750,1e3]},{register:Kd,name:"web_vitals.cls",unit:"1",boundaries:[.01,.025,.05,.075,.1,.15,.25,.5,1]},{register:ro,name:"web_vitals.fcp",unit:"ms",boundaries:[100,250,500,900,1200,1500,1800,2200,3e3,4e3,6e3]},{register:n_,name:"web_vitals.ttfb",unit:"ms",boundaries:[50,100,200,400,600,800,1200,1800,2500,4e3]}],uo=()=>{var e;return`/${(e=window.location.pathname.split("/")[1])!=null?e:""}`},lo={login_redirect:{name:"app_shell.login_redirect",description:"Time from navigation start until the shell redirects to the login service",boundaries:[50,100,200,400,700,1e3,1500,2500,4e3,6e3]},app_ready:{name:"app_shell.app_ready",description:"Time from navigation start until the splash screen is replaced by the app",boundaries:[500,1e3,1500,2e3,3e3,4e3,6e3,8e3,12e3,2e4]}},ho=new Map,_o=e=>{var t;(t=ho.get(e))==null||t.record(performance.now(),{"page.route":uo()})},o_=e=>{i_.forEach(({register:t,name:r,unit:n,boundaries:s})=>{const i=e.createHistogram(r,{unit:n,advice:{explicitBucketBoundaries:s}});t(o=>{i.record(o.value,{"web_vital.rating":o.rating,"web_vital.navigation_type":o.navigationType,"page.route":uo()})})})},a_=()=>{const{GPv2UIOtelEndpoint:e,OtelTracesSamplerRatio:t}=P();if(typeof e!="string"||e.trim()==="")return;const r=e.trim().replace(/\/+$/,""),n=crypto.randomUUID(),s=Ds({[gs]:Kt,"deployment.environment":window.location.hostname,[Ka]:n}),i=new Au({resource:s,sampler:new ht({root:new Rr(t!=null?t:1)}),spanProcessors:[new gu(new nd({url:`${r}/v1/traces`}))]});i.register();const o=new Hl({resource:s,readers:[new nl({exporter:new ud({url:`${r}/v1/metrics`}),exportIntervalMillis:s_})]});rr.setGlobalMeterProvider(o);const a=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),u=[new RegExp(`^${a}(/|$)`,"i"),/^https?:\/\/([a-z0-9-]+\.)*dc\.services\.visualstudio\.com(\/|$)/i,/^https?:\/\/([a-z0-9-]+\.)*(google-analytics|googletagmanager)\.com(\/|$)/i];dd({tracerProvider:i,meterProvider:o,instrumentations:[new Sd,new xd({ignoreUrls:u}),new Wd({ignoreUrls:u})]});const l=o.getMeter("app-shell");o_(l),Object.keys(lo).forEach(h=>{const{name:d,description:p,boundaries:_}=lo[h];ho.set(h,l.createHistogram(d,{unit:"ms",description:p,advice:{explicitBucketBoundaries:_}}))}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&(i.forceFlush().catch(()=>{}),o.forceFlush().catch(()=>{}))}),window[Zt.otel]=Object.freeze({tracerProvider:i,meterProvider:o,serviceInstanceId:n})},po=async e=>{const t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(n=>n.toString(16).padStart(2,"0")).join("")};function c_(){const{location:e}=window,t=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`,{LoginAuthority:r,GlobalPortalClientId:n,GlobalPortalUIScopes:s,GlobalPlanBShellPostLogoutRedirectUrl:i}=P();return{authority:r,client_id:n,redirect_uri:`${t}/auth-callback`,response_type:"code",scope:s,post_logout_redirect_uri:i,monitorSession:!1}}const Re=new Po(c_()),u_=e=>{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(window.atob(t).split("").map(n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));return JSON.parse(r)},fo=()=>{localStorage.removeItem(Rt)},H=()=>{const e=localStorage.getItem(Rt);return e?JSON.parse(e):null},Jr=()=>{var e;const t=localStorage.getItem(Ue);return t?(e=JSON.parse(t))==null?void 0:e.email:null},mo=async()=>{const e=H();if(!e)return null;const t=(e.profile.given_name||"")+(e.profile.family_name||"")+e.profile.sub;return await po(t)},Zr=()=>{const e=H();return e?e.id_token:null},tn=(e,t)=>{const r={...t,...e},n=u_(e.access_token);return r.profile.sub=n.sub,r.profile.account_number=n.account_number,r.expires_at=n.exp,r.is_federated=n.is_federated,n.previous_login_date&&(r.profile.previous_login_date=n.previous_login_date),mn.setAccount({accountNumber:n.account_number,email:n.email,name:n.name,givenName:n.given_name,familyName:n.family_name,authTime:n.exp,accessToken:e.access_token,idToken:e.id_token}),localStorage.setItem(Rt,JSON.stringify(r)),r},go=e=>{tn(e,null)},Eo=()=>{const e=H();return e?e.access_token:null},To=()=>{const e=H();return e&&e.is_federated!==null&&e.is_federated!==void 0?String(e.is_federated).toLowerCase()==="true":!1},So=()=>{const e=H();return e!=null&&e.expires_at?e.expires_at>Date.now()/1e3:!1},Ao=()=>{var e;const t=H();return((e=t==null?void 0:t.profile)==null?void 0:e.previous_login_date)||null};var l_=Object.freeze({__proto__:null,clearUser:fo,getAccessToken:Eo,getHashedUserId:mo,getIdToken:Zr,getPreviousLoginDate:Ao,getUser:H,getUserEmail:Jr,hasActiveAccessToken:So,isFederatedUser:To,saveUser:go,updateUser:tn,userManager:Re});const h_=["authenticate","auth-callback","logout"],d_=e=>e.expires_at&&new Date(e.expires_at*1e3),__=e=>e.expires_at&&new Date(e.expires_at*1e3+P().TokenValidForOfflineUsePostExpiryInHours*60*60*1e3),Ro=()=>{if(!P().IsLoginEnabled)return!1;const e=H();if(!Zr())return!0;if(!e.expires_at)return!1;const t=new Date;return navigator.onLine?t>d_(e):t>__(e)},p_=()=>{const e=window.location.pathname.split("/");return h_.includes(e[e.length-1])},f_=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="authenticate"?(P().IsLoginEnabled?Re.signinRedirect():window.location.href="/",!0):!1},m_=()=>{let e="/";const t=localStorage.getItem(Qt);t&&(localStorage.removeItem(Qt),e=t),sessionStorage.setItem(We.SessionStorage.ShowLastLoginPopup,"true"),window.location.href=e},g_=e=>{if(!e.id_token)throw new Error("Missing property:id_token");return e},en=e=>{const t=p_();(!t||e)&&(t||localStorage.setItem(Qt,window.location.href),window.location.href="/authenticate")},E_=async e=>{const t=`${e.profile.sub}-${e.profile.customer_id}`,r=await po(t);return{...e,profile:{...e.profile,hashed_identifier:r}}},T_=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="auth-callback"?(Re.signinRedirectCallback().then(g_).then(E_).then(go).then(m_).catch(en),!0):!1};class S_ extends pn{render(){return lt` <ix-splash-screen></ix-splash-screen> `}}window.customElements.define("splash-screen",S_);class A_{constructor(){this.permissions=[],this.loading=!1,this.getPermissions=async()=>{var t;const r=(t=mn)==null?void 0:t.access_token;if(!r)return[];const{ApiBaseUrl:n}=P(),s=await fetch(`${n}/usermanagement/my-permissions?exclude_parents=false&exclude_siblings=true`,{headers:{Authorization:`Bearer ${r}`}});return s.ok?s.json():[]},Mo(this,{permissions:Io,setPermissions:vo})}setPermissions(t){this.permissions=t}tryLoadPermissions(){try{this.loading||(this.loading=!0,this.getPermissions().then(t=>{this.setPermissions(t),this.loading=!1}).catch(()=>{this.loading=!1}))}catch(t){this.loading=!1}}clearPermissions(){this.setPermissions([])}hasExternalUserCreate(){return this.hasPermission(Be,bt)||this.hasPermission(qe,bt)}hasConnectivityCreate(){return this.hasPermission(Jt,bt)}hasPrivilegeLevel(t,r){const n=[bn,bt,An,Rn],s=n.findIndex(o=>o===t),i=n.findIndex(o=>o===r);return s>=i}hasPermission(t,r){return No(this.permissions).some(n=>n.permission_name===t&&this.hasPrivilegeLevel(r,n.privilege))}}const rn=new A_,bo=async()=>{const{getAccessToken:e}=await Promise.resolve().then(function(){return l_}),t=new Headers;return t.append("Authorization",`Bearer ${e()}`),t},R_=async()=>{const{ApiBaseUrl:e}=P(),{ORDER_MANAGEMENT_PERMISSIONS:t}=await Promise.resolve().then(function(){return $o}),r=`${e}/inventory/locations?embed=permissions&page_size=1000`;let n=[],s=1;for(;;){const o=await bo(),a=await fetch(`${r}&cursor=${s}`,{headers:o});if(!a.ok)return Promise.reject();const u=await a.json();if(n.push(...u.items),u.self===u.last)break;s++}n=n.filter(o=>o.permissions.some(a=>t.includes(a.name)));const i=new Map;for(const o of n)i.has(o.account_number)?i.get(o.account_number).push(o.site_id):i.set(o.account_number,[o.site_id]);return i},b_=async e=>{const{ApiBaseUrl:t}=P(),r=new URLSearchParams;r.append("process","Cross_connect");const n=[...e.keys()],s=[...new Set([...e.values()].flat())];r.append("account_number",n.join(",")),r.append("site",s.join(","));const i=await bo(),o=await fetch(`${t}/site-navigations/site-configurations?${r}`,{headers:i});return o.ok?await o.json():Promise.reject()},w_=async()=>{try{const e=await R_();return e.size===0?!1:(await b_(e)).some(t=>{var r;return t.portal==="GlobalPortal"&&!!((r=e.get(t.account_number))!=null&&r.includes(t.site))})}catch(e){return console.error("Failed to determine portal-managed inventory:",e),!1}},{ApiBaseUrl:O_}=P(),C_=new URL(O_).origin;function y_(e){return e.origin===C_}const P_=["type","title","detail","instance","code","correlation_id","timestamp","account_number"];function M_(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;const t=e;return typeof t.status=="number"&&P_.every(r=>typeof t[r]=="string"&&t[r]!=="")}function v_(){const e=globalThis.fetch;globalThis.fetch=async function(...t){var r;const[n]=t,s=n instanceof Request?n.url:String(n),i=await e.apply(this,t);try{y_(new URL(s,(r=globalThis.location)==null?void 0:r.href))&&i.status>=400&&i.clone().json().then(o=>{var a;M_(o)&&((a=globalThis[Zt.appInsights])==null||a.trackEvent({name:"internal_api_error",properties:{url:s,body:o}}))}).catch(o=>console.warn(`[fetch] couldn't read body ${s}`,o))}catch(o){console.error("Failed to fetch:",o)}return i}}const I_="SUPERUSER";class nn extends pn{_isSuperUser(t){return t.some(r=>{var n;return(n=r.provenance)==null?void 0:n.includes(I_)})}constructor(){super(),this._currentView="splash",this.appLoaded=!1,this._onPopState=()=>{P().IsLoginEnabled&&Ro()&&en()};try{zo(),v_()}catch(r){console.error("Telemetry initialization failed:",r)}try{a_()}catch(r){console.error("OpenTelemetry initialization failed:",r)}const t=window.location.pathname;if(t==="/session-expired"){this._currentView="session-expired",this._loadView("session-expired");return}if(t==="/logout"){this._currentView="logout",this._loadView("logout");return}if(f_()||T_()){this._currentView="splash";return}if(Ro()){this._currentView="splash",_o("login_redirect"),en();return}this._currentView="app",this._loadApp()}async _loadView(t){t==="session-expired"?await import("@digital-realty/ix-app-logic/views/session-expiry.js"):t==="logout"&&await import("./logout-BZJ5_qly.js")}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this._onPopState)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this._onPopState)}_getAccountNumber(){var t,r,n;return(n=new URLSearchParams(window.location.search).get("selected_account_number"))!=null?n:(r=(t=H())==null?void 0:t.profile)==null?void 0:r.account_number}_redirectTo(t){window.location.href=t}_isESGAccessOnly(t,r){const n=t.filter(s=>s.account_number===r);return n.length===1&&n[0].permission_name==="ESG Reporting"}async _applyGomFF(t){var r;const n=Jr(),s=structuredClone(window.gpConfig);if(!n||!s)return;const i=this._isSuperUser(t),o=!!((r=s["app-shell"])!=null&&r.IsInventoryManagementEnabled),a=await w_()&&(i||o);s["app-shell"].IsInventoryManagementEnabled=a,s["ui-launchpad"].IsInventoryManagementEnabled=a,window.gpConfig=Object.freeze(s)}_applyMfeOverrides(t,r){const n={};for(const s of Object.keys(t))n[s]={...t[s],enabled:r.includes(s)};return n}async _loadApp(){var t;const{authedUser:r}=await import("@digital-realty/ix-account-switcher");await r.hydrateStore();const[n,s]=await Promise.allSettled([fetch("./registered-apps.json").then(l=>l.json()),rn.getPermissions()]);if(n.status==="rejected"){console.error("Failed to load registered apps:",n.reason);return}if(s.status==="rejected"){console.error("Failed to load permissions:",s.reason);return}const{registeredApps:i}=n.value,o=s.value,a=(t=this._getAccountNumber())!=null?t:"";if(!a){const{LoginAuthority:l}=P();this._redirectTo(`${l}/Account/NoAccess`);return}const u=this._isESGAccessOnly(o,a)?this._applyMfeOverrides(i,["ui-esg"]):i;await this._applyGomFF(o),window.registeredApps=Object.freeze(u),rn.setPermissions(o),await import("./app-B1NFd6AL.js"),this.appLoaded=!0,_o("app_ready")}render(){switch(this._currentView){case"session-expired":return lt`<ix-session-expiry></ix-session-expiry>`;case"logout":return lt`<ixp-logout></ixp-logout>`;case"app":return this.appLoaded?lt`<global-portal-app appTitle="DLR" showDrawer></global-portal-app>`:lt`<splash-screen></splash-screen>`;default:return lt`<splash-screen></splash-screen>`}}}_n([fn({type:String})],nn.prototype,"_currentView",void 0),_n([fn({type:Boolean})],nn.prototype,"appLoaded",void 0),window.customElements.define("gp-bootstrap",nn);export{Gn as A,Ue as B,wn as C,Sn as D,Un as E,Tn as F,Ie as G,kn as I,Le as M,Bn as O,Hn as R,Dn as S,qe as U,Zr as a,mo as b,fo as c,Jr as d,Eo as e,H as f,P as g,tn as h,Ao as i,To as j,We as k,Mn as l,Be as m,yn as n,Pn as o,rn as p,xe as q,zn as r,Ne as s,Zt as t,Re as u,Kt as v,gn as w,So as x,En as y,Rt as z};
|
|
13
|
+
`,Ei(i,t))}return n}}class wl{constructor(t){c(this,"_backingStorages");c(this,"hasAttributeProcessor");this._backingStorages=t,this.hasAttributeProcessor=t.some(r=>r.hasAttributeProcessor)}record(t,r,n,s){this.hasAttributeProcessor&&n===void 0&&(n=R.active());const i=this._backingStorages;for(let o=0;o<i.length;o++)i[o].record(t,r,n,s)}}class Ol{constructor(t,r){c(this,"_buffer",new ot);c(this,"_instrumentName");c(this,"_valueType");this._instrumentName=t,this._valueType=r}observe(t,r={}){if(typeof t!="number"){f.warn(`non-number value provided to metric ${this._instrumentName}: ${t}`);return}this._valueType===X.INT&&!Number.isInteger(t)&&(f.warn(`INT value type cannot accept a floating-point value for ${this._instrumentName}, ignoring the fractional digits.`),t=Math.trunc(t),!Number.isInteger(t))||this._buffer.set(r,t)}}class Cl{constructor(){c(this,"_buffer",new Map)}observe(t,r,n={}){if(!xr(t))return;let s=this._buffer.get(t);if(s==null&&(s=new ot,this._buffer.set(t,s)),typeof r!="number"){f.warn(`non-number value provided to metric ${t._descriptor.name}: ${r}`);return}t._descriptor.valueType===X.INT&&!Number.isInteger(r)&&(f.warn(`INT value type cannot accept a floating-point value for ${t._descriptor.name}, ignoring the fractional digits.`),r=Math.trunc(r),!Number.isInteger(r))||s.set(n,r)}}class yl{constructor(){c(this,"_callbacks",[]);c(this,"_batchCallbacks",[])}addCallback(t,r){this._findCallback(t,r)>=0||this._callbacks.push({callback:t,instrument:r})}removeCallback(t,r){const n=this._findCallback(t,r);n<0||this._callbacks.splice(n,1)}addBatchCallback(t,r){const n=new Set(r.filter(xr));if(n.size===0){f.error("BatchObservableCallback is not associated with valid instruments",r);return}this._findBatchCallback(t,n)>=0||this._batchCallbacks.push({callback:t,instruments:n})}removeBatchCallback(t,r){const n=new Set(r.filter(xr)),s=this._findBatchCallback(t,n);s<0||this._batchCallbacks.splice(s,1)}async observe(t,r){const n=this._observeCallbacks(t,r),s=this._observeBatchCallbacks(t,r);return(await Promise.allSettled([...n,...s])).filter(a=>a.status==="rejected").map(a=>a.reason)}_observeCallbacks(t,r){return this._callbacks.map(async({callback:n,instrument:s})=>{const i=new Ol(s._descriptor.name,s._descriptor.valueType);let o=Promise.resolve(n(i));r!=null&&(o=Gt(o,r)),await o,s._metricStorages.forEach(a=>{a.record(i._buffer,t)})})}_observeBatchCallbacks(t,r){return this._batchCallbacks.map(async({callback:n,instruments:s})=>{const i=new Cl;let o=Promise.resolve(n(i));r!=null&&(o=Gt(o,r)),await o,s.forEach(a=>{const u=i._buffer.get(a);u!=null&&a._metricStorages.forEach(l=>{l.record(u,t)})})})}_findCallback(t,r){return this._callbacks.findIndex(n=>n.callback===t&&n.instrument===r)}_findBatchCallback(t,r){return this._batchCallbacks.findIndex(n=>n.callback===t&&Mu(n.instruments,r))}}class Pl extends fi{constructor(r,n,s,i,o){super(r);c(this,"_aggregationCardinalityLimit");c(this,"_deltaMetricStorage");c(this,"_temporalMetricStorage");c(this,"_attributesProcessor");c(this,"hasAttributeProcessor");this._aggregationCardinalityLimit=o,this._deltaMetricStorage=new mi(n,this._aggregationCardinalityLimit),this._temporalMetricStorage=new St(n,i),this._attributesProcessor=s,this.hasAttributeProcessor=s!==void 0}record(r,n,s,i){this._attributesProcessor!==void 0&&(n=this._attributesProcessor.process(n,s!=null?s:R.active())),this._deltaMetricStorage.record(r,n,i)}collect(r,n){const s=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(r,this._instrumentDescriptor,s,n)}}class Ml{constructor(t,r){c(this,"metricStorageRegistry",new hn);c(this,"observableRegistry",new yl);c(this,"meter");c(this,"_meterProviderSharedState");c(this,"_instrumentationScope");this.meter=new ml(this),this._meterProviderSharedState=t,this._instrumentationScope=r}registerMetricStorage(t){const r=this._registerMetricStorage(t,Pl);return r.length===1?r[0]:new wl(r)}registerAsyncMetricStorage(t){return this._registerMetricStorage(t,Tl)}async collect(t,r,n){const s=await this.observableRegistry.observe(r,n==null?void 0:n.timeoutMillis),i=this.metricStorageRegistry.getStorages(t);if(i.length===0)return null;const o=[];return i.forEach(a=>{const u=a.collect(t,r);u!=null&&o.push(u)}),o.length===0?{errors:s}:{scopeMetrics:{scope:this._instrumentationScope,metrics:o},errors:s}}_registerMetricStorage(t,r){let s=this._meterProviderSharedState.viewRegistry.findViews(t,this._instrumentationScope).map(i=>{const o=il(i,t),a=this.metricStorageRegistry.findOrUpdateCompatibleStorage(o);if(a!=null)return a;const u=i.aggregation.createAggregator(o),l=new r(o,u,i.attributesProcessor,this._meterProviderSharedState.metricCollectors,i.aggregationCardinalityLimit);return this.metricStorageRegistry.register(l),l});if(s.length===0){const o=this._meterProviderSharedState.selectAggregations(t.type).map(([a,u])=>{const l=this.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(a,t);if(l!=null)return l;const h=u.createAggregator(t),d=a.selectCardinalityLimit(t.type),p=new r(t,h,void 0,[a],d);return this.metricStorageRegistry.registerForCollector(a,p),p});s=s.concat(o)}return s}}class vl{constructor(t){c(this,"viewRegistry",new sl);c(this,"metricCollectors",[]);c(this,"meterSharedStates",new Map);c(this,"resource");this.resource=t}getMeterSharedState(t){const r=Pu(t);let n=this.meterSharedStates.get(r);return n==null&&(n=new Ml(this,t),this.meterSharedStates.set(r,n)),n}selectAggregations(t){const r=[];for(const n of this.metricCollectors)r.push([n,hi(n.selectAggregation(t))]);return r}}class Il{constructor(t,r){c(this,"_sharedState");c(this,"_metricReader");this._sharedState=t,this._metricReader=r}async collect(t){const r=N(Date.now()),n=[],s=[],i=Array.from(this._sharedState.meterSharedStates.values()).map(async o=>{const a=await o.collect(this,r,t);(a==null?void 0:a.scopeMetrics)!=null&&n.push(a.scopeMetrics),(a==null?void 0:a.errors)!=null&&s.push(...a.errors)});return await Promise.all(i),{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:n},errors:s}}async forceFlush(t){await this._metricReader.forceFlush(t)}async shutdown(t){await this._metricReader.shutdown(t)}selectAggregationTemporality(t){return this._metricReader.selectAggregationTemporality(t)}selectAggregation(t){return this._metricReader.selectAggregation(t)}selectCardinalityLimit(t){var r,n,s;return(s=(n=(r=this._metricReader).selectCardinalityLimit)==null?void 0:n.call(r,t))!=null?s:2e3}}const Nl=/[\^$\\.+?()[\]{}|]/g;class ye{constructor(t){c(this,"_matchAll");c(this,"_regexp");t==="*"?(this._matchAll=!0,this._regexp=/.*/):(this._matchAll=!1,this._regexp=new RegExp(ye.escapePattern(t)))}match(t){return this._matchAll?!0:this._regexp.test(t)}static escapePattern(t){return`^${t.replace(Nl,"\\$&").replace("*",".*")}$`}static hasWildcard(t){return t.includes("*")}}class _e{constructor(t){c(this,"_matchAll");c(this,"_pattern");this._matchAll=t===void 0,this._pattern=t}match(t){return!!(this._matchAll||t===this._pattern)}}class Ll{process(t,r){return t}}class xl{constructor(t){c(this,"_processors");this._processors=t}process(t,r){let n=t;for(const s of this._processors)n=s.process(n,r);return n}}function Ul(){return kl}function Dl(e){return new xl(e)}const kl=new Ll;class Bl{constructor(t){c(this,"_nameFilter");c(this,"_type");c(this,"_unitFilter");var r;this._nameFilter=new ye((r=t==null?void 0:t.name)!=null?r:"*"),this._type=t==null?void 0:t.type,this._unitFilter=new _e(t==null?void 0:t.unit)}getType(){return this._type}getNameFilter(){return this._nameFilter}getUnitFilter(){return this._unitFilter}}class Gl{constructor(t){c(this,"_nameFilter");c(this,"_versionFilter");c(this,"_schemaUrlFilter");this._nameFilter=new _e(t==null?void 0:t.name),this._versionFilter=new _e(t==null?void 0:t.version),this._schemaUrlFilter=new _e(t==null?void 0:t.schemaUrl)}getNameFilter(){return this._nameFilter}getVersionFilter(){return this._versionFilter}getSchemaUrlFilter(){return this._schemaUrlFilter}}function Fl(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}function $l(e){if(Fl(e))throw new Error("Cannot create view with no selector arguments supplied");if(e.name!=null&&((e==null?void 0:e.instrumentName)==null||ye.hasWildcard(e.instrumentName)))throw new Error("Views with a specified name must be declared with an instrument selector that selects at most one instrument per meter.")}class Vl{constructor(t){c(this,"name");c(this,"description");c(this,"aggregation");c(this,"attributesProcessor");c(this,"instrumentSelector");c(this,"meterSelector");c(this,"aggregationCardinalityLimit");var r;$l(t),t.attributesProcessors!=null?this.attributesProcessor=Dl(t.attributesProcessors):this.attributesProcessor=Ul(),this.name=t.name,this.description=t.description,this.aggregation=hi((r=t.aggregation)!=null?r:{type:B.DEFAULT}),this.instrumentSelector=new Bl({name:t.instrumentName,type:t.instrumentType,unit:t.instrumentUnit}),this.meterSelector=new Gl({name:t.meterName,version:t.meterVersion,schemaUrl:t.meterSchemaUrl}),this.aggregationCardinalityLimit=t.aggregationCardinalityLimit}}class Hl{constructor(t){c(this,"_sharedState");c(this,"_shutdown",!1);var r;if(this._sharedState=new vl((r=t==null?void 0:t.resource)!=null?r:ks()),(t==null?void 0:t.views)!=null&&t.views.length>0)for(const n of t.views)this._sharedState.viewRegistry.addView(new Vl(n));if((t==null?void 0:t.readers)!=null&&t.readers.length>0)for(const n of t.readers){const s=new Il(this._sharedState,n);n.setMetricProducer(s),this._sharedState.metricCollectors.push(s),t.sdkMetricsEnabled&&n instanceof pi&&n._setSelfObsMeterProvider(this)}}getMeter(t,r="",n={}){return this._shutdown?(f.warn("A shutdown MeterProvider cannot provide a Meter"),Mt()):this._sharedState.getMeterSharedState({name:t,version:r,schemaUrl:n.schemaUrl}).meter}async shutdown(t){if(this._shutdown){f.warn("shutdown may only be called once per MeterProvider");return}this._shutdown=!0,await Promise.all(this._sharedState.metricCollectors.map(r=>r.shutdown(t)))}async forceFlush(t){if(this._shutdown){f.warn("invalid attempt to force flush after MeterProvider shutdown");return}await Promise.all(this._sharedState.metricCollectors.map(r=>r.forceFlush(t)))}}class Ti{constructor(t){c(this,"_delegate");this._delegate=t}export(t,r){this._delegate.export(t,r)}forceFlush(){return this._delegate.forceFlush()}shutdown(){return this._delegate.shutdown()}setMetrics(t){this._delegate.setMetrics(t)}}class Si extends Error{constructor(r,n,s){super(r);c(this,"code");c(this,"name","OTLPExporterError");c(this,"data");this.data=s,this.code=n}}function zl(e){if(Number.isFinite(e)&&e>0)return e;throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${e}')`)}function jl(e){if(e!=null)return async()=>e}function ql(e,t,r){var n,s,i,o,a,u;return{timeoutMillis:zl((s=(n=e.timeoutMillis)!=null?n:t.timeoutMillis)!=null?s:r.timeoutMillis),concurrencyLimit:(o=(i=e.concurrencyLimit)!=null?i:t.concurrencyLimit)!=null?o:r.concurrencyLimit,compression:(u=(a=e.compression)!=null?a:t.compression)!=null?u:r.compression}}function Wl(){return{timeoutMillis:1e4,concurrencyLimit:30,compression:"none"}}class Xl{constructor(t){c(this,"_concurrencyLimit");c(this,"_sendingPromises",[]);this._concurrencyLimit=t}pushPromise(t){if(this.hasReachedLimit())throw new Error("Concurrency Limit reached");this._sendingPromises.push(t);const r=()=>{const n=this._sendingPromises.indexOf(t);this._sendingPromises.splice(n,1)};t.then(r,r)}hasReachedLimit(){return this._sendingPromises.length>=this._concurrencyLimit}async awaitAll(){await Promise.all(this._sendingPromises)}}function Yl(e){return new Xl(e.concurrencyLimit)}function Kl(e){return Object.prototype.hasOwnProperty.call(e,"partialSuccess")}function Ql(){return{handleResponse(e){e==null||!Kl(e)||e.partialSuccess==null||Object.keys(e.partialSuccess).length===0||f.warn("Received Partial Success response:",JSON.stringify(e.partialSuccess))}}}class Jl{constructor(t,r,n,s,i,o){c(this,"_metrics");c(this,"_diagLogger");c(this,"_transport");c(this,"_serializer");c(this,"_responseHandler");c(this,"_promiseQueue");c(this,"_timeout");this._transport=t,this._serializer=r,this._responseHandler=n,this._promiseQueue=s,this._timeout=o,this._diagLogger=f.createComponentLogger({namespace:"OTLPExportDelegate"}),this._metrics=i}export(t,r){if(this._diagLogger.debug("items to be sent",t),this._promiseQueue.hasReachedLimit()){r({code:D.FAILED,error:new Error("Concurrent export limit reached")});return}const n=this._serializer.serializeRequest(t);if(n==null){r({code:D.FAILED,error:new Error("Nothing to send")});return}const s=this._metrics.startExport(t);this._promiseQueue.pushPromise(this._transport.send(n,this._timeout).then(i=>{var o;if(i.status==="success"){if(s(void 0),i.data!=null)try{this._responseHandler.handleResponse(this._serializer.deserializeResponse(i.data))}catch(a){this._diagLogger.warn("Export succeeded but could not deserialize response - is the response specification compliant?",a,i.data)}r({code:D.SUCCESS});return}else if(i.status==="failure"&&i.error){s(i.error),r({code:D.FAILED,error:i.error});return}else i.status==="retryable"?(s("export_max_retries"),r({code:D.FAILED,error:(o=i.error)!=null?o:new Si("Export failed with retryable status")})):(s("export_failed"),r({code:D.FAILED,error:new Si("Export failed with unknown error")}))},i=>{s(i),r({code:D.FAILED,error:i})}))}forceFlush(){return this._promiseQueue.awaitAll()}setMetrics(t){this._metrics=t}async shutdown(){this._diagLogger.debug("shutdown started"),await this.forceFlush(),this._transport.shutdown()}}function Zl(e,t){return new Jl(e.transport,e.serializer,Ql(),e.promiseHandler,e.metrics,t.timeout)}function th(e,t,r,n){return Zl({transport:n,serializer:t,promiseHandler:Yl(e),metrics:r},{timeout:e.timeoutMillis})}const Ai="http.response.status_code",eh="otel.component.name",rh="otel.component.type",nh="server.address",sh="server.port",ih="error.type",oh="0.221.0",Ri=new Map;class ah{constructor(t){c(this,"inflight");c(this,"exported");c(this,"duration");c(this,"standardAttrs");c(this,"responseAttributesFromError");c(this,"helper");var l;const{componentType:r,metricsHelper:n,meterProvider:s,url:i,responseAttributesFromError:o}=t;this.responseAttributesFromError=o;const a=s?s.getMeter("@opentelemetry/otlp-exporter",oh):Mt(),u=(l=Ri.get(r))!=null?l:0;if(Ri.set(r,u+1),this.standardAttrs={[rh]:r,[eh]:`${r}/${u}`},i){let h=i;i.includes("://")||(h=`http://${i}`);try{const d=new URL(h);this.standardAttrs[nh]=d.hostname;let p;d.port?p=Number(d.port):d.protocol==="http:"?p=80:d.protocol==="https:"&&(p=443),typeof p=="number"&&(this.standardAttrs[sh]=p)}catch(d){}}this.helper=n,this.inflight=a.createUpDownCounter(`otel.sdk.exporter.${this.helper.name}.inflight`,{unit:`{${this.helper.name}}`,description:`The number of ${this.helper.name}s which were passed to the exporter, but that have not been exported yet (neither successful, nor failed).`}),this.exported=a.createCounter(`otel.sdk.exporter.${this.helper.name}.exported`,{unit:`{${this.helper.name}}`,description:`The number of ${this.helper.name}s for which the export has finished, either successful or failed.`}),this.duration=a.createHistogram("otel.sdk.exporter.operation.duration",{unit:"s",description:"The duration of exporting a batch of telemetry records.",advice:{explicitBucketBoundaries:[]}})}startExport(t){const r=this.helper.countItems(t),n=G();return this.inflight.add(r,this.standardAttrs),s=>{const i=G();this.inflight.add(-r,this.standardAttrs);const o=s?{...this.standardAttrs,[ih]:s instanceof Error?s.name:"export_failed"}:this.standardAttrs;this.exported.add(r,o);const a={...o,...this.responseAttributesFromError(s)},u=nc(pr(n,i))/1e3;this.duration.record(u,a)}}}const bi={name:"metric_data_point",countItems:e=>{let t=0;for(const r of e.scopeMetrics)for(const n of r.metrics)t+=n.dataPoints.length;return t}},ch={name:"span",countItems:e=>e.length};var wi;(function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.TRACE=1]="TRACE",e[e.TRACE2=2]="TRACE2",e[e.TRACE3=3]="TRACE3",e[e.TRACE4=4]="TRACE4",e[e.DEBUG=5]="DEBUG",e[e.DEBUG2=6]="DEBUG2",e[e.DEBUG3=7]="DEBUG3",e[e.DEBUG4=8]="DEBUG4",e[e.INFO=9]="INFO",e[e.INFO2=10]="INFO2",e[e.INFO3=11]="INFO3",e[e.INFO4=12]="INFO4",e[e.WARN=13]="WARN",e[e.WARN2=14]="WARN2",e[e.WARN3=15]="WARN3",e[e.WARN4=16]="WARN4",e[e.ERROR=17]="ERROR",e[e.ERROR2=18]="ERROR2",e[e.ERROR3=19]="ERROR3",e[e.ERROR4=20]="ERROR4",e[e.FATAL=21]="FATAL",e[e.FATAL2=22]="FATAL2",e[e.FATAL3=23]="FATAL3",e[e.FATAL4=24]="FATAL4"})(wi||(wi={}));class Oi{emit(t){}enabled(){return!1}}const uh=new Oi,pe=Symbol.for("io.opentelemetry.js.api.logs"),Vt=globalThis;function lh(e,t,r){return n=>n===e?t:r}const Ci=1;class hh{getLogger(t,r,n){return new Oi}}const yi=new hh;class dh{constructor(t,r,n,s){this._provider=t,this.name=r,this.version=n,this.options=s}emit(t){this._getLogger().emit(t)}enabled(t){return this._getLogger().enabled(t)}_getLogger(){if(this._delegate)return this._delegate;const t=this._provider._getDelegateLogger(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):uh}}class Pi{getLogger(t,r,n){var s;return(s=this._getDelegateLogger(t,r,n))!==null&&s!==void 0?s:new dh(this,t,r,n)}_getDelegate(){var t;return(t=this._delegate)!==null&&t!==void 0?t:yi}_setDelegate(t){this._delegate=t}_getDelegateLogger(t,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getLogger(t,r,n)}}class dn{constructor(){this._proxyLoggerProvider=new Pi}static getInstance(){return this._instance||(this._instance=new dn),this._instance}setGlobalLoggerProvider(t){return Vt[pe]?this.getLoggerProvider():(Vt[pe]=lh(Ci,t,yi),this._proxyLoggerProvider._setDelegate(t),t)}getLoggerProvider(){var t,r;return(r=(t=Vt[pe])===null||t===void 0?void 0:t.call(Vt,Ci))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(t,r,n){return this.getLoggerProvider().getLogger(t,r,n)}disable(){delete Vt[pe],this._proxyLoggerProvider=new Pi}}const Mi=dn.getInstance();function vi(e,t){const r={attributes:J(e.attributes,t),droppedAttributesCount:0},n=e.schemaUrl;return n&&n!==""&&(r.schemaUrl=n),r}function Ii(e,t){var n;const r={name:e.name,version:e.version};return e.attributes&&Object.keys(e.attributes).length>0&&(r.attributes=J(e.attributes,t),r.droppedAttributesCount=(n=e.droppedAttributesCount)!=null?n:0),r}function J(e,t){return Object.keys(e).map(r=>_h(r,e[r],t))}function _h(e,t,r){return{key:e,value:Ur(t,r)}}function Ur(e,t){const r=typeof e;if(r==="string")return{stringValue:e};if(r==="number")return Number.isInteger(e)?{intValue:e}:{doubleValue:e};if(r==="boolean")return{boolValue:e};if(e instanceof Uint8Array)return{bytesValue:t.encodeUint8Array(e)};if(Array.isArray(e)){const n=new Array(e.length);for(let s=0;s<e.length;s++)n[s]=Ur(e[s],t);return{arrayValue:{values:n}}}if(r==="object"&&e!=null){const n=Object.keys(e),s=new Array(n.length);for(let i=0;i<n.length;i++)s[i]={key:n[i],value:Ur(e[n[i]],t)};return{kvlistValue:{values:s}}}return{}}function ph(e){const t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}function fh(e){return ph(e).toString()}const mh=typeof BigInt<"u"?fh:q;function Ni(e){return e}const Li={encodeHrTime:mh,encodeSpanContext:Ni,encodeOptionalSpanContext:Ni,encodeUint8Array:e=>{if(typeof Buffer<"u")return Buffer.from(e).toString("base64");const t=new Array(e.length);for(let r=0;r<e.length;r++)t[r]=String.fromCharCode(e[r]);return btoa(t.join(""))}};var fe;(function(e){e[e.AGGREGATION_TEMPORALITY_UNSPECIFIED=0]="AGGREGATION_TEMPORALITY_UNSPECIFIED",e[e.AGGREGATION_TEMPORALITY_DELTA=1]="AGGREGATION_TEMPORALITY_DELTA",e[e.AGGREGATION_TEMPORALITY_CUMULATIVE=2]="AGGREGATION_TEMPORALITY_CUMULATIVE"})(fe||(fe={}));function gh(e,t){const r=vi(e.resource,t);return{resource:r,schemaUrl:r.schemaUrl,scopeMetrics:Eh(e.scopeMetrics,t)}}function Eh(e,t){return Array.from(e.map(r=>({scope:Ii(r.scope,t),metrics:r.metrics.map(n=>Th(n,t)),schemaUrl:r.scope.schemaUrl})))}function Th(e,t){const r={name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit},n=bh(e.aggregationTemporality);switch(e.dataPointType){case V.SUM:r.sum={aggregationTemporality:n,isMonotonic:e.isMonotonic,dataPoints:xi(e,t)};break;case V.GAUGE:r.gauge={dataPoints:xi(e,t)};break;case V.HISTOGRAM:r.histogram={aggregationTemporality:n,dataPoints:Ah(e,t)};break;case V.EXPONENTIAL_HISTOGRAM:r.exponentialHistogram={aggregationTemporality:n,dataPoints:Rh(e,t)};break}return r}function Sh(e,t,r){const n={attributes:J(e.attributes,r),startTimeUnixNano:r.encodeHrTime(e.startTime),timeUnixNano:r.encodeHrTime(e.endTime)};switch(t){case X.INT:n.asInt=e.value;break;case X.DOUBLE:n.asDouble=e.value;break}return n}function xi(e,t){return e.dataPoints.map(r=>Sh(r,e.descriptor.valueType,t))}function Ah(e,t){return e.dataPoints.map(r=>{const n=r.value;return{attributes:J(r.attributes,t),bucketCounts:n.buckets.counts,explicitBounds:n.buckets.boundaries,count:n.count,sum:n.sum,min:n.min,max:n.max,startTimeUnixNano:t.encodeHrTime(r.startTime),timeUnixNano:t.encodeHrTime(r.endTime)}})}function Rh(e,t){return e.dataPoints.map(r=>{const n=r.value;return{attributes:J(r.attributes,t),count:n.count,min:n.min,max:n.max,sum:n.sum,positive:{offset:n.positive.offset,bucketCounts:n.positive.bucketCounts},negative:{offset:n.negative.offset,bucketCounts:n.negative.bucketCounts},scale:n.scale,zeroCount:n.zeroCount,startTimeUnixNano:t.encodeHrTime(r.startTime),timeUnixNano:t.encodeHrTime(r.endTime)}})}function bh(e){switch(e){case k.DELTA:return fe.AGGREGATION_TEMPORALITY_DELTA;case k.CUMULATIVE:return fe.AGGREGATION_TEMPORALITY_CUMULATIVE}}function wh(e,t){return{resourceMetrics:e.map(r=>gh(r,t))}}const Oh={serializeRequest:e=>{const t=wh([e],Li);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};const t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(r){return f.warn(`Failed to parse metrics export response: ${r.message}. Returning empty response`),{}}}},Ch=256,yh=512;function Ui(e,t){let r=e&255|Ch;return t&&(r|=yh),r}function Ph(e,t){var i,o,a,u;const r=e.spanContext(),n=e.status,s=(i=e.parentSpanContext)!=null&&i.spanId?t.encodeSpanContext((o=e.parentSpanContext)==null?void 0:o.spanId):void 0;return{traceId:t.encodeSpanContext(r.traceId),spanId:t.encodeSpanContext(r.spanId),parentSpanId:s,traceState:(a=r.traceState)==null?void 0:a.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:J(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(l=>vh(l,t)),droppedEventsCount:e.droppedEventsCount,status:{code:n.code,message:n.message},links:e.links.map(l=>Mh(l,t)),droppedLinksCount:e.droppedLinksCount,flags:Ui(r.traceFlags,(u=e.parentSpanContext)==null?void 0:u.isRemote)}}function Mh(e,t){var r;return{attributes:e.attributes?J(e.attributes,t):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:(r=e.context.traceState)==null?void 0:r.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:Ui(e.context.traceFlags,e.context.isRemote)}}function vh(e,t){return{attributes:e.attributes?J(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Ih(e,t){return{resourceSpans:Lh(e,t)}}function Nh(e){const t=new Map;for(const r of e){let n=t.get(r.resource);n||(n=new Map,t.set(r.resource,n));const s=`${r.instrumentationScope.name}@${r.instrumentationScope.version||""}:${r.instrumentationScope.schemaUrl||""}`;let i=n.get(s);i||(i=[],n.set(s,i)),i.push(r)}return t}function Lh(e,t){const r=Nh(e),n=[],s=r.entries();let i=s.next();for(;!i.done;){const[o,a]=i.value,u=[],l=a.values();let h=l.next();for(;!h.done;){const _=h.value;if(_.length>0){const E=_.map(m=>Ph(m,t));u.push({scope:Ii(_[0].instrumentationScope,t),spans:E,schemaUrl:_[0].instrumentationScope.schemaUrl})}h=l.next()}const d=vi(o,t),p={resource:d,scopeSpans:u,schemaUrl:d.schemaUrl};n.push(p),i=s.next()}return n}const xh={serializeRequest:e=>{const t=Ih(e,Li);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};const t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(r){return f.warn(`Failed to parse trace export response: ${r.message}. Returning empty response`),{}}}},Dr=5,Uh=1e3,Dh=5e3,kh=1.5,Di=.2;function Bh(){return Math.random()*(2*Di)-Di}class Gh{constructor(t){c(this,"_transport");this._transport=t}retry(t,r,n){return new Promise((s,i)=>{setTimeout(()=>{this._transport.send(t,r).then(s,i)},n)})}async send(t,r){var a;let n=Dr,s=Uh;const i=Date.now()+r;let o=await this._transport.send(t,r);for(;o.status==="retryable"&&n>0;){n--;const u=Math.max(Math.min(s*(1+Bh()),Dh),0);s=s*kh;const l=(a=o.retryInMillis)!=null?a:u,h=i-Date.now();if(l>h)return f.info(`Export retry time ${Math.round(l)}ms exceeds remaining timeout ${Math.round(h)}ms, not retrying further.`),o;f.verbose(`Scheduling export retry in ${Math.round(l)}ms`),o=await this.retry(t,h,l)}return o.status==="success"?f.verbose(`Export succeeded after ${Dr-n} retry attempts.`):o.status==="retryable"?f.info(`Export failed after maximum retry attempts (${Dr}).`):f.info(`Export failed with non-retryable error: ${o.error}`),o}shutdown(){return this._transport.shutdown()}}function Fh(e){return new Gh(e.transport)}function $h(e){return e===429||e===502||e===503||e===504}function Vh(e){if(e==null)return;const t=Number.parseInt(e,10);if(Number.isInteger(t))return t>0?t*1e3:-1;const r=new Date(e).getTime()-Date.now();return r>=0?r:0}const Hh=60*1024,zh=9;let kr=0,me=0;class jh{constructor(t){c(this,"_parameters");this._parameters=t}async send(t,r){const n=new AbortController,s=setTimeout(()=>n.abort(),r);let i=globalThis.fetch;typeof i.__original=="function"&&(i=i.__original);const o=t.byteLength,a=kr+o>Hh,u=me>=zh,l=!a&&!u;if(l)kr+=o,me++;else{const h=a?"size limit":"count limit";f.debug(`keepalive disabled: ${(o/1024).toFixed(1)}KB payload, ${me} pending (${h})`)}try{const h=new URL(this._parameters.url),d=await i(h.href,{method:"POST",headers:await this._parameters.headers(),body:t,signal:n.signal,keepalive:l,mode:globalThis.location?globalThis.location.origin===h.origin?"same-origin":"cors":"no-cors"});if(d.status>=200&&d.status<=299)return f.debug(`export response success (status: ${d.status})`),{status:"success"};if($h(d.status)){f.warn(`export response retryable (status: ${d.status})`);const p=d.headers.get("Retry-After");return{status:"retryable",retryInMillis:Vh(p)}}return f.error(`export response failure (status: ${d.status})`),{status:"failure",error:new Error(`Fetch request failed with non-retryable status ${d.status}`)}}catch(h){return Wh(h)?(f.warn(`export request retryable (network error: ${h})`),{status:"retryable",error:new Error("Fetch request encountered a network error",{cause:h})}):(f.error(`export request failure (error: ${h})`),{status:"failure",error:new Error("Fetch request errored",{cause:h})})}finally{clearTimeout(s),l&&(kr-=o,me--)}}shutdown(){}}function qh(e){return new jh(e)}function Wh(e){return e instanceof TypeError&&!e.cause}function Xh(e,t,r){return th(e,t,r,Fh({transport:qh(e)}))}function Yh(e){const t={};return Object.entries(e!=null?e:{}).forEach(([r,n])=>{typeof n<"u"?t[r]=String(n):f.warn(`Header "${r}" has invalid value (${n}) and will be ignored`)}),t}function Kh(e,t,r){return async()=>{const n={...await r()},s={};return t!=null&&Object.assign(s,await t()),e!=null&&Object.assign(s,Yh(await e())),Object.assign(s,n)}}function Qh(e){var t;if(e!=null)try{const r=(t=globalThis.location)==null?void 0:t.href;return new URL(e,r).href}catch(r){throw new Error(`Configuration: Could not parse user-provided export URL: '${e}'`)}}function Jh(e,t,r){var n,s;return{...ql(e,t,r),headers:Kh(e.headers,t.headers,r.headers),url:(s=(n=Qh(e.url))!=null?n:t.url)!=null?s:r.url}}function Zh(e,t){return{...Wl(),headers:async()=>e,url:"http://localhost:4318/"+t}}function td(e){return typeof e.headers=="function"?e.headers:jl(e.headers)}function ed(e,t,r){return Jh({url:e.url,timeoutMillis:e.timeoutMillis,headers:td(e),concurrencyLimit:e.concurrencyLimit},{},Zh(r,t))}function ki(e,t,r,n){return new ah({componentType:e,metricsHelper:t,url:r,meterProvider:n,responseAttributesFromError:s=>{if(!s)return{[Ai]:200};if(!(s instanceof Error))return{};if(s.message.startsWith("Fetch request failed with non-retryable status ")){const i=s.message.substring(47);return{[Ai]:Number(i)}}return{}}})}function Bi(e,t,r,n,s,i,o){const a=ed(e,i,o);return Xh(a,t,ki(r,n,a.url,e.selfObsMeterProvider))}const rd="otlp_http_span_exporter";class nd extends Ti{constructor(t={}){super(Bi(t,xh,rd,ch,t.selfObsMeterProvider,"v1/traces",{"Content-Type":"application/json"}))}}var ge;(function(e){e[e.DELTA=0]="DELTA",e[e.CUMULATIVE=1]="CUMULATIVE",e[e.LOWMEMORY=2]="LOWMEMORY"})(ge||(ge={}));const Br=()=>k.CUMULATIVE,Gi=e=>{switch(e){case g.COUNTER:case g.OBSERVABLE_COUNTER:case g.GAUGE:case g.HISTOGRAM:case g.OBSERVABLE_GAUGE:return k.DELTA;case g.UP_DOWN_COUNTER:case g.OBSERVABLE_UP_DOWN_COUNTER:return k.CUMULATIVE}},Fi=e=>{switch(e){case g.COUNTER:case g.HISTOGRAM:return k.DELTA;case g.GAUGE:case g.UP_DOWN_COUNTER:case g.OBSERVABLE_UP_DOWN_COUNTER:case g.OBSERVABLE_COUNTER:case g.OBSERVABLE_GAUGE:return k.CUMULATIVE}};function sd(){const e="cumulative".toLowerCase();return e==="cumulative"?Br:e==="delta"?Gi:e==="lowmemory"?Fi:(f.warn(`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '${e}', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead.`),Br)}function id(e){return e!=null?e===ge.DELTA?Gi:e===ge.LOWMEMORY?Fi:Br:sd()}const od=Object.freeze({type:B.DEFAULT});function ad(e){var t;return(t=e==null?void 0:e.aggregationPreference)!=null?t:(()=>od)}class cd extends Ti{constructor(r,n){super(r);c(this,"_aggregationTemporalitySelector");c(this,"_aggregationSelector");this._aggregationSelector=ad(n),this._aggregationTemporalitySelector=id(n==null?void 0:n.temporalityPreference)}selectAggregation(r){return this._aggregationSelector(r)}selectAggregationTemporality(r){return this._aggregationTemporalitySelector(r)}}const $i="otlp_http_metric_exporter";class ud extends cd{constructor(r){super(Bi(r!=null?r:{},Oh,$i,bi,r==null?void 0:r.selfObsMeterProvider,"v1/metrics",{"Content-Type":"application/json"}),r);c(this,"_url");this._url=r==null?void 0:r.url}setSelfObsMeterProvider(r){this.setMetrics(ki($i,bi,this._url,r))}}function ld(e,t,r,n){for(let s=0,i=e.length;s<i;s++){const o=e[s];t&&o.setTracerProvider(t),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function hd(e){e.forEach(t=>t.disable())}function dd(e){var i,o;const t=e.tracerProvider||w.getTracerProvider(),r=e.meterProvider||rr.getMeterProvider(),n=e.loggerProvider||Mi.getLoggerProvider(),s=(o=(i=e.instrumentations)==null?void 0:i.flat())!=null?o:[];return ld(s,t,r,n),()=>{hd(s)}}let v=console.error.bind(console);function Ht(e,t,r){const n=!!e[t]&&Object.prototype.propertyIsEnumerable.call(e,t);Object.defineProperty(e,t,{configurable:!0,enumerable:n,writable:!0,value:r})}const Vi=(e,t,r)=>{if(!e||!e[t]){v("no original function "+String(t)+" to wrap");return}if(!r){v("no wrapper function"),v(new Error().stack);return}const n=e[t];if(typeof n!="function"||typeof r!="function"){v("original object and wrapper must be functions");return}const s=r(n,t);return Ht(s,"__original",n),Ht(s,"__unwrap",()=>{e[t]===s&&Ht(e,t,n)}),Ht(s,"__wrapped",!0),Ht(e,t,s),s},_d=(e,t,r)=>{if(e)Array.isArray(e)||(e=[e]);else{v("must provide one or more modules to patch"),v(new Error().stack);return}if(!(t&&Array.isArray(t))){v("must provide one or more functions to wrap on modules");return}e.forEach(n=>{t.forEach(s=>{Vi(n,s,r)})})},Hi=(e,t)=>{if(!e||!e[t]){v("no function to unwrap."),v(new Error().stack);return}const r=e[t];if(!r.__unwrap)v("no original to unwrap to -- has "+String(t)+" already been unwrapped?");else{r.__unwrap();return}},pd=(e,t)=>{if(e)Array.isArray(e)||(e=[e]);else{v("must provide one or more modules to patch"),v(new Error().stack);return}if(!(t&&Array.isArray(t))){v("must provide one or more functions to unwrap on modules");return}e.forEach(r=>{t.forEach(n=>{Hi(r,n)})})};class fd{constructor(t,r,n){c(this,"_config",{});c(this,"_tracer");c(this,"_meter");c(this,"_logger");c(this,"_diag");c(this,"instrumentationName");c(this,"instrumentationVersion");c(this,"_wrap",Vi);c(this,"_unwrap",Hi);c(this,"_massWrap",_d);c(this,"_massUnwrap",pd);this.instrumentationName=t,this.instrumentationVersion=r,this.setConfig(n),this._diag=f.createComponentLogger({namespace:t}),this._tracer=w.getTracer(t,r),this._meter=rr.getMeter(t,r),this._logger=Mi.getLogger(t,r),this._updateMetricInstruments()}get meter(){return this._meter}setMeterProvider(t){this._meter=t.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}get logger(){return this._logger}setLoggerProvider(t){this._logger=t.getLogger(this.instrumentationName,this.instrumentationVersion)}getModuleDefinitions(){var r;const t=(r=this.init())!=null?r:[];return Array.isArray(t)?t:[t]}_updateMetricInstruments(){}getConfig(){return this._config}setConfig(t){this._config={enabled:!0,...t}}setTracerProvider(t){this._tracer=t.getTracer(this.instrumentationName,this.instrumentationVersion)}get tracer(){return this._tracer}_runSpanCustomizationHook(t,r,n,s){if(t)try{t(n,s)}catch(i){this._diag.error("Error running span customization hook due to exception in handler",{triggerName:r},i)}}}class Gr extends fd{constructor(t,r,n){super(t,r,n),this._config.enabled&&this.enable()}}function zt(e,t,r){let n,s;try{s=e()}catch(i){n=i}finally{return t(n,s),s}}var jt;(function(e){e.DOCUMENT_LOAD="documentLoad",e.DOCUMENT_FETCH="documentFetch",e.RESOURCE_FETCH="resourceFetch"})(jt||(jt={}));const md="0.66.0",gd="@opentelemetry/instrumentation-document-load";var Ee;(function(e){e.FIRST_PAINT="firstPaint",e.FIRST_CONTENTFUL_PAINT="firstContentfulPaint"})(Ee||(Ee={}));const Ed=()=>{var r;const e={},t=(r=O.getEntriesByType)==null?void 0:r.call(O,"navigation")[0];if(t)Object.values(S).forEach(s=>{if(dt(t,s)){const i=t[s];typeof i=="number"&&(e[s]=i)}});else{const s=O.timing;s&&Object.values(S).forEach(o=>{if(dt(s,o)){const a=s[o];typeof a=="number"&&(e[o]=a)}})}return e},zi={"first-paint":Ee.FIRST_PAINT,"first-contentful-paint":Ee.FIRST_CONTENTFUL_PAINT},Td=e=>{var r;const t=(r=O.getEntriesByType)==null?void 0:r.call(O,"paint");t&&t.forEach(({name:n,startTime:s})=>{dt(zi,n)&&e.addEvent(zi[n],s)})};class Sd extends Gr{constructor(r={}){super(gd,md,r);c(this,"component","document-load");c(this,"version","1");c(this,"moduleName",this.component)}init(){}_onDocumentLoaded(){window.setTimeout(()=>{this._collectPerformance()})}_addResourcesSpans(r){var s;const n=(s=O.getEntriesByType)==null?void 0:s.call(O,"resource");n&&n.forEach(i=>{this._initResourceSpan(i,r)})}_collectPerformance(){const r=Array.from(document.getElementsByTagName("meta")).find(i=>i.getAttribute("name")===oe),n=Ed(),s=r&&r.content||"";R.with(U.extract(et,{traceparent:s}),()=>{var o;const i=this._startSpan(jt.DOCUMENT_LOAD,S.FETCH_START,n);i&&(R.with(w.setSpan(R.active(),i),()=>{const a=this._startSpan(jt.DOCUMENT_FETCH,S.FETCH_START,n);a&&(a.setAttribute(xt,location.href),R.with(w.setSpan(R.active(),a),()=>{var u;_t(a,n,this.getConfig().ignoreNetworkEvents),this._addCustomAttributesOnSpan(a,(u=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:u.documentFetch),this._endSpan(a,S.RESPONSE_END,n)}))}),i.setAttribute(xt,location.href),i.setAttribute(Ja,navigator.userAgent),this._addResourcesSpans(i),this.getConfig().ignoreNetworkEvents||(C(i,S.FETCH_START,n),C(i,S.UNLOAD_EVENT_START,n),C(i,S.UNLOAD_EVENT_END,n),C(i,S.DOM_INTERACTIVE,n),C(i,S.DOM_CONTENT_LOADED_EVENT_START,n),C(i,S.DOM_CONTENT_LOADED_EVENT_END,n),C(i,S.DOM_COMPLETE,n),C(i,S.LOAD_EVENT_START,n),C(i,S.LOAD_EVENT_END,n)),this.getConfig().ignorePerformancePaintEvents||Td(i),this._addCustomAttributesOnSpan(i,(o=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:o.documentLoad),this._endSpan(i,S.LOAD_EVENT_END,n))})}_endSpan(r,n,s){r&&(dt(s,n)?r.end(s[n]):r.end())}_initResourceSpan(r,n){var i;const s=this._startSpan(jt.RESOURCE_FETCH,S.FETCH_START,r,n);s&&(s.setAttribute(xt,r.name),_t(s,r,this.getConfig().ignoreNetworkEvents),this._addCustomAttributesOnResourceSpan(s,r,(i=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:i.resourceFetch),this._endSpan(s,S.RESPONSE_END,r))}_startSpan(r,n,s,i){if(dt(s,n)&&typeof s[n]=="number")return this.tracer.startSpan(r,{startTime:s[n]},i?w.setSpan(R.active(),i):void 0)}_waitForPageLoad(){window.document.readyState==="complete"?this._onDocumentLoaded():(this._onDocumentLoaded=this._onDocumentLoaded.bind(this),window.addEventListener("load",this._onDocumentLoaded))}_addCustomAttributesOnSpan(r,n){n&&zt(()=>n(r),s=>{s&&this._diag.error("addCustomAttributesOnSpan",s)})}_addCustomAttributesOnResourceSpan(r,n,s){s&&zt(()=>s(r,n),i=>{i&&this._diag.error("addCustomAttributesOnResourceSpan",i)})}enable(){window.removeEventListener("load",this._onDocumentLoaded),this._waitForPageLoad()}disable(){window.removeEventListener("load",this._onDocumentLoaded)}}const Ad="http.request.body.size",ji=f.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-fetch/utils"});function Rd(...e){if(e[0]instanceof URL||typeof e[0]=="string"){const t=e[1];if(!(t!=null&&t.body))return Promise.resolve();if(t.body instanceof ReadableStream){const{body:r,length:n}=bd(t.body);return t.body=r,n}else return Promise.resolve(Od(t.body))}else{const t=e[0];return t!=null&&t.body?t.clone().text().then(r=>Fr(r)):Promise.resolve()}}function bd(e){if(!e.pipeThrough)return ji.warn("Platform has ReadableStream but not pipeThrough!"),{body:e,length:Promise.resolve(void 0)};let t=0,r;const n=new Promise(i=>{r=i}),s=new TransformStream({start(){},async transform(i,o){const a=await i;t+=a.byteLength,o.enqueue(i)},flush(){r(t)}});return{body:e.pipeThrough(s),length:n}}function wd(e){return typeof Document<"u"&&e instanceof Document}function Od(e){if(wd(e))return new XMLSerializer().serializeToString(document).length;if(typeof e=="string")return Fr(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return yd(e);if(e instanceof URLSearchParams)return Fr(e.toString());if(e.byteLength!==void 0)return e.byteLength;ji.warn("unknown body type")}const Cd=new TextEncoder;function Fr(e){return Cd.encode(e).byteLength}function yd(e){let t=0;for(const[r,n]of e.entries())t+=r.length,n instanceof Blob?t+=n.size:t+=n.length;return t}function Pd(e){const t=vd(),r=e.toUpperCase();return r in t?r:"_OTHER"}const Md={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let $r;function vd(){return $r===void 0&&($r=Md),$r}const Id={"https:":"443","http:":"80"};function Nd(e){const t=Number(e.port||Id[e.protocol]);if(t&&!isNaN(t))return t}const qi="0.221.0",Ld=300,Wi=typeof PerformanceObserver<"u";class xd extends Gr{constructor(r={}){super("@opentelemetry/instrumentation-fetch",qi,r);c(this,"component","fetch");c(this,"version",qi);c(this,"moduleName",this.component);c(this,"_usedResources",new WeakSet);c(this,"_tasksCount",0)}init(){}_addChildSpan(r,n){const s=this.tracer.startSpan("CORS Preflight",{startTime:n[S.FETCH_START]},w.setSpan(R.active(),r));_t(s,n,this.getConfig().ignoreNetworkEvents,void 0,!0),s.end(n[S.RESPONSE_END])}_addFinalSpanAttributes(r,n){const s=K(n.url);r.setAttribute(ps,n.status),r.setAttribute(fs,s.hostname);const i=Nd(s);i&&r.setAttribute(ms,i)}_addHeaders(r,n){if(!Ys(n,this.getConfig().propagateTraceHeaderCorsUrls)){const s={};U.inject(R.active(),s),Object.keys(s).length>0&&this._diag.debug("headers inject skipped due to CORS policy");return}if(r instanceof Request)U.inject(R.active(),r.headers,{set:(s,i,o)=>s.set(i,typeof o=="string"?o:String(o))});else{const s=new Headers(r.headers);U.inject(R.active(),s,{set:(i,o,a)=>i.set(o,typeof a=="string"?a:String(a))}),r.headers=s}}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(performance.clearResourceTimings(),this._usedResources=new WeakSet)}_createSpan(r,n={}){if(Us(r,this.getConfig().ignoreUrls)){this._diag.debug("ignoring span as url matches ignored url");return}const s={},i=n.method,o=Pd(n.method||"GET"),a=o;return s[ds]=o,o!==i&&(s[_s]=i),s[xt]=r,this.tracer.startSpan(a,{kind:It.CLIENT,attributes:s})}_findResourceAndAddNetworkEvents(r,n,s){let i=n.entries;if(!i.length){if(!performance.getEntriesByType)return;i=performance.getEntriesByType("resource")}const o=Xs(n.spanUrl,n.startTime,s,i,this._usedResources,"fetch");if(o.mainRequest){const a=o.mainRequest;this._markResourceAsUsed(a);const u=o.corsPreFlightRequest;u&&(this._addChildSpan(r,u),this._markResourceAsUsed(u)),_t(r,a,this.getConfig().ignoreNetworkEvents,void 0,!0)}}_markResourceAsUsed(r){this._usedResources.add(r)}_endSpan(r,n,s){const i=N(Date.now()),o=G();this._addFinalSpanAttributes(r,s),s.status>=400&&(r.setStatus({code:j.ERROR}),r.setAttribute(Lt,String(s.status))),setTimeout(()=>{var a;(a=n.observer)==null||a.disconnect(),this._findResourceAndAddNetworkEvents(r,n,o),this._tasksCount--,this._clearResources(),r.end(i)},Ld)}_patchConstructor(){return r=>{const n=this;return function(...i){if(!n._isEnabled)return r.apply(this,i);const o=this,a=K(i[0]instanceof Request?i[0].url:String(i[0])).href;let u;i[0]instanceof Request?u=i[1]!=null?new Request(i[0],i[1]):i[0]:u=i[1]||{};const l=n._createSpan(a,u);if(!l)return r.apply(this,i);const h=n._prepareSpanData(a);n.getConfig().measureRequestSize&&Rd(...i).then(m=>{m&&l.setAttribute(Ad,m)}).catch(m=>{n._diag.warn("getFetchBodyLength",m)});function d(m,T){n._applyAttributesAfterFetch(m,u,T),n._endSpan(m,h,{status:T.status||0,statusText:T.message,url:a})}function p(m,T){n._applyAttributesAfterFetch(m,u,T),T.status>=200&&T.status<400?n._endSpan(m,h,T):n._endSpan(m,h,{status:T.status,statusText:T.statusText,url:a})}function _(m,T){try{const M=T.clone().body;if(M){const y=M.getReader(),At=()=>{y.read().then(({done:ut})=>{ut?p(m,T):At()},ut=>{d(m,ut)})};At()}else p(m,T)}catch(A){n._diag.error("Failed to read fetch response body",A),n._endSpan(m,h,{status:0,url:a})}return T}function E(m,T){try{d(m,T)}catch(A){n._diag.error("Failed to end span on fetch error",A),n._endSpan(m,h,{status:T.status||0,url:a})}throw T}return R.with(w.setSpan(R.active(),l),()=>(n._callRequestHook(l,u),n._addHeaders(u,a),n._tasksCount++,r.apply(o,u instanceof Request?[u]:[a,u]).then(_.bind(o,l),E.bind(o,l))))}}}_applyAttributesAfterFetch(r,n,s){const i=this.getConfig().applyCustomAttributesOnSpan;i&&zt(()=>i(r,n,s),o=>{o&&this._diag.error("applyCustomAttributesOnSpan",o)})}_callRequestHook(r,n){const s=this.getConfig().requestHook;s&&zt(()=>s(r,n),i=>{i&&this._diag.error("requestHook",i)})}_prepareSpanData(r){const n=G(),s=[];if(typeof PerformanceObserver!="function")return{entries:s,startTime:n,spanUrl:r};const i=new PerformanceObserver(o=>{o.getEntries().forEach(u=>{u.initiatorType==="fetch"&&u.name===r&&s.push(u)})});return i.observe({entryTypes:["resource"]}),{entries:s,observer:i,startTime:n,spanUrl:r}}enable(){if(!Wi){this._diag.warn("this instrumentation is intended for web usage only, it does not instrument server-side fetch()");return}if(!this._isEnabled){if(this._isFetchPatched){this._diag.debug("fetch constructor already patched"),this._isEnabled=!0;return}try{this._wrap(globalThis,"fetch",this._patchConstructor()),this._isFetchPatched=!0,this._isEnabled=!0}catch(r){this._diag.warn("Failed to patch globalThis.fetch; instrumentation will not be enabled. Another script may have locked globalThis.fetch via Object.defineProperty.",r)}}}disable(){Wi&&this._isEnabled&&(this._isEnabled=!1,this._usedResources=new WeakSet)}}const Ud="http.request.body.size";var W;(function(e){e.METHOD_OPEN="open",e.METHOD_SEND="send",e.EVENT_ABORT="abort",e.EVENT_ERROR="error",e.EVENT_LOAD="loaded",e.EVENT_TIMEOUT="timeout"})(W||(W={}));const Dd=f.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils"});function kd(e){return typeof Document<"u"&&e instanceof Document}function Bd(e){if(kd(e))return new XMLSerializer().serializeToString(document).length;if(typeof e=="string")return Xi(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return Fd(e);if(e instanceof URLSearchParams)return Xi(e.toString());if(e.byteLength!==void 0)return e.byteLength;Dd.warn("unknown body type")}const Gd=new TextEncoder;function Xi(e){return Gd.encode(e).byteLength}function Fd(e){let t=0;for(const[r,n]of e.entries())t+=r.length,n instanceof Blob?t+=n.size:t+=n.length;return t}function $d(e){const t=Hd(),r=e.toUpperCase();return r in t?r:"_OTHER"}const Vd={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let Vr;function Hd(){return Vr===void 0&&(Vr=Vd),Vr}const zd={"https:":"443","http:":"80"};function jd(e){const t=Number(e.port||zd[e.protocol]);if(t&&!isNaN(t))return t}const Yi="0.221.0",qd=300;class Wd extends Gr{constructor(r={}){super("@opentelemetry/instrumentation-xml-http-request",Yi,r);c(this,"component","xml-http-request");c(this,"version",Yi);c(this,"moduleName",this.component);c(this,"_tasksCount",0);c(this,"_xhrMem",new WeakMap);c(this,"_usedResources",new WeakSet)}init(){}_addHeaders(r,n){const s=K(n).href;if(!Ys(s,this.getConfig().propagateTraceHeaderCorsUrls)){const o={};U.inject(R.active(),o),Object.keys(o).length>0&&this._diag.debug("headers inject skipped due to CORS policy");return}const i={};U.inject(R.active(),i),Object.keys(i).forEach(o=>{r.setRequestHeader(o,String(i[o]))})}_addChildSpan(r,n){R.with(w.setSpan(R.active(),r),()=>{const s=this.tracer.startSpan("CORS Preflight",{startTime:n[S.FETCH_START]});_t(s,n,this.getConfig().ignoreNetworkEvents,void 0,!0),s.end(n[S.RESPONSE_END])})}_addFinalSpanAttributes(r,n){n.status&&r.setAttribute(ps,n.status)}_applyAttributesAfterXHR(r,n){const s=this.getConfig().applyCustomAttributesOnSpan;typeof s=="function"&&zt(()=>s(r,n),i=>{i&&this._diag.error("applyCustomAttributesOnSpan",i)})}_addResourceObserver(r,n){const s=this._xhrMem.get(r);!s||typeof PerformanceObserver!="function"||typeof PerformanceResourceTiming!="function"||(s.createdResources={observer:new PerformanceObserver(i=>{const o=i.getEntries(),a=K(n);o.forEach(u=>{u.initiatorType==="xmlhttprequest"&&u.name===a.href&&s.createdResources&&s.createdResources.entries.push(u)})}),entries:[]},s.createdResources.observer.observe({entryTypes:["resource"]}))}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(O.clearResourceTimings(),this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}_findResourceAndAddNetworkEvents(r,n,s,i,o){if(!s||!i||!o||!r.createdResources)return;let a=r.createdResources.entries;(!a||!a.length)&&(a=O.getEntriesByType("resource"));const u=Xs(K(s).href,i,o,a,this._usedResources);if(u.mainRequest){const l=u.mainRequest;this._markResourceAsUsed(l);const h=u.corsPreFlightRequest;h&&(this._addChildSpan(n,h),this._markResourceAsUsed(h)),_t(n,l,this.getConfig().ignoreNetworkEvents,void 0,!0)}}_cleanPreviousSpanInformation(r){const n=this._xhrMem.get(r);if(n){const s=n.callbackToRemoveEvents;s&&s(),this._xhrMem.delete(r)}}_createSpan(r,n,s){const i=K(n);if(Us(i.href,this.getConfig().ignoreUrls)){this._diag.debug("ignoring span as url matches ignored url");return}const o={},a=s,u=$d(s),l=u;o[ds]=u,u!==a&&(o[_s]=a),o[xt]=i.toString(),o[fs]=i.hostname;const h=jd(i);h&&(o[ms]=h);const d=this.tracer.startSpan(l,{kind:It.CLIENT,attributes:o});return d.addEvent(W.METHOD_OPEN),this._cleanPreviousSpanInformation(r),this._xhrMem.set(r,{span:d,spanUrl:n}),d}_markResourceAsUsed(r){this._usedResources.add(r)}_patchOpen(){return r=>{const n=this;return function(...i){if(!n._isEnabled)return r.apply(this,i);const o=i[0],a=i[1];return n._createSpan(this,a,o),r.apply(this,i)}}}_patchSend(){const r=this;function n(h,d,p,_){const E=d.callbackToRemoveEvents;typeof E=="function"&&E();const{span:m,spanUrl:T,sendStartTime:A}=d;m&&(r._findResourceAndAddNetworkEvents(d,m,T,A,p),m.addEvent(h,_),r._addFinalSpanAttributes(m,d),m.end(_),r._tasksCount--),r._clearResources()}function s(h,d,p,_){const E=r._xhrMem.get(d);if(!E)return;if(E.status=d.status,E.statusText=d.statusText,r._xhrMem.delete(d),E.span){const A=E.span;r._applyAttributesAfterXHR(A,d),p?_&&(A.setStatus({code:j.ERROR,message:_}),A.setAttribute(Lt,_)):E.status&&E.status>=400&&(A.setStatus({code:j.ERROR}),A.setAttribute(Lt,String(E.status)))}const m=G(),T=Date.now();setTimeout(()=>{n(h,E,m,T)},qd)}function i(){s(W.EVENT_ERROR,this,!0,"error")}function o(){s(W.EVENT_ABORT,this,!1)}function a(){s(W.EVENT_TIMEOUT,this,!0,"timeout")}function u(){this.status<299?s(W.EVENT_LOAD,this,!1):s(W.EVENT_ERROR,this,!1)}function l(h){h.removeEventListener("abort",o),h.removeEventListener("error",i),h.removeEventListener("load",u),h.removeEventListener("timeout",a);const d=r._xhrMem.get(h);d&&(d.callbackToRemoveEvents=void 0)}return h=>function(...p){if(!r._isEnabled)return h.apply(this,p);const _=r._xhrMem.get(this);if(!_)return h.apply(this,p);const E=_.span,m=_.spanUrl;if(E&&m){if(r.getConfig().measureRequestSize&&(p!=null&&p[0])){const T=p[0],A=Bd(T);A!==void 0&&E.setAttribute(Ud,A)}R.with(w.setSpan(R.active(),E),()=>{r._tasksCount++,_.sendStartTime=G(),E.addEvent(W.METHOD_SEND),this.addEventListener("abort",o),this.addEventListener("error",i),this.addEventListener("load",u),this.addEventListener("timeout",a),_.callbackToRemoveEvents=()=>{l(this),_.createdResources&&_.createdResources.observer.disconnect()},r._addHeaders(this,m),r._addResourceObserver(this,m)})}return h.apply(this,p)}}enable(){if(!this._isEnabled){if(this._isXhrPatched){this._diag.debug("reactivating existing patch on",this.moduleName,this.version),this._isEnabled=!0;return}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(r){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.",r)}}}disable(){this._isEnabled&&(this._isEnabled=!1,this._tasksCount=0,this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}}let Ki=-1;const pt=()=>Ki,ft=e=>{addEventListener("pageshow",t=>{t.persisted&&(Ki=t.timeStamp,e(t))},!0)},I=(e,t,r,n)=>{let s,i;return o=>{t.value>=0&&(o||n)&&(i=t.value-(s!=null?s:0),(i||s===void 0)&&(s=t.value,t.delta=i,t.rating=((a,u)=>a>u[1]?"poor":a>u[0]?"needs-improvement":"good")(t.value,r),e(t)))}},Hr=e=>{requestAnimationFrame(()=>requestAnimationFrame(e))},zr=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},qt=()=>{var e,t;return(t=(e=zr())==null?void 0:e.activationStart)!=null?t:0};let at=-1;const Qi=new Set,Ji=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,jr=e=>{if(document.visibilityState==="hidden"){if(e.type==="visibilitychange")for(const t of Qi)t();isFinite(at)||(at=e.type==="visibilitychange"?e.timeStamp:0,removeEventListener("prerenderingchange",jr,!0))}},Wt=(e=!1)=>{var t;if(e&&(at=1/0),at<0){const r=qt(),n=document.prerendering||(t=globalThis.performance.getEntriesByType("visibility-state").find(s=>s.name==="hidden"&&s.startTime>=r))==null?void 0:t.startTime;at=n!=null?n:Ji(),addEventListener("visibilitychange",jr,!0),addEventListener("prerenderingchange",jr,!0),ft(()=>{setTimeout(()=>{at=Ji()})})}return{get firstHiddenTime(){return at},onHidden(r){Qi.add(r)}}},L=(e,t=-1,r,n=0,s,i,o)=>{const a=zr(),u=(a==null?void 0:a.navigationId)||0;let l="navigate";return r?l=r:pt()>=0?l="back-forward-cache":a&&(document.prerendering||qt()>0?l="prerender":document.wasDiscarded?l="restore":a.type&&(l=a.type.replace(/_/g,"-"))),{name:e,value:t,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:l,navigationId:n||u,navigationInteractionId:s,navigationURL:i||(a==null?void 0:a.name),navigationStartTime:o||0}},Zi=new WeakMap;function Te(e,t){let r=Zi.get(t);return r||(r=new WeakMap,Zi.set(t,r)),r.get(e)||r.set(e,new t),r.get(e)}class Xd{constructor(){c(this,"t");c(this,"i",0);c(this,"o",[])}h(t){var s;if(t.hadRecentInput)return;const r=this.o[0],n=this.o.at(-1);this.i&&r&&n&&t.startTime-n.startTime<1e3&&t.startTime-r.startTime<5e3?(this.i+=t.value,this.o.push(t)):(this.i=t.value,this.o=[t]),(s=this.t)==null||s.call(this,t)}}const ct=(e,t,r={})=>{try{const n=e.filter(s=>PerformanceObserver.supportedEntryTypes.includes(s));if(n.length>0){const s=new PerformanceObserver(i=>{queueMicrotask(()=>{const o=i.getEntries();n.length>1&&o.sort((a,u)=>a.startTime+a.duration-(u.startTime+u.duration)),t(o)})});for(const i of n)s.observe({type:i,buffered:!0,...r});return s}}catch(n){}},Xt=e=>{var t,r,n;return((t=globalThis.PerformanceObserver)==null?void 0:t.supportedEntryTypes.includes("soft-navigation"))&&typeof((n=(r=globalThis.PerformanceSoftNavigation)==null?void 0:r.prototype)==null?void 0:n.getLargestInteractionContentfulPaint)=="function"&&e&&e.reportSoftNavs},to=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const r=e.keys().next().value;r!==void 0&&e.delete(r)}},eo=e=>{let t=!1;return()=>{t||(e(),t=!0)}};class Yd{constructor(){c(this,"l")}}const Se=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},qr=[1800,3e3],ro=(e,t={})=>{const r=Xt(t);Se(()=>{const n=Te(t,Yd),s=Wt();let i,o=L("FCP");const a=ct(["paint"],u=>{for(const l of u)l.name==="first-contentful-paint"&&(a.disconnect(),l.startTime<s.firstHiddenTime&&(o.value=Math.max(l.startTime-qt(),0),o.entries.push(l),o.navigationId=l.navigationId||o.navigationId,i(!0)))});a&&(i=I(e,o,qr,t.reportAllChanges),ft(u=>{o=L("FCP",-1,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,pt()),i=I(e,o,qr,t.reportAllChanges),Hr(()=>{o.value=performance.now()-u.timeStamp,i(!0)})})),r&&ct(["soft-navigation"],u=>{u.forEach(l=>{n.l&&l.navigationId&&to(n.l,l);const h=Math.max((l.presentationTime||l.paintTime||0)-l.startTime,0);o=L("FCP",h,"soft-navigation",l.navigationId,l.interactionId,l.name,l.startTime),i=I(e,o,qr,t.reportAllChanges),i(!0)})},t)})},no=[.1,.25],Kd=(e,t={})=>{const r=Wt();ro(eo(()=>{let n,s=L("CLS",0);const i=Te(t,Xd),o=(p,_,E,m,T)=>{s=L("CLS",0,p,_,E,m,T),i.i=0,n=I(e,s,no,t.reportAllChanges)},a=(p=!1)=>{i.i>s.value&&(s.value=i.i,s.entries=i.o),n(p)},u=p=>{a(!0),o("soft-navigation",p.navigationId,p.interactionId,p.name,p.startTime)},l=p=>{for(const _ of p)_.entryType!=="soft-navigation"?i.h(_):u(_);a()},h=["layout-shift"];Xt(t)&&h.push("soft-navigation");const d=ct(h,l);d&&(n=I(e,s,no,t.reportAllChanges),r.onHidden(()=>{l(d.takeRecords()),n(!0)}),ft(()=>{o("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,pt()),Hr(n)}),setTimeout(n))}))};let so=0,Wr=1/0,Ae=0;const Qd=e=>{for(const t of e)t.interactionId&&(Wr=Math.min(Wr,t.interactionId),Ae=Math.max(Ae,t.interactionId),so=Ae?(Ae-Wr)/7+1:0)};let Xr;const io=()=>{var e;return Xr?so:(e=performance.interactionCount)!=null?e:0},Jd=()=>{"interactionCount"in performance||Xr||(Xr=ct(["event"],Qd,{durationThreshold:0}))};let oo=0;class Zd{constructor(){c(this,"u",[]);c(this,"v",new Map);c(this,"m");c(this,"p")}T(){oo=io(),this.u.length=0,this.v.clear()}M(t){const r=io()-oo,n=Math.min(this.u.length-1,Math.floor(r/50));return!r||n!==-1||t!=="soft-navigation"&&t!=="back-forward-cache"?this.u[n]:{_:8,id:-1,entries:[]}}h(t){var s,i;if((s=this.m)==null||s.call(this,t),!t.interactionId&&t.entryType!=="first-input")return;const r=this.u.at(-1);let n=this.v.get(t.interactionId);if(n||this.u.length<10||t.duration>r._){if(n?t.duration>n._?(n.entries=[t],n._=t.duration):t.duration===n._&&t.startTime===n.entries[0].startTime&&n.entries.push(t):(n={id:t.interactionId,entries:[t],_:t.duration},this.v.set(n.id,n),this.u.push(n)),this.u.sort((o,a)=>a._-o._),this.u.length>10){const o=this.u.splice(10);for(const a of o)this.v.delete(a.id)}(i=this.p)==null||i.call(this,n)}}}const ao=e=>{const t="requestIdleCallback"in globalThis?1e3:0,r=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if(document.visibilityState==="hidden")e();else{const s=eo(e);let i=-1;const o=()=>{n(i),s()};addEventListener("visibilitychange",o,{once:!0,capture:!0}),i=r(()=>{removeEventListener("visibilitychange",o,{capture:!0}),s()},{timeout:t})}},co=[200,500],t_=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const r=Wt();Se(()=>{var p;Jd();let n,s=L("INP");const i=Te(t,Zd),o=(_,E,m,T,A)=>{i.T(),s=L("INP",-1,_,E,m,T,A),n=I(e,s,co,t.reportAllChanges)},a=()=>{const _=i.M(s.navigationType);_&&_._!==s.value&&(s.value=_._,s.entries=_.entries,n())},u=_=>{a(),n(!0),o("soft-navigation",_.navigationId,_.interactionId,_.name,_.startTime)},l=(_,E=!1)=>{ao(()=>{for(const m of _)m.entryType!=="soft-navigation"?i.h(m):u(m);a(),E&&n(!0)})},h=["event","first-input"];Xt(t)&&h.push("soft-navigation");const d=ct(h,l,{...t,durationThreshold:(p=t.durationThreshold)!=null?p:40});n=I(e,s,co,t.reportAllChanges),d&&(r.onHidden(()=>{l(d.takeRecords(),!0)}),ft(()=>{o("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,pt())}))})};class e_{constructor(){c(this,"m");c(this,"l")}h(t){var r;(r=this.m)==null||r.call(this,t)}}const Yr=[2500,4e3],r_=(e,t={})=>{let r=!1;const n=Xt(t);Se(()=>{let s,i=Wt(),o=L("LCP");const a=Te(t,e_),u=(_,E,m,T,A)=>{o=L("LCP",-1,_,E,m,T,A),s=I(e,o,Yr,t.reportAllChanges),r=!1,_==="soft-navigation"&&(i=Wt(!0))},l=_=>{var m;a.l&&_.navigationId&&to(a.l,_),r||s(!0),u("soft-navigation",_.navigationId,_.interactionId,_.name,_.startTime);const E=(m=_.getLargestInteractionContentfulPaint)==null?void 0:m.call(_);E&&h([E])},h=_=>{var E;t.reportAllChanges||n||(_=_.slice(-1));for(const m of _){if(!m)continue;if(m.entryType==="soft-navigation"){l(m);continue}let T=0,A=[],M=m.startTime;if(m.entryType==="largest-contentful-paint")T=Math.max(m.startTime-qt(),0),a.h(m),A=[m];else if(m.entryType==="interaction-contentful-paint"){const y=m;if(!o.navigationId||"interactionId"in y&&y.interactionId!=o.navigationInteractionId)continue;M=((E=y.largestContentfulPaint)==null?void 0:E.renderTime)||0,T=Math.max(M-m.startTime,0),y.largestContentfulPaint&&(a.h(y.largestContentfulPaint),A=[y.largestContentfulPaint])}M<i.firstHiddenTime&&(o.value=T,o.entries=A,s())}},d=["largest-contentful-paint"];n&&d.push("interaction-contentful-paint","soft-navigation");const p=ct(d,h);if(p){s=I(e,o,Yr,t.reportAllChanges);const _=["keydown","click","visibilitychange"],E=m=>{if(m.isTrusted&&!r){const T=o.id;ao(()=>{if(!r){if(!n){p.disconnect();for(const A of _)removeEventListener(A,E,{capture:!0})}T===o.id&&(r=!0,s(!0))}})}};for(const m of _)addEventListener(m,E,{capture:!0});ft(m=>{u("back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,pt()),s=I(e,o,Yr,t.reportAllChanges),Hr(()=>{o.value=performance.now()-m.timeStamp,r=!0,s(!0)})})}})},Kr=[800,1800],Qr=e=>{document.prerendering?Se(()=>Qr(e)):document.readyState!=="complete"?addEventListener("load",()=>Qr(e),!0):setTimeout(e)},n_=(e,t={})=>{const r=Xt(t);let n=L("TTFB"),s=I(e,n,Kr,t.reportAllChanges);Qr(()=>{const i=zr();if(i){const o=i.responseStart;n.value=Math.max(o-qt(),0),n.entries=[i],s(!0),ft(()=>{n=L("TTFB",0,"back-forward-cache",n.navigationId,n.navigationInteractionId,n.navigationURL,pt()),s=I(e,n,Kr,t.reportAllChanges),s(!0)}),r&&ct(["soft-navigation"],a=>{a.forEach(u=>{u.navigationId&&(n=L("TTFB",0,"soft-navigation",u.navigationId,u.interactionId,u.name,u.startTime),n.entries=[u],s=I(e,n,Kr,t.reportAllChanges),s(!0))})},t)}})},s_=3e4,i_=[{register:r_,name:"web_vitals.lcp",unit:"ms",boundaries:[100,250,500,1e3,1500,2e3,2500,3e3,4e3,6e3,8e3,12e3]},{register:t_,name:"web_vitals.inp",unit:"ms",boundaries:[8,16,40,75,100,150,200,300,500,750,1e3]},{register:Kd,name:"web_vitals.cls",unit:"1",boundaries:[.01,.025,.05,.075,.1,.15,.25,.5,1]},{register:ro,name:"web_vitals.fcp",unit:"ms",boundaries:[100,250,500,900,1200,1500,1800,2200,3e3,4e3,6e3]},{register:n_,name:"web_vitals.ttfb",unit:"ms",boundaries:[50,100,200,400,600,800,1200,1800,2500,4e3]}],uo=()=>{var e;return`/${(e=window.location.pathname.split("/")[1])!=null?e:""}`},lo={login_redirect:{name:"app_shell.login_redirect",description:"Time from navigation start until the shell redirects to the login service",boundaries:[50,100,200,400,700,1e3,1500,2500,4e3,6e3]},app_ready:{name:"app_shell.app_ready",description:"Time from navigation start until the splash screen is replaced by the app",boundaries:[500,1e3,1500,2e3,3e3,4e3,6e3,8e3,12e3,2e4]}},ho=new Map,_o=e=>{var t;(t=ho.get(e))==null||t.record(performance.now(),{"page.route":uo()})},o_=e=>{i_.forEach(({register:t,name:r,unit:n,boundaries:s})=>{const i=e.createHistogram(r,{unit:n,advice:{explicitBucketBoundaries:s}});t(o=>{i.record(o.value,{"web_vital.rating":o.rating,"web_vital.navigation_type":o.navigationType,"page.route":uo()})})})},a_=()=>{const{GPv2UIOtelEndpoint:e,OtelTracesSamplerRatio:t}=P();if(typeof e!="string"||e.trim()==="")return;const r=e.trim().replace(/\/+$/,""),n=crypto.randomUUID(),s=Ds({[gs]:Kt,"deployment.environment":window.location.hostname,[Ka]:n}),i=new Au({resource:s,sampler:new ht({root:new Rr(t!=null?t:1)}),spanProcessors:[new gu(new nd({url:`${r}/v1/traces`}))]});i.register();const o=new Hl({resource:s,readers:[new nl({exporter:new ud({url:`${r}/v1/metrics`}),exportIntervalMillis:s_})]});rr.setGlobalMeterProvider(o);const a=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),u=[new RegExp(`^${a}(/|$)`,"i"),/^https?:\/\/([a-z0-9-]+\.)*dc\.services\.visualstudio\.com(\/|$)/i,/^https?:\/\/([a-z0-9-]+\.)*(google-analytics|googletagmanager)\.com(\/|$)/i];dd({tracerProvider:i,meterProvider:o,instrumentations:[new Sd,new xd({ignoreUrls:u}),new Wd({ignoreUrls:u})]});const l=o.getMeter("app-shell");o_(l),Object.keys(lo).forEach(h=>{const{name:d,description:p,boundaries:_}=lo[h];ho.set(h,l.createHistogram(d,{unit:"ms",description:p,advice:{explicitBucketBoundaries:_}}))}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&(i.forceFlush().catch(()=>{}),o.forceFlush().catch(()=>{}))}),window[Zt.otel]=Object.freeze({tracerProvider:i,meterProvider:o,serviceInstanceId:n})},po=async e=>{const t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(n=>n.toString(16).padStart(2,"0")).join("")};function c_(){const{location:e}=window,t=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`,{LoginAuthority:r,GlobalPortalClientId:n,GlobalPortalUIScopes:s,GlobalPlanBShellPostLogoutRedirectUrl:i}=P();return{authority:r,client_id:n,redirect_uri:`${t}/auth-callback`,response_type:"code",scope:s,post_logout_redirect_uri:i,monitorSession:!1}}const Re=new Po(c_()),u_=e=>{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(window.atob(t).split("").map(n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));return JSON.parse(r)},fo=()=>{localStorage.removeItem(Rt)},H=()=>{const e=localStorage.getItem(Rt);return e?JSON.parse(e):null},Jr=()=>{var e;const t=localStorage.getItem(Ue);return t?(e=JSON.parse(t))==null?void 0:e.email:null},mo=async()=>{const e=H();if(!e)return null;const t=(e.profile.given_name||"")+(e.profile.family_name||"")+e.profile.sub;return await po(t)},Zr=()=>{const e=H();return e?e.id_token:null},tn=(e,t)=>{const r={...t,...e},n=u_(e.access_token);return r.profile.sub=n.sub,r.profile.account_number=n.account_number,r.expires_at=n.exp,r.is_federated=n.is_federated,n.previous_login_date&&(r.profile.previous_login_date=n.previous_login_date),mn.setAccount({accountNumber:n.account_number,email:n.email,name:n.name,givenName:n.given_name,familyName:n.family_name,authTime:n.exp,accessToken:e.access_token,idToken:e.id_token}),localStorage.setItem(Rt,JSON.stringify(r)),r},go=e=>{tn(e,null)},Eo=()=>{const e=H();return e?e.access_token:null},To=()=>{const e=H();return e&&e.is_federated!==null&&e.is_federated!==void 0?String(e.is_federated).toLowerCase()==="true":!1},So=()=>{const e=H();return e!=null&&e.expires_at?e.expires_at>Date.now()/1e3:!1},Ao=()=>{var e;const t=H();return((e=t==null?void 0:t.profile)==null?void 0:e.previous_login_date)||null};var l_=Object.freeze({__proto__:null,clearUser:fo,getAccessToken:Eo,getHashedUserId:mo,getIdToken:Zr,getPreviousLoginDate:Ao,getUser:H,getUserEmail:Jr,hasActiveAccessToken:So,isFederatedUser:To,saveUser:go,updateUser:tn,userManager:Re});const h_=["authenticate","auth-callback","logout"],d_=e=>e.expires_at&&new Date(e.expires_at*1e3),__=e=>e.expires_at&&new Date(e.expires_at*1e3+P().TokenValidForOfflineUsePostExpiryInHours*60*60*1e3),Ro=()=>{if(!P().IsLoginEnabled)return!1;const e=H();if(!Zr())return!0;if(!e.expires_at)return!1;const t=new Date;return navigator.onLine?t>d_(e):t>__(e)},p_=()=>{const e=window.location.pathname.split("/");return h_.includes(e[e.length-1])},f_=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="authenticate"?(P().IsLoginEnabled?Re.signinRedirect():window.location.href="/",!0):!1},m_=()=>{let e="/";const t=localStorage.getItem(Qt);t&&(localStorage.removeItem(Qt),e=t),sessionStorage.setItem(We.SessionStorage.ShowLastLoginPopup,"true"),window.location.href=e},g_=e=>{if(!e.id_token)throw new Error("Missing property:id_token");return e},en=e=>{const t=p_();(!t||e)&&(t||localStorage.setItem(Qt,window.location.href),window.location.href="/authenticate")},E_=async e=>{const t=`${e.profile.sub}-${e.profile.customer_id}`,r=await po(t);return{...e,profile:{...e.profile,hashed_identifier:r}}},T_=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="auth-callback"?(Re.signinRedirectCallback().then(g_).then(E_).then(go).then(m_).catch(en),!0):!1};class S_ extends pn{render(){return lt` <ix-splash-screen></ix-splash-screen> `}}window.customElements.define("splash-screen",S_);class A_{constructor(){this.permissions=[],this.loading=!1,this.getPermissions=async()=>{var t;const r=(t=mn)==null?void 0:t.access_token;if(!r)return[];const{ApiBaseUrl:n}=P(),s=await fetch(`${n}/usermanagement/my-permissions?exclude_parents=false&exclude_siblings=true`,{headers:{Authorization:`Bearer ${r}`}});return s.ok?s.json():[]},Mo(this,{permissions:Io,setPermissions:vo})}setPermissions(t){this.permissions=t}tryLoadPermissions(){try{this.loading||(this.loading=!0,this.getPermissions().then(t=>{this.setPermissions(t),this.loading=!1}).catch(()=>{this.loading=!1}))}catch(t){this.loading=!1}}clearPermissions(){this.setPermissions([])}hasExternalUserCreate(){return this.hasPermission(Be,bt)||this.hasPermission(qe,bt)}hasConnectivityCreate(){return this.hasPermission(Jt,bt)}hasPrivilegeLevel(t,r){const n=[bn,bt,An,Rn],s=n.findIndex(o=>o===t),i=n.findIndex(o=>o===r);return s>=i}hasPermission(t,r){return No(this.permissions).some(n=>n.permission_name===t&&this.hasPrivilegeLevel(r,n.privilege))}}const rn=new A_,bo=async()=>{const{getAccessToken:e}=await Promise.resolve().then(function(){return l_}),t=new Headers;return t.append("Authorization",`Bearer ${e()}`),t},R_=async()=>{const{ApiBaseUrl:e}=P(),{ORDER_MANAGEMENT_PERMISSIONS:t}=await Promise.resolve().then(function(){return $o}),r=`${e}/inventory/locations?embed=permissions&page_size=1000`;let n=[],s=1;for(;;){const o=await bo(),a=await fetch(`${r}&cursor=${s}`,{headers:o});if(!a.ok)return Promise.reject();const u=await a.json();if(n.push(...u.items),u.self===u.last)break;s++}n=n.filter(o=>o.permissions.some(a=>t.includes(a.name)));const i=new Map;for(const o of n)i.has(o.account_number)?i.get(o.account_number).push(o.site_id):i.set(o.account_number,[o.site_id]);return i},b_=async e=>{const{ApiBaseUrl:t}=P(),r=new URLSearchParams;r.append("process","Cross_connect");const n=[...e.keys()],s=[...new Set([...e.values()].flat())];r.append("account_number",n.join(",")),r.append("site",s.join(","));const i=await bo(),o=await fetch(`${t}/site-navigations/site-configurations?${r}`,{headers:i});return o.ok?await o.json():Promise.reject()},w_=async()=>{try{const e=await R_();return e.size===0?!1:(await b_(e)).some(t=>{var r;return t.portal==="GlobalPortal"&&!!((r=e.get(t.account_number))!=null&&r.includes(t.site))})}catch(e){return console.error("Failed to determine portal-managed inventory:",e),!1}},{ApiBaseUrl:O_}=P(),C_=new URL(O_).origin;function y_(e){return e.origin===C_}const P_=["type","title","detail","instance","code","correlation_id","timestamp","account_number"];function M_(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;const t=e;return typeof t.status=="number"&&P_.every(r=>typeof t[r]=="string"&&t[r]!=="")}function v_(){const e=globalThis.fetch;globalThis.fetch=async function(...t){var r;const[n]=t,s=n instanceof Request?n.url:String(n),i=await e.apply(this,t);try{y_(new URL(s,(r=globalThis.location)==null?void 0:r.href))&&i.status>=400&&i.clone().json().then(o=>{var a;M_(o)&&((a=globalThis[Zt.appInsights])==null||a.trackEvent({name:"internal_api_error",properties:{url:s,body:o}}))}).catch(o=>console.warn(`[fetch] couldn't read body ${s}`,o))}catch(o){console.error("Failed to fetch:",o)}return i}}const I_="SUPERUSER";class nn extends pn{_isSuperUser(t){return t.some(r=>{var n;return(n=r.provenance)==null?void 0:n.includes(I_)})}constructor(){super(),this._currentView="splash",this.appLoaded=!1,this._onPopState=()=>{P().IsLoginEnabled&&Ro()&&en()};try{zo(),v_()}catch(r){console.error("Telemetry initialization failed:",r)}try{a_()}catch(r){console.error("OpenTelemetry initialization failed:",r)}const t=window.location.pathname;if(t==="/session-expired"){this._currentView="session-expired",this._loadView("session-expired");return}if(t==="/logout"){this._currentView="logout",this._loadView("logout");return}if(f_()||T_()){this._currentView="splash";return}if(Ro()){this._currentView="splash",_o("login_redirect"),en();return}this._currentView="app",this._loadApp()}async _loadView(t){t==="session-expired"?await import("@digital-realty/ix-app-logic/views/session-expiry.js"):t==="logout"&&await import("./logout-BZJ5_qly.js")}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this._onPopState)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this._onPopState)}_getAccountNumber(){var t,r,n;return(n=new URLSearchParams(window.location.search).get("selected_account_number"))!=null?n:(r=(t=H())==null?void 0:t.profile)==null?void 0:r.account_number}_redirectTo(t){window.location.href=t}_isESGAccessOnly(t,r){const n=t.filter(s=>s.account_number===r);return n.length===1&&n[0].permission_name==="ESG Reporting"}async _applyGomFF(t){var r;const n=Jr(),s=structuredClone(window.gpConfig);if(!n||!s)return;const i=this._isSuperUser(t),o=!!((r=s["app-shell"])!=null&&r.IsInventoryManagementEnabled),a=await w_()&&(i||o);s["app-shell"].IsInventoryManagementEnabled=a,s["ui-launchpad"].IsInventoryManagementEnabled=a,window.gpConfig=Object.freeze(s)}_applyMfeOverrides(t,r){const n={};for(const s of Object.keys(t))n[s]={...t[s],enabled:r.includes(s)};return n}async _loadApp(){var t;const{authedUser:r}=await import("@digital-realty/ix-account-switcher");await r.hydrateStore();const[n,s]=await Promise.allSettled([fetch("./registered-apps.json").then(l=>l.json()),rn.getPermissions()]);if(n.status==="rejected"){console.error("Failed to load registered apps:",n.reason);return}if(s.status==="rejected"){console.error("Failed to load permissions:",s.reason);return}const{registeredApps:i}=n.value,o=s.value,a=(t=this._getAccountNumber())!=null?t:"";if(!a){const{LoginAuthority:l}=P();this._redirectTo(`${l}/Account/NoAccess`);return}const u=this._isESGAccessOnly(o,a)?this._applyMfeOverrides(i,["ui-esg"]):i;await this._applyGomFF(o),window.registeredApps=Object.freeze(u),rn.setPermissions(o),await import("./app-TN7-eRuH.js"),this.appLoaded=!0,_o("app_ready")}render(){switch(this._currentView){case"session-expired":return lt`<ix-session-expiry></ix-session-expiry>`;case"logout":return lt`<ixp-logout></ixp-logout>`;case"app":return this.appLoaded?lt`<global-portal-app appTitle="DLR" showDrawer></global-portal-app>`:lt`<splash-screen></splash-screen>`;default:return lt`<splash-screen></splash-screen>`}}}_n([fn({type:String})],nn.prototype,"_currentView",void 0),_n([fn({type:Boolean})],nn.prototype,"appLoaded",void 0),window.customElements.define("gp-bootstrap",nn);export{Gn as A,Ue as B,wn as C,Sn as D,Un as E,Tn as F,Ie as G,kn as I,Le as M,Bn as O,Hn as R,Dn as S,qe as U,Zr as a,mo as b,fo as c,Jr as d,Eo as e,H as f,P as g,tn as h,Ao as i,To as j,We as k,Mn as l,Be as m,yn as n,Pn as o,rn as p,xe as q,zn as r,Ne as s,Zt as t,Re as u,Kt as v,gn as w,So as x,En as y,Rt as z};
|