@sailfish-ai/sf-veritas 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,36 +1,36 @@
1
- var Yt = Object.defineProperty;
2
- var Zt = (t, n, e) => n in t ? Yt(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
- var D = (t, n, e) => Zt(t, typeof n != "symbol" ? n + "" : n, e);
4
- import { g as m, C as Q, D as en, v as ce, b as K, N as tn, c as nn, d as rn, a as on } from "./contextManager-BSAjnoti.js";
5
- import { r as Qr } from "./contextManager-BSAjnoti.js";
6
- import { B as oe, n as W, f as sn, g as Le, p as Re, a as Pt, b as an, m as pe, c as Se, i as Ye, d as cn, e as fe, s as un, h as ln, j as Ft, k as Tt, l as dn, r as pn, o as fn, q as hn, t as Ze, F as gn } from "./workerPoolSpanCapture-SpiqdLu-.js";
7
- import { u as Vr, v as Gr } from "./workerPoolSpanCapture-SpiqdLu-.js";
8
- import { a as yn, C as mn, i as L, b as Sn, c as Ct, d as bn, e as vn } from "./runtimeConfig-Dmaavj6j.js";
9
- import { f as Xr, g as Yr, s as Zr } from "./runtimeConfig-Dmaavj6j.js";
10
- import { createRequire as In } from "node:module";
11
- import * as En from "fs";
12
- import { readFileSync as _n, appendFileSync as wn } from "fs";
1
+ var Zt = Object.defineProperty;
2
+ var en = (t, n, e) => n in t ? Zt(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
+ var D = (t, n, e) => en(t, typeof n != "symbol" ? n + "" : n, e);
4
+ import { g as y, C as Q, D as tn, v as ce, b as K, N as nn, c as rn, d as on, a as sn } from "./contextManager-BSAjnoti.js";
5
+ import { r as Wr } from "./contextManager-BSAjnoti.js";
6
+ import { B as oe, n as W, f as an, g as Re, p as Be, a as Ft, b as cn, m as pe, c as Se, i as Ze, d as un, e as fe, s as ln, h as dn, j as Tt, k as Ct, l as pn, r as fn, o as hn, q as gn, t as et, F as yn } from "./workerPoolSpanCapture-SpiqdLu-.js";
7
+ import { u as Gr, v as zr } from "./workerPoolSpanCapture-SpiqdLu-.js";
8
+ import { a as mn, C as Sn, i as R, b as bn, c as At, d as vn, e as In } from "./runtimeConfig-Dmaavj6j.js";
9
+ import { f as Yr, g as Zr, s as eo } from "./runtimeConfig-Dmaavj6j.js";
10
+ import { createRequire as En } from "node:module";
11
+ import * as _n from "fs";
12
+ import { readFileSync as $n, appendFileSync as wn } from "fs";
13
13
  import G from "http";
14
14
  import he from "https";
15
- import { s as $n } from "./source-map-Cr6YkjTd.js";
16
- import * as et from "fs/promises";
17
- import * as R from "path";
18
- import { glob as kn, globSync as Nn } from "glob";
19
- import { AsyncLocalStorage as Un } from "async_hooks";
20
- import { AsyncLocalStorage as Dn } from "node:async_hooks";
15
+ import { s as kn } from "./source-map-Cr6YkjTd.js";
16
+ import * as tt from "fs/promises";
17
+ import * as B from "path";
18
+ import { glob as Nn, globSync as Un } from "glob";
19
+ import { AsyncLocalStorage as Dn } from "async_hooks";
20
+ import { AsyncLocalStorage as Pn } from "node:async_hooks";
21
21
  import * as ie from "node:path";
22
- import { randomUUID as At } from "crypto";
22
+ import { randomUUID as qt } from "crypto";
23
23
  import { threadId as ge } from "worker_threads";
24
- import { s as to, t as no, a as ro } from "./funcSpanTransformer-S_WeAt_m.js";
24
+ import { s as no, t as ro, a as oo } from "./funcSpanTransformer-S_WeAt_m.js";
25
25
  class de extends oe {
26
26
  constructor() {
27
27
  super(), this.setOperationName("IdentifyServiceDetails");
28
28
  }
29
29
  async doSend(n) {
30
- if (!m().serviceIdentificationReceived) try {
30
+ if (!y().serviceIdentificationReceived) try {
31
31
  this.send();
32
32
  } catch (e) {
33
- m().sfDebug && console.error(" Error during service identification:", e);
33
+ y().sfDebug && console.error(" Error during service identification:", e);
34
34
  }
35
35
  }
36
36
  async send() {
@@ -74,11 +74,11 @@ class de extends oe {
74
74
  dataSensitivityLevel: $dataSensitivityLevel,
75
75
  )
76
76
  }
77
- `, e = m(), o = this.getVariables({ serviceIdentifier: e.serviceIdentifier, serviceVersion: e.serviceVersion, library: e.packageLibraryType, version: e.version, serviceAdditionalMetadata: e.serviceAdditionalMetadata, gitSha: e.gitSha || "", gitOrg: e.gitOrg || void 0, gitRepo: e.gitRepo || void 0, gitProvider: e.gitProvider || void 0, serviceDisplayName: e.serviceDisplayName || void 0, framework: e.framework || void 0, additionalFrameworks: e.additionalFrameworks.length > 0 ? e.additionalFrameworks : void 0, serviceRole: e.serviceRole || void 0 });
77
+ `, e = y(), o = this.getVariables({ serviceIdentifier: e.serviceIdentifier, serviceVersion: e.serviceVersion, library: e.packageLibraryType, version: e.version, serviceAdditionalMetadata: e.serviceAdditionalMetadata, gitSha: e.gitSha || "", gitOrg: e.gitOrg || void 0, gitRepo: e.gitRepo || void 0, gitProvider: e.gitProvider || void 0, serviceDisplayName: e.serviceDisplayName || void 0, framework: e.framework || void 0, additionalFrameworks: e.additionalFrameworks.length > 0 ? e.additionalFrameworks : void 0, serviceRole: e.serviceRole || void 0 });
78
78
  W(this.endpoint, this.operationName, n, o);
79
79
  }
80
80
  }
81
- class Pn extends oe {
81
+ class Fn extends oe {
82
82
  constructor() {
83
83
  super();
84
84
  D(this, "serviceIdentifier", new de());
@@ -89,7 +89,7 @@ class Pn extends oe {
89
89
  if (this.identifyStarted) return;
90
90
  this.identifyStarted = !0, this.serviceIdentifier.doSend({});
91
91
  const e = setInterval(() => {
92
- m().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
92
+ y().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
93
93
  }, 5e3);
94
94
  e && typeof e == "object" && "unref" in e && e.unref();
95
95
  }
@@ -100,10 +100,10 @@ class Pn extends oe {
100
100
  if (!o && !i) throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');
101
101
  let d = [];
102
102
  if (!i) {
103
- const a = yn(o);
103
+ const a = mn(o);
104
104
  i = a.traitsJson, d = a.excludedFields;
105
105
  }
106
- const u = this.getVariables({ userId: e, traitsJson: i, excludedFields: d, override: r, library: m().packageLibraryType, version: m().version });
106
+ const u = this.getVariables({ userId: e, traitsJson: i, excludedFields: d, override: r, library: y().packageLibraryType, version: y().version });
107
107
  W(this.endpoint, this.operationName, this.getQuery(), u);
108
108
  }
109
109
  getQuery() {
@@ -114,20 +114,20 @@ class Pn extends oe {
114
114
  `;
115
115
  }
116
116
  }
117
- class qt {
117
+ class Lt {
118
118
  constructor(n) {
119
119
  D(this, "metadataTransmitter");
120
- this.apiKey = n, this.metadataTransmitter = new Pn();
120
+ this.apiKey = n, this.metadataTransmitter = new Fn();
121
121
  }
122
122
  identify(n, e, o, r = !1) {
123
123
  e || o ? this.addOrUpdateMetadata(n, e, o, r) : this.addOrUpdateMetadata(n, {}, void 0, r);
124
124
  }
125
125
  addOrUpdateMetadata(n, e = {}, o, r = !1) {
126
126
  if (!e && !o) throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');
127
- m().sfDebug && console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"), m().sfDebug && console.log(" addOrUpdateMetadata...SENDING DATA...", n, e, o), this.metadataTransmitter.doSend(n, e, r, o);
127
+ y().sfDebug && console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"), y().sfDebug && console.log(" addOrUpdateMetadata...SENDING DATA...", n, e, o), this.metadataTransmitter.doSend(n, e, r, o);
128
128
  }
129
129
  }
130
- class ze extends oe {
130
+ class Xe extends oe {
131
131
  constructor() {
132
132
  super();
133
133
  D(this, "serviceIdentifier", new de());
@@ -137,7 +137,7 @@ class ze extends oe {
137
137
  if (this.identifyStarted) return;
138
138
  this.identifyStarted = !0, this.serviceIdentifier.doSend({});
139
139
  const e = setInterval(() => {
140
- m().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
140
+ y().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
141
141
  }, 5e3);
142
142
  e && typeof e == "object" && "unref" in e && e.unref();
143
143
  }
@@ -149,7 +149,7 @@ class ze extends oe {
149
149
  const o = Array.isArray(e) ? e : [e, "default", null, null], r = this.getVariables({ contents: o[0], level: o[1], sourceFile: o[2] || void 0, sourceLine: o[3] || void 0 });
150
150
  W(this.endpoint, this.operationName, this.getQuery(), r);
151
151
  } catch (o) {
152
- m().sfDebug && console.error("🚨 Error in send():", o);
152
+ y().sfDebug && console.error("🚨 Error in send():", o);
153
153
  }
154
154
  }
155
155
  getQuery() {
@@ -182,10 +182,10 @@ class ze extends oe {
182
182
  `;
183
183
  }
184
184
  }
185
- function Fn(t) {
185
+ function Tn(t) {
186
186
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
187
187
  }
188
- class Tn extends oe {
188
+ class Cn extends oe {
189
189
  constructor() {
190
190
  super();
191
191
  D(this, "serviceIdentifier", new de());
@@ -204,7 +204,7 @@ class Tn extends oe {
204
204
  if (this.identifyStarted) return;
205
205
  this.identifyStarted = !0, this.serviceIdentifier.doSend({});
206
206
  const e = setInterval(() => {
207
- m().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
207
+ y().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
208
208
  }, 5e3);
209
209
  e && typeof e == "object" && "unref" in e && e.unref();
210
210
  }
@@ -212,8 +212,8 @@ class Tn extends oe {
212
212
  this.startBackgroundIdentify(), this.send(e, o);
213
213
  }
214
214
  async send(e, o) {
215
- m().sfDebug && console.log(" SENDING EXCEPTION...");
216
- const r = JSON.stringify(mn.encode(o)), i = this.normalizedSupplementalForGraphQL(), d = this.getVariables({ exceptionMessage: e, traceJson: r, reentrancyGuardPreactive: !1, library: m().packageLibraryType, version: m().version, ...i });
215
+ y().sfDebug && console.log(" SENDING EXCEPTION...");
216
+ const r = JSON.stringify(Sn.encode(o)), i = this.normalizedSupplementalForGraphQL(), d = this.getVariables({ exceptionMessage: e, traceJson: r, reentrancyGuardPreactive: !1, library: y().packageLibraryType, version: y().version, ...i });
217
217
  W(this.endpoint, this.operationName, this.getQuery(), d);
218
218
  }
219
219
  getQuery() {
@@ -250,57 +250,57 @@ class Tn extends oe {
250
250
  `;
251
251
  }
252
252
  }
253
- const se = "X-Sf3-Rid", tt = "X-Sf4-Prid", nt = "getting request source code";
253
+ const se = "X-Sf3-Rid", nt = "X-Sf4-Prid", rt = "getting request source code";
254
254
  var be = ((t) => (t.UNKNOWN = "unknown", t.ANONYMOUS = "anonymous", t.NOT_CAPTURED = "not captured", t))(be || {});
255
- const rt = "http:", Cn = In(import.meta.url);
256
- let ot = !1;
257
- function An() {
258
- const t = m().sfDebug;
259
- if (ot) return void (t && L("[patchNodeHttpInbound] Already installed, skipping."));
255
+ const we = "http:", ot = "https:", An = En(import.meta.url);
256
+ let st = !1;
257
+ function qn() {
258
+ const t = y().sfDebug;
259
+ if (st) return void (t && R("[patchNodeHttpInbound] Already installed, skipping."));
260
260
  let n;
261
- ot = !0;
261
+ st = !0;
262
262
  try {
263
- n = Cn("node:http"), t && L("[patchNodeHttpInbound] node:http required successfully.");
263
+ n = An("node:http"), t && R("[patchNodeHttpInbound] node:http required successfully.");
264
264
  } catch (r) {
265
- return void Sn("Failed to require node:http:", r);
265
+ return void bn("Failed to require node:http:", r);
266
266
  }
267
- if (!n?.Server?.prototype) return void (t && L("[patchNodeHttpInbound] http.Server.prototype not found."));
267
+ if (!n?.Server?.prototype) return void (t && R("[patchNodeHttpInbound] http.Server.prototype not found."));
268
268
  const e = n.Server.prototype, o = e.emit;
269
- o && !e.__sf_inbound_patched__ ? (Object.defineProperty(e, "__sf_inbound_patched__", { value: !0, enumerable: !1, configurable: !1, writable: !1 }), t && L("[patchNodeHttpInbound] Patching http.Server.prototype.emit."), e.emit = function(r, ...i) {
270
- if (r !== "request") return t && L(`[patchNodeHttpInbound] Passing through event: ${r}`), o.call(this, r, ...i);
271
- const d = i[0], u = i[1], a = (function(y) {
269
+ o && !e.__sf_inbound_patched__ ? (Object.defineProperty(e, "__sf_inbound_patched__", { value: !0, enumerable: !1, configurable: !1, writable: !1 }), t && R("[patchNodeHttpInbound] Patching http.Server.prototype.emit."), e.emit = function(r, ...i) {
270
+ if (r !== "request") return t && R(`[patchNodeHttpInbound] Passing through event: ${r}`), o.call(this, r, ...i);
271
+ const d = i[0], u = i[1], a = (function(g) {
272
272
  const h = {};
273
- if (!y) return h;
274
- for (const [g, S] of Object.entries(y)) S != null && (Array.isArray(S) ? h[g.toLowerCase()] = S.join(", ") : h[g.toLowerCase()] = String(S));
273
+ if (!g) return h;
274
+ for (const [m, I] of Object.entries(g)) I != null && (Array.isArray(I) ? h[m.toLowerCase()] = I.join(", ") : h[m.toLowerCase()] = String(I));
275
275
  return h;
276
- })(d?.headers), s = a["x-sf3-rid"], l = a["x-sf3-functionspancaptureoverride"];
277
- t && (L("[patchNodeHttpInbound] Intercepted request event."), L("[patchNodeHttpInbound] Inbound headers:", a), L("[patchNodeHttpInbound] Trace header:", s), L("[patchNodeHttpInbound] FuncSpan override header:", l));
278
- const c = Q.getInstance();
279
- c.setTraceId(s);
280
- const p = c.getTraceId();
281
- t && L("[patchNodeHttpInbound] Context traceId set:", p);
282
- const f = () => c.runWith({ inboundHeaders: a, ...s ? { traceId: s } : {} }, () => {
283
- s && c.setTraceId(s), t && L("[patchNodeHttpInbound] Running request handler in context.");
284
- const y = () => {
285
- t && L("[patchNodeHttpInbound] Response finished/closed for traceId:", c.getTraceId());
276
+ })(d?.headers), s = a["x-sf3-rid"], c = a["x-sf3-functionspancaptureoverride"];
277
+ t && (R("[patchNodeHttpInbound] Intercepted request event."), R("[patchNodeHttpInbound] Inbound headers:", a), R("[patchNodeHttpInbound] Trace header:", s), R("[patchNodeHttpInbound] FuncSpan override header:", c));
278
+ const l = Q.getInstance();
279
+ l.setTraceId(s);
280
+ const p = l.getTraceId();
281
+ t && R("[patchNodeHttpInbound] Context traceId set:", p);
282
+ const f = () => l.runWith({ inboundHeaders: a, ...s ? { traceId: s } : {} }, () => {
283
+ s && l.setTraceId(s), t && R("[patchNodeHttpInbound] Running request handler in context.");
284
+ const g = () => {
285
+ t && R("[patchNodeHttpInbound] Response finished/closed for traceId:", l.getTraceId());
286
286
  };
287
- return u.on("finish", y), u.on("close", y), o.call(this, r, d, u);
287
+ return u.on("finish", g), u.on("close", g), o.call(this, r, d, u);
288
288
  });
289
- if (!l) return f();
289
+ if (!c) return f();
290
290
  try {
291
- return sn.run(l, () => f());
291
+ return an.run(c, () => f());
292
292
  } catch {
293
293
  return f();
294
294
  }
295
- }) : t && L("[patchNodeHttpInbound] Already patched, skipping.");
295
+ }) : t && R("[patchNodeHttpInbound] Already patched, skipping.");
296
296
  }
297
- const st = /* @__PURE__ */ new Map();
298
- function $e(t, n) {
297
+ const it = /* @__PURE__ */ new Map();
298
+ function ke(t, n) {
299
299
  const e = `${t}|${n}`;
300
- let o = st.get(e);
301
- return o || (o = new RegExp(t, n), st.set(e, o)), o;
300
+ let o = it.get(e);
301
+ return o || (o = new RegExp(t, n), it.set(e, o)), o;
302
302
  }
303
- function ke(t, n) {
303
+ function Ne(t, n) {
304
304
  let e, o;
305
305
  if (typeof t == "string" ? e = t : typeof URL < "u" && t instanceof URL ? e = t.href : typeof Request < "u" && t instanceof Request ? e = t.url : t != null && typeof t.toString == "function" && (e = t.toString()), !e) return !1;
306
306
  try {
@@ -312,20 +312,20 @@ function ke(t, n) {
312
312
  if (!/^https?:$/.test(u)) return !1;
313
313
  const a = r.startsWith("www.") ? r.slice(4).toLowerCase() : r.toLowerCase();
314
314
  return n.some((s) => {
315
- const l = String(s || "").replace(/^[a-zA-Z]+:\/\//, "");
316
- if (!l) return !1;
317
- let [c, p] = l.split("/", 2), f = "";
318
- c.includes(":") && ([c, f] = c.split(":"));
319
- const y = $e(`^${c.replace(/\./g, "\\.").replace(/\*/g, ".*")}$`, "i"), h = a.startsWith("www.") ? a.slice(4) : a;
315
+ const c = String(s || "").replace(/^[a-zA-Z]+:\/\//, "");
316
+ if (!c) return !1;
317
+ let [l, p] = c.split("/", 2), f = "";
318
+ l.includes(":") && ([l, f] = l.split(":"));
319
+ const g = ke(`^${l.replace(/\./g, "\\.").replace(/\*/g, ".*")}$`, "i"), h = a.startsWith("www.") ? a.slice(4) : a;
320
320
  if (f && d !== f) return !1;
321
- if (c.startsWith("*.")) {
322
- const g = c.slice(2).toLowerCase();
323
- return a === g || h === g || a.endsWith("." + g) ? p ? $e(`^/${p.replace(/\*/g, ".*").replace(/\/$/, "")}`, "i").test(i) : !0 : !1;
321
+ if (l.startsWith("*.")) {
322
+ const m = l.slice(2).toLowerCase();
323
+ return a === m || h === m || a.endsWith("." + m) ? p ? ke(`^/${p.replace(/\*/g, ".*").replace(/\/$/, "")}`, "i").test(i) : !0 : !1;
324
324
  }
325
- return !y.test(h) && !y.test(a) ? !1 : p ? $e(`^/${p.replace(/\*/g, ".*").replace(/\/$/, "")}`, "i").test(i) : !0;
325
+ return !g.test(h) && !g.test(a) ? !1 : p ? ke(`^/${p.replace(/\*/g, ".*").replace(/\/$/, "")}`, "i").test(i) : !0;
326
326
  });
327
327
  }
328
- class qn extends ze {
328
+ class Ln extends Xe {
329
329
  constructor() {
330
330
  super(), this.setOperationName("DomainsToNotPassHeaderTo");
331
331
  }
@@ -349,7 +349,7 @@ class qn extends ze {
349
349
  W(this.endpoint, this.operationName, e, o);
350
350
  }
351
351
  }
352
- class Ln extends oe {
352
+ class Rn extends oe {
353
353
  constructor() {
354
354
  super();
355
355
  D(this, "serviceIdentifier", new de());
@@ -360,7 +360,7 @@ class Ln extends oe {
360
360
  if (this.identifyStarted) return;
361
361
  this.identifyStarted = !0, this.serviceIdentifier.doSend({});
362
362
  const e = setInterval(() => {
363
- m().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
363
+ y().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
364
364
  }, 5e3);
365
365
  e && typeof e == "object" && "unref" in e && e.unref();
366
366
  }
@@ -401,7 +401,7 @@ class Ln extends oe {
401
401
  `;
402
402
  }
403
403
  }
404
- class Lt extends oe {
404
+ class Rt extends oe {
405
405
  constructor() {
406
406
  super();
407
407
  D(this, "serviceIdentifier", new de());
@@ -412,7 +412,7 @@ class Lt extends oe {
412
412
  if (this.identifyStarted) return;
413
413
  this.identifyStarted = !0, this.serviceIdentifier.doSend({});
414
414
  const e = setInterval(() => {
415
- m().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
415
+ y().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
416
416
  }, 5e3);
417
417
  e && typeof e == "object" && "unref" in e && e.unref();
418
418
  }
@@ -430,15 +430,15 @@ class Lt extends oe {
430
430
  `;
431
431
  }
432
432
  async send(e) {
433
- const o = { data: { ...e, dataSensitivityLevel: m().dataSensitivityLevel } };
433
+ const o = { data: { ...e, dataSensitivityLevel: y().dataSensitivityLevel } };
434
434
  await W(this.endpoint, this.operationName, this.getQuery(), o);
435
435
  }
436
436
  }
437
- const Ne = [400, 403];
438
- function Ue(t, n) {
437
+ const Ue = [400, 403];
438
+ function De(t, n) {
439
439
  return n !== "none" && (n === "all" || t === "GET" || t === "HEAD" || t === "OPTIONS");
440
440
  }
441
- class Rn {
441
+ class Bn {
442
442
  constructor(n = []) {
443
443
  D(this, "HEADER_TRACING", "X-Sf3-Rid");
444
444
  D(this, "HEADER_LOG_GUARD", "reentrancy_guard_logging_preactive");
@@ -447,7 +447,7 @@ class Rn {
447
447
  D(this, "contextManager");
448
448
  this.contextManager = Q.getInstance(), n?.forEach((e) => {
449
449
  typeof e == "string" && e.trim() && this.contextManager.getExcludedDomains().add(e);
450
- }), m().sfDebug && console.log("[RequestInterceptor] Initialized with static excluded domains.");
450
+ }), y().sfDebug && console.log("[RequestInterceptor] Initialized with static excluded domains.");
451
451
  }
452
452
  extractIdsFromTraceHeader(n, e = this.HEADER_TRACING) {
453
453
  let o;
@@ -474,48 +474,48 @@ class Rn {
474
474
  if (n.includes("://")) return { originalPos: r };
475
475
  const i = n + ".map";
476
476
  try {
477
- const d = JSON.parse(_n(i, "utf-8"));
478
- let u = (await new $n.SourceMapConsumer(d)).originalPositionFor({ line: e, column: o });
477
+ const d = JSON.parse($n(i, "utf-8"));
478
+ let u = (await new kn.SourceMapConsumer(d)).originalPositionFor({ line: e, column: o });
479
479
  u.source && (r = u);
480
480
  } catch (d) {
481
- m().sfDebug && console.error(`Could not read/parse map file at ${i}:`, d);
481
+ y().sfDebug && console.error(`Could not read/parse map file at ${i}:`, d);
482
482
  }
483
483
  return { originalPos: r };
484
484
  }
485
485
  captureFirstUserLines(n, e = 10, o = !1) {
486
- const r = m().sfDebug ? 10 : e, i = Error.stackTraceLimit;
486
+ const r = y().sfDebug ? 10 : e, i = Error.stackTraceLimit;
487
487
  Error.stackTraceLimit = Math.max(i, r);
488
- const d = new Error(nt);
489
- nt in Error && Error.captureStackTrace(d, this.captureFirstUserLines);
490
- const u = Ct(d.stack);
488
+ const d = new Error(rt);
489
+ rt in Error && Error.captureStackTrace(d, this.captureFirstUserLines);
490
+ const u = At(d.stack);
491
491
  Error.stackTraceLimit = i;
492
492
  const a = u.split(`
493
493
  `).slice(1), s = [];
494
- for (const l of a)
495
- if (!(l.includes("node:internal") || l.includes("internal/modules") || l.includes("internal/process") || l.includes("node_modules") || l.includes(".next/server/chunks") || l.includes("RequestInterceptor") || l.includes("contextManager") || l.includes("setupConfig")) && (s.push(l.trim()), s.length >= e)) break;
496
- for (const l of s) {
497
- const c = this.parseStackFrame(l);
498
- c ? (async () => {
499
- const { originalPos: p } = await this.getOriginalPosition(c.filePath, c.line, c.column);
494
+ for (const c of a)
495
+ 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")) && (s.push(c.trim()), s.length >= e)) break;
496
+ for (const c of s) {
497
+ const l = this.parseStackFrame(c);
498
+ l ? (async () => {
499
+ const { originalPos: p } = await this.getOriginalPosition(l.filePath, l.line, l.column);
500
500
  if (p) {
501
- m().sfDebug && console.log("[RequestInterceptor] First user code line:", p);
501
+ y().sfDebug && console.log("[RequestInterceptor] First user code line:", p);
502
502
  const f = { line: p.line?.toString() || be.UNKNOWN, column: p.column?.toString() || be.NOT_CAPTURED, name: p.name || be.NOT_CAPTURED, entrypoint: p.source, retryWithoutTraceId: o };
503
503
  n.doSend(f);
504
504
  }
505
- })() : m().sfDebug && console.error("Could not parse stack line:", l);
505
+ })() : y().sfDebug && console.error("Could not parse stack line:", c);
506
506
  }
507
507
  }
508
508
  addReentrancyGuardHeaders(n) {
509
509
  n.set(this.HEADER_LOG_GUARD, "true"), n.set(this.HEADER_PRINT_GUARD, "true"), n.set(this.HEADER_EXCEPTION_GUARD, "true");
510
510
  }
511
511
  shouldPropagateHeaders(n) {
512
- const e = m(), o = e.domainsToPropagateHeadersTo, r = e.domainsToNotPropagateHeadersTo || [], i = Array.from(en);
513
- return !!ke(n, o) && !(r.length > 0 && ke(n, r)) && !ke(n, i);
512
+ const e = y(), o = e.domainsToPropagateHeadersTo, r = e.domainsToNotPropagateHeadersTo || [], i = Array.from(tn);
513
+ return !!Ne(n, o) && !(r.length > 0 && Ne(n, r)) && !Ne(n, i);
514
514
  }
515
515
  addTracingHeaders(n, e) {
516
516
  const o = this.shouldPropagateHeaders(e);
517
517
  if (o) this.addTracingHeader(n, e);
518
- else if (m().sfDebug) {
518
+ else if (y().sfDebug) {
519
519
  let r = e;
520
520
  try {
521
521
  r = new URL(e).hostname;
@@ -530,13 +530,13 @@ class Rn {
530
530
  return e.length < 2 ? { base: n, parent: n } : { base: `${e[0]}/${e[1]}`, parent: n };
531
531
  }
532
532
  addTracingHeader(n, e) {
533
- const o = Le();
533
+ const o = Re();
534
534
  if (o) {
535
- const a = Re(o);
536
- if (a && a.sample_rate === 0) return void (m().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${e}`));
535
+ const a = Be(o);
536
+ if (a && a.sample_rate === 0) return void (y().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${e}`));
537
537
  }
538
538
  const r = this.contextManager.getOrSetSfTraceId(), { base: i, parent: d } = this.deriveTraceBaseAndParent(r), u = ce();
539
- n.set(this.HEADER_TRACING, `${i}/${u}`), n.set(tt, d), m().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${e}`);
539
+ n.set(this.HEADER_TRACING, `${i}/${u}`), n.set(nt, d), y().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${e}`);
540
540
  }
541
541
  patchFetch(n, e) {
542
542
  const o = globalThis.fetch;
@@ -548,106 +548,106 @@ class Rn {
548
548
  let a, s = "GET";
549
549
  if (typeof r == "string" || r instanceof URL) a = r.toString(), s = (i?.method || "GET").toUpperCase();
550
550
  else {
551
- if (!(r instanceof Request)) return m().sfDebug && console.error("[Sailfish RequestInterceptor] Invalid fetch input."), o(r, i);
552
- a = r.url, s = r.method.toUpperCase(), r.headers.forEach((I, E) => {
553
- d.set(E, I);
551
+ if (!(r instanceof Request)) return y().sfDebug && console.error("[Sailfish RequestInterceptor] Invalid fetch input."), o(r, i);
552
+ a = r.url, s = r.method.toUpperCase(), r.headers.forEach((E, b) => {
553
+ d.set(b, E);
554
554
  });
555
555
  }
556
- m().sfDebug && console.log("[RequestInterceptor] Fetching request to:", a);
557
- let l = "unknown";
556
+ y().sfDebug && console.log("[RequestInterceptor] Fetching request to:", a);
557
+ let c = "unknown";
558
558
  try {
559
- l = new URL(a).hostname;
559
+ c = new URL(a).hostname;
560
560
  } catch {
561
- return m().sfDebug && console.warn(`[RequestInterceptor] Could not parse URL '${a}' — passing through without tracing headers.`), o(r, i);
561
+ return y().sfDebug && console.warn(`[RequestInterceptor] Could not parse URL '${a}' — passing through without tracing headers.`), o(r, i);
562
562
  }
563
- const c = new Headers(d), p = this.addTracingHeaders(d, a), f = (I) => r instanceof Request ? [new Request(r, { ...i || {}, headers: I }), void 0] : [a, { ...i, headers: I }], y = m().retryOnClientError;
564
- let h, g = !1;
563
+ const l = new Headers(d), p = this.addTracingHeaders(d, a), f = (E) => r instanceof Request ? [new Request(r, { ...i || {}, headers: E }), void 0] : [a, { ...i, headers: E }], g = y().retryOnClientError;
564
+ let h, m = !1;
565
565
  try {
566
- const [I, E] = f(d);
567
- if (h = await o(I, E), p && Ue(s, y) && Ne.includes(h.status)) {
568
- const [w, _] = f(c);
569
- h = await o(w, _), g = !0;
566
+ const [E, b] = f(d);
567
+ if (h = await o(E, b), p && De(s, g) && Ue.includes(h.status)) {
568
+ const [w, _] = f(l);
569
+ h = await o(w, _), m = !0;
570
570
  try {
571
- this.captureFirstUserLines(n, 10, g);
572
- } catch (N) {
573
- m().sfDebug && console.error("[RequestInterceptor] captureFirstUserLines (retry) failed:", N);
571
+ this.captureFirstUserLines(n, 10, m);
572
+ } catch (k) {
573
+ y().sfDebug && console.error("[RequestInterceptor] captureFirstUserLines (retry) failed:", k);
574
574
  }
575
575
  } else try {
576
- this.contextManager.addSupportedDomains(l);
576
+ this.contextManager.addSupportedDomains(c);
577
577
  } catch (w) {
578
- m().sfDebug && console.error("[RequestInterceptor] addSupportedDomains failed:", w);
578
+ y().sfDebug && console.error("[RequestInterceptor] addSupportedDomains failed:", w);
579
579
  }
580
- } catch (I) {
581
- const E = Date.now();
582
- m().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${a}, Error: ${I}, Duration: ${E - u}ms`);
580
+ } catch (E) {
581
+ const b = Date.now();
582
+ y().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${a}, Error: ${E}, Duration: ${b - u}ms`);
583
583
  try {
584
- const { sessionId: w, pageVisitId: _, requestId: N } = this.extractIdsFromTraceHeader(d), B = m();
585
- e.doSend({ apiKey: B.apiKey, requestId: N, pageVisitId: _, recordingSessionId: w, serviceUuid: B.serviceUUID, timestampStart: u.toString(), timestampEnd: E.toString(), responseCode: 0, success: !1, error: I instanceof Error ? I.message : typeof I == "string" ? I : JSON.stringify(I), url: a, method: s, retryWithoutTraceId: g, parentSpanId: K() });
584
+ const { sessionId: w, pageVisitId: _, requestId: k } = this.extractIdsFromTraceHeader(d), P = y();
585
+ e.doSend({ apiKey: P.apiKey, requestId: k, pageVisitId: _, recordingSessionId: w, serviceUuid: P.serviceUUID, timestampStart: u.toString(), timestampEnd: b.toString(), responseCode: 0, success: !1, error: E instanceof Error ? E.message : typeof E == "string" ? E : JSON.stringify(E), url: a, method: s, retryWithoutTraceId: m, parentSpanId: K() });
586
586
  } catch (w) {
587
- m().sfDebug && console.error("[RequestInterceptor] Error telemetry send failed:", w);
587
+ y().sfDebug && console.error("[RequestInterceptor] Error telemetry send failed:", w);
588
588
  }
589
- throw I;
589
+ throw E;
590
590
  }
591
- const S = Date.now();
591
+ const I = Date.now();
592
592
  try {
593
- m().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${a}, Status: ${h.status}, Duration: ${S - u}ms`);
594
- const { sessionId: I, pageVisitId: E, requestId: w } = this.extractIdsFromTraceHeader(d), _ = m(), N = { apiKey: _.apiKey, requestId: w, pageVisitId: E, recordingSessionId: I, serviceUuid: _.serviceUUID, timestampStart: u.toString(), timestampEnd: S.toString(), responseCode: h.status, success: !0, error: null, url: a, method: s, retryWithoutTraceId: g, parentSpanId: K() };
593
+ y().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${a}, Status: ${h.status}, Duration: ${I - u}ms`);
594
+ const { sessionId: E, pageVisitId: b, requestId: w } = this.extractIdsFromTraceHeader(d), _ = y(), k = { apiKey: _.apiKey, requestId: w, pageVisitId: b, recordingSessionId: E, serviceUuid: _.serviceUUID, timestampStart: u.toString(), timestampEnd: I.toString(), responseCode: h.status, success: !0, error: null, url: a, method: s, retryWithoutTraceId: m, parentSpanId: K() };
595
595
  if (_.captureRequestHeaders) {
596
596
  const $ = {};
597
- d.forEach((T, P) => {
598
- $[P] = T;
599
- }), N.requestHeaders = $;
597
+ d.forEach((C, F) => {
598
+ $[F] = C;
599
+ }), k.requestHeaders = $;
600
600
  }
601
601
  if (_.captureResponseHeaders) {
602
602
  const $ = {};
603
- h.headers.forEach((T, P) => {
604
- $[P] = T;
605
- }), N.responseHeaders = $;
603
+ h.headers.forEach((C, F) => {
604
+ $[F] = C;
605
+ }), k.responseHeaders = $;
606
606
  }
607
607
  if (_.captureRequestBody && i?.body) {
608
- const $ = i.body, T = _.requestBodyLimitBytes;
608
+ const $ = i.body, C = _.requestBodyLimitBytes;
609
609
  try {
610
- if (typeof $ == "string") N.requestBody = $.length > T ? $.substring(0, T) + "...[truncated]" : $;
610
+ if (typeof $ == "string") k.requestBody = $.length > C ? $.substring(0, C) + "...[truncated]" : $;
611
611
  else if ($ instanceof URLSearchParams) {
612
- const P = $.toString();
613
- N.requestBody = P.length > T ? P.substring(0, T) + "...[truncated]" : P;
612
+ const F = $.toString();
613
+ k.requestBody = F.length > C ? F.substring(0, C) + "...[truncated]" : F;
614
614
  } else if (typeof ArrayBuffer < "u" && ($ instanceof ArrayBuffer || ArrayBuffer.isView($))) {
615
- const P = $.byteLength ?? $.byteLength;
616
- N.requestBody = `[binary body, ${P} bytes — not captured]`;
617
- } else if (typeof Blob < "u" && $ instanceof Blob) N.requestBody = `[Blob, ${$.size} bytes, type=${$.type || "unknown"} — not captured]`;
618
- else if (typeof FormData < "u" && $ instanceof FormData) N.requestBody = "[FormData — not captured]";
619
- else if (typeof ReadableStream < "u" && $ instanceof ReadableStream) N.requestBody = "[ReadableStream — not captured]";
615
+ const F = $.byteLength ?? $.byteLength;
616
+ k.requestBody = `[binary body, ${F} bytes — not captured]`;
617
+ } else if (typeof Blob < "u" && $ instanceof Blob) k.requestBody = `[Blob, ${$.size} bytes, type=${$.type || "unknown"} — not captured]`;
618
+ else if (typeof FormData < "u" && $ instanceof FormData) k.requestBody = "[FormData — not captured]";
619
+ else if (typeof ReadableStream < "u" && $ instanceof ReadableStream) k.requestBody = "[ReadableStream — not captured]";
620
620
  else {
621
- const P = JSON.stringify($);
622
- P && P !== "{}" && (N.requestBody = P.length > T ? P.substring(0, T) + "...[truncated]" : P);
621
+ const F = JSON.stringify($);
622
+ F && F !== "{}" && (k.requestBody = F.length > C ? F.substring(0, C) + "...[truncated]" : F);
623
623
  }
624
624
  } catch {
625
625
  }
626
626
  }
627
- let B;
627
+ let P;
628
628
  if (_.captureResponseBody) {
629
629
  const $ = (h.headers.get("content-type") || "").toLowerCase();
630
630
  if (!$ || $.includes("json") || $.includes("xml") || $.includes("text/") || $.includes("javascript") || $.includes("ecmascript") || $.includes("x-www-form-urlencoded") || $.includes("application/graphql")) {
631
- const T = h.clone(), P = _.responseBodyLimitBytes;
632
- B = (async () => {
631
+ const C = h.clone(), F = _.responseBodyLimitBytes;
632
+ P = (async () => {
633
633
  try {
634
- const H = await T.text(), V = H.length > P ? H.substring(0, P) + "...[truncated]" : H;
634
+ const H = await C.text(), V = H.length > F ? H.substring(0, F) + "...[truncated]" : H;
635
635
  try {
636
- e.doSend({ ...N, responseBody: V });
636
+ e.doSend({ ...k, responseBody: V });
637
637
  } catch {
638
638
  }
639
639
  } catch {
640
640
  }
641
- })(), B.catch(() => {
641
+ })(), P.catch(() => {
642
642
  });
643
- } else N.responseBody = `[non-text body, content-type=${$} — not captured]`;
643
+ } else k.responseBody = `[non-text body, content-type=${$} — not captured]`;
644
644
  }
645
- B || e.doSend(N);
646
- } catch (I) {
647
- m().sfDebug && console.error("[RequestInterceptor] Post-fetch telemetry failed (response still returned):", I);
645
+ P || e.doSend(k);
646
+ } catch (E) {
647
+ y().sfDebug && console.error("[RequestInterceptor] Post-fetch telemetry failed (response still returned):", E);
648
648
  }
649
649
  return h;
650
- } : m().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
650
+ } : y().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
651
651
  }
652
652
  setHeader(n, e, o) {
653
653
  n instanceof Headers ? n.set(e, o) : n[e] = o;
@@ -655,14 +655,14 @@ class Rn {
655
655
  addTracingHeadersToPlainObject(n, e) {
656
656
  const o = this.shouldPropagateHeaders(e);
657
657
  if (o) {
658
- const r = Le();
658
+ const r = Re();
659
659
  if (r) {
660
- const s = Re(r);
661
- if (s && s.sample_rate === 0) return m().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${e}`), !1;
660
+ const s = Be(r);
661
+ if (s && s.sample_rate === 0) return y().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${e}`), !1;
662
662
  }
663
663
  const i = this.contextManager.getOrSetSfTraceId(), { base: d, parent: u } = this.deriveTraceBaseAndParent(i), a = ce();
664
- n[this.HEADER_TRACING] = `${d}/${a}`, n[tt] = u, m().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${e}`);
665
- } else if (m().sfDebug) {
664
+ n[this.HEADER_TRACING] = `${d}/${a}`, n[nt] = u, y().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${e}`);
665
+ } else if (y().sfDebug) {
666
666
  let r = e;
667
667
  try {
668
668
  r = new URL(e).hostname;
@@ -673,106 +673,114 @@ class Rn {
673
673
  return o;
674
674
  }
675
675
  patchHttp(n, e) {
676
- if (m().sfDebug && console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."), !G || typeof G.request != "function") return void (m().sfDebug && console.log("[RequestInterceptor] HTTP/HTTPS not available."));
677
- const o = G.request.bind(G), r = he.request.bind(he), i = (a, s, l, c = rt) => {
678
- let p, f;
679
- if (typeof a == "string" || a instanceof URL) {
680
- const y = typeof a == "string" ? new URL(a) : a;
681
- p = { ...typeof s == "object" && s !== null ? s : {}, protocol: y.protocol || c, hostname: y.hostname, port: y.port || void 0, path: y.pathname + y.search }, f = typeof s == "function" ? s : l;
682
- } else p = { ...a }, p.protocol || (p.protocol = c), f = typeof s == "function" ? s : void 0;
683
- return p.headers || (p.headers = {}), [p, f];
684
- }, d = (a, s, l) => {
685
- const [c, p] = i(a, s, l, rt);
676
+ if (y().sfDebug && console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."), !G || typeof G.request != "function") return void (y().sfDebug && console.log("[RequestInterceptor] HTTP/HTTPS not available."));
677
+ const o = G.request.bind(G), r = he.request.bind(he), i = (s) => {
678
+ const c = s.protocol || we;
679
+ let l = s.hostname || s.host?.split(":")[0] || "localhost";
680
+ l.includes(":") && !l.startsWith("[") && (l = `[${l}]`);
681
+ let p = s.port != null && String(s.port) !== "" ? String(s.port) : "";
682
+ if (!p && !s.hostname && s.host) {
683
+ const f = /:(\d+)$/.exec(s.host);
684
+ f && (p = f[1]);
685
+ }
686
+ return `${c}//${l}${p && p !== (c === ot ? "443" : "80") ? `:${p}` : ""}${typeof s.path == "string" && s.path ? s.path : "/"}`;
687
+ }, d = (s, c, l, p = we) => {
688
+ let f, g;
689
+ if (typeof s == "string" || s instanceof URL) {
690
+ const h = typeof s == "string" ? new URL(s) : s;
691
+ f = { ...typeof c == "object" && c !== null ? c : {}, protocol: h.protocol || p, hostname: h.hostname, port: h.port || void 0, path: h.pathname + h.search }, g = typeof c == "function" ? c : l;
692
+ } else f = { ...s }, f.protocol || (f.protocol = p), g = typeof c == "function" ? c : void 0;
693
+ return f.headers || (f.headers = {}), [f, g];
694
+ }, u = (s, c, l) => {
695
+ const [p, f] = d(s, c, l, we), g = i(p), h = Date.now();
686
696
  try {
687
- const g = `${c.protocol}//${c.hostname}`;
688
- this.addTracingHeadersToPlainObject(c.headers, g), this.captureFirstUserLines(n);
689
- } catch (g) {
690
- m().sfDebug && console.error("[RequestInterceptor] Error while processing HTTP request options:", g);
697
+ this.addTracingHeadersToPlainObject(p.headers, g), this.captureFirstUserLines(n);
698
+ } catch (b) {
699
+ y().sfDebug && console.error("[RequestInterceptor] Error while processing HTTP request options:", b);
691
700
  }
692
- const f = (c.method || "GET").toUpperCase(), y = m().retryOnClientError, h = (g, S, I) => {
701
+ const m = (p.method || "GET").toUpperCase(), I = y().retryOnClientError, E = (b, w, _) => {
693
702
  try {
694
- const { sessionId: E, pageVisitId: w, requestId: _ } = this.extractIdsFromTraceHeader(c.headers);
695
- e.doSend({ apiKey: m().apiKey, requestId: _, pageVisitId: w, recordingSessionId: E, serviceUuid: m().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: g.statusCode || 0, success: !!g.statusCode && g.statusCode < 400, error: null, url: S, method: f, retryWithoutTraceId: I, parentSpanId: K() });
703
+ const { sessionId: k, pageVisitId: P, requestId: $ } = this.extractIdsFromTraceHeader(p.headers);
704
+ e.doSend({ apiKey: y().apiKey, requestId: $, pageVisitId: P, recordingSessionId: k, serviceUuid: y().serviceUUID, timestampStart: h.toString(), timestampEnd: Date.now().toString(), responseCode: b.statusCode || 0, success: !!b.statusCode && b.statusCode < 400, error: null, url: w, method: m, retryWithoutTraceId: _, parentSpanId: K() });
696
705
  } catch {
697
706
  }
698
- p?.(g);
707
+ f?.(b);
699
708
  };
700
- return o(c, (g) => {
701
- const S = `${c.protocol}//${c.hostname}`;
702
- let I = !1;
709
+ return o(p, (b) => {
710
+ const w = g;
711
+ let _ = !1;
703
712
  try {
704
- I = this.shouldPropagateHeaders(S);
713
+ _ = this.shouldPropagateHeaders(w);
705
714
  } catch {
706
- I = !1;
715
+ _ = !1;
707
716
  }
708
- if (I && Ue(f, y) && Ne.includes(g.statusCode || 0)) {
709
- g.resume();
717
+ if (_ && De(m, I) && Ue.includes(b.statusCode || 0)) {
718
+ b.resume();
710
719
  try {
711
- const { sessionId: w, pageVisitId: _, requestId: N } = this.extractIdsFromTraceHeader(c.headers);
712
- e.doSend({ apiKey: m().apiKey, requestId: N, pageVisitId: _, recordingSessionId: w, serviceUuid: m().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: g.statusCode || 0, success: !1, error: null, url: S, method: f, retryWithoutTraceId: !1, parentSpanId: K() });
720
+ const { sessionId: P, pageVisitId: $, requestId: C } = this.extractIdsFromTraceHeader(p.headers);
721
+ e.doSend({ apiKey: y().apiKey, requestId: C, pageVisitId: $, recordingSessionId: P, serviceUuid: y().serviceUUID, timestampStart: h.toString(), timestampEnd: Date.now().toString(), responseCode: b.statusCode || 0, success: !1, error: null, url: w, method: m, retryWithoutTraceId: !1, parentSpanId: K() });
713
722
  } catch {
714
723
  }
715
724
  try {
716
725
  this.captureFirstUserLines(n, 10, !0);
717
726
  } catch {
718
727
  }
719
- const E = { ...c, headers: { ...c.headers } };
720
- return delete E.headers[this.HEADER_TRACING], void o(E, (w) => {
721
- h(w, S, !0);
728
+ const k = { ...p, headers: { ...p.headers } };
729
+ return delete k.headers[this.HEADER_TRACING], void o(k, (P) => {
730
+ E(P, w, !0);
722
731
  }).end();
723
732
  }
724
- h(g, S, !1);
733
+ E(b, w, !1);
725
734
  });
726
- }, u = (a, s, l) => {
727
- const [c, p] = i(a, s, l, "https:");
735
+ }, a = (s, c, l) => {
736
+ const [p, f] = d(s, c, l, ot), g = i(p), h = Date.now();
728
737
  try {
729
- const g = `${c.protocol}//${c.hostname}`;
730
- this.addTracingHeadersToPlainObject(c.headers, g), this.captureFirstUserLines(n);
731
- } catch (g) {
732
- m().sfDebug && console.error("[RequestInterceptor] Error while processing HTTPS request options:", g);
738
+ this.addTracingHeadersToPlainObject(p.headers, g), this.captureFirstUserLines(n);
739
+ } catch (b) {
740
+ y().sfDebug && console.error("[RequestInterceptor] Error while processing HTTPS request options:", b);
733
741
  }
734
- const f = (c.method || "GET").toUpperCase(), y = m().retryOnClientError, h = (g, S, I) => {
742
+ const m = (p.method || "GET").toUpperCase(), I = y().retryOnClientError, E = (b, w, _) => {
735
743
  try {
736
- const { sessionId: E, pageVisitId: w, requestId: _ } = this.extractIdsFromTraceHeader(c.headers);
737
- e.doSend({ apiKey: m().apiKey, requestId: _, pageVisitId: w, recordingSessionId: E, serviceUuid: m().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: g.statusCode || 0, success: !!g.statusCode && g.statusCode < 400, error: null, url: S, method: f, retryWithoutTraceId: I, parentSpanId: K() });
744
+ const { sessionId: k, pageVisitId: P, requestId: $ } = this.extractIdsFromTraceHeader(p.headers);
745
+ e.doSend({ apiKey: y().apiKey, requestId: $, pageVisitId: P, recordingSessionId: k, serviceUuid: y().serviceUUID, timestampStart: h.toString(), timestampEnd: Date.now().toString(), responseCode: b.statusCode || 0, success: !!b.statusCode && b.statusCode < 400, error: null, url: w, method: m, retryWithoutTraceId: _, parentSpanId: K() });
738
746
  } catch {
739
747
  }
740
- p?.(g);
748
+ f?.(b);
741
749
  };
742
- return r(c, (g) => {
743
- const S = `${c.protocol}//${c.hostname}`;
744
- let I = !1;
750
+ return r(p, (b) => {
751
+ const w = g;
752
+ let _ = !1;
745
753
  try {
746
- I = this.shouldPropagateHeaders(S);
754
+ _ = this.shouldPropagateHeaders(w);
747
755
  } catch {
748
- I = !1;
756
+ _ = !1;
749
757
  }
750
- if (I && Ue(f, y) && Ne.includes(g.statusCode || 0)) {
751
- g.resume();
758
+ if (_ && De(m, I) && Ue.includes(b.statusCode || 0)) {
759
+ b.resume();
752
760
  try {
753
- const { sessionId: w, pageVisitId: _, requestId: N } = this.extractIdsFromTraceHeader(c.headers);
754
- e.doSend({ apiKey: m().apiKey, requestId: N, pageVisitId: _, recordingSessionId: w, serviceUuid: m().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: g.statusCode || 0, success: !1, error: null, url: S, method: f, retryWithoutTraceId: !1, parentSpanId: K() });
761
+ const { sessionId: P, pageVisitId: $, requestId: C } = this.extractIdsFromTraceHeader(p.headers);
762
+ e.doSend({ apiKey: y().apiKey, requestId: C, pageVisitId: $, recordingSessionId: P, serviceUuid: y().serviceUUID, timestampStart: h.toString(), timestampEnd: Date.now().toString(), responseCode: b.statusCode || 0, success: !1, error: null, url: w, method: m, retryWithoutTraceId: !1, parentSpanId: K() });
755
763
  } catch {
756
764
  }
757
765
  try {
758
766
  this.captureFirstUserLines(n, 10, !0);
759
767
  } catch {
760
768
  }
761
- const E = { ...c, headers: { ...c.headers } };
762
- return delete E.headers[this.HEADER_TRACING], void r(E, (w) => {
763
- h(w, S, !0);
769
+ const k = { ...p, headers: { ...p.headers } };
770
+ return delete k.headers[this.HEADER_TRACING], void r(k, (P) => {
771
+ E(P, w, !0);
764
772
  }).end();
765
773
  }
766
- h(g, S, !1);
774
+ E(b, w, !1);
767
775
  });
768
776
  };
769
- G.request = d, he.request = u, G.get = (a, s, l) => {
770
- const c = d(a, s, l);
771
- return c.end(), c;
772
- }, he.get = (a, s, l) => {
773
- const c = u(a, s, l);
774
- return c.end(), c;
775
- }, m().sfDebug && console.log("✅ HTTP and HTTPS request/get methods patched globally.");
777
+ G.request = u, he.request = a, G.get = (s, c, l) => {
778
+ const p = u(s, c, l);
779
+ return p.end(), p;
780
+ }, he.get = (s, c, l) => {
781
+ const p = a(s, c, l);
782
+ return p.end(), p;
783
+ }, y().sfDebug && console.log("✅ HTTP and HTTPS request/get methods patched globally.");
776
784
  }
777
785
  tryPatch(n, e) {
778
786
  try {
@@ -784,7 +792,7 @@ class Rn {
784
792
  return [...this.contextManager.getExcludedDomains()];
785
793
  }
786
794
  }
787
- class Bn extends ze {
795
+ class On extends Xe {
788
796
  constructor() {
789
797
  super(), this.setOperationName("UpdateServiceDetails");
790
798
  }
@@ -834,11 +842,11 @@ class Bn extends ze {
834
842
  serviceRole: $serviceRole,
835
843
  )
836
844
  }
837
- `, e = m(), o = this.getVariables({ serviceIdentifier: e.serviceIdentifier, serviceVersion: e.serviceVersion, serviceAdditionalMetadata: e.serviceAdditionalMetadata, gitSha: e.gitSha || "", gitOrg: e.gitOrg || void 0, gitRepo: e.gitRepo || void 0, gitProvider: e.gitProvider || void 0, serviceDisplayName: e.serviceDisplayName || void 0, infrastructureType: e.infrastructureType || void 0, infrastructureDetails: e.infrastructureDetails || void 0, setupInterceptorsFile: e.setupInterceptorsFile || void 0, setupInterceptorsLine: e.setupInterceptorsLine || void 0, framework: e.framework || void 0, additionalFrameworks: e.additionalFrameworks?.length > 0 ? e.additionalFrameworks : void 0, serviceRole: e.serviceRole || void 0 });
845
+ `, e = y(), o = this.getVariables({ serviceIdentifier: e.serviceIdentifier, serviceVersion: e.serviceVersion, serviceAdditionalMetadata: e.serviceAdditionalMetadata, gitSha: e.gitSha || "", gitOrg: e.gitOrg || void 0, gitRepo: e.gitRepo || void 0, gitProvider: e.gitProvider || void 0, serviceDisplayName: e.serviceDisplayName || void 0, infrastructureType: e.infrastructureType || void 0, infrastructureDetails: e.infrastructureDetails || void 0, setupInterceptorsFile: e.setupInterceptorsFile || void 0, setupInterceptorsLine: e.setupInterceptorsLine || void 0, framework: e.framework || void 0, additionalFrameworks: e.additionalFrameworks?.length > 0 ? e.additionalFrameworks : void 0, serviceRole: e.serviceRole || void 0 });
838
846
  W(this.endpoint, this.operationName, n, o);
839
847
  }
840
848
  }
841
- class On {
849
+ class Mn {
842
850
  constructor(n = [process.cwd()], e = !1) {
843
851
  D(this, "rootPaths");
844
852
  D(this, "fileConfigs", /* @__PURE__ */ new Map());
@@ -852,13 +860,13 @@ class On {
852
860
  async loadAllConfigs() {
853
861
  this.debug && console.log("[FuncSpan ConfigLoader] Scanning for .sailfish files in:", this.rootPaths);
854
862
  const n = [];
855
- for (const e of this.rootPaths) En.existsSync(e) ? await this._walkDirectory(e, n) : this.debug && console.log(`[FuncSpan ConfigLoader] Root path does not exist: ${e}`);
863
+ for (const e of this.rootPaths) _n.existsSync(e) ? await this._walkDirectory(e, n) : this.debug && console.log(`[FuncSpan ConfigLoader] Root path does not exist: ${e}`);
856
864
  n.length > 0 ? (this.hasSailfishFiles = !0, this.debug && (console.log(`[FuncSpan ConfigLoader] Found ${n.length} .sailfish files:`), n.forEach((e) => console.log(`[FuncSpan ConfigLoader] - ${e}`)))) : this.debug && console.log("[FuncSpan ConfigLoader] No .sailfish files found - function spans disabled by default");
857
865
  for (const e of n) await this._loadConfigFile(e);
858
866
  await this._resolveInheritance(), this.debug && console.log(`[FuncSpan ConfigLoader] Loaded ${this.fileConfigs.size} file configs, ${this.functionConfigs.size} function configs`);
859
867
  }
860
868
  getConfig(n, e) {
861
- const o = this.hasSailfishFiles ? an() : Pt(), r = this._getDirectoryConfig(n), i = R.normalize(n), d = this.fileConfigs.get(i) || {};
869
+ const o = this.hasSailfishFiles ? cn() : Ft(), r = this._getDirectoryConfig(n), i = B.normalize(n), d = this.fileConfigs.get(i) || {};
862
870
  let u = {};
863
871
  if (e) {
864
872
  const a = this.functionConfigs.get(i);
@@ -871,9 +879,9 @@ class On {
871
879
  }
872
880
  async _walkDirectory(n, e) {
873
881
  try {
874
- const o = await et.readdir(n, { withFileTypes: !0 });
882
+ const o = await tt.readdir(n, { withFileTypes: !0 });
875
883
  for (const r of o) {
876
- const i = R.join(n, r.name);
884
+ const i = B.join(n, r.name);
877
885
  r.isFile() && r.name === ".sailfish" ? e.push(i) : r.name === "node_modules" || r.isDirectory() && r.name.startsWith(".") && r.name !== ".sailfish" || r.isDirectory() && await this._walkDirectory(i, e);
878
886
  }
879
887
  } catch (o) {
@@ -882,7 +890,7 @@ class On {
882
890
  }
883
891
  async _loadConfigFile(n) {
884
892
  try {
885
- const e = await et.readFile(n, "utf-8"), o = R.dirname(n);
893
+ const e = await tt.readFile(n, "utf-8"), o = B.dirname(n);
886
894
  let r = null;
887
895
  try {
888
896
  r = JSON.parse(e);
@@ -905,11 +913,11 @@ class On {
905
913
  }
906
914
  async _expandFileGlobs(n, e, o) {
907
915
  for (const [r, i] of Object.entries(e)) try {
908
- const d = R.join(n, r), u = await kn(d, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
916
+ const d = B.join(n, r), u = await Nn(d, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
909
917
  this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${r}' matched ${u.length} files`);
910
918
  for (const a of u) {
911
- const s = R.normalize(a), l = pe(o, i);
912
- this.fileConfigs.set(s, l), this.debug && u.length <= 5 && console.log(`[FuncSpan ConfigLoader] - ${a}`);
919
+ const s = B.normalize(a), c = pe(o, i);
920
+ this.fileConfigs.set(s, c), this.debug && u.length <= 5 && console.log(`[FuncSpan ConfigLoader] - ${a}`);
913
921
  }
914
922
  } catch (d) {
915
923
  this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${r}':`, d);
@@ -922,54 +930,54 @@ class On {
922
930
  this.debug && console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${r}' (expected format: 'file.ts::functionName')`);
923
931
  continue;
924
932
  }
925
- const [u, a] = d, s = R.normalize(R.join(n, u));
933
+ const [u, a] = d, s = B.normalize(B.join(n, u));
926
934
  this.functionConfigs.has(s) || this.functionConfigs.set(s, /* @__PURE__ */ new Map());
927
- const l = this.functionConfigs.get(s), c = pe(o, i);
928
- l.set(a, c), this.debug && console.log(`[FuncSpan ConfigLoader] Function config: ${s}::${a}`);
935
+ const c = this.functionConfigs.get(s), l = pe(o, i);
936
+ c.set(a, l), this.debug && console.log(`[FuncSpan ConfigLoader] Function config: ${s}::${a}`);
929
937
  }
930
938
  }
931
939
  async _resolveInheritance() {
932
940
  }
933
941
  _getDirectoryConfig(n) {
934
- let e = R.dirname(R.normalize(n));
942
+ let e = B.dirname(B.normalize(n));
935
943
  const o = [];
936
- for (; e && e !== R.dirname(e); ) {
944
+ for (; e && e !== B.dirname(e); ) {
937
945
  const r = this.directoryConfigs.get(e);
938
- r && o.unshift(r), e = R.dirname(e);
946
+ r && o.unshift(r), e = B.dirname(e);
939
947
  }
940
948
  return o.reduce((r, i) => pe(r, i), {});
941
949
  }
942
950
  }
943
- const Rt = "__sf_globalConfigLoader";
944
- function Bt() {
945
- return globalThis[Rt] ?? null;
951
+ const Bt = "__sf_globalConfigLoader";
952
+ function Ot() {
953
+ return globalThis[Bt] ?? null;
946
954
  }
947
- async function Mn(t, n) {
948
- const e = new On(t, n);
955
+ async function jn(t, n) {
956
+ const e = new Mn(t, n);
949
957
  (function(r) {
950
- globalThis[Rt] = r;
958
+ globalThis[Bt] = r;
951
959
  })(e), await e.loadAllConfigs();
952
960
  const o = globalThis;
953
961
  o.__sf_configEpoch = (o.__sf_configEpoch ?? 0) + 1;
954
962
  }
955
- function jn(t, n) {
956
- const e = Bt();
957
- return e ? e.getConfig(t, n) : (process.env.SF_DEBUG === "true" && console.log("[FuncSpan ConfigLoader] Config loader not initialized, using default config (disabled)"), Pt());
963
+ function xn(t, n) {
964
+ const e = Ot();
965
+ return e ? e.getConfig(t, n) : (process.env.SF_DEBUG === "true" && console.log("[FuncSpan ConfigLoader] Config loader not initialized, using default config (disabled)"), Ft());
958
966
  }
959
- function xn() {
960
- return Bt() !== null;
967
+ function Hn() {
968
+ return Ot() !== null;
961
969
  }
962
- const Hn = ["readFile", "writeFile", "appendFile", "readdir", "stat", "lstat", "fstat", "access", "open", "close", "read", "write", "chmod", "mkdir", "rmdir", "unlink", "rename"], it = ["lookup", "resolve", "resolve4", "resolve6", "resolveAny", "resolveMx", "resolveNs", "resolveTxt", "reverse"], Kn = ["pbkdf2", "randomBytes", "scrypt", "generateKeyPair"], Jn = ["gzip", "gunzip", "deflate", "inflate", "deflateRaw", "inflateRaw", "brotliCompress", "brotliDecompress"];
963
- let at = !1;
964
- function Qn(t) {
970
+ const Kn = ["readFile", "writeFile", "appendFile", "readdir", "stat", "lstat", "fstat", "access", "open", "close", "read", "write", "chmod", "mkdir", "rmdir", "unlink", "rename"], at = ["lookup", "resolve", "resolve4", "resolve6", "resolveAny", "resolveMx", "resolveNs", "resolveTxt", "reverse"], Jn = ["pbkdf2", "randomBytes", "scrypt", "generateKeyPair"], Qn = ["gzip", "gunzip", "deflate", "inflate", "deflateRaw", "inflateRaw", "brotliCompress", "brotliDecompress"];
971
+ let ct = !1;
972
+ function Wn(t) {
965
973
  if (typeof t != "string") return !1;
966
974
  const n = process.env.SF_FUNCSPAN_JSONL_FILE;
967
975
  if (n && t.includes(n)) return !0;
968
976
  const e = process.env.SF_WORKER_POOL_JSONL_FILE;
969
977
  return !(!e || !t.includes(e));
970
978
  }
971
- let ct = !1;
972
- function ut(t) {
979
+ let ut = !1;
980
+ function lt(t) {
973
981
  if (typeof t != "string") return !1;
974
982
  if (t === "localhost" || t === "127.0.0.1" || t === "::1") return !0;
975
983
  try {
@@ -980,8 +988,8 @@ function ut(t) {
980
988
  }
981
989
  return !1;
982
990
  }
983
- function Wn() {
984
- if (!ct) try {
991
+ function Vn() {
992
+ if (!ut) try {
985
993
  let t;
986
994
  if (typeof require > "u") return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] Skipping dns patching in pure ESM environment (require unavailable)"));
987
995
  try {
@@ -991,97 +999,97 @@ function Wn() {
991
999
  }
992
1000
  if (t.__sf_worker_pool_patched__) return;
993
1001
  Object.defineProperty(t, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
994
- for (const n of it) if (typeof t[n] == "function") {
1002
+ for (const n of at) if (typeof t[n] == "function") {
995
1003
  const e = t[n];
996
1004
  t[n] = function(...o) {
997
- return Ye() ? e.apply(this, o) : ut(o[0]) ? e.apply(this, o) : typeof o[o.length - 1] == "function" ? Se("dns", n, e, o, this) : e.apply(this, o);
1005
+ return Ze() ? e.apply(this, o) : lt(o[0]) ? e.apply(this, o) : typeof o[o.length - 1] == "function" ? Se("dns", n, e, o, this) : e.apply(this, o);
998
1006
  }, Object.defineProperty(t[n], "name", { value: n, writable: !1 });
999
1007
  }
1000
1008
  (function(n) {
1001
1009
  if (!n.promises) return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns.promises not available, skipping"));
1002
1010
  if (!n.promises.__sf_worker_pool_patched__) {
1003
1011
  Object.defineProperty(n.promises, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
1004
- for (const e of it) if (typeof n.promises[e] == "function") {
1012
+ for (const e of at) if (typeof n.promises[e] == "function") {
1005
1013
  const o = n.promises[e];
1006
1014
  n.promises[e] = function(...r) {
1007
- return Ye() ? o.apply(this, r) : ut(r[0]) ? o.apply(this, r) : cn("dns", e, o, r, this);
1015
+ return Ze() ? o.apply(this, r) : lt(r[0]) ? o.apply(this, r) : un("dns", e, o, r, this);
1008
1016
  }, Object.defineProperty(n.promises[e], "name", { value: e, writable: !1 });
1009
1017
  }
1010
1018
  process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns.promises module patched successfully");
1011
1019
  }
1012
- })(t), ct = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns module patched successfully");
1020
+ })(t), ut = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns module patched successfully");
1013
1021
  } catch (t) {
1014
1022
  console.error("[WorkerPool] Error patching dns module:", t);
1015
1023
  }
1016
1024
  }
1017
- let lt = !1, dt = !1, Be = !1;
1018
- function Vn() {
1019
- if (Be) return;
1025
+ let dt = !1, pt = !1, Oe = !1;
1026
+ function Gn() {
1027
+ if (Oe) return;
1020
1028
  const t = process.env.SF_DEBUG === "true";
1021
1029
  t && console.log("[WorkerPool] Initializing worker pool patching..."), fe("fs") && (t && console.log("[WorkerPool] Patching fs module..."), (function() {
1022
- if (!at) try {
1030
+ if (!ct) try {
1023
1031
  const n = require("node:fs");
1024
1032
  if (n.__sf_worker_pool_patched__) return;
1025
1033
  Object.defineProperty(n, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
1026
- for (const e of Hn) if (typeof n[e] == "function") {
1034
+ for (const e of Kn) if (typeof n[e] == "function") {
1027
1035
  const o = n[e];
1028
1036
  n[e] = function(...r) {
1029
- return Qn(r[0]) ? o.apply(this, r) : typeof r[r.length - 1] == "function" ? Se("fs", e, o, r, this) : o.apply(this, r);
1037
+ return Wn(r[0]) ? o.apply(this, r) : typeof r[r.length - 1] == "function" ? Se("fs", e, o, r, this) : o.apply(this, r);
1030
1038
  }, Object.defineProperty(n[e], "name", { value: e, writable: !1 });
1031
1039
  }
1032
- at = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] fs module patched successfully");
1040
+ ct = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] fs module patched successfully");
1033
1041
  } catch (n) {
1034
1042
  console.error("[WorkerPool] Error patching fs module:", n);
1035
1043
  }
1036
- })()), fe("dns") && (t && console.log("[WorkerPool] Patching dns module..."), Wn()), fe("crypto") && (t && console.log("[WorkerPool] Patching crypto module..."), (function() {
1037
- if (!lt) try {
1044
+ })()), fe("dns") && (t && console.log("[WorkerPool] Patching dns module..."), Vn()), fe("crypto") && (t && console.log("[WorkerPool] Patching crypto module..."), (function() {
1045
+ if (!dt) try {
1038
1046
  const n = require("node:crypto");
1039
1047
  if (n.__sf_worker_pool_patched__) return;
1040
1048
  Object.defineProperty(n, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
1041
- for (const e of Kn) if (typeof n[e] == "function") {
1049
+ for (const e of Jn) if (typeof n[e] == "function") {
1042
1050
  const o = n[e];
1043
1051
  n[e] = function(...r) {
1044
1052
  return typeof r[r.length - 1] == "function" ? Se("crypto", e, o, r, this) : o.apply(this, r);
1045
1053
  }, Object.defineProperty(n[e], "name", { value: e, writable: !1 });
1046
1054
  }
1047
- lt = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] crypto module patched successfully");
1055
+ dt = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] crypto module patched successfully");
1048
1056
  } catch (n) {
1049
1057
  console.error("[WorkerPool] Error patching crypto module:", n);
1050
1058
  }
1051
1059
  })()), fe("zlib") && (t && console.log("[WorkerPool] Patching zlib module..."), (function() {
1052
- if (!dt) try {
1060
+ if (!pt) try {
1053
1061
  const n = require("node:zlib");
1054
1062
  if (n.__sf_worker_pool_patched__) return;
1055
1063
  Object.defineProperty(n, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
1056
- for (const e of Jn) if (typeof n[e] == "function") {
1064
+ for (const e of Qn) if (typeof n[e] == "function") {
1057
1065
  const o = n[e];
1058
1066
  n[e] = function(...r) {
1059
1067
  return typeof r[r.length - 1] == "function" ? Se("zlib", e, o, r, this) : o.apply(this, r);
1060
1068
  }, Object.defineProperty(n[e], "name", { value: e, writable: !1 });
1061
1069
  }
1062
- dt = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] zlib module patched successfully");
1070
+ pt = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] zlib module patched successfully");
1063
1071
  } catch (n) {
1064
1072
  console.error("[WorkerPool] Error patching zlib module:", n);
1065
1073
  }
1066
- })()), Be = !0, t && console.log("[WorkerPool] Worker pool patching initialized");
1074
+ })()), Oe = !0, t && console.log("[WorkerPool] Worker pool patching initialized");
1067
1075
  }
1068
- function Gn() {
1069
- return Be;
1076
+ function zn() {
1077
+ return Oe;
1070
1078
  }
1071
- const pt = se.toLowerCase();
1079
+ const ft = se.toLowerCase();
1072
1080
  function Z(t) {
1073
1081
  if (t != null) {
1074
1082
  if (Array.isArray(t)) {
1075
1083
  for (const n of t)
1076
- if (!(!n || typeof n != "object") && ft(n.key) === pt)
1084
+ if (!(!n || typeof n != "object") && ht(n.key) === ft)
1077
1085
  return n.value;
1078
1086
  } else if (typeof t == "object") {
1079
- for (const [n, e] of Object.entries(t)) if (ft(n) === pt)
1087
+ for (const [n, e] of Object.entries(t)) if (ht(n) === ft)
1080
1088
  return Array.isArray(e) ? e.length === 0 ? void 0 : e[0] : e;
1081
1089
  }
1082
1090
  }
1083
1091
  }
1084
- function ft(t) {
1092
+ function ht(t) {
1085
1093
  if (typeof t == "string") return t.toLowerCase();
1086
1094
  if (Buffer.isBuffer(t)) try {
1087
1095
  return t.toString("utf8").toLowerCase();
@@ -1095,28 +1103,28 @@ function ft(t) {
1095
1103
  }
1096
1104
  return null;
1097
1105
  }
1098
- let De = null;
1099
- function Ot() {
1100
- return De || (De = new Lt()), De;
1106
+ let Pe = null;
1107
+ function Mt() {
1108
+ return Pe || (Pe = new Rt()), Pe;
1101
1109
  }
1102
- function Mt(t) {
1110
+ function jt(t) {
1103
1111
  if (!t) return null;
1104
1112
  const n = t.split("/").filter(Boolean);
1105
1113
  return n.length < 3 ? null : { sessionId: n[0], pageVisitId: n[1], requestId: n[n.length - 1] };
1106
1114
  }
1107
- const zn = /^[A-Za-z0-9._:-]{1,128}$/;
1115
+ const Xn = /^[A-Za-z0-9._:-]{1,128}$/;
1108
1116
  function ne(t) {
1109
1117
  if (typeof t != "string" || t.length === 0 || t.length > 1024) return !1;
1110
1118
  const n = t.split("/").filter(Boolean);
1111
1119
  if (n.length < 3 || n.length > 6) return !1;
1112
- for (const e of n) if (!zn.test(e)) return !1;
1120
+ for (const e of n) if (!Xn.test(e)) return !1;
1113
1121
  return !0;
1114
1122
  }
1115
1123
  function re(t) {
1116
1124
  const n = t.split("/");
1117
1125
  return n.length >= 3 ? (n[n.length - 1] = ce(), n.join("/")) : `${t}/${ce()}`;
1118
1126
  }
1119
- function Xn(t) {
1127
+ function Yn(t) {
1120
1128
  if (t == null) return null;
1121
1129
  if (typeof t == "string") return t;
1122
1130
  if (Buffer.isBuffer(t)) try {
@@ -1125,12 +1133,12 @@ function Xn(t) {
1125
1133
  return null;
1126
1134
  }
1127
1135
  try {
1128
- return JSON.stringify(Oe(t));
1136
+ return JSON.stringify(Me(t));
1129
1137
  } catch {
1130
1138
  return null;
1131
1139
  }
1132
1140
  }
1133
- function Oe(t, n = 0) {
1141
+ function Me(t, n = 0) {
1134
1142
  if (n > 10) return "[truncated-depth]";
1135
1143
  if (t == null) return t;
1136
1144
  const e = typeof t;
@@ -1149,15 +1157,15 @@ function Oe(t, n = 0) {
1149
1157
  }
1150
1158
  if (t instanceof Map) return `[Map size=${t.size}]`;
1151
1159
  if (t instanceof Set) return `[Set size=${t.size}]`;
1152
- if (Array.isArray(t)) return t.map((r) => Oe(r, n + 1));
1160
+ if (Array.isArray(t)) return t.map((r) => Me(r, n + 1));
1153
1161
  const o = {};
1154
1162
  for (const r of Object.getOwnPropertyNames(t)) {
1155
1163
  const i = Object.getOwnPropertyDescriptor(t, r);
1156
- i && typeof i.get != "function" && typeof i.set != "function" && (o[r] = Oe(i.value, n + 1));
1164
+ i && typeof i.get != "function" && typeof i.set != "function" && (o[r] = Me(i.value, n + 1));
1157
1165
  }
1158
1166
  return o;
1159
1167
  }
1160
- function jt(t) {
1168
+ function xt(t) {
1161
1169
  if (!t) return null;
1162
1170
  try {
1163
1171
  const n = t.message;
@@ -1176,21 +1184,21 @@ function jt(t) {
1176
1184
  }
1177
1185
  return "[unstringifiable error]";
1178
1186
  }
1179
- function F(t) {
1180
- const n = Q.getInstance().getOrSetSfTraceId(), e = re(n), o = Mt(e), r = Date.now(), i = m(), d = t.queueUri, u = t.method ?? "ENQUEUE", a = xt(t.messagePayload, i);
1187
+ function T(t) {
1188
+ const n = Q.getInstance().getOrSetSfTraceId(), e = re(n), o = jt(e), r = Date.now(), i = y(), d = t.queueUri, u = t.method ?? "ENQUEUE", a = Ht(t.messagePayload, i);
1181
1189
  return { traceId: e, hopEnd: (s) => {
1182
1190
  try {
1183
1191
  if (!o) return;
1184
- const l = Date.now();
1185
- let c = null;
1192
+ const c = Date.now();
1193
+ let l = null;
1186
1194
  try {
1187
- c = K() ?? null;
1195
+ l = K() ?? null;
1188
1196
  } catch {
1189
1197
  }
1190
- const p = { apiKey: i.apiKey, requestId: o.requestId, pageVisitId: o.pageVisitId, recordingSessionId: o.sessionId, serviceUuid: i.serviceUUID ?? null, timestampStart: r.toString(), timestampEnd: l.toString(), responseCode: s ? 500 : 0, success: !s, error: jt(s), url: d, method: u, parentSpanId: c };
1191
- a !== null && (p.requestBody = a), Ht(p);
1198
+ const p = { apiKey: i.apiKey, requestId: o.requestId, pageVisitId: o.pageVisitId, recordingSessionId: o.sessionId, serviceUuid: i.serviceUUID ?? null, timestampStart: r.toString(), timestampEnd: c.toString(), responseCode: s ? 500 : 0, success: !s, error: xt(s), url: d, method: u, parentSpanId: l };
1199
+ a !== null && (p.requestBody = a), Kt(p);
1192
1200
  try {
1193
- Ot().doSend(p);
1201
+ Mt().doSend(p);
1194
1202
  } catch (f) {
1195
1203
  i.sfDebug && console.warn("[asyncQueues] producer hop transmit failed:", f);
1196
1204
  }
@@ -1198,41 +1206,41 @@ function F(t) {
1198
1206
  }
1199
1207
  } };
1200
1208
  }
1201
- function xt(t, n) {
1209
+ function Ht(t, n) {
1202
1210
  if (!n.captureRequestBody || t === void 0) return null;
1203
- const e = Xn(t);
1211
+ const e = Yn(t);
1204
1212
  return e ? (function(o, r) {
1205
1213
  return !r || r <= 0 ? o : o.length > r ? o.substring(0, r) + "...[truncated]" : o;
1206
1214
  })(e, n.requestBodyLimitBytes) : null;
1207
1215
  }
1208
1216
  function j(t, n) {
1209
- if (ht.getStore() === !0) return Promise.resolve(n());
1210
- const e = Q.getInstance(), o = m(), r = t.incomingTraceId !== void 0 && ne(t.incomingTraceId) ? t.incomingTraceId : `${tn}-v3/${o.apiKey}/${ce()}`, i = t.queueUri, d = t.method, u = t.library, a = xt(t.messagePayload, o);
1211
- return ht.run(!0, () => e.runScoped({ traceId: r }, async () => {
1217
+ if (gt.getStore() === !0) return Promise.resolve(n());
1218
+ const e = Q.getInstance(), o = y(), r = t.incomingTraceId !== void 0 && ne(t.incomingTraceId) ? t.incomingTraceId : `${nn}-v3/${o.apiKey}/${ce()}`, i = t.queueUri, d = t.method, u = t.library, a = Ht(t.messagePayload, o);
1219
+ return gt.run(!0, () => e.runScoped({ traceId: r }, async () => {
1212
1220
  const s = Date.now();
1213
- let l = null;
1221
+ let c = null;
1214
1222
  try {
1215
- const c = await Promise.resolve(n());
1223
+ const l = await Promise.resolve(n());
1216
1224
  return await (function(p) {
1217
- return p !== null && typeof p == "object" && typeof p.subscribe == "function" ? new Promise((f, y) => {
1218
- let h, g = !1;
1225
+ return p !== null && typeof p == "object" && typeof p.subscribe == "function" ? new Promise((f, g) => {
1226
+ let h, m = !1;
1219
1227
  try {
1220
- p.subscribe({ next: (S) => {
1221
- h = S, g = !0;
1222
- }, error: (S) => y(S), complete: () => f(g ? h : void 0) });
1223
- } catch (S) {
1224
- y(S);
1228
+ p.subscribe({ next: (I) => {
1229
+ h = I, m = !0;
1230
+ }, error: (I) => g(I), complete: () => f(m ? h : void 0) });
1231
+ } catch (I) {
1232
+ g(I);
1225
1233
  }
1226
1234
  }) : p;
1227
- })(c);
1228
- } catch (c) {
1229
- throw l = c instanceof Error ? c : new Error(String(c)), c;
1235
+ })(l);
1236
+ } catch (l) {
1237
+ throw c = l instanceof Error ? l : new Error(String(l)), l;
1230
1238
  } finally {
1231
- (function(c, p, f, y, h, g) {
1239
+ (function(l, p, f, g, h, m) {
1232
1240
  try {
1233
- const S = Mt(f);
1234
- if (!S) return;
1235
- const I = m(), { graceful: E, tag: w } = (function(H) {
1241
+ const I = jt(f);
1242
+ if (!I) return;
1243
+ const E = y(), { graceful: b, tag: w } = (function(H) {
1236
1244
  if (!H) return { graceful: !0, tag: null };
1237
1245
  let V;
1238
1246
  try {
@@ -1241,58 +1249,58 @@ function j(t, n) {
1241
1249
  return { graceful: !1, tag: null };
1242
1250
  }
1243
1251
  return V === "AbortError" ? { graceful: !0, tag: "CONSUME_CANCELLED" } : V === "DelayedError" ? { graceful: !0, tag: "CONSUME_RESCHEDULED" } : V === "WaitingChildrenError" ? { graceful: !0, tag: "CONSUME_WAITING_CHILDREN" } : { graceful: !1, tag: null };
1244
- })(g), _ = !g && c.method ? c.method : w ?? c.method ?? "CONSUME", N = !g || E, B = g && !E ? 500 : 0, $ = g && !E ? jt(g) : null;
1245
- let T = null;
1252
+ })(m), _ = !m && l.method ? l.method : w ?? l.method ?? "CONSUME", k = !m || b, P = m && !b ? 500 : 0, $ = m && !b ? xt(m) : null;
1253
+ let C = null;
1246
1254
  try {
1247
- T = K() ?? null;
1255
+ C = K() ?? null;
1248
1256
  } catch {
1249
1257
  }
1250
- const P = { apiKey: I.apiKey, requestId: S.requestId, pageVisitId: S.pageVisitId, recordingSessionId: S.sessionId, serviceUuid: I.serviceUUID ?? null, timestampStart: y.toString(), timestampEnd: h.toString(), responseCode: B, success: N, error: $, url: c.queueUri, method: _, parentSpanId: T };
1251
- p !== null && (P.requestBody = p), Ht(P);
1258
+ const F = { apiKey: E.apiKey, requestId: I.requestId, pageVisitId: I.pageVisitId, recordingSessionId: I.sessionId, serviceUuid: E.serviceUUID ?? null, timestampStart: g.toString(), timestampEnd: h.toString(), responseCode: P, success: k, error: $, url: l.queueUri, method: _, parentSpanId: C };
1259
+ p !== null && (F.requestBody = p), Kt(F);
1252
1260
  try {
1253
- Ot().doSend(P);
1261
+ Mt().doSend(F);
1254
1262
  } catch (H) {
1255
- I.sfDebug && console.warn("[asyncQueues] consumer hop transmit failed:", H);
1263
+ E.sfDebug && console.warn("[asyncQueues] consumer hop transmit failed:", H);
1256
1264
  }
1257
1265
  } catch {
1258
1266
  }
1259
- })({ library: u, queueUri: i, method: d }, a, r, s, Date.now(), l);
1267
+ })({ library: u, queueUri: i, method: d }, a, r, s, Date.now(), c);
1260
1268
  }
1261
1269
  }));
1262
1270
  }
1263
- const ht = new Un();
1264
- let Me = null;
1265
- function qr(t) {
1266
- Me = t;
1271
+ const gt = new Dn();
1272
+ let je = null;
1273
+ function Lr(t) {
1274
+ je = t;
1267
1275
  }
1268
- function Ht(t) {
1269
- if (Me !== null) try {
1270
- Me(t);
1276
+ function Kt(t) {
1277
+ if (je !== null) try {
1278
+ je(t);
1271
1279
  } catch {
1272
1280
  }
1273
1281
  }
1274
- const v = Symbol.for("sailfish.async-queues.patched"), k = Symbol.for("sailfish.async-queues.instance-wrapped"), je = [];
1282
+ const v = Symbol.for("sailfish.async-queues.patched"), N = Symbol.for("sailfish.async-queues.instance-wrapped"), xe = [];
1275
1283
  function U(t, n, e) {
1276
- if (je.some((r) => r.proto === t && r.key === n)) return !1;
1284
+ if (xe.some((r) => r.proto === t && r.key === n)) return !1;
1277
1285
  const o = typeof t?.[n] == "function" ? t[n] : void 0;
1278
1286
  try {
1279
- return t[n] = e, je.push({ proto: t, key: n, original: o }), !0;
1287
+ return t[n] = e, xe.push({ proto: t, key: n, original: o }), !0;
1280
1288
  } catch (r) {
1281
- if (m().sfDebug) {
1289
+ if (y().sfDebug) {
1282
1290
  const i = t?.constructor?.name ?? "<unknown>";
1283
1291
  console.warn(`[asyncQueues] could not install patch on ${i}.prototype.${n} (frozen / non-writable?):`, r);
1284
1292
  }
1285
1293
  return !1;
1286
1294
  }
1287
1295
  }
1288
- function A(t, n) {
1296
+ function q(t, n) {
1289
1297
  try {
1290
1298
  return t();
1291
1299
  } catch (e) {
1292
- return m().sfDebug && console.warn(`[asyncQueues] instrumentation rewrite threw in ${n} — falling back to original args, no hop emitted:`, e), null;
1300
+ return y().sfDebug && console.warn(`[asyncQueues] instrumentation rewrite threw in ${n} — falling back to original args, no hop emitted:`, e), null;
1293
1301
  }
1294
1302
  }
1295
- function C(t, n) {
1303
+ function A(t, n) {
1296
1304
  let e = t || "unknown";
1297
1305
  if (typeof e == "string") {
1298
1306
  e.startsWith("bull:") && (e = e.slice(5));
@@ -1308,7 +1316,7 @@ function M(t, n) {
1308
1316
  const e = t ? { ...t } : {}, o = e.sf && typeof e.sf == "object" ? e.sf : {};
1309
1317
  return e.sf = { ...o, rid: n }, e;
1310
1318
  }
1311
- function Yn(t) {
1319
+ function Zn(t) {
1312
1320
  let n = t;
1313
1321
  if (!n) try {
1314
1322
  n = require("bullmq");
@@ -1319,153 +1327,153 @@ function Yn(t) {
1319
1327
  try {
1320
1328
  const s = a?.version ?? a?.Queue?.version;
1321
1329
  if (typeof s != "string") return;
1322
- parseInt(s.split(".")[0] ?? "0", 10) < 3 && m().sfDebug && console.warn(`[sf-veritas] BullMQ ${s} detected. Async-queue tracing is best-supported on BullMQ ≥ 3.0. Some APIs (FlowProducer, upsertJobScheduler, Job.promote) may be missing on older versions and will be skipped silently.`);
1330
+ parseInt(s.split(".")[0] ?? "0", 10) < 3 && y().sfDebug && console.warn(`[sf-veritas] BullMQ ${s} detected. Async-queue tracing is best-supported on BullMQ ≥ 3.0. Some APIs (FlowProducer, upsertJobScheduler, Job.promote) may be missing on older versions and will be skipped silently.`);
1323
1331
  } catch {
1324
1332
  }
1325
1333
  })(n);
1326
1334
  const e = n.Queue, o = n.Worker;
1327
- if (!e?.prototype || !o?.prototype) return m().sfDebug && console.warn("[asyncQueues][bullmq] Expected Queue/Worker classes not found on module — skipping patch."), "failed";
1335
+ if (!e?.prototype || !o?.prototype) return y().sfDebug && console.warn("[asyncQueues][bullmq] Expected Queue/Worker classes not found on module — skipping patch."), "failed";
1328
1336
  (function(a) {
1329
1337
  const s = a.prototype.add;
1330
1338
  if (typeof s != "function" || s[v]) return;
1331
- const l = async function(c, p, f) {
1332
- if (f?.sf?.rid) return s.call(this, c, p, f);
1333
- const y = A(() => {
1334
- const g = F({ library: "bullmq", queueUri: C(this?.name, c), messagePayload: p });
1335
- return { handle: g, nextOpts: M(f, g.traceId) };
1339
+ const c = async function(l, p, f) {
1340
+ if (f?.sf?.rid) return s.call(this, l, p, f);
1341
+ const g = q(() => {
1342
+ const m = T({ library: "bullmq", queueUri: A(this?.name, l), messagePayload: p });
1343
+ return { handle: m, nextOpts: M(f, m.traceId) };
1336
1344
  }, "bullmq.Queue.add");
1337
- if (y === null) return s.call(this, c, p, f);
1345
+ if (g === null) return s.call(this, l, p, f);
1338
1346
  let h = null;
1339
1347
  try {
1340
- return await s.call(this, c, p, y.nextOpts);
1341
- } catch (g) {
1342
- throw h = g instanceof Error ? g : new Error(String(g)), g;
1348
+ return await s.call(this, l, p, g.nextOpts);
1349
+ } catch (m) {
1350
+ throw h = m instanceof Error ? m : new Error(String(m)), m;
1343
1351
  } finally {
1344
- y.handle.hopEnd(h);
1352
+ g.handle.hopEnd(h);
1345
1353
  }
1346
1354
  };
1347
- l[v] = !0, U(a.prototype, "add", l);
1355
+ c[v] = !0, U(a.prototype, "add", c);
1348
1356
  })(e), (function(a) {
1349
1357
  const s = a.prototype.addBulk;
1350
1358
  if (typeof s != "function" || s[v]) return;
1351
- const l = async function(c) {
1352
- if (!Array.isArray(c) || c.length === 0) return s.call(this, c);
1353
- if (c.every((h) => h?.opts?.sf?.rid)) return s.call(this, c);
1354
- const p = m().bullmqBulkAggregateMode, f = A(() => {
1359
+ const c = async function(l) {
1360
+ if (!Array.isArray(l) || l.length === 0) return s.call(this, l);
1361
+ if (l.every((h) => h?.opts?.sf?.rid)) return s.call(this, l);
1362
+ const p = y().bullmqBulkAggregateMode, f = q(() => {
1355
1363
  if (p) {
1356
- const S = F({ library: "bullmq", queueUri: C(this?.name, `__bulk_${c.length}`), method: "ENQUEUE_BULK", messagePayload: { batchSize: c.length } }), I = c.map((E) => ({ ...E, opts: M(E?.opts, S.traceId) }));
1357
- return { handles: [S], out: I };
1364
+ const I = T({ library: "bullmq", queueUri: A(this?.name, `__bulk_${l.length}`), method: "ENQUEUE_BULK", messagePayload: { batchSize: l.length } }), E = l.map((b) => ({ ...b, opts: M(b?.opts, I.traceId) }));
1365
+ return { handles: [I], out: E };
1358
1366
  }
1359
- const h = c.map((S) => F({ library: "bullmq", queueUri: C(this?.name, S?.name), messagePayload: S?.data })), g = c.map((S, I) => ({ ...S, opts: M(S?.opts, h[I].traceId) }));
1360
- return { handles: h, out: g };
1367
+ const h = l.map((I) => T({ library: "bullmq", queueUri: A(this?.name, I?.name), messagePayload: I?.data })), m = l.map((I, E) => ({ ...I, opts: M(I?.opts, h[E].traceId) }));
1368
+ return { handles: h, out: m };
1361
1369
  }, "bullmq.Queue.addBulk");
1362
- if (f === null) return s.call(this, c);
1363
- let y = null;
1370
+ if (f === null) return s.call(this, l);
1371
+ let g = null;
1364
1372
  try {
1365
1373
  return await s.call(this, f.out);
1366
1374
  } catch (h) {
1367
- throw y = h instanceof Error ? h : new Error(String(h)), h;
1375
+ throw g = h instanceof Error ? h : new Error(String(h)), h;
1368
1376
  } finally {
1369
- for (const h of f.handles) h.hopEnd(y);
1377
+ for (const h of f.handles) h.hopEnd(g);
1370
1378
  }
1371
1379
  };
1372
- l[v] = !0, U(a.prototype, "addBulk", l);
1380
+ c[v] = !0, U(a.prototype, "addBulk", c);
1373
1381
  })(e), (function(a) {
1374
1382
  const s = a.prototype.upsertJobScheduler;
1375
1383
  if (typeof s != "function" || s[v]) return;
1376
- const l = async function(c, p, f) {
1377
- const y = A(() => {
1378
- const g = F({ library: "bullmq", queueUri: C(this?.name, f?.name ?? c), method: "ENQUEUE" });
1379
- let S;
1384
+ const c = async function(l, p, f) {
1385
+ const g = q(() => {
1386
+ const m = T({ library: "bullmq", queueUri: A(this?.name, f?.name ?? l), method: "ENQUEUE" });
1387
+ let I;
1380
1388
  if (f !== void 0) {
1381
- const I = { ...f, opts: M(f.opts, g.traceId) };
1382
- S = [c, p, I];
1383
- } else S = [c, p];
1384
- return { handle: g, callArgs: S };
1389
+ const E = { ...f, opts: M(f.opts, m.traceId) };
1390
+ I = [l, p, E];
1391
+ } else I = [l, p];
1392
+ return { handle: m, callArgs: I };
1385
1393
  }, "bullmq.Queue.upsertJobScheduler");
1386
- if (y === null) {
1387
- const g = f !== void 0 ? [c, p, f] : [c, p];
1388
- return s.call(this, ...g);
1394
+ if (g === null) {
1395
+ const m = f !== void 0 ? [l, p, f] : [l, p];
1396
+ return s.call(this, ...m);
1389
1397
  }
1390
1398
  let h = null;
1391
1399
  try {
1392
- return await s.call(this, ...y.callArgs);
1393
- } catch (g) {
1394
- throw h = g instanceof Error ? g : new Error(String(g)), g;
1400
+ return await s.call(this, ...g.callArgs);
1401
+ } catch (m) {
1402
+ throw h = m instanceof Error ? m : new Error(String(m)), m;
1395
1403
  } finally {
1396
- y.handle.hopEnd(h);
1404
+ g.handle.hopEnd(h);
1397
1405
  }
1398
1406
  };
1399
- l[v] = !0, U(a.prototype, "upsertJobScheduler", l);
1407
+ c[v] = !0, U(a.prototype, "upsertJobScheduler", c);
1400
1408
  })(e), (function(a) {
1401
1409
  const s = a.prototype.getNextJob;
1402
1410
  if (typeof s != "function" || s[v]) return;
1403
- const l = async function(...c) {
1404
- const p = await s.apply(this, c);
1411
+ const c = async function(...l) {
1412
+ const p = await s.apply(this, l);
1405
1413
  if (p && ne(p.opts?.sf?.rid)) try {
1406
1414
  Q.getInstance().setTraceId(p.opts.sf.rid);
1407
1415
  } catch {
1408
1416
  }
1409
1417
  return p;
1410
1418
  };
1411
- l[v] = !0, U(a.prototype, "getNextJob", l);
1419
+ c[v] = !0, U(a.prototype, "getNextJob", c);
1412
1420
  })(e), (function(a) {
1413
1421
  const s = a.prototype.getJob;
1414
1422
  if (typeof s != "function" || s[v]) return;
1415
- const l = async function(...c) {
1416
- const p = await s.apply(this, c);
1423
+ const c = async function(...l) {
1424
+ const p = await s.apply(this, l);
1417
1425
  if (p && ne(p.opts?.sf?.rid)) try {
1418
- const y = Q.getInstance();
1419
- (!(f = y.getTraceId()) || f.startsWith("nonsession-applogs-v3/")) && y.setTraceId(p.opts.sf.rid);
1426
+ const g = Q.getInstance();
1427
+ (!(f = g.getTraceId()) || f.startsWith("nonsession-applogs-v3/")) && g.setTraceId(p.opts.sf.rid);
1420
1428
  } catch {
1421
1429
  }
1422
1430
  var f;
1423
1431
  return p;
1424
1432
  };
1425
- l[v] = !0, U(a.prototype, "getJob", l);
1433
+ c[v] = !0, U(a.prototype, "getJob", c);
1426
1434
  })(e), (function(a) {
1427
1435
  const s = a.prototype.processJob;
1428
1436
  if (typeof s != "function" || s[v]) return;
1429
- const l = function(c, ...p) {
1430
- const f = c?.opts?.sf?.rid, y = typeof c?.attemptsMade == "number" ? c.attemptsMade : 0, h = typeof c?.stalledCounter == "number" ? c.stalledCounter : 0, g = c?.repeatJobKey != null || c?.opts?.repeat != null, S = f && (y > 0 || h > 0 || g) ? re(f) : f;
1431
- let I;
1432
- return h > 0 ? I = "CONSUME_STALLED" : g && y === 0 && (I = "CONSUME_SCHEDULED"), j({ library: "bullmq", queueUri: C(ve(c) ?? this?.name, c?.name), incomingTraceId: S, messagePayload: c?.data, method: I }, () => s.call(this, c, ...p));
1437
+ const c = function(l, ...p) {
1438
+ const f = l?.opts?.sf?.rid, g = typeof l?.attemptsMade == "number" ? l.attemptsMade : 0, h = typeof l?.stalledCounter == "number" ? l.stalledCounter : 0, m = l?.repeatJobKey != null || l?.opts?.repeat != null, I = f && (g > 0 || h > 0 || m) ? re(f) : f;
1439
+ let E;
1440
+ return h > 0 ? E = "CONSUME_STALLED" : m && g === 0 && (E = "CONSUME_SCHEDULED"), j({ library: "bullmq", queueUri: A(ve(l) ?? this?.name, l?.name), incomingTraceId: I, messagePayload: l?.data, method: E }, () => s.call(this, l, ...p));
1433
1441
  };
1434
- l[v] = !0, U(a.prototype, "processJob", l);
1442
+ c[v] = !0, U(a.prototype, "processJob", c);
1435
1443
  })(o);
1436
1444
  const r = n.Job;
1437
1445
  r?.prototype && (function(a) {
1438
1446
  const s = ["retry", "moveToDelayed", "promote"];
1439
- for (const l of s) {
1440
- const c = a.prototype[l];
1441
- if (typeof c != "function" || c[v]) continue;
1442
- const p = l === "promote" ? "PROMOTE" : l === "moveToDelayed" ? "RESCHEDULE" : "ENQUEUE_RETRY", f = async function(...y) {
1447
+ for (const c of s) {
1448
+ const l = a.prototype[c];
1449
+ if (typeof l != "function" || l[v]) continue;
1450
+ const p = c === "promote" ? "PROMOTE" : c === "moveToDelayed" ? "RESCHEDULE" : "ENQUEUE_RETRY", f = async function(...g) {
1443
1451
  const h = this?.opts?.sf?.rid;
1444
- let g;
1445
- if (h) g = re(h);
1452
+ let m;
1453
+ if (h) m = re(h);
1446
1454
  else {
1447
- const E = F({ queueUri: C(ve(this) ?? this?.name, this?.name), method: p });
1455
+ const b = T({ queueUri: A(ve(this) ?? this?.name, this?.name), method: p });
1448
1456
  let w = null;
1449
1457
  try {
1450
- return await c.apply(this, y);
1458
+ return await l.apply(this, g);
1451
1459
  } catch (_) {
1452
1460
  throw w = _ instanceof Error ? _ : new Error(String(_)), _;
1453
1461
  } finally {
1454
- E.hopEnd(w);
1462
+ b.hopEnd(w);
1455
1463
  }
1456
1464
  }
1457
- this.opts && (this.opts = { ...this.opts, sf: { ...this.opts.sf || {}, rid: g } });
1458
- const S = F({ queueUri: C(ve(this) ?? this?.name, this?.name), method: p });
1459
- let I = null;
1465
+ this.opts && (this.opts = { ...this.opts, sf: { ...this.opts.sf || {}, rid: m } });
1466
+ const I = T({ queueUri: A(ve(this) ?? this?.name, this?.name), method: p });
1467
+ let E = null;
1460
1468
  try {
1461
- return await c.apply(this, y);
1462
- } catch (E) {
1463
- throw I = E instanceof Error ? E : new Error(String(E)), E;
1469
+ return await l.apply(this, g);
1470
+ } catch (b) {
1471
+ throw E = b instanceof Error ? b : new Error(String(b)), b;
1464
1472
  } finally {
1465
- S.hopEnd(I);
1473
+ I.hopEnd(E);
1466
1474
  }
1467
1475
  };
1468
- f[v] = !0, U(a.prototype, l, f);
1476
+ f[v] = !0, U(a.prototype, c, f);
1469
1477
  }
1470
1478
  })(r);
1471
1479
  const i = n.QueueEvents;
@@ -1474,66 +1482,66 @@ function Yn(t) {
1474
1482
  return d?.prototype && ((function(a) {
1475
1483
  const s = a.prototype.add;
1476
1484
  if (typeof s != "function" || s[v]) return;
1477
- const l = async function(c, ...p) {
1478
- if (!c || typeof c != "object") return s.call(this, c, ...p);
1479
- if (c?.opts?.sf?.rid) return s.call(this, c, ...p);
1480
- const f = A(() => {
1485
+ const c = async function(l, ...p) {
1486
+ if (!l || typeof l != "object") return s.call(this, l, ...p);
1487
+ if (l?.opts?.sf?.rid) return s.call(this, l, ...p);
1488
+ const f = q(() => {
1481
1489
  const h = [];
1482
- return { hops: h, out: xe(c, h) };
1490
+ return { hops: h, out: He(l, h) };
1483
1491
  }, "bullmq.FlowProducer.add");
1484
- if (f === null) return s.call(this, c, ...p);
1485
- let y = null;
1492
+ if (f === null) return s.call(this, l, ...p);
1493
+ let g = null;
1486
1494
  try {
1487
1495
  return await s.call(this, f.out, ...p);
1488
1496
  } catch (h) {
1489
- throw y = h instanceof Error ? h : new Error(String(h)), h;
1497
+ throw g = h instanceof Error ? h : new Error(String(h)), h;
1490
1498
  } finally {
1491
- for (const h of f.hops) h.hopEnd(y);
1499
+ for (const h of f.hops) h.hopEnd(g);
1492
1500
  }
1493
1501
  };
1494
- l[v] = !0, U(a.prototype, "add", l);
1502
+ c[v] = !0, U(a.prototype, "add", c);
1495
1503
  })(d), (function(a) {
1496
1504
  const s = a.prototype.addBulk;
1497
1505
  if (typeof s != "function" || s[v]) return;
1498
- const l = async function(c) {
1499
- if (!Array.isArray(c) || c.length === 0) return s.call(this, c);
1500
- if (c.every((h) => h?.opts?.sf?.rid)) return s.call(this, c);
1501
- const p = m().bullmqBulkAggregateMode, f = A(() => {
1506
+ const c = async function(l) {
1507
+ if (!Array.isArray(l) || l.length === 0) return s.call(this, l);
1508
+ if (l.every((h) => h?.opts?.sf?.rid)) return s.call(this, l);
1509
+ const p = y().bullmqBulkAggregateMode, f = q(() => {
1502
1510
  if (p) {
1503
- const S = (_) => {
1504
- let N = 1;
1505
- if (Array.isArray(_?.children)) for (const B of _.children) N += S(B);
1506
- return N;
1507
- }, I = c.reduce((_, N) => _ + S(N), 0), E = F({ library: "bullmq-flow", queueUri: C(c[0]?.queueName, `__flow_bulk_${c.length}`), method: "ENQUEUE_BULK", messagePayload: { batchSize: c.length, totalNodes: I } }), w = c.map((_) => Kt(_, E.traceId));
1508
- return { hops: [E], out: w };
1511
+ const I = (_) => {
1512
+ let k = 1;
1513
+ if (Array.isArray(_?.children)) for (const P of _.children) k += I(P);
1514
+ return k;
1515
+ }, E = l.reduce((_, k) => _ + I(k), 0), b = T({ library: "bullmq-flow", queueUri: A(l[0]?.queueName, `__flow_bulk_${l.length}`), method: "ENQUEUE_BULK", messagePayload: { batchSize: l.length, totalNodes: E } }), w = l.map((_) => Jt(_, b.traceId));
1516
+ return { hops: [b], out: w };
1509
1517
  }
1510
- const h = [], g = c.map((S) => xe(S, h));
1511
- return { hops: h, out: g };
1518
+ const h = [], m = l.map((I) => He(I, h));
1519
+ return { hops: h, out: m };
1512
1520
  }, "bullmq.FlowProducer.addBulk");
1513
- if (f === null) return s.call(this, c);
1514
- let y = null;
1521
+ if (f === null) return s.call(this, l);
1522
+ let g = null;
1515
1523
  try {
1516
1524
  return await s.call(this, f.out);
1517
1525
  } catch (h) {
1518
- throw y = h instanceof Error ? h : new Error(String(h)), h;
1526
+ throw g = h instanceof Error ? h : new Error(String(h)), h;
1519
1527
  } finally {
1520
- for (const h of f.hops) h.hopEnd(y);
1528
+ for (const h of f.hops) h.hopEnd(g);
1521
1529
  }
1522
1530
  };
1523
- l[v] = !0, U(a.prototype, "addBulk", l);
1524
- })(d)), n.QueueScheduler?.prototype && m().sfDebug && console.log("[sf-veritas] BullMQ QueueScheduler detected (v4 API). No direct instrumentation needed — delayed/repeatable jobs are traced when the Worker picks them up via the Worker.processJob wrap."), "installed";
1531
+ c[v] = !0, U(a.prototype, "addBulk", c);
1532
+ })(d)), n.QueueScheduler?.prototype && y().sfDebug && console.log("[sf-veritas] BullMQ QueueScheduler detected (v4 API). No direct instrumentation needed — delayed/repeatable jobs are traced when the Worker picks them up via the Worker.processJob wrap."), "installed";
1525
1533
  }
1526
- function xe(t, n) {
1527
- const e = F({ queueUri: C(t?.queueName, t?.name), messagePayload: t?.data });
1534
+ function He(t, n) {
1535
+ const e = T({ queueUri: A(t?.queueName, t?.name), messagePayload: t?.data });
1528
1536
  n.push(e);
1529
1537
  const o = { ...t, opts: M(t?.opts, e.traceId) };
1530
- return Array.isArray(t?.children) && t.children.length > 0 && (o.children = t.children.map((r) => xe(r, n))), o;
1538
+ return Array.isArray(t?.children) && t.children.length > 0 && (o.children = t.children.map((r) => He(r, n))), o;
1531
1539
  }
1532
- function Kt(t, n) {
1540
+ function Jt(t, n) {
1533
1541
  const e = { ...t, opts: M(t?.opts, n) };
1534
- return Array.isArray(t?.children) && t.children.length > 0 && (e.children = t.children.map((o) => Kt(o, n))), e;
1542
+ return Array.isArray(t?.children) && t.children.length > 0 && (e.children = t.children.map((o) => Jt(o, n))), e;
1535
1543
  }
1536
- function Zn(t) {
1544
+ function er(t) {
1537
1545
  let n = t;
1538
1546
  if (!n) try {
1539
1547
  n = require("@taskforcesh/bullmq-pro");
@@ -1546,20 +1554,20 @@ function Zn(t) {
1546
1554
  return e?.prototype || o?.prototype ? (e?.prototype && ((function(i) {
1547
1555
  const d = i.prototype.add;
1548
1556
  if (typeof d != "function" || d[v]) return;
1549
- const u = async function(a, s, l) {
1550
- if (l?.sf?.rid) return d.call(this, a, s, l);
1551
- const c = A(() => {
1552
- const f = F({ library: "bullmq-pro", queueUri: C(this?.name, a), messagePayload: s });
1553
- return { handle: f, nextOpts: M(l, f.traceId) };
1557
+ const u = async function(a, s, c) {
1558
+ if (c?.sf?.rid) return d.call(this, a, s, c);
1559
+ const l = q(() => {
1560
+ const f = T({ library: "bullmq-pro", queueUri: A(this?.name, a), messagePayload: s });
1561
+ return { handle: f, nextOpts: M(c, f.traceId) };
1554
1562
  }, "bullmq-pro.QueuePro.add");
1555
- if (c === null) return d.call(this, a, s, l);
1563
+ if (l === null) return d.call(this, a, s, c);
1556
1564
  let p = null;
1557
1565
  try {
1558
- return await d.call(this, a, s, c.nextOpts);
1566
+ return await d.call(this, a, s, l.nextOpts);
1559
1567
  } catch (f) {
1560
1568
  throw p = f instanceof Error ? f : new Error(String(f)), f;
1561
1569
  } finally {
1562
- c.handle.hopEnd(p);
1570
+ l.handle.hopEnd(p);
1563
1571
  }
1564
1572
  };
1565
1573
  u[v] = !0, U(i.prototype, "add", u);
@@ -1569,84 +1577,84 @@ function Zn(t) {
1569
1577
  const u = async function(a) {
1570
1578
  if (!Array.isArray(a) || a.length === 0) return d.call(this, a);
1571
1579
  if (a.every((p) => p?.opts?.sf?.rid)) return d.call(this, a);
1572
- const s = m().bullmqBulkAggregateMode, l = A(() => {
1580
+ const s = y().bullmqBulkAggregateMode, c = q(() => {
1573
1581
  if (s) {
1574
- const y = F({ library: "bullmq-pro", queueUri: C(this?.name, `__bulk_${a.length}`), method: "ENQUEUE_BULK", messagePayload: { batchSize: a.length } }), h = a.map((g) => ({ ...g, opts: M(g?.opts, y.traceId) }));
1575
- return { handles: [y], out: h };
1582
+ const g = T({ library: "bullmq-pro", queueUri: A(this?.name, `__bulk_${a.length}`), method: "ENQUEUE_BULK", messagePayload: { batchSize: a.length } }), h = a.map((m) => ({ ...m, opts: M(m?.opts, g.traceId) }));
1583
+ return { handles: [g], out: h };
1576
1584
  }
1577
- const p = a.map((y) => F({ library: "bullmq-pro", queueUri: C(this?.name, y?.name), messagePayload: y?.data })), f = a.map((y, h) => ({ ...y, opts: M(y?.opts, p[h].traceId) }));
1585
+ const p = a.map((g) => T({ library: "bullmq-pro", queueUri: A(this?.name, g?.name), messagePayload: g?.data })), f = a.map((g, h) => ({ ...g, opts: M(g?.opts, p[h].traceId) }));
1578
1586
  return { handles: p, out: f };
1579
1587
  }, "bullmq-pro.QueuePro.addBulk");
1580
- if (l === null) return d.call(this, a);
1581
- let c = null;
1588
+ if (c === null) return d.call(this, a);
1589
+ let l = null;
1582
1590
  try {
1583
- return await d.call(this, l.out);
1591
+ return await d.call(this, c.out);
1584
1592
  } catch (p) {
1585
- throw c = p instanceof Error ? p : new Error(String(p)), p;
1593
+ throw l = p instanceof Error ? p : new Error(String(p)), p;
1586
1594
  } finally {
1587
- for (const p of l.handles) p.hopEnd(c);
1595
+ for (const p of c.handles) p.hopEnd(l);
1588
1596
  }
1589
1597
  };
1590
1598
  u[v] = !0, U(i.prototype, "addBulk", u);
1591
1599
  })(e)), o?.prototype && ((function(i) {
1592
1600
  const d = i.prototype.processJob;
1593
- typeof d != "function" || d[v] || gt(i, "processJob", d);
1601
+ typeof d != "function" || d[v] || yt(i, "processJob", d);
1594
1602
  })(o), (function(i) {
1595
1603
  const d = i.prototype.getNextJob;
1596
1604
  if (typeof d != "function" || d[v]) return;
1597
1605
  const u = async function(...a) {
1598
1606
  const s = await d.apply(this, a);
1599
1607
  if (s && ne(s.opts?.sf?.rid)) try {
1600
- const c = Q.getInstance();
1601
- (!(l = c.getTraceId()) || l.startsWith("nonsession-applogs-v3/")) && c.setTraceId(s.opts.sf.rid);
1608
+ const l = Q.getInstance();
1609
+ (!(c = l.getTraceId()) || c.startsWith("nonsession-applogs-v3/")) && l.setTraceId(s.opts.sf.rid);
1602
1610
  } catch {
1603
1611
  }
1604
- var l;
1612
+ var c;
1605
1613
  return s;
1606
1614
  };
1607
1615
  u[v] = !0, U(i.prototype, "getNextJob", u);
1608
1616
  })(o), typeof o.prototype.callProcessJob == "function" && (function(i) {
1609
1617
  const d = i.prototype.callProcessJob;
1610
- typeof d != "function" || d[v] || gt(i, "callProcessJob", d);
1618
+ typeof d != "function" || d[v] || yt(i, "callProcessJob", d);
1611
1619
  })(o)), r?.prototype && (function(i) {
1612
1620
  const d = i.prototype.add;
1613
1621
  if (typeof d != "function" || d[v]) return;
1614
1622
  const u = async function(a, ...s) {
1615
1623
  if (!a || typeof a != "object") return d.call(this, a, ...s);
1616
1624
  if (a?.opts?.sf?.rid) return d.call(this, a, ...s);
1617
- const l = A(() => {
1625
+ const c = q(() => {
1618
1626
  const p = [];
1619
- return { hops: p, out: Jt(a, p) };
1627
+ return { hops: p, out: Qt(a, p) };
1620
1628
  }, "bullmq-pro.FlowProducerPro.add");
1621
- if (l === null) return d.call(this, a, ...s);
1622
- let c = null;
1629
+ if (c === null) return d.call(this, a, ...s);
1630
+ let l = null;
1623
1631
  try {
1624
- return await d.call(this, l.out, ...s);
1632
+ return await d.call(this, c.out, ...s);
1625
1633
  } catch (p) {
1626
- throw c = p instanceof Error ? p : new Error(String(p)), p;
1634
+ throw l = p instanceof Error ? p : new Error(String(p)), p;
1627
1635
  } finally {
1628
- for (const p of l.hops) p.hopEnd(c);
1636
+ for (const p of c.hops) p.hopEnd(l);
1629
1637
  }
1630
1638
  };
1631
1639
  u[v] = !0, U(i.prototype, "add", u);
1632
- })(r), "installed") : (m().sfDebug && console.warn("[asyncQueues][bullmq-pro] No QueuePro/WorkerPro found — patch no-op."), "failed");
1640
+ })(r), "installed") : (y().sfDebug && console.warn("[asyncQueues][bullmq-pro] No QueuePro/WorkerPro found — patch no-op."), "failed");
1633
1641
  }
1634
- function gt(t, n, e) {
1642
+ function yt(t, n, e) {
1635
1643
  const o = function(r, ...i) {
1636
- const d = r?.opts?.sf?.rid, u = typeof r?.attemptsMade == "number" ? r.attemptsMade : 0, a = typeof r?.stalledCounter == "number" ? r.stalledCounter : 0, s = r?.repeatJobKey != null || r?.opts?.repeat != null, l = ne(d) && (u > 0 || a > 0 || s) ? re(d) : ne(d) ? d : void 0;
1637
- let c;
1638
- return a > 0 ? c = "CONSUME_STALLED" : s && u === 0 && (c = "CONSUME_SCHEDULED"), j({ library: "bullmq-pro", queueUri: C(ve(r) ?? this?.name, r?.name), incomingTraceId: l, messagePayload: r?.data, method: c }, () => e.call(this, r, ...i));
1644
+ const d = r?.opts?.sf?.rid, u = typeof r?.attemptsMade == "number" ? r.attemptsMade : 0, a = typeof r?.stalledCounter == "number" ? r.stalledCounter : 0, s = r?.repeatJobKey != null || r?.opts?.repeat != null, c = ne(d) && (u > 0 || a > 0 || s) ? re(d) : ne(d) ? d : void 0;
1645
+ let l;
1646
+ return a > 0 ? l = "CONSUME_STALLED" : s && u === 0 && (l = "CONSUME_SCHEDULED"), j({ library: "bullmq-pro", queueUri: A(ve(r) ?? this?.name, r?.name), incomingTraceId: c, messagePayload: r?.data, method: l }, () => e.call(this, r, ...i));
1639
1647
  };
1640
1648
  o[v] = !0, U(t.prototype, n, o);
1641
1649
  }
1642
- function Jt(t, n, e = 0) {
1650
+ function Qt(t, n, e = 0) {
1643
1651
  if (e > 100) return t;
1644
- const o = F({ queueUri: C(t?.queueName, t?.name), messagePayload: t?.data });
1652
+ const o = T({ queueUri: A(t?.queueName, t?.name), messagePayload: t?.data });
1645
1653
  n.push(o);
1646
1654
  const r = { ...t, opts: M(t?.opts, o.traceId) };
1647
- return Array.isArray(t?.children) && t.children.length > 0 && (r.children = t.children.map((i) => Jt(i, n, e + 1))), r;
1655
+ return Array.isArray(t?.children) && t.children.length > 0 && (r.children = t.children.map((i) => Qt(i, n, e + 1))), r;
1648
1656
  }
1649
- const He = se.toLowerCase();
1657
+ const Ke = se.toLowerCase();
1650
1658
  function X(t) {
1651
1659
  if (t != null) {
1652
1660
  if (typeof t == "string") return t;
@@ -1670,20 +1678,20 @@ function ae(t) {
1670
1678
  if (Array.isArray(t)) for (const n of t) {
1671
1679
  if (!n || typeof n != "object") continue;
1672
1680
  const e = n.key;
1673
- if (typeof e == "string" && e.toLowerCase() === He) return X(n.value);
1681
+ if (typeof e == "string" && e.toLowerCase() === Ke) return X(n.value);
1674
1682
  }
1675
1683
  }
1676
- function Qt(t, n) {
1684
+ function Wt(t, n) {
1677
1685
  const e = [];
1678
1686
  if (Array.isArray(t)) {
1679
1687
  for (const o of t) if (o && typeof o == "object") {
1680
1688
  const r = o.key, i = o.value;
1681
- typeof r == "string" && r.toLowerCase() === He || e.push({ key: String(r), value: Buffer.isBuffer(i) ? i : Buffer.from(String(i ?? "")) });
1689
+ typeof r == "string" && r.toLowerCase() === Ke || e.push({ key: String(r), value: Buffer.isBuffer(i) ? i : Buffer.from(String(i ?? "")) });
1682
1690
  }
1683
- } else if (t && typeof t == "object") for (const [o, r] of Object.entries(t)) o.toLowerCase() !== He && e.push({ key: o, value: Buffer.isBuffer(r) ? r : Buffer.from(String(r ?? "")) });
1691
+ } else if (t && typeof t == "object") for (const [o, r] of Object.entries(t)) o.toLowerCase() !== Ke && e.push({ key: o, value: Buffer.isBuffer(r) ? r : Buffer.from(String(r ?? "")) });
1684
1692
  return e.push({ key: se, value: Buffer.from(n) }), e;
1685
1693
  }
1686
- function er(t) {
1694
+ function tr(t) {
1687
1695
  let n = t;
1688
1696
  if (!n) try {
1689
1697
  n = require("@confluentinc/kafka-javascript");
@@ -1695,7 +1703,7 @@ function er(t) {
1695
1703
  const i = r.prototype.produce;
1696
1704
  if (typeof i != "function" || i[v]) return;
1697
1705
  const d = function(...u) {
1698
- return u.length === 1 && u[0] && typeof u[0] == "object" && Array.isArray(u[0].messages) ? tr.call(this, i, u[0]) : nr.call(this, i, u);
1706
+ return u.length === 1 && u[0] && typeof u[0] == "object" && Array.isArray(u[0].messages) ? nr.call(this, i, u[0]) : rr.call(this, i, u);
1699
1707
  };
1700
1708
  d[v] = !0, U(r.prototype, "produce", d);
1701
1709
  })(n.KafkaProducer), e = !0), n.KafkaConsumer?.prototype && ((function(r) {
@@ -1703,9 +1711,9 @@ function er(t) {
1703
1711
  if (typeof i != "function" || i[v]) return;
1704
1712
  const d = function(u, a) {
1705
1713
  if (u !== "data" || typeof a != "function") return i.call(this, u, a);
1706
- const s = function(l) {
1707
- const c = ae(l?.headers), p = l?.topic, f = X(l?.value) ?? l?.value;
1708
- return j({ library: "confluent-kafka-js", queueUri: x(p), incomingTraceId: c, messagePayload: f }, () => a.call(this, l));
1714
+ const s = function(c) {
1715
+ const l = ae(c?.headers), p = c?.topic, f = X(c?.value) ?? c?.value;
1716
+ return j({ library: "confluent-kafka-js", queueUri: x(p), incomingTraceId: l, messagePayload: f }, () => a.call(this, c));
1709
1717
  };
1710
1718
  return i.call(this, u, s);
1711
1719
  };
@@ -1715,17 +1723,17 @@ function er(t) {
1715
1723
  return o?.Producer?.prototype?.send && ((function(r) {
1716
1724
  const i = r.prototype.send;
1717
1725
  if (typeof i == "function" && !i[v]) {
1718
- const a = Ke(i);
1726
+ const a = Je(i);
1719
1727
  a[v] = !0, U(r.prototype, "send", a);
1720
1728
  }
1721
1729
  const d = r.prototype.sendBatch;
1722
1730
  if (typeof d == "function" && !d[v]) {
1723
- const a = Je(d);
1731
+ const a = Qe(d);
1724
1732
  a[v] = !0, U(r.prototype, "sendBatch", a);
1725
1733
  }
1726
1734
  const u = r.prototype.transaction;
1727
1735
  if (typeof u == "function" && !u[v]) {
1728
- const a = mt(u);
1736
+ const a = St(u);
1729
1737
  a[v] = !0, U(r.prototype, "transaction", a);
1730
1738
  }
1731
1739
  })(o.Producer), e = !0), o?.Consumer?.prototype?.run && ((function(r) {
@@ -1736,22 +1744,22 @@ function er(t) {
1736
1744
  const a = { ...u };
1737
1745
  if (typeof u.eachMessage == "function") {
1738
1746
  const s = u.eachMessage;
1739
- a.eachMessage = (l) => {
1740
- const c = X(Z(l?.message?.headers)) ?? ae(l?.message?.headers), p = typeof l?.attempt == "number" ? l.attempt : 0, f = c && p > 0 ? re(c) : c;
1741
- return j({ library: "confluent-kafka-js", queueUri: x(l?.topic), incomingTraceId: f }, () => s(l));
1747
+ a.eachMessage = (c) => {
1748
+ const l = X(Z(c?.message?.headers)) ?? ae(c?.message?.headers), p = typeof c?.attempt == "number" ? c.attempt : 0, f = l && p > 0 ? re(l) : l;
1749
+ return j({ library: "confluent-kafka-js", queueUri: x(c?.topic), incomingTraceId: f }, () => s(c));
1742
1750
  };
1743
1751
  }
1744
1752
  if (typeof u.eachBatch == "function") {
1745
1753
  const s = u.eachBatch;
1746
- a.eachBatch = (l) => {
1747
- let c = !1;
1754
+ a.eachBatch = (c) => {
1755
+ let l = !1;
1748
1756
  try {
1749
- typeof l?.isStale == "function" && (c = !!l.isStale());
1757
+ typeof c?.isStale == "function" && (l = !!c.isStale());
1750
1758
  } catch {
1751
1759
  }
1752
- if (c) return s(l);
1753
- const p = Array.isArray(l?.batch?.messages) ? l.batch.messages[0] : void 0, f = X(Z(p?.headers)) ?? ae(p?.headers);
1754
- return j({ library: "confluent-kafka-js", queueUri: x(l?.batch?.topic), incomingTraceId: f }, () => s(l));
1760
+ if (l) return s(c);
1761
+ const p = Array.isArray(c?.batch?.messages) ? c.batch.messages[0] : void 0, f = X(Z(p?.headers)) ?? ae(p?.headers);
1762
+ return j({ library: "confluent-kafka-js", queueUri: x(c?.batch?.topic), incomingTraceId: f }, () => s(c));
1755
1763
  };
1756
1764
  }
1757
1765
  return i.call(this, a);
@@ -1762,7 +1770,7 @@ function er(t) {
1762
1770
  if (typeof i == "function" && !i[v]) {
1763
1771
  const u = function(...a) {
1764
1772
  const s = i.apply(this, a);
1765
- return s && typeof s.send == "function" && !s.send[k] && (s.send = Ke(s.send.bind(s)), s.send[k] = !0), s && typeof s.sendBatch == "function" && !s.sendBatch[k] && (s.sendBatch = Je(s.sendBatch.bind(s)), s.sendBatch[k] = !0), s && typeof s.transaction == "function" && !s.transaction[k] && (s.transaction = mt(s.transaction.bind(s)), s.transaction[k] = !0), s;
1773
+ return s && typeof s.send == "function" && !s.send[N] && (s.send = Je(s.send.bind(s)), s.send[N] = !0), s && typeof s.sendBatch == "function" && !s.sendBatch[N] && (s.sendBatch = Qe(s.sendBatch.bind(s)), s.sendBatch[N] = !0), s && typeof s.transaction == "function" && !s.transaction[N] && (s.transaction = St(s.transaction.bind(s)), s.transaction[N] = !0), s;
1766
1774
  };
1767
1775
  u[v] = !0, U(r.prototype, "producer", u);
1768
1776
  }
@@ -1770,43 +1778,43 @@ function er(t) {
1770
1778
  if (typeof d == "function" && !d[v]) {
1771
1779
  const u = function(...a) {
1772
1780
  const s = d.apply(this, a);
1773
- if (s && typeof s.run == "function" && !s.run[k]) {
1774
- const l = s.run.bind(s);
1775
- s.run = async function(c) {
1776
- if (!c || typeof c != "object") return l(c);
1777
- const p = { ...c };
1778
- if (typeof c.eachMessage == "function") {
1779
- const f = c.eachMessage;
1780
- p.eachMessage = (y) => {
1781
- const h = X(Z(y?.message?.headers)) ?? ae(y?.message?.headers);
1782
- return j({ library: "confluent-kafka-js", queueUri: x(y?.topic), incomingTraceId: h }, () => f(y));
1781
+ if (s && typeof s.run == "function" && !s.run[N]) {
1782
+ const c = s.run.bind(s);
1783
+ s.run = async function(l) {
1784
+ if (!l || typeof l != "object") return c(l);
1785
+ const p = { ...l };
1786
+ if (typeof l.eachMessage == "function") {
1787
+ const f = l.eachMessage;
1788
+ p.eachMessage = (g) => {
1789
+ const h = X(Z(g?.message?.headers)) ?? ae(g?.message?.headers);
1790
+ return j({ library: "confluent-kafka-js", queueUri: x(g?.topic), incomingTraceId: h }, () => f(g));
1783
1791
  };
1784
1792
  }
1785
- if (typeof c.eachBatch == "function") {
1786
- const f = c.eachBatch;
1787
- p.eachBatch = (y) => {
1793
+ if (typeof l.eachBatch == "function") {
1794
+ const f = l.eachBatch;
1795
+ p.eachBatch = (g) => {
1788
1796
  let h = !1;
1789
1797
  try {
1790
- typeof y?.isStale == "function" && (h = !!y.isStale());
1798
+ typeof g?.isStale == "function" && (h = !!g.isStale());
1791
1799
  } catch {
1792
1800
  }
1793
- if (h) return f(y);
1794
- const g = Array.isArray(y?.batch?.messages) ? y.batch.messages[0] : void 0, S = X(Z(g?.headers)) ?? ae(g?.headers);
1795
- return j({ library: "confluent-kafka-js", queueUri: x(y?.batch?.topic), incomingTraceId: S }, () => f(y));
1801
+ if (h) return f(g);
1802
+ const m = Array.isArray(g?.batch?.messages) ? g.batch.messages[0] : void 0, I = X(Z(m?.headers)) ?? ae(m?.headers);
1803
+ return j({ library: "confluent-kafka-js", queueUri: x(g?.batch?.topic), incomingTraceId: I }, () => f(g));
1796
1804
  };
1797
1805
  }
1798
- return l(p);
1799
- }, s.run[k] = !0;
1806
+ return c(p);
1807
+ }, s.run[N] = !0;
1800
1808
  }
1801
1809
  return s;
1802
1810
  };
1803
1811
  u[v] = !0, U(r.prototype, "consumer", u);
1804
1812
  }
1805
- })(o.Kafka), e = !0), e ? "installed" : (m().sfDebug && console.warn("[asyncQueues][confluentKafkaJs] No recognizable Producer/Consumer/Kafka class — patch no-op."), "failed");
1813
+ })(o.Kafka), e = !0), e ? "installed" : (y().sfDebug && console.warn("[asyncQueues][confluentKafkaJs] No recognizable Producer/Consumer/Kafka class — patch no-op."), "failed");
1806
1814
  }
1807
- function tr(t, n) {
1808
- const e = A(() => {
1809
- const r = n?.topic, i = n.messages.map(() => F({ library: "confluent-kafka-js", queueUri: x(r), method: "ENQUEUE_BUFFERED" })), d = n.messages.map((u, a) => ({ ...u, headers: Qt(u?.headers, i[a].traceId) }));
1815
+ function nr(t, n) {
1816
+ const e = q(() => {
1817
+ const r = n?.topic, i = n.messages.map(() => T({ library: "confluent-kafka-js", queueUri: x(r), method: "ENQUEUE_BUFFERED" })), d = n.messages.map((u, a) => ({ ...u, headers: Wt(u?.headers, i[a].traceId) }));
1810
1818
  return { handles: i, outOptions: { ...n, messages: d } };
1811
1819
  }, "confluentKafkaJs.KafkaProducer.produce(object)");
1812
1820
  if (e === null) return t.call(this, n);
@@ -1819,27 +1827,27 @@ function tr(t, n) {
1819
1827
  for (const r of e.handles) r.hopEnd(o);
1820
1828
  }
1821
1829
  }
1822
- function nr(t, n) {
1823
- const [e, o, r, i, d, u, a] = n, s = A(() => {
1824
- const c = F({ library: "confluent-kafka-js", queueUri: x(typeof e == "string" ? e : void 0), method: "ENQUEUE_BUFFERED" });
1825
- return { handle: c, injectedHeaders: Qt(a, c.traceId) };
1830
+ function rr(t, n) {
1831
+ const [e, o, r, i, d, u, a] = n, s = q(() => {
1832
+ const l = T({ library: "confluent-kafka-js", queueUri: x(typeof e == "string" ? e : void 0), method: "ENQUEUE_BUFFERED" });
1833
+ return { handle: l, injectedHeaders: Wt(a, l.traceId) };
1826
1834
  }, "confluentKafkaJs.KafkaProducer.produce(positional)");
1827
1835
  if (s === null) return t.call(this, e, o, r, i, d, u, a);
1828
- let l = null;
1836
+ let c = null;
1829
1837
  try {
1830
1838
  return t.call(this, e, o, r, i, d, u, s.injectedHeaders);
1831
- } catch (c) {
1832
- throw l = c instanceof Error ? c : new Error(String(c)), c;
1839
+ } catch (l) {
1840
+ throw c = l instanceof Error ? l : new Error(String(l)), l;
1833
1841
  } finally {
1834
- s.handle.hopEnd(l);
1842
+ s.handle.hopEnd(c);
1835
1843
  }
1836
1844
  }
1837
- function Ke(t, n = {}) {
1845
+ function Je(t, n = {}) {
1838
1846
  const e = n.method ?? "ENQUEUE", o = n.library ?? "confluent-kafka-js";
1839
1847
  return async function(r) {
1840
1848
  if (!r || !Array.isArray(r.messages)) return t.call(this, r);
1841
- const i = A(() => {
1842
- const u = r.messages.map(() => F({ library: o, queueUri: x(r.topic), method: e })), a = r.messages.map((s, l) => ({ ...s, headers: { ...s?.headers || {}, [se]: Buffer.from(u[l].traceId) } }));
1849
+ const i = q(() => {
1850
+ const u = r.messages.map(() => T({ library: o, queueUri: x(r.topic), method: e })), a = r.messages.map((s, c) => ({ ...s, headers: { ...s?.headers || {}, [se]: Buffer.from(u[c].traceId) } }));
1843
1851
  return { handles: u, outPayload: { ...r, messages: a } };
1844
1852
  }, `confluentKafkaJs.Producer.${e}`);
1845
1853
  if (i === null) return t.call(this, r);
@@ -1853,17 +1861,17 @@ function Ke(t, n = {}) {
1853
1861
  }
1854
1862
  };
1855
1863
  }
1856
- function Je(t, n = {}) {
1864
+ function Qe(t, n = {}) {
1857
1865
  const e = n.method ?? "ENQUEUE", o = n.library ?? "confluent-kafka-js";
1858
1866
  return async function(r) {
1859
1867
  if (!r || !Array.isArray(r.topicMessages)) return t.call(this, r);
1860
- const i = A(() => {
1868
+ const i = q(() => {
1861
1869
  const u = [], a = r.topicMessages.map((s) => {
1862
- const l = (Array.isArray(s?.messages) ? s.messages : []).map((c) => {
1863
- const p = F({ library: o, queueUri: x(s?.topic), method: e });
1864
- return u.push(p), { ...c, headers: { ...c?.headers || {}, [se]: Buffer.from(p.traceId) } };
1870
+ const c = (Array.isArray(s?.messages) ? s.messages : []).map((l) => {
1871
+ const p = T({ library: o, queueUri: x(s?.topic), method: e });
1872
+ return u.push(p), { ...l, headers: { ...l?.headers || {}, [se]: Buffer.from(p.traceId) } };
1865
1873
  });
1866
- return { ...s, messages: l };
1874
+ return { ...s, messages: c };
1867
1875
  });
1868
1876
  return { handles: u, outPayload: { ...r, topicMessages: a } };
1869
1877
  }, `confluentKafkaJs.Producer.sendBatch[${e}]`);
@@ -1878,9 +1886,9 @@ function Je(t, n = {}) {
1878
1886
  }
1879
1887
  };
1880
1888
  }
1881
- function yt(t, n) {
1889
+ function mt(t, n) {
1882
1890
  return async function(...e) {
1883
- const o = F({ queueUri: "kafka://broker/_tx", method: n });
1891
+ const o = T({ queueUri: "kafka://broker/_tx", method: n });
1884
1892
  let r = null;
1885
1893
  try {
1886
1894
  return await t.apply(this, e);
@@ -1891,13 +1899,13 @@ function yt(t, n) {
1891
1899
  }
1892
1900
  };
1893
1901
  }
1894
- function mt(t) {
1902
+ function St(t) {
1895
1903
  return async function(...n) {
1896
1904
  const e = await t.apply(this, n);
1897
- return e && typeof e.send == "function" && !e.send[k] && (e.send = Ke(e.send.bind(e), { method: "ENQUEUE_TX", library: "confluent-kafka-js-tx" }), e.send[k] = !0), e && typeof e.sendBatch == "function" && !e.sendBatch[k] && (e.sendBatch = Je(e.sendBatch.bind(e), { method: "ENQUEUE_TX", library: "confluent-kafka-js-tx" }), e.sendBatch[k] = !0), e && typeof e.commit == "function" && !e.commit[k] && (e.commit = yt(e.commit.bind(e), "COMMIT_TX"), e.commit[k] = !0), e && typeof e.abort == "function" && !e.abort[k] && (e.abort = yt(e.abort.bind(e), "ABORT_TX"), e.abort[k] = !0), e;
1905
+ return e && typeof e.send == "function" && !e.send[N] && (e.send = Je(e.send.bind(e), { method: "ENQUEUE_TX", library: "confluent-kafka-js-tx" }), e.send[N] = !0), e && typeof e.sendBatch == "function" && !e.sendBatch[N] && (e.sendBatch = Qe(e.sendBatch.bind(e), { method: "ENQUEUE_TX", library: "confluent-kafka-js-tx" }), e.sendBatch[N] = !0), e && typeof e.commit == "function" && !e.commit[N] && (e.commit = mt(e.commit.bind(e), "COMMIT_TX"), e.commit[N] = !0), e && typeof e.abort == "function" && !e.abort[N] && (e.abort = mt(e.abort.bind(e), "ABORT_TX"), e.abort[N] = !0), e;
1898
1906
  };
1899
1907
  }
1900
- function Pe(t) {
1908
+ function Fe(t) {
1901
1909
  if (t != null) {
1902
1910
  if (typeof t == "string") return t;
1903
1911
  if (Buffer.isBuffer(t)) try {
@@ -1916,7 +1924,7 @@ function Pe(t) {
1916
1924
  function Ee(t, n) {
1917
1925
  return `kafka://broker/${t ?? "unknown"}`;
1918
1926
  }
1919
- function rr(t) {
1927
+ function or(t) {
1920
1928
  let n = t;
1921
1929
  if (!n) try {
1922
1930
  n = require("kafkajs");
@@ -1927,23 +1935,23 @@ function rr(t) {
1927
1935
  e?.prototype && typeof e.prototype.send == "function" && (function(i) {
1928
1936
  const d = i.prototype.send;
1929
1937
  if (typeof d == "function" && !d[v]) {
1930
- const s = Qe(d);
1938
+ const s = We(d);
1931
1939
  s[v] = !0, U(i.prototype, "send", s);
1932
1940
  }
1933
1941
  const u = i.prototype.sendBatch;
1934
1942
  if (typeof u == "function" && !u[v]) {
1935
- const s = We(u);
1943
+ const s = Ve(u);
1936
1944
  s[v] = !0, U(i.prototype, "sendBatch", s);
1937
1945
  }
1938
1946
  const a = i.prototype.transaction;
1939
1947
  if (typeof a == "function" && !a[v]) {
1940
- const s = bt(a);
1948
+ const s = vt(a);
1941
1949
  s[v] = !0, U(i.prototype, "transaction", s);
1942
1950
  }
1943
1951
  })(e), o?.prototype && typeof o.prototype.run == "function" && (function(i) {
1944
1952
  const d = i.prototype.run;
1945
1953
  if (typeof d != "function" || d[v]) return;
1946
- const u = vt(d);
1954
+ const u = It(d);
1947
1955
  u[v] = !0, U(i.prototype, "run", u);
1948
1956
  })(o);
1949
1957
  const r = n.Kafka;
@@ -1951,30 +1959,30 @@ function rr(t) {
1951
1959
  const d = i.prototype.producer;
1952
1960
  if (typeof d == "function" && !d[v]) {
1953
1961
  const a = function(...s) {
1954
- const l = d.apply(this, s);
1955
- return l && typeof l.send == "function" && !l.send[k] && (l.send = Qe(l.send.bind(l)), l.send[k] = !0), l && typeof l.sendBatch == "function" && !l.sendBatch[k] && (l.sendBatch = We(l.sendBatch.bind(l)), l.sendBatch[k] = !0), l && typeof l.transaction == "function" && !l.transaction[k] && (l.transaction = bt(l.transaction.bind(l)), l.transaction[k] = !0), l;
1962
+ const c = d.apply(this, s);
1963
+ return c && typeof c.send == "function" && !c.send[N] && (c.send = We(c.send.bind(c)), c.send[N] = !0), c && typeof c.sendBatch == "function" && !c.sendBatch[N] && (c.sendBatch = Ve(c.sendBatch.bind(c)), c.sendBatch[N] = !0), c && typeof c.transaction == "function" && !c.transaction[N] && (c.transaction = vt(c.transaction.bind(c)), c.transaction[N] = !0), c;
1956
1964
  };
1957
1965
  a[v] = !0, U(i.prototype, "producer", a);
1958
1966
  }
1959
1967
  const u = i.prototype.consumer;
1960
1968
  if (typeof u == "function" && !u[v]) {
1961
1969
  const a = function(...s) {
1962
- const l = u.apply(this, s);
1963
- return l && typeof l.run == "function" && !l.run[k] && (l.run = vt(l.run.bind(l)), l.run[k] = !0), l;
1970
+ const c = u.apply(this, s);
1971
+ return c && typeof c.run == "function" && !c.run[N] && (c.run = It(c.run.bind(c)), c.run[N] = !0), c;
1964
1972
  };
1965
1973
  a[v] = !0, U(i.prototype, "consumer", a);
1966
1974
  }
1967
1975
  })(r);
1968
- else if (!e?.prototype && !o?.prototype) return m().sfDebug && console.warn("[asyncQueues][kafkajs] No Kafka/Producer/Consumer class found — patch no-op."), "failed";
1976
+ else if (!e?.prototype && !o?.prototype) return y().sfDebug && console.warn("[asyncQueues][kafkajs] No Kafka/Producer/Consumer class found — patch no-op."), "failed";
1969
1977
  return "installed";
1970
1978
  }
1971
- function Qe(t, n = {}) {
1979
+ function We(t, n = {}) {
1972
1980
  const e = n.method ?? "ENQUEUE", o = n.library ?? "kafkajs";
1973
1981
  return async function(r) {
1974
1982
  if (!r || !Array.isArray(r.messages)) return t.call(this, r);
1975
- const i = A(() => {
1976
- const u = r.topic, a = r.messages.map(() => F({ library: o, queueUri: Ee(u), method: e })), s = r.messages.map((c, p) => Wt(c, a[p].traceId)), l = { ...r, messages: s };
1977
- return { handles: a, outPayload: l };
1983
+ const i = q(() => {
1984
+ const u = r.topic, a = r.messages.map(() => T({ library: o, queueUri: Ee(u), method: e })), s = r.messages.map((l, p) => Vt(l, a[p].traceId)), c = { ...r, messages: s };
1985
+ return { handles: a, outPayload: c };
1978
1986
  }, `kafkajs.Producer.${e}`);
1979
1987
  if (i === null) return t.call(this, r);
1980
1988
  let d = null;
@@ -1987,17 +1995,17 @@ function Qe(t, n = {}) {
1987
1995
  }
1988
1996
  };
1989
1997
  }
1990
- function We(t, n = {}) {
1998
+ function Ve(t, n = {}) {
1991
1999
  const e = n.method ?? "ENQUEUE", o = n.library ?? "kafkajs";
1992
2000
  return async function(r) {
1993
2001
  if (!r || !Array.isArray(r.topicMessages)) return t.call(this, r);
1994
- const i = A(() => {
1995
- const u = [], a = r.topicMessages.map((l) => {
1996
- const c = l?.topic, p = (Array.isArray(l?.messages) ? l.messages : []).map((f) => {
1997
- const y = F({ library: o, queueUri: Ee(c), method: e });
1998
- return u.push(y), Wt(f, y.traceId);
2002
+ const i = q(() => {
2003
+ const u = [], a = r.topicMessages.map((c) => {
2004
+ const l = c?.topic, p = (Array.isArray(c?.messages) ? c.messages : []).map((f) => {
2005
+ const g = T({ library: o, queueUri: Ee(l), method: e });
2006
+ return u.push(g), Vt(f, g.traceId);
1999
2007
  });
2000
- return { ...l, messages: p };
2008
+ return { ...c, messages: p };
2001
2009
  }), s = { ...r, topicMessages: a };
2002
2010
  return { handles: u, outPayload: s };
2003
2011
  }, `kafkajs.Producer.sendBatch[${e}]`);
@@ -2012,9 +2020,9 @@ function We(t, n = {}) {
2012
2020
  }
2013
2021
  };
2014
2022
  }
2015
- function St(t, n) {
2023
+ function bt(t, n) {
2016
2024
  return async function(...e) {
2017
- const o = F({ queueUri: "kafka://broker/_tx", method: n });
2025
+ const o = T({ queueUri: "kafka://broker/_tx", method: n });
2018
2026
  let r = null;
2019
2027
  try {
2020
2028
  return await t.apply(this, e);
@@ -2025,25 +2033,25 @@ function St(t, n) {
2025
2033
  }
2026
2034
  };
2027
2035
  }
2028
- function bt(t) {
2036
+ function vt(t) {
2029
2037
  return async function(...n) {
2030
2038
  const e = await t.apply(this, n);
2031
- return e && typeof e.send == "function" && !e.send[k] && (e.send = Qe(e.send.bind(e), { method: "ENQUEUE_TX", library: "kafkajs-tx" }), e.send[k] = !0), e && typeof e.sendBatch == "function" && !e.sendBatch[k] && (e.sendBatch = We(e.sendBatch.bind(e), { method: "ENQUEUE_TX", library: "kafkajs-tx" }), e.sendBatch[k] = !0), e && typeof e.commit == "function" && !e.commit[k] && (e.commit = St(e.commit.bind(e), "COMMIT_TX"), e.commit[k] = !0), e && typeof e.abort == "function" && !e.abort[k] && (e.abort = St(e.abort.bind(e), "ABORT_TX"), e.abort[k] = !0), e;
2039
+ return e && typeof e.send == "function" && !e.send[N] && (e.send = We(e.send.bind(e), { method: "ENQUEUE_TX", library: "kafkajs-tx" }), e.send[N] = !0), e && typeof e.sendBatch == "function" && !e.sendBatch[N] && (e.sendBatch = Ve(e.sendBatch.bind(e), { method: "ENQUEUE_TX", library: "kafkajs-tx" }), e.sendBatch[N] = !0), e && typeof e.commit == "function" && !e.commit[N] && (e.commit = bt(e.commit.bind(e), "COMMIT_TX"), e.commit[N] = !0), e && typeof e.abort == "function" && !e.abort[N] && (e.abort = bt(e.abort.bind(e), "ABORT_TX"), e.abort[N] = !0), e;
2032
2040
  };
2033
2041
  }
2034
- function Wt(t, n) {
2042
+ function Vt(t, n) {
2035
2043
  const e = { ...t?.headers || {} };
2036
2044
  return e[se] = Buffer.from(n), { ...t, headers: e };
2037
2045
  }
2038
- function vt(t) {
2046
+ function It(t) {
2039
2047
  return async function(n) {
2040
2048
  if (!n || typeof n != "object") return t.call(this, n);
2041
2049
  const e = { ...n };
2042
2050
  if (typeof n.eachMessage == "function") {
2043
2051
  const o = n.eachMessage;
2044
2052
  e.eachMessage = (r) => (async function(i, d) {
2045
- const u = i?.topic, a = i?.message, s = Pe(Z(a?.headers)), l = typeof i?.attempt == "number" ? i.attempt : 0, c = s && l > 0 ? re(s) : s, p = Pe(a?.value) ?? a?.value;
2046
- return j({ library: "kafkajs", queueUri: Ee(u), incomingTraceId: c, messagePayload: p }, () => d(i));
2053
+ const u = i?.topic, a = i?.message, s = Fe(Z(a?.headers)), c = typeof i?.attempt == "number" ? i.attempt : 0, l = s && c > 0 ? re(s) : s, p = Fe(a?.value) ?? a?.value;
2054
+ return j({ library: "kafkajs", queueUri: Ee(u), incomingTraceId: l, messagePayload: p }, () => d(i));
2047
2055
  })(r, o);
2048
2056
  }
2049
2057
  if (typeof n.eachBatch == "function") {
@@ -2055,25 +2063,25 @@ function vt(t) {
2055
2063
  } catch {
2056
2064
  }
2057
2065
  if (u) return d(i);
2058
- const a = i?.batch?.topic, s = Array.isArray(i?.batch?.messages) ? i.batch.messages[0] : void 0, l = Pe(Z(s?.headers));
2059
- return j({ library: "kafkajs", queueUri: Ee(a), incomingTraceId: l }, () => d(i));
2066
+ const a = i?.batch?.topic, s = Array.isArray(i?.batch?.messages) ? i.batch.messages[0] : void 0, c = Fe(Z(s?.headers));
2067
+ return j({ library: "kafkajs", queueUri: Ee(a), incomingTraceId: c }, () => d(i));
2060
2068
  })(r, o);
2061
2069
  }
2062
2070
  return t.call(this, e);
2063
2071
  };
2064
2072
  }
2065
- function or(t) {
2073
+ function sr(t) {
2066
2074
  return process.env[t] === "true";
2067
2075
  }
2068
- const sr = [{ name: "bullmq", envDisableKey: "SF_DISABLE_BULLMQ", install: () => Yn() }, { name: "@taskforcesh/bullmq-pro", envDisableKey: "SF_DISABLE_BULLMQ_PRO", install: () => Zn() }, { name: "kafkajs", envDisableKey: "SF_DISABLE_KAFKAJS", install: () => rr() }, { name: "@confluentinc/kafka-javascript", envDisableKey: "SF_DISABLE_CONFLUENT_KAFKA_JS", install: () => er() }];
2076
+ const ir = [{ name: "bullmq", envDisableKey: "SF_DISABLE_BULLMQ", install: () => Zn() }, { name: "@taskforcesh/bullmq-pro", envDisableKey: "SF_DISABLE_BULLMQ_PRO", install: () => er() }, { name: "kafkajs", envDisableKey: "SF_DISABLE_KAFKAJS", install: () => or() }, { name: "@confluentinc/kafka-javascript", envDisableKey: "SF_DISABLE_CONFLUENT_KAFKA_JS", install: () => tr() }];
2069
2077
  let _e = !1;
2070
- function Lr() {
2078
+ function Rr() {
2071
2079
  return _e;
2072
2080
  }
2073
- function Rr() {
2081
+ function Br() {
2074
2082
  const t = (function() {
2075
2083
  let n = 0;
2076
- for (const { proto: e, key: o, original: r } of je.splice(0)) try {
2084
+ for (const { proto: e, key: o, original: r } of xe.splice(0)) try {
2077
2085
  r === void 0 ? delete e[o] : e[o] = r, n += 1;
2078
2086
  } catch {
2079
2087
  }
@@ -2081,22 +2089,22 @@ function Rr() {
2081
2089
  })();
2082
2090
  return _e = !1, t;
2083
2091
  }
2084
- var It, Et;
2085
- const Vt = Fn(Et ? It : (Et = 1, It = function() {
2092
+ var Et, _t;
2093
+ const Gt = Tn(_t ? Et : (_t = 1, Et = function() {
2086
2094
  throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object");
2087
- })), _t = "__sf_funcSpanCaptureRules";
2088
- function we() {
2095
+ })), $t = "__sf_funcSpanCaptureRules";
2096
+ function $e() {
2089
2097
  const t = globalThis;
2090
- let n = t[_t];
2091
- return n || (n = { compiledRulesById: /* @__PURE__ */ new Map(), bucket: /* @__PURE__ */ new Map(), propagationStorage: new Dn(), randomFn: Math.random }, t[_t] = n), n;
2098
+ let n = t[$t];
2099
+ return n || (n = { compiledRulesById: /* @__PURE__ */ new Map(), bucket: /* @__PURE__ */ new Map(), propagationStorage: new Pn(), randomFn: Math.random }, t[$t] = n), n;
2092
2100
  }
2093
- const ir = /[*?[]/;
2094
- function ar(t, n) {
2101
+ const ar = /[*?[]/;
2102
+ function cr(t, n) {
2095
2103
  const e = [], o = /* @__PURE__ */ new Set(), r = (i) => {
2096
2104
  const d = ie.normalize(i);
2097
2105
  o.has(d) || (o.add(d), e.push(d));
2098
2106
  };
2099
- if (!ir.test(t)) {
2107
+ if (!ar.test(t)) {
2100
2108
  if (ie.isAbsolute(t)) return r(t), e;
2101
2109
  for (const i of n) r(ie.join(i, t));
2102
2110
  return e;
@@ -2104,16 +2112,16 @@ function ar(t, n) {
2104
2112
  for (const i of n) {
2105
2113
  const d = ie.isAbsolute(t) ? t : ie.join(i, t);
2106
2114
  try {
2107
- const u = Nn(d, { absolute: !0, nodir: !0 });
2115
+ const u = Un(d, { absolute: !0, nodir: !0 });
2108
2116
  for (const a of u) r(a);
2109
2117
  } catch {
2110
2118
  }
2111
2119
  }
2112
2120
  return e;
2113
2121
  }
2114
- const cr = { EQ: "==", NEQ: "!=", LT: "<", LTE: "<=", GT: ">", GTE: ">=", STARTS_WITH: "starts_with", CONTAINS: "contains" };
2115
- function ur(t) {
2116
- return cr[t] ?? t;
2122
+ const ur = { EQ: "==", NEQ: "!=", LT: "<", LTE: "<=", GT: ">", GTE: ">=", STARTS_WITH: "starts_with", CONTAINS: "contains" };
2123
+ function lr(t) {
2124
+ return ur[t] ?? t;
2117
2125
  }
2118
2126
  function z(t) {
2119
2127
  if (typeof t == "number") return Number.isFinite(t) ? t : null;
@@ -2134,7 +2142,7 @@ function ye(t) {
2134
2142
  return "";
2135
2143
  }
2136
2144
  }
2137
- function lr(t, n, e) {
2145
+ function dr(t, n, e) {
2138
2146
  try {
2139
2147
  switch (t) {
2140
2148
  case "==": {
@@ -2174,7 +2182,7 @@ function lr(t, n, e) {
2174
2182
  return !1;
2175
2183
  }
2176
2184
  }
2177
- function dr(t, n, e, o) {
2185
+ function pr(t, n, e, o) {
2178
2186
  if (t.length === 0) return !0;
2179
2187
  const r = [];
2180
2188
  for (const i of t) {
@@ -2183,8 +2191,8 @@ function dr(t, n, e, o) {
2183
2191
  r.push(!1);
2184
2192
  continue;
2185
2193
  }
2186
- const s = ur(u), l = n && typeof n == "object" ? n[d] : void 0;
2187
- r.push(lr(s, l, a));
2194
+ const s = lr(u), c = n && typeof n == "object" ? n[d] : void 0;
2195
+ r.push(dr(s, c, a));
2188
2196
  }
2189
2197
  return e === "or" ? r.some(Boolean) : r.every(Boolean);
2190
2198
  }
@@ -2194,8 +2202,8 @@ function wt(t, n) {
2194
2202
  let u, a;
2195
2203
  try {
2196
2204
  if (!d || typeof d != "object" || d.ruleId === void 0 || d.ruleId === null || !d.target || typeof d.target != "object" || d.target.filePattern === void 0 || d.target.filePattern === null || d.target.functionName === void 0 || d.target.functionName === null) continue;
2197
- const s = d.capture ?? {}, l = d.conditions ?? {}, c = d.propagate ?? { enabled: !1, maxDepth: 5 };
2198
- u = { ruleId: String(d.ruleId), functionName: String(d.target.functionName), capture: { args: s.args === void 0 || !!s.args, returnValue: s.returnValue === void 0 || !!s.returnValue, argLimitMb: Number(s.argLimitMb ?? 1), returnLimitMb: Number(s.returnLimitMb ?? 1) }, preCall: Array.isArray(l.preCall) ? l.preCall : [], postCall: Array.isArray(l.postCall) ? l.postCall : [], logic: String(l.logic ?? "and").toLowerCase() === "or" ? "or" : "and", propagateEnabled: !!c.enabled, propagateMaxDepth: Number(c.maxDepth ?? 5), sampleRate: d.sampleRate !== void 0 ? Number(d.sampleRate) : 1 };
2205
+ const s = d.capture ?? {}, c = d.conditions ?? {}, l = d.propagate ?? { enabled: !1, maxDepth: 5 };
2206
+ u = { ruleId: String(d.ruleId), functionName: String(d.target.functionName), capture: { args: s.args === void 0 || !!s.args, returnValue: s.returnValue === void 0 || !!s.returnValue, argLimitMb: Number(s.argLimitMb ?? 1), returnLimitMb: Number(s.returnLimitMb ?? 1) }, preCall: Array.isArray(c.preCall) ? c.preCall : [], postCall: Array.isArray(c.postCall) ? c.postCall : [], logic: String(c.logic ?? "and").toLowerCase() === "or" ? "or" : "and", propagateEnabled: !!l.enabled, propagateMaxDepth: Number(l.maxDepth ?? 5), sampleRate: d.sampleRate !== void 0 ? Number(d.sampleRate) : 1 };
2199
2207
  } catch {
2200
2208
  continue;
2201
2209
  }
@@ -2205,41 +2213,41 @@ function wt(t, n) {
2205
2213
  } catch {
2206
2214
  continue;
2207
2215
  }
2208
- for (const s of ar(a, e)) {
2209
- const l = `${s}::${u.functionName}`, c = r.get(l);
2210
- c ? c.push(u.ruleId) : r.set(l, [u.ruleId]);
2216
+ for (const s of cr(a, e)) {
2217
+ const c = `${s}::${u.functionName}`, l = r.get(c);
2218
+ l ? l.push(u.ruleId) : r.set(c, [u.ruleId]);
2211
2219
  }
2212
2220
  }
2213
- const i = we();
2221
+ const i = $e();
2214
2222
  i.compiledRulesById = o, i.bucket = r;
2215
2223
  }
2216
- function Gt() {
2217
- return we().compiledRulesById.size > 0;
2224
+ function zt() {
2225
+ return $e().compiledRulesById.size > 0;
2218
2226
  }
2219
- function pr(t, n, e) {
2227
+ function fr(t, n, e) {
2220
2228
  const o = (function() {
2221
- const a = we(), s = a.propagationStorage.getStore(), l = s && s.length > 0 ? s : (function() {
2229
+ const a = $e(), s = a.propagationStorage.getStore(), c = s && s.length > 0 ? s : (function() {
2222
2230
  const p = globalThis;
2223
- let f = p[$t];
2224
- return f || (f = [], p[$t] = f), f;
2231
+ let f = p[kt];
2232
+ return f || (f = [], p[kt] = f), f;
2225
2233
  })();
2226
- if (l.length === 0) return null;
2227
- const c = l.length;
2228
- for (let p = l.length - 1; p >= 0; p--) {
2229
- const f = l[p];
2230
- if (c - f.pushDepth <= f.maxDepth) return f.captureConfig;
2234
+ if (c.length === 0) return null;
2235
+ const l = c.length;
2236
+ for (let p = c.length - 1; p >= 0; p--) {
2237
+ const f = c[p];
2238
+ if (l - f.pushDepth <= f.maxDepth) return f.captureConfig;
2231
2239
  }
2232
2240
  return null;
2233
2241
  })();
2234
2242
  if (o !== null) return o;
2235
- const r = we(), i = `${t}::${n}`, d = r.bucket.get(i);
2243
+ const r = $e(), i = `${t}::${n}`, d = r.bucket.get(i);
2236
2244
  if (!d || d.length === 0) return null;
2237
2245
  const u = e && typeof e == "object" ? e : {};
2238
2246
  for (const a of d) {
2239
2247
  const s = r.compiledRulesById.get(a);
2240
2248
  if (s) {
2241
2249
  try {
2242
- if (!dr(s.preCall, u, s.logic, "arg")) continue;
2250
+ if (!pr(s.preCall, u, s.logic, "arg")) continue;
2243
2251
  } catch {
2244
2252
  continue;
2245
2253
  }
@@ -2250,27 +2258,27 @@ function pr(t, n, e) {
2250
2258
  }
2251
2259
  return null;
2252
2260
  }
2253
- const $t = "__sf_funcSpanCaptureRulesFallbackStack";
2254
- let J = null, q = null, te = null, ue = !1, ee = 1e3;
2255
- function fr(t, n) {
2261
+ const kt = "__sf_funcSpanCaptureRulesFallbackStack";
2262
+ let J = null, L = null, te = null, ue = !1, ee = 1e3;
2263
+ function hr(t, n) {
2256
2264
  const e = J;
2257
- if (e && e.readyState === Vt.OPEN) try {
2265
+ if (e && e.readyState === Gt.OPEN) try {
2258
2266
  e.send(JSON.stringify({ type: "sessionExpired", sessionId: t.sessionId, reason: n, spansEmitted: t.spansEmitted, bytesEmitted: String(t.bytesEmitted) }));
2259
2267
  } catch {
2260
2268
  }
2261
2269
  }
2262
- function hr(t, n) {
2270
+ function gr(t, n) {
2263
2271
  const e = n?.rules ?? [];
2264
- if (!Array.isArray(e) || e.length === 0) return wt([]), void (Ft() && Tt("cancelled"));
2265
- if (dn(n)) {
2272
+ if (!Array.isArray(e) || e.length === 0) return wt([]), void (Tt() && Ct("cancelled"));
2273
+ if (pn(n)) {
2266
2274
  wt(e);
2267
2275
  try {
2268
- t.send(JSON.stringify({ type: "rulesAck", sessionId: n.sessionId, rulesVersion: n.rulesVersion, podId: m().serviceUUID }));
2276
+ t.send(JSON.stringify({ type: "rulesAck", sessionId: n.sessionId, rulesVersion: n.rulesVersion, podId: y().serviceUUID }));
2269
2277
  } catch {
2270
2278
  }
2271
2279
  }
2272
2280
  }
2273
- function gr(t, n) {
2281
+ function yr(t, n) {
2274
2282
  let e;
2275
2283
  try {
2276
2284
  e = JSON.parse(n);
@@ -2279,7 +2287,7 @@ function gr(t, n) {
2279
2287
  }
2280
2288
  switch (e?.type) {
2281
2289
  case "backendFunctionSpanRules":
2282
- hr(t, e);
2290
+ gr(t, e);
2283
2291
  break;
2284
2292
  case "ping":
2285
2293
  (function(o, r) {
@@ -2290,21 +2298,21 @@ function gr(t, n) {
2290
2298
  })(t, e);
2291
2299
  }
2292
2300
  }
2293
- function Fe() {
2294
- if (ue || q) return;
2301
+ function Te() {
2302
+ if (ue || L) return;
2295
2303
  const t = 0.2 * ee * (2 * Math.random() - 1), n = Math.min(3e4, Math.max(1e3, ee + t));
2296
- q = setTimeout(() => {
2297
- q = null, Xe();
2298
- }, n), typeof q.unref == "function" && q.unref(), ee = Math.min(3e4, 1.5 * ee);
2304
+ L = setTimeout(() => {
2305
+ L = null, Ye();
2306
+ }, n), typeof L.unref == "function" && L.unref(), ee = Math.min(3e4, 1.5 * ee);
2299
2307
  }
2300
- function Xe() {
2308
+ function Ye() {
2301
2309
  if (ue) return;
2302
- if (!m().serviceIdentifier)
2303
- return q ? void 0 : (q = setTimeout(() => {
2304
- q = null, Xe();
2305
- }, 1e3), void (typeof q.unref == "function" && q.unref()));
2310
+ if (!y().serviceIdentifier)
2311
+ return L ? void 0 : (L = setTimeout(() => {
2312
+ L = null, Ye();
2313
+ }, 1e3), void (typeof L.unref == "function" && L.unref()));
2306
2314
  const t = (function() {
2307
- const o = m();
2315
+ const o = y();
2308
2316
  if (o.uplinkUrl) return o.uplinkUrl;
2309
2317
  const r = o.apiGraphqlEndpoint;
2310
2318
  if (!r) return null;
@@ -2321,36 +2329,36 @@ function Xe() {
2321
2329
  }
2322
2330
  return i.pathname = "/ws/notify/", i.search = "", i.toString();
2323
2331
  })();
2324
- if (!t) return void Fe();
2332
+ if (!t) return void Te();
2325
2333
  const n = `${t}?${(function() {
2326
- const o = m(), r = new URLSearchParams();
2334
+ const o = y(), r = new URLSearchParams();
2327
2335
  return o.apiKey && r.set("apiKey", o.apiKey), o.serviceUUID && r.set("serviceUuid", o.serviceUUID), o.serviceIdentifier && r.set("serviceIdentifier", o.serviceIdentifier), o.serviceVersion && r.set("serviceVersion", o.serviceVersion), r.set("clientKind", "backendCollector"), r.toString();
2328
2336
  })()}`;
2329
2337
  let e;
2330
2338
  try {
2331
- e = new Vt(n, { headers: { "X-Sf3-TelemetryOutbound": "True", "User-Agent": `sf-veritas-jsts/${m().version}` } });
2339
+ e = new Gt(n, { headers: { "X-Sf3-TelemetryOutbound": "True", "User-Agent": `sf-veritas-jsts/${y().version}` } });
2332
2340
  } catch {
2333
- return void Fe();
2341
+ return void Te();
2334
2342
  }
2335
2343
  J = e, e.on("open", () => {
2336
2344
  ee = 1e3;
2337
2345
  try {
2338
- e.send(JSON.stringify({ type: "clientHello", sdkVersion: m().version, runtime: "jsts", pid: process.pid }));
2346
+ e.send(JSON.stringify({ type: "clientHello", sdkVersion: y().version, runtime: "jsts", pid: process.pid }));
2339
2347
  } catch {
2340
2348
  }
2341
2349
  }), e.on("message", (o) => {
2342
2350
  try {
2343
2351
  const r = o.toString();
2344
- gr(e, r);
2352
+ yr(e, r);
2345
2353
  } catch {
2346
2354
  }
2347
2355
  }), e.on("close", () => {
2348
- J === e && (J = null), ue || Fe();
2356
+ J === e && (J = null), ue || Te();
2349
2357
  }), e.on("error", (o) => {
2350
2358
  });
2351
2359
  }
2352
- function yr() {
2353
- if (ue = !0, Ft() && Tt("shutdown"), q && (clearTimeout(q), q = null), te && (clearInterval(te), te = null), J) {
2360
+ function mr() {
2361
+ if (ue = !0, Tt() && Ct("shutdown"), L && (clearTimeout(L), L = null), te && (clearInterval(te), te = null), J) {
2354
2362
  try {
2355
2363
  J.close();
2356
2364
  } catch {
@@ -2358,14 +2366,14 @@ function yr() {
2358
2366
  J = null;
2359
2367
  }
2360
2368
  }
2361
- let kt = !1, Ve = !1, Te = !1;
2362
- function Br(t) {
2363
- if (Te) console.warn("[setupInterceptors] ⚠️ Recursive call detected and blocked!");
2364
- else if (!Ve) {
2365
- Te = !0, pn();
2369
+ let Nt = !1, Ge = !1, Ce = !1;
2370
+ function Or(t) {
2371
+ if (Ce) console.warn("[setupInterceptors] ⚠️ Recursive call detected and blocked!");
2372
+ else if (!Ge) {
2373
+ Ce = !0, fn();
2366
2374
  try {
2367
2375
  let n, e;
2368
- const o = Ct(new Error().stack);
2376
+ const o = At(new Error().stack);
2369
2377
  if (o) {
2370
2378
  const u = o.split(`
2371
2379
  `)[2] || "", a = u.match(/\((.+):(\d+):\d+\)/) || u.match(/at (.+):(\d+):\d+/);
@@ -2375,172 +2383,172 @@ function Br(t) {
2375
2383
  const u = `The required API Key is not provided: ${JSON.stringify(t)}`;
2376
2384
  console.error(u);
2377
2385
  }
2378
- const { config: r } = nn(t);
2379
- if (rn(r).catch(() => {
2386
+ const { config: r } = rn(t);
2387
+ if (on(r).catch(() => {
2380
2388
  }), n && (r.setupInterceptorsFile = n), e && (r.setupInterceptorsLine = e), r.sfDebug && console.log("Updated configuration after applying options:", r), !r.apiKey || !r.apiGraphqlEndpoint) {
2381
2389
  const u = `The required config is not provided: ${JSON.stringify(r)}`;
2382
2390
  throw console.error(u), new Error(u);
2383
2391
  }
2384
- xn() || Mn(void 0, r.sfDebug).catch((u) => {
2392
+ Hn() || jn(void 0, r.sfDebug).catch((u) => {
2385
2393
  r.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:", u);
2386
- }), process.env.SF_WORKER_POOL_DISABLED === "true" ? r.sfDebug && console.log("[setupInterceptors] Worker pool patching DISABLED (SF_WORKER_POOL_DISABLED=true)") : Gn() || (Vn(), r.sfDebug && console.log("[setupInterceptors] Worker pool patching initialized (DNS tracking enabled)"));
2387
- const i = new ze();
2388
- i.setServiceUUID(r.serviceUUID), bn(i), (function(u = []) {
2389
- const a = new Rn(u);
2390
- new qn().doSend(a.getExcludedDomains());
2391
- const s = new Ln(), l = new Lt();
2392
- a.patchFetch(s, l), a.patchHttp(s, l);
2394
+ }), process.env.SF_WORKER_POOL_DISABLED === "true" ? r.sfDebug && console.log("[setupInterceptors] Worker pool patching DISABLED (SF_WORKER_POOL_DISABLED=true)") : zn() || (Gn(), r.sfDebug && console.log("[setupInterceptors] Worker pool patching initialized (DNS tracking enabled)"));
2395
+ const i = new Xe();
2396
+ i.setServiceUUID(r.serviceUUID), vn(i), (function(u = []) {
2397
+ const a = new Bn(u);
2398
+ new Ln().doSend(a.getExcludedDomains());
2399
+ const s = new Rn(), c = new Rt();
2400
+ a.patchFetch(s, c), a.patchHttp(s, c);
2393
2401
  })(r.domainsToNotPropagateHeadersTo);
2394
- const d = new Tn();
2395
- d.setServiceUUID(r.serviceUUID), vn(d), An(), new Bn().send(), (function() {
2402
+ const d = new Cn();
2403
+ d.setServiceUUID(r.serviceUUID), In(d), qn(), new On().send(), (function() {
2396
2404
  if (_e) return;
2397
- if (_e = !0, process.env.SF_DISABLE_QUEUE_PATCHES === "true") return void (m().sfDebug && console.log("[sf-veritas] Async queue tracing DISABLED via SF_DISABLE_QUEUE_PATCHES=true"));
2398
- const u = m(), a = [], s = [], l = [], c = [];
2399
- for (const { name: f, envDisableKey: y, install: h } of sr) {
2400
- if (or(y)) {
2401
- l.push(f);
2405
+ if (_e = !0, process.env.SF_DISABLE_QUEUE_PATCHES === "true") return void (y().sfDebug && console.log("[sf-veritas] Async queue tracing DISABLED via SF_DISABLE_QUEUE_PATCHES=true"));
2406
+ const u = y(), a = [], s = [], c = [], l = [];
2407
+ for (const { name: f, envDisableKey: g, install: h } of ir) {
2408
+ if (sr(g)) {
2409
+ c.push(f);
2402
2410
  continue;
2403
2411
  }
2404
- let g = "failed";
2412
+ let m = "failed";
2405
2413
  try {
2406
- g = h();
2407
- } catch (S) {
2408
- u.sfDebug && console.warn(`[asyncQueues] Failed to install ${f} patch:`, S), c.push(f);
2414
+ m = h();
2415
+ } catch (I) {
2416
+ u.sfDebug && console.warn(`[asyncQueues] Failed to install ${f} patch:`, I), l.push(f);
2409
2417
  continue;
2410
2418
  }
2411
- g === "installed" ? a.push(f) : g === "not-installed" ? s.push(f) : c.push(f);
2419
+ m === "installed" ? a.push(f) : m === "not-installed" ? s.push(f) : l.push(f);
2412
2420
  }
2413
2421
  const p = [`active: ${a.length ? a.join(", ") : "(none)"}`];
2414
- s.length && p.push(`skipped (not installed): ${s.join(", ")}`), l.length && p.push(`disabled by env: ${l.join(", ")}`), c.length && p.push(`failed: ${c.join(", ")}`), (u.sfDebug || c.length > 0) && console.log(`[sf-veritas] Async queue tracing — ${p.join("; ")}`);
2422
+ s.length && p.push(`skipped (not installed): ${s.join(", ")}`), c.length && p.push(`disabled by env: ${c.join(", ")}`), l.length && p.push(`failed: ${l.join(", ")}`), (u.sfDebug || l.length > 0) && console.log(`[sf-veritas] Async queue tracing — ${p.join("; ")}`);
2415
2423
  })();
2416
2424
  try {
2417
- m().uplinkEnable && (J || q || (ue = !1, ee = 1e3, un(fr), te = setInterval(() => {
2425
+ y().uplinkEnable && (J || L || (ue = !1, ee = 1e3, ln(hr), te = setInterval(() => {
2418
2426
  try {
2419
- ln();
2427
+ dn();
2420
2428
  } catch {
2421
2429
  }
2422
- }, 1e3), typeof te.unref == "function" && te.unref(), Xe()));
2430
+ }, 1e3), typeof te.unref == "function" && te.unref(), Ye()));
2423
2431
  } catch (u) {
2424
2432
  r.sfDebug && console.error("[setupInterceptors] uplinkClient failed to start", u);
2425
2433
  }
2426
- if (!kt) {
2427
- kt = !0;
2434
+ if (!Nt) {
2435
+ Nt = !0;
2428
2436
  for (const u of ["exit", "SIGINT", "SIGTERM"]) process.on(u, () => {
2429
2437
  try {
2430
- yr();
2438
+ mr();
2431
2439
  } catch {
2432
2440
  }
2433
2441
  });
2434
2442
  }
2435
- Ve = !0, r.sfDebug && console.log("[setupInterceptors] ✅ Initialization complete");
2443
+ Ge = !0, r.sfDebug && console.log("[setupInterceptors] ✅ Initialization complete");
2436
2444
  } finally {
2437
- Te = !1;
2445
+ Ce = !1;
2438
2446
  }
2439
2447
  }
2440
2448
  }
2441
- function Or() {
2442
- return Ve;
2449
+ function Mr() {
2450
+ return Ge;
2443
2451
  }
2444
- function Mr(t, n, e, o = !1) {
2445
- const r = m();
2446
- new qt(r.apiKey).identify(t, n, e, o);
2452
+ function jr(t, n, e, o = !1) {
2453
+ const r = y();
2454
+ new Lt(r.apiKey).identify(t, n, e, o);
2447
2455
  }
2448
- function jr(t, n = {}, e, o = !1) {
2449
- const r = m();
2450
- new qt(r.apiKey).addOrUpdateMetadata(t, n, e, o);
2456
+ function xr(t, n = {}, e, o = !1) {
2457
+ const r = y();
2458
+ new Lt(r.apiKey).addOrUpdateMetadata(t, n, e, o);
2451
2459
  }
2452
2460
  const le = 2048;
2453
- let Ge = new Array(le), Y = 0, Ie = 0, Ce = !1;
2454
- function zt(t) {
2455
- for (let n = 0; n < le; n++) t[n] = At();
2461
+ let ze = new Array(le), Y = 0, Ie = 0, Ae = !1;
2462
+ function Xt(t) {
2463
+ for (let n = 0; n < le; n++) t[n] = qt();
2456
2464
  }
2457
- function mr() {
2465
+ function Sr() {
2458
2466
  if (Y < Ie) {
2459
- const t = Ge[Y];
2460
- return Y++, Ie - Y < 256 && (Ce || (Ce = !0, setImmediate(() => {
2467
+ const t = ze[Y];
2468
+ return Y++, Ie - Y < 256 && (Ae || (Ae = !0, setImmediate(() => {
2461
2469
  const n = new Array(le);
2462
- zt(n), Ge = n, Y = 0, Ie = le, Ce = !1;
2470
+ Xt(n), ze = n, Y = 0, Ie = le, Ae = !1;
2463
2471
  }))), t;
2464
2472
  }
2465
- return At();
2473
+ return qt();
2466
2474
  }
2467
- zt(Ge), Ie = le, Y = 0;
2468
- const Ae = /* @__PURE__ */ new Map(), Sr = process.env.SF_FUNCSPAN_SKIP_BACKEND === "true", br = process.env.SF_FUNCSPAN_CONSOLE_OUTPUT === "true", O = process.env.SF_FUNCSPAN_JSONL_FILE, Nt = '{"type":"null","has_value":true,"value":null}';
2469
- let qe = null;
2470
- function xr(t, n, e, o) {
2475
+ Xt(ze), Ie = le, Y = 0;
2476
+ const qe = /* @__PURE__ */ new Map(), br = process.env.SF_FUNCSPAN_SKIP_BACKEND === "true", vr = process.env.SF_FUNCSPAN_CONSOLE_OUTPUT === "true", O = process.env.SF_FUNCSPAN_JSONL_FILE, Ut = '{"type":"null","has_value":true,"value":null}';
2477
+ let Le = null;
2478
+ function Hr(t, n, e, o) {
2471
2479
  const r = function(...i) {
2472
- const d = on(), u = d?.sfDebug || !1;
2480
+ const d = sn(), u = d?.sfDebug || !1;
2473
2481
  let a;
2474
- if (u && console.log(`[FuncSpan] captureFunctionSpan wrapper called for ${e}::${n}`), Gt()) {
2482
+ if (u && console.log(`[FuncSpan] captureFunctionSpan wrapper called for ${e}::${n}`), zt()) {
2475
2483
  const h = {};
2476
- for (let g = 0; g < o.paramNames.length && g < i.length; g++) h[o.paramNames[g]] = i[g];
2477
- a = Dt(e, n, h);
2478
- } else a = Dt(e, n, Xt);
2484
+ for (let m = 0; m < o.paramNames.length && m < i.length; m++) h[o.paramNames[m]] = i[m];
2485
+ a = Pt(e, n, h);
2486
+ } else a = Pt(e, n, Yt);
2479
2487
  if (u && console.log(`[FuncSpan] Config for ${e}::${n}:`, a), a.enable_sampling && a.sample_rate < 1 && Math.random() > a.sample_rate) return u && console.log(`[FuncSpan] Skipping ${n} due to sampling`), t.apply(this, i);
2480
2488
  if (a.sample_rate === 0) return u && console.log(`[FuncSpan] Skipping ${n} - sample_rate is 0.0`), t.apply(this, i);
2481
2489
  u && console.log(`[FuncSpan] Capturing function span for ${n}`);
2482
- const s = Q.getInstance(), l = s.getCurrentFunctionSpanId(), c = mr();
2483
- s.setCurrentFunctionSpanId(c);
2490
+ const s = Q.getInstance(), c = s.getCurrentFunctionSpanId(), l = Sr();
2491
+ s.setCurrentFunctionSpanId(l);
2484
2492
  const p = O ? process.hrtime.bigint() : 0n, f = Date.now();
2485
- let y;
2493
+ let g;
2486
2494
  if (a.capture_arguments) {
2487
- const h = o.paramNames, g = h.length < i.length ? h.length : i.length, S = fn(h, i, g);
2488
- if (S !== null && S.length <= 1024 * a.arg_limit_mb * 1024) y = S;
2495
+ const h = o.paramNames, m = h.length < i.length ? h.length : i.length, I = hn(h, i, m);
2496
+ if (I !== null && I.length <= 1024 * a.arg_limit_mb * 1024) g = I;
2489
2497
  else {
2490
- const I = {};
2491
- for (let E = 0; E < g; E++) I[h[E]] = i[E];
2492
- y = hn(I, a.arg_limit_mb);
2498
+ const E = {};
2499
+ for (let b = 0; b < m; b++) E[h[b]] = i[b];
2500
+ g = gn(E, a.arg_limit_mb);
2493
2501
  }
2494
- } else y = "{}";
2502
+ } else g = "{}";
2495
2503
  try {
2496
2504
  const h = t.apply(this, i);
2497
- if (h && typeof h.then == "function") return l ? s.setCurrentFunctionSpanId(l) : s.clearCurrentFunctionSpanId(), h.then((E) => {
2498
- const w = Date.now(), _ = O ? Number(process.hrtime.bigint() - p) : 1e6 * (w - f), N = Ze(E, a.capture_return_value, a.return_limit_mb);
2499
- return b.functionName = n, b.filePath = e, b.metadata = o, b.argsJson = y, b.returnValueJson = N, b.error = null, b.duration = w - f, b.durationNs = _, b.startTimeNs = O ? p.toString() : "", b.async = !0, b.spanId = c, b.parentSpanId = l, b.pid = process.pid, b.threadId = ge, b.debug = u, me(b), E;
2500
- }, (E) => {
2505
+ if (h && typeof h.then == "function") return c ? s.setCurrentFunctionSpanId(c) : s.clearCurrentFunctionSpanId(), h.then((b) => {
2506
+ const w = Date.now(), _ = O ? Number(process.hrtime.bigint() - p) : 1e6 * (w - f), k = et(b, a.capture_return_value, a.return_limit_mb);
2507
+ return S.functionName = n, S.filePath = e, S.metadata = o, S.argsJson = g, S.returnValueJson = k, S.error = null, S.duration = w - f, S.durationNs = _, S.startTimeNs = O ? p.toString() : "", S.async = !0, S.spanId = l, S.parentSpanId = c, S.pid = process.pid, S.threadId = ge, S.debug = u, me(S), b;
2508
+ }, (b) => {
2501
2509
  const w = Date.now(), _ = O ? Number(process.hrtime.bigint() - p) : 1e6 * (w - f);
2502
- throw b.functionName = n, b.filePath = e, b.metadata = o, b.argsJson = y, b.returnValueJson = Nt, b.error = E?.message || String(E), b.duration = w - f, b.durationNs = _, b.startTimeNs = O ? p.toString() : "", b.async = !0, b.spanId = c, b.parentSpanId = l, b.pid = process.pid, b.threadId = ge, b.debug = u, me(b), E;
2510
+ throw S.functionName = n, S.filePath = e, S.metadata = o, S.argsJson = g, S.returnValueJson = Ut, S.error = b?.message || String(b), S.duration = w - f, S.durationNs = _, S.startTimeNs = O ? p.toString() : "", S.async = !0, S.spanId = l, S.parentSpanId = c, S.pid = process.pid, S.threadId = ge, S.debug = u, me(S), b;
2503
2511
  });
2504
- const g = Date.now(), S = O ? Number(process.hrtime.bigint() - p) : 1e6 * (g - f), I = Ze(h, a.capture_return_value, a.return_limit_mb);
2505
- return b.functionName = n, b.filePath = e, b.metadata = o, b.argsJson = y, b.returnValueJson = I, b.error = null, b.duration = g - f, b.durationNs = S, b.startTimeNs = O ? p.toString() : "", b.async = !1, b.spanId = c, b.parentSpanId = l, b.pid = process.pid, b.threadId = ge, b.debug = u, me(b), l ? s.setCurrentFunctionSpanId(l) : s.clearCurrentFunctionSpanId(), h;
2512
+ const m = Date.now(), I = O ? Number(process.hrtime.bigint() - p) : 1e6 * (m - f), E = et(h, a.capture_return_value, a.return_limit_mb);
2513
+ return S.functionName = n, S.filePath = e, S.metadata = o, S.argsJson = g, S.returnValueJson = E, S.error = null, S.duration = m - f, S.durationNs = I, S.startTimeNs = O ? p.toString() : "", S.async = !1, S.spanId = l, S.parentSpanId = c, S.pid = process.pid, S.threadId = ge, S.debug = u, me(S), c ? s.setCurrentFunctionSpanId(c) : s.clearCurrentFunctionSpanId(), h;
2506
2514
  } catch (h) {
2507
- const g = Date.now(), S = O ? Number(process.hrtime.bigint() - p) : 1e6 * (g - f);
2508
- throw b.functionName = n, b.filePath = e, b.metadata = o, b.argsJson = y, b.returnValueJson = Nt, b.error = h?.message || String(h), b.duration = g - f, b.durationNs = S, b.startTimeNs = O ? p.toString() : "", b.async = !1, b.spanId = c, b.parentSpanId = l, b.pid = process.pid, b.threadId = ge, b.debug = u, me(b), l ? s.setCurrentFunctionSpanId(l) : s.clearCurrentFunctionSpanId(), h;
2515
+ const m = Date.now(), I = O ? Number(process.hrtime.bigint() - p) : 1e6 * (m - f);
2516
+ throw S.functionName = n, S.filePath = e, S.metadata = o, S.argsJson = g, S.returnValueJson = Ut, S.error = h?.message || String(h), S.duration = m - f, S.durationNs = I, S.startTimeNs = O ? p.toString() : "", S.async = !1, S.spanId = l, S.parentSpanId = c, S.pid = process.pid, S.threadId = ge, S.debug = u, me(S), c ? s.setCurrentFunctionSpanId(c) : s.clearCurrentFunctionSpanId(), h;
2509
2517
  }
2510
2518
  };
2511
2519
  Object.defineProperty(r, "name", { value: n, writable: !1 });
2512
2520
  for (const i in t) t.hasOwnProperty(i) && (r[i] = t[i]);
2513
2521
  return r;
2514
2522
  }
2515
- const Xt = Object.freeze({}), vr = globalThis;
2516
- let Ut = -1;
2517
- function Dt(t, n, e = Xt) {
2518
- const o = Le();
2523
+ const Yt = Object.freeze({}), Ir = globalThis;
2524
+ let Dt = -1;
2525
+ function Pt(t, n, e = Yt) {
2526
+ const o = Re();
2519
2527
  if (o) {
2520
- const a = Re(o);
2528
+ const a = Be(o);
2521
2529
  if (a) return a;
2522
2530
  }
2523
- if (Gt()) try {
2524
- const a = pr(t, n, e);
2531
+ if (zt()) try {
2532
+ const a = fr(t, n, e);
2525
2533
  if (a !== null) return { capture_arguments: a.captureArgs, capture_return_value: a.captureReturnValue, arg_limit_mb: a.argLimitMb, return_limit_mb: a.returnLimitMb, autocapture_all_child_functions: a.propagate, sample_rate: 1, enable_sampling: !1, capture_sf_veritas: !1, parse_json_strings: !1 };
2526
2534
  } catch {
2527
2535
  }
2528
- const r = vr.__sf_configEpoch ?? 0;
2529
- r !== Ut && (Ae.clear(), Ut = r);
2530
- const i = t + "::" + n, d = Ae.get(i);
2536
+ const r = Ir.__sf_configEpoch ?? 0;
2537
+ r !== Dt && (qe.clear(), Dt = r);
2538
+ const i = t + "::" + n, d = qe.get(i);
2531
2539
  if (d !== void 0) return d;
2532
2540
  let u;
2533
2541
  try {
2534
- u = jn(t, n);
2542
+ u = xn(t, n);
2535
2543
  } catch {
2536
2544
  u = { sample_rate: process.env.SF_FUNCSPAN_SAMPLE_RATE ? parseFloat(process.env.SF_FUNCSPAN_SAMPLE_RATE) : 1, capture_arguments: !0, capture_return_value: !0, arg_limit_mb: 1, return_limit_mb: 1, enable_sampling: !1, autocapture_all_child_functions: !1, capture_sf_veritas: !1, parse_json_strings: !1 };
2537
2545
  }
2538
- return Ae.set(i, u), u;
2546
+ return qe.set(i, u), u;
2539
2547
  }
2540
- const b = { functionName: "", filePath: "", metadata: { line: 0, column: 0, paramNames: [] }, argsJson: "", returnValueJson: "", error: null, duration: 0, durationNs: 0, startTimeNs: "", async: !1, spanId: "", parentSpanId: null, pid: 0, threadId: 0, debug: !1 };
2548
+ const S = { functionName: "", filePath: "", metadata: { line: 0, column: 0, paramNames: [] }, argsJson: "", returnValueJson: "", error: null, duration: 0, durationNs: 0, startTimeNs: "", async: !1, spanId: "", parentSpanId: null, pid: 0, threadId: 0, debug: !1 };
2541
2549
  function me(t) {
2542
2550
  const n = t.debug;
2543
- n && console.log("[FuncSpan] captureSpanData called for:", { function: t.functionName, file: t.filePath, duration: `${t.duration}ms`, async: t.async, error: t.error, spanId: t.spanId }), br && console.log(`
2551
+ n && console.log("[FuncSpan] captureSpanData called for:", { function: t.functionName, file: t.filePath, duration: `${t.duration}ms`, async: t.async, error: t.error, spanId: t.spanId }), vr && console.log(`
2544
2552
  📊 Function Span:`, { function: `${t.functionName} (${t.filePath}:${t.metadata.line}:${t.metadata.column})`, duration: `${t.duration.toFixed(2)}ms`, arguments: JSON.parse(t.argsJson), result: t.error ? `Error: ${t.error}` : JSON.parse(t.returnValueJson), spanId: t.spanId, parentSpanId: t.parentSpanId || "none" });
2545
2553
  const e = O;
2546
2554
  if (e) try {
@@ -2550,43 +2558,43 @@ function me(t) {
2550
2558
  } catch (o) {
2551
2559
  console.error("[FuncSpan] Error writing to JSONL file:", o);
2552
2560
  }
2553
- if (n && console.log("[FuncSpan] Sending function span to transmitter:", t), !Sr) try {
2554
- (qe || (qe = new gn()), qe).sendOne(t), n && console.log("[FuncSpan] Function span sent successfully");
2561
+ if (n && console.log("[FuncSpan] Sending function span to transmitter:", t), !br) try {
2562
+ (Le || (Le = new yn()), Le).sendOne(t), n && console.log("[FuncSpan] Function span sent successfully");
2555
2563
  } catch (o) {
2556
2564
  n && console.error("[FuncSpan] Error sending function span:", o);
2557
2565
  }
2558
2566
  }
2559
- function Hr(t) {
2567
+ function Kr(t) {
2560
2568
  return !!t.includes("captureFunctionSpan(") || !!t.includes("@sailfish-ai/sf-veritas") || !(!t.includes("/* @sailfish-instrumented */") && !t.includes("// @sailfish-instrumented"));
2561
2569
  }
2562
2570
  export {
2563
2571
  Q as ContextManager,
2564
- qr as _setAsyncQueueHopSpy,
2565
- jr as addOrUpdateMetadata,
2566
- xr as captureFunctionSpan,
2567
- Vr as clearFuncspanOverride,
2572
+ Lr as _setAsyncQueueHopSpy,
2573
+ xr as addOrUpdateMetadata,
2574
+ Hr as captureFunctionSpan,
2575
+ Gr as clearFuncspanOverride,
2568
2576
  K as getCurrentFunctionSpanId,
2569
- Pt as getDefaultConfig,
2570
- an as getEnvConfig,
2571
- Le as getFuncspanOverride,
2572
- jn as getGlobalConfig,
2573
- Mr as identify,
2574
- Mn as initializeConfigLoader,
2575
- Vn as initializeWorkerPoolPatching,
2576
- Hr as isAlreadyInstrumented,
2577
- Lr as isAsyncQueuePatchesInstalled,
2578
- xn as isConfigLoaderInitialized,
2579
- Xr as isProductionEnvironment,
2580
- Yr as isRuntimeModeEnabled,
2581
- Or as isSetupInterceptorsInitialized,
2582
- Gn as isWorkerPoolInitialized,
2583
- Re as parseHeaderOverride,
2584
- Qr as runWithContext,
2585
- Gr as setFuncspanOverride,
2586
- to as setSkipTypeScriptPlugin,
2587
- Br as setupInterceptors,
2588
- Zr as shouldEnableRuntimeHooks,
2589
- no as transformFunctionSpans,
2590
- ro as transformFunctionSpansSync,
2591
- Rr as uninstallAsyncQueuePatches
2577
+ Ft as getDefaultConfig,
2578
+ cn as getEnvConfig,
2579
+ Re as getFuncspanOverride,
2580
+ xn as getGlobalConfig,
2581
+ jr as identify,
2582
+ jn as initializeConfigLoader,
2583
+ Gn as initializeWorkerPoolPatching,
2584
+ Kr as isAlreadyInstrumented,
2585
+ Rr as isAsyncQueuePatchesInstalled,
2586
+ Hn as isConfigLoaderInitialized,
2587
+ Yr as isProductionEnvironment,
2588
+ Zr as isRuntimeModeEnabled,
2589
+ Mr as isSetupInterceptorsInitialized,
2590
+ zn as isWorkerPoolInitialized,
2591
+ Be as parseHeaderOverride,
2592
+ Wr as runWithContext,
2593
+ zr as setFuncspanOverride,
2594
+ no as setSkipTypeScriptPlugin,
2595
+ Or as setupInterceptors,
2596
+ eo as shouldEnableRuntimeHooks,
2597
+ ro as transformFunctionSpans,
2598
+ oo as transformFunctionSpansSync,
2599
+ Br as uninstallAsyncQueuePatches
2592
2600
  };