@pixerate/editor 0.219.2 → 0.220.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.
@@ -9,6 +9,7 @@ var _chunkA2IS7EHEcjs = require('./chunk-A2IS7EHE.cjs');
9
9
 
10
10
 
11
11
 
12
+
12
13
  var _chunkSS53NNZOcjs = require('./chunk-SS53NNZO.cjs');
13
14
 
14
15
 
@@ -98,6 +99,8 @@ var _chunkBROJYMWUcjs = require('./chunk-BROJYMWU.cjs');
98
99
 
99
100
 
100
101
 
102
+
103
+
101
104
 
102
105
 
103
106
 
@@ -108,6 +111,7 @@ var _chunkQAUIZPYIcjs = require('./chunk-QAUIZPYI.cjs');
108
111
 
109
112
 
110
113
 
114
+
111
115
  var _chunkGF2RBSDMcjs = require('./chunk-GF2RBSDM.cjs');
112
116
 
113
117
 
@@ -1669,9 +1673,9 @@ function getProcess2Plan(adjustments) {
1669
1673
  const luts = [];
1670
1674
  const scale = [0, 0, 0];
1671
1675
  for (let c = 0; c < 3; c++) {
1672
- let reach = 0;
1673
- for (let k = 0; k < 3; k++) reach += Math.max(0, m[c * 3 + k]);
1674
- const headroom = Math.max(1, reach);
1676
+ let reach2 = 0;
1677
+ for (let k = 0; k < 3; k++) reach2 += Math.max(0, m[c * 3 + k]);
1678
+ const headroom = Math.max(1, reach2);
1675
1679
  luts[c] = buildToneLut(contrast, brightness, headroom);
1676
1680
  scale[c] = TONE_LUT_SIZE / headroom;
1677
1681
  }
@@ -2946,12 +2950,224 @@ function annotationOfShape(layer) {
2946
2950
  return out;
2947
2951
  }
2948
2952
 
2953
+ // src/image-editor/layers/hybrid-mask.ts
2954
+ var VECTOR_MASK_EDGE_DEFAULTS = { radius: 4, inner: 4, outer: 8 };
2955
+ var JOIN_SIGMA = 2;
2956
+ function vectorMaskSegments(components) {
2957
+ const out = [];
2958
+ components.forEach((c, ci) => c.subpaths.forEach((sp, si) => {
2959
+ for (let k = 0; k < _chunkQAUIZPYIcjs.subpathSegmentCount.call(void 0, sp); k++) out.push({ component: ci, subpath: si, segment: k });
2960
+ }));
2961
+ return out;
2962
+ }
2963
+ function validVectorMaskEdges(edges, components) {
2964
+ if (!_optionalChain([edges, 'optionalAccess', _34 => _34.length])) return [];
2965
+ return edges.filter((e) => {
2966
+ const sp = _optionalChain([components, 'access', _35 => _35[e.component], 'optionalAccess', _36 => _36.subpaths, 'access', _37 => _37[e.subpath]]);
2967
+ return Boolean(sp) && e.segment >= 0 && e.segment < _chunkQAUIZPYIcjs.subpathSegmentCount.call(void 0, sp);
2968
+ });
2969
+ }
2970
+ function reach(e) {
2971
+ return e.mode === "feather" ? 3 * (_nullishCoalesce(e.radius, () => ( VECTOR_MASK_EDGE_DEFAULTS.radius))) : Math.max(_nullishCoalesce(e.inner, () => ( VECTOR_MASK_EDGE_DEFAULTS.inner)), _nullishCoalesce(e.outer, () => ( VECTOR_MASK_EDGE_DEFAULTS.outer)));
2972
+ }
2973
+ function hybridVectorMaskCoverage(vm, hard, width, height, guide) {
2974
+ const edges = validVectorMaskEdges(vm.edges, vm.components).filter((e) => e.mode !== "hard");
2975
+ if (!edges.length) return hard;
2976
+ const classKey = (e) => e.mode === "feather" ? `f:${_nullishCoalesce(e.radius, () => ( VECTOR_MASK_EDGE_DEFAULTS.radius))}` : `m:${_nullishCoalesce(e.inner, () => ( VECTOR_MASK_EDGE_DEFAULTS.inner))}:${_nullishCoalesce(e.outer, () => ( VECTOR_MASK_EDGE_DEFAULTS.outer))}`;
2977
+ const classes = [{ key: "hard", edge: null }];
2978
+ const classOfEdge = /* @__PURE__ */ new Map();
2979
+ for (const e of edges) {
2980
+ const k = classKey(e);
2981
+ if (!classes.some((c) => c.key === k)) classes.push({ key: k, edge: e });
2982
+ classOfEdge.set(`${e.component}:${e.subpath}:${e.segment}`, classes.findIndex((c) => c.key === k));
2983
+ }
2984
+ const maxReach = Math.max(...edges.map(reach)) + 3 * JOIN_SIGMA + 2;
2985
+ const seedX = [];
2986
+ const seedY = [];
2987
+ const seedClass = [];
2988
+ vm.components.forEach(
2989
+ (c, ci) => c.subpaths.forEach((sp, si) => {
2990
+ for (let k = 0; k < _chunkQAUIZPYIcjs.subpathSegmentCount.call(void 0, sp); k++) {
2991
+ const seg = _chunkQAUIZPYIcjs.subpathSegment.call(void 0, sp, k);
2992
+ let len = 0;
2993
+ for (let i = 1; i < seg.length; i++) len += Math.hypot(seg[i][0] - seg[i - 1][0], seg[i][1] - seg[i - 1][1]);
2994
+ const steps = Math.max(2, Math.ceil(len * 2));
2995
+ const cls2 = _nullishCoalesce(classOfEdge.get(`${ci}:${si}:${k}`), () => ( 0));
2996
+ for (let s = 0; s <= steps; s++) {
2997
+ const [x, y] = _chunkGF2RBSDMcjs.segmentPoint.call(void 0, seg, s / steps);
2998
+ seedX.push(x);
2999
+ seedY.push(y);
3000
+ seedClass.push(cls2);
3001
+ }
3002
+ }
3003
+ })
3004
+ );
3005
+ if (!seedX.length) return hard;
3006
+ let minX = Infinity;
3007
+ let minY = Infinity;
3008
+ let maxX = -Infinity;
3009
+ let maxY = -Infinity;
3010
+ for (let i = 0; i < seedX.length; i++) {
3011
+ if (seedX[i] < minX) minX = seedX[i];
3012
+ if (seedX[i] > maxX) maxX = seedX[i];
3013
+ if (seedY[i] < minY) minY = seedY[i];
3014
+ if (seedY[i] > maxY) maxY = seedY[i];
3015
+ }
3016
+ const x0 = Math.max(0, Math.floor(minX - maxReach));
3017
+ const y0 = Math.max(0, Math.floor(minY - maxReach));
3018
+ const x1 = Math.min(width, Math.ceil(maxX + maxReach) + 1);
3019
+ const y1 = Math.min(height, Math.ceil(maxY + maxReach) + 1);
3020
+ const w = x1 - x0;
3021
+ const h = y1 - y0;
3022
+ if (w < 1 || h < 1) return hard;
3023
+ const n = w * h;
3024
+ const dist = new Float32Array(n).fill(Infinity);
3025
+ const cls = new Int16Array(n);
3026
+ for (let i = 0; i < seedX.length; i++) {
3027
+ const x = Math.round(seedX[i]) - x0;
3028
+ const y = Math.round(seedY[i]) - y0;
3029
+ if (x < 0 || y < 0 || x >= w || y >= h) continue;
3030
+ const k = y * w + x;
3031
+ const d = Math.hypot(seedX[i] - (x + x0), seedY[i] - (y + y0));
3032
+ if (d < dist[k]) {
3033
+ dist[k] = d;
3034
+ cls[k] = seedClass[i];
3035
+ }
3036
+ }
3037
+ const D = Math.SQRT2;
3038
+ const relax = (k, j, step) => {
3039
+ const d = dist[j] + step;
3040
+ if (d < dist[k]) {
3041
+ dist[k] = d;
3042
+ cls[k] = cls[j];
3043
+ }
3044
+ };
3045
+ for (let y = 0; y < h; y++) {
3046
+ for (let x = 0; x < w; x++) {
3047
+ const k = y * w + x;
3048
+ if (x > 0) relax(k, k - 1, 1);
3049
+ if (y > 0) {
3050
+ relax(k, k - w, 1);
3051
+ if (x > 0) relax(k, k - w - 1, D);
3052
+ if (x < w - 1) relax(k, k - w + 1, D);
3053
+ }
3054
+ }
3055
+ }
3056
+ for (let y = h - 1; y >= 0; y--) {
3057
+ for (let x = w - 1; x >= 0; x--) {
3058
+ const k = y * w + x;
3059
+ if (x < w - 1) relax(k, k + 1, 1);
3060
+ if (y < h - 1) {
3061
+ relax(k, k + w, 1);
3062
+ if (x < w - 1) relax(k, k + w + 1, D);
3063
+ if (x > 0) relax(k, k + w - 1, D);
3064
+ }
3065
+ }
3066
+ }
3067
+ const out = Float32Array.from(hard);
3068
+ const pad = maxReach + 3 * JOIN_SIGMA + 2;
3069
+ const T = 128;
3070
+ for (let ty = 0; ty < h; ty += T) {
3071
+ for (let tx = 0; tx < w; tx += T) {
3072
+ const tw = Math.min(T, w - tx);
3073
+ const th = Math.min(T, h - ty);
3074
+ let active = false;
3075
+ for (let y = ty; y < ty + th && !active; y++) for (let x = tx; x < tx + tw; x++) if (dist[y * w + x] <= maxReach) {
3076
+ active = true;
3077
+ break;
3078
+ }
3079
+ if (!active) continue;
3080
+ const px0 = Math.max(0, tx - pad);
3081
+ const py0 = Math.max(0, ty - pad);
3082
+ const px1 = Math.min(w, tx + tw + pad);
3083
+ const py1 = Math.min(h, ty + th + pad);
3084
+ const result = solveTile(px0, py0, px1 - px0, py1 - py0);
3085
+ for (let y = ty; y < ty + th; y++) {
3086
+ for (let x = tx; x < tx + tw; x++) {
3087
+ const k = y * w + x;
3088
+ if (dist[k] > maxReach + 3 * JOIN_SIGMA) continue;
3089
+ const v = result[(y - py0) * (px1 - px0) + (x - px0)];
3090
+ if (!Number.isNaN(v)) out[(y + y0) * width + x + x0] = v;
3091
+ }
3092
+ }
3093
+ }
3094
+ }
3095
+ return out;
3096
+ function solveTile(bx, by, bw, bh) {
3097
+ const m = bw * bh;
3098
+ const at = (x, y) => (by + y) * w + bx + x;
3099
+ const Ht = new Float32Array(m);
3100
+ for (let y = 0; y < bh; y++) for (let x = 0; x < bw; x++) Ht[y * bw + x] = hard[(by + y + y0) * width + bx + x + x0];
3101
+ const total = new Float32Array(m);
3102
+ const blended = new Float32Array(m);
3103
+ let guidePlanes = null;
3104
+ const planes = () => {
3105
+ if (guidePlanes) return guidePlanes;
3106
+ const p = [new Float32Array(m), new Float32Array(m), new Float32Array(m)];
3107
+ for (let y = 0; y < bh; y++) {
3108
+ for (let x = 0; x < bw; x++) {
3109
+ const s = ((by + y + y0) * width + bx + x + x0) * 4;
3110
+ const a = guide[s + 3] / 255;
3111
+ for (let c = 0; c < 3; c++) p[c][y * bw + x] = guide[s + c] / 255 * a;
3112
+ }
3113
+ }
3114
+ return guidePlanes = p;
3115
+ };
3116
+ for (let c = 0; c < classes.length; c++) {
3117
+ let weight = new Float32Array(m);
3118
+ let any = false;
3119
+ for (let y = 0; y < bh; y++) {
3120
+ for (let x = 0; x < bw; x++) {
3121
+ const k = at(x, y);
3122
+ const mine = dist[k] <= maxReach ? cls[k] === c : c === 0;
3123
+ if (mine) {
3124
+ weight[y * bw + x] = 1;
3125
+ any = true;
3126
+ }
3127
+ }
3128
+ }
3129
+ if (!any) continue;
3130
+ weight = _chunkK6PXS6DOcjs.gaussianBlur.call(void 0, weight, bw, bh, JOIN_SIGMA, "clamp");
3131
+ const e = classes[c].edge;
3132
+ let cov;
3133
+ if (!e) cov = Ht;
3134
+ else if (e.mode === "feather" || !guide) {
3135
+ const sigma = e.mode === "feather" ? _nullishCoalesce(e.radius, () => ( VECTOR_MASK_EDGE_DEFAULTS.radius)) : ((_nullishCoalesce(e.inner, () => ( VECTOR_MASK_EDGE_DEFAULTS.inner))) + (_nullishCoalesce(e.outer, () => ( VECTOR_MASK_EDGE_DEFAULTS.outer)))) / 3;
3136
+ cov = _chunkK6PXS6DOcjs.gaussianBlur.call(void 0, Ht, bw, bh, sigma, "clamp");
3137
+ } else {
3138
+ const inner = _nullishCoalesce(e.inner, () => ( VECTOR_MASK_EDGE_DEFAULTS.inner));
3139
+ const outer = _nullishCoalesce(e.outer, () => ( VECTOR_MASK_EDGE_DEFAULTS.outer));
3140
+ const r = Math.max(2, Math.round((inner + outer) / 2));
3141
+ const q2 = _chunkSS53NNZOcjs.guidedFilterColor.call(void 0, planes(), Ht, bw, bh, r);
3142
+ cov = new Float32Array(m);
3143
+ for (let y = 0; y < bh; y++) {
3144
+ for (let x = 0; x < bw; x++) {
3145
+ const i = y * bw + x;
3146
+ const inside = Ht[i] >= 0.5;
3147
+ const d = dist[at(x, y)];
3148
+ const unknown = inside ? d <= inner : d <= outer;
3149
+ cov[i] = unknown ? Math.min(1, Math.max(0, q2[i])) : inside ? 1 : 0;
3150
+ }
3151
+ }
3152
+ }
3153
+ for (let i = 0; i < m; i++) {
3154
+ total[i] += weight[i];
3155
+ blended[i] += weight[i] * cov[i];
3156
+ }
3157
+ }
3158
+ const res = new Float32Array(m);
3159
+ for (let i = 0; i < m; i++) res[i] = total[i] > 0 ? blended[i] / total[i] : NaN;
3160
+ return res;
3161
+ }
3162
+ }
3163
+
2949
3164
  // src/image-editor/layers/vector-mask.ts
2950
3165
  function isActiveVectorMask(vm) {
2951
3166
  return Boolean(vm && vm.enabled !== false);
2952
3167
  }
2953
- function vectorMaskCoverage(vm, width, height) {
3168
+ function vectorMaskCoverage(vm, width, height, guide = null) {
2954
3169
  let v = componentsCoverage(vm.components, { x: 0, y: 0, width, height }, _nullishCoalesce(vm.fillRule, () => ( "nonzero")), vm.inverted === true);
3170
+ if (_optionalChain([vm, 'access', _38 => _38.edges, 'optionalAccess', _39 => _39.length])) v = hybridVectorMaskCoverage(vm, v, width, height, guide);
2955
3171
  if ((_nullishCoalesce(vm.feather, () => ( 0))) > 0) v = _chunkK6PXS6DOcjs.gaussianBlur.call(void 0, v, width, height, vm.feather, "clamp");
2956
3172
  const density = _nullishCoalesce(vm.density, () => ( 1));
2957
3173
  if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
@@ -2970,12 +3186,18 @@ function rasterCoverage(mask, ox, oy, width, height) {
2970
3186
  return v;
2971
3187
  }
2972
3188
  var layerOffset = (layer) => layer.type === "pixel" ? layer.offset : { x: 0, y: 0 };
2973
- function effectiveLayerMask(layer, width, height) {
3189
+ function layerGuide(layer, width, height, surfaceOf) {
3190
+ const surface = _nullishCoalesce(_optionalChain([surfaceOf, 'optionalCall', _40 => _40(layer)]), () => ( layer.surface));
3191
+ if (!surface || surface.channels !== 4) return null;
3192
+ const { x: ox, y: oy } = layerOffset(layer);
3193
+ return _chunk474IQG74cjs.readRegion.call(void 0, surface, { x: -ox, y: -oy, width, height });
3194
+ }
3195
+ function effectiveLayerMask(layer, width, height, surfaceOf) {
2974
3196
  const vm = layer.vectorMask;
2975
3197
  const raster = layer.mask;
2976
- if (!isActiveVectorMask(vm) || _optionalChain([raster, 'optionalAccess', _34 => _34.source]) || width < 1 || height < 1) return raster;
3198
+ if (!isActiveVectorMask(vm) || _optionalChain([raster, 'optionalAccess', _41 => _41.source]) || width < 1 || height < 1) return raster;
2977
3199
  const { x: ox, y: oy } = layerOffset(layer);
2978
- const v = vectorMaskCoverage(vm, width, height);
3200
+ const v = vectorMaskCoverage(vm, width, height, _optionalChain([vm, 'access', _42 => _42.edges, 'optionalAccess', _43 => _43.length]) ? layerGuide(layer, width, height, surfaceOf) : null);
2979
3201
  let outside = outsideValue(vm);
2980
3202
  if (raster && raster.enabled !== false) {
2981
3203
  const r = rasterCoverage(raster, ox, oy, width, height);
@@ -2995,17 +3217,17 @@ function hasVectorMask(layers) {
2995
3217
  }
2996
3218
  return false;
2997
3219
  }
2998
- function resolveVectorMasks(layers, width, height) {
3220
+ function resolveVectorMasks(layers, width, height, surfaceOf) {
2999
3221
  if (!hasVectorMask(layers)) return layers;
3000
- return layers.map((l) => resolveLayer(l, width, height));
3222
+ return layers.map((l) => resolveLayer(l, width, height, surfaceOf));
3001
3223
  }
3002
- function resolveLayer(layer, width, height) {
3224
+ function resolveLayer(layer, width, height, surfaceOf) {
3003
3225
  let next = layer;
3004
3226
  if (layer.type === "group" && hasVectorMask(layer.children)) {
3005
3227
  const key2 = `${width}x${height}`;
3006
3228
  const hit2 = resolved.get(layer);
3007
- if (_optionalChain([hit2, 'optionalAccess', _35 => _35.key]) === key2) return hit2.layer;
3008
- next = { ...layer, children: layer.children.map((c) => resolveLayer(c, width, height)) };
3229
+ if (_optionalChain([hit2, 'optionalAccess', _44 => _44.key]) === key2) return hit2.layer;
3230
+ next = { ...layer, children: layer.children.map((c) => resolveLayer(c, width, height, surfaceOf)) };
3009
3231
  if (!isActiveVectorMask(layer.vectorMask)) {
3010
3232
  resolved.set(layer, { key: key2, layer: next });
3011
3233
  return next;
@@ -3014,8 +3236,8 @@ function resolveLayer(layer, width, height) {
3014
3236
  if (!isActiveVectorMask(layer.vectorMask)) return layer;
3015
3237
  const key = `${width}x${height}:v`;
3016
3238
  const hit = resolved.get(layer);
3017
- if (_optionalChain([hit, 'optionalAccess', _36 => _36.key]) === key) return hit.layer;
3018
- const mask = effectiveLayerMask(layer, width, height);
3239
+ if (_optionalChain([hit, 'optionalAccess', _45 => _45.key]) === key) return hit.layer;
3240
+ const mask = effectiveLayerMask(layer, width, height, surfaceOf);
3019
3241
  const out = { ...next, mask };
3020
3242
  delete out.vectorMask;
3021
3243
  if (!mask) delete out.mask;
@@ -3059,7 +3281,7 @@ var thumbCache = /* @__PURE__ */ new WeakMap();
3059
3281
  function vectorMaskThumbnail(vm, width, height, maxSide = 64) {
3060
3282
  const key = `${width}x${height}:${maxSide}`;
3061
3283
  const hit = thumbCache.get(vm);
3062
- if (_optionalChain([hit, 'optionalAccess', _37 => _37.key]) === key) return hit.pixels;
3284
+ if (_optionalChain([hit, 'optionalAccess', _46 => _46.key]) === key) return hit.pixels;
3063
3285
  const k = Math.min(1, maxSide / Math.max(1, width, height));
3064
3286
  const tw = Math.max(1, Math.round(width * k));
3065
3287
  const th = Math.max(1, Math.round(height * k));
@@ -3095,7 +3317,7 @@ function isPaintableLayer(layer) {
3095
3317
  function defaultActiveLayerId(layers) {
3096
3318
  const pixels = _chunkB46UQUDCcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
3097
3319
  for (let i = pixels.length - 1; i >= 0; i--) if (isPaintableLayer(pixels[i])) return pixels[i].id;
3098
- return _nullishCoalesce(_optionalChain([pixels, 'access', _38 => _38[pixels.length - 1], 'optionalAccess', _39 => _39.id]), () => ( null));
3320
+ return _nullishCoalesce(_optionalChain([pixels, 'access', _47 => _47[pixels.length - 1], 'optionalAccess', _48 => _48.id]), () => ( null));
3099
3321
  }
3100
3322
  function activeLayerAfterRemoval(prev, next, removedId) {
3101
3323
  const before = _chunkB46UQUDCcjs.flattenLayers.call(void 0, prev);
@@ -3126,7 +3348,7 @@ function placeLayer(layers, layer, placement = {}, defaultIndex) {
3126
3348
  if (given > 1) fail2("Give only one of aboveId, belowId and parentId.");
3127
3349
  if (placement.aboveId || placement.belowId) {
3128
3350
  const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
3129
- return _chunkB46UQUDCcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _40 => _40.parent, 'optionalAccess', _41 => _41.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
3351
+ return _chunkB46UQUDCcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _49 => _49.parent, 'optionalAccess', _50 => _50.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
3130
3352
  }
3131
3353
  if (placement.parentId) {
3132
3354
  const ref = requireLayer(layers, placement.parentId);
@@ -3158,7 +3380,7 @@ function withNewIds(layer) {
3158
3380
  if (next.type === "group") next.children = next.children.map(withNewIds);
3159
3381
  if (next.type === "annotation") next.annotation = { ...next.annotation, id: next.id };
3160
3382
  if (next.type === "shape" || next.type === "type") delete next.annotation;
3161
- if (next.type === "smart" && _optionalChain([next, 'access', _42 => _42.psd, 'optionalAccess', _43 => _43.placed])) {
3383
+ if (next.type === "smart" && _optionalChain([next, 'access', _51 => _51.psd, 'optionalAccess', _52 => _52.placed])) {
3162
3384
  next.psd = { ...next.psd };
3163
3385
  delete next.psd.placed;
3164
3386
  }
@@ -3169,7 +3391,7 @@ function duplicateLayer(layers, id, name) {
3169
3391
  const copy = withNewIds(loc.layer);
3170
3392
  copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
3171
3393
  delete copy.locks;
3172
- return { layers: _chunkB46UQUDCcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _44 => _44.parent, 'optionalAccess', _45 => _45.id]), () => ( null)), loc.index + 1), id: copy.id };
3394
+ return { layers: _chunkB46UQUDCcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _53 => _53.parent, 'optionalAccess', _54 => _54.id]), () => ( null)), loc.index + 1), id: copy.id };
3173
3395
  }
3174
3396
  function setLayerProperties(layers, id, props) {
3175
3397
  const loc = requireLayer(layers, id);
@@ -3221,8 +3443,8 @@ function setLayerProperties(layers, id, props) {
3221
3443
  function groupLayers(layers, ids, name = "Group") {
3222
3444
  if (!ids.length) fail2("Give at least one layer id to group.");
3223
3445
  const locs = ids.map((id) => requireLayer(layers, id));
3224
- const parent = _nullishCoalesce(_optionalChain([locs, 'access', _46 => _46[0], 'access', _47 => _47.parent, 'optionalAccess', _48 => _48.id]), () => ( null));
3225
- if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _49 => _49.parent, 'optionalAccess', _50 => _50.id]), () => ( null))) !== parent)) fail2("Layers to group must share one parent; move them next to each other first.");
3446
+ const parent = _nullishCoalesce(_optionalChain([locs, 'access', _55 => _55[0], 'access', _56 => _56.parent, 'optionalAccess', _57 => _57.id]), () => ( null));
3447
+ if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _58 => _58.parent, 'optionalAccess', _59 => _59.id]), () => ( null))) !== parent)) fail2("Layers to group must share one parent; move them next to each other first.");
3226
3448
  for (const l of locs) requireUnlocked(l.layer, "all", "group it");
3227
3449
  const ordered = [...new Set(locs)].sort((a, b) => a.index - b.index);
3228
3450
  const top = ordered[ordered.length - 1].index;
@@ -3239,7 +3461,7 @@ function groupLayers(layers, ids, name = "Group") {
3239
3461
  return c;
3240
3462
  })
3241
3463
  };
3242
- if (_optionalChain([group, 'access', _51 => _51.children, 'access', _52 => _52[0], 'optionalAccess', _53 => _53.clipped])) {
3464
+ if (_optionalChain([group, 'access', _60 => _60.children, 'access', _61 => _61[0], 'optionalAccess', _62 => _62.clipped])) {
3243
3465
  const c = { ...group.children[0] };
3244
3466
  delete c.clipped;
3245
3467
  group.children[0] = c;
@@ -3255,7 +3477,7 @@ function ungroupLayer(layers, id) {
3255
3477
  const group = loc.layer;
3256
3478
  let out = _chunkB46UQUDCcjs.mapLayer.call(void 0, layers, id, () => null);
3257
3479
  group.children.forEach((c, i) => {
3258
- out = _chunkB46UQUDCcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _54 => _54.parent, 'optionalAccess', _55 => _55.id]), () => ( null)), loc.index + i);
3480
+ out = _chunkB46UQUDCcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _63 => _63.parent, 'optionalAccess', _64 => _64.id]), () => ( null)), loc.index + i);
3259
3481
  });
3260
3482
  return { layers: out, ids: group.children.map((c) => c.id) };
3261
3483
  }
@@ -3313,7 +3535,7 @@ function requirePixelLayer(layers, id) {
3313
3535
  }
3314
3536
  function addLayerFilter(layers, id, filter) {
3315
3537
  const layer = requirePixelLayer(layers, id);
3316
- if (_optionalChain([layer, 'access', _56 => _56.filters, 'optionalAccess', _57 => _57.some, 'call', _58 => _58((f) => f.kind === filter.kind)])) fail2(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
3538
+ if (_optionalChain([layer, 'access', _65 => _65.filters, 'optionalAccess', _66 => _66.some, 'call', _67 => _67((f) => f.kind === filter.kind)])) fail2(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
3317
3539
  return _chunkB46UQUDCcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
3318
3540
  }
3319
3541
  function updateLayerFilter(layers, id, filterId, changes) {
@@ -3377,7 +3599,7 @@ function addLayerEffect(layers, id, kind, params = {}, index) {
3377
3599
  return { layers: setLayerEffects(layers, id, { ...current, items }), effect };
3378
3600
  }
3379
3601
  function requireEffect(layer, effectId) {
3380
- const items = _nullishCoalesce(_optionalChain([layer, 'access', _59 => _59.effects, 'optionalAccess', _60 => _60.items]), () => ( []));
3602
+ const items = _nullishCoalesce(_optionalChain([layer, 'access', _68 => _68.effects, 'optionalAccess', _69 => _69.items]), () => ( []));
3381
3603
  const i = items.findIndex((e) => e.id === effectId);
3382
3604
  if (i === -1) fail2(`Layer "${layer.name || layer.id}" has no effect "${effectId}". Effects: ${items.map((e) => `${e.id} (${e.kind})`).join(", ") || "none"}; call list_layer_effects.`);
3383
3605
  return i;
@@ -3560,6 +3782,11 @@ function filterReach(filters) {
3560
3782
  return r;
3561
3783
  }
3562
3784
  var filterSpecCache = /* @__PURE__ */ new WeakMap();
3785
+ function guideSurfaces(sources) {
3786
+ const of = sources.surfaceOf;
3787
+ if (!of) return void 0;
3788
+ return (l) => l.type === "pixel" || l.type === "smart" ? of(l) : void 0;
3789
+ }
3563
3790
  var maskIds = /* @__PURE__ */ new WeakMap();
3564
3791
  var nextMaskId = 1;
3565
3792
  var edgeSpecCache = /* @__PURE__ */ new WeakMap();
@@ -3575,10 +3802,10 @@ function edgeFilterSpec(layer) {
3575
3802
  const ox = layer.offset.x;
3576
3803
  const oy = layer.offset.y;
3577
3804
  const spec = {
3578
- key: `edge:${JSON.stringify([_nullishCoalesce(edge.decontaminate, () => ( 0)), _nullishCoalesce(edge.despill, () => ( 0)), id, ox, oy, _nullishCoalesce(mask.feather, () => ( 0))])}|${_nullishCoalesce(_optionalChain([filters, 'optionalAccess', _61 => _61.key]), () => ( ""))}`,
3805
+ key: `edge:${JSON.stringify([_nullishCoalesce(edge.decontaminate, () => ( 0)), _nullishCoalesce(edge.despill, () => ( 0)), id, ox, oy, _nullishCoalesce(mask.feather, () => ( 0))])}|${_nullishCoalesce(_optionalChain([filters, 'optionalAccess', _70 => _70.key]), () => ( ""))}`,
3579
3806
  spatial: true,
3580
3807
  apply: (data, width, height) => {
3581
- _optionalChain([filters, 'optionalAccess', _62 => _62.apply, 'call', _63 => _63(data, width, height)]);
3808
+ _optionalChain([filters, 'optionalAccess', _71 => _71.apply, 'call', _72 => _72(data, width, height)]);
3582
3809
  applyEdgeUnmix(data, maskCoverageOverCanvas(mask, ox, oy, width, height), width, height, edge);
3583
3810
  }
3584
3811
  };
@@ -3587,7 +3814,7 @@ function edgeFilterSpec(layer) {
3587
3814
  }
3588
3815
  function pixelFilterSpec(layer) {
3589
3816
  const list2 = layer.filters;
3590
- if (!_optionalChain([list2, 'optionalAccess', _64 => _64.length])) return null;
3817
+ if (!_optionalChain([list2, 'optionalAccess', _73 => _73.length])) return null;
3591
3818
  if (filterSpecCache.has(list2)) return filterSpecCache.get(list2);
3592
3819
  const filters = list2.filter(isActiveFilter);
3593
3820
  let spec = null;
@@ -3608,7 +3835,7 @@ var PHOTO_PROFILE = {
3608
3835
  const views = layers.map(adjustmentNodeAsLayer);
3609
3836
  applyAdjustmentLayers({ data: acc }, views, masks);
3610
3837
  },
3611
- contentTile: (l, r, sources) => l.type === "annotation" ? _nullishCoalesce(_optionalChain([sources, 'access', _65 => _65.rasterizeAnnotation, 'optionalCall', _66 => _66(l.annotation, r)]), () => ( null)) : null,
3838
+ contentTile: (l, r, sources) => l.type === "annotation" ? _nullishCoalesce(_optionalChain([sources, 'access', _74 => _74.rasterizeAnnotation, 'optionalCall', _75 => _75(l.annotation, r)]), () => ( null)) : null,
3612
3839
  /** Annotation layers draw with their annotation's blend mode unless the layer sets one. */
3613
3840
  contentBlend: (l) => l.type === "annotation" && l.blend === "normal" && l.annotation.blend ? l.annotation.blend : l.blend,
3614
3841
  layerKey: (l) => l.type === "pixel" ? [_nullishCoalesce(l.filters, () => ( null)), _nullishCoalesce(l.source, () => ( null))] : l.type === "adjustment" ? [l.kind, l.params] : l.type === "annotation" ? l.annotation : void 0,
@@ -3620,7 +3847,7 @@ var PHOTO_PROFILE = {
3620
3847
  isPixelLike: (l) => l.type === "smart" || l.type === "shape" || l.type === "type",
3621
3848
  maskSourcePlane: (source, W, H, sources) => {
3622
3849
  const opts = source;
3623
- const depth = _nullishCoalesce(_optionalChain([sources, 'access', _67 => _67.depthMap, 'optionalCall', _68 => _68(opts)]), () => ( null));
3850
+ const depth = _nullishCoalesce(_optionalChain([sources, 'access', _76 => _76.depthMap, 'optionalCall', _77 => _77(opts)]), () => ( null));
3624
3851
  if (!depth || depth.width !== W || depth.height !== H) return null;
3625
3852
  const v = new Float32Array(W * H);
3626
3853
  for (let i = 0; i < v.length; i++) v[i] = depthMaskAlpha(depth.data[i * 4], opts) / 255;
@@ -3633,13 +3860,13 @@ var LayerCompositor = class extends _chunkB46UQUDCcjs.RasterCompositor {
3633
3860
  }
3634
3861
  // Vector masks reach the engine as part of each layer's raster mask (see `resolveVectorMasks`).
3635
3862
  composite(layers, rect, sources, options) {
3636
- return super.composite(resolveVectorMasks(layers, sources.width, sources.height), rect, sources, options);
3863
+ return super.composite(resolveVectorMasks(layers, sources.width, sources.height, guideSurfaces(sources)), rect, sources, options);
3637
3864
  }
3638
3865
  compositeTiles(layers, rect, sources, onTile, options) {
3639
- super.compositeTiles(resolveVectorMasks(layers, sources.width, sources.height), rect, sources, onTile, options);
3866
+ super.compositeTiles(resolveVectorMasks(layers, sources.width, sources.height, guideSurfaces(sources)), rect, sources, onTile, options);
3640
3867
  }
3641
3868
  tile(layers, tx, ty, sources) {
3642
- return super.tile(resolveVectorMasks(layers, sources.width, sources.height), tx, ty, sources);
3869
+ return super.tile(resolveVectorMasks(layers, sources.width, sources.height, guideSurfaces(sources)), tx, ty, sources);
3643
3870
  }
3644
3871
  };
3645
3872
  function compositeDeep(layers, rect, sources, depth) {
@@ -3652,7 +3879,7 @@ function compositeDeep(layers, rect, sources, depth) {
3652
3879
  return { reach: filterReach(filters), apply: (data, width, height, linear) => runLayerFiltersFloat(data, width, height, filters, linear) };
3653
3880
  }
3654
3881
  }, depth);
3655
- return deep.composite(resolveVectorMasks(layers, sources.width, sources.height), rect, sources);
3882
+ return deep.composite(resolveVectorMasks(layers, sources.width, sources.height, guideSurfaces(sources)), rect, sources);
3656
3883
  }
3657
3884
 
3658
3885
  // src/image-editor/layers/text.ts
@@ -3719,7 +3946,7 @@ function textOutlines(layer, shaper) {
3719
3946
  }
3720
3947
  var rgbOf = (hex) => {
3721
3948
  const c = _chunkA2IS7EHEcjs.parseCssColor.call(void 0, hex);
3722
- const h = (_nullishCoalesce(_optionalChain([c, 'optionalAccess', _69 => _69.hex]), () => ( "#000000"))).slice(1);
3949
+ const h = (_nullishCoalesce(_optionalChain([c, 'optionalAccess', _78 => _78.hex]), () => ( "#000000"))).slice(1);
3723
3950
  return [parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16)];
3724
3951
  };
3725
3952
  function renderOutlines(layer, shaper, region) {
@@ -3939,7 +4166,7 @@ function createTypeLayer(init, env, id = newLayerId(), lenient = false) {
3939
4166
  surface: _chunk474IQG74cjs.emptySurface.call(void 0, 4),
3940
4167
  offset: { x: 0, y: 0 }
3941
4168
  };
3942
- if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _70 => _70.runs, 'access', _71 => _71[0], 'optionalAccess', _72 => _72.style]), () => ( _chunkQAUIZPYIcjs.DEFAULT_TEXT_STYLE)) }];
4169
+ if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _79 => _79.runs, 'access', _80 => _80[0], 'optionalAccess', _81 => _81.style]), () => ( _chunkQAUIZPYIcjs.DEFAULT_TEXT_STYLE)) }];
3943
4170
  if (init.transform && !_chunkQAUIZPYIcjs.isIdentityMatrix.call(void 0, init.transform)) layer.transform = init.transform;
3944
4171
  if (lenient && !renderText(layer, env)) return { ...layer, rendering: "stored" };
3945
4172
  return rerenderText(layer, env);
@@ -3951,7 +4178,7 @@ function updateTypeLayer(layers, id, change, env, action = "edit it") {
3951
4178
  const next = { ...current, ...patch };
3952
4179
  if (!("annotation" in patch)) delete next.annotation;
3953
4180
  if (next.orientation !== "vertical") delete next.orientation;
3954
- if ("text" in patch || "runs" in patch) next.runs = _chunkQAUIZPYIcjs.fitRuns.call(void 0, next.runs, next.text.length, _nullishCoalesce(_optionalChain([current, 'access', _73 => _73.runs, 'access', _74 => _74[0], 'optionalAccess', _75 => _75.style]), () => ( _chunkQAUIZPYIcjs.DEFAULT_TEXT_STYLE)));
4181
+ if ("text" in patch || "runs" in patch) next.runs = _chunkQAUIZPYIcjs.fitRuns.call(void 0, next.runs, next.text.length, _nullishCoalesce(_optionalChain([current, 'access', _82 => _82.runs, 'access', _83 => _83[0], 'optionalAccess', _84 => _84.style]), () => ( _chunkQAUIZPYIcjs.DEFAULT_TEXT_STYLE)));
3955
4182
  if (!next.runs.length) next.runs = [{ length: 0, style: _chunkQAUIZPYIcjs.styleAt.call(void 0, current.runs, 0, _chunkQAUIZPYIcjs.DEFAULT_TEXT_STYLE) }];
3956
4183
  if ("text" in patch || "paragraphs" in patch) next.paragraphs = _chunkQAUIZPYIcjs.fitParagraphRuns.call(void 0, next.paragraphs, next.text);
3957
4184
  const rendered = rerenderText(next, env);
@@ -4238,7 +4465,7 @@ function legacyView(stack, width, height, activeLayerId = null) {
4238
4465
  const { layers } = stack;
4239
4466
  const target = developTarget(layers, activeLayerId);
4240
4467
  const develop = target ? developFilter(target) : void 0;
4241
- const blur = _nullishCoalesce(_nullishCoalesce(stack.legacyOutputBlur, () => ( (target ? _optionalChain([blurFilter, 'call', _76 => _76(target), 'optionalAccess', _77 => _77.radius]) : void 0))), () => ( 0));
4468
+ const blur = _nullishCoalesce(_nullishCoalesce(stack.legacyOutputBlur, () => ( (target ? _optionalChain([blurFilter, 'call', _85 => _85(target), 'optionalAccess', _86 => _86.radius]) : void 0))), () => ( 0));
4242
4469
  const adjustments = {
4243
4470
  ...DEFAULT_ADJUSTMENTS_VALUES,
4244
4471
  ...develop ? {
@@ -4267,7 +4494,7 @@ function legacyView(stack, width, height, activeLayerId = null) {
4267
4494
  };
4268
4495
  walk(layers);
4269
4496
  if (adjNodes.length) adjustments.layers = adjNodes.map((n) => legacyAdjustmentLayer(n, width, height));
4270
- const depthSource = _optionalChain([target, 'optionalAccess', _78 => _78.mask, 'optionalAccess', _79 => _79.source]);
4497
+ const depthSource = _optionalChain([target, 'optionalAccess', _87 => _87.mask, 'optionalAccess', _88 => _88.source]);
4271
4498
  const depthMask = depthSource ? { ...depthSource, depthRange: [...depthSource.depthRange] } : { ...DEFAULT_DEPTH_MASK_VALUES, depthRange: [...DEFAULT_DEPTH_MASK_VALUES.depthRange] };
4272
4499
  return { adjustments, depthMask, annotations, exact: isLegacyShape(stack) };
4273
4500
  }
@@ -4292,7 +4519,7 @@ function isLegacyShape(stack) {
4292
4519
  let adjustments = 0;
4293
4520
  for (; i < layers.length && layers[i].type === "adjustment"; i++) {
4294
4521
  const l = layers[i];
4295
- if (l.clipped || l.locks || _optionalChain([l, 'access', _80 => _80.mask, 'optionalAccess', _81 => _81.source]) || l.effects) return false;
4522
+ if (l.clipped || l.locks || _optionalChain([l, 'access', _89 => _89.mask, 'optionalAccess', _90 => _90.source]) || l.effects) return false;
4296
4523
  adjustments++;
4297
4524
  }
4298
4525
  for (; i < layers.length; i++) {
@@ -4499,7 +4726,7 @@ function isContentsDecoded(contents) {
4499
4726
  }
4500
4727
  function requireDecoded(layer, action) {
4501
4728
  if (isContentsDecoded(layer.contents)) return;
4502
- const what = _optionalChain([layer, 'access', _82 => _82.contents, 'access', _83 => _83.file, 'optionalAccess', _84 => _84.type]) ? `a ${layer.contents.file.type.toUpperCase()} file` : "a file";
4729
+ const what = _optionalChain([layer, 'access', _91 => _91.contents, 'access', _92 => _92.file, 'optionalAccess', _93 => _93.type]) ? `a ${layer.contents.file.type.toUpperCase()} file` : "a file";
4503
4730
  fail4(
4504
4731
  `The contents of smart object "${layer.name || layer.id}" are ${what} that could not be decoded here, so it cannot ${action}. Run prepareSmartObjects() in a browser first, or rasterize it.`
4505
4732
  );
@@ -4524,7 +4751,7 @@ function contentsSurface(contents) {
4524
4751
  width: W,
4525
4752
  height: H,
4526
4753
  globalLight: doc.globalLight,
4527
- pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access', _85 => _85.patterns, 'optionalAccess', _86 => _86.find, 'call', _87 => _87((p) => p.id === id)]), () => ( null))
4754
+ pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access', _94 => _94.patterns, 'optionalAccess', _95 => _95.find, 'call', _96 => _96((p) => p.id === id)]), () => ( null))
4528
4755
  });
4529
4756
  s = _chunk474IQG74cjs.surfaceFromPixels.call(void 0, { width: W, height: H, data }, 4, 0, 0);
4530
4757
  }
@@ -4559,7 +4786,7 @@ function placeContents(layer, canvas, options = {}) {
4559
4786
  const preview = Boolean(options.step && options.step > 1) || Boolean(options.clip);
4560
4787
  const key = placementKey(placement, canvas);
4561
4788
  if (!preview) {
4562
- const hit = _optionalChain([placedCache, 'access', _88 => _88.get, 'call', _89 => _89(contents), 'optionalAccess', _90 => _90.get, 'call', _91 => _91(key)]);
4789
+ const hit = _optionalChain([placedCache, 'access', _97 => _97.get, 'call', _98 => _98(contents), 'optionalAccess', _99 => _99.get, 'call', _100 => _100(key)]);
4563
4790
  if (hit) return hit;
4564
4791
  }
4565
4792
  const src = contentsSurface(contents);
@@ -4586,10 +4813,10 @@ function placeContents(layer, canvas, options = {}) {
4586
4813
  let k = 1;
4587
4814
  if (step > 1) {
4588
4815
  k = step;
4589
- let r = _optionalChain([options, 'access', _92 => _92.reduced, 'optionalAccess', _93 => _93.get, 'call', _94 => _94(k)]);
4816
+ let r = _optionalChain([options, 'access', _101 => _101.reduced, 'optionalAccess', _102 => _102.get, 'call', _103 => _103(k)]);
4590
4817
  if (!r) {
4591
4818
  r = _chunkB46UQUDCcjs.reduceSurface.call(void 0, src, k);
4592
- _optionalChain([options, 'access', _95 => _95.reduced, 'optionalAccess', _96 => _96.set, 'call', _97 => _97(k, r)]);
4819
+ _optionalChain([options, 'access', _104 => _104.reduced, 'optionalAccess', _105 => _105.set, 'call', _106 => _106(k, r)]);
4593
4820
  }
4594
4821
  source = r;
4595
4822
  }
@@ -4622,15 +4849,15 @@ function placeContents(layer, canvas, options = {}) {
4622
4849
  return out;
4623
4850
  }
4624
4851
  function activeSmartFilters(stack) {
4625
- if (!_optionalChain([stack, 'optionalAccess', _98 => _98.enabled])) return [];
4852
+ if (!_optionalChain([stack, 'optionalAccess', _107 => _107.enabled])) return [];
4626
4853
  return stack.filters.filter((f) => f.kind !== "psd" && f.kind !== "effect" && isActiveFilter(f) && f.opacity > 0);
4627
4854
  }
4628
4855
  function activeEffectSmartFilters(stack) {
4629
- if (!_optionalChain([stack, 'optionalAccess', _99 => _99.enabled])) return [];
4856
+ if (!_optionalChain([stack, 'optionalAccess', _108 => _108.enabled])) return [];
4630
4857
  return stack.filters.filter((f) => f.kind === "effect" && f.enabled && f.opacity > 0);
4631
4858
  }
4632
4859
  function runnableSmartFilters(stack) {
4633
- if (!_optionalChain([stack, 'optionalAccess', _100 => _100.enabled])) return [];
4860
+ if (!_optionalChain([stack, 'optionalAccess', _109 => _109.enabled])) return [];
4634
4861
  return stack.filters.filter((f) => f.opacity > 0 && (f.kind === "effect" ? f.enabled : f.kind !== "psd" && isActiveFilter(f)));
4635
4862
  }
4636
4863
  function filterMaskCoverage(mask, canvas) {
@@ -4656,7 +4883,7 @@ function applySmartFilters(placed, stack, canvas) {
4656
4883
  if (!active.length || !(canvas.width > 0 && canvas.height > 0)) return placed;
4657
4884
  const W = canvas.width;
4658
4885
  const H = canvas.height;
4659
- const token = active.some((f) => f.kind === "effect") ? _nullishCoalesce(_optionalChain([canvas, 'access', _101 => _101.effects, 'optionalAccess', _102 => _102.token]), () => ( -1)) : 0;
4886
+ const token = active.some((f) => f.kind === "effect") ? _nullishCoalesce(_optionalChain([canvas, 'access', _110 => _110.effects, 'optionalAccess', _111 => _111.token]), () => ( -1)) : 0;
4660
4887
  const key = JSON.stringify([W, H, token, active.map((f) => ({ ...f, id: void 0 }))]);
4661
4888
  let entry = filteredCache.get(placed);
4662
4889
  let incomplete = false;
@@ -4668,9 +4895,9 @@ function applySmartFilters(placed, stack, canvas) {
4668
4895
  if (f.kind === "effect") {
4669
4896
  if (incomplete) continue;
4670
4897
  const inputKey = JSON.stringify([surfaceId(placed), W, H, active.slice(0, i + 1).map((x) => ({ ...x, id: void 0, blend: x === f ? void 0 : x.blend, opacity: x === f ? void 0 : x.opacity }))]);
4671
- const r = _optionalChain([canvas, 'access', _103 => _103.effects, 'optionalAccess', _104 => _104.resolve, 'call', _105 => _105(f, acc, W, H, inputKey)]);
4672
- if (!_optionalChain([r, 'optionalAccess', _106 => _106.result])) {
4673
- if (_optionalChain([r, 'optionalAccess', _107 => _107.pending])) incomplete = true;
4898
+ const r = _optionalChain([canvas, 'access', _112 => _112.effects, 'optionalAccess', _113 => _113.resolve, 'call', _114 => _114(f, acc, W, H, inputKey)]);
4899
+ if (!_optionalChain([r, 'optionalAccess', _115 => _115.result])) {
4900
+ if (_optionalChain([r, 'optionalAccess', _116 => _116.pending])) incomplete = true;
4674
4901
  continue;
4675
4902
  }
4676
4903
  out2 = new Uint8ClampedArray(r.result);
@@ -4721,7 +4948,7 @@ function rerender(layer, canvas, action = "change") {
4721
4948
  return { ...layer, surface: renderSmartObject(layer, canvas) };
4722
4949
  }
4723
4950
  function normalizePlacement(raw, contents) {
4724
- const c = _optionalChain([raw, 'optionalAccess', _108 => _108.corners]);
4951
+ const c = _optionalChain([raw, 'optionalAccess', _117 => _117.corners]);
4725
4952
  if (!Array.isArray(c) || c.length !== 4 || !c.every((p) => p && Number.isFinite(p.x) && Number.isFinite(p.y))) {
4726
4953
  fail4("corners must be four finite points [top-left, top-right, bottom-right, bottom-left] in document pixels.");
4727
4954
  }
@@ -4766,7 +4993,7 @@ function setSmartPlacement(layers, id, placement, canvas) {
4766
4993
  masksMoved ||= m !== layer.mask;
4767
4994
  next.mask = m;
4768
4995
  }
4769
- if (_optionalChain([next, 'access', _109 => _109.smartFilters, 'optionalAccess', _110 => _110.mask])) {
4996
+ if (_optionalChain([next, 'access', _118 => _118.smartFilters, 'optionalAccess', _119 => _119.mask])) {
4770
4997
  const m = followMask(next.smartFilters.mask, layer, next);
4771
4998
  masksMoved ||= m !== next.smartFilters.mask;
4772
4999
  next.smartFilters = { ...next.smartFilters, mask: m };
@@ -4784,13 +5011,13 @@ function offsetSmartObject(layers, id, dx, dy, canvas) {
4784
5011
  let next = { ...layer, placement: { ...layer.placement, corners } };
4785
5012
  const moveMask = (m2) => m2 && m2.linked !== false && !m2.source ? { ...m2, surface: _chunk474IQG74cjs.translateSurface.call(void 0, m2.surface, mx, my) } : m2;
4786
5013
  if (layer.mask) next.mask = moveMask(layer.mask);
4787
- if (_optionalChain([layer, 'access', _111 => _111.smartFilters, 'optionalAccess', _112 => _112.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
5014
+ if (_optionalChain([layer, 'access', _120 => _120.smartFilters, 'optionalAccess', _121 => _121.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
4788
5015
  next = followLayerMove(next, mx, my);
4789
5016
  const spatial = activeSmartFilters(layer.smartFilters).some((f) => f.kind === "blur") || activeEffectSmartFilters(layer.smartFilters).length > 0;
4790
5017
  const b = _chunk474IQG74cjs.contentBounds.call(void 0, layer.surface);
4791
5018
  const m = SMART_RENDER_MARGIN;
4792
5019
  const cut = b && (b.x <= -m || b.y <= -m || b.x + b.width >= canvas.width + m || b.y + b.height >= canvas.height + m);
4793
- if (!spatial && !cut && !(_optionalChain([next, 'access', _113 => _113.smartFilters, 'optionalAccess', _114 => _114.mask]) && activeSmartFilters(next.smartFilters).length && next.smartFilters.mask.linked === false)) {
5020
+ if (!spatial && !cut && !(_optionalChain([next, 'access', _122 => _122.smartFilters, 'optionalAccess', _123 => _123.mask]) && activeSmartFilters(next.smartFilters).length && next.smartFilters.mask.linked === false)) {
4794
5021
  next = { ...next, surface: _chunk474IQG74cjs.translateSurface.call(void 0, layer.surface, mx, my) };
4795
5022
  } else {
4796
5023
  next = rerender(next, canvas, "move");
@@ -4815,7 +5042,7 @@ function translateLayer(layer, dx, dy) {
4815
5042
  mask: moveMask(layer.mask)
4816
5043
  };
4817
5044
  if (!next.mask) delete next.mask;
4818
- if (_optionalChain([layer, 'access', _115 => _115.smartFilters, 'optionalAccess', _116 => _116.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
5045
+ if (_optionalChain([layer, 'access', _124 => _124.smartFilters, 'optionalAccess', _125 => _125.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
4819
5046
  return next;
4820
5047
  }
4821
5048
  case "group": {
@@ -4875,14 +5102,14 @@ function union(a, b) {
4875
5102
  return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };
4876
5103
  }
4877
5104
  function asSmartFilters(filters) {
4878
- if (!_optionalChain([filters, 'optionalAccess', _117 => _117.length])) return void 0;
5105
+ if (!_optionalChain([filters, 'optionalAccess', _126 => _126.length])) return void 0;
4879
5106
  return { enabled: true, filters: filters.map((f) => ({ ...f, blend: "normal", opacity: 1 })) };
4880
5107
  }
4881
5108
  function convertToSmartObject(layers, ids, canvas, options) {
4882
5109
  if (!ids.length) fail4("Give at least one layer id to convert.");
4883
5110
  const locs = [...new Set(ids)].map((id) => requireLayer(layers, id));
4884
- const parent = _nullishCoalesce(_optionalChain([locs, 'access', _118 => _118[0], 'access', _119 => _119.parent, 'optionalAccess', _120 => _120.id]), () => ( null));
4885
- if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _121 => _121.parent, 'optionalAccess', _122 => _122.id]), () => ( null))) !== parent)) fail4("Layers to convert must share one parent; move them next to each other first.");
5111
+ const parent = _nullishCoalesce(_optionalChain([locs, 'access', _127 => _127[0], 'access', _128 => _128.parent, 'optionalAccess', _129 => _129.id]), () => ( null));
5112
+ if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _130 => _130.parent, 'optionalAccess', _131 => _131.id]), () => ( null))) !== parent)) fail4("Layers to convert must share one parent; move them next to each other first.");
4886
5113
  for (const l of locs) requireUnlocked(l.layer, "all", "convert it");
4887
5114
  const ordered = locs.sort((a, b) => a.index - b.index);
4888
5115
  const top = ordered[ordered.length - 1];
@@ -4940,7 +5167,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
4940
5167
  delete first.clipped;
4941
5168
  nested[0] = first;
4942
5169
  }
4943
- const name = _optionalChain([options, 'access', _123 => _123.name, 'optionalAccess', _124 => _124.trim, 'call', _125 => _125()]) || top.layer.name || "Smart Object";
5170
+ const name = _optionalChain([options, 'access', _132 => _132.name, 'optionalAccess', _133 => _133.trim, 'call', _134 => _134()]) || top.layer.name || "Smart Object";
4944
5171
  const contents = documentContents({ layers: nested }, b.width, b.height, `${name}.psb`);
4945
5172
  smart = {
4946
5173
  type: "smart",
@@ -4955,7 +5182,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
4955
5182
  offset: { x: 0, y: 0 }
4956
5183
  };
4957
5184
  }
4958
- if (_optionalChain([options, 'access', _126 => _126.name, 'optionalAccess', _127 => _127.trim, 'call', _128 => _128()])) smart.name = options.name.trim();
5185
+ if (_optionalChain([options, 'access', _135 => _135.name, 'optionalAccess', _136 => _136.trim, 'call', _137 => _137()])) smart.name = options.name.trim();
4959
5186
  smart = { ...smart, surface: renderSmartObject(smart, canvas) };
4960
5187
  const below = ordered.filter((l) => l.index < top.index).length;
4961
5188
  let out = layers;
@@ -4985,12 +5212,12 @@ function rasterizeSmartObject(layers, id) {
4985
5212
  function copySmartObject(layers, id, linked, name) {
4986
5213
  const loc = requireLayer(layers, id);
4987
5214
  const layer = requireSmartObject(layers, id);
4988
- const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess', _129 => _129.trim, 'call', _130 => _130()]) || `${layer.name || "Smart Object"} copy` };
5215
+ const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess', _138 => _138.trim, 'call', _139 => _139()]) || `${layer.name || "Smart Object"} copy` };
4989
5216
  delete copy.locks;
4990
5217
  delete copy.psd;
4991
5218
  if (!linked) copy.contents = { ...layer.contents, id: newContentsId() };
4992
5219
  if (copy.smartFilters) copy.smartFilters = { ...copy.smartFilters, filters: copy.smartFilters.filters.map((f) => ({ ...f, id: newLayerId("flt") })) };
4993
- return { layers: _chunkB46UQUDCcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _131 => _131.parent, 'optionalAccess', _132 => _132.id]), () => ( null)), loc.index + 1), layer: copy };
5220
+ return { layers: _chunkB46UQUDCcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _140 => _140.parent, 'optionalAccess', _141 => _141.id]), () => ( null)), loc.index + 1), layer: copy };
4994
5221
  }
4995
5222
  function instancesOf(layers, contentsId) {
4996
5223
  return _chunkB46UQUDCcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
@@ -5062,7 +5289,7 @@ function stackOf(layer) {
5062
5289
  return _nullishCoalesce(layer.smartFilters, () => ( { enabled: true, filters: [] }));
5063
5290
  }
5064
5291
  function requireFilter(layer, filterId) {
5065
- const list2 = _nullishCoalesce(_optionalChain([layer, 'access', _133 => _133.smartFilters, 'optionalAccess', _134 => _134.filters]), () => ( []));
5292
+ const list2 = _nullishCoalesce(_optionalChain([layer, 'access', _142 => _142.smartFilters, 'optionalAccess', _143 => _143.filters]), () => ( []));
5066
5293
  const i = list2.findIndex((f) => f.id === filterId);
5067
5294
  if (i === -1) fail4(`Smart object "${layer.name || layer.id}" has no smart filter "${filterId}". Filters: ${list2.map((f) => `${f.id} (${f.kind})`).join(", ") || "none"}; call get_smart_object.`);
5068
5295
  return i;
@@ -5129,7 +5356,7 @@ function setSmartFiltersEnabled(layers, id, enabled, canvas) {
5129
5356
  }
5130
5357
  function setSmartFilterMask(layers, id, mask, canvas) {
5131
5358
  const layer = editableSmart(layers, id);
5132
- if (_optionalChain([mask, 'optionalAccess', _135 => _135.source])) fail4("A smart filter mask is painted, not generated; use a raster mask.");
5359
+ if (_optionalChain([mask, 'optionalAccess', _144 => _144.source])) fail4("A smart filter mask is painted, not generated; use a raster mask.");
5133
5360
  const stack = { ...stackOf(layer) };
5134
5361
  if (mask) stack.mask = mask;
5135
5362
  else delete stack.mask;
@@ -5268,18 +5495,19 @@ function serializeVectorMask(vm) {
5268
5495
  if (vm.linked === false) out.linked = false;
5269
5496
  if (vm.density !== void 0 && vm.density !== 1) out.density = vm.density;
5270
5497
  if (vm.feather) out.feather = vm.feather;
5498
+ if (_optionalChain([vm, 'access', _145 => _145.edges, 'optionalAccess', _146 => _146.length])) out.edges = vm.edges.map((e) => ({ ...e }));
5271
5499
  return out;
5272
5500
  }
5273
5501
  function readShapeComponents(stored) {
5274
5502
  if (!Array.isArray(stored)) throw new Error("its components are missing");
5275
5503
  return stored.map((raw, i) => {
5276
5504
  const c = raw;
5277
- const op = requireOperation(_optionalChain([c, 'optionalAccess', _136 => _136.op]), `components[${i}].op`);
5278
- if (_optionalChain([c, 'optionalAccess', _137 => _137.live])) {
5505
+ const op = requireOperation(_optionalChain([c, 'optionalAccess', _147 => _147.op]), `components[${i}].op`);
5506
+ if (_optionalChain([c, 'optionalAccess', _148 => _148.live])) {
5279
5507
  const live = normalizeLiveShape(c.live, `components[${i}].live`);
5280
5508
  return { op, subpaths: liveShapeSubpaths(live), live };
5281
5509
  }
5282
- return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _138 => _138.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _139 => _139.subpaths]), `components[${i}].subpaths`) };
5510
+ return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _149 => _149.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _150 => _150.subpaths]), `components[${i}].subpaths`) };
5283
5511
  });
5284
5512
  }
5285
5513
  function readVectorMask(r) {
@@ -5290,6 +5518,19 @@ function readVectorMask(r) {
5290
5518
  if (r.linked === false) vm.linked = false;
5291
5519
  if (typeof r.density === "number" && r.density !== 1) vm.density = num2(r.density, 0, 1, 1);
5292
5520
  if (typeof r.feather === "number" && r.feather > 0) vm.feather = num2(r.feather, 0, 1e3, 0);
5521
+ if (Array.isArray(r.edges)) {
5522
+ const edges = [];
5523
+ for (const raw of r.edges) {
5524
+ const e = raw;
5525
+ const int = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0 ? v : -1;
5526
+ const at = { component: int(_optionalChain([e, 'optionalAccess', _151 => _151.component])), subpath: int(_optionalChain([e, 'optionalAccess', _152 => _152.subpath])), segment: int(_optionalChain([e, 'optionalAccess', _153 => _153.segment])) };
5527
+ if (at.component < 0 || at.subpath < 0 || at.segment < 0) continue;
5528
+ if (e.mode === "feather") edges.push({ ...at, mode: "feather", radius: num2(e.radius, 0.5, 250, 4) });
5529
+ else if (e.mode === "matte") edges.push({ ...at, mode: "matte", inner: num2(e.inner, 0.5, 200, 4), outer: num2(e.outer, 0.5, 200, 8) });
5530
+ }
5531
+ const valid = validVectorMaskEdges(edges, vm.components);
5532
+ if (valid.length) vm.edges = valid;
5533
+ }
5293
5534
  return vm;
5294
5535
  }
5295
5536
  function serializeMask(mask, hint, ctx) {
@@ -5327,7 +5568,7 @@ function serializeLayer(layer, ctx) {
5327
5568
  }
5328
5569
  }
5329
5570
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5330
- if (_optionalChain([layer, 'access', _140 => _140.filters, 'optionalAccess', _141 => _141.length])) out.filters = JSON.parse(JSON.stringify(layer.filters));
5571
+ if (_optionalChain([layer, 'access', _154 => _154.filters, 'optionalAccess', _155 => _155.length])) out.filters = JSON.parse(JSON.stringify(layer.filters));
5331
5572
  if (layer.generator) out.generator = JSON.parse(JSON.stringify(layer.generator));
5332
5573
  if (layer.source !== "document") {
5333
5574
  const deep = encodeDeepSurface(layer.surface);
@@ -5371,12 +5612,12 @@ function serializeType(layer, base, ctx) {
5371
5612
  out.x = enc.x;
5372
5613
  out.y = enc.y;
5373
5614
  }
5374
- if (_optionalChain([layer, 'access', _142 => _142.missingFonts, 'optionalAccess', _143 => _143.length])) out.missingFonts = [...layer.missingFonts];
5615
+ if (_optionalChain([layer, 'access', _156 => _156.missingFonts, 'optionalAccess', _157 => _157.length])) out.missingFonts = [...layer.missingFonts];
5375
5616
  if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
5376
- if (_optionalChain([layer, 'access', _144 => _144.psd, 'optionalAccess', _145 => _145.tySh]) || _optionalChain([layer, 'access', _146 => _146.psd, 'optionalAccess', _147 => _147.blocks, 'optionalAccess', _148 => _148.length])) {
5617
+ if (_optionalChain([layer, 'access', _158 => _158.psd, 'optionalAccess', _159 => _159.tySh]) || _optionalChain([layer, 'access', _160 => _160.psd, 'optionalAccess', _161 => _161.blocks, 'optionalAccess', _162 => _162.length])) {
5377
5618
  out.psd = {};
5378
5619
  if (layer.psd.tySh) out.psd.tySh = _chunkOLNIPTB3cjs.bytesToBase64.call(void 0, layer.psd.tySh);
5379
- if (_optionalChain([layer, 'access', _149 => _149.psd, 'access', _150 => _150.blocks, 'optionalAccess', _151 => _151.length])) out.psd.blocks = layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkOLNIPTB3cjs.bytesToBase64.call(void 0, b.data) }));
5620
+ if (_optionalChain([layer, 'access', _163 => _163.psd, 'access', _164 => _164.blocks, 'optionalAccess', _165 => _165.length])) out.psd.blocks = layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkOLNIPTB3cjs.bytesToBase64.call(void 0, b.data) }));
5380
5621
  if (layer.psd.signature) out.psd.signature = layer.psd.signature;
5381
5622
  }
5382
5623
  return out;
@@ -5386,15 +5627,15 @@ function readType(r, base, ctx) {
5386
5627
  try {
5387
5628
  const text3 = normalizeText(_nullishCoalesce(r.text, () => ( "")));
5388
5629
  const runs = (Array.isArray(r.runs) ? r.runs : []).map((run, i) => ({
5389
- length: Math.max(0, Math.floor(num2(_optionalChain([run, 'optionalAccess', _152 => _152.length]), 0, 1e9, 0))),
5390
- style: patchTextStyle(_chunkQAUIZPYIcjs.DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _153 => _153.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
5630
+ length: Math.max(0, Math.floor(num2(_optionalChain([run, 'optionalAccess', _166 => _166.length]), 0, 1e9, 0))),
5631
+ style: patchTextStyle(_chunkQAUIZPYIcjs.DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _167 => _167.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
5391
5632
  }));
5392
5633
  const paragraphs = (Array.isArray(r.paragraphs) ? r.paragraphs : []).map((p, i) => ({
5393
- length: Math.max(0, Math.floor(num2(_optionalChain([p, 'optionalAccess', _154 => _154.length]), 0, 1e9, 0))),
5394
- style: patchParagraphStyle({}, _optionalChain([p, 'optionalAccess', _155 => _155.style]) && typeof p.style === "object" ? p.style : {}, `paragraphs[${i}].style`)
5634
+ length: Math.max(0, Math.floor(num2(_optionalChain([p, 'optionalAccess', _168 => _168.length]), 0, 1e9, 0))),
5635
+ style: patchParagraphStyle({}, _optionalChain([p, 'optionalAccess', _169 => _169.style]) && typeof p.style === "object" ? p.style : {}, `paragraphs[${i}].style`)
5395
5636
  }));
5396
5637
  const f = r.frame;
5397
- const frame = _optionalChain([f, 'optionalAccess', _156 => _156.kind]) === "box" ? { kind: "box", width: num2(f.width, 1, 1e6, 100), height: num2(f.height, 1, 1e6, 100) } : _optionalChain([f, 'optionalAccess', _157 => _157.origin]) === "top" ? { kind: "point", origin: "top" } : { kind: "point" };
5638
+ const frame = _optionalChain([f, 'optionalAccess', _170 => _170.kind]) === "box" ? { kind: "box", width: num2(f.width, 1, 1e6, 100), height: num2(f.height, 1, 1e6, 100) } : _optionalChain([f, 'optionalAccess', _171 => _171.origin]) === "top" ? { kind: "point", origin: "top" } : { kind: "point" };
5398
5639
  const m = Array.isArray(r.transform) && r.transform.length === 6 && r.transform.every((v) => typeof v === "number" && Number.isFinite(v)) ? r.transform : void 0;
5399
5640
  const layer = {
5400
5641
  ...base,
@@ -5406,7 +5647,7 @@ function readType(r, base, ctx) {
5406
5647
  surface: _chunk474IQG74cjs.emptySurface.call(void 0, 4),
5407
5648
  offset: { x: 0, y: 0 }
5408
5649
  };
5409
- if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _158 => _158[0], 'optionalAccess', _159 => _159.style]), () => ( _chunkQAUIZPYIcjs.DEFAULT_TEXT_STYLE)) }];
5650
+ if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _172 => _172[0], 'optionalAccess', _173 => _173.style]), () => ( _chunkQAUIZPYIcjs.DEFAULT_TEXT_STYLE)) }];
5410
5651
  if (m) layer.transform = m;
5411
5652
  if (r.orientation === "vertical") layer.orientation = "vertical";
5412
5653
  if (r.antiAlias === false) layer.antiAlias = false;
@@ -5418,10 +5659,10 @@ function readType(r, base, ctx) {
5418
5659
  if (typeof r.psd.tySh === "string") psd.tySh = _chunkOLNIPTB3cjs.base64ToBytes.call(void 0, r.psd.tySh);
5419
5660
  if (Array.isArray(r.psd.blocks)) psd.blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkOLNIPTB3cjs.base64ToBytes.call(void 0, b.data) }));
5420
5661
  if (typeof r.psd.signature === "string") psd.signature = r.psd.signature;
5421
- if (psd.tySh || _optionalChain([psd, 'access', _160 => _160.blocks, 'optionalAccess', _161 => _161.length])) layer.psd = psd;
5662
+ if (psd.tySh || _optionalChain([psd, 'access', _174 => _174.blocks, 'optionalAccess', _175 => _175.length])) layer.psd = psd;
5422
5663
  }
5423
5664
  if (typeof r.asset === "string") return { ...layer, surface: readSurface(r.asset, r.x, r.y, 4, 0, ctx, label), rendering: "stored" };
5424
- const env = { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _162 => _162.text, 'optionalAccess', _163 => _163.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _164 => _164.text, 'optionalAccess', _165 => _165.createCanvas]) };
5665
+ const env = { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _176 => _176.text, 'optionalAccess', _177 => _177.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _178 => _178.text, 'optionalAccess', _179 => _179.createCanvas]) };
5425
5666
  try {
5426
5667
  return rerenderText(layer, env);
5427
5668
  } catch (e8) {
@@ -5444,7 +5685,7 @@ function serializeShape(layer, base) {
5444
5685
  if (layer.inverted) out.inverted = true;
5445
5686
  if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
5446
5687
  if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
5447
- if (_optionalChain([layer, 'access', _166 => _166.psd, 'optionalAccess', _167 => _167.blocks, 'optionalAccess', _168 => _168.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkOLNIPTB3cjs.bytesToBase64.call(void 0, b.data) })), ...layer.psd.signature ? { signature: layer.psd.signature } : {} };
5688
+ if (_optionalChain([layer, 'access', _180 => _180.psd, 'optionalAccess', _181 => _181.blocks, 'optionalAccess', _182 => _182.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkOLNIPTB3cjs.bytesToBase64.call(void 0, b.data) })), ...layer.psd.signature ? { signature: layer.psd.signature } : {} };
5448
5689
  return out;
5449
5690
  }
5450
5691
  function readShape(r, base, ctx) {
@@ -5458,12 +5699,12 @@ function readShape(r, base, ctx) {
5458
5699
  if (!data) {
5459
5700
  if (!Array.isArray(r.components) || !r.components.length) throw new Error("it has no components");
5460
5701
  const components = r.components.map((c, i) => {
5461
- const op = requireOperation(_optionalChain([c, 'optionalAccess', _169 => _169.op]), `components[${i}].op`);
5462
- if (_optionalChain([c, 'optionalAccess', _170 => _170.live])) {
5702
+ const op = requireOperation(_optionalChain([c, 'optionalAccess', _183 => _183.op]), `components[${i}].op`);
5703
+ if (_optionalChain([c, 'optionalAccess', _184 => _184.live])) {
5463
5704
  const live = normalizeLiveShape(c.live, `components[${i}].live`);
5464
5705
  return { op, subpaths: liveShapeSubpaths(live), live };
5465
5706
  }
5466
- return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _171 => _171.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _172 => _172.subpaths]), `components[${i}].subpaths`) };
5707
+ return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _185 => _185.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _186 => _186.subpaths]), `components[${i}].subpaths`) };
5467
5708
  });
5468
5709
  data = {
5469
5710
  components,
@@ -5534,7 +5775,7 @@ function serializeContents(c, ctx) {
5534
5775
  if (c.kind === "document" && c.document) {
5535
5776
  out.layers = c.document.layers.map((l) => serializeLayer(l, ctx));
5536
5777
  if (c.document.globalLight) out.globalLight = { ...c.document.globalLight };
5537
- if (_optionalChain([c, 'access', _173 => _173.document, 'access', _174 => _174.patterns, 'optionalAccess', _175 => _175.length])) out.patterns = serializePatterns(c.document.patterns);
5778
+ if (_optionalChain([c, 'access', _187 => _187.document, 'access', _188 => _188.patterns, 'optionalAccess', _189 => _189.length])) out.patterns = serializePatterns(c.document.patterns);
5538
5779
  }
5539
5780
  if (c.file) out.file = { type: c.file.type, data: _chunkOLNIPTB3cjs.bytesToBase64.call(void 0, c.file.bytes) };
5540
5781
  if (c.linked) out.linked = { path: c.linked.path };
@@ -5723,7 +5964,7 @@ function deserializeLayer(raw, ctx) {
5723
5964
  ...base,
5724
5965
  type: "pixel",
5725
5966
  surface: r.source === "document" ? _chunk474IQG74cjs.emptySurface.call(void 0, 4) : readSurface(r.asset, r.x, r.y, 4, 0, ctx, `Layer "${base.name || id}"`),
5726
- offset: { x: Math.round(num2(_optionalChain([r, 'access', _176 => _176.offset, 'optionalAccess', _177 => _177.x]), -1e7, 1e7, 0)), y: Math.round(num2(_optionalChain([r, 'access', _178 => _178.offset, 'optionalAccess', _179 => _179.y]), -1e7, 1e7, 0)) }
5967
+ offset: { x: Math.round(num2(_optionalChain([r, 'access', _190 => _190.offset, 'optionalAccess', _191 => _191.x]), -1e7, 1e7, 0)), y: Math.round(num2(_optionalChain([r, 'access', _192 => _192.offset, 'optionalAccess', _193 => _193.y]), -1e7, 1e7, 0)) }
5727
5968
  };
5728
5969
  if (r.source === "document") layer.source = "document";
5729
5970
  else if (r.deep) layer.surface = decodeDeepSurface(layer.surface, r.deep, ctx.problems, `Layer "${base.name || id}"`);
@@ -5732,7 +5973,7 @@ function deserializeLayer(raw, ctx) {
5732
5973
  if (filters) layer.filters = filters;
5733
5974
  const generator = readEffectRef(r.generator);
5734
5975
  if (generator) {
5735
- const duration = _optionalChain([r, 'access', _180 => _180.generator, 'access', _181 => _181.animate, 'optionalAccess', _182 => _182.duration]);
5976
+ const duration = _optionalChain([r, 'access', _194 => _194.generator, 'access', _195 => _195.animate, 'optionalAccess', _196 => _196.duration]);
5736
5977
  layer.generator = {
5737
5978
  ...generator,
5738
5979
  ...typeof r.generator.time === "number" && r.generator.time > 0 ? { time: r.generator.time } : {},
@@ -5763,7 +6004,7 @@ function deserializeLayer(raw, ctx) {
5763
6004
  return null;
5764
6005
  }
5765
6006
  const annotation = JSON.parse(JSON.stringify({ ...a, id: typeof a.id === "string" ? a.id : id }));
5766
- const migrated = annotationLayerFor(annotation, { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _183 => _183.text, 'optionalAccess', _184 => _184.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _185 => _185.text, 'optionalAccess', _186 => _186.createCanvas]) });
6007
+ const migrated = annotationLayerFor(annotation, { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _197 => _197.text, 'optionalAccess', _198 => _198.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _199 => _199.text, 'optionalAccess', _200 => _200.createCanvas]) });
5767
6008
  if (migrated.type === "shape" || migrated.type === "type") {
5768
6009
  const blend = base.blend === "normal" ? migrated.blend : base.blend;
5769
6010
  return { ...migrated, ...base, blend, id, name: base.name };
@@ -6341,7 +6582,7 @@ function descriptor(classId, items = []) {
6341
6582
  return { name: "", classId, items };
6342
6583
  }
6343
6584
  function descGet(d, key) {
6344
- return _optionalChain([d, 'access', _187 => _187.items, 'access', _188 => _188.find, 'call', _189 => _189(([k]) => k === key), 'optionalAccess', _190 => _190[1]]);
6585
+ return _optionalChain([d, 'access', _201 => _201.items, 'access', _202 => _202.find, 'call', _203 => _203(([k]) => k === key), 'optionalAccess', _204 => _204[1]]);
6345
6586
  }
6346
6587
  function descNumber(d, key) {
6347
6588
  const v = descGet(d, key);
@@ -6351,7 +6592,7 @@ function descNumber(d, key) {
6351
6592
  }
6352
6593
  function descBool(d, key) {
6353
6594
  const v = descGet(d, key);
6354
- return _optionalChain([v, 'optionalAccess', _191 => _191.type]) === "bool" ? v.value : void 0;
6595
+ return _optionalChain([v, 'optionalAccess', _205 => _205.type]) === "bool" ? v.value : void 0;
6355
6596
  }
6356
6597
  function descObject(d, key) {
6357
6598
  const v = descGet(d, key);
@@ -7079,7 +7320,7 @@ function pathResourceForComponents(components, width, height) {
7079
7320
 
7080
7321
  // src/image-editor/psd/channels.ts
7081
7322
  var hexToRgb2 = (hex) => {
7082
- const v = parseInt(_nullishCoalesce(_optionalChain([/^#?([0-9a-f]{6})$/i, 'access', _192 => _192.exec, 'call', _193 => _193(hex), 'optionalAccess', _194 => _194[1]]), () => ( "ff0000")), 16);
7323
+ const v = parseInt(_nullishCoalesce(_optionalChain([/^#?([0-9a-f]{6})$/i, 'access', _206 => _206.exec, 'call', _207 => _207(hex), 'optionalAccess', _208 => _208[1]]), () => ( "ff0000")), 16);
7083
7324
  return [v >> 16 & 255, v >> 8 & 255, v & 255];
7084
7325
  };
7085
7326
  var rgbToHex = (r, g, b) => `#${[r, g, b].map((c) => c.toString(16).padStart(2, "0")).join("")}`;
@@ -7153,16 +7394,16 @@ function readAlphaChannels(planes, header, first, resource2, warn) {
7153
7394
  if (start + size > planes.length) break;
7154
7395
  const d = display[i];
7155
7396
  const name = names[i] || `Alpha ${i + 1}`;
7156
- if (_optionalChain([d, 'optionalAccess', _195 => _195.kind]) === 2) {
7397
+ if (_optionalChain([d, 'optionalAccess', _209 => _209.kind]) === 2) {
7157
7398
  warn(`Spot colour channel "${name}" is not supported and was left out.`);
7158
7399
  continue;
7159
7400
  }
7160
7401
  out.push({
7161
7402
  name,
7162
7403
  data: planeTo8(planes.subarray(start, start + size), n, header.depth),
7163
- color: _nullishCoalesce(_optionalChain([d, 'optionalAccess', _196 => _196.color]), () => ( "#ff0000")),
7164
- opacity: _nullishCoalesce(_optionalChain([d, 'optionalAccess', _197 => _197.opacity]), () => ( 0.5)),
7165
- indicates: _optionalChain([d, 'optionalAccess', _198 => _198.kind]) === 0 ? "selected" : "masked"
7404
+ color: _nullishCoalesce(_optionalChain([d, 'optionalAccess', _210 => _210.color]), () => ( "#ff0000")),
7405
+ opacity: _nullishCoalesce(_optionalChain([d, 'optionalAccess', _211 => _211.opacity]), () => ( 0.5)),
7406
+ indicates: _optionalChain([d, 'optionalAccess', _212 => _212.kind]) === 0 ? "selected" : "masked"
7166
7407
  });
7167
7408
  }
7168
7409
  return out;
@@ -7178,7 +7419,7 @@ var enumV = (typeId, value) => ({ type: "enum", typeId, value });
7178
7419
  var obj = (d) => ({ type: "Objc", value: d });
7179
7420
  var enumOf = (d, key) => {
7180
7421
  const v = descGet(d, key);
7181
- return _optionalChain([v, 'optionalAccess', _199 => _199.type]) === "enum" ? v.value : void 0;
7422
+ return _optionalChain([v, 'optionalAccess', _213 => _213.type]) === "enum" ? v.value : void 0;
7182
7423
  };
7183
7424
  function read(data) {
7184
7425
  try {
@@ -7260,7 +7501,7 @@ function strokeFromVstk(data, dpi, notes) {
7260
7501
  const miter = descNumber(d, "strokeStyleMiterLimit");
7261
7502
  if (miter !== void 0 && miter !== 100) stroke.miterLimit = Math.max(1, Math.min(500, miter));
7262
7503
  const dashes = descGet(d, "strokeStyleLineDashSet");
7263
- if (_optionalChain([dashes, 'optionalAccess', _200 => _200.type]) === "VlLs") {
7504
+ if (_optionalChain([dashes, 'optionalAccess', _214 => _214.type]) === "VlLs") {
7264
7505
  const list2 = dashes.items.map((v) => v.type === "UntF" || v.type === "doub" || v.type === "long" ? v.value : NaN).filter((v) => Number.isFinite(v) && v >= 0);
7265
7506
  if (list2.length && list2.some((v) => v > 0)) stroke.dashes = list2;
7266
7507
  }
@@ -7412,7 +7653,7 @@ function vogkBytes(components, dpi) {
7412
7653
  ["keyOriginLineArrowEnd", boolV(Boolean(live.endArrow))],
7413
7654
  ["keyOriginLineArrWdth", dbl(head ? head.width / w * 100 : 0)],
7414
7655
  ["keyOriginLineArrLngth", dbl(head ? head.length / w * 100 : 0)],
7415
- ["keyOriginLineArrConc", long2(_optionalChain([head, 'optionalAccess', _201 => _201.concavity]) ? head.concavity * 100 : 0)]
7656
+ ["keyOriginLineArrConc", long2(_optionalChain([head, 'optionalAccess', _215 => _215.concavity]) ? head.concavity * 100 : 0)]
7416
7657
  ];
7417
7658
  }
7418
7659
  const m = live.transform;
@@ -7445,7 +7686,7 @@ function shapeSignature(layer) {
7445
7686
  return JSON.stringify([layer.components, layer.fill, layer.stroke, _nullishCoalesce(layer.fillRule, () => ( "nonzero")), Boolean(layer.inverted)]);
7446
7687
  }
7447
7688
  function shapeFromBlocks(blocks, width, height, dpi, notes) {
7448
- const block = (k) => _optionalChain([blocks, 'access', _202 => _202.find, 'call', _203 => _203((b) => b.key === k), 'optionalAccess', _204 => _204.data]);
7689
+ const block = (k) => _optionalChain([blocks, 'access', _216 => _216.find, 'call', _217 => _217((b) => b.key === k), 'optionalAccess', _218 => _218.data]);
7449
7690
  const vector = _nullishCoalesce(block("vsms"), () => ( block("vmsk")));
7450
7691
  const path = vector ? componentsFromVectorBlock(vector, width, height) : null;
7451
7692
  if (!path) return null;
@@ -7500,18 +7741,18 @@ function sameExtent(sub, c) {
7500
7741
  return a.every((v, i) => Math.abs(v - b[i]) < 1);
7501
7742
  }
7502
7743
  function shapeBlocks(layer, width, height, dpi, notes) {
7503
- const kept = _optionalChain([layer, 'access', _205 => _205.psd, 'optionalAccess', _206 => _206.blocks]);
7504
- if (_optionalChain([kept, 'optionalAccess', _207 => _207.length]) && _optionalChain([layer, 'access', _208 => _208.psd, 'optionalAccess', _209 => _209.signature]) === shapeSignature(layer)) return kept.map((b) => ({ key: b.key, data: b.data }));
7744
+ const kept = _optionalChain([layer, 'access', _219 => _219.psd, 'optionalAccess', _220 => _220.blocks]);
7745
+ if (_optionalChain([kept, 'optionalAccess', _221 => _221.length]) && _optionalChain([layer, 'access', _222 => _222.psd, 'optionalAccess', _223 => _223.signature]) === shapeSignature(layer)) return kept.map((b) => ({ key: b.key, data: b.data }));
7505
7746
  const out = [];
7506
7747
  out.push({ key: "vsms", data: vectorBlockForComponents(layer.components, Boolean(layer.inverted), width, height) });
7507
7748
  if (layer.fillRule === "evenodd" && layer.components.some((c) => c.subpaths.length > 1)) notes.add("Even-odd fill rules were written as nonzero (Photoshop fills shapes nonzero)");
7508
7749
  const fill = _nullishCoalesce(layer.fill, () => ( { type: "color", color: "#000000" }));
7509
- if (_optionalChain([layer, 'access', _210 => _210.fill, 'optionalAccess', _211 => _211.opacity]) !== void 0 && layer.fill.opacity < 1) notes.add("Shape fill opacity has no PSD equivalent and was written as 100 % (use the layer fill opacity)");
7750
+ if (_optionalChain([layer, 'access', _224 => _224.fill, 'optionalAccess', _225 => _225.opacity]) !== void 0 && layer.fill.opacity < 1) notes.add("Shape fill opacity has no PSD equivalent and was written as 100 % (use the layer fill opacity)");
7510
7751
  out.push({ key: "vscg", data: vscgBytes(fill) });
7511
7752
  if (layer.stroke || !layer.fill) out.push({ key: "vstk", data: vstkBytes(layer.stroke, Boolean(layer.fill), dpi) });
7512
7753
  const vogk = vogkBytes(layer.components, dpi);
7513
7754
  if (vogk) out.push({ key: "vogk", data: vogk });
7514
- if (layer.components.some((c) => _optionalChain([c, 'access', _212 => _212.live, 'optionalAccess', _213 => _213.kind]) === "line" && (c.live.startArrow && c.live.endArrow && JSON.stringify(c.live.startArrow) !== JSON.stringify(c.live.endArrow) || false))) {
7755
+ if (layer.components.some((c) => _optionalChain([c, 'access', _226 => _226.live, 'optionalAccess', _227 => _227.kind]) === "line" && (c.live.startArrow && c.live.endArrow && JSON.stringify(c.live.startArrow) !== JSON.stringify(c.live.endArrow) || false))) {
7515
7756
  notes.add("Lines with different start and end arrowheads were written with one arrowhead size (Photoshop has one)");
7516
7757
  }
7517
7758
  return out;
@@ -7720,7 +7961,7 @@ var E = {
7720
7961
  bool: (value) => ({ t: "bool", value })
7721
7962
  };
7722
7963
  function eGet(v, key) {
7723
- return _optionalChain([v, 'optionalAccess', _214 => _214.t]) === "dict" ? _optionalChain([v, 'access', _215 => _215.items, 'access', _216 => _216.find, 'call', _217 => _217(([k]) => k === key), 'optionalAccess', _218 => _218[1]]) : void 0;
7964
+ return _optionalChain([v, 'optionalAccess', _228 => _228.t]) === "dict" ? _optionalChain([v, 'access', _229 => _229.items, 'access', _230 => _230.find, 'call', _231 => _231(([k]) => k === key), 'optionalAccess', _232 => _232[1]]) : void 0;
7724
7965
  }
7725
7966
  function ePath(v, keys) {
7726
7967
  return keys.reduce((at, k) => eGet(at, k), v);
@@ -7738,7 +7979,7 @@ function eStr(v) {
7738
7979
  return v && (v.t === "string" || v.t === "name") ? v.value : void 0;
7739
7980
  }
7740
7981
  function eArray(v) {
7741
- return _optionalChain([v, 'optionalAccess', _219 => _219.t]) === "array" ? v.items : [];
7982
+ return _optionalChain([v, 'optionalAccess', _233 => _233.t]) === "array" ? v.items : [];
7742
7983
  }
7743
7984
  function eSet(d, key, value) {
7744
7985
  if (d.t !== "dict") return;
@@ -7840,7 +8081,7 @@ function fontFromPostScript(ps) {
7840
8081
  }
7841
8082
  family += suffix;
7842
8083
  const s = style.toLowerCase();
7843
- const weight = _nullishCoalesce(_optionalChain([WEIGHTS, 'access', _220 => _220.find, 'call', _221 => _221(([re]) => re.test(s)), 'optionalAccess', _222 => _222[1]]), () => ( 400));
8084
+ const weight = _nullishCoalesce(_optionalChain([WEIGHTS, 'access', _234 => _234.find, 'call', _235 => _235(([re]) => re.test(s)), 'optionalAccess', _236 => _236[1]]), () => ( 400));
7844
8085
  return { family: family || ps, weight, italic: /italic|oblique|it$/.test(s) };
7845
8086
  }
7846
8087
  var STYLE_NAMES = [
@@ -7865,7 +8106,7 @@ var hex2 = (v) => Math.round(Math.max(0, Math.min(1, v)) * 255).toString(16).pad
7865
8106
  function merged(levels) {
7866
8107
  const items = [];
7867
8108
  for (const l of levels) {
7868
- if (_optionalChain([l, 'optionalAccess', _223 => _223.t]) !== "dict") continue;
8109
+ if (_optionalChain([l, 'optionalAccess', _237 => _237.t]) !== "dict") continue;
7869
8110
  for (const [k, v] of l.items) if (!items.some(([o]) => o === k)) items.push([k, v]);
7870
8111
  }
7871
8112
  return E.dict(items);
@@ -7938,10 +8179,10 @@ function typeFromTySh(data, notes) {
7938
8179
  const t = parseTySh(data);
7939
8180
  if (!t) return null;
7940
8181
  const txtV = descGet(t.text, "Txt ");
7941
- const txt = _optionalChain([txtV, 'optionalAccess', _224 => _224.type]) === "TEXT" ? txtV.value.replace(/\0+$/, "") : void 0;
8182
+ const txt = _optionalChain([txtV, 'optionalAccess', _238 => _238.type]) === "TEXT" ? txtV.value.replace(/\0+$/, "") : void 0;
7942
8183
  const ed = descGet(t.text, "EngineData");
7943
8184
  let engine = null;
7944
- if (_optionalChain([ed, 'optionalAccess', _225 => _225.type]) === "tdta") {
8185
+ if (_optionalChain([ed, 'optionalAccess', _239 => _239.type]) === "tdta") {
7945
8186
  try {
7946
8187
  engine = parseEngineData(ed.data);
7947
8188
  } catch (e18) {
@@ -7949,12 +8190,12 @@ function typeFromTySh(data, notes) {
7949
8190
  }
7950
8191
  }
7951
8192
  const anti = descGet(t.text, "AntA");
7952
- const antiAlias = !(_optionalChain([anti, 'optionalAccess', _226 => _226.type]) === "enum" && (anti.value === "Anno" || anti.value === "antiAliasNone"));
8193
+ const antiAlias = !(_optionalChain([anti, 'optionalAccess', _240 => _240.type]) === "enum" && (anti.value === "Anno" || anti.value === "antiAliasNone"));
7953
8194
  const ornt = descGet(t.text, "Ornt");
7954
- const vertical = _optionalChain([ornt, 'optionalAccess', _227 => _227.type]) === "enum" && ornt.value === "Vrtc";
8195
+ const vertical = _optionalChain([ornt, 'optionalAccess', _241 => _241.type]) === "enum" && ornt.value === "Vrtc";
7955
8196
  if (t.warp) {
7956
8197
  const style = descGet(t.warp, "warpStyle");
7957
- if (_optionalChain([style, 'optionalAccess', _228 => _228.type]) === "enum" && style.value !== "warpNone") notes.add("warped text is drawn without its warp when edited");
8198
+ if (_optionalChain([style, 'optionalAccess', _242 => _242.type]) === "enum" && style.value !== "warpNone") notes.add("warped text is drawn without its warp when edited");
7958
8199
  }
7959
8200
  const edText = _nullishCoalesce(eStr(ePath(_nullishCoalesce(engine, () => ( void 0)), ["EngineDict", "Editor", "Text"])), () => ( ""));
7960
8201
  const text3 = (_nullishCoalesce(txt, () => ( edText.replace(/\r$/, "")))).replace(/\r\n?/g, "\n");
@@ -8003,7 +8244,7 @@ function typeFromTySh(data, notes) {
8003
8244
  let at = 0;
8004
8245
  runs = ssheets.map((sheet, i) => {
8005
8246
  const own = named(styleSet, sheet);
8006
- const paraDefault = _optionalChain([paraBases, 'access', _229 => _229[paraAt(at)], 'optionalAccess', _230 => _230.charDefault]);
8247
+ const paraDefault = _optionalChain([paraBases, 'access', _243 => _243[paraAt(at)], 'optionalAccess', _244 => _244.charDefault]);
8007
8248
  at += _nullishCoalesce(slens[i], () => ( 0));
8008
8249
  const d = merged([eGet(sheet, "StyleSheetData"), eGet(own, "StyleSheetData"), eGet(paraDefault, "StyleSheetData"), eGet(normalStyle, "StyleSheetData")]);
8009
8250
  return { length: _nullishCoalesce(slens[i], () => ( 0)), style: charStyle(d, fonts, notes, vertical) };
@@ -8084,8 +8325,8 @@ var fontEntry = (name) => E.dict([
8084
8325
  ["Synthetic", E.int(0)]
8085
8326
  ]);
8086
8327
  function buildEngineData(layer, template) {
8087
- const e = _optionalChain([template, 'optionalAccess', _231 => _231.t]) === "dict" ? eClone(template) : E.dict([["EngineDict", E.dict()], ["ResourceDict", E.dict()]]);
8088
- if (_optionalChain([eGet, 'call', _232 => _232(e, "EngineDict"), 'optionalAccess', _233 => _233.t]) !== "dict") eSet(e, "EngineDict", E.dict());
8328
+ const e = _optionalChain([template, 'optionalAccess', _245 => _245.t]) === "dict" ? eClone(template) : E.dict([["EngineDict", E.dict()], ["ResourceDict", E.dict()]]);
8329
+ if (_optionalChain([eGet, 'call', _246 => _246(e, "EngineDict"), 'optionalAccess', _247 => _247.t]) !== "dict") eSet(e, "EngineDict", E.dict());
8089
8330
  const dict = eGet(e, "EngineDict");
8090
8331
  const text3 = layer.text.replace(/\n/g, "\r");
8091
8332
  const edText = `${text3}\r`;
@@ -8165,7 +8406,7 @@ function buildEngineData(layer, template) {
8165
8406
  eSet(e, key, rd);
8166
8407
  }
8167
8408
  eSet(rd, "FontSet", fontSet);
8168
- if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _234 => _234[0], 'optionalAccess', _235 => _235.style]), () => ( _chunkQAUIZPYIcjs.DEFAULT_TEXT_STYLE)), 0)]])]));
8409
+ if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _248 => _248[0], 'optionalAccess', _249 => _249.style]), () => ( _chunkQAUIZPYIcjs.DEFAULT_TEXT_STYLE)), 0)]])]));
8169
8410
  if (!eGet(rd, "ParagraphSheetSet")) eSet(rd, "ParagraphSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["DefaultStyleSheet", E.int(0)], ["Properties", paragraphProperties({})]])]));
8170
8411
  if (!eGet(rd, "TheNormalStyleSheet")) eSet(rd, "TheNormalStyleSheet", E.int(0));
8171
8412
  if (!eGet(rd, "TheNormalParagraphSheet")) eSet(rd, "TheNormalParagraphSheet", E.int(0));
@@ -8186,12 +8427,12 @@ function inkBounds2(layer) {
8186
8427
  return [Math.min(...pts.map((p) => p.x)), Math.min(...pts.map((p) => p.y)), Math.max(...pts.map((p) => p.x)), Math.max(...pts.map((p) => p.y))];
8187
8428
  }
8188
8429
  function tyShForLayer(layer) {
8189
- const raw = _optionalChain([layer, 'access', _236 => _236.psd, 'optionalAccess', _237 => _237.tySh]);
8190
- if (raw && _optionalChain([layer, 'access', _238 => _238.psd, 'optionalAccess', _239 => _239.signature]) === typeSignature(layer)) return raw;
8430
+ const raw = _optionalChain([layer, 'access', _250 => _250.psd, 'optionalAccess', _251 => _251.tySh]);
8431
+ if (raw && _optionalChain([layer, 'access', _252 => _252.psd, 'optionalAccess', _253 => _253.signature]) === typeSignature(layer)) return raw;
8191
8432
  const old = raw ? parseTySh(raw) : null;
8192
8433
  const oldEd = old ? descGet(old.text, "EngineData") : void 0;
8193
8434
  let template = null;
8194
- if (_optionalChain([oldEd, 'optionalAccess', _240 => _240.type]) === "tdta") {
8435
+ if (_optionalChain([oldEd, 'optionalAccess', _254 => _254.type]) === "tdta") {
8195
8436
  try {
8196
8437
  template = parseEngineData(oldEd.data);
8197
8438
  } catch (e19) {
@@ -8223,8 +8464,8 @@ function tyShForLayer(layer) {
8223
8464
  set("boundingBox", rect("boundingBox"));
8224
8465
  if (!descGet(text3, "TextIndex")) set("TextIndex", { type: "long", value: 0 });
8225
8466
  set("EngineData", { type: "tdta", data: writeEngineData(engine) });
8226
- const warpStyle = _optionalChain([old, 'optionalAccess', _241 => _241.warp]) ? descGet(old.warp, "warpStyle") : void 0;
8227
- const warp = _optionalChain([old, 'optionalAccess', _242 => _242.warp]) && _optionalChain([warpStyle, 'optionalAccess', _243 => _243.type]) === "enum" && warpStyle.value === "warpNone" ? old.warp : null;
8467
+ const warpStyle = _optionalChain([old, 'optionalAccess', _255 => _255.warp]) ? descGet(old.warp, "warpStyle") : void 0;
8468
+ const warp = _optionalChain([old, 'optionalAccess', _256 => _256.warp]) && _optionalChain([warpStyle, 'optionalAccess', _257 => _257.type]) === "enum" && warpStyle.value === "warpNone" ? old.warp : null;
8228
8469
  return writeTySh({ transform: textMatrix(layer), text: text3, warp, tail: new Uint8Array(16) });
8229
8470
  }
8230
8471
 
@@ -8238,15 +8479,15 @@ var textV = (value) => ({ type: "TEXT", value });
8238
8479
  var obj2 = (d) => ({ type: "Objc", value: d });
8239
8480
  var text = (d, key) => {
8240
8481
  const v = descGet(d, key);
8241
- return _optionalChain([v, 'optionalAccess', _244 => _244.type]) === "TEXT" ? v.value : void 0;
8482
+ return _optionalChain([v, 'optionalAccess', _258 => _258.type]) === "TEXT" ? v.value : void 0;
8242
8483
  };
8243
8484
  var enumOf2 = (d, key) => {
8244
8485
  const v = descGet(d, key);
8245
- return _optionalChain([v, 'optionalAccess', _245 => _245.type]) === "enum" ? v.value : void 0;
8486
+ return _optionalChain([v, 'optionalAccess', _259 => _259.type]) === "enum" ? v.value : void 0;
8246
8487
  };
8247
8488
  var numbers = (d, key) => {
8248
8489
  const v = descGet(d, key);
8249
- if (_optionalChain([v, 'optionalAccess', _246 => _246.type]) !== "VlLs") return null;
8490
+ if (_optionalChain([v, 'optionalAccess', _260 => _260.type]) !== "VlLs") return null;
8250
8491
  const out = [];
8251
8492
  for (const it of v.items) {
8252
8493
  if (it.type === "doub" || it.type === "UntF" || it.type === "long") out.push(it.value);
@@ -8441,8 +8682,8 @@ function filterMaskItem(placed, mask, area) {
8441
8682
  const painted = _chunk474IQG74cjs.contentBounds.call(void 0, mask.surface);
8442
8683
  let b = _nullishCoalesce(painted, () => ( { x: 0, y: 0, width: 1, height: 1 }));
8443
8684
  if (mask.defaultValue !== 255 && area) {
8444
- const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _247 => _247.x]), () => ( area.x)));
8445
- const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _248 => _248.y]), () => ( area.y)));
8685
+ const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _261 => _261.x]), () => ( area.x)));
8686
+ const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _262 => _262.y]), () => ( area.y)));
8446
8687
  const x1 = Math.max(area.x + area.width, painted ? painted.x + painted.width : 0);
8447
8688
  const y1 = Math.max(area.y + area.height, painted ? painted.y + painted.height : 0);
8448
8689
  b = { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
@@ -8462,7 +8703,7 @@ function filterMaskItem(placed, mask, area) {
8462
8703
  }
8463
8704
  var warpStyleOf = (name) => {
8464
8705
  if (!name.startsWith("warp")) return null;
8465
- const s = _optionalChain([name, 'access', _249 => _249[4], 'optionalAccess', _250 => _250.toLowerCase, 'call', _251 => _251()]) + name.slice(5);
8706
+ const s = _optionalChain([name, 'access', _263 => _263[4], 'optionalAccess', _264 => _264.toLowerCase, 'call', _265 => _265()]) + name.slice(5);
8466
8707
  return _chunkQAUIZPYIcjs.WARP_STYLES.includes(s) ? s : null;
8467
8708
  };
8468
8709
  function warpFromDescriptor(w, contents) {
@@ -8484,7 +8725,7 @@ function warpFromDescriptor(w, contents) {
8484
8725
  if (!arr || arr.type !== "ObAr") return void 0;
8485
8726
  const xs = descGet(arr.body, "Hrzn");
8486
8727
  const ys = descGet(arr.body, "Vrtc");
8487
- if (_optionalChain([xs, 'optionalAccess', _252 => _252.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _253 => _253.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
8728
+ if (_optionalChain([xs, 'optionalAccess', _266 => _266.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _267 => _267.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
8488
8729
  mesh = { us: [0, 1], vs: [0, 1], points: xs.values.map((x, i) => ({ x, y: ys.values[i] })) };
8489
8730
  const px2 = mesh.points.map((p) => p.x);
8490
8731
  const py = mesh.points.map((p) => p.y);
@@ -8651,13 +8892,13 @@ function blendOptions(f) {
8651
8892
  function smartFiltersFromPsd(fx, newId, notes) {
8652
8893
  const filters = [];
8653
8894
  const list2 = descGet(fx, "filterFXList");
8654
- for (const v of _optionalChain([list2, 'optionalAccess', _254 => _254.type]) === "VlLs" ? list2.items : []) {
8895
+ for (const v of _optionalChain([list2, 'optionalAccess', _268 => _268.type]) === "VlLs" ? list2.items : []) {
8655
8896
  if (v.type !== "Objc" && v.type !== "GlbO") continue;
8656
8897
  const item = v.value;
8657
8898
  const { blend, opacity } = blendOptionsOf(item);
8658
8899
  const enabled = descBool(item, "enab") !== false;
8659
8900
  const fltr = descObject(item, "Fltr");
8660
- const radius = _optionalChain([fltr, 'optionalAccess', _255 => _255.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
8901
+ const radius = _optionalChain([fltr, 'optionalAccess', _269 => _269.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
8661
8902
  if (radius !== void 0 && radius >= 0 && radius <= 50) {
8662
8903
  filters.push({ id: newId(), kind: "blur", enabled, radius, blend, opacity });
8663
8904
  continue;
@@ -9010,7 +9251,7 @@ function readPsd(bytes) {
9010
9251
  return { header, colorModeData, resources, layers, mergedAlpha, globalBlocks, imageCompression, imageData: r.rest() };
9011
9252
  }
9012
9253
  function layerBlock(rec, key) {
9013
- return _optionalChain([rec, 'access', _256 => _256.blocks, 'access', _257 => _257.find, 'call', _258 => _258((b) => b.key === key), 'optionalAccess', _259 => _259.data]);
9254
+ return _optionalChain([rec, 'access', _270 => _270.blocks, 'access', _271 => _271.find, 'call', _272 => _272((b) => b.key === key), 'optionalAccess', _273 => _273.data]);
9014
9255
  }
9015
9256
  function layerName(rec) {
9016
9257
  const luni = layerBlock(rec, "luni");
@@ -9041,7 +9282,7 @@ function u8Block(rec, key) {
9041
9282
  function layerTree(file) {
9042
9283
  const stack = [[]];
9043
9284
  file.layers.forEach((rec, index) => {
9044
- const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _260 => _260(rec), 'optionalAccess', _261 => _261.kind]), () => ( SECTION_OTHER));
9285
+ const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _274 => _274(rec), 'optionalAccess', _275 => _275.kind]), () => ( SECTION_OTHER));
9045
9286
  if (kind === SECTION_DIVIDER) {
9046
9287
  stack.push([]);
9047
9288
  } else if (kind === SECTION_OPEN || kind === SECTION_CLOSED) {
@@ -9059,7 +9300,7 @@ function layerTree(file) {
9059
9300
  }
9060
9301
  function channelRect(rec, id) {
9061
9302
  if (id === CHANNEL_USER_MASK && rec.mask) return rec.mask.rect;
9062
- if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _262 => _262.mask, 'access', _263 => _263.real, 'optionalAccess', _264 => _264.rect]), () => ( rec.mask.rect));
9303
+ if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _276 => _276.mask, 'access', _277 => _277.real, 'optionalAccess', _278 => _278.rect]), () => ( rec.mask.rect));
9063
9304
  return rec.rect;
9064
9305
  }
9065
9306
  function decodeLayerChannel(file, rec, id) {
@@ -9077,7 +9318,7 @@ function decodeMergedImage(file) {
9077
9318
  return decodePlanes(file.imageCompression, file.imageData, { planes: channels, width, height, depth, psb });
9078
9319
  }
9079
9320
  function resource(file, id) {
9080
- return _optionalChain([file, 'access', _265 => _265.resources, 'access', _266 => _266.find, 'call', _267 => _267((r) => r.id === id), 'optionalAccess', _268 => _268.data]);
9321
+ return _optionalChain([file, 'access', _279 => _279.resources, 'access', _280 => _280.find, 'call', _281 => _281((r) => r.id === id), 'optionalAccess', _282 => _282.data]);
9081
9322
  }
9082
9323
  function resolution(file) {
9083
9324
  const d = resource(file, 1005);
@@ -9815,8 +10056,8 @@ function baseProps(ctx, rec, name, notes) {
9815
10056
  if (read2.flags & VMSK_NOT_LINKED) vm.linked = false;
9816
10057
  if (read2.flags & VMSK_DISABLED) vm.enabled = false;
9817
10058
  const m = rec.mask;
9818
- if (_optionalChain([m, 'optionalAccess', _269 => _269.vectorDensity]) !== void 0 && m.vectorDensity < 255) vm.density = percent(m.vectorDensity);
9819
- if (_optionalChain([m, 'optionalAccess', _270 => _270.vectorFeather]) !== void 0 && m.vectorFeather > 0) vm.feather = Math.min(1e3, m.vectorFeather);
10059
+ if (_optionalChain([m, 'optionalAccess', _283 => _283.vectorDensity]) !== void 0 && m.vectorDensity < 255) vm.density = percent(m.vectorDensity);
10060
+ if (_optionalChain([m, 'optionalAccess', _284 => _284.vectorFeather]) !== void 0 && m.vectorFeather > 0) vm.feather = Math.min(1e3, m.vectorFeather);
9820
10061
  props.vectorMask = vm;
9821
10062
  } else {
9822
10063
  ctx.warn.add("A vector mask could not be read and was ignored", name);
@@ -9876,7 +10117,7 @@ function importNode(ctx, node, depth) {
9876
10117
  if (node.children) {
9877
10118
  const props2 = baseProps(ctx, rec, name, notes);
9878
10119
  const divider = sectionDivider(rec);
9879
- const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _271 => _271.blendKey]), () => ( rec.blendKey));
10120
+ const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _285 => _285.blendKey]), () => ( rec.blendKey));
9880
10121
  const groupBlend = key === "pass" ? "pass-through" : _nullishCoalesce(PSD_BLEND_KEYS[key], () => ( "normal"));
9881
10122
  const children = [];
9882
10123
  for (const child of node.children) {
@@ -9886,7 +10127,7 @@ function importNode(ctx, node, depth) {
9886
10127
  const group = { type: "group", id: ctx.newId(name), ...props2, blend: groupBlend, children };
9887
10128
  const effects2 = recordEffects(ctx, rec, name, notes, true);
9888
10129
  if (effects2) group.effects = effects2;
9889
- if (_optionalChain([divider, 'optionalAccess', _272 => _272.kind]) === SECTION_CLOSED) group.collapsed = true;
10130
+ if (_optionalChain([divider, 'optionalAccess', _286 => _286.kind]) === SECTION_CLOSED) group.collapsed = true;
9890
10131
  const mask2 = recordMask(ctx, rec, name);
9891
10132
  if (mask2) group.mask = mask2;
9892
10133
  entry.type = "group";
@@ -10110,7 +10351,7 @@ function importSmart(ctx, rec, name, notes, props) {
10110
10351
  const file = ctx.linked.get(placed.idnt);
10111
10352
  contents = {
10112
10353
  id: placed.idnt || ctx.newId(`${name}-contents`),
10113
- name: _optionalChain([file, 'optionalAccess', _273 => _273.name]) || `${name}.png`,
10354
+ name: _optionalChain([file, 'optionalAccess', _287 => _287.name]) || `${name}.png`,
10114
10355
  width,
10115
10356
  height,
10116
10357
  kind: "raster",
@@ -10267,7 +10508,7 @@ function psdToLayers(file, options = {}) {
10267
10508
  if (mode !== "rgb" && header.depth > 8 && header.colorMode !== MODE_INDEXED && header.colorMode !== MODE_BITMAP) {
10268
10509
  warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to ${header.depth}-bit RGB.`);
10269
10510
  } else if (mode !== "rgb" || header.depth !== 8 && header.depth !== 16 && header.depth !== 32) {
10270
- const how = header.colorMode === MODE_CMYK ? ` through ${_nullishCoalesce(_optionalChain([cmykProfile, 'optionalAccess', _274 => _274.name]), () => ( "its profile"))}` : "";
10511
+ const how = header.colorMode === MODE_CMYK ? ` through ${_nullishCoalesce(_optionalChain([cmykProfile, 'optionalAccess', _288 => _288.name]), () => ( "its profile"))}` : "";
10271
10512
  warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to 8-bit RGB${how}.`);
10272
10513
  }
10273
10514
  let layers = [];
@@ -10305,7 +10546,7 @@ function psdToLayers(file, options = {}) {
10305
10546
  const saved = r.id >= RESOURCE_PATH_FIRST && r.id <= RESOURCE_PATH_LAST;
10306
10547
  if (!saved && r.id !== RESOURCE_WORK_PATH) continue;
10307
10548
  const read2 = componentsFromPathResource(r.data, header.width, header.height);
10308
- if (!_optionalChain([read2, 'optionalAccess', _275 => _275.components, 'access', _276 => _276.length])) continue;
10549
+ if (!_optionalChain([read2, 'optionalAccess', _289 => _289.components, 'access', _290 => _290.length])) continue;
10309
10550
  if (read2.inverted) warn.extra.push(`The path "${r.name || "Work Path"}" starts by subtracting, which Pixerate's paths do not keep; it came in without that.`);
10310
10551
  paths.push(saved ? { name: r.name || `Path ${paths.length + 1}`, components: read2.components } : { name: "Work Path", components: read2.components, work: true });
10311
10552
  }
@@ -10395,15 +10636,15 @@ var pct = (d, key, fallback) => num3(d, key, fallback * 100) / 100;
10395
10636
  var bool = (d, key) => descBool(d, key) === true;
10396
10637
  var enumOf3 = (d, key) => {
10397
10638
  const v = descGet(d, key);
10398
- return _optionalChain([v, 'optionalAccess', _277 => _277.type]) === "enum" ? v.value : void 0;
10639
+ return _optionalChain([v, 'optionalAccess', _291 => _291.type]) === "enum" ? v.value : void 0;
10399
10640
  };
10400
10641
  var text2 = (d, key) => {
10401
10642
  const v = d ? descGet(d, key) : void 0;
10402
- return _optionalChain([v, 'optionalAccess', _278 => _278.type]) === "TEXT" ? v.value : "";
10643
+ return _optionalChain([v, 'optionalAccess', _292 => _292.type]) === "TEXT" ? v.value : "";
10403
10644
  };
10404
10645
  var list = (d, key) => {
10405
10646
  const v = descGet(d, key);
10406
- if (_optionalChain([v, 'optionalAccess', _279 => _279.type]) !== "VlLs") return [];
10647
+ if (_optionalChain([v, 'optionalAccess', _293 => _293.type]) !== "VlLs") return [];
10407
10648
  return v.items.flatMap((it) => it.type === "Objc" || it.type === "GlbO" ? [it.value] : []);
10408
10649
  };
10409
10650
  var clamp3 = (v, lo, hi) => Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : lo;
@@ -10473,8 +10714,8 @@ function contourOf(d, key) {
10473
10714
  return { name, points };
10474
10715
  }
10475
10716
  function contourDesc(c) {
10476
- const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _280 => _280.name]), () => ( "Linear"));
10477
- const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _281 => _281.points]), () => ( [
10717
+ const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _294 => _294.name]), () => ( "Linear"));
10718
+ const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _295 => _295.points]), () => ( [
10478
10719
  { input: 0, output: 0 },
10479
10720
  { input: 1, output: 1 }
10480
10721
  ]));
@@ -10509,7 +10750,7 @@ function gradientOf(d, notes) {
10509
10750
  { position: 0, color: "#000000" },
10510
10751
  { position: 1, color: "#ffffff" }
10511
10752
  ],
10512
- style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _282 => _282.find, 'call', _283 => _283(([, id]) => id === enumOf3(d, "Type")), 'optionalAccess', _284 => _284[0]]), () => ( "linear")),
10753
+ style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _296 => _296.find, 'call', _297 => _297(([, id]) => id === enumOf3(d, "Type")), 'optionalAccess', _298 => _298[0]]), () => ( "linear")),
10513
10754
  angle: clamp3(num3(d, "Angl", 90), -360, 360),
10514
10755
  scale: clamp3(pct(d, "Scl ", 1), 0.1, 1.5),
10515
10756
  reverse: bool(d, "Rvrs"),
@@ -10563,7 +10804,7 @@ function gradientItems(g) {
10563
10804
  )
10564
10805
  )
10565
10806
  };
10566
- const op = _optionalChain([g, 'access', _285 => _285.opacityStops, 'optionalAccess', _286 => _286.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
10807
+ const op = _optionalChain([g, 'access', _299 => _299.opacityStops, 'optionalAccess', _300 => _300.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
10567
10808
  const trns = {
10568
10809
  type: "VlLs",
10569
10810
  items: op.map(
@@ -11060,9 +11301,9 @@ function prepareNestedLayers(layers) {
11060
11301
  if (l.type === "annotation") continue;
11061
11302
  let next = l;
11062
11303
  if (l.type === "group") next = { ...l, children: prepareNestedLayers(l.children) };
11063
- else if (l.type === "pixel" && (_optionalChain([l, 'access', _287 => _287.filters, 'optionalAccess', _288 => _288.length]) || l.source === "document")) {
11304
+ else if (l.type === "pixel" && (_optionalChain([l, 'access', _301 => _301.filters, 'optionalAccess', _302 => _302.length]) || l.source === "document")) {
11064
11305
  const p = { ...l };
11065
- if (_optionalChain([l, 'access', _289 => _289.filters, 'optionalAccess', _290 => _290.some, 'call', _291 => _291(isActiveFilter)])) {
11306
+ if (_optionalChain([l, 'access', _303 => _303.filters, 'optionalAccess', _304 => _304.some, 'call', _305 => _305(isActiveFilter)])) {
11066
11307
  const b = l.surface.bounds;
11067
11308
  if (b) {
11068
11309
  const r = { x: b.x + l.offset.x - 64, y: b.y + l.offset.y - 64, width: b.width + 128, height: b.height + 128 };
@@ -11079,7 +11320,7 @@ function prepareNestedLayers(layers) {
11079
11320
  delete p.source;
11080
11321
  next = p;
11081
11322
  }
11082
- if (_optionalChain([next, 'access', _292 => _292.mask, 'optionalAccess', _293 => _293.source])) {
11323
+ if (_optionalChain([next, 'access', _306 => _306.mask, 'optionalAccess', _307 => _307.source])) {
11083
11324
  next = { ...next };
11084
11325
  delete next.mask;
11085
11326
  }
@@ -11196,7 +11437,7 @@ function exportPsd(input) {
11196
11437
  return {
11197
11438
  opacity: Math.round(Math.min(1, Math.max(0, layer.opacity)) * 255),
11198
11439
  clipping: layer.clipped ? 1 : 0,
11199
- flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _294 => _294.locks, 'optionalAccess', _295 => _295.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
11440
+ flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _308 => _308.locks, 'optionalAccess', _309 => _309.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
11200
11441
  legacyName: name,
11201
11442
  blocks
11202
11443
  };
@@ -11253,7 +11494,7 @@ function exportPsd(input) {
11253
11494
  }
11254
11495
  case "pixel": {
11255
11496
  if (layer.source === "document") throw new PsdError(`Layer "${layer.name}" reads the document image; resolve its pixels before export.`);
11256
- if (_optionalChain([layer, 'access', _296 => _296.filters, 'optionalAccess', _297 => _297.some, 'call', _298 => _298(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
11497
+ if (_optionalChain([layer, 'access', _310 => _310.filters, 'optionalAccess', _311 => _311.some, 'call', _312 => _312(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
11257
11498
  const extra = [];
11258
11499
  if (layer.fillOpacity !== void 0 && layer.fillOpacity < 1) {
11259
11500
  extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
@@ -11285,7 +11526,7 @@ function exportPsd(input) {
11285
11526
  if (c.linked) note("Linked smart objects were embedded (their preview is written as the contents)", layer.name);
11286
11527
  linkedFiles.set(idnt, smartContentsFile(c));
11287
11528
  }
11288
- let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _299 => _299.psd, 'optionalAccess', _300 => _300.placed]), () => ( psdUuid(`${layer.id}:placed`)));
11529
+ let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _313 => _313.psd, 'optionalAccess', _314 => _314.placed]), () => ( psdUuid(`${layer.id}:placed`)));
11289
11530
  if (placedIds.has(placedId)) placedId = psdUuid(`${layer.id}:placed:${placedIds.size}`);
11290
11531
  placedIds.add(placedId);
11291
11532
  if (placedUnchanged(layer, idnt, placedId)) {
@@ -11295,12 +11536,12 @@ function exportPsd(input) {
11295
11536
  const filterFX = layer.smartFilters ? filterFXDescriptor(layer.smartFilters, dropped) : void 0;
11296
11537
  if (dropped.length) note("Develop smart filters have no Photoshop filter and were left out of the filter list (the layer\u2019s pixels still show them)", layer.name);
11297
11538
  const raw = layer.psd && layer.psd.key !== "PlLd" ? parsePlaced(layer.psd.key, layer.psd.data) : null;
11298
- const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _301 => _301.descriptor]) };
11539
+ const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _315 => _315.descriptor]) };
11299
11540
  const wnotes = [];
11300
11541
  extra.push({ key: "PlLd", data: plldBytes(spec) }, { key: "SoLd", data: soldBytes(spec, wnotes) });
11301
11542
  for (const n2 of wnotes) note(`A smart object: ${n2}`, layer.name);
11302
11543
  }
11303
- const fm = _optionalChain([layer, 'access', _302 => _302.smartFilters, 'optionalAccess', _303 => _303.mask]);
11544
+ const fm = _optionalChain([layer, 'access', _316 => _316.smartFilters, 'optionalAccess', _317 => _317.mask]);
11304
11545
  if (fm && !fm.source) filterItems.push(filterMaskItem(placedId, fm, { x: 0, y: 0, width, height }));
11305
11546
  const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
11306
11547
  const bounds = _chunk474IQG74cjs.contentBounds.call(void 0, layer.surface);
@@ -11328,8 +11569,8 @@ function exportPsd(input) {
11328
11569
  const losses = /* @__PURE__ */ new Set();
11329
11570
  for (const b of shapeBlocks(layer, width, height, _nullishCoalesce(input.resolution, () => ( 72)), losses)) extra.push({ key: b.key, data: padEven(b.data) });
11330
11571
  for (const n2 of losses) note(n2, layer.name);
11331
- if (_optionalChain([layer, 'access', _304 => _304.fill, 'optionalAccess', _305 => _305.type]) === "pattern") patternIds2.add(layer.fill.patternId);
11332
- if (_optionalChain([layer, 'access', _306 => _306.stroke, 'optionalAccess', _307 => _307.paint, 'access', _308 => _308.type]) === "pattern") patternIds2.add(layer.stroke.paint.patternId);
11572
+ if (_optionalChain([layer, 'access', _318 => _318.fill, 'optionalAccess', _319 => _319.type]) === "pattern") patternIds2.add(layer.fill.patternId);
11573
+ if (_optionalChain([layer, 'access', _320 => _320.stroke, 'optionalAccess', _321 => _321.paint, 'access', _322 => _322.type]) === "pattern") patternIds2.add(layer.stroke.paint.patternId);
11333
11574
  } else {
11334
11575
  extra.push({ key: "TySh", data: padEven(tyShForLayer(layer)) });
11335
11576
  }
@@ -11397,7 +11638,7 @@ function exportPsd(input) {
11397
11638
  { id: 1005, name: "", data: rw.result() },
11398
11639
  { id: 1057, name: "", data: version.result() }
11399
11640
  ];
11400
- if (_optionalChain([input, 'access', _309 => _309.iccProfile, 'optionalAccess', _310 => _310.length])) resources.push({ id: 1039, name: "", data: input.iccProfile });
11641
+ if (_optionalChain([input, 'access', _323 => _323.iccProfile, 'optionalAccess', _324 => _324.length])) resources.push({ id: 1039, name: "", data: input.iccProfile });
11401
11642
  resources.push(...alphaChannelResources(_nullishCoalesce(input.alphaChannels, () => ( []))));
11402
11643
  let savedPathId = RESOURCE_PATH_FIRST;
11403
11644
  for (const p of _nullishCoalesce(input.paths, () => ( []))) {
@@ -11818,4 +12059,9 @@ function exportPsd(input) {
11818
12059
 
11819
12060
 
11820
12061
 
11821
- exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.layerMaskSelection = layerMaskSelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustmentLayersFloat = applyAdjustmentLayersFloat; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyLegacyFloat = applyLegacyFloat; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyProcess2Float = applyProcess2Float; exports.applyBoxBlurFloat = applyBoxBlurFloat; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.TEXT_ORIENTATIONS = TEXT_ORIENTATIONS; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.MAX_EFFECT_ANIMATION_MS = MAX_EFFECT_ANIMATION_MS; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.LayerOperationError = LayerOperationError; exports.userErrorMessage = userErrorMessage; exports.isPaintableLayer = isPaintableLayer; exports.defaultActiveLayerId = defaultActiveLayerId; exports.activeLayerAfterRemoval = activeLayerAfterRemoval; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.componentsCoverage = componentsCoverage; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.isActiveVectorMask = isActiveVectorMask; exports.vectorMaskCoverage = vectorMaskCoverage; exports.effectiveLayerMask = effectiveLayerMask; exports.resolveVectorMasks = resolveVectorMasks; exports.offsetVectorMask = offsetVectorMask; exports.transformVectorMask = transformVectorMask; exports.followLayerMove = followLayerMove; exports.vectorMaskBounds = vectorMaskBounds; exports.vectorMaskThumbnail = vectorMaskThumbnail; exports.EDGE_COLOR_RADIUS = EDGE_COLOR_RADIUS; exports.hasEdgeUnmix = hasEdgeUnmix; exports.maskCoverageOverCanvas = maskCoverageOverCanvas; exports.hasSoftBand = hasSoftBand; exports.despillEdge = despillEdge; exports.applyEdgeUnmix = applyEdgeUnmix; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.runLayerFiltersFloat = runLayerFiltersFloat; exports.LayerCompositor = LayerCompositor; exports.compositeDeep = compositeDeep; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.textOrientation = textOrientation; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.ANCHOR_FRACTION = ANCHOR_FRACTION; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.isSmartSurfaceIncomplete = isSmartSurfaceIncomplete; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.activeEffectSmartFilters = activeEffectSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.translateLayer = translateLayer; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.encodeDeepSurface = encodeDeepSurface; exports.decodeDeepSurface = decodeDeepSurface; exports.readEdgeColor = readEdgeColor; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.readShapeComponents = readShapeComponents; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
12062
+
12063
+
12064
+
12065
+
12066
+
12067
+ exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.layerMaskSelection = layerMaskSelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustmentLayersFloat = applyAdjustmentLayersFloat; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyLegacyFloat = applyLegacyFloat; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyProcess2Float = applyProcess2Float; exports.applyBoxBlurFloat = applyBoxBlurFloat; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.TEXT_ORIENTATIONS = TEXT_ORIENTATIONS; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.MAX_EFFECT_ANIMATION_MS = MAX_EFFECT_ANIMATION_MS; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.LayerOperationError = LayerOperationError; exports.userErrorMessage = userErrorMessage; exports.isPaintableLayer = isPaintableLayer; exports.defaultActiveLayerId = defaultActiveLayerId; exports.activeLayerAfterRemoval = activeLayerAfterRemoval; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.componentsCoverage = componentsCoverage; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.VECTOR_MASK_EDGE_DEFAULTS = VECTOR_MASK_EDGE_DEFAULTS; exports.vectorMaskSegments = vectorMaskSegments; exports.validVectorMaskEdges = validVectorMaskEdges; exports.hybridVectorMaskCoverage = hybridVectorMaskCoverage; exports.isActiveVectorMask = isActiveVectorMask; exports.vectorMaskCoverage = vectorMaskCoverage; exports.layerGuide = layerGuide; exports.effectiveLayerMask = effectiveLayerMask; exports.resolveVectorMasks = resolveVectorMasks; exports.offsetVectorMask = offsetVectorMask; exports.transformVectorMask = transformVectorMask; exports.followLayerMove = followLayerMove; exports.vectorMaskBounds = vectorMaskBounds; exports.vectorMaskThumbnail = vectorMaskThumbnail; exports.EDGE_COLOR_RADIUS = EDGE_COLOR_RADIUS; exports.hasEdgeUnmix = hasEdgeUnmix; exports.maskCoverageOverCanvas = maskCoverageOverCanvas; exports.hasSoftBand = hasSoftBand; exports.despillEdge = despillEdge; exports.applyEdgeUnmix = applyEdgeUnmix; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.runLayerFiltersFloat = runLayerFiltersFloat; exports.LayerCompositor = LayerCompositor; exports.compositeDeep = compositeDeep; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.textOrientation = textOrientation; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.ANCHOR_FRACTION = ANCHOR_FRACTION; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.isSmartSurfaceIncomplete = isSmartSurfaceIncomplete; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.activeEffectSmartFilters = activeEffectSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.translateLayer = translateLayer; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.encodeDeepSurface = encodeDeepSurface; exports.decodeDeepSurface = decodeDeepSurface; exports.readEdgeColor = readEdgeColor; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.readShapeComponents = readShapeComponents; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;