@yorab/react-paint 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +46 -283
  2. package/dist/canvas/components/Canvas.d.ts +1 -0
  3. package/dist/canvas/components/EditTextBox.d.ts +2 -2
  4. package/dist/canvas/constants/app.d.ts +2 -0
  5. package/dist/canvas/constants/keyboard.d.ts +24 -0
  6. package/dist/canvas/hooks/useComponent.d.ts +3 -1
  7. package/dist/canvas/hooks/useDebounce.d.ts +2 -0
  8. package/dist/canvas/hooks/useDrawableCanvas.d.ts +2 -1
  9. package/dist/canvas/hooks/useKeyboard.d.ts +5 -1
  10. package/dist/canvas/hooks/useReactPaint.d.ts +1845 -8
  11. package/dist/canvas/hooks/useShapes.d.ts +1378 -4
  12. package/dist/canvas/index.d.ts +3 -3
  13. package/dist/canvas/utils/data.d.ts +2 -2
  14. package/dist/canvas/utils/file.d.ts +233 -4
  15. package/dist/canvas/utils/intersect.d.ts +4 -4
  16. package/dist/canvas/utils/selection/groupSelection.d.ts +2 -2
  17. package/dist/canvas/utils/selection/lineSelection.d.ts +6 -2
  18. package/dist/canvas/utils/selection/rectSelection.d.ts +9 -4
  19. package/dist/canvas/utils/selection.d.ts +1 -1
  20. package/dist/canvas/utils/shapes/brush.d.ts +14 -11
  21. package/dist/canvas/utils/shapes/circle.d.ts +13 -9
  22. package/dist/canvas/utils/shapes/curve.d.ts +15 -10
  23. package/dist/canvas/utils/shapes/ellipse.d.ts +13 -9
  24. package/dist/canvas/utils/shapes/index.d.ts +19 -10
  25. package/dist/canvas/utils/shapes/line.d.ts +13 -8
  26. package/dist/canvas/utils/shapes/path.d.ts +18 -2
  27. package/dist/canvas/utils/shapes/picture.d.ts +13 -9
  28. package/dist/canvas/utils/shapes/polygon.d.ts +14 -8
  29. package/dist/canvas/utils/shapes/rectangle.d.ts +54 -9
  30. package/dist/canvas/utils/shapes/text.d.ts +12 -7
  31. package/dist/canvas/utils/shapes/triangle.d.ts +4 -3
  32. package/dist/canvas/utils/trigo.d.ts +1 -1
  33. package/dist/common/types/Shapes.d.ts +63 -26
  34. package/dist/common/types/utils.d.ts +1 -1
  35. package/dist/editor/components/common/Button.d.ts +2 -2
  36. package/dist/editor/components/common/FileInput.d.ts +13 -0
  37. package/dist/editor/index.d.ts +11 -11
  38. package/dist/react-paint.css +1 -1
  39. package/dist/react-paint.js +1185 -1143
  40. package/dist/react-paint.umd.cjs +1 -1
  41. package/package.json +19 -15
@@ -1,415 +1,460 @@
1
- import ua, { useState as $, useEffect as K, useRef as ae, useCallback as F, useMemo as pa, useImperativeHandle as Sn, useTransition as ga } from "react";
2
- import { jsx as g, jsxs as B, Fragment as Le } from "react/jsx-runtime";
3
- const va = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.708Q2.208 15.75 2.802 15.344Q3.396 14.938 3.396 14.104Q3.396 13.042 4.135 12.292Q4.875 11.542 5.958 11.542Q7.021 11.542 7.76 12.292Q8.5 13.042 8.5 14.104Q8.5 15.5 7.51 16.5Q6.521 17.5 5.146 17.5ZM9.917 12.5 7.562 10.146 14.917 2.729Q15.146 2.5 15.469 2.5Q15.792 2.5 16.021 2.729L17.271 3.958Q17.5 4.188 17.5 4.531Q17.5 4.875 17.271 5.125Z"/></svg>', ai = '<svg><path d="M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z"/></svg>', ni = '<svg><path d="M10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.271 2.323 6.75Q2.979 5.229 4.104 4.104Q5.229 2.979 6.75 2.323Q8.271 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.729 17.677 13.25Q17.021 14.771 15.896 15.896Q14.771 17.021 13.25 17.677Q11.729 18.333 10 18.333ZM10 16.583Q12.75 16.583 14.667 14.667Q16.583 12.75 16.583 10Q16.583 7.25 14.667 5.333Q12.75 3.417 10 3.417Q7.25 3.417 5.333 5.333Q3.417 7.25 3.417 10Q3.417 12.75 5.333 14.667Q7.25 16.583 10 16.583ZM10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Z"/></svg>', oi = '<svg><path d="M12.25 18.333V16.167L6.833 13.458H2.5V8.208H6.25L8.25 5.917V1.667H13.5V6.917H9.708L7.75 9.146V11.958L12.25 14.208V13.083H17.5V18.333Z"/></svg>', fa = '<svg><path d="M4.125 5.083V3.333H7.062L7.896 2.5H12.104L12.938 3.333H15.875V5.083ZM6.75 17.5Q6.021 17.5 5.51 16.99Q5 16.479 5 15.75V5.958H15V15.75Q15 16.479 14.49 16.99Q13.979 17.5 13.25 17.5Z"/></svg>', yi = '<svg><path d="M10 17.5Q7.208 17.5 5.271 15.594Q3.333 13.688 3.333 10.958Q3.333 9.583 3.854 8.396Q4.375 7.208 5.292 6.292L10 1.667L14.688 6.292Q15.604 7.208 16.135 8.396Q16.667 9.583 16.667 10.958Q16.667 13.688 14.719 15.594Q12.771 17.5 10 17.5ZM5.146 11.667H14.854Q15.083 10.188 14.552 9.146Q14.021 8.104 13.479 7.562L10 4.125L6.521 7.562Q5.979 8.104 5.448 9.146Q4.917 10.188 5.146 11.667Z"/></svg>', si = '<svg><path d="M4.792 15.083 8.333 11.542 9.833 13.021 11.667 10.708 15.167 15.083ZM6.667 8.417Q5.938 8.417 5.427 7.906Q4.917 7.396 4.917 6.667Q4.917 5.938 5.427 5.427Q5.938 4.917 6.667 4.917Q7.396 4.917 7.906 5.427Q8.417 5.938 8.417 6.667Q8.417 7.396 7.906 7.906Q7.396 8.417 6.667 8.417ZM4.167 18.333Q3.125 18.333 2.396 17.604Q1.667 16.875 1.667 15.833V4.167Q1.667 3.125 2.396 2.396Q3.125 1.667 4.167 1.667H15.833Q16.875 1.667 17.604 2.396Q18.333 3.125 18.333 4.167V15.833Q18.333 16.875 17.604 17.604Q16.875 18.333 15.833 18.333ZM4.167 16.583H15.833Q16.146 16.583 16.365 16.365Q16.583 16.146 16.583 15.833V4.167Q16.583 3.854 16.365 3.635Q16.146 3.417 15.833 3.417H4.167Q3.854 3.417 3.635 3.635Q3.417 3.854 3.417 4.167V15.833Q3.417 16.146 3.635 16.365Q3.854 16.583 4.167 16.583Z"/></svg>', ma = '<svg><path d="M8.708 16.667V5.917H4.167V3.333H15.833V5.917H11.292V16.667Z"/></svg>', ya = '<svg><path d="M7.5 15.833V14.083H12.833L3.333 4.583L4.583 3.333L14.083 12.833V7.5H15.833V15.833Z"/></svg>', Sa = '<svg><path d="M7.521 17.5Q6.125 17.5 5.146 16.51Q4.167 15.521 4.167 14.125V7.417Q3.438 7.125 2.969 6.49Q2.5 5.854 2.5 5.042Q2.5 3.979 3.24 3.24Q3.979 2.5 5.042 2.5Q6.104 2.5 6.844 3.24Q7.583 3.979 7.583 5.042Q7.583 5.854 7.115 6.49Q6.646 7.125 5.917 7.417V14.125Q5.917 14.792 6.385 15.271Q6.854 15.75 7.521 15.75Q8.188 15.75 8.656 15.271Q9.125 14.792 9.125 14.125V5.875Q9.125 4.479 10.104 3.49Q11.083 2.5 12.479 2.5Q13.875 2.5 14.854 3.49Q15.833 4.479 15.833 5.875V12.583Q16.562 12.875 17.031 13.51Q17.5 14.146 17.5 14.958Q17.5 16.021 16.76 16.76Q16.021 17.5 14.958 17.5Q13.896 17.5 13.156 16.76Q12.417 16.021 12.417 14.958Q12.417 14.146 12.885 13.5Q13.354 12.854 14.083 12.583V5.875Q14.083 5.208 13.615 4.729Q13.146 4.25 12.479 4.25Q11.812 4.25 11.344 4.729Q10.875 5.208 10.875 5.875V14.125Q10.875 15.521 9.896 16.51Q8.917 17.5 7.521 17.5Z"/></svg>', Si = '<svg><path d="M5.833 15V3.333H10.375Q11.812 3.333 12.885 4.156Q13.958 4.979 13.958 6.375Q13.958 7.375 13.49 7.969Q13.021 8.562 12.396 8.875V9.042Q13.312 9.354 13.844 10.021Q14.375 10.688 14.375 11.75Q14.375 13.312 13.229 14.156Q12.083 15 10.5 15ZM8.125 8.042H10.188Q10.854 8.042 11.302 7.656Q11.75 7.271 11.75 6.708Q11.75 6.167 11.302 5.771Q10.854 5.375 10.188 5.375H8.125ZM8.125 12.917H10.354Q11.167 12.917 11.625 12.51Q12.083 12.104 12.083 11.458Q12.083 10.812 11.625 10.406Q11.167 10 10.354 10H8.125Z"/></svg>', Qi = '<svg><path d="M4.167 16.667V14.083H6.979L10.229 5.917H7.5V3.333H15.833V5.917H13.021L9.771 14.083H12.5V16.667Z"/></svg>', bi = '<svg><path d="M3.021 16V15H17V16ZM3.021 13.5V12H17V13.5ZM3 10.5V8.5H16.979V10.5ZM3.021 7V4H17V7Z"/></svg>', wi = '<svg><path d="M16.354 18.833 14.521 17Q13.542 17.646 12.396 17.99Q11.25 18.333 10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.729 2.01 7.594Q2.354 6.458 3 5.458L1.167 3.625L2.396 2.396L17.583 17.604ZM10 16.583Q10.896 16.583 11.708 16.365Q12.521 16.146 13.25 15.729L4.292 6.75Q3.875 7.479 3.646 8.292Q3.417 9.104 3.417 10Q3.417 12.729 5.344 14.656Q7.271 16.583 10 16.583ZM17 14.562 15.708 13.271Q16.125 12.542 16.354 11.719Q16.583 10.896 16.583 10Q16.583 7.271 14.656 5.344Q12.729 3.417 10 3.417Q9.104 3.417 8.292 3.646Q7.479 3.875 6.75 4.292L5.458 3Q6.458 2.354 7.594 2.01Q8.729 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.271 17.979 12.417Q17.625 13.562 17 14.562ZM11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771ZM8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Z"/></svg>', xi = '<svg><path d="M16.354 18.833 14.521 17Q13.542 17.646 12.396 17.99Q11.25 18.333 10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.729 2.01 7.594Q2.354 6.458 3 5.458L1.167 3.625L2.396 2.396L17.583 17.604ZM17 14.562 5.458 3Q6.458 2.354 7.594 2.01Q8.729 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.271 17.979 12.417Q17.625 13.562 17 14.562Z"/></svg>', Qa = '<svg viewBox="0 -960 960 960" width="24px"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Zm-40-60v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"/></svg>', Se = ["transparent", "black", "white", "red", "green", "blue", "yellow"], Ue = [0, 1, 2], Ci = [[1, 0], [1, 2], [4, 6]], ft = "serif", Qn = 2, ba = 3, bn = 4, ce = "react-paint-", wa = { strokeColor: { values: Se, default: "black" }, fillColor: { values: Se, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 } }, ri = { type: "picture", id: `${ce}picture`, icon: si, label: "Image", settings: { opacity: { min: 0, max: 100, step: 1, default: 100 } } }, xa = { type: "brush", id: `${ce}brush`, icon: va, label: "Brosse", settings: { strokeColor: { values: Se, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 6, max: 20, step: 2, default: 10 }, lineDash: { values: Ue, default: 0 } } }, Ca = { type: "line", id: `${ce}line`, icon: ya, label: "Ligne", settings: { strokeColor: { values: Se, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 }, lineArrow: { values: [0, 1, 2, 3], default: 0 } } }, Ma = { type: "polygon", id: `${ce}polygon`, icon: oi, label: "Polygone", settings: { strokeColor: { values: Se, default: "black" }, fillColor: { values: Se, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 }, closedPoints: { default: 0 } } }, ka = { type: "curve", id: `${ce}curve`, icon: Sa, label: "Courbe", settings: { strokeColor: { values: Se, default: "black" }, fillColor: { values: Se, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 }, closedPoints: { default: 0 } } }, Pa = { type: "rect", id: `${ce}rect`, icon: ai, label: "Rectangle", settings: wa }, La = { type: "square", id: `${ce}square`, icon: ai, label: "Carré", settings: { strokeColor: { values: Se, default: "black" }, fillColor: { values: Se, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 } } }, Va = { type: "circle", id: `${ce}circle`, icon: ni, label: "Cercle", settings: { strokeColor: { values: Se, default: "black" }, fillColor: { values: Se, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 } } }, Za = { type: "ellipse", id: `${ce}ellipse`, icon: ni, label: "Ellipse", settings: { strokeColor: { values: Se, default: "black" }, fillColor: { values: Se, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 } } }, Ha = { type: "text", id: `${ce}text`, icon: ma, label: "Texte", settings: { strokeColor: { values: Se, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, fontFamily: { values: ["arial", "serif", "monospace"], default: ft }, fontBold: { values: [!1, !0], default: !1 }, fontItalic: { values: [!1, !0], default: !1 } } }, Be = { id: `${ce}selection`, type: "selection", icon: '<svg><path d="M8.0145 11.1707C8.38484 10.9914 8.82183 11.1558 8.99959 11.5295L10.7031 15.2591L12.0363 14.6238L10.3254 10.9017C10.1476 10.528 10.3106 10.0795 10.6809 9.90761L10.8883 9.84782L12.5918 9.51148L6.48133 4.33192V12.389L7.82934 11.2903L8.0145 11.1707ZM10.6587 16.9258C10.2883 17.1052 9.84395 16.9482 9.67359 16.5745L8.05894 13.0318L6.19988 14.5416C6.07396 14.6462 5.91842 14.706 5.74066 14.706C5.54423 14.706 5.35584 14.6272 5.21694 14.4871C5.07803 14.3469 5 14.1568 5 13.9586V2.74741C5 2.54919 5.07803 2.35908 5.21694 2.21891C5.35584 2.07874 5.54423 2 5.74066 2C5.91842 2 6.08878 2.06727 6.21469 2.1719L6.2221 2.16443L14.7323 9.36947C15.0508 9.63854 15.0879 10.1094 14.8286 10.4233C14.7175 10.5579 14.562 10.6475 14.4064 10.6774L12.0659 11.1408L13.6954 14.6761C13.888 15.0498 13.7102 15.4908 13.3399 15.6627L10.6587 16.9258Z"/></svg>', label: "Sélection" }, at = { id: `${ce}undo`, type: "undo", icon: '<svg><path d="M11.708 15.833H5.854V14.083H11.708Q13 14.083 13.958 13.292Q14.917 12.5 14.917 11.271Q14.917 10.042 13.958 9.24Q13 8.438 11.708 8.438H6.667L8.792 10.562L7.562 11.792L3.333 7.562L7.562 3.333L8.792 4.562L6.667 6.688H11.708Q13.729 6.688 15.198 7.99Q16.667 9.292 16.667 11.25Q16.667 13.208 15.198 14.521Q13.729 15.833 11.708 15.833Z"/></svg>', label: "Undo" }, nt = { id: `${ce}redo`, type: "redo", icon: '<svg><path d="M8.292 15.833Q6.271 15.833 4.802 14.521Q3.333 13.208 3.333 11.25Q3.333 9.292 4.802 7.99Q6.271 6.688 8.292 6.688H13.333L11.208 4.562L12.438 3.333L16.667 7.562L12.438 11.792L11.208 10.562L13.333 8.438H8.292Q7 8.438 6.042 9.229Q5.083 10.021 5.083 11.25Q5.083 12.5 6.042 13.292Q7 14.083 8.292 14.083H14.146V15.833Z"/></svg>', label: "Redo" }, ot = { id: `${ce}clear`, type: "clear", icon: '<svg><path d="M7.854 13.812 10 11.688 12.125 13.812 13.354 12.604 11.208 10.458 13.354 8.312 12.125 7.104 10 9.229 7.854 7.104 6.625 8.312 8.771 10.458 6.625 12.604ZM5.896 17.5Q5.167 17.5 4.656 16.99Q4.146 16.479 4.146 15.75V5.125H3.333V3.375H7.542V2.5H12.458V3.375H16.667V5.125H15.833V15.75Q15.833 16.479 15.323 16.99Q14.812 17.5 14.083 17.5Z"/></svg>', label: "Clear" }, Ft = { id: `${ce}export`, type: "export", icon: '<svg><path d="M10 13.271 5.708 8.979 6.958 7.729 9.125 9.896V3.333H10.875V9.896L13.042 7.729L14.292 8.979ZM5.083 16.667Q4.354 16.667 3.844 16.156Q3.333 15.646 3.333 14.917V12.5H5.083V14.917Q5.083 14.917 5.083 14.917Q5.083 14.917 5.083 14.917H14.917Q14.917 14.917 14.917 14.917Q14.917 14.917 14.917 14.917V12.5H16.667V14.917Q16.667 15.646 16.156 16.156Q15.646 16.667 14.917 16.667Z"/></svg>', label: "Export PNG" }, Mi = { id: `${ce}load`, type: "loadfile", icon: '<svg><path d="M3.417 16.667Q2.729 16.667 2.198 16.135Q1.667 15.604 1.667 14.917V5.083Q1.667 4.396 2.198 3.865Q2.729 3.333 3.417 3.333H8.25L9.917 5H16.667Q17.354 5 17.844 5.531Q18.333 6.062 18.333 6.75H3.417V14.917Q3.417 14.917 3.417 14.917Q3.417 14.917 3.417 14.917L5.438 8.5H19.583L17.396 15.479Q17.229 16.021 16.802 16.344Q16.375 16.667 15.833 16.667Z"/></svg>', label: "Load project" }, Bt = { id: `${ce}save`, type: "savefile", icon: '<svg><path d="M17.5 5.833V15.75Q17.5 16.479 16.99 16.99Q16.479 17.5 15.75 17.5H4.25Q3.521 17.5 3.01 16.99Q2.5 16.479 2.5 15.75V4.25Q2.5 3.521 3.01 3.01Q3.521 2.5 4.25 2.5H14.167ZM10 14.917Q11.062 14.917 11.823 14.156Q12.583 13.396 12.583 12.333Q12.583 11.271 11.823 10.51Q11.062 9.75 10 9.75Q8.938 9.75 8.177 10.51Q7.417 11.271 7.417 12.333Q7.417 13.396 8.177 14.156Q8.938 14.917 10 14.917ZM5.021 8.396H12.521V5.021H5.021Z"/></svg>', label: "Save project" }, $t = { id: `${ce}move`, type: "move", icon: '<svg viewBox="0 -960 960 960"><path d="M412-48q-21.95 0-40.98-9Q352-66 338-83L48-434l27-28q17-17 41.5-20.5T162-473l126 74v-381q0-15.3 10.29-25.65Q308.58-816 323.79-816t25.71 10.35Q360-795.3 360-780v300h80v-396q0-15.3 10.29-25.65Q460.58-912 475.79-912t25.71 10.35Q512-891.3 512-876v396h80v-348q0-15.3 10.29-25.65Q612.58-864 627.79-864t25.71 10.35Q664-843.3 664-828v348h80v-252q0-15.3 10.29-25.65Q764.58-768 779.79-768t25.71 10.35Q816-747.3 816-732v540q0 60-42 102T672-48H412Z"/></svg>', label: "Move" }, ki = { id: `${ce}upload-picture`, type: "uploadpicture", icon: si, label: "Upload picture" }, Ta = 2, za = "blue", je = 14, Aa = [[0, 0], [0.5, 0], [1, 0], [1, 0.5], [1, 1], [0.5, 1], [0, 1], [0, 0.5]], Ea = ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle", "group"], Da = "react-paint-canvas-drawcanvas", Na = "react-paint-canvas-selectioncanvas", Pi = { layersManipulation: !0, grid: 0, canGrow: !1, canShrink: !0, withExport: !0, withLoadAndSave: !0, withUploadPicture: !0, withUrlPicture: !1, availableTools: [xa, Ca, Ma, ka, Pa, La, Va, Za, ri, Ha], clearCallback: "empty", brushAlgo: "simple", isBrushShapeDoneOnMouseUp: !0, withFrameSelection: !0, withSkeleton: !0, canvasSelectionPadding: 0, size: "fixed", canZoom: "never" }, wn = { canvasBackgroundColor: "white", canvasSelectionColor: za, canvasSelectionWidth: Ta }, Wa = (e, t) => !!(e.target instanceof Node && t) && t.contains(e.target), Li = 300, _t = (e, t) => {
1
+ import si, { useState as $, useEffect as J, useRef as te, useCallback as B, useMemo as ba, useImperativeHandle as xa, useTransition as wa } from "react";
2
+ import { jsx as v, jsxs as Y, Fragment as Ve } from "react/jsx-runtime";
3
+ const Ca = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.708Q2.208 15.75 2.802 15.344Q3.396 14.938 3.396 14.104Q3.396 13.042 4.135 12.292Q4.875 11.542 5.958 11.542Q7.021 11.542 7.76 12.292Q8.5 13.042 8.5 14.104Q8.5 15.5 7.51 16.5Q6.521 17.5 5.146 17.5ZM9.917 12.5 7.562 10.146 14.917 2.729Q15.146 2.5 15.469 2.5Q15.792 2.5 16.021 2.729L17.271 3.958Q17.5 4.188 17.5 4.531Q17.5 4.875 17.271 5.125Z"/></svg>', ri = '<svg><path d="M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z"/></svg>', li = '<svg><path d="M10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.271 2.323 6.75Q2.979 5.229 4.104 4.104Q5.229 2.979 6.75 2.323Q8.271 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.729 17.677 13.25Q17.021 14.771 15.896 15.896Q14.771 17.021 13.25 17.677Q11.729 18.333 10 18.333ZM10 16.583Q12.75 16.583 14.667 14.667Q16.583 12.75 16.583 10Q16.583 7.25 14.667 5.333Q12.75 3.417 10 3.417Q7.25 3.417 5.333 5.333Q3.417 7.25 3.417 10Q3.417 12.75 5.333 14.667Q7.25 16.583 10 16.583ZM10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Z"/></svg>', ci = '<svg><path d="M12.25 18.333V16.167L6.833 13.458H2.5V8.208H6.25L8.25 5.917V1.667H13.5V6.917H9.708L7.75 9.146V11.958L12.25 14.208V13.083H17.5V18.333Z"/></svg>', Ma = '<svg><path d="M4.125 5.083V3.333H7.062L7.896 2.5H12.104L12.938 3.333H15.875V5.083ZM6.75 17.5Q6.021 17.5 5.51 16.99Q5 16.479 5 15.75V5.958H15V15.75Q15 16.479 14.49 16.99Q13.979 17.5 13.25 17.5Z"/></svg>', Li = '<svg><path d="M10 17.5Q7.208 17.5 5.271 15.594Q3.333 13.688 3.333 10.958Q3.333 9.583 3.854 8.396Q4.375 7.208 5.292 6.292L10 1.667L14.688 6.292Q15.604 7.208 16.135 8.396Q16.667 9.583 16.667 10.958Q16.667 13.688 14.719 15.594Q12.771 17.5 10 17.5ZM5.146 11.667H14.854Q15.083 10.188 14.552 9.146Q14.021 8.104 13.479 7.562L10 4.125L6.521 7.562Q5.979 8.104 5.448 9.146Q4.917 10.188 5.146 11.667Z"/></svg>', di = '<svg><path d="M4.792 15.083 8.333 11.542 9.833 13.021 11.667 10.708 15.167 15.083ZM6.667 8.417Q5.938 8.417 5.427 7.906Q4.917 7.396 4.917 6.667Q4.917 5.938 5.427 5.427Q5.938 4.917 6.667 4.917Q7.396 4.917 7.906 5.427Q8.417 5.938 8.417 6.667Q8.417 7.396 7.906 7.906Q7.396 8.417 6.667 8.417ZM4.167 18.333Q3.125 18.333 2.396 17.604Q1.667 16.875 1.667 15.833V4.167Q1.667 3.125 2.396 2.396Q3.125 1.667 4.167 1.667H15.833Q16.875 1.667 17.604 2.396Q18.333 3.125 18.333 4.167V15.833Q18.333 16.875 17.604 17.604Q16.875 18.333 15.833 18.333ZM4.167 16.583H15.833Q16.146 16.583 16.365 16.365Q16.583 16.146 16.583 15.833V4.167Q16.583 3.854 16.365 3.635Q16.146 3.417 15.833 3.417H4.167Q3.854 3.417 3.635 3.635Q3.417 3.854 3.417 4.167V15.833Q3.417 16.146 3.635 16.365Q3.854 16.583 4.167 16.583Z"/></svg>', ka = '<svg><path d="M8.708 16.667V5.917H4.167V3.333H15.833V5.917H11.292V16.667Z"/></svg>', Pa = '<svg><path d="M7.5 15.833V14.083H12.833L3.333 4.583L4.583 3.333L14.083 12.833V7.5H15.833V15.833Z"/></svg>', La = '<svg><path d="M7.521 17.5Q6.125 17.5 5.146 16.51Q4.167 15.521 4.167 14.125V7.417Q3.438 7.125 2.969 6.49Q2.5 5.854 2.5 5.042Q2.5 3.979 3.24 3.24Q3.979 2.5 5.042 2.5Q6.104 2.5 6.844 3.24Q7.583 3.979 7.583 5.042Q7.583 5.854 7.115 6.49Q6.646 7.125 5.917 7.417V14.125Q5.917 14.792 6.385 15.271Q6.854 15.75 7.521 15.75Q8.188 15.75 8.656 15.271Q9.125 14.792 9.125 14.125V5.875Q9.125 4.479 10.104 3.49Q11.083 2.5 12.479 2.5Q13.875 2.5 14.854 3.49Q15.833 4.479 15.833 5.875V12.583Q16.562 12.875 17.031 13.51Q17.5 14.146 17.5 14.958Q17.5 16.021 16.76 16.76Q16.021 17.5 14.958 17.5Q13.896 17.5 13.156 16.76Q12.417 16.021 12.417 14.958Q12.417 14.146 12.885 13.5Q13.354 12.854 14.083 12.583V5.875Q14.083 5.208 13.615 4.729Q13.146 4.25 12.479 4.25Q11.812 4.25 11.344 4.729Q10.875 5.208 10.875 5.875V14.125Q10.875 15.521 9.896 16.51Q8.917 17.5 7.521 17.5Z"/></svg>', Zi = '<svg><path d="M5.833 15V3.333H10.375Q11.812 3.333 12.885 4.156Q13.958 4.979 13.958 6.375Q13.958 7.375 13.49 7.969Q13.021 8.562 12.396 8.875V9.042Q13.312 9.354 13.844 10.021Q14.375 10.688 14.375 11.75Q14.375 13.312 13.229 14.156Q12.083 15 10.5 15ZM8.125 8.042H10.188Q10.854 8.042 11.302 7.656Q11.75 7.271 11.75 6.708Q11.75 6.167 11.302 5.771Q10.854 5.375 10.188 5.375H8.125ZM8.125 12.917H10.354Q11.167 12.917 11.625 12.51Q12.083 12.104 12.083 11.458Q12.083 10.812 11.625 10.406Q11.167 10 10.354 10H8.125Z"/></svg>', Vi = '<svg><path d="M4.167 16.667V14.083H6.979L10.229 5.917H7.5V3.333H15.833V5.917H13.021L9.771 14.083H12.5V16.667Z"/></svg>', Hi = '<svg><path d="M3.021 16V15H17V16ZM3.021 13.5V12H17V13.5ZM3 10.5V8.5H16.979V10.5ZM3.021 7V4H17V7Z"/></svg>', Ti = '<svg><path d="M16.354 18.833 14.521 17Q13.542 17.646 12.396 17.99Q11.25 18.333 10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.729 2.01 7.594Q2.354 6.458 3 5.458L1.167 3.625L2.396 2.396L17.583 17.604ZM10 16.583Q10.896 16.583 11.708 16.365Q12.521 16.146 13.25 15.729L4.292 6.75Q3.875 7.479 3.646 8.292Q3.417 9.104 3.417 10Q3.417 12.729 5.344 14.656Q7.271 16.583 10 16.583ZM17 14.562 15.708 13.271Q16.125 12.542 16.354 11.719Q16.583 10.896 16.583 10Q16.583 7.271 14.656 5.344Q12.729 3.417 10 3.417Q9.104 3.417 8.292 3.646Q7.479 3.875 6.75 4.292L5.458 3Q6.458 2.354 7.594 2.01Q8.729 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.271 17.979 12.417Q17.625 13.562 17 14.562ZM11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771ZM8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Z"/></svg>', zi = '<svg><path d="M16.354 18.833 14.521 17Q13.542 17.646 12.396 17.99Q11.25 18.333 10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.729 2.01 7.594Q2.354 6.458 3 5.458L1.167 3.625L2.396 2.396L17.583 17.604ZM17 14.562 5.458 3Q6.458 2.354 7.594 2.01Q8.729 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.271 17.979 12.417Q17.625 13.562 17 14.562Z"/></svg>', Za = '<svg viewBox="0 -960 960 960" width="24px"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Zm-40-60v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"/></svg>', we = ["transparent", "black", "white", "red", "green", "blue", "yellow"], Ge = [0, 1, 2], Ai = [[1, 0], [1, 2], [4, 6]], yt = "serif", An = 2, Va = 3, En = 4, ue = "react-paint-", Ha = { strokeColor: { values: we, default: "black" }, fillColor: { values: we, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ge, default: 0 } }, hi = { type: "picture", id: `${ue}picture`, icon: di, label: "Image", settings: { opacity: { min: 0, max: 100, step: 1, default: 100 } } }, Ta = { type: "brush", id: `${ue}brush`, icon: Ca, label: "Brosse", settings: { strokeColor: { values: we, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 6, max: 20, step: 2, default: 10 }, lineDash: { values: Ge, default: 0 } } }, za = { type: "line", id: `${ue}line`, icon: Pa, label: "Ligne", settings: { strokeColor: { values: we, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ge, default: 0 }, lineArrow: { values: [0, 1, 2, 3], default: 0 } } }, Aa = { type: "polygon", id: `${ue}polygon`, icon: ci, label: "Polygone", settings: { strokeColor: { values: we, default: "black" }, fillColor: { values: we, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ge, default: 0 }, closedPoints: { default: 0 } } }, Ea = { type: "curve", id: `${ue}curve`, icon: La, label: "Courbe", settings: { strokeColor: { values: we, default: "black" }, fillColor: { values: we, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ge, default: 0 }, closedPoints: { default: 0 } } }, Ia = { type: "rect", id: `${ue}rect`, icon: ri, label: "Rectangle", settings: Ha }, Na = { type: "square", id: `${ue}square`, icon: ri, label: "Carré", settings: { strokeColor: { values: we, default: "black" }, fillColor: { values: we, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ge, default: 0 } } }, Da = { type: "circle", id: `${ue}circle`, icon: li, label: "Cercle", settings: { strokeColor: { values: we, default: "black" }, fillColor: { values: we, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ge, default: 0 } } }, Ra = { type: "ellipse", id: `${ue}ellipse`, icon: li, label: "Ellipse", settings: { strokeColor: { values: we, default: "black" }, fillColor: { values: we, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ge, default: 0 } } }, Wa = { type: "text", id: `${ue}text`, icon: ka, label: "Texte", settings: { strokeColor: { values: we, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, fontFamily: { values: ["arial", "serif", "monospace"], default: yt }, fontBold: { values: [!1, !0], default: !1 }, fontItalic: { values: [!1, !0], default: !1 } } }, Fe = { id: `${ue}selection`, type: "selection", icon: '<svg><path d="M8.0145 11.1707C8.38484 10.9914 8.82183 11.1558 8.99959 11.5295L10.7031 15.2591L12.0363 14.6238L10.3254 10.9017C10.1476 10.528 10.3106 10.0795 10.6809 9.90761L10.8883 9.84782L12.5918 9.51148L6.48133 4.33192V12.389L7.82934 11.2903L8.0145 11.1707ZM10.6587 16.9258C10.2883 17.1052 9.84395 16.9482 9.67359 16.5745L8.05894 13.0318L6.19988 14.5416C6.07396 14.6462 5.91842 14.706 5.74066 14.706C5.54423 14.706 5.35584 14.6272 5.21694 14.4871C5.07803 14.3469 5 14.1568 5 13.9586V2.74741C5 2.54919 5.07803 2.35908 5.21694 2.21891C5.35584 2.07874 5.54423 2 5.74066 2C5.91842 2 6.08878 2.06727 6.21469 2.1719L6.2221 2.16443L14.7323 9.36947C15.0508 9.63854 15.0879 10.1094 14.8286 10.4233C14.7175 10.5579 14.562 10.6475 14.4064 10.6774L12.0659 11.1408L13.6954 14.6761C13.888 15.0498 13.7102 15.4908 13.3399 15.6627L10.6587 16.9258Z"/></svg>', label: "Sélection" }, rt = { id: `${ue}undo`, type: "undo", icon: '<svg><path d="M11.708 15.833H5.854V14.083H11.708Q13 14.083 13.958 13.292Q14.917 12.5 14.917 11.271Q14.917 10.042 13.958 9.24Q13 8.438 11.708 8.438H6.667L8.792 10.562L7.562 11.792L3.333 7.562L7.562 3.333L8.792 4.562L6.667 6.688H11.708Q13.729 6.688 15.198 7.99Q16.667 9.292 16.667 11.25Q16.667 13.208 15.198 14.521Q13.729 15.833 11.708 15.833Z"/></svg>', label: "Undo" }, lt = { id: `${ue}redo`, type: "redo", icon: '<svg><path d="M8.292 15.833Q6.271 15.833 4.802 14.521Q3.333 13.208 3.333 11.25Q3.333 9.292 4.802 7.99Q6.271 6.688 8.292 6.688H13.333L11.208 4.562L12.438 3.333L16.667 7.562L12.438 11.792L11.208 10.562L13.333 8.438H8.292Q7 8.438 6.042 9.229Q5.083 10.021 5.083 11.25Q5.083 12.5 6.042 13.292Q7 14.083 8.292 14.083H14.146V15.833Z"/></svg>', label: "Redo" }, ct = { id: `${ue}clear`, type: "clear", icon: '<svg><path d="M7.854 13.812 10 11.688 12.125 13.812 13.354 12.604 11.208 10.458 13.354 8.312 12.125 7.104 10 9.229 7.854 7.104 6.625 8.312 8.771 10.458 6.625 12.604ZM5.896 17.5Q5.167 17.5 4.656 16.99Q4.146 16.479 4.146 15.75V5.125H3.333V3.375H7.542V2.5H12.458V3.375H16.667V5.125H15.833V15.75Q15.833 16.479 15.323 16.99Q14.812 17.5 14.083 17.5Z"/></svg>', label: "Clear" }, Yt = { id: `${ue}export`, type: "export", icon: '<svg><path d="M10 13.271 5.708 8.979 6.958 7.729 9.125 9.896V3.333H10.875V9.896L13.042 7.729L14.292 8.979ZM5.083 16.667Q4.354 16.667 3.844 16.156Q3.333 15.646 3.333 14.917V12.5H5.083V14.917Q5.083 14.917 5.083 14.917Q5.083 14.917 5.083 14.917H14.917Q14.917 14.917 14.917 14.917Q14.917 14.917 14.917 14.917V12.5H16.667V14.917Q16.667 15.646 16.156 16.156Q15.646 16.667 14.917 16.667Z"/></svg>', label: "Export PNG" }, Ei = { id: `${ue}load`, type: "loadfile", icon: '<svg><path d="M3.417 16.667Q2.729 16.667 2.198 16.135Q1.667 15.604 1.667 14.917V5.083Q1.667 4.396 2.198 3.865Q2.729 3.333 3.417 3.333H8.25L9.917 5H16.667Q17.354 5 17.844 5.531Q18.333 6.062 18.333 6.75H3.417V14.917Q3.417 14.917 3.417 14.917Q3.417 14.917 3.417 14.917L5.438 8.5H19.583L17.396 15.479Q17.229 16.021 16.802 16.344Q16.375 16.667 15.833 16.667Z"/></svg>', label: "Load project" }, Ut = { id: `${ue}save`, type: "savefile", icon: '<svg><path d="M17.5 5.833V15.75Q17.5 16.479 16.99 16.99Q16.479 17.5 15.75 17.5H4.25Q3.521 17.5 3.01 16.99Q2.5 16.479 2.5 15.75V4.25Q2.5 3.521 3.01 3.01Q3.521 2.5 4.25 2.5H14.167ZM10 14.917Q11.062 14.917 11.823 14.156Q12.583 13.396 12.583 12.333Q12.583 11.271 11.823 10.51Q11.062 9.75 10 9.75Q8.938 9.75 8.177 10.51Q7.417 11.271 7.417 12.333Q7.417 13.396 8.177 14.156Q8.938 14.917 10 14.917ZM5.021 8.396H12.521V5.021H5.021Z"/></svg>', label: "Save project" }, Xt = { id: `${ue}move`, type: "move", icon: '<svg viewBox="0 -960 960 960"><path d="M412-48q-21.95 0-40.98-9Q352-66 338-83L48-434l27-28q17-17 41.5-20.5T162-473l126 74v-381q0-15.3 10.29-25.65Q308.58-816 323.79-816t25.71 10.35Q360-795.3 360-780v300h80v-396q0-15.3 10.29-25.65Q460.58-912 475.79-912t25.71 10.35Q512-891.3 512-876v396h80v-348q0-15.3 10.29-25.65Q612.58-864 627.79-864t25.71 10.35Q664-843.3 664-828v348h80v-252q0-15.3 10.29-25.65Q764.58-768 779.79-768t25.71 10.35Q816-747.3 816-732v540q0 60-42 102T672-48H412Z"/></svg>', label: "Move" }, Ii = { id: `${ue}upload-picture`, type: "uploadpicture", icon: di, label: "Upload picture" }, Oa = 2, Fa = "blue", et = 14, Ba = [[0, 0], [0.5, 0], [1, 0], [1, 0.5], [1, 1], [0.5, 1], [0, 1], [0, 0.5]], $a = ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle", "group"], Ya = "react-paint-canvas-drawcanvas", Ua = "react-paint-canvas-selectioncanvas", Ni = { layersManipulation: !0, grid: 0, canGrow: !1, canShrink: !0, withExport: !0, withLoadAndSave: !0, withUploadPicture: !0, withUrlPicture: !1, availableTools: [Ta, za, Aa, Ea, Ia, Na, Da, Ra, hi, Wa], clearCallback: "empty", brushAlgo: "simple", isBrushShapeDoneOnMouseUp: !0, withFrameSelection: !0, withSkeleton: !0, canvasSelectionPadding: 0, size: "fixed", canZoom: "never", debug: !1 }, In = { canvasBackgroundColor: "white", canvasSelectionColor: Fa, canvasSelectionWidth: Oa }, Di = 300, Jt = (e, t) => {
4
4
  const i = { ...t };
5
5
  for (const a of e) delete i[a];
6
6
  return i;
7
- }, Ce = (e, t, i) => {
7
+ }, Pe = (e, t, i) => {
8
8
  const a = Array.isArray(i) ? [...i] : { ...i }, n = Array.isArray(e) ? e : typeof e == "string" ? e.split(".") : [e];
9
- return n.reduce((o, s, l) => (o[s] = jt(o[s]) ? { ...o[s] } : Array.isArray(o[s]) ? [...o[s]] : o[s] === void 0 || o[s] === null ? {} : o[s], l === n.length - 1 && (o[s] = t), o[s]), a), a;
10
- }, jt = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, Ee = (e, t, i) => {
11
- if (!jt(t) || !jt(i)) return i;
9
+ return n.reduce((o, r, l) => (o[r] = ei(o[r]) ? { ...o[r] } : Array.isArray(o[r]) ? [...o[r]] : o[r] === void 0 || o[r] === null ? {} : o[r], l === n.length - 1 && (o[r] = t), o[r]), a), a;
10
+ }, ei = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, Ne = (e, t, i) => {
11
+ if (!ei(t) || !ei(i)) return i;
12
12
  const a = { ...t };
13
- for (const n in i) i.hasOwnProperty(n) && (a.hasOwnProperty(n) ? a[n] = e(a[n], i[n], n) ?? Ee(e, a[n], i[n]) : a[n] = i[n]);
13
+ for (const n in i) i.hasOwnProperty(n) && (a.hasOwnProperty(n) ? a[n] = e(a[n], i[n], n) ?? Ne(e, a[n], i[n]) : a[n] = i[n]);
14
14
  return a;
15
- }, Ia = (e, t) => {
15
+ }, Xa = (e, t) => {
16
16
  if (e === t) return !0;
17
17
  if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1;
18
18
  const i = Object.keys(e), a = Object.keys(t);
19
19
  if (i.length !== a.length) return !1;
20
- for (const n of i) if (!a.includes(n) || !Ia(e[n], t[n])) return !1;
20
+ for (const n of i) if (!a.includes(n) || !Xa(e[n], t[n])) return !1;
21
21
  return !0;
22
- }, Ut = {}, me = (e = "") => (Ut[e] || (Ut[e] = 0), `${e}${++Ut[e]}`), De = (e, t, i) => Math.max(t, Math.min(e, i)), Ra = () => typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), Oa = (e) => {
22
+ }, Gt = {}, ye = (e = "") => (Gt[e] || (Gt[e] = 0), `${e}${++Gt[e]}`), De = (e, t, i) => Math.max(t, Math.min(e, i)), Ga = () => typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), qa = (e) => {
23
23
  e.reset(), e.lineCap = "round", e.lineJoin = "round";
24
- }, Ve = (e, t = {}) => {
25
- const { lineCap: i = "round", fillColor: a = "transparent", opacity: n = 100, strokeColor: o = za, lineWidth: s = Ta, lineDash: l = 0, shadowColor: r = "transparent", shadowBlur: d = 0 } = t;
26
- e.lineCap = i, e.globalAlpha = n / 100, e.fillStyle = a, e.strokeStyle = o, e.lineWidth = s, e.setLineDash(l === 0 ? [] : [Ci[l][0] * s, Ci[l][1] * s]), e.shadowColor = r, e.shadowBlur = d;
24
+ }, Qe = (e, t = {}) => {
25
+ const { lineCap: i = "round", fillColor: a = "transparent", opacity: n = 100, strokeColor: o = Fa, lineWidth: r = Oa, lineDash: l = 0, shadowColor: s = "transparent", shadowBlur: c = 0 } = t;
26
+ e.lineCap = i, e.globalAlpha = n / 100, e.fillStyle = a, e.strokeStyle = o, e.lineWidth = r, e.setLineDash(l === 0 ? [] : [Ai[l][0] * r, Ai[l][1] * r]), e.shadowColor = s, e.shadowBlur = c;
27
27
  }, Pt = (e, t, i, a) => {
28
28
  e.save(), e.scale(t.canvasSize.scaleRatio, t.canvasSize.scaleRatio), e.translate(t.canvasOffset[0], t.canvasOffset[1]), i && a && (e.translate(a[0], a[1]), e.rotate(i), e.translate(-a[0], -a[1]));
29
- }, rt = (e, t) => {
30
- const i = kn(e, t);
31
- return { ...e, path: i, selection: lt(i, e, t) };
32
- }, xn = rt, Kt = (e) => 180 * e / Math.PI, Fa = (e, t) => {
29
+ }, _a = (e, { selectionPadding: t }) => {
30
+ const i = e.points.flat(), a = Math.min(...i.map((s) => s[0])), n = Math.min(...i.map((s) => s[1])), o = i.map((s) => ze(s, a, n, e.scaleX, e.scaleY)), r = Math.max(...o.map((s) => s[0])) + t, l = Math.max(...o.map((s) => s[1])) + t;
31
+ return { x: a - t, width: r - a + t, y: n - t, height: l - n + t };
32
+ }, ja = (e, t) => Re(e, _a, t), ht = (e, t) => {
33
+ const i = Wn(e, t), a = ja(e, t);
34
+ return { ...e, path: i, selection: ut(i, a, t), computed: a };
35
+ }, Nn = ht, ti = (e) => 180 * e / Math.PI, Ka = (e, t) => {
33
36
  const i = t.x - Math.min(Math.max(t.x, e.x), e.x + e.width), a = t.y - Math.min(Math.max(t.y, e.y), e.y + e.height);
34
37
  return Math.sqrt(i * i + a * a) <= t.radius;
35
- }, Me = ({ origin: e = [0, 0], point: t, rotation: i }) => {
38
+ }, xe = ({ origin: e = [0, 0], point: t, rotation: i = 0 }) => {
36
39
  const a = [t[0] - e[0], t[1] - e[1]], n = a[1] * Math.cos(i) - a[0] * Math.sin(i);
37
40
  return [a[1] * Math.sin(i) + a[0] * Math.cos(i) + e[0], n + e[1]];
38
- }, Vi = (e) => (e + 2 * Math.PI) % (2 * Math.PI), Zi = ({ targetVector: [e, t], radian: i = !0, originVector: a }) => {
39
- const n = Vi(Math.atan2(t[1] - e[1], t[0] - e[0]));
41
+ }, Ri = (e) => (e + 2 * Math.PI) % (2 * Math.PI), Wi = ({ targetVector: [e, t], radian: i = !0, originVector: a }) => {
42
+ const n = Ri(Math.atan2(t[1] - e[1], t[0] - e[0]));
40
43
  if (a) {
41
- const [o, s] = a, l = Math.atan2(s[1] - o[1], s[0] - o[0]), r = Vi(n - l);
42
- return i ? r : Kt(r);
44
+ const [o, r] = a, l = Math.atan2(r[1] - o[1], r[0] - o[0]), s = Ri(n - l);
45
+ return i ? s : ti(s);
43
46
  }
44
- return i ? n : Kt(n);
45
- }, Ba = (e, t) => Math.sqrt((e[0] - t[0]) ** 2 + (e[1] - t[1]) ** 2), $e = (e, t = 2) => Math.round(e * 10 ** t) / 10 ** t, Ze = (e, t, i, a = 1, n = 1) => [t + (e[0] - t) * a, i + (e[1] - i) * n], Y = (e, t, i = 0) => {
46
- if (!t.gridGap) return $e(e);
47
+ return i ? n : ti(n);
48
+ }, Ja = (e, t) => Math.sqrt((e[0] - t[0]) ** 2 + (e[1] - t[1]) ** 2), Xe = (e, t = 2) => Math.round(e * 10 ** t) / 10 ** t, ze = (e, t, i, a = 1, n = 1) => [t + (e[0] - t) * a, i + (e[1] - i) * n], _ = (e, t, i = 0) => {
49
+ if (!t.gridGap) return Xe(e);
47
50
  const a = e + i, n = a >= 0 ? t.gridGap : -t.gridGap;
48
51
  return a + n / 2 - (a + n / 2) % n - i;
49
- }, Cn = (e, t, i) => t.gridGap || i ? e + Math.PI / 18 / 2 - (e + Math.PI / 18 / 2) % (Math.PI / 18) : $e(e, 3), Fe = (e, t) => t ? [Math.abs(e[0]) > Math.abs(e[1]) ? e[0] : 0, Math.abs(e[1]) > Math.abs(e[0]) ? e[1] : 0] : e, Mn = (e, t, i, a, n, o, s) => ye(q(t).map((l) => {
52
+ }, Dn = (e, t, i) => t.gridGap || i ? e + Math.PI / 18 / 2 - (e + Math.PI / 18 / 2) % (Math.PI / 18) : Xe(e, 3), Oe = (e, t) => t ? [Math.abs(e[0]) > Math.abs(e[1]) ? e[0] : 0, Math.abs(e[1]) > Math.abs(e[0]) ? e[1] : 0] : e, Rn = (e, t, i, a, n, o, r) => be(j(t).map((l) => {
50
53
  switch (a.mode) {
51
54
  case "brush":
52
- return ((r, d, h) => {
53
- const c = { ...r, points: Ce(r.points.length - 1, [...r.points[r.points.length - 1], [Math.round(d[0]), Math.round(d[1])]], r.points) };
54
- return rt(c, h);
55
+ return ((s, c, u) => {
56
+ const d = { ...s, points: Pe(s.points.length - 1, [...s.points[s.points.length - 1], [Math.round(c[0]), Math.round(c[1])]], s.points) };
57
+ return ht(d, u);
55
58
  })(l, i, n);
56
59
  case "translate":
57
- return ii(i, q(a.originalShape).find((r) => r.id === l.id), a.cursorStartPosition, n, o);
60
+ return oi(i, j(a.originalShape).find((s) => s.id === l.id), a.cursorStartPosition, n, o);
58
61
  case "rotate":
59
- return Xn(l, i, q(a.originalShape).find((r) => r.id === l.id), a.cursorStartPosition, a.center, n, o);
62
+ return go(l, i, j(a.originalShape).find((s) => s.id === l.id), a.cursorStartPosition, a.center, n, o);
60
63
  case "resize":
61
- return Gn(e, l, i, q(a.originalShape).find((r) => r.id === l.id), a, n, o, s);
64
+ return vo(e, l, i, j(a.originalShape).find((s) => s.id === l.id), a, n, o, r);
62
65
  default:
63
66
  return l;
64
67
  }
65
- }), n), li = (e) => {
68
+ }), n), ui = (e) => {
66
69
  const t = new Path2D();
67
70
  return t.rect(e.x, e.y, e.width, e.height), t;
68
71
  }, Lt = (e) => {
69
72
  const t = new Path2D();
70
73
  return t.arc(e.x, e.y, e.radius, 0, 2 * Math.PI), t;
71
- }, Vt = (e) => {
74
+ }, Zt = (e) => {
72
75
  const t = new Path2D();
73
76
  return t.moveTo(...e.points[0]), t.lineTo(...e.points[1]), t;
74
- }, kn = (e, { brushAlgo: t }) => {
77
+ }, Wn = (e, { brushAlgo: t }) => {
75
78
  if (e.points.length < 1 || e.style?.strokeColor === "transparent") return;
76
- const i = e.points.flat(), a = i.map((r) => r[0]), n = i.map((r) => r[1]), o = Math.min(...a), s = Math.min(...n), l = new Path2D();
77
- for (const r of e.points) {
78
- if (!r.length) return;
79
- if (r.length === 1) l.rect(...Ze(r[0], o, s, e.scaleX, e.scaleY), 1, 1);
80
- else if (l.moveTo(...Ze(r[0], o, s, e.scaleX, e.scaleY)), t === "quadratic") {
81
- for (let d = 0; d < r.slice(1).length - 2; d++) {
82
- const h = Ze(r[d], o, s, e.scaleX, e.scaleY), c = Ze(r[d + 1], o, s, e.scaleX, e.scaleY), u = (h[0] + c[0]) / 2, f = (h[1] + c[1]) / 2;
83
- l.quadraticCurveTo(...h, u, f);
79
+ const i = e.points.flat(), a = i.map((s) => s[0]), n = i.map((s) => s[1]), o = Math.min(...a), r = Math.min(...n), l = new Path2D();
80
+ for (const s of e.points) {
81
+ if (!s.length) return;
82
+ if (s.length === 1) l.rect(...ze(s[0], o, r, e.scaleX, e.scaleY), 1, 1);
83
+ else if (l.moveTo(...ze(s[0], o, r, e.scaleX, e.scaleY)), t === "quadratic") {
84
+ for (let c = 0; c < s.slice(1).length - 2; c++) {
85
+ const u = ze(s[c], o, r, e.scaleX, e.scaleY), d = ze(s[c + 1], o, r, e.scaleX, e.scaleY), h = (u[0] + d[0]) / 2, f = (u[1] + d[1]) / 2;
86
+ l.quadraticCurveTo(...u, h, f);
84
87
  }
85
- l.quadraticCurveTo(...Ze(r[r.length - 2], o, s, e.scaleX, e.scaleY), ...Ze(r[r.length - 1], o, s, e.scaleX, e.scaleY));
86
- } else for (const d of r.slice(1)) l.lineTo(...Ze(d, o, s, e.scaleX, e.scaleY));
88
+ l.quadraticCurveTo(...ze(s[s.length - 2], o, r, e.scaleX, e.scaleY), ...ze(s[s.length - 1], o, r, e.scaleX, e.scaleY));
89
+ } else for (const c of s.slice(1)) l.lineTo(...ze(c, o, r, e.scaleX, e.scaleY));
87
90
  }
88
91
  return l;
89
- }, $a = (e, t) => e.style?.closedPoints === 1 && t.length > 2 ? [t[t.length - 2], ...t, t[0], t[1]] : [t[0], ...t, t[t.length - 1]], Ua = (e, t, i, a, n) => {
90
- const o = i[0] + (a[0] - t[0]) / 6, s = i[1] + (a[1] - t[1]) / 6, l = a[0] - (n[0] - i[0]) / 6, r = a[1] - (n[1] - i[1]) / 6;
91
- e.bezierCurveTo(o, s, l, r, a[0], a[1]);
92
- }, Ya = (e) => {
92
+ }, On = (e, t, i, a) => {
93
+ const n = (b) => (1 - b) ** 3 * e[0] + 3 * (1 - b) ** 2 * b * t[0] + 3 * (1 - b) * b ** 2 * i[0] + b ** 3 * a[0], o = (b) => (1 - b) ** 3 * e[1] + 3 * (1 - b) ** 2 * b * t[1] + 3 * (1 - b) * b ** 2 * i[1] + b ** 3 * a[1], r = (b, Z, A) => {
94
+ const T = b - 2 * Z + A, S = -2 * b + 2 * Z, V = b;
95
+ if (Math.abs(T) < 1e-10) {
96
+ if (Math.abs(S) < 1e-10) return [];
97
+ const F = -V / S;
98
+ return F > 0 && F < 1 ? [F] : [];
99
+ }
100
+ const I = S * S - 4 * T * V;
101
+ if (I < 0) return [];
102
+ const N = Math.sqrt(I), H = (-S - N) / (2 * T), D = (-S + N) / (2 * T), U = [];
103
+ return H > 0 && H < 1 && U.push(H), D > 0 && D < 1 && D !== H && U.push(D), U;
104
+ }, l = e[0], s = t[0], c = i[0], u = a[0], d = e[1], h = t[1], f = i[1], g = a[1], x = r(s - l, c - s, u - c), C = r(h - d, f - h, g - f);
105
+ let k = Math.min(e[0], a[0]), w = Math.max(e[0], a[0]), m = Math.min(e[1], a[1]), y = Math.max(e[1], a[1]);
106
+ for (const b of x) {
107
+ const Z = n(b);
108
+ k = Math.min(k, Z), w = Math.max(w, Z);
109
+ }
110
+ for (const b of C) {
111
+ const Z = o(b);
112
+ m = Math.min(m, Z), y = Math.max(y, Z);
113
+ }
114
+ return { minX: k, maxX: w, minY: m, maxY: y };
115
+ }, pi = (e, t) => e.style?.closedPoints === 1 && t.length > 2 ? [t[t.length - 2], ...t, t[0], t[1]] : [t[0], ...t, t[t.length - 1]], gi = (e, t, i, a) => ({ cp1: [t[0] + (i[0] - e[0]) / 6, t[1] + (i[1] - e[1]) / 6], cp2: [i[0] - (a[0] - t[0]) / 6, i[1] - (a[1] - t[1]) / 6] }), en = (e) => {
93
116
  const t = e.tempPoint ? [...e.points, e.tempPoint] : e.points;
94
117
  if (t.length < 2) return;
95
118
  const i = new Path2D();
96
119
  i.moveTo(...t[0]);
97
120
  for (const a of t.slice(1)) i.lineTo(...a);
98
121
  return t.length > 2 && e.style?.closedPoints === 1 && i.lineTo(...t[0]), i;
99
- }, Pn = (e) => {
122
+ }, Fn = (e) => {
100
123
  const t = new Path2D();
101
124
  return t.moveTo(...e.points[0]), t.lineTo(...e.points[1]), t.lineTo(...e.points[2]), t.lineTo(...e.points[0]), t;
102
- }, lt = (e, t, i, a = !1) => {
103
- const { borders: n } = ie(t, i);
104
- return { border: li(n), shapePath: e, line: a ? void 0 : Vt({ points: [[n.x + n.width / 2, n.y], [n.x + n.width / 2, n.y - 23 / i.canvasSize.scaleRatio]] }), anchors: a ? [] : [Lt({ x: n.x + n.width / 2, y: n.y - 23 / i.canvasSize.scaleRatio, radius: 7 / i.canvasSize.scaleRatio }), ...Aa.map((o) => Lt({ x: n.x + n.width * o[0], y: n.y + n.height * o[1], radius: 7 / i.canvasSize.scaleRatio }))] };
105
- }, Hi = ({ borderStart: e, borderSize: t, vector: i, settings: a, invertedAxe: n, anchor: o }) => {
125
+ }, Bn = (e, t) => ({ x: e.x - (t?.lineWidth ?? 0) / 2, y: e.y - (t?.lineWidth ?? 0) / 2, width: e.width + (t?.lineWidth ?? 0), height: e.height + (t?.lineWidth ?? 0) }), Re = (e, t, i, a = Bn) => {
126
+ const n = t(e, i), o = a(n, e.style), r = [n.x + n.width / 2, n.y + n.height / 2], l = ((s, c, u = 0) => {
127
+ if (u === 0) return s;
128
+ const d = [[s.x, s.y], [s.x + s.width, s.y], [s.x + s.width, s.y + s.height], [s.x, s.y + s.height]].map((g) => xe({ point: g, origin: c, rotation: u })), h = Math.min(...d.map((g) => g[0])), f = Math.min(...d.map((g) => g[1]));
129
+ return { x: h, y: f, width: Math.max(...d.map((g) => g[0])) - h, height: Math.max(...d.map((g) => g[1])) - f };
130
+ })(o, r, e.rotation);
131
+ return { borders: n, outerBorders: o, center: r, boundingBox: l };
132
+ }, ut = (e, t, i, a = !1) => {
133
+ const { borders: n } = t;
134
+ return { border: ui(n), shapePath: e, line: a ? void 0 : Zt({ points: [[n.x + n.width / 2, n.y], [n.x + n.width / 2, n.y - 23 / i.canvasSize.scaleRatio]] }), anchors: a ? [] : [Lt({ x: n.x + n.width / 2, y: n.y - 23 / i.canvasSize.scaleRatio, radius: 7 / i.canvasSize.scaleRatio }), ...Ba.map((o) => Lt({ x: n.x + n.width * o[0], y: n.y + n.height * o[1], radius: 7 / i.canvasSize.scaleRatio }))] };
135
+ }, Oi = ({ borderStart: e, borderSize: t, vector: i, settings: a, invertedAxe: n, anchor: o }) => {
106
136
  switch (o) {
107
137
  case 0: {
108
138
  if (n) {
109
139
  const l = t - 2 * a.selectionPadding;
110
140
  return [e + l, i - l];
111
141
  }
112
- const s = Math.max(2 * a.selectionPadding, t - i);
113
- return [e + t - s, s];
142
+ const r = Math.max(2 * a.selectionPadding, t - i);
143
+ return [e + t - r, r];
114
144
  }
115
145
  case 0.5:
116
146
  return [e, t];
117
147
  case 1:
118
148
  if (n) {
119
- const s = t + i;
120
- return [e + s, 2 * a.selectionPadding - s];
149
+ const r = t + i;
150
+ return [e + r, 2 * a.selectionPadding - r];
121
151
  }
122
152
  return [e, Math.max(2 * a.selectionPadding, t + i)];
123
153
  default:
124
154
  return [0, 0];
125
155
  }
126
- }, et = (e, t, i, a, n = !1, o = !1) => {
127
- const { center: s, borders: l } = ie(t, a), r = Me({ origin: s, point: e, rotation: t.rotation }), d = i.anchor[0] === 0 && r[0] >= l.x + l.width || i.anchor[0] === 1 && r[0] <= l.x, h = i.anchor[1] === 0 && r[1] >= l.y + l.height || i.anchor[1] === 1 && r[1] <= l.y, c = [Y(r[0], a, i.anchor[0] === 0 && !d || i.anchor[0] === 1 && d ? a.selectionPadding : -a.selectionPadding), Y(r[1], a, i.anchor[1] === 0 && !h || i.anchor[1] === 1 && h ? a.selectionPadding : -a.selectionPadding)], u = a.gridGap ? [i.anchor[0] === 0 ? l.x : i.anchor[0] === 0.5 ? l.x + l.width / 2 : l.x + l.width, i.anchor[1] === 0 ? l.y : i.anchor[1] === 0.5 ? l.y + l.height / 2 : l.y + l.height] : Me({ origin: s, point: i.cursorStartPosition, rotation: t.rotation }), f = [c[0] - u[0], c[1] - u[1]], [v, b] = Hi({ borderStart: l.x, borderSize: l.width, vector: f[0], settings: a, invertedAxe: d, anchor: i.anchor[0] }), [M, P] = Hi({ borderStart: l.y, borderSize: l.height, vector: f[1], settings: a, invertedAxe: h, anchor: i.anchor[1] }), x = n ? ((y, m, S, E, H, z, T, V, I, W) => {
128
- const { selectionPadding: A } = W, R = (m.width - 2 * A || 1) / (m.height - 2 * A || 1), _ = (H - 2 * A) / (T - 2 * A);
129
- let U, C, p, w;
130
- return I.anchor[0] !== 0.5 && I.anchor[1] !== 0.5 ? _ < R ? (C = z, w = T, p = (T - 2 * A) * R + 2 * A, U = I.anchor[0] === 0 ? m.width - y[0] > A ? m.x + (m.width - p) : m.x + m.width - 2 * A : m.width + y[0] > A ? m.x : m.x - p + 2 * A) : (U = E, p = H, w = (H - 2 * A) / R + 2 * A, C = I.anchor[1] === 0 ? m.height - y[1] > A ? m.y + (m.height - w) : m.y + m.height - 2 * A : m.height + y[1] > A ? m.y : m.y - w + 2 * A) : I.anchor[0] !== 0.5 ? (U = E, p = H, w = (H - 2 * A) / R + 2 * A, C = m.y + (m.height - w) / 2) : (C = z, w = T, p = (T - 2 * A) * R + 2 * A, U = m.x + (m.width - p) / 2), { borderX: U, borderWidth: p, borderY: C, borderHeight: w, center: S, originalShape: V };
131
- })(f, l, s, v, b, M, P, t, i, a) : { borderX: v, borderWidth: b, borderY: M, borderHeight: P, center: s, originalShape: t };
132
- return (({ borderX: y, borderWidth: m, borderY: S, borderHeight: E, center: H, originalShape: z }) => {
133
- const T = [y + m / 2 - H[0], S + E / 2 - H[1]], [V, I] = Me({ point: T, rotation: -z.rotation });
134
- return { borderX: $e(y + V - T[0]), borderWidth: $e(m), borderY: $e(S + I - T[1]), borderHeight: $e(E) };
135
- })(o ? ((y, m, S, E) => {
136
- const H = m.x + m.width / 2, z = m.y + m.height / 2, T = S ? 2 * y.borderWidth + m.width : Math.abs(m.width + 2 * (y.borderWidth - m.width)), V = E ? 2 * y.borderHeight + m.height : Math.abs(m.height + 2 * (y.borderHeight - m.height));
137
- return { ...y, borderHeight: V, borderWidth: T, borderX: H - T / 2, borderY: z - V / 2 };
138
- })(x, l, d, h) : x);
139
- }, Zt = (e, t, i = !1) => {
140
- const a = li(e);
141
- return { ...e, path: a, selection: lt(a, e, t, i) };
142
- }, Ln = Zt, Xa = (e, t, i, a = !1, n = 0, o = 0) => {
143
- const s = { toolId: e.id, type: e.type, id: me(`${e.type}_`), x: t[0], y: t[1], width: n, height: o, rotation: 0, style: { opacity: e.settings.opacity.default, fillColor: e.settings.fillColor.default, strokeColor: e.settings.strokeColor.default, lineWidth: e.settings.lineWidth.default, lineDash: e.settings.lineDash.default } };
144
- return Zt(s, i, a);
145
- }, Vn = (e, t) => {
156
+ }, nt = (e, t, i, a, n = !1, o = !1) => {
157
+ const { center: r, borders: l } = t.computed, s = xe({ origin: r, point: e, rotation: t.rotation }), c = i.anchor[0] === 0 && s[0] >= l.x + l.width || i.anchor[0] === 1 && s[0] <= l.x, u = i.anchor[1] === 0 && s[1] >= l.y + l.height || i.anchor[1] === 1 && s[1] <= l.y, d = [_(s[0], a, i.anchor[0] === 0 && !c || i.anchor[0] === 1 && c ? a.selectionPadding : -a.selectionPadding), _(s[1], a, i.anchor[1] === 0 && !u || i.anchor[1] === 1 && u ? a.selectionPadding : -a.selectionPadding)], h = a.gridGap ? [i.anchor[0] === 0 ? l.x : i.anchor[0] === 0.5 ? l.x + l.width / 2 : l.x + l.width, i.anchor[1] === 0 ? l.y : i.anchor[1] === 0.5 ? l.y + l.height / 2 : l.y + l.height] : xe({ origin: r, point: i.cursorStartPosition, rotation: t.rotation }), f = [d[0] - h[0], d[1] - h[1]], [g, x] = Oi({ borderStart: l.x, borderSize: l.width, vector: f[0], settings: a, invertedAxe: c, anchor: i.anchor[0] }), [C, k] = Oi({ borderStart: l.y, borderSize: l.height, vector: f[1], settings: a, invertedAxe: u, anchor: i.anchor[1] }), w = n ? ((m, y, b, Z, A, T, S, V, I, N) => {
158
+ const { selectionPadding: H } = N, D = (y.width - 2 * H || 1) / (y.height - 2 * H || 1), U = (A - 2 * H) / (S - 2 * H);
159
+ let F, X, p, Q;
160
+ return I.anchor[0] !== 0.5 && I.anchor[1] !== 0.5 ? U < D ? (X = T, Q = S, p = (S - 2 * H) * D + 2 * H, F = I.anchor[0] === 0 ? y.width - m[0] > H ? y.x + (y.width - p) : y.x + y.width - 2 * H : y.width + m[0] > H ? y.x : y.x - p + 2 * H) : (F = Z, p = A, Q = (A - 2 * H) / D + 2 * H, X = I.anchor[1] === 0 ? y.height - m[1] > H ? y.y + (y.height - Q) : y.y + y.height - 2 * H : y.height + m[1] > H ? y.y : y.y - Q + 2 * H) : I.anchor[0] !== 0.5 ? (F = Z, p = A, Q = (A - 2 * H) / D + 2 * H, X = y.y + (y.height - Q) / 2) : (X = T, Q = S, p = (S - 2 * H) * D + 2 * H, F = y.x + (y.width - p) / 2), { borderX: F, borderWidth: p, borderY: X, borderHeight: Q, center: b, originalShape: V };
161
+ })(f, l, r, g, x, C, k, t, i, a) : { borderX: g, borderWidth: x, borderY: C, borderHeight: k, center: r, originalShape: t };
162
+ return (({ borderX: m, borderWidth: y, borderY: b, borderHeight: Z, center: A, originalShape: T }) => {
163
+ const S = [m + y / 2 - A[0], b + Z / 2 - A[1]], [V, I] = xe({ point: S, rotation: -(T.rotation ?? 0) });
164
+ return { borderX: Xe(m + V - S[0]), borderWidth: Xe(y), borderY: Xe(b + I - S[1]), borderHeight: Xe(Z) };
165
+ })(o ? ((m, y, b, Z) => {
166
+ const A = y.x + y.width / 2, T = y.y + y.height / 2, S = b ? 2 * m.borderWidth + y.width : Math.abs(y.width + 2 * (m.borderWidth - y.width)), V = Z ? 2 * m.borderHeight + y.height : Math.abs(y.height + 2 * (m.borderHeight - y.height));
167
+ return { ...m, borderHeight: V, borderWidth: S, borderX: A - S / 2, borderY: T - V / 2 };
168
+ })(w, l, c, u) : w);
169
+ }, tn = (e, t) => Re(e, vi, t), Ht = (e, t, i = !1) => {
170
+ const a = ui(e), n = tn(e, t);
171
+ return { ...e, path: a, computed: n, selection: ut(a, n, t, i) };
172
+ }, $n = Ht, an = (e, t, i, a = !1, n = 0, o = 0) => {
173
+ const r = { toolId: e.id, type: e.type, id: ye(`${e.type}_`), x: t[0], y: t[1], width: n, height: o, style: { opacity: e.settings.opacity.default, fillColor: e.settings.fillColor.default, strokeColor: e.settings.strokeColor.default, lineWidth: e.settings.lineWidth.default, lineDash: e.settings.lineDash.default } };
174
+ return Ht(r, i, a);
175
+ }, Yn = (e, t) => {
146
176
  e.globalAlpha !== 0 && t.path && (t.style?.fillColor !== "transparent" && e.fill(t.path), t.style?.strokeColor !== "transparent" && e.stroke(t.path));
147
- }, Ti = (e, t) => ({ x: e.x - t.selectionPadding, width: e.width + 2 * t.selectionPadding, y: e.y - t.selectionPadding, height: e.height + 2 * t.selectionPadding }), zi = (e, t, i, [a, n] = [!1, !1]) => {
148
- const o = e[0] === 0.5 ? i.x + i.width / 2 : e[0] === 0 ? i.x + (a ? 0 : i.width) : i.x + (a ? i.width : 0), s = e[1] === 0.5 ? i.y + i.height / 2 : e[1] === 0 ? i.y + (n ? 0 : i.height) : i.y + (n ? i.height : 0);
149
- return Tn([o, s], i.rotation, t);
150
- }, Ai = (e, t, i, a, n, o, s, l) => {
151
- let r = !1;
177
+ }, vi = (e, t) => ({ x: e.x - t.selectionPadding, width: e.width + 2 * t.selectionPadding, y: e.y - t.selectionPadding, height: e.height + 2 * t.selectionPadding }), Fi = (e, t, i, [a, n] = [!1, !1]) => {
178
+ const o = e[0] === 0.5 ? i.x + i.width / 2 : e[0] === 0 ? i.x + (a ? 0 : i.width) : i.x + (a ? i.width : 0), r = e[1] === 0.5 ? i.y + i.height / 2 : e[1] === 0 ? i.y + (n ? 0 : i.height) : i.y + (n ? i.height : 0);
179
+ return Gn([o, r], i.rotation ?? 0, t);
180
+ }, Bi = (e, t, i, a, n, o, r, l) => {
181
+ let s = !1;
152
182
  if (n) {
153
- r = vt(e, n, i, a, !0, o ? 20 : void 0);
154
- const h = ((c, u, f, v) => {
155
- if (c.mode === "translate") return { mode: "translate", cursorStartPosition: f, originalShape: u, dateStart: Date.now() };
156
- if (c.mode === "rotate") {
157
- const { center: b } = ie(u, v);
158
- return { mode: "rotate", cursorStartPosition: f, originalShape: u, center: [b[0], b[1]] };
183
+ s = mt(e, n, i, a, !0, o ? 20 : void 0);
184
+ const u = ((d, h, f) => {
185
+ if (d.mode === "translate") return { mode: "translate", cursorStartPosition: f, originalShape: h, dateStart: Date.now() };
186
+ if (d.mode === "rotate") {
187
+ const { center: g } = h.computed;
188
+ return { mode: "rotate", cursorStartPosition: f, originalShape: h, center: [g[0], g[1]] };
159
189
  }
160
- return c.mode === "resize" ? { mode: "resize", cursorStartPosition: f, originalShape: u, anchor: c.anchor } : void 0;
161
- })(r || { mode: "default" }, n, i, a);
162
- if (h?.mode === "resize" || h?.mode === "rotate") return { shape: n, mode: h };
190
+ return d.mode === "resize" ? { mode: "resize", cursorStartPosition: f, originalShape: h, anchor: d.anchor } : void 0;
191
+ })(s || { mode: "default" }, n, i);
192
+ if (u?.mode === "resize" || u?.mode === "rotate") return { shape: n, mode: u };
163
193
  }
164
- const d = t.find((h) => q(n).find((c) => h.id === c?.id) ? r && l ? vt(e, h, i, a, !0, o ? 20 : void 0) : !!r : !!ja(e, h, i, a));
165
- if (d) {
194
+ const c = t.find((u) => j(n).find((d) => u.id === d?.id) ? s && l ? mt(e, u, i, a, !0, o ? 20 : void 0) : !!s : !!rn(e, u, i, a));
195
+ if (c) {
166
196
  if (l) {
167
- const c = q(n).find((u) => u.id === d?.id) ? ye(Hn(n, d), a) : ye(Ga(n, [d]), a);
168
- return { shape: c, mode: { mode: "translate", cursorStartPosition: i, dateStart: Date.now(), originalShape: c } };
197
+ const d = j(n).find((h) => h.id === c?.id) ? be(Xn(n, c), a) : be(nn(n, [c]), a);
198
+ return { shape: d, mode: { mode: "translate", cursorStartPosition: i, dateStart: Date.now(), originalShape: d } };
169
199
  }
170
- const h = q(n).find((c) => c.id === d?.id) ? n : ye([d], a);
171
- return { shape: h, mode: { mode: "translate", cursorStartPosition: i, dateStart: Date.now(), originalShape: h } };
200
+ const u = j(n).find((d) => d.id === c?.id) ? n : be([c], a);
201
+ return { shape: u, mode: { mode: "translate", cursorStartPosition: i, dateStart: Date.now(), originalShape: u } };
172
202
  }
173
- return l ? { shape: n, mode: { mode: s ? "selectionFrame" : "default" } } : { shape: void 0, mode: { mode: s ? "selectionFrame" : "default" } };
174
- }, Zn = (e, t, i = !0) => {
203
+ return l ? { shape: n, mode: { mode: r ? "selectionFrame" : "default" } } : { shape: void 0, mode: { mode: r ? "selectionFrame" : "default" } };
204
+ }, Un = (e, t, i = !0) => {
175
205
  const a = [[e.x, e.y], [e.x + e.width, e.y], [e.x + e.width, e.y + e.height], [e.x, e.y + e.height]];
176
206
  if (!i) return a;
177
207
  const n = [e.x + e.width / 2, e.y + e.height / 2];
178
- return a.map((o) => Me({ point: [o[0], o[1]], origin: n, rotation: t }));
179
- }, ye = (e, t) => {
208
+ return a.map((o) => xe({ point: [o[0], o[1]], origin: n, rotation: t }));
209
+ }, be = (e, t) => {
180
210
  if (!e.length) return;
181
211
  if (e.length === 1) return e[0];
182
212
  let i = Number.POSITIVE_INFINITY, a = Number.POSITIVE_INFINITY, n = Number.NEGATIVE_INFINITY, o = Number.NEGATIVE_INFINITY;
183
- const s = e.some((h) => h.rotation !== e[0].rotation), l = s ? 0 : e[0].rotation;
184
- for (const h of e) {
185
- const { borders: c } = ie(h, t), u = Zn(c, h.rotation, s);
186
- i = Math.min(u[0][0], u[1][0], u[2][0], u[3][0], i), n = Math.max(u[0][0], u[1][0], u[2][0], u[3][0], n), a = Math.min(u[0][1], u[1][1], u[2][1], u[3][1], a), o = Math.max(u[0][1], u[1][1], u[2][1], u[3][1], o);
213
+ const r = e.some((u) => u.rotation !== e[0].rotation), l = r ? 0 : e[0]?.rotation ?? 0;
214
+ for (const u of e) {
215
+ const { borders: d } = u.computed, h = Un(d, u.rotation ?? 0, r);
216
+ i = Math.min(h[0][0], h[1][0], h[2][0], h[3][0], i), n = Math.max(h[0][0], h[1][0], h[2][0], h[3][0], n), a = Math.min(h[0][1], h[1][1], h[2][1], h[3][1], a), o = Math.max(h[0][1], h[1][1], h[2][1], h[3][1], o);
187
217
  }
188
- const r = Xa({ id: "test", type: "rect", settings: wa }, [i, a], t, !0, n - i, o - a), d = e.slice(1).reduce((h, c) => {
189
- const u = c.style ?? {}, f = {};
190
- for (const v in u) h[v] !== void 0 && u[v] !== void 0 && h[v] === u[v] && (f[v] = h[v]);
218
+ const s = an({ id: "test", type: "rect", settings: Ha }, [i, a], t, !0, n - i, o - a), c = e.slice(1).reduce((u, d) => {
219
+ const h = d.style ?? {}, f = {};
220
+ for (const g in h) u[g] !== void 0 && h[g] !== void 0 && u[g] === h[g] && (f[g] = u[g]);
191
221
  return f;
192
222
  }, e[0].style ?? {});
193
- return { id: e.map((h) => h.id).join("-"), type: "group", shapes: e, rotation: l, visible: !0, locked: !1, selection: r.selection, x: r.x, y: r.y, width: r.width, height: r.height, style: d };
194
- }, Ei = (e, t) => (i) => {
223
+ return { id: e.map((u) => u.id).join("-"), type: "group", shapes: e, rotation: l, visible: !0, locked: !1, selection: s.selection, x: s.x, y: s.y, width: s.width, height: s.height, style: c, computed: s.computed };
224
+ }, $i = (e, t) => (i) => {
195
225
  if (!i) return;
196
226
  const a = i.type === "group" ? i.shapes.map((n) => e(n, t)) : [e(i, t)];
197
- return ye(a, t);
198
- }, q = (e) => e ? e.type === "group" ? e.shapes : [e] : [], Ga = (e, t) => {
199
- const i = q(e);
227
+ return be(a, t);
228
+ }, j = (e) => e ? e.type === "group" ? e.shapes : [e] : [], nn = (e, t) => {
229
+ const i = j(e);
200
230
  return [.../* @__PURE__ */ new Set([...i, ...t])];
201
- }, Hn = (e, t) => q(e).filter((i) => i.id !== t.id), qa = (e) => {
231
+ }, Xn = (e, t) => j(e).filter((i) => i.id !== t.id), on = (e) => {
202
232
  const { clientX: t = 0, clientY: i = 0 } = "touches" in e && e.touches[0] ? e.touches[0] : "changedTouches" in e && e.changedTouches[0] ? e.changedTouches[0] : "clientX" in e ? e : {};
203
233
  return { clientX: t, clientY: i };
204
- }, _a = (e, t, i) => {
205
- const { clientX: a, clientY: n } = qa(e), o = t.getBoundingClientRect();
234
+ }, sn = (e, t, i) => {
235
+ const { clientX: a, clientY: n } = on(e), o = t.getBoundingClientRect();
206
236
  return [(a - o.left) / i.scaleRatio, (n - o.top) / i.scaleRatio];
207
- }, tt = (e, t, i) => {
208
- const { clientX: a, clientY: n } = qa(e), o = t?.getBoundingClientRect() ?? { left: 0, top: 0, width: i.canvasSize.width, height: i.canvasSize.height };
237
+ }, ot = (e, t, i) => {
238
+ const { clientX: a, clientY: n } = on(e), o = t?.getBoundingClientRect() ?? { left: 0, top: 0, width: i.canvasSize.width, height: i.canvasSize.height };
209
239
  return [(a - o.left) * (i.canvasSize.width / o.width) / i.canvasSize.scaleRatio - i.canvasOffset[0], (n - o.top) * (i.canvasSize.height / o.height) / i.canvasSize.scaleRatio - i.canvasOffset[1]];
210
- }, it = (e) => "touches" in e, He = (e, t, [i, a]) => Me({ origin: [i, a], point: e, rotation: t }), Tn = (e, t, [i, a]) => Me({ origin: [i, a], point: e, rotation: -t }), wt = (e, t, i) => i ? Fa(e, { x: t[0], y: t[1], radius: i }) : ((a, n) => n[0] >= a.x && n[0] <= a.x + a.width && n[1] >= a.y && n[1] <= a.y + a.height)(e, t), vt = (e, t, i, a, n = !1, o = 0) => {
240
+ }, st = (e) => "touches" in e, Ae = (e, t, [i, a]) => xe({ origin: [i, a], point: e, rotation: t }), Gn = (e, t, [i, a]) => xe({ origin: [i, a], point: e, rotation: -t }), xt = (e, t, i) => i ? Ka(e, { x: t[0], y: t[1], radius: i }) : ((a, n) => n[0] >= a.x && n[0] <= a.x + a.width && n[1] >= a.y && n[1] <= a.y + a.height)(e, t), mt = (e, t, i, a, n = !1, o = 0) => {
211
241
  if (t.locked) return !1;
212
- const { canvasSize: { scaleRatio: s } } = a, { borders: l, center: r } = ie(t, a), d = He(i, t.rotation, r), h = q(t);
242
+ const { canvasSize: { scaleRatio: r } } = a, { borders: l, center: s } = t.computed, c = Ae(i, t.rotation ?? 0, s), u = j(t);
213
243
  if (n) {
214
- if (h.length !== 1 || h[0]?.type !== "line" && h[0]?.type !== "polygon" && h[0]?.type !== "curve") {
215
- if (h.length === 1) {
216
- if (wt({ x: l.x + l.width / 2 - 7 / s, y: l.y - je / s - 16 / s, width: je / s, height: je / s }, d, o)) return { mode: "rotate" };
217
- for (const c of Aa) if (wt({ x: l.x + l.width * c[0] - 7 / s, y: l.y + l.height * c[1] - 7 / s, width: je / s, height: je / s }, d, o)) return { mode: "resize", anchor: c };
244
+ if (u.length !== 1 || u[0]?.type !== "line" && u[0]?.type !== "polygon" && u[0]?.type !== "curve") {
245
+ if (u.length === 1) {
246
+ if (xt({ x: l.x + l.width / 2 - 7 / r, y: l.y - et / r - 16 / r, width: et / r, height: et / r }, c, o)) return { mode: "rotate" };
247
+ for (const d of Ba) if (xt({ x: l.x + l.width * d[0] - 7 / r, y: l.y + l.height * d[1] - 7 / r, width: et / r, height: et / r }, c, o)) return { mode: "resize", anchor: d };
218
248
  }
219
- } else for (let c = 0; c < h[0].points.length; c++) if (wt({ x: h[0].points[c][0] - 7 / s, y: h[0].points[c][1] - 7 / s, width: je / s, height: je / s }, d, o)) return { mode: "resize", anchor: c };
249
+ } else for (let d = 0; d < u[0].points.length; d++) if (xt({ x: u[0].points[d][0] - 7 / r, y: u[0].points[d][1] - 7 / r, width: et / r, height: et / r }, c, o)) return { mode: "resize", anchor: d };
220
250
  }
221
- return (wt(l, d, o) || !!(t.type === "curve" && "path" in t && t.path && e.isPointInPath(t.path, d[0], d[1]))) && { mode: "translate" };
222
- }, Di = (e, t, i, a, n = 50) => {
251
+ return (xt(l, c, o) || !!(t.type === "curve" && "path" in t && t.path && e.isPointInPath(t.path, c[0], c[1]))) && { mode: "translate" };
252
+ }, Yi = (e, t, i, a, n = 50) => {
223
253
  if (t.locked || t.points.length < 2) return !1;
224
- const { center: o } = ie(t, a), s = He(i, t.rotation, o);
254
+ const { center: o } = t.computed, r = Ae(i, t.rotation ?? 0, o);
225
255
  e.lineWidth = (t.style?.lineWidth ?? 0) + n / a.canvasZoom;
226
256
  const l = t.style?.closedPoints ? [...t.points, t.points[0]] : t.points;
227
- for (let r = 0; r < l.length - 1; r++) {
228
- const d = Vt({ points: [l[r], l[r + 1]] });
229
- if (e.isPointInStroke(d, s[0], s[1])) return { lineIndex: r };
257
+ for (let s = 0; s < l.length - 1; s++) {
258
+ const c = Zt({ points: [l[s], l[s + 1]] });
259
+ if (e.isPointInStroke(c, r[0], r[1])) return { lineIndex: s };
230
260
  }
231
261
  return !1;
232
- }, ja = (e, t, i, a) => {
262
+ }, rn = (e, t, i, a) => {
233
263
  if (t.locked) return !1;
234
- const { center: n } = ie(t, a), o = He(i, t.rotation, n);
235
- return "path" in t && t.path ? t.style?.fillColor && t.style?.fillColor !== "transparent" ? !!e.isPointInPath(t.path, o[0], o[1]) && { mode: "translate" } : (e.lineWidth = (t.style?.lineWidth ?? 0) + 15 / a.canvasZoom, !!e.isPointInStroke(t.path, o[0], o[1]) && { mode: "translate" }) : vt(e, t, i, a, !1);
264
+ const { center: n } = t.computed, o = Ae(i, t.rotation ?? 0, n);
265
+ return "path" in t && t.path ? t.style?.fillColor && t.style?.fillColor !== "transparent" ? !!e.isPointInPath(t.path, o[0], o[1]) && { mode: "translate" } : (e.lineWidth = (t.style?.lineWidth ?? 0) + 15 / a.canvasZoom, !!e.isPointInStroke(t.path, o[0], o[1]) && { mode: "translate" }) : mt(e, t, i, a, !1);
236
266
  };
237
- function Jt(e, t) {
267
+ function ii(e, t) {
238
268
  const i = Math.max(e.x, t.x), a = Math.max(e.y, t.y), n = Math.min(e.x + (e.width || 1), t.x + (t.width || 1)), o = Math.min(e.y + (e.height || 1), t.y + (t.height || 1));
239
269
  if (i < n && a < o) return { x: i, y: a, width: n - i, height: o - a };
240
270
  }
241
- const Ni = ({ ctx: e, path: t, rect: i, offset: a, checkFill: n }) => {
242
- for (let o = 0; o < a; o += a / 2) for (let s = 0; s < a; s += a / 2) for (let l = o + i.x; l < i.x + i.width; l += a) for (let r = s + i.y; r < i.y + i.height; r += a) if (n ? e.isPointInPath(t, l, r) : e.isPointInStroke(t, l, r)) return !0;
271
+ const Ui = ({ ctx: e, path: t, rect: i, offset: a, checkFill: n }) => {
272
+ for (let o = 0; o < a; o += a / 2) for (let r = 0; r < a; r += a / 2) for (let l = o + i.x; l < i.x + i.width; l += a) for (let s = r + i.y; s < i.y + i.height; s += a) if (n ? e.isPointInPath(t, l, s) : e.isPointInStroke(t, l, s)) return !0;
243
273
  return !1;
244
- }, ci = (e, t, i) => {
245
- const { borders: a } = ie(t, i);
246
- return { border: li(a), shapePath: e, anchors: [...t.points.map((n) => Lt({ x: n[0], y: n[1], radius: 7 / i.canvasSize.scaleRatio }))] };
247
- }, we = [0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8], ei = ({ size: e, zoom: t, newOffset: [i, a], canvasSize: n }) => e === "infinite" ? { zoom: t, offset: [i, a] } : t < 1 ? { zoom: t, offset: [-(n.realWidth - n.realWidth / t) / 2, -(n.realHeight - n.realHeight / t) / 2] } : { zoom: t, offset: [De(i, n.realWidth / t - n.realWidth, 0), De(a, n.realHeight / t - n.realHeight, 0)] }, ti = ({ size: e, canvasSize: t, currentOffset: i, currentZoom: a, zoom: n, centerPoint: o }) => {
248
- const s = e === "fixed" && n < 1 ? [t.realWidth / 2, t.realHeight / 2] : o, l = i[0] - (s[0] / a - s[0] / n), r = i[1] - (s[1] / a - s[1] / n);
249
- return { offset: e === "infinite" ? [l, r] : n < 1 ? [-(t.realWidth - t.realWidth / n) / 2, -(t.realHeight - t.realHeight / n) / 2] : [De(l, t.realWidth / n - t.realWidth, 0), De(r, t.realHeight / n - t.realHeight, 0)], zoom: n };
250
- }, Ka = (e) => {
274
+ }, fi = (e, t, i, a) => ({ border: ui(i.borders), shapePath: e, anchors: [...t.points.map((n) => Lt({ x: n[0], y: n[1], radius: 7 / a.canvasSize.scaleRatio }))] }), Me = [0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8], ai = ({ size: e, zoom: t, newOffset: [i, a], canvasSize: n }) => e === "infinite" ? { zoom: t, offset: [i, a] } : t < 1 ? { zoom: t, offset: [-(n.realWidth - n.realWidth / t) / 2, -(n.realHeight - n.realHeight / t) / 2] } : { zoom: t, offset: [De(i, n.realWidth / t - n.realWidth, 0), De(a, n.realHeight / t - n.realHeight, 0)] }, ni = ({ size: e, canvasSize: t, currentOffset: i, currentZoom: a, zoom: n, centerPoint: o }) => {
275
+ const r = e === "fixed" && n < 1 ? [t.realWidth / 2, t.realHeight / 2] : o, l = i[0] - (r[0] / a - r[0] / n), s = i[1] - (r[1] / a - r[1] / n);
276
+ return { offset: e === "infinite" ? [l, s] : n < 1 ? [-(t.realWidth - t.realWidth / n) / 2, -(t.realHeight - t.realHeight / n) / 2] : [De(l, t.realWidth / n - t.realWidth, 0), De(s, t.realHeight / n - t.realHeight, 0)], zoom: n };
277
+ }, ln = (e) => {
251
278
  const { canvasSize: { width: t, height: i, scaleRatioWithNoZoom: a }, canvasZoom: n, canvasOffset: o } = e;
252
279
  return { x: o[0] * n * a, y: o[1] * n * a, width: t * n, height: i * n };
253
- }, Ja = (e, t) => {
280
+ }, cn = (e, t) => {
254
281
  const { canvasZoom: i, size: a } = t;
255
282
  if (a !== "fixed" || i >= 1) return;
256
- const n = Ka(t);
283
+ const n = ln(t);
257
284
  e.beginPath(), e.rect(n.x, n.y, n.width, n.height), e.closePath(), e.clip();
258
- }, gt = (e, t) => t.size !== "fixed" || e[0] > 0 && e[0] < t.canvasSize.realWidth && e[1] > 0 && e[1] < t.canvasSize.realHeight, Ht = (e, t) => {
259
- const i = Lt(e);
260
- return { ...e, path: i, selection: lt(i, e, t) };
261
- }, zn = Ht, ct = (e, t) => {
262
- const i = Ya(e);
263
- return { ...e, path: i, selection: ci(i, e, t) };
264
- }, An = ct, en = (e, t) => {
285
+ }, ft = (e, t) => t.size !== "fixed" || e[0] > 0 && e[0] < t.canvasSize.realWidth && e[1] > 0 && e[1] < t.canvasSize.realHeight, qn = (e, t) => ({ x: e.x - e.radius - t.selectionPadding, width: 2 * (e.radius + t.selectionPadding), y: e.y - e.radius - t.selectionPadding, height: 2 * (e.radius + t.selectionPadding) }), dn = (e, t) => Re(e, qn, t), Tt = (e, t) => {
286
+ const i = Lt(e), a = dn(e, t);
287
+ return { ...e, path: i, selection: ut(i, a, t), computed: a };
288
+ }, _n = Tt, hn = (e, t) => Re(e, mi, t), pt = (e, t) => {
289
+ const i = en(e), a = hn(e, t);
290
+ return { ...e, path: i, selection: fi(i, e, a, t), computed: a };
291
+ }, jn = pt, mi = (e, t) => {
265
292
  const i = Math.min(...e.points.map((o) => o[0])) - t.selectionPadding, a = Math.max(...e.points.map((o) => o[0])) + t.selectionPadding, n = Math.min(...e.points.map((o) => o[1])) - t.selectionPadding;
266
293
  return { x: i, width: a - i, y: n, height: Math.max(...e.points.map((o) => o[1])) + t.selectionPadding - n };
267
- }, En = (e, t, i, a) => {
294
+ }, Kn = (e, t, i, a) => {
268
295
  if (t < 0 || t > e.points.length - 1) return e;
269
296
  const n = [...e.points.slice(0, t + 1), i, ...e.points.slice(t + 1)];
270
- return ct({ ...e, points: n }, a);
271
- }, Wi = (e, t, i, a = !1) => {
272
- const n = [Y(t[0], i), Y(t[1], i)], { center: o } = ie(e, i), s = He(n, e.rotation, o), l = { ...e, points: a ? e.points : [...e.points, s], tempPoint: a ? s : void 0 };
273
- return ct(l, i);
274
- }, dt = (e, t) => {
275
- const i = ((a) => {
276
- const n = a.tempPoint ? [...a.points, a.tempPoint] : a.points;
277
- if (n.length < 2) return;
278
- if (n.length < 3) return Ya(a);
279
- const o = a.style?.closedPoints === 1 && n.length > 2, s = new Path2D();
280
- s.moveTo(...n[0]);
281
- const l = $a(a, n);
282
- for (let r = 1; r < l.length - 2; r++) {
283
- const d = l[r - 1], h = l[r], c = l[r + 1], u = l[r + 2];
284
- Ua(s, d, h, c, u);
297
+ return pt({ ...e, points: n }, a);
298
+ }, Xi = (e, t, i, a = !1) => {
299
+ const n = [_(t[0], i), _(t[1], i)], o = Ae(n, e.rotation ?? 0, e.computed.center), r = { ...e, points: a ? e.points : [...e.points, o], tempPoint: a ? o : void 0 };
300
+ return pt(r, i);
301
+ }, Jn = (e, t) => {
302
+ const i = e.tempPoint ? [...e.points, e.tempPoint] : e.points;
303
+ if (i.length < 2) {
304
+ const s = i[0] ?? [0, 0], c = t.selectionPadding;
305
+ return { x: s[0] - c, y: s[1] - c, width: 2 * c, height: 2 * c };
306
+ }
307
+ if (i.length < 3) return mi({ ...e, points: i }, t);
308
+ const a = pi(e, i);
309
+ let n = Number.POSITIVE_INFINITY, o = Number.NEGATIVE_INFINITY, r = Number.POSITIVE_INFINITY, l = Number.NEGATIVE_INFINITY;
310
+ for (let s = 1; s < a.length - 2; s++) {
311
+ const c = a[s - 1], u = a[s], d = a[s + 1], h = a[s + 2], { cp1: f, cp2: g } = gi(c, u, d, h), x = On(u, f, g, d);
312
+ n = Math.min(n, x.minX), o = Math.max(o, x.maxX), r = Math.min(r, x.minY), l = Math.max(l, x.maxY);
313
+ }
314
+ return vi({ x: n, y: r, width: o - n, height: l - r }, t);
315
+ }, un = (e, t) => Re(e, Jn, t), gt = (e, t) => {
316
+ const i = ((n) => {
317
+ const o = n.tempPoint ? [...n.points, n.tempPoint] : n.points;
318
+ if (o.length < 2) return;
319
+ if (o.length < 3) return en(n);
320
+ const r = n.style?.closedPoints === 1 && o.length > 2, l = new Path2D();
321
+ l.moveTo(...o[0]);
322
+ const s = pi(n, o);
323
+ for (let c = 1; c < s.length - 2; c++) {
324
+ const u = s[c - 1], d = s[c], h = s[c + 1], f = s[c + 2], { cp1: g, cp2: x } = gi(u, d, h, f);
325
+ l.bezierCurveTo(g[0], g[1], x[0], x[1], h[0], h[1]);
285
326
  }
286
- return o && s.closePath(), s;
287
- })(e);
288
- return { ...e, path: i, selection: ci(i, e, t) };
289
- }, Dn = dt, Nn = en, Wn = (e, t, i, a) => {
327
+ return r && l.closePath(), l;
328
+ })(e), a = un(e, t);
329
+ return { ...e, path: i, selection: fi(i, e, a, t), computed: a };
330
+ }, eo = gt, to = (e, t, i, a) => {
290
331
  if (t < 0 || t > e.points.length - 1) return e;
291
332
  const n = [...e.points.slice(0, t + 1), i, ...e.points.slice(t + 1)];
292
- return dt({ ...e, points: n }, a);
293
- }, Ii = (e, t, i, a = !1) => {
294
- const n = [Y(t[0], i), Y(t[1], i)], { center: o } = ie(e, i), s = He(n, e.rotation, o), l = { ...e, points: a ? e.points : [...e.points, s], tempPoint: a ? s : void 0 };
295
- return dt(l, i);
296
- }, Tt = (e, t) => {
297
- const i = ((a) => {
298
- const n = new Path2D();
299
- return n.ellipse(a.x, a.y, a.radiusX, a.radiusY, 0, 0, 2 * Math.PI), n;
300
- })(e);
301
- return { ...e, path: i, selection: lt(i, e, t) };
302
- }, In = Tt, Ri = (e) => {
303
- return i = { ...e, type: "triangle" }, { ...i, path: Pn(i) };
304
- var i;
305
- }, Rn = (e, t) => {
333
+ return gt({ ...e, points: n }, a);
334
+ }, Gi = (e, t, i, a = !1) => {
335
+ const n = [_(t[0], i), _(t[1], i)], o = e.computed.center, r = Ae(n, e.rotation ?? 0, o), l = { ...e, points: a ? e.points : [...e.points, r], tempPoint: a ? r : void 0 };
336
+ return gt(l, i);
337
+ }, io = (e, t) => ({ x: e.x - e.radiusX - t.selectionPadding, width: 2 * (e.radiusX + t.selectionPadding), y: e.y - e.radiusY - t.selectionPadding, height: 2 * (e.radiusY + t.selectionPadding) }), pn = (e, t) => Re(e, io, t), zt = (e, t) => {
338
+ const i = ((n) => {
339
+ const o = new Path2D();
340
+ return o.ellipse(n.x, n.y, n.radiusX, n.radiusY, 0, 0, 2 * Math.PI), o;
341
+ })(e), a = pn(e, t);
342
+ return { ...e, path: i, selection: ut(i, a, t), computed: a };
343
+ }, ao = zt, no = (e, t) => Re(e, mi, t), qi = (e, t) => ((i, a) => ({ ...i, path: Fn(i), computed: no(i, a) }))({ ...e, id: ye("triangle_"), type: "triangle" }, t), oo = (e, t) => {
306
344
  e.globalAlpha !== 0 && t.path && (t.style?.fillColor !== "transparent" && e.fill(t.path), t.style?.strokeColor !== "transparent" && e.stroke(t.path));
307
- }, zt = (e, t) => {
345
+ }, so = (e, t) => ({ x: Math.min(e.points[0][0], e.points[1][0]) - t.selectionPadding, width: Math.abs(e.points[0][0] - e.points[1][0]) + 2 * t.selectionPadding, y: Math.min(e.points[0][1], e.points[1][1]) - t.selectionPadding, height: Math.abs(e.points[0][1] - e.points[1][1]) + 2 * t.selectionPadding }), gn = (e, t) => Re(e, so, t), At = (e, t) => {
308
346
  const i = [];
309
347
  let a;
310
348
  if (e.style?.lineArrow === 1 || e.style?.lineArrow === 2 || e.style?.lineArrow === 3) {
311
- const n = Math.PI / 2 - Zi({ targetVector: [e.points[0], e.points[1]] });
312
- e.style?.lineArrow !== 1 && e.style?.lineArrow !== 3 || i.push(Ri(Oi(e.points[0], n, e.style))), e.style?.lineArrow !== 2 && e.style?.lineArrow !== 3 || i.push(Ri(Oi(e.points[1], n + Math.PI, e.style)));
313
- const o = (({ line: s, size: l, direction: r }) => {
314
- const d = Math.PI / 2 - Zi({ targetVector: [s.points[0], s.points[1]] }), h = [s.points[0][0] + (s.points[1][0] - s.points[0][0]) / 2, s.points[0][1] + (s.points[1][1] - s.points[0][1]) / 2];
315
- let c, u;
316
- if (["start", "both"].includes(r)) {
317
- const f = Me({ point: s.points[0], origin: h, rotation: -d });
318
- c = Me({ point: [f[0], f[1] + l], origin: h, rotation: d });
319
- } else c = [...s.points[0]];
320
- if (["end", "both"].includes(r)) {
321
- const f = Me({ point: s.points[1], origin: h, rotation: -d });
322
- u = Me({ point: [f[0], f[1] - l], origin: h, rotation: d });
323
- } else u = [...s.points[1]];
324
- return { points: [c, u] };
349
+ const o = Math.PI / 2 - Wi({ targetVector: [e.points[0], e.points[1]] });
350
+ e.style?.lineArrow !== 1 && e.style?.lineArrow !== 3 || i.push(qi(_i(e.points[0], o, e.style), t)), e.style?.lineArrow !== 2 && e.style?.lineArrow !== 3 || i.push(qi(_i(e.points[1], o + Math.PI, e.style), t));
351
+ const r = (({ line: l, size: s, direction: c }) => {
352
+ const u = Math.PI / 2 - Wi({ targetVector: [l.points[0], l.points[1]] }), d = [l.points[0][0] + (l.points[1][0] - l.points[0][0]) / 2, l.points[0][1] + (l.points[1][1] - l.points[0][1]) / 2];
353
+ let h, f;
354
+ if (["start", "both"].includes(c)) {
355
+ const g = xe({ point: l.points[0], origin: d, rotation: -u });
356
+ h = xe({ point: [g[0], g[1] + s], origin: d, rotation: u });
357
+ } else h = [...l.points[0]];
358
+ if (["end", "both"].includes(c)) {
359
+ const g = xe({ point: l.points[1], origin: d, rotation: -u });
360
+ f = xe({ point: [g[0], g[1] - s], origin: d, rotation: u });
361
+ } else f = [...l.points[1]];
362
+ return { points: [h, f] };
325
363
  })({ line: e, size: 10 + 2 * (e.style?.lineWidth ?? 0), direction: e.style?.lineArrow === 1 ? "start" : e.style?.lineArrow === 2 ? "end" : "both" });
326
- a = Vt(o);
327
- } else a = Vt(e);
328
- return { ...e, path: a, selection: ci(a, e, t), arrows: i, style: { ...e.style, lineCap: e.style?.lineArrow ? "butt" : "round" } };
329
- }, On = zt, Oi = (e, t, i) => {
330
- const a = [Me({ point: [0, 0], rotation: t }), Me({ point: [-(5 + (i.lineWidth ?? 0)), 10 + 2 * (i.lineWidth ?? 0)], rotation: t }), Me({ point: [5 + (i.lineWidth ?? 0), 10 + 2 * (i.lineWidth ?? 0)], rotation: t })];
364
+ a = Zt(r);
365
+ } else a = Zt(e);
366
+ const n = gn(e, t);
367
+ return { ...e, path: a, selection: fi(a, e, n, t), arrows: i, style: { ...e.style, lineCap: e.style?.lineArrow ? "butt" : "round" }, computed: n };
368
+ }, ro = At, _i = (e, t, i) => {
369
+ const a = [xe({ point: [0, 0], rotation: t }), xe({ point: [-(5 + (i.lineWidth ?? 0)), 10 + 2 * (i.lineWidth ?? 0)], rotation: t }), xe({ point: [5 + (i.lineWidth ?? 0), 10 + 2 * (i.lineWidth ?? 0)], rotation: t })];
331
370
  return { points: [[e[0] + a[0][0], e[1] + a[0][1]], [e[0] + a[1][0], e[1] + a[1][1]], [e[0] + a[2][0], e[1] + a[2][1]]], style: { ...i, fillColor: i.strokeColor, strokeColor: "transparent" } };
332
- }, At = (e, t) => ({ ...e, selection: lt(void 0, e, t) }), Fn = At, Yt = (e, t, i, a, n) => {
333
- const [o, s] = ((l, r, d, h, c = !1) => {
334
- if (!(l && r && h && d)) return [Li, Li];
335
- const u = l / r;
336
- if (u > d / h) {
337
- const v = c ? d : Math.min(l, d);
338
- return [v, v / u];
371
+ }, vn = (e, t) => Re(e, vi, t), Et = (e, t) => {
372
+ const i = vn(e, t);
373
+ return { ...e, selection: ut(void 0, i, t), computed: i };
374
+ }, lo = Et, qt = (e, t, i, a, n) => {
375
+ const [o, r] = ((l, s, c, u, d = !1) => {
376
+ if (!(l && s && u && c)) return [Di, Di];
377
+ const h = l / s;
378
+ if (h > c / u) {
379
+ const g = d ? c : Math.min(l, c);
380
+ return [g, g / h];
339
381
  }
340
- const f = c ? h : Math.min(r, h);
341
- return [f * u, f];
382
+ const f = d ? u : Math.min(s, u);
383
+ return [f * h, f];
342
384
  })(e.width, e.height, i, a, !0);
343
- return At({ toolId: ri.id, type: "picture", id: me("picture_"), x: -n.canvasOffset[0] + n.canvasSize.realWidth / n.canvasZoom / 2 - o / 2, y: -n.canvasOffset[1] + n.canvasSize.realHeight / n.canvasZoom / 2 - s / 2, width: o, height: s, src: t, img: e, rotation: 0 }, n);
344
- }, Bn = (e, t, i, a) => new Promise((n, o) => {
345
- const s = new Image();
346
- s.onerror = () => {
385
+ return Et({ toolId: hi.id, type: "picture", id: ye("picture_"), x: -n.canvasOffset[0] + n.canvasSize.realWidth / n.canvasZoom / 2 - o / 2, y: -n.canvasOffset[1] + n.canvasSize.realHeight / n.canvasZoom / 2 - r / 2, width: o, height: r, src: t, img: e }, n);
386
+ }, co = (e, t, i, a) => new Promise((n, o) => {
387
+ const r = new Image();
388
+ r.onerror = () => {
347
389
  o(new Error("Some images could not be loaded"));
348
390
  }, setTimeout(() => {
349
391
  o(new Error("Timeout while loading images"));
350
- }, 4e3), e instanceof File ? ((l, r, d, h, c, u) => {
351
- nn(d) ? d.text().then((f) => {
352
- const v = an(f);
392
+ }, 4e3), e instanceof File ? ((l, s, c, u, d, h) => {
393
+ yn(c) ? c.text().then((f) => {
394
+ const g = mn(f);
353
395
  l.onload = async () => {
354
396
  URL.revokeObjectURL(l.src);
355
- const b = Yt(l, f, h, c, u);
356
- r(b);
357
- }, l.src = v;
397
+ const x = qt(l, f, u, d, h);
398
+ s(x);
399
+ }, l.src = g;
358
400
  }) : (l.onload = async () => {
359
401
  URL.revokeObjectURL(l.src);
360
- const f = Yt(l, l.src, h, c, u);
361
- r(f);
362
- }, l.src = URL.createObjectURL(d));
363
- })(s, n, e, t, i, a) : ((l, r, d, h, c, u) => {
402
+ const f = qt(l, l.src, u, d, h);
403
+ s(f);
404
+ }, l.src = URL.createObjectURL(c));
405
+ })(r, n, e, t, i, a) : ((l, s, c, u, d, h) => {
364
406
  l.onload = () => {
365
407
  URL.revokeObjectURL(l.src);
366
- const f = Yt(l, d, h, c, u);
367
- r(f);
368
- }, on(d).then((f) => {
408
+ const f = qt(l, c, u, d, h);
409
+ s(f);
410
+ }, Sn(c).then((f) => {
369
411
  l.src = f;
370
412
  }).catch(() => {
371
413
  l.src = "";
372
414
  });
373
- })(s, n, e, t, i, a);
374
- }), Xt = ["Texte"], Et = (e, t) => ({ ...e, selection: lt(void 0, e, t) }), $n = Et, di = (e, t, i, a, n, o = ft) => {
415
+ })(r, n, e, t, i, a);
416
+ }), _t = ["Texte"], yi = (e, t) => Re(e, uo, t), It = (e, t) => {
417
+ const i = yi(e, t);
418
+ return { ...e, selection: ut(void 0, i, t), computed: i };
419
+ }, ho = It, Si = (e, t, i, a, n, o = yt) => {
375
420
  e.font = `${n ? "italic" : ""} ${a ? "bold" : ""} 1px ${o}`;
376
- const s = t.map((l) => i / e.measureText(l).width);
377
- return Math.min(...s) || 36;
378
- }, Un = (e, t, i, a) => {
379
- const n = { ...t, value: i }, o = ((v, b, M, P, x, y = ft) => {
380
- v.font = `${x ? "italic" : ""} ${P ? "bold" : ""} ${M}px ${y}`;
381
- const m = b.map((S) => v.measureText(S).width);
421
+ const r = t.map((l) => i / e.measureText(l).width);
422
+ return Math.min(...r) || 36;
423
+ }, uo = (e, t) => ({ x: e.x - t.selectionPadding, width: e.width + 2 * t.selectionPadding, y: e.y - t.selectionPadding, height: e.height + 2 * t.selectionPadding }), po = (e, t, i, a) => {
424
+ const n = { ...t, value: i }, o = ((f, g, x, C, k, w = yt) => {
425
+ f.font = `${k ? "italic" : ""} ${C ? "bold" : ""} ${x}px ${w}`;
426
+ const m = g.map((y) => f.measureText(y).width);
382
427
  return Math.max(...m) || 20;
383
- })(e, n.value, n.fontSize, n.style?.fontBold ?? !1, n.style?.fontItalic ?? !1, n.style?.fontFamily), s = n.fontSize * n.value.length, l = { ...n, width: o, height: s }, { center: r } = ie(t, a), { center: d } = ie(l, a), [h, c] = zi([1, 1], r, t), [u, f] = zi([1, 1], d, l, [!1, !1]);
384
- return { ...l, x: l.x - (u - h), y: l.y - (f - c) };
385
- }, Fi = (e, t, i, a) => {
386
- const n = [Y(i[0], a), Y(i[1], a)];
428
+ })(e, n.value, n.fontSize, n.style?.fontBold ?? !1, n.style?.fontItalic ?? !1, n.style?.fontFamily), r = n.fontSize * n.value.length, l = { ...n, width: o, height: r }, { center: s } = yi(l, a), [c, u] = Fi([1, 1], t.computed.center, t), [d, h] = Fi([1, 1], s, l, [!1, !1]);
429
+ return { ...l, x: l.x - (d - c), y: l.y - (h - u) };
430
+ }, ji = (e, t, i, a) => {
431
+ const n = [_(i[0], a), _(i[1], a)];
387
432
  switch (t.type) {
388
433
  case "brush":
389
- return ((o, s, l) => rt({ toolId: o.id, type: o.type, id: me(`${o.type}_`), points: [[s]], rotation: 0, scaleX: 1, scaleY: 1, style: { opacity: o.settings.opacity.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, l))(t, n, a);
434
+ return ((o, r, l) => ht({ toolId: o.id, type: o.type, id: ye(`${o.type}_`), points: [[r]], scaleX: 1, scaleY: 1, style: { opacity: o.settings.opacity.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, l))(t, n, a);
390
435
  case "line":
391
- return ((o, s, l) => {
392
- const r = { toolId: o.id, type: o.type, id: me(`${o.type}_`), points: [s, s], rotation: 0, style: { opacity: o.settings.opacity.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default, lineArrow: o.settings.lineArrow.default } };
393
- return zt(r, l);
436
+ return ((o, r, l) => {
437
+ const s = { toolId: o.id, type: o.type, id: ye(`${o.type}_`), points: [r, r], style: { opacity: o.settings.opacity.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default, lineArrow: o.settings.lineArrow.default } };
438
+ return At(s, l);
394
439
  })(t, n, a);
395
440
  case "polygon":
396
- return ((o, s, l) => ct({ toolId: o.id, type: o.type, id: me(`${o.type}_`), points: [s], rotation: 0, style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default, closedPoints: o.settings.closedPoints.default } }, l))(t, n, a);
441
+ return ((o, r, l) => pt({ toolId: o.id, type: o.type, id: ye(`${o.type}_`), points: [r], style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default, closedPoints: o.settings.closedPoints.default } }, l))(t, n, a);
397
442
  case "curve":
398
- return ((o, s, l) => dt({ toolId: o.id, type: o.type, id: me(`${o.type}_`), points: [s], rotation: 0, style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default, closedPoints: o.settings.closedPoints.default } }, l))(t, n, a);
443
+ return ((o, r, l) => gt({ toolId: o.id, type: o.type, id: ye(`${o.type}_`), points: [r], style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default, closedPoints: o.settings.closedPoints.default } }, l))(t, n, a);
399
444
  case "rect":
400
445
  case "square":
401
- return Xa(t, n, a);
446
+ return an(t, n, a);
402
447
  case "text":
403
- return ((o, s, l, r) => {
404
- const d = di(o, Xt, 150, s.settings?.fontBold.default ?? !1, s.settings?.fontItalic.default ?? !1, s.settings.fontFamily.default), h = d * (Xt.length || 1);
405
- return Et({ toolId: s.id, type: s.type, id: me(`${s.type}_`), x: l[0] - 150, y: l[1] - h, value: Xt, fontSize: d, width: 150, height: h, rotation: 0, style: { opacity: s.settings.opacity.default, strokeColor: s.settings.strokeColor.default, fontFamily: s.settings.fontFamily.default, fontItalic: s.settings.fontItalic.default, fontBold: s.settings.fontBold.default } }, r);
448
+ return ((o, r, l, s) => {
449
+ const c = Si(o, _t, 150, r.settings?.fontBold.default ?? !1, r.settings?.fontItalic.default ?? !1, r.settings.fontFamily.default), u = c * (_t.length || 1);
450
+ return It({ toolId: r.id, type: r.type, id: ye(`${r.type}_`), x: l[0] - 150, y: l[1] - u, value: _t, fontSize: c, width: 150, height: u, style: { opacity: r.settings.opacity.default, strokeColor: r.settings.strokeColor.default, fontFamily: r.settings.fontFamily.default, fontItalic: r.settings.fontItalic.default, fontBold: r.settings.fontBold.default } }, s);
406
451
  })(e, t, n, a);
407
452
  case "ellipse":
408
- return ((o, s, l) => Tt({ toolId: o.id, type: o.type, id: me(`${o.type}_`), x: s[0], y: s[1], radiusX: 0, radiusY: 0, rotation: 0, style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, l))(t, n, a);
453
+ return ((o, r, l) => zt({ toolId: o.id, type: o.type, id: ye(`${o.type}_`), x: r[0], y: r[1], radiusX: 0, radiusY: 0, style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, l))(t, n, a);
409
454
  case "circle":
410
- return ((o, s, l) => Ht({ toolId: o.id, type: o.type, id: me(`${o.type}_`), x: s[0], y: s[1], radius: 0, rotation: 0, style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, l))(t, n, a);
455
+ return ((o, r, l) => Tt({ toolId: o.id, type: o.type, id: ye(`${o.type}_`), x: r[0], y: r[1], radius: 0, style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, l))(t, n, a);
411
456
  }
412
- }, Bi = (e, t) => {
457
+ }, Ki = (e, t) => {
413
458
  switch (t.type) {
414
459
  case "brush":
415
460
  ((i, a) => {
@@ -419,7 +464,7 @@ const Ni = ({ ctx: e, path: t, rect: i, offset: a, checkFill: n }) => {
419
464
  case "text":
420
465
  ((i, a) => {
421
466
  if (i.globalAlpha !== 0 && a.style?.strokeColor && a.style.strokeColor !== "transparent") {
422
- i.font = `${a.style?.fontItalic ? "italic" : ""} ${a.style?.fontBold ? "bold" : ""} ${a.fontSize}px ${a.style?.fontFamily ?? ft}`, i.textBaseline = "top", i.fillStyle = a.style.strokeColor;
467
+ i.font = `${a.style?.fontItalic ? "italic" : ""} ${a.style?.fontBold ? "bold" : ""} ${a.fontSize}px ${a.style?.fontFamily ?? yt}`, i.textBaseline = "top", i.fillStyle = a.style.strokeColor;
423
468
  for (let n = 0; n < a.value.length; n++) i.fillText(a.value[n], a.x, a.y + n * a.fontSize, a.width);
424
469
  }
425
470
  })(e, t);
@@ -428,7 +473,7 @@ const Ni = ({ ctx: e, path: t, rect: i, offset: a, checkFill: n }) => {
428
473
  ((i, a) => {
429
474
  if (i.globalAlpha !== 0 && a.path) {
430
475
  a.style?.fillColor !== "transparent" && i.fill(a.path), a.style?.strokeColor !== "transparent" && i.stroke(a.path);
431
- for (const n of a.arrows ?? []) Ve(i, n.style), Rn(i, n);
476
+ for (const n of a.arrows ?? []) Qe(i, n.style), oo(i, n);
432
477
  }
433
478
  })(e, t);
434
479
  break;
@@ -454,193 +499,188 @@ const Ni = ({ ctx: e, path: t, rect: i, offset: a, checkFill: n }) => {
454
499
  break;
455
500
  case "rect":
456
501
  case "square":
457
- Vn(e, t);
502
+ Yn(e, t);
458
503
  break;
459
504
  case "picture":
460
505
  ((i, a) => {
461
506
  i.globalAlpha !== 0 && (i.beginPath(), i.drawImage(a.img, a.x, a.y, a.width, a.height));
462
507
  })(e, t);
463
508
  }
464
- }, tn = (e, t, i) => {
509
+ }, fn = (e, t, i) => {
465
510
  if (t.visible === !1) return;
466
- const { center: a, outerBorders: n } = ie(t, i), o = ((s) => {
467
- const { canvasSize: { width: l, height: r, scaleRatioWithNoZoom: d }, canvasZoom: h, canvasOffset: c } = s;
468
- return { x: -c[0], y: -c[1], width: l / h / d, height: r / h / d };
469
- })(i);
470
- if (Jt(n, o)) {
471
- if (Pt(e, i, t.rotation, a), Ve(e, t.style), e.globalAlpha !== 1) return ((s, l, r) => {
472
- const d = document.createElement("canvas"), h = d.getContext("2d");
473
- if (!h) throw new Error("No context found for canvas");
474
- const c = { width: 2 * r.width, height: 2 * r.height };
475
- d.width = c.width, d.height = c.height, h.translate(c.width / 4 - r.x, c.height / 4 - r.y), Ve(h, { ...l.style, opacity: 100 }), Bi(h, l), s.drawImage(d, r.x - c.width / 4, r.y - c.height / 4);
476
- })(e, t, n), void e.restore();
477
- Bi(e, t), e.restore();
478
- }
479
- }, Yn = (e, t) => {
480
- switch (e.type) {
481
- case "brush":
482
- return ((i, { selectionPadding: a }) => {
483
- const n = i.points.flat(), o = Math.min(...n.map((h) => h[0])), s = Math.min(...n.map((h) => h[1])), l = n.map((h) => Ze(h, o, s, i.scaleX, i.scaleY)), r = Math.max(...l.map((h) => h[0])) + a, d = Math.max(...l.map((h) => h[1])) + a;
484
- return { x: o - a, width: r - o + a, y: s - a, height: d - s + a };
485
- })(e, t);
486
- case "line":
487
- return ((i, a) => ({ x: Math.min(i.points[0][0], i.points[1][0]) - a.selectionPadding, width: Math.abs(i.points[0][0] - i.points[1][0]) + 2 * a.selectionPadding, y: Math.min(i.points[0][1], i.points[1][1]) - a.selectionPadding, height: Math.abs(i.points[0][1] - i.points[1][1]) + 2 * a.selectionPadding }))(e, t);
488
- case "polygon":
489
- return en(e, t);
490
- case "curve":
491
- return Nn(e, t);
492
- case "circle":
493
- return ((i, a) => ({ x: i.x - i.radius - a.selectionPadding, width: 2 * (i.radius + a.selectionPadding), y: i.y - i.radius - a.selectionPadding, height: 2 * (i.radius + a.selectionPadding) }))(e, t);
494
- case "ellipse":
495
- return ((i, a) => ({ x: i.x - i.radiusX - a.selectionPadding, width: 2 * (i.radiusX + a.selectionPadding), y: i.y - i.radiusY - a.selectionPadding, height: 2 * (i.radiusY + a.selectionPadding) }))(e, t);
496
- case "rect":
497
- case "square":
498
- case "group":
499
- return Ti(e, t);
500
- case "text":
501
- return ((i, a) => ({ x: i.x - a.selectionPadding, width: i.width + 2 * a.selectionPadding, y: i.y - a.selectionPadding, height: i.height + 2 * a.selectionPadding }))(e, t);
502
- case "picture":
503
- return ((i, a) => Ti(i, a))(e, t);
504
- default:
505
- return { x: 0, y: 0, width: 100, height: 100 };
511
+ if (((n, o) => {
512
+ const r = ((l) => {
513
+ const { canvasSize: { width: s, height: c, scaleRatioWithNoZoom: u }, canvasZoom: d, canvasOffset: h } = l;
514
+ return { x: -h[0], y: -h[1], width: s / d / u, height: c / d / u };
515
+ })(o);
516
+ return !!ii(n.computed.boundingBox, r);
517
+ })(t, i)) {
518
+ if (Pt(e, i, t.rotation, t.computed.center), Qe(e, t.style), e.globalAlpha !== 1) return ((n, o) => {
519
+ const r = document.createElement("canvas"), l = r.getContext("2d");
520
+ if (!l) throw new Error("No context found for canvas");
521
+ const { outerBorders: s } = o.computed, c = { width: 2 * s.width, height: 2 * s.height };
522
+ r.width = c.width, r.height = c.height, l.translate(c.width / 4 - s.x, c.height / 4 - s.y), Qe(l, { ...o.style, opacity: 100 }), Ki(l, o), n.drawImage(r, s.x - c.width / 4, s.y - c.height / 4);
523
+ })(e, t), void e.restore();
524
+ Ki(e, t), e.restore();
506
525
  }
507
- }, ie = (e, t) => {
508
- const i = Yn(e, t), a = { x: i.x - (e.style?.lineWidth ?? 0), y: i.y - (e.style?.lineWidth ?? 0), width: i.width + 2 * (e.style?.lineWidth ?? 0), height: i.height + 2 * (e.style?.lineWidth ?? 0) }, n = ((o) => [o.x + o.width / 2, o.y + o.height / 2])(i);
509
- return { borders: i, outerBorders: a, center: n };
510
- }, Xn = (e, t, i, a, n, o, s) => {
511
- const l = n[0] - a[0], r = n[1] - a[1], d = n[0] - t[0], h = n[1] - t[1], c = i.rotation + Math.atan2(h, d) - Math.atan2(r, l);
512
- return { ...e, rotation: Cn(c, o, s) };
513
- }, Gn = (e, t, i, a, n, o, s, l) => {
526
+ }, go = (e, t, i, a, n, o, r) => {
527
+ const l = n[0] - a[0], s = n[1] - a[1], c = n[0] - t[0], u = n[1] - t[1], d = { ...e, rotation: Dn((i.rotation ?? 0) + Math.atan2(u, c) - Math.atan2(s, l), o, r) };
528
+ return { ...d, computed: fo(d, o) };
529
+ }, vo = (e, t, i, a, n, o, r, l) => {
514
530
  switch (a.type) {
515
531
  case "line":
516
- return ((r, d, h, c) => {
517
- const u = [Y(r[0], c), Y(r[1], c)], { center: f } = ie(d, c), v = He(u, d.rotation, f), b = Ce(["points", h.anchor], v, d);
518
- return zt(b, c);
532
+ return ((s, c, u, d) => {
533
+ const h = [_(s[0], d), _(s[1], d)], f = Ae(h, c.rotation ?? 0, c.computed.center), g = Pe(["points", u.anchor], f, c);
534
+ return At(g, d);
519
535
  })(i, a, n, o);
520
536
  case "polygon":
521
- return ((r, d, h, c) => {
522
- const u = [Y(r[0], c), Y(r[1], c)], { center: f } = ie(d, c), v = He(u, d.rotation, f), b = Ce(["points", h.anchor], v, d);
523
- return ct(b, c);
537
+ return ((s, c, u, d) => {
538
+ const h = [_(s[0], d), _(s[1], d)], f = Ae(h, c.rotation ?? 0, c.computed.center), g = Pe(["points", u.anchor], f, c);
539
+ return pt(g, d);
524
540
  })(i, a, n, o);
525
541
  case "curve":
526
- return ((r, d, h, c) => {
527
- const u = [Y(r[0], c), Y(r[1], c)], { center: f } = ie(d, c), v = He(u, d.rotation, f), b = Ce(["points", h.anchor], v, d);
528
- return dt(b, c);
542
+ return ((s, c, u, d) => {
543
+ const h = [_(s[0], d), _(s[1], d)], f = c.computed.center, g = Ae(h, c.rotation ?? 0, f), x = Pe(["points", u.anchor], g, c);
544
+ return gt(x, d);
529
545
  })(i, a, n, o);
530
546
  case "brush":
531
- return ((r, d, h, c, u, f) => {
532
- const { borders: v } = ie({ ...d, scaleX: 1, scaleY: 1 }, c), { borders: b } = ie(d, c), { borderX: M, borderHeight: P, borderY: x, borderWidth: y } = et(r, d, h, c, u, f), m = Math.max(0, v.width - 2 * c.selectionPadding), S = Math.max(0, v.height - 2 * c.selectionPadding), E = Math.max(0, y - 2 * c.selectionPadding), H = Math.max(0, P - 2 * c.selectionPadding), z = m ? E / m : 1, T = S ? H / S : 1;
533
- if (!m || !S) return d;
534
- const V = $e(M - b.x), I = $e(x - b.y);
535
- return rt({ ...d, points: d.points.map((W) => W.map(([A, R]) => [A + V, R + I])), scaleX: z, scaleY: T }, c);
536
- })(i, a, n, o, s, l);
547
+ return ((s, c, u, d, h, f) => {
548
+ const g = _a({ ...c, scaleX: 1, scaleY: 1 }, d), x = c.computed.borders, { borderX: C, borderHeight: k, borderY: w, borderWidth: m } = nt(s, c, u, d, h, f), y = Math.max(0, g.width - 2 * d.selectionPadding), b = Math.max(0, g.height - 2 * d.selectionPadding), Z = Math.max(0, m - 2 * d.selectionPadding), A = Math.max(0, k - 2 * d.selectionPadding), T = y ? Z / y : 1, S = b ? A / b : 1;
549
+ if (!y || !b) return c;
550
+ const V = Xe(C - x.x), I = Xe(w - x.y);
551
+ return ht({ ...c, points: c.points.map((N) => N.map(([H, D]) => [H + V, D + I])), scaleX: T, scaleY: S }, d);
552
+ })(i, a, n, o, r, l);
537
553
  case "circle":
538
- return ((r, d, h, c, u) => {
539
- const { borderX: f, borderHeight: v, borderY: b, borderWidth: M } = et(r, d, h, c, !0, u);
540
- return Ht({ ...d, radius: Math.max(0, M / 2 - c.selectionPadding), x: f + M / 2, y: b + v / 2 }, c);
554
+ return ((s, c, u, d, h) => {
555
+ const { borderX: f, borderHeight: g, borderY: x, borderWidth: C } = nt(s, c, u, d, !0, h);
556
+ return Tt({ ...c, radius: Math.max(0, C / 2 - d.selectionPadding), x: f + C / 2, y: x + g / 2 }, d);
541
557
  })(i, a, n, o, l);
542
558
  case "ellipse":
543
- return ((r, d, h, c, u = !1, f = !1) => {
544
- const { borderX: v, borderHeight: b, borderY: M, borderWidth: P } = et(r, d, h, c, u, f);
545
- return Tt({ ...d, radiusX: Math.max(0, P / 2 - c.selectionPadding), radiusY: Math.max(0, b / 2 - c.selectionPadding), x: v + P / 2, y: M + b / 2 }, c);
546
- })(i, a, n, o, s, l);
559
+ return ((s, c, u, d, h = !1, f = !1) => {
560
+ const { borderX: g, borderHeight: x, borderY: C, borderWidth: k } = nt(s, c, u, d, h, f);
561
+ return zt({ ...c, radiusX: Math.max(0, k / 2 - d.selectionPadding), radiusY: Math.max(0, x / 2 - d.selectionPadding), x: g + k / 2, y: C + x / 2 }, d);
562
+ })(i, a, n, o, r, l);
547
563
  case "rect":
548
564
  case "square":
549
- return ((r, d, h, c, u = !1, f = !1) => {
550
- const { borderX: v, borderHeight: b, borderY: M, borderWidth: P } = et(r, d, h, c, u, f);
551
- return Zt({ ...d, width: Math.max(0, P - 2 * c.selectionPadding), height: Math.max(0, b - 2 * c.selectionPadding), x: v + c.selectionPadding, y: M + c.selectionPadding }, c);
552
- })(i, a, n, o, t.type === "square" || s, l);
565
+ return ((s, c, u, d, h = !1, f = !1) => {
566
+ const { borderX: g, borderHeight: x, borderY: C, borderWidth: k } = nt(s, c, u, d, h, f);
567
+ return Ht({ ...c, width: Math.max(0, k - 2 * d.selectionPadding), height: Math.max(0, x - 2 * d.selectionPadding), x: g + d.selectionPadding, y: C + d.selectionPadding }, d);
568
+ })(i, a, n, o, t.type === "square" || r, l);
553
569
  case "text":
554
- return ((r, d, h, c, u, f) => {
555
- const { borderX: v, borderHeight: b, borderY: M, borderWidth: P } = et(d, h, c, u, !0, f), x = Et({ ...h, width: Math.max(0, P - 2 * u.selectionPadding), height: Math.max(0, b - 2 * u.selectionPadding), x: v + u.selectionPadding, y: M + u.selectionPadding }, u);
556
- return { ...x, fontSize: di(r, x.value, x.width, x.style?.fontBold ?? !1, x.style?.fontItalic ?? !1, x.style?.fontFamily) };
570
+ return ((s, c, u, d, h, f) => {
571
+ const { borderX: g, borderHeight: x, borderY: C, borderWidth: k } = nt(c, u, d, h, !0, f), w = It({ ...u, width: Math.max(0, k - 2 * h.selectionPadding), height: Math.max(0, x - 2 * h.selectionPadding), x: g + h.selectionPadding, y: C + h.selectionPadding }, h);
572
+ return { ...w, fontSize: Si(s, w.value, w.width, w.style?.fontBold ?? !1, w.style?.fontItalic ?? !1, w.style?.fontFamily) };
557
573
  })(e, i, a, n, o, l);
558
574
  case "picture":
559
- return ((r, d, h, c, u) => {
560
- const { borderX: f, borderHeight: v, borderY: b, borderWidth: M } = et(r, d, h, c, !0, u);
561
- return At({ ...d, width: Math.max(0, M - 2 * c.selectionPadding), height: Math.max(0, v - 2 * c.selectionPadding), x: f + c.selectionPadding, y: b + c.selectionPadding }, c);
575
+ return ((s, c, u, d, h) => {
576
+ const { borderX: f, borderHeight: g, borderY: x, borderWidth: C } = nt(s, c, u, d, !0, h);
577
+ return Et({ ...c, width: Math.max(0, C - 2 * d.selectionPadding), height: Math.max(0, g - 2 * d.selectionPadding), x: f + d.selectionPadding, y: x + d.selectionPadding }, d);
562
578
  })(i, a, n, o, l);
563
579
  default:
564
580
  return a;
565
581
  }
566
- }, ii = (e, t, i, a, n) => {
582
+ }, oi = (e, t, i, a, n) => {
567
583
  switch (t.type) {
568
584
  case "rect":
569
585
  case "square":
570
- return ((o, s, l, r, d) => {
571
- const h = Fe([o[0] - l[0], o[1] - l[1]], d);
572
- return Zt({ ...s, x: Y(s.x + h[0], r), y: Y(s.y + h[1], r) }, r);
586
+ return ((o, r, l, s, c) => {
587
+ const u = Oe([o[0] - l[0], o[1] - l[1]], c);
588
+ return Ht({ ...r, x: _(r.x + u[0], s), y: _(r.y + u[1], s) }, s);
573
589
  })(e, t, i, a, n);
574
590
  case "ellipse":
575
- return ((o, s, l, r, d) => {
576
- const h = Fe([o[0] - l[0], o[1] - l[1]], d);
577
- return Tt({ ...s, x: Y(s.x + h[0], r), y: Y(s.y + h[1], r) }, r);
591
+ return ((o, r, l, s, c) => {
592
+ const u = Oe([o[0] - l[0], o[1] - l[1]], c);
593
+ return zt({ ...r, x: _(r.x + u[0], s), y: _(r.y + u[1], s) }, s);
578
594
  })(e, t, i, a, n);
579
595
  case "circle":
580
- return ((o, s, l, r, d) => {
581
- const h = Fe([o[0] - l[0], o[1] - l[1]], d);
582
- return Ht({ ...s, x: Y(s.x + h[0], r), y: Y(s.y + h[1], r) }, r);
596
+ return ((o, r, l, s, c) => {
597
+ const u = Oe([o[0] - l[0], o[1] - l[1]], c);
598
+ return Tt({ ...r, x: _(r.x + u[0], s), y: _(r.y + u[1], s) }, s);
583
599
  })(e, t, i, a, n);
584
600
  case "picture":
585
- return ((o, s, l, r, d) => {
586
- const h = Fe([o[0] - l[0], o[1] - l[1]], d);
587
- return At({ ...s, x: Y(s.x + h[0], r), y: Y(s.y + h[1], r) }, r);
601
+ return ((o, r, l, s, c) => {
602
+ const u = Oe([o[0] - l[0], o[1] - l[1]], c);
603
+ return Et({ ...r, x: _(r.x + u[0], s), y: _(r.y + u[1], s) }, s);
588
604
  })(e, t, i, a, n);
589
605
  case "text":
590
- return ((o, s, l, r, d) => {
591
- const h = Fe([o[0] - l[0], o[1] - l[1]], d);
592
- return Et({ ...s, x: Y(s.x + h[0], r), y: Y(s.y + h[1], r) }, r);
606
+ return ((o, r, l, s, c) => {
607
+ const u = Oe([o[0] - l[0], o[1] - l[1]], c);
608
+ return It({ ...r, x: _(r.x + u[0], s), y: _(r.y + u[1], s) }, s);
593
609
  })(e, t, i, a, n);
594
610
  case "line":
595
- return ((o, s, l, r, d) => {
596
- const h = Fe([o[0] - l[0], o[1] - l[1]], d);
597
- return zt({ ...s, points: s.points.map(([c, u]) => [Y(c + h[0], r), Y(u + h[1], r)]) }, r);
611
+ return ((o, r, l, s, c) => {
612
+ const u = Oe([o[0] - l[0], o[1] - l[1]], c);
613
+ return At({ ...r, points: r.points.map(([d, h]) => [_(d + u[0], s), _(h + u[1], s)]) }, s);
598
614
  })(e, t, i, a, n);
599
615
  case "polygon":
600
- return ((o, s, l, r, d) => {
601
- const h = Fe([o[0] - l[0], o[1] - l[1]], d), { borders: c } = ie(s, r);
602
- return ct({ ...s, points: s.points.map(([u, f]) => r.gridGap ? [u + Y(c.x + h[0], r) - c.x, f + Y(c.y + h[1], r) - c.y] : [Y(u + o[0] - l[0], r), Y(f + o[1] - l[1], r)]) }, r);
616
+ return ((o, r, l, s, c) => {
617
+ const u = Oe([o[0] - l[0], o[1] - l[1]], c), d = r.computed.borders;
618
+ return pt({ ...r, points: r.points.map(([h, f]) => s.gridGap ? [h + _(d.x + u[0], s) - d.x, f + _(d.y + u[1], s) - d.y] : [_(h + o[0] - l[0], s), _(f + o[1] - l[1], s)]) }, s);
603
619
  })(e, t, i, a, n);
604
620
  case "curve":
605
- return ((o, s, l, r, d) => {
606
- const { borders: h } = ie(s, r), c = Fe([o[0] - l[0], o[1] - l[1]], d);
607
- return dt({ ...s, points: s.points.map(([u, f]) => r.gridGap ? [u + Y(h.x + c[0], r) - h.x, f + Y(h.y + c[1], r) - h.y] : [Y(u + c[0], r), Y(f + c[1], r)]) }, r);
621
+ return ((o, r, l, s, c) => {
622
+ const u = r.computed.borders, d = Oe([o[0] - l[0], o[1] - l[1]], c);
623
+ return gt({ ...r, points: r.points.map(([h, f]) => s.gridGap ? [h + _(u.x + d[0], s) - u.x, f + _(u.y + d[1], s) - u.y] : [_(h + d[0], s), _(f + d[1], s)]) }, s);
608
624
  })(e, t, i, a, n);
609
625
  case "brush":
610
- return ((o, s, l, r, d) => {
611
- const { borders: h } = ie(s, r), c = Fe([o[0] - l[0], o[1] - l[1]], d), u = r.gridGap ? Y(h.x + c[0], r) - h.x : c[0], f = r.gridGap ? Y(h.y + c[1], r) - h.y : c[1];
612
- return rt({ ...s, points: s.points.map((v) => v.map(([b, M]) => [b + u, M + f])) }, r);
626
+ return ((o, r, l, s, c) => {
627
+ const u = r.computed.borders, d = Oe([o[0] - l[0], o[1] - l[1]], c), h = s.gridGap ? _(u.x + d[0], s) - u.x : d[0], f = s.gridGap ? _(u.y + d[1], s) - u.y : d[1];
628
+ return ht({ ...r, points: r.points.map((g) => g.map(([x, C]) => [x + h, C + f])) }, s);
613
629
  })(e, t, i, a, n);
614
630
  default:
615
631
  return t;
616
632
  }
617
- }, st = (e, t) => {
633
+ }, dt = (e, t) => {
618
634
  switch (e.type) {
619
635
  case "rect":
620
636
  case "square":
621
- return Ln(e, t);
637
+ return $n(e, t);
622
638
  case "ellipse":
623
- return In(e, t);
639
+ return ao(e, t);
624
640
  case "circle":
625
- return zn(e, t);
641
+ return _n(e, t);
626
642
  case "picture":
627
- return Fn(e, t);
643
+ return lo(e, t);
628
644
  case "text":
629
- return $n(e, t);
645
+ return ho(e, t);
630
646
  case "line":
631
- return On(e, t);
647
+ return ro(e, t);
632
648
  case "polygon":
633
- return An(e, t);
649
+ return jn(e, t);
634
650
  case "curve":
635
- return Dn(e, t);
651
+ return eo(e, t);
636
652
  case "brush":
637
- return xn(e, t);
653
+ return Nn(e, t);
638
654
  default:
639
655
  return e;
640
656
  }
641
- }, $i = ({ ctx: e, shape: t, settings: i, selectionWidth: a, selectionColor: n, hoverMode: o, withAnchors: s = !0 }) => {
642
- const { center: l } = ie(t, i);
643
- switch (Pt(e, i, t.rotation, l), t.type) {
657
+ }, fo = (e, t) => {
658
+ switch (e.type) {
659
+ case "rect":
660
+ case "square":
661
+ return tn(e, t);
662
+ case "ellipse":
663
+ return pn(e, t);
664
+ case "circle":
665
+ return dn(e, t);
666
+ case "picture":
667
+ return vn(e, t);
668
+ case "text":
669
+ return yi(e, t);
670
+ case "line":
671
+ return gn(e, t);
672
+ case "polygon":
673
+ return hn(e, t);
674
+ case "curve":
675
+ return un(e, t);
676
+ case "brush":
677
+ return ja(e, t);
678
+ }
679
+ }, Ji = ({ ctx: e, shape: t, settings: i, selectionWidth: a, selectionColor: n, hoverMode: o, withAnchors: r = !0 }) => {
680
+ const { center: l } = t.computed;
681
+ switch (i.debug && ((s, c, u, d) => {
682
+ c.selection && d.debug && (s.save(), s.scale(d.canvasSize.scaleRatio, d.canvasSize.scaleRatio), s.translate(d.canvasOffset[0], d.canvasOffset[1]), Qe(s, { fillColor: "transparent", strokeColor: "green", lineWidth: u / d.canvasSize.scaleRatio }), s.strokeRect(c.computed.boundingBox.x, c.computed.boundingBox.y, c.computed.boundingBox.width, c.computed.boundingBox.height), s.restore());
683
+ })(e, t, a, i), Pt(e, i, t.rotation, l), t.type) {
644
684
  case "rect":
645
685
  case "square":
646
686
  case "circle":
@@ -648,710 +688,707 @@ const Ni = ({ ctx: e, path: t, rect: i, offset: a, checkFill: n }) => {
648
688
  case "picture":
649
689
  case "text":
650
690
  case "brush":
651
- ((r, d, h, c, u, f) => {
652
- if (d.selection && (Ve(r, { fillColor: "transparent", strokeColor: h, lineWidth: c / u.canvasSize.scaleRatio }), d.selection.shapePath ? r.stroke(d.selection.shapePath) : r.stroke(d.selection.border), f && !d.locked)) {
653
- d.selection.shapePath && r.stroke(d.selection.border), d.selection.line && r.stroke(d.selection.line), Ve(r, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / u.canvasSize.scaleRatio, shadowColor: h, shadowBlur: 0 });
654
- for (const v of d.selection.anchors) r.fill(v), r.stroke(v);
691
+ ((s, c, u, d, h, f) => {
692
+ if (c.selection && (h.debug && (Qe(s, { fillColor: "transparent", strokeColor: "red", lineWidth: d / h.canvasSize.scaleRatio }), s.strokeRect(c.computed.outerBorders.x, c.computed.outerBorders.y, c.computed.outerBorders.width, c.computed.outerBorders.height)), Qe(s, { fillColor: "transparent", strokeColor: u, lineWidth: d / h.canvasSize.scaleRatio }), c.selection.shapePath ? s.stroke(c.selection.shapePath) : s.stroke(c.selection.border), f && !c.locked)) {
693
+ c.selection.shapePath && s.stroke(c.selection.border), c.selection.line && s.stroke(c.selection.line), Qe(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / h.canvasSize.scaleRatio, shadowColor: u, shadowBlur: 0 });
694
+ for (const g of c.selection.anchors) s.fill(g), s.stroke(g);
655
695
  }
656
- })(e, t, n, a, i, s);
696
+ })(e, t, n, a, i, r);
657
697
  break;
658
698
  case "group":
659
- ((r, d, h, c, u, f) => {
660
- if (d.selection) {
661
- if (Ve(r, { fillColor: "transparent", strokeColor: h, lineWidth: c / u.canvasSize.scaleRatio }), f && !d.locked) {
662
- r.stroke(d.selection.border), d.selection.line && r.stroke(d.selection.line), Ve(r, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / u.canvasSize.scaleRatio });
663
- for (const v of d.selection.anchors) r.fill(v), r.stroke(v);
699
+ ((s, c, u, d, h, f) => {
700
+ if (c.selection) {
701
+ if (h.debug && (Qe(s, { fillColor: "transparent", strokeColor: "red", lineWidth: d / h.canvasSize.scaleRatio }), s.strokeRect(c.computed.outerBorders.x, c.computed.outerBorders.y, c.computed.outerBorders.width, c.computed.outerBorders.height)), Qe(s, { fillColor: "transparent", strokeColor: u, lineWidth: d / h.canvasSize.scaleRatio }), f && !c.locked) {
702
+ s.stroke(c.selection.border), c.selection.line && s.stroke(c.selection.line), Qe(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / h.canvasSize.scaleRatio });
703
+ for (const g of c.selection.anchors) s.fill(g), s.stroke(g);
664
704
  }
665
- d.shapes.forEach((v) => {
666
- r.restore(), Ve(r, { fillColor: "transparent", strokeColor: h, lineWidth: c / u.canvasSize.scaleRatio });
667
- const { center: b } = ie(v, u);
668
- Pt(r, u, v.rotation, b), v.selection?.shapePath && r.stroke(v.selection.shapePath);
705
+ c.shapes.forEach((g) => {
706
+ s.restore(), Qe(s, { fillColor: "transparent", strokeColor: u, lineWidth: d / h.canvasSize.scaleRatio }), Pt(s, h, g.rotation, g.computed.center), g.selection?.shapePath && s.stroke(g.selection.shapePath);
669
707
  });
670
708
  }
671
- })(e, t, n, a, i, s);
709
+ })(e, t, n, a, i, r);
672
710
  break;
673
711
  case "polygon":
674
712
  case "line":
675
713
  case "curve":
676
- (({ ctx: r, shape: d, withAnchors: h, selectionWidth: c, selectionColor: u, hoverMode: f, settings: v }) => {
677
- if (d.selection && (Ve(r, { fillColor: "transparent", strokeColor: u, lineWidth: c / v.canvasSize.scaleRatio }), d.selection.shapePath && r.stroke(d.selection.shapePath), h && !d.locked)) {
678
- Ve(r, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / v.canvasSize.scaleRatio, shadowColor: u, shadowBlur: 0 });
679
- for (let b = 0; b < d.selection.anchors.length; b++) {
680
- const M = d.selection.anchors[b];
681
- f.mode === "resize" && f.anchor === b ? (r.shadowBlur = 10, r.fill(M), r.shadowBlur = 0) : r.fill(M), r.stroke(M);
714
+ (({ ctx: s, shape: c, withAnchors: u, selectionWidth: d, selectionColor: h, hoverMode: f, settings: g }) => {
715
+ if (c.selection && (g.debug && (Qe(s, { fillColor: "transparent", strokeColor: "red", lineWidth: d / g.canvasSize.scaleRatio }), s.strokeRect(c.computed.outerBorders.x, c.computed.outerBorders.y, c.computed.outerBorders.width, c.computed.outerBorders.height)), Qe(s, { fillColor: "transparent", strokeColor: h, lineWidth: d / g.canvasSize.scaleRatio }), c.selection.shapePath && s.stroke(c.selection.shapePath), u && !c.locked)) {
716
+ Qe(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / g.canvasSize.scaleRatio, shadowColor: h, shadowBlur: 0 });
717
+ for (let x = 0; x < c.selection.anchors.length; x++) {
718
+ const C = c.selection.anchors[x];
719
+ f.mode === "resize" && f.anchor === x ? (s.shadowBlur = 10, s.fill(C), s.shadowBlur = 0) : s.fill(C), s.stroke(C);
682
720
  }
683
721
  }
684
- })({ ctx: e, shape: t, withAnchors: s, selectionWidth: a, selectionColor: n, hoverMode: o, settings: i });
722
+ })({ ctx: e, shape: t, withAnchors: r, selectionWidth: a, selectionColor: n, hoverMode: o, settings: i });
685
723
  }
686
724
  e.restore();
687
- }, qn = ({ ctx: e, selectionFrame: t, settings: i }) => {
725
+ }, mo = ({ ctx: e, selectionFrame: t, settings: i }) => {
688
726
  Pt(e, i), ((a, n, o) => {
689
- Ve(a, { fillColor: "rgba(170,170,170, 0.1)", strokeColor: "rgb(170,170,170)", lineWidth: 1 / o.canvasSize.scaleRatio }), a.fillRect(n[0][0], n[0][1], n[1][0] - n[0][0], n[1][1] - n[0][1]), a.strokeRect(n[0][0], n[0][1], n[1][0] - n[0][0], n[1][1] - n[0][1]);
727
+ Qe(a, { fillColor: "rgba(170,170,170, 0.1)", strokeColor: "rgb(170,170,170)", lineWidth: 1 / o.canvasSize.scaleRatio }), a.fillRect(n[0][0], n[0][1], n[1][0] - n[0][0], n[1][1] - n[0][1]), a.strokeRect(n[0][0], n[0][1], n[1][0] - n[0][0], n[1][1] - n[0][1]);
690
728
  })(e, t.frame, i), e.restore();
691
- }, hi = (e) => e.filter((t) => t != null), an = (e) => {
729
+ }, Qi = (e) => e.filter((t) => t != null), mn = (e) => {
692
730
  const t = new DOMParser().parseFromString(e, "text/xml").getElementsByTagName("svg")[0];
693
731
  if (!t) return "";
694
732
  const i = t.getAttribute("width"), a = t.getAttribute("height");
695
733
  let n;
696
734
  if (i || a) n = e;
697
735
  else {
698
- const s = t.getAttribute("viewBox") ?? "0 0 300 300", [, , l, r] = s.split(" ");
699
- t.setAttribute("width", l ?? "300"), t.setAttribute("height", r ?? "300"), n = new XMLSerializer().serializeToString(t);
736
+ const r = t.getAttribute("viewBox") ?? "0 0 300 300", [, , l, s] = r.split(" ");
737
+ t.setAttribute("width", l ?? "300"), t.setAttribute("height", s ?? "300"), n = new XMLSerializer().serializeToString(t);
700
738
  }
701
739
  const o = new Blob([n], { type: "image/svg+xml" });
702
740
  return URL.createObjectURL(o);
703
- }, nn = (e) => (e instanceof File ? e.name : e).includes(".svg"), on = (e) => nn(e) ? fetch(e).then((t) => t.text()).then((t) => an(t)) : fetch(e).then((t) => t.blob()).then((t) => URL.createObjectURL(t)), Ui = (e, t) => {
741
+ }, yn = (e) => (e instanceof File ? e.name : e).includes(".svg"), Sn = (e) => yn(e) ? fetch(e).then((t) => t.text()).then((t) => mn(t)) : fetch(e).then((t) => t.blob()).then((t) => URL.createObjectURL(t)), ea = (e, t) => {
704
742
  const i = document.createElement("a");
705
743
  i.href = e, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i);
706
- }, _n = (e) => e.src.includes("<svg") ? e.src : ((t) => {
744
+ }, yo = (e) => e.src.includes("<svg") ? e.src : ((t) => {
707
745
  const i = document.createElement("canvas");
708
746
  i.width = t.width, i.height = t.height;
709
747
  const a = i.getContext("2d");
710
748
  return a ? (a.drawImage(t, 0, 0), i.toDataURL("image/png")) : "";
711
- })(e.img), Gt = ({ shapes: e, settings: t }) => {
749
+ })(e.img), jt = ({ shapes: e, settings: t }) => {
712
750
  const i = document.createElement("canvas"), a = i.getContext("2d");
713
751
  if (!a) throw new Error("No context found for canvas");
714
752
  const { realHeight: n, realWidth: o } = t.canvasSize;
715
- i.width = o, i.height = n, a.clearRect(0, 0, o, n), Oa(a);
716
- for (let s = e.length - 1; s >= 0; s--) tn(a, e[s], t);
753
+ i.width = o, i.height = n, a.clearRect(0, 0, o, n), qa(a);
754
+ for (let r = e.length - 1; r >= 0; r--) fn(a, e[r], t);
717
755
  return i.toDataURL("image/png");
718
- }, Yi = ({ shapes: e, settings: t, view: i }) => {
756
+ }, ta = ({ shapes: e, settings: t, view: i }) => {
719
757
  if (i === "fitToShapes" && !e.length) throw new Error("No image found to export");
720
758
  if (i === "fitToShapes") {
721
- const n = e.map((h) => {
722
- const c = ie(h, t).borders, u = (h.style?.lineWidth ?? 0) / 2;
723
- return { minX: c.x - u, minY: c.y - u, maxX: c.x + c.width + u, maxY: c.y + c.height + u };
724
- }), o = Math.min(...n.map((h) => h.minX)), s = Math.max(...n.map((h) => h.maxX)), l = Math.min(...n.map((h) => h.minY)), r = Math.max(...n.map((h) => h.maxY)), d = { ...t, canvasOffset: [-o, -l], canvasZoom: 1, canvasSize: { realWidth: s - o, realHeight: r - l, width: s - o, height: r - l, scaleRatio: 1, scaleRatioWithNoZoom: 1 } };
725
- return Gt({ shapes: e, settings: d });
759
+ const n = Math.min(...e.map((c) => c.computed.boundingBox.x)), o = Math.max(...e.map((c) => c.computed.boundingBox.x + c.computed.boundingBox.width)), r = Math.min(...e.map((c) => c.computed.boundingBox.y)), l = Math.max(...e.map((c) => c.computed.boundingBox.y + c.computed.boundingBox.height)), s = { ...t, canvasOffset: [-n, -r], canvasZoom: 1, canvasSize: { realWidth: o - n, realHeight: l - r, width: o - n, height: l - r, scaleRatio: 1, scaleRatioWithNoZoom: 1 } };
760
+ return jt({ shapes: e, settings: s });
726
761
  }
727
762
  if (i === "defaultView") {
728
763
  const n = { ...t, canvasOffset: [0, 0], canvasZoom: 1, canvasSize: { ...t.canvasSize, width: t.canvasSize.realWidth, height: t.canvasSize.realHeight, scaleRatio: 1, scaleRatioWithNoZoom: 1 } };
729
- return Gt({ shapes: e, settings: n });
764
+ return jt({ shapes: e, settings: n });
730
765
  }
731
766
  const a = { ...t, canvasSize: { ...t.canvasSize, width: t.canvasSize.realWidth, height: t.canvasSize.realHeight, scaleRatio: t.canvasZoom, scaleRatioWithNoZoom: 1 } };
732
- return Gt({ shapes: e, settings: a });
733
- }, jn = (e, t, i) => {
734
- return n = ui(e, t, i), `data:text/plain;charset=utf-8,${encodeURIComponent(JSON.stringify(n))}`;
767
+ return jt({ shapes: e, settings: a });
768
+ }, So = (e, t, i) => {
769
+ return n = bi(e, t, i), `data:text/plain;charset=utf-8,${encodeURIComponent(JSON.stringify(n))}`;
735
770
  var n;
736
- }, Kn = (e) => {
737
- const t = ["img", "id", "selection", "path", "arrows", "tempPoint"];
738
- return e.map((i) => i.type !== "picture" || i.src.startsWith("http") ? _t(t, i) : _t(t, { ...i, src: _n(i) }));
739
- }, ui = (e, t, i) => ({ shapes: Kn(e), config: { width: t, height: i } }), Xi = (e, t) => st({ ...e, id: me(`${e.type}_`) }, t), Jn = (e, t, i, a) => {
740
- const n = ae([]), o = ae({ dataChanged: [] }), [s, l] = $(void 0), [r, d] = $(void 0), [h, c] = $(void 0), [u, f] = $({ states: [{ shapes: [], selectedShape: void 0, source: "remote" }], cursor: 0 }), v = u.cursor > 0, b = u.cursor < u.states.length - 1, M = n.current.length > 0, P = F(() => {
741
- f((p) => Ia(p.states[p.cursor]?.shapes, n.current) ? p : { states: [...p.states.slice(0, p.cursor + 1), { shapes: n.current, selectedShape: r, source: "user" }], cursor: p.cursor + 1 });
742
- }, [r]), x = F((p) => {
771
+ }, Qo = (e) => {
772
+ const t = ["img", "id", "selection", "path", "arrows", "tempPoint", "computed"];
773
+ return e.map((i) => i.type !== "picture" || i.src.startsWith("http") ? Jt(t, i) : Jt(t, { ...i, src: yo(i) }));
774
+ }, bi = (e, t, i) => ({ shapes: Qo(e), config: { width: t, height: i } }), ia = (e, t) => dt({ ...e, id: ye(`${e.type}_`) }, t), bo = (e, t, i, a) => {
775
+ const n = te([]), o = te({ dataChanged: [] }), [r, l] = $(void 0), [s, c] = $(void 0), [u, d] = $(void 0), [h, f] = $({ states: [{ shapes: [], selectedShape: void 0, source: "remote" }], cursor: 0 }), g = h.cursor > 0, x = h.cursor < h.states.length - 1, C = n.current.length > 0, k = B(() => {
776
+ f((p) => Xa(p.states[p.cursor]?.shapes, n.current) ? p : { states: [...p.states.slice(0, p.cursor + 1), { shapes: n.current, selectedShape: s, source: "user" }], cursor: p.cursor + 1 });
777
+ }, [s]), w = B((p) => {
743
778
  n.current = [...p, ...n.current];
744
- }, []), y = F((p, w, Q, L) => {
745
- if (p.target && "className" in p.target && ![Da, Na].includes(p.target.className) || !L) return void c(void 0);
746
- const k = n.current.find((D) => !q(r)?.map((Z) => Z.id).includes(D.id) && !!ja(w, D, Q, e));
747
- c(k);
748
- }, [e, r]), m = F(async (p, w = 300, Q = 300) => {
749
- const L = await Bn(p, w, Q, e);
750
- return x([L]), P(), L;
751
- }, [x, P, e]), S = F((p, w = !1) => {
752
- n.current = n.current.map((Q) => p.find((L) => L.id === Q.id) ?? Q), d((Q) => Q && ye(q(Q).map((L) => p.find((k) => k.id === L.id) ?? L), e)), w && P();
753
- }, [P, e]), E = F((p) => {
754
- const w = p.map((Q) => _t(["chosen"], Q));
755
- n.current = w, P();
756
- }, [P]), H = F((p) => {
757
- const w = new Set(p.map((Q) => Q.id));
758
- d((Q) => {
759
- const L = q(Q).map((k) => k.id);
760
- return L && w.size && L.find((k) => w.has(k)) ? void 0 : Q;
761
- }), n.current = n.current.filter((Q) => !w?.has(Q.id)), P();
762
- }, [P]), z = F((p) => {
763
- f((w) => {
764
- const Q = p(w);
765
- return n.current = w.states[Q]?.shapes ?? [], d(w.states[Q]?.selectedShape), Ce("cursor", Q, w);
779
+ }, []), m = B((p, Q, M, L) => {
780
+ if (p.target && "className" in p.target && ![Ya, Ua].includes(p.target.className) || !L) return void d(void 0);
781
+ const P = n.current.find((E) => !j(s)?.map((W) => W.id).includes(E.id) && !!rn(Q, E, M, e));
782
+ d(P);
783
+ }, [e, s]), y = B(async (p, Q = 300, M = 300) => {
784
+ const L = await co(p, Q, M, e);
785
+ return w([L]), k(), L;
786
+ }, [w, k, e]), b = B((p, Q = !1) => {
787
+ n.current = n.current.map((M) => p.find((L) => L.id === M.id) ?? M), c((M) => M && be(j(M).map((L) => p.find((P) => P.id === L.id) ?? L), e)), Q && k();
788
+ }, [k, e]), Z = B((p) => {
789
+ const Q = p.map((M) => Jt(["chosen"], M));
790
+ n.current = Q, k();
791
+ }, [k]), A = B((p) => {
792
+ const Q = new Set(p.map((M) => M.id));
793
+ c((M) => {
794
+ const L = j(M).map((P) => P.id);
795
+ return L && Q.size && L.find((P) => Q.has(P)) ? void 0 : M;
796
+ }), n.current = n.current.filter((M) => !Q?.has(M.id)), k();
797
+ }, [k]), T = B((p) => {
798
+ f((Q) => {
799
+ const M = p(Q);
800
+ return n.current = Q.states[M]?.shapes ?? [], c(Q.states[M]?.selectedShape), Pe("cursor", M, Q);
766
801
  });
767
- }, []), T = F(() => {
768
- z((p) => Math.max(0, p.cursor - 1));
769
- }, [z]), V = F(() => {
770
- z((p) => Math.min(p.states.length - 1, p.cursor + 1));
771
- }, [z]), I = F((p, w) => {
772
- d(void 0), n.current = p, f((Q) => w.clearHistory ? { states: [{ shapes: p, selectedShape: void 0, source: w.source }], cursor: 0 } : { states: [...Q.states.slice(0, Q.cursor + 1), { shapes: p, selectedShape: void 0, source: w.source }], cursor: Q.cursor + 1 });
773
- }, []), W = F((p, w) => {
774
- const Q = n.current, L = Q.findIndex((O) => O.id === p), k = Q.findIndex((O) => O.id === w);
775
- var D, Z, X;
776
- E((D = Q, X = k, (Z = L) < 0 || X < 0 || Z > D.length - 1 || X > D.length - 1 ? D : Z < X ? [...D.slice(0, Z), ...D.slice(Z + 1, X + 1), D[Z], ...D.slice(X + 1, D.length)] : [...D.slice(0, X), D[Z], ...D.slice(X, Z), ...D.slice(Z + 1, D.length)]));
777
- }, [E]), A = F((p) => {
778
- const w = n.current, Q = new Set(p.map((k) => k.id)), L = w.map((k) => Q.has(k.id) ? Ce("visible", k.visible === !1, k) : k);
779
- d(Ei((k) => Ce("visible", k.visible === !1, k), e)), E(L);
780
- }, [E, e]), R = F((p) => {
781
- const w = n.current, Q = new Set(p.map((k) => k.id)), L = w.map((k) => Q.has(k.id) ? Ce("locked", !k.locked, k) : k);
782
- d(Ei((k) => Ce("locked", !k.locked, k), e)), E(L);
783
- }, [E, e]), _ = F((p, w) => {
784
- o.current.hasOwnProperty(p) && (o.current[p] = [...o.current[p], w]);
785
- }, []), U = F((p, w) => {
786
- if (o.current.hasOwnProperty(p)) if (w) {
787
- const Q = o.current[p].indexOf(w);
788
- o.current[p] = [...o.current[p].slice(0, Q), ...o.current[p].slice(Q + 1)];
802
+ }, []), S = B(() => {
803
+ T((p) => Math.max(0, p.cursor - 1));
804
+ }, [T]), V = B(() => {
805
+ T((p) => Math.min(p.states.length - 1, p.cursor + 1));
806
+ }, [T]), I = B((p, Q) => {
807
+ c(void 0), n.current = p, f((M) => Q.clearHistory ? { states: [{ shapes: p, selectedShape: void 0, source: Q.source }], cursor: 0 } : { states: [...M.states.slice(0, M.cursor + 1), { shapes: p, selectedShape: void 0, source: Q.source }], cursor: M.cursor + 1 });
808
+ }, []), N = B((p, Q) => {
809
+ const M = n.current, L = M.findIndex((z) => z.id === p), P = M.findIndex((z) => z.id === Q);
810
+ var E, W, O;
811
+ Z((E = M, O = P, (W = L) < 0 || O < 0 || W > E.length - 1 || O > E.length - 1 ? E : W < O ? [...E.slice(0, W), ...E.slice(W + 1, O + 1), E[W], ...E.slice(O + 1, E.length)] : [...E.slice(0, O), E[W], ...E.slice(O, W), ...E.slice(W + 1, E.length)]));
812
+ }, [Z]), H = B((p) => {
813
+ const Q = n.current, M = new Set(p.map((P) => P.id)), L = Q.map((P) => M.has(P.id) ? Pe("visible", P.visible === !1, P) : P);
814
+ c($i((P) => Pe("visible", P.visible === !1, P), e)), Z(L);
815
+ }, [Z, e]), D = B((p) => {
816
+ const Q = n.current, M = new Set(p.map((P) => P.id)), L = Q.map((P) => M.has(P.id) ? Pe("locked", !P.locked, P) : P);
817
+ c($i((P) => Pe("locked", !P.locked, P), e)), Z(L);
818
+ }, [Z, e]), U = B((p, Q) => {
819
+ o.current.hasOwnProperty(p) && (o.current[p] = [...o.current[p], Q]);
820
+ }, []), F = B((p, Q) => {
821
+ if (o.current.hasOwnProperty(p)) if (Q) {
822
+ const M = o.current[p].indexOf(Q);
823
+ o.current[p] = [...o.current[p].slice(0, M), ...o.current[p].slice(M + 1)];
789
824
  } else o.current[p] = [];
790
825
  }, []);
791
- K(() => {
792
- const p = u.states[u.cursor], w = ui(p.shapes, t, i);
793
- for (const Q of o.current.dataChanged) Q(w, p.source);
794
- }, [t, i, u]), K(() => {
795
- n.current = n.current.map((p) => st(p, e)), d((p) => p === void 0 ? void 0 : ye(q(p).map((w) => st(w, e)), e));
826
+ J(() => {
827
+ const p = h.states[h.cursor], Q = bi(p.shapes, t, i);
828
+ for (const M of o.current.dataChanged) M(Q, p.source);
829
+ }, [t, i, h]), J(() => {
830
+ n.current = n.current.map((p) => dt(p, e)), c((p) => p === void 0 ? void 0 : be(j(p).map((Q) => dt(Q, e)), e));
796
831
  }, [e]);
797
- const C = F((p, w) => {
798
- l((Q) => {
799
- const L = [Q?.frame[0] ?? [w[0], w[1]], [w[0], w[1]]], k = n.current.filter((Z) => ((X, O, de, N) => {
800
- const { selectionPadding: oe } = N, { center: G, borders: le } = ie(O, N), j = He(de[0], O.rotation, G), se = He(de[1], O.rotation, G), ne = Math.round(Math.min(j[0], se[0]) - oe / 2), Qe = Math.round(Math.max(j[0], se[0]) + oe), te = Math.round(Math.min(j[1], se[1]) - oe / 2), ue = { x: ne, y: te, width: Qe - ne, height: Math.round(Math.max(j[1], se[1]) + oe) - te }, Te = Jt(le, ue);
801
- if (!Te) return !1;
802
- if (le.width <= 1 || le.height <= 1 || !("path" in O) || !O.path) return !0;
803
- if (X.lineWidth = (O.style?.lineWidth ?? 0) + 10, O.type === "brush") {
804
- const fe = O.points.flat(), Ne = Math.min(...fe.map((be) => be[0])), Ye = Math.min(...fe.map((be) => be[1]));
805
- for (const be of O.points) {
806
- if (be.length < 1) break;
807
- if (be.length < 2) {
808
- const Pe = Ze(be[0], Ne, Ye, O.scaleX, O.scaleY);
809
- if (Fa(Te, { x: Pe[0], y: Pe[1], radius: (O.style?.lineWidth ?? 1) / 2 })) return !0;
832
+ const X = B((p, Q) => {
833
+ l((M) => {
834
+ const L = [M?.frame[0] ?? [Q[0], Q[1]], [Q[0], Q[1]]], P = n.current.filter((W) => ((O, z, ie, re) => {
835
+ const { selectionPadding: R } = re, { center: oe, borders: G } = z.computed, le = Ae(ie[0], z.rotation ?? 0, oe), ae = Ae(ie[1], z.rotation ?? 0, oe), pe = Math.round(Math.min(le[0], ae[0]) - R / 2), se = Math.round(Math.max(le[0], ae[0]) + R), ge = Math.round(Math.min(le[1], ae[1]) - R / 2), q = { x: pe, y: ge, width: se - pe, height: Math.round(Math.max(le[1], ae[1]) + R) - ge }, he = ii(G, q);
836
+ if (!he) return !1;
837
+ if (G.width <= 1 || G.height <= 1 || !("path" in z) || !z.path) return !0;
838
+ if (O.lineWidth = (z.style?.lineWidth ?? 0) + 10, z.type === "brush") {
839
+ const Ee = z.points.flat(), Ie = Math.min(...Ee.map((ve) => ve[0])), He = Math.min(...Ee.map((ve) => ve[1]));
840
+ for (const ve of z.points) {
841
+ if (ve.length < 1) break;
842
+ if (ve.length < 2) {
843
+ const ne = ze(ve[0], Ie, He, z.scaleX, z.scaleY);
844
+ if (Ka(he, { x: ne[0], y: ne[1], radius: (z.style?.lineWidth ?? 1) / 2 })) return !0;
810
845
  }
811
- for (let Pe = 0; Pe < be.length - 1; Pe++) {
812
- const We = Ze(be[Pe], Ne, Ye, O.scaleX, O.scaleY), Ie = Ze(be[Pe + 1], Ne, Ye, O.scaleX, O.scaleY), re = Jt({ x: Math.min(We[0], Ie[0]), y: Math.min(We[1], Ie[1]), width: Math.abs(We[0] - Ie[0]), height: Math.abs(We[1] - Ie[1]) }, ue);
813
- if (re) {
814
- const Xe = new Path2D();
815
- if (Xe.moveTo(...We), Xe.lineTo(...Ie), Ni({ ctx: X, path: Xe, rect: re, offset: 10, checkFill: !1 })) return !0;
846
+ for (let ne = 0; ne < ve.length - 1; ne++) {
847
+ const Te = ze(ve[ne], Ie, He, z.scaleX, z.scaleY), We = ze(ve[ne + 1], Ie, He, z.scaleX, z.scaleY), Ce = ii({ x: Math.min(Te[0], We[0]), y: Math.min(Te[1], We[1]), width: Math.abs(Te[0] - We[0]), height: Math.abs(Te[1] - We[1]) }, q);
848
+ if (Ce) {
849
+ const qe = new Path2D();
850
+ if (qe.moveTo(...Te), qe.lineTo(...We), Ui({ ctx: O, path: qe, rect: Ce, offset: 10, checkFill: !1 })) return !0;
816
851
  }
817
852
  }
818
853
  }
819
854
  return !1;
820
855
  }
821
- const ve = !(!O.style?.fillColor || O.style?.fillColor === "transparent");
822
- return Ni({ ctx: X, path: O.path, rect: Te, offset: 10, checkFill: ve });
823
- })(p, Z, L, e)), D = ye(k, e);
824
- return d(a ? ye(Ga(Q?.oldSelection, k), e) : D), { oldSelection: Q?.oldSelection, frame: L };
856
+ const ce = !(!z.style?.fillColor || z.style?.fillColor === "transparent");
857
+ return Ui({ ctx: O, path: z.path, rect: he, offset: 10, checkFill: ce });
858
+ })(p, W, L, e)), E = be(P, e);
859
+ return c(a ? be(nn(M?.oldSelection, P), e) : E), { oldSelection: M?.oldSelection, frame: L };
825
860
  });
826
861
  }, [e, a]);
827
- return { registerEvent: _, unregisterEvent: U, shapesRef: n, selectedShape: r, hoveredShape: h, selectionFrame: s, setSelectionFrame: l, refreshSelectedShapes: C, addShapes: x, addPictureShape: m, moveShapes: W, saveShapes: P, setSelectedShape: d, refreshHoveredShape: y, toggleShapeVisibility: A, toggleShapeLock: R, removeShape: H, updateShape: S, backwardShape: T, forwardShape: V, clearShapes: I, canGoBackward: v, canGoForward: b, canClear: M };
828
- }, Gi = (e) => {
862
+ return { registerEvent: U, unregisterEvent: F, shapesRef: n, selectedShape: s, hoveredShape: u, selectionFrame: r, setSelectionFrame: l, refreshSelectedShapes: X, addShapes: w, addPictureShape: y, moveShapes: N, saveShapes: k, setSelectedShape: c, refreshHoveredShape: m, toggleShapeVisibility: H, toggleShapeLock: D, removeShape: A, updateShape: b, backwardShape: S, forwardShape: V, clearShapes: I, canGoBackward: g, canGoForward: x, canClear: C };
863
+ }, aa = (e) => {
829
864
  const t = [e[0].clientX, e[0].clientY], i = [e[1].clientX, e[1].clientY];
830
865
  var a, n;
831
- return { diff: Ba(t, i), center: (n = i, [((a = t)[0] + n[0]) / 2, (a[1] + n[1]) / 2]) };
832
- }, eo = ({ canvasElt: e, canvasTransformation: t, canvasSize: i, size: a, setCanvasTransformation: n }) => {
833
- const o = ae([]), [s, l] = $(o.current.length > 0), r = ae(null), d = ae(t);
834
- d.current = t;
835
- const h = F(({ startDiff: c, startZoom: u, startCenter: f, startOffset: v, currentDiff: b, currentCenter: M, isMoving: P, isZooming: x }) => {
836
- if (!e || !b || !c) return;
837
- const y = (({ canvasBoundingRect: m, canvasSize: S, size: E, startDiff: H, startZoom: z, startCenter: T, startOffset: V, currentDiff: I, currentCenter: W, isMoving: A, isZooming: R }) => {
838
- const _ = R ? De(I / H * z, we[0], we[we.length - 1]) : z, U = A ? [V[0] + (W[0] - T[0]) * (S.width / m.width) / S.scaleRatio / z, V[1] + (W[1] - T[1]) * (S.height / m.height) / S.scaleRatio / z] : [V[0], V[1]], C = [(W[0] - m.left) / S.scaleRatio, (W[1] - m.top) / S.scaleRatio];
839
- return ti({ size: E, canvasSize: S, currentOffset: U, currentZoom: z, zoom: _, centerPoint: C });
840
- })({ canvasBoundingRect: e.getBoundingClientRect(), canvasSize: i, size: a, startDiff: c, startZoom: u, startCenter: f, startOffset: v, currentDiff: b, currentCenter: M, isMoving: P, isZooming: x });
841
- n(y);
866
+ return { diff: Ja(t, i), center: (n = i, [((a = t)[0] + n[0]) / 2, (a[1] + n[1]) / 2]) };
867
+ }, xo = ({ canvasElt: e, canvasTransformation: t, canvasSize: i, size: a, setCanvasTransformation: n }) => {
868
+ const o = te([]), [r, l] = $(o.current.length > 0), s = te(null), c = te(t);
869
+ c.current = t;
870
+ const u = B(({ startDiff: d, startZoom: h, startCenter: f, startOffset: g, currentDiff: x, currentCenter: C, isMoving: k, isZooming: w }) => {
871
+ if (!e || !x || !d) return;
872
+ const m = (({ canvasBoundingRect: y, canvasSize: b, size: Z, startDiff: A, startZoom: T, startCenter: S, startOffset: V, currentDiff: I, currentCenter: N, isMoving: H, isZooming: D }) => {
873
+ const U = D ? De(I / A * T, Me[0], Me[Me.length - 1]) : T, F = H ? [V[0] + (N[0] - S[0]) * (b.width / y.width) / b.scaleRatio / T, V[1] + (N[1] - S[1]) * (b.height / y.height) / b.scaleRatio / T] : [V[0], V[1]], X = [(N[0] - y.left) / b.scaleRatio, (N[1] - y.top) / b.scaleRatio];
874
+ return ni({ size: Z, canvasSize: b, currentOffset: F, currentZoom: T, zoom: U, centerPoint: X });
875
+ })({ canvasBoundingRect: e.getBoundingClientRect(), canvasSize: i, size: a, startDiff: d, startZoom: h, startCenter: f, startOffset: g, currentDiff: x, currentCenter: C, isMoving: k, isZooming: w });
876
+ n(m);
842
877
  }, [e, i, a, n]);
843
- K(() => {
878
+ J(() => {
844
879
  if (!e) return;
845
- const c = (u) => {
846
- if (o.current = [...o.current, u], l(o.current.length > 0), o.current.length === 2) {
847
- u.stopPropagation();
848
- const { diff: f, center: v } = Gi(o.current);
849
- r.current = { startDiff: f, startCenter: v, startZoom: d.current.zoom, startOffset: d.current.offset, isMoving: !1, isZooming: !1 };
880
+ const d = (h) => {
881
+ if (o.current = [...o.current, h], l(o.current.length > 0), o.current.length === 2) {
882
+ h.stopPropagation();
883
+ const { diff: f, center: g } = aa(o.current);
884
+ s.current = { startDiff: f, startCenter: g, startZoom: c.current.zoom, startOffset: c.current.offset, isMoving: !1, isZooming: !1 };
850
885
  }
851
886
  };
852
- return e.addEventListener("pointerdown", c), () => {
853
- e.removeEventListener("pointerdown", c);
887
+ return e.addEventListener("pointerdown", d), () => {
888
+ e.removeEventListener("pointerdown", d);
854
889
  };
855
- }, [e]), K(() => {
856
- if (!s) return;
857
- const c = (f) => {
858
- const v = o.current.findIndex((b) => b.pointerId === f.pointerId);
859
- if (v > -1 && (o.current[v] = f), o.current.length === 2 && r.current) {
860
- const { diff: b, center: M } = Gi(o.current), P = r.current.isZooming || ((y, m) => Math.abs(y - m.startDiff) > 30)(b, r.current), x = r.current.isMoving || P || ((y, m) => Math.abs(Ba(y, m.startCenter)) > 10)(M, r.current);
861
- r.current = { ...r.current, isMoving: x, isZooming: P }, h({ ...r.current, currentDiff: b, currentCenter: M });
890
+ }, [e]), J(() => {
891
+ if (!r) return;
892
+ const d = (f) => {
893
+ const g = o.current.findIndex((x) => x.pointerId === f.pointerId);
894
+ if (g > -1 && (o.current[g] = f), o.current.length === 2 && s.current) {
895
+ const { diff: x, center: C } = aa(o.current), k = s.current.isZooming || ((m, y) => Math.abs(m - y.startDiff) > 30)(x, s.current), w = s.current.isMoving || k || ((m, y) => Math.abs(Ja(m, y.startCenter)) > 10)(C, s.current);
896
+ s.current = { ...s.current, isMoving: w, isZooming: k }, u({ ...s.current, currentDiff: x, currentCenter: C });
862
897
  }
863
- }, u = (f) => {
864
- o.current = o.current.filter((v) => v.pointerId !== f.pointerId), l(o.current.length > 0);
898
+ }, h = (f) => {
899
+ o.current = o.current.filter((g) => g.pointerId !== f.pointerId), l(o.current.length > 0);
865
900
  };
866
- return document.addEventListener("pointermove", c), document.addEventListener("pointerup", u), document.addEventListener("pointerout", u), document.addEventListener("pointercancel", u), document.addEventListener("pointerleave", u), () => {
867
- document.removeEventListener("pointermove", c), document.removeEventListener("pointerup", u), document.removeEventListener("pointerout", u), document.removeEventListener("pointercancel", u), document.removeEventListener("pointerleave", u);
901
+ return document.addEventListener("pointermove", d), document.addEventListener("pointerup", h), document.addEventListener("pointerout", h), document.addEventListener("pointercancel", h), document.addEventListener("pointerleave", h), () => {
902
+ document.removeEventListener("pointermove", d), document.removeEventListener("pointerup", h), document.removeEventListener("pointerout", h), document.removeEventListener("pointercancel", h), document.removeEventListener("pointerleave", h);
868
903
  };
869
- }, [s, h]);
870
- }, qi = { offset: [0, 0], zoom: 1 }, to = ({ canvasSize: e, size: t, zoomEnabled: i, canvasElt: a }) => {
871
- const [n, o] = $(qi), s = ae(0), l = F((h) => {
872
- o(({ zoom: c }) => ei({ zoom: c, size: t, canvasSize: e, newOffset: h }));
873
- }, [e, t]), r = F((h) => {
874
- o(({ offset: c, zoom: u }) => (({ size: f, canvasSize: v, currentOffset: b, currentZoom: M, action: P }) => {
875
- const x = P === "default" ? we[4] : P === "zoom" ? we[De(we.length - 1 - we.slice(0).reverse().findIndex((m) => m <= M) + 1, 0, we.length - 1)] : we[De(we.findIndex((m) => m >= M) - 1, 0, we.length - 1)], y = [v.realWidth / 2, v.realHeight / 2];
876
- return ti({ size: f, canvasSize: v, currentOffset: b, currentZoom: M, zoom: x, centerPoint: y });
877
- })({ size: t, canvasSize: e, currentOffset: c, currentZoom: u, action: h }));
904
+ }, [r, u]);
905
+ }, na = { offset: [0, 0], zoom: 1 }, wo = ({ canvasSize: e, size: t, zoomEnabled: i, canvasElt: a }) => {
906
+ const [n, o] = $(na), r = te(0), l = B((u) => {
907
+ o(({ zoom: d }) => ai({ zoom: d, size: t, canvasSize: e, newOffset: u }));
908
+ }, [e, t]), s = B((u) => {
909
+ o(({ offset: d, zoom: h }) => (({ size: f, canvasSize: g, currentOffset: x, currentZoom: C, action: k }) => {
910
+ const w = k === "default" ? Me[4] : k === "zoom" ? Me[De(Me.length - 1 - Me.slice(0).reverse().findIndex((y) => y <= C) + 1, 0, Me.length - 1)] : Me[De(Me.findIndex((y) => y >= C) - 1, 0, Me.length - 1)], m = [g.realWidth / 2, g.realHeight / 2];
911
+ return ni({ size: f, canvasSize: g, currentOffset: x, currentZoom: C, zoom: w, centerPoint: m });
912
+ })({ size: t, canvasSize: e, currentOffset: d, currentZoom: h, action: u }));
878
913
  }, [e, t]);
879
- eo({ canvasElt: a, canvasTransformation: n, canvasSize: e, size: t, setCanvasTransformation: o });
880
- const d = F(() => {
881
- o(qi);
914
+ xo({ canvasElt: a, canvasTransformation: n, canvasSize: e, size: t, setCanvasTransformation: o });
915
+ const c = B(() => {
916
+ o(na);
882
917
  }, []);
883
- return K(() => {
918
+ return J(() => {
884
919
  if (!i || !a) return;
885
- const h = (c) => {
886
- const u = c.ctrlKey, { deltaX: f, deltaY: v } = ((x, y) => {
887
- const m = Math.abs(x.deltaY) < 50 && y < 50, S = x.ctrlKey, E = Ra() && m && S;
888
- switch (x.deltaMode) {
920
+ const u = (d) => {
921
+ const h = d.ctrlKey, { deltaX: f, deltaY: g } = ((w, m) => {
922
+ const y = Math.abs(w.deltaY) < 50 && m < 50, b = w.ctrlKey, Z = Ga() && y && b;
923
+ switch (w.deltaMode) {
889
924
  case WheelEvent.DOM_DELTA_LINE:
890
- return { deltaX: 16 * x.deltaX, deltaY: 16 * x.deltaY };
925
+ return { deltaX: 16 * w.deltaX, deltaY: 16 * w.deltaY };
891
926
  case WheelEvent.DOM_DELTA_PAGE:
892
- return { deltaX: x.deltaX * window.innerHeight, deltaY: x.deltaY * window.innerHeight };
927
+ return { deltaX: w.deltaX * window.innerHeight, deltaY: w.deltaY * window.innerHeight };
893
928
  default:
894
- return E ? { deltaX: 5 * x.deltaX, deltaY: 5 * x.deltaY } : { deltaX: x.deltaX, deltaY: x.deltaY };
929
+ return Z ? { deltaX: 5 * w.deltaX, deltaY: 5 * w.deltaY } : { deltaX: w.deltaX, deltaY: w.deltaY };
895
930
  }
896
- })(c, c.timeStamp - s.current);
897
- if (s.current = c.timeStamp, u) {
898
- c.preventDefault();
899
- const x = _a(c, a, e);
900
- return void o(({ offset: y, zoom: m }) => (({ size: S, canvasSize: E, currentOffset: H, currentZoom: z, delta: T, centerPoint: V }) => {
901
- const I = De(z * (1 - T / 1e3), we[0], we[we.length - 1]);
902
- return ti({ size: S, canvasSize: E, currentOffset: H, currentZoom: z, zoom: I, centerPoint: V });
903
- })({ size: t, canvasSize: e, currentOffset: y, currentZoom: m, delta: v, centerPoint: x }));
931
+ })(d, d.timeStamp - r.current);
932
+ if (r.current = d.timeStamp, h) {
933
+ d.preventDefault();
934
+ const w = sn(d, a, e);
935
+ return void o(({ offset: m, zoom: y }) => (({ size: b, canvasSize: Z, currentOffset: A, currentZoom: T, delta: S, centerPoint: V }) => {
936
+ const I = De(T * (1 - S / 1e3), Me[0], Me[Me.length - 1]);
937
+ return ni({ size: b, canvasSize: Z, currentOffset: A, currentZoom: T, zoom: I, centerPoint: V });
938
+ })({ size: t, canvasSize: e, currentOffset: m, currentZoom: y, delta: g, centerPoint: w }));
904
939
  }
905
- const b = c.shiftKey, [M, P] = b ? [v, f] : [f, v];
906
- o(({ offset: x, zoom: y }) => {
907
- const m = [x[0] - M / y, x[1] - P / y], S = ei({ zoom: y, size: t, canvasSize: e, newOffset: m });
908
- return S.offset[0] === x[0] && S.offset[1] === x[1] || c.preventDefault(), S;
940
+ const x = d.shiftKey, [C, k] = x ? [g, f] : [f, g];
941
+ o(({ offset: w, zoom: m }) => {
942
+ const y = [w[0] - C / m, w[1] - k / m], b = ai({ zoom: m, size: t, canvasSize: e, newOffset: y });
943
+ return b.offset[0] === w[0] && b.offset[1] === w[1] || d.preventDefault(), b;
909
944
  });
910
945
  };
911
- return a.addEventListener("wheel", h, { passive: !1 }), () => {
912
- a.removeEventListener("wheel", h);
946
+ return a.addEventListener("wheel", u, { passive: !1 }), () => {
947
+ a.removeEventListener("wheel", u);
913
948
  };
914
- }, [a, t, e, i]), { setCanvasTransformation: o, setCanvasOffset: l, setCanvasZoom: r, resetZoom: d, canvasTransformation: n };
915
- }, _i = (e, t = !1) => {
949
+ }, [a, t, e, i]), { setCanvasTransformation: o, setCanvasOffset: l, setCanvasZoom: s, resetZoom: c, canvasTransformation: n };
950
+ }, oa = (e, t = !1) => {
916
951
  const i = (n, o) => {
917
952
  if (Array.isArray(n)) return o;
918
953
  }, a = e.map((n) => {
919
954
  if (typeof n != "object") return null;
920
955
  switch (n.type) {
921
956
  case "brush":
922
- return Ee(i, xa, n);
957
+ return Ne(i, Ta, n);
923
958
  case "circle":
924
- return Ee(i, Va, n);
959
+ return Ne(i, Da, n);
925
960
  case "curve":
926
- return Ee(i, ka, n);
961
+ return Ne(i, Ea, n);
927
962
  case "ellipse":
928
- return Ee(i, Za, n);
963
+ return Ne(i, Ra, n);
929
964
  case "line":
930
- return Ee(i, Ca, n);
965
+ return Ne(i, za, n);
931
966
  case "polygon":
932
- return Ee(i, Ma, n);
967
+ return Ne(i, Aa, n);
933
968
  case "rect":
934
- return Ee(i, Pa, n);
969
+ return Ne(i, Ia, n);
935
970
  case "square":
936
- return Ee(i, La, n);
971
+ return Ne(i, Na, n);
937
972
  case "text":
938
- return Ee(i, Ha, n);
973
+ return Ne(i, Wa, n);
939
974
  }
940
975
  return null;
941
976
  });
942
- return hi(t ? [...a, ri] : a);
943
- }, Fo = ({ width: e = 1e3, height: t = 600, shapes: i, mode: a = "editor", disabled: n = !1, options: o = Pi } = {}) => {
944
- const { layersManipulation: s, brushAlgo: l, isBrushShapeDoneOnMouseUp: r, grid: d, canGrow: h, canShrink: c, withExport: u, withLoadAndSave: f, withUploadPicture: v, withUrlPicture: b, withSkeleton: M, withFrameSelection: P, clearCallback: x, availableTools: y, canvasSelectionPadding: m, size: S, canZoom: E } = { ...Pi, ...o }, H = a !== "viewer", z = ae(null), T = ae(null), V = ae(!1), I = F((ee) => {
945
- z.current = ee;
946
- }, []), [W, A] = $(void 0), [R, _] = $(Be), [U, C] = $({ mode: "default" }), [p, w] = $(d), [Q, L] = $({ realWidth: e, realHeight: t, width: e, height: t, scaleRatio: 1 }), k = E === "always" && !n, { canvasTransformation: D, setCanvasTransformation: Z, setCanvasOffset: X, setCanvasZoom: O, resetZoom: de } = to({ canvasSize: Q, size: S, canvasElt: T.current, zoomEnabled: k }), { offset: N, zoom: oe } = D, G = pa(() => ({ brushAlgo: l, isBrushShapeDoneOnMouseUp: r, canvasSize: { realWidth: Q.realWidth, realHeight: Q.realHeight, width: Q.width, height: Q.height, scaleRatioWithNoZoom: Q.scaleRatio, scaleRatio: Q.scaleRatio * oe }, size: S, canvasOffset: N, canvasZoom: oe, gridGap: p, selectionPadding: m, features: { edition: H && !n, zoom: k } }), [m, p, l, r, oe, N, Q, S, n, k, H]), [le, j] = $(_i(y, v || b)), { isInsideComponent: se } = (({ settings: ee, componentRef: ge }) => {
947
- const [Re, Oe] = $(!1), _e = !ee.features.edition && !ee.features.zoom;
948
- return K(() => {
949
- if (!_e) {
950
- const ze = (ut) => {
951
- Oe(Wa(ut, ge.current));
952
- };
953
- return document.addEventListener("mousedown", ze, { passive: !0 }), document.addEventListener("touchstart", ze, { passive: !0 }), () => {
954
- document.removeEventListener("mousedown", ze), document.removeEventListener("touchstart", ze);
977
+ return Qi(t ? [...a, hi] : a);
978
+ }, ps = ({ width: e = 1e3, height: t = 600, shapes: i, mode: a = "editor", disabled: n = !1, options: o = Ni } = {}) => {
979
+ const { layersManipulation: r, brushAlgo: l, isBrushShapeDoneOnMouseUp: s, debug: c, grid: u, canGrow: d, canShrink: h, withExport: f, withLoadAndSave: g, withUploadPicture: x, withUrlPicture: C, withSkeleton: k, withFrameSelection: w, clearCallback: m, availableTools: y, canvasSelectionPadding: b, size: Z, canZoom: A } = { ...Ni, ...o }, T = a !== "viewer", S = te(null), V = te(null), I = te(!1), N = B((ee) => {
980
+ S.current = ee;
981
+ }, []), [H, D] = $(void 0), [U, F] = $(Fe), [X, p] = $({ mode: "default" }), [Q, M] = $(u), [L, P] = $({ realWidth: e, realHeight: t, width: e, height: t, scaleRatio: 1 }), E = A === "always" && !n, { canvasTransformation: W, setCanvasTransformation: O, setCanvasOffset: z, setCanvasZoom: ie, resetZoom: re } = wo({ canvasSize: L, size: Z, canvasElt: V.current, zoomEnabled: E }), { offset: R, zoom: oe } = W, G = ba(() => ({ brushAlgo: l, isBrushShapeDoneOnMouseUp: s, debug: c, canvasSize: { realWidth: L.realWidth, realHeight: L.realHeight, width: L.width, height: L.height, scaleRatioWithNoZoom: L.scaleRatio, scaleRatio: L.scaleRatio * oe }, size: Z, canvasOffset: R, canvasZoom: oe, gridGap: Q, selectionPadding: b, features: { edition: T && !n, zoom: E } }), [b, Q, l, s, c, oe, R, L, Z, n, E, T]), [le, ae] = $(oa(y, x || C)), { isInsideComponent: pe, isInsideCanvas: se } = (({ settings: ee, componentRef: de, canvasRef: Le }) => {
982
+ const [$e, Ye] = $(!1), [Ke, Je] = $(!1), Se = !ee.features.edition && !ee.features.zoom;
983
+ return J(() => {
984
+ if (!Se) {
985
+ const Ze = () => Ye(!0), Qt = () => Ye(!1), Ue = () => Je(!0), bt = () => Je(!1);
986
+ return de.current?.addEventListener("focusin", Ze), de.current?.addEventListener("focusout", Qt), Le.current?.addEventListener("focusin", Ue), Le.current?.addEventListener("focusout", bt), () => {
987
+ de.current?.removeEventListener("focusin", Ze), de.current?.removeEventListener("focusout", Qt), Le.current?.removeEventListener("focusin", Ue), Le.current?.removeEventListener("focusout", bt);
955
988
  };
956
989
  }
957
- Oe(!1);
958
- }, [_e, ge]), { isInsideComponent: Re };
959
- })({ settings: G, componentRef: z }), [ne, Qe] = $(!1), [te, ue] = $(!1), { registerEvent: Te, unregisterEvent: ve, shapesRef: fe, selectedShape: Ne, selectionFrame: Ye, hoveredShape: be, addShapes: Pe, addPictureShape: We, moveShapes: Ie, setSelectedShape: re, setSelectionFrame: Xe, refreshSelectedShapes: Wt, refreshHoveredShape: It, removeShape: mt, updateShape: yt, backwardShape: St, forwardShape: he, clearShapes: pe, saveShapes: Qt, toggleShapeVisibility: Ge, toggleShapeLock: ht, canGoBackward: rn, canGoForward: ln, canClear: cn } = Jn(G, e, t, ne), Rt = F((ee) => {
960
- re(void 0), _(ee);
961
- }, [re]), [Je, pi] = $([0, 0]), gi = U.mode === "preview";
962
- K(() => {
963
- if (gi) return () => C((ee) => ee.mode === "preview" ? { mode: "default" } : ee);
964
- }, [Ne?.id, gi]);
965
- const vi = U.mode === "selectionFrame";
966
- K(() => {
967
- if (vi) return () => pi([0, 0]);
968
- }, [vi]), K(() => {
969
- if (Je[0] !== 0 || Je[1] !== 0) {
990
+ Ye(!1), Je(!1);
991
+ }, [Se, de, Le]), { isInsideComponent: $e, isInsideCanvas: Ke };
992
+ })({ settings: G, componentRef: S, canvasRef: V }), [ge, q] = $(!1), [he, ce] = $(!1), [Ee, Ie] = $(!1), { registerEvent: He, unregisterEvent: ve, shapesRef: ne, selectedShape: Te, selectionFrame: We, hoveredShape: Ce, addShapes: qe, addPictureShape: Rt, moveShapes: Wt, setSelectedShape: _e, setSelectionFrame: Ot, refreshSelectedShapes: Ft, refreshHoveredShape: fe, removeShape: me, updateShape: vt, backwardShape: Be, forwardShape: it, clearShapes: xi, saveShapes: bn, toggleShapeVisibility: xn, toggleShapeLock: wn, canGoBackward: Cn, canGoForward: Mn, canClear: kn } = bo(G, e, t, ge), Bt = B((ee) => {
993
+ _e(void 0), F(ee);
994
+ }, [_e]), [at, wi] = $([0, 0]), Ci = X.mode === "preview";
995
+ J(() => {
996
+ if (Ci) return () => p((ee) => ee.mode === "preview" ? { mode: "default" } : ee);
997
+ }, [Te?.id, Ci]);
998
+ const Mi = X.mode === "selectionFrame";
999
+ J(() => {
1000
+ if (Mi) return () => wi([0, 0]);
1001
+ }, [Mi]), J(() => {
1002
+ if (at[0] !== 0 || at[1] !== 0) {
970
1003
  const ee = setInterval(() => {
971
- Z(({ offset: ge, zoom: Re }) => {
972
- const Oe = [ge[0] - Je[0], ge[1] - Je[1]];
973
- return ei({ zoom: Re, size: S, canvasSize: Q, newOffset: Oe });
1004
+ O(({ offset: de, zoom: Le }) => {
1005
+ const $e = [de[0] - at[0], de[1] - at[1]];
1006
+ return ai({ zoom: Le, size: Z, canvasSize: L, newOffset: $e });
974
1007
  });
975
1008
  }, 20);
976
1009
  return () => clearInterval(ee);
977
1010
  }
978
- }, [Je[0], Je[1], Z, S, Q]);
979
- const bt = F((ee, ge) => {
980
- pe(ee, ge), Rt(Be), Z({ offset: [0, 0], zoom: 1 });
981
- }, [Rt, pe, Z]), fi = F((ee) => {
982
- re((ge) => (ge?.id !== ee.map((Re) => Re.id).join("-") && _(Be), ye(ee, G)));
983
- }, [re, G]), dn = F(() => {
984
- const ee = jn(fe.current, e, t);
1011
+ }, [at[0], at[1], O, Z, L]);
1012
+ const St = B((ee, de) => {
1013
+ xi(ee, de), Bt(Fe), O({ offset: [0, 0], zoom: 1 });
1014
+ }, [Bt, xi, O]), ki = B((ee) => {
1015
+ _e((de) => (de?.id !== ee.map((Le) => Le.id).join("-") && F(Fe), be(ee, G)));
1016
+ }, [_e, G]), Pn = B(() => {
1017
+ const ee = So(ne.current, e, t);
985
1018
  if (!ee) throw new Error("L'encodage a échoué");
986
- Ui(ee, "drawing.json");
987
- }, [fe, e, t]), hn = F((ee) => {
988
- const ge = Yi({ shapes: fe.current, settings: G, view: ee });
989
- Ui(ge, "drawing.png");
990
- }, [fe, G]), un = F((ee) => Yi({ shapes: fe.current, settings: G, view: ee }), [fe, G]), pn = F(() => ui(fe.current, e, t), [fe, e, t]);
991
- K(() => {
992
- se || re(void 0);
993
- }, [se, re]);
994
- const qe = F(async (ee, ge) => {
995
- const Re = await (async (Oe, _e) => {
996
- if (!Oe) return [];
997
- const ze = [], ut = hi(Oe.map((ke) => {
998
- if (!ke || !Ea.includes(ke.type)) return null;
999
- if (ke.type === "picture") {
1000
- const Ae = new Image(), mn = new Promise((pt, yn) => {
1001
- Ae.onload = () => {
1002
- URL.revokeObjectURL(Ae.src), pt();
1003
- }, Ae.onerror = () => {
1004
- yn(new Error("Some images could not be loaded"));
1019
+ ea(ee, "drawing.json");
1020
+ }, [ne, e, t]), Ln = B((ee) => {
1021
+ const de = ta({ shapes: ne.current, settings: G, view: ee });
1022
+ ea(de, "drawing.png");
1023
+ }, [ne, G]), Zn = B((ee) => ta({ shapes: ne.current, settings: G, view: ee }), [ne, G]), Vn = B(() => bi(ne.current, e, t), [ne, e, t]), je = B(async (ee, de) => {
1024
+ const Le = await (async ($e, Ye) => {
1025
+ if (!$e) return [];
1026
+ const Ke = [], Je = Qi($e.map((Se) => {
1027
+ if (!Se || !$a.includes(Se.type)) return null;
1028
+ if (Se.type === "picture") {
1029
+ const Ze = new Image(), Qt = new Promise((Ue, bt) => {
1030
+ Ze.onload = () => {
1031
+ URL.revokeObjectURL(Ze.src), Ue();
1032
+ }, Ze.onerror = () => {
1033
+ bt(new Error("Some images could not be loaded"));
1005
1034
  };
1006
1035
  });
1007
- if (ze.push(mn), ke.src.startsWith("http")) on(ke.src).then((pt) => {
1008
- Ae.src = pt;
1036
+ if (Ke.push(Qt), Se.src.startsWith("http")) Sn(Se.src).then((Ue) => {
1037
+ Ze.src = Ue;
1009
1038
  }).catch(() => {
1010
- Ae.src = "";
1039
+ Ze.src = "";
1011
1040
  });
1012
- else if (ke.src.includes("<svg")) {
1013
- const pt = new Blob([ke.src], { type: "image/svg+xml" });
1014
- Ae.src = URL.createObjectURL(pt);
1015
- } else Ae.src = ke.src;
1016
- return Xi({ ...ke, img: Ae }, _e);
1041
+ else if (Se.src.includes("<svg")) {
1042
+ const Ue = new Blob([Se.src], { type: "image/svg+xml" });
1043
+ Ze.src = URL.createObjectURL(Ue);
1044
+ } else Ze.src = Se.src;
1045
+ return ia({ ...Se, img: Ze }, Ye);
1017
1046
  }
1018
- return Xi(ke, _e);
1047
+ return ia(Se, Ye);
1019
1048
  }));
1020
- return await Promise.all(ze), ut;
1049
+ return await Promise.all(Ke), Je;
1021
1050
  })(ee, G);
1022
- bt(Re, ge);
1023
- }, [bt, G]), Ot = ae(qe);
1024
- Ot.current = qe;
1025
- const gn = F((ee = [], ge = !0) => {
1026
- Ot.current?.(ee, { clearHistory: ge, source: "remote" });
1051
+ St(Le, de);
1052
+ }, [St, G]), $t = te(je);
1053
+ $t.current = je;
1054
+ const Hn = B((ee = [], de = !0) => {
1055
+ $t.current?.(ee, { clearHistory: de, source: "remote" });
1027
1056
  }, []);
1028
- K(() => {
1029
- V.current || (V.current = !0, i && Ot.current?.(i, { clearHistory: !0, source: "remote" }));
1057
+ J(() => {
1058
+ I.current || (I.current = !0, i && $t.current?.(i, { clearHistory: !0, source: "remote" }));
1030
1059
  }, [i]);
1031
- const vn = F(async (ee) => {
1032
- const ge = await (async (Re) => new Promise((Oe, _e) => {
1033
- const ze = new FileReader();
1034
- ze.onload = (ut) => {
1035
- const ke = ut.target?.result;
1036
- if (!ke) return _e("Impossible de récupérer les données du fichier");
1037
- const Ae = JSON.parse(ke);
1038
- Oe(Ae);
1039
- }, ze.readAsText(Re);
1060
+ const Tn = B(async (ee) => {
1061
+ const de = await (async (Le) => new Promise(($e, Ye) => {
1062
+ const Ke = new FileReader();
1063
+ Ke.onload = (Je) => {
1064
+ const Se = Je.target?.result;
1065
+ if (!Se) return Ye("Impossible de récupérer les données du fichier");
1066
+ const Ze = JSON.parse(Se);
1067
+ $e(Ze);
1068
+ }, Ke.readAsText(Le);
1040
1069
  }))(ee);
1041
- await qe(ge.shapes ?? [], { clearHistory: !0, source: "remote" });
1042
- }, [qe]), fn = F(() => {
1043
- typeof x != "string" ? qe(x(), { clearHistory: !1, source: "user" }) : x === "defaultShapes" && i !== void 0 ? qe(i, { clearHistory: !1, source: "user" }) : bt([], { clearHistory: !1, source: "user" });
1044
- }, [bt, qe, i, x]);
1045
- K(() => {
1046
- j(_i(y, v || b));
1047
- }, [y, v, b]);
1048
- const mi = { canvas: T, editor: z, setEditor: I };
1049
- return { annotationsProps: { style: { "user-select": "none", "touch-action": "none", transformOrigin: "left top", transform: "scale(var(--react-paint-canvas-zoom)) translate(calc(var(--react-paint-canvas-offset-x) * 100% / var(--react-paint-app-canvaswidth)), calc(var(--react-paint-canvas-offset-y) * 100% / var(--react-paint-app-canvasheight)))", "--react-paint-canvas-zoom": G.canvasZoom, "--react-paint-canvas-offset-x": G.canvasOffset[0], "--react-paint-canvas-offset-y": G.canvasOffset[1], "--react-paint-app-canvaswidth": e, "--react-paint-app-canvasheight": t } }, editorProps: { shapesRef: fe, addPictureShape: We, moveShapes: Ie, toggleShapeVisibility: Ge, toggleShapeLock: ht, canGoBackward: rn, canGoForward: ln, canClear: cn, selectedShape: Ne, removeShape: mt, updateShape: yt, backwardShape: St, forwardShape: he, refs: mi, width: e, height: t, selectTool: Rt, selectShapes: fi, activeTool: R, setActiveTool: _, setAvailableTools: j, isEditMode: H, availableTools: le, gridGap: p, setGridGap: w, loadFile: vn, exportPicture: hn, exportData: dn, clearCanvas: fn, settings: G, setCanvasZoom: O, canvas: { canGrow: h, canShrink: c, layersManipulation: s, withExport: u, withLoadAndSave: f, withUploadPicture: v, withUrlPicture: b } }, canvasProps: { shapesRef: fe, selectedShape: Ne, selectionFrame: Ye, hoveredShape: be, addShape: Pe, setSelectedShape: re, setSelectionFrame: Xe, refreshSelectedShapes: Wt, refreshHoveredShape: It, removeShape: mt, updateShape: yt, backwardShape: St, forwardShape: he, saveShapes: Qt, refs: mi, width: e, height: t, settings: G, setCanvasSize: L, setCanvasOffset: X, setCanvasZoom: O, selectShapes: fi, activeTool: R, setActiveTool: _, isInsideComponent: se, isEditMode: H, canvas: { withSkeleton: M, withFrameSelection: P, canGrow: h, canShrink: c }, canvasOffsetStartData: W, setCanvasOffsetStartData: A, selectionMode: U, setSelectionMode: C, setCanvasMoveAcceleration: pi, isShiftPressed: ne, isAltPressed: te, setShiftPressed: Qe, setAltPressed: ue }, registerEvent: Te, unregisterEvent: ve, resetCanvas: gn, resetZoom: de, getCurrentImage: un, getCurrentData: pn, setCanvasOffset: X, setCanvasZoom: O };
1050
- }, io = ({ addShapes: e, drawCanvasRef: t, setActiveTool: i, refreshHoveredShape: a, shapes: n, selectionMode: o, activeTool: s, isInsideComponent: l, setCanvasOffset: r, selectedShape: d, canvasOffsetStartData: h, refreshSelectedShapes: c, setSelectedShape: u, setSelectionFrame: f, setCanvasOffsetStartData: v, updateSingleShape: b, saveShapes: M, setSelectionMode: P, setCanvasMoveAcceleration: x, settings: y, isShiftPressed: m, isAltPressed: S, withFrameSelection: E }) => {
1051
- const [H, z] = $({ mode: "default" }), { registerDoubleClickEvent: T, unRegisterDoubleClickEvent: V } = (() => {
1052
- const C = ae(void 0), p = ae(void 0), w = (Q) => {
1053
- const L = Date.now();
1054
- C.current && L < C.current + 300 && p.current?.(Q), C.current = Date.now();
1070
+ await je(de.shapes ?? [], { clearHistory: !0, source: "remote" });
1071
+ }, [je]), zn = B(() => {
1072
+ typeof m != "string" ? je(m(), { clearHistory: !1, source: "user" }) : m === "defaultShapes" && i !== void 0 ? je(i, { clearHistory: !1, source: "user" }) : St([], { clearHistory: !1, source: "user" });
1073
+ }, [St, je, i, m]);
1074
+ J(() => {
1075
+ ae(oa(y, x || C));
1076
+ }, [y, x, C]);
1077
+ const Pi = { canvas: V, editor: S, setEditor: N };
1078
+ return { annotationsProps: { style: { userSelect: "none", touchAction: "none", transformOrigin: "left top", transform: "scale(var(--react-paint-canvas-zoom)) translate(calc(var(--react-paint-canvas-offset-x) * 100% / var(--react-paint-app-canvaswidth)), calc(var(--react-paint-canvas-offset-y) * 100% / var(--react-paint-app-canvasheight)))", "--react-paint-canvas-zoom": G.canvasZoom, "--react-paint-canvas-offset-x": G.canvasOffset[0], "--react-paint-canvas-offset-y": G.canvasOffset[1], "--react-paint-app-canvaswidth": e, "--react-paint-app-canvasheight": t } }, editorProps: { shapesRef: ne, addPictureShape: Rt, moveShapes: Wt, toggleShapeVisibility: xn, toggleShapeLock: wn, canGoBackward: Cn, canGoForward: Mn, canClear: kn, selectedShape: Te, removeShape: me, updateShape: vt, backwardShape: Be, forwardShape: it, refs: Pi, width: e, height: t, selectTool: Bt, selectShapes: ki, activeTool: U, setActiveTool: F, setAvailableTools: ae, isEditMode: T, availableTools: le, gridGap: Q, setGridGap: M, loadFile: Tn, exportPicture: Ln, exportData: Pn, clearCanvas: zn, settings: G, setCanvasZoom: ie, resetZoom: re, canvas: { canGrow: d, canShrink: h, layersManipulation: r, withExport: f, withLoadAndSave: g, withUploadPicture: x, withUrlPicture: C } }, canvasProps: { shapesRef: ne, selectedShape: Te, selectionFrame: We, hoveredShape: Ce, addShape: qe, setSelectedShape: _e, setSelectionFrame: Ot, refreshSelectedShapes: Ft, refreshHoveredShape: fe, removeShape: me, updateShape: vt, backwardShape: Be, forwardShape: it, saveShapes: bn, refs: Pi, width: e, height: t, settings: G, setCanvasSize: P, setCanvasOffset: z, setCanvasZoom: ie, resetZoom: re, selectShapes: ki, activeTool: U, setActiveTool: F, isInsideComponent: pe, isInsideCanvas: se, isEditMode: T, canvas: { withSkeleton: k, withFrameSelection: w, canGrow: d, canShrink: h }, canvasOffsetStartData: H, setCanvasOffsetStartData: D, selectionMode: X, setSelectionMode: p, setCanvasMoveAcceleration: wi, isShiftPressed: ge, isAltPressed: he, isSpacePressed: Ee, setShiftPressed: q, setAltPressed: ce, setIsSpacePressed: Ie }, registerEvent: He, unregisterEvent: ve, resetCanvas: Hn, resetZoom: re, getCurrentImage: Zn, getCurrentData: Vn, setCanvasOffset: z, setCanvasZoom: ie };
1079
+ }, Co = ({ addShapes: e, drawCanvasRef: t, setActiveTool: i, refreshHoveredShape: a, shapes: n, selectionMode: o, activeTool: r, isInsideComponent: l, setCanvasOffset: s, selectedShape: c, canvasOffsetStartData: u, refreshSelectedShapes: d, setSelectedShape: h, setSelectionFrame: f, setCanvasOffsetStartData: g, updateSingleShape: x, saveShapes: C, setSelectionMode: k, setCanvasMoveAcceleration: w, settings: m, isShiftPressed: y, isAltPressed: b, withFrameSelection: Z, isSpacePressed: A }) => {
1080
+ const [T, S] = $({ mode: "default" }), { registerDoubleClickEvent: V, unRegisterDoubleClickEvent: I } = (() => {
1081
+ const p = te(void 0), Q = te(void 0), M = (L) => {
1082
+ const P = Date.now();
1083
+ p.current && P < p.current + 300 && Q.current?.(L), p.current = Date.now();
1055
1084
  };
1056
- return { registerDoubleClickEvent: (Q, L) => {
1057
- p.current = L, Q.addEventListener("click", w), Q.addEventListener("touchend", w);
1058
- }, unRegisterDoubleClickEvent: (Q) => {
1059
- Q.removeEventListener("click", w), Q.removeEventListener("touchend", w);
1085
+ return { registerDoubleClickEvent: (L, P) => {
1086
+ Q.current = P, L.addEventListener("click", M), L.addEventListener("touchend", M);
1087
+ }, unRegisterDoubleClickEvent: (L) => {
1088
+ L.removeEventListener("click", M), L.removeEventListener("touchend", M);
1060
1089
  } };
1061
- })(), I = ae(null);
1062
- I.current = (C) => ((p, w, Q, L, k, D, Z, X, O, de, N, oe, G, le, j) => {
1063
- if (it(p) && p.touches.length > 1) return;
1064
- const se = w.current?.getContext("2d");
1065
- if (!se) return;
1066
- const ne = tt(p, w.current, N);
1067
- if (L.mode === "selectionFrame") {
1068
- de(se, ne, N);
1069
- const te = _a(p, w.current, N.canvasSize);
1070
- return void j([Math.ceil(De(te[0] * N.canvasZoom < 50 ? te[0] * N.canvasZoom - 50 : te[0] * N.canvasZoom > N.canvasSize.width / N.canvasSize.scaleRatioWithNoZoom - 50 ? te[0] * N.canvasZoom - (N.canvasSize.width / N.canvasSize.scaleRatioWithNoZoom - 50) : 0, -100, 100) / 5 / N.canvasZoom), Math.ceil(De(te[1] * N.canvasZoom < 50 ? te[1] * N.canvasZoom - 50 : te[1] * N.canvasZoom > N.canvasSize.height / N.canvasSize.scaleRatioWithNoZoom - 50 ? te[1] * N.canvasZoom - (N.canvasSize.height / N.canvasSize.scaleRatioWithNoZoom - 50) : 0, -100, 100) / 5 / N.canvasZoom)]);
1090
+ })(), N = te(null);
1091
+ N.current = (p) => ((Q, M, L, P, E, W, O, z, ie, re, R, oe, G, le, ae) => {
1092
+ if (st(Q) && Q.touches.length > 1) return;
1093
+ const pe = M.current?.getContext("2d");
1094
+ if (!pe) return;
1095
+ const se = ot(Q, M.current, R);
1096
+ if (P.mode === "selectionFrame") {
1097
+ re(pe, se, R);
1098
+ const q = sn(Q, M.current, R.canvasSize);
1099
+ return void ae([Math.ceil(De(q[0] * R.canvasZoom < 50 ? q[0] * R.canvasZoom - 50 : q[0] * R.canvasZoom > R.canvasSize.width / R.canvasSize.scaleRatioWithNoZoom - 50 ? q[0] * R.canvasZoom - (R.canvasSize.width / R.canvasSize.scaleRatioWithNoZoom - 50) : 0, -100, 100) / 5 / R.canvasZoom), Math.ceil(De(q[1] * R.canvasZoom < 50 ? q[1] * R.canvasZoom - 50 : q[1] * R.canvasZoom > R.canvasSize.height / R.canvasSize.scaleRatioWithNoZoom - 50 ? q[1] * R.canvasZoom - (R.canvasSize.height / R.canvasSize.scaleRatioWithNoZoom - 50) : 0, -100, 100) / 5 / R.canvasZoom)]);
1071
1100
  }
1072
- if (k !== void 0) return void O([ne[0] + N.canvasOffset[0] - k.start[0], ne[1] + N.canvasOffset[1] - k.start[1]]);
1073
- if (L.mode === "preview") {
1074
- const te = q(Q)[0];
1075
- if (te?.type === "curve") {
1076
- const ue = Ii(te, ne, N, !0);
1077
- return void le(ye([ue], N));
1101
+ if (E !== void 0) return void ie([se[0] + R.canvasOffset[0] - E.start[0], se[1] + R.canvasOffset[1] - E.start[1]]);
1102
+ if (P.mode === "preview") {
1103
+ const q = j(L)[0];
1104
+ if (q?.type === "curve") {
1105
+ const he = Gi(q, se, R, !0);
1106
+ return void le(be([he], R));
1078
1107
  }
1079
- if (te?.type === "polygon") {
1080
- const ue = Wi(te, ne, N, !0);
1081
- return void le(ye([ue], N));
1108
+ if (q?.type === "polygon") {
1109
+ const he = Xi(q, se, R, !0);
1110
+ return void le(be([he], R));
1082
1111
  }
1083
1112
  }
1084
- const Qe = gt(ne, N);
1085
- if (it(p) || Z(p, se, ne, Qe), Q === void 0 || Q.locked) D({ mode: "default", outOfView: !Qe });
1086
- else if (L.mode === "default" || L.mode === "textedition") {
1087
- if (!Qe) return void D({ mode: "default" });
1088
- D(vt(se, Q, ne, N, !0) || { mode: "default" });
1113
+ const ge = ft(se, R);
1114
+ if (st(Q) || O(Q, pe, se, ge), L === void 0 || L.locked) W({ mode: "default", outOfView: !ge });
1115
+ else if (P.mode === "default" || P.mode === "textedition") {
1116
+ if (!ge) return void W({ mode: "default" });
1117
+ W(mt(pe, L, se, R, !0) || { mode: "default" });
1089
1118
  } else {
1090
- const te = w.current?.getContext("2d");
1091
- if (!te) return;
1092
- const ue = Mn(te, Q, ne, L, N, oe, G);
1093
- X(q(ue));
1119
+ const q = M.current?.getContext("2d");
1120
+ if (!q) return;
1121
+ const he = Rn(q, L, se, P, R, oe, G);
1122
+ z(j(he));
1094
1123
  }
1095
- })(C, t, d, o, h, z, a, b, r, c, y, m, S, u, x), K(() => {
1124
+ })(p, t, c, o, u, S, a, x, s, d, m, y, b, h, w), J(() => {
1096
1125
  if (l) {
1097
- const C = (p) => I.current?.(p);
1098
- return document.addEventListener("mousemove", C), document.addEventListener("touchmove", C), () => {
1099
- document.removeEventListener("mousemove", C), document.removeEventListener("touchmove", C);
1126
+ const p = (Q) => N.current?.(Q);
1127
+ return document.addEventListener("mousemove", p), document.addEventListener("touchmove", p), () => {
1128
+ document.removeEventListener("mousemove", p), document.removeEventListener("touchmove", p);
1100
1129
  };
1101
1130
  }
1102
1131
  }, [l]);
1103
- const { isBrushShapeDoneOnMouseUp: W } = y, A = ae(null);
1104
- A.current = (C) => {
1105
- if (it(C) && C.touches.length > 1) return;
1106
- const p = t.current?.getContext("2d");
1107
- if (!p) return;
1108
- if ("button" in C && C.button === 2) return u(void 0), i(Be), P({ mode: "default" }), void f(void 0);
1109
- if (h) return void v(void 0);
1132
+ const { isBrushShapeDoneOnMouseUp: H } = m, D = te(null);
1133
+ D.current = (p) => {
1134
+ if (st(p) && p.touches.length > 1) return;
1135
+ const Q = t.current?.getContext("2d");
1136
+ if (!Q) return;
1137
+ if ("button" in p && p.button === 2) return h(void 0), i(Fe), k({ mode: "default" }), void f(void 0);
1138
+ if (u) return void g(void 0);
1110
1139
  if (o.mode === "textedition" || o.mode === "preview") return;
1111
- const w = tt(C, t.current, y);
1112
- if (o.mode === "translate" && Date.now() - o.dateStart <= 500 && w[0] === o.cursorStartPosition[0] && w[1] === o.cursorStartPosition[1]) {
1113
- if (!(C.ctrlKey || C.shiftKey || C.metaKey)) {
1114
- const { shape: Q } = Ai(p, n, w, y, void 0, it(C), E, !1);
1115
- u(Q);
1140
+ const M = ot(p, t.current, m);
1141
+ if (o.mode === "translate" && Date.now() - o.dateStart <= 500 && M[0] === o.cursorStartPosition[0] && M[1] === o.cursorStartPosition[1]) {
1142
+ if (!(p.ctrlKey || p.shiftKey || p.metaKey)) {
1143
+ const { shape: L } = Bi(Q, n, M, m, void 0, st(p), Z, !1);
1144
+ h(L);
1116
1145
  }
1117
- return P({ mode: "default" }), f(void 0), void M();
1146
+ return k({ mode: "default" }), f(void 0), void C();
1118
1147
  }
1119
- o.mode !== "default" && (o.mode === "brush" && W && u(void 0), P({ mode: "default" }), f(void 0), M());
1120
- }, K(() => {
1148
+ o.mode !== "default" && (o.mode === "brush" && H && h(void 0), k({ mode: "default" }), f(void 0), C());
1149
+ }, J(() => {
1121
1150
  if (l) {
1122
- const C = (p) => A.current?.(p);
1123
- return document.addEventListener("mouseup", C), document.addEventListener("touchend", C), () => {
1124
- document.removeEventListener("mouseup", C), document.removeEventListener("touchend", C);
1151
+ const p = (Q) => D.current?.(Q);
1152
+ return document.addEventListener("mouseup", p), document.addEventListener("touchend", p), () => {
1153
+ document.removeEventListener("mouseup", p), document.removeEventListener("touchend", p);
1125
1154
  };
1126
1155
  }
1127
1156
  }, [l]);
1128
- const R = !y.features.edition && y.features.zoom, _ = !y.features.edition && !y.features.zoom, U = ae(null);
1129
- return U.current = (C, p) => {
1130
- if (C.preventDefault(), it(C) && C.touches.length > 1) return;
1131
- const w = p?.getContext("2d");
1132
- if (!w) return;
1133
- const Q = tt(C, t.current, y), L = "button" in C && C.button === 1;
1134
- if (!("button" in C && C.button === 2)) {
1135
- if (L || s.type === "move") v({ start: Q, originalOffset: y.canvasOffset });
1136
- else if (!R) {
1137
- if (!gt(Q, y)) return u(void 0), void P({ mode: "default" });
1138
- if (s.type === "selection") {
1139
- const k = C.ctrlKey || C.shiftKey || C.metaKey, { shape: D, mode: Z } = Ai(w, n, Q, y, d, it(C), E, k);
1140
- u(D), P(Z), Z.mode === "selectionFrame" && f({ oldSelection: D, frame: [[Q[0], Q[1]], [Q[0], Q[1]]] });
1141
- } else if (Ea.some((k) => k === s.type)) {
1142
- const k = q(d)[0], D = t.current?.getContext("2d");
1143
- if (!D) return;
1144
- if (s.type === "brush") {
1145
- if (k?.type === "brush") {
1146
- const Z = ((X, O, de) => {
1147
- const N = { ...X, points: Ce(X.points.length, [[Math.round(O[0]), Math.round(O[1])]], X.points) };
1148
- return rt(N, de);
1149
- })(k, Q, y);
1150
- b([Z]);
1157
+ const U = !m.features.edition && m.features.zoom, F = !m.features.edition && !m.features.zoom, X = te(null);
1158
+ return X.current = (p, Q, M) => {
1159
+ if (p.preventDefault(), st(p) && p.touches.length > 1) return;
1160
+ const L = Q?.getContext("2d");
1161
+ if (!L) return;
1162
+ Q.focus();
1163
+ const P = ot(p, t.current, m), E = "button" in p && p.button === 1;
1164
+ if (!("button" in p && p.button === 2)) {
1165
+ if (E || M || r.type === "move") g({ start: P, originalOffset: m.canvasOffset });
1166
+ else if (!U) {
1167
+ if (!ft(P, m)) return h(void 0), void k({ mode: "default" });
1168
+ if (r.type === "selection") {
1169
+ const W = p.ctrlKey || p.shiftKey || p.metaKey, { shape: O, mode: z } = Bi(L, n, P, m, c, st(p), Z, W);
1170
+ h(O), k(z), z.mode === "selectionFrame" && f({ oldSelection: O, frame: [[P[0], P[1]], [P[0], P[1]]] });
1171
+ } else if ($a.some((W) => W === r.type)) {
1172
+ const W = j(c)[0], O = t.current?.getContext("2d");
1173
+ if (!O) return;
1174
+ if (r.type === "brush") {
1175
+ if (W?.type === "brush") {
1176
+ const z = ((ie, re, R) => {
1177
+ const oe = { ...ie, points: Pe(ie.points.length, [[Math.round(re[0]), Math.round(re[1])]], ie.points) };
1178
+ return ht(oe, R);
1179
+ })(W, P, m);
1180
+ x([z]);
1151
1181
  } else {
1152
- const Z = Fi(D, s, Q, y);
1153
- if (!Z) return;
1154
- e([Z]), u(ye([Z], y));
1182
+ const z = ji(O, r, P, m);
1183
+ if (!z) return;
1184
+ e([z]), h(be([z], m));
1155
1185
  }
1156
- P({ mode: "brush" });
1157
- } else if (o.mode !== "preview" || k?.type !== "polygon" && k?.type !== "curve") {
1158
- if (s.type !== "picture") {
1159
- const Z = Fi(D, s, Q, y);
1160
- if (!Z) return;
1161
- e([Z]);
1162
- const X = ye([Z], y);
1163
- u(X), Z.type === "polygon" || Z.type === "curve" ? P({ mode: "preview" }) : (i(Be), P({ mode: "resize", cursorStartPosition: [Q[0] + y.selectionPadding, Q[1] + y.selectionPadding], originalShape: X, anchor: Z.type === "line" ? 0 : [1, 1] }));
1186
+ k({ mode: "brush" });
1187
+ } else if (o.mode !== "preview" || W?.type !== "polygon" && W?.type !== "curve") {
1188
+ if (r.type !== "picture") {
1189
+ const z = ji(O, r, P, m);
1190
+ if (!z) return;
1191
+ e([z]);
1192
+ const ie = be([z], m);
1193
+ h(ie), z.type === "polygon" || z.type === "curve" ? k({ mode: "preview" }) : (i(Fe), k({ mode: "resize", cursorStartPosition: [P[0] + m.selectionPadding, P[1] + m.selectionPadding], originalShape: ie, anchor: z.type === "line" ? 0 : [1, 1] }));
1164
1194
  }
1165
1195
  } else {
1166
- const Z = k.type === "polygon" ? Wi(k, Q, y) : Ii(k, Q, y);
1167
- u(ye([Z], y)), b([Z], !0);
1196
+ const z = W.type === "polygon" ? Xi(W, P, m) : Gi(W, P, m);
1197
+ h(be([z], m)), x([z], !0);
1168
1198
  }
1169
1199
  }
1170
1200
  }
1171
1201
  }
1172
- }, K(() => {
1173
- if (_) return;
1174
- const C = t.current;
1175
- if (!C) return;
1176
- const p = (w) => U.current?.(w, C);
1177
- return C.addEventListener("mousedown", p, { passive: !1 }), C.addEventListener("touchstart", p, { passive: !1 }), () => {
1178
- C.removeEventListener("mousedown", p), C.removeEventListener("touchstart", p);
1202
+ }, J(() => {
1203
+ if (F) return;
1204
+ const p = t.current;
1205
+ if (!p) return;
1206
+ const Q = (M) => X.current?.(M, p, A);
1207
+ return p.addEventListener("mousedown", Q, { passive: !1 }), p.addEventListener("touchstart", Q, { passive: !1 }), () => {
1208
+ p.removeEventListener("mousedown", Q), p.removeEventListener("touchstart", Q);
1179
1209
  };
1180
- }, [_, t]), K(() => {
1181
- const C = t.current, p = t.current?.getContext("2d");
1182
- if (!(!C || !p))
1183
- return l ? (T(C, (w) => {
1184
- if (s.type === "selection") {
1185
- if (q(d).length !== 1) return;
1186
- const Q = q(d)[0];
1187
- if (Q?.type === "text") {
1188
- const L = tt(w, t.current, y);
1189
- return gt(L, y) ? void (vt(p, d, L, y) && P({ mode: "textedition", defaultValue: Q.value })) : void 0;
1210
+ }, [F, t, A]), J(() => {
1211
+ const p = t.current, Q = t.current?.getContext("2d");
1212
+ if (!(!p || !Q))
1213
+ return l ? (V(p, (M) => {
1214
+ if (r.type === "selection") {
1215
+ if (j(c).length !== 1) return;
1216
+ const L = j(c)[0];
1217
+ if (L?.type === "text") {
1218
+ const P = ot(M, t.current, m);
1219
+ return ft(P, m) ? void (mt(Q, c, P, m) && k({ mode: "textedition", defaultValue: L.value })) : void 0;
1190
1220
  }
1191
- if (Q?.type === "polygon") {
1192
- const L = tt(w, t.current, y);
1193
- if (!gt(L, y)) return;
1194
- const k = Di(p, Q, L, y);
1195
- return void (k && b([En(Q, k.lineIndex, L, y)]));
1221
+ if (L?.type === "polygon") {
1222
+ const P = ot(M, t.current, m);
1223
+ if (!ft(P, m)) return;
1224
+ const E = Yi(Q, L, P, m);
1225
+ return void (E && x([Kn(L, E.lineIndex, P, m)]));
1196
1226
  }
1197
- if (Q?.type === "curve") {
1198
- const L = tt(w, t.current, y);
1199
- if (!gt(L, y)) return;
1200
- const k = ((D, Z, X, O, de = 50) => {
1201
- if (Z.locked || Z.points.length < 2) return !1;
1202
- if (Z.points.length < 3) return Di(D, Z, X, O, de);
1203
- const { center: N } = ie(Z, O), oe = He(X, Z.rotation, N);
1204
- D.lineWidth = (Z.style?.lineWidth ?? 0) + de / O.canvasZoom;
1205
- const G = $a(Z, Z.points), le = new Path2D();
1227
+ if (L?.type === "curve") {
1228
+ const P = ot(M, t.current, m);
1229
+ if (!ft(P, m)) return;
1230
+ const E = ((W, O, z, ie, re = 50) => {
1231
+ if (O.locked || O.points.length < 2) return !1;
1232
+ if (O.points.length < 3) return Yi(W, O, z, ie, re);
1233
+ const { center: R } = O.computed, oe = Ae(z, O.rotation ?? 0, R);
1234
+ W.lineWidth = (O.style?.lineWidth ?? 0) + re / ie.canvasZoom;
1235
+ const G = pi(O, O.points), le = new Path2D();
1206
1236
  le.moveTo(...G[0]);
1207
- for (let j = 1; j < G.length - 2; j++) {
1208
- const se = G[j - 1], ne = G[j], Qe = G[j + 1], te = G[j + 2];
1209
- if (Ua(le, se, ne, Qe, te), D.isPointInStroke(le, oe[0], oe[1])) return { lineIndex: j - 1 };
1237
+ for (let ae = 1; ae < G.length - 2; ae++) {
1238
+ const pe = G[ae - 1], se = G[ae], ge = G[ae + 1], q = G[ae + 2], { cp1: he, cp2: ce } = gi(pe, se, ge, q);
1239
+ if (le.bezierCurveTo(he[0], he[1], ce[0], ce[1], ge[0], ge[1]), W.isPointInStroke(le, oe[0], oe[1])) return { lineIndex: ae - 1 };
1210
1240
  }
1211
1241
  return !1;
1212
- })(p, Q, L, y);
1213
- return void (k && b([Wn(Q, k.lineIndex, L, y)]));
1242
+ })(Q, L, P, m);
1243
+ return void (E && x([to(L, E.lineIndex, P, m)]));
1214
1244
  }
1215
1245
  }
1216
1246
  }), () => {
1217
- V(C);
1247
+ I(p);
1218
1248
  }) : void 0;
1219
- }, [b, T, V, l, t, s, d, P, y]), { hoverMode: H };
1220
- }, sn = (e) => e.childNodes.length ? Array.from(e.childNodes).map((t) => sn(t)).join("") : e.nodeValue ?? "", ao = ({ disabled: e = !1, shape: t, defaultValue: i, updateValue: a, saveShapes: n, settings: o }) => {
1221
- const s = ae(null), l = ae(n);
1222
- K(() => {
1223
- if (!s.current) return;
1224
- const d = s.current, h = (c) => {
1225
- c.preventDefault();
1226
- const u = c.clipboardData?.getData("text/plain");
1227
- document.execCommand("insertText", !1, u);
1249
+ }, [x, V, I, l, t, r, c, k, m]), { hoverMode: T };
1250
+ }, Qn = (e) => e.childNodes.length ? Array.from(e.childNodes).map((t) => Qn(t)).join("") : e.nodeValue ?? "", Mo = ({ disabled: e = !1, shape: t, defaultValue: i, updateValue: a, saveShapes: n, settings: o }) => {
1251
+ const r = te(null), l = te(n);
1252
+ J(() => {
1253
+ if (!r.current) return;
1254
+ const c = r.current, u = (d) => {
1255
+ d.preventDefault();
1256
+ const h = d.clipboardData?.getData("text/plain");
1257
+ document.execCommand("insertText", !1, h);
1228
1258
  };
1229
- d.addEventListener("paste", h), d.innerText = "";
1230
- for (const c of i) {
1231
- const u = document.createElement("div");
1232
- c === "" ? u.innerHTML = "<br/>" : u.innerText = c, d.appendChild(u);
1259
+ c.addEventListener("paste", u), c.innerText = "";
1260
+ for (const d of i) {
1261
+ const h = document.createElement("div");
1262
+ d === "" ? h.innerHTML = "<br/>" : h.innerText = d, c.appendChild(h);
1233
1263
  }
1234
- return d.focus(), () => {
1235
- d.removeEventListener("paste", h);
1264
+ return c.focus(), () => {
1265
+ c.removeEventListener("paste", u);
1236
1266
  };
1237
- }, [i]), K(() => {
1238
- const d = l.current;
1267
+ }, [i]), J(() => {
1268
+ const c = l.current;
1239
1269
  return () => {
1240
- d();
1270
+ c();
1241
1271
  };
1242
1272
  }, []);
1243
- const r = pa(() => {
1244
- const { borders: d, center: h } = ie(t, o);
1245
- return Me({ point: [d.x, d.y], rotation: -t.rotation, origin: h });
1246
- }, [t, o]);
1247
- return g("div", { className: "react-paint-editor-toolbox-edittextbox", ref: s, "data-fontbold": t.style?.fontBold ?? !1, "data-fontitalic": t.style?.fontItalic ?? !1, contentEditable: !e, onInput: (d) => {
1248
- const h = Array.from(d.target.childNodes).map((c) => sn(c));
1249
- a(h);
1250
- }, style: { "--react-paint-editor-toolbox-edittextbox-transform": `translate3D(${(r[0] + o.canvasOffset[0]) * o.canvasSize.scaleRatio}px, ${(r[1] + o.canvasOffset[1]) * o.canvasSize.scaleRatio}px, 0) rotate(${Kt(t.rotation)}deg)`, "--react-paint-editor-toolbox-edittextbox-fontsize": t.fontSize * o.canvasSize.scaleRatio + "px", "--react-paint-editor-toolbox-edittextbox-padding": o.selectionPadding * o.canvasSize.scaleRatio + "px", "--react-paint-editor-toolbox-edittextbox-color": t.style?.strokeColor ?? "inherit", "--react-paint-editor-toolbox-edittextbox-opacity": (t.style?.opacity ?? 100) / 100, "--react-paint-editor-toolbox-edittextbox-fontfamily": t.style?.fontFamily ?? ft } });
1251
- }, no = (e, t, i, a, n) => {
1252
- Oa(e), ((o, s) => {
1253
- const { canvasZoom: l, size: r, canvasSize: { width: d, height: h } } = s;
1254
- if (r !== "fixed" || l >= 1) return;
1255
- o.fillStyle = "#f5f5f5", o.fillRect(0, 0, d, h);
1256
- const c = Ka(s);
1257
- o.clearRect(c.x, c.y, c.width, c.height), Ja(o, s);
1258
- })(e, i), ((o, s) => {
1259
- const { canvasSize: { width: l, height: r }, gridGap: d, canvasOffset: h, canvasSize: { scaleRatio: c } } = s;
1260
- if (!d) return;
1261
- o.strokeStyle = "rgb(220,220,220)", o.lineWidth = 1, o.save(), o.scale(c, c), o.beginPath();
1262
- const u = h[0] % d, f = h[1] % d, v = Math.ceil(l / c / d) + 2, b = Math.ceil(r / c / d) + 2;
1263
- for (let M = -5; M < v; M++) o.moveTo(u + (M + 1) * d, f - d), o.lineTo(u + (M + 1) * d, f + r / c + d);
1264
- for (let M = -5; M < b; M++) o.moveTo(u - d, f + (M + 1) * d), o.lineTo(u + l / c + d, f + (M + 1) * d);
1273
+ const s = ba(() => {
1274
+ const { borders: c, center: u } = t.computed;
1275
+ return xe({ point: [c.x, c.y], rotation: -(t.rotation ?? 0), origin: u });
1276
+ }, [t]);
1277
+ return v("div", { className: "react-paint-editor-toolbox-edittextbox", ref: r, "data-fontbold": t.style?.fontBold ?? !1, "data-fontitalic": t.style?.fontItalic ?? !1, contentEditable: !e, onInput: (c) => {
1278
+ const u = Array.from(c.target.childNodes).map((d) => Qn(d));
1279
+ a(u);
1280
+ }, style: { "--react-paint-editor-toolbox-edittextbox-transform": `translate3D(${(s[0] + o.canvasOffset[0]) * o.canvasSize.scaleRatio}px, ${(s[1] + o.canvasOffset[1]) * o.canvasSize.scaleRatio}px, 0) rotate(${ti(t.rotation ?? 0)}deg)`, "--react-paint-editor-toolbox-edittextbox-fontsize": t.fontSize * o.canvasSize.scaleRatio + "px", "--react-paint-editor-toolbox-edittextbox-padding": o.selectionPadding * o.canvasSize.scaleRatio + "px", "--react-paint-editor-toolbox-edittextbox-color": t.style?.strokeColor ?? "inherit", "--react-paint-editor-toolbox-edittextbox-opacity": (t.style?.opacity ?? 100) / 100, "--react-paint-editor-toolbox-edittextbox-fontfamily": t.style?.fontFamily ?? yt } });
1281
+ }, ko = (e, t, i, a, n) => {
1282
+ qa(e), ((o, r) => {
1283
+ const { canvasZoom: l, size: s, canvasSize: { width: c, height: u } } = r;
1284
+ if (s !== "fixed" || l >= 1) return;
1285
+ o.fillStyle = "#f5f5f5", o.fillRect(0, 0, c, u);
1286
+ const d = ln(r);
1287
+ o.clearRect(d.x, d.y, d.width, d.height), cn(o, r);
1288
+ })(e, i), ((o, r) => {
1289
+ const { canvasSize: { width: l, height: s }, gridGap: c, canvasOffset: u, canvasSize: { scaleRatio: d } } = r;
1290
+ if (!c) return;
1291
+ o.strokeStyle = "rgb(220,220,220)", o.lineWidth = 1, o.save(), o.scale(d, d), o.beginPath();
1292
+ const h = u[0] % c, f = u[1] % c, g = Math.ceil(l / d / c) + 2, x = Math.ceil(s / d / c) + 2;
1293
+ for (let C = -5; C < g; C++) o.moveTo(h + (C + 1) * c, f - c), o.lineTo(h + (C + 1) * c, f + s / d + c);
1294
+ for (let C = -5; C < x; C++) o.moveTo(h - c, f + (C + 1) * c), o.lineTo(h + l / d + c, f + (C + 1) * c);
1265
1295
  o.stroke(), o.restore();
1266
1296
  })(e, i);
1267
- for (let o = a.length - 1; o >= 0; o--) t.mode === "textedition" && a[o] === n || tn(e, q(n).find((s) => s.id === a[o].id) ?? a[o], i);
1268
- }, oo = ua.forwardRef(({ canGrow: e, shapes: t, addShapes: i, updateSingleShape: a, selectedShape: n, setSelectedShape: o, setSelectionFrame: s, hoveredShape: l, selectionFrame: r, refreshHoveredShape: d, refreshSelectedShapes: h, saveShapes: c, activeTool: u, setActiveTool: f, canvasOffsetStartData: v, setCanvasOffsetStartData: b, setCanvasOffset: M, setCanvasMoveAcceleration: P, isInsideComponent: x, selectionMode: y, setSelectionMode: m, selectionWidth: S, selectionColor: E, settings: H, isEditMode: z, isShiftPressed: T, isAltPressed: V, withFrameSelection: I, withSkeleton: W }, A) => {
1269
- const R = ae(null), _ = ae(null), U = H.canvasSize, C = z;
1270
- Sn(A, () => R.current);
1271
- const { hoverMode: p } = io({ addShapes: i, drawCanvasRef: R, setActiveTool: f, shapes: t, selectionMode: y, activeTool: u, isInsideComponent: x, setCanvasOffset: M, selectedShape: n, canvasOffsetStartData: v, setCanvasOffsetStartData: b, setSelectedShape: o, setSelectionFrame: s, refreshHoveredShape: d, refreshSelectedShapes: h, updateSingleShape: a, saveShapes: c, setSelectionMode: m, setCanvasMoveAcceleration: P, isShiftPressed: T, isAltPressed: V, withFrameSelection: I, settings: H }), w = F((L) => {
1272
- const k = q(n)[0];
1273
- if (k?.type !== "text") return;
1274
- const D = R.current?.getContext("2d");
1275
- if (!D) return;
1276
- const Z = st(Un(D, k, L, H), H);
1277
- a([Z]);
1278
- }, [a, n, H]), Q = (L) => {
1279
- if (z) return L.preventDefault(), L.stopPropagation(), !1;
1297
+ for (let o = a.length - 1; o >= 0; o--) t.mode === "textedition" && a[o] === n || fn(e, j(n).find((r) => r.id === a[o].id) ?? a[o], i);
1298
+ }, Po = si.forwardRef(({ canGrow: e, shapes: t, addShapes: i, updateSingleShape: a, selectedShape: n, setSelectedShape: o, setSelectionFrame: r, hoveredShape: l, selectionFrame: s, refreshHoveredShape: c, refreshSelectedShapes: u, saveShapes: d, activeTool: h, setActiveTool: f, canvasOffsetStartData: g, setCanvasOffsetStartData: x, setCanvasOffset: C, setCanvasMoveAcceleration: k, isInsideComponent: w, selectionMode: m, setSelectionMode: y, selectionWidth: b, selectionColor: Z, settings: A, isEditMode: T, isShiftPressed: S, isAltPressed: V, isSpacePressed: I, withFrameSelection: N, withSkeleton: H }, D) => {
1299
+ const U = te(null), F = te(null), X = A.canvasSize, p = T, Q = T ? 0 : -1;
1300
+ xa(D, () => U.current);
1301
+ const { hoverMode: M } = Co({ addShapes: i, drawCanvasRef: U, setActiveTool: f, shapes: t, selectionMode: m, activeTool: h, isInsideComponent: w, setCanvasOffset: C, selectedShape: n, canvasOffsetStartData: g, setCanvasOffsetStartData: x, setSelectedShape: o, setSelectionFrame: r, refreshHoveredShape: c, refreshSelectedShapes: u, updateSingleShape: a, saveShapes: d, setSelectionMode: y, setCanvasMoveAcceleration: k, isShiftPressed: S, isAltPressed: V, withFrameSelection: N, settings: A, isSpacePressed: I }), L = B((E) => {
1302
+ const W = j(n)[0];
1303
+ if (W?.type !== "text") return;
1304
+ const O = U.current?.getContext("2d");
1305
+ if (!O) return;
1306
+ const z = dt(po(O, W, E, A), A);
1307
+ a([z]);
1308
+ }, [a, n, A]), P = (E) => {
1309
+ if (T) return E.preventDefault(), E.stopPropagation(), !1;
1280
1310
  };
1281
- return K(() => {
1282
- const L = R.current?.getContext("2d");
1283
- L && window.requestAnimationFrame(() => no(L, y, H, t, n));
1284
- }, [t, y, n, H]), K(() => {
1285
- const L = _.current?.getContext("2d");
1286
- L && window.requestAnimationFrame(() => ((k, D, Z, X, O, de, N, oe, G, le, j) => {
1287
- k.reset(), Ja(k, Z), j && oe && !q(N).find((se) => se.id === oe.id) && X.type === "selection" && D.mode === "default" && $i({ ctx: k, shape: oe, settings: Z, selectionWidth: O, selectionColor: de, hoverMode: G, withAnchors: !1 }), N && X.type !== "brush" && $i({ ctx: k, shape: N, settings: Z, selectionWidth: O, selectionColor: de, hoverMode: G, withAnchors: D.mode !== "textedition" }), le && qn({ ctx: k, selectionFrame: le, settings: Z });
1288
- })(L, y, H, u, S, E, n, l, p, r, W));
1289
- }, [l, p, r, y, n, u, H, S, E, W]), g("div", { className: "react-paint-canvas-box", style: { "--react-paint-canvas-cursor": v ? "grabbing" : p.outOfView ? "default" : p.mode === "resize" ? "pointer" : u.type !== "selection" && u.type !== "move" ? "crosshair" : p.mode === "translate" ? "move" : p.mode === "rotate" || u.type === "move" ? "grab" : "default" }, children: B("div", { className: "react-paint-canvas-container", "data-grow": e, children: [g("canvas", { className: Da, ref: R, "data-grow": e, width: U.width, height: U.height, onContextMenu: Q }), C && g("canvas", { className: Na, ref: _, width: U.width, height: U.height, "data-grow": e, onContextMenu: Q }), z && y.mode === "textedition" && q(n)[0]?.type === "text" && g(ao, { disabled: !H.features.edition, shape: q(n)[0], defaultValue: y.defaultValue, updateValue: w, saveShapes: c, settings: H })] }) });
1290
- }), ji = "ArrowUp", Ki = "ArrowDown", Ji = "ArrowLeft", ea = "ArrowRight", so = "Delete", ro = "Backspace", lo = "Escape", ta = "Shift", ia = "Alt", aa = "Option", co = "z", ho = "Z", uo = "y", po = "Y", na = "copy", oa = "paste", go = ({ isInsideComponent: e, selectedShape: t, isEditingText: i, settings: a, setSelectedShape: n, setActiveTool: o, setSelectionMode: s, setSelectionFrame: l, removeShape: r, pasteShapes: d, updateShapes: h, backwardShape: c, forwardShape: u, setShiftPressed: f, setAltPressed: v }) => {
1291
- const [b, M] = $(void 0);
1292
- return K(() => {
1293
- const P = (S) => {
1294
- t && (i || (S.preventDefault(), M({ ...t })));
1295
- }, x = (S) => {
1296
- b && (i || (S.preventDefault(), d(((E, H) => q(E).map((z) => ({ ...ii([20, 20], z, [0, 0], H, !1), id: me(`${z.type}_`) })))(b, a))));
1297
- }, y = (S) => {
1311
+ return J(() => {
1312
+ const E = U.current?.getContext("2d");
1313
+ E && window.requestAnimationFrame(() => ko(E, m, A, t, n));
1314
+ }, [t, m, n, A]), J(() => {
1315
+ const E = F.current?.getContext("2d");
1316
+ E && window.requestAnimationFrame(() => ((W, O, z, ie, re, R, oe, G, le, ae, pe) => {
1317
+ W.reset(), cn(W, z), pe && G && !j(oe).find((se) => se.id === G.id) && ie.type === "selection" && O.mode === "default" && Ji({ ctx: W, shape: G, settings: z, selectionWidth: re, selectionColor: R, hoverMode: le, withAnchors: !1 }), oe && ie.type !== "brush" && Ji({ ctx: W, shape: oe, settings: z, selectionWidth: re, selectionColor: R, hoverMode: le, withAnchors: O.mode !== "textedition" }), ae && mo({ ctx: W, selectionFrame: ae, settings: z });
1318
+ })(E, m, A, h, b, Z, n, l, M, s, H));
1319
+ }, [l, M, s, m, n, h, A, b, Z, H]), v("div", { className: "react-paint-canvas-box", style: { "--react-paint-canvas-cursor": g ? "grabbing" : M.outOfView ? "default" : M.mode === "resize" ? "pointer" : h.type !== "selection" && h.type !== "move" ? "crosshair" : M.mode === "translate" ? "move" : M.mode === "rotate" || h.type === "move" || I ? "grab" : "default" }, children: Y("div", { className: "react-paint-canvas-container", "data-grow": e, children: [v("canvas", { className: Ya, ref: U, "data-grow": e, width: X.width, height: X.height, onContextMenu: P, tabIndex: Q }), p && v("canvas", { className: Ua, ref: F, width: X.width, height: X.height, "data-grow": e, onContextMenu: P }), T && m.mode === "textedition" && j(n)[0]?.type === "text" && v(Mo, { disabled: !A.features.edition, shape: j(n)[0], defaultValue: m.defaultValue, updateValue: L, saveShapes: d, settings: A })] }) });
1320
+ }), sa = "ArrowUp", ra = "ArrowDown", la = "ArrowLeft", ca = "ArrowRight", Lo = "Delete", Zo = "Backspace", Vo = "Escape", da = "Shift", ha = "Alt", ua = "Option", Vt = " ", Ho = "z", To = "Z", zo = "y", Ao = "Y", Eo = "+", Io = "-", No = "0", pa = "copy", ga = "paste", Do = ({ isInsideComponent: e, isInsideCanvas: t, selectedShape: i, isEditingText: a, settings: n, setSelectedShape: o, setActiveTool: r, setCanvasZoom: l, resetZoom: s, setSelectionMode: c, setSelectionFrame: u, removeShape: d, pasteShapes: h, updateShapes: f, backwardShape: g, forwardShape: x, setShiftPressed: C, setAltPressed: k, setIsSpacePressed: w }) => {
1321
+ const [m, y] = $(void 0);
1322
+ return J(() => {
1323
+ const b = (S) => {
1324
+ i && (a || (S.preventDefault(), y({ ...i })));
1325
+ }, Z = (S) => {
1326
+ m && (a || (S.preventDefault(), h(((V, I) => j(V).map((N) => ({ ...oi([20, 20], N, [0, 0], I, !1), id: ye(`${N.type}_`) })))(m, n))));
1327
+ }, A = (S) => {
1298
1328
  switch (S.key) {
1299
- case ta:
1300
- f(!1);
1329
+ case da:
1330
+ C(!1);
1331
+ break;
1332
+ case ha:
1333
+ case ua:
1334
+ k(!1);
1301
1335
  break;
1302
- case ia:
1303
- case aa:
1304
- v(!1);
1336
+ case Vt:
1337
+ w(!1);
1305
1338
  }
1306
- }, m = (S) => {
1339
+ }, T = (S) => {
1307
1340
  if (S.metaKey || S.ctrlKey) {
1308
- if (S.key === ho || S.key === co) return S.preventDefault(), S.stopPropagation(), void (S.shiftKey ? u() : c());
1309
- if (!Ra() && (S.key === po || S.key === uo)) return S.preventDefault(), S.stopPropagation(), void u();
1341
+ if (S.key === To || S.key === Ho) return S.preventDefault(), S.stopPropagation(), void (S.shiftKey ? x() : g());
1342
+ if (!Ga() && (S.key === Ao || S.key === zo)) return S.preventDefault(), S.stopPropagation(), void x();
1343
+ if (S.key === Eo) return S.preventDefault(), S.stopPropagation(), void l("zoom");
1344
+ if (S.key === Io) return S.preventDefault(), S.stopPropagation(), void l("unzoom");
1345
+ if (S.key === No) return S.preventDefault(), S.stopPropagation(), void s();
1310
1346
  }
1311
- if (S.key === ta) return S.preventDefault(), S.stopPropagation(), void f(!0);
1312
- if (S.key === ia || S.key === aa) return S.preventDefault(), S.stopPropagation(), void v(!0);
1313
- if (!t) return;
1314
- if (S.key === lo) return n(void 0), o(Be), s({ mode: "default" }), void l(void 0);
1315
- if (i) return;
1316
- const E = { [Ji]: [a.gridGap ? -a.gridGap : -1, 0], [ea]: [a.gridGap ? a.gridGap : 1, 0], [Ki]: [0, a.gridGap ? a.gridGap : 1], [ji]: [0, a.gridGap ? -a.gridGap : -1] };
1347
+ if (S.key === da) return S.preventDefault(), S.stopPropagation(), void C(!0);
1348
+ if (S.key === Vt && t) return S.preventDefault(), S.stopPropagation(), void w(!0);
1349
+ if (S.key === ha || S.key === ua) return S.preventDefault(), S.stopPropagation(), void k(!0);
1350
+ if (!i) return;
1351
+ if (S.key === Vo) return o(void 0), r(Fe), c({ mode: "default" }), void u(void 0);
1352
+ if (a) return;
1353
+ const V = { [la]: [n.gridGap ? -n.gridGap : -1, 0], [ca]: [n.gridGap ? n.gridGap : 1, 0], [ra]: [0, n.gridGap ? n.gridGap : 1], [sa]: [0, n.gridGap ? -n.gridGap : -1] };
1317
1354
  switch (S.key) {
1318
- case Ji:
1319
- case ea:
1320
- case Ki:
1321
- case ji:
1322
- S.preventDefault(), S.stopPropagation(), h(((H, z, T, V, I) => q(z).map((W) => ii(H, W, T, V, I)))(E[S.key], t, [0, 0], a, !1));
1355
+ case la:
1356
+ case ca:
1357
+ case ra:
1358
+ case sa:
1359
+ S.preventDefault(), S.stopPropagation(), f(((I, N, H, D, U) => j(N).map((F) => oi(I, F, H, D, U)))(V[S.key], i, [0, 0], n, !1));
1323
1360
  break;
1324
- case so:
1325
- case ro:
1326
- S.preventDefault(), S.stopPropagation(), r(q(t));
1361
+ case Lo:
1362
+ case Zo:
1363
+ S.preventDefault(), S.stopPropagation(), d(j(i));
1327
1364
  }
1328
1365
  };
1329
- if (e) return document.addEventListener("keydown", m), document.addEventListener("keyup", y), document.addEventListener(na, P), document.addEventListener(oa, x), () => {
1330
- document.removeEventListener("keydown", m), document.removeEventListener("keyup", y), document.removeEventListener(na, P), document.removeEventListener(oa, x);
1366
+ if (e) return document.addEventListener("keydown", T), document.addEventListener("keyup", A), document.addEventListener(pa, b), document.addEventListener(ga, Z), () => {
1367
+ document.removeEventListener("keydown", T), document.removeEventListener("keyup", A), document.removeEventListener(pa, b), document.removeEventListener(ga, Z);
1331
1368
  };
1332
- }, [e, b, i, t, a, h, r, n, d, c, u, f, v, o, s, l]), {};
1333
- }, Bo = ({ options: e, className: t, style: i, canvasProps: a }) => {
1334
- const { shapesRef: n, selectedShape: o, selectionFrame: s, hoveredShape: l, addShape: r, setSelectedShape: d, setSelectionFrame: h, refreshSelectedShapes: c, refreshHoveredShape: u, removeShape: f, updateShape: v, backwardShape: b, forwardShape: M, saveShapes: P, refs: x, width: y, height: m, settings: S, setCanvasSize: E, setCanvasOffset: H, selectShapes: z, activeTool: T, setActiveTool: V, isInsideComponent: I, isEditMode: W, canvas: { withSkeleton: A, withFrameSelection: R, canGrow: _, canShrink: U }, canvasOffsetStartData: C, setCanvasOffsetStartData: p, selectionMode: w, setSelectionMode: Q, setCanvasMoveAcceleration: L, isShiftPressed: k, isAltPressed: D, setShiftPressed: Z, setAltPressed: X } = a, { canvasBackgroundColor: O, canvasSelectionColor: de, canvasSelectionWidth: N } = { ...wn, ...e }, oe = ae(null), G = F((j) => {
1335
- r(j), z(j);
1336
- }, [r, z]), le = F((j) => {
1337
- E({ realWidth: y, realHeight: m, width: j, height: m * j / y, scaleRatio: j / y });
1338
- }, [y, m, E]);
1339
- return go({ isInsideComponent: I, isEditingText: w.mode === "textedition", settings: S, selectedShape: o, setSelectedShape: d, removeShape: f, pasteShapes: G, updateShapes: v, backwardShape: b, forwardShape: M, setShiftPressed: Z, setAltPressed: X, setActiveTool: V, setSelectionMode: Q, setSelectionFrame: h }), (({ onResized: j, element: se }) => {
1340
- K(() => {
1341
- const ne = se.current;
1342
- if (!ne) return;
1343
- const Qe = new ResizeObserver((te) => {
1344
- const ue = te?.[0]?.borderBoxSize?.[0], { width: Te, height: ve } = ue ? { width: ue.inlineSize, height: ue.blockSize } : te?.[0]?.contentRect ?? {};
1345
- Te !== void 0 && ve !== void 0 && j(Te, ve);
1369
+ }, [e, t, m, a, i, n, f, d, o, h, g, x, C, k, r, c, u, l, s, w]), {};
1370
+ }, gs = ({ options: e, className: t, style: i, canvasProps: a }) => {
1371
+ const { shapesRef: n, selectedShape: o, selectionFrame: r, hoveredShape: l, addShape: s, setSelectedShape: c, setSelectionFrame: u, refreshSelectedShapes: d, refreshHoveredShape: h, removeShape: f, updateShape: g, backwardShape: x, forwardShape: C, saveShapes: k, refs: w, width: m, height: y, settings: b, setCanvasSize: Z, setCanvasOffset: A, selectShapes: T, activeTool: S, setActiveTool: V, isInsideComponent: I, isInsideCanvas: N, isEditMode: H, canvas: { withSkeleton: D, withFrameSelection: U, canGrow: F, canShrink: X }, canvasOffsetStartData: p, setCanvasOffsetStartData: Q, selectionMode: M, setSelectionMode: L, setCanvasMoveAcceleration: P, isShiftPressed: E, isAltPressed: W, isSpacePressed: O, setShiftPressed: z, setAltPressed: ie, setCanvasZoom: re, resetZoom: R, setIsSpacePressed: oe } = a, { canvasBackgroundColor: G, canvasSelectionColor: le, canvasSelectionWidth: ae } = { ...In, ...e }, pe = te(null), se = B((q) => {
1372
+ s(q), T(q);
1373
+ }, [s, T]), ge = B((q) => {
1374
+ Z({ realWidth: m, realHeight: y, width: q, height: y * q / m, scaleRatio: q / m });
1375
+ }, [m, y, Z]);
1376
+ return Do({ isInsideComponent: I, isInsideCanvas: N, isEditingText: M.mode === "textedition", settings: b, selectedShape: o, setSelectedShape: c, removeShape: f, pasteShapes: se, updateShapes: g, backwardShape: x, forwardShape: C, setShiftPressed: z, setAltPressed: ie, setActiveTool: V, setSelectionMode: L, setSelectionFrame: u, setCanvasZoom: re, resetZoom: R, setIsSpacePressed: oe }), (({ onResized: q, element: he }) => {
1377
+ J(() => {
1378
+ const ce = he.current;
1379
+ if (!ce) return;
1380
+ const Ee = new ResizeObserver((Ie) => {
1381
+ const He = Ie?.[0]?.borderBoxSize?.[0], { width: ve, height: ne } = He ? { width: He.inlineSize, height: He.blockSize } : Ie?.[0]?.contentRect ?? {};
1382
+ ve !== void 0 && ne !== void 0 && q(ve, ne);
1346
1383
  });
1347
- return Qe.observe(ne), () => {
1348
- Qe.unobserve(ne);
1384
+ return Ee.observe(ce), () => {
1385
+ Ee.unobserve(ce);
1349
1386
  };
1350
- }, [se, j]);
1351
- })({ element: oe, onResized: le }), g("div", { ref: oe, className: "react-paint-app-row" + (t ? ` ${t}` : ""), "data-grow": _, "data-shrink": U, style: { "--react-paint-app-row-width": S.canvasSize.width, "--react-paint-app-canvaswidth": y, "--react-paint-app-canvasheight": m, "--react-paint-app-row-aspectratio": `calc(${S.canvasSize.width} / ${S.canvasSize.height})`, "--react-paint-app-canvas-bg": O, ...i }, children: g(oo, { ref: x.canvas, canGrow: _, isInsideComponent: I, activeTool: T, setActiveTool: V, canvasOffsetStartData: C, setCanvasOffsetStartData: p, shapes: n.current, addShapes: r, updateSingleShape: v, selectedShape: o, selectionFrame: s, setSelectedShape: d, setSelectionFrame: h, hoveredShape: l, refreshHoveredShape: u, refreshSelectedShapes: c, settings: S, setCanvasOffset: H, saveShapes: P, selectionMode: w, setSelectionMode: Q, setCanvasMoveAcceleration: L, selectionColor: de, selectionWidth: N, isEditMode: W, isShiftPressed: k, isAltPressed: D, withFrameSelection: R, withSkeleton: A }) });
1352
- }, vo = ({ isLoading: e = !1 }) => {
1387
+ }, [he, q]);
1388
+ })({ element: pe, onResized: ge }), v("div", { ref: pe, className: "react-paint-app-row" + (t ? ` ${t}` : ""), "data-grow": F, "data-shrink": X, style: { "--react-paint-app-row-width": b.canvasSize.width, "--react-paint-app-canvaswidth": m, "--react-paint-app-canvasheight": y, "--react-paint-app-row-aspectratio": `calc(${b.canvasSize.width} / ${b.canvasSize.height})`, "--react-paint-app-canvas-bg": G, ...i }, children: v(Po, { isSpacePressed: O, ref: w.canvas, canGrow: F, isInsideComponent: I, activeTool: S, setActiveTool: V, canvasOffsetStartData: p, setCanvasOffsetStartData: Q, shapes: n.current, addShapes: s, updateSingleShape: g, selectedShape: o, selectionFrame: r, setSelectedShape: c, setSelectionFrame: u, hoveredShape: l, refreshHoveredShape: h, refreshSelectedShapes: d, settings: b, setCanvasOffset: A, saveShapes: k, selectionMode: M, setSelectionMode: L, setCanvasMoveAcceleration: P, selectionColor: le, selectionWidth: ae, isEditMode: H, isShiftPressed: E, isAltPressed: W, withFrameSelection: U, withSkeleton: D }) });
1389
+ }, Ro = ({ isLoading: e = !1 }) => {
1353
1390
  const [t, i] = $("hidden");
1354
- return K(() => {
1391
+ return J(() => {
1355
1392
  if (!e) {
1356
1393
  i("fadeOut");
1357
1394
  const a = setTimeout(() => i("hidden"), 300);
@@ -1360,306 +1397,311 @@ const Ni = ({ ctx: e, path: t, rect: i, offset: a, checkFill: n }) => {
1360
1397
  };
1361
1398
  }
1362
1399
  i("visible");
1363
- }, [e]), t === "hidden" ? null : g("div", { className: "react-paint-editor-loading", "data-loading": t, style: { "--react-paint-editor-loading-zindex": Qn, "--react-paint-editor-loading-transition-duration": "300ms" }, children: B("div", { className: "react-paint-editor-loader", children: [g("div", {}), g("div", {}), g("div", {}), g("div", {})] }) });
1364
- }, fo = "infos", mo = 4e3, yo = ({ type: e, text: t, duration: i }) => {
1400
+ }, [e]), t === "hidden" ? null : v("div", { className: "react-paint-editor-loading", "data-loading": t, style: { "--react-paint-editor-loading-zindex": An, "--react-paint-editor-loading-transition-duration": "300ms" }, children: Y("div", { className: "react-paint-editor-loader", children: [v("div", {}), v("div", {}), v("div", {}), v("div", {})] }) });
1401
+ }, Wo = "infos", Oo = 4e3, Fo = ({ type: e, text: t, duration: i }) => {
1365
1402
  const [a, n] = $(!1);
1366
- return K(() => {
1403
+ return J(() => {
1367
1404
  const o = setTimeout(() => {
1368
1405
  n(!0);
1369
- }, 100), s = setTimeout(() => {
1406
+ }, 100), r = setTimeout(() => {
1370
1407
  n(!1);
1371
1408
  }, i - 500 - 100);
1372
1409
  return () => {
1373
- clearTimeout(o), clearTimeout(s);
1410
+ clearTimeout(o), clearTimeout(r);
1374
1411
  };
1375
- }, [i]), g("div", { className: "react-paint-editor-snackbar", "data-is-shown": +a, "data-type": e, style: { "--react-paint-editor-panel-transition-duration": "500ms" }, children: t });
1376
- }, So = ({ snackbarList: e }) => g("div", { className: "react-paint-editor-snackbar-container", style: { "--react-paint-editor-snackbar-zindex": bn }, children: e.map((t) => g(yo, { ...t }, t.id)) }), J = ua.forwardRef((e, t) => {
1377
- if (e.type === "file" || e.type === "color") {
1378
- const { hidden: h = !1, disabled: c = !1, selected: u = !1, icon: f, children: v, className: b = "", title: M, onClick: P, ...x } = e;
1379
- return B("label", { className: `react-paint-editor-button ${b}`, title: M, onClick: P, "data-disabled": +c, "data-selected": +u, "data-hidden": +h, children: [g("input", { ref: t, disabled: c, ...x }), B("span", { className: "react-paint-editor-button-content", children: [v && g("span", { className: "react-paint-editor-button-children", children: v }), f && g("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: f } })] })] });
1380
- }
1381
- const { hidden: i = !1, disabled: a = !1, selected: n = !1, icon: o, children: s, type: l = "button", className: r = "", ...d } = e;
1382
- return g("button", { className: `react-paint-editor-button ${r}`, ref: t, disabled: a, "data-disabled": +a, "data-selected": +n, "data-hidden": +i, type: l, ...d, children: B("span", { className: "react-paint-editor-button-content", children: [s && g("span", { className: "react-paint-editor-button-children", children: s }), o && g("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: o } })] }) });
1383
- }), Ke = ({ children: e, title: t = "", className: i = "", position: a = "bottom", fitContainer: n = !1, alignment: o = "center", style: s, ...l }) => B("div", { className: `react-paint-editor-panel ${i}`, "data-fitcontainer": n, "data-position": a, "data-alignment": o, style: { ...s, "--react-paint-editor-panel-zindex": ba }, ...l, children: [t && g("h3", { className: "react-paint-editor-panel-title", children: t }), e] }), Qo = (e) => {
1412
+ }, [i]), v("div", { className: "react-paint-editor-snackbar", "data-is-shown": +a, "data-type": e, style: { "--react-paint-editor-panel-transition-duration": "500ms" }, children: t });
1413
+ }, Bo = ({ snackbarList: e }) => v("div", { className: "react-paint-editor-snackbar-container", style: { "--react-paint-editor-snackbar-zindex": En }, children: e.map((t) => v(Fo, { ...t }, t.id)) }), $o = si.forwardRef((e, t) => {
1414
+ const { hidden: i = !1, disabled: a = !1, selected: n = !1, icon: o, children: r, className: l = "", title: s, onClick: c, ...u } = e, d = a ? -1 : 0, h = te(null);
1415
+ return xa(t, () => h.current), Y("label", { className: `react-paint-editor-button ${l}`, title: s, onClick: c, "data-disabled": +a, "data-selected": +n, "data-hidden": +i, tabIndex: d, onKeyDown: (f) => {
1416
+ f.key === Vt && (f.preventDefault(), f.stopPropagation());
1417
+ }, onKeyUp: (f) => {
1418
+ f.preventDefault(), f.stopPropagation(), f.key === Vt && h.current?.click();
1419
+ }, children: [v("input", { ref: h, disabled: a, ...u }), Y("span", { className: "react-paint-editor-button-content", children: [r && v("span", { className: "react-paint-editor-button-children", children: r }), o && v("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: o } })] })] });
1420
+ }), K = si.forwardRef((e, t) => {
1421
+ if (e.type === "file" || e.type === "color") return v($o, { ...e, ref: t });
1422
+ const { hidden: i = !1, disabled: a = !1, selected: n = !1, icon: o, children: r, type: l = "button", className: s = "", ...c } = e;
1423
+ return v("button", { className: `react-paint-editor-button ${s}`, ref: t, disabled: a, "data-disabled": +a, "data-selected": +n, "data-hidden": +i, type: l, ...c, children: Y("span", { className: "react-paint-editor-button-content", children: [r && v("span", { className: "react-paint-editor-button-children", children: r }), o && v("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: o } })] }) });
1424
+ }), tt = ({ children: e, title: t = "", className: i = "", position: a = "bottom", fitContainer: n = !1, alignment: o = "center", style: r, ...l }) => Y("div", { className: `react-paint-editor-panel ${i}`, "data-fitcontainer": n, "data-position": a, "data-alignment": o, style: { ...r, "--react-paint-editor-panel-zindex": Va }, ...l, children: [t && v("h3", { className: "react-paint-editor-panel-title", children: t }), e] }), Yo = (e) => {
1384
1425
  switch (e) {
1385
1426
  case "brush":
1386
- return va;
1427
+ return Ca;
1387
1428
  case "line":
1388
- return ya;
1429
+ return Pa;
1389
1430
  case "polygon":
1390
- return oi;
1431
+ return ci;
1391
1432
  case "curve":
1392
- return Sa;
1433
+ return La;
1393
1434
  case "rect":
1394
1435
  case "square":
1395
- return ai;
1436
+ return ri;
1396
1437
  case "circle":
1397
1438
  case "ellipse":
1398
- return ni;
1439
+ return li;
1399
1440
  case "text":
1400
- return ma;
1441
+ return ka;
1401
1442
  case "picture":
1402
- return si;
1443
+ return di;
1403
1444
  case "group":
1404
1445
  return '<svg><path d="M3.333 17.5V16.667H7.5V17.5ZM3.333 14.167V13.333H9.167V14.167ZM3.333 10.833V10H10.833V10.833ZM3.333 7.5V6.667H12.5V7.5ZM3.333 4.167V3.333H13.333V4.167ZM3.333 0.833V0H16.667V0.833Z"/></svg>';
1405
1446
  case "triangle":
1406
1447
  return "";
1407
1448
  }
1408
- }, bo = ({ disabled: e = !1, shape: t, selected: i, layoutDragging: a, toggleShapeVisibility: n, toggleShapeLock: o, setLayoutDragging: s, handleRemove: l, handleSelect: r, onMoveShapes: d }) => {
1409
- const h = ae(null), { isOver: c } = (({ disabled: u = !1, ref: f, shape: v, layoutDragging: b, setLayoutDragging: M, handleSelect: P, onMoveShapes: x }) => {
1410
- const [y, m] = $(!1);
1411
- return K(() => {
1412
- b || m(!1);
1413
- }, [b]), K(() => {
1414
- const S = f.current;
1415
- if (!S) return;
1416
- const E = () => {
1417
- M(void 0);
1418
- }, H = (W) => (W.preventDefault && W.preventDefault(), !1), z = (W) => {
1419
- P([v]), W.dataTransfer && (W.dataTransfer.effectAllowed = "move", W.dataTransfer.setData("draggableShapeId", v.id), M(v.id));
1420
- }, T = () => {
1421
- b !== v.id && m(!0);
1449
+ }, Uo = ({ disabled: e = !1, shape: t, selected: i, layoutDragging: a, toggleShapeVisibility: n, toggleShapeLock: o, setLayoutDragging: r, handleRemove: l, handleSelect: s, onMoveShapes: c }) => {
1450
+ const u = te(null), { isOver: d } = (({ disabled: h = !1, ref: f, shape: g, layoutDragging: x, setLayoutDragging: C, handleSelect: k, onMoveShapes: w }) => {
1451
+ const [m, y] = $(!1);
1452
+ return J(() => {
1453
+ x || y(!1);
1454
+ }, [x]), J(() => {
1455
+ const b = f.current;
1456
+ if (!b) return;
1457
+ const Z = () => {
1458
+ C(void 0);
1459
+ }, A = (N) => (N.preventDefault && N.preventDefault(), !1), T = (N) => {
1460
+ k([g]), N.dataTransfer && (N.dataTransfer.effectAllowed = "move", N.dataTransfer.setData("draggableShapeId", g.id), C(g.id));
1461
+ }, S = () => {
1462
+ x !== g.id && y(!0);
1422
1463
  }, V = () => {
1423
- m(!1);
1424
- }, I = (W) => (W.stopPropagation(), W.dataTransfer && x(W.dataTransfer.getData("draggableShapeId"), v.id), !1);
1425
- return u || (S.addEventListener("dragstart", z), S.addEventListener("dragend", E), S.addEventListener("dragover", H), S.addEventListener("dragenter", T), S.addEventListener("dragleave", V), S.addEventListener("drop", I)), () => {
1426
- u || (S.removeEventListener("dragstart", z), S.removeEventListener("dragend", E), S.removeEventListener("dragover", H), S.removeEventListener("dragenter", T), S.removeEventListener("dragleave", V), S.removeEventListener("drop", I));
1464
+ y(!1);
1465
+ }, I = (N) => (N.stopPropagation(), N.dataTransfer && w(N.dataTransfer.getData("draggableShapeId"), g.id), !1);
1466
+ return h || (b.addEventListener("dragstart", T), b.addEventListener("dragend", Z), b.addEventListener("dragover", A), b.addEventListener("dragenter", S), b.addEventListener("dragleave", V), b.addEventListener("drop", I)), () => {
1467
+ h || (b.removeEventListener("dragstart", T), b.removeEventListener("dragend", Z), b.removeEventListener("dragover", A), b.removeEventListener("dragenter", S), b.removeEventListener("dragleave", V), b.removeEventListener("drop", I));
1427
1468
  };
1428
- }, [u, f, v, M, P, x, b]), { isOver: y };
1429
- })({ disabled: e, ref: h, shape: t, layoutDragging: a, setLayoutDragging: s, handleSelect: r, onMoveShapes: d });
1430
- return B("div", { className: "react-paint-editor-layout", "data-disabled": +e, draggable: !e, "data-is-dragging": +(a === t.id), "data-is-over": +c, onClick: (u) => {
1431
- e || (u.preventDefault(), u.stopPropagation(), r([t]));
1432
- }, "data-selected": +i, ref: h, tabIndex: -1, children: [g("span", { dangerouslySetInnerHTML: { __html: Qo(t.type) } }), g("span", { children: t.id }), g("div", { className: "react-paint-editor-layouts-separator" }), g(J, { className: "react-paint-editor-layouts-visible-button", title: t.visible ? "Hide" : "Show", "data-visible": t.visible !== !1, disabled: e, selected: i, onClick: (u) => {
1433
- e || (u.preventDefault(), u.stopPropagation(), n([t]));
1434
- }, icon: t.visible === !1 ? '<svg><path d="M13.521 11.021 12.25 9.75Q12.333 8.75 11.604 7.979Q10.875 7.208 9.812 7.312L8.542 6.042Q8.896 5.896 9.26 5.833Q9.625 5.771 10 5.771Q11.583 5.771 12.688 6.875Q13.792 7.979 13.792 9.562Q13.792 9.979 13.719 10.354Q13.646 10.729 13.521 11.021ZM16.167 13.646 14.917 12.417Q15.667 11.833 16.25 11.146Q16.833 10.458 17.25 9.562Q16.229 7.479 14.292 6.281Q12.354 5.083 10 5.083Q9.396 5.083 8.885 5.156Q8.375 5.229 7.875 5.375L6.5 4Q7.354 3.646 8.208 3.49Q9.062 3.333 10 3.333Q13.146 3.333 15.615 5.052Q18.083 6.771 19.167 9.562Q18.688 10.792 17.917 11.823Q17.146 12.854 16.167 13.646ZM16.396 18.854 12.938 15.396Q12.208 15.625 11.479 15.729Q10.75 15.833 10 15.833Q6.833 15.833 4.375 14.094Q1.917 12.354 0.833 9.562Q1.25 8.479 1.917 7.552Q2.583 6.625 3.417 5.875L1.125 3.562L2.375 2.354L17.625 17.625ZM4.604 7.062Q4.021 7.604 3.542 8.219Q3.062 8.833 2.729 9.562Q3.75 11.646 5.688 12.865Q7.625 14.083 10 14.083Q10.354 14.083 10.74 14.052Q11.125 14.021 11.479 13.938L10.812 13.271Q10.625 13.312 10.417 13.333Q10.208 13.354 10 13.354Q8.417 13.354 7.312 12.25Q6.208 11.146 6.208 9.562Q6.208 9.354 6.24 9.167Q6.271 8.979 6.312 8.771ZM11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875ZM8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Z"/></svg>' : '<svg><path d="M10 13.354Q11.583 13.354 12.688 12.25Q13.792 11.146 13.792 9.562Q13.792 7.979 12.688 6.875Q11.583 5.771 10 5.771Q8.417 5.771 7.312 6.875Q6.208 7.979 6.208 9.562Q6.208 11.146 7.312 12.25Q8.417 13.354 10 13.354ZM10 11.812Q9.062 11.812 8.406 11.156Q7.75 10.5 7.75 9.562Q7.75 8.625 8.406 7.969Q9.062 7.312 10 7.312Q10.938 7.312 11.594 7.969Q12.25 8.625 12.25 9.562Q12.25 10.5 11.594 11.156Q10.938 11.812 10 11.812ZM10 15.833Q6.938 15.833 4.448 14.125Q1.958 12.417 0.833 9.562Q1.958 6.708 4.458 5.021Q6.958 3.333 10 3.333Q13.042 3.333 15.542 5.021Q18.042 6.708 19.167 9.562Q18.042 12.417 15.552 14.125Q13.062 15.833 10 15.833ZM10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562ZM10 14.083Q12.333 14.083 14.281 12.865Q16.229 11.646 17.25 9.562Q16.229 7.479 14.281 6.281Q12.333 5.083 10 5.083Q7.667 5.083 5.708 6.281Q3.75 7.479 2.729 9.562Q3.75 11.646 5.708 12.865Q7.667 14.083 10 14.083Z"/></svg>' }), g(J, { className: "react-paint-editor-layouts-locked-button", title: t.locked ? "Locked" : "Unlocked", "data-locked": !!t.locked, disabled: e, selected: i, onClick: (u) => {
1435
- e || (u.preventDefault(), u.stopPropagation(), o([t]));
1436
- }, icon: t.locked ? '<svg><path d="M10 0.833Q11.771 0.833 12.99 2.052Q14.208 3.271 14.208 5.042V6.667H14.917Q15.646 6.667 16.156 7.177Q16.667 7.688 16.667 8.417V16.562Q16.667 17.292 16.156 17.812Q15.646 18.333 14.917 18.333H5.083Q4.354 18.333 3.844 17.812Q3.333 17.292 3.333 16.562V8.417Q3.333 7.688 3.844 7.177Q4.354 6.667 5.083 6.667H5.792V5.042Q5.792 3.271 7.01 2.052Q8.229 0.833 10 0.833ZM10 2.583Q8.979 2.583 8.26 3.302Q7.542 4.021 7.542 5.042V6.667H12.458V5.042Q12.458 4.021 11.74 3.302Q11.021 2.583 10 2.583ZM5.083 16.583H14.917Q14.917 16.583 14.917 16.583Q14.917 16.583 14.917 16.583V8.417Q14.917 8.417 14.917 8.417Q14.917 8.417 14.917 8.417H5.083Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583ZM10 10.812Q9.292 10.812 8.802 11.302Q8.312 11.792 8.312 12.5Q8.312 13.208 8.802 13.698Q9.292 14.188 10 14.188Q10.708 14.188 11.198 13.698Q11.688 13.208 11.688 12.5Q11.688 11.792 11.198 11.302Q10.708 10.812 10 10.812ZM5.083 8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583V8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417Z"/></svg>' : '<svg><path d="M5.792 5.042Q5.792 3.271 7.01 2.052Q8.229 0.833 10 0.833Q11.771 0.833 12.99 2.052Q14.208 3.271 14.208 5.042V6.667H14.917Q15.646 6.667 16.156 7.177Q16.667 7.688 16.667 8.417V16.562Q16.667 17.292 16.156 17.812Q15.646 18.333 14.917 18.333H5.083Q4.354 18.333 3.844 17.812Q3.333 17.292 3.333 16.562V8.417Q3.333 7.688 3.844 7.177Q4.354 6.667 5.083 6.667H12.458V5.042Q12.458 4.021 11.74 3.302Q11.021 2.583 10 2.583Q8.979 2.583 8.26 3.302Q7.542 4.021 7.542 5.042ZM5.083 16.583H14.917Q14.917 16.583 14.917 16.583Q14.917 16.583 14.917 16.583V8.417Q14.917 8.417 14.917 8.417Q14.917 8.417 14.917 8.417H5.083Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583ZM10 10.812Q9.292 10.812 8.802 11.302Q8.312 11.792 8.312 12.5Q8.312 13.208 8.802 13.698Q9.292 14.188 10 14.188Q10.708 14.188 11.198 13.698Q11.688 13.208 11.688 12.5Q11.688 11.792 11.198 11.302Q10.708 10.812 10 10.812ZM5.083 8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583V8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417Z"/></svg>' }), g(J, { className: "react-paint-editor-layouts-remove-button", title: "Remove", disabled: e, onClick: (u) => {
1437
- e || (u.preventDefault(), u.stopPropagation(), l([t]));
1438
- }, icon: fa })] });
1439
- }, wo = ({ gridFormat: e, setGridFormat: t, settings: i, shapes: a, removeShape: n, toggleShapeVisibility: o, toggleShapeLock: s, selectedShapes: l, moveShapes: r, selectShapes: d, isLayoutPanelShown: h }) => {
1440
- const [c, u] = $(void 0), f = !i.features.edition;
1441
- return h ? g(Ke, { alignment: "right", className: "react-paint-editor-layouts-panel", children: g("div", { className: "react-paint-editor-layouts-panel-content", children: B("div", { className: "react-paint-editor-layouts-scrolling-content", children: [B("div", { className: "react-paint-editor-layouts-row", children: [g("span", { className: "react-paint-editor-layouts-subtitle", children: "Grid" }), g(J, { icon: '<svg><path d="M18.333 15.854 16.583 14.104V13.354H15.833L14.083 11.604H16.583V8.375H13.375V10.896L11.625 9.146V8.375H10.875L9.125 6.625H11.625V3.417H8.396V5.896L6.646 4.146V3.417H5.896L4.146 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417ZM13.375 6.625H16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H13.375ZM16.771 19.229 15.854 18.333H3.417Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V4.125L0.812 3.271L2.042 2.021L18 18ZM13.375 16.583H14.104L13.375 15.833ZM8.396 11.604H9.125L8.396 10.854ZM8.396 16.583H11.625V14.083L10.875 13.354H8.396ZM3.417 6.625H4.167L3.417 5.875ZM3.417 11.604H6.646V9.104L5.917 8.375H3.417ZM6.646 16.583V13.354H3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Z"/></svg>', className: "react-paint-editor-layouts-grid-button", selected: e === "none", disabled: f, onClick: () => t("none") }), ["small", "medium", "large"].map((v) => g(J, { className: "react-paint-editor-layouts-grid-button", selected: e === v, disabled: f, onClick: () => t(v), children: v.charAt(0).toUpperCase() }, v))] }), g("hr", {}), g("div", { className: "react-paint-editor-layouts", children: a.length === 0 ? g("div", { className: "react-paint-editor-layouts-placeholder", children: "No layer yet" }) : a.map((v) => g(bo, { shape: v, disabled: f, layoutDragging: c, setLayoutDragging: u, selected: q(l).some((b) => b.id === v.id) ?? !1, handleSelect: d, handleRemove: n, onMoveShapes: r, toggleShapeVisibility: o, toggleShapeLock: s }, v.id)) })] }) }) }) : null;
1442
- }, Dt = ({ children: e, onClose: t, position: i = "center", title: a, className: n = "" }) => B("div", { className: "react-paint-editor-modal", "data-position": i, style: { "--react-paint-editor-modal-zindex": ba }, role: "dialog", "aria-modal": "true", "aria-labelledby": a, children: [g("div", { className: "react-paint-editor-modal-mask", onClick: t }), g("div", { className: `react-paint-editor-modal-panel ${n}`, children: e })] }), xt = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez une couleur", mode: a = "fill", disabled: n = !1, values: o, field: s, value: l = "", valueChanged: r }) => {
1443
- const [d] = $(me("settings_")), h = e === d;
1444
- return o.length ? B(Le, { children: [g(J, { selected: h, title: i, disabled: n, onClick: () => {
1445
- t((c) => c === d ? void 0 : d);
1446
- }, icon: l === "transparent" ? a === "fill" ? xi : wi : void 0, children: l !== "transparent" && g("div", { className: "react-paint-editor-colorfield-color", "data-mode": a, style: { "--react-paint-editor-colorfield-color-value": l } }) }), h && g(Ke, { title: i, alignment: "left", children: B("div", { className: "react-paint-editor-colorfield-wrapper", children: [o.map((c) => g(J, { title: c, selected: c === l, color: c, icon: c === "transparent" ? a === "fill" ? xi : wi : void 0, onClick: () => {
1447
- r(s, c);
1448
- }, children: c !== "transparent" && g("div", { className: "react-paint-editor-colorfield-color", color: c, "data-mode": a, style: { "--react-paint-editor-colorfield-color-value": c } }) }, c)), g(J, { type: "color", title: "Custom color", selected: l !== "" && !o.includes(l), value: l, onChange: (c) => {
1449
- const u = +c.target.value;
1450
- r(s, Number.isNaN(u) ? c.target.value : u);
1451
- }, children: g("div", { className: "react-paint-editor-colorfield-customcolor", style: { "--react-paint-editor-colorfield-color-value": o.includes(l) ? "var(--react-paint-editor-app-font-color)" : l }, children: g("span", { dangerouslySetInnerHTML: { __html: '<svg><path d="M9.958 18.333Q8.25 18.333 6.74 17.677Q5.229 17.021 4.104 15.885Q2.979 14.75 2.323 13.229Q1.667 11.708 1.667 10Q1.667 8.271 2.333 6.75Q3 5.229 4.156 4.104Q5.312 2.979 6.854 2.323Q8.396 1.667 10.125 1.667Q11.771 1.667 13.26 2.25Q14.75 2.833 15.875 3.854Q17 4.875 17.667 6.26Q18.333 7.646 18.333 9.25Q18.333 11.688 16.792 12.948Q15.25 14.208 13.188 14.208H11.75Q11.625 14.208 11.562 14.281Q11.5 14.354 11.5 14.458Q11.5 14.688 11.812 15.219Q12.125 15.75 12.125 16.458Q12.125 17.458 11.51 17.896Q10.896 18.333 9.958 18.333ZM5.458 10.875Q6 10.875 6.375 10.5Q6.75 10.125 6.75 9.583Q6.75 9.042 6.375 8.667Q6 8.292 5.458 8.292Q4.917 8.292 4.542 8.667Q4.167 9.042 4.167 9.583Q4.167 10.125 4.542 10.5Q4.917 10.875 5.458 10.875ZM7.917 7.583Q8.458 7.583 8.833 7.208Q9.208 6.833 9.208 6.292Q9.208 5.75 8.833 5.375Q8.458 5 7.917 5Q7.375 5 7 5.375Q6.625 5.75 6.625 6.292Q6.625 6.833 7 7.208Q7.375 7.583 7.917 7.583ZM12.021 7.583Q12.562 7.583 12.938 7.208Q13.312 6.833 13.312 6.292Q13.312 5.75 12.938 5.375Q12.562 5 12.021 5Q11.479 5 11.104 5.375Q10.729 5.75 10.729 6.292Q10.729 6.833 11.104 7.208Q11.479 7.583 12.021 7.583ZM14.479 10.875Q15.021 10.875 15.396 10.5Q15.771 10.125 15.771 9.583Q15.771 9.042 15.396 8.667Q15.021 8.292 14.479 8.292Q13.938 8.292 13.562 8.667Q13.188 9.042 13.188 9.583Q13.188 10.125 13.562 10.5Q13.938 10.875 14.479 10.875Z"/></svg>' } }) }) })] }) })] }) : null;
1452
- }, xo = ({ disabled: e = !1, selectedShape: t, removeShape: i }) => g(J, { title: "Delete", disabled: e, "data-disabled": +e, onClick: () => {
1453
- i(q(t));
1454
- }, icon: fa }), Nt = ({ CustomOption: e, selectedSettings: t, setSelectedSettings: i, title: a = "Choisissez l'option", disabled: n = !1, field: o, icon: s, values: l, defaultValue: r, valueChanged: d }) => {
1455
- const [h] = $(me("settings_")), c = t === h;
1456
- return l.length ? B(Le, { children: [g(J, { selected: c, title: a, icon: s, disabled: n, onClick: () => {
1457
- i((u) => u === h ? void 0 : h);
1458
- } }), c && g(Ke, { title: a, alignment: "left", fitContainer: !0, children: g("div", { className: "react-paint-editor-selectfield-wrapper", children: l.map((u) => g(J, { title: `${u}`, onClick: () => ((f) => {
1459
- d(o, f);
1460
- })(u), selected: r === u, style: { "--react-paint-editor-button-padding": "16px" }, children: g(e, { children: u }) }, u)) }) })] }) : null;
1461
- }, Co = ({ children: e }) => g("span", { className: "react-paint-editor-fontfamily-option", style: { "--react-paint-editor-fontfamily-family": e }, children: e }), sa = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: a, defaultValue: n, valueChanged: o }) => a.length ? g(Nt, { selectedSettings: e, setSelectedSettings: t, CustomOption: Co, title: "Police", icon: '<svg><path d="M5.312 14.979H7.125L8.042 12.479H11.979L12.896 14.979H14.708L10.917 5H9.083ZM8.542 10.958 9.958 6.958H10.042L11.458 10.958ZM3.417 18.333Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V3.417Q1.667 2.688 2.177 2.177Q2.688 1.667 3.417 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417V16.583Q18.333 17.312 17.823 17.823Q17.312 18.333 16.583 18.333ZM3.417 16.583H16.583Q16.583 16.583 16.583 16.583Q16.583 16.583 16.583 16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583ZM3.417 3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583V3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417Z"/></svg>', disabled: i, field: "fontFamily", values: a, defaultValue: n, valueChanged: o }) : null, Mo = ({ disabled: e, toggleLayoutPanel: t }) => g(J, { title: "Toggle layers panel", disabled: e, onClick: t, icon: '<svg><path d="M10 17.646 2.438 11.75 3.875 10.646 10 15.396 16.125 10.646 17.562 11.75ZM10 13.188 2.5 7.354 10 1.521 17.5 7.354Z"/></svg>', className: "react-paint-editor-layout-button" }), ko = ({ children: e }) => B("span", { className: "react-paint-editor-linearrow-option", "data-type": e, children: [g("span", { className: "react-paint-editor-linearrow-left" }), g("span", { className: "react-paint-editor-linearrow-right" })] }), ra = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: a, defaultValue: n, valueChanged: o }) => a.length ? g(Nt, { selectedSettings: e, setSelectedSettings: t, CustomOption: ko, title: "Flèches", icon: '<svg><path d="M6 17 2 13 6 9 7.062 10.062 4.875 12.25H17V13.75H4.875L7.062 15.938ZM14 11 12.938 9.938 15.125 7.75H3V6.25H15.125L12.938 4.062L14 3L18 7Z"/></svg>', disabled: i, field: "lineArrow", values: a, defaultValue: n, valueChanged: o }) : null, Po = ({ children: e }) => B("span", { className: "react-paint-editor-linetype-option", "data-type": e, children: [g("span", {}), g("span", {}), g("span", {}), g("span", {}), g("span", {}), g("span", {}), g("span", {})] }), la = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: a, defaultValue: n, valueChanged: o }) => a.length ? g(Nt, { selectedSettings: e, setSelectedSettings: t, CustomOption: Po, icon: '<svg><path d="M3 16V14.5H4.5V16ZM6.125 16V14.5H7.625V16ZM9.25 16V14.5H10.75V16ZM12.375 16V14.5H13.875V16ZM15.5 16V14.5H17V16ZM3 13V11.5H6.5V13ZM8.25 13V11.5H11.75V13ZM13.5 13V11.5H17V13ZM3 10V8.5H9.25V10ZM10.75 10V8.5H17V10ZM3 7V4H17V7Z"/></svg>', title: "Type de traits", disabled: i, field: "lineDash", values: a, defaultValue: n, valueChanged: o }) : null, Ct = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez l'intervalle", icon: a, disabled: n = !1, field: o, value: s, min: l = 1, max: r = 20, step: d = 1, unity: h = "", valueChanged: c }) => {
1462
- const u = s === void 0, f = u ? "N/A" : `${Math.round(s)}${h}`, [v] = $(me("settings_")), b = ae(null);
1463
- K(() => () => {
1464
- b.current && clearTimeout(b.current);
1465
- }, []);
1466
- const M = e === v;
1467
- return l === r ? null : B(Le, { children: [g(J, { selected: M, title: i, disabled: n, icon: a, onClick: () => {
1468
- t((P) => P === v ? void 0 : v);
1469
- } }), M && g(Ke, { title: i, alignment: "left", fitContainer: !0, children: g("div", { children: B("label", { className: "react-paint-editor-rangefield", children: [g("input", { type: "range", min: l, max: r, step: d, value: s ?? (r + l) / 2, "data-indeterminate": +u, onChange: (P) => {
1470
- const x = +P.target.value;
1471
- c(o, Number.isNaN(x) ? P.target.value : x, !1), b.current && clearTimeout(b.current), b.current = setTimeout(() => {
1472
- c(o, Number.isNaN(x) ? P.target.value : x, !0);
1473
- }, 1e3);
1474
- } }), g("span", { children: f })] }) }) })] });
1475
- }, Lo = ({ children: e }) => g("span", { children: e === 0 ? "Non" : "Oui" }), Vo = [0, 1], ca = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, defaultValue: a, valueChanged: n }) => g(Nt, { selectedSettings: e, setSelectedSettings: t, CustomOption: Lo, title: "Fermer les points", icon: oi, disabled: i, field: "closedPoints", values: Vo, defaultValue: a, valueChanged: n }), Zo = ({ disabled: e = !1, className: t, toggleZoomPanel: i }) => g(J, { title: "Toggle zoom panel", disabled: e, onClick: i, icon: Qa, className: t ? ` ${t}` : "" }), Mt = ({ setSelectedSettings: e, disabled: t = !1, field: i, icon: a, values: n, value: o = !1, valueChanged: s }) => {
1476
- const [l] = $(me("settings_"));
1477
- return n.length !== 2 ? null : g(J, { onClick: () => {
1478
- e((r) => r === l ? void 0 : l), s(i, !o);
1469
+ }, [h, f, g, C, k, w, x]), { isOver: m };
1470
+ })({ disabled: e, ref: u, shape: t, layoutDragging: a, setLayoutDragging: r, handleSelect: s, onMoveShapes: c });
1471
+ return Y("div", { className: "react-paint-editor-layout", "data-disabled": +e, draggable: !e, "data-is-dragging": +(a === t.id), "data-is-over": +d, onClick: (h) => {
1472
+ e || (h.preventDefault(), h.stopPropagation(), s([t]));
1473
+ }, "data-selected": +i, ref: u, tabIndex: -1, children: [v("span", { dangerouslySetInnerHTML: { __html: Yo(t.type) } }), v("span", { children: t.id }), v("div", { className: "react-paint-editor-layouts-separator" }), v(K, { className: "react-paint-editor-layouts-visible-button", title: t.visible ? "Hide" : "Show", "data-visible": t.visible !== !1, disabled: e, selected: i, onClick: (h) => {
1474
+ e || (h.preventDefault(), h.stopPropagation(), n([t]));
1475
+ }, icon: t.visible === !1 ? '<svg><path d="M13.521 11.021 12.25 9.75Q12.333 8.75 11.604 7.979Q10.875 7.208 9.812 7.312L8.542 6.042Q8.896 5.896 9.26 5.833Q9.625 5.771 10 5.771Q11.583 5.771 12.688 6.875Q13.792 7.979 13.792 9.562Q13.792 9.979 13.719 10.354Q13.646 10.729 13.521 11.021ZM16.167 13.646 14.917 12.417Q15.667 11.833 16.25 11.146Q16.833 10.458 17.25 9.562Q16.229 7.479 14.292 6.281Q12.354 5.083 10 5.083Q9.396 5.083 8.885 5.156Q8.375 5.229 7.875 5.375L6.5 4Q7.354 3.646 8.208 3.49Q9.062 3.333 10 3.333Q13.146 3.333 15.615 5.052Q18.083 6.771 19.167 9.562Q18.688 10.792 17.917 11.823Q17.146 12.854 16.167 13.646ZM16.396 18.854 12.938 15.396Q12.208 15.625 11.479 15.729Q10.75 15.833 10 15.833Q6.833 15.833 4.375 14.094Q1.917 12.354 0.833 9.562Q1.25 8.479 1.917 7.552Q2.583 6.625 3.417 5.875L1.125 3.562L2.375 2.354L17.625 17.625ZM4.604 7.062Q4.021 7.604 3.542 8.219Q3.062 8.833 2.729 9.562Q3.75 11.646 5.688 12.865Q7.625 14.083 10 14.083Q10.354 14.083 10.74 14.052Q11.125 14.021 11.479 13.938L10.812 13.271Q10.625 13.312 10.417 13.333Q10.208 13.354 10 13.354Q8.417 13.354 7.312 12.25Q6.208 11.146 6.208 9.562Q6.208 9.354 6.24 9.167Q6.271 8.979 6.312 8.771ZM11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875ZM8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Z"/></svg>' : '<svg><path d="M10 13.354Q11.583 13.354 12.688 12.25Q13.792 11.146 13.792 9.562Q13.792 7.979 12.688 6.875Q11.583 5.771 10 5.771Q8.417 5.771 7.312 6.875Q6.208 7.979 6.208 9.562Q6.208 11.146 7.312 12.25Q8.417 13.354 10 13.354ZM10 11.812Q9.062 11.812 8.406 11.156Q7.75 10.5 7.75 9.562Q7.75 8.625 8.406 7.969Q9.062 7.312 10 7.312Q10.938 7.312 11.594 7.969Q12.25 8.625 12.25 9.562Q12.25 10.5 11.594 11.156Q10.938 11.812 10 11.812ZM10 15.833Q6.938 15.833 4.448 14.125Q1.958 12.417 0.833 9.562Q1.958 6.708 4.458 5.021Q6.958 3.333 10 3.333Q13.042 3.333 15.542 5.021Q18.042 6.708 19.167 9.562Q18.042 12.417 15.552 14.125Q13.062 15.833 10 15.833ZM10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562ZM10 14.083Q12.333 14.083 14.281 12.865Q16.229 11.646 17.25 9.562Q16.229 7.479 14.281 6.281Q12.333 5.083 10 5.083Q7.667 5.083 5.708 6.281Q3.75 7.479 2.729 9.562Q3.75 11.646 5.708 12.865Q7.667 14.083 10 14.083Z"/></svg>' }), v(K, { className: "react-paint-editor-layouts-locked-button", title: t.locked ? "Locked" : "Unlocked", "data-locked": !!t.locked, disabled: e, selected: i, onClick: (h) => {
1476
+ e || (h.preventDefault(), h.stopPropagation(), o([t]));
1477
+ }, icon: t.locked ? '<svg><path d="M10 0.833Q11.771 0.833 12.99 2.052Q14.208 3.271 14.208 5.042V6.667H14.917Q15.646 6.667 16.156 7.177Q16.667 7.688 16.667 8.417V16.562Q16.667 17.292 16.156 17.812Q15.646 18.333 14.917 18.333H5.083Q4.354 18.333 3.844 17.812Q3.333 17.292 3.333 16.562V8.417Q3.333 7.688 3.844 7.177Q4.354 6.667 5.083 6.667H5.792V5.042Q5.792 3.271 7.01 2.052Q8.229 0.833 10 0.833ZM10 2.583Q8.979 2.583 8.26 3.302Q7.542 4.021 7.542 5.042V6.667H12.458V5.042Q12.458 4.021 11.74 3.302Q11.021 2.583 10 2.583ZM5.083 16.583H14.917Q14.917 16.583 14.917 16.583Q14.917 16.583 14.917 16.583V8.417Q14.917 8.417 14.917 8.417Q14.917 8.417 14.917 8.417H5.083Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583ZM10 10.812Q9.292 10.812 8.802 11.302Q8.312 11.792 8.312 12.5Q8.312 13.208 8.802 13.698Q9.292 14.188 10 14.188Q10.708 14.188 11.198 13.698Q11.688 13.208 11.688 12.5Q11.688 11.792 11.198 11.302Q10.708 10.812 10 10.812ZM5.083 8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583V8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417Z"/></svg>' : '<svg><path d="M5.792 5.042Q5.792 3.271 7.01 2.052Q8.229 0.833 10 0.833Q11.771 0.833 12.99 2.052Q14.208 3.271 14.208 5.042V6.667H14.917Q15.646 6.667 16.156 7.177Q16.667 7.688 16.667 8.417V16.562Q16.667 17.292 16.156 17.812Q15.646 18.333 14.917 18.333H5.083Q4.354 18.333 3.844 17.812Q3.333 17.292 3.333 16.562V8.417Q3.333 7.688 3.844 7.177Q4.354 6.667 5.083 6.667H12.458V5.042Q12.458 4.021 11.74 3.302Q11.021 2.583 10 2.583Q8.979 2.583 8.26 3.302Q7.542 4.021 7.542 5.042ZM5.083 16.583H14.917Q14.917 16.583 14.917 16.583Q14.917 16.583 14.917 16.583V8.417Q14.917 8.417 14.917 8.417Q14.917 8.417 14.917 8.417H5.083Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583ZM10 10.812Q9.292 10.812 8.802 11.302Q8.312 11.792 8.312 12.5Q8.312 13.208 8.802 13.698Q9.292 14.188 10 14.188Q10.708 14.188 11.198 13.698Q11.688 13.208 11.688 12.5Q11.688 11.792 11.198 11.302Q10.708 10.812 10 10.812ZM5.083 8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583V8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417Z"/></svg>' }), v(K, { className: "react-paint-editor-layouts-remove-button", title: "Remove", disabled: e, onClick: (h) => {
1478
+ e || (h.preventDefault(), h.stopPropagation(), l([t]));
1479
+ }, icon: Ma })] });
1480
+ }, Xo = ({ gridFormat: e, setGridFormat: t, settings: i, shapes: a, removeShape: n, toggleShapeVisibility: o, toggleShapeLock: r, selectedShapes: l, moveShapes: s, selectShapes: c, isLayoutPanelShown: u }) => {
1481
+ const [d, h] = $(void 0), f = !i.features.edition;
1482
+ return u ? v(tt, { alignment: "right", className: "react-paint-editor-layouts-panel", children: v("div", { className: "react-paint-editor-layouts-panel-content", children: Y("div", { className: "react-paint-editor-layouts-scrolling-content", children: [Y("div", { className: "react-paint-editor-layouts-row", children: [v("span", { className: "react-paint-editor-layouts-subtitle", children: "Grid" }), v(K, { icon: '<svg><path d="M18.333 15.854 16.583 14.104V13.354H15.833L14.083 11.604H16.583V8.375H13.375V10.896L11.625 9.146V8.375H10.875L9.125 6.625H11.625V3.417H8.396V5.896L6.646 4.146V3.417H5.896L4.146 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417ZM13.375 6.625H16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H13.375ZM16.771 19.229 15.854 18.333H3.417Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V4.125L0.812 3.271L2.042 2.021L18 18ZM13.375 16.583H14.104L13.375 15.833ZM8.396 11.604H9.125L8.396 10.854ZM8.396 16.583H11.625V14.083L10.875 13.354H8.396ZM3.417 6.625H4.167L3.417 5.875ZM3.417 11.604H6.646V9.104L5.917 8.375H3.417ZM6.646 16.583V13.354H3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Z"/></svg>', className: "react-paint-editor-layouts-grid-button", selected: e === "none", disabled: f, onClick: () => t("none") }), ["small", "medium", "large"].map((g) => v(K, { className: "react-paint-editor-layouts-grid-button", selected: e === g, disabled: f, onClick: () => t(g), children: g.charAt(0).toUpperCase() }, g))] }), v("hr", {}), v("div", { className: "react-paint-editor-layouts", children: a.length === 0 ? v("div", { className: "react-paint-editor-layouts-placeholder", children: "No layer yet" }) : a.map((g) => v(Uo, { shape: g, disabled: f, layoutDragging: d, setLayoutDragging: h, selected: j(l).some((x) => x.id === g.id) ?? !1, handleSelect: c, handleRemove: n, onMoveShapes: s, toggleShapeVisibility: o, toggleShapeLock: r }, g.id)) })] }) }) }) : null;
1483
+ }, Nt = ({ children: e, onClose: t, position: i = "center", title: a, className: n = "" }) => Y("div", { className: "react-paint-editor-modal", "data-position": i, style: { "--react-paint-editor-modal-zindex": Va }, role: "dialog", "aria-modal": "true", "aria-labelledby": a, children: [v("div", { className: "react-paint-editor-modal-mask", onClick: t }), v("div", { className: `react-paint-editor-modal-panel ${n}`, children: e })] }), wt = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez une couleur", mode: a = "fill", disabled: n = !1, values: o, field: r, value: l = "", valueChanged: s }) => {
1484
+ const [c] = $(ye("settings_")), u = e === c;
1485
+ return o.length ? Y(Ve, { children: [v(K, { selected: u, title: i, disabled: n, onClick: () => {
1486
+ t((d) => d === c ? void 0 : c);
1487
+ }, icon: l === "transparent" ? a === "fill" ? zi : Ti : void 0, children: l !== "transparent" && v("div", { className: "react-paint-editor-colorfield-color", "data-mode": a, style: { "--react-paint-editor-colorfield-color-value": l } }) }), u && v(tt, { title: i, alignment: "left", children: Y("div", { className: "react-paint-editor-colorfield-wrapper", children: [o.map((d) => v(K, { title: d, selected: d === l, color: d, icon: d === "transparent" ? a === "fill" ? zi : Ti : void 0, onClick: () => {
1488
+ s(r, d);
1489
+ }, children: d !== "transparent" && v("div", { className: "react-paint-editor-colorfield-color", color: d, "data-mode": a, style: { "--react-paint-editor-colorfield-color-value": d } }) }, d)), v(K, { type: "color", title: "Custom color", selected: l !== "" && !o.includes(l), value: l, onChange: (d) => {
1490
+ const h = +d.target.value;
1491
+ s(r, Number.isNaN(h) ? d.target.value : h);
1492
+ }, children: v("div", { className: "react-paint-editor-colorfield-customcolor", style: { "--react-paint-editor-colorfield-color-value": o.includes(l) ? "var(--react-paint-editor-app-font-color)" : l }, children: v("span", { dangerouslySetInnerHTML: { __html: '<svg><path d="M9.958 18.333Q8.25 18.333 6.74 17.677Q5.229 17.021 4.104 15.885Q2.979 14.75 2.323 13.229Q1.667 11.708 1.667 10Q1.667 8.271 2.333 6.75Q3 5.229 4.156 4.104Q5.312 2.979 6.854 2.323Q8.396 1.667 10.125 1.667Q11.771 1.667 13.26 2.25Q14.75 2.833 15.875 3.854Q17 4.875 17.667 6.26Q18.333 7.646 18.333 9.25Q18.333 11.688 16.792 12.948Q15.25 14.208 13.188 14.208H11.75Q11.625 14.208 11.562 14.281Q11.5 14.354 11.5 14.458Q11.5 14.688 11.812 15.219Q12.125 15.75 12.125 16.458Q12.125 17.458 11.51 17.896Q10.896 18.333 9.958 18.333ZM5.458 10.875Q6 10.875 6.375 10.5Q6.75 10.125 6.75 9.583Q6.75 9.042 6.375 8.667Q6 8.292 5.458 8.292Q4.917 8.292 4.542 8.667Q4.167 9.042 4.167 9.583Q4.167 10.125 4.542 10.5Q4.917 10.875 5.458 10.875ZM7.917 7.583Q8.458 7.583 8.833 7.208Q9.208 6.833 9.208 6.292Q9.208 5.75 8.833 5.375Q8.458 5 7.917 5Q7.375 5 7 5.375Q6.625 5.75 6.625 6.292Q6.625 6.833 7 7.208Q7.375 7.583 7.917 7.583ZM12.021 7.583Q12.562 7.583 12.938 7.208Q13.312 6.833 13.312 6.292Q13.312 5.75 12.938 5.375Q12.562 5 12.021 5Q11.479 5 11.104 5.375Q10.729 5.75 10.729 6.292Q10.729 6.833 11.104 7.208Q11.479 7.583 12.021 7.583ZM14.479 10.875Q15.021 10.875 15.396 10.5Q15.771 10.125 15.771 9.583Q15.771 9.042 15.396 8.667Q15.021 8.292 14.479 8.292Q13.938 8.292 13.562 8.667Q13.188 9.042 13.188 9.583Q13.188 10.125 13.562 10.5Q13.938 10.875 14.479 10.875Z"/></svg>' } }) }) })] }) })] }) : null;
1493
+ }, Go = ({ disabled: e = !1, selectedShape: t, removeShape: i }) => v(K, { title: "Delete", disabled: e, "data-disabled": +e, onClick: () => {
1494
+ i(j(t));
1495
+ }, icon: Ma }), Dt = ({ CustomOption: e, selectedSettings: t, setSelectedSettings: i, title: a = "Choisissez l'option", disabled: n = !1, field: o, icon: r, values: l, defaultValue: s, valueChanged: c }) => {
1496
+ const [u] = $(ye("settings_")), d = t === u;
1497
+ return l.length ? Y(Ve, { children: [v(K, { selected: d, title: a, icon: r, disabled: n, onClick: () => {
1498
+ i((h) => h === u ? void 0 : u);
1499
+ } }), d && v(tt, { title: a, alignment: "left", fitContainer: !0, children: v("div", { className: "react-paint-editor-selectfield-wrapper", children: l.map((h) => v(K, { title: `${h}`, onClick: () => ((f) => {
1500
+ c(o, f);
1501
+ })(h), selected: s === h, style: { "--react-paint-editor-button-padding": "16px" }, children: v(e, { children: h }) }, h)) }) })] }) : null;
1502
+ }, qo = ({ children: e }) => v("span", { className: "react-paint-editor-fontfamily-option", style: { "--react-paint-editor-fontfamily-family": e }, children: e }), va = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: a, defaultValue: n, valueChanged: o }) => a.length ? v(Dt, { selectedSettings: e, setSelectedSettings: t, CustomOption: qo, title: "Police", icon: '<svg><path d="M5.312 14.979H7.125L8.042 12.479H11.979L12.896 14.979H14.708L10.917 5H9.083ZM8.542 10.958 9.958 6.958H10.042L11.458 10.958ZM3.417 18.333Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V3.417Q1.667 2.688 2.177 2.177Q2.688 1.667 3.417 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417V16.583Q18.333 17.312 17.823 17.823Q17.312 18.333 16.583 18.333ZM3.417 16.583H16.583Q16.583 16.583 16.583 16.583Q16.583 16.583 16.583 16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583ZM3.417 3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583V3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417Z"/></svg>', disabled: i, field: "fontFamily", values: a, defaultValue: n, valueChanged: o }) : null, _o = ({ disabled: e, toggleLayoutPanel: t }) => v(K, { title: "Toggle layers panel", disabled: e, onClick: t, icon: '<svg><path d="M10 17.646 2.438 11.75 3.875 10.646 10 15.396 16.125 10.646 17.562 11.75ZM10 13.188 2.5 7.354 10 1.521 17.5 7.354Z"/></svg>', className: "react-paint-editor-layout-button" }), jo = ({ children: e }) => Y("span", { className: "react-paint-editor-linearrow-option", "data-type": e, children: [v("span", { className: "react-paint-editor-linearrow-left" }), v("span", { className: "react-paint-editor-linearrow-right" })] }), fa = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: a, defaultValue: n, valueChanged: o }) => a.length ? v(Dt, { selectedSettings: e, setSelectedSettings: t, CustomOption: jo, title: "Flèches", icon: '<svg><path d="M6 17 2 13 6 9 7.062 10.062 4.875 12.25H17V13.75H4.875L7.062 15.938ZM14 11 12.938 9.938 15.125 7.75H3V6.25H15.125L12.938 4.062L14 3L18 7Z"/></svg>', disabled: i, field: "lineArrow", values: a, defaultValue: n, valueChanged: o }) : null, Ko = ({ children: e }) => Y("span", { className: "react-paint-editor-linetype-option", "data-type": e, children: [v("span", {}), v("span", {}), v("span", {}), v("span", {}), v("span", {}), v("span", {}), v("span", {})] }), ma = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: a, defaultValue: n, valueChanged: o }) => a.length ? v(Dt, { selectedSettings: e, setSelectedSettings: t, CustomOption: Ko, icon: '<svg><path d="M3 16V14.5H4.5V16ZM6.125 16V14.5H7.625V16ZM9.25 16V14.5H10.75V16ZM12.375 16V14.5H13.875V16ZM15.5 16V14.5H17V16ZM3 13V11.5H6.5V13ZM8.25 13V11.5H11.75V13ZM13.5 13V11.5H17V13ZM3 10V8.5H9.25V10ZM10.75 10V8.5H17V10ZM3 7V4H17V7Z"/></svg>', title: "Type de traits", disabled: i, field: "lineDash", values: a, defaultValue: n, valueChanged: o }) : null, Ct = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez l'intervalle", icon: a, disabled: n = !1, field: o, value: r, min: l = 1, max: s = 20, step: c = 1, unity: u = "", valueChanged: d }) => {
1503
+ const h = r === void 0, f = h ? "N/A" : `${Math.round(r)}${u}`, [g] = $(ye("settings_")), x = ((k, w = 500) => {
1504
+ const m = te(null), y = B((...b) => {
1505
+ m.current && clearTimeout(m.current), m.current = setTimeout(() => k(...b), w);
1506
+ }, [k, w]);
1507
+ return J(() => () => {
1508
+ m.current && clearTimeout(m.current);
1509
+ }, []), y;
1510
+ })(d), C = e === g;
1511
+ return l === s ? null : Y(Ve, { children: [v(K, { selected: C, title: i, disabled: n, icon: a, onClick: () => {
1512
+ t((k) => k === g ? void 0 : g);
1513
+ } }), C && v(tt, { title: i, alignment: "left", fitContainer: !0, children: v("div", { children: Y("label", { className: "react-paint-editor-rangefield", children: [v("input", { type: "range", min: l, max: s, step: c, value: r ?? (s + l) / 2, "data-indeterminate": +h, onChange: (k) => {
1514
+ const w = +k.target.value, m = Number.isNaN(w) ? k.target.value : w;
1515
+ d(o, m, !1), x(o, m, !0);
1516
+ } }), v("span", { children: f })] }) }) })] });
1517
+ }, Jo = ({ children: e }) => v("span", { children: e === 0 ? "Non" : "Oui" }), es = [0, 1], ya = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, defaultValue: a, valueChanged: n }) => v(Dt, { selectedSettings: e, setSelectedSettings: t, CustomOption: Jo, title: "Fermer les points", icon: ci, disabled: i, field: "closedPoints", values: es, defaultValue: a, valueChanged: n }), ts = ({ disabled: e = !1, className: t, toggleZoomPanel: i }) => v(K, { title: "Toggle zoom panel", disabled: e, onClick: i, icon: Za, className: t ? ` ${t}` : "" }), Mt = ({ setSelectedSettings: e, disabled: t = !1, field: i, icon: a, values: n, value: o = !1, valueChanged: r }) => {
1518
+ const [l] = $(ye("settings_"));
1519
+ return n.length !== 2 ? null : v(K, { onClick: () => {
1520
+ e((s) => s === l ? void 0 : l), r(i, !o);
1479
1521
  }, selected: o, disabled: t, icon: a });
1480
- }, qt = ({ activeTool: e, selectedShape: t, selectedShapeTool: i, disabled: a, selectedSettings: n, setSelectedSettings: o, handleShapeStyleChange: s, handleShapeFontFamilyChange: l }) => t ? i && B(Le, { children: ["strokeColor" in i.settings && !i.settings.strokeColor.hidden && g(xt, { selectedSettings: n, setSelectedSettings: o, title: "Couleur du trait", mode: "stroke", disabled: a, field: "strokeColor", value: t.style?.strokeColor, valueChanged: s, values: i.settings.strokeColor.values }), "fillColor" in i.settings && !i.settings.fillColor.hidden && g(xt, { selectedSettings: n, setSelectedSettings: o, title: "Couleur de fond", disabled: a, field: "fillColor", value: t.style?.fillColor, valueChanged: s, values: i.settings.fillColor.values }), "lineWidth" in i.settings && !i.settings.lineWidth.hidden && g(Ct, { selectedSettings: n, setSelectedSettings: o, title: "Epaisseur du trait", icon: bi, disabled: a, field: "lineWidth", value: t.style?.lineWidth, valueChanged: s, unity: "px", min: i.settings.lineWidth.min, max: i.settings.lineWidth.max, step: i.settings.lineWidth.step }), "lineDash" in i.settings && !i.settings.lineDash.hidden && g(la, { selectedSettings: n, setSelectedSettings: o, disabled: a, defaultValue: t.style?.lineDash, valueChanged: s, values: i.settings.lineDash.values }), "lineArrow" in i.settings && !i.settings.lineArrow.hidden && g(ra, { selectedSettings: n, setSelectedSettings: o, disabled: a, defaultValue: t.style?.lineArrow, valueChanged: s, values: i.settings.lineArrow.values }), "closedPoints" in i.settings && !i.settings.closedPoints.hidden && g(ca, { selectedSettings: n, setSelectedSettings: o, disabled: a, valueChanged: s, defaultValue: t.style?.closedPoints }), "fontFamily" in i.settings && !i.settings.fontFamily.hidden && g(sa, { selectedSettings: n, setSelectedSettings: o, disabled: a, valueChanged: l, values: i.settings.fontFamily.values, defaultValue: t.style?.fontFamily }), "fontBold" in i.settings && !i.settings.fontBold.hidden && g(Mt, { setSelectedSettings: o, disabled: a, field: "fontBold", icon: Si, valueChanged: l, values: i.settings.fontBold.values, value: t.style?.fontBold }), "fontItalic" in i.settings && !i.settings.fontItalic.hidden && g(Mt, { setSelectedSettings: o, disabled: a, field: "fontItalic", icon: Qi, valueChanged: l, values: i.settings.fontItalic.values, value: t.style?.fontItalic }), "opacity" in i.settings && !i.settings.opacity.hidden && g(Ct, { selectedSettings: n, setSelectedSettings: o, title: "Opacité", icon: yi, min: i.settings.opacity.min, max: i.settings.opacity.max, step: i.settings.opacity.step, unity: "%", disabled: a, field: "opacity", value: t.style?.opacity, valueChanged: s })] }) : "settings" in e ? B(Le, { children: ["strokeColor" in e.settings && !e.settings.strokeColor.hidden && g(xt, { selectedSettings: n, setSelectedSettings: o, title: "Couleur du trait", mode: "stroke", disabled: a, field: "strokeColor", value: e.settings.strokeColor.default, valueChanged: s, values: e.settings.strokeColor.values }), "fillColor" in e.settings && !e.settings.fillColor.hidden && g(xt, { selectedSettings: n, setSelectedSettings: o, title: "Couleur de fond", disabled: a, field: "fillColor", value: e.settings.fillColor.default, valueChanged: s, values: e.settings.fillColor.values }), "lineWidth" in e.settings && !e.settings.lineWidth.hidden && g(Ct, { selectedSettings: n, setSelectedSettings: o, title: "Epaisseur du trait", disabled: a, field: "lineWidth", icon: bi, value: e.settings.lineWidth.default, valueChanged: s, unity: "px", min: e.settings.lineWidth.min, max: e.settings.lineWidth.max, step: e.settings.lineWidth.step }), "lineDash" in e.settings && !e.settings.lineDash.hidden && g(la, { selectedSettings: n, setSelectedSettings: o, disabled: a, defaultValue: e.settings.lineDash.default, valueChanged: s, values: e.settings.lineDash.values }), "lineArrow" in e.settings && !e.settings.lineArrow.hidden && g(ra, { selectedSettings: n, setSelectedSettings: o, disabled: a, defaultValue: e.settings.lineArrow.default, valueChanged: s, values: e.settings.lineArrow.values }), "closedPoints" in e.settings && !e.settings.closedPoints.hidden && g(ca, { selectedSettings: n, setSelectedSettings: o, disabled: a, valueChanged: s, defaultValue: e.settings?.closedPoints.default }), "fontFamily" in e.settings && !e.settings.fontFamily.hidden && g(sa, { selectedSettings: n, setSelectedSettings: o, disabled: a, valueChanged: l, values: e.settings.fontFamily.values, defaultValue: e.settings.fontFamily.default }), "fontBold" in e.settings && !e.settings.fontBold.hidden && g(Mt, { setSelectedSettings: o, disabled: a, field: "fontBold", icon: Si, valueChanged: l, values: e.settings.fontBold.values, value: e.settings.fontBold.default }), "fontItalic" in e.settings && !e.settings.fontItalic.hidden && g(Mt, { setSelectedSettings: o, disabled: a, field: "fontItalic", icon: Qi, valueChanged: l, values: e.settings.fontItalic.values, value: e.settings.fontItalic.default }), "opacity" in e.settings && !e.settings.opacity.hidden && g(Ct, { selectedSettings: n, setSelectedSettings: o, title: "Opacité", icon: yi, min: e.settings.opacity.min, max: e.settings.opacity.max, step: e.settings.opacity.step, unity: "%", disabled: a, field: "opacity", value: e.settings.opacity.default, valueChanged: s })] }) : null, Ho = ({ width: e, availableTools: t, updateToolSettings: i, layersManipulation: a = !1, toggleLayoutPanel: n, activeTool: o, selectedShape: s, canvas: l, settings: r, updateShape: d, removeShape: h, isZoomPanelShown: c, setIsZoomPanelShown: u }) => {
1481
- const [f, v] = $(void 0), [b, M] = $(!1), P = r.size === "infinite" || r.features.zoom, x = !r.features.edition, y = () => {
1482
- M((T) => !T);
1483
- }, m = ((T, V) => {
1484
- const I = q(T).map((A) => V.find((R) => R.id === A?.toolId) || V.find((R) => R.type === A?.type)).filter((A) => A !== void 0);
1522
+ }, Kt = ({ activeTool: e, selectedShape: t, selectedShapeTool: i, disabled: a, selectedSettings: n, setSelectedSettings: o, handleShapeStyleChange: r, handleShapeFontFamilyChange: l }) => t ? i && Y(Ve, { children: ["strokeColor" in i.settings && !i.settings.strokeColor.hidden && v(wt, { selectedSettings: n, setSelectedSettings: o, title: "Couleur du trait", mode: "stroke", disabled: a, field: "strokeColor", value: t.style?.strokeColor, valueChanged: r, values: i.settings.strokeColor.values }), "fillColor" in i.settings && !i.settings.fillColor.hidden && v(wt, { selectedSettings: n, setSelectedSettings: o, title: "Couleur de fond", disabled: a, field: "fillColor", value: t.style?.fillColor, valueChanged: r, values: i.settings.fillColor.values }), "lineWidth" in i.settings && !i.settings.lineWidth.hidden && v(Ct, { selectedSettings: n, setSelectedSettings: o, title: "Epaisseur du trait", icon: Hi, disabled: a, field: "lineWidth", value: t.style?.lineWidth, valueChanged: r, unity: "px", min: i.settings.lineWidth.min, max: i.settings.lineWidth.max, step: i.settings.lineWidth.step }), "lineDash" in i.settings && !i.settings.lineDash.hidden && v(ma, { selectedSettings: n, setSelectedSettings: o, disabled: a, defaultValue: t.style?.lineDash, valueChanged: r, values: i.settings.lineDash.values }), "lineArrow" in i.settings && !i.settings.lineArrow.hidden && v(fa, { selectedSettings: n, setSelectedSettings: o, disabled: a, defaultValue: t.style?.lineArrow, valueChanged: r, values: i.settings.lineArrow.values }), "closedPoints" in i.settings && !i.settings.closedPoints.hidden && v(ya, { selectedSettings: n, setSelectedSettings: o, disabled: a, valueChanged: r, defaultValue: t.style?.closedPoints }), "fontFamily" in i.settings && !i.settings.fontFamily.hidden && v(va, { selectedSettings: n, setSelectedSettings: o, disabled: a, valueChanged: l, values: i.settings.fontFamily.values, defaultValue: t.style?.fontFamily }), "fontBold" in i.settings && !i.settings.fontBold.hidden && v(Mt, { setSelectedSettings: o, disabled: a, field: "fontBold", icon: Zi, valueChanged: l, values: i.settings.fontBold.values, value: t.style?.fontBold }), "fontItalic" in i.settings && !i.settings.fontItalic.hidden && v(Mt, { setSelectedSettings: o, disabled: a, field: "fontItalic", icon: Vi, valueChanged: l, values: i.settings.fontItalic.values, value: t.style?.fontItalic }), "opacity" in i.settings && !i.settings.opacity.hidden && v(Ct, { selectedSettings: n, setSelectedSettings: o, title: "Opacité", icon: Li, min: i.settings.opacity.min, max: i.settings.opacity.max, step: i.settings.opacity.step, unity: "%", disabled: a, field: "opacity", value: t.style?.opacity, valueChanged: r })] }) : "settings" in e ? Y(Ve, { children: ["strokeColor" in e.settings && !e.settings.strokeColor.hidden && v(wt, { selectedSettings: n, setSelectedSettings: o, title: "Couleur du trait", mode: "stroke", disabled: a, field: "strokeColor", value: e.settings.strokeColor.default, valueChanged: r, values: e.settings.strokeColor.values }), "fillColor" in e.settings && !e.settings.fillColor.hidden && v(wt, { selectedSettings: n, setSelectedSettings: o, title: "Couleur de fond", disabled: a, field: "fillColor", value: e.settings.fillColor.default, valueChanged: r, values: e.settings.fillColor.values }), "lineWidth" in e.settings && !e.settings.lineWidth.hidden && v(Ct, { selectedSettings: n, setSelectedSettings: o, title: "Epaisseur du trait", disabled: a, field: "lineWidth", icon: Hi, value: e.settings.lineWidth.default, valueChanged: r, unity: "px", min: e.settings.lineWidth.min, max: e.settings.lineWidth.max, step: e.settings.lineWidth.step }), "lineDash" in e.settings && !e.settings.lineDash.hidden && v(ma, { selectedSettings: n, setSelectedSettings: o, disabled: a, defaultValue: e.settings.lineDash.default, valueChanged: r, values: e.settings.lineDash.values }), "lineArrow" in e.settings && !e.settings.lineArrow.hidden && v(fa, { selectedSettings: n, setSelectedSettings: o, disabled: a, defaultValue: e.settings.lineArrow.default, valueChanged: r, values: e.settings.lineArrow.values }), "closedPoints" in e.settings && !e.settings.closedPoints.hidden && v(ya, { selectedSettings: n, setSelectedSettings: o, disabled: a, valueChanged: r, defaultValue: e.settings?.closedPoints.default }), "fontFamily" in e.settings && !e.settings.fontFamily.hidden && v(va, { selectedSettings: n, setSelectedSettings: o, disabled: a, valueChanged: l, values: e.settings.fontFamily.values, defaultValue: e.settings.fontFamily.default }), "fontBold" in e.settings && !e.settings.fontBold.hidden && v(Mt, { setSelectedSettings: o, disabled: a, field: "fontBold", icon: Zi, valueChanged: l, values: e.settings.fontBold.values, value: e.settings.fontBold.default }), "fontItalic" in e.settings && !e.settings.fontItalic.hidden && v(Mt, { setSelectedSettings: o, disabled: a, field: "fontItalic", icon: Vi, valueChanged: l, values: e.settings.fontItalic.values, value: e.settings.fontItalic.default }), "opacity" in e.settings && !e.settings.opacity.hidden && v(Ct, { selectedSettings: n, setSelectedSettings: o, title: "Opacité", icon: Li, min: e.settings.opacity.min, max: e.settings.opacity.max, step: e.settings.opacity.step, unity: "%", disabled: a, field: "opacity", value: e.settings.opacity.default, valueChanged: r })] }) : null, is = ({ width: e, availableTools: t, updateToolSettings: i, layersManipulation: a = !1, toggleLayoutPanel: n, activeTool: o, selectedShape: r, canvas: l, settings: s, updateShape: c, removeShape: u, isZoomPanelShown: d, setIsZoomPanelShown: h }) => {
1523
+ const [f, g] = $(void 0), [x, C] = $(!1), k = s.size === "infinite" || s.features.zoom, w = !s.features.edition, m = () => {
1524
+ C((S) => !S);
1525
+ }, y = ((S, V) => {
1526
+ const I = j(S).map((H) => V.find((D) => D.id === H?.toolId) || V.find((D) => D.type === H?.type)).filter((H) => H !== void 0);
1485
1527
  if (!I.length) return;
1486
1528
  if (I.length === 1) return I[0];
1487
- const W = I.slice(1).reduce((A, R) => {
1488
- const _ = {};
1489
- for (const U in R.settings) {
1490
- if (A[U] === void 0 || R.settings[U]?.hidden || A[U]?.hidden) continue;
1491
- const C = A[U], p = R.settings[U], w = {};
1492
- "min" in p && "min" in C && p.min === C.min && "max" in p && "max" in C && p.max === C.max && "step" in p && "step" in C && p.step === C.step && (w.min = p.min, w.max = p.max, w.step = p.step), "values" in p && "values" in C && p.values?.join(",") === C.values?.join(",") && (w.values = p.values), (Object.keys(w).length > 0 || U === "closedPoints") && (_[U] = w);
1529
+ const N = I.slice(1).reduce((H, D) => {
1530
+ const U = {};
1531
+ for (const F in D.settings) {
1532
+ if (H[F] === void 0 || D.settings[F]?.hidden || H[F]?.hidden) continue;
1533
+ const X = H[F], p = D.settings[F], Q = {};
1534
+ "min" in p && "min" in X && p.min === X.min && "max" in p && "max" in X && p.max === X.max && "step" in p && "step" in X && p.step === X.step && (Q.min = p.min, Q.max = p.max, Q.step = p.step), "values" in p && "values" in X && p.values?.join(",") === X.values?.join(",") && (Q.values = p.values), (Object.keys(Q).length > 0 || F === "closedPoints") && (U[F] = Q);
1493
1535
  }
1494
- return _;
1536
+ return U;
1495
1537
  }, I[0].settings);
1496
- return { id: I.map((A) => A.id).join("-"), icon: "", label: "group", type: "group", settings: W };
1497
- })(s, t), S = (m ? Object.keys(m.settings).length + 1 : "settings" in o ? Object.keys(o.settings).length : 0) + +a + +P, E = e < 40 * S, H = (T, V, I = !0) => {
1498
- if (q(s).length) {
1499
- const W = q(s).map((A) => st(Ce(["style", T], V, A), r));
1500
- d(W, I), m && i(m.id, T, V);
1501
- } else i(o.id, T, V);
1502
- }, z = (T, V) => {
1503
- if (q(s).length) {
1504
- const I = q(s).map((W) => {
1505
- if (W.type !== "text") return W;
1506
- const A = l?.getContext("2d");
1507
- if (!A) return W;
1508
- const R = Ce(["style", T], V, W), _ = di(A, R.value, R.width, R.style?.fontBold ?? !1, R.style?.fontItalic ?? !1, R.style?.fontFamily);
1509
- return st({ ...R, fontSize: _, height: _ * R.value.length }, r);
1538
+ return { id: I.map((H) => H.id).join("-"), icon: "", label: "group", type: "group", settings: N };
1539
+ })(r, t), b = (y ? Object.keys(y.settings).length + 1 : "settings" in o ? Object.keys(o.settings).length : 0) + +a + +k, Z = e < 40 * b, A = (S, V, I = !0) => {
1540
+ if (j(r).length) {
1541
+ const N = j(r).map((H) => dt(Pe(["style", S], V, H), s));
1542
+ c(N, I), y && i(y.id, S, V);
1543
+ } else i(o.id, S, V);
1544
+ }, T = (S, V) => {
1545
+ if (j(r).length) {
1546
+ const I = j(r).map((N) => {
1547
+ if (N.type !== "text") return N;
1548
+ const H = l?.getContext("2d");
1549
+ if (!H) return N;
1550
+ const D = Pe(["style", S], V, N), U = Si(H, D.value, D.width, D.style?.fontBold ?? !1, D.style?.fontItalic ?? !1, D.style?.fontFamily);
1551
+ return dt({ ...D, fontSize: U, height: U * D.value.length }, s);
1510
1552
  });
1511
- d(I, !0), m && i(m.id, T, V);
1512
- } else i(o.id, T, V);
1553
+ c(I, !0), y && i(y.id, S, V);
1554
+ } else i(o.id, S, V);
1513
1555
  };
1514
- return B(Le, { children: [B("div", { className: "react-paint-editor-settings-bar", children: [B("div", { className: "react-paint-editor-settings-shrinkable", children: [P && g(Zo, { className: c ? "react-paint-editor-bar-zoom-button-opened" : void 0, toggleZoomPanel: () => {
1515
- u((T) => !T);
1516
- } }), E && S > 2 && g(J, { disabled: x, onClick: y, title: "Toggle settings", icon: '<svg><path d="M2.5 15.833V14.083H7.667V15.833ZM2.5 5.917V4.167H10.771V5.917ZM9.208 17.5V12.438H10.958V14.083H17.5V15.833H10.958V17.5ZM5.917 12.542V10.875H2.5V9.125H5.917V7.479H7.667V12.542ZM9.208 10.875V9.125H17.5V10.875ZM12.333 7.562V2.5H14.083V4.167H17.5V5.917H14.083V7.562Z"/></svg>' }), s ? m && B(Le, { children: [!E && g(qt, { activeTool: o, selectedShape: s, selectedShapeTool: m, disabled: x, selectedSettings: f, setSelectedSettings: v, handleShapeStyleChange: H, handleShapeFontFamilyChange: z }), o.type === "selection" && g(xo, { disabled: x, selectedShape: s, removeShape: h })] }) : !E && g(qt, { activeTool: o, selectedShape: s, selectedShapeTool: m, disabled: x, selectedSettings: f, setSelectedSettings: v, handleShapeStyleChange: H, handleShapeFontFamilyChange: z })] }), g("div", { className: "react-paint-editor-settings-separator" }), a && g(Mo, { disabled: x, toggleLayoutPanel: n })] }), b && g(Dt, { className: "react-paint-editor-settings-modal", onClose: y, position: "bottom", title: "Settings", children: g(qt, { activeTool: o, selectedShape: s, selectedShapeTool: m, disabled: x, selectedSettings: f, setSelectedSettings: v, handleShapeStyleChange: H, handleShapeFontFamilyChange: z }) })] });
1517
- }, da = ({ disabled: e = !1, withText: t = !1, loadFile: i, type: a, img: n, accept: o }) => {
1518
- const s = ae(null);
1519
- return g(J, { ref: s, type: "file", onClick: (l) => {
1520
- l.stopPropagation(), s.current && (s.current.value = "");
1556
+ return Y(Ve, { children: [Y("div", { className: "react-paint-editor-settings-bar", children: [Y("div", { className: "react-paint-editor-settings-shrinkable", children: [k && v(ts, { className: d ? "react-paint-editor-bar-zoom-button-opened" : void 0, toggleZoomPanel: () => {
1557
+ h((S) => !S);
1558
+ } }), Z && b > 2 && v(K, { disabled: w, onClick: m, title: "Toggle settings", icon: '<svg><path d="M2.5 15.833V14.083H7.667V15.833ZM2.5 5.917V4.167H10.771V5.917ZM9.208 17.5V12.438H10.958V14.083H17.5V15.833H10.958V17.5ZM5.917 12.542V10.875H2.5V9.125H5.917V7.479H7.667V12.542ZM9.208 10.875V9.125H17.5V10.875ZM12.333 7.562V2.5H14.083V4.167H17.5V5.917H14.083V7.562Z"/></svg>' }), r ? y && Y(Ve, { children: [!Z && v(Kt, { activeTool: o, selectedShape: r, selectedShapeTool: y, disabled: w, selectedSettings: f, setSelectedSettings: g, handleShapeStyleChange: A, handleShapeFontFamilyChange: T }), o.type === "selection" && v(Go, { disabled: w, selectedShape: r, removeShape: u })] }) : !Z && v(Kt, { activeTool: o, selectedShape: r, selectedShapeTool: y, disabled: w, selectedSettings: f, setSelectedSettings: g, handleShapeStyleChange: A, handleShapeFontFamilyChange: T })] }), v("div", { className: "react-paint-editor-settings-separator" }), a && v(_o, { disabled: w, toggleLayoutPanel: n })] }), x && v(Nt, { className: "react-paint-editor-settings-modal", onClose: m, position: "bottom", title: "Settings", children: v(Kt, { activeTool: o, selectedShape: r, selectedShapeTool: y, disabled: w, selectedSettings: f, setSelectedSettings: g, handleShapeStyleChange: A, handleShapeFontFamilyChange: T }) })] });
1559
+ }, Sa = ({ disabled: e = !1, withText: t = !1, loadFile: i, type: a, img: n, accept: o }) => {
1560
+ const r = te(null);
1561
+ return v(K, { ref: r, type: "file", onClick: (l) => {
1562
+ l.stopPropagation(), r.current && (r.current.value = "");
1521
1563
  }, onChange: (l) => {
1522
- const r = l.target.files?.item(0);
1523
- r && i(r);
1564
+ const s = l.target.files?.item(0);
1565
+ s && i(s);
1524
1566
  }, accept: o, title: a.label ?? a.type, icon: n, disabled: e, children: t ? a.label : void 0 });
1525
- }, xe = ({ type: e, img: t, isActive: i, withText: a = !1, disabled: n = !1, setActive: o }) => g(J, { disabled: n, selected: i, onClick: () => {
1567
+ }, ke = ({ type: e, img: t, isActive: i, withText: a = !1, disabled: n = !1, setActive: o }) => v(K, { disabled: n, selected: i, onClick: () => {
1526
1568
  o(e);
1527
- }, title: e.label ?? e.type, icon: t, children: a ? e.label : void 0 }), To = ({ activeTool: e, withActionsInMenu: t, hasActionToUndo: i = !1, hasActionToRedo: a = !1, hasActionToClear: n = !1, undoAction: o, redoAction: s, clearCanvas: l, alignment: r, group: d, vertical: h = !1, disabled: c = !1, withLoadAndSave: u, withExport: f, addPicture: v, loadFile: b, togglePictureUrlModal: M, saveFile: P, toggleExportModal: x, withUploadPicture: y, withUrlPicture: m }) => {
1528
- const [S, E] = $(!1), [, H] = ga(), z = d?.tools?.some((V) => V === e.type), T = (z ? e.icon : d.img) ?? d.title;
1529
- return K(() => {
1530
- if (!S) return;
1569
+ }, title: e.label ?? e.type, icon: t, children: a ? e.label : void 0 }), as = ({ activeTool: e, withActionsInMenu: t, hasActionToUndo: i = !1, hasActionToRedo: a = !1, hasActionToClear: n = !1, undoAction: o, redoAction: r, clearCanvas: l, alignment: s, group: c, vertical: u = !1, disabled: d = !1, withLoadAndSave: h, withExport: f, addPicture: g, loadFile: x, togglePictureUrlModal: C, saveFile: k, toggleExportModal: w, withUploadPicture: m, withUrlPicture: y }) => {
1570
+ const [b, Z] = $(!1), [, A] = wa(), T = c?.tools?.some((V) => V === e.type), S = (T ? e.icon : c.img) ?? c.title;
1571
+ return J(() => {
1572
+ if (!b) return;
1531
1573
  const V = () => {
1532
- E(!1);
1574
+ Z(!1);
1533
1575
  };
1534
1576
  return document.addEventListener("click", V), () => {
1535
1577
  document.removeEventListener("click", V);
1536
1578
  };
1537
- }, [S]), t || y || m || u || f ? B("div", { className: "react-paint-editor-toolbox-relative", children: [g(J, { selected: z, title: d.title, disabled: c, onClick: () => {
1538
- H(() => {
1539
- E(!0);
1579
+ }, [b]), t || m || y || h || f ? Y("div", { className: "react-paint-editor-toolbox-relative", children: [v(K, { selected: T, title: c.title, disabled: d, onClick: () => {
1580
+ A(() => {
1581
+ Z(!0);
1540
1582
  });
1541
- }, icon: T }), S && g(Ke, { alignment: r, position: "top", children: B("div", { className: "react-paint-editor-toolbox-panel-content", "data-vertical": +h, children: [t && B(Le, { children: [g(xe, { withText: !0, type: at, disabled: c || !i, img: at.icon, isActive: e.id === at.id, setActive: o }), g(xe, { withText: !0, type: nt, disabled: c || !a, img: nt.icon, isActive: e.id === nt.id, setActive: s }), g(xe, { withText: !0, type: ot, disabled: c || !n, img: ot.icon, isActive: e.id === ot.id, setActive: l }), (y || m || u) && g("hr", {})] }), y && g(da, { withText: !0, type: ki, disabled: c, loadFile: async (V) => {
1542
- E(!1), await v(V);
1543
- }, img: ki.icon, accept: "image/png, image/gif, image/jpeg, image/svg+xml, image/webp" }), m && g(J, { disabled: c, selected: !1, onClick: M, title: "Add picture from URL", icon: '<svg><path d="M9.188 16.542V14.938Q8.5 14.938 8.021 14.458Q7.542 13.979 7.542 13.292V12.458L3.583 8.5Q3.5 8.875 3.458 9.25Q3.417 9.625 3.417 10Q3.417 12.5 5.062 14.365Q6.708 16.229 9.188 16.542ZM14.854 14.438Q15.708 13.521 16.146 12.385Q16.583 11.25 16.583 10Q16.583 7.979 15.469 6.313Q14.354 4.646 12.479 3.917V4.229Q12.479 4.917 12 5.396Q11.521 5.875 10.833 5.875H9.188V7.521Q9.188 7.875 8.948 8.115Q8.708 8.354 8.354 8.354H6.708V10H11.646Q12 10 12.24 10.229Q12.479 10.458 12.479 10.812V13.292H13.292Q13.833 13.292 14.26 13.604Q14.688 13.917 14.854 14.438ZM10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.271 2.323 6.75Q2.979 5.229 4.104 4.104Q5.229 2.979 6.75 2.323Q8.271 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.729 17.677 13.25Q17.021 14.771 15.896 15.896Q14.771 17.021 13.25 17.677Q11.729 18.333 10 18.333Z"/></svg>', children: "Add picture from URL" }), (y || m) && u && g("hr", {}), u && B(Le, { children: [g(da, { withText: !0, type: Mi, disabled: c, loadFile: (V) => {
1544
- E(!1), b(V);
1545
- }, img: Mi.icon, accept: "application/JSON" }), g(xe, { withText: !0, disabled: c, type: Bt, img: Bt.icon, isActive: e.id === Bt.id, setActive: P })] }), f && g(xe, { withText: !0, disabled: c, type: Ft, img: Ft.icon, isActive: e.id === Ft.id, setActive: x })] }) })] }) : null;
1546
- }, zo = ({ togglePictureUrlModal: e, addPicture: t }) => {
1547
- const i = ae(null);
1548
- return K(() => {
1583
+ }, icon: S }), b && v(tt, { alignment: s, position: "top", children: Y("div", { className: "react-paint-editor-toolbox-panel-content", "data-vertical": +u, children: [t && Y(Ve, { children: [v(ke, { withText: !0, type: rt, disabled: d || !i, img: rt.icon, isActive: e.id === rt.id, setActive: o }), v(ke, { withText: !0, type: lt, disabled: d || !a, img: lt.icon, isActive: e.id === lt.id, setActive: r }), v(ke, { withText: !0, type: ct, disabled: d || !n, img: ct.icon, isActive: e.id === ct.id, setActive: l }), (m || y || h) && v("hr", {})] }), m && v(Sa, { withText: !0, type: Ii, disabled: d, loadFile: async (V) => {
1584
+ Z(!1), await g(V);
1585
+ }, img: Ii.icon, accept: "image/png, image/gif, image/jpeg, image/svg+xml, image/webp" }), y && v(K, { disabled: d, selected: !1, onClick: C, title: "Add picture from URL", icon: '<svg><path d="M9.188 16.542V14.938Q8.5 14.938 8.021 14.458Q7.542 13.979 7.542 13.292V12.458L3.583 8.5Q3.5 8.875 3.458 9.25Q3.417 9.625 3.417 10Q3.417 12.5 5.062 14.365Q6.708 16.229 9.188 16.542ZM14.854 14.438Q15.708 13.521 16.146 12.385Q16.583 11.25 16.583 10Q16.583 7.979 15.469 6.313Q14.354 4.646 12.479 3.917V4.229Q12.479 4.917 12 5.396Q11.521 5.875 10.833 5.875H9.188V7.521Q9.188 7.875 8.948 8.115Q8.708 8.354 8.354 8.354H6.708V10H11.646Q12 10 12.24 10.229Q12.479 10.458 12.479 10.812V13.292H13.292Q13.833 13.292 14.26 13.604Q14.688 13.917 14.854 14.438ZM10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.271 2.323 6.75Q2.979 5.229 4.104 4.104Q5.229 2.979 6.75 2.323Q8.271 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.729 17.677 13.25Q17.021 14.771 15.896 15.896Q14.771 17.021 13.25 17.677Q11.729 18.333 10 18.333Z"/></svg>', children: "Add picture from URL" }), (m || y) && h && v("hr", {}), h && Y(Ve, { children: [v(Sa, { withText: !0, type: Ei, disabled: d, loadFile: (V) => {
1586
+ Z(!1), x(V);
1587
+ }, img: Ei.icon, accept: "application/JSON" }), v(ke, { withText: !0, disabled: d, type: Ut, img: Ut.icon, isActive: e.id === Ut.id, setActive: k })] }), f && v(ke, { withText: !0, disabled: d, type: Yt, img: Yt.icon, isActive: e.id === Yt.id, setActive: w })] }) })] }) : null;
1588
+ }, ns = ({ togglePictureUrlModal: e, addPicture: t }) => {
1589
+ const i = te(null);
1590
+ return J(() => {
1549
1591
  i.current && i.current.focus();
1550
- }, []), g(Dt, { className: "react-paint-editor-toolbox-pictureinput-modal", onClose: e, title: "Add picture from URL", children: B("form", { onSubmit: async (a) => {
1592
+ }, []), v(Nt, { className: "react-paint-editor-toolbox-pictureinput-modal", onClose: e, title: "Add picture from URL", children: Y("form", { onSubmit: async (a) => {
1551
1593
  a.preventDefault();
1552
1594
  const n = i.current?.value;
1553
1595
  n && (await t(n), e());
1554
- }, children: [B("label", { children: ["URL ", g("input", { type: "text", ref: i })] }), g(J, { onClick: e, children: "Annuler" }), g(J, { type: "submit", selected: !0, children: "Ajouter" })] }) });
1555
- }, ha = "Choose export settings", Ao = ({ toggleExportModal: e, exportCanvasInFile: t }) => {
1596
+ }, children: [Y("label", { children: ["URL ", v("input", { type: "text", ref: i })] }), v(K, { onClick: e, children: "Annuler" }), v(K, { type: "submit", selected: !0, children: "Ajouter" })] }) });
1597
+ }, Qa = "Choose export settings", os = ({ toggleExportModal: e, exportCanvasInFile: t }) => {
1556
1598
  const i = async (a) => {
1557
1599
  t(a), e();
1558
1600
  };
1559
- return B(Dt, { className: "react-paint-editor-toolbox-export-modal", onClose: e, title: ha, children: [g("h3", { children: ha }), g("hr", {}), g(J, { onClick: () => i("currentZoom"), children: "Exporter la vue actuelle" }), g(J, { onClick: () => i("defaultView"), children: "Exporter le canvas entier" }), g(J, { onClick: () => i("fitToShapes"), children: "Exporter dans les limites du dessin" }), g(J, { selected: !0, onClick: e, children: "Annuler" })] });
1560
- }, Eo = ({ activeTool: e, alignment: t, group: i, disabled: a = !1, setActiveToolFromId: n }) => {
1561
- const o = ae(null), [s, l] = $(!1), [, r] = ga(), [d, h] = $(void 0), c = (v) => {
1562
- h(v), n(v.id);
1601
+ return Y(Nt, { className: "react-paint-editor-toolbox-export-modal", onClose: e, title: Qa, children: [v("h3", { children: Qa }), v("hr", {}), v(K, { onClick: () => i("currentZoom"), children: "Exporter la vue actuelle" }), v(K, { onClick: () => i("defaultView"), children: "Exporter le canevas par défaut" }), v(K, { onClick: () => i("fitToShapes"), children: "Exporter le dessin entier" }), v(K, { selected: !0, onClick: e, children: "Annuler" })] });
1602
+ }, ss = ({ activeTool: e, alignment: t, group: i, disabled: a = !1, setActiveToolFromId: n }) => {
1603
+ const o = te(null), [r, l] = $(!1), [, s] = wa(), [c, u] = $(void 0), d = (g) => {
1604
+ u(g), n(g.id);
1563
1605
  };
1564
- if (K(() => {
1565
- if (!s) return;
1566
- const v = (b) => {
1567
- !Wa(b, o.current) && l(!1);
1606
+ if (J(() => {
1607
+ if (!r) return;
1608
+ const g = (x) => {
1609
+ !((k, w) => !!(k.target instanceof Node && w) && w.contains(k.target))(x, o.current) && l(!1);
1568
1610
  };
1569
- return document.addEventListener("mousedown", v, { passive: !1 }), document.addEventListener("touchstart", v, { passive: !1 }), () => {
1570
- document.removeEventListener("mousedown", v), document.removeEventListener("touchstart", v);
1611
+ return document.addEventListener("mousedown", g, { passive: !1 }), document.addEventListener("touchstart", g, { passive: !1 }), () => {
1612
+ document.removeEventListener("mousedown", g), document.removeEventListener("touchstart", g);
1571
1613
  };
1572
- }, [s]), "type" in i) return g(xe, { disabled: a, type: i, img: i.icon, isActive: e.id === i.id, setActive: c });
1614
+ }, [r]), "type" in i) return v(ke, { disabled: a, type: i, img: i.icon, isActive: e.id === i.id, setActive: d });
1573
1615
  if (!i.toolsType.length) return null;
1574
- if (i.toolsType?.length === 1) return g(xe, { disabled: a, type: i.toolsType[0], img: i.toolsType[0].icon, isActive: e.id === i.toolsType[0].id, setActive: c });
1575
- const u = i?.toolsType.find((v) => v.type === e.type) !== void 0, f = (d ? d.icon : i.toolsType?.[0]?.icon) ?? i.title;
1576
- return B("div", { className: "react-paint-editor-toolbargroup-relative", children: [g(J, { selected: u, title: i.title, disabled: a, onClick: () => {
1577
- d ? n(d.id) : i.toolsType?.[0] && c(i.toolsType[0]), r(() => {
1616
+ if (i.toolsType?.length === 1) return v(ke, { disabled: a, type: i.toolsType[0], img: i.toolsType[0].icon, isActive: e.id === i.toolsType[0].id, setActive: d });
1617
+ const h = i?.toolsType.find((g) => g.type === e.type) !== void 0, f = (c ? c.icon : i.toolsType?.[0]?.icon) ?? i.title;
1618
+ return Y("div", { className: "react-paint-editor-toolbargroup-relative", children: [v(K, { selected: h, title: i.title, disabled: a, onClick: () => {
1619
+ c ? n(c.id) : i.toolsType?.[0] && d(i.toolsType[0]), s(() => {
1578
1620
  l(!0);
1579
1621
  });
1580
- }, icon: f }), s && g(Ke, { alignment: t, position: "top", children: g("div", { className: "react-paint-editor-toolbargroup-panel-content", "data-vertical": +i.vertical, ref: o, children: i.toolsType.map((v) => g(xe, { disabled: a, type: v, img: v.icon, isActive: e.id === v.id, setActive: c }, v.id)) }) })] });
1581
- }, Do = [{ title: "brush", toolsType: ["brush"], vertical: !1 }, { title: "lines", toolsType: ["line", "curve", "polygon"], vertical: !1 }, { title: "shapes", toolsType: ["rect", "square", "circle", "ellipse"], vertical: !1 }, "text"], No = ({ settings: e, width: t, activeTool: i, hasActionToUndo: a = !1, hasActionToRedo: n = !1, hasActionToClear: o = !1, withLoadAndSave: s, withExport: l, clearCanvas: r, setActiveTool: d, undoAction: h, redoAction: c, addPicture: u, loadFile: f, saveFile: v, exportCanvasInFile: b, availableTools: M, withUrlPicture: P, withUploadPicture: x }) => {
1582
- const y = ((p, w) => {
1583
- const Q = w.flatMap((L) => {
1584
- if (typeof L != "object") return p.filter((D) => D.type === L);
1585
- const k = p.filter((D) => L.toolsType.includes(D.type));
1586
- return k ? { ...L, toolsType: k } : null;
1622
+ }, icon: f }), r && v(tt, { alignment: t, position: "top", children: v("div", { className: "react-paint-editor-toolbargroup-panel-content", "data-vertical": +i.vertical, ref: o, children: i.toolsType.map((g) => v(ke, { disabled: a, type: g, img: g.icon, isActive: e.id === g.id, setActive: d }, g.id)) }) })] });
1623
+ }, rs = [{ title: "brush", toolsType: ["brush"], vertical: !1 }, { title: "lines", toolsType: ["line", "curve", "polygon"], vertical: !1 }, { title: "shapes", toolsType: ["rect", "square", "circle", "ellipse"], vertical: !1 }, "text"], ls = ({ settings: e, width: t, activeTool: i, hasActionToUndo: a = !1, hasActionToRedo: n = !1, hasActionToClear: o = !1, withLoadAndSave: r, withExport: l, clearCanvas: s, setActiveTool: c, undoAction: u, redoAction: d, addPicture: h, loadFile: f, saveFile: g, exportCanvasInFile: x, availableTools: C, withUrlPicture: k, withUploadPicture: w }) => {
1624
+ const m = ((p, Q) => {
1625
+ const M = Q.flatMap((L) => {
1626
+ if (typeof L != "object") return p.filter((E) => E.type === L);
1627
+ const P = p.filter((E) => L.toolsType.includes(E.type));
1628
+ return P ? { ...L, toolsType: P } : null;
1587
1629
  });
1588
- return hi(Q);
1589
- })(M, Do), m = !e.features.edition, S = t < 40 * (6 + y.length), E = t < 40 * (3 + y.length), [H, z] = $(!1), [T, V] = $(!1), [I, W] = $(!1), A = () => {
1590
- z((p) => !p);
1591
- }, R = () => {
1592
- W((p) => !p);
1593
- }, _ = (p) => {
1594
- d(p), z(!1);
1630
+ return Qi(M);
1631
+ })(C, rs), y = !e.features.edition, b = t < 40 * (6 + m.length), Z = t < 40 * (3 + m.length), [A, T] = $(!1), [S, V] = $(!1), [I, N] = $(!1), H = () => {
1632
+ T((p) => !p);
1633
+ }, D = () => {
1634
+ N((p) => !p);
1595
1635
  }, U = (p) => {
1596
- _(M.find((w) => w.id === p) ?? i);
1597
- }, C = M.find((p) => p.type === i.type) !== void 0;
1598
- return B(Le, { children: [B("div", { className: "react-paint-editor-toolbar-toolbox", style: { "--react-paint-editor-toolbar-minwidth": "160px" }, children: [B("div", { className: "react-paint-editor-toolbar-shrinkable", children: [g(xe, { type: Be, disabled: m, img: Be.icon, isActive: i.id === Be.id, setActive: _ }), (e.size === "infinite" || e.features.zoom) && g(xe, { type: $t, disabled: m, img: $t.icon, isActive: i.id === $t.id, setActive: _ }), E ? g(J, { disabled: m, onClick: A, title: "Toggle tools", icon: '<svg><path d="M5.333 9.292 10.021 1.646 14.708 9.292ZM14.562 18.333Q13 18.333 11.896 17.229Q10.792 16.125 10.792 14.562Q10.792 13 11.896 11.896Q13 10.792 14.562 10.792Q16.125 10.792 17.229 11.896Q18.333 13 18.333 14.562Q18.333 16.125 17.229 17.229Q16.125 18.333 14.562 18.333ZM2.5 17.917V11.188H9.229V17.917ZM14.562 16.583Q15.438 16.583 16.01 16.01Q16.583 15.438 16.583 14.562Q16.583 13.688 16.01 13.115Q15.438 12.542 14.562 12.542Q13.688 12.542 13.115 13.115Q12.542 13.688 12.542 14.562Q12.542 15.438 13.115 16.01Q13.688 16.583 14.562 16.583ZM4.25 16.167H7.479V12.938H4.25ZM8.458 7.542H11.583L10.021 5ZM10.021 7.542ZM7.479 12.938ZM14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Z"/></svg>', selected: C }) : y.map((p) => g(Eo, { disabled: m, activeTool: i, group: p, setActiveToolFromId: U }, "id" in p ? p.id : p.title))] }), !S && B(Le, { children: [g(xe, { type: at, disabled: m || !a, img: at.icon, isActive: i.id === at.id, setActive: h }), g(xe, { type: nt, disabled: m || !n, img: nt.icon, isActive: i.id === nt.id, setActive: c }), g(xe, { type: ot, disabled: m || !o, img: ot.icon, isActive: i.id === ot.id, setActive: r })] }), g(To, { withActionsInMenu: S, disabled: m, vertical: !0, alignment: "right", group: { title: "Menu", img: '<svg><path d="M2.5 15V13.25H17.5V15ZM2.5 10.875V9.125H17.5V10.875ZM2.5 6.75V5H17.5V6.75Z"/></svg>' }, activeTool: i, addPicture: u, loadFile: f, saveFile: v, togglePictureUrlModal: () => {
1636
+ c(p), T(!1);
1637
+ }, F = (p) => {
1638
+ U(C.find((Q) => Q.id === p) ?? i);
1639
+ }, X = C.find((p) => p.type === i.type) !== void 0;
1640
+ return Y(Ve, { children: [Y("div", { className: "react-paint-editor-toolbar-toolbox", style: { "--react-paint-editor-toolbar-minwidth": "160px" }, children: [Y("div", { className: "react-paint-editor-toolbar-shrinkable", children: [v(ke, { type: Fe, disabled: y, img: Fe.icon, isActive: i.id === Fe.id, setActive: U }), (e.size === "infinite" || e.features.zoom) && v(ke, { type: Xt, disabled: y, img: Xt.icon, isActive: i.id === Xt.id, setActive: U }), Z ? v(K, { disabled: y, onClick: H, title: "Toggle tools", icon: '<svg><path d="M5.333 9.292 10.021 1.646 14.708 9.292ZM14.562 18.333Q13 18.333 11.896 17.229Q10.792 16.125 10.792 14.562Q10.792 13 11.896 11.896Q13 10.792 14.562 10.792Q16.125 10.792 17.229 11.896Q18.333 13 18.333 14.562Q18.333 16.125 17.229 17.229Q16.125 18.333 14.562 18.333ZM2.5 17.917V11.188H9.229V17.917ZM14.562 16.583Q15.438 16.583 16.01 16.01Q16.583 15.438 16.583 14.562Q16.583 13.688 16.01 13.115Q15.438 12.542 14.562 12.542Q13.688 12.542 13.115 13.115Q12.542 13.688 12.542 14.562Q12.542 15.438 13.115 16.01Q13.688 16.583 14.562 16.583ZM4.25 16.167H7.479V12.938H4.25ZM8.458 7.542H11.583L10.021 5ZM10.021 7.542ZM7.479 12.938ZM14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Z"/></svg>', selected: X }) : m.map((p) => v(ss, { disabled: y, activeTool: i, group: p, setActiveToolFromId: F }, "id" in p ? p.id : p.title))] }), !b && Y(Ve, { children: [v(ke, { type: rt, disabled: y || !a, img: rt.icon, isActive: i.id === rt.id, setActive: u }), v(ke, { type: lt, disabled: y || !n, img: lt.icon, isActive: i.id === lt.id, setActive: d }), v(ke, { type: ct, disabled: y || !o, img: ct.icon, isActive: i.id === ct.id, setActive: s })] }), v(as, { withActionsInMenu: b, disabled: y, vertical: !0, alignment: "right", group: { title: "Menu", img: '<svg><path d="M2.5 15V13.25H17.5V15ZM2.5 10.875V9.125H17.5V10.875ZM2.5 6.75V5H17.5V6.75Z"/></svg>' }, activeTool: i, addPicture: h, loadFile: f, saveFile: g, togglePictureUrlModal: () => {
1599
1641
  V(!0);
1600
- }, toggleExportModal: R, withUploadPicture: x, withUrlPicture: P, withLoadAndSave: s, withExport: l, hasActionToUndo: a, hasActionToRedo: n, hasActionToClear: o, undoAction: h, redoAction: c, clearCanvas: r })] }), H && g(Dt, { className: "react-paint-editor-toolbar-modal", onClose: A, title: "Outils", children: M.map((p) => p.type === "picture" ? null : g(xe, { disabled: m, type: p, img: p.icon, withText: !1, isActive: i.id === p.id, setActive: _ }, p.id)) }), T && g(zo, { togglePictureUrlModal: () => {
1642
+ }, toggleExportModal: D, withUploadPicture: w, withUrlPicture: k, withLoadAndSave: r, withExport: l, hasActionToUndo: a, hasActionToRedo: n, hasActionToClear: o, undoAction: u, redoAction: d, clearCanvas: s })] }), A && v(Nt, { className: "react-paint-editor-toolbar-modal", onClose: H, title: "Outils", children: C.map((p) => p.type === "picture" ? null : v(ke, { disabled: y, type: p, img: p.icon, withText: !1, isActive: i.id === p.id, setActive: U }, p.id)) }), S && v(ns, { togglePictureUrlModal: () => {
1601
1643
  V((p) => !p);
1602
- }, addPicture: u }), I && g(Ao, { toggleExportModal: R, exportCanvasInFile: b })] });
1603
- }, kt = { none: 0, small: 10, medium: 20, large: 40 }, Wo = { toolbarBackgroundColor: "white", dividerColor: "#36418129", fontRadius: 8, fontDisabledColor: "#3641812b", fontDisabledBackgroundColor: "transparent", fontColor: "#364181", fontBackgroundColor: "transparent", fontSelectedColor: "white", fontSelectedBackgroundColor: "#364181", fontHoverColor: "#364181", fontHoverBackgroundColor: "#afd8d8" }, Io = () => {
1604
- const e = ae([]), [t, i] = $([]);
1605
- return K(() => () => {
1644
+ }, addPicture: h }), I && v(os, { toggleExportModal: D, exportCanvasInFile: x })] });
1645
+ }, kt = { none: 0, small: 10, medium: 20, large: 40 }, cs = { toolbarBackgroundColor: "white", dividerColor: "#36418129", fontRadius: 8, fontDisabledColor: "#3641812b", fontDisabledBackgroundColor: "transparent", fontColor: "#364181", fontBackgroundColor: "transparent", fontSelectedColor: "white", fontSelectedBackgroundColor: "#364181", fontHoverColor: "#364181", fontHoverBackgroundColor: "#afd8d8" }, ds = () => {
1646
+ const e = te([]), [t, i] = $([]);
1647
+ return J(() => () => {
1606
1648
  for (const a of e.current) clearTimeout(a);
1607
- }, []), { snackbarList: t, addSnackbar: ({ type: a = fo, duration: n = mo, text: o }) => {
1608
- const s = { id: me("snackbar_"), duration: n, type: a, text: o };
1609
- i((l) => [...l, s]), e.current = [...e.current, setTimeout(() => {
1610
- return l = s.id, void i((r) => r.filter((d) => d.id !== l));
1649
+ }, []), { snackbarList: t, addSnackbar: ({ type: a = Wo, duration: n = Oo, text: o }) => {
1650
+ const r = { id: ye("snackbar_"), duration: n, type: a, text: o };
1651
+ i((l) => [...l, r]), e.current = [...e.current, setTimeout(() => {
1652
+ return l = r.id, void i((s) => s.filter((c) => c.id !== l));
1611
1653
  var l;
1612
1654
  }, n)];
1613
1655
  } };
1614
- }, $o = ({ editorProps: e, className: t, style: i, options: a, children: n }) => {
1615
- const { shapesRef: o, addPictureShape: s, moveShapes: l, toggleShapeVisibility: r, toggleShapeLock: d, canGoBackward: h, canGoForward: c, canClear: u, selectedShape: f, removeShape: v, updateShape: b, backwardShape: M, forwardShape: P, refs: x, width: y, height: m, selectTool: S, selectShapes: E, activeTool: H, setActiveTool: z, setAvailableTools: T, isEditMode: V, availableTools: I, gridGap: W, setGridGap: A, loadFile: R, exportPicture: _, exportData: U, clearCanvas: C, settings: p, setCanvasZoom: w, canvas: { canGrow: Q, layersManipulation: L, withExport: k, withLoadAndSave: D, withUploadPicture: Z, withUrlPicture: X } } = e, { toolbarBackgroundColor: O, dividerColor: de, fontRadius: N, fontDisabledColor: oe, fontDisabledBackgroundColor: G, fontColor: le, fontBackgroundColor: j, fontSelectedColor: se, fontSelectedBackgroundColor: ne, fontHoverColor: Qe, fontHoverBackgroundColor: te } = { ...Wo, ...a }, ue = p.size === "infinite" || p.features.zoom, [Te, ve] = $(!1), [fe, Ne] = $(!1), [Ye, be] = $(ue), Pe = ue && Ye, We = W >= kt.large ? "large" : W >= kt.medium ? "medium" : W >= kt.small ? "small" : "none", { snackbarList: Ie, addSnackbar: re } = Io(), Xe = F((he, pe, Qt) => {
1616
- T((Ge) => Ge.map((ht) => ht.id === he ? Ce(["settings", pe, "default"], Qt, ht) : ht)), z((Ge) => Ge.id === he ? Ce(["settings", pe, "default"], Qt, Ge) : Ge);
1617
- }, [z, T]), Wt = F((he) => {
1618
- ve(!0);
1656
+ }, vs = ({ editorProps: e, className: t, style: i, options: a, children: n }) => {
1657
+ const { shapesRef: o, addPictureShape: r, moveShapes: l, toggleShapeVisibility: s, toggleShapeLock: c, canGoBackward: u, canGoForward: d, canClear: h, selectedShape: f, removeShape: g, updateShape: x, backwardShape: C, forwardShape: k, refs: w, width: m, height: y, selectTool: b, selectShapes: Z, activeTool: A, setActiveTool: T, setAvailableTools: S, isEditMode: V, availableTools: I, gridGap: N, setGridGap: H, loadFile: D, exportPicture: U, exportData: F, clearCanvas: X, settings: p, setCanvasZoom: Q, canvas: { canGrow: M, layersManipulation: L, withExport: P, withLoadAndSave: E, withUploadPicture: W, withUrlPicture: O } } = e, { toolbarBackgroundColor: z, dividerColor: ie, fontRadius: re, fontDisabledColor: R, fontDisabledBackgroundColor: oe, fontColor: G, fontBackgroundColor: le, fontSelectedColor: ae, fontSelectedBackgroundColor: pe, fontHoverColor: se, fontHoverBackgroundColor: ge } = { ...cs, ...a }, q = p.size === "infinite" || p.features.zoom, [he, ce] = $(!1), [Ee, Ie] = $(!1), [He, ve] = $(q), ne = q && He, Te = N >= kt.large ? "large" : N >= kt.medium ? "medium" : N >= kt.small ? "small" : "none", { snackbarList: We, addSnackbar: Ce } = ds(), qe = B((fe, me, vt) => {
1658
+ S((Be) => Be.map((it) => it.id === fe ? Pe(["settings", me, "default"], vt, it) : it)), T((Be) => Be.id === fe ? Pe(["settings", me, "default"], vt, Be) : Be);
1659
+ }, [T, S]), Rt = B((fe) => {
1660
+ ce(!0);
1619
1661
  try {
1620
- _(he);
1621
- } catch (pe) {
1622
- pe instanceof Error && re({ type: "error", text: `L'export a échoué : ${pe.message}` }), console.warn(pe);
1662
+ U(fe);
1663
+ } catch (me) {
1664
+ me instanceof Error && Ce({ type: "error", text: `L'export a échoué : ${me.message}` }), console.warn(me);
1623
1665
  } finally {
1624
- ve(!1);
1666
+ ce(!1);
1625
1667
  }
1626
- }, [_, re]), It = F(() => {
1627
- ve(!0);
1668
+ }, [U, Ce]), Wt = B(() => {
1669
+ ce(!0);
1628
1670
  try {
1629
- U(), ve(!1);
1630
- } catch (he) {
1631
- he instanceof Error && re({ type: "error", text: "L'enregistrement a échoué" }), console.warn(he);
1671
+ F(), ce(!1);
1672
+ } catch (fe) {
1673
+ fe instanceof Error && Ce({ type: "error", text: "L'enregistrement a échoué" }), console.warn(fe);
1632
1674
  } finally {
1633
- ve(!1);
1675
+ ce(!1);
1634
1676
  }
1635
- }, [U, re]), mt = F(async (he) => {
1636
- ve(!0);
1677
+ }, [F, Ce]), _e = B(async (fe) => {
1678
+ ce(!0);
1637
1679
  try {
1638
- await R(he), re({ type: "success", text: "Fichier chargé !" });
1639
- } catch (pe) {
1640
- pe instanceof Error && re({ type: "error", text: "Le chargement a échoué" }), console.warn(pe);
1680
+ await D(fe), Ce({ type: "success", text: "Fichier chargé !" });
1681
+ } catch (me) {
1682
+ me instanceof Error && Ce({ type: "error", text: "Le chargement a échoué" }), console.warn(me);
1641
1683
  } finally {
1642
- ve(!1);
1684
+ ce(!1);
1643
1685
  }
1644
- }, [R, re]), yt = F(async (he) => {
1645
- ve(!0);
1686
+ }, [D, Ce]), Ot = B(async (fe) => {
1687
+ ce(!0);
1646
1688
  try {
1647
- const pe = await s(he, y, m);
1648
- E([pe]);
1649
- } catch (pe) {
1650
- pe instanceof Error && re({ type: "error", text: "Le chargement a échoué" }), console.warn(pe);
1689
+ const me = await r(fe, m, y);
1690
+ Z([me]);
1691
+ } catch (me) {
1692
+ me instanceof Error && Ce({ type: "error", text: "Le chargement a échoué" }), console.warn(me);
1651
1693
  } finally {
1652
- ve(!1);
1694
+ ce(!1);
1653
1695
  }
1654
- }, [s, E, re, y, m]), St = `${t ? `${t} ` : ""}${fe ? "react-paint-editor-layout-opened " : ""}react-paint-editor-app`;
1655
- return B("div", { ref: x.setEditor, className: St, style: { "--react-paint-editor-app-maxWidth": Q ? "100%" : `${y}px`, "--react-paint-editor-app-toolbar-bg": O, "--react-paint-editor-app-divider-color": de, "--react-paint-editor-app-font-radius": N, "--react-paint-editor-app-font-disabled-color": oe, "--react-paint-editor-app-font-disabled-bg": G, "--react-paint-editor-app-font-color": le, "--react-paint-editor-app-font-bg": j, "--react-paint-editor-app-font-selected-color": se, "--react-paint-editor-app-font-selected-bg": ne, "--react-paint-editor-app-font-hover-color": Qe, "--react-paint-editor-app-font-hover-bg": te, ...i }, children: [V && g(No, { settings: p, width: p.canvasSize.width, activeTool: H, clearCanvas: C, setActiveTool: S, exportCanvasInFile: Wt, saveFile: It, loadFile: mt, addPicture: yt, hasActionToUndo: h, hasActionToRedo: c, hasActionToClear: u, undoAction: M, redoAction: P, availableTools: I, withExport: k, withLoadAndSave: D, withUploadPicture: Z, withUrlPicture: X }), n, V && L && g(wo, { gridFormat: We, setGridFormat: (he) => {
1656
- A(kt[he]);
1657
- }, shapes: o.current, moveShapes: l, selectedShapes: f, removeShape: v, selectShapes: E, toggleShapeVisibility: r, toggleShapeLock: d, isLayoutPanelShown: fe, settings: p }), Pe && B(Ke, { alignment: "left", className: "react-paint-editor-layouts-panel", "data-edit": +V, children: [g(J, { className: "react-paint-editor-zoom-button", icon: '<svg viewBox="0 -960 960 960" width="24px"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400ZM280-540v-80h200v80H280Z"/></svg>', onClick: () => w("unzoom") }), B(J, { className: "react-paint-editor-zoom-button react-paint-editor-zoom-button-value", onClick: () => w("default"), children: [Math.round(100 * p.canvasZoom), "%"] }), g(J, { className: "react-paint-editor-zoom-button", icon: Qa, onClick: () => w("zoom") })] }), V && B(Le, { children: [g(Ho, { setCanvasZoom: w, width: p.canvasSize.width, activeTool: H, availableTools: I, selectedShape: f, settings: p, removeShape: v, updateShape: b, canvas: x.canvas.current, layersManipulation: L, toggleLayoutPanel: () => {
1658
- Ne((he) => !he);
1659
- }, isZoomPanelShown: Pe, setIsZoomPanelShown: be, updateToolSettings: Xe }), g(vo, { isLoading: Te }), g(So, { snackbarList: Ie })] })] });
1696
+ }, [r, Z, Ce, m, y]), Ft = `${t ? `${t} ` : ""}${Ee ? "react-paint-editor-layout-opened " : ""}react-paint-editor-app`;
1697
+ return Y("div", { ref: w.setEditor, className: Ft, style: { "--react-paint-editor-app-maxWidth": M ? "100%" : `${m}px`, "--react-paint-editor-app-toolbar-bg": z, "--react-paint-editor-app-divider-color": ie, "--react-paint-editor-app-font-radius": re, "--react-paint-editor-app-font-disabled-color": R, "--react-paint-editor-app-font-disabled-bg": oe, "--react-paint-editor-app-font-color": G, "--react-paint-editor-app-font-bg": le, "--react-paint-editor-app-font-selected-color": ae, "--react-paint-editor-app-font-selected-bg": pe, "--react-paint-editor-app-font-hover-color": se, "--react-paint-editor-app-font-hover-bg": ge, ...i }, children: [V && v(ls, { settings: p, width: p.canvasSize.width, activeTool: A, clearCanvas: X, setActiveTool: b, exportCanvasInFile: Rt, saveFile: Wt, loadFile: _e, addPicture: Ot, hasActionToUndo: u, hasActionToRedo: d, hasActionToClear: h, undoAction: C, redoAction: k, availableTools: I, withExport: P, withLoadAndSave: E, withUploadPicture: W, withUrlPicture: O }), n, V && L && v(Xo, { gridFormat: Te, setGridFormat: (fe) => {
1698
+ H(kt[fe]);
1699
+ }, shapes: o.current, moveShapes: l, selectedShapes: f, removeShape: g, selectShapes: Z, toggleShapeVisibility: s, toggleShapeLock: c, isLayoutPanelShown: Ee, settings: p }), ne && Y(tt, { alignment: "left", className: "react-paint-editor-layouts-panel", "data-edit": +V, children: [v(K, { className: "react-paint-editor-zoom-button", icon: '<svg viewBox="0 -960 960 960" width="24px"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400ZM280-540v-80h200v80H280Z"/></svg>', onClick: () => Q("unzoom") }), Y(K, { className: "react-paint-editor-zoom-button react-paint-editor-zoom-button-value", onClick: () => Q("default"), children: [Math.round(100 * p.canvasZoom), "%"] }), v(K, { className: "react-paint-editor-zoom-button", icon: Za, onClick: () => Q("zoom") })] }), V && Y(Ve, { children: [v(is, { setCanvasZoom: Q, width: p.canvasSize.width, activeTool: A, availableTools: I, selectedShape: f, settings: p, removeShape: g, updateShape: x, canvas: w.canvas.current, layersManipulation: L, toggleLayoutPanel: () => {
1700
+ Ie((fe) => !fe);
1701
+ }, isZoomPanelShown: ne, setIsZoomPanelShown: ve, updateToolSettings: qe }), v(Ro, { isLoading: he }), v(Bo, { snackbarList: We })] })] });
1660
1702
  };
1661
1703
  export {
1662
- Bo as Canvas,
1663
- $o as Editor,
1664
- Fo as useReactPaint
1704
+ gs as Canvas,
1705
+ vs as Editor,
1706
+ ps as useReactPaint
1665
1707
  };