@weasel-js/ui 1.7.1 → 1.7.3

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 (164) hide show
  1. package/dist/chunks/{BandEditor-Dd0egAgE.js → BandEditor-B4jUAHQ8.js} +13 -13
  2. package/dist/chunks/BandEditor-B4jUAHQ8.js.map +1 -0
  3. package/dist/chunks/{ColorField-BLs9fbeq.js → ColorField-BwlelY26.js} +4 -4
  4. package/dist/chunks/ColorField-BwlelY26.js.map +1 -0
  5. package/dist/chunks/{ComboBox-CuTLRmUg.js → ComboBox-DKln_mOd.js} +11 -11
  6. package/dist/chunks/ComboBox-DKln_mOd.js.map +1 -0
  7. package/dist/chunks/{CurveEditor-jVBEqqdv.js → CurveEditor-0EE00D6s.js} +2 -2
  8. package/dist/chunks/{CurveEditor-jVBEqqdv.js.map → CurveEditor-0EE00D6s.js.map} +1 -1
  9. package/dist/chunks/{DataGrid-BklgBqS0.js → DataGrid-CmHJe57v.js} +22 -17
  10. package/dist/chunks/DataGrid-CmHJe57v.js.map +1 -0
  11. package/dist/chunks/DetailList-BpU50XVe.js +54 -0
  12. package/dist/chunks/DetailList-BpU50XVe.js.map +1 -0
  13. package/dist/chunks/{DetentSlider-Bh7EpMqT.js → DetentSlider-DNTAk8xP.js} +2 -2
  14. package/dist/chunks/{DetentSlider-Bh7EpMqT.js.map → DetentSlider-DNTAk8xP.js.map} +1 -1
  15. package/dist/chunks/{FallthroughDiagram-C7BUe8eU.js → FallthroughDiagram-CS1IhQaU.js} +14 -14
  16. package/dist/chunks/FallthroughDiagram-CS1IhQaU.js.map +1 -0
  17. package/dist/chunks/{Field-DsBlnFKf.js → Field-DiX_WByH.js} +2 -2
  18. package/dist/chunks/{Field-DsBlnFKf.js.map → Field-DiX_WByH.js.map} +1 -1
  19. package/dist/chunks/{FillStrokeSwatch-CgsYQgew.js → FillStrokeSwatch-C4h3rUFM.js} +2 -2
  20. package/dist/chunks/FillStrokeSwatch-C4h3rUFM.js.map +1 -0
  21. package/dist/chunks/{FontFamilySelect-CGJ5OIOy.js → FontFamilySelect-DEvMXyZd.js} +2 -2
  22. package/dist/chunks/{FontFamilySelect-CGJ5OIOy.js.map → FontFamilySelect-DEvMXyZd.js.map} +1 -1
  23. package/dist/chunks/{FontWeightSelect-RbcXYJPS.js → FontWeightSelect-BLQ_LMJF.js} +2 -2
  24. package/dist/chunks/{FontWeightSelect-RbcXYJPS.js.map → FontWeightSelect-BLQ_LMJF.js.map} +1 -1
  25. package/dist/chunks/{GradientEditor-DypXzMc-.js → GradientEditor-DD2OjQtn.js} +4 -4
  26. package/dist/chunks/{GradientEditor-DypXzMc-.js.map → GradientEditor-DD2OjQtn.js.map} +1 -1
  27. package/dist/chunks/{InlineRange-P01ABSzo.js → InlineRange-DPjIsJB3.js} +3 -3
  28. package/dist/chunks/InlineRange-DPjIsJB3.js.map +1 -0
  29. package/dist/chunks/{Input-CzwvCZs_.js → Input-D7SDKbST.js} +2 -2
  30. package/dist/chunks/{Input-CzwvCZs_.js.map → Input-D7SDKbST.js.map} +1 -1
  31. package/dist/chunks/{Jog-DfNUYejm.js → Jog-BrkzdGV2.js} +6 -6
  32. package/dist/chunks/Jog-BrkzdGV2.js.map +1 -0
  33. package/dist/chunks/{LayerList-CsDqwYh-.js → LayerList-BqeWFuGc.js} +3 -3
  34. package/dist/chunks/{LayerList-CsDqwYh-.js.map → LayerList-BqeWFuGc.js.map} +1 -1
  35. package/dist/chunks/{ListEditor-BnGzqERm.js → ListEditor-OQDzG4A5.js} +2 -2
  36. package/dist/chunks/{ListEditor-BnGzqERm.js.map → ListEditor-OQDzG4A5.js.map} +1 -1
  37. package/dist/chunks/{MenuButton-L9f5vido.js → MenuButton-TAFg88Lp.js} +2 -2
  38. package/dist/chunks/{MenuButton-L9f5vido.js.map → MenuButton-TAFg88Lp.js.map} +1 -1
  39. package/dist/chunks/{MeshEditor-GbqqiPk8.js → MeshEditor-DWpvg8H6.js} +2 -2
  40. package/dist/chunks/{MeshEditor-GbqqiPk8.js.map → MeshEditor-DWpvg8H6.js.map} +1 -1
  41. package/dist/chunks/{NumberField-DLXXgh48.js → NumberField-DS0WSiin.js} +7 -7
  42. package/dist/chunks/NumberField-DS0WSiin.js.map +1 -0
  43. package/dist/chunks/{PaintField-C0hoXc0Y.js → PaintField-BdmQM53v.js} +2 -2
  44. package/dist/chunks/{PaintField-C0hoXc0Y.js.map → PaintField-BdmQM53v.js.map} +1 -1
  45. package/dist/chunks/{PaintInput-jQRxM95Y.js → PaintInput-DaQMeBsI.js} +4 -4
  46. package/dist/chunks/{PaintInput-jQRxM95Y.js.map → PaintInput-DaQMeBsI.js.map} +1 -1
  47. package/dist/chunks/{PatternPicker-CaMYXzhF.js → PatternPicker-B3HcMZWg.js} +2 -2
  48. package/dist/chunks/{PatternPicker-CaMYXzhF.js.map → PatternPicker-B3HcMZWg.js.map} +1 -1
  49. package/dist/chunks/{Plot2D-BHNbgCAl.js → Plot2D-BrvQS0dh.js} +7 -7
  50. package/dist/chunks/Plot2D-BrvQS0dh.js.map +1 -0
  51. package/dist/chunks/{PointPlotter-BZ_vk6gV.js → PointPlotter-BBXpQ_QD.js} +2 -2
  52. package/dist/chunks/{PointPlotter-BZ_vk6gV.js.map → PointPlotter-BBXpQ_QD.js.map} +1 -1
  53. package/dist/chunks/{Prefs-CkyldX-e.js → Prefs-BnVEyfWO.js} +76 -66
  54. package/dist/chunks/Prefs-BnVEyfWO.js.map +1 -0
  55. package/dist/chunks/{Properties-D15c8NP-.js → Properties-BoG2MMHR.js} +24 -24
  56. package/dist/chunks/{Properties-D15c8NP-.js.map → Properties-BoG2MMHR.js.map} +1 -1
  57. package/dist/chunks/{PropertyField-CV_Gw57S.js → PropertyField-PMrqBA0n.js} +243 -186
  58. package/dist/chunks/PropertyField-PMrqBA0n.js.map +1 -0
  59. package/dist/chunks/{RadioGroup-4dbzqvGy.js → RadioGroup-B70_M-gT.js} +2 -2
  60. package/dist/chunks/{RadioGroup-4dbzqvGy.js.map → RadioGroup-B70_M-gT.js.map} +1 -1
  61. package/dist/chunks/{RangeSlider-BxokZViJ.js → RangeSlider-DO5TZVk7.js} +8 -8
  62. package/dist/chunks/RangeSlider-DO5TZVk7.js.map +1 -0
  63. package/dist/chunks/{Select-BppLsJTz.js → Select-ouV8O6cp.js} +19 -19
  64. package/dist/chunks/Select-ouV8O6cp.js.map +1 -0
  65. package/dist/chunks/{SelectionPanel-Cm1qu-ZX.js → SelectionPanel-COZ6z9_P.js} +2 -2
  66. package/dist/chunks/{SelectionPanel-Cm1qu-ZX.js.map → SelectionPanel-COZ6z9_P.js.map} +1 -1
  67. package/dist/chunks/{Slider-Cl5RCeZ7.js → Slider-DSrlMEq8.js} +19 -19
  68. package/dist/chunks/Slider-DSrlMEq8.js.map +1 -0
  69. package/dist/chunks/{StatusBar-Ca9Dvhhq.js → StatusBar-BEOfOX0D.js} +6 -6
  70. package/dist/chunks/StatusBar-BEOfOX0D.js.map +1 -0
  71. package/dist/chunks/{SwatchStrip-Cw0l8Om7.js → SwatchStrip-Bi9iPLoh.js} +2 -2
  72. package/dist/chunks/{SwatchStrip-Cw0l8Om7.js.map → SwatchStrip-Bi9iPLoh.js.map} +1 -1
  73. package/dist/chunks/{Timeline-pqnYk5cV.js → Timeline-sMCH2fah.js} +99 -84
  74. package/dist/chunks/Timeline-sMCH2fah.js.map +1 -0
  75. package/dist/chunks/{TokenPanel-DAkL6vwQ.js → TokenPanel-WtKGY2Db.js} +29 -29
  76. package/dist/chunks/TokenPanel-WtKGY2Db.js.map +1 -0
  77. package/dist/chunks/{ToolOptionsBar-COsTJ1cu.js → ToolOptionsBar-BJKwnemU.js} +2 -2
  78. package/dist/chunks/{ToolOptionsBar-COsTJ1cu.js.map → ToolOptionsBar-BJKwnemU.js.map} +1 -1
  79. package/dist/chunks/{createKeyframeLayer-BTa4LyJE.js → createKeyframeLayer-DSVf13Su.js} +2 -2
  80. package/dist/chunks/{createKeyframeLayer-BTa4LyJE.js.map → createKeyframeLayer-DSVf13Su.js.map} +1 -1
  81. package/dist/chunks/field.module-B27pWv0i.js +15 -0
  82. package/dist/chunks/{field.module-Bh7BTKMh.js.map → field.module-B27pWv0i.js.map} +1 -1
  83. package/dist/chunks/{model-B1-gMBIW.js → model-B6zuQg6b.js} +2 -2
  84. package/dist/chunks/{model-B1-gMBIW.js.map → model-B6zuQg6b.js.map} +1 -1
  85. package/dist/components/BandEditor/index.js +1 -1
  86. package/dist/components/ColorField/index.js +1 -1
  87. package/dist/components/ComboBox/index.js +1 -1
  88. package/dist/components/CurveEditor/index.js +2 -2
  89. package/dist/components/DataGrid/DataGrid.d.ts +3 -0
  90. package/dist/components/DataGrid/DataGrid.d.ts.map +1 -1
  91. package/dist/components/DataGrid/index.js +1 -1
  92. package/dist/components/DetailList/DetailList.d.ts +1 -1
  93. package/dist/components/DetailList/DetailList.d.ts.map +1 -1
  94. package/dist/components/DetailList/index.js +1 -1
  95. package/dist/components/DetentSlider/index.js +1 -1
  96. package/dist/components/FallthroughDiagram/index.js +1 -1
  97. package/dist/components/Field/index.js +1 -1
  98. package/dist/components/FillStrokeSwatch/FillStrokeSwatch.d.ts +5 -2
  99. package/dist/components/FillStrokeSwatch/FillStrokeSwatch.d.ts.map +1 -1
  100. package/dist/components/FillStrokeSwatch/index.js +1 -1
  101. package/dist/components/FontFamilySelect/index.js +1 -1
  102. package/dist/components/FontWeightSelect/index.js +1 -1
  103. package/dist/components/GradientEditor/index.js +1 -1
  104. package/dist/components/InlineRange/index.js +1 -1
  105. package/dist/components/Input/index.js +1 -1
  106. package/dist/components/Jog/index.js +1 -1
  107. package/dist/components/LayerList/index.js +1 -1
  108. package/dist/components/ListEditor/index.js +1 -1
  109. package/dist/components/MenuButton/index.js +1 -1
  110. package/dist/components/MeshEditor/index.js +1 -1
  111. package/dist/components/NumberField/index.js +1 -1
  112. package/dist/components/PaintField/index.js +1 -1
  113. package/dist/components/PaintInput/index.js +1 -1
  114. package/dist/components/PatternPicker/index.js +1 -1
  115. package/dist/components/Plot2D/index.js +1 -1
  116. package/dist/components/PointPlotter/index.js +1 -1
  117. package/dist/components/Prefs/PrefsForm.d.ts +14 -0
  118. package/dist/components/Prefs/PrefsForm.d.ts.map +1 -1
  119. package/dist/components/Prefs/PrefsRow.d.ts +4 -0
  120. package/dist/components/Prefs/PrefsRow.d.ts.map +1 -1
  121. package/dist/components/Prefs/index.js +1 -1
  122. package/dist/components/Properties/PropertyField.d.ts.map +1 -1
  123. package/dist/components/Properties/PropertyPanel.d.ts +18 -1
  124. package/dist/components/Properties/PropertyPanel.d.ts.map +1 -1
  125. package/dist/components/Properties/index.d.ts +2 -2
  126. package/dist/components/Properties/index.d.ts.map +1 -1
  127. package/dist/components/Properties/index.js +3 -3
  128. package/dist/components/RadioGroup/index.js +1 -1
  129. package/dist/components/RangeSlider/index.js +1 -1
  130. package/dist/components/Select/index.js +1 -1
  131. package/dist/components/SelectionPanel/index.js +2 -2
  132. package/dist/components/Slider/index.js +1 -1
  133. package/dist/components/StatusBar/StatusBar.d.ts +1 -1
  134. package/dist/components/StatusBar/index.js +1 -1
  135. package/dist/components/SwatchStrip/index.js +1 -1
  136. package/dist/components/Timeline/Transport.d.ts.map +1 -1
  137. package/dist/components/Timeline/index.js +1 -1
  138. package/dist/components/TokenPanel/index.js +1 -1
  139. package/dist/components/ToolOptionsBar/index.js +1 -1
  140. package/dist/index.js +75 -75
  141. package/dist/index.js.map +1 -1
  142. package/dist/style.css +1 -1
  143. package/package.json +9 -9
  144. package/dist/chunks/BandEditor-Dd0egAgE.js.map +0 -1
  145. package/dist/chunks/ColorField-BLs9fbeq.js.map +0 -1
  146. package/dist/chunks/ComboBox-CuTLRmUg.js.map +0 -1
  147. package/dist/chunks/DataGrid-BklgBqS0.js.map +0 -1
  148. package/dist/chunks/DetailList-DFtqdOJj.js +0 -52
  149. package/dist/chunks/DetailList-DFtqdOJj.js.map +0 -1
  150. package/dist/chunks/FallthroughDiagram-C7BUe8eU.js.map +0 -1
  151. package/dist/chunks/FillStrokeSwatch-CgsYQgew.js.map +0 -1
  152. package/dist/chunks/InlineRange-P01ABSzo.js.map +0 -1
  153. package/dist/chunks/Jog-DfNUYejm.js.map +0 -1
  154. package/dist/chunks/NumberField-DLXXgh48.js.map +0 -1
  155. package/dist/chunks/Plot2D-BHNbgCAl.js.map +0 -1
  156. package/dist/chunks/Prefs-CkyldX-e.js.map +0 -1
  157. package/dist/chunks/PropertyField-CV_Gw57S.js.map +0 -1
  158. package/dist/chunks/RangeSlider-BxokZViJ.js.map +0 -1
  159. package/dist/chunks/Select-BppLsJTz.js.map +0 -1
  160. package/dist/chunks/Slider-Cl5RCeZ7.js.map +0 -1
  161. package/dist/chunks/StatusBar-Ca9Dvhhq.js.map +0 -1
  162. package/dist/chunks/Timeline-pqnYk5cV.js.map +0 -1
  163. package/dist/chunks/TokenPanel-DAkL6vwQ.js.map +0 -1
  164. package/dist/chunks/field.module-Bh7BTKMh.js +0 -15
@@ -1 +1 @@
1
- {"version":3,"file":"createKeyframeLayer-BTa4LyJE.js","names":["s","_Fragment","s","dlog","plotToModel","modelToPlot","Plot2D","handleHalf","snapToNearest","hitTestAnchor","r2","radius","best","i","anchors","dx","pointer","dy","d2","hitTestCurve","segIdx","segments","samples","last","a","b","abx","aby","apx","apy","ab2","u","cx","cy","t","CurveEditor_module_default","NO_MODIFIERS","readModifiers","LayeredCurveEditor","props","historyEnabled","modelRange","useMemo","xRange","yRange","plotSize","width","height","layersRef","useLatest","layers","modelRangeRef","plotSizeRef","plotRef","useRef","makeCtx","useCallback","mr","ps","p","activeRef","activeLayerId","setActiveLayerId","useState","pastRef","futureRef","snapshot","m","restore","current","prev","snap","onLayerChange","undo","past","redo","future","next","sessionRef","cleanupGesture","findLayerState","id","onGestureMoveRef","h","model","ctx","onGestureEndRef","finalState","onLayerCommit","onGestureCancelRef","restored","installGesture","startStates","startSelfState","layerId","openPointerSession","down","onSvgPointerDown","modifiers","e","ls","nativeEvent","coords","preEventSnapshot","hit","prevState","committed","gesture","pendingCommit","onSvgKeyDown","k","renderCtxBase","cls","className","children","SAMPLES_PER_SEGMENT","KEY_HIT_PX","HANDLE_HIT_PX","CURVE_HIT_PX","KEY_HALF","HANDLE_RADIUS","SHIFT_MULTIPLIER","HANDLE_STEP","keyframeLayerState","clampTo","range","v","bezierOf","key","moveKeyTo","moved","keys","index","rest","at","selectedKey","applyKeyframeDrag","state","drag","createKeyframeLayer","cfg","label","formatX","x","snapRadiusPx","easingInto","d","seg","cubicBezierEasing","resolveEasing","segmentSamples","out","ease","pts","j","activeBezier","handlePoints","xf","yf","bezier","path","render","shown","curve","dragIndex","Fragment","x0","x1","h1","h2","hitTest","plot","c","keyGesture","perPx","handleGesture","segment","handle","onPointerDown","extra","onKeyDown","target","activate","mult","keyEl","stepX","stepY","value","segEl","handleEl"],"sources":["../../src/components/CurveEditor/hitTest.ts","../../src/components/CurveEditor/CurveEditor.module.css","../../src/components/CurveEditor/LayeredCurveEditor.tsx","../../src/components/CurveEditor/createKeyframeLayer.tsx"],"sourcesContent":["/**\n * Curve-specific hit tests. Generic coord transforms live in\n * `../Plot2D/geometry`; what's here is curve-only (anchor / polyline\n * proximity).\n */\nimport type { Point } from '../Plot2D/geometry';\n\n/**\n * Nearest-anchor hit test. Anchors are already in plot/screen coords.\n * Returns the index of the nearest anchor whose squared distance to\n * the pointer is ≤ radius². Null if no anchor is within radius.\n */\nexport function hitTestAnchor(\n anchors: readonly Point[],\n pointer: Point,\n radius: number,\n): { index: number } | null {\n const r2 = radius * radius;\n let best: { index: number; d2: number } | null = null;\n for (let i = 0; i < anchors.length; i++) {\n const a = anchors[i];\n const dx = a.x - pointer.x;\n const dy = a.y - pointer.y;\n const d2 = dx * dx + dy * dy;\n if (d2 > r2) continue;\n if (best === null || d2 < best.d2) best = { index: i, d2 };\n }\n return best ? { index: best.index } : null;\n}\n\n/**\n * Hit test against a per-segment sampled polyline. Each entry in\n * `segments` is the sample list for one segment (inclusive of\n * endpoints). Returns segment index + t (∈ [0, 1]) of the closest\n * point on the polyline within radius. Null if nothing is in range.\n *\n * Distance is measured to the line-segment chords between adjacent\n * samples, not just to the samples themselves — so sparse sampling\n * still produces accurate hits along the chord.\n */\nexport function hitTestCurve(\n segments: readonly (readonly Point[])[],\n pointer: Point,\n radius: number,\n): { segIdx: number; t: number } | null {\n const r2 = radius * radius;\n let best: { segIdx: number; t: number; d2: number } | null = null;\n for (let segIdx = 0; segIdx < segments.length; segIdx++) {\n const samples = segments[segIdx];\n if (samples.length < 2) continue;\n const last = samples.length - 1;\n for (let i = 0; i < last; i++) {\n const a = samples[i];\n const b = samples[i + 1];\n const abx = b.x - a.x;\n const aby = b.y - a.y;\n const apx = pointer.x - a.x;\n const apy = pointer.y - a.y;\n const ab2 = abx * abx + aby * aby;\n let u = ab2 > 0 ? (apx * abx + apy * aby) / ab2 : 0;\n if (u < 0) u = 0;\n else if (u > 1) u = 1;\n const cx = a.x + u * abx;\n const cy = a.y + u * aby;\n const dx = cx - pointer.x;\n const dy = cy - pointer.y;\n const d2 = dx * dx + dy * dy;\n if (d2 > r2) continue;\n const t = (i + u) / last;\n if (best === null || d2 < best.d2) best = { segIdx, t, d2 };\n }\n }\n return best ? { segIdx: best.segIdx, t: best.t } : null;\n}\n",".root {\n /* Component-local vars layered over the theme tokens. Each var resolves\n * to a semantic token from @weasel-js/theme; consumers override\n * either the curve-* var (component scope) or the wzl-* token (app\n * scope) without touching this file.\n *\n * Background / grid / axis tokens live on Plot2D now (this component\n * composes Plot2D, which paints the background and chrome). */\n --curve-line: var(--wzl-curve-color);\n --curve-line-width: var(--wzl-curve-width);\n --curve-fill: color-mix(in srgb, var(--curve-line) 30%, transparent);\n --curve-anchor-fill: var(--wzl-surface);\n --curve-anchor-stroke: var(--curve-line);\n --curve-anchor-active-fill: var(--curve-line);\n --curve-pinned-fill: var(--wzl-fg-subtle);\n}\n\n.fill {\n fill: var(--curve-fill);\n stroke: none;\n pointer-events: none;\n}\n\n.curve {\n stroke: var(--curve-line);\n stroke-width: var(--curve-line-width);\n fill: none;\n pointer-events: stroke;\n}\n\n.anchor {\n fill: var(--curve-anchor-fill);\n stroke: var(--curve-anchor-stroke);\n stroke-width: 1.5;\n cursor: grab;\n}\n\n.anchor:hover {\n fill: var(--curve-anchor-active-fill);\n}\n\n.anchor.active {\n fill: var(--curve-anchor-active-fill);\n cursor: grabbing;\n}\n\n.anchor.pinned {\n fill: var(--curve-pinned-fill);\n cursor: default;\n}\n\n/* Caller-set locked anchors share the gray pinned fill but signal\n * \"not interactive at all\" via the not-allowed cursor. */\n.anchor.locked {\n cursor: not-allowed;\n}\n\n/* Endpoint vertices render as diamonds (rotated squares) instead of\n * circles, so they read as a different category of handle. The shape\n * is enforced inline via SVG <rect transform>; this class only adds\n * the hover/active styling. */\n.endpoint {\n /* No fill / stroke overrides — endpoint visuals reuse .anchor /\n * .anchor.pinned / .anchor.active styling. The class exists as a\n * marker for future per-endpoint styling needs. */\n}\n\n/* Focus is drawn on the mark itself: an outline on an SVG shape rings its\n bounding box, which the nearest scroll container clips. */\n.anchor:focus-visible {\n outline: none;\n stroke: var(--wzl-focus-ring);\n stroke-width: 2;\n}\n\n/* ── keyframe layer ─────────────────────────────────────────────────── */\n\n.keyframe {\n fill: var(--curve-key-fill, var(--wzl-fg-muted));\n cursor: grab;\n}\n\n.keyframe[aria-current='true'] { fill: var(--curve-selected, var(--wzl-accent-strong)); }\n.keyframe:focus-visible,\n.handle:focus-visible {\n outline: none;\n stroke: var(--wzl-focus-ring);\n stroke-width: 2;\n}\n\n.segmentTarget:focus-visible {\n outline: none;\n stroke: var(--wzl-focus-ring);\n stroke-opacity: 0.5;\n}\n\n/* The committed key holds while its ghost tracks the pointer, so a drag\n reads as a move from somewhere to somewhere. */\n.keyframe[data-dragging='true'] { opacity: 0.4; }\n\n.keyframeGhost {\n fill: var(--curve-selected-soft, var(--wzl-accent-soft));\n stroke: var(--curve-selected, var(--wzl-accent-strong));\n stroke-width: 1;\n stroke-dasharray: 2 2;\n pointer-events: none;\n}\n\n.segmentBand {\n fill: var(--curve-selected-soft, var(--wzl-accent-soft));\n pointer-events: none;\n}\n\n/* Carries focus and a name for each segment; hit testing is geometric. */\n.segmentTarget {\n fill: none;\n stroke: transparent;\n stroke-width: 8;\n pointer-events: none;\n}\n\n.handle {\n fill: var(--wzl-surface);\n stroke: var(--curve-selected, var(--wzl-accent-strong));\n stroke-width: 1;\n cursor: grab;\n}\n\n.handleStem {\n stroke: var(--curve-selected, var(--wzl-accent-strong));\n stroke-width: 1;\n pointer-events: none;\n}\n","import {\n useCallback, useEffect, useMemo, useRef, useState,\n type CSSProperties,\n type KeyboardEvent as ReactKeyboardEvent,\n type PointerEvent as ReactPointerEvent,\n type ReactNode,\n} from 'react';\nimport { openPointerSession, useLatest, type PointerSession } from '@weasel-js/core';\nimport {\n Plot2D,\n type Plot2DHandle,\n type GridSettings,\n type AxesSettings,\n type TickSettings,\n} from '../Plot2D';\nimport {\n modelToPlot, plotToModel,\n type ModelRange,\n} from '../Plot2D/geometry';\nimport { dlog } from '../../dlog';\nimport s from './CurveEditor.module.css';\nimport type {\n CurveLayer, LayerCtx, LayerGesture, LayerModifiers, ModelPoint, PlotPoint,\n} from './layerTypes';\n\n/**\n * A layer paired with the state the consumer holds for it. The editor never\n * stores layer state itself.\n */\nexport interface LayerBinding<S = unknown> {\n layer: CurveLayer<S>;\n state: S;\n}\n\n/** Props for {@link LayeredCurveEditor}. */\nexport interface LayeredCurveEditorProps {\n /** Bottom-to-top render order: `layers[0]` paints first, `layers[N-1]`\n * paints on top. Hit-testing runs in reverse (topmost claim wins). */\n layers: ReadonlyArray<LayerBinding<unknown>>;\n\n /** Fires every frame during a gesture with the live in-flight state\n * for the layer that owns the gesture. */\n onLayerChange(id: string, next: unknown): void;\n\n /** Fires once per discrete user action (drag-end, one-shot insert,\n * delete) for the layer that produced the change. `prev` is the\n * layer's state at gesture start. */\n onLayerCommit?(id: string, next: unknown, prev: unknown): void;\n\n width: number;\n height: number;\n /** Model-space x range. Default [0, 1]. */\n xRange?: readonly [number, number];\n /** Model-space y range. Default [0, 1]. */\n yRange?: readonly [number, number];\n grid?: GridSettings | false | null;\n axes?: AxesSettings | false | null;\n /** Ticks at x values. See `Plot2D.xTicks`. */\n xTicks?: TickSettings | false | null;\n /** Ticks at y values. See `Plot2D.yTicks`. */\n yTicks?: TickSettings | false | null;\n\n /** Built-in undo/redo via Cmd/Ctrl+Z (Shift+Z or Y for redo) on the\n * focused SVG. Snapshots every layer's state on each commit; undo\n * fires `onLayerChange(id, prevState)` for each layer whose state\n * changed. Default `true`. */\n history?: boolean;\n\n /** Accessible name for the plot, which is exposed as a group so the\n * focusable marks layers render inside it stay reachable. */\n 'aria-label'?: string;\n className?: string;\n style?: CSSProperties;\n\n /** Extra SVG content rendered behind all layers (under the lowest\n * layer but above grid/axes). Use this for static chrome that isn't\n * worth modeling as a layer. */\n children?: ReactNode;\n}\n\ninterface ActiveGesture {\n layerId: string;\n gesture: LayerGesture<unknown>;\n startStates: Map<string, unknown>;\n startSelfState: unknown;\n}\n\n/** A cancel carries no event, so a layer's `onCancel` sees no modifiers held. */\nconst NO_MODIFIERS: LayerModifiers = { shift: false, alt: false, meta: false, ctrl: false };\n\nfunction readModifiers(e: PointerEvent | ReactPointerEvent | KeyboardEvent | ReactKeyboardEvent): LayerModifiers {\n return {\n shift: e.shiftKey,\n alt: e.altKey,\n meta: e.metaKey,\n ctrl: e.ctrlKey,\n };\n}\n\n/**\n * A `Plot2D` that hosts a stack of composable curve layers. It owns the\n * pointer gestures and the coordinate mapping; each layer supplies its own\n * drawing, hit testing and gesture behavior.\n *\n * Layer state stays with the consumer: the editor reports changes through\n * `onLayerChange` during a gesture and `onLayerCommit` at its end, and reads\n * the state back from props each frame. That is what lets one layer's drag\n * update another layer's state mid-gesture.\n */\nexport function LayeredCurveEditor(props: LayeredCurveEditorProps) {\n const {\n layers, onLayerChange, onLayerCommit,\n width, height,\n xRange = [0, 1], yRange = [0, 1],\n grid, axes, xTicks, yTicks,\n className, style, children,\n } = props;\n\n const historyEnabled = props.history !== false;\n\n const modelRange: ModelRange = useMemo(\n () => ({ xMin: xRange[0], xMax: xRange[1], yMin: yRange[0], yMax: yRange[1] }),\n [xRange, yRange],\n );\n const plotSize = useMemo(() => ({ width, height }), [width, height]);\n\n // Refs that always hold the latest props — gesture handlers and\n // window listeners close over these refs, never over render-time\n // values, so mid-drag re-renders (including cross-layer state\n // updates) are visible to the next pointermove tick.\n const layersRef = useLatest(layers);\n const modelRangeRef = useLatest(modelRange);\n const plotSizeRef = useLatest(plotSize);\n\n const plotRef = useRef<Plot2DHandle | null>(null);\n\n // ── Coord helpers ──────────────────────────────────────────────────\n const makeCtx = useCallback((modifiers: LayerModifiers): LayerCtx => {\n const mr = modelRangeRef.current;\n const ps = plotSizeRef.current;\n return {\n modelRange: mr,\n plotSize: ps,\n toPlot: (p) => modelToPlot(p, mr, ps),\n toModel: (p) => plotToModel(p, mr, ps),\n modifiers,\n };\n }, [modelRangeRef, plotSizeRef]);\n\n // ── Gesture routing ────────────────────────────────────────────────\n const activeRef = useRef(null as ActiveGesture | null);\n const [activeLayerId, setActiveLayerId] = useState<string | null>(null);\n\n // ── History (whole-state snapshots) ────────────────────────────────\n const pastRef = useRef<Map<string, unknown>[]>([]);\n const futureRef = useRef<Map<string, unknown>[]>([]);\n\n const snapshot = useCallback((): Map<string, unknown> => {\n const m = new Map<string, unknown>();\n for (const b of layersRef.current) m.set(b.layer.id, b.state);\n return m;\n }, [layersRef]);\n\n const restore = useCallback((snap: Map<string, unknown>) => {\n const current = layersRef.current;\n for (const b of current) {\n const prev = snap.get(b.layer.id);\n if (prev !== undefined && prev !== b.state) {\n onLayerChange(b.layer.id, prev);\n }\n }\n }, [onLayerChange, layersRef]);\n\n const undo = useCallback(() => {\n if (!historyEnabled) return;\n const past = pastRef.current;\n if (past.length === 0) return;\n const prev = past.pop()!;\n futureRef.current.push(snapshot());\n restore(prev);\n }, [historyEnabled, snapshot, restore]);\n\n const redo = useCallback(() => {\n if (!historyEnabled) return;\n const future = futureRef.current;\n if (future.length === 0) return;\n const next = future.pop()!;\n pastRef.current.push(snapshot());\n restore(next);\n }, [historyEnabled, snapshot, restore]);\n\n // ── Pointer routing during an active gesture ───────────────────────\n // The session's callbacks are fixed at gesture start, so they delegate\n // through refs holding the latest committed impl — a mid-drag re-render\n // must reach the next pointermove tick.\n const sessionRef = useRef<PointerSession | null>(null);\n\n const cleanupGesture = useCallback(() => {\n sessionRef.current = null;\n activeRef.current = null;\n setActiveLayerId(null);\n }, []);\n\n const findLayerState = useCallback((id: string): unknown | undefined => {\n for (const b of layersRef.current) if (b.layer.id === id) return b.state;\n return undefined;\n }, [layersRef]);\n\n const onGestureMoveRef = useLatest((e: PointerEvent) => {\n const a = activeRef.current;\n if (!a) return;\n const h = plotRef.current;\n if (!h) return;\n const model = h.clientToModel(e);\n const current = findLayerState(a.layerId);\n if (current === undefined) return;\n const ctx = makeCtx(readModifiers(e));\n const next = a.gesture.onMove(current, model, e, ctx);\n if (next !== current) onLayerChange(a.layerId, next);\n });\n\n const onGestureEndRef = useLatest((e: PointerEvent) => {\n const a = activeRef.current;\n if (!a) return;\n const current = findLayerState(a.layerId);\n if (current === undefined) { cleanupGesture(); return; }\n const ctx = makeCtx(readModifiers(e));\n const finalState = a.gesture.onCommit ? a.gesture.onCommit(current, ctx) : current;\n if (finalState !== current) onLayerChange(a.layerId, finalState);\n if (historyEnabled) {\n pastRef.current.push(a.startStates);\n futureRef.current = [];\n }\n if (onLayerCommit) onLayerCommit(a.layerId, finalState, a.startSelfState);\n cleanupGesture();\n });\n\n const onGestureCancelRef = useLatest(() => {\n const a = activeRef.current;\n if (!a) return;\n const current = findLayerState(a.layerId);\n if (current === undefined) { cleanupGesture(); return; }\n const ctx = makeCtx(NO_MODIFIERS);\n const restored = a.gesture.onCancel ? a.gesture.onCancel(current, ctx) : a.startSelfState;\n if (restored !== current) onLayerChange(a.layerId, restored);\n cleanupGesture();\n });\n\n // No pointer capture: consumers render their own SVG chrome into the plot\n // through `children`, and capture would retarget pointerup away from it.\n const installGesture = useCallback((\n layerId: string,\n down: ReactPointerEvent<SVGSVGElement>,\n gesture: LayerGesture<unknown>,\n ) => {\n const startStates = snapshot();\n const startSelfState = startStates.get(layerId);\n activeRef.current = {\n layerId, gesture,\n startStates,\n startSelfState,\n };\n setActiveLayerId(layerId);\n sessionRef.current = openPointerSession(down.currentTarget, down, {\n onMove: (e) => onGestureMoveRef.current(e),\n onEnd: (e) => onGestureEndRef.current(e),\n onCancel: () => onGestureCancelRef.current(),\n }, { capture: false });\n }, [snapshot, onGestureCancelRef, onGestureEndRef, onGestureMoveRef]);\n\n // ── pointerdown dispatch ───────────────────────────────────────────\n const onSvgPointerDown = useCallback((\n e: ReactPointerEvent<SVGSVGElement>,\n coords: { plot: PlotPoint; model: ModelPoint },\n ) => {\n if (activeRef.current) return; // ignore secondary touches mid-gesture\n const modifiers = readModifiers(e);\n const ctx = makeCtx(modifiers);\n const ls = layersRef.current;\n const nativeEvent = e.nativeEvent;\n\n dlog('layered-curve-editor', 'pointerdown', { plot: coords.plot, model: coords.model, layers: ls.length });\n\n // Capture the pre-event snapshot once; reuse for history if any\n // path produces a commit (gesture-start commit or one-shot).\n const preEventSnapshot = snapshot();\n\n // Top-to-bottom hit test.\n for (let i = ls.length - 1; i >= 0; i--) {\n const b = ls[i];\n const hit = b.layer.hitTest?.(b.state, coords.plot, ctx);\n if (!hit) continue;\n // Found a claim. onPointerDown may start a gesture, absorb the\n // click, or commit a one-shot edit via extra.commit.\n const prevState = b.state;\n let committed: unknown = undefined;\n const gesture = b.layer.onPointerDown?.(\n prevState, hit, nativeEvent, ctx,\n {\n plot: coords.plot,\n model: coords.model,\n commit(next) { committed = next; onLayerChange(b.layer.id, next); },\n },\n );\n e.stopPropagation();\n if (gesture) {\n installGesture(b.layer.id, e, gesture);\n return;\n }\n if (committed !== undefined) {\n if (historyEnabled) {\n pastRef.current.push(preEventSnapshot);\n futureRef.current = [];\n }\n onLayerCommit?.(b.layer.id, committed, prevState);\n }\n return;\n }\n\n // No hit — empty space dispatch, top-to-bottom.\n let pendingCommit: { id: string; next: unknown; prev: unknown } | null = null;\n for (let i = ls.length - 1; i >= 0; i--) {\n const b = ls[i];\n if (!b.layer.onEmptyPointerDown) continue;\n const prevState = b.state;\n let committed: unknown = undefined;\n const gesture = b.layer.onEmptyPointerDown(\n prevState, coords.model, nativeEvent, ctx,\n {\n plot: coords.plot,\n model: coords.model,\n commit(next) {\n committed = next;\n onLayerChange(b.layer.id, next);\n },\n },\n );\n if (gesture) {\n // If onEmptyPointerDown also published a commit (e.g. click-curve\n // insert publishes the new point then drags it), the gesture's\n // startStates already capture the post-insert state; the commit\n // for history is the *pre*-event snapshot, written when the\n // gesture eventually finishes via the gesture-commit path. We\n // override the gesture's startStates so undo restores correctly.\n installGesture(b.layer.id, e, gesture);\n if (committed !== undefined && activeRef.current !== null) {\n (activeRef.current as ActiveGesture).startStates = preEventSnapshot;\n (activeRef.current as ActiveGesture).startSelfState = preEventSnapshot.get(b.layer.id);\n }\n return;\n }\n if (committed !== undefined) {\n pendingCommit = { id: b.layer.id, next: committed, prev: prevState };\n break;\n }\n }\n if (pendingCommit) {\n if (historyEnabled) {\n pastRef.current.push(preEventSnapshot);\n futureRef.current = [];\n }\n onLayerCommit?.(pendingCommit.id, pendingCommit.next, pendingCommit.prev);\n }\n }, [makeCtx, installGesture, onLayerChange, onLayerCommit, historyEnabled, snapshot, layersRef]);\n\n // ── keyboard ───────────────────────────────────────────────────────\n const onSvgKeyDown = useCallback((e: ReactKeyboardEvent<SVGSVGElement>) => {\n const modifiers = readModifiers(e);\n const ctx = makeCtx(modifiers);\n const ls = layersRef.current;\n // History first.\n if (historyEnabled && (e.metaKey || e.ctrlKey)) {\n const k = e.key.toLowerCase();\n if (k === 'z') {\n if (e.shiftKey) redo();\n else undo();\n e.preventDefault();\n return;\n }\n if (k === 'y') { redo(); e.preventDefault(); return; }\n }\n // Then layers (top-to-bottom).\n for (let i = ls.length - 1; i >= 0; i--) {\n const b = ls[i];\n if (!b.layer.onKeyDown) continue;\n const preEventSnapshot = snapshot();\n let committed: unknown = undefined;\n b.layer.onKeyDown(b.state, e.nativeEvent, ctx, {\n commit(next) { committed = next; onLayerChange(b.layer.id, next); },\n });\n if (committed !== undefined) {\n if (historyEnabled) {\n pastRef.current.push(preEventSnapshot);\n futureRef.current = [];\n }\n onLayerCommit?.(b.layer.id, committed, b.state);\n }\n // The layer prevents default on the native event, which the synthetic\n // event's `isDefaultPrevented` does not observe.\n if (e.nativeEvent.defaultPrevented) return;\n }\n }, [historyEnabled, undo, redo, makeCtx, snapshot, onLayerChange, onLayerCommit, layersRef]);\n\n useEffect(() => () => { sessionRef.current?.cancel(); }, []);\n\n // ── render ─────────────────────────────────────────────────────────\n const renderCtxBase: Omit<LayerCtx, 'modifiers'> = useMemo(() => ({\n modelRange,\n plotSize,\n toPlot: (p) => modelToPlot(p, modelRange, plotSize),\n toModel: (p) => plotToModel(p, modelRange, plotSize),\n }), [modelRange, plotSize]);\n\n const cls = [s.root, className].filter(Boolean).join(' ');\n\n return (\n <Plot2D\n ref={plotRef}\n className={cls}\n style={style}\n width={width}\n height={height}\n xRange={xRange}\n yRange={yRange}\n grid={grid}\n axes={axes}\n xTicks={xTicks}\n yTicks={yTicks}\n tabIndex={historyEnabled ? 0 : undefined}\n role=\"group\"\n aria-label={props['aria-label']}\n onPointerDown={onSvgPointerDown}\n onKeyDown={onSvgKeyDown}\n >\n {children}\n {layers.map((b) => {\n const ctx = {\n ...renderCtxBase,\n modifiers: { shift: false, alt: false, meta: false, ctrl: false },\n isActive: activeLayerId === b.layer.id,\n };\n return (\n <g key={b.layer.id} data-layer-id={b.layer.id}>\n {b.layer.render(b.state, ctx)}\n </g>\n );\n })}\n </Plot2D>\n );\n}\n","/**\n * Keyframe layer for LayeredCurveEditor: a value-over-time curve whose shape\n * between two keys is the easing on the later one, with draggable keys and\n * draggable cubic-bezier handles on the selected segment.\n *\n * Distinct from `createFunctionLayer`, which interpolates a spline through\n * its anchors. Here the keys are exact and the easing approximates between\n * them, so the two do not share curve maths.\n */\nimport type { ReactNode } from 'react';\nimport { cubicBezierEasing, resolveEasing, type EasingFn, type Keyframe } from '@weasel-js/core';\nimport { hitTestAnchor, hitTestCurve } from './hitTest';\nimport { handleHalf } from '../../handles';\nimport { SNAP_RADIUS_PX, snapToNearest } from '../../snap';\nimport s from './CurveEditor.module.css';\nimport type {\n CurveLayer, EmptyDownArgs, KeyDownArgs, LayerCtx, LayerGesture, LayerHit, LayerRenderCtx, PlotPoint,\n} from './layerTypes';\n\ntype Bezier = readonly [number, number, number, number];\n\n/** A gesture in flight. The committed keys hold still underneath it. */\nexport type KeyframeDrag =\n | { kind: 'key'; index: number; t: number; value: number }\n | { kind: 'handle'; segment: number; bezier: Bezier };\n\n/**\n * The state a keyframe layer owns, held by the consumer and round-tripped\n * through `LayeredCurveEditor`'s `onLayerChange`.\n */\nexport interface KeyframeLayerState {\n /** Sorted ascending by `t`. */\n keys: readonly Keyframe<number>[];\n selectedKey: number | null;\n /** Index of the key the selected segment runs into. Its bezier handles show. */\n selectedSegment: number | null;\n drag: KeyframeDrag | null;\n}\n\n/** Configuration for {@link createKeyframeLayer}. */\nexport interface KeyframeLayerConfig {\n /** Layer id; default `'keyframes'`. */\n id?: string;\n /** Names the curve in each mark's accessible name. Default `'Curve'`. */\n label?: string;\n /** Formats a key time for accessible names. Default: rounded number. */\n formatX?: (x: number) => string;\n /** Times a dragged key snaps to. Holding alt defeats the snap. */\n snapX?: readonly number[];\n /** Snap reach, in plot pixels. Default 6. */\n snapRadiusPx?: number;\n /** Bounds for a key's time. Default: unbounded. */\n xClamp?: readonly [number, number];\n /** Bounds for a key's value. Default: unbounded. */\n yClamp?: readonly [number, number];\n /** One arrow-key step in model units; shift takes ten. Default: 1% of the\n * plot's range on that axis. */\n step?: { x?: number; y?: number };\n}\n\nconst SAMPLES_PER_SEGMENT = 16;\nconst KEY_HIT_PX = 8;\nconst HANDLE_HIT_PX = 8;\nconst CURVE_HIT_PX = 6;\nconst KEY_HALF = handleHalf('--wzl-handle-size');\nconst HANDLE_RADIUS = 3.5;\nconst SHIFT_MULTIPLIER = 10;\nconst HANDLE_STEP = 0.01;\n\n/** A keyframe layer state with nothing selected and no gesture in flight. */\nexport function keyframeLayerState(keys: readonly Keyframe<number>[]): KeyframeLayerState {\n return { keys, selectedKey: null, selectedSegment: null, drag: null };\n}\n\nfunction clampTo(v: number, range?: readonly [number, number]): number {\n return range ? Math.min(range[1], Math.max(range[0], v)) : v;\n}\n\nfunction bezierOf(key: Keyframe<number> | undefined): Bezier | null {\n const e = key?.easing;\n return typeof e === 'object' && e !== null && 'bezier' in e ? e.bezier : null;\n}\n\nfunction moveKeyTo(\n keys: readonly Keyframe<number>[], index: number, t: number, value: number,\n): { keys: Keyframe<number>[]; selectedKey: number } {\n const moved = { ...keys[index], t, value };\n const rest = keys.filter((_, i) => i !== index);\n const at = rest.findIndex((k) => k.t > t);\n const selectedKey = at === -1 ? rest.length : at;\n rest.splice(selectedKey, 0, moved);\n return { keys: rest, selectedKey };\n}\n\n/**\n * The keys a state's drag would leave behind: a dragged key re-sorted into\n * place, or a dragged handle's control points written onto the key its\n * segment runs into. `selectedKey` follows a moved key to its new index; a\n * key dropped where it started returns the same `keys` array.\n */\nexport function applyKeyframeDrag(\n state: KeyframeLayerState,\n): { keys: readonly Keyframe<number>[]; selectedKey: number | null } {\n const { drag, keys } = state;\n if (!drag) return { keys, selectedKey: state.selectedKey };\n if (drag.kind === 'key') {\n const k = keys[drag.index];\n if (k && k.t === drag.t && k.value === drag.value) return { keys, selectedKey: drag.index };\n return moveKeyTo(keys, drag.index, drag.t, drag.value);\n }\n const next = keys.slice();\n next[drag.segment] = { ...keys[drag.segment], easing: { bezier: drag.bezier } };\n return { keys: next, selectedKey: state.selectedKey };\n}\n\n/**\n * Builds a keyframe layer for `LayeredCurveEditor`. Model x is time and model\n * y is value; each segment is drawn through the easing on the key it runs\n * into. Every key, segment and handle is focusable and named, and the arrow\n * keys move whichever one has focus.\n */\nexport function createKeyframeLayer(cfg: KeyframeLayerConfig = {}): CurveLayer<KeyframeLayerState> {\n const id = cfg.id ?? 'keyframes';\n const label = cfg.label ?? 'Curve';\n const formatX = cfg.formatX ?? ((x: number) => String(Math.round(x)));\n const snapRadiusPx = cfg.snapRadiusPx ?? SNAP_RADIUS_PX;\n\n // A live handle drag is previewed straight from its control points: a\n // fresh spec per pointermove through `resolveEasing` would leave one\n // permanent cache entry per pixel of drag.\n function easingInto(state: KeyframeLayerState, keys: readonly Keyframe<number>[], seg: number): EasingFn {\n const d = state.drag;\n if (d?.kind === 'handle' && d.segment === seg) return cubicBezierEasing(...d.bezier);\n return resolveEasing(keys[seg].easing);\n }\n\n function segmentSamples(state: KeyframeLayerState, keys: readonly Keyframe<number>[], ctx: LayerCtx): PlotPoint[][] {\n const out: PlotPoint[][] = [];\n for (let i = 1; i < keys.length; i++) {\n const a = keys[i - 1];\n const b = keys[i];\n const ease = easingInto(state, keys, i);\n const pts: PlotPoint[] = [];\n for (let j = 0; j <= SAMPLES_PER_SEGMENT; j++) {\n const u = j / SAMPLES_PER_SEGMENT;\n pts.push(ctx.toPlot({ x: a.t + (b.t - a.t) * u, y: a.value + (b.value - a.value) * ease(u) }));\n }\n out.push(pts);\n }\n return out;\n }\n\n function activeBezier(state: KeyframeLayerState): Bezier | null {\n const seg = state.selectedSegment;\n if (seg === null || seg < 1 || seg >= state.keys.length) return null;\n const d = state.drag;\n if (d?.kind === 'handle' && d.segment === seg) return d.bezier;\n return bezierOf(state.keys[seg]);\n }\n\n function handlePoints(state: KeyframeLayerState, bezier: Bezier, ctx: LayerCtx): [PlotPoint, PlotPoint] {\n const a = state.keys[state.selectedSegment! - 1];\n const b = state.keys[state.selectedSegment!];\n const at = (xf: number, yf: number) =>\n ctx.toPlot({ x: a.t + xf * (b.t - a.t), y: a.value + yf * (b.value - a.value) });\n return [at(bezier[0], bezier[1]), at(bezier[2], bezier[3])];\n }\n\n const path = (pts: readonly PlotPoint[]): string =>\n pts.map((p, i) => `${i === 0 ? 'M' : 'L'}${p.x.toFixed(2)},${p.y.toFixed(2)}`).join('');\n\n // ── render ──────────────────────────────────────────────────────────\n function render(state: KeyframeLayerState, ctx: LayerRenderCtx): ReactNode {\n const shown = state.drag?.kind === 'key' ? applyKeyframeDrag(state).keys : state.keys;\n const segments = segmentSamples(state, shown, ctx);\n const curve = segments.flatMap((pts, i) => (i === 0 ? pts : pts.slice(1)));\n const seg = state.selectedSegment;\n const bezier = activeBezier(state);\n const dragIndex = state.drag?.kind === 'key' ? state.drag.index : null;\n\n return (\n <>\n {seg !== null && seg >= 1 && seg < shown.length ? (() => {\n const x0 = ctx.toPlot({ x: shown[seg - 1].t, y: 0 }).x;\n const x1 = ctx.toPlot({ x: shown[seg].t, y: 0 }).x;\n return (\n <rect\n className={s.segmentBand}\n x={Math.min(x0, x1)}\n y={0}\n width={Math.abs(x1 - x0)}\n height={ctx.plotSize.height}\n />\n );\n })() : null}\n {curve.length > 1 ? <path data-curve-element=\"curve\" className={s.curve} d={path(curve)} /> : null}\n {segments.map((pts, i) => (\n <path\n key={`seg-${i + 1}`}\n className={s.segmentTarget}\n d={path(pts)}\n role=\"button\"\n tabIndex={0}\n aria-label={`${label} segment into ${formatX(shown[i + 1].t)}`}\n aria-current={seg === i + 1 ? 'true' : undefined}\n data-segment-index={i + 1}\n />\n ))}\n {bezier ? (() => {\n const [h1, h2] = handlePoints(state, bezier, ctx);\n const a = ctx.toPlot({ x: state.keys[seg! - 1].t, y: state.keys[seg! - 1].value });\n const b = ctx.toPlot({ x: state.keys[seg!].t, y: state.keys[seg!].value });\n return (\n <>\n <line className={s.handleStem} x1={a.x} y1={a.y} x2={h1.x} y2={h1.y} />\n <line className={s.handleStem} x1={b.x} y1={b.y} x2={h2.x} y2={h2.y} />\n {[h1, h2].map((h, i) => (\n <circle\n key={`handle-${i}`}\n className={s.handle}\n cx={h.x}\n cy={h.y}\n r={HANDLE_RADIUS}\n role=\"button\"\n tabIndex={0}\n aria-label={`${label} bezier handle ${i + 1}`}\n data-handle-index={i}\n />\n ))}\n </>\n );\n })() : null}\n {state.keys.map((k, i) => {\n const p = ctx.toPlot({ x: k.t, y: k.value });\n return (\n <rect\n key={`key-${i}`}\n className={s.keyframe}\n x={p.x - KEY_HALF}\n y={p.y - KEY_HALF}\n width={KEY_HALF * 2}\n height={KEY_HALF * 2}\n transform={`rotate(45 ${p.x} ${p.y})`}\n role=\"button\"\n tabIndex={0}\n aria-label={`${label} key at ${formatX(k.t)}`}\n aria-current={state.selectedKey === i ? 'true' : undefined}\n data-keyframe-index={i}\n data-dragging={dragIndex === i ? 'true' : undefined}\n />\n );\n })}\n {state.drag?.kind === 'key' ? (() => {\n const p = ctx.toPlot({ x: state.drag.t, y: state.drag.value });\n return (\n <rect\n aria-hidden=\"true\"\n className={s.keyframeGhost}\n x={p.x - KEY_HALF}\n y={p.y - KEY_HALF}\n width={KEY_HALF * 2}\n height={KEY_HALF * 2}\n transform={`rotate(45 ${p.x} ${p.y})`}\n data-keyframe-ghost=\"\"\n />\n );\n })() : null}\n </>\n );\n }\n\n // ── hit test ────────────────────────────────────────────────────────\n function hitTest(state: KeyframeLayerState, plot: PlotPoint, ctx: LayerCtx): LayerHit | null {\n const bezier = activeBezier(state);\n if (bezier) {\n const h = hitTestAnchor(handlePoints(state, bezier, ctx), plot, HANDLE_HIT_PX);\n if (h) return { kind: 'handle', payload: { handle: h.index } };\n }\n const k = hitTestAnchor(state.keys.map((key) => ctx.toPlot({ x: key.t, y: key.value })), plot, KEY_HIT_PX);\n if (k) return { kind: 'key', payload: { index: k.index } };\n const c = hitTestCurve(segmentSamples(state, state.keys, ctx), plot, CURVE_HIT_PX);\n if (c) return { kind: 'segment', payload: { segment: c.segIdx + 1 } };\n return null;\n }\n\n // ── gestures ────────────────────────────────────────────────────────\n function keyGesture(index: number): LayerGesture<KeyframeLayerState> {\n return {\n onMove(state, model, e, ctx) {\n let t = clampTo(model.x, cfg.xClamp);\n if (cfg.snapX && !e.altKey) {\n const perPx = (ctx.modelRange.xMax - ctx.modelRange.xMin) / ctx.plotSize.width;\n t = clampTo(snapToNearest(t, cfg.snapX, Math.abs(perPx) * snapRadiusPx), cfg.xClamp);\n }\n return { ...state, drag: { kind: 'key', index, t, value: clampTo(model.y, cfg.yClamp) } };\n },\n onCommit(state) { return { ...state, ...applyKeyframeDrag(state), drag: null }; },\n onCancel(state) { return { ...state, drag: null }; },\n };\n }\n\n function handleGesture(segment: number, handle: 0 | 1): LayerGesture<KeyframeLayerState> {\n return {\n onMove(state, model) {\n const a = state.keys[segment - 1];\n const b = state.keys[segment];\n const d = state.drag;\n if (!a || !b || d?.kind !== 'handle') return state;\n const xf = b.t === a.t ? 0 : Math.min(1, Math.max(0, (model.x - a.t) / (b.t - a.t)));\n const yf = b.value === a.value ? 0 : (model.y - a.value) / (b.value - a.value);\n const bezier = [...d.bezier] as [number, number, number, number];\n bezier[handle * 2] = xf;\n bezier[handle * 2 + 1] = yf;\n return { ...state, drag: { kind: 'handle', segment, bezier } };\n },\n onCommit(state) { return { ...state, ...applyKeyframeDrag(state), drag: null }; },\n onCancel(state) { return { ...state, drag: null }; },\n };\n }\n\n function onPointerDown(\n state: KeyframeLayerState,\n hit: LayerHit,\n e: PointerEvent,\n _ctx: LayerCtx,\n extra: EmptyDownArgs<KeyframeLayerState>,\n ): LayerGesture<KeyframeLayerState> | void {\n if (e.button !== 0) return;\n if (hit.kind === 'handle') {\n const bezier = activeBezier(state);\n const segment = state.selectedSegment;\n if (!bezier || segment === null) return;\n const { handle } = hit.payload as { handle: 0 | 1 };\n extra.commit({ ...state, drag: { kind: 'handle', segment, bezier } });\n return handleGesture(segment, handle);\n }\n if (hit.kind === 'key') {\n const { index } = hit.payload as { index: number };\n const k = state.keys[index];\n extra.commit({ ...state, selectedKey: index, drag: { kind: 'key', index, t: k.t, value: k.value } });\n return keyGesture(index);\n }\n if (hit.kind === 'segment') {\n const { segment } = hit.payload as { segment: number };\n extra.commit({ ...state, selectedSegment: segment });\n }\n }\n\n // ── keyboard ────────────────────────────────────────────────────────\n function onKeyDown(\n state: KeyframeLayerState,\n e: KeyboardEvent,\n ctx: LayerCtx,\n extra: KeyDownArgs<KeyframeLayerState>,\n ): void {\n const target = e.target as Element | null;\n if (target?.closest?.('[data-layer-id]')?.getAttribute('data-layer-id') !== id) return;\n const activate = e.key === 'Enter' || e.key === ' ';\n const dx = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0;\n const dy = e.key === 'ArrowUp' ? 1 : e.key === 'ArrowDown' ? -1 : 0;\n const mult = e.shiftKey ? SHIFT_MULTIPLIER : 1;\n\n const keyEl = target.closest('[data-keyframe-index]');\n if (keyEl) {\n const index = Number(keyEl.getAttribute('data-keyframe-index'));\n const k = state.keys[index];\n if (!k) return;\n if (activate) {\n e.preventDefault();\n extra.commit({ ...state, selectedKey: index });\n return;\n }\n if (dx === 0 && dy === 0) return;\n e.preventDefault();\n const m = ctx.modelRange;\n const stepX = (cfg.step?.x ?? Math.abs(m.xMax - m.xMin) / 100) * mult;\n const stepY = (cfg.step?.y ?? Math.abs(m.yMax - m.yMin) / 100) * mult;\n const t = clampTo(k.t + dx * stepX, cfg.xClamp);\n const value = clampTo(k.value + dy * stepY, cfg.yClamp);\n if (t === k.t && value === k.value) return;\n extra.commit({ ...state, ...moveKeyTo(state.keys, index, t, value), drag: null });\n return;\n }\n\n const segEl = target.closest('[data-segment-index]');\n if (segEl && activate) {\n e.preventDefault();\n extra.commit({ ...state, selectedSegment: Number(segEl.getAttribute('data-segment-index')) });\n return;\n }\n\n const handleEl = target.closest('[data-handle-index]');\n const bezier = activeBezier(state);\n if (handleEl && bezier && state.selectedSegment !== null && (dx !== 0 || dy !== 0)) {\n e.preventDefault();\n const h = Number(handleEl.getAttribute('data-handle-index'));\n const next = [...bezier] as [number, number, number, number];\n next[h * 2] = Math.min(1, Math.max(0, next[h * 2] + dx * HANDLE_STEP * mult));\n next[h * 2 + 1] += dy * HANDLE_STEP * mult;\n const drag: KeyframeDrag = { kind: 'handle', segment: state.selectedSegment, bezier: next };\n extra.commit({ ...state, ...applyKeyframeDrag({ ...state, drag }), drag: null });\n }\n }\n\n return { id, render, hitTest, onPointerDown, onKeyDown };\n}\n"],"mappings":";;;;;;;;AAYA,SAAgBS,EACd,GACA,GACA,GAC0B;CAC1B,IAAMC,IAAKC,IAASA,GAChBC,IAA6C;CACjD,KAAK,IAAIC,IAAI,GAAGA,IAAIC,EAAQ,QAAQ,KAAK;EACvC,IAAM,IAAIA,EAAQD,IACZE,IAAK,EAAE,IAAIC,EAAQ,GACnBC,IAAK,EAAE,IAAID,EAAQ,GACnBE,IAAKH,IAAKA,IAAKE,IAAKA;EAC1B,AAAIC,IAAKR,MACLE,MAAS,QAAQM,IAAKN,EAAK,QAAI,IAAO;GAAE,OAAOC;GAAG;EAAG;CAC3D;CACA,OAAOD,IAAO,EAAE,OAAOA,EAAK,MAAM,IAAI;AACxC;AAYA,SAAgBO,EACd,GACA,GACA,GACsC;CACtC,IAAMT,IAAKC,IAASA,GAChBC,IAAyD;CAC7D,KAAK,IAAIQ,IAAS,GAAGA,IAASC,EAAS,QAAQ,KAAU;EACvD,IAAMC,IAAUD,EAASD;EACzB,IAAIE,EAAQ,SAAS,GAAG;EACxB,IAAMC,IAAOD,EAAQ,SAAS;EAC9B,KAAK,IAAIT,IAAI,GAAGA,IAAIU,GAAM,KAAK;GAC7B,IAAMC,IAAIF,EAAQT,IACZY,IAAIH,EAAQT,IAAI,IAChBa,IAAMD,EAAE,IAAID,EAAE,GACdG,IAAMF,EAAE,IAAID,EAAE,GACdI,IAAMZ,EAAQ,IAAIQ,EAAE,GACpBK,IAAMb,EAAQ,IAAIQ,EAAE,GACpBM,IAAMJ,IAAMA,IAAMC,IAAMA,GAC1BI,IAAID,IAAM,KAAKF,IAAMF,IAAMG,IAAMF,KAAOG,IAAM;GAClD,AAAIC,IAAI,IAAG,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AG,MAAM;GAAK,CAAC;EACjF;CACF;CAEA,OAAO;EAAE;EAAI;EAAQ;EAAS;EAAe;CAAU;AACzD"}
1
+ {"version":3,"file":"createKeyframeLayer-DSVf13Su.js","names":["s","_Fragment","s","dlog","plotToModel","modelToPlot","Plot2D","handleHalf","snapToNearest","hitTestAnchor","r2","radius","best","i","anchors","dx","pointer","dy","d2","hitTestCurve","segIdx","segments","samples","last","a","b","abx","aby","apx","apy","ab2","u","cx","cy","t","CurveEditor_module_default","NO_MODIFIERS","readModifiers","LayeredCurveEditor","props","historyEnabled","modelRange","useMemo","xRange","yRange","plotSize","width","height","layersRef","useLatest","layers","modelRangeRef","plotSizeRef","plotRef","useRef","makeCtx","useCallback","mr","ps","p","activeRef","activeLayerId","setActiveLayerId","useState","pastRef","futureRef","snapshot","m","restore","current","prev","snap","onLayerChange","undo","past","redo","future","next","sessionRef","cleanupGesture","findLayerState","id","onGestureMoveRef","h","model","ctx","onGestureEndRef","finalState","onLayerCommit","onGestureCancelRef","restored","installGesture","startStates","startSelfState","layerId","openPointerSession","down","onSvgPointerDown","modifiers","e","ls","nativeEvent","coords","preEventSnapshot","hit","prevState","committed","gesture","pendingCommit","onSvgKeyDown","k","renderCtxBase","cls","className","children","SAMPLES_PER_SEGMENT","KEY_HIT_PX","HANDLE_HIT_PX","CURVE_HIT_PX","KEY_HALF","HANDLE_RADIUS","SHIFT_MULTIPLIER","HANDLE_STEP","keyframeLayerState","clampTo","range","v","bezierOf","key","moveKeyTo","moved","keys","index","rest","at","selectedKey","applyKeyframeDrag","state","drag","createKeyframeLayer","cfg","label","formatX","x","snapRadiusPx","easingInto","d","seg","cubicBezierEasing","resolveEasing","segmentSamples","out","ease","pts","j","activeBezier","handlePoints","xf","yf","bezier","path","render","shown","curve","dragIndex","Fragment","x0","x1","h1","h2","hitTest","plot","c","keyGesture","perPx","handleGesture","segment","handle","onPointerDown","extra","onKeyDown","target","activate","mult","keyEl","stepX","stepY","value","segEl","handleEl"],"sources":["../../src/components/CurveEditor/hitTest.ts","../../src/components/CurveEditor/CurveEditor.module.css","../../src/components/CurveEditor/LayeredCurveEditor.tsx","../../src/components/CurveEditor/createKeyframeLayer.tsx"],"sourcesContent":["/**\n * Curve-specific hit tests. Generic coord transforms live in\n * `../Plot2D/geometry`; what's here is curve-only (anchor / polyline\n * proximity).\n */\nimport type { Point } from '../Plot2D/geometry';\n\n/**\n * Nearest-anchor hit test. Anchors are already in plot/screen coords.\n * Returns the index of the nearest anchor whose squared distance to\n * the pointer is ≤ radius². Null if no anchor is within radius.\n */\nexport function hitTestAnchor(\n anchors: readonly Point[],\n pointer: Point,\n radius: number,\n): { index: number } | null {\n const r2 = radius * radius;\n let best: { index: number; d2: number } | null = null;\n for (let i = 0; i < anchors.length; i++) {\n const a = anchors[i];\n const dx = a.x - pointer.x;\n const dy = a.y - pointer.y;\n const d2 = dx * dx + dy * dy;\n if (d2 > r2) continue;\n if (best === null || d2 < best.d2) best = { index: i, d2 };\n }\n return best ? { index: best.index } : null;\n}\n\n/**\n * Hit test against a per-segment sampled polyline. Each entry in\n * `segments` is the sample list for one segment (inclusive of\n * endpoints). Returns segment index + t (∈ [0, 1]) of the closest\n * point on the polyline within radius. Null if nothing is in range.\n *\n * Distance is measured to the line-segment chords between adjacent\n * samples, not just to the samples themselves — so sparse sampling\n * still produces accurate hits along the chord.\n */\nexport function hitTestCurve(\n segments: readonly (readonly Point[])[],\n pointer: Point,\n radius: number,\n): { segIdx: number; t: number } | null {\n const r2 = radius * radius;\n let best: { segIdx: number; t: number; d2: number } | null = null;\n for (let segIdx = 0; segIdx < segments.length; segIdx++) {\n const samples = segments[segIdx];\n if (samples.length < 2) continue;\n const last = samples.length - 1;\n for (let i = 0; i < last; i++) {\n const a = samples[i];\n const b = samples[i + 1];\n const abx = b.x - a.x;\n const aby = b.y - a.y;\n const apx = pointer.x - a.x;\n const apy = pointer.y - a.y;\n const ab2 = abx * abx + aby * aby;\n let u = ab2 > 0 ? (apx * abx + apy * aby) / ab2 : 0;\n if (u < 0) u = 0;\n else if (u > 1) u = 1;\n const cx = a.x + u * abx;\n const cy = a.y + u * aby;\n const dx = cx - pointer.x;\n const dy = cy - pointer.y;\n const d2 = dx * dx + dy * dy;\n if (d2 > r2) continue;\n const t = (i + u) / last;\n if (best === null || d2 < best.d2) best = { segIdx, t, d2 };\n }\n }\n return best ? { segIdx: best.segIdx, t: best.t } : null;\n}\n",".root {\n /* Component-local vars layered over the theme tokens. Each var resolves\n * to a semantic token from @weasel-js/theme; consumers override\n * either the curve-* var (component scope) or the wzl-* token (app\n * scope) without touching this file.\n *\n * Background / grid / axis tokens live on Plot2D now (this component\n * composes Plot2D, which paints the background and chrome). */\n --curve-line: var(--wzl-curve-color);\n --curve-line-width: var(--wzl-curve-width);\n --curve-fill: color-mix(in srgb, var(--curve-line) 30%, transparent);\n --curve-anchor-fill: var(--wzl-surface);\n --curve-anchor-stroke: var(--curve-line);\n --curve-anchor-active-fill: var(--curve-line);\n --curve-pinned-fill: var(--wzl-fg-subtle);\n}\n\n.fill {\n fill: var(--curve-fill);\n stroke: none;\n pointer-events: none;\n}\n\n.curve {\n stroke: var(--curve-line);\n stroke-width: var(--curve-line-width);\n fill: none;\n pointer-events: stroke;\n}\n\n.anchor {\n fill: var(--curve-anchor-fill);\n stroke: var(--curve-anchor-stroke);\n stroke-width: 1.5;\n cursor: grab;\n}\n\n.anchor:hover {\n fill: var(--curve-anchor-active-fill);\n}\n\n.anchor.active {\n fill: var(--curve-anchor-active-fill);\n cursor: grabbing;\n}\n\n.anchor.pinned {\n fill: var(--curve-pinned-fill);\n cursor: default;\n}\n\n/* Caller-set locked anchors share the gray pinned fill but signal\n * \"not interactive at all\" via the not-allowed cursor. */\n.anchor.locked {\n cursor: not-allowed;\n}\n\n/* Endpoint vertices render as diamonds (rotated squares) instead of\n * circles, so they read as a different category of handle. The shape\n * is enforced inline via SVG <rect transform>; this class only adds\n * the hover/active styling. */\n.endpoint {\n /* No fill / stroke overrides — endpoint visuals reuse .anchor /\n * .anchor.pinned / .anchor.active styling. The class exists as a\n * marker for future per-endpoint styling needs. */\n}\n\n/* Focus is drawn on the mark itself: an outline on an SVG shape rings its\n bounding box, which the nearest scroll container clips. */\n.anchor:focus-visible {\n outline: none;\n stroke: var(--wzl-focus-ring);\n stroke-width: 2;\n}\n\n/* ── keyframe layer ─────────────────────────────────────────────────── */\n\n.keyframe {\n fill: var(--curve-key-fill, var(--wzl-fg-muted));\n cursor: grab;\n}\n\n.keyframe[aria-current='true'] { fill: var(--curve-selected, var(--wzl-accent-strong)); }\n.keyframe:focus-visible,\n.handle:focus-visible {\n outline: none;\n stroke: var(--wzl-focus-ring);\n stroke-width: 2;\n}\n\n.segmentTarget:focus-visible {\n outline: none;\n stroke: var(--wzl-focus-ring);\n stroke-opacity: 0.5;\n}\n\n/* The committed key holds while its ghost tracks the pointer, so a drag\n reads as a move from somewhere to somewhere. */\n.keyframe[data-dragging='true'] { opacity: 0.4; }\n\n.keyframeGhost {\n fill: var(--curve-selected-soft, var(--wzl-accent-soft));\n stroke: var(--curve-selected, var(--wzl-accent-strong));\n stroke-width: 1;\n stroke-dasharray: 2 2;\n pointer-events: none;\n}\n\n.segmentBand {\n fill: var(--curve-selected-soft, var(--wzl-accent-soft));\n pointer-events: none;\n}\n\n/* Carries focus and a name for each segment; hit testing is geometric. */\n.segmentTarget {\n fill: none;\n stroke: transparent;\n stroke-width: 8;\n pointer-events: none;\n}\n\n.handle {\n fill: var(--wzl-surface);\n stroke: var(--curve-selected, var(--wzl-accent-strong));\n stroke-width: 1;\n cursor: grab;\n}\n\n.handleStem {\n stroke: var(--curve-selected, var(--wzl-accent-strong));\n stroke-width: 1;\n pointer-events: none;\n}\n","import {\n useCallback, useEffect, useMemo, useRef, useState,\n type CSSProperties,\n type KeyboardEvent as ReactKeyboardEvent,\n type PointerEvent as ReactPointerEvent,\n type ReactNode,\n} from 'react';\nimport { openPointerSession, useLatest, type PointerSession } from '@weasel-js/core';\nimport {\n Plot2D,\n type Plot2DHandle,\n type GridSettings,\n type AxesSettings,\n type TickSettings,\n} from '../Plot2D';\nimport {\n modelToPlot, plotToModel,\n type ModelRange,\n} from '../Plot2D/geometry';\nimport { dlog } from '../../dlog';\nimport s from './CurveEditor.module.css';\nimport type {\n CurveLayer, LayerCtx, LayerGesture, LayerModifiers, ModelPoint, PlotPoint,\n} from './layerTypes';\n\n/**\n * A layer paired with the state the consumer holds for it. The editor never\n * stores layer state itself.\n */\nexport interface LayerBinding<S = unknown> {\n layer: CurveLayer<S>;\n state: S;\n}\n\n/** Props for {@link LayeredCurveEditor}. */\nexport interface LayeredCurveEditorProps {\n /** Bottom-to-top render order: `layers[0]` paints first, `layers[N-1]`\n * paints on top. Hit-testing runs in reverse (topmost claim wins). */\n layers: ReadonlyArray<LayerBinding<unknown>>;\n\n /** Fires every frame during a gesture with the live in-flight state\n * for the layer that owns the gesture. */\n onLayerChange(id: string, next: unknown): void;\n\n /** Fires once per discrete user action (drag-end, one-shot insert,\n * delete) for the layer that produced the change. `prev` is the\n * layer's state at gesture start. */\n onLayerCommit?(id: string, next: unknown, prev: unknown): void;\n\n width: number;\n height: number;\n /** Model-space x range. Default [0, 1]. */\n xRange?: readonly [number, number];\n /** Model-space y range. Default [0, 1]. */\n yRange?: readonly [number, number];\n grid?: GridSettings | false | null;\n axes?: AxesSettings | false | null;\n /** Ticks at x values. See `Plot2D.xTicks`. */\n xTicks?: TickSettings | false | null;\n /** Ticks at y values. See `Plot2D.yTicks`. */\n yTicks?: TickSettings | false | null;\n\n /** Built-in undo/redo via Cmd/Ctrl+Z (Shift+Z or Y for redo) on the\n * focused SVG. Snapshots every layer's state on each commit; undo\n * fires `onLayerChange(id, prevState)` for each layer whose state\n * changed. Default `true`. */\n history?: boolean;\n\n /** Accessible name for the plot, which is exposed as a group so the\n * focusable marks layers render inside it stay reachable. */\n 'aria-label'?: string;\n className?: string;\n style?: CSSProperties;\n\n /** Extra SVG content rendered behind all layers (under the lowest\n * layer but above grid/axes). Use this for static chrome that isn't\n * worth modeling as a layer. */\n children?: ReactNode;\n}\n\ninterface ActiveGesture {\n layerId: string;\n gesture: LayerGesture<unknown>;\n startStates: Map<string, unknown>;\n startSelfState: unknown;\n}\n\n/** A cancel carries no event, so a layer's `onCancel` sees no modifiers held. */\nconst NO_MODIFIERS: LayerModifiers = { shift: false, alt: false, meta: false, ctrl: false };\n\nfunction readModifiers(e: PointerEvent | ReactPointerEvent | KeyboardEvent | ReactKeyboardEvent): LayerModifiers {\n return {\n shift: e.shiftKey,\n alt: e.altKey,\n meta: e.metaKey,\n ctrl: e.ctrlKey,\n };\n}\n\n/**\n * A `Plot2D` that hosts a stack of composable curve layers. It owns the\n * pointer gestures and the coordinate mapping; each layer supplies its own\n * drawing, hit testing and gesture behavior.\n *\n * Layer state stays with the consumer: the editor reports changes through\n * `onLayerChange` during a gesture and `onLayerCommit` at its end, and reads\n * the state back from props each frame. That is what lets one layer's drag\n * update another layer's state mid-gesture.\n */\nexport function LayeredCurveEditor(props: LayeredCurveEditorProps) {\n const {\n layers, onLayerChange, onLayerCommit,\n width, height,\n xRange = [0, 1], yRange = [0, 1],\n grid, axes, xTicks, yTicks,\n className, style, children,\n } = props;\n\n const historyEnabled = props.history !== false;\n\n const modelRange: ModelRange = useMemo(\n () => ({ xMin: xRange[0], xMax: xRange[1], yMin: yRange[0], yMax: yRange[1] }),\n [xRange, yRange],\n );\n const plotSize = useMemo(() => ({ width, height }), [width, height]);\n\n // Refs that always hold the latest props — gesture handlers and\n // window listeners close over these refs, never over render-time\n // values, so mid-drag re-renders (including cross-layer state\n // updates) are visible to the next pointermove tick.\n const layersRef = useLatest(layers);\n const modelRangeRef = useLatest(modelRange);\n const plotSizeRef = useLatest(plotSize);\n\n const plotRef = useRef<Plot2DHandle | null>(null);\n\n // ── Coord helpers ──────────────────────────────────────────────────\n const makeCtx = useCallback((modifiers: LayerModifiers): LayerCtx => {\n const mr = modelRangeRef.current;\n const ps = plotSizeRef.current;\n return {\n modelRange: mr,\n plotSize: ps,\n toPlot: (p) => modelToPlot(p, mr, ps),\n toModel: (p) => plotToModel(p, mr, ps),\n modifiers,\n };\n }, [modelRangeRef, plotSizeRef]);\n\n // ── Gesture routing ────────────────────────────────────────────────\n const activeRef = useRef(null as ActiveGesture | null);\n const [activeLayerId, setActiveLayerId] = useState<string | null>(null);\n\n // ── History (whole-state snapshots) ────────────────────────────────\n const pastRef = useRef<Map<string, unknown>[]>([]);\n const futureRef = useRef<Map<string, unknown>[]>([]);\n\n const snapshot = useCallback((): Map<string, unknown> => {\n const m = new Map<string, unknown>();\n for (const b of layersRef.current) m.set(b.layer.id, b.state);\n return m;\n }, [layersRef]);\n\n const restore = useCallback((snap: Map<string, unknown>) => {\n const current = layersRef.current;\n for (const b of current) {\n const prev = snap.get(b.layer.id);\n if (prev !== undefined && prev !== b.state) {\n onLayerChange(b.layer.id, prev);\n }\n }\n }, [onLayerChange, layersRef]);\n\n const undo = useCallback(() => {\n if (!historyEnabled) return;\n const past = pastRef.current;\n if (past.length === 0) return;\n const prev = past.pop()!;\n futureRef.current.push(snapshot());\n restore(prev);\n }, [historyEnabled, snapshot, restore]);\n\n const redo = useCallback(() => {\n if (!historyEnabled) return;\n const future = futureRef.current;\n if (future.length === 0) return;\n const next = future.pop()!;\n pastRef.current.push(snapshot());\n restore(next);\n }, [historyEnabled, snapshot, restore]);\n\n // ── Pointer routing during an active gesture ───────────────────────\n // The session's callbacks are fixed at gesture start, so they delegate\n // through refs holding the latest committed impl — a mid-drag re-render\n // must reach the next pointermove tick.\n const sessionRef = useRef<PointerSession | null>(null);\n\n const cleanupGesture = useCallback(() => {\n sessionRef.current = null;\n activeRef.current = null;\n setActiveLayerId(null);\n }, []);\n\n const findLayerState = useCallback((id: string): unknown | undefined => {\n for (const b of layersRef.current) if (b.layer.id === id) return b.state;\n return undefined;\n }, [layersRef]);\n\n const onGestureMoveRef = useLatest((e: PointerEvent) => {\n const a = activeRef.current;\n if (!a) return;\n const h = plotRef.current;\n if (!h) return;\n const model = h.clientToModel(e);\n const current = findLayerState(a.layerId);\n if (current === undefined) return;\n const ctx = makeCtx(readModifiers(e));\n const next = a.gesture.onMove(current, model, e, ctx);\n if (next !== current) onLayerChange(a.layerId, next);\n });\n\n const onGestureEndRef = useLatest((e: PointerEvent) => {\n const a = activeRef.current;\n if (!a) return;\n const current = findLayerState(a.layerId);\n if (current === undefined) { cleanupGesture(); return; }\n const ctx = makeCtx(readModifiers(e));\n const finalState = a.gesture.onCommit ? a.gesture.onCommit(current, ctx) : current;\n if (finalState !== current) onLayerChange(a.layerId, finalState);\n if (historyEnabled) {\n pastRef.current.push(a.startStates);\n futureRef.current = [];\n }\n if (onLayerCommit) onLayerCommit(a.layerId, finalState, a.startSelfState);\n cleanupGesture();\n });\n\n const onGestureCancelRef = useLatest(() => {\n const a = activeRef.current;\n if (!a) return;\n const current = findLayerState(a.layerId);\n if (current === undefined) { cleanupGesture(); return; }\n const ctx = makeCtx(NO_MODIFIERS);\n const restored = a.gesture.onCancel ? a.gesture.onCancel(current, ctx) : a.startSelfState;\n if (restored !== current) onLayerChange(a.layerId, restored);\n cleanupGesture();\n });\n\n // No pointer capture: consumers render their own SVG chrome into the plot\n // through `children`, and capture would retarget pointerup away from it.\n const installGesture = useCallback((\n layerId: string,\n down: ReactPointerEvent<SVGSVGElement>,\n gesture: LayerGesture<unknown>,\n ) => {\n const startStates = snapshot();\n const startSelfState = startStates.get(layerId);\n activeRef.current = {\n layerId, gesture,\n startStates,\n startSelfState,\n };\n setActiveLayerId(layerId);\n sessionRef.current = openPointerSession(down.currentTarget, down, {\n onMove: (e) => onGestureMoveRef.current(e),\n onEnd: (e) => onGestureEndRef.current(e),\n onCancel: () => onGestureCancelRef.current(),\n }, { capture: false });\n }, [snapshot, onGestureCancelRef, onGestureEndRef, onGestureMoveRef]);\n\n // ── pointerdown dispatch ───────────────────────────────────────────\n const onSvgPointerDown = useCallback((\n e: ReactPointerEvent<SVGSVGElement>,\n coords: { plot: PlotPoint; model: ModelPoint },\n ) => {\n if (activeRef.current) return; // ignore secondary touches mid-gesture\n const modifiers = readModifiers(e);\n const ctx = makeCtx(modifiers);\n const ls = layersRef.current;\n const nativeEvent = e.nativeEvent;\n\n dlog('layered-curve-editor', 'pointerdown', { plot: coords.plot, model: coords.model, layers: ls.length });\n\n // Capture the pre-event snapshot once; reuse for history if any\n // path produces a commit (gesture-start commit or one-shot).\n const preEventSnapshot = snapshot();\n\n // Top-to-bottom hit test.\n for (let i = ls.length - 1; i >= 0; i--) {\n const b = ls[i];\n const hit = b.layer.hitTest?.(b.state, coords.plot, ctx);\n if (!hit) continue;\n // Found a claim. onPointerDown may start a gesture, absorb the\n // click, or commit a one-shot edit via extra.commit.\n const prevState = b.state;\n let committed: unknown = undefined;\n const gesture = b.layer.onPointerDown?.(\n prevState, hit, nativeEvent, ctx,\n {\n plot: coords.plot,\n model: coords.model,\n commit(next) { committed = next; onLayerChange(b.layer.id, next); },\n },\n );\n e.stopPropagation();\n if (gesture) {\n installGesture(b.layer.id, e, gesture);\n return;\n }\n if (committed !== undefined) {\n if (historyEnabled) {\n pastRef.current.push(preEventSnapshot);\n futureRef.current = [];\n }\n onLayerCommit?.(b.layer.id, committed, prevState);\n }\n return;\n }\n\n // No hit — empty space dispatch, top-to-bottom.\n let pendingCommit: { id: string; next: unknown; prev: unknown } | null = null;\n for (let i = ls.length - 1; i >= 0; i--) {\n const b = ls[i];\n if (!b.layer.onEmptyPointerDown) continue;\n const prevState = b.state;\n let committed: unknown = undefined;\n const gesture = b.layer.onEmptyPointerDown(\n prevState, coords.model, nativeEvent, ctx,\n {\n plot: coords.plot,\n model: coords.model,\n commit(next) {\n committed = next;\n onLayerChange(b.layer.id, next);\n },\n },\n );\n if (gesture) {\n // If onEmptyPointerDown also published a commit (e.g. click-curve\n // insert publishes the new point then drags it), the gesture's\n // startStates already capture the post-insert state; the commit\n // for history is the *pre*-event snapshot, written when the\n // gesture eventually finishes via the gesture-commit path. We\n // override the gesture's startStates so undo restores correctly.\n installGesture(b.layer.id, e, gesture);\n if (committed !== undefined && activeRef.current !== null) {\n (activeRef.current as ActiveGesture).startStates = preEventSnapshot;\n (activeRef.current as ActiveGesture).startSelfState = preEventSnapshot.get(b.layer.id);\n }\n return;\n }\n if (committed !== undefined) {\n pendingCommit = { id: b.layer.id, next: committed, prev: prevState };\n break;\n }\n }\n if (pendingCommit) {\n if (historyEnabled) {\n pastRef.current.push(preEventSnapshot);\n futureRef.current = [];\n }\n onLayerCommit?.(pendingCommit.id, pendingCommit.next, pendingCommit.prev);\n }\n }, [makeCtx, installGesture, onLayerChange, onLayerCommit, historyEnabled, snapshot, layersRef]);\n\n // ── keyboard ───────────────────────────────────────────────────────\n const onSvgKeyDown = useCallback((e: ReactKeyboardEvent<SVGSVGElement>) => {\n const modifiers = readModifiers(e);\n const ctx = makeCtx(modifiers);\n const ls = layersRef.current;\n // History first.\n if (historyEnabled && (e.metaKey || e.ctrlKey)) {\n const k = e.key.toLowerCase();\n if (k === 'z') {\n if (e.shiftKey) redo();\n else undo();\n e.preventDefault();\n return;\n }\n if (k === 'y') { redo(); e.preventDefault(); return; }\n }\n // Then layers (top-to-bottom).\n for (let i = ls.length - 1; i >= 0; i--) {\n const b = ls[i];\n if (!b.layer.onKeyDown) continue;\n const preEventSnapshot = snapshot();\n let committed: unknown = undefined;\n b.layer.onKeyDown(b.state, e.nativeEvent, ctx, {\n commit(next) { committed = next; onLayerChange(b.layer.id, next); },\n });\n if (committed !== undefined) {\n if (historyEnabled) {\n pastRef.current.push(preEventSnapshot);\n futureRef.current = [];\n }\n onLayerCommit?.(b.layer.id, committed, b.state);\n }\n // The layer prevents default on the native event, which the synthetic\n // event's `isDefaultPrevented` does not observe.\n if (e.nativeEvent.defaultPrevented) return;\n }\n }, [historyEnabled, undo, redo, makeCtx, snapshot, onLayerChange, onLayerCommit, layersRef]);\n\n useEffect(() => () => { sessionRef.current?.cancel(); }, []);\n\n // ── render ─────────────────────────────────────────────────────────\n const renderCtxBase: Omit<LayerCtx, 'modifiers'> = useMemo(() => ({\n modelRange,\n plotSize,\n toPlot: (p) => modelToPlot(p, modelRange, plotSize),\n toModel: (p) => plotToModel(p, modelRange, plotSize),\n }), [modelRange, plotSize]);\n\n const cls = [s.root, className].filter(Boolean).join(' ');\n\n return (\n <Plot2D\n ref={plotRef}\n className={cls}\n style={style}\n width={width}\n height={height}\n xRange={xRange}\n yRange={yRange}\n grid={grid}\n axes={axes}\n xTicks={xTicks}\n yTicks={yTicks}\n tabIndex={historyEnabled ? 0 : undefined}\n role=\"group\"\n aria-label={props['aria-label']}\n onPointerDown={onSvgPointerDown}\n onKeyDown={onSvgKeyDown}\n >\n {children}\n {layers.map((b) => {\n const ctx = {\n ...renderCtxBase,\n modifiers: { shift: false, alt: false, meta: false, ctrl: false },\n isActive: activeLayerId === b.layer.id,\n };\n return (\n <g key={b.layer.id} data-layer-id={b.layer.id}>\n {b.layer.render(b.state, ctx)}\n </g>\n );\n })}\n </Plot2D>\n );\n}\n","/**\n * Keyframe layer for LayeredCurveEditor: a value-over-time curve whose shape\n * between two keys is the easing on the later one, with draggable keys and\n * draggable cubic-bezier handles on the selected segment.\n *\n * Distinct from `createFunctionLayer`, which interpolates a spline through\n * its anchors. Here the keys are exact and the easing approximates between\n * them, so the two do not share curve maths.\n */\nimport type { ReactNode } from 'react';\nimport { cubicBezierEasing, resolveEasing, type EasingFn, type Keyframe } from '@weasel-js/core';\nimport { hitTestAnchor, hitTestCurve } from './hitTest';\nimport { handleHalf } from '../../handles';\nimport { SNAP_RADIUS_PX, snapToNearest } from '../../snap';\nimport s from './CurveEditor.module.css';\nimport type {\n CurveLayer, EmptyDownArgs, KeyDownArgs, LayerCtx, LayerGesture, LayerHit, LayerRenderCtx, PlotPoint,\n} from './layerTypes';\n\ntype Bezier = readonly [number, number, number, number];\n\n/** A gesture in flight. The committed keys hold still underneath it. */\nexport type KeyframeDrag =\n | { kind: 'key'; index: number; t: number; value: number }\n | { kind: 'handle'; segment: number; bezier: Bezier };\n\n/**\n * The state a keyframe layer owns, held by the consumer and round-tripped\n * through `LayeredCurveEditor`'s `onLayerChange`.\n */\nexport interface KeyframeLayerState {\n /** Sorted ascending by `t`. */\n keys: readonly Keyframe<number>[];\n selectedKey: number | null;\n /** Index of the key the selected segment runs into. Its bezier handles show. */\n selectedSegment: number | null;\n drag: KeyframeDrag | null;\n}\n\n/** Configuration for {@link createKeyframeLayer}. */\nexport interface KeyframeLayerConfig {\n /** Layer id; default `'keyframes'`. */\n id?: string;\n /** Names the curve in each mark's accessible name. Default `'Curve'`. */\n label?: string;\n /** Formats a key time for accessible names. Default: rounded number. */\n formatX?: (x: number) => string;\n /** Times a dragged key snaps to. Holding alt defeats the snap. */\n snapX?: readonly number[];\n /** Snap reach, in plot pixels. Default 6. */\n snapRadiusPx?: number;\n /** Bounds for a key's time. Default: unbounded. */\n xClamp?: readonly [number, number];\n /** Bounds for a key's value. Default: unbounded. */\n yClamp?: readonly [number, number];\n /** One arrow-key step in model units; shift takes ten. Default: 1% of the\n * plot's range on that axis. */\n step?: { x?: number; y?: number };\n}\n\nconst SAMPLES_PER_SEGMENT = 16;\nconst KEY_HIT_PX = 8;\nconst HANDLE_HIT_PX = 8;\nconst CURVE_HIT_PX = 6;\nconst KEY_HALF = handleHalf('--wzl-handle-size');\nconst HANDLE_RADIUS = 3.5;\nconst SHIFT_MULTIPLIER = 10;\nconst HANDLE_STEP = 0.01;\n\n/** A keyframe layer state with nothing selected and no gesture in flight. */\nexport function keyframeLayerState(keys: readonly Keyframe<number>[]): KeyframeLayerState {\n return { keys, selectedKey: null, selectedSegment: null, drag: null };\n}\n\nfunction clampTo(v: number, range?: readonly [number, number]): number {\n return range ? Math.min(range[1], Math.max(range[0], v)) : v;\n}\n\nfunction bezierOf(key: Keyframe<number> | undefined): Bezier | null {\n const e = key?.easing;\n return typeof e === 'object' && e !== null && 'bezier' in e ? e.bezier : null;\n}\n\nfunction moveKeyTo(\n keys: readonly Keyframe<number>[], index: number, t: number, value: number,\n): { keys: Keyframe<number>[]; selectedKey: number } {\n const moved = { ...keys[index], t, value };\n const rest = keys.filter((_, i) => i !== index);\n const at = rest.findIndex((k) => k.t > t);\n const selectedKey = at === -1 ? rest.length : at;\n rest.splice(selectedKey, 0, moved);\n return { keys: rest, selectedKey };\n}\n\n/**\n * The keys a state's drag would leave behind: a dragged key re-sorted into\n * place, or a dragged handle's control points written onto the key its\n * segment runs into. `selectedKey` follows a moved key to its new index; a\n * key dropped where it started returns the same `keys` array.\n */\nexport function applyKeyframeDrag(\n state: KeyframeLayerState,\n): { keys: readonly Keyframe<number>[]; selectedKey: number | null } {\n const { drag, keys } = state;\n if (!drag) return { keys, selectedKey: state.selectedKey };\n if (drag.kind === 'key') {\n const k = keys[drag.index];\n if (k && k.t === drag.t && k.value === drag.value) return { keys, selectedKey: drag.index };\n return moveKeyTo(keys, drag.index, drag.t, drag.value);\n }\n const next = keys.slice();\n next[drag.segment] = { ...keys[drag.segment], easing: { bezier: drag.bezier } };\n return { keys: next, selectedKey: state.selectedKey };\n}\n\n/**\n * Builds a keyframe layer for `LayeredCurveEditor`. Model x is time and model\n * y is value; each segment is drawn through the easing on the key it runs\n * into. Every key, segment and handle is focusable and named, and the arrow\n * keys move whichever one has focus.\n */\nexport function createKeyframeLayer(cfg: KeyframeLayerConfig = {}): CurveLayer<KeyframeLayerState> {\n const id = cfg.id ?? 'keyframes';\n const label = cfg.label ?? 'Curve';\n const formatX = cfg.formatX ?? ((x: number) => String(Math.round(x)));\n const snapRadiusPx = cfg.snapRadiusPx ?? SNAP_RADIUS_PX;\n\n // A live handle drag is previewed straight from its control points: a\n // fresh spec per pointermove through `resolveEasing` would leave one\n // permanent cache entry per pixel of drag.\n function easingInto(state: KeyframeLayerState, keys: readonly Keyframe<number>[], seg: number): EasingFn {\n const d = state.drag;\n if (d?.kind === 'handle' && d.segment === seg) return cubicBezierEasing(...d.bezier);\n return resolveEasing(keys[seg].easing);\n }\n\n function segmentSamples(state: KeyframeLayerState, keys: readonly Keyframe<number>[], ctx: LayerCtx): PlotPoint[][] {\n const out: PlotPoint[][] = [];\n for (let i = 1; i < keys.length; i++) {\n const a = keys[i - 1];\n const b = keys[i];\n const ease = easingInto(state, keys, i);\n const pts: PlotPoint[] = [];\n for (let j = 0; j <= SAMPLES_PER_SEGMENT; j++) {\n const u = j / SAMPLES_PER_SEGMENT;\n pts.push(ctx.toPlot({ x: a.t + (b.t - a.t) * u, y: a.value + (b.value - a.value) * ease(u) }));\n }\n out.push(pts);\n }\n return out;\n }\n\n function activeBezier(state: KeyframeLayerState): Bezier | null {\n const seg = state.selectedSegment;\n if (seg === null || seg < 1 || seg >= state.keys.length) return null;\n const d = state.drag;\n if (d?.kind === 'handle' && d.segment === seg) return d.bezier;\n return bezierOf(state.keys[seg]);\n }\n\n function handlePoints(state: KeyframeLayerState, bezier: Bezier, ctx: LayerCtx): [PlotPoint, PlotPoint] {\n const a = state.keys[state.selectedSegment! - 1];\n const b = state.keys[state.selectedSegment!];\n const at = (xf: number, yf: number) =>\n ctx.toPlot({ x: a.t + xf * (b.t - a.t), y: a.value + yf * (b.value - a.value) });\n return [at(bezier[0], bezier[1]), at(bezier[2], bezier[3])];\n }\n\n const path = (pts: readonly PlotPoint[]): string =>\n pts.map((p, i) => `${i === 0 ? 'M' : 'L'}${p.x.toFixed(2)},${p.y.toFixed(2)}`).join('');\n\n // ── render ──────────────────────────────────────────────────────────\n function render(state: KeyframeLayerState, ctx: LayerRenderCtx): ReactNode {\n const shown = state.drag?.kind === 'key' ? applyKeyframeDrag(state).keys : state.keys;\n const segments = segmentSamples(state, shown, ctx);\n const curve = segments.flatMap((pts, i) => (i === 0 ? pts : pts.slice(1)));\n const seg = state.selectedSegment;\n const bezier = activeBezier(state);\n const dragIndex = state.drag?.kind === 'key' ? state.drag.index : null;\n\n return (\n <>\n {seg !== null && seg >= 1 && seg < shown.length ? (() => {\n const x0 = ctx.toPlot({ x: shown[seg - 1].t, y: 0 }).x;\n const x1 = ctx.toPlot({ x: shown[seg].t, y: 0 }).x;\n return (\n <rect\n className={s.segmentBand}\n x={Math.min(x0, x1)}\n y={0}\n width={Math.abs(x1 - x0)}\n height={ctx.plotSize.height}\n />\n );\n })() : null}\n {curve.length > 1 ? <path data-curve-element=\"curve\" className={s.curve} d={path(curve)} /> : null}\n {segments.map((pts, i) => (\n <path\n key={`seg-${i + 1}`}\n className={s.segmentTarget}\n d={path(pts)}\n role=\"button\"\n tabIndex={0}\n aria-label={`${label} segment into ${formatX(shown[i + 1].t)}`}\n aria-current={seg === i + 1 ? 'true' : undefined}\n data-segment-index={i + 1}\n />\n ))}\n {bezier ? (() => {\n const [h1, h2] = handlePoints(state, bezier, ctx);\n const a = ctx.toPlot({ x: state.keys[seg! - 1].t, y: state.keys[seg! - 1].value });\n const b = ctx.toPlot({ x: state.keys[seg!].t, y: state.keys[seg!].value });\n return (\n <>\n <line className={s.handleStem} x1={a.x} y1={a.y} x2={h1.x} y2={h1.y} />\n <line className={s.handleStem} x1={b.x} y1={b.y} x2={h2.x} y2={h2.y} />\n {[h1, h2].map((h, i) => (\n <circle\n key={`handle-${i}`}\n className={s.handle}\n cx={h.x}\n cy={h.y}\n r={HANDLE_RADIUS}\n role=\"button\"\n tabIndex={0}\n aria-label={`${label} bezier handle ${i + 1}`}\n data-handle-index={i}\n />\n ))}\n </>\n );\n })() : null}\n {state.keys.map((k, i) => {\n const p = ctx.toPlot({ x: k.t, y: k.value });\n return (\n <rect\n key={`key-${i}`}\n className={s.keyframe}\n x={p.x - KEY_HALF}\n y={p.y - KEY_HALF}\n width={KEY_HALF * 2}\n height={KEY_HALF * 2}\n transform={`rotate(45 ${p.x} ${p.y})`}\n role=\"button\"\n tabIndex={0}\n aria-label={`${label} key at ${formatX(k.t)}`}\n aria-current={state.selectedKey === i ? 'true' : undefined}\n data-keyframe-index={i}\n data-dragging={dragIndex === i ? 'true' : undefined}\n />\n );\n })}\n {state.drag?.kind === 'key' ? (() => {\n const p = ctx.toPlot({ x: state.drag.t, y: state.drag.value });\n return (\n <rect\n aria-hidden=\"true\"\n className={s.keyframeGhost}\n x={p.x - KEY_HALF}\n y={p.y - KEY_HALF}\n width={KEY_HALF * 2}\n height={KEY_HALF * 2}\n transform={`rotate(45 ${p.x} ${p.y})`}\n data-keyframe-ghost=\"\"\n />\n );\n })() : null}\n </>\n );\n }\n\n // ── hit test ────────────────────────────────────────────────────────\n function hitTest(state: KeyframeLayerState, plot: PlotPoint, ctx: LayerCtx): LayerHit | null {\n const bezier = activeBezier(state);\n if (bezier) {\n const h = hitTestAnchor(handlePoints(state, bezier, ctx), plot, HANDLE_HIT_PX);\n if (h) return { kind: 'handle', payload: { handle: h.index } };\n }\n const k = hitTestAnchor(state.keys.map((key) => ctx.toPlot({ x: key.t, y: key.value })), plot, KEY_HIT_PX);\n if (k) return { kind: 'key', payload: { index: k.index } };\n const c = hitTestCurve(segmentSamples(state, state.keys, ctx), plot, CURVE_HIT_PX);\n if (c) return { kind: 'segment', payload: { segment: c.segIdx + 1 } };\n return null;\n }\n\n // ── gestures ────────────────────────────────────────────────────────\n function keyGesture(index: number): LayerGesture<KeyframeLayerState> {\n return {\n onMove(state, model, e, ctx) {\n let t = clampTo(model.x, cfg.xClamp);\n if (cfg.snapX && !e.altKey) {\n const perPx = (ctx.modelRange.xMax - ctx.modelRange.xMin) / ctx.plotSize.width;\n t = clampTo(snapToNearest(t, cfg.snapX, Math.abs(perPx) * snapRadiusPx), cfg.xClamp);\n }\n return { ...state, drag: { kind: 'key', index, t, value: clampTo(model.y, cfg.yClamp) } };\n },\n onCommit(state) { return { ...state, ...applyKeyframeDrag(state), drag: null }; },\n onCancel(state) { return { ...state, drag: null }; },\n };\n }\n\n function handleGesture(segment: number, handle: 0 | 1): LayerGesture<KeyframeLayerState> {\n return {\n onMove(state, model) {\n const a = state.keys[segment - 1];\n const b = state.keys[segment];\n const d = state.drag;\n if (!a || !b || d?.kind !== 'handle') return state;\n const xf = b.t === a.t ? 0 : Math.min(1, Math.max(0, (model.x - a.t) / (b.t - a.t)));\n const yf = b.value === a.value ? 0 : (model.y - a.value) / (b.value - a.value);\n const bezier = [...d.bezier] as [number, number, number, number];\n bezier[handle * 2] = xf;\n bezier[handle * 2 + 1] = yf;\n return { ...state, drag: { kind: 'handle', segment, bezier } };\n },\n onCommit(state) { return { ...state, ...applyKeyframeDrag(state), drag: null }; },\n onCancel(state) { return { ...state, drag: null }; },\n };\n }\n\n function onPointerDown(\n state: KeyframeLayerState,\n hit: LayerHit,\n e: PointerEvent,\n _ctx: LayerCtx,\n extra: EmptyDownArgs<KeyframeLayerState>,\n ): LayerGesture<KeyframeLayerState> | void {\n if (e.button !== 0) return;\n if (hit.kind === 'handle') {\n const bezier = activeBezier(state);\n const segment = state.selectedSegment;\n if (!bezier || segment === null) return;\n const { handle } = hit.payload as { handle: 0 | 1 };\n extra.commit({ ...state, drag: { kind: 'handle', segment, bezier } });\n return handleGesture(segment, handle);\n }\n if (hit.kind === 'key') {\n const { index } = hit.payload as { index: number };\n const k = state.keys[index];\n extra.commit({ ...state, selectedKey: index, drag: { kind: 'key', index, t: k.t, value: k.value } });\n return keyGesture(index);\n }\n if (hit.kind === 'segment') {\n const { segment } = hit.payload as { segment: number };\n extra.commit({ ...state, selectedSegment: segment });\n }\n }\n\n // ── keyboard ────────────────────────────────────────────────────────\n function onKeyDown(\n state: KeyframeLayerState,\n e: KeyboardEvent,\n ctx: LayerCtx,\n extra: KeyDownArgs<KeyframeLayerState>,\n ): void {\n const target = e.target as Element | null;\n if (target?.closest?.('[data-layer-id]')?.getAttribute('data-layer-id') !== id) return;\n const activate = e.key === 'Enter' || e.key === ' ';\n const dx = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0;\n const dy = e.key === 'ArrowUp' ? 1 : e.key === 'ArrowDown' ? -1 : 0;\n const mult = e.shiftKey ? SHIFT_MULTIPLIER : 1;\n\n const keyEl = target.closest('[data-keyframe-index]');\n if (keyEl) {\n const index = Number(keyEl.getAttribute('data-keyframe-index'));\n const k = state.keys[index];\n if (!k) return;\n if (activate) {\n e.preventDefault();\n extra.commit({ ...state, selectedKey: index });\n return;\n }\n if (dx === 0 && dy === 0) return;\n e.preventDefault();\n const m = ctx.modelRange;\n const stepX = (cfg.step?.x ?? Math.abs(m.xMax - m.xMin) / 100) * mult;\n const stepY = (cfg.step?.y ?? Math.abs(m.yMax - m.yMin) / 100) * mult;\n const t = clampTo(k.t + dx * stepX, cfg.xClamp);\n const value = clampTo(k.value + dy * stepY, cfg.yClamp);\n if (t === k.t && value === k.value) return;\n extra.commit({ ...state, ...moveKeyTo(state.keys, index, t, value), drag: null });\n return;\n }\n\n const segEl = target.closest('[data-segment-index]');\n if (segEl && activate) {\n e.preventDefault();\n extra.commit({ ...state, selectedSegment: Number(segEl.getAttribute('data-segment-index')) });\n return;\n }\n\n const handleEl = target.closest('[data-handle-index]');\n const bezier = activeBezier(state);\n if (handleEl && bezier && state.selectedSegment !== null && (dx !== 0 || dy !== 0)) {\n e.preventDefault();\n const h = Number(handleEl.getAttribute('data-handle-index'));\n const next = [...bezier] as [number, number, number, number];\n next[h * 2] = Math.min(1, Math.max(0, next[h * 2] + dx * HANDLE_STEP * mult));\n next[h * 2 + 1] += dy * HANDLE_STEP * mult;\n const drag: KeyframeDrag = { kind: 'handle', segment: state.selectedSegment, bezier: next };\n extra.commit({ ...state, ...applyKeyframeDrag({ ...state, drag }), drag: null });\n }\n }\n\n return { id, render, hitTest, onPointerDown, onKeyDown };\n}\n"],"mappings":";;;;;;;;AAYA,SAAgBS,EACd,GACA,GACA,GAC0B;CAC1B,IAAMC,IAAKC,IAASA,GAChBC,IAA6C;CACjD,KAAK,IAAIC,IAAI,GAAGA,IAAIC,EAAQ,QAAQ,KAAK;EACvC,IAAM,IAAIA,EAAQD,IACZE,IAAK,EAAE,IAAIC,EAAQ,GACnBC,IAAK,EAAE,IAAID,EAAQ,GACnBE,IAAKH,IAAKA,IAAKE,IAAKA;EAC1B,AAAIC,IAAKR,MACLE,MAAS,QAA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AAE,eAAe,GACjBgF,EAAM,OAAO;IAAE,GAAG1C;IAAO,iBAAiB,OAAOmD,EAAM,aAAa,oBAAoB,CAAC;GAAE,CAAC;GAC5F;EACF;EAEA,IAAMC,IAAWR,EAAO,QAAQ,qBAAqB,GAC/CtB,IAASJ,EAAalB,CAAK;EACjC,IAAIoD,KAAY9B,KAAUtB,EAAM,oBAAoB,SAAS1H,MAAO,KAAKE,MAAO,IAAI;GAClF,EAAE,eAAe;GACjB,IAAMkE,IAAI,OAAO0G,EAAS,aAAa,mBAAmB,CAAC,GACrDhH,IAAO,CAAC,GAAGkF,CAAM;GAEvB,AADA,EAAK5E,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,IAAI,GAAGN,EAAKM,IAAI,KAAKpE,IAAK2G,IAAc6D,CAAI,CAAC,GAC5E,EAAKpG,IAAI,IAAI,MAAMlE,IAAKyG,IAAc6D;GACtC,IAAM7C,IAAqB;IAAE,MAAM;IAAU,SAASD,EAAM;IAAiB,QAAQ5D;GAAK;GAC1F,EAAM,OAAO;IAAE,GAAG4D;IAAO,GAAGD,EAAkB;KAAE,GAAGC;KAAO;IAAK,CAAC;IAAG,MAAM;GAAK,CAAC;EACjF;CACF;CAEA,OAAO;EAAE;EAAI;EAAQ;EAAS;EAAe;CAAU;AACzD"}
@@ -0,0 +1,15 @@
1
+ var e = {
2
+ field: "_field_1rw27_5",
3
+ label: "_label_1rw27_13",
4
+ hint: "_hint_1rw27_20",
5
+ error: "_error_1rw27_26",
6
+ row: "_row_1rw27_32",
7
+ control: "_control_1rw27_46",
8
+ fit: "_fit_1rw27_58",
9
+ frame: "_frame_1rw27_58",
10
+ below: "_below_1rw27_59"
11
+ };
12
+ //#endregion
13
+ export { e as t };
14
+
15
+ //# sourceMappingURL=field.module-B27pWv0i.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"field.module-Bh7BTKMh.js","names":["field_module_default"],"sources":["../../src/components/field.module.css"],"sourcesContent":["/* The form-row layout and the boxed frame a value sits in. Field and RadioGroup\n use the layout (`field`, `row`, `label`, `hint`, `error`); Input, Select,\n NumberField, UnitField and ComboBox add `control` to it and draw their value\n in a `frame`, which MenuButton's trigger and ListEditor's inputs wear too. */\n.field {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-2);\n font-family: var(--wzl-font-ui);\n color: var(--wzl-fg);\n}\n\n.label {\n font-size: var(--wzl-font-size-sm);\n font-weight: var(--wzl-font-weight-medium);\n color: var(--wzl-fg);\n cursor: default;\n}\n\n.hint {\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-subtle);\n line-height: 1.4;\n}\n\n.error {\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-danger);\n line-height: 1.4;\n}\n\n.row {\n flex-direction: row;\n align-items: center;\n gap: var(--wzl-space-4);\n}\n\n.row .label {\n flex: 1;\n min-width: 0;\n}\n\n/* A control fills its row. Beside its label, the label keeps its own width and\n the frame takes the rest; description and error (`below`) wrap onto a line of\n their own. A `fit` control keeps its own width instead. */\n.control {\n width: 100%;\n min-width: 0;\n}\n\n.control.row {\n align-items: center;\n flex-wrap: wrap;\n row-gap: var(--wzl-space-2);\n}\n\n.control.row .label { flex: 0 0 auto; }\n.control.row:not(.fit) .frame { flex: 1 1 0; min-width: 0; }\n.control.row .below { flex-basis: 100%; }\n\n.fit {\n width: auto;\n max-width: 100%;\n align-items: flex-start;\n}\n\n/* A control restyling part of the frame sets the matching `--_frame-*`\n property rather than restating the declaration, so no rule here ties with\n one of its own on specificity and neither stylesheet has to load first. */\n.frame {\n height: var(--_frame-h, var(--wzl-field-h, var(--wzl-control-h)));\n background: var(--_frame-bg, var(--wzl-input-surface, var(--wzl-surface-sunken)));\n border: var(--_frame-border, 1px solid var(--wzl-border));\n border-radius: var(--wzl-radius-sm);\n color: var(--_frame-fg, var(--wzl-fg));\n font-family: var(--wzl-font-ui);\n font-size: var(--wzl-font-size);\n line-height: 1;\n transition: border-color var(--wzl-motion-fast), box-shadow var(--wzl-motion-fast);\n}\n\n/* A frame holding a text box rings whenever it has focus; a button frame only\n for keyboard focus, which React Aria marks. */\n.frame:focus-within:not(button),\n.frame[data-focus-visible] {\n border-color: var(--_frame-focus-border, var(--wzl-focus-ring));\n box-shadow: var(--_frame-focus-shadow, 0 0 0 1px var(--wzl-focus-ring));\n outline: var(--_frame-focus-outline, none);\n}\n\n.field[data-invalid] .frame {\n border-color: var(--wzl-danger);\n}\n\n.field[data-disabled] .frame,\n.frame[data-disabled] {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.frame input {\n flex: 1;\n min-width: 0;\n background: transparent;\n border: none;\n outline: none;\n color: inherit;\n font: inherit;\n}\n\n.frame input::placeholder {\n color: var(--wzl-fg-subtle);\n}\n"],"mappings":""}
1
+ {"version":3,"file":"field.module-B27pWv0i.js","names":["field_module_default"],"sources":["../../src/components/field.module.css"],"sourcesContent":["/* The form-row layout and the boxed frame a value sits in. Field and RadioGroup\n use the layout (`field`, `row`, `label`, `hint`, `error`); Input, Select,\n NumberField, UnitField and ComboBox add `control` to it and draw their value\n in a `frame`, which MenuButton's trigger and ListEditor's inputs wear too. */\n.field {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-2);\n font-family: var(--wzl-font-ui);\n color: var(--wzl-fg);\n}\n\n.label {\n font-size: var(--wzl-font-size-sm);\n font-weight: var(--wzl-font-weight-medium);\n color: var(--wzl-fg);\n cursor: default;\n}\n\n.hint {\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-subtle);\n line-height: 1.4;\n}\n\n.error {\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-danger);\n line-height: 1.4;\n}\n\n.row {\n flex-direction: row;\n align-items: center;\n gap: var(--wzl-space-4);\n}\n\n.row .label {\n flex: 1;\n min-width: 0;\n}\n\n/* A control fills its row. Beside its label, the label keeps its own width and\n the frame takes the rest; description and error (`below`) wrap onto a line of\n their own. A `fit` control keeps its own width instead. */\n.control {\n width: 100%;\n min-width: 0;\n}\n\n.control.row {\n align-items: center;\n flex-wrap: wrap;\n row-gap: var(--wzl-space-2);\n}\n\n.control.row .label { flex: 0 0 auto; }\n.control.row:not(.fit) .frame { flex: 1 1 0; min-width: 0; }\n.control.row .below { flex-basis: 100%; }\n\n.fit {\n width: auto;\n max-width: 100%;\n align-items: flex-start;\n}\n\n/* A control restyling part of the frame sets the matching `--_frame-*`\n property rather than restating the declaration, so no rule here ties with\n one of its own on specificity and neither stylesheet has to load first. */\n.frame {\n height: var(--_frame-h, var(--wzl-field-h, var(--wzl-control-h)));\n background: var(--_frame-bg, var(--wzl-input-surface, var(--wzl-surface-sunken)));\n border: var(--_frame-border, 1px solid var(--wzl-border));\n border-radius: var(--wzl-radius-sm);\n color: var(--_frame-fg, var(--wzl-fg));\n font-size: var(--wzl-font-size);\n line-height: 1;\n transition: border-color var(--wzl-motion-fast), box-shadow var(--wzl-motion-fast);\n}\n\n/* The face a frame falls back to, beneath any class: NumberField composes the\n numeric face onto its frame, and a tie here would go to whichever sheet loaded last. */\n:where(.frame) {\n font-family: var(--wzl-font-ui);\n}\n\n/* A frame holding a text box rings whenever it has focus; a button frame only\n for keyboard focus, which React Aria marks. */\n.frame:focus-within:not(button),\n.frame[data-focus-visible] {\n border-color: var(--_frame-focus-border, var(--wzl-focus-ring));\n box-shadow: var(--_frame-focus-shadow, 0 0 0 1px var(--wzl-focus-ring));\n outline: var(--_frame-focus-outline, none);\n}\n\n.field[data-invalid] .frame {\n border-color: var(--wzl-danger);\n}\n\n.field[data-disabled] .frame,\n.frame[data-disabled] {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.frame input {\n flex: 1;\n min-width: 0;\n background: transparent;\n border: none;\n outline: none;\n color: inherit;\n font: inherit;\n}\n\n.frame input::placeholder {\n color: var(--wzl-fg-subtle);\n}\n"],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  import { a as e, t } from "./Icon--B1ME-6c.js";
2
- import { r as n, t as r } from "./PropertyField-CV_Gw57S.js";
2
+ import { r as n, t as r } from "./PropertyField-PMrqBA0n.js";
3
3
  import { t as i } from "./ToggleBar-Z2jZiguF.js";
4
4
  import { t as a } from "./prefField-BE_Ytr2H.js";
5
5
  import { MIXED as o } from "@weasel-js/core";
@@ -383,4 +383,4 @@ function O(e) {
383
383
  //#endregion
384
384
  export { x as a, C as c, p as d, d as f, w as i, E as l, D as n, O as o, b as r, T as s, o as t, h as u };
385
385
 
386
- //# sourceMappingURL=model-B1-gMBIW.js.map
386
+ //# sourceMappingURL=model-B6zuQg6b.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-B1-gMBIW.js","names":["s","Fragment","ICON_PATHS","drawnGlyph","PropertyControl","ToggleBar","prefFieldProps","Fragment$1","SelectionPanel_module_default","isFlagCell","cell","leaf","renderers","renderCells","out","i","cells","content","j","run","c","FlagBar","flags","perNodeState","on","f","field","now","next","renderBuiltin","ctx","pref","ObjectLeaf","siblingPath","ariaLabel","settledOnly","selectionKey","nested","dot","path","key","siblings","held","eachObject","v","allGrouped","child","rowsOf","isRow","pending","flush","prev","block","children","labeled","inner","indent","childPath","update","base","fn","_dropped","rest","childCtx","o","custom","rendered","Icon","entry","rows","classifyKind","node","routing","isGroup","n","flatten","sections","untitled","collect","group","into","schema","leaves","pairRows","item","pair","effectiveSections","uniq","kinds","byName","entries","schemas","k","s","first","flatFirst","leafKey","l","restKeys","r","keep","set","section","row","nodeValueAt","segments","head","cursor","setAtPath","root","value","aggregateValue","nodes","MIXED","kindBreakdown","counts"],"sources":["../../src/components/SelectionPanel/SelectionPanel.module.css","../../src/components/SelectionPanel/renderLeaf.tsx","../../src/components/SelectionPanel/model.ts"],"sourcesContent":[".root {\n display: flex;\n flex-direction: column;\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg);\n}\n\n.header {\n display: flex;\n align-items: baseline;\n gap: var(--wzl-space-4);\n padding: var(--wzl-space-4) 0;\n border-block-end: 1px solid var(--wzl-border);\n}\n\n.kind {\n font-weight: var(--wzl-font-weight-bold);\n font-size: var(--wzl-font-size);\n}\n\n.breakdown {\n font-size: var(--wzl-font-size-sm);\n opacity: 0.6;\n}\n\n.section {\n padding: var(--wzl-space-3) 0 var(--wzl-space-4);\n border-block-end: 1px solid var(--wzl-border);\n}\n\n.section:last-child {\n border-block-end: none;\n}\n\n.sectionTitle {\n margin: 0 0 var(--wzl-space-3);\n font-size: var(--wzl-font-size-xs);\n font-weight: var(--wzl-font-weight-bold);\n text-transform: uppercase;\n letter-spacing: 0.06em;\n opacity: 0.55;\n}\n\n.row {\n display: grid;\n grid-template-columns: 64px 1fr;\n gap: var(--wzl-space-3);\n align-items: center;\n margin-block-end: 5px;\n}\n\n.rowLabel {\n opacity: 0.75;\n}\n\n.rowControls {\n display: flex;\n flex-wrap: wrap;\n gap: var(--wzl-space-3);\n align-items: center;\n min-inline-size: 0;\n}\n\n/* Glyph plus its control, held together so the pair row wraps between\n fields rather than between a field and the icon naming it. */\n.namedField {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-2);\n min-inline-size: 0;\n}\n\n.namedField > svg {\n flex: none;\n opacity: 0.75;\n}\n\n.blockRow {\n margin-block-end: 5px;\n}\n\n/* Fields paired into one row split it evenly, the way Position's x/y do. */\n.rowControls > .namedField {\n flex: 1 1 0;\n}\n\n/* Except around a segmented bar, which is sized by its segments: an equal\n share of the row is wider than the buttons want to be. */\n.rowControls > .namedField:has(> .toggle) {\n flex: 0 1 auto;\n}\n\n.rowControls > * {\n flex: 1;\n min-inline-size: 0;\n}\n\n/* Bars sharing a row split the leftover between them, so the gap stays fixed\n and the width lands on the segments. A bar with the row to itself is sized\n by its segments instead — a third of 240px is a plate, not a button. */\n.rowControls > .toggle {\n flex: 1 1 auto;\n}\n\n.rowControls > .toggle:only-child {\n flex: 0 1 auto;\n}\n\n/* A flag bar is sized by its glyphs rather than by a share of the row: an\n even split would fling one-letter segments to the margins. */\n.rowControls > .flagToggle {\n flex: 0 0 auto;\n}\n\n.number :global(input),\n.select {\n font-size: var(--wzl-font-size-sm);\n}\n\n.unrenderable {\n font-size: var(--wzl-font-size-sm);\n opacity: 0.5;\n font-style: italic;\n}\n\n/* A `block` leaf that renders its own rows — an object leaf's fields. */\n.objectLeaf {\n margin-block: var(--wzl-space-4) var(--wzl-space-2);\n}\n\n.objectLeaf .sectionTitle {\n margin-block: 7px 5px;\n}\n\n/* Fields under a heading inside an object read as belonging to it. */\n.objectGroup {\n padding-inline-start: var(--wzl-space-4);\n border-inline-start: 1px solid var(--wzl-border);\n margin-block-end: var(--wzl-space-2);\n}\n\n/* The slider's track; the row only says how it shares the space. */\n.slider {\n flex: 1;\n}\n","/**\n * A selection's leaves as cells: one `ToolPrefLeaf` and its aggregated value\n * in, one rendered cell out, plus the run logic that turns a row of paired\n * toggles into a single segmented bar and the rows of an object leaf.\n *\n * The control itself is `PropertyControl`'s, through `prefFieldProps`; what\n * is decided here is how a selection surface sizes and composes it.\n * `ToolOptionsBar` renders a tool's options through the same functions.\n */\nimport { Fragment, type ReactNode } from 'react';\nimport type {\n ToolPrefBoolean,\n ToolPrefGroup,\n ToolPrefLeaf,\n ToolPrefObject,\n} from '@weasel-js/core';\nimport { prefFieldProps, type PrefFieldState } from '../Prefs/prefField';\nimport { drawnGlyph, PropertyControl, type PropertyBooleanFieldProps } from '../Properties/PropertyField';\nimport { ToggleBar } from '../ToggleBar';\nimport { Icon } from '../../icons/Icon';\nimport { ICON_PATHS, type IconName } from '../../icons/paths';\nimport s from './SelectionPanel.module.css';\n\n\n/** What a {@link PropertyRenderer} is given for the property it is rendering. */\nexport interface PropertyRenderContext {\n /** Dotted node path of the leaf (`pose.x`, `data.fill`). */\n path: string;\n /** The schema leaf. App renderers narrow it to their own kind shape. */\n pref: ToolPrefLeaf;\n /** Aggregated value across the selection; `undefined` when mixed or unset. */\n value: unknown;\n /** True when selected nodes disagree at this path. */\n mixed: boolean;\n /**\n * True when the nodes agree and what they agree on is nothing — the field\n * is absent, and whatever paints comes from a fallback further down.\n *\n * Distinct from `mixed`, and both leave `value` undefined. A control must\n * not substitute its schema default here: doing so shows a value the node\n * does not hold, and the next edit writes that invention back.\n */\n unset: boolean;\n /**\n * The fields of the object this leaf is a field of — `undefined` for a\n * top-level leaf, and for a field of an object the node does not hold.\n *\n * What a control needs when its own field doesn't carry the whole answer:\n * a stroke's dash lengths are multiples of the stroke's width, so reading\n * the array as a style takes both.\n */\n siblings?: Record<string, unknown>;\n /** The value each selected node holds at this path, in selection order —\n * what `value` aggregates, and what a mixed selection still has. */\n each: readonly unknown[];\n /**\n * For a field of an object leaf, each node's own object (parallel to\n * `each`), which is still there when the nodes' objects differ and\n * `siblings` is not.\n */\n eachSiblings?: readonly (Record<string, unknown> | undefined)[];\n /** Commit a value — fans out to every selected node in one undo step. */\n setValue: (value: unknown) => void;\n /**\n * Commit a value derived from what each node holds at this path, in one undo\n * step. What `setValue` cannot do across a selection whose nodes differ: a\n * field of an object leaf has to land in each node's own object, not in one\n * object written over all of them. `siblings` is that node's object, for a\n * field of an object leaf.\n */\n update: (fn: (prev: unknown, siblings?: Record<string, unknown>) => unknown) => void;\n /**\n * The aggregated value at another node path — what `value` and `mixed` are\n * for this leaf's own path, for any path.\n *\n * A control whose subject spans more than one field needs it: a font picker\n * reporting which variant will actually paint has to read the node's weight\n * and style. Reading it off `value` is impossible — a leaf is handed one\n * field.\n */\n valueAt: (path: string) => { value: unknown; mixed: boolean };\n /**\n * The ids of the nodes the values were read from, joined. It changes exactly\n * when the selection does, so a control holding scratch that belongs to one\n * selection can key on it and be remounted rather than carry it to the next.\n * Absent where the values come from no selection, as in a tool options bar.\n */\n selectionKey?: string;\n}\n\n/**\n * Renders the control for one property across the whole selection.\n * Returning `null` collapses the leaf.\n */\nexport type PropertyRenderer = (ctx: PropertyRenderContext) => ReactNode;\n\n\n/**\n * One leaf with its context built but nothing rendered yet.\n *\n * Deferring the render is what lets a run of sibling flags become one bar:\n * whether a leaf joins its neighbors is a fact about the run, which no leaf\n * rendering itself can see.\n */\nexport interface LeafCell {\n key: string;\n leaf: ToolPrefLeaf;\n ctx: PropertyRenderContext;\n /** The accessible name this leaf's control carries — qualified by the row's\n * pair where the row holds more than one leaf. */\n ariaLabel: string;\n /** Renders the leaf on its own, chrome and all. */\n render: () => ReactNode;\n}\n\n/** A cell's content, once the run it belongs to has been decided. */\nexport interface RenderedCell {\n key: string;\n /** The leaf that names the cell — the run's first, for a flag bar. */\n leaf: ToolPrefLeaf;\n block: boolean;\n content: ReactNode;\n}\n\n/**\n * True for a leaf that can join a flag bar: a paired toggle boolean the\n * consumer has not claimed with a renderer of its own.\n */\nexport function isFlagCell(cell: LeafCell, renderers?: Record<string, PropertyRenderer>): boolean {\n const { leaf } = cell;\n return (\n leaf.kind === 'boolean' &&\n (leaf as ToolPrefBoolean).control === 'toggle' &&\n leaf.pair !== undefined &&\n renderers?.[cell.ctx.path] === undefined &&\n renderers?.[leaf.kind] === undefined\n );\n}\n\n/**\n * Renders a row's cells, collapsing each run of adjacent same-`pair` toggle\n * booleans into one segmented bar — the idiom the enum toggle a row away\n * already uses, rather than one detached pill per flag.\n */\nexport function renderCells(\n cells: readonly LeafCell[],\n renderers?: Record<string, PropertyRenderer>,\n): RenderedCell[] {\n const out: RenderedCell[] = [];\n for (let i = 0; i < cells.length; ) {\n const cell = cells[i];\n if (!isFlagCell(cell, renderers)) {\n const content = cell.render();\n if (content != null) {\n out.push({ key: cell.key, leaf: cell.leaf, block: cell.leaf.block === true, content });\n }\n i += 1;\n continue;\n }\n let j = i + 1;\n while (\n j < cells.length &&\n isFlagCell(cells[j], renderers) &&\n cells[j].leaf.pair === cell.leaf.pair\n ) {\n j += 1;\n }\n const run = cells.slice(i, j);\n out.push({\n key: cell.key,\n leaf: cell.leaf,\n block: run.every((c) => c.leaf.block === true),\n content: <FlagBar run={run} ariaLabel={cell.leaf.pair as string} />,\n });\n i = j;\n }\n return out;\n}\n\n/**\n * A run of paired boolean flags as one multi-select bar — U / S / O, the way\n * every text editor draws them.\n */\nfunction FlagBar({ run, ariaLabel }: { run: readonly LeafCell[]; ariaLabel: string }): ReactNode {\n // Each flag through the same field props a lone one gets, so an `encoding`\n // (Italic stored as `fontStyle`) reads and writes the same way in a bar.\n const flags = run.map((c) => {\n const field = prefFieldProps(c.leaf, {\n value: c.ctx.value,\n mixed: c.ctx.mixed,\n unset: c.ctx.unset,\n siblings: c.ctx.siblings,\n setValue: c.ctx.setValue,\n ...perNodeState(c.ctx),\n }) as PropertyBooleanFieldProps;\n return { cell: c, field };\n });\n const on = flags.filter((f) => !f.field.mixed && f.field.value === true).map((f) => f.cell.key);\n return (\n <ToggleBar<string>\n mode=\"multiple\"\n size=\"sm\"\n variant=\"flat\"\n className={s.flagToggle}\n ariaLabel={ariaLabel}\n items={flags.map(({ cell, field }) => ({\n value: cell.key,\n label: field.glyph ?? cell.leaf.name.slice(0, 1),\n ariaLabel: cell.ariaLabel,\n tooltip: drawnGlyph(field.glyph) === undefined ? undefined : cell.leaf.name,\n }))}\n value={on}\n // Each flag owns its own path, so only the segment that moved is\n // written — committing the run would write two fields nobody touched,\n // and inside an object leaf would fabricate values for the other two.\n mixedValues={flags.filter((f) => f.field.mixed).map((f) => f.cell.key)}\n onChange={(next) => {\n for (const { cell, field } of flags) {\n const now = next.includes(cell.key);\n if (now !== on.includes(cell.key)) field.onChange(now);\n }\n }}\n />\n );\n}\n\nexport function renderBuiltin(\n ctx: PropertyRenderContext,\n ariaLabel: string,\n renderers?: Record<string, PropertyRenderer>,\n /** Identifies the current selection, so a control holding per-selection\n * scratch (the paint kind memory) is remounted rather than carried over. */\n selectionKey = '',\n /** True for a field of an object leaf. Such a field writes itself into its\n * parent, so it can only hold values its parent's type permits — which is\n * what rules \"none\" out for a nested paint. */\n nested = false,\n): ReactNode {\n const { pref, value, mixed, unset, setValue } = ctx;\n if (pref.kind === 'object') {\n // One value with fields hanging off it. Each child writes the parent\n // whole, so a field is never set on a half-built object.\n return <ObjectLeaf ctx={ctx} renderers={renderers} selectionKey={selectionKey} />;\n }\n const field = prefFieldProps(pref, {\n value,\n mixed,\n unset,\n siblings: ctx.siblings,\n setValue,\n ...perNodeState(ctx),\n // The font pickers read the rest of the font from the leaves beside\n // them: the family's substitution probe runs at the weight and style\n // that will paint, and a weight lists what its family has. A mixed\n // selection has no single one; the probe falls back to 400/normal there.\n fontVariant: {\n weight: ctx.valueAt(siblingPath(ctx.path, 'fontWeight')).value,\n style: ctx.valueAt(siblingPath(ctx.path, 'fontStyle')).value,\n },\n fontFamily: ctx.valueAt(siblingPath(ctx.path, 'fontFamily')).value,\n });\n if (field === null) {\n return <span className={s.unrenderable}>({pref.kind}: no renderer)</span>;\n }\n switch (field.kind) {\n case 'boolean':\n // A panel's flag is a switch unless it asks otherwise.\n return (\n <PropertyControl\n {...field}\n name={ariaLabel}\n control={field.control ?? 'switch'}\n className={field.control === 'toggle' ? s.flagToggle : undefined}\n />\n );\n case 'number':\n return (\n <PropertyControl\n {...field}\n name={ariaLabel}\n className={field.control === 'slider' ? s.slider : s.number}\n // A typed number writes once it is entered, as text does; a slider\n // writes as it moves.\n onInput={field.control === 'slider' ? field.onInput : settledOnly}\n />\n );\n case 'string':\n // Settled values only: a live write per keystroke would be one undo\n // step per character.\n return <PropertyControl {...field} name={ariaLabel} onInput={settledOnly} />;\n case 'enum':\n return (\n <PropertyControl\n {...field}\n name={ariaLabel}\n // A clearable toggle is a set of exclusive flags, and sits beside\n // other flags sized the way they are.\n className={\n field.control === 'toggle'\n ? field.onClear ? s.flagToggle : s.toggle\n : field.control === 'radio' ? undefined : s.select\n }\n />\n );\n case 'font-family':\n case 'font-weight':\n return <PropertyControl {...field} name={ariaLabel} className={s.select} />;\n case 'paint':\n return (\n <PropertyControl\n {...field}\n name={ariaLabel}\n // Per-kind switch memory is scratch for one selection; carrying it\n // across would recall the previous node's gradient.\n key={selectionKey}\n control=\"inline\"\n // A nested paint writes one field of its parent, and no kit paint\n // field is optional — `Stroke.paint` is required. Removing the\n // whole parent is a different edit than repainting it, so the\n // control must not offer one as the other.\n allowNone={!nested}\n />\n );\n case 'color':\n // One write per gesture, not one per step of the picker.\n return <PropertyControl {...field} name={ariaLabel} onInput={settledOnly} />;\n }\n}\n\nconst settledOnly = (): void => {};\n\n/** The dotted path of the leaf `key` beside the one at `path`. */\nfunction siblingPath(path: string, key: string): string {\n const dot = path.lastIndexOf('.');\n return dot < 0 ? key : `${path.slice(0, dot + 1)}${key}`;\n}\n\n/** What an `encoding` needs to read and write each node against its own\n * object — nothing for a leaf that is not a field of one. */\nfunction perNodeState(ctx: PropertyRenderContext): Pick<PrefFieldState, 'perNode' | 'update'> {\n if (ctx.eachSiblings === undefined) return {};\n const siblings = ctx.eachSiblings;\n return {\n perNode: ctx.each.map((value, i) => ({ value, siblings: siblings[i] })),\n update: ctx.update,\n };\n}\n\n/**\n * Renders an object leaf: a titled block whose rows are the object's own\n * fields. A child's edit commits the parent object, never the child's path —\n * writing into a path whose value is not an object yet would corrupt it.\n */\n/** One labeled row inside an object leaf; `pair` merges adjacent fields into\n * it, exactly as the section rows merge theirs. */\ninterface ObjectRow {\n key: string;\n pair?: string;\n label: string;\n title?: string;\n /** Every field in the row brought its own chrome, so the row drops the\n * label column and spans the block. One unlabeled field in an otherwise\n * labeled pair would leave the row named after half of itself. */\n block: boolean;\n controls: ReactNode[];\n}\n\n/**\n * Renders an object leaf: the object's own fields, as rows. A child's edit\n * commits the parent object, never the child's path — writing into a path\n * whose value is not an object yet would corrupt it.\n */\nfunction ObjectLeaf({\n ctx,\n renderers,\n selectionKey = '',\n}: {\n ctx: PropertyRenderContext;\n renderers?: Record<string, PropertyRenderer>;\n selectionKey?: string;\n}): ReactNode {\n const pref = ctx.pref as ToolPrefObject;\n const held = typeof ctx.value === 'object' && ctx.value !== null\n ? (ctx.value as Record<string, unknown>)\n : undefined;\n const eachObject = ctx.each.map((v) =>\n typeof v === 'object' && v !== null ? (v as Record<string, unknown>) : undefined,\n );\n\n // A value whose fields are entirely grouped is titled by those groups — its\n // own heading would stack onto the first one and name nothing new.\n const allGrouped = Object.values(pref.children).every((child) => !('kind' in child));\n\n // `indent` is false when nothing visible sits above these rows: depth is\n // drawn only where a label marks it.\n const rowsOf = (\n children: Record<string, ToolPrefLeaf | ToolPrefGroup>,\n indent: boolean,\n ): ReactNode[] => {\n const out: (ReactNode | ObjectRow)[] = [];\n const isRow = (v: ReactNode | ObjectRow): v is ObjectRow =>\n typeof v === 'object' && v !== null && 'controls' in v;\n\n // Cells accumulate unrendered so a run of adjacent same-`pair` flags can\n // be seen as a run before any of them draws; a group heading between two\n // fields ends the run, exactly as it ends a paired row.\n let pending: LeafCell[] = [];\n const flush = (): void => {\n for (const { key, leaf, block, content } of renderCells(pending, renderers)) {\n const prev = out[out.length - 1];\n if (leaf.pair !== undefined && isRow(prev) && prev.pair === leaf.pair) {\n prev.controls.push(<Fragment key={key}>{content}</Fragment>);\n prev.block &&= block;\n continue;\n }\n out.push({\n key,\n pair: leaf.pair,\n label: leaf.pair ?? leaf.name,\n title: leaf.description,\n block,\n controls: [<Fragment key={key}>{content}</Fragment>],\n });\n }\n pending = [];\n };\n\n for (const [key, child] of Object.entries(children)) {\n // A group among the children organises the fields under a heading\n // without contributing to the path — the rule group keys follow at the\n // top level.\n if (!('kind' in child)) {\n const labeled = child.name !== '';\n const inner = rowsOf(child.children, labeled);\n if (inner.length === 0) continue;\n flush();\n out.push(\n <div key={`group:${key}`} className={labeled && indent ? s.objectGroup : undefined}>\n {labeled && <h5 className={s.sectionTitle}>{child.name}</h5>}\n {inner}\n </div>,\n );\n continue;\n }\n const childPath = `${ctx.path}.${key}`;\n // Nodes whose objects differ still agree or disagree field by field: two\n // styles at different sizes are both upright, and saying \"mixed\" for\n // every field of them hides that.\n const field = ctx.mixed ? ctx.valueAt(childPath) : { value: held?.[key], mixed: false };\n // Each node's own object, with this one field changed. Deriving it per\n // node is what keeps a multi-selection edit from writing one node's\n // object over all the others.\n const update = (fn: (prev: unknown, siblings?: Record<string, unknown>) => unknown): void =>\n ctx.update((prev) => {\n // The node holds no object yet, so writing one field has to\n // materialize the rest: the leaf's `default` is what a complete\n // value looks like. Starting from `{}` instead committed the one\n // field on its own — a `data.stroke` of `{ width: 2 }` with no\n // `paint`, which the type forbids and the painter threw on, taking\n // the whole frame and the visible document with it.\n const base: Record<string, unknown> =\n typeof prev === 'object' && prev !== null\n ? (prev as Record<string, unknown>)\n : (pref.fromScalar?.(prev)\n ?? (typeof pref.default === 'object' && pref.default !== null\n ? { ...(pref.default as Record<string, unknown>) }\n : {}));\n const v = fn(base[key], base);\n if (v === undefined) {\n // A field written as absent is absent — leaving the key holding\n // `undefined` says the object has a dash of nothing.\n const { [key]: _dropped, ...rest } = base;\n return rest;\n }\n return { ...base, [key]: v };\n });\n const childCtx: PropertyRenderContext = {\n path: childPath,\n pref: child,\n value: field.mixed ? undefined : field.value,\n mixed: field.mixed,\n // A field of an object the node does not hold is unset, and so is one\n // the object omits — `data.stroke` absent leaves every stroke field\n // with nothing behind it, not with the schema's defaults.\n unset: !field.mixed && field.value === undefined,\n siblings: held,\n each: eachObject.map((o) => o?.[key]),\n eachSiblings: eachObject,\n valueAt: ctx.valueAt,\n selectionKey: ctx.selectionKey,\n update,\n setValue: (v) => update(() => v),\n };\n pending.push({\n key: childPath,\n leaf: child,\n ctx: childCtx,\n ariaLabel: child.name,\n render: () => {\n const custom = renderers?.[childPath] ?? renderers?.[child.kind];\n const rendered = custom\n ? custom(childCtx)\n : renderBuiltin(childCtx, child.name, renderers, selectionKey, true);\n if (rendered == null) return null;\n // Neither a paired row nor a block one gives a field its own label\n // column, so the glyph is all that names it on screen. The control\n // already carries `name` as its accessible name, which leaves the\n // glyph decorative.\n const unlabeled = child.pair !== undefined || child.block === true;\n const glyph = unlabeled && child.icon && child.icon in ICON_PATHS;\n if (!glyph) return rendered;\n return (\n <span className={s.namedField}>\n <Icon name={child.icon as IconName} size={14} />\n {rendered}\n </span>\n );\n },\n });\n }\n flush();\n return out.map((entry) =>\n typeof entry === 'object' && entry !== null && 'controls' in entry ? (\n entry.block ? (\n <div key={entry.key} className={`${s.rowControls} ${s.blockRow}`} title={entry.title}>\n {entry.controls}\n </div>\n ) : (\n <div key={entry.key} className={s.row}>\n <span className={s.rowLabel} title={entry.title}>{entry.label}</span>\n <span className={s.rowControls}>{entry.controls}</span>\n </div>\n )\n ) : (\n entry\n ),\n );\n };\n\n const rows = rowsOf(pref.children, !allGrouped);\n if (rows.length === 0) return null;\n return (\n <div className={s.objectLeaf}>\n {!allGrouped && <h4 className={s.sectionTitle}>{pref.name}</h4>}\n {rows}\n </div>\n );\n}\n","// Pure selection→panel derivations for SelectionPanel. Kept free of\n// React so intersection/aggregation semantics are unit-testable.\n//\n// Path convention (see core `NodePropertiesEntry`): a leaf's OWN KEY in\n// the schema is its node path — a dotted path of any depth rooted at\n// `pose` or `data` (`pose.x`, `data.fill`, `data.style.fontSize`). Group\n// keys are organizational only.\n\nimport {\n MIXED,\n type Mixed,\n type NodePropertiesEntry,\n type NodeRoutingEntry,\n type SceneNode,\n type ToolPrefGroup,\n type ToolPrefLeaf,\n} from '@weasel-js/core';\n\n// Re-exported under its existing public name here: the kit-wide \"these\n// values disagree\" sentinel (`@weasel-js/core`'s `MIXED`) also covers\n// multi-node aggregation, so this panel doesn't get its own symbol.\nexport { MIXED };\nexport type { Mixed };\n\nexport type AnyNode = SceneNode<unknown, string, unknown>;\n\n/**\n * One editable property in a {@link SelectionPanel}, paired with the dotted\n * node path it reads and writes.\n */\nexport interface PanelLeaf {\n /** Dotted node path — the leaf's key in the schema. */\n path: string;\n leaf: ToolPrefLeaf;\n}\n\n/**\n * One labeled row of a panel section. Holds several leaves when the schema\n * paired them.\n */\nexport interface PanelRow {\n label: string;\n leaves: PanelLeaf[];\n}\n\n/**\n * A titled block of rows, derived from one top-level group of a properties\n * schema. `key` is that group's schema key.\n */\nexport interface PanelSection {\n key: string;\n name: string;\n rows: PanelRow[];\n}\n\n/** Derive a node's kind: containers are `'group'`; leaves classify their\n * `data` through the routing entries (first match wins, `'unknown'`\n * otherwise) — same semantics as core's `NodeRouting.classify`. */\nexport function classifyKind(\n node: AnyNode,\n routing: readonly NodeRoutingEntry[],\n): string {\n if (node.kind === 'container') return 'group';\n for (const entry of routing) {\n if (entry.matches(node.data)) return entry.name;\n }\n return 'unknown';\n}\n\nexport function isGroup(n: ToolPrefLeaf | ToolPrefGroup): n is ToolPrefGroup {\n return !('kind' in n);\n}\n\n/** Flatten a schema to sections of leaves. Nested groups fold into their\n * top-level section; top-level leaves get an untitled leading section. */\nfunction flatten(schema: ToolPrefGroup): PanelSection[] {\n const sections: PanelSection[] = [];\n const untitled: PanelLeaf[] = [];\n\n const collect = (group: ToolPrefGroup, into: PanelLeaf[]): void => {\n for (const [key, child] of Object.entries(group.children)) {\n if (isGroup(child)) collect(child, into);\n else into.push({ path: key, leaf: child });\n }\n };\n\n for (const [key, child] of Object.entries(schema.children)) {\n if (isGroup(child)) {\n const leaves: PanelLeaf[] = [];\n collect(child, leaves);\n sections.push({ key, name: child.name, rows: pairRows(leaves) });\n } else {\n untitled.push({ path: key, leaf: child });\n }\n }\n if (untitled.length > 0) {\n sections.unshift({ key: '', name: '', rows: pairRows(untitled) });\n }\n return sections;\n}\n\n/** Merge consecutive leaves sharing a `pair` id into one labeled row. */\nexport function pairRows(leaves: readonly PanelLeaf[]): PanelRow[] {\n const rows: PanelRow[] = [];\n for (const item of leaves) {\n const pair = item.leaf.pair;\n const prev = rows[rows.length - 1];\n if (pair !== undefined && prev !== undefined && prev.label === pair) {\n prev.leaves.push(item);\n } else {\n rows.push({ label: pair ?? item.leaf.name, leaves: [item] });\n }\n }\n return rows;\n}\n\n/**\n * The schema the panel shows for a set of kinds: one kind → its full\n * schema; several → the intersection by (path, leaf kind), shaped by the\n * first kind's section/row layout. Kinds without a registered schema\n * contribute nothing, so their presence collapses the intersection.\n */\nexport function effectiveSections(\n kinds: readonly string[],\n entries: readonly NodePropertiesEntry[],\n): PanelSection[] {\n const uniq = [...new Set(kinds)];\n if (uniq.length === 0) return [];\n const byName = new Map(entries.map((e) => [e.name, e]));\n const schemas = uniq.map((k) => byName.get(k)?.schema);\n if (schemas.some((s) => s === undefined)) return [];\n const [first, ...rest] = schemas as ToolPrefGroup[];\n\n const flatFirst = flatten(first);\n if (rest.length === 0) return flatFirst;\n\n // '\\0' delimiter: path and kind strings are unconstrained, so a\n // printable separator could collide with real content.\n const leafKey = (l: PanelLeaf): string => `${l.path}\\0${l.leaf.kind}`;\n const restKeys = rest.map(\n (schema) =>\n new Set(\n flatten(schema)\n .flatMap((s) => s.rows)\n .flatMap((r) => r.leaves)\n .map(leafKey),\n ),\n );\n const keep = (l: PanelLeaf): boolean =>\n restKeys.every((set) => set.has(leafKey(l)));\n\n return flatFirst\n .map((section) => ({\n ...section,\n rows: section.rows\n .map((row) => ({ ...row, leaves: row.leaves.filter(keep) }))\n .filter((row) => row.leaves.length > 0),\n }))\n .filter((section) => section.rows.length > 0);\n}\n\n/** Read a node value at a dotted path of any depth (`pose.x`,\n * `data.style.fontSize`, `data.style.fill.color`). Returns `undefined` if\n * the path is dotless (mirrors `commit`'s no-op on a malformed schema\n * key) or if any intermediate segment is missing or not an object. */\nexport function nodeValueAt(node: AnyNode, path: string): unknown {\n const segments = path.split('.');\n if (segments.length < 2) return undefined;\n const head = segments[0];\n let cursor: unknown = head === 'pose' ? node.pose : head === 'data' ? node.data : undefined;\n for (let i = 1; i < segments.length; i++) {\n if (cursor == null || typeof cursor !== 'object') return undefined;\n cursor = (cursor as Record<string, unknown>)[segments[i]];\n }\n return cursor;\n}\n\n/** Immutably set `value` at a dotted path within `root`, cloning each level\n * on the way down so React sees new object identities. Arrays stay arrays\n * (an array intermediate is shallow-copied, not flattened into `{0: ...}`)\n * — this is the write-side twin of `nodeValueAt`, so a schema author who\n * gets a working read gets a working write. */\nexport function setAtPath(root: object, segments: readonly string[], value: unknown): object {\n const [head, ...rest] = segments;\n if (rest.length === 0) {\n return Array.isArray(root)\n ? Object.assign([...root], { [head]: value })\n : { ...root, [head]: value };\n }\n const child = (root as Record<string, unknown>)[head];\n const childObj = Array.isArray(child)\n ? [...child]\n : child != null && typeof child === 'object'\n ? { ...child }\n : {};\n const nested = setAtPath(childObj, rest, value);\n return Array.isArray(root)\n ? Object.assign([...root], { [head]: nested })\n : { ...root, [head]: nested };\n}\n\n/** Aggregate a path across nodes: the shared value, or `MIXED`. */\nexport function aggregateValue(\n nodes: readonly AnyNode[],\n path: string,\n): unknown | Mixed {\n let value: unknown;\n let first = true;\n for (const node of nodes) {\n const v = nodeValueAt(node, path);\n if (first) {\n value = v;\n first = false;\n } else if (!Object.is(v, value)) {\n return MIXED;\n }\n }\n return value;\n}\n\n/** `'rect ×2 · text'` — kinds in first-seen order with counts. */\nexport function kindBreakdown(kinds: readonly string[]): string {\n const counts = new Map<string, number>();\n for (const k of kinds) counts.set(k, (counts.get(k) ?? 0) + 1);\n return [...counts.entries()]\n .map(([k, n]) => (n > 1 ? `${k} ×${n}` : k))\n .join(' · ');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACgIA,SAAgBS,EAAW,GAAgB,GAAuD;CAChG,IAAM,EAAE,YAASC;CACjB,OACEC,EAAK,SAAS,aACbA,EAAyB,YAAY,YACtCA,EAAK,SAAS,KAAA,KACdC,IAAYF,EAAK,IAAI,UAAU,KAAA,KAC/BE,IAAYD,EAAK,UAAU,KAAA;AAE/B;AAOA,SAAgBE,EACd,GACA,GACgB;CAChB,IAAMC,IAAsB,CAAC;CAC7B,KAAK,IAAIC,IAAI,GAAGA,IAAIC,EAAM,SAAU;EAClC,IAAMN,IAAOM,EAAMD;EACnB,IAAI,CAACN,EAAWC,GAAME,CAAS,GAAG;GAChC,IAAMK,IAAUP,EAAK,OAAO;GAI5B,AAHIO,KAAW,QACbH,EAAI,KAAK;IAAE,KAAKJ,EAAK;IAAK,MAAMA,EAAK;IAAM,OAAOA,EAAK,KAAK,UAAU;IAAM;GAAQ,CAAC,GAEvF,KAAK;GACL;EACF;EACA,IAAIQ,IAAIH,IAAI;EACZ,OACEG,IAAIF,EAAM,UAC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AI3C,EAAK,WAAW,GAClB,OAAO,MAAM,QAAQ+C,CAAI,IACrB,OAAO,OAAO,CAAC,GAAGA,CAAI,GAAG,GAAGH,IAAOI,EAAM,CAAC,IAC1C;EAAE,GAAGD;GAAOH,IAAOI;CAAM;CAE/B,IAAMhE,IAAS+D,EAAiCH,IAM1CrE,IAASuE,EALE,MAAM,QAAQ9D,CAAK,IAChC,CAAC,GAAGA,CAAK,IACQ,OAAOA,KAAU,YAAlCA,IACE,EAAE,GAAGA,EAAM,IACX,CAAC,GAC4BgB,GAAMgD,CAAK;CAC9C,OAAO,MAAM,QAAQD,CAAI,IACrB,OAAO,OAAO,CAAC,GAAGA,CAAI,GAAG,GAAGH,IAAOrE,EAAO,CAAC,IAC3C;EAAE,GAAGwE;GAAOH,IAAOrE;CAAO;AAChC;AAGA,SAAgB0E,EACd,GACA,GACiB;CACjB,IAAID,GACAhB,IAAQ;CACZ,KAAK,IAAMvB,KAAQyC,GAAO;EACxB,IAAMpE,IAAI4D,EAAYjC,GAAMhC,CAAI;EAChC,IAAIuD,GAEF,AADA,IAAQlD,GACR,IAAQ;OACH,IAAI,CAAC,OAAO,GAAGA,GAAGkE,CAAK,GAC5B,OAAOG;CAEX;CACA,OAAOH;AACT;AAGA,SAAgBI,EAAc,GAAkC;CAC9D,IAAMC,oBAAS,IAAI,IAAoB;CACvC,KAAK,IAAMvB,KAAKJ,GAAO,EAAO,IAAII,IAAIuB,EAAO,IAAIvB,CAAC,KAAK,KAAK,CAAC;CAC7D,OAAO,CAAC,GAAGuB,EAAO,QAAQ,CAAC,CAAC,CACzB,KAAK,CAACvB,GAAGlB,OAAQA,IAAI,IAAI,GAAGkB,EAAE,IAAIlB,MAAMkB,CAAE,CAAC,CAC3C,KAAK,KAAK;AACf"}
1
+ {"version":3,"file":"model-B6zuQg6b.js","names":["s","Fragment","ICON_PATHS","drawnGlyph","PropertyControl","ToggleBar","prefFieldProps","Fragment$1","SelectionPanel_module_default","isFlagCell","cell","leaf","renderers","renderCells","out","i","cells","content","j","run","c","FlagBar","flags","perNodeState","on","f","field","now","next","renderBuiltin","ctx","pref","ObjectLeaf","siblingPath","ariaLabel","settledOnly","selectionKey","nested","dot","path","key","siblings","held","eachObject","v","allGrouped","child","rowsOf","isRow","pending","flush","prev","block","children","labeled","inner","indent","childPath","update","base","fn","_dropped","rest","childCtx","o","custom","rendered","Icon","entry","rows","classifyKind","node","routing","isGroup","n","flatten","sections","untitled","collect","group","into","schema","leaves","pairRows","item","pair","effectiveSections","uniq","kinds","byName","entries","schemas","k","s","first","flatFirst","leafKey","l","restKeys","r","keep","set","section","row","nodeValueAt","segments","head","cursor","setAtPath","root","value","aggregateValue","nodes","MIXED","kindBreakdown","counts"],"sources":["../../src/components/SelectionPanel/SelectionPanel.module.css","../../src/components/SelectionPanel/renderLeaf.tsx","../../src/components/SelectionPanel/model.ts"],"sourcesContent":[".root {\n display: flex;\n flex-direction: column;\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg);\n}\n\n.header {\n display: flex;\n align-items: baseline;\n gap: var(--wzl-space-4);\n padding: var(--wzl-space-4) 0;\n border-block-end: 1px solid var(--wzl-border);\n}\n\n.kind {\n font-weight: var(--wzl-font-weight-bold);\n font-size: var(--wzl-font-size);\n}\n\n.breakdown {\n font-size: var(--wzl-font-size-sm);\n opacity: 0.6;\n}\n\n.section {\n padding: var(--wzl-space-3) 0 var(--wzl-space-4);\n border-block-end: 1px solid var(--wzl-border);\n}\n\n.section:last-child {\n border-block-end: none;\n}\n\n.sectionTitle {\n margin: 0 0 var(--wzl-space-3);\n font-size: var(--wzl-font-size-xs);\n font-weight: var(--wzl-font-weight-bold);\n text-transform: uppercase;\n letter-spacing: 0.06em;\n opacity: 0.55;\n}\n\n.row {\n display: grid;\n grid-template-columns: 64px 1fr;\n gap: var(--wzl-space-3);\n align-items: center;\n margin-block-end: 5px;\n}\n\n.rowLabel {\n opacity: 0.75;\n}\n\n.rowControls {\n display: flex;\n flex-wrap: wrap;\n gap: var(--wzl-space-3);\n align-items: center;\n min-inline-size: 0;\n}\n\n/* Glyph plus its control, held together so the pair row wraps between\n fields rather than between a field and the icon naming it. */\n.namedField {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-2);\n min-inline-size: 0;\n}\n\n.namedField > svg {\n flex: none;\n opacity: 0.75;\n}\n\n.blockRow {\n margin-block-end: 5px;\n}\n\n/* Fields paired into one row split it evenly, the way Position's x/y do. */\n.rowControls > .namedField {\n flex: 1 1 0;\n}\n\n/* Except around a segmented bar, which is sized by its segments: an equal\n share of the row is wider than the buttons want to be. */\n.rowControls > .namedField:has(> .toggle) {\n flex: 0 1 auto;\n}\n\n.rowControls > * {\n flex: 1;\n min-inline-size: 0;\n}\n\n/* Bars sharing a row split the leftover between them, so the gap stays fixed\n and the width lands on the segments. A bar with the row to itself is sized\n by its segments instead — a third of 240px is a plate, not a button. */\n.rowControls > .toggle {\n flex: 1 1 auto;\n}\n\n.rowControls > .toggle:only-child {\n flex: 0 1 auto;\n}\n\n/* A flag bar is sized by its glyphs rather than by a share of the row: an\n even split would fling one-letter segments to the margins. */\n.rowControls > .flagToggle {\n flex: 0 0 auto;\n}\n\n.number :global(input),\n.select {\n font-size: var(--wzl-font-size-sm);\n}\n\n.unrenderable {\n font-size: var(--wzl-font-size-sm);\n opacity: 0.5;\n font-style: italic;\n}\n\n/* A `block` leaf that renders its own rows — an object leaf's fields. */\n.objectLeaf {\n margin-block: var(--wzl-space-4) var(--wzl-space-2);\n}\n\n.objectLeaf .sectionTitle {\n margin-block: 7px 5px;\n}\n\n/* Fields under a heading inside an object read as belonging to it. */\n.objectGroup {\n padding-inline-start: var(--wzl-space-4);\n border-inline-start: 1px solid var(--wzl-border);\n margin-block-end: var(--wzl-space-2);\n}\n\n/* The slider's track; the row only says how it shares the space. */\n.slider {\n flex: 1;\n}\n","/**\n * A selection's leaves as cells: one `ToolPrefLeaf` and its aggregated value\n * in, one rendered cell out, plus the run logic that turns a row of paired\n * toggles into a single segmented bar and the rows of an object leaf.\n *\n * The control itself is `PropertyControl`'s, through `prefFieldProps`; what\n * is decided here is how a selection surface sizes and composes it.\n * `ToolOptionsBar` renders a tool's options through the same functions.\n */\nimport { Fragment, type ReactNode } from 'react';\nimport type {\n ToolPrefBoolean,\n ToolPrefGroup,\n ToolPrefLeaf,\n ToolPrefObject,\n} from '@weasel-js/core';\nimport { prefFieldProps, type PrefFieldState } from '../Prefs/prefField';\nimport { drawnGlyph, PropertyControl, type PropertyBooleanFieldProps } from '../Properties/PropertyField';\nimport { ToggleBar } from '../ToggleBar';\nimport { Icon } from '../../icons/Icon';\nimport { ICON_PATHS, type IconName } from '../../icons/paths';\nimport s from './SelectionPanel.module.css';\n\n\n/** What a {@link PropertyRenderer} is given for the property it is rendering. */\nexport interface PropertyRenderContext {\n /** Dotted node path of the leaf (`pose.x`, `data.fill`). */\n path: string;\n /** The schema leaf. App renderers narrow it to their own kind shape. */\n pref: ToolPrefLeaf;\n /** Aggregated value across the selection; `undefined` when mixed or unset. */\n value: unknown;\n /** True when selected nodes disagree at this path. */\n mixed: boolean;\n /**\n * True when the nodes agree and what they agree on is nothing — the field\n * is absent, and whatever paints comes from a fallback further down.\n *\n * Distinct from `mixed`, and both leave `value` undefined. A control must\n * not substitute its schema default here: doing so shows a value the node\n * does not hold, and the next edit writes that invention back.\n */\n unset: boolean;\n /**\n * The fields of the object this leaf is a field of — `undefined` for a\n * top-level leaf, and for a field of an object the node does not hold.\n *\n * What a control needs when its own field doesn't carry the whole answer:\n * a stroke's dash lengths are multiples of the stroke's width, so reading\n * the array as a style takes both.\n */\n siblings?: Record<string, unknown>;\n /** The value each selected node holds at this path, in selection order —\n * what `value` aggregates, and what a mixed selection still has. */\n each: readonly unknown[];\n /**\n * For a field of an object leaf, each node's own object (parallel to\n * `each`), which is still there when the nodes' objects differ and\n * `siblings` is not.\n */\n eachSiblings?: readonly (Record<string, unknown> | undefined)[];\n /** Commit a value — fans out to every selected node in one undo step. */\n setValue: (value: unknown) => void;\n /**\n * Commit a value derived from what each node holds at this path, in one undo\n * step. What `setValue` cannot do across a selection whose nodes differ: a\n * field of an object leaf has to land in each node's own object, not in one\n * object written over all of them. `siblings` is that node's object, for a\n * field of an object leaf.\n */\n update: (fn: (prev: unknown, siblings?: Record<string, unknown>) => unknown) => void;\n /**\n * The aggregated value at another node path — what `value` and `mixed` are\n * for this leaf's own path, for any path.\n *\n * A control whose subject spans more than one field needs it: a font picker\n * reporting which variant will actually paint has to read the node's weight\n * and style. Reading it off `value` is impossible — a leaf is handed one\n * field.\n */\n valueAt: (path: string) => { value: unknown; mixed: boolean };\n /**\n * The ids of the nodes the values were read from, joined. It changes exactly\n * when the selection does, so a control holding scratch that belongs to one\n * selection can key on it and be remounted rather than carry it to the next.\n * Absent where the values come from no selection, as in a tool options bar.\n */\n selectionKey?: string;\n}\n\n/**\n * Renders the control for one property across the whole selection.\n * Returning `null` collapses the leaf.\n */\nexport type PropertyRenderer = (ctx: PropertyRenderContext) => ReactNode;\n\n\n/**\n * One leaf with its context built but nothing rendered yet.\n *\n * Deferring the render is what lets a run of sibling flags become one bar:\n * whether a leaf joins its neighbors is a fact about the run, which no leaf\n * rendering itself can see.\n */\nexport interface LeafCell {\n key: string;\n leaf: ToolPrefLeaf;\n ctx: PropertyRenderContext;\n /** The accessible name this leaf's control carries — qualified by the row's\n * pair where the row holds more than one leaf. */\n ariaLabel: string;\n /** Renders the leaf on its own, chrome and all. */\n render: () => ReactNode;\n}\n\n/** A cell's content, once the run it belongs to has been decided. */\nexport interface RenderedCell {\n key: string;\n /** The leaf that names the cell — the run's first, for a flag bar. */\n leaf: ToolPrefLeaf;\n block: boolean;\n content: ReactNode;\n}\n\n/**\n * True for a leaf that can join a flag bar: a paired toggle boolean the\n * consumer has not claimed with a renderer of its own.\n */\nexport function isFlagCell(cell: LeafCell, renderers?: Record<string, PropertyRenderer>): boolean {\n const { leaf } = cell;\n return (\n leaf.kind === 'boolean' &&\n (leaf as ToolPrefBoolean).control === 'toggle' &&\n leaf.pair !== undefined &&\n renderers?.[cell.ctx.path] === undefined &&\n renderers?.[leaf.kind] === undefined\n );\n}\n\n/**\n * Renders a row's cells, collapsing each run of adjacent same-`pair` toggle\n * booleans into one segmented bar — the idiom the enum toggle a row away\n * already uses, rather than one detached pill per flag.\n */\nexport function renderCells(\n cells: readonly LeafCell[],\n renderers?: Record<string, PropertyRenderer>,\n): RenderedCell[] {\n const out: RenderedCell[] = [];\n for (let i = 0; i < cells.length; ) {\n const cell = cells[i];\n if (!isFlagCell(cell, renderers)) {\n const content = cell.render();\n if (content != null) {\n out.push({ key: cell.key, leaf: cell.leaf, block: cell.leaf.block === true, content });\n }\n i += 1;\n continue;\n }\n let j = i + 1;\n while (\n j < cells.length &&\n isFlagCell(cells[j], renderers) &&\n cells[j].leaf.pair === cell.leaf.pair\n ) {\n j += 1;\n }\n const run = cells.slice(i, j);\n out.push({\n key: cell.key,\n leaf: cell.leaf,\n block: run.every((c) => c.leaf.block === true),\n content: <FlagBar run={run} ariaLabel={cell.leaf.pair as string} />,\n });\n i = j;\n }\n return out;\n}\n\n/**\n * A run of paired boolean flags as one multi-select bar — U / S / O, the way\n * every text editor draws them.\n */\nfunction FlagBar({ run, ariaLabel }: { run: readonly LeafCell[]; ariaLabel: string }): ReactNode {\n // Each flag through the same field props a lone one gets, so an `encoding`\n // (Italic stored as `fontStyle`) reads and writes the same way in a bar.\n const flags = run.map((c) => {\n const field = prefFieldProps(c.leaf, {\n value: c.ctx.value,\n mixed: c.ctx.mixed,\n unset: c.ctx.unset,\n siblings: c.ctx.siblings,\n setValue: c.ctx.setValue,\n ...perNodeState(c.ctx),\n }) as PropertyBooleanFieldProps;\n return { cell: c, field };\n });\n const on = flags.filter((f) => !f.field.mixed && f.field.value === true).map((f) => f.cell.key);\n return (\n <ToggleBar<string>\n mode=\"multiple\"\n size=\"sm\"\n variant=\"flat\"\n className={s.flagToggle}\n ariaLabel={ariaLabel}\n items={flags.map(({ cell, field }) => ({\n value: cell.key,\n label: field.glyph ?? cell.leaf.name.slice(0, 1),\n ariaLabel: cell.ariaLabel,\n tooltip: drawnGlyph(field.glyph) === undefined ? undefined : cell.leaf.name,\n }))}\n value={on}\n // Each flag owns its own path, so only the segment that moved is\n // written — committing the run would write two fields nobody touched,\n // and inside an object leaf would fabricate values for the other two.\n mixedValues={flags.filter((f) => f.field.mixed).map((f) => f.cell.key)}\n onChange={(next) => {\n for (const { cell, field } of flags) {\n const now = next.includes(cell.key);\n if (now !== on.includes(cell.key)) field.onChange(now);\n }\n }}\n />\n );\n}\n\nexport function renderBuiltin(\n ctx: PropertyRenderContext,\n ariaLabel: string,\n renderers?: Record<string, PropertyRenderer>,\n /** Identifies the current selection, so a control holding per-selection\n * scratch (the paint kind memory) is remounted rather than carried over. */\n selectionKey = '',\n /** True for a field of an object leaf. Such a field writes itself into its\n * parent, so it can only hold values its parent's type permits — which is\n * what rules \"none\" out for a nested paint. */\n nested = false,\n): ReactNode {\n const { pref, value, mixed, unset, setValue } = ctx;\n if (pref.kind === 'object') {\n // One value with fields hanging off it. Each child writes the parent\n // whole, so a field is never set on a half-built object.\n return <ObjectLeaf ctx={ctx} renderers={renderers} selectionKey={selectionKey} />;\n }\n const field = prefFieldProps(pref, {\n value,\n mixed,\n unset,\n siblings: ctx.siblings,\n setValue,\n ...perNodeState(ctx),\n // The font pickers read the rest of the font from the leaves beside\n // them: the family's substitution probe runs at the weight and style\n // that will paint, and a weight lists what its family has. A mixed\n // selection has no single one; the probe falls back to 400/normal there.\n fontVariant: {\n weight: ctx.valueAt(siblingPath(ctx.path, 'fontWeight')).value,\n style: ctx.valueAt(siblingPath(ctx.path, 'fontStyle')).value,\n },\n fontFamily: ctx.valueAt(siblingPath(ctx.path, 'fontFamily')).value,\n });\n if (field === null) {\n return <span className={s.unrenderable}>({pref.kind}: no renderer)</span>;\n }\n switch (field.kind) {\n case 'boolean':\n // A panel's flag is a switch unless it asks otherwise.\n return (\n <PropertyControl\n {...field}\n name={ariaLabel}\n control={field.control ?? 'switch'}\n className={field.control === 'toggle' ? s.flagToggle : undefined}\n />\n );\n case 'number':\n return (\n <PropertyControl\n {...field}\n name={ariaLabel}\n className={field.control === 'slider' ? s.slider : s.number}\n // A typed number writes once it is entered, as text does; a slider\n // writes as it moves.\n onInput={field.control === 'slider' ? field.onInput : settledOnly}\n />\n );\n case 'string':\n // Settled values only: a live write per keystroke would be one undo\n // step per character.\n return <PropertyControl {...field} name={ariaLabel} onInput={settledOnly} />;\n case 'enum':\n return (\n <PropertyControl\n {...field}\n name={ariaLabel}\n // A clearable toggle is a set of exclusive flags, and sits beside\n // other flags sized the way they are.\n className={\n field.control === 'toggle'\n ? field.onClear ? s.flagToggle : s.toggle\n : field.control === 'radio' ? undefined : s.select\n }\n />\n );\n case 'font-family':\n case 'font-weight':\n return <PropertyControl {...field} name={ariaLabel} className={s.select} />;\n case 'paint':\n return (\n <PropertyControl\n {...field}\n name={ariaLabel}\n // Per-kind switch memory is scratch for one selection; carrying it\n // across would recall the previous node's gradient.\n key={selectionKey}\n control=\"inline\"\n // A nested paint writes one field of its parent, and no kit paint\n // field is optional — `Stroke.paint` is required. Removing the\n // whole parent is a different edit than repainting it, so the\n // control must not offer one as the other.\n allowNone={!nested}\n />\n );\n case 'color':\n // One write per gesture, not one per step of the picker.\n return <PropertyControl {...field} name={ariaLabel} onInput={settledOnly} />;\n }\n}\n\nconst settledOnly = (): void => {};\n\n/** The dotted path of the leaf `key` beside the one at `path`. */\nfunction siblingPath(path: string, key: string): string {\n const dot = path.lastIndexOf('.');\n return dot < 0 ? key : `${path.slice(0, dot + 1)}${key}`;\n}\n\n/** What an `encoding` needs to read and write each node against its own\n * object — nothing for a leaf that is not a field of one. */\nfunction perNodeState(ctx: PropertyRenderContext): Pick<PrefFieldState, 'perNode' | 'update'> {\n if (ctx.eachSiblings === undefined) return {};\n const siblings = ctx.eachSiblings;\n return {\n perNode: ctx.each.map((value, i) => ({ value, siblings: siblings[i] })),\n update: ctx.update,\n };\n}\n\n/**\n * Renders an object leaf: a titled block whose rows are the object's own\n * fields. A child's edit commits the parent object, never the child's path —\n * writing into a path whose value is not an object yet would corrupt it.\n */\n/** One labeled row inside an object leaf; `pair` merges adjacent fields into\n * it, exactly as the section rows merge theirs. */\ninterface ObjectRow {\n key: string;\n pair?: string;\n label: string;\n title?: string;\n /** Every field in the row brought its own chrome, so the row drops the\n * label column and spans the block. One unlabeled field in an otherwise\n * labeled pair would leave the row named after half of itself. */\n block: boolean;\n controls: ReactNode[];\n}\n\n/**\n * Renders an object leaf: the object's own fields, as rows. A child's edit\n * commits the parent object, never the child's path — writing into a path\n * whose value is not an object yet would corrupt it.\n */\nfunction ObjectLeaf({\n ctx,\n renderers,\n selectionKey = '',\n}: {\n ctx: PropertyRenderContext;\n renderers?: Record<string, PropertyRenderer>;\n selectionKey?: string;\n}): ReactNode {\n const pref = ctx.pref as ToolPrefObject;\n const held = typeof ctx.value === 'object' && ctx.value !== null\n ? (ctx.value as Record<string, unknown>)\n : undefined;\n const eachObject = ctx.each.map((v) =>\n typeof v === 'object' && v !== null ? (v as Record<string, unknown>) : undefined,\n );\n\n // A value whose fields are entirely grouped is titled by those groups — its\n // own heading would stack onto the first one and name nothing new.\n const allGrouped = Object.values(pref.children).every((child) => !('kind' in child));\n\n // `indent` is false when nothing visible sits above these rows: depth is\n // drawn only where a label marks it.\n const rowsOf = (\n children: Record<string, ToolPrefLeaf | ToolPrefGroup>,\n indent: boolean,\n ): ReactNode[] => {\n const out: (ReactNode | ObjectRow)[] = [];\n const isRow = (v: ReactNode | ObjectRow): v is ObjectRow =>\n typeof v === 'object' && v !== null && 'controls' in v;\n\n // Cells accumulate unrendered so a run of adjacent same-`pair` flags can\n // be seen as a run before any of them draws; a group heading between two\n // fields ends the run, exactly as it ends a paired row.\n let pending: LeafCell[] = [];\n const flush = (): void => {\n for (const { key, leaf, block, content } of renderCells(pending, renderers)) {\n const prev = out[out.length - 1];\n if (leaf.pair !== undefined && isRow(prev) && prev.pair === leaf.pair) {\n prev.controls.push(<Fragment key={key}>{content}</Fragment>);\n prev.block &&= block;\n continue;\n }\n out.push({\n key,\n pair: leaf.pair,\n label: leaf.pair ?? leaf.name,\n title: leaf.description,\n block,\n controls: [<Fragment key={key}>{content}</Fragment>],\n });\n }\n pending = [];\n };\n\n for (const [key, child] of Object.entries(children)) {\n // A group among the children organises the fields under a heading\n // without contributing to the path — the rule group keys follow at the\n // top level.\n if (!('kind' in child)) {\n const labeled = child.name !== '';\n const inner = rowsOf(child.children, labeled);\n if (inner.length === 0) continue;\n flush();\n out.push(\n <div key={`group:${key}`} className={labeled && indent ? s.objectGroup : undefined}>\n {labeled && <h5 className={s.sectionTitle}>{child.name}</h5>}\n {inner}\n </div>,\n );\n continue;\n }\n const childPath = `${ctx.path}.${key}`;\n // Nodes whose objects differ still agree or disagree field by field: two\n // styles at different sizes are both upright, and saying \"mixed\" for\n // every field of them hides that.\n const field = ctx.mixed ? ctx.valueAt(childPath) : { value: held?.[key], mixed: false };\n // Each node's own object, with this one field changed. Deriving it per\n // node is what keeps a multi-selection edit from writing one node's\n // object over all the others.\n const update = (fn: (prev: unknown, siblings?: Record<string, unknown>) => unknown): void =>\n ctx.update((prev) => {\n // The node holds no object yet, so writing one field has to\n // materialize the rest: the leaf's `default` is what a complete\n // value looks like. Starting from `{}` instead committed the one\n // field on its own — a `data.stroke` of `{ width: 2 }` with no\n // `paint`, which the type forbids and the painter threw on, taking\n // the whole frame and the visible document with it.\n const base: Record<string, unknown> =\n typeof prev === 'object' && prev !== null\n ? (prev as Record<string, unknown>)\n : (pref.fromScalar?.(prev)\n ?? (typeof pref.default === 'object' && pref.default !== null\n ? { ...(pref.default as Record<string, unknown>) }\n : {}));\n const v = fn(base[key], base);\n if (v === undefined) {\n // A field written as absent is absent — leaving the key holding\n // `undefined` says the object has a dash of nothing.\n const { [key]: _dropped, ...rest } = base;\n return rest;\n }\n return { ...base, [key]: v };\n });\n const childCtx: PropertyRenderContext = {\n path: childPath,\n pref: child,\n value: field.mixed ? undefined : field.value,\n mixed: field.mixed,\n // A field of an object the node does not hold is unset, and so is one\n // the object omits — `data.stroke` absent leaves every stroke field\n // with nothing behind it, not with the schema's defaults.\n unset: !field.mixed && field.value === undefined,\n siblings: held,\n each: eachObject.map((o) => o?.[key]),\n eachSiblings: eachObject,\n valueAt: ctx.valueAt,\n selectionKey: ctx.selectionKey,\n update,\n setValue: (v) => update(() => v),\n };\n pending.push({\n key: childPath,\n leaf: child,\n ctx: childCtx,\n ariaLabel: child.name,\n render: () => {\n const custom = renderers?.[childPath] ?? renderers?.[child.kind];\n const rendered = custom\n ? custom(childCtx)\n : renderBuiltin(childCtx, child.name, renderers, selectionKey, true);\n if (rendered == null) return null;\n // Neither a paired row nor a block one gives a field its own label\n // column, so the glyph is all that names it on screen. The control\n // already carries `name` as its accessible name, which leaves the\n // glyph decorative.\n const unlabeled = child.pair !== undefined || child.block === true;\n const glyph = unlabeled && child.icon && child.icon in ICON_PATHS;\n if (!glyph) return rendered;\n return (\n <span className={s.namedField}>\n <Icon name={child.icon as IconName} size={14} />\n {rendered}\n </span>\n );\n },\n });\n }\n flush();\n return out.map((entry) =>\n typeof entry === 'object' && entry !== null && 'controls' in entry ? (\n entry.block ? (\n <div key={entry.key} className={`${s.rowControls} ${s.blockRow}`} title={entry.title}>\n {entry.controls}\n </div>\n ) : (\n <div key={entry.key} className={s.row}>\n <span className={s.rowLabel} title={entry.title}>{entry.label}</span>\n <span className={s.rowControls}>{entry.controls}</span>\n </div>\n )\n ) : (\n entry\n ),\n );\n };\n\n const rows = rowsOf(pref.children, !allGrouped);\n if (rows.length === 0) return null;\n return (\n <div className={s.objectLeaf}>\n {!allGrouped && <h4 className={s.sectionTitle}>{pref.name}</h4>}\n {rows}\n </div>\n );\n}\n","// Pure selection→panel derivations for SelectionPanel. Kept free of\n// React so intersection/aggregation semantics are unit-testable.\n//\n// Path convention (see core `NodePropertiesEntry`): a leaf's OWN KEY in\n// the schema is its node path — a dotted path of any depth rooted at\n// `pose` or `data` (`pose.x`, `data.fill`, `data.style.fontSize`). Group\n// keys are organizational only.\n\nimport {\n MIXED,\n type Mixed,\n type NodePropertiesEntry,\n type NodeRoutingEntry,\n type SceneNode,\n type ToolPrefGroup,\n type ToolPrefLeaf,\n} from '@weasel-js/core';\n\n// Re-exported under its existing public name here: the kit-wide \"these\n// values disagree\" sentinel (`@weasel-js/core`'s `MIXED`) also covers\n// multi-node aggregation, so this panel doesn't get its own symbol.\nexport { MIXED };\nexport type { Mixed };\n\nexport type AnyNode = SceneNode<unknown, string, unknown>;\n\n/**\n * One editable property in a {@link SelectionPanel}, paired with the dotted\n * node path it reads and writes.\n */\nexport interface PanelLeaf {\n /** Dotted node path — the leaf's key in the schema. */\n path: string;\n leaf: ToolPrefLeaf;\n}\n\n/**\n * One labeled row of a panel section. Holds several leaves when the schema\n * paired them.\n */\nexport interface PanelRow {\n label: string;\n leaves: PanelLeaf[];\n}\n\n/**\n * A titled block of rows, derived from one top-level group of a properties\n * schema. `key` is that group's schema key.\n */\nexport interface PanelSection {\n key: string;\n name: string;\n rows: PanelRow[];\n}\n\n/** Derive a node's kind: containers are `'group'`; leaves classify their\n * `data` through the routing entries (first match wins, `'unknown'`\n * otherwise) — same semantics as core's `NodeRouting.classify`. */\nexport function classifyKind(\n node: AnyNode,\n routing: readonly NodeRoutingEntry[],\n): string {\n if (node.kind === 'container') return 'group';\n for (const entry of routing) {\n if (entry.matches(node.data)) return entry.name;\n }\n return 'unknown';\n}\n\nexport function isGroup(n: ToolPrefLeaf | ToolPrefGroup): n is ToolPrefGroup {\n return !('kind' in n);\n}\n\n/** Flatten a schema to sections of leaves. Nested groups fold into their\n * top-level section; top-level leaves get an untitled leading section. */\nfunction flatten(schema: ToolPrefGroup): PanelSection[] {\n const sections: PanelSection[] = [];\n const untitled: PanelLeaf[] = [];\n\n const collect = (group: ToolPrefGroup, into: PanelLeaf[]): void => {\n for (const [key, child] of Object.entries(group.children)) {\n if (isGroup(child)) collect(child, into);\n else into.push({ path: key, leaf: child });\n }\n };\n\n for (const [key, child] of Object.entries(schema.children)) {\n if (isGroup(child)) {\n const leaves: PanelLeaf[] = [];\n collect(child, leaves);\n sections.push({ key, name: child.name, rows: pairRows(leaves) });\n } else {\n untitled.push({ path: key, leaf: child });\n }\n }\n if (untitled.length > 0) {\n sections.unshift({ key: '', name: '', rows: pairRows(untitled) });\n }\n return sections;\n}\n\n/** Merge consecutive leaves sharing a `pair` id into one labeled row. */\nexport function pairRows(leaves: readonly PanelLeaf[]): PanelRow[] {\n const rows: PanelRow[] = [];\n for (const item of leaves) {\n const pair = item.leaf.pair;\n const prev = rows[rows.length - 1];\n if (pair !== undefined && prev !== undefined && prev.label === pair) {\n prev.leaves.push(item);\n } else {\n rows.push({ label: pair ?? item.leaf.name, leaves: [item] });\n }\n }\n return rows;\n}\n\n/**\n * The schema the panel shows for a set of kinds: one kind → its full\n * schema; several → the intersection by (path, leaf kind), shaped by the\n * first kind's section/row layout. Kinds without a registered schema\n * contribute nothing, so their presence collapses the intersection.\n */\nexport function effectiveSections(\n kinds: readonly string[],\n entries: readonly NodePropertiesEntry[],\n): PanelSection[] {\n const uniq = [...new Set(kinds)];\n if (uniq.length === 0) return [];\n const byName = new Map(entries.map((e) => [e.name, e]));\n const schemas = uniq.map((k) => byName.get(k)?.schema);\n if (schemas.some((s) => s === undefined)) return [];\n const [first, ...rest] = schemas as ToolPrefGroup[];\n\n const flatFirst = flatten(first);\n if (rest.length === 0) return flatFirst;\n\n // '\\0' delimiter: path and kind strings are unconstrained, so a\n // printable separator could collide with real content.\n const leafKey = (l: PanelLeaf): string => `${l.path}\\0${l.leaf.kind}`;\n const restKeys = rest.map(\n (schema) =>\n new Set(\n flatten(schema)\n .flatMap((s) => s.rows)\n .flatMap((r) => r.leaves)\n .map(leafKey),\n ),\n );\n const keep = (l: PanelLeaf): boolean =>\n restKeys.every((set) => set.has(leafKey(l)));\n\n return flatFirst\n .map((section) => ({\n ...section,\n rows: section.rows\n .map((row) => ({ ...row, leaves: row.leaves.filter(keep) }))\n .filter((row) => row.leaves.length > 0),\n }))\n .filter((section) => section.rows.length > 0);\n}\n\n/** Read a node value at a dotted path of any depth (`pose.x`,\n * `data.style.fontSize`, `data.style.fill.color`). Returns `undefined` if\n * the path is dotless (mirrors `commit`'s no-op on a malformed schema\n * key) or if any intermediate segment is missing or not an object. */\nexport function nodeValueAt(node: AnyNode, path: string): unknown {\n const segments = path.split('.');\n if (segments.length < 2) return undefined;\n const head = segments[0];\n let cursor: unknown = head === 'pose' ? node.pose : head === 'data' ? node.data : undefined;\n for (let i = 1; i < segments.length; i++) {\n if (cursor == null || typeof cursor !== 'object') return undefined;\n cursor = (cursor as Record<string, unknown>)[segments[i]];\n }\n return cursor;\n}\n\n/** Immutably set `value` at a dotted path within `root`, cloning each level\n * on the way down so React sees new object identities. Arrays stay arrays\n * (an array intermediate is shallow-copied, not flattened into `{0: ...}`)\n * — this is the write-side twin of `nodeValueAt`, so a schema author who\n * gets a working read gets a working write. */\nexport function setAtPath(root: object, segments: readonly string[], value: unknown): object {\n const [head, ...rest] = segments;\n if (rest.length === 0) {\n return Array.isArray(root)\n ? Object.assign([...root], { [head]: value })\n : { ...root, [head]: value };\n }\n const child = (root as Record<string, unknown>)[head];\n const childObj = Array.isArray(child)\n ? [...child]\n : child != null && typeof child === 'object'\n ? { ...child }\n : {};\n const nested = setAtPath(childObj, rest, value);\n return Array.isArray(root)\n ? Object.assign([...root], { [head]: nested })\n : { ...root, [head]: nested };\n}\n\n/** Aggregate a path across nodes: the shared value, or `MIXED`. */\nexport function aggregateValue(\n nodes: readonly AnyNode[],\n path: string,\n): unknown | Mixed {\n let value: unknown;\n let first = true;\n for (const node of nodes) {\n const v = nodeValueAt(node, path);\n if (first) {\n value = v;\n first = false;\n } else if (!Object.is(v, value)) {\n return MIXED;\n }\n }\n return value;\n}\n\n/** `'rect ×2 · text'` — kinds in first-seen order with counts. */\nexport function kindBreakdown(kinds: readonly string[]): string {\n const counts = new Map<string, number>();\n for (const k of kin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C;EAAE,GAAGwE;GAAOH,IAAOrE;CAAO;AAChC;AAGA,SAAgB0E,EACd,GACA,GACiB;CACjB,IAAID,GACAhB,IAAQ;CACZ,KAAK,IAAMvB,KAAQyC,GAAO;EACxB,IAAMpE,IAAI4D,EAAYjC,GAAMhC,CAAI;EAChC,IAAIuD,GAEF,AADA,IAAQlD,GACR,IAAQ;OACH,IAAI,CAAC,OAAO,GAAGA,GAAGkE,CAAK,GAC5B,OAAOG;CAEX;CACA,OAAOH;AACT;AAGA,SAAgBI,EAAc,GAAkC;CAC9D,IAAMC,oBAAS,IAAI,IAAoB;CACvC,KAAK,IAAMvB,KAAKJ,GAAO,EAAO,IAAII,IAAIuB,EAAO,IAAIvB,CAAC,KAAK,KAAK,CAAC;CAC7D,OAAO,CAAC,GAAGuB,EAAO,QAAQ,CAAC,CAAC,CACzB,KAAK,CAACvB,GAAGlB,OAAQA,IAAI,IAAI,GAAGkB,EAAE,IAAIlB,MAAMkB,CAAE,CAAC,CAC3C,KAAK,KAAK;AACf"}
@@ -1,2 +1,2 @@
1
- import { n as e, r as t, t as n } from "../../chunks/BandEditor-Dd0egAgE.js";
1
+ import { n as e, r as t, t as n } from "../../chunks/BandEditor-B4jUAHQ8.js";
2
2
  export { n as BandEditor, e as linearScale, t as logScale };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../../chunks/ColorField-BLs9fbeq.js";
1
+ import { t as e } from "../../chunks/ColorField-BwlelY26.js";
2
2
  export { e as ColorField };
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "../../chunks/ComboBox-CuTLRmUg.js";
1
+ import { n as e, t } from "../../chunks/ComboBox-DKln_mOd.js";
2
2
  export { t as ComboBox, e as ComboBoxItem };