@weasel-js/path-tools 0.0.0-stage → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +70 -2
- package/dist/icons.table.d.ts +6 -0
- package/dist/icons.table.js +129 -0
- package/dist/icons.table.js.map +1 -0
- package/dist/icons.table.json +121 -0
- package/dist/index.d.ts +1550 -0
- package/dist/index.js +3900 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/balance/handleBalance.ts","../src/balance/balanceMarks.ts","../src/bridge/bridge.ts","../src/comb/comb.ts","../src/cornerShape/editCorner.ts","../src/cornerShape/cornerCommands.ts","../src/cornerShape/cornerWidgets.ts","../src/constraints/pathConstraints.ts","../src/constraints/constraintLinks.ts","../src/constraints/constraintGlyphs.ts","../src/constraints/constraintsExtension.ts","../src/constraints/anchorConstraints.ts","../src/shared/scenePaths.ts","../src/extend/extendToMeet.ts","../src/handleLocks/handleLocks.tsx","../src/handleSnap/handleSnap.ts","../src/softSelection/softSelection.ts","../src/harmonize/harmonize.tsx","../src/lengthen/lengthenPath.ts","../src/pathStructure/directionMarks.ts","../src/pathStructure/pathStructure.ts","../src/segmentType/convertSegments.ts","../src/anchorSelect/anchorSelect.ts","../src/extremes/addExtremes.ts","../src/resample/resample.ts","../src/pathEffects/params.ts","../src/pathEffects/actions.ts","../src/simplifyBrush/simplifyBrush.ts","../src/smudge/smudgeBrush.ts","../src/spiro/spiroShape.ts","../src/spiro/spiroCommands.ts","../src/spiro/spiroMarkers.ts","../src/spiro/spiroInsertPoint.ts","../src/spiro/spiroRepresentation.ts","../src/spiro/spiroPreset.ts","../src/trim/trimSegment.ts","../src/warp/pathWarp.ts","../src/warp/warpTargets.ts","../src/warp/warpActions.ts","../src/presets.ts","../src/shared/strokeClickTool.ts","../src/trim/piecePreview.ts","../src/trim/useTrimTool.ts","../src/extend/useExtendTool.ts","../src/smudge/useSmudgeBrushTool.ts","../src/warp/warpHandles.ts","../src/warp/useWarpTool.ts","../src/shapeBuilder/shapeBuilder.ts","../src/shapeBuilder/shapeBuilderActions.ts","../src/shapeBuilder/useShapeBuilderTool.ts","../src/girth/widthEdit.ts","../src/girth/girthActions.ts","../src/girth/girthOverlay.ts","../src/girth/useGirthTool.ts","../src/spiro/spiroPreviewLayer.ts","../src/spiro/useSpiroTool.ts","../src/cornerShape/cornerControls.ts","../src/cornerShape/useCornerControls.ts"],"names":["at","line","pathOperationTags","commitAnchorEdit","ActionDisabledReason","linePath","pathEditToolActive","inPlane","pathEditPreview","along","editingLayer","cornerFrames","cornerSpecAt","withCorner","depOf","toward","b","same","PathBuilder","editedPath","pathAnchorPoints","resolveEditablePathOf","pathToAnchors","openEndAt","editAnchorSetTracked","circlePath","locateAnchor","anchorEditWouldChange","commitOps","requiresAnchorSelection","LABEL","anchorAt","count","reshapeOps","num","resolveParams","pathEditToolAction","radiusOf","selectedPathNodes","shapeOf","isSpiroKind","createSetDataOp","polygonFromPoints","spiroControlPath","deleteNode","classifyPathStorage","toWorld","boundsOfPath","identity","withPath","reshapeTo","warpControls","applyToPoint","invert","createEmitter","transformPath","useMemo","defineTool","DEFAULT_OVERLAY_STYLE","viewToTransform","pathWarpMap","polylineFromPoints","useLatest","found","edge","len","start","nearestSegmentT","REQUIRES","pxExtent","ACCENT","circle","ellipsePath","worldToScreen","vertexHalfWidths","spiroToPath","withinPxRadius","commit","cornerShapeK"],"mappings":";;;;;;;;;;;;;;AAwCA,SAAS,UAAA,CACP,KACA,IAAA,EACgF;AAChF,EAAA,IAAI,CAAC,GAAA,EAAK,SAAA,IAAa,CAAC,MAAM,OAAO,IAAA;AACrC,EAAA,MAAM,CAAA,GAAI,IAAA,CAAK,KAAA,CAAM,iBAAiB,CAAA;AACtC,EAAA,IAAI,CAAC,GAAG,OAAO,IAAA;AACf,EAAA,MAAM,IAAA,GAAO,GAAA,CAAI,eAAA,CA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AAO,QAAA,EAAS;AAC/D","file":"index.js","sourcesContent":["/**\n * The balance grip on each curved segment of the path being edited, midway\n * along the line joining its two handle tips:\n *\n * - `balanceHandles` — drag the grip to scale both handles together, each\n * along its own direction, so the segment fills out toward its corner or\n * flattens toward its chord without turning at either end.\n * - `equalizeHandles` — double-click the grip to give both handles the same\n * proportion of the way to that corner.\n *\n * The grips are the `balance:N` affordances path edit lays out, shown and\n * hit-tested only while chrome-caps shows `path-edit.balance`. N is the flat\n * index of the anchor the segment starts at.\n *\n * Under a `pathSymmetry` dep a grip drag moves every image of both handles,\n * as `editAnchors` moves a dragged handle's. Both keep each handle's angle, so an angle lock holds through them. A length\n * lock in force for handle drags (the `editAnchors` dep's `handleLocks`, or Mod)\n * holds the drag still, as it would a handle drag with the angle held too.\n */\n\nimport {\n type Action, type ActionDeps, ActionDisabledReason, type ImmediateInvoker, type InvocationCtx, isBalanceGrip, type OngoingHandle,\n} from '@weasel-js/routing';\nimport {\n balanceFactorToward,\n editAnchorSetTracked,\n equalizeSegmentHandles,\n locateAnchor,\n pathToAnchors,\n scaleSegmentHandles,\n type AnchorSet,\n type PointOrigin,\n type PolygonPath,\n} from '@weasel-js/geom';\nimport {\n commitAnchorEdit, type EditAnchorsDep, editedPathSymmetries, editingLayer, HANDLE_LOCK_ROLES, inPlane, locksInForce, pathEditPreview, pathEditToolActive, pathOperationTags,\n} from '@weasel-js/core';\nimport { icon } from '../icons.gen';\n\n/** The segment a `balance:N` affordance names, on the path being edited. */\nfunction gripTarget(\n dep: EditAnchorsDep | undefined,\n kind: string | undefined,\n): { dep: EditAnchorsDep; path: PolygonPath; sub: number; segIdx: number } | null {\n if (!dep?.editingId || !kind) return null;\n const m = kind.match(/^balance:(\\d+)$/);\n if (!m) return null;\n const path = dep.getEditablePath(dep.editingId) as PolygonPath | null | undefined;\n if (!path || path.kind !== 'polygon') return null;\n const loc = locateAnchor(pathToAnchors(path) as AnchorSet, parseInt(m[1], 10));\n return loc ? { dep, path, sub: loc.sub, segIdx: loc.idx } : null;\n}\n\nconst NO_LOCKS = { angle: false, length: false };\n\n/** Enabled while a path is open and no path-edit tool has the pointer. */\nfunction gripEnabled(deps: ActionDeps | undefined): true | ActionDisabledReason {\n if (!deps?.editAnchors?.editingId || pathEditToolActive(deps)) return ActionDisabledReason.NotApplicable;\n return true;\n}\n\n/** Drag a segment's balance grip to scale both its handles together. */\nexport const balanceHandlesAction: Action & { requires: string[] } = inPlane({\n id: 'balanceHandles',\n label: 'Balance handles',\n icon: /* @icon */ 'path-tools:balanceHandles',\n tags: pathOperationTags('drag'),\n // Ties the marquee's `empty` and move's `selected-body` on specificity and\n // registers ahead of the marquee; move turns path-edit presses down itself.\n defaultBinding: { kind: 'drag', target: { kindOf: isBalanceGrip } },\n cursor: 'grab',\n eligible: { capability: 'edits-anchors' },\n modifierRoles: HANDLE_LOCK_ROLES,\n requires: ['editAnchors', 'pathSymmetry'],\n invoker: {\n timing: 'ongoing',\n start(ctx: InvocationCtx): OngoingHandle {\n const target = gripTarget(ctx.deps.editAnchors, ctx.drag?.affordance?.kind);\n if (!target) return {};\n const { dep, path: originPath, sub, segIdx } = target;\n const id = dep.editingId;\n const origin = pathToAnchors(originPath) as AnchorSet;\n const symmetries = editedPathSymmetries(ctx.deps.pathSymmetry, id, origin);\n // The grip is wherever the press landed within its radius; measure the\n // drag from there so the grab doesn't jump.\n const press = { x: ctx.world.x, y: ctx.world.y };\n const pressFactor = balanceFactorToward(origin, sub, segIdx, press);\n let current: { path: PolygonPath; origins?: readonly (PointOrigin | null)[] } | null = null;\n const preview = pathEditPreview(dep, id, () => current?.path ?? null);\n if (!preview) return {};\n\n return {\n kind: 'balance-handles',\n onMove(moveCtx: InvocationCtx): void {\n // Read live, like a handle drag's, so a lock can change mid-drag.\n const held = (moveCtx.deps.editAnchors ?? dep).handleLocks ?? NO_LOCKS;\n if (locksInForce(held, moveCtx).length) {\n current = null;\n return;\n }\n const at = balanceFactorToward(origin, sub, segIdx, moveCtx.world);\n const factor = pressFactor > 0 ? at / pressFactor : at;\n current = editAnchorSetTracked(originPath, (set) => scaleSegmentHandles(set, sub, segIdx, factor, symmetries)) ?? current;\n },\n onEnd(_endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n const done = current;\n current = null;\n if (reason === 'cancel' || !done) return;\n dep.applyEdit(id, done.path, 'Balance handles', done.origins);\n },\n previewIds: preview.previewIds,\n previewPose: preview.previewPose,\n previewData: preview.previewData,\n };\n },\n },\n enabled: gripEnabled,\n}, editingLayer);\n\n/** Double-click a segment's balance grip to even out its handles' proportions. */\nexport const equalizeHandlesAction: Action & { requires: string[] } = {\n id: 'equalizeHandles',\n label: 'Equalize handles',\n icon: /* @icon */ 'path-tools:equalizeHandles',\n tags: pathOperationTags('click'),\n defaultBinding: { kind: 'doubleClick', target: { kindOf: isBalanceGrip } },\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const kind = (params?.affordance as { kind?: string } | undefined)?.kind;\n const target = gripTarget(deps.editAnchors, kind);\n if (!target) return;\n const { dep, sub, segIdx } = target;\n commitAnchorEdit(dep, 'Equalize handles', (set) => equalizeSegmentHandles(set, sub, segIdx));\n },\n } as ImmediateInvoker,\n enabled: gripEnabled,\n};\n","/**\n * The balance lines path edit can draw over the open path: one per curved\n * segment, from its first handle's tip to its second's, with the grip\n * `balanceHandles` drags at the middle, pressed as `balance:N`.\n */\n\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport { circlePath, handleBalances, linePath, type AnchorSet, type Point } from '@weasel-js/geom';\nimport type { PathEditExtension } from '@weasel-js/core';\n\n/** Chrome-caps id the balance lines and their grips are drawn and hit-tested\n * under. Off by default. */\nexport const PATH_BALANCE_CHROME_ID = 'path-edit.balance';\n\n/** How the balance lines are drawn. */\nexport interface PathEditBalanceStyle {\n /** Color of the line between a segment's handle tips and of its grip's rim. */\n color?: string;\n /** Fill of the grip. */\n gripFill?: string;\n /** Radius of the grip, in screen px. Default 4. */\n gripRadiusPx?: number;\n}\n\nconst BALANCE_DEFAULTS: Required<PathEditBalanceStyle> = {\n color: '#9b6bd6',\n gripFill: '#ffffff',\n gripRadiusPx: 4,\n};\n\n/** Draw commands for `set`'s balance lines and their grips, in screen space. */\nexport function balanceCommands(set: AnchorSet, toScreen: (p: Point) => Point, style: PathEditBalanceStyle = {}): DrawCommand[] {\n const { color, gripFill, gripRadiusPx } = { ...BALANCE_DEFAULTS, ...style };\n const paint = { kind: 'solid' as const, color };\n const out: DrawCommand[] = [];\n for (const line of handleBalances(set)) {\n const grip = toScreen(line.grip);\n out.push({\n kind: 'path',\n path: linePath(toScreen(line.from), toScreen(line.to)),\n stroke: { paint, width: 1 },\n });\n out.push({\n kind: 'path',\n path: circlePath(grip.x, grip.y, gripRadiusPx),\n fill: { paint: { kind: 'solid', color: gripFill } },\n stroke: { paint, width: 1.5 },\n });\n }\n return out;\n}\n\n/** The balance lines as a path-edit extension: drawn, and their grips\n * pressed, while chrome-caps shows {@link PATH_BALANCE_CHROME_ID}. */\nexport function createBalanceExtension(style: PathEditBalanceStyle = {}): PathEditExtension {\n return {\n id: 'balance',\n marks: (ctx) => (ctx.isVisible(PATH_BALANCE_CHROME_ID) ? balanceCommands(ctx.anchors, ctx.toScreen, style) : []),\n parts: (target) => handleBalances(target.anchors).map((line) => ({\n x: line.grip.x,\n y: line.grip.y,\n hitKind: `balance:${line.flat}`,\n chromeId: PATH_BALANCE_CHROME_ID,\n })),\n };\n}\n","/**\n * Bridge: join open path ends with a curve that leaves each end along the\n * direction its path was heading, on whole paths or on the two anchors\n * selected in path edit.\n */\nimport { type Action, ActionDisabledReason, type ImmediateInvoker } from '@weasel-js/routing';\nimport {\n anchorEditWouldChange, commitAnchorEdit, depOf, joinPathsCommand, joinSelectedAnchors, pathOperationTags,\n} from '@weasel-js/core';\nimport { icon } from '../icons.gen';\n\n/** How long Bridge makes each handle, as a fraction of the gap, when its\n * params name no `tension`. */\nexport const DEFAULT_BRIDGE_TENSION = 0.4;\n\n/** A bridge's `params.tension`, or the default. Negative reads as `0`. */\nexport function bridgeTensionOf(params: Record<string, unknown> | undefined): number {\n const t = params?.tension;\n return typeof t === 'number' && Number.isFinite(t) ? Math.max(0, t) : DEFAULT_BRIDGE_TENSION;\n}\n\n/**\n * Bridge open paths: as `joinPaths`, but the gap is spanned by\n * a curve leaving each end along the direction its path was heading, each\n * handle `params.tension` times the gap long (default\n * {@link DEFAULT_BRIDGE_TENSION}). Two paths become one. In path edit,\n * `bridgeAnchors` bridges the two selected anchors instead.\n */\nexport const bridgePathsAction = joinPathsCommand(\n {\n id: 'bridgePaths',\n label: 'Bridge',\n icon: /* @icon */ 'core:bridge',\n // `code` too: with Shift held the key reads as `J`.\n defaultBinding: { kind: 'key', key: 'j', code: 'KeyJ', mods: { mod: true, shift: true } },\n },\n (params) => ({ tension: bridgeTensionOf(params) }),\n);\n\nconst join = joinSelectedAnchors({});\n\n/**\n * Bridge the two selected anchors, each the end of an open\n * subpath, as `joinAnchors` does, but with a curve leaving each end along the\n * direction its path was heading, each handle `params.tension` times the gap\n * long (`bridgePaths`'s default when absent). The anchor selection is\n * cleared.\n */\nexport const bridgeAnchorsAction: Action & { requires: string[] } = {\n id: 'bridgeAnchors',\n label: 'Bridge anchors',\n tags: pathOperationTags('command'),\n icon: /* @icon */ 'core:bridge',\n group: 'anchors',\n defaultBinding: { kind: 'key', key: 'j', code: 'KeyJ', mods: { mod: true, shift: true } },\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const dep = depOf(deps);\n if (!dep || dep.selectedAnchors.size !== 2) return;\n const selected = [...dep.selectedAnchors];\n const bridge = joinSelectedAnchors({ tension: bridgeTensionOf(params) });\n if (commitAnchorEdit(dep, 'Bridge anchors', (set) => bridge(set, selected))) dep.setSelectedAnchors([]);\n },\n } as ImmediateInvoker,\n enabled: (deps) => {\n const dep = depOf(deps);\n if (!dep || dep.selectedAnchors.size !== 2) return ActionDisabledReason.SelectionRequired;\n const selected = [...dep.selectedAnchors];\n return anchorEditWouldChange(deps, (set) => join(set, selected)) ? true : ActionDisabledReason.NotApplicable;\n },\n};\n","/**\n * The curvature comb path edit can draw over the open path.\n */\n\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport { curvatureComb, linePath, polylineFromPoints, type AnchorSet, type Point } from '@weasel-js/geom';\nimport type { PathEditExtension } from '@weasel-js/core';\n\n/** Chrome-caps id the curvature comb is drawn under. Off by default. */\nexport const PATH_COMB_CHROME_ID = 'path-edit.comb';\n\n/** How the curvature comb is drawn. */\nexport interface PathEditCombOptions {\n /** Tooth length per unit of curvature, in world units: a tooth over a\n * stretch of radius r is `scale / r` long. Default 2000. */\n scale?: number;\n /** Teeth per segment, ends included. Default 24. */\n samplesPerSegment?: number;\n /** Color of the teeth and of the line through their tips. */\n color?: string;\n}\n\nconst COMB_DEFAULTS = { scale: 2000, samplesPerSegment: 24, color: 'rgba(224, 102, 58, 0.75)' };\n\n/** Draw commands for `set`'s curvature comb, in screen space. */\nexport function combCommands(set: AnchorSet, toScreen: (p: Point) => Point, opts: PathEditCombOptions = {}): DrawCommand[] {\n const { scale, samplesPerSegment, color } = { ...COMB_DEFAULTS, ...opts };\n const paint = { kind: 'solid' as const, color };\n const out: DrawCommand[] = [];\n for (const { teeth } of curvatureComb(set, { scale, samplesPerSegment })) {\n const tips = teeth.map((t) => toScreen({ x: t.tipX, y: t.tipY }));\n teeth.forEach((t, i) => {\n out.push({ kind: 'path', path: linePath(toScreen(t), tips[i]), stroke: { paint, width: 1 } });\n });\n out.push({ kind: 'path', path: polylineFromPoints(tips), stroke: { paint, width: 1.5 } });\n }\n return out;\n}\n\n/** The comb as a path-edit extension, drawn while chrome-caps shows\n * {@link PATH_COMB_CHROME_ID}. `options` is read every frame. */\nexport function createCombExtension(options: () => PathEditCombOptions | undefined = () => undefined): PathEditExtension {\n return {\n id: 'curvatureComb',\n marks: (ctx) => (ctx.isVisible(PATH_COMB_CHROME_ID) ? combCommands(ctx.anchors, ctx.toScreen, options()) : []),\n };\n}\n","/**\n * Corner shape in path edit: drag a corner's widget to set its radius.\n *\n * A drag measures how far the pointer moves along the corner's bisector and\n * turns that into a cut along the edges, clamped to the room the neighboring\n * corners leave. Pressing the widget of a selected anchor gives every\n * selected corner the same radius. The release commits one undo step.\n */\nimport {\n type Action, type ActionDeps, ActionDisabledReason, type InvocationCtx, isCornerWidget, type OngoingHandle,\n} from '@weasel-js/routing';\nimport {\n cornerFrames,\n cornerSpecAt,\n withCorner,\n type CornerFrame,\n type CornerShape,\n type PolygonPath,\n} from '@weasel-js/geom';\nimport {\n editingLayer, inPlane, pathEditPreview, pathEditToolActive, pathOperationTags, type EditAnchorsDep,\n} from '@weasel-js/core';\nimport { icon } from '../icons.gen';\n\n/** The shape a corner with no spec yet takes. */\nexport const DEFAULT_CORNER_SHAPE: CornerShape = 'round';\n\n/** Flat anchor index of a `corner:N` affordance kind, or null. */\nfunction cornerIndexOf(kind: string): number | null {\n const m = kind.match(/^corner:(\\d+)$/);\n return m ? parseInt(m[1], 10) : null;\n}\n\n/** The open path, when it is a polygon. */\nexport function editedPath(dep: EditAnchorsDep): PolygonPath | null {\n const p = dep.getEditablePath(dep.editingId) as PolygonPath | undefined;\n return p && p.kind === 'polygon' ? p : null;\n}\n\ninterface CornerTarget {\n frame: CornerFrame;\n shape: CornerShape;\n}\n\n/** `path` with `radius` on every target, each clamped to the room it has. */\nfunction withRadius(path: PolygonPath, targets: readonly CornerTarget[], radius: number): PolygonPath {\n let out = path;\n for (const { frame, shape } of targets) {\n out = withCorner(out, frame.index, { shape, radius: Math.max(0, Math.min(radius, frame.maxTrim)) });\n }\n return out;\n}\n\n/** Enabled while a path is open and no path-edit tool has the pointer. */\nfunction widgetEnabled(deps: ActionDeps | undefined): true | ActionDisabledReason {\n if (!deps?.editAnchors?.editingId || pathEditToolActive(deps)) return ActionDisabledReason.NotApplicable;\n return true;\n}\n\n/** Drag a corner widget to set the corner's radius. */\nexport const editCornerAction: Action & { requires: string[] } = inPlane({\n id: 'editCorner',\n icon: /* @icon */ 'path-tools:cornerRadius',\n label: 'Corner radius',\n tags: pathOperationTags('drag'),\n // Ties the marquee's `empty` and move's `selected-body` on specificity and\n // registers ahead of the marquee; move turns path-edit presses down itself.\n defaultBinding: { kind: 'drag', target: { kindOf: isCornerWidget } },\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors'],\n invoker: {\n timing: 'ongoing',\n start(ctx: InvocationCtx): OngoingHandle {\n const dep = ctx.deps.editAnchors;\n const index = cornerIndexOf(ctx.drag?.affordance?.kind ?? '');\n if (!dep?.editingId || index === null) return {};\n const origin = editedPath(dep);\n if (!origin) return {};\n const frames = new Map(cornerFrames(origin).map((f) => [f.index, f]));\n const pressed = frames.get(index);\n if (!pressed) return {};\n const indices = dep.selectedAnchors.has(index) ? [...dep.selectedAnchors] : [index];\n const targets: CornerTarget[] = [];\n for (const i of indices) {\n const frame = frames.get(i);\n if (frame) targets.push({ frame, shape: cornerSpecAt(origin, i)?.shape ?? DEFAULT_CORNER_SHAPE });\n }\n const press = ctx.drag?.start ?? ctx.world;\n let current: PolygonPath = origin;\n let active = false;\n const preview = pathEditPreview(dep, dep.editingId, () => (active ? current : null));\n if (!preview) return {};\n const id = dep.editingId;\n return {\n kind: 'edit-corner',\n onMove(move: InvocationCtx): void {\n const along = (move.world.x - press.x) * pressed.bisector.x\n + (move.world.y - press.y) * pressed.bisector.y;\n const trim = Math.max(0, pressed.trim + along / Math.cos(pressed.halfAngle));\n current = withRadius(origin, targets, trim);\n active = true;\n },\n onEnd(_end: InvocationCtx, reason: 'commit' | 'cancel'): void {\n active = false;\n if (reason === 'cancel' || current === origin) return;\n dep.applyEdit(id, current, 'Corner radius');\n },\n previewIds: preview.previewIds,\n previewPose: preview.previewPose,\n previewData: preview.previewData,\n };\n },\n },\n enabled: widgetEnabled,\n}, editingLayer);\n","/**\n * Commands on the corners of the anchors selected in path edit: set their\n * shape or radius, or step their shape through the `corner-shape` keywords.\n */\nimport { type Action, type ActionDeps, ActionDisabledReason, type ImmediateInvoker } from '@weasel-js/routing';\nimport {\n cornerFrames,\n cornerSpecAt,\n isCornerShape,\n nextCornerShape,\n withCorner,\n type CornerFrame,\n type CornerShape,\n type PolygonPath,\n} from '@weasel-js/geom';\nimport { depOf, pathOperationTags, requiresAnchorSelection, type EditAnchorsDep } from '@weasel-js/core';\nimport { DEFAULT_CORNER_SHAPE, editedPath } from './editCorner';\nimport { icon } from '../icons.gen';\n\n/** The share of a corner's room that a shape given to a sharp corner cuts. */\nexport const DEFAULT_CORNER_TRIM_SHARE = 0.25;\n\n/** The selected anchors of the edited path that can take a corner. */\nfunction selectedCorners(dep: EditAnchorsDep, path: PolygonPath): CornerFrame[] {\n return cornerFrames(path).filter((f) => dep.selectedAnchors.has(f.index));\n}\n\n/** What a corner command changes; a field left out is kept. */\ninterface CornerChange {\n shape?: CornerShape;\n radius?: number;\n}\n\n/**\n * `path` with `change` made to every corner in `frames`, each radius clamped\n * to the room its corner has. A shape given to a sharp corner, with no\n * radius, cuts {@link DEFAULT_CORNER_TRIM_SHARE} of its room: every shape\n * looks alike at no radius.\n */\nfunction changeCorners(path: PolygonPath, frames: readonly CornerFrame[], change: CornerChange): PolygonPath {\n let out = path;\n for (const f of frames) {\n const spec = cornerSpecAt(path, f.index);\n const shape = change.shape ?? spec?.shape ?? DEFAULT_CORNER_SHAPE;\n let radius = Math.max(0, change.radius ?? spec?.radius ?? 0);\n if (change.shape !== undefined && change.radius === undefined && radius <= 0) {\n radius = DEFAULT_CORNER_TRIM_SHARE * f.maxTrim;\n }\n out = withCorner(out, f.index, { shape, radius: Math.min(radius, f.maxTrim) });\n }\n return out;\n}\n\nfunction commitChange(deps: ActionDeps | undefined, label: string, change: (frames: CornerFrame[], path: PolygonPath) => CornerChange): void {\n const dep = depOf(deps);\n const path = dep && editedPath(dep);\n if (!dep || !path) return;\n const frames = selectedCorners(dep, path);\n if (frames.length === 0) return;\n dep.applyEdit(dep.editingId, changeCorners(path, frames, change(frames, path)), label);\n}\n\nfunction cornersSelected(deps: ActionDeps | undefined): true | ActionDisabledReason {\n const selection = requiresAnchorSelection(deps);\n if (selection !== true) return selection;\n const dep = depOf(deps);\n const path = dep && editedPath(dep);\n return dep && path && selectedCorners(dep, path).length > 0 ? true : ActionDisabledReason.NotApplicable;\n}\n\n/**\n * Set the selected corners' shape, radius, or both, from the `shape` (a\n * keyword or a finite `superellipse()` parameter) and `radius` params; each\n * is left alone when its param is absent, except that a shape given to a\n * sharp corner also gives it a radius. A UI control's action: it has no\n * default binding.\n */\nexport const setCornersAction: Action & { requires: string[] } = {\n id: 'setCorners',\n icon: /* @icon */ 'path-tools:cornerRadius',\n label: 'Set corners',\n tags: pathOperationTags('command'),\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const shape = isCornerShape(params?.shape) ? params.shape : undefined;\n const radius = typeof params?.radius === 'number' && Number.isFinite(params.radius) ? params.radius : undefined;\n if (shape === undefined && radius === undefined) return;\n commitChange(deps, 'Set corners', () => ({\n ...(shape !== undefined ? { shape } : {}),\n ...(radius !== undefined ? { radius } : {}),\n }));\n },\n } as ImmediateInvoker,\n enabled: cornersSelected,\n};\n\n/**\n * Step the selected corners to the next `corner-shape` keyword, keeping\n * their radius. Every one takes the keyword after the first selected\n * corner's shape, so a mixed selection comes out alike, and a sharp corner\n * gets a radius that shows it.\n */\nexport const cycleCornerShapeAction: Action & { requires: string[] } = {\n id: 'cycleCornerShape',\n icon: /* @icon */ 'path-tools:cornerShape',\n label: 'Next corner shape',\n tags: pathOperationTags('command'),\n group: 'anchors',\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors'],\n invoker: {\n timing: 'immediate',\n run: (deps) => commitChange(deps, 'Next corner shape', (frames, path) => ({\n shape: nextCornerShape(cornerSpecAt(path, frames[0].index)?.shape ?? DEFAULT_CORNER_SHAPE),\n })),\n } as ImmediateInvoker,\n enabled: cornersSelected,\n};\n","/**\n * The corner widgets path edit shows on the open path: one inside each corner\n * anchor, at the middle of its cut, pushed a fixed distance further in on\n * screen so that it clears the anchor square at a zero radius. The overlay\n * paints it and the hit-test presses it, as `corner:N`, from this one\n * placement.\n */\nimport {\n cornerFrames, cornerShapeK, cornerShapePieces, cornerSpecAt, PathBuilder, standoff,\n type CornerFrame, type PolygonPath, type Scale2, type View,\n} from '@weasel-js/geom';\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport { DEFAULT_OVERLAY_STYLE, type PathEditExtension } from '@weasel-js/core';\n\n/** Chrome-caps id the corner widgets are drawn and hit-tested under. On by\n * default. */\nexport const PATH_CORNERS_CHROME_ID = 'path-edit.corners';\n\n/** Screen distance from the middle of a corner's cut to its widget. */\nexport const CORNER_WIDGET_STANDOFF_PX = 14;\n\n/** Below this half-angle short of straight, an anchor is too flat to offer a\n * widget; a freehand stroke would otherwise wear one at every vertex. */\nconst MIN_WIDGET_TURN = 0.05;\n\n/** The corner anchors of `path` that show a widget. */\nexport function cornerWidgetFrames(path: PolygonPath): CornerFrame[] {\n return cornerFrames(path).filter((f) => f.halfAngle < Math.PI / 2 - MIN_WIDGET_TURN);\n}\n\n/** The middle of the corner's cut, in world coords: the anchor itself while\n * the corner has no radius. */\nexport function cornerCutMiddle(frame: CornerFrame): { x: number; y: number } {\n const d = frame.trim * Math.cos(frame.halfAngle);\n return { x: frame.x + frame.bisector.x * d, y: frame.y + frame.bisector.y * d };\n}\n\n/** The widget's position in world coords under a view of `scale`. */\nexport function cornerWidgetAt(frame: CornerFrame, scale: Scale2): { x: number; y: number } {\n const at = standoff(cornerCutMiddle(frame), frame.bisector, CORNER_WIDGET_STANDOFF_PX, scale);\n return { x: at.x, y: at.y };\n}\n\n/** Half the side of a widget's glyph, in screen pixels. */\nconst GLYPH_HALF_PX = 4.5;\n\n/** How the widgets are drawn. */\nexport interface CornerWidgetStyle {\n /** Default: path edit's anchor fill. */\n fill?: string;\n /** Default: path edit's anchor stroke. */\n stroke?: string;\n}\n\n/** Hit radius of a widget, in screen px: under the anchor's, which wins\n * where the two overlap. */\nconst WIDGET_HIT_RADIUS_PX = 6;\n\ntype V = { x: number; y: number };\n\n/** A square glyph centered at `c` whose corner facing along `toward` is\n * cut by the superellipse of parameter `k`: the shape the corner has, drawn\n * small and turned to face it. */\nfunction cornerGlyph(c: V, toward: V, k: number): PolygonPath {\n const h = GLYPH_HALF_PX;\n const r2 = Math.SQRT1_2;\n const e1 = { x: (toward.x - toward.y) * r2, y: (toward.x + toward.y) * r2 };\n const e2 = { x: (toward.x + toward.y) * r2, y: (toward.y - toward.x) * r2 };\n const at = (a: number, b: number): V => ({ x: c.x + a * e1.x + b * e2.x, y: c.y + a * e1.y + b * e2.y });\n const cut = 1.2 * h;\n const outer = at(h, h);\n const b = new PathBuilder().moveTo(at(-h, -h).x, at(-h, -h).y).lineTo(at(h, -h).x, at(h, -h).y);\n const start = at(h, h - cut);\n b.lineTo(start.x, start.y);\n for (const piece of cornerShapePieces(k, { start, end: at(h - cut, h), outer })) {\n if (piece.kind === 'line') b.lineTo(piece.to.x, piece.to.y);\n else b.curveTo(piece.c1.x, piece.c1.y, piece.c2.x, piece.c2.y, piece.to.x, piece.to.y);\n }\n const last = at(-h, h);\n return b.lineTo(last.x, last.y).close().build();\n}\n\n/**\n * The widget of every corner anchor of `path`, in screen space: a small\n * square whose corner toward the anchor is cut in the corner's shape. A\n * corner with no spec draws as round, the shape a drag gives it.\n */\nexport function cornerWidgetCommands(path: PolygonPath, view: View, style: CornerWidgetStyle = {}): DrawCommand[] {\n const out: DrawCommand[] = [];\n const fill = { paint: { kind: 'solid' as const, color: style.fill ?? DEFAULT_OVERLAY_STYLE.anchorFill } };\n const stroke = { paint: { kind: 'solid' as const, color: style.stroke ?? DEFAULT_OVERLAY_STYLE.anchorStroke }, width: 1 };\n for (const frame of cornerWidgetFrames(path)) {\n const w = cornerWidgetAt(frame, view.scale);\n const x = (w.x - view.x) * view.scale.x;\n const y = (w.y - view.y) * view.scale.y;\n // On screen, the anchor lies back along the bisector.\n const bx = -frame.bisector.x * view.scale.x, by = -frame.bisector.y * view.scale.y;\n const bl = Math.hypot(bx, by) || 1;\n const k = cornerShapeK(cornerSpecAt(path, frame.index)?.shape ?? 'round');\n out.push({ kind: 'path', path: cornerGlyph({ x, y }, { x: bx / bl, y: by / bl }, k), fill, stroke });\n }\n return out;\n}\n\n/** The corner widgets as a path-edit extension: drawn, and pressed as\n * `corner:N`, while chrome-caps shows {@link PATH_CORNERS_CHROME_ID}. */\nexport function createCornerWidgetsExtension(style: CornerWidgetStyle = {}): PathEditExtension {\n return {\n id: 'cornerShape',\n marks: (ctx) => (ctx.isVisible(PATH_CORNERS_CHROME_ID) ? cornerWidgetCommands(ctx.path, ctx.view, style) : []),\n parts: (target) => cornerWidgetFrames(target.path).map((f) => ({\n ...cornerCutMiddle(f),\n hitKind: `corner:${f.index}`,\n chromeId: PATH_CORNERS_CHROME_ID,\n hitRadiusPx: WIDGET_HIT_RADIUS_PX,\n standoff: { px: CORNER_WIDGET_STANDOFF_PX, normal: f.bisector },\n })),\n };\n}\n","/**\n * A node's path constraints: kept as `data.constraints`, numbered by the\n * anchors of its editable polygon, and solved in the frame that polygon is\n * drawn in, so `horizontal` on a rotated `data.path` node turns with it.\n */\nimport {\n conflictingConstraints,\n constrainPathEdit,\n pathAnchorPoints,\n solvePathConstraints,\n unsatisfiedConstraints,\n type PathConstraint,\n type PointOrigin,\n type PolygonPath,\n} from '@weasel-js/geom';\nimport { classifyPathStorage, resolveEditablePathOf, type EditableShape } from '@weasel-js/core';\n\nconst NONE: readonly PathConstraint[] = [];\n\n/** The constraints a node's data holds, or none. */\nexport function constraintsOf(data: unknown): readonly PathConstraint[] {\n const list = (data as { constraints?: unknown } | null | undefined)?.constraints;\n return Array.isArray(list) ? (list as PathConstraint[]) : NONE;\n}\n\n/** Radians the frame `horizontal` and `vertical` read is turned from the world's: a `data.path` node's rotation. */\nexport function constraintAxisOf(node: EditableShape | null | undefined): number {\n const storage = classifyPathStorage(node);\n return storage?.kind === 'data' ? (storage.pose as { rotation?: number }).rotation ?? 0 : 0;\n}\n\n/**\n * Indices of `constraints` in conflict over `path`'s anchors: those that do\n * not hold, and with them every member of a smallest set that cannot all hold\n * together (`conflictingConstraints`). Sorted.\n */\nexport function conflictsIn(path: PolygonPath, constraints: readonly PathConstraint[], axisAngle: number): number[] {\n const points = pathAnchorPoints(path);\n const failing = unsatisfiedConstraints(points, constraints, { axisAngle });\n if (failing.length === 0) return [];\n const set = new Set([...failing, ...conflictingConstraints(points, constraints, { axisAngle })]);\n return [...set].sort((a, b) => a - b);\n}\n\n/**\n * Indices of `node`'s constraints that do not hold in its committed path, and\n * the others each conflict needs: every member of a smallest set that cannot\n * all hold. Edits leave the ones that do not hold out of the solve, and so\n * does a whole-shape transform — resize, rotate, flip — which carries the\n * list unchanged: a constraint the transform breaks, such as a set length\n * under a scale or an equal length under a non-uniform one, is reported here\n * rather than solved back.\n */\nexport function constraintConflictsOf(node: EditableShape | null | undefined): number[] {\n const constraints = constraintsOf(node?.data);\n const path = constraints.length > 0 ? resolveEditablePathOf(node) : null;\n if (!path) return [];\n return conflictsIn(path, constraints, constraintAxisOf(node));\n}\n\n/** What an edit of a constrained node commits: its path, and its constraints renumbered for it. */\nexport interface ConstrainedNodeEdit {\n path: PolygonPath;\n constraints: readonly PathConstraint[];\n}\n\n/**\n * `worldPath`, an edit of `node`'s committed path, finished so the node's\n * constraints hold. Null when they cannot. A node with no constraints gets\n * `worldPath` back as it is.\n */\nexport function constrainNodeEdit(\n node: EditableShape | null | undefined,\n worldPath: PolygonPath,\n origins?: readonly (PointOrigin | null)[],\n): ConstrainedNodeEdit | null {\n const constraints = constraintsOf(node?.data);\n const before = constraints.length > 0 ? resolveEditablePathOf(node) : null;\n if (!before) return { path: worldPath, constraints };\n const edit = constrainPathEdit(before, worldPath, constraints, { origins, axisAngle: constraintAxisOf(node) });\n if (!edit.converged) return null;\n const same = edit.constraints.length === constraints.length\n && edit.constraints.every((c, i) => JSON.stringify(c) === JSON.stringify(constraints[i]));\n return { path: edit.path, constraints: same ? constraints : edit.constraints };\n}\n\n/**\n * `node`'s path moved the least that makes `constraints` hold, and the\n * indices of those in conflict in the path it answers, as\n * {@link conflictsIn} reads them. When they cannot all hold the path is the\n * node's own, unmoved.\n */\nexport function solveNodeConstraints(\n node: EditableShape | null | undefined,\n constraints: readonly PathConstraint[],\n): { path: PolygonPath; conflicts: number[] } | null {\n const path = resolveEditablePathOf(node);\n if (!path) return null;\n const axisAngle = constraintAxisOf(node);\n const solved = solvePathConstraints(path, constraints, { axisAngle });\n if (solved.converged) return { path: solved.path, conflicts: [] };\n return { path, conflicts: conflictsIn(path, constraints, axisAngle) };\n}\n","/**\n * Constraints between nodes. A link is a node of its own: its `dependsOn`\n * names the nodes it ties, in order, and its `data.constraintLink` holds one\n * `PathConstraint` whose anchors are numbered over theirs one after another —\n * with two nodes of 4 and 5 anchors, anchor 6 is the second node's anchor 2.\n * Being a node, it is saved and undone with the scene, and deleting a node it\n * ties deletes it too. It draws nothing and takes no clicks; keep it on a\n * layer that is not exported, such as an annotation layer.\n *\n * An edit of any node a link ties solves every node the links reach in one\n * solve: an anchor held on another node's segment slides along it when\n * dragged and follows it when that node is edited.\n */\nimport {\n constrainPathsEdit,\n type PathConstraint,\n type PathLink,\n type PathsEditItem,\n type PointOrigin,\n type PolygonPath,\n} from '@weasel-js/geom';\nimport {\n registerNodeShape,\n type AddNodeSpec, type NodeId, type NodeShapeEntry, type PathEditFinishCtx, type PathEditOther, type RectPose,\n} from '@weasel-js/core';\nimport { constraintAxisOf, constraintsOf } from './pathConstraints';\n\n/** What a link node keeps in `data`. */\nexport interface ConstraintLinkData {\n constraintLink: PathConstraint;\n}\n\n/** The constraint `data` holds as a link, or null when it is not one. */\nexport function constraintLinkOf(data: unknown): PathConstraint | null {\n const c = (data as Partial<ConstraintLinkData> | null | undefined)?.constraintLink;\n return c && typeof c === 'object' && typeof c.kind === 'string' ? c : null;\n}\n\n/** The painter for link nodes: they draw nothing, have no outline to pick, and take no room. */\nexport const CONSTRAINT_LINK_SHAPE: NodeShapeEntry = {\n id: 'path-tools:constraint-link',\n matches: (node) => constraintLinkOf(node.data) !== null,\n paint: () => [],\n bounds: () => null,\n};\n\nlet linkShapeRegistered = false;\n\n/** Register {@link CONSTRAINT_LINK_SHAPE} ahead of the kit's painters, once. */\nexport function registerConstraintLinkShape(): void {\n if (linkShapeRegistered) return;\n linkShapeRegistered = true;\n registerNodeShape(CONSTRAINT_LINK_SHAPE, { priority: 'high' });\n}\n\n/** Options for {@link constraintLinkNode}. */\nexport interface ConstraintLinkNodeOptions<TPose> {\n layer: string;\n /** The nodes it ties, in the order its anchors number them. */\n nodes: readonly string[];\n constraint: PathConstraint;\n id?: string;\n /** Default: an empty box at the origin. */\n pose?: TPose;\n}\n\n/** A link node, ready for `scene.add`. Registers the painter that keeps link nodes from drawing. */\nexport function constraintLinkNode<TPose = RectPose>(\n opts: ConstraintLinkNodeOptions<TPose>,\n): AddNodeSpec<ConstraintLinkData, string, TPose> {\n registerConstraintLinkShape();\n return {\n kind: 'leaf',\n layer: opts.layer,\n pose: opts.pose ?? ({ x: 0, y: 0, width: 0, height: 0 } as TPose),\n data: { constraintLink: opts.constraint },\n dependsOn: opts.nodes as NodeId[],\n pickable: false,\n ...(opts.id ? { id: opts.id as NodeId } : {}),\n };\n}\n\ninterface Link {\n id: string;\n nodes: readonly string[];\n constraint: PathConstraint;\n}\n\nfunction linkAt(ctx: PathEditFinishCtx, id: string): Link | null {\n const node = ctx.node(id);\n const constraint = constraintLinkOf(node?.data);\n const nodes = node?.dependsOn;\n return constraint && Array.isArray(nodes) ? { id, nodes, constraint } : null;\n}\n\n/** Every link reached from `start` through the nodes links tie, and those nodes, `start` first. */\nfunction linkedFrom(ctx: PathEditFinishCtx, start: string): { nodes: string[]; links: Link[] } {\n const nodes = [start];\n const links = new Map<string, Link>();\n for (let k = 0; k < nodes.length; k++) {\n for (const id of ctx.dependents(nodes[k])) {\n const link = links.has(id) ? null : linkAt(ctx, id);\n if (!link) continue;\n links.set(id, link);\n for (const n of link.nodes) if (!nodes.includes(n)) nodes.push(n);\n }\n }\n return { nodes, links: [...links.values()] };\n}\n\nconst same = (a: readonly PathConstraint[], b: readonly PathConstraint[]) =>\n a.length === b.length && a.every((c, i) => JSON.stringify(c) === JSON.stringify(b[i]));\n\n/** What {@link finishLinkedEdit} answers. */\nexport interface LinkedEdit {\n path: PolygonPath;\n constraints: readonly PathConstraint[];\n others: PathEditOther[];\n}\n\n/**\n * `worldPath`, an edit of `ctx.id`, finished with every node links reach from\n * it solved alongside: its path, its own constraints renumbered, and the\n * other nodes and links that change with it. Undefined when no link reaches\n * it; null when the constraints cannot hold.\n */\nexport function finishLinkedEdit(\n ctx: PathEditFinishCtx,\n worldPath: PolygonPath,\n origins?: readonly (PointOrigin | null)[],\n): LinkedEdit | null | undefined {\n const { nodes, links } = linkedFrom(ctx, ctx.id);\n if (links.length === 0) return undefined;\n const items: PathsEditItem[] = [];\n for (const [k, id] of nodes.entries()) {\n const node = ctx.node(id);\n const before = ctx.path(id);\n if (!node || !before) return undefined;\n items.push({\n before,\n after: k === 0 ? worldPath : before,\n constraints: constraintsOf(node.data),\n axisAngle: constraintAxisOf(node),\n ...(k === 0 ? { origins } : {}),\n });\n }\n const pathLinks: PathLink[] = links.map((l) => ({ constraint: l.constraint, paths: l.nodes.map((n) => nodes.indexOf(n)) }));\n const done = constrainPathsEdit(items, pathLinks);\n if (!done.converged) return null;\n const others: PathEditOther[] = [];\n done.items.forEach((item, k) => {\n if (k === 0) return;\n const had = constraintsOf(ctx.node(nodes[k])?.data);\n const changed = !same(had, item.constraints);\n if (item.path !== items[k].after || changed) {\n others.push({ id: nodes[k], path: item.path, ...(changed ? { data: { constraints: item.constraints } } : {}) });\n }\n });\n done.links.forEach((l, k) => {\n const link = links[k];\n if (!l.constraint) others.push({ id: link.id, remove: true });\n else if (JSON.stringify(l.constraint) !== JSON.stringify(link.constraint)) {\n others.push({ id: link.id, data: { constraintLink: l.constraint } });\n }\n });\n const own = constraintsOf(ctx.node(ctx.id)?.data);\n const [first] = done.items;\n return { path: first.path, constraints: same(own, first.constraints) ? own : first.constraints, others };\n}\n","/**\n * The small marks the path-edit overlay draws for a path's constraints, in\n * screen pixels, and where a click finds them: a letter beside a horizontal\n * or vertical segment, paired strokes beside parallel ones, a foot beside\n * perpendicular ones, ticks across equal ones, a dimension bar beside a fixed\n * length, a pin by a fixed anchor, a ring by coincident ones, a line\n * touching a circle by a tangent one, and a dot on a line by one held on a\n * segment. Marks sit\n * on the inside of the shape, toward the centroid of its anchors, so a click\n * on one lands on the shape rather than on empty canvas.\n */\n\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport { constraintFits, PathBuilder, type AnchorPair, type PathConstraint } from '@weasel-js/geom';\n\ninterface Pt {\n x: number;\n y: number;\n}\n\n/** How far a mark sits off its segment or anchor. */\nconst OFFSET = 12;\n\n/** Colors for the constraint marks. */\nexport interface ConstraintGlyphStyle {\n /** A constraint that holds. */\n stroke: string;\n /** One that does not: it conflicts with the others. */\n conflictStroke: string;\n}\n\nconst at = (p: Pt, d: Pt, k: number): Pt => ({ x: p.x + d.x * k, y: p.y + d.y * k });\n\nfunction line(b: PathBuilder, p: Pt, q: Pt): void {\n b.moveTo(p.x, p.y).lineTo(q.x, q.y);\n}\n\nfunction centroidOf(points: readonly Pt[]): Pt {\n const n = points.length || 1;\n return { x: points.reduce((s, p) => s + p.x, 0) / n, y: points.reduce((s, p) => s + p.y, 0) / n };\n}\n\n/** The unit vector from `p` toward `to`, or straight down when they meet. */\nfunction toward(p: Pt, to: Pt): Pt {\n const len = Math.hypot(to.x - p.x, to.y - p.y);\n return len > 1e-9 ? { x: (to.x - p.x) / len, y: (to.y - p.y) / len } : { x: 0, y: 1 };\n}\n\n/** The segment's midpoint, direction, the inward normal its marks sit along, and where its mark sits. */\nfunction frameOf(points: readonly Pt[], [i, j]: AnchorPair, inside: Pt) {\n const a = points[i];\n const c = points[j];\n const len = Math.hypot(c.x - a.x, c.y - a.y);\n const u = len > 1e-9 ? { x: (c.x - a.x) / len, y: (c.y - a.y) / len } : { x: 1, y: 0 };\n const m = { x: (a.x + c.x) / 2, y: (a.y + c.y) / 2 };\n const left = { x: -u.y, y: u.x };\n const n = left.x * (inside.x - m.x) + left.y * (inside.y - m.y) < 0 ? { x: u.y, y: -u.x } : left;\n return { m, u, n, o: at(m, n, OFFSET) };\n}\n\nfunction segmentsOf(c: PathConstraint): readonly AnchorPair[] {\n switch (c.kind) {\n case 'fixed':\n case 'tangent':\n case 'onPath':\n case 'coincident': return [];\n case 'horizontal':\n case 'vertical':\n case 'length': return [c.segment];\n default: return c.segments;\n }\n}\n\n/** Where `c`'s marks sit, one point per mark. */\nfunction markCenters(points: readonly Pt[], c: PathConstraint, inside: Pt): Pt[] {\n if (c.kind === 'fixed' || c.kind === 'tangent' || c.kind === 'onPath' || c.kind === 'coincident') {\n const p = points[c.kind === 'coincident' ? c.anchors[0] : c.anchor];\n return [at(p, toward(p, inside), c.kind === 'fixed' ? 11 : 13)];\n }\n return segmentsOf(c).map((s) => {\n const f = frameOf(points, s, inside);\n return c.kind === 'equalLength' ? f.m : f.o;\n });\n}\n\nfunction letter(b: PathBuilder, o: Pt, which: 'H' | 'V'): void {\n if (which === 'H') {\n line(b, { x: o.x - 3, y: o.y - 4 }, { x: o.x - 3, y: o.y + 4 });\n line(b, { x: o.x + 3, y: o.y - 4 }, { x: o.x + 3, y: o.y + 4 });\n line(b, { x: o.x - 3, y: o.y }, { x: o.x + 3, y: o.y });\n } else {\n b.moveTo(o.x - 3, o.y - 4).lineTo(o.x, o.y + 4).lineTo(o.x + 3, o.y - 4);\n }\n}\n\nfunction segmentMark(b: PathBuilder, points: readonly Pt[], kind: PathConstraint['kind'], s: AnchorPair, inside: Pt): void {\n const { m, u, n, o } = frameOf(points, s, inside);\n switch (kind) {\n case 'parallel':\n for (const k of [-2, 2]) line(b, at(at(o, n, k), u, -4), at(at(o, n, k), u, 4));\n return;\n case 'perpendicular':\n line(b, at(o, u, -4), at(o, u, 4));\n line(b, o, at(o, n, 7));\n return;\n case 'equalLength':\n for (const k of [-2, 2]) line(b, at(at(m, u, k), n, -4), at(at(m, u, k), n, 4));\n return;\n case 'length':\n line(b, at(o, u, -8), at(o, u, 8));\n for (const k of [-8, 8]) line(b, at(at(o, u, k), n, -3), at(at(o, u, k), n, 3));\n return;\n default:\n letter(b, o, kind === 'vertical' ? 'V' : 'H');\n }\n}\n\nfunction glyphOf(b: PathBuilder, points: readonly Pt[], c: PathConstraint, inside: Pt): void {\n switch (c.kind) {\n case 'fixed': {\n // A pin standing on the anchor, pointing at it from inside the shape.\n const p = points[c.anchor];\n const d = toward(p, inside);\n const side = { x: -d.y, y: d.x };\n b.moveTo(...xy(at(p, d, 6))).lineTo(...xy(at(at(p, d, 14), side, -5)))\n .lineTo(...xy(at(at(p, d, 14), side, 5))).close();\n line(b, at(at(p, d, 17), side, -7), at(at(p, d, 17), side, 7));\n return;\n }\n case 'coincident': {\n // A ring inside the shape, tied to the anchor by a short stem.\n const p = points[c.anchors[0]];\n const d = toward(p, inside);\n const ring = at(p, d, 13);\n line(b, at(p, d, 6), at(p, d, 9));\n circle(b, ring, 4);\n return;\n }\n case 'tangent': {\n // A circle inside the shape and a line touching it on the anchor's side.\n const p = points[c.anchor];\n const d = toward(p, inside);\n const ring = at(p, d, 13);\n const side = { x: -d.y, y: d.x };\n const touch = at(ring, d, -4);\n line(b, at(touch, side, -6), at(touch, side, 6));\n circle(b, ring, 4);\n return;\n }\n case 'onPath': {\n // A dot on a short line, inside the shape by the anchor.\n const p = points[c.anchor];\n const d = toward(p, inside);\n const dot = at(p, d, 13);\n const side = { x: -d.y, y: d.x };\n line(b, at(dot, side, -7), at(dot, side, 7));\n circle(b, dot, 2.5);\n return;\n }\n default:\n for (const s of segmentsOf(c)) segmentMark(b, points, c.kind, s, inside);\n }\n}\n\nfunction circle(b: PathBuilder, o: Pt, r: number): void {\n b.moveTo(o.x + r, o.y);\n for (let k = 1; k <= 12; k++) b.lineTo(o.x + r * Math.cos((k * Math.PI) / 6), o.y + r * Math.sin((k * Math.PI) / 6));\n}\n\nconst xy = (p: Pt): [number, number] => [p.x, p.y];\n\n/**\n * Draw commands marking `constraints` on anchors at the screen positions\n * `points`, one per constraint, in `style.conflictStroke` for those listed\n * in `unsatisfied` and `style.stroke` for the rest; the one at `selected` is\n * drawn heavier. A constraint naming an anchor `points` does not have draws\n * nothing.\n */\nexport function constraintGlyphs(\n points: readonly Pt[],\n constraints: readonly PathConstraint[],\n unsatisfied: ReadonlySet<number>,\n style: ConstraintGlyphStyle,\n selected: number | null = null,\n): DrawCommand[] {\n const inside = centroidOf(points);\n const out: DrawCommand[] = [];\n constraints.forEach((c, i) => {\n if (!constraintFits(c, points.length)) return;\n const b = new PathBuilder();\n glyphOf(b, points, c, inside);\n const color = unsatisfied.has(i) ? style.conflictStroke : style.stroke;\n out.push({ kind: 'path', path: b.build(), stroke: { paint: { kind: 'solid', color }, width: i === selected ? 3 : 1.5 } });\n });\n return out;\n}\n\n/**\n * The index of the constraint whose mark is nearest `p`, within `radius`,\n * for marks drawn on anchors at the screen positions `points`; -1 for none.\n */\nexport function constraintMarkAt(\n points: readonly Pt[],\n constraints: readonly PathConstraint[],\n p: Pt,\n radius: number,\n): number {\n const inside = centroidOf(points);\n let best = -1;\n let bestD = radius;\n constraints.forEach((c, i) => {\n if (!constraintFits(c, points.length)) return;\n for (const m of markCenters(points, c, inside)) {\n const d = Math.hypot(m.x - p.x, m.y - p.y);\n if (d <= bestD) {\n bestD = d;\n best = i;\n }\n }\n });\n return best;\n}\n","/**\n * Path constraints in path edit: their marks on the open path, a click\n * selecting one, Delete removing it, and every edit finished so they hold.\n */\nimport { pathAnchorPoints, type PathConstraint, type PolygonPath } from '@weasel-js/geom';\nimport type { EditAnchorsDep, PathEditExtension, PathEditTarget } from '@weasel-js/core';\nimport { finishLinkedEdit, registerConstraintLinkShape } from './constraintLinks';\nimport { constraintGlyphs, constraintMarkAt, type ConstraintGlyphStyle } from './constraintGlyphs';\nimport { conflictsIn, constrainNodeEdit, constraintAxisOf, constraintsOf, solveNodeConstraints } from './pathConstraints';\n\n/** Owner id of the constraint marks, as `EditAnchorsDep.selectedMark` names them. */\nexport const CONSTRAINTS_EXTENSION_ID = 'constraints';\n\n/** Screen-pixel radius for \"this click landed on a constraint mark\". */\nconst MARK_CLICK_PX = 8;\n\nconst DEFAULT_STYLE: ConstraintGlyphStyle = { stroke: '#0e9f8e', conflictStroke: '#e5484d' };\n\n/** The edited node's world-space polygon, or null when it has none. */\nexport function editedPath(dep: EditAnchorsDep): PolygonPath | null {\n const p = dep.getEditablePath(dep.editingId) as PolygonPath | undefined;\n return p?.kind === 'polygon' ? p : null;\n}\n\n/**\n * Replace the open path's constraints with `constraints` as one history\n * entry, moving it the least that makes them all hold. When they cannot all\n * hold the path stays as it is and the list is stored all the same, the\n * conflict left for the marks to show. Clears the selected mark, since the\n * list is renumbered. Answers the indices in conflict, as\n * `constraintConflictsOf` names them — empty when every one holds — or null\n * when the dep cannot store.\n */\nexport function setConstraints(dep: EditAnchorsDep, constraints: readonly PathConstraint[], label: string): number[] | null {\n const node = dep.getNodeShape(dep.editingId);\n const solved = node && dep.store ? solveNodeConstraints(node, constraints) : null;\n if (!solved) return null;\n dep.setSelectedMark?.(null);\n dep.store!(dep.editingId, solved.path, label, { constraints: [...constraints] });\n return solved.conflicts;\n}\n\n/** The last answer per constraint list, so a frame that repaints an unchanged path asks for none. */\nconst conflictCache = new WeakMap<readonly PathConstraint[], { key: string; conflicts: ReadonlySet<number> }>();\n\n/** {@link conflictsIn} for `path`, answered from the cache when the list and its anchors are as last asked. */\nfunction conflictsOf(path: PolygonPath, constraints: readonly PathConstraint[], axisAngle: number): ReadonlySet<number> {\n const key = `${axisAngle};${Array.from(path.commands).join(',')};${Array.from(path.coords).join(',')}`;\n const hit = conflictCache.get(constraints);\n if (hit?.key === key) return hit.conflicts;\n const conflicts = new Set(conflictsIn(path, constraints, axisAngle));\n conflictCache.set(constraints, { key, conflicts });\n return conflicts;\n}\n\n/** The constraint selected in path edit, as an index into the open path's list, or null. */\nexport function selectedConstraintOf(dep: EditAnchorsDep): number | null {\n const mark = dep.selectedMark;\n return mark?.owner === CONSTRAINTS_EXTENSION_ID ? mark.index : null;\n}\n\nconst screenPoints = (target: PathEditTarget, toScreen: (p: { x: number; y: number }) => { x: number; y: number }) =>\n pathAnchorPoints(target.path).map(toScreen);\n\n/** The constraints extension, its marks drawn in `style`'s colors. */\nexport function createConstraintsExtension(style: Partial<ConstraintGlyphStyle> = {}): PathEditExtension {\n const colors = { ...DEFAULT_STYLE, ...style };\n registerConstraintLinkShape();\n return {\n id: CONSTRAINTS_EXTENSION_ID,\n marks(ctx) {\n const constraints = constraintsOf(ctx.node.data);\n if (constraints.length === 0) return [];\n const world = pathAnchorPoints(ctx.path);\n const conflicts = conflictsOf(ctx.path, constraints, constraintAxisOf(ctx.node));\n return constraintGlyphs(world.map(ctx.toScreen), constraints, conflicts, colors, ctx.selected);\n },\n markAt(target, toScreen, screen) {\n const constraints = constraintsOf(target.node.data);\n if (constraints.length === 0) return -1;\n return constraintMarkAt(screenPoints(target, toScreen), constraints, screen, MARK_CLICK_PX);\n },\n deleteMark(target, index, store) {\n const current = constraintsOf(target.node.data);\n if (index >= current.length) return;\n const kept = current.filter((_, i) => i !== index);\n const solved = solveNodeConstraints(target.node, kept);\n if (solved) store(target.id, solved.path, 'Delete constraint', { constraints: kept });\n },\n finishEdit(node, worldPath, origins, ctx) {\n const linked = ctx ? finishLinkedEdit(ctx, worldPath, origins) : undefined;\n if (linked === null) return null;\n if (linked) {\n return linked.constraints === constraintsOf(node.data)\n ? { path: linked.path, others: linked.others }\n : { path: linked.path, data: { constraints: linked.constraints }, others: linked.others };\n }\n const done = constrainNodeEdit(node, worldPath, origins);\n if (!done) return null;\n return done.constraints === constraintsOf(node.data)\n ? { path: done.path }\n : { path: done.path, data: { constraints: done.constraints } };\n },\n };\n}\n","/**\n * Add and remove geometric constraints on the anchors selected in path edit.\n * Neither has a default binding: a consumer binds each kind it offers, with\n * the kind as a param (see `<SceneCanvas tune>`).\n */\n\nimport { type Action, type ActionDeps, ActionDisabledReason, type ImmediateInvoker } from '@weasel-js/routing';\nimport {\n constraintAnchors,\n pathAnchorPoints,\n segmentBetween,\n type AnchorPair,\n type PathConstraint,\n type PathConstraintKind,\n type PolygonPath,\n} from '@weasel-js/geom';\nimport { depOf, deleteSelectedMark, type EditAnchorsDep, pathOperationTags } from '@weasel-js/core';\nimport { constraintsOf } from './pathConstraints';\nimport { editedPath, selectedConstraintOf, setConstraints } from './constraintsExtension';\nimport { icon } from '../icons.gen';\n\n/** Params for `constrainAnchors`. */\nexport interface ConstrainAnchorsParams {\n kind: PathConstraintKind;\n /** For `length`: the length to hold. Default: each pair's length now. */\n length?: number;\n}\n\nconst pairsOf = (anchors: readonly number[]): AnchorPair[] =>\n anchors.slice(1).map((b, i) => [anchors[i], b] as const);\n\n/** Two segments from three anchors, meeting at the middle one, or from four, as two pairs. */\nfunction segmentPair(anchors: readonly number[]): readonly [AnchorPair, AnchorPair] | null {\n if (anchors.length === 3) return [[anchors[0], anchors[1]], [anchors[1], anchors[2]]];\n if (anchors.length === 4) return [[anchors[0], anchors[1]], [anchors[2], anchors[3]]];\n return null;\n}\n\n/**\n * The constraints of `kind` that `anchors`, in the order they were selected,\n * ask for: each anchor for `fixed`; each anchor with both handles for\n * `tangent`; for `onPath`, three anchors, the first held on the segment the\n * other two end; each consecutive pair for `horizontal`,\n * `vertical`, `length`, and `coincident`; and for the kinds relating two\n * segments, three anchors as two segments sharing the middle one or four as\n * two pairs. Empty when the anchors cannot make that kind.\n */\nexport function constraintsForAnchors(\n kind: PathConstraintKind,\n anchors: readonly number[],\n path: PolygonPath,\n length?: number,\n): PathConstraint[] {\n switch (kind) {\n case 'fixed': return anchors.map((anchor) => ({ kind, anchor }));\n case 'onPath': {\n const segment = anchors.length === 3 ? segmentBetween(path, anchors[1], anchors[2]) : null;\n return segment ? [{ kind, anchor: anchors[0], segment }] : [];\n }\n case 'tangent': {\n const points = pathAnchorPoints(path);\n return anchors.filter((a) => points[a]?.inHandle && points[a]?.outHandle).map((anchor) => ({ kind, anchor }));\n }\n case 'horizontal':\n case 'vertical': return pairsOf(anchors).map((segment) => ({ kind, segment }));\n case 'coincident': return pairsOf(anchors).map((pair) => ({ kind, anchors: pair }));\n case 'length': {\n const points = pathAnchorPoints(path);\n return pairsOf(anchors).map((segment) => ({\n kind,\n segment,\n length: length ?? Math.hypot(points[segment[1]].x - points[segment[0]].x, points[segment[1]].y - points[segment[0]].y),\n }));\n }\n default: {\n const segments = segmentPair(anchors);\n return segments ? [{ kind, segments }] : [];\n }\n }\n}\n\nconst sameConstraint = (a: PathConstraint, b: PathConstraint) => JSON.stringify(a) === JSON.stringify(b);\n\n/** The constraints adding `params` to the edited path's would leave it with, or null for no change. */\nfunction withAdded(dep: EditAnchorsDep, params: Partial<ConstrainAnchorsParams> | undefined): PathConstraint[] | null {\n const path = editedPath(dep);\n if (!path || !params?.kind) return null;\n const current = constraintsOf(dep.getNodeShape(dep.editingId)?.data);\n const added = constraintsForAnchors(params.kind, [...dep.selectedAnchors], path, params.length)\n .filter((c) => !current.some((had) => sameConstraint(had, c)));\n return added.length > 0 ? [...current, ...added] : null;\n}\n\n/** The constraints left once those on only selected anchors, of `kind` when given, are gone; null for no change. */\nfunction withRemoved(dep: EditAnchorsDep, kind: PathConstraintKind | undefined): PathConstraint[] | null {\n const current = constraintsOf(dep.getNodeShape(dep.editingId)?.data);\n const kept = current.filter((c) =>\n (kind !== undefined && c.kind !== kind) || !constraintAnchors(c).every((a) => dep.selectedAnchors.has(a)));\n return kept.length < current.length ? kept : null;\n}\n\nfunction constraintCommand(\n id: string,\n label: string,\n next: (dep: EditAnchorsDep, params: Record<string, unknown> | undefined) => PathConstraint[] | null,\n): Action & { requires: string[] } {\n const ready = (deps: ActionDeps | undefined) => {\n const dep = depOf(deps);\n return dep?.store && dep.selectedAnchors.size > 0 ? dep : null;\n };\n return {\n id,\n label,\n group: 'anchors',\n tags: pathOperationTags('drag'),\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const dep = ready(deps);\n const list = dep && next(dep, params);\n if (dep && list) setConstraints(dep, list, label);\n },\n } as ImmediateInvoker,\n enabled: (deps) => (ready(deps) ? true : ActionDisabledReason.SelectionRequired),\n };\n}\n\n/**\n * Delete the constraint selected in path edit, as a command. Delete and\n * Backspace reach it through `deleteAnchors`, which deletes whichever of the\n * two is selected, so the keys have one binding.\n */\nexport const deleteConstraintAction: Action & { requires: string[] } = {\n id: 'deleteConstraint',\n label: 'Delete constraint',\n icon: /* @icon */ 'core:delete',\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors'],\n invoker: {\n timing: 'immediate',\n run: (deps) => {\n const dep = depOf(deps);\n if (dep && selectedConstraintOf(dep) !== null) deleteSelectedMark(dep);\n },\n } as ImmediateInvoker,\n enabled: (deps) => {\n const dep = depOf(deps);\n return dep?.store && selectedConstraintOf(dep) !== null ? true : ActionDisabledReason.SelectionRequired;\n },\n};\n\n/**\n * Constrain the selected anchors: params `{ kind, length? }`, read as\n * {@link constraintsForAnchors} reads them. The path moves the least that\n * makes every constraint hold; a constraint that conflicts with the rest is\n * kept all the same, left unsolved, and shown as a conflict.\n */\nexport const constrainAnchorsAction = constraintCommand(\n 'constrainAnchors',\n 'Constrain anchors',\n (dep, params) => withAdded(dep, params as Partial<ConstrainAnchorsParams> | undefined),\n);\n\n/**\n * Remove the constraints whose anchors are all selected — only those of\n * `kind` when the params name one.\n */\nexport const unconstrainAnchorsAction = constraintCommand(\n 'unconstrainAnchors',\n 'Remove constraints',\n (dep, params) => withRemoved(dep, params?.kind as PathConstraintKind | undefined),\n);\n","/**\n * What the click-driven path commands share: the press they act at and how\n * far it reaches, the strokes of the scene they act on, and the outlines that\n * stop or cut them.\n */\nimport type { ActionDeps } from '@weasel-js/routing';\nimport type { Path } from '@weasel-js/geom';\nimport { type NodeId, nodeOutline, type PathNode, resolveEditablePathOf, type SceneNode } from '@weasel-js/core';\n\ntype AnyNode = SceneNode<unknown, string, unknown>;\n\n/** Default reach of a click from the stroke it acts on, in screen pixels. */\nexport const DEFAULT_STROKE_REACH_PX = 6;\n\ntype PressParams = {\n pressX?: number; pressY?: number; worldX?: number; worldY?: number; radiusPx?: number;\n} | undefined;\n\n/** A world point, and how far from it a stroke may be in world units. */\nexport interface StrokePress {\n at: { x: number; y: number };\n radius: number;\n}\n\n/** The press in `params` — a click's, or else a hover's pointer — and its\n * reach, `radiusPx` at the view's scale; null with neither point. */\nexport function pressOf(deps: ActionDeps, params: unknown): StrokePress | null {\n const p = params as PressParams;\n const x = p?.pressX ?? p?.worldX, y = p?.pressY ?? p?.worldY;\n if (x === undefined || y === undefined) return null;\n const scale = deps.view?.get().scale ?? { x: 1, y: 1 };\n const radius = (p?.radiusPx ?? DEFAULT_STROKE_REACH_PX) / Math.max(Math.abs(scale.x), Math.abs(scale.y));\n return { at: { x, y }, radius };\n}\n\nfunction renderOrder(deps: ActionDeps | undefined): readonly AnyNode[] {\n const scene = deps?.scene as { renderOrderNodes?(): readonly AnyNode[] } | undefined;\n return scene?.renderOrderNodes?.() ?? [];\n}\n\n/** Every leaf of the scene holding an editable path, back to front. */\nexport function scenePathNodes(deps: ActionDeps | undefined): PathNode[] {\n const out: PathNode[] = [];\n for (const node of renderOrder(deps)) {\n if (node.kind !== 'leaf') continue;\n const path = resolveEditablePathOf(node);\n if (path) out.push({ id: node.id as NodeId, node, path });\n }\n return out;\n}\n\n/** The drawn outline of every leaf but `id`: what a stroke is cut at or\n * stopped by. */\nexport function strokesBesides(deps: ActionDeps | undefined, id: string): Path[] {\n const out: Path[] = [];\n for (const node of renderOrder(deps)) {\n if (node.kind !== 'leaf' || node.id === id) continue;\n const outline = nodeOutline(node);\n if (outline) out.push(outline);\n }\n return out;\n}\n","/** Extend to next path: carry an open end along its tangent until it meets a stroke. */\nimport { type Action, type ActionDeps, ActionDisabledReason, type ImmediateInvoker } from '@weasel-js/routing';\nimport {\n extendToMeet, openEndAt, openEndRay, openPathEnds, pathDistanceToPoint, pathToAnchors,\n type AnchorSet, type OpenPathEnd, type PolygonPath,\n} from '@weasel-js/geom';\nimport { commitOps, type Op, type PathNode, reshapeOps, selectedPathNodes, pathOperationTags } from '@weasel-js/core';\nimport { pressOf, scenePathNodes, strokesBesides, type StrokePress } from '../shared/scenePaths';\nimport { icon } from '../icons.gen';\n\nconst EXTEND_LABEL = 'Extend to next path';\n\n/** The open ends of `path` whose anchors are in `anchors`, flat-indexed;\n * every open end when none of the anchors is one. */\nfunction endsAt(path: PolygonPath, anchors: ReadonlySet<number>): OpenPathEnd[] {\n const ends = openPathEnds(path);\n if (anchors.size === 0) return ends;\n const set = pathToAnchors(path) as AnchorSet;\n const at = [...anchors].map((flat) => openEndAt(set, flat));\n const picked = ends.filter((e) => at.some((o) => o?.sub === e.sub && o.end === e.end));\n return picked.length > 0 ? picked : ends;\n}\n\nconst dist = (a: { x: number; y: number }, b: { x: number; y: number }) => Math.hypot(a.x - b.x, a.y - b.y);\n\n/** The topmost stroke within reach of `press` with an open end, and that end\n * of it nearest the press. */\nfunction endNearPress(all: readonly PathNode[], press: StrokePress) {\n for (let i = all.length - 1; i >= 0; i--) {\n const node = all[i];\n if (pathDistanceToPoint(node.path, press.at.x, press.at.y) > press.radius) continue;\n const near = openPathEnds(node.path)\n .map((end) => ({ end, ray: openEndRay(node.path, end) }))\n .filter((e) => e.ray)\n .sort((a, b) => dist(a.ray!.at, press.at) - dist(b.ray!.at, press.at))[0];\n if (near) return [{ node, ends: [near.end] }];\n }\n return [];\n}\n\n/** What Extend to next path would make of each node it reaches. */\nfunction planExtend(deps: ActionDeps | undefined, params?: unknown): Map<string, { node: PathNode; path: PolygonPath }> {\n const out = new Map<string, { node: PathNode; path: PolygonPath }>();\n const all = scenePathNodes(deps);\n const editing = deps?.editAnchors?.editingId;\n const press = deps ? pressOf(deps, params) : null;\n const subjects = press ? endNearPress(all, press) : editing\n ? all.filter((n) => n.id === editing).map((node) => ({ node, ends: endsAt(node.path, deps!.editAnchors!.selectedAnchors) }))\n : selectedPathNodes(deps).map((node) => ({ node, ends: openPathEnds(node.path) }));\n for (const { node, ends } of subjects) {\n const boundaries = strokesBesides(deps, node.id);\n let path = node.path;\n for (const end of ends) path = extendToMeet(path, boundaries, end)?.path ?? path;\n if (path !== node.path) out.set(node.id, { node, path });\n }\n return out;\n}\n\n/**\n * Extend to next path: carry each open end of the selected\n * paths along its tangent to the first stroke it meets (`extendToMeet`). In\n * path edit, the selected end anchors of the edited path, or all its open\n * ends when none is selected. Given a press (`pressX`, `pressY`, as a click\n * binding supplies), the open end nearest it of the topmost stroke within\n * `radiusPx` instead. An end that meets nothing stays put. One undo step.\n */\nexport const extendToMeetAction: Action & { requires: string[] } = {\n id: 'extendToMeet',\n icon: /* @icon */ 'path-tools:extend',\n label: EXTEND_LABEL,\n tags: pathOperationTags('click'),\n group: 'path',\n eligible: { capability: 'creates-shapes' },\n requires: ['selection', 'scene', 'applyOps', 'editAnchors', 'view'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const ops: Op[] = [];\n for (const { node, path } of planExtend(deps, params).values()) ops.push(...reshapeOps(node.node, path, EXTEND_LABEL));\n commitOps(deps, ops, EXTEND_LABEL);\n },\n } satisfies ImmediateInvoker,\n // A click's point arrives here without the binding's reach, so `run` decides there.\n enabled: (deps?: ActionDeps, at?: { x: number; y: number }) =>\n (at || planExtend(deps).size > 0 ? true : ActionDisabledReason.NotApplicable),\n};\n","/**\n * Toggles for the locks every path-edit handle drag holds without a\n * modifier: its angle, its length, or both, which freezes it. They set the\n * `editAnchors` dep's `handleLocks`, so a bar, the command palette, and\n * `<SceneCanvas tune>`'s `handleLock` param, which they start from, all\n * reach the one value the drag reads.\n */\n\nimport { type Action, type ActionDeps, ActionDisabledReason, type ImmediateInvoker } from '@weasel-js/routing';\nimport { type HandleLock, pathOperationTags } from '@weasel-js/core';\nimport { icon } from '../icons.gen';\n\nfunction makeHandleLockToggle(\n lock: HandleLock,\n label: string,\n icon: Action['icon'],\n): Action & { requires: string[] } {\n return {\n id: `handleLock.${lock}`,\n label,\n tags: pathOperationTags('drag'),\n icon,\n group: 'anchors',\n requires: ['editAnchors'],\n active: (deps?: ActionDeps) => deps?.editAnchors?.handleLocks?.[lock] === true,\n enabled: (deps?: ActionDeps) =>\n deps?.editAnchors?.setHandleLocks ? true : ActionDisabledReason.NotApplicable,\n invoker: {\n timing: 'immediate',\n run: (deps) => {\n const dep = deps?.editAnchors;\n if (!dep?.setHandleLocks) return;\n const held = dep.handleLocks ?? { angle: false, length: false };\n dep.setHandleLocks({ ...held, [lock]: !held[lock] });\n },\n } as ImmediateInvoker,\n };\n}\n\n/** Hold every handle drag to the handle's angle, as Shift does. */\nexport const handleLockAngleAction = makeHandleLockToggle('angle', 'Hold handle angle', /* @icon */ 'core:holdHandleAngle');\n\n/** Hold every handle drag to the handle's length, as Mod (Cmd or Ctrl) does. */\nexport const handleLockLengthAction = makeHandleLockToggle('length', 'Hold handle length', /* @icon */ 'core:holdHandleLength');\n","/**\n * Handle snapping: a control handle dragged in path edit snaps its angle to\n * steps and to the line through the anchor's other handle, keeping its\n * length. The drag runs a `'handle'` snap session about the anchor, and\n * {@link handleSnapSource} offers it the angles.\n */\nimport { anchorAt } from '@weasel-js/geom';\nimport { stepAngles, type AngleCandidate, type PathEditExtension, type SnapMark, type SnapSession, type SnapSource } from '@weasel-js/core';\n\n/** Angle snapping for a control-handle drag. */\nexport interface HandleSnapOptions {\n /** Snap to every multiple of this many degrees. Default 45; 0 turns the\n * steps off and leaves only the opposite handle. */\n stepDeg?: number;\n /** How near, in degrees, the handle must come to an angle to snap. Read\n * by the drag as it starts. Default 6. */\n reachDeg?: number;\n /** Also snap onto the line through the anchor's other handle. Default true. */\n opposite?: boolean;\n}\n\n/** Options, or a thunk read on every move: null or undefined from it leaves\n * the handle unsnapped. */\nexport type HandleSnapOptionsInput = HandleSnapOptions | (() => HandleSnapOptions | null | undefined);\n\ntype Point = { x: number; y: number };\n\nconst DEG = Math.PI / 180;\nconst DEFAULT_STEP_DEG = 45;\nconst DEFAULT_REACH_DEG = 6;\n/** How far a guide reaches past the handle, as a share of its length at the press. */\nconst LINE_OVERSHOOT = 1.25;\n\nconst reader = (options: HandleSnapOptionsInput) => (typeof options === 'function' ? options : () => options);\n\n/**\n * A handle drag's angle targets: the multiples of `stepDeg` either side of\n * the handle, and the angle that puts it in line with the anchor's other\n * handle, which the drag brings as `also.anchors`, ahead of a step it ties\n * with. Each draws its line.\n */\nexport function handleSnapSource(options: HandleSnapOptionsInput = {}): SnapSource {\n const read = reader(options);\n return {\n id: 'handle',\n roles: [],\n gestures: ['handle'],\n collect: () => [],\n *angles(q): Iterable<AngleCandidate> {\n const opts = read();\n if (!opts) return;\n const { pivot } = q;\n const reach = Math.hypot(q.press.x - pivot.x, q.press.y - pivot.y) * LINE_OVERSHOOT;\n // Yielded first, so the opposite handle wins a tie with a step.\n for (const other of opts.opposite === false ? [] : q.also?.anchors ?? []) {\n if (other.x === pivot.x && other.y === pivot.y) continue;\n const angle = Math.atan2(pivot.y - other.y, pivot.x - other.x);\n yield { angle, mark: { kind: 'line', from: other, to: along(pivot, angle, reach) } };\n }\n const step = (opts.stepDeg ?? DEFAULT_STEP_DEG) * DEG;\n if (step <= 0) return;\n for (const angle of stepAngles(q.theta, step)) yield { angle, mark: stepLine(pivot, angle, reach) };\n },\n };\n}\n\n/**\n * Handle snapping as a path-edit extension: each control-handle drag runs a\n * `'handle'` session on the canvas's `snap` dep, in polar coordinates about\n * its anchor, and the handle keeps the length the pointer and the locks give\n * it. A held angle lock holds the angle; a held length lock keeps the length\n * while the angle snaps. The angles come from {@link handleSnapSource}, which\n * `createHandleSnapPreset` registers beside it.\n */\nexport function createHandleSnapExtension(options: HandleSnapOptionsInput = {}): PathEditExtension {\n const read = reader(options);\n return {\n id: 'handleSnap',\n drag(start) {\n if (start.part === 'anchor') return null;\n const pressed = anchorAt(start.anchors, start.anchorIndex);\n const handle = start.part === 'controlIn' ? pressed?.inHandle : pressed?.outHandle;\n if (!pressed || !handle) return null;\n const anchor = { x: pressed.x, y: pressed.y };\n const other = start.part === 'controlIn' ? pressed.outHandle : pressed.inHandle;\n const session: SnapSession | undefined = start.snap?.begin({\n gesture: 'handle',\n press: { x: handle.x, y: handle.y },\n pivot: anchor,\n ids: [start.id],\n theta0: Math.atan2(handle.y - anchor.y, handle.x - anchor.x),\n reachRad: (read()?.reachDeg ?? DEFAULT_REACH_DEG) * DEG,\n ...(other ? { also: { anchors: [{ x: other.x, y: other.y }] } } : {}),\n });\n if (!session) return null;\n return {\n handle(to, { locks }) {\n const dx = to.x - anchor.x;\n const dy = to.y - anchor.y;\n const len = Math.hypot(dx, dy);\n const off = !read() || len === 0;\n const { theta } = session.angle(Math.atan2(dy, dx), { suspend: off, constrain: false, hold: locks.angle });\n if (off || locks.angle) return to;\n return along(anchor, theta, len);\n },\n end: () => session.end(),\n };\n },\n };\n}\n\nfunction along(from: Point, angle: number, len: number): Point {\n return { x: from.x + Math.cos(angle) * len, y: from.y + Math.sin(angle) * len };\n}\n\n/** The line through `pivot` at `angle`, `reach` either side of it. */\nfunction stepLine(pivot: Point, angle: number, reach: number): SnapMark {\n return { kind: 'line', from: along(pivot, angle + Math.PI, reach), to: along(pivot, angle, reach) };\n}\n","/**\n * Soft selection: dragging anchors in path edit also moves the anchors near\n * them, each by a falloff of its distance along the path. The reach is drawn\n * as a band while the drag lasts, and the wheel scrubs the radius mid-drag.\n */\nimport type { OngoingOverlay } from '@weasel-js/routing';\nimport {\n measureAnchorPath, softSelectionBand, softSelectionWeights, type AnchorSet, type SoftFalloff,\n} from '@weasel-js/geom';\nimport type { PathEditDrag, PathEditDragStart, PathEditExtension } from '@weasel-js/core';\n\n/** How far soft selection reaches, and how it fades. */\nexport interface SoftSelectionOptions {\n /** How far along the path the influence reaches, in screen pixels. */\n radiusPx: number;\n /** How the influence fades over the radius. Default `'smooth'`. */\n falloff?: SoftFalloff;\n /** Told each radius the wheel scrubs to, so a host can keep it for the next drag. */\n onRadius?: (radiusPx: number) => void;\n}\n\nconst MIN_RADIUS_PX = 2;\nconst MAX_RADIUS_PX = 4000;\n/** Radius growth per pixel of wheel travel: a notch of about 100 scales it by ~1.16. */\nconst WHEEL_GAIN = 0.0015;\n\n/** Soft selection as a path-edit extension. `options` is read as each anchor\n * drag starts; null or undefined leaves that drag hard. */\nexport function createSoftSelectionExtension(\n options: () => SoftSelectionOptions | null | undefined,\n): PathEditExtension {\n return {\n id: 'softSelection',\n drag(start) {\n const opts = options();\n if (!opts || start.part !== 'anchor' || start.dragging.length === 0) return null;\n return softDrag(start, opts);\n },\n };\n}\n\nfunction softDrag(start: PathEditDragStart, opts: SoftSelectionOptions): PathEditDrag {\n const measure = measureAnchorPath(start.anchors, start.scale ? { scale: start.scale } : {});\n const falloff = opts.falloff ?? 'smooth';\n let radiusPx = clampRadius(opts.radiusPx);\n let weights = softSelectionWeights(measure, start.dragging, radiusPx, falloff);\n return {\n weights: () => weights,\n wheel({ deltaY }) {\n radiusPx = clampRadius(radiusPx * Math.exp(-deltaY * WHEEL_GAIN));\n weights = softSelectionWeights(measure, start.dragging, radiusPx, falloff);\n opts.onRadius?.(radiusPx);\n return true;\n },\n overlays: (current: AnchorSet): OngoingOverlay[] =>\n softSelectionBand(measure, current, start.dragging, radiusPx)\n .map((points) => ({ kind: 'polyline', points, role: 'falloff' })),\n };\n}\n\nfunction clampRadius(px: number): number {\n return Math.min(MAX_RADIUS_PX, Math.max(MIN_RADIUS_PX, Number.isFinite(px) ? px : MIN_RADIUS_PX));\n}\n","import { harmonizeAnchors } from '@weasel-js/geom';\nimport { makeHandleCommand } from '@weasel-js/core';\nimport { icon } from '../icons.gen';\n\n/**\n * Make the selected smooth anchors curvature-continuous by adjusting their\n * handle lengths, or every smooth anchor of the path while none is selected.\n */\nexport const harmonizeAnchorsAction = makeHandleCommand(\n 'harmonizeAnchors',\n 'Harmonize curvature',\n /* @icon */ 'core:harmonize',\n harmonizeAnchors,\n 'selectedOrAll',\n);\n","import {\n type Action, ActionDisabledReason, type ActionDeps, type BindingOpts, type InvocationCtx, isAnchor,\n type OngoingHandle, resolveParams,\n} from '@weasel-js/routing';\nimport type { CursorSpec } from '@weasel-js/cursor';\nimport {\n editAnchorSetTracked, lengthenPathEnd, lengthToward, nearestPathAnchor, openEndAt, pathEndAnchorIndex,\n pathEndFrame, pathToAnchors, type AnchorSet, type LengthenMode, type PointOrigin, type PolygonPath,\n} from '@weasel-js/geom';\nimport {\n depOf, type EditAnchorsDep, editingLayer, inPlane, pathEditPreview, pathEditToolAction, pathOperationTags,\n} from '@weasel-js/core';\nimport { icon } from '../icons.gen';\n\n/** The path-edit tool under which a drag on an open end lengthens the path. */\nexport const LENGTHEN_TOOL = 'lengthen';\n\n/** Params `lengthenPath` reads on every move. */\nexport interface LengthenPathParams {\n /** How an unmodified drag grows the end; Shift picks the other. Default `'tangent'`. */\n mode?: LengthenMode;\n}\n\nconst LENGTHEN_CURSOR: CursorSpec = { glyph: 'penPlus', fallback: 'crosshair' };\n\n/** Screen-px reach of an end anchor, matching the anchor affordance's hit radius. */\nconst END_HIT_PX = 8;\n\nfunction editedPath(deps: ActionDeps | undefined): { dep: EditAnchorsDep; path: PolygonPath } | null {\n const dep = depOf(deps);\n if (!dep || dep.tool !== LENGTHEN_TOOL) return null;\n const path = dep.getEditablePath(dep.editingId) as PolygonPath | null | undefined;\n return path?.kind === 'polygon' ? { dep, path } : null;\n}\n\n/** Whether an open end of the edited path lies under world point `(x, y)`. */\nfunction endUnder(deps: ActionDeps | undefined, x: number, y: number): boolean {\n const edited = editedPath(deps);\n if (!edited) return false;\n const scale = deps?.view?.get().scale ?? { x: 1, y: 1 };\n const hit = nearestPathAnchor([{ id: edited.dep.editingId, path: edited.path }], { x, y }, END_HIT_PX, scale);\n return !!hit && hit.end !== null && pathToAnchors(edited.path).anchors[hit.sub].length > 1;\n}\n\n/** The `mode` param, or the other mode while `flip` is held. */\nfunction modeOf(opts: BindingOpts | undefined, flip: boolean): LengthenMode {\n const mode = (resolveParams(opts?.params) as LengthenPathParams | undefined)?.mode;\n const base: LengthenMode = mode === 'curvature' ? 'curvature' : 'tangent';\n if (!flip) return base;\n return base === 'curvature' ? 'tangent' : 'curvature';\n}\n\nfunction pressedAnchor(ctx: InvocationCtx): number {\n const m = ctx.drag?.affordance?.kind.match(/^anchor:(\\d+)$/);\n return m ? parseInt(m[1], 10) : -1;\n}\n\n/**\n * Lengthen, the path-edit tool's drag. While path edit's `lengthen` tool is\n * on, dragging an open path's end anchor lengthens the path from that end\n * (`lengthenPathEnd`): straight along its end tangent, or along an arc with\n * the curvature the end has. Dragging back into the path shortens it along\n * itself. The `mode` param (`'tangent'`, the default, or `'curvature'`) picks\n * which, and Shift picks the other; both are read on every move. One undo\n * step per drag. With the tool off, a drag on the anchor is `editAnchors`'\n * and moves it.\n */\nexport const lengthenPathAction: Action & { requires: string[] } = inPlane({\n id: 'lengthenPath',\n label: 'Lengthen path',\n tags: pathOperationTags('drag'),\n defaultBinding: { kind: 'drag', target: { kindOf: isAnchor }, mods: { shift: 'optional' } },\n cursor: LENGTHEN_CURSOR,\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors', 'view'],\n invoker: {\n timing: 'ongoing',\n start(ctx: InvocationCtx, opts?: BindingOpts): OngoingHandle {\n const edited = editedPath(ctx.deps);\n if (!edited) return {};\n const { dep, path: originPath } = edited;\n const origin = pathToAnchors(originPath) as AnchorSet;\n const end = openEndAt(origin, pressedAnchor(ctx));\n const frame = end && pathEndFrame(origin, end);\n if (!end || !frame) return {};\n const id = dep.editingId;\n const press = ctx.drag?.start ?? ctx.world;\n let distance = 0;\n let current: { path: PolygonPath; origins?: readonly (PointOrigin | null)[] } | null = null;\n const preview = pathEditPreview(dep, id, () => current?.path ?? null);\n if (!preview) return {};\n\n return {\n kind: 'lengthen-path',\n onMove(moveCtx: InvocationCtx): void {\n const mode = modeOf(opts, moveCtx.modifiers.shift);\n const toward = {\n x: frame.point.x + moveCtx.world.x - press.x,\n y: frame.point.y + moveCtx.world.y - press.y,\n };\n distance = lengthToward(origin, end, mode, toward, distance);\n current = editAnchorSetTracked(originPath, (set) => lengthenPathEnd(set, end, distance, mode));\n },\n onEnd(_endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n const done = current;\n current = null;\n if (reason === 'cancel' || !done) return;\n dep.applyEdit(id, done.path, distance < 0 ? 'Shorten path' : 'Lengthen path', done.origins);\n const index = pathEndAnchorIndex(pathToAnchors(done.path) as AnchorSet, end);\n if (index !== -1) dep.setSelectedAnchors([index]);\n },\n previewIds: preview.previewIds,\n previewPose: preview.previewPose,\n previewData: preview.previewData,\n };\n },\n },\n enabled: (deps, at) => {\n if (depOf(deps)?.tool !== LENGTHEN_TOOL) return ActionDisabledReason.NotApplicable;\n if (at && !endUnder(deps, at.x, at.y)) return ActionDisabledReason.NotApplicable;\n return true;\n },\n}, editingLayer);\n\n/** The bar toggle for Lengthen: `pathEditTool.lengthen`. */\nexport const lengthenToolAction = pathEditToolAction(LENGTHEN_TOOL, 'Lengthen', /* @icon */ 'path-tools:lengthen');\n","/**\n * Which way the open path runs, drawn over it: an arrow at the middle of\n * every segment and a ring round each subpath's start anchor.\n */\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport { circlePath, directionMarks, polygonFromPoints, type AnchorSet, type Point } from '@weasel-js/geom';\nimport type { PathEditExtension } from '@weasel-js/core';\n\n/** Chrome-caps id the direction arrows and start rings are drawn under. Off by default. */\nexport const PATH_DIRECTION_CHROME_ID = 'path-edit.direction';\n\n/** How the direction marks are drawn. */\nexport interface PathDirectionStyle {\n /** Color of the arrows and the start rings. */\n color?: string;\n /** Length of an arrow, tip to base, in screen pixels. */\n arrowPx?: number;\n /** Radius of a start ring, in screen pixels. */\n ringPx?: number;\n}\n\nconst DIRECTION_DEFAULTS: Required<PathDirectionStyle> = { color: '#e8590c', arrowPx: 9, ringPx: 8 };\n\n/** Draw commands for `set`'s direction arrows and start rings, in screen space. */\nexport function directionCommands(set: AnchorSet, toScreen: (p: Point) => Point, style: PathDirectionStyle = {}): DrawCommand[] {\n const { color, arrowPx, ringPx } = { ...DIRECTION_DEFAULTS, ...style };\n const paint = { kind: 'solid' as const, color };\n const out: DrawCommand[] = [];\n for (const m of directionMarks(set)) {\n const c = toScreen(m);\n const ahead = toScreen({ x: m.x + m.dx, y: m.y + m.dy });\n const k = Math.hypot(ahead.x - c.x, ahead.y - c.y);\n if (k === 0) continue;\n const ux = (ahead.x - c.x) / k, uy = (ahead.y - c.y) / k;\n const tip = { x: c.x + (ux * arrowPx) / 2, y: c.y + (uy * arrowPx) / 2 };\n const back = { x: c.x - (ux * arrowPx) / 2, y: c.y - (uy * arrowPx) / 2 };\n const half = arrowPx * 0.45;\n out.push({\n kind: 'path',\n path: polygonFromPoints([tip, { x: back.x - uy * half, y: back.y + ux * half }, { x: back.x + uy * half, y: back.y - ux * half }]),\n fill: { paint },\n });\n }\n for (const sub of set.anchors) {\n if (sub.length === 0) continue;\n const start = toScreen(sub[0]);\n out.push({ kind: 'path', path: circlePath(start.x, start.y, ringPx), stroke: { paint, width: 2 } });\n }\n return out;\n}\n\n/** The direction marks as a path-edit extension, drawn in `style` while\n * chrome-caps shows {@link PATH_DIRECTION_CHROME_ID}. */\nexport function createDirectionExtension(style: PathDirectionStyle = {}): PathEditExtension {\n return {\n id: 'pathDirection',\n marks: (ctx) => (ctx.isVisible(PATH_DIRECTION_CHROME_ID) ? directionCommands(ctx.anchors, ctx.toScreen, style) : []),\n };\n}\n","/**\n * Where a path starts and which way it runs: make the selected anchor its\n * subpath's start, and reverse a path's direction. Both reorder anchors\n * without moving them, and what a node keeps per anchor moves with them.\n */\nimport { ActionDisabledReason, type Action, type ActionDeps, type ImmediateInvoker } from '@weasel-js/routing';\nimport {\n editAnchorSetTracked, flatIndexesAfterReverse, locateAnchor, reverseSubpaths, setSubpathStart, subpathsOfAnchors,\n type PolygonPath,\n} from '@weasel-js/geom';\nimport { anchorEditWouldChange, commitAnchorEdit, commitOps, depOf, pathOperationTags, type Op } from '@weasel-js/core';\nimport { icon } from '../icons.gen';\n\nconst START_LABEL = 'Make start point';\nconst REVERSE_LABEL = 'Reverse path direction';\n\n/** The one selected anchor, when exactly one is selected in path edit. */\nfunction loneAnchor(deps: ActionDeps | undefined): number | null {\n const dep = depOf(deps);\n return dep && dep.selectedAnchors.size === 1 ? [...dep.selectedAnchors][0] : null;\n}\n\n/**\n * Make the selected anchor where its subpath starts. A closed\n * subpath turns to start there; an open one can start only at an end, so its\n * last anchor reverses it (`setSubpathStart`). The anchor stays selected.\n */\nexport const setPathStartAction: Action & { requires: string[] } = {\n id: 'setPathStart',\n icon: /* @icon */ 'path-tools:setPathStart',\n label: START_LABEL,\n tags: pathOperationTags('command'),\n group: 'anchors',\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors'],\n invoker: {\n timing: 'immediate',\n run: (deps) => {\n const dep = depOf(deps);\n const flat = loneAnchor(deps);\n if (!dep || flat === null) return;\n let start = -1;\n const changed = commitAnchorEdit(dep, START_LABEL, (set) => {\n const loc = locateAnchor(set, flat);\n if (!loc) return false;\n start = flat - loc.idx;\n return setSubpathStart(set, flat);\n });\n if (changed) dep.setSelectedAnchors([start]);\n },\n } as ImmediateInvoker,\n enabled: (deps) => {\n const flat = loneAnchor(deps);\n if (flat === null) return ActionDisabledReason.SelectionRequired;\n return anchorEditWouldChange(deps, (set) => setSubpathStart(set, flat)) ? true : ActionDisabledReason.NotApplicable;\n },\n};\n\n/** The selected nodes holding an editable polygon, by id. */\nfunction selectedPaths(deps: ActionDeps | undefined): { id: string; path: PolygonPath }[] {\n const dep = deps?.editAnchors;\n if (!dep) return [];\n return (deps?.selection?.get() ?? []).flatMap((id) => {\n const path = dep.getEditablePath(id) as PolygonPath | null | undefined;\n return path?.kind === 'polygon' ? [{ id, path }] : [];\n });\n}\n\n/** Reverse the subpaths holding the selected anchors, or all of them, keeping the selection on its anchors. */\nfunction reverseInPathEdit(deps: ActionDeps): boolean {\n const dep = depOf(deps);\n if (!dep) return false;\n const selected = [...dep.selectedAnchors];\n let after: number[] = [];\n const changed = commitAnchorEdit(dep, REVERSE_LABEL, (set) => {\n const subs = selected.length > 0 ? subpathsOfAnchors(set, selected) : undefined;\n after = flatIndexesAfterReverse(set, selected, subs);\n return reverseSubpaths(set, subs);\n });\n if (changed) dep.setSelectedAnchors(after);\n return true;\n}\n\n/**\n * Run paths the other way, keeping their shape. In path edit it\n * reverses the subpaths holding the selected anchors — every subpath when\n * none is selected — and the selection follows its anchors. Otherwise it\n * reverses every selected path whole, in one undo entry. A closed subpath\n * keeps its start; an open one starts where it ended (`reverseSubpaths`).\n */\nexport const reversePathAction: Action & { requires: string[] } = {\n id: 'reversePath',\n icon: /* @icon */ 'path-tools:reversePath',\n label: REVERSE_LABEL,\n tags: pathOperationTags('command'),\n group: 'path',\n requires: ['editAnchors', 'selection', 'scene', 'applyOps'],\n invoker: {\n timing: 'immediate',\n run: (deps) => {\n if (reverseInPathEdit(deps)) return;\n const edit = deps.editAnchors;\n if (!edit?.editOps) return;\n const ops: Op[] = [];\n for (const { id, path } of selectedPaths(deps)) {\n const next = editAnchorSetTracked(path, (set) => reverseSubpaths(set));\n if (next) ops.push(...edit.editOps(id, next.path, REVERSE_LABEL, next.origins));\n }\n commitOps(deps, ops, REVERSE_LABEL);\n },\n } as ImmediateInvoker,\n enabled: (deps) => {\n if (depOf(deps)) return true;\n return selectedPaths(deps).length > 0 ? true : ActionDisabledReason.SelectionRequired;\n },\n};\n","/**\n * Make segments of the path being edited straight or curved, in place\n * (`convertSegments`): the selected segments from the keyboard, or the one\n * under a Shift+double-click.\n */\nimport { ActionDisabledReason, type Action, type ImmediateInvoker } from '@weasel-js/routing';\nimport { convertSegments, editAnchorSetTracked, segmentsBetweenAnchors, type SegmentType } from '@weasel-js/geom';\nimport {\n anchorEditWouldChange, commitAnchorEdit, depOf, editingLayer, inPlane, pathOperationTags, segmentUnder,\n} from '@weasel-js/core';\nimport { icon } from '../icons.gen';\n\nconst LABEL = 'Convert segments';\n\nconst typeOf = (params: Record<string, unknown> | undefined): SegmentType | undefined =>\n (params?.to === 'line' || params?.to === 'curve' ? params.to : undefined);\n\n/**\n * Convert the selected segments — those whose two ends are both\n * selected anchors. `params.to` `'line'` straightens them, `'curve'` curves\n * them with handles at their thirds so they keep their shape, and no `to`\n * (Shift+C) curves them all when any is straight and straightens them\n * otherwise.\n */\nexport const convertSegmentsAction: Action & { requires: string[] } = {\n id: 'convertSegments',\n icon: /* @icon */ 'path-tools:convertSegment',\n label: LABEL,\n tags: pathOperationTags('command'),\n group: 'anchors',\n variants: [\n { key: 'line', label: 'Make segments straight', icon: /* @icon */ 'path-tools:straightenSegment', params: { to: 'line' } },\n { key: 'curve', label: 'Make segments curved', icon: /* @icon */ 'path-tools:curveSegment', params: { to: 'curve' } },\n ],\n defaultBinding: { kind: 'key', key: ['c', 'C'], mods: { shift: true } },\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const dep = depOf(deps);\n if (!dep) return;\n const selected = [...dep.selectedAnchors];\n commitAnchorEdit(dep, LABEL, (set) => convertSegments(set, segmentsBetweenAnchors(set, selected), typeOf(params)));\n },\n } as ImmediateInvoker,\n enabled: (deps) => {\n const selected = [...(depOf(deps)?.selectedAnchors ?? [])];\n const any = selected.length > 1\n && anchorEditWouldChange(deps, (set) => convertSegments(set, segmentsBetweenAnchors(set, selected)));\n return any ? true : ActionDisabledReason.SelectionRequired;\n },\n};\n\n/**\n * Shift+double-click a segment of the path being edited to flip\n * it between straight and curved. Off every segment the click falls through.\n */\nexport const convertSegmentAtAction: Action & { requires: string[] } = inPlane({\n id: 'convertSegmentAt',\n icon: /* @icon */ 'path-tools:convertSegment',\n label: 'Convert segment',\n tags: pathOperationTags('click'),\n defaultBinding: { kind: 'doubleClick', mods: { shift: true } },\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors', 'view', 'kitSettings'],\n invoker: {\n timing: 'immediate',\n run(deps, params) {\n const wx = params?.worldX as number | undefined;\n const wy = params?.worldY as number | undefined;\n if (typeof wx !== 'number' || typeof wy !== 'number') return;\n const under = segmentUnder(deps, wx, wy);\n if (!under) return;\n const { dep, path, hit } = under;\n const next = editAnchorSetTracked(path, (set) => convertSegments(set, [hit], typeOf(params)));\n if (next) dep.applyEdit(dep.editingId, next.path, 'Convert segment', next.origins);\n },\n } as ImmediateInvoker,\n enabled: (deps, at) => {\n if (!deps?.editAnchors?.editingId) return ActionDisabledReason.NotApplicable;\n if (at && !segmentUnder(deps, at.x, at.y)) return ActionDisabledReason.NotApplicable;\n return true;\n },\n}, editingLayer);\n","/**\n * Anchor selection along the path in path edit: grow or shrink it by one\n * anchor, every Nth anchor, corners or smooth anchors, and the complement.\n * They change which anchors are selected and nothing else, so none of them\n * is an undo step.\n */\nimport type { Action, ActionDeps, ImmediateInvoker } from '@weasel-js/routing';\nimport { ActionDisabledReason } from '@weasel-js/routing';\nimport {\n cornerAnchors, everyNthAnchor, growAnchorSelection, invertAnchorSelection, pathToAnchors,\n shrinkAnchorSelection, smoothAnchors, type AnchorSet, type PolygonPath,\n} from '@weasel-js/geom';\nimport {\n depOf, pathOperationTags, requiresAnchorSelection, type EditAnchorsDep, type KeySpec,\n} from '@weasel-js/core';\n\n/** The group every action here is in, which an `ActionBar` can show. */\nexport const ANCHOR_SELECTION_GROUP = 'anchorSelection';\n\ntype Pick = (set: AnchorSet, selected: number[], params: Record<string, unknown> | undefined) => number[];\n\n/** The edited path decoded, or null when it is not a polygon. */\nfunction editedSet(dep: EditAnchorsDep): AnchorSet | null {\n const path = dep.getEditablePath(dep.editingId) as PolygonPath | undefined;\n return path && path.kind === 'polygon' ? pathToAnchors(path) : null;\n}\n\nconst pathOpen = (deps?: ActionDeps): true | ActionDisabledReason =>\n depOf(deps) ? true : ActionDisabledReason.SelectionRequired;\n\n/** A selection command bound to `key`; `needsSelection` when `pick` reads\n * the current selection and so has nothing to do without one. */\nfunction makeSelectCommand(\n id: string, label: string, key: KeySpec, needsSelection: boolean, pick: Pick,\n): Action & { requires: string[] } {\n const enabled = needsSelection ? requiresAnchorSelection : pathOpen;\n return {\n id,\n label,\n group: ANCHOR_SELECTION_GROUP,\n tags: pathOperationTags('command'),\n defaultBinding: key,\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const dep = depOf(deps);\n const set = dep && enabled(deps) === true ? editedSet(dep) : null;\n if (set) dep!.setSelectedAnchors(pick(set, [...dep!.selectedAnchors], params));\n },\n } as ImmediateInvoker,\n enabled,\n };\n}\n\n/** A key with Alt held, matched on `code` too: with Alt held on a Mac the\n * key reads as another glyph. */\nconst altKey = (key: string, code: string): KeySpec => ({ kind: 'key', key, code, mods: { alt: true } });\n\n/** The count `params.n` asks for, 2 when it names none. */\nconst stepOf = (params: Record<string, unknown> | undefined): number => {\n const n = params?.n;\n return typeof n === 'number' && Number.isFinite(n) && n >= 1 ? Math.floor(n) : 2;\n};\n\n/** Add each selected anchor's neighbors along the path. `]`. */\nexport const growAnchorSelectionAction = makeSelectCommand(\n 'growAnchorSelection', 'Grow anchor selection', { kind: 'key', key: ']', code: 'BracketRight' }, true,\n (set, selected) => growAnchorSelection(set, selected),\n);\n\n/** Drop the anchors at the ends of each selected run. `[`. */\nexport const shrinkAnchorSelectionAction = makeSelectCommand(\n 'shrinkAnchorSelection', 'Shrink anchor selection', { kind: 'key', key: '[', code: 'BracketLeft' }, true,\n (set, selected) => shrinkAnchorSelection(set, selected),\n);\n\n/**\n * Select every `params.n`th anchor (default 2) along each subpath, counting\n * from its first selected anchor, or from the start of every subpath when\n * none is selected. Alt+N.\n */\nexport const selectEveryNthAnchorAction = makeSelectCommand(\n 'selectEveryNthAnchor', 'Select every Nth anchor', altKey('n', 'KeyN'), false,\n (set, selected, params) => everyNthAnchor(set, stepOf(params), selected),\n);\n\n/** Select every corner anchor of the edited path. Alt+C. */\nexport const selectCornerAnchorsAction = makeSelectCommand(\n 'selectCornerAnchors', 'Select corner anchors', altKey('c', 'KeyC'), false,\n (set) => cornerAnchors(set),\n);\n\n/** Select every smooth anchor of the edited path. Alt+M. */\nexport const selectSmoothAnchorsAction = makeSelectCommand(\n 'selectSmoothAnchors', 'Select smooth anchors', altKey('m', 'KeyM'), false,\n (set) => smoothAnchors(set),\n);\n\n/** Select the anchors that are not selected, and only those. Alt+I. */\nexport const invertAnchorSelectionAction = makeSelectCommand(\n 'invertAnchorSelection', 'Invert anchor selection', altKey('i', 'KeyI'), false,\n (set, selected) => invertAnchorSelection(set, selected),\n);\n","/**\n * Add extremes in path edit: an anchor at each turn of a curved segment, in x\n * and in y, with the shape left as it was.\n */\nimport type { Action, ImmediateInvoker } from '@weasel-js/routing';\nimport { ActionDisabledReason } from '@weasel-js/routing';\nimport { addExtremaAnchors, anchorAt, segmentEnds, type AnchorSet, type PenAnchor } from '@weasel-js/geom';\nimport { anchorEditWouldChange, commitAnchorEdit, depOf, pathOperationTags } from '@weasel-js/core';\nimport { icon } from '../icons.gen';\n\nconst LABEL = 'Add extremes';\n\n/** The segments whose two ends are both in `selected`, as `addExtremaAnchors`\n * filters them; every segment when nothing is selected. */\nfunction selectedSegments(set: AnchorSet, selected: ReadonlySet<number>) {\n if (selected.size === 0) return undefined;\n const picked = new Set<PenAnchor>();\n for (const flat of selected) {\n const anchor = anchorAt(set, flat);\n if (anchor) picked.add(anchor);\n }\n // Read as the splits go: they run last segment first and keep each\n // anchor's identity, so a segment not yet split still has its own ends.\n return (sub: number, segIdx: number) => {\n const ends = segmentEnds(set.anchors, set.closed, sub, segIdx);\n return ends !== null && picked.has(ends.a) && picked.has(ends.b);\n };\n}\n\n/** Split the segments `selected` covers at their extremes, in place, and\n * return the selection afterward: the same anchors and the new ones. Null\n * when there was no extreme to add. */\nfunction addExtremesTo(set: AnchorSet, selected: ReadonlySet<number>): number[] | null {\n const kept = [...selected].flatMap((flat) => anchorAt(set, flat) ?? []);\n const added = addExtremaAnchors(set, selectedSegments(set, selected));\n if (added.length === 0) return null;\n const flatOf = new Map(set.anchors.flat().map((a, k) => [a, k]));\n return [...kept.map((a) => flatOf.get(a)!), ...added];\n}\n\n/**\n * Split the curved segments of the edited path at their x and y extremes:\n * those whose two ends are both selected, or every one while no anchor is.\n * The selected anchors stay selected, and the new ones join them. Alt+X.\n * Enabled only where it would add an anchor.\n */\nexport const addExtremeAnchorsAction: Action & { requires: string[] } = {\n id: 'addExtremeAnchors',\n icon: /* @icon */ 'path-tools:extremeAnchors',\n label: LABEL,\n group: 'anchors',\n tags: pathOperationTags('command'),\n // `code` too: with Alt held on a Mac the key reads as another glyph.\n defaultBinding: { kind: 'key', key: 'x', code: 'KeyX', mods: { alt: true } },\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors'],\n invoker: {\n timing: 'immediate',\n run: (deps) => {\n const dep = depOf(deps);\n if (!dep) return;\n let next: number[] | null = null;\n commitAnchorEdit(dep, LABEL, (set) => (next = addExtremesTo(set, dep.selectedAnchors)) !== null);\n if (next) dep.setSelectedAnchors(next);\n },\n } as ImmediateInvoker,\n enabled: (deps) => {\n const dep = depOf(deps);\n if (!dep) return ActionDisabledReason.SelectionRequired;\n return anchorEditWouldChange(deps, (set) => addExtremesTo(set, dep.selectedAnchors) !== null)\n ? true\n : ActionDisabledReason.NotApplicable;\n },\n};\n","/**\n * Resample: the selected paths' anchors spread evenly along them, as an\n * ongoing action so a control can preview it and commit once.\n */\nimport { resamplePath, type ResamplePathOptions } from '@weasel-js/geom';\nimport { livePathEdit, reshapeOps } from '@weasel-js/core';\n\nconst LABEL = 'Resample';\n\n/** What the `resamplePath` action reads from its params. */\nexport type ResamplePathParams = {\n /** Anchors in the result. 0 or absent keeps the count the path has. */\n count?: number;\n /** Distance between anchors along the path; overrides `count` when above 0. */\n spacing?: number;\n /** Hold corner anchors where they are. Default `true`. */\n keepCorners?: boolean;\n /** How far the result may stray from the original. Default 0.5. */\n tolerance?: number;\n};\n\nconst num = (v: unknown): number | undefined => (typeof v === 'number' && Number.isFinite(v) ? v : undefined);\n\n/** `params` as `resamplePath` options, with `count` given as `count`. */\nfunction resampleOptions(count: number, params: Readonly<Record<string, unknown>>): ResamplePathOptions {\n const spacing = num(params.spacing);\n const tolerance = num(params.tolerance);\n return {\n ...(spacing !== undefined && spacing > 0 ? { spacing } : count > 0 ? { count } : {}),\n ...(tolerance !== undefined ? { tolerance } : {}),\n keepCorners: params.keepCorners !== false,\n };\n}\n\n/**\n * Redistribute each selected path's anchors evenly by arc length\n * (`resamplePath`), to `params.count` anchors or at `params.spacing`, with\n * corners held unless `params.keepCorners` is false, and curves refitted\n * within `params.tolerance` of the original ({@link ResamplePathParams}).\n * Ongoing: `begin` previews it, each update with new params recomputes it,\n * and committing writes one undo entry.\n */\nexport const resamplePathAction = livePathEdit({\n id: 'resamplePath',\n label: LABEL,\n param: 'count',\n initial: 0,\n edit: ({ path }, count, params) => resamplePath(path, resampleOptions(count, params)),\n commit: (_deps, next) => [...next.values()].flatMap(({ node, path }) => reshapeOps(node.node, path, LABEL)),\n});\n","/**\n * Path-effect settings read from action params: each field taken only when it\n * is the right type, so a slider's number or a toggle's boolean passes and a\n * stray value is ignored rather than written into a document.\n */\nimport type { BendAlongEffect, BlendEffect, PathEffect, RepeatAlongEffect } from '@weasel-js/core';\n\ntype Params = Record<string, unknown> | undefined;\n\nconst num = (v: unknown): number | undefined => (typeof v === 'number' && Number.isFinite(v) ? v : undefined);\nconst bool = (v: unknown): boolean | undefined => (typeof v === 'boolean' ? v : undefined);\nconst oneOf = <T extends string>(v: unknown, options: readonly T[]): T | undefined =>\n (typeof v === 'string' && (options as readonly string[]).includes(v) ? (v as T) : undefined);\n\n/** `fields` without the entries left `undefined`. */\nfunction defined<T extends object>(fields: T): Partial<T> {\n return Object.fromEntries(Object.entries(fields).filter(([, v]) => v !== undefined)) as Partial<T>;\n}\n\n/** The settings of a `kind` effect that `params` names. */\nexport function effectSettings(kind: PathEffect['kind'], params: Params): Partial<PathEffect> {\n const p = params ?? {};\n switch (kind) {\n case 'blend':\n return defined<Partial<BlendEffect>>({\n steps: num(p.steps) === undefined ? undefined : Math.max(Math.round(num(p.steps)!), 0),\n autoAlign: bool(p.autoAlign),\n startOffset: num(p.startOffset) === undefined ? undefined : Math.round(num(p.startOffset)!),\n reverse: bool(p.reverse),\n rotate: bool(p.rotate),\n spaceBy: oneOf(p.spaceBy, ['count', 'distance'] as const),\n distance: num(p.distance) === undefined ? undefined : Math.max(num(p.distance)!, 0.01),\n orient: bool(p.orient),\n });\n case 'bendAlong':\n return defined<Partial<BendAlongEffect>>({\n fit: oneOf(p.fit, ['stretch', 'natural'] as const),\n baseline: num(p.baseline),\n flip: bool(p.flip),\n tolerance: num(p.tolerance) === undefined ? undefined : Math.max(num(p.tolerance)!, 0.01),\n });\n case 'repeatAlong':\n return defined<Partial<RepeatAlongEffect>>({\n count: num(p.count) === undefined ? undefined : Math.max(Math.round(num(p.count)!), 0),\n spacing: num(p.spacing) === undefined ? undefined : Math.max(num(p.spacing)!, 0),\n align: oneOf(p.align, ['start', 'center', 'end'] as const),\n offset: num(p.offset),\n orient: bool(p.orient),\n });\n }\n}\n\n/**\n * `effect` with the settings `params` names laid over it. A blend's\n * `reverse: 'auto'` clears its direction, handing it back to `autoAlign`.\n */\nexport function withEffectSettings(effect: PathEffect, params: Params): PathEffect {\n const next = { ...effect, ...effectSettings(effect.kind, params) } as PathEffect;\n if (next.kind === 'blend' && params?.reverse === 'auto') delete next.reverse;\n return next;\n}\n\n/** What a new effect of `kind` starts from, before its params. */\nexport const EFFECT_DEFAULTS: { [K in PathEffect['kind']]: Extract<PathEffect, { kind: K }> } = {\n blend: { kind: 'blend', steps: 4 },\n bendAlong: { kind: 'bendAlong' },\n repeatAlong: { kind: 'repeatAlong' },\n};\n","/**\n * The path-effect actions: make a live blend, bend, or repeat from the\n * selection; change one's settings; and expand one into ordinary paths.\n */\nimport { type Action, type ActionDeps, ActionDisabledReason, type ImmediateInvoker } from '@weasel-js/routing';\nimport { worldEditToStorage } from '@weasel-js/geom';\nimport {\n commitOps, createSetDataOp, deleteNode, derivedDepOf, insertAt, type NodeId, type Op, type PathEffect, pathEffectNode, pathEffectOf, pathEffectParts, registeredPathEffects, type Scene, type SceneNode as Node, slotOf, pathOperationTags,\n} from '@weasel-js/core';\nimport { EFFECT_DEFAULTS, withEffectSettings } from './params';\nimport { icon } from '../icons.gen';\n\ntype AnyScene = Scene<unknown, string, unknown>;\ntype AnyNode = Node<unknown, string, unknown>;\n\n/** The `group` every path-effect action is in, for an `<ActionBar>`. */\nexport const PATH_EFFECTS_GROUP = 'pathEffects';\n\n/** The selected leaves, in the order they were selected, when there are at\n * least two. `null` too in a scene whose registry holds no path effects,\n * which could not save one. */\nfunction selectedLeaves(deps: ActionDeps | undefined): AnyNode[] | null {\n const scene = deps?.scene as AnyScene | undefined;\n if (!scene || registeredPathEffects(scene.registry) === null) return null;\n const leaves = (deps?.selection?.get() ?? [])\n .map((id) => scene.get(id as NodeId))\n .filter((n): n is AnyNode => n !== undefined && n.kind === 'leaf');\n return leaves.length >= 2 ? leaves : null;\n}\n\n/** The selected nodes holding a path effect. */\nfunction selectedEffects(deps: ActionDeps | undefined, ids?: readonly string[]): AnyNode[] {\n const scene = deps?.scene as AnyScene | undefined;\n if (!scene) return [];\n return (ids ?? deps?.selection?.get() ?? [])\n .map((id) => scene.get(id as NodeId))\n .filter((n): n is AnyNode => n !== undefined && pathEffectOf(n) !== null);\n}\n\ninterface CreateSpec {\n id: string;\n label: string;\n icon: Action['icon'];\n kind: PathEffect['kind'];\n key: string;\n code: string;\n /** Where the new node goes: between its two sources, or over both. */\n between: boolean;\n /** Take a third selected leaf as a source too. */\n third?: boolean;\n}\n\nfunction createEffectAction(spec: CreateSpec): Action & { requires: string[] } {\n return {\n id: spec.id,\n label: spec.label,\n icon: spec.icon,\n tags: pathOperationTags('command'),\n group: PATH_EFFECTS_GROUP,\n // Alt+Shift, which no major browser takes for these letters (see\n // `BROWSER_RESERVED_CHORDS`); `code` too, since with Alt held on a Mac the\n // key reads as another glyph.\n defaultBinding: { kind: 'key', key: spec.key, code: spec.code, mods: { alt: true, shift: true } },\n eligible: { capability: 'creates-shapes' },\n requires: ['selection', 'scene', 'applyOps'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const scene = deps.scene as AnyScene | undefined;\n const leaves = selectedLeaves(deps);\n if (!scene || !leaves) return;\n const derivations = registeredPathEffects(scene.registry)!;\n const [a, b, c] = leaves as [AnyNode, AnyNode, AnyNode?];\n const sources = spec.third && c ? [a.id, b.id, c.id] : [a.id, b.id];\n const effect = withEffectSettings(EFFECT_DEFAULTS[spec.kind], params as Record<string, unknown> | undefined);\n const sameParent = a.parent === b.parent;\n const slots = [slotOf(scene, a.id), slotOf(scene, b.id)];\n // Inserting at the upper source's slot puts the steps just under it.\n const index = !sameParent ? -1 : spec.between ? Math.max(...slots) : Math.max(...slots) + 1;\n const node = {\n ...pathEffectNode(effect, sources, a.layer, derivations),\n id: scene.mintId(),\n parent: sameParent ? a.parent : null,\n } as unknown as AnyNode;\n commitOps(deps, [insertAt(node, index, spec.label)], spec.label);\n deps.selection?.set([node.id] as never);\n },\n } satisfies ImmediateInvoker,\n enabled: (deps) => {\n const scene = deps?.scene as AnyScene | undefined;\n if (scene && registeredPathEffects(scene.registry) === null) return ActionDisabledReason.NotApplicable;\n return selectedLeaves(deps) ? true : ActionDisabledReason.SelectionRequired;\n },\n };\n}\n\n/**\n * Steps between the first two selected shapes, in the order they were\n * selected: `params.steps` of them, each shape, fill, stroke and turn\n * interpolated, laid along a third selected path where there is one. The\n * blend is live — editing a source moves its steps — and goes just under the\n * upper of the first two. Its other params are `BlendEffect`'s.\n */\nexport const blendAction = createEffectAction({\n id: 'blend', label: 'Blend', icon: /* @icon */ 'path-tools:blend', kind: 'blend', key: 'b', code: 'KeyB', between: true, third: true,\n});\n\n/**\n * The first selected shape bent along the second, live: editing the spine\n * re-bends it. Params are `BendAlongEffect`'s.\n */\nexport const bendAlongAction = createEffectAction({\n id: 'bendAlong', label: 'Bend Along Path', icon: /* @icon */ 'path-tools:bendAlong', kind: 'bendAlong', key: 'w', code: 'KeyW', between: false,\n});\n\n/**\n * Copies of the first selected shape along the second, live. Params are\n * `RepeatAlongEffect`'s.\n */\nexport const repeatAlongAction = createEffectAction({\n id: 'repeatAlong', label: 'Repeat Along Path', icon: /* @icon */ 'path-tools:repeatAlong', kind: 'repeatAlong', key: 'r', code: 'KeyR', between: false,\n});\n\nconst EDIT_LABEL = 'Edit Path Effect';\n\n/**\n * Change the settings of path effects: `params.ids` when given, else the\n * selected ones. Every other param is a setting, laid over each effect's\n * own, and one that would change nothing commits nothing. Consecutive edits\n * of one effect coalesce, so a slider dragged through many values is one\n * undo step where the scene coalesces.\n */\nexport const editPathEffectAction: Action & { requires: string[] } = {\n id: 'editPathEffect',\n label: EDIT_LABEL,\n icon: /* @icon */ 'core:tune',\n requires: ['scene', 'applyOps'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const p = params as Record<string, unknown> | undefined;\n const ids = Array.isArray(p?.ids) ? (p.ids as string[]) : undefined;\n const ops: Op[] = [];\n for (const node of selectedEffects(deps, ids)) {\n const effect = pathEffectOf(node)!;\n const next = withEffectSettings(effect, p);\n if (sameEffect(effect, next)) continue;\n ops.push(createSetDataOp({\n id: node.id,\n from: node.data,\n to: { ...(node.data as object), pathEffect: next },\n label: EDIT_LABEL,\n coalesceKey: `${EDIT_LABEL}:${node.id}`,\n }));\n }\n commitOps(deps, ops, EDIT_LABEL);\n },\n } satisfies ImmediateInvoker,\n};\n\nfunction sameEffect(a: PathEffect, b: PathEffect): boolean {\n const keys = new Set([...Object.keys(a), ...Object.keys(b)]);\n for (const k of keys) {\n if ((a as unknown as Record<string, unknown>)[k] !== (b as unknown as Record<string, unknown>)[k]) return false;\n }\n return true;\n}\n\nconst EXPAND_LABEL = 'Expand to Paths';\n\n/**\n * Turn each selected path effect into the ordinary paths it shows, in its\n * slot and in its paint, and select them. Its sources stay; the paths no\n * longer follow them.\n */\nexport const expandPathEffectAction: Action & { requires: string[] } = {\n id: 'expandPathEffect',\n label: EXPAND_LABEL,\n icon: /* @icon */ 'path-tools:expand',\n group: PATH_EFFECTS_GROUP,\n defaultBinding: { kind: 'key', key: 'e', code: 'KeyE', mods: { alt: true, shift: true } },\n eligible: { capability: 'creates-shapes' },\n requires: ['selection', 'scene', 'applyOps'],\n invoker: {\n timing: 'immediate',\n run: (deps) => {\n const scene = deps.scene as AnyScene | undefined;\n if (!scene) return;\n // Top slot first, so a delete cannot shift a later one's index.\n const effects = selectedEffects(deps)\n .map((node) => ({ node, at: slotOf(scene, node.id) }))\n .sort((x, y) => y.at - x.at);\n const ops: Op[] = [];\n const made: string[] = [];\n for (const { node, at } of effects) {\n const sources = (Array.isArray(node.dependsOn) ? node.dependsOn : []).map((id) => derivedDepOf(scene, id, node));\n const parts = pathEffectParts(node, sources) ?? [];\n ops.push(deleteNode(scene, node, EXPAND_LABEL));\n parts.forEach((part, k) => {\n const { pose, path } = worldEditToStorage({ x: 0, y: 0, width: 0, height: 0 }, part.path);\n const data = {\n path,\n ...(part.fill === undefined ? {} : { fill: part.fill }),\n ...(part.stroke === undefined ? {} : { stroke: part.stroke }),\n };\n const copy = { id: scene.mintId(), kind: 'leaf', layer: node.layer, parent: node.parent, pose, data } as AnyNode;\n ops.push(insertAt(copy, at < 0 ? at : at + k, EXPAND_LABEL));\n made.push(copy.id);\n });\n }\n if (ops.length === 0) return;\n commitOps(deps, ops, EXPAND_LABEL);\n deps.selection?.set(made as never);\n },\n } satisfies ImmediateInvoker,\n enabled: (deps) => (selectedEffects(deps).length > 0 ? true : ActionDisabledReason.SelectionRequired),\n};\n","import {\n type Action, ActionDisabledReason, type InvocationCtx, type OngoingHandle, resolveParams,\n} from '@weasel-js/routing';\nimport type { CursorSpec } from '@weasel-js/cursor';\nimport {\n anchorsUnderBrush, editAnchorSetTracked, pathToAnchors, simplifyAnchorsAt,\n type AnchorSet, type PointOrigin, type PolygonPath,\n} from '@weasel-js/geom';\nimport {\n DEFAULT_SIMPLIFY_TOLERANCE, depOf, editingLayer, inPlane, pathEditPreview, pathEditToolAction, pathOperationTags,\n} from '@weasel-js/core';\nimport { icon } from '../icons.gen';\n\n/** The path-edit tool under which a plain drag brushes. */\nexport const SIMPLIFY_BRUSH_TOOL = 'simplifyBrush';\n\n/** The brush's radius on screen when no param names one. */\nexport const SIMPLIFY_BRUSH_RADIUS_PX = 12;\n\n/** Params the brush reads on every move, so a thunk can change them mid-stroke. */\nexport interface SimplifyBrushParams {\n /** Brush radius in screen pixels. */\n radiusPx?: number;\n /** How far the refit may stray from the original, in world units, as for\n * the Simplify command. */\n tolerance?: number;\n}\n\n/** The kit's brush-ring cursor drawn `radiusPx` in radius on screen. */\nexport function brushRingCursor(radiusPx: number): CursorSpec {\n // The `brush` glyph's ring is 9.9 units in radius on a 24-unit box.\n return { glyph: 'brush', size: Math.round((radiusPx * 24) / 9.9), fallback: 'crosshair' };\n}\n\ntype Point = { x: number; y: number };\n\nconst brushing = (deps: Parameters<typeof depOf>[0]) => depOf(deps)?.tool === SIMPLIFY_BRUSH_TOOL;\n\nfunction radiusOf(params: SimplifyBrushParams | undefined): number {\n const r = params?.radiusPx;\n return typeof r === 'number' && r > 0 ? r : SIMPLIFY_BRUSH_RADIUS_PX;\n}\n\nfunction toleranceOf(params: SimplifyBrushParams | undefined): number {\n const t = params?.tolerance;\n return typeof t === 'number' && t >= 0 ? t : DEFAULT_SIMPLIFY_TOLERANCE;\n}\n\n/**\n * The Simplify command, brushed on. While path edit's\n * `simplifyBrush` tool is on, a plain drag gathers every anchor a round brush\n * passes over, and each unbroken stretch of them along a subpath is refitted\n * as one span by Simplify's own fitter (`simplifyAnchorsAt`) at `tolerance`.\n * Only anchors the shape does not need go, so brushing again goes further.\n * The path previews the result while the brush is down and commits as one\n * undo step on release.\n */\nexport const simplifyBrushAction: Action & { requires: string[] } = inPlane({\n id: 'simplifyBrush',\n label: 'Simplify brush',\n tags: pathOperationTags('brush'),\n // Declines through `enabled` unless its tool is on.\n defaultBinding: [{ spec: { kind: 'drag' }, opts: { yields: true } }],\n cursor: (params) => brushRingCursor(radiusOf(params as SimplifyBrushParams | undefined)),\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors', 'view'],\n invoker: {\n timing: 'ongoing',\n start(ctx: InvocationCtx, opts): OngoingHandle {\n const dep = depOf(ctx.deps);\n if (!dep || dep.tool !== SIMPLIFY_BRUSH_TOOL) return {};\n const id = dep.editingId;\n const origin = dep.getEditablePath(id) as PolygonPath | undefined;\n if (!origin || origin.kind !== 'polygon') return {};\n const originSet = pathToAnchors(origin) as AnchorSet;\n\n const params = () => resolveParams(opts?.params) as SimplifyBrushParams | undefined;\n const radiusPx = (): number => radiusOf(params());\n const tolerance = (): number => toleranceOf(params());\n const scale = () => ctx.deps.view?.get().scale;\n const trail: Point[] = [];\n const gathered = new Set<number>();\n let current: { path: PolygonPath; origins?: readonly (PointOrigin | null)[] } | null = null;\n\n const sweepTo = (p: Point): void => {\n const from = trail[trail.length - 1] ?? p;\n trail.push({ x: p.x, y: p.y });\n const before = gathered.size;\n for (const i of anchorsUnderBrush(originSet, from, p, { radiusPx: radiusPx(), scale: scale() })) {\n gathered.add(i);\n }\n if (gathered.size === before) return;\n current = editAnchorSetTracked(origin, (set) => simplifyAnchorsAt(set, gathered, tolerance()));\n };\n\n const preview = pathEditPreview(dep, id, () => current?.path ?? null);\n if (!preview) return {};\n sweepTo(ctx.world);\n\n return {\n kind: 'simplify-brush',\n cursor: () => brushRingCursor(radiusPx()),\n onMove(moveCtx: InvocationCtx): void {\n sweepTo(moveCtx.world);\n },\n onEnd(_endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n if (reason === 'cancel') { current = null; return; }\n // The tolerance as it stands at release decides the commit.\n const done = gathered.size > 0\n ? editAnchorSetTracked(origin, (set) => simplifyAnchorsAt(set, gathered, tolerance()))\n : null;\n current = null;\n if (!done) return;\n dep.applyEdit(id, done.path, 'Simplify brush', done.origins);\n // Thinning renumbers every anchor after the first one removed.\n dep.setSelectedAnchors([]);\n },\n overlay: () => ({ kind: 'brush', points: trail.slice(), radiusPx: radiusPx() }),\n previewIds: preview.previewIds,\n previewPose: preview.previewPose,\n previewData: preview.previewData,\n };\n },\n },\n enabled: (deps) => (brushing(deps) ? true : ActionDisabledReason.NotApplicable),\n}, editingLayer);\n\n/** The bar toggle for the brush: `pathEditTool.simplifyBrush`. */\nexport const simplifyBrushToolAction = pathEditToolAction(SIMPLIFY_BRUSH_TOOL, 'Simplify brush', /* @icon */ 'core:simplifyBrush');\n","/**\n * The Smudge brush's drag: the selected paths' outlines under a round brush\n * follow the pointer, as one undo entry per stroke.\n */\nimport {\n type Action, type ActionDeps, ActionDisabledReason, type BindingOpts, type InvocationCtx, type OngoingHandle, resolveParams,\n} from '@weasel-js/routing';\nimport { pxExtent, smudgePath, type PolygonPath } from '@weasel-js/geom';\nimport { brushRingCursor } from '../simplifyBrush/simplifyBrush';\nimport { commitOps, reshapeOps, selectedPathNodes, withPath, type PathNode, type SceneNode, pathOperationTags } from '@weasel-js/core';\nimport { icon } from '../icons.gen';\n\ntype AnyNode = SceneNode<unknown, string, unknown>;\n\n/** The brush's radius in screen px when no param gives one. */\nexport const DEFAULT_SMUDGE_RADIUS_PX = 40;\n/** How much of the pointer's motion the outline under the brush's center follows,\n * when no param gives it. */\nexport const DEFAULT_SMUDGE_STRENGTH = 0.6;\n\nconst LABEL = 'Smudge brush';\n\n/** The params `smudgeBrush` reads, each on every pointer move. */\nexport interface SmudgeBrushParams {\n /** The brush's radius, in screen px. */\n radiusPx?: number;\n /** `1` moves the outline under the brush's center as far as the pointer; less, less. */\n strength?: number;\n}\n\nconst num = (v: unknown, d: number) => (typeof v === 'number' && Number.isFinite(v) ? v : d);\n\nfunction radiusOf(params: SmudgeBrushParams | undefined): number {\n return Math.max(1, num(params?.radiusPx, DEFAULT_SMUDGE_RADIUS_PX));\n}\n\nfunction strengthOf(params: SmudgeBrushParams | undefined): number {\n return Math.min(1, Math.max(0, num(params?.strength, DEFAULT_SMUDGE_STRENGTH)));\n}\n\n/** The brush's radius in world units: `radiusPx` on screen at the view's scale. */\nfunction worldRadius(deps: ActionDeps, radiusPx: number): number {\n const reach = pxExtent(radiusPx, deps.view?.get().scale ?? { x: 1, y: 1 });\n return Math.max(reach.x, reach.y);\n}\n\n/**\n * A drag that pushes the outline of every selected path along with\n * the pointer (`smudgePath` in `@weasel-js/geom`). Each pointer move is one dab from\n * where the last one ended: points under the brush move with it, most at its center\n * and not at all at its rim, and a long segment the brush meets gets anchors added\n * so it can bend there. `params.radiusPx` is the brush's radius on screen, so it\n * covers the same part of the canvas at every zoom, and `params.strength` how closely\n * the outline follows; both are read on every move. The cursor is a ring the size of\n * the brush. The stroke commits as one undo entry; canceling it leaves the paths as\n * they were.\n */\nexport const smudgeBrushAction: Action & { requires: string[] } = {\n id: 'smudgeBrush',\n label: LABEL,\n icon: /* @icon */ 'path-tools:smudgeBrush',\n tags: pathOperationTags('brush'),\n group: 'path',\n eligible: { capability: 'creates-shapes' },\n cursor: (params) => brushRingCursor(radiusOf(params as SmudgeBrushParams | undefined)),\n requires: ['selection', 'scene', 'view', 'applyOps'],\n invoker: {\n timing: 'ongoing',\n start(ctx: InvocationCtx, opts?: BindingOpts): OngoingHandle {\n const nodes = selectedPathNodes(ctx.deps);\n if (nodes.length === 0) return {};\n const { deps } = ctx;\n const params = (move: InvocationCtx): SmudgeBrushParams =>\n ({ ...resolveParams(opts?.params), ...move.params }) as SmudgeBrushParams;\n let radiusPx = radiusOf(params(ctx));\n let at = { x: ctx.drag?.start.x ?? ctx.world.x, y: ctx.drag?.start.y ?? ctx.world.y };\n const current = new Map<string, { node: PathNode; path: PolygonPath }>();\n const shapeOf = (id: string) => {\n const entry = current.get(id);\n return entry ? withPath(entry.node.node as AnyNode, entry.path) : null;\n };\n return {\n kind: 'smudge-brush',\n cursor: () => brushRingCursor(radiusPx),\n onMove(move: InvocationCtx): void {\n const p = params(move);\n radiusPx = radiusOf(p);\n const to = { x: move.world.x, y: move.world.y };\n const radius = worldRadius(deps, radiusPx);\n for (const node of nodes) {\n const from = current.get(node.id)?.path ?? node.path;\n const next = smudgePath(from, {\n center: at, delta: { x: to.x - at.x, y: to.y - at.y }, radius, strength: strengthOf(p),\n });\n if (next !== from) current.set(node.id, { node, path: next });\n }\n at = to;\n },\n onEnd(_end: InvocationCtx, reason: 'commit' | 'cancel'): void {\n const done = [...current.values()];\n current.clear();\n if (reason === 'cancel' || done.length === 0) return;\n commitOps(deps, done.flatMap(({ node, path }) => reshapeOps(node.node, path, LABEL)), LABEL);\n },\n previewIds: () => (current.size > 0 ? [...current.keys()] : null),\n previewPose: (id: string) => shapeOf(id)?.pose ?? null,\n previewData: (id: string) => shapeOf(id)?.data ?? null,\n };\n },\n },\n enabled: (deps) => (selectedPathNodes(deps).length > 0 ? true : ActionDisabledReason.SelectionRequired),\n};\n","/**\n * A spiro node: a path node whose `data.representation` is a spiro form,\n * saying its `data.path` is a solved spiro curve and which of the path's\n * anchors are the curve's points (`spiroToPath`). The path stays the geometry\n * every reader uses; path edit edits the points instead, through the\n * straight-sided control path, and each edit solves the curve again\n * (`spiroRepresentation`). Converting to a path drops the form.\n */\nimport {\n isSpiroKind,\n spiroContoursFromControl,\n spiroContoursOf,\n spiroControlPath,\n spiroToPath,\n type PolygonPath,\n type SpiroContour,\n type SpiroKind,\n} from '@weasel-js/geom';\n\n/** The `kind` of a spiro form. */\nexport const SPIRO_FORM = 'spiro';\n\n/** A spiro form, as `data.representation` holds it: each point's kind, and\n * the anchor of `data.path` it became. */\nexport type SpiroShape = {\n kind: typeof SPIRO_FORM;\n kinds: SpiroKind[];\n at: number[];\n};\n\n/** `form` as a spiro form, or null when it is not a well-formed one. */\nexport function asSpiro(form: unknown): SpiroShape | null {\n const s = form as Partial<SpiroShape> | null | undefined;\n if (!s || s.kind !== SPIRO_FORM || !Array.isArray(s.kinds) || !Array.isArray(s.at)) return null;\n if (s.kinds.length !== s.at.length) return null;\n if (!s.kinds.every(isSpiroKind) || !s.at.every((i) => Number.isInteger(i))) return null;\n return s as SpiroShape;\n}\n\n/** The spiro form a node's `data` holds, or `null`. */\nexport function spiroOf(data: unknown): SpiroShape | null {\n return asSpiro((data as { representation?: unknown } | null | undefined)?.representation);\n}\n\n/** `data` without its spiro form: the curve as plain geometry. */\nexport function withoutSpiro<T>(data: T): T {\n if (!spiroOf(data)) return data;\n const { representation: _dropped, ...rest } = data as Record<string, unknown>;\n void _dropped;\n return rest as T;\n}\n\nconst shapeOf = (kinds: SpiroKind[], at: number[]): SpiroShape => ({ kind: SPIRO_FORM, kinds, at });\n\n/** The node data a solved spiro curve is stored as: its path, and the form\n * that says which anchors are points. */\nexport function spiroNodeData(\n contours: readonly SpiroContour[],\n like?: PolygonPath,\n): { path: PolygonPath; representation: SpiroShape } {\n const { path, at } = spiroToPath(contours, { like });\n return { path, representation: shapeOf(contours.flatMap((c) => c.points.map((p) => p.kind)), at) };\n}\n\n/** The contours `spiro` reads out of `path`, or null when it does not\n * describe it. */\nexport function spiroContours(path: PolygonPath, spiro: SpiroShape): SpiroContour[] | null {\n return spiroContoursOf(path, spiro.kinds, spiro.at);\n}\n\n/** The straight-sided path through `spiro`'s points on `path`: what path\n * edit shows and moves. Null when `spiro` does not describe `path`. */\nexport function spiroEditPath(path: PolygonPath, spiro: SpiroShape): PolygonPath | null {\n const contours = spiroContours(path, spiro);\n return contours ? spiroControlPath(contours) : null;\n}\n\n/**\n * The curve an edit of the control path makes, solved through its anchors:\n * `control` is the edited control path, `path` the curve it was edited from.\n * Each point keeps its kind (`spiroContoursFromControl`). Null when `spiro`\n * does not describe `path`.\n */\nexport function respiro(\n path: PolygonPath,\n spiro: SpiroShape,\n control: PolygonPath,\n): { path: PolygonPath; spiro: SpiroShape } | null {\n const before = spiroContours(path, spiro);\n if (!before) return null;\n const solved = spiroNodeData(spiroContoursFromControl(control, before), path);\n return { path: solved.path, spiro: solved.representation };\n}\n\n/** The curve `path` makes with the points at `flatIndexes` set to `kind`. Null\n * when `spiro` does not describe `path`, or no kind changes. */\nexport function respiroWithKind(\n path: PolygonPath,\n spiro: SpiroShape,\n flatIndexes: Iterable<number>,\n kind: SpiroKind,\n): { path: PolygonPath; spiro: SpiroShape } | null {\n const contours = spiroContours(path, spiro);\n if (!contours) return null;\n const picked = new Set(flatIndexes);\n let i = 0;\n let changed = false;\n const next = contours.map((c) => ({\n closed: c.closed,\n points: c.points.map((p) => {\n const hit = picked.has(i++) && p.kind !== kind;\n changed ||= hit;\n return hit ? { ...p, kind } : p;\n }),\n }));\n if (!changed) return null;\n const solved = spiroNodeData(next, path);\n return { path: solved.path, spiro: solved.representation };\n}\n","/**\n * Commands on spiro curves (`spiroShape`): set the kind of the points\n * selected in path edit, and convert a spiro curve to an ordinary path.\n */\nimport { ActionDisabledReason, type Action, type ActionDeps, type ImmediateInvoker } from '@weasel-js/routing';\nimport { SPIRO_KINDS, isSpiroKind, type SpiroKind } from '@weasel-js/geom';\nimport {\n commitOps, createSetDataOp, pathOperationTags, reshapeTo, resolveEditablePathOf, storeEditablePath,\n type NodeId, type Op, type SceneNode,\n} from '@weasel-js/core';\nimport { respiroWithKind, spiroOf, withoutSpiro } from './spiroShape';\n\ntype AnyNode = SceneNode<unknown, string, unknown>;\n\nconst KIND_LABELS: Record<SpiroKind, string> = {\n smooth: 'Smooth spiro point',\n g4: 'Extra-smooth (G4) spiro point',\n corner: 'Corner spiro point',\n left: 'Spiro point after a line',\n right: 'Spiro point before a line',\n};\n\nconst nodeOf = (deps: ActionDeps | undefined, id: string): AnyNode | undefined =>\n deps?.scene?.get(id as NodeId) as AnyNode | undefined;\n\n/** The spiro node being edited in path edit, or null. */\nfunction editedSpiro(deps: ActionDeps | undefined): AnyNode | null {\n const id = deps?.editAnchors?.editingId;\n const node = id ? nodeOf(deps, id) : undefined;\n return node && spiroOf(node.data) ? node : null;\n}\n\n/** The ops giving the selected points of the edited spiro the kind `kind`,\n * or null when that changes nothing. */\nfunction setKindOps(deps: ActionDeps | undefined, kind: SpiroKind, label: string): Op[] | null {\n const node = editedSpiro(deps);\n const selected = deps?.editAnchors?.selectedAnchors;\n const world = node ? resolveEditablePathOf(node) : null;\n if (!node || !world || !selected || selected.size === 0) return null;\n const solved = respiroWithKind(world, spiroOf(node.data)!, selected, kind);\n if (!solved) return null;\n const stored = storeEditablePath({ pose: node.pose, data: withoutSpiro(node.data) }, solved.path);\n if (!stored) return null;\n return reshapeTo(node, { pose: stored.pose, data: { ...(stored.data as object), representation: solved.spiro } }, label);\n}\n\nconst kindOf = (params: Record<string, unknown> | undefined): SpiroKind =>\n (isSpiroKind(params?.kind) ? params.kind : 'smooth');\n\n/**\n * @experimental In path edit on a spiro curve, give the selected points the\n * kind `params.kind` (default `'smooth'`) and solve the curve again. One\n * variant per kind.\n */\nexport const setSpiroKindAction: Action & { requires: string[] } = {\n id: 'setSpiroKind',\n label: 'Set spiro point kind',\n tags: pathOperationTags('command'),\n group: 'spiro',\n variants: SPIRO_KINDS.map((kind) => ({ key: kind, label: KIND_LABELS[kind], params: { kind } })),\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors', 'scene', 'applyOps'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const kind = kindOf(params);\n const ops = setKindOps(deps, kind, KIND_LABELS[kind]);\n if (ops) commitOps(deps, ops, KIND_LABELS[kind]);\n },\n } satisfies ImmediateInvoker,\n enabled: (deps) =>\n (editedSpiro(deps) && deps?.editAnchors?.selectedAnchors.size ? true : ActionDisabledReason.SelectionRequired),\n};\n\n/** The selected spiro nodes, or the one in path edit. */\nfunction spiroTargets(deps: ActionDeps | undefined): AnyNode[] {\n const edited = deps?.editAnchors?.editingId;\n const ids = edited ? [edited] : (deps?.selection?.get() ?? []);\n return ids.flatMap((id) => {\n const node = nodeOf(deps, id);\n return node && spiroOf(node.data) ? [node] : [];\n });\n}\n\nconst RELEASE_LABEL = 'Convert to path';\n\n/**\n * @experimental Convert the selected spiro curves, or the one in path edit, to\n * ordinary paths: the curve stays as drawn and its anchors and handles become\n * editable, while the spiro points stop being solved. Path edit's anchor\n * selection is cleared, since the anchors it numbered are gone.\n */\nexport const releaseSpiroAction: Action & { requires: string[] } = {\n id: 'releaseSpiro',\n label: RELEASE_LABEL,\n tags: pathOperationTags('command'),\n group: 'spiro',\n requires: ['selection', 'scene', 'applyOps', 'editAnchors'],\n invoker: {\n timing: 'immediate',\n run: (deps) => {\n const nodes = spiroTargets(deps);\n if (nodes.length === 0) return;\n commitOps(deps, nodes.map((node) => createSetDataOp({\n id: node.id, from: node.data, to: withoutSpiro(node.data), label: RELEASE_LABEL,\n })), RELEASE_LABEL);\n if (deps.editAnchors?.editingId) deps.editAnchors.setSelectedAnchors([]);\n },\n } satisfies ImmediateInvoker,\n enabled: (deps) => (spiroTargets(deps).length > 0 ? true : ActionDisabledReason.SelectionRequired),\n};\n","/**\n * How a spiro point is marked, by its kind: a circle for a smooth point, a\n * diamond for a g4 point, a square for a corner, and a half-disc for a point\n * beside a straight segment, its flat side toward the line.\n */\nimport { circlePath, polygonFromPoints, squarePath, type PolygonPath, type SpiroKind } from '@weasel-js/geom';\nimport type { AnchorMarkerShape } from '@weasel-js/core';\n\ntype Point = { x: number; y: number };\n\nconst HALF_DISC_STEPS = 12;\n\n/** A half-disc of radius `r` centered on `(x, y)`, bulging toward `toward`. */\nfunction halfDisc(x: number, y: number, r: number, toward: Point): PolygonPath {\n const mid = Math.atan2(toward.y, toward.x);\n const pts: Point[] = [];\n for (let i = 0; i <= HALF_DISC_STEPS; i++) {\n const a = mid - Math.PI / 2 + (Math.PI * i) / HALF_DISC_STEPS;\n pts.push({ x: x + r * Math.cos(a), y: y + r * Math.sin(a) });\n }\n return polygonFromPoints(pts);\n}\n\n/**\n * The marker shape of a spiro point of `kind`. A `left` point's line arrives\n * from its previous neighbor and a `right` point's leaves toward its next,\n * both in the same screen space; without that neighbor the half-disc faces\n * right.\n */\nexport function spiroMarker(kind: SpiroKind): AnchorMarkerShape {\n if (kind === 'smooth') return (at, size) => circlePath(at.x, at.y, size / 2);\n if (kind === 'corner') return (at, size) => squarePath(at.x, at.y, size);\n if (kind === 'g4') {\n return (at, size) => {\n const r = (size / 2) * 1.25;\n return polygonFromPoints([\n { x: at.x, y: at.y - r }, { x: at.x + r, y: at.y }, { x: at.x, y: at.y + r }, { x: at.x - r, y: at.y },\n ]);\n };\n }\n return (at, size, prev, next) => {\n const from = kind === 'left' ? prev : next;\n const away = from ? { x: at.x - from.x, y: at.y - from.y } : { x: 1, y: 0 };\n const toward = away.x === 0 && away.y === 0 ? { x: 1, y: 0 } : away;\n return halfDisc(at.x, at.y, (size / 2) * 1.2, toward);\n };\n}\n","/**\n * A press on a spiro curve in path edit, between two points: it inserts a\n * smooth point there and drags it, the curve solved again through it on\n * every move. A spiro curve has no handles to bend, so this is what pulling\n * on its outline means.\n */\nimport type { ActionDeps, InvocationCtx, OngoingHandle } from '@weasel-js/routing';\nimport {\n cubicPointAt, flatAnchorIndex, nearestSegmentT, pathToAnchors, spiroControlPath, withinPxRadius,\n type PolygonPath, type SpiroContour,\n} from '@weasel-js/geom';\nimport { pathEditPreview, type EditAnchorsDep } from '@weasel-js/core';\nimport { spiroContours, spiroOf } from './spiroShape';\n\n/** Screen-px reach of the curve, as the segment affordance's. */\nconst CURVE_HIT_PX = 8;\n\n/** Where a press on the edited spiro curve adds a point: before `slot` in\n * contour `sub` of `contours`, the curve's points as the press found them. */\ninterface SpiroInsertAt {\n dep: EditAnchorsDep;\n contours: SpiroContour[];\n sub: number;\n slot: number;\n}\n\n/** The spiro curve in path edit, and where a press at `(x, y)` on it inserts\n * a point. Null when no spiro curve is edited or the press misses it. */\nfunction spiroInsertAt(deps: ActionDeps, x: number, y: number): SpiroInsertAt | null {\n const dep = deps.editAnchors;\n const spiro = dep?.editingId ? spiroOf(dep.getNodeShape(dep.editingId)?.data) : null;\n const curve = spiro ? (dep!.getOutlinePath?.(dep!.editingId) as PolygonPath | null | undefined) : null;\n if (!dep || !spiro || !curve) return null;\n const contours = spiroContours(curve, spiro);\n if (!contours) return null;\n const set = pathToAnchors(curve);\n const hit = nearestSegmentT(set.anchors, x, y, set.closed);\n if (!hit) return null;\n const scale = deps.view?.get().scale ?? { x: 1, y: 1 };\n const on = set.anchors[hit.sub];\n const a = on[hit.segIdx];\n const b = on[(hit.segIdx + 1) % on.length];\n const p = cubicPointAt(a, a.outHandle ?? a, b.inHandle ?? b, b, hit.t);\n if (!withinPxRadius(p.x - x, p.y - y, CURVE_HIT_PX, scale)) return null;\n const points = contours[hit.sub].points;\n if (points.some((q) => withinPxRadius(q.x - x, q.y - y, CURVE_HIT_PX, scale))) return null;\n // The point the hit segment's spiro segment starts from: the last at or before it.\n const flat = flatAnchorIndex(set, hit.sub, hit.segIdx);\n const first = contours.slice(0, hit.sub).reduce((n, c) => n + c.points.length, 0);\n const at = spiro.at.slice(first, first + points.length);\n let from = 0;\n while (from + 1 < at.length && at[from + 1] <= flat) from++;\n return { dep, contours, sub: hit.sub, slot: from + 1 };\n}\n\n/** The drag that inserts a smooth point at the press and moves it. */\nfunction spiroInsertDrag(insert: SpiroInsertAt): OngoingHandle {\n const { dep, contours, sub, slot } = insert;\n const id = dep.editingId;\n const flat = contours.slice(0, sub).reduce((n, c) => n + c.points.length, 0) + slot;\n const control = (x: number, y: number): PolygonPath => spiroControlPath(contours.map((c, s) => (s !== sub ? c : {\n closed: c.closed,\n points: [...c.points.slice(0, slot), { x, y, kind: 'smooth' }, ...c.points.slice(slot)],\n })));\n let current: PolygonPath | null = null;\n const preview = pathEditPreview(dep, id, () => current);\n if (!preview) return {};\n dep.setSelectedAnchors([flat]);\n return {\n kind: 'spiro-insert-point',\n onMove(moveCtx: InvocationCtx): void {\n current = control(moveCtx.world.x, moveCtx.world.y);\n },\n onEnd(endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n current = null;\n if (reason === 'cancel') {\n dep.setSelectedAnchors([]);\n return;\n }\n dep.applyEdit(id, control(endCtx.world.x, endCtx.world.y), 'Add spiro point');\n },\n previewIds: preview.previewIds,\n previewPose: preview.previewPose,\n previewData: preview.previewData,\n };\n}\n\n/** The drag a press at `at` on the spiro curve in path edit starts, or null\n * when the press misses the curve or lands on one of its points. */\nexport function spiroSegmentPress(deps: ActionDeps, at: { x: number; y: number }): (() => OngoingHandle) | null {\n const insert = spiroInsertAt(deps, at.x, at.y);\n return insert ? () => spiroInsertDrag(insert) : null;\n}\n","/**\n * Spiro curves in path edit: a spiro node is edited through its straight-sided\n * control path, whose anchors are the curve's points, and every edit solves\n * the curve again through them. Each point draws by its kind, and a press on\n * the curve between two points adds one there.\n */\nimport type { PathEditExtension, PathRepresentation } from '@weasel-js/core';\nimport { asSpiro, respiro, SPIRO_FORM, spiroEditPath } from './spiroShape';\nimport { spiroMarker } from './spiroMarkers';\nimport { spiroSegmentPress } from './spiroInsertPoint';\n\n/** How path edit reads and writes a spiro form. */\nexport const spiroRepresentation: PathRepresentation = {\n kind: SPIRO_FORM,\n editPath(path, form) {\n const spiro = asSpiro(form);\n return spiro && spiroEditPath(path, spiro);\n },\n store(path, form, edited) {\n const spiro = asSpiro(form);\n const solved = spiro && respiro(path, spiro, edited);\n return solved && { path: solved.path, form: solved.spiro };\n },\n anchorMarkers: (form) => asSpiro(form)?.kinds.map(spiroMarker) ?? [],\n segmentPress: spiroSegmentPress,\n};\n\n/** The path-edit extension carrying {@link spiroRepresentation}. */\nexport const spiroExtension: PathEditExtension = { id: 'spiro', representation: spiroRepresentation };\n","import type { FeaturePreset } from '@weasel-js/core';\nimport { releaseSpiroAction, setSpiroKindAction } from './spiroCommands';\nimport { spiroExtension } from './spiroRepresentation';\n\n/** Spiro curves: path edit edits a spiro node's points and solves the curve\n * again through them (`spiroRepresentation`), `setSpiroKind` sets the kind\n * of the selected points, and `releaseSpiro` converts a spiro curve to an\n * ordinary path. `useSpiroTool` draws them. */\nexport const spiroPreset: FeaturePreset = {\n id: 'spiro',\n actions: [setSpiroKindAction, releaseSpiroAction],\n pathEdit: [spiroExtension],\n};\n","/** Trim segment: cut a stroke back to the crossings on either side of a click. */\nimport type { Action, ActionDeps, ImmediateInvoker } from '@weasel-js/routing';\nimport { trimPathAt, type TrimResult } from '@weasel-js/geom';\nimport { commitOps, deleteNode, reshapeOps, type PathNode, pathOperationTags } from '@weasel-js/core';\nimport { pressOf, scenePathNodes, strokesBesides } from '../shared/scenePaths';\nimport { icon } from '../icons.gen';\n\nconst TRIM_LABEL = 'Trim segment';\n\n/** What a trim at the press in `params` would do: the stroke it reaches, and\n * what `trimPathAt` makes of it. Null when it reaches none it can trim.\n * `params` as {@link trimPathAction} reads them; a hover's pointer serves\n * as the press, which is how a tool previews the piece. */\nexport function planTrim(\n deps: ActionDeps,\n params: unknown,\n): { target: PathNode; result: TrimResult } | null {\n const press = pressOf(deps, params);\n if (!press) return null;\n const all = scenePathNodes(deps);\n for (let i = all.length - 1; i >= 0; i--) {\n const target = all[i];\n const result = trimPathAt(target.path, strokesBesides(deps, target.id), press.at, { radius: press.radius });\n if (result) return { target, result };\n }\n return null;\n}\n\n/**\n * Trim segment: remove the piece of the stroke under the press\n * between the nearest crossings on either side — with any other node's\n * outline, or with itself — as `trimPathAt` cuts it. The topmost stroke\n * within `radiusPx` of the press (default 6) is the one trimmed; a stroke\n * with nothing left is deleted. Params: `pressX`, `pressY` in world space,\n * which a click binding supplies.\n */\nexport const trimPathAction: Action & { requires: string[] } = {\n id: 'trimPath',\n icon: /* @icon */ 'path-tools:trim',\n label: TRIM_LABEL,\n tags: pathOperationTags('click'),\n group: 'path',\n eligible: { capability: 'creates-shapes' },\n requires: ['scene', 'applyOps', 'selection', 'view'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const plan = deps.scene ? planTrim(deps, params) : null;\n if (!plan) return;\n const { target, result } = plan;\n const gone = result.path.commands.length === 0;\n const ops = gone\n ? [deleteNode(deps.scene as never, target.node, TRIM_LABEL)]\n : reshapeOps(target.node, result.path, TRIM_LABEL);\n commitOps(deps, ops, TRIM_LABEL);\n if (gone) deps.selection?.set((deps.selection.get() ?? []).filter((id) => id !== target.id) as never);\n },\n } satisfies ImmediateInvoker,\n enabled: () => true,\n};\n","/**\n * A warp a node is holding: the path it warped, the warp, and the tolerance\n * the result was refitted to, kept on the node as `data.warp` beside the\n * `data.path` (or polygon pose) they produced. The geometry stays what every\n * reader uses; the warp only says how to make it again, so it can be edited\n * until it is expanded away.\n *\n * The warp lives in its own frame, fixed when it was made. `frame` carries\n * that frame onto the stored path, so moving, resizing or rotating the node\n * keeps the warp without touching it. A writer that changes the geometry some\n * other way leaves a warp that no longer reproduces it, and such a warp is\n * ignored, the way a stale shape generator is.\n */\nimport {\n boundsOfPath,\n boxToBox,\n fitAffine,\n identity,\n invert,\n multiply,\n poseFrameOf,\n type Affine,\n type PolygonPath,\n} from '@weasel-js/geom';\nimport { applyPathWarp, type PathWarp } from '@weasel-js/geom/warp';\nimport { classifyPathStorage, type EditableShape } from '@weasel-js/core';\n\n/** What `data.warp` holds. */\nexport interface HeldPathWarp {\n /** Shared by every node warped together, so one handle drives them all. */\n id: string;\n /** The path before warping, in the warp's frame. */\n source: PolygonPath;\n warp: PathWarp;\n /** How far the refitted result may stray from the exact warp. */\n tolerance: number;\n /** From the warp's frame to the frame the node stores its path in. */\n frame: Affine;\n}\n\n/** A held warp that still reproduces its node, and where its frame lands in\n * world space now. */\nexport interface ResolvedPathWarp {\n held: HeldPathWarp;\n /** From the warp's frame to world space. */\n toWorld: Affine;\n}\n\nconst results = new WeakMap<HeldPathWarp, PolygonPath>();\n\n/** The warped path `held` makes, in its own frame. Cached per held warp. */\nexport function heldWarpResult(held: HeldPathWarp): PolygonPath {\n let out = results.get(held);\n if (!out) {\n out = applyPathWarp(held.source, held.warp, held.tolerance);\n results.set(held, out);\n }\n return out;\n}\n\n/** Record that `held` makes `result`, so resolving it later skips the warp. */\nexport function rememberWarpResult(held: HeldPathWarp, result: PolygonPath): void {\n results.set(held, result);\n}\n\nfunction isHeldWarp(v: unknown): v is HeldPathWarp {\n if (v === null || typeof v !== 'object') return false;\n const h = v as Partial<HeldPathWarp>;\n return typeof h.id === 'string' && typeof h.tolerance === 'number'\n && (h.source as { kind?: string } | undefined)?.kind === 'polygon'\n && typeof (h.warp as { kind?: unknown } | undefined)?.kind === 'string'\n && Array.isArray(h.frame) && h.frame.length === 6;\n}\n\n/** The warp a node's `data` holds, whether or not it still matches. */\nexport function heldPathWarpOf(data: unknown): HeldPathWarp | null {\n const w = (data as { warp?: unknown } | null | undefined)?.warp;\n return isHeldWarp(w) ? w : null;\n}\n\n/** `data` without its warp: the shape as plain geometry. */\nexport function withoutPathWarp<T>(data: T): T {\n if (data === null || typeof data !== 'object' || !('warp' in data)) return data;\n const { warp: _dropped, ...rest } = data as Record<string, unknown>;\n void _dropped;\n return rest as T;\n}\n\n/** The path a node stores and the map from that storage to world space. */\nexport function storedPathOf(node: EditableShape): { path: PolygonPath; toWorld: Affine } | null {\n const storage = classifyPathStorage(node);\n if (!storage) return null;\n if (storage.kind === 'pose') return { path: node.pose as PolygonPath, toWorld: identity() };\n const { pose, data } = storage;\n const b = boundsOfPath(data.path);\n const box = boxToBox(b.x, b.y, b.width, b.height, pose.x, pose.y, pose.width, pose.height);\n return { path: data.path, toWorld: multiply(poseFrameOf(pose) ?? identity(), box) };\n}\n\n/** Whether every coordinate of `a`, carried by `m`, lands on `b`'s. */\nfunction sameUnder(a: PolygonPath, m: Affine, b: PolygonPath): boolean {\n if (a.coords.length !== b.coords.length || a.commands.length !== b.commands.length) return false;\n const bb = boundsOfPath(b);\n // Stored paths are float32, so the slack scales with their distance from the origin.\n const tol = 1e-3 * Math.max(1, Math.abs(bb.x) + bb.width, Math.abs(bb.y) + bb.height);\n for (let i = 0; i + 1 < a.coords.length; i += 2) {\n const x = m[0] * a.coords[i] + m[2] * a.coords[i + 1] + m[4];\n const y = m[1] * a.coords[i] + m[3] * a.coords[i + 1] + m[5];\n if (Math.abs(x - b.coords[i]) > tol || Math.abs(y - b.coords[i + 1]) > tol) return false;\n }\n return true;\n}\n\n/**\n * The warp `node` holds and its frame in world space, or null when it holds\n * none or the one it holds no longer reproduces its geometry. A node whose\n * stored path was rewritten by an affine map since — a polygon pose moved,\n * resized or rotated, which rewrites its coordinates — still resolves: the\n * map is recovered from the two sets of points and replaces `frame`.\n */\nexport function resolvePathWarp(node: EditableShape | null | undefined): ResolvedPathWarp | null {\n if (!node) return null;\n const held = heldPathWarpOf(node.data);\n if (!held) return null;\n const stored = storedPathOf(node);\n if (!stored) return null;\n const made = heldWarpResult(held);\n let toStorage: Affine | null = held.frame;\n if (!sameUnder(made, toStorage, stored.path)) {\n toStorage = made.coords.length === stored.path.coords.length ? fitAffine(made.coords, stored.path.coords) : null;\n if (!toStorage || !sameUnder(made, toStorage, stored.path)) return null;\n }\n return { held, toWorld: multiply(stored.toWorld, toStorage) };\n}\n\n/**\n * The frame to store with a warp whose world map is `toWorld`, once `node`\n * holds its result. Null when the node's storage cannot be inverted.\n */\nexport function warpFrameFor(node: EditableShape, toWorld: Affine): Affine | null {\n const stored = storedPathOf(node);\n const back = stored && invert(stored.toWorld);\n return back ? multiply(back, toWorld) : null;\n}\n","/**\n * What every warp action shares: finding the selected paths' warps of one\n * kind, making fresh ones where a path holds none, and writing a changed warp\n * back as the geometry it makes plus the warp itself.\n */\nimport type { ActionDeps } from '@weasel-js/routing';\nimport {\n applyToPoint,\n boundsOfPath,\n identity,\n transformPath,\n type Affine,\n type PolygonPath,\n} from '@weasel-js/geom';\nimport {\n distortOver,\n envelopeOver,\n resizeEnvelope,\n warpControls,\n type DistortMode,\n type EnvelopeMapping,\n type PathWarp,\n type WarpBox,\n} from '@weasel-js/geom/warp';\nimport {\n heldWarpResult, rememberWarpResult, resolvePathWarp, warpFrameFor, type HeldPathWarp,\n} from './pathWarp';\nimport { type PathNode, resolveEditablePathOf, type SceneNode, selectedPathNodes, withPath } from '@weasel-js/core';\n\ntype AnyNode = SceneNode<unknown, string, unknown>;\n\n/** Which warp a tool or action works with. */\nexport type WarpKind = PathWarp['kind'];\n\n/** Each kind's name, as its tool and its actions are labeled. */\nexport const WARP_LABELS: Record<WarpKind, string> = { distort: 'Distort', envelope: 'Envelope', puppet: 'Puppet Warp' };\n\n/** The settings a warp is made or remade with. Each applies only to the kinds\n * it names; absent ones leave a held warp as it is. */\nexport interface WarpSettings {\n /** A distort's map. Default `'free'`. */\n mode?: DistortMode;\n /** An envelope's interpolation. Default `'bicubic'`. */\n mapping?: EnvelopeMapping;\n /** An envelope's patch rows and columns. Default 3 each. */\n rows?: number;\n cols?: number;\n /** How far, in world units, the refitted result may stray from the exact\n * warp. Default {@link DEFAULT_WARP_TOLERANCE}. */\n tolerance?: number;\n}\n\n/** The refit tolerance of a warp made without one. */\nexport const DEFAULT_WARP_TOLERANCE = 0.5;\n/** The patch rows and columns of an envelope made without them. */\nexport const DEFAULT_ENVELOPE_SIZE = 3;\n\nconst count = (v: number | undefined, fallback: number) =>\n Math.min(16, Math.max(1, Math.round(v ?? fallback)));\n\n/** A selected path, the warp it is being warped by, and that warp's frame in\n * world space. `fresh` when the warp was made just now rather than held. */\nexport interface WarpTarget {\n node: PathNode;\n held: HeldPathWarp;\n toWorld: Affine;\n fresh: boolean;\n}\n\n/** A fresh warp of `kind` over `box` that leaves it where it is. */\nexport function freshWarp(kind: WarpKind, box: WarpBox, settings: WarpSettings): PathWarp {\n switch (kind) {\n case 'distort': return distortOver(box, settings.mode ?? 'free');\n case 'envelope':\n return envelopeOver(\n box,\n count(settings.rows, DEFAULT_ENVELOPE_SIZE),\n count(settings.cols, DEFAULT_ENVELOPE_SIZE),\n settings.mapping ?? 'bicubic',\n );\n case 'puppet': return { kind: 'puppet', pins: [] };\n }\n}\n\n/** `held` remade under `settings`: a new mode, mapping or tolerance, and an\n * envelope resampled to a new grid. */\nexport function withWarpSettings(held: HeldPathWarp, settings: WarpSettings): HeldPathWarp {\n const { warp } = held;\n let next: PathWarp = warp;\n if (warp.kind === 'distort' && settings.mode && settings.mode !== warp.mode) next = { ...warp, mode: settings.mode };\n if (warp.kind === 'envelope') {\n const sized = resizeEnvelope(\n warp,\n count(settings.rows, warp.mesh.rows),\n count(settings.cols, warp.mesh.cols),\n );\n next = settings.mapping && settings.mapping !== sized.mapping ? { ...sized, mapping: settings.mapping } : sized;\n }\n const tolerance = settings.tolerance !== undefined && settings.tolerance > 0 ? settings.tolerance : held.tolerance;\n if (next === warp && tolerance === held.tolerance) return held;\n return { ...held, warp: next, tolerance };\n}\n\n/** The box, in world space, around every path in `nodes`. */\nexport function worldBoxOf(nodes: readonly PathNode[]): WarpBox | null {\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const { path } of nodes) {\n const b = boundsOfPath(path);\n x0 = Math.min(x0, b.x); y0 = Math.min(y0, b.y);\n x1 = Math.max(x1, b.x + b.width); y1 = Math.max(y1, b.y + b.height);\n }\n return x0 <= x1 ? { x: x0, y: y0, width: x1 - x0, height: y1 - y0 } : null;\n}\n\nlet freshIds = 0;\n/** An id no other warp made in this session holds. */\nfunction freshWarpId(): string {\n return `warp-${Date.now().toString(36)}-${(++freshIds).toString(36)}`;\n}\n\n/** Whether two targets' warps put the same controls in the same places. */\nfunction samePlacement(a: WarpTarget, b: WarpTarget): boolean {\n const ca = warpControls(a.held.warp), cb = warpControls(b.held.warp);\n if (ca.length !== cb.length) return false;\n const m = a.toWorld, n = b.toWorld;\n const scale = Math.max(1, Math.abs(m[0]) + Math.abs(m[1]) + Math.abs(m[2]) + Math.abs(m[3]));\n for (let i = 0; i < 4; i++) if (Math.abs(m[i] - n[i]) > 1e-4 * scale) return false;\n const box = worldBoxOf([a.node]);\n const tol = 1e-3 * Math.max(1, box ? Math.abs(box.x) + box.width + Math.abs(box.y) + box.height : 1);\n if (Math.hypot(m[4] - n[4], m[5] - n[5]) > tol * scale) return false;\n return ca.every((p, i) => {\n const [ax, ay] = applyToPoint(m, p.x, p.y);\n const [bx, by] = applyToPoint(n, cb[i].x, cb[i].y);\n return Math.hypot(ax - bx, ay - by) <= tol;\n });\n}\n\n/**\n * `nodes` split into those holding a warp of `kind` that still matches their\n * geometry, and the rest, with the box around the rest — where a fresh warp\n * for them goes.\n *\n * Paths warped together share their warp's id, but each keeps its own copy,\n * carried with it. Once one is moved or edited alone its copy no longer sits\n * where the others' do, and it is no longer driven with them: it comes back\n * under an id of its own, which the next edit writes to it.\n */\nexport function splitByWarp(\n nodes: readonly PathNode[],\n kind: WarpKind,\n): { held: WarpTarget[]; bare: PathNode[]; box: WarpBox | null } {\n const held: WarpTarget[] = [];\n const bare: PathNode[] = [];\n const groups = new Map<string, WarpTarget[]>();\n for (const node of nodes) {\n const resolved = resolvePathWarp(node.node);\n if (!resolved || resolved.held.warp.kind !== kind) {\n bare.push(node);\n continue;\n }\n let target: WarpTarget = { node, ...resolved, fresh: false };\n const id = resolved.held.id;\n const firsts = groups.get(id) ?? [];\n const joined = firsts.find((f) => samePlacement(f, target));\n const groupId = joined ? joined.held.id : firsts.length > 0 ? `${id}~${node.id}` : id;\n if (groupId !== id) {\n const parted = { ...resolved.held, id: groupId };\n rememberWarpResult(parted, heldWarpResult(resolved.held));\n target = { ...target, held: parted };\n }\n if (!joined) groups.set(id, [...firsts, target]);\n held.push(target);\n }\n return { held, bare, box: worldBoxOf(bare) };\n}\n\n/**\n * The selected paths' warps of `kind`. A path holding one that still matches\n * its geometry keeps it; the rest get one fresh warp shared between them,\n * laid over the box around them all, so dragging one of its controls warps\n * them together.\n */\nexport function warpTargets(deps: ActionDeps | undefined, kind: WarpKind, settings: WarpSettings): WarpTarget[] {\n const { held: out, bare, box } = splitByWarp(selectedPathNodes(deps), kind);\n if (!box) return out;\n const id = freshWarpId();\n const warp = freshWarp(kind, box, settings);\n const tolerance = settings.tolerance !== undefined && settings.tolerance > 0 ? settings.tolerance : DEFAULT_WARP_TOLERANCE;\n for (const node of bare) {\n const frame = warpFrameFor(node.node, identity());\n if (!frame) continue;\n // A fresh warp's frame is world space, so its source is the path as drawn.\n out.push({ node, held: { id, source: node.path, warp, tolerance, frame }, toWorld: identity(), fresh: true });\n }\n return out;\n}\n\n/**\n * `shape` (a node's pose and data) warped by `warp`, whose controls are in\n * world space, and holding it — for a scene that opens on a warp already\n * made. Null when `shape` holds no editable polygon.\n */\nexport function withPathWarp<S extends { pose: unknown; data: unknown }>(\n shape: S,\n warp: PathWarp,\n opts: { id?: string; tolerance?: number } = {},\n): { pose: unknown; data: unknown } | null {\n const source = resolveEditablePathOf(shape);\n if (!source) return null;\n const held: HeldPathWarp = {\n id: opts.id ?? freshWarpId(),\n source,\n warp,\n tolerance: opts.tolerance ?? DEFAULT_WARP_TOLERANCE,\n frame: identity(),\n };\n return storeWarp(shape as unknown as AnyNode, held, identity());\n}\n\n/** `node` holding `held`, its geometry what `held` makes under `toWorld`. */\nexport function storeWarp(node: AnyNode, held: HeldPathWarp, toWorld: Affine): { pose: unknown; data: unknown } | null {\n const made = heldWarpResult(held);\n const next = withPath(node, transformPath(made, toWorld) as PolygonPath);\n if (!next) return null;\n const frame = warpFrameFor(next, toWorld);\n if (!frame) return null;\n const kept: HeldPathWarp = { ...held, frame };\n rememberWarpResult(kept, made);\n return { pose: next.pose, data: { ...(next.data as object), warp: kept } };\n}\n","/**\n * The warp actions. A warp tool binds the per-kind ones (`<kind>.drag`,\n * `puppet.addPin`, `puppet.removePin`) and owns them; `expandWarp` and\n * `configureWarp` work on whatever warp the selection holds and ship with\n * the `paths` preset.\n */\nimport {\n type Action, type ActionDeps, ActionDisabledReason, type BindingOpts, type ImmediateInvoker, type InvocationCtx, type OngoingHandle, resolveParams,\n} from '@weasel-js/routing';\nimport { createEmitter } from '@weasel-js/registry';\nimport { applyToPoint, invert, type Point } from '@weasel-js/geom';\nimport { moveWarpControl, pathWarpMap, unwarpPoint, warpControls } from '@weasel-js/geom/warp';\nimport { commitOps, createSetDataOp, type Op, reshapeTo, selectedPathNodes, pathOperationTags } from '@weasel-js/core';\nimport { heldPathWarpOf, resolvePathWarp, withoutPathWarp } from './pathWarp';\nimport {\n storeWarp, WARP_LABELS, warpTargets, withWarpSettings, type WarpKind, type WarpSettings, type WarpTarget,\n} from './warpTargets';\nimport { icon } from '../icons.gen';\n\n/** What a press on a warp control hands the drag that follows. */\nexport interface WarpHandleScratch {\n /** The warp the control belongs to, or null for one shown over a selection\n * holding none yet, which the drag makes. */\n warpId: string | null;\n /** The control's index, as `warpControls` counts them. */\n index: number;\n}\n\n/** Nodes as an in-flight warp drag would leave them, for the chrome drawing\n * the warp's controls to follow the drag rather than the scene. */\nexport interface WarpLive {\n get(id: string): { pose: unknown; data: unknown } | undefined;\n set(next: ReadonlyMap<string, { pose: unknown; data: unknown }> | null): void;\n subscribe(listener: () => void): () => void;\n}\n\n/** An empty {@link WarpLive}. */\nexport function createWarpLive(): WarpLive {\n let current: ReadonlyMap<string, { pose: unknown; data: unknown }> | null = null;\n const changed = createEmitter();\n return {\n get: (id) => current?.get(id),\n set: (next) => { current = next; changed.emit(); },\n subscribe: changed.subscribe,\n };\n}\n\n/** The scratch a control press carried, or null when the press was elsewhere. */\nexport function warpHandleScratchOf(hit: unknown): WarpHandleScratch | null {\n const payload = (hit as { payload?: unknown } | null | undefined)?.payload as Partial<WarpHandleScratch> | undefined;\n return payload && typeof payload.index === 'number' && payload.warpId !== undefined\n ? payload as WarpHandleScratch\n : null;\n}\n\nconst REQUIRES: ('selection' | 'scene' | 'applyOps')[] = ['selection', 'scene', 'applyOps'];\n\nfunction commitTargets(deps: ActionDeps, next: ReadonlyMap<string, { target: WarpTarget; shape: { pose: unknown; data: unknown } }>, label: string): void {\n const ops: Op[] = [];\n for (const { target, shape } of next.values()) ops.push(...reshapeTo(target.node.node, shape, label));\n commitOps(deps, ops, label);\n}\n\n/**\n * Drag one control of the selection's `kind` warp: a distort's corner, an\n * envelope's mesh point, a puppet's pin. Every selected path sharing that warp\n * follows the control. A press on the controls shown over a selection with no\n * warp of this kind yet makes one, from the binding's params\n * ({@link WarpSettings}), and the drag is its first edit. One undo step.\n */\nexport function createWarpDragAction(kind: WarpKind, live?: WarpLive): Action {\n const label = WARP_LABELS[kind];\n return {\n id: `${kind}.drag`,\n label: `${label} — drag control`,\n tags: pathOperationTags(kind === 'puppet' ? 'brush' : 'box'),\n requires: REQUIRES,\n invoker: {\n timing: 'ongoing',\n start(ctx: InvocationCtx, opts?: BindingOpts): OngoingHandle {\n const scratch = warpHandleScratchOf(ctx.drag?.affordance);\n if (!scratch) return {};\n const settings = (resolveParams(opts?.params) ?? {}) as WarpSettings;\n const targets = warpTargets(ctx.deps, kind, settings)\n .filter((t) => (scratch.warpId === null ? t.fresh : t.held.id === scratch.warpId));\n const first = targets[0];\n const control = first && warpControls(first.held.warp)[scratch.index];\n if (!control) return {};\n const deps = ctx.deps;\n const [cx, cy] = applyToPoint(first.toWorld, control.x, control.y);\n const press = ctx.drag?.start ?? ctx.world;\n let current = new Map<string, { target: WarpTarget; shape: { pose: unknown; data: unknown } }>();\n const publish = () => live?.set(new Map([...current].map(([id, e]) => [id, e.shape])));\n return {\n kind: `${kind}.drag`,\n onMove(m: InvocationCtx): void {\n const at = m.drag?.current ?? m.world;\n const world = { x: cx + at.x - press.x, y: cy + at.y - press.y };\n current = new Map();\n for (const target of targets) {\n const back = invert(target.toWorld);\n if (!back) continue;\n const [lx, ly] = applyToPoint(back, world.x, world.y);\n const held = { ...target.held, warp: moveWarpControl(target.held.warp, scratch.index, { x: lx, y: ly }) };\n const shape = storeWarp(target.node.node, held, target.toWorld);\n if (shape) current.set(target.node.id, { target, shape });\n }\n publish();\n },\n onEnd(_end: InvocationCtx, reason: 'commit' | 'cancel'): void {\n const done = current;\n current = new Map();\n live?.set(null);\n if (reason === 'commit' && done.size > 0) commitTargets(deps, done, label);\n },\n previewIds: () => (current.size > 0 ? [...current.keys()] : null),\n previewPose: (id: string) => current.get(id)?.shape.pose ?? null,\n previewData: (id: string) => current.get(id)?.shape.data ?? null,\n };\n },\n },\n };\n}\n\n/** A click's world point: where the press landed. */\nfunction clickPoint(params: Record<string, unknown> | undefined): Point | null {\n const x = (params?.pressX ?? params?.worldX) as number | undefined;\n const y = (params?.pressY ?? params?.worldY) as number | undefined;\n return typeof x === 'number' && typeof y === 'number' ? { x, y } : null;\n}\n\n/**\n * Place a pin where the click landed on the selected paths, giving them a\n * puppet warp if they hold none. The pin goes where the shape is now: its\n * unwarped point is found by inverting the warp, so the shape keeps its\n * place until the pin is dragged.\n */\nexport function createAddPinAction(): Action {\n return {\n id: 'puppet.addPin',\n label: `${WARP_LABELS.puppet} — add pin`,\n tags: pathOperationTags('brush'),\n requires: REQUIRES,\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const at = clickPoint(params);\n if (!at) return;\n const next = new Map<string, { target: WarpTarget; shape: { pose: unknown; data: unknown } }>();\n for (const target of warpTargets(deps, 'puppet', (params ?? {}) as WarpSettings)) {\n const { warp } = target.held;\n const back = invert(target.toWorld);\n if (warp.kind !== 'puppet' || !back) continue;\n const [lx, ly] = applyToPoint(back, at.x, at.y);\n const to = { x: lx, y: ly };\n const from = unwarpPoint(pathWarpMap(warp, target.held.source), to);\n const held = { ...target.held, warp: { ...warp, pins: [...warp.pins, { from, to }] } };\n const shape = storeWarp(target.node.node, held, target.toWorld);\n if (shape) next.set(target.node.id, { target, shape });\n }\n commitTargets(deps, next, 'Add Pin');\n },\n } satisfies ImmediateInvoker,\n enabled: (deps) => (selectedPathNodes(deps).length > 0 ? true : ActionDisabledReason.SelectionRequired),\n };\n}\n\n/** Take out the pin the click landed on, from every path sharing its warp. */\nexport function createRemovePinAction(): Action {\n return {\n id: 'puppet.removePin',\n label: `${WARP_LABELS.puppet} — remove pin`,\n tags: pathOperationTags('brush'),\n requires: REQUIRES,\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const scratch = warpHandleScratchOf(params?.affordance);\n if (!scratch || scratch.warpId === null) return;\n const next = new Map<string, { target: WarpTarget; shape: { pose: unknown; data: unknown } }>();\n for (const target of warpTargets(deps, 'puppet', {})) {\n const { warp } = target.held;\n if (target.held.id !== scratch.warpId || warp.kind !== 'puppet') continue;\n const held = { ...target.held, warp: { ...warp, pins: warp.pins.filter((_, i) => i !== scratch.index) } };\n const shape = storeWarp(target.node.node, held, target.toWorld);\n if (shape) next.set(target.node.id, { target, shape });\n }\n commitTargets(deps, next, 'Remove Pin');\n },\n } satisfies ImmediateInvoker,\n };\n}\n\n/** Absorbs a press on a warp control, so the drag it grows into is the\n * control's: an exclusive claim with nothing bound to the press drops it. */\nexport function createWarpGrabAction(kind: WarpKind): Action {\n return {\n id: `${kind}.grab`,\n label: `${WARP_LABELS[kind]} — grab control`,\n invoker: { timing: 'immediate', run: () => {} },\n };\n}\n\n/**\n * Drop the warp from each selected path, keeping the geometry it made: the\n * shape becomes plain geometry that path editing and other warps start from.\n */\nexport const expandWarpAction: Action = {\n id: 'expandWarp',\n label: 'Expand Warp',\n icon: /* @icon */ 'path-tools:expand',\n tags: pathOperationTags('command'),\n group: 'path',\n requires: REQUIRES,\n invoker: {\n timing: 'immediate',\n run: (deps) => {\n const ops: Op[] = [];\n for (const { node } of selectedPathNodes(deps)) {\n if (!heldPathWarpOf(node.data)) continue;\n ops.push(createSetDataOp({ id: node.id, from: node.data, to: withoutPathWarp(node.data), label: 'Expand Warp' }));\n }\n commitOps(deps, ops, 'Expand Warp');\n },\n } satisfies ImmediateInvoker,\n enabled: (deps) => (selectedPathNodes(deps).some(({ node }) => heldPathWarpOf(node.data))\n ? true\n : ActionDisabledReason.NotApplicable),\n};\n\n/**\n * Remake the selection's warps under new settings (`params`, a\n * {@link WarpSettings}, plus an optional `kind` limiting it to one kind of\n * warp): switch a distort between free and perspective, an envelope between\n * its mappings or to a finer grid, or refit at another tolerance. One undo step.\n */\nexport const configureWarpAction: Action = {\n id: 'configureWarp',\n label: 'Warp Settings',\n icon: /* @icon */ 'core:tune',\n tags: pathOperationTags('command'),\n group: 'path',\n requires: REQUIRES,\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const settings = (params ?? {}) as WarpSettings & { kind?: WarpKind };\n const next = new Map<string, { target: WarpTarget; shape: { pose: unknown; data: unknown } }>();\n for (const node of selectedPathNodes(deps)) {\n const resolved = resolvePathWarp(node.node);\n if (!resolved || (settings.kind && resolved.held.warp.kind !== settings.kind)) continue;\n const held = withWarpSettings(resolved.held, settings);\n if (held === resolved.held) continue;\n const shape = storeWarp(node.node, held, resolved.toWorld);\n if (shape) next.set(node.id, { target: { node, ...resolved, fresh: false }, shape });\n }\n commitTargets(deps, next, 'Warp Settings');\n },\n } satisfies ImmediateInvoker,\n};\n","/**\n * The package's behavior as `<SceneCanvas features>` presets: one per tool\n * family, and `pathTools` for all of them. Each assumes core's `paths`\n * preset, which opens a path for editing.\n */\nimport { never, type FeaturePreset } from '@weasel-js/core';\nimport { balanceHandlesAction, equalizeHandlesAction } from './balance/handleBalance';\nimport { createBalanceExtension, PATH_BALANCE_CHROME_ID, type PathEditBalanceStyle } from './balance/balanceMarks';\nimport { bridgeAnchorsAction, bridgePathsAction } from './bridge/bridge';\nimport { createCombExtension, PATH_COMB_CHROME_ID, type PathEditCombOptions } from './comb/comb';\nimport { cycleCornerShapeAction, setCornersAction } from './cornerShape/cornerCommands';\nimport { createCornerWidgetsExtension, type CornerWidgetStyle } from './cornerShape/cornerWidgets';\nimport { editCornerAction } from './cornerShape/editCorner';\nimport { constrainAnchorsAction, deleteConstraintAction, unconstrainAnchorsAction } from './constraints/anchorConstraints';\nimport type { ConstraintGlyphStyle } from './constraints/constraintGlyphs';\nimport { createConstraintsExtension } from './constraints/constraintsExtension';\nimport { extendToMeetAction } from './extend/extendToMeet';\nimport { handleLockAngleAction, handleLockLengthAction } from './handleLocks/handleLocks';\nimport { createHandleSnapExtension, handleSnapSource, type HandleSnapOptionsInput } from './handleSnap/handleSnap';\nimport { createSoftSelectionExtension, type SoftSelectionOptions } from './softSelection/softSelection';\nimport { harmonizeAnchorsAction } from './harmonize/harmonize';\nimport { lengthenPathAction, lengthenToolAction } from './lengthen/lengthenPath';\nimport { createDirectionExtension, PATH_DIRECTION_CHROME_ID, type PathDirectionStyle } from './pathStructure/directionMarks';\nimport { reversePathAction, setPathStartAction } from './pathStructure/pathStructure';\nimport { convertSegmentAtAction, convertSegmentsAction } from './segmentType/convertSegments';\nimport {\n growAnchorSelectionAction, invertAnchorSelectionAction, selectCornerAnchorsAction, selectEveryNthAnchorAction,\n selectSmoothAnchorsAction, shrinkAnchorSelectionAction,\n} from './anchorSelect/anchorSelect';\nimport { addExtremeAnchorsAction } from './extremes/addExtremes';\nimport { resamplePathAction } from './resample/resample';\nimport {\n bendAlongAction, blendAction, editPathEffectAction, expandPathEffectAction, repeatAlongAction,\n} from './pathEffects/actions';\nimport { simplifyBrushAction, simplifyBrushToolAction } from './simplifyBrush/simplifyBrush';\nimport { smudgeBrushAction } from './smudge/smudgeBrush';\nimport { spiroPreset } from './spiro/spiroPreset';\nimport { trimPathAction } from './trim/trimSegment';\nimport { configureWarpAction, expandWarpAction } from './warp/warpActions';\n\n/** The Simplify brush, a path-edit tool that refits the curve it passes over. */\nexport const simplifyBrushPreset: FeaturePreset = {\n id: 'simplifyBrush',\n actions: [simplifyBrushAction, simplifyBrushToolAction],\n};\n\n/** The `handleLock.angle` and `handleLock.length` toggles. */\nexport const handleLocksPreset: FeaturePreset = {\n id: 'handleLocks',\n actions: [handleLockAngleAction, handleLockLengthAction],\n};\n\n/**\n * Soft selection: dragging anchors in path edit also moves the anchors near\n * them along the path, by a falloff over `options`' radius, read as each drag\n * starts. The wheel scrubs the radius mid-drag. Null or undefined from\n * `options` leaves a drag hard.\n */\nexport function createSoftSelectionPreset(options: () => SoftSelectionOptions | null | undefined): FeaturePreset {\n return { id: 'softSelection', pathEdit: [createSoftSelectionExtension(options)] };\n}\n\n/**\n * Handle snapping: a dragged control handle's angle snaps to steps and to the\n * line through its anchor's other handle, as `options` says. A thunk is read\n * every move, and null or undefined from it leaves the handle unsnapped.\n */\nexport function createHandleSnapPreset(options: HandleSnapOptionsInput = {}): FeaturePreset {\n return { id: 'handleSnap', pathEdit: [createHandleSnapExtension(options)], snapSources: [handleSnapSource(options)] };\n}\n\n/** Handle snapping every 45°, within 6°, and to the opposite handle. */\nexport const handleSnapPreset: FeaturePreset = createHandleSnapPreset();\n\n/** Bridge, on whole paths and on two selected anchors. */\nexport const bridgePreset: FeaturePreset = {\n id: 'bridge',\n actions: [bridgeAnchorsAction, bridgePathsAction],\n};\n\n/** `trimPath`, which `useTrimTool` binds. */\nexport const trimPreset: FeaturePreset = { id: 'trim', actions: [trimPathAction] };\n\n/** `extendToMeet`, which `useExtendTool` binds. */\nexport const extendPreset: FeaturePreset = { id: 'extend', actions: [extendToMeetAction] };\n\n/** Lengthen, a path-edit tool whose drag on an open end grows or trims the\n * path from that end, and its toggle. */\nexport const lengthenPreset: FeaturePreset = {\n id: 'lengthen',\n actions: [lengthenPathAction, lengthenToolAction],\n};\n\n/** `smudgeBrush`, which `useSmudgeBrushTool` binds. */\nexport const smudgePreset: FeaturePreset = { id: 'smudge', actions: [smudgeBrushAction] };\n\n/** Harmonize curvature. */\nexport const harmonizePreset: FeaturePreset = { id: 'harmonize', actions: [harmonizeAnchorsAction] };\n\n/** Anchor selection along the path: grow, shrink, every Nth, corners, smooth\n * anchors, and the complement. */\nexport const anchorSelectionPreset: FeaturePreset = {\n id: 'anchorSelection',\n actions: [\n growAnchorSelectionAction, shrinkAnchorSelectionAction, selectEveryNthAnchorAction,\n selectCornerAnchorsAction, selectSmoothAnchorsAction, invertAnchorSelectionAction,\n ],\n};\n\n/** Resample, which spreads anchors evenly by arc length. */\nexport const resamplePreset: FeaturePreset = { id: 'resample', actions: [resamplePathAction] };\n\n/** Add extremes, an anchor at each curve's leftmost, rightmost, top, and bottom. */\nexport const addExtremesPreset: FeaturePreset = { id: 'addExtremes', actions: [addExtremeAnchorsAction] };\n\n/** The curvature comb over the open path, drawn as `options` says, read every\n * frame. Off until chrome-caps shows `path-edit.comb`. */\nexport function createCurvatureCombPreset(options: () => PathEditCombOptions | undefined = () => undefined): FeaturePreset {\n return {\n id: 'curvatureComb',\n chromeRules: { [PATH_COMB_CHROME_ID]: never },\n pathEdit: [createCombExtension(options)],\n };\n}\n\n/** The curvature comb with its default look. */\nexport const curvatureCombPreset: FeaturePreset = createCurvatureCombPreset();\n\n/**\n * Balance handles: a line between each curved segment's handle tips with a\n * grip to drag (`balanceHandles`) or double-click (`equalizeHandles`), drawn\n * in `style`. Off until chrome-caps shows `path-edit.balance`. It refines\n * `paths`, so a grip's double-click goes ahead of entering path edit.\n */\nexport function createBalancePreset(style: PathEditBalanceStyle = {}): FeaturePreset {\n return {\n id: 'balance',\n refines: ['paths'],\n actions: [equalizeHandlesAction, balanceHandlesAction],\n chromeRules: { [PATH_BALANCE_CHROME_ID]: never },\n pathEdit: [createBalanceExtension(style)],\n };\n}\n\n/** Balance handles with their default look. */\nexport const balancePreset: FeaturePreset = createBalancePreset();\n\n/** Path constraints: their actions, their marks in `style`'s colors, and\n * every edit of a constrained path finished so they hold. */\nexport function createConstraintsPreset(style: Partial<ConstraintGlyphStyle> = {}): FeaturePreset {\n return {\n id: 'constraints',\n actions: [constrainAnchorsAction, unconstrainAnchorsAction, deleteConstraintAction],\n pathEdit: [createConstraintsExtension(style)],\n };\n}\n\n/** Path constraints with their default colors. */\nexport const constraintsPreset: FeaturePreset = createConstraintsPreset();\n\n/**\n * Corner shape: a widget inside each corner anchor of the open path, drawn in\n * `style`, whose drag sets the corner's radius (`editCorner`), and the\n * commands on the selected corners (`setCorners`, `cycleCornerShape`). The\n * widgets show while chrome-caps shows `path-edit.corners`, which is on by\n * default. It refines `paths`, so a widget's drag goes ahead of the marquee.\n */\nexport function createCornerShapePreset(style: CornerWidgetStyle = {}): FeaturePreset {\n return {\n id: 'cornerShape',\n refines: ['paths'],\n actions: [editCornerAction, setCornersAction, cycleCornerShapeAction],\n pathEdit: [createCornerWidgetsExtension(style)],\n };\n}\n\n/** Corner shape with path edit's anchor colors. */\nexport const cornerShapePreset: FeaturePreset = createCornerShapePreset();\n\n/**\n * Where a path starts and which way it runs: `setPathStart` and\n * `reversePath`, and arrows and start rings over the open path, drawn in\n * `style`. The marks are off until chrome-caps shows `path-edit.direction`.\n */\nexport function createPathStructurePreset(style: PathDirectionStyle = {}): FeaturePreset {\n return {\n id: 'pathStructure',\n actions: [setPathStartAction, reversePathAction],\n chromeRules: { [PATH_DIRECTION_CHROME_ID]: never },\n pathEdit: [createDirectionExtension(style)],\n };\n}\n\n/** Path start and direction with the marks' default look. */\nexport const pathStructurePreset: FeaturePreset = createPathStructurePreset();\n\n/** `convertSegments` and `convertSegmentAt`, turning segments straight or\n * curved. It refines `paths`, so a segment's Shift+double-click goes ahead\n * of entering path edit. */\nexport const segmentTypePreset: FeaturePreset = {\n id: 'segmentType',\n refines: ['paths'],\n actions: [convertSegmentsAction, convertSegmentAtAction],\n};\n\n/** Blend, Bend along, and Repeat along, live, and the actions that edit and\n * expand them. The scene must hold `withPathEffectsRegistry`'s derivations. */\nexport const pathEffectsPreset: FeaturePreset = {\n id: 'pathEffects',\n actions: [blendAction, bendAlongAction, repeatAlongAction, editPathEffectAction, expandPathEffectAction],\n};\n\n/** `expandWarp` and `configureWarp`; the warp tools bring their own drags. */\nexport const warpPreset: FeaturePreset = {\n id: 'warp',\n actions: [expandWarpAction, configureWarpAction],\n};\n\n/** Every preset above, spiro curves, the comb, balance, constraints, path\n * direction, and corner shape with their defaults — except soft selection and\n * handle snapping, which change what every anchor or handle drag does. */\nexport const pathTools: FeaturePreset = {\n id: 'pathTools',\n includes: [\n simplifyBrushPreset, handleLocksPreset, bridgePreset, spiroPreset, trimPreset, extendPreset, lengthenPreset,\n smudgePreset, harmonizePreset, anchorSelectionPreset, resamplePreset, addExtremesPreset,\n curvatureCombPreset, balancePreset, constraintsPreset, pathStructurePreset, segmentTypePreset,\n cornerShapePreset, pathEffectsPreset, warpPreset,\n ],\n};\n","import { useMemo } from 'react';\nimport type { IconRef } from '@weasel-js/icons';\nimport type { Action, GestureBinding, ToolKeybinding } from '@weasel-js/routing';\nimport { defineTool, type RenderLayer, type Tool } from '@weasel-js/core';\n\n/** Options for a tool that acts on the stroke under a click. */\nexport interface StrokeClickToolOptions {\n /** Override the default keybinding. Pass `null` to omit. */\n keybinding?: ToolKeybinding | null;\n /** How far from a stroke a click may land and still reach it, in screen\n * pixels. Read on every click. Default 6. */\n radiusPx?: number | (() => number);\n}\n\n/** What the tool is: its id, label, icon, hook name, the action its click\n * hands the press to, and its default key. */\nexport interface StrokeClickToolSpec {\n id: string;\n label: string;\n icon: IconRef;\n hookName: string;\n actionId: string;\n keybinding: ToolKeybinding;\n}\n\n/** The tool's own extras: actions it registers, bindings beside its click,\n * an overlay, and what to drop when it is put down. */\nexport interface StrokeClickExtras {\n actions?: Action[];\n bindings?: GestureBinding[];\n overlay?: RenderLayer<unknown>;\n onDeactivate?: () => void;\n}\n\n/** A declarative tool whose click binding, and any extra binding, hands the\n * press and `radiusPx` to `spec.actionId`. */\nexport function useStrokeClickTool(\n spec: StrokeClickToolSpec,\n options: StrokeClickToolOptions,\n extras: StrokeClickExtras = {},\n): Tool {\n const { keybinding = spec.keybinding, radiusPx } = options;\n const { id, label, icon, hookName, actionId } = spec;\n return useMemo(() => {\n const opts = radiusPx !== undefined\n ? { opts: { params: () => ({ radiusPx: typeof radiusPx === 'function' ? radiusPx() : radiusPx }) } }\n : {};\n return defineTool({\n id,\n ...(keybinding ? { keybinding } : {}),\n capabilities: ['creates-shapes'],\n hookName,\n cursor: 'crosshair',\n presentation: { label, group: 'path', icon },\n ...(extras.actions ? { actions: extras.actions } : {}),\n ...(extras.overlay ? { overlay: extras.overlay } : {}),\n ...(extras.onDeactivate ? { onDeactivate: extras.onDeactivate } : {}),\n bindings: [\n { spec: { kind: 'click' }, actionId, ...opts },\n ...(extras.bindings ?? []).map((b) => ({ ...b, ...opts })),\n ],\n });\n }, [id, label, icon, hookName, actionId, keybinding, radiusPx, extras.actions, extras.bindings, extras.overlay, extras.onDeactivate]);\n}\n","import { createEmitter } from '@weasel-js/registry';\nimport { transformPath, type PolygonPath } from '@weasel-js/geom';\nimport { OVERLAY_ROLE_STROKES, type RenderLayer, type Scene, viewToTransform } from '@weasel-js/core';\n\n/** A piece of a stroke shown before it is cut away, and the scene it was\n * measured on. */\nexport interface PiecePreviewState {\n path: PolygonPath;\n scene: Pick<Scene<unknown, string, unknown>, 'getVersion'>;\n}\n\n/**\n * The highlight a tool draws over the piece of a stroke a click would cut:\n * `show` sets it, and the screen-space `layer` paints it in the `cut` role's\n * stroke. A piece measured before the scene last changed is not drawn, so a\n * commit retires its own preview without being told.\n */\nexport function createPiecePreview(): {\n show(next: PiecePreviewState | null): void;\n current(): PiecePreviewState | null;\n layer: RenderLayer<unknown>;\n} {\n const changed = createEmitter();\n let state: { piece: PiecePreviewState; version: number } | null = null;\n const current = () => (state && state.piece.scene.getVersion() === state.version ? state.piece : null);\n return {\n show(next) {\n if (!next && !state) return;\n if (next && state && next.path === state.piece.path) return;\n state = next ? { piece: next, version: next.scene.getVersion() } : null;\n changed.emit();\n },\n current,\n layer: {\n id: 'stroke-piece-preview',\n label: 'Piece a click would cut',\n space: 'screen',\n subscribe: (repaint) => changed.subscribe(repaint),\n draw: (_data, view) => {\n const piece = current();\n if (!piece) return [];\n const t = viewToTransform(view);\n const stroke = { ...OVERLAY_ROLE_STROKES['cut'], width: 3 };\n return [{ kind: 'path', path: transformPath(piece.path, [t.zoom.x, 0, 0, t.zoom.y, t.panX, t.panY]), stroke }];\n },\n },\n };\n}\n","import { useMemo } from 'react';\nimport type { Action, ToolKeybinding } from '@weasel-js/routing';\nimport type { PolygonPath } from '@weasel-js/geom';\nimport { type Scene, type Tool } from '@weasel-js/core';\nimport { planTrim } from './trimSegment';\nimport { useStrokeClickTool, type StrokeClickExtras, type StrokeClickToolOptions } from '../shared/strokeClickTool';\nimport { createPiecePreview } from './piecePreview';\nimport { icon } from '../icons.gen';\n\n/** Options for `useTrimTool`; the default keybinding is `{ key: 'Y' }`. */\nexport type UseTrimToolOptions = StrokeClickToolOptions;\n\nconst TRIM_KEY: ToolKeybinding = { key: 'Y' };\nconst TRIM_PREVIEW_ID = 'trim.preview';\n\n/**\n * Trim segment tool. A click on a stroke removes its piece between the\n * crossings on either side — a declarative shell over the `trimPath` action,\n * which owns the hit-test and the commit. While it is up, the piece under the\n * pointer is drawn dashed, through the same `planTrim` the click commits.\n */\nexport function useTrimTool(options: UseTrimToolOptions = {}): Tool {\n const extras = useMemo<StrokeClickExtras>(() => {\n const preview = createPiecePreview();\n const action: Action = {\n id: TRIM_PREVIEW_ID,\n label: 'Trim segment: show the piece under the pointer',\n eligible: { capability: 'creates-shapes' },\n requires: ['scene', 'view'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const plan = deps.scene ? planTrim(deps, params) : null;\n const scene = deps.scene as Scene<unknown, string, unknown> | undefined;\n preview.show(plan && scene ? { path: plan.result.removed as PolygonPath, scene } : null);\n },\n },\n };\n return {\n actions: [action],\n bindings: [{ spec: { kind: 'hover' }, actionId: TRIM_PREVIEW_ID }],\n overlay: preview.layer,\n onDeactivate: () => preview.show(null),\n };\n }, []);\n return useStrokeClickTool(\n { id: 'trim', label: 'Trim segment', icon: /* @icon */ 'path-tools:trim', hookName: 'useTrimTool', actionId: 'trimPath', keybinding: TRIM_KEY },\n options,\n extras,\n );\n}\n","import type { ToolKeybinding } from '@weasel-js/routing';\nimport { type Tool } from '@weasel-js/core';\nimport { useStrokeClickTool, type StrokeClickToolOptions } from '../shared/strokeClickTool';\nimport { icon } from '../icons.gen';\n\n/** Options for `useExtendTool`; the default keybinding is `{ key: 'U' }`. */\nexport type UseExtendToolOptions = StrokeClickToolOptions;\n\nconst EXTEND_KEY: ToolKeybinding = { key: 'U' };\n\n/**\n * Extend to next path tool. A click near an open end of a stroke carries\n * that end along its tangent to the next stroke it meets — a declarative\n * shell over the `extendToMeet` action.\n */\nexport function useExtendTool(options: UseExtendToolOptions = {}): Tool {\n return useStrokeClickTool(\n {\n id: 'extend', label: 'Extend to next path', icon: /* @icon */ 'path-tools:extend', hookName: 'useExtendTool',\n actionId: 'extendToMeet', keybinding: EXTEND_KEY,\n },\n options,\n );\n}\n","import { useMemo } from 'react';\nimport type { ToolKeybinding } from '@weasel-js/routing';\nimport { defineTool, type Tool } from '@weasel-js/core';\nimport { icon } from '../icons.gen';\n\n/** Options for `useSmudgeBrushTool`. */\nexport interface UseSmudgeBrushToolOptions {\n /** Override the default keybinding (`{ key: 'S' }`). Pass `null` to omit. */\n keybinding?: ToolKeybinding | null;\n}\n\nconst SMUDGE_KEY: ToolKeybinding = { key: 'S' };\n\n/**\n * Smudge brush tool. A round brush that pushes the outline of the selected\n * paths along with the pointer — a declarative shell whose one binding routes a\n * drag to the `smudgeBrush` action, which owns the stroke, its preview, its ring\n * cursor, and its one undo entry. The brush's radius (screen px) and strength are\n * that action's params: `tune={{ smudgeBrush: { params: () => ({ radiusPx, strength }) } }}`.\n */\nexport function useSmudgeBrushTool(options: UseSmudgeBrushToolOptions = {}): Tool {\n const { keybinding = SMUDGE_KEY } = options;\n return useMemo(() => defineTool({\n id: 'smudgeBrush',\n ...(keybinding ? { keybinding } : {}),\n capabilities: ['creates-shapes'],\n hookName: 'useSmudgeBrushTool',\n cursor: 'crosshair',\n presentation: { label: 'Smudge brush', group: 'path', icon: /* @icon */ 'path-tools:smudgeBrush' },\n bindings: [{ spec: { kind: 'drag' }, actionId: 'smudgeBrush' }],\n }), [keybinding]);\n}\n","/**\n * The controls of the selection's warp, as a hit-tested layer: a distort's\n * corners and the quad they make, an envelope's mesh points and the grid\n * lines through them, a puppet's pins. Over a selection holding no warp of\n * the kind, the controls of a fresh one are shown where it would start.\n */\nimport {\n applyToPoint, ellipsePath, polylineFromPoints, type Affine, type Point, type PolygonPath,\n} from '@weasel-js/geom';\nimport { pathWarpMap, warpControls, type PathWarp } from '@weasel-js/geom/warp';\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport {\n type Affordance, type AffordanceRegion, type ChromeState, composeAffordanceLayer, DEFAULT_OVERLAY_STYLE, pathNodesOf, type RenderLayer, type Scene, type View, viewToTransform, worldToScreen,\n} from '@weasel-js/core';\nimport type { WarpHandleScratch, WarpLive } from './warpActions';\nimport {\n freshWarp, splitByWarp, type WarpKind, type WarpSettings,\n} from './warpTargets';\n\n/** The id of the layer showing a `kind` warp's controls. A binding reaches\n * its controls through `affordance:layer:<id>`. */\nexport const warpLayerId = (kind: WarpKind): string => `warp-${kind}`;\n\n/** What the layer reads, live, on every paint and hit-test. */\nexport interface WarpHandleLayerSource {\n kind: WarpKind;\n /** Whether to show anything: the tool owning the layer is active. */\n active(): boolean;\n /** What a fresh warp is made with. */\n settings(): WarpSettings;\n scene(): Pick<Scene<unknown, string, unknown>, 'get'> | undefined;\n live: WarpLive;\n}\n\ninterface ControlGroup {\n warpId: string | null;\n warp: PathWarp;\n /** The path the warp is laid over, in the warp's frame. */\n source: PolygonPath;\n toWorld: Affine;\n}\n\nconst HIT_PX = 8;\nconst SIZE_PX = DEFAULT_OVERLAY_STYLE.anchorSizePx;\nconst PIN_RADIUS_PX = DEFAULT_OVERLAY_STYLE.handleDotRadiusPx;\nconst ACCENT = DEFAULT_OVERLAY_STYLE.anchorStroke;\nconst LINE = { paint: { kind: 'solid' as const, color: ACCENT }, width: 1 };\nconst LINE_SAMPLES = 12;\nconst IDENTITY: Affine = [1, 0, 0, 1, 0, 0];\n\n/** One group per warp the selection shares, then one for a fresh warp over\n * whatever selected paths hold none. */\nfunction groupsOf(src: WarpHandleLayerSource, state: ChromeState): ControlGroup[] {\n const scene = src.scene();\n if (!scene || !src.active()) return [];\n const nodes = pathNodesOf(scene, state.selection, (id) => src.live.get(id));\n const { held, bare, box } = splitByWarp(nodes, src.kind);\n const out: ControlGroup[] = [];\n const seen = new Set<string>();\n for (const t of held) {\n if (seen.has(t.held.id)) continue;\n seen.add(t.held.id);\n out.push({ warpId: t.held.id, warp: t.held.warp, source: t.held.source, toWorld: t.toWorld });\n }\n if (box) out.push({ warpId: null, warp: freshWarp(src.kind, box, src.settings()), source: bare[0].path, toWorld: IDENTITY });\n return out;\n}\n\nconst toWorld = (m: Affine, p: Point): Point => {\n const [x, y] = applyToPoint(m, p.x, p.y);\n return { x, y };\n};\n\nfunction pinPaint(view: View, at: { x: number; y: number }): DrawCommand[] {\n const [x, y] = worldToScreen(at.x, at.y, viewToTransform(view));\n const r = PIN_RADIUS_PX;\n return [{\n kind: 'path',\n path: ellipsePath({ x: x - r, y: y - r, width: 2 * r, height: 2 * r }),\n fill: { paint: { kind: 'solid', color: '#ffffff' } },\n stroke: { paint: { kind: 'solid', color: ACCENT }, width: 2 },\n }];\n}\n\n/** The lines a group's controls hang on, in world space: a distort's quad,\n * an envelope's grid lines carried through the mesh. */\nfunction guideLines(group: ControlGroup): Point[][] {\n const { warp, toWorld: m } = group;\n if (warp.kind === 'distort') {\n const c = warp.corners.map((p) => toWorld(m, p));\n return [[...c, c[0]]];\n }\n if (warp.kind !== 'envelope') return [];\n const map = pathWarpMap(warp, group.source);\n const { box, mesh } = warp;\n const at = (u: number, v: number) => toWorld(m, map({ x: box.x + u * box.width, y: box.y + v * box.height }));\n const lines: Point[][] = [];\n for (let i = 0; i <= mesh.rows; i++) {\n const n = mesh.cols * LINE_SAMPLES;\n lines.push(Array.from({ length: n + 1 }, (_, k) => at(k / n, i / mesh.rows)));\n }\n for (let j = 0; j <= mesh.cols; j++) {\n const n = mesh.rows * LINE_SAMPLES;\n lines.push(Array.from({ length: n + 1 }, (_, k) => at(j / mesh.cols, k / n)));\n }\n return lines;\n}\n\nfunction warpAffordance(src: WarpHandleLayerSource): Affordance {\n const id = warpLayerId(src.kind);\n return {\n id,\n regions(state): readonly AffordanceRegion[] {\n const out: AffordanceRegion[] = [];\n for (const group of groupsOf(src, state)) {\n warpControls(group.warp).forEach((local, index) => {\n const p = toWorld(group.toWorld, local);\n out.push({\n id: `${group.warpId ?? 'fresh'}:${index}`,\n targetId: null,\n shape: { kind: 'point', x: p.x, y: p.y, hitRadiusPx: HIT_PX },\n paint: group.warp.kind === 'puppet'\n ? { kind: 'custom', draw: ({ world, view }) => pinPaint(view, world) }\n : {\n kind: 'square',\n sizePx: SIZE_PX,\n fill: { paint: { kind: 'solid', color: '#ffffff' } },\n stroke: { paint: { kind: 'solid', color: ACCENT }, width: 1 },\n },\n cursor: 'move',\n strength: 'exclusive',\n claimedKinds: ['pointer'],\n bind: () => ({ initialScratch: { warpId: group.warpId, index } satisfies WarpHandleScratch }),\n });\n });\n }\n return out;\n },\n decorate(state, view) {\n const t = viewToTransform(view);\n const out: DrawCommand[] = [];\n for (const group of groupsOf(src, state)) {\n for (const line of guideLines(group)) {\n const screen = line.map((p) => {\n const [x, y] = worldToScreen(p.x, p.y, t);\n return { x, y };\n });\n out.push({ kind: 'path', path: polylineFromPoints(screen), stroke: LINE });\n }\n }\n return out;\n },\n };\n}\n\n/**\n * The layer, for `CanvasExtensionApi.registerLayer` — the attach route that\n * is hit-tested. Its guide lines paint before its controls, so a control is\n * never hidden under a line.\n */\nexport function createWarpHandleLayer(src: WarpHandleLayerSource): RenderLayer<unknown> {\n const lines: Affordance = { id: `${warpLayerId(src.kind)}:lines`, regions: () => [], decorate: warpAffordance(src).decorate };\n const controls: Affordance = { ...warpAffordance(src), decorate: undefined };\n return composeAffordanceLayer(warpLayerId(src.kind), 'Warp controls', [lines, controls]) as unknown as RenderLayer<unknown>;\n}\n","import { useMemo } from 'react';\nimport type { IconRef } from '@weasel-js/icons';\nimport { useLatest } from '@weasel-js/react';\nimport type { DistortMode, EnvelopeMapping } from '@weasel-js/geom/warp';\nimport type { Action, GestureBinding, ToolKeybinding } from '@weasel-js/routing';\nimport {\n type CanvasExtensionApi, type ContributionDepReader, defineTool, type SurfaceContribution, type Tool,\n} from '@weasel-js/core';\nimport {\n createAddPinAction, createRemovePinAction, createWarpDragAction, createWarpGrabAction, createWarpLive,\n} from './warpActions';\nimport { WARP_LABELS, type WarpKind, type WarpSettings } from './warpTargets';\nimport { createWarpHandleLayer, warpLayerId } from './warpHandles';\nimport { icon } from '../icons.gen';\n\nconst WARP_ICONS = { distort: /* @icon */ 'path-tools:distort', envelope: /* @icon */ 'path-tools:envelope', puppet: /* @icon */ 'path-tools:puppetWarp' } satisfies Record<WarpKind, IconRef>;\n\n/** A warp tool: a `Tool` that also registers the layer showing its controls. */\nexport type WarpTool = Tool & Pick<SurfaceContribution, 'attach'>;\n\n/** Options every warp tool takes. */\nexport interface WarpToolOptions {\n /** Palette label. */\n label?: string;\n /** Override the default keybinding (Distort `F`, Envelope `M`, Puppet Warp\n * `B`). Pass `null` to omit. */\n keybinding?: ToolKeybinding | null;\n /** How far, in world units, a warped path's refitted curves may stray from\n * the exact warp. Default 0.5. */\n tolerance?: number;\n}\n\n/** Options for {@link useDistortTool}. */\nexport interface UseDistortToolOptions extends WarpToolOptions {\n /** The map a new distort starts with: `'free'` (bilinear, the default) or\n * `'perspective'` (projective). */\n mode?: DistortMode;\n}\n\n/** Options for {@link useEnvelopeTool}. */\nexport interface UseEnvelopeToolOptions extends WarpToolOptions {\n /** Patch rows and columns of a new envelope's mesh. Default 3 each. */\n rows?: number;\n cols?: number;\n /** How a new envelope interpolates its mesh. Default `'bicubic'`. */\n mapping?: EnvelopeMapping;\n}\n\n/** Options for {@link usePuppetTool}. */\nexport type UsePuppetToolOptions = WarpToolOptions;\n\nconst ANY_MODS = { shift: 'optional', alt: 'optional', meta: 'optional', ctrl: 'optional' } as const;\n\nfunction bindingsFor(kind: WarpKind, settings: () => Record<string, unknown>): GestureBinding[] {\n const target = `affordance:layer:${warpLayerId(kind)}` as const;\n const out: GestureBinding[] = [];\n if (kind === 'puppet') {\n out.push({ spec: { kind: 'click', target, mods: { alt: true } }, actionId: 'puppet.removePin' });\n out.push({ spec: { kind: 'click', target: 'selected-body' }, actionId: 'puppet.addPin', opts: { params: settings } });\n }\n out.push(\n { spec: { kind: 'drag', target }, actionId: `${kind}.drag`, opts: { params: settings } },\n { spec: { kind: 'pointerDown', target, mods: ANY_MODS }, actionId: `${kind}.grab` },\n { spec: { kind: 'click', target }, actionId: `${kind}.grab` },\n );\n return out;\n}\n\n/** `settings` without its unset keys, so `<SceneCanvas tune>` params fill them in. */\nfunction definedOf(settings: WarpSettings): Record<string, unknown> {\n return Object.fromEntries(Object.entries(settings).filter(([, v]) => v !== undefined));\n}\n\nconst KEYS: Record<WarpKind, ToolKeybinding> = { distort: { key: 'F' }, envelope: { key: 'F', shift: true }, puppet: { key: 'B' } };\n\n/** What a warp tool keeps between renders: whether it is active, the canvas\n * it is attached to, and the in-flight drag its controls follow. */\nfunction createWarpToolState() {\n let active = false;\n let api: CanvasExtensionApi | null = null;\n let deps: ContributionDepReader | null = null;\n const live = createWarpLive();\n return {\n live,\n active: () => active,\n scene: () => deps?.get('scene') as never,\n /** What an invocation of `actionId` passing `given` starts with here,\n * its tunings included. */\n paramsOf: (actionId: string, given: Record<string, unknown>) => deps?.get('actionParams')?.(actionId, given) ?? given,\n setActive(next: boolean): void {\n active = next;\n api?.requestRedraw();\n },\n attachTo(nextApi: CanvasExtensionApi | null, nextDeps: ContributionDepReader | null): void {\n api = nextApi;\n deps = nextDeps;\n },\n };\n}\n\nfunction useWarpTool(kind: WarpKind, options: WarpToolOptions, settings: WarpSettings): WarpTool {\n const { label, keybinding = KEYS[kind] } = options;\n const settingsRef = useLatest(settings);\n const state = useMemo(() => createWarpToolState(), []);\n\n const attach = useMemo(() => {\n const layer = createWarpHandleLayer({\n kind,\n active: state.active,\n settings: () => state.paramsOf(`${kind}.drag`, definedOf(settingsRef.current)) as WarpSettings,\n scene: state.scene,\n live: state.live,\n });\n return (api: CanvasExtensionApi, deps: ContributionDepReader) => {\n state.attachTo(api, deps);\n const unregister = api.registerLayer(layer);\n const unlisten = state.live.subscribe(() => api.requestRedraw());\n return () => {\n unlisten();\n unregister();\n state.attachTo(null, null);\n };\n };\n }, [kind, settingsRef, state]);\n\n const actions = useMemo<Action[]>(() => [\n createWarpDragAction(kind, state.live),\n createWarpGrabAction(kind),\n ...(kind === 'puppet' ? [createAddPinAction(), createRemovePinAction()] : []),\n ], [kind, state]);\n\n return useMemo(() => {\n const tool = defineTool({\n id: kind,\n ...(keybinding ? { keybinding } : {}),\n hookName: `use${kind[0].toUpperCase()}${kind.slice(1)}Tool`,\n capabilities: ['creates-shapes'],\n cursor: kind === 'puppet' ? 'crosshair' : 'default',\n actions,\n presentation: { label: label ?? WARP_LABELS[kind], group: 'warp', icon: WARP_ICONS[kind] },\n onActivate: () => state.setActive(true),\n onDeactivate: () => state.setActive(false),\n bindings: bindingsFor(kind, () => definedOf(settingsRef.current)),\n });\n return Object.assign(tool, { attach });\n }, [actions, attach, keybinding, kind, label, settingsRef, state]);\n}\n\n/**\n * Distort the selected paths by their box's four corners, each dragged on its\n * own. The first drag gives the selection a distort, kept on each path as\n * `data.warp` until it is expanded (`expandWarp`); selecting the paths again\n * with this tool shows its corners where they were left. `configureWarp`\n * switches a held distort between free and perspective.\n */\nexport function useDistortTool(options: UseDistortToolOptions = {}): WarpTool {\n const { mode, tolerance } = options;\n return useWarpTool('distort', options, { mode, tolerance });\n}\n\n/**\n * Warp the selected paths through a mesh of control points over their box:\n * drag any point and the shape bends smoothly around it. The mesh is held on\n * each path until it is expanded, and `configureWarp` changes its grid or its\n * interpolation.\n */\nexport function useEnvelopeTool(options: UseEnvelopeToolOptions = {}): WarpTool {\n const { rows, cols, mapping, tolerance } = options;\n return useWarpTool('envelope', options, { rows, cols, mapping, tolerance });\n}\n\n/**\n * Pin the selected paths where they are clicked, and drag a pin to bend them:\n * the rest of the shape follows as rigidly as the pins allow, and a pin left\n * alone holds its place. Alt-click a pin to take it out. The pins are held on\n * each path until it is expanded.\n */\nexport function usePuppetTool(options: UsePuppetToolOptions = {}): WarpTool {\n return useWarpTool('puppet', options, { tolerance: options.tolerance });\n}\n","/**\n * Shape building: the selected paths cut into the faces their outlines bound,\n * then a pick of those faces united into one path, or deleted, as one undo step.\n */\nimport { pointInPath, type PolygonPath } from '@weasel-js/geom';\nimport { pathFacePieces, pathUnion } from '@weasel-js/geom/booleans';\nimport {\n commitBooleanPieces, resolveBooleanOperands,\n type BooleanCommitPiece, type BooleanOpOptions, type BooleanOpResult, type BooleansAdapter, type NodeId, type PathPaint,\n} from '@weasel-js/core';\n\n/** What a pick of faces does: unite them into one path, or delete them. */\nexport type ShapeBuilderMode = 'merge' | 'delete';\n\n/** One face of the selection: a connected region no outline crosses. */\nexport interface ShapeBuilderFace {\n path: PolygonPath;\n /** The topmost source covering the face, which a path made of it stands in for. */\n sourceId: NodeId;\n /** Set when that source's stroke went into the face: the paint it wears. */\n paint?: PathPaint;\n}\n\n/** The faces of the selection, and the commit that rebuilds it from a pick of them. */\nexport interface ShapeBuilderPlan {\n kind: 'faces';\n /** Back to front by the sources they cover, exclusives first. */\n faces: readonly ShapeBuilderFace[];\n /** The index of the face holding the world point, or -1. */\n faceAt(x: number, y: number): number;\n /**\n * Replace the selection with its faces, the `picked` ones united into one\n * path standing in for the source of the first one picked (`'merge'`) or\n * left out (`'delete'`). Every other face becomes a path of its own. One\n * undo step, and what it made is selected. Commits nothing for an empty pick.\n */\n commit(picked: readonly number[], mode: ShapeBuilderMode): BooleanOpResult;\n}\n\nconst LABEL = 'Shape Builder';\n\n/**\n * The faces the selected paths cut each other into, or why there are none.\n * Reads the adapter and changes nothing; the plan's `commit` writes.\n */\nexport function planShapeBuilder(\n adapter: BooleansAdapter,\n opts: BooleanOpOptions = {},\n): ShapeBuilderPlan | Exclude<BooleanOpResult, { kind: 'applied' }> {\n const operands = resolveBooleanOperands(adapter, opts);\n if ('kind' in operands) return operands;\n const { sources } = operands;\n const cut = pathFacePieces(...sources.map((s) => s.path))\n .filter((p) => p.path.commands.length > 0)\n .map((p) => ({ path: p.path, source: p.sources[p.sources.length - 1]! }));\n if (cut.length === 0) return { kind: 'noop', reason: 'empty-result' };\n const faces = cut.map(({ path, source }): ShapeBuilderFace => {\n const { id, paint } = sources[source]!;\n return paint ? { path, sourceId: id, paint } : { path, sourceId: id };\n });\n return {\n kind: 'faces',\n faces,\n faceAt: (x, y) => faces.findIndex((f) => pointInPath(f.path, x, y)),\n commit(picked, mode) {\n const chosen = [...new Set(picked)].filter((i) => i >= 0 && i < cut.length);\n if (chosen.length === 0) return { kind: 'noop', reason: 'empty-result' };\n const taken = new Set(chosen);\n const pieces: BooleanCommitPiece[] = cut.flatMap((c, i) => (taken.has(i) ? [] : [{ ...c, producedBy: 'divide' as const }]));\n if (mode === 'merge') {\n const first = cut[chosen[0]!]!;\n const path = chosen.length === 1 ? first.path : pathUnion(...chosen.map((i) => cut[i]!.path));\n pieces.push({ path, source: first.source, producedBy: 'union' });\n }\n // Stable, so each source's pieces keep their order and stack where it did.\n pieces.sort((a, b) => a.source - b.source);\n return commitBooleanPieces(adapter, operands, pieces, LABEL);\n },\n };\n}\n\n/**\n * The faces a run of world points passes through, each once, in the order\n * the run enters them. `step` is the world distance between the samples\n * taken along each segment; a face narrower than it can be stepped over.\n */\nexport function facesAlong(\n plan: Pick<ShapeBuilderPlan, 'faceAt'>,\n run: readonly { x: number; y: number }[],\n step: number,\n): number[] {\n const out: number[] = [];\n const visit = (x: number, y: number): void => {\n const i = plan.faceAt(x, y);\n if (i >= 0 && !out.includes(i)) out.push(i);\n };\n if (run.length === 1) visit(run[0]!.x, run[0]!.y);\n for (let k = 1; k < run.length; k++) {\n const a = run[k - 1]!;\n const b = run[k]!;\n const n = Math.max(1, Math.ceil(Math.hypot(b.x - a.x, b.y - a.y) / step));\n for (let s = k === 1 ? 0 : 1; s <= n; s++) visit(a.x + ((b.x - a.x) * s) / n, a.y + ((b.y - a.y) * s) / n);\n }\n return out;\n}\n","import type { Action, ActionDeps, InvocationCtx, OngoingHandle } from '@weasel-js/routing';\nimport { ActionDisabledReason } from '@weasel-js/routing';\nimport type { BooleanOpOptions, NodeId, PathOverlay, TransientPath } from '@weasel-js/core';\nimport { facesAlong, planShapeBuilder, type ShapeBuilderMode, type ShapeBuilderPlan } from './shapeBuilder';\n\ntype Point = { x: number; y: number };\n\n/** Screen pixels between the points a drag is sampled at for the faces it crosses. */\nconst SAMPLE_PX = 2;\n\n/** The selection's faces, recomputed only when what they are cut from changes. */\nfunction createPlanCache(opts: () => BooleanOpOptions) {\n let key: string | null = null;\n let plan: ShapeBuilderPlan | null = null;\n return {\n get(deps: ActionDeps): ShapeBuilderPlan | null {\n const adapter = deps.booleansAdapter;\n if (!adapter) return null;\n const scale = deps.view?.get().scale;\n const o = { ...opts(), ...(scale ? { scale } : {}) };\n const sel = [...adapter.getSelection()] as NodeId[];\n const next = JSON.stringify([o, sel.map((id) => [\n id, adapter.getWorldPath(id) ?? adapter.getTextSource?.(id) ?? null, adapter.getPaint?.(id) ?? null,\n ])]);\n if (next !== key) {\n key = next;\n const planned = planShapeBuilder(adapter, o);\n plan = planned.kind === 'faces' ? planned : null;\n }\n return plan;\n },\n clear(): void {\n key = null;\n plan = null;\n },\n };\n}\n\nconst enoughSelected = (deps: ActionDeps | undefined): true | ActionDisabledReason => {\n if (!deps?.booleansAdapter) return ActionDisabledReason.NotApplicable;\n return (deps.selection?.get().length ?? 0) >= 2 ? true : ActionDisabledReason.SelectionRequired;\n};\n\n/** What the tool reads on every gesture: how operands are taken, and what a\n * gesture without Alt does. Alt does the other. */\nexport interface ShapeBuilderSettings {\n op: BooleanOpOptions;\n mode: ShapeBuilderMode;\n}\n\nconst OTHER: Record<ShapeBuilderMode, ShapeBuilderMode> = { merge: 'delete', delete: 'merge' };\n\n/** The tool's actions: showing the face under the pointer, and taking the\n * faces a drag or a click passes through. */\nexport function createShapeBuilderActions(overlay: PathOverlay, settings: () => ShapeBuilderSettings): {\n actions: Action[];\n reset(): void;\n} {\n const plans = createPlanCache(() => settings().op);\n const modeFor = (alt: boolean | undefined): ShapeBuilderMode => (alt ? OTHER[settings().mode] : settings().mode);\n const show = (plan: ShapeBuilderPlan, faces: readonly number[], role: string): void => {\n overlay.set(faces.map((i): TransientPath => ({ path: plan.faces[i]!.path, role })));\n };\n const eligible = { capability: 'edits-page' } as const;\n const requires = ['booleansAdapter', 'selection', 'view'] as const;\n\n const hover: Action = {\n id: 'shapeBuilder.hover',\n label: 'Shape Builder — show the face under the pointer',\n eligible,\n requires,\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const p = params as { worldX?: number; worldY?: number; mods?: { alt?: boolean } } | undefined;\n const plan = enoughSelected(deps) === true ? plans.get(deps) : null;\n const at = plan && p?.worldX !== undefined && p.worldY !== undefined ? plan.faceAt(p.worldX, p.worldY) : -1;\n if (!plan || at < 0) overlay.clear();\n else show(plan, [at], modeFor(p?.mods?.alt) === 'delete' ? 'remove' : 'chrome');\n },\n },\n };\n\n const leave: Action = {\n id: 'shapeBuilder.leave',\n label: 'Shape Builder — clear the shown face',\n eligible,\n invoker: { timing: 'immediate', run: () => overlay.clear() },\n };\n\n const click: Action = {\n id: 'shapeBuilder.click',\n label: 'Shape Builder — take the face clicked',\n eligible,\n requires,\n enabled: enoughSelected,\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const p = params as { pressX?: number; pressY?: number; mods?: { alt?: boolean } } | undefined;\n const plan = plans.get(deps);\n if (!plan || p?.pressX === undefined || p.pressY === undefined) return;\n const at = plan.faceAt(p.pressX, p.pressY);\n if (at < 0) return;\n overlay.clear();\n plans.clear();\n plan.commit([at], modeFor(p.mods?.alt));\n },\n },\n };\n\n const drag: Action = {\n id: 'shapeBuilder',\n label: 'Shape Builder',\n eligible,\n requires,\n enabled: enoughSelected,\n invoker: {\n timing: 'ongoing',\n start: (ctx: InvocationCtx): OngoingHandle => {\n const plan = plans.get(ctx.deps);\n if (!plan) return {};\n const scale = ctx.deps.view?.get().scale ?? { x: 1, y: 1 };\n const step = SAMPLE_PX / Math.max(1e-9, (Math.abs(scale.x) + Math.abs(scale.y)) / 2);\n let last: Point = ctx.drag?.start ?? ctx.world;\n const trail: Point[] = [last];\n const picked = facesAlong(plan, [last], step);\n let alt = ctx.modifiers.alt;\n const paint = () => show(plan, picked, modeFor(alt) === 'delete' ? 'remove' : 'picked');\n paint();\n return {\n kind: 'shapeBuilder',\n onMove: (c) => {\n const at = c.drag?.current ?? c.world;\n for (const i of facesAlong(plan, [last, at], step)) if (!picked.includes(i)) picked.push(i);\n last = at;\n trail.push(at);\n alt = c.modifiers.alt;\n paint();\n },\n onEnd: (_c, reason) => {\n overlay.clear();\n plans.clear();\n if (reason === 'commit') plan.commit(picked, modeFor(alt));\n },\n overlay: () => (trail.length >= 2 ? { kind: 'polyline', points: trail } : null),\n };\n },\n },\n };\n\n return {\n actions: [hover, leave, click, drag],\n reset: () => {\n overlay.clear();\n plans.clear();\n },\n };\n}\n","import { useMemo } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { ToolKeybinding } from '@weasel-js/routing';\nimport { createPathOverlay, defineTool, PATHFINDER_STROKES, type BooleanStrokes, type Tool } from '@weasel-js/core';\nimport { icon } from '../icons.gen';\nimport type { ShapeBuilderMode } from './shapeBuilder';\nimport { createShapeBuilderActions } from './shapeBuilderActions';\n\n/** Options for `useShapeBuilderTool`. */\nexport interface UseShapeBuilderToolOptions {\n /** Override the default keybinding (`{ key: 'M', shift: true }`). Pass `null` to omit. */\n keybinding?: ToolKeybinding | null;\n /** What a stroked path gives the faces. Default `'unfilled'`, as the\n * Pathfinder actions: an unfilled stroke counts as the region it covers. */\n strokes?: BooleanStrokes;\n /** What a drag or a click does without Alt: unite the faces (`'merge'`, the\n * default) or delete them. With Alt it does the other. Read on every gesture. */\n mode?: ShapeBuilderMode;\n}\n\n/**\n * Shape builder. With two or more paths selected, the faces their outlines cut\n * each other into are what the tool works on: the face under the pointer is\n * shown, a drag unites every face it passes through into one path wearing the\n * paint of the first, and an Alt-drag deletes them (the other way round under\n * `mode: 'delete'`). A click takes the one face. Every face not taken becomes a path of its own, and each gesture is\n * one undo step. With fewer than two selected, a drag marquee-selects.\n *\n * It reads the `booleansAdapter` dep the Pathfinder actions do.\n */\nexport function useShapeBuilderTool(options: UseShapeBuilderToolOptions = {}): Tool {\n const settingsRef = useLatest({ op: { strokes: options.strokes ?? PATHFINDER_STROKES }, mode: options.mode ?? 'merge' });\n const overlay = useMemo(() => createPathOverlay({ id: 'shape-builder-faces', label: 'Shape Builder — faces' }), []);\n const built = useMemo(\n () => createShapeBuilderActions(overlay, () => settingsRef.current),\n [overlay, settingsRef],\n );\n\n const { keybinding } = options;\n return useMemo(() => defineTool({\n id: 'shapeBuilder',\n capabilities: ['edits-page'],\n hookName: 'useShapeBuilderTool',\n cursor: 'crosshair',\n presentation: { label: 'Shape Builder', icon: /* @icon */ 'core:union', group: 'shape' },\n ...(keybinding === null ? {} : { keybinding: keybinding ?? { key: 'M', shift: true } }),\n actions: built.actions,\n overlay: overlay.layer,\n onDeactivate: built.reset,\n bindings: [\n { spec: { kind: 'hover', mods: { alt: 'optional' } }, actionId: 'shapeBuilder.hover' },\n { spec: { kind: 'hover', motion: 'leave', mods: { alt: 'optional' } }, actionId: 'shapeBuilder.leave' },\n { spec: { kind: 'click', mods: { alt: 'optional' } }, actionId: 'shapeBuilder.click' },\n // Alt is read live, so it can be pressed or let go mid-drag.\n { spec: { kind: 'drag', mods: { alt: 'optional' } }, actionId: 'shapeBuilder', opts: { yields: true } },\n { spec: { kind: 'drag', mods: { shift: 'optional' } }, actionId: 'areaSelect' },\n ],\n }), [built, overlay, keybinding]);\n}\n","/**\n * What the Girth tool reads and writes: the stroke edge under a point, the\n * width point a press on it moves — inserting an anchor where the press falls\n * between two — and the per-vertex widths a drag leaves behind.\n */\nimport {\n editAnchorSetTracked, insertAnchorOnSegment, nearestSegmentT, pathToAnchors, type PolygonPath, type Point,\n} from '@weasel-js/geom';\nimport {\n type HalfWidths, type Stroke, type VertexWidth, vertexHalfWidths, vertexWidthFromSides,\n} from '@weasel-js/paint';\nimport { resolveStrokeWidth, strokeEdgeNear, type StrokeEdgeHit, type StrokeSide } from '@weasel-js/stroke';\nimport { resolveEditablePathOf, withPath, type NodeId, type Scene, type SceneNode } from '@weasel-js/core';\n\n\n/** A stroked path node and its centerline in world space. */\nexport interface WidthTarget {\n id: NodeId;\n node: SceneNode<unknown, string, unknown>;\n path: PolygonPath;\n stroke: Stroke;\n /** The stroke's own width in world units: what an unset entry takes. */\n fallback: number;\n}\n\n/** A stroke edge found under a point, and the width point a press there\n * moves: anchor `index`, or one inserted at `at` when `index` is null. */\nexport interface WidthEdgeHit {\n target: WidthTarget;\n edge: StrokeEdgeHit;\n index: number | null;\n at: Point;\n}\n\n/**\n * The width point a drag edits, on a node's geometry as the press leaves it:\n * `path` gained an anchor at `index` when the press fell between two.\n */\nexport interface WidthGrip {\n target: WidthTarget;\n /** The world path, with the inserted anchor if there is one. */\n path: PolygonPath;\n /** One entry per anchor of `path`; `NaN` takes the stroke's own width. */\n widths: VertexWidth[];\n index: number;\n at: Point;\n inserted: boolean;\n /** The edge taken hold of, and the unit normal it moves along. */\n side: StrokeSide;\n normal: Point;\n /** Each edge's distance from the path at the width point, before the drag. */\n start: HalfWidths;\n /** What the nib multiplies a stored width by there, so a drag moves the\n * edge as drawn. */\n factor: number;\n}\n\nfunction anchorPoints(path: PolygonPath): Point[] {\n return pathToAnchors(path).anchors.flat().map((a) => ({ x: a.x, y: a.y }));\n}\n\n/** Whether `entry` gives either edge a distance of its own. */\nexport function isWidthSet(entry: VertexWidth | undefined): boolean {\n const { left, right } = vertexHalfWidths(entry, NaN);\n return !Number.isNaN(left) || !Number.isNaN(right);\n}\n\n/** The node's stroke, when it paints one along an editable path. */\nfunction targetOf(scene: Scene<unknown, string, unknown>, node: SceneNode<unknown, string, unknown>, scale: number): WidthTarget | null {\n if (node.kind !== 'leaf' || node.derivePath || node.derivePose || scene.isLocked(node.id) || scene.isHidden(node.id)) return null;\n const stroke = (node.data as { stroke?: Stroke | null } | null)?.stroke;\n if (!stroke?.paint) return null;\n const path = resolveEditablePathOf(node);\n return path ? { id: node.id, node, path, stroke, fallback: resolveStrokeWidth(stroke.width ?? 1, scale) } : null;\n}\n\n/** The topmost stroke, and its edge nearest `(x, y)`, that `accept` takes.\n * `scale` resolves a `{ px }` width. */\nfunction edgeAt(\n scene: Scene<unknown, string, unknown>, x: number, y: number, scale: number, accept: (edge: StrokeEdgeHit) => boolean,\n): { target: WidthTarget; edge: StrokeEdgeHit } | null {\n const nodes = scene.renderOrderNodes();\n for (let i = nodes.length - 1; i >= 0; i--) {\n const target = targetOf(scene, nodes[i], scale);\n if (!target) continue;\n const edge = strokeEdgeNear(target.path, target.stroke, x, y, { scale });\n if (edge && accept(edge)) return { target, edge };\n }\n return null;\n}\n\n/** The topmost stroke whose ink is within `reach` of `(x, y)`. */\nexport function widthTargetAt(scene: Scene<unknown, string, unknown>, x: number, y: number, scale: number, reach: number): WidthTarget | null {\n return edgeAt(scene, x, y, scale, (edge) => edge.gap <= reach)?.target ?? null;\n}\n\n/** The topmost stroke edge within `reach` of `(x, y)`, and the width point a\n * press there moves: the anchor within `reach` along the path, or a new one. */\nexport function widthEdgeAt(scene: Scene<unknown, string, unknown>, x: number, y: number, scale: number, reach: number): WidthEdgeHit | null {\n const found = edgeAt(scene, x, y, scale, (edge) => Math.abs(edge.gap) <= reach);\n if (!found) return null;\n const { edge } = found;\n let index: number | null = null;\n let bestD = reach;\n const anchors = anchorPoints(found.target.path);\n anchors.forEach((p, i) => {\n const d = Math.hypot(p.x - edge.x, p.y - edge.y);\n if (d <= bestD) { bestD = d; index = i; }\n });\n return { ...found, index, at: index === null ? { x: edge.x, y: edge.y } : anchors[index] };\n}\n\n/** `target`'s per-vertex widths, one per anchor; `NaN` where none is set. */\nexport function widthsOf(target: WidthTarget, count: number): VertexWidth[] {\n const own = target.stroke.vertexWidths ?? [];\n return Array.from({ length: count }, (_, i) => (isWidthSet(own[i]) ? own[i] : NaN));\n}\n\n/** Each anchor's unit normal toward its right edge, from the directions the\n * path leaves and enters it by. */\nexport function anchorNormals(path: PolygonPath): Point[] {\n const set = pathToAnchors(path);\n return set.anchors.flatMap((sub, s) => sub.map((a, i) => {\n const closed = set.closed?.[s] ?? false;\n const next = sub[i + 1] ?? (closed ? sub[0] : undefined);\n const prev = sub[i - 1] ?? (closed ? sub[sub.length - 1] : undefined);\n const out = a.outHandle ?? next;\n const inn = a.inHandle ?? prev;\n let tx = 0, ty = 0;\n for (const [from, to] of [[a, out], [inn, a]] as const) {\n if (!from || !to) continue;\n const len = Math.hypot(to.x - from.x, to.y - from.y);\n if (len > 0) { tx += (to.x - from.x) / len; ty += (to.y - from.y) / len; }\n }\n const len = Math.hypot(tx, ty);\n return len > 0 ? { x: -ty / len, y: tx / len } : { x: 0, y: 1 };\n }));\n}\n\n/** The index of the set width point whose line across the stroke passes\n * within `reach` of `(x, y)`, nearest first, or -1. */\nexport function widthPointNear(target: WidthTarget, x: number, y: number, reach: number): number {\n const anchors = anchorPoints(target.path);\n const normals = anchorNormals(target.path);\n const widths = widthsOf(target, anchors.length);\n let best = -1;\n let bestD = reach;\n anchors.forEach((a, i) => {\n if (!isWidthSet(widths[i])) return;\n const { left, right } = vertexHalfWidths(widths[i], target.fallback);\n const n = normals[i];\n // Along the normal, clamped to the line from the left edge to the right.\n const along = Math.min(right, Math.max(-left, (x - a.x) * n.x + (y - a.y) * n.y));\n const d = Math.hypot(x - (a.x + n.x * along), y - (a.y + n.y * along));\n if (d <= bestD) { bestD = d; best = i; }\n });\n return best;\n}\n\n/** Take hold of the width point `hit` names, inserting its anchor — the\n * path's shape and the stroke's width there both kept — when it is new. */\nexport function gripAt(hit: WidthEdgeHit): WidthGrip | null {\n const { target, edge } = hit;\n const count = anchorPoints(target.path).length;\n const widths = widthsOf(target, count);\n const factor = edge.factor > 0.05 ? edge.factor : 1;\n const base = { target, side: edge.side, normal: { x: edge.nx, y: edge.ny }, factor };\n if (hit.index !== null) {\n const start = vertexHalfWidths(widths[hit.index], target.fallback);\n return { ...base, path: target.path, widths, index: hit.index, at: hit.at, inserted: false, start };\n }\n const set = pathToAnchors(target.path);\n const seg = nearestSegmentT(set.anchors, edge.x, edge.y, set.closed);\n if (!seg) return null;\n let inserted = -1;\n const next = editAnchorSetTracked(target.path, (s) => {\n inserted = insertAnchorOnSegment(s, seg);\n return inserted !== -1;\n });\n if (!next || inserted < 0) return null;\n const start = { left: edge.left / factor, right: edge.right / factor };\n widths.splice(inserted, 0, widths.some(isWidthSet) ? vertexWidthFromSides(start.left, start.right) : NaN);\n return { ...base, path: next.path, widths, index: inserted, at: anchorPoints(next.path)[inserted], inserted: true, start };\n}\n\n/** The grabbed edge's distance from the path after the pointer has moved\n * `delta` along the grip's normal, as stored: never below zero. */\nexport function movedSide(grip: WidthGrip, delta: number): number {\n return Math.max(0, grip.start[grip.side] + delta / grip.factor);\n}\n\n/** The width point's entry once its grabbed edge sits `moved` from the path:\n * both edges there, or with `oneSided` only the grabbed one. */\nexport function draggedWidth(grip: WidthGrip, moved: number, oneSided: boolean): VertexWidth {\n if (!oneSided) return 2 * moved;\n return grip.side === 'left' ? vertexWidthFromSides(moved, grip.start.right) : vertexWidthFromSides(grip.start.left, moved);\n}\n\n/** The node's pose and data with `grip`'s geometry and `widths`, or null\n * when the node cannot store the geometry. All-unset widths drop the list. */\nexport function storedWith(grip: WidthGrip, widths: readonly VertexWidth[]): { pose: unknown; data: unknown } | null {\n const { node, stroke } = grip.target;\n const shaped = grip.inserted ? withPath(node, grip.path) : { pose: node.pose, data: node.data };\n if (!shaped) return null;\n const { vertexWidths: _old, ...rest } = stroke;\n void _old;\n const next: Stroke = widths.some(isWidthSet) ? { ...rest, vertexWidths: [...widths] } : rest;\n return { pose: shaped.pose, data: { ...(shaped.data as object), stroke: next } };\n}\n","import type { Action, ActionDeps, InvocationCtx } from '@weasel-js/routing';\nimport { ActionDisabledReason } from '@weasel-js/routing';\nimport { meanScale, pathToAnchors, pxExtent, type PolygonPath, type Point } from '@weasel-js/geom';\nimport type { VertexWidth } from '@weasel-js/paint';\nimport { commitOps, reshapeTo, type Scene } from '@weasel-js/core';\nimport {\n anchorNormals, draggedWidth, gripAt, isWidthSet, movedSide, storedWith, widthEdgeAt, widthPointNear, widthsOf,\n widthTargetAt, type WidthGrip, type WidthTarget,\n} from './widthEdit';\n\ntype AnyScene = Scene<unknown, string, unknown>;\n\n/** What the Girth tool's overlay shows, in world space: the anchors of the\n * stroke last hovered or pressed on, each with its unit normal toward its\n * right edge and its `vertexWidths` entry (`NaN` for none), and, over an\n * edge, the grab point on it and the width point a press there moves. */\nexport interface GirthFocus {\n anchors: readonly Point[];\n normals: readonly Point[];\n widths: readonly VertexWidth[];\n /** The stroke's own width, which an unset entry takes. */\n fallback: number;\n grab?: { edge: Point; at: Point };\n}\n\n/** The Girth tool's own state, shared by its actions and its overlay. */\nexport interface GirthEnv {\n focus(): GirthFocus | null;\n setFocus(next: GirthFocus | null): void;\n /** Screen px around a stroke's edge within which a press takes hold of it,\n * and along the path within which it takes the anchor there. */\n reachPx(): number;\n}\n\n/** Id of the action that drags a stroke's edge. */\nexport const GIRTH_DRAG_ID = 'girth.drag';\n/** Id of the action that clears the width point under a click. */\nexport const GIRTH_CLEAR_ID = 'girth.clear';\n/** Id of the action that marks the edge under a hover. */\nexport const GIRTH_HOVER_ID = 'girth.hover';\n/** Id of the action that drops the hover mark when the pointer leaves. */\nexport const GIRTH_UNHOVER_ID = 'girth.unhover';\nconst LABEL = 'Stroke width';\nconst REQUIRES = ['scene', 'view', 'selection', 'applyOps'] as const;\n\nconst found = (deps: ActionDeps, env: GirthEnv) => {\n const scene = deps.scene as AnyScene | undefined;\n if (!scene) return null;\n const s = deps.view?.get().scale ?? { x: 1, y: 1 };\n const e = pxExtent(env.reachPx(), s);\n return { scene, scale: meanScale(s), reach: Math.max(e.x, e.y) };\n};\n\nconst focusOf = (path: PolygonPath, widths: readonly VertexWidth[], fallback: number, grab?: GirthFocus['grab']): GirthFocus => ({\n anchors: pathToAnchors(path).anchors.flat().map((a) => ({ x: a.x, y: a.y })),\n normals: anchorNormals(path),\n widths,\n fallback,\n ...(grab ? { grab } : {}),\n});\n\nconst restingFocus = (target: WidthTarget): GirthFocus =>\n focusOf(target.path, widthsOf(target, pathToAnchors(target.path).anchors.flat().length), target.fallback);\n\n/** The focus as it was, less its grab point. */\nfunction dropGrab(env: GirthEnv): void {\n const last = env.focus();\n if (!last?.grab) return;\n const { grab: _grab, ...rest } = last;\n void _grab;\n env.setFocus(rest);\n}\n\nfunction commit(deps: ActionDeps, grip: WidthGrip, widths: readonly VertexWidth[]): void {\n const next = storedWith(grip, widths);\n if (next) commitOps(deps, reshapeTo(grip.target.node, next, LABEL), LABEL);\n}\n\nconst edgeOf = (grip: WidthGrip, moved: number): Point => ({\n x: grip.at.x + grip.normal.x * moved * grip.factor,\n y: grip.at.y + grip.normal.y * moved * grip.factor,\n});\n\nfunction dragAction(env: GirthEnv): Action['invoker'] {\n return {\n timing: 'ongoing',\n start: ({ deps, drag, world }: InvocationCtx) => {\n const press = drag?.start ?? world;\n const at = found(deps, env);\n const hit = at && widthEdgeAt(at.scene, press.x, press.y, at.scale, at.reach);\n const grip = hit && gripAt(hit);\n if (!grip) return {};\n const { fallback } = grip.target;\n let widths: VertexWidth[] | null = null;\n let preview: { pose: unknown; data: unknown } | null = null;\n env.setFocus(focusOf(grip.path, grip.widths, fallback, { edge: edgeOf(grip, grip.start[grip.side]), at: grip.at }));\n return {\n kind: GIRTH_DRAG_ID,\n onMove: (move: InvocationCtx) => {\n const p = move.drag?.current ?? move.world;\n const moved = movedSide(grip, (p.x - press.x) * grip.normal.x + (p.y - press.y) * grip.normal.y);\n widths = [...grip.widths];\n widths[grip.index] = draggedWidth(grip, moved, move.modifiers.alt);\n preview = storedWith(grip, widths);\n env.setFocus(focusOf(grip.path, widths, fallback, { edge: edgeOf(grip, moved), at: grip.at }));\n },\n // The dispatcher hands `onEnd` a context with empty deps.\n onEnd: (_end: InvocationCtx, reason: 'commit' | 'cancel') => {\n const done = widths;\n widths = null;\n preview = null;\n if (reason === 'cancel' || done === null) {\n env.setFocus(restingFocus(grip.target));\n return;\n }\n commit(deps, grip, done);\n env.setFocus(focusOf(grip.path, done, fallback));\n },\n previewIds: () => (preview ? [grip.target.id] : null),\n previewPose: (id: string) => (preview && id === grip.target.id ? preview.pose : null),\n previewData: (id: string) => (preview && id === grip.target.id ? preview.data : null),\n };\n },\n };\n}\n\n/**\n * The Girth tool's actions, which write a stroke's `vertexWidths`.\n * `girth.drag` takes hold of the stroke edge under the press, at the anchor\n * there or at one it inserts, shape kept, between two. The edge follows the\n * pointer along the path's normal, the other edge mirroring it so the width\n * stays centered; with Alt held only the grabbed edge moves, which writes a\n * `{ left, right }` pair. Either is live, and one undo entry. `girth.clear`\n * clears the width point under a click, so it takes the stroke's own width\n * again. `girth.hover` and `girth.unhover` show and hide the grab point under\n * the pointer.\n */\nexport function createGirthActions(env: GirthEnv): Action[] {\n const eligible = { capability: 'edits-page' } as const;\n const hasScene = (deps?: ActionDeps) => (deps?.scene ? true : ActionDisabledReason.NotApplicable);\n const base = { eligible, requires: REQUIRES, enabled: hasScene };\n return [\n { id: GIRTH_DRAG_ID, label: 'Girth — drag a stroke\\'s edge', ...base, invoker: dragAction(env) },\n {\n id: GIRTH_CLEAR_ID,\n label: 'Girth — clear the width point under the pointer',\n ...base,\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const p = params as { pressX?: number; pressY?: number } | undefined;\n const at = found(deps, env);\n if (!at || p?.pressX === undefined || p.pressY === undefined) return;\n const target = widthTargetAt(at.scene, p.pressX, p.pressY, at.scale, at.reach);\n if (!target) return;\n const index = widthPointNear(target, p.pressX, p.pressY, at.reach);\n const widths = widthsOf(target, pathToAnchors(target.path).anchors.flat().length);\n if (index < 0 || !isWidthSet(widths[index])) return;\n widths[index] = NaN;\n const grip: WidthGrip = {\n target, path: target.path, widths, index, at: { x: 0, y: 0 }, inserted: false,\n side: 'right', normal: { x: 0, y: 1 }, start: { left: 0, right: 0 }, factor: 1,\n };\n commit(deps, grip, widths);\n env.setFocus(focusOf(target.path, widths, target.fallback));\n },\n },\n },\n {\n id: GIRTH_HOVER_ID,\n label: 'Girth — show the stroke edge under the pointer',\n ...base,\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const p = params as { worldX?: number; worldY?: number } | undefined;\n const at = found(deps, env);\n if (!at || p?.worldX === undefined || p.worldY === undefined) return;\n const hit = widthEdgeAt(at.scene, p.worldX, p.worldY, at.scale, at.reach);\n if (!hit) {\n dropGrab(env);\n return;\n }\n const { edge } = hit;\n const half = edge.side === 'right' ? edge.right : edge.left;\n env.setFocus({\n ...restingFocus(hit.target),\n grab: { edge: { x: edge.x + edge.nx * half, y: edge.y + edge.ny * half }, at: hit.at },\n });\n },\n },\n },\n {\n id: GIRTH_UNHOVER_ID,\n label: 'Girth — hide the grab point',\n ...base,\n invoker: {\n timing: 'immediate',\n run: () => dropGrab(env),\n },\n },\n ];\n}\n","import { ellipsePath, polylineFromPoints } from '@weasel-js/geom';\nimport { vertexHalfWidths } from '@weasel-js/paint';\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport { viewToTransform, worldToScreen, type RenderLayer } from '@weasel-js/core';\nimport type { GirthFocus } from './girthActions';\nimport { isWidthSet } from './widthEdit';\n\nconst DOT_RADIUS_PX = 3.5;\nconst GRAB_RADIUS_PX = 4.5;\nconst RIM = '#10161d';\nconst SET = '#ffffff';\nconst UNSET = '#8a94a3';\nconst ACCENT = '#2f80ed';\nconst ACROSS = { paint: { color: ACCENT }, width: 1 };\n\nconst circle = (x: number, y: number, r: number) => ellipsePath({ x: x - r, y: y - r, width: 2 * r, height: 2 * r });\nconst line = (a: [number, number], b: [number, number]): DrawCommand => ({\n kind: 'path', path: polylineFromPoints([{ x: a[0], y: a[1] }, { x: b[0], y: b[1] }]), stroke: ACROSS,\n});\n\n/**\n * A screen-space layer marking the width points of the stroke the Girth tool\n * last touched: a dot on each anchor, white where it has a width of its own,\n * with a line across the stroke from its left edge to its right. Over an\n * edge it adds the grab point on that edge, ringing the width point a press\n * there moves.\n */\nexport function createGirthOverlay(source: {\n focus(): GirthFocus | null;\n subscribe(fn: () => void): () => void;\n}): RenderLayer<unknown> {\n return {\n id: 'width-tool-anchors',\n label: 'Width anchors',\n space: 'screen',\n subscribe: source.subscribe,\n draw: (_data, view) => {\n const focus = source.focus();\n if (!focus) return [];\n const m = viewToTransform(view);\n const at = (x: number, y: number) => worldToScreen(x, y, m);\n const lines: DrawCommand[] = [];\n const dots: DrawCommand[] = [];\n focus.anchors.forEach((a, i) => {\n const set = isWidthSet(focus.widths[i]);\n if (set) {\n const { left, right } = vertexHalfWidths(focus.widths[i], focus.fallback);\n const n = focus.normals[i];\n lines.push(line(at(a.x - n.x * left, a.y - n.y * left), at(a.x + n.x * right, a.y + n.y * right)));\n }\n const [x, y] = at(a.x, a.y);\n dots.push({\n kind: 'path',\n path: circle(x, y, DOT_RADIUS_PX),\n fill: { paint: { kind: 'solid', color: set ? SET : UNSET } },\n stroke: { paint: { color: RIM }, width: 1 },\n });\n });\n const grab: DrawCommand[] = [];\n if (focus.grab) {\n const w = at(focus.grab.at.x, focus.grab.at.y);\n const e = at(focus.grab.edge.x, focus.grab.edge.y);\n grab.push(\n line(w, e),\n { kind: 'path', path: circle(w[0], w[1], GRAB_RADIUS_PX + 1.5), stroke: { paint: { color: ACCENT }, width: 1.5 } },\n {\n kind: 'path',\n path: circle(e[0], e[1], GRAB_RADIUS_PX),\n fill: { paint: { kind: 'solid', color: ACCENT } },\n stroke: { paint: { color: SET }, width: 1 },\n },\n );\n }\n return [...lines, ...dots, ...grab];\n },\n };\n}\n","import { useMemo } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { createEmitter } from '@weasel-js/registry';\nimport type { ToolKeybinding } from '@weasel-js/routing';\nimport { defineTool, type Tool } from '@weasel-js/core';\nimport {\n createGirthActions, GIRTH_CLEAR_ID, GIRTH_DRAG_ID, GIRTH_HOVER_ID, GIRTH_UNHOVER_ID, type GirthEnv, type GirthFocus,\n} from './girthActions';\nimport { createGirthOverlay } from './girthOverlay';\nimport { icon } from '../icons.gen';\n\n/** Options for `useGirthTool`. */\nexport interface UseGirthToolOptions {\n /** Override the default keybinding (`{ key: 'W', shift: true }`). Pass `null` to omit. */\n keybinding?: ToolKeybinding | null;\n /** Screen px around a stroke's edge within which a press takes hold of it,\n * and along the path within which it takes the anchor there rather than\n * inserting one. Default 6. */\n reach?: number;\n}\n\n/**\n * Girth tool: shapes a stroke's width along its length, into its\n * `vertexWidths`, by dragging the stroke's edges. Hovering near either edge\n * marks the grab point on it and the width point a press there moves: the\n * anchor at that spot, or a new one inserted between two, keeping the path's\n * shape. Dragging moves the grabbed edge along the path's normal, the other\n * edge mirroring it so the width stays centered; inward pinches it, down to\n * zero. With Alt held only the grabbed edge moves, writing a `{ left, right }`\n * pair. Either drag is live and one undo entry. Alt-click on a width point\n * clears it, so it takes the stroke's own width. The last stroke touched shows\n * its anchors, with a line across the stroke at each that has a width.\n */\nexport function useGirthTool(options: UseGirthToolOptions = {}): Tool {\n const opts = useLatest({ reach: options.reach ?? 6 });\n const env = useMemo(() => {\n const changed = createEmitter();\n const held: { focus: GirthFocus | null } = { focus: null };\n const value: GirthEnv & { listen(fn: () => void): () => void } = {\n focus: () => held.focus,\n setFocus: (next) => {\n held.focus = next;\n changed.emit();\n },\n reachPx: () => opts.current.reach,\n listen: changed.subscribe,\n };\n return value;\n }, [opts]);\n\n const actions = useMemo(() => createGirthActions(env), [env]);\n const overlay = useMemo(() => createGirthOverlay({ focus: env.focus, subscribe: env.listen }), [env]);\n\n const { keybinding } = options;\n return useMemo(() => defineTool({\n id: 'girth',\n capabilities: ['edits-page'],\n hookName: 'useGirthTool',\n cursor: 'crosshair',\n presentation: { label: 'Girth', group: 'shape', icon: /* @icon */ 'path-tools:girth' },\n ...(keybinding === null ? {} : { keybinding: keybinding ?? { key: 'W', shift: true } }),\n actions,\n overlay,\n onDeactivate: () => env.setFocus(null),\n bindings: [\n { spec: { kind: 'drag', mods: { shift: 'optional', alt: 'optional' } }, actionId: GIRTH_DRAG_ID },\n { spec: { kind: 'click', mods: { alt: true } }, actionId: GIRTH_CLEAR_ID },\n { spec: { kind: 'hover', mods: { alt: 'optional', shift: 'optional' } }, actionId: GIRTH_HOVER_ID },\n { spec: { kind: 'hover', motion: 'leave' }, actionId: GIRTH_UNHOVER_ID },\n ],\n }), [actions, overlay, keybinding, env]);\n}\n","/**\n * Screen-space preview layer for `useSpiroTool`: the curve solved through the\n * points placed so far and the cursor, a marker on each point shaped by its\n * kind, and a ring on the first point while a click there would close the\n * curve. Runs in screen space so markers keep their size under zoom.\n */\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport { circlePath, spiroToPath, transformPath, type Affine, type PolygonPath, type SpiroPoint } from '@weasel-js/geom';\nimport type { RenderLayer } from '@weasel-js/core';\nimport { spiroMarker } from './spiroMarkers';\n\n/** What the spiro tool has placed, as the preview reads it each frame. */\nexport interface SpiroPreviewState {\n points: readonly SpiroPoint[];\n /** Where the next point would go, or null while the pointer is away. */\n cursor: SpiroPoint | null;\n /** True while a click would close the curve on its first point. */\n closeHint: boolean;\n}\n\n/** Options for {@link createSpiroPreviewLayer}. */\nexport interface CreateSpiroPreviewLayerOptions {\n state: () => SpiroPreviewState;\n /** The color the curve and markers are drawn in. */\n color?: string;\n}\n\nconst MARKER_PX = 8;\nconst CLOSE_HINT_PX = 8;\n\n/** Render layer drawing the spiro tool's curve in progress; nothing while\n * no point is placed. */\nexport function createSpiroPreviewLayer(opts: CreateSpiroPreviewLayerOptions): RenderLayer<unknown> {\n const color = opts.color ?? '#d4c4a8';\n const paint = { kind: 'solid' as const, color };\n return {\n id: 'spiroPreview',\n label: 'Spiro preview',\n space: 'screen',\n draw: (_data, view) => {\n const { points, cursor, closeHint } = opts.state();\n if (points.length === 0) return [];\n const sx = (p: { x: number; y: number }) => (p.x - view.x) * view.scale.x;\n const sy = (p: { x: number; y: number }) => (p.y - view.y) * view.scale.y;\n const out: DrawCommand[] = [];\n const through = cursor && !closeHint ? [...points, cursor] : [...points];\n if (through.length >= 2) {\n const { path } = spiroToPath([{ points: through, closed: closeHint }]);\n const toScreen: Affine = [view.scale.x, 0, 0, view.scale.y, -view.x * view.scale.x, -view.y * view.scale.y];\n out.push({ kind: 'path', path: transformPath(path, toScreen) as PolygonPath, stroke: { paint, width: 1 } });\n }\n const screen = points.map((p) => ({ x: sx(p), y: sy(p) }));\n points.forEach((p, i) => {\n const path = spiroMarker(p.kind)(screen[i], MARKER_PX, screen[i - 1] ?? null, screen[i + 1] ?? null);\n out.push({ kind: 'path', path, fill: { paint }, stroke: { paint, width: 1 } });\n });\n if (closeHint) {\n out.push({ kind: 'path', path: circlePath(sx(points[0]), sy(points[0]), CLOSE_HINT_PX), stroke: { paint, width: 1.5 } });\n }\n return out;\n },\n };\n}\n","import { useMemo, useReducer, useRef, useState } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { Action, ActionDeps, ModifierState } from '@weasel-js/routing';\nimport { ActionDisabledReason } from '@weasel-js/routing';\nimport { cursorFor } from '@weasel-js/cursor';\nimport { boundsOfPath, isSpiroKind, withinPxRadius, type SpiroKind, type SpiroPoint } from '@weasel-js/geom';\nimport { createPointerFollower, defineTool, pointSnap, snapMods, type Tool } from '@weasel-js/core';\nimport { icon } from '../icons.gen';\nimport { createSpiroPreviewLayer, type SpiroPreviewState } from './spiroPreviewLayer';\nimport { spiroNodeData } from './spiroShape';\n\n/** Options for {@link useSpiroTool}. */\nexport interface UseSpiroToolOptions {\n /** Select the new curve once it commits. Default `true`. */\n autoSelect?: boolean;\n /** Screen-px radius of \"click the first point to close\". Default `8`. */\n closeHitRadius?: number;\n}\n\n/** The spiro tool's state between gestures: the points placed so far. */\ninterface SpiroScratch extends SpiroPreviewState {\n points: SpiroPoint[];\n}\n\nconst fresh = (): SpiroScratch => ({ points: [], cursor: null, closeHint: false });\n\n/** What {@link spiroActions} reads and writes of the tool's hook. */\ninterface SpiroActionsHost {\n /** The points placed so far. */\n scratch(): SpiroScratch;\n /** Drop every point placed. */\n reset(): void;\n options(): { autoSelect: boolean; closeHitRadius: number };\n repaint(): void;\n}\n\nconst NO_KEYS: ModifierState = { alt: false, ctrl: false, meta: false, shift: false };\n\n/** The spiro tool's actions. Each point placed, and the cursor, snaps\n * through the `snap` dep's `point` sessions about the point placed before. */\nfunction spiroActions(host: SpiroActionsHost): Action[] {\n const s = host.scratch;\n // The deps last followed through, whose camera and snap the cursor reads.\n let followed: ActionDeps | undefined;\n const snaps = pointSnap();\n const nearFirst = (x: number, y: number): boolean => {\n const { points } = s();\n if (points.length < 3) return false;\n const scale = followed?.view?.get().scale ?? { x: 1, y: 1 };\n return withinPxRadius(points[0].x - x, points[0].y - y, host.options().closeHitRadius, scale);\n };\n // The cursor the preview solves through, following the pointer while points are placed.\n const follower = createPointerFollower(() => track());\n const track = (): void => {\n const scratch = s();\n if (scratch.points.length === 0) follower.unfollow();\n const at = scratch.points.length > 0 ? follower.pointer()?.get() ?? null : null;\n if (!at) snaps.stop();\n const p = at ? snaps.trail(followed?.snap, { x: at.worldX, y: at.worldY }, scratch.points.at(-1)) : null;\n scratch.cursor = p ? { ...p, kind: 'smooth' } : null;\n scratch.closeHint = p !== null && nearFirst(p.x, p.y);\n host.repaint();\n };\n const commit = (deps: ActionDeps, closed: boolean): void => {\n const { points } = s();\n if (points.length >= 2) {\n const { path, representation } = spiroNodeData([{ points, closed }]);\n const id = deps.insert?.commit(boundsOfPath(path), { kind: 'path', path, closed, data: { representation } }) ?? null;\n if (id !== null && host.options().autoSelect) deps.selection?.set([id]);\n }\n host.reset();\n track();\n };\n const placing = () => (s().points.length > 0 ? true : ActionDisabledReason.NotApplicable);\n\n return [\n {\n id: 'spiro.placePoint',\n label: 'Spiro — place point',\n eligible: { capability: 'creates-paths' },\n requires: ['view', 'pointer', 'insert', 'selection', 'snap'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const p = params as { pressX?: number; pressY?: number; kind?: unknown; mods?: ModifierState } | undefined;\n if (p?.pressX === undefined || p.pressY === undefined) return;\n followed = deps;\n follower.follow(deps.pointer);\n const mods = snapMods({ modifiers: p.mods ?? NO_KEYS });\n const at = snaps.place(deps.snap, { x: p.pressX, y: p.pressY }, mods, s().points.at(-1)).point;\n if (nearFirst(at.x, at.y)) return commit(deps, true);\n const kind: SpiroKind = isSpiroKind(p.kind) ? p.kind : 'smooth';\n s().points.push({ x: at.x, y: at.y, kind });\n track();\n },\n },\n },\n {\n id: 'spiro.finish',\n label: 'Spiro — finish open curve',\n eligible: { capability: 'creates-paths' },\n requires: ['insert', 'selection'],\n enabled: placing,\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n // A double click arrives after both its clicks, the second of which placed a point.\n if ((params as { viaDoubleClick?: boolean } | undefined)?.viaDoubleClick) s().points.pop();\n commit(deps, false);\n },\n },\n },\n {\n id: 'spiro.removeLast',\n label: 'Spiro — take back the last point',\n eligible: { capability: 'creates-paths' },\n enabled: placing,\n invoker: { timing: 'immediate', run: () => { s().points.pop(); track(); } },\n },\n {\n id: 'spiro.cancel',\n label: 'Spiro — discard curve',\n eligible: { capability: 'creates-paths' },\n // Declining with nothing placed passes Escape on to `escape`.\n enabled: placing,\n invoker: { timing: 'immediate', run: () => { host.reset(); track(); } },\n },\n ];\n}\n\n/**\n * Active-slot Tool that draws a spiro curve (`solveSpiro`) by placing its\n * on-curve points: each click places one, of the kind `params.kind` of the\n * `spiro.placePoint` action (default `'smooth'`; Alt-click places a corner),\n * and the preview solves the curve through the points and the cursor as it\n * moves. Clicking the first point of three or more closes the curve; Enter,\n * a double-click or Mod-click finishes it open; Backspace takes back the last\n * point and Escape discards them all, as does switching tools.\n *\n * The curve is inserted through the `insert` dep as a `'path'`, its spiro\n * form beside it on `data.representation`, so a consumer shapes the node by\n * overriding that dep. With `spiroPreset` on, path edit then edits its points\n * (`spiroRepresentation`).\n */\nexport function useSpiroTool(options: UseSpiroToolOptions = {}): Tool {\n const { autoSelect = true, closeHitRadius = 8 } = options;\n const opts = useLatest({ autoSelect, closeHitRadius });\n const scratchRef = useRef<SpiroScratch | null>(null);\n if (scratchRef.current === null) scratchRef.current = fresh();\n const [, forceRender] = useReducer((n: number) => n + 1, 0);\n const [overlay] = useState(() => createSpiroPreviewLayer({ state: () => scratchRef.current! }));\n\n const actions = useMemo(() => spiroActions({\n scratch: () => scratchRef.current!,\n reset: () => { scratchRef.current = fresh(); },\n options: () => opts.current,\n repaint: forceRender,\n }), [opts]);\n\n return useMemo(() => defineTool({\n id: 'spiro',\n keybinding: { key: 'P', shift: true },\n capabilities: ['creates-paths'],\n hookName: 'useSpiroTool',\n cursor: () => (scratchRef.current?.closeHint ? 'pointer' : cursorFor('pen', { fallback: 'crosshair' })),\n presentation: { label: 'Spiro', icon: /* @icon */ 'path-tools:spiro', group: 'draw' },\n actions,\n overlay,\n overlayPosition: 'before-selection',\n onDeactivate: () => {\n scratchRef.current = fresh();\n forceRender();\n },\n bindings: [\n { spec: { kind: 'click', mods: { shift: 'optional' } }, actionId: 'spiro.placePoint' },\n { spec: { kind: 'click', mods: { alt: true, shift: 'optional' } }, actionId: 'spiro.placePoint', opts: { params: { kind: 'corner' } } },\n { spec: { kind: 'click', mods: { mod: true, shift: 'optional' } }, actionId: 'spiro.finish' },\n { spec: { kind: 'doubleClick', mods: { shift: 'optional', alt: 'optional' } }, actionId: 'spiro.finish', opts: { params: { viaDoubleClick: true } } },\n { spec: { kind: 'key', key: 'Enter' }, actionId: 'spiro.finish' },\n { spec: { kind: 'key', key: 'Backspace' }, actionId: 'spiro.removeLast' },\n { spec: { kind: 'key', key: 'Escape' }, actionId: 'spiro.cancel' },\n ],\n }), [actions, overlay]);\n}\n","/**\n * The controls for the selected corners of a path in edit: a schema any\n * prefs form draws, the values and mixed fields it shows for a selection,\n * and the `setCorners` params a change to one of them makes.\n */\nimport {\n CORNER_KEYWORDS,\n cornerFrames,\n cornerKeywordOf,\n cornerShapeK,\n cornerSpecAt,\n type CornerKeyword,\n type CornerShape,\n type PolygonPath,\n} from '@weasel-js/geom';\nimport type { PrefGroup } from '@weasel-js/prefs';\n\n/** How far the parameter slider reaches either side of the bevel; the\n * `square` and `notch` keywords stand for the two infinities beyond it. */\nexport const CORNER_K_SLIDER_RANGE = 4;\n\nconst ENABLED = { path: 'count', above: 0 };\n\n/** What the corner controls ask for while no corner is selected. */\nexport const CORNER_CONTROLS_PROMPT = 'Click a corner anchor (Shift-click for more) to edit it';\n\n/** The corner controls as a prefs schema: the keywords, the parameter, and\n * the radius, each disabled while no corner is selected. */\nexport const CORNER_CONTROLS: PrefGroup = {\n name: 'Corner shape',\n children: {\n count: { kind: 'number', name: 'Selected corners', description: '', default: 0, hidden: true },\n shape: {\n kind: 'enum', name: 'Shape', description: '', default: 'round', control: 'toggle', enableIf: ENABLED,\n options: CORNER_KEYWORDS.map((w) => ({ value: w, label: w })),\n // A parameter between the keywords, or a sharp corner, presses none.\n encoding: {\n read: (stored) => (CORNER_KEYWORDS.includes(stored as CornerKeyword) ? (stored as CornerKeyword) : undefined),\n write: (option) => option,\n },\n },\n k: {\n kind: 'number', name: 'Curvature', description: 'The superellipse() parameter: 1 is round, 0 a bevel, -1 a scoop.',\n default: 1, min: -CORNER_K_SLIDER_RANGE, max: CORNER_K_SLIDER_RANGE, step: 0.05, control: 'slider', enableIf: ENABLED,\n },\n radius: {\n kind: 'number', name: 'Radius', description: 'How far along each edge the corner is cut.',\n default: 0, min: 0, step: 1, control: 'input', enableIf: ENABLED,\n },\n },\n};\n\n/** What the controls show for a selection. */\nexport interface CornerControlsState {\n /** `shape` is null where no keyword applies, so a form does not fall back\n * to the leaf's default. */\n values: { count: number; shape: CornerKeyword | null; k?: number; radius?: number };\n /** The fields whose selected corners disagree. */\n mixed: ReadonlySet<string>;\n}\n\nconst SHARP = Symbol('sharp');\n\n/** One value if every entry agrees, `SHARP` if they agree on being sharp,\n * else undefined. */\nfunction agreed<T>(values: readonly (T | typeof SHARP)[]): { value?: T; mixed: boolean } {\n const first = values[0];\n if (!values.every((v) => Object.is(v, first))) return { mixed: true };\n return { value: first === SHARP ? undefined : (first as T), mixed: false };\n}\n\n/** The controls for the corners of `path` among `selected` anchors. A sharp\n * corner shows no shape and no parameter. */\nexport function cornerControlsState(path: PolygonPath | null, selected: ReadonlySet<number>): CornerControlsState {\n if (!path) return { values: { count: 0, shape: null }, mixed: new Set() };\n const specs = cornerFrames(path).filter((f) => selected.has(f.index)).map((f) => cornerSpecAt(path, f.index));\n const cut = specs.map((c) => (c && c.radius > 0 ? c : SHARP));\n const shape = agreed(cut.map((c) => (c === SHARP ? SHARP : keywordOf(c.shape))));\n const k = agreed(cut.map((c) => (c === SHARP ? SHARP : clampK(cornerShapeK(c.shape)))));\n const radius = agreed(specs.map((c) => Math.round((c?.radius ?? 0) * 100) / 100));\n const mixed = new Set<string>();\n if (shape.mixed) mixed.add('shape');\n if (k.mixed) mixed.add('k');\n if (radius.mixed) mixed.add('radius');\n return {\n values: {\n count: specs.length,\n shape: shape.value ?? null,\n ...(k.value !== undefined ? { k: k.value } : {}),\n ...(radius.value !== undefined ? { radius: radius.value } : {}),\n },\n mixed,\n };\n}\n\n/** The keyword `shape` names or equals, or null for a parameter between them. */\nfunction keywordOf(shape: CornerShape): CornerKeyword | null {\n return typeof shape === 'number' ? cornerKeywordOf(shape) : shape;\n}\n\nconst clampK = (k: number): number => Math.max(-CORNER_K_SLIDER_RANGE, Math.min(CORNER_K_SLIDER_RANGE, k));\n\n/** The `setCorners` params a change of `field` to `value` makes, or null for\n * a field that sets nothing. */\nexport function cornerControlsParams(field: string, value: unknown): { shape: CornerShape } | { radius: number } | null {\n if (field === 'shape' && CORNER_KEYWORDS.includes(value as CornerKeyword)) return { shape: value as CornerKeyword };\n if (field === 'k' && typeof value === 'number' && Number.isFinite(value)) return { shape: value };\n if (field === 'radius' && typeof value === 'number' && Number.isFinite(value)) return { radius: value };\n return null;\n}\n","/**\n * The corner controls over a live selection: what to show, kept current as\n * the scene and the anchor selection change, and a change handler that runs\n * `setCorners` on the registry the caller sits under.\n */\nimport { useActionsRegistry } from '@weasel-js/routing/react';\nimport { useCallback, useMemo, useSyncExternalStore } from 'react';\nimport { resolveEditablePathOf, type EditableShape, type NodeId } from '@weasel-js/core';\nimport { CORNER_CONTROLS, CORNER_CONTROLS_PROMPT, cornerControlsParams, cornerControlsState } from './cornerControls';\n\n/** The part of a scene the controls read. */\nexport interface CornerControlsScene {\n get(id: NodeId): EditableShape | undefined;\n subscribe(listener: () => void): () => void;\n}\n\n/** Which path is open for anchor editing and which of its anchors are\n * selected: what a `PathEditHost` that owns the anchor selection knows. */\nexport interface CornerControlsSelection {\n editingId(): string | null;\n selectedAnchors(): ReadonlySet<number>;\n subscribe(listener: () => void): () => void;\n}\n\n/** What {@link useCornerControls} gives a corner panel to draw. */\nexport interface UseCornerControlsReturn {\n /** The schema a prefs form draws: `CORNER_CONTROLS`. Its `name` is the\n * controls' title. */\n schema: typeof CORNER_CONTROLS;\n /** What to show above the form, or null once a corner is selected. */\n prompt: string | null;\n values: Record<string, unknown>;\n mixed: ReadonlySet<string>;\n /** A prefs form's `onChange` for `CORNER_CONTROLS`. */\n onChange: (field: string, value: unknown) => void;\n}\n\nfunction snapshot(scene: CornerControlsScene, selection: CornerControlsSelection): string {\n const id = selection.editingId();\n const path = id ? resolveEditablePathOf(scene.get(id as NodeId)) : null;\n const { values, mixed } = cornerControlsState(path, selection.selectedAnchors());\n return JSON.stringify({ values, mixed: [...mixed] });\n}\n\n/**\n * A corner panel over the selected corners of the path open for anchor\n * editing: their shared shape and radius, kept current as the scene or the\n * selection changes, and an `onChange` that writes through `setCorners`.\n */\nexport function useCornerControls(\n scene: CornerControlsScene,\n selection: CornerControlsSelection,\n): UseCornerControlsReturn {\n const actions = useActionsRegistry();\n const subscribe = useCallback((l: () => void) => {\n const offScene = scene.subscribe(l);\n const offSelection = selection.subscribe(l);\n return () => { offScene(); offSelection(); };\n }, [scene, selection]);\n const key = useSyncExternalStore(subscribe, () => snapshot(scene, selection));\n const shown = useMemo(() => {\n const parsed = JSON.parse(key) as { values: Record<string, unknown>; mixed: string[] };\n return { values: parsed.values, mixed: new Set(parsed.mixed) };\n }, [key]);\n const onChange = useCallback((field: string, value: unknown) => {\n const params = cornerControlsParams(field, value);\n if (params) actions?.trigger('setCorners', params);\n }, [actions]);\n const prompt = shown.values.count === 0 ? CORNER_CONTROLS_PROMPT : null;\n return { schema: CORNER_CONTROLS, prompt, ...shown, onChange };\n}\n"]}
|