@bugsnag/web-worker
Version:
BugSnag error reporter for JavaScript web workers and service workers
2 lines • 33.7 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Bugsnag=t():e.Bugsnag=t()}(self,(()=>(()=>{var e={99:(e,t,r)=>{var n=r(98),s=r(225),a=r(182),o=0,i=Math.pow(36,4);function c(){return a((Math.random()*i|0).toString(36),4)}function l(){return"c"+(new Date).getTime().toString(36)+a((o=o<i?o:0,++o-1).toString(36),4)+n()+(c()+c())}l.fingerprint=n,l.isCuid=s,e.exports=l},98:(e,t,r)=>{var n=r(182),s="object"==typeof window?window:self,a=0;for(var o in s)Object.hasOwnProperty.call(s,o)&&a++;var i=n(((navigator.mimeTypes?navigator.mimeTypes.length:0)+navigator.userAgent.length).toString(36)+a.toString(36),4);e.exports=function(){return i}},225:e=>{e.exports=function(e){return"string"==typeof e&&/^c[a-z0-9]{20,32}$/.test(e)}},182:e=>{e.exports=function(e,t){var r="000000000"+e;return r.substr(r.length-t)}},876:e=>{e.exports=function(e,l,u,d){var h=d&&d.redactedKeys?d.redactedKeys:[],g=d&&d.redactedPaths?d.redactedPaths:[];return JSON.stringify(function(e,l,u){var d=[],h=0;return function e(g,f){function p(){return f.length>n&&h>r}if(h++,f.length>t)return s;if(p())return s;if(null===g||"object"!=typeof g)return g;if(function(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return!0;return!1}(d,g))return"[Circular]";if(d.push(g),"function"==typeof g.toJSON)try{h--;var m=e(g.toJSON(),f);return d.pop(),m}catch(e){return a(e)}var y;if((y=g)instanceof Error||/^\[object (Error|(Dom)?Exception)\]$/.test(Object.prototype.toString.call(y))){h--;var b=e({name:g.name,message:g.message},f);return d.pop(),b}if(function(e){return"[object Array]"===Object.prototype.toString.call(e)}(g)){for(var _=[],v=0,S=g.length;v<S;v++){if(p()){_.push(s);break}_.push(e(g[v],f.concat("[]")))}return d.pop(),_}var x={};try{for(var w in g)if(Object.prototype.hasOwnProperty.call(g,w))if(o(u,f.join("."))&&i(l,w))x[w]="[REDACTED]";else{if(p()){x[w]=s;break}x[w]=e(c(g,w),f.concat(w))}}catch(e){}return d.pop(),x}(e,[])}(e,h,g),l,u)};var t=20,r=25e3,n=8,s="...";function a(e){return"[Throws: "+(e?e.message:"?")+"]"}function o(e,t){for(var r=0,n=e.length;r<n;r++)if(0===t.indexOf(e[r]))return!0;return!1}function i(e,t){for(var r=0,n=e.length;r<n;r++){if("string"==typeof e[r]&&e[r].toLowerCase()===t.toLowerCase())return!0;if(e[r]&&"function"==typeof e[r].test&&e[r].test(t))return!0}return!1}function c(e,t){try{return e[t]}catch(e){return a(e)}}},482:function(e,t,r){var n,s,a;!function(){"use strict";s=[r(550)],void 0===(a="function"==typeof(n=function(e){var t=/(^|@)\S+:\d+/,r=/^\s*at .*(\S+:\d+|\(native\))/m,n=/^(eval@)?(\[native code])?$/;return{parse:function(e){if(void 0!==e.stacktrace||void 0!==e["opera#sourceloc"])return this.parseOpera(e);if(e.stack&&e.stack.match(r))return this.parseV8OrIE(e);if(e.stack)return this.parseFFOrSafari(e);throw new Error("Cannot parse given Error object")},extractLocation:function(e){if(-1===e.indexOf(":"))return[e];var t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));return[t[1],t[2]||void 0,t[3]||void 0]},parseV8OrIE:function(t){return t.stack.split("\n").filter((function(e){return!!e.match(r)}),this).map((function(t){t.indexOf("(eval ")>-1&&(t=t.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));var r=t.replace(/^\s+/,"").replace(/\(eval code/g,"("),n=r.match(/ (\((.+):(\d+):(\d+)\)$)/),s=(r=n?r.replace(n[0],""):r).split(/\s+/).slice(1),a=this.extractLocation(n?n[1]:s.pop()),o=s.join(" ")||void 0,i=["eval","<anonymous>"].indexOf(a[0])>-1?void 0:a[0];return new e({functionName:o,fileName:i,lineNumber:a[1],columnNumber:a[2],source:t})}),this)},parseFFOrSafari:function(t){return t.stack.split("\n").filter((function(e){return!e.match(n)}),this).map((function(t){if(t.indexOf(" > eval")>-1&&(t=t.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===t.indexOf("@")&&-1===t.indexOf(":"))return new e({functionName:t});var r=/((.*".+"[^@]*)?[^@]*)(?:@)/,n=t.match(r),s=n&&n[1]?n[1]:void 0,a=this.extractLocation(t.replace(r,""));return new e({functionName:s,fileName:a[0],lineNumber:a[1],columnNumber:a[2],source:t})}),this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(t){for(var r=/Line (\d+).*script (?:in )?(\S+)/i,n=t.message.split("\n"),s=[],a=2,o=n.length;a<o;a+=2){var i=r.exec(n[a]);i&&s.push(new e({fileName:i[2],lineNumber:i[1],source:n[a]}))}return s},parseOpera10:function(t){for(var r=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,n=t.stacktrace.split("\n"),s=[],a=0,o=n.length;a<o;a+=2){var i=r.exec(n[a]);i&&s.push(new e({functionName:i[3]||void 0,fileName:i[2],lineNumber:i[1],source:n[a]}))}return s},parseOpera11:function(r){return r.stack.split("\n").filter((function(e){return!!e.match(t)&&!e.match(/^Error created at/)}),this).map((function(t){var r,n=t.split("@"),s=this.extractLocation(n.pop()),a=n.shift()||"",o=a.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;a.match(/\(([^)]*)\)/)&&(r=a.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var i=void 0===r||"[arguments not available]"===r?void 0:r.split(",");return new e({functionName:o,args:i,fileName:s[0],lineNumber:s[1],columnNumber:s[2],source:t})}),this)}}})?n.apply(t,s):n)||(e.exports=a)}()},468:e=>{e.exports=function(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return e instanceof Error}}},14:function(e,t,r){var n,s,a;!function(){"use strict";s=[r(550)],n=function(e){return{backtrace:function(t){var r=[],n=10;"object"==typeof t&&"number"==typeof t.maxStackSize&&(n=t.maxStackSize);for(var s=arguments.callee;s&&r.length<n&&s.arguments;){for(var a=new Array(s.arguments.length),o=0;o<a.length;++o)a[o]=s.arguments[o];/function(?:\s+([\w$]+))+\s*\(/.test(s.toString())?r.push(new e({functionName:RegExp.$1||void 0,args:a})):r.push(new e({args:a}));try{s=s.caller}catch(e){break}}return r}}},void 0===(a=n.apply(t,s))||(e.exports=a)}()},550:function(e,t){var r,n,s;!function(){"use strict";n=[],void 0===(s="function"==typeof(r=function(){function e(e){return e.charAt(0).toUpperCase()+e.substring(1)}function t(e){return function(){return this[e]}}var r=["isConstructor","isEval","isNative","isToplevel"],n=["columnNumber","lineNumber"],s=["fileName","functionName","source"],a=r.concat(n,s,["args"],["evalOrigin"]);function o(t){if(t)for(var r=0;r<a.length;r++)void 0!==t[a[r]]&&this["set"+e(a[r])](t[a[r]])}o.prototype={getArgs:function(){return this.args},setArgs:function(e){if("[object Array]"!==Object.prototype.toString.call(e))throw new TypeError("Args must be an Array");this.args=e},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(e){if(e instanceof o)this.evalOrigin=e;else{if(!(e instanceof Object))throw new TypeError("Eval Origin must be an Object or StackFrame");this.evalOrigin=new o(e)}},toString:function(){var e=this.getFileName()||"",t=this.getLineNumber()||"",r=this.getColumnNumber()||"",n=this.getFunctionName()||"";return this.getIsEval()?e?"[eval] ("+e+":"+t+":"+r+")":"[eval]:"+t+":"+r:n?n+" ("+e+":"+t+":"+r+")":e+":"+t+":"+r}},o.fromString=function(e){var t=e.indexOf("("),r=e.lastIndexOf(")"),n=e.substring(0,t),s=e.substring(t+1,r).split(","),a=e.substring(r+1);if(0===a.indexOf("@"))var i=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(a,""),c=i[1],l=i[2],u=i[3];return new o({functionName:n,args:s||void 0,fileName:c,lineNumber:l||void 0,columnNumber:u||void 0})};for(var i=0;i<r.length;i++)o.prototype["get"+e(r[i])]=t(r[i]),o.prototype["set"+e(r[i])]=function(e){return function(t){this[e]=Boolean(t)}}(r[i]);for(var c=0;c<n.length;c++)o.prototype["get"+e(n[c])]=t(n[c]),o.prototype["set"+e(n[c])]=function(e){return function(t){if(r=t,isNaN(parseFloat(r))||!isFinite(r))throw new TypeError(e+" must be a Number");var r;this[e]=Number(t)}}(n[c]);for(var l=0;l<s.length;l++)o.prototype["get"+e(s[l])]=t(s[l]),o.prototype["set"+e(s[l])]=function(e){return function(t){this[e]=String(t)}}(s[l]);return o})?r.apply(t,n):r)||(e.exports=s)}()},112:e=>{e.exports=class{constructor(e,t,r,n=new Date){this.type=r,this.message=e,this.metadata=t,this.timestamp=n}toJSON(){return{type:this.type,name:this.message,timestamp:this.timestamp,metaData:this.metadata}}}},478:(e,t,r)=>{const n=r(223),s=r(717),a=r(112),o=r(669),i=r(628),c=r(957),l=r(978),u=r(850),d=r(188),h=r(465),g=r(969),f=r(670),p=r(171),m=r(496),{add:y,clear:b,merge:_}=r(472),v=()=>{};class S{constructor(e,t=n.schema,r=[],c){this._notifier=c,this._config={},this._schema=t,this._delivery={sendSession:v,sendEvent:v},this._logger={debug:v,info:v,warn:v,error:v},this._plugins={},this._breadcrumbs=[],this._session=null,this._metadata={},this._featuresIndex={},this._features=[],this._context=void 0,this._user={},this._cbs={e:[],s:[],sp:[],b:[]},this.Client=S,this.Event=s,this.Breadcrumb=a,this.Session=o,this._config=this._configure(e,r),i(r.concat(this._config.plugins),(e=>{e&&this._loadPlugin(e)})),this._depth=1;const l=this,u=this.notify;this.notify=function(){return u.apply(l,arguments)}}addMetadata(e,t,r){return f.add(this._metadata,e,t,r)}getMetadata(e,t){return f.get(this._metadata,e,t)}clearMetadata(e,t){return f.clear(this._metadata,e,t)}addFeatureFlag(e,t=null){y(this._features,this._featuresIndex,e,t)}addFeatureFlags(e){_(this._features,e,this._featuresIndex)}clearFeatureFlag(e){b(this._features,this._featuresIndex,e)}clearFeatureFlags(){this._features=[],this._featuresIndex={}}getContext(){return this._context}setContext(e){this._context=e}_configure(e,t){const r=u(t,((e,t)=>t&&t.configSchema?h({},e,t.configSchema):e),this._schema);e.endpoints||(e.sendPayloadChecksums=!("sendPayloadChecksums"in e)||e.sendPayloadChecksums);const{errors:n,config:s}=u(d(r),((t,n)=>{const s=r[n].defaultValue(e[n]);return void 0!==e[n]?r[n].validate(e[n])?r[n].allowPartialObject?t.config[n]=h(s,e[n]):t.config[n]=e[n]:(t.errors[n]=r[n].message,t.config[n]=s):t.config[n]=s,t}),{errors:{},config:{}});if(r.apiKey){if(!s.apiKey)throw new Error("No Bugsnag API Key set");/^[0-9a-f]{32}$/i.test(s.apiKey)||(n.apiKey="should be a string of 32 hexadecimal characters"),void 0===e.endpoints&&s.apiKey.startsWith("00000")&&(s.endpoints={notify:"https://notify.insighthub.smartbear.com",sessions:"https://sessions.insighthub.smartbear.com"})}return this._metadata=h({},s.metadata),_(this._features,s.featureFlags,this._featuresIndex),this._user=h({},s.user),this._context=s.context,s.logger&&(this._logger=s.logger),s.onError&&(this._cbs.e=this._cbs.e.concat(s.onError)),s.onBreadcrumb&&(this._cbs.b=this._cbs.b.concat(s.onBreadcrumb)),s.onSession&&(this._cbs.s=this._cbs.s.concat(s.onSession)),d(n).length&&this._logger.warn(x(n,e)),s}getUser(){return this._user}setUser(e,t,r){this._user={id:e,email:t,name:r}}_loadPlugin(e){const t=e.load(this);e.name&&(this._plugins[`~${e.name}~`]=t)}getPlugin(e){return this._plugins[`~${e}~`]}_setDelivery(e){this._delivery=e(this)}startSession(){const e=new o;return e.app.releaseStage=this._config.releaseStage,e.app.version=this._config.appVersion,e.app.type=this._config.appType,e._user=h({},this._user),p(this._cbs.s,e,"onSession",this._logger)?(this._logger.debug("Session not started due to onSession callback"),this):this._sessionDelegate.startSession(this,e)}addOnError(e,t=!1){this._cbs.e[t?"unshift":"push"](e)}removeOnError(e){this._cbs.e=l(this._cbs.e,(t=>t!==e))}_addOnSessionPayload(e){this._cbs.sp.push(e)}addOnSession(e){this._cbs.s.push(e)}removeOnSession(e){this._cbs.s=l(this._cbs.s,(t=>t!==e))}addOnBreadcrumb(e,t=!1){this._cbs.b[t?"unshift":"push"](e)}removeOnBreadcrumb(e){this._cbs.b=l(this._cbs.b,(t=>t!==e))}pauseSession(){return this._sessionDelegate.pauseSession(this)}resumeSession(){return this._sessionDelegate.resumeSession(this)}leaveBreadcrumb(e,t,r){if(e="string"==typeof e?e:"",r="string"==typeof r&&c(m,r)?r:"manual",!e)return;const n=new a(e,t="object"==typeof t&&null!==t?t:{},r);p(this._cbs.b,n,"onBreadcrumb",this._logger)?this._logger.debug("Breadcrumb not attached due to onBreadcrumb callback"):(this._breadcrumbs.push(n),this._breadcrumbs.length>this._config.maxBreadcrumbs&&(this._breadcrumbs=this._breadcrumbs.slice(this._breadcrumbs.length-this._config.maxBreadcrumbs)))}_isBreadcrumbTypeEnabled(e){const t=this._config.enabledBreadcrumbTypes;return null===t||c(t,e)}notify(e,t,r=v){const n=s.create(e,!0,void 0,"notify()",this._depth+1,this._logger);this._notify(n,t,r)}_notify(e,t,r=v){if(e.app=h({},e.app,{releaseStage:this._config.releaseStage,version:this._config.appVersion,type:this._config.appType}),e.context=e.context||this._context,e._metadata=h({},e._metadata,this._metadata),e._user=h({},e._user,this._user),e.breadcrumbs=this._breadcrumbs.slice(),_(e._features,this._features,e._featuresIndex),null!==this._config.enabledReleaseStages&&!c(this._config.enabledReleaseStages,this._config.releaseStage))return this._logger.warn("Event not sent due to releaseStage/enabledReleaseStages configuration"),r(null,e);const n=e.severity,s=e=>{this._logger.error("Error occurred in onError callback, continuing anyway…"),this._logger.error(e)},a=[].concat(this._cbs.e).concat(t);g(a,e,s,((t,a)=>{if(t&&s(t),!a)return this._logger.debug("Event not sent due to onError callback"),r(null,e);this._isBreadcrumbTypeEnabled("error")&&S.prototype.leaveBreadcrumb.call(this,e.errors[0].errorClass,{errorClass:e.errors[0].errorClass,errorMessage:e.errors[0].errorMessage,severity:e.severity},"error"),n!==e.severity&&(e._handledState.severityReason={type:"userCallbackSetSeverity"}),e.unhandled!==e._handledState.unhandled&&(e._handledState.severityReason.unhandledOverridden=!0,e._handledState.unhandled=e.unhandled),this._session&&(this._session._track(e),e._session=this._session),this._delivery.sendEvent({apiKey:e.apiKey||this._config.apiKey,notifier:this._notifier,events:[e]},(t=>r(t,e)))}))}}const x=(e,t)=>new Error(`Invalid configuration\n${i(d(e),(r=>` - ${r} ${e[r]}, got ${w(t[r])}`)).join("\n\n")}`),w=e=>{switch(typeof e){case"string":case"number":case"object":return JSON.stringify(e);default:return String(e)}};e.exports=S},223:(e,t,r)=>{const n=r(978),s=r(850),a=r(188),o=r(424),i=r(957),c=r(960),l=r(142),u=r(483),d=r(496);e.exports.schema={apiKey:{defaultValue:()=>null,message:"is required",validate:l},appVersion:{defaultValue:()=>{},message:"should be a string",validate:e=>void 0===e||l(e)},appType:{defaultValue:()=>{},message:"should be a string",validate:e=>void 0===e||l(e)},autoDetectErrors:{defaultValue:()=>!0,message:"should be true|false",validate:e=>!0===e||!1===e},enabledErrorTypes:{defaultValue:()=>({unhandledExceptions:!0,unhandledRejections:!0}),message:"should be an object containing the flags { unhandledExceptions:true|false, unhandledRejections:true|false }",allowPartialObject:!0,validate:e=>{if("object"!=typeof e||!e)return!1;const t=a(e),r=a({unhandledExceptions:!0,unhandledRejections:!0});return!(n(t,(e=>i(r,e))).length<t.length||n(a(e),(t=>"boolean"!=typeof e[t])).length>0)}},onError:{defaultValue:()=>[],message:"should be a function or array of functions",validate:u},onSession:{defaultValue:()=>[],message:"should be a function or array of functions",validate:u},onBreadcrumb:{defaultValue:()=>[],message:"should be a function or array of functions",validate:u},endpoints:{defaultValue:e=>void 0===e?{notify:"https://notify.bugsnag.com",sessions:"https://sessions.bugsnag.com"}:{notify:null,sessions:null},message:"should be an object containing endpoint URLs { notify, sessions }",validate:e=>e&&"object"==typeof e&&l(e.notify)&&l(e.sessions)&&0===n(a(e),(e=>!i(["notify","sessions"],e))).length},autoTrackSessions:{defaultValue:e=>!0,message:"should be true|false",validate:e=>!0===e||!1===e},enabledReleaseStages:{defaultValue:()=>null,message:"should be an array of strings",validate:e=>null===e||o(e)&&n(e,(e=>"string"==typeof e)).length===e.length},releaseStage:{defaultValue:()=>"production",message:"should be a string",validate:e=>"string"==typeof e&&e.length},maxBreadcrumbs:{defaultValue:()=>25,message:"should be a number ≤100",validate:e=>c(0,100)(e)},enabledBreadcrumbTypes:{defaultValue:()=>d,message:`should be null or a list of available breadcrumb types (${d.join(",")})`,validate:e=>null===e||o(e)&&s(e,((e,t)=>!1===e?e:i(d,t)),!0)},context:{defaultValue:()=>{},message:"should be a string",validate:e=>void 0===e||"string"==typeof e},user:{defaultValue:()=>({}),message:"should be an object with { id, email, name } properties",validate:e=>null===e||e&&s(a(e),((e,t)=>e&&i(["id","email","name"],t)),!0)},metadata:{defaultValue:()=>({}),message:"should be an object",validate:e=>"object"==typeof e&&null!==e},logger:{defaultValue:()=>{},message:"should be null or an object with methods { debug, info, warn, error }",validate:e=>!e||e&&s(["debug","info","warn","error"],((t,r)=>t&&"function"==typeof e[r]),!0)},redactedKeys:{defaultValue:()=>["password"],message:"should be an array of strings|regexes",validate:e=>o(e)&&e.length===n(e,(e=>"string"==typeof e||e&&"function"==typeof e.test)).length},plugins:{defaultValue:()=>[],message:"should be an array of plugin objects",validate:e=>o(e)&&e.length===n(e,(e=>e&&"object"==typeof e&&"function"==typeof e.load)).length},featureFlags:{defaultValue:()=>[],message:'should be an array of objects that have a "name" property',validate:e=>o(e)&&e.length===n(e,(e=>e&&"object"==typeof e&&"string"==typeof e.name)).length},reportUnhandledPromiseRejectionsAsHandled:{defaultValue:()=>!1,message:"should be true|false",validate:e=>!0===e||!1===e},sendPayloadChecksums:{defaultValue:()=>!1,message:"should be true|false",validate:e=>!0===e||!1===e}}},717:(e,t,r)=>{const n=r(480),s=r(14),a=r(744),o=r(628),i=r(850),c=r(978),l=r(465),u=r(670),d=r(472),h=r(43);class g{constructor(e,t,r=[],n=m(),s){this.apiKey=void 0,this.context=void 0,this.groupingHash=void 0,this.originalError=s,this._handledState=n,this.severity=this._handledState.severity,this.unhandled=this._handledState.unhandled,this.app={},this.device={},this.request={},this.breadcrumbs=[],this.threads=[],this._metadata={},this._features=[],this._featuresIndex={},this._user={},this._session=void 0,this._correlation=void 0,this.errors=[b(e,t,g.__type,r)]}addMetadata(e,t,r){return u.add(this._metadata,e,t,r)}setTraceCorrelation(e,t){"string"==typeof e&&(this._correlation={traceId:e,..."string"==typeof t?{spanId:t}:{}})}getMetadata(e,t){return u.get(this._metadata,e,t)}clearMetadata(e,t){return u.clear(this._metadata,e,t)}addFeatureFlag(e,t=null){d.add(this._features,this._featuresIndex,e,t)}addFeatureFlags(e){d.merge(this._features,e,this._featuresIndex)}getFeatureFlags(){return d.toEventApi(this._features)}clearFeatureFlag(e){d.clear(this._features,this._featuresIndex,e)}clearFeatureFlags(){this._features=[],this._featuresIndex={}}getUser(){return this._user}setUser(e,t,r){this._user={id:e,email:t,name:r}}toJSON(){return{payloadVersion:"4",exceptions:o(this.errors,(e=>l({},e,{message:e.errorMessage}))),severity:this.severity,unhandled:this._handledState.unhandled,severityReason:this._handledState.severityReason,app:this.app,device:this.device,request:this.request,breadcrumbs:this.breadcrumbs,context:this.context,groupingHash:this.groupingHash,metaData:this._metadata,user:this._user,session:this._session,featureFlags:this.getFeatureFlags(),correlation:this._correlation}}}const f=e=>{const t={file:e.fileName,method:p(e.functionName),lineNumber:e.lineNumber,columnNumber:e.columnNumber,code:void 0,inProject:void 0};return t.lineNumber>-1&&!t.file&&!t.method&&(t.file="global code"),t},p=e=>/^global code$/i.test(e)?"global code":e,m=()=>({unhandled:!1,severity:"warning",severityReason:{type:"handledException"}}),y=e=>"string"==typeof e?e:"";function b(e,t,r,n){return{errorClass:y(e),errorMessage:y(t),type:r,stacktrace:i(n,((e,t)=>{const r=f(t);try{return"{}"===JSON.stringify(r)?e:e.concat(r)}catch(t){return e}}),[])}}function _(e){return e.cause?[e,..._(e.cause)]:[e]}g.getStacktrace=function(e,t,r){if(a(e))return n.parse(e).slice(t);try{return c(s.backtrace(),(e=>-1===(e.functionName||"").indexOf("StackGenerator$$"))).slice(1+r)}catch(e){return[]}},g.create=function(e,t,r,s,i=0,c){const[l,u]=S(e,t,s,c);let d;try{const t=g.getStacktrace(l,u>0?1+u+i:0,1+i);d=new g(l.name,l.message,t,r,e)}catch(t){d=new g(l.name,l.message,[],r,e)}if("InvalidError"===l.name&&d.addMetadata(`${s}`,"non-error parameter",v(e)),l.cause){const e=_(l).slice(1),t=o(e,(e=>{const t=h(e)&&a(e)?n.parse(e):[],[r]=S(e,!0,"error cause");return"InvalidError"===r.name&&d.addMetadata("error cause",v(e)),b(r.name,r.message,g.__type,t)}));d.errors.push(...t)}return d};const v=e=>null===e?"null":void 0===e?"undefined":e,S=(e,t,r,n)=>{let s,o=0;const i=e=>{const t="error cause"===r?"was":"received";n&&n.warn(`${r} ${t} a non-error: "${e}"`);const s=new Error(`${r} ${t} a non-error. See "${r}" tab for more detail.`);return s.name="InvalidError",s};if(t)switch(typeof e){case"string":case"number":case"boolean":s=new Error(String(e)),o+=1;break;case"function":s=i("function"),o+=2;break;case"object":null!==e&&h(e)?s=e:null!==e&&x(e)?(s=new Error(e.message||e.errorMessage),s.name=e.name||e.errorClass,o+=1):(s=i(null===e?"null":"unsupported object"),o+=2);break;default:s=i("nothing"),o+=2}else h(e)?s=e:(s=i(typeof e),o+=2);if(!a(s))try{throw s}catch(e){a(e)&&(s=e,o=1)}return[s,o]};g.__type="browserjs";const x=e=>!("string"!=typeof e.name&&"string"!=typeof e.errorClass||"string"!=typeof e.message&&"string"!=typeof e.errorMessage);e.exports=g},179:e=>{e.exports=(e,t,r)=>{let n=0;const s=()=>{if(n>=e.length)return r(null,!0);t(e[n],((e,t)=>e?r(e):!1===t?r(null,!1):(n++,void s())))};s()}},496:e=>{e.exports=["navigation","request","process","log","user","state","error","manual"]},969:(e,t,r)=>{const n=r(179);e.exports=(e,t,r,s)=>{n(e,((e,n)=>{if("function"!=typeof e)return n(null);try{if(2!==e.length){const s=e(t);return s&&"function"==typeof s.then?s.then((e=>setTimeout((()=>n(null,e)))),(e=>{setTimeout((()=>(r(e),n(null,!0))))})):n(null,s)}e(t,((e,t)=>{if(e)return r(e),n(null);n(null,t)}))}catch(e){r(e),n(null)}}),s)}},480:(e,t,r)=>{e.exports=r(482)},465:e=>{e.exports=function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}},978:(e,t,r)=>{const n=r(850);e.exports=(e,t)=>n(e,((e,r,n,s)=>t(r,n,s)?e.concat(r):e),[])},957:(e,t,r)=>{const n=r(850);e.exports=(e,t)=>n(e,((e,r,n,s)=>!0===e||r===t),!1)},424:e=>{e.exports=e=>"[object Array]"===Object.prototype.toString.call(e)},188:e=>{const t=!{toString:null}.propertyIsEnumerable("toString"),r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"];e.exports=e=>{const n=[];let s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&n.push(s);if(!t)return n;for(let t=0,s=r.length;t<s;t++)Object.prototype.hasOwnProperty.call(e,r[t])&&n.push(r[t]);return n}},628:(e,t,r)=>{const n=r(850);e.exports=(e,t)=>n(e,((e,r,n,s)=>e.concat(t(r,n,s))),[])},850:e=>{e.exports=(e,t,r)=>{let n=r;for(let r=0,s=e.length;r<s;r++)n=t(n,e[r],r,e);return n}},472:(e,t,r)=>{const n=r(628),s=r(978),a=r(424),o=r(876);function i(e,t,r,n){if("string"!=typeof r)return;void 0===n?n=null:null!==n&&"string"!=typeof n&&(n=o(n));const s=t[r];"number"!=typeof s?(e.push({name:r,variant:n}),t[r]=e.length-1):e[s]={name:r,variant:n}}e.exports={add:i,clear:function(e,t,r){const n=t[r];"number"==typeof n&&(e[n]=null,delete t[r])},merge:function(e,t,r){if(a(t)){for(let n=0;n<t.length;++n){const s=t[n];null!==s&&"object"==typeof s&&i(e,r,s.name,s.variant)}return e}},toEventApi:function(e){return n(s(e,Boolean),(({name:e,variant:t})=>{const r={featureFlag:e};return"string"==typeof t&&(r.variant=t),r}))}}},744:e=>{e.exports=e=>!(!e||!e.stack&&!e.stacktrace&&!e["opera#sourceloc"]||"string"!=typeof(e.stack||e.stacktrace||e["opera#sourceloc"])||e.stack===`${e.name}: ${e.message}`)},43:(e,t,r)=>{e.exports=r(468)},68:(e,t,r)=>{const n=r(876),s=["events.[].metaData","events.[].breadcrumbs.[].metaData","events.[].request"];e.exports.event=(e,t)=>{let r=n(e,null,null,{redactedPaths:s,redactedKeys:t});return r.length>1e6&&(e.events[0]._metadata={notifier:`WARNING!\nSerialized payload was ${r.length/1e6}MB (limit = 1MB)\nmetadata was removed`},r=n(e,null,null,{redactedPaths:s,redactedKeys:t})),r},e.exports.session=(e,t)=>n(e,null,null)},670:(e,t,r)=>{const n=r(465),s=(e,t,r)=>{"string"==typeof t&&(r?"__proto__"!==t&&"constructor"!==t&&"prototype"!==t&&e[t]&&delete e[t][r]:delete e[t])};e.exports={add:(e,t,r,a)=>{if(!t)return;let o;if(null===r)return s(e,t);"object"==typeof r&&(o=r),"string"==typeof r&&(o={[r]:a}),o&&"__proto__"!==t&&"constructor"!==t&&"prototype"!==t&&(e[t]||(e[t]={}),e[t]=n({},e[t],o))},get:(e,t,r)=>{if("string"==typeof t)return r?e[t]?e[t][r]:void 0:e[t]},clear:s}},171:e=>{e.exports=(e,t,r,n)=>{let s=!1;const a=e.slice();for(;!s&&a.length;)try{s=!1===a.pop()(t)}catch(e){n.error(`Error occurred in ${r} callback, continuing anyway…`),n.error(e)}return s}},960:e=>{e.exports=(e=1,t=1/0)=>r=>"number"==typeof r&&parseInt(""+r,10)===r&&r>=e&&r<=t},483:(e,t,r)=>{const n=r(978),s=r(424);e.exports=e=>"function"==typeof e||s(e)&&n(e,(e=>"function"==typeof e)).length===e.length},142:e=>{e.exports=e=>"string"==typeof e&&!!e.length},669:(e,t,r)=>{const n=r(99);e.exports=class{constructor(){this.id=n(),this.startedAt=new Date,this._handled=0,this._unhandled=0,this._user={},this.app={},this.device={}}getUser(){return this._user}setUser(e,t,r){this._user={id:e,email:t,name:r}}toJSON(){return{id:this.id,startedAt:this.startedAt,events:{handled:this._handled,unhandled:this._unhandled}}}_track(e){this[e._handledState.unhandled?"_unhandled":"_handled"]+=1}}},999:(e,t,r)=>{const n=r(465),s="bugsnag-anonymous-id";e.exports=(e=navigator,t=window)=>({load:o=>{const i={locale:e.browserLanguage||e.systemLanguage||e.userLanguage||e.language,userAgent:e.userAgent};t&&t.screen&&t.screen.orientation&&t.screen.orientation.type?i.orientation=t.screen.orientation.type:t&&t.document&&(i.orientation=t.document.documentElement.clientWidth>t.document.documentElement.clientHeight?"landscape":"portrait"),o._config.generateAnonymousId&&(i.id=(e=>{try{const t=e.localStorage;let n=t.getItem(s);return n&&/^c[a-z0-9]{20,32}$/.test(n)||(n=r(99)(),t.setItem(s,n)),n}catch(e){}})(t)),o.addOnSession((e=>{e.device=n({},e.device,i),o._config.collectUserIp||a(e)})),o.addOnError((e=>{e.device=n({},e.device,i,{time:new Date}),o._config.collectUserIp||a(e)}),!0)},configSchema:{generateAnonymousId:{validate:e=>!0===e||!1===e,defaultValue:()=>!0,message:"should be true|false"}}});const a=e=>{const t=e.getUser();t&&t.id||e.setUser(e.device.id)}},473:(e,t,r)=>{const n=r(957);e.exports={load:e=>{e._sessionDelegate=s}};const s={startSession:(e,t)=>{const r=e;return r._session=t,r._pausedSession=null,null===r._config.enabledReleaseStages||n(r._config.enabledReleaseStages,r._config.releaseStage)?(r._delivery.sendSession({notifier:r._notifier,device:t.device,app:t.app,sessions:[{id:t.id,startedAt:t.startedAt,user:t._user}]}),r):(r._logger.warn("Session not sent due to releaseStage/enabledReleaseStages configuration"),r)},resumeSession:e=>e._session?e:e._pausedSession?(e._session=e._pausedSession,e._pausedSession=null,e):e.startSession(),pauseSession:e=>{e._pausedSession=e._session,e._session=null}}},500:(e,t,r)=>{const n=r(465);e.exports={load:e=>{e._config.collectUserIp||e.addOnError((e=>{e._user&&void 0===e._user.id&&delete e._user.id,e._user=n({id:"[REDACTED]"},e._user),e.request=n({clientIp:"[REDACTED]"},e.request)}))},configSchema:{collectUserIp:{defaultValue:()=>!0,message:"should be true|false",validate:e=>!0===e||!1===e}}}},665:e=>{e.exports=(e=window,r="window onerror")=>({load:n=>{if(!n._config.autoDetectErrors)return;if(!n._config.enabledErrorTypes.unhandledExceptions)return;const s=e.onerror;e.onerror=function(e,a,o,i,c){if(0===o&&/Script error\.?/.test(e))n._logger.warn("Ignoring cross-domain or eval script error. See docs: https://tinyurl.com/yy3rn63z");else{const s={severity:"error",unhandled:!0,severityReason:{type:"unhandledException"}};let l;if(c)l=n.Event.create(c,!0,s,r,1),t(l.errors[0].stacktrace,a,o,i);else if("object"!=typeof e||null===e||a&&"string"==typeof a||o||i||c)l=n.Event.create(e,!0,s,r,1),t(l.errors[0].stacktrace,a,o,i);else{const t=e.type?`Event: ${e.type}`:"Error",o=e.message||e.detail||"";l=n.Event.create({name:t,message:o},!0,s,r,1),l.originalError=e,l.addMetadata(r,{event:e,extraParameters:a})}n._notify(l)}"function"==typeof s&&s.apply(this,arguments)}}});const t=(e,t,n,s)=>{e[0]||e.push({});const a=e[0];a.file||"string"!=typeof t||(a.file=t),!a.lineNumber&&r(n)&&(a.lineNumber=n),a.columnNumber||(r(s)?a.columnNumber=s:window.event&&r(window.event.errorCharacter)&&(a.columnNumber=window.event.errorCharacter))},r=e=>"number"==typeof e&&"NaN"!==String.call(e)},309:(e,t,r)=>{const n=r(628),s=r(43);let a;e.exports=(e=window)=>({load:t=>{if(!t._config.autoDetectErrors||!t._config.enabledErrorTypes.unhandledRejections)return;const r=e=>{let r=e.reason,a=!1;try{e.detail&&e.detail.reason&&(r=e.detail.reason,a=!0)}catch(e){}const i=!t._config.reportUnhandledPromiseRejectionsAsHandled,c=t.Event.create(r,!1,{severity:"error",unhandled:i,severityReason:{type:"unhandledPromiseRejection"}},"unhandledrejection handler",1,t._logger);a&&n(c.errors[0].stacktrace,o(r)),t._notify(c,(e=>{s(e.originalError)&&!e.originalError.stack&&e.addMetadata("unhandledRejection handler",{[Object.prototype.toString.call(e.originalError)]:{name:e.originalError.name,message:e.originalError.message,code:e.originalError.code}})}))};"addEventListener"in e?e.addEventListener("unhandledrejection",r):e.onunhandledrejection=(e,t)=>{r({detail:{reason:e,promise:t}})},a=r}});const o=e=>t=>{t.file!==e.toString()&&t.method&&(t.method=t.method.replace(/^\s+/,""))}},384:(e,t,r)=>{const{schema:n}=r(223),s=r(628),a=r(465);e.exports={appType:{...n.appType,defaultValue:()=>"workerjs"},logger:a({},n.logger,{defaultValue:()=>"undefined"!=typeof console&&"function"==typeof console.debug?o():void 0}),autoTrackSessions:{...n.autoTrackSessions,defaultValue:()=>!1},autoDetectErrors:{...n.autoTrackSessions,defaultValue:()=>!1}};const o=()=>{const e={},t=console.log;return s(["debug","info","warn","error"],(r=>{const n=console[r];e[r]="function"==typeof n?n.bind(console,"[bugsnag]"):t.bind(console,"[bugsnag]")})),e}},737:e=>{const t=/^(chrome|moz|safari|safari-web)-extension:/;e.exports={name:"preventDiscard",load:e=>{e.addOnError((e=>{e.errors.forEach((({stacktrace:e})=>{e.forEach((function(e){e.file=e.file.replace(t,"$1_extension:")}))}))}),!0)}}}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n={};return(()=>{"use strict";r.d(n,{default:()=>w});var e=r(478),t=r.n(e),s=r(223),a=r(68);function o(e,t,r,n){if(e&&t.isSecureContext&&t.crypto&&t.crypto.subtle&&t.crypto.subtle.digest&&"function"==typeof TextEncoder){const e=(new TextEncoder).encode(r);return t.crypto.subtle.digest("SHA-1",e).then((e=>"sha1 "+Array.from(new Uint8Array(e)).map((e=>e.toString(16).padStart(2,"0"))).join("")))}return Promise.resolve()}var i=r(500),c=r.n(i),l=r(665),u=r.n(l),d=r(309),h=r.n(d),g=r(384),f=r.n(g),p=r(999),m=r.n(p),y=r(473),b=r.n(y),_=r(737),v=r.n(_);const S={...s.schema,...f()},x={createClient:e=>{"string"==typeof e&&(e={apiKey:e}),e||(e={});const n=[m()(navigator,null),b(),c(),v(),u()(self,"worker onerror"),h()(self)],s=new(t())(e,S,n,{name:"Bugsnag Web Worker",version:"8.4.0",url:"https://github.com/bugsnag/bugsnag-js"});return s._setDelivery((e=>((e,t=r.g.fetch,n=window)=>({sendEvent:(r,s=()=>{})=>{const i=e._config.endpoints.notify,c=a.event(r,e._config.redactedKeys);o(e._config.sendPayloadChecksums,n,c).then((n=>{const s={"Content-Type":"application/json","Bugsnag-Api-Key":r.apiKey||e._config.apiKey,"Bugsnag-Payload-Version":"4","Bugsnag-Sent-At":(new Date).toISOString()};return n&&(s["Bugsnag-Integrity"]=n),t(i,{method:"POST",headers:s,body:c})})).then((()=>{s(null)})).catch((t=>{e._logger.error(t),s(t)}))},sendSession:(r,s=()=>{})=>{const i=e._config.endpoints.sessions,c=a.session(r,e._config.redactedKeys);o(e._config.sendPayloadChecksums,n,c).then((r=>{const n={"Content-Type":"application/json","Bugsnag-Api-Key":e._config.apiKey,"Bugsnag-Payload-Version":"1","Bugsnag-Sent-At":(new Date).toISOString()};return r&&(n["Bugsnag-Integrity"]=r),t(i,{method:"POST",headers:n,body:c})})).then((()=>{s(null)})).catch((t=>{e._logger.error(t),s(t)}))}}))(e,void 0,self))),s._logger.debug("Loaded!"),s._config.autoTrackSessions?s.startSession():s},start:e=>x._client?(x._client._logger.warn("Bugsnag.start() was called more than once. Ignoring."),x._client):(x._client=x.createClient(e),x._client),isStarted:()=>null!=x._client};Object.getOwnPropertyNames(t().prototype).forEach((e=>{/^_/.test(e)||"constructor"===e||(x[e]=function(){if(!x._client)return console.log(`Bugsnag.${e}() was called before Bugsnag.start()`);x._client._depth+=1;const t=x._client[e].apply(x._client,arguments);return x._client._depth-=1,t})}));const w=x})(),n.default})()));
//# sourceMappingURL=bugsnag.web-worker.min.js.map