@arcote.tech/arc-cli 0.7.27 → 0.7.29

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.js CHANGED
@@ -3445,7 +3445,7 @@ var init_log_update = __esm(() => {
3445
3445
  logUpdateStderr = createLogUpdate(process7.stderr);
3446
3446
  });
3447
3447
 
3448
- // ../../node_modules/.bun/listr2@8.3.3/node_modules/listr2/node_modules/cli-truncate/node_modules/slice-ansi/node_modules/is-fullwidth-code-point/index.js
3448
+ // ../../node_modules/.bun/is-fullwidth-code-point@4.0.0/node_modules/is-fullwidth-code-point/index.js
3449
3449
  function isFullwidthCodePoint2(codePoint) {
3450
3450
  if (!Number.isInteger(codePoint)) {
3451
3451
  return false;
@@ -3453,183 +3453,7 @@ function isFullwidthCodePoint2(codePoint) {
3453
3453
  return codePoint >= 4352 && (codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || 11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || 12880 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65131 || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 262141);
3454
3454
  }
3455
3455
 
3456
- // ../../node_modules/.bun/listr2@8.3.3/node_modules/listr2/node_modules/cli-truncate/node_modules/slice-ansi/node_modules/ansi-styles/index.js
3457
- function assembleStyles2() {
3458
- const codes = new Map;
3459
- for (const [groupName, group] of Object.entries(styles2)) {
3460
- for (const [styleName, style] of Object.entries(group)) {
3461
- styles2[styleName] = {
3462
- open: `\x1B[${style[0]}m`,
3463
- close: `\x1B[${style[1]}m`
3464
- };
3465
- group[styleName] = styles2[styleName];
3466
- codes.set(style[0], style[1]);
3467
- }
3468
- Object.defineProperty(styles2, groupName, {
3469
- value: group,
3470
- enumerable: false
3471
- });
3472
- }
3473
- Object.defineProperty(styles2, "codes", {
3474
- value: codes,
3475
- enumerable: false
3476
- });
3477
- styles2.color.close = "\x1B[39m";
3478
- styles2.bgColor.close = "\x1B[49m";
3479
- styles2.color.ansi = wrapAnsi162();
3480
- styles2.color.ansi256 = wrapAnsi2562();
3481
- styles2.color.ansi16m = wrapAnsi16m2();
3482
- styles2.bgColor.ansi = wrapAnsi162(ANSI_BACKGROUND_OFFSET2);
3483
- styles2.bgColor.ansi256 = wrapAnsi2562(ANSI_BACKGROUND_OFFSET2);
3484
- styles2.bgColor.ansi16m = wrapAnsi16m2(ANSI_BACKGROUND_OFFSET2);
3485
- Object.defineProperties(styles2, {
3486
- rgbToAnsi256: {
3487
- value(red2, green2, blue2) {
3488
- if (red2 === green2 && green2 === blue2) {
3489
- if (red2 < 8) {
3490
- return 16;
3491
- }
3492
- if (red2 > 248) {
3493
- return 231;
3494
- }
3495
- return Math.round((red2 - 8) / 247 * 24) + 232;
3496
- }
3497
- return 16 + 36 * Math.round(red2 / 255 * 5) + 6 * Math.round(green2 / 255 * 5) + Math.round(blue2 / 255 * 5);
3498
- },
3499
- enumerable: false
3500
- },
3501
- hexToRgb: {
3502
- value(hex) {
3503
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
3504
- if (!matches) {
3505
- return [0, 0, 0];
3506
- }
3507
- let [colorString] = matches;
3508
- if (colorString.length === 3) {
3509
- colorString = [...colorString].map((character) => character + character).join("");
3510
- }
3511
- const integer = Number.parseInt(colorString, 16);
3512
- return [
3513
- integer >> 16 & 255,
3514
- integer >> 8 & 255,
3515
- integer & 255
3516
- ];
3517
- },
3518
- enumerable: false
3519
- },
3520
- hexToAnsi256: {
3521
- value: (hex) => styles2.rgbToAnsi256(...styles2.hexToRgb(hex)),
3522
- enumerable: false
3523
- },
3524
- ansi256ToAnsi: {
3525
- value(code) {
3526
- if (code < 8) {
3527
- return 30 + code;
3528
- }
3529
- if (code < 16) {
3530
- return 90 + (code - 8);
3531
- }
3532
- let red2;
3533
- let green2;
3534
- let blue2;
3535
- if (code >= 232) {
3536
- red2 = ((code - 232) * 10 + 8) / 255;
3537
- green2 = red2;
3538
- blue2 = red2;
3539
- } else {
3540
- code -= 16;
3541
- const remainder = code % 36;
3542
- red2 = Math.floor(code / 36) / 5;
3543
- green2 = Math.floor(remainder / 6) / 5;
3544
- blue2 = remainder % 6 / 5;
3545
- }
3546
- const value = Math.max(red2, green2, blue2) * 2;
3547
- if (value === 0) {
3548
- return 30;
3549
- }
3550
- let result = 30 + (Math.round(blue2) << 2 | Math.round(green2) << 1 | Math.round(red2));
3551
- if (value === 2) {
3552
- result += 60;
3553
- }
3554
- return result;
3555
- },
3556
- enumerable: false
3557
- },
3558
- rgbToAnsi: {
3559
- value: (red2, green2, blue2) => styles2.ansi256ToAnsi(styles2.rgbToAnsi256(red2, green2, blue2)),
3560
- enumerable: false
3561
- },
3562
- hexToAnsi: {
3563
- value: (hex) => styles2.ansi256ToAnsi(styles2.hexToAnsi256(hex)),
3564
- enumerable: false
3565
- }
3566
- });
3567
- return styles2;
3568
- }
3569
- var ANSI_BACKGROUND_OFFSET2 = 10, wrapAnsi162 = (offset = 0) => (code) => `\x1B[${code + offset}m`, wrapAnsi2562 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`, wrapAnsi16m2 = (offset = 0) => (red2, green2, blue2) => `\x1B[${38 + offset};2;${red2};${green2};${blue2}m`, styles2, modifierNames2, foregroundColorNames2, backgroundColorNames2, colorNames2, ansiStyles2, ansi_styles_default2;
3570
- var init_ansi_styles2 = __esm(() => {
3571
- styles2 = {
3572
- modifier: {
3573
- reset: [0, 0],
3574
- bold: [1, 22],
3575
- dim: [2, 22],
3576
- italic: [3, 23],
3577
- underline: [4, 24],
3578
- overline: [53, 55],
3579
- inverse: [7, 27],
3580
- hidden: [8, 28],
3581
- strikethrough: [9, 29]
3582
- },
3583
- color: {
3584
- black: [30, 39],
3585
- red: [31, 39],
3586
- green: [32, 39],
3587
- yellow: [33, 39],
3588
- blue: [34, 39],
3589
- magenta: [35, 39],
3590
- cyan: [36, 39],
3591
- white: [37, 39],
3592
- blackBright: [90, 39],
3593
- gray: [90, 39],
3594
- grey: [90, 39],
3595
- redBright: [91, 39],
3596
- greenBright: [92, 39],
3597
- yellowBright: [93, 39],
3598
- blueBright: [94, 39],
3599
- magentaBright: [95, 39],
3600
- cyanBright: [96, 39],
3601
- whiteBright: [97, 39]
3602
- },
3603
- bgColor: {
3604
- bgBlack: [40, 49],
3605
- bgRed: [41, 49],
3606
- bgGreen: [42, 49],
3607
- bgYellow: [43, 49],
3608
- bgBlue: [44, 49],
3609
- bgMagenta: [45, 49],
3610
- bgCyan: [46, 49],
3611
- bgWhite: [47, 49],
3612
- bgBlackBright: [100, 49],
3613
- bgGray: [100, 49],
3614
- bgGrey: [100, 49],
3615
- bgRedBright: [101, 49],
3616
- bgGreenBright: [102, 49],
3617
- bgYellowBright: [103, 49],
3618
- bgBlueBright: [104, 49],
3619
- bgMagentaBright: [105, 49],
3620
- bgCyanBright: [106, 49],
3621
- bgWhiteBright: [107, 49]
3622
- }
3623
- };
3624
- modifierNames2 = Object.keys(styles2.modifier);
3625
- foregroundColorNames2 = Object.keys(styles2.color);
3626
- backgroundColorNames2 = Object.keys(styles2.bgColor);
3627
- colorNames2 = [...foregroundColorNames2, ...backgroundColorNames2];
3628
- ansiStyles2 = assembleStyles2();
3629
- ansi_styles_default2 = ansiStyles2;
3630
- });
3631
-
3632
- // ../../node_modules/.bun/listr2@8.3.3/node_modules/listr2/node_modules/cli-truncate/node_modules/slice-ansi/index.js
3456
+ // ../../node_modules/.bun/slice-ansi@5.0.0/node_modules/slice-ansi/index.js
3633
3457
  function sliceAnsi2(string, begin, end) {
3634
3458
  const characters = [...string];
3635
3459
  const ansiCodes = [];
@@ -3681,7 +3505,7 @@ var astralRegex, ESCAPES3, wrapAnsi2 = (code) => `${ESCAPES3[0]}[${code}m`, chec
3681
3505
  if (ansiCode.includes(";")) {
3682
3506
  ansiCode = ansiCode.split(";")[0][0] + "0";
3683
3507
  }
3684
- const item = ansi_styles_default2.codes.get(Number.parseInt(ansiCode, 10));
3508
+ const item = ansi_styles_default.codes.get(Number.parseInt(ansiCode, 10));
3685
3509
  if (item) {
3686
3510
  const indexEscape = ansiCodes.indexOf(item.toString());
3687
3511
  if (indexEscape === -1) {
@@ -3699,14 +3523,14 @@ var astralRegex, ESCAPES3, wrapAnsi2 = (code) => `${ESCAPES3[0]}[${code}m`, chec
3699
3523
  if (isEscapes) {
3700
3524
  output = output.filter((element, index) => output.indexOf(element) === index);
3701
3525
  if (endAnsiCode !== undefined) {
3702
- const fistEscapeCode = wrapAnsi2(ansi_styles_default2.codes.get(Number.parseInt(endAnsiCode, 10)));
3526
+ const fistEscapeCode = wrapAnsi2(ansi_styles_default.codes.get(Number.parseInt(endAnsiCode, 10)));
3703
3527
  output = output.reduce((current, next) => next === fistEscapeCode ? [next, ...current] : [...current, next], []);
3704
3528
  }
3705
3529
  }
3706
3530
  return output.join("");
3707
3531
  };
3708
3532
  var init_slice_ansi2 = __esm(() => {
3709
- init_ansi_styles2();
3533
+ init_ansi_styles();
3710
3534
  astralRegex = /^[\uD800-\uDBFF][\uDC00-\uDFFF]$/;
3711
3535
  ESCAPES3 = [
3712
3536
  "\x1B",
@@ -3714,89 +3538,7 @@ var init_slice_ansi2 = __esm(() => {
3714
3538
  ];
3715
3539
  });
3716
3540
 
3717
- // ../../node_modules/.bun/listr2@8.3.3/node_modules/listr2/node_modules/cli-truncate/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex/index.js
3718
- function ansiRegex2({ onlyFirst = false } = {}) {
3719
- const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
3720
- const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
3721
- const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
3722
- const pattern = `${osc}|${csi}`;
3723
- return new RegExp(pattern, onlyFirst ? undefined : "g");
3724
- }
3725
-
3726
- // ../../node_modules/.bun/listr2@8.3.3/node_modules/listr2/node_modules/cli-truncate/node_modules/string-width/node_modules/strip-ansi/index.js
3727
- function stripAnsi2(string) {
3728
- if (typeof string !== "string") {
3729
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
3730
- }
3731
- if (!string.includes("\x1B") && !string.includes("\x9B")) {
3732
- return string;
3733
- }
3734
- return string.replace(regex2, "");
3735
- }
3736
- var regex2;
3737
- var init_strip_ansi2 = __esm(() => {
3738
- regex2 = ansiRegex2();
3739
- });
3740
-
3741
- // ../../node_modules/.bun/listr2@8.3.3/node_modules/listr2/node_modules/cli-truncate/node_modules/string-width/node_modules/emoji-regex/index.mjs
3742
- var emoji_regex_default2 = () => {
3743
- return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
3744
- };
3745
-
3746
- // ../../node_modules/.bun/listr2@8.3.3/node_modules/listr2/node_modules/cli-truncate/node_modules/string-width/index.js
3747
- function stringWidth2(string, options = {}) {
3748
- if (typeof string !== "string" || string.length === 0) {
3749
- return 0;
3750
- }
3751
- const {
3752
- ambiguousIsNarrow = true,
3753
- countAnsiEscapeCodes = false
3754
- } = options;
3755
- if (!countAnsiEscapeCodes) {
3756
- string = stripAnsi2(string);
3757
- }
3758
- if (string.length === 0) {
3759
- return 0;
3760
- }
3761
- let width = 0;
3762
- const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
3763
- for (const { segment: character } of segmenter2.segment(string)) {
3764
- const codePoint = character.codePointAt(0);
3765
- if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
3766
- continue;
3767
- }
3768
- if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
3769
- continue;
3770
- }
3771
- if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
3772
- continue;
3773
- }
3774
- if (codePoint >= 55296 && codePoint <= 57343) {
3775
- continue;
3776
- }
3777
- if (codePoint >= 65024 && codePoint <= 65039) {
3778
- continue;
3779
- }
3780
- if (defaultIgnorableCodePointRegex2.test(character)) {
3781
- continue;
3782
- }
3783
- if (emoji_regex_default2().test(character)) {
3784
- width += 2;
3785
- continue;
3786
- }
3787
- width += eastAsianWidth(codePoint, eastAsianWidthOptions);
3788
- }
3789
- return width;
3790
- }
3791
- var segmenter2, defaultIgnorableCodePointRegex2;
3792
- var init_string_width2 = __esm(() => {
3793
- init_strip_ansi2();
3794
- init_get_east_asian_width();
3795
- segmenter2 = new Intl.Segmenter;
3796
- defaultIgnorableCodePointRegex2 = /^\p{Default_Ignorable_Code_Point}$/u;
3797
- });
3798
-
3799
- // ../../node_modules/.bun/listr2@8.3.3/node_modules/listr2/node_modules/cli-truncate/index.js
3541
+ // ../../node_modules/.bun/cli-truncate@4.0.0/node_modules/cli-truncate/index.js
3800
3542
  var exports_cli_truncate = {};
3801
3543
  __export(exports_cli_truncate, {
3802
3544
  default: () => cliTruncate
@@ -3833,7 +3575,7 @@ function cliTruncate(text, columns, options = {}) {
3833
3575
  if (columns === 1) {
3834
3576
  return truncationCharacter;
3835
3577
  }
3836
- const length = stringWidth2(text);
3578
+ const length = stringWidth(text);
3837
3579
  if (length <= columns) {
3838
3580
  return text;
3839
3581
  }
@@ -3845,7 +3587,7 @@ function cliTruncate(text, columns, options = {}) {
3845
3587
  if (space === true) {
3846
3588
  truncationCharacter += " ";
3847
3589
  }
3848
- return truncationCharacter + sliceAnsi2(text, length - columns + stringWidth2(truncationCharacter), length);
3590
+ return truncationCharacter + sliceAnsi2(text, length - columns + stringWidth(truncationCharacter), length);
3849
3591
  }
3850
3592
  if (position === "middle") {
3851
3593
  if (space === true) {
@@ -3857,7 +3599,7 @@ function cliTruncate(text, columns, options = {}) {
3857
3599
  const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + 1, true);
3858
3600
  return sliceAnsi2(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi2(text, spaceNearSecondBreakPoint, length).trim();
3859
3601
  }
3860
- return sliceAnsi2(text, 0, half) + truncationCharacter + sliceAnsi2(text, length - (columns - half) + stringWidth2(truncationCharacter), length);
3602
+ return sliceAnsi2(text, 0, half) + truncationCharacter + sliceAnsi2(text, length - (columns - half) + stringWidth(truncationCharacter), length);
3861
3603
  }
3862
3604
  if (position === "end") {
3863
3605
  if (preferTruncationOnSpace) {
@@ -3867,13 +3609,13 @@ function cliTruncate(text, columns, options = {}) {
3867
3609
  if (space === true) {
3868
3610
  truncationCharacter = ` ${truncationCharacter}`;
3869
3611
  }
3870
- return sliceAnsi2(text, 0, columns - stringWidth2(truncationCharacter)) + truncationCharacter;
3612
+ return sliceAnsi2(text, 0, columns - stringWidth(truncationCharacter)) + truncationCharacter;
3871
3613
  }
3872
3614
  throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`);
3873
3615
  }
3874
3616
  var init_cli_truncate = __esm(() => {
3875
3617
  init_slice_ansi2();
3876
- init_string_width2();
3618
+ init_string_width();
3877
3619
  });
3878
3620
 
3879
3621
  // ../../node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js
@@ -5637,17 +5379,17 @@ var require_picomatch = __commonJS((exports, module) => {
5637
5379
  }
5638
5380
  const opts = options || {};
5639
5381
  const posix2 = utils.isWindows(options);
5640
- const regex3 = isState ? picomatch.compileRe(glob2, options) : picomatch.makeRe(glob2, options, false, true);
5641
- const state = regex3.state;
5642
- delete regex3.state;
5382
+ const regex2 = isState ? picomatch.compileRe(glob2, options) : picomatch.makeRe(glob2, options, false, true);
5383
+ const state = regex2.state;
5384
+ delete regex2.state;
5643
5385
  let isIgnored = () => false;
5644
5386
  if (opts.ignore) {
5645
5387
  const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
5646
5388
  isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
5647
5389
  }
5648
5390
  const matcher = (input, returnObject = false) => {
5649
- const { isMatch, match: match2, output } = picomatch.test(input, regex3, options, { glob: glob2, posix: posix2 });
5650
- const result = { glob: glob2, state, regex: regex3, posix: posix2, input, output, match: match2, isMatch };
5391
+ const { isMatch, match: match2, output } = picomatch.test(input, regex2, options, { glob: glob2, posix: posix2 });
5392
+ const result = { glob: glob2, state, regex: regex2, posix: posix2, input, output, match: match2, isMatch };
5651
5393
  if (typeof opts.onResult === "function") {
5652
5394
  opts.onResult(result);
5653
5395
  }
@@ -5672,7 +5414,7 @@ var require_picomatch = __commonJS((exports, module) => {
5672
5414
  }
5673
5415
  return matcher;
5674
5416
  };
5675
- picomatch.test = (input, regex3, options, { glob: glob2, posix: posix2 } = {}) => {
5417
+ picomatch.test = (input, regex2, options, { glob: glob2, posix: posix2 } = {}) => {
5676
5418
  if (typeof input !== "string") {
5677
5419
  throw new TypeError("Expected input to be a string");
5678
5420
  }
@@ -5689,16 +5431,16 @@ var require_picomatch = __commonJS((exports, module) => {
5689
5431
  }
5690
5432
  if (match2 === false || opts.capture === true) {
5691
5433
  if (opts.matchBase === true || opts.basename === true) {
5692
- match2 = picomatch.matchBase(input, regex3, options, posix2);
5434
+ match2 = picomatch.matchBase(input, regex2, options, posix2);
5693
5435
  } else {
5694
- match2 = regex3.exec(output);
5436
+ match2 = regex2.exec(output);
5695
5437
  }
5696
5438
  }
5697
5439
  return { isMatch: Boolean(match2), match: match2, output };
5698
5440
  };
5699
5441
  picomatch.matchBase = (input, glob2, options, posix2 = utils.isWindows(options)) => {
5700
- const regex3 = glob2 instanceof RegExp ? glob2 : picomatch.makeRe(glob2, options);
5701
- return regex3.test(path4.basename(input));
5442
+ const regex2 = glob2 instanceof RegExp ? glob2 : picomatch.makeRe(glob2, options);
5443
+ return regex2.test(path4.basename(input));
5702
5444
  };
5703
5445
  picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
5704
5446
  picomatch.parse = (pattern, options) => {
@@ -5718,11 +5460,11 @@ var require_picomatch = __commonJS((exports, module) => {
5718
5460
  if (state && state.negated === true) {
5719
5461
  source = `^(?!${source}).*$`;
5720
5462
  }
5721
- const regex3 = picomatch.toRegex(source, options);
5463
+ const regex2 = picomatch.toRegex(source, options);
5722
5464
  if (returnState === true) {
5723
- regex3.state = state;
5465
+ regex2.state = state;
5724
5466
  }
5725
- return regex3;
5467
+ return regex2;
5726
5468
  };
5727
5469
  picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
5728
5470
  if (!input || typeof input !== "string") {
@@ -9634,6 +9376,7 @@ var exports_dist2 = {};
9634
9376
  __export(exports_dist2, {
9635
9377
  createPostgreSQLAdapterFactoryFromUrl: () => createPostgreSQLAdapterFactoryFromUrl,
9636
9378
  createPostgreSQLAdapterFactory: () => createPostgreSQLAdapterFactory,
9379
+ coercePgNumber: () => coercePgNumber,
9637
9380
  PostgreSQLAdapter: () => PostgreSQLAdapter
9638
9381
  });
9639
9382
  import os2 from "os";
@@ -10866,9 +10609,21 @@ class LocalEventPublisher2 {
10866
10609
  views = [];
10867
10610
  syncCallback;
10868
10611
  subscribers = new Map;
10612
+ pending = new Set;
10869
10613
  constructor(dataStorage) {
10870
10614
  this.dataStorage = dataStorage;
10871
10615
  }
10616
+ track(work) {
10617
+ const wrapped = Promise.resolve(work).catch(() => {}).finally(() => {
10618
+ this.pending.delete(wrapped);
10619
+ });
10620
+ this.pending.add(wrapped);
10621
+ }
10622
+ async whenIdle() {
10623
+ while (this.pending.size > 0) {
10624
+ await Promise.all([...this.pending]);
10625
+ }
10626
+ }
10872
10627
  onPublish(callback) {
10873
10628
  this.syncCallback = callback;
10874
10629
  }
@@ -10904,9 +10659,12 @@ class LocalEventPublisher2 {
10904
10659
  store: EVENT_TABLES.events,
10905
10660
  changes: [{ type: "set", data: storedEvent }]
10906
10661
  });
10907
- if (event.payload && typeof event.payload === "object") {
10662
+ const tagFields = event.definition?.tagFields ?? [];
10663
+ if (tagFields.length > 0 && event.payload && typeof event.payload === "object") {
10664
+ const payload = event.payload;
10908
10665
  const tagChanges = [];
10909
- for (const [key, value] of Object.entries(event.payload)) {
10666
+ for (const key of tagFields) {
10667
+ const value = payload[key];
10910
10668
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
10911
10669
  tagChanges.push({
10912
10670
  type: "set",
@@ -11064,6 +10822,47 @@ class LocalEventPublisher2 {
11064
10822
  return allViewChanges;
11065
10823
  }
11066
10824
  }
10825
+ function murmurHash(key, seed = 0) {
10826
+ let remainder, bytes, h1, h1b, c1, c2, k1, i;
10827
+ remainder = key.length & 3;
10828
+ bytes = key.length - remainder;
10829
+ h1 = seed;
10830
+ c1 = 3432918353;
10831
+ c2 = 461845907;
10832
+ i = 0;
10833
+ while (i < bytes) {
10834
+ k1 = key.charCodeAt(i) & 255 | (key.charCodeAt(++i) & 255) << 8 | (key.charCodeAt(++i) & 255) << 16 | (key.charCodeAt(++i) & 255) << 24;
10835
+ ++i;
10836
+ k1 = (k1 & 65535) * c1 + (((k1 >>> 16) * c1 & 65535) << 16) & 4294967295;
10837
+ k1 = k1 << 15 | k1 >>> 17;
10838
+ k1 = (k1 & 65535) * c2 + (((k1 >>> 16) * c2 & 65535) << 16) & 4294967295;
10839
+ h1 ^= k1;
10840
+ h1 = h1 << 13 | h1 >>> 19;
10841
+ h1b = (h1 & 65535) * 5 + (((h1 >>> 16) * 5 & 65535) << 16) & 4294967295;
10842
+ h1 = (h1b & 65535) + 27492 + (((h1b >>> 16) + 58964 & 65535) << 16);
10843
+ }
10844
+ k1 = 0;
10845
+ if (remainder >= 3) {
10846
+ k1 ^= (key.charCodeAt(i + 2) & 255) << 16;
10847
+ }
10848
+ if (remainder >= 2) {
10849
+ k1 ^= (key.charCodeAt(i + 1) & 255) << 8;
10850
+ }
10851
+ if (remainder >= 1) {
10852
+ k1 ^= key.charCodeAt(i) & 255;
10853
+ k1 = (k1 & 65535) * c1 + (((k1 >>> 16) * c1 & 65535) << 16) & 4294967295;
10854
+ k1 = k1 << 15 | k1 >>> 17;
10855
+ k1 = (k1 & 65535) * c2 + (((k1 >>> 16) * c2 & 65535) << 16) & 4294967295;
10856
+ h1 ^= k1;
10857
+ }
10858
+ h1 ^= key.length;
10859
+ h1 ^= h1 >>> 16;
10860
+ h1 = (h1 & 65535) * 2246822507 + (((h1 >>> 16) * 2246822507 & 65535) << 16) & 4294967295;
10861
+ h1 ^= h1 >>> 13;
10862
+ h1 = (h1 & 65535) * 3266489909 + (((h1 >>> 16) * 3266489909 & 65535) << 16) & 4294967295;
10863
+ h1 ^= h1 >>> 16;
10864
+ return h1 >>> 0;
10865
+ }
11067
10866
 
11068
10867
  class ArcOptional {
11069
10868
  parent;
@@ -11090,6 +10889,11 @@ class ArcOptional {
11090
10889
  return false;
11091
10890
  return this.parent.validate(value);
11092
10891
  }
10892
+ coerce(value) {
10893
+ if (value == null)
10894
+ return;
10895
+ return this.parent.coerce(value);
10896
+ }
11093
10897
  toJsonSchema() {
11094
10898
  const parentSchema = this.parent.toJsonSchema?.() ?? {};
11095
10899
  return {
@@ -11136,6 +10940,9 @@ class ArcBranded {
11136
10940
  validate(value) {
11137
10941
  return this.parent.validate(value);
11138
10942
  }
10943
+ coerce(value) {
10944
+ return this.parent.coerce(value);
10945
+ }
11139
10946
  toJsonSchema() {
11140
10947
  return this.parent.toJsonSchema?.() ?? {};
11141
10948
  }
@@ -11156,7 +10963,14 @@ class ArcDefault {
11156
10963
  this.defaultValueOrCallback = defaultValueOrCallback;
11157
10964
  }
11158
10965
  validate(value) {
11159
- throw new Error("Method not implemented.");
10966
+ if (value === undefined || value === null)
10967
+ return false;
10968
+ return this.parent.validate(value);
10969
+ }
10970
+ coerce(value) {
10971
+ if (value === undefined || value === null)
10972
+ return;
10973
+ return this.parent.coerce(value);
11160
10974
  }
11161
10975
  parse(value) {
11162
10976
  if (value)
@@ -11240,6 +11054,9 @@ class ArcAbstract {
11240
11054
  }
11241
11055
  return false;
11242
11056
  }
11057
+ coerce(value) {
11058
+ return this.validate(value) ? undefined : value;
11059
+ }
11243
11060
  pipeValidation(name, validator) {
11244
11061
  const newInstance = this.clone();
11245
11062
  newInstance.validations = [...this.validations, { name, validator }];
@@ -11393,6 +11210,25 @@ class ScopedStore {
11393
11210
  }
11394
11211
  }
11395
11212
  }
11213
+ function collectFieldPaths(errors, prefix = "") {
11214
+ if (!errors || typeof errors !== "object")
11215
+ return [];
11216
+ const schema = errors.schema;
11217
+ if (!schema || typeof schema !== "object")
11218
+ return [];
11219
+ const out = [];
11220
+ for (const [field, fieldError] of Object.entries(schema)) {
11221
+ if (!fieldError)
11222
+ continue;
11223
+ const path4 = prefix ? `${prefix}.${field}` : field;
11224
+ const nested = collectFieldPaths(fieldError, path4);
11225
+ if (nested.length > 0)
11226
+ out.push(...nested);
11227
+ else
11228
+ out.push(path4);
11229
+ }
11230
+ return out;
11231
+ }
11396
11232
  function string() {
11397
11233
  return new ArcString;
11398
11234
  }
@@ -11527,6 +11363,27 @@ class ArcFunction {
11527
11363
  get results() {
11528
11364
  return this.data.results;
11529
11365
  }
11366
+ validateParams(params) {
11367
+ const schema = this.data.params;
11368
+ if (!schema || typeof schema.validate !== "function")
11369
+ return;
11370
+ const errors = schema.validate(params ?? {});
11371
+ if (errors)
11372
+ throw new ArcValidationError2(errors);
11373
+ }
11374
+ async authorize(adapters) {
11375
+ if (!this.hasProtections)
11376
+ return;
11377
+ const decoded = adapters.authAdapter?.getDecoded?.();
11378
+ if (!decoded) {
11379
+ throw new ArcAuthenticationError;
11380
+ }
11381
+ const instances = this.data.protections.filter((p3) => p3.token?.name === decoded.tokenName).map((p3) => p3.token.create(decoded.params, adapters));
11382
+ const ok2 = await this.verifyProtections(instances);
11383
+ if (!ok2) {
11384
+ throw new ArcAuthorizationError2;
11385
+ }
11386
+ }
11530
11387
  async verifyProtections(tokens) {
11531
11388
  if (!this.data.protections || this.data.protections.length === 0) {
11532
11389
  return true;
@@ -11553,6 +11410,34 @@ class ArcFunction {
11553
11410
  };
11554
11411
  }
11555
11412
  }
11413
+ function serializeParams(schema, params) {
11414
+ if (schema && typeof schema.serialize === "function") {
11415
+ return schema.serialize(params ?? {});
11416
+ }
11417
+ return params;
11418
+ }
11419
+ function deserializeParams(schema, params) {
11420
+ if (schema && typeof schema.deserialize === "function") {
11421
+ return schema.deserialize(params ?? {});
11422
+ }
11423
+ return params;
11424
+ }
11425
+ function deserializeResult(schemas, value) {
11426
+ const list = Array.isArray(schemas) ? schemas : undefined;
11427
+ if (!list || list.length !== 1)
11428
+ return value;
11429
+ const schema = list[0];
11430
+ if (!schema || typeof schema.deserialize !== "function")
11431
+ return value;
11432
+ if (value == null || typeof value !== "object" || Array.isArray(value)) {
11433
+ return value;
11434
+ }
11435
+ try {
11436
+ return schema.deserialize(value);
11437
+ } catch {
11438
+ return value;
11439
+ }
11440
+ }
11556
11441
 
11557
11442
  class AggregateBase {
11558
11443
  value;
@@ -11678,47 +11563,6 @@ function deepMerge(target, source) {
11678
11563
  function isPlainObject(item) {
11679
11564
  return item && typeof item === "object" && !Array.isArray(item) && !(item instanceof Date) && Object.prototype.toString.call(item) === "[object Object]";
11680
11565
  }
11681
- function murmurHash(key, seed = 0) {
11682
- let remainder, bytes, h1, h1b, c1, c2, k1, i;
11683
- remainder = key.length & 3;
11684
- bytes = key.length - remainder;
11685
- h1 = seed;
11686
- c1 = 3432918353;
11687
- c2 = 461845907;
11688
- i = 0;
11689
- while (i < bytes) {
11690
- k1 = key.charCodeAt(i) & 255 | (key.charCodeAt(++i) & 255) << 8 | (key.charCodeAt(++i) & 255) << 16 | (key.charCodeAt(++i) & 255) << 24;
11691
- ++i;
11692
- k1 = (k1 & 65535) * c1 + (((k1 >>> 16) * c1 & 65535) << 16) & 4294967295;
11693
- k1 = k1 << 15 | k1 >>> 17;
11694
- k1 = (k1 & 65535) * c2 + (((k1 >>> 16) * c2 & 65535) << 16) & 4294967295;
11695
- h1 ^= k1;
11696
- h1 = h1 << 13 | h1 >>> 19;
11697
- h1b = (h1 & 65535) * 5 + (((h1 >>> 16) * 5 & 65535) << 16) & 4294967295;
11698
- h1 = (h1b & 65535) + 27492 + (((h1b >>> 16) + 58964 & 65535) << 16);
11699
- }
11700
- k1 = 0;
11701
- if (remainder >= 3) {
11702
- k1 ^= (key.charCodeAt(i + 2) & 255) << 16;
11703
- }
11704
- if (remainder >= 2) {
11705
- k1 ^= (key.charCodeAt(i + 1) & 255) << 8;
11706
- }
11707
- if (remainder >= 1) {
11708
- k1 ^= key.charCodeAt(i) & 255;
11709
- k1 = (k1 & 65535) * c1 + (((k1 >>> 16) * c1 & 65535) << 16) & 4294967295;
11710
- k1 = k1 << 15 | k1 >>> 17;
11711
- k1 = (k1 & 65535) * c2 + (((k1 >>> 16) * c2 & 65535) << 16) & 4294967295;
11712
- h1 ^= k1;
11713
- }
11714
- h1 ^= key.length;
11715
- h1 ^= h1 >>> 16;
11716
- h1 = (h1 & 65535) * 2246822507 + (((h1 >>> 16) * 2246822507 & 65535) << 16) & 4294967295;
11717
- h1 ^= h1 >>> 13;
11718
- h1 = (h1 & 65535) * 3266489909 + (((h1 >>> 16) * 3266489909 & 65535) << 16) & 4294967295;
11719
- h1 ^= h1 >>> 16;
11720
- return h1 >>> 0;
11721
- }
11722
11566
  function resolveQueryChange(currentResult, event3, options) {
11723
11567
  const index = currentResult.findIndex((e2) => e2._id === event3.id);
11724
11568
  const isInCurrentResult = index !== -1;
@@ -11730,16 +11574,57 @@ function resolveQueryChange(currentResult, event3, options) {
11730
11574
  }
11731
11575
  const shouldBeInResult = checkItemMatchesWhere(event3.item, options.where);
11732
11576
  if (isInCurrentResult && shouldBeInResult) {
11733
- const newResult = currentResult.toSpliced(index, 1, event3.item);
11734
- return applyOrderByAndLimit(newResult, options);
11577
+ if (!options.orderBy) {
11578
+ return applyLimit(currentResult.toSpliced(index, 1, event3.item), options);
11579
+ }
11580
+ const cmp = compareByOrderBy(options.orderBy);
11581
+ if (cmp(currentResult[index], event3.item) === 0) {
11582
+ return applyLimit(currentResult.toSpliced(index, 1, event3.item), options);
11583
+ }
11584
+ const without = currentResult.toSpliced(index, 1);
11585
+ const at = upperBound(without, event3.item, cmp);
11586
+ return applyLimit(without.toSpliced(at, 0, event3.item), options);
11735
11587
  } else if (isInCurrentResult && !shouldBeInResult) {
11736
11588
  return currentResult.toSpliced(index, 1);
11737
11589
  } else if (!isInCurrentResult && shouldBeInResult) {
11738
- const newResult = [...currentResult, event3.item];
11739
- return applyOrderByAndLimit(newResult, options);
11590
+ if (!options.orderBy) {
11591
+ return applyLimit([...currentResult, event3.item], options);
11592
+ }
11593
+ const cmp = compareByOrderBy(options.orderBy);
11594
+ const at = upperBound(currentResult, event3.item, cmp);
11595
+ return applyLimit(currentResult.toSpliced(at, 0, event3.item), options);
11740
11596
  }
11741
11597
  return false;
11742
11598
  }
11599
+ function compareByOrderBy(orderBy) {
11600
+ const entries = Object.entries(orderBy);
11601
+ return (a2, b3) => {
11602
+ for (const [key, direction] of entries) {
11603
+ const aVal = a2[key];
11604
+ const bVal = b3[key];
11605
+ if (aVal < bVal)
11606
+ return direction === "asc" ? -1 : 1;
11607
+ if (aVal > bVal)
11608
+ return direction === "asc" ? 1 : -1;
11609
+ }
11610
+ return 0;
11611
+ };
11612
+ }
11613
+ function upperBound(arr, item, cmp) {
11614
+ let lo = 0;
11615
+ let hi = arr.length;
11616
+ while (lo < hi) {
11617
+ const mid = lo + hi >> 1;
11618
+ if (cmp(arr[mid], item) <= 0)
11619
+ lo = mid + 1;
11620
+ else
11621
+ hi = mid;
11622
+ }
11623
+ return lo;
11624
+ }
11625
+ function applyLimit(result, options) {
11626
+ return options.limit !== undefined && result.length > options.limit ? result.slice(0, options.limit) : result;
11627
+ }
11743
11628
  function checkItemMatchesWhere(item, where) {
11744
11629
  if (!where) {
11745
11630
  return true;
@@ -11775,26 +11660,6 @@ function checkItemMatchesWhere(item, where) {
11775
11660
  });
11776
11661
  });
11777
11662
  }
11778
- function applyOrderByAndLimit(result, options) {
11779
- let sorted = result;
11780
- if (options.orderBy) {
11781
- sorted = [...result].sort((a2, b3) => {
11782
- for (const [key, direction] of Object.entries(options.orderBy)) {
11783
- const aVal = a2[key];
11784
- const bVal = b3[key];
11785
- if (aVal < bVal)
11786
- return direction === "asc" ? -1 : 1;
11787
- if (aVal > bVal)
11788
- return direction === "asc" ? 1 : -1;
11789
- }
11790
- return 0;
11791
- });
11792
- }
11793
- if (options.limit !== undefined) {
11794
- sorted = sorted.slice(0, options.limit);
11795
- }
11796
- return sorted;
11797
- }
11798
11663
 
11799
11664
  class ObservableDataStorage {
11800
11665
  source;
@@ -12131,7 +11996,7 @@ class Model2 {
12131
11996
  return s;
12132
11997
  }
12133
11998
  }
12134
- function applyQueryChanges(result, changes) {
11999
+ function applyQueryChanges2(result, changes) {
12135
12000
  const next = [...result];
12136
12001
  for (const change of changes) {
12137
12002
  if (change.type === "delete") {
@@ -12184,7 +12049,7 @@ class StreamingQueryCache {
12184
12049
  if (!newEntry.hasResult || !Array.isArray(newEntry.result)) {
12185
12050
  return;
12186
12051
  }
12187
- newEntry.result = applyQueryChanges(newEntry.result, changes);
12052
+ newEntry.result = applyQueryChanges2(newEntry.result, changes);
12188
12053
  this.notify(newEntry);
12189
12054
  }
12190
12055
  });
@@ -14049,6 +13914,37 @@ function osUsername() {
14049
13914
  return process.env.USERNAME || process.env.USER || process.env.LOGNAME;
14050
13915
  }
14051
13916
  }
13917
+ function unsafeIntMessage(raw, columnName) {
13918
+ const where = columnName ? ` w kolumnie "${columnName}"` : "";
13919
+ return `[PostgreSQL] Warto\u015B\u0107 ca\u0142kowita ${raw}${where} przekracza bezpieczny zakres ` + `JS Number (\xB12^53-1). Odczyt jako number cicho straci\u0142by precyzj\u0119. ` + `U\u017Cyj kolumny TEXT/NUMERIC i obs\u0142u\u017C warto\u015B\u0107 jako string/BigInt.`;
13920
+ }
13921
+ function coercePgNumber(value, columnName) {
13922
+ if (value === null || value === undefined)
13923
+ return value;
13924
+ if (typeof value === "number")
13925
+ return value;
13926
+ if (typeof value === "bigint") {
13927
+ if (value > MAX_SAFE_INT || value < MIN_SAFE_INT) {
13928
+ throw new Error(unsafeIntMessage(value.toString(), columnName));
13929
+ }
13930
+ return Number(value);
13931
+ }
13932
+ if (typeof value === "string") {
13933
+ const s = value.trim();
13934
+ if (s === "")
13935
+ return value;
13936
+ if (/^[+-]?\d+$/.test(s)) {
13937
+ const big = BigInt(s);
13938
+ if (big > MAX_SAFE_INT || big < MIN_SAFE_INT) {
13939
+ throw new Error(unsafeIntMessage(s, columnName));
13940
+ }
13941
+ return Number(big);
13942
+ }
13943
+ const n2 = Number(s);
13944
+ return Number.isNaN(n2) ? value : n2;
13945
+ }
13946
+ return value;
13947
+ }
14052
13948
 
14053
13949
  class PostgreSQLReadTransaction {
14054
13950
  db;
@@ -14071,7 +13967,27 @@ class PostgreSQLReadTransaction {
14071
13967
  deserializeValue(value, column) {
14072
13968
  if (value === null || value === undefined)
14073
13969
  return null;
14074
- switch (column.type.toLowerCase()) {
13970
+ const type = column.type.toLowerCase().split("(")[0].trim();
13971
+ switch (type) {
13972
+ case "bigint":
13973
+ case "int8":
13974
+ case "bigserial":
13975
+ case "serial8":
13976
+ case "serial":
13977
+ case "serial4":
13978
+ case "integer":
13979
+ case "int":
13980
+ case "int4":
13981
+ case "smallint":
13982
+ case "int2":
13983
+ case "numeric":
13984
+ case "decimal":
13985
+ case "real":
13986
+ case "double precision":
13987
+ case "float":
13988
+ case "float4":
13989
+ case "float8":
13990
+ return coercePgNumber(value, column.name);
14075
13991
  case "json":
14076
13992
  case "jsonb":
14077
13993
  if (typeof value === "string") {
@@ -14667,7 +14583,7 @@ var Operation, PROXY_DRAFT, RAW_RETURN_SYMBOL, iteratorSymbol, dataTypes, intern
14667
14583
  }
14668
14584
  return returnValue(result);
14669
14585
  };
14670
- }, create, constructorString, TOKEN_PREFIX = "arc:token:", DEFAULT_TIMEOUT_MS = 8000, provider = null, latestSync = null, syncSeq = 0, eventWireInstanceCounter = 0, EVENT_TABLES, arrayValidator, ArcArray, objectValidator, ArcObject, ScopedDataStorage, ArcPrimitive, stringValidator, ArcString, ArcContextElement, ArcBoolean, ArcId, numberValidator, ArcNumber, ArcEvent, ArcCommand, ArcListener, ArcRoute, ForkedStoreState, ForkedDataStorage, MasterStoreState, MasterDataStorage2, dateValidator, originCache, originStackCache, originError, CLOSE, Query, PostgresError, Errors, types2, Identifier, Parameter, Builder, defaultHandlers, builders, serializers, parsers, mergeUserTypes = function(types22) {
14586
+ }, create, constructorString, TOKEN_PREFIX = "arc:token:", DEFAULT_TIMEOUT_MS = 8000, provider = null, latestSync = null, syncSeq = 0, eventWireInstanceCounter = 0, EVENT_TABLES, arrayValidator, ArcArray, objectValidator, ArcObject, ScopedDataStorage, ArcAuthenticationError, ArcAuthorizationError2, ArcValidationError2, ArcPrimitive, stringValidator, ArcString, ArcContextElement, ArcBoolean, ArcId, numberValidator, ArcNumber, ArcEvent, ArcCommand, ArcListener, ArcRoute, ForkedStoreState, ForkedDataStorage, MasterStoreState, MasterDataStorage2, dateValidator, _te, _td, originCache, originStackCache, originError, CLOSE, Query, PostgresError, Errors, types2, Identifier, Parameter, Builder, defaultHandlers, builders, serializers, parsers, mergeUserTypes = function(types22) {
14671
14587
  const user = typeHandlers(types22 || {});
14672
14588
  return {
14673
14589
  serializers: Object.assign({}, serializers, user.serializers),
@@ -14707,7 +14623,7 @@ var Operation, PROXY_DRAFT, RAW_RETURN_SYMBOL, iteratorSymbol, dataTypes, intern
14707
14623
  for (let i = 1;i < x2.length; i++)
14708
14624
  str += x2[i] === "_" ? x2[++i].toUpperCase() : x2[i];
14709
14625
  return str;
14710
- }, toKebab = (x2) => x2.replace(/_/g, "-"), fromCamel = (x2) => x2.replace(/([A-Z])/g, "_$1").toLowerCase(), fromPascal = (x2) => (x2.slice(0, 1) + x2.slice(1).replace(/([A-Z])/g, "_$1")).toLowerCase(), fromKebab = (x2) => x2.replace(/-/g, "_"), camel, pascal, kebab, Result, queue_default, size = 256, buffer, messages, b3, bytes_default, connection_default, uid = 1, Sync, Flush, SSLRequest, ExecuteUnnamed, DescribeUnnamed, noop = () => {}, retryRoutines, errorFields, noop2 = () => {}, src_default, PostgreSQLReadWriteTransaction, createPostgreSQLAdapterFactory = (db) => {
14626
+ }, toKebab = (x2) => x2.replace(/_/g, "-"), fromCamel = (x2) => x2.replace(/([A-Z])/g, "_$1").toLowerCase(), fromPascal = (x2) => (x2.slice(0, 1) + x2.slice(1).replace(/([A-Z])/g, "_$1")).toLowerCase(), fromKebab = (x2) => x2.replace(/-/g, "_"), camel, pascal, kebab, Result, queue_default, size = 256, buffer, messages, b3, bytes_default, connection_default, uid = 1, Sync, Flush, SSLRequest, ExecuteUnnamed, DescribeUnnamed, noop = () => {}, retryRoutines, errorFields, noop2 = () => {}, src_default, MAX_SAFE_INT, MIN_SAFE_INT, PostgreSQLReadWriteTransaction, createPostgreSQLAdapterFactory = (db) => {
14711
14627
  return async (context) => {
14712
14628
  const adapter = new PostgreSQLAdapter(db, context);
14713
14629
  await adapter.initialize();
@@ -14715,7 +14631,15 @@ var Operation, PROXY_DRAFT, RAW_RETURN_SYMBOL, iteratorSymbol, dataTypes, intern
14715
14631
  };
14716
14632
  }, createPostgreSQLAdapterFactoryFromUrl = (connectionString) => {
14717
14633
  const sql = src_default(connectionString, {
14718
- onnotice: () => {}
14634
+ onnotice: () => {},
14635
+ types: {
14636
+ bigint: {
14637
+ to: 20,
14638
+ from: [20],
14639
+ serialize: (v3) => v3.toString(),
14640
+ parse: (v3) => coercePgNumber(v3)
14641
+ }
14642
+ }
14719
14643
  });
14720
14644
  const db = new PostgresJsDatabase(sql);
14721
14645
  return createPostgreSQLAdapterFactory(db);
@@ -15187,6 +15111,17 @@ var init_dist = __esm(() => {
15187
15111
  return { msg: "array is empty" };
15188
15112
  });
15189
15113
  }
15114
+ coerce(value) {
15115
+ if (!Array.isArray(value))
15116
+ return;
15117
+ const out = [];
15118
+ for (const item of value) {
15119
+ const coerced = this.parent.coerce(item);
15120
+ if (coerced !== undefined)
15121
+ out.push(coerced);
15122
+ }
15123
+ return this.validate(out) ? undefined : out;
15124
+ }
15190
15125
  parse(value) {
15191
15126
  return value.map((v3) => this.parent.parse(v3));
15192
15127
  }
@@ -15257,6 +15192,19 @@ var init_dist = __esm(() => {
15257
15192
  ]);
15258
15193
  this.rawShape = rawShape;
15259
15194
  }
15195
+ coerce(value) {
15196
+ if (value == null || typeof value !== "object" || Array.isArray(value)) {
15197
+ return;
15198
+ }
15199
+ const src2 = value;
15200
+ const out = {};
15201
+ for (const [key, element] of Object.entries(this.rawShape)) {
15202
+ const coerced = element.coerce(src2[key]);
15203
+ if (coerced !== undefined)
15204
+ out[key] = coerced;
15205
+ }
15206
+ return this.validate(out) ? undefined : out;
15207
+ }
15260
15208
  parse(value) {
15261
15209
  return Object.entries(this.rawShape).reduce((acc, [key, element]) => {
15262
15210
  acc[key] = element.parse(value[key]);
@@ -15416,6 +15364,30 @@ var init_dist = __esm(() => {
15416
15364
  return this.#inner.getReadWriteTransaction();
15417
15365
  }
15418
15366
  };
15367
+ ArcAuthenticationError = class ArcAuthenticationError extends Error {
15368
+ arcCode = "AUTHENTICATION";
15369
+ constructor(message = "Authentication required") {
15370
+ super(message);
15371
+ this.name = "ArcAuthenticationError";
15372
+ }
15373
+ };
15374
+ ArcAuthorizationError2 = class ArcAuthorizationError2 extends Error {
15375
+ arcCode = "AUTHORIZATION";
15376
+ constructor(message = "Forbidden") {
15377
+ super(message);
15378
+ this.name = "ArcAuthorizationError";
15379
+ }
15380
+ };
15381
+ ArcValidationError2 = class ArcValidationError2 extends Error {
15382
+ arcCode = "VALIDATION";
15383
+ fields;
15384
+ constructor(errors, message = "Invalid parameters") {
15385
+ super(message);
15386
+ this.name = "ArcValidationError";
15387
+ const paths = collectFieldPaths(errors);
15388
+ this.fields = paths.length > 0 ? paths : errors && typeof errors === "object" ? Object.keys(errors) : [];
15389
+ }
15390
+ };
15419
15391
  ArcPrimitive = class ArcPrimitive extends ArcAbstract {
15420
15392
  serialize(value) {
15421
15393
  return value;
@@ -15490,20 +15462,20 @@ var init_dist = __esm(() => {
15490
15462
  }
15491
15463
  });
15492
15464
  }
15493
- regex(regex3) {
15465
+ regex(regex2) {
15494
15466
  return this.validation("regex", (value) => {
15495
- if (!regex3.test(value)) {
15467
+ if (!regex2.test(value)) {
15496
15468
  return {
15497
15469
  currentValue: value,
15498
- regex: regex3
15470
+ regex: regex2
15499
15471
  };
15500
15472
  }
15501
15473
  });
15502
15474
  }
15503
15475
  email() {
15504
- const regex3 = /^(?:(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]+)*)|(?:"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f])*"))@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$|(?:\[(?:\d{1,3}\.){3}\d{1,3}\])$/;
15476
+ const regex2 = /^(?:(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]+)*)|(?:"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f])*"))@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$|(?:\[(?:\d{1,3}\.){3}\d{1,3}\])$/;
15505
15477
  return this.validation("email", (value) => {
15506
- if (!regex3.test(value)) {
15478
+ if (!regex2.test(value)) {
15507
15479
  return {
15508
15480
  currentEmail: value
15509
15481
  };
@@ -15518,9 +15490,9 @@ var init_dist = __esm(() => {
15518
15490
  return schema;
15519
15491
  }
15520
15492
  url() {
15521
- const regex3 = /^(https?):\/\/(?![-0-9])(?!www\.[0-9])(?:[a-zA-Z0-9-]+(?::[a-zA-Z0-9-]+)?@)?(?:localhost|\b(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b|[a-zA-Z0-9-]+\.)?[a-zA-Z0-9-]+\.(?:[a-zA-Z]{2,}|[a-zA-Z]{2}\.[a-zA-Z]{2})(?::\d{1,5})?(?!\/\/)(?:\/[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(?!\/{2})(?:;[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(\?(?!=)[a-zA-Z0-9&=;]*)?(\#[a-zA-Z0-9-]*)?$|^(https?):\/\/(localhost|\b(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)(?::\d{1,5})?(?!\/\/)(?:\/[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(?!\/{2})(?:;[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(\?(?!=)[a-zA-Z0-9&=;]*)?(\#[a-zA-Z0-9-]*)?$/;
15493
+ const regex2 = /^(https?):\/\/(?![-0-9])(?!www\.[0-9])(?:[a-zA-Z0-9-]+(?::[a-zA-Z0-9-]+)?@)?(?:localhost|\b(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b|[a-zA-Z0-9-]+\.)?[a-zA-Z0-9-]+\.(?:[a-zA-Z]{2,}|[a-zA-Z]{2}\.[a-zA-Z]{2})(?::\d{1,5})?(?!\/\/)(?:\/[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(?!\/{2})(?:;[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(\?(?!=)[a-zA-Z0-9&=;]*)?(\#[a-zA-Z0-9-]*)?$|^(https?):\/\/(localhost|\b(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)(?::\d{1,5})?(?!\/\/)(?:\/[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(?!\/{2})(?:;[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(\?(?!=)[a-zA-Z0-9&=;]*)?(\#[a-zA-Z0-9-]*)?$/;
15522
15494
  return this.validation("url", (value) => {
15523
- if (!regex3.test(value)) {
15495
+ if (!regex2.test(value)) {
15524
15496
  return {
15525
15497
  currentUrl: value
15526
15498
  };
@@ -15577,12 +15549,37 @@ var init_dist = __esm(() => {
15577
15549
  ArcContextElement = class ArcContextElement extends ArcFragmentBase {
15578
15550
  name;
15579
15551
  types = ["context-element"];
15552
+ __contextId;
15553
+ __contextName;
15554
+ __contextPath;
15580
15555
  get id() {
15581
15556
  return this.name;
15582
15557
  }
15558
+ __declStack;
15583
15559
  constructor(name) {
15584
15560
  super();
15585
15561
  this.name = name;
15562
+ this.__declStack = new Error().stack;
15563
+ }
15564
+ getSourceLocation() {
15565
+ const stack = this.__declStack;
15566
+ if (!stack)
15567
+ return;
15568
+ for (const raw of stack.split(`
15569
+ `).slice(1)) {
15570
+ const m4 = raw.match(/\(?((?:file:\/\/)?[^()\s]+?):(\d+):(\d+)\)?$/);
15571
+ if (!m4)
15572
+ continue;
15573
+ let file = m4[1];
15574
+ if (file.startsWith("file://"))
15575
+ file = file.slice(7);
15576
+ const isCoreInternal = /packages\/core\/(src|dist)\//.test(file) && !/\.test\.tsx?$/.test(file);
15577
+ if (file.includes("node_modules") || isCoreInternal || file.includes("native:") || !file.includes("/")) {
15578
+ continue;
15579
+ }
15580
+ return { file, line: Number(m4[2]) };
15581
+ }
15582
+ return;
15586
15583
  }
15587
15584
  _seeds;
15588
15585
  getSeeds() {
@@ -15714,7 +15711,8 @@ var init_dist = __esm(() => {
15714
15711
  payload,
15715
15712
  id: this.eventId.generate(),
15716
15713
  createdAt: new Date,
15717
- authContext
15714
+ authContext,
15715
+ definition: this
15718
15716
  };
15719
15717
  await adapters.eventPublisher.publish(event);
15720
15718
  }
@@ -15767,8 +15765,8 @@ var init_dist = __esm(() => {
15767
15765
  const tagsSchema = new ArcObject({
15768
15766
  _id: new ArcString().primaryKey(),
15769
15767
  eventId: new ArcString().index(),
15770
- tagKey: new ArcString().index(),
15771
- tagValue: new ArcString().index()
15768
+ tagKey: new ArcString,
15769
+ tagValue: new ArcString
15772
15770
  });
15773
15771
  const syncStatusSchema = new ArcObject({
15774
15772
  _id: new ArcString().primaryKey(),
@@ -15876,7 +15874,8 @@ var init_dist = __esm(() => {
15876
15874
  scope: adapters.scope.scopeName,
15877
15875
  token: adapters.scope.getToken()
15878
15876
  } : undefined;
15879
- return await adapters.commandWire.executeCommand(this.data.name, params, wireAuth);
15877
+ const wireResult = await adapters.commandWire.executeCommand(this.data.name, serializeParams(this.data.params, params), wireAuth);
15878
+ return deserializeResult(this.data.results, wireResult);
15880
15879
  };
15881
15880
  return Object.assign(executeFunc, { params: this.data.params });
15882
15881
  }
@@ -15884,8 +15883,11 @@ var init_dist = __esm(() => {
15884
15883
  if (!this.data.handler) {
15885
15884
  throw new Error(`Command "${this.data.name}" has no handler`);
15886
15885
  }
15886
+ const input = deserializeParams(this.data.params, params);
15887
+ this.#fn.validateParams(input);
15888
+ await this.#fn.authorize(adapters);
15887
15889
  const context2 = this.buildCommandContext(adapters);
15888
- return await this.data.handler(context2, params);
15890
+ return await this.data.handler(context2, input);
15889
15891
  }
15890
15892
  buildCommandContext(adapters) {
15891
15893
  const context2 = this.#fn.buildContext(adapters);
@@ -15994,9 +15996,10 @@ var init_dist = __esm(() => {
15994
15996
  }
15995
15997
  }
15996
15998
  if (this.data.isAsync) {
15997
- Promise.resolve(this.data.handler(context2, event2)).catch((error) => {
15999
+ const work = Promise.resolve(this.data.handler(context2, event2)).catch((error) => {
15998
16000
  console.error(`Async listener "${this.data.name}" error:`, error);
15999
16001
  });
16002
+ adapters.eventPublisher?.track?.(work);
16000
16003
  } else {
16001
16004
  await this.data.handler(context2, event2);
16002
16005
  }
@@ -16449,7 +16452,9 @@ var init_dist = __esm(() => {
16449
16452
  this.reinitTablesExecuted = false;
16450
16453
  }
16451
16454
  };
16452
- dateValidator = typeValidatorBuilder("Date", (value) => value instanceof Date);
16455
+ dateValidator = typeValidatorBuilder("Date", (value) => value instanceof Date && !isNaN(value.getTime()));
16456
+ _te = new TextEncoder;
16457
+ _td = new TextDecoder;
16453
16458
  originCache = new Map;
16454
16459
  originStackCache = new Map;
16455
16460
  originError = Symbol("OriginError");
@@ -16821,6 +16826,8 @@ var init_dist = __esm(() => {
16821
16826
  }
16822
16827
  });
16823
16828
  src_default = Postgres;
16829
+ MAX_SAFE_INT = BigInt(Number.MAX_SAFE_INTEGER);
16830
+ MIN_SAFE_INT = BigInt(Number.MIN_SAFE_INTEGER);
16824
16831
  PostgreSQLReadWriteTransaction = class PostgreSQLReadWriteTransaction extends PostgreSQLReadTransaction {
16825
16832
  adapter;
16826
16833
  queries = [];
@@ -18237,9 +18244,21 @@ class LocalEventPublisher3 {
18237
18244
  views = [];
18238
18245
  syncCallback;
18239
18246
  subscribers = new Map;
18247
+ pending = new Set;
18240
18248
  constructor(dataStorage) {
18241
18249
  this.dataStorage = dataStorage;
18242
18250
  }
18251
+ track(work) {
18252
+ const wrapped = Promise.resolve(work).catch(() => {}).finally(() => {
18253
+ this.pending.delete(wrapped);
18254
+ });
18255
+ this.pending.add(wrapped);
18256
+ }
18257
+ async whenIdle() {
18258
+ while (this.pending.size > 0) {
18259
+ await Promise.all([...this.pending]);
18260
+ }
18261
+ }
18243
18262
  onPublish(callback) {
18244
18263
  this.syncCallback = callback;
18245
18264
  }
@@ -18275,9 +18294,12 @@ class LocalEventPublisher3 {
18275
18294
  store: EVENT_TABLES2.events,
18276
18295
  changes: [{ type: "set", data: storedEvent }]
18277
18296
  });
18278
- if (event.payload && typeof event.payload === "object") {
18297
+ const tagFields = event.definition?.tagFields ?? [];
18298
+ if (tagFields.length > 0 && event.payload && typeof event.payload === "object") {
18299
+ const payload = event.payload;
18279
18300
  const tagChanges = [];
18280
- for (const [key, value] of Object.entries(event.payload)) {
18301
+ for (const key of tagFields) {
18302
+ const value = payload[key];
18281
18303
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
18282
18304
  tagChanges.push({
18283
18305
  type: "set",
@@ -18435,6 +18457,47 @@ class LocalEventPublisher3 {
18435
18457
  return allViewChanges;
18436
18458
  }
18437
18459
  }
18460
+ function murmurHash2(key, seed = 0) {
18461
+ let remainder, bytes, h1, h1b, c1, c2, k1, i;
18462
+ remainder = key.length & 3;
18463
+ bytes = key.length - remainder;
18464
+ h1 = seed;
18465
+ c1 = 3432918353;
18466
+ c2 = 461845907;
18467
+ i = 0;
18468
+ while (i < bytes) {
18469
+ k1 = key.charCodeAt(i) & 255 | (key.charCodeAt(++i) & 255) << 8 | (key.charCodeAt(++i) & 255) << 16 | (key.charCodeAt(++i) & 255) << 24;
18470
+ ++i;
18471
+ k1 = (k1 & 65535) * c1 + (((k1 >>> 16) * c1 & 65535) << 16) & 4294967295;
18472
+ k1 = k1 << 15 | k1 >>> 17;
18473
+ k1 = (k1 & 65535) * c2 + (((k1 >>> 16) * c2 & 65535) << 16) & 4294967295;
18474
+ h1 ^= k1;
18475
+ h1 = h1 << 13 | h1 >>> 19;
18476
+ h1b = (h1 & 65535) * 5 + (((h1 >>> 16) * 5 & 65535) << 16) & 4294967295;
18477
+ h1 = (h1b & 65535) + 27492 + (((h1b >>> 16) + 58964 & 65535) << 16);
18478
+ }
18479
+ k1 = 0;
18480
+ if (remainder >= 3) {
18481
+ k1 ^= (key.charCodeAt(i + 2) & 255) << 16;
18482
+ }
18483
+ if (remainder >= 2) {
18484
+ k1 ^= (key.charCodeAt(i + 1) & 255) << 8;
18485
+ }
18486
+ if (remainder >= 1) {
18487
+ k1 ^= key.charCodeAt(i) & 255;
18488
+ k1 = (k1 & 65535) * c1 + (((k1 >>> 16) * c1 & 65535) << 16) & 4294967295;
18489
+ k1 = k1 << 15 | k1 >>> 17;
18490
+ k1 = (k1 & 65535) * c2 + (((k1 >>> 16) * c2 & 65535) << 16) & 4294967295;
18491
+ h1 ^= k1;
18492
+ }
18493
+ h1 ^= key.length;
18494
+ h1 ^= h1 >>> 16;
18495
+ h1 = (h1 & 65535) * 2246822507 + (((h1 >>> 16) * 2246822507 & 65535) << 16) & 4294967295;
18496
+ h1 ^= h1 >>> 13;
18497
+ h1 = (h1 & 65535) * 3266489909 + (((h1 >>> 16) * 3266489909 & 65535) << 16) & 4294967295;
18498
+ h1 ^= h1 >>> 16;
18499
+ return h1 >>> 0;
18500
+ }
18438
18501
 
18439
18502
  class ArcOptional2 {
18440
18503
  parent;
@@ -18461,6 +18524,11 @@ class ArcOptional2 {
18461
18524
  return false;
18462
18525
  return this.parent.validate(value);
18463
18526
  }
18527
+ coerce(value) {
18528
+ if (value == null)
18529
+ return;
18530
+ return this.parent.coerce(value);
18531
+ }
18464
18532
  toJsonSchema() {
18465
18533
  const parentSchema = this.parent.toJsonSchema?.() ?? {};
18466
18534
  return {
@@ -18507,6 +18575,9 @@ class ArcBranded2 {
18507
18575
  validate(value) {
18508
18576
  return this.parent.validate(value);
18509
18577
  }
18578
+ coerce(value) {
18579
+ return this.parent.coerce(value);
18580
+ }
18510
18581
  toJsonSchema() {
18511
18582
  return this.parent.toJsonSchema?.() ?? {};
18512
18583
  }
@@ -18527,7 +18598,14 @@ class ArcDefault2 {
18527
18598
  this.defaultValueOrCallback = defaultValueOrCallback;
18528
18599
  }
18529
18600
  validate(value) {
18530
- throw new Error("Method not implemented.");
18601
+ if (value === undefined || value === null)
18602
+ return false;
18603
+ return this.parent.validate(value);
18604
+ }
18605
+ coerce(value) {
18606
+ if (value === undefined || value === null)
18607
+ return;
18608
+ return this.parent.coerce(value);
18531
18609
  }
18532
18610
  parse(value) {
18533
18611
  if (value)
@@ -18611,6 +18689,9 @@ class ArcAbstract2 {
18611
18689
  }
18612
18690
  return false;
18613
18691
  }
18692
+ coerce(value) {
18693
+ return this.validate(value) ? undefined : value;
18694
+ }
18614
18695
  pipeValidation(name, validator) {
18615
18696
  const newInstance = this.clone();
18616
18697
  newInstance.validations = [...this.validations, { name, validator }];
@@ -18764,6 +18845,25 @@ class ScopedStore2 {
18764
18845
  }
18765
18846
  }
18766
18847
  }
18848
+ function collectFieldPaths2(errors, prefix = "") {
18849
+ if (!errors || typeof errors !== "object")
18850
+ return [];
18851
+ const schema = errors.schema;
18852
+ if (!schema || typeof schema !== "object")
18853
+ return [];
18854
+ const out = [];
18855
+ for (const [field, fieldError] of Object.entries(schema)) {
18856
+ if (!fieldError)
18857
+ continue;
18858
+ const path4 = prefix ? `${prefix}.${field}` : field;
18859
+ const nested = collectFieldPaths2(fieldError, path4);
18860
+ if (nested.length > 0)
18861
+ out.push(...nested);
18862
+ else
18863
+ out.push(path4);
18864
+ }
18865
+ return out;
18866
+ }
18767
18867
  function string2() {
18768
18868
  return new ArcString2;
18769
18869
  }
@@ -18898,6 +18998,27 @@ class ArcFunction2 {
18898
18998
  get results() {
18899
18999
  return this.data.results;
18900
19000
  }
19001
+ validateParams(params) {
19002
+ const schema = this.data.params;
19003
+ if (!schema || typeof schema.validate !== "function")
19004
+ return;
19005
+ const errors = schema.validate(params ?? {});
19006
+ if (errors)
19007
+ throw new ArcValidationError3(errors);
19008
+ }
19009
+ async authorize(adapters) {
19010
+ if (!this.hasProtections)
19011
+ return;
19012
+ const decoded = adapters.authAdapter?.getDecoded?.();
19013
+ if (!decoded) {
19014
+ throw new ArcAuthenticationError2;
19015
+ }
19016
+ const instances = this.data.protections.filter((p3) => p3.token?.name === decoded.tokenName).map((p3) => p3.token.create(decoded.params, adapters));
19017
+ const ok2 = await this.verifyProtections(instances);
19018
+ if (!ok2) {
19019
+ throw new ArcAuthorizationError3;
19020
+ }
19021
+ }
18901
19022
  async verifyProtections(tokens) {
18902
19023
  if (!this.data.protections || this.data.protections.length === 0) {
18903
19024
  return true;
@@ -18924,6 +19045,34 @@ class ArcFunction2 {
18924
19045
  };
18925
19046
  }
18926
19047
  }
19048
+ function serializeParams2(schema, params) {
19049
+ if (schema && typeof schema.serialize === "function") {
19050
+ return schema.serialize(params ?? {});
19051
+ }
19052
+ return params;
19053
+ }
19054
+ function deserializeParams2(schema, params) {
19055
+ if (schema && typeof schema.deserialize === "function") {
19056
+ return schema.deserialize(params ?? {});
19057
+ }
19058
+ return params;
19059
+ }
19060
+ function deserializeResult2(schemas, value) {
19061
+ const list = Array.isArray(schemas) ? schemas : undefined;
19062
+ if (!list || list.length !== 1)
19063
+ return value;
19064
+ const schema = list[0];
19065
+ if (!schema || typeof schema.deserialize !== "function")
19066
+ return value;
19067
+ if (value == null || typeof value !== "object" || Array.isArray(value)) {
19068
+ return value;
19069
+ }
19070
+ try {
19071
+ return schema.deserialize(value);
19072
+ } catch {
19073
+ return value;
19074
+ }
19075
+ }
18927
19076
 
18928
19077
  class AggregateBase2 {
18929
19078
  value;
@@ -19049,47 +19198,6 @@ function deepMerge2(target, source) {
19049
19198
  function isPlainObject2(item) {
19050
19199
  return item && typeof item === "object" && !Array.isArray(item) && !(item instanceof Date) && Object.prototype.toString.call(item) === "[object Object]";
19051
19200
  }
19052
- function murmurHash2(key, seed = 0) {
19053
- let remainder, bytes, h1, h1b, c1, c2, k1, i;
19054
- remainder = key.length & 3;
19055
- bytes = key.length - remainder;
19056
- h1 = seed;
19057
- c1 = 3432918353;
19058
- c2 = 461845907;
19059
- i = 0;
19060
- while (i < bytes) {
19061
- k1 = key.charCodeAt(i) & 255 | (key.charCodeAt(++i) & 255) << 8 | (key.charCodeAt(++i) & 255) << 16 | (key.charCodeAt(++i) & 255) << 24;
19062
- ++i;
19063
- k1 = (k1 & 65535) * c1 + (((k1 >>> 16) * c1 & 65535) << 16) & 4294967295;
19064
- k1 = k1 << 15 | k1 >>> 17;
19065
- k1 = (k1 & 65535) * c2 + (((k1 >>> 16) * c2 & 65535) << 16) & 4294967295;
19066
- h1 ^= k1;
19067
- h1 = h1 << 13 | h1 >>> 19;
19068
- h1b = (h1 & 65535) * 5 + (((h1 >>> 16) * 5 & 65535) << 16) & 4294967295;
19069
- h1 = (h1b & 65535) + 27492 + (((h1b >>> 16) + 58964 & 65535) << 16);
19070
- }
19071
- k1 = 0;
19072
- if (remainder >= 3) {
19073
- k1 ^= (key.charCodeAt(i + 2) & 255) << 16;
19074
- }
19075
- if (remainder >= 2) {
19076
- k1 ^= (key.charCodeAt(i + 1) & 255) << 8;
19077
- }
19078
- if (remainder >= 1) {
19079
- k1 ^= key.charCodeAt(i) & 255;
19080
- k1 = (k1 & 65535) * c1 + (((k1 >>> 16) * c1 & 65535) << 16) & 4294967295;
19081
- k1 = k1 << 15 | k1 >>> 17;
19082
- k1 = (k1 & 65535) * c2 + (((k1 >>> 16) * c2 & 65535) << 16) & 4294967295;
19083
- h1 ^= k1;
19084
- }
19085
- h1 ^= key.length;
19086
- h1 ^= h1 >>> 16;
19087
- h1 = (h1 & 65535) * 2246822507 + (((h1 >>> 16) * 2246822507 & 65535) << 16) & 4294967295;
19088
- h1 ^= h1 >>> 13;
19089
- h1 = (h1 & 65535) * 3266489909 + (((h1 >>> 16) * 3266489909 & 65535) << 16) & 4294967295;
19090
- h1 ^= h1 >>> 16;
19091
- return h1 >>> 0;
19092
- }
19093
19201
  function resolveQueryChange2(currentResult, event3, options) {
19094
19202
  const index = currentResult.findIndex((e2) => e2._id === event3.id);
19095
19203
  const isInCurrentResult = index !== -1;
@@ -19101,16 +19209,57 @@ function resolveQueryChange2(currentResult, event3, options) {
19101
19209
  }
19102
19210
  const shouldBeInResult = checkItemMatchesWhere2(event3.item, options.where);
19103
19211
  if (isInCurrentResult && shouldBeInResult) {
19104
- const newResult = currentResult.toSpliced(index, 1, event3.item);
19105
- return applyOrderByAndLimit2(newResult, options);
19212
+ if (!options.orderBy) {
19213
+ return applyLimit2(currentResult.toSpliced(index, 1, event3.item), options);
19214
+ }
19215
+ const cmp = compareByOrderBy2(options.orderBy);
19216
+ if (cmp(currentResult[index], event3.item) === 0) {
19217
+ return applyLimit2(currentResult.toSpliced(index, 1, event3.item), options);
19218
+ }
19219
+ const without = currentResult.toSpliced(index, 1);
19220
+ const at = upperBound2(without, event3.item, cmp);
19221
+ return applyLimit2(without.toSpliced(at, 0, event3.item), options);
19106
19222
  } else if (isInCurrentResult && !shouldBeInResult) {
19107
19223
  return currentResult.toSpliced(index, 1);
19108
19224
  } else if (!isInCurrentResult && shouldBeInResult) {
19109
- const newResult = [...currentResult, event3.item];
19110
- return applyOrderByAndLimit2(newResult, options);
19225
+ if (!options.orderBy) {
19226
+ return applyLimit2([...currentResult, event3.item], options);
19227
+ }
19228
+ const cmp = compareByOrderBy2(options.orderBy);
19229
+ const at = upperBound2(currentResult, event3.item, cmp);
19230
+ return applyLimit2(currentResult.toSpliced(at, 0, event3.item), options);
19111
19231
  }
19112
19232
  return false;
19113
19233
  }
19234
+ function compareByOrderBy2(orderBy) {
19235
+ const entries = Object.entries(orderBy);
19236
+ return (a2, b4) => {
19237
+ for (const [key, direction] of entries) {
19238
+ const aVal = a2[key];
19239
+ const bVal = b4[key];
19240
+ if (aVal < bVal)
19241
+ return direction === "asc" ? -1 : 1;
19242
+ if (aVal > bVal)
19243
+ return direction === "asc" ? 1 : -1;
19244
+ }
19245
+ return 0;
19246
+ };
19247
+ }
19248
+ function upperBound2(arr, item, cmp) {
19249
+ let lo = 0;
19250
+ let hi = arr.length;
19251
+ while (lo < hi) {
19252
+ const mid = lo + hi >> 1;
19253
+ if (cmp(arr[mid], item) <= 0)
19254
+ lo = mid + 1;
19255
+ else
19256
+ hi = mid;
19257
+ }
19258
+ return lo;
19259
+ }
19260
+ function applyLimit2(result, options) {
19261
+ return options.limit !== undefined && result.length > options.limit ? result.slice(0, options.limit) : result;
19262
+ }
19114
19263
  function checkItemMatchesWhere2(item, where) {
19115
19264
  if (!where) {
19116
19265
  return true;
@@ -19146,26 +19295,6 @@ function checkItemMatchesWhere2(item, where) {
19146
19295
  });
19147
19296
  });
19148
19297
  }
19149
- function applyOrderByAndLimit2(result, options) {
19150
- let sorted = result;
19151
- if (options.orderBy) {
19152
- sorted = [...result].sort((a2, b4) => {
19153
- for (const [key, direction] of Object.entries(options.orderBy)) {
19154
- const aVal = a2[key];
19155
- const bVal = b4[key];
19156
- if (aVal < bVal)
19157
- return direction === "asc" ? -1 : 1;
19158
- if (aVal > bVal)
19159
- return direction === "asc" ? 1 : -1;
19160
- }
19161
- return 0;
19162
- });
19163
- }
19164
- if (options.limit !== undefined) {
19165
- sorted = sorted.slice(0, options.limit);
19166
- }
19167
- return sorted;
19168
- }
19169
19298
 
19170
19299
  class ObservableDataStorage2 {
19171
19300
  source;
@@ -19502,7 +19631,7 @@ class Model3 {
19502
19631
  return s;
19503
19632
  }
19504
19633
  }
19505
- function applyQueryChanges2(result, changes) {
19634
+ function applyQueryChanges3(result, changes) {
19506
19635
  const next = [...result];
19507
19636
  for (const change of changes) {
19508
19637
  if (change.type === "delete") {
@@ -19555,7 +19684,7 @@ class StreamingQueryCache2 {
19555
19684
  if (!newEntry.hasResult || !Array.isArray(newEntry.result)) {
19556
19685
  return;
19557
19686
  }
19558
- newEntry.result = applyQueryChanges2(newEntry.result, changes);
19687
+ newEntry.result = applyQueryChanges3(newEntry.result, changes);
19559
19688
  this.notify(newEntry);
19560
19689
  }
19561
19690
  });
@@ -20514,7 +20643,7 @@ var Operation2, PROXY_DRAFT2, RAW_RETURN_SYMBOL2, iteratorSymbol2, dataTypes2, i
20514
20643
  }
20515
20644
  return returnValue(result);
20516
20645
  };
20517
- }, create2, constructorString2, TOKEN_PREFIX2 = "arc:token:", DEFAULT_TIMEOUT_MS2 = 8000, provider2 = null, latestSync2 = null, syncSeq2 = 0, eventWireInstanceCounter2 = 0, EVENT_TABLES2, arrayValidator2, ArcArray2, objectValidator2, ArcObject2, ScopedDataStorage2, ArcPrimitive2, stringValidator2, ArcString2, ArcContextElement2, ArcBoolean2, ArcId2, numberValidator2, ArcNumber2, ArcEvent2, ArcCommand2, ArcListener2, ArcRoute2, ForkedStoreState2, ForkedDataStorage2, MasterStoreState2, MasterDataStorage3, dateValidator2, SQLiteReadWriteTransaction, createSQLiteAdapterFactory = (db) => {
20646
+ }, create2, constructorString2, TOKEN_PREFIX2 = "arc:token:", DEFAULT_TIMEOUT_MS2 = 8000, provider2 = null, latestSync2 = null, syncSeq2 = 0, eventWireInstanceCounter2 = 0, EVENT_TABLES2, arrayValidator2, ArcArray2, objectValidator2, ArcObject2, ScopedDataStorage2, ArcAuthenticationError2, ArcAuthorizationError3, ArcValidationError3, ArcPrimitive2, stringValidator2, ArcString2, ArcContextElement2, ArcBoolean2, ArcId2, numberValidator2, ArcNumber2, ArcEvent2, ArcCommand2, ArcListener2, ArcRoute2, ForkedStoreState2, ForkedDataStorage2, MasterStoreState2, MasterDataStorage3, dateValidator2, _te2, _td2, SQLiteReadWriteTransaction, createSQLiteAdapterFactory = (db) => {
20518
20647
  return async (context) => {
20519
20648
  const adapter = new SQLiteAdapter(db, context);
20520
20649
  await adapter.initialize();
@@ -20993,6 +21122,17 @@ var init_dist2 = __esm(() => {
20993
21122
  return { msg: "array is empty" };
20994
21123
  });
20995
21124
  }
21125
+ coerce(value) {
21126
+ if (!Array.isArray(value))
21127
+ return;
21128
+ const out = [];
21129
+ for (const item of value) {
21130
+ const coerced = this.parent.coerce(item);
21131
+ if (coerced !== undefined)
21132
+ out.push(coerced);
21133
+ }
21134
+ return this.validate(out) ? undefined : out;
21135
+ }
20996
21136
  parse(value) {
20997
21137
  return value.map((v3) => this.parent.parse(v3));
20998
21138
  }
@@ -21063,6 +21203,19 @@ var init_dist2 = __esm(() => {
21063
21203
  ]);
21064
21204
  this.rawShape = rawShape;
21065
21205
  }
21206
+ coerce(value) {
21207
+ if (value == null || typeof value !== "object" || Array.isArray(value)) {
21208
+ return;
21209
+ }
21210
+ const src2 = value;
21211
+ const out = {};
21212
+ for (const [key, element] of Object.entries(this.rawShape)) {
21213
+ const coerced = element.coerce(src2[key]);
21214
+ if (coerced !== undefined)
21215
+ out[key] = coerced;
21216
+ }
21217
+ return this.validate(out) ? undefined : out;
21218
+ }
21066
21219
  parse(value) {
21067
21220
  return Object.entries(this.rawShape).reduce((acc, [key, element]) => {
21068
21221
  acc[key] = element.parse(value[key]);
@@ -21222,6 +21375,30 @@ var init_dist2 = __esm(() => {
21222
21375
  return this.#inner.getReadWriteTransaction();
21223
21376
  }
21224
21377
  };
21378
+ ArcAuthenticationError2 = class ArcAuthenticationError2 extends Error {
21379
+ arcCode = "AUTHENTICATION";
21380
+ constructor(message = "Authentication required") {
21381
+ super(message);
21382
+ this.name = "ArcAuthenticationError";
21383
+ }
21384
+ };
21385
+ ArcAuthorizationError3 = class ArcAuthorizationError3 extends Error {
21386
+ arcCode = "AUTHORIZATION";
21387
+ constructor(message = "Forbidden") {
21388
+ super(message);
21389
+ this.name = "ArcAuthorizationError";
21390
+ }
21391
+ };
21392
+ ArcValidationError3 = class ArcValidationError3 extends Error {
21393
+ arcCode = "VALIDATION";
21394
+ fields;
21395
+ constructor(errors, message = "Invalid parameters") {
21396
+ super(message);
21397
+ this.name = "ArcValidationError";
21398
+ const paths = collectFieldPaths2(errors);
21399
+ this.fields = paths.length > 0 ? paths : errors && typeof errors === "object" ? Object.keys(errors) : [];
21400
+ }
21401
+ };
21225
21402
  ArcPrimitive2 = class ArcPrimitive2 extends ArcAbstract2 {
21226
21403
  serialize(value) {
21227
21404
  return value;
@@ -21296,20 +21473,20 @@ var init_dist2 = __esm(() => {
21296
21473
  }
21297
21474
  });
21298
21475
  }
21299
- regex(regex3) {
21476
+ regex(regex2) {
21300
21477
  return this.validation("regex", (value) => {
21301
- if (!regex3.test(value)) {
21478
+ if (!regex2.test(value)) {
21302
21479
  return {
21303
21480
  currentValue: value,
21304
- regex: regex3
21481
+ regex: regex2
21305
21482
  };
21306
21483
  }
21307
21484
  });
21308
21485
  }
21309
21486
  email() {
21310
- const regex3 = /^(?:(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]+)*)|(?:"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f])*"))@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$|(?:\[(?:\d{1,3}\.){3}\d{1,3}\])$/;
21487
+ const regex2 = /^(?:(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]+)*)|(?:"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f])*"))@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$|(?:\[(?:\d{1,3}\.){3}\d{1,3}\])$/;
21311
21488
  return this.validation("email", (value) => {
21312
- if (!regex3.test(value)) {
21489
+ if (!regex2.test(value)) {
21313
21490
  return {
21314
21491
  currentEmail: value
21315
21492
  };
@@ -21324,9 +21501,9 @@ var init_dist2 = __esm(() => {
21324
21501
  return schema;
21325
21502
  }
21326
21503
  url() {
21327
- const regex3 = /^(https?):\/\/(?![-0-9])(?!www\.[0-9])(?:[a-zA-Z0-9-]+(?::[a-zA-Z0-9-]+)?@)?(?:localhost|\b(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b|[a-zA-Z0-9-]+\.)?[a-zA-Z0-9-]+\.(?:[a-zA-Z]{2,}|[a-zA-Z]{2}\.[a-zA-Z]{2})(?::\d{1,5})?(?!\/\/)(?:\/[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(?!\/{2})(?:;[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(\?(?!=)[a-zA-Z0-9&=;]*)?(\#[a-zA-Z0-9-]*)?$|^(https?):\/\/(localhost|\b(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)(?::\d{1,5})?(?!\/\/)(?:\/[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(?!\/{2})(?:;[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(\?(?!=)[a-zA-Z0-9&=;]*)?(\#[a-zA-Z0-9-]*)?$/;
21504
+ const regex2 = /^(https?):\/\/(?![-0-9])(?!www\.[0-9])(?:[a-zA-Z0-9-]+(?::[a-zA-Z0-9-]+)?@)?(?:localhost|\b(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b|[a-zA-Z0-9-]+\.)?[a-zA-Z0-9-]+\.(?:[a-zA-Z]{2,}|[a-zA-Z]{2}\.[a-zA-Z]{2})(?::\d{1,5})?(?!\/\/)(?:\/[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(?!\/{2})(?:;[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(\?(?!=)[a-zA-Z0-9&=;]*)?(\#[a-zA-Z0-9-]*)?$|^(https?):\/\/(localhost|\b(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)(?::\d{1,5})?(?!\/\/)(?:\/[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(?!\/{2})(?:;[a-zA-Z0-9-._~:?#\[\]@!$&'()*+,;=]*)*(\?(?!=)[a-zA-Z0-9&=;]*)?(\#[a-zA-Z0-9-]*)?$/;
21328
21505
  return this.validation("url", (value) => {
21329
- if (!regex3.test(value)) {
21506
+ if (!regex2.test(value)) {
21330
21507
  return {
21331
21508
  currentUrl: value
21332
21509
  };
@@ -21383,12 +21560,37 @@ var init_dist2 = __esm(() => {
21383
21560
  ArcContextElement2 = class ArcContextElement2 extends ArcFragmentBase2 {
21384
21561
  name;
21385
21562
  types = ["context-element"];
21563
+ __contextId;
21564
+ __contextName;
21565
+ __contextPath;
21386
21566
  get id() {
21387
21567
  return this.name;
21388
21568
  }
21569
+ __declStack;
21389
21570
  constructor(name) {
21390
21571
  super();
21391
21572
  this.name = name;
21573
+ this.__declStack = new Error().stack;
21574
+ }
21575
+ getSourceLocation() {
21576
+ const stack = this.__declStack;
21577
+ if (!stack)
21578
+ return;
21579
+ for (const raw of stack.split(`
21580
+ `).slice(1)) {
21581
+ const m4 = raw.match(/\(?((?:file:\/\/)?[^()\s]+?):(\d+):(\d+)\)?$/);
21582
+ if (!m4)
21583
+ continue;
21584
+ let file = m4[1];
21585
+ if (file.startsWith("file://"))
21586
+ file = file.slice(7);
21587
+ const isCoreInternal = /packages\/core\/(src|dist)\//.test(file) && !/\.test\.tsx?$/.test(file);
21588
+ if (file.includes("node_modules") || isCoreInternal || file.includes("native:") || !file.includes("/")) {
21589
+ continue;
21590
+ }
21591
+ return { file, line: Number(m4[2]) };
21592
+ }
21593
+ return;
21392
21594
  }
21393
21595
  _seeds;
21394
21596
  getSeeds() {
@@ -21520,7 +21722,8 @@ var init_dist2 = __esm(() => {
21520
21722
  payload,
21521
21723
  id: this.eventId.generate(),
21522
21724
  createdAt: new Date,
21523
- authContext
21725
+ authContext,
21726
+ definition: this
21524
21727
  };
21525
21728
  await adapters.eventPublisher.publish(event);
21526
21729
  }
@@ -21573,8 +21776,8 @@ var init_dist2 = __esm(() => {
21573
21776
  const tagsSchema = new ArcObject2({
21574
21777
  _id: new ArcString2().primaryKey(),
21575
21778
  eventId: new ArcString2().index(),
21576
- tagKey: new ArcString2().index(),
21577
- tagValue: new ArcString2().index()
21779
+ tagKey: new ArcString2,
21780
+ tagValue: new ArcString2
21578
21781
  });
21579
21782
  const syncStatusSchema = new ArcObject2({
21580
21783
  _id: new ArcString2().primaryKey(),
@@ -21682,7 +21885,8 @@ var init_dist2 = __esm(() => {
21682
21885
  scope: adapters.scope.scopeName,
21683
21886
  token: adapters.scope.getToken()
21684
21887
  } : undefined;
21685
- return await adapters.commandWire.executeCommand(this.data.name, params, wireAuth);
21888
+ const wireResult = await adapters.commandWire.executeCommand(this.data.name, serializeParams2(this.data.params, params), wireAuth);
21889
+ return deserializeResult2(this.data.results, wireResult);
21686
21890
  };
21687
21891
  return Object.assign(executeFunc, { params: this.data.params });
21688
21892
  }
@@ -21690,8 +21894,11 @@ var init_dist2 = __esm(() => {
21690
21894
  if (!this.data.handler) {
21691
21895
  throw new Error(`Command "${this.data.name}" has no handler`);
21692
21896
  }
21897
+ const input = deserializeParams2(this.data.params, params);
21898
+ this.#fn.validateParams(input);
21899
+ await this.#fn.authorize(adapters);
21693
21900
  const context2 = this.buildCommandContext(adapters);
21694
- return await this.data.handler(context2, params);
21901
+ return await this.data.handler(context2, input);
21695
21902
  }
21696
21903
  buildCommandContext(adapters) {
21697
21904
  const context2 = this.#fn.buildContext(adapters);
@@ -21800,9 +22007,10 @@ var init_dist2 = __esm(() => {
21800
22007
  }
21801
22008
  }
21802
22009
  if (this.data.isAsync) {
21803
- Promise.resolve(this.data.handler(context2, event2)).catch((error) => {
22010
+ const work = Promise.resolve(this.data.handler(context2, event2)).catch((error) => {
21804
22011
  console.error(`Async listener "${this.data.name}" error:`, error);
21805
22012
  });
22013
+ adapters.eventPublisher?.track?.(work);
21806
22014
  } else {
21807
22015
  await this.data.handler(context2, event2);
21808
22016
  }
@@ -22255,7 +22463,9 @@ var init_dist2 = __esm(() => {
22255
22463
  this.reinitTablesExecuted = false;
22256
22464
  }
22257
22465
  };
22258
- dateValidator2 = typeValidatorBuilder2("Date", (value) => value instanceof Date);
22466
+ dateValidator2 = typeValidatorBuilder2("Date", (value) => value instanceof Date && !isNaN(value.getTime()));
22467
+ _te2 = new TextEncoder;
22468
+ _td2 = new TextDecoder;
22259
22469
  SQLiteReadWriteTransaction = class SQLiteReadWriteTransaction extends SQLiteReadTransaction {
22260
22470
  adapter;
22261
22471
  queries = [];
@@ -22851,7 +23061,7 @@ var {
22851
23061
  // ../../node_modules/.bun/find-up@7.0.0/node_modules/find-up/index.js
22852
23062
  import path2 from "path";
22853
23063
 
22854
- // ../../node_modules/.bun/find-up@7.0.0/node_modules/find-up/node_modules/locate-path/index.js
23064
+ // ../../node_modules/.bun/locate-path@7.2.0/node_modules/locate-path/index.js
22855
23065
  import process2 from "process";
22856
23066
  import path from "path";
22857
23067
  import fs, { promises as fsPromises } from "fs";
@@ -31564,7 +31774,8 @@ async function buildServerApp(rootDir, serverDir, packages, cache, noCache) {
31564
31774
  members: packages.map((p) => ({ name: p.name, src: pkgSourceHash(p) })).sort((a, b) => a.name.localeCompare(b.name)),
31565
31775
  contexts: contexts.map((p) => p.name).sort(),
31566
31776
  external: [...external].sort(),
31567
- defines: SERVER_DEFINES
31777
+ defines: SERVER_DEFINES,
31778
+ sourcemap: "linked"
31568
31779
  });
31569
31780
  const entryFileAbs = join8(serverDir, SERVER_ENTRY_FILE);
31570
31781
  const externalsFileAbs = join8(serverDir, SERVER_EXTERNALS_FILE);
@@ -31578,8 +31789,9 @@ async function buildServerApp(rootDir, serverDir, packages, cache, noCache) {
31578
31789
  }
31579
31790
  console.log(` building: ${unitId} (${contexts.length} server modules)`);
31580
31791
  for (const f of readdirSync4(serverDir)) {
31581
- if (f.endsWith(".js"))
31792
+ if (f.endsWith(".js") || f.endsWith(".js.map")) {
31582
31793
  rmSync2(join8(serverDir, f), { force: true });
31794
+ }
31583
31795
  }
31584
31796
  const tmpDir = join8(serverDir, "_entries");
31585
31797
  mkdirSync6(tmpDir, { recursive: true });
@@ -31597,6 +31809,7 @@ async function buildServerApp(rootDir, serverDir, packages, cache, noCache) {
31597
31809
  format: "esm",
31598
31810
  splitting: true,
31599
31811
  naming: "[name].[ext]",
31812
+ sourcemap: "linked",
31600
31813
  external,
31601
31814
  plugins: [
31602
31815
  jsxDevShimPlugin(),
@@ -36687,7 +36900,8 @@ class ContextHandler {
36687
36900
  type: event.type,
36688
36901
  payload: event.payload,
36689
36902
  createdAt: new Date(event.createdAt),
36690
- authContext: eventAuthContext
36903
+ authContext: eventAuthContext,
36904
+ definition: eventDef
36691
36905
  });
36692
36906
  persistedEvents.push(syncableEvent);
36693
36907
  }
@@ -37464,14 +37678,34 @@ function arcHttpHandlers(ch, cm) {
37464
37678
  ];
37465
37679
  }
37466
37680
  // ../host/src/middleware/ws.ts
37467
- import { LiveQuery } from "@arcote.tech/arc";
37468
- var clientQuerySubs = new Map;
37469
- function cleanupClientSubs(clientId) {
37470
- const subs = clientQuerySubs.get(clientId);
37681
+ import { applyQueryChanges, LiveQuery } from "@arcote.tech/arc";
37682
+ var sharedQueries = new Map;
37683
+ var clientSubKeys = new Map;
37684
+ function sharedKeyFor(descriptor, scope, rawToken) {
37685
+ return JSON.stringify([scope, rawToken, descriptor]);
37686
+ }
37687
+ function detachSub(clientId, subscriptionId, sharedKey) {
37688
+ const entry = sharedQueries.get(sharedKey);
37689
+ if (!entry)
37690
+ return;
37691
+ const subs = entry.subscribers.get(clientId);
37471
37692
  if (subs) {
37472
- for (const live of subs.values())
37473
- live.stop();
37474
- clientQuerySubs.delete(clientId);
37693
+ subs.delete(subscriptionId);
37694
+ if (subs.size === 0)
37695
+ entry.subscribers.delete(clientId);
37696
+ }
37697
+ if (entry.subscribers.size === 0) {
37698
+ entry.live.stop();
37699
+ sharedQueries.delete(sharedKey);
37700
+ }
37701
+ }
37702
+ function cleanupClientSubs(clientId) {
37703
+ const keys = clientSubKeys.get(clientId);
37704
+ if (keys) {
37705
+ for (const [subscriptionId, sharedKey] of keys) {
37706
+ detachSub(clientId, subscriptionId, sharedKey);
37707
+ }
37708
+ clientSubKeys.delete(clientId);
37475
37709
  }
37476
37710
  }
37477
37711
  function scopeAuthHandler() {
@@ -37580,37 +37814,90 @@ function querySubscriptionHandler() {
37580
37814
  if (!rawToken && client.scopeTokens.size > 0) {
37581
37815
  rawToken = client.scopeTokens.values().next().value.raw;
37582
37816
  }
37583
- clientQuerySubs.get(client.id)?.get(subscriptionId)?.stop();
37584
- const live = new LiveQuery(ctx.contextHandler.getModel(), descriptor, scope, rawToken, (update) => {
37585
- if (update.type === "changes") {
37586
- ctx.connectionManager.sendToClient(client.id, {
37587
- type: "query-changes",
37588
- subscriptionId,
37589
- changes: update.changes
37590
- });
37591
- } else {
37592
- ctx.connectionManager.sendToClient(client.id, {
37593
- type: "query-snapshot",
37594
- subscriptionId,
37595
- result: update.result ?? null
37596
- });
37817
+ const prevKey = clientSubKeys.get(client.id)?.get(subscriptionId);
37818
+ if (prevKey)
37819
+ detachSub(client.id, subscriptionId, prevKey);
37820
+ const sharedKey = sharedKeyFor(descriptor, scope, rawToken);
37821
+ const attach = (entry2) => {
37822
+ if (!entry2.subscribers.has(client.id)) {
37823
+ entry2.subscribers.set(client.id, new Set);
37597
37824
  }
37598
- });
37599
- if (!clientQuerySubs.has(client.id)) {
37600
- clientQuerySubs.set(client.id, new Map);
37601
- }
37602
- clientQuerySubs.get(client.id).set(subscriptionId, live);
37603
- try {
37604
- const result = await live.start();
37825
+ entry2.subscribers.get(client.id).add(subscriptionId);
37826
+ if (!clientSubKeys.has(client.id)) {
37827
+ clientSubKeys.set(client.id, new Map);
37828
+ }
37829
+ clientSubKeys.get(client.id).set(subscriptionId, sharedKey);
37830
+ };
37831
+ const existing = sharedQueries.get(sharedKey);
37832
+ if (existing && existing.ready) {
37833
+ attach(existing);
37605
37834
  ctx.connectionManager.sendToClient(client.id, {
37606
37835
  type: "query-snapshot",
37607
37836
  subscriptionId,
37608
- result: result ?? null
37837
+ result: existing.lastResult ?? null
37609
37838
  });
37610
- live.flush();
37839
+ return true;
37840
+ }
37841
+ if (existing) {
37842
+ attach(existing);
37843
+ return true;
37844
+ }
37845
+ const entry = {
37846
+ live: null,
37847
+ subscribers: new Map,
37848
+ lastResult: null,
37849
+ ready: false
37850
+ };
37851
+ entry.live = new LiveQuery(ctx.contextHandler.getModel(), descriptor, scope, rawToken, (update) => {
37852
+ if (update.type === "changes") {
37853
+ if (Array.isArray(entry.lastResult)) {
37854
+ entry.lastResult = applyQueryChanges(entry.lastResult, update.changes);
37855
+ }
37856
+ } else {
37857
+ entry.lastResult = update.result ?? null;
37858
+ }
37859
+ for (const [subClientId, subIds] of entry.subscribers) {
37860
+ for (const subId of subIds) {
37861
+ ctx.connectionManager.sendToClient(subClientId, update.type === "changes" ? {
37862
+ type: "query-changes",
37863
+ subscriptionId: subId,
37864
+ changes: update.changes
37865
+ } : {
37866
+ type: "query-snapshot",
37867
+ subscriptionId: subId,
37868
+ result: update.result ?? null
37869
+ });
37870
+ }
37871
+ }
37872
+ });
37873
+ sharedQueries.set(sharedKey, entry);
37874
+ attach(entry);
37875
+ try {
37876
+ const result = await entry.live.start();
37877
+ entry.lastResult = result ?? null;
37878
+ entry.ready = true;
37879
+ for (const [subClientId, subIds] of entry.subscribers) {
37880
+ for (const subId of subIds) {
37881
+ ctx.connectionManager.sendToClient(subClientId, {
37882
+ type: "query-snapshot",
37883
+ subscriptionId: subId,
37884
+ result: result ?? null
37885
+ });
37886
+ }
37887
+ }
37888
+ entry.live.flush();
37611
37889
  } catch (err3) {
37612
- live.stop();
37613
- clientQuerySubs.get(client.id)?.delete(subscriptionId);
37890
+ entry.live.stop();
37891
+ sharedQueries.delete(sharedKey);
37892
+ for (const subClientId of entry.subscribers.keys()) {
37893
+ const keys = clientSubKeys.get(subClientId);
37894
+ if (keys) {
37895
+ for (const [subId, key] of keys) {
37896
+ if (key === sharedKey)
37897
+ keys.delete(subId);
37898
+ }
37899
+ }
37900
+ }
37614
37901
  console.error(`[Arc] Query subscription error (${descriptor?.element}.${descriptor?.method}):`, err3);
37615
37902
  ctx.connectionManager.sendToClient(client.id, {
37616
37903
  type: "error",
@@ -37620,11 +37907,10 @@ function querySubscriptionHandler() {
37620
37907
  return true;
37621
37908
  }
37622
37909
  if (message.type === "unsubscribe-query") {
37623
- const subs = clientQuerySubs.get(client.id);
37624
- const live = subs?.get(message.subscriptionId);
37625
- if (live) {
37626
- live.stop();
37627
- subs.delete(message.subscriptionId);
37910
+ const key = clientSubKeys.get(client.id)?.get(message.subscriptionId);
37911
+ if (key) {
37912
+ detachSub(client.id, message.subscriptionId, key);
37913
+ clientSubKeys.get(client.id)?.delete(message.subscriptionId);
37628
37914
  }
37629
37915
  return true;
37630
37916
  }
@@ -37826,7 +38112,7 @@ async function createArcServer(config) {
37826
38112
  cronScheduler,
37827
38113
  stop: () => {
37828
38114
  cronScheduler.stop();
37829
- server.stop();
38115
+ server.stop(true);
37830
38116
  }
37831
38117
  };
37832
38118
  }
@@ -37865,10 +38151,10 @@ function generateShellHtml(appName, manifest, initial, stylesHash) {
37865
38151
  <html lang="en">
37866
38152
  <head>
37867
38153
  <meta charset="UTF-8" />
37868
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
38154
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
37869
38155
  <title>${manifest?.title ?? appName}</title>${manifest?.favicon ? `
37870
38156
  <link rel="icon" href="${manifest.favicon}">` : ""}${manifest ? `
37871
- <link rel="manifest" href="/manifest.json">` : ""}
38157
+ <link rel="manifest" href="/manifest.json${stylesQs}">` : ""}
37872
38158
  <link rel="stylesheet" href="/styles.css${stylesQs}" />
37873
38159
  <link rel="stylesheet" href="/theme.css${stylesQs}" />
37874
38160
  <link rel="modulepreload" href="${initialUrl}" />${otelTag}
@@ -38046,7 +38332,10 @@ function staticFilesHandler(ws, devMode, getManifest) {
38046
38332
  "Cache-Control": devMode ? "no-cache" : "max-age=31536000,immutable"
38047
38333
  });
38048
38334
  if ((path4 === "/manifest.json" || path4 === "/manifest.webmanifest") && ws.manifest) {
38049
- return serveFile(ws.manifest.path, ctx.corsHeaders);
38335
+ return serveFile(ws.manifest.path, {
38336
+ ...ctx.corsHeaders,
38337
+ "Cache-Control": devMode ? "no-cache" : "max-age=31536000,immutable"
38338
+ });
38050
38339
  }
38051
38340
  if (path4.lastIndexOf(".") > path4.lastIndexOf("/")) {
38052
38341
  const publicFile = join21(ws.publicDir, path4.slice(1));
@@ -38064,7 +38353,12 @@ function apiEndpointsHandler(ws, getManifest, cm, moduleAccessMap, telemetry) {
38064
38353
  if (payloads.length === 0 && ctx.tokenPayload) {
38065
38354
  payloads = [ctx.tokenPayload];
38066
38355
  }
38067
- return filterManifestForTokens(getManifest(), moduleAccessMap, payloads).then((filtered) => Response.json(filtered, { headers: ctx.corsHeaders }));
38356
+ return filterManifestForTokens(getManifest(), moduleAccessMap, payloads).then((filtered) => Response.json(filtered, {
38357
+ headers: {
38358
+ ...ctx.corsHeaders,
38359
+ "Cache-Control": "no-cache, private"
38360
+ }
38361
+ }));
38068
38362
  }
38069
38363
  if (url.pathname === "/api/translations") {
38070
38364
  const config = readTranslationsConfig(ws.rootDir);
@@ -38114,7 +38408,11 @@ function devReloadHandler(sseClients) {
38114
38408
  function spaFallbackHandler(getShellHtml) {
38115
38409
  return (_req, _url, ctx) => {
38116
38410
  return new Response(getShellHtml(), {
38117
- headers: { ...ctx.corsHeaders, "Content-Type": "text/html" }
38411
+ headers: {
38412
+ ...ctx.corsHeaders,
38413
+ "Content-Type": "text/html",
38414
+ "Cache-Control": "no-cache, must-revalidate"
38415
+ }
38118
38416
  });
38119
38417
  };
38120
38418
  }