@pixerate/editor 0.266.2 → 0.267.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/agent/index.cjs +2 -2
  2. package/dist/agent/index.js +1 -1
  3. package/dist/animation-editor/controller.d.cts +8 -0
  4. package/dist/animation-editor/controller.d.ts +8 -0
  5. package/dist/animation-editor/effect-tools.d.cts +1 -1
  6. package/dist/animation-editor/effect-tools.d.ts +1 -1
  7. package/dist/animation-editor/index.cjs +172 -105
  8. package/dist/animation-editor/index.js +91 -24
  9. package/dist/brushes/index.cjs +59 -59
  10. package/dist/brushes/index.js +5 -5
  11. package/dist/brushes/profiles.d.cts +6 -1
  12. package/dist/brushes/profiles.d.ts +6 -1
  13. package/dist/{brushstrokeRender-FSUWXUZY.cjs → brushstrokeRender-L7JYRR2R.cjs} +16 -16
  14. package/dist/{brushstrokeRender-KD453OBX.js → brushstrokeRender-NLFPEBGI.js} +4 -4
  15. package/dist/canvas/brushTypes.d.cts +12 -0
  16. package/dist/canvas/brushTypes.d.ts +12 -0
  17. package/dist/canvas/brushstroke.d.cts +1 -1
  18. package/dist/canvas/brushstroke.d.ts +1 -1
  19. package/dist/canvas/drawController.d.cts +19 -4
  20. package/dist/canvas/drawController.d.ts +19 -4
  21. package/dist/canvas/index.cjs +144 -105
  22. package/dist/canvas/index.js +46 -7
  23. package/dist/{chunk-XORJ7UZO.cjs → chunk-3VHH6V67.cjs} +13 -12
  24. package/dist/{chunk-T2LDTEXK.js → chunk-4IDUYB45.js} +2217 -56
  25. package/dist/chunk-7UKFXXWL.js +802 -0
  26. package/dist/chunk-ADMRNWR7.js +340 -0
  27. package/dist/{chunk-CIJBSUM5.js → chunk-AGNUD5BI.js} +2 -2
  28. package/dist/{chunk-WLUVZKVD.cjs → chunk-DT4YQUGT.cjs} +32 -32
  29. package/dist/{chunk-DXYHQ2VN.js → chunk-EF7LZAXQ.js} +1 -1
  30. package/dist/chunk-EXB2EGBE.cjs +802 -0
  31. package/dist/{chunk-4ODRXQRW.js → chunk-EYSHTYLG.js} +1 -1
  32. package/dist/{chunk-R44Y3EFS.js → chunk-FGJHJIMN.js} +8 -336
  33. package/dist/{chunk-AQZQWXEU.cjs → chunk-G7NHE2VD.cjs} +35 -35
  34. package/dist/{chunk-XC6DPRYI.js → chunk-GSTSZPSR.js} +154 -949
  35. package/dist/{chunk-VRK322ZC.cjs → chunk-HIO6E7LC.cjs} +2 -2
  36. package/dist/{chunk-TOID45I2.cjs → chunk-J2TNIZ55.cjs} +1 -1
  37. package/dist/{chunk-YHDHFJUC.cjs → chunk-J5VQYK7T.cjs} +217 -1012
  38. package/dist/{chunk-3C33YTNN.js → chunk-JGWVZPT6.js} +2 -2
  39. package/dist/{chunk-ACFSFUQH.js → chunk-JL6YH5WD.js} +4 -0
  40. package/dist/{chunk-3SBLVGOM.cjs → chunk-LA5Y4ETA.cjs} +23 -23
  41. package/dist/{chunk-MVUQSK5J.cjs → chunk-LHPEG5AU.cjs} +107 -435
  42. package/dist/{chunk-DOZ6F2K2.js → chunk-NSETJI74.js} +3 -2
  43. package/dist/{chunk-XRXFVRGY.cjs → chunk-OKHKA43L.cjs} +2364 -203
  44. package/dist/{chunk-LK4SXL3V.js → chunk-OSEXT7JL.js} +1 -1
  45. package/dist/{chunk-PE6YJMQT.cjs → chunk-PFHJS4HE.cjs} +20 -19
  46. package/dist/{chunk-7KNW3WXZ.cjs → chunk-QEVLRLUN.cjs} +63 -0
  47. package/dist/{chunk-OTN6VB5S.cjs → chunk-RDFHWAHL.cjs} +5 -1
  48. package/dist/{chunk-6JL2D5SG.js → chunk-VE6UKYQ2.js} +3 -2
  49. package/dist/{chunk-RFJZGTHA.cjs → chunk-XVOP3CGQ.cjs} +9 -9
  50. package/dist/{chunk-EZOJBP4D.js → chunk-YIC6MAJ2.js} +1 -1
  51. package/dist/chunk-YZWM6ZIP.cjs +340 -0
  52. package/dist/{chunk-472INMWH.js → chunk-ZA7L5YJB.js} +63 -0
  53. package/dist/commands/builtins.d.cts +12 -1
  54. package/dist/commands/builtins.d.ts +12 -1
  55. package/dist/commands/index.cjs +2 -2
  56. package/dist/commands/index.js +1 -1
  57. package/dist/image-editor/controller.d.cts +1 -1
  58. package/dist/image-editor/controller.d.ts +1 -1
  59. package/dist/image-editor/index.cjs +837 -833
  60. package/dist/image-editor/index.js +105 -101
  61. package/dist/paint/index.cjs +5 -3
  62. package/dist/paint/index.js +46 -44
  63. package/dist/paint-editor/controller.d.cts +5 -3
  64. package/dist/paint-editor/controller.d.ts +5 -3
  65. package/dist/paint-editor/index.cjs +832 -2295
  66. package/dist/paint-editor/index.js +285 -1748
  67. package/dist/paint-editor/path-samples.d.cts +2 -0
  68. package/dist/paint-editor/path-samples.d.ts +2 -0
  69. package/dist/paint-editor/presence.d.cts +20 -1
  70. package/dist/paint-editor/presence.d.ts +20 -1
  71. package/dist/stickers/helpers.d.cts +2 -0
  72. package/dist/stickers/helpers.d.ts +2 -0
  73. package/dist/stickers/index.cjs +41 -35
  74. package/dist/stickers/index.js +22 -16
  75. package/dist/stickers/types.d.cts +4 -2
  76. package/dist/stickers/types.d.ts +4 -2
  77. package/dist/vector/backdrop.d.cts +13 -0
  78. package/dist/vector/backdrop.d.ts +13 -0
  79. package/dist/vector/brushstroke.d.cts +54 -7
  80. package/dist/vector/brushstroke.d.ts +54 -7
  81. package/dist/vector/brushstrokeMedia.d.cts +96 -0
  82. package/dist/vector/brushstrokeMedia.d.ts +96 -0
  83. package/dist/vector/controller.d.cts +17 -3
  84. package/dist/vector/controller.d.ts +17 -3
  85. package/dist/vector/index.cjs +1846 -1386
  86. package/dist/vector/index.d.cts +2 -0
  87. package/dist/vector/index.d.ts +2 -0
  88. package/dist/vector/index.js +517 -57
  89. package/dist/vector/render.d.cts +6 -0
  90. package/dist/vector/render.d.ts +6 -0
  91. package/dist/vector/types.d.cts +14 -0
  92. package/dist/vector/types.d.ts +14 -0
  93. package/package.json +1 -1
  94. package/skills/pixerate-animation-editor/SKILL.md +1 -0
  95. package/skills/pixerate-brushes/SKILL.md +2 -2
  96. package/skills/pixerate-brushes-design/SKILL.md +7 -4
  97. package/skills/pixerate-brushes-design/evals/port-to-vector.json +8 -8
  98. package/skills/pixerate-canvas/SKILL.md +11 -1
  99. package/skills/pixerate-image-editor/SKILL.md +19 -64
  100. package/skills/pixerate-image-editor/references/color-management.md +2 -1
  101. package/skills/pixerate-image-editor/references/free-transform.md +12 -0
  102. package/skills/pixerate-image-editor/references/layer-effects.md +10 -0
  103. package/skills/pixerate-image-editor/references/painting.md +17 -0
  104. package/skills/pixerate-image-editor/references/photoshop-files.md +1 -1
  105. package/skills/pixerate-image-editor/references/shapes-and-type.md +14 -0
  106. package/skills/pixerate-image-editor/references/smart-objects.md +10 -0
  107. package/skills/pixerate-paint-editor/SKILL.md +8 -4
  108. package/skills/pixerate-paint-editor/references/wet-media.md +9 -0
  109. package/skills/pixerate-vector/SKILL.md +16 -6
  110. package/skills/pixerate-vector/references/best-practices.md +1 -0
  111. package/skills/pixerate-vector/references/commands.md +19 -0
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10;
2
2
 
3
3
 
4
4
 
@@ -7,7 +7,11 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkRFJZGTHAcjs = require('./chunk-RFJZGTHA.cjs');
10
+ var _chunkXVOP3CGQcjs = require('./chunk-XVOP3CGQ.cjs');
11
+
12
+
13
+
14
+ var _chunkRDFHWAHLcjs = require('./chunk-RDFHWAHL.cjs');
11
15
 
12
16
 
13
17
  var _chunkCVFAAZXEcjs = require('./chunk-CVFAAZXE.cjs');
@@ -57,10 +61,69 @@ var _chunkJBZRVLXVcjs = require('./chunk-JBZRVLXV.cjs');
57
61
 
58
62
 
59
63
 
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+ var _chunkJ5VQYK7Tcjs = require('./chunk-J5VQYK7T.cjs');
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
60
84
  var _chunkPXDIAYB6cjs = require('./chunk-PXDIAYB6.cjs');
61
85
 
62
86
 
63
87
 
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+ var _chunkFQPUF2W2cjs = require('./chunk-FQPUF2W2.cjs');
104
+
105
+
106
+
107
+ var _chunk3K6HWEXZcjs = require('./chunk-3K6HWEXZ.cjs');
108
+
109
+
110
+
111
+ var _chunkYQGCPL5Xcjs = require('./chunk-YQGCPL5X.cjs');
112
+
113
+
114
+ var _chunk2VX55NFMcjs = require('./chunk-2VX55NFM.cjs');
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+ var _chunk474IQG74cjs = require('./chunk-474IQG74.cjs');
124
+
125
+
126
+
64
127
  var _chunk4ZC5QJE2cjs = require('./chunk-4ZC5QJE2.cjs');
65
128
 
66
129
 
@@ -2320,7 +2383,7 @@ function vectorStrokeParts(path, style) {
2320
2383
  const cap = capExtent(style, width);
2321
2384
  const tipMode = style.arrowAlign === "tip";
2322
2385
  const trims = contours.map(() => [0, 0]);
2323
- const place2 = (end, contour, ci) => {
2386
+ const place3 = (end, contour, ci) => {
2324
2387
  const kind = end === "start" ? style.startArrow : style.endArrow;
2325
2388
  if (!kind || contour.closed) return;
2326
2389
  const hw = arrowheadWeight(style, end);
@@ -2341,8 +2404,8 @@ function vectorStrokeParts(path, style) {
2341
2404
  }
2342
2405
  heads.push({ end, kind, tip, dir, inset, path: arrowheadPath(kind, tip, dir, hw) });
2343
2406
  };
2344
- place2("start", first, 0);
2345
- place2("end", last, contours.length - 1);
2407
+ place3("start", first, 0);
2408
+ place3("end", last, contours.length - 1);
2346
2409
  if (!tipMode || !heads.length) return { align, line: path, drawWidth, heads };
2347
2410
  const trimmed = contours.map((c, i) => {
2348
2411
  const [s0, s1] = trims[i];
@@ -2534,22 +2597,1839 @@ function vectorExtrudeFaces(path, params) {
2534
2597
  return order.map((i) => faces[i].face);
2535
2598
  }
2536
2599
 
2600
+ // src/paint-editor/effect-paint.ts
2601
+ var EFFECT_STRIP_HEIGHT = 256;
2602
+ var EFFECT_MAP_REPEATS = ["repeat", "mirror", "clamp"];
2603
+ function effectPaintSize(p, canvas) {
2604
+ return p.map ? { width: p.map.length, height: EFFECT_STRIP_HEIGHT } : { width: canvas.width, height: canvas.height };
2605
+ }
2606
+ function readEffectStrokeMap(raw) {
2607
+ if (raw === void 0 || raw === null || raw.by === "canvas") return void 0;
2608
+ const r = raw;
2609
+ if (r.by !== "stroke") throw new Error(`map.by ${JSON.stringify(r.by)} is not a mapping; use "canvas" (fixed to the canvas) or "stroke" (along each stroke).`);
2610
+ const length2 = r.length === void 0 ? 300 : Number(r.length);
2611
+ if (!(Number.isFinite(length2) && length2 >= 16 && length2 <= 4096)) throw new Error(`map.length ${JSON.stringify(r.length)} is out of range; use 16..4096 px of stroke per repeat.`);
2612
+ const repeat = r.repeat === void 0 ? "repeat" : r.repeat;
2613
+ if (!EFFECT_MAP_REPEATS.includes(repeat)) throw new Error(`map.repeat ${JSON.stringify(r.repeat)} is not a repeat mode; use ${EFFECT_MAP_REPEATS.join(", ")}.`);
2614
+ return { by: "stroke", length: Math.round(length2), repeat };
2615
+ }
2616
+ function stripIndex(img, map, dab, x, y) {
2617
+ const ca = Math.cos(dab.direction);
2618
+ const sa = Math.sin(dab.direction);
2619
+ const dx = x - dab.x;
2620
+ const dy = y - dab.y;
2621
+ let u = (dab.travel + dx * ca - dy * sa) / map.length;
2622
+ if (map.repeat === "clamp") u = Math.min(1, Math.max(0, u));
2623
+ else if (map.repeat === "mirror") {
2624
+ const m = (u % 2 + 2) % 2;
2625
+ u = m > 1 ? 2 - m : m;
2626
+ } else u = (u % 1 + 1) % 1;
2627
+ const v2 = Math.min(1, Math.max(0, ((dx * sa + dy * ca) / Math.max(0.5, dab.radius) + 1) / 2));
2628
+ const px = Math.min(img.width - 1, Math.floor(u * img.width));
2629
+ const py = Math.min(img.height - 1, Math.floor(v2 * img.height));
2630
+ return (py * img.width + px) * 4;
2631
+ }
2632
+ function effectPaintKey(p) {
2633
+ return JSON.stringify({ type: "effect", effect: p.effect, provider: p.provider, values: p.values, time: p.time, ...p.map ? { map: p.map } : {} });
2634
+ }
2635
+ function isPaintEffectPaint(raw) {
2636
+ return Boolean(raw) && typeof raw === "object" && raw.type === "effect";
2637
+ }
2638
+ function readMapLeniently(raw) {
2639
+ try {
2640
+ return readEffectStrokeMap(raw);
2641
+ } catch (e4) {
2642
+ return void 0;
2643
+ }
2644
+ }
2645
+ function readPaintEffectPaint(raw) {
2646
+ if (!isPaintEffectPaint(raw)) return null;
2647
+ const r = raw;
2648
+ if (typeof r.effect !== "string" || !r.effect || !r.values || typeof r.values !== "object" || Array.isArray(r.values)) return null;
2649
+ return {
2650
+ type: "effect",
2651
+ effect: r.effect,
2652
+ provider: typeof r.provider === "string" ? r.provider : "",
2653
+ values: JSON.parse(JSON.stringify(r.values)),
2654
+ time: typeof r.time === "number" && Number.isFinite(r.time) && r.time > 0 ? r.time : 0,
2655
+ ...readMapLeniently(r.map) ? { map: readMapLeniently(r.map) } : {},
2656
+ ...r.live === true ? { live: true } : {}
2657
+ };
2658
+ }
2659
+ function sampleEffectField(img, rect, vals, field, dab) {
2660
+ const { width, height, data } = img;
2661
+ if (img.map && dab) {
2662
+ for (let yy = 0, k = 0; yy < rect.height; yy++) {
2663
+ for (let xx = 0; xx < rect.width; xx++, k++) {
2664
+ const i = stripIndex(img, img.map, dab, rect.x + xx + 0.5, rect.y + yy + 0.5);
2665
+ const f = k * 3;
2666
+ const a = data[i + 3];
2667
+ if (a < 255) vals[k] *= a / 255;
2668
+ field[f] = data[i] / 255;
2669
+ field[f + 1] = data[i + 1] / 255;
2670
+ field[f + 2] = data[i + 2] / 255;
2671
+ }
2672
+ }
2673
+ return;
2674
+ }
2675
+ for (let yy = 0, k = 0; yy < rect.height; yy++) {
2676
+ const y = rect.y + yy;
2677
+ const inY = y >= 0 && y < height;
2678
+ for (let xx = 0; xx < rect.width; xx++, k++) {
2679
+ const x = rect.x + xx;
2680
+ const f = k * 3;
2681
+ if (!inY || x < 0 || x >= width) {
2682
+ vals[k] = 0;
2683
+ field[f] = field[f + 1] = field[f + 2] = 0;
2684
+ continue;
2685
+ }
2686
+ const i = (y * width + x) * 4;
2687
+ const a = data[i + 3];
2688
+ if (a < 255) vals[k] *= a / 255;
2689
+ field[f] = data[i] / 255;
2690
+ field[f + 1] = data[i + 1] / 255;
2691
+ field[f + 2] = data[i + 2] / 255;
2692
+ }
2693
+ }
2694
+ }
2695
+ function sampleEffectAt(img, x, y, out, dab) {
2696
+ if (img.map && dab) {
2697
+ const i2 = stripIndex(img, img.map, dab, x, y);
2698
+ out[0] = img.data[i2] / 255;
2699
+ out[1] = img.data[i2 + 1] / 255;
2700
+ out[2] = img.data[i2 + 2] / 255;
2701
+ return img.data[i2 + 3] / 255;
2702
+ }
2703
+ const px = Math.floor(x);
2704
+ const py = Math.floor(y);
2705
+ if (px < 0 || py < 0 || px >= img.width || py >= img.height) return 0;
2706
+ const i = (py * img.width + px) * 4;
2707
+ out[0] = img.data[i] / 255;
2708
+ out[1] = img.data[i + 1] / 255;
2709
+ out[2] = img.data[i + 2] / 255;
2710
+ return img.data[i + 3] / 255;
2711
+ }
2712
+ function effectDabField(img, rect, cov, centre, mixed, field, steps = 0, dab = null) {
2713
+ sampleEffectField(img, rect, cov, field, dab);
2714
+ const d0 = mixed[0] - centre[0];
2715
+ const d1 = mixed[1] - centre[1];
2716
+ const d2 = mixed[2] - centre[2];
2717
+ const n = rect.width * rect.height;
2718
+ for (let k = 0; k < n; k++) {
2719
+ if (steps) cov[k] = Math.round(cov[k] * steps) / steps;
2720
+ const f = k * 3;
2721
+ field[f] = Math.min(1, Math.max(0, field[f] + d0));
2722
+ field[f + 1] = Math.min(1, Math.max(0, field[f + 1] + d1));
2723
+ field[f + 2] = Math.min(1, Math.max(0, field[f + 2] + d2));
2724
+ }
2725
+ }
2726
+
2727
+ // src/paint-editor/stamp-tip.ts
2728
+ var samplers = /* @__PURE__ */ new WeakMap();
2729
+ function stampSampler(ref, art) {
2730
+ let kind = null;
2731
+ try {
2732
+ kind = _chunkRDFHWAHLcjs.editorStampOf.call(void 0, ref.includes(":") ? ref : `editor:${ref}`);
2733
+ } catch (e5) {
2734
+ return null;
2735
+ }
2736
+ if (kind) {
2737
+ const k = kind;
2738
+ return (u, v2, seed) => _chunkRDFHWAHLcjs.stampCoverage.call(void 0, k, u, v2, seed);
2739
+ }
2740
+ const a = _optionalChain([art, 'optionalCall', _55 => _55(ref)]);
2741
+ if (!a || !(a.width > 0 && a.height > 0)) return null;
2742
+ const hit = samplers.get(a);
2743
+ if (hit) return hit;
2744
+ const { width: w, height: h, data } = a;
2745
+ const scale3 = Math.max(w, h) / 2;
2746
+ const alpha = (x, y) => x < 0 || y < 0 || x >= w || y >= h ? 0 : data[(y * w + x) * 4 + 3] / 255;
2747
+ const sampler = (u, v2) => {
2748
+ const x = u * scale3 + w / 2 - 0.5;
2749
+ const y = v2 * scale3 + h / 2 - 0.5;
2750
+ const x0 = Math.floor(x);
2751
+ const y0 = Math.floor(y);
2752
+ const fx = x - x0;
2753
+ const fy = y - y0;
2754
+ return (alpha(x0, y0) * (1 - fx) + alpha(x0 + 1, y0) * fx) * (1 - fy) + (alpha(x0, y0 + 1) * (1 - fx) + alpha(x0 + 1, y0 + 1) * fx) * fy;
2755
+ };
2756
+ samplers.set(a, sampler);
2757
+ return sampler;
2758
+ }
2759
+ function stampDabRect(d) {
2760
+ const r = Math.max(0.5, d.radius) * Math.SQRT2 + 1.5;
2761
+ const x0 = Math.floor(d.x - r);
2762
+ const y0 = Math.floor(d.y - r);
2763
+ return { x: x0, y: y0, width: Math.ceil(d.x + r) - x0, height: Math.ceil(d.y + r) - y0 };
2764
+ }
2765
+ function rasterizeStampDab(d, sample, seed, rect, out) {
2766
+ const w = rect.width;
2767
+ const h = rect.height;
2768
+ out.fill(0, 0, w * h);
2769
+ const r = Math.max(0.5, d.radius);
2770
+ const ro = Math.min(1, Math.max(0.05, d.roundness));
2771
+ const sn = Math.sin(d.angle);
2772
+ const cs = Math.cos(d.angle);
2773
+ const ss = r < 6 ? 3 : 1;
2774
+ for (let yy = 0; yy < h; yy++) {
2775
+ for (let xx = 0; xx < w; xx++) {
2776
+ let sum = 0;
2777
+ for (let sy = 0; sy < ss; sy++) {
2778
+ for (let sx = 0; sx < ss; sx++) {
2779
+ const dx = rect.x + xx + (sx + 0.5) / ss - d.x;
2780
+ const dy = rect.y + yy + (sy + 0.5) / ss - d.y;
2781
+ const u = (dx * cs - dy * sn) / r;
2782
+ const v2 = (dx * sn + dy * cs) / (r * ro);
2783
+ if (u > -1.05 && u < 1.05 && v2 > -1.05 && v2 < 1.05) sum += sample(u, v2, seed);
2784
+ }
2785
+ }
2786
+ const val = sum / (ss * ss);
2787
+ if (val > 0) out[yy * w + xx] = Math.min(1, val) * d.alpha;
2788
+ }
2789
+ }
2790
+ }
2791
+ function brushStickerRefs(brush) {
2792
+ const refs = brush.engine === "sticker" ? [...brush.sticker.stamps] : brush.engine === "particle" ? [...brush.particle.dotTextures] : brush.engine === "dab" && brush.stamp ? [brush.stamp] : [];
2793
+ return [...new Set(refs.filter((r) => r.includes(":") && !r.startsWith("editor:")))];
2794
+ }
2795
+ function sprayDroplets(d, spray, seed) {
2796
+ const count = 1 + Math.round(spray.density * 31);
2797
+ const key = d.index * 131 + Math.round(d.travel * 8);
2798
+ const out = [];
2799
+ for (let i = 0; i < count; i++) {
2800
+ const n = key * 64 + i;
2801
+ const a = _chunk3K6HWEXZcjs.rand01.call(void 0, seed, n, 61) * Math.PI * 2;
2802
+ const rr = Math.sqrt(_chunk3K6HWEXZcjs.rand01.call(void 0, seed, n, 67)) * d.radius;
2803
+ out.push({ ...d, x: d.x + Math.cos(a) * rr, y: d.y + Math.sin(a) * rr, radius: Math.max(0.5, d.radius * spray.size * (0.6 + 0.8 * _chunk3K6HWEXZcjs.rand01.call(void 0, seed, n, 71))), roundness: 1, angle: _chunk3K6HWEXZcjs.rand01.call(void 0, seed, n, 73) * Math.PI * 2 });
2804
+ }
2805
+ return out;
2806
+ }
2807
+
2808
+ // src/paint-editor/paper.ts
2809
+ var PAPER_FAMILIES = ["watercolor", "drawing", "pastel", "canvas", "panel", "smooth"];
2810
+ var unit2 = (v2, d) => typeof v2 === "number" && Number.isFinite(v2) ? Math.min(1, Math.max(0, v2)) : d;
2811
+ var clampNum = (v2, lo, hi, d) => typeof v2 === "number" && Number.isFinite(v2) ? Math.min(hi, Math.max(lo, v2)) : d;
2812
+ var HEX = /^#[0-9a-f]{6}$/i;
2813
+ var tuning = (contrast = 1, invert2 = false) => ({ contrast, invert: invert2 });
2814
+ function preset(id, name, family, pattern, color2, o) {
2815
+ return {
2816
+ preset: id,
2817
+ name,
2818
+ family,
2819
+ pattern,
2820
+ seed: _nullishCoalesce(o.seed, () => ( 1)),
2821
+ color: color2,
2822
+ scale: _nullishCoalesce(o.scale, () => ( 1)),
2823
+ tiling: "mirror",
2824
+ depth: o.depth,
2825
+ shading: _nullishCoalesce(o.shading, () => ( 0.5)),
2826
+ dry: tuning(_nullishCoalesce(o.contrast, () => ( 1))),
2827
+ wet: tuning(1),
2828
+ absorption: o.absorption,
2829
+ permeability: o.permeability,
2830
+ roughness: o.roughness,
2831
+ ...o.backlight ? { backlight: o.backlight, backlightColor: _nullishCoalesce(o.backlightColor, () => ( "#fff1d6")) } : {}
2832
+ };
2833
+ }
2834
+ var PAPER_LIBRARY = [
2835
+ preset("cold-pressed", "Cold pressed watercolour", "watercolor", "cold-pressed", "#f7f3ea", { depth: 0.5, absorption: 0.7, permeability: 0.5, roughness: 0.6 }),
2836
+ preset("hot-pressed", "Hot pressed watercolour", "watercolor", "hot-pressed", "#f8f6ef", { depth: 0.25, absorption: 0.55, permeability: 0.4, roughness: 0.25 }),
2837
+ preset("rough-watercolor", "Rough watercolour", "watercolor", "rough", "#f5f0e4", { depth: 0.75, absorption: 0.8, permeability: 0.6, roughness: 0.85 }),
2838
+ preset("cartridge", "Cartridge", "drawing", "vellum", "#fbfaf6", { depth: 0.3, absorption: 0.4, permeability: 0.3, roughness: 0.35 }),
2839
+ preset("laid", "Laid paper", "drawing", "laid", "#f3ecdc", { depth: 0.45, absorption: 0.45, permeability: 0.35, roughness: 0.45 }),
2840
+ preset("ingres", "Charcoal paper", "drawing", "ingres", "#ede6d6", { depth: 0.6, absorption: 0.4, permeability: 0.3, roughness: 0.65 }),
2841
+ preset("sanded-pastel", "Sanded pastel paper", "pastel", "sanded", "#d8cfc0", { depth: 0.7, absorption: 0.3, permeability: 0.2, roughness: 0.9, shading: 0.35 }),
2842
+ preset("pastel-card", "Grey pastel card", "pastel", "sanded", "#9c978e", { depth: 0.55, absorption: 0.3, permeability: 0.2, roughness: 0.75, scale: 1.5, shading: 0.3 }),
2843
+ preset("cotton-canvas", "Cotton canvas", "canvas", "canvas", "#efe9dc", { depth: 0.55, absorption: 0.35, permeability: 0.25, roughness: 0.6 }),
2844
+ preset("fine-linen", "Fine linen", "canvas", "linen", "#e9e2d2", { depth: 0.45, absorption: 0.3, permeability: 0.25, roughness: 0.5 }),
2845
+ preset("gesso", "Gesso panel", "panel", "gesso", "#f6f4ef", { depth: 0.35, absorption: 0.2, permeability: 0.15, roughness: 0.4 }),
2846
+ preset("smooth", "Smooth bristol", "smooth", "smooth", "#ffffff", { depth: 0, absorption: 0.3, permeability: 0.2, roughness: 0.05, shading: 0 }),
2847
+ // Backlit: smooth paper on a lightbox, for glazes that glow like stained glass.
2848
+ preset("stained-glass", "Stained glass (backlit)", "smooth", "smooth", "#ffffff", { depth: 0, absorption: 0.35, permeability: 0.25, roughness: 0.05, shading: 0, backlight: 0.8, backlightColor: "#fff1d6" })
2849
+ ];
2850
+ var DEFAULT_PAPER = PAPER_LIBRARY[0];
2851
+ function paperPreset(id) {
2852
+ const p = PAPER_LIBRARY.find((x) => x.preset === id);
2853
+ return p ? clonePaper(p) : void 0;
2854
+ }
2855
+ function clonePaper(p) {
2856
+ return { ...p, dry: { ...p.dry }, wet: { ...p.wet }, ...p.offset ? { offset: { ...p.offset } } : {} };
2857
+ }
2858
+ function readOffset(raw, d) {
2859
+ const o = raw && typeof raw === "object" ? raw : null;
2860
+ const x = o && typeof o.x === "number" && Number.isFinite(o.x) ? Math.round(o.x) : _nullishCoalesce(_optionalChain([d, 'optionalAccess', _56 => _56.x]), () => ( 0));
2861
+ const y = o && typeof o.y === "number" && Number.isFinite(o.y) ? Math.round(o.y) : _nullishCoalesce(_optionalChain([d, 'optionalAccess', _57 => _57.y]), () => ( 0));
2862
+ return x || y ? { offset: { x, y } } : {};
2863
+ }
2864
+ function readTuning(raw, d) {
2865
+ const r = raw && typeof raw === "object" ? raw : {};
2866
+ return { contrast: clampNum(r.contrast, 0, 3, d.contrast), invert: typeof r.invert === "boolean" ? r.invert : d.invert };
2867
+ }
2868
+ function normalizePaper(raw = {}, base) {
2869
+ const r = raw;
2870
+ const b = _nullishCoalesce(_nullishCoalesce(base, () => ( (typeof r.preset === "string" ? paperPreset(r.preset) : void 0))), () => ( clonePaper(DEFAULT_PAPER)));
2871
+ return {
2872
+ preset: typeof r.preset === "string" && r.preset ? r.preset : b.preset,
2873
+ name: typeof r.name === "string" && r.name.trim() ? r.name.trim() : b.name,
2874
+ family: PAPER_FAMILIES.includes(r.family) ? r.family : b.family,
2875
+ pattern: _chunkPXDIAYB6cjs.GRAIN_PATTERNS.includes(r.pattern) ? r.pattern : b.pattern,
2876
+ seed: typeof r.seed === "number" && Number.isFinite(r.seed) ? Math.round(Math.abs(r.seed)) % 2147483647 : b.seed,
2877
+ color: typeof r.color === "string" && HEX.test(r.color) ? r.color.toLowerCase() : b.color,
2878
+ scale: clampNum(r.scale, 0.25, 8, b.scale),
2879
+ tiling: r.tiling === "repeat" || r.tiling === "mirror" ? r.tiling : b.tiling,
2880
+ depth: unit2(r.depth, b.depth),
2881
+ shading: unit2(r.shading, b.shading),
2882
+ dry: readTuning(r.dry, b.dry),
2883
+ wet: readTuning(r.wet, b.wet),
2884
+ absorption: unit2(r.absorption, b.absorption),
2885
+ permeability: unit2(r.permeability, b.permeability),
2886
+ roughness: unit2(r.roughness, b.roughness),
2887
+ ...unit2(r.metallic, _nullishCoalesce(b.metallic, () => ( 0))) > 0 ? { metallic: unit2(r.metallic, _nullishCoalesce(b.metallic, () => ( 0))) } : {},
2888
+ ...unit2(r.backlight, _nullishCoalesce(b.backlight, () => ( 0))) > 0 ? { backlight: unit2(r.backlight, _nullishCoalesce(b.backlight, () => ( 0))) } : {},
2889
+ ...typeof r.backlightColor === "string" && HEX.test(r.backlightColor) ? { backlightColor: r.backlightColor.toLowerCase() } : b.backlightColor ? { backlightColor: b.backlightColor } : {},
2890
+ ...readOffset(r.offset, b.offset)
2891
+ };
2892
+ }
2893
+ function hexToRgb8(hex) {
2894
+ const n = parseInt(hex.slice(1, 7), 16);
2895
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
2896
+ }
2897
+ function renderPaper(paper, rect, grain = new (0, _chunkPXDIAYB6cjs.PaperGrain)(paper), light) {
2898
+ const [r, g, b] = hexToRgb8(paper.color);
2899
+ const out = new Uint8ClampedArray(rect.width * rect.height * 4);
2900
+ const shade = grain.flat ? 0 : paper.shading * 0.16;
2901
+ const metal = light ? _nullishCoalesce(paper.metallic, () => ( 0)) : 0;
2902
+ let hx = 0;
2903
+ let hy = 0;
2904
+ let hz = 1;
2905
+ if (metal > 0 && light) {
2906
+ const az = light.azimuth * Math.PI / 180;
2907
+ const el = light.elevation * Math.PI / 180;
2908
+ const lx = Math.cos(el) * Math.sin(az);
2909
+ const ly = -Math.cos(el) * Math.cos(az);
2910
+ const lz = Math.sin(el) + 1;
2911
+ const n = Math.hypot(lx, ly, lz);
2912
+ hx = lx / n;
2913
+ hy = ly / n;
2914
+ hz = lz / n;
2915
+ }
2916
+ for (let y = 0; y < rect.height; y++) {
2917
+ for (let x = 0; x < rect.width; x++) {
2918
+ const i = (y * rect.width + x) * 4;
2919
+ const px = rect.x + x + 0.5;
2920
+ const py = rect.y + y + 0.5;
2921
+ const k = shade ? 1 - shade * (1 - grain.at(px, py)) : 1;
2922
+ let spec = 0;
2923
+ if (metal > 0) {
2924
+ const gx = (grain.at(px + 1, py) - grain.at(px - 1, py)) * 4;
2925
+ const gy = (grain.at(px, py + 1) - grain.at(px, py - 1)) * 4;
2926
+ const nl = Math.hypot(gx, gy, 1);
2927
+ const nh = Math.max(0, (-gx * hx - gy * hy + hz) / nl);
2928
+ spec = metal * Math.pow(nh, 24) * 0.9;
2929
+ }
2930
+ out[i] = Math.min(255, r * k * (1 - 0.25 * metal) + spec * (r * 0.6 + 102));
2931
+ out[i + 1] = Math.min(255, g * k * (1 - 0.25 * metal) + spec * (g * 0.6 + 102));
2932
+ out[i + 2] = Math.min(255, b * k * (1 - 0.25 * metal) + spec * (b * 0.6 + 102));
2933
+ out[i + 3] = 255;
2934
+ }
2935
+ }
2936
+ return out;
2937
+ }
2938
+
2939
+ // src/paint-editor/engine.ts
2940
+ function penOrientation(p) {
2941
+ if (typeof p.altitude === "number" && Number.isFinite(p.altitude)) {
2942
+ const altitude = Math.min(Math.PI / 2, Math.max(0, p.altitude));
2943
+ const azimuth = typeof p.azimuth === "number" && Number.isFinite(p.azimuth) ? p.azimuth : 0;
2944
+ return { altitude, azimuth };
2945
+ }
2946
+ const hasX = typeof p.tiltX === "number" && Number.isFinite(p.tiltX);
2947
+ const hasY = typeof p.tiltY === "number" && Number.isFinite(p.tiltY);
2948
+ if (!hasX && !hasY) return null;
2949
+ return tiltToOrientation(hasX ? p.tiltX : 0, hasY ? p.tiltY : 0);
2950
+ }
2951
+ function tiltToOrientation(tiltX, tiltY) {
2952
+ const clampT = (v2) => Math.min(89.999, Math.max(-89.999, v2));
2953
+ const tx = Math.tan(clampT(tiltX) * Math.PI / 180);
2954
+ const ty = Math.tan(clampT(tiltY) * Math.PI / 180);
2955
+ const r = Math.hypot(tx, ty);
2956
+ if (r < 1e-9) return { altitude: Math.PI / 2, azimuth: 0 };
2957
+ let azimuth = Math.atan2(ty, tx);
2958
+ if (azimuth < 0) azimuth += 2 * Math.PI;
2959
+ return { altitude: Math.atan(1 / r), azimuth };
2960
+ }
2961
+ var pressureOf = (p) => typeof p.pressure === "number" && Number.isFinite(p.pressure) ? Math.min(1, Math.max(0, p.pressure)) : 1;
2962
+ var PenSmoother = (_class = class {
2963
+ __init() {this.pos = null}
2964
+ __init2() {this.pressure = null}
2965
+
2966
+
2967
+ constructor(position, pressure) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
2968
+ this.a = 1 - Math.min(0.95, Math.max(0, position));
2969
+ this.ap = 1 - Math.min(0.95, Math.max(0, pressure));
2970
+ }
2971
+ push(p) {
2972
+ const pr = pressureOf(p);
2973
+ if (!this.pos) {
2974
+ this.pos = { x: p.x, y: p.y };
2975
+ this.pressure = pr;
2976
+ return p;
2977
+ }
2978
+ this.pos = { x: this.pos.x + (p.x - this.pos.x) * this.a, y: this.pos.y + (p.y - this.pos.y) * this.a };
2979
+ this.pressure = this.pressure + (pr - this.pressure) * this.ap;
2980
+ return { ...p, x: this.pos.x, y: this.pos.y, pressure: this.pressure };
2981
+ }
2982
+ /** Where the smoothed position is now (or `null` before the first sample). */
2983
+ get position() {
2984
+ return this.pos;
2985
+ }
2986
+ }, _class);
2987
+ var IDENTITY_COPY = { map: (p) => p, linear: [1, 0, 0, 1] };
2988
+ var FULL_SPEED = 2.5;
2989
+ var PenDabWalker = (_class2 = class {
2990
+ constructor(brush, seed = 0, linear = [1, 0, 0, 1]) {;_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);
2991
+ this.brush = brush;
2992
+ this.seed = seed;
2993
+ this.linear = linear;
2994
+ }
2995
+
2996
+
2997
+
2998
+ __init3() {this.last = null}
2999
+ __init4() {this.nextAt = 0}
3000
+ __init5() {this.pendingFirst = null}
3001
+ __init6() {this.index = 0}
3002
+ __init7() {this.dir = 0}
3003
+ __init8() {this.lastT = null}
3004
+ __init9() {this.firstT = null}
3005
+ __init10() {this.speed = null}
3006
+ __init11() {this.travelled = 0}
3007
+ sample(p) {
3008
+ const o = penOrientation(p);
3009
+ let speed = null;
3010
+ let time = null;
3011
+ if (this.last) this.travelled += Math.hypot(p.x - this.last.x, p.y - this.last.y);
3012
+ if (typeof p.t === "number" && Number.isFinite(p.t)) {
3013
+ if (this.firstT === null) this.firstT = p.t;
3014
+ time = p.t - this.firstT;
3015
+ if (this.last && this.lastT !== null && p.t > this.lastT) {
3016
+ const v2 = Math.hypot(p.x - this.last.x, p.y - this.last.y) / (p.t - this.lastT);
3017
+ this.speed = this.speed === null ? v2 : this.speed + (v2 - this.speed) * 0.35;
3018
+ }
3019
+ this.lastT = p.t;
3020
+ speed = _nullishCoalesce(this.speed, () => ( 0));
3021
+ }
3022
+ return {
3023
+ x: p.x,
3024
+ y: p.y,
3025
+ pressure: pressureOf(p),
3026
+ lean: o ? 1 - o.altitude / (Math.PI / 2) : 0,
3027
+ azimuth: o ? o.azimuth : 0,
3028
+ twist: typeof p.twist === "number" && Number.isFinite(p.twist) ? p.twist : null,
3029
+ speed,
3030
+ travel: this.travelled,
3031
+ time
3032
+ };
3033
+ }
3034
+ diameter(s) {
3035
+ const tip = this.brush.tip;
3036
+ const dyn = this.brush.dynamics;
3037
+ let d = tip.size;
3038
+ if (tip.pressureSize) d *= dyn.minSize + (1 - dyn.minSize) * s.pressure;
3039
+ d *= 1 + dyn.tiltSize * s.lean * 1.5;
3040
+ if (s.speed !== null && dyn.velocitySize) d *= Math.max(0.05, 1 + dyn.velocitySize * Math.min(1, s.speed / FULL_SPEED) * (dyn.velocitySize < 0 ? 0.85 : 1));
3041
+ return d;
3042
+ }
3043
+ stepLen(s) {
3044
+ return Math.max(0.5, Math.max(1, this.diameter(s)) * Math.max(0.01, this.brush.tip.spacing));
3045
+ }
3046
+ /** A rasterizer angle (CCW, y up) mapped through this copy's linear part. */
3047
+ mapAngle(theta) {
3048
+ const [a, b, c, d] = this.linear;
3049
+ if (a === 1 && b === 0 && c === 0 && d === 1) return theta;
3050
+ const vx = Math.cos(theta);
3051
+ const vy = -Math.sin(theta);
3052
+ return Math.atan2(-(c * vx + d * vy), a * vx + b * vy);
3053
+ }
3054
+ dab(s) {
3055
+ const { tip, dynamics: dyn, rotation } = this.brush;
3056
+ const i = this.index++;
3057
+ const seed = this.seed;
3058
+ let diameter = this.diameter(s);
3059
+ if (dyn.sizeJitter) diameter *= Math.max(0.05, 1 + dyn.sizeJitter * _chunk3K6HWEXZcjs.randSigned.call(void 0, seed, i, 1 /* Size */));
3060
+ const base = tip.angle * Math.PI / 180;
3061
+ let angle;
3062
+ if (rotation === "stroke") angle = this.dir + base;
3063
+ else if (rotation === "barrel" && s.twist !== null) angle = this.mapAngle(base - s.twist * Math.PI / 180);
3064
+ else if (dyn.tiltRoundness > 0 && s.lean > 0.02) angle = this.mapAngle(base - s.azimuth);
3065
+ else angle = this.mapAngle(base);
3066
+ if (dyn.angleJitter) angle += dyn.angleJitter * Math.PI * _chunk3K6HWEXZcjs.randSigned.call(void 0, seed, i, 2 /* Angle */);
3067
+ let opacity = tip.pressureOpacity ? s.pressure : 1;
3068
+ opacity *= 1 - dyn.tiltOpacity * s.lean * 0.8;
3069
+ if (s.speed !== null && dyn.velocityOpacity) opacity *= Math.max(0, 1 + dyn.velocityOpacity * (Math.min(1, s.speed / FULL_SPEED) - 0.5));
3070
+ if (dyn.opacityJitter) opacity *= 1 - dyn.opacityJitter * (_chunk3K6HWEXZcjs.randSigned.call(void 0, seed, i, 3 /* Opacity */) * 0.5 + 0.5);
3071
+ const flow = tip.flow * (1 - dyn.pressureFlow + dyn.pressureFlow * s.pressure);
3072
+ let { x, y } = s;
3073
+ if (dyn.scatter) {
3074
+ const off = dyn.scatter * diameter * _chunk3K6HWEXZcjs.randSigned.call(void 0, seed, i, 4 /* Scatter */);
3075
+ x += Math.sin(this.dir) * off;
3076
+ y += Math.cos(this.dir) * off;
3077
+ }
3078
+ return {
3079
+ x,
3080
+ y,
3081
+ radius: Math.max(0.5, diameter / 2),
3082
+ alpha: Math.min(1, Math.max(0, flow)),
3083
+ opacity: Math.min(1, Math.max(0, opacity)),
3084
+ angle,
3085
+ roundness: Math.min(1, Math.max(0.01, tip.roundness * (1 - dyn.tiltRoundness * s.lean * 0.8))),
3086
+ pressure: s.pressure,
3087
+ direction: this.dir,
3088
+ index: i,
3089
+ travel: s.travel,
3090
+ time: s.time,
3091
+ lean: s.lean,
3092
+ speed: s.speed
3093
+ };
3094
+ }
3095
+ push(p, out) {
3096
+ const a = this.last;
3097
+ const s = this.sample(p);
3098
+ if (!a) {
3099
+ this.last = s;
3100
+ this.pendingFirst = s;
3101
+ this.nextAt = this.stepLen(s);
3102
+ return;
3103
+ }
3104
+ const dx = s.x - a.x;
3105
+ const dy = s.y - a.y;
3106
+ const len2 = Math.hypot(dx, dy);
3107
+ if (len2 > 1e-9) this.dir = Math.atan2(-dy, dx);
3108
+ if (this.pendingFirst) {
3109
+ out.push(this.dab(this.pendingFirst));
3110
+ this.pendingFirst = null;
3111
+ }
3112
+ if (len2 > 1e-9) {
3113
+ while (this.nextAt <= len2 + 1e-9) {
3114
+ const f = Math.min(1, this.nextAt / len2);
3115
+ const lerp4 = (u, v2) => u + (v2 - u) * f;
3116
+ const q = {
3117
+ x: a.x + dx * f,
3118
+ y: a.y + dy * f,
3119
+ pressure: lerp4(a.pressure, s.pressure),
3120
+ lean: lerp4(a.lean, s.lean),
3121
+ azimuth: lerpAngle(a.azimuth, s.azimuth, f),
3122
+ twist: a.twist !== null && s.twist !== null ? lerpDegrees(a.twist, s.twist, f) : s.twist,
3123
+ speed: a.speed !== null && s.speed !== null ? lerp4(a.speed, s.speed) : s.speed,
3124
+ travel: a.travel + this.nextAt,
3125
+ time: a.time !== null && s.time !== null ? lerp4(a.time, s.time) : s.time
3126
+ };
3127
+ out.push(this.dab(q));
3128
+ this.nextAt += this.stepLen(q);
3129
+ }
3130
+ this.nextAt -= len2;
3131
+ }
3132
+ this.last = s;
3133
+ }
3134
+ finish(out) {
3135
+ if (this.pendingFirst) {
3136
+ out.push(this.dab(this.pendingFirst));
3137
+ this.pendingFirst = null;
3138
+ }
3139
+ }
3140
+ }, _class2);
3141
+ function lerpAngle(a, b, t) {
3142
+ let d = b - a;
3143
+ while (d > Math.PI) d -= 2 * Math.PI;
3144
+ while (d < -Math.PI) d += 2 * Math.PI;
3145
+ return a + d * t;
3146
+ }
3147
+ function lerpDegrees(a, b, t) {
3148
+ let d = b - a;
3149
+ while (d > 180) d -= 360;
3150
+ while (d < -180) d += 360;
3151
+ return a + d * t;
3152
+ }
3153
+ var DryStroke = (_class3 = class {
3154
+ constructor(brush, options) {;_class3.prototype.__init12.call(this);_class3.prototype.__init13.call(this);_class3.prototype.__init14.call(this);_class3.prototype.__init15.call(this);_class3.prototype.__init16.call(this);_class3.prototype.__init17.call(this);
3155
+ this.brush = brush;
3156
+ this.options = options;
3157
+ this.stamp = brush.stamp ? stampSampler(brush.stamp, options.stampArt) : null;
3158
+ this.smoother = new PenSmoother(brush.tip.smoothing, brush.pressureSmoothing);
3159
+ this.copies = _optionalChain([options, 'access', _58 => _58.copies, 'optionalAccess', _59 => _59.length]) ? options.copies : [IDENTITY_COPY];
3160
+ this.walkers = this.copies.map((c, i) => new PenDabWalker(brush, (_nullishCoalesce(options.seed, () => ( 0))) + i * 7919 | 0, c.linear));
3161
+ this.depth = options.grain && !options.grain.flat ? Math.min(1, Math.max(0, options.paperDepth * brush.grain)) : 0;
3162
+ }
3163
+
3164
+
3165
+ __init12() {this.coverage = new (0, _chunkFQPUF2W2cjs.CoverageMap)()}
3166
+ __init13() {this.dabCount = 0}
3167
+
3168
+
3169
+
3170
+
3171
+ __init14() {this.buf = new Float32Array(0)}
3172
+ __init15() {this.field = new Float32Array(0)}
3173
+ __init16() {this.lastRaw = null}
3174
+ __init17() {this.lastFed = null}
3175
+ /** The stamp tip's shape, or `null` for the round computed tip. */
3176
+
3177
+ /** Feeds raw pen samples; returns the document rectangles the new dabs touched. */
3178
+ push(points) {
3179
+ const dabs = [];
3180
+ for (const raw of points) {
3181
+ this.lastRaw = raw;
3182
+ const p = this.smoother.push(raw);
3183
+ this.lastFed = p;
3184
+ this.copies.forEach((c, i) => this.walkers[i].push(c.map(p), dabs));
3185
+ }
3186
+ return this.paint(dabs);
3187
+ }
3188
+ /** Ends the stroke: the smoothed path catches up with the last raw sample; a single tap paints one dab. */
3189
+ finish() {
3190
+ const dabs = [];
3191
+ const raw = this.lastRaw;
3192
+ const fed = this.lastFed;
3193
+ if (raw && fed && (raw.x !== fed.x || raw.y !== fed.y)) this.copies.forEach((c, i) => this.walkers[i].push(c.map({ ...raw, pressure: fed.pressure }), dabs));
3194
+ for (const w of this.walkers) w.finish(dabs);
3195
+ return this.paint(dabs);
3196
+ }
3197
+ paint(dabs) {
3198
+ const rects = [];
3199
+ const spray = this.brush.spray;
3200
+ const seed = _nullishCoalesce(this.options.seed, () => ( 0));
3201
+ for (const d of dabs) {
3202
+ if (!spray) {
3203
+ this.mark(d, d, rects);
3204
+ continue;
3205
+ }
3206
+ for (const drop of sprayDroplets(d, spray, seed)) this.mark(drop, d, rects);
3207
+ }
3208
+ return rects;
3209
+ }
3210
+ /** Lays one mark (a dab, or a spray droplet of dab `d`): the round tip or the stamp, the paper grain, effect paint. */
3211
+ mark(m, d, rects) {
3212
+ const hardness = this.brush.tip.hardness;
3213
+ const grain = this.options.grain;
3214
+ const rect = this.stamp ? stampDabRect(m) : _chunkFQPUF2W2cjs.dabRect.call(void 0, m, hardness);
3215
+ const n = rect.width * rect.height;
3216
+ if (this.buf.length < n) this.buf = new Float32Array(n);
3217
+ const vals = this.buf.subarray(0, n);
3218
+ if (this.stamp) rasterizeStampDab(m, this.stamp, d.index, rect, vals);
3219
+ else _chunkFQPUF2W2cjs.rasterizeDab.call(void 0, m, hardness, rect, vals);
3220
+ if (this.depth > 0 && grain) {
3221
+ for (let yy = 0, k = 0; yy < rect.height; yy++) {
3222
+ const y = rect.y + yy + 0.5;
3223
+ for (let xx = 0; xx < rect.width; xx++, k++) {
3224
+ if (vals[k] > 0) vals[k] *= _chunkPXDIAYB6cjs.grainCatch.call(void 0, grain.at(rect.x + xx + 0.5, y), this.depth, d.pressure);
3225
+ }
3226
+ }
3227
+ }
3228
+ let field = null;
3229
+ if (this.options.effect) {
3230
+ if (this.field.length < n * 3) this.field = new Float32Array(n * 3);
3231
+ field = this.field.subarray(0, n * 3);
3232
+ sampleEffectField(this.options.effect, rect, vals, field, d);
3233
+ }
3234
+ this.coverage.accumulate(rect, vals, m.opacity, null, field);
3235
+ rects.push(rect);
3236
+ this.dabCount++;
3237
+ }
3238
+ }, _class3);
3239
+ function mixerTip(brush) {
3240
+ return { ...brush.tip, smoothing: 0, pressureSize: brush.tip.pressureSize };
3241
+ }
3242
+ function toStrokePoint(p) {
3243
+ return { x: p.x, y: p.y, pressure: pressureOf(p), ...typeof p.t === "number" ? { t: p.t } : {} };
3244
+ }
3245
+
3246
+ // src/paint-editor/dab-stroke.ts
3247
+ var GRADIENT_STEPS = 32;
3248
+ function multiColorPalette(mc, color2, secondary) {
3249
+ if (mc.colors.length >= 2) {
3250
+ return mc.colors.map((h) => {
3251
+ const n = parseInt(h.slice(1), 16);
3252
+ return [(n >> 16 & 255) / 255, (n >> 8 & 255) / 255, (n & 255) / 255];
3253
+ });
3254
+ }
3255
+ return [[...color2], [...secondary]];
3256
+ }
3257
+ function soften(f, softness) {
3258
+ if (softness >= 1) return f;
3259
+ const w = Math.max(1e-3, softness);
3260
+ return Math.min(1, Math.max(0, (f - 0.5) / w + 0.5));
3261
+ }
3262
+ function mixRgb(a, b, t, mixing) {
3263
+ if (t <= 0) return [...a];
3264
+ if (t >= 1) return [...b];
3265
+ if (mixing === "pigment") {
3266
+ const o = [0, 0, 0];
3267
+ const q = (v2) => Math.round(Math.min(1, Math.max(0, v2)) * 255);
3268
+ _chunk2VX55NFMcjs.mixPigment8.call(void 0, q(a[0]), q(a[1]), q(a[2]), q(b[0]), q(b[1]), q(b[2]), t, o);
3269
+ return [o[0], o[1], o[2]];
3270
+ }
3271
+ return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];
3272
+ }
3273
+ function multiColorGradient(palette, softness, mixing) {
3274
+ const n = palette.length;
3275
+ const out = [];
3276
+ for (let j = 0; j < GRADIENT_STEPS; j++) {
3277
+ const f = j / (GRADIENT_STEPS - 1) * (n - 1);
3278
+ const i = Math.min(n - 2, Math.floor(f));
3279
+ out.push(mixRgb(palette[i], palette[i + 1], soften(f - i, softness), mixing));
3280
+ }
3281
+ return out;
3282
+ }
3283
+ function multiColorForDab(mc, palette, index, seed, mixing) {
3284
+ const n = palette.length;
3285
+ if (mc.order === "random") {
3286
+ const run = Math.floor(index / mc.length);
3287
+ return [...palette[Math.min(n - 1, Math.floor(_chunk3K6HWEXZcjs.rand01.call(void 0, seed, run, 11) * n))]];
3288
+ }
3289
+ const f = index / mc.length % n;
3290
+ const i = Math.floor(f);
3291
+ return mixRgb(palette[i], palette[(i + 1) % n], soften(f - i, mc.softness), mixing);
3292
+ }
3293
+ var PaintDabStroke = (_class4 = class {
3294
+ constructor(brush, options) {;_class4.prototype.__init18.call(this);_class4.prototype.__init19.call(this);_class4.prototype.__init20.call(this);_class4.prototype.__init21.call(this);_class4.prototype.__init22.call(this);_class4.prototype.__init23.call(this);_class4.prototype.__init24.call(this);_class4.prototype.__init25.call(this);_class4.prototype.__init26.call(this);_class4.prototype.__init27.call(this);
3295
+ this.brush = brush;
3296
+ this.options = options;
3297
+ this.stamp = brush.engine === "dab" && brush.stamp ? stampSampler(brush.stamp, options.stampArt) : null;
3298
+ this.smoother = new PenSmoother(brush.tip.smoothing, brush.pressureSmoothing);
3299
+ this.copies = _optionalChain([options, 'access', _60 => _60.copies, 'optionalAccess', _61 => _61.length]) ? options.copies : [IDENTITY_COPY];
3300
+ const exchanging = brush.engine === "mixer" || brush.engine === "dab";
3301
+ const rates = brush.engine === "mixer" ? _chunkFQPUF2W2cjs.mixerRates.call(void 0, brush.mixer) : _chunkFQPUF2W2cjs.exchangeRates.call(void 0, brush.behavior.pickup, brush.behavior.mix, 1, brush.behavior.mixing);
3302
+ this.mixing = brush.engine === "mixer" ? brush.mixer.mixing : brush.behavior.mixing;
3303
+ this.states = this.copies.map((c, i) => ({
3304
+ walker: new PenDabWalker(brush, (_nullishCoalesce(options.seed, () => ( 0))) + i * 7919 | 0, c.linear),
3305
+ exchange: exchanging ? new (0, _chunkFQPUF2W2cjs.PaintExchange)(rates, options.load) : null,
3306
+ smudge: brush.engine === "smudge" ? new (0, _chunkFQPUF2W2cjs.SmudgeTip)(brush.smudge, brush.tip.size * (1 + brush.dynamics.tiltSize * 1.5)) : null
3307
+ }));
3308
+ this.medium = new (0, _chunkFQPUF2W2cjs.TileMedium)(options.target, brush.engine === "dab" ? { blend: brush.tip.blend } : {});
3309
+ this.depth = options.grain && !options.grain.flat ? Math.min(1, Math.max(0, options.paperDepth * brush.grain)) : 0;
3310
+ this.coverage = brush.engine === "dab" ? new (0, _chunkFQPUF2W2cjs.CoverageMap)() : null;
3311
+ this.sampler = exchanging && options.paint ? new (0, _chunkFQPUF2W2cjs.PaintGradientSampler)(options.paint, _nullishCoalesce(options.seed, () => ( 0))) : null;
3312
+ const table = _optionalChain([this, 'access', _62 => _62.sampler, 'optionalAccess', _63 => _63.acrossTip]) ? this.sampler.tipTable(GRADIENT_STEPS) : null;
3313
+ this.gradient = table ? table.map((e) => e.rgb) : null;
3314
+ this.gradientAlpha = table && table.some((e) => e.alpha < 1) ? table.map((e) => e.alpha) : null;
3315
+ this.scratch = brush.engine === "blender" ? _chunkFQPUF2W2cjs.createBlenderScratch.call(void 0, ) : null;
3316
+ }
3317
+
3318
+
3319
+ __init18() {this.dabCount = 0}
3320
+
3321
+
3322
+
3323
+
3324
+
3325
+
3326
+
3327
+ __init19() {this.sample = { rgb: [0, 0, 0], alpha: 1 }}
3328
+
3329
+ /** Opacity across the tip (`across-tip` gradients with opacity stops), or `null`. */
3330
+
3331
+ __init20() {this.alphaCov = new Float32Array(0)}
3332
+ __init21() {this.fieldLut = []}
3333
+
3334
+
3335
+ __init22() {this.tip = new Float32Array(0)}
3336
+ __init23() {this.cov = new Float32Array(0)}
3337
+ __init24() {this.field = new Float32Array(0)}
3338
+ __init25() {this.paint = [0, 0, 0]}
3339
+ __init26() {this.lastRaw = null}
3340
+ __init27() {this.lastFed = null}
3341
+ /** The stamp tip's shape (dab brushes), or `null` for the round computed tip. */
3342
+
3343
+ /** What copy 0's brush carries after the dabs so far (mixer and wet-capable dab brushes). */
3344
+ get load() {
3345
+ return _nullishCoalesce(_optionalChain([this, 'access', _64 => _64.states, 'access', _65 => _65[0], 'access', _66 => _66.exchange, 'optionalAccess', _67 => _67.load]), () => ( null));
3346
+ }
3347
+ push(points) {
3348
+ const rects = [];
3349
+ for (const raw of points) {
3350
+ this.lastRaw = raw;
3351
+ const p = this.smoother.push(raw);
3352
+ this.lastFed = p;
3353
+ this.copies.forEach((c, i) => {
3354
+ const dabs = [];
3355
+ this.states[i].walker.push(c.map(p), dabs);
3356
+ this.paintDabs(i, dabs, rects);
3357
+ });
3358
+ }
3359
+ return rects;
3360
+ }
3361
+ /** Ends the stroke: the smoothed path catches up with the last raw sample; a tap paints one dab. */
3362
+ finish() {
3363
+ const rects = [];
3364
+ const raw = this.lastRaw;
3365
+ const fed = this.lastFed;
3366
+ this.copies.forEach((c, i) => {
3367
+ const dabs = [];
3368
+ if (raw && fed && (raw.x !== fed.x || raw.y !== fed.y)) this.states[i].walker.push(c.map({ ...raw, pressure: fed.pressure }), dabs);
3369
+ this.states[i].walker.finish(dabs);
3370
+ this.paintDabs(i, dabs, rects);
3371
+ });
3372
+ return rects;
3373
+ }
3374
+ paintDabs(copy, dabs, rects) {
3375
+ const spray = this.brush.engine === "dab" ? this.brush.spray : null;
3376
+ for (const d of spray ? dabs.flatMap((dab) => sprayDroplets(dab, spray, (_nullishCoalesce(this.options.seed, () => ( 0))) + copy * 7919)) : dabs) {
3377
+ const rect = this.stamp ? stampDabRect(d) : _chunkFQPUF2W2cjs.dabRect.call(void 0, d, this.brush.tip.hardness);
3378
+ if (rect.width <= 0 || rect.height <= 0) continue;
3379
+ this.dab(copy, d, rect);
3380
+ rects.push(rect);
3381
+ this.dabCount++;
3382
+ }
3383
+ }
3384
+ /** The tip's pure coverage (`tip`) and, with grain, what the paper catches of it (`cov`). */
3385
+ rasterize(d, rect) {
3386
+ const n = rect.width * rect.height;
3387
+ if (this.tip.length < n) {
3388
+ this.tip = new Float32Array(n);
3389
+ this.cov = new Float32Array(n);
3390
+ }
3391
+ const tip = this.tip.subarray(0, n);
3392
+ tip.fill(0);
3393
+ if (this.stamp) rasterizeStampDab({ ...d, alpha: 1 }, this.stamp, d.index, rect, tip);
3394
+ else _chunkFQPUF2W2cjs.rasterizeDab.call(void 0, { ...d, alpha: 1 }, this.brush.tip.hardness, rect, tip);
3395
+ if (!(this.depth > 0 && this.options.grain)) return { tip, cov: tip };
3396
+ const cov = this.cov.subarray(0, n);
3397
+ const grain = this.options.grain;
3398
+ for (let yy = 0, k = 0; yy < rect.height; yy++) {
3399
+ const y = rect.y + yy + 0.5;
3400
+ for (let xx = 0; xx < rect.width; xx++, k++) cov[k] = tip[k] > 0 ? tip[k] * _chunkPXDIAYB6cjs.grainCatch.call(void 0, grain.at(rect.x + xx + 0.5, y), this.depth, d.pressure) : 0;
3401
+ }
3402
+ return { tip, cov };
3403
+ }
3404
+ dab(copy, d, rect) {
3405
+ const brush = this.brush;
3406
+ const { tip, cov } = this.rasterize(d, rect);
3407
+ const st = this.states[copy];
3408
+ if (brush.engine === "blender") {
3409
+ _chunkFQPUF2W2cjs.blenderDab.call(void 0, this.medium, rect, cov, d.opacity * d.alpha * brush.tip.opacity, d.radius, brush.blender, this.scratch);
3410
+ return;
3411
+ }
3412
+ if (brush.engine === "smudge") {
3413
+ st.smudge.dab(this.medium, { x: d.x, y: d.y, radius: d.radius, opacity: d.opacity * d.alpha * brush.tip.opacity }, rect, cov);
3414
+ return;
3415
+ }
3416
+ const ex = st.exchange;
3417
+ ex.pickUp(this.medium.sample(rect, tip));
3418
+ let flow = 1;
3419
+ if (this.options.effect) {
3420
+ const rgb = [0, 0, 0];
3421
+ flow = sampleEffectAt(this.options.effect, d.x, d.y, rgb, d);
3422
+ ex.setReservoirColor(rgb[0], rgb[1], rgb[2]);
3423
+ } else if (this.sampler && !this.gradient) {
3424
+ const g = this.sampler.dab(d, this.sample);
3425
+ ex.setReservoirColor(g.rgb[0], g.rgb[1], g.rgb[2]);
3426
+ flow = g.alpha;
3427
+ }
3428
+ let field = null;
3429
+ let total;
3430
+ let laid = cov;
3431
+ if (this.gradient) {
3432
+ total = this.tipField(ex, d, rect);
3433
+ field = this.field;
3434
+ if (this.gradientAlpha) laid = this.tipAlpha(d, rect, cov);
3435
+ } else total = ex.paint(this.paint);
3436
+ if (total > 0 && flow > 0) {
3437
+ if (this.coverage) this.depositWithCeiling(d, rect, laid, field, ex, flow);
3438
+ else {
3439
+ const dep = Math.min(1, total) * d.alpha * brush.tip.opacity * d.opacity * flow;
3440
+ if (dep > 0) this.medium.deposit(rect, laid, dep, this.paint, ex.paintPigment, field);
3441
+ }
3442
+ }
3443
+ ex.drain();
3444
+ }
3445
+ /** Fills `this.field` with the tip gradient (mixed with the carried paint) per pixel; returns the paint weight. */
3446
+ tipField(ex, d, rect) {
3447
+ const g = this.gradient;
3448
+ const lut = this.fieldLut;
3449
+ let total = 0;
3450
+ for (let j = 0; j < g.length; j++) {
3451
+ ex.setReservoirColor(g[j][0], g[j][1], g[j][2]);
3452
+ const out = _nullishCoalesce(lut[j], () => ( [0, 0, 0]));
3453
+ total = ex.paint(out);
3454
+ lut[j] = out;
3455
+ }
3456
+ const n = rect.width * rect.height;
3457
+ if (this.field.length < n * 3) this.field = new Float32Array(n * 3);
3458
+ const f = this.field;
3459
+ const nx = Math.sin(d.direction);
3460
+ const ny = Math.cos(d.direction);
3461
+ const r = Math.max(0.5, d.radius);
3462
+ const last = g.length - 1;
3463
+ for (let yy = 0, k = 0; yy < rect.height; yy++) {
3464
+ const py = rect.y + yy + 0.5 - d.y;
3465
+ for (let xx = 0; xx < rect.width; xx++, k++) {
3466
+ const u = ((rect.x + xx + 0.5 - d.x) * nx + py * ny) / r;
3467
+ const j = Math.min(last, Math.max(0, Math.round((u + 1) / 2 * last)));
3468
+ f[k * 3] = lut[j][0];
3469
+ f[k * 3 + 1] = lut[j][1];
3470
+ f[k * 3 + 2] = lut[j][2];
3471
+ }
3472
+ }
3473
+ return total;
3474
+ }
3475
+ /** `cov` scaled by the gradient's opacity across the tip. */
3476
+ tipAlpha(d, rect, cov) {
3477
+ const a = this.gradientAlpha;
3478
+ const n = rect.width * rect.height;
3479
+ if (this.alphaCov.length < n) this.alphaCov = new Float32Array(n);
3480
+ const out = this.alphaCov.subarray(0, n);
3481
+ const nx = Math.sin(d.direction);
3482
+ const ny = Math.cos(d.direction);
3483
+ const r = Math.max(0.5, d.radius);
3484
+ const last = a.length - 1;
3485
+ for (let yy = 0, k = 0; yy < rect.height; yy++) {
3486
+ const py = rect.y + yy + 0.5 - d.y;
3487
+ for (let xx = 0; xx < rect.width; xx++, k++) {
3488
+ const u = ((rect.x + xx + 0.5 - d.x) * nx + py * ny) / r;
3489
+ out[k] = cov[k] * a[Math.min(last, Math.max(0, Math.round((u + 1) / 2 * last)))];
3490
+ }
3491
+ }
3492
+ return out;
3493
+ }
3494
+ /** A dab brush's deposit: only what this dab adds to the stroke's coverage, under its opacity ceiling. */
3495
+ depositWithCeiling(d, rect, cov, field, ex, flow = 1) {
3496
+ const map = this.coverage;
3497
+ const n = rect.width * rect.height;
3498
+ const before = new Float32Array(n);
3499
+ const vals = new Float32Array(n);
3500
+ for (let yy = 0, k = 0; yy < rect.height; yy++) {
3501
+ for (let xx = 0; xx < rect.width; xx++, k++) {
3502
+ if (cov[k] <= 0) continue;
3503
+ before[k] = map.get(rect.x + xx, rect.y + yy);
3504
+ vals[k] = cov[k] * d.alpha * flow;
3505
+ }
3506
+ }
3507
+ map.accumulate(rect, vals, d.opacity);
3508
+ const o = this.brush.tip.opacity;
3509
+ for (let yy = 0, k = 0; yy < rect.height; yy++) {
3510
+ for (let xx = 0; xx < rect.width; xx++, k++) {
3511
+ if (cov[k] <= 0) {
3512
+ vals[k] = 0;
3513
+ continue;
3514
+ }
3515
+ const c0 = before[k] * o;
3516
+ const c1 = map.get(rect.x + xx, rect.y + yy) * o;
3517
+ vals[k] = c1 > c0 && c0 < 1 ? (c1 - c0) / (1 - c0) : 0;
3518
+ }
3519
+ }
3520
+ this.medium.deposit(rect, vals, 1, this.paint, ex.paintPigment, field);
3521
+ }
3522
+ }, _class4);
3523
+
3524
+ // src/paint-editor/wet.ts
3525
+ var STROKE_WATER = 0.9;
3526
+ var STROKE_MASS = _chunkJ5VQYK7Tcjs.PIGMENT_UNIT * 2.5;
3527
+ var STROKE_LIGHT = 1.5;
3528
+ var COVERAGE_STEPS = 4096;
3529
+ function union(a, b) {
3530
+ if (!a) return { ...b };
3531
+ const x = Math.min(a.x, b.x);
3532
+ const y = Math.min(a.y, b.y);
3533
+ return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };
3534
+ }
3535
+ function wetPaperInput(paper) {
3536
+ const grain = new (0, _chunkPXDIAYB6cjs.PaperGrain)(paper, "wet");
3537
+ const flat = grain.flat;
3538
+ return {
3539
+ absorption: paper.absorption,
3540
+ permeability: paper.permeability,
3541
+ roughness: flat ? 0 : paper.roughness,
3542
+ color: hexToRgb8(paper.color),
3543
+ heightAt: flat ? () => 0.5 : (x, y) => grain.at(x, y)
3544
+ };
3545
+ }
3546
+ var WetStrokeDriver = (_class5 = class {
3547
+ constructor(init) {;_class5.prototype.__init28.call(this);_class5.prototype.__init29.call(this);_class5.prototype.__init30.call(this);_class5.prototype.__init31.call(this);_class5.prototype.__init32.call(this);_class5.prototype.__init33.call(this);_class5.prototype.__init34.call(this);_class5.prototype.__init35.call(this);_class5.prototype.__init36.call(this);_class5.prototype.__init37.call(this);_class5.prototype.__init38.call(this);_class5.prototype.__init39.call(this);_class5.prototype.__init40.call(this);
3548
+ this.init = init;
3549
+ const brush = init.brush;
3550
+ this.smoother = new PenSmoother(brush.tip.smoothing, brush.pressureSmoothing);
3551
+ const copies = init.copies.length ? init.copies : [IDENTITY_COPY];
3552
+ const wet = brush.wet;
3553
+ const spacing = Math.max(0.02, brush.tip.spacing);
3554
+ const perDab = Math.min(1, spacing * 1.2);
3555
+ const thin = wet.thinner;
3556
+ this.medium = new (0, _chunkJ5VQYK7Tcjs.WetMedium)(init.world, init.laneId, {
3557
+ water: STROKE_WATER * Math.min(1, wet.water * (1 + thin)) * perDab,
3558
+ mass: STROKE_MASS * wet.pigment * (1 - 0.6 * thin) * perDab,
3559
+ body: wet.body * (1 - thin),
3560
+ light: 0
3561
+ });
3562
+ this.lightBase = wet.tool === "paint" ? STROKE_LIGHT * brush.light.amount * (1 - 0.6 * thin) * perDab : 0;
3563
+ const rates = _chunkFQPUF2W2cjs.exchangeRates.call(void 0, brush.behavior.pickup, brush.behavior.mix, wet.load, brush.behavior.mixing);
3564
+ this.states = copies.map((c, i) => ({
3565
+ walker: new PenDabWalker(brush, init.seed + i * 7919 | 0, c.linear),
3566
+ exchange: wet.tool === "paint" ? new (0, _chunkFQPUF2W2cjs.PaintExchange)(rates, init.load) : null,
3567
+ last: null
3568
+ }));
3569
+ this.copies = copies;
3570
+ this.depth = init.grain && !init.grain.flat ? Math.min(1, Math.max(0, init.paperDepth * brush.grain)) : 0;
3571
+ const g = _nullishCoalesce(init.paint, () => ( null));
3572
+ this.sampler = g ? new (0, _chunkFQPUF2W2cjs.PaintGradientSampler)(g.map.by === "across-tip" ? { ...g, map: { by: "distance", length: 300, repeat: "mirror" } } : g, init.seed) : null;
3573
+ }
3574
+
3575
+ __init28() {this.dabCount = 0}
3576
+ __init29() {this.bounds = null}
3577
+ /** The world's clock at which each raw point was applied (recorded with the stroke). */
3578
+ __init30() {this.steps = []}
3579
+
3580
+
3581
+
3582
+ __init31() {this.queue = []}
3583
+ __init32() {this.finishing = false}
3584
+ __init33() {this.finished = false}
3585
+ __init34() {this.lastRaw = null}
3586
+ __init35() {this.lastFed = null}
3587
+ __init36() {this.tip = new Float32Array(0)}
3588
+ __init37() {this.cov = new Float32Array(0)}
3589
+ __init38() {this.paint = [0, 0, 0]}
3590
+ __init39() {this.centre = [0, 0, 0]}
3591
+
3592
+
3593
+
3594
+ __init40() {this.sample = { rgb: [0, 0, 0], alpha: 1 }}
3595
+
3596
+ /** What copy 0's brush carries after the dabs so far. */
3597
+ get load() {
3598
+ return _nullishCoalesce(_optionalChain([this, 'access', _68 => _68.states, 'access', _69 => _69[0], 'access', _70 => _70.exchange, 'optionalAccess', _71 => _71.load]), () => ( null));
3599
+ }
3600
+ /** Whether every point (and the end) has been applied. */
3601
+ get done() {
3602
+ return this.finished;
3603
+ }
3604
+ /** Adds raw points; applies them now unless a batch is running. Returns where pixels changed. */
3605
+ push(points) {
3606
+ for (const p of points) this.queue.push(p);
3607
+ return this.flush();
3608
+ }
3609
+ /** Asks for the end; it happens now unless a batch is running (then at the next `flush`). */
3610
+ finish() {
3611
+ this.finishing = true;
3612
+ return this.flush();
3613
+ }
3614
+ /** Applies waiting points (and the end, when asked) if the world is between batches. */
3615
+ flush() {
3616
+ const rects = [];
3617
+ if (this.init.world.busy || this.finished) return rects;
3618
+ while (this.queue.length) {
3619
+ const raw = this.queue.shift();
3620
+ this.steps.push(this.init.world.clock);
3621
+ this.lastRaw = raw;
3622
+ const p = this.smoother.push(raw);
3623
+ this.lastFed = p;
3624
+ this.copies.forEach((c, i) => {
3625
+ const dabs = [];
3626
+ this.states[i].walker.push(c.map(p), dabs);
3627
+ this.applyDabs(i, dabs, rects);
3628
+ });
3629
+ }
3630
+ if (this.finishing) {
3631
+ const raw = this.lastRaw;
3632
+ const fed = this.lastFed;
3633
+ this.copies.forEach((c, i) => {
3634
+ const dabs = [];
3635
+ if (raw && fed && (raw.x !== fed.x || raw.y !== fed.y)) this.states[i].walker.push(c.map({ ...raw, pressure: fed.pressure }), dabs);
3636
+ this.states[i].walker.finish(dabs);
3637
+ this.applyDabs(i, dabs, rects);
3638
+ });
3639
+ this.finished = true;
3640
+ }
3641
+ for (const r of rects) this.bounds = union(this.bounds, r);
3642
+ return rects;
3643
+ }
3644
+ applyDabs(copy, dabs, rects) {
3645
+ for (const d of dabs) {
3646
+ const rect = _chunkFQPUF2W2cjs.dabRect.call(void 0, d, this.init.brush.tip.hardness);
3647
+ if (rect.width <= 0 || rect.height <= 0) continue;
3648
+ this.dab(copy, d, rect);
3649
+ rects.push(rect);
3650
+ this.dabCount++;
3651
+ }
3652
+ }
3653
+ /** The tip's coverage over `rect`, with the grain, quantised. */
3654
+ coverage(d, rect) {
3655
+ const n = rect.width * rect.height;
3656
+ if (this.tip.length < n) {
3657
+ this.tip = new Float32Array(n);
3658
+ this.cov = new Float32Array(n);
3659
+ }
3660
+ const tip = this.tip.subarray(0, n);
3661
+ const cov = this.cov.subarray(0, n);
3662
+ tip.fill(0);
3663
+ _chunkFQPUF2W2cjs.rasterizeDab.call(void 0, { ...d, alpha: 1 }, this.init.brush.tip.hardness, rect, tip);
3664
+ const grain = this.depth > 0 ? this.init.grain : null;
3665
+ const mask = this.init.mask;
3666
+ for (let yy = 0, k = 0; yy < rect.height; yy++) {
3667
+ for (let xx = 0; xx < rect.width; xx++, k++) {
3668
+ if (mask && tip[k] > 0) {
3669
+ const mx = rect.x + xx;
3670
+ const my = rect.y + yy;
3671
+ tip[k] *= mx >= 0 && my >= 0 && mx < mask.width && my < mask.height ? mask.data[my * mask.width + mx] / 255 : 0;
3672
+ }
3673
+ let v2 = tip[k];
3674
+ if (v2 > 0 && grain) v2 *= _chunkPXDIAYB6cjs.grainCatch.call(void 0, grain.at(rect.x + xx + 0.5, rect.y + yy + 0.5), this.depth, d.pressure);
3675
+ tip[k] = Math.round(tip[k] * COVERAGE_STEPS) / COVERAGE_STEPS;
3676
+ cov[k] = Math.round(v2 * COVERAGE_STEPS) / COVERAGE_STEPS;
3677
+ }
3678
+ }
3679
+ return { tip, cov };
3680
+ }
3681
+ dab(copy, d, rect) {
3682
+ const { world, laneId, brush } = this.init;
3683
+ const wet = brush.wet;
3684
+ const st = this.states[copy];
3685
+ const { tip, cov } = this.coverage(d, rect);
3686
+ const k = Math.round(Math.min(1, d.alpha * d.opacity * brush.tip.opacity) * COVERAGE_STEPS) / COVERAGE_STEPS;
3687
+ if (!(k > 0)) return;
3688
+ switch (wet.tool) {
3689
+ case "paint": {
3690
+ const ex = st.exchange;
3691
+ this.medium.options.light = this.lightBase * (brush.light.pressure ? d.pressure : 1);
3692
+ let flow = 1;
3693
+ const effect = this.init.effect;
3694
+ if (effect) {
3695
+ sampleEffectAt(effect, d.x, d.y, this.centre, d);
3696
+ ex.setReservoirColor(this.centre[0], this.centre[1], this.centre[2]);
3697
+ } else if (this.sampler) {
3698
+ const g = this.sampler.dab(d, this.sample);
3699
+ ex.setReservoirColor(g.rgb[0], g.rgb[1], g.rgb[2]);
3700
+ flow = g.alpha;
3701
+ }
3702
+ ex.pickUp(this.medium.sample(rect, tip));
3703
+ const total = ex.paint(this.paint);
3704
+ if (total > 0 && flow > 0 && effect) {
3705
+ const ec = cov.slice();
3706
+ const field = new Float32Array(ec.length * 3);
3707
+ effectDabField(effect, rect, ec, this.centre, this.paint, field, COVERAGE_STEPS, d);
3708
+ this.medium.deposit(rect, ec, Math.min(1, total) * k, this.paint, null, field);
3709
+ } else if (total > 0 && flow > 0) this.medium.deposit(rect, cov, Math.min(1, total) * k * flow, this.paint, null);
3710
+ else world.paint(laneId, rect, cov, this.medium.options.water * k, null);
3711
+ ex.drain();
3712
+ if (wet.rewet > 0) world.rewet(laneId, rect, cov, wet.rewet * k * 0.15, this.init.paperColor);
3713
+ break;
3714
+ }
3715
+ case "water": {
3716
+ world.paint(laneId, rect, cov, this.medium.options.water * k * (wet.water > 0 ? 1 : 0), null);
3717
+ if (wet.rewet > 0) world.rewet(laneId, rect, cov, wet.rewet * k * 0.15, this.init.paperColor);
3718
+ break;
3719
+ }
3720
+ case "dry":
3721
+ world.remove(laneId, rect, cov, wet.strength * 0.35 * k, 0, 0, wet.strength * 0.35 * k);
3722
+ break;
3723
+ case "blow": {
3724
+ const s = wet.strength * 0.08 * k;
3725
+ world.push(laneId, rect, cov, Math.cos(d.direction) * s, -Math.sin(d.direction) * s);
3726
+ break;
3727
+ }
3728
+ case "blend":
3729
+ world.blend(laneId, rect, cov, wet.strength * k);
3730
+ break;
3731
+ case "smudge": {
3732
+ if (st.last) world.drag(laneId, rect, cov, d.x - st.last.x, d.y - st.last.y, wet.strength * k);
3733
+ break;
3734
+ }
3735
+ case "blot":
3736
+ world.remove(laneId, rect, cov, wet.strength * 0.8 * k, wet.strength * 0.6 * k, wet.strength * 0.15 * k, wet.strength * 0.5 * k);
3737
+ break;
3738
+ }
3739
+ st.last = d;
3740
+ }
3741
+ }, _class5);
3742
+ var WET_MEDIUM_PARAMS = {
3743
+ watercolor: {},
3744
+ gouache: { viscosity: 0.45, evaporation: 0.1, edgeDarkening: 0.15, granulation: 0.1, bloom: 0.1, bleed: 0.15, pickup: 0.5, pigmentWeight: 0.5 },
3745
+ oil: { viscosity: 0.95, evaporation: 0.03, edgeDarkening: 0, granulation: 0, bloom: 0, bleed: 0.08, pickup: 0.6, fixture: 0.02, pigmentWeight: 0.8 }
3746
+ };
3747
+ var WET_GPU_MODES = ["auto", "off"];
3748
+ var GPU_LEAD = 16;
3749
+ var DISPLAY_TILES_PER_TICK = 24;
3750
+ var PaintWetLayers = (_class6 = class {
3751
+ constructor(host, options = {}) {;_class6.prototype.__init41.call(this);_class6.prototype.__init42.call(this);_class6.prototype.__init43.call(this);_class6.prototype.__init44.call(this);_class6.prototype.__init45.call(this);_class6.prototype.__init46.call(this);_class6.prototype.__init47.call(this);_class6.prototype.__init48.call(this);_class6.prototype.__init49.call(this);_class6.prototype.__init50.call(this);_class6.prototype.__init51.call(this);_class6.prototype.__init52.call(this);_class6.prototype.__init53.call(this);_class6.prototype.__init54.call(this);_class6.prototype.__init55.call(this);_class6.prototype.__init56.call(this);
3752
+ this.host = host;
3753
+ this.options = options;
3754
+ this.speed = Math.max(1, Math.min(2e3, _nullishCoalesce(options.speed, () => ( 120))));
3755
+ this.undoMemory = Math.max(0, _nullishCoalesce(options.undoMemory, () => ( 512 * 1024 * 1024)));
3756
+ this.gpuMode = options.gpu === "off" ? "off" : "auto";
3757
+ this.gpuMinTiles = Math.max(1, Math.floor(_nullishCoalesce(options.gpuMinTiles, () => ( 16))));
3758
+ }
3759
+
3760
+
3761
+ __init41() {this.world = null}
3762
+ __init42() {this.tilt = { ..._chunkJ5VQYK7Tcjs.FLAT }}
3763
+ __init43() {this.settings = /* @__PURE__ */ new Map()}
3764
+ __init44() {this.paused = false}
3765
+ /** Wet strokes dry as soon as they end (one undo step with the stroke). */
3766
+ __init45() {this.instantDry = false}
3767
+
3768
+ __init46() {this.overlay = false}
3769
+
3770
+ /** The live wet stroke, if any. */
3771
+ __init47() {this.driver = null}
3772
+ __init48() {this.lastTick = null}
3773
+ __init49() {this.ticking = null}
3774
+ __init50() {this.stepsOwed = 0}
3775
+ __init51() {this.displaying = null}
3776
+ __init52() {this.leadAt = 0}
3777
+
3778
+
3779
+ __init53() {this.gpu = null}
3780
+ __init54() {this.gpuSupport = null}
3781
+ __init55() {this.gpuStarting = null}
3782
+ // --- Engine B ------------------------------------------------------------------
3783
+ /** Starts the GPU engine for the world (once; it may turn out unavailable). */
3784
+ startGpu() {
3785
+ if (this.gpuMode === "off" || this.gpu || this.gpuStarting || this.gpuSupport) return;
3786
+ const provider = this.options.gpuProvider === void 0 ? _chunkJ5VQYK7Tcjs.findWebGpu.call(void 0, ) : this.options.gpuProvider;
3787
+ this.gpuStarting = _chunkJ5VQYK7Tcjs.createWetGpuEngine.call(void 0, provider).then(({ engine, support }) => {
3788
+ this.gpuSupport = support;
3789
+ if (!engine) return;
3790
+ if (this.gpuMode === "off" || !this.world) {
3791
+ engine.destroy();
3792
+ this.gpuSupport = null;
3793
+ return;
3794
+ }
3795
+ this.gpu = engine;
3796
+ this.world.gpuMinTiles = this.gpuMinTiles;
3797
+ this.world.attachGpu(engine);
3798
+ }).finally(() => {
3799
+ this.gpuStarting = null;
3800
+ this.host.changed();
3801
+ });
3802
+ }
3803
+ /** Resolves once the GPU engine has started or turned out unavailable. */
3804
+ async gpuReady() {
3805
+ if (this.gpuStarting) await this.gpuStarting;
3806
+ return this.engineInfo();
3807
+ }
3808
+ /** `auto`: use the GPU for large wet areas when there is one; `off`: the CPU only. */
3809
+ setGpu(mode, minTiles) {
3810
+ if (minTiles !== void 0) {
3811
+ this.gpuMinTiles = Math.max(1, Math.floor(minTiles));
3812
+ if (this.world) this.world.gpuMinTiles = this.gpuMinTiles;
3813
+ }
3814
+ if (mode === this.gpuMode) return this.engineInfo();
3815
+ this.gpuMode = mode;
3816
+ if (mode === "off") {
3817
+ _optionalChain([this, 'access', _72 => _72.world, 'optionalAccess', _73 => _73.attachGpu, 'call', _74 => _74(null)]);
3818
+ _optionalChain([this, 'access', _75 => _75.gpu, 'optionalAccess', _76 => _76.destroy, 'call', _77 => _77()]);
3819
+ this.gpu = null;
3820
+ this.gpuSupport = null;
3821
+ } else if (this.world) this.startGpu();
3822
+ return this.engineInfo();
3823
+ }
3824
+ engineInfo() {
3825
+ const w = this.world;
3826
+ const base = { mode: this.gpuMode, adapter: _nullishCoalesce(_optionalChain([this, 'access', _78 => _78.gpuSupport, 'optionalAccess', _79 => _79.adapter]), () => ( null)), maxTiles: _nullishCoalesce(_optionalChain([this, 'access', _80 => _80.gpuSupport, 'optionalAccess', _81 => _81.maxSlots]), () => ( 0)), minTiles: this.gpuMinTiles, activeTiles: _nullishCoalesce(_optionalChain([w, 'optionalAccess', _82 => _82.activeTiles, 'call', _83 => _83()]), () => ( 0)), cpu: this.backend() };
3827
+ if (this.gpuMode === "off") return { ...base, state: "off", reason: "Forced to the CPU." };
3828
+ if (this.gpuStarting) return { ...base, state: "starting", reason: null };
3829
+ if (_optionalChain([w, 'optionalAccess', _84 => _84.gpuError])) return { ...base, state: "failed", reason: w.gpuError };
3830
+ if (this.gpuSupport && !this.gpuSupport.supported) return { ...base, state: "unavailable", reason: this.gpuSupport.reason };
3831
+ if (!this.gpu) return { ...base, state: "not-started", reason: "Starts with the first wet stroke." };
3832
+ if (_optionalChain([w, 'optionalAccess', _85 => _85.gpuActive])) return { ...base, state: "active", reason: null };
3833
+ return { ...base, state: "standby", reason: `The GPU takes over at ${this.gpuMinTiles} wet tiles (256 px).` };
3834
+ }
3835
+ /** The world (made on first use, at the canvas size). */
3836
+ ensureWorld() {
3837
+ const { width, height } = this.host.canvas();
3838
+ if (this.world && (this.world.width !== width || this.world.height !== height)) {
3839
+ if (this.world.laneIds().length) throw new Error("The wet world is the wrong size; dry the paint before resizing the canvas.");
3840
+ this.dropWorld();
3841
+ }
3842
+ if (!this.world) this.world = this.makeWorld(width, height, this.host.paper());
3843
+ return this.world;
3844
+ }
3845
+ makeWorld(width, height, paper) {
3846
+ const world = new (0, _chunkJ5VQYK7Tcjs.WetWorld)(width, height, wetPaperInput(paper), { kernel: this.options.kernel, threads: this.options.threads });
3847
+ world.setTilt(this.tilt);
3848
+ world.gpuMinTiles = this.gpuMinTiles;
3849
+ if (this.gpu) world.attachGpu(this.gpu);
3850
+ else this.startGpu();
3851
+ return world;
3852
+ }
3853
+ /**
3854
+ * Whether `extend` can keep the wet paint when the canvas grows by `left` / `top` on those
3855
+ * sides: the shift has to be whole wet tiles (256 px), and no wet stroke may be live.
3856
+ */
3857
+ canExtend(left2, top) {
3858
+ return left2 % _chunkJ5VQYK7Tcjs.WET_TILE === 0 && top % _chunkJ5VQYK7Tcjs.WET_TILE === 0 && !this.driver;
3859
+ }
3860
+ /**
3861
+ * Keeps the wet paint while the canvas grows to `width`×`height` by `left` / `top` on those
3862
+ * sides (`canExtend` must hold): the world is made again at the new size with every wet layer
3863
+ * moved by (left, top), still wet, its base and flow map with it; `paper` is the new
3864
+ * document's paper (its grain moved with the paint). Wet settings' flow centres move too. The
3865
+ * caller shows the layers again (`syncDisplays`) once the document is the new size.
3866
+ */
3867
+ extend(width, height, left2, top, paper) {
3868
+ if (!this.canExtend(left2, top)) throw new Error("Wet paint only moves by whole 256 px tiles, between strokes.");
3869
+ for (const [id, s] of this.settings) if (s.flow.center) this.settings.set(id, { ...s, flow: { ...s.flow, center: { x: s.flow.center.x + left2, y: s.flow.center.y + top } } });
3870
+ const old = this.world;
3871
+ const snap = _optionalChain([old, 'optionalAccess', _86 => _86.laneIds, 'call', _87 => _87(), 'access', _88 => _88.length]) ? old.snapshot() : null;
3872
+ this.dropWorld();
3873
+ this.lastTick = null;
3874
+ this.stepsOwed = 0;
3875
+ if (!old || !snap) return;
3876
+ const moved = _chunkJ5VQYK7Tcjs.moveWetSnapshot.call(void 0, snap, old, { width, height }, left2, top, (l) => {
3877
+ const flow = _optionalChain([this, 'access', _89 => _89.settings, 'access', _90 => _90.get, 'call', _91 => _91(l.id), 'optionalAccess', _92 => _92.flow]);
3878
+ return {
3879
+ base: _chunk474IQG74cjs.translateSurface.call(void 0, l.base, left2, top),
3880
+ ...l.light ? { light: _chunk474IQG74cjs.translateSurface.call(void 0, l.light, left2, top) } : {},
3881
+ flow: l.flow && flow && flow.kind !== "none" ? _chunkJ5VQYK7Tcjs.flowField.call(void 0, flow, width, height) : l.flow
3882
+ };
3883
+ });
3884
+ this.world = this.makeWorld(width, height, paper);
3885
+ this.world.restore(moved);
3886
+ }
3887
+ /** Whether any layer (or `layerId`) has wet paint. */
3888
+ isWet(layerId) {
3889
+ const w = this.world;
3890
+ if (!w) return false;
3891
+ if (layerId !== void 0) return w.hasLane(layerId) && w.isActive(layerId);
3892
+ return w.laneIds().some((id) => w.isActive(id));
3893
+ }
3894
+ /** Layers holding a wet layer (wet or drying). */
3895
+ wetLayerIds() {
3896
+ return _nullishCoalesce(_optionalChain([this, 'access', _93 => _93.world, 'optionalAccess', _94 => _94.laneIds, 'call', _95 => _95()]), () => ( []));
3897
+ }
3898
+ /** Whether a batch is running (edits wait). */
3899
+ get busy() {
3900
+ return Boolean(_optionalChain([this, 'access', _96 => _96.world, 'optionalAccess', _97 => _97.busy]));
3901
+ }
3902
+ /** Resolves when no batch is running. */
3903
+ async idle() {
3904
+ while (this.ticking) await this.ticking;
3905
+ }
3906
+ settingsOf(layerId, medium = "watercolor") {
3907
+ let s = this.settings.get(layerId);
3908
+ if (!s) {
3909
+ s = { params: _chunkJ5VQYK7Tcjs.normalizeWetParams.call(void 0, WET_MEDIUM_PARAMS[medium], _chunkJ5VQYK7Tcjs.DEFAULT_WET_PARAMS), flow: { ..._chunkJ5VQYK7Tcjs.DEFAULT_FLOW } };
3910
+ this.settings.set(layerId, s);
3911
+ }
3912
+ return s;
3913
+ }
3914
+ /** Puts a layer in the world (its current pixels become the base under the wet paint). */
3915
+ ensureLane(layerId, medium) {
3916
+ const w = this.ensureWorld();
3917
+ if (!w.hasLane(layerId)) {
3918
+ const base = _nullishCoalesce(this.host.layerSurface(layerId), () => ( new (0, _chunk474IQG74cjs.TiledSurface)(4, /* @__PURE__ */ new Map(), 0)));
3919
+ const s = this.settingsOf(layerId, medium);
3920
+ w.ensureLane(layerId, { params: s.params, base, light: this.host.layerLight(layerId) });
3921
+ const { width, height } = this.host.canvas();
3922
+ if (s.flow.kind !== "none") w.setFlow(layerId, _chunkJ5VQYK7Tcjs.flowField.call(void 0, s.flow, width, height), s.flow.strength);
3923
+ }
3924
+ return w;
3925
+ }
3926
+ setParams(layerId, update) {
3927
+ const s = this.settingsOf(layerId);
3928
+ s.params = _chunkJ5VQYK7Tcjs.normalizeWetParams.call(void 0, update, s.params);
3929
+ if (_optionalChain([this, 'access', _98 => _98.world, 'optionalAccess', _99 => _99.hasLane, 'call', _100 => _100(layerId)])) this.world.setParams(layerId, s.params);
3930
+ return { ...s.params };
3931
+ }
3932
+ setFlow(layerId, update) {
3933
+ const s = this.settingsOf(layerId);
3934
+ s.flow = _chunkJ5VQYK7Tcjs.normalizeFlow.call(void 0, update, s.flow);
3935
+ if (_optionalChain([this, 'access', _101 => _101.world, 'optionalAccess', _102 => _102.hasLane, 'call', _103 => _103(layerId)])) {
3936
+ const { width, height } = this.host.canvas();
3937
+ this.world.setFlow(layerId, _chunkJ5VQYK7Tcjs.flowField.call(void 0, s.flow, width, height), s.flow.strength);
3938
+ }
3939
+ return { ...s.flow };
3940
+ }
3941
+ setTilt(update) {
3942
+ this.tilt = _chunkJ5VQYK7Tcjs.normalizeTilt.call(void 0, update, this.tilt);
3943
+ _optionalChain([this, 'access', _104 => _104.world, 'optionalAccess', _105 => _105.setTilt, 'call', _106 => _106(this.tilt)]);
3944
+ return { ...this.tilt };
3945
+ }
3946
+ /** The paper changed. */
3947
+ paperChanged() {
3948
+ _optionalChain([this, 'access', _107 => _107.world, 'optionalAccess', _108 => _108.setPaper, 'call', _109 => _109(wetPaperInput(this.host.paper()))]);
3949
+ }
3950
+ /** A layer as tools describe it. */
3951
+ info(layerId) {
3952
+ const s = this.settingsOf(layerId);
3953
+ const st = _optionalChain([this, 'access', _110 => _110.world, 'optionalAccess', _111 => _111.hasLane, 'call', _112 => _112(layerId)]) ? this.world.stats(layerId) : null;
3954
+ return {
3955
+ layerId,
3956
+ wet: Boolean(st && st.wetCells > 0),
3957
+ wetCells: _nullishCoalesce(_optionalChain([st, 'optionalAccess', _113 => _113.wetCells]), () => ( 0)),
3958
+ wetBounds: _nullishCoalesce(_optionalChain([st, 'optionalAccess', _114 => _114.wetBounds]), () => ( null)),
3959
+ activeTiles: _nullishCoalesce(_optionalChain([st, 'optionalAccess', _115 => _115.activeTiles]), () => ( 0)),
3960
+ params: { ...s.params },
3961
+ flow: { ...s.flow }
3962
+ };
3963
+ }
3964
+ backend() {
3965
+ return _nullishCoalesce(_optionalChain([this, 'access', _116 => _116.world, 'optionalAccess', _117 => _117.backend, 'call', _118 => _118()]), () => ( null));
3966
+ }
3967
+ /** Shows the current wet pixels (at most `maxTiles` reshaded per layer). */
3968
+ syncDisplays(maxTiles = Infinity) {
3969
+ const w = this.world;
3970
+ if (!w) return [];
3971
+ const surfaces = /* @__PURE__ */ new Map();
3972
+ const rects = [];
3973
+ for (const id of w.laneIds()) {
3974
+ const d = w.display(id, maxTiles);
3975
+ if (this.host.layerSurface(id) !== d.surface) surfaces.set(id, d.surface);
3976
+ rects.push(...d.changed);
3977
+ }
3978
+ this.syncLights();
3979
+ if (surfaces.size) this.host.updateSurfaces(surfaces, rects);
3980
+ return rects;
3981
+ }
3982
+ /** Like `syncDisplays`, shading on the GPU when Engine B is active (all stale tiles at once). */
3983
+ async syncDisplaysGpu(maxCpuTiles, lead = false) {
3984
+ const w = this.world;
3985
+ if (!w) return [];
3986
+ const surfaces = /* @__PURE__ */ new Map();
3987
+ const rects = [];
3988
+ for (const id of w.laneIds()) {
3989
+ const d = await w.displayGpu(id, maxCpuTiles, lead);
3990
+ if (!w.hasLane(id)) continue;
3991
+ if (this.host.layerSurface(id) !== d.surface) surfaces.set(id, d.surface);
3992
+ rects.push(...d.changed);
3993
+ }
3994
+ this.syncLights();
3995
+ if (surfaces.size) this.host.updateSurfaces(surfaces, rects);
3996
+ return rects;
3997
+ }
3998
+ /** Shows each wet layer's live light paint (the light under it with the wet light shaded in). */
3999
+ syncLights() {
4000
+ const w = this.world;
4001
+ if (!w) return;
4002
+ const lights = /* @__PURE__ */ new Map();
4003
+ for (const id of w.laneIds()) {
4004
+ const l = w.lightDisplay(id);
4005
+ if (l && this.host.layerLight(id) !== l) lights.set(id, l);
4006
+ }
4007
+ if (lights.size) this.host.updateLights(lights);
4008
+ }
4009
+ /** Drops the wet layers whose paint has all dried (they become ordinary pixel layers). */
4010
+ retireDry() {
4011
+ const w = this.world;
4012
+ if (!w) return;
4013
+ for (const id of w.laneIds()) {
4014
+ if (w.isActive(id) || _optionalChain([this, 'access', _119 => _119.driver, 'optionalAccess', _120 => _120.init, 'access', _121 => _121.laneId]) === id) continue;
4015
+ const base = w.getBase(id);
4016
+ const light = w.isLit(id) ? w.getLight(id) : null;
4017
+ w.removeLane(id);
4018
+ if (light && this.host.layerLight(id) !== light) this.host.updateLights(/* @__PURE__ */ new Map([[id, light]]));
4019
+ this.host.updateSurfaces(/* @__PURE__ */ new Map([[id, base]]), []);
4020
+ }
4021
+ }
4022
+ /**
4023
+ * Advances time by the wall clock (`now` in ms, e.g. `performance.now()`): `speed` steps per
4024
+ * second, at most `maxSteps` per call. Call it every frame; it does nothing while paused or dry.
4025
+ * Resolves when the steps are done and the display is up to date.
4026
+ */
4027
+ tick(now, maxSteps = 8) {
4028
+ if (this.ticking) {
4029
+ this.leadFrame(now);
4030
+ return this.ticking;
4031
+ }
4032
+ if (this.displaying) return this.displaying;
4033
+ const last = this.lastTick;
4034
+ this.lastTick = now;
4035
+ const w = this.world;
4036
+ if (!w || this.paused || last === null) {
4037
+ this.flushDriver();
4038
+ return Promise.resolve();
4039
+ }
4040
+ if (!w.isActive()) {
4041
+ this.flushDriver();
4042
+ this.retireDry();
4043
+ return Promise.resolve();
4044
+ }
4045
+ const lead = w.gpuActive && !this.driver;
4046
+ w.gpuLeadMode = lead;
4047
+ const most = lead ? Math.max(maxSteps, GPU_LEAD) : maxSteps;
4048
+ this.stepsOwed = Math.min(most * 4, this.stepsOwed + (now - last) / 1e3 * this.speed);
4049
+ const n = Math.min(most, Math.floor(this.stepsOwed));
4050
+ this.leadAt = now;
4051
+ if (n < 1) {
4052
+ this.flushDriver();
4053
+ return Promise.resolve();
4054
+ }
4055
+ this.stepsOwed -= n;
4056
+ const run = (async () => {
4057
+ try {
4058
+ await w.step(n);
4059
+ } finally {
4060
+ this.ticking = null;
4061
+ }
4062
+ this.flushDriver();
4063
+ if (w.gpuActive) {
4064
+ const shading = this.syncDisplaysGpu(DISPLAY_TILES_PER_TICK).then(() => void 0);
4065
+ this.displaying = shading;
4066
+ try {
4067
+ await shading;
4068
+ } finally {
4069
+ this.displaying = null;
4070
+ }
4071
+ } else this.syncDisplays(DISPLAY_TILES_PER_TICK);
4072
+ this.retireDry();
4073
+ this.host.changed();
4074
+ })();
4075
+ this.ticking = run;
4076
+ return run;
4077
+ }
4078
+ /** Lead mode: steps the GPU on by the time since the last frame (within the running batch) and shows it. */
4079
+ leadFrame(now) {
4080
+ const w = this.world;
4081
+ if (!w || this.displaying || this.driver || !w.gpuLeading) return;
4082
+ const k = Math.max(1, Math.round((now - this.leadAt) / 1e3 * this.speed));
4083
+ if (!w.gpuLead(k)) return;
4084
+ this.leadAt = now;
4085
+ const shading = this.syncDisplaysGpu(0, true).then(() => this.host.changed());
4086
+ this.displaying = shading;
4087
+ void shading.finally(() => {
4088
+ if (this.displaying === shading) this.displaying = null;
4089
+ });
4090
+ }
4091
+ flushDriver() {
4092
+ const d = this.driver;
4093
+ if (!d || !this.world) return;
4094
+ const rects = d.flush();
4095
+ if (rects.length) this.syncDisplays(DISPLAY_TILES_PER_TICK);
4096
+ if (d.done) _optionalChain([this, 'access', _122 => _122.onDriverDone, 'optionalCall', _123 => _123(d)]);
4097
+ }
4098
+ /** Called when a live stroke that ended mid-batch has finished applying. */
4099
+ __init56() {this.onDriverDone = null}
4100
+ /** Steps `steps` times now (agents, tests). Returns the steps run. */
4101
+ async advance(steps) {
4102
+ await this.idle();
4103
+ const w = this.world;
4104
+ if (!w) return 0;
4105
+ await w.ready;
4106
+ await this.idle();
4107
+ const start = w.clock;
4108
+ const n = Math.max(0, Math.floor(steps));
4109
+ const job = (async () => {
4110
+ try {
4111
+ await w.step(n);
4112
+ } finally {
4113
+ this.ticking = null;
4114
+ }
4115
+ })();
4116
+ this.ticking = job;
4117
+ await job;
4118
+ if (w.gpuActive) await this.syncDisplaysGpu(Infinity);
4119
+ else this.syncDisplays();
4120
+ this.retireDry();
4121
+ return w.clock - start;
4122
+ }
4123
+ /**
4124
+ * Dries at once (everything settles where it is), on one layer or all, optionally only in a
4125
+ * rectangle. Returns the layers and rectangles that dried.
4126
+ */
4127
+ dry(layerId, rect) {
4128
+ const w = this.world;
4129
+ if (!w) return [];
4130
+ const ids = layerId !== void 0 ? w.hasLane(layerId) ? [layerId] : [] : w.laneIds();
4131
+ const out = [];
4132
+ for (const id of ids) out.push({ layerId: id, bounds: w.dry(id, rect) });
4133
+ this.syncDisplays();
4134
+ this.retireDry();
4135
+ return out;
4136
+ }
4137
+ /** The layer's light paint with all its wet paint dried (`null` without a wet layer or light), without changing anything. */
4138
+ bakedLight(layerId) {
4139
+ const w = this.world;
4140
+ if (!_optionalChain([w, 'optionalAccess', _124 => _124.hasLane, 'call', _125 => _125(layerId)]) || !w.isLit(layerId)) return null;
4141
+ return w.bakedLight(layerId);
4142
+ }
4143
+ /** The layer's pixels with all its wet paint dried (deterministic), without changing anything. */
4144
+ bakedSurface(layerId) {
4145
+ const w = this.world;
4146
+ if (!_optionalChain([w, 'optionalAccess', _126 => _126.hasLane, 'call', _127 => _127(layerId)])) return null;
4147
+ return w.bakedSurface(layerId);
4148
+ }
4149
+ /** A snapshot of the world for undo (`null` when there is none). */
4150
+ snapshot() {
4151
+ const w = this.world;
4152
+ if (!w || !w.laneIds().length) return null;
4153
+ return w.snapshot();
4154
+ }
4155
+ /** Puts a snapshot back (`null`: no wet layers). Returns the layer surfaces it implies. */
4156
+ restore(snap) {
4157
+ if (!snap) {
4158
+ if (this.world) for (const id of this.world.laneIds()) this.world.removeLane(id);
4159
+ return;
4160
+ }
4161
+ const { width, height } = this.host.canvas();
4162
+ if (this.world && (this.world.width !== width || this.world.height !== height)) this.dropWorld();
4163
+ this.ensureWorld().restore(snap);
4164
+ this.syncDisplays();
4165
+ }
4166
+ dropWorld() {
4167
+ _optionalChain([this, 'access', _128 => _128.world, 'optionalAccess', _129 => _129.destroy, 'call', _130 => _130()]);
4168
+ this.world = null;
4169
+ this.driver = null;
4170
+ }
4171
+ /** Forgets everything wet (a new canvas, a resize, opening a document). */
4172
+ reset() {
4173
+ _optionalChain([this, 'access', _131 => _131.world, 'optionalAccess', _132 => _132.destroy, 'call', _133 => _133()]);
4174
+ this.world = null;
4175
+ this.driver = null;
4176
+ this.settings.clear();
4177
+ this.lastTick = null;
4178
+ this.stepsOwed = 0;
4179
+ }
4180
+ /** Water overlay tiles (RGBA) over a document rectangle, for the view. */
4181
+ waterOverlay(rect) {
4182
+ const w = this.world;
4183
+ if (!w) return [];
4184
+ const out = [];
4185
+ const tx0 = Math.max(0, Math.floor(rect.x / _chunk474IQG74cjs.TILE));
4186
+ const ty0 = Math.max(0, Math.floor(rect.y / _chunk474IQG74cjs.TILE));
4187
+ const tx1 = Math.floor((rect.x + rect.width - 1) / _chunk474IQG74cjs.TILE);
4188
+ const ty1 = Math.floor((rect.y + rect.height - 1) / _chunk474IQG74cjs.TILE);
4189
+ for (let ty = ty0; ty <= ty1; ty++)
4190
+ for (let tx = tx0; tx <= tx1; tx++) {
4191
+ let merged = null;
4192
+ for (const id of w.laneIds()) {
4193
+ const t = w.waterOverlay(id, tx, ty);
4194
+ if (!t) continue;
4195
+ if (!merged) merged = t;
4196
+ else for (let i = 3; i < t.length; i += 4) merged[i] = Math.max(merged[i], t[i]);
4197
+ }
4198
+ if (merged) out.push({ tx, ty, data: merged });
4199
+ }
4200
+ return out;
4201
+ }
4202
+ destroy() {
4203
+ _optionalChain([this, 'access', _134 => _134.world, 'optionalAccess', _135 => _135.destroy, 'call', _136 => _136()]);
4204
+ this.world = null;
4205
+ _optionalChain([this, 'access', _137 => _137.gpu, 'optionalAccess', _138 => _138.destroy, 'call', _139 => _139()]);
4206
+ this.gpu = null;
4207
+ }
4208
+ }, _class6);
4209
+ function wetPigmentOf(hex, body) {
4210
+ const [r, g, b] = hexToRgb8(hex);
4211
+ return Array.from(_chunkJ5VQYK7Tcjs.pigmentOf.call(void 0, [r / 255, g / 255, b / 255], body));
4212
+ }
4213
+
4214
+ // src/vector/brushstrokeMedia.ts
4215
+ var VECTOR_WET_STEPS = 120;
4216
+ function vectorMediaEngine(brush) {
4217
+ if (brush.engine === "wet") return brush.wet.tool === "paint" ? "wet" : null;
4218
+ return brush.engine === "mixer" || brush.engine === "smudge" || brush.engine === "blender" ? brush.engine : null;
4219
+ }
4220
+ var usesVectorBackdrop = (engine) => engine === "mixer" || engine === "smudge" || engine === "blender";
4221
+ var finite2 = (v2) => typeof v2 === "number" && Number.isFinite(v2);
4222
+ function place(input, brush, options, pad = 0) {
4223
+ const samples = _chunkPXDIAYB6cjs.brushstrokeSamples.call(void 0, input);
4224
+ if (!samples.length) return null;
4225
+ for (const s of samples) if (!finite2(s.x) || !finite2(s.y)) throw new Error("Brushstroke samples need finite x and y.");
4226
+ let scale3 = finite2(options.scale) && options.scale > 0 ? Math.min(_chunkYQGCPL5Xcjs.BRUSHSTROKE_MAX_SCALE, Math.max(_chunkYQGCPL5Xcjs.BRUSHSTROKE_MIN_SCALE, options.scale)) : 1;
4227
+ let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
4228
+ for (const s of samples) {
4229
+ x0 = Math.min(x0, s.x);
4230
+ y0 = Math.min(y0, s.y);
4231
+ x1 = Math.max(x1, s.x);
4232
+ y1 = Math.max(y1, s.y);
4233
+ }
4234
+ const reach = brush.tip.size * (1 + 1.5 * brush.dynamics.tiltSize) / 2 + 2 + pad;
4235
+ const maxPixels = finite2(options.maxPixels) && options.maxPixels > 0 ? options.maxPixels : 4096 * 4096;
4236
+ const area = (x1 - x0 + 2 * reach) * (y1 - y0 + 2 * reach);
4237
+ if (area * scale3 * scale3 > maxPixels) scale3 = Math.max(_chunkYQGCPL5Xcjs.BRUSHSTROKE_MIN_SCALE, Math.sqrt(maxPixels / area));
4238
+ const rect = { x: Math.floor((x0 - reach) * scale3), y: Math.floor((y0 - reach) * scale3), width: 0, height: 0 };
4239
+ rect.width = Math.max(1, Math.ceil((x1 + reach) * scale3) - rect.x);
4240
+ rect.height = Math.max(1, Math.ceil((y1 + reach) * scale3) - rect.y);
4241
+ const points = samples.map((s) => ({ ...s, x: s.x * scale3 - rect.x, y: s.y * scale3 - rect.y }));
4242
+ if (options.closed && points.length > 2) points.push({ ...points[0] });
4243
+ const sized = { ...brush, pressureSmoothing: 0, tip: { ...brush.tip, size: brush.tip.size * scale3, smoothing: 0 } };
4244
+ const [r, g, b, a] = options.color;
4245
+ const hex = "#" + [r, g, b].map((v2) => Math.round(Math.min(255, Math.max(0, v2))).toString(16).padStart(2, "0")).join("");
4246
+ const source = _nullishCoalesce(options.paint, () => ( null));
4247
+ const paint = _optionalChain([source, 'optionalAccess', _140 => _140.type]) === "gradient" ? _chunkFQPUF2W2cjs.resolvePaintGradient.call(void 0, _chunkFQPUF2W2cjs.scalePaintGradient.call(void 0, source, scale3), { paint: hex, secondary: "#ffffff" }) : null;
4248
+ const color2 = _optionalChain([source, 'optionalAccess', _141 => _141.type]) === "color" ? hexRgb(source.color) : [r / 255, g / 255, b / 255];
4249
+ return { points, brush: sized, rect, scale: scale3, color: color2, alpha: Math.min(1, Math.max(0, a / 255)), paint };
4250
+ }
4251
+ function hexRgb(hex) {
4252
+ const n = parseInt(hex.slice(1), 16);
4253
+ return [(n >> 16 & 255) / 255, (n >> 8 & 255) / 255, (n & 255) / 255];
4254
+ }
4255
+ var EMPTY = { image: { width: 0, height: 0, data: new Uint8ClampedArray(0) }, bounds: null, scale: 1, dabs: 0 };
4256
+ function cropped(data, placed, dabs, keep) {
4257
+ const { width: w, height: h } = placed.rect;
4258
+ let cx0 = w, cy0 = h, cx1 = -1, cy1 = -1;
4259
+ for (let y = 0; y < h; y++) {
4260
+ for (let x = 0; x < w; x++) {
4261
+ const i = (y * w + x) * 4;
4262
+ if (keep ? !keep(i) : data[i + 3] === 0) continue;
4263
+ if (x < cx0) cx0 = x;
4264
+ if (x > cx1) cx1 = x;
4265
+ if (y < cy0) cy0 = y;
4266
+ if (y > cy1) cy1 = y;
4267
+ }
4268
+ }
4269
+ if (cx1 < 0) return { ...EMPTY, scale: placed.scale, dabs };
4270
+ const cw = cx1 - cx0 + 1;
4271
+ const ch = cy1 - cy0 + 1;
4272
+ const out = new Uint8ClampedArray(cw * ch * 4);
4273
+ for (let y = 0; y < ch; y++) {
4274
+ for (let x = 0; x < cw; x++) {
4275
+ const i = ((y + cy0) * w + x + cx0) * 4;
4276
+ if (keep && !keep(i)) continue;
4277
+ const o = (y * cw + x) * 4;
4278
+ out[o] = data[i];
4279
+ out[o + 1] = data[i + 1];
4280
+ out[o + 2] = data[i + 2];
4281
+ out[o + 3] = placed.alpha < 1 ? Math.round(data[i + 3] * placed.alpha) : data[i + 3];
4282
+ }
4283
+ }
4284
+ const s = placed.scale;
4285
+ return { image: { width: cw, height: ch, data: out }, bounds: { x: (placed.rect.x + cx0) / s, y: (placed.rect.y + cy0) / s, width: cw / s, height: ch / s }, scale: s, dabs };
4286
+ }
4287
+ var WetBrushstrokeJob = (_class7 = class {
4288
+ constructor(input, brush, options, steps = VECTOR_WET_STEPS) {;_class7.prototype.__init57.call(this);_class7.prototype.__init58.call(this);
4289
+ this.steps = steps;
4290
+ if (vectorMediaEngine(brush) !== "wet") throw new Error(`'${brush.name}' is not a wet paint brush.`);
4291
+ this.placed = place(input, brush, options, brush.tip.size * 0.25);
4292
+ if (!this.placed) {
4293
+ this.world = null;
4294
+ this.dabs = 0;
4295
+ this.final = EMPTY;
4296
+ return;
4297
+ }
4298
+ const { rect, points } = this.placed;
4299
+ this.world = new (0, _chunkJ5VQYK7Tcjs.WetWorld)(rect.width, rect.height, wetPaperInput(DEFAULT_PAPER), { kernel: "typescript", threads: 0 });
4300
+ const medium = _nullishCoalesce(this.placed.brush.wet.medium, () => ( "watercolor"));
4301
+ this.world.ensureLane("s", { params: _nullishCoalesce(WET_MEDIUM_PARAMS[medium], () => ( {})) });
4302
+ const color2 = this.placed.color;
4303
+ const driver = new WetStrokeDriver({
4304
+ world: this.world,
4305
+ laneId: "s",
4306
+ brush: this.placed.brush,
4307
+ color: color2,
4308
+ load: { reservoir: [...color2], amount: 1, pickup: null },
4309
+ grain: null,
4310
+ paperDepth: 0,
4311
+ paperColor: [255, 255, 255],
4312
+ seed: _nullishCoalesce(options.seed, () => ( 0)),
4313
+ copies: [],
4314
+ paint: this.placed.paint
4315
+ });
4316
+ driver.push(points);
4317
+ driver.finish();
4318
+ this.dabs = driver.dabCount;
4319
+ }
4320
+
4321
+
4322
+
4323
+
4324
+ __init57() {this.done = 0}
4325
+ __init58() {this.final = null}
4326
+ /** Steps run so far. */
4327
+ get progress() {
4328
+ return this.done;
4329
+ }
4330
+ get finished() {
4331
+ return this.final !== null;
4332
+ }
4333
+ /** Runs steps until `budgetMs` has passed (at least one) or all have run. Returns whether it is finished. */
4334
+ run(budgetMs = Infinity) {
4335
+ if (this.final || !this.world) return true;
4336
+ const start = Date.now();
4337
+ while (this.done < this.steps) {
4338
+ this.world.stepSync(1);
4339
+ this.done++;
4340
+ if (Date.now() - start >= budgetMs) break;
4341
+ }
4342
+ if (this.done >= this.steps) {
4343
+ this.final = this.bake();
4344
+ this.destroy();
4345
+ }
4346
+ return this.final !== null;
4347
+ }
4348
+ /** The paint dried where it is now (step 0: as laid). */
4349
+ image() {
4350
+ return _nullishCoalesce(this.final, () => ( this.bake()));
4351
+ }
4352
+ /** The settled image: runs the remaining steps now. */
4353
+ settled() {
4354
+ this.run();
4355
+ return this.final;
4356
+ }
4357
+ destroy() {
4358
+ _optionalChain([this, 'access', _142 => _142.world, 'optionalAccess', _143 => _143.destroy, 'call', _144 => _144()]);
4359
+ }
4360
+ bake() {
4361
+ if (!this.world || !this.placed) return EMPTY;
4362
+ const { width, height } = this.placed.rect;
4363
+ const data = _chunk474IQG74cjs.readRegion.call(void 0, this.world.bakedSurface("s"), { x: 0, y: 0, width, height });
4364
+ return cropped(data, this.placed, this.dabs);
4365
+ }
4366
+ }, _class7);
4367
+ function renderWetBrushstroke(input, brush, options) {
4368
+ return new WetBrushstrokeJob(input, brush, options).settled();
4369
+ }
4370
+ function vectorBackdropRect(input, brush, options) {
4371
+ const placed = place(input, brush, options);
4372
+ return placed ? { rect: placed.rect, scale: placed.scale } : null;
4373
+ }
4374
+ function renderBackdropBrushstroke(input, brush, options) {
4375
+ const engine = vectorMediaEngine(brush);
4376
+ if (!usesVectorBackdrop(engine)) throw new Error(`'${brush.name}' is not a Mixer Brush, smudge or blender.`);
4377
+ const placed = place(input, brush, options);
4378
+ if (!placed) return EMPTY;
4379
+ const { rect } = placed;
4380
+ const area = { x: 0, y: 0, width: rect.width, height: rect.height };
4381
+ const before = options.backdrop ? options.backdrop(rect, placed.scale) : new Uint8ClampedArray(rect.width * rect.height * 4);
4382
+ if (before.length !== rect.width * rect.height * 4) throw new Error(`The backdrop must be ${rect.width}\xD7${rect.height} RGBA pixels.`);
4383
+ const cached = _optionalChain([options, 'access', _145 => _145.cache, 'optionalCall', _146 => _146(before)]);
4384
+ const hit = _optionalChain([cached, 'optionalAccess', _147 => _147.get, 'call', _148 => _148()]);
4385
+ if (hit) return hit;
4386
+ const base = _chunk474IQG74cjs.writeRegion.call(void 0, _chunk474IQG74cjs.emptySurface.call(void 0, 4), area, before);
4387
+ const live = /* @__PURE__ */ new Map();
4388
+ const target = {
4389
+ offset: { x: 0, y: 0 },
4390
+ lockTransparency: false,
4391
+ selection: null,
4392
+ readTile: (tx, ty) => _nullishCoalesce(_nullishCoalesce(live.get(_chunk474IQG74cjs.tileKey.call(void 0, tx, ty)), () => ( _optionalChain([base, 'access', _149 => _149.tiles, 'access', _150 => _150.get, 'call', _151 => _151(_chunk474IQG74cjs.tileKey.call(void 0, tx, ty)), 'optionalAccess', _152 => _152.data]))), () => ( null)),
4393
+ writeTile: (tx, ty) => {
4394
+ const key = _chunk474IQG74cjs.tileKey.call(void 0, tx, ty);
4395
+ let t = live.get(key);
4396
+ if (!t) live.set(key, t = base.tiles.get(key) ? new Uint8ClampedArray(base.tiles.get(key).data) : new Uint8ClampedArray(_chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE * 4));
4397
+ return t;
4398
+ }
4399
+ };
4400
+ const color2 = placed.color;
4401
+ const load = placed.brush.engine === "mixer" && placed.brush.loadsColor ? _chunkFQPUF2W2cjs.loadMixer.call(void 0, _chunkFQPUF2W2cjs.EMPTY_MIXER_LOAD, color2) : _chunkFQPUF2W2cjs.EMPTY_MIXER_LOAD;
4402
+ const stroke = new PaintDabStroke(placed.brush, { target, color: color2, secondary: [1, 1, 1], load, grain: null, paperDepth: 0, seed: _nullishCoalesce(options.seed, () => ( 0)), paint: placed.paint });
4403
+ stroke.push(placed.points);
4404
+ stroke.finish();
4405
+ const after = new Uint8ClampedArray(rect.width * rect.height * 4);
4406
+ const tiles = new Map(base.tiles);
4407
+ for (const [key, data] of live) tiles.set(key, { data, uniform: null });
4408
+ _chunk474IQG74cjs.readRegion.call(void 0, new (0, _chunk474IQG74cjs.TiledSurface)(4, tiles), area, after);
4409
+ const result = cropped(after, placed, stroke.dabCount, (i) => after[i] !== before[i] || after[i + 1] !== before[i + 1] || after[i + 2] !== before[i + 2] || after[i + 3] !== before[i + 3]);
4410
+ _optionalChain([cached, 'optionalAccess', _153 => _153.set, 'call', _154 => _154(result)]);
4411
+ return result;
4412
+ }
4413
+
2537
4414
  // src/vector/brushstroke.ts
2538
4415
  var VECTOR_BRUSHSTROKE_SCALE = 2;
2539
- var PRESETS = _chunkRFJZGTHAcjs.listPresets.call(void 0, _chunkRFJZGTHAcjs.VECTOR_PROFILE).map((spec) => _chunkRFJZGTHAcjs.BUILTIN_BRUSHES.find((b) => b.id === spec.id));
4416
+ var PRESETS = _chunkXVOP3CGQcjs.listPresets.call(void 0, _chunkXVOP3CGQcjs.VECTOR_PROFILE).map((spec) => _chunkXVOP3CGQcjs.BUILTIN_BRUSHES.find((b) => b.id === spec.id));
2540
4417
  function admitted(spec) {
2541
4418
  try {
2542
- const brush = _chunkRFJZGTHAcjs.normalizeBrushSpec.call(void 0, spec);
2543
- return _chunkRFJZGTHAcjs.checkBrush.call(void 0, brush, _chunkRFJZGTHAcjs.VECTOR_PROFILE).ok && _chunkPXDIAYB6cjs.isBrushstrokeBrush.call(void 0, _chunkRFJZGTHAcjs.resolveBrush.call(void 0, brush)) ? brush : null;
2544
- } catch (e4) {
4419
+ const brush = _chunkXVOP3CGQcjs.normalizeBrushSpec.call(void 0, spec);
4420
+ return _chunkXVOP3CGQcjs.checkBrush.call(void 0, brush, _chunkXVOP3CGQcjs.VECTOR_PROFILE).ok && isVectorBrushstrokeEngine(_chunkXVOP3CGQcjs.resolveBrush.call(void 0, brush)) ? brush : null;
4421
+ } catch (e6) {
2545
4422
  return null;
2546
4423
  }
2547
4424
  }
4425
+ function isVectorBrushstrokeEngine(brush) {
4426
+ return brush.engine === "dab" && _chunkPXDIAYB6cjs.isBrushstrokeBrush.call(void 0, brush) || vectorMediaEngine(brush) !== null;
4427
+ }
2548
4428
  function vectorBrushstrokeBrushes(user = []) {
2549
4429
  const out = [...PRESETS];
2550
4430
  for (const raw of user) {
2551
4431
  const brush = admitted(raw);
2552
- if (brush && !out.some((b) => b.id === brush.id)) out.push(_chunkRFJZGTHAcjs.resolveBrush.call(void 0, brush));
4432
+ if (brush && !out.some((b) => b.id === brush.id)) out.push(_chunkXVOP3CGQcjs.resolveBrush.call(void 0, brush));
2553
4433
  }
2554
4434
  return out;
2555
4435
  }
@@ -2559,7 +4439,7 @@ function vectorBrushstrokeBrush(id) {
2559
4439
  function vectorBrushstrokeBrushOf(brush) {
2560
4440
  if (brush.spec) {
2561
4441
  const saved = admitted(brush.spec);
2562
- return saved && saved.id === brush.brushId ? _chunkRFJZGTHAcjs.resolveBrush.call(void 0, saved) : null;
4442
+ return saved && saved.id === brush.brushId ? _chunkXVOP3CGQcjs.resolveBrush.call(void 0, saved) : null;
2563
4443
  }
2564
4444
  return vectorBrushstrokeBrush(brush.brushId);
2565
4445
  }
@@ -2567,15 +4447,15 @@ function vectorBrushstrokeBrushError(id, user = []) {
2567
4447
  if (vectorBrushstrokeBrush(id)) return null;
2568
4448
  const saved = user.find((b) => b.id === id);
2569
4449
  const ids = vectorBrushstrokeBrushes(user).map((b) => b.id);
2570
- const reasons = (b) => _chunkRFJZGTHAcjs.checkBrush.call(void 0, b, _chunkRFJZGTHAcjs.VECTOR_PROFILE).issues.filter((i) => i.severity === "error").map((i) => `${i.reason} ${i.fix}`).join(" ") || "it is not a dry dab brush.";
4450
+ const reasons = (b) => _chunkXVOP3CGQcjs.checkBrush.call(void 0, b, _chunkXVOP3CGQcjs.VECTOR_PROFILE).issues.filter((i) => i.severity === "error").map((i) => `${i.reason} ${i.fix}`).join(" ") || "its engine does not paint brushstrokes.";
2571
4451
  if (saved) return admitted(saved) ? null : `Brush "${id}" (${saved.name}) can't paint a brushstroke: ${reasons(saved)} Use one of: ${ids.join(", ")}.`;
2572
- const preset = _chunkRFJZGTHAcjs.BRUSH_PRESETS.find((b) => b.id === id);
2573
- if (preset) return `Brush "${id}" (${preset.name}) can't paint a brushstroke: ${reasons(preset)} Use one of: ${ids.join(", ")}.`;
2574
- return `Unknown brush "${id}". ${_chunkRFJZGTHAcjs.closest.call(void 0, id, ids)}Use one of: ${ids.join(", ")} (vector.listBrushes lists them).`;
4452
+ const preset2 = _chunkXVOP3CGQcjs.BRUSH_PRESETS.find((b) => b.id === id);
4453
+ if (preset2) return `Brush "${id}" (${preset2.name}) can't paint a brushstroke: ${reasons(preset2)} Use one of: ${ids.join(", ")}.`;
4454
+ return `Unknown brush "${id}". ${_chunkXVOP3CGQcjs.closest.call(void 0, id, ids)}Use one of: ${ids.join(", ")} (vector.listBrushes lists them).`;
2575
4455
  }
2576
4456
  function vectorBrushstrokeDefaultColour(id, user = [], scheme = "light") {
2577
- const brush = _nullishCoalesce(_chunkRFJZGTHAcjs.BRUSH_PRESETS.find((b) => b.id === id), () => ( user.find((b) => b.id === id)));
2578
- return brush ? _chunkJBZRVLXVcjs.brushColourHex.call(void 0, _optionalChain([brush, 'access', _55 => _55.colour, 'optionalAccess', _56 => _56.default]), scheme) : null;
4457
+ const brush = _nullishCoalesce(_chunkXVOP3CGQcjs.BRUSH_PRESETS.find((b) => b.id === id), () => ( user.find((b) => b.id === id)));
4458
+ return brush ? _chunkJBZRVLXVcjs.brushColourHex.call(void 0, _optionalChain([brush, 'access', _155 => _155.colour, 'optionalAccess', _156 => _156.default]), scheme) : null;
2579
4459
  }
2580
4460
  function sanitizeVectorBrushstroke(value, user = []) {
2581
4461
  if (!value || typeof value !== "object") return null;
@@ -2594,6 +4474,8 @@ function sanitizeVectorBrushstroke(value, user = []) {
2594
4474
  }
2595
4475
  const seed = sanitizeSeed(r.seed);
2596
4476
  if (seed !== void 0) out.seed = seed;
4477
+ const paint = readVectorBrushstrokePaint(r.paint);
4478
+ if (paint) out.paint = paint;
2597
4479
  if (r.paper === null) out.paper = null;
2598
4480
  else {
2599
4481
  const paper = sanitizeVectorBrushstrokePaper(r.paper);
@@ -2601,9 +4483,24 @@ function sanitizeVectorBrushstroke(value, user = []) {
2601
4483
  }
2602
4484
  return out;
2603
4485
  }
4486
+ var TIMED_MAPPINGS = ["velocity", "time"];
4487
+ function vectorBrushstrokePaintError(paint) {
4488
+ let source;
4489
+ try {
4490
+ source = _chunkFQPUF2W2cjs.parsePaintSource.call(void 0, paint, "paint");
4491
+ } catch (e) {
4492
+ return e.message;
4493
+ }
4494
+ if (source.type === "gradient" && TIMED_MAPPINGS.includes(source.map.by)) return `paint.map.by "${source.map.by}" needs timed samples, which vector paths do not have; use distance, pressure, tilt, direction, across-tip or random.`;
4495
+ return null;
4496
+ }
4497
+ function readVectorBrushstrokePaint(value) {
4498
+ if (value === void 0 || value === null || vectorBrushstrokePaintError(value)) return null;
4499
+ return _chunkFQPUF2W2cjs.readPaintSource.call(void 0, value);
4500
+ }
2604
4501
  var VECTOR_BRUSHSTROKE_MAX_SEED = 2147483647;
2605
- var finite2 = (v2) => typeof v2 === "number" && Number.isFinite(v2);
2606
- var sanitizeSeed = (v2) => finite2(v2) ? Math.min(VECTOR_BRUSHSTROKE_MAX_SEED, Math.max(0, Math.round(v2))) : void 0;
4502
+ var finite3 = (v2) => typeof v2 === "number" && Number.isFinite(v2);
4503
+ var sanitizeSeed = (v2) => finite3(v2) ? Math.min(VECTOR_BRUSHSTROKE_MAX_SEED, Math.max(0, Math.round(v2))) : void 0;
2607
4504
  function sanitizeVectorBrushstrokePaper(value) {
2608
4505
  if (!value || typeof value !== "object") return null;
2609
4506
  const r = value;
@@ -2611,8 +4508,8 @@ function sanitizeVectorBrushstrokePaper(value) {
2611
4508
  if (typeof r.pattern === "string" && _chunkPXDIAYB6cjs.GRAIN_PATTERNS.includes(r.pattern)) out.pattern = r.pattern;
2612
4509
  const seed = sanitizeSeed(r.seed);
2613
4510
  if (seed !== void 0) out.seed = seed;
2614
- if (finite2(r.scale) && r.scale > 0) out.scale = Math.min(8, Math.max(0.25, r.scale));
2615
- if (finite2(r.depth)) out.depth = Math.min(1, Math.max(0, r.depth));
4511
+ if (finite3(r.scale) && r.scale > 0) out.scale = Math.min(8, Math.max(0.25, r.scale));
4512
+ if (finite3(r.depth)) out.depth = Math.min(1, Math.max(0, r.depth));
2616
4513
  return Object.keys(out).length ? out : null;
2617
4514
  }
2618
4515
  function vectorBrushstrokeCharacterError(brush) {
@@ -2625,8 +4522,8 @@ function vectorBrushstrokeCharacterError(brush) {
2625
4522
  if (extra.length) return `paper has unknown field ${extra.map((k) => `"${k}"`).join(", ")}: use pattern, seed, scale, depth.`;
2626
4523
  if (r.pattern !== void 0 && !_chunkPXDIAYB6cjs.GRAIN_PATTERNS.includes(r.pattern)) return `Unknown paper pattern "${String(r.pattern)}": use one of ${_chunkPXDIAYB6cjs.GRAIN_PATTERNS.join(", ")}.`;
2627
4524
  if (r.seed !== void 0 && !(Number.isInteger(r.seed) && r.seed >= 0 && r.seed <= VECTOR_BRUSHSTROKE_MAX_SEED)) return `paper.seed must be an integer from 0 to ${VECTOR_BRUSHSTROKE_MAX_SEED}.`;
2628
- if (r.scale !== void 0 && !(finite2(r.scale) && r.scale >= 0.25 && r.scale <= 8)) return "paper.scale must be from 0.25 to 8 (1 is the pattern's natural size).";
2629
- if (r.depth !== void 0 && !(finite2(r.depth) && r.depth >= 0 && r.depth <= 1)) return "paper.depth must be from 0 to 1.";
4525
+ if (r.scale !== void 0 && !(finite3(r.scale) && r.scale >= 0.25 && r.scale <= 8)) return "paper.scale must be from 0.25 to 8 (1 is the pattern's natural size).";
4526
+ if (r.depth !== void 0 && !(finite3(r.depth) && r.depth >= 0 && r.depth <= 1)) return "paper.depth must be from 0 to 1.";
2630
4527
  return null;
2631
4528
  }
2632
4529
  function randomVectorBrushstrokeSeed() {
@@ -2639,29 +4536,240 @@ function vectorBrushstrokeReach(layer) {
2639
4536
  if (!isVectorBrushstrokeLayer(layer)) return 0;
2640
4537
  return (_nullishCoalesce(layer.brush.size, () => ( vectorBrushstrokeBrushOf(layer.brush).tip.size))) / 2;
2641
4538
  }
4539
+ var backdropSource = null;
4540
+ function setVectorBackdropSource(source) {
4541
+ backdropSource = source;
4542
+ }
4543
+ var hex22 = (v2) => Math.round(Math.min(1, Math.max(0, v2)) * 255).toString(16).padStart(2, "0");
4544
+ function gradientPaint(g, map) {
4545
+ const stops = sortedVectorGradientStops(g);
4546
+ const exact2 = stops.length >= 2 && stops.length <= 16 && !g.smoothness && (_nullishCoalesce(g.interpolation, () => ( "srgb"))) === "srgb" && stops.every((s) => parseVectorColor(s.color));
4547
+ if (exact2) {
4548
+ return {
4549
+ type: "gradient",
4550
+ space: "srgb",
4551
+ map,
4552
+ stops: stops.map((s) => {
4553
+ const c = parseVectorColor(s.color);
4554
+ const opacity = Math.min(1, Math.max(0, (_nullishCoalesce(s.opacity, () => ( 1))) * c[3]));
4555
+ const midpoint = s.midpoint !== void 0 && s.midpoint !== 0.5 ? Math.min(0.95, Math.max(0.05, s.midpoint)) : void 0;
4556
+ return { offset: Math.min(1, Math.max(0, s.offset)), color: `#${hex22(c[0])}${hex22(c[1])}${hex22(c[2])}`, ...opacity < 1 ? { opacity } : {}, ...midpoint !== void 0 ? { midpoint } : {} };
4557
+ })
4558
+ };
4559
+ }
4560
+ const ramp = vectorGradientRamp(g);
4561
+ const n = 16;
4562
+ return {
4563
+ type: "gradient",
4564
+ space: "srgb",
4565
+ map,
4566
+ stops: Array.from({ length: n }, (_, i) => {
4567
+ const t = i / (n - 1);
4568
+ const c = ramp ? ramp.sample(t) : [0, 0, 0, 1];
4569
+ return { offset: t, color: `#${hex22(c[0])}${hex22(c[1])}${hex22(c[2])}`, ...c[3] < 1 ? { opacity: Math.max(0, c[3]) } : {} };
4570
+ })
4571
+ };
4572
+ }
4573
+ var REPEAT = { pad: "clamp", repeat: "repeat", reflect: "mirror" };
4574
+ function strokePaintOf(node, layer, brush, length2) {
4575
+ const engine = vectorMediaEngine(brush);
4576
+ if (engine === "smudge" || engine === "blender") return { color: [0, 0, 0, 255], paint: null, within: null };
4577
+ const solid = _nullishCoalesce(vectorPaintSolid(layer.paint), () => ( "#000000"));
4578
+ const c = _nullishCoalesce(parseVectorColor(solid), () => ( [0, 0, 0, 1]));
4579
+ const color2 = [c[0] * 255, c[1] * 255, c[2] * 255, c[3] * 255].map(Math.round);
4580
+ if (layer.brush.paint) return { color: color2, paint: layer.brush.paint, within: null };
4581
+ const g = layer.paint;
4582
+ if (isVectorGradient(g) && _optionalChain([g, 'access', _157 => _157.stops, 'optionalAccess', _158 => _158.length])) {
4583
+ const mode = _nullishCoalesce(g.strokeMode, () => ( "within"));
4584
+ if (mode === "along") return { color: [color2[0], color2[1], color2[2], 255], paint: gradientPaint(g, { by: "distance", length: Math.max(1, length2), repeat: REPEAT[_nullishCoalesce(g.spread, () => ( "pad"))], unit: "px" }), within: null };
4585
+ if (mode === "across") return { color: [color2[0], color2[1], color2[2], 255], paint: gradientPaint(g, { by: "across-tip" }), within: null };
4586
+ if (engine === "mixer") return { color: [color2[0], color2[1], color2[2], 255], paint: gradientPaint(g, { by: "distance", length: Math.max(1, length2), repeat: REPEAT[_nullishCoalesce(g.spread, () => ( "pad"))] }), within: null };
4587
+ const b = _chunkGF2RBSDMcjs.bezierPathBounds.call(void 0, subpathsToBezier(node.subpaths));
4588
+ return { color: [255, 255, 255, 255], paint: null, within: { gradient: g, bounds: b ? { x: b.minX, y: b.minY, width: b.maxX - b.minX, height: b.maxY - b.minY } : null } };
4589
+ }
4590
+ if (brush.paint && !TIMED_MAPPINGS.includes(brush.paint.map.by)) return { color: color2, paint: brush.paint, within: null };
4591
+ return { color: color2, paint: null, within: null };
4592
+ }
4593
+ function recoloured(stroke, within) {
4594
+ if (!stroke.bounds) return stroke;
4595
+ const ramp = vectorGradientRamp(within.gradient);
4596
+ if (!ramp) return stroke;
4597
+ const lut = Array.from({ length: 256 }, (_, i) => ramp.sample(i / 255));
4598
+ const { width, height, data } = stroke.image;
4599
+ const out = new Uint8ClampedArray(data);
4600
+ const { x: bx, y: by } = stroke.bounds;
4601
+ const s = stroke.scale;
4602
+ for (let y = 0; y < height; y++) {
4603
+ for (let x = 0; x < width; x++) {
4604
+ const i = (y * width + x) * 4;
4605
+ if (!out[i + 3]) continue;
4606
+ const t = vectorGradientTAt(within.gradient, within.bounds, { x: bx + (x + 0.5) / s, y: by + (y + 0.5) / s });
4607
+ const col = lut[Math.round(Math.min(1, Math.max(0, t)) * 255)];
4608
+ out[i] = Math.round(out[i] * col[0]);
4609
+ out[i + 1] = Math.round(out[i + 1] * col[1]);
4610
+ out[i + 2] = Math.round(out[i + 2] * col[2]);
4611
+ out[i + 3] = Math.round(out[i + 3] * col[3]);
4612
+ }
4613
+ }
4614
+ return { ...stroke, image: { width, height, data: out } };
4615
+ }
4616
+ function hash(s, h = 2166136261) {
4617
+ for (let i = 0; i < s.length; i++) {
4618
+ h ^= s.charCodeAt(i);
4619
+ h = Math.imul(h, 16777619) >>> 0;
4620
+ }
4621
+ return h;
4622
+ }
4623
+ function hashBytes(b, h = 2166136261) {
4624
+ for (let i = 0; i < b.length; i++) {
4625
+ h ^= b[i];
4626
+ h = Math.imul(h, 16777619) >>> 0;
4627
+ }
4628
+ return h;
4629
+ }
4630
+ function mediaKey(input, brush, options) {
4631
+ const path = JSON.stringify(input);
4632
+ return `${hash(path).toString(16)}:${path.length}:${hash(JSON.stringify([brush, options])).toString(16)}`;
4633
+ }
4634
+ var Lru = (_class8 = class {
4635
+ constructor(capacity) {;_class8.prototype.__init59.call(this);
4636
+ this.capacity = capacity;
4637
+ }
4638
+
4639
+ __init59() {this.map = /* @__PURE__ */ new Map()}
4640
+ get(key) {
4641
+ const v2 = this.map.get(key);
4642
+ if (v2 !== void 0) {
4643
+ this.map.delete(key);
4644
+ this.map.set(key, v2);
4645
+ }
4646
+ return v2;
4647
+ }
4648
+ has(key) {
4649
+ return this.map.has(key);
4650
+ }
4651
+ set(key, value) {
4652
+ this.map.delete(key);
4653
+ this.map.set(key, value);
4654
+ while (this.map.size > this.capacity) this.map.delete(this.map.keys().next().value);
4655
+ }
4656
+ }, _class8);
4657
+ var WET_SLICE_MS = 12;
4658
+ var wetSettled = new Lru(128);
4659
+ var wetInstant = /* @__PURE__ */ new Map();
4660
+ var wetJobs = /* @__PURE__ */ new Map();
4661
+ var settleListeners = /* @__PURE__ */ new Set();
4662
+ var wetTimer = null;
4663
+ var wetGeneration = 0;
4664
+ function wetFinished(key, job) {
4665
+ wetGeneration++;
4666
+ wetSettled.set(key, job.image());
4667
+ wetJobs.delete(key);
4668
+ wetInstant.delete(key);
4669
+ }
4670
+ function notifySettled() {
4671
+ for (const fn of [...settleListeners]) fn();
4672
+ }
4673
+ function scheduleWet() {
4674
+ if (wetTimer || !wetJobs.size) return;
4675
+ wetTimer = setTimeout(() => {
4676
+ wetTimer = null;
4677
+ const first = wetJobs.entries().next().value;
4678
+ if (first && first[1].run(WET_SLICE_MS)) {
4679
+ wetFinished(first[0], first[1]);
4680
+ notifySettled();
4681
+ }
4682
+ scheduleWet();
4683
+ }, 0);
4684
+ }
4685
+ function onVectorBrushstrokesSettled(listener) {
4686
+ settleListeners.add(listener);
4687
+ return () => settleListeners.delete(listener);
4688
+ }
4689
+ function vectorBrushstrokesSettling() {
4690
+ return wetJobs.size;
4691
+ }
4692
+ function settleVectorBrushstrokes() {
4693
+ const n = wetJobs.size;
4694
+ if (!n) return 0;
4695
+ for (const [key, job] of [...wetJobs]) {
4696
+ job.run();
4697
+ wetFinished(key, job);
4698
+ }
4699
+ notifySettled();
4700
+ return n;
4701
+ }
4702
+ function wetImage(input, brush, options, settle, pending) {
4703
+ const key = mediaKey(input, brush, options);
4704
+ const done = wetSettled.get(key);
4705
+ if (done) return done;
4706
+ let job = wetJobs.get(key);
4707
+ if (settle === "now") {
4708
+ job ??= new WetBrushstrokeJob(input, brush, options);
4709
+ job.run();
4710
+ wetFinished(key, job);
4711
+ return wetSettled.get(key);
4712
+ }
4713
+ if (!job) {
4714
+ job = new WetBrushstrokeJob(input, brush, options);
4715
+ wetJobs.set(key, job);
4716
+ wetInstant.set(key, job.image());
4717
+ scheduleWet();
4718
+ }
4719
+ pending.push(key);
4720
+ return _nullishCoalesce(wetInstant.get(key), () => ( job.image()));
4721
+ }
2642
4722
  var cache = new (0, _chunkPXDIAYB6cjs.BrushstrokeCache)(256);
4723
+ var backdropResults = new Lru(64);
2643
4724
  var urls = /* @__PURE__ */ new WeakMap();
2644
4725
  var layerCache = /* @__PURE__ */ new WeakMap();
2645
- function vectorBrushstrokeImages(node, layer) {
4726
+ var sameDeps = (a, b) => a === b || !!a && !!b && a.length === b.length && a.every((v2, i) => v2 === b[i]);
4727
+ function vectorBrushstrokeImages(node, layer, context = {}) {
2646
4728
  if (!isVectorBrushstrokeLayer(layer)) return [];
4729
+ const preset2 = vectorBrushstrokeBrushOf(layer.brush);
4730
+ const engine = vectorMediaEngine(preset2);
4731
+ const settle = _nullishCoalesce(context.settle, () => ( "async"));
4732
+ const document2 = _nullishCoalesce(context.document, () => ( null));
4733
+ const index = (_nullishCoalesce(node.strokes, () => ( []))).indexOf(layer);
4734
+ const source = usesVectorBackdrop(engine) && backdropSource ? backdropSource(document2, node, Math.max(0, index), settle) : null;
4735
+ const deps = source ? [...source.deps, wetGeneration] : null;
2647
4736
  let byLayer = layerCache.get(node);
2648
- const hit = _optionalChain([byLayer, 'optionalAccess', _57 => _57.get, 'call', _58 => _58(layer)]);
2649
- if (hit) return hit;
2650
- const preset = vectorBrushstrokeBrushOf(layer.brush);
2651
- const brush = layer.brush.size ? { ...preset, tip: { ...preset.tip, size: layer.brush.size } } : preset;
2652
- const solid = _nullishCoalesce(vectorPaintSolid(layer.paint), () => ( "#000000"));
2653
- const c = _nullishCoalesce(parseVectorColor(solid), () => ( [0, 0, 0, 1]));
2654
- const color2 = [c[0] * 255, c[1] * 255, c[2] * 255, c[3] * 255].map(Math.round);
4737
+ const hit = _optionalChain([byLayer, 'optionalAccess', _159 => _159.get, 'call', _160 => _160(layer)]);
4738
+ const stale = hit && (hit.pending.length && hit.pending.some((k) => wetSettled.has(k)) || settle === "now" && !hit.settled);
4739
+ if (hit && sameDeps(hit.deps, deps) && !stale) return hit.images;
4740
+ const brush = layer.brush.size ? { ...preset2, tip: { ...preset2.tip, size: layer.brush.size } } : preset2;
2655
4741
  const { seed, paper } = layer.brush;
2656
4742
  const character = seed !== void 0 ? { character: { seed, origin: { x: 0, y: 0 }, unit: 1, ...paper !== void 0 ? { paper } : {} } } : {};
2657
4743
  const out = [];
4744
+ const pending = [];
2658
4745
  for (const sp of node.subpaths) {
2659
4746
  if (sp.anchors.length < 2) continue;
2660
4747
  for (const contour of _chunkGF2RBSDMcjs.pathToContours.call(void 0, subpathsToBezier([sp]))) {
2661
4748
  const ring = _chunkGF2RBSDMcjs.flattenChain.call(void 0, _chunkGF2RBSDMcjs.closeContour.call(void 0, contour, contour.closed), 0.25);
2662
4749
  if (contour.closed && ring.length > 2) ring.push(ring[0]);
2663
4750
  if (ring.length < 2) continue;
2664
- const stroke = cache.render({ points: ring.map(([x, y]) => ({ x, y })), ...layer.brush.pressure ? { pressure: layer.brush.pressure } : {} }, brush, { scale: VECTOR_BRUSHSTROKE_SCALE, color: color2, maxPixels: 2048 * 2048, ...character });
4751
+ let length2 = 0;
4752
+ for (let i = 1; i < ring.length; i++) length2 += Math.hypot(ring[i][0] - ring[i - 1][0], ring[i][1] - ring[i - 1][1]);
4753
+ const input = { points: ring.map(([x, y]) => ({ x, y })), ...layer.brush.pressure ? { pressure: layer.brush.pressure } : {} };
4754
+ const sp2 = strokePaintOf(node, layer, brush, length2);
4755
+ const options = { scale: VECTOR_BRUSHSTROKE_SCALE, color: sp2.color, paint: sp2.paint, seed: _nullishCoalesce(seed, () => ( 0)), maxPixels: 2048 * 2048 };
4756
+ let stroke;
4757
+ if (engine === "wet") stroke = wetImage(input, brush, { ...options, maxPixels: 1024 * 1024 }, settle, pending);
4758
+ else if (engine) {
4759
+ const key = mediaKey(input, brush, options);
4760
+ stroke = renderBackdropBrushstroke(input, brush, {
4761
+ ...options,
4762
+ backdrop: _nullishCoalesce(_optionalChain([source, 'optionalAccess', _161 => _161.backdrop]), () => ( null)),
4763
+ cache: (bytes) => {
4764
+ const k = `${key}:${hashBytes(bytes).toString(16)}`;
4765
+ return { get: () => backdropResults.get(k), set: (img) => backdropResults.set(k, img) };
4766
+ }
4767
+ });
4768
+ } else {
4769
+ const { paint, ...rest } = options;
4770
+ stroke = cache.render(input, brush, { ...rest, ...paint ? { paint } : {}, ...character });
4771
+ }
4772
+ if (sp2.within) stroke = recoloured(stroke, sp2.within);
2665
4773
  if (!stroke.bounds) continue;
2666
4774
  let href = urls.get(stroke);
2667
4775
  if (!href) urls.set(stroke, href = _chunkPXDIAYB6cjs.brushstrokeDataUrl.call(void 0, stroke));
@@ -2669,7 +4777,7 @@ function vectorBrushstrokeImages(node, layer) {
2669
4777
  }
2670
4778
  }
2671
4779
  if (!byLayer) layerCache.set(node, byLayer = /* @__PURE__ */ new Map());
2672
- byLayer.set(layer, out);
4780
+ byLayer.set(layer, { images: out, deps, pending, settled: settle === "now" || !pending.length && !deps });
2673
4781
  return out;
2674
4782
  }
2675
4783
 
@@ -2755,7 +4863,7 @@ function withVectorFills(node, fills) {
2755
4863
  const next = { ...node };
2756
4864
  if (fills.length === 0 || fills.length === 1 && isPlainVectorPaintLayer(fills[0])) {
2757
4865
  delete next.fills;
2758
- next.fill = _nullishCoalesce(_optionalChain([fills, 'access', _59 => _59[0], 'optionalAccess', _60 => _60.paint]), () => ( null));
4866
+ next.fill = _nullishCoalesce(_optionalChain([fills, 'access', _162 => _162[0], 'optionalAccess', _163 => _163.paint]), () => ( null));
2759
4867
  return next;
2760
4868
  }
2761
4869
  next.fills = fills.map((l) => ({ ...l }));
@@ -2780,8 +4888,8 @@ function withVectorStrokes(node, strokes) {
2780
4888
  var json = (v2) => JSON.stringify(_nullishCoalesce(v2, () => ( null)));
2781
4889
  function strokeShorthandDiff(node, top) {
2782
4890
  const out = [];
2783
- if (json(node.stroke) !== json(_optionalChain([top, 'optionalAccess', _61 => _61.paint]))) out.push("stroke");
2784
- for (const key of VECTOR_STROKE_SETTING_KEYS) if (json(node[key]) !== json(_optionalChain([top, 'optionalAccess', _62 => _62[key]]))) out.push(key);
4891
+ if (json(node.stroke) !== json(_optionalChain([top, 'optionalAccess', _164 => _164.paint]))) out.push("stroke");
4892
+ for (const key of VECTOR_STROKE_SETTING_KEYS) if (json(node[key]) !== json(_optionalChain([top, 'optionalAccess', _165 => _165[key]]))) out.push(key);
2785
4893
  return out;
2786
4894
  }
2787
4895
  var checked = /* @__PURE__ */ new WeakSet();
@@ -2798,7 +4906,7 @@ function normalizeVectorPaintStacks(node, prefer = "shorthand") {
2798
4906
  if (Array.isArray(node.fills)) {
2799
4907
  let fills = node.fills;
2800
4908
  const top = fills[fills.length - 1];
2801
- if (prefer === "shorthand" && json(node.fill) !== json(_optionalChain([top, 'optionalAccess', _63 => _63.paint]))) {
4909
+ if (prefer === "shorthand" && json(node.fill) !== json(_optionalChain([top, 'optionalAccess', _166 => _166.paint]))) {
2802
4910
  if (!draws(node.fill)) fills = [];
2803
4911
  else fills = top ? [...fills.slice(0, -1), { ...top, paint: node.fill }] : [{ paint: node.fill }];
2804
4912
  }
@@ -2964,13 +5072,13 @@ function subsOf(path) {
2964
5072
  return _chunkGF2RBSDMcjs.pathToContours.call(void 0, path).map((c) => ({ segs: _chunkGF2RBSDMcjs.closeContour.call(void 0, c).filter((s) => !degenerate(s)).map(raise), closed: c.closed })).filter((s) => s.segs.length > 0);
2965
5073
  }
2966
5074
  var subsToPath = (subs) => _chunkGF2RBSDMcjs.contoursToPath.call(void 0, subs.map((s) => ({ segments: s.segs, closed: s.closed })));
2967
- var unit2 = (x, y) => {
5075
+ var unit3 = (x, y) => {
2968
5076
  const l = Math.hypot(x, y);
2969
5077
  return l > 1e-12 && Number.isFinite(l) ? [x / l, y / l] : null;
2970
5078
  };
2971
5079
  function startTangent(s) {
2972
5080
  for (let i = 1; i < s.length; i++) {
2973
- const u = unit2(s[i][0] - s[0][0], s[i][1] - s[0][1]);
5081
+ const u = unit3(s[i][0] - s[0][0], s[i][1] - s[0][1]);
2974
5082
  if (u) return u;
2975
5083
  }
2976
5084
  return [1, 0];
@@ -2978,7 +5086,7 @@ function startTangent(s) {
2978
5086
  function endTangent(s) {
2979
5087
  const end = s[s.length - 1];
2980
5088
  for (let i = s.length - 2; i >= 0; i--) {
2981
- const u = unit2(end[0] - s[i][0], end[1] - s[i][1]);
5089
+ const u = unit3(end[0] - s[i][0], end[1] - s[i][1]);
2982
5090
  if (u) return u;
2983
5091
  }
2984
5092
  return [1, 0];
@@ -2987,7 +5095,7 @@ function tangentAt(s, t) {
2987
5095
  if (t <= 1e-9) return startTangent(s);
2988
5096
  if (t >= 1 - 1e-9) return endTangent(s);
2989
5097
  const d = _chunkGF2RBSDMcjs.segmentDerivative.call(void 0, s, t);
2990
- return _nullishCoalesce(unit2(d[0], d[1]), () => ( startTangent(s)));
5098
+ return _nullishCoalesce(unit3(d[0], d[1]), () => ( startTangent(s)));
2991
5099
  }
2992
5100
  var perp2 = (v2) => [-v2[1], v2[0]];
2993
5101
  function effectPathLength(path) {
@@ -3014,8 +5122,8 @@ var Measured = class {
3014
5122
  append(sa, sb, out) {
3015
5123
  for (const piece of _chunkGF2RBSDMcjs.trimSegments.call(void 0, this.segs, sa, sb, this.lens)) {
3016
5124
  if (degenerate(piece)) continue;
3017
- const last = _optionalChain([out, 'access', _64 => _64[out.length - 1], 'optionalAccess', _65 => _65.segs]);
3018
- const end = _optionalChain([last, 'optionalAccess', _66 => _66[last.length - 1], 'optionalAccess', _67 => _67.at, 'call', _68 => _68(-1)]);
5125
+ const last = _optionalChain([out, 'access', _167 => _167[out.length - 1], 'optionalAccess', _168 => _168.segs]);
5126
+ const end = _optionalChain([last, 'optionalAccess', _169 => _169[last.length - 1], 'optionalAccess', _170 => _170.at, 'call', _171 => _171(-1)]);
3019
5127
  if (!end || Math.hypot(end[0] - piece[0][0], end[1] - piece[0][1]) > 1e-6) out.push({ segs: [piece], closed: false });
3020
5128
  else last.push(piece);
3021
5129
  }
@@ -3211,7 +5319,7 @@ function resample(sub5, m) {
3211
5319
  let tan = tout;
3212
5320
  if (prev !== null) {
3213
5321
  const tin = endTangent(segs[prev]);
3214
- tan = _nullishCoalesce(unit2(tin[0] + tout[0], tin[1] + tout[1]), () => ( tout));
5322
+ tan = _nullishCoalesce(unit3(tin[0] + tout[0], tin[1] + tout[1]), () => ( tout));
3215
5323
  }
3216
5324
  out.push({ p: segs[j][0], tan, lenPrev: prev === null ? 0 : lens[prev] / m, lenNext: piece });
3217
5325
  } else {
@@ -3269,17 +5377,17 @@ function splitmix(x) {
3269
5377
  z = (z ^ z >> 27n) * 0x94d049bb133111ebn & MASK64;
3270
5378
  return z ^ z >> 31n;
3271
5379
  }
3272
- function hash(seed, idx, t) {
5380
+ function hash3(seed, idx, t) {
3273
5381
  const h = splitmix(splitmix(splitmix(seed) ^ idx) ^ BigInt.asUintN(64, BigInt(t)));
3274
5382
  return Number(h >> 11n) / 2 ** 53 * 2 - 1;
3275
5383
  }
3276
5384
  function noise(seed, idx, t) {
3277
5385
  const i = Math.floor(t);
3278
5386
  const f = t - i;
3279
- const p0 = hash(seed, idx, i - 1);
3280
- const p1 = hash(seed, idx, i);
3281
- const p2 = hash(seed, idx, i + 1);
3282
- const p3 = hash(seed, idx, i + 2);
5387
+ const p0 = hash3(seed, idx, i - 1);
5388
+ const p1 = hash3(seed, idx, i);
5389
+ const p2 = hash3(seed, idx, i + 1);
5390
+ const p3 = hash3(seed, idx, i + 2);
3283
5391
  const v2 = 0.5 * (2 * p1 + (-p0 + p2) * f + (2 * p0 - 5 * p1 + 4 * p2 - p3) * f * f + (-p0 + 3 * p1 - 3 * p2 + p3) * f * f * f);
3284
5392
  return Math.min(1, Math.max(-1, v2));
3285
5393
  }
@@ -3327,9 +5435,9 @@ function vectorRepeaterCopies(r, pivot) {
3327
5435
  for (let i = 0; i < n; i++) {
3328
5436
  const k = i + offset;
3329
5437
  let m = translateMatrix(-pivot.x, -pivot.y);
3330
- m = multiplyMatrices(m, scaleMatrix(Math.pow((_nullishCoalesce(_optionalChain([r, 'access', _69 => _69.scale, 'optionalAccess', _70 => _70.x]), () => ( 100))) / 100, k), Math.pow((_nullishCoalesce(_optionalChain([r, 'access', _71 => _71.scale, 'optionalAccess', _72 => _72.y]), () => ( 100))) / 100, k)));
5438
+ m = multiplyMatrices(m, scaleMatrix(Math.pow((_nullishCoalesce(_optionalChain([r, 'access', _172 => _172.scale, 'optionalAccess', _173 => _173.x]), () => ( 100))) / 100, k), Math.pow((_nullishCoalesce(_optionalChain([r, 'access', _174 => _174.scale, 'optionalAccess', _175 => _175.y]), () => ( 100))) / 100, k)));
3331
5439
  m = multiplyMatrices(m, rotateMatrix((_nullishCoalesce(r.rotation, () => ( 0))) * k));
3332
- m = multiplyMatrices(m, translateMatrix(pivot.x + (_nullishCoalesce(_optionalChain([r, 'access', _73 => _73.position, 'optionalAccess', _74 => _74.x]), () => ( 0))) * k, pivot.y + (_nullishCoalesce(_optionalChain([r, 'access', _75 => _75.position, 'optionalAccess', _76 => _76.y]), () => ( 0))) * k));
5440
+ m = multiplyMatrices(m, translateMatrix(pivot.x + (_nullishCoalesce(_optionalChain([r, 'access', _176 => _176.position, 'optionalAccess', _177 => _177.x]), () => ( 0))) * k, pivot.y + (_nullishCoalesce(_optionalChain([r, 'access', _178 => _178.position, 'optionalAccess', _179 => _179.y]), () => ( 0))) * k));
3333
5441
  const t = n > 1 ? i / (n - 1) : 0;
3334
5442
  const partial = i + 1 === n && fract > 0 ? fract : 1;
3335
5443
  out.push({ index: i, matrix: m, opacity: Math.min(1, Math.max(0, (so + (eo - so) * t) * partial)) });
@@ -3493,7 +5601,7 @@ function mapBezierPath(path, f, tolerance = 0.1, options = {}) {
3493
5601
 
3494
5602
  // src/vector/frames.ts
3495
5603
  function isVectorFrame(node) {
3496
- return _optionalChain([node, 'optionalAccess', _77 => _77.type]) === "group" && !!node.frame && !node.blend && !node.liveBoolean && !node.mask;
5604
+ return _optionalChain([node, 'optionalAccess', _180 => _180.type]) === "group" && !!node.frame && !node.blend && !node.liveBoolean && !node.mask;
3497
5605
  }
3498
5606
  function vectorFrameRectPath(frame) {
3499
5607
  const { x, y, width: w, height: h } = frame;
@@ -3538,17 +5646,17 @@ function placeSpan(rule, a0, a1, f0, f1, g0, g1) {
3538
5646
  }
3539
5647
  }
3540
5648
  function vectorFrameChildMatrix(resizing, box, from, to) {
3541
- const [x0, x1] = placeSpan(_nullishCoalesce(H[_nullishCoalesce(_optionalChain([resizing, 'optionalAccess', _78 => _78.horizontal]), () => ( "left"))], () => ( "start")), box.x, box.x + box.width, from.x, from.x + from.width, to.x, to.x + to.width);
3542
- const [y0, y1] = placeSpan(_nullishCoalesce(V[_nullishCoalesce(_optionalChain([resizing, 'optionalAccess', _79 => _79.vertical]), () => ( "top"))], () => ( "start")), box.y, box.y + box.height, from.y, from.y + from.height, to.y, to.y + to.height);
5649
+ const [x0, x1] = placeSpan(_nullishCoalesce(H[_nullishCoalesce(_optionalChain([resizing, 'optionalAccess', _181 => _181.horizontal]), () => ( "left"))], () => ( "start")), box.x, box.x + box.width, from.x, from.x + from.width, to.x, to.x + to.width);
5650
+ const [y0, y1] = placeSpan(_nullishCoalesce(V[_nullishCoalesce(_optionalChain([resizing, 'optionalAccess', _182 => _182.vertical]), () => ( "top"))], () => ( "start")), box.y, box.y + box.height, from.y, from.y + from.height, to.y, to.y + to.height);
3543
5651
  const sx = box.width > 1e-9 ? (x1 - x0) / box.width : 1;
3544
5652
  const sy = box.height > 1e-9 ? (y1 - y0) / box.height : 1;
3545
5653
  return [sx, 0, 0, sy, x0 - sx * box.x, y0 - sy * box.y];
3546
5654
  }
3547
- var finite3 = (v2) => typeof v2 === "number" && Number.isFinite(v2);
5655
+ var finite4 = (v2) => typeof v2 === "number" && Number.isFinite(v2);
3548
5656
  function sanitizeVectorFrame(value) {
3549
5657
  if (!value || typeof value !== "object") return null;
3550
5658
  const r = value;
3551
- if (!finite3(r.x) || !finite3(r.y) || !finite3(r.width) || !finite3(r.height) || r.width < 0 || r.height < 0) return null;
5659
+ if (!finite4(r.x) || !finite4(r.y) || !finite4(r.width) || !finite4(r.height) || r.width < 0 || r.height < 0) return null;
3552
5660
  const out = { x: r.x, y: r.y, width: r.width, height: r.height };
3553
5661
  if (typeof r.fill === "string" || r.fill && typeof r.fill === "object") out.fill = r.fill;
3554
5662
  if (r.clip === false) out.clip = false;
@@ -3595,7 +5703,7 @@ function vectorFrameDocument(doc, id, find) {
3595
5703
  height,
3596
5704
  ...doc.background ? { background: doc.background } : {},
3597
5705
  nodes: [placed],
3598
- ..._optionalChain([doc, 'access', _80 => _80.symbols, 'optionalAccess', _81 => _81.length]) ? { symbols: doc.symbols } : {}
5706
+ ..._optionalChain([doc, 'access', _183 => _183.symbols, 'optionalAccess', _184 => _184.length]) ? { symbols: doc.symbols } : {}
3599
5707
  };
3600
5708
  }
3601
5709
  function getVectorFramePanel(state) {
@@ -3615,7 +5723,7 @@ function getVectorFramePanel(state) {
3615
5723
  const one = (values) => values.every((v2) => v2 === values[0]) ? values[0] : "mixed";
3616
5724
  return {
3617
5725
  frame: f ? { id: f.id, name: _nullishCoalesce(f.name, () => ( "Frame")), artboard: parents.get(f.id) === null, frame: f.frame } : null,
3618
- resizing: children.length ? { ids: children.map((c) => c.id), horizontal: one(children.map((c) => _nullishCoalesce(_optionalChain([c, 'access', _82 => _82.resizing, 'optionalAccess', _83 => _83.horizontal]), () => ( "left")))), vertical: one(children.map((c) => _nullishCoalesce(_optionalChain([c, 'access', _84 => _84.resizing, 'optionalAccess', _85 => _85.vertical]), () => ( "top")))) } : null
5726
+ resizing: children.length ? { ids: children.map((c) => c.id), horizontal: one(children.map((c) => _nullishCoalesce(_optionalChain([c, 'access', _185 => _185.resizing, 'optionalAccess', _186 => _186.horizontal]), () => ( "left")))), vertical: one(children.map((c) => _nullishCoalesce(_optionalChain([c, 'access', _187 => _187.resizing, 'optionalAccess', _188 => _188.vertical]), () => ( "top")))) } : null
3619
5727
  };
3620
5728
  }
3621
5729
 
@@ -4001,7 +6109,7 @@ function normalizeVectorFilterParams(type, params, base) {
4001
6109
  if (!isVectorFilterType(type)) return null;
4002
6110
  const out = { ...VECTOR_FILTER_DEFAULTS[type], ..._nullishCoalesce(base, () => ( {})) };
4003
6111
  for (const spec of VECTOR_FILTER_PARAM_SPECS[type]) {
4004
- const v2 = _optionalChain([params, 'optionalAccess', _86 => _86[spec.key]]);
6112
+ const v2 = _optionalChain([params, 'optionalAccess', _189 => _189[spec.key]]);
4005
6113
  if (v2 === void 0) continue;
4006
6114
  if (spec.kind === "number" && typeof v2 === "number" && Number.isFinite(v2)) out[spec.key] = Math.min(_nullishCoalesce(spec.max, () => ( Infinity)), Math.max(_nullishCoalesce(spec.min, () => ( -Infinity)), v2));
4007
6115
  else if (spec.kind === "color" && typeof v2 === "string" && v2.trim()) out[spec.key] = v2.trim();
@@ -4133,7 +6241,7 @@ function vectorFilterSvg(filters, id, bounds) {
4133
6241
  primitives.push(fe("feGaussianBlur", { in: body, stdDeviation: round(f.params.radius / 2), result: name("body") }));
4134
6242
  body = name("body");
4135
6243
  }
4136
- const lastResult = _optionalChain([primitives, 'access', _87 => _87[primitives.length - 1], 'optionalAccess', _88 => _88.attrs, 'access', _89 => _89.result]);
6244
+ const lastResult = _optionalChain([primitives, 'access', _190 => _190[primitives.length - 1], 'optionalAccess', _191 => _191.attrs, 'access', _192 => _192.result]);
4137
6245
  if (lastResult !== body) primitives.push(fe("feMerge", {}, [fe("feMergeNode", { in: body })]));
4138
6246
  const pad = vectorFilterReach(active) + 2;
4139
6247
  return {
@@ -4148,7 +6256,7 @@ function vectorFilterSvg(filters, id, bounds) {
4148
6256
  var escapeAttr = (value) => value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
4149
6257
  function primitiveMarkup(p) {
4150
6258
  const attrs = Object.entries(p.attrs).map(([k, v2]) => ` ${k}="${escapeAttr(String(v2))}"`).join("");
4151
- return _optionalChain([p, 'access', _90 => _90.children, 'optionalAccess', _91 => _91.length]) ? `<${p.tag}${attrs}>${p.children.map(primitiveMarkup).join("")}</${p.tag}>` : `<${p.tag}${attrs}/>`;
6259
+ return _optionalChain([p, 'access', _193 => _193.children, 'optionalAccess', _194 => _194.length]) ? `<${p.tag}${attrs}>${p.children.map(primitiveMarkup).join("")}</${p.tag}>` : `<${p.tag}${attrs}/>`;
4152
6260
  }
4153
6261
  function vectorFilterMarkup(filter, extra = "") {
4154
6262
  return `<filter id="${escapeAttr(filter.id)}" filterUnits="userSpaceOnUse" x="${filter.x}" y="${filter.y}" width="${filter.width}" height="${filter.height}" color-interpolation-filters="sRGB"${extra}>${filter.primitives.map(primitiveMarkup).join("")}</filter>`;
@@ -4166,7 +6274,7 @@ function sanitizeVectorMask(value) {
4166
6274
  return r.invert === true ? { type: r.type, invert: true } : { type: r.type };
4167
6275
  }
4168
6276
  function isVectorMaskGroup(node) {
4169
- return _optionalChain([node, 'optionalAccess', _92 => _92.type]) === "group" && !!node.mask && isVectorMaskType(node.mask.type) && !node.blend && !node.liveBoolean && node.children.length > 0;
6277
+ return _optionalChain([node, 'optionalAccess', _195 => _195.type]) === "group" && !!node.mask && isVectorMaskType(node.mask.type) && !node.blend && !node.liveBoolean && node.children.length > 0;
4170
6278
  }
4171
6279
  function isVectorMaskActive(node) {
4172
6280
  return isVectorMaskGroup(node) && node.children[0].visible !== false;
@@ -4196,12 +6304,12 @@ function vectorMaskSummary(node) {
4196
6304
  enabled: node.children[0].visible !== false
4197
6305
  };
4198
6306
  }
4199
- var place = (path, m) => isIdentityMatrix(m) ? path : _chunkGF2RBSDMcjs.transformBezierPath.call(void 0, path, m);
6307
+ var place2 = (path, m) => isIdentityMatrix(m) ? path : _chunkGF2RBSDMcjs.transformBezierPath.call(void 0, path, m);
4200
6308
  function vectorMaskRegionShapes(node, type, parent = IDENTITY_MATRIX, self = true) {
4201
6309
  if (!self && node.visible === false) return [];
4202
6310
  if (isVectorFrame(node)) node = vectorFrameDrawn(node);
4203
6311
  const m = multiplyMatrices(nodeMatrix(node), parent);
4204
- if (isVectorMaskActive(node) || node.type === "group" && _optionalChain([node, 'access', _93 => _93.effects, 'optionalAccess', _94 => _94.length])) {
6312
+ if (isVectorMaskActive(node) || node.type === "group" && _optionalChain([node, 'access', _196 => _196.effects, 'optionalAccess', _197 => _197.length])) {
4205
6313
  return vectorAppearanceShapes(node).flatMap((s) => regionOfPath(s.path, s.source, type, m));
4206
6314
  }
4207
6315
  const drawn = expandVectorAppearance(node);
@@ -4214,17 +6322,17 @@ function vectorMaskRegionShapes(node, type, parent = IDENTITY_MATRIX, self = tru
4214
6322
  function regionOfPath(path, style, type, m) {
4215
6323
  if (!path.length) return [];
4216
6324
  const fillRule = _nullishCoalesce(style.fillRule, () => ( "nonzero"));
4217
- if (type === "clip") return [{ path: place(path, m), fillRule }];
6325
+ if (type === "clip") return [{ path: place2(path, m), fillRule }];
4218
6326
  const out = [];
4219
6327
  let filled = false;
4220
6328
  for (const l of vectorPaintLayerNodes(style)) {
4221
6329
  if (!l.drawn) continue;
4222
6330
  if (l.kind === "fill") {
4223
- if (!filled) out.push({ path: place(path, m), fillRule });
6331
+ if (!filled) out.push({ path: place2(path, m), fillRule });
4224
6332
  filled = true;
4225
6333
  } else if ((_nullishCoalesce(l.node.strokeWidth, () => ( 1))) > 0) {
4226
6334
  const area = vectorStrokeOutlinePath(path, l.node);
4227
- if (area.length) out.push({ path: place(area, m), fillRule: "nonzero" });
6335
+ if (area.length) out.push({ path: place2(area, m), fillRule: "nonzero" });
4228
6336
  }
4229
6337
  }
4230
6338
  return out;
@@ -4406,7 +6514,7 @@ function fitRuns(runs, length2, fallback) {
4406
6514
  }
4407
6515
  if (left2 > 0) {
4408
6516
  if (out.length) out[out.length - 1] = { ...out[out.length - 1], length: out[out.length - 1].length + left2 };
4409
- else out.push({ length: left2, style: _nullishCoalesce(_optionalChain([runs, 'access', _95 => _95[runs.length - 1], 'optionalAccess', _96 => _96.style]), () => ( fallback)) });
6517
+ else out.push({ length: left2, style: _nullishCoalesce(_optionalChain([runs, 'access', _198 => _198[runs.length - 1], 'optionalAccess', _199 => _199.style]), () => ( fallback)) });
4410
6518
  }
4411
6519
  return compact(out);
4412
6520
  }
@@ -4416,7 +6524,7 @@ function styleAt(runs, index, fallback) {
4416
6524
  if (index < at2 + r.length) return r.style;
4417
6525
  at2 += r.length;
4418
6526
  }
4419
- return _nullishCoalesce(_optionalChain([runs, 'access', _97 => _97[runs.length - 1], 'optionalAccess', _98 => _98.style]), () => ( fallback));
6527
+ return _nullishCoalesce(_optionalChain([runs, 'access', _200 => _200[runs.length - 1], 'optionalAccess', _201 => _201.style]), () => ( fallback));
4420
6528
  }
4421
6529
  function restyleRange(runs, start, end, patch) {
4422
6530
  const out = [];
@@ -4472,7 +6580,7 @@ function paragraphRanges(text) {
4472
6580
  return out;
4473
6581
  }
4474
6582
  function fitParagraphRuns(runs, text) {
4475
- const fallback = _nullishCoalesce(_optionalChain([runs, 'access', _99 => _99[0], 'optionalAccess', _100 => _100.style]), () => ( {}));
6583
+ const fallback = _nullishCoalesce(_optionalChain([runs, 'access', _202 => _202[0], 'optionalAccess', _203 => _203.style]), () => ( {}));
4476
6584
  const out = compact(paragraphRanges(text).map((p) => ({ length: p.end - p.start, style: styleAt(runs, p.start, fallback) })));
4477
6585
  return out.length ? out : [{ length: 0, style: fallback }];
4478
6586
  }
@@ -4522,7 +6630,7 @@ function textLineRect(l) {
4522
6630
  var layoutCache = /* @__PURE__ */ new WeakMap();
4523
6631
  function layoutText(layer, shaper) {
4524
6632
  let byShaper = layoutCache.get(layer);
4525
- const hit = _optionalChain([byShaper, 'optionalAccess', _101 => _101.get, 'call', _102 => _102(shaper.id)]);
6633
+ const hit = _optionalChain([byShaper, 'optionalAccess', _204 => _204.get, 'call', _205 => _205(shaper.id)]);
4526
6634
  if (hit) return hit;
4527
6635
  const out = computeLayout(layer, shaper);
4528
6636
  if (!byShaper) {
@@ -4586,7 +6694,7 @@ function computeLayout(layer, shaper) {
4586
6694
  const code = seg.charCodeAt(k);
4587
6695
  if (isLow(code) && index > 0 && isHigh(text.charCodeAt(index - 1))) {
4588
6696
  const prev = chars[chars.length - 1];
4589
- if (_optionalChain([prev, 'optionalAccess', _103 => _103.up])) {
6697
+ if (_optionalChain([prev, 'optionalAccess', _206 => _206.up])) {
4590
6698
  chars.push({ index, ch: seg[k], advance: 0, style, up: prev.up, low: true });
4591
6699
  } else chars.push({ index, ch: seg[k], advance, style, low: true });
4592
6700
  continue;
@@ -4914,7 +7022,7 @@ function createCanvasTextShaper(options = {}) {
4914
7022
  return null;
4915
7023
  })));
4916
7024
  const canvas = make(1, 1);
4917
- const ctx = _optionalChain([canvas, 'optionalAccess', _104 => _104.getContext, 'call', _105 => _105("2d")]);
7025
+ const ctx = _optionalChain([canvas, 'optionalAccess', _207 => _207.getContext, 'call', _208 => _208("2d")]);
4918
7026
  if (!ctx || typeof ctx.measureText !== "function") return null;
4919
7027
  const fallback = _nullishCoalesce(options.fallbackFamily, () => ( "sans-serif"));
4920
7028
  const available = /* @__PURE__ */ new Map();
@@ -4987,10 +7095,10 @@ function createOutlineTextShaper(fonts, options = {}) {
4987
7095
  const entries = fonts.map((f) => {
4988
7096
  const e = "face" in f ? f : { face: f };
4989
7097
  const names = e.face.names;
4990
- const family = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(e.family, () => ( _optionalChain([names, 'optionalAccess', _106 => _106.fontFamily, 'optionalAccess', _107 => _107.en]))), () => ( Object.values(_nullishCoalesce(_optionalChain([names, 'optionalAccess', _108 => _108.fontFamily]), () => ( {})))[0])), () => ( "Font"));
4991
- const weight = _nullishCoalesce(_nullishCoalesce(e.weight, () => ( _optionalChain([e, 'access', _109 => _109.face, 'access', _110 => _110.tables, 'optionalAccess', _111 => _111.os2, 'optionalAccess', _112 => _112.usWeightClass]))), () => ( 400));
4992
- const italic = _nullishCoalesce(e.italic, () => ( Boolean((_nullishCoalesce(_optionalChain([e, 'access', _113 => _113.face, 'access', _114 => _114.tables, 'optionalAccess', _115 => _115.os2, 'optionalAccess', _116 => _116.fsSelection]), () => ( 0))) & 1)));
4993
- const postScript = _nullishCoalesce(_optionalChain([names, 'optionalAccess', _117 => _117.postScriptName, 'optionalAccess', _118 => _118.en]), () => ( Object.values(_nullishCoalesce(_optionalChain([names, 'optionalAccess', _119 => _119.postScriptName]), () => ( {})))[0]));
7098
+ const family = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(e.family, () => ( _optionalChain([names, 'optionalAccess', _209 => _209.fontFamily, 'optionalAccess', _210 => _210.en]))), () => ( Object.values(_nullishCoalesce(_optionalChain([names, 'optionalAccess', _211 => _211.fontFamily]), () => ( {})))[0])), () => ( "Font"));
7099
+ const weight = _nullishCoalesce(_nullishCoalesce(e.weight, () => ( _optionalChain([e, 'access', _212 => _212.face, 'access', _213 => _213.tables, 'optionalAccess', _214 => _214.os2, 'optionalAccess', _215 => _215.usWeightClass]))), () => ( 400));
7100
+ const italic = _nullishCoalesce(e.italic, () => ( Boolean((_nullishCoalesce(_optionalChain([e, 'access', _216 => _216.face, 'access', _217 => _217.tables, 'optionalAccess', _218 => _218.os2, 'optionalAccess', _219 => _219.fsSelection]), () => ( 0))) & 1)));
7101
+ const postScript = _nullishCoalesce(_optionalChain([names, 'optionalAccess', _220 => _220.postScriptName, 'optionalAccess', _221 => _221.en]), () => ( Object.values(_nullishCoalesce(_optionalChain([names, 'optionalAccess', _222 => _222.postScriptName]), () => ( {})))[0]));
4994
7102
  return { face: e.face, family, key: family.toLowerCase(), weight, italic, postScript };
4995
7103
  });
4996
7104
  const fallbackKey = (_nullishCoalesce(options.fallback, () => ( entries[0].family))).toLowerCase();
@@ -5037,12 +7145,12 @@ function createOutlineTextShaper(fonts, options = {}) {
5037
7145
  return out;
5038
7146
  },
5039
7147
  outline(text, font, x, y, opts) {
5040
- return toPath(pick(font).entry.face.getPath(text, x, y, font.size, _optionalChain([opts, 'optionalAccess', _120 => _120.vertical]) ? { kerning: true, vertical: true } : { kerning: true }).commands);
7148
+ return toPath(pick(font).entry.face.getPath(text, x, y, font.size, _optionalChain([opts, 'optionalAccess', _223 => _223.vertical]) ? { kerning: true, vertical: true } : { kerning: true }).commands);
5041
7149
  },
5042
7150
  vertical(char, font) {
5043
7151
  const { face } = pick(font).entry;
5044
7152
  const k = font.size / face.unitsPerEm;
5045
- const v2 = _optionalChain([face, 'access', _121 => _121.getVerticalMetrics, 'optionalCall', _122 => _122(char)]);
7153
+ const v2 = _optionalChain([face, 'access', _224 => _224.getVerticalMetrics, 'optionalCall', _225 => _225(char)]);
5046
7154
  if (v2) return { advance: v2.advance * k, originY: v2.originY * k, alternate: v2.alternate };
5047
7155
  return { advance: (face.ascender - face.descender) * k, originY: face.ascender * k, alternate: false };
5048
7156
  },
@@ -5103,7 +7211,7 @@ function vectorTextHasOutlines() {
5103
7211
  return typeof getVectorTextShaper().outline === "function";
5104
7212
  }
5105
7213
  function vectorTextFamilies() {
5106
- return _nullishCoalesce(_optionalChain([getVectorTextShaper, 'call', _123 => _123(), 'access', _124 => _124.families, 'optionalCall', _125 => _125()]), () => ( ["sans-serif", "serif", "monospace"]));
7214
+ return _nullishCoalesce(_optionalChain([getVectorTextShaper, 'call', _226 => _226(), 'access', _227 => _227.families, 'optionalCall', _228 => _228()]), () => ( ["sans-serif", "serif", "monospace"]));
5107
7215
  }
5108
7216
  var DEFAULT_VECTOR_FONT = { fontFamily: "sans-serif", fontWeight: 400, fontSize: 24 };
5109
7217
  var VECTOR_CHARACTER_STYLE_KEYS = ["fontFamily", "fontWeight", "italic", "fontSize", "tracking", "leading", "baselineShift", "underline", "strikethrough", "upright"];
@@ -5279,7 +7387,7 @@ function computeLayout2(node, shaper) {
5279
7387
  const fragments = [];
5280
7388
  const lines = [];
5281
7389
  let overflow = false;
5282
- const fillOf = (f) => _optionalChain([runs, 'access', _126 => _126.find, 'call', _127 => _127((r) => f.start >= r.start && f.start < r.end), 'optionalAccess', _128 => _128.fill]);
7390
+ const fillOf = (f) => _optionalChain([runs, 'access', _229 => _229.find, 'call', _230 => _230((r) => f.start >= r.start && f.start < r.end), 'optionalAccess', _231 => _231.fill]);
5283
7391
  const styleOf = (f) => {
5284
7392
  const { color: _c, opacity: _o, postScriptName: _p, ...style } = f.style;
5285
7393
  return style;
@@ -5318,11 +7426,11 @@ function computeLayout2(node, shaper) {
5318
7426
  } else {
5319
7427
  const line = text.lines[0];
5320
7428
  const measure = measureVectorPath(subpathPath(frame.path), !!frame.flip);
5321
- const align = _nullishCoalesce(_optionalChain([node, 'access', _129 => _129.paragraph, 'optionalAccess', _130 => _130.align]), () => ( "left"));
7429
+ const align = _nullishCoalesce(_optionalChain([node, 'access', _232 => _232.paragraph, 'optionalAccess', _233 => _233.align]), () => ( "left"));
5322
7430
  const start = Math.max(0, _nullishCoalesce(frame.start, () => ( 0)));
5323
7431
  const end = Math.max(0, _nullishCoalesce(frame.end, () => ( 0)));
5324
7432
  const upright = frame.orientation === "upright";
5325
- const baselineOffset = pathBaselineOffset(_nullishCoalesce(frame.baseline, () => ( "baseline")), _nullishCoalesce(_optionalChain([line, 'optionalAccess', _131 => _131.ascent]), () => ( 0)), _nullishCoalesce(_optionalChain([line, 'optionalAccess', _132 => _132.descent]), () => ( 0)));
7433
+ const baselineOffset = pathBaselineOffset(_nullishCoalesce(frame.baseline, () => ( "baseline")), _nullishCoalesce(_optionalChain([line, 'optionalAccess', _234 => _234.ascent]), () => ( 0)), _nullishCoalesce(_optionalChain([line, 'optionalAccess', _235 => _235.descent]), () => ( 0)));
5326
7434
  if (line) {
5327
7435
  const chars = line.chars.filter((c) => {
5328
7436
  const lo = block.text.charCodeAt(c.index);
@@ -5331,7 +7439,7 @@ function computeLayout2(node, shaper) {
5331
7439
  const advanceOf = (c) => {
5332
7440
  const pair = charAt(block.text, c.index).length === 2;
5333
7441
  const low = pair ? line.chars.find((d) => d.index === c.index + 1) : void 0;
5334
- return c.advance + (_nullishCoalesce(_optionalChain([low, 'optionalAccess', _133 => _133.advance]), () => ( 0)));
7442
+ return c.advance + (_nullishCoalesce(_optionalChain([low, 'optionalAccess', _236 => _236.advance]), () => ( 0)));
5335
7443
  };
5336
7444
  const pivots = chars.map((c) => c.x + advanceOf(c) / 2);
5337
7445
  const positions = vectorPathTextPositions(pivots, [line.x, line.x + line.width], align, measure.length, start, end);
@@ -5386,7 +7494,7 @@ function computeLayout2(node, shaper) {
5386
7494
  if (x0 < Infinity) bounds = { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
5387
7495
  else if (frame.kind === "point") {
5388
7496
  const l = text.lines[0];
5389
- bounds = { x: frame.x, y: frame.y - (_nullishCoalesce(_optionalChain([l, 'optionalAccess', _134 => _134.ascent]), () => ( 0))), width: 0, height: (_nullishCoalesce(_optionalChain([l, 'optionalAccess', _135 => _135.ascent]), () => ( 0))) + (_nullishCoalesce(_optionalChain([l, 'optionalAccess', _136 => _136.descent]), () => ( 0))) };
7497
+ bounds = { x: frame.x, y: frame.y - (_nullishCoalesce(_optionalChain([l, 'optionalAccess', _237 => _237.ascent]), () => ( 0))), width: 0, height: (_nullishCoalesce(_optionalChain([l, 'optionalAccess', _238 => _238.ascent]), () => ( 0))) + (_nullishCoalesce(_optionalChain([l, 'optionalAccess', _239 => _239.descent]), () => ( 0))) };
5390
7498
  }
5391
7499
  }
5392
7500
  return { shaper: shaper.id, glyphs, fragments, lines, origin, text, bounds, overflow, missingFonts: text.missingFonts };
@@ -5507,7 +7615,7 @@ function vectorTextCaret(node, index) {
5507
7615
  const t = { x: Math.cos(r), y: Math.sin(r) };
5508
7616
  const n2 = { x: -t.y, y: t.x };
5509
7617
  const o = { x: g2.x + t.x * u, y: g2.y + t.y * u };
5510
- return { top: { x: o.x - n2.x * g2.ascent, y: o.y - n2.y * g2.ascent }, bottom: { x: o.x + n2.x * g2.descent, y: o.y + n2.y * g2.descent }, line: _nullishCoalesce(_optionalChain([layout, 'access', _137 => _137.fragments, 'access', _138 => _138[g2.fragment], 'optionalAccess', _139 => _139.line]), () => ( 0)) };
7618
+ return { top: { x: o.x - n2.x * g2.ascent, y: o.y - n2.y * g2.ascent }, bottom: { x: o.x + n2.x * g2.descent, y: o.y + n2.y * g2.descent }, line: _nullishCoalesce(_optionalChain([layout, 'access', _240 => _240.fragments, 'access', _241 => _241[g2.fragment], 'optionalAccess', _242 => _242.line]), () => ( 0)) };
5511
7619
  };
5512
7620
  if (node.frame.kind !== "path") {
5513
7621
  const c = caretAt(layout.text, index);
@@ -5647,7 +7755,7 @@ function sanitizeVectorTextFrame(value, path = "frame") {
5647
7755
  return { kind: "area", x: num2(f.x, `${path}.x`, -1e7, 1e7), y: num2(f.y, `${path}.y`, -1e7, 1e7), width: num2(f.width, `${path}.width`, 0, 1e7), height: num2(f.height, `${path}.height`, 0, 1e7) };
5648
7756
  if (f.kind === "path") {
5649
7757
  const sp = f.path;
5650
- if (!sp || !Array.isArray(sp.anchors) || sp.anchors.length < 2 || !sp.anchors.every((a) => isNum(_optionalChain([a, 'optionalAccess', _140 => _140.x])) && isNum(_optionalChain([a, 'optionalAccess', _141 => _141.y])))) fail(`${path}.path must be a subpath with at least two anchors.`);
7758
+ if (!sp || !Array.isArray(sp.anchors) || sp.anchors.length < 2 || !sp.anchors.every((a) => isNum(_optionalChain([a, 'optionalAccess', _243 => _243.x])) && isNum(_optionalChain([a, 'optionalAccess', _244 => _244.y])))) fail(`${path}.path must be a subpath with at least two anchors.`);
5651
7759
  const out = { kind: "path", path: { closed: !!sp.closed, anchors: sp.anchors.map((a) => ({ ...a })) } };
5652
7760
  if (f.start !== void 0 && f.start !== 0) out.start = num2(f.start, `${path}.start`, 0, 1e7);
5653
7761
  if (f.end !== void 0 && f.end !== 0) out.end = num2(f.end, `${path}.end`, 0, 1e7);
@@ -5665,7 +7773,7 @@ function sanitizeVectorTextFrame(value, path = "frame") {
5665
7773
  return fail(`${path}.kind must be point, area or path, got ${JSON.stringify(f.kind)}.`);
5666
7774
  }
5667
7775
  function normalizeVectorTextRuns(text, runs) {
5668
- if (!_optionalChain([runs, 'optionalAccess', _142 => _142.length])) return null;
7776
+ if (!_optionalChain([runs, 'optionalAccess', _245 => _245.length])) return null;
5669
7777
  const cleaned = fitVectorTextRuns(
5670
7778
  runs.map((r) => ({ length: r.length, style: stripUndefined(r.style) })),
5671
7779
  text.length
@@ -5705,7 +7813,7 @@ function replaceVectorText(node, start, end, insert) {
5705
7813
  const clean2 = insert.replace(/\r\n?/g, "\n");
5706
7814
  const text = node.text.slice(0, start) + clean2 + node.text.slice(end);
5707
7815
  let runs = null;
5708
- if (_optionalChain([node, 'access', _143 => _143.runs, 'optionalAccess', _144 => _144.length])) {
7816
+ if (_optionalChain([node, 'access', _246 => _246.runs, 'optionalAccess', _247 => _247.length])) {
5709
7817
  const fitted = fitVectorTextRuns(node.runs, node.text.length);
5710
7818
  const style = styleAt(fitted, start > 0 ? start - 1 : start, {});
5711
7819
  runs = normalizeVectorTextRuns(text, spliceRuns(fitted, start, end, clean2.length, style));
@@ -5721,7 +7829,7 @@ function styleVectorText(node, start, end, patch) {
5721
7829
  if (whole) {
5722
7830
  let next2 = { ...node, font: patchVectorCharacterStyle(node.font, fields, "style") };
5723
7831
  const keys = Object.keys(fields).filter((k) => fields[k] !== void 0);
5724
- if (_optionalChain([next2, 'access', _145 => _145.runs, 'optionalAccess', _146 => _146.length]) && (keys.length || fill !== void 0)) {
7832
+ if (_optionalChain([next2, 'access', _248 => _248.runs, 'optionalAccess', _249 => _249.length]) && (keys.length || fill !== void 0)) {
5725
7833
  const runs2 = normalizeVectorTextRuns(
5726
7834
  next2.text,
5727
7835
  next2.runs.map((r) => {
@@ -5766,7 +7874,7 @@ function bakeVectorTextGeometry(node, m) {
5766
7874
  ...s.baselineShift !== void 0 ? { baselineShift: s.baselineShift * k } : {}
5767
7875
  });
5768
7876
  const font = scaleStyle(node.font);
5769
- const runs = _optionalChain([node, 'access', _147 => _147.runs, 'optionalAccess', _148 => _148.map, 'call', _149 => _149((r) => ({ length: r.length, style: scaleStyle(r.style) }))]);
7877
+ const runs = _optionalChain([node, 'access', _250 => _250.runs, 'optionalAccess', _251 => _251.map, 'call', _252 => _252((r) => ({ length: r.length, style: scaleStyle(r.style) }))]);
5770
7878
  const p = node.paragraph;
5771
7879
  const paragraph = p ? {
5772
7880
  ...p,
@@ -6055,7 +8163,7 @@ function vectorInstanceGroup(node, bake) {
6055
8163
  const m = _nullishCoalesce(node.transform, () => ( [1, 0, 0, 1, 0, 0]));
6056
8164
  const { rigid, residual } = decomposeRigid(m);
6057
8165
  const k = Math.sqrt(Math.abs(residual[0] * residual[3] - residual[1] * residual[2]));
6058
- const hidden = new Set(_nullishCoalesce(_optionalChain([node, 'access', _150 => _150.overrides, 'optionalAccess', _151 => _151.hidden]), () => ( [])));
8166
+ const hidden = new Set(_nullishCoalesce(_optionalChain([node, 'access', _253 => _253.overrides, 'optionalAccess', _254 => _254.hidden]), () => ( [])));
6059
8167
  const keep = (list) => list.filter((n) => !hidden.has(n.id)).map((n) => n.type === "group" ? { ...n, children: keep(n.children) } : n);
6060
8168
  let children = prefixVectorIds(keep(_nullishCoalesce(node.art, () => ( []))), node.id);
6061
8169
  if (!isIdentityMatrix(residual)) children = children.map((c) => bake(c, residual));
@@ -6068,8 +8176,8 @@ function vectorInstanceGroup(node, bake) {
6068
8176
  if (node.locked) group.locked = true;
6069
8177
  if (node.opacity !== void 0) group.opacity = node.opacity;
6070
8178
  if (node.blendMode) group.blendMode = node.blendMode;
6071
- if (_optionalChain([node, 'access', _152 => _152.filters, 'optionalAccess', _153 => _153.length])) group.filters = node.filters;
6072
- if (_optionalChain([node, 'access', _154 => _154.effects, 'optionalAccess', _155 => _155.length])) group.effects = node.effects;
8179
+ if (_optionalChain([node, 'access', _255 => _255.filters, 'optionalAccess', _256 => _256.length])) group.filters = node.filters;
8180
+ if (_optionalChain([node, 'access', _257 => _257.effects, 'optionalAccess', _258 => _258.length])) group.effects = node.effects;
6073
8181
  if (node.booleanOperation) group.booleanOperation = node.booleanOperation;
6074
8182
  if (node.blendStep) group.blendStep = true;
6075
8183
  return group;
@@ -6208,8 +8316,8 @@ function sanitizeVectorLens(value) {
6208
8316
  if (spec.color !== null) out.color = typeof r.color === "string" && parseVectorColor(r.color) ? r.color : spec.color;
6209
8317
  return out;
6210
8318
  }
6211
- var hex22 = (v2) => Math.round(Math.min(1, Math.max(0, v2)) * 255).toString(16).padStart(2, "0");
6212
- var formatRgba = (c) => c[3] >= 1 ? `#${hex22(c[0])}${hex22(c[1])}${hex22(c[2])}` : `rgba(${Math.round(c[0] * 255)}, ${Math.round(c[1] * 255)}, ${Math.round(c[2] * 255)}, ${Math.round(c[3] * 1e3) / 1e3})`;
8319
+ var hex23 = (v2) => Math.round(Math.min(1, Math.max(0, v2)) * 255).toString(16).padStart(2, "0");
8320
+ var formatRgba = (c) => c[3] >= 1 ? `#${hex23(c[0])}${hex23(c[1])}${hex23(c[2])}` : `rgba(${Math.round(c[0] * 255)}, ${Math.round(c[1] * 255)}, ${Math.round(c[2] * 255)}, ${Math.round(c[3] * 1e3) / 1e3})`;
6213
8321
  var luma = (c) => 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
6214
8322
  var mix = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t, a[3]];
6215
8323
  var HEAT = [
@@ -6322,8 +8430,8 @@ function vectorLensDrawn(node) {
6322
8430
  if (wire) {
6323
8431
  contents.push(shapePath(shape, id, changed, { fill: null, fills: void 0, stroke: wire, strokes: void 0, strokeWidth: 1, strokeAlign: void 0, strokeDasharray: void 0, strokeWidthProfile: void 0, opacity: Math.min(1, Math.max(0, lens.amount / 100)) }));
6324
8432
  } else if (recolour) {
6325
- const fills = _optionalChain([shape, 'access', _156 => _156.source, 'access', _157 => _157.fills, 'optionalAccess', _158 => _158.map, 'call', _159 => _159((l) => ({ ...l, paint: _nullishCoalesce(mapVectorPaintColors(l.paint, recolour), () => ( null)) }))]);
6326
- const strokes = _optionalChain([shape, 'access', _160 => _160.source, 'access', _161 => _161.strokes, 'optionalAccess', _162 => _162.map, 'call', _163 => _163((l) => ({ ...l, paint: _nullishCoalesce(mapVectorPaintColors(l.paint, recolour), () => ( null)) }))]);
8433
+ const fills = _optionalChain([shape, 'access', _259 => _259.source, 'access', _260 => _260.fills, 'optionalAccess', _261 => _261.map, 'call', _262 => _262((l) => ({ ...l, paint: _nullishCoalesce(mapVectorPaintColors(l.paint, recolour), () => ( null)) }))]);
8434
+ const strokes = _optionalChain([shape, 'access', _263 => _263.source, 'access', _264 => _264.strokes, 'optionalAccess', _265 => _265.map, 'call', _266 => _266((l) => ({ ...l, paint: _nullishCoalesce(mapVectorPaintColors(l.paint, recolour), () => ( null)) }))]);
6327
8435
  contents.push(shapePath(shape, id, changed, { fill: _nullishCoalesce(mapVectorPaintColors(shape.source.fill, recolour), () => ( null)), stroke: _nullishCoalesce(mapVectorPaintColors(shape.source.stroke, recolour), () => ( null)), ...fills ? { fills } : {}, ...strokes ? { strokes } : {} }));
6328
8436
  } else contents.push(shapePath(shape, id, changed));
6329
8437
  }
@@ -6336,7 +8444,7 @@ function vectorLensDrawn(node) {
6336
8444
  const { lens: _l, lensView: _v, transform: _t, opacity: _o, effects: _e, blendMode: _bm, filters: _f, ...style } = node;
6337
8445
  const fillOpacity = lens.type === "transparency" ? 1 - Math.min(100, Math.max(0, lens.amount)) / 100 : 0;
6338
8446
  children.push({ ...style, id: `${node.id}~lens-fill`, stroke: null, strokes: void 0, opacity: fillOpacity });
6339
- const stroked = (_nullishCoalesce(_optionalChain([node, 'access', _164 => _164.strokes, 'optionalAccess', _165 => _165.length]), () => ( 0))) > 0 || node.stroke != null && node.stroke !== "none";
8447
+ const stroked = (_nullishCoalesce(_optionalChain([node, 'access', _267 => _267.strokes, 'optionalAccess', _268 => _268.length]), () => ( 0))) > 0 || node.stroke != null && node.stroke !== "none";
6340
8448
  if (stroked) children.push({ ...style, id: `${node.id}~lens-stroke`, fill: null, fills: void 0 });
6341
8449
  const out = {
6342
8450
  id: node.id,
@@ -6345,7 +8453,7 @@ function vectorLensDrawn(node) {
6345
8453
  ...node.transform ? { transform: node.transform } : {},
6346
8454
  ...node.opacity !== void 0 ? { opacity: node.opacity } : {},
6347
8455
  ...node.blendMode ? { blendMode: node.blendMode } : {},
6348
- ..._optionalChain([node, 'access', _166 => _166.filters, 'optionalAccess', _167 => _167.length]) ? { filters: node.filters } : {},
8456
+ ..._optionalChain([node, 'access', _269 => _269.filters, 'optionalAccess', _270 => _270.length]) ? { filters: node.filters } : {},
6349
8457
  children
6350
8458
  };
6351
8459
  drawnCache2.set(node, out);
@@ -6631,15 +8739,15 @@ var BERN_INV = [
6631
8739
  [0, 0, 0, 1]
6632
8740
  ];
6633
8741
  var pct = (v2) => typeof v2 === "number" && Number.isFinite(v2) ? Math.min(1, Math.max(-1, v2 / 100)) : 0;
6634
- function warpPresetMesh(preset, bounds) {
6635
- if (!WARP_STYLES.includes(preset.style)) return null;
8742
+ function warpPresetMesh(preset2, bounds) {
8743
+ if (!WARP_STYLES.includes(preset2.style)) return null;
6636
8744
  const { x, y, width: w, height: h } = bounds;
6637
8745
  if (!(w > 0 && h > 0)) return null;
6638
- const b = pct(preset.bend);
6639
- const hd = pct(preset.horizontal);
6640
- const vd = pct(preset.vertical);
8746
+ const b = pct(preset2.bend);
8747
+ const hd = pct(preset2.horizontal);
8748
+ const vd = pct(preset2.vertical);
6641
8749
  if (b === 0 && hd === 0 && vd === 0) return null;
6642
- const grid = warpPresetGrid(preset.style, b, hd, vd, preset.orientation === "vertical", h / w);
8750
+ const grid = warpPresetGrid(preset2.style, b, hd, vd, preset2.orientation === "vertical", h / w);
6643
8751
  return { us: [0, 1], vs: [0, 1], points: grid.flat().map((p) => ({ x: x + p[0] * w, y: y + p[1] * h })) };
6644
8752
  }
6645
8753
  var warpMeshColumns = (m) => 3 * (m.us.length - 1) + 1;
@@ -7308,8 +9416,8 @@ var VECTOR_EFFECT_PARAM_SPECS = {
7308
9416
  var cloneMesh = (m) => ({ us: m.us.slice(), vs: m.vs.slice(), points: m.points.map((p) => ({ x: p.x, y: p.y })) });
7309
9417
  function vectorEnvelopeMesh(params, bounds) {
7310
9418
  if (params.style === "mesh") return _nullishCoalesce(params.mesh, () => ( identityWarpMesh(bounds, params.columns, params.rows)));
7311
- const preset = warpPresetMesh({ style: params.style, bend: params.bend, horizontal: params.horizontal, vertical: params.vertical, orientation: params.orientation }, bounds);
7312
- return preset ? resizeWarpMesh(preset, params.columns, params.rows) : identityWarpMesh(bounds, params.columns, params.rows);
9419
+ const preset2 = warpPresetMesh({ style: params.style, bend: params.bend, horizontal: params.horizontal, vertical: params.vertical, orientation: params.orientation }, bounds);
9420
+ return preset2 ? resizeWarpMesh(preset2, params.columns, params.rows) : identityWarpMesh(bounds, params.columns, params.rows);
7313
9421
  }
7314
9422
  function vectorEnvelopeMap(params, bounds) {
7315
9423
  if (!bounds || !(bounds.width > 0 && bounds.height > 0)) return null;
@@ -7346,7 +9454,7 @@ function normalizeVectorEffectParams(type, params, base) {
7346
9454
  if (!defaults) return null;
7347
9455
  const out = { ...defaults, ..._nullishCoalesce(base, () => ( {})) };
7348
9456
  for (const spec of VECTOR_EFFECT_PARAM_SPECS[type]) {
7349
- const v2 = _optionalChain([params, 'optionalAccess', _168 => _168[spec.key]]);
9457
+ const v2 = _optionalChain([params, 'optionalAccess', _271 => _271[spec.key]]);
7350
9458
  if (v2 === void 0) continue;
7351
9459
  if (spec.kind === "number" && typeof v2 === "number" && Number.isFinite(v2)) out[spec.key] = Math.min(_nullishCoalesce(spec.max, () => ( Infinity)), Math.max(_nullishCoalesce(spec.min, () => ( -Infinity)), v2));
7352
9460
  else if (spec.kind === "boolean" && typeof v2 === "boolean") out[spec.key] = v2;
@@ -7358,7 +9466,7 @@ function normalizeVectorEffectParams(type, params, base) {
7358
9466
  const o = out;
7359
9467
  o.rows = Math.round(o.rows);
7360
9468
  o.columns = Math.round(o.columns);
7361
- const given = _optionalChain([params, 'optionalAccess', _169 => _169.mesh]);
9469
+ const given = _optionalChain([params, 'optionalAccess', _272 => _272.mesh]);
7362
9470
  let mesh = given !== void 0 ? isValidWarpMesh(given) ? cloneMesh(given) : null : o.mesh;
7363
9471
  if (o.style !== "mesh") mesh = null;
7364
9472
  if (mesh && given !== void 0) {
@@ -7375,10 +9483,10 @@ function createVectorEffect(type, id, params) {
7375
9483
  }
7376
9484
  var isEnabled = (e) => e.enabled !== false && !!VECTOR_EFFECT_DEFAULTS[e.type];
7377
9485
  function activeVectorEffects(node) {
7378
- return _nullishCoalesce(_optionalChain([node, 'access', _170 => _170.effects, 'optionalAccess', _171 => _171.filter, 'call', _172 => _172(isEnabled)]), () => ( []));
9486
+ return _nullishCoalesce(_optionalChain([node, 'access', _273 => _273.effects, 'optionalAccess', _274 => _274.filter, 'call', _275 => _275(isEnabled)]), () => ( []));
7379
9487
  }
7380
9488
  function hasOwnVectorAppearance(node) {
7381
- return node.type === "text" || node.type === "instance" || node.type === "group" && !!node.liveBoolean || isVectorFrame(node) || isVectorSymmetryGroup(node) || isVectorLens(node) || !!_optionalChain([node, 'access', _173 => _173.effects, 'optionalAccess', _174 => _174.some, 'call', _175 => _175(isEnabled)]);
9489
+ return node.type === "text" || node.type === "instance" || node.type === "group" && !!node.liveBoolean || isVectorFrame(node) || isVectorSymmetryGroup(node) || isVectorLens(node) || !!_optionalChain([node, 'access', _276 => _276.effects, 'optionalAccess', _277 => _277.some, 'call', _278 => _278(isEnabled)]);
7382
9490
  }
7383
9491
  var liveCache = /* @__PURE__ */ new WeakMap();
7384
9492
  function hasVectorAppearance(node) {
@@ -7390,18 +9498,18 @@ function hasVectorAppearance(node) {
7390
9498
  return v2;
7391
9499
  }
7392
9500
  function isVectorLiveBoolean(node) {
7393
- return _optionalChain([node, 'optionalAccess', _176 => _176.type]) === "group" && !!node.liveBoolean;
9501
+ return _optionalChain([node, 'optionalAccess', _279 => _279.type]) === "group" && !!node.liveBoolean;
7394
9502
  }
7395
9503
  function vectorOperandOperation(group, child) {
7396
9504
  return _nullishCoalesce(_nullishCoalesce(child.booleanOperation, () => ( group.liveBoolean)), () => ( "union"));
7397
9505
  }
7398
9506
  var PATH_OPS = { union: "union", subtract: "difference", intersect: "intersection", exclude: "xor" };
7399
- var FoldCache = (_class = class {
7400
- constructor(cap) {;_class.prototype.__init.call(this);
9507
+ var FoldCache = (_class9 = class {
9508
+ constructor(cap) {;_class9.prototype.__init60.call(this);
7401
9509
  this.cap = cap;
7402
9510
  }
7403
9511
 
7404
- __init() {this.map = /* @__PURE__ */ new Map()}
9512
+ __init60() {this.map = /* @__PURE__ */ new Map()}
7405
9513
  get(key) {
7406
9514
  const hit = this.map.get(key);
7407
9515
  if (hit) {
@@ -7423,7 +9531,7 @@ var FoldCache = (_class = class {
7423
9531
  clear() {
7424
9532
  this.map.clear();
7425
9533
  }
7426
- }, _class);
9534
+ }, _class9);
7427
9535
  var foldCache = new FoldCache(4096);
7428
9536
  var foldSteps = 0;
7429
9537
  function vectorLiveBooleanSteps() {
@@ -7432,9 +9540,9 @@ function vectorLiveBooleanSteps() {
7432
9540
  function clearVectorLiveBooleanCache() {
7433
9541
  foldCache.clear();
7434
9542
  }
7435
- var RollingHash = (_class2 = class _RollingHash {constructor() { _class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this); }
7436
- __init2() {this.a = 2166136261}
7437
- __init3() {this.b = 16777619 ^ 1540483477}
9543
+ var RollingHash = (_class10 = class _RollingHash {constructor() { _class10.prototype.__init61.call(this);_class10.prototype.__init62.call(this); }
9544
+ __init61() {this.a = 2166136261}
9545
+ __init62() {this.b = 16777619 ^ 1540483477}
7438
9546
  static __initStatic() {this.view = new DataView(new ArrayBuffer(8))}
7439
9547
  byte(v2) {
7440
9548
  this.a = Math.imul(this.a ^ v2 & 255, 16777619);
@@ -7464,7 +9572,7 @@ var RollingHash = (_class2 = class _RollingHash {constructor() { _class2.prototy
7464
9572
  key() {
7465
9573
  return `${(this.a >>> 0).toString(36)}.${(this.b >>> 0).toString(36)}`;
7466
9574
  }
7467
- }, _class2.__initStatic(), _class2);
9575
+ }, _class10.__initStatic(), _class10);
7468
9576
  function foldVectorBooleanOperands(operands) {
7469
9577
  if (!operands.length) return [];
7470
9578
  if (operands.length === 1) return operands[0].path;
@@ -7507,7 +9615,7 @@ var compareOrder = (a, b) => {
7507
9615
  for (let i = 0; i < n; i++) if (a[i] !== b[i]) return a[i] - b[i];
7508
9616
  return a.length - b.length;
7509
9617
  };
7510
- var add3 = (a, b) => ({ x: a.x + (_nullishCoalesce(_optionalChain([b, 'optionalAccess', _177 => _177.x]), () => ( 0))), y: a.y + (_nullishCoalesce(_optionalChain([b, 'optionalAccess', _178 => _178.y]), () => ( 0))) });
9618
+ var add3 = (a, b) => ({ x: a.x + (_nullishCoalesce(_optionalChain([b, 'optionalAccess', _280 => _280.x]), () => ( 0))), y: a.y + (_nullishCoalesce(_optionalChain([b, 'optionalAccess', _281 => _281.y]), () => ( 0))) });
7511
9619
  var mapPaths = (shapes, fn) => {
7512
9620
  const out = fn(shapes.map((s) => s.path));
7513
9621
  return shapes.map((s, i) => ({ ...s, path: _nullishCoalesce(out[i], () => ( [])) }));
@@ -7535,7 +9643,7 @@ function contourShapes(shapes, c) {
7535
9643
  const power = 2 ** (Math.min(100, Math.max(-100, c.acceleration)) / 50);
7536
9644
  for (let k = 1; k <= n; k++) {
7537
9645
  const [path] = offsetPaths([s.path], (outside ? 1 : -1) * step * k, c.join, c.miterLimit, 1, 0);
7538
- if (!_optionalChain([path, 'optionalAccess', _179 => _179.length])) break;
9646
+ if (!_optionalChain([path, 'optionalAccess', _282 => _282.length])) break;
7539
9647
  const t = (k / n) ** power;
7540
9648
  const source = { ...s.source, fill: _nullishCoalesce(blendPaint(s.source.fill, c.fillColor, t), () => ( null)), stroke: _nullishCoalesce(blendPaint(s.source.stroke, c.strokeColor, t), () => ( null)), fills: void 0, strokes: void 0 };
7541
9649
  out.push({ source, path, opacity: s.opacity, order: [outside ? n - k : k, ...s.order] });
@@ -7610,8 +9718,8 @@ function bevelShapes(shapes, b) {
7610
9718
  out.push({ source, path: f.path, opacity: s.opacity, order: [...s.order, 1, k] });
7611
9719
  });
7612
9720
  const [middle] = offsetPaths([s.path], -b.width, "miter", 4, 1, 0);
7613
- if (_optionalChain([middle, 'optionalAccess', _180 => _180.length])) out.push({ ...s, source: fillOnly, path: middle, order: [...s.order, 2] });
7614
- const hasStroke = _optionalChain([s, 'access', _181 => _181.source, 'access', _182 => _182.strokes, 'optionalAccess', _183 => _183.length]) || s.source.stroke != null && s.source.stroke !== "none";
9721
+ if (_optionalChain([middle, 'optionalAccess', _283 => _283.length])) out.push({ ...s, source: fillOnly, path: middle, order: [...s.order, 2] });
9722
+ const hasStroke = _optionalChain([s, 'access', _284 => _284.source, 'access', _285 => _285.strokes, 'optionalAccess', _286 => _286.length]) || s.source.stroke != null && s.source.stroke !== "none";
7615
9723
  if (hasStroke) out.push({ ...s, source: { ...s.source, fill: null, fills: void 0 }, order: [...s.order, 3] });
7616
9724
  }
7617
9725
  return out;
@@ -7744,10 +9852,10 @@ function vectorEffectInputBounds(node, effectId) {
7744
9852
  return paths ? pathsBounds(paths) : null;
7745
9853
  }
7746
9854
  function vectorNodeEnvelope(node) {
7747
- return _nullishCoalesce(_optionalChain([node, 'optionalAccess', _184 => _184.effects, 'optionalAccess', _185 => _185.find, 'call', _186 => _186((e) => e.type === "envelope" && e.enabled !== false)]), () => ( null));
9855
+ return _nullishCoalesce(_optionalChain([node, 'optionalAccess', _287 => _287.effects, 'optionalAccess', _288 => _288.find, 'call', _289 => _289((e) => e.type === "envelope" && e.enabled !== false)]), () => ( null));
7748
9856
  }
7749
9857
  function vectorEnvelopeFrame(node, effectId) {
7750
- const e = effectId ? _optionalChain([node, 'access', _187 => _187.effects, 'optionalAccess', _188 => _188.find, 'call', _189 => _189((x) => x.id === effectId)]) : vectorNodeEnvelope(node);
9858
+ const e = effectId ? _optionalChain([node, 'access', _290 => _290.effects, 'optionalAccess', _291 => _291.find, 'call', _292 => _292((x) => x.id === effectId)]) : vectorNodeEnvelope(node);
7751
9859
  if (!e || e.type !== "envelope") return null;
7752
9860
  const bounds = vectorEffectInputBounds(node, e.id);
7753
9861
  if (!bounds || !(bounds.width > 0 && bounds.height > 0)) return null;
@@ -7808,7 +9916,7 @@ function placement(node) {
7808
9916
  ...node.blendStep ? { blendStep: true } : {},
7809
9917
  ...node.booleanOperation ? { booleanOperation: node.booleanOperation } : {},
7810
9918
  ...node.blendMode ? { blendMode: node.blendMode } : {},
7811
- ..._optionalChain([node, 'access', _190 => _190.filters, 'optionalAccess', _191 => _191.length]) ? { filters: node.filters } : {}
9919
+ ..._optionalChain([node, 'access', _293 => _293.filters, 'optionalAccess', _294 => _294.length]) ? { filters: node.filters } : {}
7812
9920
  };
7813
9921
  }
7814
9922
  function vectorAppearanceNodes(node) {
@@ -7940,7 +10048,7 @@ function vectorMasterPages(doc) {
7940
10048
  function fillTokens(node, page, pages) {
7941
10049
  const map = (s) => s.replace(/\{page\}/g, String(page)).replace(/\{pages\}/g, String(pages));
7942
10050
  if (!/\{pages?\}/.test(node.text)) return node;
7943
- if (!_optionalChain([node, 'access', _192 => _192.runs, 'optionalAccess', _193 => _193.length])) return { ...node, text: map(node.text) };
10051
+ if (!_optionalChain([node, 'access', _295 => _295.runs, 'optionalAccess', _296 => _296.length])) return { ...node, text: map(node.text) };
7944
10052
  let at2 = 0;
7945
10053
  let text = "";
7946
10054
  const runs = [];
@@ -7963,7 +10071,7 @@ function vectorMasterArt(master, page, number, count) {
7963
10071
  const f = page.frame;
7964
10072
  const key = `${page.id}|${f.x}|${f.y}|${f.width}|${f.height}|${number}|${count}`;
7965
10073
  let byKey = artCache.get(master);
7966
- const hit = _optionalChain([byKey, 'optionalAccess', _194 => _194.get, 'call', _195 => _195(key)]);
10074
+ const hit = _optionalChain([byKey, 'optionalAccess', _297 => _297.get, 'call', _298 => _298(key)]);
7967
10075
  if (hit) return hit;
7968
10076
  const art = master.children.filter((c) => c.visible !== false).map((c) => {
7969
10077
  const box = vectorNodeBounds(c);
@@ -8008,7 +10116,7 @@ function stripVectorMasterArt(doc) {
8008
10116
  // src/vector/connectors.ts
8009
10117
  var SIDES = ["top", "right", "bottom", "left", "center"];
8010
10118
  function isVectorConnector(node) {
8011
- return _optionalChain([node, 'optionalAccess', _196 => _196.type]) === "path" && !!node.connector;
10119
+ return _optionalChain([node, 'optionalAccess', _299 => _299.type]) === "path" && !!node.connector;
8012
10120
  }
8013
10121
  function vectorConnectionSites(nodes, id) {
8014
10122
  const node = findVectorNode(nodes, id);
@@ -8065,7 +10173,7 @@ function facingSite(sites, toward) {
8065
10173
  }
8066
10174
  function storedEnds(node, world) {
8067
10175
  const sp = node.subpaths[0];
8068
- if (!_optionalChain([sp, 'optionalAccess', _197 => _197.anchors, 'access', _198 => _198.length])) return null;
10176
+ if (!_optionalChain([sp, 'optionalAccess', _300 => _300.anchors, 'access', _301 => _301.length])) return null;
8069
10177
  const a = sp.anchors[0];
8070
10178
  const b = sp.anchors[sp.anchors.length - 1];
8071
10179
  return [applyMatrix(world, a), applyMatrix(world, b)];
@@ -8172,8 +10280,8 @@ function routeVectorConnector(nodes, id) {
8172
10280
  }));
8173
10281
  return {
8174
10282
  subpaths: [{ closed: false, anchors: local }],
8175
- startSide: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _199 => _199.side]), () => ( null)),
8176
- endSide: _nullishCoalesce(_optionalChain([e, 'optionalAccess', _200 => _200.side]), () => ( null)),
10283
+ startSide: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _302 => _302.side]), () => ( null)),
10284
+ endSide: _nullishCoalesce(_optionalChain([e, 'optionalAccess', _303 => _303.side]), () => ( null)),
8177
10285
  dropped: { start: !!startGlue && !s, end: !!endGlue && !e }
8178
10286
  };
8179
10287
  }
@@ -8185,7 +10293,7 @@ function sameSubpaths(a, b) {
8185
10293
  const o = b[i];
8186
10294
  return sp.closed === o.closed && sp.anchors.length === o.anchors.length && sp.anchors.every((p, k) => {
8187
10295
  const q = o.anchors[k];
8188
- return samePoint(p, q) && samePoint(p.in, q.in) && samePoint(p.out, q.out) && (_nullishCoalesce(_optionalChain([p, 'access', _201 => _201.corner, 'optionalAccess', _202 => _202.radius]), () => ( 0))) === (_nullishCoalesce(_optionalChain([q, 'access', _203 => _203.corner, 'optionalAccess', _204 => _204.radius]), () => ( 0)));
10296
+ return samePoint(p, q) && samePoint(p.in, q.in) && samePoint(p.out, q.out) && (_nullishCoalesce(_optionalChain([p, 'access', _304 => _304.corner, 'optionalAccess', _305 => _305.radius]), () => ( 0))) === (_nullishCoalesce(_optionalChain([q, 'access', _306 => _306.corner, 'optionalAccess', _307 => _307.radius]), () => ( 0)));
8189
10297
  });
8190
10298
  });
8191
10299
  }
@@ -8295,7 +10403,7 @@ var add4 = (a, b) => ({ x: a.x + b.x, y: a.y + b.y });
8295
10403
  var sub4 = (a, b) => ({ x: a.x - b.x, y: a.y - b.y });
8296
10404
  var scale2 = (a, k) => ({ x: a.x * k, y: a.y * k });
8297
10405
  var left = (d) => ({ x: d.y, y: -d.x });
8298
- var unit3 = (v2) => {
10406
+ var unit4 = (v2) => {
8299
10407
  const l = Math.hypot(v2.x, v2.y);
8300
10408
  return l > 1e-12 ? { x: v2.x / l, y: v2.y / l } : { x: 1, y: 0 };
8301
10409
  };
@@ -8352,7 +10460,7 @@ function vectorStrokeGradientDefs(g, id, node, options = {}) {
8352
10460
  for (let i = 0; i < segCount; i++) {
8353
10461
  const a = pts[i];
8354
10462
  const b = pts[(i + 1) % n];
8355
- dirs.push(unit3(sub4(b, a)));
10463
+ dirs.push(unit4(sub4(b, a)));
8356
10464
  lengths.push(lengths[i] + Math.hypot(b.x - a.x, b.y - a.y));
8357
10465
  }
8358
10466
  const total = lengths[segCount];
@@ -8446,7 +10554,7 @@ var parseJson = (text) => {
8446
10554
  if (text === void 0) return null;
8447
10555
  try {
8448
10556
  return JSON.parse(text);
8449
- } catch (e5) {
10557
+ } catch (e7) {
8450
10558
  return null;
8451
10559
  }
8452
10560
  };
@@ -8464,7 +10572,7 @@ function applyVectorCornersAttribute(subpaths, value) {
8464
10572
  for (const item of value.trim().split(/\s+/)) {
8465
10573
  const m = /^(\d+)\.(\d+):([\d.eE+-]+)(?::([a-z]+))?$/.exec(item);
8466
10574
  if (!m) continue;
8467
- const a = _optionalChain([subpaths, 'access', _205 => _205[+m[1]], 'optionalAccess', _206 => _206.anchors, 'access', _207 => _207[+m[2]]]);
10575
+ const a = _optionalChain([subpaths, 'access', _308 => _308[+m[1]], 'optionalAccess', _309 => _309.anchors, 'access', _310 => _310[+m[2]]]);
8468
10576
  const radius = parseFloat(m[3]);
8469
10577
  if (!a || !(radius > 0)) continue;
8470
10578
  const kind = VECTOR_CORNER_KINDS.includes(m[4]) ? m[4] : void 0;
@@ -8489,7 +10597,7 @@ function vectorPaintToSvg(paint, gradientId, options = {}) {
8489
10597
  const area2 = bounds2 ? { x: bounds2.x - reach2, y: bounds2.y - reach2, width: bounds2.width + 2 * reach2, height: bounds2.height + 2 * reach2 } : null;
8490
10598
  const key2 = `${gradientId}|${_nullishCoalesce(options.role, () => ( "fill"))}|${_nullishCoalesce(options.precision, () => ( 3))}|${area2 ? [area2.x, area2.y, area2.width, area2.height].join(",") : ""}`;
8491
10599
  let byKey2 = paintCache.get(paint);
8492
- const hit = _optionalChain([byKey2, 'optionalAccess', _208 => _208.get, 'call', _209 => _209(key2)]);
10600
+ const hit = _optionalChain([byKey2, 'optionalAccess', _311 => _311.get, 'call', _312 => _312(key2)]);
8493
10601
  if (hit) return { value: `url(#${gradientId})`, defs: hit };
8494
10602
  const defs2 = vectorShadedSvgDefs(paint, gradientId, { bounds: bounds2, area: area2, precision: _nullishCoalesce(options.precision, () => ( 3)) });
8495
10603
  if (!byKey2) paintCache.set(paint, byKey2 = /* @__PURE__ */ new Map());
@@ -8501,7 +10609,7 @@ function vectorPaintToSvg(paint, gradientId, options = {}) {
8501
10609
  const precision = _nullishCoalesce(options.precision, () => ( 3));
8502
10610
  const key = `${gradientId}|${role}|${precision}`;
8503
10611
  const owner = _nullishCoalesce(options.node, () => ( paint));
8504
- const cached = _optionalChain([paintCache, 'access', _210 => _210.get, 'call', _211 => _211(owner), 'optionalAccess', _212 => _212.get, 'call', _213 => _213(key)]);
10612
+ const cached = _optionalChain([paintCache, 'access', _313 => _313.get, 'call', _314 => _314(owner), 'optionalAccess', _315 => _315.get, 'call', _316 => _316(key)]);
8505
10613
  if (cached && (!options.node || (role === "fill" ? options.node.fill : options.node.stroke) === paint)) return { value: `url(#${gradientId})`, defs: cached };
8506
10614
  const node = options.node;
8507
10615
  const bounds = node ? vectorPathLocalBounds(node) : null;
@@ -8555,7 +10663,7 @@ function vectorNodeLocalPaintBounds(node) {
8555
10663
  }
8556
10664
  var filterCache = /* @__PURE__ */ new WeakMap();
8557
10665
  function vectorNodeFilterSvg(node, id) {
8558
- if (!_optionalChain([node, 'access', _214 => _214.filters, 'optionalAccess', _215 => _215.length])) return null;
10666
+ if (!_optionalChain([node, 'access', _317 => _317.filters, 'optionalAccess', _318 => _318.length])) return null;
8559
10667
  const hit = filterCache.get(node);
8560
10668
  if (hit && hit.id === id) return hit.filter;
8561
10669
  const active = activeVectorFilters(node);
@@ -8595,7 +10703,7 @@ function blendFromAttribute(value, m) {
8595
10703
  let raw;
8596
10704
  try {
8597
10705
  raw = JSON.parse(value);
8598
- } catch (e6) {
10706
+ } catch (e8) {
8599
10707
  return null;
8600
10708
  }
8601
10709
  if (!raw || typeof raw !== "object") return null;
@@ -8641,7 +10749,7 @@ function vectorDocumentToSvg(doc, options = {}) {
8641
10749
  if (node.type === "path" && node.lens) out2 += ` data-vector-lens="${escapeAttr2(JSON.stringify(node.lens))}"`;
8642
10750
  const blend = vectorBlendModeCss(node.blendMode);
8643
10751
  if (blend) out2 += ` style="mix-blend-mode:${blend}"`;
8644
- if (_optionalChain([node, 'access', _216 => _216.filters, 'optionalAccess', _217 => _217.length])) {
10752
+ if (_optionalChain([node, 'access', _319 => _319.filters, 'optionalAccess', _320 => _320.length])) {
8645
10753
  const filter = vectorNodeFilterSvg(node, `${prefix}filter-${node.id}`);
8646
10754
  const data = ` data-vector-filters="${escapeAttr2(JSON.stringify(node.filters))}"`;
8647
10755
  if (filter) {
@@ -8688,7 +10796,7 @@ function vectorDocumentToSvg(doc, options = {}) {
8688
10796
  let out2 = ` stroke="${escapeAttr2(strokeValue)}" stroke-width="${num3(width)}"`;
8689
10797
  if (node.strokeLinecap && node.strokeLinecap !== "butt") out2 += ` stroke-linecap="${node.strokeLinecap}"`;
8690
10798
  if (node.strokeLinejoin && node.strokeLinejoin !== "miter") out2 += ` stroke-linejoin="${node.strokeLinejoin}"`;
8691
- if (_optionalChain([node, 'access', _218 => _218.strokeDasharray, 'optionalAccess', _219 => _219.length])) out2 += ` stroke-dasharray="${node.strokeDasharray.map(num3).join(" ")}"`;
10799
+ if (_optionalChain([node, 'access', _321 => _321.strokeDasharray, 'optionalAccess', _322 => _322.length])) out2 += ` stroke-dasharray="${node.strokeDasharray.map(num3).join(" ")}"`;
8692
10800
  return out2;
8693
10801
  };
8694
10802
  const liveCorners = (node) => {
@@ -8710,7 +10818,7 @@ function vectorDocumentToSvg(doc, options = {}) {
8710
10818
  for (const l of layers) {
8711
10819
  if (l.kind === "stroke" && isVectorBrushstrokeLayer(l.layer)) {
8712
10820
  lines.push(`${indent(depth + 1)}<g data-vector-part="brushstroke" data-vector-layer="${l.index}"${layerAttrs(l.layer)}>`);
8713
- for (const im of vectorBrushstrokeImages(node, l.layer)) lines.push(`${indent(depth + 2)}<image href="${im.href}" x="${num3(im.x)}" y="${num3(im.y)}" width="${num3(im.width)}" height="${num3(im.height)}" preserveAspectRatio="none"/>`);
10821
+ for (const im of vectorBrushstrokeImages(node, l.layer, { document: doc, settle: "now" })) lines.push(`${indent(depth + 2)}<image href="${im.href}" x="${num3(im.x)}" y="${num3(im.y)}" width="${num3(im.width)}" height="${num3(im.height)}" preserveAspectRatio="none"/>`);
8714
10822
  lines.push(`${indent(depth + 1)}</g>`);
8715
10823
  continue;
8716
10824
  }
@@ -8737,7 +10845,7 @@ function vectorDocumentToSvg(doc, options = {}) {
8737
10845
  };
8738
10846
  const emit2 = (node, depth) => {
8739
10847
  if (node.visible === false && !options.includeHidden) return;
8740
- const wrappers = _nullishCoalesce(_optionalChain([options, 'access', _220 => _220.wrap, 'optionalAccess', _221 => _221[node.id]]), () => ( []));
10848
+ const wrappers = _nullishCoalesce(_optionalChain([options, 'access', _323 => _323.wrap, 'optionalAccess', _324 => _324[node.id]]), () => ( []));
8741
10849
  wrappers.forEach((w2, i) => {
8742
10850
  let attrs = w2.id !== void 0 ? ` id="${escapeAttr2(w2.id)}"` : "";
8743
10851
  if (w2.transform) attrs += ` transform="${escapeAttr2(w2.transform)}"`;
@@ -8758,7 +10866,7 @@ function vectorDocumentToSvg(doc, options = {}) {
8758
10866
  };
8759
10867
  const emitMaskGroup = (node, depth) => {
8760
10868
  const [source, ...contents] = node.children;
8761
- const body = _optionalChain([node, 'access', _222 => _222.effects, 'optionalAccess', _223 => _223.length]) && contents.length ? [{ id: `${node.id}~content`, type: "group", effects: node.effects, children: contents }] : contents;
10869
+ const body = _optionalChain([node, 'access', _325 => _325.effects, 'optionalAccess', _326 => _326.length]) && contents.length ? [{ id: `${node.id}~content`, type: "group", effects: node.effects, children: contents }] : contents;
8762
10870
  const settings = { type: node.mask.type, ...node.mask.invert ? { invert: true } : {} };
8763
10871
  lines.push(`${indent(depth)}<g${common(node)} data-vector-mask="${escapeAttr2(JSON.stringify(settings))}">`);
8764
10872
  const mask = vectorMaskRenderData(node, `${prefix}mask-${node.id}`, `${prefix}mask-filter-${node.id}`, precision);
@@ -8775,7 +10883,7 @@ function vectorDocumentToSvg(doc, options = {}) {
8775
10883
  lines.push(`${indent(depth + 1)}<g data-vector-part="mask-source" display="none">`);
8776
10884
  emitNode(source, depth + 2);
8777
10885
  lines.push(`${indent(depth + 1)}</g>`);
8778
- if (_optionalChain([mask, 'optionalAccess', _224 => _224.clip])) {
10886
+ if (_optionalChain([mask, 'optionalAccess', _327 => _327.clip])) {
8779
10887
  defs.push(`<clipPath id="${escapeAttr2(mask.id)}">${mask.clip.map((c) => `<path d="${c.d}" clip-rule="${c.clipRule}"/>`).join("")}</clipPath>`);
8780
10888
  ref = ` clip-path="url(#${escapeAttr2(mask.id)})"`;
8781
10889
  }
@@ -8787,7 +10895,7 @@ function vectorDocumentToSvg(doc, options = {}) {
8787
10895
  };
8788
10896
  const emitTextElement = (node, depth, attrs) => {
8789
10897
  const geometry = vectorTextGeometryNode(node);
8790
- const fields = { text: node.text, font: node.font, ..._optionalChain([node, 'access', _225 => _225.runs, 'optionalAccess', _226 => _226.length]) ? { runs: node.runs } : {}, ...node.paragraph ? { paragraph: node.paragraph } : {}, frame: node.frame, ...node.orientation ? { orientation: node.orientation } : {}, ..._optionalChain([node, 'access', _227 => _227.effects, 'optionalAccess', _228 => _228.length]) ? { effects: node.effects } : {} };
10898
+ const fields = { text: node.text, font: node.font, ..._optionalChain([node, 'access', _328 => _328.runs, 'optionalAccess', _329 => _329.length]) ? { runs: node.runs } : {}, ...node.paragraph ? { paragraph: node.paragraph } : {}, frame: node.frame, ...node.orientation ? { orientation: node.orientation } : {}, ..._optionalChain([node, 'access', _330 => _330.effects, 'optionalAccess', _331 => _331.length]) ? { effects: node.effects } : {} };
8791
10899
  let data = ` data-vector-text="${escapeAttr2(JSON.stringify(fields))}"`;
8792
10900
  if (hasVectorPaintStacks(node)) data += ` data-vector-fills="${escapeAttr2(JSON.stringify(vectorFills(node)))}" data-vector-strokes="${escapeAttr2(JSON.stringify(vectorStrokes(node)))}"`;
8793
10901
  else {
@@ -8829,12 +10937,12 @@ function vectorDocumentToSvg(doc, options = {}) {
8829
10937
  };
8830
10938
  const emitText = (node, depth) => {
8831
10939
  const outlines = vectorTextPaths(node).outlines;
8832
- const effects = !!_optionalChain([node, 'access', _229 => _229.effects, 'optionalAccess', _230 => _230.some, 'call', _231 => _231((e) => e.enabled !== false)]);
10940
+ const effects = !!_optionalChain([node, 'access', _332 => _332.effects, 'optionalAccess', _333 => _333.some, 'call', _334 => _334((e) => e.enabled !== false)]);
8833
10941
  if (!outlines || !effects && options.text !== "outlines") {
8834
10942
  emitTextElement(node, depth, common(node));
8835
10943
  return;
8836
10944
  }
8837
- lines.push(`${indent(depth)}<g${common(node)} data-vector-live="${escapeAttr2(JSON.stringify({ kind: "text", ..._optionalChain([node, 'access', _232 => _232.effects, 'optionalAccess', _233 => _233.length]) ? { effects: node.effects } : {} }))}">`);
10945
+ lines.push(`${indent(depth)}<g${common(node)} data-vector-live="${escapeAttr2(JSON.stringify({ kind: "text", ..._optionalChain([node, 'access', _335 => _335.effects, 'optionalAccess', _336 => _336.length]) ? { effects: node.effects } : {} }))}">`);
8838
10946
  lines.push(`${indent(depth + 1)}<g data-vector-part="appearance">`);
8839
10947
  for (const shape of vectorAppearanceNodes(node)) emit2(shape, depth + 2);
8840
10948
  lines.push(`${indent(depth + 1)}</g>`);
@@ -8848,7 +10956,7 @@ function vectorDocumentToSvg(doc, options = {}) {
8848
10956
  const symbolRef = (symbolId) => {
8849
10957
  const hit = symbolIds.get(symbolId);
8850
10958
  if (hit) return hit;
8851
- const sym2 = _optionalChain([doc, 'access', _234 => _234.symbols, 'optionalAccess', _235 => _235.find, 'call', _236 => _236((x) => x.id === symbolId)]);
10959
+ const sym2 = _optionalChain([doc, 'access', _337 => _337.symbols, 'optionalAccess', _338 => _338.find, 'call', _339 => _339((x) => x.id === symbolId)]);
8852
10960
  if (!sym2) return null;
8853
10961
  const id = `${prefix}symbol-${symbolId}`;
8854
10962
  symbolIds.set(symbolId, id);
@@ -8858,20 +10966,20 @@ function vectorDocumentToSvg(doc, options = {}) {
8858
10966
  };
8859
10967
  const emitInstance = (node, depth) => {
8860
10968
  const data = { symbolId: node.symbolId, ...node.scaleStrokes === false ? { scaleStrokes: false } : {}, ...node.overrides ? { overrides: node.overrides } : {} };
8861
- const exact2 = !node.overrides && node.scaleStrokes !== false && !_optionalChain([node, 'access', _237 => _237.effects, 'optionalAccess', _238 => _238.length]) && !_optionalChain([node, 'access', _239 => _239.filters, 'optionalAccess', _240 => _240.length]);
10969
+ const exact2 = !node.overrides && node.scaleStrokes !== false && !_optionalChain([node, 'access', _340 => _340.effects, 'optionalAccess', _341 => _341.length]) && !_optionalChain([node, 'access', _342 => _342.filters, 'optionalAccess', _343 => _343.length]);
8862
10970
  const ref = symbolRef(node.symbolId);
8863
10971
  if (exact2 && ref) {
8864
10972
  lines.push(`${indent(depth)}<use${common(node)} href="#${escapeAttr2(ref)}" data-vector-instance="${escapeAttr2(JSON.stringify(data))}"/>`);
8865
10973
  return;
8866
10974
  }
8867
- const full = { ...data, ...node.transform ? { transform: node.transform } : {}, ..._optionalChain([node, 'access', _241 => _241.effects, 'optionalAccess', _242 => _242.length]) ? { effects: node.effects } : {} };
10975
+ const full = { ...data, ...node.transform ? { transform: node.transform } : {}, ..._optionalChain([node, 'access', _344 => _344.effects, 'optionalAccess', _345 => _345.length]) ? { effects: node.effects } : {} };
8868
10976
  lines.push(`${indent(depth)}<g data-vector-instance="${escapeAttr2(JSON.stringify(full))}">`);
8869
10977
  emitNode(vectorInstanceDrawn(node), depth + 1);
8870
10978
  lines.push(`${indent(depth)}</g>`);
8871
10979
  };
8872
10980
  const emitFrame = (node, depth) => {
8873
10981
  const f = node.frame;
8874
- const data = { ...f, ..._optionalChain([node, 'access', _243 => _243.effects, 'optionalAccess', _244 => _244.length]) ? { effects: node.effects } : {} };
10982
+ const data = { ...f, ..._optionalChain([node, 'access', _346 => _346.effects, 'optionalAccess', _347 => _347.length]) ? { effects: node.effects } : {} };
8875
10983
  lines.push(`${indent(depth)}<g${common(node)} data-vector-frame="${escapeAttr2(JSON.stringify(data))}">`);
8876
10984
  const rect = vectorFrameRectPath(f);
8877
10985
  if (f.fill !== void 0 && f.fill !== null && f.fill !== "none") {
@@ -8886,7 +10994,7 @@ function vectorDocumentToSvg(doc, options = {}) {
8886
10994
  ref = ` clip-path="url(#${escapeAttr2(id)})"`;
8887
10995
  }
8888
10996
  lines.push(`${indent(depth + 1)}<g data-vector-part="frame-contents"${ref}>`);
8889
- if (_optionalChain([node, 'access', _245 => _245.masterArt, 'optionalAccess', _246 => _246.length])) {
10997
+ if (_optionalChain([node, 'access', _348 => _348.masterArt, 'optionalAccess', _349 => _349.length])) {
8890
10998
  lines.push(`${indent(depth + 2)}<g data-vector-part="frame-master">`);
8891
10999
  for (const child of node.masterArt) emit2(child, depth + 3);
8892
11000
  lines.push(`${indent(depth + 2)}</g>`);
@@ -8915,7 +11023,7 @@ function vectorDocumentToSvg(doc, options = {}) {
8915
11023
  if (hasOwnVectorAppearance(node)) {
8916
11024
  const live2 = {
8917
11025
  kind: node.type,
8918
- ..._optionalChain([node, 'access', _247 => _247.effects, 'optionalAccess', _248 => _248.length]) ? { effects: node.effects } : {},
11026
+ ..._optionalChain([node, 'access', _350 => _350.effects, 'optionalAccess', _351 => _351.length]) ? { effects: node.effects } : {},
8919
11027
  ...node.type === "group" && node.liveBoolean ? { liveBoolean: node.liveBoolean } : {},
8920
11028
  ...node.type === "group" && node.symmetry ? { symmetry: node.symmetry } : {}
8921
11029
  };
@@ -8966,7 +11074,7 @@ function vectorDocumentToSvg(doc, options = {}) {
8966
11074
  data += ` data-vector-width-profile="${widthProfileToAttribute(profile)}"`;
8967
11075
  if (node.strokeLinecap && node.strokeLinecap !== "butt") data += ` data-vector-stroke-linecap="${node.strokeLinecap}"`;
8968
11076
  if (node.strokeLinejoin && node.strokeLinejoin !== "miter") data += ` data-vector-stroke-linejoin="${node.strokeLinejoin}"`;
8969
- if (_optionalChain([node, 'access', _249 => _249.strokeDasharray, 'optionalAccess', _250 => _250.length])) data += ` data-vector-stroke-dasharray="${node.strokeDasharray.map(num3).join(" ")}"`;
11077
+ if (_optionalChain([node, 'access', _352 => _352.strokeDasharray, 'optionalAccess', _353 => _353.length])) data += ` data-vector-stroke-dasharray="${node.strokeDasharray.map(num3).join(" ")}"`;
8970
11078
  }
8971
11079
  lines.push(`${indent(depth)}<g${common(node)}${data}>`);
8972
11080
  lines.push(`${indent(depth + 1)}<path data-vector-part="fill" d="${d}"${fillAttrs}${live}/>`);
@@ -9147,7 +11255,7 @@ function readStyle(el, parent, cssRules) {
9147
11255
  const { mixBlendMode: _m, filter: _f, ...inherited } = parent;
9148
11256
  const out = { ...inherited };
9149
11257
  for (const [attr, key] of Object.entries(STYLE_KEYS)) if (el.attrs[attr] !== void 0) out[key] = el.attrs[attr].trim();
9150
- if (_optionalChain([cssRules, 'optionalAccess', _251 => _251.length])) {
11258
+ if (_optionalChain([cssRules, 'optionalAccess', _354 => _354.length])) {
9151
11259
  for (const rule of cssRules) {
9152
11260
  if (matchesSelector(el, rule.selector)) {
9153
11261
  for (const [prop, val] of Object.entries(rule.properties)) {
@@ -9203,7 +11311,7 @@ function attrOrStyle(el, name) {
9203
11311
  return el.attrs[name];
9204
11312
  }
9205
11313
  function urlId(value) {
9206
- return _nullishCoalesce(_optionalChain([/^url\(\s*['"]?#([^'")\s]+)['"]?\s*\)/, 'access', _252 => _252.exec, 'call', _253 => _253((_nullishCoalesce(value, () => ( ""))).trim()), 'optionalAccess', _254 => _254[1]]), () => ( null));
11314
+ return _nullishCoalesce(_optionalChain([/^url\(\s*['"]?#([^'")\s]+)['"]?\s*\)/, 'access', _355 => _355.exec, 'call', _356 => _356((_nullishCoalesce(value, () => ( ""))).trim()), 'optionalAccess', _357 => _357[1]]), () => ( null));
9207
11315
  }
9208
11316
  function clipRulesAsFillRules(el) {
9209
11317
  const attrs = { ...el.attrs };
@@ -9220,7 +11328,7 @@ function filtersFromElement(el) {
9220
11328
  if (own !== void 0) {
9221
11329
  try {
9222
11330
  return sanitizeVectorFilters(JSON.parse(own));
9223
- } catch (e7) {
11331
+ } catch (e9) {
9224
11332
  return [];
9225
11333
  }
9226
11334
  }
@@ -9254,7 +11362,7 @@ function gradientFromAttribute(value) {
9254
11362
  if (!value) return null;
9255
11363
  try {
9256
11364
  return sanitizeVectorGradient(JSON.parse(value));
9257
- } catch (e8) {
11365
+ } catch (e10) {
9258
11366
  return null;
9259
11367
  }
9260
11368
  }
@@ -9268,9 +11376,9 @@ function resolveGradient(id, raw) {
9268
11376
  for (let el = first; el && !chain.includes(el) && chain.length < 32; ) {
9269
11377
  chain.push(el);
9270
11378
  const href = _nullishCoalesce(el.attrs.href, () => ( el.attrs["xlink:href"]));
9271
- el = _optionalChain([href, 'optionalAccess', _255 => _255.startsWith, 'call', _256 => _256("#")]) ? raw.get(href.slice(1)) : void 0;
11379
+ el = _optionalChain([href, 'optionalAccess', _358 => _358.startsWith, 'call', _359 => _359("#")]) ? raw.get(href.slice(1)) : void 0;
9272
11380
  }
9273
- const attr = (name) => _optionalChain([chain, 'access', _257 => _257.find, 'call', _258 => _258((el) => el.attrs[name] !== void 0), 'optionalAccess', _259 => _259.attrs, 'access', _260 => _260[name]]);
11381
+ const attr = (name) => _optionalChain([chain, 'access', _360 => _360.find, 'call', _361 => _361((el) => el.attrs[name] !== void 0), 'optionalAccess', _362 => _362.attrs, 'access', _363 => _363[name]]);
9274
11382
  const stops = _nullishCoalesce(chain.map(readStops).find((s) => s.length), () => ( []));
9275
11383
  if (!stops.length) return null;
9276
11384
  const user = attr("gradientUnits") === "userSpaceOnUse";
@@ -9442,11 +11550,11 @@ function parseVectorSvg(svg, options = {}) {
9442
11550
  const stackedPath = (g, _style, m, meta) => {
9443
11551
  const fillEl = g.children.find((c) => c.name === "path" && c.attrs["data-vector-part"] === "fill");
9444
11552
  const subpaths = fillEl ? shapeOf(fillEl) : null;
9445
- if (!_optionalChain([subpaths, 'optionalAccess', _261 => _261.length])) return null;
11553
+ if (!_optionalChain([subpaths, 'optionalAccess', _364 => _364.length])) return null;
9446
11554
  const parse = (v2) => {
9447
11555
  try {
9448
11556
  return v2 ? JSON.parse(v2) : [];
9449
- } catch (e9) {
11557
+ } catch (e11) {
9450
11558
  return [];
9451
11559
  }
9452
11560
  };
@@ -9461,7 +11569,7 @@ function parseVectorSvg(svg, options = {}) {
9461
11569
  const key = (n) => JSON.stringify([n.subpaths, _nullishCoalesce(n.transform, () => ( null)), _nullishCoalesce(n.opacity, () => ( 1)), n.visible !== false, _nullishCoalesce(n.filters, () => ( null)), _nullishCoalesce(n.blendMode, () => ( "normal")), _nullishCoalesce(n.fillRule, () => ( "nonzero")), _nullishCoalesce(n.booleanOperation, () => ( null))]);
9462
11570
  for (const n of nodes2) {
9463
11571
  const prev = out[out.length - 1];
9464
- if (_optionalChain([prev, 'optionalAccess', _262 => _262.type]) === "path" && n.type === "path" && key(prev) === key(n)) {
11572
+ if (_optionalChain([prev, 'optionalAccess', _365 => _365.type]) === "path" && n.type === "path" && key(prev) === key(n)) {
9465
11573
  const fills = vectorFills(n);
9466
11574
  const strokesBefore = vectorStrokes(prev);
9467
11575
  if (!(fills.length && strokesBefore.length)) {
@@ -9479,7 +11587,7 @@ function parseVectorSvg(svg, options = {}) {
9479
11587
  const part = (name) => g.children.find((c) => c.name === "path" && c.attrs["data-vector-part"] === name);
9480
11588
  const fillEl = part("fill");
9481
11589
  const subpaths = fillEl ? shapeOf(fillEl) : null;
9482
- if (!fillEl || !_optionalChain([subpaths, 'optionalAccess', _263 => _263.length])) return null;
11590
+ if (!fillEl || !_optionalChain([subpaths, 'optionalAccess', _366 => _366.length])) return null;
9483
11591
  const a = g.attrs;
9484
11592
  const fs = readStyle(fillEl, style, styleRules);
9485
11593
  const strokeEl = part("stroke");
@@ -9516,7 +11624,7 @@ function parseVectorSvg(svg, options = {}) {
9516
11624
  ...profile.length ? { strokeWidthProfile: profile } : {},
9517
11625
  ...keptCap ? { strokeLinecap: keptCap } : {},
9518
11626
  ...keptJoin ? { strokeLinejoin: keptJoin } : {},
9519
- ..._optionalChain([keptDash, 'optionalAccess', _264 => _264.length]) ? { strokeDasharray: keptDash } : {}
11627
+ ..._optionalChain([keptDash, 'optionalAccess', _367 => _367.length]) ? { strokeDasharray: keptDash } : {}
9520
11628
  };
9521
11629
  return placed(node, m);
9522
11630
  };
@@ -9524,7 +11632,7 @@ function parseVectorSvg(svg, options = {}) {
9524
11632
  let raw = {};
9525
11633
  try {
9526
11634
  raw = _nullishCoalesce(JSON.parse(g.attrs["data-vector-live"]), () => ( {}));
9527
- } catch (e10) {
11635
+ } catch (e12) {
9528
11636
  raw = {};
9529
11637
  }
9530
11638
  const sourceEl = g.children.find((c) => c.name === "g" && c.attrs["data-vector-part"] === "source");
@@ -9560,7 +11668,7 @@ function parseVectorSvg(svg, options = {}) {
9560
11668
  const json2 = (v2) => {
9561
11669
  try {
9562
11670
  return v2 === void 0 ? void 0 : JSON.parse(v2);
9563
- } catch (e11) {
11671
+ } catch (e13) {
9564
11672
  return void 0;
9565
11673
  }
9566
11674
  };
@@ -9570,7 +11678,7 @@ function parseVectorSvg(svg, options = {}) {
9570
11678
  let fields;
9571
11679
  try {
9572
11680
  fields = sanitizeVectorTextFields(raw);
9573
- } catch (e12) {
11681
+ } catch (e14) {
9574
11682
  return null;
9575
11683
  }
9576
11684
  const effects = sanitizeVectorEffects(raw.effects);
@@ -9581,8 +11689,8 @@ function parseVectorSvg(svg, options = {}) {
9581
11689
  } else {
9582
11690
  const fill = json2(g.attrs["data-vector-fill"]);
9583
11691
  const stroke = json2(g.attrs["data-vector-stroke"]);
9584
- node.fill = fill == null ? null : _nullishCoalesce(_optionalChain([sanitizeVectorFills, 'call', _265 => _265([{ paint: fill }]), 'access', _266 => _266[0], 'optionalAccess', _267 => _267.paint]), () => ( null));
9585
- node.stroke = stroke == null ? null : _nullishCoalesce(_optionalChain([sanitizeVectorFills, 'call', _268 => _268([{ paint: stroke }]), 'access', _269 => _269[0], 'optionalAccess', _270 => _270.paint]), () => ( null));
11692
+ node.fill = fill == null ? null : _nullishCoalesce(_optionalChain([sanitizeVectorFills, 'call', _368 => _368([{ paint: fill }]), 'access', _369 => _369[0], 'optionalAccess', _370 => _370.paint]), () => ( null));
11693
+ node.stroke = stroke == null ? null : _nullishCoalesce(_optionalChain([sanitizeVectorFills, 'call', _371 => _371([{ paint: stroke }]), 'access', _372 => _372[0], 'optionalAccess', _373 => _373.paint]), () => ( null));
9586
11694
  const settings = json2(g.attrs["data-vector-stroke-settings"]);
9587
11695
  if (settings && typeof settings === "object") {
9588
11696
  const strokes = sanitizeVectorStrokes([{ paint: _nullishCoalesce(node.stroke, () => ( "#000")), ...settings }]);
@@ -9618,8 +11726,8 @@ function parseVectorSvg(svg, options = {}) {
9618
11726
  const anchor = attrOrStyle(el, "text-anchor");
9619
11727
  const first0 = (v2) => _nullishCoalesce(numberList(v2)[0], () => ( 0));
9620
11728
  const tspan = el.children.find((c) => c.name === "tspan");
9621
- const x = el.attrs.x !== void 0 ? first0(el.attrs.x) : first0(_optionalChain([tspan, 'optionalAccess', _271 => _271.attrs, 'access', _272 => _272.x]));
9622
- const y = el.attrs.y !== void 0 ? first0(el.attrs.y) : first0(_optionalChain([tspan, 'optionalAccess', _273 => _273.attrs, 'access', _274 => _274.y]));
11729
+ const x = el.attrs.x !== void 0 ? first0(el.attrs.x) : first0(_optionalChain([tspan, 'optionalAccess', _374 => _374.attrs, 'access', _375 => _375.x]));
11730
+ const y = el.attrs.y !== void 0 ? first0(el.attrs.y) : first0(_optionalChain([tspan, 'optionalAccess', _376 => _376.attrs, 'access', _377 => _377.y]));
9623
11731
  const fillValue = _nullishCoalesce(attrOrStyle(el, "fill"), () => ( style.fill));
9624
11732
  let node = {
9625
11733
  id: idFor(el),
@@ -9650,12 +11758,12 @@ function parseVectorSvg(svg, options = {}) {
9650
11758
  if (symbolOfElement.has(el)) return symbolOfElement.get(el);
9651
11759
  symbolOfElement.set(el, null);
9652
11760
  const own = json2(el.attrs["data-vector-symbol"]);
9653
- let id = typeof _optionalChain([own, 'optionalAccess', _275 => _275.id]) === "string" && own.id ? own.id : _nullishCoalesce(el.attrs.id, () => ( createId()));
11761
+ let id = typeof _optionalChain([own, 'optionalAccess', _378 => _378.id]) === "string" && own.id ? own.id : _nullishCoalesce(el.attrs.id, () => ( createId()));
9654
11762
  while (usedSymbolIds.has(id)) id = `${id}-${usedSymbolIds.size}`;
9655
11763
  usedSymbolIds.add(id);
9656
11764
  const style = readStyle(el, rootStyle, styleRules);
9657
11765
  const nodes2 = el.name === "symbol" ? visit2(el, style, IDENTITY_MATRIX) : visitOne({ ...el, attrs: { ...el.attrs, transform: "" } }, rootStyle, parseSvgTransform(el.attrs.transform));
9658
- symbols.push({ id, name: typeof _optionalChain([own, 'optionalAccess', _276 => _276.name]) === "string" && own.name ? own.name : _nullishCoalesce(el.attrs.id, () => ( "Symbol")), nodes: nodes2 });
11766
+ symbols.push({ id, name: typeof _optionalChain([own, 'optionalAccess', _379 => _379.name]) === "string" && own.name ? own.name : _nullishCoalesce(el.attrs.id, () => ( "Symbol")), nodes: nodes2 });
9659
11767
  symbolOfElement.set(el, id);
9660
11768
  return id;
9661
11769
  };
@@ -9666,22 +11774,22 @@ function parseVectorSvg(svg, options = {}) {
9666
11774
  const symbolId = symbolFor(target);
9667
11775
  if (!symbolId) return null;
9668
11776
  const own = json2(el.attrs["data-vector-instance"]);
9669
- const place2 = multiplyMatrices(translateMatrix(length(el.attrs.x), length(el.attrs.y)), m);
9670
- const node = { id: idFor(el), type: "instance", ...meta, symbolId, ..._optionalChain([own, 'optionalAccess', _277 => _277.scaleStrokes]) === false ? { scaleStrokes: false } : {}, ..._optionalChain([own, 'optionalAccess', _278 => _278.overrides]) ? { overrides: own.overrides } : {} };
9671
- return isIdentityMatrix(place2) ? node : { ...node, transform: place2 };
11777
+ const place3 = multiplyMatrices(translateMatrix(length(el.attrs.x), length(el.attrs.y)), m);
11778
+ const node = { id: idFor(el), type: "instance", ...meta, symbolId, ..._optionalChain([own, 'optionalAccess', _380 => _380.scaleStrokes]) === false ? { scaleStrokes: false } : {}, ..._optionalChain([own, 'optionalAccess', _381 => _381.overrides]) ? { overrides: own.overrides } : {} };
11779
+ return isIdentityMatrix(place3) ? node : { ...node, transform: place3 };
9672
11780
  };
9673
11781
  const ownInstance = (g, m, meta) => {
9674
11782
  const raw = json2(g.attrs["data-vector-instance"]);
9675
11783
  if (!raw || typeof raw.symbolId !== "string") return null;
9676
- const sym2 = [...byId.values()].find((e) => e.name === "symbol" && _optionalChain([json2, 'call', _279 => _279(e.attrs["data-vector-symbol"]), 'optionalAccess', _280 => _280.id]) === raw.symbolId);
11784
+ const sym2 = [...byId.values()].find((e) => e.name === "symbol" && _optionalChain([json2, 'call', _382 => _382(e.attrs["data-vector-symbol"]), 'optionalAccess', _383 => _383.id]) === raw.symbolId);
9677
11785
  const symbolId = sym2 ? symbolFor(sym2) : raw.symbolId;
9678
11786
  if (!symbolId) return null;
9679
11787
  const t = Array.isArray(raw.transform) && raw.transform.length === 6 && raw.transform.every(Number.isFinite) ? raw.transform : IDENTITY_MATRIX;
9680
- const place2 = multiplyMatrices(t, m);
11788
+ const place3 = multiplyMatrices(t, m);
9681
11789
  const drawn = g.children.find((c) => c.name === "g");
9682
11790
  const effects = sanitizeVectorEffects(raw.effects);
9683
11791
  const node = {
9684
- id: _nullishCoalesce(_optionalChain([drawn, 'optionalAccess', _281 => _281.attrs, 'access', _282 => _282.id]), () => ( idFor(g))),
11792
+ id: _nullishCoalesce(_optionalChain([drawn, 'optionalAccess', _384 => _384.attrs, 'access', _385 => _385.id]), () => ( idFor(g))),
9685
11793
  type: "instance",
9686
11794
  ...meta,
9687
11795
  symbolId,
@@ -9700,7 +11808,7 @@ function parseVectorSvg(svg, options = {}) {
9700
11808
  if (drawn.attrs.display === "none") node.visible = false;
9701
11809
  usedIds.add(node.id);
9702
11810
  }
9703
- return isIdentityMatrix(place2) ? node : { ...node, transform: place2 };
11811
+ return isIdentityMatrix(place3) ? node : { ...node, transform: place3 };
9704
11812
  };
9705
11813
  const visit2 = (el, style, matrix) => {
9706
11814
  const out = [];
@@ -9738,12 +11846,12 @@ function parseVectorSvg(svg, options = {}) {
9738
11846
  const masked = (el, nodes2, m) => {
9739
11847
  let out = nodes2;
9740
11848
  const clipEl = rawMasks.get(_nullishCoalesce(urlId(attrOrStyle(el, "clip-path")), () => ( "")));
9741
- if (_optionalChain([clipEl, 'optionalAccess', _283 => _283.name]) === "clipPath") {
11849
+ if (_optionalChain([clipEl, 'optionalAccess', _386 => _386.name]) === "clipPath") {
9742
11850
  const source = maskNode(clipEl, m, out, clipEl.attrs.clipPathUnits);
9743
11851
  if (source) out = [{ id: idFor({ name: "g", attrs: {}, children: [] }), type: "group", name: "Clip Group", mask: { type: "clip" }, children: [source, ...out] }];
9744
11852
  }
9745
11853
  const maskEl = rawMasks.get(_nullishCoalesce(urlId(attrOrStyle(el, "mask")), () => ( "")));
9746
- if (_optionalChain([maskEl, 'optionalAccess', _284 => _284.name]) === "mask") {
11854
+ if (_optionalChain([maskEl, 'optionalAccess', _387 => _387.name]) === "mask") {
9747
11855
  const source = maskNode(maskEl, m, out, maskEl.attrs.maskContentUnits);
9748
11856
  const type = attrOrStyle(maskEl, "mask-type") === "alpha" ? "alpha" : "luminance";
9749
11857
  if (source) out = [{ id: idFor({ name: "g", attrs: {}, children: [] }), type: "group", name: "Opacity Mask", mask: { type }, children: [source, ...out] }];
@@ -9754,7 +11862,7 @@ function parseVectorSvg(svg, options = {}) {
9754
11862
  let raw = null;
9755
11863
  try {
9756
11864
  raw = JSON.parse(g.attrs["data-vector-mask"]);
9757
- } catch (e13) {
11865
+ } catch (e15) {
9758
11866
  raw = null;
9759
11867
  }
9760
11868
  const mask = sanitizeVectorMask(raw);
@@ -9765,19 +11873,19 @@ function parseVectorSvg(svg, options = {}) {
9765
11873
  let sourceEl = part("mask-source");
9766
11874
  if (!sourceEl) {
9767
11875
  const el = rawMasks.get(_nullishCoalesce(urlId(maskedEl.attrs.mask), () => ( "")));
9768
- const invert2 = _optionalChain([el, 'optionalAccess', _285 => _285.children, 'access', _286 => _286.find, 'call', _287 => _287((c) => c.name === "g" && c.attrs["data-vector-part"] === "mask-invert")]);
11876
+ const invert2 = _optionalChain([el, 'optionalAccess', _388 => _388.children, 'access', _389 => _389.find, 'call', _390 => _390((c) => c.name === "g" && c.attrs["data-vector-part"] === "mask-invert")]);
9769
11877
  sourceEl = _nullishCoalesce(invert2, () => ( el));
9770
11878
  }
9771
11879
  const source = sourceEl ? visit2(sourceEl, style, m)[0] : void 0;
9772
11880
  let contents = visit2(maskedEl, style, m);
9773
11881
  let effects;
9774
11882
  const wrapper = contents.length === 1 && contents[0].type === "group" && contents[0].id === `${id}~content` ? contents[0] : null;
9775
- if (_optionalChain([wrapper, 'optionalAccess', _288 => _288.type]) === "group") {
11883
+ if (_optionalChain([wrapper, 'optionalAccess', _391 => _391.type]) === "group") {
9776
11884
  effects = _nullishCoalesce(wrapper.effects, () => ( void 0));
9777
11885
  contents = wrapper.children;
9778
11886
  }
9779
11887
  if (!source) return contents.length ? { id, type: "group", ...meta, children: contents } : null;
9780
- return { id, type: "group", ...meta, mask, ..._optionalChain([effects, 'optionalAccess', _289 => _289.length]) ? { effects } : {}, children: [source, ...contents] };
11888
+ return { id, type: "group", ...meta, mask, ..._optionalChain([effects, 'optionalAccess', _392 => _392.length]) ? { effects } : {}, children: [source, ...contents] };
9781
11889
  };
9782
11890
  const frameGroup = (g, style, m, meta) => {
9783
11891
  const raw = parseJson(g.attrs["data-vector-frame"]);
@@ -9789,7 +11897,7 @@ function parseVectorSvg(svg, options = {}) {
9789
11897
  const { rigid, residual } = decomposeRigid(m);
9790
11898
  const r = _chunkGF2RBSDMcjs.bezierPathBounds.call(void 0, _chunkGF2RBSDMcjs.transformBezierPath.call(void 0, subpathsToBezier(vectorFrameRectPath(frame)), residual));
9791
11899
  const back = invertMatrix(rigid);
9792
- const effects = sanitizeVectorEffects(_optionalChain([raw, 'optionalAccess', _290 => _290.effects]));
11900
+ const effects = sanitizeVectorEffects(_optionalChain([raw, 'optionalAccess', _393 => _393.effects]));
9793
11901
  return {
9794
11902
  id,
9795
11903
  type: "group",
@@ -9826,7 +11934,7 @@ function parseVectorSvg(svg, options = {}) {
9826
11934
  if (child.attrs["data-vector-generation"] !== void 0) {
9827
11935
  try {
9828
11936
  meta.generation = _chunkCVFAAZXEcjs.parseProvenance.call(void 0, parseJson(child.attrs["data-vector-generation"]));
9829
- } catch (e14) {
11937
+ } catch (e16) {
9830
11938
  }
9831
11939
  }
9832
11940
  const lens = child.attrs["data-vector-lens"] !== void 0 ? sanitizeVectorLens(parseJson(child.attrs["data-vector-lens"])) : null;
@@ -10261,13 +12369,13 @@ function hitTestVectorNode(node, p, tolerance = 0, parent = IDENTITY_MATRIX, opt
10261
12369
  }
10262
12370
  if (isVectorMaskGroup(node)) {
10263
12371
  const m = multiplyMatrices(nodeMatrix(node), parent);
10264
- const entered = !!_optionalChain([options, 'access', _291 => _291.entered, 'optionalAccess', _292 => _292.has, 'call', _293 => _293(node.id)]);
12372
+ const entered = !!_optionalChain([options, 'access', _394 => _394.entered, 'optionalAccess', _395 => _395.has, 'call', _396 => _396(node.id)]);
10265
12373
  if (!entered && isVectorMaskActive(node) && !vectorMaskContains(node, applyMatrix(invertMatrix(m), p), tolerance)) return false;
10266
12374
  const shown = !entered && hasOwnVectorAppearance(node) ? expandVectorAppearance(node).children : node.children;
10267
12375
  for (let i = shown.length - 1; i >= 1; i--) if (hitTestVectorNode(shown[i], p, tolerance, m, options)) return true;
10268
12376
  return entered && hitTestVectorMaskSource(node, p, tolerance, m, options);
10269
12377
  }
10270
- if (!(node.type === "group" && (!hasOwnVectorAppearance(node) || _optionalChain([options, 'access', _294 => _294.entered, 'optionalAccess', _295 => _295.has, 'call', _296 => _296(node.id)])))) node = expandVectorAppearance(node);
12378
+ if (!(node.type === "group" && (!hasOwnVectorAppearance(node) || _optionalChain([options, 'access', _397 => _397.entered, 'optionalAccess', _398 => _398.has, 'call', _399 => _399(node.id)])))) node = expandVectorAppearance(node);
10271
12379
  if (node.type === "group") {
10272
12380
  const m = multiplyMatrices(nodeMatrix(node), parent);
10273
12381
  return node.children.some((c) => hitTestVectorNode(c, p, tolerance, m, options));
@@ -10279,7 +12387,7 @@ function hitTestVectorNode(node, p, tolerance = 0, parent = IDENTITY_MATRIX, opt
10279
12387
  function hitTestVectorMaskSource(group, p, tolerance, m, options) {
10280
12388
  const source = group.children[0];
10281
12389
  if (source.visible === false) return false;
10282
- if (_optionalChain([group, 'access', _297 => _297.mask, 'optionalAccess', _298 => _298.type]) !== "clip") return hitTestVectorNode(source, p, tolerance, m, options);
12390
+ if (_optionalChain([group, 'access', _400 => _400.mask, 'optionalAccess', _401 => _401.type]) !== "clip") return hitTestVectorNode(source, p, tolerance, m, options);
10283
12391
  const paths = collectPathNodes(source).filter((n) => n.visible !== false);
10284
12392
  const pt2 = [p.x, p.y];
10285
12393
  return paths.some((n) => {
@@ -10328,24 +12436,24 @@ function mapAnchor(a, m) {
10328
12436
  }
10329
12437
  function bakeIntoGeometry(node, m) {
10330
12438
  if (isIdentityMatrix(m)) return node;
10331
- if (_optionalChain([node, 'access', _299 => _299.effects, 'optionalAccess', _300 => _300.length])) node = { ...node, effects: transformVectorEffects(node.effects, m, node) };
12439
+ if (_optionalChain([node, 'access', _402 => _402.effects, 'optionalAccess', _403 => _403.length])) node = { ...node, effects: transformVectorEffects(node.effects, m, node) };
10332
12440
  if (isVectorFrame(node)) return bakeFrame(node, m);
10333
12441
  if (node.type === "group") {
10334
12442
  const group = node;
10335
12443
  const children = group.children.map((c) => transformVectorNode(c, m));
10336
12444
  const sym2 = group.symmetry ? { symmetry: transformVectorSymmetry(group.symmetry, m) } : {};
10337
- const spine = _optionalChain([group, 'access', _301 => _301.blend, 'optionalAccess', _302 => _302.spine]);
12445
+ const spine = _optionalChain([group, 'access', _404 => _404.blend, 'optionalAccess', _405 => _405.spine]);
10338
12446
  if (!spine) return { ...group, ...sym2, children };
10339
12447
  const moved = { closed: spine.closed, anchors: spine.anchors.map((a) => mapAnchor(a, m)) };
10340
12448
  return { ...group, children, blend: { ...group.blend, spine: moved } };
10341
12449
  }
10342
12450
  const path = node.type === "text" ? bakeVectorTextGeometry(node, m) : node;
10343
12451
  const flips = m[0] * m[3] - m[1] * m[2] < 0;
10344
- const mirrored = flips && _optionalChain([path, 'access', _303 => _303.strokeWidthProfile, 'optionalAccess', _304 => _304.length]);
12452
+ const mirrored = flips && _optionalChain([path, 'access', _406 => _406.strokeWidthProfile, 'optionalAccess', _407 => _407.length]);
10345
12453
  const layer = (l) => ({
10346
12454
  ...l,
10347
12455
  ...isVectorGradient(l.paint) || isVectorShadedPaint(l.paint) ? { paint: transformVectorPaint(l.paint, m) } : {},
10348
- ...flips && _optionalChain([l, 'access', _305 => _305.strokeWidthProfile, 'optionalAccess', _306 => _306.length]) ? { strokeWidthProfile: mirrorWidthProfile(l.strokeWidthProfile) } : {}
12456
+ ...flips && _optionalChain([l, 'access', _408 => _408.strokeWidthProfile, 'optionalAccess', _409 => _409.length]) ? { strokeWidthProfile: mirrorWidthProfile(l.strokeWidthProfile) } : {}
10349
12457
  });
10350
12458
  return {
10351
12459
  ...path,
@@ -10580,7 +12688,7 @@ function roundSubpaths(subpaths, precision = 3) {
10580
12688
 
10581
12689
  // src/vector/symmetry.ts
10582
12690
  function isVectorSymmetryGroup(node) {
10583
- return _optionalChain([node, 'optionalAccess', _307 => _307.type]) === "group" && !!node.symmetry && !node.blend && !node.liveBoolean && !node.mask && !node.frame;
12691
+ return _optionalChain([node, 'optionalAccess', _410 => _410.type]) === "group" && !!node.symmetry && !node.blend && !node.liveBoolean && !node.mask && !node.frame;
10584
12692
  }
10585
12693
  var rad = (deg) => deg * Math.PI / 180;
10586
12694
  var exact = (v2) => Math.abs(v2) < 1e-12 ? 0 : v2;
@@ -11169,4 +13277,57 @@ function transformVectorSymmetry(s, m) {
11169
13277
 
11170
13278
 
11171
13279
 
11172
- exports.isVectorMeshGradient = isVectorMeshGradient; exports.isVectorFreeformGradient = isVectorFreeformGradient; exports.isVectorShadedPaint = isVectorShadedPaint; exports.vectorRgbaToCss = vectorRgbaToCss; exports.VECTOR_MESH_MAX = VECTOR_MESH_MAX; exports.createVectorMeshGradient = createVectorMeshGradient; exports.vectorMeshPointAt = vectorMeshPointAt; exports.vectorMeshColorAt = vectorMeshColorAt; exports.vectorMeshLines = vectorMeshLines; exports.vectorFreeformSpreadScale = vectorFreeformSpreadScale; exports.vectorFreeformLineSegments = vectorFreeformLineSegments; exports.vectorFreeformField = vectorFreeformField; exports.sampleVectorFreeform = sampleVectorFreeform; exports.autoVectorFreeformGradient = autoVectorFreeformGradient; exports.vectorShadedSvgDefs = vectorShadedSvgDefs; exports.mapVectorShadedPaint = mapVectorShadedPaint; exports.transformVectorShadedPaint = transformVectorShadedPaint; exports.sanitizeVectorShadedPaint = sanitizeVectorShadedPaint; exports.removeVectorFreeformPoint = removeVectorFreeformPoint; exports.nearestVectorShadingPoint = nearestVectorShadingPoint; exports.VECTOR_CORNER_KINDS = VECTOR_CORNER_KINDS; exports.VECTOR_GRADIENT_TYPES = VECTOR_GRADIENT_TYPES; exports.VECTOR_GRADIENT_SPREADS = VECTOR_GRADIENT_SPREADS; exports.VECTOR_GRADIENT_INTERPOLATIONS = VECTOR_GRADIENT_INTERPOLATIONS; exports.VECTOR_STROKE_GRADIENT_MODES = VECTOR_STROKE_GRADIENT_MODES; exports.VECTOR_ARROWHEADS = VECTOR_ARROWHEADS; exports.VECTOR_BLEND_MODES = VECTOR_BLEND_MODES; exports.VECTOR_HORIZONTAL_RESIZING = VECTOR_HORIZONTAL_RESIZING; exports.VECTOR_VERTICAL_RESIZING = VECTOR_VERTICAL_RESIZING; exports.VECTOR_LENS_TYPES = VECTOR_LENS_TYPES; exports.VECTOR_CONNECTOR_SIDES = VECTOR_CONNECTOR_SIDES; exports.VECTOR_CONNECTOR_ROUTES = VECTOR_CONNECTOR_ROUTES; exports.VECTOR_BLEND_SPACINGS = VECTOR_BLEND_SPACINGS; exports.VECTOR_MASK_TYPES = VECTOR_MASK_TYPES; exports.VECTOR_SYMMETRY_MODES = VECTOR_SYMMETRY_MODES; exports.VECTOR_TEXT_ALIGNS = VECTOR_TEXT_ALIGNS; exports.VECTOR_PATH_TEXT_BASELINES = VECTOR_PATH_TEXT_BASELINES; exports.VECTOR_PERSPECTIVE_PLANES = VECTOR_PERSPECTIVE_PLANES; exports.VECTOR_CONSTRAINT_KINDS = VECTOR_CONSTRAINT_KINDS; exports.VECTOR_TOOLS = VECTOR_TOOLS; exports.VECTOR_TRANSFORM_HANDLES = VECTOR_TRANSFORM_HANDLES; exports.VECTOR_PATHFINDER_OPERATIONS = VECTOR_PATHFINDER_OPERATIONS; exports.VECTOR_EFFECT_TYPES = VECTOR_EFFECT_TYPES; exports.VECTOR_MERGE_MODES = VECTOR_MERGE_MODES; exports.VECTOR_FILTER_TYPES = VECTOR_FILTER_TYPES; exports.isVectorGradient = isVectorGradient; exports.parseVectorColor = parseVectorColor; exports.VECTOR_GRADIENT_MIN_STOPS = VECTOR_GRADIENT_MIN_STOPS; exports.gradientMidpointRemap = gradientMidpointRemap; exports.sortedVectorGradientStops = sortedVectorGradientStops; exports.vectorGradientNeedsExpansion = vectorGradientNeedsExpansion; exports.vectorGradientRamp = vectorGradientRamp; exports.sampleVectorGradient = sampleVectorGradient; exports.expandVectorGradientStops = expandVectorGradientStops; exports.samplePlainStops = samplePlainStops; exports.reverseVectorGradient = reverseVectorGradient; exports.insertVectorGradientStop = insertVectorGradientStop; exports.moveVectorGradientStop = moveVectorGradientStop; exports.removeVectorGradientStop = removeVectorGradientStop; exports.vectorGradientMidpointPosition = vectorGradientMidpointPosition; exports.vectorGradientMidpointFromPosition = vectorGradientMidpointFromPosition; exports.spanVectorGradientStops = spanVectorGradientStops; exports.hasExplicitGradientGeometry = hasExplicitGradientGeometry; exports.vectorGradientPoints = vectorGradientPoints; exports.vectorBoxMatrix = vectorBoxMatrix; exports.vectorGradientUnitsMatrix = vectorGradientUnitsMatrix; exports.vectorGradientMatrix = vectorGradientMatrix; exports.vectorGradientFocalParam = vectorGradientFocalParam; exports.vectorGradientParam = vectorGradientParam; exports.applyVectorGradientSpread = applyVectorGradientSpread; exports.vectorGradientTAt = vectorGradientTAt; exports.sampleVectorGradientAt = sampleVectorGradientAt; exports.vectorGradientAspect = vectorGradientAspect; exports.explicitVectorGradient = explicitVectorGradient; exports.pinVectorGradient = pinVectorGradient; exports.transformVectorGradient = transformVectorGradient; exports.mapVectorGradient = mapVectorGradient; exports.mapVectorPaint = mapVectorPaint; exports.transformVectorPaint = transformVectorPaint; exports.isCentredVectorGradient = isCentredVectorGradient; exports.vectorGradientHandles = vectorGradientHandles; exports.moveVectorGradientHandle = moveVectorGradientHandle; exports.setVectorGradientVector = setVectorGradientVector; exports.VECTOR_GRADIENT_MAX_PERIODS = VECTOR_GRADIENT_MAX_PERIODS; exports.periodicVectorGradientStops = periodicVectorGradientStops; exports.expandVectorGradientSpread = expandVectorGradientSpread; exports.vectorGradientArea = vectorGradientArea; exports.patternAttrs = patternAttrs; exports.vectorGradientSvgDefs = vectorGradientSvgDefs; exports.sampleVectorPaintDefAt = sampleVectorPaintDefAt; exports.sanitizeVectorGradient = sanitizeVectorGradient; exports.convertVectorGradient = convertVectorGradient; exports.defaultVectorGradient = defaultVectorGradient; exports.applyVectorGradientPatch = applyVectorGradientPatch; exports.IDENTITY_MATRIX = IDENTITY_MATRIX; exports.multiplyMatrices = multiplyMatrices; exports.translateMatrix = translateMatrix; exports.scaleMatrix = scaleMatrix; exports.rotateMatrix = rotateMatrix; exports.matrixAbout = matrixAbout; exports.skewMatrix = skewMatrix; exports.applyMatrix = applyMatrix; exports.isIdentityMatrix = isIdentityMatrix; exports.invertMatrix = invertMatrix; exports.applyMatrixLinear = applyMatrixLinear; exports.matrixRotation = matrixRotation; exports.decomposeRigid = decomposeRigid; exports.isVectorSymmetryGroup = isVectorSymmetryGroup; exports.vectorSymmetryMatrices = vectorSymmetryMatrices; exports.vectorSymmetryDrawn = vectorSymmetryDrawn; exports.vectorSymmetryAxes = vectorSymmetryAxes; exports.sanitizeVectorSymmetry = sanitizeVectorSymmetry; exports.VECTOR_SYMMETRY_MODE_LABELS = VECTOR_SYMMETRY_MODE_LABELS; exports.transformVectorSymmetry = transformVectorSymmetry; exports.vectorCornerAt = vectorCornerAt; exports.vectorCorners = vectorCorners; exports.cornerSetback = cornerSetback; exports.fitCornerRadius = fitCornerRadius; exports.cornerBisectorPoint = cornerBisectorPoint; exports.cornerRadiusChange = cornerRadiusChange; exports.hasVectorCorners = hasVectorCorners; exports.expandVectorCornersOf = expandVectorCornersOf; exports.expandVectorCorners = expandVectorCorners; exports.setAnchorCorner = setAnchorCorner; exports.nextVectorCornerKind = nextVectorCornerKind; exports.setSubpathCorners = setSubpathCorners; exports.VECTOR_WIDTH_PROFILE_MAX_POINTS = VECTOR_WIDTH_PROFILE_MAX_POINTS; exports.VECTOR_WIDTH_PROFILE_MAX_SCALE = VECTOR_WIDTH_PROFILE_MAX_SCALE; exports.VECTOR_WIDTH_SAME_T = VECTOR_WIDTH_SAME_T; exports.VECTOR_WIDTH_PRESETS = VECTOR_WIDTH_PRESETS; exports.VECTOR_WIDTH_PRESET_IDS = VECTOR_WIDTH_PRESET_IDS; exports.sanitizeWidthProfile = sanitizeWidthProfile; exports.isUniformWidthProfile = isUniformWidthProfile; exports.widthProfileAt = widthProfileAt; exports.widthProfileMaxScale = widthProfileMaxScale; exports.widthProfilePreset = widthProfilePreset; exports.widthProfilePresetId = widthProfilePresetId; exports.reverseWidthProfile = reverseWidthProfile; exports.mirrorWidthProfile = mirrorWidthProfile; exports.insertWidthPoint = insertWidthPoint; exports.setWidthPoint = setWidthPoint; exports.removeWidthPoints = removeWidthPoints; exports.taperWaveFactor = taperWaveFactor; exports.generateWidthProfile = generateWidthProfile; exports.VECTOR_PRESSURE_NOMINAL = VECTOR_PRESSURE_NOMINAL; exports.pressureWidthProfile = pressureWidthProfile; exports.dashIntervals = dashIntervals; exports.variableStrokeRings = variableStrokeRings; exports.variableStrokeOutline = variableStrokeOutline; exports.nearestStrokePosition = nearestStrokePosition; exports.strokePositionPoint = strokePositionPoint; exports.isClosedBezierShape = isClosedBezierShape; exports.effectiveStrokeAlign = effectiveStrokeAlign; exports.strokeWidthProfileOf = strokeWidthProfileOf; exports.hasStrokeExtras = hasStrokeExtras; exports.vectorStrokeLineArea = vectorStrokeLineArea; exports.arrowheadWeight = arrowheadWeight; exports.arrowheadInset = arrowheadInset; exports.arrowheadPath = arrowheadPath; exports.vectorStrokeParts = vectorStrokeParts; exports.vectorStrokeOutlinePath = vectorStrokeOutlinePath; exports.hitTestVectorStroke = hitTestVectorStroke; exports.vectorStrokeReach = vectorStrokeReach; exports.vectorPaintSolid = vectorPaintSolid; exports.shadeVectorColor = shadeVectorColor; exports.vectorPathRings = vectorPathRings; exports.vectorExtrudeFaces = vectorExtrudeFaces; exports.VECTOR_BRUSHSTROKE_SCALE = VECTOR_BRUSHSTROKE_SCALE; exports.vectorBrushstrokeBrushes = vectorBrushstrokeBrushes; exports.vectorBrushstrokeBrush = vectorBrushstrokeBrush; exports.vectorBrushstrokeBrushOf = vectorBrushstrokeBrushOf; exports.vectorBrushstrokeBrushError = vectorBrushstrokeBrushError; exports.vectorBrushstrokeDefaultColour = vectorBrushstrokeDefaultColour; exports.sanitizeVectorBrushstroke = sanitizeVectorBrushstroke; exports.VECTOR_BRUSHSTROKE_MAX_SEED = VECTOR_BRUSHSTROKE_MAX_SEED; exports.sanitizeVectorBrushstrokePaper = sanitizeVectorBrushstrokePaper; exports.vectorBrushstrokeCharacterError = vectorBrushstrokeCharacterError; exports.randomVectorBrushstrokeSeed = randomVectorBrushstrokeSeed; exports.isVectorBrushstrokeLayer = isVectorBrushstrokeLayer; exports.vectorBrushstrokeReach = vectorBrushstrokeReach; exports.vectorBrushstrokeImages = vectorBrushstrokeImages; exports.VECTOR_STROKE_SETTING_KEYS = VECTOR_STROKE_SETTING_KEYS; exports.VECTOR_BLEND_MODE_LABELS = VECTOR_BLEND_MODE_LABELS; exports.isVectorBlendMode = isVectorBlendMode; exports.vectorBlendModeCss = vectorBlendModeCss; exports.vectorBlendModeFromCss = vectorBlendModeFromCss; exports.isPlainVectorPaintLayer = isPlainVectorPaintLayer; exports.isDrawnVectorPaintLayer = isDrawnVectorPaintLayer; exports.vectorFills = vectorFills; exports.vectorStrokeSettings = vectorStrokeSettings; exports.vectorStrokes = vectorStrokes; exports.hasVectorPaintStacks = hasVectorPaintStacks; exports.withVectorFills = withVectorFills; exports.withVectorStrokes = withVectorStrokes; exports.normalizeVectorPaintStacks = normalizeVectorPaintStacks; exports.sanitizeVectorFills = sanitizeVectorFills; exports.sanitizeVectorStrokeSettings = sanitizeVectorStrokeSettings; exports.sanitizeVectorStrokes = sanitizeVectorStrokes; exports.vectorPaintLayerNodes = vectorPaintLayerNodes; exports.needsVectorPaintLayers = needsVectorPaintLayers; exports.vectorStrokeStackReach = vectorStrokeStackReach; exports.hitTestVectorPaintLayer = hitTestVectorPaintLayer; exports.hitTestVectorPaintStack = hitTestVectorPaintStack; exports.vectorStacksHaveGradient = vectorStacksHaveGradient; exports.newVectorStrokeLayer = newVectorStrokeLayer; exports.vectorTargetPaint = vectorTargetPaint; exports.withVectorTargetPaint = withVectorTargetPaint; exports.effectPathLength = effectPathLength; exports.effectPathVertexCount = effectPathVertexCount; exports.trimIntervals = trimIntervals; exports.trimPaths = trimPaths; exports.trimPathsIndividually = trimPathsIndividually; exports.puckerBloatPaths = puckerBloatPaths; exports.roundCornerPaths = roundCornerPaths; exports.offsetPaths = offsetPaths; exports.sweepPath = sweepPath; exports.twistPaths = twistPaths; exports.zigzagPaths = zigzagPaths; exports.wigglePaths = wigglePaths; exports.mergePaths = mergePaths; exports.vectorRepeaterCopies = vectorRepeaterCopies; exports.repeatPaths = repeatPaths; exports.pathsCenter = pathsCenter; exports.mapVectorPoints = mapVectorPoints; exports.mapVectorSubpaths = mapVectorSubpaths; exports.mapBezierPath = mapBezierPath; exports.isVectorFrame = isVectorFrame; exports.vectorFrameRectPath = vectorFrameRectPath; exports.vectorFrameDrawn = vectorFrameDrawn; exports.vectorFrameContains = vectorFrameContains; exports.vectorFrameChildMatrix = vectorFrameChildMatrix; exports.sanitizeVectorFrame = sanitizeVectorFrame; exports.sanitizeVectorResizing = sanitizeVectorResizing; exports.VECTOR_HORIZONTAL_RESIZING_LABELS = VECTOR_HORIZONTAL_RESIZING_LABELS; exports.VECTOR_VERTICAL_RESIZING_LABELS = VECTOR_VERTICAL_RESIZING_LABELS; exports.vectorBoundsInside = vectorBoundsInside; exports.vectorArtboards = vectorArtboards; exports.vectorFrameDocument = vectorFrameDocument; exports.getVectorFramePanel = getVectorFramePanel; exports.splitIntoFaces = splitIntoFaces; exports.knifePath = knifePath; exports.eraserRegion = eraserRegion; exports.eraseFromFill = eraseFromFill; exports.eraseFromOutline = eraseFromOutline; exports.polylineBounds = polylineBounds; exports.simplifyPolyline = simplifyPolyline; exports.VECTOR_FILTER_DEFAULTS = VECTOR_FILTER_DEFAULTS; exports.VECTOR_FILTER_LABELS = VECTOR_FILTER_LABELS; exports.VECTOR_FILTER_PARAM_SPECS = VECTOR_FILTER_PARAM_SPECS; exports.isVectorFilterType = isVectorFilterType; exports.normalizeVectorFilterParams = normalizeVectorFilterParams; exports.vectorFilterParamKeys = vectorFilterParamKeys; exports.createVectorFilter = createVectorFilter; exports.sanitizeVectorFilters = sanitizeVectorFilters; exports.activeVectorFilters = activeVectorFilters; exports.vectorFilterReach = vectorFilterReach; exports.vectorFilterSvg = vectorFilterSvg; exports.vectorFilterMarkup = vectorFilterMarkup; exports.VECTOR_FILTER_MENU = VECTOR_FILTER_MENU; exports.isVectorMaskType = isVectorMaskType; exports.sanitizeVectorMask = sanitizeVectorMask; exports.isVectorMaskGroup = isVectorMaskGroup; exports.isVectorMaskActive = isVectorMaskActive; exports.vectorMaskSource = vectorMaskSource; exports.vectorMaskContents = vectorMaskContents; exports.vectorMaskOwner = vectorMaskOwner; exports.vectorMaskSummary = vectorMaskSummary; exports.vectorMaskRegionShapes = vectorMaskRegionShapes; exports.vectorMaskRegion = vectorMaskRegion; exports.vectorMaskRegionPath = vectorMaskRegionPath; exports.vectorMaskContains = vectorMaskContains; exports.vectorMaskedShapes = vectorMaskedShapes; exports.vectorMaskedGeometry = vectorMaskedGeometry; exports.vectorMaskedLocalBounds = vectorMaskedLocalBounds; exports.vectorMaskContentBounds = vectorMaskContentBounds; exports.vectorMaskRenderData = vectorMaskRenderData; exports.DEFAULT_TEXT_STYLE = DEFAULT_TEXT_STYLE; exports.DEFAULT_AUTO_LEADING = DEFAULT_AUTO_LEADING; exports.fitRuns = fitRuns; exports.styleAt = styleAt; exports.restyleRange = restyleRange; exports.spliceRuns = spliceRuns; exports.paragraphRanges = paragraphRanges; exports.fitParagraphRuns = fitParagraphRuns; exports.fontOf = fontOf; exports.transformTextRect = transformTextRect; exports.lineToTextSpace = lineToTextSpace; exports.layoutText = layoutText; exports.textIndexAt = textIndexAt; exports.caretAt = caretAt; exports.textSelectionQuads = textSelectionQuads; exports.textArrowStep = textArrowStep; exports.textLineMove = textLineMove; exports.textDecorations = textDecorations; exports.textRectPath = textRectPath; exports.textFragmentOutline = textFragmentOutline; exports.drawTextFragment = drawTextFragment; exports.cssFontFamily = cssFontFamily; exports.cssFont = cssFont; exports.createCanvasTextShaper = createCanvasTextShaper; exports.createOutlineTextShaper = createOutlineTextShaper; exports.createMetricTextShaper = createMetricTextShaper; exports.setVectorTextShaper = setVectorTextShaper; exports.getVectorTextShaper = getVectorTextShaper; exports.vectorTextShaperGeneration = vectorTextShaperGeneration; exports.vectorTextHasOutlines = vectorTextHasOutlines; exports.vectorTextFamilies = vectorTextFamilies; exports.DEFAULT_VECTOR_FONT = DEFAULT_VECTOR_FONT; exports.VECTOR_CHARACTER_STYLE_KEYS = VECTOR_CHARACTER_STYLE_KEYS; exports.VECTOR_PARAGRAPH_STYLE_KEYS = VECTOR_PARAGRAPH_STYLE_KEYS; exports.VectorTextError = VectorTextError; exports.fitVectorTextRuns = fitVectorTextRuns; exports.vectorTextRuns = vectorTextRuns; exports.vectorTextStyleAt = vectorTextStyleAt; exports.measureVectorPath = measureVectorPath; exports.vectorPathAt = vectorPathAt; exports.vectorPathTextPositions = vectorPathTextPositions; exports.layoutVectorText = layoutVectorText; exports.glyphBox = glyphBox; exports.vectorTextPaths = vectorTextPaths; exports.vectorTextPaintSource = vectorTextPaintSource; exports.vectorTextCaret = vectorTextCaret; exports.vectorTextIndexAt = vectorTextIndexAt; exports.vectorTextSelectionQuads = vectorTextSelectionQuads; exports.patchVectorCharacterStyle = patchVectorCharacterStyle; exports.patchVectorParagraphStyle = patchVectorParagraphStyle; exports.sanitizeVectorTextFrame = sanitizeVectorTextFrame; exports.normalizeVectorTextRuns = normalizeVectorTextRuns; exports.vectorTextOrientation = vectorTextOrientation; exports.sanitizeVectorTextFields = sanitizeVectorTextFields; exports.vectorTextRange = vectorTextRange; exports.replaceVectorText = replaceVectorText; exports.styleVectorText = styleVectorText; exports.bakeVectorTextGeometry = bakeVectorTextGeometry; exports.vectorTextName = vectorTextName; exports.pathTextFrameFromBezier = pathTextFrameFromBezier; exports.vectorTextBoxOutline = vectorTextBoxOutline; exports.vectorTextSpans = vectorTextSpans; exports.vectorTextGeometryNode = vectorTextGeometryNode; exports.vectorTextSpanSvg = vectorTextSpanSvg; exports.VECTOR_SYMBOL_MAX_DEPTH = VECTOR_SYMBOL_MAX_DEPTH; exports.vectorSymbolsUsedIn = vectorSymbolsUsedIn; exports.vectorSymbolUses = vectorSymbolUses; exports.resolveVectorSymbols = resolveVectorSymbols; exports.stripVectorSymbolArt = stripVectorSymbolArt; exports.scaleVectorStrokeWidths = scaleVectorStrokeWidths; exports.tintVectorNode = tintVectorNode; exports.prefixVectorIds = prefixVectorIds; exports.vectorInstanceGroup = vectorInstanceGroup; exports.composeVectorMatrices = composeVectorMatrices; exports.vectorBevelFaces = vectorBevelFaces; exports.isVectorLens = isVectorLens; exports.VECTOR_LENS_LABELS = VECTOR_LENS_LABELS; exports.VECTOR_LENS_SPECS = VECTOR_LENS_SPECS; exports.sanitizeVectorLens = sanitizeVectorLens; exports.vectorLensColorMap = vectorLensColorMap; exports.mapVectorPaintColors = mapVectorPaintColors; exports.vectorLensDrawn = vectorLensDrawn; exports.resolveVectorLenses = resolveVectorLenses; exports.stripVectorLensViews = stripVectorLensViews; exports.WARP_STYLES = WARP_STYLES; exports.WARP_STYLE_LABELS = WARP_STYLE_LABELS; exports.warpPresetGrid = warpPresetGrid; exports.warpPresetMesh = warpPresetMesh; exports.warpMeshColumns = warpMeshColumns; exports.warpMeshRows = warpMeshRows; exports.isValidWarpMesh = isValidWarpMesh; exports.fitWarpMesh = fitWarpMesh; exports.identityWarpMesh = identityWarpMesh; exports.evalWarpMesh = evalWarpMesh; exports.splitWarpMeshU = splitWarpMeshU; exports.splitWarpMeshV = splitWarpMeshV; exports.removeWarpMeshSplitU = removeWarpMeshSplitU; exports.removeWarpMeshSplitV = removeWarpMeshSplitV; exports.mapWarpMeshPoints = mapWarpMeshPoints; exports.resizeWarpMesh = resizeWarpMesh; exports.warpMeshControlBounds = warpMeshControlBounds; exports.warpMeshParamAt = warpMeshParamAt; exports.dragWarpMeshPoint = dragWarpMeshPoint; exports.pullWarpMesh = pullWarpMesh; exports.warpMeshEditPoints = warpMeshEditPoints; exports.warpMeshGridCurves = warpMeshGridCurves; exports.vectorMeshFromOutline = vectorMeshFromOutline; exports.vectorMeshOutline = vectorMeshOutline; exports.VECTOR_EFFECT_DEFAULTS = VECTOR_EFFECT_DEFAULTS; exports.VECTOR_EFFECT_LABELS = VECTOR_EFFECT_LABELS; exports.VECTOR_EFFECT_PARAM_SPECS = VECTOR_EFFECT_PARAM_SPECS; exports.vectorEnvelopeMesh = vectorEnvelopeMesh; exports.vectorEnvelopeMap = vectorEnvelopeMap; exports.normalizeVectorEffectParams = normalizeVectorEffectParams; exports.createVectorEffect = createVectorEffect; exports.activeVectorEffects = activeVectorEffects; exports.hasOwnVectorAppearance = hasOwnVectorAppearance; exports.hasVectorAppearance = hasVectorAppearance; exports.isVectorLiveBoolean = isVectorLiveBoolean; exports.vectorOperandOperation = vectorOperandOperation; exports.vectorLiveBooleanSteps = vectorLiveBooleanSteps; exports.clearVectorLiveBooleanCache = clearVectorLiveBooleanCache; exports.foldVectorBooleanOperands = foldVectorBooleanOperands; exports.applyVectorEffects = applyVectorEffects; exports.vectorInstanceDrawn = vectorInstanceDrawn; exports.vectorChildAppearanceShapes = vectorChildAppearanceShapes; exports.vectorEffectInputPaths = vectorEffectInputPaths; exports.vectorEffectInputBounds = vectorEffectInputBounds; exports.vectorNodeEnvelope = vectorNodeEnvelope; exports.vectorEnvelopeFrame = vectorEnvelopeFrame; exports.vectorAppearanceShapes = vectorAppearanceShapes; exports.vectorAppearanceOutline = vectorAppearanceOutline; exports.vectorAppearanceNodes = vectorAppearanceNodes; exports.expandVectorAppearance = expandVectorAppearance; exports.expandVectorAppearances = expandVectorAppearances; exports.sanitizeVectorEffects = sanitizeVectorEffects; exports.transformVectorEffects = transformVectorEffects; exports.vectorEnteredGroups = vectorEnteredGroups; exports.isVectorMasterPage = isVectorMasterPage; exports.vectorPages = vectorPages; exports.vectorMasterPages = vectorMasterPages; exports.vectorMasterArt = vectorMasterArt; exports.resolveVectorMasterPages = resolveVectorMasterPages; exports.stripVectorMasterArt = stripVectorMasterArt; exports.isVectorConnector = isVectorConnector; exports.vectorConnectionSites = vectorConnectionSites; exports.nearestVectorConnectionSite = nearestVectorConnectionSite; exports.vectorConnectorWorldAnchors = vectorConnectorWorldAnchors; exports.routeVectorConnector = routeVectorConnector; exports.rerouteVectorConnectors = rerouteVectorConnectors; exports.sanitizeVectorConnector = sanitizeVectorConnector; exports.VECTOR_CONNECTOR_ROUTE_LABELS = VECTOR_CONNECTOR_ROUTE_LABELS; exports.VECTOR_CONNECTOR_SIDE_LABELS = VECTOR_CONNECTOR_SIDE_LABELS; exports.getVectorConnectorPanel = getVectorConnectorPanel; exports.vectorConnectorTargetAt = vectorConnectorTargetAt; exports.vectorStrokeGradientDefs = vectorStrokeGradientDefs; exports.vectorCornersAttribute = vectorCornersAttribute; exports.applyVectorCornersAttribute = applyVectorCornersAttribute; exports.vectorPathLocalBounds = vectorPathLocalBounds; exports.vectorPaintToSvg = vectorPaintToSvg; exports.vectorStrokeSvgParts = vectorStrokeSvgParts; exports.vectorNodeLocalPaintBounds = vectorNodeLocalPaintBounds; exports.vectorNodeFilterSvg = vectorNodeFilterSvg; exports.widthProfileToAttribute = widthProfileToAttribute; exports.widthProfileFromAttribute = widthProfileFromAttribute; exports.vectorDocumentToSvg = vectorDocumentToSvg; exports.parseSvgTransform = parseSvgTransform; exports.parseVectorSvg = parseVectorSvg; exports.VECTOR_SPATIAL_MIN = VECTOR_SPATIAL_MIN; exports.VectorRTree = VectorRTree; exports.vectorNodePaintBox = vectorNodePaintBox; exports.vectorSpatialIndex = vectorSpatialIndex; exports.vectorNodesNear = vectorNodesNear; exports.cloneAnchor = cloneAnchor; exports.cloneSubpath = cloneSubpath; exports.cloneVectorNode = cloneVectorNode; exports.cloneVectorDocument = cloneVectorDocument; exports.hasPaint = hasPaint; exports.subpathSegmentCount = subpathSegmentCount; exports.subpathSegment = subpathSegment; exports.subpathsToBezier = subpathsToBezier; exports.vectorNodeToBezier = vectorNodeToBezier; exports.vectorPathData = vectorPathData; exports.inferAnchorType = inferAnchorType; exports.bezierToSubpaths = bezierToSubpaths; exports.walkVectorNodes = walkVectorNodes; exports.findVectorNode = findVectorNode; exports.locateVectorNode = locateVectorNode; exports.collectPaintedNodes = collectPaintedNodes; exports.collectPathNodes = collectPathNodes; exports.nodeMatrix = nodeMatrix; exports.vectorPathWorldBezier = vectorPathWorldBezier; exports.vectorNodeBounds = vectorNodeBounds; exports.unionBounds = unionBounds; exports.boundsIntersect = boundsIntersect; exports.boundsFromPoints = boundsFromPoints; exports.hitTestVectorNode = hitTestVectorNode; exports.vectorStrokeOutline = vectorStrokeOutline; exports.hitTestVectorNodes = hitTestVectorNodes; exports.nearestSegment = nearestSegment; exports.transformVectorNode = transformVectorNode; exports.vectorNodeRotation = vectorNodeRotation; exports.vectorWorldMatrix = vectorWorldMatrix; exports.vectorParentMatrix = vectorParentMatrix; exports.translateAnchor = translateAnchor; exports.moveAnchorHandle = moveAnchorHandle; exports.convertAnchor = convertAnchor; exports.insertAnchor = insertAnchor; exports.removeAnchors = removeAnchors; exports.reverseSubpath = reverseSubpath; exports.KAPPA = KAPPA2; exports.rectSubpath = rectSubpath; exports.ellipseSubpath = ellipseSubpath; exports.polygonSubpath = polygonSubpath; exports.starSubpath = starSubpath; exports.lineSubpath = lineSubpath; exports.roundSubpaths = roundSubpaths;
13280
+
13281
+
13282
+
13283
+
13284
+
13285
+
13286
+
13287
+
13288
+
13289
+
13290
+
13291
+
13292
+
13293
+
13294
+
13295
+
13296
+
13297
+
13298
+
13299
+
13300
+
13301
+
13302
+
13303
+
13304
+
13305
+
13306
+
13307
+
13308
+
13309
+
13310
+
13311
+
13312
+
13313
+
13314
+
13315
+
13316
+
13317
+
13318
+
13319
+
13320
+
13321
+
13322
+
13323
+
13324
+
13325
+
13326
+
13327
+
13328
+
13329
+
13330
+
13331
+
13332
+
13333
+ exports.isVectorMeshGradient = isVectorMeshGradient; exports.isVectorFreeformGradient = isVectorFreeformGradient; exports.isVectorShadedPaint = isVectorShadedPaint; exports.vectorRgbaToCss = vectorRgbaToCss; exports.VECTOR_MESH_MAX = VECTOR_MESH_MAX; exports.createVectorMeshGradient = createVectorMeshGradient; exports.vectorMeshPointAt = vectorMeshPointAt; exports.vectorMeshColorAt = vectorMeshColorAt; exports.vectorMeshLines = vectorMeshLines; exports.vectorFreeformSpreadScale = vectorFreeformSpreadScale; exports.vectorFreeformLineSegments = vectorFreeformLineSegments; exports.vectorFreeformField = vectorFreeformField; exports.sampleVectorFreeform = sampleVectorFreeform; exports.autoVectorFreeformGradient = autoVectorFreeformGradient; exports.vectorShadedSvgDefs = vectorShadedSvgDefs; exports.mapVectorShadedPaint = mapVectorShadedPaint; exports.transformVectorShadedPaint = transformVectorShadedPaint; exports.sanitizeVectorShadedPaint = sanitizeVectorShadedPaint; exports.removeVectorFreeformPoint = removeVectorFreeformPoint; exports.nearestVectorShadingPoint = nearestVectorShadingPoint; exports.VECTOR_CORNER_KINDS = VECTOR_CORNER_KINDS; exports.VECTOR_GRADIENT_TYPES = VECTOR_GRADIENT_TYPES; exports.VECTOR_GRADIENT_SPREADS = VECTOR_GRADIENT_SPREADS; exports.VECTOR_GRADIENT_INTERPOLATIONS = VECTOR_GRADIENT_INTERPOLATIONS; exports.VECTOR_STROKE_GRADIENT_MODES = VECTOR_STROKE_GRADIENT_MODES; exports.VECTOR_ARROWHEADS = VECTOR_ARROWHEADS; exports.VECTOR_BLEND_MODES = VECTOR_BLEND_MODES; exports.VECTOR_HORIZONTAL_RESIZING = VECTOR_HORIZONTAL_RESIZING; exports.VECTOR_VERTICAL_RESIZING = VECTOR_VERTICAL_RESIZING; exports.VECTOR_LENS_TYPES = VECTOR_LENS_TYPES; exports.VECTOR_CONNECTOR_SIDES = VECTOR_CONNECTOR_SIDES; exports.VECTOR_CONNECTOR_ROUTES = VECTOR_CONNECTOR_ROUTES; exports.VECTOR_BLEND_SPACINGS = VECTOR_BLEND_SPACINGS; exports.VECTOR_MASK_TYPES = VECTOR_MASK_TYPES; exports.VECTOR_SYMMETRY_MODES = VECTOR_SYMMETRY_MODES; exports.VECTOR_TEXT_ALIGNS = VECTOR_TEXT_ALIGNS; exports.VECTOR_PATH_TEXT_BASELINES = VECTOR_PATH_TEXT_BASELINES; exports.VECTOR_PERSPECTIVE_PLANES = VECTOR_PERSPECTIVE_PLANES; exports.VECTOR_CONSTRAINT_KINDS = VECTOR_CONSTRAINT_KINDS; exports.VECTOR_TOOLS = VECTOR_TOOLS; exports.VECTOR_TRANSFORM_HANDLES = VECTOR_TRANSFORM_HANDLES; exports.VECTOR_PATHFINDER_OPERATIONS = VECTOR_PATHFINDER_OPERATIONS; exports.VECTOR_EFFECT_TYPES = VECTOR_EFFECT_TYPES; exports.VECTOR_MERGE_MODES = VECTOR_MERGE_MODES; exports.VECTOR_FILTER_TYPES = VECTOR_FILTER_TYPES; exports.isVectorGradient = isVectorGradient; exports.parseVectorColor = parseVectorColor; exports.VECTOR_GRADIENT_MIN_STOPS = VECTOR_GRADIENT_MIN_STOPS; exports.gradientMidpointRemap = gradientMidpointRemap; exports.sortedVectorGradientStops = sortedVectorGradientStops; exports.vectorGradientNeedsExpansion = vectorGradientNeedsExpansion; exports.vectorGradientRamp = vectorGradientRamp; exports.sampleVectorGradient = sampleVectorGradient; exports.expandVectorGradientStops = expandVectorGradientStops; exports.samplePlainStops = samplePlainStops; exports.reverseVectorGradient = reverseVectorGradient; exports.insertVectorGradientStop = insertVectorGradientStop; exports.moveVectorGradientStop = moveVectorGradientStop; exports.removeVectorGradientStop = removeVectorGradientStop; exports.vectorGradientMidpointPosition = vectorGradientMidpointPosition; exports.vectorGradientMidpointFromPosition = vectorGradientMidpointFromPosition; exports.spanVectorGradientStops = spanVectorGradientStops; exports.hasExplicitGradientGeometry = hasExplicitGradientGeometry; exports.vectorGradientPoints = vectorGradientPoints; exports.vectorBoxMatrix = vectorBoxMatrix; exports.vectorGradientUnitsMatrix = vectorGradientUnitsMatrix; exports.vectorGradientMatrix = vectorGradientMatrix; exports.vectorGradientFocalParam = vectorGradientFocalParam; exports.vectorGradientParam = vectorGradientParam; exports.applyVectorGradientSpread = applyVectorGradientSpread; exports.vectorGradientTAt = vectorGradientTAt; exports.sampleVectorGradientAt = sampleVectorGradientAt; exports.vectorGradientAspect = vectorGradientAspect; exports.explicitVectorGradient = explicitVectorGradient; exports.pinVectorGradient = pinVectorGradient; exports.transformVectorGradient = transformVectorGradient; exports.mapVectorGradient = mapVectorGradient; exports.mapVectorPaint = mapVectorPaint; exports.transformVectorPaint = transformVectorPaint; exports.isCentredVectorGradient = isCentredVectorGradient; exports.vectorGradientHandles = vectorGradientHandles; exports.moveVectorGradientHandle = moveVectorGradientHandle; exports.setVectorGradientVector = setVectorGradientVector; exports.VECTOR_GRADIENT_MAX_PERIODS = VECTOR_GRADIENT_MAX_PERIODS; exports.periodicVectorGradientStops = periodicVectorGradientStops; exports.expandVectorGradientSpread = expandVectorGradientSpread; exports.vectorGradientArea = vectorGradientArea; exports.patternAttrs = patternAttrs; exports.vectorGradientSvgDefs = vectorGradientSvgDefs; exports.sampleVectorPaintDefAt = sampleVectorPaintDefAt; exports.sanitizeVectorGradient = sanitizeVectorGradient; exports.convertVectorGradient = convertVectorGradient; exports.defaultVectorGradient = defaultVectorGradient; exports.applyVectorGradientPatch = applyVectorGradientPatch; exports.IDENTITY_MATRIX = IDENTITY_MATRIX; exports.multiplyMatrices = multiplyMatrices; exports.translateMatrix = translateMatrix; exports.scaleMatrix = scaleMatrix; exports.rotateMatrix = rotateMatrix; exports.matrixAbout = matrixAbout; exports.skewMatrix = skewMatrix; exports.applyMatrix = applyMatrix; exports.isIdentityMatrix = isIdentityMatrix; exports.invertMatrix = invertMatrix; exports.applyMatrixLinear = applyMatrixLinear; exports.matrixRotation = matrixRotation; exports.decomposeRigid = decomposeRigid; exports.isVectorSymmetryGroup = isVectorSymmetryGroup; exports.vectorSymmetryMatrices = vectorSymmetryMatrices; exports.vectorSymmetryDrawn = vectorSymmetryDrawn; exports.vectorSymmetryAxes = vectorSymmetryAxes; exports.sanitizeVectorSymmetry = sanitizeVectorSymmetry; exports.VECTOR_SYMMETRY_MODE_LABELS = VECTOR_SYMMETRY_MODE_LABELS; exports.transformVectorSymmetry = transformVectorSymmetry; exports.vectorCornerAt = vectorCornerAt; exports.vectorCorners = vectorCorners; exports.cornerSetback = cornerSetback; exports.fitCornerRadius = fitCornerRadius; exports.cornerBisectorPoint = cornerBisectorPoint; exports.cornerRadiusChange = cornerRadiusChange; exports.hasVectorCorners = hasVectorCorners; exports.expandVectorCornersOf = expandVectorCornersOf; exports.expandVectorCorners = expandVectorCorners; exports.setAnchorCorner = setAnchorCorner; exports.nextVectorCornerKind = nextVectorCornerKind; exports.setSubpathCorners = setSubpathCorners; exports.VECTOR_WIDTH_PROFILE_MAX_POINTS = VECTOR_WIDTH_PROFILE_MAX_POINTS; exports.VECTOR_WIDTH_PROFILE_MAX_SCALE = VECTOR_WIDTH_PROFILE_MAX_SCALE; exports.VECTOR_WIDTH_SAME_T = VECTOR_WIDTH_SAME_T; exports.VECTOR_WIDTH_PRESETS = VECTOR_WIDTH_PRESETS; exports.VECTOR_WIDTH_PRESET_IDS = VECTOR_WIDTH_PRESET_IDS; exports.sanitizeWidthProfile = sanitizeWidthProfile; exports.isUniformWidthProfile = isUniformWidthProfile; exports.widthProfileAt = widthProfileAt; exports.widthProfileMaxScale = widthProfileMaxScale; exports.widthProfilePreset = widthProfilePreset; exports.widthProfilePresetId = widthProfilePresetId; exports.reverseWidthProfile = reverseWidthProfile; exports.mirrorWidthProfile = mirrorWidthProfile; exports.insertWidthPoint = insertWidthPoint; exports.setWidthPoint = setWidthPoint; exports.removeWidthPoints = removeWidthPoints; exports.taperWaveFactor = taperWaveFactor; exports.generateWidthProfile = generateWidthProfile; exports.VECTOR_PRESSURE_NOMINAL = VECTOR_PRESSURE_NOMINAL; exports.pressureWidthProfile = pressureWidthProfile; exports.dashIntervals = dashIntervals; exports.variableStrokeRings = variableStrokeRings; exports.variableStrokeOutline = variableStrokeOutline; exports.nearestStrokePosition = nearestStrokePosition; exports.strokePositionPoint = strokePositionPoint; exports.isClosedBezierShape = isClosedBezierShape; exports.effectiveStrokeAlign = effectiveStrokeAlign; exports.strokeWidthProfileOf = strokeWidthProfileOf; exports.hasStrokeExtras = hasStrokeExtras; exports.vectorStrokeLineArea = vectorStrokeLineArea; exports.arrowheadWeight = arrowheadWeight; exports.arrowheadInset = arrowheadInset; exports.arrowheadPath = arrowheadPath; exports.vectorStrokeParts = vectorStrokeParts; exports.vectorStrokeOutlinePath = vectorStrokeOutlinePath; exports.hitTestVectorStroke = hitTestVectorStroke; exports.vectorStrokeReach = vectorStrokeReach; exports.vectorPaintSolid = vectorPaintSolid; exports.shadeVectorColor = shadeVectorColor; exports.vectorPathRings = vectorPathRings; exports.vectorExtrudeFaces = vectorExtrudeFaces; exports.EFFECT_STRIP_HEIGHT = EFFECT_STRIP_HEIGHT; exports.EFFECT_MAP_REPEATS = EFFECT_MAP_REPEATS; exports.effectPaintSize = effectPaintSize; exports.readEffectStrokeMap = readEffectStrokeMap; exports.effectPaintKey = effectPaintKey; exports.isPaintEffectPaint = isPaintEffectPaint; exports.readPaintEffectPaint = readPaintEffectPaint; exports.sampleEffectField = sampleEffectField; exports.sampleEffectAt = sampleEffectAt; exports.effectDabField = effectDabField; exports.stampSampler = stampSampler; exports.brushStickerRefs = brushStickerRefs; exports.PAPER_FAMILIES = PAPER_FAMILIES; exports.PAPER_LIBRARY = PAPER_LIBRARY; exports.DEFAULT_PAPER = DEFAULT_PAPER; exports.paperPreset = paperPreset; exports.clonePaper = clonePaper; exports.normalizePaper = normalizePaper; exports.hexToRgb8 = hexToRgb8; exports.renderPaper = renderPaper; exports.penOrientation = penOrientation; exports.tiltToOrientation = tiltToOrientation; exports.PenSmoother = PenSmoother; exports.IDENTITY_COPY = IDENTITY_COPY; exports.PenDabWalker = PenDabWalker; exports.DryStroke = DryStroke; exports.mixerTip = mixerTip; exports.toStrokePoint = toStrokePoint; exports.multiColorPalette = multiColorPalette; exports.multiColorGradient = multiColorGradient; exports.multiColorForDab = multiColorForDab; exports.PaintDabStroke = PaintDabStroke; exports.wetPaperInput = wetPaperInput; exports.WetStrokeDriver = WetStrokeDriver; exports.WET_MEDIUM_PARAMS = WET_MEDIUM_PARAMS; exports.WET_GPU_MODES = WET_GPU_MODES; exports.GPU_LEAD = GPU_LEAD; exports.PaintWetLayers = PaintWetLayers; exports.wetPigmentOf = wetPigmentOf; exports.VECTOR_WET_STEPS = VECTOR_WET_STEPS; exports.vectorMediaEngine = vectorMediaEngine; exports.usesVectorBackdrop = usesVectorBackdrop; exports.WetBrushstrokeJob = WetBrushstrokeJob; exports.renderWetBrushstroke = renderWetBrushstroke; exports.vectorBackdropRect = vectorBackdropRect; exports.renderBackdropBrushstroke = renderBackdropBrushstroke; exports.VECTOR_BRUSHSTROKE_SCALE = VECTOR_BRUSHSTROKE_SCALE; exports.isVectorBrushstrokeEngine = isVectorBrushstrokeEngine; exports.vectorBrushstrokeBrushes = vectorBrushstrokeBrushes; exports.vectorBrushstrokeBrush = vectorBrushstrokeBrush; exports.vectorBrushstrokeBrushOf = vectorBrushstrokeBrushOf; exports.vectorBrushstrokeBrushError = vectorBrushstrokeBrushError; exports.vectorBrushstrokeDefaultColour = vectorBrushstrokeDefaultColour; exports.sanitizeVectorBrushstroke = sanitizeVectorBrushstroke; exports.vectorBrushstrokePaintError = vectorBrushstrokePaintError; exports.readVectorBrushstrokePaint = readVectorBrushstrokePaint; exports.VECTOR_BRUSHSTROKE_MAX_SEED = VECTOR_BRUSHSTROKE_MAX_SEED; exports.sanitizeVectorBrushstrokePaper = sanitizeVectorBrushstrokePaper; exports.vectorBrushstrokeCharacterError = vectorBrushstrokeCharacterError; exports.randomVectorBrushstrokeSeed = randomVectorBrushstrokeSeed; exports.isVectorBrushstrokeLayer = isVectorBrushstrokeLayer; exports.vectorBrushstrokeReach = vectorBrushstrokeReach; exports.setVectorBackdropSource = setVectorBackdropSource; exports.onVectorBrushstrokesSettled = onVectorBrushstrokesSettled; exports.vectorBrushstrokesSettling = vectorBrushstrokesSettling; exports.settleVectorBrushstrokes = settleVectorBrushstrokes; exports.vectorBrushstrokeImages = vectorBrushstrokeImages; exports.VECTOR_STROKE_SETTING_KEYS = VECTOR_STROKE_SETTING_KEYS; exports.VECTOR_BLEND_MODE_LABELS = VECTOR_BLEND_MODE_LABELS; exports.isVectorBlendMode = isVectorBlendMode; exports.vectorBlendModeCss = vectorBlendModeCss; exports.vectorBlendModeFromCss = vectorBlendModeFromCss; exports.isPlainVectorPaintLayer = isPlainVectorPaintLayer; exports.isDrawnVectorPaintLayer = isDrawnVectorPaintLayer; exports.vectorFills = vectorFills; exports.vectorStrokeSettings = vectorStrokeSettings; exports.vectorStrokes = vectorStrokes; exports.hasVectorPaintStacks = hasVectorPaintStacks; exports.withVectorFills = withVectorFills; exports.withVectorStrokes = withVectorStrokes; exports.normalizeVectorPaintStacks = normalizeVectorPaintStacks; exports.sanitizeVectorFills = sanitizeVectorFills; exports.sanitizeVectorStrokeSettings = sanitizeVectorStrokeSettings; exports.sanitizeVectorStrokes = sanitizeVectorStrokes; exports.vectorPaintLayerNodes = vectorPaintLayerNodes; exports.needsVectorPaintLayers = needsVectorPaintLayers; exports.vectorStrokeStackReach = vectorStrokeStackReach; exports.hitTestVectorPaintLayer = hitTestVectorPaintLayer; exports.hitTestVectorPaintStack = hitTestVectorPaintStack; exports.vectorStacksHaveGradient = vectorStacksHaveGradient; exports.newVectorStrokeLayer = newVectorStrokeLayer; exports.vectorTargetPaint = vectorTargetPaint; exports.withVectorTargetPaint = withVectorTargetPaint; exports.effectPathLength = effectPathLength; exports.effectPathVertexCount = effectPathVertexCount; exports.trimIntervals = trimIntervals; exports.trimPaths = trimPaths; exports.trimPathsIndividually = trimPathsIndividually; exports.puckerBloatPaths = puckerBloatPaths; exports.roundCornerPaths = roundCornerPaths; exports.offsetPaths = offsetPaths; exports.sweepPath = sweepPath; exports.twistPaths = twistPaths; exports.zigzagPaths = zigzagPaths; exports.wigglePaths = wigglePaths; exports.mergePaths = mergePaths; exports.vectorRepeaterCopies = vectorRepeaterCopies; exports.repeatPaths = repeatPaths; exports.pathsCenter = pathsCenter; exports.mapVectorPoints = mapVectorPoints; exports.mapVectorSubpaths = mapVectorSubpaths; exports.mapBezierPath = mapBezierPath; exports.isVectorFrame = isVectorFrame; exports.vectorFrameRectPath = vectorFrameRectPath; exports.vectorFrameDrawn = vectorFrameDrawn; exports.vectorFrameContains = vectorFrameContains; exports.vectorFrameChildMatrix = vectorFrameChildMatrix; exports.sanitizeVectorFrame = sanitizeVectorFrame; exports.sanitizeVectorResizing = sanitizeVectorResizing; exports.VECTOR_HORIZONTAL_RESIZING_LABELS = VECTOR_HORIZONTAL_RESIZING_LABELS; exports.VECTOR_VERTICAL_RESIZING_LABELS = VECTOR_VERTICAL_RESIZING_LABELS; exports.vectorBoundsInside = vectorBoundsInside; exports.vectorArtboards = vectorArtboards; exports.vectorFrameDocument = vectorFrameDocument; exports.getVectorFramePanel = getVectorFramePanel; exports.splitIntoFaces = splitIntoFaces; exports.knifePath = knifePath; exports.eraserRegion = eraserRegion; exports.eraseFromFill = eraseFromFill; exports.eraseFromOutline = eraseFromOutline; exports.polylineBounds = polylineBounds; exports.simplifyPolyline = simplifyPolyline; exports.VECTOR_FILTER_DEFAULTS = VECTOR_FILTER_DEFAULTS; exports.VECTOR_FILTER_LABELS = VECTOR_FILTER_LABELS; exports.VECTOR_FILTER_PARAM_SPECS = VECTOR_FILTER_PARAM_SPECS; exports.isVectorFilterType = isVectorFilterType; exports.normalizeVectorFilterParams = normalizeVectorFilterParams; exports.vectorFilterParamKeys = vectorFilterParamKeys; exports.createVectorFilter = createVectorFilter; exports.sanitizeVectorFilters = sanitizeVectorFilters; exports.activeVectorFilters = activeVectorFilters; exports.vectorFilterReach = vectorFilterReach; exports.vectorFilterSvg = vectorFilterSvg; exports.vectorFilterMarkup = vectorFilterMarkup; exports.VECTOR_FILTER_MENU = VECTOR_FILTER_MENU; exports.isVectorMaskType = isVectorMaskType; exports.sanitizeVectorMask = sanitizeVectorMask; exports.isVectorMaskGroup = isVectorMaskGroup; exports.isVectorMaskActive = isVectorMaskActive; exports.vectorMaskSource = vectorMaskSource; exports.vectorMaskContents = vectorMaskContents; exports.vectorMaskOwner = vectorMaskOwner; exports.vectorMaskSummary = vectorMaskSummary; exports.vectorMaskRegionShapes = vectorMaskRegionShapes; exports.vectorMaskRegion = vectorMaskRegion; exports.vectorMaskRegionPath = vectorMaskRegionPath; exports.vectorMaskContains = vectorMaskContains; exports.vectorMaskedShapes = vectorMaskedShapes; exports.vectorMaskedGeometry = vectorMaskedGeometry; exports.vectorMaskedLocalBounds = vectorMaskedLocalBounds; exports.vectorMaskContentBounds = vectorMaskContentBounds; exports.vectorMaskRenderData = vectorMaskRenderData; exports.DEFAULT_TEXT_STYLE = DEFAULT_TEXT_STYLE; exports.DEFAULT_AUTO_LEADING = DEFAULT_AUTO_LEADING; exports.fitRuns = fitRuns; exports.styleAt = styleAt; exports.restyleRange = restyleRange; exports.spliceRuns = spliceRuns; exports.paragraphRanges = paragraphRanges; exports.fitParagraphRuns = fitParagraphRuns; exports.fontOf = fontOf; exports.transformTextRect = transformTextRect; exports.lineToTextSpace = lineToTextSpace; exports.layoutText = layoutText; exports.textIndexAt = textIndexAt; exports.caretAt = caretAt; exports.textSelectionQuads = textSelectionQuads; exports.textArrowStep = textArrowStep; exports.textLineMove = textLineMove; exports.textDecorations = textDecorations; exports.textRectPath = textRectPath; exports.textFragmentOutline = textFragmentOutline; exports.drawTextFragment = drawTextFragment; exports.cssFontFamily = cssFontFamily; exports.cssFont = cssFont; exports.createCanvasTextShaper = createCanvasTextShaper; exports.createOutlineTextShaper = createOutlineTextShaper; exports.createMetricTextShaper = createMetricTextShaper; exports.setVectorTextShaper = setVectorTextShaper; exports.getVectorTextShaper = getVectorTextShaper; exports.vectorTextShaperGeneration = vectorTextShaperGeneration; exports.vectorTextHasOutlines = vectorTextHasOutlines; exports.vectorTextFamilies = vectorTextFamilies; exports.DEFAULT_VECTOR_FONT = DEFAULT_VECTOR_FONT; exports.VECTOR_CHARACTER_STYLE_KEYS = VECTOR_CHARACTER_STYLE_KEYS; exports.VECTOR_PARAGRAPH_STYLE_KEYS = VECTOR_PARAGRAPH_STYLE_KEYS; exports.VectorTextError = VectorTextError; exports.fitVectorTextRuns = fitVectorTextRuns; exports.vectorTextRuns = vectorTextRuns; exports.vectorTextStyleAt = vectorTextStyleAt; exports.measureVectorPath = measureVectorPath; exports.vectorPathAt = vectorPathAt; exports.vectorPathTextPositions = vectorPathTextPositions; exports.layoutVectorText = layoutVectorText; exports.glyphBox = glyphBox; exports.vectorTextPaths = vectorTextPaths; exports.vectorTextPaintSource = vectorTextPaintSource; exports.vectorTextCaret = vectorTextCaret; exports.vectorTextIndexAt = vectorTextIndexAt; exports.vectorTextSelectionQuads = vectorTextSelectionQuads; exports.patchVectorCharacterStyle = patchVectorCharacterStyle; exports.patchVectorParagraphStyle = patchVectorParagraphStyle; exports.sanitizeVectorTextFrame = sanitizeVectorTextFrame; exports.normalizeVectorTextRuns = normalizeVectorTextRuns; exports.vectorTextOrientation = vectorTextOrientation; exports.sanitizeVectorTextFields = sanitizeVectorTextFields; exports.vectorTextRange = vectorTextRange; exports.replaceVectorText = replaceVectorText; exports.styleVectorText = styleVectorText; exports.bakeVectorTextGeometry = bakeVectorTextGeometry; exports.vectorTextName = vectorTextName; exports.pathTextFrameFromBezier = pathTextFrameFromBezier; exports.vectorTextBoxOutline = vectorTextBoxOutline; exports.vectorTextSpans = vectorTextSpans; exports.vectorTextGeometryNode = vectorTextGeometryNode; exports.vectorTextSpanSvg = vectorTextSpanSvg; exports.VECTOR_SYMBOL_MAX_DEPTH = VECTOR_SYMBOL_MAX_DEPTH; exports.vectorSymbolsUsedIn = vectorSymbolsUsedIn; exports.vectorSymbolUses = vectorSymbolUses; exports.resolveVectorSymbols = resolveVectorSymbols; exports.stripVectorSymbolArt = stripVectorSymbolArt; exports.scaleVectorStrokeWidths = scaleVectorStrokeWidths; exports.tintVectorNode = tintVectorNode; exports.prefixVectorIds = prefixVectorIds; exports.vectorInstanceGroup = vectorInstanceGroup; exports.composeVectorMatrices = composeVectorMatrices; exports.vectorBevelFaces = vectorBevelFaces; exports.isVectorLens = isVectorLens; exports.VECTOR_LENS_LABELS = VECTOR_LENS_LABELS; exports.VECTOR_LENS_SPECS = VECTOR_LENS_SPECS; exports.sanitizeVectorLens = sanitizeVectorLens; exports.vectorLensColorMap = vectorLensColorMap; exports.mapVectorPaintColors = mapVectorPaintColors; exports.vectorLensDrawn = vectorLensDrawn; exports.resolveVectorLenses = resolveVectorLenses; exports.stripVectorLensViews = stripVectorLensViews; exports.WARP_STYLES = WARP_STYLES; exports.WARP_STYLE_LABELS = WARP_STYLE_LABELS; exports.warpPresetGrid = warpPresetGrid; exports.warpPresetMesh = warpPresetMesh; exports.warpMeshColumns = warpMeshColumns; exports.warpMeshRows = warpMeshRows; exports.isValidWarpMesh = isValidWarpMesh; exports.fitWarpMesh = fitWarpMesh; exports.identityWarpMesh = identityWarpMesh; exports.evalWarpMesh = evalWarpMesh; exports.splitWarpMeshU = splitWarpMeshU; exports.splitWarpMeshV = splitWarpMeshV; exports.removeWarpMeshSplitU = removeWarpMeshSplitU; exports.removeWarpMeshSplitV = removeWarpMeshSplitV; exports.mapWarpMeshPoints = mapWarpMeshPoints; exports.resizeWarpMesh = resizeWarpMesh; exports.warpMeshControlBounds = warpMeshControlBounds; exports.warpMeshParamAt = warpMeshParamAt; exports.dragWarpMeshPoint = dragWarpMeshPoint; exports.pullWarpMesh = pullWarpMesh; exports.warpMeshEditPoints = warpMeshEditPoints; exports.warpMeshGridCurves = warpMeshGridCurves; exports.vectorMeshFromOutline = vectorMeshFromOutline; exports.vectorMeshOutline = vectorMeshOutline; exports.VECTOR_EFFECT_DEFAULTS = VECTOR_EFFECT_DEFAULTS; exports.VECTOR_EFFECT_LABELS = VECTOR_EFFECT_LABELS; exports.VECTOR_EFFECT_PARAM_SPECS = VECTOR_EFFECT_PARAM_SPECS; exports.vectorEnvelopeMesh = vectorEnvelopeMesh; exports.vectorEnvelopeMap = vectorEnvelopeMap; exports.normalizeVectorEffectParams = normalizeVectorEffectParams; exports.createVectorEffect = createVectorEffect; exports.activeVectorEffects = activeVectorEffects; exports.hasOwnVectorAppearance = hasOwnVectorAppearance; exports.hasVectorAppearance = hasVectorAppearance; exports.isVectorLiveBoolean = isVectorLiveBoolean; exports.vectorOperandOperation = vectorOperandOperation; exports.vectorLiveBooleanSteps = vectorLiveBooleanSteps; exports.clearVectorLiveBooleanCache = clearVectorLiveBooleanCache; exports.foldVectorBooleanOperands = foldVectorBooleanOperands; exports.applyVectorEffects = applyVectorEffects; exports.vectorInstanceDrawn = vectorInstanceDrawn; exports.vectorChildAppearanceShapes = vectorChildAppearanceShapes; exports.vectorEffectInputPaths = vectorEffectInputPaths; exports.vectorEffectInputBounds = vectorEffectInputBounds; exports.vectorNodeEnvelope = vectorNodeEnvelope; exports.vectorEnvelopeFrame = vectorEnvelopeFrame; exports.vectorAppearanceShapes = vectorAppearanceShapes; exports.vectorAppearanceOutline = vectorAppearanceOutline; exports.vectorAppearanceNodes = vectorAppearanceNodes; exports.expandVectorAppearance = expandVectorAppearance; exports.expandVectorAppearances = expandVectorAppearances; exports.sanitizeVectorEffects = sanitizeVectorEffects; exports.transformVectorEffects = transformVectorEffects; exports.vectorEnteredGroups = vectorEnteredGroups; exports.isVectorMasterPage = isVectorMasterPage; exports.vectorPages = vectorPages; exports.vectorMasterPages = vectorMasterPages; exports.vectorMasterArt = vectorMasterArt; exports.resolveVectorMasterPages = resolveVectorMasterPages; exports.stripVectorMasterArt = stripVectorMasterArt; exports.isVectorConnector = isVectorConnector; exports.vectorConnectionSites = vectorConnectionSites; exports.nearestVectorConnectionSite = nearestVectorConnectionSite; exports.vectorConnectorWorldAnchors = vectorConnectorWorldAnchors; exports.routeVectorConnector = routeVectorConnector; exports.rerouteVectorConnectors = rerouteVectorConnectors; exports.sanitizeVectorConnector = sanitizeVectorConnector; exports.VECTOR_CONNECTOR_ROUTE_LABELS = VECTOR_CONNECTOR_ROUTE_LABELS; exports.VECTOR_CONNECTOR_SIDE_LABELS = VECTOR_CONNECTOR_SIDE_LABELS; exports.getVectorConnectorPanel = getVectorConnectorPanel; exports.vectorConnectorTargetAt = vectorConnectorTargetAt; exports.vectorStrokeGradientDefs = vectorStrokeGradientDefs; exports.vectorCornersAttribute = vectorCornersAttribute; exports.applyVectorCornersAttribute = applyVectorCornersAttribute; exports.vectorPathLocalBounds = vectorPathLocalBounds; exports.vectorPaintToSvg = vectorPaintToSvg; exports.vectorStrokeSvgParts = vectorStrokeSvgParts; exports.vectorNodeLocalPaintBounds = vectorNodeLocalPaintBounds; exports.vectorNodeFilterSvg = vectorNodeFilterSvg; exports.widthProfileToAttribute = widthProfileToAttribute; exports.widthProfileFromAttribute = widthProfileFromAttribute; exports.vectorDocumentToSvg = vectorDocumentToSvg; exports.parseSvgTransform = parseSvgTransform; exports.parseVectorSvg = parseVectorSvg; exports.VECTOR_SPATIAL_MIN = VECTOR_SPATIAL_MIN; exports.VectorRTree = VectorRTree; exports.vectorNodePaintBox = vectorNodePaintBox; exports.vectorSpatialIndex = vectorSpatialIndex; exports.vectorNodesNear = vectorNodesNear; exports.cloneAnchor = cloneAnchor; exports.cloneSubpath = cloneSubpath; exports.cloneVectorNode = cloneVectorNode; exports.cloneVectorDocument = cloneVectorDocument; exports.hasPaint = hasPaint; exports.subpathSegmentCount = subpathSegmentCount; exports.subpathSegment = subpathSegment; exports.subpathsToBezier = subpathsToBezier; exports.vectorNodeToBezier = vectorNodeToBezier; exports.vectorPathData = vectorPathData; exports.inferAnchorType = inferAnchorType; exports.bezierToSubpaths = bezierToSubpaths; exports.walkVectorNodes = walkVectorNodes; exports.findVectorNode = findVectorNode; exports.locateVectorNode = locateVectorNode; exports.collectPaintedNodes = collectPaintedNodes; exports.collectPathNodes = collectPathNodes; exports.nodeMatrix = nodeMatrix; exports.vectorPathWorldBezier = vectorPathWorldBezier; exports.vectorNodeBounds = vectorNodeBounds; exports.unionBounds = unionBounds; exports.boundsIntersect = boundsIntersect; exports.boundsFromPoints = boundsFromPoints; exports.hitTestVectorNode = hitTestVectorNode; exports.vectorStrokeOutline = vectorStrokeOutline; exports.hitTestVectorNodes = hitTestVectorNodes; exports.nearestSegment = nearestSegment; exports.transformVectorNode = transformVectorNode; exports.vectorNodeRotation = vectorNodeRotation; exports.vectorWorldMatrix = vectorWorldMatrix; exports.vectorParentMatrix = vectorParentMatrix; exports.translateAnchor = translateAnchor; exports.moveAnchorHandle = moveAnchorHandle; exports.convertAnchor = convertAnchor; exports.insertAnchor = insertAnchor; exports.removeAnchors = removeAnchors; exports.reverseSubpath = reverseSubpath; exports.KAPPA = KAPPA2; exports.rectSubpath = rectSubpath; exports.ellipseSubpath = ellipseSubpath; exports.polygonSubpath = polygonSubpath; exports.starSubpath = starSubpath; exports.lineSubpath = lineSubpath; exports.roundSubpaths = roundSubpaths;