@pixerate/editor 0.262.1 → 0.263.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/animation-editor/index.cjs +60 -60
  2. package/dist/animation-editor/index.js +4 -4
  3. package/dist/brushes/index.cjs +52 -52
  4. package/dist/brushes/index.js +4 -4
  5. package/dist/{brushstrokeRender-N6UPZSQS.cjs → brushstrokeRender-2GBME4XD.cjs} +13 -13
  6. package/dist/{brushstrokeRender-25Q5BEY6.js → brushstrokeRender-S5DABANG.js} +3 -3
  7. package/dist/canvas/index.cjs +15 -14
  8. package/dist/canvas/index.js +3 -2
  9. package/dist/canvas/stickers.d.cts +5 -1
  10. package/dist/canvas/stickers.d.ts +5 -1
  11. package/dist/{chunk-6NZL24W4.js → chunk-34HIZXFX.js} +1 -1
  12. package/dist/{chunk-UVZ7RQOE.cjs → chunk-4E6BGHWN.cjs} +1 -1
  13. package/dist/{chunk-J5UQHWVL.js → chunk-6JL2D5SG.js} +27 -15
  14. package/dist/{chunk-QAR2N7HZ.js → chunk-6XX7E7O2.js} +1 -1
  15. package/dist/{chunk-3TQW5MPW.cjs → chunk-73QFSPDG.cjs} +23 -23
  16. package/dist/{chunk-APX63ILU.js → chunk-ACFSFUQH.js} +31 -0
  17. package/dist/{chunk-X2EXYY4J.js → chunk-CNLO6E2K.js} +2 -2
  18. package/dist/{chunk-F7CPSRLN.js → chunk-DOZ6F2K2.js} +12 -4
  19. package/dist/{chunk-CQVTGBQI.js → chunk-JGI4PZWO.js} +1 -1
  20. package/dist/{chunk-EHALWBBD.js → chunk-LG6MEEV7.js} +1 -1
  21. package/dist/{chunk-7AUQ2UJ3.cjs → chunk-LWHUU6A6.cjs} +10 -10
  22. package/dist/{chunk-JSDND7DF.cjs → chunk-OTN6VB5S.cjs} +32 -1
  23. package/dist/{chunk-5IW65VQ6.js → chunk-P5343XZO.js} +1 -1
  24. package/dist/{chunk-AVTPZO4Z.cjs → chunk-PE6YJMQT.cjs} +37 -25
  25. package/dist/{chunk-D4TE5JNW.js → chunk-QW7LKWKE.js} +1 -1
  26. package/dist/{chunk-YLUIFXSL.cjs → chunk-TIHW7CUY.cjs} +35 -35
  27. package/dist/{chunk-PYTJBVW5.cjs → chunk-TILEUVRO.cjs} +31 -31
  28. package/dist/{chunk-RVGP2XLF.cjs → chunk-XORJ7UZO.cjs} +21 -13
  29. package/dist/{chunk-43NT242D.cjs → chunk-XQW6R7VW.cjs} +86 -86
  30. package/dist/{chunk-TZOX7KWV.cjs → chunk-ZBACQHW3.cjs} +8 -8
  31. package/dist/image-editor/index.cjs +789 -788
  32. package/dist/image-editor/index.js +7 -6
  33. package/dist/image-editor/stickers.d.cts +7 -2
  34. package/dist/image-editor/stickers.d.ts +7 -2
  35. package/dist/paint-editor/controller.d.cts +7 -2
  36. package/dist/paint-editor/controller.d.ts +7 -2
  37. package/dist/paint-editor/index.cjs +574 -521
  38. package/dist/paint-editor/index.js +97 -44
  39. package/dist/paint-editor/sticker-art.d.cts +20 -10
  40. package/dist/paint-editor/sticker-art.d.ts +20 -10
  41. package/dist/paint-editor/stickers.d.cts +8 -1
  42. package/dist/paint-editor/stickers.d.ts +8 -1
  43. package/dist/paint-editor/stroke.d.cts +2 -0
  44. package/dist/paint-editor/stroke.d.ts +2 -0
  45. package/dist/stickers/browser.d.cts +10 -3
  46. package/dist/stickers/browser.d.ts +10 -3
  47. package/dist/stickers/combine.d.cts +2 -0
  48. package/dist/stickers/combine.d.ts +2 -0
  49. package/dist/stickers/conformance.d.cts +1 -1
  50. package/dist/stickers/conformance.d.ts +1 -1
  51. package/dist/stickers/errors.d.cts +1 -1
  52. package/dist/stickers/errors.d.ts +1 -1
  53. package/dist/stickers/fake.d.cts +4 -2
  54. package/dist/stickers/fake.d.ts +4 -2
  55. package/dist/stickers/helpers.d.cts +16 -2
  56. package/dist/stickers/helpers.d.ts +16 -2
  57. package/dist/stickers/index.cjs +116 -29
  58. package/dist/stickers/index.js +106 -19
  59. package/dist/stickers/tools.d.cts +9 -2
  60. package/dist/stickers/tools.d.ts +9 -2
  61. package/dist/stickers/types.d.cts +32 -5
  62. package/dist/stickers/types.d.ts +32 -5
  63. package/dist/vector/index.cjs +972 -971
  64. package/dist/vector/index.js +7 -6
  65. package/dist/vector/stickers.d.cts +7 -2
  66. package/dist/vector/stickers.d.ts +7 -2
  67. package/package.json +1 -1
  68. package/skills/pixerate-stickers/SKILL.md +20 -9
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunk7AUQ2UJ3cjs = require('./chunk-7AUQ2UJ3.cjs');
8
+ var _chunkLWHUU6A6cjs = require('./chunk-LWHUU6A6.cjs');
9
9
 
10
10
 
11
11
  var _chunkGF2RBSDMcjs = require('./chunk-GF2RBSDM.cjs');
@@ -1361,12 +1361,12 @@ var unit = (x, y) => {
1361
1361
  return l > 1e-12 && Number.isFinite(l) ? [x / l, y / l] : null;
1362
1362
  };
1363
1363
  function cubicOf(sp, i) {
1364
- const s = _chunk7AUQ2UJ3cjs.subpathSegment.call(void 0, sp, i);
1364
+ const s = _chunkLWHUU6A6cjs.subpathSegment.call(void 0, sp, i);
1365
1365
  if (s.length === 4) return s;
1366
1366
  const [a, b] = s;
1367
1367
  return [a, [a[0] + (b[0] - a[0]) / 3, a[1] + (b[1] - a[1]) / 3], [a[0] + 2 * (b[0] - a[0]) / 3, a[1] + 2 * (b[1] - a[1]) / 3], b];
1368
1368
  }
1369
- var isLine = (sp, i) => _chunk7AUQ2UJ3cjs.subpathSegment.call(void 0, sp, i).length === 2;
1369
+ var isLine = (sp, i) => _chunkLWHUU6A6cjs.subpathSegment.call(void 0, sp, i).length === 2;
1370
1370
  function startTangent(c) {
1371
1371
  for (let k = 1; k < 4; k++) {
1372
1372
  const u = unit(c[k][0] - c[0][0], c[k][1] - c[0][1]);
@@ -1386,10 +1386,10 @@ function sample(c, n, out, withStart) {
1386
1386
  }
1387
1387
  var onAnchor = (a, h) => !h || Math.abs(h.x - a.x) < EPS && Math.abs(h.y - a.y) < EPS;
1388
1388
  function tidy(a, keepType = true) {
1389
- const next = _chunk7AUQ2UJ3cjs.cloneAnchor.call(void 0, a);
1389
+ const next = _chunkLWHUU6A6cjs.cloneAnchor.call(void 0, a);
1390
1390
  if (onAnchor(next, next.in)) delete next.in;
1391
1391
  if (onAnchor(next, next.out)) delete next.out;
1392
- const shown = _chunk7AUQ2UJ3cjs.inferAnchorType.call(void 0, next);
1392
+ const shown = _chunkLWHUU6A6cjs.inferAnchorType.call(void 0, next);
1393
1393
  const type = keepType && a.type ? a.type === "symmetric" && shown !== "symmetric" ? shown === "corner" ? "corner" : "smooth" : a.type === "smooth" && shown === "corner" ? "corner" : a.type : shown;
1394
1394
  if (type === "corner") delete next.type;
1395
1395
  else next.type = type;
@@ -1433,7 +1433,7 @@ function fitAcross(pts, N, t0, t1) {
1433
1433
  return goldenMin(fit, 0, 1);
1434
1434
  }
1435
1435
  function removeAnchorKeepingShape(sp, index) {
1436
- const anchors = sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor);
1436
+ const anchors = sp.anchors.map(_chunkLWHUU6A6cjs.cloneAnchor);
1437
1437
  const n = anchors.length;
1438
1438
  if (index < 0 || index >= n) return { anchors, closed: sp.closed };
1439
1439
  if ((sp.closed || index > 0 && index < n - 1) && n >= 3) {
@@ -1467,12 +1467,12 @@ function removeAnchorKeepingShape(sp, index) {
1467
1467
  }
1468
1468
  function removeAnchorsKeepingShape(sp, indices) {
1469
1469
  const order = [...new Set(indices)].filter((i) => i >= 0 && i < sp.anchors.length).sort((a, b) => b - a);
1470
- return order.reduce((acc, i) => removeAnchorKeepingShape(acc, i), { anchors: sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor), closed: sp.closed });
1470
+ return order.reduce((acc, i) => removeAnchorKeepingShape(acc, i), { anchors: sp.anchors.map(_chunkLWHUU6A6cjs.cloneAnchor), closed: sp.closed });
1471
1471
  }
1472
1472
  function bendSegment(sp, segment, t, p) {
1473
- const anchors = sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor);
1473
+ const anchors = sp.anchors.map(_chunkLWHUU6A6cjs.cloneAnchor);
1474
1474
  const n = anchors.length;
1475
- if (segment < 0 || segment >= _chunk7AUQ2UJ3cjs.subpathSegmentCount.call(void 0, sp) || !Number.isFinite(t) || !Number.isFinite(p.x) || !Number.isFinite(p.y)) return { anchors, closed: sp.closed };
1475
+ if (segment < 0 || segment >= _chunkLWHUU6A6cjs.subpathSegmentCount.call(void 0, sp) || !Number.isFinite(t) || !Number.isFinite(p.x) || !Number.isFinite(p.y)) return { anchors, closed: sp.closed };
1476
1476
  const tc = Math.min(0.95, Math.max(0.05, t));
1477
1477
  const ia = segment;
1478
1478
  const ib = (segment + 1) % n;
@@ -1483,16 +1483,16 @@ function bendSegment(sp, segment, t, p) {
1483
1483
  const oy = (p.y - (a.y + (b.y - a.y) * tc)) / k;
1484
1484
  const c1 = { x: a.x + (b.x - a.x) / 3 + ox, y: a.y + (b.y - a.y) / 3 + oy };
1485
1485
  const c2 = { x: b.x + (a.x - b.x) / 3 + ox, y: b.y + (a.y - b.y) / 3 + oy };
1486
- anchors[ia] = _chunk7AUQ2UJ3cjs.moveAnchorHandle.call(void 0, a, "out", c1);
1487
- anchors[ib] = _chunk7AUQ2UJ3cjs.moveAnchorHandle.call(void 0, b, "in", c2);
1486
+ anchors[ia] = _chunkLWHUU6A6cjs.moveAnchorHandle.call(void 0, a, "out", c1);
1487
+ anchors[ib] = _chunkLWHUU6A6cjs.moveAnchorHandle.call(void 0, b, "in", c2);
1488
1488
  return { anchors, closed: sp.closed };
1489
1489
  }
1490
1490
  function subpathPointAt(sp, segment, t) {
1491
- const [x, y] = _chunkGF2RBSDMcjs.segmentPoint.call(void 0, _chunk7AUQ2UJ3cjs.subpathSegment.call(void 0, sp, segment), t);
1491
+ const [x, y] = _chunkGF2RBSDMcjs.segmentPoint.call(void 0, _chunkLWHUU6A6cjs.subpathSegment.call(void 0, sp, segment), t);
1492
1492
  return { x, y };
1493
1493
  }
1494
1494
  function curvatureMoveAnchor(sp, index, q) {
1495
- const anchors = sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor);
1495
+ const anchors = sp.anchors.map(_chunkLWHUU6A6cjs.cloneAnchor);
1496
1496
  const a = sp.anchors[index];
1497
1497
  if (!a) return { anchors, closed: sp.closed };
1498
1498
  const own = [
@@ -1538,7 +1538,7 @@ function curvatureMoveAnchor(sp, index, q) {
1538
1538
  function cutSubpathAt(sp, at) {
1539
1539
  const n = sp.anchors.length;
1540
1540
  const cuts = [...new Set(at)].filter((i) => Number.isInteger(i) && i >= 0 && i < n && (sp.closed || i > 0 && i < n - 1)).sort((a, b) => a - b);
1541
- if (!cuts.length || n < 2) return [{ anchors: sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor), closed: sp.closed }];
1541
+ if (!cuts.length || n < 2) return [{ anchors: sp.anchors.map(_chunkLWHUU6A6cjs.cloneAnchor), closed: sp.closed }];
1542
1542
  const first = cuts[0];
1543
1543
  const run = sp.closed ? Array.from({ length: n + 1 }, (_, i) => sp.anchors[(first + i) % n]) : sp.anchors;
1544
1544
  const cutSet = new Set(sp.closed ? [...cuts.map((c) => (c - first + n) % n), n] : cuts);
@@ -1546,7 +1546,7 @@ function cutSubpathAt(sp, at) {
1546
1546
  let cur = [];
1547
1547
  run.forEach((a, i) => {
1548
1548
  if (!cutSet.has(i)) {
1549
- cur.push(_chunk7AUQ2UJ3cjs.cloneAnchor.call(void 0, a));
1549
+ cur.push(_chunkLWHUU6A6cjs.cloneAnchor.call(void 0, a));
1550
1550
  return;
1551
1551
  }
1552
1552
  if (cur.length) {
@@ -1561,10 +1561,10 @@ function cutSubpathAt(sp, at) {
1561
1561
  }
1562
1562
  function splitSubpathAt(sp, segment, t, endTolerance = 1e-6) {
1563
1563
  const n = sp.anchors.length;
1564
- if (segment < 0 || segment >= _chunk7AUQ2UJ3cjs.subpathSegmentCount.call(void 0, sp)) return [{ anchors: sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor), closed: sp.closed }];
1564
+ if (segment < 0 || segment >= _chunkLWHUU6A6cjs.subpathSegmentCount.call(void 0, sp)) return [{ anchors: sp.anchors.map(_chunkLWHUU6A6cjs.cloneAnchor), closed: sp.closed }];
1565
1565
  if (t <= endTolerance) return cutSubpathAt(sp, [segment]);
1566
1566
  if (t >= 1 - endTolerance) return cutSubpathAt(sp, [(segment + 1) % n]);
1567
- const { subpath, index } = _chunk7AUQ2UJ3cjs.insertAnchor.call(void 0, sp, segment, t);
1567
+ const { subpath, index } = _chunkLWHUU6A6cjs.insertAnchor.call(void 0, sp, segment, t);
1568
1568
  return cutSubpathAt(subpath, [index]);
1569
1569
  }
1570
1570
  var endOf = (sp, last) => sp.anchors[last ? sp.anchors.length - 1 : 0];
@@ -1587,7 +1587,7 @@ function joinSubpaths(subpaths, tolerance) {
1587
1587
  const closed = [];
1588
1588
  let open = [];
1589
1589
  for (const sp of subpaths) {
1590
- const copy = { anchors: sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor), closed: sp.closed };
1590
+ const copy = { anchors: sp.anchors.map(_chunkLWHUU6A6cjs.cloneAnchor), closed: sp.closed };
1591
1591
  if (sp.closed || sp.anchors.length < 2) {
1592
1592
  if (sp.anchors.length) closed.push(copy);
1593
1593
  } else open.push(copy);
@@ -1642,7 +1642,7 @@ function smoothSubpath(sp, amount = 1, only) {
1642
1642
  const t = Math.min(1, Math.max(0, amount));
1643
1643
  const orig = sp.anchors;
1644
1644
  const n = orig.length;
1645
- const anchors = orig.map(_chunk7AUQ2UJ3cjs.cloneAnchor);
1645
+ const anchors = orig.map(_chunkLWHUU6A6cjs.cloneAnchor);
1646
1646
  if (n < 3 || t === 0) return { anchors, closed: sp.closed };
1647
1647
  for (let i = 0; i < n; i++) {
1648
1648
  if (!sp.closed && (i === 0 || i === n - 1)) continue;
@@ -1671,8 +1671,8 @@ function smoothSubpath(sp, amount = 1, only) {
1671
1671
  }
1672
1672
  function segsOf(sp) {
1673
1673
  const out = [];
1674
- for (let i = 0; i < _chunk7AUQ2UJ3cjs.subpathSegmentCount.call(void 0, sp); i++) {
1675
- const s = _chunk7AUQ2UJ3cjs.subpathSegment.call(void 0, sp, i);
1674
+ for (let i = 0; i < _chunkLWHUU6A6cjs.subpathSegmentCount.call(void 0, sp); i++) {
1675
+ const s = _chunkLWHUU6A6cjs.subpathSegment.call(void 0, sp, i);
1676
1676
  out.push(s.length === 2 ? { c: s, line: true } : { c: s, line: false });
1677
1677
  }
1678
1678
  return out;
@@ -1729,7 +1729,7 @@ function removeRedundantPoints(sp, tolerance) {
1729
1729
  const tol = Math.max(tolerance, 1e-9);
1730
1730
  const types = new Map(sp.anchors.filter((a) => a.type).map((a) => [`${a.x},${a.y}`, a.type]));
1731
1731
  const segs = segsOf(sp).filter((s) => !isZeroSeg(s));
1732
- if (!segs.length) return { anchors: sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor), closed: sp.closed };
1732
+ if (!segs.length) return { anchors: sp.anchors.map(_chunkLWHUU6A6cjs.cloneAnchor), closed: sp.closed };
1733
1733
  const minSegs = sp.closed ? 2 : 1;
1734
1734
  let changed = true;
1735
1735
  while (changed && segs.length > minSegs) {
@@ -1747,7 +1747,7 @@ function removeRedundantPoints(sp, tolerance) {
1747
1747
  break;
1748
1748
  }
1749
1749
  }
1750
- return _nullishCoalesce(segsToSubpath(segs, sp.closed, types), () => ( { anchors: sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor), closed: sp.closed }));
1750
+ return _nullishCoalesce(segsToSubpath(segs, sp.closed, types), () => ( { anchors: sp.anchors.map(_chunkLWHUU6A6cjs.cloneAnchor), closed: sp.closed }));
1751
1751
  }
1752
1752
 
1753
1753
 
@@ -61,6 +61,9 @@ function stampCoverage(kind, u, v, t) {
61
61
  }
62
62
  }
63
63
 
64
+ // src/stickers/types.ts
65
+ var STICKER_VARIANTS = ["light", "dark"];
66
+
64
67
  // src/stickers/helpers.ts
65
68
  var DEFAULT_STICKER_PAGE = 24;
66
69
  var MAX_STICKER_PAGE = 100;
@@ -78,6 +81,7 @@ function stickerPage(items, options = {}, query = "") {
78
81
  const tags = (options.tags ?? []).map((t) => t.toLowerCase());
79
82
  const matches = items.filter((s) => {
80
83
  if (options.category && s.category !== options.category) return false;
84
+ if (options.collection && s.collection !== options.collection) return false;
81
85
  if (tags.length && !tags.every((t) => (s.tags ?? []).some((x) => x.toLowerCase() === t))) return false;
82
86
  if (options.licence?.commercial === true && !s.licence.commercial) return false;
83
87
  if (!q.length) return true;
@@ -89,6 +93,28 @@ function stickerPage(items, options = {}, query = "") {
89
93
  const page = matches.slice(start, start + limit);
90
94
  return { items: page, total: matches.length, ...start + limit < matches.length ? { next: String(start + limit) } : {} };
91
95
  }
96
+ function stickerVariantsOf(s) {
97
+ return STICKER_VARIANTS.filter((v) => v === "light" || s.variants?.includes(v));
98
+ }
99
+ function checkStickerVariant(s, variant) {
100
+ const v = variant ?? "light";
101
+ const has = stickerVariantsOf(s);
102
+ if (!has.includes(v)) throw new StickerError("unsupported_variant", `Sticker "${s.id}" has no ${JSON.stringify(v)} variant; it has ${has.join(", ")}.`);
103
+ return v;
104
+ }
105
+ function stickerVariantFor(s, dark) {
106
+ return dark && s.variants?.includes("dark") ? "dark" : "light";
107
+ }
108
+ function stickerCollections(items, names = {}) {
109
+ const out = /* @__PURE__ */ new Map();
110
+ for (const s of items) {
111
+ if (!s.collection) continue;
112
+ const c = out.get(s.collection) ?? { id: s.collection, ...names[s.collection] ?? { name: s.collection }, count: 0 };
113
+ c.count++;
114
+ out.set(s.collection, c);
115
+ }
116
+ return [...out.values()];
117
+ }
92
118
  function parseStickerRef(ref) {
93
119
  if (typeof ref !== "string" || !ref) throw new StickerError("invalid_argument", 'A sticker ref is a "provider:id" string, e.g. "editor:star" (find_stickers lists them).');
94
120
  const i = ref.indexOf(":");
@@ -158,11 +184,16 @@ var StickersSlot = class {
158
184
  export {
159
185
  STAMP_KINDS,
160
186
  stampCoverage,
187
+ STICKER_VARIANTS,
161
188
  DEFAULT_STICKER_PAGE,
162
189
  MAX_STICKER_PAGE,
163
190
  EDITOR_STICKERS_ID,
164
191
  checkStickerSearchOptions,
165
192
  stickerPage,
193
+ stickerVariantsOf,
194
+ checkStickerVariant,
195
+ stickerVariantFor,
196
+ stickerCollections,
166
197
  parseStickerRef,
167
198
  normalizeStickerRef,
168
199
  editorStampOf,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  describeStickerRef
3
- } from "./chunk-J5UQHWVL.js";
3
+ } from "./chunk-6JL2D5SG.js";
4
4
  import {
5
5
  BRUSH_HOST_PROFILES,
6
6
  BRUSH_JSON_SCHEMA,
@@ -15,7 +15,7 @@ import {
15
15
  normalizeBrushSpec,
16
16
  resolveCategory,
17
17
  resolveEngine
18
- } from "./chunk-5IW65VQ6.js";
18
+ } from "./chunk-P5343XZO.js";
19
19
 
20
20
  // src/brushes/patch.ts
21
21
  var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  EDITOR_STICKERS_ID,
3
3
  STAMP_KINDS,
4
+ checkStickerVariant,
4
5
  stampCoverage,
5
6
  stickerPage,
6
7
  stickerRefOf
7
- } from "./chunk-APX63ILU.js";
8
+ } from "./chunk-ACFSFUQH.js";
8
9
  import {
9
10
  StickerError
10
11
  } from "./chunk-SZTI6EER.js";
@@ -209,6 +210,7 @@ function editorStickers() {
209
210
  categories: () => [...new Set(STAMP_KINDS.map((k) => META[k].category))].map((c) => ({ id: c, name: c[0].toUpperCase() + c.slice(1), count: STAMP_KINDS.filter((k) => META[k].category === c).length })),
210
211
  load(id, options = {}) {
211
212
  const k = kind(id);
213
+ checkStickerVariant({ id: k }, options.variant);
212
214
  const colour = options.colour ?? META[k].colour;
213
215
  if (!HEX.test(colour)) throw new StickerError("invalid_argument", `colour ${JSON.stringify(colour)} must be #rrggbb.`);
214
216
  if (options.format === "png") {
@@ -229,7 +231,7 @@ var StickerBrowser = class {
229
231
  constructor(provider, pageSize = 24) {
230
232
  this.provider = provider;
231
233
  this.pageSize = pageSize;
232
- this.s = { query: "", category: "", items: [], total: 0, hasMore: false, loading: false, error: null, categories: [], provider: provider().name };
234
+ this.s = { query: "", category: "", collection: "", items: [], total: 0, hasMore: false, loading: false, error: null, categories: [], collections: [], provider: provider().name };
233
235
  }
234
236
  provider;
235
237
  pageSize;
@@ -256,8 +258,9 @@ var StickerBrowser = class {
256
258
  this.set({ loading: true, error: null, items: [], total: 0, hasMore: false, provider: p.name });
257
259
  try {
258
260
  const categories = await p.categories?.() ?? [];
261
+ const collections = await p.listCollections?.() ?? [];
259
262
  if (run !== this.run) return;
260
- this.set({ categories });
263
+ this.set({ categories, collections, ...this.s.collection && !collections.some((c) => c.id === this.s.collection) ? { collection: "" } : {} });
261
264
  await this.page(run, p, true);
262
265
  } catch (e) {
263
266
  if (run === this.run) this.set({ loading: false, error: e instanceof Error ? e.message : String(e) });
@@ -273,6 +276,11 @@ var StickerBrowser = class {
273
276
  this.s = { ...this.s, category };
274
277
  return this.refresh();
275
278
  }
279
+ /** Shows one collection (`''` for all) from the first page. */
280
+ setCollection(collection) {
281
+ this.s = { ...this.s, collection };
282
+ return this.refresh();
283
+ }
276
284
  /** Loads the next page onto the list. */
277
285
  async more() {
278
286
  if (!this.next || this.s.loading) return;
@@ -285,7 +293,7 @@ var StickerBrowser = class {
285
293
  }
286
294
  }
287
295
  async page(run, p, first) {
288
- const options = { limit: this.pageSize, ...this.s.category ? { category: this.s.category } : {}, ...!first && this.next ? { after: this.next } : {} };
296
+ const options = { limit: this.pageSize, ...this.s.category ? { category: this.s.category } : {}, ...this.s.collection ? { collection: this.s.collection } : {}, ...!first && this.next ? { after: this.next } : {} };
289
297
  const q = this.s.query.trim();
290
298
  const res = q && p.capabilities.supportsSearch ? await p.search(q, options) : await p.list(options);
291
299
  if (run !== this.run) return;
@@ -5,7 +5,7 @@ import {
5
5
  moveAnchorHandle,
6
6
  subpathSegment,
7
7
  subpathSegmentCount
8
- } from "./chunk-6NZL24W4.js";
8
+ } from "./chunk-34HIZXFX.js";
9
9
  import {
10
10
  segmentPoint
11
11
  } from "./chunk-WEIK3UYB.js";
@@ -74,7 +74,7 @@ function profileAlongPolyline(points, values, count = 32) {
74
74
  var round3 = (v) => Math.round(v * 1e3) / 1e3;
75
75
  var loading = null;
76
76
  function loadCanvasBrushstrokeRenderer() {
77
- loading ??= import("./brushstrokeRender-25Q5BEY6.js").catch((error) => {
77
+ loading ??= import("./brushstrokeRender-S5DABANG.js").catch((error) => {
78
78
  loading = null;
79
79
  throw error;
80
80
  });
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkTZOX7KWVcjs = require('./chunk-TZOX7KWV.cjs');
10
+ var _chunkZBACQHW3cjs = require('./chunk-ZBACQHW3.cjs');
11
11
 
12
12
 
13
13
  var _chunkCVFAAZXEcjs = require('./chunk-CVFAAZXE.cjs');
@@ -2536,11 +2536,11 @@ function vectorExtrudeFaces(path, params) {
2536
2536
 
2537
2537
  // src/vector/brushstroke.ts
2538
2538
  var VECTOR_BRUSHSTROKE_SCALE = 2;
2539
- var PRESETS = _chunkTZOX7KWVcjs.listPresets.call(void 0, _chunkTZOX7KWVcjs.VECTOR_PROFILE).map((spec) => _chunkTZOX7KWVcjs.BUILTIN_BRUSHES.find((b) => b.id === spec.id));
2539
+ var PRESETS = _chunkZBACQHW3cjs.listPresets.call(void 0, _chunkZBACQHW3cjs.VECTOR_PROFILE).map((spec) => _chunkZBACQHW3cjs.BUILTIN_BRUSHES.find((b) => b.id === spec.id));
2540
2540
  function admitted(spec) {
2541
2541
  try {
2542
- const brush = _chunkTZOX7KWVcjs.normalizeBrushSpec.call(void 0, spec);
2543
- return _chunkTZOX7KWVcjs.checkBrush.call(void 0, brush, _chunkTZOX7KWVcjs.VECTOR_PROFILE).ok && _chunkPXDIAYB6cjs.isBrushstrokeBrush.call(void 0, _chunkTZOX7KWVcjs.resolveBrush.call(void 0, brush)) ? brush : null;
2542
+ const brush = _chunkZBACQHW3cjs.normalizeBrushSpec.call(void 0, spec);
2543
+ return _chunkZBACQHW3cjs.checkBrush.call(void 0, brush, _chunkZBACQHW3cjs.VECTOR_PROFILE).ok && _chunkPXDIAYB6cjs.isBrushstrokeBrush.call(void 0, _chunkZBACQHW3cjs.resolveBrush.call(void 0, brush)) ? brush : null;
2544
2544
  } catch (e4) {
2545
2545
  return null;
2546
2546
  }
@@ -2549,7 +2549,7 @@ function vectorBrushstrokeBrushes(user = []) {
2549
2549
  const out = [...PRESETS];
2550
2550
  for (const raw of user) {
2551
2551
  const brush = admitted(raw);
2552
- if (brush && !out.some((b) => b.id === brush.id)) out.push(_chunkTZOX7KWVcjs.resolveBrush.call(void 0, brush));
2552
+ if (brush && !out.some((b) => b.id === brush.id)) out.push(_chunkZBACQHW3cjs.resolveBrush.call(void 0, brush));
2553
2553
  }
2554
2554
  return out;
2555
2555
  }
@@ -2559,7 +2559,7 @@ function vectorBrushstrokeBrush(id) {
2559
2559
  function vectorBrushstrokeBrushOf(brush) {
2560
2560
  if (brush.spec) {
2561
2561
  const saved = admitted(brush.spec);
2562
- return saved && saved.id === brush.brushId ? _chunkTZOX7KWVcjs.resolveBrush.call(void 0, saved) : null;
2562
+ return saved && saved.id === brush.brushId ? _chunkZBACQHW3cjs.resolveBrush.call(void 0, saved) : null;
2563
2563
  }
2564
2564
  return vectorBrushstrokeBrush(brush.brushId);
2565
2565
  }
@@ -2567,14 +2567,14 @@ function vectorBrushstrokeBrushError(id, user = []) {
2567
2567
  if (vectorBrushstrokeBrush(id)) return null;
2568
2568
  const saved = user.find((b) => b.id === id);
2569
2569
  const ids = vectorBrushstrokeBrushes(user).map((b) => b.id);
2570
- const reasons = (b) => _chunkTZOX7KWVcjs.checkBrush.call(void 0, b, _chunkTZOX7KWVcjs.VECTOR_PROFILE).issues.filter((i) => i.severity === "error").map((i) => `${i.reason} ${i.fix}`).join(" ") || "it is not a dry dab brush.";
2570
+ const reasons = (b) => _chunkZBACQHW3cjs.checkBrush.call(void 0, b, _chunkZBACQHW3cjs.VECTOR_PROFILE).issues.filter((i) => i.severity === "error").map((i) => `${i.reason} ${i.fix}`).join(" ") || "it is not a dry dab brush.";
2571
2571
  if (saved) return admitted(saved) ? null : `Brush "${id}" (${saved.name}) can't paint a brushstroke: ${reasons(saved)} Use one of: ${ids.join(", ")}.`;
2572
- const preset = _chunkTZOX7KWVcjs.BRUSH_PRESETS.find((b) => b.id === id);
2572
+ const preset = _chunkZBACQHW3cjs.BRUSH_PRESETS.find((b) => b.id === id);
2573
2573
  if (preset) return `Brush "${id}" (${preset.name}) can't paint a brushstroke: ${reasons(preset)} Use one of: ${ids.join(", ")}.`;
2574
- return `Unknown brush "${id}". ${_chunkTZOX7KWVcjs.closest.call(void 0, id, ids)}Use one of: ${ids.join(", ")} (vector.listBrushes lists them).`;
2574
+ return `Unknown brush "${id}". ${_chunkZBACQHW3cjs.closest.call(void 0, id, ids)}Use one of: ${ids.join(", ")} (vector.listBrushes lists them).`;
2575
2575
  }
2576
2576
  function vectorBrushstrokeDefaultColour(id, user = [], scheme = "light") {
2577
- const brush = _nullishCoalesce(_chunkTZOX7KWVcjs.BRUSH_PRESETS.find((b) => b.id === id), () => ( user.find((b) => b.id === id)));
2577
+ const brush = _nullishCoalesce(_chunkZBACQHW3cjs.BRUSH_PRESETS.find((b) => b.id === id), () => ( user.find((b) => b.id === id)));
2578
2578
  return brush ? _chunkLRTR4ASZcjs.brushColourHex.call(void 0, _optionalChain([brush, 'access', _55 => _55.colour, 'optionalAccess', _56 => _56.default]), scheme) : null;
2579
2579
  }
2580
2580
  function sanitizeVectorBrushstroke(value, user = []) {
@@ -61,6 +61,9 @@ function stampCoverage(kind, u, v, t) {
61
61
  }
62
62
  }
63
63
 
64
+ // src/stickers/types.ts
65
+ var STICKER_VARIANTS = ["light", "dark"];
66
+
64
67
  // src/stickers/helpers.ts
65
68
  var DEFAULT_STICKER_PAGE = 24;
66
69
  var MAX_STICKER_PAGE = 100;
@@ -78,6 +81,7 @@ function stickerPage(items, options = {}, query = "") {
78
81
  const tags = (_nullishCoalesce(options.tags, () => ( []))).map((t) => t.toLowerCase());
79
82
  const matches = items.filter((s) => {
80
83
  if (options.category && s.category !== options.category) return false;
84
+ if (options.collection && s.collection !== options.collection) return false;
81
85
  if (tags.length && !tags.every((t) => (_nullishCoalesce(s.tags, () => ( []))).some((x) => x.toLowerCase() === t))) return false;
82
86
  if (_optionalChain([options, 'access', _2 => _2.licence, 'optionalAccess', _3 => _3.commercial]) === true && !s.licence.commercial) return false;
83
87
  if (!q.length) return true;
@@ -89,6 +93,28 @@ function stickerPage(items, options = {}, query = "") {
89
93
  const page = matches.slice(start, start + limit);
90
94
  return { items: page, total: matches.length, ...start + limit < matches.length ? { next: String(start + limit) } : {} };
91
95
  }
96
+ function stickerVariantsOf(s) {
97
+ return STICKER_VARIANTS.filter((v) => v === "light" || _optionalChain([s, 'access', _4 => _4.variants, 'optionalAccess', _5 => _5.includes, 'call', _6 => _6(v)]));
98
+ }
99
+ function checkStickerVariant(s, variant) {
100
+ const v = _nullishCoalesce(variant, () => ( "light"));
101
+ const has = stickerVariantsOf(s);
102
+ if (!has.includes(v)) throw new (0, _chunkU67EN7GGcjs.StickerError)("unsupported_variant", `Sticker "${s.id}" has no ${JSON.stringify(v)} variant; it has ${has.join(", ")}.`);
103
+ return v;
104
+ }
105
+ function stickerVariantFor(s, dark) {
106
+ return dark && _optionalChain([s, 'access', _7 => _7.variants, 'optionalAccess', _8 => _8.includes, 'call', _9 => _9("dark")]) ? "dark" : "light";
107
+ }
108
+ function stickerCollections(items, names = {}) {
109
+ const out = /* @__PURE__ */ new Map();
110
+ for (const s of items) {
111
+ if (!s.collection) continue;
112
+ const c = _nullishCoalesce(out.get(s.collection), () => ( { id: s.collection, ..._nullishCoalesce(names[s.collection], () => ( { name: s.collection })), count: 0 }));
113
+ c.count++;
114
+ out.set(s.collection, c);
115
+ }
116
+ return [...out.values()];
117
+ }
92
118
  function parseStickerRef(ref) {
93
119
  if (typeof ref !== "string" || !ref) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", 'A sticker ref is a "provider:id" string, e.g. "editor:star" (find_stickers lists them).');
94
120
  const i = ref.indexOf(":");
@@ -170,4 +196,9 @@ var StickersSlot = (_class = class {
170
196
 
171
197
 
172
198
 
173
- exports.STAMP_KINDS = STAMP_KINDS; exports.stampCoverage = stampCoverage; exports.DEFAULT_STICKER_PAGE = DEFAULT_STICKER_PAGE; exports.MAX_STICKER_PAGE = MAX_STICKER_PAGE; exports.EDITOR_STICKERS_ID = EDITOR_STICKERS_ID; exports.checkStickerSearchOptions = checkStickerSearchOptions; exports.stickerPage = stickerPage; exports.parseStickerRef = parseStickerRef; exports.normalizeStickerRef = normalizeStickerRef; exports.editorStampOf = editorStampOf; exports.stickerRefOf = stickerRefOf; exports.stickerIdFor = stickerIdFor; exports.closestStickerRefs = closestStickerRefs; exports.StickersSlot = StickersSlot;
199
+
200
+
201
+
202
+
203
+
204
+ exports.STAMP_KINDS = STAMP_KINDS; exports.stampCoverage = stampCoverage; exports.STICKER_VARIANTS = STICKER_VARIANTS; exports.DEFAULT_STICKER_PAGE = DEFAULT_STICKER_PAGE; exports.MAX_STICKER_PAGE = MAX_STICKER_PAGE; exports.EDITOR_STICKERS_ID = EDITOR_STICKERS_ID; exports.checkStickerSearchOptions = checkStickerSearchOptions; exports.stickerPage = stickerPage; exports.stickerVariantsOf = stickerVariantsOf; exports.checkStickerVariant = checkStickerVariant; exports.stickerVariantFor = stickerVariantFor; exports.stickerCollections = stickerCollections; exports.parseStickerRef = parseStickerRef; exports.normalizeStickerRef = normalizeStickerRef; exports.editorStampOf = editorStampOf; exports.stickerRefOf = stickerRefOf; exports.stickerIdFor = stickerIdFor; exports.closestStickerRefs = closestStickerRefs; exports.StickersSlot = StickersSlot;
@@ -2,7 +2,7 @@ import {
2
2
  STAMP_KINDS,
3
3
  editorStampOf,
4
4
  normalizeStickerRef
5
- } from "./chunk-APX63ILU.js";
5
+ } from "./chunk-ACFSFUQH.js";
6
6
  import {
7
7
  validateJsonSchema
8
8
  } from "./chunk-V2ZCJRDM.js";
@@ -4,7 +4,10 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkJSDND7DFcjs = require('./chunk-JSDND7DF.cjs');
7
+
8
+
9
+
10
+ var _chunkOTN6VB5Scjs = require('./chunk-OTN6VB5S.cjs');
8
11
 
9
12
 
10
13
  var _chunkU67EN7GGcjs = require('./chunk-U67EN7GG.cjs');
@@ -14,26 +17,26 @@ var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, o
14
17
  var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
15
18
  function stickerForAgent(provider, s) {
16
19
  const { id, thumbnail: _thumbnail, ...rest } = s;
17
- return { ref: _chunkJSDND7DFcjs.stickerRefOf.call(void 0, provider, id), ...rest };
20
+ return { ref: _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, provider, id), ...rest };
18
21
  }
19
22
  async function knownRefs(provider, cap = 500) {
20
23
  const refs = [];
21
24
  let after;
22
25
  while (refs.length < cap) {
23
- const page = await provider.list({ limit: _chunkJSDND7DFcjs.MAX_STICKER_PAGE, ...after ? { after } : {} });
24
- refs.push(...page.items.map((s) => _chunkJSDND7DFcjs.stickerRefOf.call(void 0, provider, s.id)));
26
+ const page = await provider.list({ limit: _chunkOTN6VB5Scjs.MAX_STICKER_PAGE, ...after ? { after } : {} });
27
+ refs.push(...page.items.map((s) => _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, provider, s.id)));
25
28
  if (!page.next || !page.items.length) break;
26
29
  after = page.next;
27
30
  }
28
31
  return refs;
29
32
  }
30
33
  async function describeStickerRef(provider, ref) {
31
- _chunkJSDND7DFcjs.parseStickerRef.call(void 0, ref);
32
- const id = _chunkJSDND7DFcjs.stickerIdFor.call(void 0, provider, ref);
34
+ _chunkOTN6VB5Scjs.parseStickerRef.call(void 0, ref);
35
+ const id = _chunkOTN6VB5Scjs.stickerIdFor.call(void 0, provider, ref);
33
36
  const found = id === null ? void 0 : await provider.describe(id);
34
37
  if (found) return found;
35
- const near = _chunkJSDND7DFcjs.closestStickerRefs.call(void 0, ref, await knownRefs(provider));
36
- const owner = _chunkJSDND7DFcjs.parseStickerRef.call(void 0, ref).provider;
38
+ const near = _chunkOTN6VB5Scjs.closestStickerRefs.call(void 0, ref, await knownRefs(provider));
39
+ const owner = _chunkOTN6VB5Scjs.parseStickerRef.call(void 0, ref).provider;
37
40
  const where = id === null && !provider.namespaced ? ` The sticker library is "${provider.id}", not "${owner}".` : "";
38
41
  throw new (0, _chunkU67EN7GGcjs.StickerError)("unknown_sticker", `No sticker "${ref}".${where} Closest: ${near.join(", ") || "none"}; find_stickers lists them.`);
39
42
  }
@@ -41,70 +44,78 @@ function createStickerTools(options) {
41
44
  const find = {
42
45
  name: "find_stickers",
43
46
  title: "Find stickers",
44
- description: "Searches the sticker library (the editor's own stamps unless the host plugged in its own): words in the name, tags, category or description, filtered by category, tags and commercial licence, a small page at a time. Returns each sticker's ref (provider:id, for the tools that spray or place stickers), name, category, tags, natural width and height, formats, whether it is tintable (recoloured to the paint colour) and its licence, plus total and next (pass as after for the next page) and the categories. Changes nothing.",
47
+ description: "Searches the sticker library (the editor's own stamps unless the host plugged in its own): words in the name, tags, category or description, filtered by category, collection, tags and commercial licence, a small page at a time. Returns each sticker's ref (provider:id, for the tools that spray or place stickers), name, category, tags, natural width and height, formats, whether it is tintable (recoloured to the paint colour), its licence, aiGenerated when the provider says whether AI made the art, variants (light, and dark when it has art for dark backgrounds) and its collection, plus total and next (pass as after for the next page), the categories and the collections. Changes nothing.",
45
48
  inputSchema: {
46
49
  type: "object",
47
50
  properties: {
48
51
  query: { type: "string", maxLength: 200, description: "Words to match (default: list everything)." },
49
52
  category: { type: "string", description: "Only this category (the result lists them)." },
53
+ collection: { type: "string", minLength: 1, description: "Only this collection id (the result lists them; default every collection)." },
50
54
  tags: { type: "array", maxItems: 10, items: { type: "string", description: "A tag." }, description: "Only stickers with every one of these tags." },
51
55
  commercial: { type: "boolean", description: "true: only stickers whose licence allows commercial use." },
52
- limit: { type: "integer", minimum: 1, maximum: _chunkJSDND7DFcjs.MAX_STICKER_PAGE, description: "Page size (default 24)." },
56
+ limit: { type: "integer", minimum: 1, maximum: _chunkOTN6VB5Scjs.MAX_STICKER_PAGE, description: "Page size (default 24)." },
53
57
  after: { type: "string", description: "next from the previous page." }
54
58
  },
55
59
  additionalProperties: false
56
60
  },
57
61
  annotations: { title: "Find stickers", ...READ },
58
- handler: async ({ query, category, tags, commercial, limit, after }) => {
62
+ handler: async ({ query, category, collection, tags, commercial, limit, after }) => {
59
63
  const p = options.provider();
60
64
  const categories = await _asyncNullishCoalesce(await _optionalChain([p, 'access', _ => _.categories, 'optionalCall', _2 => _2()]), async () => ( null));
61
65
  if (category !== void 0 && categories && !categories.some((c) => c.id === category)) {
62
66
  throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `No category "${category}" in "${p.name}"; categories: ${categories.map((c) => c.id).join(", ")}.`);
63
67
  }
64
- const o = { ...category !== void 0 ? { category } : {}, ...tags ? { tags } : {}, ...commercial ? { licence: { commercial: true } } : {}, ...limit !== void 0 ? { limit } : {}, ...after !== void 0 ? { after } : {} };
68
+ const collections = await _asyncNullishCoalesce(await _optionalChain([p, 'access', _3 => _3.listCollections, 'optionalCall', _4 => _4()]), async () => ( null));
69
+ if (collection !== void 0 && !_optionalChain([collections, 'optionalAccess', _5 => _5.some, 'call', _6 => _6((c) => c.id === collection)])) {
70
+ throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", _optionalChain([collections, 'optionalAccess', _7 => _7.length]) ? `No collection "${collection}" in "${p.name}"; collections: ${collections.map((c) => c.id).join(", ")}.` : `"${p.name}" has no collections; leave collection out.`);
71
+ }
72
+ const o = { ...category !== void 0 ? { category } : {}, ...collection !== void 0 ? { collection } : {}, ...tags ? { tags } : {}, ...commercial ? { licence: { commercial: true } } : {}, ...limit !== void 0 ? { limit } : {}, ...after !== void 0 ? { after } : {} };
65
73
  const q = typeof query === "string" ? query.trim() : "";
66
74
  if (q && !p.capabilities.supportsSearch) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `"${p.name}" can't search; leave query out and filter by category instead.`);
67
75
  const page = q ? await p.search(q, o) : await p.list(o);
68
- return { provider: p.id, items: page.items.map((s) => stickerForAgent(p, s)), total: page.total, ...page.next ? { next: page.next } : {}, ...categories ? { categories } : {} };
76
+ return { provider: p.id, items: page.items.map((s) => stickerForAgent(p, s)), total: page.total, ...page.next ? { next: page.next } : {}, ...categories ? { categories } : {}, ..._optionalChain([collections, 'optionalAccess', _8 => _8.length]) ? { collections } : {} };
69
77
  }
70
78
  };
71
79
  const describe = {
72
80
  name: "describe_sticker",
73
81
  title: "Describe a sticker",
74
- description: "Everything about one sticker by ref (from find_stickers): name, category, tags, natural size, formats, tintable, licence (with any attribution it asks for), dominant colours, variants and its outline as SVG path data (silhouette). An unknown ref is refused with the closest refs. Changes nothing.",
82
+ description: "Everything about one sticker by ref (from find_stickers): name, category, collection, tags, natural size, formats, tintable, licence (with any attribution it asks for), aiGenerated, variants (light / dark), dominant colours and its outline as SVG path data (silhouette). An unknown ref is refused with the closest refs. Changes nothing.",
75
83
  inputSchema: { type: "object", properties: { ref: { type: "string", description: "Sticker ref provider:id from find_stickers (e.g. editor:star)." } }, required: ["ref"], additionalProperties: false },
76
84
  annotations: { title: "Describe a sticker", ...READ },
77
85
  handler: async ({ ref }) => {
78
86
  const p = options.provider();
79
87
  const d = await describeStickerRef(p, ref);
80
88
  const { thumbnail: _thumbnail, id, ...rest } = d;
81
- return { ref: _chunkJSDND7DFcjs.stickerRefOf.call(void 0, p, id), ...rest };
89
+ return { ref: _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, p, id), ...rest };
82
90
  }
83
91
  };
84
92
  return options.insert ? [find, describe, createInsertStickerTool(options.provider, options.insert)] : [find, describe];
85
93
  }
86
- async function loadForHost(provider, ref, d, host, colour, size) {
87
- const id = _chunkJSDND7DFcjs.stickerIdFor.call(void 0, provider, ref);
94
+ async function loadForHost(provider, ref, d, host, colour, size, variant) {
95
+ const id = _chunkOTN6VB5Scjs.stickerIdFor.call(void 0, provider, ref);
88
96
  const format = d.formats.includes(host.format) ? host.format : _nullishCoalesce(d.formats[0], () => ( host.format));
89
- return provider.load(id, { format, ...format === "png" ? { size: Math.max(8, Math.min(_nullishCoalesce(provider.capabilities.maxSize, () => ( 1024)), Math.round(size))) } : {}, ...colour && d.tintable ? { colour } : {} });
97
+ return provider.load(id, { format, ...format === "png" ? { size: Math.max(8, Math.min(_nullishCoalesce(provider.capabilities.maxSize, () => ( 1024)), Math.round(size))) } : {}, ...colour && d.tintable ? { colour } : {}, ...variant !== "light" ? { variant } : {} });
90
98
  }
91
99
  async function insertSticker(provider, host, options) {
92
100
  const d = await describeStickerRef(provider, options.ref);
101
+ const has = _chunkOTN6VB5Scjs.stickerVariantsOf.call(void 0, d);
102
+ if (options.variant !== void 0 && !has.includes(options.variant)) throw new (0, _chunkU67EN7GGcjs.StickerError)("unsupported_variant", `"${options.ref}" has no ${JSON.stringify(options.variant)} variant; it has ${has.join(", ")}. Leave variant out to pick for the background.`);
103
+ const variant = _nullishCoalesce(options.variant, () => ( _chunkOTN6VB5Scjs.stickerVariantFor.call(void 0, d, _nullishCoalesce(_optionalChain([host, 'access', _9 => _9.dark, 'optionalCall', _10 => _10()]), () => ( false)))));
93
104
  if (options.color !== void 0 && !d.tintable) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `"${options.ref}" is not tintable (its art has its own colours); leave color out, or pick a tintable sticker (find_stickers lists tintable).`);
94
105
  if (options.width !== void 0 && !(options.width > 0)) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `width must be a positive size, got ${options.width}.`);
95
106
  const w = _nullishCoalesce(options.width, () => ( d.width));
96
107
  const h = w * d.height / d.width;
97
108
  const centre = host.defaultCentre();
98
- const asset = await loadForHost(provider, options.ref, d, host, options.color, Math.max(w, h));
99
- const ref = _chunkJSDND7DFcjs.stickerRefOf.call(void 0, provider, d.id);
100
- const made = await host.insert({ ref, description: d, asset, x: _nullishCoalesce(options.x, () => ( centre.x)), y: _nullishCoalesce(options.y, () => ( centre.y)), width: w, height: h, ...options.color ? { colour: options.color.toLowerCase() } : {} });
101
- return { ...made, ref, width: w, height: h, licence: d.licence };
109
+ const asset = await loadForHost(provider, options.ref, d, host, options.color, Math.max(w, h), variant);
110
+ const ref = _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, provider, d.id);
111
+ const made = await host.insert({ ref, description: d, asset, variant, x: _nullishCoalesce(options.x, () => ( centre.x)), y: _nullishCoalesce(options.y, () => ( centre.y)), width: w, height: h, ...options.color ? { colour: options.color.toLowerCase() } : {} });
112
+ return { ...made, ref, width: w, height: h, variant, licence: d.licence };
102
113
  }
103
114
  function createInsertStickerTool(provider, host) {
104
115
  return {
105
116
  name: "insert_sticker",
106
117
  title: "Insert a sticker",
107
- description: `Puts one sticker from the sticker library (ref from find_stickers) into the document as a new ${host.noun}, centred at x, y and width wide (its natural aspect kept; default its natural size), tinted to color when the sticker is tintable. Its art is loaded first; an unknown ref is refused with the closest ones. One undo step. Returns the new ${host.noun}'s id (for the editor's own tools, such as effects on it), the ref and its licence (credit any attribution it asks for).`,
118
+ description: `Puts one sticker from the sticker library (ref from find_stickers) into the document as a new ${host.noun}, centred at x, y and width wide (its natural aspect kept; default its natural size), tinted to color when the sticker is tintable, in its dark variant when the background is dark and it has one (or the variant asked for). Its art is loaded first; an unknown ref is refused with the closest ones. One undo step. Returns the new ${host.noun}'s id (for the editor's own tools, such as effects on it), the ref, the variant used and its licence (credit any attribution it asks for).`,
108
119
  inputSchema: {
109
120
  type: "object",
110
121
  properties: {
@@ -112,13 +123,14 @@ function createInsertStickerTool(provider, host) {
112
123
  x: { type: "number", description: "Centre x in document units (default the middle of the view or document)." },
113
124
  y: { type: "number", description: "Centre y in document units (default the middle of the view or document)." },
114
125
  width: { type: "number", exclusiveMinimum: 0, maximum: 1e4, description: "Width in document units (default the natural width); the height follows the aspect." },
115
- color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$", description: "Tint #rrggbb for tintable stickers (default the sticker's own colour); refused for stickers that are not tintable." }
126
+ color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$", description: "Tint #rrggbb for tintable stickers (default the sticker's own colour); refused for stickers that are not tintable." },
127
+ variant: { type: "string", enum: [..._chunkOTN6VB5Scjs.STICKER_VARIANTS], description: "light or dark art (default: dark on a dark background when the sticker has it, else light); one the sticker does not list (find_stickers variants) is refused." }
116
128
  },
117
129
  required: ["ref"],
118
130
  additionalProperties: false
119
131
  },
120
132
  annotations: { title: "Insert a sticker", ...WRITE },
121
- handler: ({ ref, x, y, width, color }) => insertSticker(provider(), host, { ref, x, y, width, color })
133
+ handler: ({ ref, x, y, width, color, variant }) => insertSticker(provider(), host, { ref, x, y, width, color, variant })
122
134
  };
123
135
  }
124
136
  function createStickerToolProvider(options) {
@@ -108,7 +108,7 @@ import {
108
108
  transformTextRect,
109
109
  translateMatrix,
110
110
  warpPresetMesh
111
- } from "./chunk-6NZL24W4.js";
111
+ } from "./chunk-34HIZXFX.js";
112
112
  import {
113
113
  bezierPathBounds,
114
114
  outlineStroke,