@widgetic/canvas 0.5.41 → 0.5.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +1 -0
  2. package/dist/canvas/DomCanvas.svelte +49 -20
  3. package/dist/canvas/DomCanvas.svelte.d.ts +13 -7
  4. package/dist/canvas/autosaveScheduler.js +37 -89
  5. package/dist/canvas/boardFrame.js +1 -1
  6. package/dist/canvas/boardSurface.js +1 -1
  7. package/dist/canvas/canvasLogger.js +7 -19
  8. package/dist/canvas/chromeLayout.d.ts +14 -3
  9. package/dist/canvas/chromeLayout.js +30 -20
  10. package/dist/canvas/eventScope.js +10 -14
  11. package/dist/canvas/host/CanvasHost.d.ts +47 -5
  12. package/dist/canvas/host/CanvasHost.js +1481 -1566
  13. package/dist/canvas/host/CanvasHostApi.js +4 -19
  14. package/dist/canvas/host/browserServices.js +65 -116
  15. package/dist/canvas/host/conversion.js +82 -170
  16. package/dist/canvas/host/hostObject.js +7 -7
  17. package/dist/canvas/host/nearCards.d.ts +33 -0
  18. package/dist/canvas/host/nearCards.js +78 -0
  19. package/dist/canvas/host/pageEvents.d.ts +16 -4
  20. package/dist/canvas/host/pageEvents.js +17 -8
  21. package/dist/canvas/host/pictureSaves.d.ts +33 -0
  22. package/dist/canvas/host/pictureSaves.js +42 -0
  23. package/dist/canvas/host/screenRects.d.ts +5 -0
  24. package/dist/canvas/host/screenRects.js +28 -31
  25. package/dist/canvas/host/storedPictures.d.ts +88 -0
  26. package/dist/canvas/host/storedPictures.js +288 -0
  27. package/dist/canvas/host/strokeSnap.js +88 -143
  28. package/dist/canvas/index.d.ts +1 -1
  29. package/dist/canvas/index.js +1 -1
  30. package/dist/canvas/openMarks.js +2 -2
  31. package/dist/canvas/outsideClickDeselect.js +6 -7
  32. package/dist/canvas/panZoomPosition.js +2 -2
  33. package/dist/canvas/preferredTextFont.js +13 -25
  34. package/dist/canvas/shapes/ShapeLibrary.js +138 -148
  35. package/dist/canvas/shapes/shapeImageStore.d.ts +45 -2
  36. package/dist/canvas/shapes/shapeImageStore.js +10 -3
  37. package/dist/canvas/shapes/strokeShapeSnap.js +188 -233
  38. package/dist/canvas/toolbarPosition.d.ts +2 -2
  39. package/dist/canvas/toolbarPosition.js +4 -4
  40. package/dist/canvas/ui/SelectionPanel.svelte +28 -5
  41. package/dist/canvas/ui/SelectionPanel.svelte.d.ts +7 -0
  42. package/dist/canvas/ui/SelectorIndicator.svelte +81 -0
  43. package/dist/canvas/ui/SelectorIndicator.svelte.d.ts +11 -0
  44. package/dist/canvas/ui/ToolButton.svelte +8 -2
  45. package/dist/canvas/ui/colorModel.js +21 -32
  46. package/dist/canvas/ui/colorPickerMessages.js +5 -5
  47. package/dist/canvas/ui/floatingCard.d.ts +2 -2
  48. package/dist/canvas/ui/floatingCard.js +20 -20
  49. package/dist/canvas/ui/floatingLayer.d.ts +13 -2
  50. package/dist/canvas/ui/floatingLayer.js +18 -7
  51. package/dist/canvas/ui/keyHints.js +9 -11
  52. package/dist/canvas/ui/popoverSide.js +2 -3
  53. package/dist/canvas/ui/selectionTraits.js +34 -40
  54. package/dist/canvas/view/CanvasStage.svelte +101 -67
  55. package/dist/canvas/view/LeftToRightScope.svelte +21 -0
  56. package/dist/canvas/view/LeftToRightScope.svelte.d.ts +7 -0
  57. package/dist/canvas/view/ObjectView.svelte +15 -10
  58. package/dist/canvas/view/ObjectView.svelte.d.ts +1 -1
  59. package/dist/canvas/view/erasingMarks.js +7 -7
  60. package/dist/canvas/view/geometry.js +71 -90
  61. package/dist/canvas/view/liftedScene.d.ts +31 -0
  62. package/dist/canvas/view/liftedScene.js +146 -0
  63. package/dist/canvas/view/mountedScene.d.ts +71 -0
  64. package/dist/canvas/view/mountedScene.js +363 -0
  65. package/dist/components/preferenceStorage.js +2 -2
  66. package/dist/engine/EngineCore.d.ts +15 -1
  67. package/dist/engine/EngineCore.js +724 -797
  68. package/dist/engine/codec/canvasDocument.d.ts +5 -0
  69. package/dist/engine/codec/canvasDocument.js +212 -149
  70. package/dist/engine/codec/hostReadableKeys.js +1 -1
  71. package/dist/engine/core/arrange.js +26 -38
  72. package/dist/engine/core/arrow.js +76 -89
  73. package/dist/engine/core/arrowBinding.js +98 -116
  74. package/dist/engine/core/arrowBindingRecords.js +23 -38
  75. package/dist/engine/core/brush.js +67 -94
  76. package/dist/engine/core/defaults.js +90 -51
  77. package/dist/engine/core/freehand.js +147 -163
  78. package/dist/engine/core/geometry.js +47 -54
  79. package/dist/engine/core/history.d.ts +6 -0
  80. package/dist/engine/core/history.js +49 -50
  81. package/dist/engine/core/hitTest.js +68 -81
  82. package/dist/engine/core/matrix.js +18 -20
  83. package/dist/engine/core/pathData.js +183 -210
  84. package/dist/engine/core/rotationReset.js +5 -6
  85. package/dist/engine/core/scene.d.ts +10 -0
  86. package/dist/engine/core/scene.js +153 -187
  87. package/dist/engine/core/scribble.js +59 -84
  88. package/dist/engine/core/shapePaths.js +12 -15
  89. package/dist/engine/core/shapeTools.js +72 -63
  90. package/dist/engine/core/snapping.js +65 -117
  91. package/dist/engine/core/style.js +31 -64
  92. package/dist/engine/core/transform.js +83 -94
  93. package/dist/engine/core/types.d.ts +8 -2
  94. package/dist/engine/core/types.js +4 -4
  95. package/dist/engine/core/viewport.js +23 -36
  96. package/dist/engine/input/PointerController.js +467 -474
  97. package/dist/engine/input/arrowHandles.js +12 -12
  98. package/dist/engine/input/gestures.js +265 -309
  99. package/dist/engine/input/hoverCursor.js +1 -1
  100. package/dist/engine/input/keyboard.js +27 -30
  101. package/dist/engine/input/selectionHandles.js +45 -50
  102. package/dist/engine/input/types.js +1 -1
  103. package/dist/engine/render/rasterize.js +86 -158
  104. package/dist/engine/state.d.ts +20 -0
  105. package/dist/engine/state.js +5 -15
  106. package/dist/engine/text/layoutText.js +43 -62
  107. package/dist/engine/text/textMetrics.js +8 -10
  108. package/dist/engine/widgets.js +101 -137
  109. package/dist/fonts/interFont.d.ts +10 -1
  110. package/dist/fonts/interFont.js +47 -75
  111. package/dist/fonts/workspaceFonts.js +32 -90
  112. package/dist/i18n/labels.js +4 -4
  113. package/dist/i18n/language.d.ts +3 -3
  114. package/dist/i18n/language.js +4 -4
  115. package/dist/i18n/messages.d.ts +8 -1
  116. package/dist/i18n/messages.js +10 -2
  117. package/dist/i18n/shortcuts.js +14 -14
  118. package/dist/index.d.ts +1 -1
  119. package/dist/index.js +1 -1
  120. package/dist/settings/workspaceToolSettings.js +32 -48
  121. package/dist/tools/components/catalog.js +64 -74
  122. package/dist/tools/components/grouping.js +6 -28
  123. package/dist/tools/definitions.js +5 -5
  124. package/dist/tools/executors.js +105 -141
  125. package/dist/tools/hostAdapter.js +11 -13
  126. package/dist/tools/sceneSummary.js +43 -57
  127. package/dist/tools/sketchIntent.js +13 -21
  128. package/dist/tools/types.js +1 -1
  129. package/package.json +1 -1
  130. package/dist/canvas/ui/SelectorBar.svelte +0 -84
  131. package/dist/canvas/ui/SelectorBar.svelte.d.ts +0 -12
@@ -10,30 +10,17 @@
10
10
  * 'strokeRound' – apply round linecap / linejoin (line-only: check, X, +, -)
11
11
  * 'pathRegen' – regenerate sub-shape path data with rounded corners (rects & polygons)
12
12
  */
13
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
- if (ar || !(i in from)) {
16
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
- ar[i] = from[i];
18
- }
19
- }
20
- return to.concat(ar || Array.prototype.slice.call(from));
21
- };
22
13
  // ── Path-regen helpers ────────────────────────────────────────────────────────
23
14
  /** Generate SVG path data for a rounded rectangle. */
24
15
  export function roundedRectPath(x, y, w, h, r) {
25
16
  r = Math.min(r, w / 2, h / 2);
26
- var x2 = x + w, y2 = y + h;
17
+ const x2 = x + w, y2 = y + h;
27
18
  return [
28
- "M ".concat(x + r, " ").concat(y),
29
- "L ".concat(x2 - r, " ").concat(y),
30
- "Q ".concat(x2, " ").concat(y, " ").concat(x2, " ").concat(y + r),
31
- "L ".concat(x2, " ").concat(y2 - r),
32
- "Q ".concat(x2, " ").concat(y2, " ").concat(x2 - r, " ").concat(y2),
33
- "L ".concat(x + r, " ").concat(y2),
34
- "Q ".concat(x, " ").concat(y2, " ").concat(x, " ").concat(y2 - r),
35
- "L ".concat(x, " ").concat(y + r),
36
- "Q ".concat(x, " ").concat(y, " ").concat(x + r, " ").concat(y),
19
+ `M ${x + r} ${y}`,
20
+ `L ${x2 - r} ${y}`, `Q ${x2} ${y} ${x2} ${y + r}`,
21
+ `L ${x2} ${y2 - r}`, `Q ${x2} ${y2} ${x2 - r} ${y2}`,
22
+ `L ${x + r} ${y2}`, `Q ${x} ${y2} ${x} ${y2 - r}`,
23
+ `L ${x} ${y + r}`, `Q ${x} ${y} ${x + r} ${y}`,
37
24
  'Z',
38
25
  ].join(' ');
39
26
  }
@@ -44,35 +31,35 @@ export function roundedRectPath(x, y, w, h, r) {
44
31
  */
45
32
  export function roundedPolygonPath(points, r) {
46
33
  if (r <= 0) {
47
- return (points.map(function (p, i) { return "".concat(i === 0 ? 'M' : 'L', " ").concat(p[0], " ").concat(p[1]); }).join(' ') + ' Z');
34
+ return (points.map((p, i) => `${i === 0 ? 'M' : 'L'} ${p[0]} ${p[1]}`).join(' ') + ' Z');
48
35
  }
49
- var n = points.length;
36
+ const n = points.length;
50
37
  // Cap r to 45% of the shortest edge to stay inside the polygon
51
- var minEdge = Infinity;
52
- for (var i = 0; i < n; i++) {
53
- var a = points[i], b = points[(i + 1) % n];
54
- var d_1 = Math.sqrt(Math.pow((b[0] - a[0]), 2) + Math.pow((b[1] - a[1]), 2));
55
- if (d_1 < minEdge)
56
- minEdge = d_1;
38
+ let minEdge = Infinity;
39
+ for (let i = 0; i < n; i++) {
40
+ const a = points[i], b = points[(i + 1) % n];
41
+ const d = Math.sqrt((b[0] - a[0]) ** 2 + (b[1] - a[1]) ** 2);
42
+ if (d < minEdge)
43
+ minEdge = d;
57
44
  }
58
- var rClamped = Math.min(r, minEdge * 0.45);
59
- var d = '';
60
- for (var i = 0; i < n; i++) {
61
- var prev = points[(i - 1 + n) % n];
62
- var curr = points[i];
63
- var next = points[(i + 1) % n];
45
+ const rClamped = Math.min(r, minEdge * 0.45);
46
+ let d = '';
47
+ for (let i = 0; i < n; i++) {
48
+ const prev = points[(i - 1 + n) % n];
49
+ const curr = points[i];
50
+ const next = points[(i + 1) % n];
64
51
  // Unit vectors from corner toward its neighbours
65
- var pLen = Math.sqrt(Math.pow((prev[0] - curr[0]), 2) + Math.pow((prev[1] - curr[1]), 2)) || 1;
66
- var nLen = Math.sqrt(Math.pow((next[0] - curr[0]), 2) + Math.pow((next[1] - curr[1]), 2)) || 1;
67
- var pn = [(prev[0] - curr[0]) / pLen, (prev[1] - curr[1]) / pLen];
68
- var nn = [(next[0] - curr[0]) / nLen, (next[1] - curr[1]) / nLen];
52
+ const pLen = Math.sqrt((prev[0] - curr[0]) ** 2 + (prev[1] - curr[1]) ** 2) || 1;
53
+ const nLen = Math.sqrt((next[0] - curr[0]) ** 2 + (next[1] - curr[1]) ** 2) || 1;
54
+ const pn = [(prev[0] - curr[0]) / pLen, (prev[1] - curr[1]) / pLen];
55
+ const nn = [(next[0] - curr[0]) / nLen, (next[1] - curr[1]) / nLen];
69
56
  // Points along each edge, distance rClamped from the corner vertex
70
- var p1 = [curr[0] + pn[0] * rClamped, curr[1] + pn[1] * rClamped];
71
- var p2 = [curr[0] + nn[0] * rClamped, curr[1] + nn[1] * rClamped];
57
+ const p1 = [curr[0] + pn[0] * rClamped, curr[1] + pn[1] * rClamped];
58
+ const p2 = [curr[0] + nn[0] * rClamped, curr[1] + nn[1] * rClamped];
72
59
  d += i === 0
73
- ? "M ".concat(p1[0].toFixed(2), " ").concat(p1[1].toFixed(2), " ")
74
- : "L ".concat(p1[0].toFixed(2), " ").concat(p1[1].toFixed(2), " ");
75
- d += "Q ".concat(curr[0], " ").concat(curr[1], " ").concat(p2[0].toFixed(2), " ").concat(p2[1].toFixed(2), " ");
60
+ ? `M ${p1[0].toFixed(2)} ${p1[1].toFixed(2)} `
61
+ : `L ${p1[0].toFixed(2)} ${p1[1].toFixed(2)} `;
62
+ d += `Q ${curr[0]} ${curr[1]} ${p2[0].toFixed(2)} ${p2[1].toFixed(2)} `;
76
63
  }
77
64
  return d + 'Z';
78
65
  }
@@ -85,21 +72,21 @@ export function generatePathForShape(shape, roundnessPercent) {
85
72
  // regenData. Each L-command corner and the two C-to-L junctions are rounded individually
86
73
  // using Quadratic Bezier arcs so the entire shape looks smooth at high roundness values.
87
74
  if (shape.key === 'curved-arrow') {
88
- var t_1 = (roundnessPercent / 100) * 8; // max 8-unit radius at 100%
89
- if (t_1 < 0.1)
75
+ const t = (roundnessPercent / 100) * 8; // max 8-unit radius at 100%
76
+ if (t < 0.1)
90
77
  return null;
91
78
  // Round a corner at (cx,cy): px/py is the INCOMING reference point, nx/ny is OUTGOING.
92
79
  // For C commands use the adjacent control point as the reference direction.
93
80
  // Returns { s: arcStart, e: arcEnd } strings for "…s Q cx cy e…" insertion.
94
- var rc = function (px, py, cx, cy, nx, ny) {
95
- var dx1 = px - cx, dy1 = py - cy;
96
- var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1) || 1;
97
- var dx2 = nx - cx, dy2 = ny - cy;
98
- var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2) || 1;
99
- var r = Math.min(t_1, l1 * 0.45, l2 * 0.45);
81
+ const rc = (px, py, cx, cy, nx, ny) => {
82
+ const dx1 = px - cx, dy1 = py - cy;
83
+ const l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1) || 1;
84
+ const dx2 = nx - cx, dy2 = ny - cy;
85
+ const l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2) || 1;
86
+ const r = Math.min(t, l1 * 0.45, l2 * 0.45);
100
87
  return {
101
- s: "".concat((cx + dx1 / l1 * r).toFixed(1), " ").concat((cy + dy1 / l1 * r).toFixed(1)),
102
- e: "".concat((cx + dx2 / l2 * r).toFixed(1), " ").concat((cy + dy2 / l2 * r).toFixed(1)),
88
+ s: `${(cx + dx1 / l1 * r).toFixed(1)} ${(cy + dy1 / l1 * r).toFixed(1)}`,
89
+ e: `${(cx + dx2 / l2 * r).toFixed(1)} ${(cy + dy2 / l2 * r).toFixed(1)}`,
103
90
  };
104
91
  };
105
92
  // Corners with reference points for tangent direction:
@@ -123,23 +110,23 @@ export function generatePathForShape(shape, roundnessPercent) {
123
110
  // — c0_e scales with t: at t=0 → M=(80,20) = exact original path; at t=8 → M=(85.7,25.7).
124
111
  // The Q arc from (80,25) Q(80,20) to c0_e smoothly rounds the top corner with up to 8px
125
112
  // effective radius on the outgoing side, while the shape stays correct at any % level.
126
- var r0 = Math.min(t_1, 21.2 * 0.45); // cap only by first-L edge length (21.2px × 0.45)
127
- var c0_s = '80.0 25.0'; // original C endpoint — Z-line start, never moves
128
- var c0_dirX = 15 / 21.2, c0_dirY = 15 / 21.2; // unit direction (80,20)→(95,35)
129
- var c0_e = "".concat((80 + c0_dirX * r0).toFixed(1), " ").concat((20 + c0_dirY * r0).toFixed(1));
130
- var c1 = rc(80, 20, 95, 35, 80, 50); // arrowhead tip
131
- var c2 = rc(95, 35, 80, 50, 80, 40); // outer lower arrowhead wing
132
- var c3 = rc(80, 50, 80, 40, 50, 40); // inner shoulder (L→C, use C cp1 as direction)
133
- var c4 = rc(30, 55, 30, 80, 15, 80); // C-to-L junction (C cp2 as incoming direction)
134
- var c5 = rc(30, 80, 15, 80, 15, 45); // tail end (L→C, use C cp1 as direction)
113
+ const r0 = Math.min(t, 21.2 * 0.45); // cap only by first-L edge length (21.2px × 0.45)
114
+ const c0_s = '80.0 25.0'; // original C endpoint — Z-line start, never moves
115
+ const c0_dirX = 15 / 21.2, c0_dirY = 15 / 21.2; // unit direction (80,20)→(95,35)
116
+ const c0_e = `${(80 + c0_dirX * r0).toFixed(1)} ${(20 + c0_dirY * r0).toFixed(1)}`;
117
+ const c1 = rc(80, 20, 95, 35, 80, 50); // arrowhead tip
118
+ const c2 = rc(95, 35, 80, 50, 80, 40); // outer lower arrowhead wing
119
+ const c3 = rc(80, 50, 80, 40, 50, 40); // inner shoulder (L→C, use C cp1 as direction)
120
+ const c4 = rc(30, 55, 30, 80, 15, 80); // C-to-L junction (C cp2 as incoming direction)
121
+ const c5 = rc(30, 80, 15, 80, 15, 45); // tail end (L→C, use C cp1 as direction)
135
122
  return [
136
- "M ".concat(c0_e), // start at c0 arc end (Z closes back here)
137
- "L ".concat(c1.s, " Q 95 35 ").concat(c1.e), // arrowhead tip
138
- "L ".concat(c2.s, " Q 80 50 ").concat(c2.e), // outer lower arrowhead wing
139
- "L ".concat(c3.s, " Q 80 40 ").concat(c3.e), // inner shoulder
140
- "C 50 40 30 55 ".concat(c4.s, " Q 30 80 ").concat(c4.e), // curve body + C→L junction
141
- "L ".concat(c5.s, " Q 15 80 ").concat(c5.e), // tail end
142
- "C 15 45 40 25 ".concat(c0_s, " Q 80 20 ").concat(c0_e, " Z"),
123
+ `M ${c0_e}`, // start at c0 arc end (Z closes back here)
124
+ `L ${c1.s} Q 95 35 ${c1.e}`, // arrowhead tip
125
+ `L ${c2.s} Q 80 50 ${c2.e}`, // outer lower arrowhead wing
126
+ `L ${c3.s} Q 80 40 ${c3.e}`, // inner shoulder
127
+ `C 50 40 30 55 ${c4.s} Q 30 80 ${c4.e}`, // curve body + C→L junction
128
+ `L ${c5.s} Q 15 80 ${c5.e}`, // tail end
129
+ `C 15 45 40 25 ${c0_s} Q 80 20 ${c0_e} Z`, // return C (endpoint unchanged) + M arc
143
130
  ].join(' ');
144
131
  }
145
132
  // ── Shield: quadratic-arc rounding of 5 angular corners, bezier bottom preserved ──
@@ -147,23 +134,22 @@ export function generatePathForShape(shape, roundnessPercent) {
147
134
  // Corners: P0=(50,5) P1=(90,20) P2=(90,55) P4=(10,55) P5=(10,20)
148
135
  // At 0%, returns null so the original pathData is used exactly (no shape change).
149
136
  if (shape.key === 'shield') {
150
- var maxT = 10; // max arc radius in path units at 100% roundness
151
- var t_2 = (roundnessPercent / 100) * maxT;
152
- if (t_2 < 0.1)
137
+ const maxT = 10; // max arc radius in path units at 100% roundness
138
+ const t = (roundnessPercent / 100) * maxT;
139
+ if (t < 0.1)
153
140
  return null;
154
141
  // rc: quadratic bezier arc at (cx,cy), optional tMax clamps radius for corners
155
142
  // adjacent to bezier curves to limit distortion of the bezier endpoints.
156
- var rc2 = function (px, py, cx, cy, nx, ny, tMax) {
157
- if (tMax === void 0) { tMax = t_2; }
158
- var tEff = Math.min(t_2, tMax);
159
- var dx1 = px - cx, dy1 = py - cy;
160
- var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1) || 1;
161
- var dx2 = nx - cx, dy2 = ny - cy;
162
- var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2) || 1;
163
- var r = Math.min(tEff, l1 * 0.45, l2 * 0.45);
143
+ const rc2 = (px, py, cx, cy, nx, ny, tMax = t) => {
144
+ const tEff = Math.min(t, tMax);
145
+ const dx1 = px - cx, dy1 = py - cy;
146
+ const l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1) || 1;
147
+ const dx2 = nx - cx, dy2 = ny - cy;
148
+ const l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2) || 1;
149
+ const r = Math.min(tEff, l1 * 0.45, l2 * 0.45);
164
150
  return {
165
- s: "".concat((cx + dx1 / l1 * r).toFixed(1), " ").concat((cy + dy1 / l1 * r).toFixed(1)),
166
- e: "".concat((cx + dx2 / l2 * r).toFixed(1), " ").concat((cy + dy2 / l2 * r).toFixed(1)),
151
+ s: `${(cx + dx1 / l1 * r).toFixed(1)} ${(cy + dy1 / l1 * r).toFixed(1)}`,
152
+ e: `${(cx + dx2 / l2 * r).toFixed(1)} ${(cy + dy2 / l2 * r).toFixed(1)}`,
167
153
  };
168
154
  };
169
155
  // c0: top point (50,5) — prev is (10,20) via Z-line, next is (90,20)
@@ -173,59 +159,59 @@ export function generatePathForShape(shape, roundnessPercent) {
173
159
  // the last cp of C1 (70,90) and the first cp of C2 (30,90)
174
160
  // c4: left side base (10,55) — limited tMax=4 to minimize bezier bottom distortion
175
161
  // c5: top-left shoulder (10,20) — prev (10,55), next (50,5)
176
- var c0 = rc2(10, 20, 50, 5, 90, 20);
177
- var c1 = rc2(50, 5, 90, 20, 90, 55);
178
- var c2 = rc2(90, 20, 90, 55, 90, 75, 4); // cap arc size near bezier
179
- var c3 = rc2(70, 90, 50, 95, 30, 90, 6); // bottom point (bezier junction, cap=6)
180
- var c4 = rc2(10, 75, 10, 55, 10, 20, 4); // cap arc size near bezier
181
- var c5 = rc2(10, 55, 10, 20, 50, 5);
162
+ const c0 = rc2(10, 20, 50, 5, 90, 20);
163
+ const c1 = rc2(50, 5, 90, 20, 90, 55);
164
+ const c2 = rc2(90, 20, 90, 55, 90, 75, 4); // cap arc size near bezier
165
+ const c3 = rc2(70, 90, 50, 95, 30, 90, 6); // bottom point (bezier junction, cap=6)
166
+ const c4 = rc2(10, 75, 10, 55, 10, 20, 4); // cap arc size near bezier
167
+ const c5 = rc2(10, 55, 10, 20, 50, 5);
182
168
  // The top corner arc (c0) is placed LAST, just before Z, so the path visits:
183
169
  // M(c0.e) → c1 arc → c2 arc → bezier1 (shortened to c3.s) → c3 Q arc →
184
170
  // bezier2 (from c3.e, shortened) → c4 arc → c5 arc → c0 arc → Z
185
171
  return [
186
- "M ".concat(c0.e), // start past top-point toward P1
187
- "L ".concat(c1.s, " Q 90 20 ").concat(c1.e), // arc at top-right shoulder
188
- "L ".concat(c2.s, " Q 90 55 ").concat(c2.e), // arc at right base (limited radius)
189
- "C 90 75 70 90 ".concat(c3.s), // bottom-right bezier, shortened to c3 arc entry
190
- "Q 50 95 ".concat(c3.e), // arc at bottom point
191
- "C 30 90 10 75 ".concat(c4.s), // bottom-left bezier, shortened to c4 arc entry
192
- "Q 10 55 ".concat(c4.e), // arc at left base (limited radius)
193
- "L ".concat(c5.s, " Q 10 20 ").concat(c5.e), // arc at top-left shoulder
194
- "L ".concat(c0.s, " Q 50 5 ").concat(c0.e), // arc at top point
195
- "Z",
172
+ `M ${c0.e}`, // start past top-point toward P1
173
+ `L ${c1.s} Q 90 20 ${c1.e}`, // arc at top-right shoulder
174
+ `L ${c2.s} Q 90 55 ${c2.e}`, // arc at right base (limited radius)
175
+ `C 90 75 70 90 ${c3.s}`, // bottom-right bezier, shortened to c3 arc entry
176
+ `Q 50 95 ${c3.e}`, // arc at bottom point
177
+ `C 30 90 10 75 ${c4.s}`, // bottom-left bezier, shortened to c4 arc entry
178
+ `Q 10 55 ${c4.e}`, // arc at left base (limited radius)
179
+ `L ${c5.s} Q 10 20 ${c5.e}`, // arc at top-left shoulder
180
+ `L ${c0.s} Q 50 5 ${c0.e}`, // arc at top point
181
+ `Z`, // zero-distance close back to M (c0.e)
196
182
  ].join(' ');
197
183
  }
198
184
  if (shape.cornerRadiusMode !== 'pathRegen' || !shape.regenData)
199
185
  return null;
200
- return shape.regenData.map(function (sub) {
186
+ return shape.regenData.map(sub => {
201
187
  if (sub.type === 'fixed')
202
188
  return sub.path;
203
189
  if (sub.type === 'rect') {
204
- var maxR_1 = Math.min(sub.w, sub.h) / 2;
205
- var r_1 = (roundnessPercent / 100) * maxR_1;
206
- return roundedRectPath(sub.x, sub.y, sub.w, sub.h, r_1);
190
+ const maxR = Math.min(sub.w, sub.h) / 2;
191
+ const r = (roundnessPercent / 100) * maxR;
192
+ return roundedRectPath(sub.x, sub.y, sub.w, sub.h, r);
207
193
  }
208
194
  // polygon
209
- var pts = sub.points;
210
- var n = pts.length;
211
- var minEdge = Infinity;
212
- for (var i = 0; i < n; i++) {
213
- var a = pts[i], b = pts[(i + 1) % n];
214
- minEdge = Math.min(minEdge, Math.sqrt(Math.pow((b[0] - a[0]), 2) + Math.pow((b[1] - a[1]), 2)));
195
+ const pts = sub.points;
196
+ const n = pts.length;
197
+ let minEdge = Infinity;
198
+ for (let i = 0; i < n; i++) {
199
+ const a = pts[i], b = pts[(i + 1) % n];
200
+ minEdge = Math.min(minEdge, Math.sqrt((b[0] - a[0]) ** 2 + (b[1] - a[1]) ** 2));
215
201
  }
216
- var maxR = minEdge * 0.45;
217
- var r = (roundnessPercent / 100) * maxR;
202
+ const maxR = minEdge * 0.45;
203
+ const r = (roundnessPercent / 100) * maxR;
218
204
  return roundedPolygonPath(pts, r);
219
205
  }).join(' ');
220
206
  }
221
207
  // ── Geometric Shapes (library) ─────────────────────────────────────────────
222
- var GEOMETRIC_SHAPES = [
208
+ const GEOMETRIC_SHAPES = [
223
209
  {
224
210
  key: 'hexagon',
225
211
  labelKey: 'canvas.shape.hexagon',
226
212
  category: 'Geometric Shapes',
227
213
  pathData: 'M 50 3 L 93 27 L 93 73 L 50 97 L 7 73 L 7 27 Z',
228
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><polygon points=\"12,2 21.5,7 21.5,17 12,22 2.5,17 2.5,7\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/></svg>",
214
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="12,2 21.5,7 21.5,17 12,22 2.5,17 2.5,7" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
229
215
  cornerRadiusMode: 'pathRegen',
230
216
  regenData: [
231
217
  { type: 'polygon', points: [[50, 3], [93, 27], [93, 73], [50, 97], [7, 73], [7, 27]] },
@@ -237,7 +223,7 @@ var GEOMETRIC_SHAPES = [
237
223
  labelKey: 'canvas.shape.pentagon',
238
224
  category: 'Geometric Shapes',
239
225
  pathData: 'M 50 4 L 95.6 37.2 L 78.2 90.8 L 21.8 90.8 L 4.4 37.2 Z',
240
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><polygon points=\"12,2.5 21.5,9.4 17.9,20.6 6.1,20.6 2.5,9.4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/></svg>",
226
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="12,2.5 21.5,9.4 17.9,20.6 6.1,20.6 2.5,9.4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
241
227
  cornerRadiusMode: 'pathRegen',
242
228
  regenData: [
243
229
  { type: 'polygon', points: [[50, 4], [95.6, 37.2], [78.2, 90.8], [21.8, 90.8], [4.4, 37.2]] },
@@ -251,19 +237,19 @@ var GEOMETRIC_SHAPES = [
251
237
  // Capsule/stadium shape: wide rounded rect with max corner radius (half the height).
252
238
  // 160×90 content area, corner radius = 45 (half of 90). Produces semicircle caps like a pill.
253
239
  pathData: 'M 50 5 L 110 5 Q 155 5 155 50 L 155 50 Q 155 95 110 95 L 50 95 Q 5 95 5 50 L 5 50 Q 5 5 50 5 Z',
254
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"7\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"/></svg>",
240
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="14" rx="7" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>`,
255
241
  cornerRadiusMode: 'none',
256
242
  lockAspectRatio: false,
257
243
  },
258
244
  ];
259
245
  // ── Media Icons ──────────────────────────────────────────────────────────────
260
- var MEDIA_SHAPES = [
246
+ const MEDIA_SHAPES = [
261
247
  {
262
248
  key: 'play',
263
249
  labelKey: 'canvas.shape.play',
264
250
  category: 'Media Icons',
265
251
  pathData: 'M 10 5 L 10 95 L 90 50 Z',
266
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><polygon points=\"5,3 5,21 20,12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/></svg>",
252
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="5,3 5,21 20,12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
267
253
  cornerRadiusMode: 'pathRegen',
268
254
  regenData: [
269
255
  { type: 'polygon', points: [[10, 5], [10, 95], [90, 50]] },
@@ -274,7 +260,7 @@ var MEDIA_SHAPES = [
274
260
  labelKey: 'canvas.shape.pause',
275
261
  category: 'Media Icons',
276
262
  pathData: 'M 15 5 L 15 95 L 35 95 L 35 5 Z M 65 5 L 65 95 L 85 95 L 85 5 Z',
277
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><rect x=\"6\" y=\"4\" width=\"4\" height=\"16\" rx=\"1\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"/><rect x=\"14\" y=\"4\" width=\"4\" height=\"16\" rx=\"1\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"/></svg>",
263
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><rect x="6" y="4" width="4" height="16" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/><rect x="14" y="4" width="4" height="16" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>`,
278
264
  cornerRadiusMode: 'pathRegen',
279
265
  regenData: [
280
266
  { type: 'rect', x: 15, y: 5, w: 20, h: 90 },
@@ -286,7 +272,7 @@ var MEDIA_SHAPES = [
286
272
  labelKey: 'canvas.shape.stop',
287
273
  category: 'Media Icons',
288
274
  pathData: 'M 10 10 L 10 90 L 90 90 L 90 10 Z',
289
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><rect x=\"5\" y=\"5\" width=\"14\" height=\"14\" rx=\"1.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"/></svg>",
275
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><rect x="5" y="5" width="14" height="14" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>`,
290
276
  cornerRadiusMode: 'pathRegen',
291
277
  regenData: [
292
278
  { type: 'rect', x: 10, y: 10, w: 80, h: 80 },
@@ -297,7 +283,7 @@ var MEDIA_SHAPES = [
297
283
  labelKey: 'canvas.shape.rewind',
298
284
  category: 'Media Icons',
299
285
  pathData: 'M 50 5 L 50 95 L 5 50 Z M 95 5 L 95 95 L 50 50 Z',
300
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><polygon points=\"12,3 12,21 3,12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/><polygon points=\"21,3 21,21 12,12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/></svg>",
286
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="12,3 12,21 3,12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/><polygon points="21,3 21,21 12,12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
301
287
  cornerRadiusMode: 'pathRegen',
302
288
  regenData: [
303
289
  { type: 'polygon', points: [[50, 5], [50, 95], [5, 50]] },
@@ -309,7 +295,7 @@ var MEDIA_SHAPES = [
309
295
  labelKey: 'canvas.shape.fastForward',
310
296
  category: 'Media Icons',
311
297
  pathData: 'M 5 5 L 5 95 L 50 50 Z M 50 5 L 50 95 L 95 50 Z',
312
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><polygon points=\"3,3 3,21 12,12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/><polygon points=\"12,3 12,21 21,12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/></svg>",
298
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="3,3 3,21 12,12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/><polygon points="12,3 12,21 21,12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
313
299
  cornerRadiusMode: 'pathRegen',
314
300
  regenData: [
315
301
  { type: 'polygon', points: [[5, 5], [5, 95], [50, 50]] },
@@ -322,18 +308,18 @@ var MEDIA_SHAPES = [
322
308
  category: 'Media Icons',
323
309
  // Already a circle — no corner rounding needed
324
310
  pathData: 'M 50 5 A 45 45 0 1 1 49.999 5 Z',
325
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><circle cx=\"12\" cy=\"12\" r=\"7\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"/></svg>",
311
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><circle cx="12" cy="12" r="7" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>`,
326
312
  cornerRadiusMode: 'none',
327
313
  },
328
314
  ];
329
315
  // ── Arrow Shapes ─────────────────────────────────────────────────────────────
330
- var ARROW_SHAPES = [
316
+ const ARROW_SHAPES = [
331
317
  {
332
318
  key: 'arrow-right',
333
319
  labelKey: 'canvas.shape.arrowRight',
334
320
  category: 'Arrow Shapes',
335
321
  pathData: 'M 5 40 L 65 40 L 65 20 L 95 50 L 65 80 L 65 60 L 5 60 Z',
336
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M5 12 H19 M13 6 L19 12 L13 18\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>",
322
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M5 12 H19 M13 6 L19 12 L13 18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
337
323
  cornerRadiusMode: 'pathRegen',
338
324
  regenData: [{ type: 'polygon', points: [[5, 40], [65, 40], [65, 20], [95, 50], [65, 80], [65, 60], [5, 60]] }],
339
325
  },
@@ -342,7 +328,7 @@ var ARROW_SHAPES = [
342
328
  labelKey: 'canvas.shape.arrowLeft',
343
329
  category: 'Arrow Shapes',
344
330
  pathData: 'M 95 40 L 35 40 L 35 20 L 5 50 L 35 80 L 35 60 L 95 60 Z',
345
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M19 12 H5 M11 6 L5 12 L11 18\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>",
331
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M19 12 H5 M11 6 L5 12 L11 18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
346
332
  cornerRadiusMode: 'pathRegen',
347
333
  regenData: [{ type: 'polygon', points: [[95, 40], [35, 40], [35, 20], [5, 50], [35, 80], [35, 60], [95, 60]] }],
348
334
  },
@@ -351,7 +337,7 @@ var ARROW_SHAPES = [
351
337
  labelKey: 'canvas.shape.arrowUp',
352
338
  category: 'Arrow Shapes',
353
339
  pathData: 'M 40 95 L 40 35 L 20 35 L 50 5 L 80 35 L 60 35 L 60 95 Z',
354
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M12 19 V5 M6 11 L12 5 L18 11\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>",
340
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 19 V5 M6 11 L12 5 L18 11" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
355
341
  cornerRadiusMode: 'pathRegen',
356
342
  regenData: [{ type: 'polygon', points: [[40, 95], [40, 35], [20, 35], [50, 5], [80, 35], [60, 35], [60, 95]] }],
357
343
  },
@@ -360,7 +346,7 @@ var ARROW_SHAPES = [
360
346
  labelKey: 'canvas.shape.arrowDown',
361
347
  category: 'Arrow Shapes',
362
348
  pathData: 'M 60 5 L 60 65 L 80 65 L 50 95 L 20 65 L 40 65 L 40 5 Z',
363
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M12 5 V19 M6 13 L12 19 L18 13\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>",
349
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 5 V19 M6 13 L12 19 L18 13" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
364
350
  cornerRadiusMode: 'pathRegen',
365
351
  regenData: [{ type: 'polygon', points: [[60, 5], [60, 65], [80, 65], [50, 95], [20, 65], [40, 65], [40, 5]] }],
366
352
  },
@@ -369,7 +355,7 @@ var ARROW_SHAPES = [
369
355
  labelKey: 'canvas.shape.doubleArrow',
370
356
  category: 'Arrow Shapes',
371
357
  pathData: 'M 30 20 L 5 50 L 30 80 L 30 62 L 70 62 L 70 80 L 95 50 L 70 20 L 70 38 L 30 38 Z',
372
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M7 12 H17 M5 8 L1 12 L5 16 M19 8 L23 12 L19 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>",
358
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M7 12 H17 M5 8 L1 12 L5 16 M19 8 L23 12 L19 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
373
359
  cornerRadiusMode: 'pathRegen',
374
360
  regenData: [{ type: 'polygon', points: [[30, 20], [5, 50], [30, 80], [30, 62], [70, 62], [70, 80], [95, 50], [70, 20], [70, 38], [30, 38]] }],
375
361
  },
@@ -382,20 +368,20 @@ var ARROW_SHAPES = [
382
368
  // because it clips the bounding box, cutting off arrowhead tips at high roundness.
383
369
  // strokeRound was avoided because it only affects the stroke outline, not the fill corners.
384
370
  pathData: 'M 80 20 L 95 35 L 80 50 L 80 40 C 50 40 30 55 30 80 L 15 80 C 15 45 40 25 80 25 Z',
385
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M17 4 L21 8 L17 12 M21 8 C15 8 9 11 9 20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>",
371
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M17 4 L21 8 L17 12 M21 8 C15 8 9 11 9 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
386
372
  cornerRadiusMode: 'pathRegen',
387
373
  // regenData is intentionally omitted — generatePathForShape handles this shape directly.
388
374
  },
389
375
  ];
390
376
  // ── UI Icons ─────────────────────────────────────────────────────────────────
391
- var UI_ICON_SHAPES = [
377
+ const UI_ICON_SHAPES = [
392
378
  {
393
379
  key: 'check',
394
380
  labelKey: 'canvas.shape.checkMark',
395
381
  category: 'UI Icons',
396
382
  // Open path — round by setting strokeLineCap/strokeLineJoin
397
383
  pathData: 'M 5 55 L 35 85 L 95 15',
398
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M4 13 L9 18 L20 6\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>",
384
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M4 13 L9 18 L20 6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
399
385
  cornerRadiusMode: 'strokeRound',
400
386
  },
401
387
  {
@@ -403,7 +389,7 @@ var UI_ICON_SHAPES = [
403
389
  labelKey: 'canvas.shape.cross',
404
390
  category: 'UI Icons',
405
391
  pathData: 'M 10 10 L 90 90 M 90 10 L 10 90',
406
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M5 5 L19 19 M19 5 L5 19\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/></svg>",
392
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M5 5 L19 19 M19 5 L5 19" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`,
407
393
  cornerRadiusMode: 'strokeRound',
408
394
  },
409
395
  {
@@ -411,7 +397,7 @@ var UI_ICON_SHAPES = [
411
397
  labelKey: 'canvas.shape.plus',
412
398
  category: 'UI Icons',
413
399
  pathData: 'M 50 10 L 50 90 M 10 50 L 90 50',
414
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M12 5 V19 M5 12 H19\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/></svg>",
400
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 5 V19 M5 12 H19" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`,
415
401
  cornerRadiusMode: 'strokeRound',
416
402
  },
417
403
  {
@@ -419,7 +405,7 @@ var UI_ICON_SHAPES = [
419
405
  labelKey: 'canvas.shape.minus',
420
406
  category: 'UI Icons',
421
407
  pathData: 'M 10 50 L 90 50',
422
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M5 12 H19\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/></svg>",
408
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M5 12 H19" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`,
423
409
  cornerRadiusMode: 'strokeRound',
424
410
  },
425
411
  {
@@ -428,7 +414,7 @@ var UI_ICON_SHAPES = [
428
414
  category: 'UI Icons',
429
415
  // Outer circle is already curved — no corner rounding
430
416
  pathData: 'M 50 5 A 45 45 0 1 1 49.999 5 Z M 50 30 L 50 32 M 50 42 L 50 72',
431
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><circle cx=\"12\" cy=\"12\" r=\"9\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"/><path d=\"M12 8 V8.5 M12 11 V16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/></svg>",
417
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M12 8 V8.5 M12 11 V16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`,
432
418
  cornerRadiusMode: 'none',
433
419
  },
434
420
  {
@@ -437,7 +423,7 @@ var UI_ICON_SHAPES = [
437
423
  category: 'UI Icons',
438
424
  // Outer triangle + inner ! lines (inner lines kept fixed)
439
425
  pathData: 'M 50 5 L 95 90 L 5 90 Z M 50 40 L 50 60 M 50 70 L 50 72',
440
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M12 3 L22 20 H2 Z\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/><path d=\"M12 10 V14 M12 17 V17.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/></svg>",
426
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 3 L22 20 H2 Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/><path d="M12 10 V14 M12 17 V17.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`,
441
427
  cornerRadiusMode: 'pathRegen',
442
428
  regenData: [
443
429
  { type: 'polygon', points: [[50, 5], [95, 90], [5, 90]] },
@@ -446,13 +432,13 @@ var UI_ICON_SHAPES = [
446
432
  },
447
433
  ];
448
434
  // ── Symbol Shapes ─────────────────────────────────────────────────────────────
449
- var SYMBOL_SHAPES = [
435
+ const SYMBOL_SHAPES = [
450
436
  {
451
437
  key: 'star',
452
438
  labelKey: 'canvas.shape.star',
453
439
  category: 'Symbol Shapes',
454
440
  pathData: 'M 50 5 L 61 35 L 95 35 L 68 57 L 79 91 L 50 70 L 21 91 L 32 57 L 5 35 L 39 35 Z',
455
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><polygon points=\"12,2 15.09,8.26 22,9.27 17,14.14 18.18,21.02 12,17.77 5.82,21.02 7,14.14 2,9.27 8.91,8.26\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/></svg>",
441
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="12,2 15.09,8.26 22,9.27 17,14.14 18.18,21.02 12,17.77 5.82,21.02 7,14.14 2,9.27 8.91,8.26" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
456
442
  // pathRegen rounds each polygon corner individually (outer tips + inner concave vertices)
457
443
  cornerRadiusMode: 'pathRegen',
458
444
  regenData: [
@@ -465,7 +451,7 @@ var SYMBOL_SHAPES = [
465
451
  category: 'Symbol Shapes',
466
452
  // Already curved — no corner rounding
467
453
  pathData: 'M 50 85 C 5 55 5 20 25 15 C 35 12 45 17 50 25 C 55 17 65 12 75 15 C 95 20 95 55 50 85 Z',
468
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M12 21C12 21 3 14 3 8.5A4.5 4.5 0 0 1 12 6.5 4.5 4.5 0 0 1 21 8.5C21 14 12 21 12 21Z\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/></svg>",
454
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 21C12 21 3 14 3 8.5A4.5 4.5 0 0 1 12 6.5 4.5 4.5 0 0 1 21 8.5C21 14 12 21 12 21Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
469
455
  cornerRadiusMode: 'none',
470
456
  },
471
457
  {
@@ -473,7 +459,7 @@ var SYMBOL_SHAPES = [
473
459
  labelKey: 'canvas.shape.speechBubble',
474
460
  category: 'Symbol Shapes',
475
461
  pathData: 'M 10 10 L 10 65 L 35 65 L 50 90 L 65 65 L 90 65 L 90 10 Z',
476
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M4 4 H20 A2 2 0 0 1 22 6 V15 A2 2 0 0 1 20 17 H9 L4 21 V17 A2 2 0 0 1 2 15 V6 A2 2 0 0 1 4 4 Z\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/></svg>",
462
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M4 4 H20 A2 2 0 0 1 22 6 V15 A2 2 0 0 1 20 17 H9 L4 21 V17 A2 2 0 0 1 2 15 V6 A2 2 0 0 1 4 4 Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
477
463
  // pathRegen rounds box corners; the tail corner also softens slightly
478
464
  cornerRadiusMode: 'pathRegen',
479
465
  regenData: [
@@ -487,7 +473,7 @@ var SYMBOL_SHAPES = [
487
473
  labelKey: 'canvas.shape.rhombus',
488
474
  category: 'Symbol Shapes',
489
475
  pathData: 'M 50 5 L 95 50 L 50 95 L 5 50 Z',
490
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><polygon points=\"12,2 22,12 12,22 2,12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/></svg>",
476
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="12,2 22,12 12,22 2,12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
491
477
  cornerRadiusMode: 'pathRegen',
492
478
  regenData: [
493
479
  { type: 'polygon', points: [[50, 5], [95, 50], [50, 95], [5, 50]] },
@@ -499,7 +485,7 @@ var SYMBOL_SHAPES = [
499
485
  labelKey: 'canvas.shape.lightning',
500
486
  category: 'Symbol Shapes',
501
487
  pathData: 'M 55 5 L 20 52 L 45 52 L 38 95 L 80 42 L 55 42 Z',
502
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M13 2 L5 13 H11 L9 22 L19 9 H13 Z\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/></svg>",
488
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M13 2 L5 13 H11 L9 22 L19 9 H13 Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
503
489
  cornerRadiusMode: 'pathRegen',
504
490
  regenData: [
505
491
  { type: 'polygon', points: [[55, 5], [20, 52], [45, 52], [38, 95], [80, 42], [55, 42]] },
@@ -511,20 +497,26 @@ var SYMBOL_SHAPES = [
511
497
  labelKey: 'canvas.shape.shield',
512
498
  category: 'Symbol Shapes',
513
499
  pathData: 'M 50 5 L 90 20 L 90 55 C 90 75 70 90 50 95 C 30 90 10 75 10 55 L 10 20 Z',
514
- iconSvg: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\"><path d=\"M12 3 L20 7 V13 C20 17.5 16.5 21 12 22 C7.5 21 4 17.5 4 13 V7 Z\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/></svg>",
500
+ iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M12 3 L20 7 V13 C20 17.5 16.5 21 12 22 C7.5 21 4 17.5 4 13 V7 Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
515
501
  cornerRadiusMode: 'pathRegen',
516
502
  lockAspectRatio: false,
517
503
  },
518
504
  ];
519
505
  /** All library shapes, grouped by category (Geometric first, then Arrows) */
520
- export var SHAPE_LIBRARY = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], GEOMETRIC_SHAPES, true), ARROW_SHAPES, true), MEDIA_SHAPES, true), UI_ICON_SHAPES, true), SYMBOL_SHAPES, true);
506
+ export const SHAPE_LIBRARY = [
507
+ ...GEOMETRIC_SHAPES,
508
+ ...ARROW_SHAPES,
509
+ ...MEDIA_SHAPES,
510
+ ...UI_ICON_SHAPES,
511
+ ...SYMBOL_SHAPES,
512
+ ];
521
513
  /**
522
514
  * Keyed shape index: single canonical id→shape lookup, built once at module
523
515
  * load. Replaces the repeated `SHAPE_LIBRARY.find(s => s.key === ...)`
524
516
  * linear scans across Canvas.svelte. Keys are unique by construction
525
517
  * (categories partition the array); a duplicate would be an authoring bug.
526
518
  */
527
- var SHAPE_LIBRARY_BY_KEY = new Map(SHAPE_LIBRARY.map(function (shape) { return [shape.key, shape]; }));
519
+ const SHAPE_LIBRARY_BY_KEY = new Map(SHAPE_LIBRARY.map(shape => [shape.key, shape]));
528
520
  /**
529
521
  * Look up a library shape definition by its stable key.
530
522
  * Returns undefined for unknown keys (dynamic/legacy shape keys).
@@ -536,11 +528,9 @@ export function getShapeByKey(key) {
536
528
  }
537
529
  /** Shapes grouped by category for rendering in the UI */
538
530
  export function getShapesByCategory() {
539
- var _a;
540
- var map = new Map();
541
- for (var _i = 0, SHAPE_LIBRARY_1 = SHAPE_LIBRARY; _i < SHAPE_LIBRARY_1.length; _i++) {
542
- var shape = SHAPE_LIBRARY_1[_i];
543
- var existing = (_a = map.get(shape.category)) !== null && _a !== void 0 ? _a : [];
531
+ const map = new Map();
532
+ for (const shape of SHAPE_LIBRARY) {
533
+ const existing = map.get(shape.category) ?? [];
544
534
  existing.push(shape);
545
535
  map.set(shape.category, existing);
546
536
  }