kritzel-stencil 0.0.126 → 0.0.127

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 (378) hide show
  1. package/dist/cjs/app-globals-V2Kpy_OQ.js +8 -0
  2. package/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -0
  3. package/dist/cjs/index-BacMQbNR.js +2555 -0
  4. package/dist/cjs/index-BacMQbNR.js.map +1 -0
  5. package/dist/cjs/index-C05uAr89.js +1591 -0
  6. package/dist/cjs/index-C05uAr89.js.map +1 -0
  7. package/dist/cjs/index.cjs.js +19 -0
  8. package/dist/cjs/index.cjs.js.map +1 -0
  9. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +2365 -0
  10. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -0
  11. package/dist/cjs/loader.cjs.js +16 -0
  12. package/dist/cjs/loader.cjs.js.map +1 -0
  13. package/dist/cjs/stencil.cjs.js +28 -0
  14. package/dist/cjs/stencil.cjs.js.map +1 -0
  15. package/dist/collection/classes/commands/add-object.command.js +14 -0
  16. package/dist/collection/classes/commands/add-object.command.js.map +1 -0
  17. package/dist/collection/classes/commands/add-selection-group.command.js +20 -0
  18. package/dist/collection/classes/commands/add-selection-group.command.js.map +1 -0
  19. package/dist/collection/classes/commands/base.command.js +15 -0
  20. package/dist/collection/classes/commands/base.command.js.map +1 -0
  21. package/dist/collection/classes/commands/batch.command.js +14 -0
  22. package/dist/collection/classes/commands/batch.command.js.map +1 -0
  23. package/dist/collection/classes/commands/move-selection-group.command.js +25 -0
  24. package/dist/collection/classes/commands/move-selection-group.command.js.map +1 -0
  25. package/dist/collection/classes/commands/remove-object.command.js +17 -0
  26. package/dist/collection/classes/commands/remove-object.command.js.map +1 -0
  27. package/dist/collection/classes/commands/remove-selection-group.command.js +18 -0
  28. package/dist/collection/classes/commands/remove-selection-group.command.js.map +1 -0
  29. package/dist/collection/classes/commands/resize-selection-group.command.js +18 -0
  30. package/dist/collection/classes/commands/resize-selection-group.command.js.map +1 -0
  31. package/dist/collection/classes/commands/rotate-selection-group.command.js +24 -0
  32. package/dist/collection/classes/commands/rotate-selection-group.command.js.map +1 -0
  33. package/dist/collection/classes/commands/update-object.command.js +29 -0
  34. package/dist/collection/classes/commands/update-object.command.js.map +1 -0
  35. package/dist/collection/classes/commands/update-viewport.command.js +23 -0
  36. package/dist/collection/classes/commands/update-viewport.command.js.map +1 -0
  37. package/dist/collection/classes/handlers/base.handler.js +7 -0
  38. package/dist/collection/classes/handlers/base.handler.js.map +1 -0
  39. package/dist/collection/classes/handlers/context-menu.handler.js +47 -0
  40. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -0
  41. package/dist/collection/classes/handlers/hover.handler.js +19 -0
  42. package/dist/collection/classes/handlers/hover.handler.js.map +1 -0
  43. package/dist/collection/classes/handlers/key.handler.js +81 -0
  44. package/dist/collection/classes/handlers/key.handler.js.map +1 -0
  45. package/dist/collection/classes/handlers/move.handler.js +84 -0
  46. package/dist/collection/classes/handlers/move.handler.js.map +1 -0
  47. package/dist/collection/classes/handlers/resize.handler.js +150 -0
  48. package/dist/collection/classes/handlers/resize.handler.js.map +1 -0
  49. package/dist/collection/classes/handlers/rotation.handler.js +102 -0
  50. package/dist/collection/classes/handlers/rotation.handler.js.map +1 -0
  51. package/dist/collection/classes/handlers/selection.handler.js +200 -0
  52. package/dist/collection/classes/handlers/selection.handler.js.map +1 -0
  53. package/dist/collection/classes/history.class.js +71 -0
  54. package/dist/collection/classes/history.class.js.map +1 -0
  55. package/dist/collection/classes/objects/base-object.class.js +204 -0
  56. package/dist/collection/classes/objects/base-object.class.js.map +1 -0
  57. package/dist/collection/classes/objects/custom-element.class.js +52 -0
  58. package/dist/collection/classes/objects/custom-element.class.js.map +1 -0
  59. package/dist/collection/classes/objects/image.class.js +53 -0
  60. package/dist/collection/classes/objects/image.class.js.map +1 -0
  61. package/dist/collection/classes/objects/path.class.js +268 -0
  62. package/dist/collection/classes/objects/path.class.js.map +1 -0
  63. package/dist/collection/classes/objects/selection-box.class.js +22 -0
  64. package/dist/collection/classes/objects/selection-box.class.js.map +1 -0
  65. package/dist/collection/classes/objects/selection-group.class.js +157 -0
  66. package/dist/collection/classes/objects/selection-group.class.js.map +1 -0
  67. package/dist/collection/classes/objects/text.class.js +141 -0
  68. package/dist/collection/classes/objects/text.class.js.map +1 -0
  69. package/dist/{stencil/icon-registry.class-Bw5YkOTi.js → collection/classes/registries/icon-registry.class.js} +2 -6
  70. package/dist/collection/classes/registries/icon-registry.class.js.map +1 -0
  71. package/dist/collection/classes/registries/tool.registry.js +18 -0
  72. package/dist/collection/classes/registries/tool.registry.js.map +1 -0
  73. package/dist/collection/classes/reviver.class.js +66 -0
  74. package/dist/collection/classes/reviver.class.js.map +1 -0
  75. package/dist/collection/classes/store.class.js +287 -0
  76. package/dist/collection/classes/store.class.js.map +1 -0
  77. package/dist/collection/classes/structures/circular-buffer.structure.js +46 -0
  78. package/dist/collection/classes/structures/circular-buffer.structure.js.map +1 -0
  79. package/dist/collection/classes/structures/octree.structure.js +111 -0
  80. package/dist/collection/classes/structures/octree.structure.js.map +1 -0
  81. package/dist/collection/classes/tools/base-tool.class.js +31 -0
  82. package/dist/collection/classes/tools/base-tool.class.js.map +1 -0
  83. package/dist/collection/classes/tools/brush-tool.class.js +116 -0
  84. package/dist/collection/classes/tools/brush-tool.class.js.map +1 -0
  85. package/dist/collection/classes/tools/eraser-tool.class.js +86 -0
  86. package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -0
  87. package/dist/collection/classes/tools/image-tool.class.js +88 -0
  88. package/dist/collection/classes/tools/image-tool.class.js.map +1 -0
  89. package/dist/collection/classes/tools/selection-tool.class.js +156 -0
  90. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -0
  91. package/dist/collection/classes/tools/text-tool.class.js +116 -0
  92. package/dist/collection/classes/tools/text-tool.class.js.map +1 -0
  93. package/dist/collection/classes/viewport.class.js +148 -0
  94. package/dist/collection/classes/viewport.class.js.map +1 -0
  95. package/dist/collection/collection-manifest.json +29 -0
  96. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.css +10 -0
  97. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +154 -0
  98. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js.map +1 -0
  99. package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +24 -0
  100. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +672 -0
  101. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -0
  102. package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +60 -0
  103. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +1287 -0
  104. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -0
  105. package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.css +44 -0
  106. package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js +100 -0
  107. package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js.map +1 -0
  108. package/dist/collection/components/shared/kritzel-color/kritzel-color.css +21 -0
  109. package/dist/collection/components/shared/kritzel-color/kritzel-color.js +108 -0
  110. package/dist/collection/components/shared/kritzel-color/kritzel-color.js.map +1 -0
  111. package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.css +46 -0
  112. package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +147 -0
  113. package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js.map +1 -0
  114. package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.css +53 -0
  115. package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js +215 -0
  116. package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js.map +1 -0
  117. package/dist/collection/components/shared/kritzel-font/kritzel-font.css +10 -0
  118. package/dist/collection/components/shared/kritzel-font/kritzel-font.js +92 -0
  119. package/dist/collection/components/shared/kritzel-font/kritzel-font.js.map +1 -0
  120. package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.css +48 -0
  121. package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +115 -0
  122. package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js.map +1 -0
  123. package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.css +30 -0
  124. package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +112 -0
  125. package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js.map +1 -0
  126. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.css +17 -0
  127. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js +94 -0
  128. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js.map +1 -0
  129. package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.css +28 -0
  130. package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +91 -0
  131. package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js.map +1 -0
  132. package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.css +17 -0
  133. package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +181 -0
  134. package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js.map +1 -0
  135. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.css +55 -0
  136. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +178 -0
  137. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -0
  138. package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.css +19 -0
  139. package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +136 -0
  140. package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js.map +1 -0
  141. package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.css +19 -0
  142. package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +116 -0
  143. package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js.map +1 -0
  144. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +124 -0
  145. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +268 -0
  146. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -0
  147. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.css +33 -0
  148. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +79 -0
  149. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js.map +1 -0
  150. package/dist/{stencil/default-text-tool.config-DvOZmpuR.js → collection/configs/default-brush-tool.config.js} +2 -38
  151. package/dist/collection/configs/default-brush-tool.config.js.map +1 -0
  152. package/dist/collection/configs/default-engine-state.js +58 -0
  153. package/dist/collection/configs/default-engine-state.js.map +1 -0
  154. package/dist/collection/configs/default-text-tool.config.js +32 -0
  155. package/dist/collection/configs/default-text-tool.config.js.map +1 -0
  156. package/dist/collection/constants/engine.constants.js +3 -0
  157. package/dist/collection/constants/engine.constants.js.map +1 -0
  158. package/dist/collection/enums/event-button.enum.js +7 -0
  159. package/dist/collection/enums/event-button.enum.js.map +1 -0
  160. package/dist/collection/enums/handle-type.enum.js +8 -0
  161. package/dist/collection/enums/handle-type.enum.js.map +1 -0
  162. package/dist/collection/helpers/class.helper.js +6 -0
  163. package/dist/collection/helpers/class.helper.js.map +1 -0
  164. package/dist/collection/helpers/devices.helper.js +6 -0
  165. package/dist/collection/helpers/devices.helper.js.map +1 -0
  166. package/dist/collection/helpers/event.helper.js +58 -0
  167. package/dist/collection/helpers/event.helper.js.map +1 -0
  168. package/dist/collection/helpers/geometry.helper.js +53 -0
  169. package/dist/collection/helpers/geometry.helper.js.map +1 -0
  170. package/dist/collection/helpers/html.helper.js +7 -0
  171. package/dist/collection/helpers/html.helper.js.map +1 -0
  172. package/dist/collection/helpers/keyboard.helper.js +31 -0
  173. package/dist/collection/helpers/keyboard.helper.js.map +1 -0
  174. package/dist/collection/helpers/math.helper.js +6 -0
  175. package/dist/collection/helpers/math.helper.js.map +1 -0
  176. package/dist/collection/helpers/object.helper.js +38 -0
  177. package/dist/collection/helpers/object.helper.js.map +1 -0
  178. package/dist/collection/index.js +21 -0
  179. package/dist/collection/index.js.map +1 -0
  180. package/dist/collection/interfaces/bounding-box.interface.js +2 -0
  181. package/dist/collection/interfaces/bounding-box.interface.js.map +1 -0
  182. package/dist/collection/interfaces/command.interface.js +2 -0
  183. package/dist/collection/interfaces/command.interface.js.map +1 -0
  184. package/dist/collection/interfaces/context-menu-item.interface.js +2 -0
  185. package/dist/collection/interfaces/context-menu-item.interface.js.map +1 -0
  186. package/dist/collection/interfaces/debug-info.interface.js +2 -0
  187. package/dist/collection/interfaces/debug-info.interface.js.map +1 -0
  188. package/dist/collection/interfaces/engine-state.interface.js +2 -0
  189. package/dist/collection/interfaces/engine-state.interface.js.map +1 -0
  190. package/dist/collection/interfaces/object.interface.js +2 -0
  191. package/dist/collection/interfaces/object.interface.js.map +1 -0
  192. package/dist/collection/interfaces/path-options.interface.js +2 -0
  193. package/dist/collection/interfaces/path-options.interface.js.map +1 -0
  194. package/dist/collection/interfaces/point.interface.js +2 -0
  195. package/dist/collection/interfaces/point.interface.js.map +1 -0
  196. package/dist/collection/interfaces/polygon.interface.js +2 -0
  197. package/dist/collection/interfaces/polygon.interface.js.map +1 -0
  198. package/dist/collection/interfaces/selection-state.interface.js +2 -0
  199. package/dist/collection/interfaces/selection-state.interface.js.map +1 -0
  200. package/dist/collection/interfaces/serializable.interface.js +2 -0
  201. package/dist/collection/interfaces/serializable.interface.js.map +1 -0
  202. package/dist/collection/interfaces/tool.interface.js +2 -0
  203. package/dist/collection/interfaces/tool.interface.js.map +1 -0
  204. package/dist/collection/interfaces/toolbar-control.interface.js +2 -0
  205. package/dist/collection/interfaces/toolbar-control.interface.js.map +1 -0
  206. package/dist/collection/types/state.types.js +2 -0
  207. package/dist/collection/types/state.types.js.map +1 -0
  208. package/dist/components/index.js +24 -0
  209. package/dist/components/index.js.map +1 -0
  210. package/dist/components/kritzel-brush-style.js +9 -0
  211. package/dist/components/kritzel-brush-style.js.map +1 -0
  212. package/dist/components/kritzel-color-palette.js +9 -0
  213. package/dist/components/kritzel-color-palette.js.map +1 -0
  214. package/dist/components/kritzel-color.js +9 -0
  215. package/dist/components/kritzel-color.js.map +1 -0
  216. package/dist/components/kritzel-context-menu.js +9 -0
  217. package/dist/components/kritzel-context-menu.js.map +1 -0
  218. package/dist/components/kritzel-control-brush-config.js +9 -0
  219. package/dist/components/kritzel-control-brush-config.js.map +1 -0
  220. package/dist/components/kritzel-control-text-config.js +9 -0
  221. package/dist/components/kritzel-control-text-config.js.map +1 -0
  222. package/dist/components/kritzel-controls.js +9 -0
  223. package/dist/components/kritzel-controls.js.map +1 -0
  224. package/dist/components/kritzel-cursor-trail.js +9 -0
  225. package/dist/components/kritzel-cursor-trail.js.map +1 -0
  226. package/dist/components/kritzel-dropdown.js +9 -0
  227. package/dist/components/kritzel-dropdown.js.map +1 -0
  228. package/dist/components/kritzel-editor.js +409 -0
  229. package/dist/components/kritzel-editor.js.map +1 -0
  230. package/dist/components/kritzel-engine.js +9 -0
  231. package/dist/components/kritzel-engine.js.map +1 -0
  232. package/dist/components/kritzel-font-family.js +9 -0
  233. package/dist/components/kritzel-font-family.js.map +1 -0
  234. package/dist/components/kritzel-font-size.js +9 -0
  235. package/dist/components/kritzel-font-size.js.map +1 -0
  236. package/dist/components/kritzel-font.js +9 -0
  237. package/dist/components/kritzel-font.js.map +1 -0
  238. package/dist/components/kritzel-icon.js +9 -0
  239. package/dist/components/kritzel-icon.js.map +1 -0
  240. package/dist/components/kritzel-stroke-size.js +9 -0
  241. package/dist/components/kritzel-stroke-size.js.map +1 -0
  242. package/dist/components/kritzel-tooltip.js +9 -0
  243. package/dist/components/kritzel-tooltip.js.map +1 -0
  244. package/dist/components/kritzel-utility-panel.js +9 -0
  245. package/dist/components/kritzel-utility-panel.js.map +1 -0
  246. package/dist/{stencil/kritzel-context-menu-B2p1_Ffh.js → components/p-2gNwfcSP.js} +39 -11
  247. package/dist/components/p-2gNwfcSP.js.map +1 -0
  248. package/dist/components/p-BOUCnklW.js +54 -0
  249. package/dist/components/p-BOUCnklW.js.map +1 -0
  250. package/dist/components/p-BhC-Et5I.js +102 -0
  251. package/dist/components/p-BhC-Et5I.js.map +1 -0
  252. package/dist/components/p-BkFzf8vg.js +111 -0
  253. package/dist/components/p-BkFzf8vg.js.map +1 -0
  254. package/dist/{stencil/kritzel-font-family.entry.js → components/p-BubFkS0u.js} +35 -11
  255. package/dist/components/p-BubFkS0u.js.map +1 -0
  256. package/dist/components/p-C9usqwb5.js +61 -0
  257. package/dist/components/p-C9usqwb5.js.map +1 -0
  258. package/dist/{stencil/kritzel-tooltip.entry.js → components/p-CmlcJ8Kw.js} +37 -14
  259. package/dist/components/p-CmlcJ8Kw.js.map +1 -0
  260. package/dist/components/p-CtiROna-.js +90 -0
  261. package/dist/components/p-CtiROna-.js.map +1 -0
  262. package/dist/components/p-CudOuOAW.js +2716 -0
  263. package/dist/components/p-CudOuOAW.js.map +1 -0
  264. package/dist/components/p-D5a8vnRF.js +52 -0
  265. package/dist/components/p-D5a8vnRF.js.map +1 -0
  266. package/dist/{stencil/event-button.enum-D8W6LE-c.js → components/p-D8W6LE-c.js} +2 -2
  267. package/dist/components/p-D8W6LE-c.js.map +1 -0
  268. package/dist/components/p-DJN0U8pI.js +1327 -0
  269. package/dist/components/p-DJN0U8pI.js.map +1 -0
  270. package/dist/{stencil/kritzel-color-palette.entry.js → components/p-DJc6_PyL.js} +37 -11
  271. package/dist/components/p-DJc6_PyL.js.map +1 -0
  272. package/dist/{stencil/kritzel-controls.entry.js → components/p-DSWoCkxm.js} +116 -16
  273. package/dist/components/p-DSWoCkxm.js.map +1 -0
  274. package/dist/components/p-DcvujuV_.js +54 -0
  275. package/dist/components/p-DcvujuV_.js.map +1 -0
  276. package/dist/{stencil/kritzel-color.entry.js → components/p-DfJEh7HZ.js} +29 -11
  277. package/dist/components/p-DfJEh7HZ.js.map +1 -0
  278. package/dist/components/p-Dp8hrISj.js +44 -0
  279. package/dist/components/p-Dp8hrISj.js.map +1 -0
  280. package/dist/{stencil/kritzel-cursor-trail.entry.js → components/p-EQo4-DJT.js} +30 -11
  281. package/dist/components/p-EQo4-DJT.js.map +1 -0
  282. package/dist/{stencil/kritzel-dropdown.entry.js → components/p-NZJPrwJV.js} +37 -11
  283. package/dist/components/p-NZJPrwJV.js.map +1 -0
  284. package/dist/{stencil/brush-tool.class-D1U3x9_Y.js → components/p-ljdIU3DL.js} +18 -51
  285. package/dist/components/p-ljdIU3DL.js.map +1 -0
  286. package/dist/esm/app-globals-DQuL1Twl.js +6 -0
  287. package/dist/esm/app-globals-DQuL1Twl.js.map +1 -0
  288. package/dist/esm/index-BGl8znzE.js +1564 -0
  289. package/dist/esm/index-BGl8znzE.js.map +1 -0
  290. package/dist/esm/index-D37FADaF.js +2531 -0
  291. package/dist/esm/index-D37FADaF.js.map +1 -0
  292. package/dist/esm/index.js +4 -0
  293. package/dist/esm/index.js.map +1 -0
  294. package/dist/esm/kritzel-brush-style_18.entry.js +2346 -0
  295. package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -0
  296. package/dist/esm/loader.js +14 -0
  297. package/dist/esm/loader.js.map +1 -0
  298. package/dist/esm/stencil.js +24 -0
  299. package/dist/esm/stencil.js.map +1 -0
  300. package/dist/index.cjs.js +1 -0
  301. package/dist/index.js +1 -0
  302. package/dist/stencil/index.esm.js +1 -16
  303. package/dist/stencil/index.esm.js.map +1 -1
  304. package/dist/stencil/loader.esm.js.map +1 -1
  305. package/dist/stencil/p-BGl8znzE.js +3 -0
  306. package/dist/stencil/p-BGl8znzE.js.map +1 -0
  307. package/dist/stencil/p-D37FADaF.js +2 -0
  308. package/dist/stencil/p-D37FADaF.js.map +1 -0
  309. package/dist/stencil/p-DQuL1Twl.js +2 -0
  310. package/dist/stencil/p-DQuL1Twl.js.map +1 -0
  311. package/dist/stencil/p-e6ac7fc6.entry.js +2 -0
  312. package/dist/stencil/p-e6ac7fc6.entry.js.map +1 -0
  313. package/dist/stencil/stencil.esm.js +1 -49
  314. package/dist/stencil/stencil.esm.js.map +1 -1
  315. package/dist/types/classes/objects/base-object.class.d.ts +1 -0
  316. package/dist/types/classes/objects/path.class.d.ts +1 -0
  317. package/dist/types/interfaces/object.interface.d.ts +1 -0
  318. package/package.json +62 -62
  319. package/dist/stencil/brush-tool.class-D1U3x9_Y.js.map +0 -1
  320. package/dist/stencil/default-text-tool.config-DvOZmpuR.js.map +0 -1
  321. package/dist/stencil/engine.constants-DsjjAmnl.js +0 -7
  322. package/dist/stencil/engine.constants-DsjjAmnl.js.map +0 -1
  323. package/dist/stencil/event-button.enum-D8W6LE-c.js.map +0 -1
  324. package/dist/stencil/icon-registry.class-Bw5YkOTi.js.map +0 -1
  325. package/dist/stencil/image-tool.class-uKAmXFSl.js +0 -1341
  326. package/dist/stencil/image-tool.class-uKAmXFSl.js.map +0 -1
  327. package/dist/stencil/index-Df69oUcb.js +0 -4334
  328. package/dist/stencil/index-Df69oUcb.js.map +0 -1
  329. package/dist/stencil/kritzel-brush-style.entry.esm.js.map +0 -1
  330. package/dist/stencil/kritzel-brush-style.entry.js +0 -31
  331. package/dist/stencil/kritzel-brush-style.entry.js.map +0 -1
  332. package/dist/stencil/kritzel-color-palette.entry.esm.js.map +0 -1
  333. package/dist/stencil/kritzel-color-palette.entry.js.map +0 -1
  334. package/dist/stencil/kritzel-color.entry.esm.js.map +0 -1
  335. package/dist/stencil/kritzel-color.entry.js.map +0 -1
  336. package/dist/stencil/kritzel-context-menu-B2p1_Ffh.js.map +0 -1
  337. package/dist/stencil/kritzel-context-menu-DPHV6MRm.js +0 -91
  338. package/dist/stencil/kritzel-context-menu-DPHV6MRm.js.map +0 -1
  339. package/dist/stencil/kritzel-context-menu.entry.esm.js.map +0 -1
  340. package/dist/stencil/kritzel-context-menu.entry.js +0 -5
  341. package/dist/stencil/kritzel-context-menu.entry.js.map +0 -1
  342. package/dist/stencil/kritzel-control-brush-config.entry.esm.js.map +0 -1
  343. package/dist/stencil/kritzel-control-brush-config.entry.js +0 -54
  344. package/dist/stencil/kritzel-control-brush-config.entry.js.map +0 -1
  345. package/dist/stencil/kritzel-control-text-config.entry.esm.js.map +0 -1
  346. package/dist/stencil/kritzel-control-text-config.entry.js +0 -42
  347. package/dist/stencil/kritzel-control-text-config.entry.js.map +0 -1
  348. package/dist/stencil/kritzel-controls.entry.esm.js.map +0 -1
  349. package/dist/stencil/kritzel-controls.entry.js.map +0 -1
  350. package/dist/stencil/kritzel-cursor-trail.entry.esm.js.map +0 -1
  351. package/dist/stencil/kritzel-cursor-trail.entry.js.map +0 -1
  352. package/dist/stencil/kritzel-dropdown.entry.esm.js.map +0 -1
  353. package/dist/stencil/kritzel-dropdown.entry.js.map +0 -1
  354. package/dist/stencil/kritzel-editor.entry.esm.js.map +0 -1
  355. package/dist/stencil/kritzel-editor.entry.js +0 -180
  356. package/dist/stencil/kritzel-editor.entry.js.map +0 -1
  357. package/dist/stencil/kritzel-engine.entry.esm.js.map +0 -1
  358. package/dist/stencil/kritzel-engine.entry.js +0 -1318
  359. package/dist/stencil/kritzel-engine.entry.js.map +0 -1
  360. package/dist/stencil/kritzel-font-family.entry.esm.js.map +0 -1
  361. package/dist/stencil/kritzel-font-family.entry.js.map +0 -1
  362. package/dist/stencil/kritzel-font-size.entry.esm.js.map +0 -1
  363. package/dist/stencil/kritzel-font-size.entry.js +0 -29
  364. package/dist/stencil/kritzel-font-size.entry.js.map +0 -1
  365. package/dist/stencil/kritzel-font.entry.esm.js.map +0 -1
  366. package/dist/stencil/kritzel-font.entry.js +0 -25
  367. package/dist/stencil/kritzel-font.entry.js.map +0 -1
  368. package/dist/stencil/kritzel-icon.entry.esm.js.map +0 -1
  369. package/dist/stencil/kritzel-icon.entry.js +0 -29
  370. package/dist/stencil/kritzel-icon.entry.js.map +0 -1
  371. package/dist/stencil/kritzel-stroke-size.entry.esm.js.map +0 -1
  372. package/dist/stencil/kritzel-stroke-size.entry.js +0 -28
  373. package/dist/stencil/kritzel-stroke-size.entry.js.map +0 -1
  374. package/dist/stencil/kritzel-tooltip.entry.esm.js.map +0 -1
  375. package/dist/stencil/kritzel-tooltip.entry.js.map +0 -1
  376. package/dist/stencil/kritzel-utility-panel.entry.esm.js.map +0 -1
  377. package/dist/stencil/kritzel-utility-panel.entry.js +0 -33
  378. package/dist/stencil/kritzel-utility-panel.entry.js.map +0 -1
@@ -0,0 +1,2346 @@
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-BGl8znzE.js';
2
+ import { K as KritzelBrushTool, a as KritzelTextTool, b as KritzelMouseButton, c as KritzelSelectionTool, D as DEFAULT_BRUSH_CONFIG, d as KritzelEraserTool, e as DEFAULT_TEXT_CONFIG, f as KritzelImageTool, g as KritzelEventHelper, h as KritzelBaseCommand, i as KritzelSelectionGroup, j as KrtizelSelectionBox, R as RemoveSelectionGroupCommand, k as RemoveObjectCommand, B as BatchCommand, A as AddObjectCommand, l as AddSelectionGroupCommand, m as KritzelToolRegistry, n as KritzelBaseHandler, o as KritzelBaseTool, p as KritzelKeyboardHelper } from './index-D37FADaF.js';
3
+
4
+ const kritzelBrushStyleCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box;width:100%}.brush-style-button{display:flex;justify-content:center;align-items:center;width:42px;height:32px;padding:0;border:none;outline:none;background:none;cursor:default;border-radius:0;color:var(--control-text-color);font-weight:bold;-webkit-tap-highlight-color:transparent}.font-style-button:not(:last-child){border-right:1px solid #333333}.font-style-button:hover{background-color:var(--control-hover-bg)}.font-style-button:active{background-color:var(--control-active-bg)}.font-style-button.selected,.font-style-button.selected:hover,.font-style-button.selected:active{background-color:var(--control-selected-bg);color:var(--control-selected-color)}";
5
+
6
+ const KritzelBrushStyle = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.typeChange = createEvent(this, "typeChange");
10
+ this.type = 'pen';
11
+ this.brushOptions = [
12
+ { value: 'pen', label: 'Pen' },
13
+ { value: 'highlighter', label: 'Highlighter' },
14
+ ];
15
+ }
16
+ handleDropdownValueChange(event) {
17
+ this.typeChange.emit(event.detail);
18
+ }
19
+ render() {
20
+ const dropdownOptions = this.brushOptions.map(option => ({
21
+ value: option.value,
22
+ label: option.label,
23
+ }));
24
+ return (h(Host, { key: 'd7af382fe6f613aa16a5146785990ad2faa17f60' }, h("kritzel-dropdown", { key: '6d6d330d415c210058834b2968774b3db2ab7fc4', options: dropdownOptions, value: this.type, onValueChanged: event => this.handleDropdownValueChange(event) }, h("button", { key: 'c9fb33795b8e25f68c1d2ae248dc82a6de29e199', class: "brush-style-button", slot: "prefix" }, h("kritzel-icon", { key: '975c95b545a1c27ae2984405ac298592eec9743d', name: this.type, size: 16 })))));
25
+ }
26
+ };
27
+ KritzelBrushStyle.style = kritzelBrushStyleCss;
28
+
29
+ const kritzelColorCss = ":host{display:flex}.checkerboard-bg{background:repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 8px 8px;position:relative;overflow:hidden}.color-circle{width:24px;height:24px;border-radius:50%;box-sizing:border-box;display:block}.color-circle.white{border:1px solid var(--kritzel-color-palette-circle-border-color, #dddcdc)}";
30
+
31
+ const KritzelColor = class {
32
+ constructor(hostRef) {
33
+ registerInstance(this, hostRef);
34
+ this.size = 24;
35
+ }
36
+ isLightColor(hexColor) {
37
+ if (!hexColor)
38
+ return false;
39
+ let r = 0, g = 0, b = 0;
40
+ let sanitizedHex = hexColor.startsWith('#') ? hexColor.slice(1) : hexColor;
41
+ if (sanitizedHex.length === 3) {
42
+ r = parseInt(sanitizedHex[0] + sanitizedHex[0], 16);
43
+ g = parseInt(sanitizedHex[1] + sanitizedHex[1], 16);
44
+ b = parseInt(sanitizedHex[2] + sanitizedHex[2], 16);
45
+ }
46
+ else if (sanitizedHex.length === 6) {
47
+ r = parseInt(sanitizedHex.substring(0, 2), 16);
48
+ g = parseInt(sanitizedHex.substring(2, 4), 16);
49
+ b = parseInt(sanitizedHex.substring(4, 6), 16);
50
+ }
51
+ else {
52
+ return false;
53
+ }
54
+ if (isNaN(r) || isNaN(g) || isNaN(b)) {
55
+ return false;
56
+ }
57
+ const luminance = 0.299 * r + 0.587 * g + 0.114 * b;
58
+ return luminance > 220;
59
+ }
60
+ render() {
61
+ const isColorVeryLight = this.isLightColor(this.value);
62
+ return (h(Host, { key: '8f8bb6c8c710bf6f3731b2be82c0857dd13913f1' }, h("div", { key: 'd28526ebcb418130ae8f608ea51c6c8dccffb906', class: "checkerboard-bg", style: {
63
+ width: `${this.size}px`,
64
+ height: `${this.size}px`,
65
+ borderRadius: '50%',
66
+ display: 'inline-block',
67
+ position: 'relative',
68
+ } }, h("div", { key: 'ec6a886f152dd4db4d4a3f86991f3b065ece1b45', class: {
69
+ 'color-circle': true,
70
+ 'white': isColorVeryLight,
71
+ }, style: {
72
+ backgroundColor: this.value,
73
+ width: `${this.size}px`,
74
+ height: `${this.size}px`,
75
+ borderRadius: '50%',
76
+ position: 'absolute',
77
+ top: '0',
78
+ left: '0',
79
+ display: 'inline-block',
80
+ } }))));
81
+ }
82
+ };
83
+ KritzelColor.style = kritzelColorCss;
84
+
85
+ const kritzelColorPaletteCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;width:100%;box-sizing:border-box}.color-grid{width:100%;display:grid;grid-template-columns:repeat(6, 32px);gap:8px;justify-items:center;overflow:hidden;height:40px;transition:height 0.1s ease-in-out}.color-grid.expanded{height:500px}.color-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box}.color-container:hover{background-color:var(--kritzel-color-palette-hover-background-color, #f0f0f0)}.color-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-color-palette-selected-background-color)}";
86
+
87
+ const KritzelColorPalette = class {
88
+ constructor(hostRef) {
89
+ registerInstance(this, hostRef);
90
+ this.colorChange = createEvent(this, "colorChange");
91
+ this.colors = [];
92
+ this.selectedColor = null;
93
+ this.isExpanded = false;
94
+ this.isOpaque = false;
95
+ }
96
+ handleColorClick(color) {
97
+ this.selectedColor = color;
98
+ this.colorChange.emit(color);
99
+ }
100
+ calculateHeight() {
101
+ const colorsPerRow = 6;
102
+ const rowHeight = 32;
103
+ const gap = 8;
104
+ const rowCount = Math.ceil(this.colors.length / colorsPerRow);
105
+ return `${rowCount * rowHeight + (rowCount - 1) * gap}px`;
106
+ }
107
+ render() {
108
+ const displayedColors = this.isExpanded ? this.colors : this.colors.slice(0, 6);
109
+ const expandedHeight = this.isExpanded ? this.calculateHeight() : '32px';
110
+ return (h(Host, { key: 'bae0e5b2c6444f4a447dbcb13bfd427b4f25ddb6' }, h("div", { key: '3020fe3b1eef1cafb8e1720716219464d11c0594', class: {
111
+ 'color-grid': true,
112
+ 'expanded': this.isExpanded,
113
+ }, style: {
114
+ height: expandedHeight
115
+ } }, displayedColors.map(color => (h("div", { class: {
116
+ 'color-container': true,
117
+ 'selected': this.selectedColor === color,
118
+ }, onClick: () => this.handleColorClick(color) }, h("kritzel-color", { value: color })))))));
119
+ }
120
+ };
121
+ KritzelColorPalette.style = kritzelColorPaletteCss;
122
+
123
+ const kritzelContextMenuCss = ":host{display:block}.menu-container{display:flex;flex-direction:column;background-color:var(--kritzel-context-menu-background-color, #ffffff);border-radius:var(--kritzel-context-menu-border-radius, 12px);box-shadow:var(--kritzel-context-menu-box-shadow, 0 1px 6px rgba(0, 0, 0, 0.12));border:var(--kritzel-context-menu-border, 1px solid #f0f0f0);padding:var(--kritzel-context-menu-padding,4px)}.menu-item{display:flex;align-items:center;gap:var(--kritzel-context-menu-item-gap, 8px);background:none;border:none;text-align:left;padding:var(--kritzel-context-menu-item-padding, 8px);border-radius:var(--kritzel-context-menu-item-border-radius, 12px);cursor:pointer;font-size:var(--kritzel-context-menu-item-font-size, 14px);color:var(--kritzel-context-menu-item-color, #333333);white-space:nowrap;-webkit-tap-highlight-color:transparent}.menu-item:not(.disabled):hover{background-color:var(--kritzel-context-menu-item-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.menu-item:not(.disabled):active{background-color:var(--kritzel-context-menu-item-active-background-color, hsl(0, 0%, 0%, 8.6%))}.menu-item.disabled{color:var(--kritzel-context-menu-item-disabled-color, #aaaaaa);cursor:default}.menu-item kritzel-icon{opacity:0.8;flex-shrink:0}.menu-item.disabled kritzel-icon{opacity:0.4}.label{flex-grow:1}";
124
+
125
+ const KritzelContextMenu = class {
126
+ constructor(hostRef) {
127
+ registerInstance(this, hostRef);
128
+ this.actionSelected = createEvent(this, "actionSelected");
129
+ this.disabledStates = new Map();
130
+ this.visibleItems = [];
131
+ }
132
+ componentWillLoad() {
133
+ this.resolveVisibleItems();
134
+ this.resolveDisabledStates();
135
+ }
136
+ onItemsChanged() {
137
+ this.resolveVisibleItems();
138
+ this.resolveDisabledStates();
139
+ }
140
+ handleItemClick(item, index) {
141
+ if (!this.disabledStates.get(index)) {
142
+ this.actionSelected.emit(item);
143
+ }
144
+ }
145
+ async resolveVisibleItems() {
146
+ const visibleItems = [];
147
+ const visibilityPromises = this.items.map(async (item, index) => {
148
+ let isVisible = true;
149
+ if (item.visible !== undefined) {
150
+ if (typeof item.visible === 'boolean') {
151
+ isVisible = item.visible;
152
+ }
153
+ else if (typeof item.visible === 'function') {
154
+ const result = item.visible(null, this.objects);
155
+ if (result instanceof Promise) {
156
+ isVisible = await result;
157
+ }
158
+ else {
159
+ isVisible = result;
160
+ }
161
+ }
162
+ }
163
+ return { item, index, isVisible };
164
+ });
165
+ const visibilityResults = await Promise.all(visibilityPromises);
166
+ visibilityResults.forEach(({ item, isVisible }) => {
167
+ if (isVisible) {
168
+ visibleItems.push(item);
169
+ }
170
+ });
171
+ this.visibleItems = visibleItems;
172
+ }
173
+ async resolveDisabledStates() {
174
+ const newStates = new Map();
175
+ const disabledPromises = this.visibleItems.map(async (item, index) => {
176
+ let isDisabled = false;
177
+ if (typeof item.disabled === 'boolean') {
178
+ isDisabled = item.disabled;
179
+ }
180
+ else if (typeof item.disabled === 'function') {
181
+ const result = item.disabled(null, this.objects);
182
+ if (result instanceof Promise) {
183
+ isDisabled = await result;
184
+ }
185
+ else {
186
+ isDisabled = result;
187
+ }
188
+ }
189
+ newStates.set(index, isDisabled);
190
+ });
191
+ await Promise.all(disabledPromises);
192
+ this.disabledStates = new Map(newStates);
193
+ }
194
+ render() {
195
+ return (h(Host, { key: 'cc1a338a7bf0d32764c2737f4f32774ccb22370a' }, h("div", { key: '4a83b9366332e42b506c3c876c00d77498a2b8b5', class: "menu-container" }, this.visibleItems.map((item, index) => {
196
+ var _a;
197
+ const isDisabled = (_a = this.disabledStates.get(index)) !== null && _a !== void 0 ? _a : false;
198
+ return (h("button", { key: `${item.label}-${index}`, class: { 'menu-item': true, 'disabled': isDisabled }, onClick: () => this.handleItemClick(item, index), onTouchStart: () => this.handleItemClick(item, index), disabled: isDisabled }, item.icon && h("kritzel-icon", { name: item.icon, size: 16 }), h("span", { class: "label" }, item.label)));
199
+ }))));
200
+ }
201
+ get hostElement() { return getElement(this); }
202
+ static get watchers() { return {
203
+ "items": ["onItemsChanged"]
204
+ }; }
205
+ };
206
+ KritzelContextMenu.style = kritzelContextMenuCss;
207
+
208
+ const kritzelControlBrushConfigCss = ":host{display:flex;flex-direction:column;width:100%}.expand-toggle{background:none;border:none;cursor:pointer;font-size:14px;line-height:1;padding:8px;color:var(--kritzel-color-palette-expand-toggle-color, #666666)}.expand-toggle:hover{color:var(--kritzel-color-palette-expand-toggle-hover-color, #333333)}";
209
+
210
+ const KritzelControlBrushConfig = class {
211
+ constructor(hostRef) {
212
+ registerInstance(this, hostRef);
213
+ this.toolChange = createEvent(this, "toolChange");
214
+ this.isExpanded = false;
215
+ this.palette = [];
216
+ }
217
+ handleToolChange(newTool) {
218
+ this.palette = newTool.palettes[newTool.type];
219
+ }
220
+ componentWillLoad() {
221
+ this.palette = this.tool.palettes[this.tool.type];
222
+ }
223
+ handleToggleExpand() {
224
+ this.isExpanded = !this.isExpanded;
225
+ }
226
+ handleTypeChange(event) {
227
+ this.palette = this.tool.palettes[event.detail];
228
+ this.tool.type = event.detail;
229
+ this.tool.color = this.palette[0];
230
+ this.toolChange.emit(this.tool);
231
+ }
232
+ handleColorChange(event) {
233
+ this.tool.color = event.detail;
234
+ this.toolChange.emit(this.tool);
235
+ }
236
+ handleSizeChange(event) {
237
+ this.tool.size = event.detail;
238
+ this.toolChange.emit(this.tool);
239
+ }
240
+ render() {
241
+ return (h(Host, { key: 'c200146a90a3dd72241e098eff555312fd3125a9' }, h("div", { key: '886492ec4c5e15954166c4a7569ba832d0e6eff8', style: {
242
+ display: 'flex',
243
+ flexDirection: 'row',
244
+ alignItems: 'center',
245
+ justifyContent: 'flex-start',
246
+ width: '100%',
247
+ gap: '8px',
248
+ } }, h("kritzel-brush-style", { key: '64e205189fbd740c01d4fd94c5098edae574d69b', type: this.tool.type, onTypeChange: event => this.handleTypeChange(event) }), h("button", { key: '4b2d0fbf4d485350223dbc27601e78ab37be8df5', class: "expand-toggle", onClick: () => this.handleToggleExpand(), title: this.isExpanded ? 'Collapse' : 'Expand', style: this.palette.length > 6 ? { visibillity: 'visible' } : { visibility: 'hidden' } }, h("kritzel-icon", { key: '35262e8456901d10c84437e578317287282cf690', name: this.isExpanded ? 'chevron-up' : 'chevron-down' }))), h("kritzel-color-palette", { key: '4f519179f419a3e3567d2db39d0d8f9f30d5a6a1', colors: this.palette, selectedColor: this.tool.color, isExpanded: this.isExpanded, isOpaque: true, onColorChange: color => this.handleColorChange(color) }), h("kritzel-stroke-size", { key: '05f05946c3ebd2707f1c41c236a2efca47cedbec', selectedSize: this.tool.size, onSizeChange: event => this.handleSizeChange(event) })));
249
+ }
250
+ static get watchers() { return {
251
+ "tool": ["handleToolChange"]
252
+ }; }
253
+ };
254
+ KritzelControlBrushConfig.style = kritzelControlBrushConfigCss;
255
+
256
+ const kritzelControlTextConfigCss = ":host{display:block;flex-direction:column;width:100%}.expand-toggle{background:none;border:none;cursor:pointer;font-size:14px;line-height:1;padding:8px;color:var(--kritzel-color-palette-expand-toggle-color, #666666)}.expand-toggle:hover{color:var(--kritzel-color-palette-expand-toggle-hover-color, #333333)}";
257
+
258
+ const KritzelControlTextConfig = class {
259
+ constructor(hostRef) {
260
+ registerInstance(this, hostRef);
261
+ this.toolChange = createEvent(this, "toolChange");
262
+ this.isExpanded = false;
263
+ }
264
+ handleToggleExpand() {
265
+ this.isExpanded = !this.isExpanded;
266
+ }
267
+ handleFamilyChange(event) {
268
+ this.tool.fontFamily = event.detail;
269
+ this.toolChange.emit(this.tool);
270
+ }
271
+ handleColorChange(event) {
272
+ this.tool.fontColor = event.detail;
273
+ this.toolChange.emit(this.tool);
274
+ }
275
+ handleSizeChange(event) {
276
+ this.tool.fontSize = event.detail;
277
+ this.toolChange.emit(this.tool);
278
+ }
279
+ render() {
280
+ return (h(Host, { key: '1c8463a1f6b7bcf81f3b58fc0064330c50d6ada9' }, h("div", { key: '69825e6c9be473dda3597c86d51dffff9a6418fd', style: {
281
+ display: 'flex',
282
+ flexDirection: 'row',
283
+ alignItems: 'center',
284
+ justifyContent: 'flex-start',
285
+ width: '100%',
286
+ gap: '8px',
287
+ } }, h("kritzel-font-family", { key: '56c947950e32989782512a2b00e3be0aaa12d77b', selectedFontFamily: this.tool.fontFamily, onFontFamilyChange: event => this.handleFamilyChange(event) }), h("button", { key: '83fdb5908340adc032a7abae9b4b678697e0cff8', class: "expand-toggle", onClick: () => this.handleToggleExpand(), title: this.isExpanded ? 'Collapse' : 'Expand' }, h("kritzel-icon", { key: '739c175fbc3c0c5c342f2983d0e47323bc5b56f4', name: this.isExpanded ? 'chevron-up' : 'chevron-down' }))), h("kritzel-color-palette", { key: '98251da71574b3487bf6ee46f7e4e95d133e1eea', colors: this.tool.palette, selectedColor: this.tool.fontColor, isExpanded: this.isExpanded, onColorChange: event => this.handleColorChange(event) }), h("kritzel-font-size", { key: '95c88611a6631a4db5d200aac57e7eeef2c195b8', selectedSize: this.tool.fontSize, fontFamily: this.tool.fontFamily, onSizeChange: event => this.handleSizeChange(event) })));
288
+ }
289
+ };
290
+ KritzelControlTextConfig.style = kritzelControlTextConfigCss;
291
+
292
+ class KritzelDevicesHelper {
293
+ static isTouchDevice() {
294
+ return window.matchMedia('(any-pointer: coarse)').matches;
295
+ }
296
+ }
297
+
298
+ const kritzelControlsCss = ":host{display:flex;flex-direction:column;user-select:none}.kritzel-controls{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:var(--kritzel-controls-gap, 8px);height:100%;padding:var(--kritzel-controls-padding, 8px);background-color:var(--kritzel-controls-background-color, #ffffff);border-radius:var(--kritzel-controls-border-radius, 16px);box-shadow:var(--kritzel-controls-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-controls-border, 1px solid #f0f0f0);z-index:10000;position:relative}.kritzel-control{display:flex;justify-content:center;align-items:center;color:var(--kritzel-controls-control-color, #000000);border-radius:var(--kritzel-controls-control-border-radius, 12px);padding:var(--kritzel-controls-control-padding, 8px);border:none;outline:none;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent;font-weight:bold}.kritzel-control:hover{background-color:var(--kritzel-controls-control-hover-background-color, hsl(0, 0%, 0%, 4.3%))}:host(.mobile) .kritzel-control:hover{background-color:unset}.kritzel-control:active{background-color:var(--kritzel-controls-control-active-background-color, hsl(0, 0%, 0%, 8.6%))}:host(.mobile) .kritzel-control:active{background-color:unset}.kritzel-control.selected,.kritzel-control.selected:hover,.kritzel-control.selected:active{background-color:var(--kritzel-controls-control-selected-background-color, #007AFF) !important;color:var(--kritzel-controls-control-selected-color, #ffffff) !important}.kritzel-divider{width:var(--kritzel-controls-divider-width, 1px);height:var(--kritzel-controls-divider-height, 24px);background-color:var(--kritzel-controls-divider-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-config-container{position:relative;display:flex;justify-content:center;align-items:center;width:40px;height:40px;box-sizing:border-box;-webkit-tap-highlight-color:transparent}.kritzel-config{display:flex;justify-content:center;align-items:center;cursor:pointer}.color-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #f0f0f0)}.font-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #f0f0f0)}.no-config{height:24px;width:24px;border-radius:50%;border:1px dashed gray}kritzel-tooltip{position:fixed;bottom:66px;left:50%;transform:translateX(-50%);z-index:10001}";
299
+
300
+ const KritzelControls = class {
301
+ constructor(hostRef) {
302
+ registerInstance(this, hostRef);
303
+ this.isControlsReady = createEvent(this, "isControlsReady");
304
+ this.controls = [];
305
+ this.activeControl = null;
306
+ this.isUtilityPanelVisible = true;
307
+ this.firstConfig = null;
308
+ this.isTooltipVisible = false;
309
+ this.isTouchDevice = KritzelDevicesHelper.isTouchDevice();
310
+ this.kritzelEngine = null;
311
+ }
312
+ async handleActiveToolChange(event) {
313
+ var _a;
314
+ this.activeControl = this.controls.find(control => control.tool === event.detail) || null;
315
+ await ((_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.setFocus());
316
+ }
317
+ handleClick(event) {
318
+ const element = event.target;
319
+ if (!this.kritzelEngine || element.closest('.kritzel-tooltip')) {
320
+ return;
321
+ }
322
+ this.isTooltipVisible = false;
323
+ this.kritzelEngine.enable();
324
+ }
325
+ async closeTooltip() {
326
+ var _a;
327
+ this.isTooltipVisible = false;
328
+ (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.enable();
329
+ }
330
+ get activeToolAsTextTool() {
331
+ var _a;
332
+ return (_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.tool;
333
+ }
334
+ get activeToolAsBrushTool() {
335
+ var _a;
336
+ return (_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.tool;
337
+ }
338
+ async componentWillLoad() {
339
+ await this.initializeEngine();
340
+ await this.initializeTools();
341
+ this.isControlsReady.emit();
342
+ }
343
+ async initializeEngine() {
344
+ await customElements.whenDefined('kritzel-engine');
345
+ this.kritzelEngine = this.host.parentElement.querySelector('kritzel-engine');
346
+ if (!this.kritzelEngine) {
347
+ throw new Error('kritzel-engine not found in parent element.');
348
+ }
349
+ }
350
+ async initializeTools() {
351
+ for (const c of this.controls) {
352
+ if (c.type === 'tool' && c.tool) {
353
+ c.tool = await this.kritzelEngine.registerTool(c.name, c.tool, c.config);
354
+ }
355
+ if (c.type === 'tool' && c.isDefault && c.tool) {
356
+ await this.kritzelEngine.changeActiveTool(c.tool);
357
+ this.activeControl = c;
358
+ }
359
+ if (c.type === 'config') {
360
+ if (this.firstConfig === null) {
361
+ this.firstConfig = c;
362
+ }
363
+ else {
364
+ console.warn('Only one config control is allowed. The first one will be used.');
365
+ }
366
+ }
367
+ }
368
+ }
369
+ async handleControlClick(control) {
370
+ this.activeControl = control;
371
+ if (this.activeControl.type === 'tool') {
372
+ await this.kritzelEngine.changeActiveTool(this.activeControl.tool);
373
+ }
374
+ }
375
+ handleConfigClick(event) {
376
+ event.stopPropagation();
377
+ this.isTooltipVisible = !this.isTooltipVisible;
378
+ this.kritzelEngine.disable();
379
+ }
380
+ async handleToolChange(event) {
381
+ this.activeControl = Object.assign(Object.assign({}, this.activeControl), { tool: event.detail });
382
+ await this.kritzelEngine.changeActiveTool(this.activeControl.tool);
383
+ }
384
+ render() {
385
+ var _a, _b;
386
+ const hasNoConfig = ((_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.config) === undefined || ((_b = this.activeControl) === null || _b === void 0 ? void 0 : _b.config) === null;
387
+ return (h(Host, { key: 'dfb17219cf1d27d86148bc918b8303d74244700c', class: {
388
+ mobile: this.isTouchDevice,
389
+ } }, this.isUtilityPanelVisible && (h("kritzel-utility-panel", { key: 'a5eb7c6b59a193ba0bdde53812882c355a7658d4', style: {
390
+ position: 'absolute',
391
+ bottom: '56px',
392
+ left: '12px',
393
+ }, onUndo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.undo(); }, onRedo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.redo(); }, onDelete: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.delete(); } })), h("div", { key: 'b51e49664bf6330f22fb07ef64116459ec3832b3', class: "kritzel-controls" }, this.controls.map(control => {
394
+ var _a, _b, _c, _d, _e, _f, _g, _h;
395
+ if (control.type === 'tool') {
396
+ return (h("button", { class: {
397
+ 'kritzel-control': true,
398
+ 'selected': ((_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.name) === (control === null || control === void 0 ? void 0 : control.name),
399
+ }, key: control.name, onClick: _event => { var _a; return (_a = this.handleControlClick) === null || _a === void 0 ? void 0 : _a.call(this, control); } }, h("kritzel-icon", { name: control.icon })));
400
+ }
401
+ if (control.type === 'divider') {
402
+ return h("div", { class: "kritzel-divider", key: control.name });
403
+ }
404
+ if (control.type === 'config' && control.name === ((_b = this.firstConfig) === null || _b === void 0 ? void 0 : _b.name) && this.activeControl) {
405
+ return (h("div", { class: "kritzel-config-container", key: control.name }, h("kritzel-tooltip", { isVisible: this.isTooltipVisible, anchorElement: (_c = this.host.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('.kritzel-config-container') }, h("div", { style: { width: '294px', height: '100%' } }, this.activeControl.name === 'brush' && (h("kritzel-control-brush-config", { tool: this.activeToolAsBrushTool, onToolChange: event => { var _a; return (_a = this.handleToolChange) === null || _a === void 0 ? void 0 : _a.call(this, event); } })), this.activeControl.name === 'text' && (h("kritzel-control-text-config", { tool: this.activeToolAsTextTool, onToolChange: event => { var _a; return (_a = this.handleToolChange) === null || _a === void 0 ? void 0 : _a.call(this, event); } })))), h("div", { class: "kritzel-config", onClick: event => { var _a; return (_a = this.handleConfigClick) === null || _a === void 0 ? void 0 : _a.call(this, event); }, style: {
406
+ cursor: this.activeControl.config ? 'pointer' : 'default',
407
+ pointerEvents: hasNoConfig ? 'none' : 'auto',
408
+ } }, this.activeControl.tool instanceof KritzelBrushTool && (h("div", { class: "color-container" }, h("kritzel-color", { value: (_d = this.activeToolAsBrushTool) === null || _d === void 0 ? void 0 : _d.color, size: (_e = this.activeToolAsBrushTool) === null || _e === void 0 ? void 0 : _e.size, style: {
409
+ borderRadius: '50%',
410
+ border: 'none',
411
+ } }))), this.activeControl.tool instanceof KritzelTextTool && (h("div", { class: "font-container" }, h("kritzel-font", { fontFamily: (_f = this.activeToolAsTextTool) === null || _f === void 0 ? void 0 : _f.fontFamily, size: (_g = this.activeToolAsTextTool) === null || _g === void 0 ? void 0 : _g.fontSize, color: (_h = this.activeToolAsTextTool) === null || _h === void 0 ? void 0 : _h.fontColor }))), hasNoConfig && h("div", { class: "no-config" }))));
412
+ }
413
+ }))));
414
+ }
415
+ static get assetsDirs() { return ["../assets"]; }
416
+ get host() { return getElement(this); }
417
+ };
418
+ KritzelControls.style = kritzelControlsCss;
419
+
420
+ const kritzelCursorTrailCss = ":host{display:block;position:fixed;top:0;left:0;width:100vw;height:100vh;pointer-events:none;z-index:9000}";
421
+
422
+ const KritzelCursorTrail = class {
423
+ constructor(hostRef) {
424
+ registerInstance(this, hostRef);
425
+ this.cursorTrailPoints = [];
426
+ this.isLeftButtonDown = false;
427
+ this.TRAIL_DURATION_MS = 100;
428
+ this.MAX_TRAIL_POINTS = 50;
429
+ }
430
+ componentDidLoad() {
431
+ this.trailCleanupIntervalId = window.setInterval(() => {
432
+ const now = Date.now();
433
+ const newTrailPoints = this.cursorTrailPoints.filter(p => now - p.timestamp < this.TRAIL_DURATION_MS);
434
+ if (newTrailPoints.length !== this.cursorTrailPoints.length) {
435
+ this.cursorTrailPoints = newTrailPoints;
436
+ }
437
+ }, 50);
438
+ }
439
+ disconnectedCallback() {
440
+ if (this.trailCleanupIntervalId) {
441
+ window.clearInterval(this.trailCleanupIntervalId);
442
+ }
443
+ }
444
+ handleMouseDown(ev) {
445
+ if (ev.pointerType === 'mouse') {
446
+ if (ev.button === KritzelMouseButton.Left) {
447
+ this.isLeftButtonDown = true;
448
+ this.cursorTrailPoints = [];
449
+ }
450
+ }
451
+ if (ev.pointerType === 'touch') {
452
+ if (this.store.state.pointers.size === 1) {
453
+ this.isLeftButtonDown = true;
454
+ this.cursorTrailPoints = [];
455
+ }
456
+ }
457
+ }
458
+ handlePointerMove(ev) {
459
+ if (!this.isLeftButtonDown) {
460
+ return;
461
+ }
462
+ const newPoint = { x: ev.clientX, y: ev.clientY, timestamp: Date.now() };
463
+ const updatedTrail = [newPoint, ...this.cursorTrailPoints];
464
+ if (updatedTrail.length > this.MAX_TRAIL_POINTS) {
465
+ this.cursorTrailPoints = updatedTrail.slice(0, this.MAX_TRAIL_POINTS);
466
+ }
467
+ else {
468
+ this.cursorTrailPoints = updatedTrail;
469
+ }
470
+ }
471
+ handlePointerUp(ev) {
472
+ if (ev.pointerType === 'mouse') {
473
+ if (ev.button === KritzelMouseButton.Left) {
474
+ this.isLeftButtonDown = false;
475
+ this.cursorTrailPoints = [];
476
+ }
477
+ }
478
+ if (ev.pointerType === 'touch') {
479
+ if (this.store.state.pointers.size === 0) {
480
+ this.isLeftButtonDown = false;
481
+ this.cursorTrailPoints = [];
482
+ }
483
+ }
484
+ }
485
+ render() {
486
+ return (h(Host, { key: '2bd830d9a7f97a9a7e96a5b6a40535fdaefb904d' }, this.cursorTrailPoints.length > 1 && (h("svg", { key: '3da6a2e65030721cbdb04fba78d15776cb8f281c', class: "cursor-trail-svg", xmlns: "http://www.w3.org/2000/svg", style: {
487
+ position: 'absolute',
488
+ left: '0',
489
+ top: '0',
490
+ width: '100%',
491
+ height: '100%',
492
+ pointerEvents: 'none',
493
+ opacity: 'var(--kritzel-cursor-trail-opacity, 0.6)',
494
+ zIndex: '9000',
495
+ } }, this.cursorTrailPoints.slice(1).map((point, index) => {
496
+ const prevPoint = this.cursorTrailPoints[index];
497
+ const now = Date.now();
498
+ const age = now - point.timestamp;
499
+ const progress = Math.max(0, Math.min(1, age / this.TRAIL_DURATION_MS));
500
+ if (progress >= 1)
501
+ return null;
502
+ const baseStrokeWidth = Math.max(2, 15 * (1 - progress));
503
+ return (h("line", { key: `trail-segment-${point.timestamp}`, x1: prevPoint.x.toString(), y1: prevPoint.y.toString(), x2: point.x.toString(), y2: point.y.toString(), stroke: "var(--kritzel-cursor-trail-color, rgb(228, 228, 228))", "stroke-width": baseStrokeWidth.toString(), "stroke-linecap": "round" }));
504
+ })))));
505
+ }
506
+ };
507
+ KritzelCursorTrail.style = kritzelCursorTrailCss;
508
+
509
+ const kritzelDropdownCss = ":host{display:inline-flex;vertical-align:middle;width:100%;}.dropdown-wrapper{display:flex;align-items:center;border:1px solid #333333;border-radius:var(--kritzel-controls-control-border-radius, 12px);overflow:hidden;height:32px;width:100%}.custom-select{padding:0 8px;padding-right:30px;height:100%;width:100%;box-sizing:border-box;border-radius:0;border:none;background-color:#fff;cursor:pointer;outline:none;font-size:inherit;color:var(--kritzel-controls-text-color, #333333);-webkit-tap-highlight-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"%23333333\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"6 9 12 15 18 9\"/></svg>');background-size:16px 16px;background-repeat:no-repeat;background-position:right 8px center}.custom-select.has-suffix-border{border-right:1px solid #333333}.custom-select.has-prefix-border{border-left:1px solid #333333}::slotted(*){height:100%;box-sizing:border-box}";
510
+
511
+ const KritzelDropdown = class {
512
+ constructor(hostRef) {
513
+ registerInstance(this, hostRef);
514
+ this.valueChanged = createEvent(this, "valueChanged");
515
+ this.options = [];
516
+ this.selectStyles = {};
517
+ this.hasSuffixContent = false;
518
+ this.hasPrefixContent = false;
519
+ this.handleSelectChange = (event) => {
520
+ const newValue = event.target.value;
521
+ if (this.internalValue !== newValue) {
522
+ this.internalValue = newValue;
523
+ this.valueChanged.emit(this.internalValue);
524
+ }
525
+ };
526
+ this.evaluateSuffixContent = () => {
527
+ if (this.suffixSlotElement) {
528
+ const newHasContent = this.suffixSlotElement.assignedNodes({ flatten: true }).length > 0;
529
+ if (this.hasSuffixContent !== newHasContent) {
530
+ this.hasSuffixContent = newHasContent;
531
+ }
532
+ }
533
+ else {
534
+ if (this.hasSuffixContent !== false) {
535
+ this.hasSuffixContent = false;
536
+ }
537
+ }
538
+ };
539
+ this.evaluatePrefixContent = () => {
540
+ if (this.prefixSlotElement) {
541
+ const newHasContent = this.prefixSlotElement.assignedNodes({ flatten: true }).length > 0;
542
+ if (this.hasPrefixContent !== newHasContent) {
543
+ this.hasPrefixContent = newHasContent;
544
+ }
545
+ }
546
+ else {
547
+ if (this.hasPrefixContent !== false) {
548
+ this.hasPrefixContent = false;
549
+ }
550
+ }
551
+ };
552
+ }
553
+ componentWillLoad() {
554
+ this.updateInternalValue(this.value, false);
555
+ this.evaluateSuffixContent();
556
+ this.evaluatePrefixContent();
557
+ }
558
+ externalValueChanged(newValue) {
559
+ if (newValue !== this.internalValue) {
560
+ this.updateInternalValue(newValue, false);
561
+ }
562
+ }
563
+ optionsChanged() {
564
+ this.updateInternalValue(this.internalValue, true);
565
+ }
566
+ updateInternalValue(proposedValue, emitChange) {
567
+ let finalValue = proposedValue;
568
+ if (this.options && this.options.length > 0) {
569
+ const isValidValue = this.options.some(opt => opt.value === finalValue);
570
+ if (!finalValue || !isValidValue) {
571
+ finalValue = this.options[0].value;
572
+ }
573
+ }
574
+ else {
575
+ finalValue = undefined;
576
+ }
577
+ if (this.internalValue !== finalValue) {
578
+ this.internalValue = finalValue;
579
+ if (emitChange || (proposedValue !== finalValue && proposedValue !== undefined)) {
580
+ this.valueChanged.emit(this.internalValue);
581
+ }
582
+ }
583
+ }
584
+ render() {
585
+ const selectClasses = {
586
+ 'custom-select': true,
587
+ 'has-suffix-border': this.hasSuffixContent,
588
+ 'has-prefix-border': this.hasPrefixContent,
589
+ };
590
+ return (h(Host, { key: '32c5f5a4f807c1e316c91b795c005b8d30ce6189' }, h("div", { key: 'b1cbeff18e688da4a2f7472be290b9527a619f07', class: "dropdown-wrapper" }, h("slot", { key: 'b3bbb7e21c6f5620cab41aa4b1c7206b6c75fd86', name: "prefix", ref: el => this.prefixSlotElement = el, onSlotchange: this.evaluatePrefixContent }), h("select", { key: '8b2dcdc125bee59cf29fce7c980b755e78d5816e', class: selectClasses, style: Object.assign(Object.assign({}, this.selectStyles), { width: this.width }), onInput: this.handleSelectChange }, this.options.map(option => (h("option", { value: option.value, style: option.style, selected: option.value === this.internalValue }, option.label)))), h("slot", { key: '8d83f0dea41ac959bf2392948efef33bb70d0154', name: "suffix", ref: el => this.suffixSlotElement = el, onSlotchange: this.evaluateSuffixContent }))));
591
+ }
592
+ static get watchers() { return {
593
+ "value": ["externalValueChanged"],
594
+ "options": ["optionsChanged"]
595
+ }; }
596
+ };
597
+ KritzelDropdown.style = kritzelDropdownCss;
598
+
599
+ class KritzelIconRegistry {
600
+ static register(name, svgContent) {
601
+ if (this.registry.has(name)) {
602
+ console.warn(`[IconRegistry] Icon "${name}" is already registered. It will be overwritten.`);
603
+ }
604
+ this.registry.set(name, svgContent);
605
+ }
606
+ static get(name) {
607
+ return this.registry.get(name);
608
+ }
609
+ static registerIcons(icons) {
610
+ for (const name in icons) {
611
+ if (Object.prototype.hasOwnProperty.call(icons, name)) {
612
+ this.register(name, icons[name]);
613
+ }
614
+ }
615
+ }
616
+ static has(name) {
617
+ return this.registry.has(name);
618
+ }
619
+ }
620
+ KritzelIconRegistry.registry = new Map();
621
+ KritzelIconRegistry.registerIcons({
622
+ 'cursor': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/></svg>',
623
+ 'pen': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/></svg>',
624
+ 'highlighter': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-highlighter-icon lucide-highlighter"><path d="m9 11-6 6v3h9l3-3"/><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/></svg>',
625
+ 'eraser': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>',
626
+ 'type': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 7 4 4 20 4 20 7"/><line x1="9" x2="15" y1="20" y2="20"/><line x1="12" x2="12" y1="4" y2="20"/></svg>',
627
+ 'image': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',
628
+ 'chevron-down': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>',
629
+ 'chevron-up': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>',
630
+ 'copy': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy-icon lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',
631
+ 'paste': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clipboard-paste-icon lucide-clipboard-paste"><path d="M11 14h10"/><path d="M16 4h2a2 2 0 0 1 2 2v1.344"/><path d="m17 18 4-4-4-4"/><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>',
632
+ 'cut': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-scissors-icon lucide-scissors"><circle cx="6" cy="6" r="3"/><path d="M8.12 8.12 12 12"/><path d="M20 4 8.12 15.88"/><circle cx="6" cy="18" r="3"/><path d="M14.8 14.8 20 20"/></svg>',
633
+ 'delete': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash2-icon lucide-trash-2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/></svg>',
634
+ 'bring-to-front': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-up-to-line-icon lucide-arrow-up-to-line"><path d="M5 3h14"/><path d="m18 13-6-6-6 6"/><path d="M12 7v14"/></svg>',
635
+ 'send-to-back': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-down-to-line-icon lucide-arrow-down-to-line"><path d="M12 17V3"/><path d="m6 11 6 6 6-6"/><path d="M19 21H5"/></svg>',
636
+ 'select-all': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-mouse-pointer-icon lucide-square-mouse-pointer"><path d="M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"/><path d="M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"/></svg>',
637
+ 'download': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-download-icon lucide-download"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>',
638
+ 'undo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-undo-icon lucide-undo"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>',
639
+ 'redo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-redo-icon lucide-redo"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"/></svg>'
640
+ });
641
+
642
+ const ABSOLUTE_SCALE_MAX = 1000;
643
+ const ABSOLUTE_SCALE_MIN = 0.0001;
644
+
645
+ const kritzelEditorCss = "kritzel-editor{display:flex;margin:0;position:relative;overflow:hidden;width:100%;height:100%;align-items:center;justify-content:center;touch-action:manipulation;user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}kritzel-controls{position:absolute;bottom:28px}";
646
+
647
+ const KritzelEditor = class {
648
+ constructor(hostRef) {
649
+ registerInstance(this, hostRef);
650
+ this.isReady = createEvent(this, "isReady");
651
+ this.scaleMax = ABSOLUTE_SCALE_MAX;
652
+ this.scaleMin = ABSOLUTE_SCALE_MIN;
653
+ this.controls = [
654
+ {
655
+ name: 'selection',
656
+ type: 'tool',
657
+ tool: KritzelSelectionTool,
658
+ icon: 'cursor',
659
+ },
660
+ {
661
+ name: 'brush',
662
+ type: 'tool',
663
+ tool: KritzelBrushTool,
664
+ icon: 'pen',
665
+ isDefault: true,
666
+ config: DEFAULT_BRUSH_CONFIG,
667
+ },
668
+ {
669
+ name: 'eraser',
670
+ type: 'tool',
671
+ tool: KritzelEraserTool,
672
+ icon: 'eraser',
673
+ },
674
+ {
675
+ name: 'text',
676
+ type: 'tool',
677
+ tool: KritzelTextTool,
678
+ icon: 'type',
679
+ config: DEFAULT_TEXT_CONFIG,
680
+ },
681
+ {
682
+ name: 'image',
683
+ type: 'tool',
684
+ tool: KritzelImageTool,
685
+ icon: 'image',
686
+ },
687
+ {
688
+ name: 'divider',
689
+ type: 'divider',
690
+ },
691
+ {
692
+ name: 'config',
693
+ type: 'config',
694
+ },
695
+ ];
696
+ this.globalContextMenuItems = [
697
+ {
698
+ label: 'Paste',
699
+ icon: 'paste',
700
+ disabled: async () => (await this.engineRef.getCopiedObjects()).length === 0,
701
+ action: menu => this.engineRef.paste(menu.x, menu.y),
702
+ },
703
+ { label: 'Select All', icon: 'select-all', action: () => this.selectAllObjectsInViewport() },
704
+ ];
705
+ this.objectContextMenuItems = [
706
+ {
707
+ label: 'Edit',
708
+ icon: 'pen',
709
+ visible: (_, objects) => objects.length === 1 && objects[0].isEditable,
710
+ action: (_, objects) => {
711
+ if (objects.length === 1) {
712
+ const object = objects[0];
713
+ if (object.isEditable) {
714
+ object.edit();
715
+ }
716
+ }
717
+ },
718
+ },
719
+ { label: 'Copy', icon: 'copy', action: () => this.engineRef.copy() },
720
+ {
721
+ label: 'Paste',
722
+ icon: 'paste',
723
+ disabled: async () => (await this.engineRef.getCopiedObjects()).length === 0,
724
+ action: (menu, _) => this.engineRef.paste(menu.x, menu.y),
725
+ },
726
+ { label: 'Delete', icon: 'delete', action: () => this.engineRef.delete() },
727
+ { label: 'Bring to Front', icon: 'bring-to-front', action: () => this.engineRef.bringToFront() },
728
+ { label: 'Send to Back', icon: 'send-to-back', action: () => this.engineRef.sendToBack() },
729
+ ];
730
+ this.customSvgIcons = {};
731
+ this.isControlsVisible = true;
732
+ this.isUtilityPanelVisible = true;
733
+ this.isEngineReady = false;
734
+ this.isControlsReady = false;
735
+ }
736
+ onIsEngineReady(newValue) {
737
+ if (newValue && this.isControlsReady) {
738
+ this.checkIsReady();
739
+ }
740
+ }
741
+ onIsControlsReady(newValue) {
742
+ if (newValue && this.isEngineReady) {
743
+ this.checkIsReady();
744
+ }
745
+ }
746
+ async getObjectById(id) {
747
+ return this.engineRef.getObjectById(id);
748
+ }
749
+ async addObject(object) {
750
+ return this.engineRef.addObject(object);
751
+ }
752
+ async updateObject(object, updatedProperties) {
753
+ return this.engineRef.updateObject(object, updatedProperties);
754
+ }
755
+ async removeObject(object) {
756
+ return this.engineRef.removeObject(object);
757
+ }
758
+ async getSelectedObjects() {
759
+ return this.engineRef.getSelectedObjects();
760
+ }
761
+ async selectObjects(objects) {
762
+ return this.engineRef.selectObjects(objects);
763
+ }
764
+ async selectAllObjectsInViewport() {
765
+ return this.engineRef.selectAllObjectsInViewport();
766
+ }
767
+ async clearSelection() {
768
+ this.engineRef.clearSelection();
769
+ }
770
+ async centerObjectInViewport(object) {
771
+ return this.engineRef.centerObjectInViewport(object);
772
+ }
773
+ handleTouchStart(event) {
774
+ if (event.cancelable) {
775
+ event.preventDefault();
776
+ }
777
+ }
778
+ handleKeyDown(event) {
779
+ var _a;
780
+ if (event.key === 'Escape') {
781
+ event.preventDefault();
782
+ (_a = this.controlsRef) === null || _a === void 0 ? void 0 : _a.closeTooltip();
783
+ }
784
+ }
785
+ componentDidLoad() {
786
+ this.registerCustomSvgIcons();
787
+ }
788
+ async checkIsReady() {
789
+ await customElements.whenDefined('kritzel-editor');
790
+ await customElements.whenDefined('kritzel-controls');
791
+ await customElements.whenDefined('kritzel-engine');
792
+ if (!this.isEngineReady || !this.isControlsReady) {
793
+ return;
794
+ }
795
+ this.isReady.emit(this.host);
796
+ }
797
+ registerCustomSvgIcons() {
798
+ for (const [name, svg] of Object.entries(this.customSvgIcons)) {
799
+ KritzelIconRegistry.register(name, svg);
800
+ }
801
+ }
802
+ render() {
803
+ return (h(Host, { key: 'ddfb1861cc7fe2acda822b9389c3a049fe626deb' }, h("kritzel-engine", { key: 'ccbf2c636bdf63630ac06e1e8d3239c79bb7e774', ref: el => (this.engineRef = el), onIsEngineReady: () => (this.isEngineReady = true), scaleMax: this.scaleMax, scaleMin: this.scaleMin, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems }), h("kritzel-controls", { key: 'a0111b00ecbcb18c615c7f12f005f0edfe363af8', ref: el => (this.controlsRef = el), controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, style: this.isControlsVisible ? { display: 'flex' } : { display: 'none' }, onIsControlsReady: () => (this.isControlsReady = true) })));
804
+ }
805
+ get host() { return getElement(this); }
806
+ static get watchers() { return {
807
+ "isEngineReady": ["onIsEngineReady"],
808
+ "isControlsReady": ["onIsControlsReady"]
809
+ }; }
810
+ };
811
+ KritzelEditor.style = kritzelEditorCss;
812
+
813
+ class KritzelViewport {
814
+ constructor(store, host) {
815
+ this.initialTouchDistance = 0;
816
+ this.startX = 0;
817
+ this.startY = 0;
818
+ this._store = store;
819
+ this._store.state.host = host;
820
+ this._store.state.viewportWidth = host.clientWidth;
821
+ this._store.state.viewportHeight = host.clientHeight;
822
+ this._store.state.startX = 0;
823
+ this._store.state.startY = 0;
824
+ this._store.state.translateX = 0;
825
+ this._store.state.translateY = 0;
826
+ }
827
+ handleResize() {
828
+ this._store.state.viewportWidth = this._store.state.host.clientWidth;
829
+ this._store.state.viewportHeight = this._store.state.host.clientHeight;
830
+ this._store.state.hasViewportChanged = true;
831
+ this._store.rerender();
832
+ }
833
+ handlePointerDown(event) {
834
+ if (event.pointerType === 'mouse') {
835
+ const adjustedClientX = event.clientX - this._store.offsetX;
836
+ const adjustedClientY = event.clientY - this._store.offsetY;
837
+ if (event.button === KritzelMouseButton.Right) {
838
+ this._store.state.isPanning = true;
839
+ this._store.state.startX = adjustedClientX;
840
+ this._store.state.startY = adjustedClientY;
841
+ }
842
+ }
843
+ if (event.pointerType === 'touch') {
844
+ const activePointers = Array.from(this._store.state.pointers.values());
845
+ if (activePointers.length === 2) {
846
+ this._store.state.currentPath = null;
847
+ this._store.state.isScaling = true;
848
+ const firstTouchX = activePointers[0].clientX - this._store.offsetX;
849
+ const firstTouchY = activePointers[0].clientY - this._store.offsetY;
850
+ const secondTouchX = activePointers[1].clientX - this._store.offsetX;
851
+ const secondTouchY = activePointers[1].clientY - this._store.offsetY;
852
+ this.initialTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
853
+ this.startX = (firstTouchX + secondTouchX) / 2;
854
+ this.startY = (firstTouchY + secondTouchY) / 2;
855
+ this._store.rerender();
856
+ }
857
+ }
858
+ }
859
+ handlePointerMove(event) {
860
+ if (event.pointerType === 'mouse') {
861
+ const hostRect = this._store.state.host.getBoundingClientRect();
862
+ const xRelativeToHost = event.clientX - hostRect.left;
863
+ const yRelativeToHost = event.clientY - hostRect.top;
864
+ this._store.state.pointerX = (xRelativeToHost - this._store.state.translateX) / this._store.state.scale;
865
+ this._store.state.pointerY = (yRelativeToHost - this._store.state.translateY) / this._store.state.scale;
866
+ if (this._store.state.isPanning) {
867
+ this._store.state.translateX -= this._store.state.startX - xRelativeToHost;
868
+ this._store.state.translateY -= this._store.state.startY - yRelativeToHost;
869
+ this._store.state.startX = xRelativeToHost;
870
+ this._store.state.startY = yRelativeToHost;
871
+ this._store.state.hasViewportChanged = true;
872
+ this._store.state.skipContextMenu = true;
873
+ this._store.rerender();
874
+ }
875
+ }
876
+ if (event.pointerType === 'touch') {
877
+ const hostRect = this._store.state.host.getBoundingClientRect();
878
+ const xRelativeToHost = event.clientX - hostRect.left;
879
+ const yRelativeToHost = event.clientY - hostRect.top;
880
+ this._store.state.pointerX = (xRelativeToHost - this._store.state.translateX) / this._store.state.scale;
881
+ this._store.state.pointerY = (yRelativeToHost - this._store.state.translateY) / this._store.state.scale;
882
+ const activePointers = Array.from(this._store.state.pointers.values());
883
+ if (activePointers.length === 2) {
884
+ const firstTouchX = activePointers[0].clientX - this._store.offsetX;
885
+ const firstTouchY = activePointers[0].clientY - this._store.offsetY;
886
+ const secondTouchX = activePointers[1].clientX - this._store.offsetX;
887
+ const secondTouchY = activePointers[1].clientY - this._store.offsetY;
888
+ const currentTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
889
+ const midpointX = (firstTouchX + secondTouchX) / 2;
890
+ const midpointY = (firstTouchY + secondTouchY) / 2;
891
+ const scaleRatio = currentTouchDistance / this.initialTouchDistance;
892
+ const newScale = this._store.state.scale * scaleRatio;
893
+ if (newScale > this._store.state.scaleMax || newScale < this._store.state.scaleMin) {
894
+ this._store.state.translateX += midpointX - this.startX;
895
+ this._store.state.translateY += midpointY - this.startY;
896
+ }
897
+ else {
898
+ const translateXAdjustment = (midpointX - this._store.state.translateX) * (scaleRatio - 1);
899
+ const translateYAdjustment = (midpointY - this._store.state.translateY) * (scaleRatio - 1);
900
+ this._store.state.translateX += midpointX - this.startX - translateXAdjustment;
901
+ this._store.state.translateY += midpointY - this.startY - translateYAdjustment;
902
+ this._store.state.scale = newScale;
903
+ this.initialTouchDistance = currentTouchDistance;
904
+ }
905
+ this.startX = midpointX;
906
+ this.startY = midpointY;
907
+ this._store.state.hasViewportChanged = true;
908
+ this._store.rerender();
909
+ }
910
+ }
911
+ }
912
+ handlePointerUp(event) {
913
+ if (event.pointerType === 'mouse') {
914
+ if (this._store.state.isPanning) {
915
+ this._store.state.isPanning = false;
916
+ this._store.rerender();
917
+ }
918
+ }
919
+ if (event.pointerType === 'touch') {
920
+ this._store.state.isScaling = false;
921
+ this._store.rerender();
922
+ }
923
+ }
924
+ handleWheel(event) {
925
+ event.preventDefault();
926
+ if (event.ctrlKey === true && KritzelEventHelper.isMainMouseWheel(event)) {
927
+ this.handleZoom(event);
928
+ }
929
+ if (!event.ctrlKey) {
930
+ this.handlePan(event);
931
+ }
932
+ }
933
+ handleZoom(event) {
934
+ const rect = this._store.state.host.getBoundingClientRect();
935
+ const xRelativeToHost = event.clientX - rect.left;
936
+ const yRelativeToHost = event.clientY - rect.top;
937
+ this._store.state.pointerX = (xRelativeToHost - this._store.state.translateX) / this._store.state.scale;
938
+ this._store.state.pointerY = (yRelativeToHost - this._store.state.translateY) / this._store.state.scale;
939
+ const delta = event.deltaY > 0 ? -this._store.state.scaleStep * this._store.state.scale : this._store.state.scaleStep * this._store.state.scale;
940
+ const newScale = Math.min(this._store.state.scaleMax, Math.max(this._store.state.scaleMin, this._store.state.scale + delta));
941
+ const scaleRatio = newScale / this._store.state.scale;
942
+ const translateXAdjustment = (xRelativeToHost - this._store.state.translateX) * (scaleRatio - 1);
943
+ const translateYAdjustment = (yRelativeToHost - this._store.state.translateY) * (scaleRatio - 1);
944
+ this._store.state.scale = newScale;
945
+ this._store.state.translateX -= translateXAdjustment;
946
+ this._store.state.translateY -= translateYAdjustment;
947
+ this._store.state.hasViewportChanged = true;
948
+ this._store.rerender();
949
+ }
950
+ handlePan(event) {
951
+ const panSpeed = 0.8;
952
+ this._store.state.translateX -= event.deltaX * panSpeed;
953
+ this._store.state.translateY -= event.deltaY * panSpeed;
954
+ this._store.state.hasViewportChanged = true;
955
+ this._store.rerender();
956
+ }
957
+ }
958
+
959
+ class UpdateViewportCommand extends KritzelBaseCommand {
960
+ constructor(store, initiator, previousViewport) {
961
+ super(store, initiator);
962
+ this.previousViewport = previousViewport;
963
+ this.currentViewport = {
964
+ scale: this._store.state.scale,
965
+ translateX: this._store.state.translateX,
966
+ translateY: this._store.state.translateY,
967
+ };
968
+ }
969
+ execute() {
970
+ this._store.state.scale = this.currentViewport.scale;
971
+ this._store.state.translateX = this.currentViewport.translateX;
972
+ this._store.state.translateY = this.currentViewport.translateY;
973
+ }
974
+ undo() {
975
+ this._store.state.scale = this.previousViewport.scale;
976
+ this._store.state.translateX = this.previousViewport.translateX;
977
+ this._store.state.translateY = this.previousViewport.translateY;
978
+ }
979
+ }
980
+
981
+ class KritzelCircularBuffer {
982
+ constructor(capacity) {
983
+ this.head = 0;
984
+ this.tail = 0;
985
+ this.size = 0;
986
+ this.capacity = capacity;
987
+ this.buffer = new Array(capacity).fill(null);
988
+ }
989
+ add(item) {
990
+ this.buffer[this.head] = item;
991
+ this.head = (this.head + 1) % this.capacity;
992
+ if (this.size < this.capacity) {
993
+ this.size++;
994
+ }
995
+ else {
996
+ this.tail = (this.tail + 1) % this.capacity;
997
+ }
998
+ }
999
+ pop() {
1000
+ if (this.size === 0) {
1001
+ return null;
1002
+ }
1003
+ this.head = (this.head - 1 + this.capacity) % this.capacity;
1004
+ const item = this.buffer[this.head];
1005
+ this.buffer[this.head] = null;
1006
+ this.size--;
1007
+ return item;
1008
+ }
1009
+ peek() {
1010
+ if (this.size === 0) {
1011
+ return null;
1012
+ }
1013
+ const lastIndex = (this.head - 1 + this.capacity) % this.capacity;
1014
+ return this.buffer[lastIndex];
1015
+ }
1016
+ isEmpty() {
1017
+ return this.size === 0;
1018
+ }
1019
+ clear() {
1020
+ this.buffer.fill(null);
1021
+ this.head = 0;
1022
+ this.tail = 0;
1023
+ this.size = 0;
1024
+ }
1025
+ }
1026
+
1027
+ class KritzelHistory {
1028
+ constructor(store) {
1029
+ this._store = store;
1030
+ this.undoStack = new KritzelCircularBuffer(this._store.state.historyBufferSize);
1031
+ this.redoStack = new KritzelCircularBuffer(this._store.state.historyBufferSize);
1032
+ this.previousViewport = {
1033
+ scale: this._store.state.scale,
1034
+ scaleStep: this._store.state.scaleStep,
1035
+ translateX: this._store.state.translateX,
1036
+ translateY: this._store.state.translateY,
1037
+ };
1038
+ }
1039
+ executeCommand(command) {
1040
+ if (this._store.state.hasViewportChanged) {
1041
+ this.addUpdateViewportCommand();
1042
+ }
1043
+ command.execute();
1044
+ if (this._store.state.debugInfo.logCommands)
1045
+ console.info('add', command);
1046
+ this.undoStack.add(command);
1047
+ if (this.redoStack.isEmpty() === false) {
1048
+ this.redoStack.clear();
1049
+ }
1050
+ this._store.rerender();
1051
+ }
1052
+ undo() {
1053
+ if (this._store.state.hasViewportChanged) {
1054
+ const command = new UpdateViewportCommand(this._store, this, this.previousViewport);
1055
+ command.undo();
1056
+ this._store.state.hasViewportChanged = false;
1057
+ this._store.rerender();
1058
+ return;
1059
+ }
1060
+ const command = this.undoStack.pop();
1061
+ if (command) {
1062
+ command.undo();
1063
+ if (this._store.state.debugInfo.logCommands)
1064
+ console.info('undo', command);
1065
+ this.redoStack.add(command);
1066
+ }
1067
+ this._store.rerender();
1068
+ }
1069
+ redo() {
1070
+ const command = this.redoStack.pop();
1071
+ if (command) {
1072
+ command.execute();
1073
+ if (this._store.state.debugInfo.logCommands)
1074
+ console.info('redo', command);
1075
+ this.undoStack.add(command);
1076
+ }
1077
+ this._store.rerender();
1078
+ }
1079
+ addUpdateViewportCommand() {
1080
+ const command = new UpdateViewportCommand(this._store, this, this.previousViewport);
1081
+ command.execute();
1082
+ this.undoStack.add(command);
1083
+ if (this.redoStack.isEmpty() === false) {
1084
+ this.redoStack.clear();
1085
+ }
1086
+ this._store.state.hasViewportChanged = false;
1087
+ this.previousViewport = {
1088
+ scale: this._store.state.scale,
1089
+ scaleStep: this._store.state.scaleStep,
1090
+ translateX: this._store.state.translateX,
1091
+ translateY: this._store.state.translateY,
1092
+ };
1093
+ }
1094
+ }
1095
+
1096
+ class KritzelOctree {
1097
+ constructor(bounds, capacity = 8) {
1098
+ this.objects = [];
1099
+ this.children = null;
1100
+ this.bounds = bounds;
1101
+ this.capacity = capacity;
1102
+ }
1103
+ insert(object) {
1104
+ if (!this.intersects(object.rotatedBoundingBox, this.bounds)) {
1105
+ return false;
1106
+ }
1107
+ if (this.objects.length < this.capacity && this.children === null) {
1108
+ this.objects.push(object);
1109
+ return true;
1110
+ }
1111
+ if (this.children === null) {
1112
+ this.subdivide();
1113
+ }
1114
+ for (const child of this.children) {
1115
+ if (child.insert(object)) {
1116
+ return true;
1117
+ }
1118
+ }
1119
+ return false;
1120
+ }
1121
+ update(object) {
1122
+ const index = this.objects.findIndex(o => o.id === object.id);
1123
+ if (index !== -1) {
1124
+ this.objects[index] = object;
1125
+ return true;
1126
+ }
1127
+ if (this.children !== null) {
1128
+ for (const child of this.children) {
1129
+ if (child.update(object)) {
1130
+ return true;
1131
+ }
1132
+ }
1133
+ }
1134
+ return false;
1135
+ }
1136
+ remove(predicate) {
1137
+ const index = this.objects.findIndex(o => predicate(o));
1138
+ if (index !== -1) {
1139
+ this.objects.splice(index, 1);
1140
+ }
1141
+ if (this.children !== null) {
1142
+ for (const child of this.children) {
1143
+ child.remove(predicate);
1144
+ }
1145
+ }
1146
+ }
1147
+ query(range) {
1148
+ const results = [];
1149
+ if (!this.intersects(range, this.bounds)) {
1150
+ return results;
1151
+ }
1152
+ for (const object of this.objects) {
1153
+ if (this.intersects(object.rotatedBoundingBox, range)) {
1154
+ results.push(object);
1155
+ }
1156
+ }
1157
+ if (this.children !== null) {
1158
+ for (const child of this.children) {
1159
+ results.push(...child.query(range));
1160
+ }
1161
+ }
1162
+ return results;
1163
+ }
1164
+ filter(predicate) {
1165
+ const results = this.objects.filter(o => predicate(o));
1166
+ if (this.children !== null) {
1167
+ for (const child of this.children) {
1168
+ results.push(...child.filter(predicate));
1169
+ }
1170
+ }
1171
+ return results;
1172
+ }
1173
+ allObjects() {
1174
+ const results = [...this.objects];
1175
+ if (this.children !== null) {
1176
+ for (const child of this.children) {
1177
+ results.push(...child.allObjects());
1178
+ }
1179
+ }
1180
+ return results;
1181
+ }
1182
+ subdivide() {
1183
+ const { x, y, z, width, height, depth } = this.bounds;
1184
+ const halfWidth = width / 2;
1185
+ const halfHeight = height / 2;
1186
+ const halfDepth = depth / 2;
1187
+ this.children = [
1188
+ new KritzelOctree({ x, y, z, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
1189
+ new KritzelOctree({ x: x + halfWidth, y, z, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
1190
+ new KritzelOctree({ x, y: y + halfHeight, z, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
1191
+ new KritzelOctree({ x: x + halfWidth, y: y + halfHeight, z, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
1192
+ new KritzelOctree({ x, y, z: z + halfDepth, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
1193
+ new KritzelOctree({ x: x + halfWidth, y, z: z + halfDepth, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
1194
+ new KritzelOctree({ x, y: y + halfHeight, z: z + halfDepth, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
1195
+ new KritzelOctree({ x: x + halfWidth, y: y + halfHeight, z: z + halfDepth, width: halfWidth, height: halfHeight, depth: halfDepth }, this.capacity),
1196
+ ];
1197
+ }
1198
+ intersects(a, b) {
1199
+ return !(a.x >= b.x + b.width || // a is completely to the right of b
1200
+ a.x + a.width <= b.x || // a is completely to the left of b
1201
+ a.y >= b.y + b.height || // a is completely below b
1202
+ a.y + a.height <= b.y // a is completely above b
1203
+ );
1204
+ }
1205
+ }
1206
+
1207
+ class UpdateObjectCommand extends KritzelBaseCommand {
1208
+ constructor(store, initiator, object, updatedProperties) {
1209
+ super(store, initiator);
1210
+ this.object = object;
1211
+ this.updatedProperties = updatedProperties;
1212
+ this.previousProperties = {};
1213
+ for (const key in updatedProperties) {
1214
+ if (updatedProperties.hasOwnProperty(key)) {
1215
+ this.previousProperties[key] = this.object[key];
1216
+ }
1217
+ }
1218
+ }
1219
+ execute() {
1220
+ for (const key in this.updatedProperties) {
1221
+ if (this.updatedProperties.hasOwnProperty(key)) {
1222
+ this.object[key] = this.updatedProperties[key];
1223
+ }
1224
+ }
1225
+ }
1226
+ undo() {
1227
+ for (const key in this.previousProperties) {
1228
+ if (this.previousProperties.hasOwnProperty(key)) {
1229
+ this.object[key] = this.previousProperties[key];
1230
+ }
1231
+ }
1232
+ }
1233
+ }
1234
+
1235
+ const DEFAULT_ENGINE_STATE = {
1236
+ activeTool: null,
1237
+ activeText: null,
1238
+ currentPath: null,
1239
+ copiedObjects: null,
1240
+ objectsOctree: null,
1241
+ selectionBox: null,
1242
+ selectionGroup: null,
1243
+ resizeHandleType: null,
1244
+ hasViewportChanged: false,
1245
+ isReady: false,
1246
+ isEnabled: true,
1247
+ isScaling: false,
1248
+ isPanning: false,
1249
+ isFocused: false,
1250
+ isSelecting: false,
1251
+ isResizing: false,
1252
+ isResizeHandleSelected: false,
1253
+ isRotating: false,
1254
+ isRotationHandleSelected: false,
1255
+ isDragging: false,
1256
+ isDrawing: false,
1257
+ isErasing: false,
1258
+ isWriting: false,
1259
+ isCtrlKeyPressed: false,
1260
+ isContextMenuVisible: false,
1261
+ contextMenuItems: [],
1262
+ contextMenuX: 0,
1263
+ contextMenuY: 0,
1264
+ skipContextMenu: false,
1265
+ debugInfo: {
1266
+ showObjectInfo: false,
1267
+ showViewportInfo: false,
1268
+ logCommands: false,
1269
+ },
1270
+ host: null,
1271
+ pointerX: 0,
1272
+ pointerY: 0,
1273
+ scale: 1,
1274
+ scaleMax: 1,
1275
+ scaleMin: 1,
1276
+ scaleStep: 0.05,
1277
+ startX: 0,
1278
+ startY: 0,
1279
+ translateX: 0,
1280
+ translateXMax: 400,
1281
+ translateXMin: 0,
1282
+ translateY: 0,
1283
+ translateYMax: 400,
1284
+ translateYMin: 0,
1285
+ viewportWidth: 0,
1286
+ viewportHeight: 0,
1287
+ historyBufferSize: 1000,
1288
+ longTouchTimeout: null,
1289
+ longTouchDelay: 300,
1290
+ pointers: new Map()
1291
+ };
1292
+
1293
+ class KritzelStore {
1294
+ get history() {
1295
+ return this._history;
1296
+ }
1297
+ get state() {
1298
+ return this._state;
1299
+ }
1300
+ get currentZIndex() {
1301
+ return this._state.objectsOctree.filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KrtizelSelectionBox)).length;
1302
+ }
1303
+ get allObjects() {
1304
+ return this._state.objectsOctree.allObjects();
1305
+ }
1306
+ get selectedObjects() {
1307
+ return this.allObjects.filter(o => !(o instanceof KritzelSelectionGroup)).filter(o => o.isSelected);
1308
+ }
1309
+ get offsetX() {
1310
+ return this._state.host.getBoundingClientRect().left;
1311
+ }
1312
+ get offsetY() {
1313
+ return this._state.host.getBoundingClientRect().top;
1314
+ }
1315
+ constructor(kritzelEngine) {
1316
+ this._listeners = new Map();
1317
+ this.objects = [];
1318
+ this._state = DEFAULT_ENGINE_STATE;
1319
+ this._kritzelEngine = kritzelEngine;
1320
+ this._history = new KritzelHistory(this);
1321
+ this._state.objectsOctree = new KritzelOctree({
1322
+ x: -Infinity,
1323
+ y: -Infinity,
1324
+ z: -Infinity,
1325
+ width: Infinity,
1326
+ height: Infinity,
1327
+ depth: Infinity,
1328
+ });
1329
+ }
1330
+ rerender() {
1331
+ const viewportBounds = {
1332
+ x: -this._state.translateX / this._state.scale,
1333
+ y: -this._state.translateY / this._state.scale,
1334
+ z: this._state.scale,
1335
+ width: this._state.viewportWidth / this._state.scale,
1336
+ height: this._state.viewportHeight / this._state.scale,
1337
+ depth: 100,
1338
+ };
1339
+ this.objects = this._state.objectsOctree.query(viewportBounds);
1340
+ if (this._kritzelEngine) {
1341
+ this._kritzelEngine.forceUpdate++;
1342
+ }
1343
+ }
1344
+ findObjectById(id) {
1345
+ for (const object of this.allObjects) {
1346
+ if (object.id === id) {
1347
+ return object;
1348
+ }
1349
+ }
1350
+ return null;
1351
+ }
1352
+ deselectAllObjects() {
1353
+ if (this._state.selectionGroup) {
1354
+ this._history.executeCommand(new RemoveSelectionGroupCommand(this, this));
1355
+ }
1356
+ }
1357
+ onStateChange(property, listener) {
1358
+ if (!this._listeners.has(property)) {
1359
+ this._listeners.set(property, new Set());
1360
+ }
1361
+ this._listeners.get(property).add(listener);
1362
+ }
1363
+ setState(property, value) {
1364
+ const oldValue = this._state[property];
1365
+ if (oldValue !== value) {
1366
+ this._state[property] = value;
1367
+ if (this._listeners.has(property)) {
1368
+ this._listeners.get(property).forEach(listener => listener(value, oldValue, String(property)));
1369
+ }
1370
+ }
1371
+ }
1372
+ delete() {
1373
+ if (!this.state.selectionGroup) {
1374
+ return;
1375
+ }
1376
+ const deleteSelectedObjectsCommand = this.state.selectionGroup.objects.map(obj => new RemoveObjectCommand(this, this.state.selectionGroup, obj));
1377
+ const removeSelectionGroupCommand = new RemoveSelectionGroupCommand(this, this.state.selectionGroup);
1378
+ const commands = [...deleteSelectedObjectsCommand, removeSelectionGroupCommand];
1379
+ this.history.executeCommand(new BatchCommand(this, this.state.selectionGroup, commands));
1380
+ }
1381
+ deleteObject(id, isHistoryUpdated = true) {
1382
+ const object = this.findObjectById(id);
1383
+ if (object) {
1384
+ if (isHistoryUpdated) {
1385
+ const removeObjectCommand = new RemoveObjectCommand(this, this, object);
1386
+ this.history.executeCommand(removeObjectCommand);
1387
+ }
1388
+ else {
1389
+ this._state.objectsOctree.remove(obj => obj.id === id);
1390
+ this.rerender();
1391
+ }
1392
+ }
1393
+ }
1394
+ copy() {
1395
+ this.state.copiedObjects = this.state.selectionGroup.copy();
1396
+ }
1397
+ paste(x, y) {
1398
+ this.state.copiedObjects.isSelected = true;
1399
+ const adjustedX = x !== undefined ? x : this.state.copiedObjects.translateX + 25;
1400
+ const adjustedY = y !== undefined ? y : this.state.copiedObjects.translateY + 25;
1401
+ this.state.copiedObjects.updatePosition(adjustedX, adjustedY);
1402
+ const commands = [];
1403
+ if (this.state.selectionGroup !== null) {
1404
+ commands.push(new RemoveSelectionGroupCommand(this, this.state.selectionGroup));
1405
+ }
1406
+ const addCopiedObjectsCommands = this.state.copiedObjects.objects.map(obj => new AddObjectCommand(this, this, obj));
1407
+ const addCopiedObjectsAsSelectionGroupCommand = new AddSelectionGroupCommand(this, this, this.state.copiedObjects);
1408
+ commands.push(...addCopiedObjectsCommands, addCopiedObjectsAsSelectionGroupCommand);
1409
+ this.history.executeCommand(new BatchCommand(this, this, commands));
1410
+ this.state.isSelecting = false;
1411
+ this.state.copiedObjects = this.state.selectionGroup.copy();
1412
+ this.setState('activeTool', KritzelToolRegistry.getTool('selection'));
1413
+ }
1414
+ bringForward(object) {
1415
+ const max = this.allObjects.length + 1;
1416
+ const objects = object ? [object] : this.state.selectionGroup.objects;
1417
+ const increaseZIndexCommands = objects.map(obj => {
1418
+ if (obj.zIndex === max) {
1419
+ return;
1420
+ }
1421
+ return new UpdateObjectCommand(this, this, obj, { zIndex: obj.zIndex + 1 });
1422
+ });
1423
+ this.history.executeCommand(new BatchCommand(this, this, increaseZIndexCommands));
1424
+ }
1425
+ sendBackward(object) {
1426
+ const min = 0;
1427
+ const objects = object ? [object] : this.state.selectionGroup.objects;
1428
+ const decreaseZIndexCommands = objects.map(obj => {
1429
+ if (obj.zIndex === min) {
1430
+ return;
1431
+ }
1432
+ return new UpdateObjectCommand(this, this, obj, { zIndex: obj.zIndex - 1 });
1433
+ });
1434
+ this.history.executeCommand(new BatchCommand(this, this, decreaseZIndexCommands));
1435
+ }
1436
+ bringToFront(object) {
1437
+ const max = Math.max(...this.allObjects.map(obj => obj.zIndex)) + 1;
1438
+ const objects = object ? [object] : this.state.selectionGroup.objects;
1439
+ const increaseZIndexCommands = objects.map(obj => {
1440
+ return new UpdateObjectCommand(this, this, obj, { zIndex: max });
1441
+ });
1442
+ this.history.executeCommand(new BatchCommand(this, this, increaseZIndexCommands));
1443
+ }
1444
+ sendToBack(object) {
1445
+ const min = Math.min(...this.allObjects.map(obj => obj.zIndex)) - 1;
1446
+ const objects = object ? [object] : this.state.selectionGroup.objects;
1447
+ const decreaseZIndexCommands = objects.map(obj => {
1448
+ return new UpdateObjectCommand(this, this, obj, { zIndex: min });
1449
+ });
1450
+ this.history.executeCommand(new BatchCommand(this, this, decreaseZIndexCommands));
1451
+ }
1452
+ selectObjects(objects) {
1453
+ if (objects.length === 0) {
1454
+ return;
1455
+ }
1456
+ const selectionGroup = KritzelSelectionGroup.create(this);
1457
+ objects.forEach(obj => {
1458
+ obj.isSelected = false;
1459
+ selectionGroup.addOrRemove(obj);
1460
+ });
1461
+ selectionGroup.isSelected = true;
1462
+ this.state.selectionGroup = selectionGroup;
1463
+ if (objects.length === 1) {
1464
+ selectionGroup.rotation = selectionGroup.objects[0].rotation;
1465
+ }
1466
+ this.history.executeCommand(new AddSelectionGroupCommand(this, this, selectionGroup));
1467
+ }
1468
+ selectAllObjectsInViewport() {
1469
+ const objectsInViewport = this._state.objectsOctree
1470
+ .query({
1471
+ x: -this._state.translateX / this._state.scale,
1472
+ y: -this._state.translateY / this._state.scale,
1473
+ z: this._state.scale,
1474
+ width: this._state.viewportWidth / this._state.scale,
1475
+ height: this._state.viewportHeight / this._state.scale,
1476
+ depth: 100,
1477
+ })
1478
+ .filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KrtizelSelectionBox) && !(o instanceof KritzelContextMenu));
1479
+ if (objectsInViewport.length > 0) {
1480
+ const selectionGroup = KritzelSelectionGroup.create(this);
1481
+ objectsInViewport.forEach(obj => {
1482
+ obj.isSelected = false;
1483
+ selectionGroup.addOrRemove(obj);
1484
+ });
1485
+ selectionGroup.isSelected = true;
1486
+ this.state.isSelecting = false;
1487
+ if (objectsInViewport.length === 1) {
1488
+ selectionGroup.rotation = selectionGroup.objects[0].rotation;
1489
+ }
1490
+ this.history.executeCommand(new AddSelectionGroupCommand(this, this, selectionGroup));
1491
+ this.setState('activeTool', KritzelToolRegistry.getTool('selection'));
1492
+ }
1493
+ }
1494
+ clearSelection() {
1495
+ const command = new RemoveSelectionGroupCommand(this, this.state.selectionGroup);
1496
+ this.history.executeCommand(command);
1497
+ this.state.selectionGroup = null;
1498
+ this.state.selectionBox = null;
1499
+ this.state.isSelecting = false;
1500
+ this.state.isResizeHandleSelected = false;
1501
+ this.state.isRotationHandleSelected = false;
1502
+ }
1503
+ resetActiveText() {
1504
+ if (this.state.activeText && this.state.activeText.value === ' ') {
1505
+ this.deleteObject(this.state.activeText.id, false);
1506
+ this.history.undoStack.pop();
1507
+ }
1508
+ this.state.activeText = null;
1509
+ }
1510
+ getObjectFromPointerEvent(event, selector = '.object') {
1511
+ var _a;
1512
+ const shadowRoot = (_a = this.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
1513
+ if (!shadowRoot)
1514
+ return null;
1515
+ const clientX = event.clientX;
1516
+ const clientY = event.clientY;
1517
+ const elementAtPoint = shadowRoot.elementFromPoint(clientX, clientY);
1518
+ if (!elementAtPoint)
1519
+ return null;
1520
+ const selectedObject = elementAtPoint.closest(selector);
1521
+ if (selectedObject) {
1522
+ return this.allObjects.find(object => selectedObject.id === object.id);
1523
+ }
1524
+ return null;
1525
+ }
1526
+ getObjectsFromPointerEvent(event, selector = '.object') {
1527
+ var _a;
1528
+ const shadowRoot = (_a = this.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
1529
+ if (!shadowRoot)
1530
+ return [];
1531
+ const clientX = event.clientX;
1532
+ const clientY = event.clientY;
1533
+ const elementsAtPoint = shadowRoot.elementsFromPoint(clientX, clientY);
1534
+ if (!elementsAtPoint || elementsAtPoint.length === 0)
1535
+ return [];
1536
+ const objectIds = new Set();
1537
+ elementsAtPoint.forEach(element => {
1538
+ const selectedObject = element.closest(selector);
1539
+ if (selectedObject && selectedObject.id) {
1540
+ objectIds.add(selectedObject.id);
1541
+ }
1542
+ });
1543
+ if (objectIds.size > 0) {
1544
+ return this.allObjects.filter(object => objectIds.has(object.id)).sort((a, b) => b.zIndex - a.zIndex);
1545
+ }
1546
+ return [];
1547
+ }
1548
+ getCanvasPoint(event) {
1549
+ if (!this.state.host) {
1550
+ return { x: 0, y: 0 };
1551
+ }
1552
+ // Get the position of the kritzel-engine host element relative to the viewport
1553
+ const hostRect = this.state.host.getBoundingClientRect();
1554
+ // 1. Make the pointer coordinates relative to the host element
1555
+ const xRelativeToHost = event.clientX - hostRect.left;
1556
+ const yRelativeToHost = event.clientY - hostRect.top;
1557
+ // 2. Reverse the translation applied to the #origin div
1558
+ const xWithoutTranslate = xRelativeToHost - this.state.translateX;
1559
+ const yWithoutTranslate = yRelativeToHost - this.state.translateY;
1560
+ // 3. Reverse the scaling to get the final world coordinates
1561
+ const worldX = xWithoutTranslate / this.state.scale;
1562
+ const worldY = yWithoutTranslate / this.state.scale;
1563
+ return { x: worldX, y: worldY };
1564
+ }
1565
+ }
1566
+
1567
+ class KritzelKeyHandler extends KritzelBaseHandler {
1568
+ constructor(store) {
1569
+ super(store);
1570
+ }
1571
+ handleKeyDown(event) {
1572
+ if (this._store.state.isFocused === false) {
1573
+ event.preventDefault();
1574
+ return;
1575
+ }
1576
+ this._store.state.isCtrlKeyPressed = event.ctrlKey;
1577
+ if (this._store.state.isCtrlKeyPressed) {
1578
+ event.preventDefault();
1579
+ }
1580
+ if (event.key === 'Escape' && this._store.state.selectionGroup) {
1581
+ this._store.clearSelection();
1582
+ }
1583
+ if (event.key === 'Delete' && this._store.state.selectionGroup) {
1584
+ this._store.delete();
1585
+ }
1586
+ if (event.key === 'z' && event.ctrlKey) {
1587
+ this._store.history.undo();
1588
+ }
1589
+ if (event.key === 'y' && event.ctrlKey) {
1590
+ this._store.history.redo();
1591
+ }
1592
+ if (event.key === 's' && event.ctrlKey) {
1593
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
1594
+ this._store.deselectAllObjects();
1595
+ }
1596
+ if (event.key === 'b' && event.ctrlKey) {
1597
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('brush'));
1598
+ this._store.deselectAllObjects();
1599
+ }
1600
+ if (event.key === 'e' && event.ctrlKey) {
1601
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('eraser'));
1602
+ this._store.deselectAllObjects();
1603
+ }
1604
+ if (event.key === 'i' && event.ctrlKey) {
1605
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('image'));
1606
+ this._store.deselectAllObjects();
1607
+ }
1608
+ if (event.key === 'x' && event.ctrlKey) {
1609
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));
1610
+ this._store.deselectAllObjects();
1611
+ }
1612
+ if (event.key === 'c' && event.ctrlKey && this._store.state.selectionGroup) {
1613
+ this._store.copy();
1614
+ this._store.rerender();
1615
+ }
1616
+ if (event.key === 'v' && event.ctrlKey && this._store.state.copiedObjects) {
1617
+ this._store.paste();
1618
+ }
1619
+ if (event.key === '+' && event.ctrlKey && this._store.state.selectionGroup) {
1620
+ this._store.bringForward();
1621
+ }
1622
+ if (event.key === '-' && event.ctrlKey && this._store.state.selectionGroup) {
1623
+ this._store.sendBackward();
1624
+ }
1625
+ if (event.key === '*' && event.shiftKey && this._store.state.selectionGroup) {
1626
+ this._store.bringToFront();
1627
+ }
1628
+ if (event.key === '_' && event.shiftKey && this._store.state.selectionGroup) {
1629
+ this._store.sendToBack();
1630
+ }
1631
+ if (event.key === 'a' && event.ctrlKey && this._store.state.activeText) {
1632
+ this._store.state.activeText.selectAll();
1633
+ }
1634
+ if (event.key === 'v' && event.ctrlKey && this._store.state.activeText) {
1635
+ this._store.state.activeText.insertFromClipboard();
1636
+ }
1637
+ }
1638
+ handleKeyUp(event) {
1639
+ if (this._store.state.isFocused === false) {
1640
+ return;
1641
+ }
1642
+ this._store.state.isCtrlKeyPressed = event.ctrlKey;
1643
+ }
1644
+ }
1645
+
1646
+ class KritzelContextMenuHandler extends KritzelBaseHandler {
1647
+ constructor(store, globalContextMenuItems, objectContextMenuItems) {
1648
+ super(store);
1649
+ this.globalContextMenuItems = [];
1650
+ this.objectContextMenuItems = [];
1651
+ this.globalContextMenuItems = globalContextMenuItems;
1652
+ this.objectContextMenuItems = objectContextMenuItems;
1653
+ }
1654
+ handleContextMenu(event) {
1655
+ if (this._store.state.skipContextMenu) {
1656
+ this._store.state.skipContextMenu = false;
1657
+ return;
1658
+ }
1659
+ const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
1660
+ if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup)) {
1661
+ this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
1662
+ this._store.state.selectionGroup.addOrRemove(selectedObject);
1663
+ this._store.state.selectionGroup.isSelected = true;
1664
+ this._store.state.selectionGroup.rotation = selectedObject.rotation;
1665
+ this._store.state.isSelecting = false;
1666
+ this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
1667
+ }
1668
+ this._store.state.contextMenuItems = this._store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
1669
+ let x = event.clientX - this._store.offsetX;
1670
+ let y = event.clientY - this._store.offsetY;
1671
+ const menuWidthEstimate = 150;
1672
+ const menuHeightEstimate = 200;
1673
+ const margin = 10;
1674
+ if (x + menuWidthEstimate > window.innerWidth - margin) {
1675
+ x = window.innerWidth - menuWidthEstimate - margin;
1676
+ }
1677
+ if (y + menuHeightEstimate > window.innerHeight - margin) {
1678
+ y = window.innerHeight - menuHeightEstimate - margin;
1679
+ }
1680
+ x = Math.max(margin, x);
1681
+ y = Math.max(margin, y);
1682
+ this._store.state.contextMenuX = x;
1683
+ this._store.state.contextMenuY = y;
1684
+ this._store.state.isContextMenuVisible = true;
1685
+ this._store.state.isEnabled = false;
1686
+ this._store.rerender();
1687
+ }
1688
+ }
1689
+
1690
+ class KritzelClassHelper {
1691
+ static isInstanceOf(object, className) {
1692
+ return object.__class__ === className;
1693
+ }
1694
+ }
1695
+
1696
+ const kritzelEngineCss = ":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}textarea{all:unset;box-sizing:border-box;outline:none !important;border:none !important;overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}";
1697
+
1698
+ const KritzelEngine = class {
1699
+ validateScaleMax(newValue) {
1700
+ if (newValue > ABSOLUTE_SCALE_MAX) {
1701
+ console.warn(`scaleMax cannot be greater than ${ABSOLUTE_SCALE_MAX}.`);
1702
+ this.scaleMax = ABSOLUTE_SCALE_MAX;
1703
+ this.store.state.scaleMax = this.scaleMax;
1704
+ }
1705
+ else {
1706
+ this.store.state.scaleMax = newValue;
1707
+ }
1708
+ }
1709
+ validateScaleMin(newValue) {
1710
+ if (newValue < ABSOLUTE_SCALE_MIN) {
1711
+ console.warn(`scaleMin cannot be less than ${ABSOLUTE_SCALE_MIN}.`);
1712
+ this.scaleMin = ABSOLUTE_SCALE_MIN;
1713
+ this.store.state.scaleMin = this.scaleMin;
1714
+ }
1715
+ else {
1716
+ this.store.state.scaleMin = newValue;
1717
+ }
1718
+ }
1719
+ get isSelecting() {
1720
+ return this.store.state.activeTool instanceof KritzelSelectionTool && this.store.state.isSelecting;
1721
+ }
1722
+ get isSelectionActive() {
1723
+ return this.store.state.activeTool instanceof KritzelSelectionTool && this.store.state.selectionGroup !== null;
1724
+ }
1725
+ constructor(hostRef) {
1726
+ registerInstance(this, hostRef);
1727
+ this.isEngineReady = createEvent(this, "isEngineReady");
1728
+ this.activeToolChange = createEvent(this, "activeToolChange");
1729
+ this.scaleMax = ABSOLUTE_SCALE_MAX;
1730
+ this.scaleMin = ABSOLUTE_SCALE_MIN;
1731
+ this.forceUpdate = 0;
1732
+ this.contextMenuElement = null;
1733
+ this.store = new KritzelStore(this);
1734
+ }
1735
+ componentWillLoad() {
1736
+ this.validateScaleMax(this.scaleMax);
1737
+ this.validateScaleMin(this.scaleMin);
1738
+ }
1739
+ componentDidLoad() {
1740
+ this.contextMenuHandler = new KritzelContextMenuHandler(this.store, this.globalContextMenuItems, this.objectContextMenuItems);
1741
+ this.keyHandler = new KritzelKeyHandler(this.store);
1742
+ this.viewport = new KritzelViewport(this.store, this.host);
1743
+ this._registerStateChangeListeners();
1744
+ if (this.store.state.isReady === false) {
1745
+ this.store.state.isReady = true;
1746
+ this.isEngineReady.emit();
1747
+ }
1748
+ }
1749
+ handleWheel(ev) {
1750
+ var _a, _b;
1751
+ if (this.store.state.isContextMenuVisible) {
1752
+ this.hideContextMenu();
1753
+ }
1754
+ this.viewport.handleWheel(ev);
1755
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleWheel(ev);
1756
+ }
1757
+ handlePointerDown(ev) {
1758
+ var _a, _b;
1759
+ if (KritzelEventHelper.isPointerEventOnContextMenu(ev) === false && this.store.state.isContextMenuVisible) {
1760
+ this.hideContextMenu();
1761
+ return;
1762
+ }
1763
+ if (this.store.state.isEnabled === false) {
1764
+ return;
1765
+ }
1766
+ KritzelEventHelper.onLongTouchPress(ev, (event) => {
1767
+ if (!(this.store.state.activeTool instanceof KritzelSelectionTool)) {
1768
+ return;
1769
+ }
1770
+ this.contextMenuHandler.handleContextMenu(event);
1771
+ });
1772
+ this.host.setPointerCapture(ev.pointerId);
1773
+ this.store.state.pointers.set(ev.pointerId, ev);
1774
+ this.viewport.handlePointerDown(ev);
1775
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerDown(ev);
1776
+ }
1777
+ handlePointerMove(ev) {
1778
+ var _a, _b;
1779
+ if (this.store.state.isEnabled === false) {
1780
+ return;
1781
+ }
1782
+ this.store.state.pointers.set(ev.pointerId, ev);
1783
+ this.viewport.handlePointerMove(ev);
1784
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerMove(ev);
1785
+ }
1786
+ handlePointerUp(ev) {
1787
+ var _a, _b;
1788
+ if (this.store.state.isEnabled === false) {
1789
+ return;
1790
+ }
1791
+ this.store.state.pointers.delete(ev.pointerId);
1792
+ this.host.releasePointerCapture(ev.pointerId);
1793
+ this.viewport.handlePointerUp(ev);
1794
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerUp(ev);
1795
+ }
1796
+ handlePointerCancel(ev) {
1797
+ var _a, _b;
1798
+ if (this.store.state.isEnabled === false) {
1799
+ return;
1800
+ }
1801
+ this.host.releasePointerCapture(ev.pointerId);
1802
+ this.store.state.pointers.delete(ev.pointerId);
1803
+ this.viewport.handlePointerUp(ev);
1804
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerUp(ev);
1805
+ }
1806
+ handleContextMenu(ev) {
1807
+ ev.preventDefault();
1808
+ if (this.store.state.isEnabled === false) {
1809
+ return;
1810
+ }
1811
+ if (ev.pointerType === 'touch') {
1812
+ return;
1813
+ }
1814
+ this.contextMenuHandler.handleContextMenu(ev);
1815
+ }
1816
+ handleResize() {
1817
+ this.viewport.handleResize();
1818
+ }
1819
+ handleKeyDown(ev) {
1820
+ this.keyHandler.handleKeyDown(ev);
1821
+ }
1822
+ handleKeyUp(ev) {
1823
+ this.keyHandler.handleKeyUp(ev);
1824
+ }
1825
+ updateFocus(ev) {
1826
+ const rect = this.store.state.host.getBoundingClientRect();
1827
+ const isInside = ev.clientX >= rect.left && ev.clientX <= rect.right && ev.clientY >= rect.top && ev.clientY <= rect.bottom;
1828
+ const path = ev.composedPath();
1829
+ const kritzelEngineElement = this.host.closest('kritzel-engine');
1830
+ const isInKritzelEngine = path.includes(kritzelEngineElement || this.host);
1831
+ this.store.setState('isFocused', isInside && isInKritzelEngine);
1832
+ }
1833
+ async registerTool(toolName, toolClass, toolConfig) {
1834
+ if (typeof toolClass !== 'function' || !(toolClass.prototype instanceof KritzelBaseTool)) {
1835
+ console.error(`Failed to register tool "${toolName}": Tool class must be a constructor function`);
1836
+ return null;
1837
+ }
1838
+ const registeredTool = KritzelToolRegistry.registerTool(toolName, toolClass, this.store);
1839
+ if (toolConfig) {
1840
+ Object.entries(toolConfig).forEach(([key, value]) => {
1841
+ registeredTool[key] = value;
1842
+ });
1843
+ }
1844
+ return Promise.resolve(registeredTool);
1845
+ }
1846
+ async changeActiveTool(tool) {
1847
+ var _a;
1848
+ (_a = this.store.state.activeTool) === null || _a === void 0 ? void 0 : _a.onDeactivate();
1849
+ this.store.setState('activeTool', tool);
1850
+ this.store.deselectAllObjects();
1851
+ tool === null || tool === void 0 ? void 0 : tool.onActivate();
1852
+ }
1853
+ async setFocus() {
1854
+ this.host.focus();
1855
+ this.store.state.isFocused = true;
1856
+ }
1857
+ async disable() {
1858
+ this.store.state.isEnabled = false;
1859
+ this.forceUpdate++;
1860
+ }
1861
+ async enable() {
1862
+ this.store.state.isEnabled = true;
1863
+ this.forceUpdate++;
1864
+ }
1865
+ async delete() {
1866
+ this.store.delete();
1867
+ }
1868
+ async copy() {
1869
+ this.store.copy();
1870
+ }
1871
+ async paste(x, y) {
1872
+ this.store.paste(x, y);
1873
+ }
1874
+ async bringForward(object) {
1875
+ this.store.bringForward(object);
1876
+ }
1877
+ async sendBackward(object) {
1878
+ this.store.sendBackward(object);
1879
+ }
1880
+ async bringToFront(object) {
1881
+ this.store.bringToFront(object);
1882
+ }
1883
+ async sendToBack(object) {
1884
+ this.store.sendToBack(object);
1885
+ }
1886
+ async undo() {
1887
+ this.store.history.undo();
1888
+ }
1889
+ async redo() {
1890
+ this.store.history.redo();
1891
+ }
1892
+ async hideContextMenu() {
1893
+ this.store.state.pointers.clear();
1894
+ this.store.state.isContextMenuVisible = false;
1895
+ this.store.state.selectionBox = null;
1896
+ this.store.state.isSelecting = false;
1897
+ }
1898
+ async getObjectById(id) {
1899
+ const object = this.store.objects.find(obj => obj.id === id);
1900
+ return object || null;
1901
+ }
1902
+ async addObject(object) {
1903
+ this.store.deselectAllObjects();
1904
+ object.id = object.generateId();
1905
+ object._store = this.store;
1906
+ object.scale = object.scale ? object.scale : this.store.state.scale;
1907
+ object.zIndex = this.store.currentZIndex;
1908
+ const command = new AddObjectCommand(this.store, this, object);
1909
+ this.store.history.executeCommand(command);
1910
+ return object;
1911
+ }
1912
+ async updateObject(object, updatedProperties) {
1913
+ this.store.deselectAllObjects();
1914
+ const command = new UpdateObjectCommand(this.store, this, object, updatedProperties);
1915
+ this.store.history.executeCommand(command);
1916
+ return object;
1917
+ }
1918
+ async removeObject(object) {
1919
+ this.store.deselectAllObjects();
1920
+ const command = new RemoveObjectCommand(this.store, this, object);
1921
+ this.store.history.executeCommand(command);
1922
+ return object;
1923
+ }
1924
+ async getSelectedObjects() {
1925
+ return this.store.state.selectionGroup ? this.store.state.selectionGroup.objects : [];
1926
+ }
1927
+ async selectObjects(objects) {
1928
+ var _a;
1929
+ (_a = this.store.state.activeTool) === null || _a === void 0 ? void 0 : _a.onDeactivate();
1930
+ this.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
1931
+ this.store.deselectAllObjects();
1932
+ this.store.selectObjects(objects);
1933
+ }
1934
+ async selectAllObjectsInViewport() {
1935
+ var _a;
1936
+ (_a = this.store.state.activeTool) === null || _a === void 0 ? void 0 : _a.onDeactivate();
1937
+ this.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
1938
+ this.store.deselectAllObjects();
1939
+ this.store.selectAllObjectsInViewport();
1940
+ }
1941
+ async clearSelection() {
1942
+ this.store.clearSelection();
1943
+ }
1944
+ async centerObjectInViewport(object) {
1945
+ object.centerInViewport();
1946
+ const command = new UpdateObjectCommand(this.store, this, object, object);
1947
+ this.store.history.executeCommand(command);
1948
+ return object;
1949
+ }
1950
+ async getCopiedObjects() {
1951
+ var _a;
1952
+ return ((_a = this.store.state.copiedObjects) === null || _a === void 0 ? void 0 : _a.objects) || [];
1953
+ }
1954
+ _registerStateChangeListeners() {
1955
+ this.store.onStateChange('activeTool', this._handleActiveToolChange.bind(this));
1956
+ this.store.onStateChange('isFocused', this._handleIsFocusedChange.bind(this));
1957
+ }
1958
+ _handleActiveToolChange(activeTool) {
1959
+ if (!(activeTool instanceof KritzelSelectionTool)) {
1960
+ this.store.clearSelection();
1961
+ }
1962
+ this.store.state.skipContextMenu = false;
1963
+ this.activeToolChange.emit(activeTool);
1964
+ KritzelKeyboardHelper.forceHideKeyboard();
1965
+ }
1966
+ _handleIsFocusedChange(isFocused) {
1967
+ if (!isFocused) {
1968
+ this.store.resetActiveText();
1969
+ }
1970
+ }
1971
+ render() {
1972
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
1973
+ const computedStyle = window.getComputedStyle(this.host);
1974
+ const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
1975
+ const baseHandleSize = parseFloat(baseHandleSizePx);
1976
+ const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
1977
+ return (h(Host, { key: '9662d9be6c5537340fe8416a5f74f3dec995fc91' }, h("div", { key: '4f42e6cf0ee0b77c672e7485a53ffed7a75961fa', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, h("div", { key: '75bb2ea8e945c4d65d86a90f4f6da95ccd4425d1' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
1978
+ _a.translateX), h("div", { key: '69558794d6b88fece7c8af2be3cf5930174b8fd6' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
1979
+ _b.translateY), h("div", { key: 'd2e933f23eef9ee56137906f56c5cbadbaadaf23' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
1980
+ _c.viewportWidth), h("div", { key: 'c085fee84706c0be930d1e659dedb8a2728130dd' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
1981
+ _d.viewportHeight), h("div", { key: 'eeef8323ae0bc5047f038f4794aee4ed718d1183' }, "ObjectsInViewport. ", this.store.objects.length), h("div", { key: '20172772854ab20ee9dd9b4bf9b969627c649e61' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
1982
+ _e.scale), h("div", { key: '256646b05f63bc6949578acb1739f57a581c86e4' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
1983
+ _g.name), h("div", { key: 'd9e17c3c89a135fcbaf1cdfaa8f8123186c74626' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), h("div", { key: '7750bc5b2763e6351eb37f51b54bca965f7e0823' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), h("div", { key: '59ca295c0ab33fe6d82ccd1072fe64672c9f21b7' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), h("div", { key: 'b413ddf6bbc8e7e758abd811f3e66a71a4961a04' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), h("div", { key: 'c941fe71c6d3a124bcb02ff6d1efa33d943646aa' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), h("div", { key: 'f060e324991d0885770cfbedf8332047a3ede890' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: 'ec3f85f2cc61bb55210cfa952ce8b1af66c4caf4' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: '0376abe30d6456038a98383a82eff2ec955fd69a' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: '546d868377d654400e9013f8df54389e08a2c02d' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: 'b233911cad585a5318dd0a83258d477dd3e286f7' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), h("div", { key: '4fd9f89a72c49bb681695030245d4622ffe281b5' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), h("div", { key: 'e7c3b3485b945fff20dd0c6601727b52478a283b' }, "PointerX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
1984
+ _m.pointerX), h("div", { key: '0e940ac9609f23f1e4855206dda52c52eec14fe5' }, "PointerY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
1985
+ _o.pointerY), h("div", { key: '60475be8341d3a8e28416d91a38d188bce30d15b' }, "SelectedObjects: ", ((_p = this.store.state.selectionGroup) === null || _p === void 0 ? void 0 : _p.objects.length) || 0)), h("div", { key: '16608718942fd141d17a5d398045e178fa37eacf', id: "origin", class: "origin", style: {
1986
+ transform: `matrix(${(_q = this.store.state) === null || _q === void 0 ? void 0 : _q.scale}, 0, 0, ${(_r = this.store.state) === null || _r === void 0 ? void 0 : _r.scale}, ${(_s = this.store.state) === null || _s === void 0 ? void 0 : _s.translateX}, ${(_t = this.store.state) === null || _t === void 0 ? void 0 : _t.translateY})`,
1987
+ } }, (_u = this.store.objects) === null || _u === void 0 ? void 0 :
1988
+ _u.map(object => {
1989
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
1990
+ return (h("div", { style: { transform: object === null || object === void 0 ? void 0 : object.transformationMatrix, transformOrigin: 'top left', zIndex: object.zIndex.toString(), position: 'absolute' } }, h("svg", { xmlns: "http://www.w3.org/2000/svg", key: object.id, id: object.id, class: "object", style: {
1991
+ height: object === null || object === void 0 ? void 0 : object.totalHeight.toString(),
1992
+ width: object === null || object === void 0 ? void 0 : object.totalWidth.toString(),
1993
+ left: '0',
1994
+ top: '0',
1995
+ position: 'absolute',
1996
+ transform: `rotate(${object.rotationDegrees}deg)`,
1997
+ transformOrigin: 'center',
1998
+ opacity: object.markedForRemoval ? '0.5' : object.opacity.toString(),
1999
+ pointerEvents: object.markedForRemoval ? 'none' : 'auto',
2000
+ } }, h("foreignObject", { x: "0", y: "0", width: object.totalWidth.toString(), height: object.totalHeight.toString(), style: {
2001
+ minHeight: '0',
2002
+ minWidth: '0',
2003
+ backgroundColor: object.backgroundColor,
2004
+ borderColor: object.borderColor,
2005
+ borderWidth: object.borderWidth + 'px',
2006
+ borderStyle: 'solid',
2007
+ padding: object.padding + 'px',
2008
+ overflow: 'visible',
2009
+ } }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (h("svg", { ref: el => el ? object.mount(el) : object.unmount(), xmlns: "http://www.w3.org/2000/svg", style: {
2010
+ height: object === null || object === void 0 ? void 0 : object.height.toString(),
2011
+ width: object === null || object === void 0 ? void 0 : object.width.toString(),
2012
+ position: 'absolute',
2013
+ overflow: 'visible',
2014
+ }, viewBox: object === null || object === void 0 ? void 0 : object.viewBox }, h("path", { d: object === null || object === void 0 ? void 0 : object.d, fill: object.fill, stroke: object === null || object === void 0 ? void 0 : object.stroke }))), KritzelClassHelper.isInstanceOf(object, 'KritzelImage') && (h("img", { ref: el => el ? object.mount(el) : object.unmount(), src: object.src, style: {
2015
+ width: '100%',
2016
+ height: '100%',
2017
+ userSelect: 'none',
2018
+ pointerEvents: 'none',
2019
+ }, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (h("textarea", { ref: el => el ? object.mount(el) : object.unmount(), value: object.value, onKeyDown: event => object.handleKeyDown(event), onInput: event => object.handleInput(event), rows: object.rows, style: {
2020
+ width: '100%',
2021
+ height: '100%',
2022
+ color: object.fontColor,
2023
+ fontSize: ((_a = object.fontSize) === null || _a === void 0 ? void 0 : _a.toString()) + 'px',
2024
+ fontFamily: object.fontFamily,
2025
+ border: 'none',
2026
+ outline: 'none',
2027
+ resize: 'none',
2028
+ overflow: 'hidden',
2029
+ display: 'block',
2030
+ padding: '1px',
2031
+ whiteSpace: 'nowrap',
2032
+ pointerEvents: object.isReadonly ? 'none' : 'auto',
2033
+ cursor: object.isReadonly ? 'default' : 'text',
2034
+ caretColor: object.isReadonly ? 'transparent' : 'auto',
2035
+ } })), KritzelClassHelper.isInstanceOf(object, 'KritzelCustomElement') && (h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
2036
+ width: '100%',
2037
+ height: '100%',
2038
+ pointerEvents: 'auto',
2039
+ overflow: 'hidden',
2040
+ display: 'block',
2041
+ } })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup') && (h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
2042
+ width: '100%',
2043
+ height: '100%',
2044
+ } })), KritzelClassHelper.isInstanceOf(object, 'KrtizelSelectionBox') && (h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
2045
+ width: '100%',
2046
+ height: '100%',
2047
+ } }))), h("line", { x1: "0", y1: "0", x2: object.totalWidth, y2: "0", style: {
2048
+ stroke: 'var(--kritzel-selection-border-color, #007AFF)',
2049
+ strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_b = this.store.state) === null || _b === void 0 ? void 0 : _b.scale})`,
2050
+ strokeLinecap: 'square',
2051
+ }, visibility: object.isSelected ? 'visible' : 'hidden' }), h("line", { x1: "0", y1: "0", x2: "0", y2: object.totalHeight, style: {
2052
+ stroke: 'var(--kritzel-selection-border-color, #007AFF)',
2053
+ strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_c = this.store.state) === null || _c === void 0 ? void 0 : _c.scale})`,
2054
+ strokeLinecap: 'square',
2055
+ }, visibility: object.isSelected ? 'visible' : 'hidden' }), h("line", { x1: "0", y1: object.totalHeight, x2: object.totalWidth, y2: object.totalHeight, style: {
2056
+ stroke: 'var(--kritzel-selection-border-color, #007AFF)',
2057
+ strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_d = this.store.state) === null || _d === void 0 ? void 0 : _d.scale})`,
2058
+ strokeLinecap: 'square',
2059
+ }, visibility: object.isSelected ? 'visible' : 'hidden' }), h("line", { x1: object.totalWidth, y1: "0", x2: object.totalWidth, y2: object.totalHeight, style: {
2060
+ stroke: 'var(--kritzel-selection-border-color, #007AFF)',
2061
+ strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_e = this.store.state) === null || _e === void 0 ? void 0 : _e.scale})`,
2062
+ strokeLinecap: 'square',
2063
+ }, visibility: object.isSelected ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle top-left", cx: "0", cy: "0", r: `${(baseHandleSize * object.scale) / ((_f = this.store.state) === null || _f === void 0 ? void 0 : _f.scale)}`, style: {
2064
+ fill: 'var(--kritzel-selection-handle-color, #000000)',
2065
+ }, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle-overlay top-left", cx: "0", cy: "0", r: `${(baseHandleTouchSize * object.scale) / ((_g = this.store.state) === null || _g === void 0 ? void 0 : _g.scale)}`, style: {
2066
+ fill: 'transparent',
2067
+ }, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle top-right", cx: object.totalWidth, cy: "0", r: `${(baseHandleSize * object.scale) / ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.scale)}`, style: {
2068
+ fill: 'var(--kritzel-selection-handle-color, #000000)',
2069
+ }, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle-overlay top-right", cx: object.totalWidth, cy: "0", r: `${(baseHandleTouchSize * object.scale) / ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.scale)}`, style: {
2070
+ fill: 'transparent',
2071
+ }, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle bottom-left", cx: "0", cy: object.totalHeight, r: `${(baseHandleSize * object.scale) / ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.scale)}`, style: {
2072
+ fill: 'var(--kritzel-selection-handle-color, #000000)',
2073
+ }, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle-overlay bottom-left", cx: "0", cy: object.totalHeight, r: `${(baseHandleTouchSize * object.scale) / ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.scale)}`, style: {
2074
+ fill: 'transparent',
2075
+ }, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle bottom-right", cx: object.totalWidth, cy: object.totalHeight, r: `${(baseHandleSize * object.scale) / ((_m = this.store.state) === null || _m === void 0 ? void 0 : _m.scale)}`, style: {
2076
+ fill: 'var(--kritzel-selection-handle-color, #000000)',
2077
+ }, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle-overlay bottom-right", cx: object.totalWidth, cy: object.totalHeight, r: `${(baseHandleTouchSize * object.scale) / ((_o = this.store.state) === null || _o === void 0 ? void 0 : _o.scale)}`, style: {
2078
+ fill: 'transparent',
2079
+ }, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("line", { x1: object.totalWidth / 2, y1: "0", x2: object.totalWidth / 2, y2: -((15 * object.scale) / ((_p = this.store.state) === null || _p === void 0 ? void 0 : _p.scale)), style: {
2080
+ stroke: 'var(--kritzel-selection-border-color, #007AFF)',
2081
+ strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_q = this.store.state) === null || _q === void 0 ? void 0 : _q.scale})`,
2082
+ }, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "rotation-handle", cx: object.totalWidth / 2, cy: -((15 * object.scale) / ((_r = this.store.state) === null || _r === void 0 ? void 0 : _r.scale)), r: `${(baseHandleSize * object.scale) / ((_s = this.store.state) === null || _s === void 0 ? void 0 : _s.scale)}`, style: {
2083
+ fill: 'var(--kritzel-selection-handle-color, #000000)',
2084
+ }, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "rotation-handle-overlay", cx: object.totalWidth / 2, cy: -((15 * object.scale) / ((_t = this.store.state) === null || _t === void 0 ? void 0 : _t.scale)), r: `${(baseHandleTouchSize * object.scale) / ((_u = this.store.state) === null || _u === void 0 ? void 0 : _u.scale)}`, style: {
2085
+ fill: 'transparent',
2086
+ cursor: 'grab',
2087
+ }, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("g", { style: { display: this.store.state.debugInfo.showObjectInfo ? 'block' : 'none', pointerEvents: 'none' } }, h("foreignObject", { x: object.totalWidth.toString(), y: "0", width: "400px", height: "160px", style: { minHeight: '0', minWidth: '0', display: object.isDebugInfoVisible ? 'block' : 'none' } }, h("div", { style: { width: '100%', height: '100%' } }, h("div", { style: { whiteSpace: 'nowrap' } }, "zIndex: ", object.zIndex), h("div", { style: { whiteSpace: 'nowrap' } }, "translateX: ", object.translateX), h("div", { style: { whiteSpace: 'nowrap' } }, "translateY: ", object.translateY), h("div", { style: { whiteSpace: 'nowrap' } }, "width: ", object.width), h("div", { style: { whiteSpace: 'nowrap' } }, "height: ", object.height), h("div", { style: { whiteSpace: 'nowrap' } }, "scale: ", object.scale), h("div", { style: { whiteSpace: 'nowrap' } }, "rotation: ", object.rotation), h("div", { style: { whiteSpace: 'nowrap' } }, "x: ", object.x), h("div", { style: { whiteSpace: 'nowrap' } }, "y: ", object.y)))))));
2088
+ }), h("svg", { key: 'd945e3fae758a66d8d17875203561602446acf9a', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
2089
+ height: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.height.toString(),
2090
+ width: (_w = this.store.state.currentPath) === null || _w === void 0 ? void 0 : _w.width.toString(),
2091
+ left: '0',
2092
+ top: '0',
2093
+ zIndex: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.zIndex.toString(),
2094
+ position: 'absolute',
2095
+ transform: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.transformationMatrix,
2096
+ transformOrigin: 'top left',
2097
+ overflow: 'visible',
2098
+ }, viewBox: (_z = this.store.state.currentPath) === null || _z === void 0 ? void 0 : _z.viewBox }, h("path", { key: '111070848aa210dabf4150a9e69326c7a32a2bb7', d: (_0 = this.store.state.currentPath) === null || _0 === void 0 ? void 0 : _0.d, fill: (_1 = this.store.state.currentPath) === null || _1 === void 0 ? void 0 : _1.fill, stroke: (_2 = this.store.state.currentPath) === null || _2 === void 0 ? void 0 : _2.stroke }))), this.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: '13f61253ab96655d6816bfba60b7c1c8e0697533', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, objects: ((_3 = this.store.state.selectionGroup) === null || _3 === void 0 ? void 0 : _3.objects) || [], style: {
2099
+ position: 'fixed',
2100
+ left: `${this.store.state.contextMenuX}px`,
2101
+ top: `${this.store.state.contextMenuY}px`,
2102
+ zIndex: '10000',
2103
+ }, onActionSelected: event => {
2104
+ var _a;
2105
+ event.detail.action({
2106
+ x: (-this.store.state.translateX + this.store.state.contextMenuX) / this.store.state.scale,
2107
+ y: (-this.store.state.translateY + this.store.state.contextMenuY) / this.store.state.scale,
2108
+ }, (_a = this.store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.objects);
2109
+ this.hideContextMenu();
2110
+ } })), ((_4 = this.store.state) === null || _4 === void 0 ? void 0 : _4.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && h("kritzel-cursor-trail", { key: 'bcbedb0fd45a7b87e82e78326bfdc0d1a872c1aa', store: this.store })));
2111
+ }
2112
+ get host() { return getElement(this); }
2113
+ static get watchers() { return {
2114
+ "scaleMax": ["validateScaleMax"],
2115
+ "scaleMin": ["validateScaleMin"]
2116
+ }; }
2117
+ };
2118
+ KritzelEngine.style = kritzelEngineCss;
2119
+
2120
+ const kritzelFontCss = ":host{display:block}.font-preview{color:var(--kritzel-font-size-text-color, #333333);line-height:1;text-align:center;font-weight:bold}";
2121
+
2122
+ const KritzelFont = class {
2123
+ constructor(hostRef) {
2124
+ registerInstance(this, hostRef);
2125
+ this.fontFamily = 'Arial, sans-serif';
2126
+ this.size = 24;
2127
+ this.color = '#000000';
2128
+ }
2129
+ render() {
2130
+ return (h(Host, { key: 'e4123d3701933d5de1d5c063f69f6823db849baf' }, h("div", { key: '81dde2ff263a8bf110b9c0f0be4a5adc5852fa2f', class: "font-preview", style: {
2131
+ fontFamily: this.fontFamily,
2132
+ fontSize: `${this.size}px`,
2133
+ color: this.color
2134
+ } }, "A")));
2135
+ }
2136
+ };
2137
+ KritzelFont.style = kritzelFontCss;
2138
+
2139
+ const kritzelFontFamilyCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box;width:100%}.font-style-button{display:flex;justify-content:center;align-items:center;width:42px;height:32px;padding:0;border:none;outline:none;background:none;cursor:pointer;border-radius:0;color:var(--control-text-color);font-weight:bold;-webkit-tap-highlight-color:transparent}.font-style-button:not(:last-child){border-right:1px solid #333333}.font-style-button:hover{background-color:var(--control-hover-bg)}.font-style-button:active{background-color:var(--control-active-bg)}.font-style-button.selected,.font-style-button.selected:hover,.font-style-button.selected:active{background-color:var(--control-selected-bg);color:var(--control-selected-color)}.font-style-button.italic-text{font-style:italic}";
2140
+
2141
+ const KritzelFontFamily = class {
2142
+ constructor(hostRef) {
2143
+ registerInstance(this, hostRef);
2144
+ this.fontFamilyChange = createEvent(this, "fontFamilyChange");
2145
+ this.fontOptions = [
2146
+ { value: 'arial', label: 'Arial' },
2147
+ { value: 'verdana', label: 'Verdana' },
2148
+ { value: 'helvetica', label: 'Helvetica' },
2149
+ { value: 'tahoma', label: 'Tahoma' },
2150
+ { value: 'trebuchet ms', label: 'Trebuchet MS' },
2151
+ { value: 'times new roman', label: 'Times New Roman' },
2152
+ { value: 'georgia', label: 'Georgia' },
2153
+ { value: 'garamond', label: 'Garamond' },
2154
+ { value: 'courier new', label: 'Courier New' },
2155
+ { value: 'brush script mt', label: 'Brush Script MT' },
2156
+ ];
2157
+ this.handleDropdownValueChange = (event) => {
2158
+ this.fontFamilyChange.emit(event.detail);
2159
+ };
2160
+ }
2161
+ componentWillLoad() {
2162
+ if (this.fontOptions && this.fontOptions.length > 0) {
2163
+ const isValidCurrentFont = this.fontOptions.some(opt => opt.value === this.selectedFontFamily);
2164
+ if (!this.selectedFontFamily || !isValidCurrentFont) {
2165
+ this.selectedFontFamily = this.fontOptions[0].value;
2166
+ }
2167
+ }
2168
+ }
2169
+ render() {
2170
+ const dropdownOptions = this.fontOptions.map(option => ({
2171
+ value: option.value,
2172
+ label: option.label,
2173
+ style: { fontFamily: option.value },
2174
+ }));
2175
+ return (h(Host, { key: 'b56a2dcc19e11c8cf84449d94f43fd93a882ac4e' }, h("kritzel-dropdown", { key: '999c75650ce8d83c5b52eda5c96ce0b040e67475', options: dropdownOptions, value: this.selectedFontFamily, onValueChanged: this.handleDropdownValueChange, selectStyles: { fontFamily: this.selectedFontFamily } }, h("button", { key: 'defbe8238c3037a5128f59f33a51f6ec9fd08dc3', class: "font-style-button", slot: "suffix" }, "B"), h("button", { key: '7dd5a7256dde1d38b495f67bdec2d605fde0a1ec', class: "font-style-button italic-text", slot: "suffix" }, "I"))));
2176
+ }
2177
+ };
2178
+ KritzelFontFamily.style = kritzelFontFamilyCss;
2179
+
2180
+ const kritzelFontSizeCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box}.size-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:4px;cursor:pointer;border:2px solid transparent;box-sizing:border-box;border-radius:50%}.size-container:hover{background-color:var(--kritzel-font-size-hover-background-color, #f0f0f0)}.size-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-font-size-selected-background-color, #e0e0e0)}";
2181
+
2182
+ const KritzelFontSize = class {
2183
+ constructor(hostRef) {
2184
+ registerInstance(this, hostRef);
2185
+ this.sizeChange = createEvent(this, "sizeChange");
2186
+ this.sizes = [8, 10, 12, 16, 20, 24];
2187
+ this.selectedSize = null;
2188
+ this.fontFamily = 'Arial';
2189
+ }
2190
+ handleSizeClick(size) {
2191
+ this.selectedSize = size;
2192
+ this.sizeChange.emit(size);
2193
+ }
2194
+ render() {
2195
+ return (h(Host, { key: 'b741185f77e6e6f9fa7a5023d90936d1ebb48d30' }, this.sizes.map(size => (h("div", { class: {
2196
+ 'size-container': true,
2197
+ 'selected': this.selectedSize === size,
2198
+ }, onClick: () => this.handleSizeClick(size) }, h("kritzel-font", { fontFamily: this.fontFamily, size: size }))))));
2199
+ }
2200
+ };
2201
+ KritzelFontSize.style = kritzelFontSizeCss;
2202
+
2203
+ const kritzelIconCss = ":host{display:inline-flex;justify-content:center;align-items:center;}span{display:flex;align-items:center;width:100%;height:100%;}span>svg{width:100%;height:100%}";
2204
+
2205
+ const KritzelIcon = class {
2206
+ constructor(hostRef) {
2207
+ registerInstance(this, hostRef);
2208
+ this.size = 24;
2209
+ }
2210
+ render() {
2211
+ const svgContent = KritzelIconRegistry.get(this.name);
2212
+ if (!svgContent) {
2213
+ console.error(`[kritzel-icon] Icon "${this.name}" not found in registry.`);
2214
+ return h("span", { class: "error-icon", "aria-label": `Error: Icon ${this.name} not found` }, "?");
2215
+ }
2216
+ const styles = {
2217
+ width: `${this.size}px`,
2218
+ height: `${this.size}px`,
2219
+ };
2220
+ return (h(Host, { style: styles }, h("span", { "aria-hidden": !this.label, role: this.label ? 'img' : undefined, "aria-label": this.label, innerHTML: svgContent })));
2221
+ }
2222
+ };
2223
+ KritzelIcon.style = kritzelIconCss;
2224
+
2225
+ const kritzelStrokeSizeCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box}.size-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box}.size-container:hover{background-color:var(--kritzel-stroke-size-hover-background-color, #f0f0f0)}.size-container.selected{border-color:var(--kritzel-selection-border-color, #007AFF);background-color:var(--kritzel-stroke-size-selected-background-color, #f0f0f0)}";
2226
+
2227
+ const KritzelStrokeSize = class {
2228
+ constructor(hostRef) {
2229
+ registerInstance(this, hostRef);
2230
+ this.sizeChange = createEvent(this, "sizeChange");
2231
+ this.sizes = [4, 6, 8, 12, 16, 24];
2232
+ this.selectedSize = null;
2233
+ }
2234
+ handleSizeClick(size) {
2235
+ this.selectedSize = size;
2236
+ this.sizeChange.emit(size);
2237
+ }
2238
+ render() {
2239
+ return (h(Host, { key: 'b481b62184551bc776042f58d2f27beba837f61d' }, this.sizes.map(size => (h("div", { class: {
2240
+ 'size-container': true,
2241
+ 'selected': this.selectedSize === size,
2242
+ }, onClick: () => this.handleSizeClick(size) }, h("kritzel-color", { value: '#000000', size: size }))))));
2243
+ }
2244
+ };
2245
+ KritzelStrokeSize.style = kritzelStrokeSizeCss;
2246
+
2247
+ const kritzelTooltipCss = ":host{width:auto}.tooltip-content{position:relative;padding:8px 12px;border-radius:4px;width:fit-content;background-color:var(--kritzel-controls-tooltip-background-color, #ffffff);color:var(--kritzel-controls-tooltip-color, #000000);padding:var(--kritzel-controls-tooltip-padding, 8px);border-radius:var(--kritzel-controls-tooltip-border-radius, 16px);white-space:nowrap;box-shadow:var(--kritzel-controls-tooltip-box-shadow, 0 1px 6px rgba(0, 0, 0, 0.12))}";
2248
+
2249
+ const MOBILE_BREAKPOINT = 768;
2250
+ const KritzelTooltip = class {
2251
+ constructor(hostRef) {
2252
+ registerInstance(this, hostRef);
2253
+ this.isVisible = false;
2254
+ this.arrowSize = 8;
2255
+ this.offsetY = 24;
2256
+ this.positionX = 0;
2257
+ this.arrowOffset = '0px';
2258
+ this.isMobileView = window.innerWidth < MOBILE_BREAKPOINT;
2259
+ }
2260
+ handleWindowResize() {
2261
+ this.isMobileView = window.innerWidth < MOBILE_BREAKPOINT;
2262
+ this.calculateAdjustedPosition();
2263
+ }
2264
+ componentWillLoad() {
2265
+ this.isMobileView = window.innerWidth < MOBILE_BREAKPOINT;
2266
+ this.calculateAdjustedPosition();
2267
+ }
2268
+ componentWillUpdate() {
2269
+ this.calculateAdjustedPosition();
2270
+ }
2271
+ calculateAdjustedPosition() {
2272
+ var _a;
2273
+ if (this.isVisible && this.anchorElement) {
2274
+ const anchorRect = this.anchorElement.getBoundingClientRect();
2275
+ const tooltipContent = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.tooltip-content');
2276
+ if (!this.isMobileView) {
2277
+ this.positionX = anchorRect.left + anchorRect.width / 2;
2278
+ this.arrowOffset = `calc(${50}% - ${this.arrowSize}px)`;
2279
+ }
2280
+ else {
2281
+ const tooltipRect = tooltipContent.getBoundingClientRect();
2282
+ this.positionX = anchorRect.left + anchorRect.width / 2 - tooltipRect.width / 2;
2283
+ this.arrowOffset = `${anchorRect.left + anchorRect.width / 2 - tooltipRect.left - this.arrowSize}px`;
2284
+ }
2285
+ }
2286
+ }
2287
+ render() {
2288
+ return (h(Host, { key: 'aed123eda0750df66229f0dd40eeafea39360901', style: {
2289
+ position: 'fixed',
2290
+ zIndex: '9999',
2291
+ transition: 'opacity 0.3s ease-in-out, transform 0.3s ease-in-out',
2292
+ visibility: this.isVisible ? 'visible' : 'hidden',
2293
+ left: !this.isMobileView ? `${this.positionX}px` : '50%',
2294
+ marginBottom: `${this.offsetY + this.arrowSize}px`,
2295
+ } }, h("div", { key: 'ebd77cc44aea3a3ff193717f2dae7eedb55023fd', class: "tooltip-content", onClick: event => event.stopPropagation() }, h("slot", { key: '70966228bbe59b894eb472704f08b340c32bbad9' }), h("div", { key: '0d82c0f5b1531b39e48b9e80045771e3dda53964', class: "tooltip-arrow-wrapper", style: {
2296
+ position: 'fixed',
2297
+ left: this.arrowOffset,
2298
+ bottom: `-${this.arrowSize * 2}px`,
2299
+ } }, h("div", { key: '24b911e6fe5b5b9a1009d28c797c4c3d00f6f7c7', class: "tooltip-arrow", style: {
2300
+ borderLeft: `${this.arrowSize}px solid transparent`,
2301
+ borderRight: `${this.arrowSize}px solid transparent`,
2302
+ borderTop: `${this.arrowSize}px solid var(--kritzel-controls-tooltip-background-color, #ffffff)`,
2303
+ filter: 'drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2))',
2304
+ } }), h("div", { key: '2a15c5e8614e57a763aa3d8d4f8d4138146ac0a7', class: "tooltip-arrow-rect", style: {
2305
+ position: 'relative',
2306
+ width: `${this.arrowSize * 2}px`,
2307
+ height: `${this.arrowSize}px`,
2308
+ backgroundColor: 'var(--kritzel-controls-tooltip-background-color, #ffffff)',
2309
+ bottom: `${this.arrowSize * 2}px`,
2310
+ } })))));
2311
+ }
2312
+ get el() { return getElement(this); }
2313
+ };
2314
+ KritzelTooltip.style = kritzelTooltipCss;
2315
+
2316
+ const kritzelUtilityPanelCss = ":host{display:flex;flex-direction:row;align-items:center;padding:4px;gap:8px;border-top-left-radius:12px;border-top-right-radius:12px;background-color:rgb(226, 226, 226);width:fit-content;user-select:none}.utility-button{display:flex;justify-content:center;align-items:center;width:28px;height:28px;padding:8px 4px;border:none;outline:none;background:none;cursor:pointer;color:#333333;-webkit-tap-highlight-color:transparent}.utility-separator{width:1px;height:16px;background-color:hsl(0, 0%, 0%, 4.3%)}";
2317
+
2318
+ const KritzelUtilityPanel = class {
2319
+ constructor(hostRef) {
2320
+ registerInstance(this, hostRef);
2321
+ this.undo = createEvent(this, "undo");
2322
+ this.redo = createEvent(this, "redo");
2323
+ this.delete = createEvent(this, "delete");
2324
+ }
2325
+ handleUndo(event) {
2326
+ if (event.cancelable) {
2327
+ event.preventDefault();
2328
+ event.stopPropagation();
2329
+ this.undo.emit();
2330
+ }
2331
+ }
2332
+ handleRedo(event) {
2333
+ event.preventDefault();
2334
+ event.stopPropagation();
2335
+ this.redo.emit();
2336
+ }
2337
+ render() {
2338
+ return (h(Host, { key: 'f381fac2cb032ca19c6945ef4f39673ea0bd0cc5' }, h("button", { key: '1f7200672970baf1d0cfcaa116fa3f8f9a39832a', class: "utility-button", onClick: event => this.handleUndo(event) }, h("kritzel-icon", { key: '755d9201d80d8db086f07b38e90a01a06e980b50', name: "undo" })), h("button", { key: '06e4d5c2956f23245c3d48f21c15d54e8bef8119', class: "utility-button", onClick: event => this.handleRedo(event) }, h("kritzel-icon", { key: '13eb6b31c45b67ac399fc7c84b941ddce04c5c86', name: "redo" })), h("div", { key: '7f03a576a37649db679b93604c2654d29cc81da4', class: "utility-separator" }), h("button", { key: '0c40613e9f6a049cec872d71e9f948d685ec1dbe', class: "utility-button" }, h("kritzel-icon", { key: '8cba73bcb02ef8b7c182ba2fd16d98d6855f1c1b', name: "delete", onClick: () => this.delete.emit() }))));
2339
+ }
2340
+ };
2341
+ KritzelUtilityPanel.style = kritzelUtilityPanelCss;
2342
+
2343
+ export { KritzelBrushStyle as kritzel_brush_style, KritzelColor as kritzel_color, KritzelColorPalette as kritzel_color_palette, KritzelContextMenu as kritzel_context_menu, KritzelControlBrushConfig as kritzel_control_brush_config, KritzelControlTextConfig as kritzel_control_text_config, KritzelControls as kritzel_controls, KritzelCursorTrail as kritzel_cursor_trail, KritzelDropdown as kritzel_dropdown, KritzelEditor as kritzel_editor, KritzelEngine as kritzel_engine, KritzelFont as kritzel_font, KritzelFontFamily as kritzel_font_family, KritzelFontSize as kritzel_font_size, KritzelIcon as kritzel_icon, KritzelStrokeSize as kritzel_stroke_size, KritzelTooltip as kritzel_tooltip, KritzelUtilityPanel as kritzel_utility_panel };
2344
+ //# sourceMappingURL=kritzel-brush-style.kritzel-color.kritzel-color-palette.kritzel-context-menu.kritzel-control-brush-config.kritzel-control-text-config.kritzel-controls.kritzel-cursor-trail.kritzel-dropdown.kritzel-editor.kritzel-engine.kritzel-font.kritzel-font-family.kritzel-font-size.kritzel-icon.kritzel-stroke-size.kritzel-tooltip.kritzel-utility-panel.entry.js.map
2345
+
2346
+ //# sourceMappingURL=kritzel-brush-style_18.entry.js.map