@usesocial/cli 0.18.3 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
3
  import * as fs from "node:fs";
4
- import { createReadStream, existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
5
- import { basename, delimiter, dirname, extname, join, resolve } from "node:path";
4
+ import { constants, existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
5
+ import { basename, delimiter, dirname, extname, isAbsolute, join, resolve } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import { homedir } from "node:os";
8
8
  import { parseArgs, styleText } from "node:util";
9
- import { chmod, lstat, mkdir, readFile, readdir, readlink, rm, writeFile } from "node:fs/promises";
9
+ import { chmod, lstat, mkdir, open, readFile, readdir, readlink, rm, writeFile } from "node:fs/promises";
10
10
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
11
11
  import { createHash } from "node:crypto";
12
- import { dirname as dirname$1, isAbsolute, posix, relative, sep } from "path";
12
+ import { dirname as dirname$1, isAbsolute as isAbsolute$1, posix, relative, sep } from "path";
13
13
  import * as l from "node:readline";
14
14
  import l__default, { createInterface } from "node:readline";
15
15
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -40,7 +40,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
40
40
  }) : target, mod));
41
41
  var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
42
42
  //#endregion
43
- //#region ../../node_modules/.bun/better-result@2.10.0/node_modules/better-result/dist/index.mjs
43
+ //#region ../../node_modules/.bun/better-result@3.0.0/node_modules/better-result/dist/index.mjs
44
44
  function e(e, t) {
45
45
  return e === 2 ? ((...e) => e.length >= 2 ? t(e[0], e[1]) : (n) => t(n, e[0])) : e === 3 ? ((...e) => e.length >= 3 ? t(e[0], e[1], e[2]) : (n) => t(n, e[0], e[1])) : e === 4 ? ((...e) => e.length >= 4 ? t(e[0], e[1], e[2], e[3]) : (n) => t(n, e[0], e[1], e[2])) : ((...n) => n.length >= e ? t(...n) : (e) => t(e, ...n));
46
46
  }
@@ -227,12 +227,9 @@ const p = (e) => e instanceof Error ? {
227
227
  stack: e.stack
228
228
  } : e;
229
229
  const m$1 = (e) => e instanceof Error && `_tag` in e && typeof e._tag == `string` && `toJSON` in e && typeof e.toJSON == `function`;
230
- const h = Object.assign((e) => () => {
230
+ const h = (e) => {
231
231
  class t extends Error {
232
232
  _tag = e;
233
- static is(e) {
234
- return e instanceof t;
235
- }
236
233
  constructor(t) {
237
234
  let n = t && `message` in t && typeof t.message == `string` ? t.message : void 0, r = t && `cause` in t ? t.cause : void 0;
238
235
  if (super(n, r === void 0 ? void 0 : { cause: r }), t && Object.assign(this, t), Object.setPrototypeOf(this, new.target.prototype), this.name = e, r instanceof Error && r.stack) {
@@ -251,13 +248,28 @@ const h = Object.assign((e) => () => {
251
248
  stack: this.stack
252
249
  };
253
250
  }
251
+ match(e) {
252
+ return g(this, e);
253
+ }
254
254
  *[Symbol.iterator]() {
255
255
  return yield* d(this), i$1(`Unreachable: Err yielded in TaggedError but generator continued`, this);
256
256
  }
257
+ static is(e) {
258
+ return e instanceof this;
259
+ }
257
260
  }
258
261
  return t;
259
- }, { is: m$1 });
260
- var y = class extends h(`UnhandledException`)() {
262
+ };
263
+ h.is = m$1;
264
+ const g = e(2, (e, t) => {
265
+ let n = t[e._tag];
266
+ try {
267
+ return n(e);
268
+ } catch (e) {
269
+ return i$1(`matchError handler threw`, e);
270
+ }
271
+ });
272
+ var x = class extends h(`UnhandledException`) {
261
273
  constructor(e) {
262
274
  let t = e.cause instanceof Error ? `Unhandled exception: ${e.cause.message}` : `Unhandled exception: ${String(e.cause)}`;
263
275
  super({
@@ -266,27 +278,37 @@ var y = class extends h(`UnhandledException`)() {
266
278
  });
267
279
  }
268
280
  };
269
- var b = class extends h(`ResultDeserializationError`)() {
281
+ var S = class extends h(`ResultDeserializationError`) {
270
282
  constructor(e) {
271
283
  super({
272
- message: `Failed to deserialize value as Result: expected { status: "ok", value } or { status: "error", error }`,
273
- value: e.value
284
+ message: e.issues ? `Failed to deserialize Result payload` : `Failed to deserialize value as Result: expected { status: "ok", value } or { status: "error", error }`,
285
+ value: e.value,
286
+ issues: e.issues
274
287
  });
275
288
  }
276
289
  };
277
- const x = (e, t) => {
290
+ var C$1 = class extends h(`ResultSerializationError`) {
291
+ constructor(e) {
292
+ super({
293
+ message: `Failed to serialize Result payload`,
294
+ value: e.value,
295
+ issues: e.issues
296
+ });
297
+ }
298
+ };
299
+ const w = (e, t) => {
278
300
  try {
279
301
  return e();
280
302
  } catch (e) {
281
303
  throw i$1(t, e);
282
304
  }
283
305
  };
284
- const S = (e, t) => {
306
+ const T = (e, t) => {
285
307
  let n = (t) => {
286
308
  if (typeof e == `function`) try {
287
309
  return l$1(e(t));
288
310
  } catch (e) {
289
- return d(new y({ cause: e }));
311
+ return d(new x({ cause: e }));
290
312
  }
291
313
  try {
292
314
  return l$1(e.try(t));
@@ -301,12 +323,12 @@ const S = (e, t) => {
301
323
  for (let e = 0; e < r && o.status === `error`; e++) a++, o = n({ attempt: a });
302
324
  return o;
303
325
  };
304
- const C$1 = async (e, t) => {
326
+ const E = async (e, t) => {
305
327
  let n = async (t) => {
306
328
  if (typeof e == `function`) try {
307
329
  return l$1(await e(t));
308
330
  } catch (e) {
309
- return d(new y({ cause: e }));
331
+ return d(new x({ cause: e }));
310
332
  }
311
333
  try {
312
334
  return l$1(await e.try(t));
@@ -318,28 +340,59 @@ const C$1 = async (e, t) => {
318
340
  }
319
341
  }
320
342
  }, r = t?.retry;
321
- if (!r) return n({ attempt: 1 });
322
- let a = (e) => {
323
- switch (r.backoff) {
324
- case `constant`: return r.delayMs;
325
- case `linear`: return r.delayMs * (e + 1);
326
- case `exponential`: return r.delayMs * 2 ** e;
327
- }
328
- }, o = (e) => new Promise((t) => setTimeout(t, e)), s = 1, c = await n({ attempt: s }), u = r.shouldRetry ?? (() => !0);
329
- for (let e = 0; e < r.times && c.status === `error`; e++) {
330
- let t = c.error;
331
- if (!x(() => u(t), `shouldRetry predicate threw`)) break;
332
- await o(a(e)), s++, c = await n({ attempt: s });
333
- }
334
- return c;
335
- };
336
- const w = e(2, (e, t) => e.map(t));
337
- const T = e(2, (e, t) => e.mapError(t));
338
- const E = e(2, (e, t) => e.tryRecover(t));
339
- const D = e(2, (e, t) => e.andThen(t));
340
- const O = e(2, (e, t) => e.tryRecoverAsync(t));
341
- const k = e(2, (e, t) => e.andThenAsync(t));
342
- const A = e(2, (e, t) => e.match(t));
343
+ if (!r) return n({
344
+ attempt: 1,
345
+ signal: t?.signal
346
+ });
347
+ let a = (e, t, n) => {
348
+ switch (t) {
349
+ case `constant`: return e;
350
+ case `linear`: return e * (n + 1);
351
+ case `exponential`: return e * 2 ** n;
352
+ }
353
+ }, o = r.jitter ?? !1;
354
+ if (typeof o == `number` && (!Number.isFinite(o) || o < 0 || o > 1)) throw i$1(`Result.tryPromise retry jitter must be a finite number between 0 and 1`);
355
+ let s = o === !0 ? 1 : o === !1 ? 0 : o, c = (e) => s === 0 ? e : e * (1 - s + Math.random() * s), u = (e, t) => new Promise((n) => {
356
+ if (t?.aborted) {
357
+ n(!1);
358
+ return;
359
+ }
360
+ let r = () => {
361
+ clearTimeout(i), n(!1);
362
+ }, i = setTimeout(() => {
363
+ t?.removeEventListener(`abort`, r), n(!0);
364
+ }, e);
365
+ t?.addEventListener(`abort`, r, { once: !0 });
366
+ }), f = {
367
+ attempt: 1,
368
+ signal: t.signal
369
+ }, p = await n(f), m = r.shouldRetry ?? (() => !0);
370
+ for (let e = 0; e < r.times && !(p.status !== `error` || f.signal?.aborted); e++) {
371
+ let o = p.error;
372
+ if (!w(() => m(o, f), `shouldRetry predicate threw`)) break;
373
+ let s;
374
+ if (typeof r.delayMs == `function`) {
375
+ let e = r.delayMs;
376
+ s = w(() => e(o, f), `Result.tryPromise delayMs callback threw`);
377
+ } else {
378
+ if (r.backoff === void 0) throw i$1(`Result.tryPromise static retry delay requires backoff`);
379
+ s = c(a(r.delayMs, r.backoff, e));
380
+ }
381
+ if (!await u(s, f.signal) || f.signal?.aborted) break;
382
+ f = {
383
+ attempt: f.attempt + 1,
384
+ signal: t.signal
385
+ }, p = await n(f);
386
+ }
387
+ return p;
388
+ };
389
+ const D = e(2, (e, t) => e.map(t));
390
+ const O = e(2, (e, t) => e.mapError(t));
391
+ const k = e(2, (e, t) => e.tryRecover(t));
392
+ const A = e(2, (e, t) => e.andThen(t));
393
+ const ee = e(2, (e, t) => e.tryRecoverAsync(t));
394
+ const te = e(2, (e, t) => e.andThenAsync(t));
395
+ const ne = e(2, (e, t) => e.match(t));
343
396
  const j = e(2, (e, t) => e.tap(t));
344
397
  const M = e(2, (e, t) => e.tapAsync(t));
345
398
  const N = e(2, (e, t) => e.tapError(t));
@@ -384,30 +437,101 @@ async function* V$1(e) {
384
437
  return yield* await e;
385
438
  }
386
439
  function H(e) {
387
- return typeof e == `object` && !!e && `status` in e && (e.status === `ok` && `value` in e || e.status === `error` && `error` in e);
388
- }
389
- const U = (e) => e.status === `ok` ? {
390
- status: `ok`,
391
- value: e.value
392
- } : {
393
- status: `error`,
394
- error: e.error
440
+ return typeof e == `object` && !!e && `status` in e && (e.status === `ok` || e.status === `error`);
441
+ }
442
+ const U = (e) => typeof e == `object` && !!e && `then` in e && typeof e.then == `function`;
443
+ const W$2 = (e, t) => w(e, t);
444
+ const G = (e, t, n) => U(e) ? Promise.resolve(e).catch((e) => {
445
+ throw i$1(t, e);
446
+ }).then(n) : n(e);
447
+ const K = (e, t) => `issues` in e && e.issues ? d(t(e.issues)) : l$1(e.value);
448
+ const q = (e, t) => G(W$2(() => e[`~standard`].validate(t), `Result.codec serialize schema threw`), `Result.codec serialize schema threw`, (e) => K(e, (e) => new C$1({
449
+ value: t,
450
+ issues: e
451
+ })));
452
+ const J = (e, t) => G(W$2(() => e[`~standard`].validate(t), `Result.codec deserialize schema threw`), `Result.codec deserialize schema threw`, (e) => K(e, (e) => new S({
453
+ value: t,
454
+ issues: e
455
+ })));
456
+ const Y = (e, t) => U(e) ? Promise.resolve(e).then((e) => e.unwrap(t)) : e.unwrap(t);
457
+ const X = (e) => {
458
+ let t = (e) => e.status === `ok` ? l$1(e.value) : S.is(e.error) ? e.unwrap(`Result.codec deserializeUnsafe failed`) : d(e.error);
459
+ return U(e) ? Promise.resolve(e).then(t) : t(e);
460
+ };
461
+ const re = (e) => {
462
+ let t = (e) => e.status === `error` ? d(e.error) : l$1({
463
+ status: `ok`,
464
+ value: e.value
465
+ }), n = (e) => e.status === `error` ? d(e.error) : l$1({
466
+ status: `error`,
467
+ error: e.value
468
+ });
469
+ function r(r) {
470
+ if (r.status === `ok`) {
471
+ let n = q(e.serialize.ok, r.value);
472
+ return U(n) ? Promise.resolve(n).then(t) : t(n);
473
+ }
474
+ let i = q(e.serialize.err, r.error);
475
+ return U(i) ? Promise.resolve(i).then(n) : n(i);
476
+ }
477
+ let i = (e) => e.status === `error` ? d(e.error) : l$1(e.value), a = (e) => e.status === `error` ? d(e.error) : d(e.value);
478
+ function o(t) {
479
+ if (!H(t)) return d(new S({ value: t }));
480
+ if (t.status === `ok`) {
481
+ let n = J(e.deserialize.ok, t.value);
482
+ return U(n) ? Promise.resolve(n).then(i) : i(n);
483
+ }
484
+ let n = J(e.deserialize.err, t.error);
485
+ return U(n) ? Promise.resolve(n).then(a) : a(n);
486
+ }
487
+ function s(e) {
488
+ return Y(r(e), `Result.codec serializeUnsafe failed`);
489
+ }
490
+ function c(e) {
491
+ return X(o(e));
492
+ }
493
+ return {
494
+ serialize: r,
495
+ serializeUnsafe: s,
496
+ deserialize: o,
497
+ deserializeUnsafe: c
498
+ };
499
+ };
500
+ const Z = async (e, t) => {
501
+ try {
502
+ return await Promise.all(e);
503
+ } catch (e) {
504
+ return i$1(t, e);
505
+ }
395
506
  };
396
- const W$2 = (e) => H(e) ? e.status === `ok` ? new s(e.value) : new c(e.error) : d(new b({ value: e }));
397
- const G = {
507
+ const Q = (e) => {
508
+ let t = [];
509
+ for (let n of e) {
510
+ if (n.status === `error`) return n;
511
+ t.push(n.value);
512
+ }
513
+ return l$1(t);
514
+ };
515
+ const ie = async (e) => Q(await Z(e, `Result.allAsync input promise rejected`));
516
+ const $ = (e) => {
517
+ let t = [], n = [];
518
+ for (let r of e) r.status === `ok` ? t.push(r.value) : n.push(r.error);
519
+ return [t, n];
520
+ };
521
+ const ae = {
398
522
  ok: l$1,
399
523
  isOk: u$1,
400
524
  err: d,
401
525
  isError: f,
402
- try: S,
403
- tryPromise: C$1,
404
- map: w,
405
- mapError: T,
406
- tryRecover: E,
407
- andThen: D,
408
- tryRecoverAsync: O,
409
- andThenAsync: k,
410
- match: A,
526
+ try: T,
527
+ tryPromise: E,
528
+ map: D,
529
+ mapError: O,
530
+ tryRecover: k,
531
+ andThen: A,
532
+ tryRecoverAsync: ee,
533
+ andThenAsync: te,
534
+ match: ne,
411
535
  tap: j,
412
536
  tapAsync: M,
413
537
  tapError: N,
@@ -418,14 +542,11 @@ const G = {
418
542
  unwrapOr: z,
419
543
  gen: B,
420
544
  await: V$1,
421
- serialize: U,
422
- deserialize: W$2,
423
- hydrate: (e) => W$2(e),
424
- partition: (e) => {
425
- let t = [], n = [];
426
- for (let r of e) r.status === `ok` ? t.push(r.value) : n.push(r.error);
427
- return [t, n];
428
- },
545
+ codec: re,
546
+ all: Q,
547
+ allAsync: ie,
548
+ partition: $,
549
+ partitionAsync: async (e) => $(await Z(e, `Result.partitionAsync input promise rejected`)),
429
550
  flatten: (e) => e.status === `ok` ? e.value : e
430
551
  };
431
552
  //#endregion
@@ -477,8 +598,6 @@ const cliBrand = {
477
598
  }
478
599
  };
479
600
  `${cliBrand.installCommands.npm}${cliBrand.installCommands.skill}`;
480
- h("InvalidPublicBaseURL")();
481
- h("InvalidPublicRoute")();
482
601
  const publicURLForLiteral = (route) => new URL(route, brandURLs.publicWebURL).toString();
483
602
  const publicRouteURLs = {
484
603
  pricing: publicURLForLiteral(publicLinks.pricing),
@@ -548,7 +667,7 @@ const priceUsage = (costBPS) => {
548
667
  };
549
668
  const creditsToUsageUSD = (credits) => credits * 10 / 1e4;
550
669
  //#endregion
551
- //#region ../../node_modules/.bun/es-toolkit@1.49.0/node_modules/es-toolkit/dist/string/words.mjs
670
+ //#region ../../node_modules/.bun/es-toolkit@1.50.0/node_modules/es-toolkit/dist/string/words.mjs
552
671
  /**
553
672
  * Regular expression pattern to split strings into words for various case conversions
554
673
  *
@@ -588,7 +707,7 @@ function words(str) {
588
707
  return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
589
708
  }
590
709
  //#endregion
591
- //#region ../../node_modules/.bun/es-toolkit@1.49.0/node_modules/es-toolkit/dist/string/kebabCase.mjs
710
+ //#region ../../node_modules/.bun/es-toolkit@1.50.0/node_modules/es-toolkit/dist/string/kebabCase.mjs
592
711
  /**
593
712
  * Converts a string to kebab case.
594
713
  *
@@ -611,7 +730,7 @@ function kebabCase$1(str) {
611
730
  const flagName = (name) => kebabCase$1(name.replace(/[._]/g, "-"));
612
731
  //#endregion
613
732
  //#region ../../packages/codegen/src/runtime/index.ts
614
- var RuntimeUsageProblem = class extends h("RuntimeUsageProblem")() {
733
+ var RuntimeUsageProblem = class extends h("RuntimeUsageProblem") {
615
734
  constructor(input) {
616
735
  super({
617
736
  ...input,
@@ -619,12 +738,12 @@ var RuntimeUsageProblem = class extends h("RuntimeUsageProblem")() {
619
738
  });
620
739
  }
621
740
  };
622
- var RuntimeBodyProblem = class extends h("RuntimeBodyProblem")() {
741
+ var RuntimeBodyProblem = class extends h("RuntimeBodyProblem") {
623
742
  constructor(input) {
624
743
  super(input);
625
744
  }
626
745
  };
627
- var RuntimeMediaProblem = class extends h("RuntimeMediaProblem")() {
746
+ var RuntimeMediaProblem = class extends h("RuntimeMediaProblem") {
628
747
  constructor(input) {
629
748
  super(input);
630
749
  }
@@ -651,19 +770,19 @@ const resolvePathTemplateResult = (template, values) => {
651
770
  continue;
652
771
  }
653
772
  const value = values[name];
654
- if (value === void 0) return G.err(new RuntimeUsageProblem({
773
+ if (value === void 0) return ae.err(new RuntimeUsageProblem({
655
774
  kind: "missing_path_parameter",
656
775
  paramName: name
657
776
  }));
658
777
  resolvedSegments.push(safePathSegment(value));
659
778
  }
660
779
  const resolvedPath = resolvedSegments.join("/");
661
- if (!resolvedPath) return G.ok(template.startsWith("/") ? "/" : "");
662
- return G.ok(`${template.startsWith("/") ? "/" : ""}${resolvedPath}`);
780
+ if (!resolvedPath) return ae.ok(template.startsWith("/") ? "/" : "");
781
+ return ae.ok(`${template.startsWith("/") ? "/" : ""}${resolvedPath}`);
663
782
  };
664
783
  const resolvePathTemplate = (template, values) => {
665
784
  const resolved = resolvePathTemplateResult(template, values);
666
- if (G.isError(resolved)) throw new Error(resolved.error.message);
785
+ if (ae.isError(resolved)) throw new Error(resolved.error.message);
667
786
  return resolved.value;
668
787
  };
669
788
  const cliFlagNameFor$1 = (adapter, name) => adapter.cliFlagName?.(name) ?? flagName(name);
@@ -695,7 +814,7 @@ const validateMediaAttachmentsResult = (attachments, opts) => {
695
814
  if (opts.rule === "post") {
696
815
  const images = attachments.filter((attachment) => attachment.content_type.startsWith("image/")).length;
697
816
  const others = attachments.length - images;
698
- if (others > 0 && attachments.length > 1) return G.err(new RuntimeMediaProblem({
817
+ if (others > 0 && attachments.length > 1) return ae.err(new RuntimeMediaProblem({
699
818
  kind: "post_attachment_mix",
700
819
  imageCount: images,
701
820
  otherCount: others,
@@ -703,13 +822,13 @@ const validateMediaAttachmentsResult = (attachments, opts) => {
703
822
  }));
704
823
  } else {
705
824
  const total = attachments.reduce((sum, attachment) => sum + attachment.byteLength, 0);
706
- if (total > 20 * 1024 * 1024) return G.err(new RuntimeMediaProblem({
825
+ if (total > 20 * 1024 * 1024) return ae.err(new RuntimeMediaProblem({
707
826
  kind: "message_attachments_too_large",
708
827
  totalBytes: total,
709
828
  message: `LinkedIn message attachments cap at 20 MB combined; yours total ${(total / (1024 * 1024)).toFixed(1)} MB.`
710
829
  }));
711
830
  }
712
- return G.ok(attachments.map(({ content, content_type, filename }) => ({
831
+ return ae.ok(attachments.map(({ content, content_type, filename }) => ({
713
832
  content,
714
833
  content_type,
715
834
  filename
@@ -720,7 +839,7 @@ const mediaAttachmentsFrom = async (deps, paths, opts) => {
720
839
  const attachments = [];
721
840
  for (const path of paths) attachments.push(await deps.readMedia(path));
722
841
  const validated = validateMediaAttachmentsResult(attachments, opts);
723
- if (G.isError(validated)) throw opts.usageError(validated.error.message);
842
+ if (ae.isError(validated)) throw opts.usageError(validated.error.message);
724
843
  return validated.value;
725
844
  };
726
845
  const trimTrailingNewline$1 = (value) => value.endsWith("\r\n") ? value.slice(0, -2) : value.endsWith("\n") ? value.slice(0, -1) : value;
@@ -729,9 +848,9 @@ const parseStdinBodyResult = (deps, bodyTextName, bodyTextKey, value) => {
729
848
  JSON.parse(value);
730
849
  } catch {
731
850
  try {
732
- return G.ok({ [bodyTextKey]: deps.parseBodyText(`<${bodyTextName}>`, value) });
851
+ return ae.ok({ [bodyTextKey]: deps.parseBodyText(`<${bodyTextName}>`, value) });
733
852
  } catch (error) {
734
- return G.err(new RuntimeBodyProblem({
853
+ return ae.err(new RuntimeBodyProblem({
735
854
  kind: "body_parse_failed",
736
855
  message: error instanceof Error ? error.message : "Could not parse stdin body text.",
737
856
  cause: error
@@ -739,9 +858,9 @@ const parseStdinBodyResult = (deps, bodyTextName, bodyTextKey, value) => {
739
858
  }
740
859
  }
741
860
  try {
742
- return G.ok(deps.parseJSONObject("stdin", value));
861
+ return ae.ok(deps.parseJSONObject("stdin", value));
743
862
  } catch (error) {
744
- return G.err(new RuntimeBodyProblem({
863
+ return ae.err(new RuntimeBodyProblem({
745
864
  kind: "body_parse_failed",
746
865
  message: error instanceof Error ? error.message : "Could not parse stdin JSON body.",
747
866
  cause: error
@@ -750,7 +869,7 @@ const parseStdinBodyResult = (deps, bodyTextName, bodyTextKey, value) => {
750
869
  };
751
870
  const parseStdinBody$2 = (deps, bodyTextName, bodyTextKey, value) => {
752
871
  const parsed = parseStdinBodyResult(deps, bodyTextName, bodyTextKey, value);
753
- if (G.isError(parsed)) throw parsed.error.cause ?? parsed.error;
872
+ if (ae.isError(parsed)) throw parsed.error.cause ?? parsed.error;
754
873
  return parsed.value;
755
874
  };
756
875
  const hasStdinBodyText = (adapter, op) => op.config.bodyTextArg !== void 0 && adapter.bodyTextResolvesTarget?.(op) !== true;
@@ -838,16 +957,16 @@ const defaultArgAliases = (name) => /* @__PURE__ */ new Set([name, flagName(name
838
957
  const rejectUnsupportedRuntimeArgsResult = (adapter, op, args, allowedArgNames = Object.keys(buildRuntimeArgs(adapter, op))) => {
839
958
  const allowed = /* @__PURE__ */ new Set(["_"]);
840
959
  for (const name of allowedArgNames) for (const alias of adapter.argAliases?.(name) ?? defaultArgAliases(name)) allowed.add(alias);
841
- for (const [name, value] of Object.entries(args)) if (!allowed.has(name) && (adapter.ignoreUndefinedUnsupportedArgs !== true || value !== void 0)) return G.err(new RuntimeUsageProblem({
960
+ for (const [name, value] of Object.entries(args)) if (!allowed.has(name) && (adapter.ignoreUndefinedUnsupportedArgs !== true || value !== void 0)) return ae.err(new RuntimeUsageProblem({
842
961
  kind: "unsupported_arg",
843
962
  argName: name,
844
963
  value
845
964
  }));
846
- return G.ok();
965
+ return ae.ok();
847
966
  };
848
967
  const rejectUnsupportedRuntimeArgs = (adapter, op, args, allowedArgNames = Object.keys(buildRuntimeArgs(adapter, op))) => {
849
968
  const rejected = rejectUnsupportedRuntimeArgsResult(adapter, op, args, allowedArgNames);
850
- if (G.isError(rejected)) {
969
+ if (ae.isError(rejected)) {
851
970
  if (rejected.error.kind === "unsupported_arg" && rejected.error.argName !== void 0) throw adapter.unsupportedArgError(rejected.error.argName, rejected.error.value, op);
852
971
  throw adapter.usageError(rejected.error.message);
853
972
  }
@@ -924,8 +1043,8 @@ const bodyRequiredPreparseProblem = (adapter, op) => new RuntimeBodyProblem({
924
1043
  message: op.config.bodyTextArg && Object.keys(op.config.bodyParams ?? {}).length === 0 ? `Pass <${bodyTextDisplayKeyFor(op) ?? op.config.bodyTextArg}>.` : "Pass required body positional arguments or --body."
925
1044
  });
926
1045
  const checkBodyRequiredResult = (adapter, op, args, bodyTextOptional) => {
927
- if (!op.hasBody || adapter.checkBodyRequiredBeforeInput !== true) return G.ok();
928
- if (bodyTextOptional) return G.ok();
1046
+ if (!op.hasBody || adapter.checkBodyRequiredBeforeInput !== true) return ae.ok();
1047
+ if (bodyTextOptional) return ae.ok();
929
1048
  const expressions = [];
930
1049
  const bodyTextArg = op.config.bodyTextArg;
931
1050
  if (bodyTextArg && op.config.bodyTextRequired !== false) expressions.push(args[bodyTextDisplayKeyFor(op) ?? bodyTextArg] === void 0);
@@ -933,25 +1052,25 @@ const checkBodyRequiredResult = (adapter, op, args, bodyTextOptional) => {
933
1052
  const positionalValuePresent = param.positional && Array.isArray(args._) && args._.length > 0;
934
1053
  expressions.push(args[flagName(bodyParamArgFor(adapter, name, param))] === void 0 && !positionalValuePresent);
935
1054
  }
936
- if (expressions.length > 0 && typeof args.body !== "string" && expressions.some(Boolean)) return G.err(bodyRequiredPreparseProblem(adapter, op));
937
- return G.ok();
1055
+ if (expressions.length > 0 && typeof args.body !== "string" && expressions.some(Boolean)) return ae.err(bodyRequiredPreparseProblem(adapter, op));
1056
+ return ae.ok();
938
1057
  };
939
1058
  const throwRuntimeBodyProblem = (adapter, problem) => {
940
1059
  throw problem.cause ?? adapter.usageError(problem.message);
941
1060
  };
942
1061
  const checkBodyRequired = (adapter, op, args, bodyTextOptional) => {
943
1062
  const checked = checkBodyRequiredResult(adapter, op, args, bodyTextOptional);
944
- if (G.isError(checked)) throwRuntimeBodyProblem(adapter, checked.error);
1063
+ if (ae.isError(checked)) throwRuntimeBodyProblem(adapter, checked.error);
945
1064
  };
946
1065
  const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
947
1066
  const bodyTextArg = op.config.bodyTextArg;
948
1067
  const bodyParamEntries = Object.entries(op.config.bodyParams ?? {});
949
1068
  if (!bodyTextArg && bodyParamEntries.length === 0) {
950
- if (input.body === void 0) return G.ok(void 0);
1069
+ if (input.body === void 0) return ae.ok(void 0);
951
1070
  try {
952
- return G.ok(deps.parseJSONObject("--body", input.body));
1071
+ return ae.ok(deps.parseJSONObject("--body", input.body));
953
1072
  } catch (error) {
954
- return G.err(new RuntimeBodyProblem({
1073
+ return ae.err(new RuntimeBodyProblem({
955
1074
  kind: "body_parse_failed",
956
1075
  message: error instanceof Error ? error.message : "Could not parse --body JSON.",
957
1076
  cause: error
@@ -962,7 +1081,7 @@ const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
962
1081
  if (input.body !== void 0) try {
963
1082
  bodyFromJSON = deps.parseJSONObject(hasStdinBodyText(adapter, op) ? "stdin" : "--body", input.body);
964
1083
  } catch (error) {
965
- return G.err(new RuntimeBodyProblem({
1084
+ return ae.err(new RuntimeBodyProblem({
966
1085
  kind: "body_parse_failed",
967
1086
  message: error instanceof Error ? error.message : "Could not parse request body JSON.",
968
1087
  cause: error
@@ -973,7 +1092,7 @@ const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
973
1092
  if (bodyTextArg && input[bodyTextArg] !== void 0) try {
974
1093
  bodyText = deps.parseBodyText(`<${displayTextArg}>`, input[bodyTextArg]);
975
1094
  } catch (error) {
976
- return G.err(new RuntimeBodyProblem({
1095
+ return ae.err(new RuntimeBodyProblem({
977
1096
  kind: "body_parse_failed",
978
1097
  message: error instanceof Error ? error.message : "Could not parse body text.",
979
1098
  cause: error
@@ -986,7 +1105,7 @@ const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
986
1105
  try {
987
1106
  bodyParamValues.set(name, value === void 0 ? param.default : param.kind === "array" ? deps.parseResourceIdList(displayName, Array.isArray(value) ? value : [value]) : deps.parseQueryString(displayName, value));
988
1107
  } catch (error) {
989
- return G.err(new RuntimeBodyProblem({
1108
+ return ae.err(new RuntimeBodyProblem({
990
1109
  kind: "body_parse_failed",
991
1110
  message: error instanceof Error ? error.message : `Could not parse ${displayName}.`,
992
1111
  cause: error
@@ -1012,45 +1131,45 @@ const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
1012
1131
  input,
1013
1132
  op
1014
1133
  });
1015
- if (error) return G.err(new RuntimeBodyProblem({
1134
+ if (error) return ae.err(new RuntimeBodyProblem({
1016
1135
  kind: "body_validation_failed",
1017
1136
  message: error.message,
1018
1137
  cause: error
1019
1138
  }));
1020
- return G.ok(resolvedBody);
1139
+ return ae.ok(resolvedBody);
1021
1140
  };
1022
1141
  const buildBody = (adapter, deps, op, input, bodyTextOptional) => {
1023
1142
  const built = buildBodyResult(adapter, deps, op, input, bodyTextOptional);
1024
- if (G.isOk(built)) return built.value;
1143
+ if (ae.isOk(built)) return built.value;
1025
1144
  throwRuntimeBodyProblem(adapter, built.error);
1026
1145
  };
1027
1146
  const resolveBodyTextFromStdinResult = async (adapter, op, deps, args, commandLabel, bodyTextOptional) => {
1028
- if (!hasStdinBodyText(adapter, op)) return G.ok();
1147
+ if (!hasStdinBodyText(adapter, op)) return ae.ok();
1029
1148
  const bodyTextArg = op.config.bodyTextArg;
1030
- if (bodyTextArg === void 0) return G.ok();
1149
+ if (bodyTextArg === void 0) return ae.ok();
1031
1150
  const displayTextArg = bodyTextDisplayKeyFor(op) ?? bodyTextArg;
1032
1151
  const required = stdinBodyTextRequired(adapter, op) && !bodyTextOptional;
1033
1152
  if (deps.isStdinTTY()) {
1034
- if (required) return G.err(new RuntimeBodyProblem({
1153
+ if (required) return ae.err(new RuntimeBodyProblem({
1035
1154
  kind: "stdin_body_required",
1036
1155
  message: bodyTextPipeMessage(commandLabel)
1037
1156
  }));
1038
- return G.ok();
1157
+ return ae.ok();
1039
1158
  }
1040
1159
  const piped = trimTrailingNewline$1(await deps.readStdin());
1041
1160
  if (piped.length > 0) {
1042
1161
  const parsed = parseStdinBodyResult(deps, displayTextArg, bodyTextArg, piped);
1043
- if (G.isError(parsed)) return G.err(parsed.error);
1162
+ if (ae.isError(parsed)) return ae.err(parsed.error);
1044
1163
  args.body = JSON.stringify(parsed.value);
1045
- } else if (required) return G.err(new RuntimeBodyProblem({
1164
+ } else if (required) return ae.err(new RuntimeBodyProblem({
1046
1165
  kind: "stdin_body_required",
1047
1166
  message: bodyTextPipeMessage(commandLabel)
1048
1167
  }));
1049
- return G.ok();
1168
+ return ae.ok();
1050
1169
  };
1051
1170
  const resolveBodyTextFromStdin = async (adapter, op, deps, args, commandLabel, bodyTextOptional) => {
1052
1171
  const resolved = await resolveBodyTextFromStdinResult(adapter, op, deps, args, commandLabel, bodyTextOptional);
1053
- if (G.isError(resolved)) throwRuntimeBodyProblem(adapter, resolved.error);
1172
+ if (ae.isError(resolved)) throwRuntimeBodyProblem(adapter, resolved.error);
1054
1173
  };
1055
1174
  const maximumItemsHintFor$2 = (adapter, op) => adapter.maximumItemsHintFor?.(op);
1056
1175
  const costFor = (adapter, op) => {
@@ -1382,32 +1501,32 @@ const normalizeLiftedRow = (collection, row) => {
1382
1501
  const columns = collectionColumns(collection);
1383
1502
  const columnSet = new Set(columns);
1384
1503
  const normalized = {};
1385
- for (const column of Object.keys(row)) if (!columnSet.has(column)) return G.err({
1504
+ for (const column of Object.keys(row)) if (!columnSet.has(column)) return ae.err({
1386
1505
  kind: "unsupportedValue",
1387
1506
  column,
1388
1507
  message: `${collection.key} produced unexpected column ${column}`
1389
1508
  });
1390
1509
  for (const column of columns) {
1391
1510
  const value = row[column];
1392
- if (unsupportedRowValue(value)) return G.err({
1511
+ if (unsupportedRowValue(value)) return ae.err({
1393
1512
  kind: "unsupportedValue",
1394
1513
  column,
1395
1514
  message: `${collection.key} produced unsupported value for ${column}`
1396
1515
  });
1397
1516
  normalized[column] = value ?? null;
1398
1517
  }
1399
- if (normalized.id === null || normalized.id === "") return G.err({
1518
+ if (normalized.id === null || normalized.id === "") return ae.err({
1400
1519
  kind: "missingId",
1401
1520
  column: "id",
1402
1521
  message: `${collection.key} row is missing id`
1403
1522
  });
1404
- return G.ok(normalized);
1523
+ return ae.ok(normalized);
1405
1524
  };
1406
1525
  const liftCollectionRow = (collection, item) => {
1407
1526
  try {
1408
1527
  return normalizeLiftedRow(collection, collection.lift(item));
1409
1528
  } catch (error) {
1410
- return G.err(normalizationErrorFrom(error));
1529
+ return ae.err(normalizationErrorFrom(error));
1411
1530
  }
1412
1531
  };
1413
1532
  const withCollectionColumns = (collection) => ({
@@ -2219,7 +2338,7 @@ const metadataForPlatform = (platform) => {
2219
2338
  //#endregion
2220
2339
  //#region ../../packages/sqlsync/src/cursor.ts
2221
2340
  const PARTIAL_SYNC_CURSOR_PREFIX = "partial-sync-v1:";
2222
- var CorruptPartialSyncCursor = class extends h("CorruptPartialSyncCursor")() {
2341
+ var CorruptPartialSyncCursor = class extends h("CorruptPartialSyncCursor") {
2223
2342
  constructor(args) {
2224
2343
  super({
2225
2344
  cursor: args.cursor,
@@ -2232,19 +2351,19 @@ const isRecord$13 = (value) => value !== null && typeof value === "object" && !A
2232
2351
  const validPartialSyncCursor = (value) => value.version === 1 && Number.isInteger(value.requestIndex) && typeof value.requestIndex === "number" && value.requestIndex >= 0 && typeof value.cursor === "string" && (typeof value.checkpoint === "string" || value.checkpoint === null) && (typeof value.newestId === "string" || value.newestId === null) && (typeof value.since === "number" || value.since === null) && (value.phase === void 0 || value.phase === "collection" || value.phase === "parent" || value.phase === "child") && (value.parentId === void 0 || typeof value.parentId === "string" || value.parentId === null);
2233
2352
  const encodePartialSyncCursor = (cursor) => `${PARTIAL_SYNC_CURSOR_PREFIX}${JSON.stringify(cursor)}`;
2234
2353
  const parsePartialSyncCursor = (value) => {
2235
- if (!value.startsWith("partial-sync-v1:")) return G.err(new CorruptPartialSyncCursor({
2354
+ if (!value.startsWith("partial-sync-v1:")) return ae.err(new CorruptPartialSyncCursor({
2236
2355
  cursor: value,
2237
2356
  reason: "missing partial-sync-v1 prefix"
2238
2357
  }));
2239
2358
  try {
2240
2359
  const parsed = JSON.parse(value.slice(16));
2241
- if (isRecord$13(parsed) && validPartialSyncCursor(parsed)) return G.ok(parsed);
2242
- return G.err(new CorruptPartialSyncCursor({
2360
+ if (isRecord$13(parsed) && validPartialSyncCursor(parsed)) return ae.ok(parsed);
2361
+ return ae.err(new CorruptPartialSyncCursor({
2243
2362
  cursor: value,
2244
2363
  reason: "payload does not match the partial cursor shape"
2245
2364
  }));
2246
2365
  } catch (error) {
2247
- return G.err(new CorruptPartialSyncCursor({
2366
+ return ae.err(new CorruptPartialSyncCursor({
2248
2367
  cursor: value,
2249
2368
  reason: "payload is not valid JSON",
2250
2369
  cause: error
@@ -2252,12 +2371,12 @@ const parsePartialSyncCursor = (value) => {
2252
2371
  }
2253
2372
  };
2254
2373
  const readPartialSyncCursorResult = (value) => {
2255
- if (!value?.startsWith("partial-sync-v1:")) return G.ok(void 0);
2374
+ if (!value?.startsWith("partial-sync-v1:")) return ae.ok(void 0);
2256
2375
  return parsePartialSyncCursor(value);
2257
2376
  };
2258
2377
  const readPartialSyncCursor = (value) => {
2259
2378
  const parsed = readPartialSyncCursorResult(value);
2260
- return G.isError(parsed) ? void 0 : parsed.value;
2379
+ return ae.isError(parsed) ? void 0 : parsed.value;
2261
2380
  };
2262
2381
  const partialCursorMatchesSince = (cursor, since) => {
2263
2382
  const requestedSince = since ?? null;
@@ -2322,7 +2441,7 @@ const readUserVersion = (db) => {
2322
2441
  const setUserVersion = (db, version) => {
2323
2442
  db.exec(`PRAGMA user_version = ${version}`);
2324
2443
  };
2325
- var MissingMigration = class extends h("MissingMigration")() {
2444
+ var MissingMigration = class extends h("MissingMigration") {
2326
2445
  constructor(index) {
2327
2446
  super({
2328
2447
  index,
@@ -2330,7 +2449,7 @@ var MissingMigration = class extends h("MissingMigration")() {
2330
2449
  });
2331
2450
  }
2332
2451
  };
2333
- var StaleMigrationSchema = class extends h("StaleMigrationSchema")() {
2452
+ var StaleMigrationSchema = class extends h("StaleMigrationSchema") {
2334
2453
  constructor(currentVersion, finalVersion) {
2335
2454
  super({
2336
2455
  currentVersion,
@@ -2341,20 +2460,20 @@ var StaleMigrationSchema = class extends h("StaleMigrationSchema")() {
2341
2460
  };
2342
2461
  const migrateResult = (db) => {
2343
2462
  const currentVersion = readUserVersion(db);
2344
- if (currentVersion >= MIGRATIONS.length) return G.ok({
2463
+ if (currentVersion >= MIGRATIONS.length) return ae.ok({
2345
2464
  fromVersion: currentVersion,
2346
2465
  toVersion: currentVersion,
2347
2466
  applied: 0
2348
2467
  });
2349
2468
  for (let index = currentVersion; index < MIGRATIONS.length; index += 1) {
2350
2469
  const migration = MIGRATIONS[index];
2351
- if (!migration) return G.err(new MissingMigration(index));
2470
+ if (!migration) return ae.err(new MissingMigration(index));
2352
2471
  db.transaction(() => {
2353
2472
  db.exec(migration.sql);
2354
2473
  setUserVersion(db, index + 1);
2355
2474
  });
2356
2475
  }
2357
- return G.ok({
2476
+ return ae.ok({
2358
2477
  fromVersion: currentVersion,
2359
2478
  toVersion: MIGRATIONS.length,
2360
2479
  applied: MIGRATIONS.length - currentVersion
@@ -2363,8 +2482,8 @@ const migrateResult = (db) => {
2363
2482
  const migrate = (db) => migrateResult(db).unwrap();
2364
2483
  const assertAtLatestResult = (db) => {
2365
2484
  const currentVersion = readUserVersion(db);
2366
- if (currentVersion < MIGRATIONS.length) return G.err(new StaleMigrationSchema(currentVersion, MIGRATIONS.length));
2367
- return G.ok(void 0);
2485
+ if (currentVersion < MIGRATIONS.length) return ae.err(new StaleMigrationSchema(currentVersion, MIGRATIONS.length));
2486
+ return ae.ok(void 0);
2368
2487
  };
2369
2488
  const assertAtLatest = (db) => {
2370
2489
  assertAtLatestResult(db).unwrap();
@@ -2482,7 +2601,7 @@ const applyWriteThrough = (db, args) => {
2482
2601
  };
2483
2602
  //#endregion
2484
2603
  //#region ../../packages/sqlsync/src/cache.ts
2485
- var UnknownCacheTable = class extends h("UnknownCacheTable")() {
2604
+ var UnknownCacheTable = class extends h("UnknownCacheTable") {
2486
2605
  constructor(args) {
2487
2606
  super({
2488
2607
  table: args.table,
@@ -2490,7 +2609,7 @@ var UnknownCacheTable = class extends h("UnknownCacheTable")() {
2490
2609
  });
2491
2610
  }
2492
2611
  };
2493
- var ForbiddenCacheTableRead = class extends h("ForbiddenCacheTableRead")() {
2612
+ var ForbiddenCacheTableRead = class extends h("ForbiddenCacheTableRead") {
2494
2613
  constructor(args) {
2495
2614
  const tables = [...args.tables].sort();
2496
2615
  super({
@@ -2500,7 +2619,7 @@ var ForbiddenCacheTableRead = class extends h("ForbiddenCacheTableRead")() {
2500
2619
  });
2501
2620
  }
2502
2621
  };
2503
- var UnknownCachePlatform = class extends h("UnknownCachePlatform")() {
2622
+ var UnknownCachePlatform = class extends h("UnknownCachePlatform") {
2504
2623
  constructor(platform) {
2505
2624
  super({
2506
2625
  platform,
@@ -2513,40 +2632,40 @@ const resolveCachePath = (path) => path === ":memory:" ? path : resolve(path);
2513
2632
  const stringOrNull = (value) => typeof value === "string" ? value : null;
2514
2633
  const numberOrNull = (value) => typeof value === "number" ? value : null;
2515
2634
  const parseCachePlatform = (platform) => {
2516
- if (platform === "linkedin" || platform === "x") return G.ok(platform);
2517
- return G.err(new UnknownCachePlatform(platform));
2635
+ if (platform === "linkedin" || platform === "x") return ae.ok(platform);
2636
+ return ae.err(new UnknownCachePlatform(platform));
2518
2637
  };
2519
2638
  const requireCachePlatform = (platform) => {
2520
2639
  const parsed = parseCachePlatform(platform);
2521
- if (G.isError(parsed)) throw parsed.error;
2640
+ if (ae.isError(parsed)) throw parsed.error;
2522
2641
  return parsed.value;
2523
2642
  };
2524
2643
  const parseCacheTable = (table) => {
2525
- if (!cacheTableNames.has(table)) return G.err(new UnknownCacheTable({ table }));
2526
- return G.ok(table);
2644
+ if (!cacheTableNames.has(table)) return ae.err(new UnknownCacheTable({ table }));
2645
+ return ae.ok(table);
2527
2646
  };
2528
2647
  const requireCacheTable = (table) => {
2529
2648
  const parsed = parseCacheTable(table);
2530
- if (G.isError(parsed)) throw parsed.error;
2649
+ if (ae.isError(parsed)) throw parsed.error;
2531
2650
  return parsed.value;
2532
2651
  };
2533
2652
  const checkPlatformQuery = (sql, platform) => {
2534
2653
  const allowedTables = tablesForPlatform(platform);
2535
2654
  const rejectedTables = new Set(knownTableTokens(sql).filter((table) => !allowedTables.has(table)));
2536
- if (rejectedTables.size > 0) return G.err(new ForbiddenCacheTableRead({
2655
+ if (rejectedTables.size > 0) return ae.err(new ForbiddenCacheTableRead({
2537
2656
  platform,
2538
2657
  tables: rejectedTables
2539
2658
  }));
2540
- return G.ok();
2659
+ return ae.ok();
2541
2660
  };
2542
2661
  const assertPlatformQuery = (sql, platform) => {
2543
2662
  const checked = checkPlatformQuery(sql, platform);
2544
- if (G.isError(checked)) throw checked.error;
2663
+ if (ae.isError(checked)) throw checked.error;
2545
2664
  };
2546
2665
  const classifyCacheRead = (sql, platform) => {
2547
2666
  const checked = checkPlatformQuery(sql, platform);
2548
- if (G.isError(checked)) return G.err(checked.error);
2549
- return G.ok({ tables: referencedTablesForRead(sql, platform) });
2667
+ if (ae.isError(checked)) return ae.err(checked.error);
2668
+ return ae.ok({ tables: referencedTablesForRead(sql, platform) });
2550
2669
  };
2551
2670
  const unknownTableFromSQLiteError = (error) => {
2552
2671
  return (error instanceof Error ? error.message : String(error)).match(/\bno such table: ([^\s]+)/)?.[1]?.replace(/^["'`]|["'`]$/g, "");
@@ -2692,7 +2811,7 @@ const createCache = (path, db) => ({
2692
2811
  },
2693
2812
  read: (sql, opts) => {
2694
2813
  const classification = classifyCacheRead(sql, opts.platform);
2695
- if (G.isError(classification)) return G.err(classification.error);
2814
+ if (ae.isError(classification)) return ae.err(classification.error);
2696
2815
  const tables = classification.value.tables.map((name) => {
2697
2816
  const policy = freshnessPolicyForTable(name);
2698
2817
  return {
@@ -2705,10 +2824,10 @@ const createCache = (path, db) => ({
2705
2824
  rows = db.prepare(sql).all();
2706
2825
  } catch (error) {
2707
2826
  const table = unknownTableFromSQLiteError(error);
2708
- if (table) return G.err(new UnknownCacheTable({ table }));
2827
+ if (table) return ae.err(new UnknownCacheTable({ table }));
2709
2828
  throw error;
2710
2829
  }
2711
- return G.ok({
2830
+ return ae.ok({
2712
2831
  rows,
2713
2832
  tables
2714
2833
  });
@@ -3359,7 +3478,7 @@ const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9
3359
3478
  /** Returns a regex for validating an RFC 9562/4122 UUID.
3360
3479
  *
3361
3480
  * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
3362
- const uuid$1 = (version) => {
3481
+ const uuid$2 = (version) => {
3363
3482
  if (!version) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
3364
3483
  return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
3365
3484
  };
@@ -3929,8 +4048,8 @@ const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
3929
4048
  v8: 8
3930
4049
  }[def.version];
3931
4050
  if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
3932
- def.pattern ?? (def.pattern = uuid$1(v));
3933
- } else def.pattern ?? (def.pattern = uuid$1());
4051
+ def.pattern ?? (def.pattern = uuid$2(v));
4052
+ } else def.pattern ?? (def.pattern = uuid$2());
3934
4053
  $ZodStringFormat.init(inst, def);
3935
4054
  });
3936
4055
  const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
@@ -6758,6 +6877,9 @@ const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
6758
6877
  $ZodUUID.init(inst, def);
6759
6878
  ZodStringFormat.init(inst, def);
6760
6879
  });
6880
+ function uuid$1(params) {
6881
+ return /* @__PURE__ */ _uuid(ZodUUID, params);
6882
+ }
6761
6883
  const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
6762
6884
  $ZodURL.init(inst, def);
6763
6885
  ZodStringFormat.init(inst, def);
@@ -7494,7 +7616,7 @@ const planPagePersistence = (state, page, opts) => {
7494
7616
  const profileTableFor = (platform) => platform === "x" ? "x_profiles_raw" : "li_profiles_raw";
7495
7617
  //#endregion
7496
7618
  //#region ../../packages/sqlsync/src/sync-plan.ts
7497
- var SinceUnsupported = class extends h("SinceUnsupported")() {
7619
+ var SinceUnsupported = class extends h("SinceUnsupported") {
7498
7620
  constructor(collectionKey) {
7499
7621
  super({
7500
7622
  collectionKey,
@@ -7502,7 +7624,7 @@ var SinceUnsupported = class extends h("SinceUnsupported")() {
7502
7624
  });
7503
7625
  }
7504
7626
  };
7505
- var FullInitialSyncRequired = class extends h("FullInitialSyncRequired")() {
7627
+ var FullInitialSyncRequired = class extends h("FullInitialSyncRequired") {
7506
7628
  constructor(collectionKey) {
7507
7629
  super({
7508
7630
  collectionKey,
@@ -7510,7 +7632,7 @@ var FullInitialSyncRequired = class extends h("FullInitialSyncRequired")() {
7510
7632
  });
7511
7633
  }
7512
7634
  };
7513
- var MissingParentCollection = class extends h("MissingParentCollection")() {
7635
+ var MissingParentCollection = class extends h("MissingParentCollection") {
7514
7636
  constructor(collectionKey, parentCollectionKey) {
7515
7637
  super({
7516
7638
  collectionKey,
@@ -7519,7 +7641,7 @@ var MissingParentCollection = class extends h("MissingParentCollection")() {
7519
7641
  });
7520
7642
  }
7521
7643
  };
7522
- var InvalidPartialCursor = class extends h("InvalidPartialCursor")() {
7644
+ var InvalidPartialCursor = class extends h("InvalidPartialCursor") {
7523
7645
  constructor(collectionKey, cursor, cause) {
7524
7646
  super({
7525
7647
  collectionKey,
@@ -7531,19 +7653,19 @@ var InvalidPartialCursor = class extends h("InvalidPartialCursor")() {
7531
7653
  };
7532
7654
  const parseStoredPartialCursor = (collectionKey, cursor) => {
7533
7655
  const parsed = readPartialSyncCursorResult(cursor);
7534
- if (G.isError(parsed)) return G.err(new InvalidPartialCursor(collectionKey, cursor ?? "", parsed.error));
7535
- return G.ok(parsed.value);
7656
+ if (ae.isError(parsed)) return ae.err(new InvalidPartialCursor(collectionKey, cursor ?? "", parsed.error));
7657
+ return ae.ok(parsed.value);
7536
7658
  };
7537
7659
  const validateSyncOptions = (deps, opts) => {
7538
7660
  const { collection } = opts;
7539
- if (opts.since != null && collection.sinceField === void 0) return G.err(new SinceUnsupported(collection.key));
7661
+ if (opts.since != null && collection.sinceField === void 0) return ae.err(new SinceUnsupported(collection.key));
7540
7662
  const storedState = deps.cache.getCursor(collection.key);
7541
7663
  const storedPartialCursor = parseStoredPartialCursor(collection.key, storedState?.cursor);
7542
- if (G.isError(storedPartialCursor)) return G.err(storedPartialCursor.error);
7543
- if (opts.since != null && collection.requiresFullInitialSync && (storedState?.lastSynced == null || storedPartialCursor.value !== void 0)) return G.err(new FullInitialSyncRequired(collection.key));
7664
+ if (ae.isError(storedPartialCursor)) return ae.err(storedPartialCursor.error);
7665
+ if (opts.since != null && collection.requiresFullInitialSync && (storedState?.lastSynced == null || storedPartialCursor.value !== void 0)) return ae.err(new FullInitialSyncRequired(collection.key));
7544
7666
  const parentCollection = collection.parentCollection === void 0 ? void 0 : collectionByKey(collection.parentCollection);
7545
- if (collection.parentCollection && !parentCollection) return G.err(new MissingParentCollection(collection.key, collection.parentCollection));
7546
- return G.ok({
7667
+ if (collection.parentCollection && !parentCollection) return ae.err(new MissingParentCollection(collection.key, collection.parentCollection));
7668
+ return ae.ok({
7547
7669
  collection,
7548
7670
  since: opts.since,
7549
7671
  storedState,
@@ -7577,7 +7699,7 @@ const planCompletedCollectionCursor = (args) => ({
7577
7699
  //#region ../../packages/sqlsync/src/sync.ts
7578
7700
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
7579
7701
  const pageDelayFor = (pageDelayMs, pagesCompleted) => typeof pageDelayMs === "function" ? pageDelayMs(pagesCompleted) : pageDelayMs;
7580
- var UnsupportedSinceCollection = class extends h("UnsupportedSinceCollection")() {
7702
+ var UnsupportedSinceCollection = class extends h("UnsupportedSinceCollection") {
7581
7703
  constructor(collectionKey) {
7582
7704
  super({
7583
7705
  collectionKey,
@@ -7585,7 +7707,7 @@ var UnsupportedSinceCollection = class extends h("UnsupportedSinceCollection")()
7585
7707
  });
7586
7708
  }
7587
7709
  };
7588
- var InitialSyncRequired = class extends h("InitialSyncRequired")() {
7710
+ var InitialSyncRequired = class extends h("InitialSyncRequired") {
7589
7711
  constructor(collectionKey) {
7590
7712
  super({
7591
7713
  collectionKey,
@@ -7742,7 +7864,7 @@ const walkRequest = async (args) => {
7742
7864
  break;
7743
7865
  } catch (error) {
7744
7866
  if (await waitForRateLimit(error)) continue;
7745
- return G.err(pageError({
7867
+ return ae.err(pageError({
7746
7868
  ...pageContext,
7747
7869
  cursorPersisted: persistPartialCursor() || partialCursorPersisted || void 0
7748
7870
  }, error));
@@ -7753,7 +7875,7 @@ const walkRequest = async (args) => {
7753
7875
  try {
7754
7876
  json = await response.json();
7755
7877
  } catch (error) {
7756
- return G.err(pageError({
7878
+ return ae.err(pageError({
7757
7879
  ...pageContext,
7758
7880
  creditsSpent: args.credits.spent
7759
7881
  }, error));
@@ -7794,7 +7916,7 @@ const walkRequest = async (args) => {
7794
7916
  break;
7795
7917
  }
7796
7918
  }
7797
- return G.ok({
7919
+ return ae.ok({
7798
7920
  ids,
7799
7921
  newestId: state.newestId,
7800
7922
  pages,
@@ -7818,10 +7940,10 @@ const parentIdsFromCache = (deps, collection, since) => {
7818
7940
  };
7819
7941
  const runSync = async (deps, opts) => {
7820
7942
  const syncPlan = validateSyncOptions(deps, opts);
7821
- if (G.isError(syncPlan)) {
7822
- if (syncPlan.error instanceof SinceUnsupported) return G.err(new UnsupportedSinceCollection(syncPlan.error.collectionKey));
7823
- if (syncPlan.error instanceof FullInitialSyncRequired) return G.err(new InitialSyncRequired(syncPlan.error.collectionKey));
7824
- return G.err(syncPlan.error);
7943
+ if (ae.isError(syncPlan)) {
7944
+ if (syncPlan.error instanceof SinceUnsupported) return ae.err(new UnsupportedSinceCollection(syncPlan.error.collectionKey));
7945
+ if (syncPlan.error instanceof FullInitialSyncRequired) return ae.err(new InitialSyncRequired(syncPlan.error.collectionKey));
7946
+ return ae.err(syncPlan.error);
7825
7947
  }
7826
7948
  const { collection, parentCollection, storedPartialCursor } = syncPlan.value;
7827
7949
  const credits = { spent: 0 };
@@ -7846,7 +7968,7 @@ const runSync = async (deps, opts) => {
7846
7968
  deps.cache.setCursor(pending.collection, pending.cursor, pending.objectCount, pending.lastSynced);
7847
7969
  };
7848
7970
  if (collection.parentCollection) {
7849
- if (!parentCollection) return G.err(new MissingParentCollection(collection.key, collection.parentCollection));
7971
+ if (!parentCollection) return ae.err(new MissingParentCollection(collection.key, collection.parentCollection));
7850
7972
  let activePartialCursor = activeParentedPartialCursor({
7851
7973
  storedPartialCursor,
7852
7974
  since: opts.since
@@ -7886,7 +8008,7 @@ const runSync = async (deps, opts) => {
7886
8008
  onPage: opts.onPage,
7887
8009
  onProgress: opts.onProgress
7888
8010
  });
7889
- if (G.isError(result)) return G.err(result.error);
8011
+ if (ae.isError(result)) return ae.err(result.error);
7890
8012
  addResult(result.value);
7891
8013
  parentIds.push(...result.value.ids);
7892
8014
  if (parentPersistsCheckpoint) parentCheckpoint = singleRequestCheckpoint({
@@ -7933,7 +8055,7 @@ const runSync = async (deps, opts) => {
7933
8055
  onPage: opts.onPage,
7934
8056
  onProgress: opts.onProgress
7935
8057
  });
7936
- if (G.isError(result)) return G.err(result.error);
8058
+ if (ae.isError(result)) return ae.err(result.error);
7937
8059
  addResult(result.value);
7938
8060
  if (activePartialCursor?.phase === "child" && activePartialCursor.parentId === parentId) activePartialCursor = void 0;
7939
8061
  }
@@ -7971,7 +8093,7 @@ const runSync = async (deps, opts) => {
7971
8093
  onPage: opts.onPage,
7972
8094
  onProgress: opts.onProgress
7973
8095
  });
7974
- if (G.isError(result)) return G.err(result.error);
8096
+ if (ae.isError(result)) return ae.err(result.error);
7975
8097
  addResult(result.value);
7976
8098
  if (!preservesBroaderPartialOnSince(activePartialCursor, opts.since, result.value.stoppedReason) && useCheckpoint) pendingCursors.push(singleRequestCheckpoint({
7977
8099
  collection,
@@ -7984,7 +8106,7 @@ const runSync = async (deps, opts) => {
7984
8106
  })));
7985
8107
  }
7986
8108
  for (const pending of pendingCursors) writePendingCursor(pending);
7987
- return G.ok({
8109
+ return ae.ok({
7988
8110
  collection: collection.key,
7989
8111
  objectsUpserted: upserted,
7990
8112
  pages,
@@ -8411,14 +8533,14 @@ function renderDescription(arg, required) {
8411
8533
  }
8412
8534
  //#endregion
8413
8535
  //#region ../../packages/billing/src/pricing.ts
8414
- var UnknownPricingCategory = class extends h("pricing_category_unknown")() {};
8536
+ var UnknownPricingCategory = class extends h("pricing_category_unknown") {};
8415
8537
  const lookupCostBPSForCategoryResult = (table, category) => {
8416
8538
  const costBPS = table.get(category);
8417
- if (costBPS === void 0) return G.err(new UnknownPricingCategory({
8539
+ if (costBPS === void 0) return ae.err(new UnknownPricingCategory({
8418
8540
  category,
8419
8541
  message: `Unknown pricing category: ${category}`
8420
8542
  }));
8421
- return G.ok(costBPS);
8543
+ return ae.ok(costBPS);
8422
8544
  };
8423
8545
  const createPricing = (resources) => {
8424
8546
  const table = new Map(resources.map((resource) => [resource.key, Math.round(resource.unitPriceUSD * 1e4)]));
@@ -8541,7 +8663,7 @@ const costBPSForCategory$1 = (category) => {
8541
8663
  return costBPS.value;
8542
8664
  };
8543
8665
  //#endregion
8544
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/entity.js
8666
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/entity.js
8545
8667
  const entityKind = Symbol.for("drizzle:entityKind");
8546
8668
  function is(value, type) {
8547
8669
  if (!value || typeof value !== "object") return false;
@@ -8555,7 +8677,7 @@ function is(value, type) {
8555
8677
  return false;
8556
8678
  }
8557
8679
  //#endregion
8558
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/column.js
8680
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/column.js
8559
8681
  var Column = class {
8560
8682
  constructor(table, config) {
8561
8683
  this.table = table;
@@ -8605,7 +8727,7 @@ var Column = class {
8605
8727
  }
8606
8728
  };
8607
8729
  //#endregion
8608
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/column-builder.js
8730
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/column-builder.js
8609
8731
  var ColumnBuilder = class {
8610
8732
  static [entityKind] = "ColumnBuilder";
8611
8733
  config;
@@ -8708,10 +8830,10 @@ var ColumnBuilder = class {
8708
8830
  }
8709
8831
  };
8710
8832
  //#endregion
8711
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/table.utils.js
8833
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/table.utils.js
8712
8834
  const TableName = Symbol.for("drizzle:Name");
8713
8835
  //#endregion
8714
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/foreign-keys.js
8836
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/foreign-keys.js
8715
8837
  var ForeignKeyBuilder = class {
8716
8838
  static [entityKind] = "PgForeignKeyBuilder";
8717
8839
  /** @internal */
@@ -8784,17 +8906,17 @@ function foreignKey(config) {
8784
8906
  return new ForeignKeyBuilder(mappedConfig);
8785
8907
  }
8786
8908
  //#endregion
8787
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/tracing-utils.js
8909
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/tracing-utils.js
8788
8910
  function iife(fn, ...args) {
8789
8911
  return fn(...args);
8790
8912
  }
8791
8913
  //#endregion
8792
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/unique-constraint.js
8914
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/unique-constraint.js
8793
8915
  function uniqueKeyName(table, columns) {
8794
8916
  return `${table[TableName]}_${columns.join("_")}_unique`;
8795
8917
  }
8796
8918
  //#endregion
8797
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/utils/array.js
8919
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/utils/array.js
8798
8920
  function parsePgArrayValue(arrayString, startFrom, inQuotes) {
8799
8921
  for (let i = startFrom; i < arrayString.length; i++) {
8800
8922
  const char = arrayString[i];
@@ -8856,7 +8978,7 @@ function makePgArray(array) {
8856
8978
  }).join(",")}}`;
8857
8979
  }
8858
8980
  //#endregion
8859
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/common.js
8981
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/common.js
8860
8982
  var PgColumnBuilder = class extends ColumnBuilder {
8861
8983
  foreignKeyConfigs = [];
8862
8984
  static [entityKind] = "PgColumnBuilder";
@@ -9028,35 +9150,36 @@ var PgArray = class PgArray extends PgColumn {
9028
9150
  }
9029
9151
  };
9030
9152
  //#endregion
9031
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/enum.js
9153
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/enum.js
9032
9154
  const isPgEnumSym = Symbol.for("drizzle:isPgEnum");
9033
9155
  function isPgEnum(obj) {
9034
9156
  return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
9035
9157
  }
9036
9158
  //#endregion
9037
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/subquery.js
9159
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/subquery.js
9038
9160
  var Subquery = class {
9039
9161
  static [entityKind] = "Subquery";
9040
- constructor(sql, selection, alias, isWith = false) {
9162
+ constructor(sql, fields, alias, isWith = false, usedTables = []) {
9041
9163
  this._ = {
9042
9164
  brand: "Subquery",
9043
9165
  sql,
9044
- selectedFields: selection,
9166
+ selectedFields: fields,
9045
9167
  alias,
9046
- isWith
9168
+ isWith,
9169
+ usedTables
9047
9170
  };
9048
9171
  }
9049
9172
  };
9050
9173
  //#endregion
9051
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/tracing.js
9174
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/tracing.js
9052
9175
  const tracer = { startActiveSpan(name, fn) {
9053
9176
  return fn();
9054
9177
  } };
9055
9178
  //#endregion
9056
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/view-common.js
9179
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/view-common.js
9057
9180
  const ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
9058
9181
  //#endregion
9059
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/table.js
9182
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/table.js
9060
9183
  const Schema = Symbol.for("drizzle:Schema");
9061
9184
  const Columns = Symbol.for("drizzle:Columns");
9062
9185
  const ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
@@ -9112,7 +9235,7 @@ var Table = class {
9112
9235
  }
9113
9236
  };
9114
9237
  //#endregion
9115
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/sql/sql.js
9238
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/sql/sql.js
9116
9239
  function isSQLWrapper(value) {
9117
9240
  return value !== null && value !== void 0 && typeof value.getSQL === "function";
9118
9241
  }
@@ -9144,11 +9267,17 @@ var StringChunk = class {
9144
9267
  var SQL = class SQL {
9145
9268
  constructor(queryChunks) {
9146
9269
  this.queryChunks = queryChunks;
9270
+ for (const chunk of queryChunks) if (is(chunk, Table)) {
9271
+ const schemaName = chunk[Table.Symbol.Schema];
9272
+ this.usedTables.push(schemaName === void 0 ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]);
9273
+ }
9147
9274
  }
9148
9275
  static [entityKind] = "SQL";
9149
9276
  /** @internal */
9150
9277
  decoder = noopDecoder;
9151
9278
  shouldInlineParams = false;
9279
+ /** @internal */
9280
+ usedTables = [];
9152
9281
  append(query) {
9153
9282
  this.queryChunks.push(...query.queryChunks);
9154
9283
  return this;
@@ -9461,15 +9590,16 @@ Subquery.prototype.getSQL = function() {
9461
9590
  return new SQL([this]);
9462
9591
  };
9463
9592
  //#endregion
9464
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/utils.js
9593
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/utils.js
9465
9594
  function getColumnNameAndConfig(a, b) {
9466
9595
  return {
9467
9596
  name: typeof a === "string" && a.length > 0 ? a : "",
9468
9597
  config: typeof a === "object" ? a : b
9469
9598
  };
9470
9599
  }
9600
+ typeof TextDecoder === "undefined" || new TextDecoder();
9471
9601
  //#endregion
9472
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/int.common.js
9602
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/int.common.js
9473
9603
  var PgIntColumnBaseBuilder = class extends PgColumnBuilder {
9474
9604
  static [entityKind] = "PgIntColumnBaseBuilder";
9475
9605
  generatedAlwaysAsIdentity(sequence) {
@@ -9500,7 +9630,7 @@ var PgIntColumnBaseBuilder = class extends PgColumnBuilder {
9500
9630
  }
9501
9631
  };
9502
9632
  //#endregion
9503
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/bigint.js
9633
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/bigint.js
9504
9634
  var PgBigInt53Builder = class extends PgIntColumnBaseBuilder {
9505
9635
  static [entityKind] = "PgBigInt53Builder";
9506
9636
  constructor(name) {
@@ -9546,7 +9676,7 @@ function bigint(a, b) {
9546
9676
  return new PgBigInt64Builder(name);
9547
9677
  }
9548
9678
  //#endregion
9549
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/bigserial.js
9679
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/bigserial.js
9550
9680
  var PgBigSerial53Builder = class extends PgColumnBuilder {
9551
9681
  static [entityKind] = "PgBigSerial53Builder";
9552
9682
  constructor(name) {
@@ -9595,7 +9725,7 @@ function bigserial(a, b) {
9595
9725
  return new PgBigSerial64Builder(name);
9596
9726
  }
9597
9727
  //#endregion
9598
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/boolean.js
9728
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/boolean.js
9599
9729
  var PgBooleanBuilder = class extends PgColumnBuilder {
9600
9730
  static [entityKind] = "PgBooleanBuilder";
9601
9731
  constructor(name) {
@@ -9616,7 +9746,7 @@ function boolean(name) {
9616
9746
  return new PgBooleanBuilder(name ?? "");
9617
9747
  }
9618
9748
  //#endregion
9619
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/char.js
9749
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/char.js
9620
9750
  var PgCharBuilder = class extends PgColumnBuilder {
9621
9751
  static [entityKind] = "PgCharBuilder";
9622
9752
  constructor(name, config) {
@@ -9642,7 +9772,7 @@ function char(a, b = {}) {
9642
9772
  return new PgCharBuilder(name, config);
9643
9773
  }
9644
9774
  //#endregion
9645
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/cidr.js
9775
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/cidr.js
9646
9776
  var PgCidrBuilder = class extends PgColumnBuilder {
9647
9777
  static [entityKind] = "PgCidrBuilder";
9648
9778
  constructor(name) {
@@ -9663,7 +9793,7 @@ function cidr(name) {
9663
9793
  return new PgCidrBuilder(name ?? "");
9664
9794
  }
9665
9795
  //#endregion
9666
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/custom.js
9796
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/custom.js
9667
9797
  var PgCustomColumnBuilder = class extends PgColumnBuilder {
9668
9798
  static [entityKind] = "PgCustomColumnBuilder";
9669
9799
  constructor(name, fieldConfig, customTypeParams) {
@@ -9704,7 +9834,7 @@ function customType(customTypeParams) {
9704
9834
  };
9705
9835
  }
9706
9836
  //#endregion
9707
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/date.common.js
9837
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/date.common.js
9708
9838
  var PgDateColumnBaseBuilder = class extends PgColumnBuilder {
9709
9839
  static [entityKind] = "PgDateColumnBaseBuilder";
9710
9840
  defaultNow() {
@@ -9712,7 +9842,7 @@ var PgDateColumnBaseBuilder = class extends PgColumnBuilder {
9712
9842
  }
9713
9843
  };
9714
9844
  //#endregion
9715
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/date.js
9845
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/date.js
9716
9846
  var PgDateBuilder = class extends PgDateColumnBaseBuilder {
9717
9847
  static [entityKind] = "PgDateBuilder";
9718
9848
  constructor(name) {
@@ -9729,7 +9859,8 @@ var PgDate = class extends PgColumn {
9729
9859
  return "date";
9730
9860
  }
9731
9861
  mapFromDriverValue(value) {
9732
- return new Date(value);
9862
+ if (typeof value === "string") return new Date(value);
9863
+ return value;
9733
9864
  }
9734
9865
  mapToDriverValue(value) {
9735
9866
  return value.toISOString();
@@ -9750,6 +9881,10 @@ var PgDateString = class extends PgColumn {
9750
9881
  getSQLType() {
9751
9882
  return "date";
9752
9883
  }
9884
+ mapFromDriverValue(value) {
9885
+ if (typeof value === "string") return value;
9886
+ return value.toISOString().slice(0, -14);
9887
+ }
9753
9888
  };
9754
9889
  function date(a, b) {
9755
9890
  const { name, config } = getColumnNameAndConfig(a, b);
@@ -9757,7 +9892,7 @@ function date(a, b) {
9757
9892
  return new PgDateStringBuilder(name);
9758
9893
  }
9759
9894
  //#endregion
9760
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/double-precision.js
9895
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/double-precision.js
9761
9896
  var PgDoublePrecisionBuilder = class extends PgColumnBuilder {
9762
9897
  static [entityKind] = "PgDoublePrecisionBuilder";
9763
9898
  constructor(name) {
@@ -9782,7 +9917,7 @@ function doublePrecision(name) {
9782
9917
  return new PgDoublePrecisionBuilder(name ?? "");
9783
9918
  }
9784
9919
  //#endregion
9785
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/inet.js
9920
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/inet.js
9786
9921
  var PgInetBuilder = class extends PgColumnBuilder {
9787
9922
  static [entityKind] = "PgInetBuilder";
9788
9923
  constructor(name) {
@@ -9803,7 +9938,7 @@ function inet(name) {
9803
9938
  return new PgInetBuilder(name ?? "");
9804
9939
  }
9805
9940
  //#endregion
9806
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/integer.js
9941
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/integer.js
9807
9942
  var PgIntegerBuilder = class extends PgIntColumnBaseBuilder {
9808
9943
  static [entityKind] = "PgIntegerBuilder";
9809
9944
  constructor(name) {
@@ -9828,7 +9963,7 @@ function integer(name) {
9828
9963
  return new PgIntegerBuilder(name ?? "");
9829
9964
  }
9830
9965
  //#endregion
9831
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/interval.js
9966
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/interval.js
9832
9967
  var PgIntervalBuilder = class extends PgColumnBuilder {
9833
9968
  static [entityKind] = "PgIntervalBuilder";
9834
9969
  constructor(name, intervalConfig) {
@@ -9853,7 +9988,7 @@ function interval(a, b = {}) {
9853
9988
  return new PgIntervalBuilder(name, config);
9854
9989
  }
9855
9990
  //#endregion
9856
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/json.js
9991
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/json.js
9857
9992
  var PgJsonBuilder = class extends PgColumnBuilder {
9858
9993
  static [entityKind] = "PgJsonBuilder";
9859
9994
  constructor(name) {
@@ -9888,7 +10023,7 @@ function json(name) {
9888
10023
  return new PgJsonBuilder(name ?? "");
9889
10024
  }
9890
10025
  //#endregion
9891
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/jsonb.js
10026
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/jsonb.js
9892
10027
  var PgJsonbBuilder = class extends PgColumnBuilder {
9893
10028
  static [entityKind] = "PgJsonbBuilder";
9894
10029
  constructor(name) {
@@ -9923,7 +10058,7 @@ function jsonb(name) {
9923
10058
  return new PgJsonbBuilder(name ?? "");
9924
10059
  }
9925
10060
  //#endregion
9926
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/line.js
10061
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/line.js
9927
10062
  var PgLineBuilder = class extends PgColumnBuilder {
9928
10063
  static [entityKind] = "PgLineBuilder";
9929
10064
  constructor(name) {
@@ -9984,7 +10119,7 @@ function line(a, b) {
9984
10119
  return new PgLineABCBuilder(name);
9985
10120
  }
9986
10121
  //#endregion
9987
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/macaddr.js
10122
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/macaddr.js
9988
10123
  var PgMacaddrBuilder = class extends PgColumnBuilder {
9989
10124
  static [entityKind] = "PgMacaddrBuilder";
9990
10125
  constructor(name) {
@@ -10005,7 +10140,7 @@ function macaddr(name) {
10005
10140
  return new PgMacaddrBuilder(name ?? "");
10006
10141
  }
10007
10142
  //#endregion
10008
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/macaddr8.js
10143
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/macaddr8.js
10009
10144
  var PgMacaddr8Builder = class extends PgColumnBuilder {
10010
10145
  static [entityKind] = "PgMacaddr8Builder";
10011
10146
  constructor(name) {
@@ -10026,7 +10161,7 @@ function macaddr8(name) {
10026
10161
  return new PgMacaddr8Builder(name ?? "");
10027
10162
  }
10028
10163
  //#endregion
10029
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/numeric.js
10164
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/numeric.js
10030
10165
  var PgNumericBuilder = class extends PgColumnBuilder {
10031
10166
  static [entityKind] = "PgNumericBuilder";
10032
10167
  constructor(name, precision, scale) {
@@ -10125,7 +10260,7 @@ function numeric(a, b) {
10125
10260
  return mode === "number" ? new PgNumericNumberBuilder(name, config?.precision, config?.scale) : mode === "bigint" ? new PgNumericBigIntBuilder(name, config?.precision, config?.scale) : new PgNumericBuilder(name, config?.precision, config?.scale);
10126
10261
  }
10127
10262
  //#endregion
10128
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/point.js
10263
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/point.js
10129
10264
  var PgPointTupleBuilder = class extends PgColumnBuilder {
10130
10265
  static [entityKind] = "PgPointTupleBuilder";
10131
10266
  constructor(name) {
@@ -10187,7 +10322,7 @@ function point(a, b) {
10187
10322
  return new PgPointObjectBuilder(name);
10188
10323
  }
10189
10324
  //#endregion
10190
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/postgis_extension/utils.js
10325
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/postgis_extension/utils.js
10191
10326
  function hexToBytes(hex) {
10192
10327
  const bytes = [];
10193
10328
  for (let c = 0; c < hex.length; c += 2) bytes.push(Number.parseInt(hex.slice(c, c + 2), 16));
@@ -10220,7 +10355,7 @@ function parseEWKB(hex) {
10220
10355
  throw new Error("Unsupported geometry type");
10221
10356
  }
10222
10357
  //#endregion
10223
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/postgis_extension/geometry.js
10358
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/postgis_extension/geometry.js
10224
10359
  var PgGeometryBuilder = class extends PgColumnBuilder {
10225
10360
  static [entityKind] = "PgGeometryBuilder";
10226
10361
  constructor(name) {
@@ -10275,7 +10410,7 @@ function geometry(a, b) {
10275
10410
  return new PgGeometryObjectBuilder(name);
10276
10411
  }
10277
10412
  //#endregion
10278
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/real.js
10413
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/real.js
10279
10414
  var PgRealBuilder = class extends PgColumnBuilder {
10280
10415
  static [entityKind] = "PgRealBuilder";
10281
10416
  constructor(name, length) {
@@ -10304,7 +10439,7 @@ function real(name) {
10304
10439
  return new PgRealBuilder(name ?? "");
10305
10440
  }
10306
10441
  //#endregion
10307
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/serial.js
10442
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/serial.js
10308
10443
  var PgSerialBuilder = class extends PgColumnBuilder {
10309
10444
  static [entityKind] = "PgSerialBuilder";
10310
10445
  constructor(name) {
@@ -10327,7 +10462,7 @@ function serial(name) {
10327
10462
  return new PgSerialBuilder(name ?? "");
10328
10463
  }
10329
10464
  //#endregion
10330
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/smallint.js
10465
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/smallint.js
10331
10466
  var PgSmallIntBuilder = class extends PgIntColumnBaseBuilder {
10332
10467
  static [entityKind] = "PgSmallIntBuilder";
10333
10468
  constructor(name) {
@@ -10352,7 +10487,7 @@ function smallint(name) {
10352
10487
  return new PgSmallIntBuilder(name ?? "");
10353
10488
  }
10354
10489
  //#endregion
10355
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/smallserial.js
10490
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/smallserial.js
10356
10491
  var PgSmallSerialBuilder = class extends PgColumnBuilder {
10357
10492
  static [entityKind] = "PgSmallSerialBuilder";
10358
10493
  constructor(name) {
@@ -10375,7 +10510,7 @@ function smallserial(name) {
10375
10510
  return new PgSmallSerialBuilder(name ?? "");
10376
10511
  }
10377
10512
  //#endregion
10378
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/text.js
10513
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/text.js
10379
10514
  var PgTextBuilder = class extends PgColumnBuilder {
10380
10515
  static [entityKind] = "PgTextBuilder";
10381
10516
  constructor(name, config) {
@@ -10399,7 +10534,7 @@ function text$1(a, b = {}) {
10399
10534
  return new PgTextBuilder(name, config);
10400
10535
  }
10401
10536
  //#endregion
10402
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/time.js
10537
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/time.js
10403
10538
  var PgTimeBuilder = class extends PgDateColumnBaseBuilder {
10404
10539
  constructor(name, withTimezone, precision) {
10405
10540
  super(name, "string", "PgTime");
@@ -10432,7 +10567,7 @@ function time(a, b = {}) {
10432
10567
  return new PgTimeBuilder(name, config.withTimezone ?? false, config.precision);
10433
10568
  }
10434
10569
  //#endregion
10435
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/timestamp.js
10570
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/timestamp.js
10436
10571
  var PgTimestampBuilder = class extends PgDateColumnBaseBuilder {
10437
10572
  static [entityKind] = "PgTimestampBuilder";
10438
10573
  constructor(name, withTimezone, precision) {
@@ -10457,9 +10592,10 @@ var PgTimestamp = class extends PgColumn {
10457
10592
  getSQLType() {
10458
10593
  return `timestamp${this.precision === void 0 ? "" : ` (${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
10459
10594
  }
10460
- mapFromDriverValue = (value) => {
10461
- return new Date(this.withTimezone ? value : value + "+0000");
10462
- };
10595
+ mapFromDriverValue(value) {
10596
+ if (typeof value === "string") return new Date(this.withTimezone ? value : value + "+0000");
10597
+ return value;
10598
+ }
10463
10599
  mapToDriverValue = (value) => {
10464
10600
  return value.toISOString();
10465
10601
  };
@@ -10488,6 +10624,15 @@ var PgTimestampString = class extends PgColumn {
10488
10624
  getSQLType() {
10489
10625
  return `timestamp${this.precision === void 0 ? "" : `(${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
10490
10626
  }
10627
+ mapFromDriverValue(value) {
10628
+ if (typeof value === "string") return value;
10629
+ const shortened = value.toISOString().slice(0, -1).replace("T", " ");
10630
+ if (this.withTimezone) {
10631
+ const offset = value.getTimezoneOffset();
10632
+ return `${shortened}${offset <= 0 ? "+" : "-"}${Math.floor(Math.abs(offset) / 60).toString().padStart(2, "0")}`;
10633
+ }
10634
+ return shortened;
10635
+ }
10491
10636
  };
10492
10637
  function timestamp(a, b = {}) {
10493
10638
  const { name, config } = getColumnNameAndConfig(a, b);
@@ -10495,7 +10640,7 @@ function timestamp(a, b = {}) {
10495
10640
  return new PgTimestampBuilder(name, config?.withTimezone ?? false, config?.precision);
10496
10641
  }
10497
10642
  //#endregion
10498
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/uuid.js
10643
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/uuid.js
10499
10644
  var PgUUIDBuilder = class extends PgColumnBuilder {
10500
10645
  static [entityKind] = "PgUUIDBuilder";
10501
10646
  constructor(name) {
@@ -10522,7 +10667,7 @@ function uuid(name) {
10522
10667
  return new PgUUIDBuilder(name ?? "");
10523
10668
  }
10524
10669
  //#endregion
10525
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/varchar.js
10670
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/varchar.js
10526
10671
  var PgVarcharBuilder = class extends PgColumnBuilder {
10527
10672
  static [entityKind] = "PgVarcharBuilder";
10528
10673
  constructor(name, config) {
@@ -10548,7 +10693,7 @@ function varchar(a, b = {}) {
10548
10693
  return new PgVarcharBuilder(name, config);
10549
10694
  }
10550
10695
  //#endregion
10551
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/vector_extension/bit.js
10696
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/vector_extension/bit.js
10552
10697
  var PgBinaryVectorBuilder = class extends PgColumnBuilder {
10553
10698
  static [entityKind] = "PgBinaryVectorBuilder";
10554
10699
  constructor(name, config) {
@@ -10572,7 +10717,7 @@ function bit(a, b) {
10572
10717
  return new PgBinaryVectorBuilder(name, config);
10573
10718
  }
10574
10719
  //#endregion
10575
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/vector_extension/halfvec.js
10720
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/vector_extension/halfvec.js
10576
10721
  var PgHalfVectorBuilder = class extends PgColumnBuilder {
10577
10722
  static [entityKind] = "PgHalfVectorBuilder";
10578
10723
  constructor(name, config) {
@@ -10602,7 +10747,7 @@ function halfvec(a, b) {
10602
10747
  return new PgHalfVectorBuilder(name, config);
10603
10748
  }
10604
10749
  //#endregion
10605
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/vector_extension/sparsevec.js
10750
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/vector_extension/sparsevec.js
10606
10751
  var PgSparseVectorBuilder = class extends PgColumnBuilder {
10607
10752
  static [entityKind] = "PgSparseVectorBuilder";
10608
10753
  constructor(name, config) {
@@ -10626,7 +10771,7 @@ function sparsevec(a, b) {
10626
10771
  return new PgSparseVectorBuilder(name, config);
10627
10772
  }
10628
10773
  //#endregion
10629
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/vector_extension/vector.js
10774
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/vector_extension/vector.js
10630
10775
  var PgVectorBuilder = class extends PgColumnBuilder {
10631
10776
  static [entityKind] = "PgVectorBuilder";
10632
10777
  constructor(name, config) {
@@ -10656,7 +10801,7 @@ function vector(a, b) {
10656
10801
  return new PgVectorBuilder(name, config);
10657
10802
  }
10658
10803
  //#endregion
10659
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/columns/all.js
10804
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/columns/all.js
10660
10805
  function getPgColumnBuilders() {
10661
10806
  return {
10662
10807
  bigint,
@@ -10694,7 +10839,7 @@ function getPgColumnBuilders() {
10694
10839
  };
10695
10840
  }
10696
10841
  //#endregion
10697
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/table.js
10842
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/table.js
10698
10843
  const InlineForeignKeys = Symbol.for("drizzle:PgInlineForeignKeys");
10699
10844
  const EnableRLS = Symbol.for("drizzle:EnableRLS");
10700
10845
  var PgTable = class extends Table {
@@ -10741,7 +10886,7 @@ const pgTable = (name, columns, extraConfig) => {
10741
10886
  return pgTableWithSchema(name, columns, extraConfig, void 0);
10742
10887
  };
10743
10888
  //#endregion
10744
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/primary-keys.js
10889
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/primary-keys.js
10745
10890
  function primaryKey(...config) {
10746
10891
  if (config[0].columns) return new PrimaryKeyBuilder(config[0].columns, config[0].name);
10747
10892
  return new PrimaryKeyBuilder(config);
@@ -10775,7 +10920,7 @@ var PrimaryKey = class {
10775
10920
  }
10776
10921
  };
10777
10922
  //#endregion
10778
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/checks.js
10923
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/checks.js
10779
10924
  var CheckBuilder = class {
10780
10925
  constructor(name, value) {
10781
10926
  this.name = name;
@@ -10802,7 +10947,7 @@ function check(name, value) {
10802
10947
  return new CheckBuilder(name, value);
10803
10948
  }
10804
10949
  //#endregion
10805
- //#region ../../node_modules/.bun/drizzle-orm@0.43.1+b353dece7074011f/node_modules/drizzle-orm/pg-core/indexes.js
10950
+ //#region ../../node_modules/.bun/drizzle-orm@0.45.2+68d1edb702579b07/node_modules/drizzle-orm/pg-core/indexes.js
10806
10951
  var IndexBuilderOn = class {
10807
10952
  constructor(unique, name) {
10808
10953
  this.unique = unique;
@@ -10904,6 +11049,14 @@ const CONNECTED_ACCOUNT_STATUSES = [
10904
11049
  "disconnected",
10905
11050
  "error"
10906
11051
  ];
11052
+ const ACCOUNT_CONNECT_ATTEMPT_LANES = ["provider", "legacy"];
11053
+ const ACCOUNT_CONNECT_ATTEMPT_STATUSES = [
11054
+ "pending_billing",
11055
+ "pending_approval",
11056
+ "connected",
11057
+ "expired",
11058
+ "failed"
11059
+ ];
10907
11060
  const PROXY_SURFACES = [
10908
11061
  "cli",
10909
11062
  "mcp",
@@ -10960,6 +11113,8 @@ const WEBHOOK_OPERATION_STATES = [
10960
11113
  ];
10961
11114
  _enum(PLATFORMS);
10962
11115
  _enum(CONNECTED_ACCOUNT_STATUSES);
11116
+ _enum(ACCOUNT_CONNECT_ATTEMPT_LANES);
11117
+ _enum(ACCOUNT_CONNECT_ATTEMPT_STATUSES);
10963
11118
  _enum(PROXY_SURFACES);
10964
11119
  _enum(PROXY_CACHE_STATUSES);
10965
11120
  _enum(PROXY_CAPABILITIES);
@@ -10973,8 +11128,6 @@ _enum(WEBHOOK_OPERATION_KINDS);
10973
11128
  _enum(WEBHOOK_OPERATION_STATES);
10974
11129
  string().trim().min(1).transform((email) => email.toLowerCase()).brand();
10975
11130
  union([number(), string().trim().min(1)]).transform((value) => Number(value)).pipe(number().int().nonnegative()).brand();
10976
- h("InvalidBillingOverrideEmail")();
10977
- h("InvalidNonnegativeAllowance")();
10978
11131
  const sqlStringLiteral = (value) => `'${value.replaceAll("'", "''")}'`;
10979
11132
  const sqlStringList = (values) => sql.raw(values.map(sqlStringLiteral).join(", "));
10980
11133
  const sqlCheckIn = (column, values) => sql`${column} in (${sqlStringList(values)})`;
@@ -11153,6 +11306,33 @@ const connectedAccounts = pgTable("connected_accounts", {
11153
11306
  check("connected_accounts_platform_check", sqlCheckIn(table.platform, PLATFORMS)),
11154
11307
  check("connected_accounts_status_check", sqlCheckIn(table.status, CONNECTED_ACCOUNT_STATUSES))
11155
11308
  ]);
11309
+ pgTable("account_connect_attempts", {
11310
+ id: text$1("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
11311
+ userId: text$1("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
11312
+ platform: text$1("platform", { enum: PLATFORMS }).notNull(),
11313
+ lane: text$1("lane", { enum: ACCOUNT_CONNECT_ATTEMPT_LANES }).notNull(),
11314
+ targetPaidSeats: integer("target_paid_seats").notNull(),
11315
+ status: text$1("status", { enum: ACCOUNT_CONNECT_ATTEMPT_STATUSES }).notNull().default("pending_billing"),
11316
+ connectedAccountId: text$1("connected_account_id").references(() => connectedAccounts.id, { onDelete: "set null" }),
11317
+ operationKey: text$1("operation_key").notNull(),
11318
+ billingPaymentURL: text$1("billing_payment_url"),
11319
+ billingRequiredAction: jsonb("billing_required_action").$type(),
11320
+ hostedAuthBindingId: text$1("hosted_auth_binding_id"),
11321
+ hostedAuthAccountId: text$1("hosted_auth_account_id"),
11322
+ hostedAuthBoundAt: timestamptz("hosted_auth_bound_at"),
11323
+ expiresAt: timestamptz("expires_at").notNull(),
11324
+ createdAt: timestamptz("created_at").notNull().defaultNow(),
11325
+ updatedAt: timestamptz("updated_at").notNull().defaultNow().$onUpdate(() => /* @__PURE__ */ new Date())
11326
+ }, (table) => [
11327
+ uniqueIndex("account_connect_attempts_operation_key_key").on(table.operationKey),
11328
+ uniqueIndex("account_connect_attempts_hosted_auth_binding_id_key").on(table.hostedAuthBindingId),
11329
+ uniqueIndex("account_connect_attempts_active_user_platform_key").on(table.userId, table.platform).where(sql`${table.status} in ('pending_billing', 'pending_approval')`),
11330
+ index("account_connect_attempts_expiry_idx").on(table.expiresAt).where(sql`${table.status} in ('pending_billing', 'pending_approval')`),
11331
+ check("account_connect_attempts_platform_check", sqlCheckIn(table.platform, PLATFORMS)),
11332
+ check("account_connect_attempts_lane_check", sqlCheckIn(table.lane, ACCOUNT_CONNECT_ATTEMPT_LANES)),
11333
+ check("account_connect_attempts_status_check", sqlCheckIn(table.status, ACCOUNT_CONNECT_ATTEMPT_STATUSES)),
11334
+ check("account_connect_attempts_target_paid_seats_check", sql`${table.targetPaidSeats} >= 0`)
11335
+ ]);
11156
11336
  pgTable("account_defaults", {
11157
11337
  userId: text$1("user_id").notNull(),
11158
11338
  platform: text$1("platform", { enum: PLATFORMS }).notNull(),
@@ -11367,8 +11547,6 @@ pgTable("linkedin_connections", {
11367
11547
  connectedAt: timestamptz("connected_at"),
11368
11548
  createdAt: timestamptz("created_at").notNull().defaultNow()
11369
11549
  }, (table) => [uniqueIndex("linkedin_connections_of_profile_key").on(table.ofProfileId, table.profileId), index("linkedin_connections_profile_idx").on(table.profileId)]);
11370
- h("ProfileStoreUnavailable")();
11371
- h("InvalidProfileRow")();
11372
11550
  //#endregion
11373
11551
  //#region ../../packages/lib/src/url.ts
11374
11552
  const stripTrailingSlashes = (value) => value.replace(/\/+$/, "");
@@ -11379,7 +11557,7 @@ const absoluteURLPathPattern = /^[a-z][a-z0-9+.-]*:/i;
11379
11557
  const protocolRelativeURLPathPattern = /^\/\//;
11380
11558
  const unsafeRelativeURLPathMessage = "createURL: path must be relative, not absolute or protocol-relative";
11381
11559
  /** Returned when a URL path is absolute or protocol-relative instead of relative. */
11382
- var InvalidRelativeURLPath = class extends h("InvalidRelativeURLPath")() {
11560
+ var InvalidRelativeURLPath = class extends h("InvalidRelativeURLPath") {
11383
11561
  constructor({ path }) {
11384
11562
  super({
11385
11563
  path,
@@ -11387,7 +11565,7 @@ var InvalidRelativeURLPath = class extends h("InvalidRelativeURLPath")() {
11387
11565
  });
11388
11566
  }
11389
11567
  };
11390
- var InvalidBaseURL = class extends h("InvalidBaseURL")() {
11568
+ var InvalidBaseURL = class extends h("InvalidBaseURL") {
11391
11569
  constructor({ baseURL }) {
11392
11570
  super({
11393
11571
  baseURL,
@@ -11398,25 +11576,24 @@ var InvalidBaseURL = class extends h("InvalidBaseURL")() {
11398
11576
  /** Parse a path that is safe to resolve against a caller-provided base URL. */
11399
11577
  const parseRelativeURLPath = (path) => {
11400
11578
  const trimmedPath = path.trimStart();
11401
- if (absoluteURLPathPattern.test(trimmedPath) || protocolRelativeURLPathPattern.test(trimmedPath)) return G.err(new InvalidRelativeURLPath({ path }));
11402
- return G.ok(stripLeadingSlashes(path));
11579
+ if (absoluteURLPathPattern.test(trimmedPath) || protocolRelativeURLPathPattern.test(trimmedPath)) return ae.err(new InvalidRelativeURLPath({ path }));
11580
+ return ae.ok(stripLeadingSlashes(path));
11403
11581
  };
11404
11582
  const createURLResult = (baseURL, path) => {
11405
11583
  const parsedPath = parseRelativeURLPath(path);
11406
- if (G.isError(parsedPath)) return G.err(parsedPath.error);
11584
+ if (ae.isError(parsedPath)) return ae.err(parsedPath.error);
11407
11585
  try {
11408
- return G.ok(new URL(parsedPath.value, ensureTrailingSlash(stripTrailingSlashes(baseURL.toString()))));
11586
+ return ae.ok(new URL(parsedPath.value, ensureTrailingSlash(stripTrailingSlashes(baseURL.toString()))));
11409
11587
  } catch {
11410
- return G.err(new InvalidBaseURL({ baseURL: baseURL.toString() }));
11588
+ return ae.err(new InvalidBaseURL({ baseURL: baseURL.toString() }));
11411
11589
  }
11412
11590
  };
11413
11591
  const createURL = (baseURL, path) => {
11414
11592
  const url = createURLResult(baseURL, path);
11415
- if (G.isError(url)) throw url.error;
11593
+ if (ae.isError(url)) throw url.error;
11416
11594
  return url.value;
11417
11595
  };
11418
11596
  const createAbsoluteURL = (baseURL, path) => createURL(baseURL, path).toString();
11419
- h("MissingPathTemplateParam")();
11420
11597
  //#endregion
11421
11598
  //#region ../../node_modules/.bun/ky@2.0.2/node_modules/ky/distribution/errors/KyError.js
11422
11599
  /**
@@ -12060,7 +12237,7 @@ const hasSearchParameters = (search) => {
12060
12237
  //#endregion
12061
12238
  //#region ../../node_modules/.bun/ky@2.0.2/node_modules/ky/distribution/utils/is-network-error.js
12062
12239
  const objectToString$2 = Object.prototype.toString;
12063
- const isError$1 = (value) => objectToString$2.call(value) === "[object Error]";
12240
+ const isError$2 = (value) => objectToString$2.call(value) === "[object Error]";
12064
12241
  const errorMessages = /* @__PURE__ */ new Set([
12065
12242
  "network error",
12066
12243
  "NetworkError when attempting to fetch resource.",
@@ -12072,7 +12249,7 @@ const errorMessages = /* @__PURE__ */ new Set([
12072
12249
  "Network connection lost"
12073
12250
  ]);
12074
12251
  function isRawNetworkError(error) {
12075
- if (!(error && isError$1(error) && error.name === "TypeError" && typeof error.message === "string")) return false;
12252
+ if (!(error && isError$2(error) && error.name === "TypeError" && typeof error.message === "string")) return false;
12076
12253
  const { message, stack } = error;
12077
12254
  if (message === "Load failed") return stack === void 0 || "__sentry_captured__" in error;
12078
12255
  if (message.startsWith("error sending request for url")) return true;
@@ -12703,8 +12880,6 @@ object({
12703
12880
  status: number(),
12704
12881
  type: string()
12705
12882
  });
12706
- h("UnipileAPIError")();
12707
- h("UnipileHostedAuthURLMissingError")();
12708
12883
  looseObject({
12709
12884
  object: literal("HostedAuthLink"),
12710
12885
  link: string()
@@ -12740,7 +12915,7 @@ const SocialTargetPrefixes = {
12740
12915
  company_id: "company",
12741
12916
  request_id: "request"
12742
12917
  };
12743
- var InvalidSocialSelector = class extends h("InvalidSocialSelector")() {
12918
+ var InvalidSocialSelector = class extends h("InvalidSocialSelector") {
12744
12919
  constructor({ value, reason }) {
12745
12920
  super({
12746
12921
  value,
@@ -12801,42 +12976,40 @@ const linkedInURNKindFrom = (value) => {
12801
12976
  };
12802
12977
  const parseTypedSocialSelector = (value, options = {}) => {
12803
12978
  const parsed = parseTypedSocialSelectorResult(value, options);
12804
- return G.isOk(parsed) ? parsed.value : void 0;
12979
+ return ae.isOk(parsed) ? parsed.value : void 0;
12805
12980
  };
12806
12981
  const parseTypedSocialSelectorResult = (value, options = {}) => {
12807
12982
  const trimmed = value.trim();
12808
12983
  const colon = trimmed.indexOf(":");
12809
- if (colon <= 0) return G.err(new InvalidSocialSelector({
12984
+ if (colon <= 0) return ae.err(new InvalidSocialSelector({
12810
12985
  value,
12811
12986
  reason: "missing-prefix"
12812
12987
  }));
12813
12988
  const prefix = trimmed.slice(0, colon);
12814
- if (!isSocialTargetPrefix(prefix)) return G.err(new InvalidSocialSelector({
12989
+ if (!isSocialTargetPrefix(prefix)) return ae.err(new InvalidSocialSelector({
12815
12990
  value,
12816
12991
  reason: "unsupported-prefix"
12817
12992
  }));
12818
- if (options.prefixes && !options.prefixes.includes(prefix)) return G.err(new InvalidSocialSelector({
12993
+ if (options.prefixes && !options.prefixes.includes(prefix)) return ae.err(new InvalidSocialSelector({
12819
12994
  value,
12820
12995
  reason: "disallowed-prefix"
12821
12996
  }));
12822
12997
  const id = trimmed.slice(colon + 1).trim();
12823
- if (options.idMode === "lenient") return G.ok({
12998
+ if (options.idMode === "lenient") return ae.ok({
12824
12999
  prefix,
12825
13000
  kind: SocialTargetPrefixes[prefix],
12826
13001
  id
12827
13002
  });
12828
13003
  const parsed = plainResourceIdSchema(prefix).safeParse(id);
12829
- return parsed.success ? G.ok({
13004
+ return parsed.success ? ae.ok({
12830
13005
  prefix,
12831
13006
  kind: SocialTargetPrefixes[prefix],
12832
13007
  id: parsed.data
12833
- }) : G.err(new InvalidSocialSelector({
13008
+ }) : ae.err(new InvalidSocialSelector({
12834
13009
  value,
12835
13010
  reason: "invalid-id"
12836
13011
  }));
12837
13012
  };
12838
- h("InvalidLinkedinUpstreamPlanInput")();
12839
- h("InvalidUnipileCredentials")();
12840
13013
  //#endregion
12841
13014
  //#region ../../packages/linkedin/src/profiles.ts
12842
13015
  const displayNameFrom = (firstName, lastName, username) => [firstName, lastName].filter(Boolean).join(" ").trim() || username || "";
@@ -12955,8 +13128,6 @@ looseObject({
12955
13128
  data: array(GroupParticipant),
12956
13129
  next_cursor: string().nullish()
12957
13130
  });
12958
- h("ChatListParseError")();
12959
- h("ChatParticipantsFetchError")();
12960
13131
  const dropLinkedinInmailEligibility = (value) => {
12961
13132
  if (Array.isArray(value)) {
12962
13133
  let changed = false;
@@ -14963,7 +15134,7 @@ const isoDatePattern = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
14963
15134
  const isoDateTimePattern = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])T([01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d{1,3})?)?(?:Z|[+-]([01]\d|2[0-3]):[0-5]\d)?$/;
14964
15135
  const timezonePattern = /(Z|[+-]\d{2}:\d{2})$/;
14965
15136
  const invalidSinceMessage = "Invalid --since value. Use an ISO 8601 date like 2026-05-04 or datetime like 2026-05-04T00:00:00Z.";
14966
- var InvalidSince = class extends h("InvalidSince")() {
15137
+ var InvalidSince = class extends h("InvalidSince") {
14967
15138
  constructor(input) {
14968
15139
  super({
14969
15140
  input,
@@ -14991,23 +15162,23 @@ const parseSinceResult = (input) => {
14991
15162
  const isISODateTime = isoDateTimePattern.test(value);
14992
15163
  const normalized = isISODateTime && !timezonePattern.test(value) ? `${value}Z` : value;
14993
15164
  const parsed = (isISODate || isISODateTime) && hasValidDate(value) ? Date.parse(normalized) : NaN;
14994
- if (Number.isNaN(parsed)) return G.err(new InvalidSince(input));
14995
- return G.ok(parsed);
15165
+ if (Number.isNaN(parsed)) return ae.err(new InvalidSince(input));
15166
+ return ae.ok(parsed);
14996
15167
  };
14997
15168
  //#endregion
14998
15169
  //#region ../../packages/linkedin/src/cli/sync-plan.ts
14999
- var UnknownLinkedinSyncCollection = class extends h("UnknownLinkedinSyncCollection")() {};
15000
- var LinkedinSyncResetRequiresCollection = class extends h("LinkedinSyncResetRequiresCollection")() {
15170
+ var UnknownLinkedinSyncCollection = class extends h("UnknownLinkedinSyncCollection") {};
15171
+ var LinkedinSyncResetRequiresCollection = class extends h("LinkedinSyncResetRequiresCollection") {
15001
15172
  constructor() {
15002
15173
  super({ message: "--reset requires a collection" });
15003
15174
  }
15004
15175
  };
15005
- var LinkedinSyncResetWithSince = class extends h("LinkedinSyncResetWithSince")() {
15176
+ var LinkedinSyncResetWithSince = class extends h("LinkedinSyncResetWithSince") {
15006
15177
  constructor() {
15007
15178
  super({ message: "--reset cannot be combined with --since" });
15008
15179
  }
15009
15180
  };
15010
- var LinkedinSyncUnsupportedSince = class extends h("LinkedinSyncUnsupportedSince")() {
15181
+ var LinkedinSyncUnsupportedSince = class extends h("LinkedinSyncUnsupportedSince") {
15011
15182
  constructor(collection) {
15012
15183
  super({
15013
15184
  collection,
@@ -15015,7 +15186,7 @@ var LinkedinSyncUnsupportedSince = class extends h("LinkedinSyncUnsupportedSince
15015
15186
  });
15016
15187
  }
15017
15188
  };
15018
- var LinkedinSyncMissingInitialFullSync = class extends h("LinkedinSyncMissingInitialFullSync")() {
15189
+ var LinkedinSyncMissingInitialFullSync = class extends h("LinkedinSyncMissingInitialFullSync") {
15019
15190
  constructor(collection) {
15020
15191
  super({
15021
15192
  collection,
@@ -15023,36 +15194,36 @@ var LinkedinSyncMissingInitialFullSync = class extends h("LinkedinSyncMissingIni
15023
15194
  });
15024
15195
  }
15025
15196
  };
15026
- var InvalidLinkedinSyncSince = class extends h("InvalidLinkedinSyncSince")() {};
15197
+ var InvalidLinkedinSyncSince = class extends h("InvalidLinkedinSyncSince") {};
15027
15198
  const linkedinSyncCollectionShortName = (collection) => collection.key.replace(/^(x|li)_/, "");
15028
15199
  const linkedinSyncCollectionFor = (collections, collection) => {
15029
15200
  const found = collections.find((candidate) => linkedinSyncCollectionShortName(candidate) === collection || candidate.key === collection);
15030
- if (found) return G.ok(found);
15201
+ if (found) return ae.ok(found);
15031
15202
  const available = collections.map(linkedinSyncCollectionShortName);
15032
- return G.err(new UnknownLinkedinSyncCollection({
15203
+ return ae.err(new UnknownLinkedinSyncCollection({
15033
15204
  collection,
15034
15205
  available,
15035
15206
  message: `Unknown collection "${collection}". Available: ${available.join(", ")}`
15036
15207
  }));
15037
15208
  };
15038
15209
  const planLinkedinSyncCommand = ({ args, collections, cursorState }) => {
15039
- if (!args.collection) return args.reset === true ? G.err(new LinkedinSyncResetRequiresCollection()) : G.ok({ mode: "list" });
15210
+ if (!args.collection) return args.reset === true ? ae.err(new LinkedinSyncResetRequiresCollection()) : ae.ok({ mode: "list" });
15040
15211
  const collection = linkedinSyncCollectionFor(collections, String(args.collection));
15041
- if (G.isError(collection)) return G.err(collection.error);
15042
- if (args.reset === true) return args.since == null ? G.ok({
15212
+ if (ae.isError(collection)) return ae.err(collection.error);
15213
+ if (args.reset === true) return args.since == null ? ae.ok({
15043
15214
  mode: "reset",
15044
15215
  collection: collection.value
15045
- }) : G.err(new LinkedinSyncResetWithSince());
15046
- if (args.since == null) return G.ok({
15216
+ }) : ae.err(new LinkedinSyncResetWithSince());
15217
+ if (args.since == null) return ae.ok({
15047
15218
  mode: "run",
15048
15219
  collection: collection.value
15049
15220
  });
15050
15221
  const shortName = linkedinSyncCollectionShortName(collection.value);
15051
- if (!collection.value.sinceField) return G.err(new LinkedinSyncUnsupportedSince(shortName));
15052
- if (collection.value.requiresFullInitialSync && cursorState?.lastSynced == null) return G.err(new LinkedinSyncMissingInitialFullSync(shortName));
15222
+ if (!collection.value.sinceField) return ae.err(new LinkedinSyncUnsupportedSince(shortName));
15223
+ if (collection.value.requiresFullInitialSync && cursorState?.lastSynced == null) return ae.err(new LinkedinSyncMissingInitialFullSync(shortName));
15053
15224
  const parsedSince = parseSinceResult(String(args.since));
15054
- if (G.isError(parsedSince)) return G.err(new InvalidLinkedinSyncSince({ message: parsedSince.error.message }));
15055
- return G.ok({
15225
+ if (ae.isError(parsedSince)) return ae.err(new InvalidLinkedinSyncSince({ message: parsedSince.error.message }));
15226
+ return ae.ok({
15056
15227
  mode: "run",
15057
15228
  collection: collection.value,
15058
15229
  since: parsedSince.value
@@ -15483,7 +15654,7 @@ const buildSync$1 = (deps, platform) => defineCommand({
15483
15654
  }
15484
15655
  })() : void 0
15485
15656
  });
15486
- if (G.isError(plan)) throw new UsageError(plan.error.message);
15657
+ if (ae.isError(plan)) throw new UsageError(plan.error.message);
15487
15658
  if (plan.value.mode === "list") {
15488
15659
  const cache = openLinkedinCache({
15489
15660
  platform,
@@ -15560,7 +15731,7 @@ const buildSync$1 = (deps, platform) => defineCommand({
15560
15731
  if (rateLimitError) throw rateLimitError;
15561
15732
  throw error;
15562
15733
  }
15563
- if (G.isError(result)) {
15734
+ if (ae.isError(result)) {
15564
15735
  progress.error();
15565
15736
  const rateLimitError = enrichRateLimitSyncError$1({
15566
15737
  error: result.error,
@@ -15669,7 +15840,7 @@ const buildSql$1 = (deps, platform) => defineCommand({
15669
15840
  } catch (error) {
15670
15841
  throw new UsageError(`Query failed (cache is read-only): ${error instanceof Error ? error.message : String(error)}`);
15671
15842
  }
15672
- if (G.isError(result)) throw new UsageError(`Query failed (cache is read-only): ${result.error.message}`);
15843
+ if (ae.isError(result)) throw new UsageError(`Query failed (cache is read-only): ${result.error.message}`);
15673
15844
  await deps.printResult({
15674
15845
  account: res.account,
15675
15846
  contract,
@@ -19729,7 +19900,7 @@ const contractFor$1 = (op, commandName, group) => buildRuntimeContract(xRuntimeA
19729
19900
  const defineOperationCommand = (op, deps) => defineRuntimeOperationCommand(xRuntimeAdapter, op, deps);
19730
19901
  //#endregion
19731
19902
  //#region ../../packages/x/src/cli/sync-plan.ts
19732
- var XSyncPlanError = class extends h("XSyncPlanError")() {
19903
+ var XSyncPlanError = class extends h("XSyncPlanError") {
19733
19904
  constructor(args) {
19734
19905
  super(args);
19735
19906
  this.name = "XSyncPlanError";
@@ -19738,30 +19909,30 @@ var XSyncPlanError = class extends h("XSyncPlanError")() {
19738
19909
  const shortSyncCollectionName = (collection) => collection.key.replace(/^(x|li)_/, "");
19739
19910
  const findSyncCollection = (collections, input) => collections.find((collection) => shortSyncCollectionName(collection) === input || collection.key === input);
19740
19911
  const parseTimeoutSeconds = (value) => {
19741
- if (value == null) return G.ok(void 0);
19912
+ if (value == null) return ae.ok(void 0);
19742
19913
  const timeoutSeconds = Number(value);
19743
- if (!Number.isInteger(timeoutSeconds) || timeoutSeconds < 1) return G.err(new XSyncPlanError({
19914
+ if (!Number.isInteger(timeoutSeconds) || timeoutSeconds < 1) return ae.err(new XSyncPlanError({
19744
19915
  kind: "invalid-timeout",
19745
19916
  message: "--timeout must be at least 1."
19746
19917
  }));
19747
- return G.ok(timeoutSeconds);
19918
+ return ae.ok(timeoutSeconds);
19748
19919
  };
19749
19920
  const planXSync = (input) => {
19750
19921
  const accountSelector = input.accountSelector;
19751
- if (accountSelector === void 0 || accountSelector.length === 0) return G.err(new XSyncPlanError({
19922
+ if (accountSelector === void 0 || accountSelector.length === 0) return ae.err(new XSyncPlanError({
19752
19923
  kind: "missing-account-selector",
19753
19924
  message: "Selected X account is missing an account selector."
19754
19925
  }));
19755
19926
  const timeout = parseTimeoutSeconds(input.timeout);
19756
- if (G.isError(timeout)) return G.err(timeout.error);
19927
+ if (ae.isError(timeout)) return ae.err(timeout.error);
19757
19928
  const accountHeaders = { "x-social-account-id": accountSelector };
19758
19929
  const collectionInput = typeof input.collection === "string" && input.collection.length > 0 ? input.collection : void 0;
19759
19930
  if (collectionInput === void 0) {
19760
- if (input.reset === true) return G.err(new XSyncPlanError({
19931
+ if (input.reset === true) return ae.err(new XSyncPlanError({
19761
19932
  kind: "reset-without-collection",
19762
19933
  message: "--reset requires a collection"
19763
19934
  }));
19764
- return G.ok({
19935
+ return ae.ok({
19765
19936
  kind: "list",
19766
19937
  accountHeaders,
19767
19938
  accountSelector,
@@ -19769,19 +19940,19 @@ const planXSync = (input) => {
19769
19940
  });
19770
19941
  }
19771
19942
  const collection = findSyncCollection(input.collections, collectionInput);
19772
- if (collection === void 0) return G.err(new XSyncPlanError({
19943
+ if (collection === void 0) return ae.err(new XSyncPlanError({
19773
19944
  kind: "unknown-collection",
19774
19945
  collection: collectionInput,
19775
19946
  message: `Unknown collection "${collectionInput}". Available: ${input.collections.map(shortSyncCollectionName).join(", ")}`
19776
19947
  }));
19777
19948
  if (input.reset === true) {
19778
- if (input.since != null) return G.err(new XSyncPlanError({
19949
+ if (input.since != null) return ae.err(new XSyncPlanError({
19779
19950
  kind: "reset-with-since",
19780
19951
  collection: collection.key,
19781
19952
  message: "--reset cannot be combined with --since"
19782
19953
  }));
19783
19954
  const resetCollections = resetTablesFor(collection);
19784
- return G.ok({
19955
+ return ae.ok({
19785
19956
  kind: "reset",
19786
19957
  accountHeaders,
19787
19958
  accountSelector,
@@ -19792,20 +19963,20 @@ const planXSync = (input) => {
19792
19963
  }
19793
19964
  let since;
19794
19965
  if (input.since != null) {
19795
- if (!collection.sinceField) return G.err(new XSyncPlanError({
19966
+ if (!collection.sinceField) return ae.err(new XSyncPlanError({
19796
19967
  kind: "since-unsupported",
19797
19968
  collection: collection.key,
19798
19969
  message: `${shortSyncCollectionName(collection)} does not support --since`
19799
19970
  }));
19800
19971
  const parsedSince = parseSinceResult(String(input.since));
19801
- if (G.isError(parsedSince)) return G.err(new XSyncPlanError({
19972
+ if (ae.isError(parsedSince)) return ae.err(new XSyncPlanError({
19802
19973
  kind: "since-unsupported",
19803
19974
  collection: collection.key,
19804
19975
  message: parsedSince.error.message
19805
19976
  }));
19806
19977
  since = parsedSince.value;
19807
19978
  }
19808
- return G.ok({
19979
+ return ae.ok({
19809
19980
  kind: "run",
19810
19981
  accountHeaders,
19811
19982
  accountSelector,
@@ -19816,7 +19987,7 @@ const planXSync = (input) => {
19816
19987
  };
19817
19988
  //#endregion
19818
19989
  //#region ../../packages/x/src/cli/write-plan.ts
19819
- var XWritePlanError = class extends h("XWritePlanError")() {
19990
+ var XWritePlanError = class extends h("XWritePlanError") {
19820
19991
  constructor(args) {
19821
19992
  super(args);
19822
19993
  this.name = "XWritePlanError";
@@ -19838,16 +20009,16 @@ const responseString = (data, keys) => {
19838
20009
  const responseMediaIdResult = (data) => {
19839
20010
  const root = isObjectRecord$1(data) ? data : void 0;
19840
20011
  const id = (isObjectRecord$1(root?.data) ? root.data : void 0)?.id ?? root?.id;
19841
- if (typeof id !== "string" && typeof id !== "number") return G.err(new XWritePlanError({
20012
+ if (typeof id !== "string" && typeof id !== "number") return ae.err(new XWritePlanError({
19842
20013
  kind: "missing-media-id",
19843
20014
  message: "Media upload did not return a media id."
19844
20015
  }));
19845
- return G.ok(String(id));
20016
+ return ae.ok(String(id));
19846
20017
  };
19847
- const requiredTargetResult = (target) => target === void 0 ? G.err(new XWritePlanError({
20018
+ const requiredTargetResult = (target) => target === void 0 ? ae.err(new XWritePlanError({
19848
20019
  kind: "missing-target",
19849
20020
  message: "target is required."
19850
- })) : G.ok(target);
20021
+ })) : ae.ok(target);
19851
20022
  const postMediaByExtension = {
19852
20023
  ".gif": {
19853
20024
  mediaType: "image/gif",
@@ -19880,22 +20051,22 @@ const postMediaByExtension = {
19880
20051
  };
19881
20052
  const parsePostMediaFileResult = (path) => {
19882
20053
  const media = postMediaByExtension[extname(path).toLowerCase()];
19883
- if (media === void 0) return G.err(new XWritePlanError({
20054
+ if (media === void 0) return ae.err(new XWritePlanError({
19884
20055
  kind: "invalid-media-type",
19885
20056
  message: `Unsupported media type for ${path}. Supported types: jpg, jpeg, png, webp, gif, mp4, mov.`
19886
20057
  }));
19887
- return G.ok({
20058
+ return ae.ok({
19888
20059
  ...media,
19889
20060
  path
19890
20061
  });
19891
20062
  };
19892
20063
  const parsePostMediaIdResult = (value) => {
19893
20064
  const mediaId = value.trim();
19894
- if (mediaId.length === 0) return G.err(new XWritePlanError({
20065
+ if (mediaId.length === 0) return ae.err(new XWritePlanError({
19895
20066
  kind: "empty-media-id",
19896
20067
  message: "--media-id cannot be empty."
19897
20068
  }));
19898
- return G.ok(mediaId);
20069
+ return ae.ok(mediaId);
19899
20070
  };
19900
20071
  const postBodyHasText = (body) => {
19901
20072
  const text = body?.text;
@@ -19907,7 +20078,7 @@ const postBodyMediaIds = (body) => {
19907
20078
  };
19908
20079
  const postBodyHasPoll = (body) => isObjectRecord$1(body?.poll);
19909
20080
  const validatePostMediaResult = (mediaFiles, mediaIds) => {
19910
- if (mediaFiles.length + mediaIds.length > 4) return G.err(new XWritePlanError({
20081
+ if (mediaFiles.length + mediaIds.length > 4) return ae.err(new XWritePlanError({
19911
20082
  kind: "invalid-media-mix",
19912
20083
  message: "Attach at most 4 media items."
19913
20084
  }));
@@ -19919,35 +20090,35 @@ const validatePostMediaResult = (mediaFiles, mediaIds) => {
19919
20090
  gifCount > 0,
19920
20091
  videoCount > 0
19921
20092
  ].filter(Boolean).length;
19922
- if (imageCount > 4) return G.err(new XWritePlanError({
20093
+ if (imageCount > 4) return ae.err(new XWritePlanError({
19923
20094
  kind: "invalid-media-mix",
19924
20095
  message: "Attach at most 4 images."
19925
20096
  }));
19926
- if (gifCount > 1) return G.err(new XWritePlanError({
20097
+ if (gifCount > 1) return ae.err(new XWritePlanError({
19927
20098
  kind: "invalid-media-mix",
19928
20099
  message: "Attach at most 1 GIF."
19929
20100
  }));
19930
- if (videoCount > 1) return G.err(new XWritePlanError({
20101
+ if (videoCount > 1) return ae.err(new XWritePlanError({
19931
20102
  kind: "invalid-media-mix",
19932
20103
  message: "Attach at most 1 video."
19933
20104
  }));
19934
- if (localCategoryCount > 1) return G.err(new XWritePlanError({
20105
+ if (localCategoryCount > 1) return ae.err(new XWritePlanError({
19935
20106
  kind: "invalid-media-mix",
19936
20107
  message: "Do not mix images, GIFs, and videos in one post."
19937
20108
  }));
19938
- return G.ok();
20109
+ return ae.ok();
19939
20110
  };
19940
20111
  const validatePostPollMediaResult = (args) => {
19941
20112
  const explicitMediaCount = args.mediaFiles.length + args.mediaIds.length;
19942
20113
  const bodyMediaIds = explicitMediaCount > 0 ? [] : postBodyMediaIds(args.bodyFields);
19943
20114
  const hasMedia = explicitMediaCount + bodyMediaIds.length > 0;
19944
20115
  const hasPoll = args.poll !== void 0 || postBodyHasPoll(args.bodyFields);
19945
- if (hasPoll && hasMedia) return G.err(new XWritePlanError({
20116
+ if (hasPoll && hasMedia) return ae.err(new XWritePlanError({
19946
20117
  kind: "invalid-media-mix",
19947
20118
  message: "--poll-option cannot be combined with media attachments."
19948
20119
  }));
19949
20120
  const media = validatePostMediaResult(args.mediaFiles, [...args.mediaIds, ...bodyMediaIds]);
19950
- return G.isError(media) ? G.err(media.error) : G.ok({
20121
+ return ae.isError(media) ? ae.err(media.error) : ae.ok({
19951
20122
  bodyMediaIds,
19952
20123
  hasMedia,
19953
20124
  hasPoll
@@ -20017,12 +20188,12 @@ const planPostRequest = (args) => {
20017
20188
  };
20018
20189
  };
20019
20190
  const planMessageRequestResult = (args) => {
20020
- if (args.body === void 0) return G.err(new XWritePlanError({
20191
+ if (args.body === void 0) return ae.err(new XWritePlanError({
20021
20192
  kind: "missing-message-body",
20022
20193
  message: "Message body is required."
20023
20194
  }));
20024
20195
  const text = typeof args.body.text === "string" ? args.body.text : void 0;
20025
- if (args.threadResolution !== void 0) return G.ok({
20196
+ if (args.threadResolution !== void 0) return ae.ok({
20026
20197
  method: "POST",
20027
20198
  path: `x/dm_conversations/${encodeURIComponent(args.threadResolution.id)}/messages`,
20028
20199
  headers: args.headers,
@@ -20034,11 +20205,11 @@ const planMessageRequestResult = (args) => {
20034
20205
  });
20035
20206
  if (args.recipients.length === 1) {
20036
20207
  const [participant] = args.participantResolutions;
20037
- if (participant === void 0) return G.err(new XWritePlanError({
20208
+ if (participant === void 0) return ae.err(new XWritePlanError({
20038
20209
  kind: "missing-target",
20039
20210
  message: "Pass at least one recipient."
20040
20211
  }));
20041
- return G.ok({
20212
+ return ae.ok({
20042
20213
  method: "POST",
20043
20214
  path: `x/dm_conversations/with/${encodeURIComponent(participant.id)}/messages`,
20044
20215
  headers: args.headers,
@@ -20051,7 +20222,7 @@ const planMessageRequestResult = (args) => {
20051
20222
  }
20052
20223
  const participantIds = args.participantResolutions.map((resolution) => resolution.id);
20053
20224
  const { text: bodyText, ...bodyFields } = args.body;
20054
- return G.ok({
20225
+ return ae.ok({
20055
20226
  method: "POST",
20056
20227
  path: "x/dm_conversations",
20057
20228
  headers: args.headers,
@@ -20533,7 +20704,7 @@ const buildSync = (deps, platform) => defineCommand({
20533
20704
  since: args.since,
20534
20705
  timeout: args.timeout
20535
20706
  });
20536
- if (G.isError(planned)) throw new UsageError(planned.error instanceof XSyncPlanError ? planned.error.message : String(planned.error));
20707
+ if (ae.isError(planned)) throw new UsageError(planned.error instanceof XSyncPlanError ? planned.error.message : String(planned.error));
20537
20708
  const plan = planned.value;
20538
20709
  if (plan.kind === "list") {
20539
20710
  const cache = openXCacheFor(deps, {
@@ -20601,7 +20772,7 @@ const buildSync = (deps, platform) => defineCommand({
20601
20772
  if (rateLimitError) throw rateLimitError;
20602
20773
  throw error;
20603
20774
  }
20604
- if (G.isError(result)) {
20775
+ if (ae.isError(result)) {
20605
20776
  const rateLimitError = enrichRateLimitSyncError({
20606
20777
  error: result.error,
20607
20778
  platform,
@@ -20708,7 +20879,7 @@ const buildSql = (deps, platform) => {
20708
20879
  } catch (error) {
20709
20880
  throw new UsageError(`Query failed (cache is read-only): ${errorMessageFrom(error)}`);
20710
20881
  }
20711
- if (G.isError(result)) throw new UsageError(`Query failed (cache is read-only): ${result.error.message}`);
20882
+ if (ae.isError(result)) throw new UsageError(`Query failed (cache is read-only): ${result.error.message}`);
20712
20883
  await deps.printResult({
20713
20884
  account: account.account,
20714
20885
  contract: schemaContract,
@@ -20793,7 +20964,7 @@ const throwWritePlanError = (error) => {
20793
20964
  };
20794
20965
  const requireWriteTarget = (target) => {
20795
20966
  const required = requiredTargetResult(target);
20796
- if (G.isError(required)) return throwWritePlanError(required.error);
20967
+ if (ae.isError(required)) return throwWritePlanError(required.error);
20797
20968
  return required.value;
20798
20969
  };
20799
20970
  const executeWriteRequest = (deps, plan) => plan.method === "POST" ? deps.api.post(plan.path, {
@@ -20846,7 +21017,7 @@ const repeatableValues = (name, value, rawArgs) => {
20846
21017
  };
20847
21018
  const parsePostMediaId = (deps, value) => {
20848
21019
  const mediaId = parsePostMediaIdResult(value);
20849
- if (G.isError(mediaId)) throw new UsageError(mediaId.error.message);
21020
+ if (ae.isError(mediaId)) throw new UsageError(mediaId.error.message);
20850
21021
  return deps.parseResourceId("--media-id", mediaId.value);
20851
21022
  };
20852
21023
  const parsePostPoll = (deps, args, rawArgs) => {
@@ -20931,7 +21102,7 @@ const uploadPostMedia = async (deps, headers, media, timeoutSeconds) => {
20931
21102
  initBody.set("total_bytes", String(file.byteLength));
20932
21103
  initBody.set("media_category", media.category);
20933
21104
  const mediaId = responseMediaIdResult(await (await postMediaForm(deps, "x/media/upload/init", headers, initBody)).json());
20934
- if (G.isError(mediaId)) throw new UsageError(mediaId.error.message);
21105
+ if (ae.isError(mediaId)) throw new UsageError(mediaId.error.message);
20935
21106
  for (let segmentIndex = 0, offset = 0; offset < file.byteLength; segmentIndex += 1, offset += postMediaChunkSize) {
20936
21107
  const chunk = file.subarray(offset, offset + postMediaChunkSize);
20937
21108
  const appendBody = new FormData();
@@ -21193,7 +21364,7 @@ const buildPost = (deps) => {
21193
21364
  const commandArgs = args;
21194
21365
  const mediaFiles = repeatableValues("media", commandArgs.media, rawArgs).map((path) => {
21195
21366
  const media = parsePostMediaFileResult(path);
21196
- if (G.isError(media)) throw new UsageError(media.error.message);
21367
+ if (ae.isError(media)) throw new UsageError(media.error.message);
21197
21368
  return media.value;
21198
21369
  });
21199
21370
  const mediaIds = repeatableValues("media-id", commandArgs["media-id"], rawArgs).map((mediaId) => parsePostMediaId(deps, mediaId));
@@ -21205,7 +21376,7 @@ const buildPost = (deps) => {
21205
21376
  mediaIds,
21206
21377
  poll
21207
21378
  });
21208
- if (G.isError(postInputs)) throw new UsageError(postInputs.error.message);
21379
+ if (ae.isError(postInputs)) throw new UsageError(postInputs.error.message);
21209
21380
  const timeoutSeconds = commandArgs.timeout === void 0 ? postMediaProcessingTimeoutSeconds : deps.parseIntegerString("--timeout", commandArgs.timeout, { min: 1 });
21210
21381
  const stdinBody = await readPostStdinBody(deps, postInputs.value.hasMedia, bodyFields);
21211
21382
  const account = typeof commandArgs.account === "string" ? commandArgs.account : void 0;
@@ -22247,7 +22418,7 @@ const buildMessage = (deps) => {
22247
22418
  recipients,
22248
22419
  threadResolution
22249
22420
  });
22250
- if (G.isError(request)) throw new UsageError(request.error.message);
22421
+ if (ae.isError(request)) throw new UsageError(request.error.message);
22251
22422
  const response = await deps.api.post(request.value.path, {
22252
22423
  headers: request.value.headers,
22253
22424
  json: request.value.body
@@ -22540,35 +22711,30 @@ createXCommands({
22540
22711
  //#endregion
22541
22712
  //#region ../../packages/linkedin/src/cli/lifecycle-plan.ts
22542
22713
  const LINKEDIN_CONNECTED_STATUS = "connected";
22543
- var InvalidLinkedinLifecycleTarget = class extends h("InvalidLinkedinLifecycleTarget")() {};
22544
- var LinkedinLifecycleNoAccountMatch = class extends h("LinkedinLifecycleNoAccountMatch")() {};
22545
- var LinkedinLifecycleAmbiguousAccount = class extends h("LinkedinLifecycleAmbiguousAccount")() {};
22546
- var LinkedinLifecycleSeatTimeout = class extends h("LinkedinLifecycleSeatTimeout")() {
22547
- constructor() {
22548
- super({ message: "billing_seat_timed_out" });
22549
- }
22550
- };
22714
+ var InvalidLinkedinLifecycleTarget = class extends h("InvalidLinkedinLifecycleTarget") {};
22715
+ var LinkedinLifecycleNoAccountMatch = class extends h("LinkedinLifecycleNoAccountMatch") {};
22716
+ var LinkedinLifecycleAmbiguousAccount = class extends h("LinkedinLifecycleAmbiguousAccount") {};
22551
22717
  const accountUsername$1 = (account) => account.username.replace(/^@+/, "");
22552
22718
  const parseLinkedinReconnectTarget = (value) => {
22553
22719
  const trimmed = value.trim();
22554
22720
  if (trimmed.startsWith("@")) {
22555
22721
  const username = normalizeSocialIdentifier(trimmed);
22556
- if (username) return G.ok({
22722
+ if (username) return ae.ok({
22557
22723
  type: "username",
22558
22724
  value: username
22559
22725
  });
22560
22726
  }
22561
22727
  const profileSelector = parseTypedSocialSelector(trimmed, { prefixes: ["profile_id"] });
22562
- if (profileSelector) return G.ok({
22728
+ if (profileSelector) return ae.ok({
22563
22729
  type: "profileId",
22564
22730
  value: profileSelector.id.toLowerCase()
22565
22731
  });
22566
22732
  const publicIdentifier = linkedInProfileIdentifierFromURL(trimmed);
22567
- if (publicIdentifier) return G.ok({
22733
+ if (publicIdentifier) return ae.ok({
22568
22734
  type: "username",
22569
22735
  value: publicIdentifier
22570
22736
  });
22571
- return G.err(new InvalidLinkedinLifecycleTarget({
22737
+ return ae.err(new InvalidLinkedinLifecycleTarget({
22572
22738
  value,
22573
22739
  message: "LinkedIn reconnect account must be @username, a LinkedIn profile URL, or profile_id:<id>."
22574
22740
  }));
@@ -22584,14 +22750,14 @@ const reconnectCommandTargetFor = (account) => {
22584
22750
  const connectedLinkedinLifecycleAccounts = (accounts) => accounts.filter((account) => account.status === LINKEDIN_CONNECTED_STATUS);
22585
22751
  const resolveLinkedinLifecycleAccount = (accounts, identifier) => {
22586
22752
  const target = parseLinkedinReconnectTarget(identifier);
22587
- if (G.isError(target)) return G.err(target.error);
22753
+ if (ae.isError(target)) return ae.err(target.error);
22588
22754
  const matches = accounts.filter((candidate) => linkedinLifecycleAccountMatchesTarget(candidate, target.value));
22589
- if (matches.length === 1 && matches[0]) return G.ok(matches[0]);
22590
- if (matches.length === 0) return G.err(new LinkedinLifecycleNoAccountMatch({
22755
+ if (matches.length === 1 && matches[0]) return ae.ok(matches[0]);
22756
+ if (matches.length === 0) return ae.err(new LinkedinLifecycleNoAccountMatch({
22591
22757
  value: identifier,
22592
22758
  message: `No LinkedIn account matches "${identifier}".`
22593
22759
  }));
22594
- return G.err(new LinkedinLifecycleAmbiguousAccount({
22760
+ return ae.err(new LinkedinLifecycleAmbiguousAccount({
22595
22761
  value: identifier,
22596
22762
  message: `Multiple LinkedIn accounts match "${identifier}". Pass profile_id:<id>.`
22597
22763
  }));
@@ -22599,50 +22765,25 @@ const resolveLinkedinLifecycleAccount = (accounts, identifier) => {
22599
22765
  const resolveLinkedinDisconnectAccount = (accounts, identifier) => {
22600
22766
  if (identifier) return resolveLinkedinLifecycleAccount(accounts, identifier);
22601
22767
  const connected = connectedLinkedinLifecycleAccounts(accounts);
22602
- if (connected.length === 1 && connected[0]) return G.ok(connected[0]);
22603
- if (connected.length === 0) return G.err(new LinkedinLifecycleNoAccountMatch({ message: "No connected LinkedIn accounts found." }));
22604
- return G.err(new LinkedinLifecycleAmbiguousAccount({ message: "Multiple LinkedIn accounts are connected. Pass a public identifier." }));
22768
+ if (connected.length === 1 && connected[0]) return ae.ok(connected[0]);
22769
+ if (connected.length === 0) return ae.err(new LinkedinLifecycleNoAccountMatch({ message: "No connected LinkedIn accounts found." }));
22770
+ return ae.err(new LinkedinLifecycleAmbiguousAccount({ message: "Multiple LinkedIn accounts are connected. Pass a public identifier." }));
22605
22771
  };
22606
22772
  //#endregion
22607
22773
  //#region ../../packages/linkedin/src/cli/lifecycle.ts
22608
22774
  const LINKEDIN_PLATFORM = "linkedin";
22609
22775
  const DEFAULT_POLL_INTERVAL_MS = 2e3;
22610
22776
  const DEFAULT_POLL_TIMEOUT_MS = 12e4;
22611
- const SEAT_POLL_TIMEOUT_MS$1 = 600 * 1e3;
22777
+ const CONNECT_POLL_TIMEOUT_MS = 600 * 1e3;
22612
22778
  const surfaceURL$1 = (deps, url, options = {}) => {
22613
22779
  const log = deps.log ?? console.error;
22614
22780
  if (options.log ?? true) log(`Open this URL: ${url}`);
22615
22781
  };
22616
- const pollForSeat$1 = async (deps) => {
22617
- const intervalMs = deps.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
22618
- const sleep = deps.sleep ?? setTimeout$1;
22619
- const startedAt = Date.now();
22620
- while (Date.now() - startedAt < SEAT_POLL_TIMEOUT_MS$1) {
22621
- if ((await deps.client.billing.status()).canConnect) return;
22622
- await sleep(intervalMs);
22623
- }
22624
- throw new LinkedinLifecycleSeatTimeout();
22625
- };
22626
- const prepareAccountConnect$1 = async (deps) => {
22627
- if ((await deps.client.billing.status()).canConnect) return;
22628
- const status = await deps.client.billing.prepareAccountConnect();
22629
- if (status.canConnect) return;
22630
- if (status.paymentURL) surfaceURL$1(deps, status.paymentURL);
22631
- await pollForSeat$1(deps);
22632
- };
22633
22782
  const accountUsername = (account) => account.username.replace(/^@+/, "");
22634
22783
  const listLinkedinLifecycleAccounts = (deps, includeDisconnected = true) => deps.client.listAccounts({
22635
22784
  platform: LINKEDIN_PLATFORM,
22636
22785
  includeDisconnected
22637
22786
  });
22638
- /**
22639
- * Resolve the LinkedIn hosted-auth connect URL without opening a browser or
22640
- * polling. Lets a non-TTY caller advance a connect handshake one step at a time.
22641
- */
22642
- const createLinkedinConnectURL = async (deps) => (await deps.client.createHostedAuthURL({
22643
- platform: LINKEDIN_PLATFORM,
22644
- mode: "create"
22645
- })).url;
22646
22787
  const pollForAccount$1 = async (deps, predicate, errorMessage) => {
22647
22788
  const startedAt = Date.now();
22648
22789
  const timeoutMs = deps.pollTimeoutMs ?? DEFAULT_POLL_TIMEOUT_MS;
@@ -22660,30 +22801,48 @@ const authURLFor$1 = async (deps, operation) => ({
22660
22801
  openingLogged: deps.handshakeAuthURL !== void 0
22661
22802
  });
22662
22803
  const reconnectAccountForIdentifier = async (deps, identifier) => {
22663
- const account = resolveLinkedinLifecycleAccount(await listLinkedinLifecycleAccounts(deps), identifier);
22664
- if (G.isError(account)) throw account.error;
22804
+ const accounts = await listLinkedinLifecycleAccounts(deps);
22805
+ const account = resolveLinkedinLifecycleAccount(accounts.filter((candidate) => candidate.status !== "disconnected"), identifier);
22806
+ if (ae.isError(account)) {
22807
+ if (LinkedinLifecycleNoAccountMatch.is(account.error)) {
22808
+ const disconnected = resolveLinkedinLifecycleAccount(accounts.filter((candidate) => candidate.status === "disconnected"), identifier);
22809
+ if (ae.isOk(disconnected)) throw new Error(`LinkedIn account @${accountUsername(disconnected.value)} is disconnected and its seat was released. Run \`social account connect linkedin\` to connect it again.`);
22810
+ }
22811
+ throw account.error;
22812
+ }
22665
22813
  return account.value;
22666
22814
  };
22667
22815
  const resolveDisconnectTarget = async (deps, identifier) => {
22668
22816
  const account = resolveLinkedinDisconnectAccount(await listLinkedinLifecycleAccounts(deps, Boolean(identifier)), identifier);
22669
- if (G.isError(account)) throw account.error;
22817
+ if (ae.isError(account)) throw account.error;
22670
22818
  return account.value;
22671
22819
  };
22672
- const connectLinkedinAccount = async (deps) => {
22673
- await prepareAccountConnect$1(deps);
22674
- const before = await listLinkedinLifecycleAccounts(deps);
22675
- const existingProfileIds = new Set(before.map((account) => account.profileId));
22676
- const authURL = await authURLFor$1(deps, async () => (await deps.client.createHostedAuthURL({
22677
- platform: LINKEDIN_PLATFORM,
22678
- mode: "create"
22679
- })).url);
22680
- surfaceURL$1(deps, authURL.url, { log: !authURL.openingLogged });
22681
- const account = await pollForAccount$1(deps, (candidate) => candidate.status === "connected" && !existingProfileIds.has(candidate.profileId), "Timed out waiting for a new LinkedIn account connection.");
22682
- return {
22683
- platform: LINKEDIN_PLATFORM,
22684
- status: "connected",
22685
- account
22686
- };
22820
+ const connectLinkedinAccount = async (deps, attemptId) => {
22821
+ const intervalMs = deps.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
22822
+ const sleep = deps.sleep ?? setTimeout$1;
22823
+ const startedAt = Date.now();
22824
+ let currentAttemptId = attemptId;
22825
+ const surfacedURLs = /* @__PURE__ */ new Set();
22826
+ while (Date.now() - startedAt < CONNECT_POLL_TIMEOUT_MS) {
22827
+ const state = await deps.client.connectStep({
22828
+ platform: LINKEDIN_PLATFORM,
22829
+ ...currentAttemptId ? { attemptId: currentAttemptId } : {}
22830
+ });
22831
+ currentAttemptId = state.attemptId;
22832
+ if (state.status === "connected") return {
22833
+ platform: LINKEDIN_PLATFORM,
22834
+ status: "connected",
22835
+ account: state.account
22836
+ };
22837
+ if (state.status === "expired" || state.status === "failed") throw new Error(state.code);
22838
+ const url = state.status === "pending_billing" ? state.paymentURL : state.status === "pending_approval" ? state.connectURL : null;
22839
+ if (url && !surfacedURLs.has(url)) {
22840
+ surfacedURLs.add(url);
22841
+ surfaceURL$1(deps, url);
22842
+ } else if (state.status === "pending_billing" && state.requiredAction) deps.log?.(state.requiredAction.reason);
22843
+ await sleep(intervalMs);
22844
+ }
22845
+ throw new Error("linkedin_connect_timed_out");
22687
22846
  };
22688
22847
  const reconnectLinkedinAccount = async (deps, identifier) => {
22689
22848
  const account = await reconnectAccountForIdentifier(deps, identifier);
@@ -22715,9 +22874,8 @@ const disconnectLinkedinAccount = async (deps, identifier) => {
22715
22874
  //#endregion
22716
22875
  //#region ../../packages/x/src/cli/lifecycle.ts
22717
22876
  const CONNECT_TIMEOUT_MS = 300 * 1e3;
22718
- const SEAT_POLL_TIMEOUT_MS = 600 * 1e3;
22719
22877
  const POLL_INTERVAL_MS = 2 * 1e3;
22720
- var XConnectTimedOut = class extends h("XConnectTimedOut")() {
22878
+ var XConnectTimedOut = class extends h("XConnectTimedOut") {
22721
22879
  constructor(args) {
22722
22880
  super({
22723
22881
  ...args,
@@ -22726,17 +22884,17 @@ var XConnectTimedOut = class extends h("XConnectTimedOut")() {
22726
22884
  this.name = "XConnectTimedOut";
22727
22885
  }
22728
22886
  };
22729
- var XBillingSeatTimedOut = class extends h("XBillingSeatTimedOut")() {
22730
- constructor() {
22887
+ var XConnectStepFailed = class extends h("XConnectStepFailed") {
22888
+ constructor(args) {
22731
22889
  super({
22732
- operation: "prepareAccountConnect",
22733
- timeoutMS: SEAT_POLL_TIMEOUT_MS,
22734
- message: "billing_seat_timed_out"
22890
+ operation: "connect",
22891
+ ...args,
22892
+ message: args.code
22735
22893
  });
22736
- this.name = "XBillingSeatTimedOut";
22894
+ this.name = "XConnectStepFailed";
22737
22895
  }
22738
22896
  };
22739
- var XAccountNotFound = class extends h("XAccountNotFound")() {
22897
+ var XAccountNotFound = class extends h("XAccountNotFound") {
22740
22898
  constructor(args) {
22741
22899
  super({
22742
22900
  ...args,
@@ -22745,9 +22903,17 @@ var XAccountNotFound = class extends h("XAccountNotFound")() {
22745
22903
  this.name = "XAccountNotFound";
22746
22904
  }
22747
22905
  };
22748
- h("XAccountNotConnected")();
22749
- h("XAccountRequired")();
22750
- var XInvalidSelector = class extends h("XInvalidSelector")() {
22906
+ var XReconnectRequiresConnect = class extends h("XReconnectRequiresConnect") {
22907
+ constructor(account) {
22908
+ super({
22909
+ operation: "reconnect",
22910
+ account,
22911
+ message: `X account ${account} is disconnected and its seat was released. Run \`social account connect x\` to connect it again.`
22912
+ });
22913
+ this.name = "XReconnectRequiresConnect";
22914
+ }
22915
+ };
22916
+ var XInvalidSelector = class extends h("XInvalidSelector") {
22751
22917
  constructor(args) {
22752
22918
  super({
22753
22919
  ...args,
@@ -22766,11 +22932,11 @@ const throwXLifecycleError = (error) => {
22766
22932
  const defaultSleep = async (ms) => {
22767
22933
  await new Promise((resolve) => setTimeout(resolve, ms));
22768
22934
  };
22769
- const connectURLFor = async (deps, reconnectProfileId) => {
22935
+ const reconnectURLFor = async (deps, reconnectProfileId) => {
22770
22936
  return (await deps.client.accounts.reconnectURL({
22771
22937
  platform: "x",
22772
- mode: reconnectProfileId ? "reconnect" : "create",
22773
- ...reconnectProfileId ? { account: `profile_id:${reconnectProfileId}` } : {}
22938
+ mode: "reconnect",
22939
+ account: `profile_id:${reconnectProfileId}`
22774
22940
  })).url;
22775
22941
  };
22776
22942
  const surfaceURL = (deps, url, options = {}) => {
@@ -22786,10 +22952,10 @@ const pollForAccount = async (deps, operation, matches) => {
22786
22952
  platform: "x",
22787
22953
  includeDisconnected: true
22788
22954
  })).find(matches);
22789
- if (account) return G.ok(account);
22955
+ if (account) return ae.ok(account);
22790
22956
  await sleep(POLL_INTERVAL_MS);
22791
22957
  }
22792
- return G.err(new XConnectTimedOut({
22958
+ return ae.err(new XConnectTimedOut({
22793
22959
  operation,
22794
22960
  timeoutMS: CONNECT_TIMEOUT_MS
22795
22961
  }));
@@ -22798,43 +22964,24 @@ const authURLFor = async (deps, operation) => ({
22798
22964
  url: deps.handshakeAuthURL ? await deps.handshakeAuthURL(operation) : await operation(),
22799
22965
  openingLogged: deps.handshakeAuthURL !== void 0
22800
22966
  });
22801
- const pollForSeat = async (deps) => {
22802
- const sleep = deps.sleep ?? defaultSleep;
22803
- const now = deps.now ?? Date.now;
22804
- const startedAt = now();
22805
- while (now() - startedAt < SEAT_POLL_TIMEOUT_MS) {
22806
- if ((await deps.client.billing.status()).canConnect) return G.ok();
22807
- await sleep(POLL_INTERVAL_MS);
22808
- }
22809
- return G.err(new XBillingSeatTimedOut());
22810
- };
22811
- const prepareAccountConnect = async (deps) => {
22812
- if ((await deps.client.billing.status()).canConnect) return G.ok();
22813
- const status = await deps.client.billing.prepareAccountConnect();
22814
- if (status.canConnect) return G.ok();
22815
- if (status.paymentURL) surfaceURL(deps, status.paymentURL);
22816
- return pollForSeat(deps);
22817
- };
22818
- const accountKey = (account) => account.profileId;
22819
- const timestampMS = (value) => value instanceof Date ? value.getTime() : void 0;
22820
22967
  const normalizeIdentifier = (value) => value.trim().replace(/^@+/, "").toLowerCase();
22821
22968
  const accountSelectorFor$1 = (account) => account.username ? `@${account.username.replace(/^@+/, "")}` : `profile_id:${account.profileId}`;
22822
22969
  const parseXAccountSelector = (target, operation) => {
22823
22970
  const trimmed = target.trim();
22824
22971
  if (trimmed.startsWith("profile_id:")) {
22825
22972
  const profileId = trimmed.slice(11).trim();
22826
- if (profileId && !/[/?#%]/.test(profileId)) return G.ok({
22973
+ if (profileId && !/[/?#%]/.test(profileId)) return ae.ok({
22827
22974
  kind: "profileId",
22828
22975
  normalized: profileId.toLowerCase(),
22829
22976
  raw: target
22830
22977
  });
22831
22978
  }
22832
- if (trimmed.startsWith("@") && !/[/?#%]/.test(trimmed)) return G.ok({
22979
+ if (trimmed.startsWith("@") && !/[/?#%]/.test(trimmed)) return ae.ok({
22833
22980
  kind: "username",
22834
22981
  normalized: normalizeIdentifier(trimmed),
22835
22982
  raw: target
22836
22983
  });
22837
- return G.err(new XInvalidSelector({
22984
+ return ae.err(new XInvalidSelector({
22838
22985
  operation,
22839
22986
  account: target
22840
22987
  }));
@@ -22843,55 +22990,59 @@ const findXLifecycleAccount = (accounts, selector) => {
22843
22990
  if (selector.kind === "profileId") return accounts.find((account) => account.profileId.toLowerCase() === selector.normalized);
22844
22991
  return accounts.find((account) => normalizeIdentifier(account.username) === selector.normalized);
22845
22992
  };
22846
- const listXLifecycleAccounts = async (deps, includeDisconnected) => G.ok(await deps.client.accounts.list({
22993
+ const listXLifecycleAccounts = async (deps, includeDisconnected) => ae.ok(await deps.client.accounts.list({
22847
22994
  platform: "x",
22848
22995
  includeDisconnected
22849
22996
  }));
22850
- /**
22851
- * Resolve the X connect/reconnect URL without opening a browser or polling.
22852
- * Lets a non-TTY caller advance a connect handshake one step at a time.
22853
- */
22854
- const createXConnectURL = (deps, reconnectProfileId) => connectURLFor(deps, reconnectProfileId);
22855
- const connectXAccount = async (deps) => {
22856
- const beforeResult = await listXLifecycleAccounts(deps, true);
22857
- if (G.isError(beforeResult)) return G.err(beforeResult.error);
22858
- const before = beforeResult.value;
22859
- const connectedBefore = new Set(before.filter((account) => account.status === "connected").map(accountKey));
22860
- const lastSeenBefore = new Map(before.filter((account) => account.status === "connected").map((account) => [accountKey(account), timestampMS(account.lastSeenAt)]));
22861
- const prepared = await prepareAccountConnect(deps);
22862
- if (G.isError(prepared)) return G.err(prepared.error);
22863
- const authURL = await authURLFor(deps, () => connectURLFor(deps));
22864
- surfaceURL(deps, authURL.url, { log: !authURL.openingLogged });
22865
- const account = await pollForAccount(deps, "connect", (candidate) => {
22866
- if (candidate.status !== "connected") return false;
22867
- if (!connectedBefore.has(candidate.profileId)) return true;
22868
- const previousLastSeen = lastSeenBefore.get(candidate.profileId);
22869
- const currentLastSeen = timestampMS(candidate.lastSeenAt);
22870
- return previousLastSeen !== void 0 && currentLastSeen !== void 0 && currentLastSeen > previousLastSeen;
22871
- });
22872
- if (G.isError(account)) return G.err(account.error);
22873
- return G.ok({
22874
- platform: "x",
22875
- status: "connected",
22876
- account: account.value
22877
- });
22997
+ const connectXAccount = async (deps, attemptId) => {
22998
+ const sleep = deps.sleep ?? defaultSleep;
22999
+ const now = deps.now ?? Date.now;
23000
+ const startedAt = now();
23001
+ let currentAttemptId = attemptId;
23002
+ const surfacedURLs = /* @__PURE__ */ new Set();
23003
+ while (now() - startedAt < CONNECT_TIMEOUT_MS) {
23004
+ const state = await deps.client.connectStep({
23005
+ platform: "x",
23006
+ ...currentAttemptId ? { attemptId: currentAttemptId } : {}
23007
+ });
23008
+ currentAttemptId = state.attemptId;
23009
+ if (state.status === "connected") return ae.ok({
23010
+ platform: "x",
23011
+ status: "connected",
23012
+ account: state.account
23013
+ });
23014
+ if (state.status === "expired" || state.status === "failed") return ae.err(new XConnectStepFailed(state));
23015
+ const url = state.status === "pending_billing" ? state.paymentURL : state.status === "pending_approval" ? state.connectURL : null;
23016
+ if (url && !surfacedURLs.has(url)) {
23017
+ surfacedURLs.add(url);
23018
+ surfaceURL(deps, url);
23019
+ } else if (state.status === "pending_billing" && state.requiredAction) deps.log?.(state.requiredAction.reason);
23020
+ await sleep(POLL_INTERVAL_MS);
23021
+ }
23022
+ return ae.err(new XConnectTimedOut({
23023
+ operation: "connect",
23024
+ timeoutMS: CONNECT_TIMEOUT_MS
23025
+ }));
22878
23026
  };
22879
23027
  const reconnectXAccount = async (deps, args) => {
22880
23028
  const selector = parseXAccountSelector(args.account, "reconnect");
22881
- if (G.isError(selector)) return G.err(selector.error);
23029
+ if (ae.isError(selector)) return ae.err(selector.error);
22882
23030
  const accountsResult = await listXLifecycleAccounts(deps, true);
22883
- if (G.isError(accountsResult)) return G.err(accountsResult.error);
23031
+ if (ae.isError(accountsResult)) return ae.err(accountsResult.error);
22884
23032
  const accounts = accountsResult.value;
22885
- const existing = findXLifecycleAccount(accounts, selector.value);
22886
- if (!existing) return G.err(new XAccountNotFound({
22887
- operation: "reconnect",
22888
- account: args.account
22889
- }));
22890
- const authURL = await authURLFor(deps, () => connectURLFor(deps, existing.profileId));
23033
+ const existing = findXLifecycleAccount(accounts.filter((account) => account.status !== "disconnected"), selector.value);
23034
+ if (!existing) {
23035
+ if (findXLifecycleAccount(accounts.filter((account) => account.status === "disconnected"), selector.value)) return ae.err(new XReconnectRequiresConnect(args.account));
23036
+ return ae.err(new XAccountNotFound({
23037
+ operation: "reconnect",
23038
+ account: args.account
23039
+ }));
23040
+ }
23041
+ const authURL = await authURLFor(deps, () => reconnectURLFor(deps, existing.profileId));
22891
23042
  surfaceURL(deps, authURL.url, { log: !authURL.openingLogged });
22892
23043
  const account = await pollForAccount(deps, "reconnect", (candidate) => candidate.profileId === existing.profileId && candidate.status === "connected");
22893
- if (G.isError(account)) return G.err(account.error);
22894
- return G.ok({
23044
+ if (ae.isError(account)) return ae.err(account.error);
23045
+ return ae.ok({
22895
23046
  platform: "x",
22896
23047
  status: "connected",
22897
23048
  account: account.value
@@ -22899,12 +23050,12 @@ const reconnectXAccount = async (deps, args) => {
22899
23050
  };
22900
23051
  const disconnectXAccount = async (deps, target) => {
22901
23052
  const selector = parseXAccountSelector(target, "disconnect");
22902
- if (G.isError(selector)) return G.err(selector.error);
23053
+ if (ae.isError(selector)) return ae.err(selector.error);
22903
23054
  const accountsResult = await listXLifecycleAccounts(deps);
22904
- if (G.isError(accountsResult)) return G.err(accountsResult.error);
23055
+ if (ae.isError(accountsResult)) return ae.err(accountsResult.error);
22905
23056
  const accounts = accountsResult.value;
22906
23057
  const account = findXLifecycleAccount(accounts, selector.value);
22907
- if (!account) return G.err(new XAccountNotFound({
23058
+ if (!account) return ae.err(new XAccountNotFound({
22908
23059
  operation: "disconnect",
22909
23060
  account: target
22910
23061
  }));
@@ -22912,14 +23063,14 @@ const disconnectXAccount = async (deps, target) => {
22912
23063
  platform: "x",
22913
23064
  account: accountSelectorFor$1(account)
22914
23065
  });
22915
- return G.ok({
23066
+ return ae.ok({
22916
23067
  platform: "x",
22917
23068
  account,
22918
23069
  result
22919
23070
  });
22920
23071
  };
22921
23072
  //#endregion
22922
- //#region ../../node_modules/.bun/@orpc+shared@1.14.8+e40b0dfdd726a224/node_modules/@orpc/shared/dist/index.mjs
23073
+ //#region ../../node_modules/.bun/@orpc+shared@1.14.14+e40b0dfdd726a224/node_modules/@orpc/shared/dist/index.mjs
22923
23074
  function resolveMaybeOptionalOptions(rest) {
22924
23075
  return rest[0] ?? {};
22925
23076
  }
@@ -22928,7 +23079,7 @@ function toArray(value) {
22928
23079
  }
22929
23080
  const ORPC_NAME = "orpc";
22930
23081
  const ORPC_SHARED_PACKAGE_NAME = "@orpc/shared";
22931
- const ORPC_SHARED_PACKAGE_VERSION = "1.14.8";
23082
+ const ORPC_SHARED_PACKAGE_VERSION = "1.14.14";
22932
23083
  var AbortError$1 = class extends Error {
22933
23084
  constructor(...rest) {
22934
23085
  super(...rest);
@@ -23157,9 +23308,9 @@ function tryDecodeURIComponent(value) {
23157
23308
  }
23158
23309
  }
23159
23310
  //#endregion
23160
- //#region ../../node_modules/.bun/@orpc+client@1.14.8+e40b0dfdd726a224/node_modules/@orpc/client/dist/shared/client.DTC9NNUo.mjs
23311
+ //#region ../../node_modules/.bun/@orpc+client@1.14.14+e40b0dfdd726a224/node_modules/@orpc/client/dist/shared/client.RnCVAXCj.mjs
23161
23312
  const ORPC_CLIENT_PACKAGE_NAME = "@orpc/client";
23162
- const ORPC_CLIENT_PACKAGE_VERSION = "1.14.8";
23313
+ const ORPC_CLIENT_PACKAGE_VERSION = "1.14.14";
23163
23314
  const COMMON_ORPC_ERROR_DEFS = {
23164
23315
  BAD_REQUEST: {
23165
23316
  status: 400,
@@ -23323,7 +23474,7 @@ function createORPCErrorFromJson(json, options = {}) {
23323
23474
  });
23324
23475
  }
23325
23476
  //#endregion
23326
- //#region ../../node_modules/.bun/@orpc+standard-server@1.14.8+e40b0dfdd726a224/node_modules/@orpc/standard-server/dist/index.mjs
23477
+ //#region ../../node_modules/.bun/@orpc+standard-server@1.14.14+e40b0dfdd726a224/node_modules/@orpc/standard-server/dist/index.mjs
23327
23478
  var EventEncoderError = class extends TypeError {};
23328
23479
  var EventDecoderError = class extends TypeError {};
23329
23480
  var ErrorEvent = class extends Error {
@@ -23333,8 +23484,13 @@ var ErrorEvent = class extends Error {
23333
23484
  this.data = options?.data;
23334
23485
  }
23335
23486
  };
23487
+ const LINE_ENDING_REGEX$1 = /\r\n|\r(?!\n)|\n/;
23488
+ const MESSAGE_DELIMITER_REGEX = /(?:\r\n|\r(?!\n)|\n){2}/;
23489
+ const MESSAGE_DELIMITER_GLOBAL_REGEX = /(?:\r\n|\r(?!\n)|\n){2}/g;
23490
+ const CR = 13;
23491
+ const LF = 10;
23492
+ const SPACE = 32;
23336
23493
  function decodeEventMessage(encoded) {
23337
- const lines = encoded.replace(/\n+$/, "").split(/\n/);
23338
23494
  const message = {
23339
23495
  data: void 0,
23340
23496
  event: void 0,
@@ -23342,45 +23498,77 @@ function decodeEventMessage(encoded) {
23342
23498
  retry: void 0,
23343
23499
  comments: []
23344
23500
  };
23345
- for (const line of lines) {
23501
+ for (const line of encoded.split(LINE_ENDING_REGEX$1)) {
23502
+ if (line === "") continue;
23346
23503
  const index = line.indexOf(":");
23347
- const key = index === -1 ? line : line.slice(0, index);
23348
- const value = index === -1 ? "" : line.slice(index + 1).replace(/^\s/, "");
23349
- if (index === 0) message.comments.push(value);
23350
- else if (key === "data") {
23351
- message.data ??= "";
23352
- message.data += `${value}
23353
- `;
23354
- } else if (key === "event") message.event = value;
23355
- else if (key === "id") message.id = value;
23356
- else if (key === "retry") {
23357
- const maybeInteger = Number.parseInt(value);
23358
- if (Number.isInteger(maybeInteger) && maybeInteger >= 0 && maybeInteger.toString() === value) message.retry = maybeInteger;
23504
+ const value = index === -1 ? "" : line.slice(line.charCodeAt(index + 1) === SPACE ? index + 2 : index + 1);
23505
+ if (index === 0) {
23506
+ message.comments.push(value);
23507
+ continue;
23508
+ }
23509
+ switch (index === -1 ? line : line.slice(0, index)) {
23510
+ case "data":
23511
+ message.data = message.data === void 0 ? value : `${message.data}
23512
+ ${value}`;
23513
+ break;
23514
+ case "event":
23515
+ message.event = value;
23516
+ break;
23517
+ case "id":
23518
+ message.id = value;
23519
+ break;
23520
+ case "retry": {
23521
+ const maybeInteger = Number.parseInt(value, 10);
23522
+ if (maybeInteger >= 0 && maybeInteger.toString() === value) message.retry = maybeInteger;
23523
+ break;
23524
+ }
23359
23525
  }
23360
23526
  }
23361
- message.data = message.data?.replace(/\n$/, "");
23362
23527
  return message;
23363
23528
  }
23364
23529
  var EventDecoder = class {
23365
23530
  constructor(options = {}) {
23366
23531
  this.options = options;
23367
23532
  }
23368
- incomplete = "";
23533
+ pending = [];
23534
+ tail = "";
23535
+ discardLeadingLF = false;
23369
23536
  feed(chunk) {
23370
- this.incomplete += chunk;
23371
- const lastCompleteIndex = this.incomplete.lastIndexOf("\n\n");
23372
- if (lastCompleteIndex === -1) return;
23373
- const completes = this.incomplete.slice(0, lastCompleteIndex).split(/\n\n/);
23374
- this.incomplete = this.incomplete.slice(lastCompleteIndex + 2);
23375
- for (const encoded of completes) {
23376
- const message = decodeEventMessage(`${encoded}
23377
-
23378
- `);
23537
+ if (chunk === "") return;
23538
+ if (this.discardLeadingLF) {
23539
+ this.discardLeadingLF = false;
23540
+ if (chunk.charCodeAt(0) === LF) {
23541
+ chunk = chunk.slice(1);
23542
+ if (chunk === "") return;
23543
+ }
23544
+ }
23545
+ const scan = this.tail + chunk;
23546
+ if (!MESSAGE_DELIMITER_REGEX.test(scan)) {
23547
+ this.pending.push(chunk);
23548
+ this.tail = scan.slice(-3);
23549
+ return;
23550
+ }
23551
+ this.pending.push(chunk);
23552
+ const buffered = this.pending.length === 1 ? chunk : this.pending.join("");
23553
+ const offset = buffered.length - scan.length;
23554
+ const parts = [];
23555
+ let start = 0;
23556
+ for (const match of scan.matchAll(MESSAGE_DELIMITER_GLOBAL_REGEX)) {
23557
+ parts.push(buffered.slice(start, offset + match.index));
23558
+ start = offset + match.index + match[0].length;
23559
+ }
23560
+ const incomplete = buffered.slice(start);
23561
+ this.pending.length = 0;
23562
+ this.tail = incomplete.slice(-3);
23563
+ if (incomplete === "") this.discardLeadingLF = chunk.charCodeAt(chunk.length - 1) === CR;
23564
+ else this.pending.push(incomplete);
23565
+ for (const encoded of parts) {
23566
+ const message = decodeEventMessage(encoded);
23379
23567
  if (this.options.onEvent) this.options.onEvent(message);
23380
23568
  }
23381
23569
  }
23382
23570
  end() {
23383
- if (this.incomplete) throw new EventDecoderError("Event Iterator ended before complete");
23571
+ if (this.pending.length !== 0) throw new EventDecoderError("Event Iterator ended before complete");
23384
23572
  }
23385
23573
  };
23386
23574
  var EventDecoderStream = class extends TransformStream {
@@ -23401,24 +23589,27 @@ var EventDecoderStream = class extends TransformStream {
23401
23589
  });
23402
23590
  }
23403
23591
  };
23592
+ const LINE_ENDING_REGEX = /\r\n|[\n\r]/;
23593
+ const LINE_ENDING_GLOBAL_REGEX = /\r\n|[\n\r]/g;
23594
+ function containsLineBreak(value) {
23595
+ return LINE_ENDING_REGEX.test(value);
23596
+ }
23404
23597
  function assertEventId(id) {
23405
- if (id.includes("\n")) throw new EventEncoderError("Event's id must not contain a newline character");
23598
+ if (containsLineBreak(id)) throw new EventEncoderError("Event's id must not contain a carriage return or newline character");
23406
23599
  }
23407
23600
  function assertEventName(event) {
23408
- if (event.includes("\n")) throw new EventEncoderError("Event's event must not contain a newline character");
23601
+ if (containsLineBreak(event)) throw new EventEncoderError("Event's event must not contain a carriage return or newline character");
23409
23602
  }
23410
23603
  function assertEventRetry(retry) {
23411
23604
  if (!Number.isInteger(retry) || retry < 0) throw new EventEncoderError("Event's retry must be a integer and >= 0");
23412
23605
  }
23413
23606
  function assertEventComment(comment) {
23414
- if (comment.includes("\n")) throw new EventEncoderError("Event's comment must not contain a newline character");
23607
+ if (containsLineBreak(comment)) throw new EventEncoderError("Event's comment must not contain a carriage return or newline character");
23415
23608
  }
23416
23609
  function encodeEventData(data) {
23417
- const lines = data?.split(/\n/) ?? [];
23418
- let output = "";
23419
- for (const line of lines) output += `data: ${line}
23610
+ if (data === void 0) return "";
23611
+ return `data: ${data.replace(LINE_ENDING_GLOBAL_REGEX, "\ndata: ")}
23420
23612
  `;
23421
- return output;
23422
23613
  }
23423
23614
  function encodeEventComments(comments) {
23424
23615
  let output = "";
@@ -23483,7 +23674,7 @@ function mergeStandardHeaders(a, b) {
23483
23674
  return merged;
23484
23675
  }
23485
23676
  //#endregion
23486
- //#region ../../node_modules/.bun/@orpc+client@1.14.8+e40b0dfdd726a224/node_modules/@orpc/client/dist/shared/client.BLtwTQUg.mjs
23677
+ //#region ../../node_modules/.bun/@orpc+client@1.14.14+e40b0dfdd726a224/node_modules/@orpc/client/dist/shared/client.BLtwTQUg.mjs
23487
23678
  function mapEventIterator(iterator, maps) {
23488
23679
  const mapError = async (error) => {
23489
23680
  let mappedError = await maps.error(error);
@@ -23519,7 +23710,7 @@ function mapEventIterator(iterator, maps) {
23519
23710
  });
23520
23711
  }
23521
23712
  //#endregion
23522
- //#region ../../node_modules/.bun/@orpc+client@1.14.8+e40b0dfdd726a224/node_modules/@orpc/client/dist/index.mjs
23713
+ //#region ../../node_modules/.bun/@orpc+client@1.14.14+e40b0dfdd726a224/node_modules/@orpc/client/dist/index.mjs
23523
23714
  function resolveFriendlyClientOptions(options) {
23524
23715
  return {
23525
23716
  ...options,
@@ -23540,7 +23731,7 @@ function createORPCClient(link, options = {}) {
23540
23731
  } }));
23541
23732
  }
23542
23733
  //#endregion
23543
- //#region ../../node_modules/.bun/@orpc+standard-server-fetch@1.14.8+e40b0dfdd726a224/node_modules/@orpc/standard-server-fetch/dist/index.mjs
23734
+ //#region ../../node_modules/.bun/@orpc+standard-server-fetch@1.14.14+e40b0dfdd726a224/node_modules/@orpc/standard-server-fetch/dist/index.mjs
23544
23735
  function toEventIterator(stream, options = {}) {
23545
23736
  const reader = (stream?.pipeThrough(new TextDecoderStream()).pipeThrough(new EventDecoderStream()))?.getReader();
23546
23737
  let span;
@@ -23767,7 +23958,7 @@ function toStandardLazyResponse(response, options = {}) {
23767
23958
  };
23768
23959
  }
23769
23960
  //#endregion
23770
- //#region ../../node_modules/.bun/@orpc+client@1.14.8+e40b0dfdd726a224/node_modules/@orpc/client/dist/shared/client.BtFSa_yX.mjs
23961
+ //#region ../../node_modules/.bun/@orpc+client@1.14.14+e40b0dfdd726a224/node_modules/@orpc/client/dist/shared/client.Neryp5z6.mjs
23771
23962
  var CompositeStandardLinkPlugin = class {
23772
23963
  plugins;
23773
23964
  constructor(plugins = []) {
@@ -24163,7 +24354,7 @@ var StandardRPCLink = class extends StandardLink {
24163
24354
  }
24164
24355
  };
24165
24356
  //#endregion
24166
- //#region ../../node_modules/.bun/@orpc+client@1.14.8+e40b0dfdd726a224/node_modules/@orpc/client/dist/adapters/fetch/index.mjs
24357
+ //#region ../../node_modules/.bun/@orpc+client@1.14.14+e40b0dfdd726a224/node_modules/@orpc/client/dist/adapters/fetch/index.mjs
24167
24358
  var CompositeLinkFetchPlugin = class extends CompositeStandardLinkPlugin {
24168
24359
  initRuntimeAdapter(options) {
24169
24360
  for (const plugin of this.plugins) plugin.initRuntimeAdapter?.(options);
@@ -24279,7 +24470,7 @@ function createEnv(opts) {
24279
24470
  }
24280
24471
  //#endregion
24281
24472
  //#region package.json
24282
- var version$1 = "0.18.3";
24473
+ var version$1 = "0.19.0";
24283
24474
  //#endregion
24284
24475
  //#region src/lib/env.ts
24285
24476
  const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
@@ -25406,23 +25597,39 @@ const configCommand = defineCommand({
25406
25597
  })
25407
25598
  }
25408
25599
  });
25409
- const BillingOutput = object({
25410
- seats: object({
25411
- total: number().int().nonnegative(),
25412
- used: number().int().nonnegative(),
25413
- available: number().int().nonnegative()
25414
- }),
25415
- subscription: object({
25416
- active: boolean$1(),
25417
- quantity: number().int().nonnegative(),
25418
- currentPeriodEnd: string().nullable()
25419
- }).nullable(),
25420
- usage: object({
25421
- calls: number().int().nonnegative(),
25422
- credit: number().nonnegative(),
25423
- cost: number().nonnegative()
25424
- })
25600
+ //#endregion
25601
+ //#region src/billing/index.ts
25602
+ const SeatsOutput = object({
25603
+ total: number().int().nonnegative(),
25604
+ used: number().int().nonnegative(),
25605
+ available: number().int().nonnegative()
25425
25606
  });
25607
+ const SubscriptionOutput = object({
25608
+ active: boolean$1(),
25609
+ quantity: number().int().nonnegative(),
25610
+ currentPeriodEnd: string().nullable(),
25611
+ canceling: boolean$1(),
25612
+ canceledAt: string().nullable()
25613
+ }).nullable();
25614
+ const UsageSummaryOutput$1 = object({
25615
+ calls: number().int().nonnegative(),
25616
+ credit: number().nonnegative(),
25617
+ cost: number().nonnegative()
25618
+ });
25619
+ const ProviderBillingOutput = object({
25620
+ platform: _enum(["linkedin", "x"]),
25621
+ plan: object({
25622
+ id: string(),
25623
+ name: string()
25624
+ }),
25625
+ seats: SeatsOutput,
25626
+ canConnect: boolean$1(),
25627
+ subscription: SubscriptionOutput
25628
+ });
25629
+ const BillingOutput = object({ providers: object({
25630
+ linkedin: ProviderBillingOutput,
25631
+ x: ProviderBillingOutput.extend({ usage: UsageSummaryOutput$1 })
25632
+ }) });
25426
25633
  const BillingPortalOutput = object({
25427
25634
  url: string(),
25428
25635
  opened: boolean$1()
@@ -25468,11 +25675,13 @@ const createBillingCommand = (deps = {}) => {
25468
25675
  run: async () => {
25469
25676
  const client = clientFrom(deps);
25470
25677
  const [status, usage] = await Promise.all([client.billing.status(), client.usage.summary({})]);
25471
- await writeOutput$2(deps, {
25472
- seats: status.seats,
25473
- subscription: status.subscription,
25474
- usage: usageSummaryForOutput(usage)
25475
- });
25678
+ await writeOutput$2(deps, { providers: {
25679
+ linkedin: status.providers.linkedin,
25680
+ x: {
25681
+ ...status.providers.x,
25682
+ usage: usageSummaryForOutput(usage)
25683
+ }
25684
+ } });
25476
25685
  }
25477
25686
  });
25478
25687
  };
@@ -25482,16 +25691,16 @@ const CLI_SCOPE_ALIASES = ["read", "read,write"];
25482
25691
  `${productBrand.name}`, `${productBrand.name}`;
25483
25692
  const isCLIScopeAlias = (scope) => CLI_SCOPE_ALIASES.some((alias) => alias === scope);
25484
25693
  const parseDeviceScopeAlias = (scope) => {
25485
- if (!isCLIScopeAlias(scope)) return G.err({
25694
+ if (!isCLIScopeAlias(scope)) return ae.err({
25486
25695
  code: "invalid_device_authorization_scope",
25487
25696
  scope
25488
25697
  });
25489
- return G.ok(scope);
25698
+ return ae.ok(scope);
25490
25699
  };
25491
25700
  const parseCLIScopeAlias = parseDeviceScopeAlias;
25492
25701
  const scopeAliasFromAccessChoices$1 = (choices) => choices.includes("write") ? "read,write" : "read";
25493
25702
  //#endregion
25494
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
25703
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
25495
25704
  function createModulerModifier() {
25496
25705
  const getModuleFromFileName = createGetModuleFromFilename();
25497
25706
  return async (frames) => {
@@ -25521,7 +25730,7 @@ function normalizeWindowsPath(path) {
25521
25730
  return path.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
25522
25731
  }
25523
25732
  //#endregion
25524
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/featureFlagUtils.mjs
25733
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/featureFlagUtils.mjs
25525
25734
  const normalizeFlagsResponse = (flagsResponse) => {
25526
25735
  if ("flags" in flagsResponse) {
25527
25736
  const featureFlags = getFlagValuesFromFlags(flagsResponse.flags);
@@ -25578,8 +25787,67 @@ const parsePayload = (response) => {
25578
25787
  return response;
25579
25788
  }
25580
25789
  };
25790
+ const MINIMAL_FLAG_CALLED_EVENT_PROPERTIES = [
25791
+ "$feature_flag",
25792
+ "$feature_flag_response",
25793
+ "$feature_flag_has_experiment",
25794
+ "$feature_flag_id",
25795
+ "$feature_flag_version",
25796
+ "$feature_flag_reason",
25797
+ "$feature_flag_request_id",
25798
+ "$feature_flag_evaluated_at",
25799
+ "$feature_flag_error",
25800
+ "locally_evaluated",
25801
+ "$groups",
25802
+ "$process_person_profile",
25803
+ "$geoip_disable",
25804
+ "$current_url",
25805
+ "$pathname",
25806
+ "$referring_domain",
25807
+ ...[
25808
+ "utm_source",
25809
+ "utm_medium",
25810
+ "utm_campaign",
25811
+ "utm_content",
25812
+ "utm_term",
25813
+ "gad_source",
25814
+ "mc_cid",
25815
+ "gclid",
25816
+ "gclsrc",
25817
+ "dclid",
25818
+ "gbraid",
25819
+ "wbraid",
25820
+ "fbclid",
25821
+ "msclkid",
25822
+ "twclid",
25823
+ "li_fat_id",
25824
+ "igshid",
25825
+ "ttclid",
25826
+ "rdt_cid",
25827
+ "epik",
25828
+ "qclid",
25829
+ "sccid",
25830
+ "irclid",
25831
+ "_kx"
25832
+ ],
25833
+ "$session_id",
25834
+ "$window_id",
25835
+ "$lib",
25836
+ "$lib_version",
25837
+ "$device_id",
25838
+ "$is_server"
25839
+ ];
25840
+ const minimizeFlagCalledEventProperties = (properties, transportKeys = []) => {
25841
+ const minimal = {};
25842
+ const copyKey = (key) => {
25843
+ if (void 0 !== properties[key]) minimal[key] = properties[key];
25844
+ };
25845
+ MINIMAL_FLAG_CALLED_EVENT_PROPERTIES.forEach(copyKey);
25846
+ transportKeys.forEach(copyKey);
25847
+ return minimal;
25848
+ };
25581
25849
  //#endregion
25582
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/types.mjs
25850
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/types.mjs
25583
25851
  var types_PostHogPersistedProperty = /*#__PURE__*/ function(PostHogPersistedProperty) {
25584
25852
  PostHogPersistedProperty["AnonymousId"] = "anonymous_id";
25585
25853
  PostHogPersistedProperty["DistinctId"] = "distinct_id";
@@ -25615,7 +25883,7 @@ var types_PostHogPersistedProperty = /*#__PURE__*/ function(PostHogPersistedProp
25615
25883
  return PostHogPersistedProperty;
25616
25884
  }({});
25617
25885
  //#endregion
25618
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/gzip.mjs
25886
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/gzip.mjs
25619
25887
  function isGzipSupported() {
25620
25888
  return "CompressionStream" in globalThis && "TextEncoder" in globalThis && "Response" in globalThis && "function" == typeof Response.prototype.blob;
25621
25889
  }
@@ -25677,7 +25945,7 @@ async function gzipCompress(input, isDebug = true, options) {
25677
25945
  }
25678
25946
  }
25679
25947
  //#endregion
25680
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/utils/bot-detection.mjs
25948
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/utils/bot-detection.mjs
25681
25949
  const DEFAULT_BLOCKED_UA_STRS = [
25682
25950
  "amazonbot",
25683
25951
  "amazonproductbot",
@@ -25766,7 +26034,7 @@ const isBlockedUA = function(ua, customBlockedUserAgents = []) {
25766
26034
  });
25767
26035
  };
25768
26036
  //#endregion
25769
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/utils/string-utils.mjs
26037
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/utils/string-utils.mjs
25770
26038
  function safeJsonStringify(value) {
25771
26039
  const ancestors = [];
25772
26040
  return JSON.stringify(value, function(_key, replacementValue) {
@@ -25786,7 +26054,7 @@ function safeJsonStringify(value) {
25786
26054
  }) ?? "null";
25787
26055
  }
25788
26056
  //#endregion
25789
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/utils/type-utils.mjs
26057
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/utils/type-utils.mjs
25790
26058
  const nativeIsArray = Array.isArray;
25791
26059
  const ObjProto = Object.prototype;
25792
26060
  ObjProto.hasOwnProperty;
@@ -25801,13 +26069,22 @@ const isEmptyString = (x) => isString$1(x) && 0 === x.trim().length;
25801
26069
  const isNull = (x) => null === x;
25802
26070
  const isNumber = (x) => "[object Number]" == type_utils_toString.call(x) && x === x;
25803
26071
  const isBoolean = (x) => "[object Boolean]" === type_utils_toString.call(x);
25804
- const isPlainError = (x) => x instanceof Error;
25805
26072
  function isPrimitive(value) {
25806
26073
  return null === value || "object" != typeof value;
25807
26074
  }
25808
26075
  function isBuiltin(candidate, className) {
25809
26076
  return Object.prototype.toString.call(candidate) === `[object ${className}]`;
25810
26077
  }
26078
+ function isError$1(candidate) {
26079
+ switch (Object.prototype.toString.call(candidate)) {
26080
+ case "[object Error]":
26081
+ case "[object Exception]":
26082
+ case "[object DOMException]":
26083
+ case "[object DOMError]":
26084
+ case "[object WebAssembly.Exception]": return true;
26085
+ default: return isInstanceOf(candidate, Error);
26086
+ }
26087
+ }
25811
26088
  function isEvent(candidate) {
25812
26089
  return "undefined" != typeof Event && isInstanceOf(candidate, Event);
25813
26090
  }
@@ -25822,7 +26099,7 @@ function isInstanceOf(candidate, base) {
25822
26099
  }
25823
26100
  }
25824
26101
  //#endregion
25825
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/utils/number-utils.mjs
26102
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/utils/number-utils.mjs
25826
26103
  function clampToRange(value, min, max, logger, fallbackValue) {
25827
26104
  if (min > max) {
25828
26105
  logger.warn("min cannot be greater than max.");
@@ -25840,7 +26117,7 @@ function clampToRange(value, min, max, logger, fallbackValue) {
25840
26117
  return clampToRange(fallbackValue || max, min, max, logger);
25841
26118
  }
25842
26119
  //#endregion
25843
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
26120
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
25844
26121
  const ONE_DAY_IN_MS = 864e5;
25845
26122
  function resolveExceptionRateLimiterConfig(config = {}) {
25846
26123
  return {
@@ -25886,8 +26163,10 @@ var BucketedRateLimiter = class {
25886
26163
  this._buckets = {};
25887
26164
  }
25888
26165
  };
26166
+ Date.prototype.getTime;
26167
+ Date.prototype.toISOString;
25889
26168
  //#endregion
25890
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
26169
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
25891
26170
  /*! For license information please see uuidv7.mjs.LICENSE.txt */
25892
26171
  /**
25893
26172
  * uuidv7: An experimental implementation of the proposed UUID Version 7
@@ -26053,7 +26332,7 @@ let defaultGenerator;
26053
26332
  const uuidv7 = () => uuidv7obj().toString();
26054
26333
  const uuidv7obj = () => (defaultGenerator || (defaultGenerator = new V7Generator())).generate();
26055
26334
  //#endregion
26056
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/utils/promise-queue.mjs
26335
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/utils/promise-queue.mjs
26057
26336
  var PromiseQueue = class {
26058
26337
  add(promise) {
26059
26338
  const promiseUUID = uuidv7();
@@ -26092,7 +26371,7 @@ var PromiseQueue = class {
26092
26371
  }
26093
26372
  };
26094
26373
  //#endregion
26095
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/utils/logger.mjs
26374
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/utils/logger.mjs
26096
26375
  function createConsole(consoleLike = console) {
26097
26376
  return {
26098
26377
  log: consoleLike.log.bind(consoleLike),
@@ -26132,7 +26411,7 @@ function createLogger(prefix, maybeCall = passThrough) {
26132
26411
  return _createLogger(prefix, maybeCall, createConsole());
26133
26412
  }
26134
26413
  //#endregion
26135
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
26414
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
26136
26415
  const MOBILE = "Mobile";
26137
26416
  const TABLET = "Tablet";
26138
26417
  const NINTENDO = "Nintendo";
@@ -26144,7 +26423,7 @@ const WINDOWS = "Windows";
26144
26423
  new RegExp(XBOX, "i");
26145
26424
  new RegExp(NINTENDO, "i"), new RegExp(PLAYSTATION, "i"), new RegExp(WINDOWS, "i");
26146
26425
  //#endregion
26147
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/utils/index.mjs
26426
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/utils/index.mjs
26148
26427
  const STRING_FORMAT = "utf8";
26149
26428
  const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
26150
26429
  function isValidUUID(value) {
@@ -26177,6 +26456,23 @@ function safeSetTimeout(fn, timeout) {
26177
26456
  t?.unref && t?.unref();
26178
26457
  return t;
26179
26458
  }
26459
+ async function raceWithTimeout(promise, timeoutMs, onTimeout) {
26460
+ let timeoutHandle;
26461
+ try {
26462
+ return await Promise.race([promise, new Promise((resolve, reject) => {
26463
+ timeoutHandle = safeSetTimeout(() => {
26464
+ try {
26465
+ onTimeout?.();
26466
+ resolve();
26467
+ } catch (error) {
26468
+ reject(error);
26469
+ }
26470
+ }, timeoutMs);
26471
+ })]);
26472
+ } finally {
26473
+ clearTimeout(timeoutHandle);
26474
+ }
26475
+ }
26180
26476
  const isError = (x) => x instanceof Error;
26181
26477
  function allSettled(promises) {
26182
26478
  return Promise.all(promises.map((p) => (p ?? Promise.resolve()).then((value) => ({
@@ -26240,7 +26536,7 @@ function toOtlpKeyValueList(attrs) {
26240
26536
  return result;
26241
26537
  }
26242
26538
  //#endregion
26243
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/metrics/metrics-utils.mjs
26539
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/metrics/metrics-utils.mjs
26244
26540
  const DEFAULT_HISTOGRAM_BOUNDS = [
26245
26541
  0,
26246
26542
  5,
@@ -26293,7 +26589,7 @@ function buildOtlpMetricsPayload(metrics, resourceAttributes, scopeName, scopeVe
26293
26589
  }] };
26294
26590
  }
26295
26591
  //#endregion
26296
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/metrics/config.mjs
26592
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/metrics/config.mjs
26297
26593
  const DEFAULT_FLUSH_INTERVAL_MS = 1e4;
26298
26594
  const DEFAULT_MAX_SERIES_PER_FLUSH = 1e3;
26299
26595
  function resolveMetricsConfig(config) {
@@ -26309,7 +26605,7 @@ function resolveMetricsConfig(config) {
26309
26605
  };
26310
26606
  }
26311
26607
  //#endregion
26312
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/metrics/index.mjs
26608
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/metrics/index.mjs
26313
26609
  const OTLP_TEMPORALITY_DELTA = 1;
26314
26610
  var PostHogMetrics = class {
26315
26611
  constructor(_instance, _config, _logger) {
@@ -26595,7 +26891,7 @@ var PostHogMetrics = class {
26595
26891
  }
26596
26892
  };
26597
26893
  //#endregion
26598
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/eventemitter.mjs
26894
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/eventemitter.mjs
26599
26895
  var SimpleEventEmitter = class {
26600
26896
  constructor() {
26601
26897
  this.events = {};
@@ -26614,7 +26910,7 @@ var SimpleEventEmitter = class {
26614
26910
  }
26615
26911
  };
26616
26912
  //#endregion
26617
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
26913
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
26618
26914
  let parsedStackResults;
26619
26915
  let lastKeysCount;
26620
26916
  let cachedFilenameChunkIds;
@@ -26645,7 +26941,7 @@ function getFilenameToChunkIdMap(stackParser) {
26645
26941
  return cachedFilenameChunkIds;
26646
26942
  }
26647
26943
  //#endregion
26648
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
26944
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
26649
26945
  const MAX_CAUSE_RECURSION = 4;
26650
26946
  var ErrorPropertiesBuilder = class {
26651
26947
  constructor(coercers, stackParser, modifiers = []) {
@@ -26760,14 +27056,14 @@ function createFrame(platform, filename, func, lineno, colno) {
26760
27056
  return frame;
26761
27057
  }
26762
27058
  //#endregion
26763
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
27059
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
26764
27060
  const extractSafariExtensionDetails = (func, filename) => {
26765
27061
  const isSafariExtension = -1 !== func.indexOf("safari-extension");
26766
27062
  const isSafariWebExtension = -1 !== func.indexOf("safari-web-extension");
26767
27063
  return isSafariExtension || isSafariWebExtension ? [-1 !== func.indexOf("@") ? func.split("@")[0] : "?", isSafariExtension ? `safari-extension:${filename}` : `safari-web-extension:${filename}`] : [func, filename];
26768
27064
  };
26769
27065
  //#endregion
26770
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
27066
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
26771
27067
  const chromeRegexNoFnName = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i;
26772
27068
  const chromeRegex = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
26773
27069
  const chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
@@ -26792,7 +27088,7 @@ const chromeStackLineParser = (line, platform) => {
26792
27088
  }
26793
27089
  };
26794
27090
  //#endregion
26795
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
27091
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
26796
27092
  const geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
26797
27093
  const geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
26798
27094
  const geckoStackLineParser = (line, platform) => {
@@ -26814,9 +27110,12 @@ const geckoStackLineParser = (line, platform) => {
26814
27110
  }
26815
27111
  };
26816
27112
  //#endregion
26817
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
27113
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
26818
27114
  const FILENAME_MATCH = /^\s*[-]{4,}$/;
26819
27115
  const FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
27116
+ const PROMISE_COMBINATOR = /^Promise\.(?:all|any)$/;
27117
+ const PROMISE_INDEX = /^index \d+$/;
27118
+ const PROMISE_FRAME_FILENAME = "node:internal/promise";
26820
27119
  const nodeStackLineParser = (line, platform) => {
26821
27120
  const lineMatch = line.match(FULL_MATCH);
26822
27121
  if (lineMatch) {
@@ -26856,6 +27155,7 @@ const nodeStackLineParser = (line, platform) => {
26856
27155
  const isNative = "native" === lineMatch[5];
26857
27156
  if (filename?.match(/\/[A-Z]:/)) filename = filename.slice(1);
26858
27157
  if (!filename && lineMatch[5] && !isNative) filename = lineMatch[5];
27158
+ if (PROMISE_COMBINATOR.test(functionName) && PROMISE_INDEX.test(filename || "")) filename = PROMISE_FRAME_FILENAME;
26859
27159
  return {
26860
27160
  filename: filename ? decodeURI(filename) : void 0,
26861
27161
  module: void 0,
@@ -26878,7 +27178,7 @@ function _parseIntOrUndefined(input) {
26878
27178
  return parseInt(input || "", 10) || void 0;
26879
27179
  }
26880
27180
  //#endregion
26881
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
27181
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
26882
27182
  const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
26883
27183
  const STACKTRACE_FRAME_LIMIT = 50;
26884
27184
  function reverseAndStripFrames(stack) {
@@ -26920,10 +27220,10 @@ function createStackParser(platform, ...parsers) {
26920
27220
  };
26921
27221
  }
26922
27222
  //#endregion
26923
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
27223
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
26924
27224
  var ErrorCoercer = class {
26925
27225
  match(err) {
26926
- return isPlainError(err);
27226
+ return isError$1(err);
26927
27227
  }
26928
27228
  coerce(err, ctx) {
26929
27229
  return {
@@ -26947,7 +27247,7 @@ var ErrorCoercer = class {
26947
27247
  }
26948
27248
  };
26949
27249
  //#endregion
26950
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
27250
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
26951
27251
  const ERROR_TYPES_PATTERN = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
26952
27252
  var StringCoercer = class {
26953
27253
  match(input) {
@@ -26974,7 +27274,7 @@ var StringCoercer = class {
26974
27274
  }
26975
27275
  };
26976
27276
  //#endregion
26977
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/types.mjs
27277
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/types.mjs
26978
27278
  const severityLevels = [
26979
27279
  "fatal",
26980
27280
  "error",
@@ -26984,7 +27284,7 @@ const severityLevels = [
26984
27284
  "debug"
26985
27285
  ];
26986
27286
  //#endregion
26987
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
27287
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
26988
27288
  function extractExceptionKeysForMessage(err, maxLength = 40) {
26989
27289
  const keys = Object.keys(err);
26990
27290
  keys.sort();
@@ -26999,7 +27299,7 @@ function extractExceptionKeysForMessage(err, maxLength = 40) {
26999
27299
  return "";
27000
27300
  }
27001
27301
  //#endregion
27002
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
27302
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
27003
27303
  var ObjectCoercer = class {
27004
27304
  match(candidate) {
27005
27305
  return "object" == typeof candidate && null !== candidate;
@@ -27010,7 +27310,7 @@ var ObjectCoercer = class {
27010
27310
  return {
27011
27311
  type: this.getType(candidate),
27012
27312
  value: this.getValue(candidate),
27013
- stack: ctx.syntheticException?.stack,
27313
+ stack: this.getStack(candidate) ?? ctx.syntheticException?.stack,
27014
27314
  level: this.isSeverityLevel(candidate.level) ? candidate.level : "error",
27015
27315
  synthetic: true
27016
27316
  };
@@ -27032,6 +27332,14 @@ var ObjectCoercer = class {
27032
27332
  isSeverityLevel(x) {
27033
27333
  return isString$1(x) && !isEmptyString(x) && severityLevels.indexOf(x) >= 0;
27034
27334
  }
27335
+ getStack(candidate) {
27336
+ try {
27337
+ if (isString$1(candidate.stacktrace) && candidate.stacktrace.length > 0) return candidate.stacktrace;
27338
+ return isString$1(candidate.stack) && candidate.stack.length > 0 ? candidate.stack : void 0;
27339
+ } catch {
27340
+ return;
27341
+ }
27342
+ }
27035
27343
  getErrorPropertyFromObject(obj) {
27036
27344
  for (const prop in obj) if (Object.prototype.hasOwnProperty.call(obj, prop)) {
27037
27345
  const value = obj[prop];
@@ -27048,7 +27356,7 @@ var ObjectCoercer = class {
27048
27356
  }
27049
27357
  };
27050
27358
  //#endregion
27051
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
27359
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
27052
27360
  var EventCoercer = class {
27053
27361
  match(err) {
27054
27362
  return isEvent(err);
@@ -27064,7 +27372,7 @@ var EventCoercer = class {
27064
27372
  }
27065
27373
  };
27066
27374
  //#endregion
27067
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
27375
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
27068
27376
  var PrimitiveCoercer = class {
27069
27377
  match(candidate) {
27070
27378
  return isPrimitive(candidate);
@@ -27079,7 +27387,7 @@ var PrimitiveCoercer = class {
27079
27387
  }
27080
27388
  };
27081
27389
  //#endregion
27082
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/utils.mjs
27390
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/utils.mjs
27083
27391
  var ReduceableCache = class {
27084
27392
  constructor(_maxSize) {
27085
27393
  this._maxSize = _maxSize;
@@ -27103,14 +27411,20 @@ var ReduceableCache = class {
27103
27411
  }
27104
27412
  };
27105
27413
  //#endregion
27106
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
27414
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
27107
27415
  const EXCEPTION_STEP_INTERNAL_FIELDS = {
27108
27416
  MESSAGE: "$message",
27109
27417
  TIMESTAMP: "$timestamp"
27110
27418
  };
27111
27419
  EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE, EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP;
27112
27420
  //#endregion
27113
- //#region ../../node_modules/.bun/@posthog+core@1.43.1/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
27421
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/error-tracking/release.mjs
27422
+ function getInjectedReleaseId() {
27423
+ const injected = globalThis._posthogReleaseId;
27424
+ return "string" == typeof injected && injected.length > 0 ? injected : void 0;
27425
+ }
27426
+ //#endregion
27427
+ //#region ../../node_modules/.bun/@posthog+core@1.46.7/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
27114
27428
  var PostHogFetchHttpError = class extends Error {
27115
27429
  constructor(response, reqByteLength) {
27116
27430
  super("HTTP error while fetching PostHog: status=" + response.status + ", reqByteLength=" + reqByteLength), this.response = response, this.reqByteLength = reqByteLength, this.name = "PostHogFetchHttpError";
@@ -27268,17 +27582,21 @@ var PostHogCoreStateless = class {
27268
27582
  }
27269
27583
  buildPayload(payload) {
27270
27584
  const userProperties = payload.properties || {};
27271
- const properties = {
27585
+ let properties = {
27272
27586
  ...userProperties,
27273
27587
  ...this.getCommonEventProperties()
27274
27588
  };
27275
27589
  applyCallerFeatureFlagOverrides(properties, userProperties);
27590
+ if ("$feature_flag_called" === payload.event && false === properties.$feature_flag_has_experiment && this.isMinimalFlagCalledEventsEnabled()) properties = minimizeFlagCalledEventProperties(properties);
27276
27591
  return {
27277
27592
  distinct_id: payload.distinct_id,
27278
27593
  event: payload.event,
27279
27594
  properties
27280
27595
  };
27281
27596
  }
27597
+ isMinimalFlagCalledEventsEnabled() {
27598
+ return false;
27599
+ }
27282
27600
  addPendingPromise(promise) {
27283
27601
  return this.promiseQueue.add(promise);
27284
27602
  }
@@ -27750,7 +28068,15 @@ var PostHogCoreStateless = class {
27750
28068
  const batchItems = queue.slice(0, this.maxBatchSize);
27751
28069
  const batchMessages = batchItems.map((item) => void 0 === item.message ? item.message : this.normalizeMessage(item.message));
27752
28070
  const persistQueueChange = async () => {
27753
- const newQueue = (this.getPersistedProperty(queueKey) || []).slice(batchItems.length);
28071
+ const refreshedQueue = this.getPersistedProperty(queueKey) || [];
28072
+ const remainingBatchItems = [...batchItems];
28073
+ const newQueue = refreshedQueue.filter((item) => {
28074
+ const itemUuid = item.message?.uuid;
28075
+ const batchItemIndex = remainingBatchItems.findIndex((batchItem) => batchItem === item || "string" == typeof itemUuid && itemUuid.length > 0 && batchItem.message?.uuid === itemUuid);
28076
+ if (-1 === batchItemIndex) return true;
28077
+ remainingBatchItems.splice(batchItemIndex, 1);
28078
+ return false;
28079
+ });
27754
28080
  this.setPersistedProperty(queueKey, newQueue);
27755
28081
  queue = newQueue;
27756
28082
  this._dequeuedMessagesCount += batchItems.length;
@@ -27900,18 +28226,11 @@ var PostHogCoreStateless = class {
27900
28226
  await logFlushError(e);
27901
28227
  }
27902
28228
  };
27903
- let timeoutHandle;
27904
- try {
27905
- return await Promise.race([new Promise((_, reject) => {
27906
- timeoutHandle = safeSetTimeout(() => {
27907
- this._logger.error("Timed out while shutting down PostHog");
27908
- hasTimedOut = true;
27909
- reject("Timeout while shutting down PostHog. Some events may not have been sent.");
27910
- }, shutdownTimeoutMs);
27911
- }), doShutdown()]);
27912
- } finally {
27913
- clearTimeout(timeoutHandle);
27914
- }
28229
+ return raceWithTimeout(doShutdown(), shutdownTimeoutMs, () => {
28230
+ this._logger.error("Timed out while shutting down PostHog");
28231
+ hasTimedOut = true;
28232
+ throw "Timeout while shutting down PostHog. Some events may not have been sent.";
28233
+ });
27915
28234
  }
27916
28235
  async shutdown(shutdownTimeoutMs = 3e4) {
27917
28236
  if (this.shutdownPromise) this._logger.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup");
@@ -27922,16 +28241,22 @@ var PostHogCoreStateless = class {
27922
28241
  }
27923
28242
  };
27924
28243
  //#endregion
27925
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
28244
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
27926
28245
  const LRU_FILE_CONTENTS_CACHE = new ReduceableCache(25);
27927
28246
  const LRU_FILE_CONTENTS_FS_READ_FAILED = new ReduceableCache(20);
27928
28247
  const DEFAULT_LINES_OF_CONTEXT = 7;
27929
- async function addSourceContext(frames) {
28248
+ const MAX_CONTEXTLINES_FILE_SIZE = 10485760;
28249
+ async function addSourceContext(frames, openSourceFile = open, logger) {
27930
28250
  const filesToLines = {};
28251
+ let basePath;
28252
+ try {
28253
+ basePath = process.cwd();
28254
+ } catch {}
27931
28255
  for (let i = frames.length - 1; i >= 0; i--) {
27932
28256
  const frame = frames[i];
27933
28257
  const filename = frame?.filename;
27934
28258
  if (!frame || "string" != typeof filename || "number" != typeof frame.lineno || shouldSkipContextLinesForFile(filename) || shouldSkipContextLinesForFrame(frame)) continue;
28259
+ if (!isAbsolute(filename) && void 0 === basePath) continue;
27935
28260
  if (!filesToLines[filename]) filesToLines[filename] = [];
27936
28261
  filesToLines[filename].push(frame.lineno);
27937
28262
  }
@@ -27939,43 +28264,85 @@ async function addSourceContext(frames) {
27939
28264
  if (0 == files.length) return frames;
27940
28265
  const readlinePromises = [];
27941
28266
  for (const file of files) {
27942
- if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(file)) continue;
28267
+ const cacheKey = makeSourceCacheKey(file, basePath);
28268
+ if (void 0 === cacheKey) continue;
28269
+ if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(cacheKey)) continue;
27943
28270
  const filesToLineRanges = filesToLines[file];
27944
28271
  if (!filesToLineRanges) continue;
27945
28272
  filesToLineRanges.sort((a, b) => a - b);
27946
28273
  const ranges = makeLineReaderRanges(filesToLineRanges);
27947
- if (ranges.every((r) => rangeExistsInContentCache(file, r))) continue;
27948
- const cache = emplace(LRU_FILE_CONTENTS_CACHE, file, {});
27949
- readlinePromises.push(getContextLinesFromFile(file, ranges, cache));
28274
+ if (ranges.every((r) => rangeExistsInContentCache(cacheKey, r))) continue;
28275
+ const cache = emplace(LRU_FILE_CONTENTS_CACHE, cacheKey, {});
28276
+ readlinePromises.push(getContextLinesFromFile(file, ranges, cache, cacheKey, openSourceFile, logger));
27950
28277
  }
27951
28278
  await Promise.all(readlinePromises).catch(() => {});
27952
- if (frames && frames.length > 0) addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE);
28279
+ if (frames && frames.length > 0) addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE, basePath);
27953
28280
  LRU_FILE_CONTENTS_CACHE.reduce();
27954
28281
  return frames;
27955
28282
  }
27956
- function getContextLinesFromFile(path, ranges, output) {
28283
+ async function openRegularSourceFile(path, openSourceFile, logger) {
28284
+ let fileHandle;
28285
+ let isValid = false;
28286
+ try {
28287
+ fileHandle = await openSourceFile(path, constants.O_RDONLY | constants.O_NONBLOCK);
28288
+ const fileStat = await fileHandle.stat();
28289
+ if (!fileStat.isFile()) return;
28290
+ if (fileStat.size > 10485760) return void logger?.debug(`Skipping source context for oversized file ${path}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
28291
+ isValid = true;
28292
+ return fileHandle;
28293
+ } catch {
28294
+ return;
28295
+ } finally {
28296
+ if (fileHandle && !isValid) await fileHandle.close().catch(() => {});
28297
+ }
28298
+ }
28299
+ async function getContextLinesFromFile(path, ranges, output, cacheKey, openSourceFile, logger) {
28300
+ const fileHandle = await openRegularSourceFile(path, openSourceFile, logger);
28301
+ if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
28302
+ const openedFileHandle = fileHandle;
27957
28303
  return new Promise((resolve) => {
27958
- const stream = createReadStream(path);
27959
- const lineReaded = createInterface({ input: stream });
27960
- function destroyStreamAndResolve() {
27961
- stream.destroy();
27962
- resolve();
28304
+ let finished = false;
28305
+ function destroyStreamAndResolve(stream) {
28306
+ if (finished) return;
28307
+ finished = true;
28308
+ stream?.destroy();
28309
+ openedFileHandle.close().then(resolve, resolve);
28310
+ }
28311
+ let stream;
28312
+ try {
28313
+ stream = openedFileHandle.createReadStream({
28314
+ autoClose: false,
28315
+ start: 0,
28316
+ end: MAX_CONTEXTLINES_FILE_SIZE - 1
28317
+ });
28318
+ } catch {
28319
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
28320
+ destroyStreamAndResolve();
28321
+ return;
28322
+ }
28323
+ let lineReaded;
28324
+ try {
28325
+ lineReaded = createInterface({ input: stream });
28326
+ } catch {
28327
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
28328
+ destroyStreamAndResolve(stream);
28329
+ return;
27963
28330
  }
27964
28331
  let lineNumber = 0;
27965
28332
  let currentRangeIndex = 0;
27966
28333
  const range = ranges[currentRangeIndex];
27967
- if (void 0 === range) return void destroyStreamAndResolve();
28334
+ if (void 0 === range) return void destroyStreamAndResolve(stream);
27968
28335
  let rangeStart = range[0];
27969
28336
  let rangeEnd = range[1];
27970
28337
  function onStreamError() {
27971
- LRU_FILE_CONTENTS_FS_READ_FAILED.set(path, 1);
28338
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
27972
28339
  lineReaded.close();
27973
28340
  lineReaded.removeAllListeners();
27974
- destroyStreamAndResolve();
28341
+ destroyStreamAndResolve(stream);
27975
28342
  }
27976
28343
  stream.on("error", onStreamError);
27977
28344
  lineReaded.on("error", onStreamError);
27978
- lineReaded.on("close", destroyStreamAndResolve);
28345
+ lineReaded.on("close", () => destroyStreamAndResolve(stream));
27979
28346
  lineReaded.on("line", (line) => {
27980
28347
  lineNumber++;
27981
28348
  if (lineNumber < rangeStart) return;
@@ -27999,9 +28366,10 @@ function getContextLinesFromFile(path, ranges, output) {
27999
28366
  });
28000
28367
  });
28001
28368
  }
28002
- function addSourceContextToFrames(frames, cache) {
28369
+ function addSourceContextToFrames(frames, cache, basePath) {
28003
28370
  for (const frame of frames) if (frame.filename && void 0 === frame.context_line && "number" == typeof frame.lineno) {
28004
- const contents = cache.get(frame.filename);
28371
+ const cacheKey = makeSourceCacheKey(frame.filename, basePath);
28372
+ const contents = void 0 === cacheKey ? void 0 : cache.get(cacheKey);
28005
28373
  if (void 0 === contents) continue;
28006
28374
  addContextToFrame(frame.lineno, frame, contents);
28007
28375
  }
@@ -28037,8 +28405,12 @@ function shouldSkipContextLinesForFrame(frame) {
28037
28405
  if (void 0 !== frame.colno && frame.colno > 1e3) return true;
28038
28406
  return false;
28039
28407
  }
28040
- function rangeExistsInContentCache(file, range) {
28041
- const contents = LRU_FILE_CONTENTS_CACHE.get(file);
28408
+ function makeSourceCacheKey(path, basePath) {
28409
+ if (isAbsolute(path)) return JSON.stringify([null, path]);
28410
+ return void 0 === basePath ? void 0 : JSON.stringify([basePath, path]);
28411
+ }
28412
+ function rangeExistsInContentCache(cacheKey, range) {
28413
+ const contents = LRU_FILE_CONTENTS_CACHE.get(cacheKey);
28042
28414
  if (void 0 === contents) return false;
28043
28415
  for (let i = range[0]; i <= range[1]; i++) if (void 0 === contents[i]) return false;
28044
28416
  return true;
@@ -28099,23 +28471,23 @@ function snipLine(line, colno) {
28099
28471
  return newLine;
28100
28472
  }
28101
28473
  //#endregion
28102
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
28474
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
28103
28475
  function createRelativePathModifier(basePath = process.cwd()) {
28104
28476
  const isWindows = "\\" === sep;
28105
28477
  const toUnix = (p) => isWindows ? p.replace(/\\/g, "/") : p;
28106
28478
  const normalizedBase = toUnix(basePath);
28107
28479
  return async (frames) => {
28108
28480
  for (const frame of frames) if (!(!frame.filename || frame.filename.startsWith("node:") || frame.filename.startsWith("data:"))) {
28109
- if (isAbsolute(frame.filename)) frame.filename = toUnix(relative(normalizedBase, toUnix(frame.filename)));
28481
+ if (isAbsolute$1(frame.filename)) frame.filename = toUnix(relative(normalizedBase, toUnix(frame.filename)));
28110
28482
  }
28111
28483
  return frames;
28112
28484
  };
28113
28485
  }
28114
28486
  //#endregion
28115
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/version.mjs
28116
- const version = "5.45.2";
28487
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/version.mjs
28488
+ const version = "5.47.10";
28117
28489
  //#endregion
28118
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/types.mjs
28490
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/types.mjs
28119
28491
  const FeatureFlagError = {
28120
28492
  ERRORS_WHILE_COMPUTING: "errors_while_computing_flags",
28121
28493
  FLAG_MISSING: "flag_missing",
@@ -28123,7 +28495,7 @@ const FeatureFlagError = {
28123
28495
  UNKNOWN_ERROR: "unknown_error"
28124
28496
  };
28125
28497
  //#endregion
28126
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/feature-flag-evaluations.mjs
28498
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/feature-flag-evaluations.mjs
28127
28499
  var FeatureFlagEvaluations = class FeatureFlagEvaluations {
28128
28500
  constructor(init) {
28129
28501
  this._host = init.host;
@@ -28241,7 +28613,7 @@ var FeatureFlagEvaluations = class FeatureFlagEvaluations {
28241
28613
  }
28242
28614
  };
28243
28615
  //#endregion
28244
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
28616
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
28245
28617
  async function hashSHA1(text) {
28246
28618
  const subtle = globalThis.crypto?.subtle;
28247
28619
  if (!subtle) throw new Error("SubtleCrypto API not available");
@@ -28249,7 +28621,7 @@ async function hashSHA1(text) {
28249
28621
  return Array.from(new Uint8Array(hashBuffer)).map((byte) => byte.toString(16).padStart(2, "0")).join("");
28250
28622
  }
28251
28623
  //#endregion
28252
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
28624
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
28253
28625
  const SIXTY_SECONDS = 6e4;
28254
28626
  const LONG_SCALE = 0x1000000000000000;
28255
28627
  const NULL_VALUES_ALLOWED_OPERATORS = ["is_not", "is_set"];
@@ -28284,6 +28656,7 @@ var FeatureFlagsPoller = class {
28284
28656
  this.debugMode = false;
28285
28657
  this.shouldBeginExponentialBackoff = false;
28286
28658
  this.backOffCount = 0;
28659
+ this.pollerStopped = false;
28287
28660
  this.pollingInterval = pollingInterval;
28288
28661
  this.personalApiKey = personalApiKey;
28289
28662
  this.featureFlags = [];
@@ -28299,6 +28672,7 @@ var FeatureFlagsPoller = class {
28299
28672
  this.onError = options.onError;
28300
28673
  this.customHeaders = customHeaders;
28301
28674
  this.onLoad = options.onLoad;
28675
+ this.onMinimalFlagCalledEvents = options.onMinimalFlagCalledEvents;
28302
28676
  this.cacheProvider = options.cacheProvider;
28303
28677
  this.strictLocalEvaluation = options.strictLocalEvaluation ?? false;
28304
28678
  this.loadFeatureFlags();
@@ -28549,6 +28923,7 @@ var FeatureFlagsPoller = class {
28549
28923
  this.groupTypeMapping = flagData.groupTypeMapping;
28550
28924
  this.cohorts = flagData.cohorts;
28551
28925
  this.loadedSuccessfullyOnce = true;
28926
+ this.onMinimalFlagCalledEvents?.(true === flagData.minimalFlagCalledEvents);
28552
28927
  }
28553
28928
  warnAboutExperienceContinuityFlags(flags) {
28554
28929
  if (this.strictLocalEvaluation) return;
@@ -28605,7 +28980,6 @@ var FeatureFlagsPoller = class {
28605
28980
  clearTimeout(this.poller);
28606
28981
  this.poller = void 0;
28607
28982
  }
28608
- this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
28609
28983
  try {
28610
28984
  let shouldFetch = true;
28611
28985
  if (this.cacheProvider) try {
@@ -28635,6 +29009,7 @@ var FeatureFlagsPoller = class {
28635
29009
  this.featureFlagsByKey = {};
28636
29010
  this.groupTypeMapping = {};
28637
29011
  this.cohorts = {};
29012
+ this.onMinimalFlagCalledEvents?.(false);
28638
29013
  return;
28639
29014
  case 403:
28640
29015
  this.beginBackoff();
@@ -28649,7 +29024,8 @@ var FeatureFlagsPoller = class {
28649
29024
  const flagData = {
28650
29025
  flags: responseJson.flags ?? [],
28651
29026
  groupTypeMapping: responseJson.group_type_mapping || {},
28652
- cohorts: responseJson.cohorts || {}
29027
+ cohorts: responseJson.cohorts || {},
29028
+ minimalFlagCalledEvents: true === responseJson.minimal_flag_called_events
28653
29029
  };
28654
29030
  this.updateFlagState(flagData);
28655
29031
  this.flagDefinitionsLoadedAt = Date.now();
@@ -28667,6 +29043,8 @@ var FeatureFlagsPoller = class {
28667
29043
  }
28668
29044
  } catch (err) {
28669
29045
  if (err instanceof ClientError) this.onError?.(err);
29046
+ } finally {
29047
+ if (!this.pollerStopped) this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
28670
29048
  }
28671
29049
  }
28672
29050
  getPersonalApiKeyRequestOptions(method = "GET", etag) {
@@ -28681,7 +29059,7 @@ var FeatureFlagsPoller = class {
28681
29059
  headers
28682
29060
  };
28683
29061
  }
28684
- _requestFeatureFlagDefinitions() {
29062
+ async _requestFeatureFlagDefinitions() {
28685
29063
  const url = `${this.host}/flags/definitions?token=${this.projectApiKey}&send_cohorts`;
28686
29064
  const options = this.getPersonalApiKeyRequestOptions("GET", this.flagsEtag);
28687
29065
  let abortTimeout = null;
@@ -28692,18 +29070,47 @@ var FeatureFlagsPoller = class {
28692
29070
  }, this.timeout);
28693
29071
  options.signal = controller.signal;
28694
29072
  }
29073
+ const clearAbortTimeout = () => clearTimeout(abortTimeout);
28695
29074
  try {
28696
29075
  const fetch1 = this.fetch;
28697
- return fetch1(url, options);
28698
- } finally {
28699
- clearTimeout(abortTimeout);
29076
+ const res = await fetch1(url, options);
29077
+ if (200 !== res.status) {
29078
+ clearAbortTimeout();
29079
+ return res;
29080
+ }
29081
+ return {
29082
+ status: res.status,
29083
+ headers: res.headers,
29084
+ body: res.body,
29085
+ text: async () => {
29086
+ try {
29087
+ return await res.text();
29088
+ } finally {
29089
+ clearAbortTimeout();
29090
+ }
29091
+ },
29092
+ json: async () => {
29093
+ try {
29094
+ return await res.json();
29095
+ } finally {
29096
+ clearAbortTimeout();
29097
+ }
29098
+ }
29099
+ };
29100
+ } catch (err) {
29101
+ clearAbortTimeout();
29102
+ throw err;
28700
29103
  }
28701
29104
  }
28702
29105
  async stopPoller(timeoutMs = 3e4) {
29106
+ this.pollerStopped = true;
28703
29107
  clearTimeout(this.poller);
29108
+ this.poller = void 0;
28704
29109
  if (this.cacheProvider) try {
28705
29110
  const shutdownResult = this.cacheProvider.shutdown();
28706
- if (shutdownResult instanceof Promise) await Promise.race([shutdownResult, new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error(`Cache shutdown timeout after ${timeoutMs}ms`)), timeoutMs))]);
29111
+ if (shutdownResult instanceof Promise) await raceWithTimeout(shutdownResult, timeoutMs, () => {
29112
+ throw new Error(`Cache shutdown timeout after ${timeoutMs}ms`);
29113
+ });
28707
29114
  } catch (err) {
28708
29115
  this.onError?.(/* @__PURE__ */ new Error(`Error during cache shutdown: ${err}`));
28709
29116
  }
@@ -28995,34 +29402,86 @@ function relativeDateParseForFeatureFlagMatching(value) {
28995
29402
  }
28996
29403
  }
28997
29404
  //#endregion
28998
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
29405
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
29406
+ const UNHANDLED_REJECTION_OPTION_NAMES = ["--unhandled-rejections", "--unhandled_rejections"];
29407
+ const UNHANDLED_REJECTION_MODES = /* @__PURE__ */ new Set([
29408
+ "throw",
29409
+ "strict",
29410
+ "warn",
29411
+ "warn-with-error-code",
29412
+ "none"
29413
+ ]);
29414
+ const STARTUP_EXEC_ARGV = [...globalThis.process?.execArgv ?? []];
29415
+ const STARTUP_NODE_OPTIONS = globalThis.process?.env?.NODE_OPTIONS;
29416
+ function splitNodeOptions(nodeOptions) {
29417
+ const args = [];
29418
+ let current = "";
29419
+ let isInString = false;
29420
+ for (let index = 0; index < nodeOptions.length; index++) {
29421
+ const character = nodeOptions[index];
29422
+ if ("\\" === character && isInString && index + 1 < nodeOptions.length) current += nodeOptions[++index];
29423
+ else if (" " !== character || isInString) if ("\"" === character) isInString = !isInString;
29424
+ else current += character;
29425
+ else if (current) {
29426
+ args.push(current);
29427
+ current = "";
29428
+ }
29429
+ }
29430
+ if (current) args.push(current);
29431
+ return args;
29432
+ }
29433
+ function findUnhandledRejectionMode(args) {
29434
+ let mode;
29435
+ for (let index = 0; index < args.length; index++) {
29436
+ const argument = args[index];
29437
+ const optionName = UNHANDLED_REJECTION_OPTION_NAMES.find((name) => argument === name || argument.startsWith(`${name}=`));
29438
+ if (!optionName) continue;
29439
+ const value = argument === optionName ? args[++index] : argument.slice(optionName.length + 1);
29440
+ if (UNHANDLED_REJECTION_MODES.has(value)) mode = value;
29441
+ }
29442
+ return mode;
29443
+ }
29444
+ function getUnhandledRejectionMode(execArgv = STARTUP_EXEC_ARGV, nodeOptions = STARTUP_NODE_OPTIONS) {
29445
+ return findUnhandledRejectionMode(execArgv) ?? findUnhandledRejectionMode(splitNodeOptions(nodeOptions ?? "")) ?? "throw";
29446
+ }
29447
+ const STARTUP_UNHANDLED_REJECTION_MODE = getUnhandledRejectionMode();
29448
+ function captureUncaughtException(captureFn, error, origin) {
29449
+ captureFn(error, { mechanism: {
29450
+ type: "unhandledRejection" === origin ? "onunhandledrejection" : "onuncaughtexception",
29451
+ handled: false
29452
+ } });
29453
+ }
28999
29454
  function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
29000
29455
  let calledFatalError = false;
29001
- return Object.assign((error) => {
29002
- const processWouldExit = 0 === global.process.listeners("uncaughtException").filter((listener) => "domainUncaughtExceptionClear" !== listener.name && true !== listener._posthogErrorHandler).length;
29003
- captureFn(error, { mechanism: {
29004
- type: "onuncaughtexception",
29005
- handled: false
29006
- } });
29007
- if (!calledFatalError && processWouldExit) {
29456
+ return Object.assign((error, origin) => {
29457
+ const userProvidedListenersCount = global.process.listeners("uncaughtException").filter((listener) => "domainUncaughtExceptionClear" !== listener.name && true !== listener._posthogErrorHandler).length;
29458
+ captureUncaughtException(captureFn, error, origin);
29459
+ if (!calledFatalError && 0 === userProvidedListenersCount) {
29008
29460
  calledFatalError = true;
29009
29461
  onFatalFn(error);
29010
29462
  }
29011
29463
  }, { _posthogErrorHandler: true });
29012
29464
  }
29013
- function addUncaughtExceptionListener(captureFn, onFatalFn) {
29014
- globalThis.process?.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
29465
+ function addUncaughtExceptionListener(captureFn, onFatalFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
29466
+ const process = globalThis.process;
29467
+ if (!process) return;
29468
+ if ("strict" === mode) return void process.on("uncaughtExceptionMonitor", (error, origin) => captureUncaughtException(captureFn, error, origin));
29469
+ process.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
29015
29470
  }
29016
- function addUnhandledRejectionListener(captureFn) {
29017
- globalThis.process?.on("unhandledRejection", (reason) => captureFn(reason, { mechanism: {
29018
- type: "onunhandledrejection",
29019
- handled: false
29020
- } }));
29471
+ function addUnhandledRejectionListener(captureFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
29472
+ const process = globalThis.process;
29473
+ if (!process || "throw" === mode || "strict" === mode || "warn-with-error-code" === mode) return;
29474
+ process.on("unhandledRejection", (reason) => {
29475
+ captureFn(reason, { mechanism: {
29476
+ type: "onunhandledrejection",
29477
+ handled: false
29478
+ } });
29479
+ });
29021
29480
  }
29022
29481
  //#endregion
29023
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
29482
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
29024
29483
  const SHUTDOWN_TIMEOUT = 2e3;
29025
- var ErrorTracking = class ErrorTracking {
29484
+ var error_tracking_ErrorTracking = class error_tracking_ErrorTracking {
29026
29485
  constructor(client, options, _logger) {
29027
29486
  this.client = client;
29028
29487
  this._exceptionAutocaptureEnabled = options.enableExceptionAutocapture || false;
@@ -29041,6 +29500,8 @@ var ErrorTracking = class ErrorTracking {
29041
29500
  const properties = { ...additionalProperties };
29042
29501
  const exceptionProperties = builder.buildFromUnknown(error, hint);
29043
29502
  exceptionProperties.$exception_list = await builder.modifyFrames(exceptionProperties.$exception_list);
29503
+ const injectedReleaseId = getInjectedReleaseId();
29504
+ if (injectedReleaseId) properties.$release_id = injectedReleaseId;
29044
29505
  return {
29045
29506
  event: "$exception",
29046
29507
  distinctId,
@@ -29059,8 +29520,8 @@ var ErrorTracking = class ErrorTracking {
29059
29520
  }
29060
29521
  onException(exception, hint) {
29061
29522
  this.client.addPendingPromise((async () => {
29062
- if (!ErrorTracking.isPreviouslyCapturedError(exception)) {
29063
- const eventMessage = await ErrorTracking.buildEventMessage(this.client.getErrorPropertiesBuilder(), exception, hint);
29523
+ if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(exception)) {
29524
+ const eventMessage = await error_tracking_ErrorTracking.buildEventMessage(this.client.getErrorPropertiesBuilder(), exception, hint);
29064
29525
  const exceptionType = eventMessage.properties?.$exception_list[0]?.type ?? "Exception";
29065
29526
  if (this._rateLimiter.consumeRateLimit(exceptionType)) return void this._logger.info("Skipping exception capture because of client rate limiting.", { exception: exceptionType });
29066
29527
  return this.client._capturePreparedEvent(eventMessage, false);
@@ -29080,7 +29541,7 @@ var ErrorTracking = class ErrorTracking {
29080
29541
  }
29081
29542
  };
29082
29543
  //#endregion
29083
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/storage-memory.mjs
29544
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/storage-memory.mjs
29084
29545
  var PostHogMemoryStorage = class {
29085
29546
  getProperty(key) {
29086
29547
  return this._memoryStorage[key];
@@ -29093,7 +29554,7 @@ var PostHogMemoryStorage = class {
29093
29554
  }
29094
29555
  };
29095
29556
  //#endregion
29096
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/capture-v1/config.mjs
29557
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/capture-v1/config.mjs
29097
29558
  function isCaptureMode(value) {
29098
29559
  return "v0" === value || "v1" === value;
29099
29560
  }
@@ -29102,14 +29563,14 @@ function resolveCaptureMode() {
29102
29563
  return isCaptureMode(envMode) ? envMode : "v0";
29103
29564
  }
29104
29565
  //#endregion
29105
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/capture-v1/routing.mjs
29566
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/capture-v1/routing.mjs
29106
29567
  const AI_EVENT_PREFIX = "$ai_";
29107
29568
  const ANALYTICS_ROUTE = "analytics";
29108
29569
  function isLegacyOnlyEvent(message) {
29109
29570
  return "string" == typeof message.event && message.event.startsWith(AI_EVENT_PREFIX);
29110
29571
  }
29111
29572
  //#endregion
29112
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/capture-v1/errors.mjs
29573
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/capture-v1/errors.mjs
29113
29574
  var CaptureV1Error = class CaptureV1Error extends Error {
29114
29575
  constructor({ requestId, drops, retryExhausted, cause }) {
29115
29576
  super(CaptureV1Error.buildMessage(requestId, drops, retryExhausted, cause)), this.name = "CaptureV1Error";
@@ -29125,7 +29586,7 @@ var CaptureV1Error = class CaptureV1Error extends Error {
29125
29586
  }
29126
29587
  };
29127
29588
  //#endregion
29128
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/capture-v1/transform.mjs
29589
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/capture-v1/transform.mjs
29129
29590
  function coerceBool(value) {
29130
29591
  if ("boolean" == typeof value) return value;
29131
29592
  if ("number" == typeof value) return 0 !== value;
@@ -29219,7 +29680,7 @@ function buildV1Batch(messages, { createdAt, historicalMigration }) {
29219
29680
  return batch;
29220
29681
  }
29221
29682
  //#endregion
29222
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/capture-v1/sender.mjs
29683
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/capture-v1/sender.mjs
29223
29684
  const V1_ANALYTICS_PATH = "/i/v1/analytics/events";
29224
29685
  const DEFAULT_MAX_BACKOFF_MS = 3e4;
29225
29686
  const RETRYABLE_STATUSES = /* @__PURE__ */ new Set([
@@ -29401,7 +29862,7 @@ var V1CaptureSender = class {
29401
29862
  }
29402
29863
  };
29403
29864
  //#endregion
29404
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/client.mjs
29865
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/client.mjs
29405
29866
  const MINIMUM_POLLING_INTERVAL = 100;
29406
29867
  const THIRTY_SECONDS = 3e4;
29407
29868
  const MAX_CACHE_SIZE = 5e4;
@@ -29444,7 +29905,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
29444
29905
  host: normalizeHost(options.host),
29445
29906
  personalApiKey: normalizePersonalApiKey(options.secretKey ?? options.personalApiKey)
29446
29907
  };
29447
- super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage();
29908
+ super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage(), this._minimalFlagCalledEvents = false;
29448
29909
  this.options = normalizedOptions;
29449
29910
  this.captureMode = resolveCaptureMode();
29450
29911
  this.context = this.initializeContext();
@@ -29466,12 +29927,15 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
29466
29927
  onLoad: (count) => {
29467
29928
  this._events.emit("localEvaluationFlagsLoaded", count);
29468
29929
  },
29930
+ onMinimalFlagCalledEvents: (enabled) => {
29931
+ this._minimalFlagCalledEvents = enabled;
29932
+ },
29469
29933
  customHeaders: this.getCustomHeaders(),
29470
29934
  cacheProvider: normalizedOptions.flagDefinitionCacheProvider,
29471
29935
  strictLocalEvaluation: normalizedOptions.strictLocalEvaluation
29472
29936
  });
29473
29937
  }
29474
- this.errorTracking = new ErrorTracking(this, normalizedOptions, this._logger);
29938
+ this.errorTracking = new error_tracking_ErrorTracking(this, normalizedOptions, this._logger);
29475
29939
  this.distinctIdHasSentFlagCalls = {};
29476
29940
  this.maxCacheSize = normalizedOptions.maxCacheSize || MAX_CACHE_SIZE;
29477
29941
  }
@@ -29788,6 +30252,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
29788
30252
  const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, [key]);
29789
30253
  if (void 0 === flagsResponse) featureFlagError = FeatureFlagError.UNKNOWN_ERROR;
29790
30254
  else {
30255
+ this._minimalFlagCalledEvents = true === flagsResponse.minimalFlagCalledEvents;
29791
30256
  requestId = flagsResponse.requestId;
29792
30257
  evaluatedAt = flagsResponse.evaluatedAt;
29793
30258
  const errors = [];
@@ -30013,6 +30478,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
30013
30478
  if ((localResult ? localResult.fallbackToFlags : true) && !onlyEvaluateLocally) {
30014
30479
  const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
30015
30480
  if (details) {
30481
+ this._minimalFlagCalledEvents = true === details.minimalFlagCalledEvents;
30016
30482
  requestId = details.requestId;
30017
30483
  evaluatedAt = details.evaluatedAt;
30018
30484
  errorsWhileComputing = Boolean(details.errorsWhileComputingFlags);
@@ -30077,6 +30543,9 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
30077
30543
  quotaLimited
30078
30544
  });
30079
30545
  }
30546
+ _shouldSendMinimalFlagCalledEvent(event, properties) {
30547
+ return "$feature_flag_called" === event && this._minimalFlagCalledEvents && false === properties.$feature_flag_has_experiment;
30548
+ }
30080
30549
  _captureFlagCalledEventIfNeeded(params) {
30081
30550
  const { distinctId, key, response, groups, disableGeoip, properties } = params;
30082
30551
  const featureFlagReportedKey = `${key}_${response}${groups && Object.keys(groups).length > 0 ? `_${JSON.stringify(Object.entries(groups).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0))}` : ""}`;
@@ -30182,7 +30651,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
30182
30651
  await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
30183
30652
  this.errorTracking.shutdown();
30184
30653
  if (this._metrics) {
30185
- await Promise.race([this._metrics.flush().catch(() => {}), new Promise((resolve) => safeSetTimeout(resolve, Math.max(0, shutdownDeadlineMs - Date.now())))]);
30654
+ await raceWithTimeout(this._metrics.flush().catch(() => {}), Math.max(0, shutdownDeadlineMs - Date.now()));
30186
30655
  this._metrics.reset();
30187
30656
  }
30188
30657
  try {
@@ -30297,9 +30766,9 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
30297
30766
  };
30298
30767
  }
30299
30768
  captureException(error, distinctId, additionalProperties, uuid, flags) {
30300
- if (!ErrorTracking.isPreviouslyCapturedError(error)) {
30769
+ if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
30301
30770
  const syntheticException = /* @__PURE__ */ new Error("PostHog syntheticException");
30302
- this.addPendingPromise(ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, { syntheticException }, distinctId, additionalProperties).then((msg) => this._capturePreparedEvent({
30771
+ this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, { syntheticException }, distinctId, additionalProperties).then((msg) => this._capturePreparedEvent({
30303
30772
  ...msg,
30304
30773
  uuid,
30305
30774
  flags
@@ -30307,9 +30776,9 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
30307
30776
  }
30308
30777
  }
30309
30778
  async captureExceptionImmediate(error, distinctId, additionalProperties, flags) {
30310
- if (!ErrorTracking.isPreviouslyCapturedError(error)) {
30779
+ if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
30311
30780
  const syntheticException = /* @__PURE__ */ new Error("PostHog syntheticException");
30312
- return this.addPendingPromise(ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, { syntheticException }, distinctId, additionalProperties).then((msg) => this.captureImmediate({
30781
+ return this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, { syntheticException }, distinctId, additionalProperties).then((msg) => this.captureImmediate({
30313
30782
  ...msg,
30314
30783
  flags
30315
30784
  })));
@@ -30333,10 +30802,11 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
30333
30802
  mergedProperties.$process_person_profile = false;
30334
30803
  }
30335
30804
  if (includeContextProperties && contextData?.sessionId && !mergedProperties.$session_id) mergedProperties.$session_id = contextData.sessionId;
30805
+ const finalProperties = this._shouldSendMinimalFlagCalledEvent(event, mergedProperties) ? minimizeFlagCalledEventProperties(mergedProperties) : mergedProperties;
30336
30806
  const eventMessage = this._runBeforeSend({
30337
30807
  distinctId: mergedDistinctId,
30338
30808
  event,
30339
- properties: mergedProperties,
30809
+ properties: finalProperties,
30340
30810
  groups,
30341
30811
  flags,
30342
30812
  sendFeatureFlags,
@@ -30401,7 +30871,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
30401
30871
  }
30402
30872
  };
30403
30873
  //#endregion
30404
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/extensions/context/context.mjs
30874
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/extensions/context/context.mjs
30405
30875
  var PostHogContext = class {
30406
30876
  constructor() {
30407
30877
  this.storage = new AsyncLocalStorage();
@@ -30429,7 +30899,7 @@ var PostHogContext = class {
30429
30899
  }
30430
30900
  };
30431
30901
  //#endregion
30432
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
30902
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
30433
30903
  const NAME = "posthog-node";
30434
30904
  function createEventProcessor(_posthog, { organization, projectId, prefix, severityAllowList = ["error"], sendExceptionsToPostHog = true } = {}) {
30435
30905
  return (event) => {
@@ -30463,6 +30933,8 @@ function createEventProcessor(_posthog, { organization, projectId, prefix, sever
30463
30933
  $sentry_exception_type: exceptions[0]?.type,
30464
30934
  $sentry_tags: event.tags
30465
30935
  };
30936
+ const injectedReleaseId = getInjectedReleaseId();
30937
+ if (injectedReleaseId) properties.$release_id = injectedReleaseId;
30466
30938
  if (organization && projectId) properties["$sentry_url"] = (prefix || "https://sentry.io/organizations/") + organization + "/issues/?project=" + projectId + "&query=" + event.event_id;
30467
30939
  if (sendExceptionsToPostHog) _posthog.capture({
30468
30940
  event: "$exception",
@@ -30490,7 +30962,7 @@ var PostHogSentryIntegration = class {
30490
30962
  }
30491
30963
  };
30492
30964
  //#endregion
30493
- //#region ../../node_modules/.bun/posthog-node@5.45.2+63120419cc93e79b/node_modules/posthog-node/dist/entrypoints/index.node.mjs
30965
+ //#region ../../node_modules/.bun/posthog-node@5.47.10+63120419cc93e79b/node_modules/posthog-node/dist/entrypoints/index.node.mjs
30494
30966
  var PostHog = class extends PostHogBackendClient {
30495
30967
  getLibraryId() {
30496
30968
  return "posthog-node";
@@ -30507,7 +30979,7 @@ var PostHog = class extends PostHogBackendClient {
30507
30979
  new PrimitiveCoercer()
30508
30980
  ], createStackParser("node:javascript", nodeStackLineParser), [
30509
30981
  createModulerModifier(),
30510
- addSourceContext,
30982
+ (frames) => addSourceContext(frames, void 0, this._logger),
30511
30983
  createRelativePathModifier()
30512
30984
  ]);
30513
30985
  }
@@ -32328,7 +32800,6 @@ const accessPhase = async (ctx) => {
32328
32800
  data: { scopeAlias }
32329
32801
  };
32330
32802
  };
32331
- h("InvalidEmailHint")();
32332
32803
  const base64URLFromText = (value) => {
32333
32804
  const bytes = new TextEncoder().encode(value);
32334
32805
  let binary = "";
@@ -32488,7 +32959,7 @@ const resolvePhoneNumber = async (ctx) => {
32488
32959
  };
32489
32960
  //#endregion
32490
32961
  //#region src/lib/expected-errors.ts
32491
- var InvalidScope = class extends h("InvalidScope")() {
32962
+ var InvalidScope = class extends h("InvalidScope") {
32492
32963
  constructor(scope) {
32493
32964
  super({
32494
32965
  scope,
@@ -32496,7 +32967,7 @@ var InvalidScope = class extends h("InvalidScope")() {
32496
32967
  });
32497
32968
  }
32498
32969
  };
32499
- var AccountNotFound = class extends h("AccountNotFound")() {
32970
+ var AccountNotFound = class extends h("AccountNotFound") {
32500
32971
  constructor({ account, platform }) {
32501
32972
  super({
32502
32973
  account,
@@ -32505,7 +32976,7 @@ var AccountNotFound = class extends h("AccountNotFound")() {
32505
32976
  });
32506
32977
  }
32507
32978
  };
32508
- var NoConnectedAccount = class extends h("NoConnectedAccount")() {
32979
+ var NoConnectedAccount = class extends h("NoConnectedAccount") {
32509
32980
  constructor(platform) {
32510
32981
  super({
32511
32982
  platform,
@@ -32513,7 +32984,7 @@ var NoConnectedAccount = class extends h("NoConnectedAccount")() {
32513
32984
  });
32514
32985
  }
32515
32986
  };
32516
- var LookupPayloadInvalid = class extends h("LookupPayloadInvalid")() {
32987
+ var LookupPayloadInvalid = class extends h("LookupPayloadInvalid") {
32517
32988
  constructor({ input, platform }) {
32518
32989
  super({
32519
32990
  input,
@@ -32522,7 +32993,7 @@ var LookupPayloadInvalid = class extends h("LookupPayloadInvalid")() {
32522
32993
  });
32523
32994
  }
32524
32995
  };
32525
- var SchemaPathUnknown = class extends h("SchemaPathUnknown")() {
32996
+ var SchemaPathUnknown = class extends h("SchemaPathUnknown") {
32526
32997
  constructor({ message, path }) {
32527
32998
  super({
32528
32999
  message,
@@ -32530,7 +33001,7 @@ var SchemaPathUnknown = class extends h("SchemaPathUnknown")() {
32530
33001
  });
32531
33002
  }
32532
33003
  };
32533
- var SchemaContractInvalid = class extends h("SchemaContractInvalid")() {
33004
+ var SchemaContractInvalid = class extends h("SchemaContractInvalid") {
32534
33005
  constructor({ label, message }) {
32535
33006
  super({
32536
33007
  label,
@@ -32538,7 +33009,7 @@ var SchemaContractInvalid = class extends h("SchemaContractInvalid")() {
32538
33009
  });
32539
33010
  }
32540
33011
  };
32541
- var UsagePaginationLimit = class extends h("UsagePaginationLimit")() {
33012
+ var UsagePaginationLimit = class extends h("UsagePaginationLimit") {
32542
33013
  constructor(limit) {
32543
33014
  super({
32544
33015
  limit,
@@ -32546,7 +33017,7 @@ var UsagePaginationLimit = class extends h("UsagePaginationLimit")() {
32546
33017
  });
32547
33018
  }
32548
33019
  };
32549
- var LogoutRevocationFailed = class extends h("LogoutRevocationFailed")() {
33020
+ var LogoutRevocationFailed = class extends h("LogoutRevocationFailed") {
32550
33021
  constructor() {
32551
33022
  super({ message: "Could not revoke the server-side session; local credentials were cleared." });
32552
33023
  }
@@ -32555,16 +33026,16 @@ var LogoutRevocationFailed = class extends h("LogoutRevocationFailed")() {
32555
33026
  //#region src/login/phases/1.scope.ts
32556
33027
  const DEFAULT_SCOPE_ALIAS = "read,write";
32557
33028
  const parseScopeAliasResult = (value) => {
32558
- if (value === void 0 || value === null || value === "") return G.ok(DEFAULT_SCOPE_ALIAS);
32559
- if (typeof value !== "string") return G.err(new InvalidScope(String(value)));
33029
+ if (value === void 0 || value === null || value === "") return ae.ok(DEFAULT_SCOPE_ALIAS);
33030
+ if (typeof value !== "string") return ae.err(new InvalidScope(String(value)));
32560
33031
  const scope = value === "write" ? DEFAULT_SCOPE_ALIAS : value;
32561
33032
  const parsed = parseCLIScopeAlias(scope);
32562
- if (G.isError(parsed)) return G.err(new InvalidScope(scope));
32563
- return G.ok(parsed.value);
33033
+ if (ae.isError(parsed)) return ae.err(new InvalidScope(scope));
33034
+ return ae.ok(parsed.value);
32564
33035
  };
32565
33036
  const parseScopeAlias = (value) => {
32566
33037
  const parsed = parseScopeAliasResult(value);
32567
- if (G.isOk(parsed)) return parsed.value;
33038
+ if (ae.isOk(parsed)) return parsed.value;
32568
33039
  throw new Error(parsed.error.message);
32569
33040
  };
32570
33041
  //#endregion
@@ -32636,13 +33107,9 @@ const errorOutput = (error) => ({
32636
33107
  message: error instanceof Error ? error.message : String(error)
32637
33108
  });
32638
33109
  const nextCommands = ["social account connect linkedin", "social account connect x"];
32639
- const availableConnectCommands = (capabilities) => nextCommands.filter((command) => {
32640
- const platform = command.endsWith(" linkedin") ? "linkedin" : "x";
32641
- return capabilities.some((capability) => capability.startsWith(`${platform}:`));
32642
- });
32643
33110
  const setupOutputFor = (setup) => ({
32644
33111
  ...setup,
32645
- nextCommands: setup.status === "pending_billing" ? ["social account setup"] : availableConnectCommands(setup.capabilities)
33112
+ nextCommands: setup.status === "pending_billing" ? ["social account setup"] : nextCommands
32646
33113
  });
32647
33114
  const deviceExpiredMessage = "Sign-in expired before approval. Run `social account setup` again to restart.";
32648
33115
  const scopeUpgradeRequiresReauthorization = "Existing CLI session is read-only. Run `social account logout`, then `social account setup` to approve a new write-capable session.";
@@ -32729,7 +33196,7 @@ const createLoginCommand = (deps = {}) => {
32729
33196
  return defineCommand({
32730
33197
  meta: commandMeta({
32731
33198
  name: "setup",
32732
- description: "Authenticate Social and ensure billing is ready",
33199
+ description: "Authenticate Social and add a reusable payment method before connecting accounts",
32733
33200
  contract: localCLIContract({
32734
33201
  auth: {
32735
33202
  interactive: true,
@@ -32804,11 +33271,7 @@ const createLoginCommand = (deps = {}) => {
32804
33271
  }
32805
33272
  if (output.status === "ready") {
32806
33273
  analytics.identifyUser(output.user.id);
32807
- analytics.capture("login_completed", {
32808
- scope: output.scope,
32809
- seats_total: output.seats.total,
32810
- seats_available: output.seats.available
32811
- });
33274
+ analytics.capture("login_completed", { scope: output.scope });
32812
33275
  } else if (output.status === "expired") analytics.capture("login_failed", { code: "expired" });
32813
33276
  else if (output.status === "needs_input") analytics.capture("login_failed", {
32814
33277
  code: "needs_input",
@@ -32850,7 +33313,7 @@ const revokeServerSide = async (accessToken) => {
32850
33313
  return false;
32851
33314
  }
32852
33315
  };
32853
- const logoutRevocationResult = (revoked) => revoked ? G.ok(null) : G.err(new LogoutRevocationFailed());
33316
+ const logoutRevocationResult = (revoked) => revoked ? ae.ok(null) : ae.err(new LogoutRevocationFailed());
32854
33317
  const logoutCommand = defineCommand({
32855
33318
  meta: commandMeta({
32856
33319
  name: "logout",
@@ -32879,7 +33342,7 @@ const logoutCommand = defineCommand({
32879
33342
  const revoked = await revokeServerSide(credentials.accessToken);
32880
33343
  await clearCredentials();
32881
33344
  const revocation = logoutRevocationResult(revoked);
32882
- if (G.isError(revocation)) throw new Error(revocation.error.message);
33345
+ if (ae.isError(revocation)) throw new Error(revocation.error.message);
32883
33346
  analytics.capture("logout");
32884
33347
  analytics.reset();
32885
33348
  }
@@ -33018,7 +33481,7 @@ const fetchUsageLogs = async (client, input) => {
33018
33481
  let nextCursor = null;
33019
33482
  let pages = 0;
33020
33483
  do {
33021
- if (pages >= USAGE_LOG_MAX_AUTO_PAGES) return G.err(new UsagePaginationLimit(USAGE_LOG_MAX_AUTO_PAGES));
33484
+ if (pages >= USAGE_LOG_MAX_AUTO_PAGES) return ae.err(new UsagePaginationLimit(USAGE_LOG_MAX_AUTO_PAGES));
33022
33485
  const remaining = input.limit === void 0 ? USAGE_LOG_PAGE_LIMIT : input.limit - items.length;
33023
33486
  const usage = await client.usage.list({
33024
33487
  platform: input.platform,
@@ -33032,7 +33495,7 @@ const fetchUsageLogs = async (client, input) => {
33032
33495
  cursor = nextCursor ?? void 0;
33033
33496
  pages += 1;
33034
33497
  } while (nextCursor && (input.limit === void 0 || items.length < input.limit));
33035
- return G.ok({
33498
+ return ae.ok({
33036
33499
  items: input.limit === void 0 ? items : items.slice(0, input.limit),
33037
33500
  cursor: nextCursor
33038
33501
  });
@@ -33100,7 +33563,7 @@ const createUsageLogsCommand = (deps = {}) => defineCommand({
33100
33563
  from,
33101
33564
  to
33102
33565
  });
33103
- if (G.isError(usage)) throw new UsageError(usage.error.message);
33566
+ if (ae.isError(usage)) throw new UsageError(usage.error.message);
33104
33567
  await writeOutput$1(deps, {
33105
33568
  items: aggregateLogs(usage.value.items, sumBy),
33106
33569
  meta: {
@@ -33119,7 +33582,7 @@ const createUsageLogsCommand = (deps = {}) => defineCommand({
33119
33582
  from,
33120
33583
  to
33121
33584
  });
33122
- if (G.isError(usage)) throw new UsageError(usage.error.message);
33585
+ if (ae.isError(usage)) throw new UsageError(usage.error.message);
33123
33586
  await writeOutput$1(deps, {
33124
33587
  items: usage.value.items,
33125
33588
  meta: { cursor: usage.value.cursor }
@@ -33161,12 +33624,18 @@ const AccountDefaultSetInput = AccountDefaultGetInput.extend({ account: string()
33161
33624
  const AccountConnectStateOutput = discriminatedUnion("status", [
33162
33625
  object({
33163
33626
  status: literal("connected"),
33627
+ attemptId: uuid$1(),
33164
33628
  platform: _enum(["linkedin", "x"]),
33165
33629
  account: LifecycleAccountOutput
33166
33630
  }),
33167
33631
  object({
33168
33632
  status: literal("pending_billing"),
33633
+ attemptId: uuid$1(),
33169
33634
  platform: _enum(["linkedin", "x"]),
33635
+ plan: object({
33636
+ id: string(),
33637
+ name: string()
33638
+ }),
33170
33639
  paymentURL: string().nullable(),
33171
33640
  requiredAction: object({
33172
33641
  code: string(),
@@ -33180,8 +33649,17 @@ const AccountConnectStateOutput = discriminatedUnion("status", [
33180
33649
  }),
33181
33650
  object({
33182
33651
  status: literal("pending_approval"),
33652
+ attemptId: uuid$1(),
33183
33653
  platform: _enum(["linkedin", "x"]),
33184
- connectURL: string()
33654
+ connectURL: string().nullable(),
33655
+ expiresAt: string()
33656
+ }),
33657
+ object({
33658
+ status: _enum(["expired", "failed"]),
33659
+ attemptId: uuid$1(),
33660
+ platform: _enum(["linkedin", "x"]),
33661
+ code: string(),
33662
+ retryable: boolean$1()
33185
33663
  })
33186
33664
  ]);
33187
33665
  const AccountConnectOutput = union([string(), AccountConnectStateOutput]);
@@ -33271,7 +33749,15 @@ const platformLabel = (platform) => platform === "x" ? "X" : "LinkedIn";
33271
33749
  const lifecycleConnectContract = writeCLIContract({
33272
33750
  outputSchema: AccountConnectOutput,
33273
33751
  responseShaping: { supported: false },
33274
- idempotency: "non-idempotent"
33752
+ idempotency: {
33753
+ idempotent: false,
33754
+ retrySafeWith: "attemptId"
33755
+ },
33756
+ idField: "attemptId",
33757
+ hazards: [{
33758
+ code: "account_connect_billing",
33759
+ message: "The first call can start provider billing; pass the returned attemptId when polling so retries cannot start another charge."
33760
+ }]
33275
33761
  });
33276
33762
  const usernameLabelFor = (account) => account.username.startsWith("@") ? account.username : `@${account.username}`;
33277
33763
  const authHandshakeMessage = "Handshaking auth...";
@@ -33302,43 +33788,13 @@ const runConnectOutput = async (deps, connect) => {
33302
33788
  writeText(deps, `${usernameLabelFor(result.account)} connected!`);
33303
33789
  };
33304
33790
  const isInteractiveConnect = (deps) => deps.isInteractiveTerminal?.() === true;
33305
- /**
33306
- * One non-blocking step of a connect handshake for a non-TTY caller. Returns the
33307
- * connected account if one is already linked, otherwise emits the connect URL and
33308
- * reports `pending_approval`. A repeated call re-checks and advances — the skill
33309
- * polls this the same way it polls `social account setup`.
33310
- */
33311
- const runConnectStep = async (deps, platform, listConnected, connectURL) => {
33312
- const connected = (await listConnected()).find((account) => account.status === "connected");
33313
- if (connected) {
33314
- await writeOutput(deps, {
33315
- status: "connected",
33316
- platform,
33317
- account: connected
33318
- });
33319
- return;
33320
- }
33321
- const billing = await deps.client.billing.prepareAccountConnect();
33322
- if (!billing.canConnect) {
33323
- if (!billing.seats) throw new Error("billing_prepare_missing_seats");
33324
- if (billing.paymentURL) writeText(deps, `Open this URL: ${billing.paymentURL}`);
33325
- else if (billing.requiredAction) writeText(deps, billing.requiredAction.reason);
33326
- await writeOutput(deps, {
33327
- status: "pending_billing",
33328
- platform,
33329
- paymentURL: billing.paymentURL ?? null,
33330
- requiredAction: billing.requiredAction ?? null,
33331
- seats: billing.seats
33332
- });
33333
- return;
33334
- }
33335
- const url = await connectURL();
33336
- writeText(deps, `Open this URL: ${url}`);
33337
- await writeOutput(deps, {
33338
- status: "pending_approval",
33791
+ /** One retry-safe connect step for a non-TTY caller; the JSON carries its next attempt ID. */
33792
+ const runConnectStep = async (deps, platform, attemptId) => {
33793
+ const state = await deps.client.connectStep({
33339
33794
  platform,
33340
- connectURL: url
33795
+ ...attemptId ? { attemptId } : {}
33341
33796
  });
33797
+ await writeOutput(deps, state);
33342
33798
  };
33343
33799
  const createConnectPlatformCommand = (platform, run) => defineCommand({
33344
33800
  meta: commandMeta({
@@ -33348,8 +33804,12 @@ const createConnectPlatformCommand = (platform, run) => defineCommand({
33348
33804
  contract: lifecycleConnectContract,
33349
33805
  mutates: true
33350
33806
  }),
33351
- run: async () => {
33352
- await run();
33807
+ args: { attempt: {
33808
+ type: "string",
33809
+ description: "Resume the exact connect attempt returned by a previous call."
33810
+ } },
33811
+ run: async ({ args }) => {
33812
+ await run({ attempt: typeof args.attempt === "string" ? args.attempt : void 0 });
33353
33813
  }
33354
33814
  });
33355
33815
  const createAccountPlatformCommand = (platform, description, run, options = {}) => defineCommand({
@@ -33435,27 +33895,23 @@ const createAccountCommand = (deps, accountSetupCommand = setupCommand) => {
33435
33895
  description: "Connect a LinkedIn or X account."
33436
33896
  },
33437
33897
  subCommands: {
33438
- linkedin: createConnectPlatformCommand("linkedin", async () => {
33898
+ linkedin: createConnectPlatformCommand("linkedin", async ({ attempt }) => {
33439
33899
  if (isInteractiveConnect(deps)) {
33440
- await runConnectOutput(deps, connectLinkedinAccount);
33900
+ await runConnectOutput(deps, (connectDeps) => connectLinkedinAccount(connectDeps, attempt));
33441
33901
  return;
33442
33902
  }
33443
- await runConnectStep(deps, "linkedin", () => listLinkedinLifecycleAccounts(deps), () => createLinkedinConnectURL(deps));
33903
+ await runConnectStep(deps, "linkedin", attempt);
33444
33904
  }),
33445
- x: createConnectPlatformCommand("x", async () => {
33905
+ x: createConnectPlatformCommand("x", async ({ attempt }) => {
33446
33906
  if (isInteractiveConnect(deps)) {
33447
33907
  await runConnectOutput(deps, async (connectDeps) => {
33448
- const result = await connectXAccount(connectDeps);
33449
- if (G.isError(result)) throwXLifecycleError(result.error);
33908
+ const result = await connectXAccount(connectDeps, attempt);
33909
+ if (ae.isError(result)) throwXLifecycleError(result.error);
33450
33910
  return result.value;
33451
33911
  });
33452
33912
  return;
33453
33913
  }
33454
- await runConnectStep(deps, "x", async () => {
33455
- const result = await listXLifecycleAccounts(deps, true);
33456
- if (G.isError(result)) throwXLifecycleError(result.error);
33457
- return result.value;
33458
- }, () => createXConnectURL(deps));
33914
+ await runConnectStep(deps, "x", attempt);
33459
33915
  })
33460
33916
  }
33461
33917
  });
@@ -33471,7 +33927,7 @@ const createAccountCommand = (deps, accountSetupCommand = setupCommand) => {
33471
33927
  x: createAccountPlatformCommand("x", "Reconnect an X account.", async (args) => {
33472
33928
  await runConnectOutput(deps, async (connectDeps) => {
33473
33929
  const result = await reconnectXAccount(connectDeps, { account: String(args.account) });
33474
- if (G.isError(result)) throwXLifecycleError(result.error);
33930
+ if (ae.isError(result)) throwXLifecycleError(result.error);
33475
33931
  return result.value;
33476
33932
  });
33477
33933
  }, { accountArg: xAccountArg })
@@ -33497,7 +33953,7 @@ const createAccountCommand = (deps, accountSetupCommand = setupCommand) => {
33497
33953
  }) }),
33498
33954
  x: createAccountPlatformCommand("x", "Disconnect an X account.", async (args) => {
33499
33955
  const result = await disconnectXAccount(deps, String(args.account));
33500
- if (G.isError(result)) throwXLifecycleError(result.error);
33956
+ if (ae.isError(result)) throwXLifecycleError(result.error);
33501
33957
  await writeOutput(deps, result.value);
33502
33958
  }, {
33503
33959
  accountArg: xAccountArg,
@@ -33722,12 +34178,12 @@ const selectAccountOutcome = ({ accounts, defaultAccount, explicitAccount }) =>
33722
34178
  };
33723
34179
  };
33724
34180
  const requireSelectedAccount = (outcome, platform) => {
33725
- if (outcome.status === "selected") return G.ok(outcome);
33726
- if (outcome.status === "missingExplicitAccount") return G.err(new AccountNotFound({
34181
+ if (outcome.status === "selected") return ae.ok(outcome);
34182
+ if (outcome.status === "missingExplicitAccount") return ae.err(new AccountNotFound({
33727
34183
  account: outcome.account,
33728
34184
  platform
33729
34185
  }));
33730
- return G.err(new NoConnectedAccount(platform));
34186
+ return ae.err(new NoConnectedAccount(platform));
33731
34187
  };
33732
34188
  const isRecord$1 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
33733
34189
  const stringField = (value, key) => {
@@ -33740,35 +34196,35 @@ const stringOrNumberField = (value, key) => {
33740
34196
  return typeof field === "number" && Number.isFinite(field) ? String(field) : void 0;
33741
34197
  };
33742
34198
  const parseXLookupResponse = (data, input) => {
33743
- if (!(isRecord$1(data) && isRecord$1(data.data))) return G.err(new LookupPayloadInvalid({
34199
+ if (!(isRecord$1(data) && isRecord$1(data.data))) return ae.err(new LookupPayloadInvalid({
33744
34200
  input,
33745
34201
  platform: "x"
33746
34202
  }));
33747
34203
  const id = stringOrNumberField(data.data, "id");
33748
- if (!id) return G.err(new LookupPayloadInvalid({
34204
+ if (!id) return ae.err(new LookupPayloadInvalid({
33749
34205
  input,
33750
34206
  platform: "x"
33751
34207
  }));
33752
34208
  const inputUsername = input.replace(/^@+/, "");
33753
34209
  const resolvedUsername = stringField(data.data, "username") ?? inputUsername;
33754
- return G.ok({
34210
+ return ae.ok({
33755
34211
  id,
33756
34212
  url: `https://x.com/${resolvedUsername}`
33757
34213
  });
33758
34214
  };
33759
34215
  const parseLinkedinProfileLookupResponse = (data, input) => {
33760
34216
  const profile = isRecord$1(data) && isRecord$1(data.data) ? data.data : data;
33761
- if (!isRecord$1(profile)) return G.err(new LookupPayloadInvalid({
34217
+ if (!isRecord$1(profile)) return ae.err(new LookupPayloadInvalid({
33762
34218
  input,
33763
34219
  platform: "linkedin"
33764
34220
  }));
33765
34221
  const id = stringOrNumberField(profile, "provider_id") ?? stringOrNumberField(profile, "providerId") ?? stringOrNumberField(profile, "id");
33766
- if (!id) return G.err(new LookupPayloadInvalid({
34222
+ if (!id) return ae.err(new LookupPayloadInvalid({
33767
34223
  input,
33768
34224
  platform: "linkedin"
33769
34225
  }));
33770
34226
  const publicIdentifier = stringField(profile, "public_identifier") ?? stringField(profile, "publicIdentifier");
33771
- return G.ok({
34227
+ return ae.ok({
33772
34228
  id,
33773
34229
  ...publicIdentifier ? { url: `https://www.linkedin.com/in/${encodeURIComponent(publicIdentifier)}` } : {}
33774
34230
  });
@@ -33786,7 +34242,7 @@ const headerValuesFromRawArgs = (rawArgs = []) => {
33786
34242
  if (arg === "--") break;
33787
34243
  if (arg === "--header" || arg === "-H") {
33788
34244
  const value = rawArgs[index + 1];
33789
- if (value === void 0) return G.err(headerError("missingHeaderValue", `Pass a value for ${arg}.`));
34245
+ if (value === void 0) return ae.err(headerError("missingHeaderValue", `Pass a value for ${arg}.`));
33790
34246
  values.push(value);
33791
34247
  index += 1;
33792
34248
  continue;
@@ -33797,25 +34253,25 @@ const headerValuesFromRawArgs = (rawArgs = []) => {
33797
34253
  }
33798
34254
  if (arg?.startsWith("-H=")) values.push(arg.slice(3));
33799
34255
  }
33800
- return G.ok(values);
34256
+ return ae.ok(values);
33801
34257
  };
33802
34258
  const commandHeaderValuesFrom = ({ headers, rawArgs }) => {
33803
34259
  const rawValues = headerValuesFromRawArgs(rawArgs);
33804
- if (G.isError(rawValues)) return rawValues;
34260
+ if (ae.isError(rawValues)) return rawValues;
33805
34261
  if (rawValues.value.length > 0) return rawValues;
33806
- if (headers === void 0) return G.ok([]);
33807
- if (typeof headers === "string") return G.ok([headers]);
33808
- if (Array.isArray(headers) && headers.every((header) => typeof header === "string")) return G.ok(headers);
33809
- return G.err(headerError("invalidHeaderList", "Pass --header as Name: value."));
34262
+ if (headers === void 0) return ae.ok([]);
34263
+ if (typeof headers === "string") return ae.ok([headers]);
34264
+ if (Array.isArray(headers) && headers.every((header) => typeof header === "string")) return ae.ok(headers);
34265
+ return ae.err(headerError("invalidHeaderList", "Pass --header as Name: value."));
33810
34266
  };
33811
34267
  const parsedHeaderFrom = (header) => {
33812
34268
  const colon = header.indexOf(":");
33813
- if (colon <= 0) return G.err(headerError("malformedHeader", "Pass --header as Name: value."));
34269
+ if (colon <= 0) return ae.err(headerError("malformedHeader", "Pass --header as Name: value."));
33814
34270
  const name = header.slice(0, colon).trim();
33815
34271
  const value = header.slice(colon + 1).trim();
33816
34272
  const normalized = name.toLowerCase();
33817
- if (normalized === "authorization" || normalized === "content-type" || normalized.startsWith("x-social-")) return G.err(headerError("reservedHeader", `Header ${name} is reserved and cannot be set with --header.`));
33818
- return G.ok({
34273
+ if (normalized === "authorization" || normalized === "content-type" || normalized.startsWith("x-social-")) return ae.err(headerError("reservedHeader", `Header ${name} is reserved and cannot be set with --header.`));
34274
+ return ae.ok({
33819
34275
  name,
33820
34276
  value
33821
34277
  });
@@ -33823,17 +34279,17 @@ const parsedHeaderFrom = (header) => {
33823
34279
  const commandHeadersFrom = (defaults, args = {}) => {
33824
34280
  const headers = new Headers(defaults);
33825
34281
  const rawHeaders = commandHeaderValuesFrom(args);
33826
- if (G.isError(rawHeaders)) return G.err(rawHeaders.error);
34282
+ if (ae.isError(rawHeaders)) return ae.err(rawHeaders.error);
33827
34283
  for (const rawHeader of rawHeaders.value) {
33828
34284
  const parsed = parsedHeaderFrom(rawHeader);
33829
- if (G.isError(parsed)) return G.err(parsed.error);
34285
+ if (ae.isError(parsed)) return ae.err(parsed.error);
33830
34286
  try {
33831
34287
  headers.set(parsed.value.name, parsed.value.value);
33832
34288
  } catch {
33833
- return G.err(headerError("invalidHeader", `Invalid header ${parsed.value.name}.`));
34289
+ return ae.err(headerError("invalidHeader", `Invalid header ${parsed.value.name}.`));
33834
34290
  }
33835
34291
  }
33836
- return G.ok(Object.fromEntries(headers.entries()));
34292
+ return ae.ok(Object.fromEntries(headers.entries()));
33837
34293
  };
33838
34294
  //#endregion
33839
34295
  //#region ../../node_modules/.bun/@borewit+text-codec@0.2.2/node_modules/@borewit/text-codec/lib/index.js
@@ -38771,7 +39227,7 @@ const createCLIDeps = () => {
38771
39227
  platform
38772
39228
  });
38773
39229
  const selected = requireSelectedAccount(outcome, platform);
38774
- if (G.isOk(selected)) return selected.value;
39230
+ if (ae.isOk(selected)) return selected.value;
38775
39231
  if (outcome.status === "missingExplicitAccount") throw new NotFoundError(`${platform}_account_not_found`);
38776
39232
  throw new Error(`${platform}_account_not_connected`);
38777
39233
  };
@@ -38786,7 +39242,7 @@ const createCLIDeps = () => {
38786
39242
  ...selectedAccount.selector === void 0 ? {} : { "x-social-account-id": selectedAccount.selector }
38787
39243
  };
38788
39244
  const parsed = parseXLookupResponse(await api.get(`x/users/by/username/${encodeURIComponent(inputUsername)}`, { headers }).json(), input);
38789
- if (G.isError(parsed)) throw new Error(`Could not resolve X username ${input}.`);
39245
+ if (ae.isError(parsed)) throw new Error(`Could not resolve X username ${input}.`);
38790
39246
  return parsed.value;
38791
39247
  };
38792
39248
  const lookupLinkedinProfile = async (input, account, selectedAccount) => {
@@ -38799,32 +39255,26 @@ const createCLIDeps = () => {
38799
39255
  ...resolvedAccount.selector === void 0 ? {} : { "x-social-account-id": resolvedAccount.selector }
38800
39256
  };
38801
39257
  const parsed = parseLinkedinProfileLookupResponse(await api.get(`linkedin/users/${encodeURIComponent(input)}`, { headers }).json(), input);
38802
- if (G.isError(parsed)) throw new Error(`Could not resolve LinkedIn profile ${input}.`);
39258
+ if (ae.isError(parsed)) throw new Error(`Could not resolve LinkedIn profile ${input}.`);
38803
39259
  return parsed.value;
38804
39260
  };
38805
39261
  return {
38806
39262
  client: {
38807
39263
  listAccounts: client.accounts.list,
38808
39264
  createHostedAuthURL: client.accounts.reconnectURL,
39265
+ connectStep: client.accounts.connectStep,
38809
39266
  disconnectAccount: client.accounts.disconnect,
38810
39267
  accounts: {
38811
39268
  list: client.accounts.list,
38812
39269
  default: client.accounts.default,
39270
+ connectStep: client.accounts.connectStep,
38813
39271
  reconnectURL: client.accounts.reconnectURL,
38814
39272
  disconnect: client.accounts.disconnect
38815
39273
  },
38816
39274
  billing: {
38817
- status: async () => {
38818
- return await client.billing.status();
38819
- },
38820
- prepareAccountConnect: async () => {
38821
- const status = await client.billing.prepareAccountConnect();
38822
- return {
38823
- canConnect: status.canConnect,
38824
- paymentURL: status.paymentURL,
38825
- requiredAction: status.requiredAction,
38826
- seats: status.seats
38827
- };
39275
+ status: client.billing.status,
39276
+ providerStatus: async ({ platform }) => {
39277
+ return (await client.billing.status()).providers[platform];
38828
39278
  },
38829
39279
  portalURL: client.billing.portalURL
38830
39280
  },
@@ -38864,7 +39314,7 @@ const createCLIDeps = () => {
38864
39314
  }),
38865
39315
  commandHeaders: async (args) => {
38866
39316
  const headers = commandHeadersFrom({ "Cache-Control": await cacheControlHeaderFromConfig() }, args);
38867
- if (G.isError(headers)) throw new UsageError(headers.error.message);
39317
+ if (ae.isError(headers)) throw new UsageError(headers.error.message);
38868
39318
  return headers.value;
38869
39319
  },
38870
39320
  printData,
@@ -39349,7 +39799,7 @@ const schemaAtPath = (command, commandPathInput, options = {}) => {
39349
39799
  command,
39350
39800
  path: []
39351
39801
  } : commandAtPath(command, parts);
39352
- return G.ok({
39802
+ return ae.ok({
39353
39803
  schemaVersion: "2.0",
39354
39804
  commands: Object.fromEntries(leafSchemasForCommand(selectedCommand, path))
39355
39805
  });
@@ -39359,31 +39809,31 @@ const schemaAtPath = (command, commandPathInput, options = {}) => {
39359
39809
  command,
39360
39810
  path: []
39361
39811
  } : commandAtPath(command, parts);
39362
- return G.ok({
39812
+ return ae.ok({
39363
39813
  schemaVersion: "2.0",
39364
39814
  commands: Object.fromEntries(compactLeafSchemasForCommand(selectedCommand, path))
39365
39815
  });
39366
39816
  }
39367
- if (parts.length === 0) return G.ok({
39817
+ if (parts.length === 0) return ae.ok({
39368
39818
  schemaVersion: "2.0",
39369
39819
  ...schemaTreeForCommand(command)
39370
39820
  });
39371
39821
  const { command: selectedCommand, path, positionalMatch } = commandAtPath(command, parts);
39372
- if (positionalMatch) return G.ok({
39822
+ if (positionalMatch) return ae.ok({
39373
39823
  schemaVersion: "2.0",
39374
39824
  ...schemaForCommand(selectedCommand, path),
39375
39825
  ...positionalMatch
39376
39826
  });
39377
- if (selectedCommand.subCommands && typeof selectedCommand.run !== "function") return G.ok({
39827
+ if (selectedCommand.subCommands && typeof selectedCommand.run !== "function") return ae.ok({
39378
39828
  schemaVersion: "2.0",
39379
39829
  ...schemaTreeForCommand(selectedCommand, path)
39380
39830
  });
39381
- return G.ok({
39831
+ return ae.ok({
39382
39832
  schemaVersion: "2.0",
39383
39833
  ...schemaForCommand(selectedCommand, path)
39384
39834
  });
39385
39835
  } catch (error) {
39386
- return G.err(schemaErrorFor(error, parts));
39836
+ return ae.err(schemaErrorFor(error, parts));
39387
39837
  }
39388
39838
  };
39389
39839
  const schemaCommand = defineCommand({
@@ -39418,7 +39868,7 @@ const schemaCommand = defineCommand({
39418
39868
  if (!rootCommand) throw new Error("schema_root_command_unconfigured");
39419
39869
  const commandPathInput = Array.isArray(args._) && args._.length > 1 ? args._ : args.commandPath;
39420
39870
  const schema = schemaAtPath(rootCommand, commandPathInput, { mode: args.leaves === true ? "leaves" : args.list === true ? "list" : "leaf" });
39421
- if (G.isError(schema)) throw new Error(schema.error.message);
39871
+ if (ae.isError(schema)) throw new Error(schema.error.message);
39422
39872
  printData(schema.value);
39423
39873
  }
39424
39874
  });