@yorab/react-paint 0.10.0 → 0.11.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 (108) hide show
  1. package/README.md +173 -1
  2. package/dist/{components → canvas/components}/Canvas.d.ts +7 -9
  3. package/dist/{components/toolbox → canvas/components}/EditTextBox.d.ts +4 -4
  4. package/dist/canvas/constants/app.d.ts +44 -0
  5. package/dist/canvas/constants/grid.d.ts +1 -0
  6. package/dist/{constants → canvas/constants}/shapes.d.ts +1 -1
  7. package/dist/{hooks → canvas/hooks}/useComponent.d.ts +1 -1
  8. package/dist/{hooks → canvas/hooks}/useDrawableCanvas.d.ts +9 -16
  9. package/dist/{hooks → canvas/hooks}/useKeyboard.d.ts +4 -6
  10. package/dist/canvas/hooks/useReactPaint.d.ts +131 -0
  11. package/dist/{hooks → canvas/hooks}/useShapes.d.ts +7 -8
  12. package/dist/canvas/index.d.ts +13 -0
  13. package/dist/{utils → canvas/utils}/canvas.d.ts +3 -2
  14. package/dist/canvas/utils/data.d.ts +5 -0
  15. package/dist/{utils → canvas/utils}/file.d.ts +4 -3
  16. package/dist/canvas/utils/grid.d.ts +2 -0
  17. package/dist/{utils → canvas/utils}/intersect.d.ts +7 -6
  18. package/dist/{utils → canvas/utils}/selection/lineSelection.d.ts +5 -4
  19. package/dist/{utils → canvas/utils}/selection/rectSelection.d.ts +6 -6
  20. package/dist/canvas/utils/selection/selectionFrame.d.ts +3 -0
  21. package/dist/canvas/utils/selection.d.ts +8 -0
  22. package/dist/canvas/utils/shapes/brush.d.ts +20 -0
  23. package/dist/canvas/utils/shapes/circle.d.ts +17 -0
  24. package/dist/canvas/utils/shapes/curve.d.ts +17 -0
  25. package/dist/canvas/utils/shapes/ellipse.d.ts +17 -0
  26. package/dist/canvas/utils/shapes/index.d.ts +32 -0
  27. package/dist/canvas/utils/shapes/line.d.ts +17 -0
  28. package/dist/{utils → canvas/utils}/shapes/path.d.ts +3 -2
  29. package/dist/canvas/utils/shapes/picture.d.ts +12 -0
  30. package/dist/canvas/utils/shapes/polygon.d.ts +17 -0
  31. package/dist/canvas/utils/shapes/rectangle.d.ts +20 -0
  32. package/dist/{utils → canvas/utils}/shapes/text.d.ts +10 -10
  33. package/dist/{utils → canvas/utils}/shapes/triangle.d.ts +1 -1
  34. package/dist/{utils → canvas/utils}/string.d.ts +0 -1
  35. package/dist/canvas/utils/tools.d.ts +3 -0
  36. package/dist/{utils → canvas/utils}/transform.d.ts +6 -6
  37. package/dist/{utils → canvas/utils}/trigo.d.ts +4 -4
  38. package/dist/{types → common/types}/Shapes.d.ts +4 -6
  39. package/dist/common/utils/array.d.ts +1 -0
  40. package/dist/editor/components/common/Loading.d.ts +6 -0
  41. package/dist/{components → editor/components}/common/Modal.d.ts +2 -2
  42. package/dist/{components → editor/components}/common/Panel.d.ts +2 -2
  43. package/dist/{components → editor/components}/common/Snackbar.d.ts +2 -3
  44. package/dist/{components → editor/components}/settings/ColorField.d.ts +2 -2
  45. package/dist/{components → editor/components}/settings/DeleteButton.d.ts +2 -3
  46. package/dist/{components → editor/components}/settings/FontFamilyField.d.ts +2 -2
  47. package/dist/{components → editor/components}/settings/LayoutButton.d.ts +1 -2
  48. package/dist/{components → editor/components}/settings/Layouts.d.ts +5 -6
  49. package/dist/{components → editor/components}/settings/LineArrowField.d.ts +2 -2
  50. package/dist/{components → editor/components}/settings/LineTypeField.d.ts +3 -3
  51. package/dist/{components → editor/components}/settings/PointsNumberField.d.ts +2 -2
  52. package/dist/{components → editor/components}/settings/RangeField.d.ts +2 -2
  53. package/dist/{components → editor/components}/settings/SelectField.d.ts +2 -2
  54. package/dist/{components → editor/components}/settings/SettingsBar.d.ts +5 -6
  55. package/dist/{components → editor/components}/settings/ToggleField.d.ts +2 -2
  56. package/dist/{components → editor/components}/toolbox/LoadFileTool.d.ts +2 -3
  57. package/dist/{components → editor/components}/toolbox/MenuGroup.d.ts +3 -4
  58. package/dist/{components → editor/components}/toolbox/PictureUrlInput.d.ts +1 -2
  59. package/dist/{components → editor/components}/toolbox/Tool.d.ts +2 -3
  60. package/dist/{components → editor/components}/toolbox/Toolbar.d.ts +3 -4
  61. package/dist/{components → editor/components}/toolbox/ToolbarGroup.d.ts +2 -3
  62. package/dist/editor/constants/grid.d.ts +7 -0
  63. package/dist/editor/constants/options.d.ts +13 -0
  64. package/dist/{constants → editor/constants}/snackbar.d.ts +1 -1
  65. package/dist/{constants → editor/constants}/style.d.ts +0 -3
  66. package/dist/{constants → editor/constants}/tools.d.ts +1 -1
  67. package/dist/{hooks → editor/hooks}/useDrag.d.ts +2 -2
  68. package/dist/{hooks → editor/hooks}/useSnackbar.d.ts +3 -3
  69. package/dist/editor/index.d.ts +24 -0
  70. package/dist/{utils → editor/utils}/style.d.ts +1 -1
  71. package/dist/editor/utils/toolbar.d.ts +11 -0
  72. package/dist/index.d.ts +6 -0
  73. package/dist/react-paint.css +1 -1
  74. package/dist/react-paint.js +1087 -1053
  75. package/dist/react-paint.umd.cjs +1 -1
  76. package/package.json +61 -56
  77. package/dist/components/App.d.ts +0 -20
  78. package/dist/components/common/Loading.d.ts +0 -7
  79. package/dist/constants/app.d.ts +0 -45
  80. package/dist/utils/array.d.ts +0 -1
  81. package/dist/utils/data.d.ts +0 -4
  82. package/dist/utils/grid.d.ts +0 -3
  83. package/dist/utils/selection/selectionFrame.d.ts +0 -2
  84. package/dist/utils/selection.d.ts +0 -7
  85. package/dist/utils/shapes/brush.d.ts +0 -20
  86. package/dist/utils/shapes/circle.d.ts +0 -17
  87. package/dist/utils/shapes/curve.d.ts +0 -17
  88. package/dist/utils/shapes/ellipse.d.ts +0 -17
  89. package/dist/utils/shapes/index.d.ts +0 -35
  90. package/dist/utils/shapes/line.d.ts +0 -17
  91. package/dist/utils/shapes/picture.d.ts +0 -12
  92. package/dist/utils/shapes/polygon.d.ts +0 -17
  93. package/dist/utils/shapes/rectangle.d.ts +0 -20
  94. package/dist/utils/toolbar.d.ts +0 -13
  95. /package/dist/{constants → canvas/constants}/picture.d.ts +0 -0
  96. /package/dist/{hooks → canvas/hooks}/useDoubleClick.d.ts +0 -0
  97. /package/dist/{hooks → canvas/hooks}/useResizeObserver.d.ts +0 -0
  98. /package/dist/{types → common/types}/Mode.d.ts +0 -0
  99. /package/dist/{types → common/types}/react.d.ts +0 -0
  100. /package/dist/{types → common/types}/tools.d.ts +0 -0
  101. /package/dist/{types → common/types}/utils.d.ts +0 -0
  102. /package/dist/{utils → common/utils}/dom.d.ts +0 -0
  103. /package/dist/{utils → common/utils}/object.d.ts +0 -0
  104. /package/dist/{utils → common/utils}/util.d.ts +0 -0
  105. /package/dist/{components → editor/components}/common/Button.d.ts +0 -0
  106. /package/dist/{constants → editor/constants}/icons.d.ts +0 -0
  107. /package/dist/{constants → editor/constants}/loading.d.ts +0 -0
  108. /package/dist/{types → editor/types}/snackbar.d.ts +0 -0
@@ -1,587 +1,547 @@
1
- import { jsx as h, jsxs as I, Fragment as pe } from "react/jsx-runtime";
2
- import W1, { useState as R, useEffect as Y, useRef as ee, useCallback as U, useMemo as zi, useImperativeHandle as Ui, useTransition as R1 } from "react";
3
- const re = ["transparent", "black", "white", "red", "green", "blue", "yellow"], Ne = [0, 1, 2], e1 = [[1, 0], [1, 2], [4, 6]], rt = "serif", Bi = 1, Xi = 2, Rt = 3, Oe = [10, 20, 40], Yi = ({ isLoading: e = !1 }) => {
4
- const [i, t] = R("hidden");
5
- return Y(() => {
6
- if (!e) {
7
- t("fadeOut");
8
- const n = setTimeout(() => t("hidden"), 300);
9
- return () => {
10
- clearTimeout(n);
11
- };
12
- }
13
- t("visible");
14
- }, [e]), i === "hidden" ? null : h("div", { className: "react-paint-editor-loading", "data-loading": i, style: { "--react-paint-editor-loading-zindex": Xi, "--react-paint-editor-loading-transition-duration": "300ms" }, children: I("div", { className: "react-paint-editor-loader", children: [h("div", {}), h("div", {}), h("div", {}), h("div", {})] }) });
15
- }, $1 = 2, O1 = "blue", Ve = 14, z1 = [[0, 0], [0.5, 0], [1, 0], [1, 0.5], [1, 1], [0.5, 1], [0, 1], [0, 0.5]], U1 = ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle"], B1 = '<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>', $t = '<svg><path d="M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z"/></svg>', Ot = '<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>', zt = '<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>', X1 = '<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>', t1 = '<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>', Ut = '<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>', Y1 = '<svg><path d="M8.708 16.667V5.917H4.167V3.333H15.833V5.917H11.292V16.667Z"/></svg>', _1 = '<svg><path d="M7.5 15.833V14.083H12.833L3.333 4.583L4.583 3.333L14.083 12.833V7.5H15.833V15.833Z"/></svg>', j1 = '<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>', i1 = '<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>', a1 = '<svg><path d="M4.167 16.667V14.083H6.979L10.229 5.917H7.5V3.333H15.833V5.917H13.021L9.771 14.083H12.5V16.667Z"/></svg>', n1 = '<svg><path d="M3.021 16V15H17V16ZM3.021 13.5V12H17V13.5ZM3 10.5V8.5H16.979V10.5ZM3.021 7V4H17V7Z"/></svg>', o1 = '<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>', s1 = '<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>', J = "react-paint-", Bt = { type: "picture", id: `${J}picture`, icon: Ut, label: "Image", settings: { opacity: { min: 0, max: 100, step: 1, default: 100 } } }, q1 = { type: "brush", id: `${J}brush`, icon: B1, label: "Brosse", settings: { strokeColor: { values: re, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 6, max: 20, step: 2, default: 10 }, lineDash: { values: Ne, default: 0 } } }, G1 = { type: "line", id: `${J}line`, icon: _1, label: "Ligne", settings: { strokeColor: { values: re, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 }, lineArrow: { values: [0, 1, 2, 3], default: 0 } } }, J1 = { type: "polygon", id: `${J}polygon`, icon: zt, label: "Polygone", settings: { strokeColor: { values: re, default: "black" }, fillColor: { values: re, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 }, pointsCount: { min: 3, max: 10, step: 1, default: 3 } } }, K1 = { type: "curve", id: `${J}curve`, icon: j1, label: "Courbe", settings: { strokeColor: { values: re, default: "black" }, fillColor: { values: re, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 }, pointsCount: { min: 3, max: 10, step: 1, default: 3 } } }, ei = { type: "rect", id: `${J}rect`, icon: $t, label: "Rectangle", settings: { strokeColor: { values: re, default: "black" }, fillColor: { values: re, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 } } }, ti = { type: "square", id: `${J}square`, icon: $t, label: "Carré", settings: { strokeColor: { values: re, default: "black" }, fillColor: { values: re, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 } } }, ii = { type: "circle", id: `${J}circle`, icon: Ot, label: "Cercle", settings: { strokeColor: { values: re, default: "black" }, fillColor: { values: re, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 } } }, ai = { type: "ellipse", id: `${J}ellipse`, icon: Ot, label: "Ellipse", settings: { strokeColor: { values: re, default: "black" }, fillColor: { values: re, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 } } }, ni = { type: "text", id: `${J}text`, icon: Y1, label: "Texte", settings: { strokeColor: { values: re, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, fontFamily: { values: ["arial", "serif", "monospace"], default: rt }, fontBold: { values: [!1, !0], default: !1 }, fontItalic: { values: [!1, !0], default: !1 } } }, He = { id: `${J}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" }, je = { id: `${J}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" }, qe = { id: `${J}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" }, Ge = { id: `${J}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" }, Vt = { id: `${J}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" }, r1 = { id: `${J}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" }, Ht = { id: `${J}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" }, l1 = { id: `${J}upload-picture`, type: "uploadpicture", icon: Ut, label: "Upload picture" }, oi = "react-paint-editor-canvas-drawcanvas", si = "react-paint-editor-canvas-selectioncanvas", At = { layersManipulation: !0, grid: 0, canGrow: !1, canShrink: !0, withExport: !0, withLoadAndSave: !0, withUploadPicture: !0, withUrlPicture: !1, availableTools: [q1, G1, J1, K1, ei, ti, ii, ai, Bt, ni], clearCallback: "empty", withFrameSelection: !1, withSkeleton: !1, uiStyle: { toolbarBackgroundColor: "white", dividerColor: "#36418129", fontRadius: 8, fontDisabledColor: "#3641812b", fontDisabledBackgroundColor: "transparent", fontColor: "#364181", fontBackgroundColor: "transparent", fontSelectedColor: "white", fontSelectedBackgroundColor: "#364181", fontHoverColor: "#364181", fontHoverBackgroundColor: "#afd8d8", canvasBackgroundColor: "white", canvasSelectionColor: O1, canvasSelectionWidth: $1, canvasSelectionPadding: 0 } }, ri = (e, i) => !!(e.target instanceof Node && i) && i.contains(e.target), li = (e) => {
16
- e.lineCap = "round", e.lineJoin = "round";
17
- }, ze = (e, i = {}) => {
18
- const { lineCap: t = "round", fillColor: n = "transparent", opacity: o = 100, strokeColor: r = O1, lineWidth: s = $1, lineDash: a = 0 } = i;
19
- e.lineCap = t, e.globalAlpha = o / 100, e.fillStyle = n, e.strokeStyle = r, e.lineWidth = s, e.setLineDash(a === 0 ? [] : [e1[a][0] * s, e1[a][1] * s]);
20
- }, Xt = (e, i, t, n, o) => {
21
- e.save(), e.scale(i, i), e.translate(t[0], t[1]), n && o && (e.translate(o[0], o[1]), e.rotate(n), e.translate(-o[0], -o[1]));
22
- }, ut = (e) => {
23
- const i = new Path2D();
24
- return i.rect(e.x, e.y, e.width, e.height), i;
25
- }, ht = (e) => {
26
- const i = new Path2D();
27
- return i.arc(e.x, e.y, e.radius, 0, 2 * Math.PI), i;
28
- }, Nt = (e) => {
29
- const i = new Path2D();
30
- return i.moveTo(...e.points[0]), i.lineTo(...e.points[1]), i;
31
- }, _i = (e) => {
32
- const i = new Path2D();
33
- return i.moveTo(...e.points[0]), i.lineTo(...e.points[1]), i.lineTo(...e.points[2]), i.lineTo(...e.points[0]), i;
34
- }, Yt = (e, i, t, n, o = !1) => {
35
- const { borders: r } = G(i, n);
36
- return { border: ut(r), shapePath: e, anchors: [...i.points.map((s, a) => o && a > 0 && a < i.points.length - 1 ? ut({ x: s[0] - 7, y: s[1] - 7, width: Ve / t, height: Ve / t }) : ht({ x: s[0], y: s[1], radius: 7 / t }))] };
37
- }, Dt = (e) => 180 * e / Math.PI, di = (e, i) => {
38
- const t = i.x - Math.min(Math.max(i.x, e.x), e.x + e.width), n = i.y - Math.min(Math.max(i.y, e.y), e.y + e.height);
39
- return Math.sqrt(t * t + n * n) <= i.radius;
40
- }, fe = ({ origin: e = [0, 0], point: i, rotation: t }) => {
41
- const n = [i[0] - e[0], i[1] - e[1]], o = n[1] * Math.cos(t) - n[0] * Math.sin(t);
42
- return [n[1] * Math.sin(t) + n[0] * Math.cos(t) + e[0], o + e[1]];
43
- }, d1 = (e) => (e + 2 * Math.PI) % (2 * Math.PI), c1 = ({ targetVector: [e, i], radian: t = !0, originVector: n }) => {
44
- const o = d1(Math.atan2(i[1] - e[1], i[0] - e[0]));
45
- if (n) {
46
- const [r, s] = n, a = Math.atan2(s[1] - r[1], s[0] - r[0]), l = d1(o - a);
47
- return t ? l : Dt(l);
48
- }
49
- return t ? o : Dt(o);
50
- }, gt = 300, Et = (e, i) => {
1
+ import Fi, { useState as z, useEffect as U, useRef as ae, useCallback as W, useMemo as Di, useImperativeHandle as m1, useTransition as Ni } from "react";
2
+ import { jsx as p, jsxs as I, Fragment as ue } from "react/jsx-runtime";
3
+ const Ri = '<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>', It = '<svg><path d="M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z"/></svg>', Wt = '<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>', zt = '<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>', Ii = '<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>', _t = '<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>', $t = '<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>', Wi = '<svg><path d="M8.708 16.667V5.917H4.167V3.333H15.833V5.917H11.292V16.667Z"/></svg>', zi = '<svg><path d="M7.5 15.833V14.083H12.833L3.333 4.583L4.583 3.333L14.083 12.833V7.5H15.833V15.833Z"/></svg>', $i = '<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>', qt = '<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>', Jt = '<svg><path d="M4.167 16.667V14.083H6.979L10.229 5.917H7.5V3.333H15.833V5.917H13.021L9.771 14.083H12.5V16.667Z"/></svg>', Kt = '<svg><path d="M3.021 16V15H17V16ZM3.021 13.5V12H17V13.5ZM3 10.5V8.5H16.979V10.5ZM3.021 7V4H17V7Z"/></svg>', ei = '<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>', 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.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>', de = ["transparent", "black", "white", "red", "green", "blue", "yellow"], De = [0, 1, 2], ii = [[1, 0], [1, 2], [4, 6]], ot = "serif", y1 = 2, Oi = 3, Q1 = 4, ee = "react-paint-", Ot = { type: "picture", id: `${ee}picture`, icon: $t, label: "Image", settings: { opacity: { min: 0, max: 100, step: 1, default: 100 } } }, Gi = { type: "brush", id: `${ee}brush`, icon: Ri, label: "Brosse", settings: { strokeColor: { values: de, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 6, max: 20, step: 2, default: 10 }, lineDash: { values: De, default: 0 } } }, Ui = { type: "line", id: `${ee}line`, icon: zi, label: "Ligne", settings: { strokeColor: { values: de, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: De, default: 0 }, lineArrow: { values: [0, 1, 2, 3], default: 0 } } }, Bi = { type: "polygon", id: `${ee}polygon`, icon: zt, label: "Polygone", settings: { strokeColor: { values: de, default: "black" }, fillColor: { values: de, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: De, default: 0 }, pointsCount: { min: 3, max: 10, step: 1, default: 3 } } }, Xi = { type: "curve", id: `${ee}curve`, icon: $i, label: "Courbe", settings: { strokeColor: { values: de, default: "black" }, fillColor: { values: de, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: De, default: 0 }, pointsCount: { min: 3, max: 10, step: 1, default: 3 } } }, Yi = { type: "rect", id: `${ee}rect`, icon: It, label: "Rectangle", settings: { strokeColor: { values: de, default: "black" }, fillColor: { values: de, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: De, default: 0 } } }, ji = { type: "square", id: `${ee}square`, icon: It, label: "Carré", settings: { strokeColor: { values: de, default: "black" }, fillColor: { values: de, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: De, default: 0 } } }, _i = { type: "circle", id: `${ee}circle`, icon: Wt, label: "Cercle", settings: { strokeColor: { values: de, default: "black" }, fillColor: { values: de, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: De, default: 0 } } }, qi = { type: "ellipse", id: `${ee}ellipse`, icon: Wt, label: "Ellipse", settings: { strokeColor: { values: de, default: "black" }, fillColor: { values: de, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: De, default: 0 } } }, Ji = { type: "text", id: `${ee}text`, icon: Wi, label: "Texte", settings: { strokeColor: { values: de, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, fontFamily: { values: ["arial", "serif", "monospace"], default: ot }, fontBold: { values: [!1, !0], default: !1 }, fontItalic: { values: [!1, !0], default: !1 } } }, Te = { id: `${ee}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" }, Xe = { id: `${ee}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" }, Ye = { id: `${ee}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" }, je = { id: `${ee}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" }, Lt = { id: `${ee}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" }, ai = { id: `${ee}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" }, Vt = { id: `${ee}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" }, ni = { id: `${ee}upload-picture`, type: "uploadpicture", icon: $t, label: "Upload picture" }, Ki = 2, e1 = "blue", He = 14, t1 = [[0, 0], [0.5, 0], [1, 0], [1, 0.5], [1, 1], [0.5, 1], [0, 1], [0, 0.5]], i1 = ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle"], a1 = "react-paint-canvas-drawcanvas", n1 = "react-paint-canvas-selectioncanvas", Pt = { layersManipulation: !0, grid: 0, canGrow: !1, canShrink: !0, withExport: !0, withLoadAndSave: !0, withUploadPicture: !0, withUrlPicture: !1, availableTools: [Gi, Ui, Bi, Xi, Yi, ji, _i, qi, Ot, Ji], clearCallback: "empty", brushAlgo: "simple", withFrameSelection: !1, withSkeleton: !1, selection: { canvasSelectionColor: e1, canvasSelectionWidth: Ki, canvasSelectionPadding: 0 } }, S1 = { canvasBackgroundColor: "white" }, s1 = (e, i) => !!(e.target instanceof Node && i) && i.contains(e.target), ut = 300, Et = (e, i) => {
51
4
  const t = { ...i };
52
- for (const n of e)
53
- delete t[n];
5
+ for (const a of e)
6
+ delete t[a];
54
7
  return t;
55
- }, ce = (e, i, t) => {
56
- const n = Array.isArray(t) ? [...t] : { ...t }, o = Array.isArray(e) ? e : typeof e == "string" ? e.split(".") : [e];
57
- return o.reduce((r, s, a) => (r[s] = It(r[s]) ? { ...r[s] } : Array.isArray(r[s]) ? [...r[s]] : r[s] === void 0 || r[s] === null ? {} : r[s], a === o.length - 1 && (r[s] = i), r[s]), n), n;
58
- }, It = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, xe = (e, i, t) => {
59
- if (!It(i) || !It(t))
8
+ }, le = (e, i, t) => {
9
+ const a = Array.isArray(t) ? [...t] : { ...t }, s = Array.isArray(e) ? e : typeof e == "string" ? e.split(".") : [e];
10
+ return s.reduce((n, o, r) => (n[o] = Ft(n[o]) ? { ...n[o] } : Array.isArray(n[o]) ? [...n[o]] : n[o] === void 0 || n[o] === null ? {} : n[o], r === s.length - 1 && (n[o] = i), n[o]), a), a;
11
+ }, Ft = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, we = (e, i, t) => {
12
+ if (!Ft(i) || !Ft(t))
60
13
  return t;
61
- const n = { ...i };
62
- for (const o in t)
63
- t.hasOwnProperty(o) && (n.hasOwnProperty(o) ? n[o] = e(n[o], t[o], o) ?? xe(e, n[o], t[o]) : n[o] = t[o]);
64
- return n;
65
- }, ci = (e, i) => {
14
+ const a = { ...i };
15
+ for (const s in t)
16
+ Object.hasOwn(t, s) && (Object.hasOwn(a, s) ? a[s] = e(a[s], t[s], s) ?? we(e, a[s], t[s]) : a[s] = t[s]);
17
+ return a;
18
+ }, o1 = (e, i) => {
66
19
  if (e === i)
67
20
  return !0;
68
21
  if (typeof e != "object" || typeof i != "object" || e === null || i === null)
69
22
  return !1;
70
- const t = Object.keys(e), n = Object.keys(i);
71
- if (t.length !== n.length)
23
+ const t = Object.keys(e), a = Object.keys(i);
24
+ if (t.length !== a.length)
72
25
  return !1;
73
- for (const o of t)
74
- if (!n.includes(o) || !ci(e[o], i[o]))
26
+ for (const s of t)
27
+ if (!a.includes(s) || !o1(e[s], i[s]))
75
28
  return !1;
76
29
  return !0;
77
- }, Tt = {}, ae = (e = "") => (Tt[e] || (Tt[e] = 0), `${e}${++Tt[e]}`), et = (e, i, t) => {
78
- const n = ((o) => {
79
- if (o.points.length < 1 || o.style?.strokeColor === "transparent")
30
+ }, Ht = {}, se = (e = "") => (Ht[e] || (Ht[e] = 0), `${e}${++Ht[e]}`), ft = (e) => e.filter((i) => i != null), r1 = (e) => {
31
+ e.lineCap = "round", e.lineJoin = "round";
32
+ }, ze = (e, i = {}) => {
33
+ const { lineCap: t = "round", fillColor: a = "transparent", opacity: s = 100, strokeColor: n = e1, lineWidth: o = Ki, lineDash: r = 0 } = i;
34
+ e.lineCap = t, e.globalAlpha = s / 100, e.fillStyle = a, e.strokeStyle = n, e.lineWidth = o, e.setLineDash(r === 0 ? [] : [ii[r][0] * o, ii[r][1] * o]);
35
+ }, Gt = (e, i, t, a) => {
36
+ e.save(), e.scale(i.canvasSize.scaleRatio, i.canvasSize.scaleRatio), e.translate(i.canvasOffset[0], i.canvasOffset[1]), t && a && (e.translate(a[0], a[1]), e.rotate(t), e.translate(-a[0], -a[1]));
37
+ }, gt = (e) => {
38
+ const i = new Path2D();
39
+ return i.rect(e.x, e.y, e.width, e.height), i;
40
+ }, vt = (e) => {
41
+ const i = new Path2D();
42
+ return i.arc(e.x, e.y, e.radius, 0, 2 * Math.PI), i;
43
+ }, Dt = (e) => {
44
+ const i = new Path2D();
45
+ return i.moveTo(...e.points[0]), i.lineTo(...e.points[1]), i;
46
+ }, b1 = (e) => {
47
+ const i = new Path2D();
48
+ return i.moveTo(...e.points[0]), i.lineTo(...e.points[1]), i.lineTo(...e.points[2]), i.lineTo(...e.points[0]), i;
49
+ }, Ut = (e, i, t, a = !1) => {
50
+ const { borders: s } = Y(i, t);
51
+ return { border: gt(s), shapePath: e, anchors: [...i.points.map((n, o) => a && o > 0 && o < i.points.length - 1 ? gt({ x: n[0] - 7, y: n[1] - 7, width: He / t.canvasSize.scaleRatio, height: He / t.canvasSize.scaleRatio }) : vt({ x: n[0], y: n[1], radius: 7 / t.canvasSize.scaleRatio }))] };
52
+ }, Je = (e, i) => {
53
+ const t = ((a, { brushAlgo: s }) => {
54
+ if (a.points.length < 1 || a.style?.strokeColor === "transparent")
80
55
  return;
81
- const r = o.points.flat(), s = r.map((d) => d[0]), a = r.map((d) => d[1]), l = Math.min(...s), p = Math.min(...a), c = new Path2D();
82
- for (const d of o.points)
83
- if (d.length === 1)
84
- c.rect(...Ue(d[0], l, p, o.scaleX, o.scaleY), 1, 1);
85
- else {
86
- c.moveTo(...Ue(d[0], l, p, o.scaleX, o.scaleY));
87
- for (const u of d.slice(1))
88
- c.lineTo(...Ue(u, l, p, o.scaleX, o.scaleY));
89
- }
90
- return c;
91
- })(e);
92
- return { ...e, path: n, selection: tt(n, e, i, t) };
93
- }, ji = et, Fe = (e, i = 2) => Math.round(e * 10 ** i) / 10 ** i, Ue = (e, i, t, n = 1, o = 1) => [i + (e[0] - i) * n, t + (e[1] - t) * o], z = (e, i, t = 0) => {
94
- if (!i)
56
+ const n = a.points.flat(), o = n.map((h) => h[0]), r = n.map((h) => h[1]), l = Math.min(...o), c = Math.min(...r), d = new Path2D();
57
+ for (const h of a.points) {
58
+ if (!h.length)
59
+ return;
60
+ if (h.length === 1)
61
+ d.rect(...Se(h[0], l, c, a.scaleX, a.scaleY), 1, 1);
62
+ else if (d.moveTo(...Se(h[0], l, c, a.scaleX, a.scaleY)), s === "quadratic") {
63
+ for (let u = 0; u < h.slice(1).length - 2; u++) {
64
+ const g = Se(h[u], l, c, a.scaleX, a.scaleY), v = Se(h[u + 1], l, c, a.scaleX, a.scaleY), x = (g[0] + v[0]) / 2, M = (g[1] + v[1]) / 2;
65
+ d.quadraticCurveTo(...g, x, M);
66
+ }
67
+ d.quadraticCurveTo(...Se(h[h.length - 2], l, c, a.scaleX, a.scaleY), ...Se(h[h.length - 1], l, c, a.scaleX, a.scaleY));
68
+ } else
69
+ for (const u of h.slice(1))
70
+ d.lineTo(...Se(u, l, c, a.scaleX, a.scaleY));
71
+ }
72
+ return d;
73
+ })(e, i);
74
+ return { ...e, path: t, selection: Ke(t, e, i) };
75
+ }, C1 = Je, Nt = (e) => 180 * e / Math.PI, l1 = (e, i) => {
76
+ const t = i.x - Math.min(Math.max(i.x, e.x), e.x + e.width), a = i.y - Math.min(Math.max(i.y, e.y), e.y + e.height);
77
+ return Math.sqrt(t * t + a * a) <= i.radius;
78
+ }, ve = ({ origin: e = [0, 0], point: i, rotation: t }) => {
79
+ const a = [i[0] - e[0], i[1] - e[1]], s = a[1] * Math.cos(t) - a[0] * Math.sin(t);
80
+ return [a[1] * Math.sin(t) + a[0] * Math.cos(t) + e[0], s + e[1]];
81
+ }, si = (e) => (e + 2 * Math.PI) % (2 * Math.PI), oi = ({ targetVector: [e, i], radian: t = !0, originVector: a }) => {
82
+ const s = si(Math.atan2(i[1] - e[1], i[0] - e[0]));
83
+ if (a) {
84
+ const [n, o] = a, r = Math.atan2(o[1] - n[1], o[0] - n[0]), l = si(s - r);
85
+ return t ? l : Nt(l);
86
+ }
87
+ return t ? s : Nt(s);
88
+ }, Fe = (e, i = 2) => Math.round(e * 10 ** i) / 10 ** i, Se = (e, i, t, a = 1, s = 1) => [i + (e[0] - i) * a, t + (e[1] - t) * s], O = (e, i, t = 0) => {
89
+ if (!i.gridGap)
95
90
  return Fe(e);
96
- const n = e + t, o = n >= 0 ? Oe[i - 1] : -Oe[i - 1];
97
- return n + o / 2 - (n + o / 2) % o - t;
98
- }, qi = (e, i, t = 0) => i ? e + Math.PI / 18 / 2 - (e + Math.PI / 18 / 2) % (Math.PI / 18) : Fe(e, 3), Gi = (e, i, t, n, o, r, s, a, l) => {
99
- switch (r.mode) {
91
+ const a = e + t, s = a >= 0 ? i.gridGap : -i.gridGap;
92
+ return a + s / 2 - (a + s / 2) % s - t;
93
+ }, w1 = (e, i, t = 0) => i.gridGap ? e + Math.PI / 18 / 2 - (e + Math.PI / 18 / 2) % (Math.PI / 18) : Fe(e, 3), x1 = (e, i, t, a, s, n) => {
94
+ switch (a.mode) {
100
95
  case "brush":
101
- return ((p, c, d, u) => {
102
- const f = { ...p, points: ce(p.points.length - 1, [...p.points[p.points.length - 1], [Math.round(c[0]), Math.round(c[1])]], p.points) };
103
- return et(f, d, u);
104
- })(i, t, l, s);
96
+ return ((o, r, l) => {
97
+ const c = { ...o, points: le(o.points.length - 1, [...o.points[o.points.length - 1], [Math.round(r[0]), Math.round(r[1])]], o.points) };
98
+ return Je(c, l);
99
+ })(i, t, s);
105
100
  case "translate":
106
- return Wt(t, r.originalShape, r.cursorStartPosition, n, l, s);
101
+ return Rt(t, a.originalShape, a.cursorStartPosition, s);
107
102
  case "rotate":
108
- return fa(i, t, r.originalShape, r.cursorStartPosition, r.center, n);
103
+ return I1(i, t, a.originalShape, a.cursorStartPosition, a.center, s);
109
104
  case "resize":
110
- return va(e, i, t, o, r.originalShape, r, n, s, a, l);
105
+ return W1(e, i, t, a.originalShape, a, s, n);
111
106
  default:
112
107
  return i;
113
108
  }
114
- }, tt = (e, i, t, n) => {
115
- const { borders: o } = G(i, n);
116
- return { border: ut(o), shapePath: e, line: Nt({ points: [[o.x + o.width / 2, o.y], [o.x + o.width / 2, o.y - 23 / t]] }), anchors: [ht({ x: o.x + o.width / 2, y: o.y - 23 / t, radius: 7 / t }), ...z1.map((r) => ht({ x: o.x + o.width * r[0], y: o.y + o.height * r[1], radius: 7 / t }))] };
117
- }, p1 = ({ borderStart: e, borderSize: i, vector: t, selectionPadding: n, invertedAxe: o, anchor: r }) => {
118
- switch (r) {
109
+ }, Ke = (e, i, t) => {
110
+ const { borders: a } = Y(i, t);
111
+ return { border: gt(a), shapePath: e, line: Dt({ points: [[a.x + a.width / 2, a.y], [a.x + a.width / 2, a.y - 23 / t.canvasSize.scaleRatio]] }), anchors: [vt({ x: a.x + a.width / 2, y: a.y - 23 / t.canvasSize.scaleRatio, radius: 7 / t.canvasSize.scaleRatio }), ...t1.map((s) => vt({ x: a.x + a.width * s[0], y: a.y + a.height * s[1], radius: 7 / t.canvasSize.scaleRatio }))] };
112
+ }, ri = ({ borderStart: e, borderSize: i, vector: t, settings: a, invertedAxe: s, anchor: n }) => {
113
+ switch (n) {
119
114
  case 0: {
120
- if (o) {
121
- const a = i - 2 * n;
122
- return [e + a, t - a];
115
+ if (s) {
116
+ const r = i - 2 * a.selectionPadding;
117
+ return [e + r, t - r];
123
118
  }
124
- const s = Math.max(2 * n, i - t);
125
- return [e + i - s, s];
119
+ const o = Math.max(2 * a.selectionPadding, i - t);
120
+ return [e + i - o, o];
126
121
  }
127
122
  case 0.5:
128
123
  return [e, i];
129
124
  case 1:
130
- if (o) {
131
- const s = i + t;
132
- return [e + s, 2 * n - s];
125
+ if (s) {
126
+ const o = i + t;
127
+ return [e + o, 2 * a.selectionPadding - o];
133
128
  }
134
- return [e, Math.max(2 * n, i + t)];
129
+ return [e, Math.max(2 * a.selectionPadding, i + t)];
135
130
  default:
136
131
  return [0, 0];
137
132
  }
138
- }, u1 = ({ borderX: e, borderWidth: i, borderY: t, borderHeight: n, center: o, originalShape: r }) => {
139
- const s = [e + i / 2 - o[0], t + n / 2 - o[1]], [a, l] = fe({ point: s, rotation: -r.rotation });
140
- return { borderX: Fe(e + a - s[0]), borderWidth: Fe(i), borderY: Fe(t + l - s[1]), borderHeight: Fe(n) };
141
- }, _e = (e, i, t, n, o, r = !1) => {
142
- const { center: s, borders: a } = G(i, o), l = fe({ origin: s, point: e, rotation: i.rotation }), p = t.anchor[0] === 0 && l[0] >= a.x + a.width || t.anchor[0] === 1 && l[0] <= a.x, c = t.anchor[1] === 0 && l[1] >= a.y + a.height || t.anchor[1] === 1 && l[1] <= a.y, d = [z(l[0], n, t.anchor[0] === 0 && !p || t.anchor[0] === 1 && p ? o : -o), z(l[1], n, t.anchor[1] === 0 && !c || t.anchor[1] === 1 && c ? o : -o)], u = n ? [t.anchor[0] === 0 ? a.x : t.anchor[0] === 0.5 ? a.x + a.width / 2 : a.x + a.width, t.anchor[1] === 0 ? a.y : t.anchor[1] === 0.5 ? a.y + a.height / 2 : a.y + a.height] : fe({ origin: s, point: t.cursorStartPosition, rotation: i.rotation }), f = [d[0] - u[0], d[1] - u[1]], [g, v] = p1({ borderStart: a.x, borderSize: a.width, vector: f[0], selectionPadding: o, invertedAxe: p, anchor: t.anchor[0] }), [C, x] = p1({ borderStart: a.y, borderSize: a.height, vector: f[1], selectionPadding: o, invertedAxe: c, anchor: t.anchor[1] });
143
- if (r) {
144
- const w = ((y, b, H, A, Z, F, E, S, T, M) => {
145
- const B = (b.width - 2 * M || 1) / (b.height - 2 * M || 1), N = (Z - 2 * M) / (E - 2 * M);
146
- let Q, k, m, V;
147
- return T.anchor[0] !== 0.5 && T.anchor[1] !== 0.5 ? N < B ? (k = F, V = E, m = (E - 2 * M) * B + 2 * M, Q = T.anchor[0] === 0 ? b.width - y[0] > M ? b.x + (b.width - m) : b.x + b.width - 2 * M : b.width + y[0] > M ? b.x : b.x - m + 2 * M) : (Q = A, m = Z, V = (Z - 2 * M) / B + 2 * M, k = T.anchor[1] === 0 ? b.height - y[1] > M ? b.y + (b.height - V) : b.y + b.height - 2 * M : b.height + y[1] > M ? b.y : b.y - V + 2 * M) : T.anchor[0] !== 0.5 ? (Q = A, m = Z, V = (Z - 2 * M) / B + 2 * M, k = b.y + (b.height - V) / 2) : (k = F, V = E, m = (E - 2 * M) * B + 2 * M, Q = b.x + (b.width - m) / 2), { borderX: Q, borderWidth: m, borderY: k, borderHeight: V, center: H, originalShape: S };
148
- })(f, a, s, g, v, C, x, i, t, o);
149
- return u1(w);
133
+ }, li = ({ borderX: e, borderWidth: i, borderY: t, borderHeight: a, center: s, originalShape: n }) => {
134
+ const o = [e + i / 2 - s[0], t + a / 2 - s[1]], [r, l] = ve({ point: o, rotation: -n.rotation });
135
+ return { borderX: Fe(e + r - o[0]), borderWidth: Fe(i), borderY: Fe(t + l - o[1]), borderHeight: Fe(a) };
136
+ }, Be = (e, i, t, a, s = !1) => {
137
+ const { center: n, borders: o } = Y(i, a), r = ve({ origin: n, point: e, rotation: i.rotation }), l = t.anchor[0] === 0 && r[0] >= o.x + o.width || t.anchor[0] === 1 && r[0] <= o.x, c = t.anchor[1] === 0 && r[1] >= o.y + o.height || t.anchor[1] === 1 && r[1] <= o.y, d = [O(r[0], a, t.anchor[0] === 0 && !l || t.anchor[0] === 1 && l ? a.selectionPadding : -a.selectionPadding), O(r[1], a, t.anchor[1] === 0 && !c || t.anchor[1] === 1 && c ? a.selectionPadding : -a.selectionPadding)], h = a.gridGap ? [t.anchor[0] === 0 ? o.x : t.anchor[0] === 0.5 ? o.x + o.width / 2 : o.x + o.width, t.anchor[1] === 0 ? o.y : t.anchor[1] === 0.5 ? o.y + o.height / 2 : o.y + o.height] : ve({ origin: n, point: t.cursorStartPosition, rotation: i.rotation }), u = [d[0] - h[0], d[1] - h[1]], [g, v] = ri({ borderStart: o.x, borderSize: o.width, vector: u[0], settings: a, invertedAxe: l, anchor: t.anchor[0] }), [x, M] = ri({ borderStart: o.y, borderSize: o.height, vector: u[1], settings: a, invertedAxe: c, anchor: t.anchor[1] });
138
+ if (s) {
139
+ const y = ((P, Q, L, T, E, Z, H, C, V, k) => {
140
+ const { selectionPadding: S } = k, F = (Q.width - 2 * S || 1) / (Q.height - 2 * S || 1), w = (E - 2 * S) / (H - 2 * S);
141
+ let A, N, f, m;
142
+ return V.anchor[0] !== 0.5 && V.anchor[1] !== 0.5 ? w < F ? (N = Z, m = H, f = (H - 2 * S) * F + 2 * S, A = V.anchor[0] === 0 ? Q.width - P[0] > S ? Q.x + (Q.width - f) : Q.x + Q.width - 2 * S : Q.width + P[0] > S ? Q.x : Q.x - f + 2 * S) : (A = T, f = E, m = (E - 2 * S) / F + 2 * S, N = V.anchor[1] === 0 ? Q.height - P[1] > S ? Q.y + (Q.height - m) : Q.y + Q.height - 2 * S : Q.height + P[1] > S ? Q.y : Q.y - m + 2 * S) : V.anchor[0] !== 0.5 ? (A = T, f = E, m = (E - 2 * S) / F + 2 * S, N = Q.y + (Q.height - m) / 2) : (N = Z, m = H, f = (H - 2 * S) * F + 2 * S, A = Q.x + (Q.width - f) / 2), { borderX: A, borderWidth: f, borderY: N, borderHeight: m, center: L, originalShape: C };
143
+ })(u, o, n, g, v, x, M, i, t, a);
144
+ return li(y);
150
145
  }
151
- return u1({ borderX: g, borderWidth: v, borderY: C, borderHeight: x, center: s, originalShape: i });
152
- }, ft = (e, i, t) => {
153
- const n = ht(e);
154
- return { ...e, path: n, selection: tt(n, e, i, t) };
155
- }, Ji = ft, Zt = (e, i, t, n, o = 1) => {
156
- const { clientX: r = 0, clientY: s = 0 } = "touches" in e && e.touches[0] ? e.touches[0] : "changedTouches" in e && e.changedTouches[0] ? e.changedTouches[0] : "clientX" in e ? e : {}, a = i?.getBoundingClientRect() ?? { left: 0, top: 0, width: t, height: n };
157
- return [(r - a.left) * (t / a.width) / o, (s - a.top) * (n / a.height) / o];
158
- }, h1 = (e) => "touches" in e, Be = (e, i, [t, n], [o, r]) => fe({ origin: [t - o, n - r], point: e, rotation: i }), dt = (e, i, t) => t ? di(e, { x: i[0], y: i[1], radius: t }) : ((n, o) => o[0] >= n.x && o[0] <= n.x + n.width && o[1] >= n.y && o[1] <= n.y + n.height)(e, i), ot = (e, i, t, n, o, r = !1, s = 0) => {
146
+ return li({ borderX: g, borderWidth: v, borderY: x, borderHeight: M, center: n, originalShape: i });
147
+ }, mt = (e, i) => {
148
+ const t = vt(e);
149
+ return { ...e, path: t, selection: Ke(t, e, i) };
150
+ }, M1 = mt, Tt = (e, i, t) => {
151
+ const { clientX: a = 0, clientY: s = 0 } = "touches" in e && e.touches[0] ? e.touches[0] : "changedTouches" in e && e.changedTouches[0] ? e.changedTouches[0] : "clientX" in e ? e : {}, n = i?.getBoundingClientRect() ?? { left: 0, top: 0, width: t.canvasSize.width, height: t.canvasSize.height };
152
+ return [(a - n.left) * (t.canvasSize.width / n.width) / t.canvasSize.scaleRatio, (s - n.top) * (t.canvasSize.height / n.height) / t.canvasSize.scaleRatio];
153
+ }, di = (e) => "touches" in e, $e = (e, i, [t, a], [s, n]) => ve({ origin: [t - s, a - n], point: e, rotation: i }), dt = (e, i, t) => t ? l1(e, { x: i[0], y: i[1], radius: t }) : ((a, s) => s[0] >= a.x && s[0] <= a.x + a.width && s[1] >= a.y && s[1] <= a.y + a.height)(e, i), nt = (e, i, t, a = !1, s = 0) => {
159
154
  if (e.locked)
160
155
  return !1;
161
- const { borders: a, center: l } = G(e, n), p = Be(i, e.rotation, l, t);
162
- if (r)
156
+ const { canvasSize: { scaleRatio: n } } = t, { borders: o, center: r } = Y(e, t), l = $e(i, e.rotation, r, t.canvasOffset);
157
+ if (a)
163
158
  if (e.type === "line" || e.type === "polygon" || e.type === "curve") {
164
159
  for (let c = 0; c < e.points.length; c++)
165
- if (dt({ x: e.points[c][0] - 7 / o, y: e.points[c][1] - 7 / o, width: Ve / o, height: Ve / o }, p, s))
160
+ if (dt({ x: e.points[c][0] - 7 / n, y: e.points[c][1] - 7 / n, width: He / n, height: He / n }, l, s))
166
161
  return { mode: "resize", anchor: c };
167
162
  } else {
168
- if (dt({ x: a.x + a.width / 2 - 7 / o, y: a.y - Ve / o - 16 / o, width: Ve / o, height: Ve / o }, p, s))
163
+ if (dt({ x: o.x + o.width / 2 - 7 / n, y: o.y - He / n - 16 / n, width: He / n, height: He / n }, l, s))
169
164
  return { mode: "rotate" };
170
- for (const c of z1)
171
- if (dt({ x: a.x + a.width * c[0] - 7 / o, y: a.y + a.height * c[1] - 7 / o, width: Ve / o, height: Ve / o }, p, s))
165
+ for (const c of t1)
166
+ if (dt({ x: o.x + o.width * c[0] - 7 / n, y: o.y + o.height * c[1] - 7 / n, width: He / n, height: He / n }, l, s))
172
167
  return { mode: "resize", anchor: c };
173
168
  }
174
- return !!dt(a, p, s) && { mode: "translate" };
175
- }, pi = (e, i, t, n, o, r) => {
169
+ return !!dt(o, l, s) && { mode: "translate" };
170
+ }, d1 = (e, i, t, a) => {
176
171
  if (i.locked)
177
172
  return !1;
178
- const { center: s } = G(i, o), a = Be(t, i.rotation, s, n);
179
- return "path" in i && i.path ? i.style?.fillColor && i.style?.fillColor !== "transparent" ? !!e.isPointInPath(i.path, a[0], a[1]) && { mode: "translate" } : (e.lineWidth = (i.style?.lineWidth ?? 0) + 15, !!e.isPointInStroke(i.path, a[0], a[1]) && { mode: "translate" }) : ot(i, t, n, o, r, !1);
173
+ const { center: s } = Y(i, a), n = $e(t, i.rotation, s, a.canvasOffset);
174
+ return "path" in i && i.path ? i.style?.fillColor && i.style?.fillColor !== "transparent" ? !!e.isPointInPath(i.path, n[0], n[1]) && { mode: "translate" } : (e.lineWidth = (i.style?.lineWidth ?? 0) + 15, !!e.isPointInStroke(i.path, n[0], n[1]) && { mode: "translate" }) : nt(i, t, a, !1);
180
175
  };
181
- function g1(e, i) {
182
- const t = Math.max(e.x, i.x), n = Math.max(e.y, i.y), o = Math.min(e.x + (e.width || 1), i.x + (i.width || 1)), r = Math.min(e.y + (e.height || 1), i.y + (i.height || 1));
183
- if (t < o && n < r)
184
- return { x: t, y: n, width: o - t, height: r - n };
176
+ function ci(e, i) {
177
+ const t = Math.max(e.x, i.x), a = Math.max(e.y, i.y), s = Math.min(e.x + (e.width || 1), i.x + (i.width || 1)), n = Math.min(e.y + (e.height || 1), i.y + (i.height || 1));
178
+ if (t < s && a < n)
179
+ return { x: t, y: a, width: s - t, height: n - a };
185
180
  }
186
- const f1 = ({ ctx: e, path: i, rect: t, offset: n, checkFill: o }) => {
187
- for (let r = 0; r < n; r += n / 2)
188
- for (let s = 0; s < n; s += n / 2)
189
- for (let a = r + t.x; a < t.x + t.width; a += n)
190
- for (let l = s + t.y; l < t.y + t.height; l += n)
191
- if (o ? e.isPointInPath(i, a, l) : e.isPointInStroke(i, a, l))
181
+ const hi = ({ ctx: e, path: i, rect: t, offset: a, checkFill: s }) => {
182
+ for (let n = 0; n < a; n += a / 2)
183
+ for (let o = 0; o < a; o += a / 2)
184
+ for (let r = n + t.x; r < t.x + t.width; r += a)
185
+ for (let l = o + t.y; l < t.y + t.height; l += a)
186
+ if (s ? e.isPointInPath(i, r, l) : e.isPointInStroke(i, r, l))
192
187
  return !0;
193
188
  return !1;
194
- }, Je = (e, i, t) => {
195
- const n = ((o) => {
196
- if (o.points.length < 1)
189
+ }, _e = (e, i) => {
190
+ const t = ((a) => {
191
+ if (a.points.length < 1)
197
192
  return;
198
- const r = new Path2D();
199
- r.moveTo(...o.points[0]);
200
- for (const s of o.points.slice(1))
201
- r.lineTo(...s);
202
- return r.lineTo(...o.points[0]), r;
193
+ const s = new Path2D();
194
+ s.moveTo(...a.points[0]);
195
+ for (const n of a.points.slice(1))
196
+ s.lineTo(...n);
197
+ return s.lineTo(...a.points[0]), s;
203
198
  })(e);
204
- return { ...e, path: n, selection: Yt(n, e, i, t) };
205
- }, Ki = Je, ui = (e, i) => {
206
- const t = Math.min(...e.points.map((r) => r[0])) - i, n = Math.max(...e.points.map((r) => r[0])) + i, o = Math.min(...e.points.map((r) => r[1])) - i;
207
- return { x: t, width: n - t, y: o, height: Math.max(...e.points.map((r) => r[1])) + i - o };
208
- }, Ke = (e, i, t) => {
209
- const n = ((o) => {
210
- if (o.points.length < 3)
199
+ return { ...e, path: t, selection: Ut(t, e, i) };
200
+ }, k1 = _e, c1 = (e, i) => {
201
+ const t = Math.min(...e.points.map((n) => n[0])) - i.selectionPadding, a = Math.max(...e.points.map((n) => n[0])) + i.selectionPadding, s = Math.min(...e.points.map((n) => n[1])) - i.selectionPadding;
202
+ return { x: t, width: a - t, y: s, height: Math.max(...e.points.map((n) => n[1])) + i.selectionPadding - s };
203
+ }, qe = (e, i) => {
204
+ const t = ((a) => {
205
+ if (a.points.length < 3)
211
206
  return;
212
- const r = new Path2D();
213
- r.moveTo(...o.points[0]);
214
- for (let s = 1; s < o.points.length - 1; s++)
215
- r.quadraticCurveTo(...o.points[s], o.points.length - 2 === s ? o.points[s + 1][0] : (o.points[s + 1][0] - o.points[s][0]) / 2 + o.points[s][0], o.points.length - 2 === s ? o.points[s + 1][1] : (o.points[s + 1][1] - o.points[s][1]) / 2 + o.points[s][1]);
216
- return r;
207
+ const s = new Path2D();
208
+ s.moveTo(...a.points[0]);
209
+ for (let n = 1; n < a.points.length - 1; n++)
210
+ s.quadraticCurveTo(...a.points[n], a.points.length - 2 === n ? a.points[n + 1][0] : (a.points[n + 1][0] - a.points[n][0]) / 2 + a.points[n][0], a.points.length - 2 === n ? a.points[n + 1][1] : (a.points[n + 1][1] - a.points[n][1]) / 2 + a.points[n][1]);
211
+ return s;
217
212
  })(e);
218
- return { ...e, path: n, selection: Yt(n, e, i, t, !0) };
219
- }, ea = Ke, ta = ui, vt = (e, i, t) => {
220
- const n = ((o) => {
221
- const r = new Path2D();
222
- return r.ellipse(o.x, o.y, o.radiusX, o.radiusY, 0, 0, 2 * Math.PI), r;
213
+ return { ...e, path: t, selection: Ut(t, e, i, !0) };
214
+ }, L1 = qe, V1 = c1, yt = (e, i) => {
215
+ const t = ((a) => {
216
+ const s = new Path2D();
217
+ return s.ellipse(a.x, a.y, a.radiusX, a.radiusY, 0, 0, 2 * Math.PI), s;
223
218
  })(e);
224
- return { ...e, path: n, selection: tt(n, e, i, t) };
225
- }, ia = vt, v1 = (e) => {
226
- return t = { ...e, type: "triangle" }, { ...t, path: _i(t) };
219
+ return { ...e, path: t, selection: Ke(t, e, i) };
220
+ }, P1 = yt, pi = (e) => {
221
+ return t = { ...e, type: "triangle" }, { ...t, path: b1(t) };
227
222
  var t;
228
- }, aa = (e, i) => {
223
+ }, H1 = (e, i) => {
229
224
  e.globalAlpha !== 0 && i.path && (i.style?.fillColor !== "transparent" && e.fill(i.path), i.style?.strokeColor !== "transparent" && e.stroke(i.path));
230
- }, mt = (e, i, t) => {
231
- const n = [];
232
- let o;
225
+ }, Qt = (e, i) => {
226
+ const t = [];
227
+ let a;
233
228
  if (e.style?.lineArrow === 1 || e.style?.lineArrow === 2 || e.style?.lineArrow === 3) {
234
- const r = Math.PI / 2 - c1({ targetVector: [e.points[0], e.points[1]] });
235
- e.style?.lineArrow !== 1 && e.style?.lineArrow !== 3 || n.push(v1(m1(e.points[0], r, e.style))), e.style?.lineArrow !== 2 && e.style?.lineArrow !== 3 || n.push(v1(m1(e.points[1], r + Math.PI, e.style)));
236
- const s = (({ line: a, size: l, direction: p }) => {
237
- const c = Math.PI / 2 - c1({ targetVector: [a.points[0], a.points[1]] }), d = [a.points[0][0] + (a.points[1][0] - a.points[0][0]) / 2, a.points[0][1] + (a.points[1][1] - a.points[0][1]) / 2];
238
- let u, f;
239
- if (["start", "both"].includes(p)) {
240
- const g = fe({ point: a.points[0], origin: d, rotation: -c });
241
- u = fe({ point: [g[0], g[1] + l], origin: d, rotation: c });
229
+ const s = Math.PI / 2 - oi({ targetVector: [e.points[0], e.points[1]] });
230
+ e.style?.lineArrow !== 1 && e.style?.lineArrow !== 3 || t.push(pi(ui(e.points[0], s, e.style))), e.style?.lineArrow !== 2 && e.style?.lineArrow !== 3 || t.push(pi(ui(e.points[1], s + Math.PI, e.style)));
231
+ const n = (({ line: o, size: r, direction: l }) => {
232
+ const c = Math.PI / 2 - oi({ targetVector: [o.points[0], o.points[1]] }), d = [o.points[0][0] + (o.points[1][0] - o.points[0][0]) / 2, o.points[0][1] + (o.points[1][1] - o.points[0][1]) / 2];
233
+ let h, u;
234
+ if (["start", "both"].includes(l)) {
235
+ const g = ve({ point: o.points[0], origin: d, rotation: -c });
236
+ h = ve({ point: [g[0], g[1] + r], origin: d, rotation: c });
242
237
  } else
243
- u = [...a.points[0]];
244
- if (["end", "both"].includes(p)) {
245
- const g = fe({ point: a.points[1], origin: d, rotation: -c });
246
- f = fe({ point: [g[0], g[1] - l], origin: d, rotation: c });
238
+ h = [...o.points[0]];
239
+ if (["end", "both"].includes(l)) {
240
+ const g = ve({ point: o.points[1], origin: d, rotation: -c });
241
+ u = ve({ point: [g[0], g[1] - r], origin: d, rotation: c });
247
242
  } else
248
- f = [...a.points[1]];
249
- return { points: [u, f] };
243
+ u = [...o.points[1]];
244
+ return { points: [h, u] };
250
245
  })({ line: e, size: 10 + 2 * (e.style?.lineWidth ?? 0), direction: e.style?.lineArrow === 1 ? "start" : e.style?.lineArrow === 2 ? "end" : "both" });
251
- o = Nt(s);
246
+ a = Dt(n);
252
247
  } else
253
- o = Nt(e);
254
- return { ...e, path: o, selection: Yt(o, e, i, t), arrows: n, style: { ...e.style, lineCap: e.style?.lineArrow ? "butt" : "round" } };
255
- }, na = mt, m1 = (e, i, t) => {
256
- const n = [fe({ point: [0, 0], rotation: i }), fe({ point: [-(5 + (t.lineWidth ?? 0)), 10 + 2 * (t.lineWidth ?? 0)], rotation: i }), fe({ point: [5 + (t.lineWidth ?? 0), 10 + 2 * (t.lineWidth ?? 0)], rotation: i })];
257
- return { points: [[e[0] + n[0][0], e[1] + n[0][1]], [e[0] + n[1][0], e[1] + n[1][1]], [e[0] + n[2][0], e[1] + n[2][1]]], style: { ...t, fillColor: t.strokeColor, strokeColor: "transparent" } };
258
- }, yt = (e) => e.filter((i) => i != null), oa = (e) => {
259
- const i = ["img", "id", "selection", "path", "arrows"];
260
- return e.map((t) => t.type !== "picture" || t.src.startsWith("http") ? Et(i, t) : Et(i, { ...t, src: sa(t.img) }));
261
- }, hi = (e, i, t) => ({ shapes: oa(e), config: { width: i, height: t } }), y1 = (e, i, t) => st({ ...e, id: ae(`${e.type}_`) }, i, t), gi = (e) => {
262
- const i = new DOMParser().parseFromString(e, "text/xml").getElementsByTagName("svg")[0], t = i.getAttribute("width"), n = i.getAttribute("height");
263
- let o;
264
- if (t || n)
265
- o = e;
266
- else {
267
- const s = i.getAttribute("viewBox") ?? "0 0 300 300", [, , a, l] = s.split(" ");
268
- i.setAttribute("width", a ?? gt), i.setAttribute("height", l ?? gt), o = new XMLSerializer().serializeToString(i);
269
- }
270
- const r = new Blob([o], { type: "image/svg+xml" });
271
- return URL.createObjectURL(r);
272
- }, fi = (e) => (e instanceof File ? e.name : e).includes(".svg"), vi = (e) => fi(e) ? fetch(e).then((i) => i.text()).then((i) => gi(i)) : fetch(e).then((i) => i.blob()).then((i) => URL.createObjectURL(i)), Q1 = (e, i) => {
273
- const t = document.createElement("a");
274
- t.href = e, t.download = i, document.body.appendChild(t), t.click(), document.body.removeChild(t);
275
- }, sa = (e) => {
276
- const i = document.createElement("canvas");
277
- i.width = e.width, i.height = e.height;
278
- const t = i.getContext("2d");
279
- return t ? (t.drawImage(e, 0, 0), i.toDataURL("image/png")) : "";
280
- }, b1 = (e, i, t, n, o) => {
281
- const r = document.createElement("canvas");
282
- r.width = t, r.height = n;
283
- const s = r.getContext("2d");
284
- if (!s)
285
- return "";
286
- s.clearRect(0, 0, t, n), li(s);
287
- for (let a = e.length - 1; a >= 0; a--)
288
- mi(s, e[a], 1, i, o);
289
- return r.toDataURL("image/png");
290
- }, ra = (e, i, t) => {
291
- return o = hi(e, i, t), `data:text/plain;charset=utf-8,${encodeURIComponent(JSON.stringify(o))}`;
292
- var o;
293
- }, Qt = (e, i, t) => {
294
- const n = ut(e);
295
- return { ...e, path: n, selection: tt(n, e, i, t) };
296
- }, la = Qt, da = (e, i) => {
248
+ a = Dt(e);
249
+ return { ...e, path: a, selection: Ut(a, e, i), arrows: t, style: { ...e.style, lineCap: e.style?.lineArrow ? "butt" : "round" } };
250
+ }, T1 = Qt, ui = (e, i, t) => {
251
+ const a = [ve({ point: [0, 0], rotation: i }), ve({ point: [-(5 + (t.lineWidth ?? 0)), 10 + 2 * (t.lineWidth ?? 0)], rotation: i }), ve({ point: [5 + (t.lineWidth ?? 0), 10 + 2 * (t.lineWidth ?? 0)], rotation: i })];
252
+ 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: { ...t, fillColor: t.strokeColor, strokeColor: "transparent" } };
253
+ }, St = (e, i) => {
254
+ const t = gt(e);
255
+ return { ...e, path: t, selection: Ke(t, e, i) };
256
+ }, A1 = St, Z1 = (e, i) => {
297
257
  e.globalAlpha !== 0 && i.path && (i.style?.fillColor !== "transparent" && e.fill(i.path), i.style?.strokeColor !== "transparent" && e.stroke(i.path));
298
- }, S1 = (e, i) => ({ x: e.x - i, width: e.width + 2 * i, y: e.y - i, height: e.height + 2 * i }), C1 = (e, i, t, n, [o, r] = [!1, !1]) => ((s, a, [l, p], [c, d]) => fe({ origin: [l - c, p - d], point: s, rotation: -a }))([e[0] === 0.5 ? t.x + t.width / 2 : e[0] === 0 ? t.x + (o ? 0 : t.width) : t.x + (o ? t.width : 0), e[1] === 0.5 ? t.y + t.height / 2 : e[1] === 0 ? t.y + (r ? 0 : t.height) : t.y + (r ? t.height : 0)], t.rotation, i, n), bt = (e, i, t) => ({ ...e, selection: tt(void 0, e, i, t) }), ca = bt, x1 = (e, i, t, n, o, r) => {
299
- const [s, a] = ((l, p, c, d, u = !1) => {
300
- if (!(l && p && d && c))
301
- return [gt, gt];
302
- const f = l / p;
303
- if (f > c / d) {
304
- const v = u ? c : Math.min(l, c);
305
- return [v, v / f];
258
+ }, gi = (e, i) => ({ x: e.x - i.selectionPadding, width: e.width + 2 * i.selectionPadding, y: e.y - i.selectionPadding, height: e.height + 2 * i.selectionPadding }), vi = (e, i, t, a, [s, n] = [!1, !1]) => ((o, r, [l, c], [d, h]) => ve({ origin: [l - d, c - h], point: o, rotation: -r }))([e[0] === 0.5 ? t.x + t.width / 2 : e[0] === 0 ? t.x + (s ? 0 : t.width) : t.x + (s ? t.width : 0), e[1] === 0.5 ? t.y + t.height / 2 : e[1] === 0 ? t.y + (n ? 0 : t.height) : t.y + (n ? t.height : 0)], t.rotation, i, a.canvasOffset), bt = (e, i) => ({ ...e, selection: Ke(void 0, e, i) }), E1 = bt, fi = (e, i, t, a, s) => {
259
+ const [n, o] = ((r, l, c, d, h = !1) => {
260
+ if (!(r && l && d && c))
261
+ return [ut, ut];
262
+ const u = r / l;
263
+ if (u > c / d) {
264
+ const v = h ? c : Math.min(r, c);
265
+ return [v, v / u];
306
266
  }
307
- const g = u ? d : Math.min(p, d);
308
- return [g * f, g];
309
- })(e.width, e.height, t, n, !0);
310
- return bt({ toolId: Bt.id, type: "picture", id: ae("picture_"), x: (t - s) / 2, y: (n - a) / 2, width: s, height: a, src: i, img: e, rotation: 0 }, o, r);
311
- }, pa = (e, i, t, n, o) => new Promise((r, s) => {
312
- const a = new Image();
313
- a.onerror = () => {
314
- s(new Error("Some images could not be loaded"));
267
+ const g = h ? d : Math.min(l, d);
268
+ return [g * u, g];
269
+ })(e.width, e.height, t, a, !0);
270
+ return bt({ toolId: Ot.id, type: "picture", id: se("picture_"), x: (t - n) / 2, y: (a - o) / 2, width: n, height: o, src: i, img: e, rotation: 0 }, s);
271
+ }, F1 = (e, i, t, a) => new Promise((s, n) => {
272
+ const o = new Image();
273
+ o.onerror = () => {
274
+ n(new Error("Some images could not be loaded"));
315
275
  }, setTimeout(() => {
316
- s(new Error("Timeout while loading images"));
317
- }, 4e3), e instanceof File ? ((l, p, c, d, u, f, g) => {
318
- const v = URL.createObjectURL(c);
319
- l.onload = async () => {
320
- if (URL.revokeObjectURL(l.src), fi(c) && !l.width && !l.height) {
321
- const x = await c.text(), w = gi(x);
322
- if (v === l.src)
323
- return void (l.src = w);
276
+ n(new Error("Timeout while loading images"));
277
+ }, 4e3), e instanceof File ? ((r, l, c, d, h, u) => {
278
+ const g = URL.createObjectURL(c);
279
+ r.onload = async () => {
280
+ if (URL.revokeObjectURL(r.src), u1(c) && !r.width && !r.height) {
281
+ const x = await c.text(), M = p1(x);
282
+ if (g === r.src)
283
+ return void (r.src = M);
324
284
  }
325
- const C = x1(l, l.src, d, u, f, g);
326
- p(C);
327
- }, l.src = v;
328
- })(a, r, e, i, t, n, o) : ((l, p, c, d, u, f, g) => {
329
- l.onload = () => {
330
- URL.revokeObjectURL(l.src);
331
- const v = x1(l, c, d, u, f, g);
332
- p(v);
333
- }, vi(c).then((v) => {
334
- l.src = v;
285
+ const v = fi(r, r.src, d, h, u);
286
+ l(v);
287
+ }, r.src = g;
288
+ })(o, s, e, i, t, a) : ((r, l, c, d, h, u) => {
289
+ r.onload = () => {
290
+ URL.revokeObjectURL(r.src);
291
+ const g = fi(r, c, d, h, u);
292
+ l(g);
293
+ }, g1(c).then((g) => {
294
+ r.src = g;
335
295
  }).catch(() => {
336
- l.src = "";
296
+ r.src = "";
337
297
  });
338
- })(a, r, e, i, t, n, o);
339
- }), Pt = ["Texte"], St = (e, i, t) => ({ ...e, selection: tt(void 0, e, i, t) }), ua = St, _t = (e, i, t, n, o, r = rt) => {
340
- e.font = `${o ? "italic" : ""} ${n ? "bold" : ""} 1px ${r}`;
341
- const s = i.map((a) => t / e.measureText(a).width);
342
- return Math.min(...s) || 36;
343
- }, ha = (e, i, t, n, o) => {
344
- const r = { ...i, value: t }, s = ((v, C, x, w, y, b = rt) => {
345
- v.font = `${y ? "italic" : ""} ${w ? "bold" : ""} ${x}px ${b}`;
346
- const H = C.map((A) => v.measureText(A).width);
347
- return Math.max(...H) || 20;
348
- })(e, r.value, r.fontSize, r.style?.fontBold ?? !1, r.style?.fontItalic ?? !1, r.style?.fontFamily), a = r.fontSize * r.value.length, l = { ...r, width: s, height: a }, { center: p } = G(i, n), { center: c } = G(l, n), [d, u] = C1([1, 1], p, i, o), [f, g] = C1([1, 1], c, l, o, [!1, !1]);
349
- return { ...l, x: l.x - (f - d), y: l.y - (g - u) };
350
- }, w1 = (e, i, t, n, o, r) => {
351
- const s = [z(t[0], n), z(t[1], n)];
298
+ })(o, s, e, i, t, a);
299
+ }), At = ["Texte"], Ct = (e, i) => ({ ...e, selection: Ke(void 0, e, i) }), D1 = Ct, Bt = (e, i, t, a, s, n = ot) => {
300
+ e.font = `${s ? "italic" : ""} ${a ? "bold" : ""} 1px ${n}`;
301
+ const o = i.map((r) => t / e.measureText(r).width);
302
+ return Math.min(...o) || 36;
303
+ }, N1 = (e, i, t, a) => {
304
+ const s = { ...i, value: t }, n = ((v, x, M, y, P, Q = ot) => {
305
+ v.font = `${P ? "italic" : ""} ${y ? "bold" : ""} ${M}px ${Q}`;
306
+ const L = x.map((T) => v.measureText(T).width);
307
+ return Math.max(...L) || 20;
308
+ })(e, s.value, s.fontSize, s.style?.fontBold ?? !1, s.style?.fontItalic ?? !1, s.style?.fontFamily), o = s.fontSize * s.value.length, r = { ...s, width: n, height: o }, { center: l } = Y(i, a), { center: c } = Y(r, a), [d, h] = vi([1, 1], l, i, a), [u, g] = vi([1, 1], c, r, a, [!1, !1]);
309
+ return { ...r, x: r.x - (u - d), y: r.y - (g - h) };
310
+ }, mi = (e, i, t, a) => {
311
+ const s = [O(t[0], a), O(t[1], a)];
352
312
  switch (i.type) {
353
313
  case "brush":
354
- return ((a, l, p, c) => et({ toolId: a.id, type: a.type, id: ae(`${a.type}_`), points: [[l]], rotation: 0, scaleX: 1, scaleY: 1, style: { opacity: a.settings.opacity.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } }, p, c))(i, s, o, r);
314
+ return ((n, o, r) => Je({ toolId: n.id, type: n.type, id: se(`${n.type}_`), points: [[o]], rotation: 0, scaleX: 1, scaleY: 1, style: { opacity: n.settings.opacity.default, strokeColor: n.settings.strokeColor.default, lineWidth: n.settings.lineWidth.default, lineDash: n.settings.lineDash.default } }, r))(i, s, a);
355
315
  case "line":
356
- return ((a, l, p, c) => {
357
- const d = { toolId: a.id, type: a.type, id: ae(`${a.type}_`), points: [l, l], rotation: 0, style: { opacity: a.settings.opacity.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default, lineArrow: a.settings.lineArrow.default } };
358
- return mt(d, p, c);
359
- })(i, s, o, r);
316
+ return ((n, o, r) => {
317
+ const l = { toolId: n.id, type: n.type, id: se(`${n.type}_`), points: [o, o], rotation: 0, style: { opacity: n.settings.opacity.default, strokeColor: n.settings.strokeColor.default, lineWidth: n.settings.lineWidth.default, lineDash: n.settings.lineDash.default, lineArrow: n.settings.lineArrow.default } };
318
+ return Qt(l, r);
319
+ })(i, s, a);
360
320
  case "polygon":
361
- return ((a, l, p, c) => Je({ toolId: a.id, type: a.type, id: ae(`${a.type}_`), points: new Array(a.settings.pointsCount.default).fill(l), rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default, pointsCount: a.settings.pointsCount.default } }, p, c))(i, s, o, r);
321
+ return ((n, o, r) => _e({ toolId: n.id, type: n.type, id: se(`${n.type}_`), points: new Array(n.settings.pointsCount.default).fill(o), rotation: 0, style: { opacity: n.settings.opacity.default, fillColor: n.settings.fillColor.default, strokeColor: n.settings.strokeColor.default, lineWidth: n.settings.lineWidth.default, lineDash: n.settings.lineDash.default, pointsCount: n.settings.pointsCount.default } }, r))(i, s, a);
362
322
  case "curve":
363
- return ((a, l, p, c) => Ke({ toolId: a.id, type: a.type, id: ae(`${a.type}_`), points: new Array(a.settings.pointsCount.default).fill(l), rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default, pointsCount: a.settings.pointsCount.default } }, p, c))(i, s, o, r);
323
+ return ((n, o, r) => qe({ toolId: n.id, type: n.type, id: se(`${n.type}_`), points: new Array(n.settings.pointsCount.default).fill(o), rotation: 0, style: { opacity: n.settings.opacity.default, fillColor: n.settings.fillColor.default, strokeColor: n.settings.strokeColor.default, lineWidth: n.settings.lineWidth.default, lineDash: n.settings.lineDash.default, pointsCount: n.settings.pointsCount.default } }, r))(i, s, a);
364
324
  case "rect":
365
325
  case "square":
366
- return ((a, l, p, c, d = 0, u = 0) => {
367
- const f = { toolId: a.id, type: a.type, id: ae(`${a.type}_`), x: l[0], y: l[1], width: d, height: u, rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } };
368
- return Qt(f, p, c);
369
- })(i, s, o, r);
326
+ return ((n, o, r, l = 0, c = 0) => {
327
+ const d = { toolId: n.id, type: n.type, id: se(`${n.type}_`), x: o[0], y: o[1], width: l, height: c, rotation: 0, style: { opacity: n.settings.opacity.default, fillColor: n.settings.fillColor.default, strokeColor: n.settings.strokeColor.default, lineWidth: n.settings.lineWidth.default, lineDash: n.settings.lineDash.default } };
328
+ return St(d, r);
329
+ })(i, s, a);
370
330
  case "text":
371
- return ((a, l, p, c, d) => {
372
- const u = _t(a, Pt, 50, l.settings?.fontBold.default ?? !1, l.settings?.fontItalic.default ?? !1, l.settings.fontFamily.default);
373
- return St({ toolId: l.id, type: l.type, id: ae(`${l.type}_`), x: p[0], y: p[1], value: Pt, fontSize: u, width: 50, height: u * (Pt.length || 1), rotation: 0, style: { opacity: l.settings.opacity.default, strokeColor: l.settings.strokeColor.default, fontFamily: l.settings.fontFamily.default, fontItalic: l.settings.fontItalic.default, fontBold: l.settings.fontBold.default } }, c, d);
374
- })(e, i, s, o, r);
331
+ return ((n, o, r, l) => {
332
+ const c = Bt(n, At, 50, o.settings?.fontBold.default ?? !1, o.settings?.fontItalic.default ?? !1, o.settings.fontFamily.default);
333
+ return Ct({ toolId: o.id, type: o.type, id: se(`${o.type}_`), x: r[0], y: r[1], value: At, fontSize: c, width: 50, height: c * (At.length || 1), rotation: 0, style: { opacity: o.settings.opacity.default, strokeColor: o.settings.strokeColor.default, fontFamily: o.settings.fontFamily.default, fontItalic: o.settings.fontItalic.default, fontBold: o.settings.fontBold.default } }, l);
334
+ })(e, i, s, a);
375
335
  case "ellipse":
376
- return ((a, l, p, c) => vt({ toolId: a.id, type: a.type, id: ae(`${a.type}_`), x: l[0], y: l[1], radiusX: 0, radiusY: 0, rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } }, p, c))(i, s, o, r);
336
+ return ((n, o, r) => yt({ toolId: n.id, type: n.type, id: se(`${n.type}_`), x: o[0], y: o[1], radiusX: 0, radiusY: 0, rotation: 0, style: { opacity: n.settings.opacity.default, fillColor: n.settings.fillColor.default, strokeColor: n.settings.strokeColor.default, lineWidth: n.settings.lineWidth.default, lineDash: n.settings.lineDash.default } }, r))(i, s, a);
377
337
  case "circle":
378
- return ((a, l, p, c) => ft({ toolId: a.id, type: a.type, id: ae(`${a.type}_`), x: l[0], y: l[1], radius: 0, rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } }, p, c))(i, s, o, r);
338
+ return ((n, o, r) => mt({ toolId: n.id, type: n.type, id: se(`${n.type}_`), x: o[0], y: o[1], radius: 0, rotation: 0, style: { opacity: n.settings.opacity.default, fillColor: n.settings.fillColor.default, strokeColor: n.settings.strokeColor.default, lineWidth: n.settings.lineWidth.default, lineDash: n.settings.lineDash.default } }, r))(i, s, a);
379
339
  }
380
- }, mi = (e, i, t, n, o) => {
340
+ }, h1 = (e, i, t) => {
381
341
  if (i.visible === !1)
382
342
  return;
383
- const { center: r } = G(i, o);
384
- switch (Xt(e, t, n, i.rotation, r), ze(e, i.style), i.type) {
343
+ const { center: a } = Y(i, t);
344
+ switch (Gt(e, t, i.rotation, a), ze(e, i.style), i.type) {
385
345
  case "brush":
386
- ((s, a) => {
387
- a.points.length < 1 || !a.path || s.globalAlpha !== 0 && a.style?.strokeColor !== "transparent" && s.globalAlpha !== 0 && s.stroke(a.path);
346
+ ((s, n) => {
347
+ n.points.length < 1 || !n.path || s.globalAlpha !== 0 && n.style?.strokeColor !== "transparent" && s.globalAlpha !== 0 && s.stroke(n.path);
388
348
  })(e, i);
389
349
  break;
390
350
  case "text":
391
- ((s, a) => {
392
- if (s.globalAlpha !== 0 && a.style?.strokeColor && a.style.strokeColor !== "transparent") {
393
- s.font = `${a.style?.fontItalic ? "italic" : ""} ${a.style?.fontBold ? "bold" : ""} ${a.fontSize}px ${a.style?.fontFamily ?? rt}`, s.textBaseline = "top", s.fillStyle = a.style.strokeColor;
394
- for (let l = 0; l < a.value.length; l++)
395
- s.fillText(a.value[l], a.x, a.y + l * a.fontSize, a.width);
351
+ ((s, n) => {
352
+ if (s.globalAlpha !== 0 && n.style?.strokeColor && n.style.strokeColor !== "transparent") {
353
+ s.font = `${n.style?.fontItalic ? "italic" : ""} ${n.style?.fontBold ? "bold" : ""} ${n.fontSize}px ${n.style?.fontFamily ?? ot}`, s.textBaseline = "top", s.fillStyle = n.style.strokeColor;
354
+ for (let o = 0; o < n.value.length; o++)
355
+ s.fillText(n.value[o], n.x, n.y + o * n.fontSize, n.width);
396
356
  }
397
357
  })(e, i);
398
358
  break;
399
359
  case "line":
400
- ((s, a) => {
401
- if (s.globalAlpha !== 0 && a.path) {
402
- a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path);
403
- for (const l of a.arrows ?? [])
404
- ze(s, l.style), aa(s, l);
360
+ ((s, n) => {
361
+ if (s.globalAlpha !== 0 && n.path) {
362
+ n.style?.fillColor !== "transparent" && s.fill(n.path), n.style?.strokeColor !== "transparent" && s.stroke(n.path);
363
+ for (const o of n.arrows ?? [])
364
+ ze(s, o.style), H1(s, o);
405
365
  }
406
366
  })(e, i);
407
367
  break;
408
368
  case "polygon":
409
- ((s, a) => {
410
- a.path && s.globalAlpha !== 0 && (a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path));
369
+ ((s, n) => {
370
+ n.path && s.globalAlpha !== 0 && (n.style?.fillColor !== "transparent" && s.fill(n.path), n.style?.strokeColor !== "transparent" && s.stroke(n.path));
411
371
  })(e, i);
412
372
  break;
413
373
  case "curve":
414
- ((s, a) => {
415
- a.path && s.globalAlpha !== 0 && (a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path));
374
+ ((s, n) => {
375
+ n.path && s.globalAlpha !== 0 && (n.style?.fillColor !== "transparent" && s.fill(n.path), n.style?.strokeColor !== "transparent" && s.stroke(n.path));
416
376
  })(e, i);
417
377
  break;
418
378
  case "circle":
419
- ((s, a) => {
420
- s.globalAlpha !== 0 && a.path && (a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path));
379
+ ((s, n) => {
380
+ s.globalAlpha !== 0 && n.path && (n.style?.fillColor !== "transparent" && s.fill(n.path), n.style?.strokeColor !== "transparent" && s.stroke(n.path));
421
381
  })(e, i);
422
382
  break;
423
383
  case "ellipse":
424
- ((s, a) => {
425
- s.globalAlpha !== 0 && a.path && (a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path));
384
+ ((s, n) => {
385
+ s.globalAlpha !== 0 && n.path && (n.style?.fillColor !== "transparent" && s.fill(n.path), n.style?.strokeColor !== "transparent" && s.stroke(n.path));
426
386
  })(e, i);
427
387
  break;
428
388
  case "rect":
429
389
  case "square":
430
- da(e, i);
390
+ Z1(e, i);
431
391
  break;
432
392
  case "picture":
433
- ((s, a) => {
434
- s.globalAlpha !== 0 && (s.beginPath(), s.drawImage(a.img, a.x, a.y, a.width, a.height));
393
+ ((s, n) => {
394
+ s.globalAlpha !== 0 && (s.beginPath(), s.drawImage(n.img, n.x, n.y, n.width, n.height));
435
395
  })(e, i);
436
396
  }
437
397
  e.restore();
438
- }, ga = (e, i) => {
398
+ }, R1 = (e, i) => {
439
399
  switch (e.type) {
440
400
  case "brush":
441
- return ((t, n) => {
442
- const o = t.points.flat(), r = Math.min(...o.map((c) => c[0])), s = Math.min(...o.map((c) => c[1])), a = o.map((c) => Ue(c, r, s, t.scaleX, t.scaleY)), l = Math.max(...a.map((c) => c[0])) + n, p = Math.max(...a.map((c) => c[1])) + n;
443
- return { x: r - n, width: l - r + n, y: s - n, height: p - s + n };
401
+ return ((t, { selectionPadding: a }) => {
402
+ const s = t.points.flat(), n = Math.min(...s.map((d) => d[0])), o = Math.min(...s.map((d) => d[1])), r = s.map((d) => Se(d, n, o, t.scaleX, t.scaleY)), l = Math.max(...r.map((d) => d[0])) + a, c = Math.max(...r.map((d) => d[1])) + a;
403
+ return { x: n - a, width: l - n + a, y: o - a, height: c - o + a };
444
404
  })(e, i);
445
405
  case "line":
446
- return ((t, n) => ({ x: Math.min(t.points[0][0], t.points[1][0]) - n, width: Math.abs(t.points[0][0] - t.points[1][0]) + 2 * n, y: Math.min(t.points[0][1], t.points[1][1]) - n, height: Math.abs(t.points[0][1] - t.points[1][1]) + 2 * n }))(e, i);
406
+ return ((t, a) => ({ x: Math.min(t.points[0][0], t.points[1][0]) - a.selectionPadding, width: Math.abs(t.points[0][0] - t.points[1][0]) + 2 * a.selectionPadding, y: Math.min(t.points[0][1], t.points[1][1]) - a.selectionPadding, height: Math.abs(t.points[0][1] - t.points[1][1]) + 2 * a.selectionPadding }))(e, i);
447
407
  case "polygon":
448
- return ui(e, i);
408
+ return c1(e, i);
449
409
  case "curve":
450
- return ta(e, i);
410
+ return V1(e, i);
451
411
  case "circle":
452
- return ((t, n) => ({ x: t.x - t.radius - n, width: 2 * (t.radius + n), y: t.y - t.radius - n, height: 2 * (t.radius + n) }))(e, i);
412
+ return ((t, a) => ({ x: t.x - t.radius - a.selectionPadding, width: 2 * (t.radius + a.selectionPadding), y: t.y - t.radius - a.selectionPadding, height: 2 * (t.radius + a.selectionPadding) }))(e, i);
453
413
  case "ellipse":
454
- return ((t, n) => ({ x: t.x - t.radiusX - n, width: 2 * (t.radiusX + n), y: t.y - t.radiusY - n, height: 2 * (t.radiusY + n) }))(e, i);
414
+ return ((t, a) => ({ x: t.x - t.radiusX - a.selectionPadding, width: 2 * (t.radiusX + a.selectionPadding), y: t.y - t.radiusY - a.selectionPadding, height: 2 * (t.radiusY + a.selectionPadding) }))(e, i);
455
415
  case "rect":
456
416
  case "square":
457
- return S1(e, i);
417
+ return gi(e, i);
458
418
  case "text":
459
- return ((t, n) => ({ x: t.x - n, width: t.width + 2 * n, y: t.y - n, height: t.height + 2 * n }))(e, i);
419
+ return ((t, a) => ({ x: t.x - a.selectionPadding, width: t.width + 2 * a.selectionPadding, y: t.y - a.selectionPadding, height: t.height + 2 * a.selectionPadding }))(e, i);
460
420
  case "picture":
461
- return ((t, n) => S1(t, n))(e, i);
421
+ return ((t, a) => gi(t, a))(e, i);
462
422
  default:
463
423
  return { x: 0, y: 0, width: 100, height: 100 };
464
424
  }
465
- }, G = (e, i) => {
466
- const t = ga(e, i), n = ((o) => [o.x + o.width / 2, o.y + o.height / 2])(t);
467
- return { borders: t, center: n };
468
- }, fa = (e, i, t, n, o, r) => {
469
- const s = o[0] - n[0], a = o[1] - n[1], l = o[0] - i[0], p = o[1] - i[1], c = t.rotation + Math.atan2(p, l) - Math.atan2(a, s);
470
- return { ...e, rotation: qi(c, r) };
471
- }, va = (e, i, t, n, o, r, s, a, l, p) => {
472
- switch (o.type) {
425
+ }, Y = (e, i) => {
426
+ const t = R1(e, i), a = ((s) => [s.x + s.width / 2, s.y + s.height / 2])(t);
427
+ return { borders: t, center: a };
428
+ }, I1 = (e, i, t, a, s, n) => {
429
+ const o = s[0] - a[0], r = s[1] - a[1], l = s[0] - i[0], c = s[1] - i[1], d = t.rotation + Math.atan2(c, l) - Math.atan2(r, o);
430
+ return { ...e, rotation: w1(d, n) };
431
+ }, W1 = (e, i, t, a, s, n, o) => {
432
+ switch (a.type) {
473
433
  case "line":
474
- return ((c, d, u, f, g, v, C) => {
475
- const x = [z(c[0], g), z(c[1], g)], { center: w } = G(u, v), y = Be(x, u.rotation, w, d), b = ce(["points", f.anchor], y, u);
476
- return mt(b, C, v);
477
- })(t, n, o, r, s, a, p);
434
+ return ((r, l, c, d) => {
435
+ const h = [O(r[0], d), O(r[1], d)], { center: u } = Y(l, d), g = $e(h, l.rotation, u, d.canvasOffset), v = le(["points", c.anchor], g, l);
436
+ return Qt(v, d);
437
+ })(t, a, s, n);
478
438
  case "polygon":
479
- return ((c, d, u, f, g, v, C) => {
480
- const x = [z(c[0], g), z(c[1], g)], { center: w } = G(u, v), y = Be(x, u.rotation, w, d), b = ce(["points", f.anchor], y, u);
481
- return Je(b, C, v);
482
- })(t, n, o, r, s, a, p);
439
+ return ((r, l, c, d) => {
440
+ const h = [O(r[0], d), O(r[1], d)], { center: u } = Y(l, d), g = $e(h, l.rotation, u, d.canvasOffset), v = le(["points", c.anchor], g, l);
441
+ return _e(v, d);
442
+ })(t, a, s, n);
483
443
  case "curve":
484
- return ((c, d, u, f, g, v, C) => {
485
- const x = [z(c[0], g), z(c[1], g)], { center: w } = G(u, v), y = Be(x, u.rotation, w, d), b = ce(["points", f.anchor], y, u);
486
- return Ke(b, C, v);
487
- })(t, n, o, r, s, a, p);
444
+ return ((r, l, c, d) => {
445
+ const h = [O(r[0], d), O(r[1], d)], { center: u } = Y(l, d), g = $e(h, l.rotation, u, d.canvasOffset), v = le(["points", c.anchor], g, l);
446
+ return qe(v, d);
447
+ })(t, a, s, n);
488
448
  case "brush":
489
- return ((c, d, u, f, g, v, C) => {
490
- const { borders: x } = G({ ...d, scaleX: 1, scaleY: 1 }, g), { borders: w } = G(d, g), { borderX: y, borderHeight: b, borderY: H, borderWidth: A } = _e(c, d, u, f, g, C), Z = Math.max(0, x.width - 2 * g), F = Math.max(0, x.height - 2 * g), E = Math.max(0, A - 2 * g), S = Math.max(0, b - 2 * g), T = Z ? E / Z : 1, M = F ? S / F : 1;
491
- if (!Z || !F)
492
- return d;
493
- const B = Fe(y - w.x), N = Fe(H - w.y);
494
- return et({ ...d, points: d.points.map((Q) => Q.map(([k, m]) => [k + B, m + N])), scaleX: T, scaleY: M }, v, g);
495
- })(t, o, r, s, a, p, l);
449
+ return ((r, l, c, d, h) => {
450
+ const { borders: u } = Y({ ...l, scaleX: 1, scaleY: 1 }, d), { borders: g } = Y(l, d), { borderX: v, borderHeight: x, borderY: M, borderWidth: y } = Be(r, l, c, d, h), P = Math.max(0, u.width - 2 * d.selectionPadding), Q = Math.max(0, u.height - 2 * d.selectionPadding), L = Math.max(0, y - 2 * d.selectionPadding), T = Math.max(0, x - 2 * d.selectionPadding), E = P ? L / P : 1, Z = Q ? T / Q : 1;
451
+ if (!P || !Q)
452
+ return l;
453
+ const H = Fe(v - g.x), C = Fe(M - g.y);
454
+ return Je({ ...l, points: l.points.map((V) => V.map(([k, S]) => [k + H, S + C])), scaleX: E, scaleY: Z }, d);
455
+ })(t, a, s, n, o);
496
456
  case "circle":
497
- return ((c, d, u, f, g, v) => {
498
- const { borderX: C, borderHeight: x, borderY: w, borderWidth: y } = _e(c, d, u, f, g, !0);
499
- return ft({ ...d, radius: Math.max(0, y / 2 - g), x: C + y / 2, y: w + x / 2 }, v, g);
500
- })(t, o, r, s, a, p);
457
+ return ((r, l, c, d) => {
458
+ const { borderX: h, borderHeight: u, borderY: g, borderWidth: v } = Be(r, l, c, d, !0);
459
+ return mt({ ...l, radius: Math.max(0, v / 2 - d.selectionPadding), x: h + v / 2, y: g + u / 2 }, d);
460
+ })(t, a, s, n);
501
461
  case "ellipse":
502
- return ((c, d, u, f, g, v, C = !1) => {
503
- const { borderX: x, borderHeight: w, borderY: y, borderWidth: b } = _e(c, d, u, f, g, C);
504
- return vt({ ...d, radiusX: Math.max(0, b / 2 - g), radiusY: Math.max(0, w / 2 - g), x: x + b / 2, y: y + w / 2 }, v, g);
505
- })(t, o, r, s, a, p, l);
462
+ return ((r, l, c, d, h = !1) => {
463
+ const { borderX: u, borderHeight: g, borderY: v, borderWidth: x } = Be(r, l, c, d, h);
464
+ return yt({ ...l, radiusX: Math.max(0, x / 2 - d.selectionPadding), radiusY: Math.max(0, g / 2 - d.selectionPadding), x: u + x / 2, y: v + g / 2 }, d);
465
+ })(t, a, s, n, o);
506
466
  case "rect":
507
467
  case "square":
508
- return ((c, d, u, f, g, v, C = !1) => {
509
- const { borderX: x, borderHeight: w, borderY: y, borderWidth: b } = _e(c, d, u, f, g, C);
510
- return Qt({ ...d, width: Math.max(0, b - 2 * g), height: Math.max(0, w - 2 * g), x: x + g, y: y + g }, v, g);
511
- })(t, o, r, s, a, p, i.type === "square" || l);
468
+ return ((r, l, c, d, h = !1) => {
469
+ const { borderX: u, borderHeight: g, borderY: v, borderWidth: x } = Be(r, l, c, d, h);
470
+ return St({ ...l, width: Math.max(0, x - 2 * d.selectionPadding), height: Math.max(0, g - 2 * d.selectionPadding), x: u + d.selectionPadding, y: v + d.selectionPadding }, d);
471
+ })(t, a, s, n, i.type === "square" || o);
512
472
  case "text":
513
- return ((c, d, u, f, g, v, C) => {
514
- const { borderX: x, borderHeight: w, borderY: y, borderWidth: b } = _e(d, u, f, g, v, !0), H = St({ ...u, width: Math.max(0, b - 2 * v), height: Math.max(0, w - 2 * v), x: x + v, y: y + v }, C, v);
515
- return { ...H, fontSize: _t(c, H.value, H.width, H.style?.fontBold ?? !1, H.style?.fontItalic ?? !1, H.style?.fontFamily) };
516
- })(e, t, o, r, s, a, p);
473
+ return ((r, l, c, d, h) => {
474
+ const { borderX: u, borderHeight: g, borderY: v, borderWidth: x } = Be(l, c, d, h, !0), M = Ct({ ...c, width: Math.max(0, x - 2 * h.selectionPadding), height: Math.max(0, g - 2 * h.selectionPadding), x: u + h.selectionPadding, y: v + h.selectionPadding }, h);
475
+ return { ...M, fontSize: Bt(r, M.value, M.width, M.style?.fontBold ?? !1, M.style?.fontItalic ?? !1, M.style?.fontFamily) };
476
+ })(e, t, a, s, n);
517
477
  case "picture":
518
- return ((c, d, u, f, g, v, C) => {
519
- const { borderX: x, borderHeight: w, borderY: y, borderWidth: b } = _e(c, d, u, f, g, !0);
520
- return bt({ ...d, width: Math.max(0, b - 2 * g), height: Math.max(0, w - 2 * g), x: x + g, y: y + g }, v, g);
521
- })(t, o, r, s, a, p);
478
+ return ((r, l, c, d, h) => {
479
+ const { borderX: u, borderHeight: g, borderY: v, borderWidth: x } = Be(r, l, c, d, !0);
480
+ return bt({ ...l, width: Math.max(0, x - 2 * d.selectionPadding), height: Math.max(0, g - 2 * d.selectionPadding), x: u + d.selectionPadding, y: v + d.selectionPadding }, d);
481
+ })(t, a, s, n);
522
482
  default:
523
- return o;
483
+ return a;
524
484
  }
525
- }, Wt = (e, i, t, n, o, r) => {
485
+ }, Rt = (e, i, t, a) => {
526
486
  switch (i.type) {
527
487
  case "rect":
528
488
  case "square":
529
- return ((s, a, l, p, c, d) => Qt({ ...a, x: z(a.x + s[0] - l[0], p), y: z(a.y + s[1] - l[1], p) }, c, d))(e, i, t, n, o, r);
489
+ return ((s, n, o, r) => St({ ...n, x: O(n.x + s[0] - o[0], r), y: O(n.y + s[1] - o[1], r) }, r))(e, i, t, a);
530
490
  case "ellipse":
531
- return ((s, a, l, p, c, d) => vt({ ...a, x: z(a.x + s[0] - l[0], p), y: z(a.y + s[1] - l[1], p) }, c, d))(e, i, t, n, o, r);
491
+ return ((s, n, o, r) => yt({ ...n, x: O(n.x + s[0] - o[0], r), y: O(n.y + s[1] - o[1], r) }, r))(e, i, t, a);
532
492
  case "circle":
533
- return ((s, a, l, p, c, d) => ft({ ...a, x: z(a.x + s[0] - l[0], p), y: z(a.y + s[1] - l[1], p) }, c, d))(e, i, t, n, o, r);
493
+ return ((s, n, o, r) => mt({ ...n, x: O(n.x + s[0] - o[0], r), y: O(n.y + s[1] - o[1], r) }, r))(e, i, t, a);
534
494
  case "picture":
535
- return ((s, a, l, p, c, d) => bt({ ...a, x: z(a.x + s[0] - l[0], p), y: z(a.y + s[1] - l[1], p) }, c, d))(e, i, t, n, o, r);
495
+ return ((s, n, o, r) => bt({ ...n, x: O(n.x + s[0] - o[0], r), y: O(n.y + s[1] - o[1], r) }, r))(e, i, t, a);
536
496
  case "text":
537
- return ((s, a, l, p, c, d) => St({ ...a, x: z(a.x + s[0] - l[0], p), y: z(a.y + s[1] - l[1], p) }, c, d))(e, i, t, n, o, r);
497
+ return ((s, n, o, r) => Ct({ ...n, x: O(n.x + s[0] - o[0], r), y: O(n.y + s[1] - o[1], r) }, r))(e, i, t, a);
538
498
  case "line":
539
- return ((s, a, l, p, c, d) => mt({ ...a, points: a.points.map(([u, f]) => [z(u + s[0] - l[0], p), z(f + s[1] - l[1], p)]) }, c, d))(e, i, t, n, o, r);
499
+ return ((s, n, o, r) => Qt({ ...n, points: n.points.map(([l, c]) => [O(l + s[0] - o[0], r), O(c + s[1] - o[1], r)]) }, r))(e, i, t, a);
540
500
  case "polygon":
541
- return ((s, a, l, p, c, d) => {
542
- const { borders: u } = G(a, d);
543
- return Je({ ...a, points: a.points.map(([f, g]) => p ? [f + z(u.x + s[0] - l[0], p) - u.x, g + z(u.y + s[1] - l[1], p) - u.y] : [z(f + s[0] - l[0], p), z(g + s[1] - l[1], p)]) }, c, d);
544
- })(e, i, t, n, o, r);
501
+ return ((s, n, o, r) => {
502
+ const { borders: l } = Y(n, r);
503
+ return _e({ ...n, points: n.points.map(([c, d]) => r.gridGap ? [c + O(l.x + s[0] - o[0], r) - l.x, d + O(l.y + s[1] - o[1], r) - l.y] : [O(c + s[0] - o[0], r), O(d + s[1] - o[1], r)]) }, r);
504
+ })(e, i, t, a);
545
505
  case "curve":
546
- return ((s, a, l, p, c, d) => {
547
- const { borders: u } = G(a, d);
548
- return Ke({ ...a, points: a.points.map(([f, g]) => p ? [f + z(u.x + s[0] - l[0], p) - u.x, g + z(u.y + s[1] - l[1], p) - u.y] : [z(f + s[0] - l[0], p), z(g + s[1] - l[1], p)]) }, c, d);
549
- })(e, i, t, n, o, r);
506
+ return ((s, n, o, r) => {
507
+ const { borders: l } = Y(n, r);
508
+ return qe({ ...n, points: n.points.map(([c, d]) => r.gridGap ? [c + O(l.x + s[0] - o[0], r) - l.x, d + O(l.y + s[1] - o[1], r) - l.y] : [O(c + s[0] - o[0], r), O(d + s[1] - o[1], r)]) }, r);
509
+ })(e, i, t, a);
550
510
  case "brush":
551
- return ((s, a, l, p, c, d) => {
552
- const { borders: u } = G(a, d), f = p ? z(u.x + s[0] - l[0], p) - u.x : s[0] - l[0], g = p ? z(u.y + s[1] - l[1], p) - u.y : s[1] - l[1];
553
- return et({ ...a, points: a.points.map((v) => v.map(([C, x]) => [C + f, x + g])) }, c, d);
554
- })(e, i, t, n, o, r);
511
+ return ((s, n, o, r) => {
512
+ const { borders: l } = Y(n, r), c = r.gridGap ? O(l.x + s[0] - o[0], r) - l.x : s[0] - o[0], d = r.gridGap ? O(l.y + s[1] - o[1], r) - l.y : s[1] - o[1];
513
+ return Je({ ...n, points: n.points.map((h) => h.map(([u, g]) => [u + c, g + d])) }, r);
514
+ })(e, i, t, a);
555
515
  default:
556
516
  return i;
557
517
  }
558
- }, st = (e, i, t) => {
518
+ }, st = (e, i) => {
559
519
  switch (e.type) {
560
520
  case "rect":
561
521
  case "square":
562
- return la(e, i, t);
522
+ return A1(e, i);
563
523
  case "ellipse":
564
- return ia(e, i, t);
524
+ return P1(e, i);
565
525
  case "circle":
566
- return Ji(e, i, t);
526
+ return M1(e, i);
567
527
  case "picture":
568
- return ca(e, i, t);
528
+ return E1(e, i);
569
529
  case "text":
570
- return ua(e, i, t);
530
+ return D1(e, i);
571
531
  case "line":
572
- return na(e, i, t);
532
+ return T1(e, i);
573
533
  case "polygon":
574
- return Ki(e, i, t);
534
+ return k1(e, i);
575
535
  case "curve":
576
- return ea(e, i, t);
536
+ return L1(e, i);
577
537
  case "brush":
578
- return ji(e, i, t);
538
+ return C1(e, i);
579
539
  default:
580
540
  return e;
581
541
  }
582
- }, M1 = ({ ctx: e, shape: i, currentScale: t = 1, canvasOffset: n, selectionPadding: o, selectionWidth: r, selectionColor: s, withAnchors: a = !0 }) => {
583
- const { center: l } = G(i, o);
584
- switch (Xt(e, t, n, i.rotation, l), i.type) {
542
+ }, yi = ({ ctx: e, shape: i, settings: t, selectionWidth: a, selectionColor: s, withAnchors: n = !0 }) => {
543
+ const { center: o } = Y(i, t);
544
+ switch (Gt(e, t, i.rotation, o), i.type) {
585
545
  case "rect":
586
546
  case "square":
587
547
  case "circle":
@@ -589,777 +549,851 @@ const f1 = ({ ctx: e, path: i, rect: t, offset: n, checkFill: o }) => {
589
549
  case "picture":
590
550
  case "text":
591
551
  case "brush":
592
- ((p, c, d, u, f, g) => {
593
- if (c.selection && (ze(p, { fillColor: "transparent", strokeColor: d, lineWidth: u / f }), c.selection.shapePath ? p.stroke(c.selection.shapePath) : p.stroke(c.selection.border), g && !c.locked)) {
594
- c.selection.shapePath && p.stroke(c.selection.border), p.stroke(c.selection.line), ze(p, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / f });
595
- for (const v of c.selection.anchors)
596
- p.fill(v), p.stroke(v);
552
+ ((r, l, c, d, h, u) => {
553
+ if (l.selection && (ze(r, { fillColor: "transparent", strokeColor: c, lineWidth: d / h.canvasSize.scaleRatio }), l.selection.shapePath ? r.stroke(l.selection.shapePath) : r.stroke(l.selection.border), u && !l.locked)) {
554
+ l.selection.shapePath && r.stroke(l.selection.border), r.stroke(l.selection.line), ze(r, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / h.canvasSize.scaleRatio });
555
+ for (const g of l.selection.anchors)
556
+ r.fill(g), r.stroke(g);
597
557
  }
598
- })(e, i, s, r, t, a);
558
+ })(e, i, s, a, t, n);
599
559
  break;
600
560
  case "polygon":
601
561
  case "line":
602
562
  case "curve":
603
- (({ ctx: p, shape: c, withAnchors: d, selectionWidth: u, selectionColor: f, currentScale: g = 1 }) => {
604
- if (c.selection && (ze(p, { fillColor: "transparent", strokeColor: f, lineWidth: u / g }), c.selection.shapePath && p.stroke(c.selection.shapePath), d && !c.locked)) {
605
- ze(p, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / g });
606
- for (const v of c.selection.anchors)
607
- p.fill(v), p.stroke(v);
563
+ (({ ctx: r, shape: l, withAnchors: c, selectionWidth: d, selectionColor: h, settings: u }) => {
564
+ if (l.selection && (ze(r, { fillColor: "transparent", strokeColor: h, lineWidth: d / u.canvasSize.scaleRatio }), l.selection.shapePath && r.stroke(l.selection.shapePath), c && !l.locked)) {
565
+ ze(r, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / u.canvasSize.scaleRatio });
566
+ for (const g of l.selection.anchors)
567
+ r.fill(g), r.stroke(g);
608
568
  }
609
- })({ ctx: e, shape: i, withAnchors: a, selectionWidth: r, selectionColor: s, currentScale: t });
569
+ })({ ctx: e, shape: i, withAnchors: n, selectionWidth: a, selectionColor: s, settings: t });
610
570
  }
611
571
  e.restore();
612
- }, ma = ({ ctx: e, selectionFrame: i, currentScale: t = 1, canvasOffset: n }) => {
613
- Xt(e, t, n), ((o, r, s) => {
614
- ze(o, { fillColor: "rgba(170,170,170, 0.1)", strokeColor: "rgb(170,170,170)", lineWidth: 1 / s }), o.fillRect(r[0][0], r[0][1], r[1][0] - r[0][0], r[1][1] - r[0][1]), o.strokeRect(r[0][0], r[0][1], r[1][0] - r[0][0], r[1][1] - r[0][1]);
572
+ }, z1 = ({ ctx: e, selectionFrame: i, settings: t }) => {
573
+ Gt(e, t), ((a, s, n) => {
574
+ ze(a, { fillColor: "rgba(170,170,170, 0.1)", strokeColor: "rgb(170,170,170)", lineWidth: 1 / n.canvasSize.scaleRatio }), a.fillRect(s[0][0], s[0][1], s[1][0] - s[0][0], s[1][1] - s[0][1]), a.strokeRect(s[0][0], s[0][1], s[1][0] - s[0][0], s[1][1] - s[0][1]);
615
575
  })(e, i, t), e.restore();
616
- }, k1 = "ArrowUp", L1 = "ArrowDown", V1 = "ArrowLeft", H1 = "ArrowRight", ya = "Delete", Qa = "Backspace", ba = "Escape", A1 = "Shift", Sa = "z", Ca = "Z", xa = "y", wa = "Y", T1 = "copy", Z1 = "paste", Ma = ({ gridFormat: e, isInsideComponent: i, selectedShape: t, isEditingText: n, currentScale: o, selectionPadding: r, setSelectedShape: s, removeShape: a, pasteShape: l, updateShape: p, backwardShape: c, forwardShape: d, setShiftPressed: u }) => {
617
- const [f, g] = R(void 0);
618
- return Y(() => {
619
- const v = (y) => {
620
- t && (n || (y.preventDefault(), g({ ...t })));
621
- }, C = (y) => {
622
- f && (n || (y.preventDefault(), l(((b, H, A, Z) => ({ ...Wt([20, 20], b, [0, 0], H, A, Z), id: ae(`${b.type}_`) }))(f, e, o, r))));
623
- }, x = (y) => {
624
- y.key === A1 && u(!1);
625
- }, w = (y) => {
626
- if (y.metaKey || y.ctrlKey) {
627
- if (y.key === Ca || y.key === Sa)
628
- return y.preventDefault(), y.stopPropagation(), void c();
629
- if (y.key === wa || y.key === xa)
630
- return y.preventDefault(), y.stopPropagation(), void d();
631
- }
632
- if (y.key === A1)
633
- return void u(!0);
634
- if (!t)
635
- return;
636
- if (y.key === ba)
637
- return void s(void 0);
638
- if (n)
639
- return;
640
- const b = { [V1]: [e ? -Oe[e - 1] : -1, 0], [H1]: [e ? Oe[e - 1] : 1, 0], [L1]: [0, e ? Oe[e - 1] : 1], [k1]: [0, e ? -Oe[e - 1] : -1] };
641
- switch (y.key) {
642
- case V1:
643
- case H1:
644
- case L1:
645
- case k1:
646
- p(Wt(b[y.key], t, [0, 0], e, o, r));
647
- break;
648
- case ya:
649
- case Qa:
650
- a(t);
651
- }
652
- };
653
- if (i)
654
- return document.addEventListener("keydown", w), document.addEventListener("keyup", x), document.addEventListener(T1, v), document.addEventListener(Z1, C), () => {
655
- document.removeEventListener("keydown", w), document.removeEventListener("keyup", x), document.removeEventListener(T1, v), document.removeEventListener(Z1, C);
656
- };
657
- }, [i, r, e, f, n, t, o, p, a, s, l, c, d, u]), {};
658
- }, ka = (e, i, t) => {
659
- const n = ee([]), o = ee(e);
660
- o.current = e;
661
- const [r, s] = R(void 0), [a, l] = R(void 0), [p, c] = R(void 0), [d, u] = R({ states: [{ shapes: [], selectedShape: void 0 }], cursor: 0 }), f = d.cursor > 0, g = d.cursor < d.states.length - 1, v = n.current.length > 0, C = U(() => {
662
- u((Q) => ci(Q.states[Q.cursor].shapes, n.current) ? Q : { states: [...Q.states.slice(0, Q.cursor + 1), { shapes: n.current, selectedShape: a }], cursor: Q.cursor + 1 });
663
- }, [a]), x = U((Q) => {
664
- n.current = [Q, ...n.current];
665
- }, []), w = U((Q, k, m, V, L) => {
666
- if (Q.target && "className" in Q.target && ![oi, si].includes(Q.target.className))
667
- return void c(void 0);
668
- const $ = n.current.find((W) => W.id === a?.id ? !!ot(a, m, V, i, L) : !!pi(k, W, m, V, i, L));
669
- c($);
670
- }, [i, a]), y = U(async (Q, k = 300, m = 300) => {
671
- const V = await pa(Q, k, m, t.scaleRatio, i);
672
- return x(V), C(), V;
673
- }, [x, C, t, i]), b = U((Q, k = !1) => {
674
- n.current = n.current.map((m) => m.id === a?.id ? Q : m), l((m) => m?.id === Q.id ? Q : m), k && C();
675
- }, [a, C]), H = U((Q) => {
676
- const k = Q.map((m) => Et(["chosen"], m));
677
- n.current = k, C();
678
- }, [C]), A = U((Q) => {
679
- l((k) => k?.id === Q.id ? void 0 : k), n.current = n.current.filter((k) => k.id !== Q.id), C();
680
- }, [C]), Z = U((Q) => {
681
- u((k) => {
682
- const m = Q(k);
683
- return n.current = k.states[m].shapes, l(k.states[m].selectedShape), ce("cursor", m, k);
576
+ }, p1 = (e) => {
577
+ const i = new DOMParser().parseFromString(e, "text/xml").getElementsByTagName("svg")[0], t = i.getAttribute("width"), a = i.getAttribute("height");
578
+ let s;
579
+ if (t || a)
580
+ s = e;
581
+ else {
582
+ const o = i.getAttribute("viewBox") ?? "0 0 300 300", [, , r, l] = o.split(" ");
583
+ i.setAttribute("width", r ?? ut), i.setAttribute("height", l ?? ut), s = new XMLSerializer().serializeToString(i);
584
+ }
585
+ const n = new Blob([s], { type: "image/svg+xml" });
586
+ return URL.createObjectURL(n);
587
+ }, u1 = (e) => (e instanceof File ? e.name : e).includes(".svg"), g1 = (e) => u1(e) ? fetch(e).then((i) => i.text()).then((i) => p1(i)) : fetch(e).then((i) => i.blob()).then((i) => URL.createObjectURL(i)), Qi = (e, i) => {
588
+ const t = document.createElement("a");
589
+ t.href = e, t.download = i, document.body.appendChild(t), t.click(), document.body.removeChild(t);
590
+ }, $1 = (e) => {
591
+ const i = document.createElement("canvas");
592
+ i.width = e.width, i.height = e.height;
593
+ const t = i.getContext("2d");
594
+ return t ? (t.drawImage(e, 0, 0), i.toDataURL("image/png")) : "";
595
+ }, Si = (e, i, t, a) => {
596
+ const s = document.createElement("canvas");
597
+ s.width = i, s.height = t;
598
+ const n = s.getContext("2d");
599
+ if (!n)
600
+ return "";
601
+ n.clearRect(0, 0, i, t), r1(n);
602
+ for (let o = e.length - 1; o >= 0; o--)
603
+ h1(n, e[o], le(["canvasSize", "scaleRatio"], 1, a));
604
+ return s.toDataURL("image/png");
605
+ }, O1 = (e, i, t) => {
606
+ return s = Xt(e, i, t), `data:text/plain;charset=utf-8,${encodeURIComponent(JSON.stringify(s))}`;
607
+ var s;
608
+ }, G1 = (e) => {
609
+ const i = ["img", "id", "selection", "path", "arrows"];
610
+ return e.map((t) => t.type !== "picture" || t.src.startsWith("http") ? Et(i, t) : Et(i, { ...t, src: $1(t.img) }));
611
+ }, Xt = (e, i, t) => ({ shapes: G1(e), config: { width: i, height: t } }), bi = (e, i) => st({ ...e, id: se(`${e.type}_`) }, i), U1 = (e) => {
612
+ const i = ae([]), t = ae({ dataChanged: [] }), [a, s] = z(void 0), [n, o] = z(void 0), [r, l] = z(void 0), [c, d] = z({ states: [{ shapes: [], selectedShape: void 0 }], cursor: 0 }), h = c.cursor > 0, u = c.cursor < c.states.length - 1, g = i.current.length > 0, v = W(() => {
613
+ d((f) => o1(f.states[f.cursor].shapes, i.current) ? f : { states: [...f.states.slice(0, f.cursor + 1), { shapes: i.current, selectedShape: n }], cursor: f.cursor + 1 });
614
+ }, [n]), x = W((f) => {
615
+ i.current = [f, ...i.current];
616
+ }, []), M = W((f, m, b) => {
617
+ if (f.target && "className" in f.target && ![a1, n1].includes(f.target.className))
618
+ return void l(void 0);
619
+ const R = i.current.find((D) => D.id === n?.id ? !!nt(n, b, e) : !!d1(m, D, b, e));
620
+ l(R);
621
+ }, [e, n]), y = W(async (f, m = 300, b = 300) => {
622
+ const R = await F1(f, m, b, e);
623
+ return x(R), v(), R;
624
+ }, [x, v, e]), P = W((f, m = !1) => {
625
+ i.current = i.current.map((b) => b.id === n?.id ? f : b), o((b) => b?.id === f.id ? f : b), m && v();
626
+ }, [n, v]), Q = W((f) => {
627
+ const m = f.map((b) => Et(["chosen"], b));
628
+ i.current = m, v();
629
+ }, [v]), L = W((f) => {
630
+ o((m) => m?.id === f.id ? void 0 : m), i.current = i.current.filter((m) => m.id !== f.id), v();
631
+ }, [v]), T = W((f) => {
632
+ d((m) => {
633
+ const b = f(m);
634
+ return i.current = m.states[b].shapes, o(m.states[b].selectedShape), le("cursor", b, m);
684
635
  });
685
- }, []), F = U(() => {
686
- Z((Q) => Math.max(0, Q.cursor - 1));
687
- }, [Z]), E = U(() => {
688
- Z((Q) => Math.min(Q.states.length - 1, Q.cursor + 1));
689
- }, [Z]), S = U((Q = [], k = !1) => {
690
- l(void 0), n.current = Q, u((m) => k ? { states: [{ shapes: Q, selectedShape: void 0 }], cursor: 0 } : { states: [...m.states.slice(0, m.cursor + 1), { shapes: Q, selectedShape: void 0 }], cursor: m.cursor + 1 });
691
- }, []), T = U((Q, k) => {
692
- const m = n.current, V = m.findIndex(($) => $.id === Q), L = m.findIndex(($) => $.id === k);
693
- H(V < L ? [...m.slice(0, V), ...m.slice(V + 1, L + 1), m[V], ...m.slice(L + 1, m.length)] : [...m.slice(0, L), m[V], ...m.slice(L, V), ...m.slice(V + 1, m.length)]);
694
- }, [H]), M = U((Q) => {
695
- const k = n.current, m = k.findIndex((L) => L.id === Q.id);
696
- if (m < 0)
636
+ }, []), E = W(() => {
637
+ T((f) => Math.max(0, f.cursor - 1));
638
+ }, [T]), Z = W(() => {
639
+ T((f) => Math.min(f.states.length - 1, f.cursor + 1));
640
+ }, [T]), H = W((f = [], m = !1) => {
641
+ o(void 0), i.current = f, d((b) => m ? { states: [{ shapes: f, selectedShape: void 0 }], cursor: 0 } : { states: [...b.states.slice(0, b.cursor + 1), { shapes: f, selectedShape: void 0 }], cursor: b.cursor + 1 });
642
+ }, []), C = W((f, m) => {
643
+ const b = i.current, R = b.findIndex((_) => _.id === f), D = b.findIndex((_) => _.id === m);
644
+ Q(R < D ? [...b.slice(0, R), ...b.slice(R + 1, D + 1), b[R], ...b.slice(D + 1, b.length)] : [...b.slice(0, D), b[R], ...b.slice(D, R), ...b.slice(R + 1, b.length)]);
645
+ }, [Q]), V = W((f) => {
646
+ const m = i.current, b = m.findIndex((D) => D.id === f.id);
647
+ if (b < 0)
697
648
  return;
698
- const V = ce("visible", Q.visible === !1, Q);
699
- l((L) => L?.id === V.id ? V : L), H(ce(m, V, k));
700
- }, [H]), B = U((Q) => {
701
- const k = n.current, m = k.findIndex((L) => L.id === Q.id);
702
- if (m < 0)
649
+ const R = le("visible", f.visible === !1, f);
650
+ o((D) => D?.id === R.id ? R : D), Q(le(b, R, m));
651
+ }, [Q]), k = W((f) => {
652
+ const m = i.current, b = m.findIndex((D) => D.id === f.id);
653
+ if (b < 0)
703
654
  return;
704
- const V = ce("locked", !Q.locked, Q);
705
- l((L) => L?.id === V.id ? V : L), H(ce(m, V, k));
706
- }, [H]);
707
- Y(() => {
708
- o.current?.();
709
- }, [d]), Y(() => {
710
- n.current = n.current.map((Q) => st(Q, t.scaleRatio, i)), l((Q) => Q === void 0 ? void 0 : n.current.find((k) => k.id === Q.id));
711
- }, [t, i]);
712
- const N = U((Q, k, m, V) => {
713
- s((L) => {
714
- const $ = [L?.[0] ?? [k[0], k[1]], [k[0], k[1]]], W = n.current.filter((_) => ((O, P, ne, oe, se) => {
715
- const { center: le, borders: de } = G(P, se), q = Be(ne[0], P.rotation, le, oe), ue = Be(ne[1], P.rotation, le, oe), we = Math.round(Math.min(q[0], ue[0]) - se / 2), Se = Math.round(Math.max(q[0], ue[0]) + se), Me = Math.round(Math.min(q[1], ue[1]) - se / 2), Ae = { x: we, y: Me, width: Se - we, height: Math.round(Math.max(q[1], ue[1]) + se) - Me }, ve = g1(de, Ae);
716
- if (!ve)
655
+ const R = le("locked", !f.locked, f);
656
+ o((D) => D?.id === R.id ? R : D), Q(le(b, R, m));
657
+ }, [Q]), S = W((f, m) => {
658
+ Object.hasOwn(t.current, f) && (t.current[f] = [...t.current[f], m]);
659
+ }, []), F = W((f, m) => {
660
+ if (Object.hasOwn(t.current, f))
661
+ if (m) {
662
+ const b = t.current[f].findIndex((R) => R === m);
663
+ t.current[f] = [...t.current[f].slice(0, b), ...t.current[f].slice(b + 1)];
664
+ } else
665
+ t.current[f] = [];
666
+ }, []), { canvasSize: { width: w, height: A } } = e;
667
+ U(() => {
668
+ const f = Xt(i.current, w, A);
669
+ for (const m of t.current.dataChanged)
670
+ m(f);
671
+ }, [w, A, c]), U(() => {
672
+ i.current = i.current.map((f) => st(f, e)), o((f) => f === void 0 ? void 0 : i.current.find((m) => m.id === f.id));
673
+ }, [e]);
674
+ const N = W((f, m) => {
675
+ s((b) => {
676
+ const R = [b?.[0] ?? [m[0], m[1]], [m[0], m[1]]], D = i.current.filter((_) => ((oe, $, j, ce) => {
677
+ const { selectionPadding: G, canvasOffset: q } = ce, { center: me, borders: fe } = Y($, ce), te = $e(j[0], $.rotation, me, q), he = $e(j[1], $.rotation, me, q), be = Math.round(Math.min(te[0], he[0]) - G / 2), pe = Math.round(Math.max(te[0], he[0]) + G), xe = Math.round(Math.min(te[1], he[1]) - G / 2), Ce = { x: be, y: xe, width: pe - be, height: Math.round(Math.max(te[1], he[1]) + G) - xe }, Me = ci(fe, Ce);
678
+ if (!Me)
717
679
  return !1;
718
- if (de.width <= 1 || de.height <= 1 || !("path" in P) || !P.path)
680
+ if (fe.width <= 1 || fe.height <= 1 || !("path" in $) || !$.path)
719
681
  return !0;
720
- if (O.lineWidth = (P.style?.lineWidth ?? 0) + 10, P.type === "brush") {
721
- const ye = P.points.flat(), he = Math.min(...ye.map((K) => K[0])), Te = Math.min(...ye.map((K) => K[1]));
722
- for (const K of P.points) {
723
- if (K.length < 1)
682
+ if (oe.lineWidth = ($.style?.lineWidth ?? 0) + 10, $.type === "brush") {
683
+ const ne = $.points.flat(), ke = Math.min(...ne.map((re) => re[0])), Ze = Math.min(...ne.map((re) => re[1]));
684
+ for (const re of $.points) {
685
+ if (re.length < 1)
724
686
  break;
725
- if (K.length < 2) {
726
- const ke = Ue(K[0], he, Te, P.scaleX, P.scaleY);
727
- if (di(ve, { x: ke[0], y: ke[1], radius: (P.style?.lineWidth ?? 1) / 2 }))
687
+ if (re.length < 2) {
688
+ const ye = Se(re[0], ke, Ze, $.scaleX, $.scaleY);
689
+ if (l1(Me, { x: ye[0], y: ye[1], radius: ($.style?.lineWidth ?? 1) / 2 }))
728
690
  return !0;
729
691
  }
730
- for (let ke = 0; ke < K.length - 1; ke++) {
731
- const Ee = Ue(K[ke], he, Te, P.scaleX, P.scaleY), Ie = Ue(K[ke + 1], he, Te, P.scaleX, P.scaleY), Qe = g1({ x: Math.min(Ee[0], Ie[0]), y: Math.min(Ee[1], Ie[1]), width: Math.abs(Ee[0] - Ie[0]), height: Math.abs(Ee[1] - Ie[1]) }, Ae);
732
- if (Qe) {
733
- const Ze = new Path2D();
734
- if (Ze.moveTo(...Ee), Ze.lineTo(...Ie), f1({ ctx: O, path: Ze, rect: Qe, offset: 10, checkFill: !1 }))
692
+ for (let ye = 0; ye < re.length - 1; ye++) {
693
+ const ie = Se(re[ye], ke, Ze, $.scaleX, $.scaleY), Le = Se(re[ye + 1], ke, Ze, $.scaleX, $.scaleY), Oe = ci({ x: Math.min(ie[0], Le[0]), y: Math.min(ie[1], Le[1]), width: Math.abs(ie[0] - Le[0]), height: Math.abs(ie[1] - Le[1]) }, Ce);
694
+ if (Oe) {
695
+ const Ne = new Path2D();
696
+ if (Ne.moveTo(...ie), Ne.lineTo(...Le), hi({ ctx: oe, path: Ne, rect: Oe, offset: 10, checkFill: !1 }))
735
697
  return !0;
736
698
  }
737
699
  }
738
700
  }
739
701
  return !1;
740
702
  }
741
- const De = !(!P.style?.fillColor || P.style?.fillColor === "transparent");
742
- return f1({ ctx: O, path: P.path, rect: ve, offset: 10, checkFill: De });
743
- })(Q, _, $, m, i));
744
- return l(W?.[0]), $;
703
+ const Ae = !(!$.style?.fillColor || $.style?.fillColor === "transparent");
704
+ return hi({ ctx: oe, path: $.path, rect: Me, offset: 10, checkFill: Ae });
705
+ })(f, _, R, e));
706
+ return o(D?.[0]), R;
745
707
  });
746
- }, [i]);
747
- return { shapesRef: n, selectedShape: a, hoveredShape: p, selectionFrame: r, setSelectionFrame: s, refreshSelectedShapes: N, addShape: x, addPictureShape: y, moveShapes: T, saveShapes: C, setSelectedShape: l, refreshHoveredShape: w, toggleShapeVisibility: M, toggleShapeLock: B, removeShape: A, updateShape: b, backwardShape: F, forwardShape: E, clearShapes: S, canGoBackward: f, canGoForward: g, canClear: v };
748
- }, La = "infos", Va = 4e3, Ha = () => {
749
- const e = ee([]), [i, t] = R([]);
750
- return Y(() => () => {
751
- for (const n of e.current)
752
- clearTimeout(n);
753
- }, []), { snackbarList: i, addSnackbar: ({ type: n = La, duration: o = Va, text: r }) => {
754
- const s = { id: ae("snackbar_"), duration: o, type: n, text: r };
755
- t((a) => [...a, s]), e.current = [...e.current, setTimeout(() => {
756
- return a = s.id, void t((l) => l.filter((p) => p.id !== a));
757
- var a;
758
- }, o)];
759
- } };
760
- }, P1 = (e, i = !1) => {
761
- const t = (o, r) => {
762
- if (Array.isArray(o))
763
- return r;
764
- }, n = e.map((o) => {
765
- if (typeof o != "object")
708
+ }, [e]);
709
+ return { registerEvent: S, unregisterEvent: F, shapesRef: i, selectedShape: n, hoveredShape: r, selectionFrame: a, setSelectionFrame: s, refreshSelectedShapes: N, addShape: x, addPictureShape: y, moveShapes: C, saveShapes: v, setSelectedShape: o, refreshHoveredShape: M, toggleShapeVisibility: V, toggleShapeLock: k, removeShape: L, updateShape: P, backwardShape: E, forwardShape: Z, clearShapes: H, canGoBackward: h, canGoForward: u, canClear: g };
710
+ }, Ci = (e, i = !1) => {
711
+ const t = (s, n) => {
712
+ if (Array.isArray(s))
713
+ return n;
714
+ }, a = e.map((s) => {
715
+ if (typeof s != "object")
766
716
  return null;
767
- switch (o.type) {
717
+ switch (s.type) {
768
718
  case "brush":
769
- return xe(t, q1, o);
719
+ return we(t, Gi, s);
770
720
  case "circle":
771
- return xe(t, ii, o);
721
+ return we(t, _i, s);
772
722
  case "curve":
773
- return xe(t, K1, o);
723
+ return we(t, Xi, s);
774
724
  case "ellipse":
775
- return xe(t, ai, o);
725
+ return we(t, qi, s);
776
726
  case "line":
777
- return xe(t, G1, o);
727
+ return we(t, Ui, s);
778
728
  case "polygon":
779
- return xe(t, J1, o);
729
+ return we(t, Bi, s);
780
730
  case "rect":
781
- return xe(t, ei, o);
731
+ return we(t, Yi, s);
782
732
  case "square":
783
- return xe(t, ti, o);
733
+ return we(t, ji, s);
784
734
  case "text":
785
- return xe(t, ni, o);
735
+ return we(t, Ji, s);
786
736
  }
787
737
  return null;
788
738
  });
789
- return yt(i ? [...n, Bt] : n);
790
- }, Aa = (e, i, t, n, o, r, s, a, l) => {
791
- let p = !1;
792
- if (r) {
793
- p = ot(r, t, o, s, n, !0, a ? 20 : void 0);
794
- const d = ((u, f, g, v) => {
795
- if (u.mode === "translate")
796
- return { mode: "translate", cursorStartPosition: g, originalShape: f };
797
- if (u.mode === "rotate") {
798
- const { center: C } = G(f, v);
799
- return { mode: "rotate", cursorStartPosition: g, originalShape: f, center: [C[0], C[1]] };
739
+ return ft(i ? [...a, Ot] : a);
740
+ }, Ta = ({ width: e = 1e3, height: i = 600, shapes: t, mode: a = "editor", disabled: s = !1, options: n = Pt }) => {
741
+ const { layersManipulation: o, brushAlgo: r, grid: l, canGrow: c, canShrink: d, withExport: h, withLoadAndSave: u, withUploadPicture: g, withUrlPicture: v, withSkeleton: x, withFrameSelection: M, clearCallback: y, availableTools: P } = { ...Pt, ...n }, { canvasSelectionColor: Q, canvasSelectionWidth: L, canvasSelectionPadding: T } = { ...Pt.selection, ...n?.selection }, E = a !== "viewer", Z = s || !E, H = ae(null), C = ae(null), [V, k] = z(!1), S = W((X) => {
742
+ H.current = X;
743
+ }, []), [F, w] = z(Te), [A, N] = z(l), [f, m] = z({ width: e, height: i, scaleRatio: 1 }), [b, R] = z([0, 0]), D = Di(() => ({ brushAlgo: r, canvasSize: f, canvasOffset: b, gridGap: A, selectionPadding: T }), [T, A, r, b, f]), [_, oe] = z(Ci(P, g || v)), { isInsideComponent: $ } = (({ disabled: X, componentRef: Ee }) => {
744
+ const [it, Ie] = z(!1);
745
+ return U(() => {
746
+ if (!X) {
747
+ const Ve = (We) => {
748
+ Ie(s1(We, Ee.current));
749
+ };
750
+ return document.addEventListener("mousedown", Ve, { passive: !0 }), document.addEventListener("touchstart", Ve, { passive: !0 }), () => {
751
+ document.removeEventListener("mousedown", Ve), document.removeEventListener("touchstart", Ve);
752
+ };
800
753
  }
801
- return u.mode === "resize" ? { mode: "resize", cursorStartPosition: g, originalShape: f, anchor: u.anchor } : void 0;
802
- })(p || { mode: "default" }, r, t, s);
803
- if (d?.mode === "resize" || d?.mode === "rotate")
804
- return { shape: r, mode: d };
754
+ Ie(!1);
755
+ }, [X, Ee]), { isInsideComponent: it };
756
+ })({ disabled: Z, componentRef: H }), { registerEvent: j, unregisterEvent: ce, shapesRef: G, selectedShape: q, selectionFrame: me, hoveredShape: fe, addShape: te, addPictureShape: he, moveShapes: be, setSelectedShape: pe, setSelectionFrame: xe, refreshSelectedShapes: Ce, refreshHoveredShape: Me, removeShape: Ae, updateShape: ne, backwardShape: ke, forwardShape: Ze, clearShapes: re, saveShapes: ye, toggleShapeVisibility: ie, toggleShapeLock: Le, canGoBackward: Oe, canGoForward: Ne, canClear: wt } = U1(D), tt = W((X) => {
757
+ pe(void 0), w(X);
758
+ }, [pe]), Ge = W((X = [], Ee = !1) => {
759
+ re(X, Ee), tt(Te), R([0, 0]);
760
+ }, [tt, re]), rt = W((X) => {
761
+ w(Te), pe(X);
762
+ }, [pe]), xt = W(() => {
763
+ const X = O1(G.current, e, i);
764
+ if (!X)
765
+ throw new Error("L'encodage a échoué");
766
+ Qi(X, "drawing.json");
767
+ }, [G, e, i]), J = W(() => {
768
+ const X = Si(G.current, e, i, D);
769
+ if (!X)
770
+ throw new Error();
771
+ Qi(X, "drawing.png");
772
+ }, [G, e, i, D]);
773
+ U(() => {
774
+ $ || pe(void 0);
775
+ }, [$, pe]);
776
+ const K = W(async (X, Ee = !0) => {
777
+ const it = await (async (Ie, Ve) => {
778
+ if (!Ie)
779
+ return [];
780
+ const We = [], Mt = ft(Ie.map((Qe) => {
781
+ if (!Qe || !i1.includes(Qe.type))
782
+ return null;
783
+ if (Qe.type === "picture") {
784
+ const Pe = new Image(), v1 = new Promise((kt, f1) => {
785
+ Pe.onload = () => {
786
+ URL.revokeObjectURL(Pe.src), kt();
787
+ }, Pe.onerror = () => {
788
+ f1(new Error("Some images could not be loaded"));
789
+ };
790
+ });
791
+ return We.push(v1), Qe.src.startsWith("http") ? g1(Qe.src).then((kt) => {
792
+ Pe.src = kt;
793
+ }).catch(() => {
794
+ Pe.src = "";
795
+ }) : Pe.src = Qe.src, bi({ ...Qe, img: Pe }, Ve);
796
+ }
797
+ return bi(Qe, Ve);
798
+ }));
799
+ return await Promise.all(We), Mt;
800
+ })(X, D);
801
+ Ge(it, Ee);
802
+ }, [Ge, D]);
803
+ V || t === void 0 || (k(!0), K(t));
804
+ const lt = W(async (X) => {
805
+ const Ee = await (async (it) => new Promise((Ie, Ve) => {
806
+ const We = new FileReader();
807
+ We.onload = (Mt) => {
808
+ const Qe = Mt.target?.result;
809
+ if (!Qe)
810
+ return Ve("Impossible de récupérer les données du fichier");
811
+ const Pe = JSON.parse(Qe);
812
+ Ie(Pe);
813
+ }, We.readAsText(it);
814
+ }))(X);
815
+ await K(Ee.shapes ?? []);
816
+ }, [K]), Re = W(() => {
817
+ typeof y != "string" ? K(y(), !1) : y === "defaultShapes" && t !== void 0 ? K(t, !1) : Ge();
818
+ }, [Ge, K, t, y]);
819
+ U(() => {
820
+ oe(Ci(P, g || v));
821
+ }, [P, g, v]);
822
+ const Ue = { canvas: C, editor: H, setEditor: S };
823
+ return { editorProps: { shapesRef: G, addPictureShape: he, moveShapes: be, toggleShapeVisibility: ie, toggleShapeLock: Le, canGoBackward: Oe, canGoForward: Ne, canClear: wt, selectedShape: q, removeShape: Ae, updateShape: ne, backwardShape: ke, forwardShape: Ze, refs: Ue, width: e, height: i, canvasSize: f, selectTool: tt, selectShape: rt, activeTool: F, setActiveTool: w, setAvailableTools: oe, isEditMode: E, isDisabled: Z, availableTools: _, gridGap: A, setGridGap: N, loadFile: lt, exportPicture: J, exportData: xt, clearCanvas: Re, settings: D, canvas: { selection: { canvasSelectionColor: Q, canvasSelectionWidth: L, canvasSelectionPadding: T }, withSkeleton: x, withFrameSelection: M, canGrow: c, canShrink: d, layersManipulation: o, withExport: h, withLoadAndSave: u, withUploadPicture: g, withUrlPicture: v, clearCallback: y } }, canvasProps: { shapesRef: G, selectedShape: q, selectionFrame: me, hoveredShape: fe, addShape: te, setSelectedShape: pe, setSelectionFrame: xe, refreshSelectedShapes: Ce, refreshHoveredShape: Me, removeShape: Ae, updateShape: ne, backwardShape: ke, forwardShape: Ze, saveShapes: ye, refs: Ue, width: e, height: i, settings: D, canvasSize: f, setCanvasSize: m, setCanvasOffset: R, selectShape: rt, activeTool: F, setActiveTool: w, isInsideComponent: $, isEditMode: E, isDisabled: Z, canvas: { selection: { canvasSelectionColor: Q, canvasSelectionWidth: L }, withSkeleton: x, withFrameSelection: M, canGrow: c, canShrink: d } }, registerEvent: j, unregisterEvent: ce, resetCanvas: K, getCurrentImage: () => C.current ? Si(G.current, e, i, D) : void 0, getCurrentData: () => Xt(G.current, e, i) };
824
+ }, B1 = (e, i, t, a, s, n, o) => {
825
+ let r = !1;
826
+ if (s) {
827
+ r = nt(s, t, a, !0, n ? 20 : void 0);
828
+ const c = ((d, h, u, g) => {
829
+ if (d.mode === "translate")
830
+ return { mode: "translate", cursorStartPosition: u, originalShape: h };
831
+ if (d.mode === "rotate") {
832
+ const { center: v } = Y(h, g);
833
+ return { mode: "rotate", cursorStartPosition: u, originalShape: h, center: [v[0], v[1]] };
834
+ }
835
+ return d.mode === "resize" ? { mode: "resize", cursorStartPosition: u, originalShape: h, anchor: d.anchor } : void 0;
836
+ })(r || { mode: "default" }, s, t, a);
837
+ if (c?.mode === "resize" || c?.mode === "rotate")
838
+ return { shape: s, mode: c };
805
839
  }
806
- const c = i.find((d) => d.id === r?.id ? !!p : !!pi(e, d, t, o, s, n));
807
- return c ? { shape: c, mode: { mode: "translate", cursorStartPosition: t, originalShape: c } } : { shape: void 0, mode: { mode: l ? "selectionFrame" : "default" } };
808
- }, Ta = ({ disabled: e = !1, addShape: i, canvasSize: t, drawCanvasRef: n, setActiveTool: o, refreshHoveredShape: r, shapes: s, selectionMode: a, activeTool: l, isInsideComponent: p, setCanvasOffset: c, selectedShape: d, selectionCanvasRef: u, canvasOffsetStartPosition: f, refreshSelectedShapes: g, setSelectedShape: v, setSelectionFrame: C, setCanvasOffsetStartPosition: x, updateSingleShape: w, gridFormat: y, canvasOffset: b, saveShapes: H, setSelectionMode: A, selectionPadding: Z, isShiftPressed: F, withFrameSelection: E }) => {
809
- const { width: S, height: T, scaleRatio: M } = t, [B, N] = R({ mode: "default" }), { registerDoubleClickEvent: Q, unRegisterDoubleClickEvent: k } = (() => {
810
- const m = ee(void 0), V = ee(void 0), L = ($) => {
811
- const W = (/* @__PURE__ */ new Date()).getTime();
812
- m.current && W < m.current + 300 && V.current?.($), m.current = (/* @__PURE__ */ new Date()).getTime();
840
+ const l = i.find((c) => c.id === s?.id ? !!r : !!d1(e, c, t, a));
841
+ return l ? { shape: l, mode: { mode: "translate", cursorStartPosition: t, originalShape: l } } : { shape: void 0, mode: { mode: o ? "selectionFrame" : "default" } };
842
+ }, X1 = ({ disabled: e = !1, addShape: i, drawCanvasRef: t, setActiveTool: a, refreshHoveredShape: s, shapes: n, selectionMode: o, activeTool: r, isInsideComponent: l, setCanvasOffset: c, selectedShape: d, selectionCanvasRef: h, canvasOffsetStartPosition: u, refreshSelectedShapes: g, setSelectedShape: v, setSelectionFrame: x, setCanvasOffsetStartPosition: M, updateSingleShape: y, saveShapes: P, setSelectionMode: Q, settings: L, isShiftPressed: T, withFrameSelection: E }) => {
843
+ const [Z, H] = z({ mode: "default" }), { registerDoubleClickEvent: C, unRegisterDoubleClickEvent: V } = (() => {
844
+ const k = ae(void 0), S = ae(void 0), F = (w) => {
845
+ const A = (/* @__PURE__ */ new Date()).getTime();
846
+ k.current && A < k.current + 300 && S.current?.(w), k.current = (/* @__PURE__ */ new Date()).getTime();
813
847
  };
814
- return { registerDoubleClickEvent: ($, W) => {
815
- V.current = W, $.addEventListener("click", L), $.addEventListener("touchend", L);
816
- }, unRegisterDoubleClickEvent: ($) => {
817
- $.removeEventListener("click", L), $.removeEventListener("touchend", L);
848
+ return { registerDoubleClickEvent: (w, A) => {
849
+ S.current = A, w.addEventListener("click", F), w.addEventListener("touchend", F);
850
+ }, unRegisterDoubleClickEvent: (w) => {
851
+ w.removeEventListener("click", F), w.removeEventListener("touchend", F);
818
852
  } };
819
853
  })();
820
- return Y(() => {
821
- const m = (V) => window.requestAnimationFrame(() => ((L, $, W, _, O, P, ne, oe, se, le, de, q, ue, we, Se, Me, Ae, ve, De) => {
822
- const ye = $.current?.getContext("2d");
823
- if (!ye)
854
+ return U(() => {
855
+ const k = (S) => window.requestAnimationFrame(() => ((F, w, A, N, f, m, b, R, D, _, oe, $, j, ce) => {
856
+ const G = w.current?.getContext("2d");
857
+ if (!G)
824
858
  return;
825
- const he = Zt(L, $.current, se, le, de);
826
- if (W.type !== "move" || oe === void 0)
827
- if (ne.mode !== "selectionFrame") {
828
- if (h1(L) || ue(L, ye, he, O, de), P !== void 0 && !P.locked)
829
- if (ne.mode === "default" || ne.mode === "textedition")
830
- q(ot(P, he, O, ve, de, !0) || { mode: "default" });
859
+ const q = Tt(F, w.current, j);
860
+ if (A.type !== "move" || m === void 0)
861
+ if (f.mode !== "selectionFrame") {
862
+ if (di(F) || R(F, G, q, j), N !== void 0 && !N.locked)
863
+ if (f.mode === "default" || f.mode === "textedition")
864
+ b(nt(N, q, j, !0) || { mode: "default" });
831
865
  else {
832
- const Te = $.current?.getContext("2d");
833
- if (!Te)
866
+ const me = w.current?.getContext("2d");
867
+ if (!me)
834
868
  return;
835
- const K = Gi(Te, P, he, _, O, ne, ve, De, de);
836
- we(K), Me(K);
869
+ const fe = x1(me, N, q, f, j, ce);
870
+ D(fe), oe(fe);
837
871
  }
838
872
  } else
839
- Ae(ye, he, O, de);
873
+ $(G, q, j);
840
874
  else
841
- Se([he[0] - oe[0], he[1] - oe[1]]);
842
- })(V, u, l, y, b, d, a, f, S, T, M, N, r, w, c, v, g, Z, F));
843
- if (p)
844
- return document.addEventListener("mousemove", m), document.addEventListener("touchmove", m), () => {
845
- document.removeEventListener("mousemove", m), document.removeEventListener("touchmove", m);
875
+ _([q[0] - m[0], q[1] - m[1]]);
876
+ })(S, h, r, d, o, u, H, s, y, c, v, g, L, T));
877
+ if (l)
878
+ return document.addEventListener("mousemove", k), document.addEventListener("touchmove", k), () => {
879
+ document.removeEventListener("mousemove", k), document.removeEventListener("touchmove", k);
846
880
  };
847
- }, [p, u, d, a, y, b, f, S, T, M, w, l, c, v, r, g, Z, F]), Y(() => {
848
- const m = () => {
849
- a.mode !== "textedition" && a.mode !== "default" && (A({ mode: "default" }), C(void 0), H());
881
+ }, [l, h, d, o, u, y, r, c, v, s, g, L, T]), U(() => {
882
+ const k = () => {
883
+ o.mode !== "textedition" && o.mode !== "default" && (Q({ mode: "default" }), x(void 0), P());
850
884
  };
851
- return p && (document.addEventListener("mouseup", m), document.addEventListener("touchend", m)), () => {
852
- p && (document.removeEventListener("mouseup", m), document.removeEventListener("touchend", m));
885
+ return l && (document.addEventListener("mouseup", k), document.addEventListener("touchend", k)), () => {
886
+ l && (document.removeEventListener("mouseup", k), document.removeEventListener("touchend", k));
853
887
  };
854
- }, [p, a, H, C, A]), Y(() => {
855
- const m = u.current;
856
- if (!m)
888
+ }, [l, o, P, x, Q]), U(() => {
889
+ const k = h.current;
890
+ if (!k)
857
891
  return;
858
- const V = m.getContext("2d");
859
- if (!V || e)
892
+ const S = k.getContext("2d");
893
+ if (!S || e)
860
894
  return;
861
- const L = ($) => {
862
- $.preventDefault();
863
- const W = Zt($, u.current, S, T, M);
864
- if (l.type === "selection") {
865
- const { shape: _, mode: O } = Aa(V, s, W, M, b, d, Z, h1($), E);
866
- v(_), A(O), O.mode === "selectionFrame" && C([[W[0], W[1]], [W[0], W[1]]]);
867
- } else if (l.type === "move")
868
- x(W);
869
- else if (U1.some((_) => _ === l.type)) {
870
- const _ = n.current?.getContext("2d");
871
- if (!_)
895
+ const F = (w) => {
896
+ w.preventDefault();
897
+ const A = Tt(w, h.current, L);
898
+ if (r.type === "selection") {
899
+ const { shape: N, mode: f } = B1(S, n, A, L, d, di(w), E);
900
+ v(N), Q(f), f.mode === "selectionFrame" && x([[A[0], A[1]], [A[0], A[1]]]);
901
+ } else if (r.type === "move")
902
+ M(A);
903
+ else if (i1.some((N) => N === r.type)) {
904
+ const N = t.current?.getContext("2d");
905
+ if (!N)
872
906
  return;
873
- if (l.type === "brush") {
907
+ if (r.type === "brush") {
874
908
  if (d && d.type === "brush") {
875
- const O = ((P, ne, oe, se) => {
876
- const le = { ...P, points: ce(P.points.length, [[Math.round(ne[0]), Math.round(ne[1])]], P.points) };
877
- return et(le, oe, se);
878
- })(d, W, M, Z);
879
- w(O), v(O);
909
+ const f = ((m, b, R) => {
910
+ const D = { ...m, points: le(m.points.length, [[Math.round(b[0]), Math.round(b[1])]], m.points) };
911
+ return Je(D, R);
912
+ })(d, A, L);
913
+ y(f), v(f);
880
914
  } else {
881
- const O = w1(_, l, W, y, M, Z);
882
- if (!O)
915
+ const f = mi(N, r, A, L);
916
+ if (!f)
883
917
  return;
884
- i(O), v(O);
918
+ i(f), v(f);
885
919
  }
886
- A({ mode: "brush" });
887
- } else if (l.type !== "picture") {
888
- const O = w1(_, l, W, y, M, Z);
889
- i(O), o(He), v(O), A({ mode: "resize", cursorStartPosition: [W[0] + Z, W[1] + Z], originalShape: O, anchor: l.type === "line" || l.type === "polygon" || l.type === "curve" ? 0 : [1, 1] });
920
+ Q({ mode: "brush" });
921
+ } else if (r.type !== "picture") {
922
+ const f = mi(N, r, A, L);
923
+ i(f), a(Te), v(f), Q({ mode: "resize", cursorStartPosition: [A[0] + L.selectionPadding, A[1] + L.selectionPadding], originalShape: f, anchor: r.type === "line" || r.type === "polygon" || r.type === "curve" ? 0 : [1, 1] });
890
924
  }
891
925
  }
892
926
  };
893
- return m.addEventListener("mousedown", L, { passive: !1 }), m.addEventListener("touchstart", L, { passive: !1 }), () => {
894
- m.removeEventListener("mousedown", L), m.removeEventListener("touchstart", L);
927
+ return k.addEventListener("mousedown", F, { passive: !1 }), k.addEventListener("touchstart", F, { passive: !1 }), () => {
928
+ k.removeEventListener("mousedown", F), k.removeEventListener("touchstart", F);
895
929
  };
896
- }, [e, u, n, d, l, b, x, s, S, T, M, w, i, o, v, A, C, Z, y, E]), Y(() => {
897
- const m = u.current;
898
- if (m)
899
- return p ? (Q(m, (V) => {
900
- if (l.type === "selection" && d?.type === "text") {
901
- const L = Zt(V, u.current, S, T, M);
902
- ot(d, L, b, Z, M) && A({ mode: "textedition", defaultValue: d.value });
930
+ }, [e, h, t, d, r, M, n, y, i, a, v, Q, x, L, E]), U(() => {
931
+ const k = h.current;
932
+ if (k)
933
+ return l ? (C(k, (S) => {
934
+ if (r.type === "selection" && d?.type === "text") {
935
+ const F = Tt(S, h.current, L);
936
+ nt(d, F, L) && Q({ mode: "textedition", defaultValue: d.value });
903
937
  }
904
938
  }), () => {
905
- k(m);
939
+ V(k);
906
940
  }) : void 0;
907
- }, [Q, k, p, u, l, d, S, T, M, b, A, Z]), { hoverMode: B };
908
- }, Za = /(<([^>]+)>)/gi, Pa = /<(\/)?div(\/?\s?)>/gi, Fa = (e) => {
941
+ }, [C, V, l, h, r, d, Q, L]), { hoverMode: Z };
942
+ }, Y1 = /(<([^>]+)>)/gi, j1 = /<(\/)?div(\/?\s?)>/gi, _1 = (e) => {
909
943
  const i = ((t) => {
910
- const n = document.createElement("textarea");
911
- return n.innerHTML = t, n.value;
944
+ const a = document.createElement("textarea");
945
+ return a.innerHTML = t, a.value;
912
946
  })(e).split("<div>").flatMap((t) => {
913
- const n = t.replaceAll(Pa, "");
914
- return n === "" ? void 0 : n.replaceAll(Za, "");
947
+ const a = t.replaceAll(j1, "");
948
+ return a === "" ? void 0 : a.replaceAll(Y1, "");
915
949
  });
916
- return yt(i);
917
- }, Na = ({ disabled: e = !1, scaleRatio: i, shape: t, defaultValue: n, updateValue: o, saveShapes: r, selectionPadding: s }) => {
918
- const a = ee(null), l = ee(r);
919
- Y(() => {
920
- if (!a.current)
950
+ return ft(i);
951
+ }, q1 = ({ disabled: e = !1, scaleRatio: i, shape: t, defaultValue: a, updateValue: s, saveShapes: n, settings: o }) => {
952
+ const r = ae(null), l = ae(n);
953
+ U(() => {
954
+ if (!r.current)
921
955
  return;
922
- const c = a.current, d = (u) => {
956
+ const d = r.current, h = (u) => {
923
957
  u.preventDefault();
924
- const f = u.clipboardData?.getData("text/plain");
925
- document.execCommand("insertText", !1, f);
958
+ const g = u.clipboardData?.getData("text/plain");
959
+ document.execCommand("insertText", !1, g);
926
960
  };
927
- return c.addEventListener("paste", d), c.innerHTML = n.map((u) => `<div>${u === "" ? "<br/>" : u}</div>`).join(""), c.focus(), () => {
928
- c.removeEventListener("paste", d);
961
+ return d.addEventListener("paste", h), d.innerHTML = a.map((u) => `<div>${u === "" ? "<br/>" : u}</div>`).join(""), d.focus(), () => {
962
+ d.removeEventListener("paste", h);
929
963
  };
930
- }, [n]), Y(() => {
931
- const c = l.current;
964
+ }, [a]), U(() => {
965
+ const d = l.current;
932
966
  return () => {
933
- c();
967
+ d();
934
968
  };
935
969
  }, []);
936
- const p = zi(() => {
937
- const { borders: c, center: d } = G(t, s);
938
- return fe({ point: [c.x, c.y], rotation: -t.rotation, origin: d });
939
- }, [t, s]);
940
- return h("div", { className: "react-paint-editor-toolbox-edittextbox", ref: a, "data-fontbold": t.style?.fontBold ?? !1, "data-fontitalic": t.style?.fontItalic ?? !1, contentEditable: !e, onInput: (c) => {
941
- o(Fa(c.target.innerHTML));
942
- }, style: { "--react-paint-editor-toolbox-edittextbox-transform": `translate3D(${p[0] * i}px, ${p[1] * i}px, 0) rotate(${Dt(t.rotation)}deg)`, "--react-paint-editor-toolbox-edittextbox-fontsize": t.fontSize * i + "px", "--react-paint-editor-toolbox-edittextbox-padding": s * i + "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 ?? rt } });
943
- }, Da = (e, i, t, n, o, r, s, a) => {
944
- const { width: l, height: p, scaleRatio: c } = t;
945
- e.clearRect(0, 0, l, p), li(e), n && ((d, u, f, g, v, C) => {
946
- d.strokeStyle = "rgb(220,220,220)", d.lineWidth = 1, d.save(), d.scale(g, g), d.beginPath();
947
- const x = Oe[C - 1], w = -v[0] % x, y = -v[1] % x, b = Math.ceil(u / g / x), H = Math.ceil(f / g / x);
948
- for (let A = 0; A < b; A++)
949
- d.moveTo(w + (A + 1) * x, y), d.lineTo(w + (A + 1) * x, y + f / g);
950
- for (let A = 0; A < H; A++)
951
- d.moveTo(w, y + (A + 1) * x), d.lineTo(w + u / g, y + (A + 1) * x);
952
- d.stroke(), d.restore();
953
- })(e, l, p, c, o, n);
954
- for (let d = r.length - 1; d >= 0; d--)
955
- i.mode === "textedition" && r[d] === a || mi(e, r[d], c, o, s);
956
- }, Ea = W1.forwardRef(({ gridFormat: e, canGrow: i, disabled: t = !1, canvasSize: n, shapes: o, addShape: r, updateSingleShape: s, selectedShape: a, setSelectedShape: l, setSelectionFrame: p, hoveredShape: c, selectionFrame: d, refreshHoveredShape: u, refreshSelectedShapes: f, saveShapes: g, activeTool: v, setActiveTool: C, canvasOffsetStartPosition: x, setCanvasOffsetStartPosition: w, canvasOffset: y, setCanvasOffset: b, isInsideComponent: H, selectionMode: A, setSelectionMode: Z, selectionWidth: F, selectionColor: E, selectionPadding: S, isEditMode: T, isShiftPressed: M, withFrameSelection: B, withSkeleton: N }, Q) => {
957
- const k = ee(null), m = ee(null);
958
- Ui(Q, () => k.current);
959
- const { hoverMode: V } = Ta({ disabled: t, addShape: r, canvasSize: n, drawCanvasRef: k, setActiveTool: C, shapes: o, selectionMode: A, activeTool: v, isInsideComponent: H, setCanvasOffset: b, selectedShape: a, selectionCanvasRef: m, canvasOffsetStartPosition: x, setSelectedShape: l, setSelectionFrame: p, refreshHoveredShape: u, refreshSelectedShapes: f, setCanvasOffsetStartPosition: w, updateSingleShape: s, gridFormat: e, canvasOffset: y, saveShapes: g, setSelectionMode: Z, selectionPadding: S, isShiftPressed: M, withFrameSelection: B }), { scaleRatio: L } = n, $ = U((W) => {
960
- if (a?.type !== "text")
970
+ const c = Di(() => {
971
+ const { borders: d, center: h } = Y(t, o);
972
+ return ve({ point: [d.x, d.y], rotation: -t.rotation, origin: h });
973
+ }, [t, o]);
974
+ return p("div", { className: "react-paint-editor-toolbox-edittextbox", ref: r, "data-fontbold": t.style?.fontBold ?? !1, "data-fontitalic": t.style?.fontItalic ?? !1, contentEditable: !e, onInput: (d) => {
975
+ s(_1(d.target.innerHTML));
976
+ }, style: { "--react-paint-editor-toolbox-edittextbox-transform": `translate3D(${c[0] * i}px, ${c[1] * i}px, 0) rotate(${Nt(t.rotation)}deg)`, "--react-paint-editor-toolbox-edittextbox-fontsize": t.fontSize * i + "px", "--react-paint-editor-toolbox-edittextbox-padding": o.selectionPadding * i + "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 ?? ot } });
977
+ }, J1 = (e, i, t, a, s) => {
978
+ const { canvasSize: { width: n, height: o } } = t;
979
+ e.clearRect(0, 0, n, o), r1(e), t.gridGap && ((r, l, c, d) => {
980
+ const { gridGap: h, canvasOffset: u, canvasSize: { scaleRatio: g } } = d;
981
+ r.strokeStyle = "rgb(220,220,220)", r.lineWidth = 1, r.save(), r.scale(g, g), r.beginPath();
982
+ const v = -u[0] % h, x = -u[1] % h, M = Math.ceil(l / g / h), y = Math.ceil(c / g / h);
983
+ for (let P = 0; P < M; P++)
984
+ r.moveTo(v + (P + 1) * h, x), r.lineTo(v + (P + 1) * h, x + c / g);
985
+ for (let P = 0; P < y; P++)
986
+ r.moveTo(v, x + (P + 1) * h), r.lineTo(v + l / g, x + (P + 1) * h);
987
+ r.stroke(), r.restore();
988
+ })(e, n, o, t);
989
+ for (let r = a.length - 1; r >= 0; r--)
990
+ i.mode === "textedition" && a[r] === s || h1(e, a[r], t);
991
+ }, K1 = Fi.forwardRef(({ canGrow: e, disabled: i = !1, canvasSize: t, shapes: a, addShape: s, updateSingleShape: n, selectedShape: o, setSelectedShape: r, setSelectionFrame: l, hoveredShape: c, selectionFrame: d, refreshHoveredShape: h, refreshSelectedShapes: u, saveShapes: g, activeTool: v, setActiveTool: x, canvasOffsetStartPosition: M, setCanvasOffsetStartPosition: y, setCanvasOffset: P, isInsideComponent: Q, selectionMode: L, setSelectionMode: T, selectionWidth: E, selectionColor: Z, settings: H, isEditMode: C, isShiftPressed: V, withFrameSelection: k, withSkeleton: S }, F) => {
992
+ const w = ae(null), A = ae(null);
993
+ m1(F, () => w.current);
994
+ const { hoverMode: N } = X1({ disabled: i, addShape: s, drawCanvasRef: w, setActiveTool: x, shapes: a, selectionMode: L, activeTool: v, isInsideComponent: Q, setCanvasOffset: P, selectedShape: o, selectionCanvasRef: A, canvasOffsetStartPosition: M, setSelectedShape: r, setSelectionFrame: l, refreshHoveredShape: h, refreshSelectedShapes: u, setCanvasOffsetStartPosition: y, updateSingleShape: n, saveShapes: g, setSelectionMode: T, isShiftPressed: V, withFrameSelection: k, settings: H }), f = W((m) => {
995
+ if (o?.type !== "text")
961
996
  return;
962
- const _ = k.current?.getContext("2d");
963
- if (!_)
997
+ const b = w.current?.getContext("2d");
998
+ if (!b)
964
999
  return;
965
- const O = st(ha(_, a, W, S, y), L, S);
966
- s(O);
967
- }, [s, a, y, L, S]);
968
- return Y(() => {
969
- const W = k.current?.getContext("2d");
970
- W && window.requestAnimationFrame(() => Da(W, A, n, e, y, o, S, a));
971
- }, [o, e, A, a, y, n, S]), Y(() => {
972
- const W = m.current?.getContext("2d");
973
- W && window.requestAnimationFrame(() => ((_, O, P, ne, oe, se, le, de, q, ue, we, Se) => {
974
- const { width: Me, height: Ae, scaleRatio: ve } = P;
975
- _.clearRect(0, 0, Me, Ae), Se && ue && ue.id !== q?.id && ne.type === "selection" && O.mode === "default" && M1({ ctx: _, shape: ue, currentScale: ve, canvasOffset: oe, selectionPadding: se, selectionWidth: le, selectionColor: de, withAnchors: !1 }), q && ne.type !== "brush" && M1({ ctx: _, shape: q, currentScale: ve, canvasOffset: oe, selectionPadding: se, selectionWidth: le, selectionColor: de, withAnchors: O.mode !== "textedition" }), we && ma({ ctx: _, selectionFrame: we, currentScale: ve, canvasOffset: oe });
976
- })(W, A, n, v, y, S, F, E, a, c, d, N));
977
- }, [c, d, A, a, v, y, n, S, F, E, N]), h("div", { className: "react-paint-editor-canvas-box", children: I("div", { className: "react-paint-editor-canvas-container", "data-grow": i, children: [h("canvas", { className: oi, ref: k, "data-grow": i, width: n.width, height: n.height }), T && h("canvas", { className: si, ref: m, width: n.width, height: n.height, "data-grow": i, style: { "--react-paint-editor-canvas-cursor": v.type !== "selection" && v.type !== "move" || V.mode === "resize" ? "crosshair" : v.type === "move" || V.mode === "translate" ? "move" : V.mode === "rotate" ? "grab" : "default" } }), T && A.mode === "textedition" && a?.type === "text" && h(Na, { scaleRatio: n.scaleRatio, disabled: t, shape: a, defaultValue: A.defaultValue, updateValue: $, saveShapes: g, selectionPadding: S })] }) });
978
- }), Ia = ({ type: e, text: i, duration: t }) => {
979
- const [n, o] = R(!1);
980
- return Y(() => {
981
- const r = setTimeout(() => {
982
- o(!0);
983
- }, 100), s = setTimeout(() => {
984
- o(!1);
1000
+ const R = st(N1(b, o, m, H), H);
1001
+ n(R);
1002
+ }, [n, o, H]);
1003
+ return U(() => {
1004
+ const m = w.current?.getContext("2d");
1005
+ m && window.requestAnimationFrame(() => J1(m, L, H, a, o));
1006
+ }, [a, L, o, H]), U(() => {
1007
+ const m = A.current?.getContext("2d");
1008
+ m && window.requestAnimationFrame(() => ((b, R, D, _, oe, $, j, ce, G, q) => {
1009
+ b.clearRect(0, 0, D.canvasSize.width, D.canvasSize.height), q && ce && ce.id !== j?.id && _.type === "selection" && R.mode === "default" && yi({ ctx: b, shape: ce, settings: D, selectionWidth: oe, selectionColor: $, withAnchors: !1 }), j && _.type !== "brush" && yi({ ctx: b, shape: j, settings: D, selectionWidth: oe, selectionColor: $, withAnchors: R.mode !== "textedition" }), G && z1({ ctx: b, selectionFrame: G, settings: D });
1010
+ })(m, L, H, v, E, Z, o, c, d, S));
1011
+ }, [c, d, L, o, v, H, E, Z, S]), p("div", { className: "react-paint-canvas-box", children: I("div", { className: "react-paint-canvas-container", "data-grow": e, children: [p("canvas", { className: a1, ref: w, "data-grow": e, width: t.width, height: t.height }), C && p("canvas", { className: n1, ref: A, width: t.width, height: t.height, "data-grow": e, style: { "--react-paint-canvas-cursor": v.type !== "selection" && v.type !== "move" || N.mode === "resize" ? "crosshair" : v.type === "move" || N.mode === "translate" ? "move" : N.mode === "rotate" ? "grab" : "default" } }), C && L.mode === "textedition" && o?.type === "text" && p(q1, { scaleRatio: t.scaleRatio, disabled: i, shape: o, defaultValue: L.defaultValue, updateValue: f, saveShapes: g, settings: H })] }) });
1012
+ }), wi = "ArrowUp", xi = "ArrowDown", Mi = "ArrowLeft", ki = "ArrowRight", ea = "Delete", ta = "Backspace", ia = "Escape", Li = "Shift", aa = "z", na = "Z", sa = "y", oa = "Y", Vi = "copy", Pi = "paste", ra = ({ isInsideComponent: e, selectedShape: i, isEditingText: t, settings: a, setSelectedShape: s, removeShape: n, pasteShape: o, updateShape: r, backwardShape: l, forwardShape: c, setShiftPressed: d }) => {
1013
+ const [h, u] = z(void 0);
1014
+ return U(() => {
1015
+ const g = (y) => {
1016
+ i && (t || (y.preventDefault(), u({ ...i })));
1017
+ }, v = (y) => {
1018
+ h && (t || (y.preventDefault(), o(((P, Q) => ({ ...Rt([20, 20], P, [0, 0], Q), id: se(`${P.type}_`) }))(h, a))));
1019
+ }, x = (y) => {
1020
+ y.key === Li && d(!1);
1021
+ }, M = (y) => {
1022
+ if (y.metaKey || y.ctrlKey) {
1023
+ if (y.key === na || y.key === aa)
1024
+ return y.preventDefault(), y.stopPropagation(), void l();
1025
+ if (y.key === oa || y.key === sa)
1026
+ return y.preventDefault(), y.stopPropagation(), void c();
1027
+ }
1028
+ if (y.key === Li)
1029
+ return void d(!0);
1030
+ if (!i)
1031
+ return;
1032
+ if (y.key === ia)
1033
+ return void s(void 0);
1034
+ if (t)
1035
+ return;
1036
+ const P = { [Mi]: [a.gridGap ? -a.gridGap : -1, 0], [ki]: [a.gridGap ? a.gridGap : 1, 0], [xi]: [0, a.gridGap ? a.gridGap : 1], [wi]: [0, a.gridGap ? -a.gridGap : -1] };
1037
+ switch (y.key) {
1038
+ case Mi:
1039
+ case ki:
1040
+ case xi:
1041
+ case wi:
1042
+ r(Rt(P[y.key], i, [0, 0], a));
1043
+ break;
1044
+ case ea:
1045
+ case ta:
1046
+ n(i);
1047
+ }
1048
+ };
1049
+ if (e)
1050
+ return document.addEventListener("keydown", M), document.addEventListener("keyup", x), document.addEventListener(Vi, g), document.addEventListener(Pi, v), () => {
1051
+ document.removeEventListener("keydown", M), document.removeEventListener("keyup", x), document.removeEventListener(Vi, g), document.removeEventListener(Pi, v);
1052
+ };
1053
+ }, [e, h, t, i, a, r, n, s, o, l, c, d]), {};
1054
+ }, Aa = ({ options: e, className: i, style: t, canvasProps: a }) => {
1055
+ const { shapesRef: s, selectedShape: n, selectionFrame: o, hoveredShape: r, addShape: l, setSelectedShape: c, setSelectionFrame: d, refreshSelectedShapes: h, refreshHoveredShape: u, removeShape: g, updateShape: v, backwardShape: x, forwardShape: M, saveShapes: y, refs: P, width: Q, height: L, settings: T, canvasSize: E, setCanvasSize: Z, setCanvasOffset: H, selectShape: C, activeTool: V, setActiveTool: k, isInsideComponent: S, isEditMode: F, isDisabled: w, canvas: { selection: { canvasSelectionColor: A, canvasSelectionWidth: N }, withSkeleton: f, withFrameSelection: m, canGrow: b, canShrink: R } } = a, { canvasBackgroundColor: D } = { ...S1, ...e }, _ = ae(null), [oe, $] = z(void 0), [j, ce] = z({ mode: "default" }), [G, q] = z(!1), me = W((te) => {
1056
+ l(te), C(te);
1057
+ }, [l, C]), fe = W((te) => {
1058
+ const he = te / Q;
1059
+ Z({ width: te, height: L * he, scaleRatio: he });
1060
+ }, [Q, L, Z]);
1061
+ return ra({ isInsideComponent: S, isEditingText: j.mode === "textedition", settings: T, selectedShape: n, setSelectedShape: c, removeShape: g, pasteShape: me, updateShape: v, backwardShape: x, forwardShape: M, setShiftPressed: q }), (({ onResized: te, element: he }) => {
1062
+ U(() => {
1063
+ const be = he.current;
1064
+ if (!be)
1065
+ return;
1066
+ const pe = new ResizeObserver((xe) => {
1067
+ const Ce = xe?.[0]?.borderBoxSize?.[0], { width: Me, height: Ae } = Ce ? { width: Ce.inlineSize, height: Ce.blockSize } : xe?.[0].contentRect ?? {};
1068
+ te(Me, Ae);
1069
+ });
1070
+ return pe.observe(be), () => {
1071
+ pe.unobserve(be);
1072
+ };
1073
+ }, [he, te]);
1074
+ })({ element: _, onResized: fe }), p("div", { ref: _, className: "react-paint-app-row" + (i ? ` ${i}` : ""), "data-grow": b, "data-shrink": R, style: { "--react-paint-app-row-width": E.width, "--react-paint-app-canvaswidth": `${Q}px`, "--react-paint-app-row-aspectratio": `calc(${E.width} / ${E.height})`, "--react-paint-app-canvas-bg": D, ...t }, children: p(K1, { ref: P.canvas, canGrow: b, disabled: w, isInsideComponent: S, activeTool: V, setActiveTool: k, canvasOffsetStartPosition: oe, setCanvasOffsetStartPosition: $, shapes: s.current, addShape: l, updateSingleShape: v, selectedShape: n, selectionFrame: o, setSelectedShape: c, setSelectionFrame: d, hoveredShape: r, refreshHoveredShape: u, refreshSelectedShapes: h, settings: T, setCanvasOffset: H, saveShapes: y, canvasSize: E, selectionMode: j, setSelectionMode: ce, selectionColor: A, selectionWidth: N, isEditMode: F, isShiftPressed: G, withFrameSelection: m, withSkeleton: f }) });
1075
+ }, la = ({ isLoading: e = !1 }) => {
1076
+ const [i, t] = z("hidden");
1077
+ return U(() => {
1078
+ if (!e) {
1079
+ t("fadeOut");
1080
+ const a = setTimeout(() => t("hidden"), 300);
1081
+ return () => {
1082
+ clearTimeout(a);
1083
+ };
1084
+ }
1085
+ t("visible");
1086
+ }, [e]), i === "hidden" ? null : p("div", { className: "react-paint-editor-loading", "data-loading": i, style: { "--react-paint-editor-loading-zindex": y1, "--react-paint-editor-loading-transition-duration": "300ms" }, children: I("div", { className: "react-paint-editor-loader", children: [p("div", {}), p("div", {}), p("div", {}), p("div", {})] }) });
1087
+ }, da = "infos", ca = 4e3, ha = ({ type: e, text: i, duration: t }) => {
1088
+ const [a, s] = z(!1);
1089
+ return U(() => {
1090
+ const n = setTimeout(() => {
1091
+ s(!0);
1092
+ }, 100), o = setTimeout(() => {
1093
+ s(!1);
985
1094
  }, t - 500 - 100);
986
1095
  return () => {
987
- clearTimeout(r), clearTimeout(s);
1096
+ clearTimeout(n), clearTimeout(o);
988
1097
  };
989
- }, [t]), h("div", { className: "react-paint-editor-snackbar", "data-is-shown": +n, "data-type": e, style: { "--react-paint-editor-panel-transition-duration": "500ms" }, children: i });
990
- }, Wa = ({ snackbarList: e }) => h("div", { className: "react-paint-editor-snackbar-container", style: { "--react-paint-editor-snackbar-zindex": Rt }, children: e.map((i) => h(Ia, { ...i }, i.id)) }), j = W1.forwardRef((e, i) => {
1098
+ }, [t]), p("div", { className: "react-paint-editor-snackbar", "data-is-shown": +a, "data-type": e, style: { "--react-paint-editor-panel-transition-duration": "500ms" }, children: i });
1099
+ }, pa = ({ snackbarList: e }) => p("div", { className: "react-paint-editor-snackbar-container", style: { "--react-paint-editor-snackbar-zindex": Q1 }, children: e.map((i) => p(ha, { ...i }, i.id)) }), B = Fi.forwardRef((e, i) => {
991
1100
  if (e.type === "file" || e.type === "color") {
992
- const { hidden: c = !1, disabled: d = !1, selected: u = !1, icon: f, children: g, className: v = "", title: C, onClick: x, ...w } = e;
993
- return I("label", { className: `react-paint-editor-button ${v}`, title: C, onClick: x, "data-disabled": +d, "data-selected": +u, "data-hidden": +c, children: [h("input", { ref: i, disabled: d, ...w }), I("span", { className: "react-paint-editor-button-content", children: [g && h("span", { className: "react-paint-editor-button-children", children: g }), f && h("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: f } })] })] });
1101
+ const { hidden: d = !1, disabled: h = !1, selected: u = !1, icon: g, children: v, className: x = "", title: M, onClick: y, ...P } = e;
1102
+ return I("label", { className: `react-paint-editor-button ${x}`, title: M, onClick: y, "data-disabled": +h, "data-selected": +u, "data-hidden": +d, children: [p("input", { ref: i, disabled: h, ...P }), I("span", { className: "react-paint-editor-button-content", children: [v && p("span", { className: "react-paint-editor-button-children", children: v }), g && p("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: g } })] })] });
994
1103
  }
995
- const { hidden: t = !1, disabled: n = !1, selected: o = !1, icon: r, children: s, type: a = "button", className: l = "", ...p } = e;
996
- return h("button", { className: `react-paint-editor-button ${l}`, ref: i, disabled: n, "data-disabled": +n, "data-selected": +o, "data-hidden": +t, type: a, ...p, children: I("span", { className: "react-paint-editor-button-content", children: [s && h("span", { className: "react-paint-editor-button-children", children: s }), r && h("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: r } })] }) });
997
- }), it = ({ children: e, title: i = "", className: t = "", position: n = "bottom", fitContainer: o = !1, alignment: r = "center" }) => I("div", { className: `react-paint-editor-panel ${t}`, "data-fitcontainer": o, "data-position": n, "data-alignment": r, style: { "--react-paint-editor-panel-zindex": Rt }, children: [i && h("h3", { className: "react-paint-editor-panel-title", children: i }), e] }), Ra = (e) => {
1104
+ const { hidden: t = !1, disabled: a = !1, selected: s = !1, icon: n, children: o, type: r = "button", className: l = "", ...c } = e;
1105
+ return p("button", { className: `react-paint-editor-button ${l}`, ref: i, disabled: a, "data-disabled": +a, "data-selected": +s, "data-hidden": +t, type: r, ...c, children: I("span", { className: "react-paint-editor-button-content", children: [o && p("span", { className: "react-paint-editor-button-children", children: o }), n && p("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: n } })] }) });
1106
+ }), et = ({ children: e, title: i = "", className: t = "", position: a = "bottom", fitContainer: s = !1, alignment: n = "center" }) => I("div", { className: `react-paint-editor-panel ${t}`, "data-fitcontainer": s, "data-position": a, "data-alignment": n, style: { "--react-paint-editor-panel-zindex": Oi }, children: [i && p("h3", { className: "react-paint-editor-panel-title", children: i }), e] }), ua = (e) => {
998
1107
  switch (e) {
999
1108
  case "brush":
1000
- return B1;
1109
+ return Ri;
1001
1110
  case "line":
1002
- return _1;
1111
+ return zi;
1003
1112
  case "polygon":
1004
1113
  return zt;
1005
1114
  case "curve":
1006
- return j1;
1115
+ return $i;
1007
1116
  case "rect":
1008
1117
  case "square":
1009
- return $t;
1118
+ return It;
1010
1119
  case "circle":
1011
1120
  case "ellipse":
1012
- return Ot;
1121
+ return Wt;
1013
1122
  case "text":
1014
- return Y1;
1123
+ return Wi;
1015
1124
  case "picture":
1016
- return Ut;
1125
+ return $t;
1017
1126
  case "triangle":
1018
1127
  return "";
1019
1128
  }
1020
- }, $a = ({ disabled: e = !1, shape: i, selected: t, layoutDragging: n, toggleShapeVisibility: o, toggleShapeLock: r, setLayoutDragging: s, handleRemove: a, handleSelect: l, onMoveShapes: p }) => {
1021
- const c = ee(null), { isOver: d } = (({ disabled: u = !1, ref: f, shape: g, layoutDragging: v, setLayoutDragging: C, handleSelect: x, onMoveShapes: w }) => {
1022
- const [y, b] = R(!1);
1023
- return Y(() => {
1024
- v || b(!1);
1025
- }, [v]), Y(() => {
1026
- const H = f.current;
1027
- if (!H)
1129
+ }, ga = ({ disabled: e = !1, shape: i, selected: t, layoutDragging: a, toggleShapeVisibility: s, toggleShapeLock: n, setLayoutDragging: o, handleRemove: r, handleSelect: l, onMoveShapes: c }) => {
1130
+ const d = ae(null), { isOver: h } = (({ disabled: u = !1, ref: g, shape: v, layoutDragging: x, setLayoutDragging: M, handleSelect: y, onMoveShapes: P }) => {
1131
+ const [Q, L] = z(!1);
1132
+ return U(() => {
1133
+ x || L(!1);
1134
+ }, [x]), U(() => {
1135
+ const T = g.current;
1136
+ if (!T)
1028
1137
  return;
1029
- const A = () => {
1030
- C(void 0);
1031
- }, Z = (M) => (M.preventDefault && M.preventDefault(), !1), F = (M) => {
1032
- x(g), M.dataTransfer && (M.dataTransfer.effectAllowed = "move", M.dataTransfer.setData("draggableShapeId", g.id), C(g.id));
1033
- }, E = () => {
1034
- v !== g.id && b(!0);
1035
- }, S = () => {
1036
- b(!1);
1037
- }, T = (M) => (M.stopPropagation(), M.dataTransfer && w(M.dataTransfer.getData("draggableShapeId"), g.id), !1);
1038
- return u || (H.addEventListener("dragstart", F), H.addEventListener("dragend", A), H.addEventListener("dragover", Z), H.addEventListener("dragenter", E), H.addEventListener("dragleave", S), H.addEventListener("drop", T)), () => {
1039
- u || (H.removeEventListener("dragstart", F), H.removeEventListener("dragend", A), H.removeEventListener("dragover", Z), H.removeEventListener("dragenter", E), H.removeEventListener("dragleave", S), H.removeEventListener("drop", T));
1138
+ const E = () => {
1139
+ M(void 0);
1140
+ }, Z = (S) => (S.preventDefault && S.preventDefault(), !1), H = (S) => {
1141
+ y(v), S.dataTransfer && (S.dataTransfer.effectAllowed = "move", S.dataTransfer.setData("draggableShapeId", v.id), M(v.id));
1142
+ }, C = () => {
1143
+ x !== v.id && L(!0);
1144
+ }, V = () => {
1145
+ L(!1);
1146
+ }, k = (S) => (S.stopPropagation(), S.dataTransfer && P(S.dataTransfer.getData("draggableShapeId"), v.id), !1);
1147
+ return u || (T.addEventListener("dragstart", H), T.addEventListener("dragend", E), T.addEventListener("dragover", Z), T.addEventListener("dragenter", C), T.addEventListener("dragleave", V), T.addEventListener("drop", k)), () => {
1148
+ u || (T.removeEventListener("dragstart", H), T.removeEventListener("dragend", E), T.removeEventListener("dragover", Z), T.removeEventListener("dragenter", C), T.removeEventListener("dragleave", V), T.removeEventListener("drop", k));
1040
1149
  };
1041
- }, [u, f, g, C, x, w, v]), { isOver: y };
1042
- })({ disabled: e, ref: c, shape: i, layoutDragging: n, setLayoutDragging: s, handleSelect: l, onMoveShapes: p });
1043
- return I("div", { className: "react-paint-editor-layout", "data-disabled": +e, draggable: !e, "data-is-dragging": +(n === i.id), "data-is-over": +d, onClick: (u) => {
1150
+ }, [u, g, v, M, y, P, x]), { isOver: Q };
1151
+ })({ disabled: e, ref: d, shape: i, layoutDragging: a, setLayoutDragging: o, handleSelect: l, onMoveShapes: c });
1152
+ return I("div", { className: "react-paint-editor-layout", "data-disabled": +e, draggable: !e, "data-is-dragging": +(a === i.id), "data-is-over": +h, onClick: (u) => {
1044
1153
  e || (u.preventDefault(), u.stopPropagation(), l(i));
1045
- }, "data-selected": +t, ref: c, children: [h("span", { dangerouslySetInnerHTML: { __html: Ra(i.type) } }), h("span", { children: i.id }), h("div", { className: "react-paint-editor-layouts-separator" }), h(j, { className: "react-paint-editor-layouts-visible-button", title: i.visible ? "Hide" : "Show", "data-visible": i.visible !== !1, disabled: e, selected: t, onClick: (u) => {
1046
- e || (u.preventDefault(), u.stopPropagation(), o(i));
1047
- }, icon: i.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>' }), h(j, { className: "react-paint-editor-layouts-locked-button", title: i.locked ? "Locked" : "Unlocked", "data-locked": !!i.locked, disabled: e, selected: t, onClick: (u) => {
1154
+ }, "data-selected": +t, ref: d, children: [p("span", { dangerouslySetInnerHTML: { __html: ua(i.type) } }), p("span", { children: i.id }), p("div", { className: "react-paint-editor-layouts-separator" }), p(B, { className: "react-paint-editor-layouts-visible-button", title: i.visible ? "Hide" : "Show", "data-visible": i.visible !== !1, disabled: e, selected: t, onClick: (u) => {
1155
+ e || (u.preventDefault(), u.stopPropagation(), s(i));
1156
+ }, icon: i.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>' }), p(B, { className: "react-paint-editor-layouts-locked-button", title: i.locked ? "Locked" : "Unlocked", "data-locked": !!i.locked, disabled: e, selected: t, onClick: (u) => {
1157
+ e || (u.preventDefault(), u.stopPropagation(), n(i));
1158
+ }, icon: i.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>' }), p(B, { className: "react-paint-editor-layouts-remove-button", title: "Remove", disabled: e, onClick: (u) => {
1048
1159
  e || (u.preventDefault(), u.stopPropagation(), r(i));
1049
- }, icon: i.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>' }), h(j, { className: "react-paint-editor-layouts-remove-button", title: "Remove", disabled: e, onClick: (u) => {
1050
- e || (u.preventDefault(), u.stopPropagation(), a(i));
1051
- }, icon: X1 })] });
1052
- }, Oa = ({ gridFormat: e, setGridFormat: i, disabled: t = !1, shapes: n, removeShape: o, toggleShapeVisibility: r, toggleShapeLock: s, selectedShape: a, moveShapes: l, selectShape: p, isLayoutPanelShown: c }) => {
1053
- const [d, u] = R(void 0);
1054
- return c ? h(it, { alignment: "right", className: "react-paint-editor-layouts-panel", children: h("div", { className: "react-paint-editor-layouts-panel-content", children: I("div", { className: "react-paint-editor-layouts-scrolling-content", children: [I("div", { className: "react-paint-editor-layouts-row", children: [h("span", { className: "react-paint-editor-layouts-subtitle", children: "Grid" }), h(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 === 0, disabled: t, onClick: () => i(0) }), ["S", "M", "L"].map((f, g) => h(j, { className: "react-paint-editor-layouts-grid-button", selected: e === g + 1, disabled: t, onClick: () => i(g + 1), children: f }, f))] }), h("hr", {}), h("div", { className: "react-paint-editor-layouts", children: n.length === 0 ? h("div", { className: "react-paint-editor-layouts-placeholder", children: "No layer yet" }) : n.map((f) => h($a, { shape: f, disabled: t, layoutDragging: d, setLayoutDragging: u, selected: a?.id === f.id, handleSelect: p, handleRemove: o, onMoveShapes: l, toggleShapeVisibility: r, toggleShapeLock: s }, f.id)) })] }) }) }) : null;
1055
- }, jt = ({ children: e, onClose: i, position: t = "center", className: n = "" }) => I("div", { className: "react-paint-editor-modal", "data-position": t, style: { "--react-paint-editor-modal-zindex": Rt }, children: [h("div", { className: "react-paint-editor-modal-mask", onClick: i }), h("div", { className: `react-paint-editor-modal-panel ${n}`, children: e })] }), ct = ({ selectedSettings: e, setSelectedSettings: i, title: t = "Choisissez une couleur", mode: n = "fill", disabled: o = !1, values: r, field: s, value: a = "", valueChanged: l }) => {
1056
- const [p] = R(ae("settings_")), c = e === p;
1057
- return r.length ? I(pe, { children: [h(j, { selected: c, title: t, disabled: o, onClick: () => {
1058
- i((d) => d === p ? void 0 : p);
1059
- }, icon: a === "transparent" ? n === "fill" ? s1 : o1 : void 0, children: a !== "transparent" && h("div", { className: "react-paint-editor-colorfield-color", "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": a } }) }), c && h(it, { title: t, alignment: "left", children: I("div", { className: "react-paint-editor-colorfield-wrapper", children: [r.map((d, u) => h(j, { title: d, selected: d === a, color: d, icon: d === "transparent" ? n === "fill" ? s1 : o1 : void 0, onClick: () => {
1060
- l(s, d);
1061
- }, children: d !== "transparent" && h("div", { className: "react-paint-editor-colorfield-color", color: d, "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": d } }) }, d)), h(j, { type: "color", title: "Custom color", selected: !r.includes(a), value: a, onChange: (d) => {
1062
- const u = +d.target.value;
1063
- l(s, Number.isNaN(u) ? d.target.value : u);
1064
- }, children: h("div", { className: "react-paint-editor-colorfield-customcolor", style: { "--react-paint-editor-colorfield-color-value": r.includes(a) ? "var(--react-paint-editor-app-font-color)" : a }, children: h("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;
1065
- }, za = ({ disabled: e = !1, selectedShape: i, removeShape: t }) => h(j, { title: "Delete", disabled: e, "data-disabled": +e, onClick: () => {
1160
+ }, icon: Ii })] });
1161
+ }, va = ({ gridFormat: e, setGridFormat: i, disabled: t = !1, shapes: a, removeShape: s, toggleShapeVisibility: n, toggleShapeLock: o, selectedShape: r, moveShapes: l, selectShape: c, isLayoutPanelShown: d }) => {
1162
+ const [h, u] = z(void 0);
1163
+ return d ? p(et, { alignment: "right", className: "react-paint-editor-layouts-panel", children: p("div", { className: "react-paint-editor-layouts-panel-content", children: I("div", { className: "react-paint-editor-layouts-scrolling-content", children: [I("div", { className: "react-paint-editor-layouts-row", children: [p("span", { className: "react-paint-editor-layouts-subtitle", children: "Grid" }), p(B, { 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: t, onClick: () => i("none") }), ["small", "medium", "large"].map((g) => p(B, { className: "react-paint-editor-layouts-grid-button", selected: e === g, disabled: t, onClick: () => i(g), children: g.charAt(0).toUpperCase() }, g))] }), p("hr", {}), p("div", { className: "react-paint-editor-layouts", children: a.length === 0 ? p("div", { className: "react-paint-editor-layouts-placeholder", children: "No layer yet" }) : a.map((g) => p(ga, { shape: g, disabled: t, layoutDragging: h, setLayoutDragging: u, selected: r?.id === g.id, handleSelect: c, handleRemove: s, onMoveShapes: l, toggleShapeVisibility: n, toggleShapeLock: o }, g.id)) })] }) }) }) : null;
1164
+ }, Yt = ({ children: e, onClose: i, position: t = "center", className: a = "" }) => I("div", { className: "react-paint-editor-modal", "data-position": t, style: { "--react-paint-editor-modal-zindex": Oi }, children: [p("div", { className: "react-paint-editor-modal-mask", onClick: i }), p("div", { className: `react-paint-editor-modal-panel ${a}`, children: e })] }), ct = ({ selectedSettings: e, setSelectedSettings: i, title: t = "Choisissez une couleur", mode: a = "fill", disabled: s = !1, values: n, field: o, value: r = "", valueChanged: l }) => {
1165
+ const [c] = z(se("settings_")), d = e === c;
1166
+ return n.length ? I(ue, { children: [p(B, { selected: d, title: t, disabled: s, onClick: () => {
1167
+ i((h) => h === c ? void 0 : c);
1168
+ }, icon: r === "transparent" ? a === "fill" ? ti : ei : void 0, children: r !== "transparent" && p("div", { className: "react-paint-editor-colorfield-color", "data-mode": a, style: { "--react-paint-editor-colorfield-color-value": r } }) }), d && p(et, { title: t, alignment: "left", children: I("div", { className: "react-paint-editor-colorfield-wrapper", children: [n.map((h, u) => p(B, { title: h, selected: h === r, color: h, icon: h === "transparent" ? a === "fill" ? ti : ei : void 0, onClick: () => {
1169
+ l(o, h);
1170
+ }, children: h !== "transparent" && p("div", { className: "react-paint-editor-colorfield-color", color: h, "data-mode": a, style: { "--react-paint-editor-colorfield-color-value": h } }) }, h)), p(B, { type: "color", title: "Custom color", selected: !n.includes(r), value: r, onChange: (h) => {
1171
+ const u = +h.target.value;
1172
+ l(o, Number.isNaN(u) ? h.target.value : u);
1173
+ }, children: p("div", { className: "react-paint-editor-colorfield-customcolor", style: { "--react-paint-editor-colorfield-color-value": n.includes(r) ? "var(--react-paint-editor-app-font-color)" : r }, children: p("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;
1174
+ }, fa = ({ disabled: e = !1, selectedShape: i, removeShape: t }) => p(B, { title: "Delete", disabled: e, "data-disabled": +e, onClick: () => {
1066
1175
  t(i);
1067
- }, icon: X1 }), qt = ({ CustomOption: e, selectedSettings: i, setSelectedSettings: t, title: n = "Choisissez l'option", disabled: o = !1, field: r, icon: s, values: a, defaultValue: l, valueChanged: p }) => {
1068
- const [c] = R(ae("settings_")), d = i === c;
1069
- return a.length ? I(pe, { children: [h(j, { selected: d, title: n, icon: s, disabled: o, onClick: () => {
1070
- t((u) => u === c ? void 0 : c);
1071
- } }), d && h(it, { title: n, alignment: "left", fitContainer: !0, children: h("div", { className: "react-paint-editor-selectfield-wrapper", children: a.map((u) => h(j, { title: `${u}`, onClick: () => ((f) => {
1072
- p(r, f);
1073
- })(u), selected: l === u, style: { "--react-paint-editor-button-padding": "16px" }, children: h(e, { children: u }) }, u)) }) })] }) : null;
1074
- }, Ua = ({ children: e }) => h("span", { className: "react-paint-editor-fontfamily-option", style: { "--react-paint-editor-fontfamily-family": e }, children: e }), F1 = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: n, defaultValue: o, valueChanged: r }) => n.length ? h(qt, { selectedSettings: e, setSelectedSettings: i, CustomOption: Ua, 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: t, field: "fontFamily", values: n, defaultValue: o, valueChanged: r }) : null, Ba = ({ disabled: e, toggleLayoutPanel: i }) => h(j, { title: "Toggle layers panel", disabled: e, onClick: i, 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" }), Xa = ({ children: e }) => I("span", { className: "react-paint-editor-linearrow-option", "data-type": e, children: [h("span", { className: "react-paint-editor-linearrow-left" }), h("span", { className: "react-paint-editor-linearrow-right" })] }), N1 = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: n, defaultValue: o, valueChanged: r }) => n.length ? h(qt, { selectedSettings: e, setSelectedSettings: i, CustomOption: Xa, 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: t, field: "lineArrow", values: n, defaultValue: o, valueChanged: r }) : null, Ya = ({ children: e }) => I("span", { className: "react-paint-editor-linetype-option", "data-type": e, children: [h("span", {}), h("span", {}), h("span", {}), h("span", {}), h("span", {}), h("span", {}), h("span", {})] }), D1 = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: n, defaultValue: o, valueChanged: r }) => n.length ? h(qt, { selectedSettings: e, setSelectedSettings: i, CustomOption: Ya, 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: t, field: "lineDash", values: n, defaultValue: o, valueChanged: r }) : null, nt = ({ selectedSettings: e, setSelectedSettings: i, title: t = "Choisissez l'intervalle", icon: n, disabled: o = !1, field: r, value: s = 1, min: a = 1, max: l = 20, step: p = 1, unity: c = "", valueChanged: d }) => {
1075
- const u = Math.round(s), [f] = R(ae("settings_")), g = ee(null);
1076
- Y(() => () => {
1077
- g.current && clearTimeout(g.current);
1176
+ }, icon: Ii }), jt = ({ CustomOption: e, selectedSettings: i, setSelectedSettings: t, title: a = "Choisissez l'option", disabled: s = !1, field: n, icon: o, values: r, defaultValue: l, valueChanged: c }) => {
1177
+ const [d] = z(se("settings_")), h = i === d;
1178
+ return r.length ? I(ue, { children: [p(B, { selected: h, title: a, icon: o, disabled: s, onClick: () => {
1179
+ t((u) => u === d ? void 0 : d);
1180
+ } }), h && p(et, { title: a, alignment: "left", fitContainer: !0, children: p("div", { className: "react-paint-editor-selectfield-wrapper", children: r.map((u) => p(B, { title: `${u}`, onClick: () => ((g) => {
1181
+ c(n, g);
1182
+ })(u), selected: l === u, style: { "--react-paint-editor-button-padding": "16px" }, children: p(e, { children: u }) }, u)) }) })] }) : null;
1183
+ }, ma = ({ children: e }) => p("span", { className: "react-paint-editor-fontfamily-option", style: { "--react-paint-editor-fontfamily-family": e }, children: e }), Hi = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: a, defaultValue: s, valueChanged: n }) => a.length ? p(jt, { selectedSettings: e, setSelectedSettings: i, CustomOption: ma, 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: t, field: "fontFamily", values: a, defaultValue: s, valueChanged: n }) : null, ya = ({ disabled: e, toggleLayoutPanel: i }) => p(B, { title: "Toggle layers panel", disabled: e, onClick: i, 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" }), Qa = ({ children: e }) => I("span", { className: "react-paint-editor-linearrow-option", "data-type": e, children: [p("span", { className: "react-paint-editor-linearrow-left" }), p("span", { className: "react-paint-editor-linearrow-right" })] }), Ti = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: a, defaultValue: s, valueChanged: n }) => a.length ? p(jt, { selectedSettings: e, setSelectedSettings: i, CustomOption: Qa, 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: t, field: "lineArrow", values: a, defaultValue: s, valueChanged: n }) : null, Sa = ({ children: e }) => I("span", { className: "react-paint-editor-linetype-option", "data-type": e, children: [p("span", {}), p("span", {}), p("span", {}), p("span", {}), p("span", {}), p("span", {}), p("span", {})] }), Ai = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: a, defaultValue: s, valueChanged: n }) => a.length ? p(jt, { selectedSettings: e, setSelectedSettings: i, CustomOption: Sa, 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: t, field: "lineDash", values: a, defaultValue: s, valueChanged: n }) : null, at = ({ selectedSettings: e, setSelectedSettings: i, title: t = "Choisissez l'intervalle", icon: a, disabled: s = !1, field: n, value: o = 1, min: r = 1, max: l = 20, step: c = 1, unity: d = "", valueChanged: h }) => {
1184
+ const u = Math.round(o), [g] = z(se("settings_")), v = ae(null);
1185
+ U(() => () => {
1186
+ v.current && clearTimeout(v.current);
1078
1187
  }, []);
1079
- const v = e === f;
1080
- return a === l ? null : I(pe, { children: [h(j, { selected: v, title: t, disabled: o, icon: n, onClick: () => {
1081
- i((C) => C === f ? void 0 : f);
1082
- } }), v && h(it, { title: t, alignment: "left", fitContainer: !0, children: h("div", { children: I("label", { className: "react-paint-editor-rangefield", children: [h("input", { type: "range", min: a, max: l, step: p, value: s, onChange: (C) => {
1083
- const x = +C.target.value;
1084
- d(r, Number.isNaN(x) ? C.target.value : x, !1), g.current && clearTimeout(g.current), g.current = setTimeout(() => {
1085
- d(r, Number.isNaN(x) ? C.target.value : x, !0);
1188
+ const x = e === g;
1189
+ return r === l ? null : I(ue, { children: [p(B, { selected: x, title: t, disabled: s, icon: a, onClick: () => {
1190
+ i((M) => M === g ? void 0 : g);
1191
+ } }), x && p(et, { title: t, alignment: "left", fitContainer: !0, children: p("div", { children: I("label", { className: "react-paint-editor-rangefield", children: [p("input", { type: "range", min: r, max: l, step: c, value: o, onChange: (M) => {
1192
+ const y = +M.target.value;
1193
+ h(n, Number.isNaN(y) ? M.target.value : y, !1), v.current && clearTimeout(v.current), v.current = setTimeout(() => {
1194
+ h(n, Number.isNaN(y) ? M.target.value : y, !0);
1086
1195
  }, 1e3);
1087
- } }), I("span", { children: [u, c] })] }) }) })] });
1088
- }, E1 = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, min: n, max: o, step: r, value: s, valueChanged: a }) => n === o ? null : h(nt, { selectedSettings: e, setSelectedSettings: i, icon: zt, title: "Nombre de points", disabled: t, field: "pointsCount", min: n, max: o, step: r, unity: "", value: s, valueChanged: a }), pt = ({ setSelectedSettings: e, disabled: i = !1, field: t, icon: n, values: o, value: r = !1, valueChanged: s }) => {
1089
- const [a] = R(ae("settings_"));
1090
- return o.length !== 2 ? null : h(j, { onClick: () => {
1091
- e((l) => l === a ? void 0 : a), s(t, !r);
1092
- }, selected: r, disabled: i, icon: n });
1093
- }, Ft = ({ activeTool: e, selectedShape: i, selectedShapeTool: t, disabled: n, selectedSettings: o, setSelectedSettings: r, handleShapeStyleChange: s, handlePolygonLinesCount: a, handleShapeFontFamilyChange: l }) => i ? h(pe, { children: t && I(pe, { children: ["strokeColor" in t.settings && h(ct, { selectedSettings: o, setSelectedSettings: r, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: i.style?.strokeColor, valueChanged: s, values: t.settings.strokeColor.values }), "fillColor" in t.settings && h(ct, { selectedSettings: o, setSelectedSettings: r, title: "Couleur de fond", disabled: n, field: "fillColor", value: i.style?.fillColor, valueChanged: s, values: t.settings.fillColor.values }), "lineWidth" in t.settings && h(nt, { selectedSettings: o, setSelectedSettings: r, title: "Epaisseur du trait", icon: n1, disabled: n, field: "lineWidth", value: i.style?.lineWidth, valueChanged: s, unity: "px", min: t.settings.lineWidth.min, max: t.settings.lineWidth.max, step: t.settings.lineWidth.step }), "lineDash" in t.settings && h(D1, { selectedSettings: o, setSelectedSettings: r, disabled: n, defaultValue: i.style?.lineDash, valueChanged: s, values: t.settings.lineDash.values }), "lineArrow" in t.settings && h(N1, { selectedSettings: o, setSelectedSettings: r, disabled: n, defaultValue: i.style?.lineArrow, valueChanged: s, values: t.settings.lineArrow.values }), "pointsCount" in t.settings && h(E1, { selectedSettings: o, setSelectedSettings: r, disabled: n, valueChanged: a, min: t.settings.pointsCount.min, max: t.settings.pointsCount.max, step: t.settings.pointsCount.step, value: i.style?.pointsCount }), "fontFamily" in t.settings && h(F1, { selectedSettings: o, setSelectedSettings: r, disabled: n, valueChanged: l, values: t.settings.fontFamily.values, defaultValue: i.style?.fontFamily }), "fontBold" in t.settings && h(pt, { setSelectedSettings: r, disabled: n, field: "fontBold", icon: i1, valueChanged: l, values: t.settings.fontBold.values, value: i.style?.fontBold }), "fontItalic" in t.settings && h(pt, { setSelectedSettings: r, disabled: n, field: "fontItalic", icon: a1, valueChanged: l, values: t.settings.fontItalic.values, value: i.style?.fontItalic }), "opacity" in t.settings && h(nt, { selectedSettings: o, setSelectedSettings: r, title: "Opacité", icon: t1, min: t.settings.opacity.min, max: t.settings.opacity.max, step: t.settings.opacity.step, unity: "%", disabled: n, field: "opacity", value: i.style?.opacity ?? 100, valueChanged: s })] }) }) : "settings" in e ? I(pe, { children: ["strokeColor" in e.settings && h(ct, { selectedSettings: o, setSelectedSettings: r, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: e.settings.strokeColor.default, valueChanged: s, values: e.settings.strokeColor.values }), "fillColor" in e.settings && h(ct, { selectedSettings: o, setSelectedSettings: r, title: "Couleur de fond", disabled: n, field: "fillColor", value: e.settings.fillColor.default, valueChanged: s, values: e.settings.fillColor.values }), "lineWidth" in e.settings && h(nt, { selectedSettings: o, setSelectedSettings: r, title: "Epaisseur du trait", disabled: n, field: "lineWidth", icon: n1, 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 && h(D1, { selectedSettings: o, setSelectedSettings: r, disabled: n, defaultValue: e.settings.lineDash.default, valueChanged: s, values: e.settings.lineDash.values }), "lineArrow" in e.settings && h(N1, { selectedSettings: o, setSelectedSettings: r, disabled: n, defaultValue: e.settings.lineArrow.default, valueChanged: s, values: e.settings.lineArrow.values }), "pointsCount" in e.settings && h(E1, { selectedSettings: o, setSelectedSettings: r, disabled: n, valueChanged: a, min: e.settings.pointsCount.min, max: e.settings.pointsCount.max, step: e.settings.pointsCount.step, value: e.settings.pointsCount.default }), "fontFamily" in e.settings && h(F1, { selectedSettings: o, setSelectedSettings: r, disabled: n, valueChanged: l, values: e.settings.fontFamily.values, defaultValue: e.settings.fontFamily.default }), "fontBold" in e.settings && h(pt, { setSelectedSettings: r, disabled: n, field: "fontBold", icon: i1, valueChanged: l, values: e.settings.fontBold.values, value: e.settings.fontBold.default }), "fontItalic" in e.settings && h(pt, { setSelectedSettings: r, disabled: n, field: "fontItalic", icon: a1, valueChanged: l, values: e.settings.fontItalic.values, value: e.settings.fontItalic.default }), "opacity" in e.settings && h(nt, { selectedSettings: o, setSelectedSettings: r, title: "Opacité", icon: t1, min: e.settings.opacity.min, max: e.settings.opacity.max, step: e.settings.opacity.step, unity: "%", disabled: n, field: "opacity", value: e.settings.opacity.default, valueChanged: s })] }) : null, _a = ({ width: e, disabled: i = !1, availableTools: t, updateToolSettings: n, layersManipulation: o, toggleLayoutPanel: r, activeTool: s, selectedShape: a, canvas: l, currentScale: p, selectionPadding: c, updateShape: d, removeShape: u }) => {
1094
- const [f, g] = R(void 0), [v, C] = R(!1), x = () => {
1095
- C((F) => !F);
1096
- }, w = a ? t.find((F) => F.id === a.toolId) || t.find((F) => F.type === a.type) : void 0, y = (w ? Object.keys(w.settings).length + 1 : "settings" in s ? Object.keys(s.settings).length : 0) + (o ? 1 : 0), b = e < 40 * y, H = (F, E, S = !0) => {
1097
- a ? (d(st(ce(["style", F], E, a), p, c), S), w && n(w.id, F, E)) : n(s.id, F, E);
1098
- }, A = (F, E) => {
1099
- if (a) {
1100
- if (a.type !== "text")
1196
+ } }), I("span", { children: [u, d] })] }) }) })] });
1197
+ }, Zi = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, min: a, max: s, step: n, value: o, valueChanged: r }) => a === s ? null : p(at, { selectedSettings: e, setSelectedSettings: i, icon: zt, title: "Nombre de points", disabled: t, field: "pointsCount", min: a, max: s, step: n, unity: "", value: o, valueChanged: r }), ht = ({ setSelectedSettings: e, disabled: i = !1, field: t, icon: a, values: s, value: n = !1, valueChanged: o }) => {
1198
+ const [r] = z(se("settings_"));
1199
+ return s.length !== 2 ? null : p(B, { onClick: () => {
1200
+ e((l) => l === r ? void 0 : r), o(t, !n);
1201
+ }, selected: n, disabled: i, icon: a });
1202
+ }, Zt = ({ activeTool: e, selectedShape: i, selectedShapeTool: t, disabled: a, selectedSettings: s, setSelectedSettings: n, handleShapeStyleChange: o, handlePolygonLinesCount: r, handleShapeFontFamilyChange: l }) => i ? p(ue, { children: t && I(ue, { children: ["strokeColor" in t.settings && p(ct, { selectedSettings: s, setSelectedSettings: n, title: "Couleur du trait", mode: "stroke", disabled: a, field: "strokeColor", value: i.style?.strokeColor, valueChanged: o, values: t.settings.strokeColor.values }), "fillColor" in t.settings && p(ct, { selectedSettings: s, setSelectedSettings: n, title: "Couleur de fond", disabled: a, field: "fillColor", value: i.style?.fillColor, valueChanged: o, values: t.settings.fillColor.values }), "lineWidth" in t.settings && p(at, { selectedSettings: s, setSelectedSettings: n, title: "Epaisseur du trait", icon: Kt, disabled: a, field: "lineWidth", value: i.style?.lineWidth, valueChanged: o, unity: "px", min: t.settings.lineWidth.min, max: t.settings.lineWidth.max, step: t.settings.lineWidth.step }), "lineDash" in t.settings && p(Ai, { selectedSettings: s, setSelectedSettings: n, disabled: a, defaultValue: i.style?.lineDash, valueChanged: o, values: t.settings.lineDash.values }), "lineArrow" in t.settings && p(Ti, { selectedSettings: s, setSelectedSettings: n, disabled: a, defaultValue: i.style?.lineArrow, valueChanged: o, values: t.settings.lineArrow.values }), "pointsCount" in t.settings && p(Zi, { selectedSettings: s, setSelectedSettings: n, disabled: a, valueChanged: r, min: t.settings.pointsCount.min, max: t.settings.pointsCount.max, step: t.settings.pointsCount.step, value: i.style?.pointsCount }), "fontFamily" in t.settings && p(Hi, { selectedSettings: s, setSelectedSettings: n, disabled: a, valueChanged: l, values: t.settings.fontFamily.values, defaultValue: i.style?.fontFamily }), "fontBold" in t.settings && p(ht, { setSelectedSettings: n, disabled: a, field: "fontBold", icon: qt, valueChanged: l, values: t.settings.fontBold.values, value: i.style?.fontBold }), "fontItalic" in t.settings && p(ht, { setSelectedSettings: n, disabled: a, field: "fontItalic", icon: Jt, valueChanged: l, values: t.settings.fontItalic.values, value: i.style?.fontItalic }), "opacity" in t.settings && p(at, { selectedSettings: s, setSelectedSettings: n, title: "Opacité", icon: _t, min: t.settings.opacity.min, max: t.settings.opacity.max, step: t.settings.opacity.step, unity: "%", disabled: a, field: "opacity", value: i.style?.opacity ?? 100, valueChanged: o })] }) }) : "settings" in e ? I(ue, { children: ["strokeColor" in e.settings && p(ct, { selectedSettings: s, setSelectedSettings: n, title: "Couleur du trait", mode: "stroke", disabled: a, field: "strokeColor", value: e.settings.strokeColor.default, valueChanged: o, values: e.settings.strokeColor.values }), "fillColor" in e.settings && p(ct, { selectedSettings: s, setSelectedSettings: n, title: "Couleur de fond", disabled: a, field: "fillColor", value: e.settings.fillColor.default, valueChanged: o, values: e.settings.fillColor.values }), "lineWidth" in e.settings && p(at, { selectedSettings: s, setSelectedSettings: n, title: "Epaisseur du trait", disabled: a, field: "lineWidth", icon: Kt, value: e.settings.lineWidth.default, valueChanged: o, unity: "px", min: e.settings.lineWidth.min, max: e.settings.lineWidth.max, step: e.settings.lineWidth.step }), "lineDash" in e.settings && p(Ai, { selectedSettings: s, setSelectedSettings: n, disabled: a, defaultValue: e.settings.lineDash.default, valueChanged: o, values: e.settings.lineDash.values }), "lineArrow" in e.settings && p(Ti, { selectedSettings: s, setSelectedSettings: n, disabled: a, defaultValue: e.settings.lineArrow.default, valueChanged: o, values: e.settings.lineArrow.values }), "pointsCount" in e.settings && p(Zi, { selectedSettings: s, setSelectedSettings: n, disabled: a, valueChanged: r, min: e.settings.pointsCount.min, max: e.settings.pointsCount.max, step: e.settings.pointsCount.step, value: e.settings.pointsCount.default }), "fontFamily" in e.settings && p(Hi, { selectedSettings: s, setSelectedSettings: n, disabled: a, valueChanged: l, values: e.settings.fontFamily.values, defaultValue: e.settings.fontFamily.default }), "fontBold" in e.settings && p(ht, { setSelectedSettings: n, disabled: a, field: "fontBold", icon: qt, valueChanged: l, values: e.settings.fontBold.values, value: e.settings.fontBold.default }), "fontItalic" in e.settings && p(ht, { setSelectedSettings: n, disabled: a, field: "fontItalic", icon: Jt, valueChanged: l, values: e.settings.fontItalic.values, value: e.settings.fontItalic.default }), "opacity" in e.settings && p(at, { selectedSettings: s, setSelectedSettings: n, title: "Opacité", icon: _t, 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: o })] }) : null, ba = ({ width: e, disabled: i = !1, availableTools: t, updateToolSettings: a, layersManipulation: s, toggleLayoutPanel: n, activeTool: o, selectedShape: r, canvas: l, settings: c, updateShape: d, removeShape: h }) => {
1203
+ const [u, g] = z(void 0), [v, x] = z(!1), M = () => {
1204
+ x((Z) => !Z);
1205
+ }, y = r ? t.find((Z) => Z.id === r.toolId) || t.find((Z) => Z.type === r.type) : void 0, P = (y ? Object.keys(y.settings).length + 1 : "settings" in o ? Object.keys(o.settings).length : 0) + (s ? 1 : 0), Q = e < 40 * P, L = (Z, H, C = !0) => {
1206
+ r ? (d(st(le(["style", Z], H, r), c), C), y && a(y.id, Z, H)) : a(o.id, Z, H);
1207
+ }, T = (Z, H) => {
1208
+ if (r) {
1209
+ if (r.type !== "text")
1101
1210
  return;
1102
- const S = l?.getContext("2d");
1103
- if (!S)
1211
+ const C = l?.getContext("2d");
1212
+ if (!C)
1104
1213
  return;
1105
- const T = ce(["style", F], E, a), M = _t(S, T.value, T.width, T.style?.fontBold ?? !1, T.style?.fontItalic ?? !1, T.style?.fontFamily), B = st({ ...T, fontSize: M, height: M * T.value.length }, p, c);
1106
- d(B, !0), w && n(w.id, F, E);
1214
+ const V = le(["style", Z], H, r), k = Bt(C, V.value, V.width, V.style?.fontBold ?? !1, V.style?.fontItalic ?? !1, V.style?.fontFamily), S = st({ ...V, fontSize: k, height: k * V.value.length }, c);
1215
+ d(S, !0), y && a(y.id, Z, H);
1107
1216
  } else
1108
- n(s.id, F, E);
1109
- }, Z = (F, E) => {
1110
- if (a) {
1111
- if (a.type !== "polygon" && a.type !== "curve")
1217
+ a(o.id, Z, H);
1218
+ }, E = (Z, H) => {
1219
+ if (r) {
1220
+ if (r.type !== "polygon" && r.type !== "curve")
1112
1221
  return;
1113
- d(a.type === "polygon" ? ((S, T, M, B) => {
1114
- const N = S.points.length;
1115
- if (N === T)
1116
- return S;
1117
- if (N > T) {
1118
- const V = S.points.slice(0, T);
1119
- return Je({ ...S, points: V, style: { ...S.style, pointsCount: V.length } }, M, B);
1222
+ d(r.type === "polygon" ? ((C, V, k) => {
1223
+ const S = C.points.length;
1224
+ if (S === V)
1225
+ return C;
1226
+ if (S > V) {
1227
+ const N = C.points.slice(0, V);
1228
+ return _e({ ...C, points: N, style: { ...C.style, pointsCount: N.length } }, k);
1120
1229
  }
1121
- const Q = T - N, k = new Array(Q).fill(void 0).map((V, L) => [S.points[0][0] + (S.points[1][0] - S.points[0][0]) * (L + 1) / (Q + 1), S.points[0][1] + (S.points[1][1] - S.points[0][1]) * (L + 1) / (Q + 1)]), m = [S.points[0], ...k, ...S.points.slice(1, S.points.length)];
1122
- return Je({ ...S, points: m, style: { ...S.style, pointsCount: m.length } }, M, B);
1123
- })(a, E, p, c) : ((S, T, M, B) => {
1124
- const N = S.points.length;
1125
- if (N === T)
1126
- return S;
1127
- if (N > T) {
1128
- const V = S.points.slice(0, T);
1129
- return Ke({ ...S, points: V, style: { ...S.style, pointsCount: V.length } }, M, B);
1230
+ const F = V - S, w = new Array(F).fill(void 0).map((N, f) => [C.points[0][0] + (C.points[1][0] - C.points[0][0]) * (f + 1) / (F + 1), C.points[0][1] + (C.points[1][1] - C.points[0][1]) * (f + 1) / (F + 1)]), A = [C.points[0], ...w, ...C.points.slice(1, C.points.length)];
1231
+ return _e({ ...C, points: A, style: { ...C.style, pointsCount: A.length } }, k);
1232
+ })(r, H, c) : ((C, V, k) => {
1233
+ const S = C.points.length;
1234
+ if (S === V)
1235
+ return C;
1236
+ if (S > V) {
1237
+ const N = C.points.slice(0, V);
1238
+ return qe({ ...C, points: N, style: { ...C.style, pointsCount: N.length } }, k);
1130
1239
  }
1131
- const Q = T - N, k = new Array(Q).fill(void 0).map((V, L) => [S.points[0][0] + (S.points[1][0] - S.points[0][0]) * (L + 1) / (Q + 1), S.points[0][1] + (S.points[1][1] - S.points[0][1]) * (L + 1) / (Q + 1)]), m = [S.points[0], ...k, ...S.points.slice(1, S.points.length)];
1132
- return Ke({ ...S, points: m, style: { ...S.style, pointsCount: m.length } }, M, B);
1133
- })(a, E, p, c), !0), w && n(w.id, F, E);
1240
+ const F = V - S, w = new Array(F).fill(void 0).map((N, f) => [C.points[0][0] + (C.points[1][0] - C.points[0][0]) * (f + 1) / (F + 1), C.points[0][1] + (C.points[1][1] - C.points[0][1]) * (f + 1) / (F + 1)]), A = [C.points[0], ...w, ...C.points.slice(1, C.points.length)];
1241
+ return qe({ ...C, points: A, style: { ...C.style, pointsCount: A.length } }, k);
1242
+ })(r, H, c), !0), y && a(y.id, Z, H);
1134
1243
  } else
1135
- n(s.id, F, E);
1244
+ a(o.id, Z, H);
1136
1245
  };
1137
- return I(pe, { children: [I("div", { className: "react-paint-editor-settings-bar", children: [I("div", { className: "react-paint-editor-settings-shrinkable", children: [b && y > 2 && h(j, { disabled: i, onClick: x, 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>' }), a ? h(pe, { children: w && I(pe, { children: [!b && h(Ft, { activeTool: s, selectedShape: a, selectedShapeTool: w, disabled: i, selectedSettings: f, setSelectedSettings: g, handleShapeStyleChange: H, handlePolygonLinesCount: Z, handleShapeFontFamilyChange: A }), h(za, { disabled: i, selectedShape: a, removeShape: u })] }) }) : !b && h(Ft, { activeTool: s, selectedShape: a, selectedShapeTool: w, disabled: i, selectedSettings: f, setSelectedSettings: g, handleShapeStyleChange: H, handlePolygonLinesCount: Z, handleShapeFontFamilyChange: A })] }), h("div", { className: "react-paint-editor-settings-separator" }), o && h(Ba, { disabled: i, toggleLayoutPanel: r })] }), v && h(jt, { className: "react-paint-editor-settings-modal", onClose: x, position: "bottom", children: h(Ft, { activeTool: s, selectedShape: a, selectedShapeTool: w, disabled: i, selectedSettings: f, setSelectedSettings: g, handleShapeStyleChange: H, handlePolygonLinesCount: Z, handleShapeFontFamilyChange: A }) })] });
1138
- }, I1 = ({ disabled: e = !1, withText: i = !1, loadFile: t, type: n, img: o, accept: r }) => {
1139
- const s = ee(null);
1140
- return h(j, { ref: s, type: "file", onClick: (a) => {
1141
- a.stopPropagation(), s.current && (s.current.value = "");
1142
- }, onChange: (a) => {
1143
- const l = a.target.files?.item(0);
1246
+ return I(ue, { children: [I("div", { className: "react-paint-editor-settings-bar", children: [I("div", { className: "react-paint-editor-settings-shrinkable", children: [Q && P > 2 && p(B, { disabled: i, 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 ? p(ue, { children: y && I(ue, { children: [!Q && p(Zt, { activeTool: o, selectedShape: r, selectedShapeTool: y, disabled: i, selectedSettings: u, setSelectedSettings: g, handleShapeStyleChange: L, handlePolygonLinesCount: E, handleShapeFontFamilyChange: T }), p(fa, { disabled: i, selectedShape: r, removeShape: h })] }) }) : !Q && p(Zt, { activeTool: o, selectedShape: r, selectedShapeTool: y, disabled: i, selectedSettings: u, setSelectedSettings: g, handleShapeStyleChange: L, handlePolygonLinesCount: E, handleShapeFontFamilyChange: T })] }), p("div", { className: "react-paint-editor-settings-separator" }), s && p(ya, { disabled: i, toggleLayoutPanel: n })] }), v && p(Yt, { className: "react-paint-editor-settings-modal", onClose: M, position: "bottom", children: p(Zt, { activeTool: o, selectedShape: r, selectedShapeTool: y, disabled: i, selectedSettings: u, setSelectedSettings: g, handleShapeStyleChange: L, handlePolygonLinesCount: E, handleShapeFontFamilyChange: T }) })] });
1247
+ }, Ei = ({ disabled: e = !1, withText: i = !1, loadFile: t, type: a, img: s, accept: n }) => {
1248
+ const o = ae(null);
1249
+ return p(B, { ref: o, type: "file", onClick: (r) => {
1250
+ r.stopPropagation(), o.current && (o.current.value = "");
1251
+ }, onChange: (r) => {
1252
+ const l = r.target.files?.item(0);
1144
1253
  l && t(l);
1145
- }, accept: r, title: n.label ?? n.type, icon: o, children: i ? n.label : void 0, disabled: e });
1146
- }, ge = ({ type: e, img: i, isActive: t, withText: n = !1, disabled: o = !1, setActive: r }) => h(j, { disabled: o, selected: t, onClick: () => {
1147
- r(e);
1148
- }, title: e.label ?? e.type, icon: i, children: n ? e.label : void 0 }), ja = ({ activeTool: e, withActionsInMenu: i, hasActionToUndo: t = !1, hasActionToRedo: n = !1, hasActionToClear: o = !1, undoAction: r, redoAction: s, clearCanvas: a, alignment: l, group: p, vertical: c = !1, disabled: d = !1, withLoadAndSave: u, withExport: f, addPicture: g, loadFile: v, togglePictureUrlModal: C, saveFile: x, exportCanvasInFile: w, withUploadPicture: y, withUrlPicture: b }) => {
1149
- const [H, A] = R(!1), [, Z] = R1(), F = p?.tools?.some((S) => S === e.type), E = (F ? e.icon : p.img) ?? p.title;
1150
- return Y(() => {
1151
- if (!H)
1254
+ }, accept: n, title: a.label ?? a.type, icon: s, disabled: e, children: i ? a.label : void 0 });
1255
+ }, ge = ({ type: e, img: i, isActive: t, withText: a = !1, disabled: s = !1, setActive: n }) => p(B, { disabled: s, selected: t, onClick: () => {
1256
+ n(e);
1257
+ }, title: e.label ?? e.type, icon: i, children: a ? e.label : void 0 }), Ca = ({ activeTool: e, withActionsInMenu: i, hasActionToUndo: t = !1, hasActionToRedo: a = !1, hasActionToClear: s = !1, undoAction: n, redoAction: o, clearCanvas: r, alignment: l, group: c, vertical: d = !1, disabled: h = !1, withLoadAndSave: u, withExport: g, addPicture: v, loadFile: x, togglePictureUrlModal: M, saveFile: y, exportCanvasInFile: P, withUploadPicture: Q, withUrlPicture: L }) => {
1258
+ const [T, E] = z(!1), [, Z] = Ni(), H = c?.tools?.some((V) => V === e.type), C = (H ? e.icon : c.img) ?? c.title;
1259
+ return U(() => {
1260
+ if (!T)
1152
1261
  return;
1153
- const S = () => {
1154
- A(!1);
1262
+ const V = () => {
1263
+ E(!1);
1155
1264
  };
1156
- return document.addEventListener("click", S), () => {
1157
- document.removeEventListener("click", S);
1265
+ return document.addEventListener("click", V), () => {
1266
+ document.removeEventListener("click", V);
1158
1267
  };
1159
- }, [H]), i || y || b || u || f ? I("div", { className: "react-paint-editor-toolbox-relative", children: [h(j, { selected: F, title: p.title, disabled: d, onClick: () => {
1268
+ }, [T]), i || Q || L || u || g ? I("div", { className: "react-paint-editor-toolbox-relative", children: [p(B, { selected: H, title: c.title, disabled: h, onClick: () => {
1160
1269
  Z(() => {
1161
- A(!0);
1270
+ E(!0);
1162
1271
  });
1163
- }, icon: E }), H && h(it, { alignment: l, position: "top", children: I("div", { className: "react-paint-editor-toolbox-panel-content", "data-vertical": +c, children: [i && I(pe, { children: [h(ge, { withText: !0, type: je, disabled: d || !t, img: je.icon, isActive: e.id === je.id, setActive: r }), h(ge, { withText: !0, type: qe, disabled: d || !n, img: qe.icon, isActive: e.id === qe.id, setActive: s }), h(ge, { withText: !0, type: Ge, disabled: d || !o, img: Ge.icon, isActive: e.id === Ge.id, setActive: a }), (y || b || u) && h("hr", {})] }), y && h(I1, { withText: !0, type: l1, disabled: d, loadFile: async (S) => {
1164
- A(!1), await g(S);
1165
- }, img: l1.icon, accept: "image/png, image/gif, image/jpeg, image/svg+xml" }), b && h(j, { 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" }), (y || b) && u && h("hr", {}), u && I(pe, { children: [h(I1, { withText: !0, type: r1, disabled: d, loadFile: (S) => {
1166
- A(!1), v(S);
1167
- }, img: r1.icon, accept: "application/JSON" }), h(ge, { withText: !0, disabled: d, type: Ht, img: Ht.icon, isActive: e.id === Ht.id, setActive: x })] }), f && h(ge, { withText: !0, disabled: d, type: Vt, img: Vt.icon, isActive: e.id === Vt.id, setActive: w })] }) })] }) : null;
1168
- }, qa = ({ togglePictureUrlModal: e, addPicture: i }) => {
1169
- const t = ee(null);
1170
- return Y(() => {
1272
+ }, icon: C }), T && p(et, { alignment: l, position: "top", children: I("div", { className: "react-paint-editor-toolbox-panel-content", "data-vertical": +d, children: [i && I(ue, { children: [p(ge, { withText: !0, type: Xe, disabled: h || !t, img: Xe.icon, isActive: e.id === Xe.id, setActive: n }), p(ge, { withText: !0, type: Ye, disabled: h || !a, img: Ye.icon, isActive: e.id === Ye.id, setActive: o }), p(ge, { withText: !0, type: je, disabled: h || !s, img: je.icon, isActive: e.id === je.id, setActive: r }), (Q || L || u) && p("hr", {})] }), Q && p(Ei, { withText: !0, type: ni, disabled: h, loadFile: async (V) => {
1273
+ E(!1), await v(V);
1274
+ }, img: ni.icon, accept: "image/png, image/gif, image/jpeg, image/svg+xml" }), L && p(B, { disabled: h, 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" }), (Q || L) && u && p("hr", {}), u && I(ue, { children: [p(Ei, { withText: !0, type: ai, disabled: h, loadFile: (V) => {
1275
+ E(!1), x(V);
1276
+ }, img: ai.icon, accept: "application/JSON" }), p(ge, { withText: !0, disabled: h, type: Vt, img: Vt.icon, isActive: e.id === Vt.id, setActive: y })] }), g && p(ge, { withText: !0, disabled: h, type: Lt, img: Lt.icon, isActive: e.id === Lt.id, setActive: P })] }) })] }) : null;
1277
+ }, wa = ({ togglePictureUrlModal: e, addPicture: i }) => {
1278
+ const t = ae(null);
1279
+ return U(() => {
1171
1280
  t.current && t.current.focus();
1172
- }, []), h(jt, { className: "react-paint-editor-toolbox-pictureinput-modal", onClose: e, children: I("form", { onSubmit: async (n) => {
1173
- n.preventDefault();
1174
- const o = t.current?.value;
1175
- o && (await i(o), e());
1176
- }, children: [I("label", { children: ["URL ", h("input", { type: "text", ref: t })] }), h(j, { onClick: e, children: "Annuler" }), h(j, { type: "submit", selected: !0, children: "Ajouter" })] }) });
1177
- }, Ga = ({ activeTool: e, alignment: i, group: t, disabled: n = !1, setActiveToolFromId: o }) => {
1178
- const r = ee(null), [s, a] = R(!1), [, l] = R1(), [p, c] = R(void 0), d = (g) => {
1179
- c(g), o(g.id);
1281
+ }, []), p(Yt, { className: "react-paint-editor-toolbox-pictureinput-modal", onClose: e, children: I("form", { onSubmit: async (a) => {
1282
+ a.preventDefault();
1283
+ const s = t.current?.value;
1284
+ s && (await i(s), e());
1285
+ }, children: [I("label", { children: ["URL ", p("input", { type: "text", ref: t })] }), p(B, { onClick: e, children: "Annuler" }), p(B, { type: "submit", selected: !0, children: "Ajouter" })] }) });
1286
+ }, xa = ({ activeTool: e, alignment: i, group: t, disabled: a = !1, setActiveToolFromId: s }) => {
1287
+ const n = ae(null), [o, r] = z(!1), [, l] = Ni(), [c, d] = z(void 0), h = (v) => {
1288
+ d(v), s(v.id);
1180
1289
  };
1181
- if (Y(() => {
1182
- if (!s)
1290
+ if (U(() => {
1291
+ if (!o)
1183
1292
  return;
1184
- const g = (v) => {
1185
- !ri(v, r.current) && a(!1);
1293
+ const v = (x) => {
1294
+ !s1(x, n.current) && r(!1);
1186
1295
  };
1187
- return document.addEventListener("mousedown", g, { passive: !1 }), document.addEventListener("touchstart", g, { passive: !1 }), () => {
1188
- document.removeEventListener("mousedown", g), document.removeEventListener("touchstart", g);
1296
+ return document.addEventListener("mousedown", v, { passive: !1 }), document.addEventListener("touchstart", v, { passive: !1 }), () => {
1297
+ document.removeEventListener("mousedown", v), document.removeEventListener("touchstart", v);
1189
1298
  };
1190
- }, [s]), "type" in t)
1191
- return h(ge, { disabled: n, type: t, img: t.icon, isActive: e.id === t.id, setActive: d });
1299
+ }, [o]), "type" in t)
1300
+ return p(ge, { disabled: a, type: t, img: t.icon, isActive: e.id === t.id, setActive: h });
1192
1301
  if (!t.toolsType.length)
1193
1302
  return null;
1194
1303
  if (t.toolsType?.length === 1)
1195
- return h(ge, { disabled: n, type: t.toolsType[0], img: t.toolsType[0].icon, isActive: e.id === t.toolsType[0].id, setActive: d });
1196
- const u = t?.toolsType.find((g) => g.type === e.type) !== void 0, f = (p ? p.icon : t.toolsType?.[0]?.icon) ?? t.title;
1197
- return I("div", { className: "react-paint-editor-toolbargroup-relative", children: [h(j, { selected: u, title: t.title, disabled: n, onClick: () => {
1198
- p ? o(p.id) : t.toolsType?.[0] && d(t.toolsType[0]), l(() => {
1199
- a(!0);
1304
+ return p(ge, { disabled: a, type: t.toolsType[0], img: t.toolsType[0].icon, isActive: e.id === t.toolsType[0].id, setActive: h });
1305
+ const u = t?.toolsType.find((v) => v.type === e.type) !== void 0, g = (c ? c.icon : t.toolsType?.[0]?.icon) ?? t.title;
1306
+ return I("div", { className: "react-paint-editor-toolbargroup-relative", children: [p(B, { selected: u, title: t.title, disabled: a, onClick: () => {
1307
+ c ? s(c.id) : t.toolsType?.[0] && h(t.toolsType[0]), l(() => {
1308
+ r(!0);
1200
1309
  });
1201
- }, icon: f }), s && h(it, { alignment: i, position: "top", children: h("div", { className: "react-paint-editor-toolbargroup-panel-content", "data-vertical": +t.vertical, ref: r, children: t.toolsType.map((g, v) => h(ge, { disabled: n, type: g, img: g.icon, isActive: e.id === g.id, setActive: d }, v)) }) })] });
1202
- }, Ja = [{ title: "brush", toolsType: ["brush"], vertical: !1 }, { title: "lines", toolsType: ["line", "curve", "polygon"], vertical: !1 }, { title: "shapes", toolsType: ["rect", "square", "circle", "ellipse"], vertical: !1 }, "text"], Ka = ({ width: e, disabled: i = !1, activeTool: t, hasActionToUndo: n = !1, hasActionToRedo: o = !1, hasActionToClear: r = !1, withLoadAndSave: s, withExport: a, clearCanvas: l, setActiveTool: p, undoAction: c, redoAction: d, addPicture: u, loadFile: f, saveFile: g, exportCanvasInFile: v, availableTools: C, withUrlPicture: x, withUploadPicture: w }) => {
1203
- const y = ((N, Q) => {
1204
- const k = Q.flatMap((m) => {
1205
- if (typeof m != "object")
1206
- return N.filter((L) => L.type === m);
1207
- const V = N.filter((L) => m.toolsType.includes(L.type));
1208
- return V ? { ...m, toolsType: V } : null;
1310
+ }, icon: g }), o && p(et, { alignment: i, position: "top", children: p("div", { className: "react-paint-editor-toolbargroup-panel-content", "data-vertical": +t.vertical, ref: n, children: t.toolsType.map((v, x) => p(ge, { disabled: a, type: v, img: v.icon, isActive: e.id === v.id, setActive: h }, v.id)) }) })] });
1311
+ }, Ma = [{ title: "brush", toolsType: ["brush"], vertical: !1 }, { title: "lines", toolsType: ["line", "curve", "polygon"], vertical: !1 }, { title: "shapes", toolsType: ["rect", "square", "circle", "ellipse"], vertical: !1 }, "text"], ka = ({ width: e, disabled: i = !1, activeTool: t, hasActionToUndo: a = !1, hasActionToRedo: s = !1, hasActionToClear: n = !1, withLoadAndSave: o, withExport: r, clearCanvas: l, setActiveTool: c, undoAction: d, redoAction: h, addPicture: u, loadFile: g, saveFile: v, exportCanvasInFile: x, availableTools: M, withUrlPicture: y, withUploadPicture: P }) => {
1312
+ const Q = ((w, A) => {
1313
+ const N = A.flatMap((f) => {
1314
+ if (typeof f != "object")
1315
+ return w.filter((b) => b.type === f);
1316
+ const m = w.filter((b) => f.toolsType.includes(b.type));
1317
+ return m ? { ...f, toolsType: m } : null;
1209
1318
  });
1210
- return yt(k);
1211
- })(C, Ja), b = e < 40 * (5 + y.length), H = e < 40 * (2 + y.length), [A, Z] = R(!1), [F, E] = R(!1), S = () => {
1212
- Z((N) => !N);
1213
- }, T = (N) => {
1214
- p(N), Z(!1);
1215
- }, M = (N) => {
1216
- T(C.find((Q) => Q.id === N) ?? t);
1217
- }, B = C.find((N) => N.type === t.type) !== void 0;
1218
- return I(pe, { children: [I("div", { className: "react-paint-editor-toolbar-toolbox", children: [I("div", { className: "react-paint-editor-toolbar-shrinkable", children: [h(ge, { type: He, disabled: i, img: He.icon, isActive: t.id === He.id, setActive: T }), H ? h(j, { disabled: i, onClick: S, 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: B }) : y.map((N, Q) => h(Ga, { disabled: i, activeTool: t, group: N, setActiveToolFromId: M }, Q))] }), !b && I(pe, { children: [h(ge, { type: je, disabled: i || !n, img: je.icon, isActive: t.id === je.id, setActive: c }), h(ge, { type: qe, disabled: i || !o, img: qe.icon, isActive: t.id === qe.id, setActive: d }), h(ge, { type: Ge, disabled: i || !r, img: Ge.icon, isActive: t.id === Ge.id, setActive: l })] }), h(ja, { withActionsInMenu: b, disabled: i, 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: t, addPicture: u, loadFile: f, saveFile: g, togglePictureUrlModal: () => {
1219
- E(!0);
1220
- }, exportCanvasInFile: v, withUploadPicture: w, withUrlPicture: x, withLoadAndSave: s, withExport: a, hasActionToUndo: n, hasActionToRedo: o, hasActionToClear: r, undoAction: c, redoAction: d, clearCanvas: l })] }), A && h(jt, { className: "react-paint-editor-toolbar-modal", onClose: S, children: C.map((N, Q) => N.type === "picture" ? null : h(ge, { disabled: i, type: N, img: N.icon, withText: !1, isActive: t.id === N.id, setActive: T }, Q)) }), F && h(qa, { togglePictureUrlModal: () => {
1221
- E((N) => !N);
1319
+ return ft(N);
1320
+ })(M, Ma), L = e < 40 * (5 + Q.length), T = e < 40 * (2 + Q.length), [E, Z] = z(!1), [H, C] = z(!1), V = () => {
1321
+ Z((w) => !w);
1322
+ }, k = (w) => {
1323
+ c(w), Z(!1);
1324
+ }, S = (w) => {
1325
+ k(M.find((A) => A.id === w) ?? t);
1326
+ }, F = M.find((w) => w.type === t.type) !== void 0;
1327
+ return I(ue, { children: [I("div", { className: "react-paint-editor-toolbar-toolbox", children: [I("div", { className: "react-paint-editor-toolbar-shrinkable", children: [p(ge, { type: Te, disabled: i, img: Te.icon, isActive: t.id === Te.id, setActive: k }), T ? p(B, { disabled: i, onClick: V, 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: F }) : Q.map((w, A) => p(xa, { disabled: i, activeTool: t, group: w, setActiveToolFromId: S }, "id" in w ? w.id : w.title))] }), !L && I(ue, { children: [p(ge, { type: Xe, disabled: i || !a, img: Xe.icon, isActive: t.id === Xe.id, setActive: d }), p(ge, { type: Ye, disabled: i || !s, img: Ye.icon, isActive: t.id === Ye.id, setActive: h }), p(ge, { type: je, disabled: i || !n, img: je.icon, isActive: t.id === je.id, setActive: l })] }), p(Ca, { withActionsInMenu: L, disabled: i, 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: t, addPicture: u, loadFile: g, saveFile: v, togglePictureUrlModal: () => {
1328
+ C(!0);
1329
+ }, exportCanvasInFile: x, withUploadPicture: P, withUrlPicture: y, withLoadAndSave: o, withExport: r, hasActionToUndo: a, hasActionToRedo: s, hasActionToClear: n, undoAction: d, redoAction: h, clearCanvas: l })] }), E && p(Yt, { className: "react-paint-editor-toolbar-modal", onClose: V, children: M.map((w, A) => w.type === "picture" ? null : p(ge, { disabled: i, type: w, img: w.icon, withText: !1, isActive: t.id === w.id, setActive: k }, w.id)) }), H && p(wa, { togglePictureUrlModal: () => {
1330
+ C((w) => !w);
1222
1331
  }, addPicture: u })] });
1223
- }, an = ({ width: e = 1e3, height: i = 600, shapes: t, className: n = "", mode: o = "editor", disabled: r = !1, onDataChanged: s, apiRef: a, options: l = At }) => {
1224
- const { layersManipulation: p, grid: c, canGrow: d, canShrink: u, withExport: f, withLoadAndSave: g, withUploadPicture: v, withUrlPicture: C, withSkeleton: x, withFrameSelection: w, clearCallback: y, availableTools: b } = { ...At, ...l }, { toolbarBackgroundColor: H, dividerColor: A, fontRadius: Z, fontDisabledColor: F, fontDisabledBackgroundColor: E, fontColor: S, fontBackgroundColor: T, fontSelectedColor: M, fontSelectedBackgroundColor: B, fontHoverColor: N, fontHoverBackgroundColor: Q, canvasBackgroundColor: k, canvasSelectionColor: m, canvasSelectionWidth: V, canvasSelectionPadding: L } = { ...At.uiStyle, ...l?.uiStyle ?? {} }, $ = o !== "viewer", W = r || !$, _ = ee(null), O = ee(null), [P, ne] = R({ width: e, height: i, scaleRatio: 1 }), [oe, se] = R(P1(b, v || C)), { isInsideComponent: le } = (({ disabled: D, componentRef: X }) => {
1225
- const [me, te] = R(!1);
1226
- return Y(() => {
1227
- if (!D) {
1228
- const ie = (be) => {
1229
- te(ri(be, X.current));
1230
- };
1231
- return document.addEventListener("mousedown", ie, { passive: !0 }), document.addEventListener("touchstart", ie, { passive: !0 }), () => {
1232
- document.removeEventListener("mousedown", ie), document.removeEventListener("touchstart", ie);
1233
- };
1234
- }
1235
- te(!1);
1236
- }, [D, X]), { isInsideComponent: me };
1237
- })({ disabled: W, componentRef: _ }), [de, q] = R(!1), [ue, we] = R(!1), [Se, Me] = R([0, 0]), [Ae, ve] = R(void 0), [De, ye] = R(He), [he, Te] = R({ mode: "default" }), [K, ke] = R(c), [Ee, Ie] = R(!1);
1238
- a && (a.current = { getCurrentImage: () => O.current ? b1(Qe.current, Se, e, i, L) : void 0, getCurrentData: () => hi(Qe.current, e, i) });
1239
- const { shapesRef: Qe, selectedShape: Ze, selectionFrame: yi, hoveredShape: Qi, addShape: Ct, addPictureShape: Gt, moveShapes: bi, setSelectedShape: Pe, setSelectionFrame: Si, refreshSelectedShapes: Ci, refreshHoveredShape: xi, removeShape: xt, updateShape: wt, backwardShape: Mt, forwardShape: kt, clearShapes: Jt, saveShapes: wi, toggleShapeVisibility: Mi, toggleShapeLock: ki, canGoBackward: Li, canGoForward: Vi, canClear: Hi } = ka(s, L, P), { snackbarList: Ai, addSnackbar: Le } = Ha(), We = U((D) => {
1240
- Pe(void 0), ye(D);
1241
- }, [Pe]), Ti = U((D, X, me) => {
1242
- se((te) => te.map((ie) => ie.id === D ? ce(["settings", X, "default"], me, ie) : ie)), ye((te) => te.id === D ? ce(["settings", X, "default"], me, te) : te);
1243
- }, []), Zi = U(() => {
1244
- We(He), Mt();
1245
- }, [We, Mt]), Pi = U(() => {
1246
- We(He), kt();
1247
- }, [We, kt]), lt = U((D = [], X = !1) => {
1248
- Jt(D, X), We(He), Me([0, 0]);
1249
- }, [We, Jt]), Re = U(async (D, X = !0) => {
1250
- const me = await (async (te, ie, be) => {
1251
- if (!te.shapes)
1252
- return [];
1253
- const Xe = [], Ye = yt(te.shapes.map((Ce) => {
1254
- if (!Ce || !U1.includes(Ce.type))
1255
- return null;
1256
- if (Ce.type === "picture") {
1257
- const $e = new Image(), $i = new Promise((Lt, Oi) => {
1258
- $e.onload = () => {
1259
- URL.revokeObjectURL($e.src), Lt();
1260
- }, $e.onerror = () => {
1261
- Oi(new Error("Some images could not be loaded"));
1262
- };
1263
- });
1264
- return Xe.push($i), Ce.src.startsWith("http") ? vi(Ce.src).then((Lt) => {
1265
- $e.src = Lt;
1266
- }).catch(() => {
1267
- $e.src = "";
1268
- }) : $e.src = Ce.src, y1({ ...Ce, img: $e }, ie, be);
1269
- }
1270
- return y1(Ce, ie, be);
1271
- }));
1272
- return await Promise.all(Xe), Ye;
1273
- })(D, P.scaleRatio, L);
1274
- lt(me, X);
1275
- }, [lt, P, L]), Fi = U(() => {
1276
- typeof y != "string" ? Re({ shapes: y() }, !1) : y === "defaultShapes" && t !== void 0 ? Re({ shapes: t }, !1) : lt();
1277
- }, [lt, Re, t, y]), at = U((D) => {
1278
- ye(He), Pe(D);
1279
- }, [Pe]), Ni = U((D) => {
1280
- Ct(D), at(D);
1281
- }, [Ct, at]), Di = U(() => {
1282
- q(!0);
1332
+ }, pt = { none: 0, small: 10, medium: 20, large: 40 }, La = { toolbarBackgroundColor: "white", dividerColor: "#36418129", fontRadius: 8, fontDisabledColor: "#3641812b", fontDisabledBackgroundColor: "transparent", fontColor: "#364181", fontBackgroundColor: "transparent", fontSelectedColor: "white", fontSelectedBackgroundColor: "#364181", fontHoverColor: "#364181", fontHoverBackgroundColor: "#afd8d8" }, Va = () => {
1333
+ const e = ae([]), [i, t] = z([]);
1334
+ return U(() => () => {
1335
+ for (const a of e.current)
1336
+ clearTimeout(a);
1337
+ }, []), { snackbarList: i, addSnackbar: ({ type: a = da, duration: s = ca, text: n }) => {
1338
+ const o = { id: se("snackbar_"), duration: s, type: a, text: n };
1339
+ t((r) => [...r, o]), e.current = [...e.current, setTimeout(() => {
1340
+ return r = o.id, void t((l) => l.filter((c) => c.id !== r));
1341
+ var r;
1342
+ }, s)];
1343
+ } };
1344
+ }, Za = ({ editorProps: e, className: i, style: t, options: a, children: s }) => {
1345
+ const { shapesRef: n, addPictureShape: o, moveShapes: r, toggleShapeVisibility: l, toggleShapeLock: c, canGoBackward: d, canGoForward: h, canClear: u, selectedShape: g, removeShape: v, updateShape: x, backwardShape: M, forwardShape: y, refs: P, width: Q, height: L, canvasSize: T, selectTool: E, selectShape: Z, activeTool: H, setActiveTool: C, setAvailableTools: V, isEditMode: k, isDisabled: S, availableTools: F, gridGap: w, setGridGap: A, loadFile: N, exportPicture: f, exportData: m, clearCanvas: b, settings: R, canvas: { canGrow: D, layersManipulation: _, withExport: oe, withLoadAndSave: $, withUploadPicture: j, withUrlPicture: ce } } = e, { toolbarBackgroundColor: G, dividerColor: q, fontRadius: me, fontDisabledColor: fe, fontDisabledBackgroundColor: te, fontColor: he, fontBackgroundColor: be, fontSelectedColor: pe, fontSelectedBackgroundColor: xe, fontHoverColor: Ce, fontHoverBackgroundColor: Me } = { ...La, ...a }, [Ae, ne] = z(!1), [ke, Ze] = z(!1), re = w >= pt.large ? "large" : w >= pt.medium ? "medium" : w >= pt.small ? "small" : "none", { snackbarList: ye, addSnackbar: ie } = Va(), Le = W((J, K, lt) => {
1346
+ V((Re) => Re.map((Ue) => Ue.id === J ? le(["settings", K, "default"], lt, Ue) : Ue)), C((Re) => Re.id === J ? le(["settings", K, "default"], lt, Re) : Re);
1347
+ }, [C, V]), Oe = W(() => {
1348
+ E(Te), M();
1349
+ }, [E, M]), Ne = W(() => {
1350
+ E(Te), y();
1351
+ }, [E, y]), wt = W(() => {
1352
+ ne(!0);
1283
1353
  try {
1284
- const D = O.current && b1(Qe.current, Se, e, i, L);
1285
- if (!D)
1286
- throw new Error();
1287
- Q1(D, "drawing.png"), q(!1);
1288
- } catch (D) {
1289
- D instanceof Error && Le({ type: "error", text: "L'export a échoué" }), console.warn(D);
1354
+ f(), ne(!1);
1355
+ } catch (J) {
1356
+ J instanceof Error && ie({ type: "error", text: "L'export a échoué" }), console.warn(J);
1290
1357
  } finally {
1291
- q(!1);
1358
+ ne(!1);
1292
1359
  }
1293
- }, [Le, Qe, Se, e, i, L]), Ei = U(() => {
1294
- q(!0);
1360
+ }, [f, ie]), tt = W(() => {
1361
+ ne(!0);
1295
1362
  try {
1296
- const D = ra(Qe.current, e, i);
1297
- if (!D)
1298
- throw new Error("L'encodage a échoué");
1299
- Q1(D, "drawing.json"), q(!1);
1300
- } catch (D) {
1301
- D instanceof Error && Le({ type: "error", text: "L'enregistrement a échoué" }), console.warn(D);
1363
+ m(), ne(!1);
1364
+ } catch (J) {
1365
+ J instanceof Error && ie({ type: "error", text: "L'enregistrement a échoué" }), console.warn(J);
1302
1366
  } finally {
1303
- q(!1);
1367
+ ne(!1);
1304
1368
  }
1305
- }, [Qe, Le, e, i]), Ii = U(async (D) => {
1306
- q(!0);
1369
+ }, [m, ie]), Ge = W(async (J) => {
1370
+ ne(!0);
1307
1371
  try {
1308
- const X = await (async (me) => new Promise((te, ie) => {
1309
- const be = new FileReader();
1310
- be.onload = (Xe) => {
1311
- const Ye = Xe.target?.result;
1312
- if (!Ye)
1313
- return ie("Impossible de récupérer les données du fichier");
1314
- const Ce = JSON.parse(Ye);
1315
- te(Ce);
1316
- }, be.readAsText(me);
1317
- }))(D);
1318
- await Re(X), Le({ type: "success", text: "Fichier chargé !" });
1319
- } catch (X) {
1320
- X instanceof Error && Le({ type: "error", text: "Le chargement a échoué" }), console.warn(X);
1372
+ await N(J), ie({ type: "success", text: "Fichier chargé !" });
1373
+ } catch (K) {
1374
+ K instanceof Error && ie({ type: "error", text: "Le chargement a échoué" }), console.warn(K);
1321
1375
  } finally {
1322
- q(!1);
1376
+ ne(!1);
1323
1377
  }
1324
- }, [Re, Le]), Wi = U(async (D) => {
1325
- q(!0);
1378
+ }, [N, ie]), rt = W(async (J) => {
1379
+ ne(!0);
1326
1380
  try {
1327
- const X = await Gt(D, e, i);
1328
- at(X);
1329
- } catch (X) {
1330
- X instanceof Error && Le({ type: "error", text: "Le chargement a échoué" }), console.warn(X);
1381
+ const K = await o(J, Q, L);
1382
+ Z(K);
1383
+ } catch (K) {
1384
+ K instanceof Error && ie({ type: "error", text: "Le chargement a échoué" }), console.warn(K);
1331
1385
  } finally {
1332
- q(!1);
1386
+ ne(!1);
1333
1387
  }
1334
- }, [Gt, at, Le, e, i]), Ri = U((D) => {
1335
- const X = D / e;
1336
- ne({ width: D, height: i * X, scaleRatio: X });
1337
- }, [e, i]);
1338
- Ma({ isInsideComponent: le, selectionPadding: L, gridFormat: K, isEditingText: he.mode === "textedition", selectedShape: Ze, currentScale: P.scaleRatio, setSelectedShape: Pe, removeShape: xt, pasteShape: Ni, updateShape: wt, backwardShape: Mt, forwardShape: kt, setShiftPressed: Ie }), (({ onResized: D, element: X }) => {
1339
- Y(() => {
1340
- const me = X.current;
1341
- if (!me)
1342
- return;
1343
- const te = new ResizeObserver((ie) => {
1344
- const be = ie?.[0]?.borderBoxSize?.[0], { width: Xe, height: Ye } = be ? { width: be.inlineSize, height: be.blockSize } : ie?.[0].contentRect ?? {};
1345
- D(Xe, Ye);
1346
- });
1347
- return te.observe(me), () => {
1348
- te.unobserve(me);
1349
- };
1350
- }, [X, D]);
1351
- })({ element: _, onResized: Ri }), Y(() => {
1352
- se(P1(b, v || C));
1353
- }, [b, v, C]), Y(() => {
1354
- le || Pe(void 0);
1355
- }, [le, Pe]);
1356
- const Kt = ee(Re);
1357
- return Kt.current = Re, Y(() => {
1358
- t !== void 0 && Kt.current({ shapes: t });
1359
- }, [t]), I("div", { ref: _, className: `${n}${ue ? " react-paint-editor-layout-opened" : ""} react-paint-editor-app`, "data-grow": d, "data-shrink": u, style: { "--react-paint-editor-app-canvaswidth": `${e}px`, "--react-paint-editor-app-toolbar-bg": H, "--react-paint-editor-app-divider-color": A, "--react-paint-editor-app-font-radius": Z, "--react-paint-editor-app-font-disabled-color": F, "--react-paint-editor-app-font-disabled-bg": E, "--react-paint-editor-app-font-color": S, "--react-paint-editor-app-font-bg": T, "--react-paint-editor-app-font-selected-color": M, "--react-paint-editor-app-font-selected-bg": B, "--react-paint-editor-app-font-hover-color": N, "--react-paint-editor-app-font-hover-bg": Q, "--react-paint-editor-app-canvas-bg": k }, children: [$ && h(Ka, { width: P.width, disabled: W, activeTool: De, clearCanvas: Fi, setActiveTool: We, exportCanvasInFile: Di, saveFile: Ei, loadFile: Ii, addPicture: Wi, hasActionToUndo: Li, hasActionToRedo: Vi, hasActionToClear: Hi, undoAction: Zi, redoAction: Pi, availableTools: oe, withExport: f, withLoadAndSave: g, withUploadPicture: v, withUrlPicture: C }), I("div", { className: "react-paint-editor-app-row", "data-grow": d, style: { "--react-paint-editor-app-row-zindex": Bi, "--react-paint-editor-app-row-width": P.width, "--react-paint-editor-app-row-aspectratio": `calc(${P.width} / ${P.height})` }, children: [h(Ea, { canGrow: d, gridFormat: K, disabled: W, isInsideComponent: le, activeTool: De, setActiveTool: ye, canvasOffsetStartPosition: Ae, setCanvasOffsetStartPosition: ve, shapes: Qe.current, addShape: Ct, updateSingleShape: wt, selectedShape: Ze, selectionFrame: yi, setSelectedShape: Pe, setSelectionFrame: Si, hoveredShape: Qi, refreshHoveredShape: xi, refreshSelectedShapes: Ci, canvasOffset: Se, setCanvasOffset: Me, saveShapes: wi, ref: O, canvasSize: P, selectionMode: he, setSelectionMode: Te, selectionColor: m, selectionWidth: V, selectionPadding: L, isEditMode: $, isShiftPressed: Ee, withFrameSelection: w, withSkeleton: x }), $ && p && h(Oa, { gridFormat: K, setGridFormat: ke, disabled: W, shapes: Qe.current, moveShapes: bi, selectedShape: Ze, removeShape: xt, selectShape: at, toggleShapeVisibility: Mi, toggleShapeLock: ki, isLayoutPanelShown: ue })] }), $ && I(pe, { children: [h(_a, { width: P.width, disabled: W, activeTool: De, availableTools: oe, selectedShape: Ze, selectionPadding: L, removeShape: xt, updateShape: wt, canvas: O.current, currentScale: P.scaleRatio, layersManipulation: p, toggleLayoutPanel: () => {
1360
- we((D) => !D);
1361
- }, updateToolSettings: Ti }), h(Yi, { isLoading: de }), h(Wa, { snackbarList: Ai })] })] });
1388
+ }, [o, Z, ie, Q, L]), xt = `${i ? `${i} ` : ""}${ke ? "react-paint-editor-layout-opened " : ""}react-paint-editor-app`;
1389
+ return I("div", { ref: P.setEditor, className: xt, style: { "--react-paint-editor-app-maxWidth": D ? "100%" : `${Q}px`, "--react-paint-editor-app-toolbar-bg": G, "--react-paint-editor-app-divider-color": q, "--react-paint-editor-app-font-radius": me, "--react-paint-editor-app-font-disabled-color": fe, "--react-paint-editor-app-font-disabled-bg": te, "--react-paint-editor-app-font-color": he, "--react-paint-editor-app-font-bg": be, "--react-paint-editor-app-font-selected-color": pe, "--react-paint-editor-app-font-selected-bg": xe, "--react-paint-editor-app-font-hover-color": Ce, "--react-paint-editor-app-font-hover-bg": Me, ...t }, children: [k && p(ka, { width: T.width, disabled: S, activeTool: H, clearCanvas: b, setActiveTool: E, exportCanvasInFile: wt, saveFile: tt, loadFile: Ge, addPicture: rt, hasActionToUndo: d, hasActionToRedo: h, hasActionToClear: u, undoAction: Oe, redoAction: Ne, availableTools: F, withExport: oe, withLoadAndSave: $, withUploadPicture: j, withUrlPicture: ce }), s, k && _ && p(va, { gridFormat: re, setGridFormat: (J) => {
1390
+ A(pt[J]);
1391
+ }, disabled: S, shapes: n.current, moveShapes: r, selectedShape: g, removeShape: v, selectShape: Z, toggleShapeVisibility: l, toggleShapeLock: c, isLayoutPanelShown: ke }), k && I(ue, { children: [p(ba, { width: T.width, disabled: S, activeTool: H, availableTools: F, selectedShape: g, settings: R, removeShape: v, updateShape: x, canvas: P.canvas.current, layersManipulation: _, toggleLayoutPanel: () => {
1392
+ Ze((J) => !J);
1393
+ }, updateToolSettings: Le }), p(la, { isLoading: Ae }), p(pa, { snackbarList: ye })] })] });
1362
1394
  };
1363
1395
  export {
1364
- an as default
1396
+ Aa as Canvas,
1397
+ Za as Editor,
1398
+ Ta as useReactPaint
1365
1399
  };