@pixerate/editor-react 0.188.0 → 0.190.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.
@@ -60,8 +60,30 @@ function usePaintDirector(controller, options = {}) {
60
60
  const presence = new PaintPresence();
61
61
  return { presence, director: new PaintDirector(controller, presence, options) };
62
62
  });
63
+ useEffect(() => {
64
+ controller.setMutationDirector(value.director);
65
+ return () => controller.setMutationDirector(null);
66
+ }, [controller, value.director]);
63
67
  return value;
64
68
  }
69
+ function useMutationRequests(controller, onRequest) {
70
+ const state = usePaintEditorState(controller);
71
+ const cbRef = useRef(onRequest);
72
+ cbRef.current = onRequest;
73
+ const [last, setLast] = useState(null);
74
+ useEffect(() => {
75
+ return controller.onMutationRequest((m) => {
76
+ setLast(m);
77
+ cbRef.current?.(m);
78
+ });
79
+ }, [controller]);
80
+ const pending = useMemo(() => state.mutations.filter((m) => m.state === "pending"), [state.mutations]);
81
+ return {
82
+ pending,
83
+ mutations: state.mutations,
84
+ last: last && state.mutations.some((m) => m.id === last.id && m.state === "pending") ? last : pending[pending.length - 1] ?? null
85
+ };
86
+ }
65
87
  function usePaintProposals(controller, options = {}) {
66
88
  const [store] = useState(() => createPaintProposals({ ...options, controller }));
67
89
  const state = useSyncExternalStore(store.subscribe, store.getState, store.getState);
@@ -91,6 +113,7 @@ import {
91
113
  PaintGesture,
92
114
  documentToScreen,
93
115
  drawWaterOverlay,
116
+ startDeviceTilt,
94
117
  startWetClock,
95
118
  fitZoom,
96
119
  guideOverlay,
@@ -100,7 +123,7 @@ import {
100
123
  paintProposalGhost
101
124
  } from "@pixerate/editor/paint-editor";
102
125
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
103
- var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, className }) => {
126
+ var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, deviceTilt = false, className }) => {
104
127
  const state = usePaintEditorState(controller);
105
128
  const viewport = useRef2(null);
106
129
  const canvas = useRef2(null);
@@ -147,6 +170,7 @@ var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true,
147
170
  else controller.takeDirty();
148
171
  }, [state, presenter, controller]);
149
172
  useEffect2(() => startWetClock(controller), [controller]);
173
+ useEffect2(() => deviceTilt ? startDeviceTilt(controller) : void 0, [controller, deviceTilt]);
150
174
  useEffect2(() => {
151
175
  const ctx = water.current?.getContext("2d");
152
176
  if (ctx && typeof ctx.createImageData === "function") drawWaterOverlay(controller, ctx);
@@ -685,7 +709,7 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
685
709
  const carried = brushLoadColor(state.mixerLoad);
686
710
  const palette = (spec.colour?.palette ?? []).flatMap((c) => brushColourHex(c, state.colorScheme) ?? []);
687
711
  const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
688
- const loads = (["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint") && !brush.ghost;
712
+ const loads = (["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint") && !brush.ghost && !brush.mutation;
689
713
  return /* @__PURE__ */ jsxs4("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
690
714
  /* @__PURE__ */ jsx5(BrushLibraryBrowser, { entries, activeId: brush.id, onSelect: (id) => controller.setBrush({ id }), thumbnail: (id) => thumbs.get(id) ?? null, thumbnailWidth, thumbnailHeight }),
691
715
  /* @__PURE__ */ jsx5(
@@ -701,12 +725,15 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
701
725
  renderExtra: (section) => {
702
726
  if (section === "shape" && brush.engine === "sticker")
703
727
  return /* @__PURE__ */ jsx5(StickerPicker, { controller, label: "Sticker stamps", selected: brush.sticker.stamps, onPick: (ref) => controller.setBrush({ sticker: { stamps: toggleStickerRef(brush.sticker.stamps, ref) } }) });
704
- if (section === "behaviour" && loads)
705
- return /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1", children: [
706
- /* @__PURE__ */ jsx5("span", { className: "text-slate-400", children: "Carries" }),
707
- /* @__PURE__ */ jsx5("span", { "aria-label": "Brush load", title: carried ?? "Clean", className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: carried ?? "transparent" } }),
708
- brush.engine === "mixer" && /* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
709
- /* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
728
+ if (section === "behaviour")
729
+ return /* @__PURE__ */ jsxs4(Fragment3, { children: [
730
+ brush.mutation && !state.hasMutationAgent && /* @__PURE__ */ jsx5("p", { className: "text-[11px] text-amber-400", role: "status", "data-paint-mutation-unconnected": true, children: "No agent is connected \u2014 mutation strokes will stay as ordinary paint." }),
731
+ loads && /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1", children: [
732
+ /* @__PURE__ */ jsx5("span", { className: "text-slate-400", children: "Carries" }),
733
+ /* @__PURE__ */ jsx5("span", { "aria-label": "Brush load", title: carried ?? "Clean", className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: carried ?? "transparent" } }),
734
+ brush.engine === "mixer" && /* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
735
+ /* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
736
+ ] })
710
737
  ] });
711
738
  if (section === "colour")
712
739
  return /* @__PURE__ */ jsxs4(Fragment3, { children: [
@@ -751,13 +778,15 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
751
778
  };
752
779
 
753
780
  // src/paint-editor/PaperPanel.tsx
754
- import { useMemo as useMemo4 } from "react";
755
- import { DEFAULT_BACKLIGHT_COLOR, LIGHT_SLIDERS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_SLIDERS, patchPath, readPath, renderPaper } from "@pixerate/editor/paint-editor";
781
+ import { useEffect as useEffect4, useMemo as useMemo4, useState as useState5 } from "react";
782
+ import { DEFAULT_BACKLIGHT_COLOR, LIGHT_SLIDERS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_SLIDERS, UV_LIGHT_SLIDERS, VIEW_TILT_SLIDERS, patchPath, readPath, renderPaper, requestDeviceTiltPermission, startDeviceTilt as startDeviceTilt2 } from "@pixerate/editor/paint-editor";
756
783
  import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
757
784
  var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
758
785
  var PaperPanel = ({ controller, className }) => {
759
786
  const state = usePaintEditorState(controller);
760
787
  const [error, attempt] = useAttempt();
788
+ const [tiltFollow, setTiltFollow] = useState5(false);
789
+ useEffect4(() => tiltFollow ? startDeviceTilt2(controller) : void 0, [controller, tiltFollow]);
761
790
  const paper = state.document.paper;
762
791
  const previews = useMemo4(() => new Map(PAPER_LIBRARY.map((p) => [p.preset, { ...SWATCH, data: renderPaper({ ...p, shading: Math.max(0.8, p.shading) }, SWATCH) }])), []);
763
792
  return /* @__PURE__ */ jsxs5("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paper-panel", children: [
@@ -793,16 +822,48 @@ var PaperPanel = ({ controller, className }) => {
793
822
  ] }),
794
823
  /* @__PURE__ */ jsx6("button", { type: "button", className: "self-start px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.setPaper({ seed: paper.seed + 1 })), children: "New sheet" }),
795
824
  /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1.5", "data-testid": "light-panel", children: [
796
- /* @__PURE__ */ jsx6("span", { className: "font-medium text-slate-300", children: "Light (thick paint, metallic paper)" }),
825
+ /* @__PURE__ */ jsx6("span", { className: "font-medium text-slate-300", children: "Light (thick paint, iridescence, metallic paper)" }),
797
826
  LIGHT_SLIDERS.map((c) => /* @__PURE__ */ jsx6(PaintSlider, { control: c, value: readPath(controller.getLighting(), c.path), onChange: (v) => attempt(() => controller.setLighting({ [c.path]: v })) }, c.path)),
798
- /* @__PURE__ */ jsx6("button", { type: "button", className: "self-start px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.flattenRelief()), children: "Flatten relief" })
827
+ VIEW_TILT_SLIDERS.map((c) => /* @__PURE__ */ jsx6(PaintSlider, { control: c, value: readPath(state.viewTilt, c.path), onChange: (v) => attempt(() => controller.setViewTilt({ [c.path]: v })) }, c.path)),
828
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap items-center gap-1", children: [
829
+ /* @__PURE__ */ jsx6(
830
+ "button",
831
+ {
832
+ type: "button",
833
+ "aria-pressed": tiltFollow,
834
+ className: chip(tiltFollow),
835
+ onClick: () => attempt(async () => {
836
+ if (!tiltFollow && !await requestDeviceTiltPermission()) return;
837
+ setTiltFollow((v) => !v);
838
+ }),
839
+ children: "Device tilt"
840
+ }
841
+ ),
842
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "self-start px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.flattenRelief()), children: "Flatten relief" })
843
+ ] })
844
+ ] }),
845
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1.5", "data-testid": "uv-heat-panel", children: [
846
+ /* @__PURE__ */ jsx6("span", { className: "font-medium text-slate-300", children: "UV blacklight & heat" }),
847
+ /* @__PURE__ */ jsxs5("label", { className: "flex items-center gap-2", children: [
848
+ /* @__PURE__ */ jsx6("input", { type: "checkbox", checked: state.uvLight.on, onChange: (e) => attempt(() => controller.setUvLight({ on: e.target.checked })) }),
849
+ " UV blacklight"
850
+ ] }),
851
+ UV_LIGHT_SLIDERS.map((c) => /* @__PURE__ */ jsx6(PaintSlider, { control: c, value: readPath(state.uvLight, c.path), onChange: (v) => attempt(() => controller.setUvLight({ [c.path]: v })) }, c.path)),
852
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1.5", children: [
853
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.advanceHeat(10)), children: "Step heat" }),
854
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.clearHeat()), children: "Cool canvas" }),
855
+ state.heat.hotCells > 0 && /* @__PURE__ */ jsxs5("span", { className: "text-[11px] text-amber-400", children: [
856
+ Math.round(state.heat.max * 100),
857
+ "% warm"
858
+ ] })
859
+ ] })
799
860
  ] }),
800
861
  /* @__PURE__ */ jsx6(ErrorLine, { error })
801
862
  ] });
802
863
  };
803
864
 
804
865
  // src/paint-editor/ColorPanel.tsx
805
- import { useMemo as useMemo5, useRef as useRef5, useState as useState5 } from "react";
866
+ import { useMemo as useMemo5, useRef as useRef5, useState as useState6 } from "react";
806
867
  import {
807
868
  HARMONY_KINDS,
808
869
  MIXING_PAD_HEIGHT,
@@ -823,12 +884,12 @@ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
823
884
  var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className }) => {
824
885
  const state = usePaintEditorState(controller);
825
886
  const [error, attempt] = useAttempt();
826
- const [wheel, setWheel] = useState5("ryb");
827
- const [kind, setKind] = useState5("complementary");
828
- const [padTool, setPadTool] = useState5("paint");
829
- const [sample, setSample] = useState5(3);
830
- const [parts, setParts] = useState5([1, 1]);
831
- const [padName, setPadName] = useState5("");
887
+ const [wheel, setWheel] = useState6("ryb");
888
+ const [kind, setKind] = useState6("complementary");
889
+ const [padTool, setPadTool] = useState6("paint");
890
+ const [sample, setSample] = useState6(3);
891
+ const [parts, setParts] = useState6([1, 1]);
892
+ const [padName, setPadName] = useState6("");
832
893
  const padPoints = useRef5(null);
833
894
  const ring = useMemo5(() => renderColorWheel(wheelSize, wheel), [wheelSize, wheel]);
834
895
  const color = state.color;
@@ -1023,7 +1084,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
1023
1084
  };
1024
1085
 
1025
1086
  // src/paint-editor/PaintLayersPanel.tsx
1026
- import { useState as useState6 } from "react";
1087
+ import { useState as useState7 } from "react";
1027
1088
  import { BLEND_MENU_GROUPS } from "@pixerate/editor/paint-editor";
1028
1089
  import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
1029
1090
  function siblingIndex(layers, l) {
@@ -1033,8 +1094,8 @@ function siblingIndex(layers, l) {
1033
1094
  var PaintLayersPanel = ({ controller, className }) => {
1034
1095
  usePaintEditorState(controller);
1035
1096
  const [error, attempt] = useAttempt();
1036
- const [renaming, setRenaming] = useState6(null);
1037
- const layers = controller.listLayers();
1097
+ const [renaming, setRenaming] = useState7(null);
1098
+ const layers = controller.listLayers().filter((l) => !l.temporary);
1038
1099
  const active = layers.find((l) => l.active) ?? null;
1039
1100
  const light = active?.type === "pixel" ? controller.lightOf(active.id) : null;
1040
1101
  const move = (delta) => {
@@ -1343,14 +1404,14 @@ var StrokePanel = ({ controller, className }) => {
1343
1404
  };
1344
1405
 
1345
1406
  // src/paint-editor/PathStrokePanel.tsx
1346
- import { useState as useState7 } from "react";
1407
+ import { useState as useState8 } from "react";
1347
1408
  import { PATH_STROKE_TAPERS } from "@pixerate/editor/paint-editor";
1348
1409
  import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
1349
1410
  var PathStrokePanel = ({ controller, className }) => {
1350
1411
  const state = usePaintEditorState(controller);
1351
1412
  const [error, attempt] = useAttempt();
1352
- const [path, setPath] = useState7("");
1353
- const [taper, setTaper] = useState7(PATH_STROKE_TAPERS[0].id);
1413
+ const [path, setPath] = useState8("");
1414
+ const [taper, setTaper] = useState8(PATH_STROKE_TAPERS[0].id);
1354
1415
  const pressure = PATH_STROKE_TAPERS.find((t) => t.id === taper)?.pressure;
1355
1416
  return /* @__PURE__ */ jsxs11("div", { className: `${panel} ${className ?? ""}`, "data-testid": "path-stroke-panel", children: [
1356
1417
  /* @__PURE__ */ jsx12("span", { className: "font-medium text-slate-300", children: "Brush a path" }),
@@ -1373,18 +1434,190 @@ var PathStrokePanel = ({ controller, className }) => {
1373
1434
  ] });
1374
1435
  };
1375
1436
 
1437
+ // src/paint-editor/EvolutionPanel.tsx
1438
+ import { useState as useState9, useSyncExternalStore as useSyncExternalStore3 } from "react";
1439
+ import {
1440
+ EVOLUTION_SLIDERS,
1441
+ exportProposalContactSheetPng,
1442
+ liveStrokeRefusal as liveStrokeRefusal2,
1443
+ normalizeMutationRates,
1444
+ paintProposalGhost as paintProposalGhost2,
1445
+ proposalGenomeStrokes
1446
+ } from "@pixerate/editor/paint-editor";
1447
+ import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
1448
+ var EvolutionPanel = ({ controller, proposals, className }) => {
1449
+ const state = usePaintEditorState(controller);
1450
+ const store = proposals ?? controller.proposals;
1451
+ const proposalState = useSyncExternalStore3(store.subscribe, store.getState, store.getState);
1452
+ const [error, attempt] = useAttempt();
1453
+ const [selectedStrokes, setSelectedStrokes] = useState9([]);
1454
+ const [selectedProposals, setSelectedProposals] = useState9([]);
1455
+ const [count, setCount] = useState9(4);
1456
+ const [seed, setSeed] = useState9(1);
1457
+ const [mutation, setMutation] = useState9(() => normalizeMutationRates());
1458
+ const [contactSheetUrl, setContactSheetUrl] = useState9(null);
1459
+ const eligibleStrokes = state.document.strokes.filter((s) => !liveStrokeRefusal2(s.brush));
1460
+ const activeStrokeIds = selectedStrokes.filter((id) => eligibleStrokes.some((s) => s.id === id));
1461
+ const effectiveStrokeIds = activeStrokeIds.length > 0 ? activeStrokeIds : state.selectedStroke && eligibleStrokes.some((s) => s.id === state.selectedStroke) ? [state.selectedStroke] : eligibleStrokes.length > 0 ? [eligibleStrokes[eligibleStrokes.length - 1].id] : [];
1462
+ const variants = proposalState.proposals.filter((p) => proposalGenomeStrokes(p).length > 0);
1463
+ const activeProposalIds = selectedProposals.filter((id) => variants.some((v) => v.id === id));
1464
+ const toggleStroke = (id) => {
1465
+ setSelectedStrokes((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev.slice(-15), id]);
1466
+ };
1467
+ const toggleProposal = (id) => {
1468
+ setSelectedProposals((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev.slice(-1), id]);
1469
+ };
1470
+ return /* @__PURE__ */ jsxs12("div", { className: `${panel} ${className ?? ""}`, "data-testid": "evolution-panel", children: [
1471
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between", children: [
1472
+ /* @__PURE__ */ jsxs12("span", { className: "font-medium text-slate-300", children: [
1473
+ "Evolution (",
1474
+ eligibleStrokes.length,
1475
+ ")"
1476
+ ] }),
1477
+ /* @__PURE__ */ jsx13("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1 text-[11px] text-slate-400", children: [
1478
+ /* @__PURE__ */ jsx13("span", { children: "Count" }),
1479
+ /* @__PURE__ */ jsx13(
1480
+ "input",
1481
+ {
1482
+ type: "number",
1483
+ "aria-label": "Variant count",
1484
+ min: 2,
1485
+ max: 12,
1486
+ value: count,
1487
+ onChange: (e) => setCount(Math.max(2, Math.min(12, Number(e.target.value) || 4))),
1488
+ className: "w-11 rounded bg-slate-800 px-1 py-0.5 text-right font-mono text-slate-200"
1489
+ }
1490
+ )
1491
+ ] }) })
1492
+ ] }),
1493
+ eligibleStrokes.length > 0 && /* @__PURE__ */ jsx13("div", { className: "flex max-h-20 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Parent strokes", children: eligibleStrokes.map((s, i) => {
1494
+ const on = effectiveStrokeIds.includes(s.id);
1495
+ return /* @__PURE__ */ jsx13(
1496
+ "button",
1497
+ {
1498
+ type: "button",
1499
+ role: "option",
1500
+ "aria-selected": on,
1501
+ title: `${i + 1}. ${s.brush.name} (${s.id})`,
1502
+ className: `h-5 w-5 rounded ring-1 ${on ? "ring-indigo-400" : "ring-slate-700"}`,
1503
+ style: { background: s.color },
1504
+ onClick: () => toggleStroke(s.id)
1505
+ },
1506
+ s.id
1507
+ );
1508
+ }) }),
1509
+ EVOLUTION_SLIDERS.map((c) => {
1510
+ const key = c.path;
1511
+ return /* @__PURE__ */ jsx13(
1512
+ PaintSlider,
1513
+ {
1514
+ control: c,
1515
+ value: mutation[key],
1516
+ onChange: (v) => setMutation((prev) => ({ ...prev, [key]: v }))
1517
+ },
1518
+ c.path
1519
+ );
1520
+ }),
1521
+ /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap gap-1", children: [
1522
+ /* @__PURE__ */ jsx13(
1523
+ "button",
1524
+ {
1525
+ type: "button",
1526
+ className: button,
1527
+ disabled: effectiveStrokeIds.length === 0 || state.stroking,
1528
+ onClick: () => attempt(() => {
1529
+ controller.breedStrokes({ strokeIds: effectiveStrokeIds, count, mutation, seed });
1530
+ setSeed((s) => s + 1);
1531
+ }),
1532
+ children: "Breed strokes"
1533
+ }
1534
+ ),
1535
+ activeProposalIds.length === 2 && /* @__PURE__ */ jsx13(
1536
+ "button",
1537
+ {
1538
+ type: "button",
1539
+ className: button,
1540
+ disabled: state.stroking,
1541
+ onClick: () => attempt(() => {
1542
+ controller.breedProposal({ proposalIds: activeProposalIds, count, mutation, seed });
1543
+ setSeed((s) => s + 1);
1544
+ }),
1545
+ children: "Cross over (2)"
1546
+ }
1547
+ ),
1548
+ variants.length > 0 && /* @__PURE__ */ jsx13(
1549
+ "button",
1550
+ {
1551
+ type: "button",
1552
+ className: button,
1553
+ onClick: () => attempt(() => {
1554
+ const sheet = exportProposalContactSheetPng(controller, variants);
1555
+ setContactSheetUrl(`data:image/png;base64,${sheet.base64}`);
1556
+ }),
1557
+ children: "Contact sheet"
1558
+ }
1559
+ )
1560
+ ] }),
1561
+ variants.length > 0 && /* @__PURE__ */ jsx13("div", { className: "grid grid-cols-2 gap-1.5", "data-testid": "evolution-grid", children: variants.map((p) => {
1562
+ const g = paintProposalGhost2(p);
1563
+ const picked = activeProposalIds.includes(p.id);
1564
+ return /* @__PURE__ */ jsxs12(
1565
+ "div",
1566
+ {
1567
+ "data-testid": `evolution-variant-${p.id}`,
1568
+ className: `flex flex-col gap-1 rounded border p-1.5 ${picked ? "border-indigo-500 bg-slate-800/90" : "border-slate-800 bg-slate-950/60"}`,
1569
+ children: [
1570
+ /* @__PURE__ */ jsx13("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsx13(
1571
+ "button",
1572
+ {
1573
+ type: "button",
1574
+ "aria-pressed": picked,
1575
+ className: chip(picked),
1576
+ onClick: () => toggleProposal(p.id),
1577
+ children: p.title
1578
+ }
1579
+ ) }),
1580
+ g && /* @__PURE__ */ jsx13("div", { className: "flex h-16 items-center justify-center overflow-hidden rounded bg-slate-900/80 p-1", children: /* @__PURE__ */ jsx13(PixelCanvas, { pixels: g, label: p.title, className: "max-h-full max-w-full object-contain" }) }),
1581
+ p.rationale && /* @__PURE__ */ jsx13("span", { className: "line-clamp-2 text-[10px] text-slate-400", title: p.rationale, children: p.rationale }),
1582
+ /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap gap-1", children: [
1583
+ /* @__PURE__ */ jsx13(
1584
+ "button",
1585
+ {
1586
+ type: "button",
1587
+ className: button,
1588
+ disabled: state.stroking,
1589
+ onClick: () => attempt(() => {
1590
+ controller.breedProposal({ proposalIds: [p.id], count, mutation, seed });
1591
+ setSeed((s) => s + 1);
1592
+ }),
1593
+ children: "Breed from"
1594
+ }
1595
+ ),
1596
+ /* @__PURE__ */ jsx13("button", { type: "button", className: button, onClick: () => attempt(() => store.accept(p.id)), children: "Accept" }),
1597
+ /* @__PURE__ */ jsx13("button", { type: "button", className: button, onClick: () => attempt(() => store.reject(p.id)), children: "Dismiss" })
1598
+ ] })
1599
+ ]
1600
+ },
1601
+ p.id
1602
+ );
1603
+ }) }),
1604
+ contactSheetUrl && /* @__PURE__ */ jsx13("img", { src: contactSheetUrl, alt: "Variant contact sheet", className: "w-full rounded border border-slate-800", "data-testid": "evolution-contact-sheet" }),
1605
+ /* @__PURE__ */ jsx13(ErrorLine, { error })
1606
+ ] });
1607
+ };
1608
+
1376
1609
  // src/paint-editor/PaintEditor.tsx
1377
- import { useRef as useRef7, useState as useState9 } from "react";
1610
+ import { useRef as useRef7, useState as useState11 } from "react";
1378
1611
  import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
1379
1612
 
1380
1613
  // src/paint-editor/PaintEffectsPanel.tsx
1381
- import { useEffect as useEffect4, useMemo as useMemo6, useRef as useRef6, useState as useState8 } from "react";
1614
+ import { useEffect as useEffect5, useMemo as useMemo6, useRef as useRef6, useState as useState10 } from "react";
1382
1615
  import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
1383
1616
  import { pathControlsOf } from "@pixerate/editor/effects";
1384
- import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
1617
+ import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
1385
1618
  function usePaintEffectsProvider(controller) {
1386
- const [provider, setProvider] = useState8(controller.effectsProvider);
1387
- useEffect4(() => {
1619
+ const [provider, setProvider] = useState10(controller.effectsProvider);
1620
+ useEffect5(() => {
1388
1621
  setProvider(controller.effectsProvider);
1389
1622
  return controller.effects.subscribe(setProvider);
1390
1623
  }, [controller]);
@@ -1392,7 +1625,7 @@ function usePaintEffectsProvider(controller) {
1392
1625
  }
1393
1626
  function usePaintEffectsTools(registry, controller, options = {}) {
1394
1627
  const { id, namespace, readOnly, playbackSurface } = options;
1395
- useEffect4(() => {
1628
+ useEffect5(() => {
1396
1629
  if (!registry) return;
1397
1630
  return registry.register(createPaintEffectsToolProvider(controller, { id, namespace, readOnly, playbackSurface }));
1398
1631
  }, [registry, controller, id, namespace, readOnly, playbackSurface]);
@@ -1400,19 +1633,19 @@ function usePaintEffectsTools(registry, controller, options = {}) {
1400
1633
  function Controls({ provider, effect, name, values, apply }) {
1401
1634
  const { description, error } = useEffectDescription(provider, effect);
1402
1635
  const drags = useRef6(/* @__PURE__ */ new Set());
1403
- if (!provider) return /* @__PURE__ */ jsxs12("p", { className: "text-[11px] text-slate-400", children: [
1636
+ if (!provider) return /* @__PURE__ */ jsxs13("p", { className: "text-[11px] text-slate-400", children: [
1404
1637
  'No effects provider: "',
1405
1638
  name ?? effect,
1406
1639
  '" is kept as it was drawn.'
1407
1640
  ] });
1408
- if (error) return /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-amber-400", children: error });
1409
- if (!description) return /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
1641
+ if (error) return /* @__PURE__ */ jsx14("p", { className: "text-[11px] text-amber-400", children: error });
1642
+ if (!description) return /* @__PURE__ */ jsx14("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
1410
1643
  const commit = (gesture) => {
1411
1644
  if (!gesture || drags.current.has(gesture)) return !gesture;
1412
1645
  drags.current.add(gesture);
1413
1646
  return true;
1414
1647
  };
1415
- return /* @__PURE__ */ jsx13(
1648
+ return /* @__PURE__ */ jsx14(
1416
1649
  EffectParameters,
1417
1650
  {
1418
1651
  description,
@@ -1434,8 +1667,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
1434
1667
  const state = usePaintEditorState(controller);
1435
1668
  const provider = usePaintEffectsProvider(controller);
1436
1669
  const [error, attempt] = useAttempt();
1437
- const [browse, setBrowse] = useState8(null);
1438
- const [busy, setBusy] = useState8(false);
1670
+ const [browse, setBrowse] = useState10(null);
1671
+ const [busy, setBusy] = useState10(false);
1439
1672
  const paper = controller.getPaperEffect();
1440
1673
  const activeId = state.document.activeLayerId;
1441
1674
  const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
@@ -1465,28 +1698,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
1465
1698
  };
1466
1699
  const toggle = (b) => setBrowse(browse === b ? null : b);
1467
1700
  const pixel = active?.type === "pixel";
1468
- return /* @__PURE__ */ jsxs12("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
1469
- /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-1", children: [
1470
- /* @__PURE__ */ jsx13("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
1471
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
1472
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
1473
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
1474
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" }),
1475
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paint", onClick: () => toggle("paint"), title: "Paint with an effect: brushes take each pixel's colour from it", children: "Paint\u2026" })
1701
+ return /* @__PURE__ */ jsxs13("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
1702
+ /* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-center gap-1", children: [
1703
+ /* @__PURE__ */ jsx14("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
1704
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
1705
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
1706
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
1707
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" }),
1708
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paint", onClick: () => toggle("paint"), title: "Paint with an effect: brushes take each pixel's colour from it", children: "Paint\u2026" })
1476
1709
  ] }),
1477
- !provider && /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
1478
- browse && /* @__PURE__ */ jsx13(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
1479
- paper && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
1480
- /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1", children: [
1481
- /* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
1710
+ !provider && /* @__PURE__ */ jsx14("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
1711
+ browse && /* @__PURE__ */ jsx14(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
1712
+ paper && /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
1713
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1", children: [
1714
+ /* @__PURE__ */ jsxs13("span", { className: "flex-1 truncate", children: [
1482
1715
  "Paper: ",
1483
1716
  paper.name ?? paper.effect
1484
1717
  ] }),
1485
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
1718
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
1486
1719
  ] }),
1487
- /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
1488
- /* @__PURE__ */ jsx13("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
1489
- /* @__PURE__ */ jsx13(
1720
+ /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", children: [
1721
+ /* @__PURE__ */ jsx14("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
1722
+ /* @__PURE__ */ jsx14(
1490
1723
  "input",
1491
1724
  {
1492
1725
  type: "range",
@@ -1508,43 +1741,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
1508
1741
  `o${paper.opacity}`
1509
1742
  )
1510
1743
  ] }),
1511
- /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
1512
- /* @__PURE__ */ jsx13("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
1513
- /* @__PURE__ */ jsx13("select", { className: "flex-1 rounded bg-slate-800 px-1 py-0.5 text-[11px]", "aria-label": "Effect paper blend", value: paper.blend, onChange: (e) => {
1744
+ /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", children: [
1745
+ /* @__PURE__ */ jsx14("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
1746
+ /* @__PURE__ */ jsx14("select", { className: "flex-1 rounded bg-slate-800 px-1 py-0.5 text-[11px]", "aria-label": "Effect paper blend", value: paper.blend, onChange: (e) => {
1514
1747
  const blend = e.currentTarget.value;
1515
1748
  run(() => controller.updatePaperEffect({ blend }));
1516
- }, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx13("option", { value: b, children: b }, b)) })
1749
+ }, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx14("option", { value: b, children: b }, b)) })
1517
1750
  ] }),
1518
- /* @__PURE__ */ jsx13(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
1751
+ /* @__PURE__ */ jsx14(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
1519
1752
  ] }),
1520
- effectPaint && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
1521
- /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1", children: [
1522
- thumbnail ? /* @__PURE__ */ jsx13("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
1523
- /* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
1753
+ effectPaint && /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
1754
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1", children: [
1755
+ thumbnail ? /* @__PURE__ */ jsx14("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
1756
+ /* @__PURE__ */ jsxs13("span", { className: "flex-1 truncate", children: [
1524
1757
  "Paint: ",
1525
1758
  effectPaint.effect,
1526
1759
  state.effectPaintRendering ? " (rendering\u2026)" : ""
1527
1760
  ] }),
1528
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
1761
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
1529
1762
  ] }),
1530
- /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
1531
- /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
1532
- /* @__PURE__ */ jsx13("input", { type: "checkbox", checked: effectPaint.map?.by === "stroke", onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
1763
+ /* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
1764
+ /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
1765
+ /* @__PURE__ */ jsx14("input", { type: "checkbox", checked: effectPaint.map?.by === "stroke", onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
1533
1766
  "Along the stroke"
1534
1767
  ] }),
1535
- hasPathControl && /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", title: "Pass each stroke's centreline to the effect's own path control", children: [
1536
- /* @__PURE__ */ jsx13("input", { type: "checkbox", checked: effectPaint.map?.by === "path", onChange: (e) => repaint({ map: e.target.checked ? { by: "path" } : { by: "canvas" } }) }),
1768
+ hasPathControl && /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", title: "Pass each stroke's centreline to the effect's own path control", children: [
1769
+ /* @__PURE__ */ jsx14("input", { type: "checkbox", checked: effectPaint.map?.by === "path", onChange: (e) => repaint({ map: e.target.checked ? { by: "path" } : { by: "canvas" } }) }),
1537
1770
  "Along the stroke (native)"
1538
1771
  ] }),
1539
- /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
1540
- /* @__PURE__ */ jsx13("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
1772
+ /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
1773
+ /* @__PURE__ */ jsx14("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
1541
1774
  "Live"
1542
1775
  ] })
1543
1776
  ] }),
1544
- effectPaint.map?.by === "stroke" && /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-2", children: [
1545
- /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
1546
- /* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "Length" }),
1547
- /* @__PURE__ */ jsx13(
1777
+ effectPaint.map?.by === "stroke" && /* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-center gap-2", children: [
1778
+ /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", children: [
1779
+ /* @__PURE__ */ jsx14("span", { className: "text-slate-400", children: "Length" }),
1780
+ /* @__PURE__ */ jsx14(
1548
1781
  "input",
1549
1782
  {
1550
1783
  type: "number",
@@ -1558,56 +1791,56 @@ var PaintEffectsPanel = ({ controller, className }) => {
1558
1791
  effectPaint.map.length
1559
1792
  )
1560
1793
  ] }),
1561
- /* @__PURE__ */ jsxs12("select", { "aria-label": "Effect repeat", value: effectPaint.map.repeat, onChange: (e) => repaint({ map: { ...effectPaint.map, repeat: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: [
1562
- /* @__PURE__ */ jsx13("option", { value: "repeat", children: "Repeat" }),
1563
- /* @__PURE__ */ jsx13("option", { value: "mirror", children: "Mirror" }),
1564
- /* @__PURE__ */ jsx13("option", { value: "clamp", children: "Clamp" })
1794
+ /* @__PURE__ */ jsxs13("select", { "aria-label": "Effect repeat", value: effectPaint.map.repeat, onChange: (e) => repaint({ map: { ...effectPaint.map, repeat: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: [
1795
+ /* @__PURE__ */ jsx14("option", { value: "repeat", children: "Repeat" }),
1796
+ /* @__PURE__ */ jsx14("option", { value: "mirror", children: "Mirror" }),
1797
+ /* @__PURE__ */ jsx14("option", { value: "clamp", children: "Clamp" })
1565
1798
  ] })
1566
1799
  ] }),
1567
- /* @__PURE__ */ jsx13(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
1800
+ /* @__PURE__ */ jsx14(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
1568
1801
  ] }),
1569
- animation && /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
1570
- /* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
1802
+ animation && /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
1803
+ /* @__PURE__ */ jsxs13("span", { className: "flex-1 truncate", children: [
1571
1804
  "Live paint: ",
1572
1805
  animation.strokes,
1573
1806
  " ",
1574
1807
  animation.strokes === 1 ? "stroke" : "strokes"
1575
1808
  ] }),
1576
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
1577
- /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
1578
- /* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "fps" }),
1579
- /* @__PURE__ */ jsx13("input", { type: "number", "aria-label": "Live paint frame rate", min: 1, max: 60, value: playback.fps, onChange: (e) => attempt(() => controller.setEffectPlayback({ fps: Math.round(Number(e.target.value)) })), className: "w-12 rounded bg-slate-800 px-1 py-0.5" })
1809
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
1810
+ /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", children: [
1811
+ /* @__PURE__ */ jsx14("span", { className: "text-slate-400", children: "fps" }),
1812
+ /* @__PURE__ */ jsx14("input", { type: "number", "aria-label": "Live paint frame rate", min: 1, max: 60, value: playback.fps, onChange: (e) => attempt(() => controller.setEffectPlayback({ fps: Math.round(Number(e.target.value)) })), className: "w-12 rounded bg-slate-800 px-1 py-0.5" })
1580
1813
  ] })
1581
1814
  ] }),
1582
- layerEffect && activeId && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
1583
- /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1", children: [
1584
- /* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
1815
+ layerEffect && activeId && /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
1816
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1", children: [
1817
+ /* @__PURE__ */ jsxs13("span", { className: "flex-1 truncate", children: [
1585
1818
  "Layer: ",
1586
1819
  layerEffect.name ?? layerEffect.effect
1587
1820
  ] }),
1588
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
1821
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
1589
1822
  ] }),
1590
- /* @__PURE__ */ jsx13(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
1823
+ /* @__PURE__ */ jsx14(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
1591
1824
  ] }),
1592
- /* @__PURE__ */ jsx13(ErrorLine, { error })
1825
+ /* @__PURE__ */ jsx14(ErrorLine, { error })
1593
1826
  ] });
1594
1827
  };
1595
1828
 
1596
1829
  // src/paint-editor/PaintEditor.tsx
1597
- import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
1830
+ import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
1598
1831
  var PAINT_CONTROLS = {
1599
1832
  "mixing-pad": '[data-testid="mixing-pad"]',
1600
1833
  lighting: '[data-testid="light-panel"]',
1601
1834
  symmetry: '[aria-label="Symmetry"]'
1602
1835
  };
1603
- var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, className, playback, playbackId = "paint", onPlaybackReveal }) => {
1604
- const [tool, setTool] = useState9("brush");
1605
- const [fillOptions, setFillOptions] = useState9({ reference: "all", tolerance: 32, closeGap: 4, expand: 1, antialias: true });
1606
- const [tab, setTab] = useState9("color");
1836
+ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, deviceTilt, className, playback, playbackId = "paint", onPlaybackReveal }) => {
1837
+ const [tool, setTool] = useState11("brush");
1838
+ const [fillOptions, setFillOptions] = useState11({ reference: "all", tolerance: 32, closeGap: 4, expand: 1, antialias: true });
1839
+ const [tab, setTab] = useState11("color");
1607
1840
  const tabRef = useRef7(tab);
1608
1841
  tabRef.current = tab;
1609
1842
  const rootRef = useRef7(null);
1610
- const [ownPresence] = useState9(() => new PaintPresence2());
1843
+ const [ownPresence] = useState11(() => new PaintPresence2());
1611
1844
  const ambientPlayback = useAgentPlayback();
1612
1845
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
1613
1846
  const viewBox = () => {
@@ -1663,29 +1896,30 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
1663
1896
  const box = rootRef.current?.getBoundingClientRect();
1664
1897
  return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
1665
1898
  };
1666
- const [error, setError] = useState9(null);
1899
+ const [error, setError] = useState11(null);
1667
1900
  const effects = usePaintEffectsProvider(controller);
1668
1901
  const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
1669
- return /* @__PURE__ */ jsxs13("div", { ref: rootRef, className: `relative flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
1670
- playing && /* @__PURE__ */ jsx14(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
1671
- /* @__PURE__ */ jsx14(PaintToolbar, { controller, tool, onToolChange: setTool, fillOptions, onFillOptionsChange: setFillOptions, fileName }),
1672
- /* @__PURE__ */ jsxs13("div", { className: "flex min-h-0 flex-1 gap-2", children: [
1673
- /* @__PURE__ */ jsx14(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
1674
- /* @__PURE__ */ jsxs13("div", { className: "flex min-w-0 flex-1 flex-col", children: [
1675
- /* @__PURE__ */ jsx14(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
1676
- error && /* @__PURE__ */ jsx14("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
1902
+ return /* @__PURE__ */ jsxs14("div", { ref: rootRef, className: `relative flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
1903
+ playing && /* @__PURE__ */ jsx15(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
1904
+ /* @__PURE__ */ jsx15(PaintToolbar, { controller, tool, onToolChange: setTool, fillOptions, onFillOptionsChange: setFillOptions, fileName }),
1905
+ /* @__PURE__ */ jsxs14("div", { className: "flex min-h-0 flex-1 gap-2", children: [
1906
+ /* @__PURE__ */ jsx15(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
1907
+ /* @__PURE__ */ jsxs14("div", { className: "flex min-w-0 flex-1 flex-col", children: [
1908
+ /* @__PURE__ */ jsx15(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, deviceTilt, className: "flex-1 rounded-lg" }),
1909
+ error && /* @__PURE__ */ jsx15("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
1677
1910
  ] }),
1678
- /* @__PURE__ */ jsxs13("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
1679
- /* @__PURE__ */ jsx14("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ jsx14("button", { type: "button", role: "tab", "aria-selected": tab === t, "data-paint-tab": t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
1680
- /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
1681
- tab === "color" && /* @__PURE__ */ jsx14(ColorPanel, { controller }),
1682
- tab === "wet" && /* @__PURE__ */ jsx14(WetPanel, { controller }),
1683
- tab === "paper" && /* @__PURE__ */ jsx14(PaperPanel, { controller }),
1684
- tab === "layers" && /* @__PURE__ */ jsx14(PaintLayersPanel, { controller }),
1685
- tab === "layers" && /* @__PURE__ */ jsx14(StrokePanel, { controller }),
1686
- tab === "layers" && /* @__PURE__ */ jsx14(PathStrokePanel, { controller }),
1687
- tab === "layers" && /* @__PURE__ */ jsx14(StickerPanel, { controller }),
1688
- tab === "effects" && effects && /* @__PURE__ */ jsx14(PaintEffectsPanel, { controller })
1911
+ /* @__PURE__ */ jsxs14("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
1912
+ /* @__PURE__ */ jsx15("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ jsx15("button", { type: "button", role: "tab", "aria-selected": tab === t, "data-paint-tab": t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
1913
+ /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
1914
+ tab === "color" && /* @__PURE__ */ jsx15(ColorPanel, { controller }),
1915
+ tab === "wet" && /* @__PURE__ */ jsx15(WetPanel, { controller }),
1916
+ tab === "paper" && /* @__PURE__ */ jsx15(PaperPanel, { controller }),
1917
+ tab === "layers" && /* @__PURE__ */ jsx15(PaintLayersPanel, { controller }),
1918
+ tab === "layers" && /* @__PURE__ */ jsx15(StrokePanel, { controller }),
1919
+ tab === "layers" && /* @__PURE__ */ jsx15(PathStrokePanel, { controller }),
1920
+ tab === "layers" && /* @__PURE__ */ jsx15(EvolutionPanel, { controller, proposals }),
1921
+ tab === "layers" && /* @__PURE__ */ jsx15(StickerPanel, { controller }),
1922
+ tab === "effects" && effects && /* @__PURE__ */ jsx15(PaintEffectsPanel, { controller })
1689
1923
  ] })
1690
1924
  ] })
1691
1925
  ] })
@@ -1696,6 +1930,7 @@ export {
1696
1930
  BrushLibraryBrowser,
1697
1931
  BrushPanel,
1698
1932
  ColorPanel,
1933
+ EvolutionPanel,
1699
1934
  PaintCanvas,
1700
1935
  PaintEditor,
1701
1936
  PaintEffectsPanel,
@@ -1711,6 +1946,7 @@ export {
1711
1946
  StickerPicker,
1712
1947
  StrokePanel,
1713
1948
  WetPanel,
1949
+ useMutationRequests,
1714
1950
  usePaintChangeFeed,
1715
1951
  usePaintDirector,
1716
1952
  usePaintEditor,