@vanduo-oss/vd3-cbun 1.3.0 → 1.3.2
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/CHANGELOG.md +27 -0
- package/README.md +5 -4
- package/dist/draw/core.d.ts +3 -0
- package/dist/draw/index.cjs +44 -5
- package/dist/draw/index.cjs.map +3 -3
- package/dist/draw/index.js +44 -5
- package/dist/draw/index.js.map +3 -3
- package/dist/draw/vue.d.ts +12 -0
- package/dist/flowchart/index.cjs +103 -68
- package/dist/flowchart/index.cjs.map +2 -2
- package/dist/flowchart/index.js +103 -68
- package/dist/flowchart/index.js.map +2 -2
- package/dist/flowchart/vd3-flowchart.css +176 -47
- package/dist/meta.json +20 -20
- package/package.json +1 -1
package/dist/draw/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/draw/index.js", "../../src/draw/vue.js", "../../src/draw/shapes.js", "../../src/draw/core.js"],
|
|
4
|
-
"sourcesContent": ["// Entry for @vanduo-oss/vd3-cbun/draw.\n//\n// The Vue 3 wrapper is the primary export; the framework-agnostic editor core\n// is re-exported alongside as VdDrawCore. Named exports only \u2014 no default.\n\nexport { VdDraw } from './vue.js';\nexport { VdDraw as VdDrawCore } from './core.js';\nexport { VD_DRAW_VERSION, DRAW_TOOLS, DRAW_SHAPE_TYPES, BRUSH_PRESETS } from './shapes.js';\n", "/**\n * Vue 3 bindings for the draw whiteboard \u2014 the primary export surface.\n *\n * import { VdDraw } from '@vanduo-oss/vd3-cbun/draw';\n * <VdDraw :data=\"doc\" tool=\"rectangle\" @change=\"onChange\" @ready=\"onReady\" />\n *\n * The editor core stays framework-agnostic in ./core.js. SSR-safe: the editor\n * is created on mount (client) into a plain container the server can\n * pre-render.\n */\nimport { defineComponent, h, ref, onMounted, onBeforeUnmount, watch } from 'vue';\nimport { VdDraw as VdDrawCore } from './core.js';\n\nconst FORWARDED_EVENTS = ['change', 'select', 'viewport', 'ready'];\n\nexport const VdDraw = defineComponent({\n name: 'VdDraw',\n props: {\n /** Drawing document \u2014 `{ shapes, viewport }`. */\n data: { type: Object, default: () => ({}) },\n /** Render as a non-editable viewer (no toolbar, no editing). */\n readonly: { type: Boolean, default: false },\n /** Active tool \u2014 updated live without recreating the editor. */\n tool: { type: String, default: 'draw' },\n /** Background grid size in px. */\n gridSize: { type: Number, default: undefined },\n /** Show the background grid \u2014 updated live (default true). */\n showGrid: { type: Boolean, default: true },\n /** Snap shapes to nearby edges/centres while moving/resizing. */\n snap: { type: Boolean, default: true },\n /** Fit the view to content once the editor reports a measurable size. */\n autoFit: { type: Boolean, default: false },\n /** Enable the built-in undo/redo history (default true). */\n history: { type: Boolean, default: true },\n /** Maximum number of history entries to retain. */\n historyLimit: { type: Number, default: undefined },\n },\n emits: ['change', 'select', 'viewport', 'ready'],\n setup(props, { emit, expose }) {\n const el = ref(null);\n let instance = null;\n\n const create = () => {\n instance = new VdDrawCore({\n element: el.value,\n data: props.data,\n readonly: props.readonly,\n tool: props.tool,\n gridSize: props.gridSize,\n showGrid: props.showGrid,\n snap: props.snap,\n autoFit: props.autoFit,\n history: props.history,\n historyLimit: props.historyLimit,\n });\n FORWARDED_EVENTS.forEach((name) => {\n instance.on(name, (payload) => emit(name, payload));\n });\n };\n\n onMounted(() => {\n if (typeof window === 'undefined' || !el.value) return;\n create();\n });\n\n // Data flows through load(); tool updates live; construct-time options recreate.\n watch(\n () => props.data,\n (next) => {\n if (instance && typeof instance.load === 'function') instance.load(next);\n },\n { deep: true },\n );\n watch(\n () => props.tool,\n (next) => instance?.setTool(next),\n );\n watch(\n () => props.showGrid,\n (next) => instance?.setGridVisible(next),\n );\n watch(\n () => [\n props.readonly,\n props.gridSize,\n props.snap,\n props.autoFit,\n props.history,\n props.historyLimit,\n ],\n () => {\n if (!instance) return;\n instance.destroy();\n create();\n },\n );\n\n onBeforeUnmount(() => {\n if (instance) {\n instance.destroy();\n instance = null;\n }\n });\n\n expose({\n getInstance: () => instance,\n setTool: (tool) => instance?.setTool(tool),\n undo: () => instance?.undo(),\n redo: () => instance?.redo(),\n canUndo: () => Boolean(instance?.canUndo()),\n canRedo: () => Boolean(instance?.canRedo()),\n toSVG: () => instance?.toSVG(),\n toPNG: (options) => instance?.toPNG(options),\n });\n\n return () => h('div', { ref: el, class: 'vd-draw' });\n },\n});\n", "// Pure, DOM-free geometry + document model + brush engine for the draw tool.\n//\n// Everything here is framework- and DOM-agnostic so it is unit-testable in\n// plain Node (the analogue of flowchart's layout.js). core.js owns the SVG DOM\n// engine and calls into these helpers; nothing in this file touches `window`,\n// `document`, or `vue`.\n\n/** Load-bearing: stamped into every serialized document via toJSON().version. */\nexport const VD_DRAW_VERSION = '1.1.0';\n\n/** Selectable tools \u2014 drawing-first. `select`/`hand` manipulate. */\nexport const DRAW_TOOLS = Object.freeze([\n 'select',\n 'hand',\n 'draw',\n 'eraser',\n 'rectangle',\n 'ellipse',\n 'line',\n 'text',\n 'sticky',\n]);\n\n/** Persisted shape kinds. The `draw` tool produces a `freehand` (brush) stroke. */\nexport const DRAW_SHAPE_TYPES = Object.freeze([\n 'rectangle',\n 'ellipse',\n 'line',\n 'freehand',\n 'text',\n 'sticky',\n]);\n\n/**\n * Brush presets \u2014 each a config the brush engine consumes. `thinning` maps\n * pressure/velocity to width (0 = flat); `streamline` low-passes the input;\n * taper shrinks the ends; `blend` is the CSS mix-blend-mode; `nibAngle` (only\n * calligraphy) makes width depend on stroke direction.\n */\nexport const BRUSH_PRESETS = Object.freeze({\n pen: {\n size: 6,\n thinning: 0.55,\n smoothing: 0.5,\n streamline: 0.5,\n taperStart: 0,\n taperEnd: 14,\n opacity: 1,\n blend: 'normal',\n },\n pencil: {\n size: 4,\n thinning: 0.7,\n smoothing: 0.35,\n streamline: 0.35,\n taperStart: 4,\n taperEnd: 10,\n opacity: 0.92,\n blend: 'normal',\n },\n marker: {\n size: 14,\n thinning: 0.15,\n smoothing: 0.55,\n streamline: 0.5,\n taperStart: 0,\n taperEnd: 0,\n opacity: 0.85,\n blend: 'normal',\n },\n highlighter: {\n size: 22,\n thinning: 0,\n smoothing: 0.6,\n streamline: 0.55,\n taperStart: 0,\n taperEnd: 0,\n opacity: 0.4,\n blend: 'multiply',\n },\n calligraphy: {\n size: 12,\n thinning: 0.6,\n smoothing: 0.4,\n streamline: 0.3,\n taperStart: 8,\n taperEnd: 12,\n opacity: 1,\n nibAngle: -0.7,\n blend: 'normal',\n },\n});\n\nexport const DEFAULT_BRUSH = 'pen';\n\n/** Shapes whose geometry is a list of world-space points (vs. an x/y/w/h box). */\nconst POINT_TYPES = Object.freeze(['line', 'freehand']);\n\nexport const MIN_SCALE = 0.2;\nexport const MAX_SCALE = 4;\nexport const DEFAULT_GRID_SIZE = 20;\nexport const DEFAULT_STROKE_WIDTH = 2;\n\n// Bounded deserialization caps. An untrusted or corrupt document (e.g. a shared\n// link with tens of millions of points or shapes) is TRUNCATED \u2014 never thrown \u2014\n// so `load()` cannot be turned into a client-side DoS: the O(n) coercion and the\n// resulting render stay bounded. A normal document is far below these limits and\n// is unaffected.\nexport const MAX_SHAPES = 10000;\nexport const MAX_POINTS_PER_SHAPE = 100000;\n\nlet idCounter = 0;\n\n/** Monotonic-ish id; unique within a session, prefixed by kind. */\nexport function createId(prefix = 'sh') {\n idCounter += 1;\n return `${prefix}_${idCounter.toString(36)}${(idCounter * 2654435761).toString(36).slice(-4)}`;\n}\n\nexport function clamp(value, min, max) {\n return Math.min(max, Math.max(min, value));\n}\n\n/** Round to 2 decimals to keep serialized coordinates stable and compact. */\nexport function round(value) {\n return Math.round((Number(value) || 0) * 100) / 100;\n}\n\n/** Structured deep clone with a JSON fallback for older runtimes. */\nexport function deepClone(value) {\n if (typeof structuredClone === 'function') {\n try {\n return structuredClone(value);\n } catch {\n /* fall through to JSON */\n }\n }\n return JSON.parse(JSON.stringify(value));\n}\n\n/** Round a point, preserving an optional third (pressure) slot. */\nfunction roundPoint(p) {\n const out = [round(p[0]), round(p[1])];\n if (p.length >= 3 && p[2] != null) out.push(clamp(Number(p[2]) || 0, 0, 1));\n return out;\n}\n\nfunction isPointShape(shape) {\n return POINT_TYPES.includes(shape.type);\n}\n\n/** Axis-aligned bounds `{ x, y, w, h }` for any shape kind. */\nexport function shapeBounds(shape) {\n if (isPointShape(shape)) {\n const pts = shape.points || [];\n if (!pts.length) return { x: shape.x || 0, y: shape.y || 0, w: 0, h: 0 };\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const [px, py] of pts) {\n if (px < minX) minX = px;\n if (py < minY) minY = py;\n if (px > maxX) maxX = px;\n if (py > maxY) maxY = py;\n }\n return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };\n }\n return { x: shape.x || 0, y: shape.y || 0, w: shape.w || 0, h: shape.h || 0 };\n}\n\n/** Union bounds of several shapes, or null when the list is empty. */\nexport function boundsOfShapes(shapes) {\n if (!shapes || !shapes.length) return null;\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const shape of shapes) {\n const b = shapeBounds(shape);\n minX = Math.min(minX, b.x);\n minY = Math.min(minY, b.y);\n maxX = Math.max(maxX, b.x + b.w);\n maxY = Math.max(maxY, b.y + b.h);\n }\n return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };\n}\n\n/** Do two `{x,y,w,h}` boxes overlap (used for marquee selection / eraser)? */\nexport function boundsIntersect(a, b) {\n return !(a.x + a.w < b.x || b.x + b.w < a.x || a.y + a.h < b.y || b.y + b.h < a.y);\n}\n\n/** Is a world point inside a shape's (padded) bounds? Hit-test for select. */\nexport function pointInShape(shape, x, y, pad = 0) {\n const b = shapeBounds(shape);\n return x >= b.x - pad && x <= b.x + b.w + pad && y >= b.y - pad && y <= b.y + b.h + pad;\n}\n\n/** Shortest distance from a world point to a shape (for the eraser). */\nexport function distanceToShape(shape, x, y) {\n if (isPointShape(shape)) {\n const pts = shape.points || [];\n if (pts.length === 1) return Math.hypot(pts[0][0] - x, pts[0][1] - y);\n let min = Infinity;\n for (let i = 1; i < pts.length; i += 1) {\n min = Math.min(min, pointToSegment(x, y, pts[i - 1], pts[i]));\n }\n return min;\n }\n const b = shapeBounds(shape);\n const dx = Math.max(b.x - x, 0, x - (b.x + b.w));\n const dy = Math.max(b.y - y, 0, y - (b.y + b.h));\n return Math.hypot(dx, dy);\n}\n\nfunction pointToSegment(px, py, a, b) {\n const vx = b[0] - a[0];\n const vy = b[1] - a[1];\n const wx = px - a[0];\n const wy = py - a[1];\n const c1 = vx * wx + vy * wy;\n if (c1 <= 0) return Math.hypot(px - a[0], py - a[1]);\n const c2 = vx * vx + vy * vy;\n if (c2 <= c1) return Math.hypot(px - b[0], py - b[1]);\n const t = c1 / c2;\n return Math.hypot(px - (a[0] + t * vx), py - (a[1] + t * vy));\n}\n\n/** Return a NEW shape translated by (dx, dy); pure, never mutates input. */\nexport function translateShape(shape, dx, dy) {\n const next = deepClone(shape);\n if (isPointShape(next)) {\n next.points = (next.points || []).map((p) => roundPoint([p[0] + dx, p[1] + dy, p[2]]));\n } else {\n next.x = round((next.x || 0) + dx);\n next.y = round((next.y || 0) + dy);\n }\n return next;\n}\n\n/**\n * Return a NEW shape scaled about (ox, oy) by (sx, sy). Box shapes rescale\n * x/y/w/h; point shapes rescale each point. Pure.\n */\nexport function scaleShape(shape, ox, oy, sx, sy) {\n const next = deepClone(shape);\n const avg = (Math.abs(sx) + Math.abs(sy)) * 0.5;\n if (isPointShape(next)) {\n next.points = (next.points || []).map((p) =>\n roundPoint([ox + (p[0] - ox) * sx, oy + (p[1] - oy) * sy, p[2]]),\n );\n if (typeof next.size === 'number') next.size = round(Math.max(1, next.size * avg));\n if (typeof next.strokeWidth === 'number') next.strokeWidth = round(next.strokeWidth * avg);\n } else {\n next.x = round(ox + ((next.x || 0) - ox) * sx);\n next.y = round(oy + ((next.y || 0) - oy) * sy);\n next.w = round(Math.max(1, (next.w || 0) * sx));\n next.h = round(Math.max(1, (next.h || 0) * sy));\n }\n return next;\n}\n\n/** Eight resize handles for a selection box, keyed by compass direction. */\nexport function resizeHandlePositions(bounds) {\n const { x, y, w, h } = bounds;\n const mx = x + w / 2;\n const my = y + h / 2;\n return [\n { key: 'nw', x, y },\n { key: 'n', x: mx, y },\n { key: 'ne', x: x + w, y },\n { key: 'e', x: x + w, y: my },\n { key: 'se', x: x + w, y: y + h },\n { key: 's', x: mx, y: y + h },\n { key: 'sw', x, y: y + h },\n { key: 'w', x, y: my },\n ];\n}\n\n/** Build an SVG path `d` for a straight polyline (line shapes). */\nexport function pointsToPath(points) {\n if (!points || !points.length) return '';\n const [first, ...rest] = points;\n let d = `M ${round(first[0])} ${round(first[1])}`;\n for (const [px, py] of rest) d += ` L ${round(px)} ${round(py)}`;\n return d;\n}\n\n/**\n * Drop points closer than `min` world units to the previously kept point \u2014\n * keeps freehand strokes light without visibly changing the path. Preserves\n * the optional pressure slot.\n */\nexport function simplifyPoints(points, min = 1.2) {\n if (!points || points.length <= 2) return (points || []).map(roundPoint);\n const out = [roundPoint(points[0])];\n for (let i = 1; i < points.length; i += 1) {\n const p = points[i];\n const last = out[out.length - 1];\n if (Math.hypot(p[0] - last[0], p[1] - last[1]) >= min || i === points.length - 1)\n out.push(roundPoint(p));\n }\n return out;\n}\n\n// \u2500\u2500 Brush engine \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// A compact, dependency-free variable-width stroke generator: input points\n// (each [x, y, pressure?]) \u2192 a filled outline polygon. Pure/deterministic.\n\nfunction streamlinePoints(points, streamline) {\n const first = points[0];\n const out = [[first[0], first[1], first[2] == null ? 0.5 : clamp(first[2], 0, 1)]];\n if (points.length < 2) return out;\n const factor = clamp(1 - (streamline == null ? 0.5 : streamline), 0.15, 1);\n for (let i = 1; i < points.length; i += 1) {\n const prev = out[out.length - 1];\n const p = points[i];\n out.push([\n prev[0] + (p[0] - prev[0]) * factor,\n prev[1] + (p[1] - prev[1]) * factor,\n p[2] == null ? 0.5 : clamp(p[2], 0, 1),\n ]);\n }\n return out;\n}\n\nfunction circlePolygon(cx, cy, r, segments = 16) {\n const pts = [];\n for (let i = 0; i < segments; i += 1) {\n const a = (i / segments) * Math.PI * 2;\n pts.push([cx + Math.cos(a) * r, cy + Math.sin(a) * r]);\n }\n return pts;\n}\n\n// Faster strokes (longer per-sample segments) render thinner.\nfunction velocityPressure(segmentLength) {\n return clamp(1 - segmentLength / 28, 0.25, 1);\n}\n\n/**\n * Variable-width outline for a brush stroke. Returns a closed polygon (array of\n * `[x, y]`) to be filled. Width follows per-point pressure (or velocity when\n * pressure is flat), scaled by `size` and `thinning`, with start/end taper and\n * an optional fixed-angle nib.\n */\nexport function strokeOutline(rawPoints, options = {}) {\n const points = (rawPoints || []).filter((p) => Array.isArray(p) && p.length >= 2);\n if (points.length === 0) return [];\n const size = Math.max(1, options.size == null ? 8 : options.size);\n const thinning = options.thinning == null ? 0.5 : options.thinning;\n const taperStart = options.taperStart || 0;\n const taperEnd = options.taperEnd || 0;\n const nibAngle = options.nibAngle;\n\n const pts = streamlinePoints(points, options.streamline);\n if (pts.length === 1) return circlePolygon(pts[0][0], pts[0][1], size / 2);\n\n const segLen = [];\n let total = 0;\n for (let i = 1; i < pts.length; i += 1) {\n const d = Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]);\n segLen.push(d);\n total += d;\n }\n const hasPressure = points.some((p) => p.length >= 3 && p[2] != null && p[2] > 0 && p[2] !== 0.5);\n\n const left = [];\n const right = [];\n let run = 0;\n for (let i = 0; i < pts.length; i += 1) {\n const p = pts[i];\n const prev = pts[i - 1] || p;\n const next = pts[i + 1] || p;\n let dx = next[0] - prev[0];\n let dy = next[1] - prev[1];\n const len = Math.hypot(dx, dy) || 1;\n dx /= len;\n dy /= len;\n const nx = -dy;\n const ny = dx;\n const pressure = hasPressure\n ? p[2]\n : velocityPressure(segLen[i - 1] == null ? segLen[i] || 0 : segLen[i - 1]);\n let radius = (size / 2) * (thinning === 0 ? 1 : 1 - thinning + thinning * pressure);\n if (typeof nibAngle === 'number') {\n radius *= 0.35 + 0.65 * Math.abs(Math.sin(Math.atan2(dy, dx) - nibAngle));\n }\n if (i > 0) run += segLen[i - 1];\n if (taperStart > 0) radius *= clamp(run / taperStart, 0, 1);\n if (taperEnd > 0) radius *= clamp((total - run) / taperEnd, 0, 1);\n radius = Math.max(0.1, radius);\n left.push([p[0] + nx * radius, p[1] + ny * radius]);\n right.push([p[0] - nx * radius, p[1] - ny * radius]);\n }\n return [...left, ...right.reverse()];\n}\n\n/** Smooth closed SVG path `d` (quadratic) for a filled outline polygon. */\nexport function pointsToBrushPath(outline) {\n if (!outline || outline.length < 3) {\n if (outline && outline.length) {\n const [x, y] = outline[0];\n return `M ${round(x - 1)} ${round(y)} a 1 1 0 1 0 2 0 a 1 1 0 1 0 -2 0 Z`;\n }\n return '';\n }\n let d = `M ${round(outline[0][0])} ${round(outline[0][1])}`;\n for (let i = 1; i < outline.length; i += 1) {\n const prev = outline[i - 1];\n const cur = outline[i];\n const mx = (prev[0] + cur[0]) / 2;\n const my = (prev[1] + cur[1]) / 2;\n d += ` Q ${round(prev[0])} ${round(prev[1])} ${round(mx)} ${round(my)}`;\n }\n return `${d} Z`;\n}\n\n/** Convenience: the filled path `d` for a freehand shape (brush + size). */\nexport function brushStrokePath(shape) {\n const preset = BRUSH_PRESETS[shape.brush] || BRUSH_PRESETS[DEFAULT_BRUSH];\n return pointsToBrushPath(\n strokeOutline(shape.points || [], {\n ...preset,\n size: shape.size == null ? preset.size : shape.size,\n }),\n );\n}\n\nfunction coerceNumber(value, fallback = 0) {\n const n = Number(value);\n return Number.isFinite(n) ? n : fallback;\n}\n\nfunction coercePoints(raw) {\n if (!Array.isArray(raw)) return [];\n const pts = [];\n // Bounded deserialization: coerce at most MAX_POINTS_PER_SHAPE points; any\n // beyond the cap are truncated so a hostile stroke stays O(cap).\n const limit = Math.min(raw.length, MAX_POINTS_PER_SHAPE);\n for (let i = 0; i < limit; i += 1) {\n const p = raw[i];\n if (\n Array.isArray(p) &&\n p.length >= 2 &&\n Number.isFinite(Number(p[0])) &&\n Number.isFinite(Number(p[1]))\n ) {\n const pt = [round(Number(p[0])), round(Number(p[1]))];\n if (p.length >= 3 && Number.isFinite(Number(p[2]))) pt.push(clamp(Number(p[2]), 0, 1));\n pts.push(pt);\n }\n }\n return pts;\n}\n\n/**\n * Validate/normalize a single raw shape. Returns a clean shape or `null` when\n * the input is unusable. Unknown `type` values default to `rectangle`.\n * Migrates v1 freehand (`{ points, stroke, strokeWidth }`) to the brush model.\n */\nexport function normalizeShape(raw, usedIds) {\n if (!raw || typeof raw !== 'object') return null;\n const type = DRAW_SHAPE_TYPES.includes(raw.type) ? raw.type : 'rectangle';\n\n let id = typeof raw.id === 'string' && raw.id ? raw.id : createId(type.slice(0, 2));\n if (usedIds) {\n while (usedIds.has(id)) id = createId(type.slice(0, 2));\n usedIds.add(id);\n }\n const groupId = typeof raw.groupId === 'string' && raw.groupId ? raw.groupId : undefined;\n const color =\n typeof raw.color === 'string'\n ? raw.color\n : typeof raw.stroke === 'string'\n ? raw.stroke\n : undefined;\n\n if (type === 'freehand') {\n const points = coercePoints(raw.points);\n if (points.length < 1) return null;\n const brush = BRUSH_PRESETS[raw.brush] ? raw.brush : DEFAULT_BRUSH;\n const preset = BRUSH_PRESETS[brush];\n const size =\n raw.size != null\n ? Math.max(1, coerceNumber(raw.size, preset.size))\n : raw.strokeWidth != null\n ? Math.max(1, coerceNumber(raw.strokeWidth, DEFAULT_STROKE_WIDTH) * 2)\n : preset.size;\n const shape = {\n id,\n type: 'freehand',\n brush,\n points,\n size: round(size),\n opacity:\n raw.opacity == null\n ? preset.opacity\n : clamp(coerceNumber(raw.opacity, preset.opacity), 0, 1),\n };\n if (color) shape.color = color;\n if (groupId) shape.groupId = groupId;\n return shape;\n }\n\n const base = {\n id,\n type,\n strokeWidth:\n raw.strokeWidth == null\n ? DEFAULT_STROKE_WIDTH\n : coerceNumber(raw.strokeWidth, DEFAULT_STROKE_WIDTH),\n opacity: raw.opacity == null ? 1 : clamp(coerceNumber(raw.opacity, 1), 0, 1),\n };\n if (color) base.color = color;\n if (typeof raw.fill === 'string') base.fill = raw.fill;\n if (groupId) base.groupId = groupId;\n\n if (type === 'line') {\n const points = coercePoints(raw.points);\n if (points.length < 2) return null;\n return {\n ...base,\n points,\n arrowStart: Boolean(raw.arrowStart),\n arrowEnd: raw.arrowEnd == null ? true : Boolean(raw.arrowEnd),\n };\n }\n\n const shape = {\n ...base,\n x: round(coerceNumber(raw.x, 0)),\n y: round(coerceNumber(raw.y, 0)),\n w: round(Math.max(1, coerceNumber(raw.w, 100))),\n h: round(Math.max(1, coerceNumber(raw.h, 80))),\n rotation: coerceNumber(raw.rotation, 0),\n };\n if (type === 'text' || type === 'sticky')\n shape.text = typeof raw.text === 'string' ? raw.text : '';\n return shape;\n}\n\nfunction normalizeViewport(raw) {\n const vp = raw && typeof raw === 'object' ? raw : {};\n return {\n x: coerceNumber(vp.x, 0),\n y: coerceNumber(vp.y, 0),\n scale: clamp(coerceNumber(vp.scale, 1), MIN_SCALE, MAX_SCALE),\n };\n}\n\n/**\n * The single validation + forward-migration gateway. Accepts an object or a\n * JSON string (any prior VD_DRAW_VERSION), and returns a clean\n * `{ version, viewport, shapes }` stamped with the CURRENT version. Ensures\n * unique ids, drops malformed shapes, defaults unknown types, prunes dangling\n * groupIds, and migrates v1 freehand to the brush model. Never mutates input.\n */\nexport function normalizeDocument(data) {\n let raw = data;\n if (typeof raw === 'string') {\n try {\n raw = JSON.parse(raw);\n } catch {\n raw = {};\n }\n }\n if (!raw || typeof raw !== 'object') raw = {};\n\n const usedIds = new Set();\n const rawShapes = Array.isArray(raw.shapes) ? raw.shapes : [];\n const shapes = [];\n // Bounded deserialization: normalize at most MAX_SHAPES shapes; extras from an\n // untrusted document are truncated so the load stays O(cap).\n const shapeLimit = Math.min(rawShapes.length, MAX_SHAPES);\n for (let i = 0; i < shapeLimit; i += 1) {\n const shape = normalizeShape(rawShapes[i], usedIds);\n if (shape) shapes.push(shape);\n }\n\n const groupCounts = new Map();\n for (const s of shapes)\n if (s.groupId) groupCounts.set(s.groupId, (groupCounts.get(s.groupId) || 0) + 1);\n for (const s of shapes) if (s.groupId && groupCounts.get(s.groupId) < 2) delete s.groupId;\n\n return {\n version: VD_DRAW_VERSION,\n viewport: normalizeViewport(raw.viewport),\n shapes,\n };\n}\n", "// Framework-agnostic infinite-canvas drawing tool.\n//\n// Architecture mirrors the flowchart core (SVG world <g> transformed by a\n// matrix for pan/zoom, a plain-object document mutated in place, one\n// `interaction` state machine, and a single emitChange \u2192 recordHistory choke\n// point for whole-document undo snapshots) \u2014 but is a drawing/painting tool:\n// a vector brush engine (see shapes.js), brush presets, a color palette, and a\n// stroke eraser. Fully self-contained under src/draw/ (the tree-shake isolation\n// guard forbids importing vd3 or sibling components). SSR-safe: constructed on\n// mount only; no window/document at module scope; every window listener is\n// removed on destroy().\n\nimport {\n VD_DRAW_VERSION,\n DRAW_TOOLS,\n DRAW_SHAPE_TYPES,\n BRUSH_PRESETS,\n DEFAULT_BRUSH,\n MIN_SCALE,\n MAX_SCALE,\n DEFAULT_GRID_SIZE,\n createId,\n clamp,\n round,\n deepClone,\n shapeBounds,\n boundsOfShapes,\n boundsIntersect,\n distanceToShape,\n translateShape,\n scaleShape,\n resizeHandlePositions,\n pointsToPath,\n simplifyPoints,\n brushStrokePath,\n normalizeDocument,\n} from './shapes.js';\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\nconst WORLD_EXTENT = 8000; // half-size of the grid backdrop, in world units\nconst HANDLE_SIZE = 8; // screen px (kept constant via r/scale)\nconst SNAP_THRESHOLD = 6; // screen px within which edges/centres snap\nconst DRAG_THRESHOLD = 3; // screen px before a press counts as a drag\nconst ERASER_RADIUS = 12; // screen px eraser hit radius\n\n// Reasons whose consecutive same-target commits collapse into one undo entry.\nconst COALESCE_REASONS = new Set(['shape:style', 'shape:text', 'shape:nudge']);\n\n// Genuine Phosphor (regular) icon path data \u2014 MIT, inlined so the component\n// stays self-contained (no webfont / CDN). viewBox 0 0 256 256, currentColor.\nconst ICON_PATHS = {\n select:\n 'M168,132.69,214.08,115l.33-.13A16,16,0,0,0,213,85.07L52.92,32.8A15.95,15.95,0,0,0,32.8,52.92L85.07,213a15.82,15.82,0,0,0,14.41,11l.78,0a15.84,15.84,0,0,0,14.61-9.59l.13-.33L132.69,168,184,219.31a16,16,0,0,0,22.63,0l12.68-12.68a16,16,0,0,0,0-22.63ZM195.31,208,144,156.69a16,16,0,0,0-26,4.93c0,.11-.09.22-.13.32l-17.65,46L48,48l159.85,52.2-45.95,17.64-.32.13a16,16,0,0,0-4.93,26h0L208,195.31Z',\n hand: 'M188,48a27.75,27.75,0,0,0-12,2.71V44a28,28,0,0,0-54.65-8.6A28,28,0,0,0,80,60v64l-3.82-6.13a28,28,0,0,0-48.6,27.82c16,33.77,28.93,57.72,43.72,72.69C86.24,233.54,103.2,240,128,240a88.1,88.1,0,0,0,88-88V76A28,28,0,0,0,188,48Zm12,104a72.08,72.08,0,0,1-72,72c-20.38,0-33.51-4.88-45.33-16.85C69.44,193.74,57.26,171,41.9,138.58a6.36,6.36,0,0,0-.3-.58,12,12,0,0,1,20.79-12,1.76,1.76,0,0,0,.14.23l18.67,30A8,8,0,0,0,96,152V60a12,12,0,0,1,24,0v60a8,8,0,0,0,16,0V44a12,12,0,0,1,24,0v76a8,8,0,0,0,16,0V76a12,12,0,0,1,24,0Z',\n draw: 'M232,32a8,8,0,0,0-8-8c-44.08,0-89.31,49.71-114.43,82.63A60,60,0,0,0,32,164c0,30.88-19.54,44.73-20.47,45.37A8,8,0,0,0,16,224H92a60,60,0,0,0,57.37-77.57C182.3,121.31,232,76.08,232,32ZM92,208H34.63C41.38,198.41,48,183.92,48,164a44,44,0,1,1,44,44Zm32.42-94.45q5.14-6.66,10.09-12.55A76.23,76.23,0,0,1,155,121.49q-5.9,4.94-12.55,10.09A60.54,60.54,0,0,0,124.42,113.55Zm42.7-2.68a92.57,92.57,0,0,0-22-22c31.78-34.53,55.75-45,69.9-47.91C212.17,55.12,201.65,79.09,167.12,110.87Z',\n eraser:\n 'M225,80.4,183.6,39a24,24,0,0,0-33.94,0L31,157.66a24,24,0,0,0,0,33.94l30.06,30.06A8,8,0,0,0,66.74,224H216a8,8,0,0,0,0-16h-84.7L225,114.34A24,24,0,0,0,225,80.4ZM108.68,208H70.05L42.33,180.28a8,8,0,0,1,0-11.31L96,115.31,148.69,168Zm105-105L160,156.69,107.31,104,161,50.34a8,8,0,0,1,11.32,0l41.38,41.38a8,8,0,0,1,0,11.31Z',\n rectangle:\n 'M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm0,176H48V48H208V208Z',\n ellipse:\n 'M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z',\n line: 'M200,64V168a8,8,0,0,1-16,0V83.31L69.66,197.66a8,8,0,0,1-11.32-11.32L172.69,72H88a8,8,0,0,1,0-16H192A8,8,0,0,1,200,64Z',\n text: 'M208,56V88a8,8,0,0,1-16,0V64H136V192h24a8,8,0,0,1,0,16H96a8,8,0,0,1,0-16h24V64H64V88a8,8,0,0,1-16,0V56a8,8,0,0,1,8-8H200A8,8,0,0,1,208,56Z',\n sticky:\n 'M88,96a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H96A8,8,0,0,1,88,96Zm8,40h64a8,8,0,0,0,0-16H96a8,8,0,0,0,0,16Zm32,16H96a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16ZM224,48V156.69A15.86,15.86,0,0,1,219.31,168L168,219.31A15.86,15.86,0,0,1,156.69,224H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48ZM48,208H152V160a8,8,0,0,1,8-8h48V48H48Zm120-40v28.7L196.69,168Z',\n undo: 'M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L44.59,96H72a8,8,0,0,1,0,16H24a8,8,0,0,1-8-8V56a8,8,0,0,1,16,0V85.8L60.25,60A96,96,0,0,1,224,128Z',\n redo: 'M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z',\n duplicate:\n 'M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z',\n delete:\n 'M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z',\n grid: 'M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,80H136V56h64ZM120,56v64H56V56ZM56,136h64v64H56Zm144,64H136V136h64v64Z',\n};\n\nconst TOOL_BUTTONS = [\n { tool: 'select', label: 'Select' },\n { tool: 'hand', label: 'Pan' },\n { tool: 'draw', label: 'Brush' },\n { tool: 'eraser', label: 'Eraser' },\n { tool: 'rectangle', label: 'Rectangle' },\n { tool: 'ellipse', label: 'Ellipse' },\n { tool: 'line', label: 'Arrow' },\n { tool: 'text', label: 'Text' },\n { tool: 'sticky', label: 'Sticky note' },\n];\nconst ACTION_BUTTONS = [\n { action: 'undo', label: 'Undo' },\n { action: 'redo', label: 'Redo' },\n { action: 'duplicate', label: 'Duplicate' },\n { action: 'delete', label: 'Delete / clear' },\n];\n\nconst BRUSH_ORDER = ['pen', 'pencil', 'marker', 'highlighter', 'calligraphy'];\nconst BRUSH_LABELS = {\n pen: 'Pen',\n pencil: 'Pencil',\n marker: 'Marker',\n highlighter: 'Highlighter',\n calligraphy: 'Calligraphy',\n};\nconst SWATCHES = [\n '#1f2720',\n '#495057',\n '#e03131',\n '#f08c00',\n '#f2c200',\n '#2f9e44',\n '#1971c2',\n '#7048e8',\n '#e64980',\n '#ffffff',\n];\n\nfunction createSvgEl(name, attrs) {\n const el = document.createElementNS(SVG_NS, name);\n if (attrs) for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, String(v));\n return el;\n}\n\nfunction createIcon(name) {\n const svg = createSvgEl('svg', {\n viewBox: '0 0 256 256',\n 'aria-hidden': 'true',\n focusable: 'false',\n });\n svg.classList.add('vd-draw-icon');\n svg.setAttribute('fill', 'currentColor');\n svg.appendChild(createSvgEl('path', { d: ICON_PATHS[name] || '' }));\n return svg;\n}\n\nfunction clearChildren(node) {\n if (node) node.replaceChildren();\n}\n\nfunction hasWindow() {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n\n// Normalize a color to 6-digit hex for the native <input type=color>, which\n// only accepts that form. Expands #rgb \u2192 #rrggbb; returns null for rgb()/named\n// colors (the picker keeps its prior value while the mark still uses the color).\nfunction toHex6(color) {\n if (typeof color !== 'string') return null;\n const value = color.trim();\n if (/^#[0-9a-fA-F]{6}$/.test(value)) return value.toLowerCase();\n const short = /^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(value);\n if (short)\n return `#${short[1]}${short[1]}${short[2]}${short[2]}${short[3]}${short[3]}`.toLowerCase();\n return null;\n}\n\nexport class VdDraw {\n constructor(options = {}) {\n const opts = options || {};\n this.element = this._resolveElement(opts.element ?? opts.target);\n if (!this.element) throw new Error('VdDraw: a target `element` is required');\n\n this.readonly = Boolean(opts.readonly);\n this.tool = DRAW_TOOLS.includes(opts.tool) ? opts.tool : 'draw';\n this.gridSize = Number.isFinite(opts.gridSize) ? opts.gridSize : DEFAULT_GRID_SIZE;\n this.showGrid = opts.showGrid == null ? true : Boolean(opts.showGrid);\n this.snap = opts.snap == null ? true : Boolean(opts.snap);\n this.autoFit = Boolean(opts.autoFit);\n this.historyEnabled = opts.history == null ? true : Boolean(opts.history);\n this.historyLimit = Number.isFinite(opts.historyLimit) ? opts.historyLimit : 100;\n\n this.style = {\n color: typeof opts.color === 'string' ? opts.color : '#1f2720',\n opacity: Number.isFinite(opts.opacity) ? clamp(opts.opacity, 0.05, 1) : 1,\n size: Number.isFinite(opts.brushSize) ? opts.brushSize : BRUSH_PRESETS[DEFAULT_BRUSH].size,\n brush: BRUSH_PRESETS[opts.brush] ? opts.brush : DEFAULT_BRUSH,\n };\n this.recentColors = [];\n\n this.documentData = normalizeDocument(opts.data);\n this.selectedIds = new Set();\n this.interaction = null;\n this.clipboard = [];\n this.textEditor = null;\n this.destroyed = false;\n\n this.history = [];\n this.historyIndex = -1;\n this.isApplyingHistory = false;\n this.lastReason = null;\n this.lastTargetKey = null;\n\n this.listeners = new Map();\n\n this._buildShell();\n if (typeof opts.color !== 'string') this.style.color = this._resolveInk();\n this._bindEvents();\n this._resetHistory();\n this.render();\n this._syncStylePanel();\n this._scheduleReady();\n }\n\n _resolveElement(target) {\n if (!target) return null;\n if (typeof target === 'string') return hasWindow() ? document.querySelector(target) : null;\n return target;\n }\n\n _resolveInk() {\n if (!hasWindow()) return '#1f2720';\n try {\n const v = getComputedStyle(this.svg).getPropertyValue('--vd-draw-ink').trim();\n return v || '#1f2720';\n } catch {\n return '#1f2720';\n }\n }\n\n // \u2500\u2500 Shell \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _buildShell() {\n const host = this.element;\n host.classList.add('vd-draw-host');\n clearChildren(host);\n\n const shell = document.createElement('div');\n shell.className = 'vd-draw-shell';\n\n this.toolbarEl = document.createElement('div');\n this.toolbarEl.className = 'vd-draw-toolbar';\n this.toolbarEl.setAttribute('role', 'toolbar');\n this.toolbarEl.setAttribute('aria-label', 'Drawing tools');\n\n this.panelEl = document.createElement('div');\n this.panelEl.className = 'vd-draw-panel';\n if (!this.readonly) {\n this._buildToolbar();\n this._buildStylePanel();\n }\n\n this.canvasEl = document.createElement('div');\n this.canvasEl.className = 'vd-draw-canvas';\n this.canvasEl.tabIndex = 0;\n\n this.svg = createSvgEl('svg', { class: 'vd-draw-svg' });\n this.svg.setAttribute('width', '100%');\n this.svg.setAttribute('height', '100%');\n\n const defs = createSvgEl('defs');\n const gs = this.gridSize;\n this.gridPattern = createSvgEl('pattern', {\n id: this._svgId('grid'),\n width: gs,\n height: gs,\n patternUnits: 'userSpaceOnUse',\n });\n this.gridPatternPath = createSvgEl('path', {\n d: `M ${gs} 0 L 0 0 0 ${gs}`,\n fill: 'none',\n stroke: 'var(--vd-draw-grid)',\n 'stroke-width': 1,\n });\n this.gridPattern.appendChild(this.gridPatternPath);\n defs.appendChild(this.gridPattern);\n const marker = createSvgEl('marker', {\n id: this._svgId('arrow'),\n viewBox: '0 0 10 10',\n refX: 8,\n refY: 5,\n markerWidth: 7,\n markerHeight: 7,\n orient: 'auto-start-reverse',\n });\n marker.appendChild(\n createSvgEl('path', { d: 'M 0 0 L 10 5 L 0 10 z', fill: 'var(--vd-draw-shape-stroke)' }),\n );\n defs.appendChild(marker);\n this.svg.appendChild(defs);\n\n this.world = createSvgEl('g', { class: 'vd-draw-world' });\n this.gridLayer = createSvgEl('rect', {\n class: 'vd-draw-grid-rect',\n x: -WORLD_EXTENT,\n y: -WORLD_EXTENT,\n width: WORLD_EXTENT * 2,\n height: WORLD_EXTENT * 2,\n fill: `url(#${this._svgId('grid')})`,\n });\n if (!this.showGrid) this.gridLayer.style.display = 'none';\n this.shapesLayer = createSvgEl('g', { class: 'vd-draw-shapes' });\n this.guidesLayer = createSvgEl('g', { class: 'vd-draw-guides' });\n this.overlayLayer = createSvgEl('g', { class: 'vd-draw-overlay' });\n this.marqueeLayer = createSvgEl('g', { class: 'vd-draw-marquee' });\n this.world.append(\n this.gridLayer,\n this.shapesLayer,\n this.guidesLayer,\n this.overlayLayer,\n this.marqueeLayer,\n );\n this.svg.appendChild(this.world);\n\n this.canvasEl.appendChild(this.svg);\n this.textLayer = document.createElement('div');\n this.textLayer.className = 'vd-draw-text-layer';\n this.canvasEl.appendChild(this.textLayer);\n\n shell.append(this.toolbarEl, this.panelEl, this.canvasEl);\n host.appendChild(shell);\n }\n\n _buildToolbar() {\n clearChildren(this.toolbarEl);\n const makeBtn = (name, label, attr, value, active) => {\n const btn = document.createElement('button');\n btn.type = 'button';\n btn.className = 'vd-draw-tool';\n btn.setAttribute(attr, value);\n btn.setAttribute('aria-label', label);\n btn.setAttribute('title', label);\n if (active) btn.setAttribute('aria-pressed', 'true');\n btn.appendChild(createIcon(name));\n return btn;\n };\n const tools = document.createElement('div');\n tools.className = 'vd-draw-toolbar-group';\n for (const t of TOOL_BUTTONS)\n tools.appendChild(makeBtn(t.tool, t.label, 'data-tool', t.tool, t.tool === this.tool));\n const actions = document.createElement('div');\n actions.className = 'vd-draw-toolbar-group';\n for (const a of ACTION_BUTTONS)\n actions.appendChild(makeBtn(a.action, a.label, 'data-action', a.action, false));\n this.toolbarEl.append(tools, actions);\n }\n\n _panelGroup(labelText, className = '') {\n const group = document.createElement('div');\n group.className = `vd-draw-panel-group${className ? ` ${className}` : ''}`;\n const label = document.createElement('span');\n label.className = 'vd-draw-panel-label';\n label.textContent = labelText;\n group.appendChild(label);\n return group;\n }\n\n _rangeInput(min, max, step, styleKey) {\n const input = document.createElement('input');\n input.type = 'range';\n input.min = String(min);\n input.max = String(max);\n input.step = String(step);\n input.setAttribute('data-style', styleKey);\n input.setAttribute('aria-label', styleKey);\n return input;\n }\n\n _buildStylePanel() {\n clearChildren(this.panelEl);\n\n // Brush presets\n const brushGroup = this._panelGroup('Brush');\n for (const key of BRUSH_ORDER) {\n const btn = document.createElement('button');\n btn.type = 'button';\n btn.className = 'vd-draw-brush';\n btn.setAttribute('data-brush', key);\n btn.setAttribute('title', BRUSH_LABELS[key]);\n btn.textContent = BRUSH_LABELS[key];\n brushGroup.appendChild(btn);\n }\n\n // Color\n const colorGroup = this._panelGroup('Color', 'vd-draw-swatches-group');\n for (const color of SWATCHES) {\n const sw = document.createElement('button');\n sw.type = 'button';\n sw.className = 'vd-draw-swatch';\n sw.setAttribute('data-swatch', color);\n sw.setAttribute('aria-label', `Color ${color}`);\n sw.setAttribute('title', color);\n sw.style.setProperty('--sw', color);\n colorGroup.appendChild(sw);\n }\n this.colorInput = document.createElement('input');\n this.colorInput.type = 'color';\n this.colorInput.className = 'vd-draw-color-input';\n this.colorInput.setAttribute('data-style', 'color');\n this.colorInput.setAttribute('aria-label', 'Custom color');\n this.colorInput.setAttribute('title', 'Custom color');\n colorGroup.appendChild(this.colorInput);\n\n // Size\n const sizeGroup = this._panelGroup('Size');\n this.sizeInput = this._rangeInput(1, 40, 1, 'size');\n this.sizeValue = document.createElement('span');\n this.sizeValue.className = 'vd-draw-value';\n sizeGroup.append(this.sizeInput, this.sizeValue);\n\n // Opacity\n const opacityGroup = this._panelGroup('Opacity');\n this.opacityInput = this._rangeInput(0.1, 1, 0.05, 'opacity');\n this.opacityValue = document.createElement('span');\n this.opacityValue.className = 'vd-draw-value';\n opacityGroup.append(this.opacityInput, this.opacityValue);\n\n // Grid\n const gridGroup = this._panelGroup('Grid');\n this.gridToggle = document.createElement('button');\n this.gridToggle.type = 'button';\n this.gridToggle.className = 'vd-draw-tool';\n this.gridToggle.setAttribute('data-grid', 'toggle');\n this.gridToggle.setAttribute('aria-label', 'Toggle grid');\n this.gridToggle.setAttribute('title', 'Toggle grid');\n this.gridToggle.appendChild(createIcon('grid'));\n this.gridSizeInput = this._rangeInput(4, 128, 4, 'grid');\n this.gridSizeInput.title = 'Grid cell size';\n gridGroup.append(this.gridToggle, this.gridSizeInput);\n\n // Recent colors (hidden until used)\n this.recentGroup = this._panelGroup('Recent', 'vd-draw-swatches-group');\n this.recentEl = document.createElement('span');\n this.recentEl.className = 'vd-draw-recent';\n this.recentGroup.appendChild(this.recentEl);\n\n this.panelEl.append(\n brushGroup,\n colorGroup,\n sizeGroup,\n opacityGroup,\n gridGroup,\n this.recentGroup,\n );\n }\n\n _svgId(suffix) {\n if (!this._idBase) this._idBase = createId('draw');\n return `${this._idBase}-${suffix}`;\n }\n\n _syncToolbar() {\n if (this.readonly || !this.toolbarEl) return;\n for (const btn of this.toolbarEl.querySelectorAll('[data-tool]')) {\n if (btn.getAttribute('data-tool') === this.tool) btn.setAttribute('aria-pressed', 'true');\n else btn.removeAttribute('aria-pressed');\n }\n }\n\n _syncStylePanel() {\n if (this.readonly || !this.panelEl) return;\n for (const btn of this.panelEl.querySelectorAll('[data-brush]')) {\n if (btn.getAttribute('data-brush') === this.style.brush)\n btn.setAttribute('aria-pressed', 'true');\n else btn.removeAttribute('aria-pressed');\n }\n if (this.colorInput) {\n const hex = toHex6(this.style.color);\n if (hex) this.colorInput.value = hex;\n }\n if (this.sizeInput) this.sizeInput.value = String(this.style.size);\n if (this.sizeValue) this.sizeValue.textContent = `${Math.round(this.style.size)}px`;\n if (this.opacityInput) this.opacityInput.value = String(this.style.opacity);\n if (this.opacityValue)\n this.opacityValue.textContent = `${Math.round(this.style.opacity * 100)}%`;\n if (this.gridToggle) {\n if (this.showGrid) this.gridToggle.setAttribute('aria-pressed', 'true');\n else this.gridToggle.removeAttribute('aria-pressed');\n }\n if (this.gridSizeInput) this.gridSizeInput.value = String(this.gridSize);\n for (const sw of this.panelEl.querySelectorAll('.vd-draw-swatch[data-swatch]')) {\n if (sw.getAttribute('data-swatch') === this.style.color)\n sw.setAttribute('aria-pressed', 'true');\n else sw.removeAttribute('aria-pressed');\n }\n if (this.recentEl && this.recentGroup) {\n clearChildren(this.recentEl);\n for (const color of this.recentColors) {\n const sw = document.createElement('button');\n sw.type = 'button';\n sw.className = 'vd-draw-swatch';\n sw.setAttribute('data-swatch', color);\n sw.setAttribute('aria-label', `Recent color ${color}`);\n sw.setAttribute('title', color);\n sw.style.setProperty('--sw', color);\n this.recentEl.appendChild(sw);\n }\n this.recentGroup.style.display = this.recentColors.length ? '' : 'none';\n }\n }\n\n // \u2500\u2500 Events \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _bindEvents() {\n this._onPointerDown = this._handlePointerDown.bind(this);\n this._onPointerMove = this._handlePointerMove.bind(this);\n this._onPointerUp = this._handlePointerUp.bind(this);\n this._onWheel = this._handleWheel.bind(this);\n this._onKeyDown = this._handleKeyDown.bind(this);\n this._onToolbarClick = this._handleToolbarClick.bind(this);\n this._onPanelClick = this._handlePanelClick.bind(this);\n this._onPanelInput = this._handlePanelInput.bind(this);\n this._onResize = this._handleResize.bind(this);\n\n this.canvasEl.addEventListener('pointerdown', this._onPointerDown);\n this.canvasEl.addEventListener('pointermove', this._onPointerMove);\n this.canvasEl.addEventListener('pointerup', this._onPointerUp);\n this.canvasEl.addEventListener('pointercancel', this._onPointerUp);\n this.canvasEl.addEventListener('wheel', this._onWheel, { passive: false });\n this.canvasEl.addEventListener('keydown', this._onKeyDown);\n this.toolbarEl.addEventListener('click', this._onToolbarClick);\n this.panelEl.addEventListener('click', this._onPanelClick);\n this.panelEl.addEventListener('input', this._onPanelInput);\n window.addEventListener('pointerup', this._onPointerUp);\n window.addEventListener('resize', this._onResize);\n }\n\n _unbindEvents() {\n this.canvasEl.removeEventListener('pointerdown', this._onPointerDown);\n this.canvasEl.removeEventListener('pointermove', this._onPointerMove);\n this.canvasEl.removeEventListener('pointerup', this._onPointerUp);\n this.canvasEl.removeEventListener('pointercancel', this._onPointerUp);\n this.canvasEl.removeEventListener('wheel', this._onWheel);\n this.canvasEl.removeEventListener('keydown', this._onKeyDown);\n this.toolbarEl.removeEventListener('click', this._onToolbarClick);\n this.panelEl.removeEventListener('click', this._onPanelClick);\n this.panelEl.removeEventListener('input', this._onPanelInput);\n window.removeEventListener('pointerup', this._onPointerUp);\n window.removeEventListener('resize', this._onResize);\n }\n\n on(event, callback) {\n if (!this.listeners.has(event)) this.listeners.set(event, new Set());\n this.listeners.get(event).add(callback);\n return this;\n }\n\n off(event, callback) {\n this.listeners.get(event)?.delete(callback);\n return this;\n }\n\n emit(event, payload) {\n const set = this.listeners.get(event);\n if (set) for (const cb of set) cb(payload);\n }\n\n // \u2500\u2500 Coordinate transforms \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _clientToLocal(clientX, clientY) {\n const rect = this.canvasEl.getBoundingClientRect();\n return { x: clientX - rect.left, y: clientY - rect.top };\n }\n\n _localToWorld(lx, ly) {\n const vp = this.documentData.viewport;\n return { x: (lx - vp.x) / vp.scale, y: (ly - vp.y) / vp.scale };\n }\n\n _clientToWorld(clientX, clientY) {\n const local = this._clientToLocal(clientX, clientY);\n return this._localToWorld(local.x, local.y);\n }\n\n scaleAround(factor, lx, ly) {\n const vp = this.documentData.viewport;\n const next = clamp(vp.scale * factor, MIN_SCALE, MAX_SCALE);\n const applied = next / vp.scale;\n vp.x = lx - (lx - vp.x) * applied;\n vp.y = ly - (ly - vp.y) * applied;\n vp.scale = next;\n return this;\n }\n\n // \u2500\u2500 Viewport \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n setViewport(patch) {\n const vp = this.documentData.viewport;\n if (patch && typeof patch === 'object') {\n if (Number.isFinite(patch.x)) vp.x = patch.x;\n if (Number.isFinite(patch.y)) vp.y = patch.y;\n if (Number.isFinite(patch.scale)) vp.scale = clamp(patch.scale, MIN_SCALE, MAX_SCALE);\n }\n this.render({ scene: false });\n this._emitViewportChange('viewport:set');\n return this;\n }\n\n zoomIn() {\n return this._zoomAtCentre(1.2);\n }\n\n zoomOut() {\n return this._zoomAtCentre(1 / 1.2);\n }\n\n _zoomAtCentre(factor) {\n const rect = this.canvasEl.getBoundingClientRect();\n this.scaleAround(factor, rect.width / 2, rect.height / 2);\n this.render({ scene: false });\n this._emitViewportChange('viewport:zoom');\n return this;\n }\n\n resetView() {\n this.documentData.viewport = { x: 0, y: 0, scale: 1 };\n this.render({ scene: false });\n this._emitViewportChange('viewport:reset');\n return this;\n }\n\n fitView() {\n const bounds = boundsOfShapes(this.documentData.shapes);\n const rect = this.canvasEl.getBoundingClientRect();\n if (!bounds || bounds.w === 0 || bounds.h === 0 || !rect.width || !rect.height) return this;\n const pad = 40;\n const scale = clamp(\n Math.min((rect.width - pad * 2) / bounds.w, (rect.height - pad * 2) / bounds.h),\n MIN_SCALE,\n MAX_SCALE,\n );\n const vp = this.documentData.viewport;\n vp.scale = scale;\n vp.x = (rect.width - bounds.w * scale) / 2 - bounds.x * scale;\n vp.y = (rect.height - bounds.h * scale) / 2 - bounds.y * scale;\n this.render({ scene: false });\n this._emitViewportChange('viewport:fit');\n return this;\n }\n\n _emitViewportChange(reason) {\n this.emit('viewport', {\n reason,\n viewport: { ...this.documentData.viewport },\n document: this.toJSON(),\n });\n }\n\n // \u2500\u2500 Grid \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n setGridSize(size) {\n if (!Number.isFinite(size)) return this;\n this.gridSize = clamp(Math.round(size), 4, 128);\n if (this.gridPattern) {\n this.gridPattern.setAttribute('width', String(this.gridSize));\n this.gridPattern.setAttribute('height', String(this.gridSize));\n this.gridPatternPath.setAttribute('d', `M ${this.gridSize} 0 L 0 0 0 ${this.gridSize}`);\n }\n this._syncStylePanel();\n return this;\n }\n\n setGridVisible(visible) {\n this.showGrid = Boolean(visible);\n if (this.gridLayer) this.gridLayer.style.display = this.showGrid ? '' : 'none';\n this._syncStylePanel();\n return this;\n }\n\n toggleGrid() {\n return this.setGridVisible(!this.showGrid);\n }\n\n // \u2500\u2500 Tool + current style \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n setTool(tool) {\n if (!DRAW_TOOLS.includes(tool)) return this;\n this.tool = tool;\n this._syncToolbar();\n return this;\n }\n\n setColor(color) {\n if (typeof color !== 'string') return this;\n this.style.color = color;\n this._pushRecent(color);\n this._syncStylePanel();\n return this;\n }\n\n setOpacity(opacity) {\n if (Number.isFinite(opacity)) this.style.opacity = clamp(opacity, 0.05, 1);\n this._syncStylePanel();\n return this;\n }\n\n setBrushSize(size) {\n if (Number.isFinite(size)) this.style.size = clamp(size, 1, 200);\n this._syncStylePanel();\n return this;\n }\n\n setBrush(brush) {\n if (BRUSH_PRESETS[brush]) this.style.brush = brush;\n this._syncStylePanel();\n return this;\n }\n\n _pushRecent(color) {\n this.recentColors = [color, ...this.recentColors.filter((c) => c !== color)].slice(0, 8);\n }\n\n _shapeStrokeWidth() {\n return clamp(round(this.style.size / 3), 1, 14);\n }\n\n // \u2500\u2500 Shape CRUD \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n getShape(id) {\n return this.documentData.shapes.find((s) => s.id === id) || null;\n }\n\n addShape(partial = {}) {\n const type = DRAW_SHAPE_TYPES.includes(partial.type) ? partial.type : 'rectangle';\n const s = this.style;\n let shape;\n if (type === 'freehand') {\n const points = Array.isArray(partial.points)\n ? partial.points.map((p) => this._roundPoint(p))\n : [];\n shape = {\n id: partial.id || createId('fh'),\n type: 'freehand',\n brush: BRUSH_PRESETS[partial.brush] ? partial.brush : s.brush,\n color: partial.color || s.color,\n size: partial.size == null ? s.size : partial.size,\n opacity: partial.opacity == null ? s.opacity : partial.opacity,\n points,\n };\n } else if (type === 'line') {\n const points = Array.isArray(partial.points)\n ? partial.points.map(([x, y]) => [round(x), round(y)])\n : [];\n shape = {\n id: partial.id || createId('ln'),\n type: 'line',\n points,\n color: partial.color || s.color,\n strokeWidth: partial.strokeWidth == null ? this._shapeStrokeWidth() : partial.strokeWidth,\n opacity: partial.opacity == null ? s.opacity : partial.opacity,\n arrowStart: Boolean(partial.arrowStart),\n arrowEnd: partial.arrowEnd == null ? true : Boolean(partial.arrowEnd),\n };\n } else {\n shape = {\n id: partial.id || createId(type.slice(0, 2)),\n type,\n x: round(partial.x ?? 0),\n y: round(partial.y ?? 0),\n w: round(Math.max(1, partial.w ?? 100)),\n h: round(Math.max(1, partial.h ?? 80)),\n rotation: partial.rotation ?? 0,\n color: partial.color || s.color,\n strokeWidth: partial.strokeWidth == null ? this._shapeStrokeWidth() : partial.strokeWidth,\n opacity: partial.opacity == null ? s.opacity : partial.opacity,\n };\n if (partial.fill) shape.fill = partial.fill;\n if (type === 'text' || type === 'sticky')\n shape.text = typeof partial.text === 'string' ? partial.text : '';\n }\n this.documentData.shapes.push(shape);\n this.render();\n this._emitChange('shape:add', { shape: deepClone(shape), shapeId: shape.id });\n return shape;\n }\n\n _roundPoint(p) {\n const out = [round(p[0]), round(p[1])];\n if (p.length >= 3 && p[2] != null) out.push(clamp(Number(p[2]) || 0, 0, 1));\n return out;\n }\n\n updateShape(id, patch, options = {}) {\n const shape = this.getShape(id);\n if (!shape || !patch) return null;\n Object.assign(shape, patch);\n this.render();\n this._emitChange(options.reason || 'shape:update', { shapeId: id }, options.reason ? id : null);\n return shape;\n }\n\n removeShape(id) {\n const idx = this.documentData.shapes.findIndex((s) => s.id === id);\n if (idx === -1) return false;\n this.documentData.shapes.splice(idx, 1);\n this.selectedIds.delete(id);\n this.render();\n this._emitChange('shape:delete', { shapeId: id });\n return true;\n }\n\n // \u2500\u2500 Selection \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n getSelectedShapes() {\n return this.documentData.shapes.filter((s) => this.selectedIds.has(s.id));\n }\n\n select(ids, { additive = false } = {}) {\n const list = Array.isArray(ids) ? ids : ids == null ? [] : [ids];\n if (!additive) this.selectedIds.clear();\n for (const id of list) {\n const shape = this.getShape(id);\n if (shape?.groupId) {\n for (const s of this.documentData.shapes)\n if (s.groupId === shape.groupId) this.selectedIds.add(s.id);\n } else if (shape) {\n this.selectedIds.add(id);\n }\n }\n this.render({ scene: false });\n this._emitSelect();\n return this;\n }\n\n selectAll() {\n this.selectedIds = new Set(this.documentData.shapes.map((s) => s.id));\n this.render({ scene: false });\n this._emitSelect();\n return this;\n }\n\n deselect() {\n if (this.selectedIds.size === 0) return this;\n this.selectedIds.clear();\n this.render({ scene: false });\n this._emitSelect();\n return this;\n }\n\n selectInBounds(box, { additive = false } = {}) {\n if (!additive) this.selectedIds.clear();\n for (const shape of this.documentData.shapes) {\n if (boundsIntersect(shapeBounds(shape), box)) this.selectedIds.add(shape.id);\n }\n for (const shape of [...this.getSelectedShapes()]) {\n if (shape.groupId)\n for (const s of this.documentData.shapes)\n if (s.groupId === shape.groupId) this.selectedIds.add(s.id);\n }\n this.render({ scene: false });\n this._emitSelect();\n return this;\n }\n\n _emitSelect() {\n this.emit('select', {\n ids: [...this.selectedIds],\n shapes: this.getSelectedShapes().map((s) => deepClone(s)),\n });\n }\n\n _syncSelectionValidity() {\n const present = new Set(this.documentData.shapes.map((s) => s.id));\n for (const id of [...this.selectedIds]) if (!present.has(id)) this.selectedIds.delete(id);\n }\n\n // \u2500\u2500 Manipulation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _replaceShape(next) {\n const idx = this.documentData.shapes.findIndex((s) => s.id === next.id);\n if (idx !== -1) this.documentData.shapes[idx] = next;\n }\n\n nudge(dx, dy) {\n const selected = this.getSelectedShapes();\n if (!selected.length) return this;\n for (const shape of selected) this._replaceShape(translateShape(shape, dx, dy));\n this.render();\n this._emitChange(\n 'shape:nudge',\n { shapeIds: [...this.selectedIds] },\n `nudge:${[...this.selectedIds].sort().join(',')}`,\n );\n return this;\n }\n\n setSelectionBounds(target) {\n const selected = this.getSelectedShapes();\n const cur = boundsOfShapes(selected);\n if (!cur || cur.w === 0 || cur.h === 0 || !target) return this;\n const sx = target.w / cur.w;\n const sy = target.h / cur.h;\n for (const shape of selected) {\n const scaled = scaleShape(shape, cur.x, cur.y, sx, sy);\n this._replaceShape(translateShape(scaled, target.x - cur.x, target.y - cur.y));\n }\n this.render();\n this._emitChange('shape:resize', { shapeIds: [...this.selectedIds] });\n return this;\n }\n\n deleteSelection() {\n if (this.selectedIds.size === 0) return false;\n const ids = [...this.selectedIds];\n this.documentData.shapes = this.documentData.shapes.filter((s) => !this.selectedIds.has(s.id));\n this.selectedIds.clear();\n this.render();\n this._emitChange('shape:delete', { shapeIds: ids });\n return true;\n }\n\n setStyle(patch) {\n const selected = this.getSelectedShapes();\n if (!selected.length || !patch) return this;\n const allowed = ['color', 'fill', 'strokeWidth', 'opacity', 'size', 'brush'];\n for (const shape of selected) {\n for (const key of allowed) if (key in patch) shape[key] = patch[key];\n }\n this.render();\n this._emitChange(\n 'shape:style',\n { shapeIds: [...this.selectedIds] },\n `style:${[...this.selectedIds].sort().join(',')}`,\n );\n return this;\n }\n\n // \u2500\u2500 Z-order \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _reorder(mutator) {\n if (this.selectedIds.size === 0) return this;\n mutator();\n this.render();\n this._emitChange('shape:reorder', { shapeIds: [...this.selectedIds] });\n return this;\n }\n\n bringToFront() {\n return this._reorder(() => {\n const sel = this.documentData.shapes.filter((s) => this.selectedIds.has(s.id));\n const rest = this.documentData.shapes.filter((s) => !this.selectedIds.has(s.id));\n this.documentData.shapes = [...rest, ...sel];\n });\n }\n\n sendToBack() {\n return this._reorder(() => {\n const sel = this.documentData.shapes.filter((s) => this.selectedIds.has(s.id));\n const rest = this.documentData.shapes.filter((s) => !this.selectedIds.has(s.id));\n this.documentData.shapes = [...sel, ...rest];\n });\n }\n\n bringForward() {\n return this._reorder(() => {\n const arr = this.documentData.shapes;\n for (let i = arr.length - 2; i >= 0; i -= 1) {\n if (this.selectedIds.has(arr[i].id) && !this.selectedIds.has(arr[i + 1].id))\n [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]];\n }\n });\n }\n\n sendBackward() {\n return this._reorder(() => {\n const arr = this.documentData.shapes;\n for (let i = 1; i < arr.length; i += 1) {\n if (this.selectedIds.has(arr[i].id) && !this.selectedIds.has(arr[i - 1].id))\n [arr[i], arr[i - 1]] = [arr[i - 1], arr[i]];\n }\n });\n }\n\n // \u2500\u2500 Grouping \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n group() {\n const selected = this.getSelectedShapes();\n if (selected.length < 2) return this;\n const groupId = createId('grp');\n for (const shape of selected) shape.groupId = groupId;\n this.render();\n this._emitChange('shape:group', { groupId, shapeIds: [...this.selectedIds] });\n return this;\n }\n\n ungroup() {\n const selected = this.getSelectedShapes();\n let changed = false;\n for (const shape of selected) {\n if (shape.groupId) {\n delete shape.groupId;\n changed = true;\n }\n }\n if (!changed) return this;\n this.render();\n this._emitChange('shape:ungroup', { shapeIds: [...this.selectedIds] });\n return this;\n }\n\n // \u2500\u2500 Clipboard \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n copy() {\n this.clipboard = this.getSelectedShapes().map((s) => deepClone(s));\n return this;\n }\n\n cut() {\n this.copy();\n this.deleteSelection();\n return this;\n }\n\n paste({ offset = 16 } = {}) {\n if (!this.clipboard.length) return this;\n const groupRemap = new Map();\n const newIds = [];\n for (const src of this.clipboard) {\n const copy = translateShape(deepClone(src), offset, offset);\n copy.id = createId(copy.type.slice(0, 2));\n if (copy.groupId) {\n if (!groupRemap.has(copy.groupId)) groupRemap.set(copy.groupId, createId('grp'));\n copy.groupId = groupRemap.get(copy.groupId);\n }\n this.documentData.shapes.push(copy);\n newIds.push(copy.id);\n }\n this.selectedIds = new Set(newIds);\n this.render();\n this._emitChange('shape:paste', { shapeIds: newIds });\n this._emitSelect();\n return this;\n }\n\n duplicate() {\n this.copy();\n this.paste();\n return this;\n }\n\n // \u2500\u2500 Snapping \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _computeSnap(movingBounds, movingIds) {\n if (!this.snap) return { dx: 0, dy: 0, guides: [] };\n const threshold = SNAP_THRESHOLD / this.documentData.viewport.scale;\n const targetsX = [\n movingBounds.x,\n movingBounds.x + movingBounds.w / 2,\n movingBounds.x + movingBounds.w,\n ];\n const targetsY = [\n movingBounds.y,\n movingBounds.y + movingBounds.h / 2,\n movingBounds.y + movingBounds.h,\n ];\n let bestX = null;\n let bestY = null;\n const guides = [];\n for (const other of this.documentData.shapes) {\n if (movingIds.has(other.id)) continue;\n const b = shapeBounds(other);\n for (const t of targetsX)\n for (const l of [b.x, b.x + b.w / 2, b.x + b.w]) {\n const d = l - t;\n if (Math.abs(d) <= threshold && (!bestX || Math.abs(d) < Math.abs(bestX.d)))\n bestX = { d, at: l };\n }\n for (const t of targetsY)\n for (const l of [b.y, b.y + b.h / 2, b.y + b.h]) {\n const d = l - t;\n if (Math.abs(d) <= threshold && (!bestY || Math.abs(d) < Math.abs(bestY.d)))\n bestY = { d, at: l };\n }\n }\n if (bestX) guides.push({ x1: bestX.at, y1: -WORLD_EXTENT, x2: bestX.at, y2: WORLD_EXTENT });\n if (bestY) guides.push({ x1: -WORLD_EXTENT, y1: bestY.at, x2: WORLD_EXTENT, y2: bestY.at });\n return { dx: bestX ? bestX.d : 0, dy: bestY ? bestY.d : 0, guides };\n }\n\n // \u2500\u2500 Export \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _resolvedColors() {\n const cs = hasWindow() ? getComputedStyle(this.svg) : null;\n const read = (name, fallback) => {\n const v = cs?.getPropertyValue(name)?.trim();\n return v || fallback;\n };\n return {\n ink: read('--vd-draw-ink', '#1f2720'),\n shapeStroke: read('--vd-draw-shape-stroke', '#245f52'),\n text: read('--vd-draw-text', '#1f2720'),\n sticky: read('--vd-draw-sticky-fill', '#fdf3c4'),\n };\n }\n\n toSVG() {\n const shapes = this.documentData.shapes;\n const bounds = boundsOfShapes(shapes) || { x: 0, y: 0, w: 100, h: 100 };\n const pad = 20;\n const vb = {\n x: bounds.x - pad,\n y: bounds.y - pad,\n w: Math.max(1, bounds.w) + pad * 2,\n h: Math.max(1, bounds.h) + pad * 2,\n };\n const colors = this._resolvedColors();\n const svg = createSvgEl('svg', {\n xmlns: SVG_NS,\n width: round(vb.w),\n height: round(vb.h),\n viewBox: `${round(vb.x)} ${round(vb.y)} ${round(vb.w)} ${round(vb.h)}`,\n });\n for (const shape of shapes) {\n const el = this._renderShapeEl(shape, { standalone: true, colors });\n if (el) svg.appendChild(el);\n }\n return new XMLSerializer().serializeToString(svg);\n }\n\n toPNG({ scale = 2 } = {}) {\n const markup = this.toSVG();\n const bounds = boundsOfShapes(this.documentData.shapes) || { w: 100, h: 100 };\n const pad = 20;\n const w = Math.max(1, (bounds.w || 100) + pad * 2);\n const h = Math.max(1, (bounds.h || 100) + pad * 2);\n return new Promise((resolve, reject) => {\n try {\n const img = new Image();\n const url = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`;\n img.onload = () => {\n const canvas = document.createElement('canvas');\n canvas.width = Math.ceil(w * scale);\n canvas.height = Math.ceil(h * scale);\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n reject(new Error('VdDraw: 2D canvas context unavailable'));\n return;\n }\n ctx.drawImage(img, 0, 0, canvas.width, canvas.height);\n resolve(canvas.toDataURL('image/png'));\n };\n img.onerror = () => reject(new Error('VdDraw: failed to rasterize SVG'));\n img.src = url;\n } catch (err) {\n reject(err);\n }\n });\n }\n\n // \u2500\u2500 History \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _resetHistory() {\n this.history = [this.toJSON()];\n this.historyIndex = 0;\n this.lastReason = null;\n this.lastTargetKey = null;\n }\n\n _recordHistory(reason, targetKey) {\n if (!this.historyEnabled || this.isApplyingHistory) return;\n const snapshot = this.toJSON();\n const coalesce =\n COALESCE_REASONS.has(reason) &&\n reason === this.lastReason &&\n targetKey != null &&\n targetKey === this.lastTargetKey &&\n this.historyIndex >= 0 &&\n // Only coalesce onto the TOP of the stack. Without this guard a\n // coalescing edit made right after an undo overwrites an earlier\n // (non-top) snapshot, corrupting the redo branch and losing base state.\n // Mirrors the flowchart core's canCoalesce guard.\n this.historyIndex === this.history.length - 1;\n if (coalesce) {\n this.history[this.historyIndex] = snapshot;\n } else {\n this.history = this.history.slice(0, this.historyIndex + 1);\n this.history.push(snapshot);\n this.historyIndex = this.history.length - 1;\n if (this.history.length > this.historyLimit + 1) {\n this.history.shift();\n this.historyIndex -= 1;\n }\n }\n this.lastReason = reason;\n this.lastTargetKey = targetKey ?? null;\n }\n\n _emitChange(reason, extra = {}, targetKey = null) {\n this._recordHistory(reason, targetKey);\n this._syncSelectionValidity();\n this.emit('change', { reason, document: this.toJSON(), ...extra });\n }\n\n canUndo() {\n return this.historyIndex > 0;\n }\n\n canRedo() {\n return this.historyIndex < this.history.length - 1;\n }\n\n undo() {\n if (!this.canUndo()) return this;\n this.historyIndex -= 1;\n this._applySnapshot(this.history[this.historyIndex], 'undo');\n return this;\n }\n\n redo() {\n if (!this.canRedo()) return this;\n this.historyIndex += 1;\n this._applySnapshot(this.history[this.historyIndex], 'redo');\n return this;\n }\n\n clearHistory() {\n this._resetHistory();\n this.emit('history', { reason: 'clear', canUndo: false, canRedo: false });\n return this;\n }\n\n _applySnapshot(snapshot, reason) {\n this.isApplyingHistory = true;\n const viewport = { ...this.documentData.viewport };\n this.documentData = deepClone(snapshot);\n this.documentData.viewport = viewport;\n this._syncSelectionValidity();\n this.render();\n this.emit('change', { reason, document: this.toJSON() });\n this.emit('history', { reason, canUndo: this.canUndo(), canRedo: this.canRedo() });\n this.isApplyingHistory = false;\n }\n\n // \u2500\u2500 Serialization \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n toJSON() {\n return deepClone({\n version: VD_DRAW_VERSION,\n viewport: this.documentData.viewport,\n shapes: this.documentData.shapes,\n });\n }\n\n load(data) {\n this.documentData = normalizeDocument(data);\n this.selectedIds.clear();\n this._resetHistory();\n this.render();\n this._emitChange('load');\n this._emitSelect();\n return this;\n }\n\n clear() {\n if (!this.documentData.shapes.length) return this;\n this.documentData.shapes = [];\n this.selectedIds.clear();\n this.render();\n this._emitChange('clear');\n return this;\n }\n\n // \u2500\u2500 Text editing \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n startTextEdit(id) {\n const shape = this.getShape(id);\n if (!shape || (shape.type !== 'text' && shape.type !== 'sticky') || this.readonly) return false;\n this.stopTextEdit({ commit: false });\n const editor = document.createElement('textarea');\n editor.className = 'vd-draw-text-editor';\n editor.value = shape.text || '';\n this.textEditor = { id, el: editor };\n this._positionTextEditor(shape, editor);\n this.textLayer.appendChild(editor);\n editor.focus();\n editor.addEventListener('blur', () => this.stopTextEdit({ commit: true }));\n editor.addEventListener('keydown', (e) => {\n if (e.key === 'Escape') this.stopTextEdit({ commit: false });\n });\n return true;\n }\n\n _positionTextEditor(shape, editor) {\n const vp = this.documentData.viewport;\n editor.style.left = `${vp.x + shape.x * vp.scale}px`;\n editor.style.top = `${vp.y + shape.y * vp.scale}px`;\n editor.style.width = `${shape.w * vp.scale}px`;\n editor.style.height = `${shape.h * vp.scale}px`;\n }\n\n stopTextEdit({ commit = true } = {}) {\n if (!this.textEditor) return;\n const { id, el } = this.textEditor;\n const value = el.value;\n this.textEditor = null;\n el.remove();\n if (commit) {\n const shape = this.getShape(id);\n if (shape && shape.text !== value) {\n shape.text = value;\n this.render();\n this._emitChange('shape:text', { shapeId: id }, `text:${id}`);\n }\n }\n }\n\n // \u2500\u2500 Pointer interaction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _capture(pointerId) {\n if (typeof this.canvasEl.setPointerCapture === 'function') {\n try {\n this.canvasEl.setPointerCapture(pointerId);\n } catch {\n /* jsdom / unsupported \u2014 safe to ignore */\n }\n }\n }\n\n _handleToolbarClick(event) {\n const toolBtn = event.target.closest('[data-tool]');\n if (toolBtn) {\n this.setTool(toolBtn.getAttribute('data-tool'));\n return;\n }\n const actionBtn = event.target.closest('[data-action]');\n if (!actionBtn) return;\n const action = actionBtn.getAttribute('data-action');\n if (action === 'undo') this.undo();\n else if (action === 'redo') this.redo();\n else if (action === 'duplicate') this.duplicate();\n else if (action === 'delete') {\n // Delete the selection, or clear the whole canvas when nothing is selected.\n if (this.selectedIds.size) this.deleteSelection();\n else this.clear();\n }\n }\n\n _handlePanelClick(event) {\n const brushBtn = event.target.closest('[data-brush]');\n if (brushBtn) {\n this.setBrush(brushBtn.getAttribute('data-brush'));\n if (this.tool !== 'draw') this.setTool('draw');\n return;\n }\n const gridBtn = event.target.closest('[data-grid]');\n if (gridBtn) {\n this.toggleGrid();\n return;\n }\n const swatch = event.target.closest('[data-swatch]');\n if (swatch) this.setColor(swatch.getAttribute('data-swatch'));\n }\n\n _handlePanelInput(event) {\n const kind = event.target.getAttribute?.('data-style');\n if (kind === 'color') this.setColor(event.target.value);\n else if (kind === 'size') this.setBrushSize(Number(event.target.value));\n else if (kind === 'opacity') this.setOpacity(Number(event.target.value));\n else if (kind === 'grid') this.setGridSize(Number(event.target.value));\n }\n\n _handlePointerDown(event) {\n if (this.destroyed || (event.button != null && event.button !== 0)) return;\n this.canvasEl.focus();\n this.stopTextEdit({ commit: true });\n const world = this._clientToWorld(event.clientX, event.clientY);\n const shapeTarget = event.target.closest('[data-shape-id]');\n const handleTarget = event.target.closest('[data-handle]');\n\n if (this.tool === 'hand') {\n this.interaction = this._beginPan(event);\n this._capture(event.pointerId);\n return;\n }\n\n if (this.tool === 'eraser' && !this.readonly) {\n this.interaction = { kind: 'erase', pointerId: event.pointerId, erased: new Set() };\n this._capture(event.pointerId);\n this._applyErase(world);\n return;\n }\n\n if (this.tool === 'select') {\n if (handleTarget && this.selectedIds.size) {\n this.interaction = {\n kind: 'resize',\n pointerId: event.pointerId,\n handle: handleTarget.getAttribute('data-handle'),\n startBounds: boundsOfShapes(this.getSelectedShapes()),\n originals: this.getSelectedShapes().map((s) => deepClone(s)),\n start: world,\n moved: false,\n };\n this._capture(event.pointerId);\n return;\n }\n if (shapeTarget) {\n const id = shapeTarget.getAttribute('data-shape-id');\n if (!this.selectedIds.has(id)) this.select(id, { additive: event.shiftKey });\n this.interaction = {\n kind: 'move',\n pointerId: event.pointerId,\n start: world,\n originals: this.getSelectedShapes().map((s) => deepClone(s)),\n moved: false,\n };\n this._capture(event.pointerId);\n return;\n }\n if (!event.shiftKey) this.deselect();\n this.interaction = {\n kind: 'marquee',\n pointerId: event.pointerId,\n start: world,\n additive: event.shiftKey,\n };\n this._capture(event.pointerId);\n return;\n }\n\n if (this.readonly) return;\n this.interaction = this._beginCreate(this.tool, world, event);\n this._capture(event.pointerId);\n }\n\n _beginPan(event) {\n return {\n kind: 'pan',\n pointerId: event.pointerId,\n startClientX: event.clientX,\n startClientY: event.clientY,\n startX: this.documentData.viewport.x,\n startY: this.documentData.viewport.y,\n };\n }\n\n _beginCreate(tool, world, event) {\n const pressure = event.pressure || 0.5;\n if (tool === 'draw') {\n const shape = {\n id: createId('fh'),\n type: 'freehand',\n brush: this.style.brush,\n color: this.style.color,\n size: this.style.size,\n opacity: this.style.opacity,\n points: [[round(world.x), round(world.y), pressure]],\n };\n this.documentData.shapes.push(shape);\n return { kind: 'freehand', pointerId: event.pointerId, shapeId: shape.id };\n }\n if (tool === 'line') {\n const shape = {\n id: createId('ln'),\n type: 'line',\n points: [\n [round(world.x), round(world.y)],\n [round(world.x), round(world.y)],\n ],\n arrowEnd: true,\n arrowStart: false,\n color: this.style.color,\n strokeWidth: this._shapeStrokeWidth(),\n opacity: this.style.opacity,\n };\n this.documentData.shapes.push(shape);\n return { kind: 'create-line', pointerId: event.pointerId, shapeId: shape.id };\n }\n const type = tool;\n const shape = {\n id: createId(type.slice(0, 2)),\n type,\n x: round(world.x),\n y: round(world.y),\n w: 1,\n h: 1,\n rotation: 0,\n color: this.style.color,\n strokeWidth: this._shapeStrokeWidth(),\n opacity: this.style.opacity,\n };\n if (type === 'text' || type === 'sticky') shape.text = '';\n this.documentData.shapes.push(shape);\n return { kind: 'create-box', pointerId: event.pointerId, shapeId: shape.id, start: world };\n }\n\n _applyErase(world) {\n const it = this.interaction;\n if (!it || it.kind !== 'erase') return;\n const threshold = ERASER_RADIUS / this.documentData.viewport.scale;\n let changed = false;\n for (const shape of this.documentData.shapes) {\n if (it.erased.has(shape.id)) continue;\n if (distanceToShape(shape, world.x, world.y) <= threshold) {\n it.erased.add(shape.id);\n changed = true;\n }\n }\n if (changed) this.render({ scene: true, overlay: false });\n }\n\n _handlePointerMove(event) {\n const it = this.interaction;\n if (!it) return;\n\n if (it.kind === 'pan') {\n const vp = this.documentData.viewport;\n vp.x = it.startX + (event.clientX - it.startClientX);\n vp.y = it.startY + (event.clientY - it.startClientY);\n this.render({ scene: false });\n return;\n }\n\n const world = this._clientToWorld(event.clientX, event.clientY);\n\n if (it.kind === 'erase') {\n this._applyErase(world);\n return;\n }\n\n if (it.kind === 'move') {\n const dx = world.x - it.start.x;\n const dy = world.y - it.start.y;\n if (Math.hypot(dx, dy) * this.documentData.viewport.scale > DRAG_THRESHOLD) it.moved = true;\n for (const orig of it.originals) this._replaceShape(translateShape(orig, dx, dy));\n const movingIds = new Set(it.originals.map((s) => s.id));\n const snap = this._computeSnap(boundsOfShapes(this.getSelectedShapes()), movingIds);\n if (snap.dx || snap.dy)\n for (const orig of it.originals)\n this._replaceShape(translateShape(orig, dx + snap.dx, dy + snap.dy));\n this._renderGuides(snap.guides);\n this.render({ scene: true, guides: false });\n return;\n }\n\n if (it.kind === 'resize') {\n const t = this._resizeBounds(\n it.startBounds,\n it.handle,\n world.x - it.start.x,\n world.y - it.start.y,\n );\n const sx = it.startBounds.w === 0 ? 1 : t.w / it.startBounds.w;\n const sy = it.startBounds.h === 0 ? 1 : t.h / it.startBounds.h;\n for (const orig of it.originals) {\n const scaled = scaleShape(orig, it.startBounds.x, it.startBounds.y, sx, sy);\n this._replaceShape(translateShape(scaled, t.x - it.startBounds.x, t.y - it.startBounds.y));\n }\n it.moved = true;\n this.render();\n return;\n }\n\n if (it.kind === 'marquee') {\n it.current = world;\n this._renderMarquee(it.start, world);\n return;\n }\n\n if (it.kind === 'freehand') {\n const shape = this.getShape(it.shapeId);\n if (shape) {\n shape.points.push([round(world.x), round(world.y), event.pressure || 0.5]);\n this.render({ scene: true });\n }\n return;\n }\n\n if (it.kind === 'create-line') {\n const shape = this.getShape(it.shapeId);\n if (shape) {\n shape.points[1] = [round(world.x), round(world.y)];\n this.render({ scene: true });\n }\n return;\n }\n\n if (it.kind === 'create-box') {\n const shape = this.getShape(it.shapeId);\n if (shape) {\n shape.x = round(Math.min(it.start.x, world.x));\n shape.y = round(Math.min(it.start.y, world.y));\n shape.w = round(Math.max(1, Math.abs(world.x - it.start.x)));\n shape.h = round(Math.max(1, Math.abs(world.y - it.start.y)));\n this.render({ scene: true });\n }\n }\n }\n\n _resizeBounds(start, handle, dx, dy) {\n let { x, y, w, h } = start;\n if (handle.includes('e')) w = Math.max(1, start.w + dx);\n if (handle.includes('s')) h = Math.max(1, start.h + dy);\n if (handle.includes('w')) {\n w = Math.max(1, start.w - dx);\n x = start.x + (start.w - w);\n }\n if (handle.includes('n')) {\n h = Math.max(1, start.h - dy);\n y = start.y + (start.h - h);\n }\n return { x, y, w, h };\n }\n\n _handlePointerUp(event) {\n const it = this.interaction;\n if (!it) return;\n this.interaction = null;\n if (\n typeof this.canvasEl.releasePointerCapture === 'function' &&\n this.canvasEl.hasPointerCapture?.(event.pointerId)\n ) {\n try {\n this.canvasEl.releasePointerCapture(event.pointerId);\n } catch {\n /* ignore */\n }\n }\n this._renderGuides([]);\n clearChildren(this.marqueeLayer);\n\n if (it.kind === 'pan') {\n this._emitViewportChange('viewport:pan');\n return;\n }\n if (it.kind === 'erase') {\n if (it.erased.size) {\n const ids = [...it.erased];\n this.documentData.shapes = this.documentData.shapes.filter((s) => !it.erased.has(s.id));\n this.render();\n this._emitChange('shape:erase', { shapeIds: ids });\n }\n return;\n }\n if (it.kind === 'move' && it.moved) {\n this.render();\n this._emitChange('shape:move', { shapeIds: [...this.selectedIds] });\n return;\n }\n if (it.kind === 'resize' && it.moved) {\n this.render();\n this._emitChange('shape:resize', { shapeIds: [...this.selectedIds] });\n return;\n }\n if (it.kind === 'marquee') {\n const box = this._boxFromPoints(it.start, it.current || it.start);\n this.selectInBounds(box, { additive: it.additive });\n return;\n }\n if (it.kind === 'freehand' || it.kind === 'create-line' || it.kind === 'create-box') {\n const shape = this.getShape(it.shapeId);\n if (!shape) return;\n if (it.kind === 'freehand') shape.points = simplifyPoints(shape.points);\n const b = shapeBounds(shape);\n if (\n it.kind !== 'freehand' &&\n b.w < 2 &&\n b.h < 2 &&\n shape.type !== 'text' &&\n shape.type !== 'sticky'\n ) {\n this.documentData.shapes = this.documentData.shapes.filter((s) => s.id !== it.shapeId);\n this.render();\n return;\n }\n if (shape.type === 'text' || shape.type === 'sticky') {\n if (b.w < 2 && b.h < 2) {\n shape.w = shape.type === 'sticky' ? 160 : 120;\n shape.h = shape.type === 'sticky' ? 120 : 40;\n }\n }\n if (it.kind !== 'freehand') {\n this.select(shape.id);\n this.setTool('select');\n }\n this.render();\n this._emitChange('shape:add', { shape: deepClone(shape), shapeId: shape.id });\n if (shape.type === 'text' || shape.type === 'sticky') this.startTextEdit(shape.id);\n }\n }\n\n _boxFromPoints(a, b) {\n return {\n x: Math.min(a.x, b.x),\n y: Math.min(a.y, b.y),\n w: Math.abs(a.x - b.x),\n h: Math.abs(a.y - b.y),\n };\n }\n\n _handleWheel(event) {\n event.preventDefault();\n const local = this._clientToLocal(event.clientX, event.clientY);\n const factor = event.deltaY < 0 ? 1.1 : 1 / 1.1;\n this.scaleAround(factor, local.x, local.y);\n this.render({ scene: false });\n this._emitViewportChange('viewport:zoom');\n }\n\n _handleKeyDown(event) {\n if (this.textEditor) return;\n const meta = event.metaKey || event.ctrlKey;\n if (meta && event.key.toLowerCase() === 'z') {\n event.preventDefault();\n if (event.shiftKey) this.redo();\n else this.undo();\n return;\n }\n if (meta && event.key.toLowerCase() === 'y') {\n event.preventDefault();\n this.redo();\n return;\n }\n if (meta && event.key.toLowerCase() === 'a') {\n event.preventDefault();\n this.selectAll();\n return;\n }\n if (meta && event.key.toLowerCase() === 'c') {\n this.copy();\n return;\n }\n if (meta && event.key.toLowerCase() === 'v') {\n this.paste();\n return;\n }\n if (meta && event.key.toLowerCase() === 'd') {\n event.preventDefault();\n this.duplicate();\n return;\n }\n if (this.readonly) return;\n if (event.key === 'Delete' || event.key === 'Backspace') {\n event.preventDefault();\n this.deleteSelection();\n return;\n }\n const nudgeMap = {\n ArrowLeft: [-1, 0],\n ArrowRight: [1, 0],\n ArrowUp: [0, -1],\n ArrowDown: [0, 1],\n };\n if (nudgeMap[event.key] && this.selectedIds.size) {\n event.preventDefault();\n const step = event.shiftKey ? 10 : 1;\n const [dx, dy] = nudgeMap[event.key];\n this.nudge(dx * step, dy * step);\n }\n }\n\n _handleResize() {\n if (this.destroyed) return;\n this.render({ scene: false });\n }\n\n // \u2500\u2500 Rendering \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n render(flags = {}) {\n if (this.destroyed) return;\n const { scene = true, overlay = true } = flags;\n const vp = this.documentData.viewport;\n this.world.setAttribute('transform', `matrix(${vp.scale} 0 0 ${vp.scale} ${vp.x} ${vp.y})`);\n if (scene) {\n clearChildren(this.shapesLayer);\n const erasing =\n this.interaction && this.interaction.kind === 'erase' ? this.interaction.erased : null;\n for (const shape of this.documentData.shapes) {\n if (erasing && erasing.has(shape.id)) continue;\n const el = this._renderShapeEl(shape, {});\n if (el) this.shapesLayer.appendChild(el);\n }\n }\n if (overlay) this._renderOverlay();\n }\n\n // Colors are applied via inline `style` (which wins over the CSS class rules\n // and serializes self-contained), so a picked color always renders.\n _renderShapeEl(shape, { standalone = false, colors = null }) {\n let el = null;\n const setOpacity = (node) => {\n if (shape.opacity != null && shape.opacity !== 1)\n node.setAttribute('opacity', String(shape.opacity));\n };\n\n if (shape.type === 'freehand') {\n el = createSvgEl('path', { d: brushStrokePath(shape) });\n el.classList.add('vd-draw-ink');\n el.style.stroke = 'none';\n const fill = shape.color || (standalone && colors ? colors.ink : '');\n if (fill) el.style.fill = fill;\n if (shape.opacity != null && shape.opacity !== 1)\n el.style.fillOpacity = String(shape.opacity);\n const preset = BRUSH_PRESETS[shape.brush];\n if (preset && preset.blend && preset.blend !== 'normal') el.style.mixBlendMode = preset.blend;\n } else if (shape.type === 'rectangle') {\n el = createSvgEl('rect', { x: shape.x, y: shape.y, width: shape.w, height: shape.h, rx: 4 });\n el.classList.add('vd-draw-shape');\n this._applyShapeStroke(el, shape, standalone, colors);\n setOpacity(el);\n } else if (shape.type === 'ellipse') {\n el = createSvgEl('ellipse', {\n cx: shape.x + shape.w / 2,\n cy: shape.y + shape.h / 2,\n rx: shape.w / 2,\n ry: shape.h / 2,\n });\n el.classList.add('vd-draw-shape');\n this._applyShapeStroke(el, shape, standalone, colors);\n setOpacity(el);\n } else if (shape.type === 'line') {\n el = createSvgEl('path', { d: pointsToPath(shape.points) });\n el.classList.add('vd-draw-shape');\n this._applyShapeStroke(el, shape, standalone, colors);\n setOpacity(el);\n if (shape.arrowEnd) el.setAttribute('marker-end', `url(#${this._svgId('arrow')})`);\n if (shape.arrowStart) el.setAttribute('marker-start', `url(#${this._svgId('arrow')})`);\n } else if (shape.type === 'text' || shape.type === 'sticky') {\n el = createSvgEl('g');\n setOpacity(el);\n if (shape.type === 'sticky') {\n const bg = createSvgEl('rect', {\n x: shape.x,\n y: shape.y,\n width: shape.w,\n height: shape.h,\n rx: 4,\n });\n bg.classList.add('vd-draw-sticky');\n if (shape.fill) bg.style.fill = shape.fill;\n else if (standalone && colors) bg.style.fill = colors.sticky;\n el.appendChild(bg);\n }\n const text = createSvgEl('text', { x: shape.x + 6, y: shape.y + 18 });\n text.classList.add('vd-draw-text');\n const fill = shape.color || (standalone && colors ? colors.text : '');\n if (fill) text.style.fill = fill;\n text.textContent = shape.text || '';\n el.appendChild(text);\n }\n if (el && !standalone) el.setAttribute('data-shape-id', shape.id);\n return el;\n }\n\n _applyShapeStroke(el, shape, standalone, colors) {\n const stroke = shape.color || (standalone && colors ? colors.shapeStroke : '');\n if (stroke) el.style.stroke = stroke;\n if (shape.strokeWidth != null) el.setAttribute('stroke-width', String(shape.strokeWidth));\n el.style.fill = shape.fill ? shape.fill : 'none';\n }\n\n _renderOverlay() {\n clearChildren(this.overlayLayer);\n const selected = this.getSelectedShapes();\n if (!selected.length || this.readonly) return;\n const bounds = boundsOfShapes(selected);\n if (!bounds) return;\n const box = createSvgEl('rect', {\n class: 'vd-draw-selection-box',\n x: bounds.x,\n y: bounds.y,\n width: bounds.w,\n height: bounds.h,\n fill: 'none',\n });\n box.setAttribute('vector-effect', 'non-scaling-stroke');\n this.overlayLayer.appendChild(box);\n const scale = this.documentData.viewport.scale || 1;\n const r = HANDLE_SIZE / scale / 2;\n for (const handle of resizeHandlePositions(bounds)) {\n const dot = createSvgEl('rect', {\n class: 'vd-draw-handle',\n x: handle.x - r,\n y: handle.y - r,\n width: r * 2,\n height: r * 2,\n 'data-handle': handle.key,\n });\n dot.setAttribute('vector-effect', 'non-scaling-stroke');\n this.overlayLayer.appendChild(dot);\n }\n }\n\n _renderMarquee(a, b) {\n clearChildren(this.marqueeLayer);\n const box = this._boxFromPoints(a, b);\n const rect = createSvgEl('rect', {\n class: 'vd-draw-marquee-rect',\n x: box.x,\n y: box.y,\n width: box.w,\n height: box.h,\n });\n rect.setAttribute('vector-effect', 'non-scaling-stroke');\n this.marqueeLayer.appendChild(rect);\n }\n\n _renderGuides(guides) {\n clearChildren(this.guidesLayer);\n for (const g of guides || []) {\n const line = createSvgEl('line', {\n class: 'vd-draw-guide',\n x1: g.x1,\n y1: g.y1,\n x2: g.x2,\n y2: g.y2,\n });\n line.setAttribute('vector-effect', 'non-scaling-stroke');\n this.guidesLayer.appendChild(line);\n }\n }\n\n // \u2500\u2500 Ready + lifecycle \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _scheduleReady() {\n const fire = () => {\n if (this.destroyed || this._ready) return;\n this._ready = true;\n if (this.autoFit) this.fitView();\n this.emit('ready', this);\n };\n if (typeof requestAnimationFrame === 'function') requestAnimationFrame(fire);\n else setTimeout(fire, 0);\n }\n\n destroy() {\n if (this.destroyed) return;\n this.destroyed = true;\n this.stopTextEdit({ commit: false });\n this._unbindEvents();\n this.listeners.clear();\n if (this.element) this.element.replaceChildren();\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAAA;AAAA,EAAA;AAAA;AAAA;;;ACUA,iBAA2E;;;ACFpE,IAAM,kBAAkB;AAGxB,IAAM,aAAa,OAAO,OAAO;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,mBAAmB,OAAO,OAAO;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAQM,IAAM,gBAAgB,OAAO,OAAO;AAAA,EACzC,KAAK;AAAA,IACH,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AAAA,EACA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,UAAU;AAAA,I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,MACzC,MAAM,MAAM,UAAU,KAAK;AAAA,MAC3B,MAAM,MAAM,UAAU,KAAK;AAAA,MAC3B,SAAS,MAAM,QAAQ,UAAU,QAAQ,CAAC;AAAA,MAC1C,SAAS,MAAM,QAAQ,UAAU,QAAQ,CAAC;AAAA,MAC1C,OAAO,MAAM,UAAU,MAAM;AAAA,MAC7B,OAAO,CAAC,YAAY,UAAU,MAAM,OAAO;AAAA,IAC7C,CAAC;AAED,WAAO,UAAM,cAAE,OAAO,EAAE,KAAK,IAAI,OAAO,UAAU,CAAC;AAAA,EACrD;AACF,CAAC;",
|
|
6
|
-
"names": ["VdDraw", "h", "shape", "h", "shape", "VdDraw"]
|
|
4
|
+
"sourcesContent": ["// Entry for @vanduo-oss/vd3-cbun/draw.\n//\n// The Vue 3 wrapper is the primary export; the framework-agnostic editor core\n// is re-exported alongside as VdDrawCore. Named exports only \u2014 no default.\n\nexport { VdDraw } from './vue.js';\nexport { VdDraw as VdDrawCore } from './core.js';\nexport { VD_DRAW_VERSION, DRAW_TOOLS, DRAW_SHAPE_TYPES, BRUSH_PRESETS } from './shapes.js';\n", "/**\n * Vue 3 bindings for the draw whiteboard \u2014 the primary export surface.\n *\n * import { VdDraw } from '@vanduo-oss/vd3-cbun/draw';\n * <VdDraw :data=\"doc\" tool=\"rectangle\" @change=\"onChange\" @ready=\"onReady\" />\n *\n * The editor core stays framework-agnostic in ./core.js. SSR-safe: the editor\n * is created on mount (client) into a plain container the server can\n * pre-render.\n */\nimport { defineComponent, h, ref, onMounted, onBeforeUnmount, watch } from 'vue';\nimport { VdDraw as VdDrawCore } from './core.js';\n\nconst FORWARDED_EVENTS = ['change', 'select', 'viewport', 'ready'];\n\nexport const VdDraw = defineComponent({\n name: 'VdDraw',\n props: {\n /** Drawing document \u2014 `{ shapes, viewport }`. */\n data: { type: Object, default: () => ({}) },\n /** Render as a non-editable viewer (no toolbar, no editing). */\n readonly: { type: Boolean, default: false },\n /** Active tool \u2014 updated live without recreating the editor. */\n tool: { type: String, default: 'draw' },\n /** Background grid size in px. */\n gridSize: { type: Number, default: undefined },\n /** Show the background grid \u2014 updated live (default true). */\n showGrid: { type: Boolean, default: true },\n /** Snap shapes to nearby edges/centres while moving/resizing. */\n snap: { type: Boolean, default: true },\n /** Fit the view to content once the editor reports a measurable size. */\n autoFit: { type: Boolean, default: false },\n /** Enable the built-in undo/redo history (default true). */\n history: { type: Boolean, default: true },\n /** Maximum number of history entries to retain. */\n historyLimit: { type: Number, default: undefined },\n },\n emits: ['change', 'select', 'viewport', 'ready'],\n setup(props, { emit, expose }) {\n const el = ref(null);\n let instance = null;\n\n const create = () => {\n instance = new VdDrawCore({\n element: el.value,\n data: props.data,\n readonly: props.readonly,\n tool: props.tool,\n gridSize: props.gridSize,\n showGrid: props.showGrid,\n snap: props.snap,\n autoFit: props.autoFit,\n history: props.history,\n historyLimit: props.historyLimit,\n });\n FORWARDED_EVENTS.forEach((name) => {\n instance.on(name, (payload) => emit(name, payload));\n });\n };\n\n onMounted(() => {\n if (typeof window === 'undefined' || !el.value) return;\n create();\n });\n\n // Data flows through load(); tool updates live; construct-time options recreate.\n watch(\n () => props.data,\n (next) => {\n if (instance && typeof instance.load === 'function') instance.load(next);\n },\n { deep: true },\n );\n watch(\n () => props.tool,\n (next) => instance?.setTool(next),\n );\n watch(\n () => props.showGrid,\n (next) => instance?.setGridVisible(next),\n );\n watch(\n () => [\n props.readonly,\n props.gridSize,\n props.snap,\n props.autoFit,\n props.history,\n props.historyLimit,\n ],\n () => {\n if (!instance) return;\n instance.destroy();\n create();\n },\n );\n\n onBeforeUnmount(() => {\n if (instance) {\n instance.destroy();\n instance = null;\n }\n });\n\n expose({\n getInstance: () => instance,\n setTool: (tool) => instance?.setTool(tool),\n undo: () => instance?.undo(),\n redo: () => instance?.redo(),\n canUndo: () => Boolean(instance?.canUndo()),\n canRedo: () => Boolean(instance?.canRedo()),\n toSVG: () => instance?.toSVG(),\n toPNG: (options) => instance?.toPNG(options),\n addShape: (partial) => instance?.addShape(partial),\n updateShape: (id, patch, options) => instance?.updateShape(id, patch, options),\n removeShape: (id) => instance?.removeShape(id),\n getShape: (id) => instance?.getShape(id),\n getShapes: () => instance?.getShapes(),\n clear: () => instance?.clear(),\n load: (data) => instance?.load(data),\n toJSON: () => instance?.toJSON(),\n });\n\n return () => h('div', { ref: el, class: 'vd-draw' });\n },\n});\n", "// Pure, DOM-free geometry + document model + brush engine for the draw tool.\n//\n// Everything here is framework- and DOM-agnostic so it is unit-testable in\n// plain Node (the analogue of flowchart's layout.js). core.js owns the SVG DOM\n// engine and calls into these helpers; nothing in this file touches `window`,\n// `document`, or `vue`.\n\n/** Load-bearing: stamped into every serialized document via toJSON().version. */\nexport const VD_DRAW_VERSION = '1.1.0';\n\n/** Selectable tools \u2014 drawing-first. `select`/`hand` manipulate. */\nexport const DRAW_TOOLS = Object.freeze([\n 'select',\n 'hand',\n 'draw',\n 'eraser',\n 'rectangle',\n 'ellipse',\n 'line',\n 'text',\n 'sticky',\n]);\n\n/** Persisted shape kinds. The `draw` tool produces a `freehand` (brush) stroke. */\nexport const DRAW_SHAPE_TYPES = Object.freeze([\n 'rectangle',\n 'ellipse',\n 'line',\n 'freehand',\n 'text',\n 'sticky',\n]);\n\n/**\n * Brush presets \u2014 each a config the brush engine consumes. `thinning` maps\n * pressure/velocity to width (0 = flat); `streamline` low-passes the input;\n * taper shrinks the ends; `blend` is the CSS mix-blend-mode; `nibAngle` (only\n * calligraphy) makes width depend on stroke direction.\n */\nexport const BRUSH_PRESETS = Object.freeze({\n pen: {\n size: 6,\n thinning: 0.55,\n smoothing: 0.5,\n streamline: 0.5,\n taperStart: 0,\n taperEnd: 14,\n opacity: 1,\n blend: 'normal',\n },\n pencil: {\n size: 4,\n thinning: 0.7,\n smoothing: 0.35,\n streamline: 0.35,\n taperStart: 4,\n taperEnd: 10,\n opacity: 0.92,\n blend: 'normal',\n },\n marker: {\n size: 14,\n thinning: 0.15,\n smoothing: 0.55,\n streamline: 0.5,\n taperStart: 0,\n taperEnd: 0,\n opacity: 0.85,\n blend: 'normal',\n },\n highlighter: {\n size: 22,\n thinning: 0,\n smoothing: 0.6,\n streamline: 0.55,\n taperStart: 0,\n taperEnd: 0,\n opacity: 0.4,\n blend: 'multiply',\n },\n calligraphy: {\n size: 12,\n thinning: 0.6,\n smoothing: 0.4,\n streamline: 0.3,\n taperStart: 8,\n taperEnd: 12,\n opacity: 1,\n nibAngle: -0.7,\n blend: 'normal',\n },\n});\n\nexport const DEFAULT_BRUSH = 'pen';\n\n/** Shapes whose geometry is a list of world-space points (vs. an x/y/w/h box). */\nconst POINT_TYPES = Object.freeze(['line', 'freehand']);\n\nexport const MIN_SCALE = 0.2;\nexport const MAX_SCALE = 4;\nexport const DEFAULT_GRID_SIZE = 20;\nexport const DEFAULT_STROKE_WIDTH = 2;\n\n// Bounded deserialization caps. An untrusted or corrupt document (e.g. a shared\n// link with tens of millions of points or shapes) is TRUNCATED \u2014 never thrown \u2014\n// so `load()` cannot be turned into a client-side DoS: the O(n) coercion and the\n// resulting render stay bounded. A normal document is far below these limits and\n// is unaffected.\nexport const MAX_SHAPES = 10000;\nexport const MAX_POINTS_PER_SHAPE = 100000;\n\nlet idCounter = 0;\n\n/** Monotonic-ish id; unique within a session, prefixed by kind. */\nexport function createId(prefix = 'sh') {\n idCounter += 1;\n return `${prefix}_${idCounter.toString(36)}${(idCounter * 2654435761).toString(36).slice(-4)}`;\n}\n\nexport function clamp(value, min, max) {\n return Math.min(max, Math.max(min, value));\n}\n\n/** Round to 2 decimals to keep serialized coordinates stable and compact. */\nexport function round(value) {\n return Math.round((Number(value) || 0) * 100) / 100;\n}\n\n/** Structured deep clone with a JSON fallback for older runtimes. */\nexport function deepClone(value) {\n if (typeof structuredClone === 'function') {\n try {\n return structuredClone(value);\n } catch {\n /* fall through to JSON */\n }\n }\n return JSON.parse(JSON.stringify(value));\n}\n\n/** Round a point, preserving an optional third (pressure) slot. */\nfunction roundPoint(p) {\n const out = [round(p[0]), round(p[1])];\n if (p.length >= 3 && p[2] != null) out.push(clamp(Number(p[2]) || 0, 0, 1));\n return out;\n}\n\nfunction isPointShape(shape) {\n return POINT_TYPES.includes(shape.type);\n}\n\n/** Axis-aligned bounds `{ x, y, w, h }` for any shape kind. */\nexport function shapeBounds(shape) {\n if (isPointShape(shape)) {\n const pts = shape.points || [];\n if (!pts.length) return { x: shape.x || 0, y: shape.y || 0, w: 0, h: 0 };\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const [px, py] of pts) {\n if (px < minX) minX = px;\n if (py < minY) minY = py;\n if (px > maxX) maxX = px;\n if (py > maxY) maxY = py;\n }\n return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };\n }\n return { x: shape.x || 0, y: shape.y || 0, w: shape.w || 0, h: shape.h || 0 };\n}\n\n/** Union bounds of several shapes, or null when the list is empty. */\nexport function boundsOfShapes(shapes) {\n if (!shapes || !shapes.length) return null;\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const shape of shapes) {\n const b = shapeBounds(shape);\n minX = Math.min(minX, b.x);\n minY = Math.min(minY, b.y);\n maxX = Math.max(maxX, b.x + b.w);\n maxY = Math.max(maxY, b.y + b.h);\n }\n return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };\n}\n\n/** Do two `{x,y,w,h}` boxes overlap (used for marquee selection / eraser)? */\nexport function boundsIntersect(a, b) {\n return !(a.x + a.w < b.x || b.x + b.w < a.x || a.y + a.h < b.y || b.y + b.h < a.y);\n}\n\n/** Is a world point inside a shape's (padded) bounds? Hit-test for select. */\nexport function pointInShape(shape, x, y, pad = 0) {\n const b = shapeBounds(shape);\n return x >= b.x - pad && x <= b.x + b.w + pad && y >= b.y - pad && y <= b.y + b.h + pad;\n}\n\n/** Shortest distance from a world point to a shape (for the eraser). */\nexport function distanceToShape(shape, x, y) {\n if (isPointShape(shape)) {\n const pts = shape.points || [];\n if (pts.length === 1) return Math.hypot(pts[0][0] - x, pts[0][1] - y);\n let min = Infinity;\n for (let i = 1; i < pts.length; i += 1) {\n min = Math.min(min, pointToSegment(x, y, pts[i - 1], pts[i]));\n }\n return min;\n }\n const b = shapeBounds(shape);\n const dx = Math.max(b.x - x, 0, x - (b.x + b.w));\n const dy = Math.max(b.y - y, 0, y - (b.y + b.h));\n return Math.hypot(dx, dy);\n}\n\nfunction pointToSegment(px, py, a, b) {\n const vx = b[0] - a[0];\n const vy = b[1] - a[1];\n const wx = px - a[0];\n const wy = py - a[1];\n const c1 = vx * wx + vy * wy;\n if (c1 <= 0) return Math.hypot(px - a[0], py - a[1]);\n const c2 = vx * vx + vy * vy;\n if (c2 <= c1) return Math.hypot(px - b[0], py - b[1]);\n const t = c1 / c2;\n return Math.hypot(px - (a[0] + t * vx), py - (a[1] + t * vy));\n}\n\n/** Return a NEW shape translated by (dx, dy); pure, never mutates input. */\nexport function translateShape(shape, dx, dy) {\n const next = deepClone(shape);\n if (isPointShape(next)) {\n next.points = (next.points || []).map((p) => roundPoint([p[0] + dx, p[1] + dy, p[2]]));\n } else {\n next.x = round((next.x || 0) + dx);\n next.y = round((next.y || 0) + dy);\n }\n return next;\n}\n\n/**\n * Return a NEW shape scaled about (ox, oy) by (sx, sy). Box shapes rescale\n * x/y/w/h; point shapes rescale each point. Pure.\n */\nexport function scaleShape(shape, ox, oy, sx, sy) {\n const next = deepClone(shape);\n const avg = (Math.abs(sx) + Math.abs(sy)) * 0.5;\n if (isPointShape(next)) {\n next.points = (next.points || []).map((p) =>\n roundPoint([ox + (p[0] - ox) * sx, oy + (p[1] - oy) * sy, p[2]]),\n );\n if (typeof next.size === 'number') next.size = round(Math.max(1, next.size * avg));\n if (typeof next.strokeWidth === 'number') next.strokeWidth = round(next.strokeWidth * avg);\n } else {\n next.x = round(ox + ((next.x || 0) - ox) * sx);\n next.y = round(oy + ((next.y || 0) - oy) * sy);\n next.w = round(Math.max(1, (next.w || 0) * sx));\n next.h = round(Math.max(1, (next.h || 0) * sy));\n }\n return next;\n}\n\n/** Eight resize handles for a selection box, keyed by compass direction. */\nexport function resizeHandlePositions(bounds) {\n const { x, y, w, h } = bounds;\n const mx = x + w / 2;\n const my = y + h / 2;\n return [\n { key: 'nw', x, y },\n { key: 'n', x: mx, y },\n { key: 'ne', x: x + w, y },\n { key: 'e', x: x + w, y: my },\n { key: 'se', x: x + w, y: y + h },\n { key: 's', x: mx, y: y + h },\n { key: 'sw', x, y: y + h },\n { key: 'w', x, y: my },\n ];\n}\n\n/**\n * Convert Catmull-Rom through-points to a cubic Bezier SVG path.\n * Each segment uses neighbors as tangents so sparse samples look smooth.\n *\n * @param {Array<[number, number]>} points\n * @returns {string}\n */\nfunction pointsToCatmullRomPath(points) {\n const pts = points.map((p) => [Number(p[0]), Number(p[1])]);\n if (pts.length < 3) {\n const [first, ...rest] = pts;\n let d = `M ${round(first[0])} ${round(first[1])}`;\n for (const [px, py] of rest) d += ` L ${round(px)} ${round(py)}`;\n return d;\n }\n\n let d = `M ${round(pts[0][0])} ${round(pts[0][1])}`;\n for (let i = 0; i < pts.length - 1; i += 1) {\n const p0 = pts[i === 0 ? i : i - 1];\n const p1 = pts[i];\n const p2 = pts[i + 1];\n const p3 = pts[i + 2 < pts.length ? i + 2 : i + 1];\n // Uniform Catmull-Rom \u2192 cubic Bezier control points (tension 1).\n const c1x = p1[0] + (p2[0] - p0[0]) / 6;\n const c1y = p1[1] + (p2[1] - p0[1]) / 6;\n const c2x = p2[0] - (p3[0] - p1[0]) / 6;\n const c2y = p2[1] - (p3[1] - p1[1]) / 6;\n d += ` C ${round(c1x)} ${round(c1y)} ${round(c2x)} ${round(c2y)} ${round(p2[0])} ${round(p2[1])}`;\n }\n return d;\n}\n\n/**\n * Build an SVG path `d` for line shapes.\n * When `smooth` is true and there are 3+ points, uses Catmull-Rom cubics;\n * otherwise a straight polyline (`M` / `L`).\n *\n * @param {Array<[number, number]>} points\n * @param {{ smooth?: boolean }} [options]\n * @returns {string}\n */\nexport function pointsToPath(points, options = {}) {\n if (!points || !points.length) return '';\n if (options.smooth && points.length >= 3) return pointsToCatmullRomPath(points);\n const [first, ...rest] = points;\n let d = `M ${round(first[0])} ${round(first[1])}`;\n for (const [px, py] of rest) d += ` L ${round(px)} ${round(py)}`;\n return d;\n}\n\n/**\n * Drop points closer than `min` world units to the previously kept point \u2014\n * keeps freehand strokes light without visibly changing the path. Preserves\n * the optional pressure slot.\n */\nexport function simplifyPoints(points, min = 1.2) {\n if (!points || points.length <= 2) return (points || []).map(roundPoint);\n const out = [roundPoint(points[0])];\n for (let i = 1; i < points.length; i += 1) {\n const p = points[i];\n const last = out[out.length - 1];\n if (Math.hypot(p[0] - last[0], p[1] - last[1]) >= min || i === points.length - 1)\n out.push(roundPoint(p));\n }\n return out;\n}\n\n// \u2500\u2500 Brush engine \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// A compact, dependency-free variable-width stroke generator: input points\n// (each [x, y, pressure?]) \u2192 a filled outline polygon. Pure/deterministic.\n\nfunction streamlinePoints(points, streamline) {\n const first = points[0];\n const out = [[first[0], first[1], first[2] == null ? 0.5 : clamp(first[2], 0, 1)]];\n if (points.length < 2) return out;\n const factor = clamp(1 - (streamline == null ? 0.5 : streamline), 0.15, 1);\n for (let i = 1; i < points.length; i += 1) {\n const prev = out[out.length - 1];\n const p = points[i];\n out.push([\n prev[0] + (p[0] - prev[0]) * factor,\n prev[1] + (p[1] - prev[1]) * factor,\n p[2] == null ? 0.5 : clamp(p[2], 0, 1),\n ]);\n }\n return out;\n}\n\nfunction circlePolygon(cx, cy, r, segments = 16) {\n const pts = [];\n for (let i = 0; i < segments; i += 1) {\n const a = (i / segments) * Math.PI * 2;\n pts.push([cx + Math.cos(a) * r, cy + Math.sin(a) * r]);\n }\n return pts;\n}\n\n// Faster strokes (longer per-sample segments) render thinner.\nfunction velocityPressure(segmentLength) {\n return clamp(1 - segmentLength / 28, 0.25, 1);\n}\n\n/**\n * Variable-width outline for a brush stroke. Returns a closed polygon (array of\n * `[x, y]`) to be filled. Width follows per-point pressure (or velocity when\n * pressure is flat), scaled by `size` and `thinning`, with start/end taper and\n * an optional fixed-angle nib.\n */\nexport function strokeOutline(rawPoints, options = {}) {\n const points = (rawPoints || []).filter((p) => Array.isArray(p) && p.length >= 2);\n if (points.length === 0) return [];\n const size = Math.max(1, options.size == null ? 8 : options.size);\n const thinning = options.thinning == null ? 0.5 : options.thinning;\n const taperStart = options.taperStart || 0;\n const taperEnd = options.taperEnd || 0;\n const nibAngle = options.nibAngle;\n\n const pts = streamlinePoints(points, options.streamline);\n if (pts.length === 1) return circlePolygon(pts[0][0], pts[0][1], size / 2);\n\n const segLen = [];\n let total = 0;\n for (let i = 1; i < pts.length; i += 1) {\n const d = Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]);\n segLen.push(d);\n total += d;\n }\n const hasPressure = points.some((p) => p.length >= 3 && p[2] != null && p[2] > 0 && p[2] !== 0.5);\n\n const left = [];\n const right = [];\n let run = 0;\n for (let i = 0; i < pts.length; i += 1) {\n const p = pts[i];\n const prev = pts[i - 1] || p;\n const next = pts[i + 1] || p;\n let dx = next[0] - prev[0];\n let dy = next[1] - prev[1];\n const len = Math.hypot(dx, dy) || 1;\n dx /= len;\n dy /= len;\n const nx = -dy;\n const ny = dx;\n const pressure = hasPressure\n ? p[2]\n : velocityPressure(segLen[i - 1] == null ? segLen[i] || 0 : segLen[i - 1]);\n let radius = (size / 2) * (thinning === 0 ? 1 : 1 - thinning + thinning * pressure);\n if (typeof nibAngle === 'number') {\n radius *= 0.35 + 0.65 * Math.abs(Math.sin(Math.atan2(dy, dx) - nibAngle));\n }\n if (i > 0) run += segLen[i - 1];\n if (taperStart > 0) radius *= clamp(run / taperStart, 0, 1);\n if (taperEnd > 0) radius *= clamp((total - run) / taperEnd, 0, 1);\n radius = Math.max(0.1, radius);\n left.push([p[0] + nx * radius, p[1] + ny * radius]);\n right.push([p[0] - nx * radius, p[1] - ny * radius]);\n }\n return [...left, ...right.reverse()];\n}\n\n/** Smooth closed SVG path `d` (quadratic) for a filled outline polygon. */\nexport function pointsToBrushPath(outline) {\n if (!outline || outline.length < 3) {\n if (outline && outline.length) {\n const [x, y] = outline[0];\n return `M ${round(x - 1)} ${round(y)} a 1 1 0 1 0 2 0 a 1 1 0 1 0 -2 0 Z`;\n }\n return '';\n }\n let d = `M ${round(outline[0][0])} ${round(outline[0][1])}`;\n for (let i = 1; i < outline.length; i += 1) {\n const prev = outline[i - 1];\n const cur = outline[i];\n const mx = (prev[0] + cur[0]) / 2;\n const my = (prev[1] + cur[1]) / 2;\n d += ` Q ${round(prev[0])} ${round(prev[1])} ${round(mx)} ${round(my)}`;\n }\n return `${d} Z`;\n}\n\n/** Convenience: the filled path `d` for a freehand shape (brush + size). */\nexport function brushStrokePath(shape) {\n const preset = BRUSH_PRESETS[shape.brush] || BRUSH_PRESETS[DEFAULT_BRUSH];\n return pointsToBrushPath(\n strokeOutline(shape.points || [], {\n ...preset,\n size: shape.size == null ? preset.size : shape.size,\n }),\n );\n}\n\nfunction coerceNumber(value, fallback = 0) {\n const n = Number(value);\n return Number.isFinite(n) ? n : fallback;\n}\n\nfunction coercePoints(raw) {\n if (!Array.isArray(raw)) return [];\n const pts = [];\n // Bounded deserialization: coerce at most MAX_POINTS_PER_SHAPE points; any\n // beyond the cap are truncated so a hostile stroke stays O(cap).\n const limit = Math.min(raw.length, MAX_POINTS_PER_SHAPE);\n for (let i = 0; i < limit; i += 1) {\n const p = raw[i];\n if (\n Array.isArray(p) &&\n p.length >= 2 &&\n Number.isFinite(Number(p[0])) &&\n Number.isFinite(Number(p[1]))\n ) {\n const pt = [round(Number(p[0])), round(Number(p[1]))];\n if (p.length >= 3 && Number.isFinite(Number(p[2]))) pt.push(clamp(Number(p[2]), 0, 1));\n pts.push(pt);\n }\n }\n return pts;\n}\n\n/**\n * Validate/normalize a single raw shape. Returns a clean shape or `null` when\n * the input is unusable. Unknown `type` values default to `rectangle`.\n * Migrates v1 freehand (`{ points, stroke, strokeWidth }`) to the brush model.\n */\nexport function normalizeShape(raw, usedIds) {\n if (!raw || typeof raw !== 'object') return null;\n const type = DRAW_SHAPE_TYPES.includes(raw.type) ? raw.type : 'rectangle';\n\n let id = typeof raw.id === 'string' && raw.id ? raw.id : createId(type.slice(0, 2));\n if (usedIds) {\n while (usedIds.has(id)) id = createId(type.slice(0, 2));\n usedIds.add(id);\n }\n const groupId = typeof raw.groupId === 'string' && raw.groupId ? raw.groupId : undefined;\n const color =\n typeof raw.color === 'string'\n ? raw.color\n : typeof raw.stroke === 'string'\n ? raw.stroke\n : undefined;\n\n if (type === 'freehand') {\n const points = coercePoints(raw.points);\n if (points.length < 1) return null;\n const brush = BRUSH_PRESETS[raw.brush] ? raw.brush : DEFAULT_BRUSH;\n const preset = BRUSH_PRESETS[brush];\n const size =\n raw.size != null\n ? Math.max(1, coerceNumber(raw.size, preset.size))\n : raw.strokeWidth != null\n ? Math.max(1, coerceNumber(raw.strokeWidth, DEFAULT_STROKE_WIDTH) * 2)\n : preset.size;\n const shape = {\n id,\n type: 'freehand',\n brush,\n points,\n size: round(size),\n opacity:\n raw.opacity == null\n ? preset.opacity\n : clamp(coerceNumber(raw.opacity, preset.opacity), 0, 1),\n };\n if (color) shape.color = color;\n if (groupId) shape.groupId = groupId;\n return shape;\n }\n\n const base = {\n id,\n type,\n strokeWidth:\n raw.strokeWidth == null\n ? DEFAULT_STROKE_WIDTH\n : coerceNumber(raw.strokeWidth, DEFAULT_STROKE_WIDTH),\n opacity: raw.opacity == null ? 1 : clamp(coerceNumber(raw.opacity, 1), 0, 1),\n };\n if (color) base.color = color;\n if (typeof raw.fill === 'string') base.fill = raw.fill;\n if (groupId) base.groupId = groupId;\n\n if (type === 'line') {\n const points = coercePoints(raw.points);\n if (points.length < 2) return null;\n return {\n ...base,\n points,\n arrowStart: Boolean(raw.arrowStart),\n arrowEnd: raw.arrowEnd == null ? true : Boolean(raw.arrowEnd),\n smooth: Boolean(raw.smooth),\n };\n }\n\n const shape = {\n ...base,\n x: round(coerceNumber(raw.x, 0)),\n y: round(coerceNumber(raw.y, 0)),\n w: round(Math.max(1, coerceNumber(raw.w, 100))),\n h: round(Math.max(1, coerceNumber(raw.h, 80))),\n rotation: coerceNumber(raw.rotation, 0),\n };\n if (type === 'text' || type === 'sticky')\n shape.text = typeof raw.text === 'string' ? raw.text : '';\n return shape;\n}\n\nfunction normalizeViewport(raw) {\n const vp = raw && typeof raw === 'object' ? raw : {};\n return {\n x: coerceNumber(vp.x, 0),\n y: coerceNumber(vp.y, 0),\n scale: clamp(coerceNumber(vp.scale, 1), MIN_SCALE, MAX_SCALE),\n };\n}\n\n/**\n * The single validation + forward-migration gateway. Accepts an object or a\n * JSON string (any prior VD_DRAW_VERSION), and returns a clean\n * `{ version, viewport, shapes }` stamped with the CURRENT version. Ensures\n * unique ids, drops malformed shapes, defaults unknown types, prunes dangling\n * groupIds, and migrates v1 freehand to the brush model. Never mutates input.\n */\nexport function normalizeDocument(data) {\n let raw = data;\n if (typeof raw === 'string') {\n try {\n raw = JSON.parse(raw);\n } catch {\n raw = {};\n }\n }\n if (!raw || typeof raw !== 'object') raw = {};\n\n const usedIds = new Set();\n const rawShapes = Array.isArray(raw.shapes) ? raw.shapes : [];\n const shapes = [];\n // Bounded deserialization: normalize at most MAX_SHAPES shapes; extras from an\n // untrusted document are truncated so the load stays O(cap).\n const shapeLimit = Math.min(rawShapes.length, MAX_SHAPES);\n for (let i = 0; i < shapeLimit; i += 1) {\n const shape = normalizeShape(rawShapes[i], usedIds);\n if (shape) shapes.push(shape);\n }\n\n const groupCounts = new Map();\n for (const s of shapes)\n if (s.groupId) groupCounts.set(s.groupId, (groupCounts.get(s.groupId) || 0) + 1);\n for (const s of shapes) if (s.groupId && groupCounts.get(s.groupId) < 2) delete s.groupId;\n\n return {\n version: VD_DRAW_VERSION,\n viewport: normalizeViewport(raw.viewport),\n shapes,\n };\n}\n", "// Framework-agnostic infinite-canvas drawing tool.\n//\n// Architecture mirrors the flowchart core (SVG world <g> transformed by a\n// matrix for pan/zoom, a plain-object document mutated in place, one\n// `interaction` state machine, and a single emitChange \u2192 recordHistory choke\n// point for whole-document undo snapshots) \u2014 but is a drawing/painting tool:\n// a vector brush engine (see shapes.js), brush presets, a color palette, and a\n// stroke eraser. Fully self-contained under src/draw/ (the tree-shake isolation\n// guard forbids importing vd3 or sibling components). SSR-safe: constructed on\n// mount only; no window/document at module scope; every window listener is\n// removed on destroy().\n\nimport {\n VD_DRAW_VERSION,\n DRAW_TOOLS,\n DRAW_SHAPE_TYPES,\n BRUSH_PRESETS,\n DEFAULT_BRUSH,\n MIN_SCALE,\n MAX_SCALE,\n DEFAULT_GRID_SIZE,\n createId,\n clamp,\n round,\n deepClone,\n shapeBounds,\n boundsOfShapes,\n boundsIntersect,\n distanceToShape,\n translateShape,\n scaleShape,\n resizeHandlePositions,\n pointsToPath,\n simplifyPoints,\n brushStrokePath,\n normalizeDocument,\n} from './shapes.js';\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\nconst WORLD_EXTENT = 8000; // half-size of the grid backdrop, in world units\nconst HANDLE_SIZE = 8; // screen px (kept constant via r/scale)\nconst SNAP_THRESHOLD = 6; // screen px within which edges/centres snap\nconst DRAG_THRESHOLD = 3; // screen px before a press counts as a drag\nconst ERASER_RADIUS = 12; // screen px eraser hit radius\n\n// Reasons whose consecutive same-target commits collapse into one undo entry.\nconst COALESCE_REASONS = new Set(['shape:style', 'shape:text', 'shape:nudge']);\n\n// Genuine Phosphor (regular) icon path data \u2014 MIT, inlined so the component\n// stays self-contained (no webfont / CDN). viewBox 0 0 256 256, currentColor.\nconst ICON_PATHS = {\n select:\n 'M168,132.69,214.08,115l.33-.13A16,16,0,0,0,213,85.07L52.92,32.8A15.95,15.95,0,0,0,32.8,52.92L85.07,213a15.82,15.82,0,0,0,14.41,11l.78,0a15.84,15.84,0,0,0,14.61-9.59l.13-.33L132.69,168,184,219.31a16,16,0,0,0,22.63,0l12.68-12.68a16,16,0,0,0,0-22.63ZM195.31,208,144,156.69a16,16,0,0,0-26,4.93c0,.11-.09.22-.13.32l-17.65,46L48,48l159.85,52.2-45.95,17.64-.32.13a16,16,0,0,0-4.93,26h0L208,195.31Z',\n hand: 'M188,48a27.75,27.75,0,0,0-12,2.71V44a28,28,0,0,0-54.65-8.6A28,28,0,0,0,80,60v64l-3.82-6.13a28,28,0,0,0-48.6,27.82c16,33.77,28.93,57.72,43.72,72.69C86.24,233.54,103.2,240,128,240a88.1,88.1,0,0,0,88-88V76A28,28,0,0,0,188,48Zm12,104a72.08,72.08,0,0,1-72,72c-20.38,0-33.51-4.88-45.33-16.85C69.44,193.74,57.26,171,41.9,138.58a6.36,6.36,0,0,0-.3-.58,12,12,0,0,1,20.79-12,1.76,1.76,0,0,0,.14.23l18.67,30A8,8,0,0,0,96,152V60a12,12,0,0,1,24,0v60a8,8,0,0,0,16,0V44a12,12,0,0,1,24,0v76a8,8,0,0,0,16,0V76a12,12,0,0,1,24,0Z',\n draw: 'M232,32a8,8,0,0,0-8-8c-44.08,0-89.31,49.71-114.43,82.63A60,60,0,0,0,32,164c0,30.88-19.54,44.73-20.47,45.37A8,8,0,0,0,16,224H92a60,60,0,0,0,57.37-77.57C182.3,121.31,232,76.08,232,32ZM92,208H34.63C41.38,198.41,48,183.92,48,164a44,44,0,1,1,44,44Zm32.42-94.45q5.14-6.66,10.09-12.55A76.23,76.23,0,0,1,155,121.49q-5.9,4.94-12.55,10.09A60.54,60.54,0,0,0,124.42,113.55Zm42.7-2.68a92.57,92.57,0,0,0-22-22c31.78-34.53,55.75-45,69.9-47.91C212.17,55.12,201.65,79.09,167.12,110.87Z',\n eraser:\n 'M225,80.4,183.6,39a24,24,0,0,0-33.94,0L31,157.66a24,24,0,0,0,0,33.94l30.06,30.06A8,8,0,0,0,66.74,224H216a8,8,0,0,0,0-16h-84.7L225,114.34A24,24,0,0,0,225,80.4ZM108.68,208H70.05L42.33,180.28a8,8,0,0,1,0-11.31L96,115.31,148.69,168Zm105-105L160,156.69,107.31,104,161,50.34a8,8,0,0,1,11.32,0l41.38,41.38a8,8,0,0,1,0,11.31Z',\n rectangle:\n 'M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm0,176H48V48H208V208Z',\n ellipse:\n 'M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z',\n line: 'M200,64V168a8,8,0,0,1-16,0V83.31L69.66,197.66a8,8,0,0,1-11.32-11.32L172.69,72H88a8,8,0,0,1,0-16H192A8,8,0,0,1,200,64Z',\n text: 'M208,56V88a8,8,0,0,1-16,0V64H136V192h24a8,8,0,0,1,0,16H96a8,8,0,0,1,0-16h24V64H64V88a8,8,0,0,1-16,0V56a8,8,0,0,1,8-8H200A8,8,0,0,1,208,56Z',\n sticky:\n 'M88,96a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H96A8,8,0,0,1,88,96Zm8,40h64a8,8,0,0,0,0-16H96a8,8,0,0,0,0,16Zm32,16H96a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16ZM224,48V156.69A15.86,15.86,0,0,1,219.31,168L168,219.31A15.86,15.86,0,0,1,156.69,224H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48ZM48,208H152V160a8,8,0,0,1,8-8h48V48H48Zm120-40v28.7L196.69,168Z',\n undo: 'M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L44.59,96H72a8,8,0,0,1,0,16H24a8,8,0,0,1-8-8V56a8,8,0,0,1,16,0V85.8L60.25,60A96,96,0,0,1,224,128Z',\n redo: 'M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z',\n duplicate:\n 'M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z',\n delete:\n 'M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z',\n grid: 'M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,80H136V56h64ZM120,56v64H56V56ZM56,136h64v64H56Zm144,64H136V136h64v64Z',\n};\n\nconst TOOL_BUTTONS = [\n { tool: 'select', label: 'Select' },\n { tool: 'hand', label: 'Pan' },\n { tool: 'draw', label: 'Brush' },\n { tool: 'eraser', label: 'Eraser' },\n { tool: 'rectangle', label: 'Rectangle' },\n { tool: 'ellipse', label: 'Ellipse' },\n { tool: 'line', label: 'Arrow' },\n { tool: 'text', label: 'Text' },\n { tool: 'sticky', label: 'Sticky note' },\n];\nconst ACTION_BUTTONS = [\n { action: 'undo', label: 'Undo' },\n { action: 'redo', label: 'Redo' },\n { action: 'duplicate', label: 'Duplicate' },\n { action: 'delete', label: 'Delete / clear' },\n];\n\nconst BRUSH_ORDER = ['pen', 'pencil', 'marker', 'highlighter', 'calligraphy'];\nconst BRUSH_LABELS = {\n pen: 'Pen',\n pencil: 'Pencil',\n marker: 'Marker',\n highlighter: 'Highlighter',\n calligraphy: 'Calligraphy',\n};\nconst SWATCHES = [\n '#1f2720',\n '#495057',\n '#e03131',\n '#f08c00',\n '#f2c200',\n '#2f9e44',\n '#1971c2',\n '#7048e8',\n '#e64980',\n '#ffffff',\n];\n\nfunction createSvgEl(name, attrs) {\n const el = document.createElementNS(SVG_NS, name);\n if (attrs) for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, String(v));\n return el;\n}\n\nfunction createIcon(name) {\n const svg = createSvgEl('svg', {\n viewBox: '0 0 256 256',\n 'aria-hidden': 'true',\n focusable: 'false',\n });\n svg.classList.add('vd-draw-icon');\n svg.setAttribute('fill', 'currentColor');\n svg.appendChild(createSvgEl('path', { d: ICON_PATHS[name] || '' }));\n return svg;\n}\n\nfunction clearChildren(node) {\n if (node) node.replaceChildren();\n}\n\nfunction hasWindow() {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n\n// Normalize a color to 6-digit hex for the native <input type=color>, which\n// only accepts that form. Expands #rgb \u2192 #rrggbb; returns null for rgb()/named\n// colors (the picker keeps its prior value while the mark still uses the color).\nfunction toHex6(color) {\n if (typeof color !== 'string') return null;\n const value = color.trim();\n if (/^#[0-9a-fA-F]{6}$/.test(value)) return value.toLowerCase();\n const short = /^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(value);\n if (short)\n return `#${short[1]}${short[1]}${short[2]}${short[2]}${short[3]}${short[3]}`.toLowerCase();\n return null;\n}\n\nexport class VdDraw {\n constructor(options = {}) {\n const opts = options || {};\n this.element = this._resolveElement(opts.element ?? opts.target);\n if (!this.element) throw new Error('VdDraw: a target `element` is required');\n\n this.readonly = Boolean(opts.readonly);\n this.tool = DRAW_TOOLS.includes(opts.tool) ? opts.tool : 'draw';\n this.gridSize = Number.isFinite(opts.gridSize) ? opts.gridSize : DEFAULT_GRID_SIZE;\n this.showGrid = opts.showGrid == null ? true : Boolean(opts.showGrid);\n this.snap = opts.snap == null ? true : Boolean(opts.snap);\n this.autoFit = Boolean(opts.autoFit);\n this.historyEnabled = opts.history == null ? true : Boolean(opts.history);\n this.historyLimit = Number.isFinite(opts.historyLimit) ? opts.historyLimit : 100;\n\n this.style = {\n color: typeof opts.color === 'string' ? opts.color : '#1f2720',\n opacity: Number.isFinite(opts.opacity) ? clamp(opts.opacity, 0.05, 1) : 1,\n size: Number.isFinite(opts.brushSize) ? opts.brushSize : BRUSH_PRESETS[DEFAULT_BRUSH].size,\n brush: BRUSH_PRESETS[opts.brush] ? opts.brush : DEFAULT_BRUSH,\n };\n this.recentColors = [];\n\n this.documentData = normalizeDocument(opts.data);\n this.selectedIds = new Set();\n this.interaction = null;\n this.clipboard = [];\n this.textEditor = null;\n this.destroyed = false;\n\n this.history = [];\n this.historyIndex = -1;\n this.isApplyingHistory = false;\n this.lastReason = null;\n this.lastTargetKey = null;\n\n this.listeners = new Map();\n\n this._buildShell();\n if (typeof opts.color !== 'string') this.style.color = this._resolveInk();\n this._bindEvents();\n this._resetHistory();\n this.render();\n this._syncStylePanel();\n this._scheduleReady();\n }\n\n _resolveElement(target) {\n if (!target) return null;\n if (typeof target === 'string') return hasWindow() ? document.querySelector(target) : null;\n return target;\n }\n\n _resolveInk() {\n if (!hasWindow()) return '#1f2720';\n try {\n const v = getComputedStyle(this.svg).getPropertyValue('--vd-draw-ink').trim();\n return v || '#1f2720';\n } catch {\n return '#1f2720';\n }\n }\n\n // \u2500\u2500 Shell \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _buildShell() {\n const host = this.element;\n host.classList.add('vd-draw-host');\n clearChildren(host);\n\n const shell = document.createElement('div');\n shell.className = 'vd-draw-shell';\n\n this.toolbarEl = document.createElement('div');\n this.toolbarEl.className = 'vd-draw-toolbar';\n this.toolbarEl.setAttribute('role', 'toolbar');\n this.toolbarEl.setAttribute('aria-label', 'Drawing tools');\n\n this.panelEl = document.createElement('div');\n this.panelEl.className = 'vd-draw-panel';\n if (!this.readonly) {\n this._buildToolbar();\n this._buildStylePanel();\n }\n\n this.canvasEl = document.createElement('div');\n this.canvasEl.className = 'vd-draw-canvas';\n this.canvasEl.tabIndex = 0;\n\n this.svg = createSvgEl('svg', { class: 'vd-draw-svg' });\n this.svg.setAttribute('width', '100%');\n this.svg.setAttribute('height', '100%');\n\n const defs = createSvgEl('defs');\n const gs = this.gridSize;\n this.gridPattern = createSvgEl('pattern', {\n id: this._svgId('grid'),\n width: gs,\n height: gs,\n patternUnits: 'userSpaceOnUse',\n });\n this.gridPatternPath = createSvgEl('path', {\n d: `M ${gs} 0 L 0 0 0 ${gs}`,\n fill: 'none',\n stroke: 'var(--vd-draw-grid)',\n 'stroke-width': 1,\n });\n this.gridPattern.appendChild(this.gridPatternPath);\n defs.appendChild(this.gridPattern);\n const marker = createSvgEl('marker', {\n id: this._svgId('arrow'),\n viewBox: '0 0 10 10',\n refX: 8,\n refY: 5,\n markerWidth: 7,\n markerHeight: 7,\n orient: 'auto-start-reverse',\n });\n marker.appendChild(\n createSvgEl('path', { d: 'M 0 0 L 10 5 L 0 10 z', fill: 'var(--vd-draw-shape-stroke)' }),\n );\n defs.appendChild(marker);\n this.svg.appendChild(defs);\n\n this.world = createSvgEl('g', { class: 'vd-draw-world' });\n this.gridLayer = createSvgEl('rect', {\n class: 'vd-draw-grid-rect',\n x: -WORLD_EXTENT,\n y: -WORLD_EXTENT,\n width: WORLD_EXTENT * 2,\n height: WORLD_EXTENT * 2,\n fill: `url(#${this._svgId('grid')})`,\n });\n if (!this.showGrid) this.gridLayer.style.display = 'none';\n this.shapesLayer = createSvgEl('g', { class: 'vd-draw-shapes' });\n this.guidesLayer = createSvgEl('g', { class: 'vd-draw-guides' });\n this.overlayLayer = createSvgEl('g', { class: 'vd-draw-overlay' });\n this.marqueeLayer = createSvgEl('g', { class: 'vd-draw-marquee' });\n this.world.append(\n this.gridLayer,\n this.shapesLayer,\n this.guidesLayer,\n this.overlayLayer,\n this.marqueeLayer,\n );\n this.svg.appendChild(this.world);\n\n this.canvasEl.appendChild(this.svg);\n this.textLayer = document.createElement('div');\n this.textLayer.className = 'vd-draw-text-layer';\n this.canvasEl.appendChild(this.textLayer);\n\n shell.append(this.toolbarEl, this.panelEl, this.canvasEl);\n host.appendChild(shell);\n }\n\n _buildToolbar() {\n clearChildren(this.toolbarEl);\n const makeBtn = (name, label, attr, value, active) => {\n const btn = document.createElement('button');\n btn.type = 'button';\n btn.className = 'vd-draw-tool';\n btn.setAttribute(attr, value);\n btn.setAttribute('aria-label', label);\n btn.setAttribute('title', label);\n if (active) btn.setAttribute('aria-pressed', 'true');\n btn.appendChild(createIcon(name));\n return btn;\n };\n const tools = document.createElement('div');\n tools.className = 'vd-draw-toolbar-group';\n for (const t of TOOL_BUTTONS)\n tools.appendChild(makeBtn(t.tool, t.label, 'data-tool', t.tool, t.tool === this.tool));\n const actions = document.createElement('div');\n actions.className = 'vd-draw-toolbar-group';\n for (const a of ACTION_BUTTONS)\n actions.appendChild(makeBtn(a.action, a.label, 'data-action', a.action, false));\n this.toolbarEl.append(tools, actions);\n }\n\n _panelGroup(labelText, className = '') {\n const group = document.createElement('div');\n group.className = `vd-draw-panel-group${className ? ` ${className}` : ''}`;\n const label = document.createElement('span');\n label.className = 'vd-draw-panel-label';\n label.textContent = labelText;\n group.appendChild(label);\n return group;\n }\n\n _rangeInput(min, max, step, styleKey) {\n const input = document.createElement('input');\n input.type = 'range';\n input.min = String(min);\n input.max = String(max);\n input.step = String(step);\n input.setAttribute('data-style', styleKey);\n input.setAttribute('aria-label', styleKey);\n return input;\n }\n\n _buildStylePanel() {\n clearChildren(this.panelEl);\n\n // Brush presets\n const brushGroup = this._panelGroup('Brush');\n for (const key of BRUSH_ORDER) {\n const btn = document.createElement('button');\n btn.type = 'button';\n btn.className = 'vd-draw-brush';\n btn.setAttribute('data-brush', key);\n btn.setAttribute('title', BRUSH_LABELS[key]);\n btn.textContent = BRUSH_LABELS[key];\n brushGroup.appendChild(btn);\n }\n\n // Color\n const colorGroup = this._panelGroup('Color', 'vd-draw-swatches-group');\n for (const color of SWATCHES) {\n const sw = document.createElement('button');\n sw.type = 'button';\n sw.className = 'vd-draw-swatch';\n sw.setAttribute('data-swatch', color);\n sw.setAttribute('aria-label', `Color ${color}`);\n sw.setAttribute('title', color);\n sw.style.setProperty('--sw', color);\n colorGroup.appendChild(sw);\n }\n this.colorInput = document.createElement('input');\n this.colorInput.type = 'color';\n this.colorInput.className = 'vd-draw-color-input';\n this.colorInput.setAttribute('data-style', 'color');\n this.colorInput.setAttribute('aria-label', 'Custom color');\n this.colorInput.setAttribute('title', 'Custom color');\n colorGroup.appendChild(this.colorInput);\n\n // Size\n const sizeGroup = this._panelGroup('Size');\n this.sizeInput = this._rangeInput(1, 40, 1, 'size');\n this.sizeValue = document.createElement('span');\n this.sizeValue.className = 'vd-draw-value';\n sizeGroup.append(this.sizeInput, this.sizeValue);\n\n // Opacity\n const opacityGroup = this._panelGroup('Opacity');\n this.opacityInput = this._rangeInput(0.1, 1, 0.05, 'opacity');\n this.opacityValue = document.createElement('span');\n this.opacityValue.className = 'vd-draw-value';\n opacityGroup.append(this.opacityInput, this.opacityValue);\n\n // Grid\n const gridGroup = this._panelGroup('Grid');\n this.gridToggle = document.createElement('button');\n this.gridToggle.type = 'button';\n this.gridToggle.className = 'vd-draw-tool';\n this.gridToggle.setAttribute('data-grid', 'toggle');\n this.gridToggle.setAttribute('aria-label', 'Toggle grid');\n this.gridToggle.setAttribute('title', 'Toggle grid');\n this.gridToggle.appendChild(createIcon('grid'));\n this.gridSizeInput = this._rangeInput(4, 128, 4, 'grid');\n this.gridSizeInput.title = 'Grid cell size';\n gridGroup.append(this.gridToggle, this.gridSizeInput);\n\n // Recent colors (hidden until used)\n this.recentGroup = this._panelGroup('Recent', 'vd-draw-swatches-group');\n this.recentEl = document.createElement('span');\n this.recentEl.className = 'vd-draw-recent';\n this.recentGroup.appendChild(this.recentEl);\n\n this.panelEl.append(\n brushGroup,\n colorGroup,\n sizeGroup,\n opacityGroup,\n gridGroup,\n this.recentGroup,\n );\n }\n\n _svgId(suffix) {\n if (!this._idBase) this._idBase = createId('draw');\n return `${this._idBase}-${suffix}`;\n }\n\n _syncToolbar() {\n if (this.readonly || !this.toolbarEl) return;\n for (const btn of this.toolbarEl.querySelectorAll('[data-tool]')) {\n if (btn.getAttribute('data-tool') === this.tool) btn.setAttribute('aria-pressed', 'true');\n else btn.removeAttribute('aria-pressed');\n }\n }\n\n _syncStylePanel() {\n if (this.readonly || !this.panelEl) return;\n for (const btn of this.panelEl.querySelectorAll('[data-brush]')) {\n if (btn.getAttribute('data-brush') === this.style.brush)\n btn.setAttribute('aria-pressed', 'true');\n else btn.removeAttribute('aria-pressed');\n }\n if (this.colorInput) {\n const hex = toHex6(this.style.color);\n if (hex) this.colorInput.value = hex;\n }\n if (this.sizeInput) this.sizeInput.value = String(this.style.size);\n if (this.sizeValue) this.sizeValue.textContent = `${Math.round(this.style.size)}px`;\n if (this.opacityInput) this.opacityInput.value = String(this.style.opacity);\n if (this.opacityValue)\n this.opacityValue.textContent = `${Math.round(this.style.opacity * 100)}%`;\n if (this.gridToggle) {\n if (this.showGrid) this.gridToggle.setAttribute('aria-pressed', 'true');\n else this.gridToggle.removeAttribute('aria-pressed');\n }\n if (this.gridSizeInput) this.gridSizeInput.value = String(this.gridSize);\n for (const sw of this.panelEl.querySelectorAll('.vd-draw-swatch[data-swatch]')) {\n if (sw.getAttribute('data-swatch') === this.style.color)\n sw.setAttribute('aria-pressed', 'true');\n else sw.removeAttribute('aria-pressed');\n }\n if (this.recentEl && this.recentGroup) {\n clearChildren(this.recentEl);\n for (const color of this.recentColors) {\n const sw = document.createElement('button');\n sw.type = 'button';\n sw.className = 'vd-draw-swatch';\n sw.setAttribute('data-swatch', color);\n sw.setAttribute('aria-label', `Recent color ${color}`);\n sw.setAttribute('title', color);\n sw.style.setProperty('--sw', color);\n this.recentEl.appendChild(sw);\n }\n this.recentGroup.style.display = this.recentColors.length ? '' : 'none';\n }\n }\n\n // \u2500\u2500 Events \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _bindEvents() {\n this._onPointerDown = this._handlePointerDown.bind(this);\n this._onPointerMove = this._handlePointerMove.bind(this);\n this._onPointerUp = this._handlePointerUp.bind(this);\n this._onWheel = this._handleWheel.bind(this);\n this._onKeyDown = this._handleKeyDown.bind(this);\n this._onToolbarClick = this._handleToolbarClick.bind(this);\n this._onPanelClick = this._handlePanelClick.bind(this);\n this._onPanelInput = this._handlePanelInput.bind(this);\n this._onResize = this._handleResize.bind(this);\n\n this.canvasEl.addEventListener('pointerdown', this._onPointerDown);\n this.canvasEl.addEventListener('pointermove', this._onPointerMove);\n this.canvasEl.addEventListener('pointerup', this._onPointerUp);\n this.canvasEl.addEventListener('pointercancel', this._onPointerUp);\n this.canvasEl.addEventListener('wheel', this._onWheel, { passive: false });\n this.canvasEl.addEventListener('keydown', this._onKeyDown);\n this.toolbarEl.addEventListener('click', this._onToolbarClick);\n this.panelEl.addEventListener('click', this._onPanelClick);\n this.panelEl.addEventListener('input', this._onPanelInput);\n window.addEventListener('pointerup', this._onPointerUp);\n window.addEventListener('resize', this._onResize);\n }\n\n _unbindEvents() {\n this.canvasEl.removeEventListener('pointerdown', this._onPointerDown);\n this.canvasEl.removeEventListener('pointermove', this._onPointerMove);\n this.canvasEl.removeEventListener('pointerup', this._onPointerUp);\n this.canvasEl.removeEventListener('pointercancel', this._onPointerUp);\n this.canvasEl.removeEventListener('wheel', this._onWheel);\n this.canvasEl.removeEventListener('keydown', this._onKeyDown);\n this.toolbarEl.removeEventListener('click', this._onToolbarClick);\n this.panelEl.removeEventListener('click', this._onPanelClick);\n this.panelEl.removeEventListener('input', this._onPanelInput);\n window.removeEventListener('pointerup', this._onPointerUp);\n window.removeEventListener('resize', this._onResize);\n }\n\n on(event, callback) {\n if (!this.listeners.has(event)) this.listeners.set(event, new Set());\n this.listeners.get(event).add(callback);\n return this;\n }\n\n off(event, callback) {\n this.listeners.get(event)?.delete(callback);\n return this;\n }\n\n emit(event, payload) {\n const set = this.listeners.get(event);\n if (set) for (const cb of set) cb(payload);\n }\n\n // \u2500\u2500 Coordinate transforms \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _clientToLocal(clientX, clientY) {\n const rect = this.canvasEl.getBoundingClientRect();\n return { x: clientX - rect.left, y: clientY - rect.top };\n }\n\n _localToWorld(lx, ly) {\n const vp = this.documentData.viewport;\n return { x: (lx - vp.x) / vp.scale, y: (ly - vp.y) / vp.scale };\n }\n\n _clientToWorld(clientX, clientY) {\n const local = this._clientToLocal(clientX, clientY);\n return this._localToWorld(local.x, local.y);\n }\n\n scaleAround(factor, lx, ly) {\n const vp = this.documentData.viewport;\n const next = clamp(vp.scale * factor, MIN_SCALE, MAX_SCALE);\n const applied = next / vp.scale;\n vp.x = lx - (lx - vp.x) * applied;\n vp.y = ly - (ly - vp.y) * applied;\n vp.scale = next;\n return this;\n }\n\n // \u2500\u2500 Viewport \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n setViewport(patch) {\n const vp = this.documentData.viewport;\n if (patch && typeof patch === 'object') {\n if (Number.isFinite(patch.x)) vp.x = patch.x;\n if (Number.isFinite(patch.y)) vp.y = patch.y;\n if (Number.isFinite(patch.scale)) vp.scale = clamp(patch.scale, MIN_SCALE, MAX_SCALE);\n }\n this.render({ scene: false });\n this._emitViewportChange('viewport:set');\n return this;\n }\n\n zoomIn() {\n return this._zoomAtCentre(1.2);\n }\n\n zoomOut() {\n return this._zoomAtCentre(1 / 1.2);\n }\n\n _zoomAtCentre(factor) {\n const rect = this.canvasEl.getBoundingClientRect();\n this.scaleAround(factor, rect.width / 2, rect.height / 2);\n this.render({ scene: false });\n this._emitViewportChange('viewport:zoom');\n return this;\n }\n\n resetView() {\n this.documentData.viewport = { x: 0, y: 0, scale: 1 };\n this.render({ scene: false });\n this._emitViewportChange('viewport:reset');\n return this;\n }\n\n fitView() {\n const bounds = boundsOfShapes(this.documentData.shapes);\n const rect = this.canvasEl.getBoundingClientRect();\n if (!bounds || bounds.w === 0 || bounds.h === 0 || !rect.width || !rect.height) return this;\n const pad = 40;\n const scale = clamp(\n Math.min((rect.width - pad * 2) / bounds.w, (rect.height - pad * 2) / bounds.h),\n MIN_SCALE,\n MAX_SCALE,\n );\n const vp = this.documentData.viewport;\n vp.scale = scale;\n vp.x = (rect.width - bounds.w * scale) / 2 - bounds.x * scale;\n vp.y = (rect.height - bounds.h * scale) / 2 - bounds.y * scale;\n this.render({ scene: false });\n this._emitViewportChange('viewport:fit');\n return this;\n }\n\n _emitViewportChange(reason) {\n this.emit('viewport', {\n reason,\n viewport: { ...this.documentData.viewport },\n document: this.toJSON(),\n });\n }\n\n // \u2500\u2500 Grid \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n setGridSize(size) {\n if (!Number.isFinite(size)) return this;\n this.gridSize = clamp(Math.round(size), 4, 128);\n if (this.gridPattern) {\n this.gridPattern.setAttribute('width', String(this.gridSize));\n this.gridPattern.setAttribute('height', String(this.gridSize));\n this.gridPatternPath.setAttribute('d', `M ${this.gridSize} 0 L 0 0 0 ${this.gridSize}`);\n }\n this._syncStylePanel();\n return this;\n }\n\n setGridVisible(visible) {\n this.showGrid = Boolean(visible);\n if (this.gridLayer) this.gridLayer.style.display = this.showGrid ? '' : 'none';\n this._syncStylePanel();\n return this;\n }\n\n toggleGrid() {\n return this.setGridVisible(!this.showGrid);\n }\n\n // \u2500\u2500 Tool + current style \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n setTool(tool) {\n if (!DRAW_TOOLS.includes(tool)) return this;\n this.tool = tool;\n this._syncToolbar();\n return this;\n }\n\n setColor(color) {\n if (typeof color !== 'string') return this;\n this.style.color = color;\n this._pushRecent(color);\n this._syncStylePanel();\n return this;\n }\n\n setOpacity(opacity) {\n if (Number.isFinite(opacity)) this.style.opacity = clamp(opacity, 0.05, 1);\n this._syncStylePanel();\n return this;\n }\n\n setBrushSize(size) {\n if (Number.isFinite(size)) this.style.size = clamp(size, 1, 200);\n this._syncStylePanel();\n return this;\n }\n\n setBrush(brush) {\n if (BRUSH_PRESETS[brush]) this.style.brush = brush;\n this._syncStylePanel();\n return this;\n }\n\n _pushRecent(color) {\n this.recentColors = [color, ...this.recentColors.filter((c) => c !== color)].slice(0, 8);\n }\n\n _shapeStrokeWidth() {\n return clamp(round(this.style.size / 3), 1, 14);\n }\n\n // \u2500\u2500 Shape CRUD \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n getShape(id) {\n return this.documentData.shapes.find((s) => s.id === id) || null;\n }\n\n getShapes() {\n // Deep clone so callers cannot mutate live document objects without updateShape.\n return this.documentData.shapes.map((s) => deepClone(s));\n }\n\n addShape(partial = {}) {\n const type = DRAW_SHAPE_TYPES.includes(partial.type) ? partial.type : 'rectangle';\n const s = this.style;\n let shape;\n if (type === 'freehand') {\n const points = Array.isArray(partial.points)\n ? partial.points.map((p) => this._roundPoint(p))\n : [];\n shape = {\n id: partial.id || createId('fh'),\n type: 'freehand',\n brush: BRUSH_PRESETS[partial.brush] ? partial.brush : s.brush,\n color: partial.color || s.color,\n size: partial.size == null ? s.size : partial.size,\n opacity: partial.opacity == null ? s.opacity : partial.opacity,\n points,\n };\n } else if (type === 'line') {\n const points = Array.isArray(partial.points)\n ? partial.points.map(([x, y]) => [round(x), round(y)])\n : [];\n shape = {\n id: partial.id || createId('ln'),\n type: 'line',\n points,\n color: partial.color || s.color,\n strokeWidth: partial.strokeWidth == null ? this._shapeStrokeWidth() : partial.strokeWidth,\n opacity: partial.opacity == null ? s.opacity : partial.opacity,\n arrowStart: Boolean(partial.arrowStart),\n arrowEnd: partial.arrowEnd == null ? true : Boolean(partial.arrowEnd),\n // AI-authored multi-point curves set smooth:true; interactive 2-pt lines stay sharp.\n smooth: partial.smooth == null ? false : Boolean(partial.smooth),\n };\n } else {\n shape = {\n id: partial.id || createId(type.slice(0, 2)),\n type,\n x: round(partial.x ?? 0),\n y: round(partial.y ?? 0),\n w: round(Math.max(1, partial.w ?? 100)),\n h: round(Math.max(1, partial.h ?? 80)),\n rotation: partial.rotation ?? 0,\n color: partial.color || s.color,\n strokeWidth: partial.strokeWidth == null ? this._shapeStrokeWidth() : partial.strokeWidth,\n opacity: partial.opacity == null ? s.opacity : partial.opacity,\n };\n if (partial.fill) shape.fill = partial.fill;\n if (type === 'text' || type === 'sticky')\n shape.text = typeof partial.text === 'string' ? partial.text : '';\n }\n this.documentData.shapes.push(shape);\n this.render();\n this._emitChange('shape:add', { shape: deepClone(shape), shapeId: shape.id });\n return shape;\n }\n\n _roundPoint(p) {\n const out = [round(p[0]), round(p[1])];\n if (p.length >= 3 && p[2] != null) out.push(clamp(Number(p[2]) || 0, 0, 1));\n return out;\n }\n\n updateShape(id, patch, options = {}) {\n const shape = this.getShape(id);\n if (!shape || !patch) return null;\n Object.assign(shape, patch);\n this.render();\n this._emitChange(options.reason || 'shape:update', { shapeId: id }, options.reason ? id : null);\n return shape;\n }\n\n removeShape(id) {\n const idx = this.documentData.shapes.findIndex((s) => s.id === id);\n if (idx === -1) return false;\n this.documentData.shapes.splice(idx, 1);\n this.selectedIds.delete(id);\n this.render();\n this._emitChange('shape:delete', { shapeId: id });\n return true;\n }\n\n // \u2500\u2500 Selection \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n getSelectedShapes() {\n return this.documentData.shapes.filter((s) => this.selectedIds.has(s.id));\n }\n\n select(ids, { additive = false } = {}) {\n const list = Array.isArray(ids) ? ids : ids == null ? [] : [ids];\n if (!additive) this.selectedIds.clear();\n for (const id of list) {\n const shape = this.getShape(id);\n if (shape?.groupId) {\n for (const s of this.documentData.shapes)\n if (s.groupId === shape.groupId) this.selectedIds.add(s.id);\n } else if (shape) {\n this.selectedIds.add(id);\n }\n }\n this.render({ scene: false });\n this._emitSelect();\n return this;\n }\n\n selectAll() {\n this.selectedIds = new Set(this.documentData.shapes.map((s) => s.id));\n this.render({ scene: false });\n this._emitSelect();\n return this;\n }\n\n deselect() {\n if (this.selectedIds.size === 0) return this;\n this.selectedIds.clear();\n this.render({ scene: false });\n this._emitSelect();\n return this;\n }\n\n selectInBounds(box, { additive = false } = {}) {\n if (!additive) this.selectedIds.clear();\n for (const shape of this.documentData.shapes) {\n if (boundsIntersect(shapeBounds(shape), box)) this.selectedIds.add(shape.id);\n }\n for (const shape of [...this.getSelectedShapes()]) {\n if (shape.groupId)\n for (const s of this.documentData.shapes)\n if (s.groupId === shape.groupId) this.selectedIds.add(s.id);\n }\n this.render({ scene: false });\n this._emitSelect();\n return this;\n }\n\n _emitSelect() {\n this.emit('select', {\n ids: [...this.selectedIds],\n shapes: this.getSelectedShapes().map((s) => deepClone(s)),\n });\n }\n\n _syncSelectionValidity() {\n const present = new Set(this.documentData.shapes.map((s) => s.id));\n for (const id of [...this.selectedIds]) if (!present.has(id)) this.selectedIds.delete(id);\n }\n\n // \u2500\u2500 Manipulation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _replaceShape(next) {\n const idx = this.documentData.shapes.findIndex((s) => s.id === next.id);\n if (idx !== -1) this.documentData.shapes[idx] = next;\n }\n\n nudge(dx, dy) {\n const selected = this.getSelectedShapes();\n if (!selected.length) return this;\n for (const shape of selected) this._replaceShape(translateShape(shape, dx, dy));\n this.render();\n this._emitChange(\n 'shape:nudge',\n { shapeIds: [...this.selectedIds] },\n `nudge:${[...this.selectedIds].sort().join(',')}`,\n );\n return this;\n }\n\n setSelectionBounds(target) {\n const selected = this.getSelectedShapes();\n const cur = boundsOfShapes(selected);\n if (!cur || cur.w === 0 || cur.h === 0 || !target) return this;\n const sx = target.w / cur.w;\n const sy = target.h / cur.h;\n for (const shape of selected) {\n const scaled = scaleShape(shape, cur.x, cur.y, sx, sy);\n this._replaceShape(translateShape(scaled, target.x - cur.x, target.y - cur.y));\n }\n this.render();\n this._emitChange('shape:resize', { shapeIds: [...this.selectedIds] });\n return this;\n }\n\n deleteSelection() {\n if (this.selectedIds.size === 0) return false;\n const ids = [...this.selectedIds];\n this.documentData.shapes = this.documentData.shapes.filter((s) => !this.selectedIds.has(s.id));\n this.selectedIds.clear();\n this.render();\n this._emitChange('shape:delete', { shapeIds: ids });\n return true;\n }\n\n setStyle(patch) {\n const selected = this.getSelectedShapes();\n if (!selected.length || !patch) return this;\n const allowed = ['color', 'fill', 'strokeWidth', 'opacity', 'size', 'brush'];\n for (const shape of selected) {\n for (const key of allowed) if (key in patch) shape[key] = patch[key];\n }\n this.render();\n this._emitChange(\n 'shape:style',\n { shapeIds: [...this.selectedIds] },\n `style:${[...this.selectedIds].sort().join(',')}`,\n );\n return this;\n }\n\n // \u2500\u2500 Z-order \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _reorder(mutator) {\n if (this.selectedIds.size === 0) return this;\n mutator();\n this.render();\n this._emitChange('shape:reorder', { shapeIds: [...this.selectedIds] });\n return this;\n }\n\n bringToFront() {\n return this._reorder(() => {\n const sel = this.documentData.shapes.filter((s) => this.selectedIds.has(s.id));\n const rest = this.documentData.shapes.filter((s) => !this.selectedIds.has(s.id));\n this.documentData.shapes = [...rest, ...sel];\n });\n }\n\n sendToBack() {\n return this._reorder(() => {\n const sel = this.documentData.shapes.filter((s) => this.selectedIds.has(s.id));\n const rest = this.documentData.shapes.filter((s) => !this.selectedIds.has(s.id));\n this.documentData.shapes = [...sel, ...rest];\n });\n }\n\n bringForward() {\n return this._reorder(() => {\n const arr = this.documentData.shapes;\n for (let i = arr.length - 2; i >= 0; i -= 1) {\n if (this.selectedIds.has(arr[i].id) && !this.selectedIds.has(arr[i + 1].id))\n [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]];\n }\n });\n }\n\n sendBackward() {\n return this._reorder(() => {\n const arr = this.documentData.shapes;\n for (let i = 1; i < arr.length; i += 1) {\n if (this.selectedIds.has(arr[i].id) && !this.selectedIds.has(arr[i - 1].id))\n [arr[i], arr[i - 1]] = [arr[i - 1], arr[i]];\n }\n });\n }\n\n // \u2500\u2500 Grouping \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n group() {\n const selected = this.getSelectedShapes();\n if (selected.length < 2) return this;\n const groupId = createId('grp');\n for (const shape of selected) shape.groupId = groupId;\n this.render();\n this._emitChange('shape:group', { groupId, shapeIds: [...this.selectedIds] });\n return this;\n }\n\n ungroup() {\n const selected = this.getSelectedShapes();\n let changed = false;\n for (const shape of selected) {\n if (shape.groupId) {\n delete shape.groupId;\n changed = true;\n }\n }\n if (!changed) return this;\n this.render();\n this._emitChange('shape:ungroup', { shapeIds: [...this.selectedIds] });\n return this;\n }\n\n // \u2500\u2500 Clipboard \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n copy() {\n this.clipboard = this.getSelectedShapes().map((s) => deepClone(s));\n return this;\n }\n\n cut() {\n this.copy();\n this.deleteSelection();\n return this;\n }\n\n paste({ offset = 16 } = {}) {\n if (!this.clipboard.length) return this;\n const groupRemap = new Map();\n const newIds = [];\n for (const src of this.clipboard) {\n const copy = translateShape(deepClone(src), offset, offset);\n copy.id = createId(copy.type.slice(0, 2));\n if (copy.groupId) {\n if (!groupRemap.has(copy.groupId)) groupRemap.set(copy.groupId, createId('grp'));\n copy.groupId = groupRemap.get(copy.groupId);\n }\n this.documentData.shapes.push(copy);\n newIds.push(copy.id);\n }\n this.selectedIds = new Set(newIds);\n this.render();\n this._emitChange('shape:paste', { shapeIds: newIds });\n this._emitSelect();\n return this;\n }\n\n duplicate() {\n this.copy();\n this.paste();\n return this;\n }\n\n // \u2500\u2500 Snapping \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _computeSnap(movingBounds, movingIds) {\n if (!this.snap) return { dx: 0, dy: 0, guides: [] };\n const threshold = SNAP_THRESHOLD / this.documentData.viewport.scale;\n const targetsX = [\n movingBounds.x,\n movingBounds.x + movingBounds.w / 2,\n movingBounds.x + movingBounds.w,\n ];\n const targetsY = [\n movingBounds.y,\n movingBounds.y + movingBounds.h / 2,\n movingBounds.y + movingBounds.h,\n ];\n let bestX = null;\n let bestY = null;\n const guides = [];\n for (const other of this.documentData.shapes) {\n if (movingIds.has(other.id)) continue;\n const b = shapeBounds(other);\n for (const t of targetsX)\n for (const l of [b.x, b.x + b.w / 2, b.x + b.w]) {\n const d = l - t;\n if (Math.abs(d) <= threshold && (!bestX || Math.abs(d) < Math.abs(bestX.d)))\n bestX = { d, at: l };\n }\n for (const t of targetsY)\n for (const l of [b.y, b.y + b.h / 2, b.y + b.h]) {\n const d = l - t;\n if (Math.abs(d) <= threshold && (!bestY || Math.abs(d) < Math.abs(bestY.d)))\n bestY = { d, at: l };\n }\n }\n if (bestX) guides.push({ x1: bestX.at, y1: -WORLD_EXTENT, x2: bestX.at, y2: WORLD_EXTENT });\n if (bestY) guides.push({ x1: -WORLD_EXTENT, y1: bestY.at, x2: WORLD_EXTENT, y2: bestY.at });\n return { dx: bestX ? bestX.d : 0, dy: bestY ? bestY.d : 0, guides };\n }\n\n // \u2500\u2500 Export \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _resolvedColors() {\n const cs = hasWindow() ? getComputedStyle(this.svg) : null;\n const read = (name, fallback) => {\n const v = cs?.getPropertyValue(name)?.trim();\n return v || fallback;\n };\n return {\n ink: read('--vd-draw-ink', '#1f2720'),\n shapeStroke: read('--vd-draw-shape-stroke', '#245f52'),\n text: read('--vd-draw-text', '#1f2720'),\n sticky: read('--vd-draw-sticky-fill', '#fdf3c4'),\n };\n }\n\n toSVG() {\n const shapes = this.documentData.shapes;\n const bounds = boundsOfShapes(shapes) || { x: 0, y: 0, w: 100, h: 100 };\n const pad = 20;\n const vb = {\n x: bounds.x - pad,\n y: bounds.y - pad,\n w: Math.max(1, bounds.w) + pad * 2,\n h: Math.max(1, bounds.h) + pad * 2,\n };\n const colors = this._resolvedColors();\n const svg = createSvgEl('svg', {\n xmlns: SVG_NS,\n width: round(vb.w),\n height: round(vb.h),\n viewBox: `${round(vb.x)} ${round(vb.y)} ${round(vb.w)} ${round(vb.h)}`,\n });\n for (const shape of shapes) {\n const el = this._renderShapeEl(shape, { standalone: true, colors });\n if (el) svg.appendChild(el);\n }\n return new XMLSerializer().serializeToString(svg);\n }\n\n toPNG({ scale = 2 } = {}) {\n const markup = this.toSVG();\n const bounds = boundsOfShapes(this.documentData.shapes) || { w: 100, h: 100 };\n const pad = 20;\n const w = Math.max(1, (bounds.w || 100) + pad * 2);\n const h = Math.max(1, (bounds.h || 100) + pad * 2);\n return new Promise((resolve, reject) => {\n try {\n const img = new Image();\n const url = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`;\n img.onload = () => {\n const canvas = document.createElement('canvas');\n canvas.width = Math.ceil(w * scale);\n canvas.height = Math.ceil(h * scale);\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n reject(new Error('VdDraw: 2D canvas context unavailable'));\n return;\n }\n ctx.drawImage(img, 0, 0, canvas.width, canvas.height);\n resolve(canvas.toDataURL('image/png'));\n };\n img.onerror = () => reject(new Error('VdDraw: failed to rasterize SVG'));\n img.src = url;\n } catch (err) {\n reject(err);\n }\n });\n }\n\n // \u2500\u2500 History \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _resetHistory() {\n this.history = [this.toJSON()];\n this.historyIndex = 0;\n this.lastReason = null;\n this.lastTargetKey = null;\n }\n\n _recordHistory(reason, targetKey) {\n if (!this.historyEnabled || this.isApplyingHistory) return;\n const snapshot = this.toJSON();\n const coalesce =\n COALESCE_REASONS.has(reason) &&\n reason === this.lastReason &&\n targetKey != null &&\n targetKey === this.lastTargetKey &&\n this.historyIndex >= 0 &&\n // Only coalesce onto the TOP of the stack. Without this guard a\n // coalescing edit made right after an undo overwrites an earlier\n // (non-top) snapshot, corrupting the redo branch and losing base state.\n // Mirrors the flowchart core's canCoalesce guard.\n this.historyIndex === this.history.length - 1;\n if (coalesce) {\n this.history[this.historyIndex] = snapshot;\n } else {\n this.history = this.history.slice(0, this.historyIndex + 1);\n this.history.push(snapshot);\n this.historyIndex = this.history.length - 1;\n if (this.history.length > this.historyLimit + 1) {\n this.history.shift();\n this.historyIndex -= 1;\n }\n }\n this.lastReason = reason;\n this.lastTargetKey = targetKey ?? null;\n }\n\n _emitChange(reason, extra = {}, targetKey = null) {\n this._recordHistory(reason, targetKey);\n this._syncSelectionValidity();\n this.emit('change', { reason, document: this.toJSON(), ...extra });\n }\n\n canUndo() {\n return this.historyIndex > 0;\n }\n\n canRedo() {\n return this.historyIndex < this.history.length - 1;\n }\n\n undo() {\n if (!this.canUndo()) return this;\n this.historyIndex -= 1;\n this._applySnapshot(this.history[this.historyIndex], 'undo');\n return this;\n }\n\n redo() {\n if (!this.canRedo()) return this;\n this.historyIndex += 1;\n this._applySnapshot(this.history[this.historyIndex], 'redo');\n return this;\n }\n\n clearHistory() {\n this._resetHistory();\n this.emit('history', { reason: 'clear', canUndo: false, canRedo: false });\n return this;\n }\n\n _applySnapshot(snapshot, reason) {\n this.isApplyingHistory = true;\n const viewport = { ...this.documentData.viewport };\n this.documentData = deepClone(snapshot);\n this.documentData.viewport = viewport;\n this._syncSelectionValidity();\n this.render();\n this.emit('change', { reason, document: this.toJSON() });\n this.emit('history', { reason, canUndo: this.canUndo(), canRedo: this.canRedo() });\n this.isApplyingHistory = false;\n }\n\n // \u2500\u2500 Serialization \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n toJSON() {\n return deepClone({\n version: VD_DRAW_VERSION,\n viewport: this.documentData.viewport,\n shapes: this.documentData.shapes,\n });\n }\n\n load(data) {\n this.documentData = normalizeDocument(data);\n this.selectedIds.clear();\n this._resetHistory();\n this.render();\n this._emitChange('load');\n this._emitSelect();\n return this;\n }\n\n clear() {\n if (!this.documentData.shapes.length) return this;\n this.documentData.shapes = [];\n this.selectedIds.clear();\n this.render();\n this._emitChange('clear');\n return this;\n }\n\n // \u2500\u2500 Text editing \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n startTextEdit(id) {\n const shape = this.getShape(id);\n if (!shape || (shape.type !== 'text' && shape.type !== 'sticky') || this.readonly) return false;\n this.stopTextEdit({ commit: false });\n const editor = document.createElement('textarea');\n editor.className = 'vd-draw-text-editor';\n editor.value = shape.text || '';\n this.textEditor = { id, el: editor };\n this._positionTextEditor(shape, editor);\n this.textLayer.appendChild(editor);\n editor.focus();\n editor.addEventListener('blur', () => this.stopTextEdit({ commit: true }));\n editor.addEventListener('keydown', (e) => {\n if (e.key === 'Escape') this.stopTextEdit({ commit: false });\n });\n return true;\n }\n\n _positionTextEditor(shape, editor) {\n const vp = this.documentData.viewport;\n editor.style.left = `${vp.x + shape.x * vp.scale}px`;\n editor.style.top = `${vp.y + shape.y * vp.scale}px`;\n editor.style.width = `${shape.w * vp.scale}px`;\n editor.style.height = `${shape.h * vp.scale}px`;\n }\n\n stopTextEdit({ commit = true } = {}) {\n if (!this.textEditor) return;\n const { id, el } = this.textEditor;\n const value = el.value;\n this.textEditor = null;\n el.remove();\n if (commit) {\n const shape = this.getShape(id);\n if (shape && shape.text !== value) {\n shape.text = value;\n this.render();\n this._emitChange('shape:text', { shapeId: id }, `text:${id}`);\n }\n }\n }\n\n // \u2500\u2500 Pointer interaction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _capture(pointerId) {\n if (typeof this.canvasEl.setPointerCapture === 'function') {\n try {\n this.canvasEl.setPointerCapture(pointerId);\n } catch {\n /* jsdom / unsupported \u2014 safe to ignore */\n }\n }\n }\n\n _handleToolbarClick(event) {\n const toolBtn = event.target.closest('[data-tool]');\n if (toolBtn) {\n this.setTool(toolBtn.getAttribute('data-tool'));\n return;\n }\n const actionBtn = event.target.closest('[data-action]');\n if (!actionBtn) return;\n const action = actionBtn.getAttribute('data-action');\n if (action === 'undo') this.undo();\n else if (action === 'redo') this.redo();\n else if (action === 'duplicate') this.duplicate();\n else if (action === 'delete') {\n // Delete the selection, or clear the whole canvas when nothing is selected.\n if (this.selectedIds.size) this.deleteSelection();\n else this.clear();\n }\n }\n\n _handlePanelClick(event) {\n const brushBtn = event.target.closest('[data-brush]');\n if (brushBtn) {\n this.setBrush(brushBtn.getAttribute('data-brush'));\n if (this.tool !== 'draw') this.setTool('draw');\n return;\n }\n const gridBtn = event.target.closest('[data-grid]');\n if (gridBtn) {\n this.toggleGrid();\n return;\n }\n const swatch = event.target.closest('[data-swatch]');\n if (swatch) this.setColor(swatch.getAttribute('data-swatch'));\n }\n\n _handlePanelInput(event) {\n const kind = event.target.getAttribute?.('data-style');\n if (kind === 'color') this.setColor(event.target.value);\n else if (kind === 'size') this.setBrushSize(Number(event.target.value));\n else if (kind === 'opacity') this.setOpacity(Number(event.target.value));\n else if (kind === 'grid') this.setGridSize(Number(event.target.value));\n }\n\n _handlePointerDown(event) {\n if (this.destroyed || (event.button != null && event.button !== 0)) return;\n this.canvasEl.focus();\n this.stopTextEdit({ commit: true });\n const world = this._clientToWorld(event.clientX, event.clientY);\n const shapeTarget = event.target.closest('[data-shape-id]');\n const handleTarget = event.target.closest('[data-handle]');\n\n if (this.tool === 'hand') {\n this.interaction = this._beginPan(event);\n this._capture(event.pointerId);\n return;\n }\n\n if (this.tool === 'eraser' && !this.readonly) {\n this.interaction = { kind: 'erase', pointerId: event.pointerId, erased: new Set() };\n this._capture(event.pointerId);\n this._applyErase(world);\n return;\n }\n\n if (this.tool === 'select') {\n if (handleTarget && this.selectedIds.size) {\n this.interaction = {\n kind: 'resize',\n pointerId: event.pointerId,\n handle: handleTarget.getAttribute('data-handle'),\n startBounds: boundsOfShapes(this.getSelectedShapes()),\n originals: this.getSelectedShapes().map((s) => deepClone(s)),\n start: world,\n moved: false,\n };\n this._capture(event.pointerId);\n return;\n }\n if (shapeTarget) {\n const id = shapeTarget.getAttribute('data-shape-id');\n if (!this.selectedIds.has(id)) this.select(id, { additive: event.shiftKey });\n this.interaction = {\n kind: 'move',\n pointerId: event.pointerId,\n start: world,\n originals: this.getSelectedShapes().map((s) => deepClone(s)),\n moved: false,\n };\n this._capture(event.pointerId);\n return;\n }\n if (!event.shiftKey) this.deselect();\n this.interaction = {\n kind: 'marquee',\n pointerId: event.pointerId,\n start: world,\n additive: event.shiftKey,\n };\n this._capture(event.pointerId);\n return;\n }\n\n if (this.readonly) return;\n this.interaction = this._beginCreate(this.tool, world, event);\n this._capture(event.pointerId);\n }\n\n _beginPan(event) {\n return {\n kind: 'pan',\n pointerId: event.pointerId,\n startClientX: event.clientX,\n startClientY: event.clientY,\n startX: this.documentData.viewport.x,\n startY: this.documentData.viewport.y,\n };\n }\n\n _beginCreate(tool, world, event) {\n const pressure = event.pressure || 0.5;\n if (tool === 'draw') {\n const shape = {\n id: createId('fh'),\n type: 'freehand',\n brush: this.style.brush,\n color: this.style.color,\n size: this.style.size,\n opacity: this.style.opacity,\n points: [[round(world.x), round(world.y), pressure]],\n };\n this.documentData.shapes.push(shape);\n return { kind: 'freehand', pointerId: event.pointerId, shapeId: shape.id };\n }\n if (tool === 'line') {\n const shape = {\n id: createId('ln'),\n type: 'line',\n points: [\n [round(world.x), round(world.y)],\n [round(world.x), round(world.y)],\n ],\n arrowEnd: true,\n arrowStart: false,\n color: this.style.color,\n strokeWidth: this._shapeStrokeWidth(),\n opacity: this.style.opacity,\n };\n this.documentData.shapes.push(shape);\n return { kind: 'create-line', pointerId: event.pointerId, shapeId: shape.id };\n }\n const type = tool;\n const shape = {\n id: createId(type.slice(0, 2)),\n type,\n x: round(world.x),\n y: round(world.y),\n w: 1,\n h: 1,\n rotation: 0,\n color: this.style.color,\n strokeWidth: this._shapeStrokeWidth(),\n opacity: this.style.opacity,\n };\n if (type === 'text' || type === 'sticky') shape.text = '';\n this.documentData.shapes.push(shape);\n return { kind: 'create-box', pointerId: event.pointerId, shapeId: shape.id, start: world };\n }\n\n _applyErase(world) {\n const it = this.interaction;\n if (!it || it.kind !== 'erase') return;\n const threshold = ERASER_RADIUS / this.documentData.viewport.scale;\n let changed = false;\n for (const shape of this.documentData.shapes) {\n if (it.erased.has(shape.id)) continue;\n if (distanceToShape(shape, world.x, world.y) <= threshold) {\n it.erased.add(shape.id);\n changed = true;\n }\n }\n if (changed) this.render({ scene: true, overlay: false });\n }\n\n _handlePointerMove(event) {\n const it = this.interaction;\n if (!it) return;\n\n if (it.kind === 'pan') {\n const vp = this.documentData.viewport;\n vp.x = it.startX + (event.clientX - it.startClientX);\n vp.y = it.startY + (event.clientY - it.startClientY);\n this.render({ scene: false });\n return;\n }\n\n const world = this._clientToWorld(event.clientX, event.clientY);\n\n if (it.kind === 'erase') {\n this._applyErase(world);\n return;\n }\n\n if (it.kind === 'move') {\n const dx = world.x - it.start.x;\n const dy = world.y - it.start.y;\n if (Math.hypot(dx, dy) * this.documentData.viewport.scale > DRAG_THRESHOLD) it.moved = true;\n for (const orig of it.originals) this._replaceShape(translateShape(orig, dx, dy));\n const movingIds = new Set(it.originals.map((s) => s.id));\n const snap = this._computeSnap(boundsOfShapes(this.getSelectedShapes()), movingIds);\n if (snap.dx || snap.dy)\n for (const orig of it.originals)\n this._replaceShape(translateShape(orig, dx + snap.dx, dy + snap.dy));\n this._renderGuides(snap.guides);\n this.render({ scene: true, guides: false });\n return;\n }\n\n if (it.kind === 'resize') {\n const t = this._resizeBounds(\n it.startBounds,\n it.handle,\n world.x - it.start.x,\n world.y - it.start.y,\n );\n const sx = it.startBounds.w === 0 ? 1 : t.w / it.startBounds.w;\n const sy = it.startBounds.h === 0 ? 1 : t.h / it.startBounds.h;\n for (const orig of it.originals) {\n const scaled = scaleShape(orig, it.startBounds.x, it.startBounds.y, sx, sy);\n this._replaceShape(translateShape(scaled, t.x - it.startBounds.x, t.y - it.startBounds.y));\n }\n it.moved = true;\n this.render();\n return;\n }\n\n if (it.kind === 'marquee') {\n it.current = world;\n this._renderMarquee(it.start, world);\n return;\n }\n\n if (it.kind === 'freehand') {\n const shape = this.getShape(it.shapeId);\n if (shape) {\n shape.points.push([round(world.x), round(world.y), event.pressure || 0.5]);\n this.render({ scene: true });\n }\n return;\n }\n\n if (it.kind === 'create-line') {\n const shape = this.getShape(it.shapeId);\n if (shape) {\n shape.points[1] = [round(world.x), round(world.y)];\n this.render({ scene: true });\n }\n return;\n }\n\n if (it.kind === 'create-box') {\n const shape = this.getShape(it.shapeId);\n if (shape) {\n shape.x = round(Math.min(it.start.x, world.x));\n shape.y = round(Math.min(it.start.y, world.y));\n shape.w = round(Math.max(1, Math.abs(world.x - it.start.x)));\n shape.h = round(Math.max(1, Math.abs(world.y - it.start.y)));\n this.render({ scene: true });\n }\n }\n }\n\n _resizeBounds(start, handle, dx, dy) {\n let { x, y, w, h } = start;\n if (handle.includes('e')) w = Math.max(1, start.w + dx);\n if (handle.includes('s')) h = Math.max(1, start.h + dy);\n if (handle.includes('w')) {\n w = Math.max(1, start.w - dx);\n x = start.x + (start.w - w);\n }\n if (handle.includes('n')) {\n h = Math.max(1, start.h - dy);\n y = start.y + (start.h - h);\n }\n return { x, y, w, h };\n }\n\n _handlePointerUp(event) {\n const it = this.interaction;\n if (!it) return;\n this.interaction = null;\n if (\n typeof this.canvasEl.releasePointerCapture === 'function' &&\n this.canvasEl.hasPointerCapture?.(event.pointerId)\n ) {\n try {\n this.canvasEl.releasePointerCapture(event.pointerId);\n } catch {\n /* ignore */\n }\n }\n this._renderGuides([]);\n clearChildren(this.marqueeLayer);\n\n if (it.kind === 'pan') {\n this._emitViewportChange('viewport:pan');\n return;\n }\n if (it.kind === 'erase') {\n if (it.erased.size) {\n const ids = [...it.erased];\n this.documentData.shapes = this.documentData.shapes.filter((s) => !it.erased.has(s.id));\n this.render();\n this._emitChange('shape:erase', { shapeIds: ids });\n }\n return;\n }\n if (it.kind === 'move' && it.moved) {\n this.render();\n this._emitChange('shape:move', { shapeIds: [...this.selectedIds] });\n return;\n }\n if (it.kind === 'resize' && it.moved) {\n this.render();\n this._emitChange('shape:resize', { shapeIds: [...this.selectedIds] });\n return;\n }\n if (it.kind === 'marquee') {\n const box = this._boxFromPoints(it.start, it.current || it.start);\n this.selectInBounds(box, { additive: it.additive });\n return;\n }\n if (it.kind === 'freehand' || it.kind === 'create-line' || it.kind === 'create-box') {\n const shape = this.getShape(it.shapeId);\n if (!shape) return;\n if (it.kind === 'freehand') shape.points = simplifyPoints(shape.points);\n const b = shapeBounds(shape);\n if (\n it.kind !== 'freehand' &&\n b.w < 2 &&\n b.h < 2 &&\n shape.type !== 'text' &&\n shape.type !== 'sticky'\n ) {\n this.documentData.shapes = this.documentData.shapes.filter((s) => s.id !== it.shapeId);\n this.render();\n return;\n }\n if (shape.type === 'text' || shape.type === 'sticky') {\n if (b.w < 2 && b.h < 2) {\n shape.w = shape.type === 'sticky' ? 160 : 120;\n shape.h = shape.type === 'sticky' ? 120 : 40;\n }\n }\n if (it.kind !== 'freehand') {\n this.select(shape.id);\n this.setTool('select');\n }\n this.render();\n this._emitChange('shape:add', { shape: deepClone(shape), shapeId: shape.id });\n if (shape.type === 'text' || shape.type === 'sticky') this.startTextEdit(shape.id);\n }\n }\n\n _boxFromPoints(a, b) {\n return {\n x: Math.min(a.x, b.x),\n y: Math.min(a.y, b.y),\n w: Math.abs(a.x - b.x),\n h: Math.abs(a.y - b.y),\n };\n }\n\n _handleWheel(event) {\n event.preventDefault();\n const local = this._clientToLocal(event.clientX, event.clientY);\n const factor = event.deltaY < 0 ? 1.1 : 1 / 1.1;\n this.scaleAround(factor, local.x, local.y);\n this.render({ scene: false });\n this._emitViewportChange('viewport:zoom');\n }\n\n _handleKeyDown(event) {\n if (this.textEditor) return;\n const meta = event.metaKey || event.ctrlKey;\n if (meta && event.key.toLowerCase() === 'z') {\n event.preventDefault();\n if (event.shiftKey) this.redo();\n else this.undo();\n return;\n }\n if (meta && event.key.toLowerCase() === 'y') {\n event.preventDefault();\n this.redo();\n return;\n }\n if (meta && event.key.toLowerCase() === 'a') {\n event.preventDefault();\n this.selectAll();\n return;\n }\n if (meta && event.key.toLowerCase() === 'c') {\n this.copy();\n return;\n }\n if (meta && event.key.toLowerCase() === 'v') {\n this.paste();\n return;\n }\n if (meta && event.key.toLowerCase() === 'd') {\n event.preventDefault();\n this.duplicate();\n return;\n }\n if (this.readonly) return;\n if (event.key === 'Delete' || event.key === 'Backspace') {\n event.preventDefault();\n this.deleteSelection();\n return;\n }\n const nudgeMap = {\n ArrowLeft: [-1, 0],\n ArrowRight: [1, 0],\n ArrowUp: [0, -1],\n ArrowDown: [0, 1],\n };\n if (nudgeMap[event.key] && this.selectedIds.size) {\n event.preventDefault();\n const step = event.shiftKey ? 10 : 1;\n const [dx, dy] = nudgeMap[event.key];\n this.nudge(dx * step, dy * step);\n }\n }\n\n _handleResize() {\n if (this.destroyed) return;\n this.render({ scene: false });\n }\n\n // \u2500\u2500 Rendering \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n render(flags = {}) {\n if (this.destroyed) return;\n const { scene = true, overlay = true } = flags;\n const vp = this.documentData.viewport;\n this.world.setAttribute('transform', `matrix(${vp.scale} 0 0 ${vp.scale} ${vp.x} ${vp.y})`);\n if (scene) {\n clearChildren(this.shapesLayer);\n const erasing =\n this.interaction && this.interaction.kind === 'erase' ? this.interaction.erased : null;\n for (const shape of this.documentData.shapes) {\n if (erasing && erasing.has(shape.id)) continue;\n const el = this._renderShapeEl(shape, {});\n if (el) this.shapesLayer.appendChild(el);\n }\n }\n if (overlay) this._renderOverlay();\n }\n\n // Colors are applied via inline `style` (which wins over the CSS class rules\n // and serializes self-contained), so a picked color always renders.\n _renderShapeEl(shape, { standalone = false, colors = null }) {\n let el = null;\n const setOpacity = (node) => {\n if (shape.opacity != null && shape.opacity !== 1)\n node.setAttribute('opacity', String(shape.opacity));\n };\n\n if (shape.type === 'freehand') {\n el = createSvgEl('path', { d: brushStrokePath(shape) });\n el.classList.add('vd-draw-ink');\n el.style.stroke = 'none';\n const fill = shape.color || (standalone && colors ? colors.ink : '');\n if (fill) el.style.fill = fill;\n if (shape.opacity != null && shape.opacity !== 1)\n el.style.fillOpacity = String(shape.opacity);\n const preset = BRUSH_PRESETS[shape.brush];\n if (preset && preset.blend && preset.blend !== 'normal') el.style.mixBlendMode = preset.blend;\n } else if (shape.type === 'rectangle') {\n el = createSvgEl('rect', { x: shape.x, y: shape.y, width: shape.w, height: shape.h, rx: 4 });\n el.classList.add('vd-draw-shape');\n this._applyShapeStroke(el, shape, standalone, colors);\n setOpacity(el);\n } else if (shape.type === 'ellipse') {\n el = createSvgEl('ellipse', {\n cx: shape.x + shape.w / 2,\n cy: shape.y + shape.h / 2,\n rx: shape.w / 2,\n ry: shape.h / 2,\n });\n el.classList.add('vd-draw-shape');\n this._applyShapeStroke(el, shape, standalone, colors);\n setOpacity(el);\n } else if (shape.type === 'line') {\n el = createSvgEl('path', {\n d: pointsToPath(shape.points, { smooth: Boolean(shape.smooth) }),\n });\n el.classList.add('vd-draw-shape');\n this._applyShapeStroke(el, shape, standalone, colors);\n setOpacity(el);\n if (shape.arrowEnd) el.setAttribute('marker-end', `url(#${this._svgId('arrow')})`);\n if (shape.arrowStart) el.setAttribute('marker-start', `url(#${this._svgId('arrow')})`);\n } else if (shape.type === 'text' || shape.type === 'sticky') {\n el = createSvgEl('g');\n setOpacity(el);\n if (shape.type === 'sticky') {\n const bg = createSvgEl('rect', {\n x: shape.x,\n y: shape.y,\n width: shape.w,\n height: shape.h,\n rx: 4,\n });\n bg.classList.add('vd-draw-sticky');\n if (shape.fill) bg.style.fill = shape.fill;\n else if (standalone && colors) bg.style.fill = colors.sticky;\n el.appendChild(bg);\n }\n const text = createSvgEl('text', { x: shape.x + 6, y: shape.y + 18 });\n text.classList.add('vd-draw-text');\n const fill = shape.color || (standalone && colors ? colors.text : '');\n if (fill) text.style.fill = fill;\n text.textContent = shape.text || '';\n el.appendChild(text);\n }\n if (el && !standalone) el.setAttribute('data-shape-id', shape.id);\n return el;\n }\n\n _applyShapeStroke(el, shape, standalone, colors) {\n const stroke = shape.color || (standalone && colors ? colors.shapeStroke : '');\n if (stroke) el.style.stroke = stroke;\n if (shape.strokeWidth != null) el.setAttribute('stroke-width', String(shape.strokeWidth));\n el.style.fill = shape.fill ? shape.fill : 'none';\n }\n\n _renderOverlay() {\n clearChildren(this.overlayLayer);\n const selected = this.getSelectedShapes();\n if (!selected.length || this.readonly) return;\n const bounds = boundsOfShapes(selected);\n if (!bounds) return;\n const box = createSvgEl('rect', {\n class: 'vd-draw-selection-box',\n x: bounds.x,\n y: bounds.y,\n width: bounds.w,\n height: bounds.h,\n fill: 'none',\n });\n box.setAttribute('vector-effect', 'non-scaling-stroke');\n this.overlayLayer.appendChild(box);\n const scale = this.documentData.viewport.scale || 1;\n const r = HANDLE_SIZE / scale / 2;\n for (const handle of resizeHandlePositions(bounds)) {\n const dot = createSvgEl('rect', {\n class: 'vd-draw-handle',\n x: handle.x - r,\n y: handle.y - r,\n width: r * 2,\n height: r * 2,\n 'data-handle': handle.key,\n });\n dot.setAttribute('vector-effect', 'non-scaling-stroke');\n this.overlayLayer.appendChild(dot);\n }\n }\n\n _renderMarquee(a, b) {\n clearChildren(this.marqueeLayer);\n const box = this._boxFromPoints(a, b);\n const rect = createSvgEl('rect', {\n class: 'vd-draw-marquee-rect',\n x: box.x,\n y: box.y,\n width: box.w,\n height: box.h,\n });\n rect.setAttribute('vector-effect', 'non-scaling-stroke');\n this.marqueeLayer.appendChild(rect);\n }\n\n _renderGuides(guides) {\n clearChildren(this.guidesLayer);\n for (const g of guides || []) {\n const line = createSvgEl('line', {\n class: 'vd-draw-guide',\n x1: g.x1,\n y1: g.y1,\n x2: g.x2,\n y2: g.y2,\n });\n line.setAttribute('vector-effect', 'non-scaling-stroke');\n this.guidesLayer.appendChild(line);\n }\n }\n\n // \u2500\u2500 Ready + lifecycle \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n _scheduleReady() {\n const fire = () => {\n if (this.destroyed || this._ready) return;\n this._ready = true;\n if (this.autoFit) this.fitView();\n this.emit('ready', this);\n };\n if (typeof requestAnimationFrame === 'function') requestAnimationFrame(fire);\n else setTimeout(fire, 0);\n }\n\n destroy() {\n if (this.destroyed) return;\n this.destroyed = true;\n this.stopTextEdit({ commit: false });\n this._unbindEvents();\n this.listeners.clear();\n if (this.element) this.element.replaceChildren();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAAA;AAAA,EAAA;AAAA;AAAA;;;ACUA,iBAA2E;;;ACFpE,IAAM,kBAAkB;AAGxB,IAAM,aAAa,OAAO,OAAO;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,mBAAmB,OAAO,OAAO;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAQM,IAAM,gBAAgB,OAAO,OAAO;AAAA,EACzC,KAAK;AAAA,IACH,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AAAA,EACA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AAAA,EACA,aAAa;AA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