1
Fork 0
blog/bundle.js
2022-01-22 17:31:28 +01:00

9 lines
57 KiB
JavaScript

"use strict";(()=>{var u;(function(e){e.Debug="debug",e.Info="info",e.Warn="warn",e.Error="error",e.Trace="trace"})(u||(u={}));function l(e,t,r=u.Debug){let n=`(Glean.${e})`;Array.isArray(t)?console[r](n,...t):console[r](n,t)}var Ze=1e4,Ye;(function(e){e[e.RecoverableFailure=0]="RecoverableFailure",e[e.UnrecoverableFailure=1]="UnrecoverableFailure",e[e.Success=2]="Success"})(Ye||(Ye={}));var ot=class{constructor(t,r){this.result=t,this.status=r}},Qe=class{},qt=Qe;var me="platform.browser.Uploader",tr=class extends qt{async post(t,r,n={}){let i=new AbortController,s=setTimeout(()=>i.abort(),Ze),c;try{c=await fetch(t.toString(),{headers:n,method:"POST",body:r,keepalive:!0,credentials:"omit",signal:i.signal,redirect:"error"})}catch(o){return o instanceof DOMException?l(me,[`Timeout while attempting to upload ping.
`,o],u.Error):o instanceof TypeError?l(me,[`Network error while attempting to upload ping.
`,o],u.Error):l(me,[`Unknown error while attempting to upload ping.
`,o],u.Error),clearTimeout(s),new ot(0)}return clearTimeout(s),new ot(2,c.status)}},er=new tr;var Tn={os(){let e=navigator.userAgent;return e.includes("Windows")?Promise.resolve("Windows"):/tvOS/i.test(e)?Promise.resolve("TvOS"):/Watch( OS)?/i.test(e)?Promise.resolve("WatchOS"):/iPhone|iPad|iOS/i.test(e)?Promise.resolve("iOS"):/Mac OS X|macOS/i.test(e)?Promise.resolve("Darwin"):/Android/i.test(e)?Promise.resolve("Android"):/CrOS/i.test(e)?Promise.resolve("ChromeOS"):/WebOS/i.test(e)?Promise.resolve("WebOS"):/Linux/i.test(e)?Promise.resolve("Linux"):/OpenBSD/i.test(e)?Promise.resolve("OpenBSD"):/FreeBSD/i.test(e)?Promise.resolve("FreeBSD"):/NetBSD/i.test(e)?Promise.resolve("NetBSD"):/SunOS/i.test(e)?Promise.resolve("SunOS"):/AIX/i.test(e)?Promise.resolve("IBM_AIX"):Promise.resolve("Unknown")},async osVersion(){return Promise.resolve("Unknown")},async arch(){return Promise.resolve("Unknown")},async locale(){return Promise.resolve(navigator.language||"und")}},rr=Tn;var Wt,En=new Uint8Array(16);function ge(){if(!Wt&&(Wt=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Wt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Wt(En)}var nr=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function In(e){return typeof e=="string"&&nr.test(e)}var ir=In;var U=[];for(Xt=0;Xt<256;++Xt)U.push((Xt+256).toString(16).substr(1));var Xt;function Sn(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=(U[e[t+0]]+U[e[t+1]]+U[e[t+2]]+U[e[t+3]]+"-"+U[e[t+4]]+U[e[t+5]]+"-"+U[e[t+6]]+U[e[t+7]]+"-"+U[e[t+8]]+U[e[t+9]]+"-"+U[e[t+10]]+U[e[t+11]]+U[e[t+12]]+U[e[t+13]]+U[e[t+14]]+U[e[t+15]]).toLowerCase();if(!ir(r))throw TypeError("Stringified UUID is invalid");return r}var ar=Sn;function _n(e,t,r){e=e||{};var n=e.random||(e.rng||ge)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return ar(n)}var ve=_n;var Mn="core.Dispatcher",sr;(function(e){e.Uninitialized="Uninitialized",e.Idle="Idle",e.Processing="Processing",e.Stopped="Stopped",e.Shutdown="Shutdown"})(sr||(sr={}));var or;(function(e){e.Task="Task",e.PersistentTask="PersistentTask",e.InitTask="InitTask",e.Stop="Stop",e.Clear="Clear",e.Shutdown="Shutdown",e.TestTask="TestTask"})(or||(or={}));var cr=class{constructor(t=100,r=Mn){this.maxPreInitQueueSize=t,this.logTag=r,this.shuttingDown=!1,this.currentJob=Promise.resolve(),this.queue=[],this.state="Uninitialized"}getNextCommand(){return this.queue.shift()}async executeTask(t){try{return await t(),!0}catch(r){return l(this.logTag,`Error executing Glean task${r?`: ${r}`:". There might be more error logs above."}`,u.Error),!1}}unblockTestResolvers(){this.queue.forEach(t=>{t.command==="TestTask"&&t.resolver()})}async execute(){let t=this.getNextCommand();for(;t;){switch(t.command){case"Stop":this.state="Stopped";return;case"Shutdown":this.unblockTestResolvers(),this.queue=[],this.state="Shutdown",this.shuttingDown=!1;return;case"Clear":this.unblockTestResolvers(),this.queue=this.queue.filter(n=>["PersistentTask","Shutdown"].includes(n.command));break;case"TestTask":await this.executeTask(t.task),t.resolver();break;case"InitTask":await this.executeTask(t.task)||(l(this.logTag,["Error initializing dispatcher, won't execute anything further.","There might be more error logs above."],u.Error),this.clear(),this.shutdown());break;case"PersistentTask":case"Task":await this.executeTask(t.task);break}t=this.getNextCommand()}}triggerExecution(){this.state==="Idle"&&this.queue.length>0&&(this.state="Processing",this.currentJob=this.execute(),this.currentJob.then(()=>{let t=this;this.state==="Processing"&&(t.state="Idle")}).catch(t=>{l(this.logTag,["IMPOSSIBLE: Something went wrong while the dispatcher was executing the tasks queue.",t],u.Error)}))}launchInternal(t,r=!1){return this.state==="Shutdown"?(l(this.logTag,"Attempted to enqueue a new task but the dispatcher is shutdown. Ignoring.",u.Warn),!1):!r&&this.state==="Uninitialized"&&this.queue.length>=this.maxPreInitQueueSize?(l(this.logTag,"Unable to enqueue task, pre init queue is full.",u.Warn),!1):(r?this.queue.unshift(t):this.queue.push(t),this.triggerExecution(),!0)}launch(t){this.launchInternal({task:t,command:"Task"})}launchPersistent(t){this.launchInternal({task:t,command:"PersistentTask"})}flushInit(t){if(this.state!=="Uninitialized"){l(this.logTag,"Attempted to initialize the Dispatcher, but it is already initialized. Ignoring.",u.Warn);return}t&&this.launchInternal({task:t,command:"InitTask"},!0),this.state="Idle",this.triggerExecution()}clear(t=!0){this.launchInternal({command:"Clear"},t),this.resume()}stop(t=!0){this.shuttingDown?this.clear(t):this.launchInternal({command:"Stop"},t)}resume(){this.state==="Stopped"&&(this.state="Idle",this.triggerExecution())}shutdown(){return this.shuttingDown=!0,this.launchInternal({command:"Shutdown"}),this.resume(),this.currentJob}async testBlockOnQueue(){return await this.currentJob}async testUninitialize(){this.state!=="Uninitialized"&&(this.clear(),await this.shutdown(),this.state="Uninitialized")}testLaunch(t){return new Promise((r,n)=>{this.resume(),this.launchInternal({resolver:r,task:t,command:"TestTask"})||n()})}},lr=cr;var ct="core.Context",a=class{constructor(){this._initialized=!1,this._testing=!1,this._startTime=new Date,this._dispatcher=new lr}static get instance(){return a._instance||(a._instance=new a),a._instance}static testUninitialize(){a._instance=void 0}static get dispatcher(){return a.instance._dispatcher}static get uploadEnabled(){return typeof a.instance._uploadEnabled=="undefined"&&l(ct,["Attempted to access Context.uploadEnabled before it was set. This may cause unexpected behaviour."],u.Trace),a.instance._uploadEnabled}static set uploadEnabled(t){a.instance._uploadEnabled=t}static get metricsDatabase(){return typeof a.instance._metricsDatabase=="undefined"&&l(ct,["Attempted to access Context.metricsDatabase before it was set. This may cause unexpected behaviour."],u.Trace),a.instance._metricsDatabase}static set metricsDatabase(t){a.instance._metricsDatabase=t}static get eventsDatabase(){return typeof a.instance._eventsDatabase=="undefined"&&l(ct,["Attempted to access Context.eventsDatabase before it was set. This may cause unexpected behaviour."],u.Trace),a.instance._eventsDatabase}static set eventsDatabase(t){a.instance._eventsDatabase=t}static get pingsDatabase(){return typeof a.instance._pingsDatabase=="undefined"&&l(ct,["Attempted to access Context.pingsDatabase before it was set. This may cause unexpected behaviour."],u.Trace),a.instance._pingsDatabase}static set pingsDatabase(t){a.instance._pingsDatabase=t}static get errorManager(){return typeof a.instance._errorManager=="undefined"&&l(ct,["Attempted to access Context.errorManager before it was set. This may cause unexpected behaviour."],u.Trace),a.instance._errorManager}static set errorManager(t){a.instance._errorManager=t}static get applicationId(){return typeof a.instance._applicationId=="undefined"&&l(ct,["Attempted to access Context.applicationId before it was set. This may cause unexpected behaviour."],u.Trace),a.instance._applicationId}static set applicationId(t){a.instance._applicationId=t}static get initialized(){return a.instance._initialized}static set initialized(t){a.instance._initialized=t}static get config(){return typeof a.instance._config=="undefined"&&l(ct,["Attempted to access Context.config before it was set. This may cause unexpected behaviour."],u.Trace),a.instance._config}static set config(t){a.instance._config=t}static get startTime(){return a.instance._startTime}static get testing(){return a.instance._testing}static set testing(t){a.instance._testing=t}static set platform(t){a.instance._platform=t}static get platform(){return typeof a.instance._platform=="undefined"&&l(ct,["Attempted to access Context.platform before it was set. This may cause unexpected behaviour."],u.Trace),a.instance._platform}static isPlatformSet(){return!!a.instance._platform}};var M;(function(e){e.InvalidValue="invalid_value",e.InvalidLabel="invalid_label",e.InvalidState="invalid_state",e.InvalidOverflow="invalid_overflow"})(M||(M={}));var Dn="core.utils";function Q(e){if(E(e)||bt(e)||tt(e))return!0;if(S(e)){if(Object.keys(e).length===0)return!0;for(let t in e)return Q(e[t])}return Array.isArray(e)?e.every(t=>Q(t)):!1}function S(e){return typeof e=="object"&&e!==null&&e.constructor===Object}function P(e){return typeof e=="undefined"}function E(e){return typeof e=="string"}function bt(e){return typeof e=="boolean"}function tt(e){return typeof e=="number"&&!isNaN(e)}function Jt(e){return tt(e)&&Number.isInteger(e)}function ur(e){return e.replace(/[^a-z0-9]+/gi,"-").toLowerCase()}function fr(e){return/^(http|https):\/\/[a-zA-Z0-9._-]+(:\d+){0,1}(\/{0,1})$/i.test(e)}function we(e){return/^[a-z0-9-]{1,20}$/i.test(e)}function ht(){return typeof crypto!="undefined"?ve():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}var Pn=Date.now();function pt(){let e=typeof performance=="undefined"?Date.now()-Pn:performance.now();return Math.round(e)}async function xt(e,t,r){let n=t.substr(0,r);return n!==t&&await a.errorManager.record(e,M.InvalidOverflow,`Value length ${t.length} exceeds maximum of ${r}.`),n}function _(e,t=Dn){return a.testing?!0:(l(t,[`Attempted to access test only method \`${e||"unknown"}\`,`,"but Glean is not in testing mode. Ignoring. Make sure to put Glean in testing mode","before accessing such methods, by calling `Glean.testResetGlean`."],u.Error),!1)}var An="core.Storage.Utils";function Kt(e,t){if(t.length===0)throw Error("The index must contain at least one property to get.");let r=e;for(let n of t)if(S(r)&&n in r){let i=r[n];Q(i)&&(r=i)}else return;return r}function Ht(e,t,r){if(t.length===0)throw Error("The index must contain at least one property to update.");let n={...e},i=n;for(let o of t.slice(0,t.length-1))S(i[o])||(i[o]={}),i=i[o];let s=t[t.length-1],c=i[s];try{let o=r(c);return i[s]=o,n}catch(o){return l(An,["Error while transforming stored value. Ignoring old value.",o],u.Error),i[s]=r(void 0),n}}function Zt(e,t){if(t.length===0)return{};let r={...e},n=r;for(let s of t.slice(0,t.length-1)){let c=n[s];if(S(c))n=c;else throw Error(`Attempted to delete an entry from an inexistent index: ${JSON.stringify(t)}.`)}let i=t[t.length-1];return delete n[i],r}var ye="platform.web.Storage",Un="Glean",be="Main",Ut;(function(e){e.ReadOnly="readonly",e.ReadWrite="readwrite"})(Ut||(Ut={}));var Ot;(function(e){let t;function r(i){return t?i():new Promise((s,c)=>{let o=self.indexedDB.open(Un);o.onerror=()=>{l(ye,["Unable to open Glean database.",o.error]),c(o.error)},o.onsuccess=()=>{t=o.result,i().then(()=>s()).catch(p=>c(p))},o.onupgradeneeded=()=>{o.result.createObjectStore(be)}})}async function n(i,s,c){await r(async()=>{let o=t==null?void 0:t.transaction(be,c);if(!o)throw new Error("IMPOSSIBLE: Unable to perform database transaction. Database is not initialized.");let p=new Promise((m,b)=>{o.oncomplete=()=>m(),o.onerror=o.onabort=d=>b(d)}),h=o.objectStore(be),f=await new Promise((m,b)=>{let d=h.get(i);d.onsuccess=()=>m(d.result),d.onerror=()=>b(d.error)}),g;P(f)?g={}:Q(f)&&S(f)?g=f:(l(ye,["Unexpected data found in storage. Overwriting.",f],u.Warn),g={}),await s(g,h),await p})}e.withStoredValue=n})(Ot||(Ot={}));var hr=class{constructor(t){this.rootKey=t,this.logTag=`${ye}.${t}`}async get(t=[]){let r;return await Ot.withStoredValue(this.rootKey,n=>(t.length>0?r=Kt(n,t):r=Object.keys(n).length===0?void 0:n,Promise.resolve()),Ut.ReadOnly),r}async update(t,r){await Ot.withStoredValue(this.rootKey,async(n,i)=>{await new Promise((s,c)=>{let o=Ht(n,t,r),p=i.put(o,this.rootKey);p.onsuccess=s,p.onerror=()=>c(p.error)})},Ut.ReadWrite)}async delete(t){await Ot.withStoredValue(this.rootKey,async(r,n)=>{t.length===0?n.delete(this.rootKey):await new Promise((i,s)=>{try{let c=Zt(r,t),o=n.put(c,this.rootKey);o.onsuccess=()=>i(),o.onerror=()=>s(o.error)}catch(c){l(this.logTag,[`Error attempting to delete key ${t.toString()} from storage. Ignoring.`,c],u.Warn),i()}})},Ut.ReadWrite)}},pr=hr;var On={Storage:pr,uploader:er,info:rr,timer:{setTimeout,clearTimeout},name:"web"},dr=On;var mr=1,Lt="0.30.0",Rt="glean_ping_info",lt="glean_client_info",Gt="c0ffeec0-ffee-c0ff-eec0-ffeec0ffeec0",gr="https://incoming.telemetry.mozilla.org",Tt="deletion-request",xe=5,Et="#glean_reference_time",It="#glean_execution_counter",vr=[It,Et];var Te="core.Config",Ee=class{constructor(t){var r;if(this.channel=t==null?void 0:t.channel,this.appBuild=t==null?void 0:t.appBuild,this.appDisplayVersion=t==null?void 0:t.appDisplayVersion,this.architecture=t==null?void 0:t.architecture,this.osVersion=t==null?void 0:t.osVersion,this.debug={},(t==null?void 0:t.serverEndpoint)&&!fr(t.serverEndpoint))throw new Error(`Unable to initialize Glean, serverEndpoint ${t.serverEndpoint} is an invalid URL.`);this.serverEndpoint=t&&t.serverEndpoint?t.serverEndpoint:gr,this.httpClient=t==null?void 0:t.httpClient}get logPings(){return this.debug.logPings||!1}set logPings(t){this.debug.logPings=t}get debugViewTag(){return this.debug.debugViewTag}set debugViewTag(t){if(!we(t||"")){l(Te,[`"${t||""}" is not a valid \`debugViewTag\` value.`,"Please make sure the value passed satisfies the regex `^[a-zA-Z0-9-]{1,20}$`."],u.Error);return}this.debug.debugViewTag=t}get sourceTags(){return this.debug.sourceTags}set sourceTags(t){if(!t||t.length<1||t.length>xe){l(Te,`A list of tags cannot contain more than ${xe} elements or less than one.`,u.Error);return}for(let r of t){if(r.startsWith("glean")){l(Te,"Tags starting with `glean` are reserved and must not be used.",u.Error);return}if(!we(r))return}this.debug.sourceTags=t}};var Ln="core.Metrics.Metric",T=class{constructor(t){if(!this.validate(t))throw new Error("Unable to create new Metric instance, value is in unexpected format.");this._inner=t}get(){return this._inner}set(t){if(!this.validate(t)){l(Ln,`Unable to set metric to ${JSON.stringify(t)}. Value is in unexpected format. Ignoring.`,u.Error);return}this._inner=t}};var Nt=class extends T{constructor(t){super(t)}validate(t){return!0}payload(){return this._inner}},Rn=16,wr=61,Gn="__other__",Nn=/^[a-z_][a-z0-9_-]{0,29}(\.[a-z_][a-z0-9_-]{0,29})*$/;function Yt(e,t){return`${e}/${t}`}function yr(e){return e.split("/")[0]}async function br(e){if(e.dynamicLabel===void 0)throw new Error("This point should never be reached.");let t=Yt(e.baseIdentifier(),e.dynamicLabel);for(let i of e.sendInPings)if(await a.metricsDatabase.hasMetric(e.lifetime,i,e.type,t))return t;let r=0;for(let i of e.sendInPings)r+=await a.metricsDatabase.countByBaseIdentifier(e.lifetime,i,e.type,e.baseIdentifier());let n=!1;return r>=Rn?n=!0:e.dynamicLabel.length>wr?(n=!0,await a.errorManager.record(e,M.InvalidLabel,`Label length ${e.dynamicLabel.length} exceeds maximum of ${wr}.`)):Nn.test(e.dynamicLabel)||(n=!0,await a.errorManager.record(e,M.InvalidLabel,`Label must be snake_case, got '${e.dynamicLabel}'.`)),n?Yt(e.baseIdentifier(),Gn):t}var W=class{constructor(t,r){this.type=t,this.name=r.name,this.category=r.category,this.sendInPings=r.sendInPings,this.lifetime=r.lifetime,this.disabled=r.disabled,this.dynamicLabel=r.dynamicLabel}baseIdentifier(){return this.category.length>0?`${this.category}.${this.name}`:this.name}async identifier(){let t=this.baseIdentifier();return P(this.dynamicLabel)?t:await br(this)}shouldRecord(t){return t&&!this.disabled}async testGetNumRecordedErrors(t,r=this.sendInPings[0]){return _("testGetNumRecordedErrors")?a.errorManager.testGetNumRecordedErrors(this,t,r):0}};var Ie=class extends T{constructor(t){super(t)}validate(t){return bt(t)}payload(){return this._inner}};var zn="core.metrics.CounterMetricType",dt=class extends T{constructor(t){super(t)}validate(t){return!(!Jt(t)||t<=0)}payload(){return this._inner}},Qt=class extends W{constructor(t){super("counter",t)}static async _private_addUndispatched(t,r){if(!t.shouldRecord(a.uploadEnabled))return;if(P(r)&&(r=1),r<=0){await a.errorManager.record(t,M.InvalidValue,`Added negative and zero value ${r}`);return}let n=(i=>s=>{let c,o;try{c=new dt(s),o=c.get()+i}catch{c=new dt(i),o=i}return o>Number.MAX_SAFE_INTEGER&&(o=Number.MAX_SAFE_INTEGER),c.set(o),c})(r);await a.metricsDatabase.transform(t,n)}add(t){a.dispatcher.launch(async()=>Qt._private_addUndispatched(this,t))}async testGetValue(t=this.sendInPings[0]){if(_("testGetValue",zn)){let r;return await a.dispatcher.testLaunch(async()=>{r=await a.metricsDatabase.getMetric(t,this)}),r}}},Z=Qt;var Se;(function(e){e.Nanosecond="nanosecond",e.Microsecond="microsecond",e.Millisecond="millisecond",e.Second="second",e.Minute="minute",e.Hour="hour",e.Day="day"})(Se||(Se={}));var x=Se;var $n="core.metrics.DatetimeMetricType";function Cn(e){let t=e/60*-1,r=t>0?"+":"-",n=Math.abs(t).toString().padStart(2,"0");return`${r}${n}:00`}var $=class extends T{constructor(t){super(t)}static fromDate(t,r){return new $({timeUnit:r,timezone:t.getTimezoneOffset(),date:t.toISOString()})}get date(){return new Date(this._inner.date)}get timezone(){return this._inner.timezone}get timeUnit(){return this._inner.timeUnit}get dateISOString(){return this._inner.date}validate(t){if(!S(t)||Object.keys(t).length!==3)return!1;let r="timeUnit"in t&&E(t.timeUnit)&&Object.values(x).includes(t.timeUnit),n="timezone"in t&&tt(t.timezone),i="date"in t&&E(t.date)&&t.date.length===24&&!isNaN(Date.parse(t.date));return!(!r||!n||!i)}payload(){let t=this.dateISOString.match(/\d+/g);if(!t||t.length<0)throw new Error("IMPOSSIBLE: Unable to extract date information from DatetimeMetric.");let r=new Date(parseInt(t[0]),parseInt(t[1])-1,parseInt(t[2]),parseInt(t[3])-this.timezone/60,parseInt(t[4]),parseInt(t[5]),parseInt(t[6])),n=Cn(this.timezone),i=r.getFullYear().toString().padStart(2,"0"),s=(r.getMonth()+1).toString().padStart(2,"0"),c=r.getDate().toString().padStart(2,"0");if(this.timeUnit===x.Day)return`${i}-${s}-${c}${n}`;let o=r.getHours().toString().padStart(2,"0");if(this.timeUnit===x.Hour)return`${i}-${s}-${c}T${o}${n}`;let p=r.getMinutes().toString().padStart(2,"0");if(this.timeUnit===x.Minute)return`${i}-${s}-${c}T${o}:${p}${n}`;let h=r.getSeconds().toString().padStart(2,"0");if(this.timeUnit===x.Second)return`${i}-${s}-${c}T${o}:${p}:${h}${n}`;let f=r.getMilliseconds().toString().padStart(3,"0");return this.timeUnit===x.Millisecond?`${i}-${s}-${c}T${o}:${p}:${h}.${f}${n}`:this.timeUnit===x.Microsecond?`${i}-${s}-${c}T${o}:${p}:${h}.${f}000${n}`:`${i}-${s}-${c}T${o}:${p}:${h}.${f}000000${n}`}},te=class extends W{constructor(t,r){super("datetime",t);this.timeUnit=r}static async _private_setUndispatched(t,r){if(!t.shouldRecord(a.uploadEnabled))return;r||(r=new Date);let n=r;switch(t.timeUnit){case x.Day:n.setMilliseconds(0),n.setSeconds(0),n.setMinutes(0),n.setMilliseconds(0);case x.Hour:n.setMilliseconds(0),n.setSeconds(0),n.setMinutes(0);case x.Minute:n.setMilliseconds(0),n.setSeconds(0);case x.Second:n.setMilliseconds(0);default:break}let i=$.fromDate(r,t.timeUnit);await a.metricsDatabase.record(t,i)}set(t){a.dispatcher.launch(()=>te._private_setUndispatched(this,t))}async testGetValueAsDatetimeMetric(t,r){if(_(r,$n)){let n;if(await a.dispatcher.testLaunch(async()=>{n=await a.metricsDatabase.getMetric(t,this)}),n)return new $(n)}}async testGetValueAsString(t=this.sendInPings[0]){let r=await this.testGetValueAsDatetimeMetric(t,"testGetValueAsString");return r?r.payload():void 0}async testGetValue(t=this.sendInPings[0]){let r=await this.testGetValueAsDatetimeMetric(t,"testGetValue");return r?r.date:void 0}},Y=te;var _e=class extends T{constructor(t){super(t)}validate(t){return!(!Jt(t)||t<0)}payload(){return this._inner}};var Me=class extends T{constructor(t){super(t)}get numerator(){return this._inner.numerator}get denominator(){return this._inner.denominator}validate(t){if(!S(t)||Object.keys(t).length!==2)return!1;let r="numerator"in t&&tt(t.numerator)&&t.numerator>=0,n="denominator"in t&&tt(t.denominator)&&t.denominator>=0;return r&&n}payload(){return{numerator:this._inner.numerator,denominator:this._inner.denominator}}};var kn="core.metrics.StringMetricType",xr=100,ee=class extends T{constructor(t){super(t)}validate(t){return!(!E(t)||t.length>xr)}payload(){return this._inner}},re=class extends W{constructor(t){super("string",t)}static async _private_setUndispatched(t,r){if(!t.shouldRecord(a.uploadEnabled))return;let n=await xt(t,r,xr),i=new ee(n);await a.metricsDatabase.record(t,i)}set(t){a.dispatcher.launch(()=>re._private_setUndispatched(this,t))}async testGetValue(t=this.sendInPings[0]){if(_("testGetValue",kn)){let r;return await a.dispatcher.testLaunch(async()=>{r=await a.metricsDatabase.getMetric(t,this)}),r}}},O=re;var Vn=20,Fn=50,De=class extends T{constructor(t){super(t)}validate(t){if(!Array.isArray(t)||t.length>Vn)return!1;for(let r of t)if(!E(r)||r.length>Fn)return!1;return!0}payload(){return this._inner}};var Bn=200*1024,Pe=class extends T{constructor(t){super(t)}validate(t){return!(!E(t)||t.length>Bn)}payload(){return this._inner}};var Ae=class extends T{constructor(t){super(t)}get timespan(){switch(this._inner.timeUnit){case x.Nanosecond:return this._inner.timespan*10**6;case x.Microsecond:return this._inner.timespan*10**3;case x.Millisecond:return this._inner.timespan;case x.Second:return Math.round(this._inner.timespan/1e3);case x.Minute:return Math.round(this._inner.timespan/1e3/60);case x.Hour:return Math.round(this._inner.timespan/1e3/60/60);case x.Day:return Math.round(this._inner.timespan/1e3/60/60/24)}}validate(t){if(!S(t)||Object.keys(t).length!==2)return!1;let r="timeUnit"in t&&E(t.timeUnit)&&Object.values(x).includes(t.timeUnit),n="timespan"in t&&tt(t.timespan)&&t.timespan>=0;return!(!r||!n)}payload(){return{time_unit:this._inner.timeUnit,value:this.timespan}}};var Tr=2048,jn=/^[a-zA-Z][a-zA-Z0-9-\+\.]*:(.*)$/,ne=class extends Error{constructor(t,r){super(r);this.type=t,this.name="UrlMetricError"}},Ue=class extends T{constructor(t){super(t)}validate(t){if(!E(t))return!1;if(t.length>Tr)throw new ne(M.InvalidOverflow,`URL length ${t.length} exceeds maximum of ${Tr}.`);if(t.startsWith("data:"))throw new ne(M.InvalidValue,"URL metric does not support data URLs.");if(!jn.test(t))throw new ne(M.InvalidValue,`"${t}" does not start with a valid URL scheme.`);return!0}payload(){return this._inner}};var qn="core.metrics.UUIDMetricType",Wn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,ie=class extends T{constructor(t){super(t)}validate(t){return E(t)?Wn.test(t):!1}payload(){return this._inner}},ae=class extends W{constructor(t){super("uuid",t)}static async _private_setUndispatched(t,r){if(!t.shouldRecord(a.uploadEnabled))return;r||(r=ht());let n;try{n=new ie(r)}catch{await a.errorManager.record(t,M.InvalidValue,`"${r}" is not a valid UUID.`);return}await a.metricsDatabase.record(t,n)}set(t){a.dispatcher.launch(()=>ae._private_setUndispatched(this,t))}generateAndSet(){if(!this.shouldRecord(a.uploadEnabled))return;let t=ht();return this.set(t),t}async testGetValue(t=this.sendInPings[0]){if(_("testGetValue",qn)){let r;return await a.dispatcher.testLaunch(async()=>{r=await a.metricsDatabase.getMetric(t,this)}),r}}},zt=ae;var Er=Object.freeze({boolean:Ie,counter:dt,datetime:$,labeled_boolean:Nt,labeled_counter:Nt,labeled_string:Nt,quantity:_e,rate:Me,string:ee,string_list:De,text:Pe,timespan:Ae,url:Ue,uuid:ie});function $t(e,t){if(!(e in Er))throw new Error(`Unable to create metric of unknown type ${e}`);return new Er[e](t)}function Oe(e,t){try{return $t(e,t),!0}catch{return!1}}var Le="core.Metrics.Database",Ir="reserved#",Xn=`glean.${Ir}`;function Sr(e){return{category:"glean",name:`${Ir}${e}`}}function Jn(e){if(S(e)){for(let t in e){let r=e[t];if(S(r)){for(let n in r)if(!Oe(t,r[n]))return l(Le,`Invalid metric representation found for metric "${n}"`,u.Debug),!1}else return!1}return!0}else return!1}function Kn(e){let t={};for(let r in e){let n=e[r];t[r]={};for(let i in n){let s=$t(r,n[i]);t[r][i]=s.payload()}}return t}var _r=class{constructor(){this.userStore=new a.platform.Storage("userLifetimeMetrics"),this.pingStore=new a.platform.Storage("pingLifetimeMetrics"),this.appStore=new a.platform.Storage("appLifetimeMetrics")}_chooseStore(t){switch(t){case"user":return this.userStore;case"ping":return this.pingStore;case"application":return this.appStore}}async record(t,r){await this.transform(t,()=>r)}async transform(t,r){if(t.disabled)return;let n=this._chooseStore(t.lifetime),i=await t.identifier();for(let s of t.sendInPings){let c=o=>r(o).get();await n.update([s,t.type,i],c)}}async hasMetric(t,r,n,i){let c=await this._chooseStore(t).get([r,n,i]);return!P(c)}async countByBaseIdentifier(t,r,n,i){let c=await this._chooseStore(t).get([r,n]);return P(c)?0:Object.keys(c).filter(o=>o.startsWith(i)).length}async getMetric(t,r){let n=this._chooseStore(r.lifetime),i=await r.identifier(),s=await n.get([t,r.type,i]);if(!P(s)&&!Oe(r.type,s)){l(Le,`Unexpected value found for metric ${i}: ${JSON.stringify(s)}. Clearing.`,u.Error),await n.delete([t,r.type,i]);return}else return s}async getAndValidatePingData(t,r){let n=this._chooseStore(r),i=await n.get([t]);return P(i)?{}:Jn(i)?i:(l(Le,`Unexpected value found for ping "${t}" in "${r}" store: ${JSON.stringify(i)}. Clearing.`,u.Debug),await n.delete([t]),{})}processLabeledMetric(t,r,n,i){let s=`labeled_${r}`,c=n.split("/",2),o=c[0],p=c[1];if(s in t&&o in t[s]){let h=t[s][o];t[s][o]={...h,[p]:i}}else t[s]={...t[s],[o]:{[p]:i}}}async getPingMetrics(t,r){let n=await this.getAndValidatePingData(t,"user"),i=await this.getAndValidatePingData(t,"ping"),s=await this.getAndValidatePingData(t,"application");r&&Object.keys(i).length>0&&await this.clear("ping",t);let c={};for(let o of[n,i,s])for(let p in o)for(let h in o[p])h.startsWith(Xn)||(h.includes("/")?this.processLabeledMetric(c,p,h,o[p][h]):c[p]={...c[p],[h]:o[p][h]});if(Object.keys(c).length!==0)return Kn(c)}async clear(t,r){let n=this._chooseStore(t),i=r?[r]:[];await n.delete(i)}async clearAll(){await this.userStore.delete([]),await this.pingStore.delete([]),await this.appStore.delete([])}},Mr=_r;var C=Uint8Array,G=Uint16Array,se=Uint32Array,Re=new C([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ge=new C([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Dr=new C([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Pr=function(e,t){for(var r=new G(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];for(var i=new se(r[30]),n=1;n<30;++n)for(var s=r[n];s<r[n+1];++s)i[s]=s-r[n]<<5|n;return[r,i]},Ar=Pr(Re,2),Hn=Ar[0],Ne=Ar[1];Hn[28]=258,Ne[258]=28;var Ur=Pr(Ge,0),Js=Ur[0],Or=Ur[1],ze=new G(32768);for(w=0;w<32768;++w)et=(w&43690)>>>1|(w&21845)<<1,et=(et&52428)>>>2|(et&13107)<<2,et=(et&61680)>>>4|(et&3855)<<4,ze[w]=((et&65280)>>>8|(et&255)<<8)>>>1;var et,w,Ct=function(e,t,r){for(var n=e.length,i=0,s=new G(t);i<n;++i)e[i]&&++s[e[i]-1];var c=new G(t);for(i=0;i<t;++i)c[i]=c[i-1]+s[i-1]<<1;var o;if(r){o=new G(1<<t);var p=15-t;for(i=0;i<n;++i)if(e[i])for(var h=i<<4|e[i],f=t-e[i],g=c[e[i]-1]++<<f,m=g|(1<<f)-1;g<=m;++g)o[ze[g]>>>p]=h}else for(o=new G(n),i=0;i<n;++i)e[i]&&(o[i]=ze[c[e[i]-1]++]>>>15-e[i]);return o},mt=new C(288);for(w=0;w<144;++w)mt[w]=8;var w;for(w=144;w<256;++w)mt[w]=9;var w;for(w=256;w<280;++w)mt[w]=7;var w;for(w=280;w<288;++w)mt[w]=8;var w,oe=new C(32);for(w=0;w<32;++w)oe[w]=5;var w,Zn=Ct(mt,9,0);var Yn=Ct(oe,5,0);var Lr=function(e){return(e+7)/8|0},Rr=function(e,t,r){(t==null||t<0)&&(t=0),(r==null||r>e.length)&&(r=e.length);var n=new(e.BYTES_PER_ELEMENT==2?G:e.BYTES_PER_ELEMENT==4?se:C)(r-t);return n.set(e.subarray(t,r)),n};var rt=function(e,t,r){r<<=t&7;var n=t/8|0;e[n]|=r,e[n+1]|=r>>>8},kt=function(e,t,r){r<<=t&7;var n=t/8|0;e[n]|=r,e[n+1]|=r>>>8,e[n+2]|=r>>>16},$e=function(e,t){for(var r=[],n=0;n<e.length;++n)e[n]&&r.push({s:n,f:e[n]});var i=r.length,s=r.slice();if(!i)return[Ve,0];if(i==1){var c=new C(r[0].s+1);return c[r[0].s]=1,[c,1]}r.sort(function(X,V){return X.f-V.f}),r.push({s:-1,f:25001});var o=r[0],p=r[1],h=0,f=1,g=2;for(r[0]={s:-1,f:o.f+p.f,l:o,r:p};f!=i-1;)o=r[r[h].f<r[g].f?h++:g++],p=r[h!=f&&r[h].f<r[g].f?h++:g++],r[f++]={s:-1,f:o.f+p.f,l:o,r:p};for(var m=s[0].s,n=1;n<i;++n)s[n].s>m&&(m=s[n].s);var b=new G(m+1),d=Ce(r[f-1],b,0);if(d>t){var n=0,y=0,I=d-t,L=1<<I;for(s.sort(function(V,R){return b[R.s]-b[V.s]||V.f-R.f});n<i;++n){var D=s[n].s;if(b[D]>t)y+=L-(1<<d-b[D]),b[D]=t;else break}for(y>>>=I;y>0;){var vt=s[n].s;b[vt]<t?y-=1<<t-b[vt]++-1:++n}for(;n>=0&&y;--n){var at=s[n].s;b[at]==t&&(--b[at],++y)}d=t}return[new C(b),d]},Ce=function(e,t,r){return e.s==-1?Math.max(Ce(e.l,t,r+1),Ce(e.r,t,r+1)):t[e.s]=r},Gr=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new G(++t),n=0,i=e[0],s=1,c=function(p){r[n++]=p},o=1;o<=t;++o)if(e[o]==i&&o!=t)++s;else{if(!i&&s>2){for(;s>138;s-=138)c(32754);s>2&&(c(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(c(i),--s;s>6;s-=6)c(8304);s>2&&(c(s-3<<5|8208),s=0)}for(;s--;)c(i);s=1,i=e[o]}return[r.subarray(0,n),t]},Vt=function(e,t){for(var r=0,n=0;n<t.length;++n)r+=e[n]*t[n];return r},ke=function(e,t,r){var n=r.length,i=Lr(t+2);e[i]=n&255,e[i+1]=n>>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var s=0;s<n;++s)e[i+s+4]=r[s];return(i+4+n)*8},Nr=function(e,t,r,n,i,s,c,o,p,h,f){rt(t,f++,r),++i[256];for(var g=$e(i,15),m=g[0],b=g[1],d=$e(s,15),y=d[0],I=d[1],L=Gr(m),D=L[0],vt=L[1],at=Gr(y),X=at[0],V=at[1],R=new G(19),v=0;v<D.length;++v)R[D[v]&31]++;for(var v=0;v<X.length;++v)R[X[v]&31]++;for(var ft=$e(R,7),F=ft[0],jt=ft[1],N=19;N>4&&!F[Dr[N-1]];--N);var wt=h+5<<3,B=Vt(i,mt)+Vt(s,oe)+c,j=Vt(i,m)+Vt(s,y)+c+14+3*N+Vt(R,F)+(2*R[16]+3*R[17]+7*R[18]);if(wt<=B&&wt<=j)return ke(t,f,e.subarray(p,p+h));var J,A,q,st;if(rt(t,f,1+(j<B)),f+=2,j<B){J=Ct(m,b,0),A=m,q=Ct(y,I,0),st=y;var he=Ct(F,jt,0);rt(t,f,vt-257),rt(t,f+5,V-1),rt(t,f+10,N-4),f+=14;for(var v=0;v<N;++v)rt(t,f+3*v,F[Dr[v]]);f+=3*N;for(var K=[D,X],At=0;At<2;++At)for(var yt=K[At],v=0;v<yt.length;++v){var H=yt[v]&31;rt(t,f,he[H]),f+=F[H],H>15&&(rt(t,f,yt[v]>>>5&127),f+=yt[v]>>>12)}}else J=Zn,A=mt,q=Yn,st=oe;for(var v=0;v<o;++v)if(n[v]>255){var H=n[v]>>>18&31;kt(t,f,J[H+257]),f+=A[H+257],H>7&&(rt(t,f,n[v]>>>23&31),f+=Re[H]);var z=n[v]&31;kt(t,f,q[z]),f+=st[z],z>3&&(kt(t,f,n[v]>>>5&8191),f+=Ge[z])}else kt(t,f,J[n[v]]),f+=A[n[v]];return kt(t,f,J[256]),f+A[256]},Qn=new se([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ve=new C(0),ti=function(e,t,r,n,i,s){var c=e.length,o=new C(n+c+5*(1+Math.ceil(c/7e3))+i),p=o.subarray(n,o.length-i),h=0;if(!t||c<8)for(var f=0;f<=c;f+=65535){var g=f+65535;g>=c&&(p[h>>3]=s),h=ke(p,h+1,e.subarray(f,g))}else{for(var m=Qn[t-1],b=m>>>13,d=m&8191,y=(1<<r)-1,I=new G(32768),L=new G(y+1),D=Math.ceil(r/3),vt=2*D,at=function(de){return(e[de]^e[de+1]<<D^e[de+2]<<vt)&y},X=new se(25e3),V=new G(288),R=new G(32),v=0,ft=0,f=0,F=0,jt=0,N=0;f<c;++f){var wt=at(f),B=f&32767,j=L[wt];if(I[B]=j,L[wt]=B,jt<=f){var J=c-f;if((v>7e3||F>24576)&&J>423){h=Nr(e,p,0,X,V,R,ft,F,N,f-N,h),F=v=ft=0,N=f;for(var A=0;A<286;++A)V[A]=0;for(var A=0;A<30;++A)R[A]=0}var q=2,st=0,he=d,K=B-j&32767;if(J>2&&wt==at(f-K))for(var At=Math.min(b,J)-1,yt=Math.min(32767,f),H=Math.min(258,J);K<=yt&&--he&&B!=j;){if(e[f+q]==e[f+q-K]){for(var z=0;z<H&&e[f+z]==e[f+z-K];++z);if(z>q){if(q=z,st=K,z>At)break;for(var bn=Math.min(K,z-2),Xe=0,A=0;A<bn;++A){var pe=f-K+A+32768&32767,xn=I[pe],Je=pe-xn+32768&32767;Je>Xe&&(Xe=Je,j=pe)}}}B=j,j=I[B],K+=B-j+32768&32767}if(st){X[F++]=268435456|Ne[q]<<18|Or[st];var Ke=Ne[q]&31,He=Or[st]&31;ft+=Re[Ke]+Ge[He],++V[257+Ke],++R[He],jt=f+q,++v}else X[F++]=e[f],++V[e[f]]}}h=Nr(e,p,s,X,V,R,ft,F,N,f-N,h),!s&&h&7&&(h=ke(p,h+1,Ve))}return Rr(o,0,n+Lr(h)+i)},ei=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var r=t,n=9;--n;)r=(r&1&&-306674912)^r>>>1;e[t]=r}return e}(),ri=function(){var e=-1;return{p:function(t){for(var r=e,n=0;n<t.length;++n)r=ei[r&255^t[n]]^r>>>8;e=r},d:function(){return~e}}};var ni=function(e,t,r,n,i){return ti(e,t.level==null?6:t.level,t.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):12+t.mem,r,n,!i)};var Fe=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8},ii=function(e,t){var r=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&Fe(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),r){e[3]=8;for(var n=0;n<=r.length;++n)e[n+10]=r.charCodeAt(n)}};var ai=function(e){return 10+(e.filename&&e.filename.length+1||0)};function zr(e,t){t||(t={});var r=ri(),n=e.length;r.p(e);var i=ni(e,t,ai(t),8),s=i.length;return ii(i,t),Fe(i,s-8,r.d()),Fe(i,s-4,n),i}var $r=typeof TextEncoder!="undefined"&&new TextEncoder,si=typeof TextDecoder!="undefined"&&new TextDecoder,oi=0;try{si.decode(Ve,{stream:!0}),oi=1}catch{}function ce(e,t){if(t){for(var r=new C(e.length),n=0;n<e.length;++n)r[n]=e.charCodeAt(n);return r}if($r)return $r.encode(e);for(var i=e.length,s=new C(e.length+(e.length>>1)),c=0,o=function(f){s[c++]=f},n=0;n<i;++n){if(c+5>s.length){var p=new C(c+8+(i-n<<1));p.set(s),s=p}var h=e.charCodeAt(n);h<128||t?o(h):h<2048?(o(192|h>>6),o(128|h&63)):h>55295&&h<57344?(h=65536+(h&1023<<10)|e.charCodeAt(++n)&1023,o(240|h>>18),o(128|h>>12&63),o(128|h>>6&63),o(128|h&63)):(o(224|h>>12),o(128|h>>6&63),o(128|h&63))}return Rr(s,0,c)}var Be="core.Pings.Database";function le(e){return e.path.split("/")[3]===Tt}function ci(e){return ce(JSON.stringify(e)).length}function li(e){if(S(e)&&(Object.keys(e).length===2||Object.keys(e).length===3)){let t="path"in e&&E(e.path),r="payload"in e&&Q(e.payload)&&S(e.payload),n=!("headers"in e)||Q(e.headers)&&S(e.headers);return!(!t||!r||!n)}return!1}var Cr=class{constructor(){this.store=new a.platform.Storage("pings")}attachObserver(t){this.observer=t}async recordPing(t,r,n,i){let s={collectionDate:new Date().toISOString(),path:t,payload:n};i&&(s.headers=i),await this.store.update([r],()=>s),this.observer&&this.observer.update(r,s)}async deletePing(t){await this.store.delete([t])}async getAllPings(){let t=await this.store.get(),r={};if(S(t))for(let n in t){let i=t[n];li(i)?r[n]=i:(l(Be,"Unexpected data found in pings database. Deleting.",u.Warn),await this.store.delete([n]))}return Object.entries(r).sort(([n,{collectionDate:i}],[s,{collectionDate:c}])=>{let o=new Date(i).getTime(),p=new Date(c).getTime();return o-p})}async getAllPingsWithoutSurplus(t=250,r=10*1024*1024){let n=await this.getAllPings(),i=n.filter(([g,m])=>!le(m)).reverse(),s=n.filter(([g,m])=>le(m)),c=i.length;c>t&&l(Be,[`More than ${t} pending pings in the pings database,`,`will delete ${c-t} old pings.`],u.Warn);let o=!1,p=0,h=0,f=[];for(let[g,m]of i)p++,h+=ci(m),!o&&h>r&&(l(Be,[`Pending pings database has reached the size quota of ${r} bytes,`,"outstanding pings will be deleted."],u.Warn),o=!0),p>t&&(o=!0),o?await this.deletePing(g):f.unshift([g,m]);return[...s,...f]}async scanPendingPings(){if(!this.observer)return;let t=await this.getAllPingsWithoutSurplus();for(let[r,n]of t)this.observer.update(r,n)}async clearAll(){await this.store.delete([])}},kr=Cr;var ui=60*1e3,fi=40,Vr;(function(e){e[e.Incrementing=0]="Incrementing",e[e.Throttled=1]="Throttled"})(Vr||(Vr={}));var Fr=class{constructor(t=ui,r=fi,n=0,i){this.interval=t,this.maxCount=r,this.count=n,this.started=i}get elapsed(){if(P(this.started))return NaN;let r=pt()-this.started;return r<0?NaN:r}reset(){this.started=pt(),this.count=0}shouldReset(){return!!(P(this.started)||isNaN(this.elapsed)||this.elapsed>this.interval)}getState(){this.shouldReset()&&this.reset();let t=this.interval-this.elapsed;return this.count>=this.maxCount?{state:1,remainingTime:t}:(this.count++,{state:0})}},Br=Fr;var St=class{constructor(t=3,r=3,n=1024*1024){this.maxWaitAttempts=t,this.maxRecoverableFailures=r,this.maxPingBodySize=n}};var jr="core.Upload.PingUploadWorker",qr=class extends Error{constructor(t){super(t);this.name="PingBodyOverflow"}},Wr=class{constructor(t,r,n=new St){this.uploader=t,this.serverEndpoint=r,this.policy=n,this.isBlocking=!1}async buildPingRequest(t){let r=t.headers||{};r={...t.headers,"Content-Type":"application/json; charset=utf-8",Date:new Date().toISOString(),"X-Client-Type":"Glean.js","X-Client-Version":Lt,"X-Telemetry-Agent":`Glean/${Lt} (JS on ${await a.platform.info.os()})`};let n=JSON.stringify(t.payload),i=ce(n),s,c;try{s=zr(i),c=s.length,r["Content-Encoding"]="gzip"}catch{s=n,c=i.length}if(c>this.policy.maxPingBodySize)throw new qr(`Body for ping ${t.identifier} exceeds ${this.policy.maxPingBodySize}bytes. Discarding.`);return r["Content-Length"]=c.toString(),{headers:r,payload:s}}async attemptPingUpload(t){try{let r=await this.buildPingRequest(t);return await this.uploader.post(`${this.serverEndpoint}${t.path}`,r.payload,r.headers)}catch(r){return l(jr,["Error trying to build or post ping request:",r],u.Warn),new ot(1)}}async workInternal(t,r){for(;;){let n=t();switch(n.type){case"upload":let i=await this.attemptPingUpload(n.ping);await r(n.ping,i);continue;case"wait":if(this.isBlocking)return;try{if(await new Promise(c=>{this.waitPromiseResolver=c,this.waitTimeoutId=a.platform.timer.setTimeout(()=>{this.waitPromiseResolver=void 0,this.waitTimeoutId=void 0,c(!1)},n.remainingTime)}))return}catch{this.waitPromiseResolver=void 0,this.waitTimeoutId=void 0;return}continue;case"done":return}}}work(t,r){this.currentJob||(this.currentJob=this.workInternal(t,r).then(()=>{this.currentJob=void 0}).catch(n=>{l(jr,["IMPOSSIBLE: Something went wrong while processing ping upload tasks.",n],u.Error)}))}async blockOnCurrentJob(){if(this.currentJob){this.waitTimeoutId&&this.waitPromiseResolver&&(a.platform.timer.clearTimeout(this.waitTimeoutId),this.waitPromiseResolver(!0),this.waitPromiseResolver=void 0,this.waitTimeoutId=void 0),this.isBlocking=!0,await this.currentJob,this.isBlocking=!1;return}return Promise.resolve()}},Xr=Wr;var Jr;(function(e){e.Done="done",e.Wait="wait",e.Upload="upload"})(Jr||(Jr={}));var _t={done:()=>({type:"done"}),wait:e=>({type:"wait",remainingTime:e}),upload:e=>({type:"upload",ping:e})};var Ft="core.Upload.PingUploadManager",Kr=class{constructor(t,r,n=new St,i=new Br){this.pingsDatabase=r,this.policy=n,this.rateLimiter=i,this.recoverableFailureCount=0,this.waitAttemptCount=0,this.queue=[],this.worker=new Xr(t.httpClient?t.httpClient:a.platform.uploader,t.serverEndpoint,n),r.attachObserver(this)}enqueuePing(t){for(let r of this.queue)if(r.identifier===t.identifier)return;this.queue.push(t)}getUploadTaskInternal(){if(this.recoverableFailureCount>=this.policy.maxRecoverableFailures)return l(Ft,"Glean has reached maximum recoverable upload failures for the current uploading window.",u.Debug),_t.done();if(this.queue.length>0){let{state:t,remainingTime:r}=this.rateLimiter.getState();if(t===1)return l(Ft,["Glean is currently throttled.",`Pending pings may be uploaded in ${(r||0)/1e3}s.`],u.Debug),this.waitAttemptCount++,this.waitAttemptCount>this.policy.maxWaitAttempts?_t.done():_t.wait(r||0);let n=this.queue.shift();return _t.upload(n)}return _t.done()}getUploadTask(){let t=this.getUploadTaskInternal();return t.type!=="wait"&&this.waitAttemptCount>0&&(this.waitAttemptCount=0),t.type!=="upload"&&this.recoverableFailureCount>0&&(this.recoverableFailureCount=0),t}async processPingUploadResponse(t,r){let{identifier:n}=t;this.queue.filter(c=>c.identifier!==n);let{status:i,result:s}=r;if(i&&i>=200&&i<300){l(Ft,`Ping ${n} succesfully sent ${i}.`,u.Info),await this.pingsDatabase.deletePing(n);return}if(s===1||i&&i>=400&&i<500){l(Ft,`Unrecoverable upload failure while attempting to send ping ${n}. Error was: ${i??"no status"}.`,u.Warn),await this.pingsDatabase.deletePing(n);return}l(Ft,[`Recoverable upload failure while attempting to send ping ${n}, will retry.`,`Error was: ${i??"no status"}.`],u.Warn),this.recoverableFailureCount++,this.enqueuePing(t)}async clearPendingPingsQueue(){this.queue=this.queue.filter(t=>le(t)),await this.blockOnOngoingUploads()}async blockOnOngoingUploads(){return this.worker.blockOnCurrentJob()}update(t,r){this.enqueuePing({identifier:t,...r}),this.worker.work(()=>this.getUploadTask(),(n,i)=>this.processPingUploadResponse(n,i))}},Hr=Kr;var hi="core.InternalMetrics",je=class{constructor(){this.clientId=new zt({name:"client_id",category:"",sendInPings:["glean_client_info"],lifetime:"user",disabled:!1}),this.firstRunDate=new Y({name:"first_run_date",category:"",sendInPings:["glean_client_info"],lifetime:"user",disabled:!1},x.Day),this.os=new O({name:"os",category:"",sendInPings:["glean_client_info"],lifetime:"application",disabled:!1}),this.osVersion=new O({name:"os_version",category:"",sendInPings:["glean_client_info"],lifetime:"application",disabled:!1}),this.architecture=new O({name:"architecture",category:"",sendInPings:["glean_client_info"],lifetime:"application",disabled:!1}),this.locale=new O({name:"locale",category:"",sendInPings:["glean_client_info"],lifetime:"application",disabled:!1}),this.appChannel=new O({name:"app_channel",category:"",sendInPings:["glean_client_info"],lifetime:"application",disabled:!1}),this.appBuild=new O({name:"app_build",category:"",sendInPings:["glean_client_info"],lifetime:"application",disabled:!1}),this.appDisplayVersion=new O({name:"app_display_version",category:"",sendInPings:["glean_client_info"],lifetime:"application",disabled:!1})}async initialize(){await this.initializeClientId(),await this.initializeFirstRunDate(),await O._private_setUndispatched(this.os,await a.platform.info.os()),await O._private_setUndispatched(this.osVersion,await a.platform.info.osVersion(a.config.osVersion)),await O._private_setUndispatched(this.architecture,await a.platform.info.arch(a.config.architecture)),await O._private_setUndispatched(this.locale,await a.platform.info.locale()),await O._private_setUndispatched(this.appBuild,a.config.appBuild||"Unknown"),await O._private_setUndispatched(this.appDisplayVersion,a.config.appDisplayVersion||"Unknown"),a.config.channel&&await O._private_setUndispatched(this.appChannel,a.config.channel)}async initializeClientId(){let t=!1,r=await a.metricsDatabase.getMetric(lt,this.clientId);if(r)try{$t("uuid",r).payload()===Gt&&(t=!0)}catch{l(hi,"Unexpected value found for Glean clientId. Ignoring.",u.Warn),t=!0}else t=!0;t&&await zt._private_setUndispatched(this.clientId,ht())}async initializeFirstRunDate(){await a.metricsDatabase.getMetric(lt,this.firstRunDate)||await Y._private_setUndispatched(this.firstRunDate)}};var k=class{constructor(t,r,n,i){this.category=t,this.name=r,this.timestamp=n,this.extra=i}static toJSONObject(t){return{category:t.category,name:t.name,timestamp:t.timestamp,extra:t.extra}}static fromJSONObject(t){return new k(t.category,t.name,t.timestamp,t.extra)}static withTransformedExtras(t,r){let n=t.extra||{},i=r(n);return new k(t.category,t.name,t.timestamp,i&&Object.keys(i).length>0?i:void 0)}addExtra(t,r){this.extra||(this.extra={}),this.extra[t]=r}withoutReservedExtras(){return k.withTransformedExtras(this,t=>Object.keys(t).filter(r=>!vr.includes(r)).reduce((r,n)=>(r[n]=t[n],r),{}))}payload(){return k.withTransformedExtras(this.withoutReservedExtras(),t=>Object.keys(t).reduce((r,n)=>(r[n]=t[n].toString(),r),{}))}};var pi="core.metrics.EventMetricType",di=100,ue=class extends W{constructor(t,r){super("event",t);this.allowedExtraKeys=r}static async _private_recordUndispatched(t,r,n=pt()){if(!t.shouldRecord(a.uploadEnabled))return;let i;if(r&&t.allowedExtraKeys){i={};for(let[s,c]of Object.entries(r))if(t.allowedExtraKeys.includes(s))E(c)?i[s]=await xt(t,c,di):i[s]=c;else{await a.errorManager.record(t,M.InvalidValue,`Invalid key index: ${s}`);continue}}return a.eventsDatabase.record(t,new k(t.category,t.name,n,i))}record(t){let r=pt();a.dispatcher.launch(async()=>{await ue._private_recordUndispatched(this,t,r)})}async testGetValue(t=this.sendInPings[0]){if(_("testGetValue",pi)){let r;return await a.dispatcher.testLaunch(async()=>{r=await a.eventsDatabase.getEvents(t,this)}),r}}},qe=ue;var mi="core.Metric.EventsDatabase";function Zr(e){E(e)||(e="");let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Error attempting to generate Date object from string: ${e}`);return t}function Yr(e){return new Z({...Sr("execution_counter"),sendInPings:e,lifetime:"ping",disabled:!1})}function Qr(e){return new qe({category:"glean",name:"restarted",sendInPings:e,lifetime:"ping",disabled:!1},[Et])}async function tn(e,t=a.startTime){let r=Qr(e);await qe._private_recordUndispatched(r,{[Et]:t.toISOString()},0)}var en=class{constructor(){this.initialized=!1,this.eventsStore=new a.platform.Storage("events")}async getAvailableStoreNames(){let t=await this.eventsStore.get([]);return P(t)?[]:Object.keys(t)}async initialize(){if(this.initialized)return;let t=await this.getAvailableStoreNames();await Z._private_addUndispatched(Yr(t),1),await tn(t),this.initialized=!0}async record(t,r){if(!t.disabled)for(let n of t.sendInPings){let i=Yr([n]),s=await a.metricsDatabase.getMetric(n,i);s||(await Z._private_addUndispatched(i,1),s=1,await tn([n],new Date)),r.addExtra(It,s);let c=o=>{var p;let h=(p=o)!==null&&p!==void 0?p:[];return h.push(k.toJSONObject(r)),h};await this.eventsStore.update([n],c)}}async getEvents(t,r){let n=await this.getAndValidatePingData(t);if(n.length!==0)return n.filter(i=>i.category===r.category&&i.name===r.name).map(i=>i.withoutReservedExtras())}async getAndValidatePingData(t){let r=await this.eventsStore.get([t]);return P(r)?[]:Array.isArray(r)?r.map(n=>k.fromJSONObject(n)):(l(mi,`Unexpected value found for ping ${t}: ${JSON.stringify(r)}. Clearing.`,u.Error),await this.eventsStore.delete([t]),[])}async getPingEvents(t,r){let n=await this.getAndValidatePingData(t);if(r&&Object.keys(n).length>0&&await this.eventsStore.delete([t]),n.length===0)return;let i=await this.prepareEventsPayload(t,n);if(i.length>0)return i}async prepareEventsPayload(t,r){var n,i,s,c;let o=r.sort((g,m)=>{var b,d;let y=Number((b=g.extra)===null||b===void 0?void 0:b[It]),I=Number((d=m.extra)===null||d===void 0?void 0:d[It]);return y!==I?y-I:g.timestamp-m.timestamp}),p;try{p=Zr((n=o[0].extra)===null||n===void 0?void 0:n[Et]),o.shift()}catch{p=a.startTime}let h=((i=o[0])===null||i===void 0?void 0:i.timestamp)||0,f=0;for(let[g,m]of o.entries()){try{let y=Zr((s=m.extra)===null||s===void 0?void 0:s[Et]),I=y.getTime()-p.getTime();p=y;let L=f+I,D=o[g-1].timestamp;L<=D?(f=D+1,await a.errorManager.record(Qr([t]),M.InvalidValue,`Invalid time offset between application sessions found for ping "${t}". Ignoring.`)):f=L}catch{}let b=Number(((c=m.extra)===null||c===void 0?void 0:c[It])||1),d;b===1?d=m.timestamp-h:d=m.timestamp+f,o[g]=new k(m.category,m.name,d,m.extra)}return o.map(g=>k.toJSONObject(g.payload()))}async clearAll(){await this.eventsStore.delete([])}},rn=en;var gi="core.Events",nn=class{constructor(t){this.name=t}get registeredPluginIdentifier(){var t;return(t=this.plugin)===null||t===void 0?void 0:t.name}registerPlugin(t){if(this.plugin){l(gi,[`Attempted to register plugin '${t.name}', which listens to the event '${t.event}'.`,`That event is already watched by plugin '${this.plugin.name}'`,`Plugin '${t.name}' will be ignored.`],u.Error);return}this.plugin=t}deregisterPlugin(){this.plugin=void 0}trigger(...t){if(this.plugin)return this.plugin.action(...t)}},vi={afterPingCollection:new nn("afterPingCollection")},ut=vi;var Mt="core.Pings.Maker";async function wi(e){let t=new Y({category:"",name:`${e.name}#start`,sendInPings:[Rt],lifetime:"user",disabled:!1},x.Minute),r=await a.metricsDatabase.getMetric(Rt,t),n;return r?n=new $(r):n=$.fromDate(a.startTime,x.Minute),{startTimeMetric:t,startTime:n}}async function yi(e){let t=new Z({category:"",name:`${e.name}#sequence`,sendInPings:[Rt],lifetime:"user",disabled:!1}),r=await a.metricsDatabase.getMetric(Rt,t);if(await Z._private_addUndispatched(t,1),r)try{return new dt(r).payload()}catch{l(Mt,`Unexpected value found for sequence number in ping ${e.name}. Ignoring.`,u.Warn)}return 0}async function bi(e){let{startTimeMetric:t,startTime:r}=await wi(e),n=new Date;await Y._private_setUndispatched(t,n);let i=$.fromDate(n,x.Minute);return{startTime:r.payload(),endTime:i.payload()}}async function xi(e,t){let r=await yi(e),{startTime:n,endTime:i}=await bi(e),s={seq:r,start_time:n,end_time:i};return t&&(s.reason=t),s}async function Ti(e){let t=await a.metricsDatabase.getPingMetrics(lt,!0);t||(l(Mt,"Empty client info data. Will submit anyways.",u.Warn),t={});let r={telemetry_sdk_build:Lt};for(let n in t)r={...r,...t[n]};return e.includeClientId||delete r.client_id,r}function Ei(){let e={};if(a.config.debugViewTag&&(e["X-Debug-ID"]=a.config.debugViewTag),a.config.sourceTags&&(e["X-Source-Tags"]=a.config.sourceTags.toString()),Object.keys(e).length>0)return e}async function Ii(e,t){let r=await a.eventsDatabase.getPingEvents(e.name,!0),n=await a.metricsDatabase.getPingMetrics(e.name,!0);if(!n&&!r){if(!e.sendIfEmpty){l(Mt,`Storage for ${e.name} empty. Bailing out.`,u.Info);return}l(Mt,`Storage for ${e.name} empty. Ping will still be sent.`,u.Info)}let i=n?{metrics:n}:{},s=r?{events:r}:{},c=await xi(e,t),o=await Ti(e);return{...i,...s,ping_info:c,client_info:o}}function Si(e,t){return`/submit/${a.applicationId}/${t.name}/${mr}/${e}`}async function _i(e,t,r){let n=await Ii(t,r);if(!n)return;let i;try{i=await ut.afterPingCollection.trigger(n)}catch(o){l(Mt,[`Error while attempting to modify ping payload for the "${t.name}" ping using`,`the ${JSON.stringify(ut.afterPingCollection.registeredPluginIdentifier)} plugin.`,`Ping will not be submitted. See more logs below.
`,o],u.Error);return}a.config.logPings&&l(Mt,JSON.stringify(n,null,2),u.Info);let s=i||n,c=Ei();return a.pingsDatabase.recordPing(Si(e,t),e,s,c)}var an=_i;var Dt="core.Pings.PingType",gt=class{constructor(t){var r;this.name=t.name,this.includeClientId=t.includeClientId,this.sendIfEmpty=t.sendIfEmpty,this.reasonCodes=(r=t.reasonCodes)!==null&&r!==void 0?r:[]}isDeletionRequest(){return this.name===Tt}submit(t){this.testCallback?this.testCallback(t).then(()=>{gt._private_internalSubmit(this,t,this.resolveTestPromiseFunction)}).catch(r=>{l(Dt,[`There was an error validating "${this.name}" (${t??"no reason"}):`,r],u.Error),gt._private_internalSubmit(this,t,this.rejectTestPromiseFunction)}):gt._private_internalSubmit(this,t)}static async _private_submitUndispatched(t,r,n){if(!a.initialized){l(Dt,"Glean must be initialized before submitting pings.",u.Info);return}if(!a.uploadEnabled&&!t.isDeletionRequest()){l(Dt,"Glean disabled: not submitting pings. Glean may still submit the deletion-request ping.",u.Info);return}let i=r;r&&!t.reasonCodes.includes(r)&&(l(Dt,`Invalid reason code ${r} from ${this.name}. Ignoring.`,u.Warn),i=void 0);let s=ht();await an(s,t,i),n&&(n(),t.resolveTestPromiseFunction=void 0,t.rejectTestPromiseFunction=void 0,t.testCallback=void 0)}static _private_internalSubmit(t,r,n){a.dispatcher.launch(async()=>{await gt._private_submitUndispatched(t,r,n)})}async testBeforeNextSubmit(t){if(_("testBeforeNextSubmit",Dt)){if(this.testCallback){l(Dt,`There is an existing test call for ping "${this.name}". Ignoring.`,u.Error);return}return new Promise((r,n)=>{this.resolveTestPromiseFunction=r,this.rejectTestPromiseFunction=n,this.testCallback=t})}}},Pt=gt;var sn=class{constructor(){this.deletionRequest=new Pt({name:Tt,includeClientId:!0,sendIfEmpty:!0})}},on=sn;var Mi="core.Events.Utils";function cn(e){let t=e.event;if(t in ut){ut[t].registerPlugin(e);return}l(Mi,[`Attempted to register plugin '${e.name}', which listens to the event '${e.event}'.`,"That is not a valid Glean event. Ignoring"],u.Error)}function ln(){for(let e in ut)ut[e].deregisterPlugin()}function Di(e){return`core.Metrics.${e.type.charAt(0).toUpperCase()+e.type.slice(1)}`}function un(e,t){let r=e.baseIdentifier(),n=yr(r);return new Z({name:Yt(t,n),category:"glean.error",lifetime:"ping",sendInPings:e.sendInPings,disabled:!1})}var fe=class{async record(t,r,n,i=1){let s=un(t,r);l(Di(t),[`${t.baseIdentifier()}:`,n]),i>0&&await Z._private_addUndispatched(s,i)}async testGetNumRecordedErrors(t,r,n){return await un(t,r).testGetValue(n)||0}};var Pi="plaftom.test.Storage",Bt={},fn=class{constructor(t){this.rootKey=t}get(t=[]){try{let r=Kt(Bt,[this.rootKey,...t]);return Promise.resolve(r)}catch(r){return Promise.reject(r)}}update(t,r){try{return Bt=Ht(Bt,[this.rootKey,...t],r),Promise.resolve()}catch(n){return Promise.reject(n)}}delete(t){try{Bt=Zt(Bt,[this.rootKey,...t])}catch(r){l(Pi,[`Error attempting to delete key ${t.toString()} from storage. Ignoring.`,r],u.Warn)}return Promise.resolve()}},hn=fn;var pn=class extends qt{post(t,r,n){let i=new ot(2,200);return Promise.resolve(i)}},Ai={os(){return Promise.resolve("Unknown")},osVersion(){return Promise.resolve("Unknown")},arch(){return Promise.resolve("Unknown")},locale(){return Promise.resolve("Unknown")}},Ui=typeof setTimeout!="undefined"?setTimeout:()=>{throw new Error},Oi=typeof clearTimeout!="undefined"?clearTimeout:()=>{},Li={Storage:hn,uploader:new pn,info:Ai,timer:{setTimeout:Ui,clearTimeout:Oi},name:"test"},dn=Li;var nt="core.Glean",We;(function(e){e.coreMetrics=new je,e.corePings=new on;async function t(){a.uploadEnabled=!0,await e.coreMetrics.initialize()}async function r(){a.uploadEnabled=!1,await Pt._private_submitUndispatched(e.corePings.deletionRequest),await n()}async function n(){await e.pingUploader.clearPendingPingsQueue();let d;try{d=new $(await a.metricsDatabase.getMetric(lt,e.coreMetrics.firstRunDate)).date}catch{d=new Date}await a.eventsDatabase.clearAll(),await a.metricsDatabase.clearAll(),await a.pingsDatabase.clearAll(),a.uploadEnabled=!0,await zt._private_setUndispatched(e.coreMetrics.clientId,Gt),await Y._private_setUndispatched(e.coreMetrics.firstRunDate,d),a.uploadEnabled=!1}function i(d,y,I){if(a.initialized){l(nt,"Attempted to initialize Glean, but it has already been initialized. Ignoring.",u.Warn);return}if(!E(d)){l(nt,"Unable to initialize Glean, applicationId must be a string.",u.Error);return}if(!bt(y)){l(nt,"Unable to initialize Glean, uploadEnabled must be a boolean.",u.Error);return}if(d.length===0){l(nt,"Unable to initialize Glean, applicationId cannot be an empty string.",u.Error);return}if(!a.platform){l(nt,"Unable to initialize Glean, platform has not been set.",u.Error);return}a.applicationId=ur(d);let L=new Ee(I);if(a.config=L,a.metricsDatabase=new Mr,a.eventsDatabase=new rn,a.pingsDatabase=new kr,a.errorManager=new fe,e.pingUploader=new Hr(L,a.pingsDatabase),I==null?void 0:I.plugins)for(let D of I.plugins)cn(D);a.dispatcher.flushInit(async()=>{if(a.initialized=!0,a.uploadEnabled=y,y)await a.metricsDatabase.clear("application"),await t();else{let D=await a.metricsDatabase.getMetric(lt,e.coreMetrics.clientId);D?D!==Gt&&await r():await n()}await a.eventsDatabase.initialize(),await a.pingsDatabase.scanPendingPings()})}e.initialize=i;function s(d){if(!a.initialized){l(nt,[`Changing upload enabled before Glean is initialized is not supported.
`,"Pass the correct state into `initialize`.\n","See documentation at https://mozilla.github.io/glean/book/user/general-api.html#initializing-the-glean-sdk`"],u.Error);return}if(!bt(d)){l(nt,"Unable to change upload state, new value must be a boolean. Ignoring.",u.Error);return}a.dispatcher.launch(async()=>{a.uploadEnabled!==d&&(d?await t():await r())})}e.setUploadEnabled=s;function c(d){a.dispatcher.launch(()=>(a.config.logPings=d,Promise.resolve()))}e.setLogPings=c;function o(d){a.dispatcher.launch(()=>(a.config.debugViewTag=d,Promise.resolve()))}e.setDebugViewTag=o;function p(d){a.dispatcher.launch(()=>(a.config.sourceTags=d,Promise.resolve()))}e.setSourceTags=p;async function h(){if(!a.initialized){l(nt,"Attempted to shutdown Glean, but Glean is not initialized. Ignoring.");return}await a.dispatcher.shutdown(),await e.pingUploader.blockOnOngoingUploads()}e.shutdown=h;function f(d){a.initialized||(a.isPlatformSet()&&a.platform.name!==d.name&&!a.testing&&l(nt,[`IMPOSSIBLE: Attempted to change Glean's targeted platform",
"from "${a.platform.name}" to "${d.name}". Ignoring.`],u.Error),a.platform=d)}e.setPlatform=f;async function g(d,y=!0,I){a.testing=!0,f(dn),i(d,y,I),await a.dispatcher.testBlockOnQueue()}e.testInitialize=g;async function m(d=!0){a.initialized&&(await h(),d&&(await a.eventsDatabase.clearAll(),await a.metricsDatabase.clearAll(),await a.pingsDatabase.clearAll()),a.testUninitialize(),ln())}e.testUninitialize=m;async function b(d,y=!0,I,L=!0){await m(L),await g(d,y,I)}e.testResetGlean=b})(We||(We={}));var it=We;var mn=e=>({initialize(t,r,n){it.setPlatform(e),it.initialize(t,r,n)},setUploadEnabled(t){it.setUploadEnabled(t)},setLogPings(t){it.setLogPings(t)},setDebugViewTag(t){it.setDebugViewTag(t)},shutdown(){return it.shutdown()},setSourceTags(t){it.setSourceTags(t)},async testResetGlean(t,r=!0,n){return it.testResetGlean(t,r,n)}});var gn=mn(dr);var vn=new Pt({includeClientId:!0,sendIfEmpty:!1,name:"visit",reasonCodes:[]});var wn=new Y({category:"page",name:"loaded",sendInPings:["visit"],lifetime:"ping",disabled:!1},"millisecond"),yn=new O({category:"page",name:"path",sendInPings:["visit"],lifetime:"ping",disabled:!1});function Gi(e){document.readyState!="loading"?e():document.addEventListener("DOMContentLoaded",e)}Gi(()=>{let e={serverEndpoint:"https://telemetry-ingestion.fly.dev"};gn.initialize("net-rediger-jer",!0,e),wn.set(),yn.set(location.pathname),vn.submit()});})();