@pixerate/editor 0.95.0 → 0.97.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.
@@ -42,7 +42,23 @@ var _chunkVJUVNERTcjs = require('../chunk-VJUVNERT.cjs');
42
42
 
43
43
 
44
44
 
45
- var _chunkT6H3JDGAcjs = require('../chunk-T6H3JDGA.cjs');
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+ var _chunk4AB5BHYKcjs = require('../chunk-4AB5BHYK.cjs');
46
62
 
47
63
 
48
64
 
@@ -308,8 +324,8 @@ function whiteBalanceFromSample(rgb) {
308
324
  if (lin[0] + lin[1] + lin[2] <= 1e-6) return { temperature: 0, tint: 0 };
309
325
  const src = linearSrgbToXy(applyMatrix3(AS_SHOT_WB_INV, lin));
310
326
  const { kelvin, tint } = xyToTempTint(src);
311
- const clamp3 = (v) => Math.max(-100, Math.min(100, v));
312
- return { temperature: clamp3(kelvinToTemperature(kelvin)), tint: clamp3(tint) };
327
+ const clamp4 = (v) => Math.max(-100, Math.min(100, v));
328
+ return { temperature: clamp4(kelvinToTemperature(kelvin)), tint: clamp4(tint) };
313
329
  }
314
330
  var TONE_LUT_SIZE = 4096;
315
331
  var GREY = 0.18;
@@ -541,20 +557,20 @@ function hitTestCrop(canvasPt, state, vpWidth, vpHeight, handleThreshold = 14, c
541
557
  }
542
558
  function hitTestCropRect(canvasPt, rect, handleThreshold) {
543
559
  const { x, y, width: w, height: h } = rect;
544
- const px = canvasPt.x;
560
+ const px2 = canvasPt.x;
545
561
  const py = canvasPt.y;
546
562
  const dist = (x1, y1, x2, y2) => Math.hypot(x1 - x2, y1 - y2);
547
- if (dist(px, py, x, y) <= handleThreshold) return "nw";
548
- if (dist(px, py, x + w, y) <= handleThreshold) return "ne";
549
- if (dist(px, py, x + w, y + h) <= handleThreshold) return "se";
550
- if (dist(px, py, x, y + h) <= handleThreshold) return "sw";
551
- const nearX = px >= x - handleThreshold && px <= x + w + handleThreshold;
563
+ if (dist(px2, py, x, y) <= handleThreshold) return "nw";
564
+ if (dist(px2, py, x + w, y) <= handleThreshold) return "ne";
565
+ if (dist(px2, py, x + w, y + h) <= handleThreshold) return "se";
566
+ if (dist(px2, py, x, y + h) <= handleThreshold) return "sw";
567
+ const nearX = px2 >= x - handleThreshold && px2 <= x + w + handleThreshold;
552
568
  const nearY = py >= y - handleThreshold && py <= y + h + handleThreshold;
553
569
  if (nearX && Math.abs(py - y) <= handleThreshold) return "n";
554
570
  if (nearX && Math.abs(py - (y + h)) <= handleThreshold) return "s";
555
- if (nearY && Math.abs(px - x) <= handleThreshold) return "w";
556
- if (nearY && Math.abs(px - (x + w)) <= handleThreshold) return "e";
557
- if (px >= x && px <= x + w && py >= y && py <= y + h) {
571
+ if (nearY && Math.abs(px2 - x) <= handleThreshold) return "w";
572
+ if (nearY && Math.abs(px2 - (x + w)) <= handleThreshold) return "e";
573
+ if (px2 >= x && px2 <= x + w && py >= y && py <= y + h) {
558
574
  return "inside";
559
575
  }
560
576
  return null;
@@ -903,21 +919,21 @@ function toBase64(bytes, length) {
903
919
  parts.push(chunk);
904
920
  return parts.join("");
905
921
  }
906
- function fromBase64(text) {
907
- if (text.length % 4 !== 0) throw new Error("Invalid base64 length");
922
+ function fromBase64(text2) {
923
+ if (text2.length % 4 !== 0) throw new Error("Invalid base64 length");
908
924
  let pad = 0;
909
- if (text.endsWith("==")) pad = 2;
910
- else if (text.endsWith("=")) pad = 1;
911
- const out = new Uint8Array(text.length / 4 * 3 - pad);
925
+ if (text2.endsWith("==")) pad = 2;
926
+ else if (text2.endsWith("=")) pad = 1;
927
+ const out = new Uint8Array(text2.length / 4 * 3 - pad);
912
928
  let o = 0;
913
929
  const digit = (i, k) => {
914
- const ch = text.charCodeAt(i + k);
915
- if (ch === 61 && i + 4 === text.length && k >= 4 - pad) return 0;
930
+ const ch = text2.charCodeAt(i + k);
931
+ if (ch === 61 && i + 4 === text2.length && k >= 4 - pad) return 0;
916
932
  const idx = ch < 128 ? B64_INDEX[ch] : -1;
917
933
  if (idx < 0) throw new Error("Invalid base64 character");
918
934
  return idx;
919
935
  };
920
- for (let i = 0; i < text.length; i += 4) {
936
+ for (let i = 0; i < text2.length; i += 4) {
921
937
  const n = digit(i, 0) << 18 | digit(i, 1) << 12 | digit(i, 2) << 6 | digit(i, 3);
922
938
  if (o < out.length) out[o++] = n >> 16 & 255;
923
939
  if (o < out.length) out[o++] = n >> 8 & 255;
@@ -1131,7 +1147,7 @@ function smoothCoverage(m, w, h, r) {
1131
1147
  return src;
1132
1148
  }
1133
1149
  function featherCoverage(m, w, h, radius) {
1134
- const out = _chunkT6H3JDGAcjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
1150
+ const out = _chunk4AB5BHYKcjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
1135
1151
  for (let i = 0; i < out.length; i++) if (Math.abs(out[i]) < 1e-7) out[i] = 0;
1136
1152
  return out;
1137
1153
  }
@@ -1279,7 +1295,7 @@ function layerMaskCoverage(mask) {
1279
1295
  let v = new Float32Array(sel.data.length);
1280
1296
  for (let i = 0; i < v.length; i++) v[i] = sel.data[i] / 255;
1281
1297
  const feather = _nullishCoalesce(mask.feather, () => ( 0));
1282
- if (feather > 0) v = _chunkT6H3JDGAcjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
1298
+ if (feather > 0) v = _chunk4AB5BHYKcjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
1283
1299
  const density = _nullishCoalesce(mask.density, () => ( 1));
1284
1300
  if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
1285
1301
  return v;
@@ -1522,7 +1538,7 @@ function normalizeAdjustmentLayers(raw) {
1522
1538
  return out;
1523
1539
  }
1524
1540
  function curveLutFromLevels(points) {
1525
- return _chunkT6H3JDGAcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
1541
+ return _chunk4AB5BHYKcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
1526
1542
  }
1527
1543
  var toUnitLevels = (c) => ({
1528
1544
  inBlack: c.inBlack / 255,
@@ -1582,13 +1598,13 @@ function hslToRgb(h, s, l) {
1582
1598
  };
1583
1599
  return [f(h + 1 / 3), f(h), f(h - 1 / 3)];
1584
1600
  }
1585
- function hueRangeWeight(range, deg) {
1601
+ function hueRangeWeight(range, deg2) {
1586
1602
  const [a, b0, c0, d0] = range.bounds;
1587
1603
  const rel = (x) => Number.isFinite(x) && Number.isFinite(a) ? remEuclid(x - a, 360) : 0;
1588
1604
  const b = rel(b0);
1589
1605
  const c = Math.max(rel(c0), b);
1590
1606
  const d = Math.max(rel(d0), c);
1591
- const h = rel(deg);
1607
+ const h = rel(deg2);
1592
1608
  if (h <= b) return b <= 0 ? 1 : h / b;
1593
1609
  if (h <= c) return 1;
1594
1610
  if (h <= d) return d <= c ? 1 : (d - h) / (d - c);
@@ -1600,9 +1616,9 @@ function hueRangeTables(ranges) {
1600
1616
  const t = [new Float32Array(n), new Float32Array(n), new Float32Array(n)];
1601
1617
  const active = ranges.filter((r) => !isNeutralRange(r));
1602
1618
  for (let k = 0; k < n; k++) {
1603
- const deg = k / (n - 1) * 360;
1619
+ const deg2 = k / (n - 1) * 360;
1604
1620
  for (const r of active) {
1605
- const w = hueRangeWeight(r, deg);
1621
+ const w = hueRangeWeight(r, deg2);
1606
1622
  t[0][k] += w * r.hue;
1607
1623
  t[1][k] += w * r.saturation / 100;
1608
1624
  t[2][k] += w * r.lightness / 100;
@@ -2165,8 +2181,8 @@ function applyFastBoxBlur(imageData, radius) {
2165
2181
  let r = 0, g = 0, b = 0, a = 0;
2166
2182
  let count = 0;
2167
2183
  for (let k = -radius; k <= radius; k++) {
2168
- const px = Math.min(w - 1, Math.max(0, x + k));
2169
- const idx = (y * w + px) * 4;
2184
+ const px2 = Math.min(w - 1, Math.max(0, x + k));
2185
+ const idx = (y * w + px2) * 4;
2170
2186
  r += src[idx];
2171
2187
  g += src[idx + 1];
2172
2188
  b += src[idx + 2];
@@ -2348,7 +2364,7 @@ function newLayerId(prefix = "layer") {
2348
2364
  return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
2349
2365
  }
2350
2366
  function pixelLayers(layers) {
2351
- return _chunkT6H3JDGAcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
2367
+ return _chunk4AB5BHYKcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
2352
2368
  }
2353
2369
  function developFilter(layer) {
2354
2370
  return _optionalChain([layer, 'access', _8 => _8.filters, 'optionalAccess', _9 => _9.find, 'call', _10 => _10((f) => f.kind === "develop")]);
@@ -2428,10 +2444,10 @@ function depthMaskAlpha(depth, options) {
2428
2444
  }
2429
2445
  var filterSpecCache = /* @__PURE__ */ new WeakMap();
2430
2446
  function pixelFilterSpec(layer) {
2431
- const list = layer.filters;
2432
- if (!_optionalChain([list, 'optionalAccess', _14 => _14.length])) return null;
2433
- if (filterSpecCache.has(list)) return filterSpecCache.get(list);
2434
- const filters = list.filter(isActiveFilter);
2447
+ const list2 = layer.filters;
2448
+ if (!_optionalChain([list2, 'optionalAccess', _14 => _14.length])) return null;
2449
+ if (filterSpecCache.has(list2)) return filterSpecCache.get(list2);
2450
+ const filters = list2.filter(isActiveFilter);
2435
2451
  let spec = null;
2436
2452
  if (filters.length) {
2437
2453
  const spatial = filters.some(isSpatialFilter);
@@ -2446,7 +2462,7 @@ function pixelFilterSpec(layer) {
2446
2462
  }
2447
2463
  };
2448
2464
  }
2449
- filterSpecCache.set(list, spec);
2465
+ filterSpecCache.set(list2, spec);
2450
2466
  return spec;
2451
2467
  }
2452
2468
  var PHOTO_PROFILE = {
@@ -2469,7 +2485,7 @@ var PHOTO_PROFILE = {
2469
2485
  return v;
2470
2486
  }
2471
2487
  };
2472
- var LayerCompositor = class extends _chunkT6H3JDGAcjs.RasterCompositor {
2488
+ var LayerCompositor = class extends _chunk4AB5BHYKcjs.RasterCompositor {
2473
2489
  constructor(options = {}) {
2474
2490
  super(PHOTO_PROFILE, options);
2475
2491
  }
@@ -2663,8 +2679,8 @@ function legacyAdjustmentLayer(node, width, height) {
2663
2679
  }
2664
2680
  function developTarget(layers, activeLayerId) {
2665
2681
  const pixels = [];
2666
- const walk = (list) => {
2667
- for (const l of list) {
2682
+ const walk = (list2) => {
2683
+ for (const l of list2) {
2668
2684
  if (l.type === "pixel") pixels.push(l);
2669
2685
  else if (l.type === "group") walk(l.children);
2670
2686
  }
@@ -2698,8 +2714,8 @@ function legacyView(stack, width, height, activeLayerId = null) {
2698
2714
  };
2699
2715
  const adjNodes = [];
2700
2716
  const annotations = [];
2701
- const walk = (list) => {
2702
- for (const l of list) {
2717
+ const walk = (list2) => {
2718
+ for (const l of list2) {
2703
2719
  if (l.type === "adjustment") adjNodes.push(l);
2704
2720
  else if (l.type === "annotation") annotations.push(l.annotation);
2705
2721
  else if (l.type === "group") walk(l.children);
@@ -3121,13 +3137,13 @@ var ImageEditorRenderer = (_class2 = class {constructor() { _class2.prototype.__
3121
3137
  ctx.save();
3122
3138
  try {
3123
3139
  applyImageProjectionToContext(ctx, projection);
3124
- const px = 1 / (projection.scale || 1);
3140
+ const px2 = 1 / (projection.scale || 1);
3125
3141
  ctx.beginPath();
3126
- ctx.arc(b.x, b.y, Math.max(px, b.diameter / 2), 0, Math.PI * 2);
3127
- ctx.lineWidth = 2 * px;
3142
+ ctx.arc(b.x, b.y, Math.max(px2, b.diameter / 2), 0, Math.PI * 2);
3143
+ ctx.lineWidth = 2 * px2;
3128
3144
  ctx.strokeStyle = "rgba(0,0,0,0.6)";
3129
3145
  ctx.stroke();
3130
- ctx.lineWidth = px;
3146
+ ctx.lineWidth = px2;
3131
3147
  ctx.strokeStyle = "#ffffff";
3132
3148
  ctx.stroke();
3133
3149
  } catch (e5) {
@@ -3246,7 +3262,7 @@ var ImageEditorRenderer = (_class2 = class {constructor() { _class2.prototype.__
3246
3262
  /** Loads what the compositor reads synchronously: depth maps (at canvas size) and annotation images. */
3247
3263
  /** Loads depth maps and annotation images the compositor reads synchronously. */
3248
3264
  async prepareLayerAssets(layers, width, height) {
3249
- for (const l of _chunkT6H3JDGAcjs.flattenLayers.call(void 0, layers)) {
3265
+ for (const l of _chunk4AB5BHYKcjs.flattenLayers.call(void 0, layers)) {
3250
3266
  const source = _optionalChain([l, 'access', _57 => _57.mask, 'optionalAccess', _58 => _58.source]);
3251
3267
  if (_optionalChain([source, 'optionalAccess', _59 => _59.enabled]) && source.maskSource) {
3252
3268
  const key = `${source.maskSource}|${width}x${height}`;
@@ -3410,32 +3426,32 @@ var ImageEditorRenderer = (_class2 = class {constructor() { _class2.prototype.__
3410
3426
  this.outlineCache.set(selection, segs);
3411
3427
  }
3412
3428
  if (!segs.length) return;
3413
- const px = 1 / (scale || 1);
3429
+ const px2 = 1 / (scale || 1);
3414
3430
  ctx.beginPath();
3415
3431
  for (let i = 0; i < segs.length; i += 4) {
3416
3432
  ctx.moveTo(segs[i], segs[i + 1]);
3417
3433
  ctx.lineTo(segs[i + 2], segs[i + 3]);
3418
3434
  }
3419
- ctx.lineWidth = px;
3435
+ ctx.lineWidth = px2;
3420
3436
  ctx.strokeStyle = "#ffffff";
3421
3437
  ctx.stroke();
3422
3438
  if (typeof ctx.setLineDash === "function") {
3423
- ctx.setLineDash([4 * px, 4 * px]);
3424
- ctx.lineDashOffset = -offset * px;
3439
+ ctx.setLineDash([4 * px2, 4 * px2]);
3440
+ ctx.lineDashOffset = -offset * px2;
3425
3441
  }
3426
3442
  ctx.strokeStyle = "#000000";
3427
3443
  ctx.stroke();
3428
3444
  if (typeof ctx.setLineDash === "function") ctx.setLineDash([]);
3429
3445
  }
3430
3446
  drawDraftPath(ctx, points, scale) {
3431
- const px = 1 / (scale || 1);
3447
+ const px2 = 1 / (scale || 1);
3432
3448
  ctx.beginPath();
3433
3449
  points.forEach((p, i) => i === 0 ? ctx.moveTo(p.x, p.y) : ctx.lineTo(p.x, p.y));
3434
3450
  ctx.closePath();
3435
- ctx.lineWidth = px;
3451
+ ctx.lineWidth = px2;
3436
3452
  ctx.strokeStyle = "#ffffff";
3437
3453
  ctx.stroke();
3438
- if (typeof ctx.setLineDash === "function") ctx.setLineDash([4 * px, 4 * px]);
3454
+ if (typeof ctx.setLineDash === "function") ctx.setLineDash([4 * px2, 4 * px2]);
3439
3455
  ctx.strokeStyle = "#000000";
3440
3456
  ctx.stroke();
3441
3457
  if (typeof ctx.setLineDash === "function") ctx.setLineDash([]);
@@ -4281,8 +4297,8 @@ var gfRadius = (p) => Math.min(64, Math.max(1, Math.ceil(p.radius)));
4281
4297
  var smoothSigma = (p) => p.smooth / 100 * 4;
4282
4298
  var featherSigma = (p) => p.feather / 2;
4283
4299
  function shiftAmount(p) {
4284
- const px = p.shiftEdge / 100 * Math.max(p.radius, 4);
4285
- return Number.isFinite(px) ? Math.min(64, Math.max(-64, px)) : 0;
4300
+ const px2 = p.shiftEdge / 100 * Math.max(p.radius, 4);
4301
+ return Number.isFinite(px2) ? Math.min(64, Math.max(-64, px2)) : 0;
4286
4302
  }
4287
4303
  function refineEdgeHalo(params = {}) {
4288
4304
  const p = normalizeRefineEdgeParams(params);
@@ -4429,11 +4445,11 @@ function refineCoverage(guide, m, w, h, params = {}) {
4429
4445
  }
4430
4446
  const ss = smoothSigma(p);
4431
4447
  if (ss >= 0.3) {
4432
- a = _chunkT6H3JDGAcjs.gaussianBlur.call(void 0, a, w, h, ss, "clamp");
4448
+ a = _chunk4AB5BHYKcjs.gaussianBlur.call(void 0, a, w, h, ss, "clamp");
4433
4449
  const gain = 1 + ss;
4434
4450
  for (let i = 0; i < a.length; i++) a[i] = Math.min(1, Math.max(0, (a[i] - 0.5) * gain + 0.5));
4435
4451
  }
4436
- a = _chunkT6H3JDGAcjs.gaussianBlur.call(void 0, a, w, h, featherSigma(p), "clamp");
4452
+ a = _chunk4AB5BHYKcjs.gaussianBlur.call(void 0, a, w, h, featherSigma(p), "clamp");
4437
4453
  if (p.contrast > 0) {
4438
4454
  const gain = 1 / (1 - 0.99 * p.contrast / 100);
4439
4455
  for (let i = 0; i < a.length; i++) a[i] = Math.min(1, Math.max(0, (a[i] - 0.5) * gain + 0.5));
@@ -4490,6 +4506,23 @@ function refineSelection(pixels, mask, params = {}) {
4490
4506
 
4491
4507
  // src/image-editor/layers/serialize.ts
4492
4508
  var LAYERED_SCHEMA_VERSION = 3;
4509
+ function serializePatterns(patterns) {
4510
+ return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunk4AB5BHYKcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
4511
+ }
4512
+ function deserializePatterns(raw, problems = []) {
4513
+ if (!Array.isArray(raw)) return [];
4514
+ const out = [];
4515
+ for (const p of raw) {
4516
+ if (!p || typeof p !== "object" || typeof p.id !== "string" || typeof p.png !== "string") continue;
4517
+ try {
4518
+ const png = decodePngDataUrl(p.png, 4);
4519
+ out.push({ id: p.id, name: typeof p.name === "string" ? p.name : p.id, width: png.width, height: png.height, data: png.data });
4520
+ } catch (e) {
4521
+ problems.push(`Pattern "${_nullishCoalesce(p.name, () => ( p.id))}" could not be decoded (${e instanceof Error ? e.message : String(e)}).`);
4522
+ }
4523
+ }
4524
+ return out;
4525
+ }
4493
4526
  var encodedCache = /* @__PURE__ */ new WeakMap();
4494
4527
  function encodeSurface(surface) {
4495
4528
  if (encodedCache.has(surface)) return encodedCache.get(surface);
@@ -4497,7 +4530,7 @@ function encodeSurface(surface) {
4497
4530
  let out = null;
4498
4531
  if (b) {
4499
4532
  const data = _chunkCRMAXIUVcjs.readRegion.call(void 0, surface, b);
4500
- out = { url: _chunkT6H3JDGAcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
4533
+ out = { url: _chunk4AB5BHYKcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
4501
4534
  }
4502
4535
  encodedCache.set(surface, out);
4503
4536
  return out;
@@ -4519,7 +4552,7 @@ function baseFields(layer, ctx) {
4519
4552
  function serializeEffects(effects) {
4520
4553
  const out = { enabled: effects.enabled, items: JSON.parse(JSON.stringify(effects.items)) };
4521
4554
  if (effects.scale !== void 0 && effects.scale !== 1) out.scale = effects.scale;
4522
- if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkT6H3JDGAcjs.bytesToBase64.call(void 0, effects.psd.data) };
4555
+ if (effects.psd) out.psd = { key: effects.psd.key, data: _chunk4AB5BHYKcjs.bytesToBase64.call(void 0, effects.psd.data) };
4523
4556
  return out;
4524
4557
  }
4525
4558
  function deserializeEffects(raw) {
@@ -4529,12 +4562,12 @@ function deserializeEffects(raw) {
4529
4562
  const p = r.psd;
4530
4563
  if (p && typeof p.key === "string" && typeof p.data === "string") {
4531
4564
  try {
4532
- psd = { key: p.key, data: _chunkT6H3JDGAcjs.base64ToBytes.call(void 0, p.data) };
4565
+ psd = { key: p.key, data: _chunk4AB5BHYKcjs.base64ToBytes.call(void 0, p.data) };
4533
4566
  } catch (e12) {
4534
4567
  psd = void 0;
4535
4568
  }
4536
4569
  }
4537
- return _chunkT6H3JDGAcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
4570
+ return _chunk4AB5BHYKcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
4538
4571
  }
4539
4572
  function serializeMask(mask, hint, ctx) {
4540
4573
  const out = { defaultValue: mask.defaultValue };
@@ -4606,7 +4639,7 @@ async function serializeLayersExternal(layers, store) {
4606
4639
  for (const [id, url] of Object.entries(inline.assets)) {
4607
4640
  let ref = refs.get(url);
4608
4641
  if (!ref) {
4609
- const parsed = _chunkT6H3JDGAcjs.parseDataUrl.call(void 0, url);
4642
+ const parsed = _chunk4AB5BHYKcjs.parseDataUrl.call(void 0, url);
4610
4643
  const png = decodePngHeader(parsed.bytes);
4611
4644
  ref = await store.put(new Blob([parsed.bytes], { type: "image/png" }), { id, width: png.width, height: png.height });
4612
4645
  if (typeof ref !== "string" || !ref) throw new Error(`The asset store returned no reference for "${id}".`);
@@ -4634,7 +4667,7 @@ async function resolveExternalAssets(assets, store, problems) {
4634
4667
  try {
4635
4668
  const blob = await store.get(ref);
4636
4669
  const bytes = new Uint8Array(await blob.arrayBuffer());
4637
- out[id] = `data:image/png;base64,${_chunkT6H3JDGAcjs.bytesToBase64.call(void 0, bytes)}`;
4670
+ out[id] = `data:image/png;base64,${_chunk4AB5BHYKcjs.bytesToBase64.call(void 0, bytes)}`;
4638
4671
  } catch (err) {
4639
4672
  problems.push(`Asset "${id}" (${ref}) could not be fetched: ${err.message}`);
4640
4673
  }
@@ -4642,9 +4675,9 @@ async function resolveExternalAssets(assets, store, problems) {
4642
4675
  return out;
4643
4676
  }
4644
4677
  function decodePngDataUrl(url, channels) {
4645
- const parsed = _chunkT6H3JDGAcjs.parseDataUrl.call(void 0, url);
4678
+ const parsed = _chunk4AB5BHYKcjs.parseDataUrl.call(void 0, url);
4646
4679
  if (!parsed) throw new Error("Asset is not a data URL.");
4647
- const png = _chunkT6H3JDGAcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
4680
+ const png = _chunk4AB5BHYKcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
4648
4681
  if (png.channels === channels) return png;
4649
4682
  if (channels === 1) {
4650
4683
  const out2 = new Uint8ClampedArray(png.width * png.height);
@@ -4669,8 +4702,8 @@ function readSurface(ref, x, y, channels, defaultValue, ctx, what) {
4669
4702
  return _chunkCRMAXIUVcjs.emptySurface.call(void 0, channels, defaultValue);
4670
4703
  }
4671
4704
  try {
4672
- const px = (_nullishCoalesce(ctx.decodeAsset, () => ( decodePngDataUrl)))(url, channels);
4673
- return _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, px, channels, Math.round(num(x, -1e7, 1e7, 0)), Math.round(num(y, -1e7, 1e7, 0)), defaultValue);
4705
+ const px2 = (_nullishCoalesce(ctx.decodeAsset, () => ( decodePngDataUrl)))(url, channels);
4706
+ return _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, px2, channels, Math.round(num(x, -1e7, 1e7, 0)), Math.round(num(y, -1e7, 1e7, 0)), defaultValue);
4674
4707
  } catch (err) {
4675
4708
  ctx.problems.push(`${what}: asset "${ref}" could not be decoded (${err.message})`);
4676
4709
  return _chunkCRMAXIUVcjs.emptySurface.call(void 0, channels, defaultValue);
@@ -4785,7 +4818,7 @@ function deserializeLayer(raw, ctx) {
4785
4818
  function deserializeLayers(raw, ctx) {
4786
4819
  if (!Array.isArray(raw)) return [];
4787
4820
  const seen = /* @__PURE__ */ new Set();
4788
- const dedupe = (list) => list.map((l) => {
4821
+ const dedupe = (list2) => list2.map((l) => {
4789
4822
  let next = l;
4790
4823
  if (seen.has(l.id)) next = { ...l, id: newLayerId() };
4791
4824
  seen.add(next.id);
@@ -4806,47 +4839,47 @@ var fail = (message) => {
4806
4839
  throw new LayerOperationError(message);
4807
4840
  };
4808
4841
  function requireLayer(layers, id) {
4809
- const loc = _chunkT6H3JDGAcjs.findLayer.call(void 0, layers, id);
4842
+ const loc = _chunk4AB5BHYKcjs.findLayer.call(void 0, layers, id);
4810
4843
  if (!loc) {
4811
- const ids = _chunkT6H3JDGAcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
4844
+ const ids = _chunk4AB5BHYKcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
4812
4845
  fail(`Unknown layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "The document has no layers."} Call list_layers for ids.`);
4813
4846
  }
4814
4847
  return loc;
4815
4848
  }
4816
4849
  function requireUnlocked(layer, what, action) {
4817
- if (_chunkT6H3JDGAcjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
4818
- if (what !== "all" && _chunkT6H3JDGAcjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
4850
+ if (_chunk4AB5BHYKcjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
4851
+ if (what !== "all" && _chunk4AB5BHYKcjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
4819
4852
  }
4820
4853
  function placeLayer(layers, layer, placement = {}, defaultIndex) {
4821
4854
  const given = [placement.aboveId, placement.belowId, placement.parentId].filter((v) => v !== void 0).length;
4822
4855
  if (given > 1) fail("Give only one of aboveId, belowId and parentId.");
4823
4856
  if (placement.aboveId || placement.belowId) {
4824
4857
  const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
4825
- return _chunkT6H3JDGAcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _79 => _79.parent, 'optionalAccess', _80 => _80.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
4858
+ return _chunk4AB5BHYKcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _79 => _79.parent, 'optionalAccess', _80 => _80.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
4826
4859
  }
4827
4860
  if (placement.parentId) {
4828
4861
  const ref = requireLayer(layers, placement.parentId);
4829
4862
  if (ref.layer.type !== "group") fail(`Layer "${placement.parentId}" is not a group; parentId must be a group id.`);
4830
- return _chunkT6H3JDGAcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
4863
+ return _chunk4AB5BHYKcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
4831
4864
  }
4832
- return _chunkT6H3JDGAcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
4865
+ return _chunk4AB5BHYKcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
4833
4866
  }
4834
4867
  function removeLayer(layers, id) {
4835
4868
  const loc = requireLayer(layers, id);
4836
4869
  requireUnlocked(loc.layer, "all", "delete it");
4837
- return _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, id, () => null);
4870
+ return _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, id, () => null);
4838
4871
  }
4839
4872
  function moveLayer(layers, id, placement) {
4840
4873
  const loc = requireLayer(layers, id);
4841
4874
  requireUnlocked(loc.layer, "all", "move it");
4842
4875
  const target = _nullishCoalesce(_nullishCoalesce(placement.aboveId, () => ( placement.belowId)), () => ( placement.parentId));
4843
4876
  if (target === id) fail("A layer cannot be placed relative to itself.");
4844
- if (target && loc.layer.type === "group" && _chunkT6H3JDGAcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
4877
+ if (target && loc.layer.type === "group" && _chunk4AB5BHYKcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
4845
4878
  fail(`Group "${id}" cannot be moved into its own child "${target}".`);
4846
4879
  }
4847
4880
  if (target) requireLayer(layers, target);
4848
4881
  if (!target && placement.index === void 0) fail("Give aboveId, belowId, parentId or index.");
4849
- const without = _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, id, () => null);
4882
+ const without = _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, id, () => null);
4850
4883
  return placeLayer(without, loc.layer, placement);
4851
4884
  }
4852
4885
  function withNewIds(layer) {
@@ -4860,7 +4893,7 @@ function duplicateLayer(layers, id, name) {
4860
4893
  const copy = withNewIds(loc.layer);
4861
4894
  copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
4862
4895
  delete copy.locks;
4863
- return { layers: _chunkT6H3JDGAcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _81 => _81.parent, 'optionalAccess', _82 => _82.id]), () => ( null)), loc.index + 1), id: copy.id };
4896
+ return { layers: _chunk4AB5BHYKcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _81 => _81.parent, 'optionalAccess', _82 => _82.id]), () => ( null)), loc.index + 1), id: copy.id };
4864
4897
  }
4865
4898
  function setLayerProperties(layers, id, props) {
4866
4899
  const loc = requireLayer(layers, id);
@@ -4907,7 +4940,7 @@ function setLayerProperties(layers, id, props) {
4907
4940
  if (props.collapsed) g.collapsed = true;
4908
4941
  else delete g.collapsed;
4909
4942
  }
4910
- return _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, id, () => next);
4943
+ return _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, id, () => next);
4911
4944
  }
4912
4945
  function groupLayers(layers, ids, name = "Group") {
4913
4946
  if (!ids.length) fail("Give at least one layer id to group.");
@@ -4936,17 +4969,17 @@ function groupLayers(layers, ids, name = "Group") {
4936
4969
  group.children[0] = c;
4937
4970
  }
4938
4971
  let out = layers;
4939
- for (const l of ordered) out = _chunkT6H3JDGAcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
4940
- return { layers: _chunkT6H3JDGAcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
4972
+ for (const l of ordered) out = _chunk4AB5BHYKcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
4973
+ return { layers: _chunk4AB5BHYKcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
4941
4974
  }
4942
4975
  function ungroupLayer(layers, id) {
4943
4976
  const loc = requireLayer(layers, id);
4944
4977
  if (loc.layer.type !== "group") fail(`Layer "${id}" is not a group.`);
4945
4978
  requireUnlocked(loc.layer, "all", "ungroup it");
4946
4979
  const group = loc.layer;
4947
- let out = _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, id, () => null);
4980
+ let out = _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, id, () => null);
4948
4981
  group.children.forEach((c, i) => {
4949
- out = _chunkT6H3JDGAcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _91 => _91.parent, 'optionalAccess', _92 => _92.id]), () => ( null)), loc.index + i);
4982
+ out = _chunk4AB5BHYKcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _91 => _91.parent, 'optionalAccess', _92 => _92.id]), () => ( null)), loc.index + i);
4950
4983
  });
4951
4984
  return { layers: out, ids: group.children.map((c) => c.id) };
4952
4985
  }
@@ -4956,12 +4989,12 @@ function offsetLayer(layers, id, offset) {
4956
4989
  requireUnlocked(loc.layer, "position", "move it");
4957
4990
  if (!Number.isFinite(offset.x) || !Number.isFinite(offset.y)) fail("x and y must be numbers.");
4958
4991
  const layer = loc.layer;
4959
- return _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, offset: { x: Math.round(offset.x), y: Math.round(offset.y) } }));
4992
+ return _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, offset: { x: Math.round(offset.x), y: Math.round(offset.y) } }));
4960
4993
  }
4961
4994
  function setLayerMask(layers, id, mask) {
4962
4995
  const loc = requireLayer(layers, id);
4963
4996
  requireUnlocked(loc.layer, "all", "change its mask");
4964
- return _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, id, (l) => {
4997
+ return _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, id, (l) => {
4965
4998
  const next = { ...l };
4966
4999
  if (mask) next.mask = mask;
4967
5000
  else delete next.mask;
@@ -5000,7 +5033,7 @@ function requirePixelLayer(layers, id) {
5000
5033
  function addLayerFilter(layers, id, filter) {
5001
5034
  const layer = requirePixelLayer(layers, id);
5002
5035
  if (_optionalChain([layer, 'access', _93 => _93.filters, 'optionalAccess', _94 => _94.some, 'call', _95 => _95((f) => f.kind === filter.kind)])) fail(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
5003
- return _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
5036
+ return _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
5004
5037
  }
5005
5038
  function updateLayerFilter(layers, id, filterId, changes) {
5006
5039
  const layer = requirePixelLayer(layers, id);
@@ -5011,7 +5044,7 @@ function updateLayerFilter(layers, id, filterId, changes) {
5011
5044
  const merged = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
5012
5045
  const filters = [...layer.filters];
5013
5046
  filters[i] = merged;
5014
- return _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
5047
+ return _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
5015
5048
  }
5016
5049
  function removeLayerFilter(layers, id, filterId) {
5017
5050
  const layer = requirePixelLayer(layers, id);
@@ -5020,7 +5053,7 @@ function removeLayerFilter(layers, id, filterId) {
5020
5053
  const next = { ...layer };
5021
5054
  if (filters.length) next.filters = filters;
5022
5055
  else delete next.filters;
5023
- return _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, id, () => next);
5056
+ return _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, id, () => next);
5024
5057
  }
5025
5058
  function requireEffectLayer(layers, id, action) {
5026
5059
  const layer = requireLayer(layers, id).layer;
@@ -5035,7 +5068,7 @@ function guard(fn) {
5035
5068
  try {
5036
5069
  return fn();
5037
5070
  } catch (e) {
5038
- if (e instanceof _chunkT6H3JDGAcjs.LayerEffectError) fail(e.message);
5071
+ if (e instanceof _chunk4AB5BHYKcjs.LayerEffectError) fail(e.message);
5039
5072
  throw e;
5040
5073
  }
5041
5074
  }
@@ -5043,20 +5076,20 @@ function setLayerEffects(layers, id, effects) {
5043
5076
  const layer = requireEffectLayer(layers, id, "change its effects");
5044
5077
  const next = { ...layer };
5045
5078
  if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
5046
- guard(() => _chunkT6H3JDGAcjs.validateLayerEffects.call(void 0, effects));
5079
+ guard(() => _chunk4AB5BHYKcjs.validateLayerEffects.call(void 0, effects));
5047
5080
  next.effects = effects;
5048
5081
  } else delete next.effects;
5049
- return _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, id, () => next);
5082
+ return _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, id, () => next);
5050
5083
  }
5051
5084
  function addLayerEffect(layers, id, kind, params = {}, index) {
5052
- if (!_chunkT6H3JDGAcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkT6H3JDGAcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
5085
+ if (!_chunk4AB5BHYKcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunk4AB5BHYKcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
5053
5086
  const layer = requireEffectLayer(layers, id, "add effects");
5054
5087
  const current = layerEffectsOf(layer);
5055
5088
  const ids = new Set(current.items.map((e) => e.id));
5056
- let effectId = _chunkT6H3JDGAcjs.newEffectId.call(void 0, );
5057
- while (ids.has(effectId)) effectId = _chunkT6H3JDGAcjs.newEffectId.call(void 0, );
5089
+ let effectId = _chunk4AB5BHYKcjs.newEffectId.call(void 0, );
5090
+ while (ids.has(effectId)) effectId = _chunk4AB5BHYKcjs.newEffectId.call(void 0, );
5058
5091
  const { id: _ignored, kind: _kind, ...rest } = params;
5059
- const effect = guard(() => _chunkT6H3JDGAcjs.mergeLayerEffect.call(void 0, _chunkT6H3JDGAcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
5092
+ const effect = guard(() => _chunk4AB5BHYKcjs.mergeLayerEffect.call(void 0, _chunk4AB5BHYKcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
5060
5093
  const items = [...current.items];
5061
5094
  const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
5062
5095
  items.splice(at, 0, effect);
@@ -5073,7 +5106,7 @@ function updateLayerEffect(layers, id, effectId, changes) {
5073
5106
  const i = requireEffect(layer, effectId);
5074
5107
  const current = layer.effects;
5075
5108
  const items = [...current.items];
5076
- items[i] = guard(() => _chunkT6H3JDGAcjs.mergeLayerEffect.call(void 0, items[i], changes));
5109
+ items[i] = guard(() => _chunk4AB5BHYKcjs.mergeLayerEffect.call(void 0, items[i], changes));
5077
5110
  return setLayerEffects(layers, id, { ...current, items });
5078
5111
  }
5079
5112
  function removeLayerEffect(layers, id, effectId) {
@@ -5187,8 +5220,8 @@ var PsdReader = class _PsdReader {
5187
5220
  return v;
5188
5221
  }
5189
5222
  /** A length field: 8 bytes in PSB where the format says so, else 4. */
5190
- len(long2) {
5191
- return long2 ? this.u64() : this.u32();
5223
+ len(long3) {
5224
+ return long3 ? this.u64() : this.u32();
5192
5225
  }
5193
5226
  bytes(n) {
5194
5227
  this.need(n, `${n} bytes`);
@@ -5295,11 +5328,11 @@ var PsdWriter = (_class4 = class {constructor() { _class4.prototype.__init24.cal
5295
5328
  this.length += n;
5296
5329
  }
5297
5330
  /** Reserves a length field; `endLen` fills it with the bytes written since. */
5298
- beginLen(long2) {
5331
+ beginLen(long3) {
5299
5332
  const at = this.length;
5300
- if (long2) this.u64(0);
5333
+ if (long3) this.u64(0);
5301
5334
  else this.u32(0);
5302
- return { at, long: long2 };
5335
+ return { at, long: long3 };
5303
5336
  }
5304
5337
  endLen(mark) {
5305
5338
  const n = this.length - mark.at - (mark.long ? 8 : 4);
@@ -5459,12 +5492,12 @@ function readValue(r, depth) {
5459
5492
  case "UntF":
5460
5493
  return { type, unit: r.ascii(4), value: r.f64() };
5461
5494
  case "UnFl": {
5462
- const unit = r.ascii(4);
5495
+ const unit2 = r.ascii(4);
5463
5496
  const n = r.u32();
5464
5497
  r.checkCount(n, 8, "Unit float list");
5465
5498
  const values = [];
5466
5499
  for (let i = 0; i < n; i++) values.push(r.f64());
5467
- return { type, unit, values };
5500
+ return { type, unit: unit2, values };
5468
5501
  }
5469
5502
  case "TEXT":
5470
5503
  return { type, value: r.unicode() };
@@ -5917,11 +5950,11 @@ function writeAdjustmentBlock(kind, params) {
5917
5950
  case "blackWhite": {
5918
5951
  const p = params;
5919
5952
  const tint = p.tint ? hexToRgb(p.tint) : BW_TINT;
5920
- const dbl = (v) => ({ type: "doub", value: clamp2(v, 0, 1) * 255 });
5953
+ const dbl2 = (v) => ({ type: "doub", value: clamp2(v, 0, 1) * 255 });
5921
5954
  const items = BW_KEYS.map(([field, key]) => [key, long(clamp2(p[field], -200, 300))]);
5922
5955
  items.push(
5923
5956
  ["useTint", { type: "bool", value: p.tint !== null }],
5924
- ["tintColor", { type: "Objc", value: descriptor("RGBC", [["Rd ", dbl(tint[0])], ["Grn ", dbl(tint[1])], ["Bl ", dbl(tint[2])]]) }],
5957
+ ["tintColor", { type: "Objc", value: descriptor("RGBC", [["Rd ", dbl2(tint[0])], ["Grn ", dbl2(tint[1])], ["Bl ", dbl2(tint[2])]]) }],
5925
5958
  ["bwPresetKind", { type: "long", value: 1 }],
5926
5959
  ["blackAndWhitePresetFileName", { type: "TEXT", value: "" }]
5927
5960
  );
@@ -6008,9 +6041,9 @@ function packbitsDecodeInto(src, expected, out, at) {
6008
6041
  function inflateChecked(data, expected) {
6009
6042
  let out;
6010
6043
  try {
6011
- out = _chunkT6H3JDGAcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
6044
+ out = _chunk4AB5BHYKcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
6012
6045
  } catch (e) {
6013
- throw new PsdError(`ZIP channel data: ${e instanceof _chunkT6H3JDGAcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
6046
+ throw new PsdError(`ZIP channel data: ${e instanceof _chunk4AB5BHYKcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
6014
6047
  }
6015
6048
  if (out.length < expected) throw new PsdError(`ZIP stream produced ${out.length} of ${expected} bytes.`);
6016
6049
  return out.length === expected ? out : out.subarray(0, expected);
@@ -6405,11 +6438,11 @@ function writeRect(w, r) {
6405
6438
  }
6406
6439
  function writeBlocks(w, blocks, psb, alignment) {
6407
6440
  for (const b of blocks) {
6408
- const long2 = psb && PSB_LONG_KEYS.has(b.key);
6409
- w.ascii(long2 ? "8B64" : "8BIM");
6441
+ const long3 = psb && PSB_LONG_KEYS.has(b.key);
6442
+ w.ascii(long3 ? "8B64" : "8BIM");
6410
6443
  w.ascii(b.key);
6411
6444
  const pad = (alignment - b.data.length % alignment) % alignment;
6412
- if (long2) w.u64(b.data.length + pad);
6445
+ if (long3) w.u64(b.data.length + pad);
6413
6446
  else w.u32(b.data.length + pad);
6414
6447
  w.bytes(b.data);
6415
6448
  w.zeros(pad);
@@ -6663,6 +6696,784 @@ function matteWhite(data) {
6663
6696
  return out;
6664
6697
  }
6665
6698
 
6699
+ // src/image-editor/psd/effects.ts
6700
+ var BLEND_CODES = [
6701
+ ["normal", "Nrml"],
6702
+ ["darken", "Drkn"],
6703
+ ["multiply", "Mltp"],
6704
+ ["color-burn", "CBrn"],
6705
+ ["linear-burn", "linearBurn"],
6706
+ ["darker-color", "darkerColor"],
6707
+ ["lighten", "Lghn"],
6708
+ ["screen", "Scrn"],
6709
+ ["color-dodge", "CDdg"],
6710
+ ["linear-dodge", "linearDodge"],
6711
+ ["lighter-color", "lighterColor"],
6712
+ ["overlay", "Ovrl"],
6713
+ ["soft-light", "SftL"],
6714
+ ["hard-light", "HrdL"],
6715
+ ["vivid-light", "vividLight"],
6716
+ ["linear-light", "linearLight"],
6717
+ ["pin-light", "pinLight"],
6718
+ ["hard-mix", "hardMix"],
6719
+ ["difference", "Dfrn"],
6720
+ ["exclusion", "Xclu"],
6721
+ ["subtract", "blendSubtraction"],
6722
+ ["divide", "blendDivide"],
6723
+ ["hue", "H "],
6724
+ ["saturation", "Strt"],
6725
+ ["color", "Clr "],
6726
+ ["luminosity", "Lmns"]
6727
+ ];
6728
+ var BLEND_LONG = [
6729
+ ["normal", "normal"],
6730
+ ["darken", "darken"],
6731
+ ["multiply", "multiply"],
6732
+ ["color-burn", "colorBurn"],
6733
+ ["lighten", "lighten"],
6734
+ ["screen", "screen"],
6735
+ ["color-dodge", "colorDodge"],
6736
+ ["overlay", "overlay"],
6737
+ ["soft-light", "softLight"],
6738
+ ["hard-light", "hardLight"],
6739
+ ["difference", "difference"],
6740
+ ["exclusion", "exclusion"],
6741
+ ["hue", "hue"],
6742
+ ["saturation", "saturation"],
6743
+ ["color", "color"],
6744
+ ["luminosity", "luminosity"]
6745
+ ];
6746
+ var BLEND_OF = new Map([...BLEND_CODES, ...BLEND_LONG].map(([m, id]) => [id, m]));
6747
+ var BLEND_ID = new Map(BLEND_CODES);
6748
+ var num2 = (d, key, fallback) => _nullishCoalesce(descNumber(d, key), () => ( fallback));
6749
+ var pct = (d, key, fallback) => num2(d, key, fallback * 100) / 100;
6750
+ var bool = (d, key) => descBool(d, key) === true;
6751
+ var enumOf = (d, key) => {
6752
+ const v = descGet(d, key);
6753
+ return _optionalChain([v, 'optionalAccess', _116 => _116.type]) === "enum" ? v.value : void 0;
6754
+ };
6755
+ var text = (d, key) => {
6756
+ const v = d ? descGet(d, key) : void 0;
6757
+ return _optionalChain([v, 'optionalAccess', _117 => _117.type]) === "TEXT" ? v.value : "";
6758
+ };
6759
+ var list = (d, key) => {
6760
+ const v = descGet(d, key);
6761
+ if (_optionalChain([v, 'optionalAccess', _118 => _118.type]) !== "VlLs") return [];
6762
+ return v.items.flatMap((it) => it.type === "Objc" || it.type === "GlbO" ? [it.value] : []);
6763
+ };
6764
+ var clamp3 = (v, lo, hi) => Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : lo;
6765
+ var unit = (u, value) => ({ type: "UntF", unit: u, value });
6766
+ var dbl = (value) => ({ type: "doub", value });
6767
+ var long2 = (value) => ({ type: "long", value: Math.round(value) });
6768
+ var boolV = (value) => ({ type: "bool", value });
6769
+ var enumV = (typeId, value) => ({ type: "enum", typeId, value });
6770
+ var textV = (value) => ({ type: "TEXT", value });
6771
+ var obj = (d) => ({ type: "Objc", value: d });
6772
+ function blendOf(d, key, fallback, notes) {
6773
+ const id = enumOf(d, key);
6774
+ if (id === void 0) return fallback;
6775
+ const m = BLEND_OF.get(id);
6776
+ if (m) return m;
6777
+ notes.add(id === "Dslv" || id === "dissolve" ? "Dissolve became Normal" : `an unknown blend mode "${id}" became Normal`);
6778
+ return "normal";
6779
+ }
6780
+ function colorOf(d, fallback = "#000000") {
6781
+ if (!d) return fallback;
6782
+ const g = (k) => descNumber(d, k);
6783
+ if (g("redFloat") !== void 0) return _chunk4AB5BHYKcjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
6784
+ switch (d.classId) {
6785
+ case "HSBC": {
6786
+ const rgb = decodePsdColor(1, [(_nullishCoalesce(g("H "), () => ( 0))) / 360 * 65535, (_nullishCoalesce(g("Strt"), () => ( 0))) / 100 * 65535, (_nullishCoalesce(g("Brgh"), () => ( 0))) / 100 * 65535]);
6787
+ return rgb ? _chunk4AB5BHYKcjs.effectColorHex.call(void 0, rgb) : fallback;
6788
+ }
6789
+ case "CMYC": {
6790
+ const inv = (k) => (1 - (_nullishCoalesce(g(k), () => ( 0))) / 100) * 65535;
6791
+ const rgb = decodePsdColor(2, [inv("Cyn "), inv("Mgnt"), inv("Ylw "), inv("Blck")]);
6792
+ return rgb ? _chunk4AB5BHYKcjs.effectColorHex.call(void 0, rgb) : fallback;
6793
+ }
6794
+ case "LbCl": {
6795
+ 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]);
6796
+ return rgb ? _chunk4AB5BHYKcjs.effectColorHex.call(void 0, rgb) : fallback;
6797
+ }
6798
+ case "Grsc": {
6799
+ const v = 1 - (_nullishCoalesce(g("Gry "), () => ( 0))) / 100;
6800
+ return _chunk4AB5BHYKcjs.effectColorHex.call(void 0, [v, v, v]);
6801
+ }
6802
+ }
6803
+ const r = g("Rd ");
6804
+ const gr = g("Grn ");
6805
+ const b = g("Bl ");
6806
+ if (r === void 0 || gr === void 0 || b === void 0) return fallback;
6807
+ return _chunk4AB5BHYKcjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
6808
+ }
6809
+ function colorDesc(hex) {
6810
+ const [r, g, b] = _nullishCoalesce(_chunk4AB5BHYKcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
6811
+ return descriptor("RGBC", [
6812
+ ["Rd ", dbl(r * 255)],
6813
+ ["Grn ", dbl(g * 255)],
6814
+ ["Bl ", dbl(b * 255)]
6815
+ ]);
6816
+ }
6817
+ function contourOf(d, key) {
6818
+ const c = descObject(d, key);
6819
+ if (!c) return void 0;
6820
+ const name = text(c, "Nm ");
6821
+ const points = list(c, "Crv ").map((p) => {
6822
+ const out = { input: clamp3(num2(p, "Hrzn", 0) / 255, 0, 1), output: clamp3(num2(p, "Vrtc", 0) / 255, 0, 1) };
6823
+ if (descBool(p, "Cnty") === false) out.corner = true;
6824
+ return out;
6825
+ });
6826
+ const linear = points.length === 2 && points[0].input === 0 && points[0].output === 0 && points[1].input === 1 && points[1].output === 1 && !points.some((p) => p.corner);
6827
+ if (points.length < 2 || linear && (!name || name === "Linear")) return void 0;
6828
+ return { name, points };
6829
+ }
6830
+ function contourDesc(c) {
6831
+ const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _119 => _119.name]), () => ( "Linear"));
6832
+ const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _120 => _120.points]), () => ( [
6833
+ { input: 0, output: 0 },
6834
+ { input: 1, output: 1 }
6835
+ ]));
6836
+ const pts = {
6837
+ type: "VlLs",
6838
+ items: points.map((p) => {
6839
+ const items = [
6840
+ ["Hrzn", dbl(p.input * 255)],
6841
+ ["Vrtc", dbl(p.output * 255)]
6842
+ ];
6843
+ if (p.corner) items.push(["Cnty", boolV(false)]);
6844
+ return obj(descriptor("CrPt", items));
6845
+ })
6846
+ };
6847
+ return obj(
6848
+ descriptor("ShpC", [
6849
+ ["Nm ", textV(name)],
6850
+ ["Crv ", pts]
6851
+ ])
6852
+ );
6853
+ }
6854
+ var GRADIENT_STYLES = [
6855
+ ["linear", "Lnr "],
6856
+ ["radial", "Rdl "],
6857
+ ["angle", "Angl"],
6858
+ ["reflected", "Rflc"],
6859
+ ["diamond", "Dmnd"]
6860
+ ];
6861
+ function gradientOf(d, notes) {
6862
+ const g = {
6863
+ stops: [
6864
+ { position: 0, color: "#000000" },
6865
+ { position: 1, color: "#ffffff" }
6866
+ ],
6867
+ style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _121 => _121.find, 'call', _122 => _122(([, id]) => id === enumOf(d, "Type")), 'optionalAccess', _123 => _123[0]]), () => ( "linear")),
6868
+ angle: clamp3(num2(d, "Angl", 90), -360, 360),
6869
+ scale: clamp3(pct(d, "Scl ", 1), 0.1, 1.5),
6870
+ reverse: bool(d, "Rvrs"),
6871
+ align: descBool(d, "Algn") !== false,
6872
+ offset: { x: 0, y: 0 }
6873
+ };
6874
+ const off = descObject(d, "Ofst");
6875
+ if (off) g.offset = { x: clamp3(pct(off, "Hrzn", 0), -1, 1), y: clamp3(pct(off, "Vrtc", 0), -1, 1) };
6876
+ const grad = descObject(d, "Grad");
6877
+ if (!grad) return g;
6878
+ if (enumOf(grad, "GrdF") === "ClNs") {
6879
+ notes.add("noise gradients became black to white");
6880
+ return g;
6881
+ }
6882
+ const raw = list(grad, "Clrs").map((s) => {
6883
+ const type = enumOf(s, "Type");
6884
+ if (type === "FrgC" || type === "BckC") notes.add("foreground / background gradient stops became black / white");
6885
+ const color = type === "BckC" ? "#ffffff" : colorOf(descObject(s, "Clr "));
6886
+ return { position: clamp3(num2(s, "Lctn", 0) / 4096, 0, 1), color, mid: clamp3(num2(s, "Mdpn", 50) / 100, 0.05, 0.95) };
6887
+ }).sort((a, b) => a.position - b.position);
6888
+ if (raw.length) {
6889
+ const stops = [];
6890
+ raw.forEach((s, i) => {
6891
+ if (i > 0 && Math.abs(s.mid - 0.5) > 1e-3) {
6892
+ const a = raw[i - 1];
6893
+ const ca = _chunk4AB5BHYKcjs.parseEffectColor.call(void 0, a.color);
6894
+ const cb = _chunk4AB5BHYKcjs.parseEffectColor.call(void 0, s.color);
6895
+ stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunk4AB5BHYKcjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
6896
+ notes.add("gradient midpoints are drawn as straight segments");
6897
+ }
6898
+ stops.push({ position: s.position, color: s.color });
6899
+ });
6900
+ g.stops = stops;
6901
+ }
6902
+ const opacity = list(grad, "Trns").map((s) => ({ position: clamp3(num2(s, "Lctn", 0) / 4096, 0, 1), opacity: clamp3(num2(s, "Opct", 100) / 100, 0, 1) })).sort((a, b) => a.position - b.position);
6903
+ if (opacity.some((o) => o.opacity < 1)) g.opacityStops = opacity;
6904
+ if (num2(grad, "Intr", 0) > 0) notes.add("gradient smoothness is drawn as straight segments");
6905
+ return g;
6906
+ }
6907
+ function gradientItems(g) {
6908
+ const clrs = {
6909
+ type: "VlLs",
6910
+ items: g.stops.map(
6911
+ (s) => obj(
6912
+ descriptor("Clrt", [
6913
+ ["Clr ", obj(colorDesc(s.color))],
6914
+ ["Type", enumV("Clry", "UsrS")],
6915
+ ["Lctn", long2(s.position * 4096)],
6916
+ ["Mdpn", long2(50)]
6917
+ ])
6918
+ )
6919
+ )
6920
+ };
6921
+ const op = _optionalChain([g, 'access', _124 => _124.opacityStops, 'optionalAccess', _125 => _125.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
6922
+ const trns = {
6923
+ type: "VlLs",
6924
+ items: op.map(
6925
+ (s) => obj(
6926
+ descriptor("TrnS", [
6927
+ ["Opct", unit("#Prc", s.opacity * 100)],
6928
+ ["Lctn", long2(s.position * 4096)],
6929
+ ["Mdpn", long2(50)]
6930
+ ])
6931
+ )
6932
+ )
6933
+ };
6934
+ const grad = descriptor("Grdn", [
6935
+ ["Nm ", textV("Custom")],
6936
+ ["GrdF", enumV("GrdF", "CstS")],
6937
+ ["Intr", dbl(0)],
6938
+ ["Clrs", clrs],
6939
+ ["Trns", trns]
6940
+ ]);
6941
+ return [
6942
+ ["Grad", obj(grad)],
6943
+ ["Angl", unit("#Ang", g.angle)],
6944
+ ["Type", enumV("GrdT", GRADIENT_STYLES.find(([s]) => s === g.style)[1])],
6945
+ ["Rvrs", boolV(g.reverse)],
6946
+ ["Algn", boolV(g.align)],
6947
+ ["Scl ", unit("#Prc", g.scale * 100)],
6948
+ [
6949
+ "Ofst",
6950
+ obj(
6951
+ descriptor("Pnt ", [
6952
+ ["Hrzn", unit("#Prc", g.offset.x * 100)],
6953
+ ["Vrtc", unit("#Prc", g.offset.y * 100)]
6954
+ ])
6955
+ )
6956
+ ]
6957
+ ];
6958
+ }
6959
+ function patternRefOf(d) {
6960
+ const p = descObject(d, "Ptrn");
6961
+ return { patternId: text(p, "Idnt") || text(p, "Nm "), name: text(p, "Nm ") };
6962
+ }
6963
+ function patternRefDesc(patternId, name) {
6964
+ return obj(
6965
+ descriptor("Ptrn", [
6966
+ ["Nm ", textV(_nullishCoalesce(name, () => ( patternId)))],
6967
+ ["Idnt", textV(patternId)]
6968
+ ])
6969
+ );
6970
+ }
6971
+ function placementOf(d) {
6972
+ const phase = descObject(d, "phase");
6973
+ return {
6974
+ angle: clamp3(num2(d, "Angl", 0), -360, 360),
6975
+ link: descBool(d, "Algn") !== false,
6976
+ phase: phase ? { x: num2(phase, "Hrzn", 0), y: num2(phase, "Vrtc", 0) } : { x: 0, y: 0 }
6977
+ };
6978
+ }
6979
+ function placementItems(angle, link, phase) {
6980
+ const out = [];
6981
+ if (angle) out.push(["Angl", unit("#Ang", angle)]);
6982
+ out.push(["Algn", boolV(link)]);
6983
+ out.push([
6984
+ "phase",
6985
+ obj(
6986
+ descriptor("Pnt ", [
6987
+ ["Hrzn", dbl(phase.x)],
6988
+ ["Vrtc", dbl(phase.y)]
6989
+ ])
6990
+ )
6991
+ ]);
6992
+ return out;
6993
+ }
6994
+ var KINDS = [
6995
+ ["DrSh", "dropShadowMulti", "drop-shadow"],
6996
+ ["IrSh", "innerShadowMulti", "inner-shadow"],
6997
+ ["OrGl", "", "outer-glow"],
6998
+ ["IrGl", "", "inner-glow"],
6999
+ ["ebbl", "", "bevel-emboss"],
7000
+ ["ChFX", "", "satin"],
7001
+ ["SoFi", "solidFillMulti", "color-overlay"],
7002
+ ["GrFl", "gradientFillMulti", "gradient-overlay"],
7003
+ ["patternFill", "", "pattern-overlay"],
7004
+ ["FrFX", "frameFXMulti", "stroke"]
7005
+ ];
7006
+ function common(d, kind, notes) {
7007
+ const def = _chunk4AB5BHYKcjs.defaultLayerEffect.call(void 0, kind, "x");
7008
+ return { id: _chunk4AB5BHYKcjs.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) };
7009
+ }
7010
+ function readOne(kind, d, notes) {
7011
+ const size = (key, fallback) => clamp3(num2(d, key, fallback), 0, 250);
7012
+ switch (kind) {
7013
+ case "drop-shadow":
7014
+ case "inner-shadow": {
7015
+ const base = {
7016
+ ...common(d, kind, notes),
7017
+ color: colorOf(descObject(d, "Clr ")),
7018
+ angle: clamp3(num2(d, "lagl", 120), -360, 360),
7019
+ useGlobalLight: descBool(d, "uglg") !== false,
7020
+ distance: clamp3(num2(d, "Dstn", 5), 0, 3e4),
7021
+ size: size("blur", 5),
7022
+ contour: contourOf(d, "TrnS"),
7023
+ antiAlias: bool(d, "AntA"),
7024
+ noise: clamp3(pct(d, "Nose", 0), 0, 1)
7025
+ };
7026
+ const spread = clamp3(pct(d, "Ckmt", 0), 0, 1);
7027
+ return kind === "drop-shadow" ? { ...base, kind, spread, knocksOut: descBool(d, "layerConceals") !== false } : { ...base, kind, choke: spread };
7028
+ }
7029
+ case "outer-glow":
7030
+ case "inner-glow": {
7031
+ const fill = descGet(d, "Grad") ? { type: "gradient", gradient: gradientOf(d, notes) } : { type: "color", color: colorOf(descObject(d, "Clr "), "#ffffbe") };
7032
+ const jitter = clamp3(pct(d, "ShdN", 0), 0, 1);
7033
+ if (jitter > 0) notes.add("glow jitter is not drawn");
7034
+ const base = {
7035
+ ...common(d, kind, notes),
7036
+ fill,
7037
+ technique: enumOf(d, "GlwT") === "PrBL" ? "precise" : "softer",
7038
+ size: size("blur", 5),
7039
+ contour: contourOf(d, "TrnS"),
7040
+ antiAlias: bool(d, "AntA"),
7041
+ range: clamp3(pct(d, "Inpr", 0.5), 0.01, 1),
7042
+ jitter,
7043
+ noise: clamp3(pct(d, "Nose", 0), 0, 1)
7044
+ };
7045
+ const spread = clamp3(pct(d, "Ckmt", 0), 0, 1);
7046
+ return kind === "outer-glow" ? { ...base, kind, spread } : { ...base, kind, choke: spread, source: enumOf(d, "glwS") === "SrcC" ? "center" : "edge" };
7047
+ }
7048
+ case "bevel-emboss": {
7049
+ const styles = { OtrB: "outer-bevel", InrB: "inner-bevel", Embs: "emboss", PlEb: "pillow-emboss", strokeEmboss: "stroke-emboss" };
7050
+ const out = {
7051
+ id: _chunk4AB5BHYKcjs.newEffectId.call(void 0, ),
7052
+ enabled: descBool(d, "enab") !== false,
7053
+ kind,
7054
+ style: _nullishCoalesce(styles[_nullishCoalesce(enumOf(d, "bvlS"), () => ( ""))], () => ( "inner-bevel")),
7055
+ technique: enumOf(d, "bvlT") === "PrBL" ? "chisel-hard" : enumOf(d, "bvlT") === "Slmt" ? "chisel-soft" : "smooth",
7056
+ depth: clamp3(pct(d, "srgR", 1), 0, 10),
7057
+ direction: enumOf(d, "bvlD") === "Out " ? "down" : "up",
7058
+ size: size("blur", 5),
7059
+ soften: clamp3(num2(d, "Sftn", 0), 0, 16),
7060
+ angle: clamp3(num2(d, "lagl", 120), -360, 360),
7061
+ altitude: clamp3(num2(d, "Lald", 30), 0, 90),
7062
+ useGlobalLight: descBool(d, "uglg") !== false,
7063
+ glossContour: contourOf(d, "TrnS"),
7064
+ highlightColor: colorOf(descObject(d, "hglC"), "#ffffff"),
7065
+ highlightBlend: blendOf(d, "hglM", "screen", notes),
7066
+ highlightOpacity: clamp3(pct(d, "hglO", 0.75), 0, 1),
7067
+ shadowColor: colorOf(descObject(d, "sdwC")),
7068
+ shadowBlend: blendOf(d, "sdwM", "multiply", notes),
7069
+ shadowOpacity: clamp3(pct(d, "sdwO", 0.75), 0, 1)
7070
+ };
7071
+ if (bool(d, "useShape")) out.contourElement = { contour: _nullishCoalesce(contourOf(d, "MpgS"), () => ( { name: "Linear", points: [{ input: 0, output: 0 }, { input: 1, output: 1 }] })), range: clamp3(pct(d, "Inpr", 0.5), 0, 1), antiAlias: bool(d, "AntA") };
7072
+ if (bool(d, "useTexture")) {
7073
+ const ref = patternRefOf(d);
7074
+ const place = placementOf(d);
7075
+ out.texture = { patternId: ref.patternId, name: ref.name, scale: clamp3(pct(d, "Scl ", 1), 0.01, 10), depth: clamp3(pct(d, "textureDepth", 1), -10, 10), invert: bool(d, "InvT"), link: place.link, phase: place.phase };
7076
+ }
7077
+ return out;
7078
+ }
7079
+ case "satin":
7080
+ return {
7081
+ ...common(d, kind, notes),
7082
+ kind,
7083
+ color: colorOf(descObject(d, "Clr ")),
7084
+ angle: clamp3(num2(d, "lagl", 19), -360, 360),
7085
+ distance: size("Dstn", 11),
7086
+ size: size("blur", 14),
7087
+ contour: contourOf(d, "MpgS"),
7088
+ antiAlias: bool(d, "AntA"),
7089
+ invert: bool(d, "Invr")
7090
+ };
7091
+ case "color-overlay":
7092
+ return { ...common(d, kind, notes), kind, color: colorOf(descObject(d, "Clr ")) };
7093
+ case "gradient-overlay":
7094
+ return { ...common(d, kind, notes), kind, gradient: gradientOf(d, notes), dither: bool(d, "Dthr") };
7095
+ case "pattern-overlay": {
7096
+ const ref = patternRefOf(d);
7097
+ const place = placementOf(d);
7098
+ return { ...common(d, kind, notes), kind, patternId: ref.patternId, name: ref.name, scale: clamp3(pct(d, "Scl ", 1), 0.01, 10), angle: place.angle, link: place.link, phase: place.phase };
7099
+ }
7100
+ case "stroke": {
7101
+ const paint = enumOf(d, "PntT");
7102
+ let fill;
7103
+ if (paint === "GrFl") fill = { type: "gradient", gradient: gradientOf(d, notes) };
7104
+ else if (paint === "Ptrn") {
7105
+ const ref = patternRefOf(d);
7106
+ fill = { type: "pattern", patternId: ref.patternId, name: ref.name, scale: clamp3(pct(d, "Scl ", 1), 0.01, 10) };
7107
+ } else fill = { type: "color", color: colorOf(descObject(d, "Clr ")) };
7108
+ const pos = enumOf(d, "Styl");
7109
+ return { ...common(d, kind, notes), kind, size: size("Sz ", 3), position: pos === "InsF" ? "inside" : pos === "CtrF" ? "center" : "outside", fill };
7110
+ }
7111
+ }
7112
+ }
7113
+ function parseLfx2(data) {
7114
+ let d;
7115
+ try {
7116
+ d = parseVersionedDescriptor(data.subarray(4));
7117
+ } catch (e17) {
7118
+ return null;
7119
+ }
7120
+ const notes = /* @__PURE__ */ new Set();
7121
+ const items = [];
7122
+ for (const [single, multi, kind] of KINDS) {
7123
+ const many = multi ? list(d, multi) : [];
7124
+ const one = descObject(d, single);
7125
+ for (const x of many.length ? many : one ? [one] : []) {
7126
+ if (descBool(x, "present") === false) continue;
7127
+ items.push(readOne(kind, x, notes));
7128
+ }
7129
+ }
7130
+ const effects = { enabled: descBool(d, "masterFXSwitch") !== false, items };
7131
+ return { effects, notes: [...notes] };
7132
+ }
7133
+ function commonItems(e) {
7134
+ return [
7135
+ ["enab", boolV(e.enabled)],
7136
+ ["present", boolV(true)],
7137
+ ["showInDialog", boolV(true)],
7138
+ ["Md ", enumV("BlnM", _nullishCoalesce(BLEND_ID.get(e.blend), () => ( "Nrml")))],
7139
+ ["Opct", unit("#Prc", e.opacity * 100)]
7140
+ ];
7141
+ }
7142
+ function writeOne(e) {
7143
+ switch (e.kind) {
7144
+ case "drop-shadow":
7145
+ case "inner-shadow": {
7146
+ const inner = e.kind === "inner-shadow";
7147
+ const items = [
7148
+ ...commonItems(e),
7149
+ ["Clr ", obj(colorDesc(e.color))],
7150
+ ["uglg", boolV(e.useGlobalLight)],
7151
+ ["lagl", unit("#Ang", e.angle)],
7152
+ ["Dstn", unit("#Pxl", e.distance)],
7153
+ ["Ckmt", unit("#Pxl", (inner ? e.choke : e.spread) * 100)],
7154
+ ["blur", unit("#Pxl", e.size)],
7155
+ ["Nose", unit("#Prc", e.noise * 100)],
7156
+ ["AntA", boolV(e.antiAlias)],
7157
+ ["TrnS", contourDesc(e.contour)]
7158
+ ];
7159
+ if (e.kind === "drop-shadow") items.push(["layerConceals", boolV(e.knocksOut)]);
7160
+ return descriptor(inner ? "IrSh" : "DrSh", items);
7161
+ }
7162
+ case "outer-glow":
7163
+ case "inner-glow": {
7164
+ const inner = e.kind === "inner-glow";
7165
+ const items = [...commonItems(e)];
7166
+ if (e.fill.type === "gradient") items.push(...gradientItems(e.fill.gradient));
7167
+ else items.push(["Clr ", obj(colorDesc(e.fill.color))]);
7168
+ items.push(
7169
+ ["GlwT", enumV("BETE", e.technique === "precise" ? "PrBL" : "SfBL")],
7170
+ ["Ckmt", unit("#Pxl", (inner ? e.choke : e.spread) * 100)],
7171
+ ["blur", unit("#Pxl", e.size)],
7172
+ ["Nose", unit("#Prc", e.noise * 100)],
7173
+ ["ShdN", unit("#Prc", e.jitter * 100)],
7174
+ ["AntA", boolV(e.antiAlias)],
7175
+ ["TrnS", contourDesc(e.contour)],
7176
+ ["Inpr", unit("#Prc", e.range * 100)]
7177
+ );
7178
+ if (e.kind === "inner-glow") items.push(["glwS", enumV("IGSr", e.source === "center" ? "SrcC" : "SrcE")]);
7179
+ return descriptor(inner ? "IrGl" : "OrGl", items);
7180
+ }
7181
+ case "bevel-emboss": {
7182
+ const style = { "outer-bevel": "OtrB", "inner-bevel": "InrB", emboss: "Embs", "pillow-emboss": "PlEb", "stroke-emboss": "strokeEmboss" }[e.style];
7183
+ const tech = { smooth: "SfBL", "chisel-hard": "PrBL", "chisel-soft": "Slmt" }[e.technique];
7184
+ const items = [
7185
+ ["enab", boolV(e.enabled)],
7186
+ ["present", boolV(true)],
7187
+ ["showInDialog", boolV(true)],
7188
+ ["hglM", enumV("BlnM", _nullishCoalesce(BLEND_ID.get(e.highlightBlend), () => ( "Scrn")))],
7189
+ ["hglC", obj(colorDesc(e.highlightColor))],
7190
+ ["hglO", unit("#Prc", e.highlightOpacity * 100)],
7191
+ ["sdwM", enumV("BlnM", _nullishCoalesce(BLEND_ID.get(e.shadowBlend), () => ( "Mltp")))],
7192
+ ["sdwC", obj(colorDesc(e.shadowColor))],
7193
+ ["sdwO", unit("#Prc", e.shadowOpacity * 100)],
7194
+ ["bvlT", enumV("bvlT", tech)],
7195
+ ["bvlS", enumV("BESl", style)],
7196
+ ["uglg", boolV(e.useGlobalLight)],
7197
+ ["lagl", unit("#Ang", e.angle)],
7198
+ ["Lald", unit("#Ang", e.altitude)],
7199
+ ["srgR", unit("#Prc", e.depth * 100)],
7200
+ ["blur", unit("#Pxl", e.size)],
7201
+ ["bvlD", enumV("BESs", e.direction === "up" ? "In " : "Out ")],
7202
+ ["TrnS", contourDesc(e.glossContour)],
7203
+ ["Sftn", unit("#Pxl", e.soften)]
7204
+ ];
7205
+ if (e.contourElement) {
7206
+ items.push(["useShape", boolV(true)], ["MpgS", contourDesc(e.contourElement.contour)], ["AntA", boolV(e.contourElement.antiAlias)], ["Inpr", unit("#Prc", e.contourElement.range * 100)]);
7207
+ } else items.push(["useShape", boolV(false)]);
7208
+ if (e.texture) {
7209
+ const t = e.texture;
7210
+ items.push(
7211
+ ["useTexture", boolV(true)],
7212
+ ["InvT", boolV(t.invert)],
7213
+ ["Scl ", unit("#Prc", t.scale * 100)],
7214
+ ["textureDepth", unit("#Prc", t.depth * 100)],
7215
+ ["Ptrn", patternRefDesc(t.patternId, t.name)],
7216
+ ...placementItems(0, _nullishCoalesce(t.link, () => ( true)), _nullishCoalesce(t.phase, () => ( { x: 0, y: 0 })))
7217
+ );
7218
+ } else items.push(["useTexture", boolV(false)]);
7219
+ return descriptor("ebbl", items);
7220
+ }
7221
+ case "satin":
7222
+ return descriptor("ChFX", [
7223
+ ...commonItems(e),
7224
+ ["Clr ", obj(colorDesc(e.color))],
7225
+ ["AntA", boolV(e.antiAlias)],
7226
+ ["Invr", boolV(e.invert)],
7227
+ ["lagl", unit("#Ang", e.angle)],
7228
+ ["Dstn", unit("#Pxl", e.distance)],
7229
+ ["blur", unit("#Pxl", e.size)],
7230
+ ["MpgS", contourDesc(e.contour)]
7231
+ ]);
7232
+ case "color-overlay":
7233
+ return descriptor("SoFi", [...commonItems(e), ["Clr ", obj(colorDesc(e.color))]]);
7234
+ case "gradient-overlay":
7235
+ return descriptor("GrFl", [...commonItems(e), ...gradientItems(e.gradient), ["Dthr", boolV(e.dither)]]);
7236
+ case "pattern-overlay":
7237
+ return descriptor("patternFill", [
7238
+ ...commonItems(e),
7239
+ ["Ptrn", patternRefDesc(e.patternId, e.name)],
7240
+ ["Scl ", unit("#Prc", e.scale * 100)],
7241
+ ...placementItems(_nullishCoalesce(e.angle, () => ( 0)), _nullishCoalesce(e.link, () => ( true)), _nullishCoalesce(e.phase, () => ( { x: 0, y: 0 })))
7242
+ ]);
7243
+ case "stroke": {
7244
+ const items = [
7245
+ ...commonItems(e),
7246
+ ["Styl", enumV("FStl", e.position === "inside" ? "InsF" : e.position === "center" ? "CtrF" : "OutF")],
7247
+ ["Sz ", unit("#Pxl", e.size)]
7248
+ ];
7249
+ const f = e.fill;
7250
+ if (f.type === "color") items.push(["PntT", enumV("FrFl", "SClr")], ["Clr ", obj(colorDesc(f.color))]);
7251
+ else if (f.type === "gradient") items.push(["PntT", enumV("FrFl", "GrFl")], ...gradientItems(f.gradient));
7252
+ else items.push(["PntT", enumV("FrFl", "Ptrn")], ["Ptrn", patternRefDesc(f.patternId, f.name)], ["Scl ", unit("#Prc", f.scale * 100)]);
7253
+ return descriptor("FrFX", items);
7254
+ }
7255
+ }
7256
+ }
7257
+ function writeLfx2(effects) {
7258
+ const items = [
7259
+ ["Scl ", unit("#Prc", 100)],
7260
+ ["masterFXSwitch", boolV(effects.enabled)]
7261
+ ];
7262
+ const scale = _chunk4AB5BHYKcjs.effectsScale.call(void 0, effects);
7263
+ let dropped = 0;
7264
+ for (const [single, multi, kind] of KINDS) {
7265
+ const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunk4AB5BHYKcjs.scaleLayerEffect.call(void 0, e, scale)));
7266
+ if (!of.length) continue;
7267
+ if (of.length === 1) items.push([single, obj(of[0])]);
7268
+ else if (multi) items.push([multi, { type: "VlLs", items: of.map(obj) }]);
7269
+ else {
7270
+ items.push([single, obj(of[0])]);
7271
+ dropped += of.length - 1;
7272
+ }
7273
+ }
7274
+ const body = versionedDescriptorBytes(descriptor("null", items));
7275
+ const w = new PsdWriter();
7276
+ w.u32(0);
7277
+ w.bytes(body);
7278
+ if (w.length % 2) w.u8(0);
7279
+ return { data: w.result(), dropped };
7280
+ }
7281
+ function parseLrfx(data) {
7282
+ try {
7283
+ const r = new PsdReader(data);
7284
+ r.u16();
7285
+ const count = r.u16();
7286
+ const items = [];
7287
+ const notes = /* @__PURE__ */ new Set();
7288
+ const fixed = (v) => (v | 0) / 65536;
7289
+ for (let i = 0; i < count; i++) {
7290
+ if (new TextDecoder().decode(r.bytes(4)) !== "8BIM") return null;
7291
+ const key = new TextDecoder().decode(r.bytes(4));
7292
+ const size = r.u32();
7293
+ const b = new PsdReader(r.bytes(size));
7294
+ const colorAt = (rd) => {
7295
+ rd.u16();
7296
+ const c = [rd.u16(), rd.u16(), rd.u16(), rd.u16()];
7297
+ return _chunk4AB5BHYKcjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
7298
+ };
7299
+ const blendAt = (rd) => {
7300
+ rd.skip(4);
7301
+ const k = new TextDecoder().decode(rd.bytes(4));
7302
+ const m = PSD_BLEND_KEYS[k];
7303
+ return m && m !== "pass-through" ? m : "normal";
7304
+ };
7305
+ if (key === "dsdw" || key === "isdw") {
7306
+ b.u32();
7307
+ const blur = fixed(b.u32());
7308
+ b.u32();
7309
+ const angle = fixed(b.u32());
7310
+ const distance = fixed(b.u32());
7311
+ const color = colorAt(b);
7312
+ const blend = blendAt(b);
7313
+ const enabled = b.u8() !== 0;
7314
+ const useGlobalLight = b.u8() !== 0;
7315
+ const opacity = b.u8() / 255;
7316
+ const base = { id: _chunk4AB5BHYKcjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
7317
+ items.push(key === "dsdw" ? { ...base, kind: "drop-shadow", spread: 0, knocksOut: true } : { ...base, kind: "inner-shadow", choke: 0 });
7318
+ } else if (key === "oglw" || key === "iglw") {
7319
+ b.u32();
7320
+ const blur = fixed(b.u32());
7321
+ b.u32();
7322
+ const color = colorAt(b);
7323
+ const blend = blendAt(b);
7324
+ const enabled = b.u8() !== 0;
7325
+ const opacity = b.u8() / 255;
7326
+ const base = { id: _chunk4AB5BHYKcjs.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 };
7327
+ items.push(key === "oglw" ? { ...base, kind: "outer-glow", spread: 0 } : { ...base, kind: "inner-glow", choke: 0, source: "edge" });
7328
+ } else if (key === "sofi") {
7329
+ b.u32();
7330
+ const blend = blendAt(b);
7331
+ const color = colorAt(b);
7332
+ const opacity = b.u8() / 255;
7333
+ const enabled = b.u8() !== 0;
7334
+ items.push({ id: _chunk4AB5BHYKcjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
7335
+ } else if (key === "bevl") notes.add("legacy bevels are not read");
7336
+ }
7337
+ return { effects: { enabled: true, items }, notes: [...notes] };
7338
+ } catch (e18) {
7339
+ return null;
7340
+ }
7341
+ }
7342
+
7343
+ // src/image-editor/psd/patterns.ts
7344
+ var MAX_EDGE = 3e4;
7345
+ var PATTERN_BLOCK_KEYS = ["Patt", "Pat2", "Pat3"];
7346
+ function modeChannels(mode) {
7347
+ return mode === MODE_RGB || mode === MODE_LAB ? 3 : mode === MODE_CMYK ? 4 : 1;
7348
+ }
7349
+ var rowBytes2 = (width, depth) => depth === 1 ? Math.ceil(width / 8) : width * (depth / 8);
7350
+ function readPattern(r) {
7351
+ const version = r.u32();
7352
+ if (version !== 1) throw new PsdError(`Pattern version ${version}, expected 1.`);
7353
+ const mode = r.u32();
7354
+ r.u16();
7355
+ r.u16();
7356
+ const name = r.unicode();
7357
+ const idLength = r.u8();
7358
+ const id = new TextDecoder().decode(r.bytes(idLength));
7359
+ let palette;
7360
+ if (mode === MODE_INDEXED) {
7361
+ palette = r.bytes(768).slice();
7362
+ const next = r.peek(4);
7363
+ if (next.length === 4 && !(next[0] === 0 && next[1] === 0 && next[2] === 0 && next[3] === 3)) r.skip(4);
7364
+ }
7365
+ const vmaVersion = r.u32();
7366
+ if (vmaVersion !== 3) throw new PsdError(`Pattern virtual memory array list version ${vmaVersion}, expected 3.`);
7367
+ const length = r.u32();
7368
+ const body = new PsdReader(r.bytes(length));
7369
+ const [top, left, bottom, right] = [body.i32(), body.i32(), body.i32(), body.i32()];
7370
+ const width = right - left;
7371
+ const height = bottom - top;
7372
+ if (!(width > 0 && height > 0 && width <= MAX_EDGE && height <= MAX_EDGE)) throw new PsdError(`Pattern "${name}" has an invalid size ${width} \xD7 ${height}.`);
7373
+ const count = body.u32();
7374
+ if (count > 64) throw new PsdError(`Pattern "${name}" has ${count} channels.`);
7375
+ const planes = [];
7376
+ let depth = 8;
7377
+ for (let i = 0; i < count + 2 && body.remaining > 0; i++) {
7378
+ if (body.u32() === 0) continue;
7379
+ const arrayLength = body.u32();
7380
+ if (arrayLength === 0) continue;
7381
+ if (arrayLength < 23) throw new PsdError(`Pattern "${name}" has a short channel.`);
7382
+ const d32 = body.u32();
7383
+ const [ct, cl, cb, cr] = [body.i32(), body.i32(), body.i32(), body.i32()];
7384
+ const d16 = body.u16();
7385
+ const compression = body.u8();
7386
+ const data = body.bytes(arrayLength - 23);
7387
+ const d = [1, 8, 16, 32].includes(d16) ? d16 : d32;
7388
+ if (![1, 8, 16, 32].includes(d)) throw new PsdError(`Pattern "${name}" has depth ${d}.`);
7389
+ if (ct < top || cl < left || cb > bottom || cr > right || cb < ct || cr < cl) throw new PsdError(`Pattern "${name}" has a channel outside its rectangle.`);
7390
+ if (compression > 1) throw new PsdError(`Pattern "${name}" uses compression ${compression}.`);
7391
+ depth = d;
7392
+ const cw = cr - cl;
7393
+ const ch = cb - ct;
7394
+ const plane = decodePlanes(compression, data, { planes: 1, width: cw, height: ch, depth: d, psb: false });
7395
+ if (cw === width && ch === height) {
7396
+ planes.push(plane);
7397
+ continue;
7398
+ }
7399
+ if (d === 1) throw new PsdError(`Pattern "${name}" has a cropped bitmap channel.`);
7400
+ const bps = d / 8;
7401
+ const out = new Uint8Array(rowBytes2(width, d) * height);
7402
+ for (let y = 0; y < ch; y++) {
7403
+ out.set(plane.subarray(y * cw * bps, (y + 1) * cw * bps), ((ct - top + y) * width + (cl - left)) * bps);
7404
+ }
7405
+ planes.push(out);
7406
+ }
7407
+ const nc = modeChannels(mode);
7408
+ if (planes.length < nc) throw new PsdError(`Pattern "${name}" has fewer channels than its colour mode.`);
7409
+ return { mode, width, height, name, id, palette, depth, channels: planes.slice(0, nc), alpha: planes[nc] };
7410
+ }
7411
+ function parsePatternBlock(data) {
7412
+ const r = new PsdReader(data);
7413
+ const out = [];
7414
+ while (r.remaining >= 4) {
7415
+ const length = r.u32();
7416
+ if (length === 0) break;
7417
+ out.push(readPattern(new PsdReader(r.bytes(length))));
7418
+ r.skip(Math.min((4 - length % 4) % 4, r.remaining));
7419
+ }
7420
+ return out;
7421
+ }
7422
+ function psdPatternToEffectPattern(p) {
7423
+ const data = toRgba8({ width: p.width, height: p.height, depth: p.depth, mode: p.mode, color: p.channels, alpha: p.alpha, palette: p.palette });
7424
+ return { id: p.id, name: p.name, width: p.width, height: p.height, data };
7425
+ }
7426
+ function writePatternBlock(patterns) {
7427
+ const out = new PsdWriter();
7428
+ for (const p of patterns) {
7429
+ if (!(p.width > 0 && p.height > 0) || p.width > 32767 || p.height > 32767) throw new PsdError(`Pattern "${p.name}" is ${p.width} \xD7 ${p.height}; patterns are 1 to 32767 px.`);
7430
+ const one = new PsdWriter();
7431
+ one.u32(1);
7432
+ one.u32(MODE_RGB);
7433
+ one.u16(p.height);
7434
+ one.u16(p.width);
7435
+ one.unicode(p.name, true);
7436
+ const id = new TextEncoder().encode(p.id).subarray(0, 255);
7437
+ one.u8(id.length);
7438
+ one.bytes(id);
7439
+ const n = p.width * p.height;
7440
+ const plane = (c) => {
7441
+ const v = new Uint8Array(n);
7442
+ for (let i = 0; i < n; i++) v[i] = p.data[i * 4 + c];
7443
+ return v;
7444
+ };
7445
+ const alpha = plane(3);
7446
+ const opaque = alpha.every((v) => v === 255);
7447
+ const body = new PsdWriter();
7448
+ for (const v of [0, 0, p.height, p.width]) body.i32(v);
7449
+ body.u32(24);
7450
+ const array = (v) => {
7451
+ const data = encodeRle(v, { planes: 1, width: p.width, height: p.height, depth: 8, psb: false });
7452
+ body.u32(1);
7453
+ body.u32(23 + data.length);
7454
+ body.u32(8);
7455
+ for (const x of [0, 0, p.height, p.width]) body.i32(x);
7456
+ body.u16(8);
7457
+ body.u8(1);
7458
+ body.bytes(data);
7459
+ };
7460
+ for (let c = 0; c < 3; c++) array(plane(c));
7461
+ for (let c = 3; c < 24; c++) body.u32(0);
7462
+ if (opaque) body.u32(0);
7463
+ else array(alpha);
7464
+ body.u32(0);
7465
+ const b = body.result();
7466
+ one.u32(3);
7467
+ one.u32(b.length);
7468
+ one.bytes(b);
7469
+ const bytes = one.result();
7470
+ out.u32(bytes.length);
7471
+ out.bytes(bytes);
7472
+ for (let k = 0; k < (4 - bytes.length % 4) % 4; k++) out.u8(0);
7473
+ }
7474
+ return out.result();
7475
+ }
7476
+
6666
7477
  // src/image-editor/psd/import.ts
6667
7478
  var PSD_BLEND_KEYS = {
6668
7479
  pass: "pass-through",
@@ -6700,15 +7511,14 @@ var FILL_KEYS = ["SoCo", "GdFl", "PtFl"];
6700
7511
  var TYPE_KEYS = ["TySh", "tySh"];
6701
7512
  var SMART_KEYS = ["SoLd", "SoLE", "PlLd"];
6702
7513
  var VECTOR_KEYS = ["vmsk", "vsms"];
6703
- var EFFECT_KEYS = ["lfx2", "lfxs", "lmfx"];
6704
7514
  var percent = (v) => Math.round(v / 255 * 100) / 100;
6705
7515
  var Warnings = (_class5 = class {constructor() { _class5.prototype.__init26.call(this);_class5.prototype.__init27.call(this); }
6706
7516
  __init26() {this.groups = /* @__PURE__ */ new Map()}
6707
7517
  __init27() {this.extra = []}
6708
7518
  add(message, layer) {
6709
- const list = _nullishCoalesce(this.groups.get(message), () => ( []));
6710
- if (!list.includes(layer)) list.push(layer);
6711
- this.groups.set(message, list);
7519
+ const list2 = _nullishCoalesce(this.groups.get(message), () => ( []));
7520
+ if (!list2.includes(layer)) list2.push(layer);
7521
+ this.groups.set(message, list2);
6712
7522
  }
6713
7523
  list() {
6714
7524
  const out = [...this.extra];
@@ -6815,10 +7625,6 @@ function baseProps(ctx, rec, name, notes) {
6815
7625
  if (rec.clipping) props.clipped = true;
6816
7626
  const locks = locksOf(rec);
6817
7627
  if (locks) props.locks = locks;
6818
- if (rec.blocks.some((b) => EFFECT_KEYS.includes(b.key))) {
6819
- ctx.warn.add("Layer effects (lfx2) are not rendered", name);
6820
- notes.push("layer effects are not rendered");
6821
- }
6822
7628
  if (rec.blocks.some((b) => b.key === "artb" || b.key === "artd" || b.key === "abdd")) {
6823
7629
  ctx.warn.add("Artboards are not supported; they came in as plain groups, without their background colour and clipping", name);
6824
7630
  notes.push("artboard imported as a group");
@@ -6829,6 +7635,47 @@ function baseProps(ctx, rec, name, notes) {
6829
7635
  }
6830
7636
  return props;
6831
7637
  }
7638
+ function patternIds(e) {
7639
+ if (e.kind === "pattern-overlay") return [e.patternId];
7640
+ if (e.kind === "stroke" && e.fill.type === "pattern") return [e.fill.patternId];
7641
+ if (e.kind === "bevel-emboss" && e.texture) return [e.texture.patternId];
7642
+ return [];
7643
+ }
7644
+ function recordEffects(ctx, rec, name, notes, group) {
7645
+ const key = ["lmfx", "lfx2", "lfxs"].find((k) => layerBlock(rec, k));
7646
+ if (key) {
7647
+ const data = layerBlock(rec, key);
7648
+ const parsed = parseLfx2(data);
7649
+ if (!parsed) {
7650
+ ctx.warn.add("Layer effects could not be read; they are kept for export but not drawn", name);
7651
+ notes.push("layer effects could not be read");
7652
+ return { enabled: true, items: [], psd: { key, data: data.slice() } };
7653
+ }
7654
+ for (const n of parsed.notes) {
7655
+ ctx.warn.add(`Layer effects were approximated: ${n}`, name);
7656
+ notes.push(`effects: ${n}`);
7657
+ }
7658
+ for (const e of parsed.effects.items) {
7659
+ for (const id of patternIds(e)) {
7660
+ if (ctx.patterns.has(id) || _chunk4AB5BHYKcjs.builtinPattern.call(void 0, id)) continue;
7661
+ ctx.warn.add("A pattern effect uses a pattern the file does not contain, and paints nothing", name);
7662
+ notes.push(`pattern "${id}" is not in the file`);
7663
+ }
7664
+ }
7665
+ return { ...parsed.effects, psd: { key, data: data.slice() } };
7666
+ }
7667
+ const legacy = layerBlock(rec, "lrFX");
7668
+ if (legacy && !group) {
7669
+ const parsed = parseLrfx(legacy);
7670
+ if (!parsed) return void 0;
7671
+ for (const n of parsed.notes) {
7672
+ ctx.warn.add(`Layer effects were approximated: ${n}`, name);
7673
+ notes.push(`effects: ${n}`);
7674
+ }
7675
+ return parsed.effects.items.length ? parsed.effects : void 0;
7676
+ }
7677
+ return void 0;
7678
+ }
6832
7679
  function importNode(ctx, node, depth) {
6833
7680
  const rec = ctx.file.layers[node.index];
6834
7681
  const name = layerName(rec);
@@ -6839,7 +7686,7 @@ function importNode(ctx, node, depth) {
6839
7686
  if (node.children) {
6840
7687
  const props2 = baseProps(ctx, rec, name, notes);
6841
7688
  const divider = sectionDivider(rec);
6842
- const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _116 => _116.blendKey]), () => ( rec.blendKey));
7689
+ const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _126 => _126.blendKey]), () => ( rec.blendKey));
6843
7690
  const groupBlend = key === "pass" ? "pass-through" : _nullishCoalesce(PSD_BLEND_KEYS[key], () => ( "normal"));
6844
7691
  const children = [];
6845
7692
  for (const child of node.children) {
@@ -6847,7 +7694,9 @@ function importNode(ctx, node, depth) {
6847
7694
  if (layer2) children.push(layer2);
6848
7695
  }
6849
7696
  const group = { type: "group", id: ctx.newId(name), ...props2, blend: groupBlend, children };
6850
- if (_optionalChain([divider, 'optionalAccess', _117 => _117.kind]) === SECTION_CLOSED) group.collapsed = true;
7697
+ const effects2 = recordEffects(ctx, rec, name, notes, true);
7698
+ if (effects2) group.effects = effects2;
7699
+ if (_optionalChain([divider, 'optionalAccess', _127 => _127.kind]) === SECTION_CLOSED) group.collapsed = true;
6851
7700
  const mask2 = recordMask(ctx, rec, name);
6852
7701
  if (mask2) group.mask = mask2;
6853
7702
  entry.type = "group";
@@ -6887,6 +7736,8 @@ function importNode(ctx, node, depth) {
6887
7736
  const layer = { type: "pixel", id: ctx.newId(name), ...props, surface: recordPixels(ctx, rec, name), offset: { x: 0, y: 0 } };
6888
7737
  const fill = u8Block(rec, "iOpa");
6889
7738
  if (fill !== void 0 && fill < 255) layer.fillOpacity = percent(fill);
7739
+ const effects = recordEffects(ctx, rec, name, notes, false);
7740
+ if (effects) layer.effects = effects;
6890
7741
  const mask = recordMask(ctx, rec, name);
6891
7742
  if (mask) layer.mask = mask;
6892
7743
  entry.type = "pixel";
@@ -6940,8 +7791,17 @@ function psdToLayers(file, options = {}) {
6940
7791
  skipPixels: _nullishCoalesce(options.skipPixels, () => ( false)),
6941
7792
  summary: [],
6942
7793
  colorCount: colorChannelCount(header.colorMode, header.channels),
6943
- palette: header.colorMode === MODE_INDEXED ? file.colorModeData : void 0
7794
+ palette: header.colorMode === MODE_INDEXED ? file.colorModeData : void 0,
7795
+ patterns: /* @__PURE__ */ new Map()
6944
7796
  };
7797
+ for (const block of file.globalBlocks) {
7798
+ if (!PATTERN_BLOCK_KEYS.includes(block.key)) continue;
7799
+ try {
7800
+ for (const p of parsePatternBlock(block.data)) ctx.patterns.set(p.id, psdPatternToEffectPattern(p));
7801
+ } catch (e) {
7802
+ warn.extra.push(`The file's patterns could not be read (${e instanceof Error ? e.message : String(e)}); pattern effects paint nothing.`);
7803
+ }
7804
+ }
6945
7805
  const mode = _nullishCoalesce(COLOR_MODES[header.colorMode], () => ( `mode ${header.colorMode}`));
6946
7806
  if (mode !== "rgb" || header.depth !== 8) {
6947
7807
  warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to 8-bit RGB.`);
@@ -6967,6 +7827,9 @@ function psdToLayers(file, options = {}) {
6967
7827
  const bg = mergedLayer(ctx);
6968
7828
  if (bg) layers = [bg];
6969
7829
  }
7830
+ const i32 = (b) => b && b.length >= 4 ? new DataView(b.buffer, b.byteOffset, 4).getInt32(0) : void 0;
7831
+ const angle = i32(resource(file, 1037));
7832
+ const altitude = i32(resource(file, 1049));
6970
7833
  return {
6971
7834
  width: header.width,
6972
7835
  height: header.height,
@@ -6974,6 +7837,8 @@ function psdToLayers(file, options = {}) {
6974
7837
  warnings: warn.list(),
6975
7838
  summary: ctx.summary,
6976
7839
  resolution: resolution(file),
7840
+ patterns: [...ctx.patterns.values()],
7841
+ ...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)))) } } : {},
6977
7842
  info: { psb: header.psb, depth: header.depth, colorMode: mode, channels: header.channels }
6978
7843
  };
6979
7844
  }
@@ -6983,6 +7848,18 @@ function importPsd(bytes, options = {}) {
6983
7848
  }
6984
7849
 
6985
7850
  // src/image-editor/psd/export.ts
7851
+ function usedPatterns(e) {
7852
+ if (e.kind === "pattern-overlay") return [e.patternId];
7853
+ if (e.kind === "stroke" && e.fill.type === "pattern") return [e.fill.patternId];
7854
+ if (e.kind === "bevel-emboss" && e.texture) return [e.texture.patternId];
7855
+ return [];
7856
+ }
7857
+ var padEven = (d) => {
7858
+ if (d.length % 2 === 0) return d;
7859
+ const out = new Uint8Array(d.length + 1);
7860
+ out.set(d);
7861
+ return out;
7862
+ };
6986
7863
  var FLAG_PIXELS_IRRELEVANT = 8 | 16;
6987
7864
  var EMPTY_RECT = { top: 0, left: 0, bottom: 0, right: 0 };
6988
7865
  function unicodeBlock(s) {
@@ -7032,15 +7909,34 @@ function exportPsd(input) {
7032
7909
  const psb = width > PSD_MAX_DIMENSION || height > PSD_MAX_DIMENSION;
7033
7910
  const records = [];
7034
7911
  let nextId = 0;
7035
- const common = (layer, extra = []) => {
7912
+ const notes = /* @__PURE__ */ new Map();
7913
+ const note = (msg, name) => notes.set(msg, [..._nullishCoalesce(notes.get(msg), () => ( [])), name]);
7914
+ const patternIds2 = /* @__PURE__ */ new Set();
7915
+ const effectsBlock = (layer) => {
7916
+ const fx = layer.effects;
7917
+ if (!fx) return null;
7918
+ for (const e of fx.items) for (const id of usedPatterns(e)) patternIds2.add(id);
7919
+ const key = layer.type === "group" ? "lfxs" : "lfx2";
7920
+ if (fx.psd) {
7921
+ const original = parseLfx2(fx.psd.data);
7922
+ if (original ? _chunk4AB5BHYKcjs.effectsFingerprint.call(void 0, original.effects) === _chunk4AB5BHYKcjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
7923
+ }
7924
+ if (!fx.items.length && fx.enabled && (_nullishCoalesce(fx.scale, () => ( 1))) === 1) return null;
7925
+ const { data, dropped } = writeLfx2(fx);
7926
+ if (dropped) note("Only the first outer glow, inner glow, bevel, satin and pattern overlay of a layer can be written; the others were left out", layer.name);
7927
+ return { key, data };
7928
+ };
7929
+ const common2 = (layer, extra = []) => {
7036
7930
  const name = layer.name || (layer.type === "adjustment" ? adjustmentKindLabel(layer.kind) : "");
7037
7931
  const blocks = [{ key: "luni", data: unicodeBlock(name) }, { key: "lyid", data: u32Bytes(++nextId) }, ...extra];
7932
+ const fx = effectsBlock(layer);
7933
+ if (fx) blocks.push(fx);
7038
7934
  const locks = lockBits(layer);
7039
7935
  if (locks) blocks.push({ key: "lspf", data: u32Bytes(locks >>> 0) });
7040
7936
  return {
7041
7937
  opacity: Math.round(Math.min(1, Math.max(0, layer.opacity)) * 255),
7042
7938
  clipping: layer.clipped ? 1 : 0,
7043
- flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _118 => _118.locks, 'optionalAccess', _119 => _119.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
7939
+ flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _128 => _128.locks, 'optionalAccess', _129 => _129.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
7044
7940
  legacyName: name,
7045
7941
  blocks
7046
7942
  };
@@ -7063,7 +7959,7 @@ function exportPsd(input) {
7063
7959
  });
7064
7960
  for (const child of layer.children) write(child);
7065
7961
  const blendKey = _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm"));
7066
- const base = common(layer, [{ key: "lsct", data: sectionBlock(layer.collapsed ? SECTION_CLOSED : SECTION_OPEN, blendKey) }]);
7962
+ const base = common2(layer, [{ key: "lsct", data: sectionBlock(layer.collapsed ? SECTION_CLOSED : SECTION_OPEN, blendKey) }]);
7067
7963
  const rec = {
7068
7964
  ...base,
7069
7965
  rect: EMPTY_RECT,
@@ -7082,7 +7978,7 @@ function exportPsd(input) {
7082
7978
  case "adjustment": {
7083
7979
  const block = writeAdjustmentBlock(layer.kind, layer.params);
7084
7980
  const rec = {
7085
- ...common(layer, [{ key: block.key, data: block.data }]),
7981
+ ...common2(layer, [{ key: block.key, data: block.data }]),
7086
7982
  rect: EMPTY_RECT,
7087
7983
  channels: [CHANNEL_ALPHA, 0, 1, 2].map(emptyChannel),
7088
7984
  blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm"))
@@ -7097,12 +7993,12 @@ function exportPsd(input) {
7097
7993
  }
7098
7994
  case "pixel": {
7099
7995
  if (layer.source === "document") throw new PsdError(`Layer "${layer.name}" reads the document image; resolve its pixels before export.`);
7100
- if (_optionalChain([layer, 'access', _120 => _120.filters, 'optionalAccess', _121 => _121.some, 'call', _122 => _122(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
7996
+ if (_optionalChain([layer, 'access', _130 => _130.filters, 'optionalAccess', _131 => _131.some, 'call', _132 => _132(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
7101
7997
  const extra = [];
7102
7998
  if (layer.fillOpacity !== void 0 && layer.fillOpacity < 1) {
7103
7999
  extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
7104
8000
  }
7105
- const rec = { ...common(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
8001
+ const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
7106
8002
  const bounds = _chunkCRMAXIUVcjs.contentBounds.call(void 0, layer.surface);
7107
8003
  if (bounds) {
7108
8004
  const n2 = bounds.width * bounds.height;
@@ -7155,6 +8051,25 @@ function exportPsd(input) {
7155
8051
  { id: 1005, name: "", data: rw.result() },
7156
8052
  { id: 1057, name: "", data: version.result() }
7157
8053
  ];
8054
+ if (input.globalLight) {
8055
+ const i32 = (v) => {
8056
+ const w = new PsdWriter();
8057
+ w.i32(Math.round(v));
8058
+ return w.result();
8059
+ };
8060
+ resources.push({ id: 1037, name: "", data: i32(input.globalLight.angle) }, { id: 1049, name: "", data: i32(input.globalLight.altitude) });
8061
+ }
8062
+ const globalBlocks = [];
8063
+ if (patternIds2.size) {
8064
+ const byId = new Map((_nullishCoalesce(input.patterns, () => ( []))).map((p) => [p.id, p]));
8065
+ const embed = [];
8066
+ for (const id of patternIds2) {
8067
+ const p = _nullishCoalesce(byId.get(id), () => ( _chunk4AB5BHYKcjs.builtinPattern.call(void 0, id)));
8068
+ if (p) embed.push(p);
8069
+ else note(`Pattern "${id}" is not in the document and was not embedded`, id);
8070
+ }
8071
+ if (embed.length) globalBlocks.push({ key: "Patt", data: writePatternBlock(embed) });
8072
+ }
7158
8073
  const bytes = writePsd(
7159
8074
  {
7160
8075
  header: { psb, channels: planes.length, width, height, depth: 8, colorMode: 3 },
@@ -7162,13 +8077,14 @@ function exportPsd(input) {
7162
8077
  resources,
7163
8078
  layers: records,
7164
8079
  mergedAlpha: transparent && records.length > 0,
7165
- globalBlocks: [],
8080
+ globalBlocks,
7166
8081
  imageCompression: 1,
7167
8082
  imageData: encodeRle(merged, { planes: planes.length, width, height, depth: 8, psb })
7168
8083
  },
7169
8084
  encodeLegacyName
7170
8085
  );
7171
- return { bytes, psb, records: records.length };
8086
+ const warnings = [...notes].map(([msg, names]) => `${msg} (${names.map((n2) => `"${n2}"`).join(", ")}).`);
8087
+ return { bytes, psb, records: records.length, warnings };
7172
8088
  }
7173
8089
 
7174
8090
  // src/image-editor/controller.ts
@@ -7181,7 +8097,7 @@ function paintCoverageInto(base, coverage, apply, rects) {
7181
8097
  const key = _chunkCRMAXIUVcjs.tileKey.call(void 0, t.tx, t.ty);
7182
8098
  if (done.has(key)) continue;
7183
8099
  done.add(key);
7184
- const src = _nullishCoalesce(_optionalChain([base, 'access', _123 => _123.tiles, 'access', _124 => _124.get, 'call', _125 => _125(key), 'optionalAccess', _126 => _126.data]), () => ( defaultTile(base)));
8100
+ const src = _nullishCoalesce(_optionalChain([base, 'access', _133 => _133.tiles, 'access', _134 => _134.get, 'call', _135 => _135(key), 'optionalAccess', _136 => _136.data]), () => ( defaultTile(base)));
7185
8101
  const data = _chunkZZOTHJ4Kcjs.applyStrokeToTile.call(void 0, coverage, src, base.channels, t.tx, t.ty, apply);
7186
8102
  const tile = _chunkCRMAXIUVcjs.finishTile.call(void 0, data, base.channels, base.defaultValue);
7187
8103
  if (tile) tiles.set(key, tile);
@@ -7233,11 +8149,11 @@ var PaintStrokeSession = (_class6 = class {
7233
8149
  offset: a.offset,
7234
8150
  lockTransparency: a.lockTransparency,
7235
8151
  selection: a.selection,
7236
- readTile: (tx, ty) => _nullishCoalesce(_optionalChain([this, 'access', _127 => _127.live, 'access', _128 => _128.get, 'call', _129 => _129(_chunkCRMAXIUVcjs.tileKey.call(void 0, tx, ty)), 'optionalAccess', _130 => _130.data]), () => ( (this.base.defaultValue ? defaultTile(this.base) : null))),
8152
+ readTile: (tx, ty) => _nullishCoalesce(_optionalChain([this, 'access', _137 => _137.live, 'access', _138 => _138.get, 'call', _139 => _139(_chunkCRMAXIUVcjs.tileKey.call(void 0, tx, ty)), 'optionalAccess', _140 => _140.data]), () => ( (this.base.defaultValue ? defaultTile(this.base) : null))),
7237
8153
  writeTile: (tx, ty) => {
7238
8154
  const key = _chunkCRMAXIUVcjs.tileKey.call(void 0, tx, ty);
7239
8155
  if (!this.touched.has(key)) {
7240
- const src = _nullishCoalesce(_optionalChain([this, 'access', _131 => _131.base, 'access', _132 => _132.tiles, 'access', _133 => _133.get, 'call', _134 => _134(key), 'optionalAccess', _135 => _135.data]), () => ( defaultTile(this.base)));
8156
+ const src = _nullishCoalesce(_optionalChain([this, 'access', _141 => _141.base, 'access', _142 => _142.tiles, 'access', _143 => _143.get, 'call', _144 => _144(key), 'optionalAccess', _145 => _145.data]), () => ( defaultTile(this.base)));
7241
8157
  this.live.set(key, { data: new Uint8ClampedArray(src), uniform: null });
7242
8158
  this.touched.add(key);
7243
8159
  }
@@ -7274,8 +8190,8 @@ var PaintStrokeSession = (_class6 = class {
7274
8190
  }
7275
8191
  }
7276
8192
  for (const [key, { tx, ty, r }] of regions) {
7277
- const src = _nullishCoalesce(_optionalChain([this, 'access', _136 => _136.base, 'access', _137 => _137.tiles, 'access', _138 => _138.get, 'call', _139 => _139(key), 'optionalAccess', _140 => _140.data]), () => ( defaultTile(this.base)));
7278
- const prev = this.touched.has(key) ? _optionalChain([this, 'access', _141 => _141.live, 'access', _142 => _142.get, 'call', _143 => _143(key), 'optionalAccess', _144 => _144.data]) : void 0;
8193
+ const src = _nullishCoalesce(_optionalChain([this, 'access', _146 => _146.base, 'access', _147 => _147.tiles, 'access', _148 => _148.get, 'call', _149 => _149(key), 'optionalAccess', _150 => _150.data]), () => ( defaultTile(this.base)));
8194
+ const prev = this.touched.has(key) ? _optionalChain([this, 'access', _151 => _151.live, 'access', _152 => _152.get, 'call', _153 => _153(key), 'optionalAccess', _154 => _154.data]) : void 0;
7279
8195
  this.touched.add(key);
7280
8196
  const data = _chunkZZOTHJ4Kcjs.applyStrokeToTile.call(void 0, stroke.coverage, src, ch, tx, ty, this.apply, prev ? { into: prev, region: r } : {});
7281
8197
  this.live.set(key, { data, uniform: null });
@@ -7350,14 +8266,14 @@ function migrateSerializedImageEditorState(data) {
7350
8266
  const legacy = data;
7351
8267
  const adjustments = normalizeStoredAdjustments(legacy.adjustments);
7352
8268
  return {
7353
- version: _optionalChain([adjustments, 'access', _145 => _145.layers, 'optionalAccess', _146 => _146.length]) ? 2 : 1,
8269
+ version: _optionalChain([adjustments, 'access', _155 => _155.layers, 'optionalAccess', _156 => _156.length]) ? 2 : 1,
7354
8270
  crop: legacy.crop ? { ...legacy.crop } : null,
7355
8271
  transform: { ...DEFAULT_TRANSFORM, ...legacy.transform },
7356
8272
  adjustments: serializeAdjustments(adjustments),
7357
8273
  depthMask: {
7358
8274
  ...DEFAULT_DEPTH_MASK,
7359
8275
  ...legacy.depthMask,
7360
- depthRange: [..._nullishCoalesce(_optionalChain([legacy, 'access', _147 => _147.depthMask, 'optionalAccess', _148 => _148.depthRange]), () => ( DEFAULT_DEPTH_MASK.depthRange))]
8276
+ depthRange: [..._nullishCoalesce(_optionalChain([legacy, 'access', _157 => _157.depthMask, 'optionalAccess', _158 => _158.depthRange]), () => ( DEFAULT_DEPTH_MASK.depthRange))]
7361
8277
  },
7362
8278
  annotations: JSON.parse(JSON.stringify(_nullishCoalesce(legacy.annotations, () => ( [])))),
7363
8279
  ...legacy.selection ? { selection: { ...legacy.selection } } : {}
@@ -7408,7 +8324,7 @@ var ImageEditorController = (_class7 = class {
7408
8324
  __init42() {this.viewKey = []}
7409
8325
  /** For `compositePixels` and mask evaluation (the renderer keeps its own for the viewport). */
7410
8326
  __init43() {this.compositor = new LayerCompositor()}
7411
- constructor(options = {}) {;_class7.prototype.__init33.call(this);_class7.prototype.__init34.call(this);_class7.prototype.__init35.call(this);_class7.prototype.__init36.call(this);_class7.prototype.__init37.call(this);_class7.prototype.__init38.call(this);_class7.prototype.__init39.call(this);_class7.prototype.__init40.call(this);_class7.prototype.__init41.call(this);_class7.prototype.__init42.call(this);_class7.prototype.__init43.call(this);_class7.prototype.__init44.call(this);_class7.prototype.__init45.call(this);_class7.prototype.__init46.call(this);_class7.prototype.__init47.call(this);_class7.prototype.__init48.call(this);_class7.prototype.__init49.call(this);_class7.prototype.__init50.call(this);_class7.prototype.__init51.call(this);
8327
+ constructor(options = {}) {;_class7.prototype.__init33.call(this);_class7.prototype.__init34.call(this);_class7.prototype.__init35.call(this);_class7.prototype.__init36.call(this);_class7.prototype.__init37.call(this);_class7.prototype.__init38.call(this);_class7.prototype.__init39.call(this);_class7.prototype.__init40.call(this);_class7.prototype.__init41.call(this);_class7.prototype.__init42.call(this);_class7.prototype.__init43.call(this);_class7.prototype.__init44.call(this);_class7.prototype.__init45.call(this);_class7.prototype.__init46.call(this);_class7.prototype.__init47.call(this);_class7.prototype.__init48.call(this);_class7.prototype.__init49.call(this);_class7.prototype.__init50.call(this);_class7.prototype.__init51.call(this);_class7.prototype.__init52.call(this);
7412
8328
  this.maxHistoryDepth = _nullishCoalesce(options.maxHistoryDepth, () => ( 50));
7413
8329
  this.maxHistoryBytes = _nullishCoalesce(options.maxHistoryBytes, () => ( 512 * 1024 * 1024));
7414
8330
  this.onStateChange = options.onStateChange;
@@ -7419,8 +8335,9 @@ var ImageEditorController = (_class7 = class {
7419
8335
  this.renderer.layerSources = {
7420
8336
  surfaceOf: (layer) => this.surfaceOf(layer),
7421
8337
  sourceIsOpaque: () => this.sourceIsOpaque(),
7422
- version: () => this.sourceVersion(),
7423
- globalLight: () => this.state.globalLight
8338
+ version: () => `${this.sourceVersion()}:${this.patternsVersion()}`,
8339
+ globalLight: () => this.state.globalLight,
8340
+ pattern: (id) => _nullishCoalesce(_optionalChain([this, 'access', _159 => _159.state, 'access', _160 => _160.patterns, 'optionalAccess', _161 => _161.find, 'call', _162 => _162((p) => p.id === id)]), () => ( null))
7424
8341
  };
7425
8342
  this.state = {
7426
8343
  sourceUrl: typeof options.image === "string" ? options.image : null,
@@ -7453,10 +8370,10 @@ var ImageEditorController = (_class7 = class {
7453
8370
  };
7454
8371
  }
7455
8372
  this.applyStored(_nullishCoalesce(options.initialState, () => ( {})));
7456
- if (_optionalChain([options, 'access', _149 => _149.initialState, 'optionalAccess', _150 => _150.selection])) {
8373
+ if (_optionalChain([options, 'access', _163 => _163.initialState, 'optionalAccess', _164 => _164.selection])) {
7457
8374
  try {
7458
8375
  this.state.selection = normalizeSelection(deserializeSelection(options.initialState.selection));
7459
- } catch (e17) {
8376
+ } catch (e19) {
7460
8377
  }
7461
8378
  }
7462
8379
  this.initialSnapshot = this.captureHistoryEntry();
@@ -7497,7 +8414,7 @@ var ImageEditorController = (_class7 = class {
7497
8414
  height: img.naturalHeight || img.height || 600
7498
8415
  }
7499
8416
  };
7500
- } catch (e18) {
8417
+ } catch (e20) {
7501
8418
  return { sourceUrl: src, element: null, dimensions: { ...this.state.imageDimensions } };
7502
8419
  }
7503
8420
  }
@@ -7536,7 +8453,7 @@ var ImageEditorController = (_class7 = class {
7536
8453
  else if (!strokeRects) this.pendingDirty = "all";
7537
8454
  this.syncViews();
7538
8455
  const currentState = { ...this.state };
7539
- _optionalChain([this, 'access', _151 => _151.onStateChange, 'optionalCall', _152 => _152(currentState)]);
8456
+ _optionalChain([this, 'access', _165 => _165.onStateChange, 'optionalCall', _166 => _166(currentState)]);
7540
8457
  this.listeners.forEach((l) => l(currentState));
7541
8458
  }
7542
8459
  /** Recomputes the compatibility views (`adjustments`, `depthMask`, `annotations`) when the stack changed. */
@@ -7575,6 +8492,7 @@ var ImageEditorController = (_class7 = class {
7575
8492
  };
7576
8493
  if (s.legacyOutputBlur !== void 0) entry.legacyOutputBlur = s.legacyOutputBlur;
7577
8494
  if (s.globalLight) entry.globalLight = { ...s.globalLight };
8495
+ if (s.patterns) entry.patterns = s.patterns;
7578
8496
  return entry;
7579
8497
  }
7580
8498
  restoreHistoryEntry(entry) {
@@ -7589,6 +8507,8 @@ var ImageEditorController = (_class7 = class {
7589
8507
  else delete s.legacyOutputBlur;
7590
8508
  if (entry.globalLight) s.globalLight = { ...entry.globalLight };
7591
8509
  else delete s.globalLight;
8510
+ if (entry.patterns) s.patterns = entry.patterns;
8511
+ else delete s.patterns;
7592
8512
  s.selection = entry.selection;
7593
8513
  if (this.imageElement !== entry.source.element && !this.samplePixelsOverride) this.samplePixels = null;
7594
8514
  this.imageElement = entry.source.element;
@@ -7744,7 +8664,7 @@ var ImageEditorController = (_class7 = class {
7744
8664
  return this.state.layers;
7745
8665
  }
7746
8666
  getLayer(id) {
7747
- return _optionalChain([_chunkT6H3JDGAcjs.findLayer.call(void 0, this.state.layers, id), 'optionalAccess', _153 => _153.layer]);
8667
+ return _optionalChain([_chunk4AB5BHYKcjs.findLayer.call(void 0, this.state.layers, id), 'optionalAccess', _167 => _167.layer]);
7748
8668
  }
7749
8669
  /** The active layer, or `undefined`. */
7750
8670
  getActiveLayer() {
@@ -7757,7 +8677,7 @@ var ImageEditorController = (_class7 = class {
7757
8677
  setActiveLayer(id, target = "pixels") {
7758
8678
  if (id !== null && !this.getLayer(id)) return false;
7759
8679
  const layer = id ? this.getLayer(id) : void 0;
7760
- const t = target === "mask" && _optionalChain([layer, 'optionalAccess', _154 => _154.mask]) ? "mask" : "pixels";
8680
+ const t = target === "mask" && _optionalChain([layer, 'optionalAccess', _168 => _168.mask]) ? "mask" : "pixels";
7761
8681
  if (this.state.activeLayerId === id && this.state.activeTarget === t) return true;
7762
8682
  this.state.activeLayerId = id;
7763
8683
  this.state.activeTarget = t;
@@ -7803,14 +8723,21 @@ var ImageEditorController = (_class7 = class {
7803
8723
  let layers = this.state.layers;
7804
8724
  if (options.layerIds) {
7805
8725
  const keep = new Set(options.layerIds);
7806
- layers = _chunkT6H3JDGAcjs.flattenLayers.call(void 0, layers).filter((l) => keep.has(l.id) && l.type !== "group");
8726
+ layers = _chunk4AB5BHYKcjs.flattenLayers.call(void 0, layers).filter((l) => keep.has(l.id) && l.type !== "group");
7807
8727
  }
7808
8728
  const data = this.compositor.composite(layers, r, this.compositorSources());
7809
8729
  return { width: r.width, height: r.height, data };
7810
8730
  }
7811
8731
  compositorSources() {
7812
8732
  const { width, height } = this.naturalSize;
7813
- return { width, height, surfaceOf: (l) => this.surfaceOf(l), version: this.sourceVersion(), globalLight: this.state.globalLight };
8733
+ return {
8734
+ width,
8735
+ height,
8736
+ surfaceOf: (l) => this.surfaceOf(l),
8737
+ version: `${this.sourceVersion()}:${this.patternsVersion()}`,
8738
+ globalLight: this.state.globalLight,
8739
+ pattern: (id) => _nullishCoalesce(_optionalChain([this, 'access', _169 => _169.state, 'access', _170 => _170.patterns, 'optionalAccess', _171 => _171.find, 'call', _172 => _172((p) => p.id === id)]), () => ( null))
8740
+ };
7814
8741
  }
7815
8742
  __init46() {this.sourceIds = /* @__PURE__ */ new WeakMap()}
7816
8743
  __init47() {this.nextSourceId = 1}
@@ -7836,17 +8763,17 @@ var ImageEditorController = (_class7 = class {
7836
8763
  */
7837
8764
  sourceSurface() {
7838
8765
  const { width, height } = this.naturalSize;
7839
- const fromPixels = (px2) => {
7840
- let s = this.sourceSurfaces.get(px2);
8766
+ const fromPixels = (px3) => {
8767
+ let s = this.sourceSurfaces.get(px3);
7841
8768
  if (!s) {
7842
- s = _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, px2, 4);
7843
- this.sourceSurfaces.set(px2, s);
8769
+ s = _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, px3, 4);
8770
+ this.sourceSurfaces.set(px3, s);
7844
8771
  }
7845
8772
  return s;
7846
8773
  };
7847
- const px = this.samplePixels;
7848
- const fits = Boolean(px && px.width === width && px.height === height);
7849
- if (this.samplePixelsOverride && fits) return fromPixels(px);
8774
+ const px2 = this.samplePixels;
8775
+ const fits = Boolean(px2 && px2.width === width && px2.height === height);
8776
+ if (this.samplePixelsOverride && fits) return fromPixels(px2);
7850
8777
  const el = this.imageElement;
7851
8778
  if (el) {
7852
8779
  const cached = this.sourceSurfaces.get(el);
@@ -7860,7 +8787,7 @@ var ImageEditorController = (_class7 = class {
7860
8787
  return s;
7861
8788
  }
7862
8789
  }
7863
- return fits ? fromPixels(px) : null;
8790
+ return fits ? fromPixels(px2) : null;
7864
8791
  }
7865
8792
  __init48() {this.opaqueCache = /* @__PURE__ */ new WeakMap()}
7866
8793
  /** Whether every source pixel is opaque (some legacy renders depend on it). */
@@ -7886,9 +8813,9 @@ var ImageEditorController = (_class7 = class {
7886
8813
  if (!ctx || typeof ctx.getImageData !== "function") return null;
7887
8814
  ctx.drawImage(el, 0, 0, width, height);
7888
8815
  const data = ctx.getImageData(0, 0, width, height);
7889
- if (!_optionalChain([data, 'optionalAccess', _155 => _155.data]) || data.data.length < width * height * 4) return null;
8816
+ if (!_optionalChain([data, 'optionalAccess', _173 => _173.data]) || data.data.length < width * height * 4) return null;
7890
8817
  return { width, height, data: data.data };
7891
- } catch (e19) {
8818
+ } catch (e21) {
7892
8819
  return null;
7893
8820
  }
7894
8821
  }
@@ -7897,8 +8824,8 @@ var ImageEditorController = (_class7 = class {
7897
8824
  commitLayers(next, extra, commitToHistory = true) {
7898
8825
  if (commitToHistory) this.recordHistory();
7899
8826
  this.state.layers = next;
7900
- _optionalChain([extra, 'optionalCall', _156 => _156()]);
7901
- if (this.state.activeLayerId && !_chunkT6H3JDGAcjs.findLayer.call(void 0, next, this.state.activeLayerId)) {
8827
+ _optionalChain([extra, 'optionalCall', _174 => _174()]);
8828
+ if (this.state.activeLayerId && !_chunk4AB5BHYKcjs.findLayer.call(void 0, next, this.state.activeLayerId)) {
7902
8829
  this.state.activeLayerId = null;
7903
8830
  this.state.activeTarget = "pixels";
7904
8831
  }
@@ -7907,7 +8834,7 @@ var ImageEditorController = (_class7 = class {
7907
8834
  /** The default position of a new layer: above the active layer, else the top of the stack. */
7908
8835
  newLayerPlacement(placement) {
7909
8836
  if (placement.aboveId || placement.belowId || placement.parentId || placement.index !== void 0) return placement;
7910
- const active = this.state.activeLayerId ? _chunkT6H3JDGAcjs.findLayer.call(void 0, this.state.layers, this.state.activeLayerId) : null;
8837
+ const active = this.state.activeLayerId ? _chunk4AB5BHYKcjs.findLayer.call(void 0, this.state.layers, this.state.activeLayerId) : null;
7911
8838
  return active ? { aboveId: active.layer.id } : {};
7912
8839
  }
7913
8840
  /**
@@ -7919,22 +8846,22 @@ var ImageEditorController = (_class7 = class {
7919
8846
  const { width, height } = this.naturalSize;
7920
8847
  let surface = _chunkCRMAXIUVcjs.emptySurface.call(void 0, 4);
7921
8848
  if (init.pixels) {
7922
- const px = init.pixels;
7923
- if (!(px.width > 0 && px.height > 0) || px.data.length < px.width * px.height * 4) {
8849
+ const px2 = init.pixels;
8850
+ if (!(px2.width > 0 && px2.height > 0) || px2.data.length < px2.width * px2.height * 4) {
7924
8851
  throw new LayerOperationError("pixels must be RGBA with width \xD7 height \xD7 4 bytes.");
7925
8852
  }
7926
- surface = _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, px, 4);
8853
+ surface = _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, px2, 4);
7927
8854
  } else if (init.color !== void 0) {
7928
8855
  const c = parseColor(init.color);
7929
8856
  surface = _chunkCRMAXIUVcjs.solidSurface.call(void 0, 4, { x: 0, y: 0, width, height }, _chunkCRMAXIUVcjs.packRgba.call(void 0, c[0], c[1], c[2], c[3]));
7930
8857
  }
7931
8858
  const blend = parseBlend(init.blend);
7932
8859
  if (init.opacity !== void 0 && !(init.opacity >= 0 && init.opacity <= 1)) throw new LayerOperationError("opacity must be from 0 to 1.");
7933
- const ids = new Set(_chunkT6H3JDGAcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.id));
8860
+ const ids = new Set(_chunk4AB5BHYKcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.id));
7934
8861
  const layer = {
7935
8862
  type: "pixel",
7936
8863
  id: init.id && !ids.has(init.id) ? init.id : newLayerId(),
7937
- name: _optionalChain([init, 'access', _157 => _157.name, 'optionalAccess', _158 => _158.trim, 'call', _159 => _159()]) || this.nextLayerName(),
8864
+ name: _optionalChain([init, 'access', _175 => _175.name, 'optionalAccess', _176 => _176.trim, 'call', _177 => _177()]) || this.nextLayerName(),
7938
8865
  visible: _nullishCoalesce(init.visible, () => ( true)),
7939
8866
  opacity: _nullishCoalesce(init.opacity, () => ( 1)),
7940
8867
  blend: _nullishCoalesce(blend, () => ( "normal")),
@@ -7961,27 +8888,27 @@ var ImageEditorController = (_class7 = class {
7961
8888
  async decodeImage(image) {
7962
8889
  const trimmed = image.trim();
7963
8890
  let png = null;
7964
- if (/^data:image\/png/i.test(trimmed)) png = _nullishCoalesce(_optionalChain([_chunkT6H3JDGAcjs.parseDataUrl.call(void 0, trimmed), 'optionalAccess', _160 => _160.bytes]), () => ( null));
8891
+ if (/^data:image\/png/i.test(trimmed)) png = _nullishCoalesce(_optionalChain([_chunk4AB5BHYKcjs.parseDataUrl.call(void 0, trimmed), 'optionalAccess', _178 => _178.bytes]), () => ( null));
7965
8892
  else if (/^[A-Za-z0-9+/=\s]+$/.test(trimmed) && trimmed.length > 16) {
7966
8893
  try {
7967
- const bytes = _chunkT6H3JDGAcjs.base64ToBytes.call(void 0, trimmed);
7968
- if (_chunkT6H3JDGAcjs.isPng.call(void 0, bytes)) png = bytes;
7969
- } catch (e20) {
8894
+ const bytes = _chunk4AB5BHYKcjs.base64ToBytes.call(void 0, trimmed);
8895
+ if (_chunk4AB5BHYKcjs.isPng.call(void 0, bytes)) png = bytes;
8896
+ } catch (e22) {
7970
8897
  png = null;
7971
8898
  }
7972
8899
  }
7973
8900
  if (png) {
7974
8901
  try {
7975
- const d = _chunkT6H3JDGAcjs.decodePng.call(void 0, png);
8902
+ const d = _chunk4AB5BHYKcjs.decodePng.call(void 0, png);
7976
8903
  return { width: d.width, height: d.height, data: d.data };
7977
- } catch (e21) {
8904
+ } catch (e23) {
7978
8905
  }
7979
8906
  }
7980
- const src = png ? `data:image/png;base64,${_chunkT6H3JDGAcjs.bytesToBase64.call(void 0, png)}` : trimmed;
8907
+ const src = png ? `data:image/png;base64,${_chunk4AB5BHYKcjs.bytesToBase64.call(void 0, png)}` : trimmed;
7981
8908
  let img;
7982
8909
  try {
7983
8910
  img = await this.renderer.imageCache.get(src);
7984
- } catch (e22) {
8911
+ } catch (e24) {
7985
8912
  throw new LayerOperationError("The image could not be decoded here. Pass a PNG (data URL or base64), or run in a browser for other formats and URLs.");
7986
8913
  }
7987
8914
  const w = img.naturalWidth || img.width;
@@ -7993,7 +8920,7 @@ var ImageEditorController = (_class7 = class {
7993
8920
  return { width: w, height: h, data: data.data };
7994
8921
  }
7995
8922
  nextLayerName() {
7996
- const names = new Set(_chunkT6H3JDGAcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.name));
8923
+ const names = new Set(_chunk4AB5BHYKcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.name));
7997
8924
  let n = 1;
7998
8925
  while (names.has(`Layer ${n}`)) n++;
7999
8926
  return `Layer ${n}`;
@@ -8010,7 +8937,7 @@ var ImageEditorController = (_class7 = class {
8010
8937
  removeLayer(id) {
8011
8938
  const next = removeLayer(this.state.layers, id);
8012
8939
  this.commitLayers(next, () => {
8013
- if (this.state.selectedAnnotationId && !_chunkT6H3JDGAcjs.flattenLayers.call(void 0, next).some((l) => l.type === "annotation" && l.annotation.id === this.state.selectedAnnotationId)) {
8940
+ if (this.state.selectedAnnotationId && !_chunk4AB5BHYKcjs.flattenLayers.call(void 0, next).some((l) => l.type === "annotation" && l.annotation.id === this.state.selectedAnnotationId)) {
8014
8941
  this.state.selectedAnnotationId = null;
8015
8942
  }
8016
8943
  });
@@ -8018,10 +8945,10 @@ var ImageEditorController = (_class7 = class {
8018
8945
  /** Moves a layer above / below another, or into a group, as one undo step. Returns its new parent and index. */
8019
8946
  moveLayer(id, placement) {
8020
8947
  const next = moveLayer(this.state.layers, id, placement);
8021
- const loc = _chunkT6H3JDGAcjs.findLayer.call(void 0, next, id);
8022
- if (next === this.state.layers) return { parentId: _nullishCoalesce(_optionalChain([loc, 'access', _161 => _161.parent, 'optionalAccess', _162 => _162.id]), () => ( null)), index: loc.index };
8948
+ const loc = _chunk4AB5BHYKcjs.findLayer.call(void 0, next, id);
8949
+ if (next === this.state.layers) return { parentId: _nullishCoalesce(_optionalChain([loc, 'access', _179 => _179.parent, 'optionalAccess', _180 => _180.id]), () => ( null)), index: loc.index };
8023
8950
  this.commitLayers(next);
8024
- return { parentId: _nullishCoalesce(_optionalChain([loc, 'access', _163 => _163.parent, 'optionalAccess', _164 => _164.id]), () => ( null)), index: loc.index };
8951
+ return { parentId: _nullishCoalesce(_optionalChain([loc, 'access', _181 => _181.parent, 'optionalAccess', _182 => _182.id]), () => ( null)), index: loc.index };
8025
8952
  }
8026
8953
  /**
8027
8954
  * Changes name, visibility, opacity, fill, blend, clipping, locks or (groups) collapsed state, as
@@ -8030,7 +8957,7 @@ var ImageEditorController = (_class7 = class {
8030
8957
  setLayerProperties(id, props, commitToHistory = true) {
8031
8958
  const next = setLayerProperties(this.state.layers, id, props);
8032
8959
  this.commitLayers(next, void 0, commitToHistory);
8033
- return _chunkT6H3JDGAcjs.findLayer.call(void 0, next, id).layer;
8960
+ return _chunk4AB5BHYKcjs.findLayer.call(void 0, next, id).layer;
8034
8961
  }
8035
8962
  /** Adds an empty pass-through group above the active layer (or at `placement`) and makes it active. Returns its id. */
8036
8963
  addGroup(init = {}) {
@@ -8038,7 +8965,7 @@ var ImageEditorController = (_class7 = class {
8038
8965
  const group = {
8039
8966
  type: "group",
8040
8967
  id: newLayerId("group"),
8041
- name: _optionalChain([init, 'access', _165 => _165.name, 'optionalAccess', _166 => _166.trim, 'call', _167 => _167()]) || "Group",
8968
+ name: _optionalChain([init, 'access', _183 => _183.name, 'optionalAccess', _184 => _184.trim, 'call', _185 => _185()]) || "Group",
8042
8969
  visible: true,
8043
8970
  opacity: 1,
8044
8971
  blend,
@@ -8088,7 +9015,7 @@ var ImageEditorController = (_class7 = class {
8088
9015
  let mask;
8089
9016
  if (from === "selection") {
8090
9017
  const sel = this.state.selection;
8091
- if (!_optionalChain([sel, 'optionalAccess', _168 => _168.bounds])) throw new LayerOperationError("Nothing is selected; select first, or use reveal-all / hide-all.");
9018
+ if (!_optionalChain([sel, 'optionalAccess', _186 => _186.bounds])) throw new LayerOperationError("Nothing is selected; select first, or use reveal-all / hide-all.");
8092
9019
  mask = this.maskFromSelection(sel, props);
8093
9020
  if (layer.type === "pixel" && (layer.offset.x || layer.offset.y)) {
8094
9021
  mask = { ...mask, surface: _chunkCRMAXIUVcjs.translateSurface.call(void 0, mask.surface, -layer.offset.x, -layer.offset.y) };
@@ -8151,7 +9078,7 @@ var ImageEditorController = (_class7 = class {
8151
9078
  const next = { ...layer, surface: out };
8152
9079
  delete next.mask;
8153
9080
  delete next.source;
8154
- this.commitLayers(_chunkT6H3JDGAcjs.mapLayer.call(void 0, this.state.layers, id, () => next), () => {
9081
+ this.commitLayers(_chunk4AB5BHYKcjs.mapLayer.call(void 0, this.state.layers, id, () => next), () => {
8155
9082
  if (this.state.activeLayerId === id) this.state.activeTarget = "pixels";
8156
9083
  });
8157
9084
  }
@@ -8166,36 +9093,36 @@ var ImageEditorController = (_class7 = class {
8166
9093
  const layer = loc.layer;
8167
9094
  if (layer.type !== "pixel") throw new LayerOperationError(`Layer via copy needs a pixel layer; "${id}" is a ${layer.type} layer.`);
8168
9095
  const sel = this.state.selection;
8169
- if (!_optionalChain([sel, 'optionalAccess', _169 => _169.bounds])) throw new LayerOperationError("Nothing is selected; select the pixels to copy first.");
9096
+ if (!_optionalChain([sel, 'optionalAccess', _187 => _187.bounds])) throw new LayerOperationError("Nothing is selected; select the pixels to copy first.");
8170
9097
  if (options.cut) requireUnlocked(layer, "pixels", "cut from it");
8171
9098
  const surface = this.surfaceOf(layer);
8172
9099
  const sb = sel.bounds;
8173
9100
  const src = { x: sb.x - layer.offset.x, y: sb.y - layer.offset.y, width: sb.width, height: sb.height };
8174
- const px = _chunkCRMAXIUVcjs.readRegion.call(void 0, surface, src);
8175
- const kept = options.cut ? new Uint8ClampedArray(px) : null;
9101
+ const px2 = _chunkCRMAXIUVcjs.readRegion.call(void 0, surface, src);
9102
+ const kept = options.cut ? new Uint8ClampedArray(px2) : null;
8176
9103
  for (let y = 0; y < sb.height; y++) {
8177
9104
  for (let x = 0; x < sb.width; x++) {
8178
9105
  const c = sel.data[(sb.y + y) * sel.width + sb.x + x];
8179
9106
  const i = (y * sb.width + x) * 4 + 3;
8180
9107
  if (kept) kept[i] = Math.round(kept[i] * (1 - c / 255));
8181
- px[i] = Math.round(px[i] * (c / 255));
9108
+ px2[i] = Math.round(px2[i] * (c / 255));
8182
9109
  }
8183
9110
  }
8184
9111
  const copy = {
8185
9112
  type: "pixel",
8186
9113
  id: newLayerId(),
8187
- name: _optionalChain([options, 'access', _170 => _170.name, 'optionalAccess', _171 => _171.trim, 'call', _172 => _172()]) || `${layer.name || "Layer"} ${options.cut ? "cut" : "copy"}`,
9114
+ name: _optionalChain([options, 'access', _188 => _188.name, 'optionalAccess', _189 => _189.trim, 'call', _190 => _190()]) || `${layer.name || "Layer"} ${options.cut ? "cut" : "copy"}`,
8188
9115
  visible: true,
8189
9116
  opacity: 1,
8190
9117
  blend: "normal",
8191
- surface: _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width: src.width, height: src.height, data: px }, 4, src.x, src.y),
9118
+ surface: _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width: src.width, height: src.height, data: px2 }, 4, src.x, src.y),
8192
9119
  offset: { ...layer.offset }
8193
9120
  };
8194
- let next = _chunkT6H3JDGAcjs.insertLayer.call(void 0, this.state.layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _173 => _173.parent, 'optionalAccess', _174 => _174.id]), () => ( null)), loc.index + 1);
9121
+ let next = _chunk4AB5BHYKcjs.insertLayer.call(void 0, this.state.layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _191 => _191.parent, 'optionalAccess', _192 => _192.id]), () => ( null)), loc.index + 1);
8195
9122
  if (kept) {
8196
9123
  const cutLayer = { ...layer, surface: _chunkCRMAXIUVcjs.writeRegion.call(void 0, surface, src, kept) };
8197
9124
  delete cutLayer.source;
8198
- next = _chunkT6H3JDGAcjs.mapLayer.call(void 0, next, id, () => cutLayer);
9125
+ next = _chunk4AB5BHYKcjs.mapLayer.call(void 0, next, id, () => cutLayer);
8199
9126
  }
8200
9127
  this.commitLayers(next, () => {
8201
9128
  this.state.activeLayerId = copy.id;
@@ -8208,19 +9135,19 @@ var ImageEditorController = (_class7 = class {
8208
9135
  const f = normalizeFilter(filter);
8209
9136
  const next = addLayerFilter(this.state.layers, id, f);
8210
9137
  this.commitLayers(next);
8211
- return _nullishCoalesce(_chunkT6H3JDGAcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
9138
+ return _nullishCoalesce(_chunk4AB5BHYKcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
8212
9139
  }
8213
9140
  /** Changes one filter (one undo step, or none with `commitToHistory = false` during a drag). Returns the filters. */
8214
9141
  updateLayerFilter(id, filterId, changes, commitToHistory = true) {
8215
9142
  const next = updateLayerFilter(this.state.layers, id, filterId, changes);
8216
9143
  this.commitLayers(next, void 0, commitToHistory);
8217
- return _nullishCoalesce(_chunkT6H3JDGAcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
9144
+ return _nullishCoalesce(_chunk4AB5BHYKcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
8218
9145
  }
8219
9146
  /** Removes one filter (one undo step). Returns the remaining filters. */
8220
9147
  removeLayerFilter(id, filterId) {
8221
9148
  const next = removeLayerFilter(this.state.layers, id, filterId);
8222
9149
  this.commitLayers(next);
8223
- return _nullishCoalesce(_chunkT6H3JDGAcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
9150
+ return _nullishCoalesce(_chunk4AB5BHYKcjs.findLayer.call(void 0, next, id).layer.filters, () => ( []));
8224
9151
  }
8225
9152
  // --- Layer effects ---
8226
9153
  /** A layer's effects (an empty, enabled list when it has none). */
@@ -8256,9 +9183,25 @@ var ImageEditorController = (_class7 = class {
8256
9183
  this.commitLayers(setLayerEffects(this.state.layers, id, effects), void 0, commitToHistory);
8257
9184
  return this.getLayerEffects(id);
8258
9185
  }
9186
+ __init49() {this.patternIds = /* @__PURE__ */ new WeakMap()}
9187
+ /** Changes whenever the document's pattern list is replaced (the compositor then drops its caches). */
9188
+ patternsVersion() {
9189
+ const list2 = this.state.patterns;
9190
+ if (!list2) return 0;
9191
+ let id = this.patternIds.get(list2);
9192
+ if (id === void 0) {
9193
+ id = this.nextSourceId++;
9194
+ this.patternIds.set(list2, id);
9195
+ }
9196
+ return id;
9197
+ }
9198
+ /** The document's patterns (from an opened PSD), besides the built-in ones. */
9199
+ getDocumentPatterns() {
9200
+ return _nullishCoalesce(this.state.patterns, () => ( []));
9201
+ }
8259
9202
  /** The light effects with "use global light" follow. */
8260
9203
  getGlobalLight() {
8261
- return { ..._nullishCoalesce(this.state.globalLight, () => ( _chunkT6H3JDGAcjs.DEFAULT_GLOBAL_LIGHT)) };
9204
+ return { ..._nullishCoalesce(this.state.globalLight, () => ( _chunk4AB5BHYKcjs.DEFAULT_GLOBAL_LIGHT)) };
8262
9205
  }
8263
9206
  /** Sets the global light (one undo step). `angle` -360..360°, `altitude` 0..90°. Returns it. */
8264
9207
  setGlobalLight(light, commitToHistory = true) {
@@ -8266,7 +9209,7 @@ var ImageEditorController = (_class7 = class {
8266
9209
  if (!(Number.isFinite(next.angle) && next.angle >= -360 && next.angle <= 360)) throw new LayerOperationError(`angle must be from -360 to 360 degrees, got ${next.angle}.`);
8267
9210
  if (!(Number.isFinite(next.altitude) && next.altitude >= 0 && next.altitude <= 90)) throw new LayerOperationError(`altitude must be from 0 to 90 degrees, got ${next.altitude}.`);
8268
9211
  if (commitToHistory) this.recordHistory();
8269
- if (next.angle === _chunkT6H3JDGAcjs.DEFAULT_GLOBAL_LIGHT.angle && next.altitude === _chunkT6H3JDGAcjs.DEFAULT_GLOBAL_LIGHT.altitude) delete this.state.globalLight;
9212
+ if (next.angle === _chunk4AB5BHYKcjs.DEFAULT_GLOBAL_LIGHT.angle && next.altitude === _chunk4AB5BHYKcjs.DEFAULT_GLOBAL_LIGHT.altitude) delete this.state.globalLight;
8270
9213
  else this.state.globalLight = next;
8271
9214
  this.notify();
8272
9215
  return this.getGlobalLight();
@@ -8274,7 +9217,7 @@ var ImageEditorController = (_class7 = class {
8274
9217
  /** Composites `layers` (in isolation) over `rect` into a surface, loading depth maps first. */
8275
9218
  async compositeToSurface(layers, rect) {
8276
9219
  const { width, height } = this.naturalSize;
8277
- if (_chunkT6H3JDGAcjs.flattenLayers.call(void 0, layers).some((l) => l.type === "annotation" && l.visible) && !this.renderer.canRasterize()) {
9220
+ if (_chunk4AB5BHYKcjs.flattenLayers.call(void 0, layers).some((l) => l.type === "annotation" && l.visible) && !this.renderer.canRasterize()) {
8278
9221
  throw new LayerOperationError("Merging annotation layers needs a canvas (a browser); hide or delete them first, or merge in the browser.");
8279
9222
  }
8280
9223
  await this.renderer.prepareLayerAssets(layers, width, height);
@@ -8314,7 +9257,7 @@ var ImageEditorController = (_class7 = class {
8314
9257
  requireUnlocked(upper, "all", "merge it");
8315
9258
  requireUnlocked(lower, "pixels", "merge into it");
8316
9259
  let rect = _nullishCoalesce(unionRect(this.paintBounds(lower), upper.type === "adjustment" ? null : this.paintBounds(upper)), () => ( { x: 0, y: 0, width: 1, height: 1 }));
8317
- const reach = Math.max(_chunkT6H3JDGAcjs.effectsMargin.call(void 0, lower.effects), upper.type === "adjustment" ? 0 : _chunkT6H3JDGAcjs.effectsMargin.call(void 0, upper.effects));
9260
+ const reach = Math.max(_chunk4AB5BHYKcjs.effectsMargin.call(void 0, lower.effects), upper.type === "adjustment" ? 0 : _chunk4AB5BHYKcjs.effectsMargin.call(void 0, upper.effects));
8318
9261
  if (reach) rect = { x: rect.x - reach, y: rect.y - reach, width: rect.width + 2 * reach, height: rect.height + 2 * reach };
8319
9262
  const base = { ...lower, blend: "normal", opacity: 1 };
8320
9263
  delete base.clipped;
@@ -8325,8 +9268,8 @@ var ImageEditorController = (_class7 = class {
8325
9268
  delete merged.filters;
8326
9269
  delete merged.source;
8327
9270
  delete merged.effects;
8328
- let next = _chunkT6H3JDGAcjs.mapLayer.call(void 0, this.state.layers, id, () => null);
8329
- next = _chunkT6H3JDGAcjs.mapLayer.call(void 0, next, lower.id, () => merged);
9271
+ let next = _chunk4AB5BHYKcjs.mapLayer.call(void 0, this.state.layers, id, () => null);
9272
+ next = _chunk4AB5BHYKcjs.mapLayer.call(void 0, next, lower.id, () => merged);
8330
9273
  this.commitLayers(next, () => {
8331
9274
  this.state.activeLayerId = merged.id;
8332
9275
  this.state.activeTarget = "pixels";
@@ -8383,7 +9326,7 @@ var ImageEditorController = (_class7 = class {
8383
9326
  });
8384
9327
  return bg.id;
8385
9328
  }
8386
- __init49() {this.thumbCache = /* @__PURE__ */ new WeakMap()}
9329
+ __init50() {this.thumbCache = /* @__PURE__ */ new WeakMap()}
8387
9330
  /**
8388
9331
  * A small RGBA preview of a pixel layer over the canvas (or of its mask with `mask: true`),
8389
9332
  * longest side `maxSide` px, point-sampled; `null` for layers without pixels.
@@ -8402,7 +9345,7 @@ var ImageEditorController = (_class7 = class {
8402
9345
  const oy = layer.type === "pixel" ? layer.offset.y : 0;
8403
9346
  const key = `${tw}x${th}:${ox},${oy}`;
8404
9347
  let byKey = this.thumbCache.get(surface);
8405
- const hit = _optionalChain([byKey, 'optionalAccess', _175 => _175.get, 'call', _176 => _176(key)]);
9348
+ const hit = _optionalChain([byKey, 'optionalAccess', _193 => _193.get, 'call', _194 => _194(key)]);
8406
9349
  if (hit) return hit;
8407
9350
  const out = new Uint8ClampedArray(tw * th * 4);
8408
9351
  for (let y = 0; y < th; y++) {
@@ -8490,7 +9433,7 @@ var ImageEditorController = (_class7 = class {
8490
9433
  if (!layer.visible) throw new LayerOperationError(`Layer "${layer.name || id}" is hidden; show it before you ${action}.`);
8491
9434
  const offset = layer.type === "pixel" ? layer.offset : { x: 0, y: 0 };
8492
9435
  const surface = ch === "mask" ? layer.mask.surface : this.surfaceOf(layer);
8493
- const lockTransparency = ch === "pixels" && Boolean(_optionalChain([layer, 'access', _177 => _177.locks, 'optionalAccess', _178 => _178.transparency]));
9436
+ const lockTransparency = ch === "pixels" && Boolean(_optionalChain([layer, 'access', _195 => _195.locks, 'optionalAccess', _196 => _196.transparency]));
8494
9437
  return { id, layer, channel: ch, offset, surface, lockTransparency };
8495
9438
  }
8496
9439
  /** The layer with its pixels (or mask) replaced by `surface`. */
@@ -8527,7 +9470,7 @@ var ImageEditorController = (_class7 = class {
8527
9470
  opacity: brush.opacity,
8528
9471
  blend: target.channel === "mask" ? "normal" : brush.blend,
8529
9472
  lockTransparency: target.lockTransparency,
8530
- selection: _optionalChain([this, 'access', _179 => _179.state, 'access', _180 => _180.selection, 'optionalAccess', _181 => _181.bounds]) ? this.state.selection : null,
9473
+ selection: _optionalChain([this, 'access', _197 => _197.state, 'access', _198 => _198.selection, 'optionalAccess', _199 => _199.bounds]) ? this.state.selection : null,
8531
9474
  offset: target.offset
8532
9475
  };
8533
9476
  if (tool === "mixer") return new PaintStrokeSession(this, target, this.mixerStroke(init, brush), apply);
@@ -8552,12 +9495,12 @@ var ImageEditorController = (_class7 = class {
8552
9495
  }
8553
9496
  /** @internal Shows a stroke's live surface (no history). */
8554
9497
  _strokeUpdate(layerId, channel, surface, rects) {
8555
- this.state.layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => this.withSurface(l, channel, surface));
9498
+ this.state.layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => this.withSurface(l, channel, surface));
8556
9499
  this.notify(rects);
8557
9500
  }
8558
9501
  /** @internal Commits a finished stroke as one undo step (`before` is the pre-stroke state). */
8559
9502
  _strokeCommit(before, layerId, channel, surface) {
8560
- if (surface) this.state.layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => this.withSurface(l, channel, surface));
9503
+ if (surface) this.state.layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => this.withSurface(l, channel, surface));
8561
9504
  else this.state.layers = before.layers;
8562
9505
  if (surface && !this.isApplyingHistory) {
8563
9506
  this.undoStack.push(before);
@@ -8579,7 +9522,7 @@ var ImageEditorController = (_class7 = class {
8579
9522
  paintStroke(init) {
8580
9523
  if (!Array.isArray(init.points) || !init.points.length) throw new LayerOperationError("points must hold at least one { x, y } point.");
8581
9524
  for (const p of init.points) {
8582
- if (!Number.isFinite(_optionalChain([p, 'optionalAccess', _182 => _182.x])) || !Number.isFinite(_optionalChain([p, 'optionalAccess', _183 => _183.y]))) throw new LayerOperationError("Every point needs finite x and y (document pixels).");
9525
+ if (!Number.isFinite(_optionalChain([p, 'optionalAccess', _200 => _200.x])) || !Number.isFinite(_optionalChain([p, 'optionalAccess', _201 => _201.y]))) throw new LayerOperationError("Every point needs finite x and y (document pixels).");
8583
9526
  }
8584
9527
  const session = this.beginStroke(init);
8585
9528
  session.push(init.points);
@@ -8607,8 +9550,8 @@ var ImageEditorController = (_class7 = class {
8607
9550
  const opacity = _nullishCoalesce(options.opacity, () => ( 1));
8608
9551
  if (!(opacity >= 0 && opacity <= 1)) throw new LayerOperationError("opacity must be from 0 to 1.");
8609
9552
  const blend = _nullishCoalesce(parseBlend(options.blend), () => ( "normal"));
8610
- const sel = options.useSelection !== false && _optionalChain([this, 'access', _184 => _184.state, 'access', _185 => _185.selection, 'optionalAccess', _186 => _186.bounds]) ? this.state.selection : null;
8611
- const region = _nullishCoalesce(_optionalChain([sel, 'optionalAccess', _187 => _187.bounds]), () => ( { x: 0, y: 0, width, height }));
9553
+ const sel = options.useSelection !== false && _optionalChain([this, 'access', _202 => _202.state, 'access', _203 => _203.selection, 'optionalAccess', _204 => _204.bounds]) ? this.state.selection : null;
9554
+ const region = _nullishCoalesce(_optionalChain([sel, 'optionalAccess', _205 => _205.bounds]), () => ( { x: 0, y: 0, width, height }));
8612
9555
  const coverage = new (0, _chunkZZOTHJ4Kcjs.CoverageMap)();
8613
9556
  const ones = new Float32Array(region.width * region.height);
8614
9557
  if (sel) {
@@ -8634,7 +9577,7 @@ var ImageEditorController = (_class7 = class {
8634
9577
  offset: target.offset
8635
9578
  };
8636
9579
  const surface = paintCoverageInto(target.surface, coverage, apply, [region]);
8637
- const next = _chunkT6H3JDGAcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => this.withSurface(l, target.channel, surface));
9580
+ const next = _chunk4AB5BHYKcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => this.withSurface(l, target.channel, surface));
8638
9581
  this.commitLayers(next);
8639
9582
  return { layerId: target.id, channel: target.channel, bounds: region, dabs: 0 };
8640
9583
  }
@@ -8656,12 +9599,12 @@ var ImageEditorController = (_class7 = class {
8656
9599
  const target = this.developLayer();
8657
9600
  let layers = this.state.layers;
8658
9601
  if (target && (DEVELOP_KEYS.some((k) => k in partial) || "process" in partial)) {
8659
- layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, target.id, (l) => withDevelop(l, partial));
9602
+ layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, target.id, (l) => withDevelop(l, partial));
8660
9603
  }
8661
9604
  if ("blur" in partial && typeof partial.blur === "number") {
8662
9605
  const blur = Math.max(0, partial.blur);
8663
9606
  if (this.state.legacyOutputBlur !== void 0) this.state.legacyOutputBlur = blur;
8664
- else if (target) layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, target.id, (l) => withBlur(l, blur));
9607
+ else if (target) layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, target.id, (l) => withBlur(l, blur));
8665
9608
  }
8666
9609
  if ("opacity" in partial && typeof partial.opacity === "number") {
8667
9610
  this.state.outputOpacity = Math.min(1, Math.max(0, partial.opacity));
@@ -8691,7 +9634,7 @@ var ImageEditorController = (_class7 = class {
8691
9634
  this.recordHistory();
8692
9635
  const target = this.developLayer();
8693
9636
  if (target) {
8694
- this.state.layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0,
9637
+ this.state.layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0,
8695
9638
  this.state.layers,
8696
9639
  target.id,
8697
9640
  (l) => withBlur(withDevelop(l, { ...DEFAULT_ADJUSTMENTS, process: LATEST_PROCESS_VERSION }), 0)
@@ -8711,7 +9654,7 @@ var ImageEditorController = (_class7 = class {
8711
9654
  return this.getAdjustmentLayers().find((l) => l.id === id);
8712
9655
  }
8713
9656
  adjustmentNodes(layers = this.state.layers) {
8714
- return _chunkT6H3JDGAcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "adjustment");
9657
+ return _chunk4AB5BHYKcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "adjustment");
8715
9658
  }
8716
9659
  /**
8717
9660
  * Where a new layer goes when no position is given: directly above the topmost layer that is
@@ -8725,26 +9668,26 @@ var ImageEditorController = (_class7 = class {
8725
9668
  /** Inserts `node` by `aboveId` / `parentId` / adjustment index / default position. */
8726
9669
  placeLayer(layers, node, where) {
8727
9670
  if (where.aboveId) {
8728
- const loc = _chunkT6H3JDGAcjs.findLayer.call(void 0, layers, where.aboveId);
8729
- if (loc) return _chunkT6H3JDGAcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _188 => _188.parent, 'optionalAccess', _189 => _189.id]), () => ( null)), loc.index + 1);
9671
+ const loc = _chunk4AB5BHYKcjs.findLayer.call(void 0, layers, where.aboveId);
9672
+ if (loc) return _chunk4AB5BHYKcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _206 => _206.parent, 'optionalAccess', _207 => _207.id]), () => ( null)), loc.index + 1);
8730
9673
  }
8731
9674
  if (where.parentId) {
8732
- const loc = _chunkT6H3JDGAcjs.findLayer.call(void 0, layers, where.parentId);
8733
- if (loc && loc.layer.type === "group") return _chunkT6H3JDGAcjs.insertLayer.call(void 0, layers, node, loc.layer.id);
9675
+ const loc = _chunk4AB5BHYKcjs.findLayer.call(void 0, layers, where.parentId);
9676
+ if (loc && loc.layer.type === "group") return _chunk4AB5BHYKcjs.insertLayer.call(void 0, layers, node, loc.layer.id);
8734
9677
  }
8735
9678
  if (where.adjustmentIndex !== void 0) {
8736
9679
  const nodes = this.adjustmentNodes(layers);
8737
9680
  const at = Math.max(0, Math.min(nodes.length, Math.round(where.adjustmentIndex)));
8738
9681
  if (at < nodes.length) {
8739
- const loc = _chunkT6H3JDGAcjs.findLayer.call(void 0, layers, nodes[at].id);
8740
- return _chunkT6H3JDGAcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _190 => _190.parent, 'optionalAccess', _191 => _191.id]), () => ( null)), loc.index);
9682
+ const loc = _chunk4AB5BHYKcjs.findLayer.call(void 0, layers, nodes[at].id);
9683
+ return _chunk4AB5BHYKcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _208 => _208.parent, 'optionalAccess', _209 => _209.id]), () => ( null)), loc.index);
8741
9684
  }
8742
9685
  if (nodes.length) {
8743
- const loc = _chunkT6H3JDGAcjs.findLayer.call(void 0, layers, nodes[nodes.length - 1].id);
8744
- return _chunkT6H3JDGAcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _192 => _192.parent, 'optionalAccess', _193 => _193.id]), () => ( null)), loc.index + 1);
9686
+ const loc = _chunk4AB5BHYKcjs.findLayer.call(void 0, layers, nodes[nodes.length - 1].id);
9687
+ return _chunk4AB5BHYKcjs.insertLayer.call(void 0, layers, node, _nullishCoalesce(_optionalChain([loc, 'access', _210 => _210.parent, 'optionalAccess', _211 => _211.id]), () => ( null)), loc.index + 1);
8745
9688
  }
8746
9689
  }
8747
- return _chunkT6H3JDGAcjs.insertLayer.call(void 0, layers, node, null, this.defaultInsertIndex(layers));
9690
+ return _chunk4AB5BHYKcjs.insertLayer.call(void 0, layers, node, null, this.defaultInsertIndex(layers));
8748
9691
  }
8749
9692
  /** `setAdjustments({ layers })`: updates nodes by id in place, removes missing ones, adds new ones. */
8750
9693
  replaceAdjustmentNodes(layers, next) {
@@ -8753,7 +9696,7 @@ var ImageEditorController = (_class7 = class {
8753
9696
  let out = layers;
8754
9697
  for (const node of this.adjustmentNodes(layers)) {
8755
9698
  const update = byId.get(node.id);
8756
- out = _chunkT6H3JDGAcjs.mapLayer.call(void 0, out, node.id, () => update ? mergeAdjustmentNode(node, update, width, height) : null);
9699
+ out = _chunk4AB5BHYKcjs.mapLayer.call(void 0, out, node.id, () => update ? mergeAdjustmentNode(node, update, width, height) : null);
8757
9700
  }
8758
9701
  const existing = new Set(this.adjustmentNodes(out).map((n) => n.id));
8759
9702
  for (const l of next) {
@@ -8772,7 +9715,7 @@ var ImageEditorController = (_class7 = class {
8772
9715
  */
8773
9716
  addAdjustmentLayer(init, index) {
8774
9717
  const spec = typeof init === "string" ? { kind: init } : init;
8775
- const ids = new Set(_chunkT6H3JDGAcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.id));
9718
+ const ids = new Set(_chunk4AB5BHYKcjs.flattenLayers.call(void 0, this.state.layers).map((l) => l.id));
8776
9719
  const layer = createAdjustmentLayer(spec.kind, {
8777
9720
  id: spec.id && !ids.has(spec.id) ? spec.id : void 0,
8778
9721
  name: spec.name,
@@ -8801,7 +9744,7 @@ var ImageEditorController = (_class7 = class {
8801
9744
  * Returns false for an unknown id.
8802
9745
  */
8803
9746
  updateAdjustmentLayer(id, update, commitToHistory = true) {
8804
- const loc = _chunkT6H3JDGAcjs.findLayer.call(void 0, this.state.layers, id);
9747
+ const loc = _chunk4AB5BHYKcjs.findLayer.call(void 0, this.state.layers, id);
8805
9748
  if (!loc || loc.layer.type !== "adjustment") return false;
8806
9749
  const { width, height } = this.naturalSize;
8807
9750
  const node = loc.layer;
@@ -8829,16 +9772,16 @@ var ImageEditorController = (_class7 = class {
8829
9772
  if (mask) next.mask = mask;
8830
9773
  else delete next.mask;
8831
9774
  }
8832
- this.state.layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, this.state.layers, id, () => next);
9775
+ this.state.layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, this.state.layers, id, () => next);
8833
9776
  this.notify();
8834
9777
  return true;
8835
9778
  }
8836
9779
  /** Removes a layer as one undo step. Returns false for an unknown id. */
8837
9780
  removeAdjustmentLayer(id) {
8838
- const loc = _chunkT6H3JDGAcjs.findLayer.call(void 0, this.state.layers, id);
9781
+ const loc = _chunk4AB5BHYKcjs.findLayer.call(void 0, this.state.layers, id);
8839
9782
  if (!loc || loc.layer.type !== "adjustment") return false;
8840
9783
  this.recordHistory();
8841
- this.state.layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, this.state.layers, id, () => null);
9784
+ this.state.layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, this.state.layers, id, () => null);
8842
9785
  if (this.state.activeLayerId === id) this.state.activeLayerId = null;
8843
9786
  this.notify();
8844
9787
  return true;
@@ -8851,9 +9794,9 @@ var ImageEditorController = (_class7 = class {
8851
9794
  if (to === from) return layers;
8852
9795
  const node = nodes[from];
8853
9796
  const anchor = nodes[to];
8854
- const without = _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, id, () => null);
8855
- const loc = _chunkT6H3JDGAcjs.findLayer.call(void 0, without, anchor.id);
8856
- return _chunkT6H3JDGAcjs.insertLayer.call(void 0, without, node, _nullishCoalesce(_optionalChain([loc, 'access', _194 => _194.parent, 'optionalAccess', _195 => _195.id]), () => ( null)), to > from ? loc.index + 1 : loc.index);
9797
+ const without = _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, id, () => null);
9798
+ const loc = _chunk4AB5BHYKcjs.findLayer.call(void 0, without, anchor.id);
9799
+ return _chunk4AB5BHYKcjs.insertLayer.call(void 0, without, node, _nullishCoalesce(_optionalChain([loc, 'access', _212 => _212.parent, 'optionalAccess', _213 => _213.id]), () => ( null)), to > from ? loc.index + 1 : loc.index);
8857
9800
  }
8858
9801
  /** Moves a layer to `toIndex` among the adjustment layers (0 = bottom) as one undo step. Returns false if nothing moved. */
8859
9802
  moveAdjustmentLayer(id, toIndex) {
@@ -8878,7 +9821,7 @@ var ImageEditorController = (_class7 = class {
8878
9821
  if (!nodes.length) return;
8879
9822
  this.recordHistory();
8880
9823
  let layers = this.state.layers;
8881
- for (const n of nodes) layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, n.id, () => null);
9824
+ for (const n of nodes) layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, n.id, () => null);
8882
9825
  this.state.layers = layers;
8883
9826
  if (nodes.some((n) => n.id === this.state.activeLayerId)) this.state.activeLayerId = null;
8884
9827
  this.notify();
@@ -8889,7 +9832,7 @@ var ImageEditorController = (_class7 = class {
8889
9832
  return _nullishCoalesce(this.state.selection, () => ( null));
8890
9833
  }
8891
9834
  get hasSelection() {
8892
- return Boolean(_optionalChain([this, 'access', _196 => _196.state, 'access', _197 => _197.selection, 'optionalAccess', _198 => _198.bounds]));
9835
+ return Boolean(_optionalChain([this, 'access', _214 => _214.state, 'access', _215 => _215.selection, 'optionalAccess', _216 => _216.bounds]));
8893
9836
  }
8894
9837
  get naturalSize() {
8895
9838
  return {
@@ -8979,13 +9922,13 @@ var ImageEditorController = (_class7 = class {
8979
9922
  try {
8980
9923
  const canvas = await this.renderSource();
8981
9924
  const ctx = canvas.getContext("2d");
8982
- const data2 = _optionalChain([ctx, 'optionalAccess', _199 => _199.getImageData, 'optionalCall', _200 => _200(0, 0, width, height)]);
9925
+ const data2 = _optionalChain([ctx, 'optionalAccess', _217 => _217.getImageData, 'optionalCall', _218 => _218(0, 0, width, height)]);
8983
9926
  if (data2 && data2.data && data2.data.length >= width * height * 4) {
8984
9927
  base = { width, height, data: data2.data };
8985
9928
  this.samplePixels = base;
8986
9929
  this.samplePixelsOverride = false;
8987
9930
  }
8988
- } catch (e23) {
9931
+ } catch (e25) {
8989
9932
  base = null;
8990
9933
  }
8991
9934
  }
@@ -9045,7 +9988,7 @@ var ImageEditorController = (_class7 = class {
9045
9988
  /** Select › Modify: grow, shrink, feather, border or smooth by `radius` pixels (one undo step). */
9046
9989
  modifySelection(op, radius) {
9047
9990
  const sel = this.state.selection;
9048
- if (!_optionalChain([sel, 'optionalAccess', _201 => _201.bounds])) return false;
9991
+ if (!_optionalChain([sel, 'optionalAccess', _219 => _219.bounds])) return false;
9049
9992
  return this.setSelection(modifySelection(sel, op, radius));
9050
9993
  }
9051
9994
  /**
@@ -9054,7 +9997,7 @@ var ImageEditorController = (_class7 = class {
9054
9997
  */
9055
9998
  async refineSelection(params, options = {}) {
9056
9999
  const sel = this.state.selection;
9057
- if (!_optionalChain([sel, 'optionalAccess', _202 => _202.bounds])) return false;
10000
+ if (!_optionalChain([sel, 'optionalAccess', _220 => _220.bounds])) return false;
9058
10001
  const pixels = (_nullishCoalesce(params.radius, () => ( 0))) > 0 ? await this.requirePixels(options) : null;
9059
10002
  return this.setSelection(refineSelection(pixels, sel, params));
9060
10003
  }
@@ -9071,7 +10014,7 @@ var ImageEditorController = (_class7 = class {
9071
10014
  const canvas = this.renderer.createCanvas(w, h);
9072
10015
  const ctx = canvas.getContext("2d");
9073
10016
  if (ctx) ctx.drawImage(img, 0, 0, w, h);
9074
- const data = _optionalChain([ctx, 'optionalAccess', _203 => _203.getImageData, 'optionalCall', _204 => _204(0, 0, w, h)]);
10017
+ const data = _optionalChain([ctx, 'optionalAccess', _221 => _221.getImageData, 'optionalCall', _222 => _222(0, 0, w, h)]);
9075
10018
  if (!data) throw new Error("The mask image pixels are not available (no canvas access); pass pixels.");
9076
10019
  pixels = { width: w, height: h, data: data.data };
9077
10020
  } else {
@@ -9099,14 +10042,14 @@ var ImageEditorController = (_class7 = class {
9099
10042
  */
9100
10043
  applySelectionAsLayerMask(layerId, props = {}) {
9101
10044
  const sel = this.state.selection;
9102
- if (!_optionalChain([sel, 'optionalAccess', _205 => _205.bounds]) || !this.getAdjustmentLayer(layerId)) return false;
10045
+ if (!_optionalChain([sel, 'optionalAccess', _223 => _223.bounds]) || !this.getAdjustmentLayer(layerId)) return false;
9103
10046
  return this.setLayerMask(layerId, this.maskFromSelection(sel, props));
9104
10047
  }
9105
10048
  setLayerMask(layerId, mask, commitToHistory = true) {
9106
- const loc = _chunkT6H3JDGAcjs.findLayer.call(void 0, this.state.layers, layerId);
10049
+ const loc = _chunk4AB5BHYKcjs.findLayer.call(void 0, this.state.layers, layerId);
9107
10050
  if (!loc) return false;
9108
10051
  if (commitToHistory) this.recordHistory();
9109
- this.state.layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => {
10052
+ this.state.layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, this.state.layers, layerId, (l) => {
9110
10053
  const next = { ...l };
9111
10054
  if (mask) next.mask = mask;
9112
10055
  else delete next.mask;
@@ -9130,7 +10073,7 @@ var ImageEditorController = (_class7 = class {
9130
10073
  /** Load Selection from a layer mask (its pixels; density and feather are not applied). */
9131
10074
  selectionFromLayerMask(layerId, mode = "replace") {
9132
10075
  const layer = this.getLayer(layerId);
9133
- if (!_optionalChain([layer, 'optionalAccess', _206 => _206.mask]) || layer.mask.source) return false;
10076
+ if (!_optionalChain([layer, 'optionalAccess', _224 => _224.mask]) || layer.mask.source) return false;
9134
10077
  const { width, height } = this.naturalSize;
9135
10078
  const ox = layer.type === "pixel" ? layer.offset.x : 0;
9136
10079
  const oy = layer.type === "pixel" ? layer.offset.y : 0;
@@ -9163,10 +10106,10 @@ var ImageEditorController = (_class7 = class {
9163
10106
  if (target) {
9164
10107
  const merged = { ...this.state.depthMask, ...partial };
9165
10108
  merged.depthRange = [...merged.depthRange];
9166
- this.state.layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => {
10109
+ this.state.layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => {
9167
10110
  const next = { ...l };
9168
10111
  if (isDefaultDepthMask(merged)) {
9169
- if (_optionalChain([next, 'access', _207 => _207.mask, 'optionalAccess', _208 => _208.source])) delete next.mask;
10112
+ if (_optionalChain([next, 'access', _225 => _225.mask, 'optionalAccess', _226 => _226.source])) delete next.mask;
9170
10113
  } else next.mask = depthRasterMask(merged);
9171
10114
  return next;
9172
10115
  });
@@ -9176,8 +10119,8 @@ var ImageEditorController = (_class7 = class {
9176
10119
  resetDepthMask() {
9177
10120
  this.recordHistory();
9178
10121
  const target = this.developLayer();
9179
- if (_optionalChain([target, 'optionalAccess', _209 => _209.mask, 'optionalAccess', _210 => _210.source])) {
9180
- this.state.layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => {
10122
+ if (_optionalChain([target, 'optionalAccess', _227 => _227.mask, 'optionalAccess', _228 => _228.source])) {
10123
+ this.state.layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, this.state.layers, target.id, (l) => {
9181
10124
  const next = { ...l };
9182
10125
  delete next.mask;
9183
10126
  return next;
@@ -9187,7 +10130,7 @@ var ImageEditorController = (_class7 = class {
9187
10130
  }
9188
10131
  // --- Annotations & Layers ---
9189
10132
  annotationLayer(id) {
9190
- return _chunkT6H3JDGAcjs.flattenLayers.call(void 0, this.state.layers).find(
10133
+ return _chunk4AB5BHYKcjs.flattenLayers.call(void 0, this.state.layers).find(
9191
10134
  (l) => l.type === "annotation" && l.annotation.id === id
9192
10135
  );
9193
10136
  }
@@ -9197,8 +10140,8 @@ var ImageEditorController = (_class7 = class {
9197
10140
  const id = `ann_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`;
9198
10141
  const fullAnnotation = { ...annotation, id };
9199
10142
  const layer = annotationLayerFor(fullAnnotation);
9200
- const loc = placement.aboveId ? _chunkT6H3JDGAcjs.findLayer.call(void 0, this.state.layers, placement.aboveId) : null;
9201
- this.state.layers = loc ? _chunkT6H3JDGAcjs.insertLayer.call(void 0, this.state.layers, layer, _nullishCoalesce(_optionalChain([loc, 'access', _211 => _211.parent, 'optionalAccess', _212 => _212.id]), () => ( null)), loc.index + 1) : _chunkT6H3JDGAcjs.insertLayer.call(void 0, this.state.layers, layer, null);
10143
+ const loc = placement.aboveId ? _chunk4AB5BHYKcjs.findLayer.call(void 0, this.state.layers, placement.aboveId) : null;
10144
+ this.state.layers = loc ? _chunk4AB5BHYKcjs.insertLayer.call(void 0, this.state.layers, layer, _nullishCoalesce(_optionalChain([loc, 'access', _229 => _229.parent, 'optionalAccess', _230 => _230.id]), () => ( null)), loc.index + 1) : _chunk4AB5BHYKcjs.insertLayer.call(void 0, this.state.layers, layer, null);
9202
10145
  this.state.selectedAnnotationId = id;
9203
10146
  this.notify();
9204
10147
  return id;
@@ -9211,14 +10154,14 @@ var ImageEditorController = (_class7 = class {
9211
10154
  if (layer) {
9212
10155
  const annotation = { ...layer.annotation, ...partial, id };
9213
10156
  const name = layer.name === annotationLayerName(layer.annotation) ? annotationLayerName(annotation) : layer.name;
9214
- this.state.layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, this.state.layers, layer.id, () => ({ ...layer, annotation, name }));
10157
+ this.state.layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, this.state.layers, layer.id, () => ({ ...layer, annotation, name }));
9215
10158
  }
9216
10159
  this.notify();
9217
10160
  }
9218
10161
  removeAnnotation(id) {
9219
10162
  this.recordHistory();
9220
10163
  const layer = this.annotationLayer(id);
9221
- if (layer) this.state.layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, this.state.layers, layer.id, () => null);
10164
+ if (layer) this.state.layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, this.state.layers, layer.id, () => null);
9222
10165
  if (this.state.selectedAnnotationId === id) {
9223
10166
  this.state.selectedAnnotationId = null;
9224
10167
  }
@@ -9227,7 +10170,7 @@ var ImageEditorController = (_class7 = class {
9227
10170
  clearAnnotations() {
9228
10171
  this.recordHistory();
9229
10172
  let layers = this.state.layers;
9230
- for (const l of _chunkT6H3JDGAcjs.flattenLayers.call(void 0, layers)) if (l.type === "annotation") layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, l.id, () => null);
10173
+ for (const l of _chunk4AB5BHYKcjs.flattenLayers.call(void 0, layers)) if (l.type === "annotation") layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, l.id, () => null);
9231
10174
  this.state.layers = layers;
9232
10175
  this.state.selectedAnnotationId = null;
9233
10176
  this.notify();
@@ -9267,7 +10210,7 @@ var ImageEditorController = (_class7 = class {
9267
10210
  this.notify();
9268
10211
  }
9269
10212
  // --- Rendering & Export ---
9270
- __init50() {this.blankSource = null}
10213
+ __init51() {this.blankSource = null}
9271
10214
  /**
9272
10215
  * What the renderer draws from: the source image, or, for a document without one (an opened
9273
10216
  * PSD, a v3 document loaded on its own), a transparent canvas of the document size, since every
@@ -9295,7 +10238,7 @@ var ImageEditorController = (_class7 = class {
9295
10238
  dirty: dirty === "all" ? void 0 : dirty,
9296
10239
  checkpointLayerId: this.state.activeLayerId
9297
10240
  });
9298
- } catch (e24) {
10241
+ } catch (e26) {
9299
10242
  }
9300
10243
  }
9301
10244
  async renderExport(options) {
@@ -9304,9 +10247,9 @@ var ImageEditorController = (_class7 = class {
9304
10247
  return this.renderer.createCanvas(1, 1);
9305
10248
  }
9306
10249
  this.syncViews();
9307
- if (_optionalChain([options, 'optionalAccess', _213 => _213.layerIds])) {
10250
+ if (_optionalChain([options, 'optionalAccess', _231 => _231.layerIds])) {
9308
10251
  const keep = new Set(options.layerIds);
9309
- const layers = _chunkT6H3JDGAcjs.flattenLayers.call(void 0, this.state.layers).filter((l) => keep.has(l.id));
10252
+ const layers = _chunk4AB5BHYKcjs.flattenLayers.call(void 0, this.state.layers).filter((l) => keep.has(l.id));
9310
10253
  return this.renderer.renderExport(source, { ...this.state, layers }, options);
9311
10254
  }
9312
10255
  return this.renderer.renderExport(source, this.state, options);
@@ -9416,10 +10359,10 @@ var ImageEditorController = (_class7 = class {
9416
10359
  /** No source image, and no layer reading one (an opened PSD): the layers are the whole document. */
9417
10360
  isSourceless() {
9418
10361
  if (this.imageElement || this.state.sourceUrl || !this.state.layers.length) return false;
9419
- return !_chunkT6H3JDGAcjs.flattenLayers.call(void 0, this.state.layers).some((l) => l.type === "pixel" && l.source === "document");
10362
+ return !_chunk4AB5BHYKcjs.flattenLayers.call(void 0, this.state.layers).some((l) => l.type === "pixel" && l.source === "document");
9420
10363
  }
9421
10364
  get isMultiLayer() {
9422
- return _chunkT6H3JDGAcjs.flattenLayers.call(void 0, this.state.layers).filter((l) => l.type === "pixel" || l.type === "group").length > 1;
10365
+ return _chunk4AB5BHYKcjs.flattenLayers.call(void 0, this.state.layers).filter((l) => l.type === "pixel" || l.type === "group").length > 1;
9423
10366
  }
9424
10367
  /**
9425
10368
  * Applies an inpainted result (natural image space, see `toSourceDataURL`) as ONE undoable step.
@@ -9434,10 +10377,10 @@ var ImageEditorController = (_class7 = class {
9434
10377
  return;
9435
10378
  }
9436
10379
  const { width, height } = this.naturalSize;
9437
- let px = await this.decodeImage(newDataUrl);
9438
- if (px.width !== width || px.height !== height) px = resizePixels(px, width, height);
9439
- const data = new Uint8ClampedArray(px.data);
9440
- const sel = _optionalChain([this, 'access', _214 => _214.state, 'access', _215 => _215.selection, 'optionalAccess', _216 => _216.bounds]) ? this.state.selection : null;
10380
+ let px2 = await this.decodeImage(newDataUrl);
10381
+ if (px2.width !== width || px2.height !== height) px2 = resizePixels(px2, width, height);
10382
+ const data = new Uint8ClampedArray(px2.data);
10383
+ const sel = _optionalChain([this, 'access', _232 => _232.state, 'access', _233 => _233.selection, 'optionalAccess', _234 => _234.bounds]) ? this.state.selection : null;
9441
10384
  if (sel) for (let p = 0, i = 3; p < width * height; p++, i += 4) data[i] = Math.round(data[i] * sel.data[p] / 255);
9442
10385
  return this.addPixelLayer({ name: "Inpaint", pixels: { width, height, data } });
9443
10386
  }
@@ -9457,10 +10400,10 @@ var ImageEditorController = (_class7 = class {
9457
10400
  if (!target) throw new LayerOperationError("There is no pixel layer to mask.");
9458
10401
  requireUnlocked(target, "all", "mask it");
9459
10402
  const { width, height } = this.naturalSize;
9460
- let px = await this.decodeImage(newDataUrl);
9461
- if (px.width !== width || px.height !== height) px = resizePixels(px, width, height);
10403
+ let px2 = await this.decodeImage(newDataUrl);
10404
+ if (px2.width !== width || px2.height !== height) px2 = resizePixels(px2, width, height);
9462
10405
  const alpha = new Uint8ClampedArray(width * height);
9463
- for (let p = 0; p < alpha.length; p++) alpha[p] = px.data[p * 4 + 3];
10406
+ for (let p = 0; p < alpha.length; p++) alpha[p] = px2.data[p * 4 + 3];
9464
10407
  let surface = _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width, height, data: alpha }, 1, 0, 0, 0);
9465
10408
  if (target.offset.x || target.offset.y) surface = _chunkCRMAXIUVcjs.translateSurface.call(void 0, surface, -target.offset.x, -target.offset.y);
9466
10409
  this.commitLayers(setLayerMask(this.state.layers, target.id, { surface, defaultValue: 0 }));
@@ -9489,7 +10432,7 @@ var ImageEditorController = (_class7 = class {
9489
10432
  if (layer.locks) next.locks = layer.locks;
9490
10433
  if (this.state.selectedAnnotationId === layer.annotation.id) this.state.selectedAnnotationId = null;
9491
10434
  } else if (layer.type === "pixel") {
9492
- if (!_optionalChain([layer, 'access', _217 => _217.filters, 'optionalAccess', _218 => _218.length])) throw new LayerOperationError(`Layer "${layer.name || id}" is already pixels with no filters to bake.`);
10435
+ if (!_optionalChain([layer, 'access', _235 => _235.filters, 'optionalAccess', _236 => _236.length])) throw new LayerOperationError(`Layer "${layer.name || id}" is already pixels with no filters to bake.`);
9493
10436
  requireUnlocked(layer, "pixels", "rasterize it");
9494
10437
  const spatial = layer.filters.some((f) => f.enabled && f.kind === "blur");
9495
10438
  const content = { ...layer, visible: true, opacity: 1, blend: "normal" };
@@ -9507,7 +10450,7 @@ var ImageEditorController = (_class7 = class {
9507
10450
  } else {
9508
10451
  throw new LayerOperationError(`Only annotation layers and pixel layers with filters rasterize; "${layer.name || id}" is a ${layer.type} layer. Merge it down or flatten instead.`);
9509
10452
  }
9510
- this.commitLayers(_chunkT6H3JDGAcjs.mapLayer.call(void 0, this.state.layers, id, () => next));
10453
+ this.commitLayers(_chunk4AB5BHYKcjs.mapLayer.call(void 0, this.state.layers, id, () => next));
9511
10454
  return id;
9512
10455
  }
9513
10456
  // --- PSD ---
@@ -9534,14 +10477,18 @@ var ImageEditorController = (_class7 = class {
9534
10477
  delete s.legacyOutputBlur;
9535
10478
  s.selection = null;
9536
10479
  s.selectedAnnotationId = null;
9537
- const pixels = _chunkT6H3JDGAcjs.flattenLayers.call(void 0, result.layers).filter((l) => l.type === "pixel");
10480
+ const pixels = _chunk4AB5BHYKcjs.flattenLayers.call(void 0, result.layers).filter((l) => l.type === "pixel");
9538
10481
  s.activeLayerId = pixels.length ? pixels[pixels.length - 1].id : null;
9539
10482
  s.activeTarget = "pixels";
9540
10483
  this.psdResolution = result.resolution;
10484
+ if (result.patterns.length) s.patterns = result.patterns;
10485
+ else delete s.patterns;
10486
+ if (result.globalLight) s.globalLight = result.globalLight;
10487
+ else delete s.globalLight;
9541
10488
  this.lastLoadProblems = result.warnings;
9542
10489
  this.notify();
9543
10490
  return {
9544
- layerIds: _chunkT6H3JDGAcjs.flattenLayers.call(void 0, result.layers).map((l) => l.id),
10491
+ layerIds: _chunk4AB5BHYKcjs.flattenLayers.call(void 0, result.layers).map((l) => l.id),
9545
10492
  warnings: result.warnings,
9546
10493
  width: result.width,
9547
10494
  height: result.height,
@@ -9566,7 +10513,7 @@ var ImageEditorController = (_class7 = class {
9566
10513
  const compositor = new LayerCompositor();
9567
10514
  const bakeMask = (layer) => {
9568
10515
  const mask = layer.mask;
9569
- if (!_optionalChain([mask, 'optionalAccess', _219 => _219.source])) return mask;
10516
+ if (!_optionalChain([mask, 'optionalAccess', _237 => _237.source])) return mask;
9570
10517
  add("Parametric (depth) masks were baked into pixel masks", layer.name);
9571
10518
  const plain3 = { ...layer, mask: { ...mask, density: 1, feather: 0, enabled: true } };
9572
10519
  const ox = layer.type === "pixel" ? layer.offset.x : 0;
@@ -9583,7 +10530,7 @@ var ImageEditorController = (_class7 = class {
9583
10530
  };
9584
10531
  const prepare = async (layer) => {
9585
10532
  const p = await prepareLayer(layer);
9586
- if (_optionalChain([p, 'optionalAccess', _220 => _220.blend]) === "pigment") add("The Pigment blend mode has no PSD equivalent and was written as Normal", layer.name);
10533
+ if (_optionalChain([p, 'optionalAccess', _238 => _238.blend]) === "pigment") add("The Pigment blend mode has no PSD equivalent and was written as Normal", layer.name);
9587
10534
  return p;
9588
10535
  };
9589
10536
  const prepareLayer = async (layer) => {
@@ -9606,6 +10553,7 @@ var ImageEditorController = (_class7 = class {
9606
10553
  const content = { ...layer, visible: true, opacity: 1, blend: "normal", annotation: { ...layer.annotation, blend: void 0 } };
9607
10554
  delete content.mask;
9608
10555
  delete content.clipped;
10556
+ delete content.effects;
9609
10557
  const data = compositor.composite([content], canvas, sources);
9610
10558
  const out2 = {
9611
10559
  type: "pixel",
@@ -9619,6 +10567,7 @@ var ImageEditorController = (_class7 = class {
9619
10567
  };
9620
10568
  if (layer.clipped) out2.clipped = true;
9621
10569
  if (layer.locks) out2.locks = layer.locks;
10570
+ if (layer.effects) out2.effects = layer.effects;
9622
10571
  const mask2 = bakeMask(layer);
9623
10572
  if (mask2) out2.mask = mask2;
9624
10573
  return out2;
@@ -9628,17 +10577,18 @@ var ImageEditorController = (_class7 = class {
9628
10577
  out.surface = this.surfaceOf(layer);
9629
10578
  delete out.source;
9630
10579
  }
9631
- const active = _nullishCoalesce(_optionalChain([layer, 'access', _221 => _221.filters, 'optionalAccess', _222 => _222.filter, 'call', _223 => _223(isActiveFilter)]), () => ( []));
10580
+ const active = _nullishCoalesce(_optionalChain([layer, 'access', _239 => _239.filters, 'optionalAccess', _240 => _240.filter, 'call', _241 => _241(isActiveFilter)]), () => ( []));
9632
10581
  if (active.length) {
9633
10582
  add("Layer filters (develop, blur) were baked into the pixels", layer.name);
9634
10583
  const content = { ...out, visible: true, opacity: 1, blend: "normal" };
9635
10584
  delete content.mask;
9636
10585
  delete content.clipped;
9637
10586
  delete content.fillOpacity;
10587
+ delete content.effects;
9638
10588
  const data = compositor.composite([content], canvas, sources);
9639
10589
  out = { ...out, surface: _chunkCRMAXIUVcjs.surfaceFromPixels.call(void 0, { width, height, data }, 4, -layer.offset.x, -layer.offset.y) };
9640
10590
  }
9641
- if (_optionalChain([layer, 'access', _224 => _224.filters, 'optionalAccess', _225 => _225.some, 'call', _226 => _226((f) => !f.enabled)])) add("Disabled layer filters were left out", layer.name);
10591
+ if (_optionalChain([layer, 'access', _242 => _242.filters, 'optionalAccess', _243 => _243.some, 'call', _244 => _244((f) => !f.enabled)])) add("Disabled layer filters were left out", layer.name);
9642
10592
  delete out.filters;
9643
10593
  const mask = bakeMask(layer);
9644
10594
  if (mask) out.mask = mask;
@@ -9657,7 +10607,8 @@ var ImageEditorController = (_class7 = class {
9657
10607
  if (s.legacyOutputBlur) warnings.push("The document-level blur of an old document is not written.");
9658
10608
  for (const [msg, names] of note) warnings.push(`${msg} (${names.length === 1 ? "layer" : "layers"} ${names.map((n) => `"${n}"`).join(", ")}).`);
9659
10609
  const merged = compositor.composite(prepared, canvas, { ...sources, version: `psd:${Date.now()}` });
9660
- const result = exportPsd({ width, height, layers: prepared, merged, resolution: this.psdResolution });
10610
+ const result = exportPsd({ width, height, layers: prepared, merged, resolution: this.psdResolution, patterns: this.state.patterns, globalLight: this.state.globalLight });
10611
+ warnings.push(...result.warnings);
9661
10612
  return { bytes: result.bytes, warnings, psb: result.psb, width, height };
9662
10613
  }
9663
10614
  async replaceSource(src, clearAnnotations) {
@@ -9690,16 +10641,16 @@ var ImageEditorController = (_class7 = class {
9690
10641
  );
9691
10642
  }
9692
10643
  layers = resizeLegacyMasks(layers, prev, next.dimensions);
9693
- for (const l of _chunkT6H3JDGAcjs.flattenLayers.call(void 0, layers)) {
10644
+ for (const l of _chunk4AB5BHYKcjs.flattenLayers.call(void 0, layers)) {
9694
10645
  if (l.type === "annotation") {
9695
- layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, l.id, () => ({ ...l, annotation: scaleAnnotation(l.annotation, sx, sy) }));
10646
+ layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, l.id, () => ({ ...l, annotation: scaleAnnotation(l.annotation, sx, sy) }));
9696
10647
  }
9697
10648
  }
9698
10649
  }
9699
10650
  const bg = developTarget(layers, null);
9700
- if (bg && bg.source !== "document") layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, bg.id, () => ({ ...bg, source: "document" }));
10651
+ if (bg && bg.source !== "document") layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, bg.id, () => ({ ...bg, source: "document" }));
9701
10652
  if (clearAnnotations) {
9702
- for (const l of _chunkT6H3JDGAcjs.flattenLayers.call(void 0, layers)) if (l.type === "annotation") layers = _chunkT6H3JDGAcjs.mapLayer.call(void 0, layers, l.id, () => null);
10653
+ for (const l of _chunk4AB5BHYKcjs.flattenLayers.call(void 0, layers)) if (l.type === "annotation") layers = _chunk4AB5BHYKcjs.mapLayer.call(void 0, layers, l.id, () => null);
9703
10654
  this.state.selectedAnnotationId = null;
9704
10655
  }
9705
10656
  this.state.layers = layers;
@@ -9707,7 +10658,7 @@ var ImageEditorController = (_class7 = class {
9707
10658
  }
9708
10659
  toJSON(options) {
9709
10660
  const out = this.serializeState();
9710
- if (_optionalChain([this, 'access', _227 => _227.state, 'access', _228 => _228.selection, 'optionalAccess', _229 => _229.bounds])) out.selection = serializeSelection(this.state.selection);
10661
+ if (_optionalChain([this, 'access', _245 => _245.state, 'access', _246 => _246.selection, 'optionalAccess', _247 => _247.bounds])) out.selection = serializeSelection(this.state.selection);
9711
10662
  if (!options || out.version !== LAYERED_SCHEMA_VERSION) return options ? Promise.resolve(out) : out;
9712
10663
  return serializeLayersExternal(this.state.layers, options.store).then(({ layers, assets }) => ({ ...out, layers, assets }));
9713
10664
  }
@@ -9734,7 +10685,7 @@ var ImageEditorController = (_class7 = class {
9734
10685
  if (data.selection) {
9735
10686
  try {
9736
10687
  selection = normalizeSelection(deserializeSelection(data.selection));
9737
- } catch (e25) {
10688
+ } catch (e27) {
9738
10689
  selection = null;
9739
10690
  }
9740
10691
  }
@@ -9743,7 +10694,7 @@ var ImageEditorController = (_class7 = class {
9743
10694
  this.notify();
9744
10695
  }
9745
10696
  /** Problems found by the last `loadJSON` / `initialState` of a v3 document (unreadable layers or assets). */
9746
- __init51() {this.lastLoadProblems = []}
10697
+ __init52() {this.lastLoadProblems = []}
9747
10698
  applyStored(raw) {
9748
10699
  const s = this.state;
9749
10700
  const data = migrateSerializedImageEditorState(raw);
@@ -9757,10 +10708,13 @@ var ImageEditorController = (_class7 = class {
9757
10708
  s.outputOpacity = data.opacity;
9758
10709
  if (typeof data.legacyOutputBlur === "number" && data.legacyOutputBlur >= 0) s.legacyOutputBlur = data.legacyOutputBlur;
9759
10710
  else delete s.legacyOutputBlur;
9760
- s.activeLayerId = data.activeLayerId && _chunkT6H3JDGAcjs.findLayer.call(void 0, s.layers, data.activeLayerId) ? data.activeLayerId : null;
10711
+ s.activeLayerId = data.activeLayerId && _chunk4AB5BHYKcjs.findLayer.call(void 0, s.layers, data.activeLayerId) ? data.activeLayerId : null;
9761
10712
  const light = data.globalLight;
9762
10713
  if (light && Number.isFinite(light.angle) && Number.isFinite(light.altitude)) s.globalLight = { angle: light.angle, altitude: Math.min(90, Math.max(0, light.altitude)) };
9763
10714
  else delete s.globalLight;
10715
+ const patterns = deserializePatterns(data.patterns, problems);
10716
+ if (patterns.length) s.patterns = patterns;
10717
+ else delete s.patterns;
9764
10718
  if (!this.imageElement && typeof data.width === "number" && typeof data.height === "number" && data.width > 0 && data.height > 0) {
9765
10719
  s.imageDimensions = { width: data.width, height: data.height };
9766
10720
  }
@@ -9775,6 +10729,7 @@ var ImageEditorController = (_class7 = class {
9775
10729
  s.transform = { ...data.transform };
9776
10730
  s.activeLayerId = null;
9777
10731
  delete s.globalLight;
10732
+ delete s.patterns;
9778
10733
  }
9779
10734
  s.activeTarget = "pixels";
9780
10735
  this.viewKey = [];
@@ -9784,10 +10739,10 @@ var ImageEditorController = (_class7 = class {
9784
10739
  serializeState() {
9785
10740
  const { width, height } = this.naturalSize;
9786
10741
  const view = legacyView(this.stack(), width, height, null);
9787
- if (view.exact && !this.state.globalLight) {
10742
+ if (view.exact && !this.state.globalLight && !_optionalChain([this, 'access', _248 => _248.state, 'access', _249 => _249.patterns, 'optionalAccess', _250 => _250.length])) {
9788
10743
  return {
9789
10744
  // States without adjustment layers keep schema 1, so they round-trip unchanged.
9790
- version: _optionalChain([view, 'access', _230 => _230.adjustments, 'access', _231 => _231.layers, 'optionalAccess', _232 => _232.length]) ? 2 : 1,
10745
+ version: _optionalChain([view, 'access', _251 => _251.adjustments, 'access', _252 => _252.layers, 'optionalAccess', _253 => _253.length]) ? 2 : 1,
9791
10746
  crop: this.state.crop ? { ...this.state.crop } : null,
9792
10747
  transform: { ...this.state.transform },
9793
10748
  adjustments: serializeAdjustments(view.adjustments),
@@ -9812,12 +10767,13 @@ var ImageEditorController = (_class7 = class {
9812
10767
  };
9813
10768
  if (this.state.legacyOutputBlur !== void 0) out.legacyOutputBlur = this.state.legacyOutputBlur;
9814
10769
  if (this.state.globalLight) out.globalLight = { ...this.state.globalLight };
10770
+ if (_optionalChain([this, 'access', _254 => _254.state, 'access', _255 => _255.patterns, 'optionalAccess', _256 => _256.length])) out.patterns = serializePatterns(this.state.patterns);
9815
10771
  return out;
9816
10772
  }
9817
10773
  }, _class7);
9818
10774
  function serializeAdjustments(adjustments) {
9819
10775
  const out = { ...adjustments };
9820
- if (_optionalChain([out, 'access', _233 => _233.layers, 'optionalAccess', _234 => _234.length])) out.layers = JSON.parse(JSON.stringify(out.layers));
10776
+ if (_optionalChain([out, 'access', _257 => _257.layers, 'optionalAccess', _258 => _258.length])) out.layers = JSON.parse(JSON.stringify(out.layers));
9821
10777
  else delete out.layers;
9822
10778
  if (normalizeProcessVersion(out.process) === LEGACY_PROCESS_VERSION) {
9823
10779
  delete out.process;
@@ -9853,11 +10809,11 @@ function withDevelop(layer, partial) {
9853
10809
  return { ...layer, filters };
9854
10810
  }
9855
10811
  function withBlur(layer, radius) {
9856
- const existing = _optionalChain([layer, 'access', _235 => _235.filters, 'optionalAccess', _236 => _236.find, 'call', _237 => _237((f) => f.kind === "blur")]);
10812
+ const existing = _optionalChain([layer, 'access', _259 => _259.filters, 'optionalAccess', _260 => _260.find, 'call', _261 => _261((f) => f.kind === "blur")]);
9857
10813
  const filters = (_nullishCoalesce(layer.filters, () => ( []))).filter((f) => f.kind !== "blur");
9858
10814
  if (radius > 0) {
9859
10815
  filters.push({
9860
- id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _238 => _238.id]), () => ( (layer.source === "document" ? BLUR_FILTER_ID : newLayerId("flt")))),
10816
+ id: _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _262 => _262.id]), () => ( (layer.source === "document" ? BLUR_FILTER_ID : newLayerId("flt")))),
9861
10817
  kind: "blur",
9862
10818
  enabled: true,
9863
10819
  radius
@@ -9921,12 +10877,12 @@ function resizeLegacyMasks(layers, from, to) {
9921
10877
  const th = Math.max(1, Math.round(to.height));
9922
10878
  if (fw === tw && fh === th) return layers;
9923
10879
  let out = layers;
9924
- for (const l of _chunkT6H3JDGAcjs.flattenLayers.call(void 0, layers)) {
10880
+ for (const l of _chunk4AB5BHYKcjs.flattenLayers.call(void 0, layers)) {
9925
10881
  if (l.type !== "adjustment" || !l.mask || l.mask.source) continue;
9926
10882
  const old = l.mask;
9927
10883
  const mask = rasterMaskFromLegacy(legacyMaskOf(old, fw, fh), tw, th);
9928
10884
  if (!mask) continue;
9929
- out = _chunkT6H3JDGAcjs.mapLayer.call(void 0, out, l.id, (n) => ({ ...n, mask: { ...mask, density: old.density, feather: old.feather, enabled: old.enabled } }));
10885
+ out = _chunk4AB5BHYKcjs.mapLayer.call(void 0, out, l.id, (n) => ({ ...n, mask: { ...mask, density: old.density, feather: old.feather, enabled: old.enabled } }));
9930
10886
  }
9931
10887
  return out;
9932
10888
  }
@@ -9939,7 +10895,7 @@ function isOpaqueInside(surface, width, height) {
9939
10895
  return true;
9940
10896
  }
9941
10897
  function collectStateTiles(layers, into) {
9942
- for (const l of _chunkT6H3JDGAcjs.flattenLayers.call(void 0, layers)) {
10898
+ for (const l of _chunk4AB5BHYKcjs.flattenLayers.call(void 0, layers)) {
9943
10899
  if (l.type === "pixel" && l.source !== "document") _chunkCRMAXIUVcjs.collectTiles.call(void 0, l.surface, into);
9944
10900
  if (l.mask && !l.mask.source) _chunkCRMAXIUVcjs.collectTiles.call(void 0, l.mask.surface, into);
9945
10901
  }
@@ -9949,7 +10905,7 @@ function pixelsOnly(layers) {
9949
10905
  for (const l of layers) {
9950
10906
  if (l.type === "adjustment") continue;
9951
10907
  if (l.type === "group") out.push({ ...l, children: pixelsOnly(l.children) });
9952
- else if (l.type === "pixel" && _optionalChain([l, 'access', _239 => _239.filters, 'optionalAccess', _240 => _240.length])) {
10908
+ else if (l.type === "pixel" && _optionalChain([l, 'access', _263 => _263.filters, 'optionalAccess', _264 => _264.length])) {
9953
10909
  const p = { ...l };
9954
10910
  delete p.filters;
9955
10911
  out.push(p);
@@ -9957,24 +10913,24 @@ function pixelsOnly(layers) {
9957
10913
  }
9958
10914
  return out;
9959
10915
  }
9960
- function resizePixels(px, width, height) {
9961
- const src = px.data;
10916
+ function resizePixels(px2, width, height) {
10917
+ const src = px2.data;
9962
10918
  const out = new Uint8ClampedArray(width * height * 4);
9963
- const kx = px.width / width;
9964
- const ky = px.height / height;
10919
+ const kx = px2.width / width;
10920
+ const ky = px2.height / height;
9965
10921
  for (let y = 0; y < height; y++) {
9966
- const fy = Math.min(px.height - 1, Math.max(0, (y + 0.5) * ky - 0.5));
10922
+ const fy = Math.min(px2.height - 1, Math.max(0, (y + 0.5) * ky - 0.5));
9967
10923
  const y0 = Math.floor(fy);
9968
- const y1 = Math.min(px.height - 1, y0 + 1);
10924
+ const y1 = Math.min(px2.height - 1, y0 + 1);
9969
10925
  const ty = fy - y0;
9970
10926
  for (let x = 0; x < width; x++) {
9971
- const fx = Math.min(px.width - 1, Math.max(0, (x + 0.5) * kx - 0.5));
10927
+ const fx = Math.min(px2.width - 1, Math.max(0, (x + 0.5) * kx - 0.5));
9972
10928
  const x0 = Math.floor(fx);
9973
- const x1 = Math.min(px.width - 1, x0 + 1);
10929
+ const x1 = Math.min(px2.width - 1, x0 + 1);
9974
10930
  const tx = fx - x0;
9975
10931
  for (let c = 0; c < 4; c++) {
9976
- const a = src[(y0 * px.width + x0) * 4 + c] * (1 - tx) + src[(y0 * px.width + x1) * 4 + c] * tx;
9977
- const b = src[(y1 * px.width + x0) * 4 + c] * (1 - tx) + src[(y1 * px.width + x1) * 4 + c] * tx;
10932
+ const a = src[(y0 * px2.width + x0) * 4 + c] * (1 - tx) + src[(y0 * px2.width + x1) * 4 + c] * tx;
10933
+ const b = src[(y1 * px2.width + x0) * 4 + c] * (1 - tx) + src[(y1 * px2.width + x1) * 4 + c] * tx;
9978
10934
  out[(y * width + x) * 4 + c] = a * (1 - ty) + b * ty;
9979
10935
  }
9980
10936
  }
@@ -10007,7 +10963,7 @@ function toHex2(c) {
10007
10963
  return "#" + [c[0], c[1], c[2]].map((v) => Math.round(v).toString(16).padStart(2, "0")).join("");
10008
10964
  }
10009
10965
  function normalizeSelection(mask) {
10010
- return _optionalChain([mask, 'optionalAccess', _241 => _241.bounds]) ? mask : null;
10966
+ return _optionalChain([mask, 'optionalAccess', _265 => _265.bounds]) ? mask : null;
10011
10967
  }
10012
10968
  function sameSelection(a, b) {
10013
10969
  if (a.width !== b.width || a.height !== b.height) return false;
@@ -10112,7 +11068,7 @@ function loadImageEditorDocument(input) {
10112
11068
  if (typeof input === "string") {
10113
11069
  try {
10114
11070
  parsed = JSON.parse(input);
10115
- } catch (e26) {
11071
+ } catch (e28) {
10116
11072
  parsed = input;
10117
11073
  }
10118
11074
  }
@@ -10168,7 +11124,7 @@ function loadImageEditorDocument(input) {
10168
11124
  }
10169
11125
  const state = { version: 1, ...result.value };
10170
11126
  if (isV2) {
10171
- if (_optionalChain([state, 'access', _242 => _242.adjustments, 'access', _243 => _243.layers, 'optionalAccess', _244 => _244.length])) state.version = 2;
11127
+ if (_optionalChain([state, 'access', _266 => _266.adjustments, 'access', _267 => _267.layers, 'optionalAccess', _268 => _268.length])) state.version = 2;
10172
11128
  result.report.version = 2;
10173
11129
  }
10174
11130
  if (state.selection === void 0) delete state.selection;
@@ -10368,7 +11324,7 @@ function findAdjustmentControl(id) {
10368
11324
  }
10369
11325
  function findLayerControl(kind, id) {
10370
11326
  if (id === "opacity") return ADJUSTMENT_LAYER_OPACITY_CONTROL;
10371
- return _optionalChain([ADJUSTMENT_LAYER_CONTROLS, 'access', _245 => _245[kind], 'optionalAccess', _246 => _246.find, 'call', _247 => _247((c) => c.id === id)]);
11327
+ return _optionalChain([ADJUSTMENT_LAYER_CONTROLS, 'access', _269 => _269[kind], 'optionalAccess', _270 => _270.find, 'call', _271 => _271((c) => c.id === id)]);
10372
11328
  }
10373
11329
  function clampControlValue(spec, v) {
10374
11330
  if (typeof v !== "number" || !Number.isFinite(v)) return spec.default;
@@ -10401,17 +11357,17 @@ function controlTrackBackground(spec) {
10401
11357
  return void 0;
10402
11358
  }
10403
11359
  }
10404
- function getControlPath(obj, path) {
10405
- let cur = obj;
11360
+ function getControlPath(obj2, path) {
11361
+ let cur = obj2;
10406
11362
  for (const part of path.split(".")) {
10407
11363
  if (cur === null || cur === void 0) return void 0;
10408
11364
  cur = cur[part];
10409
11365
  }
10410
11366
  return cur;
10411
11367
  }
10412
- function setControlPath(obj, path, value) {
11368
+ function setControlPath(obj2, path, value) {
10413
11369
  const parts = path.split(".");
10414
- const root = Array.isArray(obj) ? [...obj] : { ...obj };
11370
+ const root = Array.isArray(obj2) ? [...obj2] : { ...obj2 };
10415
11371
  let cur = root;
10416
11372
  for (let i = 0; i < parts.length - 1; i++) {
10417
11373
  const next = cur[parts[i]];
@@ -10469,8 +11425,8 @@ function describeSelection(mask) {
10469
11425
  if (!mask || !mask.bounds) return "No selection";
10470
11426
  let sum = 0;
10471
11427
  for (let i = 0; i < mask.data.length; i++) sum += mask.data[i];
10472
- const pct = sum / 255 / mask.data.length * 100;
10473
- const shown = pct >= 10 ? Math.round(pct) : Math.round(pct * 10) / 10;
11428
+ const pct3 = sum / 255 / mask.data.length * 100;
11429
+ const shown = pct3 >= 10 ? Math.round(pct3) : Math.round(pct3 * 10) / 10;
10474
11430
  return `${mask.bounds.width} \xD7 ${mask.bounds.height} px selected (${shown}% of the image)`;
10475
11431
  }
10476
11432
 
@@ -10480,14 +11436,14 @@ var modeSchema = {
10480
11436
  enum: [...SELECTION_MODES],
10481
11437
  description: "How the result combines with the current selection (default replace)."
10482
11438
  };
10483
- var num2 = (v, d) => typeof v === "number" && Number.isFinite(v) ? v : d;
11439
+ var num3 = (v, d) => typeof v === "number" && Number.isFinite(v) ? v : d;
10484
11440
  function summary(controller) {
10485
11441
  const sel = controller.getSelection();
10486
11442
  const { width, height } = controller.getState().imageDimensions;
10487
11443
  const area = selectionArea(sel);
10488
11444
  return {
10489
11445
  empty: !sel,
10490
- bounds: _nullishCoalesce(_optionalChain([sel, 'optionalAccess', _248 => _248.bounds]), () => ( null)),
11446
+ bounds: _nullishCoalesce(_optionalChain([sel, 'optionalAccess', _272 => _272.bounds]), () => ( null)),
10491
11447
  /** Σ coverage in pixels. */
10492
11448
  area: Math.round(area),
10493
11449
  percent: Math.round(area / Math.max(1, width * height) * 1e4) / 100,
@@ -10530,7 +11486,7 @@ function createImageSelectionTools(controller) {
10530
11486
  },
10531
11487
  annotations: writeAnnotations("Select a region", true),
10532
11488
  handler: ({ shape, x, y, width, height, mode, feather }) => {
10533
- const opts = { mode: parseSelectionMode(mode), feather: num2(feather, 0) };
11489
+ const opts = { mode: parseSelectionMode(mode), feather: num3(feather, 0) };
10534
11490
  switch (shape) {
10535
11491
  case "all":
10536
11492
  controller.selectAll();
@@ -10543,7 +11499,7 @@ function createImageSelectionTools(controller) {
10543
11499
  break;
10544
11500
  case "rect":
10545
11501
  case "ellipse": {
10546
- const rect = { x: num2(x, NaN), y: num2(y, NaN), width: num2(width, NaN), height: num2(height, NaN) };
11502
+ const rect = { x: num3(x, NaN), y: num3(y, NaN), width: num3(width, NaN), height: num3(height, NaN) };
10547
11503
  if (![rect.x, rect.y, rect.width, rect.height].every(Number.isFinite)) {
10548
11504
  throw new Error("rect and ellipse need numeric x, y, width and height.");
10549
11505
  }
@@ -10582,15 +11538,15 @@ function createImageSelectionTools(controller) {
10582
11538
  },
10583
11539
  annotations: writeAnnotations("Select by colour", true),
10584
11540
  handler: async ({ x, y, color, tolerance, contiguous, fuzziness, sampleMerged, sample, mode }) => {
10585
- const common = {
11541
+ const common2 = {
10586
11542
  mode: parseSelectionMode(mode),
10587
11543
  sampleMerged: sampleMerged === true,
10588
11544
  sample: _nullishCoalesce(sample, () => ( "composite"))
10589
11545
  };
10590
11546
  if (typeof color === "string") {
10591
- await controller.selectColorRange([{ color }], { ...common, fuzziness: num2(fuzziness, 40) });
11547
+ await controller.selectColorRange([{ color }], { ...common2, fuzziness: num3(fuzziness, 40) });
10592
11548
  } else if (typeof x === "number" && typeof y === "number") {
10593
- await controller.magicWand({ x, y }, { ...common, tolerance: num2(tolerance, 32), contiguous: contiguous !== false });
11549
+ await controller.magicWand({ x, y }, { ...common2, tolerance: num3(tolerance, 32), contiguous: contiguous !== false });
10594
11550
  } else {
10595
11551
  throw new Error("Pass x and y (magic wand) or color (#rrggbb).");
10596
11552
  }
@@ -10614,7 +11570,7 @@ function createImageSelectionTools(controller) {
10614
11570
  handler: ({ op, radius }) => {
10615
11571
  if (!SELECTION_MODIFY_OPS.includes(op)) throw new Error(`Unknown op "${String(op)}".`);
10616
11572
  if (!controller.getSelection()) throw new Error("Nothing is selected.");
10617
- controller.modifySelection(op, Math.min(500, Math.max(0, num2(radius, 0))));
11573
+ controller.modifySelection(op, Math.min(500, Math.max(0, num3(radius, 0))));
10618
11574
  return summary(controller);
10619
11575
  }
10620
11576
  };
@@ -10638,12 +11594,12 @@ function createImageSelectionTools(controller) {
10638
11594
  handler: async (params) => {
10639
11595
  if (!controller.getSelection()) throw new Error("Nothing is selected.");
10640
11596
  await controller.refineSelection({
10641
- radius: num2(params.radius, 8),
11597
+ radius: num3(params.radius, 8),
10642
11598
  smartRadius: params.smartRadius === true,
10643
- smooth: num2(params.smooth, 0),
10644
- feather: num2(params.feather, 0),
10645
- contrast: num2(params.contrast, 0),
10646
- shiftEdge: num2(params.shiftEdge, 0)
11599
+ smooth: num3(params.smooth, 0),
11600
+ feather: num3(params.feather, 0),
11601
+ contrast: num3(params.contrast, 0),
11602
+ shiftEdge: num3(params.shiftEdge, 0)
10647
11603
  });
10648
11604
  return summary(controller);
10649
11605
  }
@@ -10731,7 +11687,7 @@ async function renderImageRegion(controller, request) {
10731
11687
  if (request.includeOverlays) {
10732
11688
  const s = request.scale;
10733
11689
  const selection = state.selection;
10734
- if (_optionalChain([selection, 'optionalAccess', _249 => _249.bounds]) && selection.width === state.imageDimensions.width && selection.height === state.imageDimensions.height) {
11690
+ if (_optionalChain([selection, 'optionalAccess', _273 => _273.bounds]) && selection.width === state.imageDimensions.width && selection.height === state.imageDimensions.height) {
10735
11691
  const shade = selectionShade(selection, document);
10736
11692
  if (shade) context.drawImage(shade, rect.x, rect.y, rect.width, rect.height, 0, 0, out.width, out.height);
10737
11693
  }
@@ -10756,7 +11712,7 @@ function createImageCaptureSurface(controller) {
10756
11712
  return {
10757
11713
  units: "image pixels",
10758
11714
  content: whole,
10759
- selection: () => ({ rect: _nullishCoalesce(_optionalChain([controller, 'access', _250 => _250.getState, 'call', _251 => _251(), 'access', _252 => _252.selection, 'optionalAccess', _253 => _253.bounds]), () => ( null)) }),
11715
+ selection: () => ({ rect: _nullishCoalesce(_optionalChain([controller, 'access', _274 => _274.getState, 'call', _275 => _275(), 'access', _276 => _276.selection, 'optionalAccess', _277 => _277.bounds]), () => ( null)) }),
10760
11716
  overlays: "a shade over unselected pixels and the crop box outline",
10761
11717
  maxScale: 8,
10762
11718
  render: (request) => renderImageRegion(controller, request)
@@ -10790,14 +11746,14 @@ function rebin(bins, count) {
10790
11746
  return out;
10791
11747
  }
10792
11748
  function histogramSummary(h, bins) {
10793
- const pct = (n) => h.samples ? round(n / h.samples * 100) : 0;
11749
+ const pct3 = (n) => h.samples ? round(n / h.samples * 100) : 0;
10794
11750
  const channels = { red: h.red, green: h.green, blue: h.blue, luminance: h.luminance };
10795
11751
  return {
10796
11752
  samples: h.samples,
10797
11753
  transparent: h.transparent,
10798
11754
  clipping: {
10799
- shadowsPercent: { red: pct(h.shadows[0]), green: pct(h.shadows[1]), blue: pct(h.shadows[2]) },
10800
- highlightsPercent: { red: pct(h.highlights[0]), green: pct(h.highlights[1]), blue: pct(h.highlights[2]) }
11755
+ shadowsPercent: { red: pct3(h.shadows[0]), green: pct3(h.shadows[1]), blue: pct3(h.shadows[2]) },
11756
+ highlightsPercent: { red: pct3(h.highlights[0]), green: pct3(h.highlights[1]), blue: pct3(h.highlights[2]) }
10801
11757
  },
10802
11758
  stats: Object.fromEntries(Object.entries(channels).map(([k, v]) => [k, binStats(v, h.samples)])),
10803
11759
  ...bins ? { bins: Object.fromEntries(Object.entries(channels).map(([k, v]) => [k, rebin(v, bins)])) } : {}
@@ -11093,11 +12049,11 @@ function placementFrom(args) {
11093
12049
  function createImageLayerTools(controller) {
11094
12050
  const describe = (id) => {
11095
12051
  const s = controller.getState();
11096
- const loc = _chunkT6H3JDGAcjs.findLayer.call(void 0, s.layers, id);
12052
+ const loc = _chunk4AB5BHYKcjs.findLayer.call(void 0, s.layers, id);
11097
12053
  if (!loc) return null;
11098
12054
  return {
11099
12055
  ...describeLayer(loc.layer, s.activeLayerId, (x) => controller.getLayerBounds(x.id)),
11100
- parentId: _nullishCoalesce(_optionalChain([loc, 'access', _254 => _254.parent, 'optionalAccess', _255 => _255.id]), () => ( null)),
12056
+ parentId: _nullishCoalesce(_optionalChain([loc, 'access', _278 => _278.parent, 'optionalAccess', _279 => _279.id]), () => ( null)),
11101
12057
  index: loc.index
11102
12058
  };
11103
12059
  };
@@ -11552,7 +12508,7 @@ var WRITE_IDEMPOTENT3 = { readOnlyHint: false, destructiveHint: false, idempoten
11552
12508
  var DESTRUCTIVE2 = { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false };
11553
12509
  var LAYER_ID3 = { type: "string", description: "Layer id from list_layers (a pixel, annotation or group layer)." };
11554
12510
  var EFFECT_ID = { type: "string", description: "Effect id from list_layer_effects or add_layer_effect." };
11555
- var BLEND_IDS = _chunkCRMAXIUVcjs.BLEND_MODES.map((m) => m.id);
12511
+ var BLEND_IDS = _chunkCRMAXIUVcjs.BLEND_MODES.map((m) => m.id).filter((id) => id !== "pigment");
11556
12512
  var DEFS = {
11557
12513
  color: { type: "string", pattern: "^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$", description: "Colour as #rrggbb." },
11558
12514
  contour: {
@@ -11664,7 +12620,7 @@ var DEFS = {
11664
12620
  };
11665
12621
  var nullable = (schema, description) => ({ anyOf: [schema, { type: "null" }], description });
11666
12622
  function settingsSchema(forUpdate) {
11667
- const opt = (schema, description) => forUpdate ? nullable(schema, `${description} null removes it.`) : { ...schema, description };
12623
+ const opt2 = (schema, description) => forUpdate ? nullable(schema, `${description} null removes it.`) : { ...schema, description };
11668
12624
  return {
11669
12625
  type: "object",
11670
12626
  description: forUpdate ? "Settings to change (only these; nested objects are replaced whole). Which settings a kind takes: see add_layer_effect." : "Settings to change from Photoshop's defaults (all optional). Unknown settings for the kind are refused with the list of its settings.",
@@ -11679,7 +12635,7 @@ function settingsSchema(forUpdate) {
11679
12635
  spread: { type: "number", minimum: 0, maximum: 1, description: "drop-shadow, outer-glow: 0..1 of the size made solid (default 0)." },
11680
12636
  choke: { type: "number", minimum: 0, maximum: 1, description: "inner-shadow, inner-glow: 0..1 of the size made solid (default 0)." },
11681
12637
  size: { type: "number", minimum: 0, maximum: 250, description: "Shadows, glows, satin, bevel-emboss: blur / size in px (default 5; satin 14); stroke: width in px (default 3)." },
11682
- contour: opt({ $ref: "#/$defs/contour" }, "Shadows, glows, satin: coverage contour (default linear)."),
12638
+ contour: opt2({ $ref: "#/$defs/contour" }, "Shadows, glows, satin: coverage contour (default linear)."),
11683
12639
  antiAlias: { type: "boolean", description: "Shadows, glows, satin: smooth the contour (default false; satin true)." },
11684
12640
  noise: { type: "number", minimum: 0, maximum: 1, description: "Shadows, glows: speckle 0..1 (default 0)." },
11685
12641
  knocksOut: { type: "boolean", description: "drop-shadow: the layer hides the shadow beneath its see-through fill (default true)." },
@@ -11693,14 +12649,14 @@ function settingsSchema(forUpdate) {
11693
12649
  direction: { type: "string", enum: ["up", "down"], description: "bevel-emboss: raised (up, default) or sunk (down)." },
11694
12650
  soften: { type: "number", minimum: 0, maximum: 16, description: "bevel-emboss: blur of the height in px (default 0)." },
11695
12651
  altitude: { type: "number", minimum: 0, maximum: 90, description: "bevel-emboss: light altitude in degrees (default 30)." },
11696
- glossContour: opt({ $ref: "#/$defs/contour" }, "bevel-emboss: gloss contour over the shading (default linear)."),
12652
+ glossContour: opt2({ $ref: "#/$defs/contour" }, "bevel-emboss: gloss contour over the shading (default linear)."),
11697
12653
  highlightColor: { $ref: "#/$defs/color", description: "bevel-emboss: highlight colour (default #ffffff)." },
11698
12654
  highlightBlend: { type: "string", enum: BLEND_IDS, description: "bevel-emboss: highlight mode (default screen)." },
11699
12655
  highlightOpacity: { type: "number", minimum: 0, maximum: 1, description: "bevel-emboss: highlight opacity (default 0.75)." },
11700
12656
  shadowColor: { $ref: "#/$defs/color", description: "bevel-emboss: shadow colour (default #000000)." },
11701
12657
  shadowBlend: { type: "string", enum: BLEND_IDS, description: "bevel-emboss: shadow mode (default multiply)." },
11702
12658
  shadowOpacity: { type: "number", minimum: 0, maximum: 1, description: "bevel-emboss: shadow opacity (default 0.75)." },
11703
- contourElement: opt(
12659
+ contourElement: opt2(
11704
12660
  {
11705
12661
  type: "object",
11706
12662
  properties: {
@@ -11713,7 +12669,7 @@ function settingsSchema(forUpdate) {
11713
12669
  },
11714
12670
  "bevel-emboss: the Contour element, shaping the bevel's height profile (default off)."
11715
12671
  ),
11716
- texture: opt(
12672
+ texture: opt2(
11717
12673
  {
11718
12674
  type: "object",
11719
12675
  properties: {
@@ -11743,19 +12699,21 @@ function settingsSchema(forUpdate) {
11743
12699
  additionalProperties: false
11744
12700
  };
11745
12701
  }
11746
- function patternList() {
11747
- return _chunkT6H3JDGAcjs.builtinPatternIds.call(void 0, ).map((id) => {
11748
- const p = _chunkT6H3JDGAcjs.builtinPattern.call(void 0, id);
12702
+ function patternList(controller) {
12703
+ const doc = controller.getDocumentPatterns().map((p) => ({ id: p.id, name: p.name, width: p.width, height: p.height, builtin: false }));
12704
+ const builtins = _chunk4AB5BHYKcjs.builtinPatternIds.call(void 0, ).map((id) => {
12705
+ const p = _chunk4AB5BHYKcjs.builtinPattern.call(void 0, id);
11749
12706
  return { id, name: p.name, width: p.width, height: p.height, builtin: true };
11750
12707
  });
12708
+ return [...doc, ...builtins];
11751
12709
  }
11752
12710
  function describeLayerEffects(effects) {
11753
12711
  return {
11754
12712
  enabled: effects.enabled,
11755
12713
  scale: _nullishCoalesce(effects.scale, () => ( 1)),
11756
- margin: _chunkT6H3JDGAcjs.effectsMargin.call(void 0, effects),
12714
+ margin: _chunk4AB5BHYKcjs.effectsMargin.call(void 0, effects),
11757
12715
  fromPsd: Boolean(effects.psd),
11758
- effects: effects.items.map((e) => ({ ...JSON.parse(JSON.stringify(e)), label: _chunkT6H3JDGAcjs.layerEffectLabel.call(void 0, e.kind) }))
12716
+ effects: effects.items.map((e) => ({ ...JSON.parse(JSON.stringify(e)), label: _chunk4AB5BHYKcjs.layerEffectLabel.call(void 0, e.kind) }))
11759
12717
  };
11760
12718
  }
11761
12719
  function createImageEffectTools(controller) {
@@ -11765,13 +12723,13 @@ function createImageEffectTools(controller) {
11765
12723
  return id;
11766
12724
  };
11767
12725
  const result = (layerId, extra = {}) => ({ layerId, ...extra, ...describeLayerEffects(controller.getLayerEffects(layerId)) });
11768
- const list = {
12726
+ const list2 = {
11769
12727
  name: "list_layer_effects",
11770
12728
  title: "List layer effects",
11771
12729
  description: "Returns a layer's effects: the master switch (enabled), Scale Effects (scale, 1 = 100 %), margin (px the effects reach beyond the shape), whether they came from a PSD, and every effect with its id, kind, label and all settings. Also returns the document global light and the pattern ids pattern effects can use.",
11772
12730
  inputSchema: { type: "object", properties: { layerId: LAYER_ID3 }, required: ["layerId"], additionalProperties: false },
11773
12731
  annotations: { title: "List layer effects", ...READ3 },
11774
- handler: ({ layerId }) => result(layerArg(layerId), { globalLight: controller.getGlobalLight(), patterns: patternList(), kinds: [..._chunkT6H3JDGAcjs.LAYER_EFFECT_KINDS] })
12732
+ handler: ({ layerId }) => result(layerArg(layerId), { globalLight: controller.getGlobalLight(), patterns: patternList(controller), kinds: [..._chunk4AB5BHYKcjs.LAYER_EFFECT_KINDS] })
11775
12733
  };
11776
12734
  const add = {
11777
12735
  name: "add_layer_effect",
@@ -11782,7 +12740,7 @@ function createImageEffectTools(controller) {
11782
12740
  $defs: DEFS,
11783
12741
  properties: {
11784
12742
  layerId: LAYER_ID3,
11785
- kind: { type: "string", enum: [..._chunkT6H3JDGAcjs.LAYER_EFFECT_KINDS], description: "Effect kind." },
12743
+ kind: { type: "string", enum: [..._chunk4AB5BHYKcjs.LAYER_EFFECT_KINDS], description: "Effect kind." },
11786
12744
  settings: settingsSchema(false),
11787
12745
  index: { type: "integer", minimum: 0, description: "Position in the layer's effect list (default the end)." }
11788
12746
  },
@@ -11792,7 +12750,7 @@ function createImageEffectTools(controller) {
11792
12750
  annotations: { title: "Add a layer effect", ...WRITE3 },
11793
12751
  handler: ({ layerId, kind, settings, index }) => {
11794
12752
  const id = layerArg(layerId);
11795
- if (!_chunkT6H3JDGAcjs.isLayerEffectKind.call(void 0, kind)) throw new LayerOperationError(`kind must be one of ${_chunkT6H3JDGAcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
12753
+ if (!_chunk4AB5BHYKcjs.isLayerEffectKind.call(void 0, kind)) throw new LayerOperationError(`kind must be one of ${_chunk4AB5BHYKcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
11796
12754
  const { effect } = controller.addLayerEffect(id, kind, _nullishCoalesce(settings, () => ( {})), index);
11797
12755
  return result(id, { effectId: effect.id });
11798
12756
  }
@@ -11871,7 +12829,7 @@ function createImageEffectTools(controller) {
11871
12829
  return { globalLight: controller.setGlobalLight(next) };
11872
12830
  }
11873
12831
  };
11874
- return [list, add, update, remove, setEnabled, light];
12832
+ return [list2, add, update, remove, setEnabled, light];
11875
12833
  }
11876
12834
 
11877
12835
  // src/image-editor/layers/paint-ui.ts
@@ -11952,14 +12910,14 @@ function pointerPressure(e) {
11952
12910
  return 1;
11953
12911
  }
11954
12912
  var PaintGesture = (_class8 = class {
11955
- constructor(controller) {;_class8.prototype.__init52.call(this);_class8.prototype.__init53.call(this);_class8.prototype.__init54.call(this);
12913
+ constructor(controller) {;_class8.prototype.__init53.call(this);_class8.prototype.__init54.call(this);_class8.prototype.__init55.call(this);
11956
12914
  this.controller = controller;
11957
12915
  }
11958
12916
 
11959
- __init52() {this.stroke = null}
11960
- __init53() {this.move = null}
12917
+ __init53() {this.stroke = null}
12918
+ __init54() {this.move = null}
11961
12919
  /** The last refusal (e.g. "layer is locked"), for the editor to show. */
11962
- __init54() {this.error = null}
12920
+ __init55() {this.error = null}
11963
12921
  get active() {
11964
12922
  return Boolean(this.stroke || this.move);
11965
12923
  }
@@ -11971,7 +12929,7 @@ var PaintGesture = (_class8 = class {
11971
12929
  const layer = this.controller.getActiveLayer();
11972
12930
  if (!layer) throw new Error("Select a layer to move in the Layers panel.");
11973
12931
  if (layer.type !== "pixel") throw new Error(`Only pixel layers move; "${layer.name}" is a ${layer.type} layer.`);
11974
- if (_optionalChain([layer, 'access', _256 => _256.locks, 'optionalAccess', _257 => _257.all]) || _optionalChain([layer, 'access', _258 => _258.locks, 'optionalAccess', _259 => _259.position])) throw new Error(`Layer "${layer.name}" has its position locked.`);
12932
+ if (_optionalChain([layer, 'access', _280 => _280.locks, 'optionalAccess', _281 => _281.all]) || _optionalChain([layer, 'access', _282 => _282.locks, 'optionalAccess', _283 => _283.position])) throw new Error(`Layer "${layer.name}" has its position locked.`);
11975
12933
  this.move = { id: layer.id, start: { x: sample.x, y: sample.y }, origin: { ...layer.offset }, moved: false };
11976
12934
  return null;
11977
12935
  }
@@ -12020,7 +12978,7 @@ var PaintGesture = (_class8 = class {
12020
12978
  this.move = null;
12021
12979
  }
12022
12980
  cancel() {
12023
- _optionalChain([this, 'access', _260 => _260.stroke, 'optionalAccess', _261 => _261.cancel, 'call', _262 => _262()]);
12981
+ _optionalChain([this, 'access', _284 => _284.stroke, 'optionalAccess', _285 => _285.cancel, 'call', _286 => _286()]);
12024
12982
  this.stroke = null;
12025
12983
  this.move = null;
12026
12984
  }
@@ -12216,7 +13174,7 @@ function psdBytesFromBase64(data) {
12216
13174
  if (typeof data !== "string" || !data.trim()) throw new PsdError("data is required: the PSD file as base64.");
12217
13175
  const body = data.trim().replace(/^data:[^,]*;base64,/i, "");
12218
13176
  if (!/^[A-Za-z0-9+/=_\s-]+$/.test(body)) throw new PsdError("data is not base64; send the PSD file bytes base64-encoded.");
12219
- const bytes = _chunkT6H3JDGAcjs.base64ToBytes.call(void 0, body);
13177
+ const bytes = _chunk4AB5BHYKcjs.base64ToBytes.call(void 0, body);
12220
13178
  if (bytes.length < 26) throw new PsdError(`data decodes to ${bytes.length} bytes, too short for a PSD (at least 26).`);
12221
13179
  return bytes;
12222
13180
  }
@@ -12242,7 +13200,7 @@ function createImagePsdTools(controller) {
12242
13200
  const open = {
12243
13201
  name: "import_psd",
12244
13202
  title: "Open a PSD as the document",
12245
- description: "Opens a PSD / PSB as the document, replacing the current layers, crop and rotation (one undo step; undo brings the previous document back). Pixel, group and adjustment layers, masks, blend modes, opacity, fill, clipping, visibility and locks map directly; type, smart-object, fill and shape layers come in as their pixels; unsupported adjustments are left out. Returns the new layer tree with ids, the size and the warnings (each names the affected layers).",
13203
+ description: "Opens a PSD / PSB as the document, replacing the current layers, crop and rotation (one undo step; undo brings the previous document back). Pixel, group and adjustment layers, masks, blend modes, opacity, fill, clipping, visibility, locks, layer effects (with the patterns and global light of the file) map directly; type, smart-object, fill and shape layers come in as their pixels; unsupported adjustments are left out. Returns the new layer tree with ids, the size and the warnings (each names the affected layers).",
12246
13204
  inputSchema: { type: "object", properties: { data: DATA }, required: ["data"], additionalProperties: false },
12247
13205
  annotations: { title: "Open a PSD as the document", ...DESTRUCTIVE4 },
12248
13206
  handler: ({ data }) => {
@@ -12261,13 +13219,13 @@ function createImagePsdTools(controller) {
12261
13219
  const save = {
12262
13220
  name: "export_psd",
12263
13221
  title: "Export the document as a PSD",
12264
- description: "Writes the document as an 8-bit RGB PSD (a PSB above 30000 px) with real layers, groups, adjustment layers and masks, in the source frame (crop and rotation are not applied). Layer filters and depth masks are baked, annotation layers are rasterized (in a browser; elsewhere left out), and the merged image is the editor's composite. Changes nothing. Returns the file as base64, its size in bytes, whether it is a PSB, and warnings for everything that was changed or left out.",
13222
+ description: "Writes the document as an 8-bit RGB PSD (a PSB above 30000 px) with real layers, groups, adjustment layers, masks and layer effects (an effects block opened from a PSD is written back unchanged while its effects are; the patterns effects use are embedded), in the source frame (crop and rotation are not applied). Layer filters and depth masks are baked, annotation layers are rasterized (in a browser; elsewhere left out), and the merged image is the editor's composite. Changes nothing. Returns the file as base64, its size in bytes, whether it is a PSB, and warnings for everything that was changed or left out.",
12265
13223
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
12266
13224
  annotations: { title: "Export the document as a PSD", ...READ5 },
12267
13225
  handler: async () => {
12268
13226
  const res = await controller.toPsd();
12269
13227
  return {
12270
- data: _chunkT6H3JDGAcjs.bytesToBase64.call(void 0, res.bytes),
13228
+ data: _chunk4AB5BHYKcjs.bytesToBase64.call(void 0, res.bytes),
12271
13229
  mimeType: "image/vnd.adobe.photoshop",
12272
13230
  size: res.bytes.length,
12273
13231
  psb: res.psb,
@@ -12452,7 +13410,7 @@ function createImageEditorToolProvider(controller, options = {}) {
12452
13410
  for (const ref of [aboveId, parentId]) {
12453
13411
  if (ref !== void 0 && !controller.getLayer(ref)) throw new Error(`Unknown layer "${ref}". Call list_layers for ids.`);
12454
13412
  }
12455
- if (parentId !== void 0 && _optionalChain([controller, 'access', _263 => _263.getLayer, 'call', _264 => _264(parentId), 'optionalAccess', _265 => _265.type]) !== "group") throw new Error(`Layer "${parentId}" is not a group.`);
13413
+ if (parentId !== void 0 && _optionalChain([controller, 'access', _287 => _287.getLayer, 'call', _288 => _288(parentId), 'optionalAccess', _289 => _289.type]) !== "group") throw new Error(`Layer "${parentId}" is not a group.`);
12456
13414
  const id = controller.addAdjustmentLayer({ kind, params, opacity, blend, name, aboveId, parentId });
12457
13415
  const layer = controller.getAdjustmentLayer(id);
12458
13416
  return { layer: JSON.parse(JSON.stringify(layer)), index: controller.getAdjustmentLayers().findIndex((l) => l.id === id) };
@@ -12581,18 +13539,18 @@ var round22 = (v) => Math.round(v * 100) / 100;
12581
13539
 
12582
13540
  // src/image-editor/selection/gesture.ts
12583
13541
  var SelectionGesture = (_class9 = class {
12584
- constructor(controller, getOptions) {;_class9.prototype.__init55.call(this);_class9.prototype.__init56.call(this);_class9.prototype.__init57.call(this);_class9.prototype.__init58.call(this);_class9.prototype.__init59.call(this);
13542
+ constructor(controller, getOptions) {;_class9.prototype.__init56.call(this);_class9.prototype.__init57.call(this);_class9.prototype.__init58.call(this);_class9.prototype.__init59.call(this);_class9.prototype.__init60.call(this);
12585
13543
  this.controller = controller;
12586
13544
  this.getOptions = getOptions;
12587
13545
  }
12588
13546
 
12589
13547
 
12590
- __init55() {this.start = null}
12591
- __init56() {this.points = []}
12592
- __init57() {this.current = null}
12593
- __init58() {this.modifiers = {}}
13548
+ __init56() {this.start = null}
13549
+ __init57() {this.points = []}
13550
+ __init58() {this.current = null}
13551
+ __init59() {this.modifiers = {}}
12594
13552
  /** The last error (e.g. pixels unavailable for the wand), for the UI to show. */
12595
- __init59() {this.error = null}
13553
+ __init60() {this.error = null}
12596
13554
  get active() {
12597
13555
  return this.start !== null;
12598
13556
  }
@@ -12728,8 +13686,8 @@ function applyRegionMosaic(imageData, regions, blockSize = 12) {
12728
13686
  const count = bw * bh;
12729
13687
  for (let py = by; py < by + bh; py++) {
12730
13688
  const rowOffset = py * width;
12731
- for (let px = bx; px < bx + bw; px++) {
12732
- const idx = (rowOffset + px) * 4;
13689
+ for (let px2 = bx; px2 < bx + bw; px2++) {
13690
+ const idx = (rowOffset + px2) * 4;
12733
13691
  rSum += data[idx];
12734
13692
  gSum += data[idx + 1];
12735
13693
  bSum += data[idx + 2];
@@ -12742,8 +13700,8 @@ function applyRegionMosaic(imageData, regions, blockSize = 12) {
12742
13700
  const aAvg = Math.round(aSum / count);
12743
13701
  for (let py = by; py < by + bh; py++) {
12744
13702
  const rowOffset = py * width;
12745
- for (let px = bx; px < bx + bw; px++) {
12746
- const idx = (rowOffset + px) * 4;
13703
+ for (let px2 = bx; px2 < bx + bw; px2++) {
13704
+ const idx = (rowOffset + px2) * 4;
12747
13705
  data[idx] = rAvg;
12748
13706
  data[idx + 1] = gAvg;
12749
13707
  data[idx + 2] = bAvg;
@@ -12822,9 +13780,9 @@ function applyRegionBlur(imageData, regions, radius = 10) {
12822
13780
  // src/image-editor/layers/panel.ts
12823
13781
  function layerPanelRows(layers, activeId) {
12824
13782
  const rows = [];
12825
- const walk = (list, depth, parentId) => {
12826
- for (let i = list.length - 1; i >= 0; i--) {
12827
- const layer = list[i];
13783
+ const walk = (list2, depth, parentId) => {
13784
+ for (let i = list2.length - 1; i >= 0; i--) {
13785
+ const layer = list2[i];
12828
13786
  rows.push({
12829
13787
  layer,
12830
13788
  depth,
@@ -12863,7 +13821,7 @@ function dropZone(fraction, isGroup) {
12863
13821
  }
12864
13822
  function dropPlacement(layers, dragId, targetId, zone) {
12865
13823
  if (dragId === targetId) return null;
12866
- const target = _chunkT6H3JDGAcjs.findLayer.call(void 0, layers, targetId);
13824
+ const target = _chunk4AB5BHYKcjs.findLayer.call(void 0, layers, targetId);
12867
13825
  if (!target) return null;
12868
13826
  if (zone === "inside" && target.layer.type === "group") return { parentId: targetId };
12869
13827
  return zone === "above" ? { aboveId: targetId } : { belowId: targetId };
@@ -12871,35 +13829,35 @@ function dropPlacement(layers, dragId, targetId, zone) {
12871
13829
  function layerMenu(controller) {
12872
13830
  const s = controller.getState();
12873
13831
  const active = controller.getActiveLayer();
12874
- const loc = active ? _chunkT6H3JDGAcjs.findLayer.call(void 0, s.layers, active.id) : null;
13832
+ const loc = active ? _chunk4AB5BHYKcjs.findLayer.call(void 0, s.layers, active.id) : null;
12875
13833
  const siblings = loc ? loc.parent ? loc.parent.children : s.layers : [];
12876
13834
  const below = loc ? siblings[loc.index - 1] : void 0;
12877
13835
  const hasSel = controller.hasSelection;
12878
- const isPixel = _optionalChain([active, 'optionalAccess', _266 => _266.type]) === "pixel";
13836
+ const isPixel = _optionalChain([active, 'optionalAccess', _290 => _290.type]) === "pixel";
12879
13837
  return [
12880
13838
  { action: "new-layer", label: "New Layer", enabled: true },
12881
13839
  { action: "new-group", label: "New Group", enabled: true },
12882
13840
  { action: "duplicate", label: "Duplicate Layer", enabled: Boolean(active) },
12883
13841
  { action: "delete", label: "Delete Layer", enabled: Boolean(active) },
12884
13842
  { action: "group-selected", label: "Group Layer", enabled: Boolean(active) },
12885
- { action: "ungroup", label: "Ungroup", enabled: _optionalChain([active, 'optionalAccess', _267 => _267.type]) === "group" },
12886
- { action: "merge-down", label: "Merge Down", enabled: Boolean(_optionalChain([active, 'optionalAccess', _268 => _268.visible]) && _optionalChain([below, 'optionalAccess', _269 => _269.type]) === "pixel") },
13843
+ { action: "ungroup", label: "Ungroup", enabled: _optionalChain([active, 'optionalAccess', _291 => _291.type]) === "group" },
13844
+ { action: "merge-down", label: "Merge Down", enabled: Boolean(_optionalChain([active, 'optionalAccess', _292 => _292.visible]) && _optionalChain([below, 'optionalAccess', _293 => _293.type]) === "pixel") },
12887
13845
  { action: "merge-visible", label: "Merge Visible", enabled: s.layers.some((l) => l.visible) },
12888
13846
  { action: "flatten", label: "Flatten Image", enabled: s.layers.length > 0 },
12889
13847
  { action: "via-copy", label: "Layer via Copy", enabled: isPixel && hasSel },
12890
13848
  { action: "via-cut", label: "Layer via Cut", enabled: isPixel && hasSel },
12891
13849
  { action: "add-mask", label: "Add Layer Mask", enabled: Boolean(active) },
12892
13850
  { action: "add-mask-selection", label: "Add Mask from Selection", enabled: Boolean(active) && hasSel },
12893
- { action: "apply-mask", label: "Apply Layer Mask", enabled: isPixel && Boolean(_optionalChain([active, 'optionalAccess', _270 => _270.mask])) },
12894
- { action: "delete-mask", label: "Delete Layer Mask", enabled: Boolean(_optionalChain([active, 'optionalAccess', _271 => _271.mask])) },
12895
- { action: "toggle-mask", label: _optionalChain([active, 'optionalAccess', _272 => _272.mask, 'optionalAccess', _273 => _273.enabled]) === false ? "Enable Layer Mask" : "Disable Layer Mask", enabled: Boolean(_optionalChain([active, 'optionalAccess', _274 => _274.mask])) },
12896
- { action: "rasterize", label: "Rasterize Layer", enabled: _optionalChain([active, 'optionalAccess', _275 => _275.type]) === "annotation" || isPixel && Boolean(_optionalChain([active, 'optionalAccess', _276 => _276.type]) === "pixel" && _optionalChain([active, 'access', _277 => _277.filters, 'optionalAccess', _278 => _278.length])) },
12897
- { action: "toggle-clip", label: _optionalChain([active, 'optionalAccess', _279 => _279.clipped]) ? "Release Clipping Mask" : "Create Clipping Mask", enabled: Boolean(loc && loc.index > 0) }
13851
+ { action: "apply-mask", label: "Apply Layer Mask", enabled: isPixel && Boolean(_optionalChain([active, 'optionalAccess', _294 => _294.mask])) },
13852
+ { action: "delete-mask", label: "Delete Layer Mask", enabled: Boolean(_optionalChain([active, 'optionalAccess', _295 => _295.mask])) },
13853
+ { action: "toggle-mask", label: _optionalChain([active, 'optionalAccess', _296 => _296.mask, 'optionalAccess', _297 => _297.enabled]) === false ? "Enable Layer Mask" : "Disable Layer Mask", enabled: Boolean(_optionalChain([active, 'optionalAccess', _298 => _298.mask])) },
13854
+ { action: "rasterize", label: "Rasterize Layer", enabled: _optionalChain([active, 'optionalAccess', _299 => _299.type]) === "annotation" || isPixel && Boolean(_optionalChain([active, 'optionalAccess', _300 => _300.type]) === "pixel" && _optionalChain([active, 'access', _301 => _301.filters, 'optionalAccess', _302 => _302.length])) },
13855
+ { action: "toggle-clip", label: _optionalChain([active, 'optionalAccess', _303 => _303.clipped]) ? "Release Clipping Mask" : "Create Clipping Mask", enabled: Boolean(loc && loc.index > 0) }
12898
13856
  ];
12899
13857
  }
12900
13858
  async function runLayerMenuAction(controller, action) {
12901
13859
  const active = controller.getActiveLayer();
12902
- const id = _optionalChain([active, 'optionalAccess', _280 => _280.id]);
13860
+ const id = _optionalChain([active, 'optionalAccess', _304 => _304.id]);
12903
13861
  try {
12904
13862
  switch (action) {
12905
13863
  case "new-layer":
@@ -12946,13 +13904,13 @@ async function runLayerMenuAction(controller, action) {
12946
13904
  if (id) controller.removeLayerMask(id);
12947
13905
  break;
12948
13906
  case "toggle-mask":
12949
- if (id && _optionalChain([active, 'optionalAccess', _281 => _281.mask])) controller.setLayerMaskProps(id, { enabled: active.mask.enabled === false });
13907
+ if (id && _optionalChain([active, 'optionalAccess', _305 => _305.mask])) controller.setLayerMaskProps(id, { enabled: active.mask.enabled === false });
12950
13908
  break;
12951
13909
  case "rasterize":
12952
13910
  if (id) await controller.rasterizeLayer(id);
12953
13911
  break;
12954
13912
  case "toggle-clip":
12955
- if (id) controller.setLayerProperties(id, { clipped: !_optionalChain([active, 'optionalAccess', _282 => _282.clipped]) });
13913
+ if (id) controller.setLayerProperties(id, { clipped: !_optionalChain([active, 'optionalAccess', _306 => _306.clipped]) });
12956
13914
  break;
12957
13915
  }
12958
13916
  return null;
@@ -12961,6 +13919,179 @@ async function runLayerMenuAction(controller, action) {
12961
13919
  }
12962
13920
  }
12963
13921
 
13922
+ // src/image-editor/layers/effects-ui.ts
13923
+ function layerEffectsPanel(layer) {
13924
+ const empty = { readOnly: true, enabled: true, scale: 1, rows: [] };
13925
+ if (!layer) return { ...empty, available: false, reason: "Select a layer to add effects." };
13926
+ if (layer.type === "adjustment") return { ...empty, available: false, reason: "Adjustment layers cannot have effects." };
13927
+ const fx = layer.effects;
13928
+ const readOnly = Boolean(_optionalChain([layer, 'access', _307 => _307.locks, 'optionalAccess', _308 => _308.all]));
13929
+ return {
13930
+ available: true,
13931
+ readOnly,
13932
+ reason: readOnly ? "The layer is locked; unlock it to change its effects." : void 0,
13933
+ enabled: _nullishCoalesce(_optionalChain([fx, 'optionalAccess', _309 => _309.enabled]), () => ( true)),
13934
+ scale: _nullishCoalesce(_optionalChain([fx, 'optionalAccess', _310 => _310.scale]), () => ( 1)),
13935
+ rows: (_nullishCoalesce(_optionalChain([fx, 'optionalAccess', _311 => _311.items]), () => ( []))).map((e) => ({ id: e.id, kind: e.kind, label: _chunk4AB5BHYKcjs.layerEffectLabel.call(void 0, e.kind), enabled: e.enabled }))
13936
+ };
13937
+ }
13938
+ function layerEffectsBadge(layer) {
13939
+ if (!_optionalChain([layer, 'access', _312 => _312.effects, 'optionalAccess', _313 => _313.items, 'access', _314 => _314.length])) return null;
13940
+ return _chunk4AB5BHYKcjs.hasActiveEffects.call(void 0, layer.effects) ? "on" : "off";
13941
+ }
13942
+ var LAYER_EFFECT_MENU = _chunk4AB5BHYKcjs.LAYER_EFFECT_KINDS.map((kind) => ({ kind, label: _chunk4AB5BHYKcjs.layerEffectLabel.call(void 0, kind) }));
13943
+ var BLENDS = _chunkCRMAXIUVcjs.BLEND_MODES.filter((m) => m.id !== "pigment").map((m) => ({ value: m.id, label: m.label }));
13944
+ var opt = (...pairs) => pairs.map(([value, label]) => ({ value, label }));
13945
+ function patternOptions(patterns) {
13946
+ return [...patterns.map((p) => ({ value: p.id, label: p.name || p.id })), ..._chunk4AB5BHYKcjs.builtinPatternIds.call(void 0, ).map((id) => ({ value: id, label: _chunk4AB5BHYKcjs.builtinPattern.call(void 0, id).name }))];
13947
+ }
13948
+ function getPath(o, path) {
13949
+ let v = o;
13950
+ for (const p of path.split(".")) {
13951
+ if (v === null || v === void 0) return void 0;
13952
+ if (Array.isArray(v)) v = p === "last" ? v[v.length - 1] : v[Number(p)];
13953
+ else v = v[p];
13954
+ }
13955
+ return v;
13956
+ }
13957
+ function setPath(o, parts, value) {
13958
+ if (!parts.length) return value;
13959
+ const [p, ...rest] = parts;
13960
+ if (Array.isArray(o)) {
13961
+ const i = p === "last" ? o.length - 1 : Number(p);
13962
+ const out = [...o];
13963
+ out[i] = setPath(o[i], rest, value);
13964
+ return out;
13965
+ }
13966
+ const r = _nullishCoalesce(o, () => ( {}));
13967
+ return { ...r, [p]: setPath(r[p], rest, value) };
13968
+ }
13969
+ function fillControls(f, allowPattern, patterns) {
13970
+ const types = allowPattern ? opt(["color", "Color"], ["gradient", "Gradient"], ["pattern", "Pattern"]) : opt(["color", "Color"], ["gradient", "Gradient"]);
13971
+ const out = [{ key: "fill.type", label: "Fill", type: "select", value: f.type, options: types }];
13972
+ if (f.type === "color") out.push({ key: "fill.color", label: "Color", type: "color", value: f.color });
13973
+ else if (f.type === "gradient") out.push(...gradientControls("fill.gradient", f.gradient));
13974
+ else {
13975
+ out.push(
13976
+ { key: "fill.patternId", label: "Pattern", type: "select", value: f.patternId, options: patternOptions(patterns) },
13977
+ { key: "fill.scale", label: "Scale", type: "range", min: 0.01, max: 10, step: 0.01, value: f.scale, percent: true, unit: "%" }
13978
+ );
13979
+ }
13980
+ return out;
13981
+ }
13982
+ function gradientControls(prefix, g) {
13983
+ return [
13984
+ { key: `${prefix}.stops.0.color`, label: "Start colour", type: "color", value: _nullishCoalesce(_optionalChain([g, 'access', _315 => _315.stops, 'access', _316 => _316[0], 'optionalAccess', _317 => _317.color]), () => ( "#000000")) },
13985
+ { key: `${prefix}.stops.last.color`, label: "End colour", type: "color", value: _nullishCoalesce(_optionalChain([g, 'access', _318 => _318.stops, 'access', _319 => _319[g.stops.length - 1], 'optionalAccess', _320 => _320.color]), () => ( "#ffffff")) },
13986
+ { key: `${prefix}.style`, label: "Style", type: "select", value: g.style, options: opt(["linear", "Linear"], ["radial", "Radial"], ["angle", "Angle"], ["reflected", "Reflected"], ["diamond", "Diamond"]) },
13987
+ { key: `${prefix}.angle`, label: "Angle", type: "range", min: -180, max: 180, step: 1, value: g.angle, unit: "\xB0" },
13988
+ { key: `${prefix}.scale`, label: "Scale", type: "range", min: 0.1, max: 1.5, step: 0.01, value: g.scale, percent: true, unit: "%" },
13989
+ { key: `${prefix}.reverse`, label: "Reverse", type: "checkbox", value: g.reverse },
13990
+ { key: `${prefix}.align`, label: "Align with layer", type: "checkbox", value: g.align }
13991
+ ];
13992
+ }
13993
+ var px = (key, label, value, max = 250) => ({ key, label, type: "range", min: 0, max, step: 1, value, unit: "px" });
13994
+ var pct2 = (key, label, value, min = 0, max = 1) => ({ key, label, type: "range", min, max, step: 0.01, value, percent: true, unit: "%" });
13995
+ var deg = (key, label, value, min = -180, max = 180) => ({ key, label, type: "range", min, max, step: 1, value, unit: "\xB0" });
13996
+ function layerEffectControls(e, patterns = []) {
13997
+ const blended = e.kind === "bevel-emboss" ? [] : [
13998
+ { key: "blend", label: "Blend mode", type: "select", value: e.blend, options: BLENDS },
13999
+ pct2("opacity", "Opacity", e.opacity)
14000
+ ];
14001
+ switch (e.kind) {
14002
+ case "drop-shadow":
14003
+ case "inner-shadow":
14004
+ return [
14005
+ ...blended,
14006
+ { key: "color", label: "Color", type: "color", value: e.color },
14007
+ { key: "useGlobalLight", label: "Use global light", type: "checkbox", value: e.useGlobalLight },
14008
+ deg("angle", "Angle", e.angle),
14009
+ px("distance", "Distance", e.distance, 500),
14010
+ e.kind === "drop-shadow" ? pct2("spread", "Spread", e.spread) : pct2("choke", "Choke", e.choke),
14011
+ px("size", "Size", e.size),
14012
+ pct2("noise", "Noise", e.noise),
14013
+ ...e.kind === "drop-shadow" ? [{ key: "knocksOut", label: "Layer knocks out shadow", type: "checkbox", value: e.knocksOut }] : []
14014
+ ];
14015
+ case "outer-glow":
14016
+ case "inner-glow":
14017
+ return [
14018
+ ...blended,
14019
+ ...fillControls(e.fill, false, patterns),
14020
+ { key: "technique", label: "Technique", type: "select", value: e.technique, options: opt(["softer", "Softer"], ["precise", "Precise"]) },
14021
+ ...e.kind === "inner-glow" ? [{ key: "source", label: "Source", type: "select", value: e.source, options: opt(["edge", "Edge"], ["center", "Center"]) }] : [],
14022
+ e.kind === "outer-glow" ? pct2("spread", "Spread", e.spread) : pct2("choke", "Choke", e.choke),
14023
+ px("size", "Size", e.size),
14024
+ pct2("range", "Range", e.range, 0.01, 1),
14025
+ pct2("noise", "Noise", e.noise)
14026
+ ];
14027
+ case "bevel-emboss":
14028
+ return [
14029
+ { key: "style", label: "Style", type: "select", value: e.style, options: opt(["inner-bevel", "Inner Bevel"], ["outer-bevel", "Outer Bevel"], ["emboss", "Emboss"], ["pillow-emboss", "Pillow Emboss"], ["stroke-emboss", "Stroke Emboss"]) },
14030
+ { key: "technique", label: "Technique", type: "select", value: e.technique, options: opt(["smooth", "Smooth"], ["chisel-hard", "Chisel Hard"], ["chisel-soft", "Chisel Soft"]) },
14031
+ pct2("depth", "Depth", e.depth, 0, 10),
14032
+ { key: "direction", label: "Direction", type: "select", value: e.direction, options: opt(["up", "Up"], ["down", "Down"]) },
14033
+ px("size", "Size", e.size),
14034
+ px("soften", "Soften", e.soften, 16),
14035
+ { key: "useGlobalLight", label: "Use global light", type: "checkbox", value: e.useGlobalLight },
14036
+ deg("angle", "Angle", e.angle),
14037
+ deg("altitude", "Altitude", e.altitude, 0, 90),
14038
+ { key: "highlightColor", label: "Highlight", type: "color", value: e.highlightColor },
14039
+ { key: "highlightBlend", label: "Highlight mode", type: "select", value: e.highlightBlend, options: BLENDS },
14040
+ pct2("highlightOpacity", "Highlight opacity", e.highlightOpacity),
14041
+ { key: "shadowColor", label: "Shadow", type: "color", value: e.shadowColor },
14042
+ { key: "shadowBlend", label: "Shadow mode", type: "select", value: e.shadowBlend, options: BLENDS },
14043
+ pct2("shadowOpacity", "Shadow opacity", e.shadowOpacity)
14044
+ ];
14045
+ case "satin":
14046
+ return [
14047
+ ...blended,
14048
+ { key: "color", label: "Color", type: "color", value: e.color },
14049
+ deg("angle", "Angle", e.angle),
14050
+ px("distance", "Distance", e.distance),
14051
+ px("size", "Size", e.size),
14052
+ { key: "invert", label: "Invert", type: "checkbox", value: e.invert }
14053
+ ];
14054
+ case "color-overlay":
14055
+ return [...blended, { key: "color", label: "Color", type: "color", value: e.color }];
14056
+ case "gradient-overlay":
14057
+ return [...blended, ...gradientControls("gradient", e.gradient)];
14058
+ case "pattern-overlay":
14059
+ return [
14060
+ ...blended,
14061
+ { key: "patternId", label: "Pattern", type: "select", value: e.patternId, options: patternOptions(patterns) },
14062
+ pct2("scale", "Scale", e.scale, 0.01, 10),
14063
+ deg("angle", "Angle", _nullishCoalesce(e.angle, () => ( 0))),
14064
+ { key: "link", label: "Link with layer", type: "checkbox", value: _nullishCoalesce(e.link, () => ( true)) }
14065
+ ];
14066
+ case "stroke":
14067
+ return [
14068
+ ...blended,
14069
+ px("size", "Size", e.size),
14070
+ { key: "position", label: "Position", type: "select", value: e.position, options: opt(["outside", "Outside"], ["inside", "Inside"], ["center", "Center"]) },
14071
+ ...fillControls(e.fill, true, patterns)
14072
+ ];
14073
+ }
14074
+ }
14075
+ function fillOfType(current, type, patterns) {
14076
+ if (type === "gradient") return { type: "gradient", gradient: _chunk4AB5BHYKcjs.defaultEffectGradient.call(void 0, ) };
14077
+ if (type === "pattern") return { type: "pattern", patternId: _nullishCoalesce(_optionalChain([patterns, 'access', _321 => _321[0], 'optionalAccess', _322 => _322.id]), () => ( "checker")), scale: 1 };
14078
+ return { type: "color", color: current.type === "color" ? current.color : "#000000" };
14079
+ }
14080
+ function effectControlChange(effect, key, value, patterns = []) {
14081
+ const [top, ...rest] = key.split(".");
14082
+ if (top === "fill" && rest[0] === "type") return { fill: fillOfType(effect.fill, String(value), patterns) };
14083
+ if (top === "patternId" && !rest.length) {
14084
+ const name = _optionalChain([patternOptions, 'call', _323 => _323(patterns), 'access', _324 => _324.find, 'call', _325 => _325((o) => o.value === value), 'optionalAccess', _326 => _326.label]);
14085
+ return name ? { patternId: value, name } : { patternId: value };
14086
+ }
14087
+ if (!rest.length) return { [top]: value };
14088
+ if (top === "fill" && rest[0] === "patternId") {
14089
+ const name = _optionalChain([patternOptions, 'call', _327 => _327(patterns), 'access', _328 => _328.find, 'call', _329 => _329((o) => o.value === value), 'optionalAccess', _330 => _330.label]);
14090
+ return { fill: { ...effect.fill, patternId: value, ...name ? { name } : {} } };
14091
+ }
14092
+ return { [top]: setPath(getPath(effect, top), rest, value) };
14093
+ }
14094
+
12964
14095
  // src/image-editor/psd/ui.ts
12965
14096
  var PSD_FILE_ACCEPT = ".psd,.psb,image/vnd.adobe.photoshop,application/x-photoshop";
12966
14097
  function blobBytes(file) {
@@ -13426,5 +14557,48 @@ async function downloadPsd(controller, name = "image") {
13426
14557
 
13427
14558
 
13428
14559
 
13429
- exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.ADJUSTMENT_LAYER_CONTROLS = ADJUSTMENT_LAYER_CONTROLS; exports.ADJUSTMENT_LAYER_OPACITY_CONTROL = ADJUSTMENT_LAYER_OPACITY_CONTROL; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.BLEND_MODES = _chunkCRMAXIUVcjs.BLEND_MODES; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.BRUSH_OPTION_CONTROLS = BRUSH_OPTION_CONTROLS; exports.CoverageMap = _chunkZZOTHJ4Kcjs.CoverageMap; exports.D50 = D50; exports.D65 = D65; exports.DEFAULT_ADJUSTMENTS = DEFAULT_ADJUSTMENTS; exports.DEFAULT_BRUSH = _chunkZZOTHJ4Kcjs.DEFAULT_BRUSH; exports.DEFAULT_DEPTH_MASK = DEFAULT_DEPTH_MASK; exports.DEFAULT_MIXER = _chunkZZOTHJ4Kcjs.DEFAULT_MIXER; exports.DEFAULT_REFINE_EDGE_PARAMS = DEFAULT_REFINE_EDGE_PARAMS; exports.DEFAULT_SELECTION_TOOL_OPTIONS = DEFAULT_SELECTION_TOOL_OPTIONS; exports.DEFAULT_TRANSFORM = DEFAULT_TRANSFORM; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.DIRECT_GAUSSIAN_MAX_SIGMA = _chunkT6H3JDGAcjs.DIRECT_GAUSSIAN_MAX_SIGMA; exports.DabWalker = _chunkZZOTHJ4Kcjs.DabWalker; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.EMPTY_MIXER_LOAD = _chunkZZOTHJ4Kcjs.EMPTY_MIXER_LOAD; exports.GUIDED_FILTER_EPS = GUIDED_FILTER_EPS; exports.HISTOGRAM_BINS = HISTOGRAM_BINS; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.IMAGE_ADJUSTMENT_CONTROLS = IMAGE_ADJUSTMENT_CONTROLS; exports.IMAGE_EDITOR_SCHEMA_VERSION = IMAGE_EDITOR_SCHEMA_VERSION; exports.IMAGE_EDITOR_STATE_VERSION = IMAGE_EDITOR_STATE_VERSION; exports.ImageEditorController = ImageEditorController; exports.ImageEditorRenderer = ImageEditorRenderer; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LUMA_709 = LUMA_709; exports.LayerCompositor = LayerCompositor; exports.LayerOperationError = LayerOperationError; exports.MAX_BRUSH_SIZE = _chunkZZOTHJ4Kcjs.MAX_BRUSH_SIZE; exports.MAX_KELVIN = MAX_KELVIN; exports.MIN_KELVIN = MIN_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.MIXER_DRAIN = _chunkZZOTHJ4Kcjs.MIXER_DRAIN; exports.MIXER_MIXING_OPTIONS = MIXER_MIXING_OPTIONS; exports.MIXER_OPTION_CONTROLS = MIXER_OPTION_CONTROLS; exports.MIXER_PICKUP_RATE = _chunkZZOTHJ4Kcjs.MIXER_PICKUP_RATE; exports.MIXING_MODELS = _chunkZZOTHJ4Kcjs.MIXING_MODELS; exports.MixerStroke = _chunkZZOTHJ4Kcjs.MixerStroke; exports.PAINT_TOOLS = PAINT_TOOLS; exports.PIGMENT_BANDS = _chunkCRMAXIUVcjs.PIGMENT_BANDS; exports.PIGMENT_LAMBDA_MIN = _chunkCRMAXIUVcjs.PIGMENT_LAMBDA_MIN; exports.PIGMENT_LAMBDA_STEP = _chunkCRMAXIUVcjs.PIGMENT_LAMBDA_STEP; exports.PIGMENT_WAVELENGTHS = _chunkCRMAXIUVcjs.PIGMENT_WAVELENGTHS; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.PSD_FILE_ACCEPT = PSD_FILE_ACCEPT; exports.PaintGesture = PaintGesture; exports.PaintStrokeSession = PaintStrokeSession; exports.PsdError = PsdError; exports.REFINE_EDGE_CONTROLS = REFINE_EDGE_CONTROLS; exports.SELECTION_MODES = SELECTION_MODES; exports.SELECTION_MODE_LABELS = SELECTION_MODE_LABELS; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.SELECTION_TOOLS = SELECTION_TOOLS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.SelectionGesture = SelectionGesture; exports.StrokeCoverage = _chunkZZOTHJ4Kcjs.StrokeCoverage; exports.SurfaceDraft = _chunkCRMAXIUVcjs.SurfaceDraft; exports.TILE = _chunkCRMAXIUVcjs.TILE; exports.TILE_SHIFT = _chunkCRMAXIUVcjs.TILE_SHIFT; exports.TINT_SCALE = TINT_SCALE; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.TONE_RANGE_PRESETS = TONE_RANGE_PRESETS; exports.TiledSurface = _chunkCRMAXIUVcjs.TiledSurface; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.ZlibError = _chunkT6H3JDGAcjs.ZlibError; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.addLayerEffect = addLayerEffect; exports.addLayerFilter = addLayerFilter; exports.addToHistogram = addToHistogram; exports.adjustmentKindLabel = adjustmentKindLabel; exports.adjustmentLayersKey = adjustmentLayersKey; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.adler32 = _chunkT6H3JDGAcjs.adler32; exports.annotationLayerFor = annotationLayerFor; exports.annotationLayerName = annotationLayerName; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustments = applyAdjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyMatrix3 = applyMatrix3; exports.applyOutputStage = applyOutputStage; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyRegionBlur = applyRegionBlur; exports.applyRegionMosaic = applyRegionMosaic; exports.applyStrokeToTile = _chunkZZOTHJ4Kcjs.applyStrokeToTile; exports.backgroundLayer = backgroundLayer; exports.base64ToBytes = _chunkT6H3JDGAcjs.base64ToBytes; exports.baseProjection = baseProjection; exports.blackWhiteGray = blackWhiteGray; exports.blendChannel = _chunkCRMAXIUVcjs.blendChannel; exports.blendImageData = _chunkCRMAXIUVcjs.blendImageData; exports.blendLum = _chunkCRMAXIUVcjs.blendLum; exports.blendPixel = _chunkCRMAXIUVcjs.blendPixel; exports.blendRgb = _chunkCRMAXIUVcjs.blendRgb; exports.blendTile = _chunkT6H3JDGAcjs.blendTile; exports.blurFilter = blurFilter; exports.borderCoverage = borderCoverage; exports.boxMean = boxMean; exports.boxToCurvePoint = boxToCurvePoint; exports.bradfordAdaptation = bradfordAdaptation; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.buildToneLut = buildToneLut; exports.bytesToBase64 = _chunkT6H3JDGAcjs.bytesToBase64; exports.calculateCropDrag = calculateCropDrag; exports.canvasCompositeOperation = _chunkCRMAXIUVcjs.canvasCompositeOperation; exports.canvasToImagePoint = canvasToImagePoint; exports.changedTiles = _chunkT6H3JDGAcjs.changedTiles; exports.clampControlValue = clampControlValue; exports.clampCropToImage = clampCropToImage; exports.cleanMixer = _chunkZZOTHJ4Kcjs.cleanMixer; exports.collectTiles = _chunkCRMAXIUVcjs.collectTiles; exports.colorBalanceChannel = colorBalanceChannel; exports.colorRange = colorRange; exports.combineSelections = combineSelections; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.computeHistogram = computeHistogram; exports.computeSelectionBounds = computeSelectionBounds; exports.contentBounds = _chunkCRMAXIUVcjs.contentBounds; exports.contractCoverage = contractCoverage; exports.controlPosition = controlPosition; exports.controlTrackBackground = controlTrackBackground; exports.coverageTileCoord = _chunkZZOTHJ4Kcjs.coverageTileCoord; exports.coverageToByte = coverageToByte; exports.coveringRect = coveringRect; exports.createAdjustmentLayer = createAdjustmentLayer; exports.createImageCaptureSurface = createImageCaptureSurface; exports.createImageEditTools = createImageEditTools; exports.createImageEditorToolProvider = createImageEditorToolProvider; exports.createImageEffectTools = createImageEffectTools; exports.createImageLayerTools = createImageLayerTools; exports.createImagePaintTools = createImagePaintTools; exports.createImagePsdTools = createImagePsdTools; exports.createImageSelectionTools = createImageSelectionTools; exports.createPigment = _chunkCRMAXIUVcjs.createPigment; exports.createPigmentTools = _chunkZZOTHJ4Kcjs.createPigmentTools; exports.createSelectionMask = createSelectionMask; exports.curveLut = _chunkT6H3JDGAcjs.curveLut; exports.curveLutFromLevels = curveLutFromLevels; exports.curvePointToBox = curvePointToBox; exports.curveSvgPath = curveSvgPath; exports.dabCoverage = _chunkZZOTHJ4Kcjs.dabCoverage; exports.dabRect = _chunkZZOTHJ4Kcjs.dabRect; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeLayerMask = decodeLayerMask; exports.decodeMergedImage = decodeMergedImage; exports.decodePlanes = decodePlanes; exports.decodePng = _chunkT6H3JDGAcjs.decodePng; exports.decodePngDataUrl = decodePngDataUrl; exports.decodeSelectionRle = decodeSelectionRle; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.deflate = _chunkT6H3JDGAcjs.deflate; exports.deflateRaw = _chunkT6H3JDGAcjs.deflateRaw; exports.depthMaskAlpha = depthMaskAlpha; exports.depthRasterMask = depthRasterMask; exports.describeLayer = describeLayer; exports.describeLayerEffects = describeLayerEffects; exports.describeSelection = describeSelection; exports.deserializeEffects = deserializeEffects; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.deserializeSelection = deserializeSelection; exports.developFilter = developFilter; exports.developFromAdjustments = developFromAdjustments; exports.developTarget = developTarget; exports.distanceTransform = distanceTransform; exports.downloadPsd = downloadPsd; exports.dropPlacement = dropPlacement; exports.dropZone = dropZone; exports.duplicateLayer = duplicateLayer; exports.edgeWidth = edgeWidth; exports.ellipsePoints = ellipsePoints; exports.ellipseSelection = ellipseSelection; exports.emptyHistogram = emptyHistogram; exports.emptySurface = _chunkCRMAXIUVcjs.emptySurface; exports.encodePng = _chunkT6H3JDGAcjs.encodePng; exports.encodeRle = encodeRle; exports.encodeSelectionRle = encodeSelectionRle; exports.encodeSurface = encodeSurface; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.expandCoverage = expandCoverage; exports.exportPsd = exportPsd; exports.featherCoverage = featherCoverage; exports.fillRect = _chunkCRMAXIUVcjs.fillRect; exports.findAdjustmentControl = findAdjustmentControl; exports.findLayer = _chunkT6H3JDGAcjs.findLayer; exports.findLayerControl = findLayerControl; exports.finishTile = _chunkCRMAXIUVcjs.finishTile; exports.flattenLayers = _chunkT6H3JDGAcjs.flattenLayers; exports.formatControlValue = formatControlValue; exports.fullSelection = fullSelection; exports.gaussianBlur = _chunkT6H3JDGAcjs.gaussianBlur; exports.getAnnotationBounds = getAnnotationBounds; exports.getControlPath = getControlPath; exports.getCropCursor = getCropCursor; exports.getRotatedSize = getRotatedSize; exports.getViewportMetrics = getViewportMetrics; exports.getViewportProjection = getViewportProjection; exports.globalImageCache = globalImageCache; exports.greyMorphology = greyMorphology; exports.groupLayers = groupLayers; exports.guidePlanes = guidePlanes; exports.guidedFilterColor = guidedFilterColor; exports.handlePaintShortcut = handlePaintShortcut; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.hashMaskContent = hashMaskContent; exports.hexToRgb = hexToRgb; exports.histogramPath = histogramPath; exports.hitTestAnnotation = hitTestAnnotation; exports.hitTestCrop = hitTestCrop; exports.hitTestCurvePoint = hitTestCurvePoint; exports.hslToRgb = hslToRgb; exports.hueRange = hueRange; exports.hueRangeTables = hueRangeTables; exports.hueRangeWeight = hueRangeWeight; exports.hueSaturation = hueSaturation; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.imageEditorStateMigrations = imageEditorStateMigrations; exports.imageToCanvasPoint = imageToCanvasPoint; exports.importPsd = importPsd; exports.inflate = _chunkT6H3JDGAcjs.inflate; exports.inflateRaw = _chunkT6H3JDGAcjs.inflateRaw; exports.insertCurvePoint = insertCurvePoint; exports.insertLayer = _chunkT6H3JDGAcjs.insertLayer; exports.invertMatrix3 = invertMatrix3; exports.invertSelection = invertSelection; exports.isActiveFilter = isActiveFilter; exports.isAdjustmentKind = isAdjustmentKind; exports.isBlendMode = _chunkCRMAXIUVcjs.isBlendMode; exports.isDefaultDepthMask = isDefaultDepthMask; exports.isLayerLocked = _chunkT6H3JDGAcjs.isLayerLocked; exports.isLegacyShape = isLegacyShape; exports.isPaintTool = isPaintTool; exports.isPng = _chunkT6H3JDGAcjs.isPng; exports.isQuarterTurn = isQuarterTurn; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.isSelectionEmpty = isSelectionEmpty; exports.isSelectionMode = isSelectionMode; exports.isSeparableBlendMode = _chunkCRMAXIUVcjs.isSeparableBlendMode; exports.isSpatialFilter = isSpatialFilter; exports.kelvinToTemperature = kelvinToTemperature; exports.layerBadge = layerBadge; exports.layerEffectsOf = layerEffectsOf; exports.layerLabel = layerLabel; exports.layerMaskCoverage = layerMaskCoverage; exports.layerMaskFromSelection = layerMaskFromSelection; exports.layerMaskKey = layerMaskKey; exports.layerMenu = layerMenu; exports.layerName = layerName; exports.layerPanelRows = layerPanelRows; exports.layerTree = layerTree; exports.layerTypeLabel = layerTypeLabel; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.legacyMaskOf = legacyMaskOf; exports.legacyView = legacyView; exports.lerpPigment = _chunkCRMAXIUVcjs.lerpPigment; exports.lerpPigmentInto = _chunkCRMAXIUVcjs.lerpPigmentInto; exports.levelsValue = levelsValue; exports.linearSrgbToXy = linearSrgbToXy; exports.linearToSrgb = linearToSrgb; exports.loadImageEditorDocument = loadImageEditorDocument; exports.loadMixer = _chunkZZOTHJ4Kcjs.loadMixer; exports.magicWand = magicWand; exports.mapCropHandle = mapCropHandle; exports.mapLayer = _chunkT6H3JDGAcjs.mapLayer; exports.maskSummary = maskSummary; exports.migrateSerializedImageEditorState = migrateSerializedImageEditorState; exports.migrateToLayeredState = migrateToLayeredState; exports.mixPigment8 = _chunkCRMAXIUVcjs.mixPigment8; exports.mixPigmentRgb = _chunkCRMAXIUVcjs.mixPigmentRgb; exports.mixPigments = _chunkCRMAXIUVcjs.mixPigments; exports.mixerLoadResult = mixerLoadResult; exports.modifySelection = modifySelection; exports.moveCurvePoint = moveCurvePoint; exports.moveLayer = moveLayer; exports.mulMatrix3 = mulMatrix3; exports.needsLegacyBase = needsLegacyBase; exports.neutralHueRange = neutralHueRange; exports.newLayerId = newLayerId; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.normalizeAngle = normalizeAngle; exports.normalizeBlendMode = _chunkCRMAXIUVcjs.normalizeBlendMode; exports.normalizeBrush = _chunkZZOTHJ4Kcjs.normalizeBrush; exports.normalizeFilter = normalizeFilter; exports.normalizeLayerMask = normalizeLayerMask; exports.normalizeMixer = _chunkZZOTHJ4Kcjs.normalizeMixer; exports.normalizeProcessVersion = normalizeProcessVersion; exports.normalizeRect = normalizeRect; exports.normalizeRefineEdgeParams = normalizeRefineEdgeParams; exports.normalizeStoredAdjustments = normalizeStoredAdjustments; exports.offsetLayer = offsetLayer; exports.openPsdFile = openPsdFile; exports.packRgba = _chunkCRMAXIUVcjs.packRgba; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.parseBlend = parseBlend; exports.parseColor = parseColor; exports.parseDataUrl = _chunkT6H3JDGAcjs.parseDataUrl; exports.parseSelectionMode = parseSelectionMode; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.photoFilterMatrix = photoFilterMatrix; exports.pixelLayerBounds = pixelLayerBounds; exports.pixelLayers = pixelLayers; exports.placeLayer = placeLayer; exports.pngDataUrl = _chunkT6H3JDGAcjs.pngDataUrl; exports.pointerPressure = pointerPressure; exports.polygonCoverage = polygonCoverage; exports.polygonSelection = polygonSelection; exports.posterizeValue = posterizeValue; exports.projectImagePoint = projectImagePoint; exports.projectImageRect = projectImageRect; exports.projectMaskCoverage = projectMaskCoverage; exports.projectQuarterTurn = projectQuarterTurn; exports.psdBytesFromBase64 = psdBytesFromBase64; exports.psdFileName = psdFileName; exports.psdToLayers = psdToLayers; exports.quickMaskPixels = quickMaskPixels; exports.rangeLightness = rangeLightness; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.rasterizeDab = _chunkZZOTHJ4Kcjs.rasterizeDab; exports.readAdjustmentControls = readAdjustmentControls; exports.readPixel = _chunkCRMAXIUVcjs.readPixel; exports.readPsd = readPsd; exports.readRegion = _chunkCRMAXIUVcjs.readRegion; exports.rectSelection = rectSelection; exports.refineCoverage = refineCoverage; exports.refineEdgeHalo = refineEdgeHalo; exports.refineSelection = refineSelection; exports.reflectanceToRgb = _chunkCRMAXIUVcjs.reflectanceToRgb; exports.removeAlpha = removeAlpha; exports.removeCurvePoint = removeCurvePoint; exports.removeLayer = removeLayer; exports.removeLayerEffect = removeLayerEffect; exports.removeLayerFilter = removeLayerFilter; exports.renderLayeredBase = renderLayeredBase; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.resizePixels = resizePixels; exports.resizeSelection = resizeSelection; exports.resolveExternalAssets = resolveExternalAssets; exports.resolveMosaicRegionBounds = resolveMosaicRegionBounds; exports.rgbToGray = rgbToGray; exports.rgbToHsl = rgbToHsl; exports.rgbToReflectance = _chunkCRMAXIUVcjs.rgbToReflectance; exports.rgbUnitToHex = rgbUnitToHex; exports.runLayerMenuAction = runLayerMenuAction; exports.sampleLut = sampleLut; exports.sampleToneLut = sampleToneLut; exports.selectionArea = selectionArea; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionFromPixels = selectionFromPixels; exports.selectionModeFromModifiers = selectionModeFromModifiers; exports.selectionOutline = selectionOutline; exports.selectionToCoverage = selectionToCoverage; exports.selectionToPixels = selectionToPixels; exports.selectionValueAt = selectionValueAt; exports.serializeEffects = serializeEffects; exports.serializeLayer = serializeLayer; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.serializeSelection = serializeSelection; exports.setControlPath = setControlPath; exports.setLayerEffects = setLayerEffects; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.setLayerMask = setLayerMask; exports.setLayerProperties = setLayerProperties; exports.setLum = _chunkCRMAXIUVcjs.setLum; exports.setPigmentColor = _chunkCRMAXIUVcjs.setPigmentColor; exports.shiftCoverage = shiftCoverage; exports.smoothCoverage = smoothCoverage; exports.smoothPoints = _chunkZZOTHJ4Kcjs.smoothPoints; exports.solidSurface = _chunkCRMAXIUVcjs.solidSurface; exports.splitOverlayAnnotations = splitOverlayAnnotations; exports.srgb8ToLab = srgb8ToLab; exports.srgbToLinear = srgbToLinear; exports.sumHistograms = sumHistograms; exports.surfaceBytes = _chunkCRMAXIUVcjs.surfaceBytes; exports.surfaceFromPixels = _chunkCRMAXIUVcjs.surfaceFromPixels; exports.surfacesEqual = _chunkCRMAXIUVcjs.surfacesEqual; exports.tempTintToXy = tempTintToXy; exports.temperatureToKelvin = temperatureToKelvin; exports.tileCoord = _chunkCRMAXIUVcjs.tileCoord; exports.tileKey = _chunkCRMAXIUVcjs.tileKey; exports.tileRect = _chunkCRMAXIUVcjs.tileRect; exports.tilesInRect = _chunkCRMAXIUVcjs.tilesInRect; exports.tipFalloff = _chunkZZOTHJ4Kcjs.tipFalloff; exports.tipReach = _chunkZZOTHJ4Kcjs.tipReach; exports.tipShape = _chunkZZOTHJ4Kcjs.tipShape; exports.toHex = toHex2; exports.toneCurve = toneCurve; exports.toneLuts = toneLuts; exports.toneRange = toneRange; exports.translateSurface = _chunkCRMAXIUVcjs.translateSurface; exports.ungroupLayer = ungroupLayer; exports.uniformTile = _chunkCRMAXIUVcjs.uniformTile; exports.unionRect = unionRect; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.updateLayerEffect = updateLayerEffect; exports.updateLayerFilter = updateLayerFilter; exports.updateLayerMaskProps = updateLayerMaskProps; exports.uvToXy = uvToXy; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.walkDabs = _chunkZZOTHJ4Kcjs.walkDabs; exports.wbMatrix = wbMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.withNewIds = withNewIds; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.writePsd = writePsd; exports.writeRegion = _chunkCRMAXIUVcjs.writeRegion; exports.xyToTempTint = xyToTempTint; exports.xyToUv = xyToUv;
14560
+
14561
+
14562
+
14563
+
14564
+
14565
+
14566
+
14567
+
14568
+
14569
+
14570
+
14571
+
14572
+
14573
+
14574
+
14575
+
14576
+
14577
+
14578
+
14579
+
14580
+
14581
+
14582
+
14583
+
14584
+
14585
+
14586
+
14587
+
14588
+
14589
+
14590
+
14591
+
14592
+
14593
+
14594
+
14595
+
14596
+
14597
+
14598
+
14599
+
14600
+
14601
+
14602
+
14603
+ exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.ADJUSTMENT_LAYER_CONTROLS = ADJUSTMENT_LAYER_CONTROLS; exports.ADJUSTMENT_LAYER_OPACITY_CONTROL = ADJUSTMENT_LAYER_OPACITY_CONTROL; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.BLEND_MODES = _chunkCRMAXIUVcjs.BLEND_MODES; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.BRUSH_OPTION_CONTROLS = BRUSH_OPTION_CONTROLS; exports.CoverageMap = _chunkZZOTHJ4Kcjs.CoverageMap; exports.D50 = D50; exports.D65 = D65; exports.DEFAULT_ADJUSTMENTS = DEFAULT_ADJUSTMENTS; exports.DEFAULT_BRUSH = _chunkZZOTHJ4Kcjs.DEFAULT_BRUSH; exports.DEFAULT_DEPTH_MASK = DEFAULT_DEPTH_MASK; exports.DEFAULT_GLOBAL_LIGHT = _chunk4AB5BHYKcjs.DEFAULT_GLOBAL_LIGHT; exports.DEFAULT_MIXER = _chunkZZOTHJ4Kcjs.DEFAULT_MIXER; exports.DEFAULT_REFINE_EDGE_PARAMS = DEFAULT_REFINE_EDGE_PARAMS; exports.DEFAULT_SELECTION_TOOL_OPTIONS = DEFAULT_SELECTION_TOOL_OPTIONS; exports.DEFAULT_TRANSFORM = DEFAULT_TRANSFORM; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.DIRECT_GAUSSIAN_MAX_SIGMA = _chunk4AB5BHYKcjs.DIRECT_GAUSSIAN_MAX_SIGMA; exports.DabWalker = _chunkZZOTHJ4Kcjs.DabWalker; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.EMPTY_MIXER_LOAD = _chunkZZOTHJ4Kcjs.EMPTY_MIXER_LOAD; exports.GUIDED_FILTER_EPS = GUIDED_FILTER_EPS; exports.HISTOGRAM_BINS = HISTOGRAM_BINS; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.IMAGE_ADJUSTMENT_CONTROLS = IMAGE_ADJUSTMENT_CONTROLS; exports.IMAGE_EDITOR_SCHEMA_VERSION = IMAGE_EDITOR_SCHEMA_VERSION; exports.IMAGE_EDITOR_STATE_VERSION = IMAGE_EDITOR_STATE_VERSION; exports.ImageEditorController = ImageEditorController; exports.ImageEditorRenderer = ImageEditorRenderer; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.LAYER_EFFECT_KINDS = _chunk4AB5BHYKcjs.LAYER_EFFECT_KINDS; exports.LAYER_EFFECT_MENU = LAYER_EFFECT_MENU; exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LUMA_709 = LUMA_709; exports.LayerCompositor = LayerCompositor; exports.LayerEffectError = _chunk4AB5BHYKcjs.LayerEffectError; exports.LayerOperationError = LayerOperationError; exports.MAX_BRUSH_SIZE = _chunkZZOTHJ4Kcjs.MAX_BRUSH_SIZE; exports.MAX_EFFECT_REACH = _chunk4AB5BHYKcjs.MAX_EFFECT_REACH; exports.MAX_KELVIN = MAX_KELVIN; exports.MIN_KELVIN = MIN_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.MIXER_DRAIN = _chunkZZOTHJ4Kcjs.MIXER_DRAIN; exports.MIXER_MIXING_OPTIONS = MIXER_MIXING_OPTIONS; exports.MIXER_OPTION_CONTROLS = MIXER_OPTION_CONTROLS; exports.MIXER_PICKUP_RATE = _chunkZZOTHJ4Kcjs.MIXER_PICKUP_RATE; exports.MIXING_MODELS = _chunkZZOTHJ4Kcjs.MIXING_MODELS; exports.MixerStroke = _chunkZZOTHJ4Kcjs.MixerStroke; exports.PAINT_TOOLS = PAINT_TOOLS; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.PIGMENT_BANDS = _chunkCRMAXIUVcjs.PIGMENT_BANDS; exports.PIGMENT_LAMBDA_MIN = _chunkCRMAXIUVcjs.PIGMENT_LAMBDA_MIN; exports.PIGMENT_LAMBDA_STEP = _chunkCRMAXIUVcjs.PIGMENT_LAMBDA_STEP; exports.PIGMENT_WAVELENGTHS = _chunkCRMAXIUVcjs.PIGMENT_WAVELENGTHS; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.PSD_FILE_ACCEPT = PSD_FILE_ACCEPT; exports.PaintGesture = PaintGesture; exports.PaintStrokeSession = PaintStrokeSession; exports.PatternPlacement = _chunk4AB5BHYKcjs.PatternPlacement; exports.PatternTile = _chunk4AB5BHYKcjs.PatternTile; exports.PsdError = PsdError; exports.REFINE_EDGE_CONTROLS = REFINE_EDGE_CONTROLS; exports.SELECTION_MODES = SELECTION_MODES; exports.SELECTION_MODE_LABELS = SELECTION_MODE_LABELS; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.SELECTION_TOOLS = SELECTION_TOOLS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.SelectionGesture = SelectionGesture; exports.StrokeCoverage = _chunkZZOTHJ4Kcjs.StrokeCoverage; exports.SurfaceDraft = _chunkCRMAXIUVcjs.SurfaceDraft; exports.TILE = _chunkCRMAXIUVcjs.TILE; exports.TILE_SHIFT = _chunkCRMAXIUVcjs.TILE_SHIFT; exports.TINT_SCALE = TINT_SCALE; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.TONE_RANGE_PRESETS = TONE_RANGE_PRESETS; exports.TiledSurface = _chunkCRMAXIUVcjs.TiledSurface; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.ZlibError = _chunk4AB5BHYKcjs.ZlibError; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.addLayerEffect = addLayerEffect; exports.addLayerFilter = addLayerFilter; exports.addToHistogram = addToHistogram; exports.adjustmentKindLabel = adjustmentKindLabel; exports.adjustmentLayersKey = adjustmentLayersKey; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.adler32 = _chunk4AB5BHYKcjs.adler32; exports.annotationLayerFor = annotationLayerFor; exports.annotationLayerName = annotationLayerName; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustments = applyAdjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyMatrix3 = applyMatrix3; exports.applyOutputStage = applyOutputStage; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyRegionBlur = applyRegionBlur; exports.applyRegionMosaic = applyRegionMosaic; exports.applyStrokeToTile = _chunkZZOTHJ4Kcjs.applyStrokeToTile; exports.backgroundLayer = backgroundLayer; exports.base64ToBytes = _chunk4AB5BHYKcjs.base64ToBytes; exports.baseProjection = baseProjection; exports.blackWhiteGray = blackWhiteGray; exports.blendChannel = _chunkCRMAXIUVcjs.blendChannel; exports.blendImageData = _chunkCRMAXIUVcjs.blendImageData; exports.blendLum = _chunkCRMAXIUVcjs.blendLum; exports.blendPixel = _chunkCRMAXIUVcjs.blendPixel; exports.blendRgb = _chunkCRMAXIUVcjs.blendRgb; exports.blendTile = _chunk4AB5BHYKcjs.blendTile; exports.blurFilter = blurFilter; exports.borderCoverage = borderCoverage; exports.boxMean = boxMean; exports.boxToCurvePoint = boxToCurvePoint; exports.bradfordAdaptation = bradfordAdaptation; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.buildToneLut = buildToneLut; exports.builtinPattern = _chunk4AB5BHYKcjs.builtinPattern; exports.builtinPatternIds = _chunk4AB5BHYKcjs.builtinPatternIds; exports.bytesToBase64 = _chunk4AB5BHYKcjs.bytesToBase64; exports.calculateCropDrag = calculateCropDrag; exports.canvasCompositeOperation = _chunkCRMAXIUVcjs.canvasCompositeOperation; exports.canvasToImagePoint = canvasToImagePoint; exports.changedTiles = _chunk4AB5BHYKcjs.changedTiles; exports.clampControlValue = clampControlValue; exports.clampCropToImage = clampCropToImage; exports.cleanMixer = _chunkZZOTHJ4Kcjs.cleanMixer; exports.collectTiles = _chunkCRMAXIUVcjs.collectTiles; exports.colorBalanceChannel = colorBalanceChannel; exports.colorRange = colorRange; exports.combineSelections = combineSelections; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.computeHistogram = computeHistogram; exports.computeSelectionBounds = computeSelectionBounds; exports.contentBounds = _chunkCRMAXIUVcjs.contentBounds; exports.contractCoverage = contractCoverage; exports.controlPosition = controlPosition; exports.controlTrackBackground = controlTrackBackground; exports.coverageTileCoord = _chunkZZOTHJ4Kcjs.coverageTileCoord; exports.coverageToByte = coverageToByte; exports.coveringRect = coveringRect; exports.createAdjustmentLayer = createAdjustmentLayer; exports.createImageCaptureSurface = createImageCaptureSurface; exports.createImageEditTools = createImageEditTools; exports.createImageEditorToolProvider = createImageEditorToolProvider; exports.createImageEffectTools = createImageEffectTools; exports.createImageLayerTools = createImageLayerTools; exports.createImagePaintTools = createImagePaintTools; exports.createImagePsdTools = createImagePsdTools; exports.createImageSelectionTools = createImageSelectionTools; exports.createPigment = _chunkCRMAXIUVcjs.createPigment; exports.createPigmentTools = _chunkZZOTHJ4Kcjs.createPigmentTools; exports.createSelectionMask = createSelectionMask; exports.curveLut = _chunk4AB5BHYKcjs.curveLut; exports.curveLutFromLevels = curveLutFromLevels; exports.curvePointToBox = curvePointToBox; exports.curveSvgPath = curveSvgPath; exports.dabCoverage = _chunkZZOTHJ4Kcjs.dabCoverage; exports.dabRect = _chunkZZOTHJ4Kcjs.dabRect; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeLayerMask = decodeLayerMask; exports.decodeMergedImage = decodeMergedImage; exports.decodePlanes = decodePlanes; exports.decodePng = _chunk4AB5BHYKcjs.decodePng; exports.decodePngDataUrl = decodePngDataUrl; exports.decodeSelectionRle = decodeSelectionRle; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.defaultEffectGradient = _chunk4AB5BHYKcjs.defaultEffectGradient; exports.defaultLayerEffect = _chunk4AB5BHYKcjs.defaultLayerEffect; exports.deflate = _chunk4AB5BHYKcjs.deflate; exports.deflateRaw = _chunk4AB5BHYKcjs.deflateRaw; exports.depthMaskAlpha = depthMaskAlpha; exports.depthRasterMask = depthRasterMask; exports.describeLayer = describeLayer; exports.describeLayerEffects = describeLayerEffects; exports.describeSelection = describeSelection; exports.deserializeEffects = deserializeEffects; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.deserializePatterns = deserializePatterns; exports.deserializeSelection = deserializeSelection; exports.developFilter = developFilter; exports.developFromAdjustments = developFromAdjustments; exports.developTarget = developTarget; exports.distanceTransform = distanceTransform; exports.downloadPsd = downloadPsd; exports.dropPlacement = dropPlacement; exports.dropZone = dropZone; exports.duplicateLayer = duplicateLayer; exports.edgeWidth = edgeWidth; exports.effectColorHex = _chunk4AB5BHYKcjs.effectColorHex; exports.effectControlChange = effectControlChange; exports.effectReach = _chunk4AB5BHYKcjs.effectReach; exports.effectsFingerprint = _chunk4AB5BHYKcjs.effectsFingerprint; exports.effectsMargin = _chunk4AB5BHYKcjs.effectsMargin; exports.effectsScale = _chunk4AB5BHYKcjs.effectsScale; exports.ellipsePoints = ellipsePoints; exports.ellipseSelection = ellipseSelection; exports.emptyHistogram = emptyHistogram; exports.emptySurface = _chunkCRMAXIUVcjs.emptySurface; exports.encodePng = _chunk4AB5BHYKcjs.encodePng; exports.encodeRle = encodeRle; exports.encodeSelectionRle = encodeSelectionRle; exports.encodeSurface = encodeSurface; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.expandCoverage = expandCoverage; exports.exportPsd = exportPsd; exports.featherCoverage = featherCoverage; exports.fillRect = _chunkCRMAXIUVcjs.fillRect; exports.findAdjustmentControl = findAdjustmentControl; exports.findLayer = _chunk4AB5BHYKcjs.findLayer; exports.findLayerControl = findLayerControl; exports.finishTile = _chunkCRMAXIUVcjs.finishTile; exports.flattenLayers = _chunk4AB5BHYKcjs.flattenLayers; exports.formatControlValue = formatControlValue; exports.fullSelection = fullSelection; exports.gaussianBlur = _chunk4AB5BHYKcjs.gaussianBlur; exports.getAnnotationBounds = getAnnotationBounds; exports.getControlPath = getControlPath; exports.getCropCursor = getCropCursor; exports.getRotatedSize = getRotatedSize; exports.getViewportMetrics = getViewportMetrics; exports.getViewportProjection = getViewportProjection; exports.globalImageCache = globalImageCache; exports.greyMorphology = greyMorphology; exports.groupLayers = groupLayers; exports.guidePlanes = guidePlanes; exports.guidedFilterColor = guidedFilterColor; exports.handlePaintShortcut = handlePaintShortcut; exports.hasActiveEffects = _chunk4AB5BHYKcjs.hasActiveEffects; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.hashMaskContent = hashMaskContent; exports.hashNoise = _chunk4AB5BHYKcjs.hashNoise; exports.hexToRgb = hexToRgb; exports.histogramPath = histogramPath; exports.hitTestAnnotation = hitTestAnnotation; exports.hitTestCrop = hitTestCrop; exports.hitTestCurvePoint = hitTestCurvePoint; exports.hslToRgb = hslToRgb; exports.hueRange = hueRange; exports.hueRangeTables = hueRangeTables; exports.hueRangeWeight = hueRangeWeight; exports.hueSaturation = hueSaturation; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.imageEditorStateMigrations = imageEditorStateMigrations; exports.imageToCanvasPoint = imageToCanvasPoint; exports.importPsd = importPsd; exports.inflate = _chunk4AB5BHYKcjs.inflate; exports.inflateRaw = _chunk4AB5BHYKcjs.inflateRaw; exports.insertCurvePoint = insertCurvePoint; exports.insertLayer = _chunk4AB5BHYKcjs.insertLayer; exports.invertMatrix3 = invertMatrix3; exports.invertSelection = invertSelection; exports.isActiveFilter = isActiveFilter; exports.isAdjustmentKind = isAdjustmentKind; exports.isBlendMode = _chunkCRMAXIUVcjs.isBlendMode; exports.isDefaultDepthMask = isDefaultDepthMask; exports.isLayerEffectKind = _chunk4AB5BHYKcjs.isLayerEffectKind; exports.isLayerLocked = _chunk4AB5BHYKcjs.isLayerLocked; exports.isLegacyShape = isLegacyShape; exports.isPaintTool = isPaintTool; exports.isPng = _chunk4AB5BHYKcjs.isPng; exports.isQuarterTurn = isQuarterTurn; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.isSelectionEmpty = isSelectionEmpty; exports.isSelectionMode = isSelectionMode; exports.isSeparableBlendMode = _chunkCRMAXIUVcjs.isSeparableBlendMode; exports.isSpatialFilter = isSpatialFilter; exports.kelvinToTemperature = kelvinToTemperature; exports.layerBadge = layerBadge; exports.layerEffectControls = layerEffectControls; exports.layerEffectFields = _chunk4AB5BHYKcjs.layerEffectFields; exports.layerEffectLabel = _chunk4AB5BHYKcjs.layerEffectLabel; exports.layerEffectsBadge = layerEffectsBadge; exports.layerEffectsOf = layerEffectsOf; exports.layerEffectsPanel = layerEffectsPanel; exports.layerLabel = layerLabel; exports.layerMaskCoverage = layerMaskCoverage; exports.layerMaskFromSelection = layerMaskFromSelection; exports.layerMaskKey = layerMaskKey; exports.layerMenu = layerMenu; exports.layerName = layerName; exports.layerPanelRows = layerPanelRows; exports.layerTree = layerTree; exports.layerTypeLabel = layerTypeLabel; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.legacyMaskOf = legacyMaskOf; exports.legacyView = legacyView; exports.lerpPigment = _chunkCRMAXIUVcjs.lerpPigment; exports.lerpPigmentInto = _chunkCRMAXIUVcjs.lerpPigmentInto; exports.levelsValue = levelsValue; exports.linearSrgbToXy = linearSrgbToXy; exports.linearToSrgb = linearToSrgb; exports.loadImageEditorDocument = loadImageEditorDocument; exports.loadMixer = _chunkZZOTHJ4Kcjs.loadMixer; exports.magicWand = magicWand; exports.mapCropHandle = mapCropHandle; exports.mapLayer = _chunk4AB5BHYKcjs.mapLayer; exports.maskSummary = maskSummary; exports.mergeLayerEffect = _chunk4AB5BHYKcjs.mergeLayerEffect; exports.migrateSerializedImageEditorState = migrateSerializedImageEditorState; exports.migrateToLayeredState = migrateToLayeredState; exports.mixPigment8 = _chunkCRMAXIUVcjs.mixPigment8; exports.mixPigmentRgb = _chunkCRMAXIUVcjs.mixPigmentRgb; exports.mixPigments = _chunkCRMAXIUVcjs.mixPigments; exports.mixerLoadResult = mixerLoadResult; exports.modifySelection = modifySelection; exports.moveCurvePoint = moveCurvePoint; exports.moveLayer = moveLayer; exports.mulMatrix3 = mulMatrix3; exports.needsLegacyBase = needsLegacyBase; exports.neutralHueRange = neutralHueRange; exports.newEffectId = _chunk4AB5BHYKcjs.newEffectId; exports.newLayerId = newLayerId; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.normalizeAngle = normalizeAngle; exports.normalizeBlendMode = _chunkCRMAXIUVcjs.normalizeBlendMode; exports.normalizeBrush = _chunkZZOTHJ4Kcjs.normalizeBrush; exports.normalizeFilter = normalizeFilter; exports.normalizeLayerEffects = _chunk4AB5BHYKcjs.normalizeLayerEffects; exports.normalizeLayerMask = normalizeLayerMask; exports.normalizeMixer = _chunkZZOTHJ4Kcjs.normalizeMixer; exports.normalizeProcessVersion = normalizeProcessVersion; exports.normalizeRect = normalizeRect; exports.normalizeRefineEdgeParams = normalizeRefineEdgeParams; exports.normalizeStoredAdjustments = normalizeStoredAdjustments; exports.offsetLayer = offsetLayer; exports.openPsdFile = openPsdFile; exports.packRgba = _chunkCRMAXIUVcjs.packRgba; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.parseBlend = parseBlend; exports.parseColor = parseColor; exports.parseDataUrl = _chunk4AB5BHYKcjs.parseDataUrl; exports.parseEffectColor = _chunk4AB5BHYKcjs.parseEffectColor; exports.parseLfx2 = parseLfx2; exports.parseLrfx = parseLrfx; exports.parsePatternBlock = parsePatternBlock; exports.parseSelectionMode = parseSelectionMode; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.photoFilterMatrix = photoFilterMatrix; exports.pixelLayerBounds = pixelLayerBounds; exports.pixelLayers = pixelLayers; exports.placeLayer = placeLayer; exports.pngDataUrl = _chunk4AB5BHYKcjs.pngDataUrl; exports.pointerPressure = pointerPressure; exports.polygonCoverage = polygonCoverage; exports.polygonSelection = polygonSelection; exports.posterizeValue = posterizeValue; exports.projectImagePoint = projectImagePoint; exports.projectImageRect = projectImageRect; exports.projectMaskCoverage = projectMaskCoverage; exports.projectQuarterTurn = projectQuarterTurn; exports.psdBytesFromBase64 = psdBytesFromBase64; exports.psdFileName = psdFileName; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.psdToLayers = psdToLayers; exports.quickMaskPixels = quickMaskPixels; exports.rangeLightness = rangeLightness; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.rasterizeDab = _chunkZZOTHJ4Kcjs.rasterizeDab; exports.readAdjustmentControls = readAdjustmentControls; exports.readPixel = _chunkCRMAXIUVcjs.readPixel; exports.readPsd = readPsd; exports.readRegion = _chunkCRMAXIUVcjs.readRegion; exports.rectSelection = rectSelection; exports.refineCoverage = refineCoverage; exports.refineEdgeHalo = refineEdgeHalo; exports.refineSelection = refineSelection; exports.reflectanceToRgb = _chunkCRMAXIUVcjs.reflectanceToRgb; exports.removeAlpha = removeAlpha; exports.removeCurvePoint = removeCurvePoint; exports.removeLayer = removeLayer; exports.removeLayerEffect = removeLayerEffect; exports.removeLayerFilter = removeLayerFilter; exports.renderLayerEffects = _chunk4AB5BHYKcjs.renderLayerEffects; exports.renderLayeredBase = renderLayeredBase; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.resizePixels = resizePixels; exports.resizeSelection = resizeSelection; exports.resolveExternalAssets = resolveExternalAssets; exports.resolveMosaicRegionBounds = resolveMosaicRegionBounds; exports.rgbToGray = rgbToGray; exports.rgbToHsl = rgbToHsl; exports.rgbToReflectance = _chunkCRMAXIUVcjs.rgbToReflectance; exports.rgbUnitToHex = rgbUnitToHex; exports.runLayerMenuAction = runLayerMenuAction; exports.sampleLut = sampleLut; exports.sampleToneLut = sampleToneLut; exports.scaleLayerEffect = _chunk4AB5BHYKcjs.scaleLayerEffect; exports.selectionArea = selectionArea; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionFromPixels = selectionFromPixels; exports.selectionModeFromModifiers = selectionModeFromModifiers; exports.selectionOutline = selectionOutline; exports.selectionToCoverage = selectionToCoverage; exports.selectionToPixels = selectionToPixels; exports.selectionValueAt = selectionValueAt; exports.serializeEffects = serializeEffects; exports.serializeLayer = serializeLayer; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.serializePatterns = serializePatterns; exports.serializeSelection = serializeSelection; exports.setControlPath = setControlPath; exports.setLayerEffects = setLayerEffects; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.setLayerMask = setLayerMask; exports.setLayerProperties = setLayerProperties; exports.setLum = _chunkCRMAXIUVcjs.setLum; exports.setPigmentColor = _chunkCRMAXIUVcjs.setPigmentColor; exports.shiftCoverage = shiftCoverage; exports.smoothCoverage = smoothCoverage; exports.smoothPoints = _chunkZZOTHJ4Kcjs.smoothPoints; exports.solidSurface = _chunkCRMAXIUVcjs.solidSurface; exports.splitOverlayAnnotations = splitOverlayAnnotations; exports.srgb8ToLab = srgb8ToLab; exports.srgbToLinear = srgbToLinear; exports.sumHistograms = sumHistograms; exports.surfaceBytes = _chunkCRMAXIUVcjs.surfaceBytes; exports.surfaceFromPixels = _chunkCRMAXIUVcjs.surfaceFromPixels; exports.surfacesEqual = _chunkCRMAXIUVcjs.surfacesEqual; exports.tempTintToXy = tempTintToXy; exports.temperatureToKelvin = temperatureToKelvin; exports.tileCoord = _chunkCRMAXIUVcjs.tileCoord; exports.tileKey = _chunkCRMAXIUVcjs.tileKey; exports.tileRect = _chunkCRMAXIUVcjs.tileRect; exports.tilesInRect = _chunkCRMAXIUVcjs.tilesInRect; exports.tipFalloff = _chunkZZOTHJ4Kcjs.tipFalloff; exports.tipReach = _chunkZZOTHJ4Kcjs.tipReach; exports.tipShape = _chunkZZOTHJ4Kcjs.tipShape; exports.toHex = toHex2; exports.toneCurve = toneCurve; exports.toneLuts = toneLuts; exports.toneRange = toneRange; exports.translateSurface = _chunkCRMAXIUVcjs.translateSurface; exports.ungroupLayer = ungroupLayer; exports.uniformTile = _chunkCRMAXIUVcjs.uniformTile; exports.unionRect = unionRect; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.updateLayerEffect = updateLayerEffect; exports.updateLayerFilter = updateLayerFilter; exports.updateLayerMaskProps = updateLayerMaskProps; exports.uvToXy = uvToXy; exports.validateEffectGradient = _chunk4AB5BHYKcjs.validateEffectGradient; exports.validateLayerEffect = _chunk4AB5BHYKcjs.validateLayerEffect; exports.validateLayerEffects = _chunk4AB5BHYKcjs.validateLayerEffects; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.walkDabs = _chunkZZOTHJ4Kcjs.walkDabs; exports.wbMatrix = wbMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.withNewIds = withNewIds; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.writeLfx2 = writeLfx2; exports.writePatternBlock = writePatternBlock; exports.writePsd = writePsd; exports.writeRegion = _chunkCRMAXIUVcjs.writeRegion; exports.xyToTempTint = xyToTempTint; exports.xyToUv = xyToUv;
13430
14604
  //# sourceMappingURL=index.cjs.map