@digital-realty/app-shell 15.0.1 → 15.0.2

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 zi=Object.defineProperty;var ji=(e,t,r)=>t in e?zi(e,t,{enumerable:!0,config
10
10
  To resolve the conflict:`,Vs(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
  `,$s(i,t),`To resolve the conflict:
13
- `,Vs(i,t))}return n}}class _l{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=b.active());const i=this._backingStorages;for(let o=0;o<i.length;o++)i[o].record(t,r,n,s)}}class pl{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 fl{constructor(){c(this,"_buffer",new Map)}observe(t,r,n={}){if(!mr(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 ml{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(mr));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(mr)),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 pl(s._descriptor.name,s._descriptor.valueType);let o=Promise.resolve(n(i));r!=null&&(o=kt(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 fl;let o=Promise.resolve(n(i));r!=null&&(o=kt(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&&Eu(n.instruments,r))}}class gl extends Gs{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 Fs(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:b.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 El{constructor(t,r){c(this,"metricStorageRegistry",new zr);c(this,"observableRegistry",new ml);c(this,"meter");c(this,"_meterProviderSharedState");c(this,"_instrumentationScope");this.meter=new il(this),this._meterProviderSharedState=t,this._instrumentationScope=r}registerMetricStorage(t){const r=this._registerMetricStorage(t,gl);return r.length===1?r[0]:new _l(r)}registerAsyncMetricStorage(t){return this._registerMetricStorage(t,cl)}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=Xu(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 Tl{constructor(t){c(this,"viewRegistry",new Wu);c(this,"metricCollectors",[]);c(this,"meterSharedStates",new Map);c(this,"resource");this.resource=t}getMeterSharedState(t){const r=gu(t);let n=this.meterSharedStates.get(r);return n==null&&(n=new El(this,t),this.meterSharedStates.set(r,n)),n}selectAggregations(t){const r=[];for(const n of this.metricCollectors)r.push([n,Us(n.selectAggregation(t))]);return r}}class Sl{constructor(t,r){c(this,"_sharedState");c(this,"_metricReader");this._sharedState=t,this._metricReader=r}async collect(t){const r=L(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 Al=/[\^$\\.+?()[\]{}|]/g;class be{constructor(t){c(this,"_matchAll");c(this,"_regexp");t==="*"?(this._matchAll=!0,this._regexp=/.*/):(this._matchAll=!1,this._regexp=new RegExp(be.escapePattern(t)))}match(t){return this._matchAll?!0:this._regexp.test(t)}static escapePattern(t){return`^${t.replace(Al,"\\$&").replace("*",".*")}$`}static hasWildcard(t){return t.includes("*")}}class ue{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 bl{process(t,r){return t}}class wl{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 Rl(){return Cl}function Ol(e){return new wl(e)}const Cl=new bl;class yl{constructor(t){c(this,"_nameFilter");c(this,"_type");c(this,"_unitFilter");var r;this._nameFilter=new be((r=t==null?void 0:t.name)!=null?r:"*"),this._type=t==null?void 0:t.type,this._unitFilter=new ue(t==null?void 0:t.unit)}getType(){return this._type}getNameFilter(){return this._nameFilter}getUnitFilter(){return this._unitFilter}}class Pl{constructor(t){c(this,"_nameFilter");c(this,"_versionFilter");c(this,"_schemaUrlFilter");this._nameFilter=new ue(t==null?void 0:t.name),this._versionFilter=new ue(t==null?void 0:t.version),this._schemaUrlFilter=new ue(t==null?void 0:t.schemaUrl)}getNameFilter(){return this._nameFilter}getVersionFilter(){return this._versionFilter}getSchemaUrlFilter(){return this._schemaUrlFilter}}function Ml(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}function vl(e){if(Ml(e))throw new Error("Cannot create view with no selector arguments supplied");if(e.name!=null&&((e==null?void 0:e.instrumentName)==null||be.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 Il{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;vl(t),t.attributesProcessors!=null?this.attributesProcessor=Ol(t.attributesProcessors):this.attributesProcessor=Rl(),this.name=t.name,this.description=t.description,this.aggregation=Us((r=t.aggregation)!=null?r:{type:B.DEFAULT}),this.instrumentSelector=new yl({name:t.instrumentName,type:t.instrumentType,unit:t.instrumentUnit}),this.meterSelector=new Pl({name:t.meterName,version:t.meterVersion,schemaUrl:t.meterSchemaUrl}),this.aggregationCardinalityLimit=t.aggregationCardinalityLimit}}class Ll{constructor(t){c(this,"_sharedState");c(this,"_shutdown",!1);var r;if(this._sharedState=new Tl((r=t==null?void 0:t.resource)!=null?r:as()),(t==null?void 0:t.views)!=null&&t.views.length>0)for(const n of t.views)this._sharedState.viewRegistry.addView(new Il(n));if((t==null?void 0:t.readers)!=null&&t.readers.length>0)for(const n of t.readers){const s=new Sl(this._sharedState,n);n.setMetricProducer(s),this._sharedState.metricCollectors.push(s),t.sdkMetricsEnabled&&n instanceof Bs&&n._setSelfObsMeterProvider(this)}}getMeter(t,r="",n={}){return this._shutdown?(f.warn("A shutdown MeterProvider cannot provide a Meter"),yt()):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 Hs{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 zs 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 Nl(e){if(Number.isFinite(e)&&e>0)return e;throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${e}')`)}function xl(e){if(e!=null)return async()=>e}function Ul(e,t,r){var n,s,i,o,a,u;return{timeoutMillis:Nl((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 Dl(){return{timeoutMillis:1e4,concurrencyLimit:30,compression:"none"}}class kl{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 Bl(e){return new kl(e.concurrencyLimit)}function Gl(e){return Object.prototype.hasOwnProperty.call(e,"partialSuccess")}function Fl(){return{handleResponse(e){e==null||!Gl(e)||e.partialSuccess==null||Object.keys(e.partialSuccess).length===0||f.warn("Received Partial Success response:",JSON.stringify(e.partialSuccess))}}}class $l{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 zs("Export failed with retryable status")})):(s("export_failed"),r({code:D.FAILED,error:new zs("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 Vl(e,t){return new $l(e.transport,e.serializer,Fl(),e.promiseHandler,e.metrics,t.timeout)}function Hl(e,t,r,n){return Vl({transport:n,serializer:t,promiseHandler:Bl(e),metrics:r},{timeout:e.timeoutMillis})}const js="http.response.status_code",zl="otel.component.name",jl="otel.component.type",ql="server.address",Wl="server.port",Xl="error.type",Yl="0.221.0",qs=new Map;class Kl{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",Yl):yt(),u=(l=qs.get(r))!=null?l:0;if(qs.set(r,u+1),this.standardAttrs={[jl]:r,[zl]:`${r}/${u}`},i){let h=i;i.includes("://")||(h=`http://${i}`);try{const d=new URL(h);this.standardAttrs[ql]=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[Wl]=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,[Xl]:s instanceof Error?s.name:"export_failed"}:this.standardAttrs;this.exported.add(r,o);const a={...o,...this.responseAttributesFromError(s)},u=qa(Ke(n,i))/1e3;this.duration.record(u,a)}}}const Ws={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}},Ql={name:"span",countItems:e=>e.length};var Xs;(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"})(Xs||(Xs={}));class Ys{emit(t){}enabled(){return!1}}const Jl=new Ys,le=Symbol.for("io.opentelemetry.js.api.logs"),Ft=globalThis;function Zl(e,t,r){return n=>n===e?t:r}const Ks=1;class th{getLogger(t,r,n){return new Ys}}const Qs=new th;class eh{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):Jl}}class Js{getLogger(t,r,n){var s;return(s=this._getDelegateLogger(t,r,n))!==null&&s!==void 0?s:new eh(this,t,r,n)}_getDelegate(){var t;return(t=this._delegate)!==null&&t!==void 0?t:Qs}_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 jr{constructor(){this._proxyLoggerProvider=new Js}static getInstance(){return this._instance||(this._instance=new jr),this._instance}setGlobalLoggerProvider(t){return Ft[le]?this.getLoggerProvider():(Ft[le]=Zl(Ks,t,Qs),this._proxyLoggerProvider._setDelegate(t),t)}getLoggerProvider(){var t,r;return(r=(t=Ft[le])===null||t===void 0?void 0:t.call(Ft,Ks))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(t,r,n){return this.getLoggerProvider().getLogger(t,r,n)}disable(){delete Ft[le],this._proxyLoggerProvider=new Js}}const Zs=jr.getInstance();function ti(e,t){const r={attributes:J(e.attributes,t),droppedAttributesCount:0},n=e.schemaUrl;return n&&n!==""&&(r.schemaUrl=n),r}function ei(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=>rh(r,e[r],t))}function rh(e,t,r){return{key:e,value:gr(t,r)}}function gr(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]=gr(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:gr(e[n[i]],t)};return{kvlistValue:{values:s}}}return{}}function nh(e){const t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}function sh(e){return nh(e).toString()}const ih=typeof BigInt<"u"?sh:j;function ri(e){return e}const ni={encodeHrTime:ih,encodeSpanContext:ri,encodeOptionalSpanContext:ri,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 he;(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"})(he||(he={}));function oh(e,t){const r=ti(e.resource,t);return{resource:r,schemaUrl:r.schemaUrl,scopeMetrics:ah(e.scopeMetrics,t)}}function ah(e,t){return Array.from(e.map(r=>({scope:ei(r.scope,t),metrics:r.metrics.map(n=>ch(n,t)),schemaUrl:r.scope.schemaUrl})))}function ch(e,t){const r={name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit},n=dh(e.aggregationTemporality);switch(e.dataPointType){case V.SUM:r.sum={aggregationTemporality:n,isMonotonic:e.isMonotonic,dataPoints:si(e,t)};break;case V.GAUGE:r.gauge={dataPoints:si(e,t)};break;case V.HISTOGRAM:r.histogram={aggregationTemporality:n,dataPoints:lh(e,t)};break;case V.EXPONENTIAL_HISTOGRAM:r.exponentialHistogram={aggregationTemporality:n,dataPoints:hh(e,t)};break}return r}function uh(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 si(e,t){return e.dataPoints.map(r=>uh(r,e.descriptor.valueType,t))}function lh(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 hh(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 dh(e){switch(e){case k.DELTA:return he.AGGREGATION_TEMPORALITY_DELTA;case k.CUMULATIVE:return he.AGGREGATION_TEMPORALITY_CUMULATIVE}}function _h(e,t){return{resourceMetrics:e.map(r=>oh(r,t))}}const ph={serializeRequest:e=>{const t=_h([e],ni);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`),{}}}},fh=256,mh=512;function ii(e,t){let r=e&255|fh;return t&&(r|=mh),r}function gh(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=>Th(l,t)),droppedEventsCount:e.droppedEventsCount,status:{code:n.code,message:n.message},links:e.links.map(l=>Eh(l,t)),droppedLinksCount:e.droppedLinksCount,flags:ii(r.traceFlags,(u=e.parentSpanContext)==null?void 0:u.isRemote)}}function Eh(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:ii(e.context.traceFlags,e.context.isRemote)}}function Th(e,t){return{attributes:e.attributes?J(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Sh(e,t){return{resourceSpans:bh(e,t)}}function Ah(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 bh(e,t){const r=Ah(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=>gh(m,t));u.push({scope:ei(_[0].instrumentationScope,t),spans:E,schemaUrl:_[0].instrumentationScope.schemaUrl})}h=l.next()}const d=ti(o,t),p={resource:d,scopeSpans:u,schemaUrl:d.schemaUrl};n.push(p),i=s.next()}return n}const wh={serializeRequest:e=>{const t=Sh(e,ni);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`),{}}}},Er=5,Rh=1e3,Oh=5e3,Ch=1.5,oi=.2;function yh(){return Math.random()*(2*oi)-oi}class Ph{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=Er,s=Rh;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+yh()),Oh),0);s=s*Ch;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 ${Er-n} retry attempts.`):o.status==="retryable"?f.info(`Export failed after maximum retry attempts (${Er}).`):f.info(`Export failed with non-retryable error: ${o.error}`),o}shutdown(){return this._transport.shutdown()}}function Mh(e){return new Ph(e.transport)}function vh(e){return e===429||e===502||e===503||e===504}function Ih(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 Lh=60*1024,Nh=9;let Tr=0,de=0;class xh{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=Tr+o>Lh,u=de>=Nh,l=!a&&!u;if(l)Tr+=o,de++;else{const h=a?"size limit":"count limit";f.debug(`keepalive disabled: ${(o/1024).toFixed(1)}KB payload, ${de} 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(vh(d.status)){f.warn(`export response retryable (status: ${d.status})`);const p=d.headers.get("Retry-After");return{status:"retryable",retryInMillis:Ih(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 Dh(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&&(Tr-=o,de--)}}shutdown(){}}function Uh(e){return new xh(e)}function Dh(e){return e instanceof TypeError&&!e.cause}function kh(e,t,r){return Hl(e,t,r,Mh({transport:Uh(e)}))}function Bh(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 Gh(e,t,r){return async()=>{const n={...await r()},s={};return t!=null&&Object.assign(s,await t()),e!=null&&Object.assign(s,Bh(await e())),Object.assign(s,n)}}function Fh(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 $h(e,t,r){var n,s;return{...Ul(e,t,r),headers:Gh(e.headers,t.headers,r.headers),url:(s=(n=Fh(e.url))!=null?n:t.url)!=null?s:r.url}}function Vh(e,t){return{...Dl(),headers:async()=>e,url:"http://localhost:4318/"+t}}function Hh(e){return typeof e.headers=="function"?e.headers:xl(e.headers)}function zh(e,t,r){return $h({url:e.url,timeoutMillis:e.timeoutMillis,headers:Hh(e),concurrencyLimit:e.concurrencyLimit},{},Vh(r,t))}function ai(e,t,r,n){return new Kl({componentType:e,metricsHelper:t,url:r,meterProvider:n,responseAttributesFromError:s=>{if(!s)return{[js]:200};if(!(s instanceof Error))return{};if(s.message.startsWith("Fetch request failed with non-retryable status ")){const i=s.message.substring(47);return{[js]:Number(i)}}return{}}})}function ci(e,t,r,n,s,i,o){const a=zh(e,i,o);return kh(a,t,ai(r,n,a.url,e.selfObsMeterProvider))}const jh="otlp_http_span_exporter";class qh extends Hs{constructor(t={}){super(ci(t,wh,jh,Ql,t.selfObsMeterProvider,"v1/traces",{"Content-Type":"application/json"}))}}var _e;(function(e){e[e.DELTA=0]="DELTA",e[e.CUMULATIVE=1]="CUMULATIVE",e[e.LOWMEMORY=2]="LOWMEMORY"})(_e||(_e={}));const Sr=()=>k.CUMULATIVE,ui=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}},li=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 Wh(){const e="cumulative".toLowerCase();return e==="cumulative"?Sr:e==="delta"?ui:e==="lowmemory"?li:(f.warn(`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '${e}', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead.`),Sr)}function Xh(e){return e!=null?e===_e.DELTA?ui:e===_e.LOWMEMORY?li:Sr:Wh()}const Yh=Object.freeze({type:B.DEFAULT});function Kh(e){var t;return(t=e==null?void 0:e.aggregationPreference)!=null?t:(()=>Yh)}class Qh extends Hs{constructor(r,n){super(r);c(this,"_aggregationTemporalitySelector");c(this,"_aggregationSelector");this._aggregationSelector=Kh(n),this._aggregationTemporalitySelector=Xh(n==null?void 0:n.temporalityPreference)}selectAggregation(r){return this._aggregationSelector(r)}selectAggregationTemporality(r){return this._aggregationTemporalitySelector(r)}}const hi="otlp_http_metric_exporter";class Jh extends Qh{constructor(r){super(ci(r!=null?r:{},ph,hi,Ws,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(ai(hi,Ws,this._url,r))}}function Zh(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 td(e){e.forEach(t=>t.disable())}function ed(e){var i,o;const t=e.tracerProvider||R.getTracerProvider(),r=e.meterProvider||Be.getMeterProvider(),n=e.loggerProvider||Zs.getLoggerProvider(),s=(o=(i=e.instrumentations)==null?void 0:i.flat())!=null?o:[];return Zh(s,t,r,n),()=>{td(s)}}let v=console.error.bind(console);function $t(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 di=(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 $t(s,"__original",n),$t(s,"__unwrap",()=>{e[t]===s&&$t(e,t,n)}),$t(s,"__wrapped",!0),$t(e,t,s),s},rd=(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=>{di(n,s,r)})})},_i=(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}},nd=(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=>{_i(r,n)})})};class sd{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",di);c(this,"_unwrap",_i);c(this,"_massWrap",rd);c(this,"_massUnwrap",nd);this.instrumentationName=t,this.instrumentationVersion=r,this.setConfig(n),this._diag=f.createComponentLogger({namespace:t}),this._tracer=R.getTracer(t,r),this._meter=Be.getMeter(t,r),this._logger=Zs.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 Ar extends sd{constructor(t,r,n){super(t,r,n),this._config.enabled&&this.enable()}}function Vt(e,t,r){let n,s;try{s=e()}catch(i){n=i}finally{return t(n,s),s}}var Ht;(function(e){e.DOCUMENT_LOAD="documentLoad",e.DOCUMENT_FETCH="documentFetch",e.RESOURCE_FETCH="resourceFetch"})(Ht||(Ht={}));const id="0.66.0",od="@opentelemetry/instrumentation-document-load";var pe;(function(e){e.FIRST_PAINT="firstPaint",e.FIRST_CONTENTFUL_PAINT="firstContentfulPaint"})(pe||(pe={}));const ad=()=>{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},pi={"first-paint":pe.FIRST_PAINT,"first-contentful-paint":pe.FIRST_CONTENTFUL_PAINT},cd=e=>{var r;const t=(r=O.getEntriesByType)==null?void 0:r.call(O,"paint");t&&t.forEach(({name:n,startTime:s})=>{dt(pi,n)&&e.addEvent(pi[n],s)})};class ud extends Ar{constructor(r={}){super(od,id,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")===re),n=ad(),s=r&&r.content||"";b.with(U.extract(et,{traceparent:s}),()=>{var o;const i=this._startSpan(Ht.DOCUMENT_LOAD,S.FETCH_START,n);i&&(b.with(R.setSpan(b.active(),i),()=>{const a=this._startSpan(Ht.DOCUMENT_FETCH,S.FETCH_START,n);a&&(a.setAttribute(Lt,location.href),b.with(R.setSpan(b.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(Lt,location.href),i.setAttribute($a,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||cd(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(Ht.RESOURCE_FETCH,S.FETCH_START,r,n);s&&(s.setAttribute(Lt,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?R.setSpan(b.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&&Vt(()=>n(r),s=>{s&&this._diag.error("addCustomAttributesOnSpan",s)})}_addCustomAttributesOnResourceSpan(r,n,s){s&&Vt(()=>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 ld="http.request.body.size",fi=f.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-fetch/utils"});function hd(...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}=dd(t.body);return t.body=r,n}else return Promise.resolve(pd(t.body))}else{const t=e[0];return t!=null&&t.body?t.clone().text().then(r=>br(r)):Promise.resolve()}}function dd(e){if(!e.pipeThrough)return fi.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 _d(e){return typeof Document<"u"&&e instanceof Document}function pd(e){if(_d(e))return new XMLSerializer().serializeToString(document).length;if(typeof e=="string")return br(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return md(e);if(e instanceof URLSearchParams)return br(e.toString());if(e.byteLength!==void 0)return e.byteLength;fi.warn("unknown body type")}const fd=new TextEncoder;function br(e){return fd.encode(e).byteLength}function md(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 gd(e){const t=Td(),r=e.toUpperCase();return r in t?r:"_OTHER"}const Ed={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let wr;function Td(){return wr===void 0&&(wr=Ed),wr}const Sd={"https:":"443","http:":"80"};function Ad(e){const t=Number(e.port||Sd[e.protocol]);if(t&&!isNaN(t))return t}const mi="0.221.0",bd=300,gi=typeof PerformanceObserver<"u";class wd extends Ar{constructor(r={}){super("@opentelemetry/instrumentation-fetch",mi,r);c(this,"component","fetch");c(this,"version",mi);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]},R.setSpan(b.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(Bn,n.status),r.setAttribute(Gn,s.hostname);const i=Ad(s);i&&r.setAttribute(Fn,i)}_addHeaders(r,n){if(!Ts(n,this.getConfig().propagateTraceHeaderCorsUrls)){const s={};U.inject(b.active(),s),Object.keys(s).length>0&&this._diag.debug("headers inject skipped due to CORS policy");return}if(r instanceof Request)U.inject(b.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(b.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(is(r,this.getConfig().ignoreUrls)){this._diag.debug("ignoring span as url matches ignored url");return}const s={},i=n.method,o=gd(n.method||"GET"),a=o;return s[Dn]=o,o!==i&&(s[kn]=i),s[Lt]=r,this.tracer.startSpan(a,{kind:Mt.CLIENT,attributes:s})}_findResourceAndAddNetworkEvents(r,n,s){let i=n.entries;if(!i.length){if(!performance.getEntriesByType)return;i=performance.getEntriesByType("resource")}const o=Es(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=L(Date.now()),o=G();this._addFinalSpanAttributes(r,s),s.status>=400&&(r.setStatus({code:z.ERROR}),r.setAttribute(It,String(s.status))),setTimeout(()=>{var a;(a=n.observer)==null||a.disconnect(),this._findResourceAndAddNetworkEvents(r,n,o),this._tasksCount--,this._clearResources(),r.end(i)},bd)}_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&&hd(...i).then(m=>{m&&l.setAttribute(ld,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 b.with(R.setSpan(b.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&&Vt(()=>i(r,n,s),o=>{o&&this._diag.error("applyCustomAttributesOnSpan",o)})}_callRequestHook(r,n){const s=this.getConfig().requestHook;s&&Vt(()=>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(!gi){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(){gi&&this._isEnabled&&(this._isEnabled=!1,this._usedResources=new WeakSet)}}const Rd="http.request.body.size";var q;(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"})(q||(q={}));const Od=f.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils"});function Cd(e){return typeof Document<"u"&&e instanceof Document}function yd(e){if(Cd(e))return new XMLSerializer().serializeToString(document).length;if(typeof e=="string")return Ei(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return Md(e);if(e instanceof URLSearchParams)return Ei(e.toString());if(e.byteLength!==void 0)return e.byteLength;Od.warn("unknown body type")}const Pd=new TextEncoder;function Ei(e){return Pd.encode(e).byteLength}function Md(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 vd(e){const t=Ld(),r=e.toUpperCase();return r in t?r:"_OTHER"}const Id={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let Rr;function Ld(){return Rr===void 0&&(Rr=Id),Rr}const Nd={"https:":"443","http:":"80"};function xd(e){const t=Number(e.port||Nd[e.protocol]);if(t&&!isNaN(t))return t}const Ti="0.221.0",Ud=300;class Dd extends Ar{constructor(r={}){super("@opentelemetry/instrumentation-xml-http-request",Ti,r);c(this,"component","xml-http-request");c(this,"version",Ti);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(!Ts(s,this.getConfig().propagateTraceHeaderCorsUrls)){const o={};U.inject(b.active(),o),Object.keys(o).length>0&&this._diag.debug("headers inject skipped due to CORS policy");return}const i={};U.inject(b.active(),i),Object.keys(i).forEach(o=>{r.setRequestHeader(o,String(i[o]))})}_addChildSpan(r,n){b.with(R.setSpan(b.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(Bn,n.status)}_applyAttributesAfterXHR(r,n){const s=this.getConfig().applyCustomAttributesOnSpan;typeof s=="function"&&Vt(()=>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=Es(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(is(i.href,this.getConfig().ignoreUrls)){this._diag.debug("ignoring span as url matches ignored url");return}const o={},a=s,u=vd(s),l=u;o[Dn]=u,u!==a&&(o[kn]=a),o[Lt]=i.toString(),o[Gn]=i.hostname;const h=xd(i);h&&(o[Fn]=h);const d=this.tracer.startSpan(l,{kind:Mt.CLIENT,attributes:o});return d.addEvent(q.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:z.ERROR,message:_}),A.setAttribute(It,_)):E.status&&E.status>=400&&(A.setStatus({code:z.ERROR}),A.setAttribute(It,String(E.status)))}const m=G(),T=Date.now();setTimeout(()=>{n(h,E,m,T)},Ud)}function i(){s(q.EVENT_ERROR,this,!0,"error")}function o(){s(q.EVENT_ABORT,this,!1)}function a(){s(q.EVENT_TIMEOUT,this,!0,"timeout")}function u(){this.status<299?s(q.EVENT_LOAD,this,!1):s(q.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=yd(T);A!==void 0&&E.setAttribute(Rd,A)}b.with(R.setSpan(b.active(),E),()=>{r._tasksCount++,_.sendStartTime=G(),E.addEvent(q.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 Si=-1;const pt=()=>Si,ft=e=>{addEventListener("pageshow",t=>{t.persisted&&(Si=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)))}},Or=e=>{requestAnimationFrame(()=>requestAnimationFrame(e))},Cr=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},zt=()=>{var e,t;return(t=(e=Cr())==null?void 0:e.activationStart)!=null?t:0};let at=-1;const Ai=new Set,bi=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,yr=e=>{if(document.visibilityState==="hidden"){if(e.type==="visibilitychange")for(const t of Ai)t();isFinite(at)||(at=e.type==="visibilitychange"?e.timeStamp:0,removeEventListener("prerenderingchange",yr,!0))}},jt=(e=!1)=>{var t;if(e&&(at=1/0),at<0){const r=zt(),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:bi(),addEventListener("visibilitychange",yr,!0),addEventListener("prerenderingchange",yr,!0),ft(()=>{setTimeout(()=>{at=bi()})})}return{get firstHiddenTime(){return at},onHidden(r){Ai.add(r)}}},N=(e,t=-1,r,n=0,s,i,o)=>{const a=Cr(),u=(a==null?void 0:a.navigationId)||0;let l="navigate";return r?l=r:pt()>=0?l="back-forward-cache":a&&(document.prerendering||zt()>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}},wi=new WeakMap;function fe(e,t){let r=wi.get(t);return r||(r=new WeakMap,wi.set(t,r)),r.get(e)||r.set(e,new t),r.get(e)}class kd{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){}},qt=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},Ri=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const r=e.keys().next().value;r!==void 0&&e.delete(r)}},Oi=e=>{let t=!1;return()=>{t||(e(),t=!0)}};class Bd{constructor(){c(this,"l")}}const me=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},Pr=[1800,3e3],Ci=(e,t={})=>{const r=qt(t);me(()=>{const n=fe(t,Bd),s=jt();let i,o=N("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-zt(),0),o.entries.push(l),o.navigationId=l.navigationId||o.navigationId,i(!0)))});a&&(i=I(e,o,Pr,t.reportAllChanges),ft(u=>{o=N("FCP",-1,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,pt()),i=I(e,o,Pr,t.reportAllChanges),Or(()=>{o.value=performance.now()-u.timeStamp,i(!0)})})),r&&ct(["soft-navigation"],u=>{u.forEach(l=>{n.l&&l.navigationId&&Ri(n.l,l);const h=Math.max((l.presentationTime||l.paintTime||0)-l.startTime,0);o=N("FCP",h,"soft-navigation",l.navigationId,l.interactionId,l.name,l.startTime),i=I(e,o,Pr,t.reportAllChanges),i(!0)})},t)})},yi=[.1,.25],Gd=(e,t={})=>{const r=jt();Ci(Oi(()=>{let n,s=N("CLS",0);const i=fe(t,kd),o=(p,_,E,m,T)=>{s=N("CLS",0,p,_,E,m,T),i.i=0,n=I(e,s,yi,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"];qt(t)&&h.push("soft-navigation");const d=ct(h,l);d&&(n=I(e,s,yi,t.reportAllChanges),r.onHidden(()=>{l(d.takeRecords()),n(!0)}),ft(()=>{o("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,pt()),Or(n)}),setTimeout(n))}))};let Pi=0,Mr=1/0,ge=0;const Fd=e=>{for(const t of e)t.interactionId&&(Mr=Math.min(Mr,t.interactionId),ge=Math.max(ge,t.interactionId),Pi=ge?(ge-Mr)/7+1:0)};let vr;const Mi=()=>{var e;return vr?Pi:(e=performance.interactionCount)!=null?e:0},$d=()=>{"interactionCount"in performance||vr||(vr=ct(["event"],Fd,{durationThreshold:0}))};let vi=0;class Vd{constructor(){c(this,"u",[]);c(this,"v",new Map);c(this,"m");c(this,"p")}T(){vi=Mi(),this.u.length=0,this.v.clear()}M(t){const r=Mi()-vi,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 Ii=e=>{const t="requestIdleCallback"in globalThis?1e3:0,r=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if(document.visibilityState==="hidden")e();else{const s=Oi(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})}},Li=[200,500],Hd=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const r=jt();me(()=>{var p;$d();let n,s=N("INP");const i=fe(t,Vd),o=(_,E,m,T,A)=>{i.T(),s=N("INP",-1,_,E,m,T,A),n=I(e,s,Li,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)=>{Ii(()=>{for(const m of _)m.entryType!=="soft-navigation"?i.h(m):u(m);a(),E&&n(!0)})},h=["event","first-input"];qt(t)&&h.push("soft-navigation");const d=ct(h,l,{...t,durationThreshold:(p=t.durationThreshold)!=null?p:40});n=I(e,s,Li,t.reportAllChanges),d&&(r.onHidden(()=>{l(d.takeRecords(),!0)}),ft(()=>{o("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,pt())}))})};class zd{constructor(){c(this,"m");c(this,"l")}h(t){var r;(r=this.m)==null||r.call(this,t)}}const Ir=[2500,4e3],jd=(e,t={})=>{let r=!1;const n=qt(t);me(()=>{let s,i=jt(),o=N("LCP");const a=fe(t,zd),u=(_,E,m,T,A)=>{o=N("LCP",-1,_,E,m,T,A),s=I(e,o,Ir,t.reportAllChanges),r=!1,_==="soft-navigation"&&(i=jt(!0))},l=_=>{var m;a.l&&_.navigationId&&Ri(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-zt(),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,Ir,t.reportAllChanges);const _=["keydown","click","visibilitychange"],E=m=>{if(m.isTrusted&&!r){const T=o.id;Ii(()=>{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,Ir,t.reportAllChanges),Or(()=>{o.value=performance.now()-m.timeStamp,r=!0,s(!0)})})}})},Lr=[800,1800],Nr=e=>{document.prerendering?me(()=>Nr(e)):document.readyState!=="complete"?addEventListener("load",()=>Nr(e),!0):setTimeout(e)},qd=(e,t={})=>{const r=qt(t);let n=N("TTFB"),s=I(e,n,Lr,t.reportAllChanges);Nr(()=>{const i=Cr();if(i){const o=i.responseStart;n.value=Math.max(o-zt(),0),n.entries=[i],s(!0),ft(()=>{n=N("TTFB",0,"back-forward-cache",n.navigationId,n.navigationInteractionId,n.navigationURL,pt()),s=I(e,n,Lr,t.reportAllChanges),s(!0)}),r&&ct(["soft-navigation"],a=>{a.forEach(u=>{u.navigationId&&(n=N("TTFB",0,"soft-navigation",u.navigationId,u.interactionId,u.name,u.startTime),n.entries=[u],s=I(e,n,Lr,t.reportAllChanges),s(!0))})},t)}})},Wd=3e4,Xd=[{register:jd,name:"web_vitals.lcp",unit:"ms",boundaries:[100,250,500,1e3,1500,2e3,2500,3e3,4e3,6e3,8e3,12e3]},{register:Hd,name:"web_vitals.inp",unit:"ms",boundaries:[8,16,40,75,100,150,200,300,500,750,1e3]},{register:Gd,name:"web_vitals.cls",unit:"1",boundaries:[.01,.025,.05,.075,.1,.15,.25,.5,1]},{register:Ci,name:"web_vitals.fcp",unit:"ms",boundaries:[100,250,500,900,1200,1500,1800,2200,3e3,4e3,6e3]},{register:qd,name:"web_vitals.ttfb",unit:"ms",boundaries:[50,100,200,400,600,800,1200,1800,2500,4e3]}],Ni=()=>{var e;return`/${(e=window.location.pathname.split("/")[1])!=null?e:""}`},xi={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]}},Ui=new Map,Di=e=>{var t;(t=Ui.get(e))==null||t.record(performance.now(),{"page.route":Ni()})},Yd=e=>{Xd.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":Ni()})})})},Kd=()=>{const{GPv2UIOtelEndpoint:e,OtelTracesSamplerRatio:t}=P();if(typeof e!="string"||e.trim()==="")return;const r=e.trim().replace(/\/+$/,""),n=crypto.randomUUID(),s=os({[$n]:Ce,"deployment.environment":window.location.hostname,[Ga]:n}),i=new lu({resource:s,sampler:new ht({root:new sr(t!=null?t:1)}),spanProcessors:[new ou(new qh({url:`${r}/v1/traces`}))]});i.register();const o=new Ll({resource:s,readers:[new qu({exporter:new Jh({url:`${r}/v1/metrics`}),exportIntervalMillis:Wd})]});Be.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];ed({tracerProvider:i,meterProvider:o,instrumentations:[new ud,new wd({ignoreUrls:u}),new Dd({ignoreUrls:u})]});const l=o.getMeter("app-shell");Yd(l),Object.keys(xi).forEach(h=>{const{name:d,description:p,boundaries:_}=xi[h];Ui.set(h,l.createHistogram(d,{unit:"ms",description:p,advice:{explicitBucketBoundaries:_}}))}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&(i.forceFlush().catch(()=>{}),o.forceFlush().catch(()=>{}))}),window[Me.otel]=Object.freeze({tracerProvider:i,meterProvider:o,serviceInstanceId:n})},ki=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 Qd(){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 xr=new Xi(Qd()),Jd=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)},Zd=()=>{localStorage.removeItem(Xt)},W=()=>{const e=localStorage.getItem(Xt);return e?JSON.parse(e):null},Bi=()=>{var e;const t=localStorage.getItem(tn);return t?(e=JSON.parse(t))==null?void 0:e.email:null},t_=async()=>{const e=W();if(!e)return null;const t=(e.profile.given_name||"")+(e.profile.family_name||"")+e.profile.sub;return await ki(t)},Gi=()=>{const e=W();return e?e.id_token:null},Fi=(e,t)=>{const r={...t,...e},n=Jd(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),Yr.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(Xt,JSON.stringify(r)),r},e_=e=>{Fi(e,null)},$i=()=>{const e=W();return e?e.access_token:null},r_=()=>{const e=W();return e&&e.is_federated!==null&&e.is_federated!==void 0?String(e.is_federated).toLowerCase()==="true":!1},n_=()=>{const e=W();return e!=null&&e.expires_at?e.expires_at>Date.now()/1e3:!1},s_=()=>{var e;const t=W();return((e=t==null?void 0:t.profile)==null?void 0:e.previous_login_date)||null},i_=["authenticate","auth-callback","logout"],o_=e=>e.expires_at&&new Date(e.expires_at*1e3),a_=e=>e.expires_at&&new Date(e.expires_at*1e3+P().TokenValidForOfflineUsePostExpiryInHours*60*60*1e3),Vi=()=>{if(!P().IsLoginEnabled)return!1;const e=W();if(!Gi())return!0;if(!e.expires_at)return!1;const t=new Date;return navigator.onLine?t>o_(e):t>a_(e)},c_=()=>{const e=window.location.pathname.split("/");return i_.includes(e[e.length-1])},u_=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="authenticate"?(P().IsLoginEnabled?xr.signinRedirect():window.location.href="/",!0):!1},l_=()=>{let e="/";const t=localStorage.getItem(ye);t&&(localStorage.removeItem(ye),e=t),sessionStorage.setItem(pn.SessionStorage.ShowLastLoginPopup,"true"),window.location.href=e},h_=e=>{if(!e.id_token)throw new Error("Missing property:id_token");return e},Ur=e=>{const t=c_();(!t||e)&&(t||localStorage.setItem(ye,window.location.href),window.location.href="/authenticate")},d_=async e=>{const t=`${e.profile.sub}-${e.profile.customer_id}`,r=await ki(t);return{...e,profile:{...e.profile,hashed_identifier:r}}},__=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="auth-callback"?(xr.signinRedirectCallback().then(h_).then(d_).then(e_).then(l_).catch(Ur),!0):!1};class p_ extends Wr{render(){return lt` <ix-splash-screen></ix-splash-screen> `}}window.customElements.define("splash-screen",p_);class f_{constructor(){this.permissions=[],this.loading=!1,this.getPermissions=async()=>{var t;const r=(t=Yr)==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():[]},Yi(this,{permissions:Qi,setPermissions:Ki})}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(nn,Yt)||this.hasPermission(dn,Yt)}hasConnectivityCreate(){return this.hasPermission(Pe,Yt)}hasPrivilegeLevel(t,r){const n=[uo,Yt,ao,co],s=n.findIndex(o=>o===t),i=n.findIndex(o=>o===r);return s>=i}hasPermission(t,r){return Ji(this.permissions).some(n=>n.permission_name===t&&this.hasPrivilegeLevel(r,n.privilege))}}const Dr=new f_,Hi=()=>{const e=new Headers;return e.append("Authorization",`Bearer ${$i()}`),e},m_=async()=>{const{ApiBaseUrl:e}=P(),t=`${e}/inventory/locations?embed=permissions&page_size=1000`;let r=[],n=1;for(;;){const i=await fetch(`${t}&cursor=${n}`,{headers:Hi()});if(!i.ok)return Promise.reject();const o=await i.json();if(r.push(...o.items),o.self===o.last)break;n++}r=r.filter(i=>i.permissions.some(o=>_n.includes(o.name)));const s=new Map;for(const i of r)s.has(i.account_number)?s.get(i.account_number).push(i.site_id):s.set(i.account_number,[i.site_id]);return s},g_=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 fetch(`${t}/site-navigations/site-configurations?${r}`,{headers:Hi()});return i.ok?await i.json():Promise.reject()},E_=async()=>{try{const e=await m_();return e.size===0?!1:(await g_(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}},T_="SUPERUSER";class kr extends Wr{_isSuperUser(t){return t.some(r=>{var n;return(n=r.provenance)==null?void 0:n.includes(T_)})}constructor(){super(),this._currentView="splash",this.appLoaded=!1,this._onPopState=()=>{P().IsLoginEnabled&&Vi()&&Ur()};try{No()}catch(r){console.error("Telemetry initialization failed:",r)}try{Kd()}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(u_()||__()){this._currentView="splash";return}if(Vi()){this._currentView="splash",Di("login_redirect"),Ur();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-DHu3NPe-.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=W())==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=Bi(),s=structuredClone(window.gpConfig);if(!n||!s)return;const i=this._isSuperUser(t),o=!!((r=s["app-shell"])!=null&&r.IsInventoryManagementEnabled),a=await E_()&&(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()),Dr.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),Dr.setPermissions(o),await import("./app-CQYtI6QN.js"),this.appLoaded=!0,Di("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>`}}}qr([Xr({type:String})],kr.prototype,"_currentView",void 0),qr([Xr({type:Boolean})],kr.prototype,"appLoaded",void 0),window.customElements.define("gp-bootstrap",kr);export{Oo as A,tn as B,lo as C,oo as D,bo as E,io as F,Kr as G,Ro as I,Jr as M,_n as O,Mo as R,wo as S,dn as U,Gi as a,t_ as b,Zd as c,Bi as d,$i as e,W as f,P as g,Fi as h,s_ as i,r_ as j,pn as k,mo as l,nn as m,po as n,fo as o,Dr as p,Zr as q,vo as r,Qr as s,Me as t,xr as u,Ce as v,no as w,n_ as x,so as y,Xt as z};
13
+ `,Vs(i,t))}return n}}class _l{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=b.active());const i=this._backingStorages;for(let o=0;o<i.length;o++)i[o].record(t,r,n,s)}}class pl{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 fl{constructor(){c(this,"_buffer",new Map)}observe(t,r,n={}){if(!mr(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 ml{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(mr));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(mr)),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 pl(s._descriptor.name,s._descriptor.valueType);let o=Promise.resolve(n(i));r!=null&&(o=kt(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 fl;let o=Promise.resolve(n(i));r!=null&&(o=kt(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&&Eu(n.instruments,r))}}class gl extends Gs{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 Fs(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:b.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 El{constructor(t,r){c(this,"metricStorageRegistry",new zr);c(this,"observableRegistry",new ml);c(this,"meter");c(this,"_meterProviderSharedState");c(this,"_instrumentationScope");this.meter=new il(this),this._meterProviderSharedState=t,this._instrumentationScope=r}registerMetricStorage(t){const r=this._registerMetricStorage(t,gl);return r.length===1?r[0]:new _l(r)}registerAsyncMetricStorage(t){return this._registerMetricStorage(t,cl)}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=Xu(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 Tl{constructor(t){c(this,"viewRegistry",new Wu);c(this,"metricCollectors",[]);c(this,"meterSharedStates",new Map);c(this,"resource");this.resource=t}getMeterSharedState(t){const r=gu(t);let n=this.meterSharedStates.get(r);return n==null&&(n=new El(this,t),this.meterSharedStates.set(r,n)),n}selectAggregations(t){const r=[];for(const n of this.metricCollectors)r.push([n,Us(n.selectAggregation(t))]);return r}}class Sl{constructor(t,r){c(this,"_sharedState");c(this,"_metricReader");this._sharedState=t,this._metricReader=r}async collect(t){const r=L(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 Al=/[\^$\\.+?()[\]{}|]/g;class be{constructor(t){c(this,"_matchAll");c(this,"_regexp");t==="*"?(this._matchAll=!0,this._regexp=/.*/):(this._matchAll=!1,this._regexp=new RegExp(be.escapePattern(t)))}match(t){return this._matchAll?!0:this._regexp.test(t)}static escapePattern(t){return`^${t.replace(Al,"\\$&").replace("*",".*")}$`}static hasWildcard(t){return t.includes("*")}}class ue{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 bl{process(t,r){return t}}class wl{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 Rl(){return Cl}function Ol(e){return new wl(e)}const Cl=new bl;class yl{constructor(t){c(this,"_nameFilter");c(this,"_type");c(this,"_unitFilter");var r;this._nameFilter=new be((r=t==null?void 0:t.name)!=null?r:"*"),this._type=t==null?void 0:t.type,this._unitFilter=new ue(t==null?void 0:t.unit)}getType(){return this._type}getNameFilter(){return this._nameFilter}getUnitFilter(){return this._unitFilter}}class Pl{constructor(t){c(this,"_nameFilter");c(this,"_versionFilter");c(this,"_schemaUrlFilter");this._nameFilter=new ue(t==null?void 0:t.name),this._versionFilter=new ue(t==null?void 0:t.version),this._schemaUrlFilter=new ue(t==null?void 0:t.schemaUrl)}getNameFilter(){return this._nameFilter}getVersionFilter(){return this._versionFilter}getSchemaUrlFilter(){return this._schemaUrlFilter}}function Ml(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}function vl(e){if(Ml(e))throw new Error("Cannot create view with no selector arguments supplied");if(e.name!=null&&((e==null?void 0:e.instrumentName)==null||be.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 Il{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;vl(t),t.attributesProcessors!=null?this.attributesProcessor=Ol(t.attributesProcessors):this.attributesProcessor=Rl(),this.name=t.name,this.description=t.description,this.aggregation=Us((r=t.aggregation)!=null?r:{type:B.DEFAULT}),this.instrumentSelector=new yl({name:t.instrumentName,type:t.instrumentType,unit:t.instrumentUnit}),this.meterSelector=new Pl({name:t.meterName,version:t.meterVersion,schemaUrl:t.meterSchemaUrl}),this.aggregationCardinalityLimit=t.aggregationCardinalityLimit}}class Ll{constructor(t){c(this,"_sharedState");c(this,"_shutdown",!1);var r;if(this._sharedState=new Tl((r=t==null?void 0:t.resource)!=null?r:as()),(t==null?void 0:t.views)!=null&&t.views.length>0)for(const n of t.views)this._sharedState.viewRegistry.addView(new Il(n));if((t==null?void 0:t.readers)!=null&&t.readers.length>0)for(const n of t.readers){const s=new Sl(this._sharedState,n);n.setMetricProducer(s),this._sharedState.metricCollectors.push(s),t.sdkMetricsEnabled&&n instanceof Bs&&n._setSelfObsMeterProvider(this)}}getMeter(t,r="",n={}){return this._shutdown?(f.warn("A shutdown MeterProvider cannot provide a Meter"),yt()):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 Hs{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 zs 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 Nl(e){if(Number.isFinite(e)&&e>0)return e;throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${e}')`)}function xl(e){if(e!=null)return async()=>e}function Ul(e,t,r){var n,s,i,o,a,u;return{timeoutMillis:Nl((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 Dl(){return{timeoutMillis:1e4,concurrencyLimit:30,compression:"none"}}class kl{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 Bl(e){return new kl(e.concurrencyLimit)}function Gl(e){return Object.prototype.hasOwnProperty.call(e,"partialSuccess")}function Fl(){return{handleResponse(e){e==null||!Gl(e)||e.partialSuccess==null||Object.keys(e.partialSuccess).length===0||f.warn("Received Partial Success response:",JSON.stringify(e.partialSuccess))}}}class $l{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 zs("Export failed with retryable status")})):(s("export_failed"),r({code:D.FAILED,error:new zs("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 Vl(e,t){return new $l(e.transport,e.serializer,Fl(),e.promiseHandler,e.metrics,t.timeout)}function Hl(e,t,r,n){return Vl({transport:n,serializer:t,promiseHandler:Bl(e),metrics:r},{timeout:e.timeoutMillis})}const js="http.response.status_code",zl="otel.component.name",jl="otel.component.type",ql="server.address",Wl="server.port",Xl="error.type",Yl="0.221.0",qs=new Map;class Kl{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",Yl):yt(),u=(l=qs.get(r))!=null?l:0;if(qs.set(r,u+1),this.standardAttrs={[jl]:r,[zl]:`${r}/${u}`},i){let h=i;i.includes("://")||(h=`http://${i}`);try{const d=new URL(h);this.standardAttrs[ql]=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[Wl]=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,[Xl]:s instanceof Error?s.name:"export_failed"}:this.standardAttrs;this.exported.add(r,o);const a={...o,...this.responseAttributesFromError(s)},u=qa(Ke(n,i))/1e3;this.duration.record(u,a)}}}const Ws={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}},Ql={name:"span",countItems:e=>e.length};var Xs;(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"})(Xs||(Xs={}));class Ys{emit(t){}enabled(){return!1}}const Jl=new Ys,le=Symbol.for("io.opentelemetry.js.api.logs"),Ft=globalThis;function Zl(e,t,r){return n=>n===e?t:r}const Ks=1;class th{getLogger(t,r,n){return new Ys}}const Qs=new th;class eh{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):Jl}}class Js{getLogger(t,r,n){var s;return(s=this._getDelegateLogger(t,r,n))!==null&&s!==void 0?s:new eh(this,t,r,n)}_getDelegate(){var t;return(t=this._delegate)!==null&&t!==void 0?t:Qs}_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 jr{constructor(){this._proxyLoggerProvider=new Js}static getInstance(){return this._instance||(this._instance=new jr),this._instance}setGlobalLoggerProvider(t){return Ft[le]?this.getLoggerProvider():(Ft[le]=Zl(Ks,t,Qs),this._proxyLoggerProvider._setDelegate(t),t)}getLoggerProvider(){var t,r;return(r=(t=Ft[le])===null||t===void 0?void 0:t.call(Ft,Ks))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(t,r,n){return this.getLoggerProvider().getLogger(t,r,n)}disable(){delete Ft[le],this._proxyLoggerProvider=new Js}}const Zs=jr.getInstance();function ti(e,t){const r={attributes:J(e.attributes,t),droppedAttributesCount:0},n=e.schemaUrl;return n&&n!==""&&(r.schemaUrl=n),r}function ei(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=>rh(r,e[r],t))}function rh(e,t,r){return{key:e,value:gr(t,r)}}function gr(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]=gr(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:gr(e[n[i]],t)};return{kvlistValue:{values:s}}}return{}}function nh(e){const t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}function sh(e){return nh(e).toString()}const ih=typeof BigInt<"u"?sh:j;function ri(e){return e}const ni={encodeHrTime:ih,encodeSpanContext:ri,encodeOptionalSpanContext:ri,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 he;(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"})(he||(he={}));function oh(e,t){const r=ti(e.resource,t);return{resource:r,schemaUrl:r.schemaUrl,scopeMetrics:ah(e.scopeMetrics,t)}}function ah(e,t){return Array.from(e.map(r=>({scope:ei(r.scope,t),metrics:r.metrics.map(n=>ch(n,t)),schemaUrl:r.scope.schemaUrl})))}function ch(e,t){const r={name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit},n=dh(e.aggregationTemporality);switch(e.dataPointType){case V.SUM:r.sum={aggregationTemporality:n,isMonotonic:e.isMonotonic,dataPoints:si(e,t)};break;case V.GAUGE:r.gauge={dataPoints:si(e,t)};break;case V.HISTOGRAM:r.histogram={aggregationTemporality:n,dataPoints:lh(e,t)};break;case V.EXPONENTIAL_HISTOGRAM:r.exponentialHistogram={aggregationTemporality:n,dataPoints:hh(e,t)};break}return r}function uh(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 si(e,t){return e.dataPoints.map(r=>uh(r,e.descriptor.valueType,t))}function lh(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 hh(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 dh(e){switch(e){case k.DELTA:return he.AGGREGATION_TEMPORALITY_DELTA;case k.CUMULATIVE:return he.AGGREGATION_TEMPORALITY_CUMULATIVE}}function _h(e,t){return{resourceMetrics:e.map(r=>oh(r,t))}}const ph={serializeRequest:e=>{const t=_h([e],ni);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`),{}}}},fh=256,mh=512;function ii(e,t){let r=e&255|fh;return t&&(r|=mh),r}function gh(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=>Th(l,t)),droppedEventsCount:e.droppedEventsCount,status:{code:n.code,message:n.message},links:e.links.map(l=>Eh(l,t)),droppedLinksCount:e.droppedLinksCount,flags:ii(r.traceFlags,(u=e.parentSpanContext)==null?void 0:u.isRemote)}}function Eh(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:ii(e.context.traceFlags,e.context.isRemote)}}function Th(e,t){return{attributes:e.attributes?J(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Sh(e,t){return{resourceSpans:bh(e,t)}}function Ah(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 bh(e,t){const r=Ah(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=>gh(m,t));u.push({scope:ei(_[0].instrumentationScope,t),spans:E,schemaUrl:_[0].instrumentationScope.schemaUrl})}h=l.next()}const d=ti(o,t),p={resource:d,scopeSpans:u,schemaUrl:d.schemaUrl};n.push(p),i=s.next()}return n}const wh={serializeRequest:e=>{const t=Sh(e,ni);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`),{}}}},Er=5,Rh=1e3,Oh=5e3,Ch=1.5,oi=.2;function yh(){return Math.random()*(2*oi)-oi}class Ph{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=Er,s=Rh;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+yh()),Oh),0);s=s*Ch;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 ${Er-n} retry attempts.`):o.status==="retryable"?f.info(`Export failed after maximum retry attempts (${Er}).`):f.info(`Export failed with non-retryable error: ${o.error}`),o}shutdown(){return this._transport.shutdown()}}function Mh(e){return new Ph(e.transport)}function vh(e){return e===429||e===502||e===503||e===504}function Ih(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 Lh=60*1024,Nh=9;let Tr=0,de=0;class xh{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=Tr+o>Lh,u=de>=Nh,l=!a&&!u;if(l)Tr+=o,de++;else{const h=a?"size limit":"count limit";f.debug(`keepalive disabled: ${(o/1024).toFixed(1)}KB payload, ${de} 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(vh(d.status)){f.warn(`export response retryable (status: ${d.status})`);const p=d.headers.get("Retry-After");return{status:"retryable",retryInMillis:Ih(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 Dh(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&&(Tr-=o,de--)}}shutdown(){}}function Uh(e){return new xh(e)}function Dh(e){return e instanceof TypeError&&!e.cause}function kh(e,t,r){return Hl(e,t,r,Mh({transport:Uh(e)}))}function Bh(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 Gh(e,t,r){return async()=>{const n={...await r()},s={};return t!=null&&Object.assign(s,await t()),e!=null&&Object.assign(s,Bh(await e())),Object.assign(s,n)}}function Fh(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 $h(e,t,r){var n,s;return{...Ul(e,t,r),headers:Gh(e.headers,t.headers,r.headers),url:(s=(n=Fh(e.url))!=null?n:t.url)!=null?s:r.url}}function Vh(e,t){return{...Dl(),headers:async()=>e,url:"http://localhost:4318/"+t}}function Hh(e){return typeof e.headers=="function"?e.headers:xl(e.headers)}function zh(e,t,r){return $h({url:e.url,timeoutMillis:e.timeoutMillis,headers:Hh(e),concurrencyLimit:e.concurrencyLimit},{},Vh(r,t))}function ai(e,t,r,n){return new Kl({componentType:e,metricsHelper:t,url:r,meterProvider:n,responseAttributesFromError:s=>{if(!s)return{[js]:200};if(!(s instanceof Error))return{};if(s.message.startsWith("Fetch request failed with non-retryable status ")){const i=s.message.substring(47);return{[js]:Number(i)}}return{}}})}function ci(e,t,r,n,s,i,o){const a=zh(e,i,o);return kh(a,t,ai(r,n,a.url,e.selfObsMeterProvider))}const jh="otlp_http_span_exporter";class qh extends Hs{constructor(t={}){super(ci(t,wh,jh,Ql,t.selfObsMeterProvider,"v1/traces",{"Content-Type":"application/json"}))}}var _e;(function(e){e[e.DELTA=0]="DELTA",e[e.CUMULATIVE=1]="CUMULATIVE",e[e.LOWMEMORY=2]="LOWMEMORY"})(_e||(_e={}));const Sr=()=>k.CUMULATIVE,ui=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}},li=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 Wh(){const e="cumulative".toLowerCase();return e==="cumulative"?Sr:e==="delta"?ui:e==="lowmemory"?li:(f.warn(`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '${e}', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead.`),Sr)}function Xh(e){return e!=null?e===_e.DELTA?ui:e===_e.LOWMEMORY?li:Sr:Wh()}const Yh=Object.freeze({type:B.DEFAULT});function Kh(e){var t;return(t=e==null?void 0:e.aggregationPreference)!=null?t:(()=>Yh)}class Qh extends Hs{constructor(r,n){super(r);c(this,"_aggregationTemporalitySelector");c(this,"_aggregationSelector");this._aggregationSelector=Kh(n),this._aggregationTemporalitySelector=Xh(n==null?void 0:n.temporalityPreference)}selectAggregation(r){return this._aggregationSelector(r)}selectAggregationTemporality(r){return this._aggregationTemporalitySelector(r)}}const hi="otlp_http_metric_exporter";class Jh extends Qh{constructor(r){super(ci(r!=null?r:{},ph,hi,Ws,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(ai(hi,Ws,this._url,r))}}function Zh(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 td(e){e.forEach(t=>t.disable())}function ed(e){var i,o;const t=e.tracerProvider||R.getTracerProvider(),r=e.meterProvider||Be.getMeterProvider(),n=e.loggerProvider||Zs.getLoggerProvider(),s=(o=(i=e.instrumentations)==null?void 0:i.flat())!=null?o:[];return Zh(s,t,r,n),()=>{td(s)}}let v=console.error.bind(console);function $t(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 di=(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 $t(s,"__original",n),$t(s,"__unwrap",()=>{e[t]===s&&$t(e,t,n)}),$t(s,"__wrapped",!0),$t(e,t,s),s},rd=(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=>{di(n,s,r)})})},_i=(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}},nd=(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=>{_i(r,n)})})};class sd{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",di);c(this,"_unwrap",_i);c(this,"_massWrap",rd);c(this,"_massUnwrap",nd);this.instrumentationName=t,this.instrumentationVersion=r,this.setConfig(n),this._diag=f.createComponentLogger({namespace:t}),this._tracer=R.getTracer(t,r),this._meter=Be.getMeter(t,r),this._logger=Zs.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 Ar extends sd{constructor(t,r,n){super(t,r,n),this._config.enabled&&this.enable()}}function Vt(e,t,r){let n,s;try{s=e()}catch(i){n=i}finally{return t(n,s),s}}var Ht;(function(e){e.DOCUMENT_LOAD="documentLoad",e.DOCUMENT_FETCH="documentFetch",e.RESOURCE_FETCH="resourceFetch"})(Ht||(Ht={}));const id="0.66.0",od="@opentelemetry/instrumentation-document-load";var pe;(function(e){e.FIRST_PAINT="firstPaint",e.FIRST_CONTENTFUL_PAINT="firstContentfulPaint"})(pe||(pe={}));const ad=()=>{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},pi={"first-paint":pe.FIRST_PAINT,"first-contentful-paint":pe.FIRST_CONTENTFUL_PAINT},cd=e=>{var r;const t=(r=O.getEntriesByType)==null?void 0:r.call(O,"paint");t&&t.forEach(({name:n,startTime:s})=>{dt(pi,n)&&e.addEvent(pi[n],s)})};class ud extends Ar{constructor(r={}){super(od,id,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")===re),n=ad(),s=r&&r.content||"";b.with(U.extract(et,{traceparent:s}),()=>{var o;const i=this._startSpan(Ht.DOCUMENT_LOAD,S.FETCH_START,n);i&&(b.with(R.setSpan(b.active(),i),()=>{const a=this._startSpan(Ht.DOCUMENT_FETCH,S.FETCH_START,n);a&&(a.setAttribute(Lt,location.href),b.with(R.setSpan(b.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(Lt,location.href),i.setAttribute($a,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||cd(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(Ht.RESOURCE_FETCH,S.FETCH_START,r,n);s&&(s.setAttribute(Lt,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?R.setSpan(b.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&&Vt(()=>n(r),s=>{s&&this._diag.error("addCustomAttributesOnSpan",s)})}_addCustomAttributesOnResourceSpan(r,n,s){s&&Vt(()=>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 ld="http.request.body.size",fi=f.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-fetch/utils"});function hd(...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}=dd(t.body);return t.body=r,n}else return Promise.resolve(pd(t.body))}else{const t=e[0];return t!=null&&t.body?t.clone().text().then(r=>br(r)):Promise.resolve()}}function dd(e){if(!e.pipeThrough)return fi.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 _d(e){return typeof Document<"u"&&e instanceof Document}function pd(e){if(_d(e))return new XMLSerializer().serializeToString(document).length;if(typeof e=="string")return br(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return md(e);if(e instanceof URLSearchParams)return br(e.toString());if(e.byteLength!==void 0)return e.byteLength;fi.warn("unknown body type")}const fd=new TextEncoder;function br(e){return fd.encode(e).byteLength}function md(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 gd(e){const t=Td(),r=e.toUpperCase();return r in t?r:"_OTHER"}const Ed={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let wr;function Td(){return wr===void 0&&(wr=Ed),wr}const Sd={"https:":"443","http:":"80"};function Ad(e){const t=Number(e.port||Sd[e.protocol]);if(t&&!isNaN(t))return t}const mi="0.221.0",bd=300,gi=typeof PerformanceObserver<"u";class wd extends Ar{constructor(r={}){super("@opentelemetry/instrumentation-fetch",mi,r);c(this,"component","fetch");c(this,"version",mi);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]},R.setSpan(b.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(Bn,n.status),r.setAttribute(Gn,s.hostname);const i=Ad(s);i&&r.setAttribute(Fn,i)}_addHeaders(r,n){if(!Ts(n,this.getConfig().propagateTraceHeaderCorsUrls)){const s={};U.inject(b.active(),s),Object.keys(s).length>0&&this._diag.debug("headers inject skipped due to CORS policy");return}if(r instanceof Request)U.inject(b.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(b.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(is(r,this.getConfig().ignoreUrls)){this._diag.debug("ignoring span as url matches ignored url");return}const s={},i=n.method,o=gd(n.method||"GET"),a=o;return s[Dn]=o,o!==i&&(s[kn]=i),s[Lt]=r,this.tracer.startSpan(a,{kind:Mt.CLIENT,attributes:s})}_findResourceAndAddNetworkEvents(r,n,s){let i=n.entries;if(!i.length){if(!performance.getEntriesByType)return;i=performance.getEntriesByType("resource")}const o=Es(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=L(Date.now()),o=G();this._addFinalSpanAttributes(r,s),s.status>=400&&(r.setStatus({code:z.ERROR}),r.setAttribute(It,String(s.status))),setTimeout(()=>{var a;(a=n.observer)==null||a.disconnect(),this._findResourceAndAddNetworkEvents(r,n,o),this._tasksCount--,this._clearResources(),r.end(i)},bd)}_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&&hd(...i).then(m=>{m&&l.setAttribute(ld,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 b.with(R.setSpan(b.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&&Vt(()=>i(r,n,s),o=>{o&&this._diag.error("applyCustomAttributesOnSpan",o)})}_callRequestHook(r,n){const s=this.getConfig().requestHook;s&&Vt(()=>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(!gi){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(){gi&&this._isEnabled&&(this._isEnabled=!1,this._usedResources=new WeakSet)}}const Rd="http.request.body.size";var q;(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"})(q||(q={}));const Od=f.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils"});function Cd(e){return typeof Document<"u"&&e instanceof Document}function yd(e){if(Cd(e))return new XMLSerializer().serializeToString(document).length;if(typeof e=="string")return Ei(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return Md(e);if(e instanceof URLSearchParams)return Ei(e.toString());if(e.byteLength!==void 0)return e.byteLength;Od.warn("unknown body type")}const Pd=new TextEncoder;function Ei(e){return Pd.encode(e).byteLength}function Md(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 vd(e){const t=Ld(),r=e.toUpperCase();return r in t?r:"_OTHER"}const Id={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let Rr;function Ld(){return Rr===void 0&&(Rr=Id),Rr}const Nd={"https:":"443","http:":"80"};function xd(e){const t=Number(e.port||Nd[e.protocol]);if(t&&!isNaN(t))return t}const Ti="0.221.0",Ud=300;class Dd extends Ar{constructor(r={}){super("@opentelemetry/instrumentation-xml-http-request",Ti,r);c(this,"component","xml-http-request");c(this,"version",Ti);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(!Ts(s,this.getConfig().propagateTraceHeaderCorsUrls)){const o={};U.inject(b.active(),o),Object.keys(o).length>0&&this._diag.debug("headers inject skipped due to CORS policy");return}const i={};U.inject(b.active(),i),Object.keys(i).forEach(o=>{r.setRequestHeader(o,String(i[o]))})}_addChildSpan(r,n){b.with(R.setSpan(b.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(Bn,n.status)}_applyAttributesAfterXHR(r,n){const s=this.getConfig().applyCustomAttributesOnSpan;typeof s=="function"&&Vt(()=>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=Es(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(is(i.href,this.getConfig().ignoreUrls)){this._diag.debug("ignoring span as url matches ignored url");return}const o={},a=s,u=vd(s),l=u;o[Dn]=u,u!==a&&(o[kn]=a),o[Lt]=i.toString(),o[Gn]=i.hostname;const h=xd(i);h&&(o[Fn]=h);const d=this.tracer.startSpan(l,{kind:Mt.CLIENT,attributes:o});return d.addEvent(q.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:z.ERROR,message:_}),A.setAttribute(It,_)):E.status&&E.status>=400&&(A.setStatus({code:z.ERROR}),A.setAttribute(It,String(E.status)))}const m=G(),T=Date.now();setTimeout(()=>{n(h,E,m,T)},Ud)}function i(){s(q.EVENT_ERROR,this,!0,"error")}function o(){s(q.EVENT_ABORT,this,!1)}function a(){s(q.EVENT_TIMEOUT,this,!0,"timeout")}function u(){this.status<299?s(q.EVENT_LOAD,this,!1):s(q.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=yd(T);A!==void 0&&E.setAttribute(Rd,A)}b.with(R.setSpan(b.active(),E),()=>{r._tasksCount++,_.sendStartTime=G(),E.addEvent(q.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 Si=-1;const pt=()=>Si,ft=e=>{addEventListener("pageshow",t=>{t.persisted&&(Si=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)))}},Or=e=>{requestAnimationFrame(()=>requestAnimationFrame(e))},Cr=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},zt=()=>{var e,t;return(t=(e=Cr())==null?void 0:e.activationStart)!=null?t:0};let at=-1;const Ai=new Set,bi=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,yr=e=>{if(document.visibilityState==="hidden"){if(e.type==="visibilitychange")for(const t of Ai)t();isFinite(at)||(at=e.type==="visibilitychange"?e.timeStamp:0,removeEventListener("prerenderingchange",yr,!0))}},jt=(e=!1)=>{var t;if(e&&(at=1/0),at<0){const r=zt(),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:bi(),addEventListener("visibilitychange",yr,!0),addEventListener("prerenderingchange",yr,!0),ft(()=>{setTimeout(()=>{at=bi()})})}return{get firstHiddenTime(){return at},onHidden(r){Ai.add(r)}}},N=(e,t=-1,r,n=0,s,i,o)=>{const a=Cr(),u=(a==null?void 0:a.navigationId)||0;let l="navigate";return r?l=r:pt()>=0?l="back-forward-cache":a&&(document.prerendering||zt()>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}},wi=new WeakMap;function fe(e,t){let r=wi.get(t);return r||(r=new WeakMap,wi.set(t,r)),r.get(e)||r.set(e,new t),r.get(e)}class kd{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){}},qt=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},Ri=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const r=e.keys().next().value;r!==void 0&&e.delete(r)}},Oi=e=>{let t=!1;return()=>{t||(e(),t=!0)}};class Bd{constructor(){c(this,"l")}}const me=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},Pr=[1800,3e3],Ci=(e,t={})=>{const r=qt(t);me(()=>{const n=fe(t,Bd),s=jt();let i,o=N("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-zt(),0),o.entries.push(l),o.navigationId=l.navigationId||o.navigationId,i(!0)))});a&&(i=I(e,o,Pr,t.reportAllChanges),ft(u=>{o=N("FCP",-1,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,pt()),i=I(e,o,Pr,t.reportAllChanges),Or(()=>{o.value=performance.now()-u.timeStamp,i(!0)})})),r&&ct(["soft-navigation"],u=>{u.forEach(l=>{n.l&&l.navigationId&&Ri(n.l,l);const h=Math.max((l.presentationTime||l.paintTime||0)-l.startTime,0);o=N("FCP",h,"soft-navigation",l.navigationId,l.interactionId,l.name,l.startTime),i=I(e,o,Pr,t.reportAllChanges),i(!0)})},t)})},yi=[.1,.25],Gd=(e,t={})=>{const r=jt();Ci(Oi(()=>{let n,s=N("CLS",0);const i=fe(t,kd),o=(p,_,E,m,T)=>{s=N("CLS",0,p,_,E,m,T),i.i=0,n=I(e,s,yi,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"];qt(t)&&h.push("soft-navigation");const d=ct(h,l);d&&(n=I(e,s,yi,t.reportAllChanges),r.onHidden(()=>{l(d.takeRecords()),n(!0)}),ft(()=>{o("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,pt()),Or(n)}),setTimeout(n))}))};let Pi=0,Mr=1/0,ge=0;const Fd=e=>{for(const t of e)t.interactionId&&(Mr=Math.min(Mr,t.interactionId),ge=Math.max(ge,t.interactionId),Pi=ge?(ge-Mr)/7+1:0)};let vr;const Mi=()=>{var e;return vr?Pi:(e=performance.interactionCount)!=null?e:0},$d=()=>{"interactionCount"in performance||vr||(vr=ct(["event"],Fd,{durationThreshold:0}))};let vi=0;class Vd{constructor(){c(this,"u",[]);c(this,"v",new Map);c(this,"m");c(this,"p")}T(){vi=Mi(),this.u.length=0,this.v.clear()}M(t){const r=Mi()-vi,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 Ii=e=>{const t="requestIdleCallback"in globalThis?1e3:0,r=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if(document.visibilityState==="hidden")e();else{const s=Oi(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})}},Li=[200,500],Hd=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const r=jt();me(()=>{var p;$d();let n,s=N("INP");const i=fe(t,Vd),o=(_,E,m,T,A)=>{i.T(),s=N("INP",-1,_,E,m,T,A),n=I(e,s,Li,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)=>{Ii(()=>{for(const m of _)m.entryType!=="soft-navigation"?i.h(m):u(m);a(),E&&n(!0)})},h=["event","first-input"];qt(t)&&h.push("soft-navigation");const d=ct(h,l,{...t,durationThreshold:(p=t.durationThreshold)!=null?p:40});n=I(e,s,Li,t.reportAllChanges),d&&(r.onHidden(()=>{l(d.takeRecords(),!0)}),ft(()=>{o("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,pt())}))})};class zd{constructor(){c(this,"m");c(this,"l")}h(t){var r;(r=this.m)==null||r.call(this,t)}}const Ir=[2500,4e3],jd=(e,t={})=>{let r=!1;const n=qt(t);me(()=>{let s,i=jt(),o=N("LCP");const a=fe(t,zd),u=(_,E,m,T,A)=>{o=N("LCP",-1,_,E,m,T,A),s=I(e,o,Ir,t.reportAllChanges),r=!1,_==="soft-navigation"&&(i=jt(!0))},l=_=>{var m;a.l&&_.navigationId&&Ri(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-zt(),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,Ir,t.reportAllChanges);const _=["keydown","click","visibilitychange"],E=m=>{if(m.isTrusted&&!r){const T=o.id;Ii(()=>{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,Ir,t.reportAllChanges),Or(()=>{o.value=performance.now()-m.timeStamp,r=!0,s(!0)})})}})},Lr=[800,1800],Nr=e=>{document.prerendering?me(()=>Nr(e)):document.readyState!=="complete"?addEventListener("load",()=>Nr(e),!0):setTimeout(e)},qd=(e,t={})=>{const r=qt(t);let n=N("TTFB"),s=I(e,n,Lr,t.reportAllChanges);Nr(()=>{const i=Cr();if(i){const o=i.responseStart;n.value=Math.max(o-zt(),0),n.entries=[i],s(!0),ft(()=>{n=N("TTFB",0,"back-forward-cache",n.navigationId,n.navigationInteractionId,n.navigationURL,pt()),s=I(e,n,Lr,t.reportAllChanges),s(!0)}),r&&ct(["soft-navigation"],a=>{a.forEach(u=>{u.navigationId&&(n=N("TTFB",0,"soft-navigation",u.navigationId,u.interactionId,u.name,u.startTime),n.entries=[u],s=I(e,n,Lr,t.reportAllChanges),s(!0))})},t)}})},Wd=3e4,Xd=[{register:jd,name:"web_vitals.lcp",unit:"ms",boundaries:[100,250,500,1e3,1500,2e3,2500,3e3,4e3,6e3,8e3,12e3]},{register:Hd,name:"web_vitals.inp",unit:"ms",boundaries:[8,16,40,75,100,150,200,300,500,750,1e3]},{register:Gd,name:"web_vitals.cls",unit:"1",boundaries:[.01,.025,.05,.075,.1,.15,.25,.5,1]},{register:Ci,name:"web_vitals.fcp",unit:"ms",boundaries:[100,250,500,900,1200,1500,1800,2200,3e3,4e3,6e3]},{register:qd,name:"web_vitals.ttfb",unit:"ms",boundaries:[50,100,200,400,600,800,1200,1800,2500,4e3]}],Ni=()=>{var e;return`/${(e=window.location.pathname.split("/")[1])!=null?e:""}`},xi={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]}},Ui=new Map,Di=e=>{var t;(t=Ui.get(e))==null||t.record(performance.now(),{"page.route":Ni()})},Yd=e=>{Xd.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":Ni()})})})},Kd=()=>{const{GPv2UIOtelEndpoint:e,OtelTracesSamplerRatio:t}=P();if(typeof e!="string"||e.trim()==="")return;const r=e.trim().replace(/\/+$/,""),n=crypto.randomUUID(),s=os({[$n]:Ce,"deployment.environment":window.location.hostname,[Ga]:n}),i=new lu({resource:s,sampler:new ht({root:new sr(t!=null?t:1)}),spanProcessors:[new ou(new qh({url:`${r}/v1/traces`}))]});i.register();const o=new Ll({resource:s,readers:[new qu({exporter:new Jh({url:`${r}/v1/metrics`}),exportIntervalMillis:Wd})]});Be.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];ed({tracerProvider:i,meterProvider:o,instrumentations:[new ud,new wd({ignoreUrls:u}),new Dd({ignoreUrls:u})]});const l=o.getMeter("app-shell");Yd(l),Object.keys(xi).forEach(h=>{const{name:d,description:p,boundaries:_}=xi[h];Ui.set(h,l.createHistogram(d,{unit:"ms",description:p,advice:{explicitBucketBoundaries:_}}))}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&(i.forceFlush().catch(()=>{}),o.forceFlush().catch(()=>{}))}),window[Me.otel]=Object.freeze({tracerProvider:i,meterProvider:o,serviceInstanceId:n})},ki=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 Qd(){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 xr=new Xi(Qd()),Jd=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)},Zd=()=>{localStorage.removeItem(Xt)},W=()=>{const e=localStorage.getItem(Xt);return e?JSON.parse(e):null},Bi=()=>{var e;const t=localStorage.getItem(tn);return t?(e=JSON.parse(t))==null?void 0:e.email:null},t_=async()=>{const e=W();if(!e)return null;const t=(e.profile.given_name||"")+(e.profile.family_name||"")+e.profile.sub;return await ki(t)},Gi=()=>{const e=W();return e?e.id_token:null},Fi=(e,t)=>{const r={...t,...e},n=Jd(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),Yr.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(Xt,JSON.stringify(r)),r},e_=e=>{Fi(e,null)},$i=()=>{const e=W();return e?e.access_token:null},r_=()=>{const e=W();return e&&e.is_federated!==null&&e.is_federated!==void 0?String(e.is_federated).toLowerCase()==="true":!1},n_=()=>{const e=W();return e!=null&&e.expires_at?e.expires_at>Date.now()/1e3:!1},s_=()=>{var e;const t=W();return((e=t==null?void 0:t.profile)==null?void 0:e.previous_login_date)||null},i_=["authenticate","auth-callback","logout"],o_=e=>e.expires_at&&new Date(e.expires_at*1e3),a_=e=>e.expires_at&&new Date(e.expires_at*1e3+P().TokenValidForOfflineUsePostExpiryInHours*60*60*1e3),Vi=()=>{if(!P().IsLoginEnabled)return!1;const e=W();if(!Gi())return!0;if(!e.expires_at)return!1;const t=new Date;return navigator.onLine?t>o_(e):t>a_(e)},c_=()=>{const e=window.location.pathname.split("/");return i_.includes(e[e.length-1])},u_=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="authenticate"?(P().IsLoginEnabled?xr.signinRedirect():window.location.href="/",!0):!1},l_=()=>{let e="/";const t=localStorage.getItem(ye);t&&(localStorage.removeItem(ye),e=t),sessionStorage.setItem(pn.SessionStorage.ShowLastLoginPopup,"true"),window.location.href=e},h_=e=>{if(!e.id_token)throw new Error("Missing property:id_token");return e},Ur=e=>{const t=c_();(!t||e)&&(t||localStorage.setItem(ye,window.location.href),window.location.href="/authenticate")},d_=async e=>{const t=`${e.profile.sub}-${e.profile.customer_id}`,r=await ki(t);return{...e,profile:{...e.profile,hashed_identifier:r}}},__=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="auth-callback"?(xr.signinRedirectCallback().then(h_).then(d_).then(e_).then(l_).catch(Ur),!0):!1};class p_ extends Wr{render(){return lt` <ix-splash-screen></ix-splash-screen> `}}window.customElements.define("splash-screen",p_);class f_{constructor(){this.permissions=[],this.loading=!1,this.getPermissions=async()=>{var t;const r=(t=Yr)==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():[]},Yi(this,{permissions:Qi,setPermissions:Ki})}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(nn,Yt)||this.hasPermission(dn,Yt)}hasConnectivityCreate(){return this.hasPermission(Pe,Yt)}hasPrivilegeLevel(t,r){const n=[uo,Yt,ao,co],s=n.findIndex(o=>o===t),i=n.findIndex(o=>o===r);return s>=i}hasPermission(t,r){return Ji(this.permissions).some(n=>n.permission_name===t&&this.hasPrivilegeLevel(r,n.privilege))}}const Dr=new f_,Hi=()=>{const e=new Headers;return e.append("Authorization",`Bearer ${$i()}`),e},m_=async()=>{const{ApiBaseUrl:e}=P(),t=`${e}/inventory/locations?embed=permissions&page_size=1000`;let r=[],n=1;for(;;){const i=await fetch(`${t}&cursor=${n}`,{headers:Hi()});if(!i.ok)return Promise.reject();const o=await i.json();if(r.push(...o.items),o.self===o.last)break;n++}r=r.filter(i=>i.permissions.some(o=>_n.includes(o.name)));const s=new Map;for(const i of r)s.has(i.account_number)?s.get(i.account_number).push(i.site_id):s.set(i.account_number,[i.site_id]);return s},g_=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 fetch(`${t}/site-navigations/site-configurations?${r}`,{headers:Hi()});return i.ok?await i.json():Promise.reject()},E_=async()=>{try{const e=await m_();return e.size===0?!1:(await g_(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}},T_="SUPERUSER";class kr extends Wr{_isSuperUser(t){return t.some(r=>{var n;return(n=r.provenance)==null?void 0:n.includes(T_)})}constructor(){super(),this._currentView="splash",this.appLoaded=!1,this._onPopState=()=>{P().IsLoginEnabled&&Vi()&&Ur()};try{No()}catch(r){console.error("Telemetry initialization failed:",r)}try{Kd()}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(u_()||__()){this._currentView="splash";return}if(Vi()){this._currentView="splash",Di("login_redirect"),Ur();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-DHu3NPe-.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=W())==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=Bi(),s=structuredClone(window.gpConfig);if(!n||!s)return;const i=this._isSuperUser(t),o=!!((r=s["app-shell"])!=null&&r.IsInventoryManagementEnabled),a=await E_()&&(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()),Dr.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),Dr.setPermissions(o),await import("./app-CQxvnc62.js"),this.appLoaded=!0,Di("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>`}}}qr([Xr({type:String})],kr.prototype,"_currentView",void 0),qr([Xr({type:Boolean})],kr.prototype,"appLoaded",void 0),window.customElements.define("gp-bootstrap",kr);export{Oo as A,tn as B,lo as C,oo as D,bo as E,io as F,Kr as G,Ro as I,Jr as M,_n as O,Mo as R,wo as S,dn as U,Gi as a,t_ as b,Zd as c,Bi as d,$i as e,W as f,P as g,Fi as h,s_ as i,r_ as j,pn as k,mo as l,nn as m,po as n,fo as o,Dr as p,Zr as q,vo as r,Qr as s,Me as t,xr as u,Ce as v,no as w,n_ as x,so as y,Xt as z};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-realty/app-shell",
3
- "version": "15.0.1",
3
+ "version": "15.0.2",
4
4
  "license": "UNLICENSED",
5
5
  "contributors": [
6
6
  "DLR"