@yorab/react-paint 0.9.3 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,525 +1,587 @@
1
- import { jsx as u, jsxs as D, Fragment as de } from "react/jsx-runtime";
2
- import $1, { useRef as ne, useEffect as _, useMemo as Yi, useState as O, useImperativeHandle as ji, useCallback as z, useTransition as O1 } from "react";
3
- const U1 = 2, z1 = "blue", xe = 14, B1 = [[0, 0], [0.5, 0], [1, 0], [1, 0.5], [1, 1], [0.5, 1], [0, 1], [0, 0.5]], _1 = ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle"], re = ["transparent", "black", "white", "red", "green", "blue", "yellow"], Te = [0, 1, 2], s1 = [[1, 0], [1, 2], [4, 6]], Ke = "serif", Xi = 1, qi = 2, Bt = 3, Ne = [10, 20, 40], Y1 = (e) => {
1
+ import { jsx as h, jsxs as I, Fragment as pe } from "react/jsx-runtime";
2
+ import W1, { useState as R, useEffect as Y, useRef as ee, useCallback as U, useMemo as zi, useImperativeHandle as Ui, useTransition as R1 } from "react";
3
+ const re = ["transparent", "black", "white", "red", "green", "blue", "yellow"], Ne = [0, 1, 2], e1 = [[1, 0], [1, 2], [4, 6]], rt = "serif", Bi = 1, Xi = 2, Rt = 3, Oe = [10, 20, 40], Yi = ({ isLoading: e = !1 }) => {
4
+ const [i, t] = R("hidden");
5
+ return Y(() => {
6
+ if (!e) {
7
+ t("fadeOut");
8
+ const n = setTimeout(() => t("hidden"), 300);
9
+ return () => {
10
+ clearTimeout(n);
11
+ };
12
+ }
13
+ t("visible");
14
+ }, [e]), i === "hidden" ? null : h("div", { className: "react-paint-editor-loading", "data-loading": i, style: { "--react-paint-editor-loading-zindex": Xi, "--react-paint-editor-loading-transition-duration": "300ms" }, children: I("div", { className: "react-paint-editor-loader", children: [h("div", {}), h("div", {}), h("div", {}), h("div", {})] }) });
15
+ }, $1 = 2, O1 = "blue", Ve = 14, z1 = [[0, 0], [0.5, 0], [1, 0], [1, 0.5], [1, 1], [0.5, 1], [0, 1], [0, 0.5]], U1 = ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle"], B1 = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.708Q2.208 15.75 2.802 15.344Q3.396 14.938 3.396 14.104Q3.396 13.042 4.135 12.292Q4.875 11.542 5.958 11.542Q7.021 11.542 7.76 12.292Q8.5 13.042 8.5 14.104Q8.5 15.5 7.51 16.5Q6.521 17.5 5.146 17.5ZM9.917 12.5 7.562 10.146 14.917 2.729Q15.146 2.5 15.469 2.5Q15.792 2.5 16.021 2.729L17.271 3.958Q17.5 4.188 17.5 4.531Q17.5 4.875 17.271 5.125Z"/></svg>', $t = '<svg><path d="M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z"/></svg>', Ot = '<svg><path d="M10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.271 2.323 6.75Q2.979 5.229 4.104 4.104Q5.229 2.979 6.75 2.323Q8.271 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.729 17.677 13.25Q17.021 14.771 15.896 15.896Q14.771 17.021 13.25 17.677Q11.729 18.333 10 18.333ZM10 16.583Q12.75 16.583 14.667 14.667Q16.583 12.75 16.583 10Q16.583 7.25 14.667 5.333Q12.75 3.417 10 3.417Q7.25 3.417 5.333 5.333Q3.417 7.25 3.417 10Q3.417 12.75 5.333 14.667Q7.25 16.583 10 16.583ZM10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Z"/></svg>', zt = '<svg><path d="M12.25 18.333V16.167L6.833 13.458H2.5V8.208H6.25L8.25 5.917V1.667H13.5V6.917H9.708L7.75 9.146V11.958L12.25 14.208V13.083H17.5V18.333Z"/></svg>', X1 = '<svg><path d="M4.125 5.083V3.333H7.062L7.896 2.5H12.104L12.938 3.333H15.875V5.083ZM6.75 17.5Q6.021 17.5 5.51 16.99Q5 16.479 5 15.75V5.958H15V15.75Q15 16.479 14.49 16.99Q13.979 17.5 13.25 17.5Z"/></svg>', t1 = '<svg><path d="M10 17.5Q7.208 17.5 5.271 15.594Q3.333 13.688 3.333 10.958Q3.333 9.583 3.854 8.396Q4.375 7.208 5.292 6.292L10 1.667L14.688 6.292Q15.604 7.208 16.135 8.396Q16.667 9.583 16.667 10.958Q16.667 13.688 14.719 15.594Q12.771 17.5 10 17.5ZM5.146 11.667H14.854Q15.083 10.188 14.552 9.146Q14.021 8.104 13.479 7.562L10 4.125L6.521 7.562Q5.979 8.104 5.448 9.146Q4.917 10.188 5.146 11.667Z"/></svg>', Ut = '<svg><path d="M4.792 15.083 8.333 11.542 9.833 13.021 11.667 10.708 15.167 15.083ZM6.667 8.417Q5.938 8.417 5.427 7.906Q4.917 7.396 4.917 6.667Q4.917 5.938 5.427 5.427Q5.938 4.917 6.667 4.917Q7.396 4.917 7.906 5.427Q8.417 5.938 8.417 6.667Q8.417 7.396 7.906 7.906Q7.396 8.417 6.667 8.417ZM4.167 18.333Q3.125 18.333 2.396 17.604Q1.667 16.875 1.667 15.833V4.167Q1.667 3.125 2.396 2.396Q3.125 1.667 4.167 1.667H15.833Q16.875 1.667 17.604 2.396Q18.333 3.125 18.333 4.167V15.833Q18.333 16.875 17.604 17.604Q16.875 18.333 15.833 18.333ZM4.167 16.583H15.833Q16.146 16.583 16.365 16.365Q16.583 16.146 16.583 15.833V4.167Q16.583 3.854 16.365 3.635Q16.146 3.417 15.833 3.417H4.167Q3.854 3.417 3.635 3.635Q3.417 3.854 3.417 4.167V15.833Q3.417 16.146 3.635 16.365Q3.854 16.583 4.167 16.583Z"/></svg>', Y1 = '<svg><path d="M8.708 16.667V5.917H4.167V3.333H15.833V5.917H11.292V16.667Z"/></svg>', _1 = '<svg><path d="M7.5 15.833V14.083H12.833L3.333 4.583L4.583 3.333L14.083 12.833V7.5H15.833V15.833Z"/></svg>', j1 = '<svg><path d="M7.521 17.5Q6.125 17.5 5.146 16.51Q4.167 15.521 4.167 14.125V7.417Q3.438 7.125 2.969 6.49Q2.5 5.854 2.5 5.042Q2.5 3.979 3.24 3.24Q3.979 2.5 5.042 2.5Q6.104 2.5 6.844 3.24Q7.583 3.979 7.583 5.042Q7.583 5.854 7.115 6.49Q6.646 7.125 5.917 7.417V14.125Q5.917 14.792 6.385 15.271Q6.854 15.75 7.521 15.75Q8.188 15.75 8.656 15.271Q9.125 14.792 9.125 14.125V5.875Q9.125 4.479 10.104 3.49Q11.083 2.5 12.479 2.5Q13.875 2.5 14.854 3.49Q15.833 4.479 15.833 5.875V12.583Q16.562 12.875 17.031 13.51Q17.5 14.146 17.5 14.958Q17.5 16.021 16.76 16.76Q16.021 17.5 14.958 17.5Q13.896 17.5 13.156 16.76Q12.417 16.021 12.417 14.958Q12.417 14.146 12.885 13.5Q13.354 12.854 14.083 12.583V5.875Q14.083 5.208 13.615 4.729Q13.146 4.25 12.479 4.25Q11.812 4.25 11.344 4.729Q10.875 5.208 10.875 5.875V14.125Q10.875 15.521 9.896 16.51Q8.917 17.5 7.521 17.5Z"/></svg>', i1 = '<svg><path d="M5.833 15V3.333H10.375Q11.812 3.333 12.885 4.156Q13.958 4.979 13.958 6.375Q13.958 7.375 13.49 7.969Q13.021 8.562 12.396 8.875V9.042Q13.312 9.354 13.844 10.021Q14.375 10.688 14.375 11.75Q14.375 13.312 13.229 14.156Q12.083 15 10.5 15ZM8.125 8.042H10.188Q10.854 8.042 11.302 7.656Q11.75 7.271 11.75 6.708Q11.75 6.167 11.302 5.771Q10.854 5.375 10.188 5.375H8.125ZM8.125 12.917H10.354Q11.167 12.917 11.625 12.51Q12.083 12.104 12.083 11.458Q12.083 10.812 11.625 10.406Q11.167 10 10.354 10H8.125Z"/></svg>', a1 = '<svg><path d="M4.167 16.667V14.083H6.979L10.229 5.917H7.5V3.333H15.833V5.917H13.021L9.771 14.083H12.5V16.667Z"/></svg>', n1 = '<svg><path d="M3.021 16V15H17V16ZM3.021 13.5V12H17V13.5ZM3 10.5V8.5H16.979V10.5ZM3.021 7V4H17V7Z"/></svg>', o1 = '<svg><path d="M16.354 18.833 14.521 17Q13.542 17.646 12.396 17.99Q11.25 18.333 10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.729 2.01 7.594Q2.354 6.458 3 5.458L1.167 3.625L2.396 2.396L17.583 17.604ZM10 16.583Q10.896 16.583 11.708 16.365Q12.521 16.146 13.25 15.729L4.292 6.75Q3.875 7.479 3.646 8.292Q3.417 9.104 3.417 10Q3.417 12.729 5.344 14.656Q7.271 16.583 10 16.583ZM17 14.562 15.708 13.271Q16.125 12.542 16.354 11.719Q16.583 10.896 16.583 10Q16.583 7.271 14.656 5.344Q12.729 3.417 10 3.417Q9.104 3.417 8.292 3.646Q7.479 3.875 6.75 4.292L5.458 3Q6.458 2.354 7.594 2.01Q8.729 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.271 17.979 12.417Q17.625 13.562 17 14.562ZM11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771ZM8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Z"/></svg>', s1 = '<svg ><path d="M16.354 18.833 14.521 17Q13.542 17.646 12.396 17.99Q11.25 18.333 10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.729 2.01 7.594Q2.354 6.458 3 5.458L1.167 3.625L2.396 2.396L17.583 17.604ZM17 14.562 5.458 3Q6.458 2.354 7.594 2.01Q8.729 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.271 17.979 12.417Q17.625 13.562 17 14.562Z"/></svg>', J = "react-paint-", Bt = { type: "picture", id: `${J}picture`, icon: Ut, label: "Image", settings: { opacity: { min: 0, max: 100, step: 1, default: 100 } } }, q1 = { type: "brush", id: `${J}brush`, icon: B1, label: "Brosse", settings: { strokeColor: { values: re, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 6, max: 20, step: 2, default: 10 }, lineDash: { values: Ne, default: 0 } } }, G1 = { type: "line", id: `${J}line`, icon: _1, label: "Ligne", settings: { strokeColor: { values: re, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 }, lineArrow: { values: [0, 1, 2, 3], default: 0 } } }, J1 = { type: "polygon", id: `${J}polygon`, icon: zt, label: "Polygone", settings: { strokeColor: { values: re, default: "black" }, fillColor: { values: re, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 }, pointsCount: { min: 3, max: 10, step: 1, default: 3 } } }, K1 = { type: "curve", id: `${J}curve`, icon: j1, label: "Courbe", settings: { strokeColor: { values: re, default: "black" }, fillColor: { values: re, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 }, pointsCount: { min: 3, max: 10, step: 1, default: 3 } } }, ei = { type: "rect", id: `${J}rect`, icon: $t, label: "Rectangle", settings: { strokeColor: { values: re, default: "black" }, fillColor: { values: re, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 } } }, ti = { type: "square", id: `${J}square`, icon: $t, label: "Carré", settings: { strokeColor: { values: re, default: "black" }, fillColor: { values: re, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 } } }, ii = { type: "circle", id: `${J}circle`, icon: Ot, label: "Cercle", settings: { strokeColor: { values: re, default: "black" }, fillColor: { values: re, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 } } }, ai = { type: "ellipse", id: `${J}ellipse`, icon: Ot, label: "Ellipse", settings: { strokeColor: { values: re, default: "black" }, fillColor: { values: re, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ne, default: 0 } } }, ni = { type: "text", id: `${J}text`, icon: Y1, label: "Texte", settings: { strokeColor: { values: re, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, fontFamily: { values: ["arial", "serif", "monospace"], default: rt }, fontBold: { values: [!1, !0], default: !1 }, fontItalic: { values: [!1, !0], default: !1 } } }, He = { id: `${J}selection`, type: "selection", icon: '<svg><path d="M8.0145 11.1707C8.38484 10.9914 8.82183 11.1558 8.99959 11.5295L10.7031 15.2591L12.0363 14.6238L10.3254 10.9017C10.1476 10.528 10.3106 10.0795 10.6809 9.90761L10.8883 9.84782L12.5918 9.51148L6.48133 4.33192V12.389L7.82934 11.2903L8.0145 11.1707ZM10.6587 16.9258C10.2883 17.1052 9.84395 16.9482 9.67359 16.5745L8.05894 13.0318L6.19988 14.5416C6.07396 14.6462 5.91842 14.706 5.74066 14.706C5.54423 14.706 5.35584 14.6272 5.21694 14.4871C5.07803 14.3469 5 14.1568 5 13.9586V2.74741C5 2.54919 5.07803 2.35908 5.21694 2.21891C5.35584 2.07874 5.54423 2 5.74066 2C5.91842 2 6.08878 2.06727 6.21469 2.1719L6.2221 2.16443L14.7323 9.36947C15.0508 9.63854 15.0879 10.1094 14.8286 10.4233C14.7175 10.5579 14.562 10.6475 14.4064 10.6774L12.0659 11.1408L13.6954 14.6761C13.888 15.0498 13.7102 15.4908 13.3399 15.6627L10.6587 16.9258Z"/></svg>', label: "Sélection" }, je = { id: `${J}undo`, type: "undo", icon: '<svg><path d="M11.708 15.833H5.854V14.083H11.708Q13 14.083 13.958 13.292Q14.917 12.5 14.917 11.271Q14.917 10.042 13.958 9.24Q13 8.438 11.708 8.438H6.667L8.792 10.562L7.562 11.792L3.333 7.562L7.562 3.333L8.792 4.562L6.667 6.688H11.708Q13.729 6.688 15.198 7.99Q16.667 9.292 16.667 11.25Q16.667 13.208 15.198 14.521Q13.729 15.833 11.708 15.833Z"/></svg>', label: "Undo" }, qe = { id: `${J}redo`, type: "redo", icon: '<svg><path d="M8.292 15.833Q6.271 15.833 4.802 14.521Q3.333 13.208 3.333 11.25Q3.333 9.292 4.802 7.99Q6.271 6.688 8.292 6.688H13.333L11.208 4.562L12.438 3.333L16.667 7.562L12.438 11.792L11.208 10.562L13.333 8.438H8.292Q7 8.438 6.042 9.229Q5.083 10.021 5.083 11.25Q5.083 12.5 6.042 13.292Q7 14.083 8.292 14.083H14.146V15.833Z"/></svg>', label: "Redo" }, Ge = { id: `${J}clear`, type: "clear", icon: '<svg><path d="M7.854 13.812 10 11.688 12.125 13.812 13.354 12.604 11.208 10.458 13.354 8.312 12.125 7.104 10 9.229 7.854 7.104 6.625 8.312 8.771 10.458 6.625 12.604ZM5.896 17.5Q5.167 17.5 4.656 16.99Q4.146 16.479 4.146 15.75V5.125H3.333V3.375H7.542V2.5H12.458V3.375H16.667V5.125H15.833V15.75Q15.833 16.479 15.323 16.99Q14.812 17.5 14.083 17.5Z"/></svg>', label: "Clear" }, Vt = { id: `${J}export`, type: "export", icon: '<svg><path d="M10 13.271 5.708 8.979 6.958 7.729 9.125 9.896V3.333H10.875V9.896L13.042 7.729L14.292 8.979ZM5.083 16.667Q4.354 16.667 3.844 16.156Q3.333 15.646 3.333 14.917V12.5H5.083V14.917Q5.083 14.917 5.083 14.917Q5.083 14.917 5.083 14.917H14.917Q14.917 14.917 14.917 14.917Q14.917 14.917 14.917 14.917V12.5H16.667V14.917Q16.667 15.646 16.156 16.156Q15.646 16.667 14.917 16.667Z"/></svg>', label: "Export PNG" }, r1 = { id: `${J}load`, type: "loadfile", icon: '<svg><path d="M3.417 16.667Q2.729 16.667 2.198 16.135Q1.667 15.604 1.667 14.917V5.083Q1.667 4.396 2.198 3.865Q2.729 3.333 3.417 3.333H8.25L9.917 5H16.667Q17.354 5 17.844 5.531Q18.333 6.062 18.333 6.75H3.417V14.917Q3.417 14.917 3.417 14.917Q3.417 14.917 3.417 14.917L5.438 8.5H19.583L17.396 15.479Q17.229 16.021 16.802 16.344Q16.375 16.667 15.833 16.667Z"/></svg>', label: "Load project" }, Ht = { id: `${J}save`, type: "savefile", icon: '<svg><path d="M17.5 5.833V15.75Q17.5 16.479 16.99 16.99Q16.479 17.5 15.75 17.5H4.25Q3.521 17.5 3.01 16.99Q2.5 16.479 2.5 15.75V4.25Q2.5 3.521 3.01 3.01Q3.521 2.5 4.25 2.5H14.167ZM10 14.917Q11.062 14.917 11.823 14.156Q12.583 13.396 12.583 12.333Q12.583 11.271 11.823 10.51Q11.062 9.75 10 9.75Q8.938 9.75 8.177 10.51Q7.417 11.271 7.417 12.333Q7.417 13.396 8.177 14.156Q8.938 14.917 10 14.917ZM5.021 8.396H12.521V5.021H5.021Z"/></svg>', label: "Save project" }, l1 = { id: `${J}upload-picture`, type: "uploadpicture", icon: Ut, label: "Upload picture" }, oi = "react-paint-editor-canvas-drawcanvas", si = "react-paint-editor-canvas-selectioncanvas", At = { layersManipulation: !0, grid: 0, canGrow: !1, canShrink: !0, withExport: !0, withLoadAndSave: !0, withUploadPicture: !0, withUrlPicture: !1, availableTools: [q1, G1, J1, K1, ei, ti, ii, ai, Bt, ni], clearCallback: "empty", withFrameSelection: !1, withSkeleton: !1, uiStyle: { toolbarBackgroundColor: "white", dividerColor: "#36418129", fontRadius: 8, fontDisabledColor: "#3641812b", fontDisabledBackgroundColor: "transparent", fontColor: "#364181", fontBackgroundColor: "transparent", fontSelectedColor: "white", fontSelectedBackgroundColor: "#364181", fontHoverColor: "#364181", fontHoverBackgroundColor: "#afd8d8", canvasBackgroundColor: "white", canvasSelectionColor: O1, canvasSelectionWidth: $1, canvasSelectionPadding: 0 } }, ri = (e, i) => !!(e.target instanceof Node && i) && i.contains(e.target), li = (e) => {
4
16
  e.lineCap = "round", e.lineJoin = "round";
5
- }, We = (e, i = {}) => {
6
- const { fillColor: t = "transparent", opacity: a = 100, strokeColor: s = z1, lineWidth: r = U1, lineDash: o = 0 } = i;
7
- a !== void 0 && (e.globalAlpha = a / 100), t && (e.fillStyle = t), s && (e.strokeStyle = s), r && (e.lineWidth = r), o !== void 0 && r && e.setLineDash([s1[o][0] * r, s1[o][1] * r]);
8
- }, j1 = (e, i, t, a, s) => {
9
- e.save(), e.scale(i, i), e.translate(t[0], t[1]), a !== 0 && (e.translate(s[0], s[1]), e.rotate(a), e.translate(-s[0], -s[1]));
10
- }, Qt = (e) => e.filter((i) => i != null), Gi = /(<([^>]+)>)/gi, Ji = /<(\/)?div(\/?\s?)>/gi, Ki = (e) => {
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
+ }, ze = (e, i = {}) => {
18
+ const { lineCap: t = "round", fillColor: n = "transparent", opacity: o = 100, strokeColor: r = O1, lineWidth: s = $1, lineDash: a = 0 } = i;
19
+ e.lineCap = t, e.globalAlpha = o / 100, e.fillStyle = n, e.strokeStyle = r, e.lineWidth = s, e.setLineDash(a === 0 ? [] : [e1[a][0] * s, e1[a][1] * s]);
20
+ }, Xt = (e, i, t, n, o) => {
21
+ e.save(), e.scale(i, i), e.translate(t[0], t[1]), n && o && (e.translate(o[0], o[1]), e.rotate(n), e.translate(-o[0], -o[1]));
22
+ }, ut = (e) => {
30
23
  const i = new Path2D();
31
24
  return i.rect(e.x, e.y, e.width, e.height), i;
32
- }, vt = (e) => {
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
- }, en = (e) => {
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
+ }, Nt = (e) => {
39
29
  const i = new Path2D();
40
30
  return i.moveTo(...e.points[0]), i.lineTo(...e.points[1]), i;
41
- }, tn = (e) => {
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
+ }, _i = (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
- }, Be = (e, i, t) => {
60
- const { borders: a } = K(e, t);
61
- return { border: gt(a), line: X1({ points: [[a.x + a.width / 2, a.y], [a.x + a.width / 2, a.y - 7 - 16 / i]] }), anchors: [vt({ x: a.x + a.width / 2, y: a.y - 7 - 16 / i, radius: 7 / i }), ...B1.map((s) => vt({ x: a.x + a.width * s[0], y: a.y + a.height * s[1], radius: 7 / i }))] };
62
- }, d1 = ({ borderStart: e, borderSize: i, vector: t, selectionPadding: a, invertedAxe: s, anchor: r }) => {
63
- switch (r) {
64
- case 0:
65
- if (s) {
66
- const o = i - 2 * a;
67
- return [e + o, t - o];
68
- }
69
- {
70
- const o = Math.max(2 * a, i - t);
71
- return [e + i - o, o];
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
+ }, Yt = (e, i, t, n, o = !1) => {
35
+ const { borders: r } = G(i, n);
36
+ return { border: ut(r), shapePath: e, anchors: [...i.points.map((s, a) => o && a > 0 && a < i.points.length - 1 ? ut({ x: s[0] - 7, y: s[1] - 7, width: Ve / t, height: Ve / t }) : ht({ x: s[0], y: s[1], radius: 7 / t }))] };
37
+ }, Dt = (e) => 180 * e / Math.PI, di = (e, i) => {
38
+ const t = i.x - Math.min(Math.max(i.x, e.x), e.x + e.width), n = i.y - Math.min(Math.max(i.y, e.y), e.y + e.height);
39
+ return Math.sqrt(t * t + n * n) <= i.radius;
40
+ }, fe = ({ origin: e = [0, 0], point: i, rotation: t }) => {
41
+ const n = [i[0] - e[0], i[1] - e[1]], o = n[1] * Math.cos(t) - n[0] * Math.sin(t);
42
+ return [n[1] * Math.sin(t) + n[0] * Math.cos(t) + e[0], o + e[1]];
43
+ }, d1 = (e) => (e + 2 * Math.PI) % (2 * Math.PI), c1 = ({ targetVector: [e, i], radian: t = !0, originVector: n }) => {
44
+ const o = d1(Math.atan2(i[1] - e[1], i[0] - e[0]));
45
+ if (n) {
46
+ const [r, s] = n, a = Math.atan2(s[1] - r[1], s[0] - r[0]), l = d1(o - a);
47
+ return t ? l : Dt(l);
96
48
  }
97
- return c1({ borderX: g, borderWidth: f, borderY: S, borderHeight: m, center: o, originalShape: i });
98
- }, Ot = (e, i) => {
49
+ return t ? o : Dt(o);
50
+ }, gt = 300, Et = (e, i) => {
99
51
  const t = { ...i };
100
- return e.forEach((a) => {
101
- delete t[a];
102
- }), t;
103
- }, le = (e, i, t) => {
104
- const a = Array.isArray(t) ? [...t] : { ...t }, s = Array.isArray(e) ? e : typeof e == "string" ? e.split(".") : [e];
105
- return s.reduce((r, o, n) => (r[o] = Ut(r[o]) ? { ...r[o] } : Array.isArray(r[o]) ? [...r[o]] : r[o] === void 0 || r[o] === null ? {} : r[o], n === s.length - 1 && (r[o] = i), r[o]), a), a;
106
- }, Ut = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, Qe = (e, i, t) => {
107
- if (!Ut(i) || !Ut(t))
52
+ for (const n of e)
53
+ delete t[n];
54
+ return t;
55
+ }, ce = (e, i, t) => {
56
+ const n = Array.isArray(t) ? [...t] : { ...t }, o = Array.isArray(e) ? e : typeof e == "string" ? e.split(".") : [e];
57
+ return o.reduce((r, s, a) => (r[s] = It(r[s]) ? { ...r[s] } : Array.isArray(r[s]) ? [...r[s]] : r[s] === void 0 || r[s] === null ? {} : r[s], a === o.length - 1 && (r[s] = i), r[s]), n), n;
58
+ }, It = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, xe = (e, i, t) => {
59
+ if (!It(i) || !It(t))
108
60
  return t;
109
- const a = { ...i };
110
- for (const s in t)
111
- t.hasOwnProperty(s) && (a.hasOwnProperty(s) ? a[s] = e(a[s], t[s], s) ?? Qe(e, a[s], t[s]) : a[s] = t[s]);
112
- return a;
113
- }, q1 = (e, i) => {
61
+ const n = { ...i };
62
+ for (const o in t)
63
+ t.hasOwnProperty(o) && (n.hasOwnProperty(o) ? n[o] = e(n[o], t[o], o) ?? xe(e, n[o], t[o]) : n[o] = t[o]);
64
+ return n;
65
+ }, ci = (e, i) => {
114
66
  if (e === i)
115
67
  return !0;
116
68
  if (typeof e != "object" || typeof i != "object" || e === null || i === null)
117
69
  return !1;
118
- const t = Object.keys(e), a = Object.keys(i);
119
- if (t.length !== a.length)
70
+ const t = Object.keys(e), n = Object.keys(i);
71
+ if (t.length !== n.length)
120
72
  return !1;
121
- for (const s of t)
122
- if (!a.includes(s) || !q1(e[s], i[s]))
73
+ for (const o of t)
74
+ if (!n.includes(o) || !ci(e[o], i[o]))
123
75
  return !1;
124
76
  return !0;
125
- }, Et = {}, ae = (e = "") => (Et[e] || (Et[e] = 0), `${e}${++Et[e]}`), ut = (e, i, t, a = 1, s = 1) => [i + (e[0] - i) * a, t + (e[1] - t) * s], on = (e) => {
126
- if (e.points.length < 1 || e.style?.strokeColor === "transparent")
127
- return;
128
- const i = e.points.flat(), t = i.map((n) => n[0]), a = i.map((n) => n[1]), s = Math.min(...t), r = Math.min(...a), o = new Path2D();
129
- return e.points.forEach((n) => {
130
- n.length === 1 ? o.rect(...ut(n[0], s, r, e.scaleX, e.scaleY), 1, 1) : (o.moveTo(...ut(n[0], s, r, e.scaleX, e.scaleY)), n.slice(1).forEach((l) => {
131
- o.lineTo(...ut(l, s, r, e.scaleX, e.scaleY));
132
- }));
133
- }), o;
134
- }, _e = (e, i, t) => ({ ...e, path: on(e), selection: Be(e, i, t) }), sn = _e, ft = 300, He = (e, i = 2) => Math.round(e * 10 ** i) / 10 ** i, $ = (e, i, t = 0) => {
77
+ }, Tt = {}, ae = (e = "") => (Tt[e] || (Tt[e] = 0), `${e}${++Tt[e]}`), et = (e, i, t) => {
78
+ const n = ((o) => {
79
+ if (o.points.length < 1 || o.style?.strokeColor === "transparent")
80
+ return;
81
+ const r = o.points.flat(), s = r.map((d) => d[0]), a = r.map((d) => d[1]), l = Math.min(...s), p = Math.min(...a), c = new Path2D();
82
+ for (const d of o.points)
83
+ if (d.length === 1)
84
+ c.rect(...Ue(d[0], l, p, o.scaleX, o.scaleY), 1, 1);
85
+ else {
86
+ c.moveTo(...Ue(d[0], l, p, o.scaleX, o.scaleY));
87
+ for (const u of d.slice(1))
88
+ c.lineTo(...Ue(u, l, p, o.scaleX, o.scaleY));
89
+ }
90
+ return c;
91
+ })(e);
92
+ return { ...e, path: n, selection: tt(n, e, i, t) };
93
+ }, ji = et, Fe = (e, i = 2) => Math.round(e * 10 ** i) / 10 ** i, Ue = (e, i, t, n = 1, o = 1) => [i + (e[0] - i) * n, t + (e[1] - t) * o], z = (e, i, t = 0) => {
135
94
  if (!i)
136
- return He(e);
137
- const a = e + t, s = a >= 0 ? Ne[i - 1] : -Ne[i - 1];
138
- return a + s / 2 - (a + s / 2) % s - t;
139
- }, rn = (e, i, t = 0) => i ? e + Math.PI / 18 / 2 - (e + Math.PI / 18 / 2) % (Math.PI / 18) : He(e, 3), ln = (e, i, t, a, s, r, o, n, l) => {
95
+ return Fe(e);
96
+ const n = e + t, o = n >= 0 ? Oe[i - 1] : -Oe[i - 1];
97
+ return n + o / 2 - (n + o / 2) % o - t;
98
+ }, qi = (e, i, t = 0) => i ? e + Math.PI / 18 / 2 - (e + Math.PI / 18 / 2) % (Math.PI / 18) : Fe(e, 3), Gi = (e, i, t, n, o, r, s, a, l) => {
140
99
  switch (r.mode) {
141
100
  case "brush":
142
- return ((c, d, p, h) => {
143
- const v = { ...c, points: le(c.points.length - 1, [...c.points[c.points.length - 1], [Math.round(d[0]), Math.round(d[1])]], c.points) };
144
- return _e(v, p, h);
145
- })(i, t, l, o);
101
+ return ((p, c, d, u) => {
102
+ const f = { ...p, points: ce(p.points.length - 1, [...p.points[p.points.length - 1], [Math.round(c[0]), Math.round(c[1])]], p.points) };
103
+ return et(f, d, u);
104
+ })(i, t, l, s);
146
105
  case "translate":
147
- return zt(t, r.originalShape, r.cursorStartPosition, a, l, o);
106
+ return Wt(t, r.originalShape, r.cursorStartPosition, n, l, s);
148
107
  case "rotate":
149
- return Ln(i, t, r.originalShape, r.cursorStartPosition, r.center, a);
108
+ return fa(i, t, r.originalShape, r.cursorStartPosition, r.center, n);
150
109
  case "resize":
151
- return Vn(e, i, t, s, r.originalShape, r, a, o, n, l);
110
+ return va(e, i, t, o, r.originalShape, r, n, s, a, l);
152
111
  default:
153
112
  return i;
154
113
  }
155
- }, lt = (e, i, t, a, s = 1) => {
156
- const { clientX: r = 0, clientY: o = 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, height: a };
157
- return [(r - n.left) * (t / n.width) / s, (o - n.top) * (a / n.height) / s];
158
- }, ht = (e, i, [t, a], [s, r]) => Me({ origin: [t - s, a - r], point: e, rotation: i }), mt = (e, i, t, a, s = 1, r = !1) => {
114
+ }, tt = (e, i, t, n) => {
115
+ const { borders: o } = G(i, n);
116
+ return { border: ut(o), shapePath: e, line: Nt({ points: [[o.x + o.width / 2, o.y], [o.x + o.width / 2, o.y - 23 / t]] }), anchors: [ht({ x: o.x + o.width / 2, y: o.y - 23 / t, radius: 7 / t }), ...z1.map((r) => ht({ x: o.x + o.width * r[0], y: o.y + o.height * r[1], radius: 7 / t }))] };
117
+ }, p1 = ({ borderStart: e, borderSize: i, vector: t, selectionPadding: n, invertedAxe: o, anchor: r }) => {
118
+ switch (r) {
119
+ case 0: {
120
+ if (o) {
121
+ const a = i - 2 * n;
122
+ return [e + a, t - a];
123
+ }
124
+ const s = Math.max(2 * n, i - t);
125
+ return [e + i - s, s];
126
+ }
127
+ case 0.5:
128
+ return [e, i];
129
+ case 1:
130
+ if (o) {
131
+ const s = i + t;
132
+ return [e + s, 2 * n - s];
133
+ }
134
+ return [e, Math.max(2 * n, i + t)];
135
+ default:
136
+ return [0, 0];
137
+ }
138
+ }, u1 = ({ borderX: e, borderWidth: i, borderY: t, borderHeight: n, center: o, originalShape: r }) => {
139
+ const s = [e + i / 2 - o[0], t + n / 2 - o[1]], [a, l] = fe({ point: s, rotation: -r.rotation });
140
+ return { borderX: Fe(e + a - s[0]), borderWidth: Fe(i), borderY: Fe(t + l - s[1]), borderHeight: Fe(n) };
141
+ }, _e = (e, i, t, n, o, r = !1) => {
142
+ const { center: s, borders: a } = G(i, o), l = fe({ origin: s, point: e, rotation: i.rotation }), p = t.anchor[0] === 0 && l[0] >= a.x + a.width || t.anchor[0] === 1 && l[0] <= a.x, c = t.anchor[1] === 0 && l[1] >= a.y + a.height || t.anchor[1] === 1 && l[1] <= a.y, d = [z(l[0], n, t.anchor[0] === 0 && !p || t.anchor[0] === 1 && p ? o : -o), z(l[1], n, t.anchor[1] === 0 && !c || t.anchor[1] === 1 && c ? o : -o)], u = n ? [t.anchor[0] === 0 ? a.x : t.anchor[0] === 0.5 ? a.x + a.width / 2 : a.x + a.width, t.anchor[1] === 0 ? a.y : t.anchor[1] === 0.5 ? a.y + a.height / 2 : a.y + a.height] : fe({ origin: s, point: t.cursorStartPosition, rotation: i.rotation }), f = [d[0] - u[0], d[1] - u[1]], [g, v] = p1({ borderStart: a.x, borderSize: a.width, vector: f[0], selectionPadding: o, invertedAxe: p, anchor: t.anchor[0] }), [C, x] = p1({ borderStart: a.y, borderSize: a.height, vector: f[1], selectionPadding: o, invertedAxe: c, anchor: t.anchor[1] });
143
+ if (r) {
144
+ const w = ((y, b, H, A, Z, F, E, S, T, M) => {
145
+ const B = (b.width - 2 * M || 1) / (b.height - 2 * M || 1), N = (Z - 2 * M) / (E - 2 * M);
146
+ let Q, k, m, V;
147
+ return T.anchor[0] !== 0.5 && T.anchor[1] !== 0.5 ? N < B ? (k = F, V = E, m = (E - 2 * M) * B + 2 * M, Q = T.anchor[0] === 0 ? b.width - y[0] > M ? b.x + (b.width - m) : b.x + b.width - 2 * M : b.width + y[0] > M ? b.x : b.x - m + 2 * M) : (Q = A, m = Z, V = (Z - 2 * M) / B + 2 * M, k = T.anchor[1] === 0 ? b.height - y[1] > M ? b.y + (b.height - V) : b.y + b.height - 2 * M : b.height + y[1] > M ? b.y : b.y - V + 2 * M) : T.anchor[0] !== 0.5 ? (Q = A, m = Z, V = (Z - 2 * M) / B + 2 * M, k = b.y + (b.height - V) / 2) : (k = F, V = E, m = (E - 2 * M) * B + 2 * M, Q = b.x + (b.width - m) / 2), { borderX: Q, borderWidth: m, borderY: k, borderHeight: V, center: H, originalShape: S };
148
+ })(f, a, s, g, v, C, x, i, t, o);
149
+ return u1(w);
150
+ }
151
+ return u1({ borderX: g, borderWidth: v, borderY: C, borderHeight: x, center: s, originalShape: i });
152
+ }, ft = (e, i, t) => {
153
+ const n = ht(e);
154
+ return { ...e, path: n, selection: tt(n, e, i, t) };
155
+ }, Ji = ft, Zt = (e, i, t, n, o = 1) => {
156
+ const { clientX: r = 0, clientY: s = 0 } = "touches" in e && e.touches[0] ? e.touches[0] : "changedTouches" in e && e.changedTouches[0] ? e.changedTouches[0] : "clientX" in e ? e : {}, a = i?.getBoundingClientRect() ?? { left: 0, top: 0, width: t, height: n };
157
+ return [(r - a.left) * (t / a.width) / o, (s - a.top) * (n / a.height) / o];
158
+ }, h1 = (e) => "touches" in e, Be = (e, i, [t, n], [o, r]) => fe({ origin: [t - o, n - r], point: e, rotation: i }), dt = (e, i, t) => t ? di(e, { x: i[0], y: i[1], radius: t }) : ((n, o) => o[0] >= n.x && o[0] <= n.x + n.width && o[1] >= n.y && o[1] <= n.y + n.height)(e, i), ot = (e, i, t, n, o, r = !1, s = 0) => {
159
159
  if (e.locked)
160
160
  return !1;
161
- const o = Math.min(1, s), { borders: n, center: l } = K(e, a), c = ht(i, e.rotation, l, t);
161
+ const { borders: a, center: l } = G(e, n), p = Be(i, e.rotation, l, t);
162
162
  if (r)
163
163
  if (e.type === "line" || e.type === "polygon" || e.type === "curve") {
164
- for (let d = 0; d < e.points.length; d++)
165
- if (rt({ x: e.points[d][0] - 7 / o, y: e.points[d][1] - 7 / o, width: xe / o, height: xe / o }, c))
166
- return { mode: "resize", anchor: d };
164
+ for (let c = 0; c < e.points.length; c++)
165
+ if (dt({ x: e.points[c][0] - 7 / o, y: e.points[c][1] - 7 / o, width: Ve / o, height: Ve / o }, p, s))
166
+ return { mode: "resize", anchor: c };
167
167
  } else {
168
- if (rt({ x: n.x + n.width / 2 - 7 / o, y: n.y - xe / o - 16 / o, width: xe / o, height: xe / o }, c))
168
+ if (dt({ x: a.x + a.width / 2 - 7 / o, y: a.y - Ve / o - 16 / o, width: Ve / o, height: Ve / o }, p, s))
169
169
  return { mode: "rotate" };
170
- for (const d of B1)
171
- if (rt({ x: n.x + n.width * d[0] - 7 / o, y: n.y + n.height * d[1] - 7 / o, width: xe / o, height: xe / o }, c))
172
- return { mode: "resize", anchor: d };
170
+ for (const c of z1)
171
+ if (dt({ x: a.x + a.width * c[0] - 7 / o, y: a.y + a.height * c[1] - 7 / o, width: Ve / o, height: Ve / o }, p, s))
172
+ return { mode: "resize", anchor: c };
173
173
  }
174
- return !!rt(n, c) && { mode: "translate" };
175
- }, p1 = (e) => {
176
- return t = { ...e, type: "triangle" }, { ...t, path: an(t) };
174
+ return !!dt(a, p, s) && { mode: "translate" };
175
+ }, pi = (e, i, t, n, o, r) => {
176
+ if (i.locked)
177
+ return !1;
178
+ const { center: s } = G(i, o), a = Be(t, i.rotation, s, n);
179
+ return "path" in i && i.path ? i.style?.fillColor && i.style?.fillColor !== "transparent" ? !!e.isPointInPath(i.path, a[0], a[1]) && { mode: "translate" } : (e.lineWidth = (i.style?.lineWidth ?? 0) + 15, !!e.isPointInStroke(i.path, a[0], a[1]) && { mode: "translate" }) : ot(i, t, n, o, r, !1);
180
+ };
181
+ function g1(e, i) {
182
+ const t = Math.max(e.x, i.x), n = Math.max(e.y, i.y), o = Math.min(e.x + (e.width || 1), i.x + (i.width || 1)), r = Math.min(e.y + (e.height || 1), i.y + (i.height || 1));
183
+ if (t < o && n < r)
184
+ return { x: t, y: n, width: o - t, height: r - n };
185
+ }
186
+ const f1 = ({ ctx: e, path: i, rect: t, offset: n, checkFill: o }) => {
187
+ for (let r = 0; r < n; r += n / 2)
188
+ for (let s = 0; s < n; s += n / 2)
189
+ for (let a = r + t.x; a < t.x + t.width; a += n)
190
+ for (let l = s + t.y; l < t.y + t.height; l += n)
191
+ if (o ? e.isPointInPath(i, a, l) : e.isPointInStroke(i, a, l))
192
+ return !0;
193
+ return !1;
194
+ }, Je = (e, i, t) => {
195
+ const n = ((o) => {
196
+ if (o.points.length < 1)
197
+ return;
198
+ const r = new Path2D();
199
+ r.moveTo(...o.points[0]);
200
+ for (const s of o.points.slice(1))
201
+ r.lineTo(...s);
202
+ return r.lineTo(...o.points[0]), r;
203
+ })(e);
204
+ return { ...e, path: n, selection: Yt(n, e, i, t) };
205
+ }, Ki = Je, ui = (e, i) => {
206
+ const t = Math.min(...e.points.map((r) => r[0])) - i, n = Math.max(...e.points.map((r) => r[0])) + i, o = Math.min(...e.points.map((r) => r[1])) - i;
207
+ return { x: t, width: n - t, y: o, height: Math.max(...e.points.map((r) => r[1])) + i - o };
208
+ }, Ke = (e, i, t) => {
209
+ const n = ((o) => {
210
+ if (o.points.length < 3)
211
+ return;
212
+ const r = new Path2D();
213
+ r.moveTo(...o.points[0]);
214
+ for (let s = 1; s < o.points.length - 1; s++)
215
+ r.quadraticCurveTo(...o.points[s], o.points.length - 2 === s ? o.points[s + 1][0] : (o.points[s + 1][0] - o.points[s][0]) / 2 + o.points[s][0], o.points.length - 2 === s ? o.points[s + 1][1] : (o.points[s + 1][1] - o.points[s][1]) / 2 + o.points[s][1]);
216
+ return r;
217
+ })(e);
218
+ return { ...e, path: n, selection: Yt(n, e, i, t, !0) };
219
+ }, ea = Ke, ta = ui, vt = (e, i, t) => {
220
+ const n = ((o) => {
221
+ const r = new Path2D();
222
+ return r.ellipse(o.x, o.y, o.radiusX, o.radiusY, 0, 0, 2 * Math.PI), r;
223
+ })(e);
224
+ return { ...e, path: n, selection: tt(n, e, i, t) };
225
+ }, ia = vt, v1 = (e) => {
226
+ return t = { ...e, type: "triangle" }, { ...t, path: _i(t) };
177
227
  var t;
178
- }, dn = (e, i) => {
179
- e.globalAlpha !== 0 && i.path && (i.style?.fillColor !== "transparent" && e.fill(i.path), i.style?.strokeColor !== "transparent" && e.stroke(i.path));
180
- }, _t = (e, i, t, a = !1) => {
181
- const { borders: s } = K(e, t);
182
- return { border: gt(s), anchors: [...e.points.map((r, o) => a && o > 0 && o < e.points.length - 1 ? gt({ x: r[0] - 7, y: r[1] - 7, width: xe / i, height: xe / i }) : vt({ x: r[0], y: r[1], radius: 7 / i }))] };
183
- }, yt = (e, i, t) => {
184
- const a = [];
185
- if (e.style?.lineArrow === 1 || e.style?.lineArrow === 3) {
186
- const s = Math.PI / 2 - l1({ targetVector: [e.points[0], e.points[1]] });
187
- a.push(p1(u1(e.points[0], s, e.style)));
188
- }
189
- if (e.style?.lineArrow === 2 || e.style?.lineArrow === 3) {
190
- const s = Math.PI / 2 - l1({ targetVector: [e.points[1], e.points[0]] });
191
- a.push(p1(u1(e.points[1], s, e.style)));
192
- }
193
- return { ...e, path: X1(e), selection: _t(e, i, t), arrows: a };
194
- }, cn = yt, u1 = (e, i, t) => {
195
- const a = [Me({ point: [0, -(10 + 1 * (t.lineWidth ?? 0))], rotation: i }), Me({ point: [-(5 + 1 * (t.lineWidth ?? 0)), 5 + 2 * (t.lineWidth ?? 0)], rotation: i }), Me({ point: [5 + 1 * (t.lineWidth ?? 0), 5 + 2 * (t.lineWidth ?? 0)], rotation: i })];
196
- 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
- }, Ue = (e, i, t) => ({ ...e, path: nn(e), selection: _t(e, i, t) }), pn = Ue, G1 = (e, i) => {
198
- const t = Math.min(...e.points.map((r) => r[0])) - i, a = Math.max(...e.points.map((r) => r[0])) + i, s = Math.min(...e.points.map((r) => r[1])) - i;
199
- return { x: t, width: a - t, y: s, height: Math.max(...e.points.map((r) => r[1])) + i - s };
200
- }, ze = (e, i, t) => ({ ...e, path: tn(e), selection: _t(e, i, t, !0) }), un = ze, hn = G1, bt = (e, i, t) => ({ ...e, path: gt(e), selection: Be(e, i, t) }), gn = bt, vn = (e, i) => {
228
+ }, aa = (e, i) => {
201
229
  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) => {
220
- const i = new DOMParser().parseFromString(e, "text/xml").getElementsByTagName("svg")[0], t = i.getAttribute("width"), a = i.getAttribute("height");
221
- let s;
222
- if (t || a)
223
- s = e;
230
+ }, mt = (e, i, t) => {
231
+ const n = [];
232
+ let o;
233
+ if (e.style?.lineArrow === 1 || e.style?.lineArrow === 2 || e.style?.lineArrow === 3) {
234
+ const r = Math.PI / 2 - c1({ targetVector: [e.points[0], e.points[1]] });
235
+ e.style?.lineArrow !== 1 && e.style?.lineArrow !== 3 || n.push(v1(m1(e.points[0], r, e.style))), e.style?.lineArrow !== 2 && e.style?.lineArrow !== 3 || n.push(v1(m1(e.points[1], r + Math.PI, e.style)));
236
+ const s = (({ line: a, size: l, direction: p }) => {
237
+ const c = Math.PI / 2 - c1({ targetVector: [a.points[0], a.points[1]] }), d = [a.points[0][0] + (a.points[1][0] - a.points[0][0]) / 2, a.points[0][1] + (a.points[1][1] - a.points[0][1]) / 2];
238
+ let u, f;
239
+ if (["start", "both"].includes(p)) {
240
+ const g = fe({ point: a.points[0], origin: d, rotation: -c });
241
+ u = fe({ point: [g[0], g[1] + l], origin: d, rotation: c });
242
+ } else
243
+ u = [...a.points[0]];
244
+ if (["end", "both"].includes(p)) {
245
+ const g = fe({ point: a.points[1], origin: d, rotation: -c });
246
+ f = fe({ point: [g[0], g[1] - l], origin: d, rotation: c });
247
+ } else
248
+ f = [...a.points[1]];
249
+ return { points: [u, f] };
250
+ })({ line: e, size: 10 + 2 * (e.style?.lineWidth ?? 0), direction: e.style?.lineArrow === 1 ? "start" : e.style?.lineArrow === 2 ? "end" : "both" });
251
+ o = Nt(s);
252
+ } else
253
+ o = Nt(e);
254
+ return { ...e, path: o, selection: Yt(o, e, i, t), arrows: n, style: { ...e.style, lineCap: e.style?.lineArrow ? "butt" : "round" } };
255
+ }, na = mt, m1 = (e, i, t) => {
256
+ const n = [fe({ point: [0, 0], rotation: i }), fe({ point: [-(5 + (t.lineWidth ?? 0)), 10 + 2 * (t.lineWidth ?? 0)], rotation: i }), fe({ point: [5 + (t.lineWidth ?? 0), 10 + 2 * (t.lineWidth ?? 0)], rotation: i })];
257
+ return { points: [[e[0] + n[0][0], e[1] + n[0][1]], [e[0] + n[1][0], e[1] + n[1][1]], [e[0] + n[2][0], e[1] + n[2][1]]], style: { ...t, fillColor: t.strokeColor, strokeColor: "transparent" } };
258
+ }, yt = (e) => e.filter((i) => i != null), oa = (e) => {
259
+ const i = ["img", "id", "selection", "path", "arrows"];
260
+ return e.map((t) => t.type !== "picture" || t.src.startsWith("http") ? Et(i, t) : Et(i, { ...t, src: sa(t.img) }));
261
+ }, hi = (e, i, t) => ({ shapes: oa(e), config: { width: i, height: t } }), y1 = (e, i, t) => st({ ...e, id: ae(`${e.type}_`) }, i, t), gi = (e) => {
262
+ const i = new DOMParser().parseFromString(e, "text/xml").getElementsByTagName("svg")[0], t = i.getAttribute("width"), n = i.getAttribute("height");
263
+ let o;
264
+ if (t || n)
265
+ o = e;
224
266
  else {
225
- const o = i.getAttribute("viewBox") ?? "0 0 300 300", [, , n, l] = o.split(" ");
226
- i.setAttribute("width", n ?? ft), i.setAttribute("height", l ?? ft), s = new XMLSerializer().serializeToString(i);
267
+ const s = i.getAttribute("viewBox") ?? "0 0 300 300", [, , a, l] = s.split(" ");
268
+ i.setAttribute("width", a ?? gt), i.setAttribute("height", l ?? gt), o = new XMLSerializer().serializeToString(i);
227
269
  }
228
- const r = new Blob([s], { type: "image/svg+xml" });
270
+ const r = new Blob([o], { type: "image/svg+xml" });
229
271
  return URL.createObjectURL(r);
230
- }, ei = (e) => (e instanceof File ? e.name : e).includes(".svg"), ti = (e) => ei(e) ? fetch(e).then((i) => i.text()).then((i) => K1(i)) : fetch(e).then((i) => i.blob()).then((i) => URL.createObjectURL(i)), f1 = (e, i) => {
272
+ }, fi = (e) => (e instanceof File ? e.name : e).includes(".svg"), vi = (e) => fi(e) ? fetch(e).then((i) => i.text()).then((i) => gi(i)) : fetch(e).then((i) => i.blob()).then((i) => URL.createObjectURL(i)), Q1 = (e, i) => {
231
273
  const t = document.createElement("a");
232
274
  t.href = e, t.download = i, document.body.appendChild(t), t.click(), document.body.removeChild(t);
233
- }, Sn = (e) => {
275
+ }, sa = (e) => {
234
276
  const i = document.createElement("canvas");
235
277
  i.width = e.width, i.height = e.height;
236
278
  const t = i.getContext("2d");
237
279
  return t ? (t.drawImage(e, 0, 0), i.toDataURL("image/png")) : "";
238
- }, m1 = (e, i, t, a, s) => {
280
+ }, b1 = (e, i, t, n, o) => {
239
281
  const r = document.createElement("canvas");
240
- r.width = t, r.height = a;
241
- const o = r.getContext("2d");
242
- if (!o)
282
+ r.width = t, r.height = n;
283
+ const s = r.getContext("2d");
284
+ if (!s)
243
285
  return "";
244
- o.clearRect(0, 0, t, a), Y1(o);
245
- for (let n = e.length - 1; n >= 0; n--)
246
- fi(o, e[n], 1, i, s);
286
+ s.clearRect(0, 0, t, n), li(s);
287
+ for (let a = e.length - 1; a >= 0; a--)
288
+ mi(s, e[a], 1, i, o);
247
289
  return r.toDataURL("image/png");
248
- }, Cn = (e, i, t) => {
249
- return s = J1(e, i, t), "data:text/plain;charset=utf-8," + encodeURIComponent(JSON.stringify(s));
250
- 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 [o, n] = ((l, c, d, p, h = !1) => {
253
- if (!(l && c && p && d))
254
- return [ft, ft];
255
- const v = l / c;
256
- if (v > d / p) {
257
- const g = h ? d : Math.min(l, d);
258
- return [g, g / v];
259
- }
260
- {
261
- const g = h ? p : Math.min(c, p);
262
- return [g * v, g];
290
+ }, ra = (e, i, t) => {
291
+ return o = hi(e, i, t), `data:text/plain;charset=utf-8,${encodeURIComponent(JSON.stringify(o))}`;
292
+ var o;
293
+ }, Qt = (e, i, t) => {
294
+ const n = ut(e);
295
+ return { ...e, path: n, selection: tt(n, e, i, t) };
296
+ }, la = Qt, da = (e, i) => {
297
+ e.globalAlpha !== 0 && i.path && (i.style?.fillColor !== "transparent" && e.fill(i.path), i.style?.strokeColor !== "transparent" && e.stroke(i.path));
298
+ }, S1 = (e, i) => ({ x: e.x - i, width: e.width + 2 * i, y: e.y - i, height: e.height + 2 * i }), C1 = (e, i, t, n, [o, r] = [!1, !1]) => ((s, a, [l, p], [c, d]) => fe({ origin: [l - c, p - d], point: s, rotation: -a }))([e[0] === 0.5 ? t.x + t.width / 2 : e[0] === 0 ? t.x + (o ? 0 : t.width) : t.x + (o ? t.width : 0), e[1] === 0.5 ? t.y + t.height / 2 : e[1] === 0 ? t.y + (r ? 0 : t.height) : t.y + (r ? t.height : 0)], t.rotation, i, n), bt = (e, i, t) => ({ ...e, selection: tt(void 0, e, i, t) }), ca = bt, x1 = (e, i, t, n, o, r) => {
299
+ const [s, a] = ((l, p, c, d, u = !1) => {
300
+ if (!(l && p && d && c))
301
+ return [gt, gt];
302
+ const f = l / p;
303
+ if (f > c / d) {
304
+ const v = u ? c : Math.min(l, c);
305
+ return [v, v / f];
263
306
  }
264
- })(e.width, e.height, t, a, !0);
265
- return e1({ toolId: Kt.id, type: "picture", id: ae("picture_"), x: (t - o) / 2, y: (a - n) / 2, width: o, height: n, src: i, img: e, rotation: 0 }, s, r);
266
- }, Mn = (e, i, t, a, s) => new Promise((r, o) => {
267
- const n = new Image();
268
- n.onerror = () => {
269
- o(new Error("Some images could not be loaded"));
307
+ const g = u ? d : Math.min(p, d);
308
+ return [g * f, g];
309
+ })(e.width, e.height, t, n, !0);
310
+ return bt({ toolId: Bt.id, type: "picture", id: ae("picture_"), x: (t - s) / 2, y: (n - a) / 2, width: s, height: a, src: i, img: e, rotation: 0 }, o, r);
311
+ }, pa = (e, i, t, n, o) => new Promise((r, s) => {
312
+ const a = new Image();
313
+ a.onerror = () => {
314
+ s(new Error("Some images could not be loaded"));
270
315
  }, setTimeout(() => {
271
- o(new Error("Timeout while loading images"));
272
- }, 4e3), e instanceof File ? ((l, c, d, p, h, v, g) => {
273
- const f = URL.createObjectURL(d);
316
+ s(new Error("Timeout while loading images"));
317
+ }, 4e3), e instanceof File ? ((l, p, c, d, u, f, g) => {
318
+ const v = URL.createObjectURL(c);
274
319
  l.onload = async () => {
275
- if (URL.revokeObjectURL(l.src), ei(d) && !l.width && !l.height) {
276
- const m = await d.text(), C = K1(m);
277
- if (f === l.src)
278
- return void (l.src = C);
320
+ if (URL.revokeObjectURL(l.src), fi(c) && !l.width && !l.height) {
321
+ const x = await c.text(), w = gi(x);
322
+ if (v === l.src)
323
+ return void (l.src = w);
279
324
  }
280
- const S = k1(l, l.src, p, h, v, g);
281
- c(S);
282
- }, l.src = f;
283
- })(n, r, e, i, t, a, s) : ((l, c, d, p, h, v, g) => {
325
+ const C = x1(l, l.src, d, u, f, g);
326
+ p(C);
327
+ }, l.src = v;
328
+ })(a, r, e, i, t, n, o) : ((l, p, c, d, u, f, g) => {
284
329
  l.onload = () => {
285
330
  URL.revokeObjectURL(l.src);
286
- const f = k1(l, d, p, h, v, g);
287
- c(f);
288
- }, ti(d).then((f) => {
289
- l.src = f;
331
+ const v = x1(l, c, d, u, f, g);
332
+ p(v);
333
+ }, vi(c).then((v) => {
334
+ l.src = v;
290
335
  }).catch(() => {
291
336
  l.src = "";
292
337
  });
293
- })(n, r, e, i, t, a, s);
294
- }), L1 = (e, i, t, a, s, r) => {
295
- const o = [$(t[0], a), $(t[1], a)];
338
+ })(a, r, e, i, t, n, o);
339
+ }), Pt = ["Texte"], St = (e, i, t) => ({ ...e, selection: tt(void 0, e, i, t) }), ua = St, _t = (e, i, t, n, o, r = rt) => {
340
+ e.font = `${o ? "italic" : ""} ${n ? "bold" : ""} 1px ${r}`;
341
+ const s = i.map((a) => t / e.measureText(a).width);
342
+ return Math.min(...s) || 36;
343
+ }, ha = (e, i, t, n, o) => {
344
+ const r = { ...i, value: t }, s = ((v, C, x, w, y, b = rt) => {
345
+ v.font = `${y ? "italic" : ""} ${w ? "bold" : ""} ${x}px ${b}`;
346
+ const H = C.map((A) => v.measureText(A).width);
347
+ return Math.max(...H) || 20;
348
+ })(e, r.value, r.fontSize, r.style?.fontBold ?? !1, r.style?.fontItalic ?? !1, r.style?.fontFamily), a = r.fontSize * r.value.length, l = { ...r, width: s, height: a }, { center: p } = G(i, n), { center: c } = G(l, n), [d, u] = C1([1, 1], p, i, o), [f, g] = C1([1, 1], c, l, o, [!1, !1]);
349
+ return { ...l, x: l.x - (f - d), y: l.y - (g - u) };
350
+ }, w1 = (e, i, t, n, o, r) => {
351
+ const s = [z(t[0], n), z(t[1], n)];
296
352
  switch (i.type) {
297
353
  case "brush":
298
- return ((n, l, c, d) => _e({ toolId: n.id, type: n.type, id: ae(`${n.type}_`), points: [[l]], 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 } }, c, d))(i, o, s, r);
354
+ return ((a, l, p, c) => et({ toolId: a.id, type: a.type, id: ae(`${a.type}_`), points: [[l]], rotation: 0, scaleX: 1, scaleY: 1, style: { opacity: a.settings.opacity.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } }, p, c))(i, s, o, r);
299
355
  case "line":
300
- return ((n, l, c, d) => {
301
- const p = { toolId: n.id, type: n.type, id: ae(`${n.type}_`), points: [l, l], 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 } };
302
- return yt(p, c, d);
303
- })(i, o, s, r);
356
+ return ((a, l, p, c) => {
357
+ const d = { toolId: a.id, type: a.type, id: ae(`${a.type}_`), points: [l, l], rotation: 0, style: { opacity: a.settings.opacity.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default, lineArrow: a.settings.lineArrow.default } };
358
+ return mt(d, p, c);
359
+ })(i, s, o, r);
304
360
  case "polygon":
305
- return ((n, l, c, d) => Ue({ toolId: n.id, type: n.type, id: ae(`${n.type}_`), points: new Array(n.settings.pointsCount.default).fill(l), 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 } }, c, d))(i, o, s, r);
361
+ return ((a, l, p, c) => Je({ toolId: a.id, type: a.type, id: ae(`${a.type}_`), points: new Array(a.settings.pointsCount.default).fill(l), rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default, pointsCount: a.settings.pointsCount.default } }, p, c))(i, s, o, r);
306
362
  case "curve":
307
- return ((n, l, c, d) => ze({ toolId: n.id, type: n.type, id: ae(`${n.type}_`), points: new Array(n.settings.pointsCount.default).fill(l), 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 } }, c, d))(i, o, s, r);
363
+ return ((a, l, p, c) => Ke({ toolId: a.id, type: a.type, id: ae(`${a.type}_`), points: new Array(a.settings.pointsCount.default).fill(l), rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default, pointsCount: a.settings.pointsCount.default } }, p, c))(i, s, o, r);
308
364
  case "rect":
309
365
  case "square":
310
- return ((n, l, c, d) => {
311
- const p = { toolId: n.id, type: n.type, id: ae(`${n.type}_`), x: l[0], y: l[1], width: 0, height: 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 } };
312
- return bt(p, c, d);
313
- })(i, o, s, r);
366
+ return ((a, l, p, c, d = 0, u = 0) => {
367
+ const f = { toolId: a.id, type: a.type, id: ae(`${a.type}_`), x: l[0], y: l[1], width: d, height: u, rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } };
368
+ return Qt(f, p, c);
369
+ })(i, s, o, r);
314
370
  case "text":
315
- return ((n, l, c, d, p) => {
316
- const h = jt(n, Nt, 50, l.settings?.fontBold.default ?? !1, l.settings?.fontItalic.default ?? !1, l.settings.fontFamily.default);
317
- return Yt({ toolId: l.id, type: l.type, id: ae(`${l.type}_`), x: c[0], y: c[1], value: Nt, fontSize: h, width: 50, height: h * (Nt.length || 1), rotation: 0, style: { opacity: l.settings.opacity.default, strokeColor: l.settings.strokeColor.default, fontFamily: l.settings.fontFamily.default, fontItalic: l.settings.fontItalic.default, fontBold: l.settings.fontBold.default } }, d, p);
318
- })(e, i, o, s, r);
371
+ return ((a, l, p, c, d) => {
372
+ const u = _t(a, Pt, 50, l.settings?.fontBold.default ?? !1, l.settings?.fontItalic.default ?? !1, l.settings.fontFamily.default);
373
+ return St({ toolId: l.id, type: l.type, id: ae(`${l.type}_`), x: p[0], y: p[1], value: Pt, fontSize: u, width: 50, height: u * (Pt.length || 1), rotation: 0, style: { opacity: l.settings.opacity.default, strokeColor: l.settings.strokeColor.default, fontFamily: l.settings.fontFamily.default, fontItalic: l.settings.fontItalic.default, fontBold: l.settings.fontBold.default } }, c, d);
374
+ })(e, i, s, o, r);
319
375
  case "ellipse":
320
- return ((n, l, c, d) => St({ toolId: n.id, type: n.type, id: ae(`${n.type}_`), x: l[0], y: l[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 } }, c, d))(i, o, s, r);
376
+ return ((a, l, p, c) => vt({ toolId: a.id, type: a.type, id: ae(`${a.type}_`), x: l[0], y: l[1], radiusX: 0, radiusY: 0, rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } }, p, c))(i, s, o, r);
321
377
  case "circle":
322
- return ((n, l, c, d) => Ct({ toolId: n.id, type: n.type, id: ae(`${n.type}_`), x: l[0], y: l[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 } }, c, d))(i, o, s, r);
378
+ return ((a, l, p, c) => ft({ toolId: a.id, type: a.type, id: ae(`${a.type}_`), x: l[0], y: l[1], radius: 0, rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } }, p, c))(i, s, o, r);
323
379
  }
324
- }, fi = (e, i, t, a, s) => {
380
+ }, mi = (e, i, t, n, o) => {
325
381
  if (i.visible === !1)
326
382
  return;
327
- const { center: r } = K(i, s);
328
- switch (j1(e, t, a, i.rotation, r), We(e, i.style), i.type) {
383
+ const { center: r } = G(i, o);
384
+ switch (Xt(e, t, n, i.rotation, r), ze(e, i.style), i.type) {
329
385
  case "brush":
330
- ((o, n) => {
331
- n.points.length < 1 || !n.path || o.globalAlpha !== 0 && n.style?.strokeColor !== "transparent" && o.globalAlpha !== 0 && o.stroke(n.path);
386
+ ((s, a) => {
387
+ a.points.length < 1 || !a.path || s.globalAlpha !== 0 && a.style?.strokeColor !== "transparent" && s.globalAlpha !== 0 && s.stroke(a.path);
332
388
  })(e, i);
333
389
  break;
334
390
  case "text":
335
- ((o, n) => {
336
- if (o.globalAlpha !== 0 && n.style?.strokeColor && n.style.strokeColor !== "transparent") {
337
- o.font = `${n.style?.fontItalic ? "italic" : ""} ${n.style?.fontBold ? "bold" : ""} ${n.fontSize}px ${n.style?.fontFamily ?? Ke}`, o.textBaseline = "top", o.fillStyle = n.style.strokeColor;
338
- for (let l = 0; l < n.value.length; l++)
339
- o.fillText(n.value[l], n.x, n.y + l * n.fontSize, n.width);
391
+ ((s, a) => {
392
+ if (s.globalAlpha !== 0 && a.style?.strokeColor && a.style.strokeColor !== "transparent") {
393
+ s.font = `${a.style?.fontItalic ? "italic" : ""} ${a.style?.fontBold ? "bold" : ""} ${a.fontSize}px ${a.style?.fontFamily ?? rt}`, s.textBaseline = "top", s.fillStyle = a.style.strokeColor;
394
+ for (let l = 0; l < a.value.length; l++)
395
+ s.fillText(a.value[l], a.x, a.y + l * a.fontSize, a.width);
340
396
  }
341
397
  })(e, i);
342
398
  break;
343
399
  case "line":
344
- ((o, n) => {
345
- if (o.globalAlpha !== 0 && n.path) {
346
- n.style?.fillColor !== "transparent" && o.fill(n.path), n.style?.strokeColor !== "transparent" && o.stroke(n.path);
347
- for (const l of n.arrows ?? [])
348
- We(o, l.style), dn(o, l);
400
+ ((s, a) => {
401
+ if (s.globalAlpha !== 0 && a.path) {
402
+ a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path);
403
+ for (const l of a.arrows ?? [])
404
+ ze(s, l.style), aa(s, l);
349
405
  }
350
406
  })(e, i);
351
407
  break;
352
408
  case "polygon":
353
- ((o, n) => {
354
- n.path && o.globalAlpha !== 0 && (n.style?.fillColor !== "transparent" && o.fill(n.path), n.style?.strokeColor !== "transparent" && o.stroke(n.path));
409
+ ((s, a) => {
410
+ a.path && s.globalAlpha !== 0 && (a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path));
355
411
  })(e, i);
356
412
  break;
357
413
  case "curve":
358
- ((o, n) => {
359
- n.path && o.globalAlpha !== 0 && (n.style?.fillColor !== "transparent" && o.fill(n.path), n.style?.strokeColor !== "transparent" && o.stroke(n.path));
414
+ ((s, a) => {
415
+ a.path && s.globalAlpha !== 0 && (a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path));
360
416
  })(e, i);
361
417
  break;
362
418
  case "circle":
363
- ((o, n) => {
364
- o.globalAlpha !== 0 && n.path && (n.style?.fillColor !== "transparent" && o.fill(n.path), n.style?.strokeColor !== "transparent" && o.stroke(n.path));
419
+ ((s, a) => {
420
+ s.globalAlpha !== 0 && a.path && (a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path));
365
421
  })(e, i);
366
422
  break;
367
423
  case "ellipse":
368
- ((o, n) => {
369
- o.globalAlpha !== 0 && n.path && (n.style?.fillColor !== "transparent" && o.fill(n.path), n.style?.strokeColor !== "transparent" && o.stroke(n.path));
424
+ ((s, a) => {
425
+ s.globalAlpha !== 0 && a.path && (a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path));
370
426
  })(e, i);
371
427
  break;
372
428
  case "rect":
373
429
  case "square":
374
- vn(e, i);
430
+ da(e, i);
375
431
  break;
376
432
  case "picture":
377
- ((o, n) => {
378
- o.globalAlpha !== 0 && (o.beginPath(), o.drawImage(n.img, n.x, n.y, n.width, n.height));
433
+ ((s, a) => {
434
+ s.globalAlpha !== 0 && (s.beginPath(), s.drawImage(a.img, a.x, a.y, a.width, a.height));
379
435
  })(e, i);
380
436
  }
381
437
  e.restore();
382
- }, kn = (e, i) => {
438
+ }, ga = (e, i) => {
383
439
  switch (e.type) {
384
440
  case "brush":
385
- return ((t, a) => {
386
- const s = t.points.flat(), r = Math.min(...s.map((d) => d[0])), o = Math.min(...s.map((d) => d[1])), n = s.map((d) => ut(d, r, o, t.scaleX, t.scaleY)), l = Math.max(...n.map((d) => d[0])) + a, c = Math.max(...n.map((d) => d[1])) + a;
387
- return { x: r - a, width: l - r + a, y: o - a, height: c - o + a };
441
+ return ((t, n) => {
442
+ const o = t.points.flat(), r = Math.min(...o.map((c) => c[0])), s = Math.min(...o.map((c) => c[1])), a = o.map((c) => Ue(c, r, s, t.scaleX, t.scaleY)), l = Math.max(...a.map((c) => c[0])) + n, p = Math.max(...a.map((c) => c[1])) + n;
443
+ return { x: r - n, width: l - r + n, y: s - n, height: p - s + n };
388
444
  })(e, i);
389
445
  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);
446
+ return ((t, n) => ({ x: Math.min(t.points[0][0], t.points[1][0]) - n, width: Math.abs(t.points[0][0] - t.points[1][0]) + 2 * n, y: Math.min(t.points[0][1], t.points[1][1]) - n, height: Math.abs(t.points[0][1] - t.points[1][1]) + 2 * n }))(e, i);
391
447
  case "polygon":
392
- return G1(e, i);
448
+ return ui(e, i);
393
449
  case "curve":
394
- return hn(e, i);
450
+ return ta(e, i);
395
451
  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);
452
+ return ((t, n) => ({ x: t.x - t.radius - n, width: 2 * (t.radius + n), y: t.y - t.radius - n, height: 2 * (t.radius + n) }))(e, i);
397
453
  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);
454
+ return ((t, n) => ({ x: t.x - t.radiusX - n, width: 2 * (t.radiusX + n), y: t.y - t.radiusY - n, height: 2 * (t.radiusY + n) }))(e, i);
399
455
  case "rect":
400
456
  case "square":
401
- return h1(e, i);
457
+ return S1(e, i);
402
458
  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);
459
+ return ((t, n) => ({ x: t.x - n, width: t.width + 2 * n, y: t.y - n, height: t.height + 2 * n }))(e, i);
404
460
  case "picture":
405
- return ((t, a) => h1(t, a))(e, i);
461
+ return ((t, n) => S1(t, n))(e, i);
406
462
  default:
407
463
  return { x: 0, y: 0, width: 100, height: 100 };
408
464
  }
409
- }, K = (e, i) => {
410
- const t = kn(e, i), a = ((s) => [s.x + s.width / 2, s.y + s.height / 2])(t);
411
- return { borders: t, center: a };
412
- }, Ln = (e, i, t, a, s, r) => {
413
- const o = s[0] - a[0], n = s[1] - a[1], l = s[0] - i[0], c = s[1] - i[1], d = t.rotation + Math.atan2(c, l) - Math.atan2(n, o);
414
- return { ...e, rotation: rn(d, r) };
415
- }, Vn = (e, i, t, a, s, r, o, n, l, c) => {
416
- switch (s.type) {
465
+ }, G = (e, i) => {
466
+ const t = ga(e, i), n = ((o) => [o.x + o.width / 2, o.y + o.height / 2])(t);
467
+ return { borders: t, center: n };
468
+ }, fa = (e, i, t, n, o, r) => {
469
+ const s = o[0] - n[0], a = o[1] - n[1], l = o[0] - i[0], p = o[1] - i[1], c = t.rotation + Math.atan2(p, l) - Math.atan2(a, s);
470
+ return { ...e, rotation: qi(c, r) };
471
+ }, va = (e, i, t, n, o, r, s, a, l, p) => {
472
+ switch (o.type) {
417
473
  case "line":
418
- return ((d, p, h, v, g, f, S) => {
419
- const m = [$(d[0], g), $(d[1], g)], { center: C } = K(h, f), y = ht(m, h.rotation, C, p), Q = le(["points", v.anchor], y, h);
420
- return yt(Q, S, f);
421
- })(t, a, s, r, o, n, c);
474
+ return ((c, d, u, f, g, v, C) => {
475
+ const x = [z(c[0], g), z(c[1], g)], { center: w } = G(u, v), y = Be(x, u.rotation, w, d), b = ce(["points", f.anchor], y, u);
476
+ return mt(b, C, v);
477
+ })(t, n, o, r, s, a, p);
422
478
  case "polygon":
423
- return ((d, p, h, v, g, f, S) => {
424
- const m = [$(d[0], g), $(d[1], g)], { center: C } = K(h, f), y = ht(m, h.rotation, C, p), Q = le(["points", v.anchor], y, h);
425
- return Ue(Q, S, f);
426
- })(t, a, s, r, o, n, c);
479
+ return ((c, d, u, f, g, v, C) => {
480
+ const x = [z(c[0], g), z(c[1], g)], { center: w } = G(u, v), y = Be(x, u.rotation, w, d), b = ce(["points", f.anchor], y, u);
481
+ return Je(b, C, v);
482
+ })(t, n, o, r, s, a, p);
427
483
  case "curve":
428
- return ((d, p, h, v, g, f, S) => {
429
- const m = [$(d[0], g), $(d[1], g)], { center: C } = K(h, f), y = ht(m, h.rotation, C, p), Q = le(["points", v.anchor], y, h);
430
- return ze(Q, S, f);
431
- })(t, a, s, r, o, n, c);
484
+ return ((c, d, u, f, g, v, C) => {
485
+ const x = [z(c[0], g), z(c[1], g)], { center: w } = G(u, v), y = Be(x, u.rotation, w, d), b = ce(["points", f.anchor], y, u);
486
+ return Ke(b, C, v);
487
+ })(t, n, o, r, s, a, p);
432
488
  case "brush":
433
- return ((d, p, h, v, g, f, S) => {
434
- const { borders: m } = K({ ...p, scaleX: 1, scaleY: 1 }, g), { borders: C } = K(p, g), { borderX: y, borderHeight: Q, borderY: k, borderWidth: H } = pt(d, p, h, v, g, S), F = Math.max(0, m.width - 2 * g), T = Math.max(0, m.height - 2 * g), E = Math.max(0, H - 2 * g) / F, b = Math.max(0, Q - 2 * g) / T, P = He(y - C.x), w = He(k - C.y);
435
- return _e({ ...p, points: p.points.map((L) => L.map(([x, M]) => [x + P, M + w])), scaleX: E, scaleY: b }, f, g);
436
- })(t, s, r, o, n, c, l);
489
+ return ((c, d, u, f, g, v, C) => {
490
+ const { borders: x } = G({ ...d, scaleX: 1, scaleY: 1 }, g), { borders: w } = G(d, g), { borderX: y, borderHeight: b, borderY: H, borderWidth: A } = _e(c, d, u, f, g, C), Z = Math.max(0, x.width - 2 * g), F = Math.max(0, x.height - 2 * g), E = Math.max(0, A - 2 * g), S = Math.max(0, b - 2 * g), T = Z ? E / Z : 1, M = F ? S / F : 1;
491
+ if (!Z || !F)
492
+ return d;
493
+ const B = Fe(y - w.x), N = Fe(H - w.y);
494
+ return et({ ...d, points: d.points.map((Q) => Q.map(([k, m]) => [k + B, m + N])), scaleX: T, scaleY: M }, v, g);
495
+ })(t, o, r, s, a, p, l);
437
496
  case "circle":
438
- return ((d, p, h, v, g, f) => {
439
- const { borderX: S, borderHeight: m, borderY: C, borderWidth: y } = pt(d, p, h, v, g, !0);
440
- return Ct({ ...p, radius: Math.max(0, y / 2 - g), x: S + y / 2, y: C + m / 2 }, f, g);
441
- })(t, s, r, o, n, c);
497
+ return ((c, d, u, f, g, v) => {
498
+ const { borderX: C, borderHeight: x, borderY: w, borderWidth: y } = _e(c, d, u, f, g, !0);
499
+ return ft({ ...d, radius: Math.max(0, y / 2 - g), x: C + y / 2, y: w + x / 2 }, v, g);
500
+ })(t, o, r, s, a, p);
442
501
  case "ellipse":
443
- return ((d, p, h, v, g, f, S = !1) => {
444
- const { borderX: m, borderHeight: C, borderY: y, borderWidth: Q } = pt(d, p, h, v, g, S);
445
- return St({ ...p, radiusX: Math.max(0, Q / 2 - g), radiusY: Math.max(0, C / 2 - g), x: m + Q / 2, y: y + C / 2 }, f, g);
446
- })(t, s, r, o, n, c, l);
502
+ return ((c, d, u, f, g, v, C = !1) => {
503
+ const { borderX: x, borderHeight: w, borderY: y, borderWidth: b } = _e(c, d, u, f, g, C);
504
+ return vt({ ...d, radiusX: Math.max(0, b / 2 - g), radiusY: Math.max(0, w / 2 - g), x: x + b / 2, y: y + w / 2 }, v, g);
505
+ })(t, o, r, s, a, p, l);
447
506
  case "rect":
448
507
  case "square":
449
- return Dt(t, s, r, o, n, c, i.type === "square" || l);
508
+ return ((c, d, u, f, g, v, C = !1) => {
509
+ const { borderX: x, borderHeight: w, borderY: y, borderWidth: b } = _e(c, d, u, f, g, C);
510
+ return Qt({ ...d, width: Math.max(0, b - 2 * g), height: Math.max(0, w - 2 * g), x: x + g, y: y + g }, v, g);
511
+ })(t, o, r, s, a, p, i.type === "square" || l);
450
512
  case "text":
451
- return ((d, p, h, v, g, f, S) => {
452
- const m = Dt(p, h, v, g, f, S, !0);
453
- return { ...m, fontSize: jt(d, m.value, m.width, m.style?.fontBold ?? !1, m.style?.fontItalic ?? !1, m.style?.fontFamily) };
454
- })(e, t, s, r, o, n, c);
513
+ return ((c, d, u, f, g, v, C) => {
514
+ const { borderX: x, borderHeight: w, borderY: y, borderWidth: b } = _e(d, u, f, g, v, !0), H = St({ ...u, width: Math.max(0, b - 2 * v), height: Math.max(0, w - 2 * v), x: x + v, y: y + v }, C, v);
515
+ return { ...H, fontSize: _t(c, H.value, H.width, H.style?.fontBold ?? !1, H.style?.fontItalic ?? !1, H.style?.fontFamily) };
516
+ })(e, t, o, r, s, a, p);
455
517
  case "picture":
456
- return ((d, p, h, v, g, f, S) => Dt(d, p, h, v, g, f, S))(t, s, r, o, n, c, !l);
518
+ return ((c, d, u, f, g, v, C) => {
519
+ const { borderX: x, borderHeight: w, borderY: y, borderWidth: b } = _e(c, d, u, f, g, !0);
520
+ return bt({ ...d, width: Math.max(0, b - 2 * g), height: Math.max(0, w - 2 * g), x: x + g, y: y + g }, v, g);
521
+ })(t, o, r, s, a, p);
457
522
  default:
458
- return s;
523
+ return o;
459
524
  }
460
- }, zt = (e, i, t, a, s, r) => {
525
+ }, Wt = (e, i, t, n, o, r) => {
461
526
  switch (i.type) {
462
527
  case "rect":
463
528
  case "square":
464
- return ((o, n, l, c, d, p) => bt({ ...n, x: $(n.x + o[0] - l[0], c), y: $(n.y + o[1] - l[1], c) }, d, p))(e, i, t, a, s, r);
529
+ return ((s, a, l, p, c, d) => Qt({ ...a, x: z(a.x + s[0] - l[0], p), y: z(a.y + s[1] - l[1], p) }, c, d))(e, i, t, n, o, r);
465
530
  case "ellipse":
466
- return ((o, n, l, c, d, p) => St({ ...n, x: $(n.x + o[0] - l[0], c), y: $(n.y + o[1] - l[1], c) }, d, p))(e, i, t, a, s, r);
531
+ return ((s, a, l, p, c, d) => vt({ ...a, x: z(a.x + s[0] - l[0], p), y: z(a.y + s[1] - l[1], p) }, c, d))(e, i, t, n, o, r);
467
532
  case "circle":
468
- return ((o, n, l, c, d, p) => Ct({ ...n, x: $(n.x + o[0] - l[0], c), y: $(n.y + o[1] - l[1], c) }, d, p))(e, i, t, a, s, r);
533
+ return ((s, a, l, p, c, d) => ft({ ...a, x: z(a.x + s[0] - l[0], p), y: z(a.y + s[1] - l[1], p) }, c, d))(e, i, t, n, o, r);
469
534
  case "picture":
470
- return ((o, n, l, c, d, p) => e1({ ...n, x: $(n.x + o[0] - l[0], c), y: $(n.y + o[1] - l[1], c) }, d, p))(e, i, t, a, s, r);
535
+ return ((s, a, l, p, c, d) => bt({ ...a, x: z(a.x + s[0] - l[0], p), y: z(a.y + s[1] - l[1], p) }, c, d))(e, i, t, n, o, r);
471
536
  case "text":
472
- return ((o, n, l, c, d, p) => Yt({ ...n, x: $(n.x + o[0] - l[0], c), y: $(n.y + o[1] - l[1], c) }, d, p))(e, i, t, a, s, r);
537
+ return ((s, a, l, p, c, d) => St({ ...a, x: z(a.x + s[0] - l[0], p), y: z(a.y + s[1] - l[1], p) }, c, d))(e, i, t, n, o, r);
473
538
  case "line":
474
- return ((o, n, l, c, d, p) => yt({ ...n, points: n.points.map(([h, v]) => [$(h + o[0] - l[0], c), $(v + o[1] - l[1], c)]) }, d, p))(e, i, t, a, s, r);
539
+ return ((s, a, l, p, c, d) => mt({ ...a, points: a.points.map(([u, f]) => [z(u + s[0] - l[0], p), z(f + s[1] - l[1], p)]) }, c, d))(e, i, t, n, o, r);
475
540
  case "polygon":
476
- return ((o, n, l, c, d, p) => {
477
- if (c) {
478
- const { borders: h } = K(n, p), v = $(h.x + o[0] - l[0], c) - h.x, g = $(h.y + o[1] - l[1], c) - h.y;
479
- return { ...n, points: n.points.map(([f, S]) => [f + v, S + g]) };
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);
541
+ return ((s, a, l, p, c, d) => {
542
+ const { borders: u } = G(a, d);
543
+ return Je({ ...a, points: a.points.map(([f, g]) => p ? [f + z(u.x + s[0] - l[0], p) - u.x, g + z(u.y + s[1] - l[1], p) - u.y] : [z(f + s[0] - l[0], p), z(g + s[1] - l[1], p)]) }, c, d);
544
+ })(e, i, t, n, o, r);
483
545
  case "curve":
484
- return ((o, n, l, c, d, p) => {
485
- const { borders: h } = K(n, p);
486
- return ze({ ...n, points: n.points.map(([v, g]) => c ? [v + $(h.x + o[0] - l[0], c) - h.x, g + $(h.y + o[1] - l[1], c) - h.y] : [$(v + o[0] - l[0], c), $(g + o[1] - l[1], c)]) }, d, p);
487
- })(e, i, t, a, s, r);
546
+ return ((s, a, l, p, c, d) => {
547
+ const { borders: u } = G(a, d);
548
+ return Ke({ ...a, points: a.points.map(([f, g]) => p ? [f + z(u.x + s[0] - l[0], p) - u.x, g + z(u.y + s[1] - l[1], p) - u.y] : [z(f + s[0] - l[0], p), z(g + s[1] - l[1], p)]) }, c, d);
549
+ })(e, i, t, n, o, r);
488
550
  case "brush":
489
- return ((o, n, l, c, d, p) => {
490
- const { borders: h } = K(n, p), v = c ? $(h.x + o[0] - l[0], c) - h.x : o[0] - l[0], g = c ? $(h.y + o[1] - l[1], c) - h.y : o[1] - l[1];
491
- return _e({ ...n, points: n.points.map((f) => f.map(([S, m]) => [S + v, m + g])) }, d, p);
492
- })(e, i, t, a, s, r);
551
+ return ((s, a, l, p, c, d) => {
552
+ const { borders: u } = G(a, d), f = p ? z(u.x + s[0] - l[0], p) - u.x : s[0] - l[0], g = p ? z(u.y + s[1] - l[1], p) - u.y : s[1] - l[1];
553
+ return et({ ...a, points: a.points.map((v) => v.map(([C, x]) => [C + f, x + g])) }, c, d);
554
+ })(e, i, t, n, o, r);
493
555
  default:
494
556
  return i;
495
557
  }
496
- }, Je = (e, i, t) => {
558
+ }, st = (e, i, t) => {
497
559
  switch (e.type) {
498
560
  case "rect":
499
561
  case "square":
500
- return gn(e, i, t);
562
+ return la(e, i, t);
501
563
  case "ellipse":
502
- return Qn(e, i, t);
564
+ return ia(e, i, t);
503
565
  case "circle":
504
- return yn(e, i, t);
566
+ return Ji(e, i, t);
505
567
  case "picture":
506
- return wn(e, i, t);
568
+ return ca(e, i, t);
507
569
  case "text":
508
- return fn(e, i, t);
570
+ return ua(e, i, t);
509
571
  case "line":
510
- return cn(e, i, t);
572
+ return na(e, i, t);
511
573
  case "polygon":
512
- return pn(e, i, t);
574
+ return Ki(e, i, t);
513
575
  case "curve":
514
- return un(e, i, t);
576
+ return ea(e, i, t);
515
577
  case "brush":
516
- return sn(e, i, t);
578
+ return ji(e, i, t);
517
579
  default:
518
580
  return e;
519
581
  }
520
- }, Hn = ({ ctx: e, shape: i, currentScale: t = 1, canvasOffset: a, selectionPadding: s, selectionWidth: r, selectionColor: o, withAnchors: n = !0 }) => {
521
- const { center: l } = K(i, s);
522
- switch (j1(e, t, a, i.rotation, l), i.type) {
582
+ }, M1 = ({ ctx: e, shape: i, currentScale: t = 1, canvasOffset: n, selectionPadding: o, selectionWidth: r, selectionColor: s, withAnchors: a = !0 }) => {
583
+ const { center: l } = G(i, o);
584
+ switch (Xt(e, t, n, i.rotation, l), i.type) {
523
585
  case "rect":
524
586
  case "square":
525
587
  case "circle":
@@ -527,743 +589,777 @@ const U1 = 2, z1 = "blue", xe = 14, B1 = [[0, 0], [0.5, 0], [1, 0], [1, 0.5], [1
527
589
  case "picture":
528
590
  case "text":
529
591
  case "brush":
530
- ((c, d, p, h, v, g) => {
531
- if (d.selection && (We(c, { fillColor: "transparent", strokeColor: p, lineWidth: h / v }), c.stroke(d.selection.border), g && !d.locked)) {
532
- c.stroke(d.selection.line), We(c, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / v });
533
- for (const f of d.selection.anchors)
534
- c.fill(f), c.stroke(f);
592
+ ((p, c, d, u, f, g) => {
593
+ if (c.selection && (ze(p, { fillColor: "transparent", strokeColor: d, lineWidth: u / f }), c.selection.shapePath ? p.stroke(c.selection.shapePath) : p.stroke(c.selection.border), g && !c.locked)) {
594
+ c.selection.shapePath && p.stroke(c.selection.border), p.stroke(c.selection.line), ze(p, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / f });
595
+ for (const v of c.selection.anchors)
596
+ p.fill(v), p.stroke(v);
535
597
  }
536
- })(e, i, o, r, t, n);
598
+ })(e, i, s, r, t, a);
537
599
  break;
538
600
  case "polygon":
539
601
  case "line":
540
602
  case "curve":
541
- (({ ctx: c, shape: d, withAnchors: p, selectionWidth: h, selectionColor: v, currentScale: g = 1 }) => {
542
- if (d.selection && (We(c, { fillColor: "transparent", strokeColor: v, lineWidth: h / g }), c.stroke(d.selection.border), p && !d.locked)) {
543
- We(c, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / g });
544
- for (const f of d.selection.anchors)
545
- c.fill(f), c.stroke(f);
603
+ (({ ctx: p, shape: c, withAnchors: d, selectionWidth: u, selectionColor: f, currentScale: g = 1 }) => {
604
+ if (c.selection && (ze(p, { fillColor: "transparent", strokeColor: f, lineWidth: u / g }), c.selection.shapePath && p.stroke(c.selection.shapePath), d && !c.locked)) {
605
+ ze(p, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / g });
606
+ for (const v of c.selection.anchors)
607
+ p.fill(v), p.stroke(v);
546
608
  }
547
- })({ ctx: e, shape: i, withAnchors: n, selectionWidth: r, selectionColor: o, currentScale: t });
609
+ })({ ctx: e, shape: i, withAnchors: a, selectionWidth: r, selectionColor: s, currentScale: t });
548
610
  }
549
611
  e.restore();
550
- }, Tn = ({ disabled: e = !1, scaleRatio: i, shape: t, defaultValue: a, updateValue: s, saveShapes: r, selectionPadding: o }) => {
551
- const n = ne(null), l = ne(r);
552
- _(() => {
553
- if (!n.current)
554
- return;
555
- const d = n.current, p = (h) => {
556
- h.preventDefault();
557
- const v = h.clipboardData?.getData("text/plain");
558
- document.execCommand("insertText", !1, v);
559
- };
560
- return d.addEventListener("paste", p), d.innerHTML = a.map((h) => `<div>${h === "" ? "<br/>" : h}</div>`).join(""), d.focus(), () => {
561
- d.removeEventListener("paste", p);
562
- };
563
- }, [a]), _(() => {
564
- const d = l.current;
565
- return () => {
566
- d();
612
+ }, ma = ({ ctx: e, selectionFrame: i, currentScale: t = 1, canvasOffset: n }) => {
613
+ Xt(e, t, n), ((o, r, s) => {
614
+ ze(o, { fillColor: "rgba(170,170,170, 0.1)", strokeColor: "rgb(170,170,170)", lineWidth: 1 / s }), o.fillRect(r[0][0], r[0][1], r[1][0] - r[0][0], r[1][1] - r[0][1]), o.strokeRect(r[0][0], r[0][1], r[1][0] - r[0][0], r[1][1] - r[0][1]);
615
+ })(e, i, t), e.restore();
616
+ }, k1 = "ArrowUp", L1 = "ArrowDown", V1 = "ArrowLeft", H1 = "ArrowRight", ya = "Delete", Qa = "Backspace", ba = "Escape", A1 = "Shift", Sa = "z", Ca = "Z", xa = "y", wa = "Y", T1 = "copy", Z1 = "paste", Ma = ({ gridFormat: e, isInsideComponent: i, selectedShape: t, isEditingText: n, currentScale: o, selectionPadding: r, setSelectedShape: s, removeShape: a, pasteShape: l, updateShape: p, backwardShape: c, forwardShape: d, setShiftPressed: u }) => {
617
+ const [f, g] = R(void 0);
618
+ return Y(() => {
619
+ const v = (y) => {
620
+ t && (n || (y.preventDefault(), g({ ...t })));
621
+ }, C = (y) => {
622
+ f && (n || (y.preventDefault(), l(((b, H, A, Z) => ({ ...Wt([20, 20], b, [0, 0], H, A, Z), id: ae(`${b.type}_`) }))(f, e, o, r))));
623
+ }, x = (y) => {
624
+ y.key === A1 && u(!1);
625
+ }, w = (y) => {
626
+ if (y.metaKey || y.ctrlKey) {
627
+ if (y.key === Ca || y.key === Sa)
628
+ return y.preventDefault(), y.stopPropagation(), void c();
629
+ if (y.key === wa || y.key === xa)
630
+ return y.preventDefault(), y.stopPropagation(), void d();
631
+ }
632
+ if (y.key === A1)
633
+ return void u(!0);
634
+ if (!t)
635
+ return;
636
+ if (y.key === ba)
637
+ return void s(void 0);
638
+ if (n)
639
+ return;
640
+ const b = { [V1]: [e ? -Oe[e - 1] : -1, 0], [H1]: [e ? Oe[e - 1] : 1, 0], [L1]: [0, e ? Oe[e - 1] : 1], [k1]: [0, e ? -Oe[e - 1] : -1] };
641
+ switch (y.key) {
642
+ case V1:
643
+ case H1:
644
+ case L1:
645
+ case k1:
646
+ p(Wt(b[y.key], t, [0, 0], e, o, r));
647
+ break;
648
+ case ya:
649
+ case Qa:
650
+ a(t);
651
+ }
567
652
  };
568
- }, []);
569
- const c = Yi(() => {
570
- const { borders: d, center: p } = K(t, o);
571
- return Me({ point: [d.x, d.y], rotation: -t.rotation, origin: p });
572
- }, [t, o]);
573
- return u("div", { className: "react-paint-editor-toolbox-edittextbox", ref: n, "data-fontbold": t.style?.fontBold ?? !1, "data-fontitalic": t.style?.fontItalic ?? !1, contentEditable: !e, onInput: (d) => {
574
- s(Ki(d.target.innerHTML));
575
- }, style: { "--react-paint-editor-toolbox-edittextbox-transform": `translate3D(${c[0] * i}px, ${c[1] * i}px, 0) rotate(${$t(t.rotation)}deg)`, "--react-paint-editor-toolbox-edittextbox-fontsize": t.fontSize * i + "px", "--react-paint-editor-toolbox-edittextbox-padding": o * 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 ?? Ke } });
576
- }, An = (e, i, t, a, s, r) => {
577
- if (s) {
578
- const n = ((l, c, d, p) => {
579
- if (l.mode === "translate")
580
- return { mode: "translate", cursorStartPosition: d, originalShape: c };
581
- if (l.mode === "rotate") {
582
- const { center: h } = K(c, p);
583
- return { mode: "rotate", cursorStartPosition: d, originalShape: c, center: [h[0], h[1]] };
653
+ if (i)
654
+ return document.addEventListener("keydown", w), document.addEventListener("keyup", x), document.addEventListener(T1, v), document.addEventListener(Z1, C), () => {
655
+ document.removeEventListener("keydown", w), document.removeEventListener("keyup", x), document.removeEventListener(T1, v), document.removeEventListener(Z1, C);
656
+ };
657
+ }, [i, r, e, f, n, t, o, p, a, s, l, c, d, u]), {};
658
+ }, ka = (e, i, t) => {
659
+ const n = ee([]), o = ee(e);
660
+ o.current = e;
661
+ const [r, s] = R(void 0), [a, l] = R(void 0), [p, c] = R(void 0), [d, u] = R({ states: [{ shapes: [], selectedShape: void 0 }], cursor: 0 }), f = d.cursor > 0, g = d.cursor < d.states.length - 1, v = n.current.length > 0, C = U(() => {
662
+ u((Q) => ci(Q.states[Q.cursor].shapes, n.current) ? Q : { states: [...Q.states.slice(0, Q.cursor + 1), { shapes: n.current, selectedShape: a }], cursor: Q.cursor + 1 });
663
+ }, [a]), x = U((Q) => {
664
+ n.current = [Q, ...n.current];
665
+ }, []), w = U((Q, k, m, V, L) => {
666
+ if (Q.target && "className" in Q.target && ![oi, si].includes(Q.target.className))
667
+ return void c(void 0);
668
+ const $ = n.current.find((W) => W.id === a?.id ? !!ot(a, m, V, i, L) : !!pi(k, W, m, V, i, L));
669
+ c($);
670
+ }, [i, a]), y = U(async (Q, k = 300, m = 300) => {
671
+ const V = await pa(Q, k, m, t.scaleRatio, i);
672
+ return x(V), C(), V;
673
+ }, [x, C, t, i]), b = U((Q, k = !1) => {
674
+ n.current = n.current.map((m) => m.id === a?.id ? Q : m), l((m) => m?.id === Q.id ? Q : m), k && C();
675
+ }, [a, C]), H = U((Q) => {
676
+ const k = Q.map((m) => Et(["chosen"], m));
677
+ n.current = k, C();
678
+ }, [C]), A = U((Q) => {
679
+ l((k) => k?.id === Q.id ? void 0 : k), n.current = n.current.filter((k) => k.id !== Q.id), C();
680
+ }, [C]), Z = U((Q) => {
681
+ u((k) => {
682
+ const m = Q(k);
683
+ return n.current = k.states[m].shapes, l(k.states[m].selectedShape), ce("cursor", m, k);
684
+ });
685
+ }, []), F = U(() => {
686
+ Z((Q) => Math.max(0, Q.cursor - 1));
687
+ }, [Z]), E = U(() => {
688
+ Z((Q) => Math.min(Q.states.length - 1, Q.cursor + 1));
689
+ }, [Z]), S = U((Q = [], k = !1) => {
690
+ l(void 0), n.current = Q, u((m) => k ? { states: [{ shapes: Q, selectedShape: void 0 }], cursor: 0 } : { states: [...m.states.slice(0, m.cursor + 1), { shapes: Q, selectedShape: void 0 }], cursor: m.cursor + 1 });
691
+ }, []), T = U((Q, k) => {
692
+ const m = n.current, V = m.findIndex(($) => $.id === Q), L = m.findIndex(($) => $.id === k);
693
+ H(V < L ? [...m.slice(0, V), ...m.slice(V + 1, L + 1), m[V], ...m.slice(L + 1, m.length)] : [...m.slice(0, L), m[V], ...m.slice(L, V), ...m.slice(V + 1, m.length)]);
694
+ }, [H]), M = U((Q) => {
695
+ const k = n.current, m = k.findIndex((L) => L.id === Q.id);
696
+ if (m < 0)
697
+ return;
698
+ const V = ce("visible", Q.visible === !1, Q);
699
+ l((L) => L?.id === V.id ? V : L), H(ce(m, V, k));
700
+ }, [H]), B = U((Q) => {
701
+ const k = n.current, m = k.findIndex((L) => L.id === Q.id);
702
+ if (m < 0)
703
+ return;
704
+ const V = ce("locked", !Q.locked, Q);
705
+ l((L) => L?.id === V.id ? V : L), H(ce(m, V, k));
706
+ }, [H]);
707
+ Y(() => {
708
+ o.current?.();
709
+ }, [d]), Y(() => {
710
+ n.current = n.current.map((Q) => st(Q, t.scaleRatio, i)), l((Q) => Q === void 0 ? void 0 : n.current.find((k) => k.id === Q.id));
711
+ }, [t, i]);
712
+ const N = U((Q, k, m, V) => {
713
+ s((L) => {
714
+ const $ = [L?.[0] ?? [k[0], k[1]], [k[0], k[1]]], W = n.current.filter((_) => ((O, P, ne, oe, se) => {
715
+ const { center: le, borders: de } = G(P, se), q = Be(ne[0], P.rotation, le, oe), ue = Be(ne[1], P.rotation, le, oe), we = Math.round(Math.min(q[0], ue[0]) - se / 2), Se = Math.round(Math.max(q[0], ue[0]) + se), Me = Math.round(Math.min(q[1], ue[1]) - se / 2), Ae = { x: we, y: Me, width: Se - we, height: Math.round(Math.max(q[1], ue[1]) + se) - Me }, ve = g1(de, Ae);
716
+ if (!ve)
717
+ return !1;
718
+ if (de.width <= 1 || de.height <= 1 || !("path" in P) || !P.path)
719
+ return !0;
720
+ if (O.lineWidth = (P.style?.lineWidth ?? 0) + 10, P.type === "brush") {
721
+ const ye = P.points.flat(), he = Math.min(...ye.map((K) => K[0])), Te = Math.min(...ye.map((K) => K[1]));
722
+ for (const K of P.points) {
723
+ if (K.length < 1)
724
+ break;
725
+ if (K.length < 2) {
726
+ const ke = Ue(K[0], he, Te, P.scaleX, P.scaleY);
727
+ if (di(ve, { x: ke[0], y: ke[1], radius: (P.style?.lineWidth ?? 1) / 2 }))
728
+ return !0;
729
+ }
730
+ for (let ke = 0; ke < K.length - 1; ke++) {
731
+ const Ee = Ue(K[ke], he, Te, P.scaleX, P.scaleY), Ie = Ue(K[ke + 1], he, Te, P.scaleX, P.scaleY), Qe = g1({ x: Math.min(Ee[0], Ie[0]), y: Math.min(Ee[1], Ie[1]), width: Math.abs(Ee[0] - Ie[0]), height: Math.abs(Ee[1] - Ie[1]) }, Ae);
732
+ if (Qe) {
733
+ const Ze = new Path2D();
734
+ if (Ze.moveTo(...Ee), Ze.lineTo(...Ie), f1({ ctx: O, path: Ze, rect: Qe, offset: 10, checkFill: !1 }))
735
+ return !0;
736
+ }
737
+ }
738
+ }
739
+ return !1;
740
+ }
741
+ const De = !(!P.style?.fillColor || P.style?.fillColor === "transparent");
742
+ return f1({ ctx: O, path: P.path, rect: ve, offset: 10, checkFill: De });
743
+ })(Q, _, $, m, i));
744
+ return l(W?.[0]), $;
745
+ });
746
+ }, [i]);
747
+ return { shapesRef: n, selectedShape: a, hoveredShape: p, selectionFrame: r, setSelectionFrame: s, refreshSelectedShapes: N, addShape: x, addPictureShape: y, moveShapes: T, saveShapes: C, setSelectedShape: l, refreshHoveredShape: w, toggleShapeVisibility: M, toggleShapeLock: B, removeShape: A, updateShape: b, backwardShape: F, forwardShape: E, clearShapes: S, canGoBackward: f, canGoForward: g, canClear: v };
748
+ }, La = "infos", Va = 4e3, Ha = () => {
749
+ const e = ee([]), [i, t] = R([]);
750
+ return Y(() => () => {
751
+ for (const n of e.current)
752
+ clearTimeout(n);
753
+ }, []), { snackbarList: i, addSnackbar: ({ type: n = La, duration: o = Va, text: r }) => {
754
+ const s = { id: ae("snackbar_"), duration: o, type: n, text: r };
755
+ t((a) => [...a, s]), e.current = [...e.current, setTimeout(() => {
756
+ return a = s.id, void t((l) => l.filter((p) => p.id !== a));
757
+ var a;
758
+ }, o)];
759
+ } };
760
+ }, P1 = (e, i = !1) => {
761
+ const t = (o, r) => {
762
+ if (Array.isArray(o))
763
+ return r;
764
+ }, n = e.map((o) => {
765
+ if (typeof o != "object")
766
+ return null;
767
+ switch (o.type) {
768
+ case "brush":
769
+ return xe(t, q1, o);
770
+ case "circle":
771
+ return xe(t, ii, o);
772
+ case "curve":
773
+ return xe(t, K1, o);
774
+ case "ellipse":
775
+ return xe(t, ai, o);
776
+ case "line":
777
+ return xe(t, G1, o);
778
+ case "polygon":
779
+ return xe(t, J1, o);
780
+ case "rect":
781
+ return xe(t, ei, o);
782
+ case "square":
783
+ return xe(t, ti, o);
784
+ case "text":
785
+ return xe(t, ni, o);
786
+ }
787
+ return null;
788
+ });
789
+ return yt(i ? [...n, Bt] : n);
790
+ }, Aa = (e, i, t, n, o, r, s, a, l) => {
791
+ let p = !1;
792
+ if (r) {
793
+ p = ot(r, t, o, s, n, !0, a ? 20 : void 0);
794
+ const d = ((u, f, g, v) => {
795
+ if (u.mode === "translate")
796
+ return { mode: "translate", cursorStartPosition: g, originalShape: f };
797
+ if (u.mode === "rotate") {
798
+ const { center: C } = G(f, v);
799
+ return { mode: "rotate", cursorStartPosition: g, originalShape: f, center: [C[0], C[1]] };
584
800
  }
585
- return l.mode === "resize" ? { mode: "resize", cursorStartPosition: d, originalShape: c, anchor: l.anchor } : void 0;
586
- })(mt(s, i, a, r, t, !0) || { mode: "default" }, s, i, r);
587
- if (n?.mode === "resize" || n?.mode === "rotate")
588
- return { shape: s, mode: n };
801
+ return u.mode === "resize" ? { mode: "resize", cursorStartPosition: g, originalShape: f, anchor: u.anchor } : void 0;
802
+ })(p || { mode: "default" }, r, t, s);
803
+ if (d?.mode === "resize" || d?.mode === "rotate")
804
+ return { shape: r, mode: d };
589
805
  }
590
- const o = e.find((n) => !!mt(n, i, a, r, t, !1));
591
- return o ? { shape: o, mode: { mode: "translate", cursorStartPosition: i, originalShape: o } } : { shape: void 0, mode: { mode: "default" } };
592
- }, Zn = ({ disabled: e = !1, addShape: i, canvasSize: t, drawCanvasRef: a, setActiveTool: s, shapes: r, selectionMode: o, activeTool: n, isInsideComponent: l, setCanvasOffset: c, selectedShape: d, selectionCanvasRef: p, canvasOffsetStartPosition: h, setSelectedShape: v, setCanvasOffsetStartPosition: g, updateSingleShape: f, gridFormat: S, canvasOffset: m, saveShapes: C, setSelectionMode: y, selectionPadding: Q, isShiftPressed: k }) => {
593
- const { width: H, height: F, scaleRatio: T } = t, [E, b] = O({ mode: "default" }), { registerDoubleClickEvent: P, unRegisterDoubleClickEvent: w } = (() => {
594
- const L = ne(void 0), x = ne(void 0), M = (N) => {
595
- const Z = (/* @__PURE__ */ new Date()).getTime();
596
- L.current && Z < L.current + 300 && x.current?.(N), L.current = (/* @__PURE__ */ new Date()).getTime();
806
+ const c = i.find((d) => d.id === r?.id ? !!p : !!pi(e, d, t, o, s, n));
807
+ return c ? { shape: c, mode: { mode: "translate", cursorStartPosition: t, originalShape: c } } : { shape: void 0, mode: { mode: l ? "selectionFrame" : "default" } };
808
+ }, Ta = ({ disabled: e = !1, addShape: i, canvasSize: t, drawCanvasRef: n, setActiveTool: o, refreshHoveredShape: r, shapes: s, selectionMode: a, activeTool: l, isInsideComponent: p, setCanvasOffset: c, selectedShape: d, selectionCanvasRef: u, canvasOffsetStartPosition: f, refreshSelectedShapes: g, setSelectedShape: v, setSelectionFrame: C, setCanvasOffsetStartPosition: x, updateSingleShape: w, gridFormat: y, canvasOffset: b, saveShapes: H, setSelectionMode: A, selectionPadding: Z, isShiftPressed: F, withFrameSelection: E }) => {
809
+ const { width: S, height: T, scaleRatio: M } = t, [B, N] = R({ mode: "default" }), { registerDoubleClickEvent: Q, unRegisterDoubleClickEvent: k } = (() => {
810
+ const m = ee(void 0), V = ee(void 0), L = ($) => {
811
+ const W = (/* @__PURE__ */ new Date()).getTime();
812
+ m.current && W < m.current + 300 && V.current?.($), m.current = (/* @__PURE__ */ new Date()).getTime();
597
813
  };
598
- return { registerDoubleClickEvent: (N, Z) => {
599
- x.current = Z, N.addEventListener("click", M), N.addEventListener("touchend", M);
600
- }, unRegisterDoubleClickEvent: (N) => {
601
- N.removeEventListener("click", M), N.removeEventListener("touchend", M);
814
+ return { registerDoubleClickEvent: ($, W) => {
815
+ V.current = W, $.addEventListener("click", L), $.addEventListener("touchend", L);
816
+ }, unRegisterDoubleClickEvent: ($) => {
817
+ $.removeEventListener("click", L), $.removeEventListener("touchend", L);
602
818
  } };
603
819
  })();
604
- return _(() => {
605
- const L = (x) => window.requestAnimationFrame(() => ((M, N, Z, I, Y, ce, he, q, ye, Ae, be, ke, xt, ge, et, tt, Ie) => {
606
- if (Z.type === "move" && q !== void 0) {
607
- const Ze = lt(M, N.current, ye, Ae, be);
608
- ge([Ze[0] - q[0], Ze[1] - q[1]]);
609
- }
610
- if (ce == null || ce.locked)
820
+ return Y(() => {
821
+ const m = (V) => window.requestAnimationFrame(() => ((L, $, W, _, O, P, ne, oe, se, le, de, q, ue, we, Se, Me, Ae, ve, De) => {
822
+ const ye = $.current?.getContext("2d");
823
+ if (!ye)
611
824
  return;
612
- const je = lt(M, N.current, ye, Ae, be);
613
- if (he.mode === "default" || he.mode === "textedition")
614
- ke(mt(ce, je, Y, tt, be, !0) || { mode: "default" });
615
- else {
616
- const Ze = N.current?.getContext("2d");
617
- if (!Ze)
618
- return;
619
- const it = ln(Ze, ce, je, I, Y, he, tt, Ie, be);
620
- xt(it), et(it);
621
- }
622
- })(x, p, n, S, m, d, o, h, H, F, T, b, f, c, v, Q, k));
623
- return l && (document.addEventListener("mousemove", L), document.addEventListener("touchmove", L)), () => {
624
- l && (document.removeEventListener("mousemove", L), document.removeEventListener("touchmove", L));
625
- };
626
- }, [l, p, d, o, b, S, m, h, H, F, T, f, n, c, v, Q, k]), _(() => {
627
- const L = () => {
628
- o.mode !== "textedition" && o.mode !== "default" && (y({ mode: "default" }), C());
825
+ const he = Zt(L, $.current, se, le, de);
826
+ if (W.type !== "move" || oe === void 0)
827
+ if (ne.mode !== "selectionFrame") {
828
+ if (h1(L) || ue(L, ye, he, O, de), P !== void 0 && !P.locked)
829
+ if (ne.mode === "default" || ne.mode === "textedition")
830
+ q(ot(P, he, O, ve, de, !0) || { mode: "default" });
831
+ else {
832
+ const Te = $.current?.getContext("2d");
833
+ if (!Te)
834
+ return;
835
+ const K = Gi(Te, P, he, _, O, ne, ve, De, de);
836
+ we(K), Me(K);
837
+ }
838
+ } else
839
+ Ae(ye, he, O, de);
840
+ else
841
+ Se([he[0] - oe[0], he[1] - oe[1]]);
842
+ })(V, u, l, y, b, d, a, f, S, T, M, N, r, w, c, v, g, Z, F));
843
+ if (p)
844
+ return document.addEventListener("mousemove", m), document.addEventListener("touchmove", m), () => {
845
+ document.removeEventListener("mousemove", m), document.removeEventListener("touchmove", m);
846
+ };
847
+ }, [p, u, d, a, y, b, f, S, T, M, w, l, c, v, r, g, Z, F]), Y(() => {
848
+ const m = () => {
849
+ a.mode !== "textedition" && a.mode !== "default" && (A({ mode: "default" }), C(void 0), H());
629
850
  };
630
- return l && (document.addEventListener("mouseup", L), document.addEventListener("touchend", L)), () => {
631
- l && (document.removeEventListener("mouseup", L), document.removeEventListener("touchend", L));
851
+ return p && (document.addEventListener("mouseup", m), document.addEventListener("touchend", m)), () => {
852
+ p && (document.removeEventListener("mouseup", m), document.removeEventListener("touchend", m));
632
853
  };
633
- }, [l, o, C, y]), _(() => {
634
- const L = p.current;
635
- if (!L || e)
854
+ }, [p, a, H, C, A]), Y(() => {
855
+ const m = u.current;
856
+ if (!m)
636
857
  return;
637
- const x = (M) => {
638
- M.preventDefault();
639
- const N = lt(M, p.current, H, F, T);
640
- if (n.type === "selection") {
641
- const { shape: Z, mode: I } = An(r, N, T, m, d, Q);
642
- v(Z), y(I);
643
- } else
644
- n.type === "move" && g(N);
645
- if (_1.includes(n.type)) {
646
- const Z = a.current?.getContext("2d");
647
- if (!Z)
858
+ const V = m.getContext("2d");
859
+ if (!V || e)
860
+ return;
861
+ const L = ($) => {
862
+ $.preventDefault();
863
+ const W = Zt($, u.current, S, T, M);
864
+ if (l.type === "selection") {
865
+ const { shape: _, mode: O } = Aa(V, s, W, M, b, d, Z, h1($), E);
866
+ v(_), A(O), O.mode === "selectionFrame" && C([[W[0], W[1]], [W[0], W[1]]]);
867
+ } else if (l.type === "move")
868
+ x(W);
869
+ else if (U1.some((_) => _ === l.type)) {
870
+ const _ = n.current?.getContext("2d");
871
+ if (!_)
648
872
  return;
649
- if (n.type === "brush") {
873
+ if (l.type === "brush") {
650
874
  if (d && d.type === "brush") {
651
- const I = ((Y, ce, he, q) => {
652
- const ye = { ...Y, points: le(Y.points.length, [[Math.round(ce[0]), Math.round(ce[1])]], Y.points) };
653
- return _e(ye, he, q);
654
- })(d, N, T, Q);
655
- f(I), v(I);
875
+ const O = ((P, ne, oe, se) => {
876
+ const le = { ...P, points: ce(P.points.length, [[Math.round(ne[0]), Math.round(ne[1])]], P.points) };
877
+ return et(le, oe, se);
878
+ })(d, W, M, Z);
879
+ w(O), v(O);
656
880
  } else {
657
- const I = L1(Z, n, N, S, T, Q);
658
- if (!I)
881
+ const O = w1(_, l, W, y, M, Z);
882
+ if (!O)
659
883
  return;
660
- i(I), v(I);
884
+ i(O), v(O);
661
885
  }
662
- y({ mode: "brush" });
663
- } else if (n.type !== "picture") {
664
- const I = L1(Z, n, N, S, T, Q);
665
- i(I), s(we), v(I), y({ mode: "resize", cursorStartPosition: [N[0] + Q, N[1] + Q], originalShape: I, anchor: n.type === "line" || n.type === "polygon" || n.type === "curve" ? 0 : [1, 1] });
886
+ A({ mode: "brush" });
887
+ } else if (l.type !== "picture") {
888
+ const O = w1(_, l, W, y, M, Z);
889
+ i(O), o(He), v(O), A({ mode: "resize", cursorStartPosition: [W[0] + Z, W[1] + Z], originalShape: O, anchor: l.type === "line" || l.type === "polygon" || l.type === "curve" ? 0 : [1, 1] });
666
890
  }
667
891
  }
668
892
  };
669
- return L.addEventListener("mousedown", x, { passive: !1 }), L.addEventListener("touchstart", x, { passive: !1 }), () => {
670
- L.removeEventListener("mousedown", x), L.removeEventListener("touchstart", x);
893
+ return m.addEventListener("mousedown", L, { passive: !1 }), m.addEventListener("touchstart", L, { passive: !1 }), () => {
894
+ m.removeEventListener("mousedown", L), m.removeEventListener("touchstart", L);
671
895
  };
672
- }, [e, p, a, d, n, m, g, r, H, F, T, f, i, s, v, y, Q, S]), _(() => {
673
- const L = p.current;
674
- if (L)
675
- return l ? (P(L, (x) => {
676
- if (n.type === "selection" && d?.type === "text") {
677
- const M = lt(x, p.current, H, F, T);
678
- mt(d, M, m, Q) && y({ mode: "textedition", defaultValue: d.value });
896
+ }, [e, u, n, d, l, b, x, s, S, T, M, w, i, o, v, A, C, Z, y, E]), Y(() => {
897
+ const m = u.current;
898
+ if (m)
899
+ return p ? (Q(m, (V) => {
900
+ if (l.type === "selection" && d?.type === "text") {
901
+ const L = Zt(V, u.current, S, T, M);
902
+ ot(d, L, b, Z, M) && A({ mode: "textedition", defaultValue: d.value });
679
903
  }
680
904
  }), () => {
681
- w(L);
905
+ k(m);
682
906
  }) : void 0;
683
- }, [P, w, l, p, n, d, H, F, T, m, y, Q]), { hoverMode: E };
684
- }, Pn = (e, i, t, a, s, r, o, n) => {
685
- const { width: l, height: c, scaleRatio: d } = t;
686
- e.clearRect(0, 0, l, c), Y1(e), a && ((p, h, v, g, f, S) => {
687
- p.strokeStyle = "rgb(220,220,220)", p.lineWidth = 1, p.save(), p.scale(g, g), p.beginPath();
688
- const m = Ne[S - 1], C = -f[0] % m, y = -f[1] % m, Q = Math.ceil(h / g / m), k = Math.ceil(v / g / m);
689
- for (let H = 0; H < Q; H++)
690
- p.moveTo(C + (H + 1) * m, y), p.lineTo(C + (H + 1) * m, y + v / g);
691
- for (let H = 0; H < k; H++)
692
- p.moveTo(C, y + (H + 1) * m), p.lineTo(C + h / g, y + (H + 1) * m);
693
- p.stroke(), p.restore();
694
- })(e, l, c, d, s, a);
695
- for (let p = r.length - 1; p >= 0; p--)
696
- i.mode === "textedition" && r[p] === n || fi(e, r[p], d, s, o);
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")
907
+ }, [Q, k, p, u, l, d, S, T, M, b, A, Z]), { hoverMode: B };
908
+ }, Za = /(<([^>]+)>)/gi, Pa = /<(\/)?div(\/?\s?)>/gi, Fa = (e) => {
909
+ const i = ((t) => {
910
+ const n = document.createElement("textarea");
911
+ return n.innerHTML = t, n.value;
912
+ })(e).split("<div>").flatMap((t) => {
913
+ const n = t.replaceAll(Pa, "");
914
+ return n === "" ? void 0 : n.replaceAll(Za, "");
915
+ });
916
+ return yt(i);
917
+ }, Na = ({ disabled: e = !1, scaleRatio: i, shape: t, defaultValue: n, updateValue: o, saveShapes: r, selectionPadding: s }) => {
918
+ const a = ee(null), l = ee(r);
919
+ Y(() => {
920
+ if (!a.current)
702
921
  return;
703
- const M = E.current?.getContext("2d");
704
- if (!M)
922
+ const c = a.current, d = (u) => {
923
+ u.preventDefault();
924
+ const f = u.clipboardData?.getData("text/plain");
925
+ document.execCommand("insertText", !1, f);
926
+ };
927
+ return c.addEventListener("paste", d), c.innerHTML = n.map((u) => `<div>${u === "" ? "<br/>" : u}</div>`).join(""), c.focus(), () => {
928
+ c.removeEventListener("paste", d);
929
+ };
930
+ }, [n]), Y(() => {
931
+ const c = l.current;
932
+ return () => {
933
+ c();
934
+ };
935
+ }, []);
936
+ const p = zi(() => {
937
+ const { borders: c, center: d } = G(t, s);
938
+ return fe({ point: [c.x, c.y], rotation: -t.rotation, origin: d });
939
+ }, [t, s]);
940
+ return h("div", { className: "react-paint-editor-toolbox-edittextbox", ref: a, "data-fontbold": t.style?.fontBold ?? !1, "data-fontitalic": t.style?.fontItalic ?? !1, contentEditable: !e, onInput: (c) => {
941
+ o(Fa(c.target.innerHTML));
942
+ }, style: { "--react-paint-editor-toolbox-edittextbox-transform": `translate3D(${p[0] * i}px, ${p[1] * i}px, 0) rotate(${Dt(t.rotation)}deg)`, "--react-paint-editor-toolbox-edittextbox-fontsize": t.fontSize * i + "px", "--react-paint-editor-toolbox-edittextbox-padding": s * i + "px", "--react-paint-editor-toolbox-edittextbox-color": t.style?.strokeColor ?? "inherit", "--react-paint-editor-toolbox-edittextbox-opacity": (t.style?.opacity ?? 100) / 100, "--react-paint-editor-toolbox-edittextbox-fontfamily": t.style?.fontFamily ?? rt } });
943
+ }, Da = (e, i, t, n, o, r, s, a) => {
944
+ const { width: l, height: p, scaleRatio: c } = t;
945
+ e.clearRect(0, 0, l, p), li(e), n && ((d, u, f, g, v, C) => {
946
+ d.strokeStyle = "rgb(220,220,220)", d.lineWidth = 1, d.save(), d.scale(g, g), d.beginPath();
947
+ const x = Oe[C - 1], w = -v[0] % x, y = -v[1] % x, b = Math.ceil(u / g / x), H = Math.ceil(f / g / x);
948
+ for (let A = 0; A < b; A++)
949
+ d.moveTo(w + (A + 1) * x, y), d.lineTo(w + (A + 1) * x, y + f / g);
950
+ for (let A = 0; A < H; A++)
951
+ d.moveTo(w, y + (A + 1) * x), d.lineTo(w + u / g, y + (A + 1) * x);
952
+ d.stroke(), d.restore();
953
+ })(e, l, p, c, o, n);
954
+ for (let d = r.length - 1; d >= 0; d--)
955
+ i.mode === "textedition" && r[d] === a || mi(e, r[d], c, o, s);
956
+ }, Ea = W1.forwardRef(({ gridFormat: e, canGrow: i, disabled: t = !1, canvasSize: n, shapes: o, addShape: r, updateSingleShape: s, selectedShape: a, setSelectedShape: l, setSelectionFrame: p, hoveredShape: c, selectionFrame: d, refreshHoveredShape: u, refreshSelectedShapes: f, saveShapes: g, activeTool: v, setActiveTool: C, canvasOffsetStartPosition: x, setCanvasOffsetStartPosition: w, canvasOffset: y, setCanvasOffset: b, isInsideComponent: H, selectionMode: A, setSelectionMode: Z, selectionWidth: F, selectionColor: E, selectionPadding: S, isEditMode: T, isShiftPressed: M, withFrameSelection: B, withSkeleton: N }, Q) => {
957
+ const k = ee(null), m = ee(null);
958
+ Ui(Q, () => k.current);
959
+ const { hoverMode: V } = Ta({ disabled: t, addShape: r, canvasSize: n, drawCanvasRef: k, setActiveTool: C, shapes: o, selectionMode: A, activeTool: v, isInsideComponent: H, setCanvasOffset: b, selectedShape: a, selectionCanvasRef: m, canvasOffsetStartPosition: x, setSelectedShape: l, setSelectionFrame: p, refreshHoveredShape: u, refreshSelectedShapes: f, setCanvasOffsetStartPosition: w, updateSingleShape: s, gridFormat: e, canvasOffset: y, saveShapes: g, setSelectionMode: Z, selectionPadding: S, isShiftPressed: M, withFrameSelection: B }), { scaleRatio: L } = n, $ = U((W) => {
960
+ if (a?.type !== "text")
961
+ return;
962
+ const _ = k.current?.getContext("2d");
963
+ if (!_)
705
964
  return;
706
- const N = Je(mn(M, n, x, k, g), w, k);
707
- o(N);
708
- }, [o, n, g, w, k]);
709
- return _(() => {
710
- const x = E.current?.getContext("2d");
711
- x && window.requestAnimationFrame(() => Pn(x, m, a, e, g, s, k, n));
712
- }, [s, e, m, n, g, a, k]), _(() => {
713
- const x = b.current?.getContext("2d");
714
- x && window.requestAnimationFrame(() => ((M, N, Z, I, Y, ce, he, q, ye) => {
715
- const { width: Ae, height: be, scaleRatio: ke } = Z;
716
- M.clearRect(0, 0, Ae, be), ye && I.type !== "brush" && Hn({ ctx: M, shape: ye, currentScale: ke, canvasOffset: Y, selectionPadding: ce, selectionWidth: he, selectionColor: q, withAnchors: N.mode !== "textedition" });
717
- })(x, m, a, d, g, k, y, Q, n));
718
- }, [m, n, d, g, a, k, y, Q]), u("div", { className: "react-paint-editor-canvas-box", children: D("div", { className: "react-paint-editor-canvas-container", "data-grow": i, children: [u("canvas", { className: "react-paint-editor-canvas-drawcanvas", ref: E, "data-grow": i, width: a.width, height: a.height }), H && u("canvas", { className: "react-paint-editor-canvas-selectioncanvas", ref: b, width: a.width, height: a.height, "data-grow": i, style: { "--react-paint-editor-canvas-cursor": d.type !== "selection" && d.type !== "move" || P.mode === "resize" ? "crosshair" : d.type === "move" || P.mode === "translate" ? "move" : P.mode === "rotate" ? "grab" : "default" } }), H && m.mode === "textedition" && n?.type === "text" && u(Tn, { scaleRatio: a.scaleRatio, disabled: t, shape: n, defaultValue: m.defaultValue, updateValue: L, saveShapes: c, selectionPadding: k })] }) });
719
- }), Dn = (e) => {
965
+ const O = st(ha(_, a, W, S, y), L, S);
966
+ s(O);
967
+ }, [s, a, y, L, S]);
968
+ return Y(() => {
969
+ const W = k.current?.getContext("2d");
970
+ W && window.requestAnimationFrame(() => Da(W, A, n, e, y, o, S, a));
971
+ }, [o, e, A, a, y, n, S]), Y(() => {
972
+ const W = m.current?.getContext("2d");
973
+ W && window.requestAnimationFrame(() => ((_, O, P, ne, oe, se, le, de, q, ue, we, Se) => {
974
+ const { width: Me, height: Ae, scaleRatio: ve } = P;
975
+ _.clearRect(0, 0, Me, Ae), Se && ue && ue.id !== q?.id && ne.type === "selection" && O.mode === "default" && M1({ ctx: _, shape: ue, currentScale: ve, canvasOffset: oe, selectionPadding: se, selectionWidth: le, selectionColor: de, withAnchors: !1 }), q && ne.type !== "brush" && M1({ ctx: _, shape: q, currentScale: ve, canvasOffset: oe, selectionPadding: se, selectionWidth: le, selectionColor: de, withAnchors: O.mode !== "textedition" }), we && ma({ ctx: _, selectionFrame: we, currentScale: ve, canvasOffset: oe });
976
+ })(W, A, n, v, y, S, F, E, a, c, d, N));
977
+ }, [c, d, A, a, v, y, n, S, F, E, N]), h("div", { className: "react-paint-editor-canvas-box", children: I("div", { className: "react-paint-editor-canvas-container", "data-grow": i, children: [h("canvas", { className: oi, ref: k, "data-grow": i, width: n.width, height: n.height }), T && h("canvas", { className: si, ref: m, width: n.width, height: n.height, "data-grow": i, style: { "--react-paint-editor-canvas-cursor": v.type !== "selection" && v.type !== "move" || V.mode === "resize" ? "crosshair" : v.type === "move" || V.mode === "translate" ? "move" : V.mode === "rotate" ? "grab" : "default" } }), T && A.mode === "textedition" && a?.type === "text" && h(Na, { scaleRatio: n.scaleRatio, disabled: t, shape: a, defaultValue: A.defaultValue, updateValue: $, saveShapes: g, selectionPadding: S })] }) });
978
+ }), Ia = ({ type: e, text: i, duration: t }) => {
979
+ const [n, o] = R(!1);
980
+ return Y(() => {
981
+ const r = setTimeout(() => {
982
+ o(!0);
983
+ }, 100), s = setTimeout(() => {
984
+ o(!1);
985
+ }, t - 500 - 100);
986
+ return () => {
987
+ clearTimeout(r), clearTimeout(s);
988
+ };
989
+ }, [t]), h("div", { className: "react-paint-editor-snackbar", "data-is-shown": +n, "data-type": e, style: { "--react-paint-editor-panel-transition-duration": "500ms" }, children: i });
990
+ }, Wa = ({ snackbarList: e }) => h("div", { className: "react-paint-editor-snackbar-container", style: { "--react-paint-editor-snackbar-zindex": Rt }, children: e.map((i) => h(Ia, { ...i }, i.id)) }), j = W1.forwardRef((e, i) => {
991
+ if (e.type === "file" || e.type === "color") {
992
+ const { hidden: c = !1, disabled: d = !1, selected: u = !1, icon: f, children: g, className: v = "", title: C, onClick: x, ...w } = e;
993
+ return I("label", { className: `react-paint-editor-button ${v}`, title: C, onClick: x, "data-disabled": +d, "data-selected": +u, "data-hidden": +c, children: [h("input", { ref: i, disabled: d, ...w }), I("span", { className: "react-paint-editor-button-content", children: [g && h("span", { className: "react-paint-editor-button-children", children: g }), f && h("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: f } })] })] });
994
+ }
995
+ const { hidden: t = !1, disabled: n = !1, selected: o = !1, icon: r, children: s, type: a = "button", className: l = "", ...p } = e;
996
+ return h("button", { className: `react-paint-editor-button ${l}`, ref: i, disabled: n, "data-disabled": +n, "data-selected": +o, "data-hidden": +t, type: a, ...p, children: I("span", { className: "react-paint-editor-button-content", children: [s && h("span", { className: "react-paint-editor-button-children", children: s }), r && h("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: r } })] }) });
997
+ }), it = ({ children: e, title: i = "", className: t = "", position: n = "bottom", fitContainer: o = !1, alignment: r = "center" }) => I("div", { className: `react-paint-editor-panel ${t}`, "data-fitcontainer": o, "data-position": n, "data-alignment": r, style: { "--react-paint-editor-panel-zindex": Rt }, children: [i && h("h3", { className: "react-paint-editor-panel-title", children: i }), e] }), Ra = (e) => {
720
998
  switch (e) {
721
999
  case "brush":
722
- return ii;
1000
+ return B1;
723
1001
  case "line":
724
- return oi;
1002
+ return _1;
725
1003
  case "polygon":
726
- return Gt;
1004
+ return zt;
727
1005
  case "curve":
728
- return si;
1006
+ return j1;
729
1007
  case "rect":
730
1008
  case "square":
731
- return Xt;
1009
+ return $t;
732
1010
  case "circle":
733
1011
  case "ellipse":
734
- return qt;
1012
+ return Ot;
735
1013
  case "text":
736
- return ai;
1014
+ return Y1;
737
1015
  case "picture":
738
- return Jt;
1016
+ return Ut;
739
1017
  case "triangle":
740
1018
  return "";
741
1019
  }
742
- }, j = $1.forwardRef((e, i) => {
743
- if (e.type === "file" || e.type === "color") {
744
- const { hidden: t = !1, disabled: a = !1, selected: s = !1, icon: r, children: o, className: n = "", title: l, onClick: c, ...d } = e;
745
- return D("label", { className: `react-paint-editor-button ${n}`, title: l, onClick: c, "data-disabled": +a, "data-selected": +s, "data-hidden": +t, children: [u("input", { ref: i, disabled: a, ...d }), D("span", { className: "react-paint-editor-button-content", children: [o && u("span", { className: "react-paint-editor-button-children", children: o }), r && u("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: r } })] })] });
746
- }
747
- {
748
- const { hidden: t = !1, disabled: a = !1, selected: s = !1, icon: r, children: o, type: n = "button", className: l = "", ...c } = e;
749
- return u("button", { className: `react-paint-editor-button ${l}`, ref: i, disabled: a, "data-disabled": +a, "data-selected": +s, "data-hidden": +t, type: n, ...c, children: D("span", { className: "react-paint-editor-button-content", children: [o && u("span", { className: "react-paint-editor-button-children", children: o }), r && u("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: r } })] }) });
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)
1020
+ }, $a = ({ disabled: e = !1, shape: i, selected: t, layoutDragging: n, toggleShapeVisibility: o, toggleShapeLock: r, setLayoutDragging: s, handleRemove: a, handleSelect: l, onMoveShapes: p }) => {
1021
+ const c = ee(null), { isOver: d } = (({ disabled: u = !1, ref: f, shape: g, layoutDragging: v, setLayoutDragging: C, handleSelect: x, onMoveShapes: w }) => {
1022
+ const [y, b] = R(!1);
1023
+ return Y(() => {
1024
+ v || b(!1);
1025
+ }, [v]), Y(() => {
1026
+ const H = f.current;
1027
+ if (!H)
759
1028
  return;
760
- const H = () => {
761
- S(void 0);
762
- }, F = (w) => (w.preventDefault && w.preventDefault(), !1), T = (w) => {
763
- m(g), w.dataTransfer && (w.dataTransfer.effectAllowed = "move", w.dataTransfer.setData("draggableShapeId", g.id), S(g.id));
1029
+ const A = () => {
1030
+ C(void 0);
1031
+ }, Z = (M) => (M.preventDefault && M.preventDefault(), !1), F = (M) => {
1032
+ x(g), M.dataTransfer && (M.dataTransfer.effectAllowed = "move", M.dataTransfer.setData("draggableShapeId", g.id), C(g.id));
764
1033
  }, E = () => {
765
- f !== g.id && Q(!0);
766
- }, b = () => {
767
- Q(!1);
768
- }, P = (w) => (w.stopPropagation(), w.dataTransfer && C(w.dataTransfer.getData("draggableShapeId"), g.id), !1);
769
- return h || (k.addEventListener("dragstart", T), k.addEventListener("dragend", H), k.addEventListener("dragover", F), k.addEventListener("dragenter", E), k.addEventListener("dragleave", b), k.addEventListener("drop", P)), () => {
770
- h || (k.removeEventListener("dragstart", T), k.removeEventListener("dragend", H), k.removeEventListener("dragover", F), k.removeEventListener("dragenter", E), k.removeEventListener("dragleave", b), k.removeEventListener("drop", P));
1034
+ v !== g.id && b(!0);
1035
+ }, S = () => {
1036
+ b(!1);
1037
+ }, T = (M) => (M.stopPropagation(), M.dataTransfer && w(M.dataTransfer.getData("draggableShapeId"), g.id), !1);
1038
+ return u || (H.addEventListener("dragstart", F), H.addEventListener("dragend", A), H.addEventListener("dragover", Z), H.addEventListener("dragenter", E), H.addEventListener("dragleave", S), H.addEventListener("drop", T)), () => {
1039
+ u || (H.removeEventListener("dragstart", F), H.removeEventListener("dragend", A), H.removeEventListener("dragover", Z), H.removeEventListener("dragenter", E), H.removeEventListener("dragleave", S), H.removeEventListener("drop", T));
771
1040
  };
772
- }, [h, v, g, S, m, C, f]), { isOver: y };
773
- })({ disabled: e, ref: d, shape: i, layoutDragging: a, setLayoutDragging: o, handleSelect: l, onMoveShapes: c });
774
- return D("div", { className: "react-paint-editor-layout", "data-disabled": +e, draggable: !e, "data-is-dragging": +(a === i.id), "data-is-over": +p, onClick: (h) => {
775
- e || (h.preventDefault(), h.stopPropagation(), l(i));
776
- }, "data-selected": +t, ref: d, children: [u("span", { dangerouslySetInnerHTML: { __html: Dn(i.type) } }), u("span", { children: i.id }), u("div", { className: "react-paint-editor-layouts-separator" }), u(j, { className: "react-paint-editor-layouts-visible-button", title: i.visible ? "Hide" : "Show", "data-visible": i.visible !== !1, disabled: e, selected: t, onClick: (h) => {
777
- e || (h.preventDefault(), h.stopPropagation(), s(i));
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(j, { className: "react-paint-editor-layouts-locked-button", title: i.locked ? "Locked" : "Unlocked", "data-locked": !!i.locked, disabled: e, selected: t, onClick: (h) => {
779
- e || (h.preventDefault(), h.stopPropagation(), r(i));
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(j, { className: "react-paint-editor-layouts-remove-button", title: "Remove", disabled: e, onClick: (h) => {
781
- e || (h.preventDefault(), h.stopPropagation(), n(i));
782
- }, icon: ni })] });
783
- }, In = ({ gridFormat: e, setGridFormat: i, disabled: t = !1, shapes: a, removeShape: s, toggleShapeVisibility: r, toggleShapeLock: o, selectedShape: n, moveShapes: l, selectShape: c, isLayoutPanelShown: d }) => {
784
- const [p, h] = O(void 0);
785
- return d ? u(Ye, { alignment: "right", className: "react-paint-editor-layouts-panel", children: u("div", { className: "react-paint-editor-layouts-panel-content", children: D("div", { className: "react-paint-editor-layouts-scrolling-content", children: [D("div", { className: "react-paint-editor-layouts-row", children: [u("span", { className: "react-paint-editor-layouts-subtitle", children: "Grid" }), u(j, { icon: '<svg><path d="M18.333 15.854 16.583 14.104V13.354H15.833L14.083 11.604H16.583V8.375H13.375V10.896L11.625 9.146V8.375H10.875L9.125 6.625H11.625V3.417H8.396V5.896L6.646 4.146V3.417H5.896L4.146 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417ZM13.375 6.625H16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H13.375ZM16.771 19.229 15.854 18.333H3.417Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V4.125L0.812 3.271L2.042 2.021L18 18ZM13.375 16.583H14.104L13.375 15.833ZM8.396 11.604H9.125L8.396 10.854ZM8.396 16.583H11.625V14.083L10.875 13.354H8.396ZM3.417 6.625H4.167L3.417 5.875ZM3.417 11.604H6.646V9.104L5.917 8.375H3.417ZM6.646 16.583V13.354H3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Z"/></svg>', className: "react-paint-editor-layouts-grid-button", selected: e === 0, disabled: t, onClick: () => i(0) }), ["S", "M", "L"].map((v, g) => u(j, { className: "react-paint-editor-layouts-grid-button", selected: e === g + 1, disabled: t, onClick: () => i(g + 1), children: v }, v))] }), 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((v) => u(Nn, { shape: v, disabled: t, layoutDragging: p, setLayoutDragging: h, selected: n?.id === v.id, handleSelect: c, handleRemove: s, onMoveShapes: l, toggleShapeVisibility: r, toggleShapeLock: o }, v.id)) })] }) }) }) : null;
786
- }, V1 = (e, i = !1) => {
787
- const t = (s, r) => {
788
- if (Array.isArray(s))
789
- return r;
790
- }, a = e.map((s) => {
791
- if (typeof s != "object")
792
- return null;
793
- switch (s.type) {
794
- case "brush":
795
- return Qe(t, ri, s);
796
- case "circle":
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: () => {
1041
+ }, [u, f, g, C, x, w, v]), { isOver: y };
1042
+ })({ disabled: e, ref: c, shape: i, layoutDragging: n, setLayoutDragging: s, handleSelect: l, onMoveShapes: p });
1043
+ return I("div", { className: "react-paint-editor-layout", "data-disabled": +e, draggable: !e, "data-is-dragging": +(n === i.id), "data-is-over": +d, onClick: (u) => {
1044
+ e || (u.preventDefault(), u.stopPropagation(), l(i));
1045
+ }, "data-selected": +t, ref: c, children: [h("span", { dangerouslySetInnerHTML: { __html: Ra(i.type) } }), h("span", { children: i.id }), h("div", { className: "react-paint-editor-layouts-separator" }), h(j, { className: "react-paint-editor-layouts-visible-button", title: i.visible ? "Hide" : "Show", "data-visible": i.visible !== !1, disabled: e, selected: t, onClick: (u) => {
1046
+ e || (u.preventDefault(), u.stopPropagation(), o(i));
1047
+ }, icon: i.visible === !1 ? '<svg><path d="M13.521 11.021 12.25 9.75Q12.333 8.75 11.604 7.979Q10.875 7.208 9.812 7.312L8.542 6.042Q8.896 5.896 9.26 5.833Q9.625 5.771 10 5.771Q11.583 5.771 12.688 6.875Q13.792 7.979 13.792 9.562Q13.792 9.979 13.719 10.354Q13.646 10.729 13.521 11.021ZM16.167 13.646 14.917 12.417Q15.667 11.833 16.25 11.146Q16.833 10.458 17.25 9.562Q16.229 7.479 14.292 6.281Q12.354 5.083 10 5.083Q9.396 5.083 8.885 5.156Q8.375 5.229 7.875 5.375L6.5 4Q7.354 3.646 8.208 3.49Q9.062 3.333 10 3.333Q13.146 3.333 15.615 5.052Q18.083 6.771 19.167 9.562Q18.688 10.792 17.917 11.823Q17.146 12.854 16.167 13.646ZM16.396 18.854 12.938 15.396Q12.208 15.625 11.479 15.729Q10.75 15.833 10 15.833Q6.833 15.833 4.375 14.094Q1.917 12.354 0.833 9.562Q1.25 8.479 1.917 7.552Q2.583 6.625 3.417 5.875L1.125 3.562L2.375 2.354L17.625 17.625ZM4.604 7.062Q4.021 7.604 3.542 8.219Q3.062 8.833 2.729 9.562Q3.75 11.646 5.688 12.865Q7.625 14.083 10 14.083Q10.354 14.083 10.74 14.052Q11.125 14.021 11.479 13.938L10.812 13.271Q10.625 13.312 10.417 13.333Q10.208 13.354 10 13.354Q8.417 13.354 7.312 12.25Q6.208 11.146 6.208 9.562Q6.208 9.354 6.24 9.167Q6.271 8.979 6.312 8.771ZM11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875ZM8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Z"/></svg>' : '<svg><path d="M10 13.354Q11.583 13.354 12.688 12.25Q13.792 11.146 13.792 9.562Q13.792 7.979 12.688 6.875Q11.583 5.771 10 5.771Q8.417 5.771 7.312 6.875Q6.208 7.979 6.208 9.562Q6.208 11.146 7.312 12.25Q8.417 13.354 10 13.354ZM10 11.812Q9.062 11.812 8.406 11.156Q7.75 10.5 7.75 9.562Q7.75 8.625 8.406 7.969Q9.062 7.312 10 7.312Q10.938 7.312 11.594 7.969Q12.25 8.625 12.25 9.562Q12.25 10.5 11.594 11.156Q10.938 11.812 10 11.812ZM10 15.833Q6.938 15.833 4.448 14.125Q1.958 12.417 0.833 9.562Q1.958 6.708 4.458 5.021Q6.958 3.333 10 3.333Q13.042 3.333 15.542 5.021Q18.042 6.708 19.167 9.562Q18.042 12.417 15.552 14.125Q13.062 15.833 10 15.833ZM10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562ZM10 14.083Q12.333 14.083 14.281 12.865Q16.229 11.646 17.25 9.562Q16.229 7.479 14.281 6.281Q12.333 5.083 10 5.083Q7.667 5.083 5.708 6.281Q3.75 7.479 2.729 9.562Q3.75 11.646 5.708 12.865Q7.667 14.083 10 14.083Z"/></svg>' }), h(j, { className: "react-paint-editor-layouts-locked-button", title: i.locked ? "Locked" : "Unlocked", "data-locked": !!i.locked, disabled: e, selected: t, onClick: (u) => {
1048
+ e || (u.preventDefault(), u.stopPropagation(), r(i));
1049
+ }, icon: i.locked ? '<svg><path d="M10 0.833Q11.771 0.833 12.99 2.052Q14.208 3.271 14.208 5.042V6.667H14.917Q15.646 6.667 16.156 7.177Q16.667 7.688 16.667 8.417V16.562Q16.667 17.292 16.156 17.812Q15.646 18.333 14.917 18.333H5.083Q4.354 18.333 3.844 17.812Q3.333 17.292 3.333 16.562V8.417Q3.333 7.688 3.844 7.177Q4.354 6.667 5.083 6.667H5.792V5.042Q5.792 3.271 7.01 2.052Q8.229 0.833 10 0.833ZM10 2.583Q8.979 2.583 8.26 3.302Q7.542 4.021 7.542 5.042V6.667H12.458V5.042Q12.458 4.021 11.74 3.302Q11.021 2.583 10 2.583ZM5.083 16.583H14.917Q14.917 16.583 14.917 16.583Q14.917 16.583 14.917 16.583V8.417Q14.917 8.417 14.917 8.417Q14.917 8.417 14.917 8.417H5.083Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583ZM10 10.812Q9.292 10.812 8.802 11.302Q8.312 11.792 8.312 12.5Q8.312 13.208 8.802 13.698Q9.292 14.188 10 14.188Q10.708 14.188 11.198 13.698Q11.688 13.208 11.688 12.5Q11.688 11.792 11.198 11.302Q10.708 10.812 10 10.812ZM5.083 8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583V8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417Z"/></svg>' : '<svg><path d="M5.792 5.042Q5.792 3.271 7.01 2.052Q8.229 0.833 10 0.833Q11.771 0.833 12.99 2.052Q14.208 3.271 14.208 5.042V6.667H14.917Q15.646 6.667 16.156 7.177Q16.667 7.688 16.667 8.417V16.562Q16.667 17.292 16.156 17.812Q15.646 18.333 14.917 18.333H5.083Q4.354 18.333 3.844 17.812Q3.333 17.292 3.333 16.562V8.417Q3.333 7.688 3.844 7.177Q4.354 6.667 5.083 6.667H12.458V5.042Q12.458 4.021 11.74 3.302Q11.021 2.583 10 2.583Q8.979 2.583 8.26 3.302Q7.542 4.021 7.542 5.042ZM5.083 16.583H14.917Q14.917 16.583 14.917 16.583Q14.917 16.583 14.917 16.583V8.417Q14.917 8.417 14.917 8.417Q14.917 8.417 14.917 8.417H5.083Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583ZM10 10.812Q9.292 10.812 8.802 11.302Q8.312 11.792 8.312 12.5Q8.312 13.208 8.802 13.698Q9.292 14.188 10 14.188Q10.708 14.188 11.198 13.698Q11.688 13.208 11.688 12.5Q11.688 11.792 11.198 11.302Q10.708 10.812 10 10.812ZM5.083 8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583V8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417Z"/></svg>' }), h(j, { className: "react-paint-editor-layouts-remove-button", title: "Remove", disabled: e, onClick: (u) => {
1050
+ e || (u.preventDefault(), u.stopPropagation(), a(i));
1051
+ }, icon: X1 })] });
1052
+ }, Oa = ({ gridFormat: e, setGridFormat: i, disabled: t = !1, shapes: n, removeShape: o, toggleShapeVisibility: r, toggleShapeLock: s, selectedShape: a, moveShapes: l, selectShape: p, isLayoutPanelShown: c }) => {
1053
+ const [d, u] = R(void 0);
1054
+ return c ? h(it, { alignment: "right", className: "react-paint-editor-layouts-panel", children: h("div", { className: "react-paint-editor-layouts-panel-content", children: I("div", { className: "react-paint-editor-layouts-scrolling-content", children: [I("div", { className: "react-paint-editor-layouts-row", children: [h("span", { className: "react-paint-editor-layouts-subtitle", children: "Grid" }), h(j, { icon: '<svg><path d="M18.333 15.854 16.583 14.104V13.354H15.833L14.083 11.604H16.583V8.375H13.375V10.896L11.625 9.146V8.375H10.875L9.125 6.625H11.625V3.417H8.396V5.896L6.646 4.146V3.417H5.896L4.146 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417ZM13.375 6.625H16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H13.375ZM16.771 19.229 15.854 18.333H3.417Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V4.125L0.812 3.271L2.042 2.021L18 18ZM13.375 16.583H14.104L13.375 15.833ZM8.396 11.604H9.125L8.396 10.854ZM8.396 16.583H11.625V14.083L10.875 13.354H8.396ZM3.417 6.625H4.167L3.417 5.875ZM3.417 11.604H6.646V9.104L5.917 8.375H3.417ZM6.646 16.583V13.354H3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Z"/></svg>', className: "react-paint-editor-layouts-grid-button", selected: e === 0, disabled: t, onClick: () => i(0) }), ["S", "M", "L"].map((f, g) => h(j, { className: "react-paint-editor-layouts-grid-button", selected: e === g + 1, disabled: t, onClick: () => i(g + 1), children: f }, f))] }), h("hr", {}), h("div", { className: "react-paint-editor-layouts", children: n.length === 0 ? h("div", { className: "react-paint-editor-layouts-placeholder", children: "No layer yet" }) : n.map((f) => h($a, { shape: f, disabled: t, layoutDragging: d, setLayoutDragging: u, selected: a?.id === f.id, handleSelect: p, handleRemove: o, onMoveShapes: l, toggleShapeVisibility: r, toggleShapeLock: s }, f.id)) })] }) }) }) : null;
1055
+ }, jt = ({ children: e, onClose: i, position: t = "center", className: n = "" }) => I("div", { className: "react-paint-editor-modal", "data-position": t, style: { "--react-paint-editor-modal-zindex": Rt }, children: [h("div", { className: "react-paint-editor-modal-mask", onClick: i }), h("div", { className: `react-paint-editor-modal-panel ${n}`, children: e })] }), ct = ({ selectedSettings: e, setSelectedSettings: i, title: t = "Choisissez une couleur", mode: n = "fill", disabled: o = !1, values: r, field: s, value: a = "", valueChanged: l }) => {
1056
+ const [p] = R(ae("settings_")), c = e === p;
1057
+ return r.length ? I(pe, { children: [h(j, { selected: c, title: t, disabled: o, onClick: () => {
1058
+ i((d) => d === p ? void 0 : p);
1059
+ }, icon: a === "transparent" ? n === "fill" ? s1 : o1 : void 0, children: a !== "transparent" && h("div", { className: "react-paint-editor-colorfield-color", "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": a } }) }), c && h(it, { title: t, alignment: "left", children: I("div", { className: "react-paint-editor-colorfield-wrapper", children: [r.map((d, u) => h(j, { title: d, selected: d === a, color: d, icon: d === "transparent" ? n === "fill" ? s1 : o1 : void 0, onClick: () => {
1060
+ l(s, d);
1061
+ }, children: d !== "transparent" && h("div", { className: "react-paint-editor-colorfield-color", color: d, "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": d } }) }, d)), h(j, { type: "color", title: "Custom color", selected: !r.includes(a), value: a, onChange: (d) => {
1062
+ const u = +d.target.value;
1063
+ l(s, Number.isNaN(u) ? d.target.value : u);
1064
+ }, children: h("div", { className: "react-paint-editor-colorfield-customcolor", style: { "--react-paint-editor-colorfield-color-value": r.includes(a) ? "var(--react-paint-editor-app-font-color)" : a }, children: h("span", { dangerouslySetInnerHTML: { __html: '<svg><path d="M9.958 18.333Q8.25 18.333 6.74 17.677Q5.229 17.021 4.104 15.885Q2.979 14.75 2.323 13.229Q1.667 11.708 1.667 10Q1.667 8.271 2.333 6.75Q3 5.229 4.156 4.104Q5.312 2.979 6.854 2.323Q8.396 1.667 10.125 1.667Q11.771 1.667 13.26 2.25Q14.75 2.833 15.875 3.854Q17 4.875 17.667 6.26Q18.333 7.646 18.333 9.25Q18.333 11.688 16.792 12.948Q15.25 14.208 13.188 14.208H11.75Q11.625 14.208 11.562 14.281Q11.5 14.354 11.5 14.458Q11.5 14.688 11.812 15.219Q12.125 15.75 12.125 16.458Q12.125 17.458 11.51 17.896Q10.896 18.333 9.958 18.333ZM5.458 10.875Q6 10.875 6.375 10.5Q6.75 10.125 6.75 9.583Q6.75 9.042 6.375 8.667Q6 8.292 5.458 8.292Q4.917 8.292 4.542 8.667Q4.167 9.042 4.167 9.583Q4.167 10.125 4.542 10.5Q4.917 10.875 5.458 10.875ZM7.917 7.583Q8.458 7.583 8.833 7.208Q9.208 6.833 9.208 6.292Q9.208 5.75 8.833 5.375Q8.458 5 7.917 5Q7.375 5 7 5.375Q6.625 5.75 6.625 6.292Q6.625 6.833 7 7.208Q7.375 7.583 7.917 7.583ZM12.021 7.583Q12.562 7.583 12.938 7.208Q13.312 6.833 13.312 6.292Q13.312 5.75 12.938 5.375Q12.562 5 12.021 5Q11.479 5 11.104 5.375Q10.729 5.75 10.729 6.292Q10.729 6.833 11.104 7.208Q11.479 7.583 12.021 7.583ZM14.479 10.875Q15.021 10.875 15.396 10.5Q15.771 10.125 15.771 9.583Q15.771 9.042 15.396 8.667Q15.021 8.292 14.479 8.292Q13.938 8.292 13.562 8.667Q13.188 9.042 13.188 9.583Q13.188 10.125 13.562 10.5Q13.938 10.875 14.479 10.875Z"/></svg>' } }) }) })] }) })] }) : null;
1065
+ }, za = ({ disabled: e = !1, selectedShape: i, removeShape: t }) => h(j, { title: "Delete", disabled: e, "data-disabled": +e, onClick: () => {
912
1066
  t(i);
913
- }, icon: ni }), zn = ({ disabled: e, toggleLayoutPanel: i }) => u(j, { title: "Toggle layers panel", disabled: e, onClick: i, icon: '<svg><path d="M10 17.646 2.438 11.75 3.875 10.646 10 15.396 16.125 10.646 17.562 11.75ZM10 13.188 2.5 7.354 10 1.521 17.5 7.354Z"/></svg>', className: "react-paint-editor-layout-button" }), Ge = ({ selectedSettings: e, setSelectedSettings: i, title: t = "Choisissez l'intervalle", icon: a, disabled: s = !1, field: r, value: o = 1, min: n = 1, max: l = 20, step: c = 1, unity: d = "", valueChanged: p }) => {
914
- const h = Math.round(o), [v] = O(ae("settings_")), g = ne(null);
915
- _(() => () => {
1067
+ }, icon: X1 }), qt = ({ CustomOption: e, selectedSettings: i, setSelectedSettings: t, title: n = "Choisissez l'option", disabled: o = !1, field: r, icon: s, values: a, defaultValue: l, valueChanged: p }) => {
1068
+ const [c] = R(ae("settings_")), d = i === c;
1069
+ return a.length ? I(pe, { children: [h(j, { selected: d, title: n, icon: s, disabled: o, onClick: () => {
1070
+ t((u) => u === c ? void 0 : c);
1071
+ } }), d && h(it, { title: n, alignment: "left", fitContainer: !0, children: h("div", { className: "react-paint-editor-selectfield-wrapper", children: a.map((u) => h(j, { title: `${u}`, onClick: () => ((f) => {
1072
+ p(r, f);
1073
+ })(u), selected: l === u, style: { "--react-paint-editor-button-padding": "16px" }, children: h(e, { children: u }) }, u)) }) })] }) : null;
1074
+ }, Ua = ({ children: e }) => h("span", { className: "react-paint-editor-fontfamily-option", style: { "--react-paint-editor-fontfamily-family": e }, children: e }), F1 = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: n, defaultValue: o, valueChanged: r }) => n.length ? h(qt, { selectedSettings: e, setSelectedSettings: i, CustomOption: Ua, title: "Police", icon: '<svg><path d="M5.312 14.979H7.125L8.042 12.479H11.979L12.896 14.979H14.708L10.917 5H9.083ZM8.542 10.958 9.958 6.958H10.042L11.458 10.958ZM3.417 18.333Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V3.417Q1.667 2.688 2.177 2.177Q2.688 1.667 3.417 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417V16.583Q18.333 17.312 17.823 17.823Q17.312 18.333 16.583 18.333ZM3.417 16.583H16.583Q16.583 16.583 16.583 16.583Q16.583 16.583 16.583 16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583ZM3.417 3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583V3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417Z"/></svg>', disabled: t, field: "fontFamily", values: n, defaultValue: o, valueChanged: r }) : null, Ba = ({ disabled: e, toggleLayoutPanel: i }) => h(j, { title: "Toggle layers panel", disabled: e, onClick: i, icon: '<svg><path d="M10 17.646 2.438 11.75 3.875 10.646 10 15.396 16.125 10.646 17.562 11.75ZM10 13.188 2.5 7.354 10 1.521 17.5 7.354Z"/></svg>', className: "react-paint-editor-layout-button" }), Xa = ({ children: e }) => I("span", { className: "react-paint-editor-linearrow-option", "data-type": e, children: [h("span", { className: "react-paint-editor-linearrow-left" }), h("span", { className: "react-paint-editor-linearrow-right" })] }), N1 = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: n, defaultValue: o, valueChanged: r }) => n.length ? h(qt, { selectedSettings: e, setSelectedSettings: i, CustomOption: Xa, title: "Flèches", icon: '<svg><path d="M6 17 2 13 6 9 7.062 10.062 4.875 12.25H17V13.75H4.875L7.062 15.938ZM14 11 12.938 9.938 15.125 7.75H3V6.25H15.125L12.938 4.062L14 3L18 7Z"/></svg>', disabled: t, field: "lineArrow", values: n, defaultValue: o, valueChanged: r }) : null, Ya = ({ children: e }) => I("span", { className: "react-paint-editor-linetype-option", "data-type": e, children: [h("span", {}), h("span", {}), h("span", {}), h("span", {}), h("span", {}), h("span", {}), h("span", {})] }), D1 = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: n, defaultValue: o, valueChanged: r }) => n.length ? h(qt, { selectedSettings: e, setSelectedSettings: i, CustomOption: Ya, icon: '<svg><path d="M3 16V14.5H4.5V16ZM6.125 16V14.5H7.625V16ZM9.25 16V14.5H10.75V16ZM12.375 16V14.5H13.875V16ZM15.5 16V14.5H17V16ZM3 13V11.5H6.5V13ZM8.25 13V11.5H11.75V13ZM13.5 13V11.5H17V13ZM3 10V8.5H9.25V10ZM10.75 10V8.5H17V10ZM3 7V4H17V7Z"/></svg>', title: "Type de traits", disabled: t, field: "lineDash", values: n, defaultValue: o, valueChanged: r }) : null, nt = ({ selectedSettings: e, setSelectedSettings: i, title: t = "Choisissez l'intervalle", icon: n, disabled: o = !1, field: r, value: s = 1, min: a = 1, max: l = 20, step: p = 1, unity: c = "", valueChanged: d }) => {
1075
+ const u = Math.round(s), [f] = R(ae("settings_")), g = ee(null);
1076
+ Y(() => () => {
916
1077
  g.current && clearTimeout(g.current);
917
1078
  }, []);
918
- const f = e === v;
919
- return n === l ? null : D(de, { children: [u(j, { selected: f, title: t, disabled: s, icon: a, onClick: () => {
920
- i((S) => S === v ? void 0 : v);
921
- } }), f && u(Ye, { title: t, alignment: "left", fitContainer: !0, children: u("div", { children: D("label", { className: "react-paint-editor-rangefield", children: [u("input", { type: "range", min: n, max: l, step: c, value: o, onChange: (S) => {
922
- const m = +S.target.value;
923
- p(r, Number.isNaN(m) ? S.target.value : m, !1), g.current && clearTimeout(g.current), g.current = setTimeout(() => {
924
- p(r, Number.isNaN(m) ? S.target.value : m, !0);
1079
+ const v = e === f;
1080
+ return a === l ? null : I(pe, { children: [h(j, { selected: v, title: t, disabled: o, icon: n, onClick: () => {
1081
+ i((C) => C === f ? void 0 : f);
1082
+ } }), v && h(it, { title: t, alignment: "left", fitContainer: !0, children: h("div", { children: I("label", { className: "react-paint-editor-rangefield", children: [h("input", { type: "range", min: a, max: l, step: p, value: s, onChange: (C) => {
1083
+ const x = +C.target.value;
1084
+ d(r, Number.isNaN(x) ? C.target.value : x, !1), g.current && clearTimeout(g.current), g.current = setTimeout(() => {
1085
+ d(r, Number.isNaN(x) ? C.target.value : x, !0);
925
1086
  }, 1e3);
926
- } }), D("span", { children: [h, d] })] }) }) })] });
927
- }, i1 = ({ CustomOption: e, selectedSettings: i, setSelectedSettings: t, title: a = "Choisissez l'option", disabled: s = !1, field: r, icon: o, values: n, defaultValue: l, valueChanged: c }) => {
928
- const [d] = O(ae("settings_")), p = i === d;
929
- return n.length ? D(de, { children: [u(j, { selected: p, title: a, icon: o, disabled: s, onClick: () => {
930
- t((h) => h === d ? void 0 : d);
931
- } }), p && u(Ye, { title: a, alignment: "left", fitContainer: !0, children: u("div", { className: "react-paint-editor-selectfield-wrapper", children: n.map((h) => u(j, { title: `${h}`, onClick: () => ((v) => {
932
- c(r, v);
933
- })(h), selected: l == h, style: { "--react-paint-editor-button-padding": "16px" }, children: u(e, { children: h }) }, h)) }) })] }) : null;
934
- }, Bn = ({ children: e }) => u("span", { className: "react-paint-editor-fontfamily-option", style: { "--react-paint-editor-fontfamily-family": e }, children: e }), T1 = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: a, defaultValue: s, valueChanged: r }) => a.length ? u(i1, { selectedSettings: e, setSelectedSettings: i, CustomOption: Bn, 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: r }) : null, A1 = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, min: a, max: s, step: r, value: o, valueChanged: n }) => a === s ? null : u(Ge, { selectedSettings: e, setSelectedSettings: i, icon: Gt, title: "Nombre de points", disabled: t, field: "pointsCount", min: a, max: s, step: r, unity: "", value: o, valueChanged: n }), _n = ({ children: e }) => D("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", {})] }), Z1 = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: a, defaultValue: s, valueChanged: r }) => a.length ? u(i1, { selectedSettings: e, setSelectedSettings: i, CustomOption: _n, 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: r }) : null, Yn = ({ children: e }) => D("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" })] }), P1 = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: a, defaultValue: s, valueChanged: r }) => a.length ? u(i1, { selectedSettings: e, setSelectedSettings: i, CustomOption: Yn, 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: r }) : null, ct = ({ setSelectedSettings: e, disabled: i = !1, field: t, icon: a, values: s, value: r = !1, valueChanged: o }) => {
935
- const [n] = O(ae("settings_"));
936
- return s.length !== 2 ? null : u(j, { onClick: () => {
937
- e((l) => l === n ? void 0 : n), o(t, !r);
938
- }, selected: r, disabled: i, icon: a });
939
- }, Wt = ({ activeTool: e, selectedShape: i, selectedShapeTool: t, disabled: a, selectedSettings: s, setSelectedSettings: r, handleShapeStyleChange: o, handlePolygonLinesCount: n, handleShapeFontFamilyChange: l }) => i ? u(de, { children: t && D(de, { children: ["strokeColor" in t.settings && u(dt, { selectedSettings: s, setSelectedSettings: r, title: "Couleur du trait", mode: "stroke", disabled: a, field: "strokeColor", value: i.style?.strokeColor, valueChanged: o, values: t.settings.strokeColor.values }), "fillColor" in t.settings && u(dt, { selectedSettings: s, setSelectedSettings: r, title: "Couleur de fond", disabled: a, field: "fillColor", value: i.style?.fillColor, valueChanged: o, values: t.settings.fillColor.values }), "lineWidth" in t.settings && u(Ge, { selectedSettings: s, setSelectedSettings: r, title: "Epaisseur du trait", icon: S1, disabled: a, field: "lineWidth", value: i.style?.lineWidth, valueChanged: o, unity: "px", min: t.settings.lineWidth.min, max: t.settings.lineWidth.max, step: t.settings.lineWidth.step }), "lineDash" in t.settings && u(Z1, { selectedSettings: s, setSelectedSettings: r, disabled: a, defaultValue: i.style?.lineDash, valueChanged: o, values: t.settings.lineDash.values }), "lineArrow" in t.settings && u(P1, { selectedSettings: s, setSelectedSettings: r, disabled: a, defaultValue: i.style?.lineArrow, valueChanged: o, values: t.settings.lineArrow.values }), "pointsCount" in t.settings && u(A1, { selectedSettings: s, setSelectedSettings: r, disabled: a, valueChanged: n, min: t.settings.pointsCount.min, max: t.settings.pointsCount.max, step: t.settings.pointsCount.step, value: i.style?.pointsCount }), "fontFamily" in t.settings && u(T1, { selectedSettings: s, setSelectedSettings: r, disabled: a, valueChanged: l, values: t.settings.fontFamily.values, defaultValue: i.style?.fontFamily }), "fontBold" in t.settings && u(ct, { setSelectedSettings: r, disabled: a, field: "fontBold", icon: y1, valueChanged: l, values: t.settings.fontBold.values, value: i.style?.fontBold }), "fontItalic" in t.settings && u(ct, { setSelectedSettings: r, disabled: a, field: "fontItalic", icon: b1, valueChanged: l, values: t.settings.fontItalic.values, value: i.style?.fontItalic }), "opacity" in t.settings && u(Ge, { selectedSettings: s, setSelectedSettings: r, title: "Opacité", icon: Q1, min: t.settings.opacity.min, max: t.settings.opacity.max, step: t.settings.opacity.step, unity: "%", disabled: a, field: "opacity", value: i.style?.opacity ?? 100, valueChanged: o })] }) }) : "settings" in e ? D(de, { children: ["strokeColor" in e.settings && u(dt, { selectedSettings: s, setSelectedSettings: r, title: "Couleur du trait", mode: "stroke", disabled: a, field: "strokeColor", value: e.settings.strokeColor.default, valueChanged: o, values: e.settings.strokeColor.values }), "fillColor" in e.settings && u(dt, { selectedSettings: s, setSelectedSettings: r, title: "Couleur de fond", disabled: a, field: "fillColor", value: e.settings.fillColor.default, valueChanged: o, values: e.settings.fillColor.values }), "lineWidth" in e.settings && u(Ge, { selectedSettings: s, setSelectedSettings: r, title: "Epaisseur du trait", disabled: a, field: "lineWidth", icon: S1, value: e.settings.lineWidth.default, valueChanged: o, unity: "px", min: e.settings.lineWidth.min, max: e.settings.lineWidth.max, step: e.settings.lineWidth.step }), "lineDash" in e.settings && u(Z1, { selectedSettings: s, setSelectedSettings: r, disabled: a, defaultValue: e.settings.lineDash.default, valueChanged: o, values: e.settings.lineDash.values }), "lineArrow" in e.settings && u(P1, { selectedSettings: s, setSelectedSettings: r, disabled: a, defaultValue: e.settings.lineArrow.default, valueChanged: o, values: e.settings.lineArrow.values }), "pointsCount" in e.settings && u(A1, { selectedSettings: s, setSelectedSettings: r, disabled: a, valueChanged: n, 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(T1, { selectedSettings: s, setSelectedSettings: r, disabled: a, valueChanged: l, values: e.settings.fontFamily.values, defaultValue: e.settings.fontFamily.default }), "fontBold" in e.settings && u(ct, { setSelectedSettings: r, disabled: a, field: "fontBold", icon: y1, valueChanged: l, values: e.settings.fontBold.values, value: e.settings.fontBold.default }), "fontItalic" in e.settings && u(ct, { setSelectedSettings: r, disabled: a, field: "fontItalic", icon: b1, valueChanged: l, values: e.settings.fontItalic.values, value: e.settings.fontItalic.default }), "opacity" in e.settings && u(Ge, { selectedSettings: s, setSelectedSettings: r, title: "Opacité", icon: Q1, min: e.settings.opacity.min, max: e.settings.opacity.max, step: e.settings.opacity.step, unity: "%", disabled: a, field: "opacity", value: e.settings.opacity.default, valueChanged: o })] }) : null, jn = ({ width: e, disabled: i = !1, availableTools: t, updateToolSettings: a, layersManipulation: s, toggleLayoutPanel: r, activeTool: o, selectedShape: n, canvas: l, currentScale: c, selectionPadding: d, updateShape: p, removeShape: h }) => {
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")
1087
+ } }), I("span", { children: [u, c] })] }) }) })] });
1088
+ }, E1 = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, min: n, max: o, step: r, value: s, valueChanged: a }) => n === o ? null : h(nt, { selectedSettings: e, setSelectedSettings: i, icon: zt, title: "Nombre de points", disabled: t, field: "pointsCount", min: n, max: o, step: r, unity: "", value: s, valueChanged: a }), pt = ({ setSelectedSettings: e, disabled: i = !1, field: t, icon: n, values: o, value: r = !1, valueChanged: s }) => {
1089
+ const [a] = R(ae("settings_"));
1090
+ return o.length !== 2 ? null : h(j, { onClick: () => {
1091
+ e((l) => l === a ? void 0 : a), s(t, !r);
1092
+ }, selected: r, disabled: i, icon: n });
1093
+ }, Ft = ({ activeTool: e, selectedShape: i, selectedShapeTool: t, disabled: n, selectedSettings: o, setSelectedSettings: r, handleShapeStyleChange: s, handlePolygonLinesCount: a, handleShapeFontFamilyChange: l }) => i ? h(pe, { children: t && I(pe, { children: ["strokeColor" in t.settings && h(ct, { selectedSettings: o, setSelectedSettings: r, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: i.style?.strokeColor, valueChanged: s, values: t.settings.strokeColor.values }), "fillColor" in t.settings && h(ct, { selectedSettings: o, setSelectedSettings: r, title: "Couleur de fond", disabled: n, field: "fillColor", value: i.style?.fillColor, valueChanged: s, values: t.settings.fillColor.values }), "lineWidth" in t.settings && h(nt, { selectedSettings: o, setSelectedSettings: r, title: "Epaisseur du trait", icon: n1, disabled: n, field: "lineWidth", value: i.style?.lineWidth, valueChanged: s, unity: "px", min: t.settings.lineWidth.min, max: t.settings.lineWidth.max, step: t.settings.lineWidth.step }), "lineDash" in t.settings && h(D1, { selectedSettings: o, setSelectedSettings: r, disabled: n, defaultValue: i.style?.lineDash, valueChanged: s, values: t.settings.lineDash.values }), "lineArrow" in t.settings && h(N1, { selectedSettings: o, setSelectedSettings: r, disabled: n, defaultValue: i.style?.lineArrow, valueChanged: s, values: t.settings.lineArrow.values }), "pointsCount" in t.settings && h(E1, { selectedSettings: o, setSelectedSettings: r, disabled: n, valueChanged: a, min: t.settings.pointsCount.min, max: t.settings.pointsCount.max, step: t.settings.pointsCount.step, value: i.style?.pointsCount }), "fontFamily" in t.settings && h(F1, { selectedSettings: o, setSelectedSettings: r, disabled: n, valueChanged: l, values: t.settings.fontFamily.values, defaultValue: i.style?.fontFamily }), "fontBold" in t.settings && h(pt, { setSelectedSettings: r, disabled: n, field: "fontBold", icon: i1, valueChanged: l, values: t.settings.fontBold.values, value: i.style?.fontBold }), "fontItalic" in t.settings && h(pt, { setSelectedSettings: r, disabled: n, field: "fontItalic", icon: a1, valueChanged: l, values: t.settings.fontItalic.values, value: i.style?.fontItalic }), "opacity" in t.settings && h(nt, { selectedSettings: o, setSelectedSettings: r, title: "Opacité", icon: t1, min: t.settings.opacity.min, max: t.settings.opacity.max, step: t.settings.opacity.step, unity: "%", disabled: n, field: "opacity", value: i.style?.opacity ?? 100, valueChanged: s })] }) }) : "settings" in e ? I(pe, { children: ["strokeColor" in e.settings && h(ct, { selectedSettings: o, setSelectedSettings: r, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: e.settings.strokeColor.default, valueChanged: s, values: e.settings.strokeColor.values }), "fillColor" in e.settings && h(ct, { selectedSettings: o, setSelectedSettings: r, title: "Couleur de fond", disabled: n, field: "fillColor", value: e.settings.fillColor.default, valueChanged: s, values: e.settings.fillColor.values }), "lineWidth" in e.settings && h(nt, { selectedSettings: o, setSelectedSettings: r, title: "Epaisseur du trait", disabled: n, field: "lineWidth", icon: n1, value: e.settings.lineWidth.default, valueChanged: s, unity: "px", min: e.settings.lineWidth.min, max: e.settings.lineWidth.max, step: e.settings.lineWidth.step }), "lineDash" in e.settings && h(D1, { selectedSettings: o, setSelectedSettings: r, disabled: n, defaultValue: e.settings.lineDash.default, valueChanged: s, values: e.settings.lineDash.values }), "lineArrow" in e.settings && h(N1, { selectedSettings: o, setSelectedSettings: r, disabled: n, defaultValue: e.settings.lineArrow.default, valueChanged: s, values: e.settings.lineArrow.values }), "pointsCount" in e.settings && h(E1, { selectedSettings: o, setSelectedSettings: r, disabled: n, valueChanged: a, min: e.settings.pointsCount.min, max: e.settings.pointsCount.max, step: e.settings.pointsCount.step, value: e.settings.pointsCount.default }), "fontFamily" in e.settings && h(F1, { selectedSettings: o, setSelectedSettings: r, disabled: n, valueChanged: l, values: e.settings.fontFamily.values, defaultValue: e.settings.fontFamily.default }), "fontBold" in e.settings && h(pt, { setSelectedSettings: r, disabled: n, field: "fontBold", icon: i1, valueChanged: l, values: e.settings.fontBold.values, value: e.settings.fontBold.default }), "fontItalic" in e.settings && h(pt, { setSelectedSettings: r, disabled: n, field: "fontItalic", icon: a1, valueChanged: l, values: e.settings.fontItalic.values, value: e.settings.fontItalic.default }), "opacity" in e.settings && h(nt, { selectedSettings: o, setSelectedSettings: r, title: "Opacité", icon: t1, min: e.settings.opacity.min, max: e.settings.opacity.max, step: e.settings.opacity.step, unity: "%", disabled: n, field: "opacity", value: e.settings.opacity.default, valueChanged: s })] }) : null, _a = ({ width: e, disabled: i = !1, availableTools: t, updateToolSettings: n, layersManipulation: o, toggleLayoutPanel: r, activeTool: s, selectedShape: a, canvas: l, currentScale: p, selectionPadding: c, updateShape: d, removeShape: u }) => {
1094
+ const [f, g] = R(void 0), [v, C] = R(!1), x = () => {
1095
+ C((F) => !F);
1096
+ }, w = a ? t.find((F) => F.id === a.toolId) || t.find((F) => F.type === a.type) : void 0, y = (w ? Object.keys(w.settings).length + 1 : "settings" in s ? Object.keys(s.settings).length : 0) + (o ? 1 : 0), b = e < 40 * y, H = (F, E, S = !0) => {
1097
+ a ? (d(st(ce(["style", F], E, a), p, c), S), w && n(w.id, F, E)) : n(s.id, F, E);
1098
+ }, A = (F, E) => {
1099
+ if (a) {
1100
+ if (a.type !== "text")
947
1101
  return;
948
- const b = l?.getContext("2d");
949
- if (!b)
1102
+ const S = l?.getContext("2d");
1103
+ if (!S)
950
1104
  return;
951
- const P = le(["style", T], E, n), w = jt(b, P.value, P.width, P.style?.fontBold ?? !1, P.style?.fontItalic ?? !1, P.style?.fontFamily), L = Je({ ...P, fontSize: w, height: w * P.value.length }, c, d);
952
- p(L, !0), C && a(C.id, T, E);
1105
+ const T = ce(["style", F], E, a), M = _t(S, T.value, T.width, T.style?.fontBold ?? !1, T.style?.fontItalic ?? !1, T.style?.fontFamily), B = st({ ...T, fontSize: M, height: M * T.value.length }, p, c);
1106
+ d(B, !0), w && n(w.id, F, E);
953
1107
  } else
954
- a(o.id, T, E);
955
- }, F = (T, E) => {
956
- if (n) {
957
- if (n.type !== "polygon" && n.type !== "curve")
1108
+ n(s.id, F, E);
1109
+ }, Z = (F, E) => {
1110
+ if (a) {
1111
+ if (a.type !== "polygon" && a.type !== "curve")
958
1112
  return;
959
- p(n.type === "polygon" ? ((b, P, w, L) => {
960
- const x = b.points.length;
961
- if (x === P)
962
- return b;
963
- if (x > P) {
964
- const M = b.points.slice(0, P);
965
- return Ue({ ...b, points: M, style: { ...b.style, pointsCount: M.length } }, w, L);
1113
+ d(a.type === "polygon" ? ((S, T, M, B) => {
1114
+ const N = S.points.length;
1115
+ if (N === T)
1116
+ return S;
1117
+ if (N > T) {
1118
+ const V = S.points.slice(0, T);
1119
+ return Je({ ...S, points: V, style: { ...S.style, pointsCount: V.length } }, M, B);
966
1120
  }
967
- {
968
- 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)];
969
- return Ue({ ...b, points: Z, style: { ...b.style, pointsCount: Z.length } }, w, L);
1121
+ const Q = T - N, k = new Array(Q).fill(void 0).map((V, L) => [S.points[0][0] + (S.points[1][0] - S.points[0][0]) * (L + 1) / (Q + 1), S.points[0][1] + (S.points[1][1] - S.points[0][1]) * (L + 1) / (Q + 1)]), m = [S.points[0], ...k, ...S.points.slice(1, S.points.length)];
1122
+ return Je({ ...S, points: m, style: { ...S.style, pointsCount: m.length } }, M, B);
1123
+ })(a, E, p, c) : ((S, T, M, B) => {
1124
+ const N = S.points.length;
1125
+ if (N === T)
1126
+ return S;
1127
+ if (N > T) {
1128
+ const V = S.points.slice(0, T);
1129
+ return Ke({ ...S, points: V, style: { ...S.style, pointsCount: V.length } }, M, B);
970
1130
  }
971
- })(n, E, c, d) : ((b, P, w, L) => {
972
- const x = b.points.length;
973
- if (x === P)
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);
1131
+ const Q = T - N, k = new Array(Q).fill(void 0).map((V, L) => [S.points[0][0] + (S.points[1][0] - S.points[0][0]) * (L + 1) / (Q + 1), S.points[0][1] + (S.points[1][1] - S.points[0][1]) * (L + 1) / (Q + 1)]), m = [S.points[0], ...k, ...S.points.slice(1, S.points.length)];
1132
+ return Ke({ ...S, points: m, style: { ...S.style, pointsCount: m.length } }, M, B);
1133
+ })(a, E, p, c), !0), w && n(w.id, F, E);
984
1134
  } else
985
- a(o.id, T, E);
1135
+ n(s.id, F, E);
986
1136
  };
987
- return D(de, { children: [D("div", { className: "react-paint-editor-settings-bar", children: [D("div", { className: "react-paint-editor-settings-shrinkable", children: [Q && y > 2 && u(j, { disabled: i, onClick: m, title: "Toggle settings", icon: '<svg><path d="M2.5 15.833V14.083H7.667V15.833ZM2.5 5.917V4.167H10.771V5.917ZM9.208 17.5V12.438H10.958V14.083H17.5V15.833H10.958V17.5ZM5.917 12.542V10.875H2.5V9.125H5.917V7.479H7.667V12.542ZM9.208 10.875V9.125H17.5V10.875ZM12.333 7.562V2.5H14.083V4.167H17.5V5.917H14.083V7.562Z"/></svg>' }), n ? u(de, { children: C && D(de, { children: [!Q && u(Wt, { activeTool: o, selectedShape: n, selectedShapeTool: C, disabled: i, selectedSettings: v, setSelectedSettings: g, handleShapeStyleChange: k, handlePolygonLinesCount: F, handleShapeFontFamilyChange: H }), u(Un, { disabled: i, selectedShape: n, removeShape: h })] }) }) : !Q && u(Wt, { activeTool: o, selectedShape: n, selectedShapeTool: C, disabled: i, selectedSettings: v, setSelectedSettings: g, handleShapeStyleChange: k, handlePolygonLinesCount: F, handleShapeFontFamilyChange: H })] }), u("div", { className: "react-paint-editor-settings-separator" }), s && u(zn, { disabled: i, toggleLayoutPanel: r })] }), f && u(t1, { className: "react-paint-editor-settings-modal", onClose: m, position: "bottom", children: u(Wt, { activeTool: o, selectedShape: n, selectedShapeTool: C, disabled: i, selectedSettings: v, setSelectedSettings: g, handleShapeStyleChange: k, handlePolygonLinesCount: F, handleShapeFontFamilyChange: H }) })] });
988
- }, E1 = "ArrowUp", D1 = "ArrowDown", N1 = "ArrowLeft", I1 = "ArrowRight", Xn = "Delete", qn = "Backspace", Gn = "Escape", R1 = "Shift", Jn = "z", Kn = "Z", ea = "y", ta = "Y", W1 = "copy", F1 = "paste", ia = ({ gridFormat: e, isInsideComponent: i, selectedShape: t, isEditingText: a, currentScale: s, selectionPadding: r, setSelectedShape: o, removeShape: n, pasteShape: l, updateShape: c, backwardShape: d, forwardShape: p, setShiftPressed: h }) => {
989
- const [v, g] = O(void 0);
990
- return _(() => {
991
- const f = (y) => {
992
- t && (a || (y.preventDefault(), g({ ...t })));
993
- }, S = (y) => {
994
- v && (a || (y.preventDefault(), l(((Q, k, H, F) => ({ ...zt([20, 20], Q, [0, 0], k, H, F), id: ae(`${Q.type}_`) }))(v, e, s, r))));
995
- }, m = (y) => {
996
- y.key === R1 && h(!1);
997
- }, C = (y) => {
998
- if (y.metaKey || y.ctrlKey) {
999
- if (y.key === Kn || y.key === Jn)
1000
- return y.preventDefault(), y.stopPropagation(), void d();
1001
- if (y.key === ta || y.key === ea)
1002
- return y.preventDefault(), y.stopPropagation(), void p();
1003
- }
1004
- if (y.key === R1)
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
- }
1137
+ return I(pe, { children: [I("div", { className: "react-paint-editor-settings-bar", children: [I("div", { className: "react-paint-editor-settings-shrinkable", children: [b && y > 2 && h(j, { disabled: i, onClick: x, title: "Toggle settings", icon: '<svg><path d="M2.5 15.833V14.083H7.667V15.833ZM2.5 5.917V4.167H10.771V5.917ZM9.208 17.5V12.438H10.958V14.083H17.5V15.833H10.958V17.5ZM5.917 12.542V10.875H2.5V9.125H5.917V7.479H7.667V12.542ZM9.208 10.875V9.125H17.5V10.875ZM12.333 7.562V2.5H14.083V4.167H17.5V5.917H14.083V7.562Z"/></svg>' }), a ? h(pe, { children: w && I(pe, { children: [!b && h(Ft, { activeTool: s, selectedShape: a, selectedShapeTool: w, disabled: i, selectedSettings: f, setSelectedSettings: g, handleShapeStyleChange: H, handlePolygonLinesCount: Z, handleShapeFontFamilyChange: A }), h(za, { disabled: i, selectedShape: a, removeShape: u })] }) }) : !b && h(Ft, { activeTool: s, selectedShape: a, selectedShapeTool: w, disabled: i, selectedSettings: f, setSelectedSettings: g, handleShapeStyleChange: H, handlePolygonLinesCount: Z, handleShapeFontFamilyChange: A })] }), h("div", { className: "react-paint-editor-settings-separator" }), o && h(Ba, { disabled: i, toggleLayoutPanel: r })] }), v && h(jt, { className: "react-paint-editor-settings-modal", onClose: x, position: "bottom", children: h(Ft, { activeTool: s, selectedShape: a, selectedShapeTool: w, disabled: i, selectedSettings: f, setSelectedSettings: g, handleShapeStyleChange: H, handlePolygonLinesCount: Z, handleShapeFontFamilyChange: A }) })] });
1138
+ }, I1 = ({ disabled: e = !1, withText: i = !1, loadFile: t, type: n, img: o, accept: r }) => {
1139
+ const s = ee(null);
1140
+ return h(j, { ref: s, type: "file", onClick: (a) => {
1141
+ a.stopPropagation(), s.current && (s.current.value = "");
1142
+ }, onChange: (a) => {
1143
+ const l = a.target.files?.item(0);
1144
+ l && t(l);
1145
+ }, accept: r, title: n.label ?? n.type, icon: o, children: i ? n.label : void 0, disabled: e });
1146
+ }, ge = ({ type: e, img: i, isActive: t, withText: n = !1, disabled: o = !1, setActive: r }) => h(j, { disabled: o, selected: t, onClick: () => {
1147
+ r(e);
1148
+ }, title: e.label ?? e.type, icon: i, children: n ? e.label : void 0 }), ja = ({ activeTool: e, withActionsInMenu: i, hasActionToUndo: t = !1, hasActionToRedo: n = !1, hasActionToClear: o = !1, undoAction: r, redoAction: s, clearCanvas: a, alignment: l, group: p, vertical: c = !1, disabled: d = !1, withLoadAndSave: u, withExport: f, addPicture: g, loadFile: v, togglePictureUrlModal: C, saveFile: x, exportCanvasInFile: w, withUploadPicture: y, withUrlPicture: b }) => {
1149
+ const [H, A] = R(!1), [, Z] = R1(), F = p?.tools?.some((S) => S === e.type), E = (F ? e.icon : p.img) ?? p.title;
1150
+ return Y(() => {
1151
+ if (!H)
1152
+ return;
1153
+ const S = () => {
1154
+ A(!1);
1024
1155
  };
1025
- return i && (document.addEventListener("keydown", C), document.addEventListener("keyup", m), document.addEventListener(W1, f), document.addEventListener(F1, S)), () => {
1026
- i && (document.removeEventListener("keydown", C), document.removeEventListener("keyup", m), document.removeEventListener(W1, f), document.removeEventListener(F1, S));
1156
+ return document.addEventListener("click", S), () => {
1157
+ document.removeEventListener("click", S);
1027
1158
  };
1028
- }, [i, r, e, v, a, t, s, c, n, o, l, d, p, h]), {};
1029
- }, na = "infos", aa = 4e3, oa = ({ type: e, text: i, duration: t }) => {
1030
- const [a, s] = O(!1);
1031
- return _(() => {
1032
- const r = setTimeout(() => {
1033
- s(!0);
1034
- }, 100), o = setTimeout(() => {
1035
- s(!1);
1036
- }, t - 500 - 100);
1037
- return () => {
1038
- clearTimeout(r), clearTimeout(o);
1159
+ }, [H]), i || y || b || u || f ? I("div", { className: "react-paint-editor-toolbox-relative", children: [h(j, { selected: F, title: p.title, disabled: d, onClick: () => {
1160
+ Z(() => {
1161
+ A(!0);
1162
+ });
1163
+ }, icon: E }), H && h(it, { alignment: l, position: "top", children: I("div", { className: "react-paint-editor-toolbox-panel-content", "data-vertical": +c, children: [i && I(pe, { children: [h(ge, { withText: !0, type: je, disabled: d || !t, img: je.icon, isActive: e.id === je.id, setActive: r }), h(ge, { withText: !0, type: qe, disabled: d || !n, img: qe.icon, isActive: e.id === qe.id, setActive: s }), h(ge, { withText: !0, type: Ge, disabled: d || !o, img: Ge.icon, isActive: e.id === Ge.id, setActive: a }), (y || b || u) && h("hr", {})] }), y && h(I1, { withText: !0, type: l1, disabled: d, loadFile: async (S) => {
1164
+ A(!1), await g(S);
1165
+ }, img: l1.icon, accept: "image/png, image/gif, image/jpeg, image/svg+xml" }), b && h(j, { disabled: d, selected: !1, onClick: C, title: "Add picture from URL", icon: '<svg><path d="M9.188 16.542V14.938Q8.5 14.938 8.021 14.458Q7.542 13.979 7.542 13.292V12.458L3.583 8.5Q3.5 8.875 3.458 9.25Q3.417 9.625 3.417 10Q3.417 12.5 5.062 14.365Q6.708 16.229 9.188 16.542ZM14.854 14.438Q15.708 13.521 16.146 12.385Q16.583 11.25 16.583 10Q16.583 7.979 15.469 6.313Q14.354 4.646 12.479 3.917V4.229Q12.479 4.917 12 5.396Q11.521 5.875 10.833 5.875H9.188V7.521Q9.188 7.875 8.948 8.115Q8.708 8.354 8.354 8.354H6.708V10H11.646Q12 10 12.24 10.229Q12.479 10.458 12.479 10.812V13.292H13.292Q13.833 13.292 14.26 13.604Q14.688 13.917 14.854 14.438ZM10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.271 2.323 6.75Q2.979 5.229 4.104 4.104Q5.229 2.979 6.75 2.323Q8.271 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.729 17.677 13.25Q17.021 14.771 15.896 15.896Q14.771 17.021 13.25 17.677Q11.729 18.333 10 18.333Z"/></svg>', children: "Add picture from URL" }), (y || b) && u && h("hr", {}), u && I(pe, { children: [h(I1, { withText: !0, type: r1, disabled: d, loadFile: (S) => {
1166
+ A(!1), v(S);
1167
+ }, img: r1.icon, accept: "application/JSON" }), h(ge, { withText: !0, disabled: d, type: Ht, img: Ht.icon, isActive: e.id === Ht.id, setActive: x })] }), f && h(ge, { withText: !0, disabled: d, type: Vt, img: Vt.icon, isActive: e.id === Vt.id, setActive: w })] }) })] }) : null;
1168
+ }, qa = ({ togglePictureUrlModal: e, addPicture: i }) => {
1169
+ const t = ee(null);
1170
+ return Y(() => {
1171
+ t.current && t.current.focus();
1172
+ }, []), h(jt, { className: "react-paint-editor-toolbox-pictureinput-modal", onClose: e, children: I("form", { onSubmit: async (n) => {
1173
+ n.preventDefault();
1174
+ const o = t.current?.value;
1175
+ o && (await i(o), e());
1176
+ }, children: [I("label", { children: ["URL ", h("input", { type: "text", ref: t })] }), h(j, { onClick: e, children: "Annuler" }), h(j, { type: "submit", selected: !0, children: "Ajouter" })] }) });
1177
+ }, Ga = ({ activeTool: e, alignment: i, group: t, disabled: n = !1, setActiveToolFromId: o }) => {
1178
+ const r = ee(null), [s, a] = R(!1), [, l] = R1(), [p, c] = R(void 0), d = (g) => {
1179
+ c(g), o(g.id);
1180
+ };
1181
+ if (Y(() => {
1182
+ if (!s)
1183
+ return;
1184
+ const g = (v) => {
1185
+ !ri(v, r.current) && a(!1);
1039
1186
  };
1040
- }, [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 });
1041
- }, sa = ({ snackbarList: e }) => u("div", { className: "react-paint-editor-snackbar-container", style: { "--react-paint-editor-snackbar-zindex": Bt }, children: e.map((i) => u(oa, { ...i }, i.id)) }), ra = () => {
1042
- const e = ne([]), [i, t] = O([]);
1043
- return _(() => () => {
1044
- for (const a of e.current)
1045
- clearTimeout(a);
1046
- }, []), { snackbarList: i, addSnackbar: ({ type: a = na, duration: s = aa, text: r }) => {
1047
- const o = { id: ae("snackbar_"), duration: s, type: a, text: r };
1048
- t((n) => [...n, o]), e.current = [...e.current, setTimeout(() => {
1049
- return n = o.id, void t((l) => l.filter((c) => c.id !== n));
1050
- var n;
1051
- }, s)];
1052
- } };
1053
- }, la = ({ isLoading: e = !1 }) => {
1054
- const [i, t] = O("hidden");
1055
- return _(() => {
1056
- if (!e) {
1057
- t("fadeOut");
1058
- const a = setTimeout(() => t("hidden"), 300);
1059
- return () => {
1060
- clearTimeout(a);
1061
- };
1062
- }
1063
- t("visible");
1064
- }, [e]), i === "hidden" ? null : u("div", { className: "react-paint-editor-loading", "data-loading": i, style: { "--react-paint-editor-loading-zindex": qi, "--react-paint-editor-loading-transition-duration": "300ms" }, children: D("div", { className: "react-paint-editor-loader", children: [u("div", {}), u("div", {}), u("div", {}), u("div", {})] }) });
1065
- }, Ft = { layersManipulation: !0, grid: 0, canGrow: !1, canShrink: !0, withExport: !0, withLoadAndSave: !0, withUploadPicture: !0, withUrlPicture: !1, availableTools: xn, clearCallback: "empty", 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: z1, canvasSelectionWidth: U1, canvasSelectionPadding: 0 } }, pa = ({ width: e = 1e3, height: i = 600, shapes: t, className: a = "", mode: s = "editor", disabled: r = !1, onDataChanged: o, apiRef: n, options: l = Ft }) => {
1066
- const { layersManipulation: c, grid: d, canGrow: p, canShrink: h, withExport: v, withLoadAndSave: g, withUploadPicture: f, withUrlPicture: S, clearCallback: m, availableTools: C } = { ...Ft, ...l }, { toolbarBackgroundColor: y, dividerColor: Q, fontRadius: k, fontDisabledColor: H, fontDisabledBackgroundColor: F, fontColor: T, fontBackgroundColor: E, fontSelectedColor: b, fontSelectedBackgroundColor: P, fontHoverColor: w, fontHoverBackgroundColor: L, canvasBackgroundColor: x, canvasSelectionColor: M, canvasSelectionWidth: N, canvasSelectionPadding: Z } = { ...Ft.uiStyle, ...l?.uiStyle ?? {} }, I = s !== "viewer", Y = r || !I, ce = ne(null), he = ne(null), [q, ye] = O({ width: e, height: i, scaleRatio: 1 }), [Ae, be] = O(V1(C, f || S)), { isInsideComponent: ke } = (({ disabled: A, componentRef: U }) => {
1067
- const [te, W] = O(!1);
1068
- return _(() => {
1069
- const G = (ie) => {
1070
- W(mi(ie, U.current));
1071
- };
1072
- return A ? W(!1) : (document.addEventListener("mousedown", G, { passive: !0 }), document.addEventListener("touchstart", G, { passive: !0 })), () => {
1073
- A || (document.removeEventListener("mousedown", G), document.removeEventListener("touchstart", G));
1074
- };
1075
- }, [A, U]), { isInsideComponent: te };
1076
- })({ disabled: Y, componentRef: ce }), [xt, ge] = O(!1), [et, tt] = O(!1), [Ie, je] = O([0, 0]), [Ze, it] = O(void 0), [wt, nt] = O(we), [n1, Qi] = O({ mode: "default" }), [Mt, yi] = O(d), [bi, Si] = O(!1);
1077
- n && (n.current = { getCurrentImage: () => he.current ? m1(Le.current, Ie, e, i, Z) : void 0, getCurrentData: () => J1(Le.current, e, i) });
1078
- const { shapesRef: Le, selectedShape: at, addShape: kt, addPictureShape: a1, moveShapes: Ci, setSelectedShape: Ve, removeShape: Lt, updateShape: Vt, backwardShape: Ht, forwardShape: Tt, clearShapes: o1, saveShapes: xi, toggleShapeVisibility: wi, toggleShapeLock: Mi, canGoBackward: ki, canGoForward: Li, canClear: Vi } = ((A, U, te) => {
1079
- const W = ne([]), G = ne(A);
1080
- G.current = A;
1081
- const [ie, oe] = O(void 0), [fe, De] = O({ states: [{ shapes: [], selectedShape: void 0 }], cursor: 0 }), ve = fe.cursor > 0, pe = fe.cursor < fe.states.length - 1, me = W.current.length > 0, X = z(() => {
1082
- De((V) => q1(V.states[V.cursor].shapes, W.current) ? V : { states: [...V.states.slice(0, V.cursor + 1), { shapes: W.current, selectedShape: ie }], cursor: V.cursor + 1 });
1083
- }, [ie]), Ce = z((V) => {
1084
- W.current = [V, ...W.current];
1085
- }, []), qe = z(async (V, B = 300, R = 300) => {
1086
- const J = await Mn(V, B, R, te.scaleRatio, U);
1087
- return Ce(J), X(), J;
1088
- }, [Ce, X, te, U]), Zt = z((V, B = !1) => {
1089
- W.current = W.current.map((R) => R.id === ie?.id ? V : R), oe((R) => R?.id === V.id ? V : R), B && X();
1090
- }, [ie, X]), Re = z((V) => {
1091
- const B = V.map((R) => Ot(["chosen"], R));
1092
- W.current = B, X();
1093
- }, [X]), Fi = z((V) => {
1094
- oe((B) => B?.id === V.id ? void 0 : B), W.current = W.current.filter((B) => B.id !== V.id), X();
1095
- }, [X]), st = z((V) => {
1096
- De((B) => {
1097
- const R = V(B);
1098
- return W.current = B.states[R].shapes, oe(B.states[R].selectedShape), le("cursor", R, B);
1099
- });
1100
- }, []), $i = z(() => {
1101
- st((V) => Math.max(0, V.cursor - 1));
1102
- }, [st]), Oi = z(() => {
1103
- st((V) => Math.min(V.states.length - 1, V.cursor + 1));
1104
- }, [st]), Ui = z((V = [], B = !1) => {
1105
- oe(void 0), W.current = V, De((R) => B ? { states: [{ shapes: V, selectedShape: void 0 }], cursor: 0 } : { states: [...R.states.slice(0, R.cursor + 1), { shapes: V, selectedShape: void 0 }], cursor: R.cursor + 1 });
1106
- }, []), zi = z((V, B) => {
1107
- const R = W.current, J = R.findIndex((Pt) => Pt.id === V), se = R.findIndex((Pt) => Pt.id === B);
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))
1187
+ return document.addEventListener("mousedown", g, { passive: !1 }), document.addEventListener("touchstart", g, { passive: !1 }), () => {
1188
+ document.removeEventListener("mousedown", g), document.removeEventListener("touchstart", g);
1189
+ };
1190
+ }, [s]), "type" in t)
1191
+ return h(ge, { disabled: n, type: t, img: t.icon, isActive: e.id === t.id, setActive: d });
1192
+ if (!t.toolsType.length)
1193
+ return null;
1194
+ if (t.toolsType?.length === 1)
1195
+ return h(ge, { disabled: n, type: t.toolsType[0], img: t.toolsType[0].icon, isActive: e.id === t.toolsType[0].id, setActive: d });
1196
+ const u = t?.toolsType.find((g) => g.type === e.type) !== void 0, f = (p ? p.icon : t.toolsType?.[0]?.icon) ?? t.title;
1197
+ return I("div", { className: "react-paint-editor-toolbargroup-relative", children: [h(j, { selected: u, title: t.title, disabled: n, onClick: () => {
1198
+ p ? o(p.id) : t.toolsType?.[0] && d(t.toolsType[0]), l(() => {
1199
+ a(!0);
1200
+ });
1201
+ }, icon: f }), s && h(it, { alignment: i, position: "top", children: h("div", { className: "react-paint-editor-toolbargroup-panel-content", "data-vertical": +t.vertical, ref: r, children: t.toolsType.map((g, v) => h(ge, { disabled: n, type: g, img: g.icon, isActive: e.id === g.id, setActive: d }, v)) }) })] });
1202
+ }, Ja = [{ title: "brush", toolsType: ["brush"], vertical: !1 }, { title: "lines", toolsType: ["line", "curve", "polygon"], vertical: !1 }, { title: "shapes", toolsType: ["rect", "square", "circle", "ellipse"], vertical: !1 }, "text"], Ka = ({ width: e, disabled: i = !1, activeTool: t, hasActionToUndo: n = !1, hasActionToRedo: o = !1, hasActionToClear: r = !1, withLoadAndSave: s, withExport: a, clearCanvas: l, setActiveTool: p, undoAction: c, redoAction: d, addPicture: u, loadFile: f, saveFile: g, exportCanvasInFile: v, availableTools: C, withUrlPicture: x, withUploadPicture: w }) => {
1203
+ const y = ((N, Q) => {
1204
+ const k = Q.flatMap((m) => {
1205
+ if (typeof m != "object")
1206
+ return N.filter((L) => L.type === m);
1207
+ const V = N.filter((L) => m.toolsType.includes(L.type));
1208
+ return V ? { ...m, toolsType: V } : null;
1209
+ });
1210
+ return yt(k);
1211
+ })(C, Ja), b = e < 40 * (5 + y.length), H = e < 40 * (2 + y.length), [A, Z] = R(!1), [F, E] = R(!1), S = () => {
1212
+ Z((N) => !N);
1213
+ }, T = (N) => {
1214
+ p(N), Z(!1);
1215
+ }, M = (N) => {
1216
+ T(C.find((Q) => Q.id === N) ?? t);
1217
+ }, B = C.find((N) => N.type === t.type) !== void 0;
1218
+ return I(pe, { children: [I("div", { className: "react-paint-editor-toolbar-toolbox", children: [I("div", { className: "react-paint-editor-toolbar-shrinkable", children: [h(ge, { type: He, disabled: i, img: He.icon, isActive: t.id === He.id, setActive: T }), H ? h(j, { disabled: i, onClick: S, title: "Toggle tools", icon: '<svg><path d="M5.333 9.292 10.021 1.646 14.708 9.292ZM14.562 18.333Q13 18.333 11.896 17.229Q10.792 16.125 10.792 14.562Q10.792 13 11.896 11.896Q13 10.792 14.562 10.792Q16.125 10.792 17.229 11.896Q18.333 13 18.333 14.562Q18.333 16.125 17.229 17.229Q16.125 18.333 14.562 18.333ZM2.5 17.917V11.188H9.229V17.917ZM14.562 16.583Q15.438 16.583 16.01 16.01Q16.583 15.438 16.583 14.562Q16.583 13.688 16.01 13.115Q15.438 12.542 14.562 12.542Q13.688 12.542 13.115 13.115Q12.542 13.688 12.542 14.562Q12.542 15.438 13.115 16.01Q13.688 16.583 14.562 16.583ZM4.25 16.167H7.479V12.938H4.25ZM8.458 7.542H11.583L10.021 5ZM10.021 7.542ZM7.479 12.938ZM14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Z"/></svg>', selected: B }) : y.map((N, Q) => h(Ga, { disabled: i, activeTool: t, group: N, setActiveToolFromId: M }, Q))] }), !b && I(pe, { children: [h(ge, { type: je, disabled: i || !n, img: je.icon, isActive: t.id === je.id, setActive: c }), h(ge, { type: qe, disabled: i || !o, img: qe.icon, isActive: t.id === qe.id, setActive: d }), h(ge, { type: Ge, disabled: i || !r, img: Ge.icon, isActive: t.id === Ge.id, setActive: l })] }), h(ja, { withActionsInMenu: b, disabled: i, vertical: !0, alignment: "right", group: { title: "Menu", img: '<svg><path d="M2.5 15V13.25H17.5V15ZM2.5 10.875V9.125H17.5V10.875ZM2.5 6.75V5H17.5V6.75Z"/></svg>' }, activeTool: t, addPicture: u, loadFile: f, saveFile: g, togglePictureUrlModal: () => {
1219
+ E(!0);
1220
+ }, exportCanvasInFile: v, withUploadPicture: w, withUrlPicture: x, withLoadAndSave: s, withExport: a, hasActionToUndo: n, hasActionToRedo: o, hasActionToClear: r, undoAction: c, redoAction: d, clearCanvas: l })] }), A && h(jt, { className: "react-paint-editor-toolbar-modal", onClose: S, children: C.map((N, Q) => N.type === "picture" ? null : h(ge, { disabled: i, type: N, img: N.icon, withText: !1, isActive: t.id === N.id, setActive: T }, Q)) }), F && h(qa, { togglePictureUrlModal: () => {
1221
+ E((N) => !N);
1222
+ }, addPicture: u })] });
1223
+ }, an = ({ width: e = 1e3, height: i = 600, shapes: t, className: n = "", mode: o = "editor", disabled: r = !1, onDataChanged: s, apiRef: a, options: l = At }) => {
1224
+ const { layersManipulation: p, grid: c, canGrow: d, canShrink: u, withExport: f, withLoadAndSave: g, withUploadPicture: v, withUrlPicture: C, withSkeleton: x, withFrameSelection: w, clearCallback: y, availableTools: b } = { ...At, ...l }, { toolbarBackgroundColor: H, dividerColor: A, fontRadius: Z, fontDisabledColor: F, fontDisabledBackgroundColor: E, fontColor: S, fontBackgroundColor: T, fontSelectedColor: M, fontSelectedBackgroundColor: B, fontHoverColor: N, fontHoverBackgroundColor: Q, canvasBackgroundColor: k, canvasSelectionColor: m, canvasSelectionWidth: V, canvasSelectionPadding: L } = { ...At.uiStyle, ...l?.uiStyle ?? {} }, $ = o !== "viewer", W = r || !$, _ = ee(null), O = ee(null), [P, ne] = R({ width: e, height: i, scaleRatio: 1 }), [oe, se] = R(P1(b, v || C)), { isInsideComponent: le } = (({ disabled: D, componentRef: X }) => {
1225
+ const [me, te] = R(!1);
1226
+ return Y(() => {
1227
+ if (!D) {
1228
+ const ie = (be) => {
1229
+ te(ri(be, X.current));
1230
+ };
1231
+ return document.addEventListener("mousedown", ie, { passive: !0 }), document.addEventListener("touchstart", ie, { passive: !0 }), () => {
1232
+ document.removeEventListener("mousedown", ie), document.removeEventListener("touchstart", ie);
1233
+ };
1234
+ }
1235
+ te(!1);
1236
+ }, [D, X]), { isInsideComponent: me };
1237
+ })({ disabled: W, componentRef: _ }), [de, q] = R(!1), [ue, we] = R(!1), [Se, Me] = R([0, 0]), [Ae, ve] = R(void 0), [De, ye] = R(He), [he, Te] = R({ mode: "default" }), [K, ke] = R(c), [Ee, Ie] = R(!1);
1238
+ a && (a.current = { getCurrentImage: () => O.current ? b1(Qe.current, Se, e, i, L) : void 0, getCurrentData: () => hi(Qe.current, e, i) });
1239
+ const { shapesRef: Qe, selectedShape: Ze, selectionFrame: yi, hoveredShape: Qi, addShape: Ct, addPictureShape: Gt, moveShapes: bi, setSelectedShape: Pe, setSelectionFrame: Si, refreshSelectedShapes: Ci, refreshHoveredShape: xi, removeShape: xt, updateShape: wt, backwardShape: Mt, forwardShape: kt, clearShapes: Jt, saveShapes: wi, toggleShapeVisibility: Mi, toggleShapeLock: ki, canGoBackward: Li, canGoForward: Vi, canClear: Hi } = ka(s, L, P), { snackbarList: Ai, addSnackbar: Le } = Ha(), We = U((D) => {
1240
+ Pe(void 0), ye(D);
1241
+ }, [Pe]), Ti = U((D, X, me) => {
1242
+ se((te) => te.map((ie) => ie.id === D ? ce(["settings", X, "default"], me, ie) : ie)), ye((te) => te.id === D ? ce(["settings", X, "default"], me, te) : te);
1243
+ }, []), Zi = U(() => {
1244
+ We(He), Mt();
1245
+ }, [We, Mt]), Pi = U(() => {
1246
+ We(He), kt();
1247
+ }, [We, kt]), lt = U((D = [], X = !1) => {
1248
+ Jt(D, X), We(He), Me([0, 0]);
1249
+ }, [We, Jt]), Re = U(async (D, X = !0) => {
1250
+ const me = await (async (te, ie, be) => {
1251
+ if (!te.shapes)
1252
+ return [];
1253
+ const Xe = [], Ye = yt(te.shapes.map((Ce) => {
1254
+ if (!Ce || !U1.includes(Ce.type))
1159
1255
  return null;
1160
- if (ve.type === "picture") {
1161
- const pe = new Image(), me = new Promise((X, Ce) => {
1162
- pe.onload = () => {
1163
- URL.revokeObjectURL(pe.src), X();
1164
- }, pe.onerror = () => {
1165
- Ce(new Error("Some images could not be loaded"));
1256
+ if (Ce.type === "picture") {
1257
+ const $e = new Image(), $i = new Promise((Lt, Oi) => {
1258
+ $e.onload = () => {
1259
+ URL.revokeObjectURL($e.src), Lt();
1260
+ }, $e.onerror = () => {
1261
+ Oi(new Error("Some images could not be loaded"));
1166
1262
  };
1167
1263
  });
1168
- return oe.push(me), ve.src.startsWith("http") ? ti(ve.src).then((X) => {
1169
- pe.src = X;
1264
+ return Xe.push($i), Ce.src.startsWith("http") ? vi(Ce.src).then((Lt) => {
1265
+ $e.src = Lt;
1170
1266
  }).catch(() => {
1171
- pe.src = "";
1172
- }) : pe.src = ve.src, v1({ ...ve, img: pe }, G, ie);
1267
+ $e.src = "";
1268
+ }) : $e.src = Ce.src, y1({ ...Ce, img: $e }, ie, be);
1173
1269
  }
1174
- return v1(ve, G, ie);
1270
+ return y1(Ce, ie, be);
1175
1271
  }));
1176
- return await Promise.all(oe), De;
1177
- })(A, q.scaleRatio, Z);
1178
- ot(te, U);
1179
- }, [ot, q, Z]), Pi = z(() => {
1180
- typeof m != "string" ? Ee({ shapes: m() }, !1) : m === "defaultShapes" && t !== void 0 ? Ee({ shapes: t }, !1) : ot();
1181
- }, [ot, Ee, t, m]), Xe = z((A) => {
1182
- nt(we), Ve(A);
1183
- }, [Ve]), Ei = z((A) => {
1184
- kt(A), Xe(A);
1185
- }, [kt, Xe]), Di = z(() => {
1186
- ge(!0);
1272
+ return await Promise.all(Xe), Ye;
1273
+ })(D, P.scaleRatio, L);
1274
+ lt(me, X);
1275
+ }, [lt, P, L]), Fi = U(() => {
1276
+ typeof y != "string" ? Re({ shapes: y() }, !1) : y === "defaultShapes" && t !== void 0 ? Re({ shapes: t }, !1) : lt();
1277
+ }, [lt, Re, t, y]), at = U((D) => {
1278
+ ye(He), Pe(D);
1279
+ }, [Pe]), Ni = U((D) => {
1280
+ Ct(D), at(D);
1281
+ }, [Ct, at]), Di = U(() => {
1282
+ q(!0);
1187
1283
  try {
1188
- const A = he.current && m1(Le.current, Ie, e, i, Z);
1189
- if (!A)
1284
+ const D = O.current && b1(Qe.current, Se, e, i, L);
1285
+ if (!D)
1190
1286
  throw new Error();
1191
- f1(A, "drawing.png"), ge(!1);
1192
- } catch (A) {
1193
- A instanceof Error && Se({ type: "error", text: "L'export a échoué" }), console.warn(A);
1287
+ Q1(D, "drawing.png"), q(!1);
1288
+ } catch (D) {
1289
+ D instanceof Error && Le({ type: "error", text: "L'export a échoué" }), console.warn(D);
1194
1290
  } finally {
1195
- ge(!1);
1291
+ q(!1);
1196
1292
  }
1197
- }, [Se, Le, Ie, e, i, Z]), Ni = z(() => {
1198
- ge(!0);
1293
+ }, [Le, Qe, Se, e, i, L]), Ei = U(() => {
1294
+ q(!0);
1199
1295
  try {
1200
- const A = Cn(Le.current, e, i);
1201
- if (!A)
1296
+ const D = ra(Qe.current, e, i);
1297
+ if (!D)
1202
1298
  throw new Error("L'encodage a échoué");
1203
- f1(A, "drawing.json"), ge(!1);
1204
- } catch (A) {
1205
- A instanceof Error && Se({ type: "error", text: "L'enregistrement a échoué" }), console.warn(A);
1299
+ Q1(D, "drawing.json"), q(!1);
1300
+ } catch (D) {
1301
+ D instanceof Error && Le({ type: "error", text: "L'enregistrement a échoué" }), console.warn(D);
1206
1302
  } finally {
1207
- ge(!1);
1303
+ q(!1);
1208
1304
  }
1209
- }, [Le, Se, e, i]), Ii = z(async (A) => {
1210
- ge(!0);
1305
+ }, [Qe, Le, e, i]), Ii = U(async (D) => {
1306
+ q(!0);
1211
1307
  try {
1212
- const U = await (async (te) => new Promise((W, G) => {
1213
- const ie = new FileReader();
1214
- ie.onload = (oe) => {
1215
- const fe = oe.target?.result;
1216
- if (!fe)
1217
- return G("Impossible de récupérer les données du fichier");
1218
- const De = JSON.parse(fe);
1219
- W(De);
1220
- }, ie.readAsText(te);
1221
- }))(A);
1222
- await Ee(U), Se({ type: "success", text: "Fichier chargé !" });
1223
- } catch (U) {
1224
- U instanceof Error && Se({ type: "error", text: "Le chargement a échoué" }), console.warn(U);
1308
+ const X = await (async (me) => new Promise((te, ie) => {
1309
+ const be = new FileReader();
1310
+ be.onload = (Xe) => {
1311
+ const Ye = Xe.target?.result;
1312
+ if (!Ye)
1313
+ return ie("Impossible de récupérer les données du fichier");
1314
+ const Ce = JSON.parse(Ye);
1315
+ te(Ce);
1316
+ }, be.readAsText(me);
1317
+ }))(D);
1318
+ await Re(X), Le({ type: "success", text: "Fichier chargé !" });
1319
+ } catch (X) {
1320
+ X instanceof Error && Le({ type: "error", text: "Le chargement a échoué" }), console.warn(X);
1225
1321
  } finally {
1226
- ge(!1);
1322
+ q(!1);
1227
1323
  }
1228
- }, [Ee, Se]), Ri = z(async (A) => {
1229
- ge(!0);
1324
+ }, [Re, Le]), Wi = U(async (D) => {
1325
+ q(!0);
1230
1326
  try {
1231
- const U = await a1(A, e, i);
1232
- Xe(U);
1233
- } catch (U) {
1234
- U instanceof Error && Se({ type: "error", text: "Le chargement a échoué" }), console.warn(U);
1327
+ const X = await Gt(D, e, i);
1328
+ at(X);
1329
+ } catch (X) {
1330
+ X instanceof Error && Le({ type: "error", text: "Le chargement a échoué" }), console.warn(X);
1235
1331
  } finally {
1236
- ge(!1);
1332
+ q(!1);
1237
1333
  }
1238
- }, [a1, Xe, Se, e, i]), Wi = z((A) => {
1239
- const U = A / e;
1240
- ye({ width: A, height: i * U, scaleRatio: U });
1334
+ }, [Gt, at, Le, e, i]), Ri = U((D) => {
1335
+ const X = D / e;
1336
+ ne({ width: D, height: i * X, scaleRatio: X });
1241
1337
  }, [e, i]);
1242
- ia({ isInsideComponent: ke, selectionPadding: Z, gridFormat: Mt, isEditingText: n1.mode === "textedition", selectedShape: at, currentScale: q.scaleRatio, setSelectedShape: Ve, removeShape: Lt, pasteShape: Ei, updateShape: Vt, backwardShape: Ht, forwardShape: Tt, setShiftPressed: Si }), (({ onResized: A, element: U }) => {
1243
- _(() => {
1244
- const te = U.current;
1245
- if (!te)
1338
+ Ma({ isInsideComponent: le, selectionPadding: L, gridFormat: K, isEditingText: he.mode === "textedition", selectedShape: Ze, currentScale: P.scaleRatio, setSelectedShape: Pe, removeShape: xt, pasteShape: Ni, updateShape: wt, backwardShape: Mt, forwardShape: kt, setShiftPressed: Ie }), (({ onResized: D, element: X }) => {
1339
+ Y(() => {
1340
+ const me = X.current;
1341
+ if (!me)
1246
1342
  return;
1247
- const W = new ResizeObserver((G) => {
1248
- const ie = G?.[0]?.borderBoxSize?.[0], { width: oe, height: fe } = ie ? { width: ie.inlineSize, height: ie.blockSize } : G?.[0].contentRect;
1249
- A(oe, fe);
1343
+ const te = new ResizeObserver((ie) => {
1344
+ const be = ie?.[0]?.borderBoxSize?.[0], { width: Xe, height: Ye } = be ? { width: be.inlineSize, height: be.blockSize } : ie?.[0].contentRect ?? {};
1345
+ D(Xe, Ye);
1250
1346
  });
1251
- return W.observe(te), () => {
1252
- W.unobserve(te);
1347
+ return te.observe(me), () => {
1348
+ te.unobserve(me);
1253
1349
  };
1254
- }, [U, A]);
1255
- })({ element: ce, onResized: Wi }), _(() => {
1256
- be(V1(C, f || S));
1257
- }, [C, f, S]), _(() => {
1258
- ke || Ve(void 0);
1259
- }, [ke, Ve]);
1260
- const At = ne(Ee);
1261
- return At.current = Ee, _(() => {
1262
- t !== void 0 && At.current({ shapes: t });
1263
- }, [At, t]), D("div", { ref: ce, className: `${a}${et ? " react-paint-editor-layout-opened" : ""} react-paint-editor-app`, "data-grow": p, "data-shrink": h, style: { "--react-paint-editor-app-canvaswidth": `${e}px`, "--react-paint-editor-app-toolbar-bg": y, "--react-paint-editor-app-divider-color": Q, "--react-paint-editor-app-font-radius": k, "--react-paint-editor-app-font-disabled-color": H, "--react-paint-editor-app-font-disabled-bg": F, "--react-paint-editor-app-font-color": T, "--react-paint-editor-app-font-bg": E, "--react-paint-editor-app-font-selected-color": b, "--react-paint-editor-app-font-selected-bg": P, "--react-paint-editor-app-font-hover-color": w, "--react-paint-editor-app-font-hover-bg": L, "--react-paint-editor-app-canvas-bg": x }, children: [I && u(On, { width: q.width, disabled: Y, activeTool: wt, clearCanvas: Pi, setActiveTool: Pe, exportCanvasInFile: Di, saveFile: Ni, loadFile: Ii, addPicture: Ri, hasActionToUndo: ki, hasActionToRedo: Li, hasActionToClear: Vi, undoAction: Ai, redoAction: Zi, availableTools: Ae, withExport: v, withLoadAndSave: g, withUploadPicture: f, withUrlPicture: S }), D("div", { className: "react-paint-editor-app-row", "data-grow": p, style: { "--react-paint-editor-app-row-zindex": Xi, "--react-paint-editor-app-row-width": q.width, "--react-paint-editor-app-row-aspectratio": `calc(${q.width} / ${q.height})` }, children: [u(En, { canGrow: p, gridFormat: Mt, disabled: Y, isInsideComponent: ke, activeTool: wt, setActiveTool: nt, canvasOffsetStartPosition: Ze, setCanvasOffsetStartPosition: it, shapes: Le.current, addShape: kt, updateSingleShape: Vt, selectedShape: at, setSelectedShape: Ve, canvasOffset: Ie, setCanvasOffset: je, saveShapes: xi, ref: he, canvasSize: q, selectionMode: n1, setSelectionMode: Qi, selectionColor: M, selectionWidth: N, selectionPadding: Z, isEditMode: I, isShiftPressed: bi }), I && c && u(In, { gridFormat: Mt, setGridFormat: yi, disabled: Y, shapes: Le.current, moveShapes: Ci, selectedShape: at, removeShape: Lt, selectShape: Xe, toggleShapeVisibility: wi, toggleShapeLock: Mi, isLayoutPanelShown: et })] }), I && D(de, { children: [u(jn, { width: q.width, disabled: Y, activeTool: wt, availableTools: Ae, selectedShape: at, selectionPadding: Z, removeShape: Lt, updateShape: Vt, canvas: he.current, currentScale: q.scaleRatio, layersManipulation: c, toggleLayoutPanel: () => {
1264
- tt((A) => !A);
1265
- }, updateToolSettings: Ti }), u(la, { isLoading: xt }), u(sa, { snackbarList: Hi })] })] });
1350
+ }, [X, D]);
1351
+ })({ element: _, onResized: Ri }), Y(() => {
1352
+ se(P1(b, v || C));
1353
+ }, [b, v, C]), Y(() => {
1354
+ le || Pe(void 0);
1355
+ }, [le, Pe]);
1356
+ const Kt = ee(Re);
1357
+ return Kt.current = Re, Y(() => {
1358
+ t !== void 0 && Kt.current({ shapes: t });
1359
+ }, [t]), I("div", { ref: _, className: `${n}${ue ? " react-paint-editor-layout-opened" : ""} react-paint-editor-app`, "data-grow": d, "data-shrink": u, style: { "--react-paint-editor-app-canvaswidth": `${e}px`, "--react-paint-editor-app-toolbar-bg": H, "--react-paint-editor-app-divider-color": A, "--react-paint-editor-app-font-radius": Z, "--react-paint-editor-app-font-disabled-color": F, "--react-paint-editor-app-font-disabled-bg": E, "--react-paint-editor-app-font-color": S, "--react-paint-editor-app-font-bg": T, "--react-paint-editor-app-font-selected-color": M, "--react-paint-editor-app-font-selected-bg": B, "--react-paint-editor-app-font-hover-color": N, "--react-paint-editor-app-font-hover-bg": Q, "--react-paint-editor-app-canvas-bg": k }, children: [$ && h(Ka, { width: P.width, disabled: W, activeTool: De, clearCanvas: Fi, setActiveTool: We, exportCanvasInFile: Di, saveFile: Ei, loadFile: Ii, addPicture: Wi, hasActionToUndo: Li, hasActionToRedo: Vi, hasActionToClear: Hi, undoAction: Zi, redoAction: Pi, availableTools: oe, withExport: f, withLoadAndSave: g, withUploadPicture: v, withUrlPicture: C }), I("div", { className: "react-paint-editor-app-row", "data-grow": d, style: { "--react-paint-editor-app-row-zindex": Bi, "--react-paint-editor-app-row-width": P.width, "--react-paint-editor-app-row-aspectratio": `calc(${P.width} / ${P.height})` }, children: [h(Ea, { canGrow: d, gridFormat: K, disabled: W, isInsideComponent: le, activeTool: De, setActiveTool: ye, canvasOffsetStartPosition: Ae, setCanvasOffsetStartPosition: ve, shapes: Qe.current, addShape: Ct, updateSingleShape: wt, selectedShape: Ze, selectionFrame: yi, setSelectedShape: Pe, setSelectionFrame: Si, hoveredShape: Qi, refreshHoveredShape: xi, refreshSelectedShapes: Ci, canvasOffset: Se, setCanvasOffset: Me, saveShapes: wi, ref: O, canvasSize: P, selectionMode: he, setSelectionMode: Te, selectionColor: m, selectionWidth: V, selectionPadding: L, isEditMode: $, isShiftPressed: Ee, withFrameSelection: w, withSkeleton: x }), $ && p && h(Oa, { gridFormat: K, setGridFormat: ke, disabled: W, shapes: Qe.current, moveShapes: bi, selectedShape: Ze, removeShape: xt, selectShape: at, toggleShapeVisibility: Mi, toggleShapeLock: ki, isLayoutPanelShown: ue })] }), $ && I(pe, { children: [h(_a, { width: P.width, disabled: W, activeTool: De, availableTools: oe, selectedShape: Ze, selectionPadding: L, removeShape: xt, updateShape: wt, canvas: O.current, currentScale: P.scaleRatio, layersManipulation: p, toggleLayoutPanel: () => {
1360
+ we((D) => !D);
1361
+ }, updateToolSettings: Ti }), h(Yi, { isLoading: de }), h(Wa, { snackbarList: Ai })] })] });
1266
1362
  };
1267
1363
  export {
1268
- pa as default
1364
+ an as default
1269
1365
  };