@pixerate/editor 0.108.0 → 0.109.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 (74) hide show
  1. package/dist/animation/index.cjs +5 -5
  2. package/dist/animation/index.cjs.map +1 -1
  3. package/dist/animation/index.js +9 -9
  4. package/dist/animation-editor/index.cjs +59 -59
  5. package/dist/animation-editor/index.cjs.map +1 -1
  6. package/dist/animation-editor/index.d.cts +2 -1
  7. package/dist/animation-editor/index.d.ts +2 -1
  8. package/dist/animation-editor/index.js +29 -29
  9. package/dist/canvas/index.cjs +27 -27
  10. package/dist/canvas/index.cjs.map +1 -1
  11. package/dist/canvas/index.js +11 -11
  12. package/dist/{chunk-2FGRTYJN.cjs → chunk-477UVMNR.cjs} +3 -3
  13. package/dist/{chunk-2FGRTYJN.cjs.map → chunk-477UVMNR.cjs.map} +1 -1
  14. package/dist/{chunk-T3QZ6S47.cjs → chunk-AZTZRLDI.cjs} +40 -2
  15. package/dist/chunk-AZTZRLDI.cjs.map +1 -0
  16. package/dist/{chunk-HUQ7EHVI.js → chunk-BLWCAQCW.js} +723 -1975
  17. package/dist/chunk-BLWCAQCW.js.map +1 -0
  18. package/dist/{chunk-G4BIYE6R.js → chunk-CFMWALBM.js} +39 -1
  19. package/dist/chunk-CFMWALBM.js.map +1 -0
  20. package/dist/{chunk-FRD3FUXI.cjs → chunk-D37BX2ZA.cjs} +2081 -460
  21. package/dist/chunk-D37BX2ZA.cjs.map +1 -0
  22. package/dist/chunk-JLYX4V57.cjs +2001 -0
  23. package/dist/chunk-JLYX4V57.cjs.map +1 -0
  24. package/dist/chunk-KB2YBCVS.js +2001 -0
  25. package/dist/chunk-KB2YBCVS.js.map +1 -0
  26. package/dist/{chunk-SOROZ2BF.js → chunk-RE77QYUF.js} +1938 -317
  27. package/dist/chunk-RE77QYUF.js.map +1 -0
  28. package/dist/{chunk-UTEVPQTS.cjs → chunk-W3GXSUSQ.cjs} +746 -1998
  29. package/dist/chunk-W3GXSUSQ.cjs.map +1 -0
  30. package/dist/{chunk-JK6M6V7G.js → chunk-Z3YWVUWT.js} +4 -4
  31. package/dist/{export-a9bnF7Cl.d.ts → export-BLPLaE6Z.d.ts} +417 -16
  32. package/dist/{export-JGWQEPJn.d.cts → export-DSUc4fQD.d.cts} +417 -16
  33. package/dist/image-editor/index.cjs +1527 -1001
  34. package/dist/image-editor/index.cjs.map +1 -1
  35. package/dist/image-editor/index.d.cts +73 -9
  36. package/dist/image-editor/index.d.ts +73 -9
  37. package/dist/image-editor/index.js +814 -288
  38. package/dist/image-editor/index.js.map +1 -1
  39. package/dist/paint-editor/index.cjs +56 -53
  40. package/dist/paint-editor/index.cjs.map +1 -1
  41. package/dist/paint-editor/index.d.cts +5 -2
  42. package/dist/paint-editor/index.d.ts +5 -2
  43. package/dist/paint-editor/index.js +6 -3
  44. package/dist/paint-editor/index.js.map +1 -1
  45. package/dist/raster/index.cjs +4 -2
  46. package/dist/raster/index.cjs.map +1 -1
  47. package/dist/raster/index.d.cts +3 -129
  48. package/dist/raster/index.d.ts +3 -129
  49. package/dist/raster/index.js +3 -1
  50. package/dist/{compositor-D92URMlm.d.cts → render-C-fO_mes.d.cts} +135 -1
  51. package/dist/{compositor-Kt_M4ruo.d.ts → render-OLIMk_v0.d.ts} +135 -1
  52. package/dist/{svg-SseJTIrA.d.ts → svg-D_cfkhlB.d.cts} +3 -629
  53. package/dist/{svg-ClVIG4T7.d.cts → svg-wIaKLrU0.d.ts} +3 -629
  54. package/dist/types-DtL_qLFz.d.ts +630 -0
  55. package/dist/types-DyQq-WPY.d.cts +630 -0
  56. package/dist/vector/index.cjs +563 -563
  57. package/dist/vector/index.cjs.map +1 -1
  58. package/dist/vector/index.d.cts +4 -2
  59. package/dist/vector/index.d.ts +4 -2
  60. package/dist/vector/index.js +69 -69
  61. package/dist/video-editor/index.cjs +3 -3
  62. package/dist/video-editor/index.js +2 -2
  63. package/package.json +1 -1
  64. package/dist/chunk-DWGZUSES.cjs +0 -694
  65. package/dist/chunk-DWGZUSES.cjs.map +0 -1
  66. package/dist/chunk-FRD3FUXI.cjs.map +0 -1
  67. package/dist/chunk-G4BIYE6R.js.map +0 -1
  68. package/dist/chunk-HUQ7EHVI.js.map +0 -1
  69. package/dist/chunk-KKREERP2.js +0 -694
  70. package/dist/chunk-KKREERP2.js.map +0 -1
  71. package/dist/chunk-SOROZ2BF.js.map +0 -1
  72. package/dist/chunk-T3QZ6S47.cjs.map +0 -1
  73. package/dist/chunk-UTEVPQTS.cjs.map +0 -1
  74. /package/dist/{chunk-JK6M6V7G.js.map → chunk-Z3YWVUWT.js.map} +0 -0
@@ -37,7 +37,11 @@
37
37
 
38
38
 
39
39
 
40
- var _chunkT3QZ6S47cjs = require('./chunk-T3QZ6S47.cjs');
40
+
41
+
42
+
43
+
44
+ var _chunkAZTZRLDIcjs = require('./chunk-AZTZRLDI.cjs');
41
45
 
42
46
 
43
47
 
@@ -59,6 +63,11 @@ var _chunkMUUXNRU4cjs = require('./chunk-MUUXNRU4.cjs');
59
63
 
60
64
 
61
65
 
66
+
67
+
68
+
69
+
70
+
62
71
  var _chunkSZ6KMZNMcjs = require('./chunk-SZ6KMZNM.cjs');
63
72
 
64
73
 
@@ -74,7 +83,23 @@ var _chunkSZ6KMZNMcjs = require('./chunk-SZ6KMZNM.cjs');
74
83
 
75
84
 
76
85
 
77
- var _chunkDWGZUSEScjs = require('./chunk-DWGZUSES.cjs');
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ var _chunkW3GXSUSQcjs = require('./chunk-W3GXSUSQ.cjs');
97
+
98
+
99
+
100
+
101
+
102
+ var _chunkXGD3FSNCcjs = require('./chunk-XGD3FSNC.cjs');
78
103
 
79
104
  // src/image-editor/color.ts
80
105
  var LEGACY_PROCESS_VERSION = 1;
@@ -793,12 +818,12 @@ function selectionFromPixels(pixels, options = {}) {
793
818
  const { width, height, data } = pixels;
794
819
  checkSize(width, height);
795
820
  if (data.length < width * height * 4) throw new Error("Pixel data is shorter than width \xD7 height \xD7 4");
796
- const channel = _nullishCoalesce(options.channel, () => ( "luminance"));
821
+ const channel2 = _nullishCoalesce(options.channel, () => ( "luminance"));
797
822
  const out = new Uint8Array(width * height);
798
823
  const threshold = options.threshold;
799
824
  for (let i = 0, p = 0; i < out.length; i++, p += 4) {
800
825
  let v;
801
- switch (channel) {
826
+ switch (channel2) {
802
827
  case "alpha":
803
828
  v = data[p + 3];
804
829
  break;
@@ -1086,7 +1111,7 @@ function smoothCoverage(m, w, h, r) {
1086
1111
  return src;
1087
1112
  }
1088
1113
  function featherCoverage(m, w, h, radius) {
1089
- const out = _chunkT3QZ6S47cjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
1114
+ const out = _chunkAZTZRLDIcjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
1090
1115
  for (let i = 0; i < out.length; i++) if (Math.abs(out[i]) < 1e-7) out[i] = 0;
1091
1116
  return out;
1092
1117
  }
@@ -1234,7 +1259,7 @@ function layerMaskCoverage(mask) {
1234
1259
  let v = new Float32Array(sel.data.length);
1235
1260
  for (let i = 0; i < v.length; i++) v[i] = sel.data[i] / 255;
1236
1261
  const feather = _nullishCoalesce(mask.feather, () => ( 0));
1237
- if (feather > 0) v = _chunkT3QZ6S47cjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
1262
+ if (feather > 0) v = _chunkAZTZRLDIcjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
1238
1263
  const density = _nullishCoalesce(mask.density, () => ( 1));
1239
1264
  if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
1240
1265
  return v;
@@ -1477,7 +1502,7 @@ function normalizeAdjustmentLayers(raw) {
1477
1502
  return out;
1478
1503
  }
1479
1504
  function curveLutFromLevels(points) {
1480
- return _chunkT3QZ6S47cjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
1505
+ return _chunkAZTZRLDIcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
1481
1506
  }
1482
1507
  var toUnitLevels = (c) => ({
1483
1508
  inBlack: c.inBlack / 255,
@@ -2197,12 +2222,14 @@ function removeAlpha(imageData) {
2197
2222
  }
2198
2223
 
2199
2224
  // src/image-editor/layers/model.ts
2225
+ var SHAPE_OPERATIONS = ["combine", "subtract", "intersect", "exclude"];
2226
+ var LIVE_SHAPE_KINDS = ["rect", "ellipse", "polygon", "star", "line"];
2200
2227
  var idCounter = 0;
2201
2228
  function newLayerId(prefix = "layer") {
2202
2229
  return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
2203
2230
  }
2204
2231
  function pixelLayers(layers) {
2205
- return _chunkT3QZ6S47cjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
2232
+ return _chunkAZTZRLDIcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
2206
2233
  }
2207
2234
  function developFilter(layer) {
2208
2235
  return _optionalChain([layer, 'access', _8 => _8.filters, 'optionalAccess', _9 => _9.find, 'call', _10 => _10((f) => f.kind === "develop")]);
@@ -2224,13 +2251,19 @@ function pixelLayerBounds(layer, surface = layer.surface) {
2224
2251
  return { x: b.x + layer.offset.x, y: b.y + layer.offset.y, width: b.width, height: b.height };
2225
2252
  }
2226
2253
  function layerTypeLabel(type) {
2227
- return type === "pixel" ? "Pixel layer" : type === "adjustment" ? "Adjustment layer" : type === "group" ? "Group" : type === "smart" ? "Smart object" : "Annotation";
2254
+ return type === "pixel" ? "Pixel layer" : type === "adjustment" ? "Adjustment layer" : type === "group" ? "Group" : type === "smart" ? "Smart object" : type === "shape" ? "Shape layer" : "Annotation";
2228
2255
  }
2229
2256
  function hasSurface(layer) {
2230
- return layer.type === "pixel" || layer.type === "smart";
2257
+ return layer.type === "pixel" || layer.type === "smart" || layer.type === "shape";
2258
+ }
2259
+ function isRenderedLayer(layer) {
2260
+ return layer.type === "smart" || layer.type === "shape";
2261
+ }
2262
+ function shapeLayers(layers) {
2263
+ return _chunkAZTZRLDIcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
2231
2264
  }
2232
2265
  function smartObjectLayers(layers) {
2233
- return _chunkT3QZ6S47cjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
2266
+ return _chunkAZTZRLDIcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
2234
2267
  }
2235
2268
 
2236
2269
  // src/image-editor/layers/compositor.ts
@@ -2322,8 +2355,11 @@ var PHOTO_PROFILE = {
2322
2355
  contentBlend: (l) => l.type === "annotation" && l.blend === "normal" && l.annotation.blend ? l.annotation.blend : l.blend,
2323
2356
  layerKey: (l) => l.type === "pixel" ? [_nullishCoalesce(l.filters, () => ( null)), _nullishCoalesce(l.source, () => ( null))] : l.type === "adjustment" ? [l.kind, l.params] : l.type === "annotation" ? l.annotation : void 0,
2324
2357
  pixelFilters: (l) => l.type === "pixel" ? pixelFilterSpec(l) : null,
2325
- /** A smart object draws its rendered pixels (contents → placement → smart filters) like a pixel layer. */
2326
- isPixelLike: (l) => l.type === "smart",
2358
+ /**
2359
+ * A smart object draws its rendered pixels (contents → placement → smart filters) like a pixel
2360
+ * layer, and a shape layer the pixels rendered from its paths.
2361
+ */
2362
+ isPixelLike: (l) => l.type === "smart" || l.type === "shape",
2327
2363
  maskSourcePlane: (source, W, H, sources) => {
2328
2364
  const opts = source;
2329
2365
  const depth = _nullishCoalesce(_optionalChain([sources, 'access', _17 => _17.depthMap, 'optionalCall', _18 => _18(opts)]), () => ( null));
@@ -2333,169 +2369,540 @@ var PHOTO_PROFILE = {
2333
2369
  return v;
2334
2370
  }
2335
2371
  };
2336
- var LayerCompositor = class extends _chunkT3QZ6S47cjs.RasterCompositor {
2372
+ var LayerCompositor = class extends _chunkAZTZRLDIcjs.RasterCompositor {
2337
2373
  constructor(options = {}) {
2338
2374
  super(PHOTO_PROFILE, options);
2339
2375
  }
2340
2376
  };
2341
2377
 
2342
- // src/image-editor/transform.ts
2343
- var FREE_TRANSFORM_MODES = ["scale", "rotate", "skew", "distort", "perspective", "warp"];
2344
- var TRANSFORM_ANCHORS = ["top-left", "top", "top-right", "left", "center", "right", "bottom-left", "bottom", "bottom-right"];
2345
- var ANCHOR_FRACTION = {
2346
- "top-left": [0, 0],
2347
- top: [0.5, 0],
2348
- "top-right": [1, 0],
2349
- left: [0, 0.5],
2350
- center: [0.5, 0.5],
2351
- right: [1, 0.5],
2352
- "bottom-left": [0, 1],
2353
- bottom: [0.5, 1],
2354
- "bottom-right": [1, 1]
2355
- };
2356
- function isTransformAnchor(value) {
2357
- return typeof value === "string" && value in ANCHOR_FRACTION;
2358
- }
2359
- function identityTransform(box) {
2360
- return { box: { ...box }, corners: _chunkMUUXNRU4cjs.boxQuad.call(void 0, box) };
2361
- }
2362
- function cornersFromMatrix(box, m) {
2363
- const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, box);
2364
- return [_chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[0]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[1]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[2]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[3])];
2365
- }
2366
- function matrixFromCorners(box, corners, eps = 1e-6) {
2367
- const [tl, tr, br, bl] = corners;
2368
- const size = 1 + Math.max(box.width, box.height);
2369
- if (Math.abs(tl.x + br.x - tr.x - bl.x) > eps * size || Math.abs(tl.y + br.y - tr.y - bl.y) > eps * size) return null;
2370
- const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, box, corners);
2371
- return h ? _chunkMUUXNRU4cjs.affineFromHomography.call(void 0, h, 1e-9) : null;
2372
- }
2373
- function transformHomography(geometry) {
2374
- const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
2375
- if (!h) return null;
2376
- return _chunkMUUXNRU4cjs.homographyKeepsQuad.call(void 0, h, _chunkMUUXNRU4cjs.boxQuad.call(void 0, geometry.box)) ? h : null;
2377
- }
2378
- function hasWarp(geometry) {
2379
- const w = geometry.warp;
2380
- if (!w) return false;
2381
- const id = _chunkDWGZUSEScjs.identityWarpMesh.call(void 0, geometry.box, w.us.length - 1, w.vs.length - 1);
2382
- if (id.points.length !== w.points.length || id.us.some((u, i) => Math.abs(u - w.us[i]) > 1e-12) || id.vs.some((v, i) => Math.abs(v - w.vs[i]) > 1e-12)) return true;
2383
- return w.points.some((p, i) => Math.abs(p.x - id.points[i].x) > 1e-6 || Math.abs(p.y - id.points[i].y) > 1e-6);
2384
- }
2385
- function isIdentityTransform(geometry) {
2386
- if (hasWarp(geometry)) return false;
2387
- const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, geometry.box);
2388
- return geometry.corners.every((c, i) => Math.abs(c.x - q2[i].x) < 1e-6 && Math.abs(c.y - q2[i].y) < 1e-6);
2389
- }
2390
- function transformMap(geometry) {
2391
- const h = transformHomography(geometry);
2392
- if (!h) return null;
2393
- const { box } = geometry;
2394
- const warp = hasWarp(geometry) ? geometry.warp : null;
2395
- if (!warp) return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p);
2396
- return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, _chunkDWGZUSEScjs.evalWarpMesh.call(void 0, warp, (p.x - box.x) / box.width, (p.y - box.y) / box.height));
2397
- }
2398
- function transformedPoint(geometry, fx, fy) {
2399
- const f = transformMap(geometry);
2400
- const { box } = geometry;
2401
- return f ? f({ x: box.x + fx * box.width, y: box.y + fy * box.height }) : null;
2402
- }
2403
- function anchorPoint(geometry, anchor) {
2404
- const [fx, fy] = ANCHOR_FRACTION[anchor];
2405
- const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
2406
- const p = { x: geometry.box.x + fx * geometry.box.width, y: geometry.box.y + fy * geometry.box.height };
2407
- return _nullishCoalesce((h && _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p)), () => ( p));
2408
- }
2409
- function transformedBox(geometry) {
2410
- const f = transformMap(geometry);
2411
- if (!f) return null;
2412
- const { box } = geometry;
2413
- const pts = [];
2414
- const n = hasWarp(geometry) ? 16 : 1;
2415
- for (let i = 0; i <= n; i++) {
2416
- const t = i / n;
2417
- for (const [fx, fy] of [[t, 0], [1, t], [1 - t, 1], [0, 1 - t]]) {
2418
- const p = f({ x: box.x + fx * box.width, y: box.y + fy * box.height });
2419
- if (!p) return null;
2420
- pts.push(p);
2378
+ // src/image-editor/layers/vector-raster.ts
2379
+ var FLATNESS = 0.01;
2380
+ function flattenPath(path, tolerance = FLATNESS) {
2381
+ const out = [];
2382
+ let pts = [];
2383
+ let cx = 0;
2384
+ let cy = 0;
2385
+ let sx = 0;
2386
+ let sy = 0;
2387
+ const flush = () => {
2388
+ if (pts.length >= 6) out.push(Float64Array.from(pts));
2389
+ pts = [];
2390
+ };
2391
+ const steps = (dd, degree) => Math.max(1, Math.min(1024, Math.ceil(Math.sqrt(degree * (degree - 1) * dd / (8 * tolerance)))));
2392
+ for (const c of path) {
2393
+ switch (c.type) {
2394
+ case "M":
2395
+ flush();
2396
+ cx = sx = c.x;
2397
+ cy = sy = c.y;
2398
+ pts.push(cx, cy);
2399
+ break;
2400
+ case "L":
2401
+ if (!pts.length) pts.push(cx, cy);
2402
+ cx = c.x;
2403
+ cy = c.y;
2404
+ pts.push(cx, cy);
2405
+ break;
2406
+ case "Q": {
2407
+ if (!pts.length) pts.push(cx, cy);
2408
+ const n = steps(Math.hypot(cx - 2 * c.x1 + c.x, cy - 2 * c.y1 + c.y), 2);
2409
+ for (let k = 1; k <= n; k++) {
2410
+ const t = k / n;
2411
+ const u = 1 - t;
2412
+ pts.push(u * u * cx + 2 * u * t * c.x1 + t * t * c.x, u * u * cy + 2 * u * t * c.y1 + t * t * c.y);
2413
+ }
2414
+ cx = c.x;
2415
+ cy = c.y;
2416
+ break;
2417
+ }
2418
+ case "C": {
2419
+ if (!pts.length) pts.push(cx, cy);
2420
+ const dd = Math.max(Math.hypot(cx - 2 * c.x1 + c.x2, cy - 2 * c.y1 + c.y2), Math.hypot(c.x1 - 2 * c.x2 + c.x, c.y1 - 2 * c.y2 + c.y));
2421
+ const n = steps(dd, 3);
2422
+ for (let k = 1; k <= n; k++) {
2423
+ const t = k / n;
2424
+ const u = 1 - t;
2425
+ const a = u * u * u;
2426
+ const b = 3 * u * u * t;
2427
+ const d = 3 * u * t * t;
2428
+ const e = t * t * t;
2429
+ pts.push(a * cx + b * c.x1 + d * c.x2 + e * c.x, a * cy + b * c.y1 + d * c.y2 + e * c.y);
2430
+ }
2431
+ cx = c.x;
2432
+ cy = c.y;
2433
+ break;
2434
+ }
2435
+ case "Z":
2436
+ flush();
2437
+ cx = sx;
2438
+ cy = sy;
2439
+ break;
2421
2440
  }
2422
2441
  }
2423
- const xs = pts.map((p) => p.x);
2424
- const ys = pts.map((p) => p.y);
2425
- const x = Math.min(...xs);
2426
- const y = Math.min(...ys);
2427
- return { x, y, width: Math.max(...xs) - x, height: Math.max(...ys) - y };
2428
- }
2429
- function referencePoint(box, reference) {
2430
- if (reference && typeof reference === "object") return { x: reference.x, y: reference.y };
2431
- const [fx, fy] = ANCHOR_FRACTION[_nullishCoalesce(reference, () => ( "center"))];
2432
- return { x: box.x + fx * box.width, y: box.y + fy * box.height };
2433
- }
2434
- function matrixFromParams(box, params) {
2435
- const sx = (_nullishCoalesce(params.scaleX, () => ( 100))) / 100;
2436
- const sy = (_nullishCoalesce(params.scaleY, () => ( 100))) / 100;
2437
- const tx = Math.tan((_nullishCoalesce(params.skewX, () => ( 0))) * Math.PI / 180);
2438
- const ty = Math.tan((_nullishCoalesce(params.skewY, () => ( 0))) * Math.PI / 180);
2439
- const ref = referencePoint(box, params.reference);
2440
- const linear = _chunkDWGZUSEScjs.multiplyMatrices.call(void 0, _chunkDWGZUSEScjs.multiplyMatrices.call(void 0, [1, ty, tx, 1, 0, 0], [sx, 0, 0, sy, 0, 0]), _chunkDWGZUSEScjs.rotateMatrix.call(void 0, _nullishCoalesce(params.rotate, () => ( 0))));
2441
- return _chunkDWGZUSEScjs.multiplyMatrices.call(void 0, _chunkDWGZUSEScjs.matrixAbout.call(void 0, linear, ref), _chunkDWGZUSEScjs.translateMatrix.call(void 0, _nullishCoalesce(params.dx, () => ( 0)), _nullishCoalesce(params.dy, () => ( 0))));
2442
- }
2443
- function describeTransform(geometry, reference = "center") {
2444
- const m = hasWarp(geometry) ? null : matrixFromCorners(geometry.box, geometry.corners);
2445
- const ref = referencePoint(geometry.box, reference);
2446
- const bounds = transformedBox(geometry);
2447
- if (!m) {
2448
- const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
2449
- const at2 = _nullishCoalesce((h && _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, ref)), () => ( ref));
2450
- return { affine: false, scaleX: 100, scaleY: 100, rotate: 0, skewX: 0, x: at2.x, y: at2.y, bounds, corners: geometry.corners };
2442
+ flush();
2443
+ return out.filter((p) => p.every(Number.isFinite));
2444
+ }
2445
+ function flatBounds(flat) {
2446
+ let x0 = Infinity;
2447
+ let y0 = Infinity;
2448
+ let x1 = -Infinity;
2449
+ let y1 = -Infinity;
2450
+ for (const p of flat) {
2451
+ for (let i = 0; i < p.length; i += 2) {
2452
+ if (p[i] < x0) x0 = p[i];
2453
+ if (p[i] > x1) x1 = p[i];
2454
+ if (p[i + 1] < y0) y0 = p[i + 1];
2455
+ if (p[i + 1] > y1) y1 = p[i + 1];
2456
+ }
2457
+ }
2458
+ if (x0 === Infinity) return null;
2459
+ const x = Math.floor(x0);
2460
+ const y = Math.floor(y0);
2461
+ return { x, y, width: Math.ceil(x1) - x, height: Math.ceil(y1) - y };
2462
+ }
2463
+ function drawLine(a, w, h, x0, y0, x1, y1) {
2464
+ if (y0 === y1) return;
2465
+ let dir = 1;
2466
+ if (y0 > y1) {
2467
+ dir = -1;
2468
+ let t = x0;
2469
+ x0 = x1;
2470
+ x1 = t;
2471
+ t = y0;
2472
+ y0 = y1;
2473
+ y1 = t;
2474
+ }
2475
+ if (y1 <= 0 || y0 >= h) return;
2476
+ const dxdy = (x1 - x0) / (y1 - y0);
2477
+ let x = x0;
2478
+ if (y0 < 0) x -= y0 * dxdy;
2479
+ const rowStart = Math.max(0, Math.floor(y0));
2480
+ const rowEnd = Math.min(h, Math.ceil(y1));
2481
+ for (let y = rowStart; y < rowEnd; y++) {
2482
+ const line = y * w;
2483
+ const dy = Math.min(y + 1, y1) - Math.max(y, y0);
2484
+ const xnext = x + dxdy * dy;
2485
+ const d = dy * dir;
2486
+ const xa = x < xnext ? x : xnext;
2487
+ const xb = x < xnext ? xnext : x;
2488
+ const xaFloor = Math.floor(xa);
2489
+ const xai = xaFloor;
2490
+ const xbCeil = Math.ceil(xb);
2491
+ const xbi = xbCeil;
2492
+ if (xbi <= xai + 1) {
2493
+ const xmf = 0.5 * (x + xnext) - xaFloor;
2494
+ a[line + xai] += d - d * xmf;
2495
+ a[line + xai + 1] += d * xmf;
2496
+ } else {
2497
+ const s = 1 / (xb - xa);
2498
+ const xaf = xa - xaFloor;
2499
+ const a0 = 0.5 * s * (1 - xaf) * (1 - xaf);
2500
+ const xbf = xb - xbCeil + 1;
2501
+ const am = 0.5 * s * xbf * xbf;
2502
+ a[line + xai] += d * a0;
2503
+ if (xbi === xai + 2) a[line + xai + 1] += d * (1 - a0 - am);
2504
+ else {
2505
+ const a1 = s * (1.5 - xaf);
2506
+ a[line + xai + 1] += d * (a1 - a0);
2507
+ for (let xi = xai + 2; xi < xbi - 1; xi++) a[line + xi] += d * s;
2508
+ const a2 = a1 + (xbi - xai - 3) * s;
2509
+ a[line + xbi - 1] += d * (1 - a2 - am);
2510
+ }
2511
+ a[line + xbi] += d * am;
2512
+ }
2513
+ x = xnext;
2514
+ }
2515
+ }
2516
+ function drawClippedLine(a, w, h, x0, y0, x1, y1) {
2517
+ if (y0 === y1) return;
2518
+ if (y0 <= 0 && y1 <= 0 || y0 >= h && y1 >= h) return;
2519
+ if (x0 >= 0 && x0 <= w && x1 >= 0 && x1 <= w) return drawLine(a, w, h, x0, y0, x1, y1);
2520
+ const ts = [0, 1];
2521
+ const dx = x1 - x0;
2522
+ if (dx !== 0) {
2523
+ for (const edge of [0, w]) {
2524
+ const t = (edge - x0) / dx;
2525
+ if (t > 0 && t < 1) ts.push(t);
2526
+ }
2527
+ }
2528
+ ts.sort((p, q2) => p - q2);
2529
+ const clamp4 = (v) => v < 0 ? 0 : v > w ? w : v;
2530
+ for (let i = 0; i + 1 < ts.length; i++) {
2531
+ const ta = ts[i];
2532
+ const tb = ts[i + 1];
2533
+ drawLine(a, w, h, clamp4(x0 + dx * ta), y0 + (y1 - y0) * ta, clamp4(x0 + dx * tb), y0 + (y1 - y0) * tb);
2534
+ }
2535
+ }
2536
+ function ruleCoverage(v, rule) {
2537
+ const m = v < 0 ? -v : v;
2538
+ if (rule === "nonzero") return m >= 1 ? 1 : m;
2539
+ const f = m % 2;
2540
+ return f > 1 ? 2 - f : f;
2541
+ }
2542
+ function rasterizeCoverage(flat, rect, rule = "nonzero") {
2543
+ const w = rect.width;
2544
+ const h = rect.height;
2545
+ if (w <= 0 || h <= 0 || !flat.length) return null;
2546
+ const a = new Float64Array(w * h + w + 4);
2547
+ const ox = rect.x;
2548
+ const oy = rect.y;
2549
+ let touched = false;
2550
+ for (const p of flat) {
2551
+ const n = p.length;
2552
+ for (let i = 0; i < n; i += 2) {
2553
+ const j = i + 2 < n ? i + 2 : 0;
2554
+ const ya = p[i + 1] - oy;
2555
+ const yb = p[j + 1] - oy;
2556
+ if (ya <= 0 && yb <= 0 || ya >= h && yb >= h || ya === yb) continue;
2557
+ drawClippedLine(a, w, h, p[i] - ox, ya, p[j] - ox, yb);
2558
+ touched = true;
2559
+ }
2560
+ }
2561
+ if (!touched) return null;
2562
+ const out = new Float32Array(w * h);
2563
+ let acc = 0;
2564
+ let any = false;
2565
+ for (let i = 0; i < out.length; i++) {
2566
+ acc += a[i];
2567
+ const c = ruleCoverage(acc, rule);
2568
+ if (c > 1e-6) {
2569
+ out[i] = c;
2570
+ any = true;
2571
+ }
2451
2572
  }
2452
- const [a, b, c, d] = m;
2453
- const sxAbs = Math.hypot(a, b);
2454
- const rot = Math.atan2(b, a) * 180 / Math.PI;
2455
- const shear = sxAbs ? (a * c + b * d) / sxAbs : 0;
2456
- const sy = sxAbs ? (a * d - b * c) / sxAbs : 0;
2457
- const skew = sxAbs ? Math.atan(shear / sxAbs) * 180 / Math.PI : 0;
2458
- const at = _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, ref);
2459
- const clean = (v) => Math.abs(v) < 1e-9 ? 0 : v;
2460
- return {
2461
- affine: true,
2462
- scaleX: clean(sxAbs * 100),
2463
- scaleY: clean(sy * 100),
2464
- rotate: clean(rot === -180 ? 180 : rot),
2465
- skewX: clean(skew),
2466
- x: at.x,
2467
- y: at.y,
2468
- bounds,
2469
- corners: geometry.corners
2470
- };
2471
- }
2472
- function applyParams(geometry, params) {
2473
- const ref = params.reference && typeof params.reference === "object" ? params.reference : anchorPoint(geometry, _nullishCoalesce(params.reference, () => ( "center")));
2474
- const m = matrixFromParams({ x: ref.x, y: ref.y, width: 0, height: 0 }, { ...params, reference: ref });
2475
- const c = geometry.corners;
2476
- return [_chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[0]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[1]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[2]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[3])];
2573
+ return any ? out : null;
2477
2574
  }
2478
- function flipCorners(geometry, axis) {
2479
- const c = anchorPoint(geometry, "center");
2480
- const m = axis === "horizontal" ? [-1, 0, 0, 1, 2 * c.x, 0] : [1, 0, 0, -1, 0, 2 * c.y];
2481
- const q2 = geometry.corners;
2482
- return [_chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[0]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[1]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[2]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, q2[3])];
2575
+ var SUB_ROWS = 16;
2576
+ function rasterizeCoverageSampled(flat, rect, rule = "nonzero") {
2577
+ const w = rect.width;
2578
+ const h = rect.height;
2579
+ if (w <= 0 || h <= 0 || !flat.length) return null;
2580
+ let n = 0;
2581
+ for (const p of flat) n += p.length >> 1;
2582
+ const ey0 = new Float64Array(n);
2583
+ const ey1 = new Float64Array(n);
2584
+ const ex0 = new Float64Array(n);
2585
+ const eslope = new Float64Array(n);
2586
+ const edir = new Int8Array(n);
2587
+ let count = 0;
2588
+ for (const p of flat) {
2589
+ const len = p.length;
2590
+ for (let i = 0; i < len; i += 2) {
2591
+ const j = i + 2 < len ? i + 2 : 0;
2592
+ let xa = p[i] - rect.x;
2593
+ let ya = p[i + 1] - rect.y;
2594
+ let xb = p[j] - rect.x;
2595
+ let yb = p[j + 1] - rect.y;
2596
+ if (ya === yb) continue;
2597
+ let dir = 1;
2598
+ if (ya > yb) {
2599
+ dir = -1;
2600
+ let t = xa;
2601
+ xa = xb;
2602
+ xb = t;
2603
+ t = ya;
2604
+ ya = yb;
2605
+ yb = t;
2606
+ }
2607
+ if (yb <= 0 || ya >= h) continue;
2608
+ ey0[count] = ya;
2609
+ ey1[count] = yb;
2610
+ ex0[count] = xa;
2611
+ eslope[count] = (xb - xa) / (yb - ya);
2612
+ edir[count] = dir;
2613
+ count++;
2614
+ }
2615
+ }
2616
+ if (!count) return null;
2617
+ const order = Array.from({ length: count }, (_, i) => i).sort((a, b) => ey0[a] - ey0[b]);
2618
+ const out = new Float32Array(w * h);
2619
+ const diff = new Float32Array(w + 1);
2620
+ let active = [];
2621
+ let next = 0;
2622
+ const xs = [];
2623
+ const ds = [];
2624
+ const idx = [];
2625
+ const f = 1 / SUB_ROWS;
2626
+ let any = false;
2627
+ const firstRow = Math.max(0, Math.floor(ey0[order[0]]));
2628
+ for (let y = firstRow; y < h; y++) {
2629
+ if (next >= count && !active.length) break;
2630
+ const row = y * w;
2631
+ let rowTouched = false;
2632
+ for (let s = 0; s < SUB_ROWS; s++) {
2633
+ const sy = y + (s + 0.5) * f;
2634
+ while (next < count && ey0[order[next]] <= sy) active.push(order[next++]);
2635
+ if (!active.length) continue;
2636
+ active = active.filter((e) => ey1[e] > sy);
2637
+ xs.length = 0;
2638
+ ds.length = 0;
2639
+ idx.length = 0;
2640
+ for (const e of active) {
2641
+ if (ey0[e] > sy) continue;
2642
+ idx.push(xs.length);
2643
+ xs.push(ex0[e] + (sy - ey0[e]) * eslope[e]);
2644
+ ds.push(edir[e]);
2645
+ }
2646
+ if (xs.length < 2) continue;
2647
+ idx.sort((a, b) => xs[a] - xs[b]);
2648
+ let wind = 0;
2649
+ for (let k = 0; k + 1 < idx.length; k++) {
2650
+ wind += ds[idx[k]];
2651
+ const inside = rule === "nonzero" ? wind !== 0 : (wind & 1) !== 0;
2652
+ if (!inside) continue;
2653
+ let xa = xs[idx[k]];
2654
+ let xb = xs[idx[k + 1]];
2655
+ if (xb <= 0 || xa >= w || xb <= xa) continue;
2656
+ if (xa < 0) xa = 0;
2657
+ if (xb > w) xb = w;
2658
+ const ia = Math.floor(xa);
2659
+ const ib = Math.floor(xb);
2660
+ rowTouched = true;
2661
+ if (ia === ib) {
2662
+ out[row + ia] += (xb - xa) * f;
2663
+ continue;
2664
+ }
2665
+ out[row + ia] += (ia + 1 - xa) * f;
2666
+ diff[ia + 1] += f;
2667
+ diff[ib] -= f;
2668
+ if (ib < w) out[row + ib] += (xb - ib) * f;
2669
+ }
2670
+ }
2671
+ if (!rowTouched) continue;
2672
+ let run = 0;
2673
+ for (let x = 0; x < w; x++) {
2674
+ run += diff[x];
2675
+ diff[x] = 0;
2676
+ const v = out[row + x] + run;
2677
+ out[row + x] = v > 1 ? 1 : v < 1e-6 ? 0 : v;
2678
+ if (out[row + x] > 0) any = true;
2679
+ }
2680
+ diff[w] = 0;
2681
+ }
2682
+ return any ? out : null;
2683
+ }
2684
+ function combineCoverage(a, b, op, n) {
2685
+ if (op === "combine") {
2686
+ if (!a) return b;
2687
+ if (!b) return a;
2688
+ const out2 = new Float32Array(n);
2689
+ for (let i = 0; i < n; i++) out2[i] = a[i] + b[i] - a[i] * b[i];
2690
+ return out2;
2691
+ }
2692
+ if (op === "subtract") {
2693
+ if (!a || !b) return a;
2694
+ const out2 = new Float32Array(n);
2695
+ for (let i = 0; i < n; i++) out2[i] = a[i] * (1 - b[i]);
2696
+ return out2;
2697
+ }
2698
+ if (op === "intersect") {
2699
+ if (!a || !b) return null;
2700
+ const out2 = new Float32Array(n);
2701
+ for (let i = 0; i < n; i++) out2[i] = a[i] * b[i];
2702
+ return out2;
2703
+ }
2704
+ if (!a) return b;
2705
+ if (!b) return a;
2706
+ const out = new Float32Array(n);
2707
+ for (let i = 0; i < n; i++) out[i] = a[i] + b[i] - 2 * a[i] * b[i];
2708
+ return out;
2483
2709
  }
2484
- function boxPointOf(geometry, p) {
2485
- const m = matrixFromCorners(geometry.box, geometry.corners);
2486
- if (m) return _chunkDWGZUSEScjs.applyMatrix.call(void 0, _chunkDWGZUSEScjs.invertMatrix.call(void 0, m), p);
2710
+
2711
+ // src/image-editor/layers/css-color.ts
2712
+ var NAMED = {
2713
+ aliceblue: "f0f8ff",
2714
+ antiquewhite: "faebd7",
2715
+ aqua: "00ffff",
2716
+ aquamarine: "7fffd4",
2717
+ azure: "f0ffff",
2718
+ beige: "f5f5dc",
2719
+ bisque: "ffe4c4",
2720
+ black: "000000",
2721
+ blanchedalmond: "ffebcd",
2722
+ blue: "0000ff",
2723
+ blueviolet: "8a2be2",
2724
+ brown: "a52a2a",
2725
+ burlywood: "deb887",
2726
+ cadetblue: "5f9ea0",
2727
+ chartreuse: "7fff00",
2728
+ chocolate: "d2691e",
2729
+ coral: "ff7f50",
2730
+ cornflowerblue: "6495ed",
2731
+ cornsilk: "fff8dc",
2732
+ crimson: "dc143c",
2733
+ cyan: "00ffff",
2734
+ darkblue: "00008b",
2735
+ darkcyan: "008b8b",
2736
+ darkgoldenrod: "b8860b",
2737
+ darkgray: "a9a9a9",
2738
+ darkgreen: "006400",
2739
+ darkgrey: "a9a9a9",
2740
+ darkkhaki: "bdb76b",
2741
+ darkmagenta: "8b008b",
2742
+ darkolivegreen: "556b2f",
2743
+ darkorange: "ff8c00",
2744
+ darkorchid: "9932cc",
2745
+ darkred: "8b0000",
2746
+ darksalmon: "e9967a",
2747
+ darkseagreen: "8fbc8f",
2748
+ darkslateblue: "483d8b",
2749
+ darkslategray: "2f4f4f",
2750
+ darkslategrey: "2f4f4f",
2751
+ darkturquoise: "00ced1",
2752
+ darkviolet: "9400d3",
2753
+ deeppink: "ff1493",
2754
+ deepskyblue: "00bfff",
2755
+ dimgray: "696969",
2756
+ dimgrey: "696969",
2757
+ dodgerblue: "1e90ff",
2758
+ firebrick: "b22222",
2759
+ floralwhite: "fffaf0",
2760
+ forestgreen: "228b22",
2761
+ fuchsia: "ff00ff",
2762
+ gainsboro: "dcdcdc",
2763
+ ghostwhite: "f8f8ff",
2764
+ gold: "ffd700",
2765
+ goldenrod: "daa520",
2766
+ gray: "808080",
2767
+ green: "008000",
2768
+ greenyellow: "adff2f",
2769
+ grey: "808080",
2770
+ honeydew: "f0fff0",
2771
+ hotpink: "ff69b4",
2772
+ indianred: "cd5c5c",
2773
+ indigo: "4b0082",
2774
+ ivory: "fffff0",
2775
+ khaki: "f0e68c",
2776
+ lavender: "e6e6fa",
2777
+ lavenderblush: "fff0f5",
2778
+ lawngreen: "7cfc00",
2779
+ lemonchiffon: "fffacd",
2780
+ lightblue: "add8e6",
2781
+ lightcoral: "f08080",
2782
+ lightcyan: "e0ffff",
2783
+ lightgoldenrodyellow: "fafad2",
2784
+ lightgray: "d3d3d3",
2785
+ lightgreen: "90ee90",
2786
+ lightgrey: "d3d3d3",
2787
+ lightpink: "ffb6c1",
2788
+ lightsalmon: "ffa07a",
2789
+ lightseagreen: "20b2aa",
2790
+ lightskyblue: "87cefa",
2791
+ lightslategray: "778899",
2792
+ lightslategrey: "778899",
2793
+ lightsteelblue: "b0c4de",
2794
+ lightyellow: "ffffe0",
2795
+ lime: "00ff00",
2796
+ limegreen: "32cd32",
2797
+ linen: "faf0e6",
2798
+ magenta: "ff00ff",
2799
+ maroon: "800000",
2800
+ mediumaquamarine: "66cdaa",
2801
+ mediumblue: "0000cd",
2802
+ mediumorchid: "ba55d3",
2803
+ mediumpurple: "9370db",
2804
+ mediumseagreen: "3cb371",
2805
+ mediumslateblue: "7b68ee",
2806
+ mediumspringgreen: "00fa9a",
2807
+ mediumturquoise: "48d1cc",
2808
+ mediumvioletred: "c71585",
2809
+ midnightblue: "191970",
2810
+ mintcream: "f5fffa",
2811
+ mistyrose: "ffe4e1",
2812
+ moccasin: "ffe4b5",
2813
+ navajowhite: "ffdead",
2814
+ navy: "000080",
2815
+ oldlace: "fdf5e6",
2816
+ olive: "808000",
2817
+ olivedrab: "6b8e23",
2818
+ orange: "ffa500",
2819
+ orangered: "ff4500",
2820
+ orchid: "da70d6",
2821
+ palegoldenrod: "eee8aa",
2822
+ palegreen: "98fb98",
2823
+ paleturquoise: "afeeee",
2824
+ palevioletred: "db7093",
2825
+ papayawhip: "ffefd5",
2826
+ peachpuff: "ffdab9",
2827
+ peru: "cd853f",
2828
+ pink: "ffc0cb",
2829
+ plum: "dda0dd",
2830
+ powderblue: "b0e0e6",
2831
+ purple: "800080",
2832
+ rebeccapurple: "663399",
2833
+ red: "ff0000",
2834
+ rosybrown: "bc8f8f",
2835
+ royalblue: "4169e1",
2836
+ saddlebrown: "8b4513",
2837
+ salmon: "fa8072",
2838
+ sandybrown: "f4a460",
2839
+ seagreen: "2e8b57",
2840
+ seashell: "fff5ee",
2841
+ sienna: "a0522d",
2842
+ silver: "c0c0c0",
2843
+ skyblue: "87ceeb",
2844
+ slateblue: "6a5acd",
2845
+ slategray: "708090",
2846
+ slategrey: "708090",
2847
+ snow: "fffafa",
2848
+ springgreen: "00ff7f",
2849
+ steelblue: "4682b4",
2850
+ tan: "d2b48c",
2851
+ teal: "008080",
2852
+ thistle: "d8bfd8",
2853
+ tomato: "ff6347",
2854
+ turquoise: "40e0d0",
2855
+ violet: "ee82ee",
2856
+ wheat: "f5deb3",
2857
+ white: "ffffff",
2858
+ whitesmoke: "f5f5f5",
2859
+ yellow: "ffff00",
2860
+ yellowgreen: "9acd32"
2861
+ };
2862
+ var hex2 = (v) => Math.round(Math.max(0, Math.min(255, v))).toString(16).padStart(2, "0");
2863
+ function channel(s) {
2864
+ return s.endsWith("%") ? parseFloat(s) / 100 * 255 : parseFloat(s);
2865
+ }
2866
+ function alphaOf(s) {
2867
+ if (s === void 0) return 1;
2868
+ const v = s.endsWith("%") ? parseFloat(s) / 100 : parseFloat(s);
2869
+ return Math.max(0, Math.min(1, v));
2870
+ }
2871
+ function hslToRgb2(h, s, l) {
2872
+ h = (h % 360 + 360) % 360;
2873
+ const c = (1 - Math.abs(2 * l - 1)) * s;
2874
+ const x = c * (1 - Math.abs(h / 60 % 2 - 1));
2875
+ const m = l - c / 2;
2876
+ const [r, g, b] = h < 60 ? [c, x, 0] : h < 120 ? [x, c, 0] : h < 180 ? [0, c, x] : h < 240 ? [0, x, c] : h < 300 ? [x, 0, c] : [c, 0, x];
2877
+ return [(r + m) * 255, (g + m) * 255, (b + m) * 255];
2878
+ }
2879
+ function parseCssColor(value) {
2880
+ if (typeof value !== "string") return null;
2881
+ const text3 = value.trim().toLowerCase();
2882
+ if (text3 === "transparent") return { hex: "#000000", alpha: 0 };
2883
+ const named = NAMED[text3];
2884
+ if (named) return { hex: `#${named}`, alpha: 1 };
2885
+ let m = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(text3);
2886
+ if (m) {
2887
+ let h = m[1];
2888
+ if (h.length <= 4) h = h.replace(/./g, (c) => c + c);
2889
+ return { hex: `#${h.slice(0, 6)}`, alpha: h.length === 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1 };
2890
+ }
2891
+ const num3 = "([+-]?[\\d.]+%?)";
2892
+ m = new RegExp(`^rgba?\\(\\s*${num3}[\\s,]+${num3}[\\s,]+${num3}(?:\\s*[,/]\\s*${num3})?\\s*\\)$`).exec(text3);
2893
+ if (m) {
2894
+ const rgb = [m[1], m[2], m[3]].map(channel);
2895
+ if (!rgb.every(Number.isFinite)) return null;
2896
+ return { hex: `#${rgb.map(hex2).join("")}`, alpha: alphaOf(m[4]) };
2897
+ }
2898
+ m = new RegExp(`^hsla?\\(\\s*([+-]?[\\d.]+)(?:deg)?[\\s,]+${num3}[\\s,]+${num3}(?:\\s*[,/]\\s*${num3})?\\s*\\)$`).exec(text3);
2899
+ if (m) {
2900
+ const rgb = hslToRgb2(parseFloat(m[1]), parseFloat(m[2]) / 100, parseFloat(m[3]) / 100);
2901
+ if (!rgb.every(Number.isFinite)) return null;
2902
+ return { hex: `#${rgb.map(hex2).join("")}`, alpha: alphaOf(m[4]) };
2903
+ }
2487
2904
  return null;
2488
2905
  }
2489
- function presetWarp(box, preset) {
2490
- return _chunkDWGZUSEScjs.warpPresetMesh.call(void 0, preset, box);
2491
- }
2492
- function isValidWarp(mesh) {
2493
- return _chunkDWGZUSEScjs.isValidWarpMesh.call(void 0, mesh);
2494
- }
2495
- function geometryHomography(geometry) {
2496
- const m = matrixFromCorners(geometry.box, geometry.corners);
2497
- return m ? _chunkMUUXNRU4cjs.homographyFromAffine.call(void 0, m) : transformHomography(geometry);
2498
- }
2499
2906
 
2500
2907
  // src/image-editor/layers/ops.ts
2501
2908
  var LayerOperationError = class extends Error {
@@ -2508,53 +2915,54 @@ var fail = (message) => {
2508
2915
  throw new LayerOperationError(message);
2509
2916
  };
2510
2917
  function requireLayer(layers, id) {
2511
- const loc = _chunkT3QZ6S47cjs.findLayer.call(void 0, layers, id);
2918
+ const loc = _chunkAZTZRLDIcjs.findLayer.call(void 0, layers, id);
2512
2919
  if (!loc) {
2513
- const ids = _chunkT3QZ6S47cjs.flattenLayers.call(void 0, layers).map((l) => l.id);
2920
+ const ids = _chunkAZTZRLDIcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
2514
2921
  fail(`Unknown layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "The document has no layers."} Call list_layers for ids.`);
2515
2922
  }
2516
2923
  return loc;
2517
2924
  }
2518
2925
  function requireUnlocked(layer, what, action) {
2519
- if (_chunkT3QZ6S47cjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
2520
- if (what !== "all" && _chunkT3QZ6S47cjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
2926
+ if (_chunkAZTZRLDIcjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
2927
+ if (what !== "all" && _chunkAZTZRLDIcjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
2521
2928
  }
2522
2929
  function placeLayer(layers, layer, placement = {}, defaultIndex) {
2523
2930
  const given = [placement.aboveId, placement.belowId, placement.parentId].filter((v) => v !== void 0).length;
2524
2931
  if (given > 1) fail("Give only one of aboveId, belowId and parentId.");
2525
2932
  if (placement.aboveId || placement.belowId) {
2526
2933
  const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
2527
- return _chunkT3QZ6S47cjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _19 => _19.parent, 'optionalAccess', _20 => _20.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
2934
+ return _chunkAZTZRLDIcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _19 => _19.parent, 'optionalAccess', _20 => _20.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
2528
2935
  }
2529
2936
  if (placement.parentId) {
2530
2937
  const ref = requireLayer(layers, placement.parentId);
2531
2938
  if (ref.layer.type !== "group") fail(`Layer "${placement.parentId}" is not a group; parentId must be a group id.`);
2532
- return _chunkT3QZ6S47cjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
2939
+ return _chunkAZTZRLDIcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
2533
2940
  }
2534
- return _chunkT3QZ6S47cjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
2941
+ return _chunkAZTZRLDIcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
2535
2942
  }
2536
2943
  function removeLayer(layers, id) {
2537
2944
  const loc = requireLayer(layers, id);
2538
2945
  requireUnlocked(loc.layer, "all", "delete it");
2539
- return _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => null);
2946
+ return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => null);
2540
2947
  }
2541
2948
  function moveLayer(layers, id, placement) {
2542
2949
  const loc = requireLayer(layers, id);
2543
2950
  requireUnlocked(loc.layer, "all", "move it");
2544
2951
  const target = _nullishCoalesce(_nullishCoalesce(placement.aboveId, () => ( placement.belowId)), () => ( placement.parentId));
2545
2952
  if (target === id) fail("A layer cannot be placed relative to itself.");
2546
- if (target && loc.layer.type === "group" && _chunkT3QZ6S47cjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
2953
+ if (target && loc.layer.type === "group" && _chunkAZTZRLDIcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
2547
2954
  fail(`Group "${id}" cannot be moved into its own child "${target}".`);
2548
2955
  }
2549
2956
  if (target) requireLayer(layers, target);
2550
2957
  if (!target && placement.index === void 0) fail("Give aboveId, belowId, parentId or index.");
2551
- const without = _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => null);
2958
+ const without = _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => null);
2552
2959
  return placeLayer(without, loc.layer, placement);
2553
2960
  }
2554
2961
  function withNewIds(layer) {
2555
2962
  const next = { ...layer, id: newLayerId(layer.type === "adjustment" ? "adj" : layer.type) };
2556
2963
  if (next.type === "group") next.children = next.children.map(withNewIds);
2557
2964
  if (next.type === "annotation") next.annotation = { ...next.annotation, id: next.id };
2965
+ if (next.type === "shape") delete next.annotation;
2558
2966
  if (next.type === "smart" && _optionalChain([next, 'access', _21 => _21.psd, 'optionalAccess', _22 => _22.placed])) {
2559
2967
  next.psd = { ...next.psd };
2560
2968
  delete next.psd.placed;
@@ -2566,7 +2974,7 @@ function duplicateLayer(layers, id, name) {
2566
2974
  const copy = withNewIds(loc.layer);
2567
2975
  copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
2568
2976
  delete copy.locks;
2569
- return { layers: _chunkT3QZ6S47cjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _23 => _23.parent, 'optionalAccess', _24 => _24.id]), () => ( null)), loc.index + 1), id: copy.id };
2977
+ return { layers: _chunkAZTZRLDIcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _23 => _23.parent, 'optionalAccess', _24 => _24.id]), () => ( null)), loc.index + 1), id: copy.id };
2570
2978
  }
2571
2979
  function setLayerProperties(layers, id, props) {
2572
2980
  const loc = requireLayer(layers, id);
@@ -2584,7 +2992,7 @@ function setLayerProperties(layers, id, props) {
2584
2992
  next.opacity = props.opacity;
2585
2993
  }
2586
2994
  if (props.fillOpacity !== void 0) {
2587
- if (layer.type !== "pixel" && layer.type !== "smart") fail(`fillOpacity applies to pixel layers and smart objects; "${id}" is a ${layer.type} layer.`);
2995
+ if (layer.type !== "pixel" && layer.type !== "smart" && layer.type !== "shape") fail(`fillOpacity applies to pixel, shape and smart object layers; "${id}" is a ${layer.type} layer.`);
2588
2996
  if (!(typeof props.fillOpacity === "number" && props.fillOpacity >= 0 && props.fillOpacity <= 1)) fail("fillOpacity must be a number from 0 to 1.");
2589
2997
  const p = next;
2590
2998
  if (props.fillOpacity === 1) delete p.fillOpacity;
@@ -2613,7 +3021,7 @@ function setLayerProperties(layers, id, props) {
2613
3021
  if (props.collapsed) g.collapsed = true;
2614
3022
  else delete g.collapsed;
2615
3023
  }
2616
- return _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => next);
3024
+ return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next);
2617
3025
  }
2618
3026
  function groupLayers(layers, ids, name = "Group") {
2619
3027
  if (!ids.length) fail("Give at least one layer id to group.");
@@ -2642,17 +3050,17 @@ function groupLayers(layers, ids, name = "Group") {
2642
3050
  group.children[0] = c;
2643
3051
  }
2644
3052
  let out = layers;
2645
- for (const l of ordered) out = _chunkT3QZ6S47cjs.mapLayer.call(void 0, out, l.layer.id, () => null);
2646
- return { layers: _chunkT3QZ6S47cjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
3053
+ for (const l of ordered) out = _chunkAZTZRLDIcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
3054
+ return { layers: _chunkAZTZRLDIcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
2647
3055
  }
2648
3056
  function ungroupLayer(layers, id) {
2649
3057
  const loc = requireLayer(layers, id);
2650
3058
  if (loc.layer.type !== "group") fail(`Layer "${id}" is not a group.`);
2651
3059
  requireUnlocked(loc.layer, "all", "ungroup it");
2652
3060
  const group = loc.layer;
2653
- let out = _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => null);
3061
+ let out = _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => null);
2654
3062
  group.children.forEach((c, i) => {
2655
- out = _chunkT3QZ6S47cjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _33 => _33.parent, 'optionalAccess', _34 => _34.id]), () => ( null)), loc.index + i);
3063
+ out = _chunkAZTZRLDIcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _33 => _33.parent, 'optionalAccess', _34 => _34.id]), () => ( null)), loc.index + i);
2656
3064
  });
2657
3065
  return { layers: out, ids: group.children.map((c) => c.id) };
2658
3066
  }
@@ -2667,12 +3075,12 @@ function offsetLayer(layers, id, offset) {
2667
3075
  if (mask && mask.linked === false && !mask.source) {
2668
3076
  next.mask = { ...mask, surface: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
2669
3077
  }
2670
- return _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => next);
3078
+ return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next);
2671
3079
  }
2672
3080
  function setLayerMask(layers, id, mask) {
2673
3081
  const loc = requireLayer(layers, id);
2674
3082
  requireUnlocked(loc.layer, "all", "change its mask");
2675
- return _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, (l) => {
3083
+ return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, (l) => {
2676
3084
  const next = { ...l };
2677
3085
  if (mask) next.mask = mask;
2678
3086
  else delete next.mask;
@@ -2711,7 +3119,7 @@ function requirePixelLayer(layers, id) {
2711
3119
  function addLayerFilter(layers, id, filter) {
2712
3120
  const layer = requirePixelLayer(layers, id);
2713
3121
  if (_optionalChain([layer, 'access', _35 => _35.filters, 'optionalAccess', _36 => _36.some, 'call', _37 => _37((f) => f.kind === filter.kind)])) fail(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
2714
- return _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
3122
+ return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
2715
3123
  }
2716
3124
  function updateLayerFilter(layers, id, filterId, changes) {
2717
3125
  const layer = requirePixelLayer(layers, id);
@@ -2722,7 +3130,7 @@ function updateLayerFilter(layers, id, filterId, changes) {
2722
3130
  const merged = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
2723
3131
  const filters = [...layer.filters];
2724
3132
  filters[i] = merged;
2725
- return _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
3133
+ return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
2726
3134
  }
2727
3135
  function removeLayerFilter(layers, id, filterId) {
2728
3136
  const layer = requirePixelLayer(layers, id);
@@ -2731,98 +3139,1209 @@ function removeLayerFilter(layers, id, filterId) {
2731
3139
  const next = { ...layer };
2732
3140
  if (filters.length) next.filters = filters;
2733
3141
  else delete next.filters;
2734
- return _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => next);
3142
+ return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next);
3143
+ }
3144
+ function requireEffectLayer(layers, id, action) {
3145
+ const layer = requireLayer(layers, id).layer;
3146
+ if (layer.type === "adjustment") fail(`Layer "${layer.name || id}" is an adjustment layer; effects go on pixel, annotation and group layers.`);
3147
+ requireUnlocked(layer, "all", action);
3148
+ return layer;
3149
+ }
3150
+ function layerEffectsOf(layer) {
3151
+ return _nullishCoalesce(layer.effects, () => ( { enabled: true, items: [] }));
3152
+ }
3153
+ function guard(fn) {
3154
+ try {
3155
+ return fn();
3156
+ } catch (e) {
3157
+ if (e instanceof _chunkAZTZRLDIcjs.LayerEffectError) fail(e.message);
3158
+ throw e;
3159
+ }
3160
+ }
3161
+ function setLayerEffects(layers, id, effects) {
3162
+ const layer = requireEffectLayer(layers, id, "change its effects");
3163
+ const next = { ...layer };
3164
+ if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
3165
+ guard(() => _chunkAZTZRLDIcjs.validateLayerEffects.call(void 0, effects));
3166
+ next.effects = effects;
3167
+ } else delete next.effects;
3168
+ return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next);
3169
+ }
3170
+ function addLayerEffect(layers, id, kind, params = {}, index) {
3171
+ if (!_chunkAZTZRLDIcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkAZTZRLDIcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
3172
+ const layer = requireEffectLayer(layers, id, "add effects");
3173
+ const current = layerEffectsOf(layer);
3174
+ const ids = new Set(current.items.map((e) => e.id));
3175
+ let effectId = _chunkAZTZRLDIcjs.newEffectId.call(void 0, );
3176
+ while (ids.has(effectId)) effectId = _chunkAZTZRLDIcjs.newEffectId.call(void 0, );
3177
+ const { id: _ignored, kind: _kind, ...rest } = params;
3178
+ const effect = guard(() => _chunkAZTZRLDIcjs.mergeLayerEffect.call(void 0, _chunkAZTZRLDIcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
3179
+ const items = [...current.items];
3180
+ const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
3181
+ items.splice(at, 0, effect);
3182
+ return { layers: setLayerEffects(layers, id, { ...current, items }), effect };
3183
+ }
3184
+ function requireEffect(layer, effectId) {
3185
+ const items = _nullishCoalesce(_optionalChain([layer, 'access', _38 => _38.effects, 'optionalAccess', _39 => _39.items]), () => ( []));
3186
+ const i = items.findIndex((e) => e.id === effectId);
3187
+ if (i === -1) fail(`Layer "${layer.name || layer.id}" has no effect "${effectId}". Effects: ${items.map((e) => `${e.id} (${e.kind})`).join(", ") || "none"}; call list_layer_effects.`);
3188
+ return i;
3189
+ }
3190
+ function updateLayerEffect(layers, id, effectId, changes) {
3191
+ const layer = requireEffectLayer(layers, id, "change its effects");
3192
+ const i = requireEffect(layer, effectId);
3193
+ const current = layer.effects;
3194
+ const items = [...current.items];
3195
+ items[i] = guard(() => _chunkAZTZRLDIcjs.mergeLayerEffect.call(void 0, items[i], changes));
3196
+ return setLayerEffects(layers, id, { ...current, items });
3197
+ }
3198
+ function removeLayerEffect(layers, id, effectId) {
3199
+ const layer = requireEffectLayer(layers, id, "change its effects");
3200
+ requireEffect(layer, effectId);
3201
+ const current = layer.effects;
3202
+ return setLayerEffects(layers, id, { ...current, items: current.items.filter((e) => e.id !== effectId) });
3203
+ }
3204
+ function setLayerEffectsEnabled(layers, id, enabled, scale) {
3205
+ const layer = requireEffectLayer(layers, id, "change its effects");
3206
+ if (scale !== void 0 && !(Number.isFinite(scale) && scale >= 0.01 && scale <= 10)) fail(`scale must be from 0.01 to 10 (1 = 100 %), got ${scale}.`);
3207
+ const current = layerEffectsOf(layer);
3208
+ const next = { ...current, enabled };
3209
+ if (scale !== void 0) {
3210
+ if (scale === 1) delete next.scale;
3211
+ else next.scale = scale;
3212
+ }
3213
+ return setLayerEffects(layers, id, next);
3214
+ }
3215
+ function parseBlend(value, allowPassThrough = false) {
3216
+ if (value === void 0) return void 0;
3217
+ if (value === "pass-through" && allowPassThrough) return value;
3218
+ if (!_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, value)) fail(`Unknown blend mode "${String(value)}".`);
3219
+ return value;
3220
+ }
3221
+ function unionRect(a, b) {
3222
+ if (!a) return b;
3223
+ if (!b) return a;
3224
+ const x = Math.min(a.x, b.x);
3225
+ const y = Math.min(a.y, b.y);
3226
+ 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 };
3227
+ }
3228
+
3229
+ // src/image-editor/layers/shape.ts
3230
+ var SHAPE_RENDER_MARGIN = _chunkAZTZRLDIcjs.MAX_EFFECT_REACH;
3231
+ var DEFAULT_MITER_LIMIT = 100;
3232
+ var fail2 = (message) => {
3233
+ throw new LayerOperationError(message);
3234
+ };
3235
+ var orientation = (anchors) => {
3236
+ let a = 0;
3237
+ for (let i = 0; i < anchors.length; i++) {
3238
+ const p = anchors[i];
3239
+ const q2 = anchors[(i + 1) % anchors.length];
3240
+ a += p.x * q2.y - q2.x * p.y;
3241
+ }
3242
+ return a;
3243
+ };
3244
+ function polygon(points) {
3245
+ const anchors = orientation(points) < 0 ? [...points].reverse() : points;
3246
+ return { closed: true, anchors: anchors.map((p) => ({ x: p.x, y: p.y })) };
3247
+ }
3248
+ function arrowheadPolygon(head, tip, dir) {
3249
+ const len = Math.max(0, head.length);
3250
+ const hw = Math.max(0, head.width) / 2;
3251
+ if (!(len > 0) || !(hw > 0)) return null;
3252
+ const n = { x: -dir.y, y: dir.x };
3253
+ const base = { x: tip.x - dir.x * len, y: tip.y - dir.y * len };
3254
+ const c = Math.max(-0.5, Math.min(0.5, _nullishCoalesce(head.concavity, () => ( 0))));
3255
+ const pts = [tip, { x: base.x + n.x * hw, y: base.y + n.y * hw }];
3256
+ if (c) pts.push({ x: base.x + dir.x * len * c, y: base.y + dir.y * len * c });
3257
+ pts.push({ x: base.x - n.x * hw, y: base.y - n.y * hw });
3258
+ return polygon(pts);
3259
+ }
3260
+ function mapAnchor(a, f) {
3261
+ const p = f(a);
3262
+ const out = { x: p.x, y: p.y };
3263
+ if (a.in) out.in = f(a.in);
3264
+ if (a.out) out.out = f(a.out);
3265
+ if (a.type) out.type = a.type;
3266
+ if (a.corner) out.corner = { ...a.corner };
3267
+ return out;
3268
+ }
3269
+ function mapSubpaths(subpaths, f) {
3270
+ return _chunkW3GXSUSQcjs.expandVectorCorners.call(void 0, subpaths).map((sp) => ({ closed: sp.closed, anchors: sp.anchors.map((a) => mapAnchor(a, f)) }));
3271
+ }
3272
+ function liveShapeSubpaths(live) {
3273
+ let out;
3274
+ switch (live.kind) {
3275
+ case "rect": {
3276
+ const x = Math.min(live.x, live.x + live.width);
3277
+ const y = Math.min(live.y, live.y + live.height);
3278
+ const sp = _chunkW3GXSUSQcjs.rectSubpath.call(void 0, { x, y, width: Math.abs(live.width), height: Math.abs(live.height) });
3279
+ const r = _nullishCoalesce(live.radii, () => ( [0, 0, 0, 0]));
3280
+ out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ? _chunkW3GXSUSQcjs.setAnchorCorner.call(void 0, a, r[i]) : a) }];
3281
+ break;
3282
+ }
3283
+ case "ellipse":
3284
+ out = [_chunkW3GXSUSQcjs.ellipseSubpath.call(void 0, normBox(live))];
3285
+ break;
3286
+ case "polygon":
3287
+ out = [_chunkW3GXSUSQcjs.polygonSubpath.call(void 0, normBox(live), live.sides)];
3288
+ break;
3289
+ case "star":
3290
+ out = [_chunkW3GXSUSQcjs.starSubpath.call(void 0, normBox(live), live.points, Math.max(0, Math.min(1, live.innerRatio)))];
3291
+ break;
3292
+ case "line": {
3293
+ const a = { x: live.x1, y: live.y1 };
3294
+ const b = { x: live.x2, y: live.y2 };
3295
+ const len = Math.hypot(b.x - a.x, b.y - a.y);
3296
+ out = [];
3297
+ if (len > 0) {
3298
+ const d = { x: (b.x - a.x) / len, y: (b.y - a.y) / len };
3299
+ const hw = Math.max(0, live.weight) / 2;
3300
+ if (hw > 0) {
3301
+ const n = { x: -d.y * hw, y: d.x * hw };
3302
+ out.push(polygon([{ x: a.x + n.x, y: a.y + n.y }, { x: b.x + n.x, y: b.y + n.y }, { x: b.x - n.x, y: b.y - n.y }, { x: a.x - n.x, y: a.y - n.y }]));
3303
+ }
3304
+ const end = live.endArrow ? arrowheadPolygon(live.endArrow, b, d) : null;
3305
+ const start = live.startArrow ? arrowheadPolygon(live.startArrow, a, { x: -d.x, y: -d.y }) : null;
3306
+ if (start) out.push(start);
3307
+ if (end) out.push(end);
3308
+ }
3309
+ break;
3310
+ }
3311
+ }
3312
+ const m = live.transform;
3313
+ return m && !_chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, m) ? mapSubpaths(out, (p) => _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, p)) : out;
3314
+ }
3315
+ function normBox(b) {
3316
+ return { x: Math.min(b.x, b.x + b.width), y: Math.min(b.y, b.y + b.height), width: Math.abs(b.width), height: Math.abs(b.height) };
3317
+ }
3318
+ function liveComponent(live, op = "combine") {
3319
+ return { op, subpaths: liveShapeSubpaths(live), live };
3320
+ }
3321
+ var pathCache = /* @__PURE__ */ new WeakMap();
3322
+ function componentPath(c) {
3323
+ let p = pathCache.get(c.subpaths);
3324
+ if (!p) {
3325
+ p = _chunkW3GXSUSQcjs.subpathsToBezier.call(void 0, c.subpaths);
3326
+ pathCache.set(c.subpaths, p);
3327
+ }
3328
+ return p;
3329
+ }
3330
+ var BOOLEAN_OF = { combine: "union", subtract: "difference", intersect: "intersection", exclude: "xor" };
3331
+ var outlineCache = /* @__PURE__ */ new WeakMap();
3332
+ function shapeOutline(components, fillRule = "nonzero") {
3333
+ if (components.length === 1) return componentPath(components[0]);
3334
+ let byRule = outlineCache.get(components);
3335
+ if (!byRule) {
3336
+ byRule = /* @__PURE__ */ new Map();
3337
+ outlineCache.set(components, byRule);
3338
+ }
3339
+ const hit = byRule.get(fillRule);
3340
+ if (hit) return hit;
3341
+ let acc = [];
3342
+ components.forEach((c, i) => {
3343
+ const operand = { path: componentPath(c), fillRule };
3344
+ if (i === 0) acc = _chunkXGD3FSNCcjs.pathBoolean.call(void 0, "union", [operand]).path;
3345
+ else acc = _chunkXGD3FSNCcjs.pathBoolean.call(void 0, BOOLEAN_OF[c.op], [{ path: acc, fillRule: "nonzero" }, operand]).path;
3346
+ });
3347
+ byRule.set(fillRule, acc);
3348
+ return acc;
3349
+ }
3350
+ function shapeGeometryBounds(layer) {
3351
+ let b = null;
3352
+ for (const c of layer.components) {
3353
+ const cb = _chunkXGD3FSNCcjs.bezierPathBounds.call(void 0, componentPath(c));
3354
+ if (!cb) continue;
3355
+ b = b ? { minX: Math.min(b.minX, cb.minX), minY: Math.min(b.minY, cb.minY), maxX: Math.max(b.maxX, cb.maxX), maxY: Math.max(b.maxY, cb.maxY) } : cb;
3356
+ }
3357
+ return b ? { x: b.minX, y: b.minY, width: b.maxX - b.minX, height: b.maxY - b.minY } : null;
3358
+ }
3359
+ function closedOutline(path) {
3360
+ let open = false;
3361
+ let inSub = false;
3362
+ for (const c of path) {
3363
+ if (c.type === "M") {
3364
+ if (inSub) open = true;
3365
+ inSub = true;
3366
+ } else if (c.type === "Z") inSub = false;
3367
+ }
3368
+ return !open && !inSub;
3369
+ }
3370
+ function strokeArea(path, stroke, double) {
3371
+ const w = stroke.width * (double ? 2 : 1);
3372
+ if (!(w > 0) || !path.length) return [];
3373
+ const dashes = _optionalChain([stroke, 'access', _40 => _40.dashes, 'optionalAccess', _41 => _41.length]) && stroke.dashes.some((d) => d > 0) ? stroke.dashes.map((d) => d * stroke.width) : void 0;
3374
+ const options = {
3375
+ width: w,
3376
+ cap: _nullishCoalesce(stroke.cap, () => ( "butt")),
3377
+ join: _nullishCoalesce(stroke.join, () => ( "miter")),
3378
+ miterLimit: _nullishCoalesce(stroke.miterLimit, () => ( DEFAULT_MITER_LIMIT)),
3379
+ ...dashes ? { dash: dashes, dashOffset: (_nullishCoalesce(stroke.dashOffset, () => ( 0))) * stroke.width } : {}
3380
+ };
3381
+ const curved = path.some((c) => c.type === "C" || c.type === "Q");
3382
+ if (curved && path.length <= CLEAN_OUTLINE_LIMIT) {
3383
+ try {
3384
+ return _chunkXGD3FSNCcjs.outlineStroke.call(void 0, path, options);
3385
+ } catch (e3) {
3386
+ }
3387
+ }
3388
+ return _chunkXGD3FSNCcjs.strokeOutlineRings.call(void 0, path, options);
3389
+ }
3390
+ var CLEAN_OUTLINE_LIMIT = 64;
3391
+ var geometryCache = /* @__PURE__ */ new WeakMap();
3392
+ function shapeGeometry(layer) {
3393
+ const hit = geometryCache.get(layer);
3394
+ if (hit) return hit;
3395
+ const fills = layer.components.map((c) => ({ op: c.op, flat: flattenPath(componentPath(c)) }));
3396
+ let stroke = null;
3397
+ let align = "center";
3398
+ const s = layer.stroke;
3399
+ if (s && s.width > 0 && layer.components.length) {
3400
+ let outline;
3401
+ try {
3402
+ outline = shapeOutline(layer.components, layer.fillRule);
3403
+ } catch (e4) {
3404
+ outline = layer.components.flatMap((c) => componentPath(c));
3405
+ }
3406
+ align = s.align && s.align !== "center" && closedOutline(outline) ? s.align : "center";
3407
+ stroke = flattenPath(strokeArea(outline, s, align !== "center"));
3408
+ }
3409
+ let bounds = null;
3410
+ const add = (b) => {
3411
+ if (!b) return;
3412
+ if (!bounds) bounds = { ...b };
3413
+ else {
3414
+ const x0 = Math.min(bounds.x, b.x);
3415
+ const y0 = Math.min(bounds.y, b.y);
3416
+ bounds = { x: x0, y: y0, width: Math.max(bounds.x + bounds.width, b.x + b.width) - x0, height: Math.max(bounds.y + bounds.height, b.y + b.height) - y0 };
3417
+ }
3418
+ };
3419
+ if (layer.fill) for (const f of fills) add(flatBounds(f.flat));
3420
+ if (stroke) add(flatBounds(stroke));
3421
+ const g = _nullishCoalesce(shapeGeometryBounds(layer), () => ( { x: 0, y: 0, width: 0, height: 0 }));
3422
+ const frame = { x: Math.floor(g.x), y: Math.floor(g.y), width: Math.max(1, Math.ceil(g.x + g.width) - Math.floor(g.x)), height: Math.max(1, Math.ceil(g.y + g.height) - Math.floor(g.y)) };
3423
+ const geo = { fills, stroke, align, bounds, frame };
3424
+ geometryCache.set(layer, geo);
3425
+ return geo;
3426
+ }
3427
+ function fillCoverage(geo, rect, rule) {
3428
+ const n = rect.width * rect.height;
3429
+ let acc = null;
3430
+ geo.fills.forEach((f, i) => {
3431
+ const cov = f.flat.length > 1 ? rasterizeCoverageSampled(f.flat, rect, rule) : rasterizeCoverage(f.flat, rect, rule);
3432
+ acc = i === 0 ? cov : combineCoverage(acc, cov, f.op, n);
3433
+ });
3434
+ return acc;
3435
+ }
3436
+ function paintContext(env) {
3437
+ const tiles = /* @__PURE__ */ new Map();
3438
+ return {
3439
+ light: _chunkAZTZRLDIcjs.DEFAULT_GLOBAL_LIGHT,
3440
+ pattern: (id) => {
3441
+ if (tiles.has(id)) return tiles.get(id);
3442
+ const p = _nullishCoalesce(_optionalChain([env, 'access', _42 => _42.pattern, 'optionalCall', _43 => _43(id)]), () => ( _chunkAZTZRLDIcjs.builtinPattern.call(void 0, id)));
3443
+ const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0, _chunkAZTZRLDIcjs.PatternTile)(p) : null;
3444
+ tiles.set(id, t);
3445
+ return t;
3446
+ }
3447
+ };
3448
+ }
3449
+ function shapeRenderClip(env) {
3450
+ const m = SHAPE_RENDER_MARGIN;
3451
+ return { x: -m, y: -m, width: env.width + 2 * m, height: env.height + 2 * m };
3452
+ }
3453
+ function intersect(a, b) {
3454
+ const x0 = Math.max(a.x, b.x);
3455
+ const y0 = Math.max(a.y, b.y);
3456
+ const x1 = Math.min(a.x + a.width, b.x + b.width);
3457
+ const y1 = Math.min(a.y + a.height, b.y + b.height);
3458
+ return x1 > x0 && y1 > y0 ? { x: x0, y: y0, width: x1 - x0, height: y1 - y0 } : null;
3459
+ }
3460
+ function renderShapeRect(layer, rect, env, ctx = paintContext(env)) {
3461
+ const geo = shapeGeometry(layer);
3462
+ if (!geo.bounds || !intersect(geo.bounds, rect)) return null;
3463
+ const n = rect.width * rect.height;
3464
+ const rule = _nullishCoalesce(layer.fillRule, () => ( "nonzero"));
3465
+ const needArea = Boolean(layer.fill) || geo.stroke !== null && geo.align !== "center";
3466
+ const area = needArea ? fillCoverage(geo, rect, rule) : null;
3467
+ let sCov = geo.stroke ? rasterizeCoverageSampled(geo.stroke, rect, "nonzero") : null;
3468
+ if (sCov && geo.align === "inside") sCov = area ? combineCoverage(sCov, area, "intersect", n) : null;
3469
+ else if (sCov && geo.align === "outside" && area) sCov = combineCoverage(sCov, area, "subtract", n);
3470
+ const fCov = layer.fill ? area : null;
3471
+ if (!fCov && !sCov) return null;
3472
+ const canvas = { x: 0, y: 0, width: env.width, height: env.height };
3473
+ const anchor = { x: geo.frame.x, y: geo.frame.y };
3474
+ const fc = fCov ? _chunkAZTZRLDIcjs.effectFillColors.call(void 0, layer.fill, rect, geo.frame, canvas, anchor, ctx) : null;
3475
+ const fo = _nullishCoalesce(_optionalChain([layer, 'access', _44 => _44.fill, 'optionalAccess', _45 => _45.opacity]), () => ( 1));
3476
+ const sc = sCov ? _chunkAZTZRLDIcjs.effectFillColors.call(void 0, layer.stroke.paint, rect, geo.frame, canvas, anchor, ctx) : null;
3477
+ const so = _nullishCoalesce(_optionalChain([layer, 'access', _46 => _46.stroke, 'optionalAccess', _47 => _47.paint, 'access', _48 => _48.opacity]), () => ( 1));
3478
+ const out = new Uint8ClampedArray(n * 4);
3479
+ let any = false;
3480
+ for (let i = 0; i < n; i++) {
3481
+ const k = i * 4;
3482
+ let r = 0;
3483
+ let g = 0;
3484
+ let b = 0;
3485
+ let a = 0;
3486
+ if (fCov && fCov[i] > 0) {
3487
+ a = fCov[i] * fo * fc[k + 3];
3488
+ r = fc[k];
3489
+ g = fc[k + 1];
3490
+ b = fc[k + 2];
3491
+ }
3492
+ if (sCov && sCov[i] > 0) {
3493
+ const sa = Math.min(1, sCov[i]) * so * sc[k + 3];
3494
+ const ao = sa + a * (1 - sa);
3495
+ if (ao > 0) {
3496
+ r = (sc[k] * sa + r * a * (1 - sa)) / ao;
3497
+ g = (sc[k + 1] * sa + g * a * (1 - sa)) / ao;
3498
+ b = (sc[k + 2] * sa + b * a * (1 - sa)) / ao;
3499
+ }
3500
+ a = ao;
3501
+ }
3502
+ if (a <= 0) continue;
3503
+ const ab = Math.round(Math.min(1, a) * 255);
3504
+ if (!ab) continue;
3505
+ out[k] = Math.round(r * 255);
3506
+ out[k + 1] = Math.round(g * 255);
3507
+ out[k + 2] = Math.round(b * 255);
3508
+ out[k + 3] = ab;
3509
+ any = true;
3510
+ }
3511
+ return any ? out : null;
3512
+ }
3513
+ function renderShape(layer, env, options = {}) {
3514
+ const geo = shapeGeometry(layer);
3515
+ if (!geo.bounds) return _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4);
3516
+ let region = intersect(geo.bounds, shapeRenderClip(env));
3517
+ if (region && options.clip) region = intersect(region, options.clip);
3518
+ if (!region) return _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4);
3519
+ const ctx = paintContext(env);
3520
+ const tiles = /* @__PURE__ */ new Map();
3521
+ for (const { tx, ty } of _chunkSZ6KMZNMcjs.tilesInRect.call(void 0, region)) {
3522
+ const rect = { x: tx * _chunkSZ6KMZNMcjs.TILE, y: ty * _chunkSZ6KMZNMcjs.TILE, width: _chunkSZ6KMZNMcjs.TILE, height: _chunkSZ6KMZNMcjs.TILE };
3523
+ const px = renderShapeRect(layer, rect, env, ctx);
3524
+ if (!px) continue;
3525
+ const tile = _chunkSZ6KMZNMcjs.finishTile.call(void 0, px, 4, 0);
3526
+ if (tile) tiles.set(_chunkSZ6KMZNMcjs.tileKey.call(void 0, tx, ty), tile);
3527
+ }
3528
+ return new (0, _chunkSZ6KMZNMcjs.TiledSurface)(4, tiles, 0);
3529
+ }
3530
+ function rerenderShape(layer, env) {
3531
+ return { ...layer, surface: renderShape(layer, env) };
3532
+ }
3533
+ var isNum = (v) => typeof v === "number" && Number.isFinite(v);
3534
+ function requireNum(v, path, min = -Infinity, max = Infinity) {
3535
+ if (!isNum(v)) fail2(`${path} must be a finite number.`);
3536
+ if (v < min || v > max) fail2(`${path} must be between ${min} and ${max}, got ${v}.`);
3537
+ return v;
3538
+ }
3539
+ function normalizeShapePaint(v, path = "paint") {
3540
+ if (typeof v === "string") {
3541
+ const c = parseCssColor(v);
3542
+ if (!c) return fail2(`${path}: "${v}" is not a colour; use #rrggbb (or #rrggbbaa, rgb(), a CSS colour name).`);
3543
+ return c.alpha < 1 ? { type: "color", color: c.hex, opacity: c.alpha } : { type: "color", color: c.hex };
3544
+ }
3545
+ if (!v || typeof v !== "object") return fail2(`${path} must be a colour string or an object with type color, gradient or pattern.`);
3546
+ const o = v;
3547
+ const opacity = o.opacity === void 0 ? void 0 : requireNum(o.opacity, `${path}.opacity`, 0, 1);
3548
+ const withOpacity = (p) => opacity !== void 0 && opacity !== 1 ? { ...p, opacity } : p;
3549
+ if (o.type === "color") {
3550
+ const c = parseCssColor(o.color);
3551
+ if (!c) return fail2(`${path}.color must be a colour such as #rrggbb.`);
3552
+ const op = (_nullishCoalesce(opacity, () => ( 1))) * c.alpha;
3553
+ return op !== 1 ? { type: "color", color: c.hex, opacity: op } : { type: "color", color: c.hex };
3554
+ }
3555
+ if (o.type === "gradient") {
3556
+ const g = o.gradient;
3557
+ if (!g || typeof g !== "object") return fail2(`${path}.gradient is required: { stops: [{ position, color }], style, angle, \u2026 }.`);
3558
+ const gradient = {
3559
+ stops: Array.isArray(g.stops) ? g.stops.map((s) => ({ position: s.position, color: _nullishCoalesce(_optionalChain([parseCssColor, 'call', _49 => _49(s.color), 'optionalAccess', _50 => _50.hex]), () => ( s.color)) })) : [],
3560
+ ...g.opacityStops ? { opacityStops: g.opacityStops } : {},
3561
+ style: _nullishCoalesce(g.style, () => ( "linear")),
3562
+ angle: _nullishCoalesce(g.angle, () => ( 90)),
3563
+ scale: _nullishCoalesce(g.scale, () => ( 1)),
3564
+ reverse: _nullishCoalesce(g.reverse, () => ( false)),
3565
+ align: _nullishCoalesce(g.align, () => ( true)),
3566
+ offset: _nullishCoalesce(g.offset, () => ( { x: 0, y: 0 }))
3567
+ };
3568
+ try {
3569
+ _chunkAZTZRLDIcjs.validateEffectGradient.call(void 0, gradient, `${path}.gradient`);
3570
+ } catch (e) {
3571
+ if (e instanceof _chunkAZTZRLDIcjs.LayerEffectError) fail2(e.message);
3572
+ throw e;
3573
+ }
3574
+ if (gradient.stops.length < 1) fail2(`${path}.gradient.stops needs at least one { position, color }.`);
3575
+ return withOpacity({ type: "gradient", gradient });
3576
+ }
3577
+ if (o.type === "pattern") {
3578
+ if (typeof o.patternId !== "string" || !o.patternId) fail2(`${path}.patternId is required (a document or built-in pattern id).`);
3579
+ const p = { type: "pattern", patternId: o.patternId, scale: o.scale === void 0 ? 1 : requireNum(o.scale, `${path}.scale`, 0.01, 10) };
3580
+ if (typeof o.name === "string") p.name = o.name;
3581
+ if (o.angle !== void 0) p.angle = requireNum(o.angle, `${path}.angle`, -360, 360);
3582
+ if (o.link !== void 0) p.link = Boolean(o.link);
3583
+ if (o.phase !== void 0) {
3584
+ const ph = o.phase;
3585
+ p.phase = { x: requireNum(_optionalChain([ph, 'optionalAccess', _51 => _51.x]), `${path}.phase.x`), y: requireNum(_optionalChain([ph, 'optionalAccess', _52 => _52.y]), `${path}.phase.y`) };
3586
+ }
3587
+ return withOpacity(p);
3588
+ }
3589
+ return fail2(`${path}.type must be color, gradient or pattern, got ${JSON.stringify(o.type)}.`);
3590
+ }
3591
+ function normalizeShapeStroke(v, path = "stroke", base) {
3592
+ if (!v || typeof v !== "object") return fail2(`${path} must be an object { width, paint, align?, cap?, join?, miterLimit?, dashes?, dashOffset? } or null.`);
3593
+ const o = v;
3594
+ const width = o.width === void 0 && base ? base.width : requireNum(o.width, `${path}.width`, 0, 1e4);
3595
+ const paint = o.paint === void 0 && base ? base.paint : o.paint === void 0 && o.color !== void 0 ? normalizeShapePaint(o.color, `${path}.color`) : normalizeShapePaint(o.paint, `${path}.paint`);
3596
+ const out = { width, paint };
3597
+ const pick = (k, allowed) => {
3598
+ const value = o[k] === void 0 ? _optionalChain([base, 'optionalAccess', _53 => _53[k]]) : o[k];
3599
+ if (value === void 0) return;
3600
+ if (!allowed.includes(value)) fail2(`${path}.${k} must be one of ${allowed.join(", ")}, got ${JSON.stringify(value)}.`);
3601
+ if (value !== (k === "align" ? "center" : k === "cap" ? "butt" : "miter")) out[k] = value;
3602
+ };
3603
+ pick("align", ["inside", "center", "outside"]);
3604
+ pick("cap", ["butt", "round", "square"]);
3605
+ pick("join", ["miter", "round", "bevel"]);
3606
+ const miter = o.miterLimit === void 0 ? _optionalChain([base, 'optionalAccess', _54 => _54.miterLimit]) : requireNum(o.miterLimit, `${path}.miterLimit`, 1, 500);
3607
+ if (miter !== void 0 && miter !== DEFAULT_MITER_LIMIT) out.miterLimit = miter;
3608
+ const dashes = o.dashes === void 0 ? _optionalChain([base, 'optionalAccess', _55 => _55.dashes]) : o.dashes;
3609
+ if (dashes !== void 0 && dashes !== null) {
3610
+ if (!Array.isArray(dashes) || dashes.length > 32 || !dashes.every((d) => isNum(d) && d >= 0 && d <= 1e4)) fail2(`${path}.dashes must be at most 32 lengths 0..10000 (multiples of the width).`);
3611
+ if (dashes.length) {
3612
+ if (dashes.reduce((s, d) => s + d, 0) < 0.01) fail2(`${path}.dashes must add up to at least 0.01 widths.`);
3613
+ out.dashes = [...dashes];
3614
+ }
3615
+ }
3616
+ const offset = o.dashOffset === void 0 ? _optionalChain([base, 'optionalAccess', _56 => _56.dashOffset]) : requireNum(o.dashOffset, `${path}.dashOffset`, -1e6, 1e6);
3617
+ if (offset) out.dashOffset = offset;
3618
+ return out;
3619
+ }
3620
+ function box(o, path) {
3621
+ return {
3622
+ x: requireNum(o.x, `${path}.x`),
3623
+ y: requireNum(o.y, `${path}.y`),
3624
+ width: requireNum(o.width, `${path}.width`, -1e6, 1e6),
3625
+ height: requireNum(o.height, `${path}.height`, -1e6, 1e6)
3626
+ };
3627
+ }
3628
+ function arrowhead(v, path) {
3629
+ if (v === null || v === void 0 || v === false) return null;
3630
+ if (typeof v !== "object") return fail2(`${path} must be { width, length, concavity? } in pixels, or null.`);
3631
+ const o = v;
3632
+ const head = { width: requireNum(o.width, `${path}.width`, 0, 1e5), length: requireNum(o.length, `${path}.length`, 0, 1e5) };
3633
+ if (o.concavity !== void 0 && o.concavity !== 0) head.concavity = requireNum(o.concavity, `${path}.concavity`, -0.5, 0.5);
3634
+ return head;
3635
+ }
3636
+ function matrixArg(v, path) {
3637
+ if (v === void 0 || v === null) return void 0;
3638
+ if (!Array.isArray(v) || v.length !== 6 || !v.every(isNum)) fail2(`${path} must be six numbers [a, b, c, d, e, f].`);
3639
+ const m = v;
3640
+ if (Math.abs(m[0] * m[3] - m[1] * m[2]) < 1e-12) fail2(`${path} is singular.`);
3641
+ return _chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, m) ? void 0 : [...m];
3642
+ }
3643
+ function normalizeLiveShape(v, path = "shape") {
3644
+ if (!v || typeof v !== "object") return fail2(`${path} must be an object with kind ${LIVE_SHAPE_KINDS.join(", ")}.`);
3645
+ const o = v;
3646
+ const transform = matrixArg(o.transform, `${path}.transform`);
3647
+ const t = transform ? { transform } : {};
3648
+ switch (o.kind) {
3649
+ case "rect": {
3650
+ const b = box(o, path);
3651
+ let radii;
3652
+ if (o.radii !== void 0 || o.radius !== void 0) {
3653
+ const r = _nullishCoalesce(o.radii, () => ( o.radius));
3654
+ const list2 = typeof r === "number" ? [r, r, r, r] : r;
3655
+ if (!Array.isArray(list2) || list2.length !== 4 || !list2.every((x) => isNum(x) && x >= 0)) fail2(`${path}.radii must be four radii \u2265 0 [top-left, top-right, bottom-right, bottom-left] (or radius, one number).`);
3656
+ if (list2.some((x) => x > 0)) radii = [...list2];
3657
+ }
3658
+ return { kind: "rect", ...b, ...radii ? { radii } : {}, ...t };
3659
+ }
3660
+ case "ellipse":
3661
+ return { kind: "ellipse", ...box(o, path), ...t };
3662
+ case "polygon":
3663
+ return { kind: "polygon", ...box(o, path), sides: Math.round(requireNum(_nullishCoalesce(o.sides, () => ( 6)), `${path}.sides`, 3, 100)), ...t };
3664
+ case "star":
3665
+ return {
3666
+ kind: "star",
3667
+ ...box(o, path),
3668
+ points: Math.round(requireNum(_nullishCoalesce(o.points, () => ( 5)), `${path}.points`, 3, 100)),
3669
+ innerRatio: requireNum(_nullishCoalesce(o.innerRatio, () => ( 0.5)), `${path}.innerRatio`, 0.01, 1),
3670
+ ...t
3671
+ };
3672
+ case "line": {
3673
+ const line = {
3674
+ kind: "line",
3675
+ x1: requireNum(o.x1, `${path}.x1`),
3676
+ y1: requireNum(o.y1, `${path}.y1`),
3677
+ x2: requireNum(o.x2, `${path}.x2`),
3678
+ y2: requireNum(o.y2, `${path}.y2`),
3679
+ weight: requireNum(_nullishCoalesce(o.weight, () => ( 1)), `${path}.weight`, 0, 1e5),
3680
+ ...t
3681
+ };
3682
+ const s = arrowhead(o.startArrow, `${path}.startArrow`);
3683
+ const e = arrowhead(o.endArrow, `${path}.endArrow`);
3684
+ if (s) line.startArrow = s;
3685
+ if (e) line.endArrow = e;
3686
+ if (line.x1 === line.x2 && line.y1 === line.y2) fail2(`${path}: the line's two ends are the same point.`);
3687
+ return line;
3688
+ }
3689
+ default:
3690
+ return fail2(`${path}.kind must be one of ${LIVE_SHAPE_KINDS.join(", ")}, got ${JSON.stringify(o.kind)}.`);
3691
+ }
3692
+ }
3693
+ function point(v, path) {
3694
+ const p = v;
3695
+ if (!p || typeof p !== "object") return fail2(`${path} must be { x, y } in document pixels.`);
3696
+ return { x: requireNum(p.x, `${path}.x`), y: requireNum(p.y, `${path}.y`) };
3697
+ }
3698
+ function normalizeSubpaths(v, path = "subpaths") {
3699
+ if (typeof v === "string") {
3700
+ let subs;
3701
+ try {
3702
+ subs = _chunkW3GXSUSQcjs.bezierToSubpaths.call(void 0, v);
3703
+ } catch (e5) {
3704
+ return fail2(`${path}: could not read the SVG path data.`);
3705
+ }
3706
+ if (!subs.length || !subs.every((s) => s.anchors.every((a) => isNum(a.x) && isNum(a.y)))) fail2(`${path}: the SVG path data holds no drawable subpath.`);
3707
+ return subs;
3708
+ }
3709
+ if (!Array.isArray(v) || !v.length) return fail2(`${path} must be a non-empty array of { anchors: [{ x, y, in?, out? }], closed } (or SVG path data).`);
3710
+ return v.map((s, i) => {
3711
+ const sp = s;
3712
+ if (!sp || !Array.isArray(sp.anchors) || sp.anchors.length < 1) fail2(`${path}[${i}].anchors must be a non-empty array.`);
3713
+ const anchors = sp.anchors.map((a, j) => {
3714
+ const at = `${path}[${i}].anchors[${j}]`;
3715
+ const p = point(a, at);
3716
+ const ao = a;
3717
+ const out = { x: p.x, y: p.y };
3718
+ if (ao.in) out.in = point(ao.in, `${at}.in`);
3719
+ if (ao.out) out.out = point(ao.out, `${at}.out`);
3720
+ if (ao.corner !== void 0 && ao.corner !== null) {
3721
+ const c = ao.corner;
3722
+ const r = requireNum(typeof c === "number" ? c : c.radius, `${at}.corner.radius`, 0, 1e5);
3723
+ if (r > 0) out.corner = { radius: r };
3724
+ }
3725
+ return out;
3726
+ });
3727
+ return { anchors, closed: sp.closed !== false };
3728
+ });
3729
+ }
3730
+ function requireOperation(v, path = "op") {
3731
+ if (v === void 0) return "combine";
3732
+ if (!SHAPE_OPERATIONS.includes(v)) fail2(`${path} must be one of ${SHAPE_OPERATIONS.join(", ")}, got ${JSON.stringify(v)}.`);
3733
+ return v;
3734
+ }
3735
+ function requireShapeLayer(layers, id) {
3736
+ const layer = requireLayer(layers, id).layer;
3737
+ if (layer.type !== "shape") fail2(`Layer "${layer.name || id}" is a ${layer.type} layer, not a shape layer; list_layers shows each layer's type.`);
3738
+ return layer;
3739
+ }
3740
+ function createShapeLayer(init, env, id = newLayerId()) {
3741
+ if (!init.components.length) fail2("A shape needs at least one component.");
3742
+ const layer = {
3743
+ type: "shape",
3744
+ id,
3745
+ name: _nullishCoalesce(init.name, () => ( defaultShapeName(init.components[0]))),
3746
+ visible: _nullishCoalesce(init.visible, () => ( true)),
3747
+ opacity: _nullishCoalesce(init.opacity, () => ( 1)),
3748
+ blend: _nullishCoalesce(init.blend, () => ( "normal")),
3749
+ components: init.components,
3750
+ fill: init.fill === void 0 ? null : init.fill,
3751
+ stroke: _nullishCoalesce(init.stroke, () => ( null)),
3752
+ surface: _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4),
3753
+ offset: { x: 0, y: 0 }
3754
+ };
3755
+ if (init.fillRule && init.fillRule !== "nonzero") layer.fillRule = init.fillRule;
3756
+ return rerenderShape(layer, env);
3757
+ }
3758
+ function defaultShapeName(c) {
3759
+ switch (_optionalChain([c, 'optionalAccess', _57 => _57.live, 'optionalAccess', _58 => _58.kind])) {
3760
+ case "rect":
3761
+ return "Rectangle";
3762
+ case "ellipse":
3763
+ return "Ellipse";
3764
+ case "polygon":
3765
+ return "Polygon";
3766
+ case "star":
3767
+ return "Star";
3768
+ case "line":
3769
+ return "Line";
3770
+ default:
3771
+ return "Shape";
3772
+ }
3773
+ }
3774
+ function updateShapeLayer(layers, id, change, env, action = "edit it") {
3775
+ const current = requireShapeLayer(layers, id);
3776
+ requireUnlocked(current, "pixels", action);
3777
+ const patch = change(current);
3778
+ const next = { ...current, ...patch };
3779
+ if (!("annotation" in patch)) delete next.annotation;
3780
+ if (!next.components.length) fail2("A shape needs at least one component; delete the layer instead.");
3781
+ const rendered = rerenderShape(next, env);
3782
+ return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
3783
+ }
3784
+ function transformShapeComponents(components, f, affine) {
3785
+ return components.map((c) => {
3786
+ if (affine && c.live) {
3787
+ const live = { ...c.live, transform: _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, _nullishCoalesce(c.live.transform, () => ( _chunkW3GXSUSQcjs.IDENTITY_MATRIX)), affine) };
3788
+ if (_chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, live.transform)) delete live.transform;
3789
+ return { op: c.op, subpaths: liveShapeSubpaths(live), live };
3790
+ }
3791
+ return { op: c.op, subpaths: mapSubpaths(c.subpaths, f) };
3792
+ });
3793
+ }
3794
+ function offsetShape(layer, dx, dy, env) {
3795
+ const m = _chunkW3GXSUSQcjs.translateMatrix.call(void 0, dx, dy);
3796
+ const next = { ...layer, components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), m) };
3797
+ delete next.annotation;
3798
+ return rerenderShape(next, env);
3799
+ }
3800
+ function mergeShapeComponents(components, fillRule = "nonzero") {
3801
+ if (components.length < 2) return [...components];
3802
+ const path = shapeOutline(components, fillRule);
3803
+ const subpaths = _chunkW3GXSUSQcjs.bezierToSubpaths.call(void 0, path);
3804
+ if (!subpaths.length) fail2("The components combine to nothing (the operations remove every area), so there is nothing to merge into.");
3805
+ return [{ op: "combine", subpaths }];
3806
+ }
3807
+ function shapeAsPixelLayer(layer) {
3808
+ const { components: _c, fillRule: _r, fill: _f, stroke: _s, annotation: _a, psd: _p, type: _t, ...rest } = layer;
3809
+ return { ...rest, type: "pixel", surface: layer.surface, offset: { x: 0, y: 0 } };
3810
+ }
3811
+ function annotationPaint(color, opacity) {
3812
+ const c = parseCssColor(color);
3813
+ if (!c || !_chunkAZTZRLDIcjs.parseEffectColor.call(void 0, c.hex)) return void 0;
3814
+ const a = c.alpha * opacity;
3815
+ return a !== 1 ? { type: "color", color: c.hex, opacity: a } : { type: "color", color: c.hex };
3816
+ }
3817
+ function shapeFromAnnotation(a) {
3818
+ const opacity = _nullishCoalesce(a.opacity, () => ( 1));
3819
+ const lineWidth = "strokeWidth" in a && a.strokeWidth > 0 ? a.strokeWidth : 1;
3820
+ const rotation = a.rotation ? _chunkW3GXSUSQcjs.rotateMatrix.call(void 0, a.rotation, { x: a.x, y: a.y }) : void 0;
3821
+ const t = rotation ? { transform: rotation } : {};
3822
+ const live = (l) => liveComponent(l);
3823
+ switch (a.type) {
3824
+ case "rect": {
3825
+ const stroke = annotationPaint(a.strokeColor, opacity);
3826
+ if (!stroke) return null;
3827
+ const fill = a.fillColor ? annotationPaint(a.fillColor, opacity) : null;
3828
+ if (fill === void 0) return null;
3829
+ return {
3830
+ components: [live({ kind: "rect", x: a.x, y: a.y, width: a.width, height: a.height, ...t })],
3831
+ fill,
3832
+ stroke: a.strokeWidth > 0 ? { width: a.strokeWidth, paint: stroke } : null
3833
+ };
3834
+ }
3835
+ case "circle": {
3836
+ const stroke = annotationPaint(a.strokeColor, opacity);
3837
+ if (!stroke) return null;
3838
+ const fill = a.fillColor ? annotationPaint(a.fillColor, opacity) : null;
3839
+ if (fill === void 0) return null;
3840
+ const rx = Math.abs(a.radiusX);
3841
+ const ry = Math.abs(a.radiusY);
3842
+ return {
3843
+ components: [live({ kind: "ellipse", x: a.x - rx, y: a.y - ry, width: 2 * rx, height: 2 * ry, ...t })],
3844
+ fill,
3845
+ stroke: a.strokeWidth > 0 ? { width: a.strokeWidth, paint: stroke } : null
3846
+ };
3847
+ }
3848
+ case "line":
3849
+ case "arrow": {
3850
+ const paint = annotationPaint(a.strokeColor, opacity);
3851
+ if (!paint) return null;
3852
+ const line = { kind: "line", x1: a.x, y1: a.y, x2: a.endX, y2: a.endY, weight: lineWidth, ...t };
3853
+ if (a.type === "arrow") {
3854
+ const side = Math.max(12, a.strokeWidth * 3);
3855
+ line.endArrow = { width: side, length: side * Math.cos(Math.PI / 6) };
3856
+ }
3857
+ if (line.x1 === line.x2 && line.y1 === line.y2) return { components: [{ op: "combine", subpaths: [] }], fill: paint, stroke: null };
3858
+ return { components: [live(line)], fill: paint, stroke: null };
3859
+ }
3860
+ case "pen": {
3861
+ const paint = annotationPaint(a.strokeColor, opacity);
3862
+ if (!paint) return null;
3863
+ const pts = rotation ? a.points.map((p) => _chunkW3GXSUSQcjs.applyMatrix.call(void 0, rotation, p)) : a.points;
3864
+ const subpaths = pts.length > 1 ? [{ closed: false, anchors: pts.map((p) => ({ x: p.x, y: p.y })) }] : [];
3865
+ return {
3866
+ components: [{ op: "combine", subpaths }],
3867
+ fill: null,
3868
+ stroke: { width: lineWidth, paint, cap: "round", join: "round" }
3869
+ };
3870
+ }
3871
+ default:
3872
+ return null;
3873
+ }
3874
+ }
3875
+ function annotationBlend(a, layerBlend) {
3876
+ if (layerBlend !== "normal") return layerBlend;
3877
+ return a.blend && _chunkSZ6KMZNMcjs.isBlendMode.call(void 0, a.blend) ? a.blend : "normal";
3878
+ }
3879
+ function annotationOfShape(layer) {
3880
+ const a = layer.annotation;
3881
+ if (!a) return null;
3882
+ const blend = layer.blend;
3883
+ if ((_nullishCoalesce(a.blend, () => ( "normal"))) === blend) return a;
3884
+ const out = { ...a };
3885
+ if (blend === "normal") delete out.blend;
3886
+ else out.blend = blend;
3887
+ return out;
3888
+ }
3889
+
3890
+ // src/image-editor/layers/defaults.ts
3891
+ var DEFAULT_ADJUSTMENTS_VALUES = {
3892
+ brightness: 0,
3893
+ contrast: 0,
3894
+ saturation: 0,
3895
+ exposure: 0,
3896
+ temperature: 0,
3897
+ tint: 0,
3898
+ blur: 0,
3899
+ opacity: 1,
3900
+ process: LATEST_PROCESS_VERSION
3901
+ };
3902
+ var DEFAULT_TRANSFORM_VALUES = {
3903
+ rotate: 0,
3904
+ flipH: false,
3905
+ flipV: false
3906
+ };
3907
+ var DEFAULT_DEPTH_MASK_VALUES = {
3908
+ enabled: false,
3909
+ maskSource: null,
3910
+ mode: "threshold",
3911
+ depthRange: [0, 255],
3912
+ softness: 10,
3913
+ invert: false
3914
+ };
3915
+
3916
+ // src/image-editor/layers/migrate.ts
3917
+ var BACKGROUND_LAYER_ID = "background";
3918
+ var BACKGROUND_LAYER_NAME = "Background";
3919
+ var DEVELOP_FILTER_ID = "develop";
3920
+ var BLUR_FILTER_ID = "blur";
3921
+ var legacyMaskMemo = /* @__PURE__ */ new WeakMap();
3922
+ function rasterMaskFromLegacy(mask, width, height) {
3923
+ const sel = decodeLayerMask(mask);
3924
+ if (!sel) return null;
3925
+ const sized = sel.width === width && sel.height === height ? sel : resizeSelection(sel, width, height);
3926
+ const surface = _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, { width, height, data: sized.data }, 1, 0, 0, 0);
3927
+ legacyMaskMemo.set(surface, { width: mask.width, height: mask.height, rle: mask.rle });
3928
+ const out = { surface, defaultValue: 0 };
3929
+ if (mask.density !== void 0 && mask.density !== 1) out.density = mask.density;
3930
+ if (mask.feather) out.feather = mask.feather;
3931
+ if (mask.enabled === false) out.enabled = false;
3932
+ return out;
3933
+ }
3934
+ function hasResampledLegacyMask(layers, width, height) {
3935
+ for (const l of layers) {
3936
+ if (l.type !== "adjustment" || !l.mask) continue;
3937
+ const memo = legacyMaskMemo.get(l.mask.surface);
3938
+ if (memo && (memo.width !== width || memo.height !== height)) return true;
3939
+ }
3940
+ return false;
3941
+ }
3942
+ function legacyMaskOf(mask, width, height) {
3943
+ let memo = legacyMaskMemo.get(mask.surface);
3944
+ if (!memo) {
3945
+ const data = _chunkSZ6KMZNMcjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width, height });
3946
+ memo = { width, height, rle: encodeSelectionRle(new Uint8Array(data.buffer, data.byteOffset, data.length)) };
3947
+ legacyMaskMemo.set(mask.surface, memo);
3948
+ }
3949
+ return normalizeLayerMask({ ...memo, density: mask.density, feather: mask.feather, enabled: mask.enabled });
3950
+ }
3951
+ function sameJson(a, b) {
3952
+ return JSON.stringify(a) === JSON.stringify(b);
3953
+ }
3954
+ function isDefaultDepthMask(mask) {
3955
+ if (!mask) return true;
3956
+ return sameJson({ ...DEFAULT_DEPTH_MASK_VALUES, ...mask, depthRange: [..._nullishCoalesce(mask.depthRange, () => ( []))] }, DEFAULT_DEPTH_MASK_VALUES);
3957
+ }
3958
+ function developFromAdjustments(adjustments) {
3959
+ return {
3960
+ id: DEVELOP_FILTER_ID,
3961
+ kind: "develop",
3962
+ enabled: true,
3963
+ brightness: _nullishCoalesce(adjustments.brightness, () => ( 0)),
3964
+ contrast: _nullishCoalesce(adjustments.contrast, () => ( 0)),
3965
+ saturation: _nullishCoalesce(adjustments.saturation, () => ( 0)),
3966
+ exposure: _nullishCoalesce(adjustments.exposure, () => ( 0)),
3967
+ temperature: _nullishCoalesce(adjustments.temperature, () => ( 0)),
3968
+ tint: _nullishCoalesce(adjustments.tint, () => ( 0)),
3969
+ process: normalizeProcessVersion(adjustments.process)
3970
+ };
3971
+ }
3972
+ function annotationLayerName(annotation) {
3973
+ switch (annotation.type) {
3974
+ case "pen":
3975
+ return "Pen";
3976
+ case "rect":
3977
+ return "Rectangle";
3978
+ case "circle":
3979
+ return "Ellipse";
3980
+ case "arrow":
3981
+ return "Arrow";
3982
+ case "line":
3983
+ return "Line";
3984
+ case "text":
3985
+ return annotation.text ? annotation.text.slice(0, 32) : "Text";
3986
+ case "image":
3987
+ return "Image";
3988
+ }
3989
+ }
3990
+ function annotationLayerFor(annotation, canvas) {
3991
+ const shape = canvas ? shapeFromAnnotation(annotation) : null;
3992
+ if (shape) {
3993
+ const layer = createShapeLayer(
3994
+ { ...shape, name: annotationLayerName(annotation), blend: annotation.blend && annotation.blend !== "normal" ? annotation.blend : "normal" },
3995
+ canvas,
3996
+ annotation.id
3997
+ );
3998
+ return { ...layer, annotation };
3999
+ }
4000
+ return {
4001
+ type: "annotation",
4002
+ id: annotation.id,
4003
+ name: annotationLayerName(annotation),
4004
+ visible: true,
4005
+ opacity: 1,
4006
+ blend: "normal",
4007
+ annotation
4008
+ };
4009
+ }
4010
+ function annotationOfLayer(layer) {
4011
+ if (layer.type === "annotation") return layer.annotation;
4012
+ if (layer.type === "shape") return annotationOfShape(layer);
4013
+ return null;
4014
+ }
4015
+ function adjustmentNodeFromLegacy(layer, width, height) {
4016
+ const node = {
4017
+ type: "adjustment",
4018
+ id: layer.id,
4019
+ name: _nullishCoalesce(layer.name, () => ( "")),
4020
+ visible: layer.enabled !== false,
4021
+ opacity: _nullishCoalesce(layer.opacity, () => ( 1)),
4022
+ blend: _nullishCoalesce(layer.blend, () => ( "normal")),
4023
+ kind: layer.kind,
4024
+ params: JSON.parse(JSON.stringify(layer.params))
4025
+ };
4026
+ if (layer.mask) {
4027
+ const mask = rasterMaskFromLegacy(layer.mask, width, height);
4028
+ if (mask) node.mask = mask;
4029
+ }
4030
+ return node;
4031
+ }
4032
+ function backgroundLayer(filters = [], mask) {
4033
+ const layer = {
4034
+ type: "pixel",
4035
+ id: BACKGROUND_LAYER_ID,
4036
+ name: BACKGROUND_LAYER_NAME,
4037
+ visible: true,
4038
+ opacity: 1,
4039
+ blend: "normal",
4040
+ surface: _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4),
4041
+ offset: { x: 0, y: 0 },
4042
+ source: "document",
4043
+ filters
4044
+ };
4045
+ if (mask) layer.mask = mask;
4046
+ return layer;
4047
+ }
4048
+ function depthRasterMask(source) {
4049
+ const out = {
4050
+ surface: _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 1, 255),
4051
+ defaultValue: 255,
4052
+ source: { ...source, depthRange: [...source.depthRange] }
4053
+ };
4054
+ if (!source.enabled) out.enabled = false;
4055
+ return out;
4056
+ }
4057
+ function layersFromLegacy(parts, width, height) {
4058
+ const stored = parts.adjustments;
4059
+ const adjustments = stored ? { ...DEFAULT_ADJUSTMENTS_VALUES, ...stored, process: normalizeProcessVersion(stored.process) } : { ...DEFAULT_ADJUSTMENTS_VALUES };
4060
+ const adjLayers = normalizeAdjustmentLayers(adjustments.layers);
4061
+ const filters = [developFromAdjustments(adjustments)];
4062
+ const blur = typeof adjustments.blur === "number" && adjustments.blur > 0 ? adjustments.blur : 0;
4063
+ let legacyOutputBlur;
4064
+ if (blur > 0) {
4065
+ if (adjLayers.length) legacyOutputBlur = blur;
4066
+ else filters.push({ id: BLUR_FILTER_ID, kind: "blur", enabled: true, radius: blur });
4067
+ }
4068
+ const depth = parts.depthMask;
4069
+ const mask = depth && !isDefaultDepthMask(depth) ? depthRasterMask({ ...DEFAULT_DEPTH_MASK_VALUES, ...depth }) : void 0;
4070
+ const layers = [backgroundLayer(filters, mask)];
4071
+ for (const l of adjLayers) layers.push(adjustmentNodeFromLegacy(l, width, height));
4072
+ for (const a of _nullishCoalesce(parts.annotations, () => ( []))) layers.push(annotationLayerFor(JSON.parse(JSON.stringify(a)), { width, height }));
4073
+ const out = { layers, outputOpacity: typeof adjustments.opacity === "number" ? adjustments.opacity : 1 };
4074
+ if (legacyOutputBlur !== void 0) out.legacyOutputBlur = legacyOutputBlur;
4075
+ return out;
4076
+ }
4077
+ function legacyAdjustmentLayer(node, width, height) {
4078
+ const out = {
4079
+ id: node.id,
4080
+ kind: node.kind,
4081
+ enabled: node.visible,
4082
+ opacity: node.opacity,
4083
+ blend: node.blend,
4084
+ params: node.params
4085
+ };
4086
+ if (node.name) out.name = node.name;
4087
+ if (node.mask && !node.mask.source) out.mask = legacyMaskOf(node.mask, width, height);
4088
+ return out;
4089
+ }
4090
+ function developTarget(layers, activeLayerId) {
4091
+ const pixels = [];
4092
+ const walk = (list2) => {
4093
+ for (const l of list2) {
4094
+ if (l.type === "pixel") pixels.push(l);
4095
+ else if (l.type === "group") walk(l.children);
4096
+ }
4097
+ };
4098
+ walk(layers);
4099
+ if (activeLayerId) {
4100
+ const active = pixels.find((l) => l.id === activeLayerId);
4101
+ if (active) return active;
4102
+ }
4103
+ return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(pixels.find((l) => l.source === "document"), () => ( pixels.find((l) => l.id === BACKGROUND_LAYER_ID))), () => ( pixels[0])), () => ( null));
4104
+ }
4105
+ var isPlain = (l) => l.visible && l.opacity === 1 && l.blend === "normal" && !l.clipped && !l.mask && !l.locks && !l.effects;
4106
+ function legacyView(stack, width, height, activeLayerId = null) {
4107
+ const { layers } = stack;
4108
+ const target = developTarget(layers, activeLayerId);
4109
+ const develop = target ? developFilter(target) : void 0;
4110
+ const blur = _nullishCoalesce(_nullishCoalesce(stack.legacyOutputBlur, () => ( (target ? _optionalChain([blurFilter, 'call', _59 => _59(target), 'optionalAccess', _60 => _60.radius]) : void 0))), () => ( 0));
4111
+ const adjustments = {
4112
+ ...DEFAULT_ADJUSTMENTS_VALUES,
4113
+ ...develop ? {
4114
+ brightness: develop.brightness,
4115
+ contrast: develop.contrast,
4116
+ saturation: develop.saturation,
4117
+ exposure: develop.exposure,
4118
+ temperature: develop.temperature,
4119
+ tint: _nullishCoalesce(develop.tint, () => ( 0))
4120
+ } : {},
4121
+ blur,
4122
+ opacity: stack.outputOpacity,
4123
+ process: develop ? normalizeProcessVersion(develop.process) : DEFAULT_ADJUSTMENTS_VALUES.process
4124
+ };
4125
+ const adjNodes = [];
4126
+ const annotations = [];
4127
+ const walk = (list2) => {
4128
+ for (const l of list2) {
4129
+ if (l.type === "adjustment") adjNodes.push(l);
4130
+ else if (l.type === "group") walk(l.children);
4131
+ else {
4132
+ const a = annotationOfLayer(l);
4133
+ if (a) annotations.push(a);
4134
+ }
4135
+ }
4136
+ };
4137
+ walk(layers);
4138
+ if (adjNodes.length) adjustments.layers = adjNodes.map((n) => legacyAdjustmentLayer(n, width, height));
4139
+ const depthSource = _optionalChain([target, 'optionalAccess', _61 => _61.mask, 'optionalAccess', _62 => _62.source]);
4140
+ const depthMask = depthSource ? { ...depthSource, depthRange: [...depthSource.depthRange] } : { ...DEFAULT_DEPTH_MASK_VALUES, depthRange: [...DEFAULT_DEPTH_MASK_VALUES.depthRange] };
4141
+ return { adjustments, depthMask, annotations, exact: isLegacyShape(stack) };
4142
+ }
4143
+ function isLegacyShape(stack) {
4144
+ const { layers } = stack;
4145
+ const bg = layers[0];
4146
+ if (!bg || bg.type !== "pixel" || bg.source !== "document") return false;
4147
+ if (bg.id !== BACKGROUND_LAYER_ID || bg.name !== BACKGROUND_LAYER_NAME) return false;
4148
+ if (!bg.visible || bg.opacity !== 1 || bg.blend !== "normal" || bg.clipped || bg.locks || bg.effects) return false;
4149
+ if ((_nullishCoalesce(bg.fillOpacity, () => ( 1))) !== 1 || bg.offset.x !== 0 || bg.offset.y !== 0) return false;
4150
+ const filters = _nullishCoalesce(bg.filters, () => ( []));
4151
+ if (filters.length < 1 || filters.length > 2) return false;
4152
+ const [develop, blur] = filters;
4153
+ if (develop.kind !== "develop" || !develop.enabled || develop.id !== DEVELOP_FILTER_ID) return false;
4154
+ if (blur && (blur.kind !== "blur" || !blur.enabled || blur.id !== BLUR_FILTER_ID || !(blur.radius > 0))) return false;
4155
+ if (bg.mask) {
4156
+ const m = bg.mask;
4157
+ if (!m.source || m.density !== void 0 || m.feather !== void 0) return false;
4158
+ if (m.enabled !== false !== m.source.enabled) return false;
4159
+ }
4160
+ let i = 1;
4161
+ let adjustments = 0;
4162
+ for (; i < layers.length && layers[i].type === "adjustment"; i++) {
4163
+ const l = layers[i];
4164
+ if (l.clipped || l.locks || _optionalChain([l, 'access', _63 => _63.mask, 'optionalAccess', _64 => _64.source]) || l.effects) return false;
4165
+ adjustments++;
4166
+ }
4167
+ for (; i < layers.length; i++) {
4168
+ const l = layers[i];
4169
+ if (l.type === "shape") {
4170
+ const a = l.annotation;
4171
+ if (!a || (_nullishCoalesce(a.blend, () => ( "normal"))) !== l.blend || !isPlain({ ...l, blend: "normal" }) || l.fillOpacity !== void 0) return false;
4172
+ if (l.id !== a.id || l.name !== annotationLayerName(a)) return false;
4173
+ continue;
4174
+ }
4175
+ if (l.type !== "annotation" || !isPlain(l) || l.id !== l.annotation.id || l.name !== annotationLayerName(l.annotation)) return false;
4176
+ }
4177
+ if (blur && adjustments) return false;
4178
+ if (stack.legacyOutputBlur !== void 0 && (!adjustments || !(stack.legacyOutputBlur > 0))) return false;
4179
+ return true;
4180
+ }
4181
+
4182
+ // src/image-editor/transform.ts
4183
+ var FREE_TRANSFORM_MODES = ["scale", "rotate", "skew", "distort", "perspective", "warp"];
4184
+ var TRANSFORM_ANCHORS = ["top-left", "top", "top-right", "left", "center", "right", "bottom-left", "bottom", "bottom-right"];
4185
+ var ANCHOR_FRACTION = {
4186
+ "top-left": [0, 0],
4187
+ top: [0.5, 0],
4188
+ "top-right": [1, 0],
4189
+ left: [0, 0.5],
4190
+ center: [0.5, 0.5],
4191
+ right: [1, 0.5],
4192
+ "bottom-left": [0, 1],
4193
+ bottom: [0.5, 1],
4194
+ "bottom-right": [1, 1]
4195
+ };
4196
+ function isTransformAnchor(value) {
4197
+ return typeof value === "string" && value in ANCHOR_FRACTION;
4198
+ }
4199
+ function identityTransform(box2) {
4200
+ return { box: { ...box2 }, corners: _chunkMUUXNRU4cjs.boxQuad.call(void 0, box2) };
4201
+ }
4202
+ function cornersFromMatrix(box2, m) {
4203
+ const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, box2);
4204
+ return [_chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[0]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[1]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[2]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[3])];
4205
+ }
4206
+ function matrixFromCorners(box2, corners, eps = 1e-6) {
4207
+ const [tl, tr, br, bl] = corners;
4208
+ const size = 1 + Math.max(box2.width, box2.height);
4209
+ if (Math.abs(tl.x + br.x - tr.x - bl.x) > eps * size || Math.abs(tl.y + br.y - tr.y - bl.y) > eps * size) return null;
4210
+ const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, box2, corners);
4211
+ return h ? _chunkMUUXNRU4cjs.affineFromHomography.call(void 0, h, 1e-9) : null;
4212
+ }
4213
+ function transformHomography(geometry) {
4214
+ const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
4215
+ if (!h) return null;
4216
+ return _chunkMUUXNRU4cjs.homographyKeepsQuad.call(void 0, h, _chunkMUUXNRU4cjs.boxQuad.call(void 0, geometry.box)) ? h : null;
4217
+ }
4218
+ function hasWarp(geometry) {
4219
+ const w = geometry.warp;
4220
+ if (!w) return false;
4221
+ const id = _chunkW3GXSUSQcjs.identityWarpMesh.call(void 0, geometry.box, w.us.length - 1, w.vs.length - 1);
4222
+ if (id.points.length !== w.points.length || id.us.some((u, i) => Math.abs(u - w.us[i]) > 1e-12) || id.vs.some((v, i) => Math.abs(v - w.vs[i]) > 1e-12)) return true;
4223
+ return w.points.some((p, i) => Math.abs(p.x - id.points[i].x) > 1e-6 || Math.abs(p.y - id.points[i].y) > 1e-6);
4224
+ }
4225
+ function isIdentityTransform(geometry) {
4226
+ if (hasWarp(geometry)) return false;
4227
+ const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, geometry.box);
4228
+ return geometry.corners.every((c, i) => Math.abs(c.x - q2[i].x) < 1e-6 && Math.abs(c.y - q2[i].y) < 1e-6);
4229
+ }
4230
+ function transformMap(geometry) {
4231
+ const h = transformHomography(geometry);
4232
+ if (!h) return null;
4233
+ const { box: box2 } = geometry;
4234
+ const warp = hasWarp(geometry) ? geometry.warp : null;
4235
+ if (!warp) return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p);
4236
+ return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, _chunkW3GXSUSQcjs.evalWarpMesh.call(void 0, warp, (p.x - box2.x) / box2.width, (p.y - box2.y) / box2.height));
2735
4237
  }
2736
- function requireEffectLayer(layers, id, action) {
2737
- const layer = requireLayer(layers, id).layer;
2738
- if (layer.type === "adjustment") fail(`Layer "${layer.name || id}" is an adjustment layer; effects go on pixel, annotation and group layers.`);
2739
- requireUnlocked(layer, "all", action);
2740
- return layer;
4238
+ function transformedPoint(geometry, fx, fy) {
4239
+ const f = transformMap(geometry);
4240
+ const { box: box2 } = geometry;
4241
+ return f ? f({ x: box2.x + fx * box2.width, y: box2.y + fy * box2.height }) : null;
2741
4242
  }
2742
- function layerEffectsOf(layer) {
2743
- return _nullishCoalesce(layer.effects, () => ( { enabled: true, items: [] }));
4243
+ function anchorPoint(geometry, anchor) {
4244
+ const [fx, fy] = ANCHOR_FRACTION[anchor];
4245
+ const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
4246
+ const p = { x: geometry.box.x + fx * geometry.box.width, y: geometry.box.y + fy * geometry.box.height };
4247
+ return _nullishCoalesce((h && _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p)), () => ( p));
2744
4248
  }
2745
- function guard(fn) {
2746
- try {
2747
- return fn();
2748
- } catch (e) {
2749
- if (e instanceof _chunkT3QZ6S47cjs.LayerEffectError) fail(e.message);
2750
- throw e;
4249
+ function transformedBox(geometry) {
4250
+ const f = transformMap(geometry);
4251
+ if (!f) return null;
4252
+ const { box: box2 } = geometry;
4253
+ const pts = [];
4254
+ const n = hasWarp(geometry) ? 16 : 1;
4255
+ for (let i = 0; i <= n; i++) {
4256
+ const t = i / n;
4257
+ for (const [fx, fy] of [[t, 0], [1, t], [1 - t, 1], [0, 1 - t]]) {
4258
+ const p = f({ x: box2.x + fx * box2.width, y: box2.y + fy * box2.height });
4259
+ if (!p) return null;
4260
+ pts.push(p);
4261
+ }
2751
4262
  }
4263
+ const xs = pts.map((p) => p.x);
4264
+ const ys = pts.map((p) => p.y);
4265
+ const x = Math.min(...xs);
4266
+ const y = Math.min(...ys);
4267
+ return { x, y, width: Math.max(...xs) - x, height: Math.max(...ys) - y };
2752
4268
  }
2753
- function setLayerEffects(layers, id, effects) {
2754
- const layer = requireEffectLayer(layers, id, "change its effects");
2755
- const next = { ...layer };
2756
- if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
2757
- guard(() => _chunkT3QZ6S47cjs.validateLayerEffects.call(void 0, effects));
2758
- next.effects = effects;
2759
- } else delete next.effects;
2760
- return _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => next);
4269
+ function referencePoint(box2, reference) {
4270
+ if (reference && typeof reference === "object") return { x: reference.x, y: reference.y };
4271
+ const [fx, fy] = ANCHOR_FRACTION[_nullishCoalesce(reference, () => ( "center"))];
4272
+ return { x: box2.x + fx * box2.width, y: box2.y + fy * box2.height };
2761
4273
  }
2762
- function addLayerEffect(layers, id, kind, params = {}, index) {
2763
- if (!_chunkT3QZ6S47cjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkT3QZ6S47cjs.LAYER_EFFECT_KINDS.join(", ")}.`);
2764
- const layer = requireEffectLayer(layers, id, "add effects");
2765
- const current = layerEffectsOf(layer);
2766
- const ids = new Set(current.items.map((e) => e.id));
2767
- let effectId = _chunkT3QZ6S47cjs.newEffectId.call(void 0, );
2768
- while (ids.has(effectId)) effectId = _chunkT3QZ6S47cjs.newEffectId.call(void 0, );
2769
- const { id: _ignored, kind: _kind, ...rest } = params;
2770
- const effect = guard(() => _chunkT3QZ6S47cjs.mergeLayerEffect.call(void 0, _chunkT3QZ6S47cjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
2771
- const items = [...current.items];
2772
- const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
2773
- items.splice(at, 0, effect);
2774
- return { layers: setLayerEffects(layers, id, { ...current, items }), effect };
4274
+ function matrixFromParams(box2, params) {
4275
+ const sx = (_nullishCoalesce(params.scaleX, () => ( 100))) / 100;
4276
+ const sy = (_nullishCoalesce(params.scaleY, () => ( 100))) / 100;
4277
+ const tx = Math.tan((_nullishCoalesce(params.skewX, () => ( 0))) * Math.PI / 180);
4278
+ const ty = Math.tan((_nullishCoalesce(params.skewY, () => ( 0))) * Math.PI / 180);
4279
+ const ref = referencePoint(box2, params.reference);
4280
+ const linear = _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, [1, ty, tx, 1, 0, 0], [sx, 0, 0, sy, 0, 0]), _chunkW3GXSUSQcjs.rotateMatrix.call(void 0, _nullishCoalesce(params.rotate, () => ( 0))));
4281
+ return _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, _chunkW3GXSUSQcjs.matrixAbout.call(void 0, linear, ref), _chunkW3GXSUSQcjs.translateMatrix.call(void 0, _nullishCoalesce(params.dx, () => ( 0)), _nullishCoalesce(params.dy, () => ( 0))));
2775
4282
  }
2776
- function requireEffect(layer, effectId) {
2777
- const items = _nullishCoalesce(_optionalChain([layer, 'access', _38 => _38.effects, 'optionalAccess', _39 => _39.items]), () => ( []));
2778
- const i = items.findIndex((e) => e.id === effectId);
2779
- if (i === -1) fail(`Layer "${layer.name || layer.id}" has no effect "${effectId}". Effects: ${items.map((e) => `${e.id} (${e.kind})`).join(", ") || "none"}; call list_layer_effects.`);
2780
- return i;
4283
+ function describeTransform(geometry, reference = "center") {
4284
+ const m = hasWarp(geometry) ? null : matrixFromCorners(geometry.box, geometry.corners);
4285
+ const ref = referencePoint(geometry.box, reference);
4286
+ const bounds = transformedBox(geometry);
4287
+ if (!m) {
4288
+ const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
4289
+ const at2 = _nullishCoalesce((h && _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, ref)), () => ( ref));
4290
+ return { affine: false, scaleX: 100, scaleY: 100, rotate: 0, skewX: 0, x: at2.x, y: at2.y, bounds, corners: geometry.corners };
4291
+ }
4292
+ const [a, b, c, d] = m;
4293
+ const sxAbs = Math.hypot(a, b);
4294
+ const rot = Math.atan2(b, a) * 180 / Math.PI;
4295
+ const shear = sxAbs ? (a * c + b * d) / sxAbs : 0;
4296
+ const sy = sxAbs ? (a * d - b * c) / sxAbs : 0;
4297
+ const skew = sxAbs ? Math.atan(shear / sxAbs) * 180 / Math.PI : 0;
4298
+ const at = _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, ref);
4299
+ const clean = (v) => Math.abs(v) < 1e-9 ? 0 : v;
4300
+ return {
4301
+ affine: true,
4302
+ scaleX: clean(sxAbs * 100),
4303
+ scaleY: clean(sy * 100),
4304
+ rotate: clean(rot === -180 ? 180 : rot),
4305
+ skewX: clean(skew),
4306
+ x: at.x,
4307
+ y: at.y,
4308
+ bounds,
4309
+ corners: geometry.corners
4310
+ };
2781
4311
  }
2782
- function updateLayerEffect(layers, id, effectId, changes) {
2783
- const layer = requireEffectLayer(layers, id, "change its effects");
2784
- const i = requireEffect(layer, effectId);
2785
- const current = layer.effects;
2786
- const items = [...current.items];
2787
- items[i] = guard(() => _chunkT3QZ6S47cjs.mergeLayerEffect.call(void 0, items[i], changes));
2788
- return setLayerEffects(layers, id, { ...current, items });
4312
+ function applyParams(geometry, params) {
4313
+ const ref = params.reference && typeof params.reference === "object" ? params.reference : anchorPoint(geometry, _nullishCoalesce(params.reference, () => ( "center")));
4314
+ const m = matrixFromParams({ x: ref.x, y: ref.y, width: 0, height: 0 }, { ...params, reference: ref });
4315
+ const c = geometry.corners;
4316
+ return [_chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, c[0]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, c[1]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, c[2]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, c[3])];
2789
4317
  }
2790
- function removeLayerEffect(layers, id, effectId) {
2791
- const layer = requireEffectLayer(layers, id, "change its effects");
2792
- requireEffect(layer, effectId);
2793
- const current = layer.effects;
2794
- return setLayerEffects(layers, id, { ...current, items: current.items.filter((e) => e.id !== effectId) });
4318
+ function flipCorners(geometry, axis) {
4319
+ const c = anchorPoint(geometry, "center");
4320
+ const m = axis === "horizontal" ? [-1, 0, 0, 1, 2 * c.x, 0] : [1, 0, 0, -1, 0, 2 * c.y];
4321
+ const q2 = geometry.corners;
4322
+ return [_chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[0]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[1]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[2]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[3])];
2795
4323
  }
2796
- function setLayerEffectsEnabled(layers, id, enabled, scale) {
2797
- const layer = requireEffectLayer(layers, id, "change its effects");
2798
- if (scale !== void 0 && !(Number.isFinite(scale) && scale >= 0.01 && scale <= 10)) fail(`scale must be from 0.01 to 10 (1 = 100 %), got ${scale}.`);
2799
- const current = layerEffectsOf(layer);
2800
- const next = { ...current, enabled };
2801
- if (scale !== void 0) {
2802
- if (scale === 1) delete next.scale;
2803
- else next.scale = scale;
2804
- }
2805
- return setLayerEffects(layers, id, next);
4324
+ function boxPointOf(geometry, p) {
4325
+ const m = matrixFromCorners(geometry.box, geometry.corners);
4326
+ if (m) return _chunkW3GXSUSQcjs.applyMatrix.call(void 0, _chunkW3GXSUSQcjs.invertMatrix.call(void 0, m), p);
4327
+ return null;
2806
4328
  }
2807
- function parseBlend(value, allowPassThrough = false) {
2808
- if (value === void 0) return void 0;
2809
- if (value === "pass-through" && allowPassThrough) return value;
2810
- if (!_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, value)) fail(`Unknown blend mode "${String(value)}".`);
2811
- return value;
4329
+ function presetWarp(box2, preset) {
4330
+ return _chunkW3GXSUSQcjs.warpPresetMesh.call(void 0, preset, box2);
2812
4331
  }
2813
- function unionRect(a, b) {
2814
- if (!a) return b;
2815
- if (!b) return a;
2816
- const x = Math.min(a.x, b.x);
2817
- const y = Math.min(a.y, b.y);
2818
- 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 };
4332
+ function isValidWarp(mesh) {
4333
+ return _chunkW3GXSUSQcjs.isValidWarpMesh.call(void 0, mesh);
4334
+ }
4335
+ function geometryHomography(geometry) {
4336
+ const m = matrixFromCorners(geometry.box, geometry.corners);
4337
+ return m ? _chunkMUUXNRU4cjs.homographyFromAffine.call(void 0, m) : transformHomography(geometry);
2819
4338
  }
2820
4339
 
2821
4340
  // src/image-editor/layers/smart.ts
2822
- var fail2 = (message) => {
4341
+ var fail3 = (message) => {
2823
4342
  throw new LayerOperationError(message);
2824
4343
  };
2825
- var SMART_RENDER_MARGIN = _chunkT3QZ6S47cjs.MAX_EFFECT_REACH;
4344
+ var SMART_RENDER_MARGIN = _chunkAZTZRLDIcjs.MAX_EFFECT_REACH;
2826
4345
  function newContentsId() {
2827
4346
  return newLayerId("so");
2828
4347
  }
@@ -2840,14 +4359,14 @@ function isContentsDecoded(contents) {
2840
4359
  }
2841
4360
  function requireDecoded(layer, action) {
2842
4361
  if (isContentsDecoded(layer.contents)) return;
2843
- const what = _optionalChain([layer, 'access', _40 => _40.contents, 'access', _41 => _41.file, 'optionalAccess', _42 => _42.type]) ? `a ${layer.contents.file.type.toUpperCase()} file` : "a file";
2844
- fail2(
4362
+ const what = _optionalChain([layer, 'access', _65 => _65.contents, 'access', _66 => _66.file, 'optionalAccess', _67 => _67.type]) ? `a ${layer.contents.file.type.toUpperCase()} file` : "a file";
4363
+ fail3(
2845
4364
  `The contents of smart object "${layer.name || layer.id}" are ${what} that could not be decoded here, so it cannot ${action}. Run prepareSmartObjects() in a browser first, or rasterize it.`
2846
4365
  );
2847
4366
  }
2848
4367
  function requireSmartObject(layers, id) {
2849
4368
  const layer = requireLayer(layers, id).layer;
2850
- if (layer.type !== "smart") fail2(`Layer "${layer.name || id}" is a ${layer.type} layer, not a smart object; convert it with convert_to_smart_object.`);
4369
+ if (layer.type !== "smart") fail3(`Layer "${layer.name || id}" is a ${layer.type} layer, not a smart object; convert it with convert_to_smart_object.`);
2851
4370
  return layer;
2852
4371
  }
2853
4372
  var contentsPixels = /* @__PURE__ */ new WeakMap();
@@ -2865,7 +4384,7 @@ function contentsSurface(contents) {
2865
4384
  width: W,
2866
4385
  height: H,
2867
4386
  globalLight: doc.globalLight,
2868
- pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access', _43 => _43.patterns, 'optionalAccess', _44 => _44.find, 'call', _45 => _45((p) => p.id === id)]), () => ( null))
4387
+ pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access', _68 => _68.patterns, 'optionalAccess', _69 => _69.find, 'call', _70 => _70((p) => p.id === id)]), () => ( null))
2869
4388
  });
2870
4389
  s = _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, { width: W, height: H, data }, 4, 0, 0);
2871
4390
  }
@@ -2873,11 +4392,11 @@ function contentsSurface(contents) {
2873
4392
  return s;
2874
4393
  }
2875
4394
  function rasterContents(pixels, name, id = newContentsId()) {
2876
- if (!(pixels.width > 0 && pixels.height > 0) || pixels.data.length < pixels.width * pixels.height * 4) fail2("Contents pixels must be RGBA with width \xD7 height \xD7 4 bytes.");
4395
+ if (!(pixels.width > 0 && pixels.height > 0) || pixels.data.length < pixels.width * pixels.height * 4) fail3("Contents pixels must be RGBA with width \xD7 height \xD7 4 bytes.");
2877
4396
  return { id, name, width: pixels.width, height: pixels.height, kind: "raster", raster: _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, pixels, 4, 0, 0) };
2878
4397
  }
2879
4398
  function documentContents(document, width, height, name, id = newContentsId()) {
2880
- if (!(Number.isInteger(width) && Number.isInteger(height) && width > 0 && height > 0)) fail2("Contents width and height must be positive whole numbers.");
4399
+ if (!(Number.isInteger(width) && Number.isInteger(height) && width > 0 && height > 0)) fail3("Contents width and height must be positive whole numbers.");
2881
4400
  return { id, name, width, height, kind: "document", document };
2882
4401
  }
2883
4402
  var placedCache = /* @__PURE__ */ new WeakMap();
@@ -2900,7 +4419,7 @@ function placeContents(layer, canvas, options = {}) {
2900
4419
  const preview = Boolean(options.step && options.step > 1) || Boolean(options.clip);
2901
4420
  const key = placementKey(placement, canvas);
2902
4421
  if (!preview) {
2903
- const hit = _optionalChain([placedCache, 'access', _46 => _46.get, 'call', _47 => _47(contents), 'optionalAccess', _48 => _48.get, 'call', _49 => _49(key)]);
4422
+ const hit = _optionalChain([placedCache, 'access', _71 => _71.get, 'call', _72 => _72(contents), 'optionalAccess', _73 => _73.get, 'call', _74 => _74(key)]);
2904
4423
  if (hit) return hit;
2905
4424
  }
2906
4425
  const src = contentsSurface(contents);
@@ -2927,27 +4446,27 @@ function placeContents(layer, canvas, options = {}) {
2927
4446
  let k = 1;
2928
4447
  if (step > 1) {
2929
4448
  k = step;
2930
- let r = _optionalChain([options, 'access', _50 => _50.reduced, 'optionalAccess', _51 => _51.get, 'call', _52 => _52(k)]);
4449
+ let r = _optionalChain([options, 'access', _75 => _75.reduced, 'optionalAccess', _76 => _76.get, 'call', _77 => _77(k)]);
2931
4450
  if (!r) {
2932
- r = _chunkT3QZ6S47cjs.reduceSurface.call(void 0, src, k);
2933
- _optionalChain([options, 'access', _53 => _53.reduced, 'optionalAccess', _54 => _54.set, 'call', _55 => _55(k, r)]);
4451
+ r = _chunkAZTZRLDIcjs.reduceSurface.call(void 0, src, k);
4452
+ _optionalChain([options, 'access', _78 => _78.reduced, 'optionalAccess', _79 => _79.set, 'call', _80 => _80(k, r)]);
2934
4453
  }
2935
4454
  source = r;
2936
4455
  }
2937
- const box = { x: 0, y: 0, width: Math.ceil(contents.width / k), height: Math.ceil(contents.height / k) };
4456
+ const box2 = { x: 0, y: 0, width: Math.ceil(contents.width / k), height: Math.ceil(contents.height / k) };
2938
4457
  try {
2939
4458
  if (hasWarp(g)) {
2940
4459
  const f = transformMap(g);
2941
- if (!f) fail2("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
2942
- out = _chunkT3QZ6S47cjs.warpSurface.call(void 0, source, (p) => f({ x: p.x * k, y: p.y * k }), { interpolation, source: box, clip, step: step > 1 ? step : void 0 });
4460
+ if (!f) fail3("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
4461
+ out = _chunkAZTZRLDIcjs.warpSurface.call(void 0, source, (p) => f({ x: p.x * k, y: p.y * k }), { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
2943
4462
  } else {
2944
4463
  const h = transformHomography(g);
2945
- if (!h) fail2("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
4464
+ if (!h) fail3("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
2946
4465
  const hk = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, [k, 0, 0, 0, k, 0, 0, 0, 1], h);
2947
- out = _chunkT3QZ6S47cjs.transformSurface.call(void 0, source, hk, { interpolation, source: box, clip, step: step > 1 ? step : void 0 });
4466
+ out = _chunkAZTZRLDIcjs.transformSurface.call(void 0, source, hk, { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
2948
4467
  }
2949
4468
  } catch (e) {
2950
- if (e instanceof _chunkT3QZ6S47cjs.TransformTooLargeError) fail2(e.message);
4469
+ if (e instanceof _chunkAZTZRLDIcjs.TransformTooLargeError) fail3(e.message);
2951
4470
  throw e;
2952
4471
  }
2953
4472
  }
@@ -2963,7 +4482,7 @@ function placeContents(layer, canvas, options = {}) {
2963
4482
  return out;
2964
4483
  }
2965
4484
  function activeSmartFilters(stack) {
2966
- if (!_optionalChain([stack, 'optionalAccess', _56 => _56.enabled])) return [];
4485
+ if (!_optionalChain([stack, 'optionalAccess', _81 => _81.enabled])) return [];
2967
4486
  return stack.filters.filter((f) => f.kind !== "psd" && isActiveFilter(f) && f.opacity > 0);
2968
4487
  }
2969
4488
  function filterMaskCoverage(mask, canvas) {
@@ -2979,7 +4498,7 @@ function filterMaskCoverage(mask, canvas) {
2979
4498
  }
2980
4499
  const feather = _nullishCoalesce(mask.feather, () => ( 0));
2981
4500
  if (all && !(feather > 0)) return null;
2982
- if (feather > 0) v = _chunkT3QZ6S47cjs.gaussianBlur.call(void 0, v, W, H, feather, "clamp");
4501
+ if (feather > 0) v = _chunkAZTZRLDIcjs.gaussianBlur.call(void 0, v, W, H, feather, "clamp");
2983
4502
  const density = _nullishCoalesce(mask.density, () => ( 1));
2984
4503
  if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
2985
4504
  return v;
@@ -3001,7 +4520,7 @@ function applySmartFilters(placed, stack, canvas) {
3001
4520
  if (f.opacity >= 1) acc = out;
3002
4521
  else lerpInto(acc, out, f.opacity, null);
3003
4522
  } else {
3004
- _chunkT3QZ6S47cjs.blendTile.call(void 0, acc, out, f.blend, f.opacity, null);
4523
+ _chunkAZTZRLDIcjs.blendTile.call(void 0, acc, out, f.blend, f.opacity, null);
3005
4524
  }
3006
4525
  }
3007
4526
  entry = { key, base, filtered: acc };
@@ -3038,21 +4557,21 @@ function rerender(layer, canvas, action = "change") {
3038
4557
  return { ...layer, surface: renderSmartObject(layer, canvas) };
3039
4558
  }
3040
4559
  function normalizePlacement(raw, contents) {
3041
- const c = _optionalChain([raw, 'optionalAccess', _57 => _57.corners]);
4560
+ const c = _optionalChain([raw, 'optionalAccess', _82 => _82.corners]);
3042
4561
  if (!Array.isArray(c) || c.length !== 4 || !c.every((p) => p && Number.isFinite(p.x) && Number.isFinite(p.y))) {
3043
- fail2("corners must be four finite points [top-left, top-right, bottom-right, bottom-left] in document pixels.");
4562
+ fail3("corners must be four finite points [top-left, top-right, bottom-right, bottom-left] in document pixels.");
3044
4563
  }
3045
4564
  const out = { corners: c.map((p) => ({ x: p.x, y: p.y })) };
3046
4565
  if (raw.warp) {
3047
- if (!_chunkDWGZUSEScjs.isValidWarpMesh.call(void 0, raw.warp)) fail2("warp must be a mesh with us and vs (knots from 0 to 1, increasing) and (3\xB7columns + 1) \xD7 (3\xB7rows + 1) finite points in contents pixels.");
4566
+ if (!_chunkW3GXSUSQcjs.isValidWarpMesh.call(void 0, raw.warp)) fail3("warp must be a mesh with us and vs (knots from 0 to 1, increasing) and (3\xB7columns + 1) \xD7 (3\xB7rows + 1) finite points in contents pixels.");
3048
4567
  out.warp = { us: [...raw.warp.us], vs: [...raw.warp.vs], points: raw.warp.points.map((p) => ({ x: p.x, y: p.y })) };
3049
4568
  }
3050
4569
  if (raw.interpolation !== void 0) {
3051
- if (!_chunkT3QZ6S47cjs.isInterpolation.call(void 0, raw.interpolation)) fail2(`Unknown interpolation "${String(raw.interpolation)}"; use nearest, bilinear or bicubic.`);
4570
+ if (!_chunkAZTZRLDIcjs.isInterpolation.call(void 0, raw.interpolation)) fail3(`Unknown interpolation "${String(raw.interpolation)}"; use nearest, bilinear or bicubic.`);
3052
4571
  if (raw.interpolation !== "bicubic") out.interpolation = raw.interpolation;
3053
4572
  }
3054
4573
  const g = { box: { x: 0, y: 0, width: contents.width, height: contents.height }, corners: out.corners, warp: _nullishCoalesce(out.warp, () => ( null)) };
3055
- if (!transformHomography(g)) fail2("These corners fold the contents over themselves or through the horizon; keep the quad convex.");
4574
+ if (!transformHomography(g)) fail3("These corners fold the contents over themselves or through the horizon; keep the quad convex.");
3056
4575
  if (out.warp && !hasWarp(g)) delete out.warp;
3057
4576
  return out;
3058
4577
  }
@@ -3068,7 +4587,7 @@ function followMask(mask, before, after) {
3068
4587
  const inv = _chunkMUUXNRU4cjs.invertHomography.call(void 0, h0);
3069
4588
  if (!inv) return mask;
3070
4589
  const delta = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, inv, h1);
3071
- const surface = _chunkT3QZ6S47cjs.transformSurface.call(void 0, mask.surface, delta, { interpolation: "bilinear" });
4590
+ const surface = _chunkAZTZRLDIcjs.transformSurface.call(void 0, mask.surface, delta, { interpolation: "bilinear" });
3072
4591
  return { ...mask, surface };
3073
4592
  }
3074
4593
  function setSmartPlacement(layers, id, placement, canvas) {
@@ -3083,13 +4602,13 @@ function setSmartPlacement(layers, id, placement, canvas) {
3083
4602
  masksMoved ||= m !== layer.mask;
3084
4603
  next.mask = m;
3085
4604
  }
3086
- if (_optionalChain([next, 'access', _58 => _58.smartFilters, 'optionalAccess', _59 => _59.mask])) {
4605
+ if (_optionalChain([next, 'access', _83 => _83.smartFilters, 'optionalAccess', _84 => _84.mask])) {
3087
4606
  const m = followMask(next.smartFilters.mask, layer, next);
3088
4607
  masksMoved ||= m !== next.smartFilters.mask;
3089
4608
  next.smartFilters = { ...next.smartFilters, mask: m };
3090
4609
  }
3091
4610
  next = rerender(next, canvas, "be transformed");
3092
- return { layers: _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => next), layer: next, masksMoved };
4611
+ return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, masksMoved };
3093
4612
  }
3094
4613
  function offsetSmartObject(layers, id, dx, dy, canvas) {
3095
4614
  const layer = requireSmartObject(layers, id);
@@ -3101,23 +4620,23 @@ function offsetSmartObject(layers, id, dx, dy, canvas) {
3101
4620
  let next = { ...layer, placement: { ...layer.placement, corners } };
3102
4621
  const moveMask = (m2) => m2 && m2.linked !== false && !m2.source ? { ...m2, surface: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, m2.surface, mx, my) } : m2;
3103
4622
  if (layer.mask) next.mask = moveMask(layer.mask);
3104
- if (_optionalChain([layer, 'access', _60 => _60.smartFilters, 'optionalAccess', _61 => _61.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
4623
+ if (_optionalChain([layer, 'access', _85 => _85.smartFilters, 'optionalAccess', _86 => _86.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
3105
4624
  const spatial = activeSmartFilters(layer.smartFilters).some((f) => f.kind === "blur");
3106
4625
  const b = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, layer.surface);
3107
4626
  const m = SMART_RENDER_MARGIN;
3108
4627
  const cut = b && (b.x <= -m || b.y <= -m || b.x + b.width >= canvas.width + m || b.y + b.height >= canvas.height + m);
3109
- if (!spatial && !cut && !(_optionalChain([next, 'access', _62 => _62.smartFilters, 'optionalAccess', _63 => _63.mask]) && activeSmartFilters(next.smartFilters).length && next.smartFilters.mask.linked === false)) {
4628
+ if (!spatial && !cut && !(_optionalChain([next, 'access', _87 => _87.smartFilters, 'optionalAccess', _88 => _88.mask]) && activeSmartFilters(next.smartFilters).length && next.smartFilters.mask.linked === false)) {
3110
4629
  next = { ...next, surface: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, layer.surface, mx, my) };
3111
4630
  } else {
3112
4631
  next = rerender(next, canvas, "move");
3113
4632
  }
3114
- return _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => next);
4633
+ return _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next);
3115
4634
  }
3116
4635
  function translateLayer(layer, dx, dy) {
3117
4636
  if (!dx && !dy) return layer;
3118
4637
  const moveMask = (m) => {
3119
4638
  if (!m) return m;
3120
- if (m.source) fail2(`Layer "${layer.name || layer.id}" has a depth mask, which cannot move into a smart object; bake or remove it first.`);
4639
+ if (m.source) fail3(`Layer "${layer.name || layer.id}" has a depth mask, which cannot move into a smart object; bake or remove it first.`);
3121
4640
  return { ...m, surface: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, m.surface, dx, dy) };
3122
4641
  };
3123
4642
  switch (layer.type) {
@@ -3131,7 +4650,7 @@ function translateLayer(layer, dx, dy) {
3131
4650
  mask: moveMask(layer.mask)
3132
4651
  };
3133
4652
  if (!next.mask) delete next.mask;
3134
- if (_optionalChain([layer, 'access', _64 => _64.smartFilters, 'optionalAccess', _65 => _65.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
4653
+ if (_optionalChain([layer, 'access', _89 => _89.smartFilters, 'optionalAccess', _90 => _90.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
3135
4654
  return next;
3136
4655
  }
3137
4656
  case "group": {
@@ -3144,14 +4663,25 @@ function translateLayer(layer, dx, dy) {
3144
4663
  if (!next.mask) delete next.mask;
3145
4664
  return next;
3146
4665
  }
4666
+ case "shape": {
4667
+ const next = {
4668
+ ...layer,
4669
+ components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), _chunkW3GXSUSQcjs.translateMatrix.call(void 0, dx, dy)),
4670
+ surface: _chunkSZ6KMZNMcjs.translateSurface.call(void 0, layer.surface, dx, dy),
4671
+ mask: moveMask(layer.mask)
4672
+ };
4673
+ if (!next.mask) delete next.mask;
4674
+ delete next.annotation;
4675
+ return next;
4676
+ }
3147
4677
  case "annotation":
3148
- return fail2(`Annotation layer "${layer.name || layer.id}" cannot go into a smart object; rasterize it first.`);
4678
+ return fail3(`Annotation layer "${layer.name || layer.id}" cannot go into a smart object; rasterize it first.`);
3149
4679
  }
3150
4680
  }
3151
4681
  function layerExtent(layer, surfaceOf, canvas) {
3152
4682
  const full = { x: 0, y: 0, width: canvas.width, height: canvas.height };
3153
4683
  let b = null;
3154
- if (layer.type === "pixel" || layer.type === "smart") {
4684
+ if (layer.type === "pixel" || layer.type === "smart" || layer.type === "shape") {
3155
4685
  const s = layer.type === "pixel" ? surfaceOf(layer) : layer.surface;
3156
4686
  if (s.defaultValue !== 0) b = full;
3157
4687
  else {
@@ -3163,7 +4693,7 @@ function layerExtent(layer, surfaceOf, canvas) {
3163
4693
  } else {
3164
4694
  b = full;
3165
4695
  }
3166
- const m = _chunkT3QZ6S47cjs.effectsMargin.call(void 0, layer.effects);
4696
+ const m = _chunkAZTZRLDIcjs.effectsMargin.call(void 0, layer.effects);
3167
4697
  if (b && m > 0) b = { x: b.x - Math.ceil(m), y: b.y - Math.ceil(m), width: b.width + 2 * Math.ceil(m), height: b.height + 2 * Math.ceil(m) };
3168
4698
  return b;
3169
4699
  }
@@ -3175,14 +4705,14 @@ function union(a, b) {
3175
4705
  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 };
3176
4706
  }
3177
4707
  function asSmartFilters(filters) {
3178
- if (!_optionalChain([filters, 'optionalAccess', _66 => _66.length])) return void 0;
4708
+ if (!_optionalChain([filters, 'optionalAccess', _91 => _91.length])) return void 0;
3179
4709
  return { enabled: true, filters: filters.map((f) => ({ ...f, blend: "normal", opacity: 1 })) };
3180
4710
  }
3181
4711
  function convertToSmartObject(layers, ids, canvas, options) {
3182
- if (!ids.length) fail2("Give at least one layer id to convert.");
4712
+ if (!ids.length) fail3("Give at least one layer id to convert.");
3183
4713
  const locs = [...new Set(ids)].map((id) => requireLayer(layers, id));
3184
- const parent = _nullishCoalesce(_optionalChain([locs, 'access', _67 => _67[0], 'access', _68 => _68.parent, 'optionalAccess', _69 => _69.id]), () => ( null));
3185
- if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _70 => _70.parent, 'optionalAccess', _71 => _71.id]), () => ( null))) !== parent)) fail2("Layers to convert must share one parent; move them next to each other first.");
4714
+ const parent = _nullishCoalesce(_optionalChain([locs, 'access', _92 => _92[0], 'access', _93 => _93.parent, 'optionalAccess', _94 => _94.id]), () => ( null));
4715
+ if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _95 => _95.parent, 'optionalAccess', _96 => _96.id]), () => ( null))) !== parent)) fail3("Layers to convert must share one parent; move them next to each other first.");
3186
4716
  for (const l of locs) requireUnlocked(l.layer, "all", "convert it");
3187
4717
  const ordered = locs.sort((a, b) => a.index - b.index);
3188
4718
  const top = ordered[ordered.length - 1];
@@ -3190,9 +4720,9 @@ function convertToSmartObject(layers, ids, canvas, options) {
3190
4720
  const single = ordered.length === 1 ? ordered[0].layer : null;
3191
4721
  if (single && single.type === "pixel") {
3192
4722
  const surface = options.surfaceOf(single);
3193
- if (surface.defaultValue !== 0) fail2(`Layer "${single.name || single.id}" has no transparent area to crop to; it cannot be converted.`);
4723
+ if (surface.defaultValue !== 0) fail3(`Layer "${single.name || single.id}" has no transparent area to crop to; it cannot be converted.`);
3194
4724
  const b = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, surface);
3195
- if (!b) fail2(`Layer "${single.name || single.id}" has no pixels to convert; paint something first.`);
4725
+ if (!b) fail3(`Layer "${single.name || single.id}" has no pixels to convert; paint something first.`);
3196
4726
  const contents = {
3197
4727
  id: newContentsId(),
3198
4728
  name: `${single.name || "Layer"}.png`,
@@ -3224,7 +4754,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
3224
4754
  } else {
3225
4755
  let b = null;
3226
4756
  for (const l of ordered) b = union(b, layerExtent(l.layer, options.surfaceOf, canvas));
3227
- if (!b || !(b.width > 0 && b.height > 0)) fail2("The layers have no pixels to convert; paint something first.");
4757
+ if (!b || !(b.width > 0 && b.height > 0)) fail3("The layers have no pixels to convert; paint something first.");
3228
4758
  const nested = ordered.map((l) => {
3229
4759
  let layer = l.layer;
3230
4760
  if (layer.type === "pixel" && layer.source === "document") {
@@ -3232,7 +4762,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
3232
4762
  delete resolved.source;
3233
4763
  layer = resolved;
3234
4764
  }
3235
- if (_chunkT3QZ6S47cjs.flattenLayers.call(void 0, [layer]).some((x) => x.type === "pixel" && x.source === "document")) fail2(`Layer "${layer.name || layer.id}" holds the document image inside a group; convert the Background on its own.`);
4765
+ if (_chunkAZTZRLDIcjs.flattenLayers.call(void 0, [layer]).some((x) => x.type === "pixel" && x.source === "document")) fail3(`Layer "${layer.name || layer.id}" holds the document image inside a group; convert the Background on its own.`);
3236
4766
  return translateLayer(layer, -b.x, -b.y);
3237
4767
  });
3238
4768
  if (nested[0].clipped) {
@@ -3240,7 +4770,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
3240
4770
  delete first.clipped;
3241
4771
  nested[0] = first;
3242
4772
  }
3243
- const name = _optionalChain([options, 'access', _72 => _72.name, 'optionalAccess', _73 => _73.trim, 'call', _74 => _74()]) || top.layer.name || "Smart Object";
4773
+ const name = _optionalChain([options, 'access', _97 => _97.name, 'optionalAccess', _98 => _98.trim, 'call', _99 => _99()]) || top.layer.name || "Smart Object";
3244
4774
  const contents = documentContents({ layers: nested }, b.width, b.height, `${name}.psb`);
3245
4775
  smart = {
3246
4776
  type: "smart",
@@ -3255,12 +4785,12 @@ function convertToSmartObject(layers, ids, canvas, options) {
3255
4785
  offset: { x: 0, y: 0 }
3256
4786
  };
3257
4787
  }
3258
- if (_optionalChain([options, 'access', _75 => _75.name, 'optionalAccess', _76 => _76.trim, 'call', _77 => _77()])) smart.name = options.name.trim();
4788
+ if (_optionalChain([options, 'access', _100 => _100.name, 'optionalAccess', _101 => _101.trim, 'call', _102 => _102()])) smart.name = options.name.trim();
3259
4789
  smart = { ...smart, surface: renderSmartObject(smart, canvas) };
3260
4790
  const below = ordered.filter((l) => l.index < top.index).length;
3261
4791
  let out = layers;
3262
- for (const l of ordered) out = _chunkT3QZ6S47cjs.mapLayer.call(void 0, out, l.layer.id, () => null);
3263
- return { layers: _chunkT3QZ6S47cjs.insertLayer.call(void 0, out, smart, parent, top.index - below), layer: smart };
4792
+ for (const l of ordered) out = _chunkAZTZRLDIcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
4793
+ return { layers: _chunkAZTZRLDIcjs.insertLayer.call(void 0, out, smart, parent, top.index - below), layer: smart };
3264
4794
  }
3265
4795
  function rasterizeSmartObject(layers, id) {
3266
4796
  const layer = requireSmartObject(layers, id);
@@ -3280,29 +4810,29 @@ function rasterizeSmartObject(layers, id) {
3280
4810
  if (layer.locks) out.locks = layer.locks;
3281
4811
  if (layer.effects) out.effects = layer.effects;
3282
4812
  if (layer.fillOpacity !== void 0) out.fillOpacity = layer.fillOpacity;
3283
- return { layers: _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => out), layer: out };
4813
+ return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => out), layer: out };
3284
4814
  }
3285
4815
  function copySmartObject(layers, id, linked, name) {
3286
4816
  const loc = requireLayer(layers, id);
3287
4817
  const layer = requireSmartObject(layers, id);
3288
- const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess', _78 => _78.trim, 'call', _79 => _79()]) || `${layer.name || "Smart Object"} copy` };
4818
+ const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess', _103 => _103.trim, 'call', _104 => _104()]) || `${layer.name || "Smart Object"} copy` };
3289
4819
  delete copy.locks;
3290
4820
  delete copy.psd;
3291
4821
  if (!linked) copy.contents = { ...layer.contents, id: newContentsId() };
3292
4822
  if (copy.smartFilters) copy.smartFilters = { ...copy.smartFilters, filters: copy.smartFilters.filters.map((f) => ({ ...f, id: newLayerId("flt") })) };
3293
- return { layers: _chunkT3QZ6S47cjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _80 => _80.parent, 'optionalAccess', _81 => _81.id]), () => ( null)), loc.index + 1), layer: copy };
4823
+ return { layers: _chunkAZTZRLDIcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _105 => _105.parent, 'optionalAccess', _106 => _106.id]), () => ( null)), loc.index + 1), layer: copy };
3294
4824
  }
3295
4825
  function instancesOf(layers, contentsId) {
3296
- return _chunkT3QZ6S47cjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
4826
+ return _chunkAZTZRLDIcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
3297
4827
  }
3298
4828
  function replaceContents(layers, contentsId, contents, canvas) {
3299
4829
  const ids = instancesOf(layers, contentsId);
3300
- if (!ids.length) fail2(`No smart object uses contents "${contentsId}".`);
3301
- for (const id of ids) requireUnlocked(_chunkT3QZ6S47cjs.findLayer.call(void 0, layers, id).layer, "all", "replace its contents");
4830
+ if (!ids.length) fail3(`No smart object uses contents "${contentsId}".`);
4831
+ for (const id of ids) requireUnlocked(_chunkAZTZRLDIcjs.findLayer.call(void 0, layers, id).layer, "all", "replace its contents");
3302
4832
  const next = { ...contents, id: contentsId };
3303
4833
  let out = layers;
3304
4834
  for (const id of ids) {
3305
- out = _chunkT3QZ6S47cjs.mapLayer.call(void 0, out, id, (l) => {
4835
+ out = _chunkAZTZRLDIcjs.mapLayer.call(void 0, out, id, (l) => {
3306
4836
  const layer = l;
3307
4837
  return rerender({ ...layer, contents: next, placement: refitPlacement(layer, next) }, canvas, "take the new contents");
3308
4838
  });
@@ -3326,16 +4856,16 @@ function refitPlacement(layer, contents) {
3326
4856
  });
3327
4857
  const out = { corners: pts };
3328
4858
  if (layer.placement.interpolation) out.interpolation = layer.placement.interpolation;
3329
- if (layer.placement.warp) out.warp = _chunkDWGZUSEScjs.mapWarpMeshPoints.call(void 0, layer.placement.warp, (p) => ({ x: p.x * W1 / W0, y: p.y * H1 / H0 }));
4859
+ if (layer.placement.warp) out.warp = _chunkW3GXSUSQcjs.mapWarpMeshPoints.call(void 0, layer.placement.warp, (p) => ({ x: p.x * W1 / W0, y: p.y * H1 / H0 }));
3330
4860
  return out;
3331
4861
  }
3332
4862
  function normalizeSmartFilter(raw, id = newLayerId("flt")) {
3333
- if (raw.kind === "psd") fail2("Photoshop filters can only come from a PSD; add develop or blur.");
4863
+ if (raw.kind === "psd") fail3("Photoshop filters can only come from a PSD; add develop or blur.");
3334
4864
  const base = normalizeFilter(raw, id);
3335
4865
  const blend = _nullishCoalesce(raw.blend, () => ( "normal"));
3336
- if (!_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail2(`Unknown blend mode "${String(blend)}" for a smart filter.`);
4866
+ if (!_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail3(`Unknown blend mode "${String(blend)}" for a smart filter.`);
3337
4867
  const opacity = _nullishCoalesce(raw.opacity, () => ( 1));
3338
- if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail2("opacity must be a number from 0 to 1.");
4868
+ if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail3("opacity must be a number from 0 to 1.");
3339
4869
  return { ...base, blend, opacity };
3340
4870
  }
3341
4871
  function withStack(layer, stack, canvas) {
@@ -3348,9 +4878,9 @@ function stackOf(layer) {
3348
4878
  return _nullishCoalesce(layer.smartFilters, () => ( { enabled: true, filters: [] }));
3349
4879
  }
3350
4880
  function requireFilter(layer, filterId) {
3351
- const list2 = _nullishCoalesce(_optionalChain([layer, 'access', _82 => _82.smartFilters, 'optionalAccess', _83 => _83.filters]), () => ( []));
4881
+ const list2 = _nullishCoalesce(_optionalChain([layer, 'access', _107 => _107.smartFilters, 'optionalAccess', _108 => _108.filters]), () => ( []));
3352
4882
  const i = list2.findIndex((f) => f.id === filterId);
3353
- if (i === -1) fail2(`Smart object "${layer.name || layer.id}" has no smart filter "${filterId}". Filters: ${list2.map((f) => `${f.id} (${f.kind})`).join(", ") || "none"}; call get_smart_object.`);
4883
+ if (i === -1) fail3(`Smart object "${layer.name || layer.id}" has no smart filter "${filterId}". Filters: ${list2.map((f) => `${f.id} (${f.kind})`).join(", ") || "none"}; call get_smart_object.`);
3354
4884
  return i;
3355
4885
  }
3356
4886
  function editableSmart(layers, id) {
@@ -3365,21 +4895,21 @@ function addSmartFilter(layers, id, filter, canvas, index) {
3365
4895
  const at = index === void 0 ? filters.length : Math.max(0, Math.min(filters.length, Math.floor(index)));
3366
4896
  filters.splice(at, 0, filter);
3367
4897
  const next = withStack(layer, { ...stack, filters }, canvas);
3368
- return { layers: _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter };
4898
+ return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter };
3369
4899
  }
3370
4900
  function updateSmartFilter(layers, id, filterId, changes, canvas) {
3371
4901
  const layer = editableSmart(layers, id);
3372
4902
  const i = requireFilter(layer, filterId);
3373
4903
  const current = layer.smartFilters.filters[i];
3374
- if ("kind" in changes && changes.kind !== current.kind) fail2("A smart filter kind cannot change; remove it and add another.");
4904
+ if ("kind" in changes && changes.kind !== current.kind) fail3("A smart filter kind cannot change; remove it and add another.");
3375
4905
  let merged;
3376
4906
  if (current.kind === "psd") {
3377
4907
  const extra = Object.keys(changes).filter((k) => !["enabled", "blend", "opacity", "kind"].includes(k));
3378
- if (extra.length) fail2(`"${current.name}" is a Photoshop filter we keep but do not model; only enabled, blend and opacity change. Unknown: ${extra.join(", ")}.`);
4908
+ if (extra.length) fail3(`"${current.name}" is a Photoshop filter we keep but do not model; only enabled, blend and opacity change. Unknown: ${extra.join(", ")}.`);
3379
4909
  const blend = _nullishCoalesce(changes.blend, () => ( current.blend));
3380
- if (!_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail2(`Unknown blend mode "${String(blend)}" for a smart filter.`);
4910
+ if (!_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail3(`Unknown blend mode "${String(blend)}" for a smart filter.`);
3381
4911
  const opacity = _nullishCoalesce(changes.opacity, () => ( current.opacity));
3382
- if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail2("opacity must be a number from 0 to 1.");
4912
+ if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail3("opacity must be a number from 0 to 1.");
3383
4913
  merged = { ...current, enabled: changes.enabled === void 0 ? current.enabled : Boolean(changes.enabled), blend, opacity };
3384
4914
  } else {
3385
4915
  merged = normalizeSmartFilter({ ...current, ...changes, kind: current.kind }, current.id);
@@ -3387,7 +4917,7 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
3387
4917
  const filters = [...layer.smartFilters.filters];
3388
4918
  filters[i] = merged;
3389
4919
  const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
3390
- return { layers: _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter: merged };
4920
+ return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter: merged };
3391
4921
  }
3392
4922
  function removeSmartFilter(layers, id, filterId, canvas) {
3393
4923
  const layer = editableSmart(layers, id);
@@ -3395,72 +4925,46 @@ function removeSmartFilter(layers, id, filterId, canvas) {
3395
4925
  const stack = layer.smartFilters;
3396
4926
  const filters = stack.filters.filter((f) => f.id !== filterId);
3397
4927
  const next = withStack(layer, filters.length ? { ...stack, filters } : stack.enabled ? void 0 : { enabled: false, filters }, canvas);
3398
- return { layers: _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
4928
+ return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
3399
4929
  }
3400
4930
  function moveSmartFilter(layers, id, filterId, index, canvas) {
3401
4931
  const layer = editableSmart(layers, id);
3402
4932
  const i = requireFilter(layer, filterId);
3403
4933
  const list2 = layer.smartFilters.filters;
3404
- if (!Number.isInteger(index) || index < 0 || index >= list2.length) fail2(`index must be a whole number from 0 to ${list2.length - 1}.`);
4934
+ if (!Number.isInteger(index) || index < 0 || index >= list2.length) fail3(`index must be a whole number from 0 to ${list2.length - 1}.`);
3405
4935
  const filters = [...list2];
3406
4936
  const [f] = filters.splice(i, 1);
3407
4937
  filters.splice(index, 0, f);
3408
4938
  const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
3409
- return { layers: _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
4939
+ return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
3410
4940
  }
3411
4941
  function setSmartFiltersEnabled(layers, id, enabled, canvas) {
3412
4942
  const layer = editableSmart(layers, id);
3413
4943
  const next = withStack(layer, { ...stackOf(layer), enabled: Boolean(enabled) }, canvas);
3414
- return { layers: _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
4944
+ return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
3415
4945
  }
3416
4946
  function setSmartFilterMask(layers, id, mask, canvas) {
3417
4947
  const layer = editableSmart(layers, id);
3418
- if (_optionalChain([mask, 'optionalAccess', _84 => _84.source])) fail2("A smart filter mask is painted, not generated; use a raster mask.");
4948
+ if (_optionalChain([mask, 'optionalAccess', _109 => _109.source])) fail3("A smart filter mask is painted, not generated; use a raster mask.");
3419
4949
  const stack = { ...stackOf(layer) };
3420
4950
  if (mask) stack.mask = mask;
3421
4951
  else delete stack.mask;
3422
4952
  const next = withStack(layer, stack, canvas);
3423
- return { layers: _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
4953
+ return { layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
3424
4954
  }
3425
4955
  function withFilterMaskSurface(layer, surface, canvas) {
3426
4956
  const stack = stackOf(layer);
3427
- if (!stack.mask) fail2(`Smart object "${layer.name || layer.id}" has no filter mask; add one with set_smart_filter_mask.`);
4957
+ if (!stack.mask) fail3(`Smart object "${layer.name || layer.id}" has no filter mask; add one with set_smart_filter_mask.`);
3428
4958
  return withStack(layer, { ...stack, mask: { ...stack.mask, surface } }, canvas);
3429
4959
  }
3430
4960
  function placementBounds(layer) {
3431
4961
  return transformedBox(placementGeometry(layer));
3432
4962
  }
3433
4963
 
3434
- // src/image-editor/layers/defaults.ts
3435
- var DEFAULT_ADJUSTMENTS_VALUES = {
3436
- brightness: 0,
3437
- contrast: 0,
3438
- saturation: 0,
3439
- exposure: 0,
3440
- temperature: 0,
3441
- tint: 0,
3442
- blur: 0,
3443
- opacity: 1,
3444
- process: LATEST_PROCESS_VERSION
3445
- };
3446
- var DEFAULT_TRANSFORM_VALUES = {
3447
- rotate: 0,
3448
- flipH: false,
3449
- flipV: false
3450
- };
3451
- var DEFAULT_DEPTH_MASK_VALUES = {
3452
- enabled: false,
3453
- maskSource: null,
3454
- mode: "threshold",
3455
- depthRange: [0, 255],
3456
- softness: 10,
3457
- invert: false
3458
- };
3459
-
3460
4964
  // src/image-editor/layers/serialize.ts
3461
4965
  var LAYERED_SCHEMA_VERSION = 3;
3462
4966
  function serializePatterns(patterns) {
3463
- return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkT3QZ6S47cjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
4967
+ return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkAZTZRLDIcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
3464
4968
  }
3465
4969
  function deserializePatterns(raw, problems = []) {
3466
4970
  if (!Array.isArray(raw)) return [];
@@ -3483,7 +4987,7 @@ function encodeSurface(surface) {
3483
4987
  let out = null;
3484
4988
  if (b) {
3485
4989
  const data = _chunkSZ6KMZNMcjs.readRegion.call(void 0, surface, b);
3486
- out = { url: _chunkT3QZ6S47cjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
4990
+ out = { url: _chunkAZTZRLDIcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
3487
4991
  }
3488
4992
  encodedCache.set(surface, out);
3489
4993
  return out;
@@ -3505,7 +5009,7 @@ function baseFields(layer, ctx) {
3505
5009
  function serializeEffects(effects) {
3506
5010
  const out = { enabled: effects.enabled, items: JSON.parse(JSON.stringify(effects.items)) };
3507
5011
  if (effects.scale !== void 0 && effects.scale !== 1) out.scale = effects.scale;
3508
- if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkT3QZ6S47cjs.bytesToBase64.call(void 0, effects.psd.data) };
5012
+ if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, effects.psd.data) };
3509
5013
  return out;
3510
5014
  }
3511
5015
  function deserializeEffects(raw) {
@@ -3515,12 +5019,12 @@ function deserializeEffects(raw) {
3515
5019
  const p = r.psd;
3516
5020
  if (p && typeof p.key === "string" && typeof p.data === "string") {
3517
5021
  try {
3518
- psd = { key: p.key, data: _chunkT3QZ6S47cjs.base64ToBytes.call(void 0, p.data) };
3519
- } catch (e3) {
5022
+ psd = { key: p.key, data: _chunkAZTZRLDIcjs.base64ToBytes.call(void 0, p.data) };
5023
+ } catch (e6) {
3520
5024
  psd = void 0;
3521
5025
  }
3522
5026
  }
3523
- return _chunkT3QZ6S47cjs.normalizeLayerEffects.call(void 0, { ...r, psd });
5027
+ return _chunkAZTZRLDIcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
3524
5028
  }
3525
5029
  function serializeMask(mask, hint, ctx) {
3526
5030
  const out = { defaultValue: mask.defaultValue };
@@ -3555,7 +5059,7 @@ function serializeLayer(layer, ctx) {
3555
5059
  }
3556
5060
  }
3557
5061
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
3558
- if (_optionalChain([layer, 'access', _85 => _85.filters, 'optionalAccess', _86 => _86.length])) out.filters = JSON.parse(JSON.stringify(layer.filters));
5062
+ if (_optionalChain([layer, 'access', _110 => _110.filters, 'optionalAccess', _111 => _111.length])) out.filters = JSON.parse(JSON.stringify(layer.filters));
3559
5063
  return out;
3560
5064
  }
3561
5065
  case "adjustment":
@@ -3569,12 +5073,66 @@ function serializeLayer(layer, ctx) {
3569
5073
  return { ...base, type: "annotation", annotation: JSON.parse(JSON.stringify(layer.annotation)) };
3570
5074
  case "smart":
3571
5075
  return serializeSmartObject(layer, base, ctx);
5076
+ case "shape":
5077
+ return serializeShape(layer, base);
5078
+ }
5079
+ }
5080
+ function serializeShape(layer, base) {
5081
+ const out = {
5082
+ ...base,
5083
+ type: "shape",
5084
+ components: JSON.parse(JSON.stringify(layer.components)),
5085
+ fill: layer.fill ? JSON.parse(JSON.stringify(layer.fill)) : null,
5086
+ stroke: layer.stroke ? JSON.parse(JSON.stringify(layer.stroke)) : null
5087
+ };
5088
+ if (layer.fillRule === "evenodd") out.fillRule = "evenodd";
5089
+ if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5090
+ if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
5091
+ if (_optionalChain([layer, 'access', _112 => _112.psd, 'optionalAccess', _113 => _113.blocks, 'optionalAccess', _114 => _114.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, b.data) })) };
5092
+ return out;
5093
+ }
5094
+ function readShape(r, base, ctx) {
5095
+ const label = `Layer "${base.name || base.id}"`;
5096
+ const canvas = _nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 }));
5097
+ const env = { ...canvas, pattern: ctx.pattern };
5098
+ try {
5099
+ let data = null;
5100
+ const a = r.annotation && typeof r.annotation === "object" && typeof r.annotation.type === "string" ? JSON.parse(JSON.stringify({ ...r.annotation, id: _nullishCoalesce(r.annotation.id, () => ( base.id)) })) : void 0;
5101
+ if (a) data = shapeFromAnnotation(a);
5102
+ if (!data) {
5103
+ if (!Array.isArray(r.components) || !r.components.length) throw new Error("it has no components");
5104
+ const components = r.components.map((c, i) => {
5105
+ const op = requireOperation(_optionalChain([c, 'optionalAccess', _115 => _115.op]), `components[${i}].op`);
5106
+ if (_optionalChain([c, 'optionalAccess', _116 => _116.live])) {
5107
+ const live = normalizeLiveShape(c.live, `components[${i}].live`);
5108
+ return { op, subpaths: liveShapeSubpaths(live), live };
5109
+ }
5110
+ return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _117 => _117.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _118 => _118.subpaths]), `components[${i}].subpaths`) };
5111
+ });
5112
+ data = {
5113
+ components,
5114
+ fill: r.fill === null || r.fill === void 0 ? null : normalizeShapePaint(r.fill, "fill"),
5115
+ stroke: r.stroke === null || r.stroke === void 0 ? null : normalizeShapeStroke(r.stroke, "stroke")
5116
+ };
5117
+ }
5118
+ const layer = createShapeLayer({ ...data, fillRule: r.fillRule === "evenodd" ? "evenodd" : "nonzero" }, env, base.id);
5119
+ const out = { ...layer, ...base, type: "shape", components: layer.components, fill: layer.fill, stroke: layer.stroke, surface: layer.surface, offset: { x: 0, y: 0 } };
5120
+ if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) out.fillOpacity = num(r.fillOpacity, 0, 1, 1);
5121
+ if (a && shapeFromAnnotation(a)) out.annotation = a;
5122
+ if (r.psd && Array.isArray(r.psd.blocks)) {
5123
+ const blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkAZTZRLDIcjs.base64ToBytes.call(void 0, b.data) }));
5124
+ if (blocks.length) out.psd = { blocks };
5125
+ }
5126
+ return out;
5127
+ } catch (e) {
5128
+ ctx.problems.push(`${label}: the shape could not be read (${e instanceof Error ? e.message : String(e)})`);
5129
+ return null;
3572
5130
  }
3573
5131
  }
3574
5132
  function serializeSmartFilters(stack, layerId, ctx) {
3575
5133
  const out = {
3576
5134
  enabled: stack.enabled,
3577
- filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data: _chunkT3QZ6S47cjs.bytesToBase64.call(void 0, f.data) } : JSON.parse(JSON.stringify(f)))
5135
+ filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, f.data) } : JSON.parse(JSON.stringify(f)))
3578
5136
  };
3579
5137
  if (stack.mask) out.mask = serializeMask(stack.mask, `${layerId}-filter-mask`, ctx);
3580
5138
  return out;
@@ -3600,7 +5158,7 @@ function serializeSmartObject(layer, base, ctx) {
3600
5158
  }
3601
5159
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
3602
5160
  if (layer.psd) {
3603
- out.psd = { key: layer.psd.key, data: _chunkT3QZ6S47cjs.bytesToBase64.call(void 0, layer.psd.data) };
5161
+ out.psd = { key: layer.psd.key, data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, layer.psd.data) };
3604
5162
  if (layer.psd.placed) out.psd.placed = layer.psd.placed;
3605
5163
  }
3606
5164
  return out;
@@ -3612,16 +5170,16 @@ function serializeContents(c, ctx) {
3612
5170
  if (enc) {
3613
5171
  if (enc.x !== 0 || enc.y !== 0) {
3614
5172
  const data = _chunkSZ6KMZNMcjs.readRegion.call(void 0, c.raster, { x: 0, y: 0, width: c.width, height: c.height });
3615
- out.asset = ctx.addAsset(_chunkT3QZ6S47cjs.pngDataUrl.call(void 0, c.width, c.height, data, 4), `contents-${c.id}`);
5173
+ out.asset = ctx.addAsset(_chunkAZTZRLDIcjs.pngDataUrl.call(void 0, c.width, c.height, data, 4), `contents-${c.id}`);
3616
5174
  } else out.asset = ctx.addAsset(enc.url, `contents-${c.id}`);
3617
5175
  }
3618
5176
  }
3619
5177
  if (c.kind === "document" && c.document) {
3620
5178
  out.layers = c.document.layers.map((l) => serializeLayer(l, ctx));
3621
5179
  if (c.document.globalLight) out.globalLight = { ...c.document.globalLight };
3622
- if (_optionalChain([c, 'access', _87 => _87.document, 'access', _88 => _88.patterns, 'optionalAccess', _89 => _89.length])) out.patterns = serializePatterns(c.document.patterns);
5180
+ if (_optionalChain([c, 'access', _119 => _119.document, 'access', _120 => _120.patterns, 'optionalAccess', _121 => _121.length])) out.patterns = serializePatterns(c.document.patterns);
3623
5181
  }
3624
- if (c.file) out.file = { type: c.file.type, data: _chunkT3QZ6S47cjs.bytesToBase64.call(void 0, c.file.bytes) };
5182
+ if (c.file) out.file = { type: c.file.type, data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, c.file.bytes) };
3625
5183
  if (c.linked) out.linked = { path: c.linked.path };
3626
5184
  return out;
3627
5185
  }
@@ -3657,7 +5215,7 @@ async function serializeLayersExternal(layers, store) {
3657
5215
  for (const [id, url] of Object.entries(inline.assets)) {
3658
5216
  let ref = refs.get(url);
3659
5217
  if (!ref) {
3660
- const parsed = _chunkT3QZ6S47cjs.parseDataUrl.call(void 0, url);
5218
+ const parsed = _chunkAZTZRLDIcjs.parseDataUrl.call(void 0, url);
3661
5219
  const png = decodePngHeader(parsed.bytes);
3662
5220
  ref = await store.put(new Blob([parsed.bytes], { type: "image/png" }), { id, width: png.width, height: png.height });
3663
5221
  if (typeof ref !== "string" || !ref) throw new Error(`The asset store returned no reference for "${id}".`);
@@ -3685,7 +5243,7 @@ async function resolveExternalAssets(assets, store, problems) {
3685
5243
  try {
3686
5244
  const blob = await store.get(ref);
3687
5245
  const bytes = new Uint8Array(await blob.arrayBuffer());
3688
- out[id] = `data:image/png;base64,${_chunkT3QZ6S47cjs.bytesToBase64.call(void 0, bytes)}`;
5246
+ out[id] = `data:image/png;base64,${_chunkAZTZRLDIcjs.bytesToBase64.call(void 0, bytes)}`;
3689
5247
  } catch (err) {
3690
5248
  problems.push(`Asset "${id}" (${ref}) could not be fetched: ${err.message}`);
3691
5249
  }
@@ -3693,9 +5251,9 @@ async function resolveExternalAssets(assets, store, problems) {
3693
5251
  return out;
3694
5252
  }
3695
5253
  function decodePngDataUrl(url, channels) {
3696
- const parsed = _chunkT3QZ6S47cjs.parseDataUrl.call(void 0, url);
5254
+ const parsed = _chunkAZTZRLDIcjs.parseDataUrl.call(void 0, url);
3697
5255
  if (!parsed) throw new Error("Asset is not a data URL.");
3698
- const png = _chunkT3QZ6S47cjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
5256
+ const png = _chunkAZTZRLDIcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
3699
5257
  if (png.channels === channels) return png;
3700
5258
  if (channels === 1) {
3701
5259
  const out2 = new Uint8ClampedArray(png.width * png.height);
@@ -3798,7 +5356,7 @@ function deserializeLayer(raw, ctx) {
3798
5356
  ...base,
3799
5357
  type: "pixel",
3800
5358
  surface: r.source === "document" ? _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4) : readSurface(r.asset, r.x, r.y, 4, 0, ctx, `Layer "${base.name || id}"`),
3801
- offset: { x: Math.round(num(_optionalChain([r, 'access', _90 => _90.offset, 'optionalAccess', _91 => _91.x]), -1e7, 1e7, 0)), y: Math.round(num(_optionalChain([r, 'access', _92 => _92.offset, 'optionalAccess', _93 => _93.y]), -1e7, 1e7, 0)) }
5359
+ offset: { x: Math.round(num(_optionalChain([r, 'access', _122 => _122.offset, 'optionalAccess', _123 => _123.x]), -1e7, 1e7, 0)), y: Math.round(num(_optionalChain([r, 'access', _124 => _124.offset, 'optionalAccess', _125 => _125.y]), -1e7, 1e7, 0)) }
3802
5360
  };
3803
5361
  if (r.source === "document") layer.source = "document";
3804
5362
  if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num(r.fillOpacity, 0, 1, 1);
@@ -3827,8 +5385,16 @@ function deserializeLayer(raw, ctx) {
3827
5385
  ctx.problems.push(`Layer "${base.name || id}": annotation is missing`);
3828
5386
  return null;
3829
5387
  }
3830
- return { ...base, type: "annotation", annotation: JSON.parse(JSON.stringify({ ...a, id: typeof a.id === "string" ? a.id : id })) };
5388
+ const annotation = JSON.parse(JSON.stringify({ ...a, id: typeof a.id === "string" ? a.id : id }));
5389
+ const migrated = annotationLayerFor(annotation, _nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })));
5390
+ if (migrated.type === "shape") {
5391
+ const blend = base.blend === "normal" ? migrated.blend : base.blend;
5392
+ return { ...migrated, ...base, blend, type: "shape", id, name: base.name };
5393
+ }
5394
+ return { ...base, type: "annotation", annotation };
3831
5395
  }
5396
+ case "shape":
5397
+ return readShape(r, base, ctx);
3832
5398
  case "smart":
3833
5399
  return readSmartObject(r, base, ctx);
3834
5400
  default:
@@ -3858,8 +5424,8 @@ function readContents(id, ctx) {
3858
5424
  const c = { id, name: typeof raw.name === "string" ? raw.name : "Contents", width, height, kind: raw.kind === "document" ? "document" : "raster" };
3859
5425
  if (raw.file && typeof raw.file.type === "string" && typeof raw.file.data === "string") {
3860
5426
  try {
3861
- c.file = { type: raw.file.type, bytes: _chunkT3QZ6S47cjs.base64ToBytes.call(void 0, raw.file.data) };
3862
- } catch (e4) {
5427
+ c.file = { type: raw.file.type, bytes: _chunkAZTZRLDIcjs.base64ToBytes.call(void 0, raw.file.data) };
5428
+ } catch (e7) {
3863
5429
  ctx.problems.push(`Smart object contents "${c.name}": the embedded file could not be read`);
3864
5430
  }
3865
5431
  }
@@ -3893,8 +5459,8 @@ function readSmartFilters(raw, ctx, what) {
3893
5459
  const opacity = num(f.opacity, 0, 1, 1);
3894
5460
  if (f.kind === "psd") {
3895
5461
  try {
3896
- filters.push({ id: typeof f.id === "string" ? f.id : newLayerId("flt"), kind: "psd", enabled: f.enabled !== false, name: typeof f.name === "string" ? f.name : "Filter", data: _chunkT3QZ6S47cjs.base64ToBytes.call(void 0, String(_nullishCoalesce(f.data, () => ( "")))), blend, opacity });
3897
- } catch (e5) {
5462
+ filters.push({ id: typeof f.id === "string" ? f.id : newLayerId("flt"), kind: "psd", enabled: f.enabled !== false, name: typeof f.name === "string" ? f.name : "Filter", data: _chunkAZTZRLDIcjs.base64ToBytes.call(void 0, String(_nullishCoalesce(f.data, () => ( "")))), blend, opacity });
5463
+ } catch (e8) {
3898
5464
  ctx.problems.push(`${what}: a Photoshop smart filter could not be read`);
3899
5465
  }
3900
5466
  } else if (f.kind === "develop" || f.kind === "blur") {
@@ -3918,8 +5484,8 @@ function readSmartObject(r, base, ctx) {
3918
5484
  let placement;
3919
5485
  try {
3920
5486
  const raw = { corners: p.corners };
3921
- if (p.warp && _chunkDWGZUSEScjs.isValidWarpMesh.call(void 0, p.warp)) raw.warp = p.warp;
3922
- if (_chunkT3QZ6S47cjs.isInterpolation.call(void 0, p.interpolation)) raw.interpolation = p.interpolation;
5487
+ if (p.warp && _chunkW3GXSUSQcjs.isValidWarpMesh.call(void 0, p.warp)) raw.warp = p.warp;
5488
+ if (_chunkAZTZRLDIcjs.isInterpolation.call(void 0, p.interpolation)) raw.interpolation = p.interpolation;
3923
5489
  placement = normalizePlacement(raw, contents);
3924
5490
  } catch (e) {
3925
5491
  ctx.problems.push(`${what}: its placement is invalid (${e instanceof Error ? e.message : String(e)}); it was placed at the top left`);
@@ -3931,9 +5497,9 @@ function readSmartObject(r, base, ctx) {
3931
5497
  if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num(r.fillOpacity, 0, 1, 1);
3932
5498
  if (r.psd && typeof r.psd.key === "string" && typeof r.psd.data === "string") {
3933
5499
  try {
3934
- layer.psd = { key: r.psd.key, data: _chunkT3QZ6S47cjs.base64ToBytes.call(void 0, r.psd.data) };
5500
+ layer.psd = { key: r.psd.key, data: _chunkAZTZRLDIcjs.base64ToBytes.call(void 0, r.psd.data) };
3935
5501
  if (typeof r.psd.placed === "string") layer.psd.placed = r.psd.placed;
3936
- } catch (e6) {
5502
+ } catch (e9) {
3937
5503
  }
3938
5504
  }
3939
5505
  if (typeof r.asset === "string") layer.surface = readSurface(r.asset, r.x, r.y, 4, 0, ctx, what);
@@ -4176,7 +5742,7 @@ var PsdWriter = (_class = class {constructor() { _class.prototype.__init.call(th
4176
5742
  function decodeLegacyName(b) {
4177
5743
  try {
4178
5744
  return new TextDecoder("utf-8", { fatal: true }).decode(b);
4179
- } catch (e7) {
5745
+ } catch (e10) {
4180
5746
  return String.fromCharCode(...b);
4181
5747
  }
4182
5748
  }
@@ -4255,9 +5821,9 @@ function packbitsDecodeInto(src, expected, out, at) {
4255
5821
  function inflateChecked(data, expected) {
4256
5822
  let out;
4257
5823
  try {
4258
- out = _chunkT3QZ6S47cjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
5824
+ out = _chunkAZTZRLDIcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
4259
5825
  } catch (e) {
4260
- throw new PsdError(`ZIP channel data: ${e instanceof _chunkT3QZ6S47cjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
5826
+ throw new PsdError(`ZIP channel data: ${e instanceof _chunkAZTZRLDIcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
4261
5827
  }
4262
5828
  if (out.length < expected) throw new PsdError(`ZIP stream produced ${out.length} of ${expected} bytes.`);
4263
5829
  return out.length === expected ? out : out.subarray(0, expected);
@@ -4353,7 +5919,7 @@ function descriptor(classId, items = []) {
4353
5919
  return { name: "", classId, items };
4354
5920
  }
4355
5921
  function descGet(d, key) {
4356
- return _optionalChain([d, 'access', _94 => _94.items, 'access', _95 => _95.find, 'call', _96 => _96(([k]) => k === key), 'optionalAccess', _97 => _97[1]]);
5922
+ return _optionalChain([d, 'access', _126 => _126.items, 'access', _127 => _127.find, 'call', _128 => _128(([k]) => k === key), 'optionalAccess', _129 => _129[1]]);
4357
5923
  }
4358
5924
  function descNumber(d, key) {
4359
5925
  const v = descGet(d, key);
@@ -4363,7 +5929,7 @@ function descNumber(d, key) {
4363
5929
  }
4364
5930
  function descBool(d, key) {
4365
5931
  const v = descGet(d, key);
4366
- return _optionalChain([v, 'optionalAccess', _98 => _98.type]) === "bool" ? v.value : void 0;
5932
+ return _optionalChain([v, 'optionalAccess', _130 => _130.type]) === "bool" ? v.value : void 0;
4367
5933
  }
4368
5934
  function descObject(d, key) {
4369
5935
  const v = descGet(d, key);
@@ -4834,7 +6400,7 @@ function parseAdjustmentBlock(key, data) {
4834
6400
  default:
4835
6401
  return null;
4836
6402
  }
4837
- } catch (e8) {
6403
+ } catch (e11) {
4838
6404
  return null;
4839
6405
  }
4840
6406
  }
@@ -4955,15 +6521,15 @@ var textV = (value) => ({ type: "TEXT", value });
4955
6521
  var obj = (d) => ({ type: "Objc", value: d });
4956
6522
  var text = (d, key) => {
4957
6523
  const v = descGet(d, key);
4958
- return _optionalChain([v, 'optionalAccess', _99 => _99.type]) === "TEXT" ? v.value : void 0;
6524
+ return _optionalChain([v, 'optionalAccess', _131 => _131.type]) === "TEXT" ? v.value : void 0;
4959
6525
  };
4960
6526
  var enumOf = (d, key) => {
4961
6527
  const v = descGet(d, key);
4962
- return _optionalChain([v, 'optionalAccess', _100 => _100.type]) === "enum" ? v.value : void 0;
6528
+ return _optionalChain([v, 'optionalAccess', _132 => _132.type]) === "enum" ? v.value : void 0;
4963
6529
  };
4964
6530
  var numbers = (d, key) => {
4965
6531
  const v = descGet(d, key);
4966
- if (_optionalChain([v, 'optionalAccess', _101 => _101.type]) !== "VlLs") return null;
6532
+ if (_optionalChain([v, 'optionalAccess', _133 => _133.type]) !== "VlLs") return null;
4967
6533
  const out = [];
4968
6534
  for (const it of v.items) {
4969
6535
  if (it.type === "doub" || it.type === "UntF" || it.type === "long") out.push(it.value);
@@ -5007,7 +6573,7 @@ function readLinkedItem(item) {
5007
6573
  try {
5008
6574
  const d = readVersionedDescriptor(r);
5009
6575
  path = _nullishCoalesce(_nullishCoalesce(text(d, "fullPath"), () => ( text(d, "originalPath"))), () => ( text(d, "relPath")));
5010
- } catch (e9) {
6576
+ } catch (e12) {
5011
6577
  path = void 0;
5012
6578
  }
5013
6579
  void version;
@@ -5024,7 +6590,7 @@ function parseLinkedFiles(data) {
5024
6590
  try {
5025
6591
  const item = readLinkedItem(data.subarray(at + 8, at + 8 + len));
5026
6592
  if (item) out.push(item);
5027
- } catch (e10) {
6593
+ } catch (e13) {
5028
6594
  }
5029
6595
  at = at + 8 + len + 3 & ~3;
5030
6596
  }
@@ -5158,8 +6724,8 @@ function filterMaskItem(placed, mask, area) {
5158
6724
  const painted = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, mask.surface);
5159
6725
  let b = _nullishCoalesce(painted, () => ( { x: 0, y: 0, width: 1, height: 1 }));
5160
6726
  if (mask.defaultValue !== 255 && area) {
5161
- const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _102 => _102.x]), () => ( area.x)));
5162
- const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _103 => _103.y]), () => ( area.y)));
6727
+ const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _134 => _134.x]), () => ( area.x)));
6728
+ const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _135 => _135.y]), () => ( area.y)));
5163
6729
  const x1 = Math.max(area.x + area.width, painted ? painted.x + painted.width : 0);
5164
6730
  const y1 = Math.max(area.y + area.height, painted ? painted.y + painted.height : 0);
5165
6731
  b = { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
@@ -5179,8 +6745,8 @@ function filterMaskItem(placed, mask, area) {
5179
6745
  }
5180
6746
  var warpStyleOf = (name) => {
5181
6747
  if (!name.startsWith("warp")) return null;
5182
- const s = _optionalChain([name, 'access', _104 => _104[4], 'optionalAccess', _105 => _105.toLowerCase, 'call', _106 => _106()]) + name.slice(5);
5183
- return _chunkDWGZUSEScjs.WARP_STYLES.includes(s) ? s : null;
6748
+ const s = _optionalChain([name, 'access', _136 => _136[4], 'optionalAccess', _137 => _137.toLowerCase, 'call', _138 => _138()]) + name.slice(5);
6749
+ return _chunkW3GXSUSQcjs.WARP_STYLES.includes(s) ? s : null;
5184
6750
  };
5185
6751
  function warpFromDescriptor(w, contents) {
5186
6752
  const full = { x: 0, y: 0, width: contents.width, height: contents.height };
@@ -5201,7 +6767,7 @@ function warpFromDescriptor(w, contents) {
5201
6767
  if (!arr || arr.type !== "ObAr") return void 0;
5202
6768
  const xs = descGet(arr.body, "Hrzn");
5203
6769
  const ys = descGet(arr.body, "Vrtc");
5204
- if (_optionalChain([xs, 'optionalAccess', _107 => _107.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _108 => _108.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
6770
+ if (_optionalChain([xs, 'optionalAccess', _139 => _139.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _140 => _140.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
5205
6771
  mesh = { us: [0, 1], vs: [0, 1], points: xs.values.map((x, i) => ({ x, y: ys.values[i] })) };
5206
6772
  const px = mesh.points.map((p) => p.x);
5207
6773
  const py = mesh.points.map((p) => p.y);
@@ -5210,7 +6776,7 @@ function warpFromDescriptor(w, contents) {
5210
6776
  } else {
5211
6777
  const style = warpStyleOf(styleName);
5212
6778
  if (!style) return void 0;
5213
- mesh = _chunkDWGZUSEScjs.warpPresetMesh.call(void 0,
6779
+ mesh = _chunkW3GXSUSQcjs.warpPresetMesh.call(void 0,
5214
6780
  {
5215
6781
  style,
5216
6782
  bend: _nullishCoalesce(descNumber(w, "warpValue"), () => ( 0)),
@@ -5225,7 +6791,7 @@ function warpFromDescriptor(w, contents) {
5225
6791
  const same = Math.abs(bounds.x) < 1e-6 && Math.abs(bounds.y) < 1e-6 && Math.abs(bounds.width - contents.width) < 1e-6 && Math.abs(bounds.height - contents.height) < 1e-6;
5226
6792
  if (!same) {
5227
6793
  const m = mesh;
5228
- mesh = _chunkDWGZUSEScjs.fitWarpMesh.call(void 0, (s, t) => _chunkDWGZUSEScjs.evalWarpMesh.call(void 0, m, (s * contents.width - bounds.x) / bounds.width, (t * contents.height - bounds.y) / bounds.height), [0, 1], [0, 1]);
6794
+ mesh = _chunkW3GXSUSQcjs.fitWarpMesh.call(void 0, (s, t) => _chunkW3GXSUSQcjs.evalWarpMesh.call(void 0, m, (s * contents.width - bounds.x) / bounds.width, (t * contents.height - bounds.y) / bounds.height), [0, 1], [0, 1]);
5229
6795
  }
5230
6796
  return { mesh, frame };
5231
6797
  }
@@ -5322,13 +6888,13 @@ function parsePlaced(key, data) {
5322
6888
  r.u32();
5323
6889
  try {
5324
6890
  warp = readVersionedDescriptor(r);
5325
- } catch (e11) {
6891
+ } catch (e14) {
5326
6892
  warp = void 0;
5327
6893
  }
5328
6894
  }
5329
6895
  return { key, idnt, placed: idnt, quad, warp };
5330
6896
  }
5331
- } catch (e12) {
6897
+ } catch (e15) {
5332
6898
  return null;
5333
6899
  }
5334
6900
  return null;
@@ -5368,13 +6934,13 @@ function blendOptions(f) {
5368
6934
  function smartFiltersFromPsd(fx, newId, notes) {
5369
6935
  const filters = [];
5370
6936
  const list2 = descGet(fx, "filterFXList");
5371
- for (const v of _optionalChain([list2, 'optionalAccess', _109 => _109.type]) === "VlLs" ? list2.items : []) {
6937
+ for (const v of _optionalChain([list2, 'optionalAccess', _141 => _141.type]) === "VlLs" ? list2.items : []) {
5372
6938
  if (v.type !== "Objc" && v.type !== "GlbO") continue;
5373
6939
  const item = v.value;
5374
6940
  const { blend, opacity } = blendOptionsOf(item);
5375
6941
  const enabled = descBool(item, "enab") !== false;
5376
6942
  const fltr = descObject(item, "Fltr");
5377
- const radius = _optionalChain([fltr, 'optionalAccess', _110 => _110.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
6943
+ const radius = _optionalChain([fltr, 'optionalAccess', _142 => _142.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
5378
6944
  if (radius !== void 0 && radius >= 0 && radius <= 50) {
5379
6945
  filters.push({ id: newId(), kind: "blur", enabled, radius, blend, opacity });
5380
6946
  continue;
@@ -5653,7 +7219,7 @@ function parseMask(d) {
5653
7219
  }
5654
7220
  if (!realFirst) m.real = readReal();
5655
7221
  return m;
5656
- } catch (e13) {
7222
+ } catch (e16) {
5657
7223
  return void 0;
5658
7224
  }
5659
7225
  }
@@ -5727,14 +7293,14 @@ function readPsd(bytes) {
5727
7293
  return { header, colorModeData, resources, layers, mergedAlpha, globalBlocks, imageCompression, imageData: r.rest() };
5728
7294
  }
5729
7295
  function layerBlock(rec, key) {
5730
- return _optionalChain([rec, 'access', _111 => _111.blocks, 'access', _112 => _112.find, 'call', _113 => _113((b) => b.key === key), 'optionalAccess', _114 => _114.data]);
7296
+ return _optionalChain([rec, 'access', _143 => _143.blocks, 'access', _144 => _144.find, 'call', _145 => _145((b) => b.key === key), 'optionalAccess', _146 => _146.data]);
5731
7297
  }
5732
7298
  function layerName(rec) {
5733
7299
  const luni = layerBlock(rec, "luni");
5734
7300
  if (luni) {
5735
7301
  try {
5736
7302
  return new PsdReader(luni).unicode();
5737
- } catch (e14) {
7303
+ } catch (e17) {
5738
7304
  }
5739
7305
  }
5740
7306
  return rec.legacyName;
@@ -5758,7 +7324,7 @@ function u8Block(rec, key) {
5758
7324
  function layerTree(file) {
5759
7325
  const stack = [[]];
5760
7326
  file.layers.forEach((rec, index) => {
5761
- const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _115 => _115(rec), 'optionalAccess', _116 => _116.kind]), () => ( SECTION_OTHER));
7327
+ const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _147 => _147(rec), 'optionalAccess', _148 => _148.kind]), () => ( SECTION_OTHER));
5762
7328
  if (kind === SECTION_DIVIDER) {
5763
7329
  stack.push([]);
5764
7330
  } else if (kind === SECTION_OPEN || kind === SECTION_CLOSED) {
@@ -5776,7 +7342,7 @@ function layerTree(file) {
5776
7342
  }
5777
7343
  function channelRect(rec, id) {
5778
7344
  if (id === CHANNEL_USER_MASK && rec.mask) return rec.mask.rect;
5779
- if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _117 => _117.mask, 'access', _118 => _118.real, 'optionalAccess', _119 => _119.rect]), () => ( rec.mask.rect));
7345
+ if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _149 => _149.mask, 'access', _150 => _150.real, 'optionalAccess', _151 => _151.rect]), () => ( rec.mask.rect));
5780
7346
  return rec.rect;
5781
7347
  }
5782
7348
  function decodeLayerChannel(file, rec, id) {
@@ -5794,7 +7360,7 @@ function decodeMergedImage(file) {
5794
7360
  return decodePlanes(file.imageCompression, file.imageData, { planes: channels, width, height, depth, psb });
5795
7361
  }
5796
7362
  function resource(file, id) {
5797
- return _optionalChain([file, 'access', _120 => _120.resources, 'access', _121 => _121.find, 'call', _122 => _122((r) => r.id === id), 'optionalAccess', _123 => _123.data]);
7363
+ return _optionalChain([file, 'access', _152 => _152.resources, 'access', _153 => _153.find, 'call', _154 => _154((r) => r.id === id), 'optionalAccess', _155 => _155.data]);
5798
7364
  }
5799
7365
  function resolution(file) {
5800
7366
  const d = resource(file, 1005);
@@ -6386,7 +7952,7 @@ function recordEffects(ctx, rec, name, notes, group) {
6386
7952
  }
6387
7953
  for (const e of parsed.effects.items) {
6388
7954
  for (const id of patternIds(e)) {
6389
- if (ctx.patterns.has(id) || _chunkT3QZ6S47cjs.builtinPattern.call(void 0, id)) continue;
7955
+ if (ctx.patterns.has(id) || _chunkAZTZRLDIcjs.builtinPattern.call(void 0, id)) continue;
6390
7956
  ctx.warn.add("A pattern effect uses a pattern the file does not contain, and paints nothing", name);
6391
7957
  notes.push(`pattern "${id}" is not in the file`);
6392
7958
  }
@@ -6415,7 +7981,7 @@ function importNode(ctx, node, depth) {
6415
7981
  if (node.children) {
6416
7982
  const props2 = baseProps(ctx, rec, name, notes);
6417
7983
  const divider = sectionDivider(rec);
6418
- const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _124 => _124.blendKey]), () => ( rec.blendKey));
7984
+ const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _156 => _156.blendKey]), () => ( rec.blendKey));
6419
7985
  const groupBlend = key === "pass" ? "pass-through" : _nullishCoalesce(PSD_BLEND_KEYS[key], () => ( "normal"));
6420
7986
  const children = [];
6421
7987
  for (const child of node.children) {
@@ -6425,7 +7991,7 @@ function importNode(ctx, node, depth) {
6425
7991
  const group = { type: "group", id: ctx.newId(name), ...props2, blend: groupBlend, children };
6426
7992
  const effects2 = recordEffects(ctx, rec, name, notes, true);
6427
7993
  if (effects2) group.effects = effects2;
6428
- if (_optionalChain([divider, 'optionalAccess', _125 => _125.kind]) === SECTION_CLOSED) group.collapsed = true;
7994
+ if (_optionalChain([divider, 'optionalAccess', _157 => _157.kind]) === SECTION_CLOSED) group.collapsed = true;
6429
7995
  const mask2 = recordMask(ctx, rec, name);
6430
7996
  if (mask2) group.mask = mask2;
6431
7997
  entry.type = "group";
@@ -6515,7 +8081,7 @@ function contentsFor(ctx, placed, name, notes) {
6515
8081
  document: { layers: nested.layers, globalLight: nested.globalLight, patterns: nested.patterns.length ? nested.patterns : void 0 }
6516
8082
  };
6517
8083
  } else if (t.ext === "png") {
6518
- const png = _chunkT3QZ6S47cjs.decodePng.call(void 0, file.bytes);
8084
+ const png = _chunkAZTZRLDIcjs.decodePng.call(void 0, file.bytes);
6519
8085
  out = { ...base, kind: "raster", width: png.width, height: png.height, raster: _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, png, 4, 0, 0) };
6520
8086
  } else {
6521
8087
  const size = _nullishCoalesce(placed.size, () => ( { width: 0, height: 0 }));
@@ -6557,7 +8123,7 @@ function importSmart(ctx, rec, name, notes, props) {
6557
8123
  if (placement && (size.width !== contents.width || size.height !== contents.height)) {
6558
8124
  const kx = contents.width / size.width;
6559
8125
  const ky = contents.height / size.height;
6560
- if (placement.warp) placement = { ...placement, warp: _chunkDWGZUSEScjs.mapWarpMeshPoints.call(void 0, placement.warp, (p) => ({ x: p.x * kx, y: p.y * ky })) };
8126
+ if (placement.warp) placement = { ...placement, warp: _chunkW3GXSUSQcjs.mapWarpMeshPoints.call(void 0, placement.warp, (p) => ({ x: p.x * kx, y: p.y * ky })) };
6561
8127
  }
6562
8128
  }
6563
8129
  if (!contents || !placement) {
@@ -6567,7 +8133,7 @@ function importSmart(ctx, rec, name, notes, props) {
6567
8133
  const file = ctx.linked.get(placed.idnt);
6568
8134
  contents = {
6569
8135
  id: placed.idnt || ctx.newId(`${name}-contents`),
6570
- name: _optionalChain([file, 'optionalAccess', _126 => _126.name]) || `${name}.png`,
8136
+ name: _optionalChain([file, 'optionalAccess', _158 => _158.name]) || `${name}.png`,
6571
8137
  width,
6572
8138
  height,
6573
8139
  kind: "raster",
@@ -6792,15 +8358,15 @@ var pct = (d, key, fallback) => num2(d, key, fallback * 100) / 100;
6792
8358
  var bool = (d, key) => descBool(d, key) === true;
6793
8359
  var enumOf2 = (d, key) => {
6794
8360
  const v = descGet(d, key);
6795
- return _optionalChain([v, 'optionalAccess', _127 => _127.type]) === "enum" ? v.value : void 0;
8361
+ return _optionalChain([v, 'optionalAccess', _159 => _159.type]) === "enum" ? v.value : void 0;
6796
8362
  };
6797
8363
  var text2 = (d, key) => {
6798
8364
  const v = d ? descGet(d, key) : void 0;
6799
- return _optionalChain([v, 'optionalAccess', _128 => _128.type]) === "TEXT" ? v.value : "";
8365
+ return _optionalChain([v, 'optionalAccess', _160 => _160.type]) === "TEXT" ? v.value : "";
6800
8366
  };
6801
8367
  var list = (d, key) => {
6802
8368
  const v = descGet(d, key);
6803
- if (_optionalChain([v, 'optionalAccess', _129 => _129.type]) !== "VlLs") return [];
8369
+ if (_optionalChain([v, 'optionalAccess', _161 => _161.type]) !== "VlLs") return [];
6804
8370
  return v.items.flatMap((it) => it.type === "Objc" || it.type === "GlbO" ? [it.value] : []);
6805
8371
  };
6806
8372
  var clamp3 = (v, lo, hi) => Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : lo;
@@ -6822,34 +8388,34 @@ function blendOf(d, key, fallback, notes) {
6822
8388
  function colorOf(d, fallback = "#000000") {
6823
8389
  if (!d) return fallback;
6824
8390
  const g = (k) => descNumber(d, k);
6825
- if (g("redFloat") !== void 0) return _chunkT3QZ6S47cjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
8391
+ if (g("redFloat") !== void 0) return _chunkAZTZRLDIcjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
6826
8392
  switch (d.classId) {
6827
8393
  case "HSBC": {
6828
8394
  const rgb = decodePsdColor(1, [(_nullishCoalesce(g("H "), () => ( 0))) / 360 * 65535, (_nullishCoalesce(g("Strt"), () => ( 0))) / 100 * 65535, (_nullishCoalesce(g("Brgh"), () => ( 0))) / 100 * 65535]);
6829
- return rgb ? _chunkT3QZ6S47cjs.effectColorHex.call(void 0, rgb) : fallback;
8395
+ return rgb ? _chunkAZTZRLDIcjs.effectColorHex.call(void 0, rgb) : fallback;
6830
8396
  }
6831
8397
  case "CMYC": {
6832
8398
  const inv = (k) => (1 - (_nullishCoalesce(g(k), () => ( 0))) / 100) * 65535;
6833
8399
  const rgb = decodePsdColor(2, [inv("Cyn "), inv("Mgnt"), inv("Ylw "), inv("Blck")]);
6834
- return rgb ? _chunkT3QZ6S47cjs.effectColorHex.call(void 0, rgb) : fallback;
8400
+ return rgb ? _chunkAZTZRLDIcjs.effectColorHex.call(void 0, rgb) : fallback;
6835
8401
  }
6836
8402
  case "LbCl": {
6837
8403
  const rgb = decodePsdColor(7, [(_nullishCoalesce(g("Lmnc"), () => ( 0))) * 100, Math.round((_nullishCoalesce(g("A "), () => ( 0))) * 100) & 65535, Math.round((_nullishCoalesce(g("B "), () => ( 0))) * 100) & 65535]);
6838
- return rgb ? _chunkT3QZ6S47cjs.effectColorHex.call(void 0, rgb) : fallback;
8404
+ return rgb ? _chunkAZTZRLDIcjs.effectColorHex.call(void 0, rgb) : fallback;
6839
8405
  }
6840
8406
  case "Grsc": {
6841
8407
  const v = 1 - (_nullishCoalesce(g("Gry "), () => ( 0))) / 100;
6842
- return _chunkT3QZ6S47cjs.effectColorHex.call(void 0, [v, v, v]);
8408
+ return _chunkAZTZRLDIcjs.effectColorHex.call(void 0, [v, v, v]);
6843
8409
  }
6844
8410
  }
6845
8411
  const r = g("Rd ");
6846
8412
  const gr = g("Grn ");
6847
8413
  const b = g("Bl ");
6848
8414
  if (r === void 0 || gr === void 0 || b === void 0) return fallback;
6849
- return _chunkT3QZ6S47cjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
8415
+ return _chunkAZTZRLDIcjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
6850
8416
  }
6851
8417
  function colorDesc(hex) {
6852
- const [r, g, b] = _nullishCoalesce(_chunkT3QZ6S47cjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
8418
+ const [r, g, b] = _nullishCoalesce(_chunkAZTZRLDIcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
6853
8419
  return descriptor("RGBC", [
6854
8420
  ["Rd ", dbl2(r * 255)],
6855
8421
  ["Grn ", dbl2(g * 255)],
@@ -6870,8 +8436,8 @@ function contourOf(d, key) {
6870
8436
  return { name, points };
6871
8437
  }
6872
8438
  function contourDesc(c) {
6873
- const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _130 => _130.name]), () => ( "Linear"));
6874
- const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _131 => _131.points]), () => ( [
8439
+ const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _162 => _162.name]), () => ( "Linear"));
8440
+ const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _163 => _163.points]), () => ( [
6875
8441
  { input: 0, output: 0 },
6876
8442
  { input: 1, output: 1 }
6877
8443
  ]));
@@ -6906,7 +8472,7 @@ function gradientOf(d, notes) {
6906
8472
  { position: 0, color: "#000000" },
6907
8473
  { position: 1, color: "#ffffff" }
6908
8474
  ],
6909
- style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _132 => _132.find, 'call', _133 => _133(([, id]) => id === enumOf2(d, "Type")), 'optionalAccess', _134 => _134[0]]), () => ( "linear")),
8475
+ style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _164 => _164.find, 'call', _165 => _165(([, id]) => id === enumOf2(d, "Type")), 'optionalAccess', _166 => _166[0]]), () => ( "linear")),
6910
8476
  angle: clamp3(num2(d, "Angl", 90), -360, 360),
6911
8477
  scale: clamp3(pct(d, "Scl ", 1), 0.1, 1.5),
6912
8478
  reverse: bool(d, "Rvrs"),
@@ -6932,9 +8498,9 @@ function gradientOf(d, notes) {
6932
8498
  raw.forEach((s, i) => {
6933
8499
  if (i > 0 && Math.abs(s.mid - 0.5) > 1e-3) {
6934
8500
  const a = raw[i - 1];
6935
- const ca = _chunkT3QZ6S47cjs.parseEffectColor.call(void 0, a.color);
6936
- const cb = _chunkT3QZ6S47cjs.parseEffectColor.call(void 0, s.color);
6937
- stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkT3QZ6S47cjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
8501
+ const ca = _chunkAZTZRLDIcjs.parseEffectColor.call(void 0, a.color);
8502
+ const cb = _chunkAZTZRLDIcjs.parseEffectColor.call(void 0, s.color);
8503
+ stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkAZTZRLDIcjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
6938
8504
  notes.add("gradient midpoints are drawn as straight segments");
6939
8505
  }
6940
8506
  stops.push({ position: s.position, color: s.color });
@@ -6960,7 +8526,7 @@ function gradientItems(g) {
6960
8526
  )
6961
8527
  )
6962
8528
  };
6963
- const op = _optionalChain([g, 'access', _135 => _135.opacityStops, 'optionalAccess', _136 => _136.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
8529
+ const op = _optionalChain([g, 'access', _167 => _167.opacityStops, 'optionalAccess', _168 => _168.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
6964
8530
  const trns = {
6965
8531
  type: "VlLs",
6966
8532
  items: op.map(
@@ -7046,8 +8612,8 @@ var KINDS = [
7046
8612
  ["FrFX", "frameFXMulti", "stroke"]
7047
8613
  ];
7048
8614
  function common(d, kind, notes) {
7049
- const def = _chunkT3QZ6S47cjs.defaultLayerEffect.call(void 0, kind, "x");
7050
- return { id: _chunkT3QZ6S47cjs.newEffectId.call(void 0, ), enabled: descBool(d, "enab") !== false, blend: blendOf(d, "Md ", def.blend, notes), opacity: clamp3(pct(d, "Opct", def.opacity), 0, 1) };
8615
+ const def = _chunkAZTZRLDIcjs.defaultLayerEffect.call(void 0, kind, "x");
8616
+ return { id: _chunkAZTZRLDIcjs.newEffectId.call(void 0, ), enabled: descBool(d, "enab") !== false, blend: blendOf(d, "Md ", def.blend, notes), opacity: clamp3(pct(d, "Opct", def.opacity), 0, 1) };
7051
8617
  }
7052
8618
  function readOne(kind, d, notes) {
7053
8619
  const size = (key, fallback) => clamp3(num2(d, key, fallback), 0, 250);
@@ -7090,7 +8656,7 @@ function readOne(kind, d, notes) {
7090
8656
  case "bevel-emboss": {
7091
8657
  const styles = { OtrB: "outer-bevel", InrB: "inner-bevel", Embs: "emboss", PlEb: "pillow-emboss", strokeEmboss: "stroke-emboss" };
7092
8658
  const out = {
7093
- id: _chunkT3QZ6S47cjs.newEffectId.call(void 0, ),
8659
+ id: _chunkAZTZRLDIcjs.newEffectId.call(void 0, ),
7094
8660
  enabled: descBool(d, "enab") !== false,
7095
8661
  kind,
7096
8662
  style: _nullishCoalesce(styles[_nullishCoalesce(enumOf2(d, "bvlS"), () => ( ""))], () => ( "inner-bevel")),
@@ -7156,7 +8722,7 @@ function parseLfx2(data) {
7156
8722
  let d;
7157
8723
  try {
7158
8724
  d = parseVersionedDescriptor(data.subarray(4));
7159
- } catch (e15) {
8725
+ } catch (e18) {
7160
8726
  return null;
7161
8727
  }
7162
8728
  const notes = /* @__PURE__ */ new Set();
@@ -7301,10 +8867,10 @@ function writeLfx2(effects) {
7301
8867
  ["Scl ", unit2("#Prc", 100)],
7302
8868
  ["masterFXSwitch", boolV2(effects.enabled)]
7303
8869
  ];
7304
- const scale = _chunkT3QZ6S47cjs.effectsScale.call(void 0, effects);
8870
+ const scale = _chunkAZTZRLDIcjs.effectsScale.call(void 0, effects);
7305
8871
  let dropped = 0;
7306
8872
  for (const [single, multi, kind] of KINDS) {
7307
- const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkT3QZ6S47cjs.scaleLayerEffect.call(void 0, e, scale)));
8873
+ const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkAZTZRLDIcjs.scaleLayerEffect.call(void 0, e, scale)));
7308
8874
  if (!of.length) continue;
7309
8875
  if (of.length === 1) items.push([single, obj2(of[0])]);
7310
8876
  else if (multi) items.push([multi, { type: "VlLs", items: of.map(obj2) }]);
@@ -7336,7 +8902,7 @@ function parseLrfx(data) {
7336
8902
  const colorAt = (rd) => {
7337
8903
  rd.u16();
7338
8904
  const c = [rd.u16(), rd.u16(), rd.u16(), rd.u16()];
7339
- return _chunkT3QZ6S47cjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
8905
+ return _chunkAZTZRLDIcjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
7340
8906
  };
7341
8907
  const blendAt = (rd) => {
7342
8908
  rd.skip(4);
@@ -7355,7 +8921,7 @@ function parseLrfx(data) {
7355
8921
  const enabled = b.u8() !== 0;
7356
8922
  const useGlobalLight = b.u8() !== 0;
7357
8923
  const opacity = b.u8() / 255;
7358
- const base = { id: _chunkT3QZ6S47cjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
8924
+ const base = { id: _chunkAZTZRLDIcjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
7359
8925
  items.push(key === "dsdw" ? { ...base, kind: "drop-shadow", spread: 0, knocksOut: true } : { ...base, kind: "inner-shadow", choke: 0 });
7360
8926
  } else if (key === "oglw" || key === "iglw") {
7361
8927
  b.u32();
@@ -7365,7 +8931,7 @@ function parseLrfx(data) {
7365
8931
  const blend = blendAt(b);
7366
8932
  const enabled = b.u8() !== 0;
7367
8933
  const opacity = b.u8() / 255;
7368
- const base = { id: _chunkT3QZ6S47cjs.newEffectId.call(void 0, ), enabled, blend, opacity, fill: { type: "color", color }, technique: "softer", size: clamp3(blur, 0, 250), antiAlias: false, range: 0.5, jitter: 0, noise: 0 };
8934
+ const base = { id: _chunkAZTZRLDIcjs.newEffectId.call(void 0, ), enabled, blend, opacity, fill: { type: "color", color }, technique: "softer", size: clamp3(blur, 0, 250), antiAlias: false, range: 0.5, jitter: 0, noise: 0 };
7369
8935
  items.push(key === "oglw" ? { ...base, kind: "outer-glow", spread: 0 } : { ...base, kind: "inner-glow", choke: 0, source: "edge" });
7370
8936
  } else if (key === "sofi") {
7371
8937
  b.u32();
@@ -7373,11 +8939,11 @@ function parseLrfx(data) {
7373
8939
  const color = colorAt(b);
7374
8940
  const opacity = b.u8() / 255;
7375
8941
  const enabled = b.u8() !== 0;
7376
- items.push({ id: _chunkT3QZ6S47cjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
8942
+ items.push({ id: _chunkAZTZRLDIcjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
7377
8943
  } else if (key === "bevl") notes.add("legacy bevels are not read");
7378
8944
  }
7379
8945
  return { effects: { enabled: true, items }, notes: [...notes] };
7380
- } catch (e16) {
8946
+ } catch (e19) {
7381
8947
  return null;
7382
8948
  }
7383
8949
  }
@@ -7445,9 +9011,9 @@ function prepareNestedLayers(layers) {
7445
9011
  if (l.type === "annotation") continue;
7446
9012
  let next = l;
7447
9013
  if (l.type === "group") next = { ...l, children: prepareNestedLayers(l.children) };
7448
- else if (l.type === "pixel" && (_optionalChain([l, 'access', _137 => _137.filters, 'optionalAccess', _138 => _138.length]) || l.source === "document")) {
9014
+ else if (l.type === "pixel" && (_optionalChain([l, 'access', _169 => _169.filters, 'optionalAccess', _170 => _170.length]) || l.source === "document")) {
7449
9015
  const p = { ...l };
7450
- if (_optionalChain([l, 'access', _139 => _139.filters, 'optionalAccess', _140 => _140.some, 'call', _141 => _141(isActiveFilter)])) {
9016
+ if (_optionalChain([l, 'access', _171 => _171.filters, 'optionalAccess', _172 => _172.some, 'call', _173 => _173(isActiveFilter)])) {
7451
9017
  const b = l.surface.bounds;
7452
9018
  if (b) {
7453
9019
  const r = { x: b.x + l.offset.x - 64, y: b.y + l.offset.y - 64, width: b.width + 128, height: b.height + 128 };
@@ -7464,7 +9030,7 @@ function prepareNestedLayers(layers) {
7464
9030
  delete p.source;
7465
9031
  next = p;
7466
9032
  }
7467
- if (_optionalChain([next, 'access', _142 => _142.mask, 'optionalAccess', _143 => _143.source])) {
9033
+ if (_optionalChain([next, 'access', _174 => _174.mask, 'optionalAccess', _175 => _175.source])) {
7468
9034
  next = { ...next };
7469
9035
  delete next.mask;
7470
9036
  }
@@ -7477,7 +9043,7 @@ function smartContentsFile(c) {
7477
9043
  if (c.file) return { name: c.name, bytes: c.file.bytes };
7478
9044
  if (c.kind === "raster") {
7479
9045
  const data = _chunkSZ6KMZNMcjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
7480
- return { name: `${base}.png`, bytes: _chunkT3QZ6S47cjs.encodePng.call(void 0, c.width, c.height, data) };
9046
+ return { name: `${base}.png`, bytes: _chunkAZTZRLDIcjs.encodePng.call(void 0, c.width, c.height, data) };
7481
9047
  }
7482
9048
  const doc = c.document;
7483
9049
  const merged = _chunkSZ6KMZNMcjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
@@ -7528,7 +9094,7 @@ function exportPsd(input) {
7528
9094
  const key = layer.type === "group" ? "lfxs" : "lfx2";
7529
9095
  if (fx.psd) {
7530
9096
  const original = parseLfx2(fx.psd.data);
7531
- if (original ? _chunkT3QZ6S47cjs.effectsFingerprint.call(void 0, original.effects) === _chunkT3QZ6S47cjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
9097
+ if (original ? _chunkAZTZRLDIcjs.effectsFingerprint.call(void 0, original.effects) === _chunkAZTZRLDIcjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
7532
9098
  }
7533
9099
  if (!fx.items.length && fx.enabled && (_nullishCoalesce(fx.scale, () => ( 1))) === 1) return null;
7534
9100
  const { data, dropped } = writeLfx2(fx);
@@ -7545,7 +9111,7 @@ function exportPsd(input) {
7545
9111
  return {
7546
9112
  opacity: Math.round(Math.min(1, Math.max(0, layer.opacity)) * 255),
7547
9113
  clipping: layer.clipped ? 1 : 0,
7548
- flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _144 => _144.locks, 'optionalAccess', _145 => _145.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
9114
+ flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _176 => _176.locks, 'optionalAccess', _177 => _177.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
7549
9115
  legacyName: name,
7550
9116
  blocks
7551
9117
  };
@@ -7602,7 +9168,7 @@ function exportPsd(input) {
7602
9168
  }
7603
9169
  case "pixel": {
7604
9170
  if (layer.source === "document") throw new PsdError(`Layer "${layer.name}" reads the document image; resolve its pixels before export.`);
7605
- if (_optionalChain([layer, 'access', _146 => _146.filters, 'optionalAccess', _147 => _147.some, 'call', _148 => _148(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
9171
+ if (_optionalChain([layer, 'access', _178 => _178.filters, 'optionalAccess', _179 => _179.some, 'call', _180 => _180(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
7606
9172
  const extra = [];
7607
9173
  if (layer.fillOpacity !== void 0 && layer.fillOpacity < 1) {
7608
9174
  extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
@@ -7641,7 +9207,7 @@ function exportPsd(input) {
7641
9207
  if (c.linked) note("Linked smart objects were embedded (their preview is written as the contents)", layer.name);
7642
9208
  linkedFiles.set(idnt, smartContentsFile(c));
7643
9209
  }
7644
- let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _149 => _149.psd, 'optionalAccess', _150 => _150.placed]), () => ( psdUuid(`${layer.id}:placed`)));
9210
+ let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _181 => _181.psd, 'optionalAccess', _182 => _182.placed]), () => ( psdUuid(`${layer.id}:placed`)));
7645
9211
  if (placedIds.has(placedId)) placedId = psdUuid(`${layer.id}:placed:${placedIds.size}`);
7646
9212
  placedIds.add(placedId);
7647
9213
  if (placedUnchanged(layer, idnt, placedId)) {
@@ -7651,12 +9217,12 @@ function exportPsd(input) {
7651
9217
  const filterFX = layer.smartFilters ? filterFXDescriptor(layer.smartFilters, dropped) : void 0;
7652
9218
  if (dropped.length) note("Develop smart filters have no Photoshop filter and were left out of the filter list (the layer\u2019s pixels still show them)", layer.name);
7653
9219
  const raw = layer.psd && layer.psd.key !== "PlLd" ? parsePlaced(layer.psd.key, layer.psd.data) : null;
7654
- const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _151 => _151.descriptor]) };
9220
+ const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _183 => _183.descriptor]) };
7655
9221
  const wnotes = [];
7656
9222
  extra.push({ key: "PlLd", data: plldBytes(spec) }, { key: "SoLd", data: soldBytes(spec, wnotes) });
7657
9223
  for (const n2 of wnotes) note(`A smart object: ${n2}`, layer.name);
7658
9224
  }
7659
- const fm = _optionalChain([layer, 'access', _152 => _152.smartFilters, 'optionalAccess', _153 => _153.mask]);
9225
+ const fm = _optionalChain([layer, 'access', _184 => _184.smartFilters, 'optionalAccess', _185 => _185.mask]);
7660
9226
  if (fm && !fm.source) filterItems.push(filterMaskItem(placedId, fm, { x: 0, y: 0, width, height }));
7661
9227
  const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
7662
9228
  const bounds = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, layer.surface);
@@ -7724,7 +9290,7 @@ function exportPsd(input) {
7724
9290
  const byId = new Map((_nullishCoalesce(input.patterns, () => ( []))).map((p) => [p.id, p]));
7725
9291
  const embed = [];
7726
9292
  for (const id of patternIds2) {
7727
- const p = _nullishCoalesce(byId.get(id), () => ( _chunkT3QZ6S47cjs.builtinPattern.call(void 0, id)));
9293
+ const p = _nullishCoalesce(byId.get(id), () => ( _chunkAZTZRLDIcjs.builtinPattern.call(void 0, id)));
7728
9294
  if (p) embed.push(p);
7729
9295
  else note(`Pattern "${id}" is not in the document and was not embedded`, id);
7730
9296
  }
@@ -8032,5 +9598,60 @@ function exportPsd(input) {
8032
9598
 
8033
9599
 
8034
9600
 
8035
- exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.LayerCompositor = LayerCompositor; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.LayerOperationError = LayerOperationError; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
8036
- //# sourceMappingURL=chunk-FRD3FUXI.cjs.map
9601
+
9602
+
9603
+
9604
+
9605
+
9606
+
9607
+
9608
+
9609
+
9610
+
9611
+
9612
+
9613
+
9614
+
9615
+
9616
+
9617
+
9618
+
9619
+
9620
+
9621
+
9622
+
9623
+
9624
+
9625
+
9626
+
9627
+
9628
+
9629
+
9630
+
9631
+
9632
+
9633
+
9634
+
9635
+
9636
+
9637
+
9638
+
9639
+
9640
+
9641
+
9642
+
9643
+
9644
+
9645
+
9646
+
9647
+
9648
+
9649
+
9650
+
9651
+
9652
+
9653
+
9654
+
9655
+
9656
+ exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.LayerCompositor = LayerCompositor; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.parseCssColor = parseCssColor; exports.LayerOperationError = LayerOperationError; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
9657
+ //# sourceMappingURL=chunk-D37BX2ZA.cjs.map