@sailfish-ai/sf-veritas 0.1.35 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/funcSpanTransformer-CTddGtUV.cjs +1 -0
  2. package/dist/funcSpanTransformer-coYDqcrs.js +136 -0
  3. package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -0
  4. package/dist/plugins/funcspanEsbuildPlugin.mjs +21 -0
  5. package/dist/plugins/funcspanRollupPlugin.cjs +1 -0
  6. package/dist/plugins/funcspanRollupPlugin.mjs +18 -0
  7. package/dist/plugins/funcspanTscPlugin.cjs +1 -0
  8. package/dist/plugins/funcspanTscPlugin.mjs +39 -0
  9. package/dist/plugins/funcspanVitePlugin.cjs +1 -0
  10. package/dist/plugins/funcspanVitePlugin.mjs +17 -0
  11. package/dist/plugins/funcspanWebpackLoader.cjs +1 -0
  12. package/dist/plugins/funcspanWebpackLoader.mjs +15 -0
  13. package/dist/plugins/funcspanWebpackPlugin.cjs +1 -0
  14. package/dist/plugins/funcspanWebpackPlugin.mjs +28 -0
  15. package/dist/sf-veritas.cjs +38 -20
  16. package/dist/sf-veritas.mjs +850 -1239
  17. package/dist/source-map-Cr6YkjTd.js +631 -0
  18. package/dist/source-map-rHHEdpre.cjs +1 -0
  19. package/dist/types/baseTransmitter.d.ts +2 -1
  20. package/dist/types/contextManager.d.ts +23 -0
  21. package/dist/types/exceptionTransmitter.d.ts +1 -1
  22. package/dist/types/funcSpanCapture.d.ts +24 -0
  23. package/dist/types/funcSpanConfig.d.ts +80 -0
  24. package/dist/types/funcSpanConfigLoader.d.ts +70 -0
  25. package/dist/types/index.d.ts +4 -1
  26. package/dist/types/networkRequestTransmitter.d.ts +1 -0
  27. package/dist/types/plugins/funcSpanTransformer.d.ts +31 -0
  28. package/dist/types/plugins/funcspanEsbuildPlugin.d.ts +28 -0
  29. package/dist/types/plugins/funcspanRollupPlugin.d.ts +28 -0
  30. package/dist/types/plugins/funcspanTscPlugin.d.ts +35 -0
  31. package/dist/types/plugins/funcspanVitePlugin.d.ts +27 -0
  32. package/dist/types/plugins/funcspanWebpackLoader.d.ts +1 -0
  33. package/dist/types/plugins/funcspanWebpackPlugin.d.ts +32 -0
  34. package/package.json +49 -3
@@ -1,4 +1,4 @@
1
- "use strict";var xe=Object.defineProperty;var ze=(i,t,s)=>t in i?xe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var y=(i,t,s)=>ze(i,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ue=require("async_hooks"),Fe=require("fs"),ke=require("worker_threads"),G=[];for(let i=0;i<256;++i)G.push((i+256).toString(16).slice(1));let ne;const $e=new Uint8Array(16),Ie={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function T(i,t,s){if(Ie.randomUUID&&!i)return Ie.randomUUID();const l=(i=i||{}).random??i.rng?.()??(function(){if(!ne){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ne=crypto.getRandomValues.bind(crypto)}return ne($e)})();if(l.length<16)throw new Error("Random bytes length must be >= 16");return l[6]=15&l[6]|64,l[8]=63&l[8]|128,(function(a,n=0){return(G[a[n+0]]+G[a[n+1]]+G[a[n+2]]+G[a[n+3]]+"-"+G[a[n+4]]+G[a[n+5]]+"-"+G[a[n+6]]+G[a[n+7]]+"-"+G[a[n+8]]+G[a[n+9]]+"-"+G[a[n+10]]+G[a[n+11]]+G[a[n+12]]+G[a[n+13]]+G[a[n+14]]+G[a[n+15]]).toLowerCase()})(l)}class Pe{constructor(t){y(this,"apiKey");y(this,"apiGraphqlEndpoint");y(this,"sfDebug");y(this,"serviceIdentifier");y(this,"serviceVersion");y(this,"serviceUUID");y(this,"serviceAdditionalMetadata");y(this,"profilingModeEnabled");y(this,"profilingMaxDepth");y(this,"profilingMaxVariableSizeKb");y(this,"domainsToNotPropagateHeadersTo");y(this,"nodeModulesToCollectLocalVariablesOn");y(this,"printConfigurationStatuses");y(this,"logLevel");y(this,"stackDepthLocals");y(this,"stackDepthCodeTraceDepth");y(this,"packageLibraryType");y(this,"version");y(this,"gitSha");y(this,"_serviceIdentificationReceived",!1);this.apiKey=t.apiKey,this.apiGraphqlEndpoint=t?.apiGraphqlEndpoint||process.env.SAILFISH_GRAPHQL_ENDPOINT||"https://api-service.sailfishqa.com/graphql/",this.sfDebug=t?.debug===!0||process.env.SF_DEBUG==="true",this.serviceIdentifier=t?.serviceIdentifier||process.env.SERVICE_IDENTIFIER,this.serviceUUID=T(),this.serviceVersion=t?.serviceVersion||process.env.SERVICE_VERSION,this.gitSha=t?.gitSha||process.env.GIT_SHA||process.env.VERCEL_GIT_COMMIT_SHA,this.serviceAdditionalMetadata=t?.serviceAdditionalMetadata||{},this.profilingModeEnabled=t?.profilingModeEnabled??!1,this.profilingMaxDepth=t?.profilingMaxDepth??5,this.profilingMaxVariableSizeKb=t?.profilingMaxVariableSizeKb??25,this.domainsToNotPropagateHeadersTo=t?.domainsToNotPropagateHeadersTo||[],this.nodeModulesToCollectLocalVariablesOn=t?.nodeModulesToCollectLocalVariablesOn||["_all_"],this.printConfigurationStatuses=process.env.PRINT_CONFIGURATION_STATUSES||"true",this.logLevel=process.env.LOG_LEVEL||"INFO",this.stackDepthLocals=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS,10):5,isNaN(this.stackDepthLocals)&&(this.stackDepthLocals=-1),this.stackDepthCodeTraceDepth=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH,10):-1,isNaN(this.stackDepthCodeTraceDepth)&&(this.stackDepthCodeTraceDepth=-1),this.packageLibraryType="JS/TS BACKEND",this.version=this.getPackageVersion()}getPackageVersion(){return"0.1.15"}get serviceIdentificationReceived(){return this._serviceIdentificationReceived}setServiceIdentificationReceived(t){this._serviceIdentificationReceived=t}}const Ke=Symbol.for("sailfish.sf_config");function Xe(){return globalThis[Ke]}function je(i){const t=Xe();if(t)return{config:t};const s=new Pe(i);return(function(l){globalThis[Ke]=l})(s),s.sfDebug&&console.log("[[getOrCreateConfig]] Created global config:",s),{config:s}}function A(){const i=Xe();if(!i)throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");return i}const pe=Symbol.for("sf.ctx.storeAls"),_=globalThis,te=_[pe]??(_[pe]=new Ue.AsyncLocalStorage),Te=["identitytoolkit.googleapis.com","t.co","*.twitter.com","*.gravatar.com","*.googleapis.com","*.amazonaws.com","*.smooch.io","*.zendesk.com"],he=Symbol.for("sf.ctx.als"),X=_[he]??(_[he]=new Ue.AsyncLocalStorage),Ce=Symbol.for("sf.ctx.sessionRegistry"),U=_[Ce]??(_[Ce]=new Map),z={handledExceptions:new Set,reentrancyGuardLoggingActive:!1,reentrancyGuardLoggingPreActive:!1,reentrancyGuardPrintActive:!1,reentrancyGuardPrintPreActive:!1,reentrancyGuardExceptionActive:!1,reentrancyGuardExceptionPreActive:!1,excludedDomains:new Set(Te),supportedDomains:new Set},L=class L{constructor(){}current(){return te.getStore()}ensureStore(){const t=this.current();if(t)return t;const s=new Map;return te.enterWith(s),s}runWith(t,s){const l=this.current()??new Map,a=new Map(l);for(const[n,o]of Object.entries(t))a.set(n,o);return te.run(a,s)}static getInstance(){return _[L.GLOBAL_MANAGER_SYMBOL]||(_[L.GLOBAL_MANAGER_SYMBOL]=new L),_[L.GLOBAL_MANAGER_SYMBOL]}getCurrentContext(){return X.getStore()||z}setCurrentContext(t){const s=X.getStore()||z;X.enterWith({...s,...t})}ensureSession(t){let s=U.get(t);return s||(s={...z},U.set(t,s)),s}getContextFor(t){return U.get(t)??z}updateContextFor(t,s){const l=this.ensureSession(t);U.set(t,{...l,...s})}runWithSession(t,s){const l={...this.ensureSession(t)};return X.run(l,s)}deleteSession(t){U.delete(t)}getTraceId(){return this.getCurrentContext().traceId}getPageVisitUUID(){return this.getCurrentContext().pageVisitUUID}setTraceId(t){this.setCurrentContext({traceId:t})}setPageVisitUUID(t){this.setCurrentContext({pageVisitUUID:t})}getOrSetSfTraceId(t,s=!1){let l=this.getTraceId();return l||(l=t||(s?T():`nonsession-applogs-v3/${A().apiKey}/${T()}`),this.setTraceId(l),A().sfDebug&&console.log(" Created new trace ID:",l),l)}getOrSetPageVisitUUID(){let t=this.getPageVisitUUID();return t||(t=T(),this.setPageVisitUUID(t),A().sfDebug&&console.log(" Created new page visit UUID:",t),t)}getHandledExceptions(){return this.getCurrentContext().handledExceptions}markExceptionHandled(t){const s=this.getHandledExceptions();s.add(t),this.setCurrentContext({handledExceptions:s})}hasHandledException(t){return this.getHandledExceptions().has(t)}resetHandledExceptions(){this.setCurrentContext({handledExceptions:new Set})}getExcludedDomains(){return this.getCurrentContext().excludedDomains}getSupportedDomains(){return this.getCurrentContext().supportedDomains}addSupportedDomains(t){this.getCurrentContext().supportedDomains.add(t.toLowerCase().trim())}setTraceIdFor(t,s){this.updateContextFor(t,{traceId:s})}setPageVisitUUIDFor(t,s){this.updateContextFor(t,{pageVisitUUID:s})}};y(L,"GLOBAL_MANAGER_SYMBOL",Symbol.for("sf.ctx.manager"));let w=L;class E{constructor(){y(this,"apiKey");y(this,"endpoint");y(this,"queryType","mutation");y(this,"operationName","");y(this,"serviceUUID",A().serviceUUID);y(this,"contextManager");this.apiKey=A().apiKey,this.endpoint=A().apiGraphqlEndpoint,this.contextManager=w.getInstance()}get queryName(){return this.operationName?this.operationName.charAt(0).toLowerCase()+this.operationName.slice(1):""}getDefaultVariables(){const t=Date.now().toString(),s=this.contextManager.getOrSetSfTraceId();return{apiKey:this.apiKey,serviceUuid:this.serviceUUID,sessionId:s,timestampMs:t}}getVariables(t={}){return{...this.getDefaultVariables(),...t}}setOperationName(t){this.operationName=t}setEndpoint(t){this.endpoint=t}setServiceUUID(t){this.serviceUUID=t}}const Qe=fetch;async function H(i,t,s,l){try{const a=A();let n;try{n=JSON.stringify({query:s,variables:l,operationName:t})}catch{n=JSON.stringify({query:s,operationName:t})}Qe(i,{method:"POST",headers:{"Content-Type":"application/json"},body:n}).then(async o=>{if(!o.ok)return void(a.sfDebug&&console.error(`GraphQL request failed with status ${o.status} for ${t}`));const c=await o.json();c.errors?.length?(function(d,p,C){const g=d&&typeof d=="object"&&!Array.isArray(d)?Object.keys(d)[0]:void 0;console.error(g==="identifyServiceDetails"?`IdentifyServiceDetails NOT sent successfully for service: UUID=${C.serviceUUID}`:`GraphQL request failed with errors: ${JSON.stringify(p)} for operation key ${g}`)})(c.data,c.errors,a):a.sfDebug&&(function(d,p,C){const g=d&&typeof d=="object"&&!Array.isArray(d)?Object.keys(d)[0]:void 0,I=d[g]||!1;g==="identifyServiceDetails"&&(C.setServiceIdentificationReceived(I),A().sfDebug&&console.log(`IdentifyServiceDetails sent successfully for service: UUID=${C.serviceUUID}; serviceIdentificationReceived=${g==="identifyServiceDetails"?I:"N/A"}`))})(c.data,0,a)}).catch(o=>{a.sfDebug&&console.error("Fetch error:",o)})}catch(a){A().sfDebug&&console.error("Error sending data to GraphQL server:",a)}}class D extends E{constructor(){super(),this.setOperationName("IdentifyServiceDetails")}async doSend(t){if(!A().serviceIdentificationReceived)try{this.send()}catch(s){A().sfDebug&&console.error(" Error during service identification:",s)}}async send(){const t=`
1
+ "use strict";var We=Object.defineProperty;var Fe=(o,e,t)=>e in o?We(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var u=(o,e,t)=>Fe(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ne=require("async_hooks"),ie=require("fs"),fe=require("./source-map-rHHEdpre.cjs"),Ve=require("worker_threads"),we=require("path"),He=require("glob");function ye(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const k=ye(ie),v=ye(we),S=[];for(let o=0;o<256;++o)S.push((o+256).toString(16).slice(1));let O;const Re=new Uint8Array(16),se={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function H(o,e,t){if(se.randomUUID&&!o)return se.randomUUID();const i=(o=o||{}).random??o.rng?.()??(function(){if(!O){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");O=crypto.getRandomValues.bind(crypto)}return O(Re)})();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,(function(n,s=0){return(S[n[s+0]]+S[n[s+1]]+S[n[s+2]]+S[n[s+3]]+"-"+S[n[s+4]]+S[n[s+5]]+"-"+S[n[s+6]]+S[n[s+7]]+"-"+S[n[s+8]]+S[n[s+9]]+"-"+S[n[s+10]]+S[n[s+11]]+S[n[s+12]]+S[n[s+13]]+S[n[s+14]]+S[n[s+15]]).toLowerCase()})(i)}class Ye{constructor(e){u(this,"apiKey");u(this,"apiGraphqlEndpoint");u(this,"sfDebug");u(this,"serviceIdentifier");u(this,"serviceVersion");u(this,"serviceUUID");u(this,"serviceAdditionalMetadata");u(this,"profilingModeEnabled");u(this,"profilingMaxDepth");u(this,"profilingMaxVariableSizeKb");u(this,"domainsToNotPropagateHeadersTo");u(this,"nodeModulesToCollectLocalVariablesOn");u(this,"printConfigurationStatuses");u(this,"logLevel");u(this,"stackDepthLocals");u(this,"stackDepthCodeTraceDepth");u(this,"packageLibraryType");u(this,"version");u(this,"gitSha");u(this,"_serviceIdentificationReceived",!1);this.apiKey=e.apiKey,this.apiGraphqlEndpoint=e?.apiGraphqlEndpoint||process.env.SAILFISH_GRAPHQL_ENDPOINT||"https://api-service.sailfishqa.com/graphql/",this.sfDebug=e?.debug===!0||process.env.SF_DEBUG==="true",this.serviceIdentifier=e?.serviceIdentifier||process.env.SERVICE_IDENTIFIER,this.serviceUUID=H(),this.serviceVersion=e?.serviceVersion||process.env.SERVICE_VERSION,this.gitSha=e?.gitSha||process.env.GIT_SHA||process.env.VERCEL_GIT_COMMIT_SHA,this.serviceAdditionalMetadata=e?.serviceAdditionalMetadata||{},this.profilingModeEnabled=e?.profilingModeEnabled??!1,this.profilingMaxDepth=e?.profilingMaxDepth??5,this.profilingMaxVariableSizeKb=e?.profilingMaxVariableSizeKb??25,this.domainsToNotPropagateHeadersTo=e?.domainsToNotPropagateHeadersTo||[],this.nodeModulesToCollectLocalVariablesOn=e?.nodeModulesToCollectLocalVariablesOn||["_all_"],this.printConfigurationStatuses=process.env.PRINT_CONFIGURATION_STATUSES||"true",this.logLevel=process.env.LOG_LEVEL||"INFO",this.stackDepthLocals=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS,10):5,isNaN(this.stackDepthLocals)&&(this.stackDepthLocals=-1),this.stackDepthCodeTraceDepth=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH,10):-1,isNaN(this.stackDepthCodeTraceDepth)&&(this.stackDepthCodeTraceDepth=-1),this.packageLibraryType="JS/TS BACKEND",this.version=this.getPackageVersion()}getPackageVersion(){return"0.1.15"}get serviceIdentificationReceived(){return this._serviceIdentificationReceived}setServiceIdentificationReceived(e){this._serviceIdentificationReceived=e}}const Se=Symbol.for("sailfish.sf_config");function Ze(){return globalThis[Se]}function Ke(o){const e=Ze();if(e)return{config:e};const t=new Ye(o);return(function(i){globalThis[Se]=i})(t),t.sfDebug&&console.log("[[getOrCreateConfig]] Created global config:",t),{config:t}}function l(){const o=Ze();if(!o)throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");return o}const re=Symbol.for("sf.ctx.storeAls"),W=globalThis,P=W[re]??(W[re]=new ne.AsyncLocalStorage),Ge=["identitytoolkit.googleapis.com","t.co","*.twitter.com","*.gravatar.com","*.googleapis.com","*.amazonaws.com","*.smooch.io","*.zendesk.com"],ae=Symbol.for("sf.ctx.als"),U=W[ae]??(W[ae]=new ne.AsyncLocalStorage),ce=Symbol.for("sf.ctx.sessionRegistry"),Y=W[ce]??(W[ce]=new Map),_={handledExceptions:new Set,reentrancyGuardLoggingActive:!1,reentrancyGuardLoggingPreActive:!1,reentrancyGuardPrintActive:!1,reentrancyGuardPrintPreActive:!1,reentrancyGuardExceptionActive:!1,reentrancyGuardExceptionPreActive:!1,excludedDomains:new Set(Ge),supportedDomains:new Set},V=class V{constructor(){}current(){return P.getStore()}ensureStore(){const e=this.current();if(e)return e;const t=new Map;return P.enterWith(t),t}runWith(e,t){const i=this.current()??new Map,n=new Map(i);for(const[s,a]of Object.entries(e))n.set(s,a);return P.run(n,t)}static getInstance(){return W[V.GLOBAL_MANAGER_SYMBOL]||(W[V.GLOBAL_MANAGER_SYMBOL]=new V),W[V.GLOBAL_MANAGER_SYMBOL]}getCurrentContext(){return U.getStore()||_}setCurrentContext(e){const t=U.getStore()||_;U.enterWith({...t,...e})}ensureSession(e){let t=Y.get(e);return t||(t={..._},Y.set(e,t)),t}getContextFor(e){return Y.get(e)??_}updateContextFor(e,t){const i=this.ensureSession(e);Y.set(e,{...i,...t})}runWithSession(e,t){const i={...this.ensureSession(e)};return U.run(i,t)}deleteSession(e){Y.delete(e)}getTraceId(){return this.getCurrentContext().traceId}getPageVisitUUID(){return this.getCurrentContext().pageVisitUUID}setTraceId(e){this.setCurrentContext({traceId:e})}setPageVisitUUID(e){this.setCurrentContext({pageVisitUUID:e})}getCurrentFunctionSpanId(){return this.getCurrentContext().currentFunctionSpanId}setCurrentFunctionSpanId(e){this.setCurrentContext({currentFunctionSpanId:e})}clearCurrentFunctionSpanId(){this.setCurrentContext({currentFunctionSpanId:void 0})}getOrSetSfTraceId(e,t=!1){let i=this.getTraceId();return i||(i=e||(t?H():`nonsession-applogs-v3/${l().apiKey}/${H()}`),this.setTraceId(i),l().sfDebug&&console.log(" Created new trace ID:",i),i)}getOrSetPageVisitUUID(){let e=this.getPageVisitUUID();return e||(e=H(),this.setPageVisitUUID(e),l().sfDebug&&console.log(" Created new page visit UUID:",e),e)}getHandledExceptions(){return this.getCurrentContext().handledExceptions}markExceptionHandled(e){const t=this.getHandledExceptions();t.add(e),this.setCurrentContext({handledExceptions:t})}hasHandledException(e){return this.getHandledExceptions().has(e)}resetHandledExceptions(){this.setCurrentContext({handledExceptions:new Set})}getExcludedDomains(){return this.getCurrentContext().excludedDomains}getSupportedDomains(){return this.getCurrentContext().supportedDomains}addSupportedDomains(e){this.getCurrentContext().supportedDomains.add(e.toLowerCase().trim())}setTraceIdFor(e,t){this.updateContextFor(e,{traceId:t})}setPageVisitUUIDFor(e,t){this.updateContextFor(e,{pageVisitUUID:t})}};u(V,"GLOBAL_MANAGER_SYMBOL",Symbol.for("sf.ctx.manager"));let G=V;function ve(o){const e={...G.getInstance().getCurrentContext()};U.run(e,()=>{o()})}function L(){return G.getInstance().getCurrentFunctionSpanId()}class R{constructor(){u(this,"apiKey");u(this,"endpoint");u(this,"queryType","mutation");u(this,"operationName","");u(this,"serviceUUID",l().serviceUUID);u(this,"contextManager");this.apiKey=l().apiKey,this.endpoint=l().apiGraphqlEndpoint,this.contextManager=G.getInstance()}get queryName(){return this.operationName?this.operationName.charAt(0).toLowerCase()+this.operationName.slice(1):""}getDefaultVariables(){const e=Date.now().toString(),t=this.contextManager.getOrSetSfTraceId(),i=this.contextManager.getCurrentFunctionSpanId();return{apiKey:this.apiKey,serviceUuid:this.serviceUUID,sessionId:t,timestampMs:e,parentSpanId:i}}getVariables(e={}){return{...this.getDefaultVariables(),...e}}setOperationName(e){this.operationName=e}setEndpoint(e){this.endpoint=e}setServiceUUID(e){this.serviceUUID=e}}const Ue=fetch;async function F(o,e,t,i){try{const n=l();let s;try{s=JSON.stringify({query:t,variables:i,operationName:e})}catch{s=JSON.stringify({query:t,operationName:e})}Ue(o,{method:"POST",headers:{"Content-Type":"application/json"},body:s}).then(async a=>{if(!a.ok)return void(n.sfDebug&&console.error(`GraphQL request failed with status ${a.status} for ${e}`));const r=await a.json();r.errors?.length?(function(g,c,I){const d=g&&typeof g=="object"&&!Array.isArray(g)?Object.keys(g)[0]:void 0;console.error(d==="identifyServiceDetails"?`IdentifyServiceDetails NOT sent successfully for service: UUID=${I.serviceUUID}`:`GraphQL request failed with errors: ${JSON.stringify(c)} for operation key ${d}`)})(r.data,r.errors,n):n.sfDebug&&(function(g,c,I){const d=g&&typeof g=="object"&&!Array.isArray(g)?Object.keys(g)[0]:void 0,C=g[d]||!1;d==="identifyServiceDetails"&&(I.setServiceIdentificationReceived(C),l().sfDebug&&console.log(`IdentifyServiceDetails sent successfully for service: UUID=${I.serviceUUID}; serviceIdentificationReceived=${d==="identifyServiceDetails"?C:"N/A"}`))})(r.data,0,n)}).catch(a=>{n.sfDebug&&console.error("Fetch error:",a)})}catch(n){l().sfDebug&&console.error("Error sending data to GraphQL server:",n)}}class T extends R{constructor(){super(),this.setOperationName("IdentifyServiceDetails")}async doSend(e){if(!l().serviceIdentificationReceived)try{this.send()}catch(t){l().sfDebug&&console.error(" Error during service identification:",t)}}async send(){const e=`
2
2
  ${this.queryType} ${this.operationName}(
3
3
  $apiKey: String!,
4
4
  $timestampMs: String!,
@@ -22,19 +22,35 @@
22
22
  gitSha: $gitSha,
23
23
  )
24
24
  }
25
- `,s=this.getVariables({serviceIdentifier:A().serviceIdentifier,serviceVersion:A().serviceVersion,library:A().packageLibraryType,version:A().version,serviceAdditionalMetadata:A().serviceAdditionalMetadata,gitSha:A().gitSha||""});H(this.endpoint,this.operationName,t,s)}}function qe(i){try{return JSON.stringify(i),!0}catch{return!1}}class en extends E{constructor(){super();y(this,"serviceIdentifier",new D);this.setOperationName("CollectMetadata")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s,l,a,n){this.sendAppIdentifier(),this.send(s,l,a,n)}async send(s,l,a,n){if(!l&&!n)throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');let o=[];if(!n){const d=(function(p){const C={},g=[];if(p)for(const[I,e]of Object.entries(p))qe(e)?C[I]=e:g.push(I);return{traitsJson:JSON.stringify(C),excludedFields:g}})(l);n=d.traitsJson,o=d.excludedFields}const c=this.getVariables({userId:s,traitsJson:n,excludedFields:o,override:a,library:A().packageLibraryType,version:A().version});H(this.endpoint,this.operationName,this.getQuery(),c)}getQuery(){return`
25
+ `,t=this.getVariables({serviceIdentifier:l().serviceIdentifier,serviceVersion:l().serviceVersion,library:l().packageLibraryType,version:l().version,serviceAdditionalMetadata:l().serviceAdditionalMetadata,gitSha:l().gitSha||""});F(this.endpoint,this.operationName,e,t)}}function Xe(o){try{return JSON.stringify(o),!0}catch{return!1}}class Je extends R{constructor(){super();u(this,"serviceIdentifier",new T);this.setOperationName("CollectMetadata")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(t,i,n,s){this.sendAppIdentifier(),this.send(t,i,n,s)}async send(t,i,n,s){if(!i&&!s)throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');let a=[];if(!s){const g=(function(c){const I={},d=[];if(c)for(const[C,p]of Object.entries(c))Xe(p)?I[C]=p:d.push(C);return{traitsJson:JSON.stringify(I),excludedFields:d}})(i);s=g.traitsJson,a=g.excludedFields}const r=this.getVariables({userId:t,traitsJson:s,excludedFields:a,override:n,library:l().packageLibraryType,version:l().version});F(this.endpoint,this.operationName,this.getQuery(),r)}getQuery(){return`
26
26
  mutation ${this.operationName}($apiKey: String!, $serviceUuid: String!, $sessionId: String!, $userId: String!, $traitsJson: String!, $excludedFields: [String!]!, $library: String!, $timestampMs: String!, $version: String!, $override: Boolean!) {
27
27
  ${this.queryName}(apiKey: $apiKey, serviceUuid: $serviceUuid, sessionId: $sessionId, userId: $userId, traitsJson: $traitsJson, excludedFields: $excludedFields, library: $library, timestampMs: $timestampMs, version: $version, override: $override)
28
28
  }
29
- `}}class me{constructor(t){y(this,"metadataTransmitter");this.apiKey=t,this.metadataTransmitter=new en}identify(t,s,l,a=!1){s||l?this.addOrUpdateMetadata(t,s,l,a):this.addOrUpdateMetadata(t,{},void 0,a)}addOrUpdateMetadata(t,s={},l,a=!1){if(!s&&!l)throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');A().sfDebug&&console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"),A().sfDebug&&console.log(" addOrUpdateMetadata...SENDING DATA...",t,s,l),this.metadataTransmitter.doSend(t,s,a,l)}}class de extends E{constructor(){super();y(this,"serviceIdentifier",new D)}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s){this.sendAppIdentifier(),this.send(s)}async send(s){try{const l=Array.isArray(s)?s:[s,"default"],a=this.getVariables({contents:l[0],level:l[1]});H(this.endpoint,this.operationName,this.getQuery(),a)}catch(l){A().sfDebug&&console.error("🚨 Error in send():",l)}}getQuery(){return`
30
- ${this.queryType} ${this.operationName}($apiKey: String!, $serviceUuid: String!, $sessionId: String!, $timestampMs: String!, $level: String!, $contents: String!) {
31
- ${this.queryName}(apiKey: $apiKey, serviceUuid: $serviceUuid, sessionId: $sessionId, timestampMs: $timestampMs, level: $level, contents: $contents)
29
+ `}}class ge{constructor(e){u(this,"metadataTransmitter");this.apiKey=e,this.metadataTransmitter=new Je}identify(e,t,i,n=!1){t||i?this.addOrUpdateMetadata(e,t,i,n):this.addOrUpdateMetadata(e,{},void 0,n)}addOrUpdateMetadata(e,t={},i,n=!1){if(!t&&!i)throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');l().sfDebug&&console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"),l().sfDebug&&console.log(" addOrUpdateMetadata...SENDING DATA...",e,t,i),this.metadataTransmitter.doSend(e,t,n,i)}}class oe extends R{constructor(){super();u(this,"serviceIdentifier",new T)}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(t){this.sendAppIdentifier(),this.send(t)}async send(t){try{const i=Array.isArray(t)?t:[t,"default"],n=this.getVariables({contents:i[0],level:i[1]});F(this.endpoint,this.operationName,this.getQuery(),n)}catch(i){l().sfDebug&&console.error("🚨 Error in send():",i)}}getQuery(){return`
30
+ ${this.queryType} ${this.operationName}(
31
+ $apiKey: String!,
32
+ $serviceUuid: String!,
33
+ $sessionId: String!,
34
+ $timestampMs: String!,
35
+ $level: String!,
36
+ $contents: String!,
37
+ $parentSpanId: String
38
+ ) {
39
+ ${this.queryName}(
40
+ apiKey: $apiKey,
41
+ serviceUuid: $serviceUuid,
42
+ sessionId: $sessionId,
43
+ timestampMs: $timestampMs,
44
+ level: $level,
45
+ contents: $contents,
46
+ parentSpanId: $parentSpanId
47
+ )
32
48
  }
33
- `}}const N={};var Ae,fe,k={},re={},$={},P={};function nn(){if(Ae)return P;Ae=1;var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return P.encode=function(t){if(0<=t&&t<i.length)return i[t];throw new TypeError("Must be between 0 and 63: "+t)},P.decode=function(t){return 65<=t&&t<=90?t-65:97<=t&&t<=122?t-97+26:48<=t&&t<=57?t-48+52:t==43?62:t==47?63:-1},P}function Je(){if(fe)return $;fe=1;var i=nn();return $.encode=function(t){var s,l="",a=(function(n){return n<0?1+(-n<<1):0+(n<<1)})(t);do s=31&a,(a>>>=5)>0&&(s|=32),l+=i.encode(s);while(a>0);return l},$.decode=function(t,s,l){var a,n,o,c,d=t.length,p=0,C=0;do{if(s>=d)throw new Error("Expected more digits in base 64 VLQ value.");if((n=i.decode(t.charCodeAt(s++)))===-1)throw new Error("Invalid base64 digit: "+t.charAt(s-1));a=!!(32&n),p+=(n&=31)<<C,C+=5}while(a);l.value=(c=(o=p)>>1,1&~o?c:-c),l.rest=s},$}var be,ye={};function M(){return be||(be=1,(function(i){i.getArg=function(e,r,h){if(r in e)return e[r];if(arguments.length===3)return h;throw new Error('"'+r+'" is a required argument.')};var t=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,s=/^data:.+\,.+$/;function l(e){var r=e.match(t);return r?{scheme:r[1],auth:r[2],host:r[3],port:r[4],path:r[5]}:null}function a(e){var r="";return e.scheme&&(r+=e.scheme+":"),r+="//",e.auth&&(r+=e.auth+"@"),e.host&&(r+=e.host),e.port&&(r+=":"+e.port),e.path&&(r+=e.path),r}i.urlParse=l,i.urlGenerate=a;var n,o,c=(n=function(e){var r=e,h=l(e);if(h){if(!h.path)return e;r=h.path}for(var u=i.isAbsolute(r),m=[],f=0,b=0;;){if(f=b,(b=r.indexOf("/",f))===-1){m.push(r.slice(f));break}for(m.push(r.slice(f,b));b<r.length&&r[b]==="/";)b++}var v,S=0;for(b=m.length-1;b>=0;b--)(v=m[b])==="."?m.splice(b,1):v===".."?S++:S>0&&(v===""?(m.splice(b+1,S),S=0):(m.splice(b,2),S--));return(r=m.join("/"))===""&&(r=u?"/":"."),h?(h.path=r,a(h)):r},o=[],function(e){for(var r=0;r<o.length;r++)if(o[r].input===e){var h=o[0];return o[0]=o[r],o[r]=h,o[0].result}var u=n(e);return o.unshift({input:e,result:u}),o.length>32&&o.pop(),u});function d(e,r){e===""&&(e="."),r===""&&(r=".");var h=l(r),u=l(e);if(u&&(e=u.path||"/"),h&&!h.scheme)return u&&(h.scheme=u.scheme),a(h);if(h||r.match(s))return r;if(u&&!u.host&&!u.path)return u.host=r,a(u);var m=r.charAt(0)==="/"?r:c(e.replace(/\/+$/,"")+"/"+r);return u?(u.path=m,a(u)):m}i.normalize=c,i.join=d,i.isAbsolute=function(e){return e.charAt(0)==="/"||t.test(e)},i.relative=function(e,r){e===""&&(e="."),e=e.replace(/\/$/,"");for(var h=0;r.indexOf(e+"/")!==0;){var u=e.lastIndexOf("/");if(u<0||(e=e.slice(0,u)).match(/^([^\/]+:\/)?\/*$/))return r;++h}return Array(h+1).join("../")+r.substr(e.length+1)};var p=!("__proto__"in Object.create(null));function C(e){return e}function g(e){if(!e)return!1;var r=e.length;if(r<9||e.charCodeAt(r-1)!==95||e.charCodeAt(r-2)!==95||e.charCodeAt(r-3)!==111||e.charCodeAt(r-4)!==116||e.charCodeAt(r-5)!==111||e.charCodeAt(r-6)!==114||e.charCodeAt(r-7)!==112||e.charCodeAt(r-8)!==95||e.charCodeAt(r-9)!==95)return!1;for(var h=r-10;h>=0;h--)if(e.charCodeAt(h)!==36)return!1;return!0}function I(e,r){return e===r?0:e===null?1:r===null?-1:e>r?1:-1}i.toSetString=p?C:function(e){return g(e)?"$"+e:e},i.fromSetString=p?C:function(e){return g(e)?e.slice(1):e},i.compareByOriginalPositions=function(e,r,h){var u=I(e.source,r.source);return u!==0||(u=e.originalLine-r.originalLine)!==0||(u=e.originalColumn-r.originalColumn)!==0||h||(u=e.generatedColumn-r.generatedColumn)!==0||(u=e.generatedLine-r.generatedLine)!==0?u:I(e.name,r.name)},i.compareByOriginalPositionsNoSource=function(e,r,h){var u;return(u=e.originalLine-r.originalLine)!==0||(u=e.originalColumn-r.originalColumn)!==0||h||(u=e.generatedColumn-r.generatedColumn)!==0||(u=e.generatedLine-r.generatedLine)!==0?u:I(e.name,r.name)},i.compareByGeneratedPositionsDeflated=function(e,r,h){var u=e.generatedLine-r.generatedLine;return u!==0||(u=e.generatedColumn-r.generatedColumn)!==0||h||(u=I(e.source,r.source))!==0||(u=e.originalLine-r.originalLine)!==0||(u=e.originalColumn-r.originalColumn)!==0?u:I(e.name,r.name)},i.compareByGeneratedPositionsDeflatedNoLine=function(e,r,h){var u=e.generatedColumn-r.generatedColumn;return u!==0||h||(u=I(e.source,r.source))!==0||(u=e.originalLine-r.originalLine)!==0||(u=e.originalColumn-r.originalColumn)!==0?u:I(e.name,r.name)},i.compareByGeneratedPositionsInflated=function(e,r){var h=e.generatedLine-r.generatedLine;return h!==0||(h=e.generatedColumn-r.generatedColumn)!==0||(h=I(e.source,r.source))!==0||(h=e.originalLine-r.originalLine)!==0||(h=e.originalColumn-r.originalColumn)!==0?h:I(e.name,r.name)},i.parseSourceMapInput=function(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))},i.computeSourceURL=function(e,r,h){if(r=r||"",e&&(e[e.length-1]!=="/"&&r[0]!=="/"&&(e+="/"),r=e+r),h){var u=l(h);if(!u)throw new Error("sourceMapURL could not be parsed");if(u.path){var m=u.path.lastIndexOf("/");m>=0&&(u.path=u.path.substring(0,m+1))}r=d(a(u),r)}return c(r)}})(ye)),ye}var ve,oe={};function Me(){if(ve)return oe;ve=1;var i=M(),t=Object.prototype.hasOwnProperty,s=typeof Map<"u";function l(){this._array=[],this._set=s?new Map:Object.create(null)}return l.fromArray=function(a,n){for(var o=new l,c=0,d=a.length;c<d;c++)o.add(a[c],n);return o},l.prototype.size=function(){return s?this._set.size:Object.getOwnPropertyNames(this._set).length},l.prototype.add=function(a,n){var o=s?a:i.toSetString(a),c=s?this.has(a):t.call(this._set,o),d=this._array.length;c&&!n||this._array.push(a),c||(s?this._set.set(a,d):this._set[o]=d)},l.prototype.has=function(a){if(s)return this._set.has(a);var n=i.toSetString(a);return t.call(this._set,n)},l.prototype.indexOf=function(a){if(s){var n=this._set.get(a);if(n>=0)return n}else{var o=i.toSetString(a);if(t.call(this._set,o))return this._set[o]}throw new Error('"'+a+'" is not in the set.')},l.prototype.at=function(a){if(a>=0&&a<this._array.length)return this._array[a];throw new Error("No element indexed by "+a)},l.prototype.toArray=function(){return this._array.slice()},oe.ArraySet=l,oe}var Se,Ge,ie={};function tn(){if(Se)return ie;Se=1;var i=M();function t(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}return t.prototype.unsortedForEach=function(s,l){this._array.forEach(s,l)},t.prototype.add=function(s){var l,a,n,o,c,d;l=this._last,a=s,n=l.generatedLine,o=a.generatedLine,c=l.generatedColumn,d=a.generatedColumn,o>n||o==n&&d>=c||i.compareByGeneratedPositionsInflated(l,a)<=0?(this._last=s,this._array.push(s)):(this._sorted=!1,this._array.push(s))},t.prototype.toArray=function(){return this._sorted||(this._array.sort(i.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},ie.MappingList=t,ie}function Ze(){if(Ge)return re;Ge=1;var i=Je(),t=M(),s=Me().ArraySet,l=tn().MappingList;function a(n){n||(n={}),this._file=t.getArg(n,"file",null),this._sourceRoot=t.getArg(n,"sourceRoot",null),this._skipValidation=t.getArg(n,"skipValidation",!1),this._ignoreInvalidMapping=t.getArg(n,"ignoreInvalidMapping",!1),this._sources=new s,this._names=new s,this._mappings=new l,this._sourcesContents=null}return a.prototype._version=3,a.fromSourceMap=function(n,o){var c=n.sourceRoot,d=new a(Object.assign(o||{},{file:n.file,sourceRoot:c}));return n.eachMapping(function(p){var C={generated:{line:p.generatedLine,column:p.generatedColumn}};p.source!=null&&(C.source=p.source,c!=null&&(C.source=t.relative(c,C.source)),C.original={line:p.originalLine,column:p.originalColumn},p.name!=null&&(C.name=p.name)),d.addMapping(C)}),n.sources.forEach(function(p){var C=p;c!==null&&(C=t.relative(c,p)),d._sources.has(C)||d._sources.add(C);var g=n.sourceContentFor(p);g!=null&&d.setSourceContent(p,g)}),d},a.prototype.addMapping=function(n){var o=t.getArg(n,"generated"),c=t.getArg(n,"original",null),d=t.getArg(n,"source",null),p=t.getArg(n,"name",null);(this._skipValidation||this._validateMapping(o,c,d,p)!==!1)&&(d!=null&&(d=String(d),this._sources.has(d)||this._sources.add(d)),p!=null&&(p=String(p),this._names.has(p)||this._names.add(p)),this._mappings.add({generatedLine:o.line,generatedColumn:o.column,originalLine:c!=null&&c.line,originalColumn:c!=null&&c.column,source:d,name:p}))},a.prototype.setSourceContent=function(n,o){var c=n;this._sourceRoot!=null&&(c=t.relative(this._sourceRoot,c)),o!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[t.toSetString(c)]=o):this._sourcesContents&&(delete this._sourcesContents[t.toSetString(c)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))},a.prototype.applySourceMap=function(n,o,c){var d=o;if(o==null){if(n.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);d=n.file}var p=this._sourceRoot;p!=null&&(d=t.relative(p,d));var C=new s,g=new s;this._mappings.unsortedForEach(function(I){if(I.source===d&&I.originalLine!=null){var e=n.originalPositionFor({line:I.originalLine,column:I.originalColumn});e.source!=null&&(I.source=e.source,c!=null&&(I.source=t.join(c,I.source)),p!=null&&(I.source=t.relative(p,I.source)),I.originalLine=e.line,I.originalColumn=e.column,e.name!=null&&(I.name=e.name))}var r=I.source;r==null||C.has(r)||C.add(r);var h=I.name;h==null||g.has(h)||g.add(h)},this),this._sources=C,this._names=g,n.sources.forEach(function(I){var e=n.sourceContentFor(I);e!=null&&(c!=null&&(I=t.join(c,I)),p!=null&&(I=t.relative(p,I)),this.setSourceContent(I,e))},this)},a.prototype._validateMapping=function(n,o,c,d){if(o&&typeof o.line!="number"&&typeof o.column!="number"){var p="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(p),!1;throw new Error(p)}if((!(n&&"line"in n&&"column"in n&&n.line>0&&n.column>=0)||o||c||d)&&!(n&&"line"in n&&"column"in n&&o&&"line"in o&&"column"in o&&n.line>0&&n.column>=0&&o.line>0&&o.column>=0&&c)){if(p="Invalid mapping: "+JSON.stringify({generated:n,source:c,original:o,name:d}),this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(p),!1;throw new Error(p)}},a.prototype._serializeMappings=function(){for(var n,o,c,d,p=0,C=1,g=0,I=0,e=0,r=0,h="",u=this._mappings.toArray(),m=0,f=u.length;m<f;m++){if(n="",(o=u[m]).generatedLine!==C)for(p=0;o.generatedLine!==C;)n+=";",C++;else if(m>0){if(!t.compareByGeneratedPositionsInflated(o,u[m-1]))continue;n+=","}n+=i.encode(o.generatedColumn-p),p=o.generatedColumn,o.source!=null&&(d=this._sources.indexOf(o.source),n+=i.encode(d-r),r=d,n+=i.encode(o.originalLine-1-I),I=o.originalLine-1,n+=i.encode(o.originalColumn-g),g=o.originalColumn,o.name!=null&&(c=this._names.indexOf(o.name),n+=i.encode(c-e),e=c)),h+=n}return h},a.prototype._generateSourcesContent=function(n,o){return n.map(function(c){if(!this._sourcesContents)return null;o!=null&&(c=t.relative(o,c));var d=t.toSetString(c);return Object.prototype.hasOwnProperty.call(this._sourcesContents,d)?this._sourcesContents[d]:null},this)},a.prototype.toJSON=function(){var n={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(n.file=this._file),this._sourceRoot!=null&&(n.sourceRoot=this._sourceRoot),this._sourcesContents&&(n.sourcesContent=this._generateSourcesContent(n.sources,n.sourceRoot)),n},a.prototype.toString=function(){return JSON.stringify(this.toJSON())},re.SourceMapGenerator=a,re}var Be,F={},We={};function rn(){return Be||(Be=1,(function(i){function t(s,l,a,n,o,c){var d=Math.floor((l-s)/2)+s,p=o(a,n[d],!0);return p===0?d:p>0?l-d>1?t(d,l,a,n,o,c):c==i.LEAST_UPPER_BOUND?l<n.length?l:-1:d:d-s>1?t(s,d,a,n,o,c):c==i.LEAST_UPPER_BOUND?d:s<0?-1:s}i.GREATEST_LOWER_BOUND=1,i.LEAST_UPPER_BOUND=2,i.search=function(s,l,a,n){if(l.length===0)return-1;var o=t(-1,l.length,s,l,a,n||i.GREATEST_LOWER_BOUND);if(o<0)return-1;for(;o-1>=0&&a(l[o],l[o-1],!0)===0;)--o;return o}})(We)),We}var we,Ne,se={};function on(){if(we)return se;function i(s){function l(a,n,o){var c=a[n];a[n]=a[o],a[o]=c}return function a(n,o,c,d){if(c<d){var p=c-1;l(n,(e=c,r=d,Math.round(e+Math.random()*(r-e))),d);for(var C=n[d],g=c;g<d;g++)o(n[g],C,!1)<=0&&l(n,p+=1,g);l(n,p+1,g);var I=p+1;a(n,o,c,I-1),a(n,o,I+1,d)}var e,r}}we=1;let t=new WeakMap;return se.quickSort=function(s,l,a=0){let n=t.get(l);n===void 0&&(n=(function(o){let c=i.toString();return new Function(`return ${c}`)()(o)})(l),t.set(l,n)),n(s,l,a,s.length-1)},se}var Re,Ve,ae={},De=(Ve||(Ve=1,k.SourceMapGenerator=Ze().SourceMapGenerator,k.SourceMapConsumer=(function(){if(Ne)return F;Ne=1;var i=M(),t=rn(),s=Me().ArraySet,l=Je(),a=on().quickSort;function n(g,I){var e=g;return typeof g=="string"&&(e=i.parseSourceMapInput(g)),e.sections!=null?new C(e,I):new o(e,I)}function o(g,I){var e=g;typeof g=="string"&&(e=i.parseSourceMapInput(g));var r=i.getArg(e,"version"),h=i.getArg(e,"sources"),u=i.getArg(e,"names",[]),m=i.getArg(e,"sourceRoot",null),f=i.getArg(e,"sourcesContent",null),b=i.getArg(e,"mappings"),v=i.getArg(e,"file",null);if(r!=this._version)throw new Error("Unsupported version: "+r);m&&(m=i.normalize(m)),h=h.map(String).map(i.normalize).map(function(S){return m&&i.isAbsolute(m)&&i.isAbsolute(S)?i.relative(m,S):S}),this._names=s.fromArray(u.map(String),!0),this._sources=s.fromArray(h,!0),this._absoluteSources=this._sources.toArray().map(function(S){return i.computeSourceURL(m,S,I)}),this.sourceRoot=m,this.sourcesContent=f,this._mappings=b,this._sourceMapURL=I,this.file=v}function c(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}n.fromSourceMap=function(g,I){return o.fromSourceMap(g,I)},n.prototype._version=3,n.prototype.__generatedMappings=null,Object.defineProperty(n.prototype,"_generatedMappings",{configurable:!0,enumerable:!0,get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),n.prototype.__originalMappings=null,Object.defineProperty(n.prototype,"_originalMappings",{configurable:!0,enumerable:!0,get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),n.prototype._charIsMappingSeparator=function(g,I){var e=g.charAt(I);return e===";"||e===","},n.prototype._parseMappings=function(g,I){throw new Error("Subclasses must implement _parseMappings")},n.GENERATED_ORDER=1,n.ORIGINAL_ORDER=2,n.GREATEST_LOWER_BOUND=1,n.LEAST_UPPER_BOUND=2,n.prototype.eachMapping=function(g,I,e){var r,h=I||null;switch(e||n.GENERATED_ORDER){case n.GENERATED_ORDER:r=this._generatedMappings;break;case n.ORIGINAL_ORDER:r=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}for(var u=this.sourceRoot,m=g.bind(h),f=this._names,b=this._sources,v=this._sourceMapURL,S=0,B=r.length;S<B;S++){var W=r[S],Z=W.source===null?null:b.at(W.source);Z!==null&&(Z=i.computeSourceURL(u,Z,v)),m({source:Z,generatedLine:W.generatedLine,generatedColumn:W.generatedColumn,originalLine:W.originalLine,originalColumn:W.originalColumn,name:W.name===null?null:f.at(W.name)})}},n.prototype.allGeneratedPositionsFor=function(g){var I=i.getArg(g,"line"),e={source:i.getArg(g,"source"),originalLine:I,originalColumn:i.getArg(g,"column",0)};if(e.source=this._findSourceIndex(e.source),e.source<0)return[];var r=[],h=this._findMapping(e,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions,t.LEAST_UPPER_BOUND);if(h>=0){var u=this._originalMappings[h];if(g.column===void 0)for(var m=u.originalLine;u&&u.originalLine===m;)r.push({line:i.getArg(u,"generatedLine",null),column:i.getArg(u,"generatedColumn",null),lastColumn:i.getArg(u,"lastGeneratedColumn",null)}),u=this._originalMappings[++h];else for(var f=u.originalColumn;u&&u.originalLine===I&&u.originalColumn==f;)r.push({line:i.getArg(u,"generatedLine",null),column:i.getArg(u,"generatedColumn",null),lastColumn:i.getArg(u,"lastGeneratedColumn",null)}),u=this._originalMappings[++h]}return r},F.SourceMapConsumer=n,o.prototype=Object.create(n.prototype),o.prototype.consumer=n,o.prototype._findSourceIndex=function(g){var I,e=g;if(this.sourceRoot!=null&&(e=i.relative(this.sourceRoot,e)),this._sources.has(e))return this._sources.indexOf(e);for(I=0;I<this._absoluteSources.length;++I)if(this._absoluteSources[I]==g)return I;return-1},o.fromSourceMap=function(g,I){var e=Object.create(o.prototype),r=e._names=s.fromArray(g._names.toArray(),!0),h=e._sources=s.fromArray(g._sources.toArray(),!0);e.sourceRoot=g._sourceRoot,e.sourcesContent=g._generateSourcesContent(e._sources.toArray(),e.sourceRoot),e.file=g._file,e._sourceMapURL=I,e._absoluteSources=e._sources.toArray().map(function(W){return i.computeSourceURL(e.sourceRoot,W,I)});for(var u=g._mappings.toArray().slice(),m=e.__generatedMappings=[],f=e.__originalMappings=[],b=0,v=u.length;b<v;b++){var S=u[b],B=new c;B.generatedLine=S.generatedLine,B.generatedColumn=S.generatedColumn,S.source&&(B.source=h.indexOf(S.source),B.originalLine=S.originalLine,B.originalColumn=S.originalColumn,S.name&&(B.name=r.indexOf(S.name)),f.push(B)),m.push(B)}return a(e.__originalMappings,i.compareByOriginalPositions),e},o.prototype._version=3,Object.defineProperty(o.prototype,"sources",{get:function(){return this._absoluteSources.slice()}});const d=i.compareByGeneratedPositionsDeflatedNoLine;function p(g,I){let e=g.length,r=g.length-I;if(!(r<=1))if(r==2){let h=g[I],u=g[I+1];d(h,u)>0&&(g[I]=u,g[I+1]=h)}else if(r<20)for(let h=I;h<e;h++)for(let u=h;u>I;u--){let m=g[u-1],f=g[u];if(d(m,f)<=0)break;g[u-1]=f,g[u]=m}else a(g,d,I)}function C(g,I){var e=g;typeof g=="string"&&(e=i.parseSourceMapInput(g));var r=i.getArg(e,"version"),h=i.getArg(e,"sections");if(r!=this._version)throw new Error("Unsupported version: "+r);this._sources=new s,this._names=new s;var u={line:-1,column:0};this._sections=h.map(function(m){if(m.url)throw new Error("Support for url field in sections not implemented.");var f=i.getArg(m,"offset"),b=i.getArg(f,"line"),v=i.getArg(f,"column");if(b<u.line||b===u.line&&v<u.column)throw new Error("Section offsets must be ordered and non-overlapping.");return u=f,{generatedOffset:{generatedLine:b+1,generatedColumn:v+1},consumer:new n(i.getArg(m,"map"),I)}})}return o.prototype._parseMappings=function(g,I){var e,r,h,u,m=1,f=0,b=0,v=0,S=0,B=0,W=g.length,Z=0,q={},R=[],Y=[];let ee=0;for(;Z<W;)if(g.charAt(Z)===";")m++,Z++,f=0,p(Y,ee),ee=Y.length;else if(g.charAt(Z)===",")Z++;else{for((e=new c).generatedLine=m,h=Z;h<W&&!this._charIsMappingSeparator(g,h);h++);for(g.slice(Z,h),r=[];Z<h;)l.decode(g,Z,q),u=q.value,Z=q.rest,r.push(u);if(r.length===2)throw new Error("Found a source, but no line and column");if(r.length===3)throw new Error("Found a source and line, but no column");if(e.generatedColumn=f+r[0],f=e.generatedColumn,r.length>1&&(e.source=S+r[1],S+=r[1],e.originalLine=b+r[2],b=e.originalLine,e.originalLine+=1,e.originalColumn=v+r[3],v=e.originalColumn,r.length>4&&(e.name=B+r[4],B+=r[4])),Y.push(e),typeof e.originalLine=="number"){let x=e.source;for(;R.length<=x;)R.push(null);R[x]===null&&(R[x]=[]),R[x].push(e)}}p(Y,ee),this.__generatedMappings=Y;for(var O=0;O<R.length;O++)R[O]!=null&&a(R[O],i.compareByOriginalPositionsNoSource);this.__originalMappings=[].concat(...R)},o.prototype._findMapping=function(g,I,e,r,h,u){if(g[e]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+g[e]);if(g[r]<0)throw new TypeError("Column must be greater than or equal to 0, got "+g[r]);return t.search(g,I,h,u)},o.prototype.computeColumnSpans=function(){for(var g=0;g<this._generatedMappings.length;++g){var I=this._generatedMappings[g];if(g+1<this._generatedMappings.length){var e=this._generatedMappings[g+1];if(I.generatedLine===e.generatedLine){I.lastGeneratedColumn=e.generatedColumn-1;continue}}I.lastGeneratedColumn=1/0}},o.prototype.originalPositionFor=function(g){var I={generatedLine:i.getArg(g,"line"),generatedColumn:i.getArg(g,"column")},e=this._findMapping(I,this._generatedMappings,"generatedLine","generatedColumn",i.compareByGeneratedPositionsDeflated,i.getArg(g,"bias",n.GREATEST_LOWER_BOUND));if(e>=0){var r=this._generatedMappings[e];if(r.generatedLine===I.generatedLine){var h=i.getArg(r,"source",null);h!==null&&(h=this._sources.at(h),h=i.computeSourceURL(this.sourceRoot,h,this._sourceMapURL));var u=i.getArg(r,"name",null);return u!==null&&(u=this._names.at(u)),{source:h,line:i.getArg(r,"originalLine",null),column:i.getArg(r,"originalColumn",null),name:u}}}return{source:null,line:null,column:null,name:null}},o.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(g){return g==null})},o.prototype.sourceContentFor=function(g,I){if(!this.sourcesContent)return null;var e=this._findSourceIndex(g);if(e>=0)return this.sourcesContent[e];var r,h=g;if(this.sourceRoot!=null&&(h=i.relative(this.sourceRoot,h)),this.sourceRoot!=null&&(r=i.urlParse(this.sourceRoot))){var u=h.replace(/^file:\/\//,"");if(r.scheme=="file"&&this._sources.has(u))return this.sourcesContent[this._sources.indexOf(u)];if((!r.path||r.path=="/")&&this._sources.has("/"+h))return this.sourcesContent[this._sources.indexOf("/"+h)]}if(I)return null;throw new Error('"'+h+'" is not in the SourceMap.')},o.prototype.generatedPositionFor=function(g){var I=i.getArg(g,"source");if((I=this._findSourceIndex(I))<0)return{line:null,column:null,lastColumn:null};var e={source:I,originalLine:i.getArg(g,"line"),originalColumn:i.getArg(g,"column")},r=this._findMapping(e,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions,i.getArg(g,"bias",n.GREATEST_LOWER_BOUND));if(r>=0){var h=this._originalMappings[r];if(h.source===e.source)return{line:i.getArg(h,"generatedLine",null),column:i.getArg(h,"generatedColumn",null),lastColumn:i.getArg(h,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},F.BasicSourceMapConsumer=o,C.prototype=Object.create(n.prototype),C.prototype.constructor=n,C.prototype._version=3,Object.defineProperty(C.prototype,"sources",{get:function(){for(var g=[],I=0;I<this._sections.length;I++)for(var e=0;e<this._sections[I].consumer.sources.length;e++)g.push(this._sections[I].consumer.sources[e]);return g}}),C.prototype.originalPositionFor=function(g){var I={generatedLine:i.getArg(g,"line"),generatedColumn:i.getArg(g,"column")},e=t.search(I,this._sections,function(h,u){return h.generatedLine-u.generatedOffset.generatedLine||h.generatedColumn-u.generatedOffset.generatedColumn}),r=this._sections[e];return r?r.consumer.originalPositionFor({line:I.generatedLine-(r.generatedOffset.generatedLine-1),column:I.generatedColumn-(r.generatedOffset.generatedLine===I.generatedLine?r.generatedOffset.generatedColumn-1:0),bias:g.bias}):{source:null,line:null,column:null,name:null}},C.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(g){return g.consumer.hasContentsOfAllSources()})},C.prototype.sourceContentFor=function(g,I){for(var e=0;e<this._sections.length;e++){var r=this._sections[e].consumer.sourceContentFor(g,!0);if(r||r==="")return r}if(I)return null;throw new Error('"'+g+'" is not in the SourceMap.')},C.prototype.generatedPositionFor=function(g){for(var I=0;I<this._sections.length;I++){var e=this._sections[I];if(e.consumer._findSourceIndex(i.getArg(g,"source"))!==-1){var r=e.consumer.generatedPositionFor(g);if(r)return{line:r.line+(e.generatedOffset.generatedLine-1),column:r.column+(e.generatedOffset.generatedLine===r.line?e.generatedOffset.generatedColumn-1:0)}}}return{line:null,column:null}},C.prototype._parseMappings=function(g,I){this.__generatedMappings=[],this.__originalMappings=[];for(var e=0;e<this._sections.length;e++)for(var r=this._sections[e],h=r.consumer._generatedMappings,u=0;u<h.length;u++){var m=h[u],f=r.consumer._sources.at(m.source);f!==null&&(f=i.computeSourceURL(r.consumer.sourceRoot,f,this._sourceMapURL)),this._sources.add(f),f=this._sources.indexOf(f);var b=null;m.name&&(b=r.consumer._names.at(m.name),this._names.add(b),b=this._names.indexOf(b));var v={source:f,generatedLine:m.generatedLine+(r.generatedOffset.generatedLine-1),generatedColumn:m.generatedColumn+(r.generatedOffset.generatedLine===m.generatedLine?r.generatedOffset.generatedColumn-1:0),originalLine:m.originalLine,originalColumn:m.originalColumn,name:b};this.__generatedMappings.push(v),typeof v.originalLine=="number"&&this.__originalMappings.push(v)}a(this.__generatedMappings,i.compareByGeneratedPositionsDeflated),a(this.__originalMappings,i.compareByOriginalPositions)},F.IndexedSourceMapConsumer=C,F})().SourceMapConsumer,k.SourceNode=(function(){if(Re)return ae;Re=1;var i=Ze().SourceMapGenerator,t=M(),s=/(\r?\n)/,l="$$$isSourceNode$$$";function a(n,o,c,d,p){this.children=[],this.sourceContents={},this.line=n??null,this.column=o??null,this.source=c??null,this.name=p??null,this[l]=!0,d!=null&&this.add(d)}return a.fromStringWithSourceMap=function(n,o,c){var d=new a,p=n.split(s),C=0,g=function(){return u()+(u()||"");function u(){return C<p.length?p[C++]:void 0}},I=1,e=0,r=null;return o.eachMapping(function(u){if(r!==null){if(!(I<u.generatedLine)){var m=(f=p[C]||"").substr(0,u.generatedColumn-e);return p[C]=f.substr(u.generatedColumn-e),e=u.generatedColumn,h(r,m),void(r=u)}h(r,g()),I++,e=0}for(;I<u.generatedLine;)d.add(g()),I++;if(e<u.generatedColumn){var f=p[C]||"";d.add(f.substr(0,u.generatedColumn)),p[C]=f.substr(u.generatedColumn),e=u.generatedColumn}r=u},this),C<p.length&&(r&&h(r,g()),d.add(p.splice(C).join(""))),o.sources.forEach(function(u){var m=o.sourceContentFor(u);m!=null&&(c!=null&&(u=t.join(c,u)),d.setSourceContent(u,m))}),d;function h(u,m){if(u===null||u.source===void 0)d.add(m);else{var f=c?t.join(c,u.source):u.source;d.add(new a(u.originalLine,u.originalColumn,f,m,u.name))}}},a.prototype.add=function(n){if(Array.isArray(n))n.forEach(function(o){this.add(o)},this);else{if(!n[l]&&typeof n!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+n);n&&this.children.push(n)}return this},a.prototype.prepend=function(n){if(Array.isArray(n))for(var o=n.length-1;o>=0;o--)this.prepend(n[o]);else{if(!n[l]&&typeof n!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+n);this.children.unshift(n)}return this},a.prototype.walk=function(n){for(var o,c=0,d=this.children.length;c<d;c++)(o=this.children[c])[l]?o.walk(n):o!==""&&n(o,{source:this.source,line:this.line,column:this.column,name:this.name})},a.prototype.join=function(n){var o,c,d=this.children.length;if(d>0){for(o=[],c=0;c<d-1;c++)o.push(this.children[c]),o.push(n);o.push(this.children[c]),this.children=o}return this},a.prototype.replaceRight=function(n,o){var c=this.children[this.children.length-1];return c[l]?c.replaceRight(n,o):typeof c=="string"?this.children[this.children.length-1]=c.replace(n,o):this.children.push("".replace(n,o)),this},a.prototype.setSourceContent=function(n,o){this.sourceContents[t.toSetString(n)]=o},a.prototype.walkSourceContents=function(n){for(var o=0,c=this.children.length;o<c;o++)this.children[o][l]&&this.children[o].walkSourceContents(n);var d=Object.keys(this.sourceContents);for(o=0,c=d.length;o<c;o++)n(t.fromSetString(d[o]),this.sourceContents[d[o]])},a.prototype.toString=function(){var n="";return this.walk(function(o){n+=o}),n},a.prototype.toStringWithSourceMap=function(n){var o={code:"",line:1,column:0},c=new i(n),d=!1,p=null,C=null,g=null,I=null;return this.walk(function(e,r){o.code+=e,r.source!==null&&r.line!==null&&r.column!==null?(p===r.source&&C===r.line&&g===r.column&&I===r.name||c.addMapping({source:r.source,original:{line:r.line,column:r.column},generated:{line:o.line,column:o.column},name:r.name}),p=r.source,C=r.line,g=r.column,I=r.name,d=!0):d&&(c.addMapping({generated:{line:o.line,column:o.column}}),p=null,d=!1);for(var h=0,u=e.length;h<u;h++)e.charCodeAt(h)===10?(o.line++,o.column=0,h+1===u?(p=null,d=!1):d&&c.addMapping({source:r.source,original:{line:r.line,column:r.column},generated:{line:o.line,column:o.column},name:r.name})):o.column++}),this.walkSourceContents(function(e,r){c.setSourceContent(e,r)}),{code:o.code,map:c}},ae.SourceNode=a,ae})().SourceNode),k);class J{constructor({file:t,line:s,function:l,code:a,locals:n={},offender:o=!1,column:c}){y(this,"file");y(this,"line");y(this,"function");y(this,"code");y(this,"locals");y(this,"offender");y(this,"column");this.file=t,this.line=s,this.function=l,this.code=a,this.locals=n,this.offender=o,this.column=c}toDict(){const t={file:this.file,line:this.line,function:this.function,code:this.code,locals:Object.fromEntries(Object.entries(this.locals).map(([s,l])=>[s,String(l)]))};return this.offender&&(t.offender=this.offender),this.column!==void 0&&(t.column=this.column),t}toJson(){return JSON.stringify(this.toDict())}}class Q{static encode(t){return t instanceof J?t.toDict():Array.isArray(t)?t.map(s=>Q.encode(s)):typeof t=="object"&&t!==null?JSON.stringify(t):t}static stringify(t){return JSON.stringify(Q.encode(t),(s,l)=>l instanceof J?l.toDict():l)}}let V,K=0;function sn(i){A().sfDebug&&console.log("Initializing Exception Interceptor...");try{const c=(function(){if(V!==void 0)return V;const d=process.env||{},p=Le(d.SF_IS_LOCAL);if(p!==void 0)return V=p;const C=(d.SF_ENV||d.NODE_ENV||"").toLowerCase();if(["local","dev","development"].includes(C))return V=!0;if(["KUBERNETES_SERVICE_HOST","AWS_EXECUTION_ENV","ECS_CONTAINER_METADATA_URI","ECS_CONTAINER_METADATA_URI_V4","GAE_ENV","K_SERVICE","GOOGLE_CLOUD_PROJECT","WEBSITE_INSTANCE_ID","VERCEL","NETLIFY","DYNO","RENDER","FLY_APP_NAME","RAILWAY_STATIC_URL","CF_PAGES","CLOUDFLARE"].some(I=>!!d[I]))return V=!1;const g=(N.hostname?.()||d.HOSTNAME||"").toLowerCase();return g==="localhost"||g.endsWith(".local")||g.includes("local")?V=!0:V=!1})();i?.setSupplementalFields?.({isFromLocalService:c}),(async function(d){if(He)return;He=!0;const p=process.env||{};if(Le(p.SF_IS_LOCAL)===void 0)try{await(async function(C){const g=ce("http://169.254.169.254/latest/meta-data/",{},C),I=ce("http://metadata.google.internal/computeMetadata/v1/instance/",{"Metadata-Flavor":"Google"},C),e=ce("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{Metadata:"true"},C);return(await Promise.allSettled([g,I,e])).some(r=>r.status==="fulfilled"&&(r.value==="ok"||r.value==="http_error"))})(150)&&V&&(V=!1,d?.setSupplementalFields?.({isFromLocalService:!1}))}catch{}})(i).catch(()=>{})}catch{}const t=new ke.Worker(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5ub2RlTW9kdWxlc1RvQ29sbGVjdExvY2FsVmFyaWFibGVzT24gPSB1bmRlZmluZWQ7CgovKioKICogUHJvY2Vzc2VzIGNhbGwgZnJhbWVzIGZyb20gYW4gZXhjZXB0aW9uIGFuZCBwb3N0cyB0aGVtIHZpYSB0aGUgV29ya2Vy4oCZcyBwYXJlbnRQb3J0LgogKgogKiBAcGFyYW0gc2Vzc2lvbiAtIFRoZSBEZXZUb29scyBzZXNzaW9uIG9yIHNpbWlsYXIgb2JqZWN0IHlvdSB1c2UgdG8gcXVlcnkgZm9yIHNjcmlwdCBzb3VyY2VzLgogKiBAcGFyYW0gY2FsbEZyYW1lcyAtIEFuIGFycmF5IG9mIGNhbGwgZnJhbWUgb2JqZWN0cy4KICogQHBhcmFtIGRlc2NyaXB0aW9uTGluZXMgLSBBbiBhcnJheSBvZiBsaW5lcyBmcm9tIHRoZSBlcnJvcuKAmXMgZGVzY3JpcHRpb24sIGVhY2ggdHlwaWNhbGx5IGJlZ2lubmluZyB3aXRoICJhdCAiLgogKiBAcmV0dXJucyB7UHJvbWlzZTx2b2lkPn0KICovCmV4cG9ydCBhc3luYyBmdW5jdGlvbiBwcm9jZXNzQ2FsbEZyYW1lcyhzZX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lsZSA9IGRlc2NyaXB0aW9uTGluZXNbaW5kZXhdLnRyaW0oKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZmlsZSA9ICI8dW5rbm93bj4iOwogICAgICAgIH0KCiAgICAgICAgLy8gSWYgd2UgaGF2ZSBhIHZhbGlkIGxvY2F0aW9uIGFuZCBzY3JpcHRJZCwgZmV0Y2ggdGhlIGNvZGUgbGluZQogICAgICAgIGlmIChsb2NhdGlvbiAmJiBsb2NhdGlvbi5zY3JpcHRJZCkgewogICAgICAgICAgY29uc3Qgc2NyaXB0SWQgPSBsb2NhdGlvbi5zY3JpcHRJZDsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIGNvbnN0IHsgc2NyaXB0U291cmNlIH0gPSBhd2FpdCBzZXNzaW9uLnBvc3QoCiAgICAgICAgICAgICAgIkRlYnVnZ2VyLmdldFNjcmlwdFNvdXJjZSIsCiAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgc2NyaXB0SWQsCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgKTsKICAgICAgICAgICAgY29uc3Qgc291cmNlTGluZXMgPSBzY3JpcHRTb3VyY2Uuc3BsaXQoIlxuIik7CiAgICAgICAgICAgIGNvZGUgPSBzb3VyY2VMaW5lc1tsb2NhdGlvbi5saW5lTnVtYmVyXSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRXJyb3IgcHJvY2Vzc2luZyBjYWxsIGZyYW1lOiIsIGVycm9yKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiAiPGVycm9yPiIsCiAgICAgICAgICBsb2NhbHM6IHt9LAogICAgICAgICAgZmlsZTogIjx1bmtub3duPiIsCiAgICAgICAgICBsaW5lOiAwLAogICAgICAgICAgY29kZTogIjxub3QgY2FwdHVyZWQ+IiwKICAgICAgICB9OwogICAgICB9CiAgICB9KSwKICApOwogIC8vIFBvc3QgZXhjZXB0aW9uIGRhdGEKICBwYXJlbnRQb3J0Py5wb3N0TWVzc2FnZSh7IHR5cGU6ICJleGNlcHRpb24iLCBmcmFtZXMgfSk7Cn0KCi8qKgogKiBIYW5kbGVzIHRoZSAicGF1c2VkIiBzdGF0ZSBvZiB0aGUgZGVidWdnZXIgYW5kIHByb2Nlc3NlcyBleGNlcHRpb25zIG9yIHByb21pc2UgcmVqZWN0aW9ucy4KICogQHBhcmFtIHtTZXNzaW9ufSBzZXNzaW9uIC0gVGhlIGRlYnVnZ2luZyBzZXNzaW9uIGluc3RhbmNlLg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0SWQ7CiAgICAgICAgICBhd2FpdCB1bnJvbGxPYmplY3Qoc2Vzc2lvbiwgaWQsIHByb3AubmFtZSwgdmFyaWFibGVzKTsKICAgICAgICB9IGVsc2UgaWYgKHByb3A/LnZhbHVlKSB7CiAgICAgICAgICB1bnJvbGxPdGhlcihwcm9wLCB2YXJpYWJsZXMpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gdmFyaWFibGVzOwogICAgfQogIH0gY2F0Y2ggKGVycikgewogICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBsb2NhbCB2YXJpYWJsZXM6IiwgZXJyKTsKICAgIH0KICAgIHJldHVybiB7fTsKICB9Cn0KCnN0YXJ0RGVidWdnZXIoKS5jYXRjaCgoZXJyb3IpID0+IHsKICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlcjoiLCBlcnJvcik7CiAgfQp9KTsKCi8vIEtlZXAgdGhlIHdvcmtlciBhbGl2ZQpzZXRJbnRlcnZhbCgoKSA9PiB7fSwgMTAwMDApOwo="),{workerData:{captureAllExceptions:!0}});let s=null;const l=new WeakMap;t.on("message",c=>{if(typeof c=="string"&&A().sfDebug&&console.log(`[Worker] ${c}`),c.readyToGetParameters&&t.postMessage({sfDebug:A().sfDebug,stackDepthLocals:A().stackDepthLocals,nodeModulesToCollectLocalVariablesOn:A().nodeModulesToCollectLocalVariablesOn}),c.type==="exception"){const{frames:d}=c,p=s;if(!p)return;const C=l.get(p),g=(function(e){return e?e.split(`
34
- `).slice(1).map(r=>{const h=/at (.+?) \((.+):(\d+):(\d+)\)/.exec(r)||/at (.+):(\d+):(\d+)/.exec(r);if(h){const[,u,m,f,b]=h;return new J({function:u||"<anonymous>",locals:{},file:m||"<unknown>",line:parseInt(f,10)||0,code:"<not captured>",column:parseInt(b)||0})}return new J({function:"<unknown>",locals:{},file:"<unknown>",line:0,code:"<not captured>",column:0})}):[]})(p.stack),I=(function(e,r){const h=[];let u=-1,m=-1;for(let f=0;f<e.length;f++){const b=cn(e[f].file);if(m=f,b!=="<unknown>"){for(let v=0;v<r.length;v++){const S=r[v];if(Oe(S,b)||typeof S.file=="string"&&S.file.includes(b)){u=v,K=0,A().sfDebug&&console.log(`✅ Matched Frame Found: ${b} @ Debugger Frame ${v}`);break}}if(u!==-1)break}}if(u===-1)return K===10?(K=0,e):(++K,A().sfDebug&&console.log(`"❌ No matching frame found. Checking once again, Attempt N ${K}"`),[]);A().sfDebug&&console.log(`🔄 Merging from matched index ${u} onward...`);for(let f=0;f<r.length;f++){const b=e[m+f],v=r[u+f];h.push(new J({function:v?.function||b?.function||"<anonymous>",locals:v?.locals||b?.locals||{},file:b?.file||v?.file||"<unknown>",line:v?.line||b?.line||0,code:v?.code||b?.code||"<not captured>"}))}return h})(g,d||[]);if(I.length!==0){s=null;const e=A().stackDepthCodeTraceDepth,r=e===-1?I:I.slice(0,e+1),h=Math.min(r.length,g.length);for(let b=0;b<h;b++)(async()=>{const v=an(r[b].file,g[b].line,g[b].column);v&&(v.content!=null&&(r[b].code=v.content),v.file!=null&&(r[b].file=v.file))})();i.setOperationName("CollectExceptions");const u=p.message?`${p.name}: ${p.message}`:p.name;A().sfDebug&&console.log("error message is : ",u);const m=w.getInstance(),f=l.get(p);f?(m.setTraceIdFor(f,f),m.runWithSession(f,()=>{m.setTraceId(f),i.doSend(u,r)})):i.doSend(u,r),C?w.getInstance().runWithSession(C,()=>{i.doSend(u,r)}):i.doSend(u,r)}}}),t.on("error",c=>{console.error("[Worker Error]",c)}),t.on("exit",c=>{console.error(`[Worker] Exited with code ${c}`)}),t.unref();const a=Error,n=new Set;function o(...c){const d=Reflect.construct(a,c);Reflect.setPrototypeOf(d,o.prototype);try{const C=w.getInstance().getTraceId();l.set(d,C)}catch{}a.captureStackTrace&&a.captureStackTrace(d,o);const p=`${d.message}:${d.stack?.split(`
35
- `)[1]?.trim()}`;if(!n.has(p)){n.add(p),s=d;const C=w.getInstance().getTraceId();l.set(d,C),t.postMessage({type:"processException",error:d.message})}return d}o.prototype=Object.create(a.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf(o,a),globalThis.Error=o}function _e(i){return i=(i=(i=i.replace(/^webpack:\/\/[^\/]+\/\.?\//,"")).replace(/^.*\/pages\//,"pages/")).replace(/\.(js|ts)$/,"")}function an(i,t,s){const l=(function(n){n.startsWith("at ")&&(n=n.slice(3).trim());const o=n.match(/^(.*?)(:\d+)+(\.map)?$/);return o?o[1]:n})(i);if(!l||l==="<unknown>")return null;const a=l+".map";try{const n=Fe.readFileSync(a,"utf-8");if(n){const o=JSON.parse(n);let c=new De.SourceMapConsumer(o).originalPositionFor({line:t,column:s});if(l&&c.source){const d=_e(l),p=o.sources.findIndex(C=>_e(C)===d);if(p===-1)A().sfDebug&&console.log(`Source file "${l}" not found in the source map.`);else{const C=o.sourcesContent[p],g=o.names.join(",");if(C)return{content:C.split(`
36
- `).slice(c.line-1,c.line+20).join(`
37
- `),name:g,file:c.source};A().sfDebug&&console.log(`No source content available for file "${l}".`)}}return{content:o.sourcesContent[0],name:o.names[0],file:o.file}}}catch(n){A().sfDebug&&console.log(`Cant read/parse "${a}: Error - ".`,n)}return null}function cn(i){return i?.split("/").pop()||"<unknown>"}function Oe(i,t){if(!i||typeof i!="object")return!1;for(const s of Object.values(i))if(typeof s=="string"&&s.includes(t)||typeof s=="object"&&Oe(s,t))return!0;return!1}let He=!1;function Le(i){if(!i)return;const t=i.toLowerCase().trim();return!!["1","true","yes","on"].includes(t)||!["0","false","no","off"].includes(t)&&void 0}function ce(i,t,s){return new Promise(l=>{try{const a=new URL(i),n=(a.protocol,N).request({method:"GET",hostname:a.hostname,port:a.port||(a.protocol==="https:"?443:80),path:a.pathname+(a.search||""),headers:t},o=>{o.resume(),o.statusCode&&o.statusCode>=200&&o.statusCode<400?l("ok"):l("http_error")});n.on("error",()=>l("error")),n.setTimeout(s,()=>{n.destroy(),l("timeout")}),n.end()}catch{l("error")}})}class ln extends E{constructor(){super();y(this,"serviceIdentifier",new D);y(this,"supplementalFields",{});this.setOperationName("CollectExceptions")}setSupplementalFields(s){this.supplementalFields={...this.supplementalFields,...s}}normalizedSupplementalForGraphQL(){const{isFromLocalService:s}=this.supplementalFields,l={};return s!==void 0&&(l.isFromLocalService=s),l}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s,l){this.sendAppIdentifier(),this.send(s,l)}async send(s,l){A().sfDebug&&console.log(" SENDING EXCEPTION...");const a=JSON.stringify(Q.encode(l)),n=this.normalizedSupplementalForGraphQL(),o=this.getVariables({exceptionMessage:s,traceJson:a,reentrancyGuardPreactive:!1,library:A().packageLibraryType,version:A().version,...n});H(this.endpoint,this.operationName,this.getQuery(),o)}getQuery(){return`
49
+ `}}const B={};class X{constructor({file:e,line:t,function:i,code:n,locals:s={},offender:a=!1,column:r}){u(this,"file");u(this,"line");u(this,"function");u(this,"code");u(this,"locals");u(this,"offender");u(this,"column");this.file=e,this.line=t,this.function=i,this.code=n,this.locals=s,this.offender=a,this.column=r}toDict(){const e={file:this.file,line:this.line,function:this.function,code:this.code,locals:Object.fromEntries(Object.entries(this.locals).map(([t,i])=>[t,String(i)]))};return this.offender&&(e.offender=this.offender),this.column!==void 0&&(e.column=this.column),e}toJson(){return JSON.stringify(this.toDict())}}class x{static encode(e){return e instanceof X?e.toDict():Array.isArray(e)?e.map(t=>x.encode(t)):typeof e=="object"&&e!==null?JSON.stringify(e):e}static stringify(e){return JSON.stringify(x.encode(e),(t,i)=>i instanceof X?i.toDict():i)}}let N,K=0;function Te(o){l().sfDebug&&console.log("Initializing Exception Interceptor...");try{const r=(function(){if(N!==void 0)return N;const g=process.env||{},c=de(g.SF_IS_LOCAL);if(c!==void 0)return N=c;const I=(g.SF_ENV||g.NODE_ENV||"").toLowerCase();if(["local","dev","development"].includes(I))return N=!0;if(["KUBERNETES_SERVICE_HOST","AWS_EXECUTION_ENV","ECS_CONTAINER_METADATA_URI","ECS_CONTAINER_METADATA_URI_V4","GAE_ENV","K_SERVICE","GOOGLE_CLOUD_PROJECT","WEBSITE_INSTANCE_ID","VERCEL","NETLIFY","DYNO","RENDER","FLY_APP_NAME","RAILWAY_STATIC_URL","CF_PAGES","CLOUDFLARE"].some(C=>!!g[C]))return N=!1;const d=(B.hostname?.()||g.HOSTNAME||"").toLowerCase();return d==="localhost"||d.endsWith(".local")||d.includes("local")?N=!0:N=!1})();o?.setSupplementalFields?.({isFromLocalService:r}),(async function(g){if(Ie)return;Ie=!0;const c=process.env||{};if(de(c.SF_IS_LOCAL)===void 0)try{await(async function(I){const d=M("http://169.254.169.254/latest/meta-data/",{},I),C=M("http://metadata.google.internal/computeMetadata/v1/instance/",{"Metadata-Flavor":"Google"},I),p=M("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{Metadata:"true"},I);return(await Promise.allSettled([d,C,p])).some(h=>h.status==="fulfilled"&&(h.value==="ok"||h.value==="http_error"))})(150)&&N&&(N=!1,g?.setSupplementalFields?.({isFromLocalService:!1}))}catch{}})(o).catch(()=>{})}catch{}const e=new Ve.Worker(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5ub2RlTW9kdWxlc1RvQ29sbGVjdExvY2FsVmFyaWFibGVzT24gPSB1bmRlZmluZWQ7CgovKioKICogUHJvY2Vzc2VzIGNhbGwgZnJhbWVzIGZyb20gYW4gZXhjZXB0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gICAgICAgICAgfSwKICAgICAgICAgICAgKTsKICAgICAgICAgICAgY29uc3Qgc291cmNlTGluZXMgPSBzY3JpcHRTb3VyY2Uuc3BsaXQoIlxuIik7CiAgICAgICAgICAgIGNvZGUgPSBzb3VyY2VMaW5lc1tsb2NhdGlvbi5saW5lTnVtYmVyXSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRXJyb3IgcHJvY2Vzc2luZyBjYWxsIGZyYW1lOiIsIGVycm9yKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuI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YCR7bW9kdWxlTmFtZX1gKSwKICAgICAgICApOwoKICAgICAgICBpZiAoIWlzRnJvbUFsbG93ZWROb2RlTW9kdWxlKSB7CiAgICAgICAgICAvLyBOb3QgZnJvbSBhbiBhbGxvd2VkIG5vZGUgbW9kdWxlID0+IHJldHVybiBlYXJseQogICAgICAgICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgICAgICAgIGNvbnNvbGUubG9nKAogICAgICAgICAgICAgICJbV29ya2VyXSBFcnJvciBhcHBlYXJzIHRvIGJlIHRyaWdnZXJlZCBmcm9tIG5vbi1hcHBsaWNhdGlvbiBzb3VyY2VzOyBpZ25vcmluZy4iLAogICAgICAgICAgICApOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICAvLyBPdGhlcndpc2UsIGl0J3MgZnJvbSBhbiBhbGxvd2VkIG5vZGUgbW9kdWxlLCBzbyBjb250aW51ZQogICAgICB9IGVsc2UgewogICAgICAgIC8vIElmIHRoZSBsaXN0IGlzIGVtcHR5LCBwcmVzZXJ2ZSBleGlzdGluZyBiZWhhdmlvciBhbmQgaWdub3JlIG5vbi1hcHBsaWNhdGlvbiBlcnJvcnMKICAgICAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgICAgIGNvbnNvbGUubG9nKAogICAgICAgICAgICAiW1dvcmtlcl0gRXJyb3IgYXBwZWFycyB0byBiZSB0cmlnZ2VyZWQgZnJvbSBub24tYXBwbGljYXRpb24gc291cmNlczsgaWdub3JpbmcuIiwKICAgICAgICAgICk7CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgfQoKICAgIC8vIElmIHdlIHJlYWNoIHRoaXMgcG9pbnQsIHRoZSBlcnJvciBpcyBlaXRoZXIgZnJvbSBhcHAgY29kZSwgb3IgZnJvbSBhIG5vZGUgbW9kdWxlIGFsbG93ZWQgYnkgdGhlIGxpc3QKICAgIC8vID0+IFByb2NlZWQgd2l0aCBj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3JrZXJdIEZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlcjoiLCBlcnJvcik7CiAgfQp9KTsKCi8vIEtlZXAgdGhlIHdvcmtlciBhbGl2ZQpzZXRJbnRlcnZhbCgoKSA9PiB7fSwgMTAwMDApOwo="),{workerData:{captureAllExceptions:!0}});let t=null;const i=new WeakMap;e.on("message",r=>{if(typeof r=="string"&&l().sfDebug&&console.log(`[Worker] ${r}`),r.readyToGetParameters&&e.postMessage({sfDebug:l().sfDebug,stackDepthLocals:l().stackDepthLocals,nodeModulesToCollectLocalVariablesOn:l().nodeModulesToCollectLocalVariablesOn}),r.type==="exception"){const{frames:g}=r,c=t;if(!c)return;const I=i.get(c),d=(function(p){return p?p.split(`
50
+ `).slice(1).map(h=>{const A=/at (.+?) \((.+):(\d+):(\d+)\)/.exec(h)||/at (.+):(\d+):(\d+)/.exec(h);if(A){const[,m,Z,f,b]=A;return new X({function:m||"<anonymous>",locals:{},file:Z||"<unknown>",line:parseInt(f,10)||0,code:"<not captured>",column:parseInt(b)||0})}return new X({function:"<unknown>",locals:{},file:"<unknown>",line:0,code:"<not captured>",column:0})}):[]})(c.stack),C=(function(p,h){const A=[];let m=-1,Z=-1;for(let f=0;f<p.length;f++){const b=Ee(p[f].file);if(Z=f,b!=="<unknown>"){for(let y=0;y<h.length;y++){const $=h[y];if(Be($,b)||typeof $.file=="string"&&$.file.includes(b)){m=y,K=0,l().sfDebug&&console.log(`✅ Matched Frame Found: ${b} @ Debugger Frame ${y}`);break}}if(m!==-1)break}}if(m===-1)return K===10?(K=0,p):(++K,l().sfDebug&&console.log(`"❌ No matching frame found. Checking once again, Attempt N ${K}"`),[]);l().sfDebug&&console.log(`🔄 Merging from matched index ${m} onward...`);for(let f=0;f<h.length;f++){const b=p[Z+f],y=h[m+f];A.push(new X({function:y?.function||b?.function||"<anonymous>",locals:y?.locals||b?.locals||{},file:b?.file||y?.file||"<unknown>",line:y?.line||b?.line||0,code:y?.code||b?.code||"<not captured>"}))}return A})(d,g||[]);if(C.length!==0){t=null;const p=l().stackDepthCodeTraceDepth,h=p===-1?C:C.slice(0,p+1),A=Math.min(h.length,d.length);for(let b=0;b<A;b++)(async()=>{const y=_e(h[b].file,d[b].line,d[b].column);y&&(y.content!=null&&(h[b].code=y.content),y.file!=null&&(h[b].file=y.file))})();o.setOperationName("CollectExceptions");const m=c.message?`${c.name}: ${c.message}`:c.name;l().sfDebug&&console.log("error message is : ",m);const Z=G.getInstance(),f=i.get(c);f?(Z.setTraceIdFor(f,f),Z.runWithSession(f,()=>{Z.setTraceId(f),o.doSend(m,h)})):o.doSend(m,h),I?G.getInstance().runWithSession(I,()=>{o.doSend(m,h)}):o.doSend(m,h)}}}),e.on("error",r=>{console.error("[Worker Error]",r)}),e.on("exit",r=>{console.error(`[Worker] Exited with code ${r}`)}),e.unref();const n=Error,s=new Set;function a(...r){const g=Reflect.construct(n,r);Reflect.setPrototypeOf(g,a.prototype);try{const I=G.getInstance().getTraceId();i.set(g,I)}catch{}n.captureStackTrace&&n.captureStackTrace(g,a);const c=`${g.message}:${g.stack?.split(`
51
+ `)[1]?.trim()}`;if(!s.has(c)){s.add(c),t=g;const I=G.getInstance().getTraceId();i.set(g,I),e.postMessage({type:"processException",error:g.message})}return g}a.prototype=Object.create(n.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf(a,n),globalThis.Error=a}function le(o){return o=(o=(o=o.replace(/^webpack:\/\/[^\/]+\/\.?\//,"")).replace(/^.*\/pages\//,"pages/")).replace(/\.(js|ts)$/,"")}function _e(o,e,t){const i=(function(s){s.startsWith("at ")&&(s=s.slice(3).trim());const a=s.match(/^(.*?)(:\d+)+(\.map)?$/);return a?a[1]:s})(o);if(!i||i==="<unknown>")return null;const n=i+".map";try{const s=ie.readFileSync(n,"utf-8");if(s){const a=JSON.parse(s);let r=new fe.sourceMapExports.SourceMapConsumer(a).originalPositionFor({line:e,column:t});if(i&&r.source){const g=le(i),c=a.sources.findIndex(I=>le(I)===g);if(c===-1)l().sfDebug&&console.log(`Source file "${i}" not found in the source map.`);else{const I=a.sourcesContent[c],d=a.names.join(",");if(I)return{content:I.split(`
52
+ `).slice(r.line-1,r.line+20).join(`
53
+ `),name:d,file:r.source};l().sfDebug&&console.log(`No source content available for file "${i}".`)}}return{content:a.sourcesContent[0],name:a.names[0],file:a.file}}}catch(s){l().sfDebug&&console.log(`Cant read/parse "${n}: Error - ".`,s)}return null}function Ee(o){return o?.split("/").pop()||"<unknown>"}function Be(o,e){if(!o||typeof o!="object")return!1;for(const t of Object.values(o))if(typeof t=="string"&&t.includes(e)||typeof t=="object"&&Be(t,e))return!0;return!1}let Ie=!1;function de(o){if(!o)return;const e=o.toLowerCase().trim();return!!["1","true","yes","on"].includes(e)||!["0","false","no","off"].includes(e)&&void 0}function M(o,e,t){return new Promise(i=>{try{const n=new URL(o),s=(n.protocol,B).request({method:"GET",hostname:n.hostname,port:n.port||(n.protocol==="https:"?443:80),path:n.pathname+(n.search||""),headers:e},a=>{a.resume(),a.statusCode&&a.statusCode>=200&&a.statusCode<400?i("ok"):i("http_error")});s.on("error",()=>i("error")),s.setTimeout(t,()=>{s.destroy(),i("timeout")}),s.end()}catch{i("error")}})}class De extends R{constructor(){super();u(this,"serviceIdentifier",new T);u(this,"supplementalFields",{});this.setOperationName("CollectExceptions")}setSupplementalFields(t){this.supplementalFields={...this.supplementalFields,...t}}normalizedSupplementalForGraphQL(){const{isFromLocalService:t}=this.supplementalFields,i={};return t!==void 0&&(i.isFromLocalService=t),i}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(t,i){this.sendAppIdentifier(),this.send(t,i)}async send(t,i){l().sfDebug&&console.log(" SENDING EXCEPTION...");const n=JSON.stringify(x.encode(i)),s=this.normalizedSupplementalForGraphQL(),a=this.getVariables({exceptionMessage:t,traceJson:n,reentrancyGuardPreactive:!1,library:l().packageLibraryType,version:l().version,...s});F(this.endpoint,this.operationName,this.getQuery(),a)}getQuery(){return`
38
54
  mutation ${this.operationName}(
39
55
  $apiKey: String!,
40
56
  $serviceUuid: String!,
@@ -45,7 +61,8 @@
45
61
  $library: String!,
46
62
  $timestampMs: String!,
47
63
  $version: String!,
48
- $isFromLocalService: Boolean
64
+ $isFromLocalService: Boolean,
65
+ $parentSpanId: String
49
66
  ) {
50
67
  ${this.queryName}(
51
68
  apiKey: $apiKey,
@@ -57,10 +74,11 @@
57
74
  library: $library,
58
75
  timestampMs: $timestampMs,
59
76
  version: $version,
60
- isFromLocalService: $isFromLocalService
77
+ isFromLocalService: $isFromLocalService,
78
+ parentSpanId: $parentSpanId
61
79
  )
62
80
  }
63
- `}}const Ee="getting request source code";var j=(i=>(i.UNKNOWN="unknown",i.ANONYMOUS="anonymous",i.NOT_CAPTURED="not captured",i))(j||{});const le="http:",ge="https:";let Ye=!1;function gn(){const i=A().sfDebug;if(Ye)return void(i&&console.log("[patchNodeHttpInbound] Already installed, skipping."));let t;Ye=!0;try{t=require("node:http"),i&&console.log("[patchNodeHttpInbound] node:http required successfully.")}catch(a){return void console.error("Failed to require node:http:",a)}if(!t?.Server?.prototype)return void(i&&console.log("[patchNodeHttpInbound] http.Server.prototype not found."));const s=t.Server.prototype,l=s.emit;l&&!s.__sf_inbound_patched__?(Object.defineProperty(s,"__sf_inbound_patched__",{value:!0,enumerable:!1,configurable:!1,writable:!1}),i&&console.log("[patchNodeHttpInbound] Patching http.Server.prototype.emit."),s.emit=function(a,...n){if(a!=="request")return i&&console.log(`[patchNodeHttpInbound] Passing through event: ${a}`),l.call(this,a,...n);const o=n[0],c=n[1],d=(function(I){const e={};if(!I)return e;for(const[r,h]of Object.entries(I))h!=null&&(Array.isArray(h)?e[r.toLowerCase()]=h.join(", "):e[r.toLowerCase()]=String(h));return e})(o?.headers),p=d["x-sf3-rid"];i&&(console.log("[patchNodeHttpInbound] Intercepted request event."),console.log("[patchNodeHttpInbound] Inbound headers:",d),console.log("[patchNodeHttpInbound] Trace header:",p));const C=w.getInstance();C.setTraceId(p);const g=C.getTraceId();return i&&console.log("[patchNodeHttpInbound] Context traceId set:",g),C.runWith({inboundHeaders:d,...p?{traceId:p}:{}},()=>{p&&C.setTraceId(p),i&&console.log("[patchNodeHttpInbound] Running request handler in context.");const I=()=>{i&&console.log("[patchNodeHttpInbound] Response finished/closed for traceId:",C.getTraceId())};return c.on("finish",I),c.on("close",I),l.call(this,a,o,c)})}):i&&console.log("[patchNodeHttpInbound] Already patched, skipping.")}class un extends de{constructor(){super(),this.setOperationName("DomainsToNotPassHeaderTo")}async doSend(t){this.sendAppIdentifier(),this.send(t)}async send(t){const s=`
81
+ `}}const ue="getting request source code";var z=(o=>(o.UNKNOWN="unknown",o.ANONYMOUS="anonymous",o.NOT_CAPTURED="not captured",o))(z||{});const j="http:",Q="https:";let Ce=!1;function Le(){const o=l().sfDebug;if(Ce)return void(o&&console.log("[patchNodeHttpInbound] Already installed, skipping."));let e;Ce=!0;try{e=require("node:http"),o&&console.log("[patchNodeHttpInbound] node:http required successfully.")}catch(n){return void console.error("Failed to require node:http:",n)}if(!e?.Server?.prototype)return void(o&&console.log("[patchNodeHttpInbound] http.Server.prototype not found."));const t=e.Server.prototype,i=t.emit;i&&!t.__sf_inbound_patched__?(Object.defineProperty(t,"__sf_inbound_patched__",{value:!0,enumerable:!1,configurable:!1,writable:!1}),o&&console.log("[patchNodeHttpInbound] Patching http.Server.prototype.emit."),t.emit=function(n,...s){if(n!=="request")return o&&console.log(`[patchNodeHttpInbound] Passing through event: ${n}`),i.call(this,n,...s);const a=s[0],r=s[1],g=(function(C){const p={};if(!C)return p;for(const[h,A]of Object.entries(C))A!=null&&(Array.isArray(A)?p[h.toLowerCase()]=A.join(", "):p[h.toLowerCase()]=String(A));return p})(a?.headers),c=g["x-sf3-rid"];o&&(console.log("[patchNodeHttpInbound] Intercepted request event."),console.log("[patchNodeHttpInbound] Inbound headers:",g),console.log("[patchNodeHttpInbound] Trace header:",c));const I=G.getInstance();I.setTraceId(c);const d=I.getTraceId();return o&&console.log("[patchNodeHttpInbound] Context traceId set:",d),I.runWith({inboundHeaders:g,...c?{traceId:c}:{}},()=>{c&&I.setTraceId(c),o&&console.log("[patchNodeHttpInbound] Running request handler in context.");const C=()=>{o&&console.log("[patchNodeHttpInbound] Response finished/closed for traceId:",I.getTraceId())};return r.on("finish",C),r.on("close",C),i.call(this,n,a,r)})}):o&&console.log("[patchNodeHttpInbound] Already patched, skipping.")}class ze extends oe{constructor(){super(),this.setOperationName("DomainsToNotPassHeaderTo")}async doSend(e){this.sendAppIdentifier(),this.send(e)}async send(e){const t=`
64
82
  ${this.queryType} ${this.operationName}(
65
83
  $apiKey: String!,
66
84
  $serviceUuid: String!,
@@ -72,7 +90,7 @@
72
90
  domains: $domains
73
91
  )
74
92
  }
75
- `,l={apiKey:this.apiKey,serviceUuid:this.serviceUUID,domains:t};H(this.endpoint,this.operationName,s,l)}}class dn extends E{constructor(){super();y(this,"serviceIdentifier",new D);this.setOperationName("CollectNetworkHops")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s){this.sendAppIdentifier(),this.send(s)}async send(s){const{name:l,column:a,line:n,entrypoint:o,retryWithoutTraceId:c}=s,d=this.getVariables({name:l,column:a,line:n,entrypoint:o,retryWithoutTraceId:c});H(this.endpoint,this.operationName,this.getQuery(),d)}getQuery(){return`
93
+ `,i={apiKey:this.apiKey,serviceUuid:this.serviceUUID,domains:e};F(this.endpoint,this.operationName,t,i)}}class xe extends R{constructor(){super();u(this,"serviceIdentifier",new T);this.setOperationName("CollectNetworkHops")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(t){this.sendAppIdentifier(),this.send(t)}async send(t){const{name:i,column:n,line:s,entrypoint:a,retryWithoutTraceId:r}=t,g=this.getVariables({name:i,column:n,line:s,entrypoint:a,retryWithoutTraceId:r});F(this.endpoint,this.operationName,this.getQuery(),g)}getQuery(){return`
76
94
  mutation ${this.operationName}(
77
95
  $apiKey: String!,
78
96
  $sessionId: String!,
@@ -96,15 +114,15 @@
96
114
  ${this.operationName==="CollectNetworkHops"?", retryWithoutTraceId: $retryWithoutTraceId":""}
97
115
  )
98
116
  }
99
- `}}class In extends E{constructor(){super();y(this,"serviceIdentifier",new D);this.setOperationName("CollectNetworkRequest")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s){this.sendAppIdentifier(),this.send(s)}getQuery(){return`
117
+ `}}class $e extends R{constructor(){super();u(this,"serviceIdentifier",new T);this.setOperationName("CollectNetworkRequest")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(t){this.sendAppIdentifier(),this.send(t)}getQuery(){return`
100
118
  mutation ${this.operationName}(
101
119
  $data: NetworkRequestInput!
102
120
  ) {
103
121
  ${this.queryName}(
104
122
  data: $data)
105
123
  }
106
- `}async send(s){const l={data:{...s}};await H(this.endpoint,this.operationName,this.getQuery(),l)}}const ue=[400,403];class pn{constructor(t=[]){y(this,"HEADER_TRACING","X-Sf3-Rid");y(this,"HEADER_LOG_GUARD","reentrancy_guard_logging_preactive");y(this,"HEADER_PRINT_GUARD","reentrancy_guard_print_preactive");y(this,"HEADER_EXCEPTION_GUARD","reentrancy_guard_exception_preactive");y(this,"contextManager");this.contextManager=w.getInstance(),t?.forEach(s=>{typeof s=="string"&&s.trim()&&this.contextManager.getExcludedDomains().add(s)}),A().sfDebug&&console.log("[RequestInterceptor] Initialized with static excluded domains.")}extractIdsFromTraceHeader(t,s=this.HEADER_TRACING){let l;if(t instanceof Headers)l=t.get(s)??void 0;else{const n=s.toLowerCase();for(const[o,c]of Object.entries(t))if(o.toLowerCase()===n){l=c;break}}if(!l)return{};const a=l.split("/").filter(Boolean);return a.length<3?{}:{sessionId:a[0],pageVisitId:a[1],requestId:a[a.length-1]}}parseStackFrame(t){const s=/\((.*):(\d+):(\d+)\)$/.exec(t.trim());if(!s)return null;const[,l,a,n]=s;return{filePath:l,line:parseInt(a,10),column:parseInt(n,10)}}async getOriginalPosition(t,s,l){let a={source:t,line:s,column:l,name:null};const n=t+".map";try{const o=JSON.parse(Fe.readFileSync(n,"utf-8"));let c=(await new De.SourceMapConsumer(o)).originalPositionFor({line:s,column:l});c.source&&(a=c)}catch(o){A().sfDebug&&console.error(`Could not read/parse map file at ${n}:`,o)}return{originalPos:a}}captureFirstUserLines(t,s=10,l=!1){const a=A().sfDebug?10:s,n=Error.stackTraceLimit;Error.stackTraceLimit=Math.max(n,a);const o=new Error(Ee);Ee in Error&&Error.captureStackTrace(o,this.captureFirstUserLines);const c=o.stack||"";Error.stackTraceLimit=n;const d=c.split(`
107
- `).slice(1),p=[];for(const C of d)if(!(C.includes("node:internal")||C.includes("internal/modules")||C.includes("internal/process")||C.includes("node_modules")||C.includes(".next/server/chunks")||C.includes("RequestInterceptor")||C.includes("contextManager")||C.includes("setupConfig"))&&(p.push(C.trim()),p.length>=s))break;for(const C of p){const g=this.parseStackFrame(C);g?(async()=>{const{originalPos:I}=await this.getOriginalPosition(g.filePath,g.line,g.column);if(I){A().sfDebug&&console.log("[RequestInterceptor] First user code line:",I);const e={line:I.line?.toString()||j.UNKNOWN,column:I.column?.toString()||j.NOT_CAPTURED,name:I.name||j.NOT_CAPTURED,entrypoint:I.source,retryWithoutTraceId:l};t.doSend(e)}})():A().sfDebug&&console.error("Could not parse stack line:",C)}}addReentrancyGuardHeaders(t){t.set(this.HEADER_LOG_GUARD,"true"),t.set(this.HEADER_PRINT_GUARD,"true"),t.set(this.HEADER_EXCEPTION_GUARD,"true")}shouldPropagateHeaders(t){return!Te.some(s=>new RegExp(`^${s.replace(/\*/g,".*")}$`).test(t))}addTracingHeaders(t,s){const l=new URL(s).hostname,a=this.shouldPropagateHeaders(l);return a?this.addTracingHeader(t,s):A().sfDebug&&console.error(`[RequestInterceptor] Excluded domain: ${l}`),a}addTracingHeader(t,s){const l=this.contextManager.getOrSetSfTraceId(),a=this.contextManager.getOrSetPageVisitUUID(),n=T();t.set(this.HEADER_TRACING,`${l}/${a}/${n}`),A().sfDebug&&console.log(`[RequestInterceptor] Added tracing header for ${s}`)}patchFetch(t,s){const l=globalThis.fetch;typeof l=="function"?globalThis.fetch=async(a,n)=>{this.captureFirstUserLines(t);const o=Date.now(),c=new Headers(n?.headers);let d;typeof a=="string"||a instanceof URL?d=a.toString():a instanceof Request?(d=a.url,a.headers.forEach((r,h)=>{c.set(h,r)})):A().sfDebug&&console.error("[Sailfish RequestInterceptor] Invalid fetch input."),A().sfDebug&&console.log("[RequestInterceptor] Fetching request to:",d);const p=new URL(d).hostname,C=new Headers(c),g=this.addTracingHeaders(c,d),I={...n,headers:c};let e;try{let r=!1;this.addTracingHeaders(C,d),e=await l(d,I),g&&ue.includes(e.status)?(e=await l(d,{...n,headers:C}),r=!0,this.captureFirstUserLines(t,10,r)):this.contextManager.addSupportedDomains(p);const h=Date.now();A().sfDebug&&console.log(`[RequestInterceptor] Fetch completed: ${d}, Status: ${e.status}, Duration: ${h-o}ms`);const{sessionId:u,pageVisitId:m,requestId:f}=this.extractIdsFromTraceHeader(c);return s.doSend({apiKey:A().apiKey,requestId:f,pageVisitId:m,recordingSessionId:u,serviceUuid:A().serviceUUID,timestampStart:o.toString(),timestampEnd:h.toString(),responseCode:e.status,success:!0,error:null,url:d,method:I.method||"GET",retryWithoutTraceId:r}),e}catch(r){const h=Date.now();A().sfDebug&&console.error(`[RequestInterceptor] Fetch failed: ${d}, Error: ${r}, Duration: ${h-o}ms`)}}:A().sfDebug&&console.error("[RequestInterceptor] Fetch not available.")}patchHttp(t,s){if(A().sfDebug&&console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."),!N||typeof N.request!="function")return void(A().sfDebug&&console.log("[RequestInterceptor] HTTP/HTTPS not available."));const l=N.request.bind(N),a=N.request.bind(N);N.request=function(n,o){let c;try{if(typeof n=="string"){const p=new URL(n);c={protocol:p.protocol||le,hostname:p.hostname,path:p.pathname+p.search,headers:{}}}else n instanceof URL?c={protocol:n.protocol||le,hostname:n.hostname,path:n.pathname+n.search,headers:{}}:(c={...n},c.protocol||(c.protocol=le));if(c.headers){const p=`${c.protocol}//${c.hostname}`;this.addTracingHeaders(c.headers,p),this.captureFirstUserLines(t)}else A().sfDebug&&console.warn("[RequestInterceptor] No headers found in HTTP request options. Skipping header addition.")}catch(p){throw A().sfDebug&&console.error("[RequestInterceptor] Error while processing HTTP request options:",p),p}let d=!1;return l(c,p=>{const C=`${c.protocol}//${c.hostname}`;if(c.headers&&this.shouldPropagateHeaders(new URL(C).hostname)&&ue.includes(p.statusCode||0)){c.hostname;const r={...c,headers:{...c.headers}};delete r.headers[this.HEADER_TRACING],l(r,o),d=!0,this.captureFirstUserLines(t,10,d)}const{sessionId:g,pageVisitId:I,requestId:e}=this.extractIdsFromTraceHeader(c.headers);s.doSend({apiKey:A().apiKey,requestId:e,pageVisitId:I,recordingSessionId:g,serviceUuid:A().serviceUUID,timestampStart:Date.now().toString(),timestampEnd:Date.now().toString(),responseCode:p.statusCode||0,success:!!p.statusCode&&p.statusCode<400,error:null,url:C,method:c.method||"GET",retryWithoutTraceId:d}),o?.(p)})},N.request=function(n,o){let c;try{if(typeof n=="string"){const p=new URL(n);c={protocol:p.protocol||ge,hostname:p.hostname,path:p.pathname+p.search,headers:{}}}else n instanceof URL?c={protocol:n.protocol||ge,hostname:n.hostname,path:n.pathname+n.search,headers:{}}:(c={...n},c.protocol||(c.protocol=ge));if(c.headers){const p=`${c.protocol}//${c.hostname}`;this.addTracingHeaders(c.headers,p)}else A().sfDebug&&console.warn("[RequestInterceptor] No headers found in HTTPS request options. Skipping header addition.")}catch(p){throw A().sfDebug&&console.error("[RequestInterceptor] Error while processing HTTPS request options:",p),p}let d=!1;return a(c,p=>{const C=`${c.protocol}//${c.hostname}`;if(c.headers&&this.shouldPropagateHeaders(new URL(C).hostname)&&ue.includes(p.statusCode||0)){const r={...c,headers:{...c.headers}};delete r.headers[this.HEADER_TRACING],a(r,o),d=!0,this.captureFirstUserLines(t,10,d)}const{sessionId:g,pageVisitId:I,requestId:e}=this.extractIdsFromTraceHeader(c.headers);s.doSend({apiKey:A().apiKey,requestId:e,pageVisitId:I,recordingSessionId:g,serviceUuid:A().serviceUUID,timestampStart:Date.now().toString(),timestampEnd:Date.now().toString(),responseCode:p.statusCode||0,success:!!p.statusCode&&p.statusCode<400,error:null,url:C,method:c.method||"GET",retryWithoutTraceId:d}),o?.(p)})},A().sfDebug&&console.log("✅ HTTP and HTTPS request methods patched globally.")}tryPatch(t,s){try{require.resolve(s),t(),console.log(`[RequestInterceptor] Patched ${s}`)}catch(l){console.warn(`[RequestInterceptor] Could not patch ${s}: ${l.message}`)}}getExcludedDomains(){return[...this.contextManager.getExcludedDomains()]}}class hn extends de{constructor(){super(),this.setOperationName("UpdateServiceDetails")}async doSend(){this.sendAppIdentifier(),this.send()}async send(){const t=`
124
+ `}async send(t){const i={data:{...t}};await F(this.endpoint,this.operationName,this.getQuery(),i)}}const q=[400,403];class ke{constructor(e=[]){u(this,"HEADER_TRACING","X-Sf3-Rid");u(this,"HEADER_LOG_GUARD","reentrancy_guard_logging_preactive");u(this,"HEADER_PRINT_GUARD","reentrancy_guard_print_preactive");u(this,"HEADER_EXCEPTION_GUARD","reentrancy_guard_exception_preactive");u(this,"contextManager");this.contextManager=G.getInstance(),e?.forEach(t=>{typeof t=="string"&&t.trim()&&this.contextManager.getExcludedDomains().add(t)}),l().sfDebug&&console.log("[RequestInterceptor] Initialized with static excluded domains.")}extractIdsFromTraceHeader(e,t=this.HEADER_TRACING){let i;if(e instanceof Headers)i=e.get(t)??void 0;else{const s=t.toLowerCase();for(const[a,r]of Object.entries(e))if(a.toLowerCase()===s){i=r;break}}if(!i)return{};const n=i.split("/").filter(Boolean);return n.length<3?{}:{sessionId:n[0],pageVisitId:n[1],requestId:n[n.length-1]}}parseStackFrame(e){const t=/\((.*):(\d+):(\d+)\)$/.exec(e.trim());if(!t)return null;const[,i,n,s]=t;return{filePath:i,line:parseInt(n,10),column:parseInt(s,10)}}async getOriginalPosition(e,t,i){let n={source:e,line:t,column:i,name:null};const s=e+".map";try{const a=JSON.parse(ie.readFileSync(s,"utf-8"));let r=(await new fe.sourceMapExports.SourceMapConsumer(a)).originalPositionFor({line:t,column:i});r.source&&(n=r)}catch(a){l().sfDebug&&console.error(`Could not read/parse map file at ${s}:`,a)}return{originalPos:n}}captureFirstUserLines(e,t=10,i=!1){const n=l().sfDebug?10:t,s=Error.stackTraceLimit;Error.stackTraceLimit=Math.max(s,n);const a=new Error(ue);ue in Error&&Error.captureStackTrace(a,this.captureFirstUserLines);const r=a.stack||"";Error.stackTraceLimit=s;const g=r.split(`
125
+ `).slice(1),c=[];for(const I of g)if(!(I.includes("node:internal")||I.includes("internal/modules")||I.includes("internal/process")||I.includes("node_modules")||I.includes(".next/server/chunks")||I.includes("RequestInterceptor")||I.includes("contextManager")||I.includes("setupConfig"))&&(c.push(I.trim()),c.length>=t))break;for(const I of c){const d=this.parseStackFrame(I);d?(async()=>{const{originalPos:C}=await this.getOriginalPosition(d.filePath,d.line,d.column);if(C){l().sfDebug&&console.log("[RequestInterceptor] First user code line:",C);const p={line:C.line?.toString()||z.UNKNOWN,column:C.column?.toString()||z.NOT_CAPTURED,name:C.name||z.NOT_CAPTURED,entrypoint:C.source,retryWithoutTraceId:i};e.doSend(p)}})():l().sfDebug&&console.error("Could not parse stack line:",I)}}addReentrancyGuardHeaders(e){e.set(this.HEADER_LOG_GUARD,"true"),e.set(this.HEADER_PRINT_GUARD,"true"),e.set(this.HEADER_EXCEPTION_GUARD,"true")}shouldPropagateHeaders(e){return!Ge.some(t=>new RegExp(`^${t.replace(/\*/g,".*")}$`).test(e))}addTracingHeaders(e,t){const i=new URL(t).hostname,n=this.shouldPropagateHeaders(i);return n?this.addTracingHeader(e,t):l().sfDebug&&console.error(`[RequestInterceptor] Excluded domain: ${i}`),n}addTracingHeader(e,t){const i=this.contextManager.getOrSetSfTraceId(),n=this.contextManager.getOrSetPageVisitUUID(),s=H();e.set(this.HEADER_TRACING,`${i}/${n}/${s}`),l().sfDebug&&console.log(`[RequestInterceptor] Added tracing header for ${t}`)}patchFetch(e,t){const i=globalThis.fetch;typeof i=="function"?globalThis.fetch=async(n,s)=>{this.captureFirstUserLines(e);const a=Date.now(),r=new Headers(s?.headers);let g;typeof n=="string"||n instanceof URL?g=n.toString():n instanceof Request?(g=n.url,n.headers.forEach((h,A)=>{r.set(A,h)})):l().sfDebug&&console.error("[Sailfish RequestInterceptor] Invalid fetch input."),l().sfDebug&&console.log("[RequestInterceptor] Fetching request to:",g);const c=new URL(g).hostname,I=new Headers(r),d=this.addTracingHeaders(r,g),C={...s,headers:r};let p;try{let h=!1;this.addTracingHeaders(I,g),p=await i(g,C),d&&q.includes(p.status)?(p=await i(g,{...s,headers:I}),h=!0,this.captureFirstUserLines(e,10,h)):this.contextManager.addSupportedDomains(c);const A=Date.now();l().sfDebug&&console.log(`[RequestInterceptor] Fetch completed: ${g}, Status: ${p.status}, Duration: ${A-a}ms`);const{sessionId:m,pageVisitId:Z,requestId:f}=this.extractIdsFromTraceHeader(r);return t.doSend({apiKey:l().apiKey,requestId:f,pageVisitId:Z,recordingSessionId:m,serviceUuid:l().serviceUUID,timestampStart:a.toString(),timestampEnd:A.toString(),responseCode:p.status,success:!0,error:null,url:g,method:C.method||"GET",retryWithoutTraceId:h,parentSpanId:L()}),p}catch(h){const A=Date.now();l().sfDebug&&console.error(`[RequestInterceptor] Fetch failed: ${g}, Error: ${h}, Duration: ${A-a}ms`)}}:l().sfDebug&&console.error("[RequestInterceptor] Fetch not available.")}patchHttp(e,t){if(l().sfDebug&&console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."),!B||typeof B.request!="function")return void(l().sfDebug&&console.log("[RequestInterceptor] HTTP/HTTPS not available."));const i=B.request.bind(B),n=B.request.bind(B);B.request=function(s,a){let r;try{if(typeof s=="string"){const c=new URL(s);r={protocol:c.protocol||j,hostname:c.hostname,path:c.pathname+c.search,headers:{}}}else s instanceof URL?r={protocol:s.protocol||j,hostname:s.hostname,path:s.pathname+s.search,headers:{}}:(r={...s},r.protocol||(r.protocol=j));if(r.headers){const c=`${r.protocol}//${r.hostname}`;this.addTracingHeaders(r.headers,c),this.captureFirstUserLines(e)}else l().sfDebug&&console.warn("[RequestInterceptor] No headers found in HTTP request options. Skipping header addition.")}catch(c){throw l().sfDebug&&console.error("[RequestInterceptor] Error while processing HTTP request options:",c),c}let g=!1;return i(r,c=>{const I=`${r.protocol}//${r.hostname}`;if(r.headers&&this.shouldPropagateHeaders(new URL(I).hostname)&&q.includes(c.statusCode||0)){r.hostname;const h={...r,headers:{...r.headers}};delete h.headers[this.HEADER_TRACING],i(h,a),g=!0,this.captureFirstUserLines(e,10,g)}const{sessionId:d,pageVisitId:C,requestId:p}=this.extractIdsFromTraceHeader(r.headers);t.doSend({apiKey:l().apiKey,requestId:p,pageVisitId:C,recordingSessionId:d,serviceUuid:l().serviceUUID,timestampStart:Date.now().toString(),timestampEnd:Date.now().toString(),responseCode:c.statusCode||0,success:!!c.statusCode&&c.statusCode<400,error:null,url:I,method:r.method||"GET",retryWithoutTraceId:g,parentSpanId:L()}),a?.(c)})},B.request=function(s,a){let r;try{if(typeof s=="string"){const c=new URL(s);r={protocol:c.protocol||Q,hostname:c.hostname,path:c.pathname+c.search,headers:{}}}else s instanceof URL?r={protocol:s.protocol||Q,hostname:s.hostname,path:s.pathname+s.search,headers:{}}:(r={...s},r.protocol||(r.protocol=Q));if(r.headers){const c=`${r.protocol}//${r.hostname}`;this.addTracingHeaders(r.headers,c)}else l().sfDebug&&console.warn("[RequestInterceptor] No headers found in HTTPS request options. Skipping header addition.")}catch(c){throw l().sfDebug&&console.error("[RequestInterceptor] Error while processing HTTPS request options:",c),c}let g=!1;return n(r,c=>{const I=`${r.protocol}//${r.hostname}`;if(r.headers&&this.shouldPropagateHeaders(new URL(I).hostname)&&q.includes(c.statusCode||0)){const h={...r,headers:{...r.headers}};delete h.headers[this.HEADER_TRACING],n(h,a),g=!0,this.captureFirstUserLines(e,10,g)}const{sessionId:d,pageVisitId:C,requestId:p}=this.extractIdsFromTraceHeader(r.headers);t.doSend({apiKey:l().apiKey,requestId:p,pageVisitId:C,recordingSessionId:d,serviceUuid:l().serviceUUID,timestampStart:Date.now().toString(),timestampEnd:Date.now().toString(),responseCode:c.statusCode||0,success:!!c.statusCode&&c.statusCode<400,error:null,url:I,method:r.method||"GET",retryWithoutTraceId:g,parentSpanId:L()}),a?.(c)})},l().sfDebug&&console.log("✅ HTTP and HTTPS request methods patched globally.")}tryPatch(e,t){try{require.resolve(t),e(),console.log(`[RequestInterceptor] Patched ${t}`)}catch(i){console.warn(`[RequestInterceptor] Could not patch ${t}: ${i.message}`)}}getExcludedDomains(){return[...this.contextManager.getExcludedDomains()]}}class Oe extends oe{constructor(){super(),this.setOperationName("UpdateServiceDetails")}async doSend(){this.sendAppIdentifier(),this.send()}async send(){const e=`
108
126
  ${this.queryType} ${this.operationName}(
109
127
  $apiKey: String!,
110
128
  $serviceUuid: String!,
@@ -112,7 +130,7 @@
112
130
  $serviceIdentifier: String,
113
131
  $serviceVersion: String,
114
132
  $serviceAdditionalMetadata: JSON,
115
-
133
+ $gitSha: String!,
116
134
  ) {
117
135
  ${this.queryName}(
118
136
  apiKey: $apiKey,
@@ -121,7 +139,7 @@
121
139
  serviceIdentifier: $serviceIdentifier,
122
140
  serviceVersion: $serviceVersion,
123
141
  serviceAdditionalMetadata: $serviceAdditionalMetadata,
124
-
142
+ gitSha: $gitSha,
125
143
  )
126
144
  }
127
- `,s=this.getVariables({serviceIdentifier:A().serviceIdentifier,serviceVersion:A().serviceVersion,serviceAdditionalMetadata:A().serviceAdditionalMetadata});H(this.endpoint,this.operationName,t,s)}}exports.ContextManager=w,exports.addOrUpdateMetadata=function(i,t={},s,l=!1){const a=A();new me(a.apiKey).addOrUpdateMetadata(i,t,s,l)},exports.identify=function(i,t,s,l=!1){const a=A();new me(a.apiKey).identify(i,t,s,l)},exports.runWithContext=function(i){const t={...w.getInstance().getCurrentContext()};X.run(t,()=>{i()})},exports.setupInterceptors=function(i){if(!i||!i.apiKey){const a=`The required API Key is not provided: ${JSON.stringify(i)}`;console.error(a)}const{config:t}=je(i);if(t.sfDebug&&console.log("Updated configuration after applying options:",t),!t.apiKey||!t.apiGraphqlEndpoint){const a=`The required config is not provided: ${JSON.stringify(t)}`;throw console.error(a),new Error(a)}const s=new de;s.setServiceUUID(t.serviceUUID),(function(a){function n(g,I){a.setOperationName("CollectLogs"),a.doSend([I,g])}const o=console.log.bind(console),c=console.error.bind(console),d=console.warn.bind(console),p=console.info.bind(console),C=console.debug.bind(console);console.log=(...g)=>{n("INFO",g.join(" ")),o(...g)},console.error=(...g)=>{n("ERROR",g.join(" ")),c(...g)},console.warn=(...g)=>{n("WARN",g.join(" ")),d(...g)},console.info=(...g)=>{n("INFO",g.join(" ")),p(...g)},A().logLevel==="DEBUG"&&(console.debug=(...g)=>{n("DEBUG",g.join(" ")),C(...g)})})(s),(function(a=[]){const n=new pn(a);new un().doSend(n.getExcludedDomains());const o=new dn,c=new In;n.patchFetch(o,c),n.patchHttp(o,c)})(t.domainsToNotPropagateHeadersTo);const l=new ln;l.setServiceUUID(t.serviceUUID),sn(l),gn(),new hn().send()};
145
+ `,t=this.getVariables({serviceIdentifier:l().serviceIdentifier,serviceVersion:l().serviceVersion,serviceAdditionalMetadata:l().serviceAdditionalMetadata,gitSha:l().gitSha||""});F(this.endpoint,this.operationName,e,t)}}function Ne(){return{capture_arguments:w(process.env.SF_FUNCSPAN_CAPTURE_ARGUMENTS,!0),capture_return_value:w(process.env.SF_FUNCSPAN_CAPTURE_RETURN_VALUE,!0),arg_limit_mb:parseInt(process.env.SF_FUNCSPAN_ARG_LIMIT_MB||"1",10),return_limit_mb:parseInt(process.env.SF_FUNCSPAN_RETURN_LIMIT_MB||"1",10),autocapture_all_child_functions:w(process.env.SF_FUNCSPAN_AUTOCAPTURE_ALL_CHILD_FUNCTIONS,!1),sample_rate:parseFloat(process.env.SF_FUNCSPAN_SAMPLE_RATE||"1.0"),enable_sampling:w(process.env.SF_FUNCSPAN_ENABLE_SAMPLING,!1),capture_sf_veritas:w(process.env.SF_FUNCSPAN_CAPTURE_SF_VERITAS,!1),parse_json_strings:w(process.env.SF_FUNCSPAN_PARSE_JSON_STRINGS,!1)}}function Pe(){return{capture_arguments:!1,capture_return_value:!1,arg_limit_mb:1,return_limit_mb:1,autocapture_all_child_functions:!1,sample_rate:1,enable_sampling:!1,capture_sf_veritas:!1,parse_json_strings:!1}}function pe(o){try{const e=o.split("-");return e.length!==9?(console.error(`[FuncSpan] Invalid header format: expected 9 parts, got ${e.length}`),null):{capture_arguments:e[0]==="1",capture_return_value:e[1]==="1",arg_limit_mb:parseInt(e[2],10),return_limit_mb:parseInt(e[3],10),autocapture_all_child_functions:e[4]==="1",sample_rate:parseFloat(e[5]),enable_sampling:e[6]==="1",capture_sf_veritas:e[7]==="1",parse_json_strings:e[8]==="1"}}catch(e){return console.error(`[FuncSpan] Failed to parse header override "${o}":`,e),null}}function w(o,e){if(!o)return e;const t=o.toLowerCase();return t==="true"||t==="1"||t==="yes"}const te=new ne.AsyncLocalStorage;function he(){return te.getStore()}function E(...o){const e={};for(const t of o)for(const i in t)t[i]!==void 0&&(e[i]=t[i]);return e}function ee(o,e){try{const t=JSON.stringify(o).length/1048576;return t<=e?o:{_truncated:!0,_originalSizeMB:t.toFixed(2),_limitMB:e,_preview:JSON.stringify(o).substring(0,500)+"..."}}catch{return{_error:"Failed to serialize data",_type:typeof o}}}class Me{constructor(e=[process.cwd()],t=!1){u(this,"rootPaths");u(this,"fileConfigs",new Map);u(this,"functionConfigs",new Map);u(this,"directoryConfigs",new Map);u(this,"hasSailfishFiles",!1);u(this,"debug");this.rootPaths=e,this.debug=t||process.env.SF_DEBUG==="true"}async loadAllConfigs(){this.debug&&console.log("[FuncSpan ConfigLoader] Scanning for .sailfish files in:",this.rootPaths);const e=[];for(const t of this.rootPaths)k.existsSync(t)?await this._walkDirectory(t,e):this.debug&&console.log(`[FuncSpan ConfigLoader] Root path does not exist: ${t}`);e.length>0?(this.hasSailfishFiles=!0,this.debug&&(console.log(`[FuncSpan ConfigLoader] Found ${e.length} .sailfish files:`),e.forEach(t=>console.log(`[FuncSpan ConfigLoader] - ${t}`)))):this.debug&&console.log("[FuncSpan ConfigLoader] No .sailfish files found - function spans disabled by default");for(const t of e)await this._loadConfigFile(t);await this._resolveInheritance(),this.debug&&console.log(`[FuncSpan ConfigLoader] Loaded ${this.fileConfigs.size} file configs, ${this.functionConfigs.size} function configs`)}getConfig(e,t){const i=this.hasSailfishFiles?Ne():{capture_arguments:!1,capture_return_value:!1,arg_limit_mb:1,return_limit_mb:1,autocapture_all_child_functions:!1,sample_rate:1,enable_sampling:!1,capture_sf_veritas:!1,parse_json_strings:!1},n=this._getDirectoryConfig(e),s=v.normalize(e),a=this.fileConfigs.get(s)||{};let r={};if(t){const g=this.functionConfigs.get(s);g&&(r=g.get(t)||{})}return E(i,n,a,r)}async _walkDirectory(e,t){try{const i=k.readdirSync(e,{withFileTypes:!0});for(const n of i){const s=v.join(e,n.name);n.name==="node_modules"||n.name===".git"||n.name.startsWith(".")||(n.isDirectory()?await this._walkDirectory(s,t):n.name===".sailfish"&&t.push(s))}}catch(i){this.debug&&console.error(`[FuncSpan ConfigLoader] Error walking directory ${e}:`,i)}}async _loadConfigFile(e){try{const t=k.readFileSync(e,"utf-8"),i=v.dirname(e);let n=null;try{n=JSON.parse(t)}catch{try{n=require("js-yaml").load(t)}catch(s){return void(this.debug&&console.error(`[FuncSpan ConfigLoader] Failed to parse ${e} as JSON or YAML:`,s))}}if(!n)return;n.default&&this.directoryConfigs.set(i,n.default),n.files&&await this._expandFileGlobs(i,n.files,n.default||{}),n.functions&&this._storeFunctionConfigs(i,n.functions,n.default||{}),this.debug&&(console.log(`[FuncSpan ConfigLoader] Loaded config from ${e}`),console.log(`[FuncSpan ConfigLoader] Directory: ${i}`),console.log(`[FuncSpan ConfigLoader] Has default: ${!!n.default}`),console.log(`[FuncSpan ConfigLoader] File patterns: ${Object.keys(n.files||{}).length}`),console.log(`[FuncSpan ConfigLoader] Functions: ${Object.keys(n.functions||{}).length}`))}catch(t){this.debug&&console.error(`[FuncSpan ConfigLoader] Error loading ${e}:`,t)}}async _expandFileGlobs(e,t,i){for(const[n,s]of Object.entries(t))try{const a=v.join(e,n),r=await He.glob(a,{absolute:!0,nodir:!0,ignore:["**/node_modules/**","**/.git/**"]});this.debug&&console.log(`[FuncSpan ConfigLoader] Pattern '${n}' matched ${r.length} files`);for(const g of r){const c=v.normalize(g),I=E(i,s);this.fileConfigs.set(c,I),this.debug&&r.length<=5&&console.log(`[FuncSpan ConfigLoader] - ${g}`)}}catch(a){this.debug&&console.error(`[FuncSpan ConfigLoader] Error expanding glob '${n}':`,a)}}_storeFunctionConfigs(e,t,i){for(const[n,s]of Object.entries(t)){const a=n.split("::");if(a.length!==2){this.debug&&console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${n}' (expected format: 'file.ts::functionName')`);continue}const[r,g]=a,c=v.normalize(v.join(e,r));this.functionConfigs.has(c)||this.functionConfigs.set(c,new Map);const I=this.functionConfigs.get(c),d=E(i,s);I.set(g,d),this.debug&&console.log(`[FuncSpan ConfigLoader] Function config: ${c}::${g}`)}}async _resolveInheritance(){}_getDirectoryConfig(e){let t=v.dirname(v.normalize(e));const i=[];for(;t&&t!==v.dirname(t);){const n=this.directoryConfigs.get(t);n&&i.unshift(n),t=v.dirname(t)}return i.reduce((n,s)=>E(n,s),{})}}let J=null;async function Ae(o,e){J=new Me(o,e),await J.loadAllConfigs()}function be(o,e){return J?J.getConfig(o,e):{capture_arguments:!1,capture_return_value:!1,arg_limit_mb:1,return_limit_mb:1,autocapture_all_child_functions:!1,sample_rate:1,enable_sampling:!1,capture_sf_veritas:!1,parse_json_strings:!1}}function me(){return J!==null}function D(o){process.env.SF_VERITAS_DEBUG==="true"&&console.log("[FuncSpan Capture]",{function:o.functionName,file:o.filePath,duration:`${o.duration}ms`,async:o.async,error:o.error}),ve(()=>{})}exports.ContextManager=G,exports.addOrUpdateMetadata=function(o,e={},t,i=!1){const n=l();new ge(n.apiKey).addOrUpdateMetadata(o,e,t,i)},exports.captureFunctionSpan=function(o,e,t,i){const n=function(...s){const a=(function(C,p){const h=he();if(h){const A=pe(h);if(A)return process.env.SF_DEBUG==="true"&&console.log(`[FuncSpan] Using HTTP header override for ${C}::${p}`),A}return be(C,p)})(t,e);if(a.enable_sampling&&a.sample_rate<1&&Math.random()>a.sample_rate)return o.apply(this,s);if(a.sample_rate===0)return o.apply(this,s);const r=G.getInstance(),g=r.getCurrentFunctionSpanId(),c=H();r.setCurrentFunctionSpanId(c);const I=Date.now();let d=null;a.capture_arguments&&(d={},i.paramNames.forEach((C,p)=>{p<s.length&&(d[C]=s[p])}),d&&a.arg_limit_mb>0&&(d=ee(d,a.arg_limit_mb)));try{const C=o.apply(this,s);if(C&&typeof C.then=="function")return C.then(A=>{const m=Date.now();let Z=null;return a.capture_return_value&&a.return_limit_mb>0&&(Z=ee(A,a.return_limit_mb)),D({functionName:e,filePath:t,metadata:i,args:d,result:Z,error:null,duration:m-I,async:!0,spanId:c}),g?r.setCurrentFunctionSpanId(g):r.clearCurrentFunctionSpanId(),A},A=>{const m=Date.now();throw D({functionName:e,filePath:t,metadata:i,args:d,result:null,error:A?.message||String(A),duration:m-I,async:!0,spanId:c}),g?r.setCurrentFunctionSpanId(g):r.clearCurrentFunctionSpanId(),A});const p=Date.now();let h=null;return a.capture_return_value&&a.return_limit_mb>0&&(h=ee(C,a.return_limit_mb)),D({functionName:e,filePath:t,metadata:i,args:d,result:h,error:null,duration:p-I,async:!1,spanId:c}),g?r.setCurrentFunctionSpanId(g):r.clearCurrentFunctionSpanId(),C}catch(C){const p=Date.now();throw D({functionName:e,filePath:t,error:C?.message||String(C),duration:p-I,async:!1}),g?r.setCurrentFunctionSpanId(g):r.clearCurrentFunctionSpanId(),C}};Object.defineProperty(n,"name",{value:e,writable:!1});for(const s in o)o.hasOwnProperty(s)&&(n[s]=o[s]);return n},exports.clearFuncspanOverride=function(){te.enterWith(void 0)},exports.getCurrentFunctionSpanId=L,exports.getDefaultConfig=Pe,exports.getEnvConfig=Ne,exports.getFuncspanOverride=he,exports.getGlobalConfig=be,exports.identify=function(o,e,t,i=!1){const n=l();new ge(n.apiKey).identify(o,e,t,i)},exports.initializeConfigLoader=Ae,exports.isConfigLoaderInitialized=me,exports.parseHeaderOverride=pe,exports.runWithContext=ve,exports.setFuncspanOverride=function(o){te.enterWith(o)},exports.setupInterceptors=function(o){if(!o||!o.apiKey){const n=`The required API Key is not provided: ${JSON.stringify(o)}`;console.error(n)}const{config:e}=Ke(o);if(e.sfDebug&&console.log("Updated configuration after applying options:",e),!e.apiKey||!e.apiGraphqlEndpoint){const n=`The required config is not provided: ${JSON.stringify(e)}`;throw console.error(n),new Error(n)}me()||Ae(void 0,e.sfDebug).catch(n=>{e.sfDebug&&console.error("[FuncSpan] Failed to initialize config loader:",n)});const t=new oe;t.setServiceUUID(e.serviceUUID),(function(n){function s(d,C){n.setOperationName("CollectLogs"),n.doSend([C,d])}const a=console.log.bind(console),r=console.error.bind(console),g=console.warn.bind(console),c=console.info.bind(console),I=console.debug.bind(console);console.log=(...d)=>{s("INFO",d.join(" ")),a(...d)},console.error=(...d)=>{s("ERROR",d.join(" ")),r(...d)},console.warn=(...d)=>{s("WARN",d.join(" ")),g(...d)},console.info=(...d)=>{s("INFO",d.join(" ")),c(...d)},l().logLevel==="DEBUG"&&(console.debug=(...d)=>{s("DEBUG",d.join(" ")),I(...d)})})(t),(function(n=[]){const s=new ke(n);new ze().doSend(s.getExcludedDomains());const a=new xe,r=new $e;s.patchFetch(a,r),s.patchHttp(a,r)})(e.domainsToNotPropagateHeadersTo);const i=new De;i.setServiceUUID(e.serviceUUID),Te(i),Le(),new Oe().send()};