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