@pixerate/editor 0.114.0 → 0.116.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 (122) hide show
  1. package/THIRD_PARTY_NOTICES.md +6 -0
  2. package/dist/animation-editor/index.cjs +54 -54
  3. package/dist/animation-editor/index.d.cts +2 -2
  4. package/dist/animation-editor/index.d.ts +2 -2
  5. package/dist/animation-editor/index.js +2 -2
  6. package/dist/{chunk-DFQEX3AM.cjs → chunk-2UT4GXYA.cjs} +133 -8
  7. package/dist/chunk-2UT4GXYA.cjs.map +1 -0
  8. package/dist/{chunk-VXR7XWMF.js → chunk-7LNZAWSJ.js} +437 -41
  9. package/dist/chunk-7LNZAWSJ.js.map +1 -0
  10. package/dist/{chunk-LKCYANMW.js → chunk-ARQ7PQ6Q.js} +129 -4
  11. package/dist/chunk-ARQ7PQ6Q.js.map +1 -0
  12. package/dist/chunk-COAMRKVI.cjs +159 -0
  13. package/dist/chunk-COAMRKVI.cjs.map +1 -0
  14. package/dist/{chunk-C6C5PDKU.js → chunk-D53KSJUV.js} +3 -322
  15. package/dist/chunk-D53KSJUV.js.map +1 -0
  16. package/dist/chunk-D53VQGEJ.js +3262 -0
  17. package/dist/chunk-D53VQGEJ.js.map +1 -0
  18. package/dist/chunk-EJVDBITD.cjs +501 -0
  19. package/dist/chunk-EJVDBITD.cjs.map +1 -0
  20. package/dist/{chunk-LPLCWZTM.cjs → chunk-FODKPD44.cjs} +555 -159
  21. package/dist/chunk-FODKPD44.cjs.map +1 -0
  22. package/dist/chunk-HOCPSFGA.cjs +3262 -0
  23. package/dist/chunk-HOCPSFGA.cjs.map +1 -0
  24. package/dist/chunk-IPFRWILU.js +1908 -0
  25. package/dist/chunk-IPFRWILU.js.map +1 -0
  26. package/dist/{chunk-FV5AXTSF.cjs → chunk-JSSBHMMU.cjs} +36 -188
  27. package/dist/chunk-JSSBHMMU.cjs.map +1 -0
  28. package/dist/chunk-LF4WOZXZ.js +159 -0
  29. package/dist/chunk-LF4WOZXZ.js.map +1 -0
  30. package/dist/{chunk-26PGXHY7.cjs → chunk-M7O4BJRH.cjs} +36 -36
  31. package/dist/{chunk-26PGXHY7.cjs.map → chunk-M7O4BJRH.cjs.map} +1 -1
  32. package/dist/chunk-N3467VD6.js +501 -0
  33. package/dist/chunk-N3467VD6.js.map +1 -0
  34. package/dist/{chunk-ST7E3NEE.cjs → chunk-PAOWHJ5O.cjs} +18 -337
  35. package/dist/chunk-PAOWHJ5O.cjs.map +1 -0
  36. package/dist/{chunk-EUVSQ25B.js → chunk-SEBYNBHW.js} +85 -46
  37. package/dist/chunk-SEBYNBHW.js.map +1 -0
  38. package/dist/chunk-SMJGE7HM.cjs +1908 -0
  39. package/dist/chunk-SMJGE7HM.cjs.map +1 -0
  40. package/dist/{chunk-MMVHBKMM.js → chunk-T2P5TIZ6.js} +2 -2
  41. package/dist/{chunk-FGW5OWJ4.js → chunk-VJUML33I.js} +4 -156
  42. package/dist/chunk-VJUML33I.js.map +1 -0
  43. package/dist/{chunk-5OVJHMZQ.cjs → chunk-ZYZGEILO.cjs} +332 -293
  44. package/dist/chunk-ZYZGEILO.cjs.map +1 -0
  45. package/dist/export/index.cjs +4 -2
  46. package/dist/export/index.cjs.map +1 -1
  47. package/dist/export/index.js +5 -3
  48. package/dist/{export-b6NjCZ5-.d.cts → export-BXxSGBCq.d.cts} +67 -5
  49. package/dist/{export-_1dUKwpF.d.ts → export-Dm44YUvS.d.ts} +67 -5
  50. package/dist/export-Dv0-ZVrV.d.cts +501 -0
  51. package/dist/export-Dv0-ZVrV.d.ts +501 -0
  52. package/dist/{retouch-Do6tBs2H.d.ts → flow-BMtHAmg4.d.ts} +561 -2
  53. package/dist/{retouch-Bxkuc0KH.d.cts → flow-COCB42TP.d.cts} +561 -2
  54. package/dist/image-editor/index.cjs +1227 -934
  55. package/dist/image-editor/index.cjs.map +1 -1
  56. package/dist/image-editor/index.d.cts +18 -10
  57. package/dist/image-editor/index.d.ts +18 -10
  58. package/dist/image-editor/index.js +324 -31
  59. package/dist/image-editor/index.js.map +1 -1
  60. package/dist/index.cjs +4 -2
  61. package/dist/index.cjs.map +1 -1
  62. package/dist/index.js +5 -3
  63. package/dist/index.js.map +1 -1
  64. package/dist/kernel-wasm-WYCGNZR4.js +10 -0
  65. package/dist/kernel-wasm-WYCGNZR4.js.map +1 -0
  66. package/dist/kernel-wasm-YPVAEMVN.cjs +10 -0
  67. package/dist/kernel-wasm-YPVAEMVN.cjs.map +1 -0
  68. package/dist/paint/index.cjs +165 -3
  69. package/dist/paint/index.cjs.map +1 -1
  70. package/dist/paint/index.d.cts +225 -3
  71. package/dist/paint/index.d.ts +225 -3
  72. package/dist/paint/index.js +166 -4
  73. package/dist/paint-editor/index.cjs +4691 -845
  74. package/dist/paint-editor/index.cjs.map +1 -1
  75. package/dist/paint-editor/index.d.cts +1525 -277
  76. package/dist/paint-editor/index.d.ts +1525 -277
  77. package/dist/paint-editor/index.js +4561 -715
  78. package/dist/paint-editor/index.js.map +1 -1
  79. package/dist/raster/index.cjs +4 -3
  80. package/dist/raster/index.cjs.map +1 -1
  81. package/dist/raster/index.js +10 -9
  82. package/dist/{svg-BnRj0q8i.d.cts → svg-CVdFc80-.d.cts} +2 -2
  83. package/dist/{svg-CmmBFfGT.d.ts → svg-DlEuhwoX.d.ts} +2 -2
  84. package/dist/{types-1SUQKDAw.d.ts → types-CDLGhAZp.d.ts} +40 -2
  85. package/dist/{types-yINF17Ta.d.cts → types-Tfly4Aya.d.cts} +40 -2
  86. package/dist/vector/index.cjs +1897 -975
  87. package/dist/vector/index.cjs.map +1 -1
  88. package/dist/vector/index.d.cts +292 -32
  89. package/dist/vector/index.d.ts +292 -32
  90. package/dist/vector/index.js +928 -6
  91. package/dist/vector/index.js.map +1 -1
  92. package/dist/video-editor/index.cjs +502 -2165
  93. package/dist/video-editor/index.cjs.map +1 -1
  94. package/dist/video-editor/index.d.cts +3 -501
  95. package/dist/video-editor/index.d.ts +3 -501
  96. package/dist/video-editor/index.js +151 -1814
  97. package/dist/video-editor/index.js.map +1 -1
  98. package/package.json +4 -2
  99. package/skills/pixerate-image-editor/SKILL.md +1 -0
  100. package/skills/pixerate-image-editor/references/color-management.md +8 -3
  101. package/skills/pixerate-image-editor/references/photoshop-files.md +15 -9
  102. package/skills/pixerate-paint-editor/SKILL.md +136 -4
  103. package/skills/pixerate-vector/SKILL.md +22 -1
  104. package/dist/chunk-5OVJHMZQ.cjs.map +0 -1
  105. package/dist/chunk-C6C5PDKU.js.map +0 -1
  106. package/dist/chunk-DFQEX3AM.cjs.map +0 -1
  107. package/dist/chunk-EUVSQ25B.js.map +0 -1
  108. package/dist/chunk-FGW5OWJ4.js.map +0 -1
  109. package/dist/chunk-FV5AXTSF.cjs.map +0 -1
  110. package/dist/chunk-GX332W2C.js +0 -181
  111. package/dist/chunk-GX332W2C.js.map +0 -1
  112. package/dist/chunk-LKCYANMW.js.map +0 -1
  113. package/dist/chunk-LPLCWZTM.cjs.map +0 -1
  114. package/dist/chunk-MUUXNRU4.cjs +0 -181
  115. package/dist/chunk-MUUXNRU4.cjs.map +0 -1
  116. package/dist/chunk-ST7E3NEE.cjs.map +0 -1
  117. package/dist/chunk-TCKIXI46.cjs +0 -1136
  118. package/dist/chunk-TCKIXI46.cjs.map +0 -1
  119. package/dist/chunk-UBIXVXPR.js +0 -1136
  120. package/dist/chunk-UBIXVXPR.js.map +0 -1
  121. package/dist/chunk-VXR7XWMF.js.map +0 -1
  122. /package/dist/{chunk-MMVHBKMM.js.map → chunk-T2P5TIZ6.js.map} +0 -0
@@ -38,13 +38,13 @@
38
38
 
39
39
 
40
40
 
41
+ var _chunkPAOWHJ5Ocjs = require('./chunk-PAOWHJ5O.cjs');
41
42
 
42
43
 
43
44
 
44
45
 
45
46
 
46
47
 
47
- var _chunkST7E3NEEcjs = require('./chunk-ST7E3NEE.cjs');
48
48
 
49
49
 
50
50
 
@@ -54,7 +54,7 @@ var _chunkST7E3NEEcjs = require('./chunk-ST7E3NEE.cjs');
54
54
 
55
55
 
56
56
 
57
- var _chunkMUUXNRU4cjs = require('./chunk-MUUXNRU4.cjs');
57
+ var _chunkEJVDBITDcjs = require('./chunk-EJVDBITD.cjs');
58
58
 
59
59
 
60
60
 
@@ -76,6 +76,12 @@ var _chunkTFOPHZ3Ucjs = require('./chunk-TFOPHZ3U.cjs');
76
76
 
77
77
 
78
78
 
79
+
80
+ var _chunkG5NMLUVFcjs = require('./chunk-G5NMLUVF.cjs');
81
+
82
+
83
+
84
+
79
85
  var _chunk643B2HKCcjs = require('./chunk-643B2HKC.cjs');
80
86
 
81
87
 
@@ -112,7 +118,7 @@ var _chunk643B2HKCcjs = require('./chunk-643B2HKC.cjs');
112
118
 
113
119
 
114
120
 
115
- var _chunkLPLCWZTMcjs = require('./chunk-LPLCWZTM.cjs');
121
+ var _chunkFODKPD44cjs = require('./chunk-FODKPD44.cjs');
116
122
 
117
123
 
118
124
 
@@ -1131,7 +1137,7 @@ function smoothCoverage(m, w, h, r) {
1131
1137
  return src;
1132
1138
  }
1133
1139
  function featherCoverage(m, w, h, radius) {
1134
- const out = _chunkST7E3NEEcjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
1140
+ const out = _chunkPAOWHJ5Ocjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
1135
1141
  for (let i = 0; i < out.length; i++) if (Math.abs(out[i]) < 1e-7) out[i] = 0;
1136
1142
  return out;
1137
1143
  }
@@ -1279,7 +1285,7 @@ function layerMaskCoverage(mask) {
1279
1285
  let v = new Float32Array(sel.data.length);
1280
1286
  for (let i = 0; i < v.length; i++) v[i] = sel.data[i] / 255;
1281
1287
  const feather = _nullishCoalesce(mask.feather, () => ( 0));
1282
- if (feather > 0) v = _chunkST7E3NEEcjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
1288
+ if (feather > 0) v = _chunkPAOWHJ5Ocjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
1283
1289
  const density = _nullishCoalesce(mask.density, () => ( 1));
1284
1290
  if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
1285
1291
  return v;
@@ -1522,7 +1528,7 @@ function normalizeAdjustmentLayers(raw) {
1522
1528
  return out;
1523
1529
  }
1524
1530
  function curveLutFromLevels(points) {
1525
- return _chunkST7E3NEEcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
1531
+ return _chunkPAOWHJ5Ocjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
1526
1532
  }
1527
1533
  var toUnitLevels = (c) => ({
1528
1534
  inBlack: c.inBlack / 255,
@@ -2276,7 +2282,7 @@ function newLayerId(prefix = "layer") {
2276
2282
  return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
2277
2283
  }
2278
2284
  function pixelLayers(layers) {
2279
- return _chunkST7E3NEEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
2285
+ return _chunkPAOWHJ5Ocjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
2280
2286
  }
2281
2287
  function developFilter(layer) {
2282
2288
  return _optionalChain([layer, 'access', _10 => _10.filters, 'optionalAccess', _11 => _11.find, 'call', _12 => _12((f) => f.kind === "develop")]);
@@ -2307,10 +2313,10 @@ function isRenderedLayer(layer) {
2307
2313
  return layer.type === "smart" || layer.type === "shape" || layer.type === "type";
2308
2314
  }
2309
2315
  function shapeLayers(layers) {
2310
- return _chunkST7E3NEEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
2316
+ return _chunkPAOWHJ5Ocjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
2311
2317
  }
2312
2318
  function smartObjectLayers(layers) {
2313
- return _chunkST7E3NEEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
2319
+ return _chunkPAOWHJ5Ocjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
2314
2320
  }
2315
2321
 
2316
2322
  // src/image-editor/layers/compositor.ts
@@ -2416,13 +2422,13 @@ var PHOTO_PROFILE = {
2416
2422
  return v;
2417
2423
  }
2418
2424
  };
2419
- var LayerCompositor = class extends _chunkST7E3NEEcjs.RasterCompositor {
2425
+ var LayerCompositor = class extends _chunkPAOWHJ5Ocjs.RasterCompositor {
2420
2426
  constructor(options = {}) {
2421
2427
  super(PHOTO_PROFILE, options);
2422
2428
  }
2423
2429
  };
2424
2430
  function compositeDeep(layers, rect, sources, depth) {
2425
- const deep = new (0, _chunkST7E3NEEcjs.DeepCompositor)(new LayerCompositor(), PHOTO_PROFILE, {
2431
+ const deep = new (0, _chunkPAOWHJ5Ocjs.DeepCompositor)(new LayerCompositor(), PHOTO_PROFILE, {
2426
2432
  applyFilterRunDeep: (run, acc, _r, masks) => applyAdjustmentLayersFloat(acc, run.map(adjustmentNodeAsLayer), masks)
2427
2433
  }, depth);
2428
2434
  return deep.composite(layers, rect, sources);
@@ -2968,47 +2974,47 @@ var fail = (message) => {
2968
2974
  throw new LayerOperationError(message);
2969
2975
  };
2970
2976
  function requireLayer(layers, id) {
2971
- const loc = _chunkST7E3NEEcjs.findLayer.call(void 0, layers, id);
2977
+ const loc = _chunkPAOWHJ5Ocjs.findLayer.call(void 0, layers, id);
2972
2978
  if (!loc) {
2973
- const ids = _chunkST7E3NEEcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
2979
+ const ids = _chunkPAOWHJ5Ocjs.flattenLayers.call(void 0, layers).map((l) => l.id);
2974
2980
  fail(`Unknown layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "The document has no layers."} Call list_layers for ids.`);
2975
2981
  }
2976
2982
  return loc;
2977
2983
  }
2978
2984
  function requireUnlocked(layer, what, action) {
2979
- if (_chunkST7E3NEEcjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
2980
- if (what !== "all" && _chunkST7E3NEEcjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
2985
+ if (_chunkPAOWHJ5Ocjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
2986
+ if (what !== "all" && _chunkPAOWHJ5Ocjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
2981
2987
  }
2982
2988
  function placeLayer(layers, layer, placement = {}, defaultIndex) {
2983
2989
  const given = [placement.aboveId, placement.belowId, placement.parentId].filter((v) => v !== void 0).length;
2984
2990
  if (given > 1) fail("Give only one of aboveId, belowId and parentId.");
2985
2991
  if (placement.aboveId || placement.belowId) {
2986
2992
  const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
2987
- return _chunkST7E3NEEcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _21 => _21.parent, 'optionalAccess', _22 => _22.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
2993
+ return _chunkPAOWHJ5Ocjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _21 => _21.parent, 'optionalAccess', _22 => _22.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
2988
2994
  }
2989
2995
  if (placement.parentId) {
2990
2996
  const ref = requireLayer(layers, placement.parentId);
2991
2997
  if (ref.layer.type !== "group") fail(`Layer "${placement.parentId}" is not a group; parentId must be a group id.`);
2992
- return _chunkST7E3NEEcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
2998
+ return _chunkPAOWHJ5Ocjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
2993
2999
  }
2994
- return _chunkST7E3NEEcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
3000
+ return _chunkPAOWHJ5Ocjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
2995
3001
  }
2996
3002
  function removeLayer(layers, id) {
2997
3003
  const loc = requireLayer(layers, id);
2998
3004
  requireUnlocked(loc.layer, "all", "delete it");
2999
- return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => null);
3005
+ return _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => null);
3000
3006
  }
3001
3007
  function moveLayer(layers, id, placement) {
3002
3008
  const loc = requireLayer(layers, id);
3003
3009
  requireUnlocked(loc.layer, "all", "move it");
3004
3010
  const target = _nullishCoalesce(_nullishCoalesce(placement.aboveId, () => ( placement.belowId)), () => ( placement.parentId));
3005
3011
  if (target === id) fail("A layer cannot be placed relative to itself.");
3006
- if (target && loc.layer.type === "group" && _chunkST7E3NEEcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
3012
+ if (target && loc.layer.type === "group" && _chunkPAOWHJ5Ocjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
3007
3013
  fail(`Group "${id}" cannot be moved into its own child "${target}".`);
3008
3014
  }
3009
3015
  if (target) requireLayer(layers, target);
3010
3016
  if (!target && placement.index === void 0) fail("Give aboveId, belowId, parentId or index.");
3011
- const without = _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => null);
3017
+ const without = _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => null);
3012
3018
  return placeLayer(without, loc.layer, placement);
3013
3019
  }
3014
3020
  function withNewIds(layer) {
@@ -3027,7 +3033,7 @@ function duplicateLayer(layers, id, name) {
3027
3033
  const copy = withNewIds(loc.layer);
3028
3034
  copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
3029
3035
  delete copy.locks;
3030
- return { layers: _chunkST7E3NEEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _25 => _25.parent, 'optionalAccess', _26 => _26.id]), () => ( null)), loc.index + 1), id: copy.id };
3036
+ return { layers: _chunkPAOWHJ5Ocjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _25 => _25.parent, 'optionalAccess', _26 => _26.id]), () => ( null)), loc.index + 1), id: copy.id };
3031
3037
  }
3032
3038
  function setLayerProperties(layers, id, props) {
3033
3039
  const loc = requireLayer(layers, id);
@@ -3074,7 +3080,7 @@ function setLayerProperties(layers, id, props) {
3074
3080
  if (props.collapsed) g.collapsed = true;
3075
3081
  else delete g.collapsed;
3076
3082
  }
3077
- return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next);
3083
+ return _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => next);
3078
3084
  }
3079
3085
  function groupLayers(layers, ids, name = "Group") {
3080
3086
  if (!ids.length) fail("Give at least one layer id to group.");
@@ -3103,17 +3109,17 @@ function groupLayers(layers, ids, name = "Group") {
3103
3109
  group.children[0] = c;
3104
3110
  }
3105
3111
  let out = layers;
3106
- for (const l of ordered) out = _chunkST7E3NEEcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
3107
- return { layers: _chunkST7E3NEEcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
3112
+ for (const l of ordered) out = _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, out, l.layer.id, () => null);
3113
+ return { layers: _chunkPAOWHJ5Ocjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
3108
3114
  }
3109
3115
  function ungroupLayer(layers, id) {
3110
3116
  const loc = requireLayer(layers, id);
3111
3117
  if (loc.layer.type !== "group") fail(`Layer "${id}" is not a group.`);
3112
3118
  requireUnlocked(loc.layer, "all", "ungroup it");
3113
3119
  const group = loc.layer;
3114
- let out = _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => null);
3120
+ let out = _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => null);
3115
3121
  group.children.forEach((c, i) => {
3116
- out = _chunkST7E3NEEcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _35 => _35.parent, 'optionalAccess', _36 => _36.id]), () => ( null)), loc.index + i);
3122
+ out = _chunkPAOWHJ5Ocjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _35 => _35.parent, 'optionalAccess', _36 => _36.id]), () => ( null)), loc.index + i);
3117
3123
  });
3118
3124
  return { layers: out, ids: group.children.map((c) => c.id) };
3119
3125
  }
@@ -3128,12 +3134,12 @@ function offsetLayer(layers, id, offset) {
3128
3134
  if (mask && mask.linked === false && !mask.source) {
3129
3135
  next.mask = { ...mask, surface: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
3130
3136
  }
3131
- return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next);
3137
+ return _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => next);
3132
3138
  }
3133
3139
  function setLayerMask(layers, id, mask) {
3134
3140
  const loc = requireLayer(layers, id);
3135
3141
  requireUnlocked(loc.layer, "all", "change its mask");
3136
- return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, (l) => {
3142
+ return _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, (l) => {
3137
3143
  const next = { ...l };
3138
3144
  if (mask) next.mask = mask;
3139
3145
  else delete next.mask;
@@ -3172,7 +3178,7 @@ function requirePixelLayer(layers, id) {
3172
3178
  function addLayerFilter(layers, id, filter) {
3173
3179
  const layer = requirePixelLayer(layers, id);
3174
3180
  if (_optionalChain([layer, 'access', _37 => _37.filters, 'optionalAccess', _38 => _38.some, 'call', _39 => _39((f) => f.kind === filter.kind)])) fail(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
3175
- return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
3181
+ return _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
3176
3182
  }
3177
3183
  function updateLayerFilter(layers, id, filterId, changes) {
3178
3184
  const layer = requirePixelLayer(layers, id);
@@ -3183,7 +3189,7 @@ function updateLayerFilter(layers, id, filterId, changes) {
3183
3189
  const merged2 = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
3184
3190
  const filters = [...layer.filters];
3185
3191
  filters[i] = merged2;
3186
- return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
3192
+ return _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
3187
3193
  }
3188
3194
  function removeLayerFilter(layers, id, filterId) {
3189
3195
  const layer = requirePixelLayer(layers, id);
@@ -3192,7 +3198,7 @@ function removeLayerFilter(layers, id, filterId) {
3192
3198
  const next = { ...layer };
3193
3199
  if (filters.length) next.filters = filters;
3194
3200
  else delete next.filters;
3195
- return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next);
3201
+ return _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => next);
3196
3202
  }
3197
3203
  function requireEffectLayer(layers, id, action) {
3198
3204
  const layer = requireLayer(layers, id).layer;
@@ -3207,7 +3213,7 @@ function guard(fn) {
3207
3213
  try {
3208
3214
  return fn();
3209
3215
  } catch (e) {
3210
- if (e instanceof _chunkST7E3NEEcjs.LayerEffectError) fail(e.message);
3216
+ if (e instanceof _chunkPAOWHJ5Ocjs.LayerEffectError) fail(e.message);
3211
3217
  throw e;
3212
3218
  }
3213
3219
  }
@@ -3215,20 +3221,20 @@ function setLayerEffects(layers, id, effects) {
3215
3221
  const layer = requireEffectLayer(layers, id, "change its effects");
3216
3222
  const next = { ...layer };
3217
3223
  if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
3218
- guard(() => _chunkST7E3NEEcjs.validateLayerEffects.call(void 0, effects));
3224
+ guard(() => _chunkPAOWHJ5Ocjs.validateLayerEffects.call(void 0, effects));
3219
3225
  next.effects = effects;
3220
3226
  } else delete next.effects;
3221
- return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next);
3227
+ return _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => next);
3222
3228
  }
3223
3229
  function addLayerEffect(layers, id, kind, params = {}, index) {
3224
- if (!_chunkST7E3NEEcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkST7E3NEEcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
3230
+ if (!_chunkPAOWHJ5Ocjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkPAOWHJ5Ocjs.LAYER_EFFECT_KINDS.join(", ")}.`);
3225
3231
  const layer = requireEffectLayer(layers, id, "add effects");
3226
3232
  const current = layerEffectsOf(layer);
3227
3233
  const ids = new Set(current.items.map((e) => e.id));
3228
- let effectId = _chunkST7E3NEEcjs.newEffectId.call(void 0, );
3229
- while (ids.has(effectId)) effectId = _chunkST7E3NEEcjs.newEffectId.call(void 0, );
3234
+ let effectId = _chunkPAOWHJ5Ocjs.newEffectId.call(void 0, );
3235
+ while (ids.has(effectId)) effectId = _chunkPAOWHJ5Ocjs.newEffectId.call(void 0, );
3230
3236
  const { id: _ignored, kind: _kind, ...rest } = params;
3231
- const effect = guard(() => _chunkST7E3NEEcjs.mergeLayerEffect.call(void 0, _chunkST7E3NEEcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
3237
+ const effect = guard(() => _chunkPAOWHJ5Ocjs.mergeLayerEffect.call(void 0, _chunkPAOWHJ5Ocjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
3232
3238
  const items = [...current.items];
3233
3239
  const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
3234
3240
  items.splice(at, 0, effect);
@@ -3245,7 +3251,7 @@ function updateLayerEffect(layers, id, effectId, changes) {
3245
3251
  const i = requireEffect(layer, effectId);
3246
3252
  const current = layer.effects;
3247
3253
  const items = [...current.items];
3248
- items[i] = guard(() => _chunkST7E3NEEcjs.mergeLayerEffect.call(void 0, items[i], changes));
3254
+ items[i] = guard(() => _chunkPAOWHJ5Ocjs.mergeLayerEffect.call(void 0, items[i], changes));
3249
3255
  return setLayerEffects(layers, id, { ...current, items });
3250
3256
  }
3251
3257
  function removeLayerEffect(layers, id, effectId) {
@@ -3280,7 +3286,7 @@ function unionRect(a, b) {
3280
3286
  }
3281
3287
 
3282
3288
  // src/image-editor/layers/shape.ts
3283
- var SHAPE_RENDER_MARGIN = _chunkST7E3NEEcjs.MAX_EFFECT_REACH;
3289
+ var SHAPE_RENDER_MARGIN = _chunkPAOWHJ5Ocjs.MAX_EFFECT_REACH;
3284
3290
  var DEFAULT_MITER_LIMIT = 100;
3285
3291
  var fail2 = (message) => {
3286
3292
  throw new LayerOperationError(message);
@@ -3320,7 +3326,7 @@ function mapAnchor(a, f) {
3320
3326
  return out;
3321
3327
  }
3322
3328
  function mapSubpaths(subpaths, f) {
3323
- return _chunkLPLCWZTMcjs.expandVectorCorners.call(void 0, subpaths).map((sp) => ({ closed: sp.closed, anchors: sp.anchors.map((a) => mapAnchor(a, f)) }));
3329
+ return _chunkFODKPD44cjs.expandVectorCorners.call(void 0, subpaths).map((sp) => ({ closed: sp.closed, anchors: sp.anchors.map((a) => mapAnchor(a, f)) }));
3324
3330
  }
3325
3331
  function liveShapeSubpaths(live) {
3326
3332
  let out;
@@ -3328,19 +3334,19 @@ function liveShapeSubpaths(live) {
3328
3334
  case "rect": {
3329
3335
  const x = Math.min(live.x, live.x + live.width);
3330
3336
  const y = Math.min(live.y, live.y + live.height);
3331
- const sp = _chunkLPLCWZTMcjs.rectSubpath.call(void 0, { x, y, width: Math.abs(live.width), height: Math.abs(live.height) });
3337
+ const sp = _chunkFODKPD44cjs.rectSubpath.call(void 0, { x, y, width: Math.abs(live.width), height: Math.abs(live.height) });
3332
3338
  const r = _nullishCoalesce(live.radii, () => ( [0, 0, 0, 0]));
3333
- out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ? _chunkLPLCWZTMcjs.setAnchorCorner.call(void 0, a, r[i]) : a) }];
3339
+ out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ? _chunkFODKPD44cjs.setAnchorCorner.call(void 0, a, r[i]) : a) }];
3334
3340
  break;
3335
3341
  }
3336
3342
  case "ellipse":
3337
- out = [_chunkLPLCWZTMcjs.ellipseSubpath.call(void 0, normBox(live))];
3343
+ out = [_chunkFODKPD44cjs.ellipseSubpath.call(void 0, normBox(live))];
3338
3344
  break;
3339
3345
  case "polygon":
3340
- out = [_chunkLPLCWZTMcjs.polygonSubpath.call(void 0, normBox(live), live.sides)];
3346
+ out = [_chunkFODKPD44cjs.polygonSubpath.call(void 0, normBox(live), live.sides)];
3341
3347
  break;
3342
3348
  case "star":
3343
- out = [_chunkLPLCWZTMcjs.starSubpath.call(void 0, normBox(live), live.points, Math.max(0, Math.min(1, live.innerRatio)))];
3349
+ out = [_chunkFODKPD44cjs.starSubpath.call(void 0, normBox(live), live.points, Math.max(0, Math.min(1, live.innerRatio)))];
3344
3350
  break;
3345
3351
  case "line": {
3346
3352
  const a = { x: live.x1, y: live.y1 };
@@ -3363,7 +3369,7 @@ function liveShapeSubpaths(live) {
3363
3369
  }
3364
3370
  }
3365
3371
  const m = live.transform;
3366
- return m && !_chunkLPLCWZTMcjs.isIdentityMatrix.call(void 0, m) ? mapSubpaths(out, (p) => _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, p)) : out;
3372
+ return m && !_chunkFODKPD44cjs.isIdentityMatrix.call(void 0, m) ? mapSubpaths(out, (p) => _chunkFODKPD44cjs.applyMatrix.call(void 0, m, p)) : out;
3367
3373
  }
3368
3374
  function normBox(b) {
3369
3375
  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) };
@@ -3375,7 +3381,7 @@ var pathCache = /* @__PURE__ */ new WeakMap();
3375
3381
  function componentPath(c) {
3376
3382
  let p = pathCache.get(c.subpaths);
3377
3383
  if (!p) {
3378
- p = _chunkLPLCWZTMcjs.subpathsToBezier.call(void 0, c.subpaths);
3384
+ p = _chunkFODKPD44cjs.subpathsToBezier.call(void 0, c.subpaths);
3379
3385
  pathCache.set(c.subpaths, p);
3380
3386
  }
3381
3387
  return p;
@@ -3496,11 +3502,11 @@ function fillCoverage(geo, rect, rule, inverted = false) {
3496
3502
  function paintContext(env) {
3497
3503
  const tiles = /* @__PURE__ */ new Map();
3498
3504
  return {
3499
- light: _chunkST7E3NEEcjs.DEFAULT_GLOBAL_LIGHT,
3505
+ light: _chunkPAOWHJ5Ocjs.DEFAULT_GLOBAL_LIGHT,
3500
3506
  pattern: (id) => {
3501
3507
  if (tiles.has(id)) return tiles.get(id);
3502
- const p = _nullishCoalesce(_optionalChain([env, 'access', _44 => _44.pattern, 'optionalCall', _45 => _45(id)]), () => ( _chunkST7E3NEEcjs.builtinPattern.call(void 0, id)));
3503
- const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0, _chunkST7E3NEEcjs.PatternTile)(p) : null;
3508
+ const p = _nullishCoalesce(_optionalChain([env, 'access', _44 => _44.pattern, 'optionalCall', _45 => _45(id)]), () => ( _chunkPAOWHJ5Ocjs.builtinPattern.call(void 0, id)));
3509
+ const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0, _chunkPAOWHJ5Ocjs.PatternTile)(p) : null;
3504
3510
  tiles.set(id, t);
3505
3511
  return t;
3506
3512
  }
@@ -3531,9 +3537,9 @@ function renderShapeRect(layer, rect, env, ctx = paintContext(env)) {
3531
3537
  if (!fCov && !sCov) return null;
3532
3538
  const canvas = { x: 0, y: 0, width: env.width, height: env.height };
3533
3539
  const anchor = { x: geo.frame.x, y: geo.frame.y };
3534
- const fc = fCov ? _chunkST7E3NEEcjs.effectFillColors.call(void 0, layer.fill, rect, geo.frame, canvas, anchor, ctx) : null;
3540
+ const fc = fCov ? _chunkPAOWHJ5Ocjs.effectFillColors.call(void 0, layer.fill, rect, geo.frame, canvas, anchor, ctx) : null;
3535
3541
  const fo = _nullishCoalesce(_optionalChain([layer, 'access', _46 => _46.fill, 'optionalAccess', _47 => _47.opacity]), () => ( 1));
3536
- const sc = sCov ? _chunkST7E3NEEcjs.effectFillColors.call(void 0, layer.stroke.paint, rect, geo.frame, canvas, anchor, ctx) : null;
3542
+ const sc = sCov ? _chunkPAOWHJ5Ocjs.effectFillColors.call(void 0, layer.stroke.paint, rect, geo.frame, canvas, anchor, ctx) : null;
3537
3543
  const so = _nullishCoalesce(_optionalChain([layer, 'access', _48 => _48.stroke, 'optionalAccess', _49 => _49.paint, 'access', _50 => _50.opacity]), () => ( 1));
3538
3544
  const out = new Uint8ClampedArray(n * 4);
3539
3545
  let any = false;
@@ -3626,9 +3632,9 @@ function normalizeShapePaint(v, path = "paint") {
3626
3632
  offset: _nullishCoalesce(g.offset, () => ( { x: 0, y: 0 }))
3627
3633
  };
3628
3634
  try {
3629
- _chunkST7E3NEEcjs.validateEffectGradient.call(void 0, gradient, `${path}.gradient`);
3635
+ _chunkPAOWHJ5Ocjs.validateEffectGradient.call(void 0, gradient, `${path}.gradient`);
3630
3636
  } catch (e) {
3631
- if (e instanceof _chunkST7E3NEEcjs.LayerEffectError) fail2(e.message);
3637
+ if (e instanceof _chunkPAOWHJ5Ocjs.LayerEffectError) fail2(e.message);
3632
3638
  throw e;
3633
3639
  }
3634
3640
  if (gradient.stops.length < 1) fail2(`${path}.gradient.stops needs at least one { position, color }.`);
@@ -3698,7 +3704,7 @@ function matrixArg(v, path) {
3698
3704
  if (!Array.isArray(v) || v.length !== 6 || !v.every(isNum)) fail2(`${path} must be six numbers [a, b, c, d, e, f].`);
3699
3705
  const m = v;
3700
3706
  if (Math.abs(m[0] * m[3] - m[1] * m[2]) < 1e-12) fail2(`${path} is singular.`);
3701
- return _chunkLPLCWZTMcjs.isIdentityMatrix.call(void 0, m) ? void 0 : [...m];
3707
+ return _chunkFODKPD44cjs.isIdentityMatrix.call(void 0, m) ? void 0 : [...m];
3702
3708
  }
3703
3709
  function normalizeLiveShape(v, path = "shape") {
3704
3710
  if (!v || typeof v !== "object") return fail2(`${path} must be an object with kind ${LIVE_SHAPE_KINDS.join(", ")}.`);
@@ -3759,7 +3765,7 @@ function normalizeSubpaths(v, path = "subpaths") {
3759
3765
  if (typeof v === "string") {
3760
3766
  let subs;
3761
3767
  try {
3762
- subs = _chunkLPLCWZTMcjs.bezierToSubpaths.call(void 0, v);
3768
+ subs = _chunkFODKPD44cjs.bezierToSubpaths.call(void 0, v);
3763
3769
  } catch (e5) {
3764
3770
  return fail2(`${path}: could not read the SVG path data.`);
3765
3771
  }
@@ -3840,20 +3846,20 @@ function updateShapeLayer(layers, id, change, env, action = "edit it") {
3840
3846
  if (!("annotation" in patch)) delete next.annotation;
3841
3847
  if (!next.components.length) fail2("A shape needs at least one component; delete the layer instead.");
3842
3848
  const rendered = rerenderShape(next, env);
3843
- return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
3849
+ return { layers: _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
3844
3850
  }
3845
3851
  function transformShapeComponents(components, f, affine) {
3846
3852
  return components.map((c) => {
3847
3853
  if (affine && c.live) {
3848
- const live = { ...c.live, transform: _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, _nullishCoalesce(c.live.transform, () => ( _chunkLPLCWZTMcjs.IDENTITY_MATRIX)), affine) };
3849
- if (_chunkLPLCWZTMcjs.isIdentityMatrix.call(void 0, live.transform)) delete live.transform;
3854
+ const live = { ...c.live, transform: _chunkFODKPD44cjs.multiplyMatrices.call(void 0, _nullishCoalesce(c.live.transform, () => ( _chunkFODKPD44cjs.IDENTITY_MATRIX)), affine) };
3855
+ if (_chunkFODKPD44cjs.isIdentityMatrix.call(void 0, live.transform)) delete live.transform;
3850
3856
  return { op: c.op, subpaths: liveShapeSubpaths(live), live };
3851
3857
  }
3852
3858
  return { op: c.op, subpaths: mapSubpaths(c.subpaths, f) };
3853
3859
  });
3854
3860
  }
3855
3861
  function offsetShape(layer, dx, dy, env) {
3856
- const m = _chunkLPLCWZTMcjs.translateMatrix.call(void 0, dx, dy);
3862
+ const m = _chunkFODKPD44cjs.translateMatrix.call(void 0, dx, dy);
3857
3863
  const next = { ...layer, components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), m) };
3858
3864
  delete next.annotation;
3859
3865
  return rerenderShape(next, env);
@@ -3861,7 +3867,7 @@ function offsetShape(layer, dx, dy, env) {
3861
3867
  function mergeShapeComponents(components, fillRule = "nonzero") {
3862
3868
  if (components.length < 2) return [...components];
3863
3869
  const path = shapeOutline(components, fillRule);
3864
- const subpaths = _chunkLPLCWZTMcjs.bezierToSubpaths.call(void 0, path);
3870
+ const subpaths = _chunkFODKPD44cjs.bezierToSubpaths.call(void 0, path);
3865
3871
  if (!subpaths.length) fail2("The components combine to nothing (the operations remove every area), so there is nothing to merge into.");
3866
3872
  return [{ op: "combine", subpaths }];
3867
3873
  }
@@ -3871,14 +3877,14 @@ function shapeAsPixelLayer(layer) {
3871
3877
  }
3872
3878
  function annotationPaint(color, opacity) {
3873
3879
  const c = parseCssColor(color);
3874
- if (!c || !_chunkST7E3NEEcjs.parseEffectColor.call(void 0, c.hex)) return void 0;
3880
+ if (!c || !_chunkPAOWHJ5Ocjs.parseEffectColor.call(void 0, c.hex)) return void 0;
3875
3881
  const a = c.alpha * opacity;
3876
3882
  return a !== 1 ? { type: "color", color: c.hex, opacity: a } : { type: "color", color: c.hex };
3877
3883
  }
3878
3884
  function shapeFromAnnotation(a) {
3879
3885
  const opacity = _nullishCoalesce(a.opacity, () => ( 1));
3880
3886
  const lineWidth = "strokeWidth" in a && a.strokeWidth > 0 ? a.strokeWidth : 1;
3881
- const rotation = a.rotation ? _chunkLPLCWZTMcjs.rotateMatrix.call(void 0, a.rotation, { x: a.x, y: a.y }) : void 0;
3887
+ const rotation = a.rotation ? _chunkFODKPD44cjs.rotateMatrix.call(void 0, a.rotation, { x: a.x, y: a.y }) : void 0;
3882
3888
  const t = rotation ? { transform: rotation } : {};
3883
3889
  const live = (l) => liveComponent(l);
3884
3890
  switch (a.type) {
@@ -3921,7 +3927,7 @@ function shapeFromAnnotation(a) {
3921
3927
  case "pen": {
3922
3928
  const paint = annotationPaint(a.strokeColor, opacity);
3923
3929
  if (!paint) return null;
3924
- const pts = rotation ? a.points.map((p) => _chunkLPLCWZTMcjs.applyMatrix.call(void 0, rotation, p)) : a.points;
3930
+ const pts = rotation ? a.points.map((p) => _chunkFODKPD44cjs.applyMatrix.call(void 0, rotation, p)) : a.points;
3925
3931
  const subpaths = pts.length > 1 ? [{ closed: false, anchors: pts.map((p) => ({ x: p.x, y: p.y })) }] : [];
3926
3932
  return {
3927
3933
  components: [{ op: "combine", subpaths }],
@@ -3952,9 +3958,9 @@ function annotationOfShape(layer) {
3952
3958
  var fail3 = (message) => {
3953
3959
  throw new LayerOperationError(message);
3954
3960
  };
3955
- var TEXT_RENDER_MARGIN = _chunkST7E3NEEcjs.MAX_EFFECT_REACH;
3961
+ var TEXT_RENDER_MARGIN = _chunkPAOWHJ5Ocjs.MAX_EFFECT_REACH;
3956
3962
  function textMatrix(layer) {
3957
- return _nullishCoalesce(layer.transform, () => ( _chunkLPLCWZTMcjs.IDENTITY_MATRIX));
3963
+ return _nullishCoalesce(layer.transform, () => ( _chunkFODKPD44cjs.IDENTITY_MATRIX));
3958
3964
  }
3959
3965
  function rectCorners(r) {
3960
3966
  return [
@@ -3965,7 +3971,7 @@ function rectCorners(r) {
3965
3971
  ];
3966
3972
  }
3967
3973
  function docRect(r, m) {
3968
- const pts = rectCorners(r).map((p) => _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, p));
3974
+ const pts = rectCorners(r).map((p) => _chunkFODKPD44cjs.applyMatrix.call(void 0, m, p));
3969
3975
  const x0 = Math.floor(Math.min(...pts.map((p) => p.x)));
3970
3976
  const y0 = Math.floor(Math.min(...pts.map((p) => p.y)));
3971
3977
  const x1 = Math.ceil(Math.max(...pts.map((p) => p.x)));
@@ -3998,14 +4004,14 @@ function inkBounds(layout) {
3998
4004
  }
3999
4005
  function textOutlines(layer, shaper) {
4000
4006
  if (!shaper.outline) fail3(`The text shaper "${shaper.id}" cannot give glyph outlines; plug in an outline shaper (createOutlineTextShaper) to convert text to shapes.`);
4001
- const layout = _chunkLPLCWZTMcjs.layoutText.call(void 0, layer, shaper);
4007
+ const layout = _chunkFODKPD44cjs.layoutText.call(void 0, layer, shaper);
4002
4008
  const m = textMatrix(layer);
4003
4009
  const out = [];
4004
4010
  for (const l of layout.lines) {
4005
4011
  for (const f of l.fragments) {
4006
- let path = _chunkLPLCWZTMcjs.textFragmentOutline.call(void 0, shaper, layer.text, f);
4007
- for (const r of _chunkLPLCWZTMcjs.textDecorations.call(void 0, f, l)) path = [...path, ..._chunkLPLCWZTMcjs.textRectPath.call(void 0, r)];
4008
- out.push({ fragment: f, path: _chunkLPLCWZTMcjs.isIdentityMatrix.call(void 0, m) ? path : _chunkXGD3FSNCcjs.transformBezierPath.call(void 0, path, m) });
4012
+ let path = _chunkFODKPD44cjs.textFragmentOutline.call(void 0, shaper, layer.text, f);
4013
+ for (const r of _chunkFODKPD44cjs.textDecorations.call(void 0, f, l)) path = [...path, ..._chunkFODKPD44cjs.textRectPath.call(void 0, r)];
4014
+ out.push({ fragment: f, path: _chunkFODKPD44cjs.isIdentityMatrix.call(void 0, m) ? path : _chunkXGD3FSNCcjs.transformBezierPath.call(void 0, path, m) });
4009
4015
  }
4010
4016
  }
4011
4017
  return out;
@@ -4061,7 +4067,7 @@ function renderOnCanvas(layer, shaper, region, env) {
4061
4067
  const canvas = env.createCanvas(region.width, region.height);
4062
4068
  const ctx = canvas.getContext("2d");
4063
4069
  if (!ctx || typeof ctx.getImageData !== "function") return null;
4064
- const layout = _chunkLPLCWZTMcjs.layoutText.call(void 0, layer, shaper);
4070
+ const layout = _chunkFODKPD44cjs.layoutText.call(void 0, layer, shaper);
4065
4071
  const m = textMatrix(layer);
4066
4072
  ctx.setTransform(1, 0, 0, 1, 0, 0);
4067
4073
  ctx.clearRect(0, 0, region.width, region.height);
@@ -4073,8 +4079,8 @@ function renderOnCanvas(layer, shaper, region, env) {
4073
4079
  ctx.globalAlpha = _nullishCoalesce(f.style.opacity, () => ( 1));
4074
4080
  const s = layer.text.slice(f.start, f.end);
4075
4081
  if (!f.spaced) shaper.draw(ctx, s, f.font, f.x, f.y);
4076
- else for (let k = 0; k < s.length; k++) if (!_chunkLPLCWZTMcjs.isTextSpace.call(void 0, s[k])) shaper.draw(ctx, s[k], f.font, f.x + f.carets[k], f.y);
4077
- for (const d of _chunkLPLCWZTMcjs.textDecorations.call(void 0, f, l)) ctx.fillRect(d.x, d.y, d.width, d.height);
4082
+ else for (let k = 0; k < s.length; k++) if (!_chunkFODKPD44cjs.isTextSpace.call(void 0, s[k])) shaper.draw(ctx, s[k], f.font, f.x + f.carets[k], f.y);
4083
+ for (const d of _chunkFODKPD44cjs.textDecorations.call(void 0, f, l)) ctx.fillRect(d.x, d.y, d.width, d.height);
4078
4084
  }
4079
4085
  }
4080
4086
  ctx.globalAlpha = 1;
@@ -4085,7 +4091,7 @@ function renderOnCanvas(layer, shaper, region, env) {
4085
4091
  function renderText(layer, env) {
4086
4092
  const shaper = env.shaper;
4087
4093
  if (!shaper || !shaper.outline && !shaper.draw) return null;
4088
- const layout = _chunkLPLCWZTMcjs.layoutText.call(void 0, layer, shaper);
4094
+ const layout = _chunkFODKPD44cjs.layoutText.call(void 0, layer, shaper);
4089
4095
  const ink = inkBounds(layout);
4090
4096
  const clip = { x: -TEXT_RENDER_MARGIN, y: -TEXT_RENDER_MARGIN, width: env.width + 2 * TEXT_RENDER_MARGIN, height: env.height + 2 * TEXT_RENDER_MARGIN };
4091
4097
  const region = ink ? intersect2(docRect(ink, textMatrix(layer)), clip) : null;
@@ -4180,7 +4186,7 @@ function patchParagraphStyle(base, patch, path = "paragraph") {
4180
4186
  continue;
4181
4187
  }
4182
4188
  const value = k === "autoLeading" ? num(v, `${path}.${k}`, 0.1, 10) : num(v, `${path}.${k}`, -1e4, 1e4);
4183
- if (k === "autoLeading" && value === _chunkLPLCWZTMcjs.DEFAULT_AUTO_LEADING || k !== "autoLeading" && value === 0) delete o[k];
4189
+ if (k === "autoLeading" && value === _chunkFODKPD44cjs.DEFAULT_AUTO_LEADING || k !== "autoLeading" && value === 0) delete o[k];
4184
4190
  else o[k] = value;
4185
4191
  } else fail3(`${path}.${k} is not a paragraph style field; use ${PARAGRAPH_STYLE_FIELDS.join(", ")}.`);
4186
4192
  }
@@ -4217,14 +4223,14 @@ function createTypeLayer(init, env, id = newLayerId(), lenient = false) {
4217
4223
  opacity: 1,
4218
4224
  blend: "normal",
4219
4225
  text: text3,
4220
- runs: _chunkLPLCWZTMcjs.fitRuns.call(void 0, init.runs, text3.length, _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE),
4221
- paragraphs: _chunkLPLCWZTMcjs.fitParagraphRuns.call(void 0, _nullishCoalesce(init.paragraphs, () => ( [{ length: text3.length, style: {} }])), text3),
4226
+ runs: _chunkFODKPD44cjs.fitRuns.call(void 0, init.runs, text3.length, _chunkFODKPD44cjs.DEFAULT_TEXT_STYLE),
4227
+ paragraphs: _chunkFODKPD44cjs.fitParagraphRuns.call(void 0, _nullishCoalesce(init.paragraphs, () => ( [{ length: text3.length, style: {} }])), text3),
4222
4228
  frame: init.frame,
4223
4229
  surface: _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4),
4224
4230
  offset: { x: 0, y: 0 }
4225
4231
  };
4226
- if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _62 => _62.runs, 'access', _63 => _63[0], 'optionalAccess', _64 => _64.style]), () => ( _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE)) }];
4227
- if (init.transform && !_chunkLPLCWZTMcjs.isIdentityMatrix.call(void 0, init.transform)) layer.transform = init.transform;
4232
+ if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _62 => _62.runs, 'access', _63 => _63[0], 'optionalAccess', _64 => _64.style]), () => ( _chunkFODKPD44cjs.DEFAULT_TEXT_STYLE)) }];
4233
+ if (init.transform && !_chunkFODKPD44cjs.isIdentityMatrix.call(void 0, init.transform)) layer.transform = init.transform;
4228
4234
  if (lenient && !renderText(layer, env)) return { ...layer, rendering: "stored" };
4229
4235
  return rerenderText(layer, env);
4230
4236
  }
@@ -4234,24 +4240,24 @@ function updateTypeLayer(layers, id, change, env, action = "edit it") {
4234
4240
  const patch = change(current);
4235
4241
  const next = { ...current, ...patch };
4236
4242
  if (!("annotation" in patch)) delete next.annotation;
4237
- if ("text" in patch || "runs" in patch) next.runs = _chunkLPLCWZTMcjs.fitRuns.call(void 0, next.runs, next.text.length, _nullishCoalesce(_optionalChain([current, 'access', _65 => _65.runs, 'access', _66 => _66[0], 'optionalAccess', _67 => _67.style]), () => ( _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE)));
4238
- if (!next.runs.length) next.runs = [{ length: 0, style: _chunkLPLCWZTMcjs.styleAt.call(void 0, current.runs, 0, _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE) }];
4239
- if ("text" in patch || "paragraphs" in patch) next.paragraphs = _chunkLPLCWZTMcjs.fitParagraphRuns.call(void 0, next.paragraphs, next.text);
4243
+ if ("text" in patch || "runs" in patch) next.runs = _chunkFODKPD44cjs.fitRuns.call(void 0, next.runs, next.text.length, _nullishCoalesce(_optionalChain([current, 'access', _65 => _65.runs, 'access', _66 => _66[0], 'optionalAccess', _67 => _67.style]), () => ( _chunkFODKPD44cjs.DEFAULT_TEXT_STYLE)));
4244
+ if (!next.runs.length) next.runs = [{ length: 0, style: _chunkFODKPD44cjs.styleAt.call(void 0, current.runs, 0, _chunkFODKPD44cjs.DEFAULT_TEXT_STYLE) }];
4245
+ if ("text" in patch || "paragraphs" in patch) next.paragraphs = _chunkFODKPD44cjs.fitParagraphRuns.call(void 0, next.paragraphs, next.text);
4240
4246
  const rendered = rerenderText(next, env);
4241
- return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
4247
+ return { layers: _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
4242
4248
  }
4243
4249
  function replaceTextRange(layer, start, end, insert) {
4244
4250
  const text3 = layer.text.slice(0, start) + insert + layer.text.slice(end);
4245
- const style = _chunkLPLCWZTMcjs.styleAt.call(void 0, layer.runs, start > 0 && start === layer.text.length ? start - 1 : start, _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE);
4246
- const runs = _chunkLPLCWZTMcjs.spliceRuns.call(void 0, layer.runs, start, end, insert.length, style);
4247
- const pstyle = _chunkLPLCWZTMcjs.styleAt.call(void 0, layer.paragraphs, start, {});
4248
- const paragraphs = _chunkLPLCWZTMcjs.spliceRuns.call(void 0, layer.paragraphs, start, end, insert.length, pstyle);
4249
- return { text: text3, runs, paragraphs: _chunkLPLCWZTMcjs.fitParagraphRuns.call(void 0, paragraphs, text3) };
4251
+ const style = _chunkFODKPD44cjs.styleAt.call(void 0, layer.runs, start > 0 && start === layer.text.length ? start - 1 : start, _chunkFODKPD44cjs.DEFAULT_TEXT_STYLE);
4252
+ const runs = _chunkFODKPD44cjs.spliceRuns.call(void 0, layer.runs, start, end, insert.length, style);
4253
+ const pstyle = _chunkFODKPD44cjs.styleAt.call(void 0, layer.paragraphs, start, {});
4254
+ const paragraphs = _chunkFODKPD44cjs.spliceRuns.call(void 0, layer.paragraphs, start, end, insert.length, pstyle);
4255
+ return { text: text3, runs, paragraphs: _chunkFODKPD44cjs.fitParagraphRuns.call(void 0, paragraphs, text3) };
4250
4256
  }
4251
4257
  function transformTypeLayer(layer, m) {
4252
- const t = _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, textMatrix(layer), m);
4258
+ const t = _chunkFODKPD44cjs.multiplyMatrices.call(void 0, textMatrix(layer), m);
4253
4259
  const next = { ...layer };
4254
- if (_chunkLPLCWZTMcjs.isIdentityMatrix.call(void 0, t)) delete next.transform;
4260
+ if (_chunkFODKPD44cjs.isIdentityMatrix.call(void 0, t)) delete next.transform;
4255
4261
  else next.transform = t;
4256
4262
  delete next.annotation;
4257
4263
  return next;
@@ -4259,7 +4265,7 @@ function transformTypeLayer(layer, m) {
4259
4265
  function typeFrame(layer, shaper) {
4260
4266
  if (layer.frame.kind === "box") return { x: 0, y: 0, width: layer.frame.width, height: layer.frame.height };
4261
4267
  if (!shaper) return fail3("Type layers need a text shaper to be measured; none is set here.");
4262
- const b = _chunkLPLCWZTMcjs.layoutText.call(void 0, layer, shaper).bounds;
4268
+ const b = _chunkFODKPD44cjs.layoutText.call(void 0, layer, shaper).bounds;
4263
4269
  return { x: b.x, y: b.y, width: Math.max(b.width, 1), height: Math.max(b.height, 1) };
4264
4270
  }
4265
4271
  function typeAsPixelLayer(layer) {
@@ -4267,7 +4273,7 @@ function typeAsPixelLayer(layer) {
4267
4273
  return { ...rest, type: "pixel", surface: layer.surface, offset: { x: 0, y: 0 } };
4268
4274
  }
4269
4275
  function toTextSpace(layer, p) {
4270
- return _chunkLPLCWZTMcjs.applyMatrix.call(void 0, _chunkLPLCWZTMcjs.invertMatrix.call(void 0, textMatrix(layer)), p);
4276
+ return _chunkFODKPD44cjs.applyMatrix.call(void 0, _chunkFODKPD44cjs.invertMatrix.call(void 0, textMatrix(layer)), p);
4271
4277
  }
4272
4278
  function typeFromAnnotation(a) {
4273
4279
  if (a.type !== "text") return null;
@@ -4281,7 +4287,7 @@ function typeFromAnnotation(a) {
4281
4287
  if (op !== 1) style.opacity = op;
4282
4288
  const text3 = t.text.replace(/\r?\n|\r/g, " ");
4283
4289
  const translate = [1, 0, 0, 1, t.x, t.y];
4284
- const transform = t.rotation ? _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, translate, _chunkLPLCWZTMcjs.rotateMatrix.call(void 0, t.rotation, { x: t.x, y: t.y })) : translate;
4290
+ const transform = t.rotation ? _chunkFODKPD44cjs.multiplyMatrices.call(void 0, translate, _chunkFODKPD44cjs.rotateMatrix.call(void 0, t.rotation, { x: t.x, y: t.y })) : translate;
4285
4291
  return { text: text3, runs: [{ length: text3.length, style }], frame: { kind: "point", origin: "top" }, transform };
4286
4292
  }
4287
4293
  function annotationOfType(layer) {
@@ -4611,34 +4617,34 @@ function isTransformAnchor(value) {
4611
4617
  return typeof value === "string" && value in ANCHOR_FRACTION;
4612
4618
  }
4613
4619
  function identityTransform(box2) {
4614
- return { box: { ...box2 }, corners: _chunkMUUXNRU4cjs.boxQuad.call(void 0, box2) };
4620
+ return { box: { ...box2 }, corners: _chunkEJVDBITDcjs.boxQuad.call(void 0, box2) };
4615
4621
  }
4616
4622
  function cornersFromMatrix(box2, m) {
4617
- const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, box2);
4618
- return [_chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[0]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[1]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[2]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[3])];
4623
+ const q2 = _chunkEJVDBITDcjs.boxQuad.call(void 0, box2);
4624
+ return [_chunkFODKPD44cjs.applyMatrix.call(void 0, m, q2[0]), _chunkFODKPD44cjs.applyMatrix.call(void 0, m, q2[1]), _chunkFODKPD44cjs.applyMatrix.call(void 0, m, q2[2]), _chunkFODKPD44cjs.applyMatrix.call(void 0, m, q2[3])];
4619
4625
  }
4620
4626
  function matrixFromCorners(box2, corners, eps = 1e-6) {
4621
4627
  const [tl, tr, br, bl] = corners;
4622
4628
  const size = 1 + Math.max(box2.width, box2.height);
4623
4629
  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;
4624
- const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, box2, corners);
4625
- return h ? _chunkMUUXNRU4cjs.affineFromHomography.call(void 0, h, 1e-9) : null;
4630
+ const h = _chunkEJVDBITDcjs.rectToQuad.call(void 0, box2, corners);
4631
+ return h ? _chunkEJVDBITDcjs.affineFromHomography.call(void 0, h, 1e-9) : null;
4626
4632
  }
4627
4633
  function transformHomography(geometry) {
4628
- const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
4634
+ const h = _chunkEJVDBITDcjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
4629
4635
  if (!h) return null;
4630
- return _chunkMUUXNRU4cjs.homographyKeepsQuad.call(void 0, h, _chunkMUUXNRU4cjs.boxQuad.call(void 0, geometry.box)) ? h : null;
4636
+ return _chunkEJVDBITDcjs.homographyKeepsQuad.call(void 0, h, _chunkEJVDBITDcjs.boxQuad.call(void 0, geometry.box)) ? h : null;
4631
4637
  }
4632
4638
  function hasWarp(geometry) {
4633
4639
  const w = geometry.warp;
4634
4640
  if (!w) return false;
4635
- const id = _chunkLPLCWZTMcjs.identityWarpMesh.call(void 0, geometry.box, w.us.length - 1, w.vs.length - 1);
4641
+ const id = _chunkFODKPD44cjs.identityWarpMesh.call(void 0, geometry.box, w.us.length - 1, w.vs.length - 1);
4636
4642
  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;
4637
4643
  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);
4638
4644
  }
4639
4645
  function isIdentityTransform(geometry) {
4640
4646
  if (hasWarp(geometry)) return false;
4641
- const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, geometry.box);
4647
+ const q2 = _chunkEJVDBITDcjs.boxQuad.call(void 0, geometry.box);
4642
4648
  return geometry.corners.every((c, i) => Math.abs(c.x - q2[i].x) < 1e-6 && Math.abs(c.y - q2[i].y) < 1e-6);
4643
4649
  }
4644
4650
  function transformMap(geometry) {
@@ -4646,8 +4652,8 @@ function transformMap(geometry) {
4646
4652
  if (!h) return null;
4647
4653
  const { box: box2 } = geometry;
4648
4654
  const warp = hasWarp(geometry) ? geometry.warp : null;
4649
- if (!warp) return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p);
4650
- return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, _chunkLPLCWZTMcjs.evalWarpMesh.call(void 0, warp, (p.x - box2.x) / box2.width, (p.y - box2.y) / box2.height));
4655
+ if (!warp) return (p) => _chunkEJVDBITDcjs.applyHomography.call(void 0, h, p);
4656
+ return (p) => _chunkEJVDBITDcjs.applyHomography.call(void 0, h, _chunkFODKPD44cjs.evalWarpMesh.call(void 0, warp, (p.x - box2.x) / box2.width, (p.y - box2.y) / box2.height));
4651
4657
  }
4652
4658
  function transformedPoint(geometry, fx, fy) {
4653
4659
  const f = transformMap(geometry);
@@ -4656,9 +4662,9 @@ function transformedPoint(geometry, fx, fy) {
4656
4662
  }
4657
4663
  function anchorPoint(geometry, anchor) {
4658
4664
  const [fx, fy] = ANCHOR_FRACTION[anchor];
4659
- const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
4665
+ const h = _chunkEJVDBITDcjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
4660
4666
  const p = { x: geometry.box.x + fx * geometry.box.width, y: geometry.box.y + fy * geometry.box.height };
4661
- return _nullishCoalesce((h && _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p)), () => ( p));
4667
+ return _nullishCoalesce((h && _chunkEJVDBITDcjs.applyHomography.call(void 0, h, p)), () => ( p));
4662
4668
  }
4663
4669
  function transformedBox(geometry) {
4664
4670
  const f = transformMap(geometry);
@@ -4691,16 +4697,16 @@ function matrixFromParams(box2, params) {
4691
4697
  const tx = Math.tan((_nullishCoalesce(params.skewX, () => ( 0))) * Math.PI / 180);
4692
4698
  const ty = Math.tan((_nullishCoalesce(params.skewY, () => ( 0))) * Math.PI / 180);
4693
4699
  const ref = referencePoint(box2, params.reference);
4694
- const linear = _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, [1, ty, tx, 1, 0, 0], [sx, 0, 0, sy, 0, 0]), _chunkLPLCWZTMcjs.rotateMatrix.call(void 0, _nullishCoalesce(params.rotate, () => ( 0))));
4695
- return _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, _chunkLPLCWZTMcjs.matrixAbout.call(void 0, linear, ref), _chunkLPLCWZTMcjs.translateMatrix.call(void 0, _nullishCoalesce(params.dx, () => ( 0)), _nullishCoalesce(params.dy, () => ( 0))));
4700
+ const linear = _chunkFODKPD44cjs.multiplyMatrices.call(void 0, _chunkFODKPD44cjs.multiplyMatrices.call(void 0, [1, ty, tx, 1, 0, 0], [sx, 0, 0, sy, 0, 0]), _chunkFODKPD44cjs.rotateMatrix.call(void 0, _nullishCoalesce(params.rotate, () => ( 0))));
4701
+ return _chunkFODKPD44cjs.multiplyMatrices.call(void 0, _chunkFODKPD44cjs.matrixAbout.call(void 0, linear, ref), _chunkFODKPD44cjs.translateMatrix.call(void 0, _nullishCoalesce(params.dx, () => ( 0)), _nullishCoalesce(params.dy, () => ( 0))));
4696
4702
  }
4697
4703
  function describeTransform(geometry, reference = "center") {
4698
4704
  const m = hasWarp(geometry) ? null : matrixFromCorners(geometry.box, geometry.corners);
4699
4705
  const ref = referencePoint(geometry.box, reference);
4700
4706
  const bounds = transformedBox(geometry);
4701
4707
  if (!m) {
4702
- const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
4703
- const at2 = _nullishCoalesce((h && _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, ref)), () => ( ref));
4708
+ const h = _chunkEJVDBITDcjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
4709
+ const at2 = _nullishCoalesce((h && _chunkEJVDBITDcjs.applyHomography.call(void 0, h, ref)), () => ( ref));
4704
4710
  return { affine: false, scaleX: 100, scaleY: 100, rotate: 0, skewX: 0, x: at2.x, y: at2.y, bounds, corners: geometry.corners };
4705
4711
  }
4706
4712
  const [a, b, c, d] = m;
@@ -4709,7 +4715,7 @@ function describeTransform(geometry, reference = "center") {
4709
4715
  const shear = sxAbs ? (a * c + b * d) / sxAbs : 0;
4710
4716
  const sy = sxAbs ? (a * d - b * c) / sxAbs : 0;
4711
4717
  const skew = sxAbs ? Math.atan(shear / sxAbs) * 180 / Math.PI : 0;
4712
- const at = _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, ref);
4718
+ const at = _chunkFODKPD44cjs.applyMatrix.call(void 0, m, ref);
4713
4719
  const clean = (v) => Math.abs(v) < 1e-9 ? 0 : v;
4714
4720
  return {
4715
4721
  affine: true,
@@ -4727,35 +4733,35 @@ function applyParams(geometry, params) {
4727
4733
  const ref = params.reference && typeof params.reference === "object" ? params.reference : anchorPoint(geometry, _nullishCoalesce(params.reference, () => ( "center")));
4728
4734
  const m = matrixFromParams({ x: ref.x, y: ref.y, width: 0, height: 0 }, { ...params, reference: ref });
4729
4735
  const c = geometry.corners;
4730
- return [_chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, c[0]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, c[1]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, c[2]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, c[3])];
4736
+ return [_chunkFODKPD44cjs.applyMatrix.call(void 0, m, c[0]), _chunkFODKPD44cjs.applyMatrix.call(void 0, m, c[1]), _chunkFODKPD44cjs.applyMatrix.call(void 0, m, c[2]), _chunkFODKPD44cjs.applyMatrix.call(void 0, m, c[3])];
4731
4737
  }
4732
4738
  function flipCorners(geometry, axis) {
4733
4739
  const c = anchorPoint(geometry, "center");
4734
4740
  const m = axis === "horizontal" ? [-1, 0, 0, 1, 2 * c.x, 0] : [1, 0, 0, -1, 0, 2 * c.y];
4735
4741
  const q2 = geometry.corners;
4736
- return [_chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[0]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[1]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[2]), _chunkLPLCWZTMcjs.applyMatrix.call(void 0, m, q2[3])];
4742
+ return [_chunkFODKPD44cjs.applyMatrix.call(void 0, m, q2[0]), _chunkFODKPD44cjs.applyMatrix.call(void 0, m, q2[1]), _chunkFODKPD44cjs.applyMatrix.call(void 0, m, q2[2]), _chunkFODKPD44cjs.applyMatrix.call(void 0, m, q2[3])];
4737
4743
  }
4738
4744
  function boxPointOf(geometry, p) {
4739
4745
  const m = matrixFromCorners(geometry.box, geometry.corners);
4740
- if (m) return _chunkLPLCWZTMcjs.applyMatrix.call(void 0, _chunkLPLCWZTMcjs.invertMatrix.call(void 0, m), p);
4746
+ if (m) return _chunkFODKPD44cjs.applyMatrix.call(void 0, _chunkFODKPD44cjs.invertMatrix.call(void 0, m), p);
4741
4747
  return null;
4742
4748
  }
4743
4749
  function presetWarp(box2, preset) {
4744
- return _chunkLPLCWZTMcjs.warpPresetMesh.call(void 0, preset, box2);
4750
+ return _chunkFODKPD44cjs.warpPresetMesh.call(void 0, preset, box2);
4745
4751
  }
4746
4752
  function isValidWarp(mesh) {
4747
- return _chunkLPLCWZTMcjs.isValidWarpMesh.call(void 0, mesh);
4753
+ return _chunkFODKPD44cjs.isValidWarpMesh.call(void 0, mesh);
4748
4754
  }
4749
4755
  function geometryHomography(geometry) {
4750
4756
  const m = matrixFromCorners(geometry.box, geometry.corners);
4751
- return m ? _chunkMUUXNRU4cjs.homographyFromAffine.call(void 0, m) : transformHomography(geometry);
4757
+ return m ? _chunkEJVDBITDcjs.homographyFromAffine.call(void 0, m) : transformHomography(geometry);
4752
4758
  }
4753
4759
 
4754
4760
  // src/image-editor/layers/smart.ts
4755
4761
  var fail4 = (message) => {
4756
4762
  throw new LayerOperationError(message);
4757
4763
  };
4758
- var SMART_RENDER_MARGIN = _chunkST7E3NEEcjs.MAX_EFFECT_REACH;
4764
+ var SMART_RENDER_MARGIN = _chunkPAOWHJ5Ocjs.MAX_EFFECT_REACH;
4759
4765
  function newContentsId() {
4760
4766
  return newLayerId("so");
4761
4767
  }
@@ -4766,7 +4772,7 @@ function placementGeometry(layer) {
4766
4772
  return { box: contentsBox(layer.contents), corners: layer.placement.corners, warp: _nullishCoalesce(layer.placement.warp, () => ( null)) };
4767
4773
  }
4768
4774
  function placementAt(contents, x, y) {
4769
- return { corners: _chunkMUUXNRU4cjs.boxQuad.call(void 0, { x, y, width: contents.width, height: contents.height }) };
4775
+ return { corners: _chunkEJVDBITDcjs.boxQuad.call(void 0, { x, y, width: contents.width, height: contents.height }) };
4770
4776
  }
4771
4777
  function isContentsDecoded(contents) {
4772
4778
  return contents.kind === "raster" ? Boolean(contents.raster) : Boolean(contents.document);
@@ -4821,7 +4827,7 @@ function placementKey(p, canvas) {
4821
4827
  function integerMove(layer) {
4822
4828
  const g = placementGeometry(layer);
4823
4829
  if (hasWarp(g)) return null;
4824
- const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, g.box);
4830
+ const q2 = _chunkEJVDBITDcjs.boxQuad.call(void 0, g.box);
4825
4831
  const dx = g.corners[0].x - q2[0].x;
4826
4832
  const dy = g.corners[0].y - q2[0].y;
4827
4833
  if (Math.abs(dx - Math.round(dx)) > 1e-9 || Math.abs(dy - Math.round(dy)) > 1e-9) return null;
@@ -4862,7 +4868,7 @@ function placeContents(layer, canvas, options = {}) {
4862
4868
  k = step;
4863
4869
  let r = _optionalChain([options, 'access', _84 => _84.reduced, 'optionalAccess', _85 => _85.get, 'call', _86 => _86(k)]);
4864
4870
  if (!r) {
4865
- r = _chunkST7E3NEEcjs.reduceSurface.call(void 0, src, k);
4871
+ r = _chunkPAOWHJ5Ocjs.reduceSurface.call(void 0, src, k);
4866
4872
  _optionalChain([options, 'access', _87 => _87.reduced, 'optionalAccess', _88 => _88.set, 'call', _89 => _89(k, r)]);
4867
4873
  }
4868
4874
  source = r;
@@ -4872,15 +4878,15 @@ function placeContents(layer, canvas, options = {}) {
4872
4878
  if (hasWarp(g)) {
4873
4879
  const f = transformMap(g);
4874
4880
  if (!f) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
4875
- out = _chunkST7E3NEEcjs.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 });
4881
+ out = _chunkPAOWHJ5Ocjs.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 });
4876
4882
  } else {
4877
4883
  const h = transformHomography(g);
4878
4884
  if (!h) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
4879
- const hk = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, [k, 0, 0, 0, k, 0, 0, 0, 1], h);
4880
- out = _chunkST7E3NEEcjs.transformSurface.call(void 0, source, hk, { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
4885
+ const hk = _chunkEJVDBITDcjs.multiplyHomographies.call(void 0, [k, 0, 0, 0, k, 0, 0, 0, 1], h);
4886
+ out = _chunkPAOWHJ5Ocjs.transformSurface.call(void 0, source, hk, { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
4881
4887
  }
4882
4888
  } catch (e) {
4883
- if (e instanceof _chunkST7E3NEEcjs.TransformTooLargeError) fail4(e.message);
4889
+ if (e instanceof _chunkPAOWHJ5Ocjs.TransformTooLargeError) fail4(e.message);
4884
4890
  throw e;
4885
4891
  }
4886
4892
  }
@@ -4912,7 +4918,7 @@ function filterMaskCoverage(mask, canvas) {
4912
4918
  }
4913
4919
  const feather = _nullishCoalesce(mask.feather, () => ( 0));
4914
4920
  if (all && !(feather > 0)) return null;
4915
- if (feather > 0) v = _chunkST7E3NEEcjs.gaussianBlur.call(void 0, v, W, H, feather, "clamp");
4921
+ if (feather > 0) v = _chunkPAOWHJ5Ocjs.gaussianBlur.call(void 0, v, W, H, feather, "clamp");
4916
4922
  const density = _nullishCoalesce(mask.density, () => ( 1));
4917
4923
  if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
4918
4924
  return v;
@@ -4934,7 +4940,7 @@ function applySmartFilters(placed, stack, canvas) {
4934
4940
  if (f.opacity >= 1) acc = out;
4935
4941
  else lerpInto(acc, out, f.opacity, null);
4936
4942
  } else {
4937
- _chunkST7E3NEEcjs.blendTile.call(void 0, acc, out, f.blend, f.opacity, null);
4943
+ _chunkPAOWHJ5Ocjs.blendTile.call(void 0, acc, out, f.blend, f.opacity, null);
4938
4944
  }
4939
4945
  }
4940
4946
  entry = { key, base, filtered: acc };
@@ -4977,11 +4983,11 @@ function normalizePlacement(raw, contents) {
4977
4983
  }
4978
4984
  const out = { corners: c.map((p) => ({ x: p.x, y: p.y })) };
4979
4985
  if (raw.warp) {
4980
- if (!_chunkLPLCWZTMcjs.isValidWarpMesh.call(void 0, raw.warp)) fail4("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.");
4986
+ if (!_chunkFODKPD44cjs.isValidWarpMesh.call(void 0, raw.warp)) fail4("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.");
4981
4987
  out.warp = { us: [...raw.warp.us], vs: [...raw.warp.vs], points: raw.warp.points.map((p) => ({ x: p.x, y: p.y })) };
4982
4988
  }
4983
4989
  if (raw.interpolation !== void 0) {
4984
- if (!_chunkST7E3NEEcjs.isInterpolation.call(void 0, raw.interpolation)) fail4(`Unknown interpolation "${String(raw.interpolation)}"; use nearest, bilinear or bicubic.`);
4990
+ if (!_chunkPAOWHJ5Ocjs.isInterpolation.call(void 0, raw.interpolation)) fail4(`Unknown interpolation "${String(raw.interpolation)}"; use nearest, bilinear or bicubic.`);
4985
4991
  if (raw.interpolation !== "bicubic") out.interpolation = raw.interpolation;
4986
4992
  }
4987
4993
  const g = { box: { x: 0, y: 0, width: contents.width, height: contents.height }, corners: out.corners, warp: _nullishCoalesce(out.warp, () => ( null)) };
@@ -4998,10 +5004,10 @@ function followMask(mask, before, after) {
4998
5004
  const h0 = placementHomography(before);
4999
5005
  const h1 = placementHomography(after);
5000
5006
  if (!h0 || !h1) return mask;
5001
- const inv = _chunkMUUXNRU4cjs.invertHomography.call(void 0, h0);
5007
+ const inv = _chunkEJVDBITDcjs.invertHomography.call(void 0, h0);
5002
5008
  if (!inv) return mask;
5003
- const delta = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, inv, h1);
5004
- const surface = _chunkST7E3NEEcjs.transformSurface.call(void 0, mask.surface, delta, { interpolation: "bilinear" });
5009
+ const delta = _chunkEJVDBITDcjs.multiplyHomographies.call(void 0, inv, h1);
5010
+ const surface = _chunkPAOWHJ5Ocjs.transformSurface.call(void 0, mask.surface, delta, { interpolation: "bilinear" });
5005
5011
  return { ...mask, surface };
5006
5012
  }
5007
5013
  function setSmartPlacement(layers, id, placement, canvas) {
@@ -5022,7 +5028,7 @@ function setSmartPlacement(layers, id, placement, canvas) {
5022
5028
  next.smartFilters = { ...next.smartFilters, mask: m };
5023
5029
  }
5024
5030
  next = rerender(next, canvas, "be transformed");
5025
- return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, masksMoved };
5031
+ return { layers: _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => next), layer: next, masksMoved };
5026
5032
  }
5027
5033
  function offsetSmartObject(layers, id, dx, dy, canvas) {
5028
5034
  const layer = requireSmartObject(layers, id);
@@ -5044,7 +5050,7 @@ function offsetSmartObject(layers, id, dx, dy, canvas) {
5044
5050
  } else {
5045
5051
  next = rerender(next, canvas, "move");
5046
5052
  }
5047
- return _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next);
5053
+ return _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => next);
5048
5054
  }
5049
5055
  function translateLayer(layer, dx, dy) {
5050
5056
  if (!dx && !dy) return layer;
@@ -5080,7 +5086,7 @@ function translateLayer(layer, dx, dy) {
5080
5086
  case "shape": {
5081
5087
  const next = {
5082
5088
  ...layer,
5083
- components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), _chunkLPLCWZTMcjs.translateMatrix.call(void 0, dx, dy)),
5089
+ components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), _chunkFODKPD44cjs.translateMatrix.call(void 0, dx, dy)),
5084
5090
  surface: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, layer.surface, dx, dy),
5085
5091
  mask: moveMask(layer.mask)
5086
5092
  };
@@ -5089,7 +5095,7 @@ function translateLayer(layer, dx, dy) {
5089
5095
  return next;
5090
5096
  }
5091
5097
  case "type": {
5092
- const next = { ...transformTypeLayer(layer, _chunkLPLCWZTMcjs.translateMatrix.call(void 0, dx, dy)), surface: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, layer.surface, dx, dy), mask: moveMask(layer.mask) };
5098
+ const next = { ...transformTypeLayer(layer, _chunkFODKPD44cjs.translateMatrix.call(void 0, dx, dy)), surface: _chunkTFOPHZ3Ucjs.translateSurface.call(void 0, layer.surface, dx, dy), mask: moveMask(layer.mask) };
5093
5099
  if (!next.mask) delete next.mask;
5094
5100
  return next;
5095
5101
  }
@@ -5112,7 +5118,7 @@ function layerExtent(layer, surfaceOf, canvas) {
5112
5118
  } else {
5113
5119
  b = full;
5114
5120
  }
5115
- const m = _chunkST7E3NEEcjs.effectsMargin.call(void 0, layer.effects);
5121
+ const m = _chunkPAOWHJ5Ocjs.effectsMargin.call(void 0, layer.effects);
5116
5122
  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) };
5117
5123
  return b;
5118
5124
  }
@@ -5181,7 +5187,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
5181
5187
  delete resolved.source;
5182
5188
  layer = resolved;
5183
5189
  }
5184
- if (_chunkST7E3NEEcjs.flattenLayers.call(void 0, [layer]).some((x) => x.type === "pixel" && x.source === "document")) fail4(`Layer "${layer.name || layer.id}" holds the document image inside a group; convert the Background on its own.`);
5190
+ if (_chunkPAOWHJ5Ocjs.flattenLayers.call(void 0, [layer]).some((x) => x.type === "pixel" && x.source === "document")) fail4(`Layer "${layer.name || layer.id}" holds the document image inside a group; convert the Background on its own.`);
5185
5191
  return translateLayer(layer, -b.x, -b.y);
5186
5192
  });
5187
5193
  if (nested[0].clipped) {
@@ -5208,8 +5214,8 @@ function convertToSmartObject(layers, ids, canvas, options) {
5208
5214
  smart = { ...smart, surface: renderSmartObject(smart, canvas) };
5209
5215
  const below = ordered.filter((l) => l.index < top.index).length;
5210
5216
  let out = layers;
5211
- for (const l of ordered) out = _chunkST7E3NEEcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
5212
- return { layers: _chunkST7E3NEEcjs.insertLayer.call(void 0, out, smart, parent, top.index - below), layer: smart };
5217
+ for (const l of ordered) out = _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, out, l.layer.id, () => null);
5218
+ return { layers: _chunkPAOWHJ5Ocjs.insertLayer.call(void 0, out, smart, parent, top.index - below), layer: smart };
5213
5219
  }
5214
5220
  function rasterizeSmartObject(layers, id) {
5215
5221
  const layer = requireSmartObject(layers, id);
@@ -5229,7 +5235,7 @@ function rasterizeSmartObject(layers, id) {
5229
5235
  if (layer.locks) out.locks = layer.locks;
5230
5236
  if (layer.effects) out.effects = layer.effects;
5231
5237
  if (layer.fillOpacity !== void 0) out.fillOpacity = layer.fillOpacity;
5232
- return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => out), layer: out };
5238
+ return { layers: _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => out), layer: out };
5233
5239
  }
5234
5240
  function copySmartObject(layers, id, linked, name) {
5235
5241
  const loc = requireLayer(layers, id);
@@ -5239,19 +5245,19 @@ function copySmartObject(layers, id, linked, name) {
5239
5245
  delete copy.psd;
5240
5246
  if (!linked) copy.contents = { ...layer.contents, id: newContentsId() };
5241
5247
  if (copy.smartFilters) copy.smartFilters = { ...copy.smartFilters, filters: copy.smartFilters.filters.map((f) => ({ ...f, id: newLayerId("flt") })) };
5242
- return { layers: _chunkST7E3NEEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _114 => _114.parent, 'optionalAccess', _115 => _115.id]), () => ( null)), loc.index + 1), layer: copy };
5248
+ return { layers: _chunkPAOWHJ5Ocjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _114 => _114.parent, 'optionalAccess', _115 => _115.id]), () => ( null)), loc.index + 1), layer: copy };
5243
5249
  }
5244
5250
  function instancesOf(layers, contentsId) {
5245
- return _chunkST7E3NEEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
5251
+ return _chunkPAOWHJ5Ocjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
5246
5252
  }
5247
5253
  function replaceContents(layers, contentsId, contents, canvas) {
5248
5254
  const ids = instancesOf(layers, contentsId);
5249
5255
  if (!ids.length) fail4(`No smart object uses contents "${contentsId}".`);
5250
- for (const id of ids) requireUnlocked(_chunkST7E3NEEcjs.findLayer.call(void 0, layers, id).layer, "all", "replace its contents");
5256
+ for (const id of ids) requireUnlocked(_chunkPAOWHJ5Ocjs.findLayer.call(void 0, layers, id).layer, "all", "replace its contents");
5251
5257
  const next = { ...contents, id: contentsId };
5252
5258
  let out = layers;
5253
5259
  for (const id of ids) {
5254
- out = _chunkST7E3NEEcjs.mapLayer.call(void 0, out, id, (l) => {
5260
+ out = _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, out, id, (l) => {
5255
5261
  const layer = l;
5256
5262
  return rerender({ ...layer, contents: next, placement: refitPlacement(layer, next) }, canvas, "take the new contents");
5257
5263
  });
@@ -5268,14 +5274,14 @@ function refitPlacement(layer, contents) {
5268
5274
  const h = transformHomography(g);
5269
5275
  if (!h) return placementAt(contents, 0, 0);
5270
5276
  const shift = [1, 0, (W0 - W1) / 2, 0, 1, (H0 - H1) / 2, 0, 0, 1];
5271
- const hn = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, shift, h);
5272
- const pts = _chunkMUUXNRU4cjs.boxQuad.call(void 0, { x: 0, y: 0, width: W1, height: H1 }).map((p) => {
5277
+ const hn = _chunkEJVDBITDcjs.multiplyHomographies.call(void 0, shift, h);
5278
+ const pts = _chunkEJVDBITDcjs.boxQuad.call(void 0, { x: 0, y: 0, width: W1, height: H1 }).map((p) => {
5273
5279
  const w = hn[6] * p.x + hn[7] * p.y + hn[8];
5274
5280
  return { x: (hn[0] * p.x + hn[1] * p.y + hn[2]) / w, y: (hn[3] * p.x + hn[4] * p.y + hn[5]) / w };
5275
5281
  });
5276
5282
  const out = { corners: pts };
5277
5283
  if (layer.placement.interpolation) out.interpolation = layer.placement.interpolation;
5278
- if (layer.placement.warp) out.warp = _chunkLPLCWZTMcjs.mapWarpMeshPoints.call(void 0, layer.placement.warp, (p) => ({ x: p.x * W1 / W0, y: p.y * H1 / H0 }));
5284
+ if (layer.placement.warp) out.warp = _chunkFODKPD44cjs.mapWarpMeshPoints.call(void 0, layer.placement.warp, (p) => ({ x: p.x * W1 / W0, y: p.y * H1 / H0 }));
5279
5285
  return out;
5280
5286
  }
5281
5287
  function normalizeSmartFilter(raw, id = newLayerId("flt")) {
@@ -5314,7 +5320,7 @@ function addSmartFilter(layers, id, filter, canvas, index) {
5314
5320
  const at = index === void 0 ? filters.length : Math.max(0, Math.min(filters.length, Math.floor(index)));
5315
5321
  filters.splice(at, 0, filter);
5316
5322
  const next = withStack(layer, { ...stack, filters }, canvas);
5317
- return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter };
5323
+ return { layers: _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter };
5318
5324
  }
5319
5325
  function updateSmartFilter(layers, id, filterId, changes, canvas) {
5320
5326
  const layer = editableSmart(layers, id);
@@ -5336,7 +5342,7 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
5336
5342
  const filters = [...layer.smartFilters.filters];
5337
5343
  filters[i] = merged2;
5338
5344
  const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
5339
- return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter: merged2 };
5345
+ return { layers: _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter: merged2 };
5340
5346
  }
5341
5347
  function removeSmartFilter(layers, id, filterId, canvas) {
5342
5348
  const layer = editableSmart(layers, id);
@@ -5344,7 +5350,7 @@ function removeSmartFilter(layers, id, filterId, canvas) {
5344
5350
  const stack = layer.smartFilters;
5345
5351
  const filters = stack.filters.filter((f) => f.id !== filterId);
5346
5352
  const next = withStack(layer, filters.length ? { ...stack, filters } : stack.enabled ? void 0 : { enabled: false, filters }, canvas);
5347
- return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5353
+ return { layers: _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5348
5354
  }
5349
5355
  function moveSmartFilter(layers, id, filterId, index, canvas) {
5350
5356
  const layer = editableSmart(layers, id);
@@ -5355,12 +5361,12 @@ function moveSmartFilter(layers, id, filterId, index, canvas) {
5355
5361
  const [f] = filters.splice(i, 1);
5356
5362
  filters.splice(index, 0, f);
5357
5363
  const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
5358
- return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5364
+ return { layers: _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5359
5365
  }
5360
5366
  function setSmartFiltersEnabled(layers, id, enabled, canvas) {
5361
5367
  const layer = editableSmart(layers, id);
5362
5368
  const next = withStack(layer, { ...stackOf(layer), enabled: Boolean(enabled) }, canvas);
5363
- return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5369
+ return { layers: _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5364
5370
  }
5365
5371
  function setSmartFilterMask(layers, id, mask, canvas) {
5366
5372
  const layer = editableSmart(layers, id);
@@ -5369,7 +5375,7 @@ function setSmartFilterMask(layers, id, mask, canvas) {
5369
5375
  if (mask) stack.mask = mask;
5370
5376
  else delete stack.mask;
5371
5377
  const next = withStack(layer, stack, canvas);
5372
- return { layers: _chunkST7E3NEEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5378
+ return { layers: _chunkPAOWHJ5Ocjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
5373
5379
  }
5374
5380
  function withFilterMaskSurface(layer, surface, canvas) {
5375
5381
  const stack = stackOf(layer);
@@ -5383,7 +5389,7 @@ function placementBounds(layer) {
5383
5389
  // src/image-editor/layers/serialize.ts
5384
5390
  var LAYERED_SCHEMA_VERSION = 3;
5385
5391
  function serializePatterns(patterns) {
5386
- return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkST7E3NEEcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
5392
+ return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkEJVDBITDcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
5387
5393
  }
5388
5394
  function deserializePatterns(raw, problems = []) {
5389
5395
  if (!Array.isArray(raw)) return [];
@@ -5406,7 +5412,7 @@ function encodeSurface(surface) {
5406
5412
  let out = null;
5407
5413
  if (b) {
5408
5414
  const data = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, surface, b);
5409
- out = { url: _chunkST7E3NEEcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
5415
+ out = { url: _chunkEJVDBITDcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
5410
5416
  }
5411
5417
  encodedCache.set(surface, out);
5412
5418
  return out;
@@ -5415,15 +5421,15 @@ var deepCache = /* @__PURE__ */ new WeakMap();
5415
5421
  function encodeDeepSurface(surface) {
5416
5422
  if (deepCache.has(surface)) return deepCache.get(surface);
5417
5423
  let out = null;
5418
- const depth = _chunkST7E3NEEcjs.surfaceDepth.call(void 0, surface);
5424
+ const depth = _chunkPAOWHJ5Ocjs.surfaceDepth.call(void 0, surface);
5419
5425
  const b = depth === 8 ? null : _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, surface);
5420
5426
  if (depth !== 8 && b) {
5421
- const samples = _chunkST7E3NEEcjs.readDeepRegion.call(void 0, surface, b, depth);
5427
+ const samples = _chunkPAOWHJ5Ocjs.readDeepRegion.call(void 0, surface, b, depth);
5422
5428
  const bytes = new Uint8Array(samples.byteLength);
5423
5429
  const view = new DataView(bytes.buffer);
5424
5430
  if (samples instanceof Uint16Array) for (let i = 0; i < samples.length; i++) view.setUint16(2 * i, samples[i], true);
5425
5431
  else for (let i = 0; i < samples.length; i++) view.setFloat32(4 * i, samples[i], true);
5426
- out = { depth, x: b.x, y: b.y, width: b.width, height: b.height, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, _chunk643B2HKCcjs.deflate.call(void 0, bytes)) };
5432
+ out = { depth, x: b.x, y: b.y, width: b.width, height: b.height, data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, _chunk643B2HKCcjs.deflate.call(void 0, bytes)) };
5427
5433
  }
5428
5434
  deepCache.set(surface, out);
5429
5435
  return out;
@@ -5435,13 +5441,13 @@ function decodeDeepSurface(surface, raw, problems, label) {
5435
5441
  if (d.depth !== 16 && d.depth !== 32 || !(d.width > 0 && d.height > 0) || !Number.isInteger(d.x) || !Number.isInteger(d.y) || typeof d.data !== "string") throw new Error("malformed");
5436
5442
  const n = d.width * d.height * 4;
5437
5443
  const size = d.depth === 16 ? 2 : 4;
5438
- const bytes = _chunk643B2HKCcjs.inflate.call(void 0, _chunkST7E3NEEcjs.base64ToBytes.call(void 0, d.data), { maxOutput: n * size });
5444
+ const bytes = _chunk643B2HKCcjs.inflate.call(void 0, _chunkEJVDBITDcjs.base64ToBytes.call(void 0, d.data), { maxOutput: n * size });
5439
5445
  if (bytes.length !== n * size) throw new Error("wrong length");
5440
5446
  const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
5441
5447
  const samples = d.depth === 16 ? new Uint16Array(n) : new Float32Array(n);
5442
5448
  if (samples instanceof Uint16Array) for (let i = 0; i < n; i++) samples[i] = view.getUint16(2 * i, true);
5443
5449
  else for (let i = 0; i < n; i++) samples[i] = view.getFloat32(4 * i, true);
5444
- return _chunkST7E3NEEcjs.writeDeepRegion.call(void 0, surface, { x: d.x, y: d.y, width: d.width, height: d.height }, samples);
5450
+ return _chunkPAOWHJ5Ocjs.writeDeepRegion.call(void 0, surface, { x: d.x, y: d.y, width: d.width, height: d.height }, samples);
5445
5451
  } catch (e6) {
5446
5452
  problems.push(`${label}: its ${d.depth}-bit samples could not be read, so it was opened at 8 bits`);
5447
5453
  return surface;
@@ -5464,7 +5470,7 @@ function baseFields(layer, ctx) {
5464
5470
  function serializeEffects(effects) {
5465
5471
  const out = { enabled: effects.enabled, items: JSON.parse(JSON.stringify(effects.items)) };
5466
5472
  if (effects.scale !== void 0 && effects.scale !== 1) out.scale = effects.scale;
5467
- if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, effects.psd.data) };
5473
+ if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, effects.psd.data) };
5468
5474
  return out;
5469
5475
  }
5470
5476
  function deserializeEffects(raw) {
@@ -5474,12 +5480,12 @@ function deserializeEffects(raw) {
5474
5480
  const p = r.psd;
5475
5481
  if (p && typeof p.key === "string" && typeof p.data === "string") {
5476
5482
  try {
5477
- psd = { key: p.key, data: _chunkST7E3NEEcjs.base64ToBytes.call(void 0, p.data) };
5483
+ psd = { key: p.key, data: _chunkEJVDBITDcjs.base64ToBytes.call(void 0, p.data) };
5478
5484
  } catch (e7) {
5479
5485
  psd = void 0;
5480
5486
  }
5481
5487
  }
5482
- return _chunkST7E3NEEcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
5488
+ return _chunkPAOWHJ5Ocjs.normalizeLayerEffects.call(void 0, { ...r, psd });
5483
5489
  }
5484
5490
  function serializeMask(mask, hint, ctx) {
5485
5491
  const out = { defaultValue: mask.defaultValue };
@@ -5560,8 +5566,8 @@ function serializeType(layer, base, ctx) {
5560
5566
  if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
5561
5567
  if (_optionalChain([layer, 'access', _123 => _123.psd, 'optionalAccess', _124 => _124.tySh]) || _optionalChain([layer, 'access', _125 => _125.psd, 'optionalAccess', _126 => _126.blocks, 'optionalAccess', _127 => _127.length])) {
5562
5568
  out.psd = {};
5563
- if (layer.psd.tySh) out.psd.tySh = _chunkST7E3NEEcjs.bytesToBase64.call(void 0, layer.psd.tySh);
5564
- if (_optionalChain([layer, 'access', _128 => _128.psd, 'access', _129 => _129.blocks, 'optionalAccess', _130 => _130.length])) out.psd.blocks = layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, b.data) }));
5569
+ if (layer.psd.tySh) out.psd.tySh = _chunkEJVDBITDcjs.bytesToBase64.call(void 0, layer.psd.tySh);
5570
+ if (_optionalChain([layer, 'access', _128 => _128.psd, 'access', _129 => _129.blocks, 'optionalAccess', _130 => _130.length])) out.psd.blocks = layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, b.data) }));
5565
5571
  if (layer.psd.signature) out.psd.signature = layer.psd.signature;
5566
5572
  }
5567
5573
  return out;
@@ -5572,7 +5578,7 @@ function readType(r, base, ctx) {
5572
5578
  const text3 = normalizeText(_nullishCoalesce(r.text, () => ( "")));
5573
5579
  const runs = (Array.isArray(r.runs) ? r.runs : []).map((run, i) => ({
5574
5580
  length: Math.max(0, Math.floor(num2(_optionalChain([run, 'optionalAccess', _131 => _131.length]), 0, 1e9, 0))),
5575
- style: patchTextStyle(_chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _132 => _132.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
5581
+ style: patchTextStyle(_chunkFODKPD44cjs.DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _132 => _132.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
5576
5582
  }));
5577
5583
  const paragraphs = (Array.isArray(r.paragraphs) ? r.paragraphs : []).map((p, i) => ({
5578
5584
  length: Math.max(0, Math.floor(num2(_optionalChain([p, 'optionalAccess', _133 => _133.length]), 0, 1e9, 0))),
@@ -5585,13 +5591,13 @@ function readType(r, base, ctx) {
5585
5591
  ...base,
5586
5592
  type: "type",
5587
5593
  text: text3,
5588
- runs: _chunkLPLCWZTMcjs.fitRuns.call(void 0, runs, text3.length, _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE),
5589
- paragraphs: _chunkLPLCWZTMcjs.fitParagraphRuns.call(void 0, paragraphs.length ? paragraphs : [{ length: text3.length, style: {} }], text3),
5594
+ runs: _chunkFODKPD44cjs.fitRuns.call(void 0, runs, text3.length, _chunkFODKPD44cjs.DEFAULT_TEXT_STYLE),
5595
+ paragraphs: _chunkFODKPD44cjs.fitParagraphRuns.call(void 0, paragraphs.length ? paragraphs : [{ length: text3.length, style: {} }], text3),
5590
5596
  frame,
5591
5597
  surface: _chunkTFOPHZ3Ucjs.emptySurface.call(void 0, 4),
5592
5598
  offset: { x: 0, y: 0 }
5593
5599
  };
5594
- if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _137 => _137[0], 'optionalAccess', _138 => _138.style]), () => ( _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE)) }];
5600
+ if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _137 => _137[0], 'optionalAccess', _138 => _138.style]), () => ( _chunkFODKPD44cjs.DEFAULT_TEXT_STYLE)) }];
5595
5601
  if (m) layer.transform = m;
5596
5602
  if (r.antiAlias === false) layer.antiAlias = false;
5597
5603
  if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
@@ -5599,8 +5605,8 @@ function readType(r, base, ctx) {
5599
5605
  if (r.annotation && typeof r.annotation === "object" && r.annotation.type === "text") layer.annotation = JSON.parse(JSON.stringify({ ...r.annotation, id: _nullishCoalesce(r.annotation.id, () => ( base.id)) }));
5600
5606
  if (r.psd && typeof r.psd === "object") {
5601
5607
  const psd = {};
5602
- if (typeof r.psd.tySh === "string") psd.tySh = _chunkST7E3NEEcjs.base64ToBytes.call(void 0, r.psd.tySh);
5603
- if (Array.isArray(r.psd.blocks)) psd.blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkST7E3NEEcjs.base64ToBytes.call(void 0, b.data) }));
5608
+ if (typeof r.psd.tySh === "string") psd.tySh = _chunkEJVDBITDcjs.base64ToBytes.call(void 0, r.psd.tySh);
5609
+ if (Array.isArray(r.psd.blocks)) psd.blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkEJVDBITDcjs.base64ToBytes.call(void 0, b.data) }));
5604
5610
  if (typeof r.psd.signature === "string") psd.signature = r.psd.signature;
5605
5611
  if (psd.tySh || _optionalChain([psd, 'access', _139 => _139.blocks, 'optionalAccess', _140 => _140.length])) layer.psd = psd;
5606
5612
  }
@@ -5628,7 +5634,7 @@ function serializeShape(layer, base) {
5628
5634
  if (layer.inverted) out.inverted = true;
5629
5635
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5630
5636
  if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
5631
- if (_optionalChain([layer, 'access', _145 => _145.psd, 'optionalAccess', _146 => _146.blocks, 'optionalAccess', _147 => _147.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, b.data) })), ...layer.psd.signature ? { signature: layer.psd.signature } : {} };
5637
+ if (_optionalChain([layer, 'access', _145 => _145.psd, 'optionalAccess', _146 => _146.blocks, 'optionalAccess', _147 => _147.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, b.data) })), ...layer.psd.signature ? { signature: layer.psd.signature } : {} };
5632
5638
  return out;
5633
5639
  }
5634
5640
  function readShape(r, base, ctx) {
@@ -5660,7 +5666,7 @@ function readShape(r, base, ctx) {
5660
5666
  if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) out.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
5661
5667
  if (a && shapeFromAnnotation(a)) out.annotation = a;
5662
5668
  if (r.psd && Array.isArray(r.psd.blocks)) {
5663
- const blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkST7E3NEEcjs.base64ToBytes.call(void 0, b.data) }));
5669
+ const blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkEJVDBITDcjs.base64ToBytes.call(void 0, b.data) }));
5664
5670
  if (blocks.length) out.psd = { blocks };
5665
5671
  if (out.psd && typeof r.psd.signature === "string") out.psd.signature = r.psd.signature;
5666
5672
  }
@@ -5673,7 +5679,7 @@ function readShape(r, base, ctx) {
5673
5679
  function serializeSmartFilters(stack, layerId, ctx) {
5674
5680
  const out = {
5675
5681
  enabled: stack.enabled,
5676
- filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, f.data) } : JSON.parse(JSON.stringify(f)))
5682
+ filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, f.data) } : JSON.parse(JSON.stringify(f)))
5677
5683
  };
5678
5684
  if (stack.mask) out.mask = serializeMask(stack.mask, `${layerId}-filter-mask`, ctx);
5679
5685
  return out;
@@ -5699,7 +5705,7 @@ function serializeSmartObject(layer, base, ctx) {
5699
5705
  }
5700
5706
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5701
5707
  if (layer.psd) {
5702
- out.psd = { key: layer.psd.key, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, layer.psd.data) };
5708
+ out.psd = { key: layer.psd.key, data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, layer.psd.data) };
5703
5709
  if (layer.psd.placed) out.psd.placed = layer.psd.placed;
5704
5710
  }
5705
5711
  return out;
@@ -5711,7 +5717,7 @@ function serializeContents(c, ctx) {
5711
5717
  if (enc) {
5712
5718
  if (enc.x !== 0 || enc.y !== 0) {
5713
5719
  const data = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, c.raster, { x: 0, y: 0, width: c.width, height: c.height });
5714
- out.asset = ctx.addAsset(_chunkST7E3NEEcjs.pngDataUrl.call(void 0, c.width, c.height, data, 4), `contents-${c.id}`);
5720
+ out.asset = ctx.addAsset(_chunkEJVDBITDcjs.pngDataUrl.call(void 0, c.width, c.height, data, 4), `contents-${c.id}`);
5715
5721
  } else out.asset = ctx.addAsset(enc.url, `contents-${c.id}`);
5716
5722
  }
5717
5723
  }
@@ -5720,7 +5726,7 @@ function serializeContents(c, ctx) {
5720
5726
  if (c.document.globalLight) out.globalLight = { ...c.document.globalLight };
5721
5727
  if (_optionalChain([c, 'access', _152 => _152.document, 'access', _153 => _153.patterns, 'optionalAccess', _154 => _154.length])) out.patterns = serializePatterns(c.document.patterns);
5722
5728
  }
5723
- if (c.file) out.file = { type: c.file.type, data: _chunkST7E3NEEcjs.bytesToBase64.call(void 0, c.file.bytes) };
5729
+ if (c.file) out.file = { type: c.file.type, data: _chunkEJVDBITDcjs.bytesToBase64.call(void 0, c.file.bytes) };
5724
5730
  if (c.linked) out.linked = { path: c.linked.path };
5725
5731
  return out;
5726
5732
  }
@@ -5756,7 +5762,7 @@ async function serializeLayersExternal(layers, store) {
5756
5762
  for (const [id, url] of Object.entries(inline.assets)) {
5757
5763
  let ref = refs.get(url);
5758
5764
  if (!ref) {
5759
- const parsed = _chunkST7E3NEEcjs.parseDataUrl.call(void 0, url);
5765
+ const parsed = _chunkEJVDBITDcjs.parseDataUrl.call(void 0, url);
5760
5766
  const png = decodePngHeader(parsed.bytes);
5761
5767
  ref = await store.put(new Blob([parsed.bytes], { type: "image/png" }), { id, width: png.width, height: png.height });
5762
5768
  if (typeof ref !== "string" || !ref) throw new Error(`The asset store returned no reference for "${id}".`);
@@ -5784,7 +5790,7 @@ async function resolveExternalAssets(assets, store, problems) {
5784
5790
  try {
5785
5791
  const blob = await store.get(ref);
5786
5792
  const bytes = new Uint8Array(await blob.arrayBuffer());
5787
- out[id] = `data:image/png;base64,${_chunkST7E3NEEcjs.bytesToBase64.call(void 0, bytes)}`;
5793
+ out[id] = `data:image/png;base64,${_chunkEJVDBITDcjs.bytesToBase64.call(void 0, bytes)}`;
5788
5794
  } catch (err) {
5789
5795
  problems.push(`Asset "${id}" (${ref}) could not be fetched: ${err.message}`);
5790
5796
  }
@@ -5792,9 +5798,9 @@ async function resolveExternalAssets(assets, store, problems) {
5792
5798
  return out;
5793
5799
  }
5794
5800
  function decodePngDataUrl(url, channels) {
5795
- const parsed = _chunkST7E3NEEcjs.parseDataUrl.call(void 0, url);
5801
+ const parsed = _chunkEJVDBITDcjs.parseDataUrl.call(void 0, url);
5796
5802
  if (!parsed) throw new Error("Asset is not a data URL.");
5797
- const png = _chunkST7E3NEEcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
5803
+ const png = _chunkEJVDBITDcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
5798
5804
  if (png.channels === channels) return png;
5799
5805
  if (channels === 1) {
5800
5806
  const out2 = new Uint8ClampedArray(png.width * png.height);
@@ -5968,7 +5974,7 @@ function readContents(id, ctx) {
5968
5974
  const c = { id, name: typeof raw.name === "string" ? raw.name : "Contents", width, height, kind: raw.kind === "document" ? "document" : "raster" };
5969
5975
  if (raw.file && typeof raw.file.type === "string" && typeof raw.file.data === "string") {
5970
5976
  try {
5971
- c.file = { type: raw.file.type, bytes: _chunkST7E3NEEcjs.base64ToBytes.call(void 0, raw.file.data) };
5977
+ c.file = { type: raw.file.type, bytes: _chunkEJVDBITDcjs.base64ToBytes.call(void 0, raw.file.data) };
5972
5978
  } catch (e9) {
5973
5979
  ctx.problems.push(`Smart object contents "${c.name}": the embedded file could not be read`);
5974
5980
  }
@@ -6003,7 +6009,7 @@ function readSmartFilters(raw, ctx, what) {
6003
6009
  const opacity = num2(f.opacity, 0, 1, 1);
6004
6010
  if (f.kind === "psd") {
6005
6011
  try {
6006
- 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: _chunkST7E3NEEcjs.base64ToBytes.call(void 0, String(_nullishCoalesce(f.data, () => ( "")))), blend, opacity });
6012
+ 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: _chunkEJVDBITDcjs.base64ToBytes.call(void 0, String(_nullishCoalesce(f.data, () => ( "")))), blend, opacity });
6007
6013
  } catch (e10) {
6008
6014
  ctx.problems.push(`${what}: a Photoshop smart filter could not be read`);
6009
6015
  }
@@ -6028,8 +6034,8 @@ function readSmartObject(r, base, ctx) {
6028
6034
  let placement;
6029
6035
  try {
6030
6036
  const raw = { corners: p.corners };
6031
- if (p.warp && _chunkLPLCWZTMcjs.isValidWarpMesh.call(void 0, p.warp)) raw.warp = p.warp;
6032
- if (_chunkST7E3NEEcjs.isInterpolation.call(void 0, p.interpolation)) raw.interpolation = p.interpolation;
6037
+ if (p.warp && _chunkFODKPD44cjs.isValidWarpMesh.call(void 0, p.warp)) raw.warp = p.warp;
6038
+ if (_chunkPAOWHJ5Ocjs.isInterpolation.call(void 0, p.interpolation)) raw.interpolation = p.interpolation;
6033
6039
  placement = normalizePlacement(raw, contents);
6034
6040
  } catch (e) {
6035
6041
  ctx.problems.push(`${what}: its placement is invalid (${e instanceof Error ? e.message : String(e)}); it was placed at the top left`);
@@ -6041,7 +6047,7 @@ function readSmartObject(r, base, ctx) {
6041
6047
  if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
6042
6048
  if (r.psd && typeof r.psd.key === "string" && typeof r.psd.data === "string") {
6043
6049
  try {
6044
- layer.psd = { key: r.psd.key, data: _chunkST7E3NEEcjs.base64ToBytes.call(void 0, r.psd.data) };
6050
+ layer.psd = { key: r.psd.key, data: _chunkEJVDBITDcjs.base64ToBytes.call(void 0, r.psd.data) };
6045
6051
  if (typeof r.psd.placed === "string") layer.psd.placed = r.psd.placed;
6046
6052
  } catch (e11) {
6047
6053
  }
@@ -7011,7 +7017,7 @@ function vectorBlockForComponents(components, inverted, width, height, flags = 0
7011
7017
  const fr = (p) => ({ x: p.x / w, y: p.y / h });
7012
7018
  const subpaths = [];
7013
7019
  components.forEach((c, ci) => {
7014
- _chunkLPLCWZTMcjs.expandVectorCorners.call(void 0, c.subpaths).forEach((sp, si) => {
7020
+ _chunkFODKPD44cjs.expandVectorCorners.call(void 0, c.subpaths).forEach((sp, si) => {
7015
7021
  if (!sp.anchors.length) return;
7016
7022
  subpaths.push({
7017
7023
  closed: sp.closed,
@@ -7733,7 +7739,7 @@ function merged(levels) {
7733
7739
  function charStyle(d, fonts, notes) {
7734
7740
  const n = (k) => eNum(eGet(d, k));
7735
7741
  const flag = (k) => eBool(eGet(d, k));
7736
- const s = { ..._chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE };
7742
+ const s = { ..._chunkFODKPD44cjs.DEFAULT_TEXT_STYLE };
7737
7743
  const fi = n("Font");
7738
7744
  const ps = fi !== void 0 ? fonts[fi] : void 0;
7739
7745
  if (ps) {
@@ -7816,7 +7822,7 @@ function typeFromTySh(data, notes) {
7816
7822
  }
7817
7823
  const edText = _nullishCoalesce(eStr(ePath(_nullishCoalesce(engine, () => ( void 0)), ["EngineDict", "Editor", "Text"])), () => ( ""));
7818
7824
  const text3 = (_nullishCoalesce(txt, () => ( edText.replace(/\r$/, "")))).replace(/\r\n?/g, "\n");
7819
- let runs = [{ length: text3.length, style: { ..._chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE } }];
7825
+ let runs = [{ length: text3.length, style: { ..._chunkFODKPD44cjs.DEFAULT_TEXT_STYLE } }];
7820
7826
  let paragraphs = [{ length: text3.length, style: {} }];
7821
7827
  let frame = { kind: "point" };
7822
7828
  let transform = t.transform;
@@ -7872,14 +7878,14 @@ function typeFromTySh(data, notes) {
7872
7878
  const b = eArray(ePath(shape, ["Cookie", "Photoshop", "BoxBounds"])).map((v) => _nullishCoalesce(eNum(v), () => ( 0)));
7873
7879
  if (b.length === 4 && b[2] > b[0] && b[3] > b[1]) {
7874
7880
  frame = { kind: "box", width: b[2] - b[0], height: b[3] - b[1] };
7875
- transform = _chunkLPLCWZTMcjs.multiplyMatrices.call(void 0, [1, 0, 0, 1, b[0], b[1]], t.transform);
7881
+ transform = _chunkFODKPD44cjs.multiplyMatrices.call(void 0, [1, 0, 0, 1, b[0], b[1]], t.transform);
7876
7882
  }
7877
7883
  }
7878
7884
  }
7879
7885
  return {
7880
7886
  text: text3,
7881
- runs: _chunkLPLCWZTMcjs.fitRuns.call(void 0, runs, text3.length, _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE),
7882
- paragraphs: _chunkLPLCWZTMcjs.fitParagraphRuns.call(void 0, paragraphs, text3),
7887
+ runs: _chunkFODKPD44cjs.fitRuns.call(void 0, runs, text3.length, _chunkFODKPD44cjs.DEFAULT_TEXT_STYLE),
7888
+ paragraphs: _chunkFODKPD44cjs.fitParagraphRuns.call(void 0, paragraphs, text3),
7883
7889
  frame,
7884
7890
  transform,
7885
7891
  antiAlias,
@@ -7953,7 +7959,7 @@ function buildEngineData(layer, template) {
7953
7959
  fonts.push(ps);
7954
7960
  return fonts.length - 1;
7955
7961
  };
7956
- const runs = _chunkLPLCWZTMcjs.fitRuns.call(void 0, layer.runs, layer.text.length, _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE);
7962
+ const runs = _chunkFODKPD44cjs.fitRuns.call(void 0, layer.runs, layer.text.length, _chunkFODKPD44cjs.DEFAULT_TEXT_STYLE);
7957
7963
  const sruns = [];
7958
7964
  const slens = [];
7959
7965
  runs.forEach((r, i) => {
@@ -7961,10 +7967,10 @@ function buildEngineData(layer, template) {
7961
7967
  slens.push(E.int(r.length + (i === runs.length - 1 ? 1 : 0)));
7962
7968
  });
7963
7969
  if (!runs.length) {
7964
- sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(_chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE, fontIndex(postScriptFor(_chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE)))]])]]));
7970
+ sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(_chunkFODKPD44cjs.DEFAULT_TEXT_STYLE, fontIndex(postScriptFor(_chunkFODKPD44cjs.DEFAULT_TEXT_STYLE)))]])]]));
7965
7971
  slens.push(E.int(1));
7966
7972
  }
7967
- const paras = _chunkLPLCWZTMcjs.fitParagraphRuns.call(void 0, layer.paragraphs, layer.text);
7973
+ const paras = _chunkFODKPD44cjs.fitParagraphRuns.call(void 0, layer.paragraphs, layer.text);
7968
7974
  const pruns = [];
7969
7975
  const plens = [];
7970
7976
  paras.forEach((p, i) => {
@@ -8020,7 +8026,7 @@ function buildEngineData(layer, template) {
8020
8026
  eSet(e, key, rd);
8021
8027
  }
8022
8028
  eSet(rd, "FontSet", fontSet);
8023
- if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _203 => _203[0], 'optionalAccess', _204 => _204.style]), () => ( _chunkLPLCWZTMcjs.DEFAULT_TEXT_STYLE)), 0)]])]));
8029
+ if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _203 => _203[0], 'optionalAccess', _204 => _204.style]), () => ( _chunkFODKPD44cjs.DEFAULT_TEXT_STYLE)), 0)]])]));
8024
8030
  if (!eGet(rd, "ParagraphSheetSet")) eSet(rd, "ParagraphSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["DefaultStyleSheet", E.int(0)], ["Properties", paragraphProperties({})]])]));
8025
8031
  if (!eGet(rd, "TheNormalStyleSheet")) eSet(rd, "TheNormalStyleSheet", E.int(0));
8026
8032
  if (!eGet(rd, "TheNormalParagraphSheet")) eSet(rd, "TheNormalParagraphSheet", E.int(0));
@@ -8031,13 +8037,13 @@ function inkBounds2(layer) {
8031
8037
  if (layer.frame.kind === "box") return [0, 0, layer.frame.width, layer.frame.height];
8032
8038
  const b = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, layer.surface);
8033
8039
  if (!b) return [0, 0, 0, 0];
8034
- const inv = _chunkLPLCWZTMcjs.invertMatrix.call(void 0, textMatrix(layer));
8040
+ const inv = _chunkFODKPD44cjs.invertMatrix.call(void 0, textMatrix(layer));
8035
8041
  const pts = [
8036
8042
  { x: b.x, y: b.y },
8037
8043
  { x: b.x + b.width, y: b.y },
8038
8044
  { x: b.x + b.width, y: b.y + b.height },
8039
8045
  { x: b.x, y: b.y + b.height }
8040
- ].map((p) => _chunkLPLCWZTMcjs.applyMatrix.call(void 0, inv, p));
8046
+ ].map((p) => _chunkFODKPD44cjs.applyMatrix.call(void 0, inv, p));
8041
8047
  return [Math.min(...pts.map((p) => p.x)), Math.min(...pts.map((p) => p.y)), Math.max(...pts.map((p) => p.x)), Math.max(...pts.map((p) => p.y))];
8042
8048
  }
8043
8049
  function tyShForLayer(layer) {
@@ -8504,7 +8510,7 @@ function filterMaskItem(placed, mask, area) {
8504
8510
  var warpStyleOf = (name) => {
8505
8511
  if (!name.startsWith("warp")) return null;
8506
8512
  const s = _optionalChain([name, 'access', _218 => _218[4], 'optionalAccess', _219 => _219.toLowerCase, 'call', _220 => _220()]) + name.slice(5);
8507
- return _chunkLPLCWZTMcjs.WARP_STYLES.includes(s) ? s : null;
8513
+ return _chunkFODKPD44cjs.WARP_STYLES.includes(s) ? s : null;
8508
8514
  };
8509
8515
  function warpFromDescriptor(w, contents) {
8510
8516
  const full = { x: 0, y: 0, width: contents.width, height: contents.height };
@@ -8534,7 +8540,7 @@ function warpFromDescriptor(w, contents) {
8534
8540
  } else {
8535
8541
  const style = warpStyleOf(styleName);
8536
8542
  if (!style) return void 0;
8537
- mesh = _chunkLPLCWZTMcjs.warpPresetMesh.call(void 0,
8543
+ mesh = _chunkFODKPD44cjs.warpPresetMesh.call(void 0,
8538
8544
  {
8539
8545
  style,
8540
8546
  bend: _nullishCoalesce(descNumber(w, "warpValue"), () => ( 0)),
@@ -8549,7 +8555,7 @@ function warpFromDescriptor(w, contents) {
8549
8555
  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;
8550
8556
  if (!same) {
8551
8557
  const m = mesh;
8552
- mesh = _chunkLPLCWZTMcjs.fitWarpMesh.call(void 0, (s, t) => _chunkLPLCWZTMcjs.evalWarpMesh.call(void 0, m, (s * contents.width - bounds.x) / bounds.width, (t * contents.height - bounds.y) / bounds.height), [0, 1], [0, 1]);
8558
+ mesh = _chunkFODKPD44cjs.fitWarpMesh.call(void 0, (s, t) => _chunkFODKPD44cjs.evalWarpMesh.call(void 0, m, (s * contents.width - bounds.x) / bounds.width, (t * contents.height - bounds.y) / bounds.height), [0, 1], [0, 1]);
8553
8559
  }
8554
8560
  return { mesh, frame };
8555
8561
  }
@@ -8598,14 +8604,14 @@ var toQuad = (p) => [
8598
8604
  function cornersFromQuad(quad, frame, contents) {
8599
8605
  if (quad.length !== 8 || !quad.every(Number.isFinite)) return null;
8600
8606
  const q2 = toQuad(quad);
8601
- const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, frame, q2);
8607
+ const h = _chunkEJVDBITDcjs.rectToQuad.call(void 0, frame, q2);
8602
8608
  if (!h) return null;
8603
- const out = _chunkMUUXNRU4cjs.boxQuad.call(void 0, { x: 0, y: 0, width: contents.width, height: contents.height }).map((p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p));
8609
+ const out = _chunkEJVDBITDcjs.boxQuad.call(void 0, { x: 0, y: 0, width: contents.width, height: contents.height }).map((p) => _chunkEJVDBITDcjs.applyHomography.call(void 0, h, p));
8604
8610
  return out.every(Boolean) ? out : null;
8605
8611
  }
8606
8612
  function quadFromCorners(corners, frame, contents) {
8607
- const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, { x: 0, y: 0, width: contents.width, height: contents.height }, corners);
8608
- const pts = _chunkMUUXNRU4cjs.boxQuad.call(void 0, frame).map((p) => _nullishCoalesce((h ? _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p) : p), () => ( p)));
8613
+ const h = _chunkEJVDBITDcjs.rectToQuad.call(void 0, { x: 0, y: 0, width: contents.width, height: contents.height }, corners);
8614
+ const pts = _chunkEJVDBITDcjs.boxQuad.call(void 0, frame).map((p) => _nullishCoalesce((h ? _chunkEJVDBITDcjs.applyHomography.call(void 0, h, p) : p), () => ( p)));
8609
8615
  return pts.flatMap((p) => [p.x, p.y]);
8610
8616
  }
8611
8617
  var PLACED_KEYS = ["SoLd", "SoLE", "PlLd"];
@@ -9321,6 +9327,15 @@ function toRgba8(set) {
9321
9327
  }
9322
9328
  return out;
9323
9329
  }
9330
+ if (mode === MODE_CMYK && set.cmykToRgb) {
9331
+ const ink = new Uint8Array(n * 4);
9332
+ for (let i = 0, o = 0; i < n; i++, o += 4) {
9333
+ for (let c = 0; c < 4; c++) ink[o + c] = Math.round((1 - (planes[c] ? planes[c](i) : 1)) * 255);
9334
+ out[o + 3] = Math.round(alpha(i) * 255);
9335
+ }
9336
+ set.cmykToRgb(ink, out);
9337
+ return out;
9338
+ }
9324
9339
  const palette = set.palette;
9325
9340
  for (let i = 0, o = 0; i < n; i++, o += 4) {
9326
9341
  let r;
@@ -9745,10 +9760,11 @@ function recordPixels(ctx, rec, name) {
9745
9760
  mode: ctx.file.header.colorMode,
9746
9761
  color: planes.slice(0, ctx.colorCount),
9747
9762
  alpha: planes[ctx.colorCount],
9748
- palette: ctx.palette
9763
+ palette: ctx.palette,
9764
+ cmykToRgb: ctx.cmykToRgb
9749
9765
  };
9750
- const deep = toRgbaDeep(set);
9751
- if (deep) return _chunkST7E3NEEcjs.surfaceFromDeepPixels.call(void 0, { width, height, data: deep }, 4, rec.rect.left, rec.rect.top);
9766
+ const deep = set.cmykToRgb ? null : toRgbaDeep(set);
9767
+ if (deep) return _chunkPAOWHJ5Ocjs.surfaceFromDeepPixels.call(void 0, { width, height, data: deep }, 4, rec.rect.left, rec.rect.top);
9752
9768
  return _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, { width, height, data: toRgba8(set) }, 4, rec.rect.left, rec.rect.top);
9753
9769
  }
9754
9770
  function recordMask(ctx, rec, name) {
@@ -9824,7 +9840,7 @@ function recordEffects(ctx, rec, name, notes, group) {
9824
9840
  }
9825
9841
  for (const e of parsed.effects.items) {
9826
9842
  for (const id of patternIds(e)) {
9827
- if (ctx.patterns.has(id) || _chunkST7E3NEEcjs.builtinPattern.call(void 0, id)) continue;
9843
+ if (ctx.patterns.has(id) || _chunkPAOWHJ5Ocjs.builtinPattern.call(void 0, id)) continue;
9828
9844
  ctx.warn.add("A pattern effect uses a pattern the file does not contain, and paints nothing", name);
9829
9845
  notes.push(`pattern "${id}" is not in the file`);
9830
9846
  }
@@ -10034,7 +10050,7 @@ function contentsFor(ctx, placed, name, notes) {
10034
10050
  document: { layers: nested.layers, globalLight: nested.globalLight, patterns: nested.patterns.length ? nested.patterns : void 0 }
10035
10051
  };
10036
10052
  } else if (t.ext === "png") {
10037
- const png = _chunkST7E3NEEcjs.decodePng.call(void 0, file.bytes);
10053
+ const png = _chunkEJVDBITDcjs.decodePng.call(void 0, file.bytes);
10038
10054
  out = { ...base, kind: "raster", width: png.width, height: png.height, raster: _chunkTFOPHZ3Ucjs.surfaceFromPixels.call(void 0, png, 4, 0, 0) };
10039
10055
  } else {
10040
10056
  const size = _nullishCoalesce(placed.size, () => ( { width: 0, height: 0 }));
@@ -10076,7 +10092,7 @@ function importSmart(ctx, rec, name, notes, props) {
10076
10092
  if (placement && (size.width !== contents.width || size.height !== contents.height)) {
10077
10093
  const kx = contents.width / size.width;
10078
10094
  const ky = contents.height / size.height;
10079
- if (placement.warp) placement = { ...placement, warp: _chunkLPLCWZTMcjs.mapWarpMeshPoints.call(void 0, placement.warp, (p) => ({ x: p.x * kx, y: p.y * ky })) };
10095
+ if (placement.warp) placement = { ...placement, warp: _chunkFODKPD44cjs.mapWarpMeshPoints.call(void 0, placement.warp, (p) => ({ x: p.x * kx, y: p.y * ky })) };
10080
10096
  }
10081
10097
  }
10082
10098
  if (!contents || !placement) {
@@ -10100,7 +10116,7 @@ function importSmart(ctx, rec, name, notes, props) {
10100
10116
  ctx.warn.add("A smart object without readable contents came in with its stored pixels as contents", name);
10101
10117
  notes.push("contents missing");
10102
10118
  }
10103
- placement = { corners: _chunkMUUXNRU4cjs.boxQuad.call(void 0, { x: rec.rect.left, y: rec.rect.top, width, height }) };
10119
+ placement = { corners: _chunkEJVDBITDcjs.boxQuad.call(void 0, { x: rec.rect.left, y: rec.rect.top, width, height }) };
10104
10120
  preview = true;
10105
10121
  }
10106
10122
  const layer = { type: "smart", id: ctx.newId(name), ...props, contents, placement, surface, offset: { x: 0, y: 0 } };
@@ -10154,11 +10170,12 @@ function mergedLayer(ctx) {
10154
10170
  mode: header.colorMode,
10155
10171
  color: Array.from({ length: cc }, (_, i) => plane(i)),
10156
10172
  alpha: hasAlpha ? plane(cc) : void 0,
10157
- palette: ctx.palette
10173
+ palette: ctx.palette,
10174
+ cmykToRgb: ctx.cmykToRgb
10158
10175
  };
10159
- const deep = hasAlpha ? null : toRgbaDeep(set);
10176
+ const deep = hasAlpha || set.cmykToRgb ? null : toRgbaDeep(set);
10160
10177
  let surface;
10161
- if (deep) surface = _chunkST7E3NEEcjs.surfaceFromDeepPixels.call(void 0, { width, height, data: deep }, 4);
10178
+ if (deep) surface = _chunkPAOWHJ5Ocjs.surfaceFromDeepPixels.call(void 0, { width, height, data: deep }, 4);
10162
10179
  else {
10163
10180
  const data = toRgba8(set);
10164
10181
  if (hasAlpha) unmatteWhite(data);
@@ -10194,6 +10211,28 @@ function psdToLayers(file, options = {}) {
10194
10211
  depth: _nullishCoalesce(options.depth, () => ( 0)),
10195
10212
  dpi: _nullishCoalesce(resolution(file), () => ( 72))
10196
10213
  };
10214
+ let cmykProfile = null;
10215
+ if (header.colorMode === MODE_CMYK && !ctx.skipPixels) {
10216
+ const icc = resource(file, 1039);
10217
+ let src = null;
10218
+ if (icc) {
10219
+ try {
10220
+ const p = _chunkG5NMLUVFcjs.parseProfile.call(void 0, icc);
10221
+ if (p.colorSpace === "cmyk") {
10222
+ src = p;
10223
+ cmykProfile = { name: p.description || "Embedded CMYK profile", icc: icc.slice() };
10224
+ } else warn.extra.push(`The CMYK file embeds a ${p.colorSpace.toUpperCase()} profile; the default coated CMYK profile was used.`);
10225
+ } catch (e) {
10226
+ warn.extra.push(`The CMYK profile could not be read (${e instanceof Error ? e.message : String(e)}); the default coated CMYK profile was used.`);
10227
+ }
10228
+ }
10229
+ if (!src) {
10230
+ src = _chunkG5NMLUVFcjs.builtinProfile.call(void 0, "coated-cmyk");
10231
+ cmykProfile = { builtin: "coated-cmyk", name: src.description };
10232
+ }
10233
+ const t = _chunkG5NMLUVFcjs.Transform.create(src, _chunkG5NMLUVFcjs.srgbProfile.call(void 0, ), { intent: "relative", bpc: true });
10234
+ ctx.cmykToRgb = (ink, out) => t.convert8(ink, 4, out, 4, false);
10235
+ }
10197
10236
  for (const block of file.globalBlocks) {
10198
10237
  if (LINKED_FILE_KEYS.includes(block.key)) {
10199
10238
  for (const f of parseLinkedFiles(block.data)) if (!ctx.linked.has(f.uuid)) ctx.linked.set(f.uuid, f);
@@ -10218,7 +10257,8 @@ function psdToLayers(file, options = {}) {
10218
10257
  if (mode !== "rgb" && header.depth > 8 && header.colorMode !== MODE_INDEXED && header.colorMode !== MODE_BITMAP) {
10219
10258
  warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to ${header.depth}-bit RGB.`);
10220
10259
  } else if (mode !== "rgb" || header.depth !== 8 && header.depth !== 16 && header.depth !== 32) {
10221
- warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to 8-bit RGB.`);
10260
+ const how = header.colorMode === MODE_CMYK ? ` through ${_nullishCoalesce(_optionalChain([cmykProfile, 'optionalAccess', _241 => _241.name]), () => ( "its profile"))}` : "";
10261
+ warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to 8-bit RGB${how}.`);
10222
10262
  }
10223
10263
  let layers = [];
10224
10264
  if (file.layers.length) {
@@ -10253,6 +10293,7 @@ function psdToLayers(file, options = {}) {
10253
10293
  patterns: [...ctx.patterns.values()],
10254
10294
  ...angle !== void 0 || altitude !== void 0 ? { globalLight: { angle: Math.max(-360, Math.min(360, _nullishCoalesce(angle, () => ( 120)))), altitude: Math.max(0, Math.min(90, _nullishCoalesce(altitude, () => ( 30)))) } } : {},
10255
10295
  info: { psb: header.psb, depth: header.depth, colorMode: mode, channels: header.channels },
10296
+ ...cmykProfile ? { sourceMode: { mode: "cmyk", profile: cmykProfile } } : header.colorMode === MODE_LAB ? { sourceMode: { mode: "lab" } } : {},
10256
10297
  ...resource(file, 1039) ? { iccProfile: resource(file, 1039).slice() } : {},
10257
10298
  bitDepth: (header.depth === 16 || header.depth === 32) && header.colorMode !== MODE_INDEXED && header.colorMode !== MODE_BITMAP ? header.depth : 8
10258
10299
  };
@@ -10322,15 +10363,15 @@ var pct = (d, key, fallback) => num3(d, key, fallback * 100) / 100;
10322
10363
  var bool = (d, key) => descBool(d, key) === true;
10323
10364
  var enumOf3 = (d, key) => {
10324
10365
  const v = descGet(d, key);
10325
- return _optionalChain([v, 'optionalAccess', _241 => _241.type]) === "enum" ? v.value : void 0;
10366
+ return _optionalChain([v, 'optionalAccess', _242 => _242.type]) === "enum" ? v.value : void 0;
10326
10367
  };
10327
10368
  var text2 = (d, key) => {
10328
10369
  const v = d ? descGet(d, key) : void 0;
10329
- return _optionalChain([v, 'optionalAccess', _242 => _242.type]) === "TEXT" ? v.value : "";
10370
+ return _optionalChain([v, 'optionalAccess', _243 => _243.type]) === "TEXT" ? v.value : "";
10330
10371
  };
10331
10372
  var list = (d, key) => {
10332
10373
  const v = descGet(d, key);
10333
- if (_optionalChain([v, 'optionalAccess', _243 => _243.type]) !== "VlLs") return [];
10374
+ if (_optionalChain([v, 'optionalAccess', _244 => _244.type]) !== "VlLs") return [];
10334
10375
  return v.items.flatMap((it) => it.type === "Objc" || it.type === "GlbO" ? [it.value] : []);
10335
10376
  };
10336
10377
  var clamp3 = (v, lo, hi) => Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : lo;
@@ -10352,34 +10393,34 @@ function blendOf(d, key, fallback, notes) {
10352
10393
  function colorOf(d, fallback = "#000000") {
10353
10394
  if (!d) return fallback;
10354
10395
  const g = (k) => descNumber(d, k);
10355
- if (g("redFloat") !== void 0) return _chunkST7E3NEEcjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
10396
+ if (g("redFloat") !== void 0) return _chunkPAOWHJ5Ocjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
10356
10397
  switch (d.classId) {
10357
10398
  case "HSBC": {
10358
10399
  const rgb = decodePsdColor(1, [(_nullishCoalesce(g("H "), () => ( 0))) / 360 * 65535, (_nullishCoalesce(g("Strt"), () => ( 0))) / 100 * 65535, (_nullishCoalesce(g("Brgh"), () => ( 0))) / 100 * 65535]);
10359
- return rgb ? _chunkST7E3NEEcjs.effectColorHex.call(void 0, rgb) : fallback;
10400
+ return rgb ? _chunkPAOWHJ5Ocjs.effectColorHex.call(void 0, rgb) : fallback;
10360
10401
  }
10361
10402
  case "CMYC": {
10362
10403
  const inv = (k) => (1 - (_nullishCoalesce(g(k), () => ( 0))) / 100) * 65535;
10363
10404
  const rgb = decodePsdColor(2, [inv("Cyn "), inv("Mgnt"), inv("Ylw "), inv("Blck")]);
10364
- return rgb ? _chunkST7E3NEEcjs.effectColorHex.call(void 0, rgb) : fallback;
10405
+ return rgb ? _chunkPAOWHJ5Ocjs.effectColorHex.call(void 0, rgb) : fallback;
10365
10406
  }
10366
10407
  case "LbCl": {
10367
10408
  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]);
10368
- return rgb ? _chunkST7E3NEEcjs.effectColorHex.call(void 0, rgb) : fallback;
10409
+ return rgb ? _chunkPAOWHJ5Ocjs.effectColorHex.call(void 0, rgb) : fallback;
10369
10410
  }
10370
10411
  case "Grsc": {
10371
10412
  const v = 1 - (_nullishCoalesce(g("Gry "), () => ( 0))) / 100;
10372
- return _chunkST7E3NEEcjs.effectColorHex.call(void 0, [v, v, v]);
10413
+ return _chunkPAOWHJ5Ocjs.effectColorHex.call(void 0, [v, v, v]);
10373
10414
  }
10374
10415
  }
10375
10416
  const r = g("Rd ");
10376
10417
  const gr = g("Grn ");
10377
10418
  const b = g("Bl ");
10378
10419
  if (r === void 0 || gr === void 0 || b === void 0) return fallback;
10379
- return _chunkST7E3NEEcjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
10420
+ return _chunkPAOWHJ5Ocjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
10380
10421
  }
10381
10422
  function colorDesc(hex) {
10382
- const [r, g, b] = _nullishCoalesce(_chunkST7E3NEEcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
10423
+ const [r, g, b] = _nullishCoalesce(_chunkPAOWHJ5Ocjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
10383
10424
  return descriptor("RGBC", [
10384
10425
  ["Rd ", dbl3(r * 255)],
10385
10426
  ["Grn ", dbl3(g * 255)],
@@ -10400,8 +10441,8 @@ function contourOf(d, key) {
10400
10441
  return { name, points };
10401
10442
  }
10402
10443
  function contourDesc(c) {
10403
- const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _244 => _244.name]), () => ( "Linear"));
10404
- const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _245 => _245.points]), () => ( [
10444
+ const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _245 => _245.name]), () => ( "Linear"));
10445
+ const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _246 => _246.points]), () => ( [
10405
10446
  { input: 0, output: 0 },
10406
10447
  { input: 1, output: 1 }
10407
10448
  ]));
@@ -10436,7 +10477,7 @@ function gradientOf(d, notes) {
10436
10477
  { position: 0, color: "#000000" },
10437
10478
  { position: 1, color: "#ffffff" }
10438
10479
  ],
10439
- style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _246 => _246.find, 'call', _247 => _247(([, id]) => id === enumOf3(d, "Type")), 'optionalAccess', _248 => _248[0]]), () => ( "linear")),
10480
+ style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _247 => _247.find, 'call', _248 => _248(([, id]) => id === enumOf3(d, "Type")), 'optionalAccess', _249 => _249[0]]), () => ( "linear")),
10440
10481
  angle: clamp3(num3(d, "Angl", 90), -360, 360),
10441
10482
  scale: clamp3(pct(d, "Scl ", 1), 0.1, 1.5),
10442
10483
  reverse: bool(d, "Rvrs"),
@@ -10462,9 +10503,9 @@ function gradientOf(d, notes) {
10462
10503
  raw.forEach((s, i) => {
10463
10504
  if (i > 0 && Math.abs(s.mid - 0.5) > 1e-3) {
10464
10505
  const a = raw[i - 1];
10465
- const ca = _chunkST7E3NEEcjs.parseEffectColor.call(void 0, a.color);
10466
- const cb = _chunkST7E3NEEcjs.parseEffectColor.call(void 0, s.color);
10467
- stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkST7E3NEEcjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
10506
+ const ca = _chunkPAOWHJ5Ocjs.parseEffectColor.call(void 0, a.color);
10507
+ const cb = _chunkPAOWHJ5Ocjs.parseEffectColor.call(void 0, s.color);
10508
+ stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkPAOWHJ5Ocjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
10468
10509
  notes.add("gradient midpoints are drawn as straight segments");
10469
10510
  }
10470
10511
  stops.push({ position: s.position, color: s.color });
@@ -10490,7 +10531,7 @@ function gradientItems(g) {
10490
10531
  )
10491
10532
  )
10492
10533
  };
10493
- const op = _optionalChain([g, 'access', _249 => _249.opacityStops, 'optionalAccess', _250 => _250.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
10534
+ const op = _optionalChain([g, 'access', _250 => _250.opacityStops, 'optionalAccess', _251 => _251.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
10494
10535
  const trns = {
10495
10536
  type: "VlLs",
10496
10537
  items: op.map(
@@ -10576,8 +10617,8 @@ var KINDS = [
10576
10617
  ["FrFX", "frameFXMulti", "stroke"]
10577
10618
  ];
10578
10619
  function common(d, kind, notes) {
10579
- const def = _chunkST7E3NEEcjs.defaultLayerEffect.call(void 0, kind, "x");
10580
- return { id: _chunkST7E3NEEcjs.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) };
10620
+ const def = _chunkPAOWHJ5Ocjs.defaultLayerEffect.call(void 0, kind, "x");
10621
+ return { id: _chunkPAOWHJ5Ocjs.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) };
10581
10622
  }
10582
10623
  function readOne(kind, d, notes) {
10583
10624
  const size = (key, fallback) => clamp3(num3(d, key, fallback), 0, 250);
@@ -10620,7 +10661,7 @@ function readOne(kind, d, notes) {
10620
10661
  case "bevel-emboss": {
10621
10662
  const styles = { OtrB: "outer-bevel", InrB: "inner-bevel", Embs: "emboss", PlEb: "pillow-emboss", strokeEmboss: "stroke-emboss" };
10622
10663
  const out = {
10623
- id: _chunkST7E3NEEcjs.newEffectId.call(void 0, ),
10664
+ id: _chunkPAOWHJ5Ocjs.newEffectId.call(void 0, ),
10624
10665
  enabled: descBool(d, "enab") !== false,
10625
10666
  kind,
10626
10667
  style: _nullishCoalesce(styles[_nullishCoalesce(enumOf3(d, "bvlS"), () => ( ""))], () => ( "inner-bevel")),
@@ -10831,10 +10872,10 @@ function writeLfx2(effects) {
10831
10872
  ["Scl ", unit3("#Prc", 100)],
10832
10873
  ["masterFXSwitch", boolV3(effects.enabled)]
10833
10874
  ];
10834
- const scale = _chunkST7E3NEEcjs.effectsScale.call(void 0, effects);
10875
+ const scale = _chunkPAOWHJ5Ocjs.effectsScale.call(void 0, effects);
10835
10876
  let dropped = 0;
10836
10877
  for (const [single, multi, kind] of KINDS) {
10837
- const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkST7E3NEEcjs.scaleLayerEffect.call(void 0, e, scale)));
10878
+ const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkPAOWHJ5Ocjs.scaleLayerEffect.call(void 0, e, scale)));
10838
10879
  if (!of.length) continue;
10839
10880
  if (of.length === 1) items.push([single, obj3(of[0])]);
10840
10881
  else if (multi) items.push([multi, { type: "VlLs", items: of.map(obj3) }]);
@@ -10866,7 +10907,7 @@ function parseLrfx(data) {
10866
10907
  const colorAt = (rd) => {
10867
10908
  rd.u16();
10868
10909
  const c = [rd.u16(), rd.u16(), rd.u16(), rd.u16()];
10869
- return _chunkST7E3NEEcjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
10910
+ return _chunkPAOWHJ5Ocjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
10870
10911
  };
10871
10912
  const blendAt = (rd) => {
10872
10913
  rd.skip(4);
@@ -10885,7 +10926,7 @@ function parseLrfx(data) {
10885
10926
  const enabled = b.u8() !== 0;
10886
10927
  const useGlobalLight = b.u8() !== 0;
10887
10928
  const opacity = b.u8() / 255;
10888
- const base = { id: _chunkST7E3NEEcjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
10929
+ const base = { id: _chunkPAOWHJ5Ocjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
10889
10930
  items.push(key === "dsdw" ? { ...base, kind: "drop-shadow", spread: 0, knocksOut: true } : { ...base, kind: "inner-shadow", choke: 0 });
10890
10931
  } else if (key === "oglw" || key === "iglw") {
10891
10932
  b.u32();
@@ -10895,7 +10936,7 @@ function parseLrfx(data) {
10895
10936
  const blend = blendAt(b);
10896
10937
  const enabled = b.u8() !== 0;
10897
10938
  const opacity = b.u8() / 255;
10898
- const base = { id: _chunkST7E3NEEcjs.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 };
10939
+ const base = { id: _chunkPAOWHJ5Ocjs.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 };
10899
10940
  items.push(key === "oglw" ? { ...base, kind: "outer-glow", spread: 0 } : { ...base, kind: "inner-glow", choke: 0, source: "edge" });
10900
10941
  } else if (key === "sofi") {
10901
10942
  b.u32();
@@ -10903,7 +10944,7 @@ function parseLrfx(data) {
10903
10944
  const color = colorAt(b);
10904
10945
  const opacity = b.u8() / 255;
10905
10946
  const enabled = b.u8() !== 0;
10906
- items.push({ id: _chunkST7E3NEEcjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
10947
+ items.push({ id: _chunkPAOWHJ5Ocjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
10907
10948
  } else if (key === "bevl") notes.add("legacy bevels are not read");
10908
10949
  }
10909
10950
  return { effects: { enabled: true, items }, notes: [...notes] };
@@ -10955,7 +10996,7 @@ function rleChannel(id, plane, width, height, psb, depth = 8) {
10955
10996
  function surfacePlanes(surface, bounds, depth) {
10956
10997
  const n = bounds.width * bounds.height;
10957
10998
  if (depth === 8) return rgbaToPlanes(_chunkTFOPHZ3Ucjs.readRegion.call(void 0, surface, bounds), n);
10958
- return deepToPlanes(_chunkST7E3NEEcjs.readDeepRegion.call(void 0, surface, bounds, depth), n);
10999
+ return deepToPlanes(_chunkPAOWHJ5Ocjs.readDeepRegion.call(void 0, surface, bounds, depth), n);
10959
11000
  }
10960
11001
  var emptyChannel = (id) => ({ id, compression: 0, data: new Uint8Array(0) });
10961
11002
  function maskChannel(mask, ox, oy, psb, depth = 8) {
@@ -10983,9 +11024,9 @@ function prepareNestedLayers(layers) {
10983
11024
  if (l.type === "annotation") continue;
10984
11025
  let next = l;
10985
11026
  if (l.type === "group") next = { ...l, children: prepareNestedLayers(l.children) };
10986
- else if (l.type === "pixel" && (_optionalChain([l, 'access', _251 => _251.filters, 'optionalAccess', _252 => _252.length]) || l.source === "document")) {
11027
+ else if (l.type === "pixel" && (_optionalChain([l, 'access', _252 => _252.filters, 'optionalAccess', _253 => _253.length]) || l.source === "document")) {
10987
11028
  const p = { ...l };
10988
- if (_optionalChain([l, 'access', _253 => _253.filters, 'optionalAccess', _254 => _254.some, 'call', _255 => _255(isActiveFilter)])) {
11029
+ if (_optionalChain([l, 'access', _254 => _254.filters, 'optionalAccess', _255 => _255.some, 'call', _256 => _256(isActiveFilter)])) {
10989
11030
  const b = l.surface.bounds;
10990
11031
  if (b) {
10991
11032
  const r = { x: b.x + l.offset.x - 64, y: b.y + l.offset.y - 64, width: b.width + 128, height: b.height + 128 };
@@ -11002,7 +11043,7 @@ function prepareNestedLayers(layers) {
11002
11043
  delete p.source;
11003
11044
  next = p;
11004
11045
  }
11005
- if (_optionalChain([next, 'access', _256 => _256.mask, 'optionalAccess', _257 => _257.source])) {
11046
+ if (_optionalChain([next, 'access', _257 => _257.mask, 'optionalAccess', _258 => _258.source])) {
11006
11047
  next = { ...next };
11007
11048
  delete next.mask;
11008
11049
  }
@@ -11015,7 +11056,7 @@ function smartContentsFile(c) {
11015
11056
  if (c.file) return { name: c.name, bytes: c.file.bytes };
11016
11057
  if (c.kind === "raster") {
11017
11058
  const data = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
11018
- return { name: `${base}.png`, bytes: _chunkST7E3NEEcjs.encodePng.call(void 0, c.width, c.height, data) };
11059
+ return { name: `${base}.png`, bytes: _chunkEJVDBITDcjs.encodePng.call(void 0, c.width, c.height, data) };
11019
11060
  }
11020
11061
  const doc = c.document;
11021
11062
  const merged2 = _chunkTFOPHZ3Ucjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
@@ -11051,6 +11092,21 @@ function exportPsd(input) {
11051
11092
  const { width, height } = input;
11052
11093
  const depth = _nullishCoalesce(input.depth, () => ( 8));
11053
11094
  if (width < 1 || height < 1) throw new PsdError("The document is empty.");
11095
+ const mode = _nullishCoalesce(input.colorMode, () => ( "rgb"));
11096
+ if (mode !== "rgb" && !input.colorPlanes) throw new PsdError(`A ${mode.toUpperCase()} file needs colorPlanes to convert the pixels.`);
11097
+ if (mode !== "rgb" && depth !== 8) throw new PsdError(`${mode.toUpperCase()} files are written at 8 bits per channel.`);
11098
+ const colorIds = mode === "cmyk" ? [0, 1, 2, 3] : [0, 1, 2];
11099
+ const colorPlanes = (rgba, n2) => mode === "rgb" ? rgbaToPlanes(rgba, n2).slice(0, 3) : input.colorPlanes(rgba, n2);
11100
+ const pixelChannels = (rgba, w, h) => {
11101
+ const n2 = w * h;
11102
+ const alpha = rgbaToPlanes(rgba, n2)[3];
11103
+ return [rleChannel(CHANNEL_ALPHA, alpha, w, h, psb), ...colorPlanes(rgba, n2).map((p, i) => rleChannel(i, p, w, h, psb))];
11104
+ };
11105
+ const surfaceChannels = (surface, bounds) => {
11106
+ if (mode !== "rgb") return pixelChannels(_chunkTFOPHZ3Ucjs.readRegion.call(void 0, surface, bounds), bounds.width, bounds.height);
11107
+ const [r, g, b, a2] = surfacePlanes(surface, bounds, depth);
11108
+ return [CHANNEL_ALPHA, 0, 1, 2].map((id, i) => rleChannel(id, [a2, r, g, b][i], bounds.width, bounds.height, psb, depth));
11109
+ };
11054
11110
  const psb = width > PSD_MAX_DIMENSION || height > PSD_MAX_DIMENSION;
11055
11111
  const records = [];
11056
11112
  let nextId = 0;
@@ -11067,7 +11123,7 @@ function exportPsd(input) {
11067
11123
  const key = layer.type === "group" ? "lfxs" : "lfx2";
11068
11124
  if (fx.psd) {
11069
11125
  const original = parseLfx2(fx.psd.data);
11070
- if (original ? _chunkST7E3NEEcjs.effectsFingerprint.call(void 0, original.effects) === _chunkST7E3NEEcjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
11126
+ if (original ? _chunkPAOWHJ5Ocjs.effectsFingerprint.call(void 0, original.effects) === _chunkPAOWHJ5Ocjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
11071
11127
  }
11072
11128
  if (!fx.items.length && fx.enabled && (_nullishCoalesce(fx.scale, () => ( 1))) === 1) return null;
11073
11129
  const { data, dropped } = writeLfx2(fx);
@@ -11084,7 +11140,7 @@ function exportPsd(input) {
11084
11140
  return {
11085
11141
  opacity: Math.round(Math.min(1, Math.max(0, layer.opacity)) * 255),
11086
11142
  clipping: layer.clipped ? 1 : 0,
11087
- flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _258 => _258.locks, 'optionalAccess', _259 => _259.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
11143
+ flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _259 => _259.locks, 'optionalAccess', _260 => _260.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
11088
11144
  legacyName: name,
11089
11145
  blocks
11090
11146
  };
@@ -11094,7 +11150,7 @@ function exportPsd(input) {
11094
11150
  case "group": {
11095
11151
  records.push({
11096
11152
  rect: EMPTY_RECT,
11097
- channels: [CHANNEL_ALPHA, 0, 1, 2].map(emptyChannel),
11153
+ channels: [CHANNEL_ALPHA, ...colorIds].map(emptyChannel),
11098
11154
  blendKey: "norm",
11099
11155
  opacity: 255,
11100
11156
  clipping: 0,
@@ -11111,7 +11167,7 @@ function exportPsd(input) {
11111
11167
  const rec = {
11112
11168
  ...base,
11113
11169
  rect: EMPTY_RECT,
11114
- channels: [CHANNEL_ALPHA, 0, 1, 2].map(emptyChannel),
11170
+ channels: [CHANNEL_ALPHA, ...colorIds].map(emptyChannel),
11115
11171
  blendKey,
11116
11172
  flags: base.flags | FLAG_PIXELS_IRRELEVANT
11117
11173
  };
@@ -11128,7 +11184,7 @@ function exportPsd(input) {
11128
11184
  const rec = {
11129
11185
  ...common2(layer, [{ key: block.key, data: block.data }]),
11130
11186
  rect: EMPTY_RECT,
11131
- channels: [CHANNEL_ALPHA, 0, 1, 2].map(emptyChannel),
11187
+ channels: [CHANNEL_ALPHA, ...colorIds].map(emptyChannel),
11132
11188
  blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm"))
11133
11189
  };
11134
11190
  if (layer.mask) {
@@ -11141,7 +11197,7 @@ function exportPsd(input) {
11141
11197
  }
11142
11198
  case "pixel": {
11143
11199
  if (layer.source === "document") throw new PsdError(`Layer "${layer.name}" reads the document image; resolve its pixels before export.`);
11144
- if (_optionalChain([layer, 'access', _260 => _260.filters, 'optionalAccess', _261 => _261.some, 'call', _262 => _262(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
11200
+ if (_optionalChain([layer, 'access', _261 => _261.filters, 'optionalAccess', _262 => _262.some, 'call', _263 => _263(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
11145
11201
  const extra = [];
11146
11202
  if (layer.fillOpacity !== void 0 && layer.fillOpacity < 1) {
11147
11203
  extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
@@ -11149,16 +11205,10 @@ function exportPsd(input) {
11149
11205
  const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
11150
11206
  const bounds = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, layer.surface);
11151
11207
  if (bounds) {
11152
- const [r2, g2, b2, a2] = surfacePlanes(layer.surface, bounds, depth);
11153
11208
  rec.rect = toRect({ ...bounds, x: bounds.x + layer.offset.x, y: bounds.y + layer.offset.y });
11154
- rec.channels = [
11155
- rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb, depth),
11156
- rleChannel(0, r2, bounds.width, bounds.height, psb, depth),
11157
- rleChannel(1, g2, bounds.width, bounds.height, psb, depth),
11158
- rleChannel(2, b2, bounds.width, bounds.height, psb, depth)
11159
- ];
11209
+ rec.channels = surfaceChannels(layer.surface, bounds);
11160
11210
  } else {
11161
- rec.channels = [CHANNEL_ALPHA, 0, 1, 2].map(emptyChannel);
11211
+ rec.channels = [CHANNEL_ALPHA, ...colorIds].map(emptyChannel);
11162
11212
  }
11163
11213
  if (layer.mask) {
11164
11214
  const m = maskChannel(layer.mask, layer.offset.x, layer.offset.y, psb, depth);
@@ -11179,7 +11229,7 @@ function exportPsd(input) {
11179
11229
  if (c.linked) note("Linked smart objects were embedded (their preview is written as the contents)", layer.name);
11180
11230
  linkedFiles.set(idnt, smartContentsFile(c));
11181
11231
  }
11182
- let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _263 => _263.psd, 'optionalAccess', _264 => _264.placed]), () => ( psdUuid(`${layer.id}:placed`)));
11232
+ let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _264 => _264.psd, 'optionalAccess', _265 => _265.placed]), () => ( psdUuid(`${layer.id}:placed`)));
11183
11233
  if (placedIds.has(placedId)) placedId = psdUuid(`${layer.id}:placed:${placedIds.size}`);
11184
11234
  placedIds.add(placedId);
11185
11235
  if (placedUnchanged(layer, idnt, placedId)) {
@@ -11189,26 +11239,20 @@ function exportPsd(input) {
11189
11239
  const filterFX = layer.smartFilters ? filterFXDescriptor(layer.smartFilters, dropped) : void 0;
11190
11240
  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);
11191
11241
  const raw = layer.psd && layer.psd.key !== "PlLd" ? parsePlaced(layer.psd.key, layer.psd.data) : null;
11192
- const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _265 => _265.descriptor]) };
11242
+ const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _266 => _266.descriptor]) };
11193
11243
  const wnotes = [];
11194
11244
  extra.push({ key: "PlLd", data: plldBytes(spec) }, { key: "SoLd", data: soldBytes(spec, wnotes) });
11195
11245
  for (const n2 of wnotes) note(`A smart object: ${n2}`, layer.name);
11196
11246
  }
11197
- const fm = _optionalChain([layer, 'access', _266 => _266.smartFilters, 'optionalAccess', _267 => _267.mask]);
11247
+ const fm = _optionalChain([layer, 'access', _267 => _267.smartFilters, 'optionalAccess', _268 => _268.mask]);
11198
11248
  if (fm && !fm.source) filterItems.push(filterMaskItem(placedId, fm, { x: 0, y: 0, width, height }));
11199
11249
  const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
11200
11250
  const bounds = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, layer.surface);
11201
11251
  if (bounds) {
11202
- const [r2, g2, b2, a2] = surfacePlanes(layer.surface, bounds, depth);
11203
11252
  rec.rect = toRect(bounds);
11204
- rec.channels = [
11205
- rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb, depth),
11206
- rleChannel(0, r2, bounds.width, bounds.height, psb, depth),
11207
- rleChannel(1, g2, bounds.width, bounds.height, psb, depth),
11208
- rleChannel(2, b2, bounds.width, bounds.height, psb, depth)
11209
- ];
11253
+ rec.channels = surfaceChannels(layer.surface, bounds);
11210
11254
  } else {
11211
- rec.channels = [CHANNEL_ALPHA, 0, 1, 2].map(emptyChannel);
11255
+ rec.channels = [CHANNEL_ALPHA, ...colorIds].map(emptyChannel);
11212
11256
  }
11213
11257
  if (layer.mask) {
11214
11258
  const m = maskChannel(layer.mask, 0, 0, psb, depth);
@@ -11226,26 +11270,20 @@ function exportPsd(input) {
11226
11270
  }
11227
11271
  if (layer.type === "shape") {
11228
11272
  const losses = /* @__PURE__ */ new Set();
11229
- for (const b2 of shapeBlocks(layer, width, height, _nullishCoalesce(input.resolution, () => ( 72)), losses)) extra.push({ key: b2.key, data: padEven(b2.data) });
11273
+ for (const b of shapeBlocks(layer, width, height, _nullishCoalesce(input.resolution, () => ( 72)), losses)) extra.push({ key: b.key, data: padEven(b.data) });
11230
11274
  for (const n2 of losses) note(n2, layer.name);
11231
- if (_optionalChain([layer, 'access', _268 => _268.fill, 'optionalAccess', _269 => _269.type]) === "pattern") patternIds2.add(layer.fill.patternId);
11232
- if (_optionalChain([layer, 'access', _270 => _270.stroke, 'optionalAccess', _271 => _271.paint, 'access', _272 => _272.type]) === "pattern") patternIds2.add(layer.stroke.paint.patternId);
11275
+ if (_optionalChain([layer, 'access', _269 => _269.fill, 'optionalAccess', _270 => _270.type]) === "pattern") patternIds2.add(layer.fill.patternId);
11276
+ if (_optionalChain([layer, 'access', _271 => _271.stroke, 'optionalAccess', _272 => _272.paint, 'access', _273 => _273.type]) === "pattern") patternIds2.add(layer.stroke.paint.patternId);
11233
11277
  } else {
11234
11278
  extra.push({ key: "TySh", data: padEven(tyShForLayer(layer)) });
11235
11279
  }
11236
11280
  const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
11237
11281
  const bounds = _chunkTFOPHZ3Ucjs.contentBounds.call(void 0, layer.surface);
11238
11282
  if (bounds) {
11239
- const [r2, g2, b2, a2] = surfacePlanes(layer.surface, bounds, depth);
11240
11283
  rec.rect = toRect(bounds);
11241
- rec.channels = [
11242
- rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb, depth),
11243
- rleChannel(0, r2, bounds.width, bounds.height, psb, depth),
11244
- rleChannel(1, g2, bounds.width, bounds.height, psb, depth),
11245
- rleChannel(2, b2, bounds.width, bounds.height, psb, depth)
11246
- ];
11284
+ rec.channels = surfaceChannels(layer.surface, bounds);
11247
11285
  } else {
11248
- rec.channels = [CHANNEL_ALPHA, 0, 1, 2].map(emptyChannel);
11286
+ rec.channels = [CHANNEL_ALPHA, ...colorIds].map(emptyChannel);
11249
11287
  }
11250
11288
  if (layer.mask) {
11251
11289
  const m = maskChannel(layer.mask, 0, 0, psb, depth);
@@ -11263,9 +11301,10 @@ function exportPsd(input) {
11263
11301
  if (records.length > 32767) throw new PsdError("A PSD holds at most 32767 layer records.");
11264
11302
  const n = width * height;
11265
11303
  if (input.merged.length < n * 4) throw new PsdError(`The merged image has ${input.merged.length} bytes, expected ${n * 4}.`);
11266
- const [r, g, b, a] = rgbaToPlanes(matteWhite(input.merged), n);
11304
+ const matted = matteWhite(input.merged);
11305
+ const a = rgbaToPlanes(matted, n)[3];
11267
11306
  const transparent = a.some((v) => v !== 255);
11268
- let planes = (transparent ? [r, g, b, a] : [r, g, b]).map((p) => planeAtDepth(p, depth));
11307
+ let planes = [...colorPlanes(matted, n), ...transparent ? [a] : []].map((p) => planeAtDepth(p, depth));
11269
11308
  const deep = input.mergedDeep;
11270
11309
  if (deep && depth !== 8 && deep.length >= n * 4 && (deep instanceof Uint16Array ? depth === 16 : depth === 32)) {
11271
11310
  const dp = deepToPlanes(matteWhiteDeep(deep), n);
@@ -11291,7 +11330,7 @@ function exportPsd(input) {
11291
11330
  { id: 1005, name: "", data: rw.result() },
11292
11331
  { id: 1057, name: "", data: version.result() }
11293
11332
  ];
11294
- if (_optionalChain([input, 'access', _273 => _273.iccProfile, 'optionalAccess', _274 => _274.length])) resources.push({ id: 1039, name: "", data: input.iccProfile });
11333
+ if (_optionalChain([input, 'access', _274 => _274.iccProfile, 'optionalAccess', _275 => _275.length])) resources.push({ id: 1039, name: "", data: input.iccProfile });
11295
11334
  if (input.globalLight) {
11296
11335
  const i32 = (v) => {
11297
11336
  const w = new PsdWriter();
@@ -11305,7 +11344,7 @@ function exportPsd(input) {
11305
11344
  const byId = new Map((_nullishCoalesce(input.patterns, () => ( []))).map((p) => [p.id, p]));
11306
11345
  const embed = [];
11307
11346
  for (const id of patternIds2) {
11308
- const p = _nullishCoalesce(byId.get(id), () => ( _chunkST7E3NEEcjs.builtinPattern.call(void 0, id)));
11347
+ const p = _nullishCoalesce(byId.get(id), () => ( _chunkPAOWHJ5Ocjs.builtinPattern.call(void 0, id)));
11309
11348
  if (p) embed.push(p);
11310
11349
  else note(`Pattern "${id}" is not in the document and was not embedded`, id);
11311
11350
  }
@@ -11324,7 +11363,7 @@ function exportPsd(input) {
11324
11363
  if (filterItems.length) globalBlocks.push({ key: "FEid", data: writeFilterEffects(filterItems) });
11325
11364
  const bytes = writePsd(
11326
11365
  {
11327
- header: { psb, channels: planes.length, width, height, depth, colorMode: 3 },
11366
+ header: { psb, channels: planes.length, width, height, depth, colorMode: mode === "cmyk" ? 4 : mode === "lab" ? 9 : 3 },
11328
11367
  colorModeData: new Uint8Array(0),
11329
11368
  resources,
11330
11369
  layers: records,
@@ -11696,4 +11735,4 @@ function exportPsd(input) {
11696
11735
 
11697
11736
 
11698
11737
  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.applyAdjustmentLayersFloat = applyAdjustmentLayersFloat; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.TEXT_ALIGNS = TEXT_ALIGNS; 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.compositeDeep = compositeDeep; 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.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; 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.encodeDeepSurface = encodeDeepSurface; exports.decodeDeepSurface = decodeDeepSurface; 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.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.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; 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;
11699
- //# sourceMappingURL=chunk-5OVJHMZQ.cjs.map
11738
+ //# sourceMappingURL=chunk-ZYZGEILO.cjs.map