@pibbl/core 0.0.1 → 0.0.3-alpha.109.1

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 (683) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.txt +81 -0
  3. package/dist/features/machines/animation.d.ts +64 -0
  4. package/dist/features/machines/animation.js +55 -0
  5. package/dist/features/machines/animation.js.map +7 -0
  6. package/dist/features/machines/animation.mjs +1 -0
  7. package/dist/features/machines/assign.d.ts +16 -0
  8. package/dist/features/machines/assign.js +15 -0
  9. package/dist/features/machines/assign.js.map +7 -0
  10. package/dist/features/machines/callback.d.ts +9 -0
  11. package/dist/features/machines/callback.js +7 -0
  12. package/dist/features/machines/callback.js.map +7 -0
  13. package/dist/features/machines/hook.d.ts +30 -0
  14. package/dist/features/machines/hook.js +37 -0
  15. package/dist/features/machines/hook.js.map +7 -0
  16. package/dist/features/machines/index.d.ts +6 -0
  17. package/dist/features/machines/index.js +12 -0
  18. package/dist/features/machines/index.js.map +7 -0
  19. package/dist/features/machines/index.mjs +1 -0
  20. package/dist/features/machines/runtime.d.ts +18 -0
  21. package/dist/features/machines/runtime.js +363 -0
  22. package/dist/features/machines/runtime.js.map +7 -0
  23. package/dist/features/machines/types.d.ts +164 -0
  24. package/dist/features/physics/2d-geometry.d.ts +3 -3
  25. package/dist/features/physics/2d-geometry.js.map +1 -1
  26. package/dist/features/physics/2d-testing.d.ts +1 -1
  27. package/dist/features/physics/2d-testing.js +2 -2
  28. package/dist/features/physics/2d-testing.js.map +2 -2
  29. package/dist/features/physics/2d.d.ts +115 -62
  30. package/dist/features/physics/2d.js +59 -28
  31. package/dist/features/physics/2d.js.map +2 -2
  32. package/dist/features/physics/lib/2d/canvas/components.js +25 -21
  33. package/dist/features/physics/lib/2d/canvas/components.js.map +2 -2
  34. package/dist/features/physics/lib/2d/canvas/presentation.js +1 -2
  35. package/dist/features/physics/lib/2d/canvas/presentation.js.map +2 -2
  36. package/dist/features/physics/lib/2d/collision/casts.js +4 -2
  37. package/dist/features/physics/lib/2d/collision/casts.js.map +2 -2
  38. package/dist/features/physics/lib/2d/query-types.d.ts +6 -0
  39. package/dist/features/physics/lib/2d/runtime/controller.d.ts +7 -6
  40. package/dist/features/physics/lib/2d/runtime/controller.js +1 -1
  41. package/dist/features/physics/lib/2d/runtime/controller.js.map +2 -2
  42. package/dist/features/physics/lib/2d/runtime/obstacles.js +9 -11
  43. package/dist/features/physics/lib/2d/runtime/obstacles.js.map +2 -2
  44. package/dist/features/physics/lib/2d/shapes.js +8 -9
  45. package/dist/features/physics/lib/2d/shapes.js.map +2 -2
  46. package/dist/features/physics/lib/2d/types.d.ts +8 -30
  47. package/dist/features/physics/lib/2d/world/queries.d.ts +7 -6
  48. package/dist/features/physics/lib/2d/world/queries.js.map +2 -2
  49. package/dist/features/physics/lib/2d/world/rapier.js +22 -26
  50. package/dist/features/physics/lib/2d/world/rapier.js.map +2 -2
  51. package/dist/features/sprites/formats/aseprite.d.ts +5 -0
  52. package/dist/features/sprites/formats/texture-packer.d.ts +5 -0
  53. package/dist/features/sprites/index.d.ts +6 -0
  54. package/dist/features/sprites/loader.d.ts +25 -0
  55. package/dist/features/sprites/loader.js +6 -3
  56. package/dist/features/sprites/loader.js.map +2 -2
  57. package/dist/features/sprites/model.d.ts +75 -0
  58. package/dist/features/sprites/sprite.d.ts +22 -0
  59. package/dist/features/textures/index.d.ts +12 -2
  60. package/dist/features/textures/index.js +33 -1
  61. package/dist/features/textures/index.js.map +2 -2
  62. package/dist/features/textures/lib/chemical-field.d.ts +56 -0
  63. package/dist/features/textures/lib/chemical-field.js +154 -0
  64. package/dist/features/textures/lib/chemical-field.js.map +7 -0
  65. package/dist/features/textures/lib/chemical-recipes.d.ts +119 -0
  66. package/dist/features/textures/lib/chemical-recipes.js +275 -0
  67. package/dist/features/textures/lib/chemical-recipes.js.map +7 -0
  68. package/dist/features/textures/lib/definitions.d.ts +3 -18
  69. package/dist/features/textures/lib/definitions.js +17 -24
  70. package/dist/features/textures/lib/definitions.js.map +2 -2
  71. package/dist/features/textures/lib/geometric-patterns.d.ts +149 -0
  72. package/dist/features/textures/lib/geometric-patterns.js +305 -0
  73. package/dist/features/textures/lib/geometric-patterns.js.map +7 -0
  74. package/dist/features/textures/lib/gray-scott.d.ts +55 -0
  75. package/dist/features/textures/lib/gray-scott.js +37 -0
  76. package/dist/features/textures/lib/gray-scott.js.map +7 -0
  77. package/dist/features/textures/lib/palette.js +1 -3
  78. package/dist/features/textures/lib/palette.js.map +2 -2
  79. package/dist/features/textures/lib/patterns.d.ts +123 -0
  80. package/dist/features/textures/lib/patterns.js +344 -0
  81. package/dist/features/textures/lib/patterns.js.map +7 -0
  82. package/dist/features/textures/lib/rain-drops.js +2 -1
  83. package/dist/features/textures/lib/rain-drops.js.map +2 -2
  84. package/dist/features/textures/lib/reaction-diffusion.d.ts +3 -2
  85. package/dist/features/textures/lib/reaction-diffusion.js +9 -20
  86. package/dist/features/textures/lib/reaction-diffusion.js.map +2 -2
  87. package/dist/features/textures/lib/simulation.d.ts +10 -4
  88. package/dist/features/textures/lib/simulation.js +23 -13
  89. package/dist/features/textures/lib/simulation.js.map +2 -2
  90. package/dist/features/textures/lib/wasm/electric.js +8 -1
  91. package/dist/features/textures/lib/wasm/electric.js.map +2 -2
  92. package/dist/features/textures/lib/water-surface.js +1 -3
  93. package/dist/features/textures/lib/water-surface.js.map +2 -2
  94. package/dist/features/viz/index.d.ts +92 -5
  95. package/dist/features/viz/index.js +202 -4
  96. package/dist/features/viz/index.js.map +2 -2
  97. package/dist/features/viz/inspection/bar.d.ts +79 -0
  98. package/dist/features/viz/inspection/bar.js +49 -0
  99. package/dist/features/viz/inspection/bar.js.map +7 -0
  100. package/dist/features/viz/inspection/candle.d.ts +156 -0
  101. package/dist/features/viz/inspection/candle.js +120 -0
  102. package/dist/features/viz/inspection/candle.js.map +7 -0
  103. package/dist/features/viz/inspection/capture-types.d.ts +65 -0
  104. package/dist/features/viz/inspection/capture.d.ts +16 -0
  105. package/dist/features/viz/inspection/capture.js +49 -0
  106. package/dist/features/viz/inspection/capture.js.map +7 -0
  107. package/dist/features/viz/inspection/handler.d.ts +36 -0
  108. package/dist/features/viz/inspection/handler.js +91 -0
  109. package/dist/features/viz/inspection/handler.js.map +7 -0
  110. package/dist/features/viz/inspection/ohlc-bar.d.ts +132 -0
  111. package/dist/features/viz/inspection/ohlc-bar.js +118 -0
  112. package/dist/features/viz/inspection/ohlc-bar.js.map +7 -0
  113. package/dist/features/viz/inspection/owned-ref.d.ts +16 -0
  114. package/dist/features/viz/inspection/owned-ref.js +99 -0
  115. package/dist/features/viz/inspection/owned-ref.js.map +7 -0
  116. package/dist/features/viz/inspection/painted-point.d.ts +22 -0
  117. package/dist/features/viz/inspection/painted-point.js +29 -0
  118. package/dist/features/viz/inspection/painted-point.js.map +7 -0
  119. package/dist/features/viz/inspection/queries.d.ts +100 -0
  120. package/dist/features/viz/inspection/queries.js +192 -0
  121. package/dist/features/viz/inspection/queries.js.map +7 -0
  122. package/dist/features/viz/inspection/query-types.d.ts +177 -0
  123. package/dist/features/viz/inspection/volume.d.ts +104 -0
  124. package/dist/features/viz/inspection/volume.js +95 -0
  125. package/dist/features/viz/inspection/volume.js.map +7 -0
  126. package/dist/features/viz/inspection.d.ts +19 -0
  127. package/dist/features/viz/inspection.js +54 -0
  128. package/dist/features/viz/inspection.js.map +7 -0
  129. package/dist/features/viz/inspection.mjs +1 -0
  130. package/dist/features/viz/lib/area-series.d.ts +62 -0
  131. package/dist/features/viz/lib/area-series.js +120 -0
  132. package/dist/features/viz/lib/area-series.js.map +7 -0
  133. package/dist/features/viz/lib/axis-labels.d.ts +2 -0
  134. package/dist/features/viz/lib/axis-labels.js +41 -0
  135. package/dist/features/viz/lib/axis-labels.js.map +7 -0
  136. package/dist/features/viz/lib/axis-title.d.ts +23 -0
  137. package/dist/features/viz/lib/axis-title.js +24 -0
  138. package/dist/features/viz/lib/axis-title.js.map +7 -0
  139. package/dist/features/viz/lib/axis.d.ts +1 -1
  140. package/dist/features/viz/lib/axis.js +50 -50
  141. package/dist/features/viz/lib/axis.js.map +2 -2
  142. package/dist/features/viz/lib/bar-scale.d.ts +7 -0
  143. package/dist/features/viz/lib/bar-scale.js +34 -0
  144. package/dist/features/viz/lib/bar-scale.js.map +7 -0
  145. package/dist/features/viz/lib/bar-series.d.ts +3 -1
  146. package/dist/features/viz/lib/bar-series.js +21 -5
  147. package/dist/features/viz/lib/bar-series.js.map +2 -2
  148. package/dist/features/viz/lib/baseline-series.d.ts +55 -0
  149. package/dist/features/viz/lib/baseline-series.js +136 -0
  150. package/dist/features/viz/lib/baseline-series.js.map +7 -0
  151. package/dist/features/viz/lib/candlestick-series.d.ts +62 -0
  152. package/dist/features/viz/lib/candlestick-series.js +150 -0
  153. package/dist/features/viz/lib/candlestick-series.js.map +7 -0
  154. package/dist/features/viz/lib/censored-point-series.d.ts +71 -0
  155. package/dist/features/viz/lib/censored-point-series.js +129 -0
  156. package/dist/features/viz/lib/censored-point-series.js.map +7 -0
  157. package/dist/features/viz/lib/chart-lines.d.ts +41 -0
  158. package/dist/features/viz/lib/chart-lines.js +32 -0
  159. package/dist/features/viz/lib/chart-lines.js.map +7 -0
  160. package/dist/features/viz/lib/color-context.d.ts +4 -0
  161. package/dist/features/viz/lib/color-context.js +41 -0
  162. package/dist/features/viz/lib/color-context.js.map +7 -0
  163. package/dist/features/viz/lib/color-math.d.ts +4 -0
  164. package/dist/features/viz/lib/color-math.js +31 -0
  165. package/dist/features/viz/lib/color-math.js.map +7 -0
  166. package/dist/features/viz/lib/color-types.d.ts +53 -0
  167. package/dist/features/viz/lib/curve-definition.d.ts +49 -0
  168. package/dist/features/viz/lib/curve-definition.js +142 -0
  169. package/dist/features/viz/lib/curve-definition.js.map +7 -0
  170. package/dist/features/viz/lib/diverging-color-scale.d.ts +11 -0
  171. package/dist/features/viz/lib/diverging-color-scale.js +51 -0
  172. package/dist/features/viz/lib/diverging-color-scale.js.map +7 -0
  173. package/dist/features/viz/lib/domain-navigation.d.ts +40 -0
  174. package/dist/features/viz/lib/domain-navigation.js +77 -0
  175. package/dist/features/viz/lib/domain-navigation.js.map +7 -0
  176. package/dist/features/viz/lib/editable-chart-elements.d.ts +178 -0
  177. package/dist/features/viz/lib/editable-chart-elements.js +733 -0
  178. package/dist/features/viz/lib/editable-chart-elements.js.map +7 -0
  179. package/dist/features/viz/lib/financial-aggregation.d.ts +127 -0
  180. package/dist/features/viz/lib/financial-aggregation.js +116 -0
  181. package/dist/features/viz/lib/financial-aggregation.js.map +7 -0
  182. package/dist/features/viz/lib/financial-autoscale.d.ts +64 -0
  183. package/dist/features/viz/lib/financial-autoscale.js +61 -0
  184. package/dist/features/viz/lib/financial-autoscale.js.map +7 -0
  185. package/dist/features/viz/lib/financial-comparison.d.ts +62 -0
  186. package/dist/features/viz/lib/financial-comparison.js +98 -0
  187. package/dist/features/viz/lib/financial-comparison.js.map +7 -0
  188. package/dist/features/viz/lib/financial-geometry.d.ts +77 -0
  189. package/dist/features/viz/lib/financial-geometry.js +67 -0
  190. package/dist/features/viz/lib/financial-geometry.js.map +7 -0
  191. package/dist/features/viz/lib/financial-indicators.d.ts +114 -0
  192. package/dist/features/viz/lib/financial-indicators.js +135 -0
  193. package/dist/features/viz/lib/financial-indicators.js.map +7 -0
  194. package/dist/features/viz/lib/financial-oscillators.d.ts +171 -0
  195. package/dist/features/viz/lib/financial-oscillators.js +265 -0
  196. package/dist/features/viz/lib/financial-oscillators.js.map +7 -0
  197. package/dist/features/viz/lib/graph/bipartite.d.ts +14 -0
  198. package/dist/features/viz/lib/graph/bipartite.js +250 -0
  199. package/dist/features/viz/lib/graph/bipartite.js.map +7 -0
  200. package/dist/features/viz/lib/graph/chord.d.ts +44 -0
  201. package/dist/features/viz/lib/graph/chord.js +348 -0
  202. package/dist/features/viz/lib/graph/chord.js.map +7 -0
  203. package/dist/features/viz/lib/graph/dependency.d.ts +26 -0
  204. package/dist/features/viz/lib/graph/dependency.js +140 -0
  205. package/dist/features/viz/lib/graph/dependency.js.map +7 -0
  206. package/dist/features/viz/lib/graph/force.d.ts +28 -0
  207. package/dist/features/viz/lib/graph/force.js +580 -0
  208. package/dist/features/viz/lib/graph/force.js.map +7 -0
  209. package/dist/features/viz/lib/graph/hierarchy.d.ts +21 -0
  210. package/dist/features/viz/lib/graph/hierarchy.js +112 -0
  211. package/dist/features/viz/lib/graph/hierarchy.js.map +7 -0
  212. package/dist/features/viz/lib/graph/icicle.d.ts +16 -0
  213. package/dist/features/viz/lib/graph/icicle.js +153 -0
  214. package/dist/features/viz/lib/graph/icicle.js.map +7 -0
  215. package/dist/features/viz/lib/graph/matrix.d.ts +30 -0
  216. package/dist/features/viz/lib/graph/matrix.js +243 -0
  217. package/dist/features/viz/lib/graph/matrix.js.map +7 -0
  218. package/dist/features/viz/lib/graph/neighborhood.d.ts +11 -0
  219. package/dist/features/viz/lib/graph/neighborhood.js +281 -0
  220. package/dist/features/viz/lib/graph/neighborhood.js.map +7 -0
  221. package/dist/features/viz/lib/graph/routes.d.ts +35 -0
  222. package/dist/features/viz/lib/graph/routes.js +101 -0
  223. package/dist/features/viz/lib/graph/routes.js.map +7 -0
  224. package/dist/features/viz/lib/graph/sankey.d.ts +44 -0
  225. package/dist/features/viz/lib/graph/sankey.js +341 -0
  226. package/dist/features/viz/lib/graph/sankey.js.map +7 -0
  227. package/dist/features/viz/lib/graph/shared.d.ts +59 -0
  228. package/dist/features/viz/lib/graph/shared.js +301 -0
  229. package/dist/features/viz/lib/graph/shared.js.map +7 -0
  230. package/dist/features/viz/lib/graph/tree.d.ts +11 -0
  231. package/dist/features/viz/lib/graph/tree.js +232 -0
  232. package/dist/features/viz/lib/graph/tree.js.map +7 -0
  233. package/dist/features/viz/lib/graph/treemap.d.ts +20 -0
  234. package/dist/features/viz/lib/graph/treemap.js +227 -0
  235. package/dist/features/viz/lib/graph/treemap.js.map +7 -0
  236. package/dist/features/viz/lib/graph/types.d.ts +1097 -0
  237. package/dist/features/viz/lib/hover-card.js +8 -9
  238. package/dist/features/viz/lib/hover-card.js.map +2 -2
  239. package/dist/features/viz/lib/hover-data.d.ts +1 -1
  240. package/dist/features/viz/lib/hover-data.js +6 -3
  241. package/dist/features/viz/lib/hover-data.js.map +2 -2
  242. package/dist/features/viz/lib/hover-types.d.ts +5 -5
  243. package/dist/features/viz/lib/interval-band-series.d.ts +49 -0
  244. package/dist/features/viz/lib/interval-band-series.js +136 -0
  245. package/dist/features/viz/lib/interval-band-series.js.map +7 -0
  246. package/dist/features/viz/lib/interval-diamond-series.d.ts +43 -0
  247. package/dist/features/viz/lib/interval-diamond-series.js +122 -0
  248. package/dist/features/viz/lib/interval-diamond-series.js.map +7 -0
  249. package/dist/features/viz/lib/interval-series.d.ts +79 -0
  250. package/dist/features/viz/lib/interval-series.js +158 -0
  251. package/dist/features/viz/lib/interval-series.js.map +7 -0
  252. package/dist/features/viz/lib/layout-pie.js +9 -13
  253. package/dist/features/viz/lib/layout-pie.js.map +2 -2
  254. package/dist/features/viz/lib/line-series.d.ts +1 -1
  255. package/dist/features/viz/lib/line-series.js +47 -28
  256. package/dist/features/viz/lib/line-series.js.map +2 -2
  257. package/dist/features/viz/lib/linear-scale-component.d.ts +7 -0
  258. package/dist/features/viz/lib/linear-scale-component.js +18 -0
  259. package/dist/features/viz/lib/linear-scale-component.js.map +7 -0
  260. package/dist/features/viz/lib/linear-scale.js +1 -1
  261. package/dist/features/viz/lib/linear-scale.js.map +2 -2
  262. package/dist/features/viz/lib/log-scale-component.d.ts +7 -0
  263. package/dist/features/viz/lib/log-scale-component.js +19 -0
  264. package/dist/features/viz/lib/log-scale-component.js.map +7 -0
  265. package/dist/features/viz/lib/log-scale.d.ts +2 -0
  266. package/dist/features/viz/lib/log-scale.js +53 -0
  267. package/dist/features/viz/lib/log-scale.js.map +7 -0
  268. package/dist/features/viz/lib/monotone-curve.d.ts +11 -0
  269. package/dist/features/viz/lib/monotone-curve.js +63 -0
  270. package/dist/features/viz/lib/monotone-curve.js.map +7 -0
  271. package/dist/features/viz/lib/nearest.d.ts +9 -9
  272. package/dist/features/viz/lib/nearest.js.map +1 -1
  273. package/dist/features/viz/lib/numeric-range-interpolation.d.ts +15 -0
  274. package/dist/features/viz/lib/numeric-range-interpolation.js +36 -0
  275. package/dist/features/viz/lib/numeric-range-interpolation.js.map +7 -0
  276. package/dist/features/viz/lib/numeric-ticks.d.ts +38 -0
  277. package/dist/features/viz/lib/numeric-ticks.js +54 -0
  278. package/dist/features/viz/lib/numeric-ticks.js.map +7 -0
  279. package/dist/features/viz/lib/ohlc-bar-series.d.ts +55 -0
  280. package/dist/features/viz/lib/ohlc-bar-series.js +168 -0
  281. package/dist/features/viz/lib/ohlc-bar-series.js.map +7 -0
  282. package/dist/features/viz/lib/paired-series.d.ts +44 -0
  283. package/dist/features/viz/lib/paired-series.js +93 -0
  284. package/dist/features/viz/lib/paired-series.js.map +7 -0
  285. package/dist/features/viz/lib/pie-layout.js +2 -1
  286. package/dist/features/viz/lib/pie-layout.js.map +2 -2
  287. package/dist/features/viz/lib/plot-series.js +11 -6
  288. package/dist/features/viz/lib/plot-series.js.map +2 -2
  289. package/dist/features/viz/lib/plot-types.d.ts +4 -3
  290. package/dist/features/viz/lib/point-scale-component.d.ts +7 -0
  291. package/dist/features/viz/lib/point-scale-component.js +19 -0
  292. package/dist/features/viz/lib/point-scale-component.js.map +7 -0
  293. package/dist/features/viz/lib/point-scale.d.ts +2 -0
  294. package/dist/features/viz/lib/point-scale.js +45 -0
  295. package/dist/features/viz/lib/point-scale.js.map +7 -0
  296. package/dist/features/viz/lib/point-series.d.ts +1 -1
  297. package/dist/features/viz/lib/point-series.js +36 -9
  298. package/dist/features/viz/lib/point-series.js.map +2 -2
  299. package/dist/features/viz/lib/point-types.d.ts +5 -2
  300. package/dist/features/viz/lib/reference-band.d.ts +16 -0
  301. package/dist/features/viz/lib/reference-band.js +30 -0
  302. package/dist/features/viz/lib/reference-band.js.map +7 -0
  303. package/dist/features/viz/lib/scale-adjust.js +9 -4
  304. package/dist/features/viz/lib/scale-adjust.js.map +2 -2
  305. package/dist/features/viz/lib/scale-context.d.ts +5 -4
  306. package/dist/features/viz/lib/scale-context.js +15 -11
  307. package/dist/features/viz/lib/scale-context.js.map +2 -2
  308. package/dist/features/viz/lib/scale-provider.d.ts +2 -0
  309. package/dist/features/viz/lib/scale-provider.js +13 -0
  310. package/dist/features/viz/lib/scale-provider.js.map +7 -0
  311. package/dist/features/viz/lib/scale-ticks.d.ts +5 -0
  312. package/dist/features/viz/lib/scale-ticks.js +64 -0
  313. package/dist/features/viz/lib/scale-ticks.js.map +7 -0
  314. package/dist/features/viz/lib/scale-view.d.ts +4 -0
  315. package/dist/features/viz/lib/scale-view.js +21 -0
  316. package/dist/features/viz/lib/scale-view.js.map +7 -0
  317. package/dist/features/viz/lib/sequential-color-scale.d.ts +11 -0
  318. package/dist/features/viz/lib/sequential-color-scale.js +49 -0
  319. package/dist/features/viz/lib/sequential-color-scale.js.map +7 -0
  320. package/dist/features/viz/lib/series-position.d.ts +12 -0
  321. package/dist/features/viz/lib/series-position.js +44 -0
  322. package/dist/features/viz/lib/series-position.js.map +7 -0
  323. package/dist/features/viz/lib/step-curves.d.ts +19 -0
  324. package/dist/features/viz/lib/step-curves.js +53 -0
  325. package/dist/features/viz/lib/step-curves.js.map +7 -0
  326. package/dist/features/viz/lib/symlog-scale-component.d.ts +7 -0
  327. package/dist/features/viz/lib/symlog-scale-component.js +19 -0
  328. package/dist/features/viz/lib/symlog-scale-component.js.map +7 -0
  329. package/dist/features/viz/lib/symlog-scale.d.ts +2 -0
  330. package/dist/features/viz/lib/symlog-scale.js +38 -0
  331. package/dist/features/viz/lib/symlog-scale.js.map +7 -0
  332. package/dist/features/viz/lib/threshold-color-scale.d.ts +43 -0
  333. package/dist/features/viz/lib/threshold-color-scale.js +59 -0
  334. package/dist/features/viz/lib/threshold-color-scale.js.map +7 -0
  335. package/dist/features/viz/lib/trading-time-mapping.d.ts +32 -0
  336. package/dist/features/viz/lib/trading-time-mapping.js +89 -0
  337. package/dist/features/viz/lib/trading-time-mapping.js.map +7 -0
  338. package/dist/features/viz/lib/trading-time-scale.d.ts +83 -0
  339. package/dist/features/viz/lib/trading-time-scale.js +96 -0
  340. package/dist/features/viz/lib/trading-time-scale.js.map +7 -0
  341. package/dist/features/viz/lib/trajectory-series.d.ts +71 -0
  342. package/dist/features/viz/lib/trajectory-series.js +111 -0
  343. package/dist/features/viz/lib/trajectory-series.js.map +7 -0
  344. package/dist/features/viz/lib/types.d.ts +114 -21
  345. package/dist/features/viz/lib/use-bar-scale.d.ts +8 -0
  346. package/dist/features/viz/lib/use-bar-scale.js +9 -0
  347. package/dist/features/viz/lib/use-bar-scale.js.map +7 -0
  348. package/dist/features/viz/lib/use-continuous-scale.d.ts +8 -0
  349. package/dist/features/viz/lib/use-continuous-scale.js +14 -0
  350. package/dist/features/viz/lib/use-continuous-scale.js.map +7 -0
  351. package/dist/features/viz/lib/use-linear-scale.d.ts +8 -0
  352. package/dist/features/viz/lib/use-linear-scale.js +9 -0
  353. package/dist/features/viz/lib/use-linear-scale.js.map +7 -0
  354. package/dist/features/viz/lib/use-log-scale.d.ts +8 -0
  355. package/dist/features/viz/lib/use-log-scale.js +9 -0
  356. package/dist/features/viz/lib/use-log-scale.js.map +7 -0
  357. package/dist/features/viz/lib/use-point-scale.d.ts +8 -0
  358. package/dist/features/viz/lib/use-point-scale.js +9 -0
  359. package/dist/features/viz/lib/use-point-scale.js.map +7 -0
  360. package/dist/features/viz/lib/use-symlog-scale.d.ts +8 -0
  361. package/dist/features/viz/lib/use-symlog-scale.js +9 -0
  362. package/dist/features/viz/lib/use-symlog-scale.js.map +7 -0
  363. package/dist/features/viz/lib/use-utc-scale.d.ts +8 -0
  364. package/dist/features/viz/lib/use-utc-scale.js +9 -0
  365. package/dist/features/viz/lib/use-utc-scale.js.map +7 -0
  366. package/dist/features/viz/lib/utc-labels.d.ts +12 -0
  367. package/dist/features/viz/lib/utc-labels.js +27 -0
  368. package/dist/features/viz/lib/utc-labels.js.map +7 -0
  369. package/dist/features/viz/lib/utc-scale-component.d.ts +7 -0
  370. package/dist/features/viz/lib/utc-scale-component.js +18 -0
  371. package/dist/features/viz/lib/utc-scale-component.js.map +7 -0
  372. package/dist/features/viz/lib/utc-scale.d.ts +21 -0
  373. package/dist/features/viz/lib/utc-scale.js +124 -0
  374. package/dist/features/viz/lib/utc-scale.js.map +7 -0
  375. package/dist/features/viz/lib/volume-series.d.ts +59 -0
  376. package/dist/features/viz/lib/volume-series.js +117 -0
  377. package/dist/features/viz/lib/volume-series.js.map +7 -0
  378. package/dist/features/viz/lib/weighted-point-series.d.ts +71 -0
  379. package/dist/features/viz/lib/weighted-point-series.js +169 -0
  380. package/dist/features/viz/lib/weighted-point-series.js.map +7 -0
  381. package/dist/filters/backdrop-contrast-gpu.d.ts +5 -0
  382. package/dist/filters/backdrop-contrast-gpu.js +33 -0
  383. package/dist/filters/backdrop-contrast-gpu.js.map +7 -0
  384. package/dist/filters/backdrop-contrast.d.ts +21 -0
  385. package/dist/filters/backdrop-contrast.js +61 -0
  386. package/dist/filters/backdrop-contrast.js.map +7 -0
  387. package/dist/filters/displacement.js +1 -1
  388. package/dist/filters/displacement.js.map +2 -2
  389. package/dist/filters/emboss-gpu.d.ts +4 -0
  390. package/dist/filters/emboss-gpu.js +39 -0
  391. package/dist/filters/emboss-gpu.js.map +7 -0
  392. package/dist/filters/emboss.d.ts +32 -0
  393. package/dist/filters/emboss.js +104 -0
  394. package/dist/filters/emboss.js.map +7 -0
  395. package/dist/filters/filter-executor.d.ts +11 -4
  396. package/dist/filters/filter-executor.js +104 -49
  397. package/dist/filters/filter-executor.js.map +2 -2
  398. package/dist/filters/reflected-light.js +1 -1
  399. package/dist/filters/reflected-light.js.map +2 -2
  400. package/dist/filters/reflection-gpu.d.ts +3 -1
  401. package/dist/filters/reflection-gpu.js +5 -2
  402. package/dist/filters/reflection-gpu.js.map +2 -2
  403. package/dist/filters/render-backdrop-contrast-boundary.d.ts +31 -0
  404. package/dist/filters/render-backdrop-contrast-boundary.js +116 -0
  405. package/dist/filters/render-backdrop-contrast-boundary.js.map +7 -0
  406. package/dist/filters/render-emboss-boundary.d.ts +13 -0
  407. package/dist/filters/render-emboss-boundary.js +131 -0
  408. package/dist/filters/render-emboss-boundary.js.map +7 -0
  409. package/dist/filters.d.ts +9 -5
  410. package/dist/filters.js +4 -0
  411. package/dist/filters.js.map +2 -2
  412. package/dist/index.d.ts +10 -6
  413. package/dist/index.js +18 -2
  414. package/dist/index.js.map +2 -2
  415. package/dist/internal.d.ts +4 -0
  416. package/dist/internal.js +6 -0
  417. package/dist/internal.js.map +2 -2
  418. package/dist/layout-kernel.d.ts +12 -0
  419. package/dist/layout-kernel.js +11 -0
  420. package/dist/layout-kernel.js.map +7 -0
  421. package/dist/layout-kernel.mjs +1 -0
  422. package/dist/lib/animation/definition.d.ts +5 -3
  423. package/dist/lib/animation/definition.js +29 -4
  424. package/dist/lib/animation/definition.js.map +2 -2
  425. package/dist/lib/animation/playback.d.ts +8 -0
  426. package/dist/lib/animation/playback.js +33 -11
  427. package/dist/lib/animation/playback.js.map +2 -2
  428. package/dist/lib/animation/spring.d.ts +3 -1
  429. package/dist/lib/animation/spring.js.map +2 -2
  430. package/dist/lib/animation/types.d.ts +29 -73
  431. package/dist/lib/backend/types.d.ts +13 -1
  432. package/dist/lib/backend/types.js.map +2 -2
  433. package/dist/lib/components/arc-geometry.js +2 -1
  434. package/dist/lib/components/arc-geometry.js.map +2 -2
  435. package/dist/lib/components/g.js +2 -0
  436. package/dist/lib/components/g.js.map +2 -2
  437. package/dist/lib/components/html-box.js +2 -1
  438. package/dist/lib/components/html-box.js.map +2 -2
  439. package/dist/lib/components/img.js +3 -3
  440. package/dist/lib/components/img.js.map +2 -2
  441. package/dist/lib/components/layer.js +98 -16
  442. package/dist/lib/components/layer.js.map +3 -3
  443. package/dist/lib/components/text.d.ts +16 -0
  444. package/dist/lib/components/text.js +131 -24
  445. package/dist/lib/components/text.js.map +2 -2
  446. package/dist/lib/define-primitive.d.ts +4 -2
  447. package/dist/lib/define-primitive.js +3 -1
  448. package/dist/lib/define-primitive.js.map +2 -2
  449. package/dist/lib/element/metadata.d.ts +9 -0
  450. package/dist/lib/element/metadata.js +19 -0
  451. package/dist/lib/element/metadata.js.map +2 -2
  452. package/dist/lib/element/resolve-primitive-inputs.d.ts +2 -0
  453. package/dist/lib/element/resolve-primitive-inputs.js +17 -4
  454. package/dist/lib/element/resolve-primitive-inputs.js.map +2 -2
  455. package/dist/lib/events/event-facade.d.ts +18 -0
  456. package/dist/lib/events/event-facade.js +28 -2
  457. package/dist/lib/events/event-facade.js.map +2 -2
  458. package/dist/lib/events/hit-test.js +2 -1
  459. package/dist/lib/events/hit-test.js.map +2 -2
  460. package/dist/lib/events/propagation.d.ts +2 -1
  461. package/dist/lib/events/propagation.js +22 -16
  462. package/dist/lib/events/propagation.js.map +2 -2
  463. package/dist/lib/events/registrations.d.ts +10 -0
  464. package/dist/lib/events/registrations.js +160 -5
  465. package/dist/lib/events/registrations.js.map +2 -2
  466. package/dist/lib/execute-render.js +25 -1
  467. package/dist/lib/execute-render.js.map +2 -2
  468. package/dist/lib/filter/filter-region.js +3 -10
  469. package/dist/lib/filter/filter-region.js.map +2 -2
  470. package/dist/lib/focus/focus-manager.d.ts +8 -1
  471. package/dist/lib/focus/focus-manager.js +87 -43
  472. package/dist/lib/focus/focus-manager.js.map +2 -2
  473. package/dist/lib/focus/geometry.d.ts +2 -0
  474. package/dist/lib/focus/geometry.js +6 -0
  475. package/dist/lib/focus/geometry.js.map +2 -2
  476. package/dist/lib/geometry/path-bend-guide.js +1 -1
  477. package/dist/lib/geometry/path-bend-guide.js.map +2 -2
  478. package/dist/lib/geometry/path-geometry.js +12 -11
  479. package/dist/lib/geometry/path-geometry.js.map +2 -2
  480. package/dist/lib/geometry/path-transforms.js +17 -21
  481. package/dist/lib/geometry/path-transforms.js.map +2 -2
  482. package/dist/lib/geometry/path-warp-bezier.js +3 -1
  483. package/dist/lib/geometry/path-warp-bezier.js.map +2 -2
  484. package/dist/lib/geometry/path-warp.js +1 -1
  485. package/dist/lib/geometry/path-warp.js.map +2 -2
  486. package/dist/lib/global-state.js +2 -0
  487. package/dist/lib/global-state.js.map +2 -2
  488. package/dist/lib/hooks/use-animated-value.d.ts +11 -21
  489. package/dist/lib/hooks/use-animated-value.js +23 -70
  490. package/dist/lib/hooks/use-animated-value.js.map +3 -3
  491. package/dist/lib/hooks/use-playback.js +1 -0
  492. package/dist/lib/hooks/use-playback.js.map +2 -2
  493. package/dist/lib/html/html-events.d.ts +32 -0
  494. package/dist/lib/html/html-events.js +179 -0
  495. package/dist/lib/html/html-events.js.map +7 -0
  496. package/dist/lib/html/html-service.d.ts +8 -2
  497. package/dist/lib/html/html-service.js +198 -65
  498. package/dist/lib/html/html-service.js.map +2 -2
  499. package/dist/lib/html/overlay-config.js +7 -6
  500. package/dist/lib/html/overlay-config.js.map +2 -2
  501. package/dist/lib/html/types.d.ts +29 -2
  502. package/dist/lib/layout/absolute.d.ts +11 -5
  503. package/dist/lib/layout/absolute.js +329 -55
  504. package/dist/lib/layout/absolute.js.map +3 -3
  505. package/dist/lib/layout/allocation-checkpoint-owner.d.ts +11 -0
  506. package/dist/lib/layout/allocation-checkpoint-owner.js +86 -0
  507. package/dist/lib/layout/allocation-checkpoint-owner.js.map +7 -0
  508. package/dist/lib/layout/allocation-checkpoint.d.ts +53 -0
  509. package/dist/lib/layout/allocation-checkpoint.js +463 -0
  510. package/dist/lib/layout/allocation-checkpoint.js.map +7 -0
  511. package/dist/lib/layout/allocation-dependencies.d.ts +30 -0
  512. package/dist/lib/layout/allocation-dependencies.js +90 -0
  513. package/dist/lib/layout/allocation-dependencies.js.map +7 -0
  514. package/dist/lib/layout/allocation-revision.d.ts +13 -0
  515. package/dist/lib/layout/allocation-revision.js +67 -0
  516. package/dist/lib/layout/allocation-revision.js.map +7 -0
  517. package/dist/lib/layout/box-insets.d.ts +17 -0
  518. package/dist/lib/layout/box-insets.js +138 -0
  519. package/dist/lib/layout/box-insets.js.map +7 -0
  520. package/dist/lib/layout/box-sizing.d.ts +16 -0
  521. package/dist/lib/layout/box-sizing.js +77 -0
  522. package/dist/lib/layout/box-sizing.js.map +7 -0
  523. package/dist/lib/layout/box.js +42 -12
  524. package/dist/lib/layout/box.js.map +2 -2
  525. package/dist/lib/layout/canvas-measurement.d.ts +13 -0
  526. package/dist/lib/layout/canvas-measurement.js +57 -0
  527. package/dist/lib/layout/canvas-measurement.js.map +7 -0
  528. package/dist/lib/layout/context.d.ts +35 -6
  529. package/dist/lib/layout/context.js +72 -3
  530. package/dist/lib/layout/context.js.map +2 -2
  531. package/dist/lib/layout/define-layout-component.d.ts +23 -0
  532. package/dist/lib/layout/define-layout-component.js +84 -0
  533. package/dist/lib/layout/define-layout-component.js.map +7 -0
  534. package/dist/lib/layout/flex-allocation-cache.d.ts +42 -0
  535. package/dist/lib/layout/flex-baseline-mode.d.ts +2 -0
  536. package/dist/lib/layout/flex-baseline-mode.js +7 -0
  537. package/dist/lib/layout/flex-baseline-mode.js.map +7 -0
  538. package/dist/lib/layout/flex.d.ts +50 -15
  539. package/dist/lib/layout/flex.js +2124 -195
  540. package/dist/lib/layout/flex.js.map +3 -3
  541. package/dist/lib/layout/flow.js +225 -49
  542. package/dist/lib/layout/flow.js.map +2 -2
  543. package/dist/lib/layout/geometry-publication.d.ts +53 -0
  544. package/dist/lib/layout/geometry-publication.js +244 -0
  545. package/dist/lib/layout/geometry-publication.js.map +7 -0
  546. package/dist/lib/layout/grid-kernel.d.ts +63 -0
  547. package/dist/lib/layout/grid-kernel.js +168 -0
  548. package/dist/lib/layout/grid-kernel.js.map +7 -0
  549. package/dist/lib/layout/grid.d.ts +63 -4
  550. package/dist/lib/layout/grid.js +767 -171
  551. package/dist/lib/layout/grid.js.map +3 -3
  552. package/dist/lib/layout/measure.d.ts +55 -3
  553. package/dist/lib/layout/measure.js +448 -15
  554. package/dist/lib/layout/measure.js.map +2 -2
  555. package/dist/lib/layout/overlay.js +81 -23
  556. package/dist/lib/layout/overlay.js.map +2 -2
  557. package/dist/lib/layout/participation.d.ts +27 -0
  558. package/dist/lib/layout/participation.js +188 -0
  559. package/dist/lib/layout/participation.js.map +7 -0
  560. package/dist/lib/layout/place-child.js +1 -1
  561. package/dist/lib/layout/place-child.js.map +2 -2
  562. package/dist/lib/layout/positioning-diagnostics.d.ts +1 -1
  563. package/dist/lib/layout/positioning-diagnostics.js +13 -2
  564. package/dist/lib/layout/positioning-diagnostics.js.map +2 -2
  565. package/dist/lib/layout/prepared-root.d.ts +121 -0
  566. package/dist/lib/layout/prepared-root.js +360 -0
  567. package/dist/lib/layout/prepared-root.js.map +7 -0
  568. package/dist/lib/layout/standalone-kernel.d.ts +60 -0
  569. package/dist/lib/layout/standalone-kernel.js +722 -0
  570. package/dist/lib/layout/standalone-kernel.js.map +7 -0
  571. package/dist/lib/layout/topology.d.ts +21 -0
  572. package/dist/lib/layout/topology.js +113 -0
  573. package/dist/lib/layout/topology.js.map +7 -0
  574. package/dist/lib/layout/types.d.ts +5 -0
  575. package/dist/lib/layout/wasm/artifact.d.ts +1 -0
  576. package/dist/lib/layout/wasm/artifact.js +5 -0
  577. package/dist/lib/layout/wasm/artifact.js.map +7 -0
  578. package/dist/lib/layout/wasm/bytes.d.ts +1 -0
  579. package/dist/lib/layout/wasm/bytes.js +5 -0
  580. package/dist/lib/layout/wasm/bytes.js.map +7 -0
  581. package/dist/lib/layout/wasm/embedded.d.ts +2 -0
  582. package/dist/lib/layout/wasm/embedded.js +12 -0
  583. package/dist/lib/layout/wasm/embedded.js.map +7 -0
  584. package/dist/lib/layout/wasm/layout.wasm +0 -0
  585. package/dist/lib/layout/wasm/module.d.ts +8 -0
  586. package/dist/lib/layout/wasm/module.js +70 -0
  587. package/dist/lib/layout/wasm/module.js.map +7 -0
  588. package/dist/lib/layout/wasm/region.d.ts +267 -0
  589. package/dist/lib/layout/wasm/region.js +1018 -0
  590. package/dist/lib/layout/wasm/region.js.map +7 -0
  591. package/dist/lib/manipulation/controller.js +4 -7
  592. package/dist/lib/manipulation/controller.js.map +2 -2
  593. package/dist/lib/manipulation/frame.js +1 -1
  594. package/dist/lib/manipulation/frame.js.map +2 -2
  595. package/dist/lib/manipulation/handles.js +32 -33
  596. package/dist/lib/manipulation/handles.js.map +2 -2
  597. package/dist/lib/manipulation/solve.js +12 -10
  598. package/dist/lib/manipulation/solve.js.map +2 -2
  599. package/dist/lib/mount-pibbl.js +1 -0
  600. package/dist/lib/mount-pibbl.js.map +2 -2
  601. package/dist/lib/mount-prepared-pibbl.d.ts +5 -0
  602. package/dist/lib/mount-prepared-pibbl.js +29 -0
  603. package/dist/lib/mount-prepared-pibbl.js.map +7 -0
  604. package/dist/lib/mount-request.d.ts +8 -0
  605. package/dist/lib/mount-request.js +41 -0
  606. package/dist/lib/mount-request.js.map +7 -0
  607. package/dist/lib/pibbl.d.ts +21 -13
  608. package/dist/lib/pibbl.js +18 -16
  609. package/dist/lib/pibbl.js.map +2 -2
  610. package/dist/lib/recording/recording.d.ts +43 -0
  611. package/dist/lib/recording/recording.js +555 -0
  612. package/dist/lib/recording/recording.js.map +7 -0
  613. package/dist/lib/recording/types.d.ts +118 -0
  614. package/dist/lib/recording/wasm-bytes.d.ts +1 -0
  615. package/dist/lib/recording/wasm-bytes.js +5 -0
  616. package/dist/lib/recording/wasm-bytes.js.map +7 -0
  617. package/dist/lib/recording/worker-source.d.ts +1 -0
  618. package/dist/lib/recording/worker-source.js +5 -0
  619. package/dist/lib/recording/worker-source.js.map +7 -0
  620. package/dist/lib/render-layer/controller.d.ts +9 -3
  621. package/dist/lib/render-layer/controller.js +259 -110
  622. package/dist/lib/render-layer/controller.js.map +2 -2
  623. package/dist/lib/render-transaction.d.ts +12 -2
  624. package/dist/lib/render-transaction.js +69 -1
  625. package/dist/lib/render-transaction.js.map +2 -2
  626. package/dist/lib/render.js +32 -8
  627. package/dist/lib/render.js.map +2 -2
  628. package/dist/lib/scheduler/realm-scheduler.d.ts +2 -0
  629. package/dist/lib/scheduler/realm-scheduler.js +55 -26
  630. package/dist/lib/scheduler/realm-scheduler.js.map +2 -2
  631. package/dist/lib/scheduler/renderer-participant.js +1 -0
  632. package/dist/lib/scheduler/renderer-participant.js.map +2 -2
  633. package/dist/lib/series-inspection-frame.d.ts +18 -0
  634. package/dist/lib/series-inspection-frame.js +70 -0
  635. package/dist/lib/series-inspection-frame.js.map +7 -0
  636. package/dist/lib/signals/edge.d.ts +7 -4
  637. package/dist/lib/signals/edge.js +25 -3
  638. package/dist/lib/signals/edge.js.map +2 -2
  639. package/dist/lib/signals/graph.d.ts +16 -2
  640. package/dist/lib/signals/graph.js +54 -12
  641. package/dist/lib/signals/graph.js.map +2 -2
  642. package/dist/lib/signals/input-provision.d.ts +15 -0
  643. package/dist/lib/signals/input-provision.js +53 -3
  644. package/dist/lib/signals/input-provision.js.map +2 -2
  645. package/dist/lib/signals/render-consumer.d.ts +3 -0
  646. package/dist/lib/signals/render-consumer.js +22 -14
  647. package/dist/lib/signals/render-consumer.js.map +2 -2
  648. package/dist/lib/style/positioning.d.ts +50 -2
  649. package/dist/lib/style/positioning.js +28 -4
  650. package/dist/lib/style/positioning.js.map +2 -2
  651. package/dist/lib/style/resolve-built-in.d.ts +4 -3
  652. package/dist/lib/style/resolve-built-in.js +17 -3
  653. package/dist/lib/style/resolve-built-in.js.map +2 -2
  654. package/dist/lib/style/resolve-dispatch.d.ts +3 -0
  655. package/dist/lib/style/resolve-dispatch.js +77 -4
  656. package/dist/lib/style/resolve-dispatch.js.map +2 -2
  657. package/dist/lib/style/resolve-length.d.ts +2 -0
  658. package/dist/lib/style/resolve-length.js +13 -9
  659. package/dist/lib/style/resolve-length.js.map +2 -2
  660. package/dist/lib/style/sizing-length.d.ts +51 -0
  661. package/dist/lib/style/sizing-length.js +77 -0
  662. package/dist/lib/style/sizing-length.js.map +7 -0
  663. package/dist/lib/style/types.d.ts +63 -25
  664. package/dist/lib/surface/root-surface.js +10 -6
  665. package/dist/lib/surface/root-surface.js.map +2 -2
  666. package/dist/lib/textures/texture.js +10 -8
  667. package/dist/lib/textures/texture.js.map +2 -2
  668. package/dist/lib/transitions/capture.js +4 -1
  669. package/dist/lib/transitions/capture.js.map +2 -2
  670. package/dist/lib/transitions/embers-physics.js +17 -10
  671. package/dist/lib/transitions/embers-physics.js.map +2 -2
  672. package/dist/lib/types.d.ts +110 -1
  673. package/dist/sync.d.ts +16 -0
  674. package/dist/sync.js +13 -0
  675. package/dist/sync.js.map +7 -0
  676. package/dist/sync.mjs +1 -0
  677. package/package.json +43 -6
  678. package/dist/features/viz/lib/scale.d.ts +0 -11
  679. package/dist/features/viz/lib/scale.js +0 -80
  680. package/dist/features/viz/lib/scale.js.map +0 -7
  681. package/dist/features/viz/lib/use-scale.d.ts +0 -20
  682. package/dist/features/viz/lib/use-scale.js +0 -10
  683. package/dist/features/viz/lib/use-scale.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/manipulation/handles.ts"],
4
- "sourcesContent": ["import type { PibblResizePosition } from \"./types.js\";\nimport type { PibblManipulationWhen } from './types.js';\nimport type { PibblManipulableProps } from './manipulable.js';\nimport { createElement } from \"../element/create-element.js\";\nimport {\n createGroupTransform,\n setPrimitivePresentation,\n} from \"../primitive-presentation.js\";\nimport { getCurrentWorldTransform } from \"../render-target.js\";\nimport { GLOBAL_STATE } from \"../global-state.js\";\nimport { definePrimitive } from \"../define-primitive.js\";\nimport { useEventListener } from \"../hooks/use-event-listener.js\";\nimport { useEventTarget } from \"../hooks/use-event-target.js\";\nimport { useSignal } from \"../hooks/use-signal.js\";\nimport { useConst } from \"../hooks/use-const.js\";\nimport type { GStyle } from \"../components/g.js\";\nimport { stripLayoutParticipation } from \"../style/resolve-built-in.js\";\nimport type { ResolvedDrawingStyle } from \"../style/types.js\";\nimport { getLayoutBox } from \"../layout/context.js\";\nimport type { PibblNode } from \"../element/types.js\";\nimport type { RenderingContext2D, SystemStyle } from \"../types.js\";\nimport type { PibblManipulationController } from \"./controller-types.js\";\nimport {\n isManipulationSourceActive,\n manipulationHandlers,\n type ManipulationState,\n} from \"./controller.js\";\nimport { requireManipulationFrame } from \"./frame.js\";\n\n/**\n * Authored inputs for DragHandle, including the declared data and presentation options.\n *\n * @see {@link PibblManipulationController}\n * @see {@link PibblNode}\n * @see {@link DragHandle}\n * @see {@link PibblManipulationWhen}\n */\nexport interface PibblDragHandleProps {\n /**\n * Formats the value shown by the manipulation readout. See {@link PibblDragHandleProps}.\n * @param value - Current left and top coordinates.\n * @returns Text to display in the drag readout.\n */\n readonly formatReadout?: (value: {\n /** Left edge coordinate or inset. See {@link PibblDragHandleProps}. */\n readonly left: number;\n /** Top edge value or top envelope guide. See {@link PibblDragHandleProps}. */\n readonly top: number;\n }) => string;\n /**\n * Controller owning the current interaction or mounted scenario. See\n * {@link PibblManipulationController}.\n */\n readonly controller: PibblManipulationController;\n /** Descendant content or the callback that supplies it. See {@link PibblNode}. */\n readonly children?: PibblNode;\n}\n/**\n * Supported geometry and presentation properties for DragHandle.\n *\n * @see {@link GStyle}\n * @see {@link PibblManipulationReadoutStyle}\n * @see {@link DragHandle}\n * @see {@link PibblManipulableProps}\n */\nexport interface PibblDragHandleStyle extends GStyle {\n /** Presentation of the manipulation value readout. See {@link PibblManipulationReadoutStyle}. */\n readonly readout?: false | true | PibblManipulationReadoutStyle;\n}\ntype ResolvedDragStyle = ResolvedDrawingStyle<PibblDragHandleStyle>;\ninterface CssHandleContentProps {\n readonly children?: PibblNode;\n}\ninterface CssHandleContentStyle extends SystemStyle {\n readonly transform: DOMMatrix;\n}\n/** Private CSS-pixel basis for author-provided handle visuals. */\nconst CssHandleContent = definePrimitive<\n CssHandleContentProps,\n CssHandleContentStyle\n>(\n function CssHandleContent(props) {\n return props.children;\n },\n { childInput: \"structural\" },\n);\nsetPrimitivePresentation<CssHandleContentStyle>(CssHandleContent, (style) => ({\n transform: style.transform,\n}));\n\n/**\n * Draws an interactive handle that starts translation of its manipulation target.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link PibblDragHandleProps}\n * @see {@link PibblDragHandleStyle}\n */\nexport const DragHandle = definePrimitive<\n PibblDragHandleProps,\n PibblDragHandleStyle,\n PibblDragHandleStyle,\n ResolvedDragStyle\n>(\n function DragHandle(props, style) {\n requireManipulationFrame(props.controller);\n const focused = useSignal(false);\n const source = useConst(() => ({}));\n const handlers = manipulationHandlers(\n props.controller,\n \"move\",\n undefined,\n source,\n );\n useEventListener({\n ...handlers,\n onFocusIn: () => focused.set(true),\n onFocusOut: () => focused.set(false),\n });\n const box = getLayoutBox();\n return [\n props.children,\n createElement(DragReadout, {\n controller: props.controller,\n formatReadout: props.formatReadout,\n readout: style.readout,\n focused: focused.get(),\n source,\n anchorX: box.width / 2,\n }),\n ];\n },\n {\n childInput: \"structural\",\n resolveStyle: (style) =>\n stripLayoutParticipation(style) as ResolvedDragStyle,\n },\n);\n\nsetPrimitivePresentation<ResolvedDragStyle>(DragHandle, (style) => ({\n transform: createGroupTransform(style),\n}));\n\nconst DragReadout = definePrimitive<\n PibblDragHandleProps & {\n readonly readout?: false | true | PibblManipulationReadoutStyle;\n readonly focused: boolean;\n readonly source: object;\n readonly anchorX: number;\n }\n>(function DragReadout(props, _style, ctx) {\n if (!readoutEnabled(props.readout, props.formatReadout)) return;\n const state = requireManipulationFrame(props.controller);\n paintReadout(\n ctx,\n state,\n cssPoint(state, props.anchorX, 0),\n () => {\n const { left, top } = state.options.box.get();\n const value = props.formatReadout\n ? props.formatReadout({ left, top })\n : `left ${round(left)} \u00B7 top ${round(top)} px`;\n if (typeof value !== \"string\")\n throw new Error(\n \"Manipulation readout formatReadout must return a string.\",\n );\n return value;\n },\n props.readout,\n props.focused,\n isManipulationSourceActive(props.controller, props.source),\n \"top\",\n 40,\n );\n});\n\n/**\n * Supported geometry and presentation properties for ManipulationReadoutState.\n *\n * @see {@link PibblManipulationReadoutStyle}\n */\nexport interface PibblManipulationReadoutStateStyle {\n /** Minimum outward spacing in CSS pixels; defaults to 40 for drag, 5 otherwise. */\n readonly gap?: number;\n /**\n * Canvas font string used to draw or measure text. See {@link PibblManipulationReadoutStateStyle}\n * .\n */\n readonly font?: string;\n /** Paint used for the interior. See {@link PibblManipulationReadoutStateStyle}. */\n readonly fill?: string;\n /** Paint used for the outline. See {@link PibblManipulationReadoutStateStyle}. */\n readonly stroke?: string;\n /** Width of the painted outline. See {@link PibblManipulationReadoutStateStyle}. */\n readonly strokeWidth?: number;\n /** Opacity of the painted result. See {@link PibblManipulationReadoutStateStyle}. */\n readonly opacity?: number;\n /** Whether this presentation is visible. See {@link PibblManipulationReadoutStateStyle}. */\n readonly visible?: boolean;\n}\n/**\n * Supported geometry and presentation properties for ManipulationReadout.\n *\n * @see {@link PibblManipulationReadoutStateStyle}\n * @see {@link PibblDragHandleStyle}\n * @see {@link PibblResizeHandleStyle}\n * @see {@link PibblRotationHandleStyle}\n */\nexport interface PibblManipulationReadoutStyle extends PibblManipulationReadoutStateStyle {\n /**\n * Readout presentation while no interaction is active. See\n * {@link PibblManipulationReadoutStateStyle}.\n */\n readonly inactive?: PibblManipulationReadoutStateStyle;\n /**\n * Readout presentation while the handle has keyboard focus. See\n * {@link PibblManipulationReadoutStateStyle}.\n */\n readonly focused?: PibblManipulationReadoutStateStyle;\n /**\n * Current active operation or its presentation configuration. See\n * {@link PibblManipulationReadoutStateStyle}.\n */\n readonly active?: PibblManipulationReadoutStateStyle;\n}\n/**\n * Supported geometry and presentation properties for ResizeHandle.\n *\n * @see {@link SystemStyle}\n * @see {@link PibblManipulationReadoutStyle}\n * @see {@link ResizeHandle}\n * @see {@link PibblResizeHandlesProps}\n */\nexport interface PibblResizeHandleStyle extends SystemStyle {\n /** Presentation of the manipulation value readout. See {@link PibblManipulationReadoutStyle}. */\n readonly readout?: false | true | PibblManipulationReadoutStyle;\n}\n/**\n * Supported geometry and presentation properties for RotationConnector.\n *\n * @see {@link PibblRotationHandleStyle}\n */\nexport interface PibblRotationConnectorStyle {\n /** Paint used for the outline. See {@link PibblRotationConnectorStyle}. */\n readonly stroke?: string;\n /** Width of the painted outline. See {@link PibblRotationConnectorStyle}. */\n readonly strokeWidth?: number;\n /** Opacity of the painted result. See {@link PibblRotationConnectorStyle}. */\n readonly opacity?: number;\n}\n/**\n * Supported geometry and presentation properties for RotationArc.\n *\n * @see {@link PibblRotationHandleStyle}\n */\nexport interface PibblRotationArcStyle {\n /** Color used by the mark or effect. See {@link PibblRotationArcStyle}. */\n readonly color?: string;\n /** Angular extent of the arc. See {@link PibblRotationArcStyle}. */\n readonly sweep?: number;\n /** Width of the painted outline. See {@link PibblRotationArcStyle}. */\n readonly strokeWidth?: number;\n /** Opacity of the painted result. See {@link PibblRotationArcStyle}. */\n readonly opacity?: number;\n}\n/**\n * Supported geometry and presentation properties for RotationHandle.\n *\n * @see {@link SystemStyle}\n * @see {@link PibblRotationConnectorStyle}\n * @see {@link PibblRotationArcStyle}\n * @see {@link PibblManipulationReadoutStyle}\n * @see {@link RotationHandle}\n * @see {@link PibblManipulableProps}\n */\nexport interface PibblRotationHandleStyle extends SystemStyle {\n /**\n * Presentation of the line connecting the rotation handle to its target. See\n * {@link PibblRotationConnectorStyle}.\n */\n readonly connector?: false | true | PibblRotationConnectorStyle;\n /** Presentation of the rotation-angle arc. See {@link PibblRotationArcStyle}. */\n readonly arc?: false | true | PibblRotationArcStyle;\n /** Presentation of the manipulation value readout. See {@link PibblManipulationReadoutStyle}. */\n readonly readout?: false | true | PibblManipulationReadoutStyle;\n}\n/**\n * Authored inputs for ResizeHandle, including the declared data and presentation options.\n *\n * @see {@link PibblManipulationController}\n * @see {@link PibblNode}\n * @see {@link ResizeHandle}\n * @see {@link PibblResizeHandlesProps}\n * @see {@link PibblResizePosition}\n */\nexport interface PibblResizeHandleProps {\n /**\n * Controller owning the current interaction or mounted scenario. See\n * {@link PibblManipulationController}.\n */\n readonly controller: PibblManipulationController;\n /**\n * Position of the geometry, source, or selected resize handle. See {@link PibblResizeHandleProps}\n * .\n */\n readonly position: import(\"./types.js\").PibblResizePosition;\n /** Size of the handle's interactive hit region. See {@link PibblResizeHandleProps}. */\n readonly hitSize?: number;\n /**\n * Formats the value shown by the manipulation readout. See {@link PibblResizeHandleProps}.\n * @param value - Current width and height.\n * @returns Text to display in the resize readout.\n */\n readonly formatReadout?: (value: {\n /**\n * Horizontal extent in the units of the containing geometry or surface. See\n * {@link PibblResizeHandleProps}.\n */\n readonly width: number;\n /**\n * Vertical extent in the units of the containing geometry or surface. See\n * {@link PibblResizeHandleProps}.\n */\n readonly height: number;\n }) => string;\n /** Descendant content or the callback that supplies it. See {@link PibblNode}. */\n readonly children?: PibblNode;\n}\n/**\n * Authored inputs for ResizeHandles, including the declared data and presentation options.\n *\n * @see {@link PibblManipulationController}\n * @see {@link PibblResizeHandleStyle}\n * @see {@link PibblResizeHandleProps}\n * @see {@link ResizeHandles}\n * @see {@link PibblManipulableProps}\n * @see {@link PibblResizePosition}\n */\nexport interface PibblResizeHandlesProps {\n /**\n * Controller owning the current interaction or mounted scenario. See\n * {@link PibblManipulationController}.\n */\n readonly controller: PibblManipulationController;\n /** Edges and corners at which resize handles are created. See {@link PibblResizeHandlesProps}. */\n readonly positions?:\n \"corners\" | \"edges-and-corners\" | readonly import(\"./types.js\").PibblResizePosition[];\n /** Size of the handle's interactive hit region. See {@link PibblResizeHandlesProps}. */\n readonly hitSize?: number;\n /** Declared presentation and layout properties. See {@link PibblResizeHandleStyle}. */\n readonly style?: PibblResizeHandleStyle;\n /** Formats the value shown by the manipulation readout. See {@link PibblResizeHandleProps}. */\n readonly formatReadout?: PibblResizeHandleProps[\"formatReadout\"];\n}\nconst corners = [\n \"top-left\",\n \"top-right\",\n \"bottom-right\",\n \"bottom-left\",\n] as const;\nconst allHandles = [\n \"top-left\",\n \"top\",\n \"top-right\",\n \"right\",\n \"bottom-right\",\n \"bottom\",\n \"bottom-left\",\n \"left\",\n] as const;\ntype ResizePosition = (typeof allHandles)[number];\ninterface CollectionReadout {\n readonly controller: PibblManipulationController;\n readonly positions: readonly ResizePosition[];\n readonly owner: ResizePosition;\n readonly style: PibblResizeHandleStyle | undefined;\n readonly formatReadout: PibblResizeHandleProps[\"formatReadout\"];\n readonly focused: Map<ResizePosition, boolean>;\n}\nconst collectionStack: CollectionReadout[] = [];\nconst ResizeCollection = definePrimitive<{\n readonly collection: CollectionReadout;\n readonly children?: PibblNode;\n}>(\n function ResizeCollection(props) {\n collectionStack.push(props.collection);\n GLOBAL_STATE.componentRefs!.onAfterRender = () => {\n const collection = collectionStack.pop();\n if (collection !== props.collection)\n throw new Error(\n \"Manipulation resize collection render context was unbalanced.\",\n );\n };\n return props.children;\n },\n { childInput: \"structural\" },\n);\n\n/**\n * Draws an interactive handle for one edge or corner of a manipulation target.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link PibblResizeHandleProps}\n * @see {@link PibblResizeHandleStyle}\n */\nexport const ResizeHandle = definePrimitive<\n PibblResizeHandleProps,\n PibblResizeHandleStyle\n>(function ResizeHandle(props, style, ctx) {\n const state = requireManipulationFrame(props.controller);\n const box = getLayoutBox();\n const position = props.position as ResizePosition;\n if (!allHandles.includes(position))\n throw new Error(\"ResizeHandle requires a valid edge or corner position.\");\n const x = position.includes(\"left\")\n ? 0\n : position.includes(\"right\")\n ? box.width\n : box.width / 2;\n const y = position.includes(\"top\")\n ? 0\n : position.includes(\"bottom\")\n ? box.height\n : box.height / 2;\n const hitSize = props.hitSize ?? 24;\n if (!Number.isFinite(hitSize) || hitSize <= 0)\n throw new Error(\"ResizeHandle hitSize must be positive finite CSS pixels.\");\n const handlers = manipulationHandlers(props.controller, \"resize\", position);\n useEventListener(handlers);\n const focus = useEventTarget(handlers, {\n path: cssHandlePath(state, x, y, hitSize),\n fill: true,\n cursor:\n position === \"left\" || position === \"right\"\n ? \"ew-resize\"\n : position === \"top\" || position === \"bottom\"\n ? \"ns-resize\"\n : position === \"top-left\" || position === \"bottom-right\"\n ? \"nwse-resize\"\n : \"nesw-resize\",\n keyboardFocusable: true,\n keyboardNavigationBounds: { x: x - 4, y: y - 4, width: 8, height: 8 },\n });\n const active = state.controller.active.get();\n const relevant = active?.operation === \"resize\" && active.handle === position;\n const collection = collectionStack.at(-1);\n if (\n collection?.controller === props.controller &&\n collection.positions.includes(position)\n ) {\n collection.focused.set(position, focus.isFocused);\n } else if (readoutEnabled(style.readout, props.formatReadout)) {\n paintReadout(\n ctx,\n state,\n cssPoint(state, x, y),\n () => formatResize(state, props.formatReadout),\n style.readout,\n focus.isFocused,\n relevant,\n position,\n );\n }\n if (props.children !== undefined)\n return createElement(CssHandleContent, {\n style: { transform: cssHandleChildTransform(state, x, y) },\n children: props.children,\n });\n paintDefaultHandle(ctx, state, x, y);\n});\n/**\n * Creates the configured collection of resize handles around a manipulation target.\n *\n * @param props - Controller, handle placement, and presentation options. See\n * {@link PibblResizeHandlesProps} .\n * @returns Pibbl nodes rendering the resize handles. See {@link PibblNode}.\n *\n * @see {@link PibblResizeHandlesProps}\n * @see {@link PibblNode}\n */\nexport function ResizeHandles(props: PibblResizeHandlesProps): PibblNode {\n const positions = (\n props.positions === undefined || props.positions === \"corners\"\n ? corners\n : props.positions === \"edges-and-corners\"\n ? allHandles\n : props.positions\n ) as readonly ResizePosition[];\n if (positions.length === 0) return [];\n const owner = positions.includes(\"bottom-right\")\n ? \"bottom-right\"\n : positions.at(-1)!;\n const collection: CollectionReadout = {\n controller: props.controller,\n positions,\n owner,\n style: props.style,\n formatReadout: props.formatReadout,\n focused: new Map(),\n };\n return createElement(ResizeCollection, {\n collection,\n children: [\n ...positions.map((position) =>\n createElement(ResizeHandle, {\n key: position,\n controller: props.controller,\n position,\n hitSize: props.hitSize,\n style: props.style,\n formatReadout: props.formatReadout,\n }),\n ),\n createElement(ResizeCollectionReadout, {\n key: \"readout\",\n controller: props.controller,\n collection,\n }),\n ],\n });\n}\nconst ResizeCollectionReadout = definePrimitive<{\n readonly controller: PibblManipulationController;\n readonly collection: CollectionReadout;\n}>(function ResizeCollectionReadout(props, _style, ctx) {\n const state = requireManipulationFrame(props.controller);\n if (\n !readoutEnabled(\n props.collection.style?.readout,\n props.collection.formatReadout,\n )\n )\n return;\n const active = state.controller.active.get();\n const position =\n active?.operation === \"resize\" &&\n active.handle &&\n props.collection.positions.includes(active.handle)\n ? active.handle\n : (props.collection.positions.find((candidate) =>\n props.collection.focused.get(candidate),\n ) ?? props.collection.owner);\n const box = getLayoutBox();\n const x = position.includes(\"left\")\n ? 0\n : position.includes(\"right\")\n ? box.width\n : box.width / 2;\n const y = position.includes(\"top\")\n ? 0\n : position.includes(\"bottom\")\n ? box.height\n : box.height / 2;\n paintReadout(\n ctx,\n state,\n cssPoint(state, x, y),\n () => formatResize(state, props.collection.formatReadout),\n props.collection.style?.readout,\n props.collection.focused.get(position) ?? false,\n active?.operation === \"resize\" && active.handle === position,\n position,\n );\n});\n\n/**\n * Authored inputs for RotationHandle, including the declared data and presentation options.\n *\n * @see {@link PibblManipulationController}\n * @see {@link PibblNode}\n * @see {@link RotationHandle}\n * @see {@link PibblManipulableProps}\n */\nexport interface PibblRotationHandleProps {\n /**\n * Controller owning the current interaction or mounted scenario. See\n * {@link PibblManipulationController}.\n */\n readonly controller: PibblManipulationController;\n /** Size of the handle's interactive hit region. See {@link PibblRotationHandleProps}. */\n readonly hitSize?: number;\n /** Selects `\"degrees\"`, `\"radians\"` for readout unit. See {@link PibblRotationHandleProps}. */\n readonly readoutUnit?: \"degrees\" | \"radians\";\n /**\n * Formats the value shown by the manipulation readout. See {@link PibblRotationHandleProps}.\n * @param value - Current rotation.\n * @returns Text to display in the rotation readout.\n */\n readonly formatReadout?: (value: {\n /** Rotation applied to the containing geometry. See {@link PibblRotationHandleProps}. */\n readonly rotation: number;\n }) => string;\n /** Descendant content or the callback that supplies it. See {@link PibblNode}. */\n readonly children?: PibblNode;\n}\n/**\n * Draws an interactive handle for rotating a manipulation target.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link PibblRotationHandleProps}\n * @see {@link PibblRotationHandleStyle}\n */\nexport const RotationHandle = definePrimitive<\n PibblRotationHandleProps,\n PibblRotationHandleStyle\n>(function RotationHandle(props, style, ctx) {\n const state = requireManipulationFrame(props.controller);\n const box = getLayoutBox();\n const anchor = rotationAnchor(state, box.width, box.height);\n const hitSize = props.hitSize ?? 24;\n if (!Number.isFinite(hitSize) || hitSize <= 0)\n throw new Error(\n \"RotationHandle hitSize must be positive finite CSS pixels.\",\n );\n const handlers = manipulationHandlers(props.controller, \"rotate\");\n useEventListener(handlers);\n const focus = useEventTarget(handlers, {\n path: cssHandlePath(state, anchor.local.x, anchor.local.y, hitSize),\n fill: true,\n cursor: \"grab\",\n keyboardFocusable: true,\n keyboardNavigationBounds: {\n x: anchor.local.x - 4,\n y: anchor.local.y - 4,\n width: 8,\n height: 8,\n },\n });\n const relevant = state.controller.active.get()?.operation === \"rotate\";\n paintRotationDecorations(ctx, state, anchor, style);\n if (readoutEnabled(style.readout, props.formatReadout || props.readoutUnit))\n paintReadout(\n ctx,\n state,\n anchor.css,\n () => formatRotation(state, props),\n style.readout,\n focus.isFocused,\n relevant,\n \"top\",\n );\n if (props.children !== undefined)\n return createElement(CssHandleContent, {\n style: {\n transform: cssHandleChildTransform(\n state,\n anchor.local.x,\n anchor.local.y,\n ),\n },\n children: props.children,\n });\n paintDefaultHandle(ctx, state, anchor.local.x, anchor.local.y);\n});\n\nfunction frameToCss(state: ManipulationState): DOMMatrix {\n const surface = state.root.surface.snapshot;\n const world = getCurrentWorldTransform();\n return surface\n ? new DOMMatrix()\n .scale(\n 1 / surface.backingPixelsPerCssPixelX,\n 1 / surface.backingPixelsPerCssPixelY,\n )\n .multiply(surface.renderTransform)\n .multiply(world)\n : world;\n}\nfunction cssPoint(state: ManipulationState, x: number, y: number): DOMPoint {\n return frameToCss(state).transformPoint(new DOMPoint(x, y));\n}\nfunction cssBasis(state: ManipulationState): {\n css: DOMMatrix;\n inverse: DOMMatrix;\n angle: number;\n} {\n const css = frameToCss(state);\n const inverse = new DOMMatrix([css.a, css.b, css.c, css.d, 0, 0]).inverse();\n if (![inverse.a, inverse.b, inverse.c, inverse.d].every(Number.isFinite))\n throw new Error(\n \"Manipulation handle cannot use a singular presentation transform.\",\n );\n return { css, inverse, angle: Math.atan2(css.b, css.a) };\n}\nfunction cssHandlePath(\n state: ManipulationState,\n x: number,\n y: number,\n size: number,\n): Path2D {\n const { inverse, angle } = cssBasis(state);\n const path = new Path2D();\n const half = size / 2;\n const cos = Math.cos(angle),\n sin = Math.sin(angle);\n for (const [i, point] of [\n [-half, -half],\n [half, -half],\n [half, half],\n [-half, half],\n ].entries()) {\n const sx = point[0] * cos - point[1] * sin,\n sy = point[0] * sin + point[1] * cos;\n const local = inverse.transformPoint(new DOMPoint(sx, sy));\n if (i === 0) path.moveTo(x + local.x, y + local.y);\n else path.lineTo(x + local.x, y + local.y);\n }\n path.closePath();\n return path;\n}\nfunction cssHandleChildTransform(\n state: ManipulationState,\n x: number,\n y: number,\n): DOMMatrix {\n const { inverse, angle } = cssBasis(state);\n const rotate = new DOMMatrix().rotate((angle * 180) / Math.PI);\n const basis = inverse.multiply(rotate);\n return new DOMMatrix([basis.a, basis.b, basis.c, basis.d, x, y]);\n}\nfunction paintDefaultHandle(\n ctx: RenderingContext2D,\n state: ManipulationState,\n x: number,\n y: number,\n): void {\n ctx.fillStyle = \"#2563eb\";\n ctx.fill(cssHandlePath(state, x, y, 8));\n ctx.fillStyle = \"#ffffff\";\n ctx.fill(cssHandlePath(state, x, y, 6));\n}\n\nfunction rotationAnchor(\n state: ManipulationState,\n width: number,\n height: number,\n) {\n const css = frameToCss(state);\n const top = css.transformPoint(new DOMPoint(width / 2, 0));\n const pivot = css.transformPoint(new DOMPoint(width / 2, height / 2));\n const edge = new DOMPoint(css.a, css.b);\n const mappedOut = new DOMPoint(-css.c, -css.d);\n let normal = new DOMPoint(-edge.y, edge.x);\n const length = Math.hypot(normal.x, normal.y);\n if (!Number.isFinite(length) || length === 0)\n throw new Error(\n \"RotationHandle cannot use a singular presentation transform.\",\n );\n normal = new DOMPoint(normal.x / length, normal.y / length);\n if (normal.x * mappedOut.x + normal.y * mappedOut.y < 0)\n normal = new DOMPoint(-normal.x, -normal.y);\n const handle = new DOMPoint(top.x + normal.x * 24, top.y + normal.y * 24);\n const local = css.inverse().transformPoint(handle);\n return { css: handle, local, top, pivot, normal };\n}\nfunction paintRotationDecorations(\n ctx: RenderingContext2D,\n state: ManipulationState,\n anchor: ReturnType<typeof rotationAnchor>,\n style: PibblRotationHandleStyle,\n): void {\n validateRotationStyle(style);\n const connector =\n style.connector === undefined || style.connector === true\n ? {}\n : style.connector;\n const arc = style.arc === true ? {} : style.arc;\n if (connector === false && !arc) return;\n withCssContext(ctx, state, () => {\n const baseAlpha = ctx.globalAlpha;\n if (connector !== false) {\n ctx.strokeStyle = connector.stroke ?? \"#2563eb\";\n ctx.lineWidth = connector.strokeWidth ?? 1;\n ctx.globalAlpha *= connector.opacity ?? 1;\n ctx.beginPath();\n ctx.moveTo(anchor.top.x, anchor.top.y);\n ctx.lineTo(anchor.css.x, anchor.css.y);\n ctx.stroke();\n ctx.globalAlpha = baseAlpha;\n }\n if (arc) {\n const radius = Math.hypot(\n anchor.css.x - anchor.pivot.x,\n anchor.css.y - anchor.pivot.y,\n );\n const center = Math.atan2(\n anchor.css.y - anchor.pivot.y,\n anchor.css.x - anchor.pivot.x,\n );\n const sweep = arc.sweep ?? Math.PI / 3;\n for (let i = 0; i < 24; i++) {\n const a0 = center - sweep / 2 + (sweep * i) / 24,\n a1 = center - sweep / 2 + (sweep * (i + 1)) / 24;\n const alpha = (1 - Math.abs((i + 0.5) / 12 - 1)) * (arc.opacity ?? 1);\n ctx.strokeStyle = arc.color ?? \"#2563eb\";\n ctx.lineWidth = arc.strokeWidth ?? 1;\n ctx.globalAlpha = baseAlpha * alpha;\n ctx.beginPath();\n ctx.arc(anchor.pivot.x, anchor.pivot.y, radius, a0, a1);\n ctx.stroke();\n }\n ctx.globalAlpha = baseAlpha;\n }\n });\n}\nfunction validateReadoutStyle(\n value: false | true | PibblManipulationReadoutStyle | undefined,\n): void {\n if (!value || value === true) return;\n for (const style of [value, value.inactive, value.focused, value.active]) {\n if (!style) continue;\n if (\n style.gap !== undefined &&\n (!Number.isFinite(style.gap) || style.gap < 0)\n )\n throw new Error(\n \"Manipulation readout gap must be finite non-negative CSS pixels.\",\n );\n if (\n style.strokeWidth !== undefined &&\n (!Number.isFinite(style.strokeWidth) || style.strokeWidth < 0)\n )\n throw new Error(\n \"Manipulation readout strokeWidth must be finite and non-negative.\",\n );\n if (\n style.opacity !== undefined &&\n (!Number.isFinite(style.opacity) || style.opacity < 0)\n )\n throw new Error(\n \"Manipulation readout opacity must be finite and non-negative.\",\n );\n }\n}\nfunction validateRotationStyle(style: PibblRotationHandleStyle): void {\n const connector =\n style.connector && style.connector !== true ? style.connector : undefined;\n const arc = style.arc && style.arc !== true ? style.arc : undefined;\n for (const value of [connector?.strokeWidth, arc?.strokeWidth])\n if (value !== undefined && (!Number.isFinite(value) || value < 0))\n throw new Error(\n \"Manipulation guide strokeWidth must be finite and non-negative.\",\n );\n for (const value of [connector?.opacity, arc?.opacity])\n if (value !== undefined && (!Number.isFinite(value) || value < 0))\n throw new Error(\n \"Manipulation guide opacity must be finite and non-negative.\",\n );\n if (\n arc?.sweep !== undefined &&\n (!Number.isFinite(arc.sweep) || arc.sweep <= 0 || arc.sweep > Math.PI * 2)\n )\n throw new Error(\n \"Manipulation arc sweep must be finite, positive, and no greater than 2\u03C0 radians.\",\n );\n}\n\nfunction readoutEnabled(\n readout: false | true | PibblManipulationReadoutStyle | undefined,\n formatter: unknown,\n): boolean {\n return (\n readout !== false && (readout !== undefined || formatter !== undefined)\n );\n}\nfunction formatResize(\n state: ManipulationState,\n format: PibblResizeHandleProps[\"formatReadout\"],\n): string {\n const box = state.options.box.get();\n const value = format\n ? format({ width: box.width, height: box.height })\n : `${round(box.width)} \u00D7 ${round(box.height)} px`;\n if (typeof value !== \"string\")\n throw new Error(\"Manipulation readout formatReadout must return a string.\");\n return value;\n}\nfunction formatRotation(\n state: ManipulationState,\n props: PibblRotationHandleProps,\n): string {\n const rotation = state.options.rotation?.get() ?? 0;\n const value = props.formatReadout\n ? props.formatReadout({ rotation })\n : props.readoutUnit === \"radians\"\n ? `${round(rotation)} rad`\n : `${round((rotation * 180) / Math.PI)}\u00B0`;\n if (typeof value !== \"string\")\n throw new Error(\"Manipulation readout formatReadout must return a string.\");\n return value;\n}\nfunction round(value: number): string {\n return Number.isInteger(value)\n ? String(value)\n : String(Number(value.toFixed(2)));\n}\nfunction paintReadout(\n ctx: RenderingContext2D,\n state: ManipulationState,\n anchor: DOMPoint,\n format: () => string,\n readout: false | true | PibblManipulationReadoutStyle | undefined,\n focused: boolean,\n active: boolean,\n position?: ResizePosition,\n defaultGap = 5,\n): void {\n validateReadoutStyle(readout);\n const resolved = resolveReadout(\n readout,\n state.controller.active.get() === null,\n focused,\n active,\n defaultGap,\n );\n if (!resolved.visible) return;\n const text = format();\n if (!text) return;\n const frameMapping = frameToCss(state);\n withCssContext(ctx, state, () => {\n ctx.font = resolved.font;\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"alphabetic\";\n const surface = state.root.surface.snapshot;\n if (!surface) return;\n const stroke = resolved.stroke ? resolved.strokeWidth : 0;\n const available = surface.displayWidth - 16 - stroke;\n const value = ellipsis(ctx, text, available);\n if (!value) return;\n const metrics = measureLabel(ctx, value);\n const glyphLeft = Math.max(0, metrics.actualBoundingBoxLeft);\n const glyphRight = Math.max(metrics.width, metrics.actualBoundingBoxRight);\n const ascent = Math.max(0, metrics.actualBoundingBoxAscent);\n const descent = Math.max(0, metrics.actualBoundingBoxDescent);\n const height = ascent + descent + 6 + stroke;\n const width = glyphLeft + glyphRight + 8 + stroke;\n if (width > surface.displayWidth - 8 || height > surface.displayHeight - 8)\n return;\n const offset = outwardReadoutOffset(\n frameMapping,\n position,\n width,\n height,\n resolved.gap,\n );\n let left = anchor.x + offset.x - width / 2;\n let top = anchor.y + offset.y - height / 2;\n left = Math.max(4, Math.min(surface.displayWidth - 4 - width, left));\n top = Math.max(4, Math.min(surface.displayHeight - 4 - height, top));\n ctx.globalAlpha *= resolved.opacity;\n ctx.fillStyle = resolved.fill;\n if (resolved.stroke) {\n ctx.strokeStyle = resolved.stroke;\n ctx.lineWidth = resolved.strokeWidth;\n ctx.strokeText(\n value,\n left + 4 + glyphLeft + stroke / 2,\n top + 3 + ascent + stroke / 2,\n );\n }\n ctx.fillText(\n value,\n left + 4 + glyphLeft + stroke / 2,\n top + 3 + ascent + stroke / 2,\n );\n });\n}\n/** Separate the upright label from the selected edges in displayed CSS space. */\nfunction outwardReadoutOffset(\n frameMapping: DOMMatrix,\n position: ResizePosition | undefined,\n width: number,\n height: number,\n gap: number,\n): DOMPoint {\n if (!position) return new DOMPoint(width / 2 + gap, 0);\n const inverse = frameMapping.inverse();\n const normals: DOMPoint[] = [];\n const add = (x: number, y: number, sign: number) => {\n const length = Math.hypot(x, y);\n normals.push(new DOMPoint((sign * x) / length, (sign * y) / length));\n };\n if (position.includes(\"left\")) add(inverse.a, inverse.c, -1);\n if (position.includes(\"right\")) add(inverse.a, inverse.c, 1);\n if (position.includes(\"top\")) add(inverse.b, inverse.d, -1);\n if (position.includes(\"bottom\")) add(inverse.b, inverse.d, 1);\n const support = (n: DOMPoint) =>\n (Math.abs(n.x) * width) / 2 + (Math.abs(n.y) * height) / 2 + gap;\n const [a, b] = normals;\n const da = support(a);\n if (!b) return new DOMPoint(a.x * da, a.y * da);\n const db = support(b),\n determinant = a.x * b.y - a.y * b.x;\n return new DOMPoint(\n (da * b.y - a.y * db) / determinant,\n (a.x * db - da * b.x) / determinant,\n );\n}\nfunction resolveReadout(\n value: false | true | PibblManipulationReadoutStyle | undefined,\n inactive: boolean,\n focused: boolean,\n active: boolean,\n defaultGap: number,\n): Required<PibblManipulationReadoutStateStyle> {\n const source = value && value !== true ? value : {};\n const base: Required<PibblManipulationReadoutStateStyle> = {\n gap: source.gap ?? defaultGap,\n font: source.font ?? \"12px sans-serif\",\n fill: source.fill ?? \"#1d4ed8\",\n stroke: source.stroke ?? \"\",\n strokeWidth: source.strokeWidth ?? 0,\n opacity: source.opacity ?? 1,\n visible: source.visible ?? false,\n };\n const patch = (next: PibblManipulationReadoutStateStyle | undefined) => {\n if (next) Object.assign(base, next);\n };\n if (inactive) patch(source.inactive);\n if (focused) patch(source.focused);\n if (active) (patch({ visible: true }), patch(source.active));\n return base;\n}\nconst labelMeasurements = new WeakMap<\n RenderingContext2D,\n Map<string, TextMetrics>\n>();\nfunction measureLabel(ctx: RenderingContext2D, text: string): TextMetrics {\n let cache = labelMeasurements.get(ctx);\n if (!cache) labelMeasurements.set(ctx, (cache = new Map()));\n const key = JSON.stringify([\n ctx.font,\n ctx.direction,\n ctx.fontKerning,\n ctx.letterSpacing,\n ctx.wordSpacing,\n text,\n ]);\n const found = cache.get(key);\n if (found) return found;\n const result = ctx.measureText(text);\n if (cache.size >= 64) cache.delete(cache.keys().next().value!);\n cache.set(key, result);\n return result;\n}\nfunction ellipsis(\n ctx: RenderingContext2D,\n text: string,\n width: number,\n): string {\n const fits = (value: string) => {\n const m = measureLabel(ctx, value);\n return (\n Math.max(0, m.actualBoundingBoxLeft) +\n Math.max(m.width, m.actualBoundingBoxRight) <=\n width\n );\n };\n if (width <= 0) return \"\";\n if (fits(text)) return text;\n const suffix = \"\u2026\";\n if (!fits(suffix)) return \"\";\n const points = Array.from(text);\n let low = 0,\n high = points.length;\n while (low < high) {\n const mid = Math.ceil((low + high) / 2);\n if (fits(points.slice(0, mid).join(\"\") + suffix)) low = mid;\n else high = mid - 1;\n }\n return points.slice(0, low).join(\"\") + suffix;\n}\nfunction withCssContext(\n ctx: RenderingContext2D,\n state: ManipulationState,\n draw: () => void,\n): void {\n const surface = state.root.surface.snapshot;\n if (!surface) return;\n const cssToCurrent = ctx.getTransform().multiply(frameToCss(state).inverse());\n ctx.save();\n try {\n ctx.setTransform(cssToCurrent);\n ctx.beginPath();\n ctx.rect(0, 0, surface.displayWidth, surface.displayHeight);\n ctx.clip();\n draw();\n } finally {\n ctx.restore();\n }\n}\n"],
5
- "mappings": "AAGA,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AAEzB,SAAS,gCAAgC;AAEzC,SAAS,oBAAoB;AAI7B;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gCAAgC;AAkDzC,MAAM,mBAAmB;AAAA,EAIvB,SAASA,kBAAiB,OAAO;AAC/B,WAAO,MAAM;AAAA,EACf;AAAA,EACA,EAAE,YAAY,aAAa;AAC7B;AACA,yBAAgD,kBAAkB,CAAC,WAAW;AAAA,EAC5E,WAAW,MAAM;AACnB,EAAE;AAYK,MAAM,aAAa;AAAA,EAMxB,SAASC,YAAW,OAAO,OAAO;AAChC,6BAAyB,MAAM,UAAU;AACzC,UAAM,UAAU,UAAU,KAAK;AAC/B,UAAM,SAAS,SAAS,OAAO,CAAC,EAAE;AAClC,UAAM,WAAW;AAAA,MACf,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACA,qBAAiB;AAAA,MACf,GAAG;AAAA,MACH,WAAW,MAAM,QAAQ,IAAI,IAAI;AAAA,MACjC,YAAY,MAAM,QAAQ,IAAI,KAAK;AAAA,IACrC,CAAC;AACD,UAAM,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AAA,EACP,UAAE;AACA,QAAI,QAAQ;AAAA,EACd;AACF;",
4
+ "sourcesContent": ["import type { PibblResizePosition } from \"./types.js\";\nimport type { PibblManipulationWhen } from './types.js';\nimport type { PibblManipulableProps } from './manipulable.js';\nimport { createElement } from \"../element/create-element.js\";\nimport {\n createGroupTransform,\n setPrimitivePresentation,\n} from \"../primitive-presentation.js\";\nimport { getCurrentWorldTransform } from \"../render-target.js\";\nimport { GLOBAL_STATE } from \"../global-state.js\";\nimport { definePrimitive } from \"../define-primitive.js\";\nimport { useEventListener } from \"../hooks/use-event-listener.js\";\nimport { useEventTarget } from \"../hooks/use-event-target.js\";\nimport { useSignal } from \"../hooks/use-signal.js\";\nimport { useConst } from \"../hooks/use-const.js\";\nimport type { GStyle } from \"../components/g.js\";\nimport { stripLayoutParticipation } from \"../style/resolve-built-in.js\";\nimport type { ResolvedDrawingStyle } from \"../style/types.js\";\nimport { getLayoutBox } from \"../layout/context.js\";\nimport type { PibblNode } from \"../element/types.js\";\nimport type { RenderingContext2D, SystemStyle } from \"../types.js\";\nimport type { PibblManipulationController } from \"./controller-types.js\";\nimport {\n isManipulationSourceActive,\n manipulationHandlers,\n type ManipulationState,\n} from \"./controller.js\";\nimport { requireManipulationFrame } from \"./frame.js\";\n\n/**\n * Authored inputs for DragHandle, including the declared data and presentation options.\n *\n * @see {@link PibblManipulationController}\n * @see {@link PibblNode}\n * @see {@link DragHandle}\n * @see {@link PibblManipulationWhen}\n */\nexport interface PibblDragHandleProps {\n /**\n * Formats the value shown by the manipulation readout. See {@link PibblDragHandleProps}.\n * @param value - Current left and top coordinates.\n * @returns Text to display in the drag readout.\n */\n readonly formatReadout?: (value: {\n /** Left edge coordinate or inset. See {@link PibblDragHandleProps}. */\n readonly left: number;\n /** Top edge value or top envelope guide. See {@link PibblDragHandleProps}. */\n readonly top: number;\n }) => string;\n /**\n * Controller owning the current interaction or mounted scenario. See\n * {@link PibblManipulationController}.\n */\n readonly controller: PibblManipulationController;\n /** Descendant content or the callback that supplies it. See {@link PibblNode}. */\n readonly children?: PibblNode;\n}\n/**\n * Supported geometry and presentation properties for DragHandle.\n *\n * @see {@link GStyle}\n * @see {@link PibblManipulationReadoutStyle}\n * @see {@link DragHandle}\n * @see {@link PibblManipulableProps}\n */\nexport interface PibblDragHandleStyle extends GStyle {\n /** Presentation of the manipulation value readout. See {@link PibblManipulationReadoutStyle}. */\n readonly readout?: false | true | PibblManipulationReadoutStyle;\n}\ntype ResolvedDragStyle = ResolvedDrawingStyle<PibblDragHandleStyle>;\ninterface CssHandleContentProps {\n readonly children?: PibblNode;\n}\ninterface CssHandleContentStyle extends SystemStyle {\n readonly transform: DOMMatrix;\n}\n/** Private CSS-pixel basis for author-provided handle visuals. */\nconst CssHandleContent = definePrimitive<\n CssHandleContentProps,\n CssHandleContentStyle\n>(\n function CssHandleContent(props) {\n return props.children;\n },\n { childInput: \"structural\" },\n);\nsetPrimitivePresentation<CssHandleContentStyle>(CssHandleContent, (style) => ({\n transform: style.transform,\n}));\n\n/**\n * Draws an interactive handle that starts translation of its manipulation target.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link PibblDragHandleProps}\n * @see {@link PibblDragHandleStyle}\n */\nexport const DragHandle = definePrimitive<\n PibblDragHandleProps,\n PibblDragHandleStyle,\n PibblDragHandleStyle,\n ResolvedDragStyle\n>(\n function DragHandle(props, style) {\n requireManipulationFrame(props.controller);\n const focused = useSignal(false);\n const source = useConst(() => ({}));\n const handlers = manipulationHandlers(\n props.controller,\n \"move\",\n undefined,\n source,\n );\n useEventListener({\n ...handlers,\n onFocusIn: () => focused.set(true),\n onFocusOut: () => focused.set(false),\n });\n const box = getLayoutBox();\n return [\n props.children,\n createElement(DragReadout, {\n controller: props.controller,\n formatReadout: props.formatReadout,\n readout: style.readout,\n focused: focused.get(),\n source,\n anchorX: box.width / 2,\n }),\n ];\n },\n {\n childInput: \"structural\",\n resolveStyle: (style) =>\n stripLayoutParticipation(style) as ResolvedDragStyle,\n },\n);\n\nsetPrimitivePresentation<ResolvedDragStyle>(DragHandle, (style) => ({\n transform: createGroupTransform(style),\n}));\n\nconst DragReadout = definePrimitive<\n PibblDragHandleProps & {\n readonly readout?: false | true | PibblManipulationReadoutStyle;\n readonly focused: boolean;\n readonly source: object;\n readonly anchorX: number;\n }\n>(function DragReadout(props, _style, ctx) {\n if (!readoutEnabled(props.readout, props.formatReadout)) return;\n const state = requireManipulationFrame(props.controller);\n paintReadout(\n ctx,\n state,\n cssPoint(state, props.anchorX, 0),\n () => {\n const { left, top } = state.options.box.get();\n const value = props.formatReadout\n ? props.formatReadout({ left, top })\n : `left ${round(left)} \u00B7 top ${round(top)} px`;\n if (typeof value !== \"string\")\n throw new Error(\n \"Manipulation readout formatReadout must return a string.\",\n );\n return value;\n },\n props.readout,\n props.focused,\n isManipulationSourceActive(props.controller, props.source),\n \"top\",\n 40,\n );\n});\n\n/**\n * Supported geometry and presentation properties for ManipulationReadoutState.\n *\n * @see {@link PibblManipulationReadoutStyle}\n */\nexport interface PibblManipulationReadoutStateStyle {\n /** Minimum outward spacing in CSS pixels; defaults to 40 for drag, 5 otherwise. */\n readonly gap?: number;\n /**\n * Canvas font string used to draw or measure text. See {@link PibblManipulationReadoutStateStyle}\n * .\n */\n readonly font?: string;\n /** Paint used for the interior. See {@link PibblManipulationReadoutStateStyle}. */\n readonly fill?: string;\n /** Paint used for the outline. See {@link PibblManipulationReadoutStateStyle}. */\n readonly stroke?: string;\n /** Width of the painted outline. See {@link PibblManipulationReadoutStateStyle}. */\n readonly strokeWidth?: number;\n /** Opacity of the painted result. See {@link PibblManipulationReadoutStateStyle}. */\n readonly opacity?: number;\n /** Whether this presentation is visible. See {@link PibblManipulationReadoutStateStyle}. */\n readonly visible?: boolean;\n}\n/**\n * Supported geometry and presentation properties for ManipulationReadout.\n *\n * @see {@link PibblManipulationReadoutStateStyle}\n * @see {@link PibblDragHandleStyle}\n * @see {@link PibblResizeHandleStyle}\n * @see {@link PibblRotationHandleStyle}\n */\nexport interface PibblManipulationReadoutStyle extends PibblManipulationReadoutStateStyle {\n /**\n * Readout presentation while no interaction is active. See\n * {@link PibblManipulationReadoutStateStyle}.\n */\n readonly inactive?: PibblManipulationReadoutStateStyle;\n /**\n * Readout presentation while the handle has keyboard focus. See\n * {@link PibblManipulationReadoutStateStyle}.\n */\n readonly focused?: PibblManipulationReadoutStateStyle;\n /**\n * Current active operation or its presentation configuration. See\n * {@link PibblManipulationReadoutStateStyle}.\n */\n readonly active?: PibblManipulationReadoutStateStyle;\n}\n/**\n * Supported geometry and presentation properties for ResizeHandle.\n *\n * @see {@link SystemStyle}\n * @see {@link PibblManipulationReadoutStyle}\n * @see {@link ResizeHandle}\n * @see {@link PibblResizeHandlesProps}\n */\nexport interface PibblResizeHandleStyle extends SystemStyle {\n /** Presentation of the manipulation value readout. See {@link PibblManipulationReadoutStyle}. */\n readonly readout?: false | true | PibblManipulationReadoutStyle;\n}\n/**\n * Supported geometry and presentation properties for RotationConnector.\n *\n * @see {@link PibblRotationHandleStyle}\n */\nexport interface PibblRotationConnectorStyle {\n /** Paint used for the outline. See {@link PibblRotationConnectorStyle}. */\n readonly stroke?: string;\n /** Width of the painted outline. See {@link PibblRotationConnectorStyle}. */\n readonly strokeWidth?: number;\n /** Opacity of the painted result. See {@link PibblRotationConnectorStyle}. */\n readonly opacity?: number;\n}\n/**\n * Supported geometry and presentation properties for RotationArc.\n *\n * @see {@link PibblRotationHandleStyle}\n */\nexport interface PibblRotationArcStyle {\n /** Color used by the mark or effect. See {@link PibblRotationArcStyle}. */\n readonly color?: string;\n /** Angular extent of the arc. See {@link PibblRotationArcStyle}. */\n readonly sweep?: number;\n /** Width of the painted outline. See {@link PibblRotationArcStyle}. */\n readonly strokeWidth?: number;\n /** Opacity of the painted result. See {@link PibblRotationArcStyle}. */\n readonly opacity?: number;\n}\n/**\n * Supported geometry and presentation properties for RotationHandle.\n *\n * @see {@link SystemStyle}\n * @see {@link PibblRotationConnectorStyle}\n * @see {@link PibblRotationArcStyle}\n * @see {@link PibblManipulationReadoutStyle}\n * @see {@link RotationHandle}\n * @see {@link PibblManipulableProps}\n */\nexport interface PibblRotationHandleStyle extends SystemStyle {\n /**\n * Presentation of the line connecting the rotation handle to its target. See\n * {@link PibblRotationConnectorStyle}.\n */\n readonly connector?: false | true | PibblRotationConnectorStyle;\n /** Presentation of the rotation-angle arc. See {@link PibblRotationArcStyle}. */\n readonly arc?: false | true | PibblRotationArcStyle;\n /** Presentation of the manipulation value readout. See {@link PibblManipulationReadoutStyle}. */\n readonly readout?: false | true | PibblManipulationReadoutStyle;\n}\n/**\n * Authored inputs for ResizeHandle, including the declared data and presentation options.\n *\n * @see {@link PibblManipulationController}\n * @see {@link PibblNode}\n * @see {@link ResizeHandle}\n * @see {@link PibblResizeHandlesProps}\n * @see {@link PibblResizePosition}\n */\nexport interface PibblResizeHandleProps {\n /**\n * Controller owning the current interaction or mounted scenario. See\n * {@link PibblManipulationController}.\n */\n readonly controller: PibblManipulationController;\n /**\n * Position of the geometry, source, or selected resize handle. See {@link PibblResizeHandleProps}\n * .\n */\n readonly position: import(\"./types.js\").PibblResizePosition;\n /** Size of the handle's interactive hit region. See {@link PibblResizeHandleProps}. */\n readonly hitSize?: number;\n /**\n * Formats the value shown by the manipulation readout. See {@link PibblResizeHandleProps}.\n * @param value - Current width and height.\n * @returns Text to display in the resize readout.\n */\n readonly formatReadout?: (value: {\n /**\n * Horizontal extent in the units of the containing geometry or surface. See\n * {@link PibblResizeHandleProps}.\n */\n readonly width: number;\n /**\n * Vertical extent in the units of the containing geometry or surface. See\n * {@link PibblResizeHandleProps}.\n */\n readonly height: number;\n }) => string;\n /** Descendant content or the callback that supplies it. See {@link PibblNode}. */\n readonly children?: PibblNode;\n}\n/**\n * Authored inputs for ResizeHandles, including the declared data and presentation options.\n *\n * @see {@link PibblManipulationController}\n * @see {@link PibblResizeHandleStyle}\n * @see {@link PibblResizeHandleProps}\n * @see {@link ResizeHandles}\n * @see {@link PibblManipulableProps}\n * @see {@link PibblResizePosition}\n */\nexport interface PibblResizeHandlesProps {\n /**\n * Controller owning the current interaction or mounted scenario. See\n * {@link PibblManipulationController}.\n */\n readonly controller: PibblManipulationController;\n /** Edges and corners at which resize handles are created. See {@link PibblResizeHandlesProps}. */\n readonly positions?:\n \"corners\" | \"edges-and-corners\" | readonly import(\"./types.js\").PibblResizePosition[];\n /** Size of the handle's interactive hit region. See {@link PibblResizeHandlesProps}. */\n readonly hitSize?: number;\n /** Declared presentation and layout properties. See {@link PibblResizeHandleStyle}. */\n readonly style?: PibblResizeHandleStyle;\n /** Formats the value shown by the manipulation readout. See {@link PibblResizeHandleProps}. */\n readonly formatReadout?: PibblResizeHandleProps[\"formatReadout\"];\n}\nconst corners = [\n \"top-left\",\n \"top-right\",\n \"bottom-right\",\n \"bottom-left\",\n] as const;\nconst allHandles = [\n \"top-left\",\n \"top\",\n \"top-right\",\n \"right\",\n \"bottom-right\",\n \"bottom\",\n \"bottom-left\",\n \"left\",\n] as const;\ntype ResizePosition = (typeof allHandles)[number];\ninterface CollectionReadout {\n readonly controller: PibblManipulationController;\n readonly positions: readonly ResizePosition[];\n readonly owner: ResizePosition;\n readonly style: PibblResizeHandleStyle | undefined;\n readonly formatReadout: PibblResizeHandleProps[\"formatReadout\"];\n readonly focused: Map<ResizePosition, boolean>;\n}\nconst collectionStack: CollectionReadout[] = [];\nconst ResizeCollection = definePrimitive<{\n readonly collection: CollectionReadout;\n readonly children?: PibblNode;\n}>(\n function ResizeCollection(props) {\n collectionStack.push(props.collection);\n GLOBAL_STATE.componentRefs!.onAfterRender = () => {\n const collection = collectionStack.pop();\n if (collection !== props.collection)\n throw new Error(\n \"Manipulation resize collection render context was unbalanced.\",\n );\n };\n return props.children;\n },\n { childInput: \"structural\" },\n);\n\n/**\n * Draws an interactive handle for one edge or corner of a manipulation target.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link PibblResizeHandleProps}\n * @see {@link PibblResizeHandleStyle}\n */\nexport const ResizeHandle = definePrimitive<\n PibblResizeHandleProps,\n PibblResizeHandleStyle\n>(function ResizeHandle(props, style, ctx) {\n const state = requireManipulationFrame(props.controller);\n const box = getLayoutBox();\n const position = props.position as ResizePosition;\n if (!allHandles.includes(position))\n throw new Error(\"ResizeHandle requires a valid edge or corner position.\");\n const x = position.includes(\"left\")\n ? 0\n : position.includes(\"right\")\n ? box.width\n : box.width / 2;\n const y = position.includes(\"top\")\n ? 0\n : position.includes(\"bottom\")\n ? box.height\n : box.height / 2;\n const hitSize = props.hitSize ?? 24;\n if (!Number.isFinite(hitSize) || hitSize <= 0)\n throw new Error(\"ResizeHandle hitSize must be positive finite CSS pixels.\");\n const handlers = manipulationHandlers(props.controller, \"resize\", position);\n useEventListener(handlers);\n const focus = useEventTarget(handlers, {\n path: cssHandlePath(state, x, y, hitSize),\n fill: true,\n cursor:\n position === \"left\" || position === \"right\"\n ? \"ew-resize\"\n : position === \"top\" || position === \"bottom\"\n ? \"ns-resize\"\n : position === \"top-left\" || position === \"bottom-right\"\n ? \"nwse-resize\"\n : \"nesw-resize\",\n keyboardFocusable: true,\n keyboardNavigationBounds: { x: x - 4, y: y - 4, width: 8, height: 8 },\n });\n const active = state.controller.active.get();\n const relevant = active?.operation === \"resize\" && active.handle === position;\n const collection = collectionStack.at(-1);\n if (\n collection?.controller === props.controller &&\n collection.positions.includes(position)\n ) {\n collection.focused.set(position, focus.isFocused);\n } else if (readoutEnabled(style.readout, props.formatReadout)) {\n paintReadout(\n ctx,\n state,\n cssPoint(state, x, y),\n () => formatResize(state, props.formatReadout),\n style.readout,\n focus.isFocused,\n relevant,\n position,\n );\n }\n if (props.children !== undefined)\n return createElement(CssHandleContent, {\n style: { transform: cssHandleChildTransform(state, x, y) },\n children: props.children,\n });\n paintDefaultHandle(ctx, state, x, y);\n});\n/**\n * Creates the configured collection of resize handles around a manipulation target.\n *\n * @param props - Controller, handle placement, and presentation options. See\n * {@link PibblResizeHandlesProps} .\n * @returns Pibbl nodes rendering the resize handles. See {@link PibblNode}.\n *\n * @see {@link PibblResizeHandlesProps}\n * @see {@link PibblNode}\n */\nexport function ResizeHandles(props: PibblResizeHandlesProps): PibblNode {\n const positions = (\n props.positions === undefined || props.positions === \"corners\"\n ? corners\n : props.positions === \"edges-and-corners\"\n ? allHandles\n : props.positions\n ) as readonly ResizePosition[];\n if (positions.length === 0) return [];\n const owner = positions.includes(\"bottom-right\")\n ? \"bottom-right\"\n : positions.at(-1)!;\n const collection: CollectionReadout = {\n controller: props.controller,\n positions,\n owner,\n style: props.style,\n formatReadout: props.formatReadout,\n focused: new Map(),\n };\n return createElement(ResizeCollection, {\n collection,\n children: [\n ...positions.map((position) =>\n createElement(ResizeHandle, {\n key: position,\n controller: props.controller,\n position,\n hitSize: props.hitSize,\n style: props.style,\n formatReadout: props.formatReadout,\n }),\n ),\n createElement(ResizeCollectionReadout, {\n key: \"readout\",\n controller: props.controller,\n collection,\n }),\n ],\n });\n}\nconst ResizeCollectionReadout = definePrimitive<{\n readonly controller: PibblManipulationController;\n readonly collection: CollectionReadout;\n}>(function ResizeCollectionReadout(props, _style, ctx) {\n const state = requireManipulationFrame(props.controller);\n if (\n !readoutEnabled(\n props.collection.style?.readout,\n props.collection.formatReadout,\n )\n )\n return;\n const active = state.controller.active.get();\n const position =\n active?.operation === \"resize\" &&\n active.handle &&\n props.collection.positions.includes(active.handle)\n ? active.handle\n : (props.collection.positions.find((candidate) =>\n props.collection.focused.get(candidate),\n ) ?? props.collection.owner);\n const box = getLayoutBox();\n const x = position.includes(\"left\")\n ? 0\n : position.includes(\"right\")\n ? box.width\n : box.width / 2;\n const y = position.includes(\"top\")\n ? 0\n : position.includes(\"bottom\")\n ? box.height\n : box.height / 2;\n paintReadout(\n ctx,\n state,\n cssPoint(state, x, y),\n () => formatResize(state, props.collection.formatReadout),\n props.collection.style?.readout,\n props.collection.focused.get(position) ?? false,\n active?.operation === \"resize\" && active.handle === position,\n position,\n );\n});\n\n/**\n * Authored inputs for RotationHandle, including the declared data and presentation options.\n *\n * @see {@link PibblManipulationController}\n * @see {@link PibblNode}\n * @see {@link RotationHandle}\n * @see {@link PibblManipulableProps}\n */\nexport interface PibblRotationHandleProps {\n /**\n * Controller owning the current interaction or mounted scenario. See\n * {@link PibblManipulationController}.\n */\n readonly controller: PibblManipulationController;\n /** Size of the handle's interactive hit region. See {@link PibblRotationHandleProps}. */\n readonly hitSize?: number;\n /** Selects `\"degrees\"`, `\"radians\"` for readout unit. See {@link PibblRotationHandleProps}. */\n readonly readoutUnit?: \"degrees\" | \"radians\";\n /**\n * Formats the value shown by the manipulation readout. See {@link PibblRotationHandleProps}.\n * @param value - Current rotation.\n * @returns Text to display in the rotation readout.\n */\n readonly formatReadout?: (value: {\n /** Rotation applied to the containing geometry. See {@link PibblRotationHandleProps}. */\n readonly rotation: number;\n }) => string;\n /** Descendant content or the callback that supplies it. See {@link PibblNode}. */\n readonly children?: PibblNode;\n}\n/**\n * Draws an interactive handle for rotating a manipulation target.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link PibblRotationHandleProps}\n * @see {@link PibblRotationHandleStyle}\n */\nexport const RotationHandle = definePrimitive<\n PibblRotationHandleProps,\n PibblRotationHandleStyle\n>(function RotationHandle(props, style, ctx) {\n const state = requireManipulationFrame(props.controller);\n const box = getLayoutBox();\n const anchor = rotationAnchor(state, box.width, box.height);\n const hitSize = props.hitSize ?? 24;\n if (!Number.isFinite(hitSize) || hitSize <= 0)\n throw new Error(\n \"RotationHandle hitSize must be positive finite CSS pixels.\",\n );\n const handlers = manipulationHandlers(props.controller, \"rotate\");\n useEventListener(handlers);\n const focus = useEventTarget(handlers, {\n path: cssHandlePath(state, anchor.local.x, anchor.local.y, hitSize),\n fill: true,\n cursor: \"grab\",\n keyboardFocusable: true,\n keyboardNavigationBounds: {\n x: anchor.local.x - 4,\n y: anchor.local.y - 4,\n width: 8,\n height: 8,\n },\n });\n const relevant = state.controller.active.get()?.operation === \"rotate\";\n paintRotationDecorations(ctx, state, anchor, style);\n if (readoutEnabled(style.readout, props.formatReadout || props.readoutUnit))\n paintReadout(\n ctx,\n state,\n anchor.css,\n () => formatRotation(state, props),\n style.readout,\n focus.isFocused,\n relevant,\n \"top\",\n );\n if (props.children !== undefined)\n return createElement(CssHandleContent, {\n style: {\n transform: cssHandleChildTransform(\n state,\n anchor.local.x,\n anchor.local.y,\n ),\n },\n children: props.children,\n });\n paintDefaultHandle(ctx, state, anchor.local.x, anchor.local.y);\n});\n\nfunction frameToCss(state: ManipulationState): DOMMatrix {\n const surface = state.root.surface.snapshot;\n const world = getCurrentWorldTransform();\n return surface\n ? new DOMMatrix()\n .scale(\n 1 / surface.backingPixelsPerCssPixelX,\n 1 / surface.backingPixelsPerCssPixelY,\n )\n .multiply(surface.renderTransform)\n .multiply(world)\n : world;\n}\nfunction cssPoint(state: ManipulationState, x: number, y: number): DOMPoint {\n return frameToCss(state).transformPoint(new DOMPoint(x, y));\n}\nfunction cssBasis(state: ManipulationState): {\n css: DOMMatrix;\n inverse: DOMMatrix;\n angle: number;\n} {\n const css = frameToCss(state);\n const inverse = new DOMMatrix([css.a, css.b, css.c, css.d, 0, 0]).inverse();\n if (!(\n Number.isFinite(inverse.a) &&\n Number.isFinite(inverse.b) &&\n Number.isFinite(inverse.c) &&\n Number.isFinite(inverse.d)\n ))\n throw new Error(\n \"Manipulation handle cannot use a singular presentation transform.\",\n );\n return { css, inverse, angle: Math.atan2(css.b, css.a) };\n}\nfunction cssHandlePath(\n state: ManipulationState,\n x: number,\n y: number,\n size: number,\n): Path2D {\n const { inverse, angle } = cssBasis(state);\n const path = new Path2D();\n const half = size / 2;\n const cos = Math.cos(angle),\n sin = Math.sin(angle);\n for (let i = 0; i < 4; i++) {\n const cornerX = i === 0 || i === 3 ? -half : half;\n const cornerY = i < 2 ? -half : half;\n const sx = cornerX * cos - cornerY * sin,\n sy = cornerX * sin + cornerY * cos;\n const local = inverse.transformPoint(new DOMPoint(sx, sy));\n if (i === 0) path.moveTo(x + local.x, y + local.y);\n else path.lineTo(x + local.x, y + local.y);\n }\n path.closePath();\n return path;\n}\nfunction cssHandleChildTransform(\n state: ManipulationState,\n x: number,\n y: number,\n): DOMMatrix {\n const { inverse, angle } = cssBasis(state);\n const rotate = new DOMMatrix().rotate((angle * 180) / Math.PI);\n const basis = inverse.multiply(rotate);\n return new DOMMatrix([basis.a, basis.b, basis.c, basis.d, x, y]);\n}\nfunction paintDefaultHandle(\n ctx: RenderingContext2D,\n state: ManipulationState,\n x: number,\n y: number,\n): void {\n ctx.fillStyle = \"#2563eb\";\n ctx.fill(cssHandlePath(state, x, y, 8));\n ctx.fillStyle = \"#ffffff\";\n ctx.fill(cssHandlePath(state, x, y, 6));\n}\n\nfunction rotationAnchor(\n state: ManipulationState,\n width: number,\n height: number,\n) {\n const css = frameToCss(state);\n const top = css.transformPoint(new DOMPoint(width / 2, 0));\n const pivot = css.transformPoint(new DOMPoint(width / 2, height / 2));\n const edge = new DOMPoint(css.a, css.b);\n const mappedOut = new DOMPoint(-css.c, -css.d);\n let normal = new DOMPoint(-edge.y, edge.x);\n const length = Math.hypot(normal.x, normal.y);\n if (!Number.isFinite(length) || length === 0)\n throw new Error(\n \"RotationHandle cannot use a singular presentation transform.\",\n );\n normal = new DOMPoint(normal.x / length, normal.y / length);\n if (normal.x * mappedOut.x + normal.y * mappedOut.y < 0)\n normal = new DOMPoint(-normal.x, -normal.y);\n const handle = new DOMPoint(top.x + normal.x * 24, top.y + normal.y * 24);\n const local = css.inverse().transformPoint(handle);\n return { css: handle, local, top, pivot, normal };\n}\nfunction paintRotationDecorations(\n ctx: RenderingContext2D,\n state: ManipulationState,\n anchor: ReturnType<typeof rotationAnchor>,\n style: PibblRotationHandleStyle,\n): void {\n validateRotationStyle(style);\n const connector =\n style.connector === undefined || style.connector === true\n ? {}\n : style.connector;\n const arc = style.arc === true ? {} : style.arc;\n if (connector === false && !arc) return;\n withCssContext(ctx, state, () => {\n const baseAlpha = ctx.globalAlpha;\n if (connector !== false) {\n ctx.strokeStyle = connector.stroke ?? \"#2563eb\";\n ctx.lineWidth = connector.strokeWidth ?? 1;\n ctx.globalAlpha *= connector.opacity ?? 1;\n ctx.beginPath();\n ctx.moveTo(anchor.top.x, anchor.top.y);\n ctx.lineTo(anchor.css.x, anchor.css.y);\n ctx.stroke();\n ctx.globalAlpha = baseAlpha;\n }\n if (arc) {\n const radius = Math.hypot(\n anchor.css.x - anchor.pivot.x,\n anchor.css.y - anchor.pivot.y,\n );\n const center = Math.atan2(\n anchor.css.y - anchor.pivot.y,\n anchor.css.x - anchor.pivot.x,\n );\n const sweep = arc.sweep ?? Math.PI / 3;\n for (let i = 0; i < 24; i++) {\n const a0 = center - sweep / 2 + (sweep * i) / 24,\n a1 = center - sweep / 2 + (sweep * (i + 1)) / 24;\n const alpha = (1 - Math.abs((i + 0.5) / 12 - 1)) * (arc.opacity ?? 1);\n ctx.strokeStyle = arc.color ?? \"#2563eb\";\n ctx.lineWidth = arc.strokeWidth ?? 1;\n ctx.globalAlpha = baseAlpha * alpha;\n ctx.beginPath();\n ctx.arc(anchor.pivot.x, anchor.pivot.y, radius, a0, a1);\n ctx.stroke();\n }\n ctx.globalAlpha = baseAlpha;\n }\n });\n}\nfunction validateReadoutStyle(\n value: false | true | PibblManipulationReadoutStyle | undefined,\n): void {\n if (!value || value === true) return;\n validateReadoutStateStyle(value);\n validateReadoutStateStyle(value.inactive);\n validateReadoutStateStyle(value.focused);\n validateReadoutStateStyle(value.active);\n}\nfunction validateReadoutStateStyle(style: PibblManipulationReadoutStateStyle | undefined): void {\n if (!style) return;\n if (\n style.gap !== undefined &&\n (!Number.isFinite(style.gap) || style.gap < 0)\n )\n throw new Error(\n \"Manipulation readout gap must be finite non-negative CSS pixels.\",\n );\n if (\n style.strokeWidth !== undefined &&\n (!Number.isFinite(style.strokeWidth) || style.strokeWidth < 0)\n )\n throw new Error(\n \"Manipulation readout strokeWidth must be finite and non-negative.\",\n );\n if (\n style.opacity !== undefined &&\n (!Number.isFinite(style.opacity) || style.opacity < 0)\n )\n throw new Error(\n \"Manipulation readout opacity must be finite and non-negative.\",\n );\n}\nfunction validateGuideDimension(value: number | undefined, property: string): void {\n if (value !== undefined && (!Number.isFinite(value) || value < 0))\n throw new Error(`Manipulation guide ${property} must be finite and non-negative.`);\n}\nfunction validateRotationStyle(style: PibblRotationHandleStyle): void {\n const connector =\n style.connector && style.connector !== true ? style.connector : undefined;\n const arc = style.arc && style.arc !== true ? style.arc : undefined;\n validateGuideDimension(connector?.strokeWidth, \"strokeWidth\");\n validateGuideDimension(arc?.strokeWidth, \"strokeWidth\");\n validateGuideDimension(connector?.opacity, \"opacity\");\n validateGuideDimension(arc?.opacity, \"opacity\");\n if (\n arc?.sweep !== undefined &&\n (!Number.isFinite(arc.sweep) || arc.sweep <= 0 || arc.sweep > Math.PI * 2)\n )\n throw new Error(\n \"Manipulation arc sweep must be finite, positive, and no greater than 2\u03C0 radians.\",\n );\n}\n\nfunction readoutEnabled(\n readout: false | true | PibblManipulationReadoutStyle | undefined,\n formatter: unknown,\n): boolean {\n return (\n readout !== false && (readout !== undefined || formatter !== undefined)\n );\n}\nfunction formatResize(\n state: ManipulationState,\n format: PibblResizeHandleProps[\"formatReadout\"],\n): string {\n const box = state.options.box.get();\n const value = format\n ? format({ width: box.width, height: box.height })\n : `${round(box.width)} \u00D7 ${round(box.height)} px`;\n if (typeof value !== \"string\")\n throw new Error(\"Manipulation readout formatReadout must return a string.\");\n return value;\n}\nfunction formatRotation(\n state: ManipulationState,\n props: PibblRotationHandleProps,\n): string {\n const rotation = state.options.rotation?.get() ?? 0;\n const value = props.formatReadout\n ? props.formatReadout({ rotation })\n : props.readoutUnit === \"radians\"\n ? `${round(rotation)} rad`\n : `${round((rotation * 180) / Math.PI)}\u00B0`;\n if (typeof value !== \"string\")\n throw new Error(\"Manipulation readout formatReadout must return a string.\");\n return value;\n}\nfunction round(value: number): string {\n return Number.isInteger(value)\n ? String(value)\n : String(Number(value.toFixed(2)));\n}\nfunction paintReadout(\n ctx: RenderingContext2D,\n state: ManipulationState,\n anchor: DOMPoint,\n format: () => string,\n readout: false | true | PibblManipulationReadoutStyle | undefined,\n focused: boolean,\n active: boolean,\n position?: ResizePosition,\n defaultGap = 5,\n): void {\n validateReadoutStyle(readout);\n const resolved = resolveReadout(\n readout,\n state.controller.active.get() === null,\n focused,\n active,\n defaultGap,\n );\n if (!resolved.visible) return;\n const text = format();\n if (!text) return;\n const frameMapping = frameToCss(state);\n withCssContext(ctx, state, () => {\n ctx.font = resolved.font;\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"alphabetic\";\n const surface = state.root.surface.snapshot;\n if (!surface) return;\n const stroke = resolved.stroke ? resolved.strokeWidth : 0;\n const available = surface.displayWidth - 16 - stroke;\n const value = ellipsis(ctx, text, available);\n if (!value) return;\n const metrics = measureLabel(ctx, value);\n const glyphLeft = Math.max(0, metrics.actualBoundingBoxLeft);\n const glyphRight = Math.max(metrics.width, metrics.actualBoundingBoxRight);\n const ascent = Math.max(0, metrics.actualBoundingBoxAscent);\n const descent = Math.max(0, metrics.actualBoundingBoxDescent);\n const height = ascent + descent + 6 + stroke;\n const width = glyphLeft + glyphRight + 8 + stroke;\n if (width > surface.displayWidth - 8 || height > surface.displayHeight - 8)\n return;\n const offset = outwardReadoutOffset(\n frameMapping,\n position,\n width,\n height,\n resolved.gap,\n );\n let left = anchor.x + offset.x - width / 2;\n let top = anchor.y + offset.y - height / 2;\n left = Math.max(4, Math.min(surface.displayWidth - 4 - width, left));\n top = Math.max(4, Math.min(surface.displayHeight - 4 - height, top));\n ctx.globalAlpha *= resolved.opacity;\n ctx.fillStyle = resolved.fill;\n if (resolved.stroke) {\n ctx.strokeStyle = resolved.stroke;\n ctx.lineWidth = resolved.strokeWidth;\n ctx.strokeText(\n value,\n left + 4 + glyphLeft + stroke / 2,\n top + 3 + ascent + stroke / 2,\n );\n }\n ctx.fillText(\n value,\n left + 4 + glyphLeft + stroke / 2,\n top + 3 + ascent + stroke / 2,\n );\n });\n}\n/** Separate the upright label from the selected edges in displayed CSS space. */\nfunction outwardReadoutOffset(\n frameMapping: DOMMatrix,\n position: ResizePosition | undefined,\n width: number,\n height: number,\n gap: number,\n): DOMPoint {\n if (!position) return new DOMPoint(width / 2 + gap, 0);\n const inverse = frameMapping.inverse();\n const normals: DOMPoint[] = [];\n const add = (x: number, y: number, sign: number) => {\n const length = Math.hypot(x, y);\n normals.push(new DOMPoint((sign * x) / length, (sign * y) / length));\n };\n if (position.includes(\"left\")) add(inverse.a, inverse.c, -1);\n if (position.includes(\"right\")) add(inverse.a, inverse.c, 1);\n if (position.includes(\"top\")) add(inverse.b, inverse.d, -1);\n if (position.includes(\"bottom\")) add(inverse.b, inverse.d, 1);\n const support = (n: DOMPoint) =>\n (Math.abs(n.x) * width) / 2 + (Math.abs(n.y) * height) / 2 + gap;\n const [a, b] = normals;\n const da = support(a);\n if (!b) return new DOMPoint(a.x * da, a.y * da);\n const db = support(b),\n determinant = a.x * b.y - a.y * b.x;\n return new DOMPoint(\n (da * b.y - a.y * db) / determinant,\n (a.x * db - da * b.x) / determinant,\n );\n}\nfunction resolveReadout(\n value: false | true | PibblManipulationReadoutStyle | undefined,\n inactive: boolean,\n focused: boolean,\n active: boolean,\n defaultGap: number,\n): Required<PibblManipulationReadoutStateStyle> {\n const source = value && value !== true ? value : {};\n const base: Required<PibblManipulationReadoutStateStyle> = {\n gap: source.gap ?? defaultGap,\n font: source.font ?? \"12px sans-serif\",\n fill: source.fill ?? \"#1d4ed8\",\n stroke: source.stroke ?? \"\",\n strokeWidth: source.strokeWidth ?? 0,\n opacity: source.opacity ?? 1,\n visible: source.visible ?? false,\n };\n const patch = (next: PibblManipulationReadoutStateStyle | undefined) => {\n if (next) Object.assign(base, next);\n };\n if (inactive) patch(source.inactive);\n if (focused) patch(source.focused);\n if (active) (patch({ visible: true }), patch(source.active));\n return base;\n}\nconst labelMeasurements = new WeakMap<\n RenderingContext2D,\n Map<string, TextMetrics>\n>();\nfunction measureLabel(ctx: RenderingContext2D, text: string): TextMetrics {\n let cache = labelMeasurements.get(ctx);\n if (!cache) labelMeasurements.set(ctx, (cache = new Map()));\n const key = JSON.stringify([\n ctx.font,\n ctx.direction,\n ctx.fontKerning,\n ctx.letterSpacing,\n ctx.wordSpacing,\n text,\n ]);\n const found = cache.get(key);\n if (found) return found;\n const result = ctx.measureText(text);\n if (cache.size >= 64) cache.delete(cache.keys().next().value!);\n cache.set(key, result);\n return result;\n}\nfunction ellipsis(\n ctx: RenderingContext2D,\n text: string,\n width: number,\n): string {\n const fits = (value: string) => {\n const m = measureLabel(ctx, value);\n return (\n Math.max(0, m.actualBoundingBoxLeft) +\n Math.max(m.width, m.actualBoundingBoxRight) <=\n width\n );\n };\n if (width <= 0) return \"\";\n if (fits(text)) return text;\n const suffix = \"\u2026\";\n if (!fits(suffix)) return \"\";\n const points = Array.from(text);\n let low = 0,\n high = points.length;\n while (low < high) {\n const mid = Math.ceil((low + high) / 2);\n if (fits(points.slice(0, mid).join(\"\") + suffix)) low = mid;\n else high = mid - 1;\n }\n return points.slice(0, low).join(\"\") + suffix;\n}\nfunction withCssContext(\n ctx: RenderingContext2D,\n state: ManipulationState,\n draw: () => void,\n): void {\n const surface = state.root.surface.snapshot;\n if (!surface) return;\n const cssToCurrent = ctx.getTransform().multiply(frameToCss(state).inverse());\n ctx.save();\n try {\n ctx.setTransform(cssToCurrent);\n ctx.beginPath();\n ctx.rect(0, 0, surface.displayWidth, surface.displayHeight);\n ctx.clip();\n draw();\n } finally {\n ctx.restore();\n }\n}\n"],
5
+ "mappings": "AAGA,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,oBA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AAI,KAAK,IAAI,EAAG,QAAO;AACvB,QAAM,SAAS;AACf,MAAI,CAAC,KAAK,MAAM,EAAG,QAAO;AAC1B,QAAM,SAAS,MAAM,KAAK,IAAI;AAC9B,MAAI,MAAM,GACR,OAAO,OAAO;AAChB,SAAO,MAAM,MAAM;AACjB,UAAM,MAAM,KAAK,MAAM,MAAM,QAAQ,CAAC;AACtC,QAAI,KAAK,OAAO,MAAM,GAAG,GAAG,EAAE,KAAK,EAAE,IAAI,MAAM,EAAG,OAAM;AAAA,QACnD,QAAO,MAAM;AAAA,EACpB;AACA,SAAO,OAAO,MAAM,GAAG,GAAG,EAAE,KAAK,EAAE,IAAI;AACzC;AACA,SAAS,eACP,KACA,OACA,MACM;AACN,QAAM,UAAU,MAAM,KAAK,QAAQ;AACnC,MAAI,CAAC,QAAS;AACd,QAAM,eAAe,IAAI,aAAa,EAAE,SAAS,WAAW,KAAK,EAAE,QAAQ,CAAC;AAC5E,MAAI,KAAK;AACT,MAAI;AACF,QAAI,aAAa,YAAY;AAC7B,QAAI,UAAU;AACd,QAAI,KAAK,GAAG,GAAG,QAAQ,cAAc,QAAQ,aAAa;AAC1D,QAAI,KAAK;AACT,SAAK;AAAA,EACP,UAAE;AACA,QAAI,QAAQ;AAAA,EACd;AACF;",
6
6
  "names": ["CssHandleContent", "DragHandle", "DragReadout", "ResizeCollection", "ResizeHandle", "ResizeCollectionReadout", "RotationHandle"]
7
7
  }
@@ -5,6 +5,12 @@ import {
5
5
  isSnapActive,
6
6
  snapToLattice
7
7
  } from "./snap.js";
8
+ const sizeConstraintNames = [
9
+ "minWidth",
10
+ "minHeight",
11
+ "maxWidth",
12
+ "maxHeight"
13
+ ];
8
14
  function solveManipulation(input) {
9
15
  assertFiniteBox(input.initial, "initial");
10
16
  assertFinitePoint(input.initialPoint, "initialPoint");
@@ -246,12 +252,8 @@ function gridSteps(snap) {
246
252
  return typeof snap.step === "number" ? [snap.step, snap.step] : [snap.step.x, snap.step.y];
247
253
  }
248
254
  function resolvedResizeConstraints(options) {
249
- for (const name of [
250
- "minWidth",
251
- "minHeight",
252
- "maxWidth",
253
- "maxHeight"
254
- ]) {
255
+ for (let nameIndex = 0; nameIndex < sizeConstraintNames.length; nameIndex++) {
256
+ const name = sizeConstraintNames[nameIndex];
255
257
  const value = options?.[name];
256
258
  if (value !== void 0 && (!Number.isFinite(value) || value <= 0))
257
259
  throw new Error(`${name} must be positive and finite.`);
@@ -430,10 +432,10 @@ function boundsPlanes(initial, handle, rotation, bounds) {
430
432
  const widthCorners = rotatedCorners(unitWidth, rotation);
431
433
  const heightCorners = rotatedCorners(unitHeight, rotation);
432
434
  for (let index = 0; index < 4; index++) {
433
- for (const [coordinate, lower, upper] of [
434
- ["x", bounds.left, bounds.left + bounds.width],
435
- ["y", bounds.top, bounds.top + bounds.height]
436
- ]) {
435
+ for (let axis = 0; axis < 2; axis++) {
436
+ const coordinate = axis === 0 ? "x" : "y";
437
+ const lower = axis === 0 ? bounds.left : bounds.top;
438
+ const upper = lower + (axis === 0 ? bounds.width : bounds.height);
437
439
  const constant = zeroCorners[index][coordinate];
438
440
  const a = widthCorners[index][coordinate] - constant;
439
441
  const b = heightCorners[index][coordinate] - constant;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/manipulation/solve.ts"],
4
- "sourcesContent": ["import { assertFiniteBox, assertFinitePoint, freezeBox } from \"./geometry.js\";\nimport {\n assertFiniteOrigin,\n assertPositiveFiniteStep,\n isSnapActive,\n snapToLattice,\n} from \"./snap.js\";\nimport type {\n PibblManipulationBox,\n PibblManipulationMoveSnap,\n PibblManipulationResizeOptions,\n PibblManipulationResizeGridSnap,\n PibblManipulationResizeSizeSnap,\n PibblResizePosition,\n ManipulationSolveInput,\n ManipulationSolveResult,\n} from \"./types.js\";\n\nexport function solveManipulation(\n input: ManipulationSolveInput,\n): ManipulationSolveResult {\n assertFiniteBox(input.initial, \"initial\");\n assertFinitePoint(input.initialPoint, \"initialPoint\");\n assertFinitePoint(input.currentPoint, \"currentPoint\");\n validateConfiguredSnaps(input);\n if (!Number.isFinite(input.initialRotation ?? 0))\n throw new Error(\"initialRotation must be finite.\");\n\n switch (input.operation) {\n case \"move\":\n return solveMove(input);\n case \"resize\":\n return solveResize(input);\n case \"rotate\":\n return solveRotation(input);\n }\n}\n\nfunction solveMove(input: ManipulationSolveInput): ManipulationSolveResult {\n const { initial } = input;\n const axis = input.move?.axis ?? \"both\";\n if (input.move?.bounds) {\n assertFiniteBox(input.move.bounds, \"move.bounds\");\n if (\n !containsRotated(input.move.bounds, initial, input.initialRotation ?? 0)\n )\n throw new Error(\"Move bounds must contain the initial box.\");\n }\n const deltaX = input.currentPoint.x - input.initialPoint.x;\n const deltaY = input.currentPoint.y - input.initialPoint.y;\n const proposed = freezeBox({\n ...initial,\n left: axis === \"y\" ? initial.left : initial.left + deltaX,\n top: axis === \"x\" ? initial.top : initial.top + deltaY,\n });\n const snap = input.move?.snap;\n const snapActive =\n snap !== undefined &&\n isSnapActive(snap.enabled, snap.when, input.modifiers);\n if (!snapActive)\n return result(\n proposed,\n clampMoveToBounds(\n proposed,\n input.move?.bounds,\n input.initialRotation ?? 0,\n ),\n false,\n true,\n input.initialRotation,\n );\n\n const [stepX, stepY] = moveSteps(snap!);\n const origin = snap!.origin;\n const applied = freezeBox({\n ...proposed,\n left:\n axis === \"y\"\n ? proposed.left\n : snapToLattice(proposed.left, stepX, origin?.x ?? 0),\n top:\n axis === \"x\"\n ? proposed.top\n : snapToLattice(proposed.top, stepY, origin?.y ?? 0),\n });\n const bounded = clampMoveToBounds(\n applied,\n input.move?.bounds,\n input.initialRotation ?? 0,\n );\n return result(\n proposed,\n bounded,\n true,\n boxesEqual(applied, bounded),\n input.initialRotation,\n );\n}\n\nfunction solveResize(input: ManipulationSolveInput): ManipulationSolveResult {\n const handle = input.handle;\n if (!handle) throw new Error(\"Resize manipulation requires a handle.\");\n const rotation = input.initialRotation ?? 0;\n if (!Number.isFinite(rotation))\n throw new Error(\"initialRotation must be finite.\");\n if (input.resize?.snap?.target === \"grid\" && rotation !== 0)\n throw new Error(\"Grid resize snapping requires an unrotated box.\");\n const raw = resizeFromPoint(\n input.initial,\n handle,\n rotateInverse(\n {\n x: input.currentPoint.x - input.initialPoint.x,\n y: input.currentPoint.y - input.initialPoint.y,\n },\n rotation,\n ),\n );\n const proposed = resizeFromDimensionsRotated(\n input.initial,\n handle,\n raw.width,\n raw.height,\n rotation,\n );\n const ratio = activeRatio(input.initial, input.resize, input.modifiers);\n const changesWidth = handle.includes(\"left\") || handle.includes(\"right\");\n const changesHeight = handle.includes(\"top\") || handle.includes(\"bottom\");\n const constraints = resolvedResizeConstraints(input.resize);\n if (ratio === undefined) {\n if (!changesWidth) {\n if (\n input.initial.width < constraints.minWidth ||\n input.initial.width > constraints.maxWidth\n )\n throw new Error(\n \"Resize width constraints conflict with the fixed dimension.\",\n );\n constraints.minWidth = constraints.maxWidth = input.initial.width;\n }\n if (!changesHeight) {\n if (\n input.initial.height < constraints.minHeight ||\n input.initial.height > constraints.maxHeight\n )\n throw new Error(\n \"Resize height constraints conflict with the fixed dimension.\",\n );\n constraints.minHeight = constraints.maxHeight = input.initial.height;\n }\n }\n const snap = input.resize?.snap;\n const snapActive =\n snap !== undefined &&\n isSnapActive(snap.enabled, snap.when, input.modifiers);\n let width = raw.width;\n let height = raw.height;\n if (ratio !== undefined) {\n const widthDrives =\n changesWidth &&\n (!changesHeight ||\n Math.abs(raw.width / input.initial.width - 1) >=\n Math.abs(raw.height / input.initial.height - 1));\n if (snapActive) {\n const snapped = snapResize(input.initial, raw, handle, snap!);\n if (widthDrives) width = snapped.width;\n else height = snapped.height;\n }\n if (widthDrives) height = width / ratio;\n else width = height * ratio;\n } else if (snapActive) {\n const snapped = snapResize(input.initial, raw, handle, snap!);\n width = snapped.width;\n height = snapped.height;\n }\n const bounded = constrainDimensions(\n input.initial,\n handle,\n { width, height },\n rotation,\n input.resize?.bounds,\n ratio,\n constraints,\n );\n const applied = resizeFromDimensionsRotated(\n input.initial,\n handle,\n bounded.width,\n bounded.height,\n rotation,\n );\n const onLattice = (value: number, step: number, origin = 0) =>\n Math.abs(value - snapToLattice(value, step, origin)) <=\n 1e-9 * Math.max(1, Math.abs(value));\n let snapSatisfied = true;\n if (snapActive) {\n if (snap!.target === \"grid\") {\n const grid = snap as PibblManipulationResizeGridSnap;\n const [stepX, stepY] = gridSteps(grid);\n snapSatisfied =\n (!changesWidth ||\n onLattice(\n handle.includes(\"left\")\n ? applied.left\n : applied.left + applied.width,\n stepX,\n grid.origin?.x,\n )) &&\n (!changesHeight ||\n onLattice(\n handle.includes(\"top\") ? applied.top : applied.top + applied.height,\n stepY,\n grid.origin?.y,\n ));\n } else {\n const [stepWidth, stepHeight] = sizeSteps(\n snap as PibblManipulationResizeSizeSnap,\n );\n snapSatisfied =\n (!(changesWidth || ratio !== undefined) ||\n onLattice(applied.width, stepWidth)) &&\n (!(changesHeight || ratio !== undefined) ||\n onLattice(applied.height, stepHeight));\n }\n }\n return result(proposed, applied, snapActive, snapSatisfied, rotation);\n}\n\nfunction solveRotation(input: ManipulationSolveInput): ManipulationSolveResult {\n const initialRotation = input.initialRotation ?? 0;\n const delta = input.rotationDelta ?? 0;\n if (!Number.isFinite(initialRotation) || !Number.isFinite(delta)) {\n throw new Error(\"Rotation values must be finite.\");\n }\n const proposedRotation = initialRotation + delta;\n const snap = input.rotate?.snap;\n const snapActive =\n snap !== undefined &&\n isSnapActive(snap.enabled, snap.when, input.modifiers);\n const appliedRotation = snapActive\n ? snapToLattice(proposedRotation, snap!.step, snap!.origin ?? 0)\n : proposedRotation;\n return result(\n input.initial,\n input.initial,\n snapActive,\n true,\n initialRotation,\n proposedRotation,\n appliedRotation,\n );\n}\n\nfunction resizeFromPoint(\n initial: PibblManipulationBox,\n handle: PibblResizePosition,\n delta: Readonly<{ x: number; y: number }>,\n): PibblManipulationBox {\n const movesLeft = handle.includes(\"left\");\n const movesRight = handle.includes(\"right\");\n const movesTop = handle.includes(\"top\");\n const movesBottom = handle.includes(\"bottom\");\n return freezeBox({\n left: movesLeft ? initial.left + delta.x : initial.left,\n top: movesTop ? initial.top + delta.y : initial.top,\n width:\n initial.width + (movesRight ? delta.x : 0) - (movesLeft ? delta.x : 0),\n height:\n initial.height + (movesBottom ? delta.y : 0) - (movesTop ? delta.y : 0),\n });\n}\n\nfunction resizeFromDimensions(\n initial: PibblManipulationBox,\n handle: PibblResizePosition,\n width: number,\n height: number,\n): PibblManipulationBox {\n return freezeBox({\n left: handle.includes(\"left\")\n ? initial.left + initial.width - width\n : initial.left,\n top: handle.includes(\"top\")\n ? initial.top + initial.height - height\n : initial.top,\n width,\n height,\n });\n}\n\nfunction snapResize(\n initial: PibblManipulationBox,\n proposed: PibblManipulationBox,\n handle: PibblResizePosition,\n snap: PibblManipulationResizeSizeSnap | PibblManipulationResizeGridSnap,\n): PibblManipulationBox {\n if (snap.target === \"grid\") {\n const [stepX, stepY] = gridSteps(snap);\n const origin = snap.origin;\n const movesLeft = handle.includes(\"left\");\n const movesTop = handle.includes(\"top\");\n const edgeX = movesLeft ? proposed.left : proposed.left + proposed.width;\n const edgeY = movesTop ? proposed.top : proposed.top + proposed.height;\n const snappedEdgeX = snapToLattice(edgeX, stepX, origin?.x ?? 0);\n const snappedEdgeY = snapToLattice(edgeY, stepY, origin?.y ?? 0);\n const width = !(handle.includes(\"left\") || handle.includes(\"right\"))\n ? initial.width\n : movesLeft\n ? initial.left + initial.width - snappedEdgeX\n : snappedEdgeX - initial.left;\n const height = !(handle.includes(\"top\") || handle.includes(\"bottom\"))\n ? initial.height\n : movesTop\n ? initial.top + initial.height - snappedEdgeY\n : snappedEdgeY - initial.top;\n return resizeFromDimensions(initial, handle, width, height);\n }\n const [stepWidth, stepHeight] = sizeSteps(snap);\n return resizeFromDimensions(\n proposed,\n handle,\n handle.includes(\"left\") || handle.includes(\"right\")\n ? snapToLattice(proposed.width, stepWidth)\n : proposed.width,\n handle.includes(\"top\") || handle.includes(\"bottom\")\n ? snapToLattice(proposed.height, stepHeight)\n : proposed.height,\n );\n}\n\nfunction moveSteps(snap: PibblManipulationMoveSnap): readonly [number, number] {\n return typeof snap.step === \"number\"\n ? [snap.step, snap.step]\n : [snap.step.x, snap.step.y];\n}\n\nfunction sizeSteps(\n snap: PibblManipulationResizeSizeSnap,\n): readonly [number, number] {\n return typeof snap.step === \"number\"\n ? [snap.step, snap.step]\n : [snap.step.width, snap.step.height];\n}\n\nfunction gridSteps(\n snap: PibblManipulationResizeGridSnap,\n): readonly [number, number] {\n return typeof snap.step === \"number\"\n ? [snap.step, snap.step]\n : [snap.step.x, snap.step.y];\n}\n\nfunction resolvedResizeConstraints(\n options: PibblManipulationResizeOptions | undefined,\n): {\n minWidth: number;\n minHeight: number;\n maxWidth: number;\n maxHeight: number;\n} {\n for (const name of [\n \"minWidth\",\n \"minHeight\",\n \"maxWidth\",\n \"maxHeight\",\n ] as const) {\n const value = options?.[name];\n if (value !== undefined && (!Number.isFinite(value) || value <= 0))\n throw new Error(`${name} must be positive and finite.`);\n }\n const minWidth = options?.minWidth ?? 1;\n const minHeight = options?.minHeight ?? 1;\n const maxWidth = options?.maxWidth ?? Number.POSITIVE_INFINITY;\n const maxHeight = options?.maxHeight ?? Number.POSITIVE_INFINITY;\n for (const [name, value] of Object.entries({\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n })) {\n if (!Number.isFinite(value) && value !== Number.POSITIVE_INFINITY) {\n throw new Error(`${name} must be finite, received ${value}`);\n }\n }\n if (minWidth <= 0 || minHeight <= 0 || maxWidth <= 0 || maxHeight <= 0) {\n throw new Error(\"Resize constraints must be greater than zero.\");\n }\n if (minWidth > maxWidth || minHeight > maxHeight) {\n throw new Error(\n \"Resize minimum dimensions must not exceed maximum dimensions.\",\n );\n }\n return { minWidth, minHeight, maxWidth, maxHeight };\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value));\n}\n\nfunction clampMoveToBounds(\n box: PibblManipulationBox,\n bounds: PibblManipulationBox | undefined,\n rotation = 0,\n): PibblManipulationBox {\n if (!bounds) return box;\n assertFiniteBox(bounds, \"move.bounds\");\n const corners = rotatedCorners(box, rotation);\n const minX = Math.min(...corners.map((point) => point.x));\n const maxX = Math.max(...corners.map((point) => point.x));\n const minY = Math.min(...corners.map((point) => point.y));\n const maxY = Math.max(...corners.map((point) => point.y));\n if (maxX - minX > bounds.width || maxY - minY > bounds.height)\n throw new Error(\"Move bounds cannot contain the initial box.\");\n return freezeBox({\n ...box,\n left:\n box.left +\n clamp(0, bounds.left - minX, bounds.left + bounds.width - maxX),\n top:\n box.top + clamp(0, bounds.top - minY, bounds.top + bounds.height - maxY),\n });\n}\n\nfunction activeRatio(\n initial: PibblManipulationBox,\n options: PibblManipulationResizeOptions | undefined,\n modifiers: ManipulationSolveInput[\"modifiers\"],\n): number | undefined {\n const aspect = options?.aspectRatio;\n if (!aspect) return undefined;\n const ratio =\n aspect.value === \"initial\" ? initial.width / initial.height : aspect.value;\n if (!Number.isFinite(ratio) || ratio <= 0)\n throw new Error(\n \"Resize aspect ratio must be finite and greater than zero.\",\n );\n return isSnapActive(true, aspect.when, modifiers) ? ratio : undefined;\n}\n\nfunction rotateInverse(\n point: Readonly<{ x: number; y: number }>,\n radians: number,\n): Readonly<{ x: number; y: number }> {\n const cosine = Math.cos(radians);\n const sine = Math.sin(radians);\n return {\n x: point.x * cosine + point.y * sine,\n y: -point.x * sine + point.y * cosine,\n };\n}\n\nfunction resizeFromDimensionsRotated(\n initial: PibblManipulationBox,\n handle: PibblResizePosition,\n width: number,\n height: number,\n radians: number,\n): PibblManipulationBox {\n const oldCenter = {\n x: initial.left + initial.width / 2,\n y: initial.top + initial.height / 2,\n };\n const opposite = {\n x: handle.includes(\"left\")\n ? initial.width / 2\n : handle.includes(\"right\")\n ? -initial.width / 2\n : 0,\n y: handle.includes(\"top\")\n ? initial.height / 2\n : handle.includes(\"bottom\")\n ? -initial.height / 2\n : 0,\n };\n const cosine = Math.cos(radians);\n const sine = Math.sin(radians);\n const anchor = {\n x: oldCenter.x + opposite.x * cosine - opposite.y * sine,\n y: oldCenter.y + opposite.x * sine + opposite.y * cosine,\n };\n const nextOpposite = {\n x: handle.includes(\"left\")\n ? width / 2\n : handle.includes(\"right\")\n ? -width / 2\n : 0,\n y: handle.includes(\"top\")\n ? height / 2\n : handle.includes(\"bottom\")\n ? -height / 2\n : 0,\n };\n const center = {\n x: anchor.x - (nextOpposite.x * cosine - nextOpposite.y * sine),\n y: anchor.y - (nextOpposite.x * sine + nextOpposite.y * cosine),\n };\n return freezeBox({\n left: center.x - width / 2,\n top: center.y - height / 2,\n width,\n height,\n });\n}\n\nfunction constrainDimensions(\n initial: PibblManipulationBox,\n handle: PibblResizePosition,\n proposed: SizePoint,\n rotation: number,\n bounds: PibblManipulationBox | undefined,\n ratio: number | undefined,\n constraints: ReturnType<typeof resolvedResizeConstraints>,\n): SizePoint {\n if (!Number.isFinite(proposed.width) || !Number.isFinite(proposed.height))\n throw new Error(\"Resize geometry exceeds finite coordinates.\");\n if (bounds) {\n assertFiniteBox(bounds, \"resize.bounds\");\n if (!containsRotated(bounds, initial, rotation))\n throw new Error(\"Resize bounds must contain the initial box.\");\n }\n if (ratio !== undefined) {\n let minimum = Math.max(constraints.minWidth, constraints.minHeight * ratio);\n let maximum = Math.min(constraints.maxWidth, constraints.maxHeight * ratio);\n for (const plane of bounds\n ? boundsPlanes(initial, handle, rotation, bounds)\n : []) {\n const slope = plane.a + plane.b / ratio;\n if (Math.abs(slope) < 1e-12) {\n if (plane.c < -1e-9)\n throw new Error(\"Resize bounds have no feasible ratio.\");\n } else if (slope > 0) maximum = Math.min(maximum, plane.c / slope);\n else minimum = Math.max(minimum, plane.c / slope);\n }\n if (minimum > maximum)\n throw new Error(\n \"Resize constraints cannot satisfy the aspect ratio and bounds.\",\n );\n const width = clamp(proposed.width, minimum, maximum);\n return { width, height: width / ratio };\n }\n if (bounds)\n return projectSizeToBounds(\n initial,\n handle,\n proposed,\n rotation,\n bounds,\n constraints,\n );\n return {\n width: clamp(proposed.width, constraints.minWidth, constraints.maxWidth),\n height: clamp(\n proposed.height,\n constraints.minHeight,\n constraints.maxHeight,\n ),\n };\n}\n\ntype SizePoint = Readonly<{ width: number; height: number }>;\ntype HalfPlane = Readonly<{ a: number; b: number; c: number }>;\n\nfunction projectSizeToBounds(\n initial: PibblManipulationBox,\n handle: PibblResizePosition,\n proposed: SizePoint,\n rotation: number,\n bounds: PibblManipulationBox,\n constraints: ReturnType<typeof resolvedResizeConstraints>,\n): SizePoint {\n const maximumWidth = Number.isFinite(constraints.maxWidth)\n ? constraints.maxWidth\n : Math.max(initial.width, bounds.width + bounds.height);\n const maximumHeight = Number.isFinite(constraints.maxHeight)\n ? constraints.maxHeight\n : Math.max(initial.height, bounds.width + bounds.height);\n let polygon: SizePoint[] = [\n { width: constraints.minWidth, height: constraints.minHeight },\n { width: maximumWidth, height: constraints.minHeight },\n { width: maximumWidth, height: maximumHeight },\n { width: constraints.minWidth, height: maximumHeight },\n ];\n const planes = boundsPlanes(initial, handle, rotation, bounds);\n for (const plane of planes) polygon = clipPolygon(polygon, plane);\n if (polygon.length === 0)\n throw new Error(\"Resize bounds have no feasible size region.\");\n return closestPointInPolygon(\n { width: proposed.width, height: proposed.height },\n polygon,\n );\n}\n\nfunction boundsPlanes(\n initial: PibblManipulationBox,\n handle: PibblResizePosition,\n rotation: number,\n bounds: PibblManipulationBox,\n): readonly HalfPlane[] {\n const zero = resizeFromDimensionsRotated(initial, handle, 0, 0, rotation);\n const unitWidth = resizeFromDimensionsRotated(\n initial,\n handle,\n 1,\n 0,\n rotation,\n );\n const unitHeight = resizeFromDimensionsRotated(\n initial,\n handle,\n 0,\n 1,\n rotation,\n );\n const planes: HalfPlane[] = [];\n const zeroCorners = rotatedCorners(zero, rotation);\n const widthCorners = rotatedCorners(unitWidth, rotation);\n const heightCorners = rotatedCorners(unitHeight, rotation);\n for (let index = 0; index < 4; index++) {\n for (const [coordinate, lower, upper] of [\n [\"x\", bounds.left, bounds.left + bounds.width],\n [\"y\", bounds.top, bounds.top + bounds.height],\n ] as const) {\n const constant = zeroCorners[index][coordinate];\n const a = widthCorners[index][coordinate] - constant;\n const b = heightCorners[index][coordinate] - constant;\n planes.push(\n { a, b, c: upper - constant },\n { a: -a, b: -b, c: constant - lower },\n );\n }\n }\n return planes;\n}\n\nfunction clipPolygon(\n points: readonly SizePoint[],\n plane: HalfPlane,\n): SizePoint[] {\n const output: SizePoint[] = [];\n for (let index = 0; index < points.length; index++) {\n const from = points[index];\n const to = points[(index + 1) % points.length];\n const fromValue = plane.a * from.width + plane.b * from.height - plane.c;\n const toValue = plane.a * to.width + plane.b * to.height - plane.c;\n if (fromValue <= 0) output.push(from);\n if (fromValue <= 0 !== toValue <= 0) {\n const t = fromValue / (fromValue - toValue);\n output.push({\n width: from.width + (to.width - from.width) * t,\n height: from.height + (to.height - from.height) * t,\n });\n }\n }\n return output;\n}\n\nfunction closestPointInPolygon(\n point: SizePoint,\n polygon: readonly SizePoint[],\n): SizePoint {\n const area = polygon.reduce((sum, candidate, index) => {\n const next = polygon[(index + 1) % polygon.length];\n return sum + candidate.width * next.height - next.width * candidate.height;\n }, 0);\n if (\n Math.abs(area) > 1e-12 &&\n polygon.every((candidate, index) => {\n const next = polygon[(index + 1) % polygon.length];\n return (\n (next.width - candidate.width) * (point.height - candidate.height) -\n (next.height - candidate.height) * (point.width - candidate.width) >=\n -1e-9\n );\n })\n )\n return point;\n let best = polygon[0];\n let distance = Number.POSITIVE_INFINITY;\n for (let index = 0; index < polygon.length; index++) {\n const from = polygon[index];\n const to = polygon[(index + 1) % polygon.length];\n const dx = to.width - from.width;\n const dy = to.height - from.height;\n const scale =\n dx === 0 && dy === 0\n ? 0\n : clamp(\n ((point.width - from.width) * dx +\n (point.height - from.height) * dy) /\n (dx * dx + dy * dy),\n 0,\n 1,\n );\n const candidate = {\n width: from.width + dx * scale,\n height: from.height + dy * scale,\n };\n const nextDistance =\n (candidate.width - point.width) ** 2 +\n (candidate.height - point.height) ** 2;\n if (\n nextDistance < distance ||\n (nextDistance === distance &&\n (candidate.width > best.width ||\n (candidate.width === best.width && candidate.height > best.height)))\n ) {\n best = candidate;\n distance = nextDistance;\n }\n }\n return best;\n}\n\nfunction containsRotated(\n bounds: PibblManipulationBox,\n box: PibblManipulationBox,\n radians: number,\n): boolean {\n return rotatedCorners(box, radians).every(\n (point) =>\n point.x >= bounds.left &&\n point.x <= bounds.left + bounds.width &&\n point.y >= bounds.top &&\n point.y <= bounds.top + bounds.height,\n );\n}\n\nfunction rotatedCorners(\n box: PibblManipulationBox,\n radians: number,\n): readonly Readonly<{ x: number; y: number }>[] {\n const center = { x: box.left + box.width / 2, y: box.top + box.height / 2 };\n const cosine = Math.cos(radians);\n const sine = Math.sin(radians);\n return [\n [-box.width / 2, -box.height / 2],\n [box.width / 2, -box.height / 2],\n [box.width / 2, box.height / 2],\n [-box.width / 2, box.height / 2],\n ].map(([x, y]) => ({\n x: center.x + x * cosine - y * sine,\n y: center.y + x * sine + y * cosine,\n }));\n}\n\nfunction validateConfiguredSnaps(input: ManipulationSolveInput): void {\n const check = (\n step: number | Readonly<Record<string, number>>,\n origin: Readonly<Record<string, number | undefined>> | undefined,\n label: string,\n ) => {\n for (const [name, value] of Object.entries(\n typeof step === \"number\" ? { value: step } : step,\n ))\n assertPositiveFiniteStep(value, `${label}.${name}`);\n for (const [name, value] of Object.entries(origin ?? {}))\n if (value !== undefined)\n assertFiniteOrigin(value, `${label}.origin.${name}`);\n };\n if (input.move?.snap)\n check(input.move.snap.step, input.move.snap.origin, \"move.snap.step\");\n if (input.resize?.snap)\n check(\n input.resize.snap.step,\n input.resize.snap.target === \"grid\"\n ? input.resize.snap.origin\n : undefined,\n \"resize.snap.step\",\n );\n if (input.rotate?.snap)\n check(\n input.rotate.snap.step,\n { value: input.rotate.snap.origin },\n \"rotate.snap.step\",\n );\n}\n\nfunction boxesEqual(\n left: PibblManipulationBox,\n right: PibblManipulationBox,\n): boolean {\n return (\n left.left === right.left &&\n left.top === right.top &&\n left.width === right.width &&\n left.height === right.height\n );\n}\n\nfunction result(\n proposed: PibblManipulationBox,\n applied: PibblManipulationBox,\n snapActive: boolean,\n snapSatisfied: boolean,\n initialRotation = 0,\n proposedRotation = initialRotation,\n appliedRotation = proposedRotation,\n): ManipulationSolveResult {\n assertFiniteBox(applied, \"applied\");\n if (!Number.isFinite(proposedRotation) || !Number.isFinite(appliedRotation))\n throw new Error(\"Rotation exceeds finite coordinates.\");\n return Object.freeze({\n proposed,\n applied,\n snapActive,\n snapSatisfied,\n proposedRotation,\n appliedRotation,\n });\n}\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB,mBAAmB,iBAAiB;AAC9D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAYA,SAAS,kBACd,OACyB;AACzB,kBAAgB,MAAM,SAAS,SAAS;AACxC,oBAAkB,MAAM,cAAc,cAAc;AACpD,oBAAkB,MAAM,cAAc,cAAc;AACpD,0BAAwB,KAAK;AAC7B,MAAI,CAAC,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC7C,UAAM,IAAI,MAAM,iCAAiC;AAEnD,UAAQ,MAAM,WAAW;AAAA,IACvB,KAAK;AACH,aAAO,UAAU,KAAK;AAAA,IACxB,KAAK;AACH,aAAO,YAAY,KAAK;AAAA,IAC1B,KAAK;AACH,aAAO,cAAc,KAAK;AAAA,EAC9B;AACF;AAEA,SAAS,UAAU,OAAwD;AACzE,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,OAAO,MAAM,MAAM,QAAQ;AACjC,MAAI,MAAM,MAAM,QAAQ;AACtB,oBAAgB,MAAM,KAAK,QAAQ,aAAa;AAChD,QACE,CAAC,gBAAgB,MAAM,KAAK,QAAQ,SAAS,MAAM,mBAAmB,CAAC;AAEvE,YAAM,IAAI,MAAM,2CAA2C;AAAA,EAC/D;AACA,QAAM,SAAS,MAAM,aAAa,IAA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MACjC,OAAO,SAAS,WAAW,EAAE,OAAO,KAAK,IAAI;AAAA,IAC/C;AACE,+BAAyB,OAAO,GAAG,KAAK,IAAI,IAAI,EAAE;AACpD,eAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,UAAU,CAAC,CAAC;AACrD,UAAI,UAAU;AACZ,2BAAmB,OAAO,GAAG,KAAK,WAAW,IAAI,EAAE;AAAA,EACzD;AACA,MAAI,MAAM,MAAM;AACd,UAAM,MAAM,KAAK,KAAK,MAAM,MAAM,KAAK,KAAK,QAAQ,gBAAgB;AACtE,MAAI,MAAM,QAAQ;AAChB;AAAA,MACE,MAAM,OAAO,KAAK;AAAA,MAClB,MAAM,OAAO,KAAK,WAAW,SACzB,MAAM,OAAO,KAAK,SAClB;AAAA,MACJ;AAAA,IACF;AACF,MAAI,MAAM,QAAQ;AAChB;AAAA,MACE,MAAM,OAAO,KAAK;AAAA,MAClB,EAAE,OAAO,MAAM,OAAO,KAAK,OAAO;AAAA,MAClC;AAAA,IACF;AACJ;AAEA,SAAS,WACP,MACA,OACS;AACT,SACE,KAAK,SAAS,MAAM,QACpB,KAAK,QAAQ,MAAM,OACnB,KAAK,UAAU,MAAM,SACrB,KAAK,WAAW,MAAM;AAE1B;AAEA,SAAS,OACP,UACA,SACA,YACA,eACA,kBAAkB,GAClB,mBAAmB,iBACnB,kBAAkB,kBACO;AACzB,kBAAgB,SAAS,SAAS;AAClC,MAAI,CAAC,OAAO,SAAS,gBAAgB,KAAK,CAAC,OAAO,SAAS,eAAe;AACxE,UAAM,IAAI,MAAM,sCAAsC;AACxD,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
4
+ "sourcesContent": ["import { assertFiniteBox, assertFinitePoint, freezeBox } from \"./geometry.js\";\nimport {\n assertFiniteOrigin,\n assertPositiveFiniteStep,\n isSnapActive,\n snapToLattice,\n} from \"./snap.js\";\nimport type {\n PibblManipulationBox,\n PibblManipulationMoveSnap,\n PibblManipulationResizeOptions,\n PibblManipulationResizeGridSnap,\n PibblManipulationResizeSizeSnap,\n PibblResizePosition,\n ManipulationSolveInput,\n ManipulationSolveResult,\n} from \"./types.js\";\nconst sizeConstraintNames = [\n \"minWidth\",\n \"minHeight\",\n \"maxWidth\",\n \"maxHeight\",\n ] as const;\n\nexport function solveManipulation(\n input: ManipulationSolveInput,\n): ManipulationSolveResult {\n assertFiniteBox(input.initial, \"initial\");\n assertFinitePoint(input.initialPoint, \"initialPoint\");\n assertFinitePoint(input.currentPoint, \"currentPoint\");\n validateConfiguredSnaps(input);\n if (!Number.isFinite(input.initialRotation ?? 0))\n throw new Error(\"initialRotation must be finite.\");\n\n switch (input.operation) {\n case \"move\":\n return solveMove(input);\n case \"resize\":\n return solveResize(input);\n case \"rotate\":\n return solveRotation(input);\n }\n}\n\nfunction solveMove(input: ManipulationSolveInput): ManipulationSolveResult {\n const { initial } = input;\n const axis = input.move?.axis ?? \"both\";\n if (input.move?.bounds) {\n assertFiniteBox(input.move.bounds, \"move.bounds\");\n if (\n !containsRotated(input.move.bounds, initial, input.initialRotation ?? 0)\n )\n throw new Error(\"Move bounds must contain the initial box.\");\n }\n const deltaX = input.currentPoint.x - input.initialPoint.x;\n const deltaY = input.currentPoint.y - input.initialPoint.y;\n const proposed = freezeBox({\n ...initial,\n left: axis === \"y\" ? initial.left : initial.left + deltaX,\n top: axis === \"x\" ? initial.top : initial.top + deltaY,\n });\n const snap = input.move?.snap;\n const snapActive =\n snap !== undefined &&\n isSnapActive(snap.enabled, snap.when, input.modifiers);\n if (!snapActive)\n return result(\n proposed,\n clampMoveToBounds(\n proposed,\n input.move?.bounds,\n input.initialRotation ?? 0,\n ),\n false,\n true,\n input.initialRotation,\n );\n\n const [stepX, stepY] = moveSteps(snap!);\n const origin = snap!.origin;\n const applied = freezeBox({\n ...proposed,\n left:\n axis === \"y\"\n ? proposed.left\n : snapToLattice(proposed.left, stepX, origin?.x ?? 0),\n top:\n axis === \"x\"\n ? proposed.top\n : snapToLattice(proposed.top, stepY, origin?.y ?? 0),\n });\n const bounded = clampMoveToBounds(\n applied,\n input.move?.bounds,\n input.initialRotation ?? 0,\n );\n return result(\n proposed,\n bounded,\n true,\n boxesEqual(applied, bounded),\n input.initialRotation,\n );\n}\n\nfunction solveResize(input: ManipulationSolveInput): ManipulationSolveResult {\n const handle = input.handle;\n if (!handle) throw new Error(\"Resize manipulation requires a handle.\");\n const rotation = input.initialRotation ?? 0;\n if (!Number.isFinite(rotation))\n throw new Error(\"initialRotation must be finite.\");\n if (input.resize?.snap?.target === \"grid\" && rotation !== 0)\n throw new Error(\"Grid resize snapping requires an unrotated box.\");\n const raw = resizeFromPoint(\n input.initial,\n handle,\n rotateInverse(\n {\n x: input.currentPoint.x - input.initialPoint.x,\n y: input.currentPoint.y - input.initialPoint.y,\n },\n rotation,\n ),\n );\n const proposed = resizeFromDimensionsRotated(\n input.initial,\n handle,\n raw.width,\n raw.height,\n rotation,\n );\n const ratio = activeRatio(input.initial, input.resize, input.modifiers);\n const changesWidth = handle.includes(\"left\") || handle.includes(\"right\");\n const changesHeight = handle.includes(\"top\") || handle.includes(\"bottom\");\n const constraints = resolvedResizeConstraints(input.resize);\n if (ratio === undefined) {\n if (!changesWidth) {\n if (\n input.initial.width < constraints.minWidth ||\n input.initial.width > constraints.maxWidth\n )\n throw new Error(\n \"Resize width constraints conflict with the fixed dimension.\",\n );\n constraints.minWidth = constraints.maxWidth = input.initial.width;\n }\n if (!changesHeight) {\n if (\n input.initial.height < constraints.minHeight ||\n input.initial.height > constraints.maxHeight\n )\n throw new Error(\n \"Resize height constraints conflict with the fixed dimension.\",\n );\n constraints.minHeight = constraints.maxHeight = input.initial.height;\n }\n }\n const snap = input.resize?.snap;\n const snapActive =\n snap !== undefined &&\n isSnapActive(snap.enabled, snap.when, input.modifiers);\n let width = raw.width;\n let height = raw.height;\n if (ratio !== undefined) {\n const widthDrives =\n changesWidth &&\n (!changesHeight ||\n Math.abs(raw.width / input.initial.width - 1) >=\n Math.abs(raw.height / input.initial.height - 1));\n if (snapActive) {\n const snapped = snapResize(input.initial, raw, handle, snap!);\n if (widthDrives) width = snapped.width;\n else height = snapped.height;\n }\n if (widthDrives) height = width / ratio;\n else width = height * ratio;\n } else if (snapActive) {\n const snapped = snapResize(input.initial, raw, handle, snap!);\n width = snapped.width;\n height = snapped.height;\n }\n const bounded = constrainDimensions(\n input.initial,\n handle,\n { width, height },\n rotation,\n input.resize?.bounds,\n ratio,\n constraints,\n );\n const applied = resizeFromDimensionsRotated(\n input.initial,\n handle,\n bounded.width,\n bounded.height,\n rotation,\n );\n const onLattice = (value: number, step: number, origin = 0) =>\n Math.abs(value - snapToLattice(value, step, origin)) <=\n 1e-9 * Math.max(1, Math.abs(value));\n let snapSatisfied = true;\n if (snapActive) {\n if (snap!.target === \"grid\") {\n const grid = snap as PibblManipulationResizeGridSnap;\n const [stepX, stepY] = gridSteps(grid);\n snapSatisfied =\n (!changesWidth ||\n onLattice(\n handle.includes(\"left\")\n ? applied.left\n : applied.left + applied.width,\n stepX,\n grid.origin?.x,\n )) &&\n (!changesHeight ||\n onLattice(\n handle.includes(\"top\") ? applied.top : applied.top + applied.height,\n stepY,\n grid.origin?.y,\n ));\n } else {\n const [stepWidth, stepHeight] = sizeSteps(\n snap as PibblManipulationResizeSizeSnap,\n );\n snapSatisfied =\n (!(changesWidth || ratio !== undefined) ||\n onLattice(applied.width, stepWidth)) &&\n (!(changesHeight || ratio !== undefined) ||\n onLattice(applied.height, stepHeight));\n }\n }\n return result(proposed, applied, snapActive, snapSatisfied, rotation);\n}\n\nfunction solveRotation(input: ManipulationSolveInput): ManipulationSolveResult {\n const initialRotation = input.initialRotation ?? 0;\n const delta = input.rotationDelta ?? 0;\n if (!Number.isFinite(initialRotation) || !Number.isFinite(delta)) {\n throw new Error(\"Rotation values must be finite.\");\n }\n const proposedRotation = initialRotation + delta;\n const snap = input.rotate?.snap;\n const snapActive =\n snap !== undefined &&\n isSnapActive(snap.enabled, snap.when, input.modifiers);\n const appliedRotation = snapActive\n ? snapToLattice(proposedRotation, snap!.step, snap!.origin ?? 0)\n : proposedRotation;\n return result(\n input.initial,\n input.initial,\n snapActive,\n true,\n initialRotation,\n proposedRotation,\n appliedRotation,\n );\n}\n\nfunction resizeFromPoint(\n initial: PibblManipulationBox,\n handle: PibblResizePosition,\n delta: Readonly<{ x: number; y: number }>,\n): PibblManipulationBox {\n const movesLeft = handle.includes(\"left\");\n const movesRight = handle.includes(\"right\");\n const movesTop = handle.includes(\"top\");\n const movesBottom = handle.includes(\"bottom\");\n return freezeBox({\n left: movesLeft ? initial.left + delta.x : initial.left,\n top: movesTop ? initial.top + delta.y : initial.top,\n width:\n initial.width + (movesRight ? delta.x : 0) - (movesLeft ? delta.x : 0),\n height:\n initial.height + (movesBottom ? delta.y : 0) - (movesTop ? delta.y : 0),\n });\n}\n\nfunction resizeFromDimensions(\n initial: PibblManipulationBox,\n handle: PibblResizePosition,\n width: number,\n height: number,\n): PibblManipulationBox {\n return freezeBox({\n left: handle.includes(\"left\")\n ? initial.left + initial.width - width\n : initial.left,\n top: handle.includes(\"top\")\n ? initial.top + initial.height - height\n : initial.top,\n width,\n height,\n });\n}\n\nfunction snapResize(\n initial: PibblManipulationBox,\n proposed: PibblManipulationBox,\n handle: PibblResizePosition,\n snap: PibblManipulationResizeSizeSnap | PibblManipulationResizeGridSnap,\n): PibblManipulationBox {\n if (snap.target === \"grid\") {\n const [stepX, stepY] = gridSteps(snap);\n const origin = snap.origin;\n const movesLeft = handle.includes(\"left\");\n const movesTop = handle.includes(\"top\");\n const edgeX = movesLeft ? proposed.left : proposed.left + proposed.width;\n const edgeY = movesTop ? proposed.top : proposed.top + proposed.height;\n const snappedEdgeX = snapToLattice(edgeX, stepX, origin?.x ?? 0);\n const snappedEdgeY = snapToLattice(edgeY, stepY, origin?.y ?? 0);\n const width = !(handle.includes(\"left\") || handle.includes(\"right\"))\n ? initial.width\n : movesLeft\n ? initial.left + initial.width - snappedEdgeX\n : snappedEdgeX - initial.left;\n const height = !(handle.includes(\"top\") || handle.includes(\"bottom\"))\n ? initial.height\n : movesTop\n ? initial.top + initial.height - snappedEdgeY\n : snappedEdgeY - initial.top;\n return resizeFromDimensions(initial, handle, width, height);\n }\n const [stepWidth, stepHeight] = sizeSteps(snap);\n return resizeFromDimensions(\n proposed,\n handle,\n handle.includes(\"left\") || handle.includes(\"right\")\n ? snapToLattice(proposed.width, stepWidth)\n : proposed.width,\n handle.includes(\"top\") || handle.includes(\"bottom\")\n ? snapToLattice(proposed.height, stepHeight)\n : proposed.height,\n );\n}\n\nfunction moveSteps(snap: PibblManipulationMoveSnap): readonly [number, number] {\n return typeof snap.step === \"number\"\n ? [snap.step, snap.step]\n : [snap.step.x, snap.step.y];\n}\n\nfunction sizeSteps(\n snap: PibblManipulationResizeSizeSnap,\n): readonly [number, number] {\n return typeof snap.step === \"number\"\n ? [snap.step, snap.step]\n : [snap.step.width, snap.step.height];\n}\n\nfunction gridSteps(\n snap: PibblManipulationResizeGridSnap,\n): readonly [number, number] {\n return typeof snap.step === \"number\"\n ? [snap.step, snap.step]\n : [snap.step.x, snap.step.y];\n}\n\nfunction resolvedResizeConstraints(\n options: PibblManipulationResizeOptions | undefined,\n): {\n minWidth: number;\n minHeight: number;\n maxWidth: number;\n maxHeight: number;\n} {\n for (let nameIndex = 0; nameIndex < sizeConstraintNames.length; nameIndex++) {\n const name = sizeConstraintNames[nameIndex];\n const value = options?.[name];\n if (value !== undefined && (!Number.isFinite(value) || value <= 0))\n throw new Error(`${name} must be positive and finite.`);\n }\n const minWidth = options?.minWidth ?? 1;\n const minHeight = options?.minHeight ?? 1;\n const maxWidth = options?.maxWidth ?? Number.POSITIVE_INFINITY;\n const maxHeight = options?.maxHeight ?? Number.POSITIVE_INFINITY;\n for (const [name, value] of Object.entries({\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n })) {\n if (!Number.isFinite(value) && value !== Number.POSITIVE_INFINITY) {\n throw new Error(`${name} must be finite, received ${value}`);\n }\n }\n if (minWidth <= 0 || minHeight <= 0 || maxWidth <= 0 || maxHeight <= 0) {\n throw new Error(\"Resize constraints must be greater than zero.\");\n }\n if (minWidth > maxWidth || minHeight > maxHeight) {\n throw new Error(\n \"Resize minimum dimensions must not exceed maximum dimensions.\",\n );\n }\n return { minWidth, minHeight, maxWidth, maxHeight };\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value));\n}\n\nfunction clampMoveToBounds(\n box: PibblManipulationBox,\n bounds: PibblManipulationBox | undefined,\n rotation = 0,\n): PibblManipulationBox {\n if (!bounds) return box;\n assertFiniteBox(bounds, \"move.bounds\");\n const corners = rotatedCorners(box, rotation);\n const minX = Math.min(...corners.map((point) => point.x));\n const maxX = Math.max(...corners.map((point) => point.x));\n const minY = Math.min(...corners.map((point) => point.y));\n const maxY = Math.max(...corners.map((point) => point.y));\n if (maxX - minX > bounds.width || maxY - minY > bounds.height)\n throw new Error(\"Move bounds cannot contain the initial box.\");\n return freezeBox({\n ...box,\n left:\n box.left +\n clamp(0, bounds.left - minX, bounds.left + bounds.width - maxX),\n top:\n box.top + clamp(0, bounds.top - minY, bounds.top + bounds.height - maxY),\n });\n}\n\nfunction activeRatio(\n initial: PibblManipulationBox,\n options: PibblManipulationResizeOptions | undefined,\n modifiers: ManipulationSolveInput[\"modifiers\"],\n): number | undefined {\n const aspect = options?.aspectRatio;\n if (!aspect) return undefined;\n const ratio =\n aspect.value === \"initial\" ? initial.width / initial.height : aspect.value;\n if (!Number.isFinite(ratio) || ratio <= 0)\n throw new Error(\n \"Resize aspect ratio must be finite and greater than zero.\",\n );\n return isSnapActive(true, aspect.when, modifiers) ? ratio : undefined;\n}\n\nfunction rotateInverse(\n point: Readonly<{ x: number; y: number }>,\n radians: number,\n): Readonly<{ x: number; y: number }> {\n const cosine = Math.cos(radians);\n const sine = Math.sin(radians);\n return {\n x: point.x * cosine + point.y * sine,\n y: -point.x * sine + point.y * cosine,\n };\n}\n\nfunction resizeFromDimensionsRotated(\n initial: PibblManipulationBox,\n handle: PibblResizePosition,\n width: number,\n height: number,\n radians: number,\n): PibblManipulationBox {\n const oldCenter = {\n x: initial.left + initial.width / 2,\n y: initial.top + initial.height / 2,\n };\n const opposite = {\n x: handle.includes(\"left\")\n ? initial.width / 2\n : handle.includes(\"right\")\n ? -initial.width / 2\n : 0,\n y: handle.includes(\"top\")\n ? initial.height / 2\n : handle.includes(\"bottom\")\n ? -initial.height / 2\n : 0,\n };\n const cosine = Math.cos(radians);\n const sine = Math.sin(radians);\n const anchor = {\n x: oldCenter.x + opposite.x * cosine - opposite.y * sine,\n y: oldCenter.y + opposite.x * sine + opposite.y * cosine,\n };\n const nextOpposite = {\n x: handle.includes(\"left\")\n ? width / 2\n : handle.includes(\"right\")\n ? -width / 2\n : 0,\n y: handle.includes(\"top\")\n ? height / 2\n : handle.includes(\"bottom\")\n ? -height / 2\n : 0,\n };\n const center = {\n x: anchor.x - (nextOpposite.x * cosine - nextOpposite.y * sine),\n y: anchor.y - (nextOpposite.x * sine + nextOpposite.y * cosine),\n };\n return freezeBox({\n left: center.x - width / 2,\n top: center.y - height / 2,\n width,\n height,\n });\n}\n\nfunction constrainDimensions(\n initial: PibblManipulationBox,\n handle: PibblResizePosition,\n proposed: SizePoint,\n rotation: number,\n bounds: PibblManipulationBox | undefined,\n ratio: number | undefined,\n constraints: ReturnType<typeof resolvedResizeConstraints>,\n): SizePoint {\n if (!Number.isFinite(proposed.width) || !Number.isFinite(proposed.height))\n throw new Error(\"Resize geometry exceeds finite coordinates.\");\n if (bounds) {\n assertFiniteBox(bounds, \"resize.bounds\");\n if (!containsRotated(bounds, initial, rotation))\n throw new Error(\"Resize bounds must contain the initial box.\");\n }\n if (ratio !== undefined) {\n let minimum = Math.max(constraints.minWidth, constraints.minHeight * ratio);\n let maximum = Math.min(constraints.maxWidth, constraints.maxHeight * ratio);\n for (const plane of bounds\n ? boundsPlanes(initial, handle, rotation, bounds)\n : []) {\n const slope = plane.a + plane.b / ratio;\n if (Math.abs(slope) < 1e-12) {\n if (plane.c < -1e-9)\n throw new Error(\"Resize bounds have no feasible ratio.\");\n } else if (slope > 0) maximum = Math.min(maximum, plane.c / slope);\n else minimum = Math.max(minimum, plane.c / slope);\n }\n if (minimum > maximum)\n throw new Error(\n \"Resize constraints cannot satisfy the aspect ratio and bounds.\",\n );\n const width = clamp(proposed.width, minimum, maximum);\n return { width, height: width / ratio };\n }\n if (bounds)\n return projectSizeToBounds(\n initial,\n handle,\n proposed,\n rotation,\n bounds,\n constraints,\n );\n return {\n width: clamp(proposed.width, constraints.minWidth, constraints.maxWidth),\n height: clamp(\n proposed.height,\n constraints.minHeight,\n constraints.maxHeight,\n ),\n };\n}\n\ntype SizePoint = Readonly<{ width: number; height: number }>;\ntype HalfPlane = Readonly<{ a: number; b: number; c: number }>;\n\nfunction projectSizeToBounds(\n initial: PibblManipulationBox,\n handle: PibblResizePosition,\n proposed: SizePoint,\n rotation: number,\n bounds: PibblManipulationBox,\n constraints: ReturnType<typeof resolvedResizeConstraints>,\n): SizePoint {\n const maximumWidth = Number.isFinite(constraints.maxWidth)\n ? constraints.maxWidth\n : Math.max(initial.width, bounds.width + bounds.height);\n const maximumHeight = Number.isFinite(constraints.maxHeight)\n ? constraints.maxHeight\n : Math.max(initial.height, bounds.width + bounds.height);\n let polygon: SizePoint[] = [\n { width: constraints.minWidth, height: constraints.minHeight },\n { width: maximumWidth, height: constraints.minHeight },\n { width: maximumWidth, height: maximumHeight },\n { width: constraints.minWidth, height: maximumHeight },\n ];\n const planes = boundsPlanes(initial, handle, rotation, bounds);\n for (const plane of planes) polygon = clipPolygon(polygon, plane);\n if (polygon.length === 0)\n throw new Error(\"Resize bounds have no feasible size region.\");\n return closestPointInPolygon(\n { width: proposed.width, height: proposed.height },\n polygon,\n );\n}\n\nfunction boundsPlanes(\n initial: PibblManipulationBox,\n handle: PibblResizePosition,\n rotation: number,\n bounds: PibblManipulationBox,\n): readonly HalfPlane[] {\n const zero = resizeFromDimensionsRotated(initial, handle, 0, 0, rotation);\n const unitWidth = resizeFromDimensionsRotated(\n initial,\n handle,\n 1,\n 0,\n rotation,\n );\n const unitHeight = resizeFromDimensionsRotated(\n initial,\n handle,\n 0,\n 1,\n rotation,\n );\n const planes: HalfPlane[] = [];\n const zeroCorners = rotatedCorners(zero, rotation);\n const widthCorners = rotatedCorners(unitWidth, rotation);\n const heightCorners = rotatedCorners(unitHeight, rotation);\n for (let index = 0; index < 4; index++) {\n for (let axis = 0; axis < 2; axis++) {\n const coordinate = axis === 0 ? \"x\" : \"y\";\n const lower = axis === 0 ? bounds.left : bounds.top;\n const upper = lower + (axis === 0 ? bounds.width : bounds.height);\n const constant = zeroCorners[index][coordinate];\n const a = widthCorners[index][coordinate] - constant;\n const b = heightCorners[index][coordinate] - constant;\n planes.push(\n { a, b, c: upper - constant },\n { a: -a, b: -b, c: constant - lower },\n );\n }\n }\n return planes;\n}\n\nfunction clipPolygon(\n points: readonly SizePoint[],\n plane: HalfPlane,\n): SizePoint[] {\n const output: SizePoint[] = [];\n for (let index = 0; index < points.length; index++) {\n const from = points[index];\n const to = points[(index + 1) % points.length];\n const fromValue = plane.a * from.width + plane.b * from.height - plane.c;\n const toValue = plane.a * to.width + plane.b * to.height - plane.c;\n if (fromValue <= 0) output.push(from);\n if (fromValue <= 0 !== toValue <= 0) {\n const t = fromValue / (fromValue - toValue);\n output.push({\n width: from.width + (to.width - from.width) * t,\n height: from.height + (to.height - from.height) * t,\n });\n }\n }\n return output;\n}\n\nfunction closestPointInPolygon(\n point: SizePoint,\n polygon: readonly SizePoint[],\n): SizePoint {\n const area = polygon.reduce((sum, candidate, index) => {\n const next = polygon[(index + 1) % polygon.length];\n return sum + candidate.width * next.height - next.width * candidate.height;\n }, 0);\n if (\n Math.abs(area) > 1e-12 &&\n polygon.every((candidate, index) => {\n const next = polygon[(index + 1) % polygon.length];\n return (\n (next.width - candidate.width) * (point.height - candidate.height) -\n (next.height - candidate.height) * (point.width - candidate.width) >=\n -1e-9\n );\n })\n )\n return point;\n let best = polygon[0];\n let distance = Number.POSITIVE_INFINITY;\n for (let index = 0; index < polygon.length; index++) {\n const from = polygon[index];\n const to = polygon[(index + 1) % polygon.length];\n const dx = to.width - from.width;\n const dy = to.height - from.height;\n const scale =\n dx === 0 && dy === 0\n ? 0\n : clamp(\n ((point.width - from.width) * dx +\n (point.height - from.height) * dy) /\n (dx * dx + dy * dy),\n 0,\n 1,\n );\n const candidate = {\n width: from.width + dx * scale,\n height: from.height + dy * scale,\n };\n const nextDistance =\n (candidate.width - point.width) ** 2 +\n (candidate.height - point.height) ** 2;\n if (\n nextDistance < distance ||\n (nextDistance === distance &&\n (candidate.width > best.width ||\n (candidate.width === best.width && candidate.height > best.height)))\n ) {\n best = candidate;\n distance = nextDistance;\n }\n }\n return best;\n}\n\nfunction containsRotated(\n bounds: PibblManipulationBox,\n box: PibblManipulationBox,\n radians: number,\n): boolean {\n return rotatedCorners(box, radians).every(\n (point) =>\n point.x >= bounds.left &&\n point.x <= bounds.left + bounds.width &&\n point.y >= bounds.top &&\n point.y <= bounds.top + bounds.height,\n );\n}\n\nfunction rotatedCorners(\n box: PibblManipulationBox,\n radians: number,\n): readonly Readonly<{ x: number; y: number }>[] {\n const center = { x: box.left + box.width / 2, y: box.top + box.height / 2 };\n const cosine = Math.cos(radians);\n const sine = Math.sin(radians);\n return [\n [-box.width / 2, -box.height / 2],\n [box.width / 2, -box.height / 2],\n [box.width / 2, box.height / 2],\n [-box.width / 2, box.height / 2],\n ].map(([x, y]) => ({\n x: center.x + x * cosine - y * sine,\n y: center.y + x * sine + y * cosine,\n }));\n}\n\nfunction validateConfiguredSnaps(input: ManipulationSolveInput): void {\n const check = (\n step: number | Readonly<Record<string, number>>,\n origin: Readonly<Record<string, number | undefined>> | undefined,\n label: string,\n ) => {\n for (const [name, value] of Object.entries(\n typeof step === \"number\" ? { value: step } : step,\n ))\n assertPositiveFiniteStep(value, `${label}.${name}`);\n for (const [name, value] of Object.entries(origin ?? {}))\n if (value !== undefined)\n assertFiniteOrigin(value, `${label}.origin.${name}`);\n };\n if (input.move?.snap)\n check(input.move.snap.step, input.move.snap.origin, \"move.snap.step\");\n if (input.resize?.snap)\n check(\n input.resize.snap.step,\n input.resize.snap.target === \"grid\"\n ? input.resize.snap.origin\n : undefined,\n \"resize.snap.step\",\n );\n if (input.rotate?.snap)\n check(\n input.rotate.snap.step,\n { value: input.rotate.snap.origin },\n \"rotate.snap.step\",\n );\n}\n\nfunction boxesEqual(\n left: PibblManipulationBox,\n right: PibblManipulationBox,\n): boolean {\n return (\n left.left === right.left &&\n left.top === right.top &&\n left.width === right.width &&\n left.height === right.height\n );\n}\n\nfunction result(\n proposed: PibblManipulationBox,\n applied: PibblManipulationBox,\n snapActive: boolean,\n snapSatisfied: boolean,\n initialRotation = 0,\n proposedRotation = initialRotation,\n appliedRotation = proposedRotation,\n): ManipulationSolveResult {\n assertFiniteBox(applied, \"applied\");\n if (!Number.isFinite(proposedRotation) || !Number.isFinite(appliedRotation))\n throw new Error(\"Rotation exceeds finite coordinates.\");\n return Object.freeze({\n proposed,\n applied,\n snapActive,\n snapSatisfied,\n proposedRotation,\n appliedRotation,\n });\n}\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB,mBAAmB,iBAAiB;AAC9D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAWP,MAAM,sBAAsB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEK,SAAS,kBACd,OACyB;AACzB,kBAAgB,MAAM,SAAS,SAAS;AACxC,oBAAkB,MAAM,cAAc,cAAc;AACpD,oBAAkB,MAAM,cAAc,cAAc;AACpD,0BAAwB,KAAK;AAC7B,MAAI,CAAC,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC7C,UAAM,IAAI,MAAM,iCAAiC;AAEnD,UAAQ,MAAM,WAAW;AAAA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B;AAEA,SAAS,OACP,UACA,SACA,YACA,eACA,kBAAkB,GAClB,mBAAmB,iBACnB,kBAAkB,kBACO;AACzB,kBAAgB,SAAS,SAAS;AAClC,MAAI,CAAC,OAAO,SAAS,gBAAgB,KAAK,CAAC,OAAO,SAAS,eAAe;AACxE,UAAM,IAAI,MAAM,sCAAsC;AACxD,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -99,6 +99,7 @@ function mountPibbl(canvas, element, config) {
99
99
  width: surface.snapshot?.logicalWidth ?? (surface.kind === "root" && surface.config.mode === "fixed" ? surface.config.width : surface.kind === "root" ? surface.display.width : canvas.width),
100
100
  height: surface.snapshot?.logicalHeight ?? (surface.kind === "root" && surface.config.mode === "fixed" ? surface.config.height : surface.kind === "root" ? surface.display.height : canvas.height)
101
101
  }),
102
+ rootLayoutDirection: "ltr",
102
103
  surface,
103
104
  optionalServices: /* @__PURE__ */ new Map(),
104
105
  backendDriver: config?.driver ?? CANVAS_2D_BACKEND