@pixerate/editor 0.256.0 → 0.258.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 (124) hide show
  1. package/dist/agent/index.cjs +40 -38
  2. package/dist/agent/index.js +9 -7
  3. package/dist/animation/index.cjs +4 -2
  4. package/dist/animation/index.js +4 -2
  5. package/dist/animation-editor/index.cjs +63 -61
  6. package/dist/animation-editor/index.js +7 -5
  7. package/dist/brushes/colour.d.cts +11 -0
  8. package/dist/brushes/colour.d.ts +11 -0
  9. package/dist/brushes/index.cjs +51 -30
  10. package/dist/brushes/index.d.cts +1 -0
  11. package/dist/brushes/index.d.ts +1 -0
  12. package/dist/brushes/index.js +25 -4
  13. package/dist/brushes/resolve.d.cts +2 -0
  14. package/dist/brushes/resolve.d.ts +2 -0
  15. package/dist/brushes/schema.d.cts +1 -0
  16. package/dist/brushes/schema.d.ts +1 -0
  17. package/dist/brushes/tools.d.cts +7 -0
  18. package/dist/brushes/tools.d.ts +7 -0
  19. package/dist/brushes/types.d.cts +10 -2
  20. package/dist/brushes/types.d.ts +10 -2
  21. package/dist/brushes/ui.d.cts +14 -3
  22. package/dist/brushes/ui.d.ts +14 -3
  23. package/dist/{brushstrokeRender-HCOQUSWW.js → brushstrokeRender-JI4W6F2G.js} +2 -2
  24. package/dist/{brushstrokeRender-ZZOXI5O5.cjs → brushstrokeRender-MQ6PSDM5.cjs} +11 -11
  25. package/dist/canvas/index.cjs +20 -18
  26. package/dist/canvas/index.js +7 -5
  27. package/dist/chart/index.cjs +159 -157
  28. package/dist/chart/index.js +9 -7
  29. package/dist/{chunk-7272D3K2.js → chunk-2EUW2XZX.js} +27 -276
  30. package/dist/{chunk-L6Y7TSQ4.js → chunk-2VJ6OVJV.js} +1 -1
  31. package/dist/{chunk-6ZZKRH7R.js → chunk-47V3WXDG.js} +2 -2
  32. package/dist/{chunk-H7ET2ISK.cjs → chunk-4IMD2TLY.cjs} +52 -52
  33. package/dist/{chunk-VUKUTT2W.js → chunk-4M4E3N6X.js} +1 -1
  34. package/dist/{chunk-TBAVCLEQ.cjs → chunk-5Q5MLXAD.cjs} +23 -23
  35. package/dist/{chunk-MONXNVZK.js → chunk-6I23ZCGK.js} +5 -3
  36. package/dist/{chunk-GOBOCZZI.js → chunk-6NQPKNUZ.js} +1 -1
  37. package/dist/{chunk-WYGSR3IJ.js → chunk-AORZ5M5C.js} +1 -1
  38. package/dist/chunk-AVTPZO4Z.cjs +142 -0
  39. package/dist/{chunk-WKMUBATU.js → chunk-C2WEIEUB.js} +1 -1
  40. package/dist/{chunk-P3K2JCJA.js → chunk-D5BXSOSU.js} +3 -3
  41. package/dist/chunk-E2V5DA3W.js +36 -0
  42. package/dist/{chunk-WZOGDKCQ.js → chunk-F7CPSRLN.js} +0 -133
  43. package/dist/chunk-FJBQTZS4.js +17 -0
  44. package/dist/{chunk-SOSBOS5T.cjs → chunk-G23BTQA5.cjs} +22 -22
  45. package/dist/{chunk-EUIDTZNQ.cjs → chunk-I3Y2Q3PM.cjs} +59 -308
  46. package/dist/{chunk-YHUMGBZD.js → chunk-ICTPLVSR.js} +22 -4
  47. package/dist/{chunk-LRNUZKWV.cjs → chunk-IPUTIUGQ.cjs} +1 -1
  48. package/dist/{chunk-6GRUVGKU.js → chunk-ITURMC2M.js} +3 -3
  49. package/dist/{chunk-HYWRU5VX.js → chunk-IXQZHCOF.js} +1 -1
  50. package/dist/chunk-J5UQHWVL.js +142 -0
  51. package/dist/{chunk-YBAPT7NL.js → chunk-JC2SHA4A.js} +1 -23
  52. package/dist/chunk-LRTR4ASZ.cjs +17 -0
  53. package/dist/{chunk-HUAISCUX.cjs → chunk-M2HG5DJ2.cjs} +18 -18
  54. package/dist/{chunk-N76AMOKE.cjs → chunk-MDLEGVEN.cjs} +42 -42
  55. package/dist/chunk-MEGSQUQO.cjs +36 -0
  56. package/dist/chunk-MLLTWAXH.cjs +276 -0
  57. package/dist/{chunk-RHPSE2YR.js → chunk-MQ6MGIQM.js} +2 -2
  58. package/dist/{chunk-PGPFWC35.cjs → chunk-MQGQTKVW.cjs} +51 -33
  59. package/dist/{chunk-5YWWQ36H.cjs → chunk-O3ZVZSNJ.cjs} +9 -9
  60. package/dist/{chunk-GCTUOTCW.cjs → chunk-P3PZ63M3.cjs} +35 -35
  61. package/dist/{chunk-WRZ6C4TU.cjs → chunk-P6WYDBTH.cjs} +4 -4
  62. package/dist/{chunk-CJ6TBL2N.cjs → chunk-RHEMMGCN.cjs} +16 -16
  63. package/dist/{chunk-HIMGBZAM.cjs → chunk-RSIKDWOP.cjs} +201 -38
  64. package/dist/{chunk-SABJMH6M.cjs → chunk-RVGP2XLF.cjs} +2 -135
  65. package/dist/{chunk-JVRLGV3C.js → chunk-SMTUQWGY.js} +184 -21
  66. package/dist/{chunk-DMTEQ6SH.js → chunk-SSFMWJDK.js} +4 -4
  67. package/dist/{chunk-TFF2GTGN.cjs → chunk-SXQHWXEL.cjs} +2 -24
  68. package/dist/{chunk-IWEVV63O.cjs → chunk-UEYLANO3.cjs} +18 -16
  69. package/dist/chunk-VR6OGHU5.js +276 -0
  70. package/dist/{chunk-AF23QK5F.js → chunk-YQ4PQTBB.js} +1 -1
  71. package/dist/{chunk-B7V34GIH.cjs → chunk-YSGW7VV4.cjs} +88 -88
  72. package/dist/{chunk-3NS5C7FB.cjs → chunk-YYBW6DF2.cjs} +76 -76
  73. package/dist/{chunk-UFEDHACQ.js → chunk-Z7BX4TWO.js} +2 -2
  74. package/dist/{chunk-RUONPPMC.cjs → chunk-ZSE25IZA.cjs} +8 -8
  75. package/dist/color/index.cjs +7 -3
  76. package/dist/color/index.js +18 -14
  77. package/dist/export/index.cjs +8 -6
  78. package/dist/export/index.js +7 -5
  79. package/dist/extensions/index.cjs +11 -9
  80. package/dist/extensions/index.js +10 -8
  81. package/dist/gradient/index.cjs +33 -31
  82. package/dist/gradient/index.js +5 -3
  83. package/dist/image-editor/brush-presets.d.cts +4 -1
  84. package/dist/image-editor/brush-presets.d.ts +4 -1
  85. package/dist/image-editor/controller.d.cts +10 -5
  86. package/dist/image-editor/controller.d.ts +10 -5
  87. package/dist/image-editor/index.cjs +1090 -1073
  88. package/dist/image-editor/index.js +37 -20
  89. package/dist/index.cjs +17 -15
  90. package/dist/index.js +11 -9
  91. package/dist/paint-editor/brushes.d.cts +18 -1
  92. package/dist/paint-editor/brushes.d.ts +18 -1
  93. package/dist/paint-editor/collaboration.d.cts +38 -0
  94. package/dist/paint-editor/collaboration.d.ts +38 -0
  95. package/dist/paint-editor/controller.d.cts +60 -0
  96. package/dist/paint-editor/controller.d.ts +60 -0
  97. package/dist/paint-editor/engine.d.cts +7 -0
  98. package/dist/paint-editor/engine.d.ts +7 -0
  99. package/dist/paint-editor/index.cjs +1564 -1324
  100. package/dist/paint-editor/index.js +1198 -958
  101. package/dist/paint-editor/mark-settings.d.cts +1 -1
  102. package/dist/paint-editor/mark-settings.d.ts +1 -1
  103. package/dist/paint-editor/procedural.d.cts +4 -2
  104. package/dist/paint-editor/procedural.d.ts +4 -2
  105. package/dist/paint-editor/stamp-tip.d.cts +45 -0
  106. package/dist/paint-editor/stamp-tip.d.ts +45 -0
  107. package/dist/paint-editor/stroke.d.cts +4 -0
  108. package/dist/paint-editor/stroke.d.ts +4 -0
  109. package/dist/stickers/index.cjs +4 -2
  110. package/dist/stickers/index.js +6 -4
  111. package/dist/typography/index.cjs +3 -2
  112. package/dist/typography/index.js +2 -1
  113. package/dist/vector/index.cjs +971 -969
  114. package/dist/vector/index.js +8 -6
  115. package/dist/video-editor/index.cjs +4 -2
  116. package/dist/video-editor/index.js +4 -2
  117. package/package.json +1 -1
  118. package/skills/pixerate-brushes/SKILL.md +21 -11
  119. package/skills/pixerate-brushes-design/SKILL.md +6 -2
  120. package/skills/pixerate-brushes-design/evals/canvas-chalk.json +8 -8
  121. package/skills/pixerate-canvas/SKILL.md +3 -2
  122. package/skills/pixerate-image-editor/SKILL.md +1 -1
  123. package/skills/pixerate-paint-editor/SKILL.md +5 -1
  124. package/skills/pixerate-vector/SKILL.md +1 -1
@@ -1,12 +1,22 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
+ var _chunkMEGSQUQOcjs = require('./chunk-MEGSQUQO.cjs');
3
4
 
4
5
 
5
6
 
6
7
 
7
8
 
8
9
 
9
- var _chunkTFF2GTGNcjs = require('./chunk-TFF2GTGN.cjs');
10
+
11
+ var _chunkMLLTWAXHcjs = require('./chunk-MLLTWAXH.cjs');
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+ var _chunkSXQHWXELcjs = require('./chunk-SXQHWXEL.cjs');
10
20
 
11
21
 
12
22
 
@@ -70,7 +80,7 @@ function checkPaletteColors(colors, options = {}) {
70
80
  for (let a = 0; a < seen.length; a++) {
71
81
  for (let b = a + 1; b < seen.length; b++) {
72
82
  if (!seen[a] || !seen[b]) continue;
73
- const distance = _chunkTFF2GTGNcjs.deltaEOK.call(void 0, seen[a], seen[b]);
83
+ const distance = _chunkSXQHWXELcjs.deltaEOK.call(void 0, seen[a], seen[b]);
74
84
  if (!best || distance < best.distance) {
75
85
  best = {
76
86
  a,
@@ -195,7 +205,7 @@ function mixColors(from, to, t, options = {}) {
195
205
  const lab2 = _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, c2);
196
206
  if (alpha <= 1e-9) {
197
207
  const lab3 = { l: lab1.l + (lab2.l - lab1.l) * t, a: 0, b: 0, alpha: 0 };
198
- return _chunkTFF2GTGNcjs.formatHex.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, lab3));
208
+ return _chunkSXQHWXELcjs.formatHex.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, lab3));
199
209
  }
200
210
  const premul = (k) => lab1[k] * lab1.alpha + (lab2[k] * lab2.alpha - lab1[k] * lab1.alpha) * t;
201
211
  const lab = {
@@ -204,7 +214,7 @@ function mixColors(from, to, t, options = {}) {
204
214
  b: premul("b") / alpha,
205
215
  alpha
206
216
  };
207
- return _chunkTFF2GTGNcjs.formatHex.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, lab));
217
+ return _chunkSXQHWXELcjs.formatHex.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, lab));
208
218
  }
209
219
  if (space === "oklch") {
210
220
  const lch1 = _chunk5UEFBM2Mcjs.oklabToOklch.call(void 0, _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, c1));
@@ -217,13 +227,13 @@ function mixColors(from, to, t, options = {}) {
217
227
  const h = ((h1 + (h2 - h1) * t) % 360 + 360) % 360;
218
228
  if (alpha <= 1e-9) {
219
229
  const l2 = lch1.l + (lch2.l - lch1.l) * t;
220
- return _chunkTFF2GTGNcjs.formatHex.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l: l2, c: 0, h: 0, alpha: 0 })));
230
+ return _chunkSXQHWXELcjs.formatHex.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l: l2, c: 0, h: 0, alpha: 0 })));
221
231
  }
222
232
  const lPremul = lch1.l * lch1.alpha + (lch2.l * lch2.alpha - lch1.l * lch1.alpha) * t;
223
233
  const cPremul = lch1.c * lch1.alpha + (lch2.c * lch2.alpha - lch1.c * lch1.alpha) * t;
224
234
  const l = lPremul / alpha;
225
235
  const c = cPremul / alpha;
226
- return _chunkTFF2GTGNcjs.formatHex.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l, c, h, alpha })));
236
+ return _chunkSXQHWXELcjs.formatHex.call(void 0, _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l, c, h, alpha })));
227
237
  }
228
238
  if (space === "srgb-linear") {
229
239
  const lr1 = _chunk5UEFBM2Mcjs.srgbToLinear.call(void 0, c1.r);
@@ -233,7 +243,7 @@ function mixColors(from, to, t, options = {}) {
233
243
  const lg2 = _chunk5UEFBM2Mcjs.srgbToLinear.call(void 0, c2.g);
234
244
  const lb2 = _chunk5UEFBM2Mcjs.srgbToLinear.call(void 0, c2.b);
235
245
  if (alpha <= 1e-9) {
236
- return _chunkTFF2GTGNcjs.formatHex.call(void 0, {
246
+ return _chunkSXQHWXELcjs.formatHex.call(void 0, {
237
247
  r: _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, lr1 + (lr2 - lr1) * t),
238
248
  g: _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, lg1 + (lg2 - lg1) * t),
239
249
  b: _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, lb1 + (lb2 - lb1) * t),
@@ -243,7 +253,7 @@ function mixColors(from, to, t, options = {}) {
243
253
  const premulR2 = lr1 * c1.a + (lr2 * c2.a - lr1 * c1.a) * t;
244
254
  const premulG2 = lg1 * c1.a + (lg2 * c2.a - lg1 * c1.a) * t;
245
255
  const premulB2 = lb1 * c1.a + (lb2 * c2.a - lb1 * c1.a) * t;
246
- return _chunkTFF2GTGNcjs.formatHex.call(void 0, {
256
+ return _chunkSXQHWXELcjs.formatHex.call(void 0, {
247
257
  r: _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, premulR2 / alpha),
248
258
  g: _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, premulG2 / alpha),
249
259
  b: _chunk5UEFBM2Mcjs.linearToSrgb.call(void 0, premulB2 / alpha),
@@ -251,7 +261,7 @@ function mixColors(from, to, t, options = {}) {
251
261
  });
252
262
  }
253
263
  if (alpha <= 1e-9) {
254
- return _chunkTFF2GTGNcjs.formatHex.call(void 0, {
264
+ return _chunkSXQHWXELcjs.formatHex.call(void 0, {
255
265
  r: c1.r + (c2.r - c1.r) * t,
256
266
  g: c1.g + (c2.g - c1.g) * t,
257
267
  b: c1.b + (c2.b - c1.b) * t,
@@ -261,7 +271,7 @@ function mixColors(from, to, t, options = {}) {
261
271
  const premulR = c1.r * c1.a + (c2.r * c2.a - c1.r * c1.a) * t;
262
272
  const premulG = c1.g * c1.a + (c2.g * c2.a - c1.g * c1.a) * t;
263
273
  const premulB = c1.b * c1.a + (c2.b * c2.a - c1.b * c1.a) * t;
264
- return _chunkTFF2GTGNcjs.formatHex.call(void 0, {
274
+ return _chunkSXQHWXELcjs.formatHex.call(void 0, {
265
275
  r: premulR / alpha,
266
276
  g: premulG / alpha,
267
277
  b: premulB / alpha,
@@ -271,260 +281,12 @@ function mixColors(from, to, t, options = {}) {
271
281
 
272
282
  // src/color/recent.ts
273
283
  function pushRecentColor(list, color, max = 12) {
274
- const normal = _chunkTFF2GTGNcjs.normalizeColor.call(void 0, color);
284
+ const normal = _chunkSXQHWXELcjs.normalizeColor.call(void 0, color);
275
285
  if (!normal) return list.slice();
276
- const next = [normal, ...list.filter((c) => _chunkTFF2GTGNcjs.normalizeColor.call(void 0, c) !== normal)];
286
+ const next = [normal, ...list.filter((c) => _chunkSXQHWXELcjs.normalizeColor.call(void 0, c) !== normal)];
277
287
  return next.slice(0, max);
278
288
  }
279
289
 
280
- // src/color/dual.ts
281
- var DEFAULT_SCHEME_SURFACES = {
282
- light: "#ffffff",
283
- dark: "#0b0b0f"
284
- };
285
- var clamp = (v, min, max) => Math.min(max, Math.max(min, v));
286
- function isDualColor(value) {
287
- return typeof value === "object" && value !== null && typeof value.light === "string" && typeof value.dark === "string";
288
- }
289
- function parseDualColor(input) {
290
- if (input === null || input === void 0) return null;
291
- if (isDualColor(input)) {
292
- if (_chunk5UEFBM2Mcjs.parseColor.call(void 0, input.light) === null || _chunk5UEFBM2Mcjs.parseColor.call(void 0, input.dark) === null) {
293
- return null;
294
- }
295
- return { light: input.light, dark: input.dark };
296
- }
297
- if (typeof input === "string") {
298
- const trimmed = input.trim();
299
- if (trimmed.toLowerCase().startsWith("light-dark(") && trimmed.endsWith(")")) {
300
- const inner = trimmed.slice("light-dark(".length, -1).trim();
301
- if (inner.toLowerCase().includes("light-dark(")) {
302
- return null;
303
- }
304
- let depth = 0;
305
- let commaIndex = -1;
306
- for (let i = 0; i < inner.length; i++) {
307
- const char = inner[i];
308
- if (char === "(") {
309
- depth++;
310
- } else if (char === ")") {
311
- depth--;
312
- if (depth < 0) return null;
313
- } else if (char === "," && depth === 0) {
314
- if (commaIndex !== -1) {
315
- return null;
316
- }
317
- commaIndex = i;
318
- }
319
- }
320
- if (depth !== 0 || commaIndex === -1) {
321
- return null;
322
- }
323
- const lightPart = inner.slice(0, commaIndex).trim();
324
- const darkPart = inner.slice(commaIndex + 1).trim();
325
- if (!lightPart || !darkPart) return null;
326
- if (_chunk5UEFBM2Mcjs.parseColor.call(void 0, lightPart) === null || _chunk5UEFBM2Mcjs.parseColor.call(void 0, darkPart) === null) {
327
- return null;
328
- }
329
- return { light: lightPart, dark: darkPart };
330
- }
331
- if (_chunk5UEFBM2Mcjs.parseColor.call(void 0, trimmed) !== null) {
332
- return { light: trimmed, dark: trimmed };
333
- }
334
- }
335
- return null;
336
- }
337
- function normalizeDualColor(input) {
338
- const parsed = parseDualColor(input);
339
- if (!parsed) return null;
340
- const light = _chunkTFF2GTGNcjs.normalizeColor.call(void 0, parsed.light);
341
- const dark = _chunkTFF2GTGNcjs.normalizeColor.call(void 0, parsed.dark);
342
- if (!light || !dark) return null;
343
- return { light, dark };
344
- }
345
- function resolveColor(value, scheme) {
346
- const normalized = normalizeDualColor(value);
347
- if (!normalized) return null;
348
- return scheme === "dark" ? normalized.dark : normalized.light;
349
- }
350
- function formatDualColor(value) {
351
- const light = _nullishCoalesce(_chunkTFF2GTGNcjs.normalizeColor.call(void 0, value.light), () => ( value.light));
352
- const dark = _nullishCoalesce(_chunkTFF2GTGNcjs.normalizeColor.call(void 0, value.dark), () => ( value.dark));
353
- if (light === dark) {
354
- return light;
355
- }
356
- return `light-dark(${light}, ${dark})`;
357
- }
358
- function isSameInBothSchemes(value) {
359
- const light = _chunkTFF2GTGNcjs.normalizeColor.call(void 0, value.light);
360
- const dark = _chunkTFF2GTGNcjs.normalizeColor.call(void 0, value.dark);
361
- if (!light || !dark) return value.light === value.dark;
362
- return light === dark;
363
- }
364
- function setDualColorSide(value, scheme, color) {
365
- const base = _nullishCoalesce(normalizeDualColor(value), () => ( { light: "#000000", dark: "#000000" }));
366
- const normColor = _nullishCoalesce(_chunkTFF2GTGNcjs.normalizeColor.call(void 0, color), () => ( color));
367
- return {
368
- light: scheme === "light" ? normColor : base.light,
369
- dark: scheme === "dark" ? normColor : base.dark
370
- };
371
- }
372
- function deriveDualColor(color, options) {
373
- const fromScheme = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.from]), () => ( "light"));
374
- const baseRgba = _chunk5UEFBM2Mcjs.parseColor.call(void 0, color);
375
- if (!baseRgba) {
376
- throw new Error(`"${String(color)}" is not a colour; pass hex, rgb(), hsl(), oklch() or a CSS colour name.`);
377
- }
378
- if (_optionalChain([options, 'optionalAccess', _3 => _3.surfaces]) && !normalizeDualColor(options.surfaces)) {
379
- throw new Error('The surfaces need a readable light and dark colour, e.g. { light: "#ffffff", dark: "#0b0b0f" }.');
380
- }
381
- const baseHex = _chunkTFF2GTGNcjs.formatHex.call(void 0, baseRgba);
382
- const lab = _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, baseRgba);
383
- const lch = _chunk5UEFBM2Mcjs.oklabToOklch.call(void 0, lab);
384
- const startL = clamp(1.05 - lch.l, 0.12, 0.95);
385
- const targetC = lch.c * 0.9;
386
- const targetH = lch.h;
387
- let derivedHex;
388
- if (_optionalChain([options, 'optionalAccess', _4 => _4.surfaces])) {
389
- const surfaces = options.surfaces;
390
- const fromSurfaceRgba = _chunk5UEFBM2Mcjs.parseColor.call(void 0, surfaces[fromScheme]);
391
- const targetScheme = fromScheme === "light" ? "dark" : "light";
392
- const targetSurfaceRgba = _chunk5UEFBM2Mcjs.parseColor.call(void 0, surfaces[targetScheme]);
393
- const targetRatio = _chunk5UEFBM2Mcjs.contrastRatio.call(void 0, baseRgba, fromSurfaceRgba);
394
- const targetSurfaceL = _chunk5UEFBM2Mcjs.oklabToOklch.call(void 0, _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, targetSurfaceRgba)).l;
395
- const preferHigherL = targetSurfaceL < 0.5;
396
- let bestDiff = Infinity;
397
- let bestL = startL;
398
- for (let candL = 0.05; candL <= 0.98; candL += 5e-3) {
399
- const candRgb = _chunkTFF2GTGNcjs.toSrgbGamut.call(void 0,
400
- _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l: candL, c: targetC, h: targetH, alpha: baseRgba.a }))
401
- );
402
- const ratio = _chunk5UEFBM2Mcjs.contrastRatio.call(void 0, candRgb, targetSurfaceRgba);
403
- const diff = Math.abs(ratio - targetRatio);
404
- const isBetter = diff < bestDiff - 1e-4 || Math.abs(diff - bestDiff) <= 1e-4 && (preferHigherL ? candL > bestL : candL < bestL);
405
- if (isBetter) {
406
- bestDiff = diff;
407
- bestL = candL;
408
- }
409
- }
410
- const finalRgba = _chunkTFF2GTGNcjs.toSrgbGamut.call(void 0,
411
- _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l: bestL, c: targetC, h: targetH, alpha: baseRgba.a }))
412
- );
413
- derivedHex = _chunkTFF2GTGNcjs.formatHex.call(void 0, finalRgba);
414
- } else {
415
- const finalRgba = _chunkTFF2GTGNcjs.toSrgbGamut.call(void 0,
416
- _chunk5UEFBM2Mcjs.oklabToRgb.call(void 0, _chunk5UEFBM2Mcjs.oklchToOklab.call(void 0, { l: startL, c: targetC, h: targetH, alpha: baseRgba.a }))
417
- );
418
- derivedHex = _chunkTFF2GTGNcjs.formatHex.call(void 0, finalRgba);
419
- }
420
- return fromScheme === "light" ? { light: baseHex, dark: derivedHex } : { light: derivedHex, dark: baseHex };
421
- }
422
- function checkDualColorContrast(foreground, background, options) {
423
- const large = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _5 => _5.large]), () => ( false));
424
- const requiredRatio = large ? 3 : 4.5;
425
- const fg = normalizeDualColor(foreground);
426
- const bg = normalizeDualColor(background);
427
- if (!fg) throw new Error(`The foreground "${describeValue(foreground)}" is not a colour, light-dark() or { light, dark }.`);
428
- if (!bg) throw new Error(`The background "${describeValue(background)}" is not a colour, light-dark() or { light, dark }.`);
429
- const lightFgHex = fg.light;
430
- const lightBgHex = bg.light;
431
- const darkFgHex = fg.dark;
432
- const darkBgHex = bg.dark;
433
- const lightFg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, lightFgHex);
434
- const lightBg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, lightBgHex);
435
- const darkFg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, darkFgHex);
436
- const darkBg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, darkBgHex);
437
- const lightRatio = Math.round(_chunk5UEFBM2Mcjs.contrastRatio.call(void 0, lightFg, lightBg) * 100) / 100;
438
- const darkRatio = Math.round(_chunk5UEFBM2Mcjs.contrastRatio.call(void 0, darkFg, darkBg) * 100) / 100;
439
- const lightLevel = _chunk5UEFBM2Mcjs.contrastLevel.call(void 0, lightRatio, { large });
440
- const darkLevel = _chunk5UEFBM2Mcjs.contrastLevel.call(void 0, darkRatio, { large });
441
- const issues = [];
442
- if (lightLevel === "fail") {
443
- issues.push(
444
- `In light mode, ${lightFgHex} on ${lightBgHex} has a contrast of ${lightRatio.toFixed(1)} (needs ${requiredRatio} for AA).`
445
- );
446
- }
447
- if (darkLevel === "fail") {
448
- issues.push(
449
- `In dark mode, ${darkFgHex} on ${darkBgHex} has a contrast of ${darkRatio.toFixed(1)} (needs ${requiredRatio} for AA).`
450
- );
451
- }
452
- return {
453
- light: { ratio: lightRatio, level: lightLevel },
454
- dark: { ratio: darkRatio, level: darkLevel },
455
- issues
456
- };
457
- }
458
- var CSS_VARIABLE_NAME = /^[A-Za-z_][A-Za-z0-9_-]*$/;
459
- function describeValue(value) {
460
- return typeof value === "string" ? value : _nullishCoalesce(JSON.stringify(value), () => ( String(value)));
461
- }
462
- function dualColorsToCss(colors, options) {
463
- const selector = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _6 => _6.selector]), () => ( ":root"));
464
- const strategy = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _7 => _7.strategy]), () => ( "light-dark"));
465
- const darkSelector = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _8 => _8.darkSelector]), () => ( ".dark"));
466
- for (const [label, sel] of [["selector", selector], ["darkSelector", darkSelector]]) {
467
- if (!sel.trim() || /[{};]/.test(sel)) {
468
- throw new Error(`The ${label} "${sel}" is not a CSS selector (it can't be empty or contain "{", "}" or ";").`);
469
- }
470
- }
471
- const normalized = {};
472
- for (const [key, value] of Object.entries(colors)) {
473
- if (!CSS_VARIABLE_NAME.test(key)) {
474
- throw new Error(`"${key}" is not a CSS variable name; use letters, digits, "-" and "_" without the leading "--" (e.g. "brand-color").`);
475
- }
476
- const dual = normalizeDualColor(value);
477
- if (!dual) throw new Error(`"${key}" has "${describeValue(value)}", which is not a colour, light-dark() or { light, dark }.`);
478
- normalized[key] = dual;
479
- }
480
- const sortedKeys = Object.keys(normalized).sort();
481
- switch (strategy) {
482
- case "light-dark": {
483
- const lines = [
484
- `${selector} {`,
485
- ...selector === ":root" ? [" color-scheme: light dark;"] : [],
486
- ...sortedKeys.map((k) => {
487
- return ` --${k}: ${formatDualColor(normalized[k])};`;
488
- }),
489
- "}"
490
- ];
491
- return lines.join("\n");
492
- }
493
- case "media": {
494
- const lightLines = [
495
- `${selector} {`,
496
- ...sortedKeys.map((k) => ` --${k}: ${normalized[k].light};`),
497
- "}"
498
- ];
499
- const darkLines = [
500
- `@media (prefers-color-scheme: dark) {`,
501
- ` ${selector} {`,
502
- ...sortedKeys.map((k) => ` --${k}: ${normalized[k].dark};`),
503
- ` }`,
504
- `}`
505
- ];
506
- return `${lightLines.join("\n")}
507
-
508
- ${darkLines.join("\n")}`;
509
- }
510
- case "class": {
511
- const lightLines = [
512
- `${selector} {`,
513
- ...sortedKeys.map((k) => ` --${k}: ${normalized[k].light};`),
514
- "}"
515
- ];
516
- const darkLines = [
517
- `${darkSelector} {`,
518
- ...sortedKeys.map((k) => ` --${k}: ${normalized[k].dark};`),
519
- "}"
520
- ];
521
- return `${lightLines.join("\n")}
522
-
523
- ${darkLines.join("\n")}`;
524
- }
525
- }
526
- }
527
-
528
290
  // src/color/tools.ts
529
291
  var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
530
292
  var fail = (message) => {
@@ -561,13 +323,13 @@ function requireColor(input, name) {
561
323
  return parsed;
562
324
  }
563
325
  function requireDualColor(input, name) {
564
- const parsed = normalizeDualColor(input);
326
+ const parsed = _chunkMLLTWAXHcjs.normalizeDualColor.call(void 0, input);
565
327
  if (!parsed) {
566
328
  fail(`"${String(input)}" is not a dual colour I can read; use a CSS colour, light-dark(), or { light, dark }.`);
567
329
  }
568
330
  return parsed;
569
331
  }
570
- var findAccessibleLightness = (fg, bg, large) => _chunkTFF2GTGNcjs.suggestAccessibleForeground.call(void 0, fg, bg, { large });
332
+ var findAccessibleLightness = (fg, bg, large) => _chunkMEGSQUQOcjs.suggestAccessibleForeground.call(void 0, fg, bg, { large });
571
333
  function createColorToolProvider(options = {}) {
572
334
  const id = _nullishCoalesce(options.id, () => ( "color"));
573
335
  const namespace = _nullishCoalesce(options.namespace, () => ( "color"));
@@ -587,18 +349,18 @@ function createColorToolProvider(options = {}) {
587
349
  handler: (args) => {
588
350
  const { color } = args;
589
351
  const rgba = requireColor(color, "color");
590
- const inGamut = _chunkTFF2GTGNcjs.inSrgbGamut.call(void 0, rgba);
591
- const mappedRgba = inGamut ? rgba : _chunkTFF2GTGNcjs.toSrgbGamut.call(void 0, rgba);
352
+ const inGamut = _chunkSXQHWXELcjs.inSrgbGamut.call(void 0, rgba);
353
+ const mappedRgba = inGamut ? rgba : _chunkSXQHWXELcjs.toSrgbGamut.call(void 0, rgba);
592
354
  const hsl = _chunk5UEFBM2Mcjs.rgbToHsl.call(void 0, mappedRgba);
593
355
  const oklab = _chunk5UEFBM2Mcjs.rgbToOklab.call(void 0, rgba);
594
356
  const oklch = _chunk5UEFBM2Mcjs.oklabToOklch.call(void 0, oklab);
595
357
  const formats = ["hex", "rgb", "hsl", "oklab", "oklch"];
596
358
  const css = {};
597
359
  for (const f of formats) {
598
- css[f] = _chunkTFF2GTGNcjs.formatColor.call(void 0, rgba, f);
360
+ css[f] = _chunkSXQHWXELcjs.formatColor.call(void 0, rgba, f);
599
361
  }
600
362
  return {
601
- hex: _chunkTFF2GTGNcjs.formatHex.call(void 0, mappedRgba),
363
+ hex: _chunkSXQHWXELcjs.formatHex.call(void 0, mappedRgba),
602
364
  alpha: Math.round(rgba.a * 1e3) / 1e3,
603
365
  rgb: {
604
366
  r: Math.round(Math.min(1, Math.max(0, mappedRgba.r)) * 255),
@@ -617,7 +379,7 @@ function createColorToolProvider(options = {}) {
617
379
  },
618
380
  css,
619
381
  inSrgbGamut: inGamut,
620
- ...inGamut ? {} : { gamutMappedHex: _chunkTFF2GTGNcjs.formatHex.call(void 0, mappedRgba) },
382
+ ...inGamut ? {} : { gamutMappedHex: _chunkSXQHWXELcjs.formatHex.call(void 0, mappedRgba) },
621
383
  relativeLuminance: Math.round(_chunk5UEFBM2Mcjs.relativeLuminance.call(void 0, mappedRgba) * 1e4) / 1e4
622
384
  };
623
385
  }
@@ -645,7 +407,7 @@ function createColorToolProvider(options = {}) {
645
407
  const level = _chunk5UEFBM2Mcjs.contrastLevel.call(void 0, ratio, { large });
646
408
  const passesAA = level === "AA" || level === "AAA";
647
409
  const passesAAA = level === "AAA";
648
- const suggestion = passesAA ? void 0 : _chunkTFF2GTGNcjs.suggestAccessibleForeground.call(void 0, fg, bg, { large });
410
+ const suggestion = passesAA ? void 0 : _chunkMEGSQUQOcjs.suggestAccessibleForeground.call(void 0, fg, bg, { large });
649
411
  return {
650
412
  ratio,
651
413
  level,
@@ -727,7 +489,7 @@ function createColorToolProvider(options = {}) {
727
489
  handler: (args) => {
728
490
  const { base, kind, wheel = "rgb", spread } = args;
729
491
  const rgba = requireColor(base, "base");
730
- const hex = _chunkTFF2GTGNcjs.formatHex.call(void 0, _chunkTFF2GTGNcjs.toSrgbGamut.call(void 0, rgba));
492
+ const hex = _chunkSXQHWXELcjs.formatHex.call(void 0, _chunkSXQHWXELcjs.toSrgbGamut.call(void 0, rgba));
731
493
  if (!HARMONY_KINDS.includes(kind)) {
732
494
  fail(`Unknown harmony kind "${kind}"; expected one of ${HARMONY_KINDS.join(", ")}.`);
733
495
  }
@@ -827,8 +589,8 @@ function createColorToolProvider(options = {}) {
827
589
  }
828
590
  const baseDual = requireDualColor(color, "color");
829
591
  const baseHex = from === "dark" ? baseDual.dark : baseDual.light;
830
- const resolvedSurfaces = surfaces ? requireDualColor(surfaces, "surfaces") : DEFAULT_SCHEME_SURFACES;
831
- const derived = deriveDualColor(baseHex, {
592
+ const resolvedSurfaces = surfaces ? requireDualColor(surfaces, "surfaces") : _chunkMLLTWAXHcjs.DEFAULT_SCHEME_SURFACES;
593
+ const derived = _chunkMLLTWAXHcjs.deriveDualColor.call(void 0, baseHex, {
832
594
  from,
833
595
  surfaces: keepContrast ? resolvedSurfaces : void 0
834
596
  });
@@ -839,7 +601,7 @@ function createColorToolProvider(options = {}) {
839
601
  return {
840
602
  light: derived.light,
841
603
  dark: derived.dark,
842
- css: formatDualColor(derived),
604
+ css: _chunkMLLTWAXHcjs.formatDualColor.call(void 0, derived),
843
605
  contrast: {
844
606
  light: lightRatio,
845
607
  dark: darkRatio
@@ -875,7 +637,7 @@ function createColorToolProvider(options = {}) {
875
637
  const { foreground, background, large = false } = args;
876
638
  const fg = requireDualColor(foreground, "foreground");
877
639
  const bg = requireDualColor(background, "background");
878
- const res = checkDualColorContrast(fg, bg, { large });
640
+ const res = _chunkMLLTWAXHcjs.checkDualColorContrast.call(void 0, fg, bg, { large });
879
641
  let suggestion;
880
642
  if (res.light.level === "fail") {
881
643
  const lightFg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, fg.light);
@@ -936,11 +698,11 @@ function createColorToolProvider(options = {}) {
936
698
  fail('"colors" must be an object with at least one colour property.');
937
699
  }
938
700
  for (const [k, v] of Object.entries(colors)) {
939
- if (!normalizeDualColor(v)) {
701
+ if (!_chunkMLLTWAXHcjs.normalizeDualColor.call(void 0, v)) {
940
702
  fail(`Property "${k}" contains invalid colour "${String(v)}".`);
941
703
  }
942
704
  }
943
- const css = dualColorsToCss(colors, { selector, strategy, darkSelector });
705
+ const css = _chunkMLLTWAXHcjs.dualColorsToCss.call(void 0, colors, { selector, strategy, darkSelector });
944
706
  return { css };
945
707
  }
946
708
  };
@@ -964,7 +726,7 @@ function createColorToolProvider(options = {}) {
964
726
  }
965
727
 
966
728
  // src/color/picker.ts
967
- var clamp2 = (val, min, max) => Math.max(min, Math.min(max, val));
729
+ var clamp = (val, min, max) => Math.max(min, Math.min(max, val));
968
730
  function pickerStateFromColor(input, previous) {
969
731
  if (input === null || input === void 0) return null;
970
732
  let rgba;
@@ -976,7 +738,7 @@ function pickerStateFromColor(input, previous) {
976
738
  return null;
977
739
  }
978
740
  if (!rgba) return null;
979
- const clampedRgba = _chunkTFF2GTGNcjs.toSrgbGamut.call(void 0, rgba);
741
+ const clampedRgba = _chunkSXQHWXELcjs.toSrgbGamut.call(void 0, rgba);
980
742
  const hsva = _chunk5UEFBM2Mcjs.rgbToHsv.call(void 0, clampedRgba);
981
743
  let h = hsva.h;
982
744
  let s = hsva.s;
@@ -991,10 +753,10 @@ function pickerStateFromColor(input, previous) {
991
753
  }
992
754
  }
993
755
  return {
994
- h: clamp2(h, 0, 360) % 360,
995
- s: clamp2(s, 0, 1),
996
- v: clamp2(v, 0, 1),
997
- alpha: clamp2(alpha, 0, 1)
756
+ h: clamp(h, 0, 360) % 360,
757
+ s: clamp(s, 0, 1),
758
+ v: clamp(v, 0, 1),
759
+ alpha: clamp(alpha, 0, 1)
998
760
  };
999
761
  }
1000
762
  function pickerStateToHex(state, forceAlpha = false) {
@@ -1004,7 +766,7 @@ function pickerStateToHex(state, forceAlpha = false) {
1004
766
  v: state.v,
1005
767
  alpha: state.alpha
1006
768
  });
1007
- const hex = _chunkTFF2GTGNcjs.formatHex.call(void 0, rgba);
769
+ const hex = _chunkSXQHWXELcjs.formatHex.call(void 0, rgba);
1008
770
  if (forceAlpha && hex.length === 7) {
1009
771
  return hex + "ff";
1010
772
  }
@@ -1013,12 +775,12 @@ function pickerStateToHex(state, forceAlpha = false) {
1013
775
  function pickerStateFromArea(state, x, y) {
1014
776
  return {
1015
777
  ...state,
1016
- s: clamp2(x, 0, 1),
1017
- v: clamp2(1 - y, 0, 1)
778
+ s: clamp(x, 0, 1),
779
+ v: clamp(1 - y, 0, 1)
1018
780
  };
1019
781
  }
1020
782
  function pickerStateFromHue(state, t) {
1021
- const clampedT = clamp2(t, 0, 1);
783
+ const clampedT = clamp(t, 0, 1);
1022
784
  const h = clampedT >= 1 ? 0 : clampedT * 360;
1023
785
  return {
1024
786
  ...state,
@@ -1028,7 +790,7 @@ function pickerStateFromHue(state, t) {
1028
790
  function pickerStateFromAlpha(state, t) {
1029
791
  return {
1030
792
  ...state,
1031
- alpha: clamp2(t, 0, 1)
793
+ alpha: clamp(t, 0, 1)
1032
794
  };
1033
795
  }
1034
796
  function pickerKeyStep(state, target, key, shift) {
@@ -1037,16 +799,16 @@ function pickerKeyStep(state, target, key, shift) {
1037
799
  switch (target) {
1038
800
  case "area": {
1039
801
  if (key === "ArrowLeft") {
1040
- return { ...state, s: clamp2(state.s - step, 0, 1) };
802
+ return { ...state, s: clamp(state.s - step, 0, 1) };
1041
803
  }
1042
804
  if (key === "ArrowRight") {
1043
- return { ...state, s: clamp2(state.s + step, 0, 1) };
805
+ return { ...state, s: clamp(state.s + step, 0, 1) };
1044
806
  }
1045
807
  if (key === "ArrowDown") {
1046
- return { ...state, v: clamp2(state.v - step, 0, 1) };
808
+ return { ...state, v: clamp(state.v - step, 0, 1) };
1047
809
  }
1048
810
  if (key === "ArrowUp") {
1049
- return { ...state, v: clamp2(state.v + step, 0, 1) };
811
+ return { ...state, v: clamp(state.v + step, 0, 1) };
1050
812
  }
1051
813
  if (key === "Home") {
1052
814
  return { ...state, s: 0, v: 1 };
@@ -1075,10 +837,10 @@ function pickerKeyStep(state, target, key, shift) {
1075
837
  }
1076
838
  case "alpha": {
1077
839
  if (key === "ArrowLeft" || key === "ArrowDown") {
1078
- return { ...state, alpha: clamp2(state.alpha - step, 0, 1) };
840
+ return { ...state, alpha: clamp(state.alpha - step, 0, 1) };
1079
841
  }
1080
842
  if (key === "ArrowRight" || key === "ArrowUp") {
1081
- return { ...state, alpha: clamp2(state.alpha + step, 0, 1) };
843
+ return { ...state, alpha: clamp(state.alpha + step, 0, 1) };
1082
844
  }
1083
845
  if (key === "Home") {
1084
846
  return { ...state, alpha: 0 };
@@ -1094,17 +856,17 @@ function pickerKeyStep(state, target, key, shift) {
1094
856
  }
1095
857
  function pickerAreaBackground(state) {
1096
858
  const pureHueRgb = _chunk5UEFBM2Mcjs.hsvToRgb.call(void 0, { h: state.h, s: 1, v: 1, alpha: 1 });
1097
- const hueHex = _chunkTFF2GTGNcjs.formatHex.call(void 0, pureHueRgb);
859
+ const hueHex = _chunkSXQHWXELcjs.formatHex.call(void 0, pureHueRgb);
1098
860
  return `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${hueHex})`;
1099
861
  }
1100
862
  function pickerAlphaBackground(state) {
1101
863
  const opaqueRgb = _chunk5UEFBM2Mcjs.hsvToRgb.call(void 0, { h: state.h, s: state.s, v: state.v, alpha: 1 });
1102
- const hex = _chunkTFF2GTGNcjs.formatHex.call(void 0, opaqueRgb);
864
+ const hex = _chunkSXQHWXELcjs.formatHex.call(void 0, opaqueRgb);
1103
865
  return `linear-gradient(to right, transparent, ${hex})`;
1104
866
  }
1105
867
  var PICKER_HUE_BACKGROUND = "linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%)";
1106
868
  function dualPickerView(value, scheme) {
1107
- const norm = _nullishCoalesce(normalizeDualColor(value), () => ( { light: "#000000", dark: "#000000" }));
869
+ const norm = _nullishCoalesce(_chunkMLLTWAXHcjs.normalizeDualColor.call(void 0, value), () => ( { light: "#000000", dark: "#000000" }));
1108
870
  const otherScheme = scheme === "light" ? "dark" : "light";
1109
871
  return {
1110
872
  color: norm[scheme],
@@ -1133,15 +895,4 @@ function dualPickerView(value, scheme) {
1133
895
 
1134
896
 
1135
897
 
1136
-
1137
-
1138
-
1139
-
1140
-
1141
-
1142
-
1143
-
1144
-
1145
-
1146
-
1147
- exports.simulateColorVision = simulateColorVision; exports.checkPaletteColors = checkPaletteColors; exports.HARMONY_KINDS = HARMONY_KINDS; exports.wheelToHue = wheelToHue; exports.hueToWheel = hueToWheel; exports.colorHarmony = colorHarmony; exports.mixColors = mixColors; exports.pushRecentColor = pushRecentColor; exports.DEFAULT_SCHEME_SURFACES = DEFAULT_SCHEME_SURFACES; exports.isDualColor = isDualColor; exports.parseDualColor = parseDualColor; exports.normalizeDualColor = normalizeDualColor; exports.resolveColor = resolveColor; exports.formatDualColor = formatDualColor; exports.isSameInBothSchemes = isSameInBothSchemes; exports.setDualColorSide = setDualColorSide; exports.deriveDualColor = deriveDualColor; exports.checkDualColorContrast = checkDualColorContrast; exports.dualColorsToCss = dualColorsToCss; exports.createColorToolProvider = createColorToolProvider; exports.pickerStateFromColor = pickerStateFromColor; exports.pickerStateToHex = pickerStateToHex; exports.pickerStateFromArea = pickerStateFromArea; exports.pickerStateFromHue = pickerStateFromHue; exports.pickerStateFromAlpha = pickerStateFromAlpha; exports.pickerKeyStep = pickerKeyStep; exports.pickerAreaBackground = pickerAreaBackground; exports.pickerAlphaBackground = pickerAlphaBackground; exports.PICKER_HUE_BACKGROUND = PICKER_HUE_BACKGROUND; exports.dualPickerView = dualPickerView;
898
+ exports.simulateColorVision = simulateColorVision; exports.checkPaletteColors = checkPaletteColors; exports.HARMONY_KINDS = HARMONY_KINDS; exports.wheelToHue = wheelToHue; exports.hueToWheel = hueToWheel; exports.colorHarmony = colorHarmony; exports.mixColors = mixColors; exports.pushRecentColor = pushRecentColor; exports.createColorToolProvider = createColorToolProvider; exports.pickerStateFromColor = pickerStateFromColor; exports.pickerStateToHex = pickerStateToHex; exports.pickerStateFromArea = pickerStateFromArea; exports.pickerStateFromHue = pickerStateFromHue; exports.pickerStateFromAlpha = pickerStateFromAlpha; exports.pickerKeyStep = pickerKeyStep; exports.pickerAreaBackground = pickerAreaBackground; exports.pickerAlphaBackground = pickerAlphaBackground; exports.PICKER_HUE_BACKGROUND = PICKER_HUE_BACKGROUND; exports.dualPickerView = dualPickerView;
@@ -1,3 +1,6 @@
1
+ import {
2
+ describeStickerRef
3
+ } from "./chunk-J5UQHWVL.js";
1
4
  import {
2
5
  BRUSH_HOST_PROFILES,
3
6
  BRUSH_JSON_SCHEMA,
@@ -12,7 +15,7 @@ import {
12
15
  normalizeBrushSpec,
13
16
  resolveCategory,
14
17
  resolveEngine
15
- } from "./chunk-JVRLGV3C.js";
18
+ } from "./chunk-SMTUQWGY.js";
16
19
 
17
20
  // src/brushes/patch.ts
18
21
  var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -95,6 +98,21 @@ function createBrushLibraryTools(library, options = {}) {
95
98
  const ids = (await library.list()).map((e) => e.brush.id);
96
99
  throw new BrushLibraryError("unknown_brush", `No brush "${id}". ${closest(id, ids)}list_brush_presets lists them.`);
97
100
  };
101
+ const checkFor = async (brush, p) => {
102
+ const check2 = checkBrush(brush, p);
103
+ const provider = options.stickers?.();
104
+ if (!provider || brush.tip.shape !== "stamp") return check2;
105
+ const issues = [...check2.issues];
106
+ for (const ref of brush.tip.stamps ?? []) {
107
+ if (ref.startsWith("editor:")) continue;
108
+ try {
109
+ await describeStickerRef(provider, ref);
110
+ } catch (e) {
111
+ issues.push({ facet: "tip.stamps", severity: "error", reason: `${p.name} can't load sticker "${ref}": ${e.message}`, fix: "Use a ref from find_stickers, or an editor stamp (editor:star, editor:dot\u2026)." });
112
+ }
113
+ }
114
+ return { ok: !issues.some((i) => i.severity === "error"), issues };
115
+ };
98
116
  const store = async (raw, overwrite) => {
99
117
  const problems = [];
100
118
  let brush;
@@ -103,7 +121,7 @@ function createBrushLibraryTools(library, options = {}) {
103
121
  } catch (e) {
104
122
  throw new BrushLibraryError("invalid", e.message);
105
123
  }
106
- const check2 = checkBrush(brush, profile);
124
+ const check2 = await checkFor(brush, profile);
107
125
  if (!check2.ok) throw new BrushLibraryError("invalid", refusal(check2, profile));
108
126
  const saved = await library.save(brush, { overwrite });
109
127
  return { ...saved, problems, check: check2 };
@@ -146,7 +164,7 @@ function createBrushLibraryTools(library, options = {}) {
146
164
  handler: async ({ id }) => {
147
165
  const e = await entry(id);
148
166
  const engine = resolveEngine(e.brush);
149
- return { brush: e.brush, builtin: e.builtin, engine, category: resolveCategory(e.brush, engine), check: checkBrush(e.brush, profile) };
167
+ return { brush: e.brush, builtin: e.builtin, engine, category: resolveCategory(e.brush, engine), check: await checkFor(e.brush, profile) };
150
168
  }
151
169
  };
152
170
  const check = {
@@ -176,7 +194,7 @@ function createBrushLibraryTools(library, options = {}) {
176
194
  throw new BrushLibraryError("invalid", e.message);
177
195
  }
178
196
  }
179
- const result = checkBrush(b, p);
197
+ const result = await checkFor(b, p);
180
198
  return { host: p.id, ...result, ...problems.length ? { problems } : {}, ...!result.ok ? { degraded: degrade(b, p) } : {} };
181
199
  }
182
200
  };