@yorab/react-paint 0.16.2 → 0.16.3

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,6 +1,6 @@
1
- import hi, { useState as X, useEffect as ee, useRef as ne, useCallback as Y, useMemo as Pn, useImperativeHandle as kn, useTransition as Ln } from "react";
2
- import { jsx as m, jsxs as U, Fragment as Ae } from "react/jsx-runtime";
3
- const Vn = '<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>', ui = '<svg><path d="M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z"/></svg>', pi = '<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>', gi = '<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>', Zn = '<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>', Hi = '<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>', fi = '<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>', Hn = '<svg><path d="M8.708 16.667V5.917H4.167V3.333H15.833V5.917H11.292V16.667Z"/></svg>', zn = '<svg><path d="M7.5 15.833V14.083H12.833L3.333 4.583L4.583 3.333L14.083 12.833V7.5H15.833V15.833Z"/></svg>', Tn = '<svg><path d="M7.521 17.5Q6.125 17.5 5.146 16.51Q4.167 15.521 4.167 14.125V7.417Q3.438 7.125 2.969 6.49Q2.5 5.854 2.5 5.042Q2.5 3.979 3.24 3.24Q3.979 2.5 5.042 2.5Q6.104 2.5 6.844 3.24Q7.583 3.979 7.583 5.042Q7.583 5.854 7.115 6.49Q6.646 7.125 5.917 7.417V14.125Q5.917 14.792 6.385 15.271Q6.854 15.75 7.521 15.75Q8.188 15.75 8.656 15.271Q9.125 14.792 9.125 14.125V5.875Q9.125 4.479 10.104 3.49Q11.083 2.5 12.479 2.5Q13.875 2.5 14.854 3.49Q15.833 4.479 15.833 5.875V12.583Q16.562 12.875 17.031 13.51Q17.5 14.146 17.5 14.958Q17.5 16.021 16.76 16.76Q16.021 17.5 14.958 17.5Q13.896 17.5 13.156 16.76Q12.417 16.021 12.417 14.958Q12.417 14.146 12.885 13.5Q13.354 12.854 14.083 12.583V5.875Q14.083 5.208 13.615 4.729Q13.146 4.25 12.479 4.25Q11.812 4.25 11.344 4.729Q10.875 5.208 10.875 5.875V14.125Q10.875 15.521 9.896 16.51Q8.917 17.5 7.521 17.5Z"/></svg>', zi = '<svg><path d="M5.833 15V3.333H10.375Q11.812 3.333 12.885 4.156Q13.958 4.979 13.958 6.375Q13.958 7.375 13.49 7.969Q13.021 8.562 12.396 8.875V9.042Q13.312 9.354 13.844 10.021Q14.375 10.688 14.375 11.75Q14.375 13.312 13.229 14.156Q12.083 15 10.5 15ZM8.125 8.042H10.188Q10.854 8.042 11.302 7.656Q11.75 7.271 11.75 6.708Q11.75 6.167 11.302 5.771Q10.854 5.375 10.188 5.375H8.125ZM8.125 12.917H10.354Q11.167 12.917 11.625 12.51Q12.083 12.104 12.083 11.458Q12.083 10.812 11.625 10.406Q11.167 10 10.354 10H8.125Z"/></svg>', Ti = '<svg><path d="M4.167 16.667V14.083H6.979L10.229 5.917H7.5V3.333H15.833V5.917H13.021L9.771 14.083H12.5V16.667Z"/></svg>', Ai = '<svg><path d="M3.021 16V15H17V16ZM3.021 13.5V12H17V13.5ZM3 10.5V8.5H16.979V10.5ZM3.021 7V4H17V7Z"/></svg>', Ei = '<svg><path d="M16.354 18.833 14.521 17Q13.542 17.646 12.396 17.99Q11.25 18.333 10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.729 2.01 7.594Q2.354 6.458 3 5.458L1.167 3.625L2.396 2.396L17.583 17.604ZM10 16.583Q10.896 16.583 11.708 16.365Q12.521 16.146 13.25 15.729L4.292 6.75Q3.875 7.479 3.646 8.292Q3.417 9.104 3.417 10Q3.417 12.729 5.344 14.656Q7.271 16.583 10 16.583ZM17 14.562 15.708 13.271Q16.125 12.542 16.354 11.719Q16.583 10.896 16.583 10Q16.583 7.271 14.656 5.344Q12.729 3.417 10 3.417Q9.104 3.417 8.292 3.646Q7.479 3.875 6.75 4.292L5.458 3Q6.458 2.354 7.594 2.01Q8.729 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.271 17.979 12.417Q17.625 13.562 17 14.562ZM11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771ZM8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Z"/></svg>', Di = '<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>', An = '<svg viewBox="0 -960 960 960" width="24px"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Zm-40-60v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"/></svg>', Ce = ["transparent", "black", "white", "red", "green", "blue", "yellow"], Ue = [0, 1, 2], Ii = [[1, 0], [1, 2], [4, 6]], mt = "serif", Ta = 2, En = 3, Aa = 4, he = "react-paint-", Dn = { strokeColor: { values: Ce, default: "black" }, fillColor: { values: Ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 } }, vi = { type: "picture", id: `${he}picture`, icon: fi, label: "Image", settings: { opacity: { min: 0, max: 100, step: 1, default: 100 } } }, In = { type: "brush", id: `${he}brush`, icon: Vn, label: "Brosse", settings: { strokeColor: { values: Ce, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 6, max: 20, step: 2, default: 10 }, lineDash: { values: Ue, default: 0 } } }, Wn = { type: "line", id: `${he}line`, icon: zn, label: "Ligne", settings: { strokeColor: { values: Ce, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 }, lineArrow: { values: [0, 1, 2, 3], default: 0 } } }, Rn = { type: "polygon", id: `${he}polygon`, icon: gi, label: "Polygone", settings: { strokeColor: { values: Ce, default: "black" }, fillColor: { values: Ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 }, closedPoints: { default: 0 } } }, Nn = { type: "curve", id: `${he}curve`, icon: Tn, label: "Courbe", settings: { strokeColor: { values: Ce, default: "black" }, fillColor: { values: Ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 }, closedPoints: { default: 0 } } }, Bn = { type: "rect", id: `${he}rect`, icon: ui, label: "Rectangle", settings: Dn }, On = { type: "square", id: `${he}square`, icon: ui, label: "Carré", settings: { strokeColor: { values: Ce, default: "black" }, fillColor: { values: Ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 } } }, Fn = { type: "circle", id: `${he}circle`, icon: pi, label: "Cercle", settings: { strokeColor: { values: Ce, default: "black" }, fillColor: { values: Ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 } } }, Yn = { type: "ellipse", id: `${he}ellipse`, icon: pi, label: "Ellipse", settings: { strokeColor: { values: Ce, default: "black" }, fillColor: { values: Ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 } } }, Xn = { type: "text", id: `${he}text`, icon: Hn, label: "Texte", settings: { strokeColor: { values: Ce, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, fontFamily: { values: ["arial", "serif", "monospace"], default: mt }, fontBold: { values: [!1, !0], default: !1 }, fontItalic: { values: [!1, !0], default: !1 } } }, Oe = { id: `${he}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" }, dt = { id: `${he}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" }, ct = { id: `${he}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" }, ht = { id: `${he}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" }, _t = { id: `${he}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" }, Wi = { id: `${he}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" }, jt = { id: `${he}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" }, Kt = { id: `${he}move`, type: "move", icon: '<svg viewBox="0 -960 960 960"><path d="M412-48q-21.95 0-40.98-9Q352-66 338-83L48-434l27-28q17-17 41.5-20.5T162-473l126 74v-381q0-15.3 10.29-25.65Q308.58-816 323.79-816t25.71 10.35Q360-795.3 360-780v300h80v-396q0-15.3 10.29-25.65Q460.58-912 475.79-912t25.71 10.35Q512-891.3 512-876v396h80v-348q0-15.3 10.29-25.65Q612.58-864 627.79-864t25.71 10.35Q664-843.3 664-828v348h80v-252q0-15.3 10.29-25.65Q764.58-768 779.79-768t25.71 10.35Q816-747.3 816-732v540q0 60-42 102T672-48H412Z"/></svg>', label: "Move" }, Ri = { id: `${he}upload-picture`, type: "uploadpicture", icon: fi, label: "Upload picture" }, $n = 2, Un = "blue", Je = 14, qn = [[0, 0], [0.5, 0], [1, 0], [1, 0.5], [1, 1], [0.5, 1], [0, 1], [0, 0.5]], Gn = ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle", "group"], Ea = ["rect", "square", "circle", "ellipse", "picture", "text", "triangle", "brush", "group"], Da = ["square", "circle", "picture", "text"], _n = "react-paint-canvas-drawcanvas", jn = "react-paint-canvas-selectioncanvas", Ni = { layersManipulation: !0, grid: 0, canGrow: !1, canShrink: !0, withExport: !0, withLoadAndSave: !0, withUploadPicture: !0, withUrlPicture: !1, availableTools: [In, Wn, Rn, Nn, Bn, On, Fn, Yn, vi, Xn], clearCallback: "empty", brushAlgo: "simple", isBrushShapeDoneOnMouseUp: !0, withFrameSelection: !0, withSkeleton: !0, canvasSelectionPadding: 0, size: "fixed", canZoom: "never", debug: !1 }, Ia = { canvasBackgroundColor: "white", canvasSelectionColor: Un, canvasSelectionWidth: $n }, Bi = 300, ai = (e, t) => {
1
+ import hi, { useState as $, useEffect as ee, useRef as ne, useCallback as X, useMemo as kn, useImperativeHandle as Ln, useTransition as Vn } from "react";
2
+ import { jsx as m, jsxs as q, Fragment as Ae } from "react/jsx-runtime";
3
+ const Zn = '<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>', ui = '<svg><path d="M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z"/></svg>', pi = '<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>', gi = '<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>', Hn = '<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>', zi = '<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>', vi = '<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>', zn = '<svg><path d="M8.708 16.667V5.917H4.167V3.333H15.833V5.917H11.292V16.667Z"/></svg>', Tn = '<svg><path d="M7.5 15.833V14.083H12.833L3.333 4.583L4.583 3.333L14.083 12.833V7.5H15.833V15.833Z"/></svg>', An = '<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>', Ti = '<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>', Ai = '<svg><path d="M4.167 16.667V14.083H6.979L10.229 5.917H7.5V3.333H15.833V5.917H13.021L9.771 14.083H12.5V16.667Z"/></svg>', Di = '<svg><path d="M3.021 16V15H17V16ZM3.021 13.5V12H17V13.5ZM3 10.5V8.5H16.979V10.5ZM3.021 7V4H17V7Z"/></svg>', Ei = '<svg><path d="M16.354 18.833 14.521 17Q13.542 17.646 12.396 17.99Q11.25 18.333 10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.729 2.01 7.594Q2.354 6.458 3 5.458L1.167 3.625L2.396 2.396L17.583 17.604ZM10 16.583Q10.896 16.583 11.708 16.365Q12.521 16.146 13.25 15.729L4.292 6.75Q3.875 7.479 3.646 8.292Q3.417 9.104 3.417 10Q3.417 12.729 5.344 14.656Q7.271 16.583 10 16.583ZM17 14.562 15.708 13.271Q16.125 12.542 16.354 11.719Q16.583 10.896 16.583 10Q16.583 7.271 14.656 5.344Q12.729 3.417 10 3.417Q9.104 3.417 8.292 3.646Q7.479 3.875 6.75 4.292L5.458 3Q6.458 2.354 7.594 2.01Q8.729 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.271 17.979 12.417Q17.625 13.562 17 14.562ZM11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771ZM8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Z"/></svg>', Ii = '<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>', Dn = '<svg viewBox="0 -960 960 960" width="24px"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Zm-40-60v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"/></svg>', Ce = ["transparent", "black", "white", "red", "green", "blue", "yellow"], Ue = [0, 1, 2], Wi = [[1, 0], [1, 2], [4, 6]], mt = "serif", Aa = 2, En = 3, Da = 4, he = "react-paint-", In = { strokeColor: { values: Ce, default: "black" }, fillColor: { values: Ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 } }, fi = { type: "picture", id: `${he}picture`, icon: vi, label: "Image", settings: { opacity: { min: 0, max: 100, step: 1, default: 100 } } }, Wn = { type: "brush", id: `${he}brush`, icon: Zn, label: "Brosse", settings: { strokeColor: { values: Ce, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 6, max: 20, step: 2, default: 10 }, lineDash: { values: Ue, default: 0 } } }, Rn = { type: "line", id: `${he}line`, icon: Tn, label: "Ligne", settings: { strokeColor: { values: Ce, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 }, lineArrow: { values: [0, 1, 2, 3], default: 0 } } }, Nn = { type: "polygon", id: `${he}polygon`, icon: gi, label: "Polygone", settings: { strokeColor: { values: Ce, default: "black" }, fillColor: { values: Ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 }, closedPoints: { default: 0 } } }, Bn = { type: "curve", id: `${he}curve`, icon: An, label: "Courbe", settings: { strokeColor: { values: Ce, default: "black" }, fillColor: { values: Ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 }, closedPoints: { default: 0 } } }, On = { type: "rect", id: `${he}rect`, icon: ui, label: "Rectangle", settings: In }, Fn = { type: "square", id: `${he}square`, icon: ui, label: "Carré", settings: { strokeColor: { values: Ce, default: "black" }, fillColor: { values: Ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 } } }, Yn = { type: "circle", id: `${he}circle`, icon: pi, label: "Cercle", settings: { strokeColor: { values: Ce, default: "black" }, fillColor: { values: Ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 } } }, Xn = { type: "ellipse", id: `${he}ellipse`, icon: pi, label: "Ellipse", settings: { strokeColor: { values: Ce, default: "black" }, fillColor: { values: Ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Ue, default: 0 } } }, $n = { type: "text", id: `${he}text`, icon: zn, label: "Texte", settings: { strokeColor: { values: Ce, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, fontFamily: { values: ["arial", "serif", "monospace"], default: mt }, fontBold: { values: [!1, !0], default: !1 }, fontItalic: { values: [!1, !0], default: !1 } } }, Oe = { id: `${he}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" }, dt = { id: `${he}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" }, ct = { id: `${he}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" }, ht = { id: `${he}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" }, _t = { id: `${he}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" }, Ri = { id: `${he}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" }, jt = { id: `${he}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" }, Kt = { id: `${he}move`, type: "move", icon: '<svg viewBox="0 -960 960 960"><path d="M412-48q-21.95 0-40.98-9Q352-66 338-83L48-434l27-28q17-17 41.5-20.5T162-473l126 74v-381q0-15.3 10.29-25.65Q308.58-816 323.79-816t25.71 10.35Q360-795.3 360-780v300h80v-396q0-15.3 10.29-25.65Q460.58-912 475.79-912t25.71 10.35Q512-891.3 512-876v396h80v-348q0-15.3 10.29-25.65Q612.58-864 627.79-864t25.71 10.35Q664-843.3 664-828v348h80v-252q0-15.3 10.29-25.65Q764.58-768 779.79-768t25.71 10.35Q816-747.3 816-732v540q0 60-42 102T672-48H412Z"/></svg>', label: "Move" }, Ni = { id: `${he}upload-picture`, type: "uploadpicture", icon: vi, label: "Upload picture" }, Un = 2, qn = "blue", Je = 14, Gn = [[0, 0], [0.5, 0], [1, 0], [1, 0.5], [1, 1], [0.5, 1], [0, 1], [0, 0.5]], _n = ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle", "group"], Ea = ["rect", "square", "circle", "ellipse", "picture", "text", "triangle", "brush", "group"], Ia = ["square", "circle", "picture", "text"], jn = "react-paint-canvas-drawcanvas", Kn = "react-paint-canvas-selectioncanvas", Bi = { layersManipulation: !0, grid: 0, canGrow: !1, canShrink: !0, withExport: !0, withLoadAndSave: !0, withUploadPicture: !0, withUrlPicture: !1, availableTools: [Wn, Rn, Nn, Bn, On, Fn, Yn, Xn, fi, $n], clearCallback: "empty", brushAlgo: "simple", isBrushShapeDoneOnMouseUp: !0, withFrameSelection: !0, withSkeleton: !0, canvasSelectionPadding: 0, size: "fixed", canZoom: "never", debug: !1 }, Wa = { canvasBackgroundColor: "white", canvasSelectionColor: qn, canvasSelectionWidth: Un }, Oi = 300, ai = (e, t) => {
4
4
  const i = { ...t };
5
5
  for (const n of e) Array.isArray(n) ? n[1].includes(i[n[0]]) && delete i[n[0]] : delete i[n];
6
6
  return i;
@@ -12,56 +12,56 @@ const Vn = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.70
12
12
  const n = { ...t };
13
13
  for (const a in i) i.hasOwnProperty(a) && (n.hasOwnProperty(a) ? n[a] = e(n[a], i[a], a) ?? Ie(e, n[a], i[a]) : n[a] = i[a]);
14
14
  return n;
15
- }, Kn = (e, t) => {
15
+ }, Jn = (e, t) => {
16
16
  if (e === t) return !0;
17
17
  if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1;
18
18
  const i = Object.keys(e), n = Object.keys(t);
19
19
  if (i.length !== n.length) return !1;
20
- for (const a of i) if (!n.includes(a) || !Kn(e[a], t[a])) return !1;
20
+ for (const a of i) if (!n.includes(a) || !Jn(e[a], t[a])) return !1;
21
21
  return !0;
22
- }, Jt = {}, ue = (e = "") => (Jt[e] || (Jt[e] = 0), `${e}${++Jt[e]}`), We = (e, t, i) => Math.max(t, Math.min(e, i)), Jn = () => typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), ea = (e) => {
22
+ }, Jt = {}, ue = (e = "") => (Jt[e] || (Jt[e] = 0), `${e}${++Jt[e]}`), We = (e, t, i) => Math.max(t, Math.min(e, i)), ea = () => typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), ta = (e) => {
23
23
  e.reset(), e.lineCap = "round", e.lineJoin = "round";
24
24
  }, xe = (e, t = {}) => {
25
- const { lineCap: i = "round", fillColor: n = "transparent", opacity: a = 100, strokeColor: o = Un, lineWidth: d = $n, lineDash: r = 0, shadowColor: s = "transparent", shadowBlur: l = 0 } = t;
26
- e.lineCap = i, e.globalAlpha = a / 100, e.fillStyle = n, e.strokeStyle = o, e.lineWidth = d, e.setLineDash(r === 0 ? [] : [Ii[r][0] * d, Ii[r][1] * d]), e.shadowColor = s, e.shadowBlur = l;
25
+ const { lineCap: i = "round", fillColor: n = "transparent", opacity: a = 100, strokeColor: o = qn, lineWidth: d = Un, lineDash: r = 0, shadowColor: s = "transparent", shadowBlur: l = 0 } = t;
26
+ e.lineCap = i, e.globalAlpha = a / 100, e.fillStyle = n, e.strokeStyle = o, e.lineWidth = d, e.setLineDash(r === 0 ? [] : [Wi[r][0] * d, Wi[r][1] * d]), e.shadowColor = s, e.shadowBlur = l;
27
27
  }, lt = (e, t, i, n) => {
28
28
  e.save(), e.scale(t.canvasSize.scaleRatio, t.canvasSize.scaleRatio), e.translate(t.canvasOffset[0], t.canvasOffset[1]), i && n && (e.translate(n[0], n[1]), e.rotate(i), e.translate(-n[0], -n[1]));
29
- }, si = (e) => 180 * e / Math.PI, ta = (e, t) => {
29
+ }, si = (e) => 180 * e / Math.PI, ia = (e, t) => {
30
30
  const i = t.x - Math.min(Math.max(t.x, e.x), e.x + e.width), n = t.y - Math.min(Math.max(t.y, e.y), e.y + e.height);
31
31
  return Math.sqrt(i * i + n * n) <= t.radius;
32
32
  }, le = ({ origin: e = [0, 0], point: t, rotation: i = 0 }) => {
33
33
  if (i === 0) return t;
34
34
  const n = [t[0] - e[0], t[1] - e[1]], a = n[1] * Math.cos(i) - n[0] * Math.sin(i);
35
35
  return [n[1] * Math.sin(i) + n[0] * Math.cos(i) + e[0], a + e[1]];
36
- }, Oi = (e) => (e + 2 * Math.PI) % (2 * Math.PI), Fi = ({ targetVector: [e, t], radian: i = !0, originVector: n }) => {
37
- const a = Oi(Math.atan2(t[1] - e[1], t[0] - e[0]));
36
+ }, Fi = (e) => (e + 2 * Math.PI) % (2 * Math.PI), Yi = ({ targetVector: [e, t], radian: i = !0, originVector: n }) => {
37
+ const a = Fi(Math.atan2(t[1] - e[1], t[0] - e[0]));
38
38
  if (n) {
39
- const [o, d] = n, r = Math.atan2(d[1] - o[1], d[0] - o[0]), s = Oi(a - r);
39
+ const [o, d] = n, r = Math.atan2(d[1] - o[1], d[0] - o[0]), s = Fi(a - r);
40
40
  return i ? s : si(s);
41
41
  }
42
42
  return i ? a : si(a);
43
- }, ia = (e, t) => Math.sqrt((e[0] - t[0]) ** 2 + (e[1] - t[1]) ** 2), et = (e, t, i) => {
43
+ }, na = (e, t) => Math.sqrt((e[0] - t[0]) ** 2 + (e[1] - t[1]) ** 2), et = (e, t, i) => {
44
44
  const n = le({ origin: t.computed.center, point: e.computed.center, rotation: t.rotation ?? 0 }), a = (n[0] - (e.computed.borders.width / 2 - i.settings.selectionPadding) - (i.originalBorders.x + i.settings.selectionPadding)) * i.widthMultiplier, o = (n[1] - (e.computed.borders.height / 2 - i.settings.selectionPadding) - (i.originalBorders.y + i.settings.selectionPadding)) * i.heightMultiplier;
45
45
  return { x: i.newBorderX + i.settings.selectionPadding + (i.isXinverted ? i.newBorderWidth - 2 * i.settings.selectionPadding - (e.computed.borders.width - 2 * i.settings.selectionPadding || 1) * i.widthMultiplier - a : a), y: i.newBorderY + i.settings.selectionPadding + (i.isYinverted ? i.newBorderHeight - 2 * i.settings.selectionPadding - (e.computed.borders.height - 2 * i.settings.selectionPadding || 1) * i.heightMultiplier - o : o) };
46
46
  }, tt = (e, t, i, n, a) => le({ origin: e.groupCenter, point: [t + n / 2, i + a / 2], rotation: -e.rotation }), mi = (e, { selectionPadding: t }) => {
47
- const i = e.points.flat(), n = Math.min(...i.map((s) => s[0])), a = Math.min(...i.map((s) => s[1])), o = i.map((s) => De(s, n, a, e.scaleX, e.scaleY)), d = Math.max(...o.map((s) => s[0])) + t, r = Math.max(...o.map((s) => s[1])) + t;
47
+ const i = e.points.flat(), n = Math.min(...i.map((s) => s[0])), a = Math.min(...i.map((s) => s[1])), o = i.map((s) => Ee(s, n, a, e.scaleX, e.scaleY)), d = Math.max(...o.map((s) => s[0])) + t, r = Math.max(...o.map((s) => s[1])) + t;
48
48
  return { x: n - t, width: d - n + t, y: a - t, height: r - a + t };
49
- }, pt = (e, t) => {
50
- const i = Na(e, t), n = ((a, o) => Be(a, mi, o))(e, t);
51
- return { ...e, path: i, selection: gt(i, n, t), computed: n };
52
- }, Wa = pt, Ve = (e, t = 2) => Math.round(e * 10 ** t) / 10 ** t, De = (e, t, i, n = 1, a = 1) => [t + (e[0] - t) * n, i + (e[1] - i) * a], we = (e, t, i = 0) => {
49
+ }, ut = (e, t) => {
50
+ const i = Ba(e, t), n = ((a, o) => Be(a, mi, o))(e, t);
51
+ return { ...e, path: i, selection: pt(i, n, t), computed: n };
52
+ }, Ra = ut, Ve = (e, t = 2) => Math.round(e * 10 ** t) / 10 ** t, Ee = (e, t, i, n = 1, a = 1) => [t + (e[0] - t) * n, i + (e[1] - i) * a], we = (e, t, i = 0) => {
53
53
  if (!t.gridGap) return Ve(e);
54
54
  const n = e + i, a = n >= 0 ? t.gridGap : -t.gridGap;
55
55
  return n + a / 2 - (n + a / 2) % a - i;
56
- }, Ra = (e, t, i, n, a, o, d) => {
57
- if (n.mode === "translate") return pe(va(i, n.originalShape, n.cursorStartPosition, a, o), a);
56
+ }, Na = (e, t, i, n, a, o, d) => {
57
+ if (n.mode === "translate") return pe(ma(i, n.originalShape, n.cursorStartPosition, a, o), a);
58
58
  if (n.mode === "rotate") {
59
- const r = n.originalShape.computed.center[0] - n.cursorStartPosition[0], s = n.originalShape.computed.center[1] - n.cursorStartPosition[1], l = n.originalShape.computed.center[0] - i[0], c = n.originalShape.computed.center[1] - i[1], h = ((v, f, g) => f.gridGap || g ? v + Math.PI / 18 / 2 - (v + Math.PI / 18 / 2) % (Math.PI / 18) : Ve(v, 3))(Math.atan2(c, l) - Math.atan2(s, r), a, o), u = _(n.originalShape).map((v) => Ne(po(v, h, n.originalShape.computed.center), a));
59
+ const r = n.originalShape.computed.center[0] - n.cursorStartPosition[0], s = n.originalShape.computed.center[1] - n.cursorStartPosition[1], l = n.originalShape.computed.center[0] - i[0], h = n.originalShape.computed.center[1] - i[1], c = ((f, v, p) => v.gridGap || p ? f + Math.PI / 18 / 2 - (f + Math.PI / 18 / 2) % (Math.PI / 18) : Ve(f, 3))(Math.atan2(h, l) - Math.atan2(s, r), a, o), u = Y(n.originalShape).map((f) => Ne(go(f, c, n.originalShape.computed.center), a));
60
60
  return pe(u, a);
61
61
  }
62
- return n.mode === "resize" ? pe(go(e, i, n.originalShape, n, a, o, d), a) : n.mode === "brush" ? pe(_(t).map((r) => ((s, l, c) => {
63
- const h = { ...s, points: Le(s.points.length - 1, [...s.points[s.points.length - 1], [Math.round(l[0]), Math.round(l[1])]], s.points) };
64
- return pt(h, c);
62
+ return n.mode === "resize" ? pe(vo(e, i, n.originalShape, n, a, o, d), a) : n.mode === "brush" ? pe(Y(t).map((r) => ((s, l, h) => {
63
+ const c = { ...s, points: Le(s.points.length - 1, [...s.points[s.points.length - 1], [Math.round(l[0]), Math.round(l[1])]], s.points) };
64
+ return ut(c, h);
65
65
  })(r, i, a)), a) : t;
66
66
  }, yt = (e) => {
67
67
  const t = new Path2D();
@@ -72,65 +72,62 @@ const Vn = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.70
72
72
  }, Zt = (e) => {
73
73
  const t = new Path2D();
74
74
  return t.moveTo(...e.points[0]), t.lineTo(...e.points[1]), t;
75
- }, Na = (e, { brushAlgo: t }) => {
76
- if (e.points.length < 1 || e.style?.strokeColor === "transparent") return;
77
- const i = e.points.flat(), n = i.map((s) => s[0]), a = i.map((s) => s[1]), o = Math.min(...n), d = Math.min(...a), r = new Path2D();
78
- for (const s of e.points) {
79
- if (!s.length) return;
80
- if (s.length === 1) r.rect(...De(s[0], o, d, e.scaleX, e.scaleY), 1, 1);
81
- else if (r.moveTo(...De(s[0], o, d, e.scaleX, e.scaleY)), t === "quadratic") {
82
- for (let l = 0; l < s.slice(1).length - 2; l++) {
83
- const c = De(s[l], o, d, e.scaleX, e.scaleY), h = De(s[l + 1], o, d, e.scaleX, e.scaleY), u = (c[0] + h[0]) / 2, v = (c[1] + h[1]) / 2;
84
- r.quadraticCurveTo(...c, u, v);
85
- }
86
- r.quadraticCurveTo(...De(s[s.length - 2], o, d, e.scaleX, e.scaleY), ...De(s[s.length - 1], o, d, e.scaleX, e.scaleY));
87
- } else for (const l of s.slice(1)) r.lineTo(...De(l, o, d, e.scaleX, e.scaleY));
88
- }
89
- return r;
90
- }, Ba = (e, t, i, n) => {
75
+ }, Ba = (e, { brushAlgo: t }) => {
76
+ const i = new Path2D();
77
+ if (e.points.length < 1) return i;
78
+ const n = e.points.flat(), a = n.map((s) => s[0]), o = n.map((s) => s[1]), d = Math.min(...a), r = Math.min(...o);
79
+ for (const s of e.points) if (s.length) if (s.length === 1) i.rect(...Ee(s[0], d, r, e.scaleX, e.scaleY), 1, 1);
80
+ else if (i.moveTo(...Ee(s[0], d, r, e.scaleX, e.scaleY)), t === "quadratic") {
81
+ for (let l = 0; l < s.slice(1).length - 2; l++) {
82
+ const h = Ee(s[l], d, r, e.scaleX, e.scaleY), c = Ee(s[l + 1], d, r, e.scaleX, e.scaleY), u = (h[0] + c[0]) / 2, f = (h[1] + c[1]) / 2;
83
+ i.quadraticCurveTo(...h, u, f);
84
+ }
85
+ i.quadraticCurveTo(...Ee(s[s.length - 2], d, r, e.scaleX, e.scaleY), ...Ee(s[s.length - 1], d, r, e.scaleX, e.scaleY));
86
+ } else for (const l of s.slice(1)) i.lineTo(...Ee(l, d, r, e.scaleX, e.scaleY));
87
+ return i;
88
+ }, Oa = (e, t, i, n) => {
91
89
  const a = (w) => (1 - w) ** 3 * e[0] + 3 * (1 - w) ** 2 * w * t[0] + 3 * (1 - w) * w ** 2 * i[0] + w ** 3 * n[0], o = (w) => (1 - w) ** 3 * e[1] + 3 * (1 - w) ** 2 * w * t[1] + 3 * (1 - w) * w ** 2 * i[1] + w ** 3 * n[1], d = (w, L, D) => {
92
90
  const V = w - 2 * L + D, x = -2 * w + 2 * L, Z = w;
93
91
  if (Math.abs(V) < 1e-10) {
94
92
  if (Math.abs(x) < 1e-10) return [];
95
- const q = -Z / x;
96
- return q > 0 && q < 1 ? [q] : [];
93
+ const G = -Z / x;
94
+ return G > 0 && G < 1 ? [G] : [];
97
95
  }
98
96
  const A = x * x - 4 * V * Z;
99
97
  if (A < 0) return [];
100
- const H = Math.sqrt(A), F = (-x - H) / (2 * V), I = (-x + H) / (2 * V), W = [];
101
- return F > 0 && F < 1 && W.push(F), I > 0 && I < 1 && I !== F && W.push(I), W;
102
- }, r = e[0], s = t[0], l = i[0], c = n[0], h = e[1], u = t[1], v = i[1], f = n[1], g = d(s - r, l - s, c - l), Q = d(u - h, v - u, f - v);
103
- let M = Math.min(e[0], n[0]), b = Math.max(e[0], n[0]), S = Math.min(e[1], n[1]), p = Math.max(e[1], n[1]);
104
- for (const w of g) {
98
+ const H = Math.sqrt(A), F = (-x - H) / (2 * V), E = (-x + H) / (2 * V), W = [];
99
+ return F > 0 && F < 1 && W.push(F), E > 0 && E < 1 && E !== F && W.push(E), W;
100
+ }, r = e[0], s = t[0], l = i[0], h = n[0], c = e[1], u = t[1], f = i[1], v = n[1], p = d(s - r, l - s, h - l), S = d(u - c, f - u, v - f);
101
+ let C = Math.min(e[0], n[0]), b = Math.max(e[0], n[0]), Q = Math.min(e[1], n[1]), g = Math.max(e[1], n[1]);
102
+ for (const w of p) {
105
103
  const L = a(w);
106
- M = Math.min(M, L), b = Math.max(b, L);
104
+ C = Math.min(C, L), b = Math.max(b, L);
107
105
  }
108
- for (const w of Q) {
106
+ for (const w of S) {
109
107
  const L = o(w);
110
- S = Math.min(S, L), p = Math.max(p, L);
108
+ Q = Math.min(Q, L), g = Math.max(g, L);
111
109
  }
112
- return { minX: M, maxX: b, minY: S, maxY: p };
113
- }, yi = (e, t) => e.style?.closedPoints === 1 && t.length > 2 ? [t[t.length - 2], ...t, t[0], t[1]] : [t[0], ...t, t[t.length - 1]], Si = (e, t, i, n) => ({ cp1: [t[0] + (i[0] - e[0]) / 6, t[1] + (i[1] - e[1]) / 6], cp2: [i[0] - (n[0] - t[0]) / 6, i[1] - (n[1] - t[1]) / 6] }), na = (e) => {
114
- const t = e.tempPoint ? [...e.points, e.tempPoint] : e.points;
115
- if (t.length < 2) return;
116
- const i = new Path2D();
117
- i.moveTo(...t[0]);
118
- for (const n of t.slice(1)) i.lineTo(...n);
119
- return t.length > 2 && e.style?.closedPoints === 1 && i.lineTo(...t[0]), i;
120
- }, Oa = (e) => {
110
+ return { minX: C, maxX: b, minY: Q, maxY: g };
111
+ }, yi = (e, t) => e.style?.closedPoints === 1 && t.length > 2 ? [t[t.length - 2], ...t, t[0], t[1]] : [t[0], ...t, t[t.length - 1]], Si = (e, t, i, n) => ({ cp1: [t[0] + (i[0] - e[0]) / 6, t[1] + (i[1] - e[1]) / 6], cp2: [i[0] - (n[0] - t[0]) / 6, i[1] - (n[1] - t[1]) / 6] }), aa = (e) => {
112
+ const t = new Path2D(), i = e.tempPoint ? [...e.points, e.tempPoint] : e.points;
113
+ if (i.length < 2) return t;
114
+ t.moveTo(...i[0]);
115
+ for (const n of i.slice(1)) t.lineTo(...n);
116
+ return i.length > 2 && e.style?.closedPoints === 1 && t.lineTo(...i[0]), t;
117
+ }, Fa = (e) => {
121
118
  const t = new Path2D();
122
119
  return t.moveTo(...e.points[0]), t.lineTo(...e.points[1]), t.lineTo(...e.points[2]), t.lineTo(...e.points[0]), t;
123
- }, Fa = (e, t) => ({ x: t.x - (e.style?.lineWidth ?? 0) / 2, y: t.y - (e.style?.lineWidth ?? 0) / 2, width: t.width + (e.style?.lineWidth ?? 0), height: t.height + (e.style?.lineWidth ?? 0) }), Be = (e, t, i, n = Fa) => {
124
- const a = t(e, i), o = n(e, a, i), d = [a.x + a.width / 2, a.y + a.height / 2], r = ((s, l, c = 0) => {
125
- if (c === 0) return s;
126
- const h = [[s.x, s.y], [s.x + s.width, s.y], [s.x + s.width, s.y + s.height], [s.x, s.y + s.height]].map((f) => le({ point: f, origin: l, rotation: c })), u = Math.min(...h.map((f) => f[0])), v = Math.min(...h.map((f) => f[1]));
127
- return { x: u, y: v, width: Math.max(...h.map((f) => f[0])) - u, height: Math.max(...h.map((f) => f[1])) - v };
120
+ }, Ya = (e, t) => ({ x: t.x - (e.style?.lineWidth ?? 0) / 2, y: t.y - (e.style?.lineWidth ?? 0) / 2, width: t.width + (e.style?.lineWidth ?? 0), height: t.height + (e.style?.lineWidth ?? 0) }), Be = (e, t, i, n = Ya) => {
121
+ const a = t(e, i), o = n(e, a, i), d = [a.x + a.width / 2, a.y + a.height / 2], r = ((s, l, h = 0) => {
122
+ if (h === 0) return s;
123
+ const c = [[s.x, s.y], [s.x + s.width, s.y], [s.x + s.width, s.y + s.height], [s.x, s.y + s.height]].map((v) => le({ point: v, origin: l, rotation: h })), u = Math.min(...c.map((v) => v[0])), f = Math.min(...c.map((v) => v[1]));
124
+ return { x: u, y: f, width: Math.max(...c.map((v) => v[0])) - u, height: Math.max(...c.map((v) => v[1])) - f };
128
125
  })(o, d, e.rotation);
129
126
  return { borders: a, outerBorders: o, center: d, boundingBox: r };
130
- }, gt = (e, t, i) => {
127
+ }, pt = (e, t, i) => {
131
128
  const { borders: n } = t;
132
- return { border: yt(n), shapePath: e, line: Zt({ points: [[n.x + n.width / 2, n.y], [n.x + n.width / 2, n.y - 23 / i.canvasSize.scaleRatio]] }), anchors: [Vt({ x: n.x + n.width / 2, y: n.y - 23 / i.canvasSize.scaleRatio, radius: 7 / i.canvasSize.scaleRatio }), ...qn.map((a) => Vt({ x: n.x + n.width * a[0], y: n.y + n.height * a[1], radius: 7 / i.canvasSize.scaleRatio }))] };
133
- }, Yi = ({ borderStart: e, borderSize: t, vector: i, settings: n, invertedAxe: a, anchor: o }) => {
129
+ return { type: "rect", border: yt(n), shapePath: e, line: Zt({ points: [[n.x + n.width / 2, n.y], [n.x + n.width / 2, n.y - 23 / i.canvasSize.scaleRatio]] }), anchors: [Vt({ x: n.x + n.width / 2, y: n.y - 23 / i.canvasSize.scaleRatio, radius: 7 / i.canvasSize.scaleRatio }), ...Gn.map((a) => Vt({ x: n.x + n.width * a[0], y: n.y + n.height * a[1], radius: 7 / i.canvasSize.scaleRatio }))] };
130
+ }, Xi = ({ borderStart: e, borderSize: t, vector: i, settings: n, invertedAxe: a, anchor: o }) => {
134
131
  switch (o) {
135
132
  case 0: {
136
133
  if (a) {
@@ -151,96 +148,109 @@ const Vn = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.70
151
148
  default:
152
149
  return [0, 0];
153
150
  }
154
- }, Ya = ({ borderX: e, borderWidth: t, borderY: i, borderHeight: n, center: a, originalShape: o }) => {
151
+ }, Xa = ({ borderX: e, borderWidth: t, borderY: i, borderHeight: n, center: a, originalShape: o }) => {
155
152
  const d = [e + t / 2 - a[0], i + n / 2 - a[1]], [r, s] = le({ point: d, rotation: -(o.rotation ?? 0) });
156
153
  return { borderX: Ve(e + r - d[0]), borderWidth: Ve(t), borderY: Ve(i + s - d[1]), borderHeight: Ve(n) };
157
- }, Xa = (e, t, i, n) => {
154
+ }, $a = (e, t, i, n) => {
158
155
  const a = t.x + t.width / 2, o = t.y + t.height / 2, d = i ? 2 * e.borderWidth + t.width : Math.abs(t.width + 2 * (e.borderWidth - t.width)), r = n ? 2 * e.borderHeight + t.height : Math.abs(t.height + 2 * (e.borderHeight - t.height));
159
156
  return { ...e, borderHeight: r, borderWidth: d, borderX: a - d / 2, borderY: o - r / 2 };
160
157
  }, it = (e, t, i, n, a = !1, o = !1) => {
161
- const { center: d, borders: r } = t.computed, s = le({ origin: d, point: e, rotation: t.rotation }), l = i.anchor[0] === 0 && s[0] >= r.x + r.width - n.selectionPadding || i.anchor[0] === 1 && s[0] <= r.x + n.selectionPadding, c = i.anchor[1] === 0 && s[1] >= r.y + r.height - n.selectionPadding || i.anchor[1] === 1 && s[1] <= r.y + n.selectionPadding, h = [we(s[0], n, i.anchor[0] === 0 && !l || i.anchor[0] === 1 && l ? n.selectionPadding : -n.selectionPadding), we(s[1], n, i.anchor[1] === 0 && !c || i.anchor[1] === 1 && c ? n.selectionPadding : -n.selectionPadding)], u = n.gridGap ? [i.anchor[0] === 0 ? r.x : i.anchor[0] === 0.5 ? r.x + r.width / 2 : r.x + r.width, i.anchor[1] === 0 ? r.y : i.anchor[1] === 0.5 ? r.y + r.height / 2 : r.y + r.height] : le({ origin: d, point: i.cursorStartPosition, rotation: t.rotation }), v = [h[0] - u[0], h[1] - u[1]], [f, g] = Yi({ borderStart: r.x, borderSize: r.width, vector: v[0], settings: n, invertedAxe: l, anchor: i.anchor[0] }), [Q, M] = Yi({ borderStart: r.y, borderSize: r.height, vector: v[1], settings: n, invertedAxe: c, anchor: i.anchor[1] }), b = a ? ((S, p, w, L, D, V, x, Z, A, H, F) => {
162
- const { selectionPadding: I } = F, W = "ratio" in A && A.ratio ? A.ratio : (S.width - 2 * I || 1) / (S.height - 2 * I || 1), q = (L - 2 * I) / (V - 2 * I);
163
- let G, z, y, C;
164
- return H.anchor[0] !== 0.5 && H.anchor[1] !== 0.5 ? q < W ? (z = D, C = V, y = (V - 2 * I) * W + 2 * I, G = H.anchor[0] === 0 ? x ? S.x + S.width - 2 * I : S.x + (S.width - y) : x ? S.x - y + 2 * I : S.x) : (G = w, y = L, C = (L - 2 * I) / W + 2 * I, z = H.anchor[1] === 0 ? Z ? S.y + S.height - 2 * I : S.y + (S.height - C) : Z ? S.y - C + 2 * I : S.y) : H.anchor[0] !== 0.5 ? (G = w, y = L, C = (L - 2 * I) / W + 2 * I, z = S.y + (S.height - C) / 2) : (z = D, C = V, y = (V - 2 * I) * W + 2 * I, G = S.x + (S.width - y) / 2), { borderX: G, borderWidth: y, borderY: z, borderHeight: C, center: p, originalShape: A };
165
- })(r, d, f, g, Q, M, l, c, t, i, n) : { borderX: f, borderWidth: g, borderY: Q, borderHeight: M, center: d, originalShape: t };
166
- return { ...Ya(o ? Xa(b, r, l, c) : b), isXinverted: l, isYinverted: c };
158
+ const { center: d, borders: r } = t.computed, s = le({ origin: d, point: e, rotation: t.rotation }), l = i.anchor[0] === 0 && s[0] >= r.x + r.width - n.selectionPadding || i.anchor[0] === 1 && s[0] <= r.x + n.selectionPadding, h = i.anchor[1] === 0 && s[1] >= r.y + r.height - n.selectionPadding || i.anchor[1] === 1 && s[1] <= r.y + n.selectionPadding, c = [we(s[0], n, i.anchor[0] === 0 && !l || i.anchor[0] === 1 && l ? n.selectionPadding : -n.selectionPadding), we(s[1], n, i.anchor[1] === 0 && !h || i.anchor[1] === 1 && h ? n.selectionPadding : -n.selectionPadding)], u = n.gridGap ? [i.anchor[0] === 0 ? r.x : i.anchor[0] === 0.5 ? r.x + r.width / 2 : r.x + r.width, i.anchor[1] === 0 ? r.y : i.anchor[1] === 0.5 ? r.y + r.height / 2 : r.y + r.height] : le({ origin: d, point: i.cursorStartPosition, rotation: t.rotation }), f = [c[0] - u[0], c[1] - u[1]], [v, p] = Xi({ borderStart: r.x, borderSize: r.width, vector: f[0], settings: n, invertedAxe: l, anchor: i.anchor[0] }), [S, C] = Xi({ borderStart: r.y, borderSize: r.height, vector: f[1], settings: n, invertedAxe: h, anchor: i.anchor[1] }), b = a ? ((Q, g, w, L, D, V, x, Z, A, H, F) => {
159
+ const { selectionPadding: E } = F, W = "ratio" in A && A.ratio ? A.ratio : (Q.width - 2 * E || 1) / (Q.height - 2 * E || 1), G = (L - 2 * E) / (V - 2 * E);
160
+ let _, z, y, M;
161
+ return H.anchor[0] !== 0.5 && H.anchor[1] !== 0.5 ? G < W ? (z = D, M = V, y = (V - 2 * E) * W + 2 * E, _ = H.anchor[0] === 0 ? x ? Q.x + Q.width - 2 * E : Q.x + (Q.width - y) : x ? Q.x - y + 2 * E : Q.x) : (_ = w, y = L, M = (L - 2 * E) / W + 2 * E, z = H.anchor[1] === 0 ? Z ? Q.y + Q.height - 2 * E : Q.y + (Q.height - M) : Z ? Q.y - M + 2 * E : Q.y) : H.anchor[0] !== 0.5 ? (_ = w, y = L, M = (L - 2 * E) / W + 2 * E, z = Q.y + (Q.height - M) / 2) : (z = D, M = V, y = (V - 2 * E) * W + 2 * E, _ = Q.x + (Q.width - y) / 2), { borderX: _, borderWidth: y, borderY: z, borderHeight: M, center: g, originalShape: A };
162
+ })(r, d, v, p, S, C, l, h, t, i, n) : { borderX: v, borderWidth: p, borderY: S, borderHeight: C, center: d, originalShape: t };
163
+ return { ...Xa(o ? $a(b, r, l, h) : b), isXinverted: l, isYinverted: h };
167
164
  }, zt = (e, t) => {
168
165
  const i = yt(e), n = ((a, o) => Be(a, Qi, o))(e, t);
169
- return { ...e, path: i, computed: n, selection: gt(i, n, t) };
170
- }, $a = zt, aa = (e, t, i, n = 0, a = 0) => {
166
+ return { ...e, path: i, computed: n, selection: pt(i, n, t) };
167
+ }, Ua = zt, oa = (e, t, i, n = 0, a = 0) => {
171
168
  const o = { toolId: e.id, type: e.type, id: ue(`${e.type}_`), x: t[0], y: t[1], width: n, height: a, style: { opacity: e.settings.opacity.default, fillColor: e.settings.fillColor.default, strokeColor: e.settings.strokeColor.default, lineWidth: e.settings.lineWidth.default, lineDash: e.settings.lineDash.default } };
172
169
  return zt(o, i);
173
- }, Ua = (e, t) => {
174
- e.globalAlpha !== 0 && t.path && (t.style?.fillColor !== "transparent" && e.fill(t.path), t.style?.strokeColor !== "transparent" && e.stroke(t.path));
175
- }, Qi = (e, t) => ({ x: e.x - t.selectionPadding, width: e.width + 2 * t.selectionPadding, y: e.y - t.selectionPadding, height: e.height + 2 * t.selectionPadding }), Xi = (e, t, i, [n, a] = [!1, !1]) => {
170
+ }, qa = (e, t) => {
171
+ e.globalAlpha !== 0 && (t.style?.fillColor !== "transparent" && e.fill(t.path), t.style?.strokeColor !== "transparent" && e.stroke(t.path));
172
+ }, Qi = (e, t) => ({ x: e.x - t.selectionPadding, width: e.width + 2 * t.selectionPadding, y: e.y - t.selectionPadding, height: e.height + 2 * t.selectionPadding }), $i = (e, t, i, [n, a] = [!1, !1]) => {
176
173
  const o = e[0] === 0.5 ? i.x + i.width / 2 : e[0] === 0 ? i.x + (n ? 0 : i.width) : i.x + (n ? i.width : 0), d = e[1] === 0.5 ? i.y + i.height / 2 : e[1] === 0 ? i.y + (a ? 0 : i.height) : i.y + (a ? i.height : 0);
177
174
  return ri([o, d], i.rotation ?? 0, t);
178
- }, $i = (e, t, i, n, a, o, d, r) => {
175
+ }, Ui = (e, t, i, n, a, o, d, r = "replace") => {
179
176
  let s = !1;
180
177
  if (a) {
181
- s = ut(e, a, i, n, !0, o ? 20 : void 0);
182
- const c = ((h, u, v) => {
183
- if (h.mode === "translate") return { mode: "translate", cursorStartPosition: v, originalShape: u, hasBeenDuplicated: !1, dateStart: Date.now() };
184
- if (h.mode === "rotate") {
185
- const { center: f } = u.computed;
186
- return { mode: "rotate", cursorStartPosition: v, originalShape: u, center: [f[0], f[1]] };
178
+ s = ft(e, a, i, n, !0, o ? 20 : void 0);
179
+ const h = ((c, u, f) => {
180
+ if (c.mode === "translate") return { mode: "translate", cursorStartPosition: f, originalShape: u, hasBeenDuplicated: !1, dateStart: Date.now(), selectedShapesLengthAtMouseDown: Y(u).length };
181
+ if (c.mode === "rotate") {
182
+ const { center: v } = u.computed;
183
+ return { mode: "rotate", cursorStartPosition: f, originalShape: u, center: [v[0], v[1]], selectedShapesLengthAtMouseDown: Y(u).length };
187
184
  }
188
- return h.mode === "resize" ? { mode: "resize", cursorStartPosition: v, originalShape: u, anchor: h.anchor } : void 0;
185
+ return c.mode === "resize" ? { mode: "resize", cursorStartPosition: f, originalShape: u, anchor: c.anchor, selectedShapesLengthAtMouseDown: Y(u).length } : void 0;
189
186
  })(s || { mode: "default" }, a, i);
190
- if (c?.mode === "resize" || c?.mode === "rotate") return { shape: a, mode: c };
187
+ if (h?.mode === "resize" || h?.mode === "rotate") return { shape: a, mode: h };
191
188
  }
192
- const l = t.find((c) => _(a).find((h) => c.id === h?.id) ? s && r ? ut(e, c, i, n, !0, o ? 20 : void 0) : !!s : !!la(e, c, i, n));
189
+ const l = t.find((h) => Y(a).find((c) => h.id === c?.id) ? s && ft(e, h, i, n, !0, o ? 20 : void 0) : !!da(e, h, i, n)) ?? (s ? a : void 0);
190
+ if (a && a?.id === l?.id) return { shape: a, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: a, selectedShapesLengthAtMouseDown: Y(a).length } };
193
191
  if (l) {
194
- if (r) {
195
- const h = _(a).find((u) => u.id === l?.id) ? pe(qa(a, l), n) : pe(oa(a, [l]), n);
196
- return { shape: h, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: h } };
192
+ if (r === "add") {
193
+ const c = pe(sa(a, [l]), n);
194
+ return { shape: c, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: c, selectedShapesLengthAtMouseDown: Y(a).length } };
195
+ }
196
+ if (r === "remove") {
197
+ const c = pe(Ga(a, l), n);
198
+ return { shape: c, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: c, selectedShapesLengthAtMouseDown: Y(a).length } };
197
199
  }
198
- const c = _(a).find((h) => h.id === l?.id) ? a : pe([l], n);
199
- return { shape: c, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: c } };
200
+ const h = Y(a).find((c) => c.id === l?.id) ? a : pe([l], n);
201
+ return { shape: h, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: h, selectedShapesLengthAtMouseDown: Y(a).length } };
200
202
  }
201
- return r ? { shape: a, mode: { mode: d ? "selectionFrame" : "default" } } : { shape: void 0, mode: { mode: d ? "selectionFrame" : "default" } };
203
+ return { shape: r !== "replace" ? a : void 0, mode: { mode: d ? "selectionFrame" : "default" } };
202
204
  }, pe = (e, t) => {
203
205
  if (!e.length) return;
204
206
  if (e.length === 1) return e[0];
205
207
  const i = e.some((d) => d.rotation !== e[0].rotation) ? 0 : e[0]?.rotation ?? 0, n = ((d, r, s) => {
206
- const l = d.map((p) => [[p.computed.borders.x + s.selectionPadding, p.computed.borders.y + s.selectionPadding], [p.computed.borders.x - s.selectionPadding + p.computed.borders.width, p.computed.borders.y + s.selectionPadding], [p.computed.borders.x - s.selectionPadding + p.computed.borders.width, p.computed.borders.y - s.selectionPadding + p.computed.borders.height], [p.computed.borders.x + s.selectionPadding, p.computed.borders.y - s.selectionPadding + p.computed.borders.height]].map((w) => {
207
- const L = le({ point: [w[0], w[1]], origin: p.computed.center, rotation: -(p.rotation ?? 0) });
208
+ const l = d.map((g) => [[g.computed.borders.x + s.selectionPadding, g.computed.borders.y + s.selectionPadding], [g.computed.borders.x - s.selectionPadding + g.computed.borders.width, g.computed.borders.y + s.selectionPadding], [g.computed.borders.x - s.selectionPadding + g.computed.borders.width, g.computed.borders.y - s.selectionPadding + g.computed.borders.height], [g.computed.borders.x + s.selectionPadding, g.computed.borders.y - s.selectionPadding + g.computed.borders.height]].map((w) => {
209
+ const L = le({ point: [w[0], w[1]], origin: g.computed.center, rotation: -(g.rotation ?? 0) });
208
210
  return le({ point: [L[0], L[1]], origin: [0, 0], rotation: r });
209
- })), c = Math.min(...l.flatMap((p) => [p[0][0], p[1][0], p[2][0], p[3][0]])), h = Math.min(...l.flatMap((p) => [p[0][1], p[1][1], p[2][1], p[3][1]])), u = Math.max(...l.flatMap((p) => [p[0][0], p[1][0], p[2][0], p[3][0]])), v = Math.max(...l.flatMap((p) => [p[0][1], p[1][1], p[2][1], p[3][1]])), f = [(c + u) / 2, (h + v) / 2], g = le({ point: f, origin: [0, 0], rotation: -r }), Q = [f[0] - g[0], f[1] - g[1]], M = Ve(c - Q[0]), b = Ve(u - Q[0]), S = Ve(h - Q[1]);
210
- return { width: b - M, height: Ve(v - Q[1]) - S, x: M, y: S };
211
- })(e, i, t), a = aa({ id: "group_selection", type: "rect", settings: Dn }, [n.x, n.y], t, n.width, n.height), o = e.slice(1).reduce((d, r) => {
211
+ })), h = Math.min(...l.flatMap((g) => [g[0][0], g[1][0], g[2][0], g[3][0]])), c = Math.min(...l.flatMap((g) => [g[0][1], g[1][1], g[2][1], g[3][1]])), u = Math.max(...l.flatMap((g) => [g[0][0], g[1][0], g[2][0], g[3][0]])), f = Math.max(...l.flatMap((g) => [g[0][1], g[1][1], g[2][1], g[3][1]])), v = [(h + u) / 2, (c + f) / 2], p = le({ point: v, origin: [0, 0], rotation: -r }), S = [v[0] - p[0], v[1] - p[1]], C = Ve(h - S[0]), b = Ve(u - S[0]), Q = Ve(c - S[1]);
212
+ return { width: b - C, height: Ve(f - S[1]) - Q, x: C, y: Q };
213
+ })(e, i, t), a = oa({ id: "group_selection", type: "rect", settings: In }, [n.x, n.y], t, n.width, n.height), o = e.slice(1).reduce((d, r) => {
212
214
  const s = r.style ?? {}, l = {};
213
- for (const c in s) d[c] !== void 0 && s[c] !== void 0 && d[c] === s[c] && (l[c] = d[c]);
215
+ for (const h in s) d[h] !== void 0 && s[h] !== void 0 && d[h] === s[h] && (l[h] = d[h]);
214
216
  return l;
215
217
  }, e[0].style ?? {});
216
- return { id: e.map((d) => d.id).join("-"), type: "group", shapes: e, rotation: i, visible: !0, locked: !1, selection: a.selection, x: a.x, y: a.y, width: a.width, height: a.height, style: o, computed: a.computed };
217
- }, Ui = (e, t) => (i) => {
218
+ return { id: e.map((d) => d.id).join("-"), type: "group", shapes: e, rotation: i, visible: !0, locked: !1, selection: a.selection, x: a.x, y: a.y, width: a.width, height: a.height, style: o, computed: a.computed, path: a.path };
219
+ }, qi = (e, t) => (i) => {
218
220
  if (!i) return;
219
221
  const n = i.type === "group" ? i.shapes.map((a) => e(a, t)) : [e(i, t)];
220
222
  return pe(n, t);
221
- }, _ = (e) => e ? e.type === "group" ? e.shapes : [e] : [], oa = (e, t) => {
222
- const i = _(e);
223
+ }, Y = (e) => e ? e.type === "group" ? e.shapes : [e] : [], sa = (e, t) => {
224
+ const i = Y(e);
223
225
  return [.../* @__PURE__ */ new Set([...i, ...t])];
224
- }, qa = (e, t) => _(e).filter((i) => i.id !== t.id), sa = (e) => {
226
+ }, Ga = (e, t) => Y(e).filter((i) => i.id !== t.id), ra = (e) => {
225
227
  const { clientX: t = 0, clientY: i = 0 } = "touches" in e && e.touches[0] ? e.touches[0] : "changedTouches" in e && e.changedTouches[0] ? e.changedTouches[0] : "clientX" in e ? e : {};
226
228
  return { clientX: t, clientY: i };
227
- }, ra = (e, t, i) => {
228
- const { clientX: n, clientY: a } = sa(e), o = t.getBoundingClientRect();
229
+ }, la = (e, t, i) => {
230
+ const { clientX: n, clientY: a } = ra(e), o = t.getBoundingClientRect();
229
231
  return [(n - o.left) / i.scaleRatio, (a - o.top) / i.scaleRatio];
230
232
  }, st = (e, t, i) => {
231
- const { clientX: n, clientY: a } = sa(e), o = t?.getBoundingClientRect() ?? { left: 0, top: 0, width: i.canvasSize.width, height: i.canvasSize.height };
233
+ const { clientX: n, clientY: a } = ra(e), o = t?.getBoundingClientRect() ?? { left: 0, top: 0, width: i.canvasSize.width, height: i.canvasSize.height };
232
234
  return [(n - o.left) * (i.canvasSize.width / o.width) / i.canvasSize.scaleRatio - i.canvasOffset[0], (a - o.top) * (i.canvasSize.height / o.height) / i.canvasSize.scaleRatio - i.canvasOffset[1]];
233
- }, rt = (e) => "touches" in e, Re = (e, t, [i, n]) => le({ origin: [i, n], point: e, rotation: t }), ri = (e, t, [i, n]) => le({ origin: [i, n], point: e, rotation: -t }), Ct = (e, t, i) => i ? ta(e, { x: t[0], y: t[1], radius: i }) : ((n, a) => a[0] >= n.x && a[0] <= n.x + n.width && a[1] >= n.y && a[1] <= n.y + n.height)(e, t), ut = (e, t, i, n, a = !1, o = 0) => {
234
- if (t.locked) return !1;
235
- const { canvasSize: { scaleRatio: d } } = n, { borders: r, center: s } = t.computed, l = Re(i, t.rotation ?? 0, s), c = _(t).length > 1 ? t : _(t)[0];
236
- if (c && a) if (c.type === "line" || c.type === "polygon" || c.type === "curve") {
237
- for (let h = 0; h < c.points.length; h++) if (Ct({ x: c.points[h][0] - 7 / d, y: c.points[h][1] - 7 / d, width: Je / d, height: Je / d }, l, o)) return { mode: "resize", anchor: h };
238
- } else {
239
- if (Ct({ x: r.x + r.width / 2 - 7 / d, y: r.y - Je / d - 16 / d, width: Je / d, height: Je / d }, l, o)) return { mode: "rotate" };
240
- for (const h of qn) if (Ct({ x: r.x + r.width * h[0] - 7 / d, y: r.y + r.height * h[1] - 7 / d, width: Je / d, height: Je / d }, l, o)) return { mode: "resize", anchor: h };
235
+ }, rt = (e) => "touches" in e, Re = (e, t, [i, n]) => le({ origin: [i, n], point: e, rotation: t }), ri = (e, t, [i, n]) => le({ origin: [i, n], point: e, rotation: -t }), Ct = (e, t, i) => i ? ia(e, { x: t[0], y: t[1], radius: i }) : ((n, a) => a[0] >= n.x && a[0] <= n.x + n.width && a[1] >= n.y && a[1] <= n.y + n.height)(e, t), ft = (e, t, i, n, a = !1, o = 0) => {
236
+ const d = Y(t).length > 1 ? t : Y(t)[0];
237
+ if (!d || d.locked) return !1;
238
+ const { borders: r, center: s } = d.computed, l = Re(i, d.rotation ?? 0, s);
239
+ if (a) {
240
+ const h = ((c, u, f, v = 0) => {
241
+ const { canvasSize: { scaleRatio: p } } = f, { borders: S } = c.computed;
242
+ if (c.type === "line" || c.type === "polygon" || c.type === "curve") {
243
+ for (let C = 0; C < c.points.length; C++) if (Ct({ x: c.points[C][0] - 7 / p, y: c.points[C][1] - 7 / p, width: Je / p, height: Je / p }, u, v)) return { mode: "resize", anchor: C };
244
+ } else {
245
+ if (Ct({ x: S.x + S.width / 2 - 7 / p, y: S.y - Je / p - 16 / p, width: Je / p, height: Je / p }, u, v)) return { mode: "rotate" };
246
+ for (const C of Gn) if (Ct({ x: S.x + S.width * C[0] - 7 / p, y: S.y + S.height * C[1] - 7 / p, width: Je / p, height: Je / p }, u, v)) return { mode: "resize", anchor: C };
247
+ }
248
+ return !1;
249
+ })(d, l, n, o);
250
+ if (h) return h;
241
251
  }
242
- return (Ct(r, l, o) || !(t.type !== "curve" || !t.path || !e.isPointInPath(t.path, l[0], l[1]))) && { mode: "translate" };
243
- }, qi = (e, t, i, n, a = 50) => {
252
+ return d.selection?.type === "line" ? (e.lineWidth = (d.style?.lineWidth ?? 0) + 15 / n.canvasZoom, !!(bi(d, !0) ? e.isPointInPath(d.path, l[0], l[1]) : e.isPointInStroke(d.path, l[0], l[1])) && { mode: "translate" }) : !!Ct(r, l, 15 + o) && { mode: "translate" };
253
+ }, Gi = (e, t, i, n, a = 50) => {
244
254
  if (t.locked || t.points.length < 2) return !1;
245
255
  const { center: o } = t.computed, d = Re(i, t.rotation ?? 0, o);
246
256
  e.lineWidth = (t.style?.lineWidth ?? 0) + a / n.canvasZoom;
@@ -250,189 +260,189 @@ const Vn = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.70
250
260
  if (e.isPointInStroke(l, d[0], d[1])) return { lineIndex: s };
251
261
  }
252
262
  return !1;
253
- }, la = (e, t, i, n) => {
263
+ }, bi = (e, t = !1) => !(!t || !["curve", "polygon"].includes(e.type)) || e.style?.fillColor && e.style?.fillColor !== "transparent" || ["picture", "text"].includes(e.type), da = (e, t, i, n) => {
254
264
  if (t.locked) return !1;
255
265
  const { center: a } = t.computed, o = Re(i, t.rotation ?? 0, a);
256
- return t.path ? t.style?.fillColor && t.style?.fillColor !== "transparent" || ["picture", "text"].includes(t.type) ? !!e.isPointInPath(t.path, o[0], o[1]) && { mode: "translate" } : (e.lineWidth = (t.style?.lineWidth ?? 0) + 15 / n.canvasZoom, !!e.isPointInStroke(t.path, o[0], o[1]) && { mode: "translate" }) : ut(e, t, i, n, !1);
266
+ return e.lineWidth = (t.style?.lineWidth ?? 0) + 15 / n.canvasZoom, !!(bi(t) ? e.isPointInPath(t.path, o[0], o[1]) : e.isPointInStroke(t.path, o[0], o[1])) && { mode: "translate" };
257
267
  };
258
268
  function li(e, t) {
259
269
  const i = Math.max(e.x, t.x), n = Math.max(e.y, t.y), a = Math.min(e.x + (e.width || 1), t.x + (t.width || 1)), o = Math.min(e.y + (e.height || 1), t.y + (t.height || 1));
260
270
  if (i < a && n < o) return { x: i, y: n, width: a - i, height: o - n };
261
271
  }
262
- const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, checkFill: d }) => {
263
- for (let r = 0; r < n; r += n / 2) for (let s = 0; s < n; s += n / 2) for (let l = r + i.x; l < i.x + i.width; l += n) for (let c = s + i.y; c < i.y + i.height; c += n) {
264
- const h = Re([l, c], o, a);
265
- if (d ? e.isPointInPath(t, h[0], h[1]) : e.isPointInStroke(t, h[0], h[1])) return !0;
272
+ const _i = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, checkFill: d }) => {
273
+ for (let r = 0; r < n; r += n / 2) for (let s = 0; s < n; s += n / 2) for (let l = r + i.x; l < i.x + i.width; l += n) for (let h = s + i.y; h < i.y + i.height; h += n) {
274
+ const c = Re([l, h], o, a);
275
+ if (d ? e.isPointInPath(t, c[0], c[1]) : e.isPointInStroke(t, c[0], c[1])) return !0;
266
276
  }
267
277
  return !1;
268
- }, bi = (e, t, i, n) => ({ border: yt(i.borders), shapePath: e, anchors: [...t.points.map((a) => Vt({ x: a[0], y: a[1], radius: 7 / n.canvasSize.scaleRatio }))] }), Pe = [0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8], di = ({ size: e, zoom: t, newOffset: [i, n], canvasSize: a }) => e === "infinite" ? { zoom: t, offset: [i, n] } : t < 1 ? { zoom: t, offset: [-(a.realWidth - a.realWidth / t) / 2, -(a.realHeight - a.realHeight / t) / 2] } : { zoom: t, offset: [We(i, a.realWidth / t - a.realWidth, 0), We(n, a.realHeight / t - a.realHeight, 0)] }, ci = ({ size: e, canvasSize: t, currentOffset: i, currentZoom: n, zoom: a, centerPoint: o }) => {
278
+ }, wi = (e, t, i, n) => ({ type: "line", border: yt(i.borders), shapePath: e, anchors: [...t.points.map((a) => Vt({ x: a[0], y: a[1], radius: 7 / n.canvasSize.scaleRatio }))] }), Pe = [0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8], di = ({ size: e, zoom: t, newOffset: [i, n], canvasSize: a }) => e === "infinite" ? { zoom: t, offset: [i, n] } : t < 1 ? { zoom: t, offset: [-(a.realWidth - a.realWidth / t) / 2, -(a.realHeight - a.realHeight / t) / 2] } : { zoom: t, offset: [We(i, a.realWidth / t - a.realWidth, 0), We(n, a.realHeight / t - a.realHeight, 0)] }, ci = ({ size: e, canvasSize: t, currentOffset: i, currentZoom: n, zoom: a, centerPoint: o }) => {
269
279
  const d = e === "fixed" && a < 1 ? [t.realWidth / 2, t.realHeight / 2] : o, r = i[0] - (d[0] / n - d[0] / a), s = i[1] - (d[1] / n - d[1] / a);
270
280
  return { offset: e === "infinite" ? [r, s] : a < 1 ? [-(t.realWidth - t.realWidth / a) / 2, -(t.realHeight - t.realHeight / a) / 2] : [We(r, t.realWidth / a - t.realWidth, 0), We(s, t.realHeight / a - t.realHeight, 0)], zoom: a };
271
- }, da = (e) => {
281
+ }, ca = (e) => {
272
282
  const { canvasSize: { width: t, height: i, scaleRatioWithNoZoom: n }, canvasZoom: a, canvasOffset: o } = e;
273
283
  return { x: o[0] * a * n, y: o[1] * a * n, width: t * a, height: i * a };
274
- }, ca = (e, t) => {
284
+ }, ha = (e, t) => {
275
285
  const { canvasZoom: i, size: n } = t;
276
286
  if (n !== "fixed" || i >= 1) return;
277
- const a = da(t);
287
+ const a = ca(t);
278
288
  e.beginPath(), e.rect(a.x, a.y, a.width, a.height), e.closePath(), e.clip();
279
- }, vt = (e, t) => t.size !== "fixed" || e[0] > 0 && e[0] < t.canvasSize.realWidth && e[1] > 0 && e[1] < t.canvasSize.realHeight, Ga = (e, t) => ({ x: e.x - e.radius - t.selectionPadding, width: 2 * (e.radius + t.selectionPadding), y: e.y - e.radius - t.selectionPadding, height: 2 * (e.radius + t.selectionPadding) }), Tt = (e, t) => {
280
- const i = Vt(e), n = ((a, o) => Be(a, Ga, o))(e, t);
281
- return { ...e, path: i, selection: gt(i, n, t), computed: n };
282
- }, _a = Tt, St = (e, t) => {
283
- const i = na(e), n = ((a, o) => Be(a, At, o))(e, t);
284
- return { ...e, path: i, selection: bi(i, e, n, t), computed: n };
285
- }, ha = St, At = (e, t) => {
289
+ }, vt = (e, t) => t.size !== "fixed" || e[0] > 0 && e[0] < t.canvasSize.realWidth && e[1] > 0 && e[1] < t.canvasSize.realHeight, _a = (e, t) => ({ x: e.x - e.radius - t.selectionPadding, width: 2 * (e.radius + t.selectionPadding), y: e.y - e.radius - t.selectionPadding, height: 2 * (e.radius + t.selectionPadding) }), Tt = (e, t) => {
290
+ const i = Vt(e), n = ((a, o) => Be(a, _a, o))(e, t);
291
+ return { ...e, path: i, selection: pt(i, n, t), computed: n };
292
+ }, ja = Tt, St = (e, t) => {
293
+ const i = aa(e), n = ((a, o) => Be(a, At, o))(e, t);
294
+ return { ...e, path: i, selection: wi(i, e, n, t), computed: n };
295
+ }, ua = St, At = (e, t) => {
286
296
  const i = Math.min(...e.points.map((o) => o[0])) - t.selectionPadding, n = Math.max(...e.points.map((o) => o[0])) + t.selectionPadding, a = Math.min(...e.points.map((o) => o[1])) - t.selectionPadding;
287
297
  return { x: i, width: n - i, y: a, height: Math.max(...e.points.map((o) => o[1])) + t.selectionPadding - a };
288
- }, ja = (e, t, i, n) => {
298
+ }, Ka = (e, t, i, n) => {
289
299
  if (t < 0 || t > e.points.length - 1) return e;
290
300
  const a = [...e.points.slice(0, t + 1), i, ...e.points.slice(t + 1)];
291
301
  return St({ ...e, points: a }, n);
292
- }, _i = (e, t, i, n = !1) => {
302
+ }, ji = (e, t, i, n = !1) => {
293
303
  const a = [we(t[0], i), we(t[1], i)], o = Re(a, e.rotation ?? 0, e.computed.center), d = { ...e, points: n ? e.points : [...e.points, o], tempPoint: n ? o : void 0 };
294
304
  return St(d, i);
295
- }, Ka = (e, t, i) => {
305
+ }, Ja = (e, t, i) => {
296
306
  const n = e.tempPoint ? [...e.points, e.tempPoint] : e.points;
297
307
  if (n.length < 2) {
298
- const l = n[0] ?? [0, 0], c = i.selectionPadding;
299
- return { x: l[0] - c, y: l[1] - c, width: 2 * c, height: 2 * c };
308
+ const l = n[0] ?? [0, 0], h = i.selectionPadding;
309
+ return { x: l[0] - h, y: l[1] - h, width: 2 * h, height: 2 * h };
300
310
  }
301
311
  if (n.length < 3) return At({ ...e, points: n }, i);
302
312
  const a = yi(e, n);
303
313
  let o = Number.POSITIVE_INFINITY, d = Number.NEGATIVE_INFINITY, r = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
304
314
  for (let l = 1; l < a.length - 2; l++) {
305
- const c = a[l - 1], h = a[l], u = a[l + 1], v = a[l + 2], { cp1: f, cp2: g } = Si(c, h, u, v), Q = Ba(h, f, g, u);
306
- o = Math.min(o, Q.minX), d = Math.max(d, Q.maxX), r = Math.min(r, Q.minY), s = Math.max(s, Q.maxY);
315
+ const h = a[l - 1], c = a[l], u = a[l + 1], f = a[l + 2], { cp1: v, cp2: p } = Si(h, c, u, f), S = Oa(c, v, p, u);
316
+ o = Math.min(o, S.minX), d = Math.max(d, S.maxX), r = Math.min(r, S.minY), s = Math.max(s, S.maxY);
307
317
  }
308
318
  return Qi({ x: o, y: r, width: d - o, height: s - r }, i);
309
319
  }, Qt = (e, t) => {
310
320
  const i = ((a) => {
311
- const o = a.tempPoint ? [...a.points, a.tempPoint] : a.points;
312
- if (o.length < 2) return;
313
- if (o.length < 3) return na(a);
314
- const d = a.style?.closedPoints === 1 && o.length > 2, r = new Path2D();
315
- r.moveTo(...o[0]);
316
- const s = yi(a, o);
321
+ const o = new Path2D(), d = a.tempPoint ? [...a.points, a.tempPoint] : a.points;
322
+ if (d.length < 2) return o;
323
+ if (d.length < 3) return aa(a);
324
+ const r = a.style?.closedPoints === 1 && d.length > 2;
325
+ o.moveTo(...d[0]);
326
+ const s = yi(a, d);
317
327
  for (let l = 1; l < s.length - 2; l++) {
318
- const c = s[l - 1], h = s[l], u = s[l + 1], v = s[l + 2], { cp1: f, cp2: g } = Si(c, h, u, v);
319
- r.bezierCurveTo(f[0], f[1], g[0], g[1], u[0], u[1]);
328
+ const h = s[l - 1], c = s[l], u = s[l + 1], f = s[l + 2], { cp1: v, cp2: p } = Si(h, c, u, f);
329
+ o.bezierCurveTo(v[0], v[1], p[0], p[1], u[0], u[1]);
320
330
  }
321
- return d && r.closePath(), r;
322
- })(e), n = ((a, o) => Be(a, At, o, Ka))(e, t);
323
- return { ...e, path: i, selection: bi(i, e, n, t), computed: n };
324
- }, ua = Qt, Ja = (e, t, i, n) => {
331
+ return r && o.closePath(), o;
332
+ })(e), n = ((a, o) => Be(a, At, o, Ja))(e, t);
333
+ return { ...e, path: i, selection: wi(i, e, n, t), computed: n };
334
+ }, pa = Qt, eo = (e, t, i, n) => {
325
335
  if (t < 0 || t > e.points.length - 1) return e;
326
336
  const a = [...e.points.slice(0, t + 1), i, ...e.points.slice(t + 1)];
327
337
  return Qt({ ...e, points: a }, n);
328
- }, ji = (e, t, i, n = !1) => {
338
+ }, Ki = (e, t, i, n = !1) => {
329
339
  const a = [we(t[0], i), we(t[1], i)], o = e.computed.center, d = Re(a, e.rotation ?? 0, o), r = { ...e, points: n ? e.points : [...e.points, d], tempPoint: n ? d : void 0 };
330
340
  return Qt(r, i);
331
- }, eo = (e, t) => ({ x: e.x - e.radiusX - t.selectionPadding, width: 2 * (e.radiusX + t.selectionPadding), y: e.y - e.radiusY - t.selectionPadding, height: 2 * (e.radiusY + t.selectionPadding) }), Et = (e, t) => {
341
+ }, to = (e, t) => ({ x: e.x - e.radiusX - t.selectionPadding, width: 2 * (e.radiusX + t.selectionPadding), y: e.y - e.radiusY - t.selectionPadding, height: 2 * (e.radiusY + t.selectionPadding) }), Dt = (e, t) => {
332
342
  const i = ((a) => {
333
343
  const o = new Path2D();
334
344
  return o.ellipse(a.x, a.y, a.radiusX, a.radiusY, 0, 0, 2 * Math.PI), o;
335
- })(e), n = ((a, o) => Be(a, eo, o))(e, t);
336
- return { ...e, path: i, selection: gt(i, n, t), computed: n };
337
- }, to = Et, io = (e, t) => Be(e, At, t), Ki = (e, t) => ((i, n) => ({ ...i, path: Oa(i), computed: io(i, n) }))({ ...e, id: ue("triangle_"), type: "triangle" }, t), no = (e, t) => {
338
- e.globalAlpha !== 0 && t.path && (t.style?.fillColor !== "transparent" && e.fill(t.path), t.style?.strokeColor !== "transparent" && e.stroke(t.path));
339
- }, ao = (e, t) => ({ x: Math.min(e.points[0][0], e.points[1][0]) - t.selectionPadding, width: Math.abs(e.points[0][0] - e.points[1][0]) + 2 * t.selectionPadding, y: Math.min(e.points[0][1], e.points[1][1]) - t.selectionPadding, height: Math.abs(e.points[0][1] - e.points[1][1]) + 2 * t.selectionPadding }), Dt = (e, t) => {
345
+ })(e), n = ((a, o) => Be(a, to, o))(e, t);
346
+ return { ...e, path: i, selection: pt(i, n, t), computed: n };
347
+ }, io = Dt, no = (e, t) => Be(e, At, t), Ji = (e, t) => ((i, n) => ({ ...i, path: Fa(i), computed: no(i, n) }))({ ...e, id: ue("triangle_"), type: "triangle" }, t), ao = (e, t) => {
348
+ e.globalAlpha !== 0 && (t.style?.fillColor !== "transparent" && e.fill(t.path), t.style?.strokeColor !== "transparent" && e.stroke(t.path));
349
+ }, oo = (e, t) => ({ x: Math.min(e.points[0][0], e.points[1][0]) - t.selectionPadding, width: Math.abs(e.points[0][0] - e.points[1][0]) + 2 * t.selectionPadding, y: Math.min(e.points[0][1], e.points[1][1]) - t.selectionPadding, height: Math.abs(e.points[0][1] - e.points[1][1]) + 2 * t.selectionPadding }), Et = (e, t) => {
340
350
  const i = [];
341
351
  let n;
342
352
  if (e.style?.lineArrow === 1 || e.style?.lineArrow === 2 || e.style?.lineArrow === 3) {
343
- const o = Math.PI / 2 - Fi({ targetVector: [e.points[0], e.points[1]] });
344
- e.style?.lineArrow !== 1 && e.style?.lineArrow !== 3 || i.push(Ki(Ji(e.points[0], o, e.style), t)), e.style?.lineArrow !== 2 && e.style?.lineArrow !== 3 || i.push(Ki(Ji(e.points[1], o + Math.PI, e.style), t));
353
+ const o = Math.PI / 2 - Yi({ targetVector: [e.points[0], e.points[1]] });
354
+ e.style?.lineArrow !== 1 && e.style?.lineArrow !== 3 || i.push(Ji(en(e.points[0], o, e.style), t)), e.style?.lineArrow !== 2 && e.style?.lineArrow !== 3 || i.push(Ji(en(e.points[1], o + Math.PI, e.style), t));
345
355
  const d = (({ line: r, size: s, direction: l }) => {
346
- const c = Math.PI / 2 - Fi({ targetVector: [r.points[0], r.points[1]] }), h = [r.points[0][0] + (r.points[1][0] - r.points[0][0]) / 2, r.points[0][1] + (r.points[1][1] - r.points[0][1]) / 2];
347
- let u, v;
356
+ const h = Math.PI / 2 - Yi({ targetVector: [r.points[0], r.points[1]] }), c = [r.points[0][0] + (r.points[1][0] - r.points[0][0]) / 2, r.points[0][1] + (r.points[1][1] - r.points[0][1]) / 2];
357
+ let u, f;
348
358
  if (["start", "both"].includes(l)) {
349
- const f = le({ point: r.points[0], origin: h, rotation: -c });
350
- u = le({ point: [f[0], f[1] + s], origin: h, rotation: c });
359
+ const v = le({ point: r.points[0], origin: c, rotation: -h });
360
+ u = le({ point: [v[0], v[1] + s], origin: c, rotation: h });
351
361
  } else u = [...r.points[0]];
352
362
  if (["end", "both"].includes(l)) {
353
- const f = le({ point: r.points[1], origin: h, rotation: -c });
354
- v = le({ point: [f[0], f[1] - s], origin: h, rotation: c });
355
- } else v = [...r.points[1]];
356
- return { points: [u, v] };
363
+ const v = le({ point: r.points[1], origin: c, rotation: -h });
364
+ f = le({ point: [v[0], v[1] - s], origin: c, rotation: h });
365
+ } else f = [...r.points[1]];
366
+ return { points: [u, f] };
357
367
  })({ line: e, size: 10 + 2 * (e.style?.lineWidth ?? 0), direction: e.style?.lineArrow === 1 ? "start" : e.style?.lineArrow === 2 ? "end" : "both" });
358
368
  n = Zt(d);
359
369
  } else n = Zt(e);
360
- const a = ((o, d) => Be(o, ao, d))(e, t);
361
- return { ...e, path: n, selection: bi(n, e, a, t), arrows: i, style: { ...e.style, lineCap: e.style?.lineArrow ? "butt" : "round" }, computed: a };
362
- }, oo = Dt, Ji = (e, t, i) => {
370
+ const a = ((o, d) => Be(o, oo, d))(e, t);
371
+ return { ...e, path: n, selection: wi(n, e, a, t), arrows: i, style: { ...e.style, lineCap: e.style?.lineArrow ? "butt" : "round" }, computed: a };
372
+ }, so = Et, en = (e, t, i) => {
363
373
  const n = [le({ point: [0, 0], rotation: t }), le({ point: [-(5 + (i.lineWidth ?? 0)), 10 + 2 * (i.lineWidth ?? 0)], rotation: t }), le({ point: [5 + (i.lineWidth ?? 0), 10 + 2 * (i.lineWidth ?? 0)], rotation: t })];
364
374
  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: { ...i, fillColor: i.strokeColor, strokeColor: "transparent" } };
365
- }, so = (e, t, i) => {
366
- const { isXinverted: n, isYinverted: a, settings: o, widthMultiplier: d, heightMultiplier: r } = i, s = e.computed.borders.width - 2 * o.selectionPadding, l = e.computed.borders.height - 2 * o.selectionPadding, c = s * d, h = l * r, u = et(e, t, i), v = tt(i, u.x, u.y, c, h), f = e.computed.center[0] - s / 2, g = e.computed.center[1] - l / 2, Q = v[0] - c / 2, M = v[1] - h / 2;
367
- return ((b, S) => b.type === "line" ? Dt(b, S) : b.type === "polygon" ? ha(b, S) : ua(b, S))({ ...e, points: e.points.map(([b, S]) => [Q + (n ? c - (b - f) * d : (b - f) * d), M + (a ? h - (S - g) * r : (S - g) * r)]) }, i.settings);
375
+ }, ro = (e, t, i) => {
376
+ const { isXinverted: n, isYinverted: a, settings: o, widthMultiplier: d, heightMultiplier: r } = i, s = e.computed.borders.width - 2 * o.selectionPadding, l = e.computed.borders.height - 2 * o.selectionPadding, h = s * d, c = l * r, u = et(e, t, i), f = tt(i, u.x, u.y, h, c), v = e.computed.center[0] - s / 2, p = e.computed.center[1] - l / 2, S = f[0] - h / 2, C = f[1] - c / 2;
377
+ return ((b, Q) => b.type === "line" ? Et(b, Q) : b.type === "polygon" ? ua(b, Q) : pa(b, Q))({ ...e, points: e.points.map(([b, Q]) => [S + (n ? h - (b - v) * d : (b - v) * d), C + (a ? c - (Q - p) * r : (Q - p) * r)]) }, i.settings);
368
378
  }, It = (e, t) => {
369
379
  const i = ((a, o) => Be(a, Qi, o))(e, t), n = yt(e);
370
- return { ...e, path: n, selection: gt(void 0, i, t), computed: i };
371
- }, ro = It, ei = (e, t, i, n, a) => {
372
- const [o, d] = ((r, s, l, c, h = !1) => {
373
- if (!(r && s && c && l)) return [Bi, Bi];
380
+ return { ...e, path: n, selection: pt(void 0, i, t), computed: i };
381
+ }, lo = It, ei = (e, t, i, n, a) => {
382
+ const [o, d] = ((r, s, l, h, c = !1) => {
383
+ if (!(r && s && h && l)) return [Oi, Oi];
374
384
  const u = r / s;
375
- if (u > l / c) {
376
- const f = h ? l : Math.min(r, l);
377
- return [f, f / u];
385
+ if (u > l / h) {
386
+ const v = c ? l : Math.min(r, l);
387
+ return [v, v / u];
378
388
  }
379
- const v = h ? c : Math.min(s, c);
380
- return [v * u, v];
389
+ const f = c ? h : Math.min(s, h);
390
+ return [f * u, f];
381
391
  })(e.width, e.height, i, n, !0);
382
- return It({ toolId: vi.id, type: "picture", id: ue("picture_"), x: -a.canvasOffset[0] + a.canvasSize.realWidth / a.canvasZoom / 2 - o / 2, y: -a.canvasOffset[1] + a.canvasSize.realHeight / a.canvasZoom / 2 - d / 2, width: o, height: d, ratio: o / d, src: t, img: e }, a);
383
- }, lo = (e, t, i, n) => new Promise((a, o) => {
392
+ return It({ toolId: fi.id, type: "picture", id: ue("picture_"), x: -a.canvasOffset[0] + a.canvasSize.realWidth / a.canvasZoom / 2 - o / 2, y: -a.canvasOffset[1] + a.canvasSize.realHeight / a.canvasZoom / 2 - d / 2, width: o, height: d, ratio: o / d, src: t, img: e }, a);
393
+ }, co = (e, t, i, n) => new Promise((a, o) => {
384
394
  const d = new Image();
385
395
  d.onerror = () => {
386
396
  o(new Error("Some images could not be loaded"));
387
397
  }, setTimeout(() => {
388
398
  o(new Error("Timeout while loading images"));
389
- }, 4e3), e instanceof File ? ((r, s, l, c, h, u) => {
390
- ya(l) ? l.text().then((v) => {
391
- const f = ma(v);
399
+ }, 4e3), e instanceof File ? ((r, s, l, h, c, u) => {
400
+ Sa(l) ? l.text().then((f) => {
401
+ const v = ya(f);
392
402
  r.onload = async () => {
393
403
  URL.revokeObjectURL(r.src);
394
- const g = ei(r, v, c, h, u);
395
- s(g);
396
- }, r.src = f;
404
+ const p = ei(r, f, h, c, u);
405
+ s(p);
406
+ }, r.src = v;
397
407
  }) : (r.onload = async () => {
398
408
  URL.revokeObjectURL(r.src);
399
- const v = ei(r, r.src, c, h, u);
400
- s(v);
409
+ const f = ei(r, r.src, h, c, u);
410
+ s(f);
401
411
  }, r.src = URL.createObjectURL(l));
402
- })(d, a, e, t, i, n) : ((r, s, l, c, h, u) => {
412
+ })(d, a, e, t, i, n) : ((r, s, l, h, c, u) => {
403
413
  r.onload = () => {
404
414
  URL.revokeObjectURL(r.src);
405
- const v = ei(r, l, c, h, u);
406
- s(v);
407
- }, Sa(l).then((v) => {
408
- r.src = v;
415
+ const f = ei(r, l, h, c, u);
416
+ s(f);
417
+ }, Qa(l).then((f) => {
418
+ r.src = f;
409
419
  }).catch(() => {
410
420
  r.src = "";
411
421
  });
412
422
  })(d, a, e, t, i, n);
413
- }), ti = ["Texte"], pa = (e, t) => Be(e, ho, t), Wt = (e, t) => {
414
- const i = pa(e, t), n = yt(e);
415
- return { ...e, path: n, selection: gt(void 0, i, t), computed: i };
416
- }, co = Wt, Rt = (e, t, i, n, a, o = mt) => {
423
+ }), ti = ["Texte"], ga = (e, t) => Be(e, uo, t), Wt = (e, t) => {
424
+ const i = ga(e, t), n = yt(e);
425
+ return { ...e, path: n, selection: pt(void 0, i, t), computed: i };
426
+ }, ho = Wt, Rt = (e, t, i, n, a, o = mt) => {
417
427
  e.font = `${a ? "italic" : ""} ${n ? "bold" : ""} 1px ${o}`;
418
428
  const d = t.map((r) => i / e.measureText(r).width);
419
429
  return Math.min(...d) || 36;
420
- }, ho = (e, t) => ({ x: e.x - t.selectionPadding, width: e.width + 2 * t.selectionPadding, y: e.y - t.selectionPadding, height: e.height + 2 * t.selectionPadding }), uo = (e, t, i, n) => {
421
- const a = { ...t, value: i }, o = ((f, g, Q, M, b, S = mt) => {
422
- f.font = `${b ? "italic" : ""} ${M ? "bold" : ""} ${Q}px ${S}`;
423
- const p = g.map((w) => f.measureText(w).width);
424
- return Math.max(...p) || 20;
425
- })(e, a.value, a.fontSize, a.style?.fontBold ?? !1, a.style?.fontItalic ?? !1, a.style?.fontFamily), d = a.fontSize * a.value.length, r = o / d, s = { ...a, width: o, height: d, ratio: r }, { center: l } = pa(s, n), [c, h] = Xi([1, 1], t.computed.center, t), [u, v] = Xi([1, 1], l, s, [!1, !1]);
426
- return { ...s, x: s.x - (u - c), y: s.y - (v - h) };
427
- }, en = (e, t, i, n) => {
430
+ }, uo = (e, t) => ({ x: e.x - t.selectionPadding, width: e.width + 2 * t.selectionPadding, y: e.y - t.selectionPadding, height: e.height + 2 * t.selectionPadding }), po = (e, t, i, n) => {
431
+ const a = { ...t, value: i }, o = ((v, p, S, C, b, Q = mt) => {
432
+ v.font = `${b ? "italic" : ""} ${C ? "bold" : ""} ${S}px ${Q}`;
433
+ const g = p.map((w) => v.measureText(w).width);
434
+ return Math.max(...g) || 20;
435
+ })(e, a.value, a.fontSize, a.style?.fontBold ?? !1, a.style?.fontItalic ?? !1, a.style?.fontFamily), d = a.fontSize * a.value.length, r = o / d, s = { ...a, width: o, height: d, ratio: r }, { center: l } = ga(s, n), [h, c] = $i([1, 1], t.computed.center, t), [u, f] = $i([1, 1], l, s, [!1, !1]);
436
+ return { ...s, x: s.x - (u - h), y: s.y - (f - c) };
437
+ }, tn = (e, t, i, n) => {
428
438
  const a = [we(i[0], n), we(i[1], n)];
429
439
  switch (t.type) {
430
440
  case "brush":
431
- return ((o, d, r) => pt({ toolId: o.id, type: o.type, id: ue(`${o.type}_`), points: [[d]], scaleX: 1, scaleY: 1, style: { opacity: o.settings.opacity.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, r))(t, a, n);
441
+ return ((o, d, r) => ut({ toolId: o.id, type: o.type, id: ue(`${o.type}_`), points: [[d]], scaleX: 1, scaleY: 1, style: { opacity: o.settings.opacity.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, r))(t, a, n);
432
442
  case "line":
433
443
  return ((o, d, r) => {
434
444
  const s = { toolId: o.id, type: o.type, id: ue(`${o.type}_`), points: [d, d], style: { opacity: o.settings.opacity.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default, lineArrow: o.settings.lineArrow.default } };
435
- return Dt(s, r);
445
+ return Et(s, r);
436
446
  })(t, a, n);
437
447
  case "polygon":
438
448
  return ((o, d, r) => St({ toolId: o.id, type: o.type, id: ue(`${o.type}_`), points: [d], style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default, closedPoints: o.settings.closedPoints.default } }, r))(t, a, n);
@@ -440,22 +450,22 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
440
450
  return ((o, d, r) => Qt({ toolId: o.id, type: o.type, id: ue(`${o.type}_`), points: [d], style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default, closedPoints: o.settings.closedPoints.default } }, r))(t, a, n);
441
451
  case "rect":
442
452
  case "square":
443
- return aa(t, a, n);
453
+ return oa(t, a, n);
444
454
  case "text":
445
455
  return ((o, d, r, s) => {
446
- const l = Rt(o, ti, 150, d.settings?.fontBold.default ?? !1, d.settings?.fontItalic.default ?? !1, d.settings.fontFamily.default), c = l * (ti.length || 1);
447
- return Wt({ toolId: d.id, type: d.type, id: ue(`${d.type}_`), x: r[0] - 150, y: r[1] - c, value: ti, fontSize: l, width: 150, height: c, ratio: 150 / c, style: { opacity: d.settings.opacity.default, strokeColor: d.settings.strokeColor.default, fontFamily: d.settings.fontFamily.default, fontItalic: d.settings.fontItalic.default, fontBold: d.settings.fontBold.default } }, s);
456
+ const l = Rt(o, ti, 150, d.settings?.fontBold.default ?? !1, d.settings?.fontItalic.default ?? !1, d.settings.fontFamily.default), h = l * (ti.length || 1);
457
+ return Wt({ toolId: d.id, type: d.type, id: ue(`${d.type}_`), x: r[0] - 150, y: r[1] - h, value: ti, fontSize: l, width: 150, height: h, ratio: 150 / h, style: { opacity: d.settings.opacity.default, strokeColor: d.settings.strokeColor.default, fontFamily: d.settings.fontFamily.default, fontItalic: d.settings.fontItalic.default, fontBold: d.settings.fontBold.default } }, s);
448
458
  })(e, t, a, n);
449
459
  case "ellipse":
450
- return ((o, d, r) => Et({ toolId: o.id, type: o.type, id: ue(`${o.type}_`), x: d[0], y: d[1], radiusX: 0, radiusY: 0, style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, r))(t, a, n);
460
+ return ((o, d, r) => Dt({ toolId: o.id, type: o.type, id: ue(`${o.type}_`), x: d[0], y: d[1], radiusX: 0, radiusY: 0, style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, r))(t, a, n);
451
461
  case "circle":
452
462
  return ((o, d, r) => Tt({ toolId: o.id, type: o.type, id: ue(`${o.type}_`), x: d[0], y: d[1], radius: 0, style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, r))(t, a, n);
453
463
  }
454
- }, tn = (e, t) => {
464
+ }, nn = (e, t) => {
455
465
  switch (t.type) {
456
466
  case "brush":
457
467
  ((i, n) => {
458
- n.points.length < 1 || !n.path || i.globalAlpha !== 0 && n.style?.strokeColor !== "transparent" && i.globalAlpha !== 0 && i.stroke(n.path);
468
+ n.points.length < 1 || i.globalAlpha !== 0 && n.style?.strokeColor !== "transparent" && i.globalAlpha !== 0 && i.stroke(n.path);
459
469
  })(e, t);
460
470
  break;
461
471
  case "text":
@@ -468,47 +478,47 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
468
478
  break;
469
479
  case "line":
470
480
  ((i, n) => {
471
- if (i.globalAlpha !== 0 && n.path) {
481
+ if (i.globalAlpha !== 0) {
472
482
  n.style?.fillColor !== "transparent" && i.fill(n.path), n.style?.strokeColor !== "transparent" && i.stroke(n.path);
473
- for (const a of n.arrows ?? []) xe(i, a.style), no(i, a);
483
+ for (const a of n.arrows ?? []) xe(i, a.style), ao(i, a);
474
484
  }
475
485
  })(e, t);
476
486
  break;
477
487
  case "polygon":
478
488
  ((i, n) => {
479
- n.path && i.globalAlpha !== 0 && (n.style?.fillColor !== "transparent" && i.fill(n.path), n.style?.strokeColor !== "transparent" && i.stroke(n.path));
489
+ i.globalAlpha !== 0 && (n.style?.fillColor !== "transparent" && i.fill(n.path), n.style?.strokeColor !== "transparent" && i.stroke(n.path));
480
490
  })(e, t);
481
491
  break;
482
492
  case "curve":
483
493
  ((i, n) => {
484
- n.path && i.globalAlpha !== 0 && (n.style?.fillColor !== "transparent" && i.fill(n.path), n.style?.strokeColor !== "transparent" && i.stroke(n.path));
494
+ i.globalAlpha !== 0 && (n.style?.fillColor !== "transparent" && i.fill(n.path), n.style?.strokeColor !== "transparent" && i.stroke(n.path));
485
495
  })(e, t);
486
496
  break;
487
497
  case "circle":
488
498
  ((i, n) => {
489
- i.globalAlpha !== 0 && n.path && (n.style?.fillColor !== "transparent" && i.fill(n.path), n.style?.strokeColor !== "transparent" && i.stroke(n.path));
499
+ i.globalAlpha !== 0 && (n.style?.fillColor !== "transparent" && i.fill(n.path), n.style?.strokeColor !== "transparent" && i.stroke(n.path));
490
500
  })(e, t);
491
501
  break;
492
502
  case "ellipse":
493
503
  ((i, n) => {
494
- i.globalAlpha !== 0 && n.path && (n.style?.fillColor !== "transparent" && i.fill(n.path), n.style?.strokeColor !== "transparent" && i.stroke(n.path));
504
+ i.globalAlpha !== 0 && (n.style?.fillColor !== "transparent" && i.fill(n.path), n.style?.strokeColor !== "transparent" && i.stroke(n.path));
495
505
  })(e, t);
496
506
  break;
497
507
  case "rect":
498
508
  case "square":
499
- Ua(e, t);
509
+ qa(e, t);
500
510
  break;
501
511
  case "picture":
502
512
  ((i, n) => {
503
513
  i.globalAlpha !== 0 && (i.beginPath(), i.scale(n.flipX ? -1 : 1, n.flipY ? -1 : 1), i.drawImage(n.img, n.flipX ? -n.x - n.width : n.x, n.flipY ? -n.y - n.height : n.y, n.width, n.height));
504
514
  })(e, t);
505
515
  }
506
- }, ga = (e, t, i) => {
516
+ }, va = (e, t, i) => {
507
517
  if (t.visible === !1) return;
508
518
  if (((a, o) => {
509
519
  const d = ((r) => {
510
- const { canvasSize: { width: s, height: l, scaleRatioWithNoZoom: c }, canvasZoom: h, canvasOffset: u } = r;
511
- return { x: -u[0], y: -u[1], width: s / h / c, height: l / h / c };
520
+ const { canvasSize: { width: s, height: l, scaleRatioWithNoZoom: h }, canvasZoom: c, canvasOffset: u } = r;
521
+ return { x: -u[0], y: -u[1], width: s / c / h, height: l / c / h };
512
522
  })(o);
513
523
  return !!li(a.computed.boundingBox, d);
514
524
  })(t, i)) {
@@ -517,11 +527,11 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
517
527
  if (r.width === 0 || r.height === 0) return;
518
528
  const s = document.createElement("canvas"), l = s.getContext("2d");
519
529
  if (!l) throw new Error("No context found for canvas");
520
- s.width = r.width, s.height = r.height, l.translate(r.width / 4 - d.x, r.height / 4 - d.y), xe(l, { ...o.style, opacity: 100 }), tn(l, o), a.drawImage(s, d.x - r.width / 4, d.y - r.height / 4);
530
+ s.width = r.width, s.height = r.height, l.translate(r.width / 4 - d.x, r.height / 4 - d.y), xe(l, { ...o.style, opacity: 100 }), nn(l, o), a.drawImage(s, d.x - r.width / 4, d.y - r.height / 4);
521
531
  })(e, t), void e.restore();
522
- tn(e, t), e.restore();
532
+ nn(e, t), e.restore();
523
533
  }
524
- }, po = (e, t, i) => {
534
+ }, go = (e, t, i) => {
525
535
  const n = le({ origin: i, point: e.computed.center, rotation: -t });
526
536
  if ("points" in e) {
527
537
  if (e.type === "brush") {
@@ -532,104 +542,104 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
532
542
  return { ...e, points: a };
533
543
  }
534
544
  return { ...e, x: e.x + n[0] - e.computed.center[0], y: e.y + n[1] - e.computed.center[1], rotation: (e.rotation ?? 0) + t };
535
- }, nn = (e, t, i, n, a, o, d) => {
545
+ }, an = (e, t, i, n, a, o, d) => {
536
546
  switch (i.type) {
537
547
  case "line":
538
- return ((r, s, l, c) => {
539
- const h = [we(r[0], c), we(r[1], c)], u = Re(h, s.rotation ?? 0, s.computed.center), v = Le(["points", l.anchor], u, s);
540
- return Dt(v, c);
548
+ return ((r, s, l, h) => {
549
+ const c = [we(r[0], h), we(r[1], h)], u = Re(c, s.rotation ?? 0, s.computed.center), f = Le(["points", l.anchor], u, s);
550
+ return Et(f, h);
541
551
  })(t, i, n, a);
542
552
  case "polygon":
543
- return ((r, s, l, c) => {
544
- const h = [we(r[0], c), we(r[1], c)], u = Re(h, s.rotation ?? 0, s.computed.center), v = Le(["points", l.anchor], u, s);
545
- return St(v, c);
553
+ return ((r, s, l, h) => {
554
+ const c = [we(r[0], h), we(r[1], h)], u = Re(c, s.rotation ?? 0, s.computed.center), f = Le(["points", l.anchor], u, s);
555
+ return St(f, h);
546
556
  })(t, i, n, a);
547
557
  case "curve":
548
- return ((r, s, l, c) => {
549
- const h = [we(r[0], c), we(r[1], c)], u = s.computed.center, v = Re(h, s.rotation ?? 0, u), f = Le(["points", l.anchor], v, s);
550
- return Qt(f, c);
558
+ return ((r, s, l, h) => {
559
+ const c = [we(r[0], h), we(r[1], h)], u = s.computed.center, f = Re(c, s.rotation ?? 0, u), v = Le(["points", l.anchor], f, s);
560
+ return Qt(v, h);
551
561
  })(t, i, n, a);
552
562
  case "brush":
553
- return ((r, s, l, c, h, u) => {
554
- const v = mi({ ...s, scaleX: 1, scaleY: 1 }, c), f = s.computed.borders, { borderX: g, borderHeight: Q, borderY: M, borderWidth: b, isXinverted: S, isYinverted: p } = it(r, s, l, c, h, u), w = Math.max(0, v.width - 2 * c.selectionPadding), L = Math.max(0, v.height - 2 * c.selectionPadding), D = Math.max(0, b - 2 * c.selectionPadding), V = Math.max(0, Q - 2 * c.selectionPadding), x = w ? D / w : 1, Z = L ? V / L : 1;
563
+ return ((r, s, l, h, c, u) => {
564
+ const f = mi({ ...s, scaleX: 1, scaleY: 1 }, h), v = s.computed.borders, { borderX: p, borderHeight: S, borderY: C, borderWidth: b, isXinverted: Q, isYinverted: g } = it(r, s, l, h, c, u), w = Math.max(0, f.width - 2 * h.selectionPadding), L = Math.max(0, f.height - 2 * h.selectionPadding), D = Math.max(0, b - 2 * h.selectionPadding), V = Math.max(0, S - 2 * h.selectionPadding), x = w ? D / w : 1, Z = L ? V / L : 1;
555
565
  if (!w || !L) return s;
556
- const A = Ve(g - f.x) + (S ? 2 * f.x + v.width : 0), H = Ve(M - f.y) + (p ? 2 * f.y + v.height : 0);
557
- return pt({ ...s, points: s.points.map((F) => F.map(([I, W]) => [S ? -I + A : I + A, p ? -W + H : W + H])), scaleX: x, scaleY: Z }, c);
566
+ const A = Ve(p - v.x) + (Q ? 2 * v.x + f.width : 0), H = Ve(C - v.y) + (g ? 2 * v.y + f.height : 0);
567
+ return ut({ ...s, points: s.points.map((F) => F.map(([E, W]) => [Q ? -E + A : E + A, g ? -W + H : W + H])), scaleX: x, scaleY: Z }, h);
558
568
  })(t, i, n, a, o, d);
559
569
  case "circle":
560
- return ((r, s, l, c, h) => {
561
- const { borderX: u, borderHeight: v, borderY: f, borderWidth: g } = it(r, s, l, c, !0, h);
562
- return Tt({ ...s, radius: Math.max(0, g / 2 - c.selectionPadding), x: u + g / 2, y: f + v / 2 }, c);
570
+ return ((r, s, l, h, c) => {
571
+ const { borderX: u, borderHeight: f, borderY: v, borderWidth: p } = it(r, s, l, h, !0, c);
572
+ return Tt({ ...s, radius: Math.max(0, p / 2 - h.selectionPadding), x: u + p / 2, y: v + f / 2 }, h);
563
573
  })(t, i, n, a, d);
564
574
  case "ellipse":
565
- return ((r, s, l, c, h = !1, u = !1) => {
566
- const { borderX: v, borderHeight: f, borderY: g, borderWidth: Q } = it(r, s, l, c, h, u);
567
- return Et({ ...s, radiusX: Math.max(0, Q / 2 - c.selectionPadding), radiusY: Math.max(0, f / 2 - c.selectionPadding), x: v + Q / 2, y: g + f / 2 }, c);
575
+ return ((r, s, l, h, c = !1, u = !1) => {
576
+ const { borderX: f, borderHeight: v, borderY: p, borderWidth: S } = it(r, s, l, h, c, u);
577
+ return Dt({ ...s, radiusX: Math.max(0, S / 2 - h.selectionPadding), radiusY: Math.max(0, v / 2 - h.selectionPadding), x: f + S / 2, y: p + v / 2 }, h);
568
578
  })(t, i, n, a, o, d);
569
579
  case "rect":
570
580
  case "square":
571
- return ((r, s, l, c, h = !1, u = !1) => {
572
- const { borderX: v, borderHeight: f, borderY: g, borderWidth: Q } = it(r, s, l, c, h, u);
573
- return zt({ ...s, width: Math.max(0, Q - 2 * c.selectionPadding), height: Math.max(0, f - 2 * c.selectionPadding), x: v + c.selectionPadding, y: g + c.selectionPadding }, c);
581
+ return ((r, s, l, h, c = !1, u = !1) => {
582
+ const { borderX: f, borderHeight: v, borderY: p, borderWidth: S } = it(r, s, l, h, c, u);
583
+ return zt({ ...s, width: Math.max(0, S - 2 * h.selectionPadding), height: Math.max(0, v - 2 * h.selectionPadding), x: f + h.selectionPadding, y: p + h.selectionPadding }, h);
574
584
  })(t, i, n, a, i.type === "square" || o, d);
575
585
  case "text":
576
- return ((r, s, l, c, h, u) => {
577
- const { borderX: v, borderHeight: f, borderY: g, borderWidth: Q, isXinverted: M, isYinverted: b } = it(s, l, c, h, !0, u), S = Math.max(0, Q - 2 * h.selectionPadding), p = Math.max(0, f - 2 * h.selectionPadding), w = Wt({ ...l, width: S, height: p, x: v + h.selectionPadding, y: g + h.selectionPadding, flipX: M ? !l.flipX : !!l.flipX, flipY: b ? !l.flipY : !!l.flipY }, h);
586
+ return ((r, s, l, h, c, u) => {
587
+ const { borderX: f, borderHeight: v, borderY: p, borderWidth: S, isXinverted: C, isYinverted: b } = it(s, l, h, c, !0, u), Q = Math.max(0, S - 2 * c.selectionPadding), g = Math.max(0, v - 2 * c.selectionPadding), w = Wt({ ...l, width: Q, height: g, x: f + c.selectionPadding, y: p + c.selectionPadding, flipX: C ? !l.flipX : !!l.flipX, flipY: b ? !l.flipY : !!l.flipY }, c);
578
588
  return { ...w, fontSize: Rt(r, w.value, w.width, w.style?.fontBold ?? !1, w.style?.fontItalic ?? !1, w.style?.fontFamily) };
579
589
  })(e, t, i, n, a, d);
580
590
  case "picture":
581
- return ((r, s, l, c, h) => {
582
- const { borderX: u, borderHeight: v, borderY: f, borderWidth: g, isXinverted: Q, isYinverted: M } = it(r, s, l, c, !0, h), b = Math.max(0, g - 2 * c.selectionPadding), S = Math.max(0, v - 2 * c.selectionPadding);
583
- return It({ ...s, width: b, height: S, x: u + c.selectionPadding, y: f + c.selectionPadding, flipX: Q ? !s.flipX : !!s.flipX, flipY: M ? !s.flipY : !!s.flipY }, c);
591
+ return ((r, s, l, h, c) => {
592
+ const { borderX: u, borderHeight: f, borderY: v, borderWidth: p, isXinverted: S, isYinverted: C } = it(r, s, l, h, !0, c), b = Math.max(0, p - 2 * h.selectionPadding), Q = Math.max(0, f - 2 * h.selectionPadding);
593
+ return It({ ...s, width: b, height: Q, x: u + h.selectionPadding, y: v + h.selectionPadding, flipX: S ? !s.flipX : !!s.flipX, flipY: C ? !s.flipY : !!s.flipY }, h);
584
594
  })(t, i, n, a, d);
585
595
  default:
586
596
  return i;
587
597
  }
588
- }, go = (e, t, i, n, a, o, d) => {
589
- if (i.type !== "group") return _(i).map((f) => nn(e, t, f, n, a, o, d));
590
- const r = i, s = _(r), l = s.filter((f) => Ea.includes(f.type)), c = !l.some((f) => (f.rotation ?? 0) !== (l[0]?.rotation ?? 0)), h = (l[0]?.rotation ?? 0) !== 0 && l.length !== s.length, u = s.some((f) => Da.includes(f.type)), v = ((f, g, Q, M, b, S) => {
591
- const { borders: p } = g.computed, { borderX: w, borderHeight: L, borderY: D, borderWidth: V, isXinverted: x, isYinverted: Z } = it(f, g, Q, M, b, S);
592
- return { newBorderX: w, newBorderY: D, newBorderWidth: V, newBorderHeight: L, widthMultiplier: (V - 2 * M.selectionPadding) / (p.width - 2 * M.selectionPadding || 1), heightMultiplier: (L - 2 * M.selectionPadding) / (p.height - 2 * M.selectionPadding || 1), isXinverted: x, isYinverted: Z, groupCenter: [w + V / 2, D + L / 2], rotation: g.rotation ?? 0, settings: M, originalBorders: p };
593
- })(t, r, n, a, o || !c || u || h, d);
594
- return s.map((f) => {
595
- switch (f.type) {
598
+ }, vo = (e, t, i, n, a, o, d) => {
599
+ if (i.type !== "group") return Y(i).map((v) => an(e, t, v, n, a, o, d));
600
+ const r = i, s = Y(r), l = s.filter((v) => Ea.includes(v.type)), h = !l.some((v) => (v.rotation ?? 0) !== (l[0]?.rotation ?? 0)), c = (l[0]?.rotation ?? 0) !== 0 && l.length !== s.length, u = s.some((v) => Ia.includes(v.type)), f = ((v, p, S, C, b, Q) => {
601
+ const { borders: g } = p.computed, { borderX: w, borderHeight: L, borderY: D, borderWidth: V, isXinverted: x, isYinverted: Z } = it(v, p, S, C, b, Q);
602
+ return { newBorderX: w, newBorderY: D, newBorderWidth: V, newBorderHeight: L, widthMultiplier: (V - 2 * C.selectionPadding) / (g.width - 2 * C.selectionPadding || 1), heightMultiplier: (L - 2 * C.selectionPadding) / (g.height - 2 * C.selectionPadding || 1), isXinverted: x, isYinverted: Z, groupCenter: [w + V / 2, D + L / 2], rotation: p.rotation ?? 0, settings: C, originalBorders: g };
603
+ })(t, r, n, a, o || !h || u || c, d);
604
+ return s.map((v) => {
605
+ switch (v.type) {
596
606
  case "rect":
597
607
  case "square":
598
- return ((g, Q, M) => {
599
- const { isXinverted: b, isYinverted: S, settings: p, widthMultiplier: w, heightMultiplier: L } = M, D = (b || S) && !(b && S) && (g.rotation ?? 0) !== 0 && Q.rotation !== g.rotation, V = et(g, Q, M), x = (g.width || 1) * w, Z = (g.height || 1) * L, A = tt(M, V.x, V.y, x, Z);
600
- return zt({ ...g, width: x, height: Z, x: A[0] - x / 2, y: A[1] - Z / 2, rotation: D ? -(g.rotation ?? 0) : g.rotation ?? 0 }, p);
601
- })(f, r, v);
608
+ return ((p, S, C) => {
609
+ const { isXinverted: b, isYinverted: Q, settings: g, widthMultiplier: w, heightMultiplier: L } = C, D = (b || Q) && !(b && Q) && (p.rotation ?? 0) !== 0 && S.rotation !== p.rotation, V = et(p, S, C), x = (p.width || 1) * w, Z = (p.height || 1) * L, A = tt(C, V.x, V.y, x, Z);
610
+ return zt({ ...p, width: x, height: Z, x: A[0] - x / 2, y: A[1] - Z / 2, rotation: D ? -(p.rotation ?? 0) : p.rotation ?? 0 }, g);
611
+ })(v, r, f);
602
612
  case "picture":
603
- return ((g, Q, M) => {
604
- const { isXinverted: b, isYinverted: S, settings: p, widthMultiplier: w, heightMultiplier: L } = M, D = et(g, Q, M), V = (g.width === 0 || g.height === 0 ? g.ratio ?? 1 : g.width) * w, x = (g.width === 0 || g.height === 0 ? g.ratio ?? 1 : g.height) * L, Z = tt(M, D.x, D.y, V, x), A = (b || S) && !(b && S) && (g.rotation ?? 0) !== 0 && Q.rotation !== g.rotation;
605
- return It({ ...g, width: V, height: x, x: Z[0] - V / 2, y: Z[1] - x / 2, flipX: b ? !g.flipX : !!g.flipX, flipY: S ? !g.flipY : !!g.flipY, rotation: A ? -(g.rotation ?? 0) : g.rotation ?? 0 }, p);
606
- })(f, r, v);
613
+ return ((p, S, C) => {
614
+ const { isXinverted: b, isYinverted: Q, settings: g, widthMultiplier: w, heightMultiplier: L } = C, D = et(p, S, C), V = (p.width === 0 || p.height === 0 ? p.ratio ?? 1 : p.width) * w, x = (p.width === 0 || p.height === 0 ? p.ratio ?? 1 : p.height) * L, Z = tt(C, D.x, D.y, V, x), A = (b || Q) && !(b && Q) && (p.rotation ?? 0) !== 0 && S.rotation !== p.rotation;
615
+ return It({ ...p, width: V, height: x, x: Z[0] - V / 2, y: Z[1] - x / 2, flipX: b ? !p.flipX : !!p.flipX, flipY: Q ? !p.flipY : !!p.flipY, rotation: A ? -(p.rotation ?? 0) : p.rotation ?? 0 }, g);
616
+ })(v, r, f);
607
617
  case "text":
608
- return ((g, Q, M, b) => {
609
- const { isXinverted: S, isYinverted: p, settings: w, widthMultiplier: L, heightMultiplier: D } = b, V = (S || p) && !(S && p) && (Q.rotation ?? 0) !== 0 && M.rotation !== Q.rotation, x = et(Q, M, b), Z = (Q.width === 0 || Q.height === 0 ? Q.ratio ?? 1 : Q.width) * L, A = (Q.width === 0 || Q.height === 0 ? Q.ratio ?? 1 : Q.height) * D, H = tt(b, x.x, x.y, Z, A), F = Wt({ ...Q, width: Z, height: A, x: H[0] - Z / 2, y: H[1] - A / 2, flipX: S ? !Q.flipX : !!Q.flipX, flipY: p ? !Q.flipY : !!Q.flipY, rotation: V ? -(Q.rotation ?? 0) : Q.rotation ?? 0 }, w);
610
- return { ...F, fontSize: Rt(g, F.value, F.width, F.style?.fontBold ?? !1, F.style?.fontItalic ?? !1, F.style?.fontFamily) };
611
- })(e, f, r, v);
618
+ return ((p, S, C, b) => {
619
+ const { isXinverted: Q, isYinverted: g, settings: w, widthMultiplier: L, heightMultiplier: D } = b, V = (Q || g) && !(Q && g) && (S.rotation ?? 0) !== 0 && C.rotation !== S.rotation, x = et(S, C, b), Z = (S.width === 0 || S.height === 0 ? S.ratio ?? 1 : S.width) * L, A = (S.width === 0 || S.height === 0 ? S.ratio ?? 1 : S.height) * D, H = tt(b, x.x, x.y, Z, A), F = Wt({ ...S, width: Z, height: A, x: H[0] - Z / 2, y: H[1] - A / 2, flipX: Q ? !S.flipX : !!S.flipX, flipY: g ? !S.flipY : !!S.flipY, rotation: V ? -(S.rotation ?? 0) : S.rotation ?? 0 }, w);
620
+ return { ...F, fontSize: Rt(p, F.value, F.width, F.style?.fontBold ?? !1, F.style?.fontItalic ?? !1, F.style?.fontFamily) };
621
+ })(e, v, r, f);
612
622
  case "ellipse":
613
- return ((g, Q, M) => {
614
- const { isXinverted: b, isYinverted: S, settings: p, widthMultiplier: w, heightMultiplier: L } = M, D = (b || S) && !(b && S) && (g.rotation ?? 0) !== 0 && Q.rotation !== g.rotation, V = et(g, Q, M), x = (g.radiusX || 0.5) * w, Z = (g.radiusY || 0.5) * L, A = tt(M, V.x, V.y, 2 * x, 2 * Z);
615
- return Et({ ...g, radiusX: x, radiusY: Z, x: A[0], y: A[1], rotation: D ? -(g.rotation ?? 0) : g.rotation ?? 0 }, p);
616
- })(f, r, v);
623
+ return ((p, S, C) => {
624
+ const { isXinverted: b, isYinverted: Q, settings: g, widthMultiplier: w, heightMultiplier: L } = C, D = (b || Q) && !(b && Q) && (p.rotation ?? 0) !== 0 && S.rotation !== p.rotation, V = et(p, S, C), x = (p.radiusX || 0.5) * w, Z = (p.radiusY || 0.5) * L, A = tt(C, V.x, V.y, 2 * x, 2 * Z);
625
+ return Dt({ ...p, radiusX: x, radiusY: Z, x: A[0], y: A[1], rotation: D ? -(p.rotation ?? 0) : p.rotation ?? 0 }, g);
626
+ })(v, r, f);
617
627
  case "circle":
618
- return ((g, Q, M) => {
619
- const b = et(g, Q, M), S = (g.radius || 0.5) * M.widthMultiplier, p = tt(M, b.x, b.y, 2 * S, 2 * S);
620
- return Tt({ ...g, radius: S, x: p[0], y: p[1] }, M.settings);
621
- })(f, r, v);
628
+ return ((p, S, C) => {
629
+ const b = et(p, S, C), Q = (p.radius || 0.5) * C.widthMultiplier, g = tt(C, b.x, b.y, 2 * Q, 2 * Q);
630
+ return Tt({ ...p, radius: Q, x: g[0], y: g[1] }, C.settings);
631
+ })(v, r, f);
622
632
  case "brush":
623
- return ((g, Q, M) => {
624
- const { isXinverted: b, isYinverted: S, settings: p, widthMultiplier: w, heightMultiplier: L } = M, D = mi({ ...g, scaleX: 1, scaleY: 1 }, p), V = D.width - 2 * p.selectionPadding, x = D.height - 2 * p.selectionPadding, Z = g.scaleX ?? 1 ? (g.scaleX ?? 1) * w : w / V, A = g.scaleY ?? 1 ? (g.scaleY ?? 1) * L : L / x, H = V * Z, F = x * A, I = et(g, Q, M), W = tt(M, I.x, I.y, H, F), q = Ve(W[0] - H / 2 - g.computed.borders.x - p.selectionPadding) + (b ? 2 * g.computed.borders.x + D.width : 0), G = Ve(W[1] - F / 2 - g.computed.borders.y - p.selectionPadding) + (S ? 2 * g.computed.borders.y + D.height : 0), z = (b || S) && !(b && S) && (g.rotation ?? 0) !== 0 && Q.rotation !== g.rotation;
625
- return pt({ ...g, points: g.points.map((y) => y.map(([C, P]) => [b ? -C + q : C + q, S ? -P + G : P + G])), scaleX: Z, scaleY: A, rotation: z ? -(g.rotation ?? 0) : g.rotation ?? 0 }, M.settings);
626
- })(f, r, v);
633
+ return ((p, S, C) => {
634
+ const { isXinverted: b, isYinverted: Q, settings: g, widthMultiplier: w, heightMultiplier: L } = C, D = mi({ ...p, scaleX: 1, scaleY: 1 }, g), V = D.width - 2 * g.selectionPadding, x = D.height - 2 * g.selectionPadding, Z = p.scaleX ?? 1 ? (p.scaleX ?? 1) * w : w / V, A = p.scaleY ?? 1 ? (p.scaleY ?? 1) * L : L / x, H = V * Z, F = x * A, E = et(p, S, C), W = tt(C, E.x, E.y, H, F), G = Ve(W[0] - H / 2 - p.computed.borders.x - g.selectionPadding) + (b ? 2 * p.computed.borders.x + D.width : 0), _ = Ve(W[1] - F / 2 - p.computed.borders.y - g.selectionPadding) + (Q ? 2 * p.computed.borders.y + D.height : 0), z = (b || Q) && !(b && Q) && (p.rotation ?? 0) !== 0 && S.rotation !== p.rotation;
635
+ return ut({ ...p, points: p.points.map((y) => y.map(([M, P]) => [b ? -M + G : M + G, Q ? -P + _ : P + _])), scaleX: Z, scaleY: A, rotation: z ? -(p.rotation ?? 0) : p.rotation ?? 0 }, C.settings);
636
+ })(v, r, f);
627
637
  case "line":
628
638
  case "polygon":
629
639
  case "curve":
630
- return so(f, r, v);
640
+ return ro(v, r, f);
631
641
  default:
632
- return nn(e, t, f, n, a, o, d);
642
+ return an(e, t, v, n, a, o, d);
633
643
  }
634
644
  });
635
645
  }, fa = (e, t, i, n) => {
@@ -650,36 +660,36 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
650
660
  default:
651
661
  return e;
652
662
  }
653
- }, va = (e, t, i, n, a) => {
654
- const o = t.computed.borders, d = ((l, c) => c ? [Math.abs(l[0]) > Math.abs(l[1]) ? l[0] : 0, Math.abs(l[1]) > Math.abs(l[0]) ? l[1] : 0] : l)([e[0] - i[0], e[1] - i[1]], a), r = d[0] === 0 ? 0 : we(o.x + n.selectionPadding + d[0], n) - (o.x + n.selectionPadding), s = d[1] === 0 ? 0 : we(o.y + n.selectionPadding + d[1], n) - (o.y + n.selectionPadding);
655
- return _(t).map((l) => fa(l, r, s, n));
663
+ }, ma = (e, t, i, n, a) => {
664
+ const o = t.computed.borders, d = ((l, h) => h ? [Math.abs(l[0]) > Math.abs(l[1]) ? l[0] : 0, Math.abs(l[1]) > Math.abs(l[0]) ? l[1] : 0] : l)([e[0] - i[0], e[1] - i[1]], a), r = d[0] === 0 ? 0 : we(o.x + n.selectionPadding + d[0], n) - (o.x + n.selectionPadding), s = d[1] === 0 ? 0 : we(o.y + n.selectionPadding + d[1], n) - (o.y + n.selectionPadding);
665
+ return Y(t).map((l) => fa(l, r, s, n));
656
666
  }, Ne = (e, t) => {
657
667
  switch (e.type) {
658
668
  case "rect":
659
669
  case "square":
660
- return $a(e, t);
670
+ return Ua(e, t);
661
671
  case "ellipse":
662
- return to(e, t);
672
+ return io(e, t);
663
673
  case "circle":
664
- return _a(e, t);
674
+ return ja(e, t);
665
675
  case "picture":
666
- return ro(e, t);
676
+ return lo(e, t);
667
677
  case "text":
668
- return co(e, t);
678
+ return ho(e, t);
669
679
  case "line":
670
- return oo(e, t);
680
+ return so(e, t);
671
681
  case "polygon":
672
- return ha(e, t);
673
- case "curve":
674
682
  return ua(e, t);
683
+ case "curve":
684
+ return pa(e, t);
675
685
  case "brush":
676
- return Wa(e, t);
686
+ return Ra(e, t);
677
687
  default:
678
688
  return e;
679
689
  }
680
- }, an = ({ ctx: e, shape: t, settings: i, selectionWidth: n, selectionColor: a, hoverMode: o, selectionMode: d, withAnchors: r = !0 }) => {
681
- switch (i.debug && ((s, l, c, h) => {
682
- l.selection && h.debug && (s.save(), s.scale(h.canvasSize.scaleRatio, h.canvasSize.scaleRatio), s.translate(h.canvasOffset[0], h.canvasOffset[1]), xe(s, { fillColor: "transparent", strokeColor: "green", lineWidth: c / h.canvasSize.scaleRatio }), s.strokeRect(l.computed.boundingBox.x, l.computed.boundingBox.y, l.computed.boundingBox.width, l.computed.boundingBox.height), s.restore());
690
+ }, on = ({ ctx: e, shape: t, settings: i, selectionWidth: n, selectionColor: a, hoverMode: o, selectionMode: d, withAnchors: r = !0 }) => {
691
+ switch (i.debug && ((s, l, h, c) => {
692
+ l.selection && c.debug && (s.save(), s.scale(c.canvasSize.scaleRatio, c.canvasSize.scaleRatio), s.translate(c.canvasOffset[0], c.canvasOffset[1]), xe(s, { fillColor: "transparent", strokeColor: "green", lineWidth: h / c.canvasSize.scaleRatio }), s.strokeRect(l.computed.boundingBox.x, l.computed.boundingBox.y, l.computed.boundingBox.width, l.computed.boundingBox.height), s.restore());
683
693
  })(e, t, n, i), t.type) {
684
694
  case "rect":
685
695
  case "square":
@@ -688,32 +698,32 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
688
698
  case "picture":
689
699
  case "text":
690
700
  case "brush":
691
- ((s, l, c, h, u, v) => {
692
- if (l.selection && (lt(s, u, l.rotation, l.computed.center), u.debug && (xe(s, { fillColor: "transparent", strokeColor: "red", lineWidth: h / u.canvasSize.scaleRatio }), s.strokeRect(l.computed.outerBorders.x, l.computed.outerBorders.y, l.computed.outerBorders.width, l.computed.outerBorders.height)), xe(s, { fillColor: "transparent", strokeColor: c, lineWidth: h / u.canvasSize.scaleRatio }), l.selection.shapePath ? s.stroke(l.selection.shapePath) : s.stroke(l.selection.border), v && !l.locked)) {
693
- l.selection.shapePath && s.stroke(l.selection.border), l.selection.line && s.stroke(l.selection.line), xe(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / u.canvasSize.scaleRatio, shadowColor: c, shadowBlur: 0 });
694
- for (const f of l.selection.anchors) s.fill(f), s.stroke(f);
701
+ ((s, l, h, c, u, f) => {
702
+ if (l.selection && (lt(s, u, l.rotation, l.computed.center), u.debug && (xe(s, { fillColor: "transparent", strokeColor: "red", lineWidth: c / u.canvasSize.scaleRatio }), s.strokeRect(l.computed.outerBorders.x, l.computed.outerBorders.y, l.computed.outerBorders.width, l.computed.outerBorders.height)), xe(s, { fillColor: "transparent", strokeColor: h, lineWidth: c / u.canvasSize.scaleRatio }), l.selection.shapePath ? s.stroke(l.selection.shapePath) : s.stroke(l.selection.border), f && !l.locked)) {
703
+ l.selection.shapePath && s.stroke(l.selection.border), l.selection.line && s.stroke(l.selection.line), xe(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / u.canvasSize.scaleRatio, shadowColor: h, shadowBlur: 0 });
704
+ for (const v of l.selection.anchors) s.fill(v), s.stroke(v);
695
705
  }
696
706
  })(e, t, a, n, i, r);
697
707
  break;
698
708
  case "group":
699
- ((s, l, c, h, u, v, f) => {
700
- if (l.selection && (l.shapes.forEach((g) => {
701
- xe(s, { fillColor: "transparent", strokeColor: c, lineWidth: h / v.canvasSize.scaleRatio }), lt(s, v, g.rotation, g.computed.center), g.selection?.shapePath && s.stroke(g.selection.shapePath), s.restore();
702
- }), u.mode !== "rotate" && (lt(s, v, l.rotation, l.computed.center), v.debug && (xe(s, { fillColor: "transparent", strokeColor: "red", lineWidth: h / v.canvasSize.scaleRatio }), s.strokeRect(l.computed.outerBorders.x, l.computed.outerBorders.y, l.computed.outerBorders.width, l.computed.outerBorders.height)), xe(s, { fillColor: "transparent", strokeColor: c, lineWidth: h / v.canvasSize.scaleRatio }), f && !l.locked))) {
703
- s.stroke(l.selection.border), l.selection.line && s.stroke(l.selection.line), xe(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / v.canvasSize.scaleRatio });
704
- for (const g of l.selection.anchors) s.fill(g), s.stroke(g);
709
+ ((s, l, h, c, u, f, v) => {
710
+ if (l.selection && (l.shapes.forEach((p) => {
711
+ xe(s, { fillColor: "transparent", strokeColor: h, lineWidth: c / f.canvasSize.scaleRatio }), lt(s, f, p.rotation, p.computed.center), p.selection?.shapePath && s.stroke(p.selection.shapePath), s.restore();
712
+ }), u.mode !== "rotate" && (lt(s, f, l.rotation, l.computed.center), f.debug && (xe(s, { fillColor: "transparent", strokeColor: "red", lineWidth: c / f.canvasSize.scaleRatio }), s.strokeRect(l.computed.outerBorders.x, l.computed.outerBorders.y, l.computed.outerBorders.width, l.computed.outerBorders.height)), xe(s, { fillColor: "transparent", strokeColor: h, lineWidth: c / f.canvasSize.scaleRatio }), v && !l.locked))) {
713
+ s.stroke(l.selection.border), l.selection.line && s.stroke(l.selection.line), xe(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / f.canvasSize.scaleRatio });
714
+ for (const p of l.selection.anchors) s.fill(p), s.stroke(p);
705
715
  }
706
716
  })(e, t, a, n, d, i, r);
707
717
  break;
708
718
  case "polygon":
709
719
  case "line":
710
720
  case "curve":
711
- (({ ctx: s, shape: l, withAnchors: c, selectionWidth: h, selectionColor: u, hoverMode: v, settings: f }) => {
712
- if (l.selection && (lt(s, f, l.rotation, l.computed.center), f.debug && (xe(s, { fillColor: "transparent", strokeColor: "red", lineWidth: h / f.canvasSize.scaleRatio }), s.strokeRect(l.computed.outerBorders.x, l.computed.outerBorders.y, l.computed.outerBorders.width, l.computed.outerBorders.height)), xe(s, { fillColor: "transparent", strokeColor: u, lineWidth: h / f.canvasSize.scaleRatio }), l.selection.shapePath && s.stroke(l.selection.shapePath), c && !l.locked)) {
713
- xe(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / f.canvasSize.scaleRatio, shadowColor: u, shadowBlur: 0 });
714
- for (let g = 0; g < l.selection.anchors.length; g++) {
715
- const Q = l.selection.anchors[g];
716
- v.mode === "resize" && v.anchor === g ? (s.shadowBlur = 10, s.fill(Q), s.shadowBlur = 0) : s.fill(Q), s.stroke(Q);
721
+ (({ ctx: s, shape: l, withAnchors: h, selectionWidth: c, selectionColor: u, hoverMode: f, settings: v }) => {
722
+ if (l.selection && (lt(s, v, l.rotation, l.computed.center), v.debug && (xe(s, { fillColor: "transparent", strokeColor: "red", lineWidth: c / v.canvasSize.scaleRatio }), s.strokeRect(l.computed.outerBorders.x, l.computed.outerBorders.y, l.computed.outerBorders.width, l.computed.outerBorders.height)), xe(s, { fillColor: "transparent", strokeColor: u, lineWidth: c / v.canvasSize.scaleRatio }), l.selection.shapePath && s.stroke(l.selection.shapePath), h && !l.locked)) {
723
+ xe(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / v.canvasSize.scaleRatio, shadowColor: u, shadowBlur: 0 });
724
+ for (let p = 0; p < l.selection.anchors.length; p++) {
725
+ const S = l.selection.anchors[p];
726
+ f.mode === "resize" && f.anchor === p ? (s.shadowBlur = 10, s.fill(S), s.shadowBlur = 0) : s.fill(S), s.stroke(S);
717
727
  }
718
728
  }
719
729
  })({ ctx: e, shape: t, withAnchors: r, selectionWidth: n, selectionColor: a, hoverMode: o, settings: i });
@@ -723,7 +733,7 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
723
733
  lt(e, i), ((n, a, o) => {
724
734
  xe(n, { fillColor: "rgba(170,170,170, 0.1)", strokeColor: "rgb(170,170,170)", lineWidth: 1 / o.canvasSize.scaleRatio }), n.fillRect(a[0][0], a[0][1], a[1][0] - a[0][0], a[1][1] - a[0][1]), n.strokeRect(a[0][0], a[0][1], a[1][0] - a[0][0], a[1][1] - a[0][1]);
725
735
  })(e, t.frame, i), e.restore();
726
- }, wi = (e) => e.filter((t) => t != null), ma = (e) => {
736
+ }, xi = (e) => e.filter((t) => t != null), ya = (e) => {
727
737
  const t = new DOMParser().parseFromString(e, "text/xml").getElementsByTagName("svg")[0];
728
738
  if (!t) return "";
729
739
  const i = t.getAttribute("width"), n = t.getAttribute("height");
@@ -735,10 +745,10 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
735
745
  }
736
746
  const o = new Blob([a], { type: "image/svg+xml" });
737
747
  return URL.createObjectURL(o);
738
- }, ya = (e) => (e instanceof File ? e.name : e).includes(".svg"), Sa = (e) => ya(e) ? fetch(e).then((t) => t.text()).then((t) => ma(t)) : fetch(e).then((t) => t.blob()).then((t) => URL.createObjectURL(t)), on = (e, t) => {
748
+ }, Sa = (e) => (e instanceof File ? e.name : e).includes(".svg"), Qa = (e) => Sa(e) ? fetch(e).then((t) => t.text()).then((t) => ya(t)) : fetch(e).then((t) => t.blob()).then((t) => URL.createObjectURL(t)), sn = (e, t) => {
739
749
  const i = document.createElement("a");
740
750
  i.href = e, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i);
741
- }, vo = (e) => e.src.includes("<svg") ? e.src : ((t) => {
751
+ }, mo = (e) => e.src.includes("<svg") ? e.src : ((t) => {
742
752
  const i = document.createElement("canvas");
743
753
  i.width = t.width, i.height = t.height;
744
754
  const n = i.getContext("2d");
@@ -747,10 +757,10 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
747
757
  const i = document.createElement("canvas"), n = i.getContext("2d");
748
758
  if (!n) throw new Error("No context found for canvas");
749
759
  const { realHeight: a, realWidth: o } = t.canvasSize;
750
- i.width = o, i.height = a, n.clearRect(0, 0, o, a), ea(n);
751
- for (let d = e.length - 1; d >= 0; d--) ga(n, e[d], t);
760
+ i.width = o, i.height = a, n.clearRect(0, 0, o, a), ta(n);
761
+ for (let d = e.length - 1; d >= 0; d--) va(n, e[d], t);
752
762
  return i.toDataURL("image/png");
753
- }, sn = ({ shapes: e, settings: t, view: i }) => {
763
+ }, rn = ({ shapes: e, settings: t, view: i }) => {
754
764
  if (i === "fitToShapes" && !e.length) throw new Error("No image found to export");
755
765
  if (i === "fitToShapes") {
756
766
  const a = Math.min(...e.map((l) => l.computed.boundingBox.x)), o = Math.max(...e.map((l) => l.computed.boundingBox.x + l.computed.boundingBox.width)), d = Math.min(...e.map((l) => l.computed.boundingBox.y)), r = Math.max(...e.map((l) => l.computed.boundingBox.y + l.computed.boundingBox.height)), s = { ...t, canvasOffset: [-a, -d], canvasZoom: 1, canvasSize: { realWidth: o - a, realHeight: r - d, width: o - a, height: r - d, scaleRatio: 1, scaleRatioWithNoZoom: 1 } };
@@ -762,166 +772,166 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
762
772
  }
763
773
  const n = { ...t, canvasSize: { ...t.canvasSize, width: t.canvasSize.realWidth, height: t.canvasSize.realHeight, scaleRatio: t.canvasZoom, scaleRatioWithNoZoom: 1 } };
764
774
  return ii({ shapes: e, settings: n });
765
- }, mo = (e, t, i) => {
766
- return a = xi(e, t, i), `data:text/plain;charset=utf-8,${encodeURIComponent(JSON.stringify(a))}`;
775
+ }, yo = (e, t, i) => {
776
+ return a = Ci(e, t, i), `data:text/plain;charset=utf-8,${encodeURIComponent(JSON.stringify(a))}`;
767
777
  var a;
768
- }, yo = (e) => {
778
+ }, So = (e) => {
769
779
  const t = ["img", "id", "selection", "path", "arrows", "tempPoint", "computed", ["flipX", [void 0, !1]], ["flipY", [void 0, !1]]];
770
- return e.map((i) => i.type !== "picture" || i.src.startsWith("http") ? ai(t, i) : ai(t, { ...i, src: vo(i) }));
771
- }, xi = (e, t, i) => ({ shapes: yo(e), config: { width: t, height: i } }), rn = (e, t) => Ne({ ...e, id: ue(`${e.type}_`) }, t), So = (e, t, i, n) => {
772
- const a = ne([]), o = ne({ dataChanged: [] }), [d, r] = X(void 0), [s, l] = X(void 0), [c, h] = X(void 0), [u, v] = X({ states: [{ shapes: [], selectedShape: void 0, source: "remote" }], cursor: 0 }), f = u.cursor > 0, g = u.cursor < u.states.length - 1, Q = a.current.length > 0, M = Y(() => {
773
- v((y) => Kn(y.states[y.cursor]?.shapes, a.current) ? y : { states: [...y.states.slice(0, y.cursor + 1), { shapes: a.current, selectedShape: s, source: "user" }], cursor: y.cursor + 1 });
774
- }, [s]), b = Y((y) => {
780
+ return e.map((i) => i.type !== "picture" || i.src.startsWith("http") ? ai(t, i) : ai(t, { ...i, src: mo(i) }));
781
+ }, Ci = (e, t, i) => ({ shapes: So(e), config: { width: t, height: i } }), ln = (e, t) => Ne({ ...e, id: ue(`${e.type}_`) }, t), Qo = (e, t, i, n) => {
782
+ const a = ne([]), o = ne({ dataChanged: [] }), [d, r] = $(void 0), [s, l] = $(void 0), [h, c] = $(void 0), [u, f] = $({ states: [{ shapes: [], selectedShape: void 0, source: "remote" }], cursor: 0 }), v = u.cursor > 0, p = u.cursor < u.states.length - 1, S = a.current.length > 0, C = X(() => {
783
+ f((y) => Jn(y.states[y.cursor]?.shapes, a.current) ? y : { states: [...y.states.slice(0, y.cursor + 1), { shapes: a.current, selectedShape: s, source: "user" }], cursor: y.cursor + 1 });
784
+ }, [s]), b = X((y) => {
775
785
  a.current = [...y, ...a.current];
776
- }, []), S = Y((y) => {
777
- a.current = a.current.flatMap((C) => {
778
- const P = y.find((T) => T.id === C.id);
779
- return P ? [{ ...P, id: ue(`${C.type}_`) }, C] : C;
786
+ }, []), Q = X((y) => {
787
+ a.current = a.current.flatMap((M) => {
788
+ const P = y.find((T) => T.id === M.id);
789
+ return P ? [{ ...P, id: ue(`${M.type}_`) }, M] : M;
780
790
  });
781
- }, []), p = Y((y, C, P, T) => {
782
- if (y.target && "className" in y.target && ![_n, jn].includes(y.target.className) || !T) return void h(void 0);
783
- const k = a.current.find((O) => _(s)?.map((R) => R.id).includes(O.id) ? !!ut(C, O, P, e) : !!la(C, O, P, e));
784
- h(k);
785
- }, [e, s]), w = Y(async (y, C = 300, P = 300) => {
786
- const T = await lo(y, C, P, e);
787
- return b([T]), M(), T;
788
- }, [b, M, e]), L = Y((y, C = !1) => {
789
- a.current = a.current.map((P) => y.find((T) => T.id === P.id) ?? P), l((P) => P && pe(_(P).map((T) => y.find((k) => k.id === T.id) ?? T), e)), C && M();
790
- }, [M, e]), D = Y((y) => {
791
- const C = y.map((P) => ai(["chosen"], P));
792
- a.current = C, M();
793
- }, [M]), V = Y((y) => {
794
- const C = new Set(y.map((P) => P.id));
791
+ }, []), g = X((y, M, P, T) => {
792
+ if (y.target && "className" in y.target && ![jn, Kn].includes(y.target.className) || !T) return void c(void 0);
793
+ const k = a.current.find((O) => Y(s)?.map((R) => R.id).includes(O.id) ? !!ft(M, O, P, e) : !!da(M, O, P, e));
794
+ c(k);
795
+ }, [e, s]), w = X(async (y, M = 300, P = 300) => {
796
+ const T = await co(y, M, P, e);
797
+ return b([T]), C(), T;
798
+ }, [b, C, e]), L = X((y, M = !1) => {
799
+ a.current = a.current.map((P) => y.find((T) => T.id === P.id) ?? P), l((P) => P && pe(Y(P).map((T) => y.find((k) => k.id === T.id) ?? T), e)), M && C();
800
+ }, [C, e]), D = X((y) => {
801
+ const M = y.map((P) => ai(["chosen"], P));
802
+ a.current = M, C();
803
+ }, [C]), V = X((y) => {
804
+ const M = new Set(y.map((P) => P.id));
795
805
  l((P) => {
796
- const T = _(P).map((k) => k.id);
797
- return T && C.size && T.find((k) => C.has(k)) ? void 0 : P;
798
- }), a.current = a.current.filter((P) => !C?.has(P.id)), M();
799
- }, [M]), x = Y((y) => {
800
- v((C) => {
801
- const P = y(C);
802
- return a.current = C.states[P]?.shapes ?? [], l(C.states[P]?.selectedShape), Le("cursor", P, C);
806
+ const T = Y(P).map((k) => k.id);
807
+ return T && M.size && T.find((k) => M.has(k)) ? void 0 : P;
808
+ }), a.current = a.current.filter((P) => !M?.has(P.id)), C();
809
+ }, [C]), x = X((y) => {
810
+ f((M) => {
811
+ const P = y(M);
812
+ return a.current = M.states[P]?.shapes ?? [], l(M.states[P]?.selectedShape), Le("cursor", P, M);
803
813
  });
804
- }, []), Z = Y(() => {
814
+ }, []), Z = X(() => {
805
815
  x((y) => Math.max(0, y.cursor - 1));
806
- }, [x]), A = Y(() => {
816
+ }, [x]), A = X(() => {
807
817
  x((y) => Math.min(y.states.length - 1, y.cursor + 1));
808
- }, [x]), H = Y((y, C) => {
809
- l(void 0), a.current = y, v((P) => C.clearHistory ? { states: [{ shapes: y, selectedShape: void 0, source: C.source }], cursor: 0 } : { states: [...P.states.slice(0, P.cursor + 1), { shapes: y, selectedShape: void 0, source: C.source }], cursor: P.cursor + 1 });
810
- }, []), F = Y((y, C) => {
811
- const P = a.current, T = P.findIndex((E) => E.id === y), k = P.findIndex((E) => E.id === C);
818
+ }, [x]), H = X((y, M) => {
819
+ l(void 0), a.current = y, f((P) => M.clearHistory ? { states: [{ shapes: y, selectedShape: void 0, source: M.source }], cursor: 0 } : { states: [...P.states.slice(0, P.cursor + 1), { shapes: y, selectedShape: void 0, source: M.source }], cursor: P.cursor + 1 });
820
+ }, []), F = X((y, M) => {
821
+ const P = a.current, T = P.findIndex((I) => I.id === y), k = P.findIndex((I) => I.id === M);
812
822
  var O, R, B;
813
823
  D((O = P, B = k, (R = T) < 0 || B < 0 || R > O.length - 1 || B > O.length - 1 ? O : R < B ? [...O.slice(0, R), ...O.slice(R + 1, B + 1), O[R], ...O.slice(B + 1, O.length)] : [...O.slice(0, B), O[R], ...O.slice(B, R), ...O.slice(R + 1, O.length)]));
814
- }, [D]), I = Y((y) => {
815
- const C = a.current, P = new Set(y.map((k) => k.id)), T = C.map((k) => P.has(k.id) ? Le("visible", k.visible === !1, k) : k);
816
- l(Ui((k) => Le("visible", k.visible === !1, k), e)), D(T);
817
- }, [D, e]), W = Y((y) => {
818
- const C = a.current, P = new Set(y.map((k) => k.id)), T = C.map((k) => P.has(k.id) ? Le("locked", !k.locked, k) : k);
819
- l(Ui((k) => Le("locked", !k.locked, k), e)), D(T);
820
- }, [D, e]), q = Y((y, C) => {
821
- o.current.hasOwnProperty(y) && (o.current[y] = [...o.current[y], C]);
822
- }, []), G = Y((y, C) => {
823
- if (o.current.hasOwnProperty(y)) if (C) {
824
- const P = o.current[y].indexOf(C);
824
+ }, [D]), E = X((y) => {
825
+ const M = a.current, P = new Set(y.map((k) => k.id)), T = M.map((k) => P.has(k.id) ? Le("visible", k.visible === !1, k) : k);
826
+ l(qi((k) => Le("visible", k.visible === !1, k), e)), D(T);
827
+ }, [D, e]), W = X((y) => {
828
+ const M = a.current, P = new Set(y.map((k) => k.id)), T = M.map((k) => P.has(k.id) ? Le("locked", !k.locked, k) : k);
829
+ l(qi((k) => Le("locked", !k.locked, k), e)), D(T);
830
+ }, [D, e]), G = X((y, M) => {
831
+ o.current.hasOwnProperty(y) && (o.current[y] = [...o.current[y], M]);
832
+ }, []), _ = X((y, M) => {
833
+ if (o.current.hasOwnProperty(y)) if (M) {
834
+ const P = o.current[y].indexOf(M);
825
835
  o.current[y] = [...o.current[y].slice(0, P), ...o.current[y].slice(P + 1)];
826
836
  } else o.current[y] = [];
827
837
  }, []);
828
838
  ee(() => {
829
- const y = u.states[u.cursor], C = xi(y.shapes, t, i);
830
- for (const P of o.current.dataChanged) P(C, y.source);
839
+ const y = u.states[u.cursor], M = Ci(y.shapes, t, i);
840
+ for (const P of o.current.dataChanged) P(M, y.source);
831
841
  }, [t, i, u]), ee(() => {
832
- a.current = a.current.map((y) => Ne(y, e)), l((y) => y === void 0 ? void 0 : pe(_(y).map((C) => Ne(C, e)), e));
842
+ a.current = a.current.map((y) => Ne(y, e)), l((y) => y === void 0 ? void 0 : pe(Y(y).map((M) => Ne(M, e)), e));
833
843
  }, [e]);
834
- const z = Y((y, C) => {
844
+ const z = X((y, M) => {
835
845
  r((P) => {
836
- const T = [P?.frame[0] ?? [C[0], C[1]], [C[0], C[1]]], k = a.current.filter((R) => ((B, E, K) => {
837
- const { borders: de, center: se, boundingBox: j } = E.computed, N = Math.min(K[0][0], K[1][0]), ge = Math.max(K[0][0], K[1][0]), oe = Math.min(K[0][1], K[1][1]), ye = { x: N, y: oe, width: ge - N, height: Math.max(K[0][1], K[1][1]) - oe }, Se = li(j, ye);
846
+ const T = [P?.frame[0] ?? [M[0], M[1]], [M[0], M[1]]], k = a.current.filter((R) => ((B, I, j) => {
847
+ const { borders: de, center: se, boundingBox: K } = I.computed, N = Math.min(j[0][0], j[1][0]), ge = Math.max(j[0][0], j[1][0]), oe = Math.min(j[0][1], j[1][1]), ye = { x: N, y: oe, width: ge - N, height: Math.max(j[0][1], j[1][1]) - oe }, Se = li(K, ye);
838
848
  if (!Se) return !1;
839
- if (de.width <= 1 || de.height <= 1 || !E.path) return !0;
840
- if (B.lineWidth = (E.style?.lineWidth ?? 0) + 10, E.type === "brush") {
841
- const te = E.points.flat(), fe = Math.min(...te.map((ae) => ae[0])), $ = Math.min(...te.map((ae) => ae[1]));
842
- for (const ae of E.points) {
849
+ if (de.width <= 1 || de.height <= 1) return !0;
850
+ if (B.lineWidth = (I.style?.lineWidth ?? 0) + 10, I.type === "brush") {
851
+ const te = I.points.flat(), ve = Math.min(...te.map((ae) => ae[0])), U = Math.min(...te.map((ae) => ae[1]));
852
+ for (const ae of I.points) {
843
853
  if (ae.length < 1) break;
844
854
  if (ae.length < 2) {
845
- const Me = De(ae[0], fe, $, E.scaleX, E.scaleY);
846
- if (ta(Se, { x: Me[0], y: Me[1], radius: (E.style?.lineWidth ?? 1) / 2 })) return !0;
855
+ const Me = Ee(ae[0], ve, U, I.scaleX, I.scaleY);
856
+ if (ia(Se, { x: Me[0], y: Me[1], radius: (I.style?.lineWidth ?? 1) / 2 })) return !0;
847
857
  }
848
858
  for (let Me = 0; Me < ae.length - 1; Me++) {
849
- const Ze = ri(De(ae[Me], fe, $, E.scaleX, E.scaleY), E.rotation ?? 0, se), re = ri(De(ae[Me + 1], fe, $, E.scaleX, E.scaleY), E.rotation ?? 0, se), Te = li({ x: Math.min(Ze[0], re[0]), y: Math.min(Ze[1], re[1]), width: Math.abs(Ze[0] - re[0]), height: Math.abs(Ze[1] - re[1]) }, ye);
859
+ const Ze = ri(Ee(ae[Me], ve, U, I.scaleX, I.scaleY), I.rotation ?? 0, se), re = ri(Ee(ae[Me + 1], ve, U, I.scaleX, I.scaleY), I.rotation ?? 0, se), Te = li({ x: Math.min(Ze[0], re[0]), y: Math.min(Ze[1], re[1]), width: Math.abs(Ze[0] - re[0]), height: Math.abs(Ze[1] - re[1]) }, ye);
850
860
  if (Te) {
851
861
  const qe = new Path2D();
852
- if (qe.moveTo(...Ze), qe.lineTo(...re), Gi({ ctx: B, path: qe, rect: Te, offset: 10, center: se, checkFill: !1 })) return !0;
862
+ if (qe.moveTo(...Ze), qe.lineTo(...re), _i({ ctx: B, path: qe, rect: Te, offset: 10, center: se, checkFill: !1 })) return !0;
853
863
  }
854
864
  }
855
865
  }
856
866
  return !1;
857
867
  }
858
- const Qe = E.style?.fillColor && E.style?.fillColor !== "transparent" || ["picture", "text"].includes(E.type);
859
- return Gi({ ctx: B, path: E.path, rect: Se, offset: 10, center: se, rotation: E.rotation ?? 0, checkFill: Qe });
868
+ const Qe = bi(I);
869
+ return _i({ ctx: B, path: I.path, rect: Se, offset: 10, center: se, rotation: I.rotation ?? 0, checkFill: Qe });
860
870
  })(y, R, T)), O = pe(k, e);
861
- return l(n ? pe(oa(P?.oldSelection, k), e) : O), { oldSelection: P?.oldSelection, frame: T };
871
+ return l(n ? pe(sa(P?.oldSelection, k), e) : O), { oldSelection: P?.oldSelection, frame: T };
862
872
  });
863
873
  }, [e, n]);
864
- return { registerEvent: q, unregisterEvent: G, shapesRef: a, selectedShape: s, hoveredShape: c, selectionFrame: d, setSelectionFrame: r, refreshSelectedShapes: z, addShapes: b, duplicateShapes: S, addPictureShape: w, moveShapes: F, saveShapes: M, setSelectedShape: l, refreshHoveredShape: p, toggleShapeVisibility: I, toggleShapeLock: W, removeShape: V, updateShape: L, backwardShape: Z, forwardShape: A, clearShapes: H, canGoBackward: f, canGoForward: g, canClear: Q };
865
- }, ln = (e) => {
874
+ return { registerEvent: G, unregisterEvent: _, shapesRef: a, selectedShape: s, hoveredShape: h, selectionFrame: d, setSelectionFrame: r, refreshSelectedShapes: z, addShapes: b, duplicateShapes: Q, addPictureShape: w, moveShapes: F, saveShapes: C, setSelectedShape: l, refreshHoveredShape: g, toggleShapeVisibility: E, toggleShapeLock: W, removeShape: V, updateShape: L, backwardShape: Z, forwardShape: A, clearShapes: H, canGoBackward: v, canGoForward: p, canClear: S };
875
+ }, dn = (e) => {
866
876
  const t = [e[0].clientX, e[0].clientY], i = [e[1].clientX, e[1].clientY];
867
877
  var n, a;
868
- return { diff: ia(t, i), center: (a = i, [((n = t)[0] + a[0]) / 2, (n[1] + a[1]) / 2]) };
869
- }, Qo = ({ canvasElt: e, canvasTransformation: t, canvasSize: i, size: n, setCanvasTransformation: a }) => {
870
- const o = ne([]), [d, r] = X(o.current.length > 0), s = ne(null), l = ne(t);
878
+ return { diff: na(t, i), center: (a = i, [((n = t)[0] + a[0]) / 2, (n[1] + a[1]) / 2]) };
879
+ }, bo = ({ canvasElt: e, canvasTransformation: t, canvasSize: i, size: n, setCanvasTransformation: a }) => {
880
+ const o = ne([]), [d, r] = $(o.current.length > 0), s = ne(null), l = ne(t);
871
881
  l.current = t;
872
- const c = Y(({ startDiff: h, startZoom: u, startCenter: v, startOffset: f, currentDiff: g, currentCenter: Q, isMoving: M, isZooming: b }) => {
873
- if (!e || !g || !h) return;
874
- const S = (({ canvasBoundingRect: p, canvasSize: w, size: L, startDiff: D, startZoom: V, startCenter: x, startOffset: Z, currentDiff: A, currentCenter: H, isMoving: F, isZooming: I }) => {
875
- const W = I ? We(A / D * V, Pe[0], Pe[Pe.length - 1]) : V, q = F ? [Z[0] + (H[0] - x[0]) * (w.width / p.width) / w.scaleRatio / V, Z[1] + (H[1] - x[1]) * (w.height / p.height) / w.scaleRatio / V] : [Z[0], Z[1]], G = [(H[0] - p.left) / w.scaleRatio, (H[1] - p.top) / w.scaleRatio];
876
- return ci({ size: L, canvasSize: w, currentOffset: q, currentZoom: V, zoom: W, centerPoint: G });
877
- })({ canvasBoundingRect: e.getBoundingClientRect(), canvasSize: i, size: n, startDiff: h, startZoom: u, startCenter: v, startOffset: f, currentDiff: g, currentCenter: Q, isMoving: M, isZooming: b });
878
- a(S);
882
+ const h = X(({ startDiff: c, startZoom: u, startCenter: f, startOffset: v, currentDiff: p, currentCenter: S, isMoving: C, isZooming: b }) => {
883
+ if (!e || !p || !c) return;
884
+ const Q = (({ canvasBoundingRect: g, canvasSize: w, size: L, startDiff: D, startZoom: V, startCenter: x, startOffset: Z, currentDiff: A, currentCenter: H, isMoving: F, isZooming: E }) => {
885
+ const W = E ? We(A / D * V, Pe[0], Pe[Pe.length - 1]) : V, G = F ? [Z[0] + (H[0] - x[0]) * (w.width / g.width) / w.scaleRatio / V, Z[1] + (H[1] - x[1]) * (w.height / g.height) / w.scaleRatio / V] : [Z[0], Z[1]], _ = [(H[0] - g.left) / w.scaleRatio, (H[1] - g.top) / w.scaleRatio];
886
+ return ci({ size: L, canvasSize: w, currentOffset: G, currentZoom: V, zoom: W, centerPoint: _ });
887
+ })({ canvasBoundingRect: e.getBoundingClientRect(), canvasSize: i, size: n, startDiff: c, startZoom: u, startCenter: f, startOffset: v, currentDiff: p, currentCenter: S, isMoving: C, isZooming: b });
888
+ a(Q);
879
889
  }, [e, i, n, a]);
880
890
  ee(() => {
881
891
  if (!e) return;
882
- const h = (u) => {
892
+ const c = (u) => {
883
893
  if (o.current = [...o.current, u], r(o.current.length > 0), o.current.length === 2) {
884
894
  u.stopPropagation();
885
- const { diff: v, center: f } = ln(o.current);
886
- s.current = { startDiff: v, startCenter: f, startZoom: l.current.zoom, startOffset: l.current.offset, isMoving: !1, isZooming: !1 };
895
+ const { diff: f, center: v } = dn(o.current);
896
+ s.current = { startDiff: f, startCenter: v, startZoom: l.current.zoom, startOffset: l.current.offset, isMoving: !1, isZooming: !1 };
887
897
  }
888
898
  };
889
- return e.addEventListener("pointerdown", h), () => {
890
- e.removeEventListener("pointerdown", h);
899
+ return e.addEventListener("pointerdown", c), () => {
900
+ e.removeEventListener("pointerdown", c);
891
901
  };
892
902
  }, [e]), ee(() => {
893
903
  if (!d) return;
894
- const h = (v) => {
895
- const f = o.current.findIndex((g) => g.pointerId === v.pointerId);
896
- if (f > -1 && (o.current[f] = v), o.current.length === 2 && s.current) {
897
- const { diff: g, center: Q } = ln(o.current), M = s.current.isZooming || ((S, p) => Math.abs(S - p.startDiff) > 30)(g, s.current), b = s.current.isMoving || M || ((S, p) => Math.abs(ia(S, p.startCenter)) > 10)(Q, s.current);
898
- s.current = { ...s.current, isMoving: b, isZooming: M }, c({ ...s.current, currentDiff: g, currentCenter: Q });
904
+ const c = (f) => {
905
+ const v = o.current.findIndex((p) => p.pointerId === f.pointerId);
906
+ if (v > -1 && (o.current[v] = f), o.current.length === 2 && s.current) {
907
+ const { diff: p, center: S } = dn(o.current), C = s.current.isZooming || ((Q, g) => Math.abs(Q - g.startDiff) > 30)(p, s.current), b = s.current.isMoving || C || ((Q, g) => Math.abs(na(Q, g.startCenter)) > 10)(S, s.current);
908
+ s.current = { ...s.current, isMoving: b, isZooming: C }, h({ ...s.current, currentDiff: p, currentCenter: S });
899
909
  }
900
- }, u = (v) => {
901
- o.current = o.current.filter((f) => f.pointerId !== v.pointerId), r(o.current.length > 0);
910
+ }, u = (f) => {
911
+ o.current = o.current.filter((v) => v.pointerId !== f.pointerId), r(o.current.length > 0);
902
912
  };
903
- return document.addEventListener("pointermove", h), document.addEventListener("pointerup", u), document.addEventListener("pointerout", u), document.addEventListener("pointercancel", u), document.addEventListener("pointerleave", u), () => {
904
- document.removeEventListener("pointermove", h), document.removeEventListener("pointerup", u), document.removeEventListener("pointerout", u), document.removeEventListener("pointercancel", u), document.removeEventListener("pointerleave", u);
913
+ return document.addEventListener("pointermove", c), document.addEventListener("pointerup", u), document.addEventListener("pointerout", u), document.addEventListener("pointercancel", u), document.addEventListener("pointerleave", u), () => {
914
+ document.removeEventListener("pointermove", c), document.removeEventListener("pointerup", u), document.removeEventListener("pointerout", u), document.removeEventListener("pointercancel", u), document.removeEventListener("pointerleave", u);
905
915
  };
906
- }, [d, c]);
907
- }, dn = { offset: [0, 0], zoom: 1 }, bo = ({ canvasSize: e, size: t, zoomEnabled: i, canvasElt: n }) => {
908
- const [a, o] = X(dn), d = ne(0), r = Y((c) => {
909
- o(({ zoom: h }) => di({ zoom: h, size: t, canvasSize: e, newOffset: c }));
910
- }, [e, t]), s = Y((c) => {
911
- o(({ offset: h, zoom: u }) => (({ size: v, canvasSize: f, currentOffset: g, currentZoom: Q, action: M }) => {
912
- const b = M === "default" ? Pe[4] : M === "zoom" ? Pe[We(Pe.length - 1 - Pe.slice(0).reverse().findIndex((p) => p <= Q) + 1, 0, Pe.length - 1)] : Pe[We(Pe.findIndex((p) => p >= Q) - 1, 0, Pe.length - 1)], S = [f.realWidth / 2, f.realHeight / 2];
913
- return ci({ size: v, canvasSize: f, currentOffset: g, currentZoom: Q, zoom: b, centerPoint: S });
914
- })({ size: t, canvasSize: e, currentOffset: h, currentZoom: u, action: c }));
916
+ }, [d, h]);
917
+ }, cn = { offset: [0, 0], zoom: 1 }, wo = ({ canvasSize: e, size: t, zoomEnabled: i, canvasElt: n }) => {
918
+ const [a, o] = $(cn), d = ne(0), r = X((h) => {
919
+ o(({ zoom: c }) => di({ zoom: c, size: t, canvasSize: e, newOffset: h }));
920
+ }, [e, t]), s = X((h) => {
921
+ o(({ offset: c, zoom: u }) => (({ size: f, canvasSize: v, currentOffset: p, currentZoom: S, action: C }) => {
922
+ const b = C === "default" ? Pe[4] : C === "zoom" ? Pe[We(Pe.length - 1 - Pe.slice(0).reverse().findIndex((g) => g <= S) + 1, 0, Pe.length - 1)] : Pe[We(Pe.findIndex((g) => g >= S) - 1, 0, Pe.length - 1)], Q = [v.realWidth / 2, v.realHeight / 2];
923
+ return ci({ size: f, canvasSize: v, currentOffset: p, currentZoom: S, zoom: b, centerPoint: Q });
924
+ })({ size: t, canvasSize: e, currentOffset: c, currentZoom: u, action: h }));
915
925
  }, [e, t]);
916
- Qo({ canvasElt: n, canvasTransformation: a, canvasSize: e, size: t, setCanvasTransformation: o });
917
- const l = Y(() => {
918
- o(dn);
926
+ bo({ canvasElt: n, canvasTransformation: a, canvasSize: e, size: t, setCanvasTransformation: o });
927
+ const l = X(() => {
928
+ o(cn);
919
929
  }, []);
920
930
  return ee(() => {
921
931
  if (!i || !n) return;
922
- const c = (h) => {
923
- const u = h.ctrlKey, { deltaX: v, deltaY: f } = ((b, S) => {
924
- const p = Math.abs(b.deltaY) < 50 && S < 50, w = b.ctrlKey, L = Jn() && p && w;
932
+ const h = (c) => {
933
+ const u = c.ctrlKey, { deltaX: f, deltaY: v } = ((b, Q) => {
934
+ const g = Math.abs(b.deltaY) < 50 && Q < 50, w = b.ctrlKey, L = ea() && g && w;
925
935
  switch (b.deltaMode) {
926
936
  case WheelEvent.DOM_DELTA_LINE:
927
937
  return { deltaX: 16 * b.deltaX, deltaY: 16 * b.deltaY };
@@ -930,58 +940,58 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
930
940
  default:
931
941
  return L ? { deltaX: 5 * b.deltaX, deltaY: 5 * b.deltaY } : { deltaX: b.deltaX, deltaY: b.deltaY };
932
942
  }
933
- })(h, h.timeStamp - d.current);
934
- if (d.current = h.timeStamp, u) {
935
- h.preventDefault();
936
- const b = ra(h, n, e);
937
- return void o(({ offset: S, zoom: p }) => (({ size: w, canvasSize: L, currentOffset: D, currentZoom: V, delta: x, centerPoint: Z }) => {
943
+ })(c, c.timeStamp - d.current);
944
+ if (d.current = c.timeStamp, u) {
945
+ c.preventDefault();
946
+ const b = la(c, n, e);
947
+ return void o(({ offset: Q, zoom: g }) => (({ size: w, canvasSize: L, currentOffset: D, currentZoom: V, delta: x, centerPoint: Z }) => {
938
948
  const A = We(V * (1 - x / 1e3), Pe[0], Pe[Pe.length - 1]);
939
949
  return ci({ size: w, canvasSize: L, currentOffset: D, currentZoom: V, zoom: A, centerPoint: Z });
940
- })({ size: t, canvasSize: e, currentOffset: S, currentZoom: p, delta: f, centerPoint: b }));
950
+ })({ size: t, canvasSize: e, currentOffset: Q, currentZoom: g, delta: v, centerPoint: b }));
941
951
  }
942
- const g = h.shiftKey, [Q, M] = g ? [f, v] : [v, f];
943
- o(({ offset: b, zoom: S }) => {
944
- const p = [b[0] - Q / S, b[1] - M / S], w = di({ zoom: S, size: t, canvasSize: e, newOffset: p });
945
- return w.offset[0] === b[0] && w.offset[1] === b[1] || h.preventDefault(), w;
952
+ const p = c.shiftKey, [S, C] = p ? [v, f] : [f, v];
953
+ o(({ offset: b, zoom: Q }) => {
954
+ const g = [b[0] - S / Q, b[1] - C / Q], w = di({ zoom: Q, size: t, canvasSize: e, newOffset: g });
955
+ return w.offset[0] === b[0] && w.offset[1] === b[1] || c.preventDefault(), w;
946
956
  });
947
957
  };
948
- return n.addEventListener("wheel", c, { passive: !1 }), () => {
949
- n.removeEventListener("wheel", c);
958
+ return n.addEventListener("wheel", h, { passive: !1 }), () => {
959
+ n.removeEventListener("wheel", h);
950
960
  };
951
961
  }, [n, t, e, i]), { setCanvasTransformation: o, setCanvasOffset: r, setCanvasZoom: s, resetZoom: l, canvasTransformation: a };
952
- }, cn = (e, t = !1) => {
962
+ }, hn = (e, t = !1) => {
953
963
  const i = (a, o) => {
954
964
  if (Array.isArray(a)) return o;
955
965
  }, n = e.map((a) => {
956
966
  if (typeof a != "object") return null;
957
967
  switch (a.type) {
958
968
  case "brush":
959
- return Ie(i, In, a);
969
+ return Ie(i, Wn, a);
960
970
  case "circle":
961
- return Ie(i, Fn, a);
971
+ return Ie(i, Yn, a);
962
972
  case "curve":
963
- return Ie(i, Nn, a);
973
+ return Ie(i, Bn, a);
964
974
  case "ellipse":
965
- return Ie(i, Yn, a);
975
+ return Ie(i, Xn, a);
966
976
  case "line":
967
- return Ie(i, Wn, a);
968
- case "polygon":
969
977
  return Ie(i, Rn, a);
978
+ case "polygon":
979
+ return Ie(i, Nn, a);
970
980
  case "rect":
971
- return Ie(i, Bn, a);
972
- case "square":
973
981
  return Ie(i, On, a);
982
+ case "square":
983
+ return Ie(i, Fn, a);
974
984
  case "text":
975
- return Ie(i, Xn, a);
985
+ return Ie(i, $n, a);
976
986
  }
977
987
  return null;
978
988
  });
979
- return wi(t ? [...n, vi] : n);
980
- }, hs = ({ width: e = 1e3, height: t = 600, shapes: i, mode: n = "editor", disabled: a = !1, options: o = Ni } = {}) => {
981
- const { layersManipulation: d, brushAlgo: r, isBrushShapeDoneOnMouseUp: s, debug: l, grid: c, canGrow: h, canShrink: u, withExport: v, withLoadAndSave: f, withUploadPicture: g, withUrlPicture: Q, withSkeleton: M, withFrameSelection: b, clearCallback: S, availableTools: p, canvasSelectionPadding: w, size: L, canZoom: D } = { ...Ni, ...o }, V = n !== "viewer", x = ne(null), Z = ne(null), A = ne(!1), H = Y((ie) => {
989
+ return xi(t ? [...n, fi] : n);
990
+ }, us = ({ width: e = 1e3, height: t = 600, shapes: i, mode: n = "editor", disabled: a = !1, options: o = Bi } = {}) => {
991
+ const { layersManipulation: d, brushAlgo: r, isBrushShapeDoneOnMouseUp: s, debug: l, grid: h, canGrow: c, canShrink: u, withExport: f, withLoadAndSave: v, withUploadPicture: p, withUrlPicture: S, withSkeleton: C, withFrameSelection: b, clearCallback: Q, availableTools: g, canvasSelectionPadding: w, size: L, canZoom: D } = { ...Bi, ...o }, V = n !== "viewer", x = ne(null), Z = ne(null), A = ne(!1), H = X((ie) => {
982
992
  x.current = ie;
983
- }, []), [F, I] = X(void 0), [W, q] = X(Oe), [G, z] = X({ mode: "default" }), [y, C] = X(c), [P, T] = X({ realWidth: e, realHeight: t, width: e, height: t, scaleRatio: 1 }), k = D === "always" && !a, { canvasTransformation: O, setCanvasTransformation: R, setCanvasOffset: B, setCanvasZoom: E, resetZoom: K } = bo({ canvasSize: P, size: L, canvasElt: Z.current, zoomEnabled: k }), { offset: de, zoom: se } = O, j = Pn(() => ({ brushAlgo: r, isBrushShapeDoneOnMouseUp: s, debug: l, canvasSize: { realWidth: P.realWidth, realHeight: P.realHeight, width: P.width, height: P.height, scaleRatioWithNoZoom: P.scaleRatio, scaleRatio: P.scaleRatio * se }, size: L, canvasOffset: de, canvasZoom: se, gridGap: y, selectionPadding: w, features: { edition: V && !a, zoom: k } }), [w, y, r, s, l, se, de, P, L, a, k, V]), [N, ge] = X(cn(p, g || Q)), { isInsideComponent: oe, isInsideCanvas: ye } = (({ settings: ie, componentRef: ce, canvasRef: He }) => {
984
- const [Ye, Xe] = X(!1), [je, Ke] = X(!1), be = !ie.features.edition && !ie.features.zoom;
993
+ }, []), [F, E] = $(void 0), [W, G] = $(Oe), [_, z] = $({ mode: "default" }), [y, M] = $(h), [P, T] = $({ realWidth: e, realHeight: t, width: e, height: t, scaleRatio: 1 }), k = D === "always" && !a, { canvasTransformation: O, setCanvasTransformation: R, setCanvasOffset: B, setCanvasZoom: I, resetZoom: j } = wo({ canvasSize: P, size: L, canvasElt: Z.current, zoomEnabled: k }), { offset: de, zoom: se } = O, K = kn(() => ({ brushAlgo: r, isBrushShapeDoneOnMouseUp: s, debug: l, canvasSize: { realWidth: P.realWidth, realHeight: P.realHeight, width: P.width, height: P.height, scaleRatioWithNoZoom: P.scaleRatio, scaleRatio: P.scaleRatio * se }, size: L, canvasOffset: de, canvasZoom: se, gridGap: y, selectionPadding: w, features: { edition: V && !a, zoom: k } }), [w, y, r, s, l, se, de, P, L, a, k, V]), [N, ge] = $(hn(g, p || S)), { isInsideComponent: oe, isInsideCanvas: ye } = (({ settings: ie, componentRef: ce, canvasRef: He }) => {
994
+ const [Ye, Xe] = $(!1), [je, Ke] = $(!1), be = !ie.features.edition && !ie.features.zoom;
985
995
  return ee(() => {
986
996
  if (!be) {
987
997
  const ze = () => Xe(!0), wt = () => Xe(!1), $e = () => Ke(!0), xt = () => Ke(!1);
@@ -991,16 +1001,16 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
991
1001
  }
992
1002
  Xe(!1), Ke(!1);
993
1003
  }, [be, ce, He]), { isInsideComponent: Ye, isInsideCanvas: je };
994
- })({ settings: j, componentRef: x, canvasRef: Z }), [Se, Qe] = X(!1), [te, fe] = X(!1), [$, ae] = X(!1), { registerEvent: Me, unregisterEvent: Ze, shapesRef: re, selectedShape: Te, selectionFrame: qe, hoveredShape: Ot, addShapes: Ee, addPictureShape: Ft, moveShapes: Yt, setSelectedShape: Ge, setSelectionFrame: Xt, refreshSelectedShapes: $t, refreshHoveredShape: Ut, duplicateShapes: ve, removeShape: me, updateShape: ft, backwardShape: Fe, forwardShape: at, clearShapes: Ci, saveShapes: Mi, toggleShapeVisibility: ba, toggleShapeLock: wa, canGoBackward: xa, canGoForward: Ca, canClear: Ma } = So(j, e, t, Se), qt = Y((ie) => {
995
- Ge(void 0), q(ie);
996
- }, [Ge]), [ot, Pi] = X([0, 0]), ki = G.mode === "preview";
1004
+ })({ settings: K, componentRef: x, canvasRef: Z }), [Se, Qe] = $(!1), [te, ve] = $(!1), [U, ae] = $(!1), { registerEvent: Me, unregisterEvent: Ze, shapesRef: re, selectedShape: Te, selectionFrame: qe, hoveredShape: Ot, addShapes: De, addPictureShape: Ft, moveShapes: Yt, setSelectedShape: Ge, setSelectionFrame: Xt, refreshSelectedShapes: $t, refreshHoveredShape: Ut, duplicateShapes: fe, removeShape: me, updateShape: gt, backwardShape: Fe, forwardShape: at, clearShapes: Mi, saveShapes: Pi, toggleShapeVisibility: wa, toggleShapeLock: xa, canGoBackward: Ca, canGoForward: Ma, canClear: Pa } = Qo(K, e, t, Se), qt = X((ie) => {
1005
+ Ge(void 0), G(ie);
1006
+ }, [Ge]), [ot, ki] = $([0, 0]), Li = _.mode === "preview";
997
1007
  ee(() => {
998
- if (ki) return () => z((ie) => ie.mode === "preview" ? { mode: "default" } : ie);
999
- }, [Te?.id, ki]);
1000
- const Li = G.mode === "selectionFrame";
1008
+ if (Li) return () => z((ie) => ie.mode === "preview" ? { mode: "default" } : ie);
1009
+ }, [Te?.id, Li]);
1010
+ const Vi = _.mode === "selectionFrame";
1001
1011
  ee(() => {
1002
- if (Li) return () => Pi([0, 0]);
1003
- }, [Li]), ee(() => {
1012
+ if (Vi) return () => ki([0, 0]);
1013
+ }, [Vi]), ee(() => {
1004
1014
  if (ot[0] !== 0 || ot[1] !== 0) {
1005
1015
  const ie = setInterval(() => {
1006
1016
  R(({ offset: ce, zoom: He }) => {
@@ -1011,22 +1021,22 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
1011
1021
  return () => clearInterval(ie);
1012
1022
  }
1013
1023
  }, [ot[0], ot[1], R, L, P]);
1014
- const bt = Y((ie, ce) => {
1015
- Ci(ie, ce), qt(Oe), R({ offset: [0, 0], zoom: 1 });
1016
- }, [qt, Ci, R]), Vi = Y((ie) => {
1017
- Ge((ce) => (ce?.id !== ie.map((He) => He.id).join("-") && q(Oe), pe(ie, j)));
1018
- }, [Ge, j]), Pa = Y(() => {
1019
- const ie = mo(re.current, e, t);
1024
+ const bt = X((ie, ce) => {
1025
+ Mi(ie, ce), qt(Oe), R({ offset: [0, 0], zoom: 1 });
1026
+ }, [qt, Mi, R]), Zi = X((ie) => {
1027
+ Ge((ce) => (ce?.id !== ie.map((He) => He.id).join("-") && G(Oe), pe(ie, K)));
1028
+ }, [Ge, K]), ka = X(() => {
1029
+ const ie = yo(re.current, e, t);
1020
1030
  if (!ie) throw new Error("L'encodage a échoué");
1021
- on(ie, "drawing.json");
1022
- }, [re, e, t]), ka = Y((ie) => {
1023
- const ce = sn({ shapes: re.current, settings: j, view: ie });
1024
- on(ce, "drawing.png");
1025
- }, [re, j]), La = Y((ie) => sn({ shapes: re.current, settings: j, view: ie }), [re, j]), Va = Y(() => xi(re.current, e, t), [re, e, t]), _e = Y(async (ie, ce) => {
1031
+ sn(ie, "drawing.json");
1032
+ }, [re, e, t]), La = X((ie) => {
1033
+ const ce = rn({ shapes: re.current, settings: K, view: ie });
1034
+ sn(ce, "drawing.png");
1035
+ }, [re, K]), Va = X((ie) => rn({ shapes: re.current, settings: K, view: ie }), [re, K]), Za = X(() => Ci(re.current, e, t), [re, e, t]), _e = X(async (ie, ce) => {
1026
1036
  const He = await (async (Ye, Xe) => {
1027
1037
  if (!Ye) return [];
1028
- const je = [], Ke = wi(Ye.map((be) => {
1029
- if (!be || !Gn.includes(be.type)) return null;
1038
+ const je = [], Ke = xi(Ye.map((be) => {
1039
+ if (!be || !_n.includes(be.type)) return null;
1030
1040
  if (be.type === "picture") {
1031
1041
  const ze = new Image(), wt = new Promise(($e, xt) => {
1032
1042
  ze.onload = () => {
@@ -1035,7 +1045,7 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
1035
1045
  xt(new Error("Some images could not be loaded"));
1036
1046
  };
1037
1047
  });
1038
- if (je.push(wt), be.src.startsWith("http")) Sa(be.src).then(($e) => {
1048
+ if (je.push(wt), be.src.startsWith("http")) Qa(be.src).then(($e) => {
1039
1049
  ze.src = $e;
1040
1050
  }).catch(() => {
1041
1051
  ze.src = "";
@@ -1044,22 +1054,22 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
1044
1054
  const $e = new Blob([be.src], { type: "image/svg+xml" });
1045
1055
  ze.src = URL.createObjectURL($e);
1046
1056
  } else ze.src = be.src;
1047
- return rn({ ...be, img: ze }, Xe);
1057
+ return ln({ ...be, img: ze }, Xe);
1048
1058
  }
1049
- return rn(be, Xe);
1059
+ return ln(be, Xe);
1050
1060
  }));
1051
1061
  return await Promise.all(je), Ke;
1052
- })(ie, j);
1062
+ })(ie, K);
1053
1063
  bt(He, ce);
1054
- }, [bt, j]), Gt = ne(_e);
1064
+ }, [bt, K]), Gt = ne(_e);
1055
1065
  Gt.current = _e;
1056
- const Za = Y((ie = [], ce = !0) => {
1066
+ const Ha = X((ie = [], ce = !0) => {
1057
1067
  Gt.current?.(ie, { clearHistory: ce, source: "remote" });
1058
1068
  }, []);
1059
1069
  ee(() => {
1060
1070
  A.current || (A.current = !0, i && Gt.current?.(i, { clearHistory: !0, source: "remote" }));
1061
1071
  }, [i]);
1062
- const Ha = Y(async (ie) => {
1072
+ const za = X(async (ie) => {
1063
1073
  const ce = await (async (He) => new Promise((Ye, Xe) => {
1064
1074
  const je = new FileReader();
1065
1075
  je.onload = (Ke) => {
@@ -1070,329 +1080,329 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
1070
1080
  }, je.readAsText(He);
1071
1081
  }))(ie);
1072
1082
  await _e(ce.shapes ?? [], { clearHistory: !0, source: "remote" });
1073
- }, [_e]), za = Y(() => {
1074
- typeof S != "string" ? _e(S(), { clearHistory: !1, source: "user" }) : S === "defaultShapes" && i !== void 0 ? _e(i, { clearHistory: !1, source: "user" }) : bt([], { clearHistory: !1, source: "user" });
1075
- }, [bt, _e, i, S]);
1083
+ }, [_e]), Ta = X(() => {
1084
+ typeof Q != "string" ? _e(Q(), { clearHistory: !1, source: "user" }) : Q === "defaultShapes" && i !== void 0 ? _e(i, { clearHistory: !1, source: "user" }) : bt([], { clearHistory: !1, source: "user" });
1085
+ }, [bt, _e, i, Q]);
1076
1086
  ee(() => {
1077
- ge(cn(p, g || Q));
1078
- }, [p, g, Q]);
1079
- const Zi = { canvas: Z, editor: x, setEditor: H };
1080
- return { annotationsProps: { style: { userSelect: "none", touchAction: "none", transformOrigin: "left top", transform: "scale(var(--react-paint-canvas-zoom)) translate(calc(var(--react-paint-canvas-offset-x) * 100% / var(--react-paint-app-canvaswidth)), calc(var(--react-paint-canvas-offset-y) * 100% / var(--react-paint-app-canvasheight)))", "--react-paint-canvas-zoom": j.canvasZoom, "--react-paint-canvas-offset-x": j.canvasOffset[0], "--react-paint-canvas-offset-y": j.canvasOffset[1], "--react-paint-app-canvaswidth": e, "--react-paint-app-canvasheight": t } }, editorProps: { shapesRef: re, addPictureShape: Ft, moveShapes: Yt, toggleShapeVisibility: ba, toggleShapeLock: wa, canGoBackward: xa, canGoForward: Ca, canClear: Ma, selectedShape: Te, saveShapes: Mi, removeShape: me, updateShape: ft, backwardShape: Fe, forwardShape: at, refs: Zi, width: e, height: t, selectTool: qt, selectShapes: Vi, activeTool: W, setActiveTool: q, setAvailableTools: ge, isEditMode: V, availableTools: N, gridGap: y, setGridGap: C, loadFile: Ha, exportPicture: ka, exportData: Pa, clearCanvas: za, settings: j, setCanvasZoom: E, resetZoom: K, canvas: { canGrow: h, canShrink: u, layersManipulation: d, withExport: v, withLoadAndSave: f, withUploadPicture: g, withUrlPicture: Q } }, canvasProps: { shapesRef: re, selectedShape: Te, selectionFrame: qe, hoveredShape: Ot, addShape: Ee, setSelectedShape: Ge, setSelectionFrame: Xt, refreshSelectedShapes: $t, refreshHoveredShape: Ut, removeShape: me, updateShape: ft, duplicateShapes: ve, backwardShape: Fe, forwardShape: at, saveShapes: Mi, refs: Zi, width: e, height: t, settings: j, setCanvasSize: T, setCanvasOffset: B, setCanvasZoom: E, resetZoom: K, selectShapes: Vi, activeTool: W, setActiveTool: q, isInsideComponent: oe, isInsideCanvas: ye, isEditMode: V, canvas: { withSkeleton: M, withFrameSelection: b, canGrow: h, canShrink: u }, canvasOffsetStartData: F, setCanvasOffsetStartData: I, selectionMode: G, setSelectionMode: z, setCanvasMoveAcceleration: Pi, isShiftPressed: Se, isAltPressed: te, isSpacePressed: $, setShiftPressed: Qe, setAltPressed: fe, setIsSpacePressed: ae }, registerEvent: Me, unregisterEvent: Ze, resetCanvas: Za, resetZoom: K, getCurrentImage: La, getCurrentData: Va, setCanvasOffset: B, setCanvasZoom: E };
1081
- }, wo = ({ addShapes: e, drawCanvasRef: t, setActiveTool: i, refreshHoveredShape: n, shapes: a, selectionMode: o, activeTool: d, isInsideComponent: r, setCanvasOffset: s, selectedShape: l, canvasOffsetStartData: c, refreshSelectedShapes: h, setSelectedShape: u, setSelectionFrame: v, setCanvasOffsetStartData: f, updateSingleShape: g, duplicateShapes: Q, saveShapes: M, setSelectionMode: b, setCanvasMoveAcceleration: S, settings: p, isShiftPressed: w, isAltPressed: L, withFrameSelection: D, isSpacePressed: V }) => {
1082
- const [x, Z] = X({ mode: "default" }), { registerDoubleClickEvent: A, unRegisterDoubleClickEvent: H } = (() => {
1083
- const y = ne(void 0), C = ne(void 0), P = (T) => {
1087
+ ge(hn(g, p || S));
1088
+ }, [g, p, S]);
1089
+ const Hi = { canvas: Z, editor: x, setEditor: H };
1090
+ return { annotationsProps: { style: { userSelect: "none", touchAction: "none", transformOrigin: "left top", transform: "scale(var(--react-paint-canvas-zoom)) translate(calc(var(--react-paint-canvas-offset-x) * 100% / var(--react-paint-app-canvaswidth)), calc(var(--react-paint-canvas-offset-y) * 100% / var(--react-paint-app-canvasheight)))", "--react-paint-canvas-zoom": K.canvasZoom, "--react-paint-canvas-offset-x": K.canvasOffset[0], "--react-paint-canvas-offset-y": K.canvasOffset[1], "--react-paint-app-canvaswidth": e, "--react-paint-app-canvasheight": t } }, editorProps: { shapesRef: re, addPictureShape: Ft, moveShapes: Yt, toggleShapeVisibility: wa, toggleShapeLock: xa, canGoBackward: Ca, canGoForward: Ma, canClear: Pa, selectedShape: Te, saveShapes: Pi, removeShape: me, updateShape: gt, backwardShape: Fe, forwardShape: at, refs: Hi, width: e, height: t, selectTool: qt, selectShapes: Zi, activeTool: W, setActiveTool: G, setAvailableTools: ge, isEditMode: V, availableTools: N, gridGap: y, setGridGap: M, loadFile: za, exportPicture: La, exportData: ka, clearCanvas: Ta, settings: K, setCanvasZoom: I, resetZoom: j, canvas: { canGrow: c, canShrink: u, layersManipulation: d, withExport: f, withLoadAndSave: v, withUploadPicture: p, withUrlPicture: S } }, canvasProps: { shapesRef: re, selectedShape: Te, selectionFrame: qe, hoveredShape: Ot, addShape: De, setSelectedShape: Ge, setSelectionFrame: Xt, refreshSelectedShapes: $t, refreshHoveredShape: Ut, removeShape: me, updateShape: gt, duplicateShapes: fe, backwardShape: Fe, forwardShape: at, saveShapes: Pi, refs: Hi, width: e, height: t, settings: K, setCanvasSize: T, setCanvasOffset: B, setCanvasZoom: I, resetZoom: j, selectShapes: Zi, activeTool: W, setActiveTool: G, isInsideComponent: oe, isInsideCanvas: ye, isEditMode: V, canvas: { withSkeleton: C, withFrameSelection: b, canGrow: c, canShrink: u }, canvasOffsetStartData: F, setCanvasOffsetStartData: E, selectionMode: _, setSelectionMode: z, setCanvasMoveAcceleration: ki, isShiftPressed: Se, isAltPressed: te, isSpacePressed: U, setShiftPressed: Qe, setAltPressed: ve, setIsSpacePressed: ae }, registerEvent: Me, unregisterEvent: Ze, resetCanvas: Ha, resetZoom: j, getCurrentImage: Va, getCurrentData: Za, setCanvasOffset: B, setCanvasZoom: I };
1091
+ }, xo = ({ addShapes: e, drawCanvasRef: t, setActiveTool: i, refreshHoveredShape: n, shapes: a, selectionMode: o, activeTool: d, isInsideComponent: r, setCanvasOffset: s, selectedShape: l, canvasOffsetStartData: h, refreshSelectedShapes: c, setSelectedShape: u, setSelectionFrame: f, setCanvasOffsetStartData: v, updateSingleShape: p, duplicateShapes: S, saveShapes: C, setSelectionMode: b, setCanvasMoveAcceleration: Q, settings: g, isShiftPressed: w, isAltPressed: L, withFrameSelection: D, isSpacePressed: V }) => {
1092
+ const [x, Z] = $({ mode: "default" }), { registerDoubleClickEvent: A, unRegisterDoubleClickEvent: H } = (() => {
1093
+ const y = ne(void 0), M = ne(void 0), P = (T) => {
1084
1094
  const k = Date.now();
1085
- y.current && k < y.current + 300 && C.current?.(T), y.current = Date.now();
1095
+ y.current && k < y.current + 300 && M.current?.(T), y.current = Date.now();
1086
1096
  };
1087
1097
  return { registerDoubleClickEvent: (T, k) => {
1088
- C.current = k, T.addEventListener("click", P), T.addEventListener("touchend", P);
1098
+ M.current = k, T.addEventListener("click", P), T.addEventListener("touchend", P);
1089
1099
  }, unRegisterDoubleClickEvent: (T) => {
1090
1100
  T.removeEventListener("click", P), T.removeEventListener("touchend", P);
1091
1101
  } };
1092
1102
  })(), F = ne(null);
1093
- F.current = (y) => ((C, P, T, k, O, R, B, E, K, de, se, j, N, ge, oe, ye, Se) => {
1094
- if (rt(C) && C.touches.length > 1) return;
1103
+ F.current = (y) => ((M, P, T, k, O, R, B, I, j, de, se, K, N, ge, oe, ye, Se) => {
1104
+ if (rt(M) && M.touches.length > 1) return;
1095
1105
  const Qe = P.current?.getContext("2d");
1096
1106
  if (!Qe) return;
1097
- const te = st(C, P.current, N);
1107
+ const te = st(M, P.current, N);
1098
1108
  if (k.mode === "selectionFrame") {
1099
- j(Qe, te, N);
1100
- const $ = ra(C, P.current, N.canvasSize);
1101
- return void Se([Math.ceil(We($[0] * N.canvasZoom < 50 ? $[0] * N.canvasZoom - 50 : $[0] * N.canvasZoom > N.canvasSize.width / N.canvasSize.scaleRatioWithNoZoom - 50 ? $[0] * N.canvasZoom - (N.canvasSize.width / N.canvasSize.scaleRatioWithNoZoom - 50) : 0, -100, 100) / 5 / N.canvasZoom), Math.ceil(We($[1] * N.canvasZoom < 50 ? $[1] * N.canvasZoom - 50 : $[1] * N.canvasZoom > N.canvasSize.height / N.canvasSize.scaleRatioWithNoZoom - 50 ? $[1] * N.canvasZoom - (N.canvasSize.height / N.canvasSize.scaleRatioWithNoZoom - 50) : 0, -100, 100) / 5 / N.canvasZoom)]);
1109
+ K(Qe, te, N);
1110
+ const U = la(M, P.current, N.canvasSize);
1111
+ return void Se([Math.ceil(We(U[0] * N.canvasZoom < 50 ? U[0] * N.canvasZoom - 50 : U[0] * N.canvasZoom > N.canvasSize.width / N.canvasSize.scaleRatioWithNoZoom - 50 ? U[0] * N.canvasZoom - (N.canvasSize.width / N.canvasSize.scaleRatioWithNoZoom - 50) : 0, -100, 100) / 5 / N.canvasZoom), Math.ceil(We(U[1] * N.canvasZoom < 50 ? U[1] * N.canvasZoom - 50 : U[1] * N.canvasZoom > N.canvasSize.height / N.canvasSize.scaleRatioWithNoZoom - 50 ? U[1] * N.canvasZoom - (N.canvasSize.height / N.canvasSize.scaleRatioWithNoZoom - 50) : 0, -100, 100) / 5 / N.canvasZoom)]);
1102
1112
  }
1103
1113
  if (R !== void 0) return void se([te[0] + N.canvasOffset[0] - R.start[0], te[1] + N.canvasOffset[1] - R.start[1]]);
1104
1114
  if (k.mode === "preview") {
1105
- const $ = _(T)[0];
1106
- if ($?.type === "curve") {
1107
- const ae = ji($, te, N, !0);
1115
+ const U = Y(T)[0];
1116
+ if (U?.type === "curve") {
1117
+ const ae = Ki(U, te, N, !0);
1108
1118
  return void ye(pe([ae], N));
1109
1119
  }
1110
- if ($?.type === "polygon") {
1111
- const ae = _i($, te, N, !0);
1120
+ if (U?.type === "polygon") {
1121
+ const ae = ji(U, te, N, !0);
1112
1122
  return void ye(pe([ae], N));
1113
1123
  }
1114
1124
  }
1115
- const fe = vt(te, N);
1116
- if (rt(C) || E(C, Qe, te, fe), T === void 0 || T.locked) B({ mode: "default", outOfView: !fe });
1125
+ const ve = vt(te, N);
1126
+ if (rt(M) || I(M, Qe, te, ve), T === void 0 || T.locked) B({ mode: "default", outOfView: !ve });
1117
1127
  else {
1118
1128
  if (k.mode === "default" || k.mode === "textedition") {
1119
- if (!fe) return void B({ mode: "default" });
1120
- B(ut(Qe, T, te, N, !0) || { mode: "default" });
1129
+ if (!ve) return void B({ mode: "default" });
1130
+ B(ft(Qe, T, te, N, !0) || { mode: "default" });
1121
1131
  } else {
1122
- const $ = P.current?.getContext("2d");
1123
- if (!$) return;
1124
- const ae = Ra($, T, te, k, N, ge, oe);
1125
- K(_(ae));
1132
+ const U = P.current?.getContext("2d");
1133
+ if (!U) return;
1134
+ const ae = Na(U, T, te, k, N, ge, oe);
1135
+ j(Y(ae));
1126
1136
  }
1127
- k.mode === "translate" && oe && !k.hasBeenDuplicated && (O({ ...k, hasBeenDuplicated: !0 }), de(_(k.originalShape)));
1137
+ k.mode === "translate" && oe && !k.hasBeenDuplicated && (O({ ...k, hasBeenDuplicated: !0 }), de(Y(k.originalShape)));
1128
1138
  }
1129
- })(y, t, l, o, b, c, Z, n, g, Q, s, h, p, w, L, u, S), ee(() => {
1139
+ })(y, t, l, o, b, h, Z, n, p, S, s, c, g, w, L, u, Q), ee(() => {
1130
1140
  if (r) {
1131
- const y = (C) => F.current?.(C);
1141
+ const y = (M) => F.current?.(M);
1132
1142
  return document.addEventListener("mousemove", y), document.addEventListener("touchmove", y), () => {
1133
1143
  document.removeEventListener("mousemove", y), document.removeEventListener("touchmove", y);
1134
1144
  };
1135
1145
  }
1136
1146
  }, [r]);
1137
- const { isBrushShapeDoneOnMouseUp: I } = p, W = ne(null);
1147
+ const { isBrushShapeDoneOnMouseUp: E } = g, W = ne(null);
1138
1148
  W.current = (y) => {
1139
1149
  if (rt(y) && y.touches.length > 1) return;
1140
- const C = t.current?.getContext("2d");
1141
- if (!C) return;
1142
- if ("button" in y && y.button === 2) return u(void 0), i(Oe), b({ mode: "default" }), void v(void 0);
1143
- if (c) return void f(void 0);
1150
+ const M = t.current?.getContext("2d");
1151
+ if (!M) return;
1152
+ if ("button" in y && y.button === 2) return u(void 0), i(Oe), b({ mode: "default" }), void f(void 0);
1153
+ if (h) return void v(void 0);
1144
1154
  if (o.mode === "textedition" || o.mode === "preview") return;
1145
- const P = st(y, t.current, p);
1155
+ const P = st(y, t.current, g);
1146
1156
  if (o.mode === "translate" && Date.now() - o.dateStart <= 500 && P[0] === o.cursorStartPosition[0] && P[1] === o.cursorStartPosition[1]) {
1147
- if (!(y.ctrlKey || y.shiftKey || y.metaKey)) {
1148
- const { shape: T } = $i(C, a, P, p, void 0, rt(y), D, !1);
1149
- u(T);
1157
+ if (y.ctrlKey || y.shiftKey || y.metaKey) {
1158
+ const { shape: T } = Ui(M, a, P, g, l, rt(y), D, "remove");
1159
+ Y(T).length !== o.selectedShapesLengthAtMouseDown && u(T);
1150
1160
  }
1151
- return b({ mode: "default" }), v(void 0), void M();
1161
+ return b({ mode: "default" }), f(void 0), void C();
1152
1162
  }
1153
- o.mode !== "default" && (o.mode === "brush" && I && u(void 0), b({ mode: "default" }), v(void 0), M());
1163
+ o.mode !== "default" && (o.mode === "brush" && E && u(void 0), b({ mode: "default" }), f(void 0), C());
1154
1164
  }, ee(() => {
1155
1165
  if (r) {
1156
- const y = (C) => W.current?.(C);
1166
+ const y = (M) => W.current?.(M);
1157
1167
  return document.addEventListener("mouseup", y), document.addEventListener("touchend", y), () => {
1158
1168
  document.removeEventListener("mouseup", y), document.removeEventListener("touchend", y);
1159
1169
  };
1160
1170
  }
1161
1171
  }, [r]);
1162
- const q = !p.features.edition && p.features.zoom, G = !p.features.edition && !p.features.zoom, z = ne(null);
1163
- return z.current = (y, C, P) => {
1172
+ const G = !g.features.edition && g.features.zoom, _ = !g.features.edition && !g.features.zoom, z = ne(null);
1173
+ return z.current = (y, M, P) => {
1164
1174
  if (y.preventDefault(), rt(y) && y.touches.length > 1) return;
1165
- const T = C?.getContext("2d");
1175
+ const T = M?.getContext("2d");
1166
1176
  if (!T) return;
1167
- C.focus();
1168
- const k = st(y, t.current, p), O = "button" in y && y.button === 1;
1177
+ M.focus();
1178
+ const k = st(y, t.current, g), O = "button" in y && y.button === 1;
1169
1179
  if (!("button" in y && y.button === 2)) {
1170
- if (O || P || d.type === "move") f({ start: k, originalOffset: p.canvasOffset });
1171
- else if (!q) {
1172
- if (!vt(k, p)) return u(void 0), void b({ mode: "default" });
1180
+ if (O || P || d.type === "move") v({ start: k, originalOffset: g.canvasOffset });
1181
+ else if (!G) {
1182
+ if (!vt(k, g)) return u(void 0), void b({ mode: "default" });
1173
1183
  if (d.type === "selection") {
1174
- const R = y.ctrlKey || y.shiftKey || y.metaKey, { shape: B, mode: E } = $i(T, a, k, p, l, rt(y), D, R);
1175
- u(B), b(E), E.mode === "selectionFrame" && v({ oldSelection: B, frame: [[k[0], k[1]], [k[0], k[1]]] });
1176
- } else if (Gn.some((R) => R === d.type)) {
1177
- const R = _(l)[0], B = t.current?.getContext("2d");
1184
+ const R = y.ctrlKey || y.shiftKey || y.metaKey ? "add" : "replace", { shape: B, mode: I } = Ui(T, a, k, g, l, rt(y), D, R);
1185
+ u(B), b(I), I.mode === "selectionFrame" && f({ oldSelection: B, frame: [[k[0], k[1]], [k[0], k[1]]] });
1186
+ } else if (_n.some((R) => R === d.type)) {
1187
+ const R = Y(l)[0], B = t.current?.getContext("2d");
1178
1188
  if (!B) return;
1179
1189
  if (d.type === "brush") {
1180
1190
  if (R?.type === "brush") {
1181
- const E = ((K, de, se) => {
1182
- const j = { ...K, points: Le(K.points.length, [[Math.round(de[0]), Math.round(de[1])]], K.points) };
1183
- return pt(j, se);
1184
- })(R, k, p);
1185
- g([E]);
1191
+ const I = ((j, de, se) => {
1192
+ const K = { ...j, points: Le(j.points.length, [[Math.round(de[0]), Math.round(de[1])]], j.points) };
1193
+ return ut(K, se);
1194
+ })(R, k, g);
1195
+ p([I]);
1186
1196
  } else {
1187
- const E = en(B, d, k, p);
1188
- if (!E) return;
1189
- e([E]), u(pe([E], p));
1197
+ const I = tn(B, d, k, g);
1198
+ if (!I) return;
1199
+ e([I]), u(pe([I], g));
1190
1200
  }
1191
1201
  b({ mode: "brush" });
1192
1202
  } else if (o.mode !== "preview" || R?.type !== "polygon" && R?.type !== "curve") {
1193
1203
  if (d.type !== "picture") {
1194
- const E = en(B, d, k, p);
1195
- if (!E) return;
1196
- e([E]);
1197
- const K = pe([E], p);
1198
- u(K), E.type === "polygon" || E.type === "curve" ? b({ mode: "preview" }) : (i(Oe), b({ mode: "resize", cursorStartPosition: [k[0] + p.selectionPadding, k[1] + p.selectionPadding], originalShape: K, anchor: E.type === "line" ? 0 : [1, 1] }));
1204
+ const I = tn(B, d, k, g);
1205
+ if (!I) return;
1206
+ e([I]);
1207
+ const j = pe([I], g);
1208
+ u(j), I.type === "polygon" || I.type === "curve" ? b({ mode: "preview" }) : (i(Oe), b({ mode: "resize", cursorStartPosition: [k[0] + g.selectionPadding, k[1] + g.selectionPadding], originalShape: j, anchor: I.type === "line" ? 0 : [1, 1], selectedShapesLengthAtMouseDown: Y(j).length }));
1199
1209
  }
1200
1210
  } else {
1201
- const E = R.type === "polygon" ? _i(R, k, p) : ji(R, k, p);
1202
- u(pe([E], p)), g([E], !0);
1211
+ const I = R.type === "polygon" ? ji(R, k, g) : Ki(R, k, g);
1212
+ u(pe([I], g)), p([I], !0);
1203
1213
  }
1204
1214
  }
1205
1215
  }
1206
1216
  }
1207
1217
  }, ee(() => {
1208
- if (G) return;
1218
+ if (_) return;
1209
1219
  const y = t.current;
1210
1220
  if (!y) return;
1211
- const C = (P) => z.current?.(P, y, V);
1212
- return y.addEventListener("mousedown", C, { passive: !1 }), y.addEventListener("touchstart", C, { passive: !1 }), () => {
1213
- y.removeEventListener("mousedown", C), y.removeEventListener("touchstart", C);
1221
+ const M = (P) => z.current?.(P, y, V);
1222
+ return y.addEventListener("mousedown", M, { passive: !1 }), y.addEventListener("touchstart", M, { passive: !1 }), () => {
1223
+ y.removeEventListener("mousedown", M), y.removeEventListener("touchstart", M);
1214
1224
  };
1215
- }, [G, t, V]), ee(() => {
1216
- const y = t.current, C = t.current?.getContext("2d");
1217
- if (!(!y || !C))
1225
+ }, [_, t, V]), ee(() => {
1226
+ const y = t.current, M = t.current?.getContext("2d");
1227
+ if (!(!y || !M))
1218
1228
  return r ? (A(y, (P) => {
1219
1229
  if (d.type === "selection") {
1220
- if (_(l).length !== 1) return;
1221
- const T = _(l)[0];
1230
+ if (Y(l).length !== 1) return;
1231
+ const T = Y(l)[0];
1222
1232
  if (T?.type === "text") {
1223
- const k = st(P, t.current, p);
1224
- return vt(k, p) ? void (ut(C, l, k, p) && b({ mode: "textedition", defaultValue: T.value })) : void 0;
1233
+ const k = st(P, t.current, g);
1234
+ return vt(k, g) ? void (ft(M, l, k, g) && b({ mode: "textedition", defaultValue: T.value })) : void 0;
1225
1235
  }
1226
1236
  if (T?.type === "polygon") {
1227
- const k = st(P, t.current, p);
1228
- if (!vt(k, p)) return;
1229
- const O = qi(C, T, k, p);
1230
- return void (O && g([ja(T, O.lineIndex, k, p)]));
1237
+ const k = st(P, t.current, g);
1238
+ if (!vt(k, g)) return;
1239
+ const O = Gi(M, T, k, g);
1240
+ return void (O && p([Ka(T, O.lineIndex, k, g)]));
1231
1241
  }
1232
1242
  if (T?.type === "curve") {
1233
- const k = st(P, t.current, p);
1234
- if (!vt(k, p)) return;
1235
- const O = ((R, B, E, K, de = 50) => {
1243
+ const k = st(P, t.current, g);
1244
+ if (!vt(k, g)) return;
1245
+ const O = ((R, B, I, j, de = 50) => {
1236
1246
  if (B.locked || B.points.length < 2) return !1;
1237
- if (B.points.length < 3) return qi(R, B, E, K, de);
1238
- const { center: se } = B.computed, j = Re(E, B.rotation ?? 0, se);
1239
- R.lineWidth = (B.style?.lineWidth ?? 0) + de / K.canvasZoom;
1247
+ if (B.points.length < 3) return Gi(R, B, I, j, de);
1248
+ const { center: se } = B.computed, K = Re(I, B.rotation ?? 0, se);
1249
+ R.lineWidth = (B.style?.lineWidth ?? 0) + de / j.canvasZoom;
1240
1250
  const N = yi(B, B.points), ge = new Path2D();
1241
1251
  ge.moveTo(...N[0]);
1242
1252
  for (let oe = 1; oe < N.length - 2; oe++) {
1243
- const ye = N[oe - 1], Se = N[oe], Qe = N[oe + 1], te = N[oe + 2], { cp1: fe, cp2: $ } = Si(ye, Se, Qe, te);
1244
- if (ge.bezierCurveTo(fe[0], fe[1], $[0], $[1], Qe[0], Qe[1]), R.isPointInStroke(ge, j[0], j[1])) return { lineIndex: oe - 1 };
1253
+ const ye = N[oe - 1], Se = N[oe], Qe = N[oe + 1], te = N[oe + 2], { cp1: ve, cp2: U } = Si(ye, Se, Qe, te);
1254
+ if (ge.bezierCurveTo(ve[0], ve[1], U[0], U[1], Qe[0], Qe[1]), R.isPointInStroke(ge, K[0], K[1])) return { lineIndex: oe - 1 };
1245
1255
  }
1246
1256
  return !1;
1247
- })(C, T, k, p);
1248
- return void (O && g([Ja(T, O.lineIndex, k, p)]));
1257
+ })(M, T, k, g);
1258
+ return void (O && p([eo(T, O.lineIndex, k, g)]));
1249
1259
  }
1250
1260
  }
1251
1261
  }), () => {
1252
1262
  H(y);
1253
1263
  }) : void 0;
1254
- }, [g, A, H, r, t, d, l, b, p]), { hoverMode: x };
1255
- }, Qa = (e) => e.childNodes.length ? Array.from(e.childNodes).map((t) => Qa(t)).join("") : e.nodeValue ?? "", xo = ({ disabled: e = !1, shape: t, defaultValue: i, updateValue: n, saveShapes: a, settings: o }) => {
1264
+ }, [p, A, H, r, t, d, l, b, g]), { hoverMode: x };
1265
+ }, ba = (e) => e.childNodes.length ? Array.from(e.childNodes).map((t) => ba(t)).join("") : e.nodeValue ?? "", Co = ({ disabled: e = !1, shape: t, defaultValue: i, updateValue: n, saveShapes: a, settings: o }) => {
1256
1266
  const d = ne(null), r = ne(a);
1257
1267
  ee(() => {
1258
1268
  if (!d.current) return;
1259
- const c = d.current, h = (u) => {
1269
+ const h = d.current, c = (u) => {
1260
1270
  u.preventDefault();
1261
- const v = u.clipboardData?.getData("text/plain");
1262
- document.execCommand("insertText", !1, v);
1271
+ const f = u.clipboardData?.getData("text/plain");
1272
+ document.execCommand("insertText", !1, f);
1263
1273
  };
1264
- c.addEventListener("paste", h), c.innerText = "";
1274
+ h.addEventListener("paste", c), h.innerText = "";
1265
1275
  for (const u of i) {
1266
- const v = document.createElement("div");
1267
- u === "" ? v.innerHTML = "<br/>" : v.innerText = u, c.appendChild(v);
1276
+ const f = document.createElement("div");
1277
+ u === "" ? f.innerHTML = "<br/>" : f.innerText = u, h.appendChild(f);
1268
1278
  }
1269
- return c.focus(), () => {
1270
- c.removeEventListener("paste", h);
1279
+ return h.focus(), () => {
1280
+ h.removeEventListener("paste", c);
1271
1281
  };
1272
1282
  }, [i]), ee(() => {
1273
- const c = r.current;
1283
+ const h = r.current;
1274
1284
  return () => {
1275
- c();
1285
+ h();
1276
1286
  };
1277
1287
  }, []);
1278
- const s = Pn(() => {
1279
- const { borders: c, center: h } = t.computed;
1280
- return le({ point: [c.x, c.y], rotation: -(t.rotation ?? 0), origin: h });
1288
+ const s = kn(() => {
1289
+ const { borders: h, center: c } = t.computed;
1290
+ return le({ point: [h.x, h.y], rotation: -(t.rotation ?? 0), origin: c });
1281
1291
  }, [t]), l = [`translate3D(${(s[0] + o.canvasOffset[0]) * o.canvasSize.scaleRatio}px, ${(s[1] + o.canvasOffset[1]) * o.canvasSize.scaleRatio}px, 0)`, `rotate(${si(t.rotation ?? 0)}deg)`, t.flipX || t.flipY ? `scale(${t.flipX ? -1 : 1}, ${t.flipY ? -1 : 1})` : void 0, t.flipX || t.flipY ? `translate3D(${t.flipX ? -100 : 0}%,${t.flipY ? -100 : 0}%,0)` : void 0].filter(Boolean).join(" ");
1282
- return m("div", { className: "react-paint-editor-toolbox-edittextbox", ref: d, "data-fontbold": t.style?.fontBold ?? !1, "data-fontitalic": t.style?.fontItalic ?? !1, contentEditable: !e, onInput: (c) => {
1283
- const h = Array.from(c.target.childNodes).map((u) => Qa(u));
1284
- n(h);
1292
+ return m("div", { className: "react-paint-editor-toolbox-edittextbox", ref: d, "data-fontbold": t.style?.fontBold ?? !1, "data-fontitalic": t.style?.fontItalic ?? !1, contentEditable: !e, onInput: (h) => {
1293
+ const c = Array.from(h.target.childNodes).map((u) => ba(u));
1294
+ n(c);
1285
1295
  }, style: { "--react-paint-editor-toolbox-edittextbox-transform": l, "--react-paint-editor-toolbox-edittextbox-fontsize": t.fontSize * o.canvasSize.scaleRatio + "px", "--react-paint-editor-toolbox-edittextbox-padding": o.selectionPadding * o.canvasSize.scaleRatio + "px", "--react-paint-editor-toolbox-edittextbox-color": t.style?.strokeColor ?? "inherit", "--react-paint-editor-toolbox-edittextbox-opacity": (t.style?.opacity ?? 100) / 100, "--react-paint-editor-toolbox-edittextbox-fontfamily": t.style?.fontFamily ?? mt } });
1286
- }, Co = (e, t, i, n, a) => {
1287
- ea(e), ((o, d) => {
1288
- const { canvasZoom: r, size: s, canvasSize: { width: l, height: c } } = d;
1296
+ }, Mo = (e, t, i, n, a) => {
1297
+ ta(e), ((o, d) => {
1298
+ const { canvasZoom: r, size: s, canvasSize: { width: l, height: h } } = d;
1289
1299
  if (s !== "fixed" || r >= 1) return;
1290
- o.fillStyle = "#f5f5f5", o.fillRect(0, 0, l, c);
1291
- const h = da(d);
1292
- o.clearRect(h.x, h.y, h.width, h.height), ca(o, d);
1300
+ o.fillStyle = "#f5f5f5", o.fillRect(0, 0, l, h);
1301
+ const c = ca(d);
1302
+ o.clearRect(c.x, c.y, c.width, c.height), ha(o, d);
1293
1303
  })(e, i), ((o, d) => {
1294
- const { canvasSize: { width: r, height: s }, gridGap: l, canvasOffset: c, canvasSize: { scaleRatio: h } } = d;
1304
+ const { canvasSize: { width: r, height: s }, gridGap: l, canvasOffset: h, canvasSize: { scaleRatio: c } } = d;
1295
1305
  if (!l) return;
1296
- o.strokeStyle = "rgb(220,220,220)", o.lineWidth = 1, o.save(), o.scale(h, h), o.beginPath();
1297
- const u = c[0] % l, v = c[1] % l, f = Math.ceil(r / h / l) + 2, g = Math.ceil(s / h / l) + 2;
1298
- for (let Q = -5; Q < f; Q++) o.moveTo(u + (Q + 1) * l, v - l), o.lineTo(u + (Q + 1) * l, v + s / h + l);
1299
- for (let Q = -5; Q < g; Q++) o.moveTo(u - l, v + (Q + 1) * l), o.lineTo(u + r / h + l, v + (Q + 1) * l);
1306
+ o.strokeStyle = "rgb(220,220,220)", o.lineWidth = 1, o.save(), o.scale(c, c), o.beginPath();
1307
+ const u = h[0] % l, f = h[1] % l, v = Math.ceil(r / c / l) + 2, p = Math.ceil(s / c / l) + 2;
1308
+ for (let S = -5; S < v; S++) o.moveTo(u + (S + 1) * l, f - l), o.lineTo(u + (S + 1) * l, f + s / c + l);
1309
+ for (let S = -5; S < p; S++) o.moveTo(u - l, f + (S + 1) * l), o.lineTo(u + r / c + l, f + (S + 1) * l);
1300
1310
  o.stroke(), o.restore();
1301
1311
  })(e, i);
1302
- for (let o = n.length - 1; o >= 0; o--) t.mode === "textedition" && n[o] === a || ga(e, _(a).find((d) => d.id === n[o].id) ?? n[o], i);
1303
- }, Mo = hi.forwardRef(({ canGrow: e, shapes: t, duplicateShapes: i, addShapes: n, updateSingleShape: a, selectedShape: o, setSelectedShape: d, setSelectionFrame: r, hoveredShape: s, selectionFrame: l, refreshHoveredShape: c, refreshSelectedShapes: h, saveShapes: u, activeTool: v, setActiveTool: f, canvasOffsetStartData: g, setCanvasOffsetStartData: Q, setCanvasOffset: M, setCanvasMoveAcceleration: b, isInsideComponent: S, selectionMode: p, setSelectionMode: w, selectionWidth: L, selectionColor: D, settings: V, isEditMode: x, isShiftPressed: Z, isAltPressed: A, isSpacePressed: H, withFrameSelection: F, withSkeleton: I }, W) => {
1304
- const q = ne(null), G = ne(null), z = V.canvasSize, y = x, C = x ? 0 : -1;
1305
- kn(W, () => q.current);
1306
- const { hoverMode: P } = wo({ addShapes: n, drawCanvasRef: q, setActiveTool: f, shapes: t, selectionMode: p, activeTool: v, isInsideComponent: S, setCanvasOffset: M, selectedShape: o, canvasOffsetStartData: g, setCanvasOffsetStartData: Q, setSelectedShape: d, setSelectionFrame: r, refreshHoveredShape: c, refreshSelectedShapes: h, updateSingleShape: a, duplicateShapes: i, saveShapes: u, setSelectionMode: w, setCanvasMoveAcceleration: b, isShiftPressed: Z, isAltPressed: A, withFrameSelection: F, settings: V, isSpacePressed: H }), T = Y((O) => {
1307
- const R = _(o)[0];
1312
+ for (let o = n.length - 1; o >= 0; o--) t.mode === "textedition" && n[o] === a || va(e, Y(a).find((d) => d.id === n[o].id) ?? n[o], i);
1313
+ }, Po = hi.forwardRef(({ canGrow: e, shapes: t, duplicateShapes: i, addShapes: n, updateSingleShape: a, selectedShape: o, setSelectedShape: d, setSelectionFrame: r, hoveredShape: s, selectionFrame: l, refreshHoveredShape: h, refreshSelectedShapes: c, saveShapes: u, activeTool: f, setActiveTool: v, canvasOffsetStartData: p, setCanvasOffsetStartData: S, setCanvasOffset: C, setCanvasMoveAcceleration: b, isInsideComponent: Q, selectionMode: g, setSelectionMode: w, selectionWidth: L, selectionColor: D, settings: V, isEditMode: x, isShiftPressed: Z, isAltPressed: A, isSpacePressed: H, withFrameSelection: F, withSkeleton: E }, W) => {
1314
+ const G = ne(null), _ = ne(null), z = V.canvasSize, y = x, M = x ? 0 : -1;
1315
+ Ln(W, () => G.current);
1316
+ const { hoverMode: P } = xo({ addShapes: n, drawCanvasRef: G, setActiveTool: v, shapes: t, selectionMode: g, activeTool: f, isInsideComponent: Q, setCanvasOffset: C, selectedShape: o, canvasOffsetStartData: p, setCanvasOffsetStartData: S, setSelectedShape: d, setSelectionFrame: r, refreshHoveredShape: h, refreshSelectedShapes: c, updateSingleShape: a, duplicateShapes: i, saveShapes: u, setSelectionMode: w, setCanvasMoveAcceleration: b, isShiftPressed: Z, isAltPressed: A, withFrameSelection: F, settings: V, isSpacePressed: H }), T = X((O) => {
1317
+ const R = Y(o)[0];
1308
1318
  if (R?.type !== "text") return;
1309
- const B = q.current?.getContext("2d");
1319
+ const B = G.current?.getContext("2d");
1310
1320
  if (!B) return;
1311
- const E = Ne(uo(B, R, O, V), V);
1312
- a([E]);
1321
+ const I = Ne(po(B, R, O, V), V);
1322
+ a([I]);
1313
1323
  }, [a, o, V]), k = (O) => {
1314
1324
  if (x) return O.preventDefault(), O.stopPropagation(), !1;
1315
1325
  };
1316
1326
  return ee(() => {
1317
- const O = q.current?.getContext("2d");
1318
- O && window.requestAnimationFrame(() => Co(O, p, V, t, o));
1319
- }, [t, p, o, V]), ee(() => {
1320
1327
  const O = G.current?.getContext("2d");
1321
- O && window.requestAnimationFrame(() => ((R, B, E, K, de, se, j, N, ge, oe, ye) => {
1322
- R.reset(), ca(R, E), ye && N && !_(j).find((Se) => Se.id === N.id) && K.type === "selection" && B.mode === "default" && an({ ctx: R, shape: N, settings: E, selectionWidth: de, selectionColor: se, hoverMode: ge, selectionMode: B, withAnchors: !1 }), j && K.type !== "brush" && an({ ctx: R, shape: j, settings: E, selectionWidth: de, selectionColor: se, hoverMode: ge, selectionMode: B, withAnchors: B.mode !== "textedition" }), oe && fo({ ctx: R, selectionFrame: oe, settings: E });
1323
- })(O, p, V, v, L, D, o, s, P, l, I));
1324
- }, [s, P, l, p, o, v, V, L, D, I]), m("div", { className: "react-paint-canvas-box", style: { "--react-paint-canvas-cursor": g ? "grabbing" : P.outOfView ? "default" : P.mode === "resize" ? "pointer" : v.type !== "selection" && v.type !== "move" ? "crosshair" : P.mode === "translate" ? "move" : P.mode === "rotate" || v.type === "move" || H ? "grab" : "default" }, children: U("div", { className: "react-paint-canvas-container", "data-grow": e, children: [m("canvas", { className: _n, ref: q, "data-grow": e, width: z.width, height: z.height, onContextMenu: k, tabIndex: C }), y && m("canvas", { className: jn, ref: G, width: z.width, height: z.height, "data-grow": e, onContextMenu: k }), x && p.mode === "textedition" && _(o)[0]?.type === "text" && m(xo, { disabled: !V.features.edition, shape: _(o)[0], defaultValue: p.defaultValue, updateValue: T, saveShapes: u, settings: V })] }) });
1325
- }), hn = "ArrowUp", un = "ArrowDown", pn = "ArrowLeft", gn = "ArrowRight", Po = "Delete", ko = "Backspace", Lo = "Escape", fn = "Shift", vn = "Alt", mn = "Option", Ht = " ", Vo = "z", Zo = "Z", Ho = "y", zo = "Y", To = "+", Ao = "-", Eo = "0", yn = "copy", Sn = "paste", Do = ({ isInsideComponent: e, isInsideCanvas: t, selectedShape: i, isEditingText: n, settings: a, setSelectedShape: o, setActiveTool: d, setCanvasZoom: r, resetZoom: s, setSelectionMode: l, setSelectionFrame: c, removeShape: h, pasteShapes: u, updateShapes: v, backwardShape: f, forwardShape: g, setShiftPressed: Q, setAltPressed: M, setIsSpacePressed: b }) => {
1326
- const [S, p] = X(void 0);
1328
+ O && window.requestAnimationFrame(() => Mo(O, g, V, t, o));
1329
+ }, [t, g, o, V]), ee(() => {
1330
+ const O = _.current?.getContext("2d");
1331
+ O && window.requestAnimationFrame(() => ((R, B, I, j, de, se, K, N, ge, oe, ye) => {
1332
+ R.reset(), ha(R, I), ye && N && !Y(K).find((Se) => Se.id === N.id) && j.type === "selection" && B.mode === "default" && on({ ctx: R, shape: N, settings: I, selectionWidth: de, selectionColor: se, hoverMode: ge, selectionMode: B, withAnchors: !1 }), K && j.type !== "brush" && on({ ctx: R, shape: K, settings: I, selectionWidth: de, selectionColor: se, hoverMode: ge, selectionMode: B, withAnchors: B.mode !== "textedition" }), oe && fo({ ctx: R, selectionFrame: oe, settings: I });
1333
+ })(O, g, V, f, L, D, o, s, P, l, E));
1334
+ }, [s, P, l, g, o, f, V, L, D, E]), m("div", { className: "react-paint-canvas-box", style: { "--react-paint-canvas-cursor": p ? "grabbing" : P.outOfView ? "default" : P.mode === "resize" ? "pointer" : f.type !== "selection" && f.type !== "move" ? "crosshair" : P.mode === "translate" ? "move" : P.mode === "rotate" || f.type === "move" || H ? "grab" : "default" }, children: q("div", { className: "react-paint-canvas-container", "data-grow": e, children: [m("canvas", { className: jn, ref: G, "data-grow": e, width: z.width, height: z.height, onContextMenu: k, tabIndex: M }), y && m("canvas", { className: Kn, ref: _, width: z.width, height: z.height, "data-grow": e, onContextMenu: k }), x && g.mode === "textedition" && Y(o)[0]?.type === "text" && m(Co, { disabled: !V.features.edition, shape: Y(o)[0], defaultValue: g.defaultValue, updateValue: T, saveShapes: u, settings: V })] }) });
1335
+ }), un = "ArrowUp", pn = "ArrowDown", gn = "ArrowLeft", vn = "ArrowRight", ko = "Delete", Lo = "Backspace", Vo = "Escape", fn = "Shift", mn = "Alt", yn = "Option", Ht = " ", Zo = "z", Ho = "Z", zo = "y", To = "Y", Ao = "+", Do = "-", Eo = "0", Sn = "copy", Qn = "paste", Io = ({ isInsideComponent: e, isInsideCanvas: t, selectedShape: i, isEditingText: n, settings: a, setSelectedShape: o, setActiveTool: d, setCanvasZoom: r, resetZoom: s, setSelectionMode: l, setSelectionFrame: h, removeShape: c, pasteShapes: u, updateShapes: f, backwardShape: v, forwardShape: p, setShiftPressed: S, setAltPressed: C, setIsSpacePressed: b }) => {
1336
+ const [Q, g] = $(void 0);
1327
1337
  return ee(() => {
1328
1338
  const w = (x) => {
1329
- i && (n || (x.preventDefault(), p({ ...i })));
1339
+ i && (n || (x.preventDefault(), g({ ...i })));
1330
1340
  }, L = (x) => {
1331
- S && (n || (x.preventDefault(), u(((Z, A) => _(Z).map((H) => ({ ...fa(H, 20, 20, A), id: ue(`${H.type}_`) })))(S, a))));
1341
+ Q && (n || (x.preventDefault(), u(((Z, A) => Y(Z).map((H) => ({ ...fa(H, 20, 20, A), id: ue(`${H.type}_`) })))(Q, a))));
1332
1342
  }, D = (x) => {
1333
1343
  switch (x.key) {
1334
1344
  case fn:
1335
- Q(!1);
1345
+ S(!1);
1336
1346
  break;
1337
- case vn:
1338
1347
  case mn:
1339
- M(!1);
1348
+ case yn:
1349
+ C(!1);
1340
1350
  break;
1341
1351
  case Ht:
1342
1352
  b(!1);
1343
1353
  }
1344
1354
  }, V = (x) => {
1345
1355
  if (x.metaKey || x.ctrlKey) {
1346
- if (x.key === Zo || x.key === Vo) return x.preventDefault(), x.stopPropagation(), void (x.shiftKey ? g() : f());
1347
- if (!Jn() && (x.key === zo || x.key === Ho)) return x.preventDefault(), x.stopPropagation(), void g();
1348
- if (x.key === To) return x.preventDefault(), x.stopPropagation(), void r("zoom");
1349
- if (x.key === Ao) return x.preventDefault(), x.stopPropagation(), void r("unzoom");
1356
+ if (x.key === Ho || x.key === Zo) return x.preventDefault(), x.stopPropagation(), void (x.shiftKey ? p() : v());
1357
+ if (!ea() && (x.key === To || x.key === zo)) return x.preventDefault(), x.stopPropagation(), void p();
1358
+ if (x.key === Ao) return x.preventDefault(), x.stopPropagation(), void r("zoom");
1359
+ if (x.key === Do) return x.preventDefault(), x.stopPropagation(), void r("unzoom");
1350
1360
  if (x.key === Eo) return x.preventDefault(), x.stopPropagation(), void s();
1351
1361
  }
1352
- if (x.key === fn) return x.preventDefault(), x.stopPropagation(), void Q(!0);
1362
+ if (x.key === fn) return x.preventDefault(), x.stopPropagation(), void S(!0);
1353
1363
  if (x.key === Ht && t) return x.preventDefault(), x.stopPropagation(), void b(!0);
1354
- if (x.key === vn || x.key === mn) return x.preventDefault(), x.stopPropagation(), void M(!0);
1364
+ if (x.key === mn || x.key === yn) return x.preventDefault(), x.stopPropagation(), void C(!0);
1355
1365
  if (!i) return;
1356
- if (x.key === Lo) return o(void 0), d(Oe), l({ mode: "default" }), void c(void 0);
1366
+ if (x.key === Vo) return o(void 0), d(Oe), l({ mode: "default" }), void h(void 0);
1357
1367
  if (n) return;
1358
- const Z = { [pn]: [a.gridGap ? -a.gridGap : -1, 0], [gn]: [a.gridGap ? a.gridGap : 1, 0], [un]: [0, a.gridGap ? a.gridGap : 1], [hn]: [0, a.gridGap ? -a.gridGap : -1] };
1368
+ const Z = { [gn]: [a.gridGap ? -a.gridGap : -1, 0], [vn]: [a.gridGap ? a.gridGap : 1, 0], [pn]: [0, a.gridGap ? a.gridGap : 1], [un]: [0, a.gridGap ? -a.gridGap : -1] };
1359
1369
  switch (x.key) {
1360
- case pn:
1361
1370
  case gn:
1371
+ case vn:
1372
+ case pn:
1362
1373
  case un:
1363
- case hn:
1364
- x.preventDefault(), x.stopPropagation(), v(va(Z[x.key], i, [0, 0], a, !0));
1374
+ x.preventDefault(), x.stopPropagation(), f(ma(Z[x.key], i, [0, 0], a, !0));
1365
1375
  break;
1366
- case Po:
1367
1376
  case ko:
1368
- x.preventDefault(), x.stopPropagation(), h(_(i));
1377
+ case Lo:
1378
+ x.preventDefault(), x.stopPropagation(), c(Y(i));
1369
1379
  }
1370
1380
  };
1371
- if (e) return document.addEventListener("keydown", V), document.addEventListener("keyup", D), document.addEventListener(yn, w), document.addEventListener(Sn, L), () => {
1372
- document.removeEventListener("keydown", V), document.removeEventListener("keyup", D), document.removeEventListener(yn, w), document.removeEventListener(Sn, L);
1381
+ if (e) return document.addEventListener("keydown", V), document.addEventListener("keyup", D), document.addEventListener(Sn, w), document.addEventListener(Qn, L), () => {
1382
+ document.removeEventListener("keydown", V), document.removeEventListener("keyup", D), document.removeEventListener(Sn, w), document.removeEventListener(Qn, L);
1373
1383
  };
1374
- }, [e, t, S, n, i, a, v, h, o, u, f, g, Q, M, d, l, c, r, s, b]), {};
1375
- }, us = ({ options: e, className: t, style: i, canvasProps: n }) => {
1376
- const { shapesRef: a, selectedShape: o, selectionFrame: d, hoveredShape: r, addShape: s, setSelectedShape: l, setSelectionFrame: c, refreshSelectedShapes: h, refreshHoveredShape: u, duplicateShapes: v, removeShape: f, updateShape: g, backwardShape: Q, forwardShape: M, saveShapes: b, refs: S, width: p, height: w, settings: L, setCanvasSize: D, setCanvasOffset: V, selectShapes: x, activeTool: Z, setActiveTool: A, isInsideComponent: H, isInsideCanvas: F, isEditMode: I, canvas: { withSkeleton: W, withFrameSelection: q, canGrow: G, canShrink: z }, canvasOffsetStartData: y, setCanvasOffsetStartData: C, selectionMode: P, setSelectionMode: T, setCanvasMoveAcceleration: k, isShiftPressed: O, isAltPressed: R, isSpacePressed: B, setShiftPressed: E, setAltPressed: K, setCanvasZoom: de, resetZoom: se, setIsSpacePressed: j } = n, { canvasBackgroundColor: N, canvasSelectionColor: ge, canvasSelectionWidth: oe } = { ...Ia, ...e }, ye = ne(null), Se = Y((te) => {
1384
+ }, [e, t, Q, n, i, a, f, c, o, u, v, p, S, C, d, l, h, r, s, b]), {};
1385
+ }, ps = ({ options: e, className: t, style: i, canvasProps: n }) => {
1386
+ const { shapesRef: a, selectedShape: o, selectionFrame: d, hoveredShape: r, addShape: s, setSelectedShape: l, setSelectionFrame: h, refreshSelectedShapes: c, refreshHoveredShape: u, duplicateShapes: f, removeShape: v, updateShape: p, backwardShape: S, forwardShape: C, saveShapes: b, refs: Q, width: g, height: w, settings: L, setCanvasSize: D, setCanvasOffset: V, selectShapes: x, activeTool: Z, setActiveTool: A, isInsideComponent: H, isInsideCanvas: F, isEditMode: E, canvas: { withSkeleton: W, withFrameSelection: G, canGrow: _, canShrink: z }, canvasOffsetStartData: y, setCanvasOffsetStartData: M, selectionMode: P, setSelectionMode: T, setCanvasMoveAcceleration: k, isShiftPressed: O, isAltPressed: R, isSpacePressed: B, setShiftPressed: I, setAltPressed: j, setCanvasZoom: de, resetZoom: se, setIsSpacePressed: K } = n, { canvasBackgroundColor: N, canvasSelectionColor: ge, canvasSelectionWidth: oe } = { ...Wa, ...e }, ye = ne(null), Se = X((te) => {
1377
1387
  s(te), x(te);
1378
- }, [s, x]), Qe = Y((te) => {
1379
- D({ realWidth: p, realHeight: w, width: te, height: w * te / p, scaleRatio: te / p });
1380
- }, [p, w, D]);
1381
- return Do({ isInsideComponent: H, isInsideCanvas: F, isEditingText: P.mode === "textedition", settings: L, selectedShape: o, setSelectedShape: l, removeShape: f, pasteShapes: Se, updateShapes: g, backwardShape: Q, forwardShape: M, setShiftPressed: E, setAltPressed: K, setActiveTool: A, setSelectionMode: T, setSelectionFrame: c, setCanvasZoom: de, resetZoom: se, setIsSpacePressed: j }), (({ onResized: te, element: fe }) => {
1388
+ }, [s, x]), Qe = X((te) => {
1389
+ D({ realWidth: g, realHeight: w, width: te, height: w * te / g, scaleRatio: te / g });
1390
+ }, [g, w, D]);
1391
+ return Io({ isInsideComponent: H, isInsideCanvas: F, isEditingText: P.mode === "textedition", settings: L, selectedShape: o, setSelectedShape: l, removeShape: v, pasteShapes: Se, updateShapes: p, backwardShape: S, forwardShape: C, setShiftPressed: I, setAltPressed: j, setActiveTool: A, setSelectionMode: T, setSelectionFrame: h, setCanvasZoom: de, resetZoom: se, setIsSpacePressed: K }), (({ onResized: te, element: ve }) => {
1382
1392
  ee(() => {
1383
- const $ = fe.current;
1384
- if (!$) return;
1393
+ const U = ve.current;
1394
+ if (!U) return;
1385
1395
  const ae = new ResizeObserver((Me) => {
1386
1396
  const Ze = Me?.[0]?.borderBoxSize?.[0], { width: re, height: Te } = Ze ? { width: Ze.inlineSize, height: Ze.blockSize } : Me?.[0]?.contentRect ?? {};
1387
1397
  re !== void 0 && Te !== void 0 && te(re, Te);
1388
1398
  });
1389
- return ae.observe($), () => {
1390
- ae.unobserve($);
1399
+ return ae.observe(U), () => {
1400
+ ae.unobserve(U);
1391
1401
  };
1392
- }, [fe, te]);
1393
- })({ element: ye, onResized: Qe }), m("div", { ref: ye, className: "react-paint-app-row" + (t ? ` ${t}` : ""), "data-grow": G, "data-shrink": z, style: { "--react-paint-app-row-width": L.canvasSize.width, "--react-paint-app-canvaswidth": p, "--react-paint-app-canvasheight": w, "--react-paint-app-row-aspectratio": `calc(${L.canvasSize.width} / ${L.canvasSize.height})`, "--react-paint-app-canvas-bg": N, ...i }, children: m(Mo, { duplicateShapes: v, isSpacePressed: B, ref: S.canvas, canGrow: G, isInsideComponent: H, activeTool: Z, setActiveTool: A, canvasOffsetStartData: y, setCanvasOffsetStartData: C, shapes: a.current, addShapes: s, updateSingleShape: g, selectedShape: o, selectionFrame: d, setSelectedShape: l, setSelectionFrame: c, hoveredShape: r, refreshHoveredShape: u, refreshSelectedShapes: h, settings: L, setCanvasOffset: V, saveShapes: b, selectionMode: P, setSelectionMode: T, setCanvasMoveAcceleration: k, selectionColor: ge, selectionWidth: oe, isEditMode: I, isShiftPressed: O, isAltPressed: R, withFrameSelection: q, withSkeleton: W }) });
1394
- }, Io = ({ isLoading: e = !1 }) => {
1395
- const [t, i] = X("hidden");
1402
+ }, [ve, te]);
1403
+ })({ element: ye, onResized: Qe }), m("div", { ref: ye, className: "react-paint-app-row" + (t ? ` ${t}` : ""), "data-grow": _, "data-shrink": z, style: { "--react-paint-app-row-width": L.canvasSize.width, "--react-paint-app-canvaswidth": g, "--react-paint-app-canvasheight": w, "--react-paint-app-row-aspectratio": `calc(${L.canvasSize.width} / ${L.canvasSize.height})`, "--react-paint-app-canvas-bg": N, ...i }, children: m(Po, { duplicateShapes: f, isSpacePressed: B, ref: Q.canvas, canGrow: _, isInsideComponent: H, activeTool: Z, setActiveTool: A, canvasOffsetStartData: y, setCanvasOffsetStartData: M, shapes: a.current, addShapes: s, updateSingleShape: p, selectedShape: o, selectionFrame: d, setSelectedShape: l, setSelectionFrame: h, hoveredShape: r, refreshHoveredShape: u, refreshSelectedShapes: c, settings: L, setCanvasOffset: V, saveShapes: b, selectionMode: P, setSelectionMode: T, setCanvasMoveAcceleration: k, selectionColor: ge, selectionWidth: oe, isEditMode: E, isShiftPressed: O, isAltPressed: R, withFrameSelection: G, withSkeleton: W }) });
1404
+ }, Wo = ({ isLoading: e = !1 }) => {
1405
+ const [t, i] = $("hidden");
1396
1406
  return ee(() => {
1397
1407
  if (!e) {
1398
1408
  i("fadeOut");
@@ -1402,9 +1412,9 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
1402
1412
  };
1403
1413
  }
1404
1414
  i("visible");
1405
- }, [e]), t === "hidden" ? null : m("div", { className: "react-paint-editor-loading", "data-loading": t, style: { "--react-paint-editor-loading-zindex": Ta, "--react-paint-editor-loading-transition-duration": "300ms" }, children: U("div", { className: "react-paint-editor-loader", children: [m("div", {}), m("div", {}), m("div", {}), m("div", {})] }) });
1406
- }, Wo = "infos", Ro = 4e3, No = ({ type: e, text: t, duration: i }) => {
1407
- const [n, a] = X(!1);
1415
+ }, [e]), t === "hidden" ? null : m("div", { className: "react-paint-editor-loading", "data-loading": t, style: { "--react-paint-editor-loading-zindex": Aa, "--react-paint-editor-loading-transition-duration": "300ms" }, children: q("div", { className: "react-paint-editor-loader", children: [m("div", {}), m("div", {}), m("div", {}), m("div", {})] }) });
1416
+ }, Ro = "infos", No = 4e3, Bo = ({ type: e, text: t, duration: i }) => {
1417
+ const [n, a] = $(!1);
1408
1418
  return ee(() => {
1409
1419
  const o = setTimeout(() => {
1410
1420
  a(!0);
@@ -1415,27 +1425,27 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
1415
1425
  clearTimeout(o), clearTimeout(d);
1416
1426
  };
1417
1427
  }, [i]), m("div", { className: "react-paint-editor-snackbar", "data-is-shown": +n, "data-type": e, style: { "--react-paint-editor-panel-transition-duration": "500ms" }, children: t });
1418
- }, Bo = ({ snackbarList: e }) => m("div", { className: "react-paint-editor-snackbar-container", style: { "--react-paint-editor-snackbar-zindex": Aa }, children: e.map((t) => m(No, { ...t }, t.id)) }), Oo = hi.forwardRef((e, t) => {
1419
- const { hidden: i = !1, disabled: n = !1, selected: a = !1, icon: o, children: d, className: r = "", title: s, onClick: l, ...c } = e, h = n ? -1 : 0, u = ne(null);
1420
- return kn(t, () => u.current), U("label", { className: `react-paint-editor-button ${r}`, title: s, onClick: l, "data-disabled": +n, "data-selected": +a, "data-hidden": +i, tabIndex: h, onKeyDown: (v) => {
1421
- v.key === Ht && (v.preventDefault(), v.stopPropagation());
1422
- }, onKeyUp: (v) => {
1423
- v.preventDefault(), v.stopPropagation(), v.key === Ht && u.current?.click();
1424
- }, children: [m("input", { ref: u, disabled: n, ...c }), U("span", { className: "react-paint-editor-button-content", children: [d && m("span", { className: "react-paint-editor-button-children", children: d }), o && m("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: o } })] })] });
1428
+ }, Oo = ({ snackbarList: e }) => m("div", { className: "react-paint-editor-snackbar-container", style: { "--react-paint-editor-snackbar-zindex": Da }, children: e.map((t) => m(Bo, { ...t }, t.id)) }), Fo = hi.forwardRef((e, t) => {
1429
+ const { hidden: i = !1, disabled: n = !1, selected: a = !1, icon: o, children: d, className: r = "", title: s, onClick: l, ...h } = e, c = n ? -1 : 0, u = ne(null);
1430
+ return Ln(t, () => u.current), q("label", { className: `react-paint-editor-button ${r}`, title: s, onClick: l, "data-disabled": +n, "data-selected": +a, "data-hidden": +i, tabIndex: c, onKeyDown: (f) => {
1431
+ f.key === Ht && (f.preventDefault(), f.stopPropagation());
1432
+ }, onKeyUp: (f) => {
1433
+ f.preventDefault(), f.stopPropagation(), f.key === Ht && u.current?.click();
1434
+ }, children: [m("input", { ref: u, disabled: n, ...h }), q("span", { className: "react-paint-editor-button-content", children: [d && m("span", { className: "react-paint-editor-button-children", children: d }), o && m("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: o } })] })] });
1425
1435
  }), J = hi.forwardRef((e, t) => {
1426
- if (e.type === "file" || e.type === "color") return m(Oo, { ...e, ref: t });
1436
+ if (e.type === "file" || e.type === "color") return m(Fo, { ...e, ref: t });
1427
1437
  const { hidden: i = !1, disabled: n = !1, selected: a = !1, icon: o, children: d, type: r = "button", className: s = "", ...l } = e;
1428
- return m("button", { className: `react-paint-editor-button ${s}`, ref: t, disabled: n, "data-disabled": +n, "data-selected": +a, "data-hidden": +i, type: r, ...l, children: U("span", { className: "react-paint-editor-button-content", children: [d && m("span", { className: "react-paint-editor-button-children", children: d }), o && m("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: o } })] }) });
1429
- }), nt = ({ children: e, title: t = "", className: i = "", position: n = "bottom", fitContainer: a = !1, alignment: o = "center", style: d, ...r }) => U("div", { className: `react-paint-editor-panel ${i}`, "data-fitcontainer": a, "data-position": n, "data-alignment": o, style: { ...d, "--react-paint-editor-panel-zindex": En }, ...r, children: [t && m("h3", { className: "react-paint-editor-panel-title", children: t }), e] }), Fo = (e) => {
1438
+ return m("button", { className: `react-paint-editor-button ${s}`, ref: t, disabled: n, "data-disabled": +n, "data-selected": +a, "data-hidden": +i, type: r, ...l, children: q("span", { className: "react-paint-editor-button-content", children: [d && m("span", { className: "react-paint-editor-button-children", children: d }), o && m("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: o } })] }) });
1439
+ }), nt = ({ children: e, title: t = "", className: i = "", position: n = "bottom", fitContainer: a = !1, alignment: o = "center", style: d, ...r }) => q("div", { className: `react-paint-editor-panel ${i}`, "data-fitcontainer": a, "data-position": n, "data-alignment": o, style: { ...d, "--react-paint-editor-panel-zindex": En }, ...r, children: [t && m("h3", { className: "react-paint-editor-panel-title", children: t }), e] }), Yo = (e) => {
1430
1440
  switch (e) {
1431
1441
  case "brush":
1432
- return Vn;
1442
+ return Zn;
1433
1443
  case "line":
1434
- return zn;
1444
+ return Tn;
1435
1445
  case "polygon":
1436
1446
  return gi;
1437
1447
  case "curve":
1438
- return Tn;
1448
+ return An;
1439
1449
  case "rect":
1440
1450
  case "square":
1441
1451
  return ui;
@@ -1443,125 +1453,125 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
1443
1453
  case "ellipse":
1444
1454
  return pi;
1445
1455
  case "text":
1446
- return Hn;
1456
+ return zn;
1447
1457
  case "picture":
1448
- return fi;
1458
+ return vi;
1449
1459
  case "group":
1450
1460
  return '<svg><path d="M3.333 17.5V16.667H7.5V17.5ZM3.333 14.167V13.333H9.167V14.167ZM3.333 10.833V10H10.833V10.833ZM3.333 7.5V6.667H12.5V7.5ZM3.333 4.167V3.333H13.333V4.167ZM3.333 0.833V0H16.667V0.833Z"/></svg>';
1451
1461
  case "triangle":
1452
1462
  return "";
1453
1463
  }
1454
- }, Yo = ({ disabled: e = !1, shape: t, selected: i, layoutDragging: n, toggleShapeVisibility: a, toggleShapeLock: o, setLayoutDragging: d, handleRemove: r, handleSelect: s, onMoveShapes: l }) => {
1455
- const c = ne(null), { isOver: h } = (({ disabled: u = !1, ref: v, shape: f, layoutDragging: g, setLayoutDragging: Q, handleSelect: M, onMoveShapes: b }) => {
1456
- const [S, p] = X(!1);
1464
+ }, Xo = ({ disabled: e = !1, shape: t, selected: i, layoutDragging: n, toggleShapeVisibility: a, toggleShapeLock: o, setLayoutDragging: d, handleRemove: r, handleSelect: s, onMoveShapes: l }) => {
1465
+ const h = ne(null), { isOver: c } = (({ disabled: u = !1, ref: f, shape: v, layoutDragging: p, setLayoutDragging: S, handleSelect: C, onMoveShapes: b }) => {
1466
+ const [Q, g] = $(!1);
1457
1467
  return ee(() => {
1458
- g || p(!1);
1459
- }, [g]), ee(() => {
1460
- const w = v.current;
1468
+ p || g(!1);
1469
+ }, [p]), ee(() => {
1470
+ const w = f.current;
1461
1471
  if (!w) return;
1462
1472
  const L = () => {
1463
- Q(void 0);
1473
+ S(void 0);
1464
1474
  }, D = (H) => (H.preventDefault && H.preventDefault(), !1), V = (H) => {
1465
- M([f]), H.dataTransfer && (H.dataTransfer.effectAllowed = "move", H.dataTransfer.setData("draggableShapeId", f.id), Q(f.id));
1475
+ C([v]), H.dataTransfer && (H.dataTransfer.effectAllowed = "move", H.dataTransfer.setData("draggableShapeId", v.id), S(v.id));
1466
1476
  }, x = () => {
1467
- g !== f.id && p(!0);
1477
+ p !== v.id && g(!0);
1468
1478
  }, Z = () => {
1469
- p(!1);
1470
- }, A = (H) => (H.stopPropagation(), H.dataTransfer && b(H.dataTransfer.getData("draggableShapeId"), f.id), !1);
1479
+ g(!1);
1480
+ }, A = (H) => (H.stopPropagation(), H.dataTransfer && b(H.dataTransfer.getData("draggableShapeId"), v.id), !1);
1471
1481
  return u || (w.addEventListener("dragstart", V), w.addEventListener("dragend", L), w.addEventListener("dragover", D), w.addEventListener("dragenter", x), w.addEventListener("dragleave", Z), w.addEventListener("drop", A)), () => {
1472
1482
  u || (w.removeEventListener("dragstart", V), w.removeEventListener("dragend", L), w.removeEventListener("dragover", D), w.removeEventListener("dragenter", x), w.removeEventListener("dragleave", Z), w.removeEventListener("drop", A));
1473
1483
  };
1474
- }, [u, v, f, Q, M, b, g]), { isOver: S };
1475
- })({ disabled: e, ref: c, shape: t, layoutDragging: n, setLayoutDragging: d, handleSelect: s, onMoveShapes: l });
1476
- return U("div", { className: "react-paint-editor-layout", "data-disabled": +e, draggable: !e, "data-is-dragging": +(n === t.id), "data-is-over": +h, onClick: (u) => {
1484
+ }, [u, f, v, S, C, b, p]), { isOver: Q };
1485
+ })({ disabled: e, ref: h, shape: t, layoutDragging: n, setLayoutDragging: d, handleSelect: s, onMoveShapes: l });
1486
+ return q("div", { className: "react-paint-editor-layout", "data-disabled": +e, draggable: !e, "data-is-dragging": +(n === t.id), "data-is-over": +c, onClick: (u) => {
1477
1487
  e || (u.preventDefault(), u.stopPropagation(), s([t]));
1478
- }, "data-selected": +i, ref: c, tabIndex: -1, children: [m("span", { dangerouslySetInnerHTML: { __html: Fo(t.type) } }), m("span", { children: t.id }), m("div", { className: "react-paint-editor-layouts-separator" }), m(J, { className: "react-paint-editor-layouts-visible-button", title: t.visible ? "Hide" : "Show", "data-visible": t.visible !== !1, disabled: e, selected: i, onClick: (u) => {
1488
+ }, "data-selected": +i, ref: h, tabIndex: -1, children: [m("span", { dangerouslySetInnerHTML: { __html: Yo(t.type) } }), m("span", { children: t.id }), m("div", { className: "react-paint-editor-layouts-separator" }), m(J, { className: "react-paint-editor-layouts-visible-button", title: t.visible ? "Hide" : "Show", "data-visible": t.visible !== !1, disabled: e, selected: i, onClick: (u) => {
1479
1489
  e || (u.preventDefault(), u.stopPropagation(), a([t]));
1480
1490
  }, icon: t.visible === !1 ? '<svg><path d="M13.521 11.021 12.25 9.75Q12.333 8.75 11.604 7.979Q10.875 7.208 9.812 7.312L8.542 6.042Q8.896 5.896 9.26 5.833Q9.625 5.771 10 5.771Q11.583 5.771 12.688 6.875Q13.792 7.979 13.792 9.562Q13.792 9.979 13.719 10.354Q13.646 10.729 13.521 11.021ZM16.167 13.646 14.917 12.417Q15.667 11.833 16.25 11.146Q16.833 10.458 17.25 9.562Q16.229 7.479 14.292 6.281Q12.354 5.083 10 5.083Q9.396 5.083 8.885 5.156Q8.375 5.229 7.875 5.375L6.5 4Q7.354 3.646 8.208 3.49Q9.062 3.333 10 3.333Q13.146 3.333 15.615 5.052Q18.083 6.771 19.167 9.562Q18.688 10.792 17.917 11.823Q17.146 12.854 16.167 13.646ZM16.396 18.854 12.938 15.396Q12.208 15.625 11.479 15.729Q10.75 15.833 10 15.833Q6.833 15.833 4.375 14.094Q1.917 12.354 0.833 9.562Q1.25 8.479 1.917 7.552Q2.583 6.625 3.417 5.875L1.125 3.562L2.375 2.354L17.625 17.625ZM4.604 7.062Q4.021 7.604 3.542 8.219Q3.062 8.833 2.729 9.562Q3.75 11.646 5.688 12.865Q7.625 14.083 10 14.083Q10.354 14.083 10.74 14.052Q11.125 14.021 11.479 13.938L10.812 13.271Q10.625 13.312 10.417 13.333Q10.208 13.354 10 13.354Q8.417 13.354 7.312 12.25Q6.208 11.146 6.208 9.562Q6.208 9.354 6.24 9.167Q6.271 8.979 6.312 8.771ZM11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875ZM8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Z"/></svg>' : '<svg><path d="M10 13.354Q11.583 13.354 12.688 12.25Q13.792 11.146 13.792 9.562Q13.792 7.979 12.688 6.875Q11.583 5.771 10 5.771Q8.417 5.771 7.312 6.875Q6.208 7.979 6.208 9.562Q6.208 11.146 7.312 12.25Q8.417 13.354 10 13.354ZM10 11.812Q9.062 11.812 8.406 11.156Q7.75 10.5 7.75 9.562Q7.75 8.625 8.406 7.969Q9.062 7.312 10 7.312Q10.938 7.312 11.594 7.969Q12.25 8.625 12.25 9.562Q12.25 10.5 11.594 11.156Q10.938 11.812 10 11.812ZM10 15.833Q6.938 15.833 4.448 14.125Q1.958 12.417 0.833 9.562Q1.958 6.708 4.458 5.021Q6.958 3.333 10 3.333Q13.042 3.333 15.542 5.021Q18.042 6.708 19.167 9.562Q18.042 12.417 15.552 14.125Q13.062 15.833 10 15.833ZM10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562ZM10 14.083Q12.333 14.083 14.281 12.865Q16.229 11.646 17.25 9.562Q16.229 7.479 14.281 6.281Q12.333 5.083 10 5.083Q7.667 5.083 5.708 6.281Q3.75 7.479 2.729 9.562Q3.75 11.646 5.708 12.865Q7.667 14.083 10 14.083Z"/></svg>' }), m(J, { className: "react-paint-editor-layouts-locked-button", title: t.locked ? "Locked" : "Unlocked", "data-locked": !!t.locked, disabled: e, selected: i, onClick: (u) => {
1481
1491
  e || (u.preventDefault(), u.stopPropagation(), o([t]));
1482
1492
  }, icon: t.locked ? '<svg><path d="M10 0.833Q11.771 0.833 12.99 2.052Q14.208 3.271 14.208 5.042V6.667H14.917Q15.646 6.667 16.156 7.177Q16.667 7.688 16.667 8.417V16.562Q16.667 17.292 16.156 17.812Q15.646 18.333 14.917 18.333H5.083Q4.354 18.333 3.844 17.812Q3.333 17.292 3.333 16.562V8.417Q3.333 7.688 3.844 7.177Q4.354 6.667 5.083 6.667H5.792V5.042Q5.792 3.271 7.01 2.052Q8.229 0.833 10 0.833ZM10 2.583Q8.979 2.583 8.26 3.302Q7.542 4.021 7.542 5.042V6.667H12.458V5.042Q12.458 4.021 11.74 3.302Q11.021 2.583 10 2.583ZM5.083 16.583H14.917Q14.917 16.583 14.917 16.583Q14.917 16.583 14.917 16.583V8.417Q14.917 8.417 14.917 8.417Q14.917 8.417 14.917 8.417H5.083Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583ZM10 10.812Q9.292 10.812 8.802 11.302Q8.312 11.792 8.312 12.5Q8.312 13.208 8.802 13.698Q9.292 14.188 10 14.188Q10.708 14.188 11.198 13.698Q11.688 13.208 11.688 12.5Q11.688 11.792 11.198 11.302Q10.708 10.812 10 10.812ZM5.083 8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583V8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417Z"/></svg>' : '<svg><path d="M5.792 5.042Q5.792 3.271 7.01 2.052Q8.229 0.833 10 0.833Q11.771 0.833 12.99 2.052Q14.208 3.271 14.208 5.042V6.667H14.917Q15.646 6.667 16.156 7.177Q16.667 7.688 16.667 8.417V16.562Q16.667 17.292 16.156 17.812Q15.646 18.333 14.917 18.333H5.083Q4.354 18.333 3.844 17.812Q3.333 17.292 3.333 16.562V8.417Q3.333 7.688 3.844 7.177Q4.354 6.667 5.083 6.667H12.458V5.042Q12.458 4.021 11.74 3.302Q11.021 2.583 10 2.583Q8.979 2.583 8.26 3.302Q7.542 4.021 7.542 5.042ZM5.083 16.583H14.917Q14.917 16.583 14.917 16.583Q14.917 16.583 14.917 16.583V8.417Q14.917 8.417 14.917 8.417Q14.917 8.417 14.917 8.417H5.083Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583ZM10 10.812Q9.292 10.812 8.802 11.302Q8.312 11.792 8.312 12.5Q8.312 13.208 8.802 13.698Q9.292 14.188 10 14.188Q10.708 14.188 11.198 13.698Q11.688 13.208 11.688 12.5Q11.688 11.792 11.198 11.302Q10.708 10.812 10 10.812ZM5.083 8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583V8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417Z"/></svg>' }), m(J, { className: "react-paint-editor-layouts-remove-button", title: "Remove", disabled: e, onClick: (u) => {
1483
1493
  e || (u.preventDefault(), u.stopPropagation(), r([t]));
1484
- }, icon: Zn })] });
1485
- }, Xo = ({ gridFormat: e, setGridFormat: t, settings: i, shapes: n, removeShape: a, toggleShapeVisibility: o, toggleShapeLock: d, selectedShapes: r, moveShapes: s, selectShapes: l, isLayoutPanelShown: c }) => {
1486
- const [h, u] = X(void 0), v = !i.features.edition;
1487
- return c ? m(nt, { alignment: "right", className: "react-paint-editor-layouts-panel", children: m("div", { className: "react-paint-editor-layouts-panel-content", children: U("div", { className: "react-paint-editor-layouts-scrolling-content", children: [U("div", { className: "react-paint-editor-layouts-row", children: [m("span", { className: "react-paint-editor-layouts-subtitle", children: "Grid" }), m(J, { icon: '<svg><path d="M18.333 15.854 16.583 14.104V13.354H15.833L14.083 11.604H16.583V8.375H13.375V10.896L11.625 9.146V8.375H10.875L9.125 6.625H11.625V3.417H8.396V5.896L6.646 4.146V3.417H5.896L4.146 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417ZM13.375 6.625H16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H13.375ZM16.771 19.229 15.854 18.333H3.417Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V4.125L0.812 3.271L2.042 2.021L18 18ZM13.375 16.583H14.104L13.375 15.833ZM8.396 11.604H9.125L8.396 10.854ZM8.396 16.583H11.625V14.083L10.875 13.354H8.396ZM3.417 6.625H4.167L3.417 5.875ZM3.417 11.604H6.646V9.104L5.917 8.375H3.417ZM6.646 16.583V13.354H3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Z"/></svg>', className: "react-paint-editor-layouts-grid-button", selected: e === "none", disabled: v, onClick: () => t("none") }), ["small", "medium", "large"].map((f) => m(J, { className: "react-paint-editor-layouts-grid-button", selected: e === f, disabled: v, onClick: () => t(f), children: f.charAt(0).toUpperCase() }, f))] }), m("hr", {}), m("div", { className: "react-paint-editor-layouts", children: n.length === 0 ? m("div", { className: "react-paint-editor-layouts-placeholder", children: "No layer yet" }) : n.map((f) => m(Yo, { shape: f, disabled: v, layoutDragging: h, setLayoutDragging: u, selected: _(r).some((g) => g.id === f.id) ?? !1, handleSelect: l, handleRemove: a, onMoveShapes: s, toggleShapeVisibility: o, toggleShapeLock: d }, f.id)) })] }) }) }) : null;
1488
- }, Nt = ({ children: e, onClose: t, position: i = "center", title: n, className: a = "" }) => U("div", { className: "react-paint-editor-modal", "data-position": i, style: { "--react-paint-editor-modal-zindex": En }, role: "dialog", "aria-modal": "true", "aria-labelledby": n, children: [m("div", { className: "react-paint-editor-modal-mask", onClick: t }), m("div", { className: `react-paint-editor-modal-panel ${a}`, children: e })] }), Mt = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez une couleur", mode: n = "fill", disabled: a = !1, values: o, field: d, value: r = "", valueChanged: s }) => {
1489
- const [l] = X(ue("settings_")), c = e === l;
1490
- return o.length ? U(Ae, { children: [m(J, { selected: c, title: i, disabled: a, onClick: () => {
1491
- t((h) => h === l ? void 0 : l);
1492
- }, icon: r === "transparent" ? n === "fill" ? Di : Ei : void 0, children: r !== "transparent" && m("div", { className: "react-paint-editor-colorfield-color", "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": r } }) }), c && m(nt, { title: i, alignment: "left", children: U("div", { className: "react-paint-editor-colorfield-wrapper", children: [o.map((h) => m(J, { title: h, selected: h === r, color: h, icon: h === "transparent" ? n === "fill" ? Di : Ei : void 0, onClick: () => {
1493
- s(d, h);
1494
- }, children: h !== "transparent" && m("div", { className: "react-paint-editor-colorfield-color", color: h, "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": h } }) }, h)), m(J, { type: "color", title: "Custom color", selected: r !== "" && !o.includes(r), value: r, onChange: (h) => {
1495
- const u = +h.target.value;
1496
- s(d, Number.isNaN(u) ? h.target.value : u);
1494
+ }, icon: Hn })] });
1495
+ }, $o = ({ gridFormat: e, setGridFormat: t, settings: i, shapes: n, removeShape: a, toggleShapeVisibility: o, toggleShapeLock: d, selectedShapes: r, moveShapes: s, selectShapes: l, isLayoutPanelShown: h }) => {
1496
+ const [c, u] = $(void 0), f = !i.features.edition;
1497
+ return h ? m(nt, { alignment: "right", className: "react-paint-editor-layouts-panel", children: m("div", { className: "react-paint-editor-layouts-panel-content", children: q("div", { className: "react-paint-editor-layouts-scrolling-content", children: [q("div", { className: "react-paint-editor-layouts-row", children: [m("span", { className: "react-paint-editor-layouts-subtitle", children: "Grid" }), m(J, { icon: '<svg><path d="M18.333 15.854 16.583 14.104V13.354H15.833L14.083 11.604H16.583V8.375H13.375V10.896L11.625 9.146V8.375H10.875L9.125 6.625H11.625V3.417H8.396V5.896L6.646 4.146V3.417H5.896L4.146 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417ZM13.375 6.625H16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H13.375ZM16.771 19.229 15.854 18.333H3.417Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V4.125L0.812 3.271L2.042 2.021L18 18ZM13.375 16.583H14.104L13.375 15.833ZM8.396 11.604H9.125L8.396 10.854ZM8.396 16.583H11.625V14.083L10.875 13.354H8.396ZM3.417 6.625H4.167L3.417 5.875ZM3.417 11.604H6.646V9.104L5.917 8.375H3.417ZM6.646 16.583V13.354H3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Z"/></svg>', className: "react-paint-editor-layouts-grid-button", selected: e === "none", disabled: f, onClick: () => t("none") }), ["small", "medium", "large"].map((v) => m(J, { className: "react-paint-editor-layouts-grid-button", selected: e === v, disabled: f, onClick: () => t(v), children: v.charAt(0).toUpperCase() }, v))] }), m("hr", {}), m("div", { className: "react-paint-editor-layouts", children: n.length === 0 ? m("div", { className: "react-paint-editor-layouts-placeholder", children: "No layer yet" }) : n.map((v) => m(Xo, { shape: v, disabled: f, layoutDragging: c, setLayoutDragging: u, selected: Y(r).some((p) => p.id === v.id) ?? !1, handleSelect: l, handleRemove: a, onMoveShapes: s, toggleShapeVisibility: o, toggleShapeLock: d }, v.id)) })] }) }) }) : null;
1498
+ }, Nt = ({ children: e, onClose: t, position: i = "center", title: n, className: a = "" }) => q("div", { className: "react-paint-editor-modal", "data-position": i, style: { "--react-paint-editor-modal-zindex": En }, role: "dialog", "aria-modal": "true", "aria-labelledby": n, children: [m("div", { className: "react-paint-editor-modal-mask", onClick: t }), m("div", { className: `react-paint-editor-modal-panel ${a}`, children: e })] }), Mt = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez une couleur", mode: n = "fill", disabled: a = !1, values: o, field: d, value: r = "", valueChanged: s }) => {
1499
+ const [l] = $(ue("settings_")), h = e === l;
1500
+ return o.length ? q(Ae, { children: [m(J, { selected: h, title: i, disabled: a, onClick: () => {
1501
+ t((c) => c === l ? void 0 : l);
1502
+ }, icon: r === "transparent" ? n === "fill" ? Ii : Ei : void 0, children: r !== "transparent" && m("div", { className: "react-paint-editor-colorfield-color", "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": r } }) }), h && m(nt, { title: i, alignment: "left", children: q("div", { className: "react-paint-editor-colorfield-wrapper", children: [o.map((c) => m(J, { title: c, selected: c === r, color: c, icon: c === "transparent" ? n === "fill" ? Ii : Ei : void 0, onClick: () => {
1503
+ s(d, c);
1504
+ }, children: c !== "transparent" && m("div", { className: "react-paint-editor-colorfield-color", color: c, "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": c } }) }, c)), m(J, { type: "color", title: "Custom color", selected: r !== "" && !o.includes(r), value: r, onChange: (c) => {
1505
+ const u = +c.target.value;
1506
+ s(d, Number.isNaN(u) ? c.target.value : u);
1497
1507
  }, children: m("div", { className: "react-paint-editor-colorfield-customcolor", style: { "--react-paint-editor-colorfield-color-value": o.includes(r) ? "var(--react-paint-editor-app-font-color)" : r }, children: m("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;
1498
- }, $o = ({ disabled: e = !1, selectedShape: t, removeShape: i }) => m(J, { title: "Delete", disabled: e, "data-disabled": +e, onClick: () => {
1499
- i(_(t));
1500
- }, icon: Zn }), Bt = ({ CustomOption: e, selectedSettings: t, setSelectedSettings: i, title: n = "Choisissez l'option", disabled: a = !1, field: o, icon: d, values: r, defaultValue: s, valueChanged: l }) => {
1501
- const [c] = X(ue("settings_")), h = t === c;
1502
- return r.length ? U(Ae, { children: [m(J, { selected: h, title: n, icon: d, disabled: a, onClick: () => {
1503
- i((u) => u === c ? void 0 : c);
1504
- } }), h && m(nt, { title: n, alignment: "left", fitContainer: !0, children: m("div", { className: "react-paint-editor-selectfield-wrapper", children: r.map((u) => m(J, { title: `${u}`, onClick: () => ((v) => {
1505
- l(o, v);
1508
+ }, Uo = ({ disabled: e = !1, selectedShape: t, removeShape: i }) => m(J, { title: "Delete", disabled: e, "data-disabled": +e, onClick: () => {
1509
+ i(Y(t));
1510
+ }, icon: Hn }), Bt = ({ CustomOption: e, selectedSettings: t, setSelectedSettings: i, title: n = "Choisissez l'option", disabled: a = !1, field: o, icon: d, values: r, defaultValue: s, valueChanged: l }) => {
1511
+ const [h] = $(ue("settings_")), c = t === h;
1512
+ return r.length ? q(Ae, { children: [m(J, { selected: c, title: n, icon: d, disabled: a, onClick: () => {
1513
+ i((u) => u === h ? void 0 : h);
1514
+ } }), c && m(nt, { title: n, alignment: "left", fitContainer: !0, children: m("div", { className: "react-paint-editor-selectfield-wrapper", children: r.map((u) => m(J, { title: `${u}`, onClick: () => ((f) => {
1515
+ l(o, f);
1506
1516
  })(u), selected: s === u, style: { "--react-paint-editor-button-padding": "16px" }, children: m(e, { children: u }) }, u)) }) })] }) : null;
1507
- }, Uo = ({ children: e }) => m("span", { className: "react-paint-editor-fontfamily-option", style: { "--react-paint-editor-fontfamily-family": e }, children: e }), Qn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: a, valueChanged: o }) => n.length ? m(Bt, { selectedSettings: e, setSelectedSettings: t, CustomOption: Uo, title: "Police", icon: '<svg><path d="M5.312 14.979H7.125L8.042 12.479H11.979L12.896 14.979H14.708L10.917 5H9.083ZM8.542 10.958 9.958 6.958H10.042L11.458 10.958ZM3.417 18.333Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V3.417Q1.667 2.688 2.177 2.177Q2.688 1.667 3.417 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417V16.583Q18.333 17.312 17.823 17.823Q17.312 18.333 16.583 18.333ZM3.417 16.583H16.583Q16.583 16.583 16.583 16.583Q16.583 16.583 16.583 16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583ZM3.417 3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583V3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417Z"/></svg>', disabled: i, field: "fontFamily", values: n, defaultValue: a, valueChanged: o }) : null, qo = ({ disabled: e, toggleLayoutPanel: t }) => m(J, { title: "Toggle layers panel", disabled: e, onClick: t, icon: '<svg><path d="M10 17.646 2.438 11.75 3.875 10.646 10 15.396 16.125 10.646 17.562 11.75ZM10 13.188 2.5 7.354 10 1.521 17.5 7.354Z"/></svg>', className: "react-paint-editor-layout-button" }), Go = ({ children: e }) => U("span", { className: "react-paint-editor-linearrow-option", "data-type": e, children: [m("span", { className: "react-paint-editor-linearrow-left" }), m("span", { className: "react-paint-editor-linearrow-right" })] }), bn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: a, valueChanged: o }) => n.length ? m(Bt, { selectedSettings: e, setSelectedSettings: t, CustomOption: Go, title: "Flèches", icon: '<svg><path d="M6 17 2 13 6 9 7.062 10.062 4.875 12.25H17V13.75H4.875L7.062 15.938ZM14 11 12.938 9.938 15.125 7.75H3V6.25H15.125L12.938 4.062L14 3L18 7Z"/></svg>', disabled: i, field: "lineArrow", values: n, defaultValue: a, valueChanged: o }) : null, _o = ({ children: e }) => U("span", { className: "react-paint-editor-linetype-option", "data-type": e, children: [m("span", {}), m("span", {}), m("span", {}), m("span", {}), m("span", {}), m("span", {}), m("span", {})] }), wn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: a, valueChanged: o }) => n.length ? m(Bt, { selectedSettings: e, setSelectedSettings: t, CustomOption: _o, icon: '<svg><path d="M3 16V14.5H4.5V16ZM6.125 16V14.5H7.625V16ZM9.25 16V14.5H10.75V16ZM12.375 16V14.5H13.875V16ZM15.5 16V14.5H17V16ZM3 13V11.5H6.5V13ZM8.25 13V11.5H11.75V13ZM13.5 13V11.5H17V13ZM3 10V8.5H9.25V10ZM10.75 10V8.5H17V10ZM3 7V4H17V7Z"/></svg>', title: "Type de traits", disabled: i, field: "lineDash", values: n, defaultValue: a, valueChanged: o }) : null, Pt = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez l'intervalle", icon: n, disabled: a = !1, field: o, value: d, min: r = 1, max: s = 20, step: l = 1, unity: c = "", valueChanged: h, saveShapes: u }) => {
1508
- const v = d === void 0, f = v ? "N/A" : `${Math.round(d)}${c}`, [g] = X(ue("settings_")), Q = ((b, S = 500) => {
1509
- const p = ne(null), w = Y((...L) => {
1510
- p.current && clearTimeout(p.current), p.current = setTimeout(() => b(...L), S);
1511
- }, [b, S]);
1517
+ }, qo = ({ children: e }) => m("span", { className: "react-paint-editor-fontfamily-option", style: { "--react-paint-editor-fontfamily-family": e }, children: e }), bn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: a, valueChanged: o }) => n.length ? m(Bt, { selectedSettings: e, setSelectedSettings: t, CustomOption: qo, title: "Police", icon: '<svg><path d="M5.312 14.979H7.125L8.042 12.479H11.979L12.896 14.979H14.708L10.917 5H9.083ZM8.542 10.958 9.958 6.958H10.042L11.458 10.958ZM3.417 18.333Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V3.417Q1.667 2.688 2.177 2.177Q2.688 1.667 3.417 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417V16.583Q18.333 17.312 17.823 17.823Q17.312 18.333 16.583 18.333ZM3.417 16.583H16.583Q16.583 16.583 16.583 16.583Q16.583 16.583 16.583 16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583ZM3.417 3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583V3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417Z"/></svg>', disabled: i, field: "fontFamily", values: n, defaultValue: a, valueChanged: o }) : null, Go = ({ disabled: e, toggleLayoutPanel: t }) => m(J, { title: "Toggle layers panel", disabled: e, onClick: t, icon: '<svg><path d="M10 17.646 2.438 11.75 3.875 10.646 10 15.396 16.125 10.646 17.562 11.75ZM10 13.188 2.5 7.354 10 1.521 17.5 7.354Z"/></svg>', className: "react-paint-editor-layout-button" }), _o = ({ children: e }) => q("span", { className: "react-paint-editor-linearrow-option", "data-type": e, children: [m("span", { className: "react-paint-editor-linearrow-left" }), m("span", { className: "react-paint-editor-linearrow-right" })] }), wn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: a, valueChanged: o }) => n.length ? m(Bt, { selectedSettings: e, setSelectedSettings: t, CustomOption: _o, title: "Flèches", icon: '<svg><path d="M6 17 2 13 6 9 7.062 10.062 4.875 12.25H17V13.75H4.875L7.062 15.938ZM14 11 12.938 9.938 15.125 7.75H3V6.25H15.125L12.938 4.062L14 3L18 7Z"/></svg>', disabled: i, field: "lineArrow", values: n, defaultValue: a, valueChanged: o }) : null, jo = ({ children: e }) => q("span", { className: "react-paint-editor-linetype-option", "data-type": e, children: [m("span", {}), m("span", {}), m("span", {}), m("span", {}), m("span", {}), m("span", {}), m("span", {})] }), xn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: a, valueChanged: o }) => n.length ? m(Bt, { selectedSettings: e, setSelectedSettings: t, CustomOption: jo, icon: '<svg><path d="M3 16V14.5H4.5V16ZM6.125 16V14.5H7.625V16ZM9.25 16V14.5H10.75V16ZM12.375 16V14.5H13.875V16ZM15.5 16V14.5H17V16ZM3 13V11.5H6.5V13ZM8.25 13V11.5H11.75V13ZM13.5 13V11.5H17V13ZM3 10V8.5H9.25V10ZM10.75 10V8.5H17V10ZM3 7V4H17V7Z"/></svg>', title: "Type de traits", disabled: i, field: "lineDash", values: n, defaultValue: a, valueChanged: o }) : null, Pt = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez l'intervalle", icon: n, disabled: a = !1, field: o, value: d, min: r = 1, max: s = 20, step: l = 1, unity: h = "", valueChanged: c, saveShapes: u }) => {
1518
+ const f = d === void 0, v = f ? "N/A" : `${Math.round(d)}${h}`, [p] = $(ue("settings_")), S = ((b, Q = 500) => {
1519
+ const g = ne(null), w = X((...L) => {
1520
+ g.current && clearTimeout(g.current), g.current = setTimeout(() => b(...L), Q);
1521
+ }, [b, Q]);
1512
1522
  return ee(() => () => {
1513
- p.current && clearTimeout(p.current);
1523
+ g.current && clearTimeout(g.current);
1514
1524
  }, []), w;
1515
- })(u), M = e === g;
1516
- return r === s ? null : U(Ae, { children: [m(J, { selected: M, title: i, disabled: a, icon: n, onClick: () => {
1517
- t((b) => b === g ? void 0 : g);
1518
- } }), M && m(nt, { title: i, alignment: "left", fitContainer: !0, children: m("div", { children: U("label", { className: "react-paint-editor-rangefield", children: [m("input", { type: "range", min: r, max: s, step: l, value: d ?? (s + r) / 2, "data-indeterminate": +v, onChange: (b) => {
1519
- const S = +b.target.value, p = Number.isNaN(S) ? b.target.value : S;
1520
- h(o, p, !1), Q();
1521
- } }), m("span", { children: f })] }) }) })] });
1522
- }, jo = ({ children: e }) => m("span", { children: e === 0 ? "Non" : "Oui" }), Ko = [0, 1], xn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, defaultValue: n, valueChanged: a }) => m(Bt, { selectedSettings: e, setSelectedSettings: t, CustomOption: jo, title: "Fermer les points", icon: gi, disabled: i, field: "closedPoints", values: Ko, defaultValue: n, valueChanged: a }), Jo = ({ disabled: e = !1, className: t, toggleZoomPanel: i }) => m(J, { title: "Toggle zoom panel", disabled: e, onClick: i, icon: An, className: t ? ` ${t}` : "" }), kt = ({ setSelectedSettings: e, disabled: t = !1, field: i, icon: n, values: a, value: o = !1, valueChanged: d }) => {
1523
- const [r] = X(ue("settings_"));
1525
+ })(u), C = e === p;
1526
+ return r === s ? null : q(Ae, { children: [m(J, { selected: C, title: i, disabled: a, icon: n, onClick: () => {
1527
+ t((b) => b === p ? void 0 : p);
1528
+ } }), C && m(nt, { title: i, alignment: "left", fitContainer: !0, children: m("div", { children: q("label", { className: "react-paint-editor-rangefield", children: [m("input", { type: "range", min: r, max: s, step: l, value: d ?? (s + r) / 2, "data-indeterminate": +f, onChange: (b) => {
1529
+ const Q = +b.target.value, g = Number.isNaN(Q) ? b.target.value : Q;
1530
+ c(o, g, !1), S();
1531
+ } }), m("span", { children: v })] }) }) })] });
1532
+ }, Ko = ({ children: e }) => m("span", { children: e === 0 ? "Non" : "Oui" }), Jo = [0, 1], Cn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, defaultValue: n, valueChanged: a }) => m(Bt, { selectedSettings: e, setSelectedSettings: t, CustomOption: Ko, title: "Fermer les points", icon: gi, disabled: i, field: "closedPoints", values: Jo, defaultValue: n, valueChanged: a }), es = ({ disabled: e = !1, className: t, toggleZoomPanel: i }) => m(J, { title: "Toggle zoom panel", disabled: e, onClick: i, icon: Dn, className: t ? ` ${t}` : "" }), kt = ({ setSelectedSettings: e, disabled: t = !1, field: i, icon: n, values: a, value: o = !1, valueChanged: d }) => {
1533
+ const [r] = $(ue("settings_"));
1524
1534
  return a.length !== 2 ? null : m(J, { onClick: () => {
1525
1535
  e((s) => s === r ? void 0 : r), d(i, !o);
1526
1536
  }, selected: o, disabled: t, icon: n });
1527
- }, ni = ({ activeTool: e, selectedShape: t, selectedShapeTool: i, disabled: n, selectedSettings: a, setSelectedSettings: o, saveShapes: d, handleShapeStyleChange: r, handleShapeFontFamilyChange: s }) => t ? i && U(Ae, { children: ["strokeColor" in i.settings && !i.settings.strokeColor.hidden && m(Mt, { selectedSettings: a, setSelectedSettings: o, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: t.style?.strokeColor, valueChanged: r, values: i.settings.strokeColor.values }), "fillColor" in i.settings && !i.settings.fillColor.hidden && m(Mt, { selectedSettings: a, setSelectedSettings: o, title: "Couleur de fond", disabled: n, field: "fillColor", value: t.style?.fillColor, valueChanged: r, values: i.settings.fillColor.values }), "lineWidth" in i.settings && !i.settings.lineWidth.hidden && m(Pt, { saveShapes: d, selectedSettings: a, setSelectedSettings: o, title: "Epaisseur du trait", icon: Ai, disabled: n, field: "lineWidth", value: t.style?.lineWidth, valueChanged: r, unity: "px", min: i.settings.lineWidth.min, max: i.settings.lineWidth.max, step: i.settings.lineWidth.step }), "lineDash" in i.settings && !i.settings.lineDash.hidden && m(wn, { selectedSettings: a, setSelectedSettings: o, disabled: n, defaultValue: t.style?.lineDash, valueChanged: r, values: i.settings.lineDash.values }), "lineArrow" in i.settings && !i.settings.lineArrow.hidden && m(bn, { selectedSettings: a, setSelectedSettings: o, disabled: n, defaultValue: t.style?.lineArrow, valueChanged: r, values: i.settings.lineArrow.values }), "closedPoints" in i.settings && !i.settings.closedPoints.hidden && m(xn, { selectedSettings: a, setSelectedSettings: o, disabled: n, valueChanged: r, defaultValue: t.style?.closedPoints }), "fontFamily" in i.settings && !i.settings.fontFamily.hidden && m(Qn, { selectedSettings: a, setSelectedSettings: o, disabled: n, valueChanged: s, values: i.settings.fontFamily.values, defaultValue: t.style?.fontFamily }), "fontBold" in i.settings && !i.settings.fontBold.hidden && m(kt, { setSelectedSettings: o, disabled: n, field: "fontBold", icon: zi, valueChanged: s, values: i.settings.fontBold.values, value: t.style?.fontBold }), "fontItalic" in i.settings && !i.settings.fontItalic.hidden && m(kt, { setSelectedSettings: o, disabled: n, field: "fontItalic", icon: Ti, valueChanged: s, values: i.settings.fontItalic.values, value: t.style?.fontItalic }), "opacity" in i.settings && !i.settings.opacity.hidden && m(Pt, { saveShapes: d, selectedSettings: a, setSelectedSettings: o, title: "Opacité", icon: Hi, min: i.settings.opacity.min, max: i.settings.opacity.max, step: i.settings.opacity.step, unity: "%", disabled: n, field: "opacity", value: t.style?.opacity, valueChanged: r })] }) : "settings" in e ? U(Ae, { children: ["strokeColor" in e.settings && !e.settings.strokeColor.hidden && m(Mt, { selectedSettings: a, setSelectedSettings: o, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: e.settings.strokeColor.default, valueChanged: r, values: e.settings.strokeColor.values }), "fillColor" in e.settings && !e.settings.fillColor.hidden && m(Mt, { selectedSettings: a, setSelectedSettings: o, title: "Couleur de fond", disabled: n, field: "fillColor", value: e.settings.fillColor.default, valueChanged: r, values: e.settings.fillColor.values }), "lineWidth" in e.settings && !e.settings.lineWidth.hidden && m(Pt, { saveShapes: d, selectedSettings: a, setSelectedSettings: o, title: "Epaisseur du trait", disabled: n, field: "lineWidth", icon: Ai, value: e.settings.lineWidth.default, valueChanged: r, unity: "px", min: e.settings.lineWidth.min, max: e.settings.lineWidth.max, step: e.settings.lineWidth.step }), "lineDash" in e.settings && !e.settings.lineDash.hidden && m(wn, { selectedSettings: a, setSelectedSettings: o, disabled: n, defaultValue: e.settings.lineDash.default, valueChanged: r, values: e.settings.lineDash.values }), "lineArrow" in e.settings && !e.settings.lineArrow.hidden && m(bn, { selectedSettings: a, setSelectedSettings: o, disabled: n, defaultValue: e.settings.lineArrow.default, valueChanged: r, values: e.settings.lineArrow.values }), "closedPoints" in e.settings && !e.settings.closedPoints.hidden && m(xn, { selectedSettings: a, setSelectedSettings: o, disabled: n, valueChanged: r, defaultValue: e.settings?.closedPoints.default }), "fontFamily" in e.settings && !e.settings.fontFamily.hidden && m(Qn, { selectedSettings: a, setSelectedSettings: o, disabled: n, valueChanged: s, values: e.settings.fontFamily.values, defaultValue: e.settings.fontFamily.default }), "fontBold" in e.settings && !e.settings.fontBold.hidden && m(kt, { setSelectedSettings: o, disabled: n, field: "fontBold", icon: zi, valueChanged: s, values: e.settings.fontBold.values, value: e.settings.fontBold.default }), "fontItalic" in e.settings && !e.settings.fontItalic.hidden && m(kt, { setSelectedSettings: o, disabled: n, field: "fontItalic", icon: Ti, valueChanged: s, values: e.settings.fontItalic.values, value: e.settings.fontItalic.default }), "opacity" in e.settings && !e.settings.opacity.hidden && m(Pt, { saveShapes: d, selectedSettings: a, setSelectedSettings: o, title: "Opacité", icon: Hi, 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: r })] }) : null, es = ({ width: e, availableTools: t, updateToolSettings: i, layersManipulation: n = !1, toggleLayoutPanel: a, activeTool: o, saveShapes: d, selectedShape: r, canvas: s, settings: l, updateShape: c, removeShape: h, isZoomPanelShown: u, setIsZoomPanelShown: v }) => {
1528
- const [f, g] = X(void 0), [Q, M] = X(!1), b = l.size === "infinite" || l.features.zoom, S = !l.features.edition, p = () => {
1529
- M((Z) => !Z);
1537
+ }, ni = ({ activeTool: e, selectedShape: t, selectedShapeTool: i, disabled: n, selectedSettings: a, setSelectedSettings: o, saveShapes: d, handleShapeStyleChange: r, handleShapeFontFamilyChange: s }) => t ? i && q(Ae, { children: ["strokeColor" in i.settings && !i.settings.strokeColor.hidden && m(Mt, { selectedSettings: a, setSelectedSettings: o, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: t.style?.strokeColor, valueChanged: r, values: i.settings.strokeColor.values }), "fillColor" in i.settings && !i.settings.fillColor.hidden && m(Mt, { selectedSettings: a, setSelectedSettings: o, title: "Couleur de fond", disabled: n, field: "fillColor", value: t.style?.fillColor, valueChanged: r, values: i.settings.fillColor.values }), "lineWidth" in i.settings && !i.settings.lineWidth.hidden && m(Pt, { saveShapes: d, selectedSettings: a, setSelectedSettings: o, title: "Epaisseur du trait", icon: Di, disabled: n, field: "lineWidth", value: t.style?.lineWidth, valueChanged: r, unity: "px", min: i.settings.lineWidth.min, max: i.settings.lineWidth.max, step: i.settings.lineWidth.step }), "lineDash" in i.settings && !i.settings.lineDash.hidden && m(xn, { selectedSettings: a, setSelectedSettings: o, disabled: n, defaultValue: t.style?.lineDash, valueChanged: r, values: i.settings.lineDash.values }), "lineArrow" in i.settings && !i.settings.lineArrow.hidden && m(wn, { selectedSettings: a, setSelectedSettings: o, disabled: n, defaultValue: t.style?.lineArrow, valueChanged: r, values: i.settings.lineArrow.values }), "closedPoints" in i.settings && !i.settings.closedPoints.hidden && m(Cn, { selectedSettings: a, setSelectedSettings: o, disabled: n, valueChanged: r, defaultValue: t.style?.closedPoints }), "fontFamily" in i.settings && !i.settings.fontFamily.hidden && m(bn, { selectedSettings: a, setSelectedSettings: o, disabled: n, valueChanged: s, values: i.settings.fontFamily.values, defaultValue: t.style?.fontFamily }), "fontBold" in i.settings && !i.settings.fontBold.hidden && m(kt, { setSelectedSettings: o, disabled: n, field: "fontBold", icon: Ti, valueChanged: s, values: i.settings.fontBold.values, value: t.style?.fontBold }), "fontItalic" in i.settings && !i.settings.fontItalic.hidden && m(kt, { setSelectedSettings: o, disabled: n, field: "fontItalic", icon: Ai, valueChanged: s, values: i.settings.fontItalic.values, value: t.style?.fontItalic }), "opacity" in i.settings && !i.settings.opacity.hidden && m(Pt, { saveShapes: d, selectedSettings: a, setSelectedSettings: o, title: "Opacité", icon: zi, min: i.settings.opacity.min, max: i.settings.opacity.max, step: i.settings.opacity.step, unity: "%", disabled: n, field: "opacity", value: t.style?.opacity, valueChanged: r })] }) : "settings" in e ? q(Ae, { children: ["strokeColor" in e.settings && !e.settings.strokeColor.hidden && m(Mt, { selectedSettings: a, setSelectedSettings: o, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: e.settings.strokeColor.default, valueChanged: r, values: e.settings.strokeColor.values }), "fillColor" in e.settings && !e.settings.fillColor.hidden && m(Mt, { selectedSettings: a, setSelectedSettings: o, title: "Couleur de fond", disabled: n, field: "fillColor", value: e.settings.fillColor.default, valueChanged: r, values: e.settings.fillColor.values }), "lineWidth" in e.settings && !e.settings.lineWidth.hidden && m(Pt, { saveShapes: d, selectedSettings: a, setSelectedSettings: o, title: "Epaisseur du trait", disabled: n, field: "lineWidth", icon: Di, value: e.settings.lineWidth.default, valueChanged: r, unity: "px", min: e.settings.lineWidth.min, max: e.settings.lineWidth.max, step: e.settings.lineWidth.step }), "lineDash" in e.settings && !e.settings.lineDash.hidden && m(xn, { selectedSettings: a, setSelectedSettings: o, disabled: n, defaultValue: e.settings.lineDash.default, valueChanged: r, values: e.settings.lineDash.values }), "lineArrow" in e.settings && !e.settings.lineArrow.hidden && m(wn, { selectedSettings: a, setSelectedSettings: o, disabled: n, defaultValue: e.settings.lineArrow.default, valueChanged: r, values: e.settings.lineArrow.values }), "closedPoints" in e.settings && !e.settings.closedPoints.hidden && m(Cn, { selectedSettings: a, setSelectedSettings: o, disabled: n, valueChanged: r, defaultValue: e.settings?.closedPoints.default }), "fontFamily" in e.settings && !e.settings.fontFamily.hidden && m(bn, { selectedSettings: a, setSelectedSettings: o, disabled: n, valueChanged: s, values: e.settings.fontFamily.values, defaultValue: e.settings.fontFamily.default }), "fontBold" in e.settings && !e.settings.fontBold.hidden && m(kt, { setSelectedSettings: o, disabled: n, field: "fontBold", icon: Ti, valueChanged: s, values: e.settings.fontBold.values, value: e.settings.fontBold.default }), "fontItalic" in e.settings && !e.settings.fontItalic.hidden && m(kt, { setSelectedSettings: o, disabled: n, field: "fontItalic", icon: Ai, valueChanged: s, values: e.settings.fontItalic.values, value: e.settings.fontItalic.default }), "opacity" in e.settings && !e.settings.opacity.hidden && m(Pt, { saveShapes: d, selectedSettings: a, setSelectedSettings: o, title: "Opacité", icon: zi, 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: r })] }) : null, ts = ({ width: e, availableTools: t, updateToolSettings: i, layersManipulation: n = !1, toggleLayoutPanel: a, activeTool: o, saveShapes: d, selectedShape: r, canvas: s, settings: l, updateShape: h, removeShape: c, isZoomPanelShown: u, setIsZoomPanelShown: f }) => {
1538
+ const [v, p] = $(void 0), [S, C] = $(!1), b = l.size === "infinite" || l.features.zoom, Q = !l.features.edition, g = () => {
1539
+ C((Z) => !Z);
1530
1540
  }, w = ((Z, A) => {
1531
- const H = _(Z).map((I) => A.find((W) => W.id === I?.toolId) || A.find((W) => W.type === I?.type)).filter((I) => I !== void 0);
1541
+ const H = Y(Z).map((E) => A.find((W) => W.id === E?.toolId) || A.find((W) => W.type === E?.type)).filter((E) => E !== void 0);
1532
1542
  if (!H.length) return;
1533
1543
  if (H.length === 1) return H[0];
1534
- const F = H.slice(1).reduce((I, W) => {
1535
- const q = {};
1536
- for (const G in W.settings) {
1537
- if (I[G] === void 0 || W.settings[G]?.hidden || I[G]?.hidden) continue;
1538
- const z = I[G], y = W.settings[G], C = {};
1539
- "min" in y && "min" in z && y.min === z.min && "max" in y && "max" in z && y.max === z.max && "step" in y && "step" in z && y.step === z.step && (C.min = y.min, C.max = y.max, C.step = y.step), "values" in y && "values" in z && y.values?.join(",") === z.values?.join(",") && (C.values = y.values), (Object.keys(C).length > 0 || G === "closedPoints") && (q[G] = C);
1544
+ const F = H.slice(1).reduce((E, W) => {
1545
+ const G = {};
1546
+ for (const _ in W.settings) {
1547
+ if (E[_] === void 0 || W.settings[_]?.hidden || E[_]?.hidden) continue;
1548
+ const z = E[_], y = W.settings[_], M = {};
1549
+ "min" in y && "min" in z && y.min === z.min && "max" in y && "max" in z && y.max === z.max && "step" in y && "step" in z && y.step === z.step && (M.min = y.min, M.max = y.max, M.step = y.step), "values" in y && "values" in z && y.values?.join(",") === z.values?.join(",") && (M.values = y.values), (Object.keys(M).length > 0 || _ === "closedPoints") && (G[_] = M);
1540
1550
  }
1541
- return q;
1551
+ return G;
1542
1552
  }, H[0].settings);
1543
- return { id: H.map((I) => I.id).join("-"), icon: "", label: "group", type: "group", settings: F };
1553
+ return { id: H.map((E) => E.id).join("-"), icon: "", label: "group", type: "group", settings: F };
1544
1554
  })(r, t), L = (w ? Object.keys(w.settings).length + 1 : "settings" in o ? Object.keys(o.settings).length : 0) + +n + +b, D = e < 40 * L, V = (Z, A, H = !0) => {
1545
- if (_(r).length) {
1546
- const F = _(r).map((I) => Ne(Le(["style", Z], A, I), l));
1547
- c(F, H), w && i(w.id, Z, A);
1555
+ if (Y(r).length) {
1556
+ const F = Y(r).map((E) => Ne(Le(["style", Z], A, E), l));
1557
+ h(F, H), w && i(w.id, Z, A);
1548
1558
  } else i(o.id, Z, A);
1549
1559
  }, x = (Z, A) => {
1550
- if (_(r).length) {
1551
- const H = _(r).map((F) => {
1560
+ if (Y(r).length) {
1561
+ const H = Y(r).map((F) => {
1552
1562
  if (F.type !== "text") return F;
1553
- const I = s?.getContext("2d");
1554
- if (!I) return F;
1555
- const W = Le(["style", Z], A, F), q = Rt(I, W.value, W.width, W.style?.fontBold ?? !1, W.style?.fontItalic ?? !1, W.style?.fontFamily);
1556
- return Ne({ ...W, fontSize: q, height: q * W.value.length }, l);
1563
+ const E = s?.getContext("2d");
1564
+ if (!E) return F;
1565
+ const W = Le(["style", Z], A, F), G = Rt(E, W.value, W.width, W.style?.fontBold ?? !1, W.style?.fontItalic ?? !1, W.style?.fontFamily);
1566
+ return Ne({ ...W, fontSize: G, height: G * W.value.length }, l);
1557
1567
  });
1558
- c(H, !0), w && i(w.id, Z, A);
1568
+ h(H, !0), w && i(w.id, Z, A);
1559
1569
  } else i(o.id, Z, A);
1560
1570
  };
1561
- return U(Ae, { children: [U("div", { className: "react-paint-editor-settings-bar", children: [U("div", { className: "react-paint-editor-settings-shrinkable", children: [b && m(Jo, { className: u ? "react-paint-editor-bar-zoom-button-opened" : void 0, toggleZoomPanel: () => {
1562
- v((Z) => !Z);
1563
- } }), D && L > 2 && m(J, { disabled: S, onClick: p, title: "Toggle settings", icon: '<svg><path d="M2.5 15.833V14.083H7.667V15.833ZM2.5 5.917V4.167H10.771V5.917ZM9.208 17.5V12.438H10.958V14.083H17.5V15.833H10.958V17.5ZM5.917 12.542V10.875H2.5V9.125H5.917V7.479H7.667V12.542ZM9.208 10.875V9.125H17.5V10.875ZM12.333 7.562V2.5H14.083V4.167H17.5V5.917H14.083V7.562Z"/></svg>' }), r ? w && U(Ae, { children: [!D && m(ni, { saveShapes: d, activeTool: o, selectedShape: r, selectedShapeTool: w, disabled: S, selectedSettings: f, setSelectedSettings: g, handleShapeStyleChange: V, handleShapeFontFamilyChange: x }), o.type === "selection" && m($o, { disabled: S, selectedShape: r, removeShape: h })] }) : !D && m(ni, { saveShapes: d, activeTool: o, selectedShape: r, selectedShapeTool: w, disabled: S, selectedSettings: f, setSelectedSettings: g, handleShapeStyleChange: V, handleShapeFontFamilyChange: x })] }), m("div", { className: "react-paint-editor-settings-separator" }), n && m(qo, { disabled: S, toggleLayoutPanel: a })] }), Q && m(Nt, { className: "react-paint-editor-settings-modal", onClose: p, position: "bottom", title: "Settings", children: m(ni, { saveShapes: d, activeTool: o, selectedShape: r, selectedShapeTool: w, disabled: S, selectedSettings: f, setSelectedSettings: g, handleShapeStyleChange: V, handleShapeFontFamilyChange: x }) })] });
1564
- }, Cn = ({ disabled: e = !1, withText: t = !1, loadFile: i, type: n, img: a, accept: o }) => {
1571
+ return q(Ae, { children: [q("div", { className: "react-paint-editor-settings-bar", children: [q("div", { className: "react-paint-editor-settings-shrinkable", children: [b && m(es, { className: u ? "react-paint-editor-bar-zoom-button-opened" : void 0, toggleZoomPanel: () => {
1572
+ f((Z) => !Z);
1573
+ } }), D && L > 2 && m(J, { disabled: Q, onClick: g, title: "Toggle settings", icon: '<svg><path d="M2.5 15.833V14.083H7.667V15.833ZM2.5 5.917V4.167H10.771V5.917ZM9.208 17.5V12.438H10.958V14.083H17.5V15.833H10.958V17.5ZM5.917 12.542V10.875H2.5V9.125H5.917V7.479H7.667V12.542ZM9.208 10.875V9.125H17.5V10.875ZM12.333 7.562V2.5H14.083V4.167H17.5V5.917H14.083V7.562Z"/></svg>' }), r ? w && q(Ae, { children: [!D && m(ni, { saveShapes: d, activeTool: o, selectedShape: r, selectedShapeTool: w, disabled: Q, selectedSettings: v, setSelectedSettings: p, handleShapeStyleChange: V, handleShapeFontFamilyChange: x }), o.type === "selection" && m(Uo, { disabled: Q, selectedShape: r, removeShape: c })] }) : !D && m(ni, { saveShapes: d, activeTool: o, selectedShape: r, selectedShapeTool: w, disabled: Q, selectedSettings: v, setSelectedSettings: p, handleShapeStyleChange: V, handleShapeFontFamilyChange: x })] }), m("div", { className: "react-paint-editor-settings-separator" }), n && m(Go, { disabled: Q, toggleLayoutPanel: a })] }), S && m(Nt, { className: "react-paint-editor-settings-modal", onClose: g, position: "bottom", title: "Settings", children: m(ni, { saveShapes: d, activeTool: o, selectedShape: r, selectedShapeTool: w, disabled: Q, selectedSettings: v, setSelectedSettings: p, handleShapeStyleChange: V, handleShapeFontFamilyChange: x }) })] });
1574
+ }, Mn = ({ disabled: e = !1, withText: t = !1, loadFile: i, type: n, img: a, accept: o }) => {
1565
1575
  const d = ne(null);
1566
1576
  return m(J, { ref: d, type: "file", onClick: (r) => {
1567
1577
  r.stopPropagation(), d.current && (d.current.value = "");
@@ -1571,8 +1581,8 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
1571
1581
  }, accept: o, title: n.label ?? n.type, icon: a, disabled: e, children: t ? n.label : void 0 });
1572
1582
  }, ke = ({ type: e, img: t, isActive: i, withText: n = !1, disabled: a = !1, setActive: o }) => m(J, { disabled: a, selected: i, onClick: () => {
1573
1583
  o(e);
1574
- }, title: e.label ?? e.type, icon: t, children: n ? e.label : void 0 }), ts = ({ activeTool: e, withActionsInMenu: t, hasActionToUndo: i = !1, hasActionToRedo: n = !1, hasActionToClear: a = !1, undoAction: o, redoAction: d, clearCanvas: r, alignment: s, group: l, vertical: c = !1, disabled: h = !1, withLoadAndSave: u, withExport: v, addPicture: f, loadFile: g, togglePictureUrlModal: Q, saveFile: M, toggleExportModal: b, withUploadPicture: S, withUrlPicture: p }) => {
1575
- const [w, L] = X(!1), [, D] = Ln(), V = l?.tools?.some((Z) => Z === e.type), x = (V ? e.icon : l.img) ?? l.title;
1584
+ }, title: e.label ?? e.type, icon: t, children: n ? e.label : void 0 }), is = ({ activeTool: e, withActionsInMenu: t, hasActionToUndo: i = !1, hasActionToRedo: n = !1, hasActionToClear: a = !1, undoAction: o, redoAction: d, clearCanvas: r, alignment: s, group: l, vertical: h = !1, disabled: c = !1, withLoadAndSave: u, withExport: f, addPicture: v, loadFile: p, togglePictureUrlModal: S, saveFile: C, toggleExportModal: b, withUploadPicture: Q, withUrlPicture: g }) => {
1585
+ const [w, L] = $(!1), [, D] = Vn(), V = l?.tools?.some((Z) => Z === e.type), x = (V ? e.icon : l.img) ?? l.title;
1576
1586
  return ee(() => {
1577
1587
  if (!w) return;
1578
1588
  const Z = () => {
@@ -1581,132 +1591,132 @@ const Gi = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, c
1581
1591
  return document.addEventListener("click", Z), () => {
1582
1592
  document.removeEventListener("click", Z);
1583
1593
  };
1584
- }, [w]), t || S || p || u || v ? U("div", { className: "react-paint-editor-toolbox-relative", children: [m(J, { selected: V, title: l.title, disabled: h, onClick: () => {
1594
+ }, [w]), t || Q || g || u || f ? q("div", { className: "react-paint-editor-toolbox-relative", children: [m(J, { selected: V, title: l.title, disabled: c, onClick: () => {
1585
1595
  D(() => {
1586
1596
  L(!0);
1587
1597
  });
1588
- }, icon: x }), w && m(nt, { alignment: s, position: "top", children: U("div", { className: "react-paint-editor-toolbox-panel-content", "data-vertical": +c, children: [t && U(Ae, { children: [m(ke, { withText: !0, type: dt, disabled: h || !i, img: dt.icon, isActive: e.id === dt.id, setActive: o }), m(ke, { withText: !0, type: ct, disabled: h || !n, img: ct.icon, isActive: e.id === ct.id, setActive: d }), m(ke, { withText: !0, type: ht, disabled: h || !a, img: ht.icon, isActive: e.id === ht.id, setActive: r }), (S || p || u) && m("hr", {})] }), S && m(Cn, { withText: !0, type: Ri, disabled: h, loadFile: async (Z) => {
1589
- L(!1), await f(Z);
1590
- }, img: Ri.icon, accept: "image/png, image/gif, image/jpeg, image/svg+xml, image/webp" }), p && m(J, { disabled: h, selected: !1, onClick: Q, 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" }), (S || p) && u && m("hr", {}), u && U(Ae, { children: [m(Cn, { withText: !0, type: Wi, disabled: h, loadFile: (Z) => {
1591
- L(!1), g(Z);
1592
- }, img: Wi.icon, accept: "application/JSON" }), m(ke, { withText: !0, disabled: h, type: jt, img: jt.icon, isActive: e.id === jt.id, setActive: M })] }), v && m(ke, { withText: !0, disabled: h, type: _t, img: _t.icon, isActive: e.id === _t.id, setActive: b })] }) })] }) : null;
1593
- }, is = ({ togglePictureUrlModal: e, addPicture: t }) => {
1598
+ }, icon: x }), w && m(nt, { alignment: s, position: "top", children: q("div", { className: "react-paint-editor-toolbox-panel-content", "data-vertical": +h, children: [t && q(Ae, { children: [m(ke, { withText: !0, type: dt, disabled: c || !i, img: dt.icon, isActive: e.id === dt.id, setActive: o }), m(ke, { withText: !0, type: ct, disabled: c || !n, img: ct.icon, isActive: e.id === ct.id, setActive: d }), m(ke, { withText: !0, type: ht, disabled: c || !a, img: ht.icon, isActive: e.id === ht.id, setActive: r }), (Q || g || u) && m("hr", {})] }), Q && m(Mn, { withText: !0, type: Ni, disabled: c, loadFile: async (Z) => {
1599
+ L(!1), await v(Z);
1600
+ }, img: Ni.icon, accept: "image/png, image/gif, image/jpeg, image/svg+xml, image/webp" }), g && m(J, { disabled: c, 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" }), (Q || g) && u && m("hr", {}), u && q(Ae, { children: [m(Mn, { withText: !0, type: Ri, disabled: c, loadFile: (Z) => {
1601
+ L(!1), p(Z);
1602
+ }, img: Ri.icon, accept: "application/JSON" }), m(ke, { withText: !0, disabled: c, type: jt, img: jt.icon, isActive: e.id === jt.id, setActive: C })] }), f && m(ke, { withText: !0, disabled: c, type: _t, img: _t.icon, isActive: e.id === _t.id, setActive: b })] }) })] }) : null;
1603
+ }, ns = ({ togglePictureUrlModal: e, addPicture: t }) => {
1594
1604
  const i = ne(null);
1595
1605
  return ee(() => {
1596
1606
  i.current && i.current.focus();
1597
- }, []), m(Nt, { className: "react-paint-editor-toolbox-pictureinput-modal", onClose: e, title: "Add picture from URL", children: U("form", { onSubmit: async (n) => {
1607
+ }, []), m(Nt, { className: "react-paint-editor-toolbox-pictureinput-modal", onClose: e, title: "Add picture from URL", children: q("form", { onSubmit: async (n) => {
1598
1608
  n.preventDefault();
1599
1609
  const a = i.current?.value;
1600
1610
  a && (await t(a), e());
1601
- }, children: [U("label", { children: ["URL ", m("input", { type: "text", ref: i })] }), m(J, { onClick: e, children: "Annuler" }), m(J, { type: "submit", selected: !0, children: "Ajouter" })] }) });
1602
- }, Mn = "Choose export settings", ns = ({ toggleExportModal: e, exportCanvasInFile: t }) => {
1611
+ }, children: [q("label", { children: ["URL ", m("input", { type: "text", ref: i })] }), m(J, { onClick: e, children: "Annuler" }), m(J, { type: "submit", selected: !0, children: "Ajouter" })] }) });
1612
+ }, Pn = "Choose export settings", as = ({ toggleExportModal: e, exportCanvasInFile: t }) => {
1603
1613
  const i = async (n) => {
1604
1614
  t(n), e();
1605
1615
  };
1606
- return U(Nt, { className: "react-paint-editor-toolbox-export-modal", onClose: e, title: Mn, children: [m("h3", { children: Mn }), m("hr", {}), m(J, { onClick: () => i("currentZoom"), children: "Exporter la vue actuelle" }), m(J, { onClick: () => i("defaultView"), children: "Exporter le canevas par défaut" }), m(J, { onClick: () => i("fitToShapes"), children: "Exporter le dessin entier" }), m(J, { selected: !0, onClick: e, children: "Annuler" })] });
1607
- }, as = ({ activeTool: e, alignment: t, group: i, disabled: n = !1, setActiveToolFromId: a }) => {
1608
- const o = ne(null), [d, r] = X(!1), [, s] = Ln(), [l, c] = X(void 0), h = (f) => {
1609
- c(f), a(f.id);
1616
+ return q(Nt, { className: "react-paint-editor-toolbox-export-modal", onClose: e, title: Pn, children: [m("h3", { children: Pn }), m("hr", {}), m(J, { onClick: () => i("currentZoom"), children: "Exporter la vue actuelle" }), m(J, { onClick: () => i("defaultView"), children: "Exporter le canevas par défaut" }), m(J, { onClick: () => i("fitToShapes"), children: "Exporter le dessin entier" }), m(J, { selected: !0, onClick: e, children: "Annuler" })] });
1617
+ }, os = ({ activeTool: e, alignment: t, group: i, disabled: n = !1, setActiveToolFromId: a }) => {
1618
+ const o = ne(null), [d, r] = $(!1), [, s] = Vn(), [l, h] = $(void 0), c = (v) => {
1619
+ h(v), a(v.id);
1610
1620
  };
1611
1621
  if (ee(() => {
1612
1622
  if (!d) return;
1613
- const f = (g) => {
1614
- !((M, b) => !!(M.target instanceof Node && b) && b.contains(M.target))(g, o.current) && r(!1);
1623
+ const v = (p) => {
1624
+ !((C, b) => !!(C.target instanceof Node && b) && b.contains(C.target))(p, o.current) && r(!1);
1615
1625
  };
1616
- return document.addEventListener("mousedown", f, { passive: !1 }), document.addEventListener("touchstart", f, { passive: !1 }), () => {
1617
- document.removeEventListener("mousedown", f), document.removeEventListener("touchstart", f);
1626
+ return document.addEventListener("mousedown", v, { passive: !1 }), document.addEventListener("touchstart", v, { passive: !1 }), () => {
1627
+ document.removeEventListener("mousedown", v), document.removeEventListener("touchstart", v);
1618
1628
  };
1619
- }, [d]), "type" in i) return m(ke, { disabled: n, type: i, img: i.icon, isActive: e.id === i.id, setActive: h });
1629
+ }, [d]), "type" in i) return m(ke, { disabled: n, type: i, img: i.icon, isActive: e.id === i.id, setActive: c });
1620
1630
  if (!i.toolsType.length) return null;
1621
- if (i.toolsType?.length === 1) return m(ke, { disabled: n, type: i.toolsType[0], img: i.toolsType[0].icon, isActive: e.id === i.toolsType[0].id, setActive: h });
1622
- const u = i?.toolsType.find((f) => f.type === e.type) !== void 0, v = (l ? l.icon : i.toolsType?.[0]?.icon) ?? i.title;
1623
- return U("div", { className: "react-paint-editor-toolbargroup-relative", children: [m(J, { selected: u, title: i.title, disabled: n, onClick: () => {
1624
- l ? a(l.id) : i.toolsType?.[0] && h(i.toolsType[0]), s(() => {
1631
+ if (i.toolsType?.length === 1) return m(ke, { disabled: n, type: i.toolsType[0], img: i.toolsType[0].icon, isActive: e.id === i.toolsType[0].id, setActive: c });
1632
+ const u = i?.toolsType.find((v) => v.type === e.type) !== void 0, f = (l ? l.icon : i.toolsType?.[0]?.icon) ?? i.title;
1633
+ return q("div", { className: "react-paint-editor-toolbargroup-relative", children: [m(J, { selected: u, title: i.title, disabled: n, onClick: () => {
1634
+ l ? a(l.id) : i.toolsType?.[0] && c(i.toolsType[0]), s(() => {
1625
1635
  r(!0);
1626
1636
  });
1627
- }, icon: v }), d && m(nt, { alignment: t, position: "top", children: m("div", { className: "react-paint-editor-toolbargroup-panel-content", "data-vertical": +i.vertical, ref: o, children: i.toolsType.map((f) => m(ke, { disabled: n, type: f, img: f.icon, isActive: e.id === f.id, setActive: h }, f.id)) }) })] });
1628
- }, os = [{ title: "brush", toolsType: ["brush"], vertical: !1 }, { title: "lines", toolsType: ["line", "curve", "polygon"], vertical: !1 }, { title: "shapes", toolsType: ["rect", "square", "circle", "ellipse"], vertical: !1 }, "text"], ss = ({ settings: e, width: t, activeTool: i, hasActionToUndo: n = !1, hasActionToRedo: a = !1, hasActionToClear: o = !1, withLoadAndSave: d, withExport: r, clearCanvas: s, setActiveTool: l, undoAction: c, redoAction: h, addPicture: u, loadFile: v, saveFile: f, exportCanvasInFile: g, availableTools: Q, withUrlPicture: M, withUploadPicture: b }) => {
1629
- const S = ((z, y) => {
1630
- const C = y.flatMap((P) => {
1637
+ }, icon: f }), d && m(nt, { alignment: t, position: "top", children: m("div", { className: "react-paint-editor-toolbargroup-panel-content", "data-vertical": +i.vertical, ref: o, children: i.toolsType.map((v) => m(ke, { disabled: n, type: v, img: v.icon, isActive: e.id === v.id, setActive: c }, v.id)) }) })] });
1638
+ }, ss = [{ title: "brush", toolsType: ["brush"], vertical: !1 }, { title: "lines", toolsType: ["line", "curve", "polygon"], vertical: !1 }, { title: "shapes", toolsType: ["rect", "square", "circle", "ellipse"], vertical: !1 }, "text"], rs = ({ settings: e, width: t, activeTool: i, hasActionToUndo: n = !1, hasActionToRedo: a = !1, hasActionToClear: o = !1, withLoadAndSave: d, withExport: r, clearCanvas: s, setActiveTool: l, undoAction: h, redoAction: c, addPicture: u, loadFile: f, saveFile: v, exportCanvasInFile: p, availableTools: S, withUrlPicture: C, withUploadPicture: b }) => {
1639
+ const Q = ((z, y) => {
1640
+ const M = y.flatMap((P) => {
1631
1641
  if (typeof P != "object") return z.filter((k) => k.type === P);
1632
1642
  const T = z.filter((k) => P.toolsType.includes(k.type));
1633
1643
  return T ? { ...P, toolsType: T } : null;
1634
1644
  });
1635
- return wi(C);
1636
- })(Q, os), p = !e.features.edition, w = t < 40 * (6 + S.length), L = t < 40 * (3 + S.length), [D, V] = X(!1), [x, Z] = X(!1), [A, H] = X(!1), F = () => {
1645
+ return xi(M);
1646
+ })(S, ss), g = !e.features.edition, w = t < 40 * (6 + Q.length), L = t < 40 * (3 + Q.length), [D, V] = $(!1), [x, Z] = $(!1), [A, H] = $(!1), F = () => {
1637
1647
  V((z) => !z);
1638
- }, I = () => {
1648
+ }, E = () => {
1639
1649
  H((z) => !z);
1640
1650
  }, W = (z) => {
1641
1651
  l(z), V(!1);
1642
- }, q = (z) => {
1643
- W(Q.find((y) => y.id === z) ?? i);
1644
- }, G = Q.find((z) => z.type === i.type) !== void 0;
1645
- return U(Ae, { children: [U("div", { className: "react-paint-editor-toolbar-toolbox", style: { "--react-paint-editor-toolbar-minwidth": "160px" }, children: [U("div", { className: "react-paint-editor-toolbar-shrinkable", children: [m(ke, { type: Oe, disabled: p, img: Oe.icon, isActive: i.id === Oe.id, setActive: W }), (e.size === "infinite" || e.features.zoom) && m(ke, { type: Kt, disabled: p, img: Kt.icon, isActive: i.id === Kt.id, setActive: W }), L ? m(J, { disabled: p, onClick: F, 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: G }) : S.map((z) => m(as, { disabled: p, activeTool: i, group: z, setActiveToolFromId: q }, "id" in z ? z.id : z.title))] }), !w && U(Ae, { children: [m(ke, { type: dt, disabled: p || !n, img: dt.icon, isActive: i.id === dt.id, setActive: c }), m(ke, { type: ct, disabled: p || !a, img: ct.icon, isActive: i.id === ct.id, setActive: h }), m(ke, { type: ht, disabled: p || !o, img: ht.icon, isActive: i.id === ht.id, setActive: s })] }), m(ts, { withActionsInMenu: w, disabled: p, vertical: !0, alignment: "right", group: { title: "Menu", img: '<svg><path d="M2.5 15V13.25H17.5V15ZM2.5 10.875V9.125H17.5V10.875ZM2.5 6.75V5H17.5V6.75Z"/></svg>' }, activeTool: i, addPicture: u, loadFile: v, saveFile: f, togglePictureUrlModal: () => {
1652
+ }, G = (z) => {
1653
+ W(S.find((y) => y.id === z) ?? i);
1654
+ }, _ = S.find((z) => z.type === i.type) !== void 0;
1655
+ return q(Ae, { children: [q("div", { className: "react-paint-editor-toolbar-toolbox", style: { "--react-paint-editor-toolbar-minwidth": "160px" }, children: [q("div", { className: "react-paint-editor-toolbar-shrinkable", children: [m(ke, { type: Oe, disabled: g, img: Oe.icon, isActive: i.id === Oe.id, setActive: W }), (e.size === "infinite" || e.features.zoom) && m(ke, { type: Kt, disabled: g, img: Kt.icon, isActive: i.id === Kt.id, setActive: W }), L ? m(J, { disabled: g, onClick: F, 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: _ }) : Q.map((z) => m(os, { disabled: g, activeTool: i, group: z, setActiveToolFromId: G }, "id" in z ? z.id : z.title))] }), !w && q(Ae, { children: [m(ke, { type: dt, disabled: g || !n, img: dt.icon, isActive: i.id === dt.id, setActive: h }), m(ke, { type: ct, disabled: g || !a, img: ct.icon, isActive: i.id === ct.id, setActive: c }), m(ke, { type: ht, disabled: g || !o, img: ht.icon, isActive: i.id === ht.id, setActive: s })] }), m(is, { withActionsInMenu: w, disabled: g, vertical: !0, alignment: "right", group: { title: "Menu", img: '<svg><path d="M2.5 15V13.25H17.5V15ZM2.5 10.875V9.125H17.5V10.875ZM2.5 6.75V5H17.5V6.75Z"/></svg>' }, activeTool: i, addPicture: u, loadFile: f, saveFile: v, togglePictureUrlModal: () => {
1646
1656
  Z(!0);
1647
- }, toggleExportModal: I, withUploadPicture: b, withUrlPicture: M, withLoadAndSave: d, withExport: r, hasActionToUndo: n, hasActionToRedo: a, hasActionToClear: o, undoAction: c, redoAction: h, clearCanvas: s })] }), D && m(Nt, { className: "react-paint-editor-toolbar-modal", onClose: F, title: "Outils", children: Q.map((z) => z.type === "picture" ? null : m(ke, { disabled: p, type: z, img: z.icon, withText: !1, isActive: i.id === z.id, setActive: W }, z.id)) }), x && m(is, { togglePictureUrlModal: () => {
1657
+ }, toggleExportModal: E, withUploadPicture: b, withUrlPicture: C, withLoadAndSave: d, withExport: r, hasActionToUndo: n, hasActionToRedo: a, hasActionToClear: o, undoAction: h, redoAction: c, clearCanvas: s })] }), D && m(Nt, { className: "react-paint-editor-toolbar-modal", onClose: F, title: "Outils", children: S.map((z) => z.type === "picture" ? null : m(ke, { disabled: g, type: z, img: z.icon, withText: !1, isActive: i.id === z.id, setActive: W }, z.id)) }), x && m(ns, { togglePictureUrlModal: () => {
1648
1658
  Z((z) => !z);
1649
- }, addPicture: u }), A && m(ns, { toggleExportModal: I, exportCanvasInFile: g })] });
1650
- }, Lt = { none: 0, small: 10, medium: 20, large: 40 }, rs = { toolbarBackgroundColor: "white", dividerColor: "#36418129", fontRadius: 8, fontDisabledColor: "#3641812b", fontDisabledBackgroundColor: "transparent", fontColor: "#364181", fontBackgroundColor: "transparent", fontSelectedColor: "white", fontSelectedBackgroundColor: "#364181", fontHoverColor: "#364181", fontHoverBackgroundColor: "#afd8d8" }, ls = () => {
1651
- const e = ne([]), [t, i] = X([]);
1659
+ }, addPicture: u }), A && m(as, { toggleExportModal: E, exportCanvasInFile: p })] });
1660
+ }, Lt = { none: 0, small: 10, medium: 20, large: 40 }, ls = { toolbarBackgroundColor: "white", dividerColor: "#36418129", fontRadius: 8, fontDisabledColor: "#3641812b", fontDisabledBackgroundColor: "transparent", fontColor: "#364181", fontBackgroundColor: "transparent", fontSelectedColor: "white", fontSelectedBackgroundColor: "#364181", fontHoverColor: "#364181", fontHoverBackgroundColor: "#afd8d8" }, ds = () => {
1661
+ const e = ne([]), [t, i] = $([]);
1652
1662
  return ee(() => () => {
1653
1663
  for (const n of e.current) clearTimeout(n);
1654
- }, []), { snackbarList: t, addSnackbar: ({ type: n = Wo, duration: a = Ro, text: o }) => {
1664
+ }, []), { snackbarList: t, addSnackbar: ({ type: n = Ro, duration: a = No, text: o }) => {
1655
1665
  const d = { id: ue("snackbar_"), duration: a, type: n, text: o };
1656
1666
  i((r) => [...r, d]), e.current = [...e.current, setTimeout(() => {
1657
1667
  return r = d.id, void i((s) => s.filter((l) => l.id !== r));
1658
1668
  var r;
1659
1669
  }, a)];
1660
1670
  } };
1661
- }, ps = ({ editorProps: e, className: t, style: i, options: n, children: a }) => {
1662
- const { shapesRef: o, addPictureShape: d, moveShapes: r, toggleShapeVisibility: s, toggleShapeLock: l, canGoBackward: c, canGoForward: h, canClear: u, selectedShape: v, removeShape: f, updateShape: g, backwardShape: Q, forwardShape: M, refs: b, width: S, height: p, selectTool: w, selectShapes: L, activeTool: D, setActiveTool: V, setAvailableTools: x, isEditMode: Z, availableTools: A, gridGap: H, setGridGap: F, loadFile: I, exportPicture: W, exportData: q, clearCanvas: G, settings: z, setCanvasZoom: y, saveShapes: C, canvas: { canGrow: P, layersManipulation: T, withExport: k, withLoadAndSave: O, withUploadPicture: R, withUrlPicture: B } } = e, { toolbarBackgroundColor: E, dividerColor: K, fontRadius: de, fontDisabledColor: se, fontDisabledBackgroundColor: j, fontColor: N, fontBackgroundColor: ge, fontSelectedColor: oe, fontSelectedBackgroundColor: ye, fontHoverColor: Se, fontHoverBackgroundColor: Qe } = { ...rs, ...n }, te = z.size === "infinite" || z.features.zoom, [fe, $] = X(!1), [ae, Me] = X(!1), [Ze, re] = X(te), Te = te && Ze, qe = H >= Lt.large ? "large" : H >= Lt.medium ? "medium" : H >= Lt.small ? "small" : "none", { snackbarList: Ot, addSnackbar: Ee } = ls(), Ft = Y((ve, me, ft) => {
1663
- x((Fe) => Fe.map((at) => at.id === ve ? Le(["settings", me, "default"], ft, at) : at)), V((Fe) => Fe.id === ve ? Le(["settings", me, "default"], ft, Fe) : Fe);
1664
- }, [V, x]), Yt = Y((ve) => {
1665
- $(!0);
1671
+ }, gs = ({ editorProps: e, className: t, style: i, options: n, children: a }) => {
1672
+ const { shapesRef: o, addPictureShape: d, moveShapes: r, toggleShapeVisibility: s, toggleShapeLock: l, canGoBackward: h, canGoForward: c, canClear: u, selectedShape: f, removeShape: v, updateShape: p, backwardShape: S, forwardShape: C, refs: b, width: Q, height: g, selectTool: w, selectShapes: L, activeTool: D, setActiveTool: V, setAvailableTools: x, isEditMode: Z, availableTools: A, gridGap: H, setGridGap: F, loadFile: E, exportPicture: W, exportData: G, clearCanvas: _, settings: z, setCanvasZoom: y, saveShapes: M, canvas: { canGrow: P, layersManipulation: T, withExport: k, withLoadAndSave: O, withUploadPicture: R, withUrlPicture: B } } = e, { toolbarBackgroundColor: I, dividerColor: j, fontRadius: de, fontDisabledColor: se, fontDisabledBackgroundColor: K, fontColor: N, fontBackgroundColor: ge, fontSelectedColor: oe, fontSelectedBackgroundColor: ye, fontHoverColor: Se, fontHoverBackgroundColor: Qe } = { ...ls, ...n }, te = z.size === "infinite" || z.features.zoom, [ve, U] = $(!1), [ae, Me] = $(!1), [Ze, re] = $(te), Te = te && Ze, qe = H >= Lt.large ? "large" : H >= Lt.medium ? "medium" : H >= Lt.small ? "small" : "none", { snackbarList: Ot, addSnackbar: De } = ds(), Ft = X((fe, me, gt) => {
1673
+ x((Fe) => Fe.map((at) => at.id === fe ? Le(["settings", me, "default"], gt, at) : at)), V((Fe) => Fe.id === fe ? Le(["settings", me, "default"], gt, Fe) : Fe);
1674
+ }, [V, x]), Yt = X((fe) => {
1675
+ U(!0);
1666
1676
  try {
1667
- W(ve);
1677
+ W(fe);
1668
1678
  } catch (me) {
1669
- me instanceof Error && Ee({ type: "error", text: `L'export a échoué : ${me.message}` }), console.warn(me);
1679
+ me instanceof Error && De({ type: "error", text: `L'export a échoué : ${me.message}` }), console.warn(me);
1670
1680
  } finally {
1671
- $(!1);
1681
+ U(!1);
1672
1682
  }
1673
- }, [W, Ee]), Ge = Y(() => {
1674
- $(!0);
1683
+ }, [W, De]), Ge = X(() => {
1684
+ U(!0);
1675
1685
  try {
1676
- q(), $(!1);
1677
- } catch (ve) {
1678
- ve instanceof Error && Ee({ type: "error", text: "L'enregistrement a échoué" }), console.warn(ve);
1686
+ G(), U(!1);
1687
+ } catch (fe) {
1688
+ fe instanceof Error && De({ type: "error", text: "L'enregistrement a échoué" }), console.warn(fe);
1679
1689
  } finally {
1680
- $(!1);
1690
+ U(!1);
1681
1691
  }
1682
- }, [q, Ee]), Xt = Y(async (ve) => {
1683
- $(!0);
1692
+ }, [G, De]), Xt = X(async (fe) => {
1693
+ U(!0);
1684
1694
  try {
1685
- await I(ve), Ee({ type: "success", text: "Fichier chargé !" });
1695
+ await E(fe), De({ type: "success", text: "Fichier chargé !" });
1686
1696
  } catch (me) {
1687
- me instanceof Error && Ee({ type: "error", text: "Le chargement a échoué" }), console.warn(me);
1697
+ me instanceof Error && De({ type: "error", text: "Le chargement a échoué" }), console.warn(me);
1688
1698
  } finally {
1689
- $(!1);
1699
+ U(!1);
1690
1700
  }
1691
- }, [I, Ee]), $t = Y(async (ve) => {
1692
- $(!0);
1701
+ }, [E, De]), $t = X(async (fe) => {
1702
+ U(!0);
1693
1703
  try {
1694
- const me = await d(ve, S, p);
1704
+ const me = await d(fe, Q, g);
1695
1705
  L([me]);
1696
1706
  } catch (me) {
1697
- me instanceof Error && Ee({ type: "error", text: "Le chargement a échoué" }), console.warn(me);
1707
+ me instanceof Error && De({ type: "error", text: "Le chargement a échoué" }), console.warn(me);
1698
1708
  } finally {
1699
- $(!1);
1709
+ U(!1);
1700
1710
  }
1701
- }, [d, L, Ee, S, p]), Ut = `${t ? `${t} ` : ""}${ae ? "react-paint-editor-layout-opened " : ""}react-paint-editor-app`;
1702
- return U("div", { ref: b.setEditor, className: Ut, style: { "--react-paint-editor-app-maxWidth": P ? "100%" : `${S}px`, "--react-paint-editor-app-toolbar-bg": E, "--react-paint-editor-app-divider-color": K, "--react-paint-editor-app-font-radius": de, "--react-paint-editor-app-font-disabled-color": se, "--react-paint-editor-app-font-disabled-bg": j, "--react-paint-editor-app-font-color": N, "--react-paint-editor-app-font-bg": ge, "--react-paint-editor-app-font-selected-color": oe, "--react-paint-editor-app-font-selected-bg": ye, "--react-paint-editor-app-font-hover-color": Se, "--react-paint-editor-app-font-hover-bg": Qe, ...i }, children: [Z && m(ss, { settings: z, width: z.canvasSize.width, activeTool: D, clearCanvas: G, setActiveTool: w, exportCanvasInFile: Yt, saveFile: Ge, loadFile: Xt, addPicture: $t, hasActionToUndo: c, hasActionToRedo: h, hasActionToClear: u, undoAction: Q, redoAction: M, availableTools: A, withExport: k, withLoadAndSave: O, withUploadPicture: R, withUrlPicture: B }), a, Z && T && m(Xo, { gridFormat: qe, setGridFormat: (ve) => {
1703
- F(Lt[ve]);
1704
- }, shapes: o.current, moveShapes: r, selectedShapes: v, removeShape: f, selectShapes: L, toggleShapeVisibility: s, toggleShapeLock: l, isLayoutPanelShown: ae, settings: z }), Te && U(nt, { alignment: "left", className: "react-paint-editor-layouts-panel", "data-edit": +Z, children: [m(J, { className: "react-paint-editor-zoom-button", icon: '<svg viewBox="0 -960 960 960" width="24px"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400ZM280-540v-80h200v80H280Z"/></svg>', onClick: () => y("unzoom") }), U(J, { className: "react-paint-editor-zoom-button react-paint-editor-zoom-button-value", onClick: () => y("default"), children: [Math.round(100 * z.canvasZoom), "%"] }), m(J, { className: "react-paint-editor-zoom-button", icon: An, onClick: () => y("zoom") })] }), Z && U(Ae, { children: [m(es, { saveShapes: C, setCanvasZoom: y, width: z.canvasSize.width, activeTool: D, availableTools: A, selectedShape: v, settings: z, removeShape: f, updateShape: g, canvas: b.canvas.current, layersManipulation: T, toggleLayoutPanel: () => {
1705
- Me((ve) => !ve);
1706
- }, isZoomPanelShown: Te, setIsZoomPanelShown: re, updateToolSettings: Ft }), m(Io, { isLoading: fe }), m(Bo, { snackbarList: Ot })] })] });
1711
+ }, [d, L, De, Q, g]), Ut = `${t ? `${t} ` : ""}${ae ? "react-paint-editor-layout-opened " : ""}react-paint-editor-app`;
1712
+ return q("div", { ref: b.setEditor, className: Ut, style: { "--react-paint-editor-app-maxWidth": P ? "100%" : `${Q}px`, "--react-paint-editor-app-toolbar-bg": I, "--react-paint-editor-app-divider-color": j, "--react-paint-editor-app-font-radius": de, "--react-paint-editor-app-font-disabled-color": se, "--react-paint-editor-app-font-disabled-bg": K, "--react-paint-editor-app-font-color": N, "--react-paint-editor-app-font-bg": ge, "--react-paint-editor-app-font-selected-color": oe, "--react-paint-editor-app-font-selected-bg": ye, "--react-paint-editor-app-font-hover-color": Se, "--react-paint-editor-app-font-hover-bg": Qe, ...i }, children: [Z && m(rs, { settings: z, width: z.canvasSize.width, activeTool: D, clearCanvas: _, setActiveTool: w, exportCanvasInFile: Yt, saveFile: Ge, loadFile: Xt, addPicture: $t, hasActionToUndo: h, hasActionToRedo: c, hasActionToClear: u, undoAction: S, redoAction: C, availableTools: A, withExport: k, withLoadAndSave: O, withUploadPicture: R, withUrlPicture: B }), a, Z && T && m($o, { gridFormat: qe, setGridFormat: (fe) => {
1713
+ F(Lt[fe]);
1714
+ }, shapes: o.current, moveShapes: r, selectedShapes: f, removeShape: v, selectShapes: L, toggleShapeVisibility: s, toggleShapeLock: l, isLayoutPanelShown: ae, settings: z }), Te && q(nt, { alignment: "left", className: "react-paint-editor-layouts-panel", "data-edit": +Z, children: [m(J, { className: "react-paint-editor-zoom-button", icon: '<svg viewBox="0 -960 960 960" width="24px"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400ZM280-540v-80h200v80H280Z"/></svg>', onClick: () => y("unzoom") }), q(J, { className: "react-paint-editor-zoom-button react-paint-editor-zoom-button-value", onClick: () => y("default"), children: [Math.round(100 * z.canvasZoom), "%"] }), m(J, { className: "react-paint-editor-zoom-button", icon: Dn, onClick: () => y("zoom") })] }), Z && q(Ae, { children: [m(ts, { saveShapes: M, setCanvasZoom: y, width: z.canvasSize.width, activeTool: D, availableTools: A, selectedShape: f, settings: z, removeShape: v, updateShape: p, canvas: b.canvas.current, layersManipulation: T, toggleLayoutPanel: () => {
1715
+ Me((fe) => !fe);
1716
+ }, isZoomPanelShown: Te, setIsZoomPanelShown: re, updateToolSettings: Ft }), m(Wo, { isLoading: ve }), m(Oo, { snackbarList: Ot })] })] });
1707
1717
  };
1708
1718
  export {
1709
- us as Canvas,
1710
- ps as Editor,
1711
- hs as useReactPaint
1719
+ ps as Canvas,
1720
+ gs as Editor,
1721
+ us as useReactPaint
1712
1722
  };