@aivex/ui 1.2.0-dev.19 → 1.2.0-dev.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ShapeEditor/_constants.d.ts +6 -4
- package/dist/components/ShapeEditor/_model/geometry.d.ts +3 -3
- package/dist/shape-editor.cjs +1 -1
- package/dist/shape-editor.cjs.map +1 -1
- package/dist/shape-editor.js +914 -898
- package/dist/shape-editor.js.map +1 -1
- package/package.json +1 -1
package/dist/shape-editor.js
CHANGED
|
@@ -318,7 +318,7 @@ function De(e, t = 256) {
|
|
|
318
318
|
}
|
|
319
319
|
//#endregion
|
|
320
320
|
//#region src/components/ShapeEditor/_model/strings.ts
|
|
321
|
-
var
|
|
321
|
+
var Oe = {
|
|
322
322
|
contextMenu: {
|
|
323
323
|
copy: "복사",
|
|
324
324
|
paste: "붙여넣기",
|
|
@@ -361,27 +361,27 @@ var W = {
|
|
|
361
361
|
imageLoading: "이미지를 불러오는 중…",
|
|
362
362
|
imageLoadError: "이미지를 불러올 수 없습니다"
|
|
363
363
|
};
|
|
364
|
-
function
|
|
364
|
+
function ke(e) {
|
|
365
365
|
return e ? {
|
|
366
366
|
contextMenu: {
|
|
367
|
-
...
|
|
367
|
+
...Oe.contextMenu,
|
|
368
368
|
...e.contextMenu
|
|
369
369
|
},
|
|
370
370
|
viewSettings: {
|
|
371
|
-
...
|
|
371
|
+
...Oe.viewSettings,
|
|
372
372
|
...e.viewSettings
|
|
373
373
|
},
|
|
374
374
|
minimap: {
|
|
375
|
-
...
|
|
375
|
+
...Oe.minimap,
|
|
376
376
|
...e.minimap
|
|
377
377
|
},
|
|
378
|
-
imageLoading: e.imageLoading ??
|
|
379
|
-
imageLoadError: e.imageLoadError ??
|
|
380
|
-
} :
|
|
378
|
+
imageLoading: e.imageLoading ?? Oe.imageLoading,
|
|
379
|
+
imageLoadError: e.imageLoadError ?? Oe.imageLoadError
|
|
380
|
+
} : Oe;
|
|
381
381
|
}
|
|
382
382
|
//#endregion
|
|
383
383
|
//#region src/components/ShapeEditor/_model/tools.ts
|
|
384
|
-
var
|
|
384
|
+
var W = {
|
|
385
385
|
SELECT: "SELECT",
|
|
386
386
|
POLYGON: "POLYGON",
|
|
387
387
|
PATH: "PATH",
|
|
@@ -393,7 +393,7 @@ var G = {
|
|
|
393
393
|
ASSISTANT_POLYGON: "ASSISTANT_POLYGON",
|
|
394
394
|
ASSISTANT_RECT: "ASSISTANT_RECT",
|
|
395
395
|
ASSISTANT_POINT: "ASSISTANT_POINT"
|
|
396
|
-
},
|
|
396
|
+
}, Ae = {
|
|
397
397
|
brightness: 1,
|
|
398
398
|
contrast: 1,
|
|
399
399
|
showCursorGuide: !1,
|
|
@@ -405,9 +405,9 @@ var G = {
|
|
|
405
405
|
keepZoomOnImageChange: !1,
|
|
406
406
|
wheelZoom: !0,
|
|
407
407
|
zoomSensitivity: 1
|
|
408
|
-
},
|
|
409
|
-
function
|
|
410
|
-
let t = e.positive ?
|
|
408
|
+
}, G = "var(--editor-overlay-inverse-scale, 1)", je = "#377be2", Me = "#e23c3c";
|
|
409
|
+
function Ne({ point: e }) {
|
|
410
|
+
let t = e.positive ? je : Me;
|
|
411
411
|
return /* @__PURE__ */ O("div", {
|
|
412
412
|
style: {
|
|
413
413
|
position: "absolute",
|
|
@@ -428,13 +428,13 @@ function Me({ point: e }) {
|
|
|
428
428
|
display: "flex",
|
|
429
429
|
alignItems: "center",
|
|
430
430
|
justifyContent: "center",
|
|
431
|
-
transform: `scale(${
|
|
431
|
+
transform: `scale(${G})`,
|
|
432
432
|
transformOrigin: "center"
|
|
433
433
|
},
|
|
434
434
|
children: e.positive ? "+" : "−"
|
|
435
435
|
});
|
|
436
436
|
}
|
|
437
|
-
function
|
|
437
|
+
function Pe({ image: e, points: t, boxes: n, status: r }) {
|
|
438
438
|
return /* @__PURE__ */ k("div", {
|
|
439
439
|
style: {
|
|
440
440
|
position: "absolute",
|
|
@@ -458,13 +458,13 @@ function Ne({ image: e, points: t, boxes: n, status: r }) {
|
|
|
458
458
|
backgroundSize: "200% 100%",
|
|
459
459
|
animation: "editorv2-assistant-shimmer 1.4s linear infinite"
|
|
460
460
|
} }, `box-${t}-${e.x}-${e.y}-${e.width}-${e.height}`)),
|
|
461
|
-
r === "loading" && t.map((e, t) => /* @__PURE__ */ O(
|
|
461
|
+
r === "loading" && t.map((e, t) => /* @__PURE__ */ O(Ne, { point: e }, `pt-${t}-${e.x}-${e.y}`))
|
|
462
462
|
]
|
|
463
463
|
});
|
|
464
464
|
}
|
|
465
465
|
//#endregion
|
|
466
466
|
//#region src/components/ShapeEditor/_components/ContextMenu.tsx
|
|
467
|
-
function
|
|
467
|
+
function K(e) {
|
|
468
468
|
let t = [];
|
|
469
469
|
for (let n of e) if ("separator" in n) {
|
|
470
470
|
if (!t.length || "separator" in t[t.length - 1]) continue;
|
|
@@ -473,8 +473,8 @@ function q(e) {
|
|
|
473
473
|
for (; t.length && "separator" in t[t.length - 1];) t.pop();
|
|
474
474
|
return t;
|
|
475
475
|
}
|
|
476
|
-
function
|
|
477
|
-
let i =
|
|
476
|
+
function Fe({ x: e, y: t, items: n, onClose: r }) {
|
|
477
|
+
let i = K(n);
|
|
478
478
|
return /* @__PURE__ */ k(m, {
|
|
479
479
|
open: !0,
|
|
480
480
|
modal: !1,
|
|
@@ -525,7 +525,7 @@ function Pe({ x: e, y: t, items: n, onClose: r }) {
|
|
|
525
525
|
}
|
|
526
526
|
//#endregion
|
|
527
527
|
//#region src/components/ShapeEditor/_components/CursorGuide.tsx
|
|
528
|
-
function
|
|
528
|
+
function Ie({ color: e = "#1e88e5" }) {
|
|
529
529
|
let t = T(null), n = T(null), r = T(null);
|
|
530
530
|
return y(() => {
|
|
531
531
|
let e = t.current, i = n.current, a = r.current;
|
|
@@ -575,7 +575,7 @@ function Fe({ color: e = "#1e88e5" }) {
|
|
|
575
575
|
}
|
|
576
576
|
//#endregion
|
|
577
577
|
//#region src/components/ShapeEditor/_components/ImageStateOverlay.tsx
|
|
578
|
-
function
|
|
578
|
+
function Le({ status: e, render: t, loadingLabel: n = Oe.imageLoading, errorLabel: r = Oe.imageLoadError }) {
|
|
579
579
|
return /* @__PURE__ */ O("div", {
|
|
580
580
|
"data-track-id": e === "loading" ? "editor-image-loading-wrap" : "editor-image-error-wrap",
|
|
581
581
|
style: {
|
|
@@ -628,22 +628,22 @@ function Ie({ status: e, render: t, loadingLabel: n = W.imageLoading, errorLabel
|
|
|
628
628
|
});
|
|
629
629
|
}
|
|
630
630
|
Math.PI / 12;
|
|
631
|
-
var
|
|
631
|
+
var Re = "#00ff00", ze = "rgba(0, 255, 0, 0.1)", Be = "#669DEF", Ve = .1, He = [3, 3];
|
|
632
632
|
//#endregion
|
|
633
633
|
//#region src/components/ShapeEditor/_model/shapeRenderStyle.ts
|
|
634
|
-
function
|
|
635
|
-
let n = e.style?.color ?? "#00e5ff", r =
|
|
634
|
+
function Ue(e, t = {}) {
|
|
635
|
+
let n = e.style?.color ?? "#00e5ff", r = e.style?.strokeWidth ?? t.strokeWidth ?? 2, i = e.style?.opacity ?? 1, a = e.style?.fillOpacity ?? .12549019607843137, o = e.style?.dash ?? (e.style?.dashed ? [r * He[0], r * He[1]] : void 0);
|
|
636
636
|
return {
|
|
637
637
|
color: n,
|
|
638
|
-
strokeWidth:
|
|
639
|
-
opacity:
|
|
640
|
-
fillAlpha:
|
|
638
|
+
strokeWidth: r,
|
|
639
|
+
opacity: i,
|
|
640
|
+
fillAlpha: a,
|
|
641
641
|
fillVisible: !!e.style?.filled,
|
|
642
|
-
dash:
|
|
642
|
+
dash: o,
|
|
643
643
|
pointRadius: e.style?.pointRadius ?? t.pointRadius ?? 5
|
|
644
644
|
};
|
|
645
645
|
}
|
|
646
|
-
function
|
|
646
|
+
function We(e, t) {
|
|
647
647
|
let n = Math.max(0, Math.min(1, t)), r = e.trim().replace("#", "");
|
|
648
648
|
if (r.length === 3 || r.length === 6) {
|
|
649
649
|
let e = r.length === 3 ? r.replace(/./g, (e) => e + e) : r, t = Number.parseInt(e, 16);
|
|
@@ -653,8 +653,8 @@ function Ge(e, t) {
|
|
|
653
653
|
}
|
|
654
654
|
//#endregion
|
|
655
655
|
//#region src/components/ShapeEditor/_components/MinimapShape.tsx
|
|
656
|
-
var
|
|
657
|
-
let { type: r, points: i } = e, a =
|
|
656
|
+
var Ge = _(function({ shape: e, strokeSize: t, register: n }) {
|
|
657
|
+
let { type: r, points: i } = e, a = Ue(e, { strokeWidth: t }), o = (t) => n?.(e.id, t), s = {
|
|
658
658
|
ref: o,
|
|
659
659
|
stroke: a.color,
|
|
660
660
|
strokeWidth: a.strokeWidth,
|
|
@@ -699,7 +699,7 @@ var Ke = _(function({ shape: e, strokeSize: t, register: n }) {
|
|
|
699
699
|
});
|
|
700
700
|
//#endregion
|
|
701
701
|
//#region src/components/ShapeEditor/_components/RegionOverlay.tsx
|
|
702
|
-
function
|
|
702
|
+
function Ke({ image: e, region: t, maskId: n, width: r, height: i, strokeWidth: a, strokeDasharray: o, style: s }) {
|
|
703
703
|
let c = [...t.visibleOutline, ...t.occludedOutline];
|
|
704
704
|
return /* @__PURE__ */ k("svg", {
|
|
705
705
|
width: r,
|
|
@@ -753,7 +753,7 @@ function qe({ image: e, region: t, maskId: n, width: r, height: i, strokeWidth:
|
|
|
753
753
|
}
|
|
754
754
|
//#endregion
|
|
755
755
|
//#region src/components/ShapeEditor/_components/SettingsPanel.tsx
|
|
756
|
-
function
|
|
756
|
+
function qe({ value: i, defaults: o, onChange: s, onClose: c, labels: d = Oe.viewSettings }) {
|
|
757
757
|
return y(() => {
|
|
758
758
|
let e = (e) => {
|
|
759
759
|
e.key === "Escape" && c();
|
|
@@ -772,7 +772,7 @@ function Je({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
|
|
|
772
772
|
/* @__PURE__ */ k("div", {
|
|
773
773
|
className: "aivex:flex aivex:flex-col aivex:gap-md",
|
|
774
774
|
children: [
|
|
775
|
-
/* @__PURE__ */ O(
|
|
775
|
+
/* @__PURE__ */ O(Je, {
|
|
776
776
|
icon: /* @__PURE__ */ O(r, { size: 16 }),
|
|
777
777
|
label: d.brightness,
|
|
778
778
|
value: i.brightness.toFixed(2),
|
|
@@ -784,7 +784,7 @@ function Je({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
|
|
|
784
784
|
onValueChange: ([e]) => s({ brightness: e })
|
|
785
785
|
})
|
|
786
786
|
}),
|
|
787
|
-
/* @__PURE__ */ O(
|
|
787
|
+
/* @__PURE__ */ O(Je, {
|
|
788
788
|
icon: /* @__PURE__ */ O(n, { size: 16 }),
|
|
789
789
|
label: d.contrast,
|
|
790
790
|
value: i.contrast.toFixed(2),
|
|
@@ -796,7 +796,7 @@ function Je({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
|
|
|
796
796
|
onValueChange: ([e]) => s({ contrast: e })
|
|
797
797
|
})
|
|
798
798
|
}),
|
|
799
|
-
/* @__PURE__ */ O(
|
|
799
|
+
/* @__PURE__ */ O(Je, {
|
|
800
800
|
icon: /* @__PURE__ */ O(t, { size: 16 }),
|
|
801
801
|
label: d.strokeSize,
|
|
802
802
|
value: String(i.strokeSize),
|
|
@@ -808,7 +808,7 @@ function Je({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
|
|
|
808
808
|
onValueChange: ([e]) => s({ strokeSize: e })
|
|
809
809
|
})
|
|
810
810
|
}),
|
|
811
|
-
/* @__PURE__ */ O(
|
|
811
|
+
/* @__PURE__ */ O(Je, {
|
|
812
812
|
icon: /* @__PURE__ */ O(e, { size: 16 }),
|
|
813
813
|
label: d.simplifyStrength,
|
|
814
814
|
value: String(i.simplifyStrength),
|
|
@@ -820,7 +820,7 @@ function Je({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
|
|
|
820
820
|
onValueChange: ([e]) => s({ simplifyStrength: e })
|
|
821
821
|
})
|
|
822
822
|
}),
|
|
823
|
-
/* @__PURE__ */ O(
|
|
823
|
+
/* @__PURE__ */ O(Je, {
|
|
824
824
|
icon: /* @__PURE__ */ O(l, { size: 16 }),
|
|
825
825
|
label: d.zoomSensitivity,
|
|
826
826
|
value: i.zoomSensitivity.toFixed(1),
|
|
@@ -835,32 +835,32 @@ function Je({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
|
|
|
835
835
|
/* @__PURE__ */ k("div", {
|
|
836
836
|
className: "aivex:flex aivex:flex-col aivex:gap-xs",
|
|
837
837
|
children: [
|
|
838
|
-
/* @__PURE__ */ O(
|
|
838
|
+
/* @__PURE__ */ O(Ye, {
|
|
839
839
|
label: d.pixelation,
|
|
840
840
|
checked: !i.imageSmoothing,
|
|
841
841
|
onChange: (e) => s({ imageSmoothing: !e })
|
|
842
842
|
}),
|
|
843
|
-
/* @__PURE__ */ O(
|
|
843
|
+
/* @__PURE__ */ O(Ye, {
|
|
844
844
|
label: d.cursorGuide,
|
|
845
845
|
checked: i.showCursorGuide,
|
|
846
846
|
onChange: (e) => s({ showCursorGuide: e })
|
|
847
847
|
}),
|
|
848
|
-
/* @__PURE__ */ O(
|
|
848
|
+
/* @__PURE__ */ O(Ye, {
|
|
849
849
|
label: d.guideMask,
|
|
850
850
|
checked: i.showGuide,
|
|
851
851
|
onChange: (e) => s({ showGuide: e })
|
|
852
852
|
}),
|
|
853
|
-
/* @__PURE__ */ O(
|
|
853
|
+
/* @__PURE__ */ O(Ye, {
|
|
854
854
|
label: d.regionMask,
|
|
855
855
|
checked: i.showRegionMask,
|
|
856
856
|
onChange: (e) => s({ showRegionMask: e })
|
|
857
857
|
}),
|
|
858
|
-
/* @__PURE__ */ O(
|
|
858
|
+
/* @__PURE__ */ O(Ye, {
|
|
859
859
|
label: d.keepZoomOnImageChange,
|
|
860
860
|
checked: i.keepZoomOnImageChange,
|
|
861
861
|
onChange: (e) => s({ keepZoomOnImageChange: e })
|
|
862
862
|
}),
|
|
863
|
-
/* @__PURE__ */ O(
|
|
863
|
+
/* @__PURE__ */ O(Ye, {
|
|
864
864
|
label: d.wheelZoom,
|
|
865
865
|
checked: i.wheelZoom,
|
|
866
866
|
onChange: (e) => s({ wheelZoom: e })
|
|
@@ -883,7 +883,7 @@ function Je({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
|
|
|
883
883
|
]
|
|
884
884
|
});
|
|
885
885
|
}
|
|
886
|
-
function
|
|
886
|
+
function Je({ icon: e, label: t, value: n, children: r }) {
|
|
887
887
|
return /* @__PURE__ */ k("div", {
|
|
888
888
|
className: "aivex:flex aivex:flex-col aivex:px-md aivex:py-2xs",
|
|
889
889
|
children: [/* @__PURE__ */ k("div", {
|
|
@@ -908,7 +908,7 @@ function Ye({ icon: e, label: t, value: n, children: r }) {
|
|
|
908
908
|
})]
|
|
909
909
|
});
|
|
910
910
|
}
|
|
911
|
-
function
|
|
911
|
+
function Ye({ label: e, checked: t, onChange: n }) {
|
|
912
912
|
return /* @__PURE__ */ k("div", {
|
|
913
913
|
className: "aivex:flex aivex:items-center aivex:gap-md aivex:rounded-md aivex:px-md aivex:py-sm",
|
|
914
914
|
children: [/* @__PURE__ */ O("span", {
|
|
@@ -923,7 +923,7 @@ function Xe({ label: e, checked: t, onChange: n }) {
|
|
|
923
923
|
}
|
|
924
924
|
//#endregion
|
|
925
925
|
//#region src/components/ShapeEditor/_components/Minimap.tsx
|
|
926
|
-
var
|
|
926
|
+
var Xe = _(function({ image: e, imageUrl: t, imageVisible: n = !0, loading: r = !1, maskDataUrl: a, region: o, roiMaskId: l, shapes: p, view: m, viewDefaults: h, onChangeView: g, nav: _, registerShape: v, rectRef: y, zoomLabelRef: b, onZoom100: x, open: S, onToggleOpen: C, showSettings: w = !0, settingsOpen: T, onToggleSettings: E, onCloseSettings: D, labels: A = Oe.minimap, settingsLabels: j }) {
|
|
927
927
|
let { offX: M, offY: N, dispW: P, dispH: ee, zoomCentered: te } = _, ne = {
|
|
928
928
|
position: "absolute",
|
|
929
929
|
left: M,
|
|
@@ -973,7 +973,7 @@ var Ze = _(function({ image: e, imageUrl: t, imageVisible: n = !0, loading: r =
|
|
|
973
973
|
pointerEvents: "none"
|
|
974
974
|
}
|
|
975
975
|
}),
|
|
976
|
-
m.showRegionMask && o && o.rects.length > 0 && /* @__PURE__ */ O(
|
|
976
|
+
m.showRegionMask && o && o.rects.length > 0 && /* @__PURE__ */ O(Ke, {
|
|
977
977
|
image: e,
|
|
978
978
|
region: o,
|
|
979
979
|
maskId: l,
|
|
@@ -999,7 +999,7 @@ var Ze = _(function({ image: e, imageUrl: t, imageVisible: n = !0, loading: r =
|
|
|
999
999
|
pointerEvents: "none"
|
|
1000
1000
|
},
|
|
1001
1001
|
"aria-hidden": !0,
|
|
1002
|
-
children: R(p).filter(ie).map((e) => /* @__PURE__ */ O(
|
|
1002
|
+
children: R(p).filter(ie).map((e) => /* @__PURE__ */ O(Ge, {
|
|
1003
1003
|
shape: e,
|
|
1004
1004
|
strokeSize: m.strokeSize,
|
|
1005
1005
|
register: v
|
|
@@ -1009,8 +1009,8 @@ var Ze = _(function({ image: e, imageUrl: t, imageVisible: n = !0, loading: r =
|
|
|
1009
1009
|
ref: y,
|
|
1010
1010
|
style: {
|
|
1011
1011
|
position: "absolute",
|
|
1012
|
-
border: `1px solid ${
|
|
1013
|
-
background:
|
|
1012
|
+
border: `1px solid ${Re}`,
|
|
1013
|
+
background: ze,
|
|
1014
1014
|
boxSizing: "border-box",
|
|
1015
1015
|
pointerEvents: "none"
|
|
1016
1016
|
}
|
|
@@ -1059,7 +1059,7 @@ var Ze = _(function({ image: e, imageUrl: t, imageVisible: n = !0, loading: r =
|
|
|
1059
1059
|
onPointerDown: (e) => e.stopPropagation(),
|
|
1060
1060
|
className: T ? "aivex:text-text-brand" : void 0,
|
|
1061
1061
|
children: /* @__PURE__ */ O(d, { size: 20 })
|
|
1062
|
-
}), T && /* @__PURE__ */ O(
|
|
1062
|
+
}), T && /* @__PURE__ */ O(qe, {
|
|
1063
1063
|
value: m,
|
|
1064
1064
|
defaults: h,
|
|
1065
1065
|
onChange: g,
|
|
@@ -1078,7 +1078,7 @@ var Ze = _(function({ image: e, imageUrl: t, imageVisible: n = !0, loading: r =
|
|
|
1078
1078
|
]
|
|
1079
1079
|
})]
|
|
1080
1080
|
});
|
|
1081
|
-
}),
|
|
1081
|
+
}), Ze = "var(--editor-overlay-inverse-scale, 1)", Qe = 6, $e = {
|
|
1082
1082
|
fontFamily: "Pretendard, sans-serif",
|
|
1083
1083
|
fontSize: 12,
|
|
1084
1084
|
fontWeight: 500,
|
|
@@ -1087,7 +1087,7 @@ var Ze = _(function({ image: e, imageUrl: t, imageVisible: n = !0, loading: r =
|
|
|
1087
1087
|
textShadow: "0 0 4px #000, 0 0 4px #000",
|
|
1088
1088
|
whiteSpace: "nowrap"
|
|
1089
1089
|
};
|
|
1090
|
-
function
|
|
1090
|
+
function et(e) {
|
|
1091
1091
|
let t = B(e);
|
|
1092
1092
|
return {
|
|
1093
1093
|
x: t.minX,
|
|
@@ -1096,19 +1096,19 @@ function tt(e) {
|
|
|
1096
1096
|
height: t.maxY - t.minY
|
|
1097
1097
|
};
|
|
1098
1098
|
}
|
|
1099
|
-
function
|
|
1100
|
-
return `translate3d(${e.width}px, ${e.height}px, 0) scale(${
|
|
1099
|
+
function tt(e) {
|
|
1100
|
+
return `translate3d(${e.width}px, ${e.height}px, 0) scale(${Ze}) translate(-100%, ${Qe}px)`;
|
|
1101
1101
|
}
|
|
1102
1102
|
function nt(e, t) {
|
|
1103
|
-
let n =
|
|
1103
|
+
let n = et(t);
|
|
1104
1104
|
e.style.transform = `translate3d(${n.x}px, ${n.y}px, 0)`;
|
|
1105
1105
|
let r = e.querySelector("[data-selinfo-dim]");
|
|
1106
|
-
return r && (r.style.transform =
|
|
1106
|
+
return r && (r.style.transform = tt(n)), r;
|
|
1107
1107
|
}
|
|
1108
1108
|
function rt(e, t) {
|
|
1109
1109
|
return {
|
|
1110
1110
|
shape: e,
|
|
1111
|
-
...
|
|
1111
|
+
...et(t)
|
|
1112
1112
|
};
|
|
1113
1113
|
}
|
|
1114
1114
|
function it(e) {
|
|
@@ -1128,7 +1128,7 @@ function at({ color: e, striped: t }) {
|
|
|
1128
1128
|
}
|
|
1129
1129
|
function ot({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i }) {
|
|
1130
1130
|
return /* @__PURE__ */ O(D, { children: e.map((e) => {
|
|
1131
|
-
let a =
|
|
1131
|
+
let a = et(e.points), o = e.type === F.POINT, s = o ? void 0 : t?.(e), c = e.style?.color ?? "#00e5ff", l = !!e.style?.dashed || !!e.style?.dash, u = rt(e, e.points), d = r ? r(u) : it(u);
|
|
1132
1132
|
return /* @__PURE__ */ k("div", {
|
|
1133
1133
|
ref: (t) => i(e.id, t),
|
|
1134
1134
|
style: {
|
|
@@ -1147,9 +1147,9 @@ function ot({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1147
1147
|
display: "flex",
|
|
1148
1148
|
alignItems: "center",
|
|
1149
1149
|
gap: 4,
|
|
1150
|
-
transform: `scale(${
|
|
1150
|
+
transform: `scale(${Ze}) translateY(calc(-100% - ${Qe}px))`,
|
|
1151
1151
|
transformOrigin: "left top",
|
|
1152
|
-
|
|
1152
|
+
...$e
|
|
1153
1153
|
},
|
|
1154
1154
|
children: [!n && /* @__PURE__ */ O(at, {
|
|
1155
1155
|
color: c,
|
|
@@ -1161,10 +1161,10 @@ function ot({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1161
1161
|
position: "absolute",
|
|
1162
1162
|
left: 0,
|
|
1163
1163
|
top: 0,
|
|
1164
|
-
transform:
|
|
1164
|
+
transform: tt(a),
|
|
1165
1165
|
transformOrigin: "left top",
|
|
1166
1166
|
willChange: "transform",
|
|
1167
|
-
|
|
1167
|
+
...$e
|
|
1168
1168
|
},
|
|
1169
1169
|
children: d
|
|
1170
1170
|
})]
|
|
@@ -1173,21 +1173,21 @@ function ot({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1173
1173
|
}
|
|
1174
1174
|
//#endregion
|
|
1175
1175
|
//#region src/components/ShapeEditor/_model/clipboard.ts
|
|
1176
|
-
var
|
|
1177
|
-
function
|
|
1176
|
+
var q = "AIVEX_SHAPE_EDITOR:", st = 1, ct = new Set(Object.values(F)), J = null, lt = "unavailable", ut = 0;
|
|
1177
|
+
function dt(e) {
|
|
1178
1178
|
if (!e || typeof e != "object") return !1;
|
|
1179
1179
|
let t = e;
|
|
1180
1180
|
return Number.isFinite(t.x) && Number.isFinite(t.y);
|
|
1181
1181
|
}
|
|
1182
|
-
function
|
|
1182
|
+
function ft(e) {
|
|
1183
1183
|
if (!e || typeof e != "object") return !1;
|
|
1184
1184
|
let t = e;
|
|
1185
|
-
return typeof t.type == "string" && ct.has(t.type) && Array.isArray(t.points) && t.points.length > 0 && t.points.every(
|
|
1185
|
+
return typeof t.type == "string" && ct.has(t.type) && Array.isArray(t.points) && t.points.length > 0 && t.points.every(dt);
|
|
1186
1186
|
}
|
|
1187
|
-
function
|
|
1187
|
+
function pt(e, t, n) {
|
|
1188
1188
|
return {
|
|
1189
1189
|
kind: "aivex-shape-editor",
|
|
1190
|
-
version:
|
|
1190
|
+
version: st,
|
|
1191
1191
|
scope: n,
|
|
1192
1192
|
documentId: t,
|
|
1193
1193
|
shapes: e
|
|
@@ -1199,53 +1199,53 @@ function mt(e) {
|
|
|
1199
1199
|
return `fnv1a:${(t >>> 0).toString(36)}`;
|
|
1200
1200
|
}
|
|
1201
1201
|
function ht(e) {
|
|
1202
|
-
return `${
|
|
1202
|
+
return `${q}${JSON.stringify(e)}`;
|
|
1203
1203
|
}
|
|
1204
|
-
function
|
|
1205
|
-
if (!e.startsWith(
|
|
1204
|
+
function Y(e) {
|
|
1205
|
+
if (!e.startsWith(q)) return null;
|
|
1206
1206
|
try {
|
|
1207
1207
|
let t = JSON.parse(e.slice(19));
|
|
1208
|
-
return t.kind !== "aivex-shape-editor" || t.version !==
|
|
1208
|
+
return t.kind !== "aivex-shape-editor" || t.version !== st || !Array.isArray(t.shapes) || t.shapes.length === 0 || !t.shapes.every(ft) || t.scope !== void 0 && typeof t.scope != "string" || t.documentId !== void 0 && typeof t.documentId != "string" ? null : t;
|
|
1209
1209
|
} catch {
|
|
1210
1210
|
return null;
|
|
1211
1211
|
}
|
|
1212
1212
|
}
|
|
1213
|
-
function
|
|
1214
|
-
|
|
1215
|
-
let t = ++
|
|
1213
|
+
function gt(e) {
|
|
1214
|
+
J = e;
|
|
1215
|
+
let t = ++ut;
|
|
1216
1216
|
if (typeof navigator > "u" || !navigator.clipboard?.writeText) {
|
|
1217
|
-
|
|
1217
|
+
lt = "unavailable";
|
|
1218
1218
|
return;
|
|
1219
1219
|
}
|
|
1220
1220
|
let n;
|
|
1221
1221
|
try {
|
|
1222
1222
|
n = ht(e);
|
|
1223
1223
|
} catch {
|
|
1224
|
-
|
|
1224
|
+
lt = "unavailable";
|
|
1225
1225
|
return;
|
|
1226
1226
|
}
|
|
1227
|
-
|
|
1228
|
-
t ===
|
|
1227
|
+
lt = "pending", navigator.clipboard.writeText(n).then(() => {
|
|
1228
|
+
t === ut && (lt = "written");
|
|
1229
1229
|
}, () => {
|
|
1230
|
-
t ===
|
|
1230
|
+
t === ut && (lt = "unavailable");
|
|
1231
1231
|
});
|
|
1232
1232
|
}
|
|
1233
1233
|
function _t(e, t) {
|
|
1234
1234
|
return !!e && e.scope === t;
|
|
1235
1235
|
}
|
|
1236
|
-
function
|
|
1237
|
-
return _t(
|
|
1236
|
+
function X(e) {
|
|
1237
|
+
return _t(J, e) || typeof navigator < "u" && typeof navigator.clipboard?.readText == "function";
|
|
1238
1238
|
}
|
|
1239
|
-
async function
|
|
1240
|
-
let t = _t(
|
|
1241
|
-
if (t &&
|
|
1239
|
+
async function vt(e) {
|
|
1240
|
+
let t = _t(J, e) ? J : null;
|
|
1241
|
+
if (t && lt !== "written") return t;
|
|
1242
1242
|
if (typeof navigator < "u" && navigator.clipboard?.readText) try {
|
|
1243
|
-
let t =
|
|
1244
|
-
return t?.scope === e ? (
|
|
1243
|
+
let t = Y(await navigator.clipboard.readText());
|
|
1244
|
+
return t?.scope === e ? (J = t, t) : null;
|
|
1245
1245
|
} catch {}
|
|
1246
1246
|
return t;
|
|
1247
1247
|
}
|
|
1248
|
-
function
|
|
1248
|
+
function yt(e, t, n) {
|
|
1249
1249
|
return {
|
|
1250
1250
|
offset: n * (t ? e : e + 1),
|
|
1251
1251
|
nextPasteCount: e + 1
|
|
@@ -1253,18 +1253,18 @@ function bt(e, t, n) {
|
|
|
1253
1253
|
}
|
|
1254
1254
|
//#endregion
|
|
1255
1255
|
//#region src/components/ShapeEditor/_model/cursors.ts
|
|
1256
|
-
var
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
]),
|
|
1256
|
+
var bt = new Set([
|
|
1257
|
+
W.RECTANGLE,
|
|
1258
|
+
W.ROTATED_RECTANGLE,
|
|
1259
|
+
W.CIRCLE,
|
|
1260
|
+
W.POLYGON,
|
|
1261
|
+
W.PATH,
|
|
1262
|
+
W.BRUSH,
|
|
1263
|
+
W.POINT,
|
|
1264
|
+
W.ASSISTANT_POLYGON,
|
|
1265
|
+
W.ASSISTANT_RECT,
|
|
1266
|
+
W.ASSISTANT_POINT
|
|
1267
|
+
]), xt = {
|
|
1268
1268
|
tl: -135,
|
|
1269
1269
|
t: -90,
|
|
1270
1270
|
tr: -45,
|
|
@@ -1273,21 +1273,21 @@ var xt = new Set([
|
|
|
1273
1273
|
b: 90,
|
|
1274
1274
|
bl: 135,
|
|
1275
1275
|
l: 180
|
|
1276
|
-
},
|
|
1276
|
+
}, St = [
|
|
1277
1277
|
"ew-resize",
|
|
1278
1278
|
"nwse-resize",
|
|
1279
1279
|
"ns-resize",
|
|
1280
1280
|
"nesw-resize"
|
|
1281
1281
|
];
|
|
1282
|
-
function
|
|
1283
|
-
let n = ((
|
|
1284
|
-
return
|
|
1282
|
+
function Ct(e, t = 0) {
|
|
1283
|
+
let n = ((xt[e] + t * 180 / Math.PI) % 180 + 180) % 180;
|
|
1284
|
+
return St[Math.round(n / 45) % 4];
|
|
1285
1285
|
}
|
|
1286
|
-
function
|
|
1287
|
-
return n ? "grab" : t || (e ===
|
|
1286
|
+
function wt({ tool: e, externalToolCursor: t, isSpacePressed: n, isPolygonDrawing: r }) {
|
|
1287
|
+
return n ? "grab" : t || (e === W.SELECT ? "default" : bt.has(e) ? r ? "default" : "crosshair" : "default");
|
|
1288
1288
|
}
|
|
1289
|
-
function
|
|
1290
|
-
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e ===
|
|
1289
|
+
function Tt({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode: r, rendererCursorHint: i, isPolygonDrawing: a }) {
|
|
1290
|
+
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e === W.SELECT && i ? i : wt({
|
|
1291
1291
|
tool: e,
|
|
1292
1292
|
externalToolCursor: t,
|
|
1293
1293
|
isSpacePressed: n,
|
|
@@ -1296,7 +1296,7 @@ function Et({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode
|
|
|
1296
1296
|
}
|
|
1297
1297
|
//#endregion
|
|
1298
1298
|
//#region src/components/ShapeEditor/_model/overlays.ts
|
|
1299
|
-
var
|
|
1299
|
+
var Et = (e) => Math.min(255, Math.max(0, e)), Dt = (e) => {
|
|
1300
1300
|
let t = e.replace("#", "").trim();
|
|
1301
1301
|
if (![
|
|
1302
1302
|
3,
|
|
@@ -1310,13 +1310,13 @@ var Dt = (e) => Math.min(255, Math.max(0, e)), Ot = (e) => {
|
|
|
1310
1310
|
c(o),
|
|
1311
1311
|
c(s)
|
|
1312
1312
|
];
|
|
1313
|
-
return l.some((e) => Number.isNaN(e)) ? null : l.map(
|
|
1314
|
-
},
|
|
1313
|
+
return l.some((e) => Number.isNaN(e)) ? null : l.map(Et);
|
|
1314
|
+
}, Ot = (e, t) => {
|
|
1315
1315
|
let { width: n, height: r, indices: i, transparent: a } = e;
|
|
1316
1316
|
if (!n || !r || i.length < n * r) return null;
|
|
1317
1317
|
let o = {};
|
|
1318
1318
|
for (let [e, n] of Object.entries(t)) {
|
|
1319
|
-
let t =
|
|
1319
|
+
let t = Dt(n);
|
|
1320
1320
|
t && (o[Number(e)] = t);
|
|
1321
1321
|
}
|
|
1322
1322
|
if (!Object.keys(o).length) return null;
|
|
@@ -1335,12 +1335,12 @@ var Dt = (e) => Math.min(255, Math.max(0, e)), Ot = (e) => {
|
|
|
1335
1335
|
}
|
|
1336
1336
|
return c.putImageData(new ImageData(l, n, r), 0, 0), s;
|
|
1337
1337
|
};
|
|
1338
|
-
function
|
|
1338
|
+
function kt(e, t) {
|
|
1339
1339
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
1340
1340
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
1341
1341
|
e.closePath();
|
|
1342
1342
|
}
|
|
1343
|
-
var
|
|
1343
|
+
var At = (e) => [
|
|
1344
1344
|
{
|
|
1345
1345
|
x: e.x,
|
|
1346
1346
|
y: e.y
|
|
@@ -1358,7 +1358,7 @@ var jt = (e) => [
|
|
|
1358
1358
|
y: e.y + e.h
|
|
1359
1359
|
}
|
|
1360
1360
|
];
|
|
1361
|
-
function
|
|
1361
|
+
function jt(e, t) {
|
|
1362
1362
|
let n = !1;
|
|
1363
1363
|
for (let r = 0, i = t.length - 1; r < t.length; i = r, r += 1) {
|
|
1364
1364
|
let a = t[r], o = t[i];
|
|
@@ -1369,7 +1369,7 @@ function Mt(e, t) {
|
|
|
1369
1369
|
}
|
|
1370
1370
|
return n;
|
|
1371
1371
|
}
|
|
1372
|
-
function
|
|
1372
|
+
function Mt(e, t, n) {
|
|
1373
1373
|
let r = [], i = t.x - e.x, a = t.y - e.y;
|
|
1374
1374
|
for (let t = 0; t < n.length; t += 1) {
|
|
1375
1375
|
let o = n[t], s = n[(t + 1) % n.length], c = s.x - o.x, l = s.y - o.y, u = i * l - a * c;
|
|
@@ -1379,15 +1379,15 @@ function Nt(e, t, n) {
|
|
|
1379
1379
|
}
|
|
1380
1380
|
return r;
|
|
1381
1381
|
}
|
|
1382
|
-
function
|
|
1382
|
+
function Nt(e, t, n) {
|
|
1383
1383
|
let r = .001, i = [], a = (e, t, n) => ({
|
|
1384
1384
|
x: e.x + (t.x - e.x) * n,
|
|
1385
1385
|
y: e.y + (t.y - e.y) * n
|
|
1386
1386
|
});
|
|
1387
1387
|
for (let o of e) if (!(o.length < 2)) for (let e = 0; e < o.length; e += 1) {
|
|
1388
1388
|
let s = o[e], c = o[(e + 1) % o.length], l = [0, 1];
|
|
1389
|
-
for (let e of t) e !== o && l.push(...
|
|
1390
|
-
if (n) for (let e of n) l.push(...
|
|
1389
|
+
for (let e of t) e !== o && l.push(...Mt(s, c, e));
|
|
1390
|
+
if (n) for (let e of n) l.push(...Mt(s, c, e));
|
|
1391
1391
|
let u = Math.hypot(c.x - s.x, c.y - s.y);
|
|
1392
1392
|
if (!u) continue;
|
|
1393
1393
|
let d = -(c.y - s.y) / u * r, f = (c.x - s.x) / u * r;
|
|
@@ -1401,13 +1401,13 @@ function Pt(e, t, n) {
|
|
|
1401
1401
|
}, h = {
|
|
1402
1402
|
x: p.x - d,
|
|
1403
1403
|
y: p.y - f
|
|
1404
|
-
}, g =
|
|
1405
|
-
t.some((e) => e !== o &&
|
|
1404
|
+
}, g = jt(m, o) ? m : h, _ = g === m ? h : m;
|
|
1405
|
+
t.some((e) => e !== o && jt(_, e)) || n && !n.some((e) => jt(g, e)) || i.push([a(s, c, r), a(s, c, u)]);
|
|
1406
1406
|
}
|
|
1407
1407
|
}
|
|
1408
1408
|
return i;
|
|
1409
1409
|
}
|
|
1410
|
-
function
|
|
1410
|
+
function Pt(e) {
|
|
1411
1411
|
let t = [...new Set(e.flatMap((e) => [e.x, e.x + e.w]))].sort((e, t) => e - t), n = [];
|
|
1412
1412
|
for (let r = 0; r + 1 < t.length; r += 1) {
|
|
1413
1413
|
let i = t[r], a = t[r + 1];
|
|
@@ -1428,14 +1428,14 @@ function Ft(e) {
|
|
|
1428
1428
|
}
|
|
1429
1429
|
return n;
|
|
1430
1430
|
}
|
|
1431
|
-
function
|
|
1431
|
+
function Ft(e, t, n, r) {
|
|
1432
1432
|
e.save(), e.globalAlpha *= t.dim.opacity, e.fillStyle = t.dim.color, e.beginPath(), e.rect(0, 0, n, r);
|
|
1433
1433
|
for (let n of t.dimHoles) e.moveTo(n.x, n.y), e.lineTo(n.x, n.y + n.h), e.lineTo(n.x + n.w, n.y + n.h), e.lineTo(n.x + n.w, n.y), e.closePath();
|
|
1434
1434
|
if (e.fill(), t.zones.length) {
|
|
1435
1435
|
e.beginPath();
|
|
1436
1436
|
for (let n of t.rects) e.rect(n.x, n.y, n.w, n.h);
|
|
1437
1437
|
e.clip();
|
|
1438
|
-
for (let n of t.zones)
|
|
1438
|
+
for (let n of t.zones) kt(e, n.points), e.fill();
|
|
1439
1439
|
}
|
|
1440
1440
|
e.restore();
|
|
1441
1441
|
}
|
|
@@ -1444,22 +1444,22 @@ function It(e) {
|
|
|
1444
1444
|
for (let n of e) if (!(n.length < 2)) for (let e = 0; e < n.length; e += 1) t.push([n[e], n[(e + 1) % n.length]]);
|
|
1445
1445
|
return t;
|
|
1446
1446
|
}
|
|
1447
|
-
var
|
|
1447
|
+
var Z = {
|
|
1448
1448
|
color: "#000000",
|
|
1449
1449
|
opacity: .5
|
|
1450
|
-
},
|
|
1450
|
+
}, Lt = {
|
|
1451
1451
|
color: "#ffffff",
|
|
1452
1452
|
opacity: 1,
|
|
1453
1453
|
width: 2,
|
|
1454
1454
|
dash: [6, 6],
|
|
1455
1455
|
underlayColor: "#000000"
|
|
1456
|
-
},
|
|
1456
|
+
}, Rt = {
|
|
1457
1457
|
color: "#dc2626",
|
|
1458
1458
|
opacity: .8,
|
|
1459
1459
|
width: 2,
|
|
1460
1460
|
dash: [6, 6],
|
|
1461
1461
|
underlayColor: "#000000"
|
|
1462
|
-
},
|
|
1462
|
+
}, zt = (e, t, n) => {
|
|
1463
1463
|
let r = e.occludedAreas?.filter((e) => e.points.length >= 3) ?? [];
|
|
1464
1464
|
if (!t || !n || !e.visibleAreas.length && !r.length) return null;
|
|
1465
1465
|
let i = e.visibleAreas, a = i.length ? i : [{
|
|
@@ -1467,8 +1467,8 @@ var Lt = {
|
|
|
1467
1467
|
y: 0,
|
|
1468
1468
|
w: t,
|
|
1469
1469
|
h: n
|
|
1470
|
-
}], o =
|
|
1471
|
-
...
|
|
1470
|
+
}], o = Pt(a), s = {
|
|
1471
|
+
...Z,
|
|
1472
1472
|
...e.dim
|
|
1473
1473
|
}, c = e.outline;
|
|
1474
1474
|
if (c === !1) return {
|
|
@@ -1482,14 +1482,14 @@ var Lt = {
|
|
|
1482
1482
|
};
|
|
1483
1483
|
let l = {
|
|
1484
1484
|
visible: {
|
|
1485
|
-
...
|
|
1485
|
+
...Lt,
|
|
1486
1486
|
...c?.visibleStyle
|
|
1487
1487
|
},
|
|
1488
1488
|
occluded: {
|
|
1489
|
-
...
|
|
1489
|
+
...Rt,
|
|
1490
1490
|
...c?.occludedStyle
|
|
1491
1491
|
}
|
|
1492
|
-
}, u = i.map(
|
|
1492
|
+
}, u = i.map(At), d = a.map(At), f = r.map((e) => e.points);
|
|
1493
1493
|
return c?.mode === "separate" ? {
|
|
1494
1494
|
rects: a,
|
|
1495
1495
|
zones: r,
|
|
@@ -1503,15 +1503,15 @@ var Lt = {
|
|
|
1503
1503
|
zones: r,
|
|
1504
1504
|
dimHoles: o,
|
|
1505
1505
|
dim: s,
|
|
1506
|
-
visibleOutline: [...
|
|
1506
|
+
visibleOutline: [...Nt(u, [...u, ...f], null), ...Nt(f, f, d)],
|
|
1507
1507
|
occludedOutline: [],
|
|
1508
1508
|
outlineStyles: l
|
|
1509
1509
|
};
|
|
1510
|
-
},
|
|
1511
|
-
function
|
|
1510
|
+
}, Bt = .3, Vt = .05;
|
|
1511
|
+
function Ht(e) {
|
|
1512
1512
|
return 1 - (1 - e) ** 3;
|
|
1513
1513
|
}
|
|
1514
|
-
function
|
|
1514
|
+
function Ut(e) {
|
|
1515
1515
|
return {
|
|
1516
1516
|
x: e.minX,
|
|
1517
1517
|
y: e.minY,
|
|
@@ -1519,7 +1519,7 @@ function Wt(e) {
|
|
|
1519
1519
|
height: Math.max(0, e.maxY - e.minY)
|
|
1520
1520
|
};
|
|
1521
1521
|
}
|
|
1522
|
-
function
|
|
1522
|
+
function Wt(e, t) {
|
|
1523
1523
|
if (!t.length) return null;
|
|
1524
1524
|
if (e === F.POINT) {
|
|
1525
1525
|
let e = t[0];
|
|
@@ -1538,10 +1538,10 @@ function Gt(e, t) {
|
|
|
1538
1538
|
height: i
|
|
1539
1539
|
};
|
|
1540
1540
|
}
|
|
1541
|
-
function
|
|
1541
|
+
function Gt(e) {
|
|
1542
1542
|
if (!e.length) return null;
|
|
1543
|
-
let t = e.map((e) =>
|
|
1544
|
-
return t.length ?
|
|
1543
|
+
let t = e.map((e) => Wt(e.type, e.points)).filter((e) => e !== null);
|
|
1544
|
+
return t.length ? Ut(B(t.flatMap((e) => [{
|
|
1545
1545
|
x: e.x,
|
|
1546
1546
|
y: e.y
|
|
1547
1547
|
}, {
|
|
@@ -1549,8 +1549,8 @@ function Kt(e) {
|
|
|
1549
1549
|
y: e.y + e.height
|
|
1550
1550
|
}]))) : null;
|
|
1551
1551
|
}
|
|
1552
|
-
function
|
|
1553
|
-
let { containerRatio: i =
|
|
1552
|
+
function Kt(e, t, n, r = {}) {
|
|
1553
|
+
let { containerRatio: i = Bt, minScale: a = Vt, maxScale: o = 20 } = r;
|
|
1554
1554
|
if (!t || !n || e.width <= 0 || e.height <= 0) return null;
|
|
1555
1555
|
let s = Math.min(t * i / e.width, n * i / e.height), c = Math.max(a, Math.min(o, s)), l = e.x + e.width / 2, u = e.y + e.height / 2;
|
|
1556
1556
|
return {
|
|
@@ -1559,18 +1559,18 @@ function qt(e, t, n, r = {}) {
|
|
|
1559
1559
|
y: n / 2 - u * c
|
|
1560
1560
|
};
|
|
1561
1561
|
}
|
|
1562
|
-
function
|
|
1562
|
+
function qt(e, t, n, r = 80) {
|
|
1563
1563
|
if (!t || !n) return null;
|
|
1564
|
-
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(
|
|
1564
|
+
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(Vt, Math.min(20, Math.min((t - r) / i, (n - r) / a))), s = (e.minX + e.maxX) / 2, c = (e.minY + e.maxY) / 2;
|
|
1565
1565
|
return {
|
|
1566
1566
|
scale: o,
|
|
1567
1567
|
x: t / 2 - s * o,
|
|
1568
1568
|
y: n / 2 - c * o
|
|
1569
1569
|
};
|
|
1570
1570
|
}
|
|
1571
|
-
function
|
|
1571
|
+
function Jt(e, t, n, r = 300) {
|
|
1572
1572
|
let i = Date.now(), a = 0, o = () => {
|
|
1573
|
-
let s = Date.now() - i, c = Math.min(s / r, 1), l =
|
|
1573
|
+
let s = Date.now() - i, c = Math.min(s / r, 1), l = Ht(c);
|
|
1574
1574
|
n({
|
|
1575
1575
|
scale: e.scale + (t.scale - e.scale) * l,
|
|
1576
1576
|
x: e.x + (t.x - e.x) * l,
|
|
@@ -1581,10 +1581,10 @@ function Yt(e, t, n, r = 300) {
|
|
|
1581
1581
|
}
|
|
1582
1582
|
//#endregion
|
|
1583
1583
|
//#region src/components/ShapeEditor/_state/createInteractionController.ts
|
|
1584
|
-
function
|
|
1585
|
-
let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, shiftRef: a, docRef: o, selRef: s, draftRef: c, readOnlyRef: l, disableMarqueeRef: u, lockedRef: d, onLockedInteraction: f, createRef: p, selectRef: m, enterEditRef: h, editingIdRef: g, drawSessionRef: _, assistantRef: v, setCursorHint: y, setInteractionMode: b, syncMinimap: x, onTransformPreview: S, onDrawPreview: C } = e, w = () => _.current, T = () => v.current, E = null, D = null, O = null, k = null, A = null, j = null, M = "", N = null, P = (e) => e ===
|
|
1584
|
+
function Yt(e) {
|
|
1585
|
+
let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, shiftRef: a, docRef: o, selRef: s, draftRef: c, readOnlyRef: l, disableMarqueeRef: u, lockedRef: d, onLockedInteraction: f, createRef: p, selectRef: m, enterEditRef: h, editingIdRef: g, drawSessionRef: _, assistantRef: v, setCursorHint: y, setInteractionMode: b, syncMinimap: x, onTransformPreview: S, onDrawPreview: C } = e, w = () => _.current, T = () => v.current, E = null, D = null, O = null, k = null, A = null, j = null, M = "", N = null, P = (e) => e === W.RECTANGLE || e === W.ROTATED_RECTANGLE || e === W.CIRCLE, ee = (e) => e === W.ASSISTANT_POLYGON || e === W.ASSISTANT_RECT, te = (e) => e === W.POLYGON, ne = (e, t) => {
|
|
1586
1586
|
let n = !1;
|
|
1587
|
-
D && !P(t) && !ee(t) && (D = null, e.clearPreview(), C(null), n = !0), (O === "path" && t !==
|
|
1587
|
+
D && !P(t) && !ee(t) && (D = null, e.clearPreview(), C(null), n = !0), (O === "path" && t !== W.PATH || O === "scalar" && t !== W.BRUSH) && (O = null, n = !0), k && !te(t) && (k = null, n = !0), A && t !== W.SELECT && (A = null, j = null, e.clearMarquee(), n = !0), n && b("idle");
|
|
1588
1588
|
}, re = () => r.current.get(n.current), ie = (e, t, n, r) => ({
|
|
1589
1589
|
point: t,
|
|
1590
1590
|
targetId: r,
|
|
@@ -1606,7 +1606,7 @@ function Xt(e) {
|
|
|
1606
1606
|
};
|
|
1607
1607
|
return;
|
|
1608
1608
|
}
|
|
1609
|
-
if (u.button === 2 && !(_ ===
|
|
1609
|
+
if (u.button === 2 && !(_ === W.ASSISTANT_POINT && u.altKey)) {
|
|
1610
1610
|
if (r && !s.current.includes(r)) {
|
|
1611
1611
|
let e = o.current.getShapes().find((e) => e.id === r);
|
|
1612
1612
|
e && I(e) && m.current([r]);
|
|
@@ -1622,7 +1622,7 @@ function Xt(e) {
|
|
|
1622
1622
|
f();
|
|
1623
1623
|
return;
|
|
1624
1624
|
}
|
|
1625
|
-
if (_ ===
|
|
1625
|
+
if (_ === W.ASSISTANT_POINT) {
|
|
1626
1626
|
u.altKey ? T().addPoint(e, u.button !== 2) : T().newPolygon(e);
|
|
1627
1627
|
return;
|
|
1628
1628
|
}
|
|
@@ -1630,7 +1630,7 @@ function Xt(e) {
|
|
|
1630
1630
|
D = e, b("drawing");
|
|
1631
1631
|
return;
|
|
1632
1632
|
}
|
|
1633
|
-
if (_ ===
|
|
1633
|
+
if (_ === W.SELECT && u.altKey) {
|
|
1634
1634
|
let t = R(o.current.getShapes()).filter((t) => {
|
|
1635
1635
|
if (!I(t)) return !1;
|
|
1636
1636
|
let n = B(t.points);
|
|
@@ -1642,7 +1642,7 @@ function Xt(e) {
|
|
|
1642
1642
|
return;
|
|
1643
1643
|
}
|
|
1644
1644
|
}
|
|
1645
|
-
if (r && _ ===
|
|
1645
|
+
if (r && _ === W.SELECT) {
|
|
1646
1646
|
let t = o.current.getShapes().find((e) => e.id === r);
|
|
1647
1647
|
if (!t || !I(t)) return;
|
|
1648
1648
|
let n = typeof performance < "u" ? performance.now() : 0, i = !!N && N.id === r && n - N.t < 300;
|
|
@@ -1688,15 +1688,15 @@ function Xt(e) {
|
|
|
1688
1688
|
w().appendPolygonPoint(e);
|
|
1689
1689
|
return;
|
|
1690
1690
|
}
|
|
1691
|
-
if (_ ===
|
|
1691
|
+
if (_ === W.PATH && c.current) {
|
|
1692
1692
|
s.current.length && m.current([]), O = "path", b("drawing"), w().beginStroke(e);
|
|
1693
1693
|
return;
|
|
1694
1694
|
}
|
|
1695
|
-
if (_ ===
|
|
1695
|
+
if (_ === W.BRUSH && c.current && !l.current) {
|
|
1696
1696
|
O = "scalar", b("drawing"), w().beginStroke(e);
|
|
1697
1697
|
return;
|
|
1698
1698
|
}
|
|
1699
|
-
if (_ ===
|
|
1699
|
+
if (_ === W.SELECT) {
|
|
1700
1700
|
if (j = g.current ? a.current ? p.getVertexSelection() : [] : null, !a.current && !l.current && s.current.length >= 2) {
|
|
1701
1701
|
let t = o.current.getShapes().filter((e) => s.current.includes(e.id) && L(e));
|
|
1702
1702
|
if (t.length) {
|
|
@@ -1735,11 +1735,11 @@ function Xt(e) {
|
|
|
1735
1735
|
}
|
|
1736
1736
|
if (D && (P(s) || ee(s))) {
|
|
1737
1737
|
let t = a.current ? le(D, e) : e;
|
|
1738
|
-
i.previewBox(s ===
|
|
1738
|
+
i.previewBox(s === W.CIRCLE ? "ellipse" : "rect", D, t, {
|
|
1739
1739
|
...c.current,
|
|
1740
1740
|
color: c.current?.color ?? "#00e5ff"
|
|
1741
1741
|
}), P(s) && C({
|
|
1742
|
-
type: s ===
|
|
1742
|
+
type: s === W.CIRCLE ? F.ELLIPSE : F.RECTANGLE,
|
|
1743
1743
|
points: [D, t]
|
|
1744
1744
|
});
|
|
1745
1745
|
return;
|
|
@@ -1786,7 +1786,7 @@ function Xt(e) {
|
|
|
1786
1786
|
o.onPointerUp?.(ie(r, e, {}));
|
|
1787
1787
|
return;
|
|
1788
1788
|
}
|
|
1789
|
-
if (i ===
|
|
1789
|
+
if (i === W.POINT && c.current) {
|
|
1790
1790
|
p.current(F.POINT, [e]);
|
|
1791
1791
|
return;
|
|
1792
1792
|
}
|
|
@@ -1804,12 +1804,12 @@ function Xt(e) {
|
|
|
1804
1804
|
width: Math.abs(e.x - t.x),
|
|
1805
1805
|
height: Math.abs(e.y - t.y)
|
|
1806
1806
|
};
|
|
1807
|
-
n.width > 2 && n.height > 2 && T().beginBox(n, i ===
|
|
1807
|
+
n.width > 2 && n.height > 2 && T().beginBox(n, i === W.ASSISTANT_RECT ? "rect" : "polygon");
|
|
1808
1808
|
return;
|
|
1809
1809
|
}
|
|
1810
1810
|
if (D && P(i)) {
|
|
1811
1811
|
let t = a.current ? le(D, e) : e, n = D;
|
|
1812
|
-
D = null, b("idle"), r.clearPreview(), C(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (i ===
|
|
1812
|
+
D = null, b("idle"), r.clearPreview(), C(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (i === W.ROTATED_RECTANGLE ? p.current(F.ROTATED_RECTANGLE, de([n, t])) : i === W.CIRCLE ? p.current(F.POLYGON, fe(n, t)) : p.current(F.RECTANGLE, [n, t]));
|
|
1813
1813
|
return;
|
|
1814
1814
|
}
|
|
1815
1815
|
if (A) {
|
|
@@ -1834,7 +1834,7 @@ function Xt(e) {
|
|
|
1834
1834
|
}
|
|
1835
1835
|
//#endregion
|
|
1836
1836
|
//#region src/components/ShapeEditor/_state/useAssistant.ts
|
|
1837
|
-
function
|
|
1837
|
+
function Xt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistantRef: i }) {
|
|
1838
1838
|
let [a, o] = E("idle"), [s, c] = E([]), [l, u] = E([]), d = T([]), f = T([]), p = T([]), m = T("idle"), h = T(0), g = T(null), _ = T(null), y = T(0), b = v((e) => {
|
|
1839
1839
|
d.current = e(d.current), u(d.current);
|
|
1840
1840
|
}, []), x = v((e) => {
|
|
@@ -1999,17 +1999,17 @@ function Zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
1999
1999
|
}
|
|
2000
2000
|
//#endregion
|
|
2001
2001
|
//#region src/components/ShapeEditor/_model/brush.ts
|
|
2002
|
-
function
|
|
2002
|
+
function Zt(e, t, n) {
|
|
2003
2003
|
let r = Math.abs(.5 * (t.x * n.y + n.x * e.y + e.x * t.y - n.x * t.y - e.x * n.y - t.x * e.y)), i = Math.hypot(t.x - n.x, t.y - n.y);
|
|
2004
2004
|
return i === 0 ? 0 : r * 2 / i;
|
|
2005
2005
|
}
|
|
2006
|
-
function
|
|
2006
|
+
function Qt(e, t = 1.5) {
|
|
2007
2007
|
if (e.length <= 2) return e;
|
|
2008
2008
|
let n = (e, t) => {
|
|
2009
2009
|
if (e.length < 3) return e;
|
|
2010
2010
|
let r = 0, i = 0, a = e.length - 1;
|
|
2011
2011
|
for (let t = 1; t < a; t++) {
|
|
2012
|
-
let n =
|
|
2012
|
+
let n = Zt(e[t], e[0], e[a]);
|
|
2013
2013
|
n > r && (i = t, r = n);
|
|
2014
2014
|
}
|
|
2015
2015
|
if (r > t) {
|
|
@@ -2022,8 +2022,8 @@ function $t(e, t = 1.5) {
|
|
|
2022
2022
|
}
|
|
2023
2023
|
//#endregion
|
|
2024
2024
|
//#region src/components/ShapeEditor/_model/scalarMask.ts
|
|
2025
|
-
var
|
|
2026
|
-
function
|
|
2025
|
+
var $t = 4096, en = 4;
|
|
2026
|
+
function tn(e) {
|
|
2027
2027
|
let t = 0;
|
|
2028
2028
|
for (let n = 0; n < e.length; n++) {
|
|
2029
2029
|
let r = e[n], i = e[(n + 1) % e.length];
|
|
@@ -2031,17 +2031,17 @@ function nn(e) {
|
|
|
2031
2031
|
}
|
|
2032
2032
|
return Math.abs(t / 2);
|
|
2033
2033
|
}
|
|
2034
|
-
function
|
|
2034
|
+
function nn(e, t, n) {
|
|
2035
2035
|
let r = new Uint8Array(t * n);
|
|
2036
2036
|
for (let i = 0; i < t * n; i++) r[i] = e[i * 4 + 3] > 128 ? 255 : 0;
|
|
2037
2037
|
return r;
|
|
2038
2038
|
}
|
|
2039
|
-
function
|
|
2039
|
+
function rn(e) {
|
|
2040
2040
|
let t = new Uint8ClampedArray(e.length * 4);
|
|
2041
2041
|
for (let n = 0; n < e.length; n++) e[n] > 128 && (t[n * 4 + 3] = 255);
|
|
2042
2042
|
return t;
|
|
2043
2043
|
}
|
|
2044
|
-
function
|
|
2044
|
+
function an(e, t, n, r, i) {
|
|
2045
2045
|
let a = new Uint8Array(t * n), o = [[r, i]];
|
|
2046
2046
|
for (; o.length;) {
|
|
2047
2047
|
let [r, i] = o.pop(), s = i * t + r;
|
|
@@ -2049,8 +2049,8 @@ function on(e, t, n, r, i) {
|
|
|
2049
2049
|
}
|
|
2050
2050
|
return a;
|
|
2051
2051
|
}
|
|
2052
|
-
function
|
|
2053
|
-
let r =
|
|
2052
|
+
function on(e, t, n) {
|
|
2053
|
+
let r = nn(e, t, n), i = [];
|
|
2054
2054
|
for (;;) {
|
|
2055
2055
|
let e = -1, a = -1;
|
|
2056
2056
|
outer: for (let i = 0; i < n; i++) for (let n = 0; n < t; n++) if (r[i * t + n] > 128) {
|
|
@@ -2058,17 +2058,17 @@ function sn(e, t, n) {
|
|
|
2058
2058
|
break outer;
|
|
2059
2059
|
}
|
|
2060
2060
|
if (e < 0) break;
|
|
2061
|
-
let o =
|
|
2061
|
+
let o = cn(rn(an(r, t, n, e, a)), t, n);
|
|
2062
2062
|
o.length >= 3 && i.push(o);
|
|
2063
2063
|
}
|
|
2064
2064
|
return i;
|
|
2065
2065
|
}
|
|
2066
|
-
function
|
|
2066
|
+
function sn(e, t, n, r, i) {
|
|
2067
2067
|
return r < 0 || i < 0 || r >= t || i >= n ? !1 : e[(i * t + r) * 4 + 3] > 128;
|
|
2068
2068
|
}
|
|
2069
|
-
function
|
|
2069
|
+
function cn(e, t, n) {
|
|
2070
2070
|
let r = -1, i = -1;
|
|
2071
|
-
outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if (
|
|
2071
|
+
outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if (sn(e, t, n, o, a)) {
|
|
2072
2072
|
r = o, i = a;
|
|
2073
2073
|
break outer;
|
|
2074
2074
|
}
|
|
@@ -2103,7 +2103,7 @@ function ln(e, t, n) {
|
|
|
2103
2103
|
let r = !1;
|
|
2104
2104
|
for (let i = 0; i < 8; i++) {
|
|
2105
2105
|
let s = (u + i) % 8, d = c + a[s], f = l + o[s];
|
|
2106
|
-
if (
|
|
2106
|
+
if (sn(e, t, n, d, f)) {
|
|
2107
2107
|
c = d, l = f, u = (s + 6) % 8, r = !0;
|
|
2108
2108
|
break;
|
|
2109
2109
|
}
|
|
@@ -2112,13 +2112,13 @@ function ln(e, t, n) {
|
|
|
2112
2112
|
} while (c !== d.x || l !== d.y || s.length === 1);
|
|
2113
2113
|
return s;
|
|
2114
2114
|
}
|
|
2115
|
-
function
|
|
2115
|
+
function ln(e, t) {
|
|
2116
2116
|
let n = [];
|
|
2117
2117
|
for (let t of e) for (let e of t.points) n.push(e);
|
|
2118
2118
|
for (let e of t) for (let t of e) n.push(t);
|
|
2119
2119
|
return n;
|
|
2120
2120
|
}
|
|
2121
|
-
function
|
|
2121
|
+
function un(e) {
|
|
2122
2122
|
switch (e.type) {
|
|
2123
2123
|
case F.RECTANGLE: return e.points.length < 2 ? null : de(e.points);
|
|
2124
2124
|
case F.POLYGON:
|
|
@@ -2137,14 +2137,14 @@ function dn(e) {
|
|
|
2137
2137
|
default: return null;
|
|
2138
2138
|
}
|
|
2139
2139
|
}
|
|
2140
|
-
function
|
|
2141
|
-
return e.map(
|
|
2140
|
+
function dn(e) {
|
|
2141
|
+
return e.map(un).filter((e) => !!e && e.length >= 3);
|
|
2142
2142
|
}
|
|
2143
|
-
function
|
|
2143
|
+
function fn(e, t, n = []) {
|
|
2144
2144
|
if (t <= 0 || !e.length && !n.length) return null;
|
|
2145
|
-
let r =
|
|
2145
|
+
let r = ln(e, n);
|
|
2146
2146
|
if (!r.length) return null;
|
|
2147
|
-
let i = t + 4, a = B(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1,
|
|
2147
|
+
let i = t + 4, a = B(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1, $t / Math.max(o, s, 1));
|
|
2148
2148
|
o = Math.max(1, Math.ceil(o * c)), s = Math.max(1, Math.ceil(s * c));
|
|
2149
2149
|
let l = a.minX - i, u = a.minY - i, d = (e) => ({
|
|
2150
2150
|
x: (e.x - l) * c,
|
|
@@ -2183,20 +2183,20 @@ function pn(e, t, n = []) {
|
|
|
2183
2183
|
scale: c
|
|
2184
2184
|
};
|
|
2185
2185
|
}
|
|
2186
|
-
function
|
|
2187
|
-
let { canvas: n, ox: r, oy: i, scale: a } = e, o =
|
|
2186
|
+
function pn(e, t = 1.5) {
|
|
2187
|
+
let { canvas: n, ox: r, oy: i, scale: a } = e, o = on(n.getContext("2d").getImageData(0, 0, n.width, n.height).data, n.width, n.height);
|
|
2188
2188
|
if (!o.length) return [];
|
|
2189
2189
|
let s = (e) => ({
|
|
2190
2190
|
x: e.x / a + r,
|
|
2191
2191
|
y: e.y / a + i
|
|
2192
2192
|
}), c = [];
|
|
2193
2193
|
for (let e of o) {
|
|
2194
|
-
let n = e.map(s), r =
|
|
2195
|
-
i.length >= 3 &&
|
|
2194
|
+
let n = e.map(s), r = Qt(n, t), i = r.length >= 3 ? r : n;
|
|
2195
|
+
i.length >= 3 && tn(i) >= en && c.push(i);
|
|
2196
2196
|
}
|
|
2197
2197
|
return c;
|
|
2198
2198
|
}
|
|
2199
|
-
function
|
|
2199
|
+
function mn(e, t) {
|
|
2200
2200
|
let { canvas: n } = e, r = document.createElement("canvas");
|
|
2201
2201
|
r.width = n.width, r.height = n.height;
|
|
2202
2202
|
let i = r.getContext("2d");
|
|
@@ -2204,30 +2204,30 @@ function hn(e, t) {
|
|
|
2204
2204
|
}
|
|
2205
2205
|
//#endregion
|
|
2206
2206
|
//#region src/components/ShapeEditor/_state/drawSessionState.ts
|
|
2207
|
-
function
|
|
2207
|
+
function hn(e) {
|
|
2208
2208
|
return e.map((e) => ({
|
|
2209
2209
|
mode: e.mode,
|
|
2210
2210
|
points: e.points.map((e) => ({ ...e }))
|
|
2211
2211
|
}));
|
|
2212
2212
|
}
|
|
2213
|
-
function
|
|
2213
|
+
function gn(e, t) {
|
|
2214
2214
|
return e.length === t.length && e.every((e, n) => e.mode === t[n].mode && e.points.length === t[n].points.length && e.points.every((e, r) => e.x === t[n].points[r].x && e.y === t[n].points[r].y));
|
|
2215
2215
|
}
|
|
2216
|
-
function
|
|
2216
|
+
function _n(e) {
|
|
2217
2217
|
return e.map((e) => ({ ...e }));
|
|
2218
2218
|
}
|
|
2219
|
-
function
|
|
2219
|
+
function vn(e, t) {
|
|
2220
2220
|
return e.length === t.length && e.every((e, n) => e.x === t[n].x && e.y === t[n].y);
|
|
2221
2221
|
}
|
|
2222
2222
|
//#endregion
|
|
2223
2223
|
//#region src/components/ShapeEditor/_state/useDrawSession.ts
|
|
2224
|
-
var
|
|
2225
|
-
function
|
|
2224
|
+
var yn = 10;
|
|
2225
|
+
function bn(e, t) {
|
|
2226
2226
|
if (e.active !== t.active || e.kind !== t.kind || e.canUndo !== t.canUndo || e.canRedo !== t.canRedo) return !1;
|
|
2227
2227
|
let n = e.brush, r = t.brush;
|
|
2228
2228
|
return !n || !r ? n === r : n.mode === r.mode && n.editing === r.editing && n.editTargetIds.length === r.editTargetIds.length && n.editTargetIds.every((e, t) => e === r.editTargetIds[t]);
|
|
2229
2229
|
}
|
|
2230
|
-
function
|
|
2230
|
+
function xn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, brushSizeRef: a, simplifyEpsilonRef: o, draftMeta: s, engineRef: c, onDrawSessionChange: l, onDraftShapeChange: u, changeSelection: d, createShape: f }) {
|
|
2231
2231
|
let p = T(l);
|
|
2232
2232
|
p.current = l;
|
|
2233
2233
|
let m = T(u);
|
|
@@ -2236,15 +2236,15 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2236
2236
|
h.current = s;
|
|
2237
2237
|
let g = T(f);
|
|
2238
2238
|
g.current = f;
|
|
2239
|
-
let _ = T(null), y = T([]), b = T(null), x = T(/* @__PURE__ */ new Set()), S = T([[]]), C = T(0), w = T(null), E = T([]), D = T([]), O = T([]), k = T([[]]), A = T(0), j = T("draw"), M = () => j.current === "erase" ? "erase" : "add", N = () => O.current.length > 0 || E.current.length > 0 || e.current ===
|
|
2239
|
+
let _ = T(null), y = T([]), b = T(null), x = T(/* @__PURE__ */ new Set()), S = T([[]]), C = T(0), w = T(null), E = T([]), D = T([]), O = T([]), k = T([[]]), A = T(0), j = T("draw"), M = () => j.current === "erase" ? "erase" : "add", N = () => O.current.length > 0 || E.current.length > 0 || e.current === W.BRUSH && y.current.length > 0, P = () => {
|
|
2240
2240
|
let t = e.current;
|
|
2241
|
-
return t ===
|
|
2241
|
+
return t === W.BRUSH && N() ? "brush" : t === W.POLYGON && y.current.length > 0 ? "polygon" : t === W.PATH && y.current.length > 0 ? "path" : "none";
|
|
2242
2242
|
}, ee = () => y.current.length > 0 || A.current > 0, te = () => y.current.length === 0 && A.current < k.current.length - 1, ne = () => C.current > 0, re = () => C.current < S.current.length - 1, ie = () => {
|
|
2243
2243
|
let t = e.current;
|
|
2244
|
-
return t ===
|
|
2244
|
+
return t === W.BRUSH ? ee() : t === W.POLYGON || t === W.PATH ? ne() : !1;
|
|
2245
2245
|
}, ae = () => {
|
|
2246
2246
|
let t = e.current;
|
|
2247
|
-
return t ===
|
|
2247
|
+
return t === W.BRUSH ? te() : t === W.POLYGON || t === W.PATH ? re() : !1;
|
|
2248
2248
|
}, I = () => P() !== "none", L = v(() => {
|
|
2249
2249
|
let e = P(), t = {
|
|
2250
2250
|
active: e !== "none",
|
|
@@ -2257,14 +2257,14 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2257
2257
|
editTargetIds: [...O.current]
|
|
2258
2258
|
} : void 0
|
|
2259
2259
|
}, n = _.current;
|
|
2260
|
-
n &&
|
|
2260
|
+
n && bn(n, t) || (_.current = t, p.current?.(t));
|
|
2261
2261
|
}, []), R = v(() => {
|
|
2262
2262
|
k.current = [[]], A.current = 0;
|
|
2263
2263
|
}, []), z = v(() => {
|
|
2264
2264
|
let t = c.current;
|
|
2265
2265
|
if (!t) return;
|
|
2266
2266
|
let n = e.current;
|
|
2267
|
-
if (n ===
|
|
2267
|
+
if (n === W.BRUSH) {
|
|
2268
2268
|
let e = [...E.current];
|
|
2269
2269
|
if (y.current.length && e.push({
|
|
2270
2270
|
points: y.current,
|
|
@@ -2273,7 +2273,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2273
2273
|
t.clearPreview();
|
|
2274
2274
|
return;
|
|
2275
2275
|
}
|
|
2276
|
-
let n =
|
|
2276
|
+
let n = fn(e, a.current, D.current);
|
|
2277
2277
|
if (!n) {
|
|
2278
2278
|
t.clearPreview();
|
|
2279
2279
|
return;
|
|
@@ -2290,12 +2290,12 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2290
2290
|
let o = {
|
|
2291
2291
|
...i.current,
|
|
2292
2292
|
color: i.current?.color ?? "#00e5ff"
|
|
2293
|
-
}, s = Array.from(x.current), l = n !==
|
|
2294
|
-
if (t.previewPoly(r, b.current, o, !1, s, l), n ===
|
|
2293
|
+
}, s = Array.from(x.current), l = n !== W.PATH;
|
|
2294
|
+
if (t.previewPoly(r, b.current, o, !1, s, l), n === W.POLYGON || n === W.PATH) {
|
|
2295
2295
|
let e = m.current;
|
|
2296
2296
|
e && r !== w.current && (w.current = r, e({
|
|
2297
2297
|
type: F.POLYGON,
|
|
2298
|
-
points:
|
|
2298
|
+
points: _n(r),
|
|
2299
2299
|
meta: h.current
|
|
2300
2300
|
}));
|
|
2301
2301
|
}
|
|
@@ -2305,11 +2305,11 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2305
2305
|
c,
|
|
2306
2306
|
e
|
|
2307
2307
|
]), B = v((e) => {
|
|
2308
|
-
let t =
|
|
2309
|
-
i &&
|
|
2308
|
+
let t = hn(e), n = k.current, r = A.current, i = n[r];
|
|
2309
|
+
i && gn(i, t) || (k.current = [...n.slice(0, r + 1), t], A.current += 1, L());
|
|
2310
2310
|
}, [L]), ce = v((e) => {
|
|
2311
2311
|
let t = S.current, n = C.current, r = t[n];
|
|
2312
|
-
r &&
|
|
2312
|
+
r && vn(r, e) || (S.current = [...t.slice(0, n + 1), _n(e)], C.current += 1);
|
|
2313
2313
|
}, []), V = v(() => {
|
|
2314
2314
|
y.current = [], E.current = [], D.current = [], O.current = [], b.current = null, x.current = /* @__PURE__ */ new Set(), S.current = [[]], C.current = 0, w.current = null, R(), c.current?.clearPreview(), m.current?.(null), L();
|
|
2315
2315
|
}, [
|
|
@@ -2322,8 +2322,8 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2322
2322
|
L,
|
|
2323
2323
|
ce,
|
|
2324
2324
|
z
|
|
2325
|
-
]), ue = v(() =>
|
|
2326
|
-
if (e.current !==
|
|
2325
|
+
]), ue = v(() => _n(y.current), []), de = v(() => y.current.length > 0, []), fe = v((t, n) => {
|
|
2326
|
+
if (e.current !== W.POLYGON) return !1;
|
|
2327
2327
|
let r = y.current;
|
|
2328
2328
|
if (r.length < 3) return !1;
|
|
2329
2329
|
let i = r[0];
|
|
@@ -2336,7 +2336,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2336
2336
|
if (e < 0 || e >= n.length) return null;
|
|
2337
2337
|
let r = new Set(x.current);
|
|
2338
2338
|
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), x.current = r, b.current = null, z(), L(), {
|
|
2339
|
-
base:
|
|
2339
|
+
base: _n(n),
|
|
2340
2340
|
indices: Array.from(r)
|
|
2341
2341
|
};
|
|
2342
2342
|
}, [L, z]), H = v((e) => {
|
|
@@ -2360,16 +2360,16 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2360
2360
|
z
|
|
2361
2361
|
]), ye = v((e) => {
|
|
2362
2362
|
b.current = e ? { ...e } : null, z();
|
|
2363
|
-
}, [z]), be = v(() => y.current.length > 0 ? (y.current = [], z(), L(), !0) : A.current <= 0 ? !1 : (--A.current, E.current =
|
|
2363
|
+
}, [z]), be = v(() => y.current.length > 0 ? (y.current = [], z(), L(), !0) : A.current <= 0 ? !1 : (--A.current, E.current = hn(k.current[A.current]), z(), L(), !0), [L, z]), xe = v(() => y.current.length > 0 || A.current >= k.current.length - 1 ? !1 : (A.current += 1, E.current = hn(k.current[A.current]), z(), L(), !0), [L, z]), Se = v(() => C.current <= 0 ? !1 : (--C.current, y.current = _n(S.current[C.current]), x.current = /* @__PURE__ */ new Set(), z(), L(), !0), [L, z]), Ce = v(() => C.current >= S.current.length - 1 ? !1 : (C.current += 1, y.current = _n(S.current[C.current]), x.current = /* @__PURE__ */ new Set(), z(), L(), !0), [L, z]), we = v(() => {
|
|
2364
2364
|
let t = e.current;
|
|
2365
|
-
return t ===
|
|
2365
|
+
return t === W.BRUSH ? be() : t === W.POLYGON || t === W.PATH ? Se() : !1;
|
|
2366
2366
|
}, [
|
|
2367
2367
|
e,
|
|
2368
2368
|
be,
|
|
2369
2369
|
Se
|
|
2370
2370
|
]), U = v(() => {
|
|
2371
2371
|
let t = e.current;
|
|
2372
|
-
return t ===
|
|
2372
|
+
return t === W.BRUSH ? xe() : t === W.POLYGON || t === W.PATH ? Ce() : !1;
|
|
2373
2373
|
}, [
|
|
2374
2374
|
xe,
|
|
2375
2375
|
Ce,
|
|
@@ -2377,24 +2377,24 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2377
2377
|
]), Te = v(() => {
|
|
2378
2378
|
let e = t.current;
|
|
2379
2379
|
if (!e.length) return O.current.length > 0;
|
|
2380
|
-
let r = n.current.getShapes().filter((t) => e.includes(t.id) && oe(t)), i =
|
|
2380
|
+
let r = n.current.getShapes().filter((t) => e.includes(t.id) && oe(t)), i = dn(r);
|
|
2381
2381
|
return i.length ? (O.current = r.map((e) => e.id), D.current = i, !0) : (O.current = [], D.current = [], !1);
|
|
2382
2382
|
}, [n, t]), Ee = v(() => {
|
|
2383
2383
|
if (r.current) return !1;
|
|
2384
2384
|
let e = [...E.current];
|
|
2385
2385
|
y.current.length && e.push({
|
|
2386
|
-
points:
|
|
2386
|
+
points: _n(y.current),
|
|
2387
2387
|
mode: M()
|
|
2388
2388
|
});
|
|
2389
2389
|
let t = D.current, c = [...O.current];
|
|
2390
2390
|
if (!e.length && !t.length) return !1;
|
|
2391
|
-
let l =
|
|
2391
|
+
let l = fn(e, a.current, t);
|
|
2392
2392
|
if (!l) return V(), !1;
|
|
2393
|
-
let u =
|
|
2393
|
+
let u = pn(l, o.current);
|
|
2394
2394
|
if (c.length) {
|
|
2395
2395
|
let e = n.current.getShapes().filter((e) => c.includes(e.id));
|
|
2396
2396
|
if (!u.length) return n.current.remove(c), V(), d([]), !0;
|
|
2397
|
-
u.sort((e, t) =>
|
|
2397
|
+
u.sort((e, t) => tn(t) - tn(e));
|
|
2398
2398
|
let t = [], r = [], i = [];
|
|
2399
2399
|
for (let n = 0; n < u.length; n++) {
|
|
2400
2400
|
let a = u[n];
|
|
@@ -2439,24 +2439,24 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2439
2439
|
V
|
|
2440
2440
|
]), De = v(() => {
|
|
2441
2441
|
let t = e.current;
|
|
2442
|
-
if (t ===
|
|
2442
|
+
if (t === W.BRUSH) return Ee();
|
|
2443
2443
|
let n = y.current;
|
|
2444
|
-
return t ===
|
|
2444
|
+
return t === W.POLYGON && n.length >= 3 ? (g.current(F.POLYGON, n), V(), !0) : !1;
|
|
2445
2445
|
}, [
|
|
2446
2446
|
Ee,
|
|
2447
2447
|
V,
|
|
2448
2448
|
e
|
|
2449
|
-
]),
|
|
2449
|
+
]), Oe = v(() => {
|
|
2450
2450
|
let t = y.current;
|
|
2451
|
-
if (e.current ===
|
|
2452
|
-
let e =
|
|
2451
|
+
if (e.current === W.PATH && t.length >= 3) {
|
|
2452
|
+
let e = Qt(t, o.current);
|
|
2453
2453
|
e.length >= 3 && g.current(F.POLYGON, e);
|
|
2454
2454
|
}
|
|
2455
2455
|
V();
|
|
2456
|
-
}, [V, e]),
|
|
2456
|
+
}, [V, e]), ke = v((e) => {
|
|
2457
2457
|
j.current = e, L(), z();
|
|
2458
|
-
}, [L, z]),
|
|
2459
|
-
if (r.current || e.current !==
|
|
2458
|
+
}, [L, z]), Ae = v(() => {
|
|
2459
|
+
if (r.current || e.current !== W.BRUSH) return !1;
|
|
2460
2460
|
E.current = [], y.current = [], R();
|
|
2461
2461
|
let t = Te();
|
|
2462
2462
|
return L(), z(), t;
|
|
@@ -2467,23 +2467,23 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2467
2467
|
R,
|
|
2468
2468
|
Te,
|
|
2469
2469
|
e
|
|
2470
|
-
]),
|
|
2470
|
+
]), G = v(() => {
|
|
2471
2471
|
let e = x.current;
|
|
2472
2472
|
if (!e.size) return !1;
|
|
2473
2473
|
let t = y.current.filter((t, n) => !e.has(n));
|
|
2474
2474
|
return x.current = /* @__PURE__ */ new Set(), le(t, !0), !0;
|
|
2475
|
-
}, [le]),
|
|
2475
|
+
}, [le]), je = v((e) => {
|
|
2476
2476
|
let t = c.current, n = y.current;
|
|
2477
2477
|
if (!t || !n.length) return -1;
|
|
2478
|
-
let r =
|
|
2478
|
+
let r = yn / (t.viewport.scale || 1);
|
|
2479
2479
|
for (let t = n.length - 1; t >= 0; t--) {
|
|
2480
2480
|
let i = n[t];
|
|
2481
2481
|
if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
|
|
2482
2482
|
}
|
|
2483
2483
|
return -1;
|
|
2484
|
-
}, [c]),
|
|
2484
|
+
}, [c]), Me = v(() => {
|
|
2485
2485
|
y.current.length >= 1 && (E.current.push({
|
|
2486
|
-
points:
|
|
2486
|
+
points: _n(y.current),
|
|
2487
2487
|
mode: M()
|
|
2488
2488
|
}), y.current = [], B(E.current)), z(), L();
|
|
2489
2489
|
}, [
|
|
@@ -2500,17 +2500,17 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2500
2500
|
hasDraftSession: I,
|
|
2501
2501
|
hasDraftPoints: de,
|
|
2502
2502
|
commitDraftSession: De,
|
|
2503
|
-
completeFreehandStroke:
|
|
2504
|
-
setBrushScalarMode:
|
|
2503
|
+
completeFreehandStroke: Oe,
|
|
2504
|
+
setBrushScalarMode: ke,
|
|
2505
2505
|
getBrushScalarMode: () => j.current,
|
|
2506
2506
|
hasBrushSession: N,
|
|
2507
2507
|
commitBrush: Ee,
|
|
2508
2508
|
cancelBrush: v(() => {
|
|
2509
|
-
e.current ===
|
|
2509
|
+
e.current === W.BRUSH && V();
|
|
2510
2510
|
}, [V, e]),
|
|
2511
|
-
beginBrushEditFromSelection:
|
|
2512
|
-
deleteDraftSelectedPoints:
|
|
2513
|
-
hitDraftPoint:
|
|
2511
|
+
beginBrushEditFromSelection: Ae,
|
|
2512
|
+
deleteDraftSelectedPoints: G,
|
|
2513
|
+
hitDraftPoint: je,
|
|
2514
2514
|
getDraftPointsSnapshot: ue,
|
|
2515
2515
|
tryClosePolygon: fe,
|
|
2516
2516
|
removeDraftPoint: pe,
|
|
@@ -2521,13 +2521,13 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2521
2521
|
moveDraftPoints: _e,
|
|
2522
2522
|
commitDraftPointDrag: ve,
|
|
2523
2523
|
setDraftCursor: ye,
|
|
2524
|
-
finishScalarStroke:
|
|
2524
|
+
finishScalarStroke: Me,
|
|
2525
2525
|
handleToolChange: v((e, t) => {
|
|
2526
2526
|
if (t) {
|
|
2527
2527
|
V(), j.current = "draw";
|
|
2528
2528
|
return;
|
|
2529
2529
|
}
|
|
2530
|
-
if (e !==
|
|
2530
|
+
if (e !== W.BRUSH) {
|
|
2531
2531
|
V(), j.current = "draw";
|
|
2532
2532
|
return;
|
|
2533
2533
|
}
|
|
@@ -2540,7 +2540,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2540
2540
|
Te
|
|
2541
2541
|
]),
|
|
2542
2542
|
handleBrushSelectionChange: v((t, n) => {
|
|
2543
|
-
if (!(e.current !==
|
|
2543
|
+
if (!(e.current !== W.BRUSH || n)) {
|
|
2544
2544
|
if (!t.length) {
|
|
2545
2545
|
L();
|
|
2546
2546
|
return;
|
|
@@ -2558,31 +2558,31 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2558
2558
|
}
|
|
2559
2559
|
//#endregion
|
|
2560
2560
|
//#region src/components/ShapeEditor/_state/useEditorDocument.ts
|
|
2561
|
-
function
|
|
2561
|
+
function Sn(e, t) {
|
|
2562
2562
|
return {
|
|
2563
2563
|
shapes: t,
|
|
2564
2564
|
past: [...e.past, e.shapes],
|
|
2565
2565
|
future: []
|
|
2566
2566
|
};
|
|
2567
2567
|
}
|
|
2568
|
-
function
|
|
2568
|
+
function Cn(e, t) {
|
|
2569
2569
|
switch (t.type) {
|
|
2570
|
-
case "CREATE": return
|
|
2570
|
+
case "CREATE": return Sn(e, [...e.shapes, ...t.shapes]);
|
|
2571
2571
|
case "UPDATE": {
|
|
2572
2572
|
let n = new Map(t.shapes.map((e) => [e.id, e]));
|
|
2573
|
-
return
|
|
2573
|
+
return Sn(e, e.shapes.map((e) => n.get(e.id) ?? e));
|
|
2574
2574
|
}
|
|
2575
2575
|
case "DELETE": {
|
|
2576
2576
|
let n = new Set(t.ids);
|
|
2577
|
-
return
|
|
2577
|
+
return Sn(e, e.shapes.filter((e) => !n.has(e.id)));
|
|
2578
2578
|
}
|
|
2579
2579
|
case "REPLACE": {
|
|
2580
2580
|
let n = new Set(t.removeIds);
|
|
2581
|
-
return
|
|
2581
|
+
return Sn(e, [...e.shapes.filter((e) => !n.has(e.id)), ...t.shapes]);
|
|
2582
2582
|
}
|
|
2583
2583
|
case "REORDER": {
|
|
2584
2584
|
let n = new Set(t.ids), r = e.shapes.filter((e) => n.has(e.id)), i = e.shapes.filter((e) => !n.has(e.id));
|
|
2585
|
-
return r.length === 0 ? e :
|
|
2585
|
+
return r.length === 0 ? e : Sn(e, t.edge === "front" ? [...i, ...r] : [...r, ...i]);
|
|
2586
2586
|
}
|
|
2587
2587
|
case "RESET": return {
|
|
2588
2588
|
shapes: t.shapes,
|
|
@@ -2602,15 +2602,15 @@ function wn(e, t) {
|
|
|
2602
2602
|
default: return e;
|
|
2603
2603
|
}
|
|
2604
2604
|
}
|
|
2605
|
-
function
|
|
2606
|
-
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = w(
|
|
2605
|
+
function wn(e) {
|
|
2606
|
+
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = w(Cn, {
|
|
2607
2607
|
shapes: [],
|
|
2608
2608
|
past: [],
|
|
2609
2609
|
future: []
|
|
2610
2610
|
}), o = T(i);
|
|
2611
2611
|
o.current = i;
|
|
2612
2612
|
let s = v((e) => {
|
|
2613
|
-
o.current =
|
|
2613
|
+
o.current = Cn(o.current, e), a(e);
|
|
2614
2614
|
}, []), c = v((e, i) => {
|
|
2615
2615
|
let a = new Map(e.map((e) => [e.id, e])), o = new Map(i.map((e) => [e.id, e])), s = i.filter((e) => !a.has(e.id));
|
|
2616
2616
|
s.length && t?.(s);
|
|
@@ -2679,7 +2679,7 @@ function Tn(e) {
|
|
|
2679
2679
|
}
|
|
2680
2680
|
//#endregion
|
|
2681
2681
|
//#region src/components/ShapeEditor/_model/keymap.ts
|
|
2682
|
-
var
|
|
2682
|
+
var Tn = {
|
|
2683
2683
|
undo: ["mod+z"],
|
|
2684
2684
|
redo: ["mod+shift+z"],
|
|
2685
2685
|
selectAll: ["mod+a"],
|
|
@@ -2707,7 +2707,7 @@ var En = {
|
|
|
2707
2707
|
pathTool: ["g"],
|
|
2708
2708
|
brushTool: ["b"],
|
|
2709
2709
|
pointTool: ["i"]
|
|
2710
|
-
},
|
|
2710
|
+
}, En = {
|
|
2711
2711
|
Equal: "=",
|
|
2712
2712
|
Minus: "-",
|
|
2713
2713
|
BracketLeft: "[",
|
|
@@ -2717,7 +2717,7 @@ var En = {
|
|
|
2717
2717
|
Comma: ",",
|
|
2718
2718
|
Slash: "/",
|
|
2719
2719
|
Backquote: "`"
|
|
2720
|
-
},
|
|
2720
|
+
}, Dn = {
|
|
2721
2721
|
Escape: "escape",
|
|
2722
2722
|
Enter: "enter",
|
|
2723
2723
|
Backspace: "backspace",
|
|
@@ -2728,58 +2728,58 @@ var En = {
|
|
|
2728
2728
|
ArrowLeft: "arrowleft",
|
|
2729
2729
|
ArrowRight: "arrowright"
|
|
2730
2730
|
};
|
|
2731
|
-
function
|
|
2731
|
+
function On(e) {
|
|
2732
2732
|
let t = e.code, n = /^Key([A-Z])$/.exec(t);
|
|
2733
2733
|
if (n) return n[1].toLowerCase();
|
|
2734
2734
|
let r = /^Digit([0-9])$/.exec(t);
|
|
2735
|
-
return r ? r[1] :
|
|
2735
|
+
return r ? r[1] : En[t] ? En[t] : Dn[e.key] ? Dn[e.key] : null;
|
|
2736
2736
|
}
|
|
2737
|
-
function
|
|
2738
|
-
let t =
|
|
2737
|
+
function kn(e) {
|
|
2738
|
+
let t = On(e);
|
|
2739
2739
|
if (!t) return null;
|
|
2740
2740
|
let n = [];
|
|
2741
2741
|
return (e.metaKey || e.ctrlKey) && n.push("mod"), e.shiftKey && n.push("shift"), e.altKey && n.push("alt"), n.push(t), n.join("+");
|
|
2742
2742
|
}
|
|
2743
|
-
function
|
|
2743
|
+
function An(e) {
|
|
2744
2744
|
let t = /* @__PURE__ */ new Map();
|
|
2745
|
-
for (let n of Object.keys(
|
|
2746
|
-
let r = e?.[n], i = r === void 0 ?
|
|
2745
|
+
for (let n of Object.keys(Tn)) {
|
|
2746
|
+
let r = e?.[n], i = r === void 0 ? Tn[n] : r === null ? [] : Array.isArray(r) ? r : [r];
|
|
2747
2747
|
for (let e of i) t.set(e.toLowerCase(), n);
|
|
2748
2748
|
}
|
|
2749
2749
|
return t;
|
|
2750
2750
|
}
|
|
2751
2751
|
//#endregion
|
|
2752
2752
|
//#region src/components/ShapeEditor/_state/useEditorHotkeys.ts
|
|
2753
|
-
var
|
|
2753
|
+
var jn = {
|
|
2754
2754
|
ArrowUp: [0, -1],
|
|
2755
2755
|
ArrowDown: [0, 1],
|
|
2756
2756
|
ArrowLeft: [-1, 0],
|
|
2757
2757
|
ArrowRight: [1, 0]
|
|
2758
2758
|
};
|
|
2759
|
-
function
|
|
2759
|
+
function Mn() {
|
|
2760
2760
|
let e = document.activeElement;
|
|
2761
2761
|
return !!e && (e.tagName === "INPUT" || e.tagName === "TEXTAREA" || e.isContentEditable);
|
|
2762
2762
|
}
|
|
2763
|
-
function
|
|
2763
|
+
function Nn(e, t) {
|
|
2764
2764
|
if (!t || !(e instanceof Element)) return !1;
|
|
2765
2765
|
let n = e.closest("[role=\"dialog\"],[aria-modal=\"true\"]");
|
|
2766
2766
|
return !!n && !n.contains(t);
|
|
2767
2767
|
}
|
|
2768
|
-
function
|
|
2769
|
-
let { spaceRef: t, shiftRef: n } = e, r = C(() =>
|
|
2768
|
+
function Pn(e) {
|
|
2769
|
+
let { spaceRef: t, shiftRef: n } = e, r = C(() => An(e.keymap), [e.keymap]), i = T(e);
|
|
2770
2770
|
i.current = e;
|
|
2771
2771
|
let a = T(r);
|
|
2772
2772
|
a.current = r, y(() => {
|
|
2773
2773
|
let e = (e) => {
|
|
2774
|
-
if (e.code === "Space" && (t.current = !0, i.current.onSpaceDown()), e.key === "Shift" && (n.current = !0),
|
|
2775
|
-
let r =
|
|
2774
|
+
if (e.code === "Space" && (t.current = !0, i.current.onSpaceDown()), e.key === "Shift" && (n.current = !0), Mn() || Nn(e.target, i.current.hostRef.current)) return;
|
|
2775
|
+
let r = jn[e.key];
|
|
2776
2776
|
if (r) {
|
|
2777
2777
|
e.preventDefault();
|
|
2778
2778
|
let t = e.shiftKey ? 10 : 1;
|
|
2779
2779
|
i.current.nudge(r[0] * t, r[1] * t);
|
|
2780
2780
|
return;
|
|
2781
2781
|
}
|
|
2782
|
-
let o =
|
|
2782
|
+
let o = kn(e);
|
|
2783
2783
|
if (!o) return;
|
|
2784
2784
|
let s = a.current.get(o);
|
|
2785
2785
|
s && i.current.actions[s]?.() !== !1 && e.preventDefault();
|
|
@@ -2793,7 +2793,7 @@ function Fn(e) {
|
|
|
2793
2793
|
}
|
|
2794
2794
|
//#endregion
|
|
2795
2795
|
//#region src/components/ShapeEditor/_model/imageFetch.ts
|
|
2796
|
-
async function
|
|
2796
|
+
async function Fn(e) {
|
|
2797
2797
|
for (let t of ["default", "reload"]) try {
|
|
2798
2798
|
let n = await fetch(e, {
|
|
2799
2799
|
mode: "cors",
|
|
@@ -2806,8 +2806,8 @@ async function In(e) {
|
|
|
2806
2806
|
}
|
|
2807
2807
|
//#endregion
|
|
2808
2808
|
//#region src/components/ShapeEditor/_model/imageTiles.ts
|
|
2809
|
-
var
|
|
2810
|
-
function
|
|
2809
|
+
var In = 4e3;
|
|
2810
|
+
function Ln(e, t, n = In) {
|
|
2811
2811
|
if (e <= 0 || t <= 0) return [];
|
|
2812
2812
|
let r = Math.ceil(e / n), i = Math.ceil(t / n);
|
|
2813
2813
|
return Array.from({ length: i }, (a, o) => Array.from({ length: r }, (a, s) => {
|
|
@@ -2822,7 +2822,7 @@ function Rn(e, t, n = Ln) {
|
|
|
2822
2822
|
};
|
|
2823
2823
|
})).flat();
|
|
2824
2824
|
}
|
|
2825
|
-
function
|
|
2825
|
+
function Rn(e, t) {
|
|
2826
2826
|
let n = document.createElement("canvas");
|
|
2827
2827
|
n.width = t.width, n.height = t.height;
|
|
2828
2828
|
let r = n.getContext("2d");
|
|
@@ -2830,7 +2830,7 @@ function zn(e, t) {
|
|
|
2830
2830
|
}
|
|
2831
2831
|
//#endregion
|
|
2832
2832
|
//#region src/components/ShapeEditor/_model/konva.ts
|
|
2833
|
-
function
|
|
2833
|
+
function zn(e, t, n) {
|
|
2834
2834
|
if (t === F.POINT) {
|
|
2835
2835
|
e.setAttrs({
|
|
2836
2836
|
x: n[0].x,
|
|
@@ -2866,17 +2866,17 @@ function Bn(e, t, n) {
|
|
|
2866
2866
|
}
|
|
2867
2867
|
//#endregion
|
|
2868
2868
|
//#region src/components/ShapeEditor/_model/pinIcon.ts
|
|
2869
|
-
var
|
|
2870
|
-
function
|
|
2871
|
-
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${
|
|
2869
|
+
var Bn = "M8 0C12.4183 0 16 3.58172 16 8C16 11.5323 13.71 14.5277 10.5342 15.5879L10.166 20.0068C10.0721 21.1334 9.13046 22 8 22C6.86954 22 5.92786 21.1334 5.83398 20.0068L5.46484 15.5879C2.28949 14.5275 0 11.532 0 8C0 3.58172 3.58172 0 8 0Z", Vn = "#ffffff", Hn = 1.5;
|
|
2870
|
+
function Un(e) {
|
|
2871
|
+
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${Bn}" fill="${e}" stroke="${Vn}" stroke-width="${Hn}"/></svg>`;
|
|
2872
2872
|
}
|
|
2873
2873
|
//#endregion
|
|
2874
2874
|
//#region src/components/ShapeEditor/_renderers/transformSession.ts
|
|
2875
|
-
var
|
|
2875
|
+
var Wn = Math.PI / 12;
|
|
2876
2876
|
function Gn(e, t) {
|
|
2877
2877
|
return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type === F.ROTATED_RECTANGLE;
|
|
2878
2878
|
}
|
|
2879
|
-
function
|
|
2879
|
+
function Q(e, t, n) {
|
|
2880
2880
|
if (e.kind === "resize") {
|
|
2881
2881
|
let r = n ? e.box : V(e.anchor, e.box, t.x, t.y);
|
|
2882
2882
|
return {
|
|
@@ -2907,7 +2907,7 @@ function Kn(e, t, n) {
|
|
|
2907
2907
|
}
|
|
2908
2908
|
if (e.kind === "rotate") {
|
|
2909
2909
|
let n = Math.atan2(t.y - e.center.y, t.x - e.center.x) - e.startAngle;
|
|
2910
|
-
return e.shiftKey && (n = Math.round(n /
|
|
2910
|
+
return e.shiftKey && (n = Math.round(n / Wn) * Wn), {
|
|
2911
2911
|
updates: [{
|
|
2912
2912
|
id: e.id,
|
|
2913
2913
|
points: e.points.map((t) => ue(t, e.center, n))
|
|
@@ -2927,13 +2927,13 @@ function Kn(e, t, n) {
|
|
|
2927
2927
|
box: B(a)
|
|
2928
2928
|
};
|
|
2929
2929
|
}
|
|
2930
|
-
function
|
|
2930
|
+
function Kn(e, t) {
|
|
2931
2931
|
return t.kind === "move" || t.kind === "vertex" ? t.start : t.kind === "rotate" ? {
|
|
2932
2932
|
x: t.center.x + Math.cos(t.startAngle),
|
|
2933
2933
|
y: t.center.y + Math.sin(t.startAngle)
|
|
2934
2934
|
} : Gn(e, t) ? be(t.shapes[0].points)[z.indexOf(t.anchor)] : ce(t.anchor, t.box);
|
|
2935
2935
|
}
|
|
2936
|
-
function
|
|
2936
|
+
function qn(e, t, n) {
|
|
2937
2937
|
let r = e.filter((e) => t.includes(e.id) && L(e)).map((e) => ({
|
|
2938
2938
|
id: e.id,
|
|
2939
2939
|
points: e.points
|
|
@@ -2945,27 +2945,27 @@ function Jn(e, t, n) {
|
|
|
2945
2945
|
shapes: r
|
|
2946
2946
|
} : null;
|
|
2947
2947
|
}
|
|
2948
|
-
function
|
|
2948
|
+
function Jn(e) {
|
|
2949
2949
|
return e.map((e) => ({
|
|
2950
2950
|
...e,
|
|
2951
2951
|
points: e.points.map((e) => ({ ...e }))
|
|
2952
2952
|
}));
|
|
2953
2953
|
}
|
|
2954
|
-
function
|
|
2954
|
+
function Yn(e, t) {
|
|
2955
2955
|
let n = new Set(t);
|
|
2956
2956
|
return e.filter((e) => n.has(e.id) && oe(e));
|
|
2957
2957
|
}
|
|
2958
|
-
function
|
|
2958
|
+
function Xn(e, t) {
|
|
2959
2959
|
return e.filter((e) => {
|
|
2960
2960
|
if (!I(e)) return !1;
|
|
2961
2961
|
let n = B(e.points);
|
|
2962
2962
|
return n.minX <= t.maxX && n.maxX >= t.minX && n.minY <= t.maxY && n.maxY >= t.minY;
|
|
2963
2963
|
}).map((e) => e.id);
|
|
2964
2964
|
}
|
|
2965
|
-
function
|
|
2966
|
-
return (e ?
|
|
2965
|
+
function Zn(e, t, n) {
|
|
2966
|
+
return (e ? Ue(e, { strokeWidth: t }).pointRadius : 5) / (n || 1);
|
|
2967
2967
|
}
|
|
2968
|
-
function
|
|
2968
|
+
function Qn(e, t) {
|
|
2969
2969
|
return {
|
|
2970
2970
|
minX: e.x - t,
|
|
2971
2971
|
minY: e.y - t,
|
|
@@ -2973,9 +2973,9 @@ function $n(e, t) {
|
|
|
2973
2973
|
maxY: e.y + t
|
|
2974
2974
|
};
|
|
2975
2975
|
}
|
|
2976
|
-
function
|
|
2976
|
+
function $n(e, t, n) {
|
|
2977
2977
|
if (e.type === F.ROTATED_RECTANGLE) return t;
|
|
2978
|
-
let r = e.type === F.POINT ?
|
|
2978
|
+
let r = e.type === F.POINT ? Qn(t[0], n) : B(t);
|
|
2979
2979
|
return de([{
|
|
2980
2980
|
x: r.minX,
|
|
2981
2981
|
y: r.minY
|
|
@@ -2984,17 +2984,17 @@ function er(e, t, n) {
|
|
|
2984
2984
|
y: r.maxY
|
|
2985
2985
|
}]);
|
|
2986
2986
|
}
|
|
2987
|
-
function
|
|
2987
|
+
function er(e) {
|
|
2988
2988
|
return 24 / (e || 1);
|
|
2989
2989
|
}
|
|
2990
|
-
function
|
|
2990
|
+
function tr(e, t) {
|
|
2991
2991
|
return Math.atan2(t.y - e.y, t.x - e.x);
|
|
2992
2992
|
}
|
|
2993
2993
|
//#endregion
|
|
2994
2994
|
//#region src/components/ShapeEditor/_renderers/KonvaRenderer.ts
|
|
2995
|
-
var
|
|
2995
|
+
var nr = 2, rr = "#1e88e5", ir = "#669def", ar = class {
|
|
2996
2996
|
constructor(e, t) {
|
|
2997
|
-
this.layer = new A.Layer(), this.world = new A.Group(), this.bgGroup = new A.Group(), this.overlayGroup = new A.Group({ listening: !1 }), this.guideOverlayGroup = new A.Group({ listening: !1 }), this.regionOverlayGroup = new A.Group({ listening: !1 }), this.dimOverlayGroup = new A.Group({ listening: !1 }), this.shapeGroup = new A.Group(), this.selGroup = new A.Group(), this.previewGroup = new A.Group(), this.handleGroup = new A.Group(), this.baseCursor = "default", this.strokeSize =
|
|
2997
|
+
this.layer = new A.Layer(), this.world = new A.Group(), this.bgGroup = new A.Group(), this.overlayGroup = new A.Group({ listening: !1 }), this.guideOverlayGroup = new A.Group({ listening: !1 }), this.regionOverlayGroup = new A.Group({ listening: !1 }), this.dimOverlayGroup = new A.Group({ listening: !1 }), this.shapeGroup = new A.Group(), this.selGroup = new A.Group(), this.previewGroup = new A.Group(), this.handleGroup = new A.Group(), this.baseCursor = "default", this.strokeSize = nr, this.imageSmoothing = !0, this.imageWidth = 0, this.imageHeight = 0, this.shapes = [], this.selected = [], this.nodes = /* @__PURE__ */ new Map(), this.altNodes = /* @__PURE__ */ new Map(), this.lastAppliedScale = -1, this.imageLoadToken = 0, this.transformEnabled = !1, this.handleNodes = [], this.vertexNodes = [], this.lastImg = {
|
|
2998
2998
|
x: 0,
|
|
2999
2999
|
y: 0
|
|
3000
3000
|
}, this.lastDragImg = null, this.ro = null, this.activeDrag = null, this.midNodes = [], this.ghostNode = null, this.selectedVertices = /* @__PURE__ */ new Set(), this.vertexPolygonId = null, this.editingId = null, this.rotNode = null, this.rotLineNode = null, this.transformerOutline = null, this.selectionBorders = [], this.upCleanup = null, this.lastPreviewPoly = null, this.preview = null, this.marquee = null, this.host = e, this.cb = t, this.stage = new A.Stage({
|
|
@@ -3086,7 +3086,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3086
3086
|
return this.world.getAbsoluteTransform().point(e);
|
|
3087
3087
|
}
|
|
3088
3088
|
async setImage(e, t, n) {
|
|
3089
|
-
let r = ++this.imageLoadToken, i = await
|
|
3089
|
+
let r = ++this.imageLoadToken, i = await Fn(e);
|
|
3090
3090
|
await new Promise((a) => {
|
|
3091
3091
|
let o = new Image();
|
|
3092
3092
|
i || (o.crossOrigin = "anonymous"), o.onload = () => {
|
|
@@ -3097,7 +3097,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3097
3097
|
x: e / o.naturalWidth,
|
|
3098
3098
|
y: s / o.naturalHeight
|
|
3099
3099
|
}), this.bgGroup.destroyChildren();
|
|
3100
|
-
for (let e of
|
|
3100
|
+
for (let e of Ln(o.naturalWidth, o.naturalHeight)) this.bgGroup.add(new A.Image({
|
|
3101
3101
|
image: o,
|
|
3102
3102
|
x: e.x,
|
|
3103
3103
|
y: e.y,
|
|
@@ -3156,7 +3156,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3156
3156
|
if (this.regionOverlayGroup.add(new A.Shape({
|
|
3157
3157
|
listening: !1,
|
|
3158
3158
|
sceneFunc: (r) => {
|
|
3159
|
-
|
|
3159
|
+
Ft(r._context, e, t, n);
|
|
3160
3160
|
}
|
|
3161
3161
|
})), e.outlineStyles) {
|
|
3162
3162
|
let t = (e, t) => {
|
|
@@ -3212,7 +3212,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3212
3212
|
let e = this.lastPreviewPoly;
|
|
3213
3213
|
e && this.previewPoly(e.points, e.cursor, e.style, e.closed, e.selectedPointIndices, e.showVertices);
|
|
3214
3214
|
}
|
|
3215
|
-
this.activeDrag ? this.dragTransform(this.lastDragImg ??
|
|
3215
|
+
this.activeDrag ? this.dragTransform(this.lastDragImg ?? Kn(this.shapes, this.activeDrag)) : this.drawTransformer(), this.layer.batchDraw(), this.cb.onViewportChange?.();
|
|
3216
3216
|
}
|
|
3217
3217
|
fit() {
|
|
3218
3218
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -3241,10 +3241,10 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3241
3241
|
});
|
|
3242
3242
|
}
|
|
3243
3243
|
setShapes(e, t) {
|
|
3244
|
-
if (this.shapes =
|
|
3244
|
+
if (this.shapes = Jn(e), this.selected = t, !this.activeDrag) {
|
|
3245
3245
|
this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
|
|
3246
3246
|
for (let t of R(e).filter(ie)) {
|
|
3247
|
-
let e = this.makeNode(t), n =
|
|
3247
|
+
let e = this.makeNode(t), n = Ue(t, { strokeWidth: this.strokeSize });
|
|
3248
3248
|
if (t.style?.alternateColor && n.dash?.length && t.type !== F.POINT) {
|
|
3249
3249
|
let n = e.clone({
|
|
3250
3250
|
id: `${t.id}__alt`,
|
|
@@ -3275,7 +3275,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3275
3275
|
t.size === this.selectedVertices.size && [...t].every((e) => this.selectedVertices.has(e)) || (this.selectedVertices = t, this.activeDrag || (this.drawTransformer(), this.layer.batchDraw()));
|
|
3276
3276
|
}
|
|
3277
3277
|
makeNode(e) {
|
|
3278
|
-
let { type: t, points: n } = e, r =
|
|
3278
|
+
let { type: t, points: n } = e, r = Ue(e, { strokeWidth: this.strokeSize }), i = I(e), a = {
|
|
3279
3279
|
id: e.id,
|
|
3280
3280
|
stroke: r.color,
|
|
3281
3281
|
strokeWidth: r.strokeWidth,
|
|
@@ -3283,11 +3283,11 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3283
3283
|
opacity: r.opacity,
|
|
3284
3284
|
strokeScaleEnabled: !1,
|
|
3285
3285
|
listening: i
|
|
3286
|
-
}, o = r.fillVisible ?
|
|
3286
|
+
}, o = r.fillVisible ? We(r.color, r.fillAlpha) : void 0;
|
|
3287
3287
|
if (t === F.POINT) {
|
|
3288
3288
|
let t = 1 / (this.world.scaleX() || 1), a = new A.Path({
|
|
3289
3289
|
id: e.id,
|
|
3290
|
-
data:
|
|
3290
|
+
data: Bn,
|
|
3291
3291
|
x: n[0].x,
|
|
3292
3292
|
y: n[0].y,
|
|
3293
3293
|
offsetX: 16 / 2,
|
|
@@ -3295,8 +3295,8 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3295
3295
|
scaleX: t,
|
|
3296
3296
|
scaleY: t,
|
|
3297
3297
|
fill: r.color,
|
|
3298
|
-
stroke:
|
|
3299
|
-
strokeWidth:
|
|
3298
|
+
stroke: Vn,
|
|
3299
|
+
strokeWidth: Hn,
|
|
3300
3300
|
strokeScaleEnabled: !1,
|
|
3301
3301
|
shadowColor: "#000",
|
|
3302
3302
|
shadowBlur: 2,
|
|
@@ -3341,13 +3341,13 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3341
3341
|
liveUpdateShape(e, t) {
|
|
3342
3342
|
let n = this.nodes.get(e), r = this.shapes.find((t) => t.id === e);
|
|
3343
3343
|
if (n && r) {
|
|
3344
|
-
|
|
3344
|
+
zn(n, r.type, t);
|
|
3345
3345
|
let i = this.altNodes.get(e);
|
|
3346
|
-
i &&
|
|
3346
|
+
i && zn(i, r.type, t), r.type === F.POINT && n instanceof A.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
|
|
3347
3347
|
}
|
|
3348
3348
|
}
|
|
3349
3349
|
pointRadius(e) {
|
|
3350
|
-
return
|
|
3350
|
+
return Zn(e, this.strokeSize, this.world.scaleX() || 1);
|
|
3351
3351
|
}
|
|
3352
3352
|
scaledDash(e) {
|
|
3353
3353
|
return e;
|
|
@@ -3363,11 +3363,11 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3363
3363
|
});
|
|
3364
3364
|
continue;
|
|
3365
3365
|
}
|
|
3366
|
-
n?.dash(this.scaledDash(
|
|
3366
|
+
n?.dash(this.scaledDash(Ue(t, { strokeWidth: this.strokeSize }).dash));
|
|
3367
3367
|
}
|
|
3368
3368
|
}
|
|
3369
3369
|
shapesIntersecting(e) {
|
|
3370
|
-
return
|
|
3370
|
+
return Xn(this.shapes, e);
|
|
3371
3371
|
}
|
|
3372
3372
|
drawSelectionBorders() {
|
|
3373
3373
|
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && I(t)) : [];
|
|
@@ -3376,7 +3376,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3376
3376
|
this.selectionBorders = t.map(() => {
|
|
3377
3377
|
let e = new A.Line({
|
|
3378
3378
|
closed: !0,
|
|
3379
|
-
stroke:
|
|
3379
|
+
stroke: ir,
|
|
3380
3380
|
strokeWidth: 1.5,
|
|
3381
3381
|
strokeScaleEnabled: !1,
|
|
3382
3382
|
listening: !1
|
|
@@ -3397,7 +3397,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3397
3397
|
}
|
|
3398
3398
|
}
|
|
3399
3399
|
selectionOutlinePoints(e, t) {
|
|
3400
|
-
return
|
|
3400
|
+
return $n(e, t, this.pointRadius(e));
|
|
3401
3401
|
}
|
|
3402
3402
|
clearPreview() {
|
|
3403
3403
|
this.lastPreviewPoly = null, this.previewGroup.destroyChildren(), this.layer.batchDraw();
|
|
@@ -3460,8 +3460,8 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3460
3460
|
x: n.x,
|
|
3461
3461
|
y: n.y,
|
|
3462
3462
|
radius: (r ? 6 : 5) / l,
|
|
3463
|
-
fill: r ?
|
|
3464
|
-
stroke: r ? "#ffffff" :
|
|
3463
|
+
fill: r ? rr : "#ffffff",
|
|
3464
|
+
stroke: r ? "#ffffff" : rr,
|
|
3465
3465
|
strokeWidth: 1.5,
|
|
3466
3466
|
strokeScaleEnabled: !1,
|
|
3467
3467
|
listening: !1
|
|
@@ -3471,7 +3471,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3471
3471
|
}
|
|
3472
3472
|
previewScalarMask(e, t) {
|
|
3473
3473
|
this.previewGroup.destroyChildren();
|
|
3474
|
-
let n =
|
|
3474
|
+
let n = mn(e, t.length === 7 ? `${t}99` : t);
|
|
3475
3475
|
this.previewGroup.add(new A.Image({
|
|
3476
3476
|
image: n,
|
|
3477
3477
|
x: e.ox,
|
|
@@ -3483,8 +3483,8 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3483
3483
|
}
|
|
3484
3484
|
previewMarquee(e, t) {
|
|
3485
3485
|
this.marquee || (this.marquee = new A.Rect({
|
|
3486
|
-
fill:
|
|
3487
|
-
stroke:
|
|
3486
|
+
fill: We(Be, Ve),
|
|
3487
|
+
stroke: Be,
|
|
3488
3488
|
strokeWidth: 1,
|
|
3489
3489
|
strokeScaleEnabled: !1,
|
|
3490
3490
|
listening: !1,
|
|
@@ -3515,14 +3515,14 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3515
3515
|
setTransformerOutlinePoints(e) {
|
|
3516
3516
|
e.length < 2 || (this.transformerOutline || (this.transformerOutline = new A.Line({
|
|
3517
3517
|
closed: !0,
|
|
3518
|
-
stroke:
|
|
3518
|
+
stroke: rr,
|
|
3519
3519
|
strokeWidth: 1,
|
|
3520
3520
|
strokeScaleEnabled: !1,
|
|
3521
3521
|
listening: !1
|
|
3522
3522
|
}), this.selGroup.add(this.transformerOutline)), this.transformerOutline.points(e.flatMap((e) => [e.x, e.y])));
|
|
3523
3523
|
}
|
|
3524
3524
|
rotationHandleGap() {
|
|
3525
|
-
return
|
|
3525
|
+
return er(this.viewport.scale);
|
|
3526
3526
|
}
|
|
3527
3527
|
rotationHandleScreenPoint(e) {
|
|
3528
3528
|
return this.imgToScreen(xe(e, this.rotationHandleGap()));
|
|
@@ -3541,7 +3541,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3541
3541
|
n.x,
|
|
3542
3542
|
n.y
|
|
3543
3543
|
],
|
|
3544
|
-
stroke:
|
|
3544
|
+
stroke: rr,
|
|
3545
3545
|
strokeWidth: 1,
|
|
3546
3546
|
listening: !1
|
|
3547
3547
|
}), this.handleGroup.add(this.rotLineNode));
|
|
@@ -3556,7 +3556,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3556
3556
|
}), e.rotation(n * 180 / Math.PI);
|
|
3557
3557
|
}
|
|
3558
3558
|
orientedHandleAngle(e) {
|
|
3559
|
-
return
|
|
3559
|
+
return tr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
3560
3560
|
}
|
|
3561
3561
|
repositionOrientedHandles(e) {
|
|
3562
3562
|
let t = this.orientedHandleAngle(e);
|
|
@@ -3578,7 +3578,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3578
3578
|
for (let e of this.vertexNodes) e.destroy();
|
|
3579
3579
|
for (let e of this.midNodes) e.destroy();
|
|
3580
3580
|
if (this.ghostNode?.destroy(), this.ghostNode = null, this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
|
|
3581
|
-
let e =
|
|
3581
|
+
let e = Yn(this.shapes, this.selected);
|
|
3582
3582
|
if (!e.length || e.length === 1 && e[0].type === F.POINT) return;
|
|
3583
3583
|
let t = e.length === 1 && (e[0].type === F.POLYGON || e[0].type === F.LINE) && this.editingId === e[0].id ? e[0] : null, n = B(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === F.ROTATED_RECTANGLE ? e[0] : null, i = r ? be(r.points) : z.map((e) => ce(e, n));
|
|
3584
3584
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
@@ -3593,12 +3593,12 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3593
3593
|
offsetY: 4,
|
|
3594
3594
|
rotation: a * 180 / Math.PI,
|
|
3595
3595
|
fill: "#ffffff",
|
|
3596
|
-
stroke:
|
|
3596
|
+
stroke: rr,
|
|
3597
3597
|
strokeWidth: 1
|
|
3598
|
-
}), r =
|
|
3598
|
+
}), r = Ct(e, a);
|
|
3599
3599
|
this.bindCursor(n, r), n.on("mousedown", (t) => {
|
|
3600
3600
|
t.cancelBubble = !0, this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
3601
|
-
let n =
|
|
3601
|
+
let n = Yn(this.shapes, this.selected);
|
|
3602
3602
|
this.activeDrag = {
|
|
3603
3603
|
kind: "resize",
|
|
3604
3604
|
anchor: e,
|
|
@@ -3615,7 +3615,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3615
3615
|
radius: i * .8,
|
|
3616
3616
|
fill: "#ffffff",
|
|
3617
3617
|
opacity: .6,
|
|
3618
|
-
stroke:
|
|
3618
|
+
stroke: rr,
|
|
3619
3619
|
strokeWidth: 1,
|
|
3620
3620
|
visible: !1,
|
|
3621
3621
|
listening: !1
|
|
@@ -3675,8 +3675,8 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3675
3675
|
x: a.x,
|
|
3676
3676
|
y: a.y,
|
|
3677
3677
|
radius: i,
|
|
3678
|
-
fill: o ?
|
|
3679
|
-
stroke: o ? "#ffffff" :
|
|
3678
|
+
fill: o ? rr : "#ffffff",
|
|
3679
|
+
stroke: o ? "#ffffff" : rr,
|
|
3680
3680
|
strokeWidth: Math.max(1.5, i * .3)
|
|
3681
3681
|
});
|
|
3682
3682
|
this.bindCursor(s, "pointer"), s.on("mousedown", (t) => {
|
|
@@ -3701,7 +3701,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3701
3701
|
y: r.y,
|
|
3702
3702
|
radius: 6,
|
|
3703
3703
|
fill: "#ffffff",
|
|
3704
|
-
stroke:
|
|
3704
|
+
stroke: rr,
|
|
3705
3705
|
strokeWidth: 1.5
|
|
3706
3706
|
});
|
|
3707
3707
|
this.bindCursor(i, "grab"), i.on("mousedown", (e) => {
|
|
@@ -3720,7 +3720,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3720
3720
|
this.layer.batchDraw();
|
|
3721
3721
|
}
|
|
3722
3722
|
beginMove(e, t) {
|
|
3723
|
-
let n =
|
|
3723
|
+
let n = qn(this.shapes, t, e);
|
|
3724
3724
|
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === F.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
3725
3725
|
}
|
|
3726
3726
|
repositionHandles(e) {
|
|
@@ -3762,7 +3762,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3762
3762
|
let t = this.activeDrag;
|
|
3763
3763
|
if (!t) return;
|
|
3764
3764
|
this.applyCursor();
|
|
3765
|
-
let n = Gn(this.shapes, t), { updates: r, box: i } =
|
|
3765
|
+
let n = Gn(this.shapes, t), { updates: r, box: i } = Q(t, e, n);
|
|
3766
3766
|
for (let e of r) this.liveUpdateShape(e.id, e.points);
|
|
3767
3767
|
if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
|
|
3768
3768
|
n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
|
|
@@ -3789,18 +3789,18 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3789
3789
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
3790
3790
|
return;
|
|
3791
3791
|
}
|
|
3792
|
-
let { updates: n } =
|
|
3792
|
+
let { updates: n } = Q(e, t, Gn(this.shapes, e));
|
|
3793
3793
|
this.commitTransformUpdates(n);
|
|
3794
3794
|
}
|
|
3795
|
-
},
|
|
3796
|
-
function
|
|
3797
|
-
if (!e) return
|
|
3795
|
+
}, or = 2, sr = 58879, cr = 6725103;
|
|
3796
|
+
function $(e) {
|
|
3797
|
+
if (!e) return sr;
|
|
3798
3798
|
let t = e.replace("#", "");
|
|
3799
3799
|
return Number.parseInt(t.length === 3 ? t.replace(/./g, "$&$&") : t, 16);
|
|
3800
3800
|
}
|
|
3801
|
-
var
|
|
3801
|
+
var lr = class {
|
|
3802
3802
|
constructor(e, t) {
|
|
3803
|
-
this.app = new j(), this.world = new N(), this.bgLayer = new N(), this.overlayLayer = new N(), this.guideOverlayLayer = new N(), this.regionOverlayLayer = new N(), this.dimOverlayLayer = new N(), this.shapeLayer = new N(), this.selLayer = new N(), this.previewLayer = new N(), this.handleLayer = new N(), this.filter = new M(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.overlayTextures = [], this.region = null, this.regionDimMaskG = new P(), this.regionDimG = new P(), this.regionZoneMaskG = new P(), this.regionZoneG = new P(), this.regionOutlineG = new P(), this.baseCursor = "default", this.strokeSize =
|
|
3803
|
+
this.app = new j(), this.world = new N(), this.bgLayer = new N(), this.overlayLayer = new N(), this.guideOverlayLayer = new N(), this.regionOverlayLayer = new N(), this.dimOverlayLayer = new N(), this.shapeLayer = new N(), this.selLayer = new N(), this.previewLayer = new N(), this.handleLayer = new N(), this.filter = new M(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.overlayTextures = [], this.region = null, this.regionDimMaskG = new P(), this.regionDimG = new P(), this.regionZoneMaskG = new P(), this.regionZoneG = new P(), this.regionOutlineG = new P(), this.baseCursor = "default", this.strokeSize = or, this.shapes = [], this.selected = [], this.nodes = /* @__PURE__ */ new Map(), this.lastAppliedScale = -1, this.brightness = 1, this.contrast = 1, this.imageSmoothing = !0, this.destroyed = !1, this.transformEnabled = !1, this.handleNodes = [], this.vertexNodes = [], this.lastDragImg = null, this.activeDrag = null, this.midNodes = [], this.ghostNode = null, this.selectedVertices = /* @__PURE__ */ new Set(), this.vertexPolygonId = null, this.editingId = null, this.rotNode = null, this.rotLineNode = null, this.transformerOutline = null, this.selectionBorderGfx = [], this.previewG = new P(), this.marqueeG = new P(), this.previewMaskSprite = null, this.previewMaskTexture = null, this.previewReady = !1, this.lastPreview = null, this.host = e, this.cb = t;
|
|
3804
3804
|
}
|
|
3805
3805
|
ev(e) {
|
|
3806
3806
|
return {
|
|
@@ -3898,7 +3898,7 @@ var dr = class {
|
|
|
3898
3898
|
};
|
|
3899
3899
|
}
|
|
3900
3900
|
async setImage(e, t, n) {
|
|
3901
|
-
let r = ++this.imageLoadToken, i = await
|
|
3901
|
+
let r = ++this.imageLoadToken, i = await Fn(e);
|
|
3902
3902
|
if (this.destroyed) {
|
|
3903
3903
|
i && URL.revokeObjectURL(i);
|
|
3904
3904
|
return;
|
|
@@ -3910,8 +3910,8 @@ var dr = class {
|
|
|
3910
3910
|
this.imageWidth = t?.width ?? o.naturalWidth, this.imageHeight = t?.height ?? o.naturalHeight;
|
|
3911
3911
|
let e = n?.width ?? this.imageWidth, s = n?.height ?? this.imageHeight;
|
|
3912
3912
|
this.bgLayer.scale.set(e / o.naturalWidth, s / o.naturalHeight), this.clearImageTiles();
|
|
3913
|
-
for (let e of
|
|
3914
|
-
let t = re.from(
|
|
3913
|
+
for (let e of Ln(o.naturalWidth, o.naturalHeight)) {
|
|
3914
|
+
let t = re.from(Rn(o, e));
|
|
3915
3915
|
t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
|
|
3916
3916
|
let n = new ne(t);
|
|
3917
3917
|
n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
|
|
@@ -3974,7 +3974,7 @@ var dr = class {
|
|
|
3974
3974
|
}
|
|
3975
3975
|
setRegionOverlay(e) {
|
|
3976
3976
|
if (this.region = e, this.regionDimMaskG.clear(), this.regionDimG.clear(), this.regionZoneMaskG.clear(), this.regionZoneG.clear(), this.regionOutlineG.clear(), !e) return;
|
|
3977
|
-
let t =
|
|
3977
|
+
let t = $(e.dim.color);
|
|
3978
3978
|
for (let t of e.rects) this.regionDimMaskG.rect(t.x, t.y, t.w, t.h).fill(16777215), this.regionZoneMaskG.rect(t.x, t.y, t.w, t.h).fill(16777215);
|
|
3979
3979
|
this.regionDimG.rect(0, 0, this.imageWidth, this.imageHeight).fill({
|
|
3980
3980
|
color: t,
|
|
@@ -3995,7 +3995,7 @@ var dr = class {
|
|
|
3995
3995
|
}
|
|
3996
3996
|
applyViewport(e) {
|
|
3997
3997
|
let t = e.scale !== this.lastAppliedScale;
|
|
3998
|
-
this.lastAppliedScale = e.scale, this.world.scale.set(e.scale), this.world.position.set(e.x, e.y), this.world.visible = !0, t && this.restrokeShapes(), this.activeDrag ? this.dragTransform(this.lastDragImg ??
|
|
3998
|
+
this.lastAppliedScale = e.scale, this.world.scale.set(e.scale), this.world.position.set(e.x, e.y), this.world.visible = !0, t && this.restrokeShapes(), this.activeDrag ? this.dragTransform(this.lastDragImg ?? Kn(this.shapes, this.activeDrag)) : this.drawTransformer(), this.cb.onViewportChange?.();
|
|
3999
3999
|
}
|
|
4000
4000
|
fit() {
|
|
4001
4001
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -4031,7 +4031,7 @@ var dr = class {
|
|
|
4031
4031
|
});
|
|
4032
4032
|
}
|
|
4033
4033
|
setShapes(e, t) {
|
|
4034
|
-
this.shapes =
|
|
4034
|
+
this.shapes = Jn(e), this.selected = t, !this.activeDrag && (this.drawShapes(), this.drawSelectionBorders(), this.drawTransformer());
|
|
4035
4035
|
}
|
|
4036
4036
|
setSelection(e) {
|
|
4037
4037
|
this.selected = e, (e.length !== 1 || e[0] !== this.vertexPolygonId) && (this.vertexPolygonId = null, this.selectedVertices.clear()), this.editingId && (e.length !== 1 || e[0] !== this.editingId) && (this.editingId = null), !this.activeDrag && (this.drawSelectionBorders(), this.drawTransformer());
|
|
@@ -4054,13 +4054,13 @@ var dr = class {
|
|
|
4054
4054
|
this.handleLayer.interactiveChildren = !e;
|
|
4055
4055
|
}
|
|
4056
4056
|
strokeW(e) {
|
|
4057
|
-
return (e ?
|
|
4057
|
+
return (e ? Ue(e, { strokeWidth: this.strokeSize }).strokeWidth : or) / this.world.scale.x;
|
|
4058
4058
|
}
|
|
4059
4059
|
pointRadius(e) {
|
|
4060
|
-
return
|
|
4060
|
+
return Zn(e, this.strokeSize, this.world.scale.x);
|
|
4061
4061
|
}
|
|
4062
4062
|
dashForShape(e) {
|
|
4063
|
-
let t =
|
|
4063
|
+
let t = Ue(e, { strokeWidth: this.strokeSize }).dash;
|
|
4064
4064
|
if (!t?.length) return null;
|
|
4065
4065
|
let n = this.world.scale.x || 1;
|
|
4066
4066
|
return [t[0] / n, (t[1] ?? t[0]) / n];
|
|
@@ -4082,9 +4082,9 @@ var dr = class {
|
|
|
4082
4082
|
}
|
|
4083
4083
|
paintShape(e, t) {
|
|
4084
4084
|
e.clear();
|
|
4085
|
-
let n =
|
|
4085
|
+
let n = Ue(t, { strokeWidth: this.strokeSize }), r = $(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
|
|
4086
4086
|
if (t.type === F.POINT) {
|
|
4087
|
-
e.svg(
|
|
4087
|
+
e.svg(Un(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
|
|
4088
4088
|
let r = 1 / (this.world.scale.x || 1);
|
|
4089
4089
|
e.scale.set(r, r), e.alpha = a;
|
|
4090
4090
|
return;
|
|
@@ -4106,7 +4106,7 @@ var dr = class {
|
|
|
4106
4106
|
if (o) {
|
|
4107
4107
|
t.style?.alternateColor && (this.path(e, t), e.stroke({
|
|
4108
4108
|
width: i,
|
|
4109
|
-
color:
|
|
4109
|
+
color: $(t.style.alternateColor),
|
|
4110
4110
|
alpha: a
|
|
4111
4111
|
})), this.dashedStrokeShape(e, t, i, r, a, o);
|
|
4112
4112
|
return;
|
|
@@ -4125,7 +4125,7 @@ var dr = class {
|
|
|
4125
4125
|
});
|
|
4126
4126
|
}
|
|
4127
4127
|
shapesIntersecting(e) {
|
|
4128
|
-
return
|
|
4128
|
+
return Xn(this.shapes, e);
|
|
4129
4129
|
}
|
|
4130
4130
|
shapesAt(e) {
|
|
4131
4131
|
return this.shapes.filter((t) => {
|
|
@@ -4162,16 +4162,16 @@ var dr = class {
|
|
|
4162
4162
|
}, a = this.strokeW(i);
|
|
4163
4163
|
r.alternateColor && (this.path(this.previewG, i), this.previewG.stroke({
|
|
4164
4164
|
width: a,
|
|
4165
|
-
color:
|
|
4165
|
+
color: $(r.alternateColor)
|
|
4166
4166
|
}));
|
|
4167
4167
|
let o = this.dashForShape(i);
|
|
4168
4168
|
if (o) {
|
|
4169
|
-
this.dashedStrokeShape(this.previewG, i, a,
|
|
4169
|
+
this.dashedStrokeShape(this.previewG, i, a, $(r.color ?? "#00e5ff"), r.opacity ?? 1, o);
|
|
4170
4170
|
return;
|
|
4171
4171
|
}
|
|
4172
4172
|
this.path(this.previewG, i), this.previewG.stroke({
|
|
4173
4173
|
width: a,
|
|
4174
|
-
color:
|
|
4174
|
+
color: $(r.color ?? "#00e5ff"),
|
|
4175
4175
|
alpha: r.opacity ?? 1
|
|
4176
4176
|
});
|
|
4177
4177
|
}
|
|
@@ -4193,12 +4193,12 @@ var dr = class {
|
|
|
4193
4193
|
}, c = this.strokeW(s);
|
|
4194
4194
|
n.alternateColor && (this.path(this.previewG, s), this.previewG.stroke({
|
|
4195
4195
|
width: c,
|
|
4196
|
-
color:
|
|
4196
|
+
color: $(n.alternateColor)
|
|
4197
4197
|
}));
|
|
4198
4198
|
let l = this.dashForShape(s);
|
|
4199
|
-
if (l ? this.dashedStrokeShape(this.previewG, s, c,
|
|
4199
|
+
if (l ? this.dashedStrokeShape(this.previewG, s, c, $(n.color ?? "#00e5ff"), n.opacity ?? 1, l) : (this.path(this.previewG, s), this.previewG.stroke({
|
|
4200
4200
|
width: c,
|
|
4201
|
-
color:
|
|
4201
|
+
color: $(n.color ?? "#00e5ff"),
|
|
4202
4202
|
alpha: n.opacity ?? 1
|
|
4203
4203
|
})), !a) return;
|
|
4204
4204
|
let u = new Set(i), d = 5 / this.world.scale.x, f = 6 / this.world.scale.x;
|
|
@@ -4212,15 +4212,15 @@ var dr = class {
|
|
|
4212
4212
|
}
|
|
4213
4213
|
previewScalarMask(e, t) {
|
|
4214
4214
|
this.lastPreview = null, this.ensurePreview(), this.previewG.clear();
|
|
4215
|
-
let n =
|
|
4215
|
+
let n = mn(e, t.length === 7 ? `${t}99` : t);
|
|
4216
4216
|
this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture = re.from(n), this.previewMaskSprite ? (this.previewMaskSprite.texture = this.previewMaskTexture, this.previewMaskSprite.visible = !0) : (this.previewMaskSprite = new ne(this.previewMaskTexture), this.previewLayer.addChildAt(this.previewMaskSprite, 0)), this.previewMaskSprite.x = e.ox, this.previewMaskSprite.y = e.oy, this.previewMaskSprite.width = n.width / e.scale, this.previewMaskSprite.height = n.height / e.scale;
|
|
4217
4217
|
}
|
|
4218
4218
|
previewMarquee(e, t) {
|
|
4219
4219
|
this.ensurePreview(), this.marqueeG.clear();
|
|
4220
|
-
let n = Math.min(e.x, t.x), r = Math.min(e.y, t.y), i = Math.abs(t.x - e.x), a = Math.abs(t.y - e.y), o =
|
|
4220
|
+
let n = Math.min(e.x, t.x), r = Math.min(e.y, t.y), i = Math.abs(t.x - e.x), a = Math.abs(t.y - e.y), o = $(Be);
|
|
4221
4221
|
this.marqueeG.rect(n, r, i, a).fill({
|
|
4222
4222
|
color: o,
|
|
4223
|
-
alpha:
|
|
4223
|
+
alpha: Ve
|
|
4224
4224
|
}).stroke({
|
|
4225
4225
|
width: 1 / this.world.scale.x,
|
|
4226
4226
|
color: o
|
|
@@ -4251,8 +4251,8 @@ var dr = class {
|
|
|
4251
4251
|
o.y
|
|
4252
4252
|
], !1).stroke({
|
|
4253
4253
|
width: i,
|
|
4254
|
-
color:
|
|
4255
|
-
}), this.strokeDashedPolyline(e, [n, o], !1, i,
|
|
4254
|
+
color: $(r.underlayColor)
|
|
4255
|
+
}), this.strokeDashedPolyline(e, [n, o], !1, i, $(r.color), r.opacity, a);
|
|
4256
4256
|
};
|
|
4257
4257
|
r(this.region.visibleOutline, t.visible), r(this.region.occludedOutline, t.occluded);
|
|
4258
4258
|
}
|
|
@@ -4314,24 +4314,40 @@ var dr = class {
|
|
|
4314
4314
|
}
|
|
4315
4315
|
strokeDashedPolyline(e, t, n, r, i, a, o) {
|
|
4316
4316
|
if (t.length < 2) return;
|
|
4317
|
-
let [s, c] = o
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
if (
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4317
|
+
let [s, c] = o;
|
|
4318
|
+
if (!(s > 0) || !(c > 0)) return;
|
|
4319
|
+
let l = !0, u = 0, d = null, f = () => {
|
|
4320
|
+
if (d && d.length >= 2) {
|
|
4321
|
+
e.moveTo(d[0].x, d[0].y);
|
|
4322
|
+
for (let t = 1; t < d.length; t++) e.lineTo(d[t].x, d[t].y);
|
|
4323
|
+
e.stroke({
|
|
4324
|
+
width: r,
|
|
4325
|
+
color: i,
|
|
4326
|
+
alpha: a
|
|
4327
|
+
});
|
|
4328
|
+
}
|
|
4329
|
+
d = null;
|
|
4330
|
+
}, p = n ? t.length : t.length - 1;
|
|
4331
|
+
for (let e = 0; e < p; e++) {
|
|
4332
|
+
let n = t[e], r = t[(e + 1) % t.length], i = r.x - n.x, a = r.y - n.y, o = Math.hypot(i, a);
|
|
4333
|
+
if (!o) continue;
|
|
4334
|
+
let p = 0;
|
|
4335
|
+
for (; p < o;) {
|
|
4336
|
+
let e = l ? s : c, t = Math.min(e - u, o - p);
|
|
4324
4337
|
if (l) {
|
|
4325
|
-
let
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4338
|
+
let e = p / o, r = (p + t) / o;
|
|
4339
|
+
d ||= [{
|
|
4340
|
+
x: n.x + i * e,
|
|
4341
|
+
y: n.y + a * e
|
|
4342
|
+
}], d.push({
|
|
4343
|
+
x: n.x + i * r,
|
|
4344
|
+
y: n.y + a * r
|
|
4330
4345
|
});
|
|
4331
4346
|
}
|
|
4332
|
-
|
|
4347
|
+
p += t, u += t, u >= e - 1e-4 && (u = 0, l && f(), l = !l);
|
|
4333
4348
|
}
|
|
4334
4349
|
}
|
|
4350
|
+
f();
|
|
4335
4351
|
}
|
|
4336
4352
|
drawSelectionBorders() {
|
|
4337
4353
|
this.selLayer.position.set(0, 0);
|
|
@@ -4348,7 +4364,7 @@ var dr = class {
|
|
|
4348
4364
|
let r = this.selectionBorderGfx[t];
|
|
4349
4365
|
r.clear(), r.poly(this.selectionOutlinePoints(e, e.points).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4350
4366
|
width: n,
|
|
4351
|
-
color:
|
|
4367
|
+
color: cr
|
|
4352
4368
|
});
|
|
4353
4369
|
});
|
|
4354
4370
|
}
|
|
@@ -4359,12 +4375,12 @@ var dr = class {
|
|
|
4359
4375
|
let a = this.selectionBorderGfx[r++];
|
|
4360
4376
|
a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4361
4377
|
width: n,
|
|
4362
|
-
color:
|
|
4378
|
+
color: cr
|
|
4363
4379
|
}));
|
|
4364
4380
|
}
|
|
4365
4381
|
}
|
|
4366
4382
|
selectionOutlinePoints(e, t) {
|
|
4367
|
-
return
|
|
4383
|
+
return $n(e, t, this.pointRadius(e));
|
|
4368
4384
|
}
|
|
4369
4385
|
imgToScreen(e) {
|
|
4370
4386
|
let t = this.world.toGlobal({
|
|
@@ -4393,7 +4409,7 @@ var dr = class {
|
|
|
4393
4409
|
}));
|
|
4394
4410
|
}
|
|
4395
4411
|
rotationHandleGap() {
|
|
4396
|
-
return
|
|
4412
|
+
return er(this.viewport.scale);
|
|
4397
4413
|
}
|
|
4398
4414
|
rotationHandleScreenPoint(e) {
|
|
4399
4415
|
return this.imgToScreen(xe(e, this.rotationHandleGap()));
|
|
@@ -4409,7 +4425,7 @@ var dr = class {
|
|
|
4409
4425
|
e.position.set(t.x, t.y), e.rotation = n;
|
|
4410
4426
|
}
|
|
4411
4427
|
orientedHandleAngle(e) {
|
|
4412
|
-
return
|
|
4428
|
+
return tr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
4413
4429
|
}
|
|
4414
4430
|
drawTransformer() {
|
|
4415
4431
|
if (this.activeDrag) return;
|
|
@@ -4417,7 +4433,7 @@ var dr = class {
|
|
|
4417
4433
|
for (let e of this.vertexNodes) e.destroy();
|
|
4418
4434
|
for (let e of this.midNodes) e.destroy();
|
|
4419
4435
|
if (this.ghostNode?.destroy(), this.ghostNode = null, this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
|
|
4420
|
-
let e =
|
|
4436
|
+
let e = Yn(this.shapes, this.selected);
|
|
4421
4437
|
if (e.length === 0 || e.length === 1 && e[0].type === F.POINT) return;
|
|
4422
4438
|
let t = e.length === 1 && (e[0].type === F.POLYGON || e[0].type === F.LINE) && this.editingId === e[0].id ? e[0] : null, n = B(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === F.ROTATED_RECTANGLE ? e[0] : null, i = r ? be(r.points) : z.map((e) => ce(e, n));
|
|
4423
4439
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
@@ -4428,10 +4444,10 @@ var dr = class {
|
|
|
4428
4444
|
width: 1,
|
|
4429
4445
|
color: 2001125
|
|
4430
4446
|
}), this.layoutResizeHandle(n, t, a), n.eventMode = "static";
|
|
4431
|
-
let r =
|
|
4447
|
+
let r = Ct(e, a);
|
|
4432
4448
|
this.bindCursor(n, r), n.on("pointerdown", (t) => {
|
|
4433
4449
|
t.stopPropagation(), this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
4434
|
-
let n =
|
|
4450
|
+
let n = Yn(this.shapes, this.selected);
|
|
4435
4451
|
this.activeDrag = {
|
|
4436
4452
|
kind: "resize",
|
|
4437
4453
|
anchor: e,
|
|
@@ -4528,7 +4544,7 @@ var dr = class {
|
|
|
4528
4544
|
}
|
|
4529
4545
|
}
|
|
4530
4546
|
beginMove(e, t) {
|
|
4531
|
-
let n =
|
|
4547
|
+
let n = qn(this.shapes, t, e);
|
|
4532
4548
|
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === F.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4533
4549
|
}
|
|
4534
4550
|
repositionHandlesForBox(e) {
|
|
@@ -4596,7 +4612,7 @@ var dr = class {
|
|
|
4596
4612
|
let t = this.activeDrag;
|
|
4597
4613
|
if (!t) return;
|
|
4598
4614
|
this.applyCursor();
|
|
4599
|
-
let n = Gn(this.shapes, t), { updates: r, box: i } =
|
|
4615
|
+
let n = Gn(this.shapes, t), { updates: r, box: i } = Q(t, e, n);
|
|
4600
4616
|
if (t.kind === "move") {
|
|
4601
4617
|
let n = e.x - t.start.x, r = e.y - t.start.y;
|
|
4602
4618
|
for (let e of t.shapes) {
|
|
@@ -4628,13 +4644,13 @@ var dr = class {
|
|
|
4628
4644
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
4629
4645
|
return;
|
|
4630
4646
|
}
|
|
4631
|
-
let { updates: n } =
|
|
4647
|
+
let { updates: n } = Q(e, t, Gn(this.shapes, e));
|
|
4632
4648
|
e.kind === "move" && this.resetMoveOffsets(), this.commitTransformUpdates(n);
|
|
4633
4649
|
}
|
|
4634
4650
|
};
|
|
4635
4651
|
//#endregion
|
|
4636
4652
|
//#region src/components/ShapeEditor/_state/useEngineLifecycle.ts
|
|
4637
|
-
function
|
|
4653
|
+
function ur({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r }) {
|
|
4638
4654
|
if (!r) return e !== null || n !== null ? { kind: "clear" } : { kind: "none" };
|
|
4639
4655
|
let i = e !== t;
|
|
4640
4656
|
return !i && n === r ? { kind: "none" } : {
|
|
@@ -4642,7 +4658,7 @@ function fr({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r
|
|
|
4642
4658
|
docChange: i
|
|
4643
4659
|
};
|
|
4644
4660
|
}
|
|
4645
|
-
function
|
|
4661
|
+
function dr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImageUrl: i, makeCallbacks: a, viewRef: o, readOnlyRef: s, toolRef: c, renderShapesRef: l, coordinateSizeRef: u, imageSizeRef: d, selRef: f, maskCanvasRef: p, regionOverlayRef: m, dimmedRef: h, syncMinimap: g, setImage: _, setImageVisible: v, setReady: b, setImageStatus: x, onContextMenuRequest: S }) {
|
|
4646
4662
|
let C = T(i);
|
|
4647
4663
|
C.current = i;
|
|
4648
4664
|
let w = T(r);
|
|
@@ -4653,7 +4669,7 @@ function pr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
4653
4669
|
j.current = S, y(() => {
|
|
4654
4670
|
let r = t.current;
|
|
4655
4671
|
if (!r) return;
|
|
4656
|
-
let i = !1, a = null, y = null, x = A.current(), S = e === "konva" ? new
|
|
4672
|
+
let i = !1, a = null, y = null, x = A.current(), S = e === "konva" ? new ar(r, x) : new lr(r, x);
|
|
4657
4673
|
return n.current = S, (async () => {
|
|
4658
4674
|
if (await S.init(), i) return;
|
|
4659
4675
|
if (S.setFilter(o.current.brightness, o.current.contrast), S.setRenderDefaults({ strokeWidth: o.current.strokeSize }), S.setImageSmoothing(o.current.imageSmoothing), S.setTransformEnabled(!s.current), O.current = !0, C.current) {
|
|
@@ -4684,7 +4700,7 @@ function pr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
4684
4700
|
}
|
|
4685
4701
|
S.zoomAt(t.clientX - n.left, t.clientY - n.top, e(t.deltaY, r));
|
|
4686
4702
|
}, S.dom.addEventListener("wheel", a, { passive: !1 }), y = (e) => {
|
|
4687
|
-
if (e.preventDefault(), c.current ===
|
|
4703
|
+
if (e.preventDefault(), c.current === W.ASSISTANT_POINT && e.altKey) return;
|
|
4688
4704
|
let t = r.getBoundingClientRect(), n = e.clientX - t.left, i = e.clientY - t.top, a = S.viewport;
|
|
4689
4705
|
j.current({
|
|
4690
4706
|
x: n,
|
|
@@ -4704,7 +4720,7 @@ function pr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
4704
4720
|
}, [e]), y(() => {
|
|
4705
4721
|
let e = n.current;
|
|
4706
4722
|
if (!e || !O.current) return;
|
|
4707
|
-
let t =
|
|
4723
|
+
let t = ur({
|
|
4708
4724
|
currentDocId: D.current,
|
|
4709
4725
|
documentId: r,
|
|
4710
4726
|
loadedUrl: E.current,
|
|
@@ -4748,19 +4764,19 @@ function pr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
4748
4764
|
}
|
|
4749
4765
|
//#endregion
|
|
4750
4766
|
//#region src/components/ShapeEditor/_state/useMinimapNavigation.ts
|
|
4751
|
-
var
|
|
4752
|
-
function
|
|
4767
|
+
var fr = .05, pr = 20;
|
|
4768
|
+
function mr(e) {
|
|
4753
4769
|
let { deltaY: t, deltaX: n, deltaMode: r } = e;
|
|
4754
4770
|
return r === 0 ? Math.abs(t) < 10 || Math.abs(n) < 10 || !Number.isInteger(t) || !Number.isInteger(n) : r === 1 ? !1 : !Number.isInteger(t) || !Number.isInteger(n);
|
|
4755
4771
|
}
|
|
4756
|
-
function
|
|
4772
|
+
function hr(e) {
|
|
4757
4773
|
let t = e.currentTarget.getBoundingClientRect();
|
|
4758
4774
|
return {
|
|
4759
4775
|
x: e.clientX - t.left,
|
|
4760
4776
|
y: e.clientY - t.top
|
|
4761
4777
|
};
|
|
4762
4778
|
}
|
|
4763
|
-
function
|
|
4779
|
+
function gr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
4764
4780
|
let i = T(null), a = !!t && t.w > 0 && t.h > 0, o = a ? Math.min(r / t.w, r / t.h) : 1, s = a ? t.w * o : 0, c = a ? t.h * o : 0, l = a ? (r - s) / 2 : 0, u = a ? (r - c) / 2 : 0, d = v(() => {
|
|
4765
4781
|
let t = e.current;
|
|
4766
4782
|
if (!t) return null;
|
|
@@ -4798,7 +4814,7 @@ function vr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4798
4814
|
let n = e.current, r = d();
|
|
4799
4815
|
if (!n || !r) return;
|
|
4800
4816
|
t.preventDefault(), t.stopPropagation();
|
|
4801
|
-
let a =
|
|
4817
|
+
let a = hr(t), o = a.x >= r.x && a.x <= r.x + r.width && a.y >= r.y && a.y <= r.y + r.height ? {
|
|
4802
4818
|
offsetX: a.x - r.x,
|
|
4803
4819
|
offsetY: a.y - r.y
|
|
4804
4820
|
} : {
|
|
@@ -4815,7 +4831,7 @@ function vr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4815
4831
|
d
|
|
4816
4832
|
]), m = v((t) => {
|
|
4817
4833
|
let n = i.current, r = e.current;
|
|
4818
|
-
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(
|
|
4834
|
+
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(hr(t), r.viewport.scale, n));
|
|
4819
4835
|
}, [f, e]), h = v((e) => {
|
|
4820
4836
|
let t = i.current;
|
|
4821
4837
|
!t || t.pointerId !== e.pointerId || (i.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId));
|
|
@@ -4823,8 +4839,8 @@ function vr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4823
4839
|
let r = e.current;
|
|
4824
4840
|
if (!r || !n) return;
|
|
4825
4841
|
t.preventDefault(), t.stopPropagation();
|
|
4826
|
-
let i =
|
|
4827
|
-
f(
|
|
4842
|
+
let i = mr(t.nativeEvent) ? 2.5 : 1, a = t.deltaY * i, o = 1.05, s = a > 0 ? r.viewport.scale / o : r.viewport.scale * o, c = Math.max(fr, Math.min(pr, s));
|
|
4843
|
+
f(hr(t), c);
|
|
4828
4844
|
}, [
|
|
4829
4845
|
f,
|
|
4830
4846
|
e,
|
|
@@ -4861,7 +4877,7 @@ function vr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4861
4877
|
}
|
|
4862
4878
|
//#endregion
|
|
4863
4879
|
//#region src/components/ShapeEditor/_state/useMinimapSync.ts
|
|
4864
|
-
function
|
|
4880
|
+
function _r(e, t, n) {
|
|
4865
4881
|
if (!(!e || !n.length)) {
|
|
4866
4882
|
if (t.type === F.POINT) {
|
|
4867
4883
|
e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
|
|
@@ -4879,7 +4895,7 @@ function yr(e, t, n) {
|
|
|
4879
4895
|
e.setAttribute("points", n.map((e) => `${e.x},${e.y}`).join(" "));
|
|
4880
4896
|
}
|
|
4881
4897
|
}
|
|
4882
|
-
function
|
|
4898
|
+
function vr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRectRef: i, minimapSize: a, onViewportChangeRef: o }) {
|
|
4883
4899
|
let s = T(/* @__PURE__ */ new Map());
|
|
4884
4900
|
return {
|
|
4885
4901
|
registerMinimapShape: v((e, t) => {
|
|
@@ -4888,13 +4904,13 @@ function br({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
4888
4904
|
applyMinimapPreview: v((e) => {
|
|
4889
4905
|
let n = t.current.getShapes();
|
|
4890
4906
|
if (!e.length) {
|
|
4891
|
-
for (let e of n)
|
|
4907
|
+
for (let e of n) _r(s.current.get(e.id), e, e.points);
|
|
4892
4908
|
return;
|
|
4893
4909
|
}
|
|
4894
4910
|
let r = new Map(n.map((e) => [e.id, e]));
|
|
4895
4911
|
for (let t of e) {
|
|
4896
4912
|
let e = r.get(t.id);
|
|
4897
|
-
e &&
|
|
4913
|
+
e && _r(s.current.get(e.id), e, t.points);
|
|
4898
4914
|
}
|
|
4899
4915
|
}, [t]),
|
|
4900
4916
|
syncMinimap: v(() => {
|
|
@@ -4923,8 +4939,8 @@ function br({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
4923
4939
|
}
|
|
4924
4940
|
//#endregion
|
|
4925
4941
|
//#region src/components/ShapeEditor/_state/useSelectionActions.ts
|
|
4926
|
-
var
|
|
4927
|
-
function
|
|
4942
|
+
var yr = 12;
|
|
4943
|
+
function br({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMergeSelection: i, clipboardDocumentId: a, clipboardScope: o }) {
|
|
4928
4944
|
let s = T(0), c = T(!0), l = T(n), u = T(a), d = T(o);
|
|
4929
4945
|
l.current = n, u.current = a, d.current = o, y(() => (c.current = !0, () => {
|
|
4930
4946
|
c.current = !1;
|
|
@@ -4943,22 +4959,22 @@ function Sr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4943
4959
|
t
|
|
4944
4960
|
]), g = v(() => {
|
|
4945
4961
|
let e = m();
|
|
4946
|
-
e.length && (s.current = 0,
|
|
4962
|
+
e.length && (s.current = 0, gt(pt(e, a, o)));
|
|
4947
4963
|
}, [
|
|
4948
4964
|
a,
|
|
4949
4965
|
o,
|
|
4950
4966
|
m
|
|
4951
|
-
]), _ = v(() =>
|
|
4967
|
+
]), _ = v(() => X(o), [o]), b = v((t) => {
|
|
4952
4968
|
if (n) return;
|
|
4953
4969
|
let i = a;
|
|
4954
|
-
|
|
4970
|
+
vt(o).then((n) => {
|
|
4955
4971
|
if (!c.current || l.current || u.current !== i || d.current !== o || !n?.shapes.length) return;
|
|
4956
4972
|
let f, p, m = n.shapes.flatMap((e) => e.points);
|
|
4957
4973
|
if (t && m.length) {
|
|
4958
4974
|
let e = B(m);
|
|
4959
4975
|
f = t.x - (e.minX + e.maxX) / 2, p = t.y - (e.minY + e.maxY) / 2;
|
|
4960
4976
|
} else {
|
|
4961
|
-
let e = !!n.documentId && n.documentId !== a, t =
|
|
4977
|
+
let e = !!n.documentId && n.documentId !== a, t = yt(s.current, e, yr);
|
|
4962
4978
|
f = t.offset, s.current = t.nextPasteCount, p = f;
|
|
4963
4979
|
}
|
|
4964
4980
|
let h = n.shapes.map((e) => ({
|
|
@@ -4983,8 +4999,8 @@ function Sr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4983
4999
|
...e,
|
|
4984
5000
|
id: se(),
|
|
4985
5001
|
points: e.points.map((e) => ({
|
|
4986
|
-
x: e.x +
|
|
4987
|
-
y: e.y +
|
|
5002
|
+
x: e.x + yr,
|
|
5003
|
+
y: e.y + yr
|
|
4988
5004
|
}))
|
|
4989
5005
|
}));
|
|
4990
5006
|
i.length && (e.create(i), r(i.map((e) => e.id)));
|
|
@@ -5042,9 +5058,9 @@ function Sr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5042
5058
|
if (n) return;
|
|
5043
5059
|
let t = E();
|
|
5044
5060
|
if (t.length < 2 || i && !i(t)) return;
|
|
5045
|
-
let a =
|
|
5061
|
+
let a = fn([], 1, dn(t));
|
|
5046
5062
|
if (!a) return;
|
|
5047
|
-
let o =
|
|
5063
|
+
let o = pn(a, 1);
|
|
5048
5064
|
if (!o.length) return;
|
|
5049
5065
|
let s = t[0], c = o.map((e) => ({
|
|
5050
5066
|
id: se(),
|
|
@@ -5065,12 +5081,12 @@ function Sr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5065
5081
|
}
|
|
5066
5082
|
//#endregion
|
|
5067
5083
|
//#region src/components/ShapeEditor/_state/useViewportControls.ts
|
|
5068
|
-
function
|
|
5084
|
+
function xr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBound: i, ready: a }) {
|
|
5069
5085
|
let o = T(null), s = T(null), c = v(() => {
|
|
5070
5086
|
o.current?.(), o.current = null;
|
|
5071
5087
|
}, []), l = v((t, n = r) => {
|
|
5072
5088
|
let i = e.current;
|
|
5073
|
-
i && (c(), o.current =
|
|
5089
|
+
i && (c(), o.current = Jt(i.viewport, t, (e) => i.applyViewport(e), n));
|
|
5074
5090
|
}, [
|
|
5075
5091
|
c,
|
|
5076
5092
|
r,
|
|
@@ -5078,14 +5094,14 @@ function Cr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5078
5094
|
]), u = v((t, n = r) => {
|
|
5079
5095
|
let i = e.current;
|
|
5080
5096
|
if (!i) return;
|
|
5081
|
-
let a =
|
|
5097
|
+
let a = Kt(t, i.screenSize.w, i.screenSize.h);
|
|
5082
5098
|
a && l(a, n);
|
|
5083
5099
|
}, [
|
|
5084
5100
|
l,
|
|
5085
5101
|
r,
|
|
5086
5102
|
e
|
|
5087
5103
|
]), d = v((e, n = r) => {
|
|
5088
|
-
let i =
|
|
5104
|
+
let i = Gt(t.getShapes().filter((t) => e.includes(t.id)));
|
|
5089
5105
|
i && u(i, n);
|
|
5090
5106
|
}, [
|
|
5091
5107
|
t,
|
|
@@ -5096,7 +5112,7 @@ function Cr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5096
5112
|
if (!r.length) return;
|
|
5097
5113
|
let i = e.current;
|
|
5098
5114
|
if (!i) return;
|
|
5099
|
-
let a =
|
|
5115
|
+
let a = qt(B(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
|
|
5100
5116
|
a && l(a);
|
|
5101
5117
|
}, [
|
|
5102
5118
|
t,
|
|
@@ -5137,45 +5153,45 @@ function Cr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5137
5153
|
}
|
|
5138
5154
|
//#endregion
|
|
5139
5155
|
//#region src/components/ShapeEditor/ShapeEditor.tsx
|
|
5140
|
-
var
|
|
5156
|
+
var Sr = "__draft_preview__", Cr = new Set([
|
|
5141
5157
|
"copy",
|
|
5142
5158
|
"selectAll",
|
|
5143
5159
|
"clearSelection",
|
|
5144
5160
|
"zoomToSelection"
|
|
5145
5161
|
]);
|
|
5146
|
-
function
|
|
5162
|
+
function wr(e, t) {
|
|
5147
5163
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
5148
5164
|
}
|
|
5149
|
-
function
|
|
5150
|
-
let we = T(null), U = T(null), Te = T(null), Ee = T(null), De = T(null),
|
|
5165
|
+
function Tr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !1, selectedIds: i, activeTool: a, draftStyle: s, draftMeta: c, readOnly: l, disableMarquee: u, locked: d, onLockedInteraction: f, onIdleEscape: p, overrideShapeInteraction: m, defaultViewSettings: h, viewSettings: g, onViewSettingsChange: _, showMinimap: w = !0, showViewSettings: D = !0, getContextMenuItems: A, strings: j, canMergeSelection: M, brushSize: N = 20, zoomBound: P, zoomAnimationDuration: ee = 300, decorationShapes: te, regionMask: ne, guideMask: re, maskPalette: ae, overlayMarkers: L, renderOverlayMarker: R, onOverlayMarkerClick: z, renderImageOverlay: B, getSelectionLabel: ce, hideSelectionLabelDot: V, formatSelectionInfo: le, externalTools: ue, assistant: de, keymap: fe, handleRef: pe, backend: me = "pixi", onActiveToolChange: H, onSelectionChange: he, onEditingChange: ge, onShapesCreated: _e, onShapesUpdated: ve, onShapesDeleted: ye, onDrawSessionChange: be, onDraftShapeChange: xe, onViewportChange: Se, onShapesTransformPreview: Ce }) {
|
|
5166
|
+
let we = T(null), U = T(null), Te = T(null), Ee = T(null), De = T(null), Oe = `${b()}-minimap`, [G, je] = E(null), [Me, Ne] = E(!1), [K, Re] = E(!1), [ze, Be] = E(null), [Ve, He] = E({
|
|
5151
5167
|
active: !1,
|
|
5152
5168
|
kind: "none",
|
|
5153
5169
|
canUndo: !1,
|
|
5154
5170
|
canRedo: !1
|
|
5155
|
-
}), [
|
|
5171
|
+
}), [Ue, We] = E(!0), [Ge, Ke] = E(!1), qe = e?.id ?? "", Je = e?.imageUrl ?? "", Ye = e?.displayImageUrl, Ze = e?.coordinateSize, Qe = e?.initialShapes, $e = e?.initialSelectedIds, et = Ye ?? Je, [tt, at] = E("loading"), q = wn({
|
|
5156
5172
|
onShapesCreated: _e,
|
|
5157
5173
|
onShapesUpdated: ve,
|
|
5158
5174
|
onShapesDeleted: ye
|
|
5159
|
-
}), [
|
|
5175
|
+
}), [st, ct] = E([]), J = i ?? st, lt = i !== void 0, ut = C(() => new Map((ue ?? []).map((e) => [e.id, e])), [ue]), dt = T(ut);
|
|
5160
5176
|
S(() => {
|
|
5161
|
-
|
|
5162
|
-
}, [
|
|
5163
|
-
let
|
|
5164
|
-
|
|
5165
|
-
let
|
|
5177
|
+
dt.current = ut;
|
|
5178
|
+
}, [ut]);
|
|
5179
|
+
let ft = T(Ve);
|
|
5180
|
+
ft.current = Ve;
|
|
5181
|
+
let pt = C(() => {
|
|
5166
5182
|
let e = Object.fromEntries(Object.entries(h ?? {}).filter(([, e]) => e !== void 0));
|
|
5167
5183
|
return {
|
|
5168
|
-
...
|
|
5184
|
+
...Ae,
|
|
5169
5185
|
...e
|
|
5170
5186
|
};
|
|
5171
|
-
}, [h]),
|
|
5172
|
-
|
|
5173
|
-
let [
|
|
5187
|
+
}, [h]), ht = T(pt);
|
|
5188
|
+
ht.current = pt;
|
|
5189
|
+
let [Y, gt] = E(() => ht.current), _t = v((e) => gt((t) => ({
|
|
5174
5190
|
...t,
|
|
5175
5191
|
...e
|
|
5176
|
-
})), []),
|
|
5192
|
+
})), []), X = C(() => ke(j), [j]);
|
|
5177
5193
|
y(() => {
|
|
5178
|
-
g &&
|
|
5194
|
+
g && gt((e) => {
|
|
5179
5195
|
let t = Object.entries(g).filter(([t, n]) => n !== void 0 && e[t] !== n);
|
|
5180
5196
|
return t.length ? {
|
|
5181
5197
|
...e,
|
|
@@ -5183,78 +5199,78 @@ function Dr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5183
5199
|
} : e;
|
|
5184
5200
|
});
|
|
5185
5201
|
}, [g]);
|
|
5186
|
-
let
|
|
5187
|
-
|
|
5188
|
-
let
|
|
5202
|
+
let vt = T(_);
|
|
5203
|
+
vt.current = _;
|
|
5204
|
+
let yt = T(!1);
|
|
5189
5205
|
y(() => {
|
|
5190
|
-
if (!
|
|
5191
|
-
|
|
5206
|
+
if (!yt.current) {
|
|
5207
|
+
yt.current = !0;
|
|
5192
5208
|
return;
|
|
5193
5209
|
}
|
|
5194
|
-
|
|
5195
|
-
}, [X]);
|
|
5196
|
-
let yt = C(() => !re || !ae ? null : kt(re, ae), [re, ae]), bt = C(() => yt?.toDataURL() ?? null, [yt]), xt = C(() => !K || !ne ? null : Bt(ne, K.w, K.h), [K, ne]), St = T(yt);
|
|
5197
|
-
St.current = yt;
|
|
5198
|
-
let Ct = T(xt);
|
|
5199
|
-
Ct.current = xt;
|
|
5200
|
-
let wt = T(r);
|
|
5201
|
-
wt.current = r;
|
|
5202
|
-
let Tt = T(K);
|
|
5203
|
-
Tt.current = K;
|
|
5204
|
-
let Dt = T(Ye);
|
|
5205
|
-
Dt.current = Ye;
|
|
5206
|
-
let Ot = T(Ye?.imageSize);
|
|
5207
|
-
Ot.current = Ye?.imageSize;
|
|
5208
|
-
let At = T(Y);
|
|
5209
|
-
S(() => {
|
|
5210
|
-
At.current = Y;
|
|
5210
|
+
vt.current?.(Y);
|
|
5211
5211
|
}, [Y]);
|
|
5212
|
-
let
|
|
5213
|
-
|
|
5214
|
-
let
|
|
5215
|
-
|
|
5216
|
-
let
|
|
5217
|
-
|
|
5218
|
-
let
|
|
5219
|
-
|
|
5220
|
-
let
|
|
5221
|
-
|
|
5222
|
-
let
|
|
5223
|
-
|
|
5224
|
-
let
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
let
|
|
5229
|
-
|
|
5230
|
-
let
|
|
5231
|
-
|
|
5232
|
-
let
|
|
5233
|
-
|
|
5234
|
-
let
|
|
5212
|
+
let bt = C(() => !re || !ae ? null : Ot(re, ae), [re, ae]), xt = C(() => bt?.toDataURL() ?? null, [bt]), St = C(() => !G || !ne ? null : zt(ne, G.w, G.h), [G, ne]), Ct = T(bt);
|
|
5213
|
+
Ct.current = bt;
|
|
5214
|
+
let wt = T(St);
|
|
5215
|
+
wt.current = St;
|
|
5216
|
+
let Et = T(r);
|
|
5217
|
+
Et.current = r;
|
|
5218
|
+
let Dt = T(G);
|
|
5219
|
+
Dt.current = G;
|
|
5220
|
+
let kt = T(Ze);
|
|
5221
|
+
kt.current = Ze;
|
|
5222
|
+
let At = T(Ze?.imageSize);
|
|
5223
|
+
At.current = Ze?.imageSize;
|
|
5224
|
+
let jt = T(J);
|
|
5225
|
+
S(() => {
|
|
5226
|
+
jt.current = J;
|
|
5227
|
+
}, [J]);
|
|
5228
|
+
let Mt = T(a);
|
|
5229
|
+
Mt.current = a;
|
|
5230
|
+
let Nt = T(s);
|
|
5231
|
+
Nt.current = s;
|
|
5232
|
+
let Pt = T(c);
|
|
5233
|
+
Pt.current = c;
|
|
5234
|
+
let Ft = T(N);
|
|
5235
|
+
Ft.current = N;
|
|
5236
|
+
let It = T(Y.simplifyStrength);
|
|
5237
|
+
It.current = Y.simplifyStrength;
|
|
5238
|
+
let Z = !!l || !!d, Lt = T(Z);
|
|
5239
|
+
Lt.current = Z;
|
|
5240
|
+
let Rt = T(u);
|
|
5241
|
+
Rt.current = u;
|
|
5242
|
+
let Bt = T(d);
|
|
5243
|
+
Bt.current = d;
|
|
5244
|
+
let Vt = T(f);
|
|
5245
|
+
Vt.current = f;
|
|
5246
|
+
let Ht = T(m);
|
|
5247
|
+
Ht.current = m;
|
|
5248
|
+
let Ut = T(q);
|
|
5249
|
+
Ut.current = q;
|
|
5250
|
+
let Wt = T(!1), Gt = T(!1), Kt = T("idle"), qt = T(null), Jt = v(() => {
|
|
5235
5251
|
let e = U.current;
|
|
5236
5252
|
if (!e) return;
|
|
5237
|
-
let t =
|
|
5238
|
-
e.setCursor(
|
|
5253
|
+
let t = Mt.current, n = dt.current.get(t), r = ft.current;
|
|
5254
|
+
e.setCursor(Tt({
|
|
5239
5255
|
tool: t,
|
|
5240
5256
|
externalToolCursor: n?.cursor,
|
|
5241
|
-
isSpacePressed:
|
|
5242
|
-
interactionMode:
|
|
5243
|
-
rendererCursorHint:
|
|
5257
|
+
isSpacePressed: Wt.current,
|
|
5258
|
+
interactionMode: Kt.current,
|
|
5259
|
+
rendererCursorHint: qt.current,
|
|
5244
5260
|
isPolygonDrawing: r.kind === "polygon" && r.active
|
|
5245
5261
|
}));
|
|
5246
|
-
}, []),
|
|
5247
|
-
|
|
5248
|
-
}, [
|
|
5249
|
-
|
|
5250
|
-
}, [
|
|
5251
|
-
let t = /* @__PURE__ */ new Set(), n = new Map(
|
|
5262
|
+
}, []), Zt = v((e) => {
|
|
5263
|
+
Kt.current !== e && (Kt.current = e, Jt());
|
|
5264
|
+
}, [Jt]), Qt = v((e) => {
|
|
5265
|
+
qt.current !== e && (qt.current = e, Jt());
|
|
5266
|
+
}, [Jt]), $t = v((e) => {
|
|
5267
|
+
let t = /* @__PURE__ */ new Set(), n = new Map(Ut.current.getShapes().map((e) => [e.id, e]));
|
|
5252
5268
|
return e.filter((e) => {
|
|
5253
5269
|
if (t.has(e)) return !1;
|
|
5254
5270
|
t.add(e);
|
|
5255
5271
|
let r = n.get(e);
|
|
5256
5272
|
if (!r) return !1;
|
|
5257
|
-
let i =
|
|
5273
|
+
let i = Ht.current?.(r);
|
|
5258
5274
|
return I(i ? {
|
|
5259
5275
|
...r,
|
|
5260
5276
|
interaction: {
|
|
@@ -5263,175 +5279,175 @@ function Dr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5263
5279
|
}
|
|
5264
5280
|
} : r);
|
|
5265
5281
|
});
|
|
5266
|
-
}, []),
|
|
5267
|
-
let t =
|
|
5268
|
-
|
|
5282
|
+
}, []), en = v((e) => {
|
|
5283
|
+
let t = $t(e);
|
|
5284
|
+
wr(jt.current, t) || (lt || ct(t), U.current?.setSelection(t), he?.(t));
|
|
5269
5285
|
}, [
|
|
5270
|
-
|
|
5286
|
+
$t,
|
|
5271
5287
|
he,
|
|
5272
|
-
|
|
5273
|
-
]),
|
|
5274
|
-
|
|
5275
|
-
let [
|
|
5276
|
-
|
|
5277
|
-
let
|
|
5278
|
-
|
|
5279
|
-
if (!
|
|
5280
|
-
let e =
|
|
5281
|
-
|
|
5288
|
+
lt
|
|
5289
|
+
]), tn = T(en);
|
|
5290
|
+
tn.current = en;
|
|
5291
|
+
let [nn, rn] = E(null), an = v((e) => rn(e), []), on = T(an);
|
|
5292
|
+
on.current = an;
|
|
5293
|
+
let sn = T(null);
|
|
5294
|
+
sn.current = nn, y(() => {
|
|
5295
|
+
if (!lt) return;
|
|
5296
|
+
let e = $t(i);
|
|
5297
|
+
wr(i, e) || he?.(e);
|
|
5282
5298
|
}, [
|
|
5283
5299
|
i,
|
|
5284
|
-
|
|
5285
|
-
|
|
5300
|
+
q.shapes,
|
|
5301
|
+
$t,
|
|
5286
5302
|
he,
|
|
5287
|
-
|
|
5303
|
+
lt
|
|
5288
5304
|
]);
|
|
5289
|
-
let
|
|
5290
|
-
|
|
5291
|
-
let { registerMinimapShape:
|
|
5305
|
+
let cn = T(Se);
|
|
5306
|
+
cn.current = Se;
|
|
5307
|
+
let { registerMinimapShape: ln, applyMinimapPreview: un, syncMinimap: dn } = vr({
|
|
5292
5308
|
engineRef: U,
|
|
5293
|
-
docRef:
|
|
5309
|
+
docRef: Ut,
|
|
5294
5310
|
overlayRef: Ee,
|
|
5295
5311
|
zoomLabelRef: De,
|
|
5296
5312
|
minimapRectRef: Te,
|
|
5297
5313
|
minimapSize: 204,
|
|
5298
|
-
onViewportChangeRef:
|
|
5299
|
-
}),
|
|
5300
|
-
|
|
5301
|
-
let
|
|
5302
|
-
t ?
|
|
5303
|
-
}, []),
|
|
5314
|
+
onViewportChangeRef: cn
|
|
5315
|
+
}), fn = T(/* @__PURE__ */ new Map()), pn = T(le);
|
|
5316
|
+
pn.current = le;
|
|
5317
|
+
let mn = v((e, t) => {
|
|
5318
|
+
t ? fn.current.set(e, t) : fn.current.delete(e);
|
|
5319
|
+
}, []), hn = T(null), [gn, _n] = E(null), vn = v((e) => {
|
|
5304
5320
|
if (!e.length) return;
|
|
5305
|
-
let t = new Map(
|
|
5306
|
-
|
|
5321
|
+
let t = new Map(Ut.current.getShapes().map((e) => [e.id, e]));
|
|
5322
|
+
hn.current && t.set(hn.current.id, hn.current);
|
|
5307
5323
|
for (let { id: n, points: r } of e) {
|
|
5308
|
-
let e =
|
|
5324
|
+
let e = fn.current.get(n), i = t.get(n);
|
|
5309
5325
|
if (!e || !i) continue;
|
|
5310
5326
|
let a = nt(e, r);
|
|
5311
5327
|
if (a) {
|
|
5312
5328
|
let e = rt(i, r);
|
|
5313
|
-
a.textContent =
|
|
5329
|
+
a.textContent = pn.current?.(e) ?? it(e);
|
|
5314
5330
|
}
|
|
5315
5331
|
}
|
|
5316
|
-
}, []),
|
|
5317
|
-
|
|
5332
|
+
}, []), yn = v((e) => {
|
|
5333
|
+
un(e), vn(e), Ce?.(e);
|
|
5318
5334
|
}, [
|
|
5319
|
-
|
|
5320
|
-
|
|
5335
|
+
un,
|
|
5336
|
+
vn,
|
|
5321
5337
|
Ce
|
|
5322
|
-
]),
|
|
5338
|
+
]), bn = v((e) => {
|
|
5323
5339
|
if (xe?.(e ? {
|
|
5324
5340
|
...e,
|
|
5325
|
-
meta:
|
|
5326
|
-
} : null), !e || !
|
|
5327
|
-
|
|
5341
|
+
meta: Pt.current
|
|
5342
|
+
} : null), !e || !Nt.current) {
|
|
5343
|
+
hn.current && (hn.current = null, _n(null));
|
|
5328
5344
|
return;
|
|
5329
5345
|
}
|
|
5330
5346
|
let t = {
|
|
5331
|
-
id:
|
|
5347
|
+
id: Sr,
|
|
5332
5348
|
type: e.type,
|
|
5333
5349
|
points: e.points,
|
|
5334
|
-
style:
|
|
5335
|
-
meta:
|
|
5336
|
-
}, n =
|
|
5337
|
-
|
|
5338
|
-
id:
|
|
5350
|
+
style: Nt.current,
|
|
5351
|
+
meta: Pt.current
|
|
5352
|
+
}, n = hn.current !== null;
|
|
5353
|
+
hn.current = t, n ? vn([{
|
|
5354
|
+
id: Sr,
|
|
5339
5355
|
points: e.points
|
|
5340
|
-
}]) :
|
|
5341
|
-
}, [
|
|
5342
|
-
let n =
|
|
5343
|
-
if (!n ||
|
|
5356
|
+
}]) : _n(t);
|
|
5357
|
+
}, [vn, xe]), Sn = v((e, t) => {
|
|
5358
|
+
let n = Nt.current;
|
|
5359
|
+
if (!n || Lt.current) return;
|
|
5344
5360
|
let r = se();
|
|
5345
|
-
|
|
5361
|
+
Ut.current.create({
|
|
5346
5362
|
id: r,
|
|
5347
5363
|
type: e,
|
|
5348
5364
|
points: t,
|
|
5349
5365
|
style: n,
|
|
5350
5366
|
meta: c
|
|
5351
|
-
}),
|
|
5352
|
-
}, [c]),
|
|
5353
|
-
|
|
5354
|
-
let
|
|
5355
|
-
toolRef:
|
|
5356
|
-
selRef:
|
|
5357
|
-
docRef:
|
|
5358
|
-
readOnlyRef:
|
|
5359
|
-
draftRef:
|
|
5360
|
-
brushSizeRef:
|
|
5361
|
-
simplifyEpsilonRef:
|
|
5367
|
+
}), tn.current([r]);
|
|
5368
|
+
}, [c]), Cn = T(Sn);
|
|
5369
|
+
Cn.current = Sn;
|
|
5370
|
+
let Tn = xn({
|
|
5371
|
+
toolRef: Mt,
|
|
5372
|
+
selRef: jt,
|
|
5373
|
+
docRef: Ut,
|
|
5374
|
+
readOnlyRef: Lt,
|
|
5375
|
+
draftRef: Nt,
|
|
5376
|
+
brushSizeRef: Ft,
|
|
5377
|
+
simplifyEpsilonRef: It,
|
|
5362
5378
|
draftMeta: c,
|
|
5363
5379
|
engineRef: U,
|
|
5364
5380
|
onDrawSessionChange: v((e) => {
|
|
5365
|
-
|
|
5381
|
+
He(e), be?.(e);
|
|
5366
5382
|
}, [be]),
|
|
5367
5383
|
onDraftShapeChange: xe,
|
|
5368
|
-
changeSelection:
|
|
5369
|
-
createShape:
|
|
5370
|
-
}),
|
|
5371
|
-
|
|
5372
|
-
let { reset:
|
|
5373
|
-
|
|
5374
|
-
let
|
|
5375
|
-
docRef:
|
|
5376
|
-
draftRef:
|
|
5384
|
+
changeSelection: en,
|
|
5385
|
+
createShape: Sn
|
|
5386
|
+
}), En = T(Tn);
|
|
5387
|
+
En.current = Tn;
|
|
5388
|
+
let { reset: Dn, undoSession: On, redoSession: kn, canUndoSession: An, canRedoSession: jn, hasDraftSession: Mn, hasDraftPoints: Nn, commitDraftSession: Fn, setBrushScalarMode: In, getBrushScalarMode: Ln, hasBrushSession: Rn, commitBrush: zn, cancelBrush: Bn, beginBrushEditFromSelection: Vn, deleteDraftSelectedPoints: Hn, handleToolChange: Un, handleBrushSelectionChange: Wn } = Tn, Gn = T(de);
|
|
5389
|
+
Gn.current = de;
|
|
5390
|
+
let Q = Xt({
|
|
5391
|
+
docRef: Ut,
|
|
5392
|
+
draftRef: Nt,
|
|
5377
5393
|
draftMeta: c,
|
|
5378
|
-
changeSelection:
|
|
5379
|
-
assistantRef:
|
|
5380
|
-
}),
|
|
5381
|
-
|
|
5382
|
-
let
|
|
5383
|
-
doc:
|
|
5384
|
-
selRef:
|
|
5385
|
-
effectiveReadOnly:
|
|
5386
|
-
changeSelection:
|
|
5394
|
+
changeSelection: en,
|
|
5395
|
+
assistantRef: Gn
|
|
5396
|
+
}), Kn = T(Q);
|
|
5397
|
+
Kn.current = Q;
|
|
5398
|
+
let qn = C(() => mt(qe), [qe]), { selectAll: Jn, clearSelection: Yn, deleteSelection: Xn, copySelection: Zn, canPaste: Qn, paste: $n, duplicate: er, bringToFront: tr, sendToBack: nr, nudgeSelection: rr, getMergeTargets: ir, mergeSelection: ar } = br({
|
|
5399
|
+
doc: q,
|
|
5400
|
+
selRef: jt,
|
|
5401
|
+
effectiveReadOnly: Z,
|
|
5402
|
+
changeSelection: en,
|
|
5387
5403
|
canMergeSelection: M,
|
|
5388
|
-
clipboardDocumentId:
|
|
5389
|
-
clipboardScope: t ??
|
|
5390
|
-
}), { zoomToBounds:
|
|
5404
|
+
clipboardDocumentId: qn,
|
|
5405
|
+
clipboardScope: t ?? qn
|
|
5406
|
+
}), { zoomToBounds: or, zoomToShapes: sr, zoomToSelection: cr, zoomAtCenter: $ } = xr({
|
|
5391
5407
|
engineRef: U,
|
|
5392
|
-
doc:
|
|
5393
|
-
selRef:
|
|
5408
|
+
doc: q,
|
|
5409
|
+
selRef: jt,
|
|
5394
5410
|
zoomAnimationDuration: ee,
|
|
5395
5411
|
zoomBound: P,
|
|
5396
|
-
ready:
|
|
5412
|
+
ready: K
|
|
5397
5413
|
});
|
|
5398
5414
|
x(pe, () => ({
|
|
5399
5415
|
previewRegionMask: (e) => {
|
|
5400
|
-
let t =
|
|
5416
|
+
let t = Dt.current;
|
|
5401
5417
|
if (!t) return;
|
|
5402
|
-
let n = e ?
|
|
5418
|
+
let n = e ? zt(e, t.w, t.h) : wt.current;
|
|
5403
5419
|
U.current?.setRegionOverlay(lr.current.showRegionMask ? n : null);
|
|
5404
5420
|
},
|
|
5405
5421
|
undo: () => {
|
|
5406
|
-
|
|
5422
|
+
On() || q.undo();
|
|
5407
5423
|
},
|
|
5408
5424
|
redo: () => {
|
|
5409
|
-
|
|
5425
|
+
kn() || q.redo();
|
|
5410
5426
|
},
|
|
5411
|
-
canUndo: () =>
|
|
5412
|
-
canRedo: () =>
|
|
5413
|
-
undoSession:
|
|
5414
|
-
redoSession:
|
|
5415
|
-
canUndoSession:
|
|
5416
|
-
canRedoSession:
|
|
5417
|
-
hasDraftSession:
|
|
5418
|
-
cancelDraftSession:
|
|
5419
|
-
commitDraftSession:
|
|
5420
|
-
setSelection:
|
|
5427
|
+
canUndo: () => An() || q.canUndo(),
|
|
5428
|
+
canRedo: () => jn() || q.canRedo(),
|
|
5429
|
+
undoSession: On,
|
|
5430
|
+
redoSession: kn,
|
|
5431
|
+
canUndoSession: An,
|
|
5432
|
+
canRedoSession: jn,
|
|
5433
|
+
hasDraftSession: Mn,
|
|
5434
|
+
cancelDraftSession: Dn,
|
|
5435
|
+
commitDraftSession: Fn,
|
|
5436
|
+
setSelection: en,
|
|
5421
5437
|
createShapes: (e) => {
|
|
5422
|
-
e.length && (
|
|
5438
|
+
e.length && (q.create(e), en(e.map((e) => e.id)));
|
|
5423
5439
|
},
|
|
5424
|
-
updateShapes:
|
|
5425
|
-
deleteShapes:
|
|
5426
|
-
getShapes:
|
|
5427
|
-
selectAll:
|
|
5428
|
-
clearSelection:
|
|
5429
|
-
deleteSelection:
|
|
5430
|
-
copySelection:
|
|
5431
|
-
paste:
|
|
5432
|
-
duplicate:
|
|
5433
|
-
bringToFront:
|
|
5434
|
-
sendToBack:
|
|
5440
|
+
updateShapes: q.update,
|
|
5441
|
+
deleteShapes: q.remove,
|
|
5442
|
+
getShapes: q.getShapes,
|
|
5443
|
+
selectAll: Jn,
|
|
5444
|
+
clearSelection: Yn,
|
|
5445
|
+
deleteSelection: Xn,
|
|
5446
|
+
copySelection: Zn,
|
|
5447
|
+
paste: $n,
|
|
5448
|
+
duplicate: er,
|
|
5449
|
+
bringToFront: tr,
|
|
5450
|
+
sendToBack: nr,
|
|
5435
5451
|
zoomFit: () => U.current?.fit(),
|
|
5436
5452
|
zoom100: () => U.current?.zoom100(),
|
|
5437
5453
|
zoomIn: () => {
|
|
@@ -5446,101 +5462,101 @@ function Dr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5446
5462
|
let { w: t, h: n } = e.screenSize;
|
|
5447
5463
|
e.zoomAt(t / 2, n / 2, 1 / 1.2);
|
|
5448
5464
|
},
|
|
5449
|
-
zoomToSelection:
|
|
5450
|
-
zoomToShapes:
|
|
5451
|
-
zoomToBounds:
|
|
5465
|
+
zoomToSelection: cr,
|
|
5466
|
+
zoomToShapes: sr,
|
|
5467
|
+
zoomToBounds: or,
|
|
5452
5468
|
brush: {
|
|
5453
|
-
setScalarMode:
|
|
5454
|
-
getScalarMode:
|
|
5455
|
-
hasSession:
|
|
5456
|
-
commit:
|
|
5457
|
-
cancel:
|
|
5458
|
-
beginEditFromSelection:
|
|
5469
|
+
setScalarMode: In,
|
|
5470
|
+
getScalarMode: Ln,
|
|
5471
|
+
hasSession: Rn,
|
|
5472
|
+
commit: zn,
|
|
5473
|
+
cancel: Bn,
|
|
5474
|
+
beginEditFromSelection: Vn
|
|
5459
5475
|
}
|
|
5460
5476
|
}), [
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
Dn,
|
|
5477
|
+
q,
|
|
5478
|
+
en,
|
|
5464
5479
|
On,
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5480
|
+
kn,
|
|
5481
|
+
Fn,
|
|
5482
|
+
Dn,
|
|
5468
5483
|
zn,
|
|
5469
|
-
|
|
5484
|
+
Bn,
|
|
5470
5485
|
Jn,
|
|
5471
5486
|
Yn,
|
|
5472
5487
|
Xn,
|
|
5473
|
-
|
|
5488
|
+
Zn,
|
|
5474
5489
|
$n,
|
|
5475
5490
|
er,
|
|
5476
5491
|
tr,
|
|
5492
|
+
nr,
|
|
5493
|
+
cr,
|
|
5477
5494
|
sr,
|
|
5478
5495
|
or,
|
|
5479
|
-
ar,
|
|
5480
|
-
Pn,
|
|
5481
5496
|
In,
|
|
5482
5497
|
Ln,
|
|
5483
|
-
|
|
5498
|
+
Rn,
|
|
5499
|
+
Vn
|
|
5484
5500
|
]);
|
|
5485
|
-
let lr = T(
|
|
5486
|
-
lr.current =
|
|
5487
|
-
let ur = v(() =>
|
|
5501
|
+
let lr = T(Y);
|
|
5502
|
+
lr.current = Y;
|
|
5503
|
+
let ur = v(() => Yt({
|
|
5488
5504
|
engineRef: U,
|
|
5489
|
-
toolRef:
|
|
5490
|
-
externalToolMapRef:
|
|
5491
|
-
spaceRef:
|
|
5492
|
-
shiftRef:
|
|
5493
|
-
docRef:
|
|
5494
|
-
selRef:
|
|
5495
|
-
draftRef:
|
|
5496
|
-
readOnlyRef:
|
|
5497
|
-
disableMarqueeRef:
|
|
5498
|
-
lockedRef:
|
|
5499
|
-
onLockedInteraction: () =>
|
|
5500
|
-
createRef:
|
|
5501
|
-
selectRef:
|
|
5502
|
-
enterEditRef:
|
|
5503
|
-
editingIdRef:
|
|
5504
|
-
drawSessionRef:
|
|
5505
|
-
assistantRef:
|
|
5506
|
-
setCursorHint:
|
|
5507
|
-
setInteractionMode:
|
|
5508
|
-
syncMinimap:
|
|
5509
|
-
onTransformPreview:
|
|
5510
|
-
onDrawPreview:
|
|
5505
|
+
toolRef: Mt,
|
|
5506
|
+
externalToolMapRef: dt,
|
|
5507
|
+
spaceRef: Wt,
|
|
5508
|
+
shiftRef: Gt,
|
|
5509
|
+
docRef: Ut,
|
|
5510
|
+
selRef: jt,
|
|
5511
|
+
draftRef: Nt,
|
|
5512
|
+
readOnlyRef: Lt,
|
|
5513
|
+
disableMarqueeRef: Rt,
|
|
5514
|
+
lockedRef: Bt,
|
|
5515
|
+
onLockedInteraction: () => Vt.current?.(),
|
|
5516
|
+
createRef: Cn,
|
|
5517
|
+
selectRef: tn,
|
|
5518
|
+
enterEditRef: on,
|
|
5519
|
+
editingIdRef: sn,
|
|
5520
|
+
drawSessionRef: En,
|
|
5521
|
+
assistantRef: Kn,
|
|
5522
|
+
setCursorHint: Qt,
|
|
5523
|
+
setInteractionMode: Zt,
|
|
5524
|
+
syncMinimap: dn,
|
|
5525
|
+
onTransformPreview: yn,
|
|
5526
|
+
onDrawPreview: bn
|
|
5511
5527
|
}), [
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
]),
|
|
5518
|
-
|
|
5528
|
+
Qt,
|
|
5529
|
+
Zt,
|
|
5530
|
+
dn,
|
|
5531
|
+
yn,
|
|
5532
|
+
bn
|
|
5533
|
+
]), fr = T([]);
|
|
5534
|
+
dr({
|
|
5519
5535
|
backend: me,
|
|
5520
5536
|
hostRef: we,
|
|
5521
5537
|
engineRef: U,
|
|
5522
|
-
documentId:
|
|
5523
|
-
renderedImageUrl:
|
|
5538
|
+
documentId: qe,
|
|
5539
|
+
renderedImageUrl: et,
|
|
5524
5540
|
makeCallbacks: ur,
|
|
5525
5541
|
viewRef: lr,
|
|
5526
|
-
readOnlyRef:
|
|
5527
|
-
toolRef:
|
|
5528
|
-
renderShapesRef:
|
|
5529
|
-
coordinateSizeRef:
|
|
5530
|
-
imageSizeRef:
|
|
5531
|
-
selRef:
|
|
5532
|
-
maskCanvasRef:
|
|
5533
|
-
regionOverlayRef:
|
|
5534
|
-
dimmedRef:
|
|
5535
|
-
syncMinimap:
|
|
5536
|
-
setImage:
|
|
5537
|
-
setImageVisible:
|
|
5538
|
-
setReady:
|
|
5539
|
-
setImageStatus:
|
|
5540
|
-
onContextMenuRequest:
|
|
5542
|
+
readOnlyRef: Lt,
|
|
5543
|
+
toolRef: Mt,
|
|
5544
|
+
renderShapesRef: fr,
|
|
5545
|
+
coordinateSizeRef: kt,
|
|
5546
|
+
imageSizeRef: At,
|
|
5547
|
+
selRef: jt,
|
|
5548
|
+
maskCanvasRef: Ct,
|
|
5549
|
+
regionOverlayRef: wt,
|
|
5550
|
+
dimmedRef: Et,
|
|
5551
|
+
syncMinimap: dn,
|
|
5552
|
+
setImage: je,
|
|
5553
|
+
setImageVisible: Ne,
|
|
5554
|
+
setReady: Re,
|
|
5555
|
+
setImageStatus: at,
|
|
5556
|
+
onContextMenuRequest: Be
|
|
5541
5557
|
});
|
|
5542
|
-
let
|
|
5543
|
-
let e = m ?
|
|
5558
|
+
let pr = C(() => {
|
|
5559
|
+
let e = m ? q.shapes.map((e) => {
|
|
5544
5560
|
let t = m(e);
|
|
5545
5561
|
return t ? {
|
|
5546
5562
|
...e,
|
|
@@ -5549,7 +5565,7 @@ function Dr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5549
5565
|
...t
|
|
5550
5566
|
}
|
|
5551
5567
|
} : e;
|
|
5552
|
-
}) :
|
|
5568
|
+
}) : q.shapes;
|
|
5553
5569
|
return te?.length ? [...te.map((e) => ({
|
|
5554
5570
|
...e,
|
|
5555
5571
|
interaction: {
|
|
@@ -5561,343 +5577,343 @@ function Dr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5561
5577
|
}
|
|
5562
5578
|
})), ...e] : e;
|
|
5563
5579
|
}, [
|
|
5564
|
-
|
|
5580
|
+
q.shapes,
|
|
5565
5581
|
m,
|
|
5566
5582
|
te
|
|
5567
5583
|
]);
|
|
5568
|
-
|
|
5569
|
-
U.current?.setShapes(
|
|
5570
|
-
}, [
|
|
5571
|
-
U.current?.setSelection(
|
|
5572
|
-
}, [
|
|
5573
|
-
U.current?.setEditing(
|
|
5574
|
-
}, [
|
|
5584
|
+
fr.current = pr, y(() => {
|
|
5585
|
+
U.current?.setShapes(pr, jt.current), dn();
|
|
5586
|
+
}, [pr, dn]), y(() => {
|
|
5587
|
+
U.current?.setSelection(J);
|
|
5588
|
+
}, [J]), y(() => {
|
|
5589
|
+
U.current?.setEditing(nn);
|
|
5590
|
+
}, [nn, K]);
|
|
5575
5591
|
let mr = T(ge);
|
|
5576
5592
|
mr.current = ge, y(() => {
|
|
5577
|
-
mr.current?.(
|
|
5578
|
-
}, [
|
|
5579
|
-
|
|
5593
|
+
mr.current?.(nn);
|
|
5594
|
+
}, [nn]), y(() => {
|
|
5595
|
+
rn(null);
|
|
5580
5596
|
}, [a]), y(() => {
|
|
5581
|
-
|
|
5582
|
-
}, [
|
|
5597
|
+
nn && (J.length !== 1 || J[0] !== nn) && rn(null);
|
|
5598
|
+
}, [J, nn]), y(() => {
|
|
5583
5599
|
let e = U.current;
|
|
5584
|
-
e && (e.setFilter(
|
|
5600
|
+
e && (e.setFilter(Y.brightness, Y.contrast), e.setRenderDefaults({ strokeWidth: Y.strokeSize }), e.setImageSmoothing(Y.imageSmoothing), dn());
|
|
5585
5601
|
}, [
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5602
|
+
Y.brightness,
|
|
5603
|
+
Y.contrast,
|
|
5604
|
+
Y.strokeSize,
|
|
5605
|
+
Y.imageSmoothing,
|
|
5606
|
+
dn
|
|
5591
5607
|
]), S(() => {
|
|
5592
|
-
|
|
5608
|
+
K && U.current?.setOverlays(Y.showGuide ? bt : null, Y.showRegionMask ? St : null, r);
|
|
5593
5609
|
}, [
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5610
|
+
K,
|
|
5611
|
+
bt,
|
|
5612
|
+
St,
|
|
5613
|
+
Y.showGuide,
|
|
5614
|
+
Y.showRegionMask,
|
|
5599
5615
|
r
|
|
5600
5616
|
]), y(() => {
|
|
5601
|
-
!
|
|
5617
|
+
!K || !G || dn();
|
|
5602
5618
|
}, [
|
|
5603
|
-
q,
|
|
5604
5619
|
K,
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5620
|
+
G,
|
|
5621
|
+
xt,
|
|
5622
|
+
Y.showGuide,
|
|
5623
|
+
Y.showRegionMask,
|
|
5608
5624
|
ne,
|
|
5609
|
-
|
|
5625
|
+
dn
|
|
5610
5626
|
]), y(() => {
|
|
5611
|
-
|
|
5627
|
+
K && U.current?.setTransformEnabled(!Z && a !== W.BRUSH);
|
|
5612
5628
|
}, [
|
|
5613
|
-
|
|
5614
|
-
|
|
5629
|
+
Z,
|
|
5630
|
+
K,
|
|
5615
5631
|
a
|
|
5616
5632
|
]), y(() => {
|
|
5617
|
-
|
|
5618
|
-
}, [a,
|
|
5619
|
-
let hr =
|
|
5633
|
+
Un(a, dt.current.has(a));
|
|
5634
|
+
}, [a, Un]);
|
|
5635
|
+
let hr = Q.finalize;
|
|
5620
5636
|
y(() => {
|
|
5621
5637
|
hr();
|
|
5622
5638
|
}, [a, hr]), y(() => {
|
|
5623
|
-
|
|
5639
|
+
Kt.current = "idle", qt.current = null, Jt();
|
|
5624
5640
|
}, [
|
|
5625
5641
|
a,
|
|
5626
5642
|
me,
|
|
5627
|
-
|
|
5643
|
+
Jt
|
|
5628
5644
|
]), y(() => {
|
|
5629
|
-
|
|
5645
|
+
Wn(J, Z);
|
|
5630
5646
|
}, [
|
|
5631
|
-
|
|
5647
|
+
J,
|
|
5632
5648
|
a,
|
|
5633
|
-
|
|
5634
|
-
|
|
5649
|
+
Z,
|
|
5650
|
+
Wn
|
|
5635
5651
|
]), y(() => {
|
|
5636
|
-
|
|
5652
|
+
K && Jt();
|
|
5637
5653
|
}, [
|
|
5638
5654
|
a,
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5655
|
+
Ve,
|
|
5656
|
+
ut,
|
|
5657
|
+
K,
|
|
5658
|
+
Jt
|
|
5643
5659
|
]);
|
|
5644
|
-
let
|
|
5645
|
-
|
|
5646
|
-
let
|
|
5660
|
+
let _r = T($e);
|
|
5661
|
+
_r.current = $e;
|
|
5662
|
+
let yr = e !== null, Tr = T(null);
|
|
5647
5663
|
y(() => {
|
|
5648
|
-
let e =
|
|
5649
|
-
|
|
5664
|
+
let e = yr ? qe : null;
|
|
5665
|
+
Tr.current !== e && (Tr.current = e, Be(null), rn(null), Kt.current = "idle", qt.current = null, q.reset(yr ? Qe ?? [] : []), en(yr ? _r.current ?? [] : []), Dn(), hr(), Jt());
|
|
5650
5666
|
}, [
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5667
|
+
yr,
|
|
5668
|
+
qe,
|
|
5669
|
+
Qe,
|
|
5670
|
+
q.reset,
|
|
5671
|
+
en,
|
|
5672
|
+
Dn,
|
|
5657
5673
|
hr,
|
|
5658
|
-
|
|
5674
|
+
Jt
|
|
5659
5675
|
]);
|
|
5660
|
-
let
|
|
5661
|
-
let e =
|
|
5662
|
-
if (!e ||
|
|
5676
|
+
let Er = v(() => {
|
|
5677
|
+
let e = sn.current;
|
|
5678
|
+
if (!e || Z) return !1;
|
|
5663
5679
|
let t = U.current, n = new Set(t?.getVertexSelection() ?? []);
|
|
5664
5680
|
if (!n.size) return !1;
|
|
5665
|
-
let r =
|
|
5681
|
+
let r = Ut.current.getShapes().find((t) => t.id === e);
|
|
5666
5682
|
if (!r) return !1;
|
|
5667
5683
|
let i = r.points.filter((e, t) => !n.has(t)), a = r.type === F.LINE ? 2 : 3;
|
|
5668
|
-
return i.length < a ? !1 : (
|
|
5684
|
+
return i.length < a ? !1 : (Ut.current.update([{
|
|
5669
5685
|
...r,
|
|
5670
5686
|
points: i
|
|
5671
5687
|
}]), t?.setVertexSelection([]), !0);
|
|
5672
|
-
}, [
|
|
5673
|
-
|
|
5688
|
+
}, [Z]);
|
|
5689
|
+
Pn({
|
|
5674
5690
|
keymap: fe,
|
|
5675
5691
|
hostRef: we,
|
|
5676
5692
|
actions: {
|
|
5677
5693
|
undo: () => {
|
|
5678
|
-
|
|
5694
|
+
Z || On() || q.undo();
|
|
5679
5695
|
},
|
|
5680
5696
|
redo: () => {
|
|
5681
|
-
|
|
5697
|
+
Z || kn() || q.redo();
|
|
5682
5698
|
},
|
|
5683
|
-
selectAll:
|
|
5684
|
-
copy:
|
|
5699
|
+
selectAll: Jn,
|
|
5700
|
+
copy: Zn,
|
|
5685
5701
|
cut: () => {
|
|
5686
|
-
|
|
5702
|
+
Zn(), Xn();
|
|
5687
5703
|
},
|
|
5688
|
-
paste:
|
|
5689
|
-
duplicate:
|
|
5704
|
+
paste: $n,
|
|
5705
|
+
duplicate: er,
|
|
5690
5706
|
delete: () => {
|
|
5691
|
-
|
|
5707
|
+
Nn() && Hn() || Er() || Xn();
|
|
5692
5708
|
},
|
|
5693
5709
|
cancel: () => {
|
|
5694
|
-
let e =
|
|
5710
|
+
let e = dt.current.get(Mt.current);
|
|
5695
5711
|
if (!(e?.onCancel && e.onCancel() !== !1)) {
|
|
5696
|
-
if (
|
|
5697
|
-
|
|
5712
|
+
if (Q.isActive()) {
|
|
5713
|
+
Q.cancel();
|
|
5698
5714
|
return;
|
|
5699
5715
|
}
|
|
5700
|
-
if (
|
|
5701
|
-
|
|
5716
|
+
if (Mn()) {
|
|
5717
|
+
Dn();
|
|
5702
5718
|
return;
|
|
5703
5719
|
}
|
|
5704
|
-
if (
|
|
5705
|
-
|
|
5720
|
+
if (nn) {
|
|
5721
|
+
rn(null);
|
|
5706
5722
|
return;
|
|
5707
5723
|
}
|
|
5708
|
-
if (
|
|
5709
|
-
|
|
5724
|
+
if (jt.current.length) {
|
|
5725
|
+
Yn();
|
|
5710
5726
|
return;
|
|
5711
5727
|
}
|
|
5712
5728
|
p?.();
|
|
5713
5729
|
}
|
|
5714
5730
|
},
|
|
5715
5731
|
commitDraft: () => {
|
|
5716
|
-
if (
|
|
5717
|
-
|
|
5732
|
+
if (Q.isActive()) {
|
|
5733
|
+
Q.finalize();
|
|
5718
5734
|
return;
|
|
5719
5735
|
}
|
|
5720
|
-
if (
|
|
5721
|
-
|
|
5736
|
+
if (Mn()) {
|
|
5737
|
+
Fn();
|
|
5722
5738
|
return;
|
|
5723
5739
|
}
|
|
5724
|
-
if (
|
|
5725
|
-
if (
|
|
5726
|
-
|
|
5740
|
+
if (Z) return;
|
|
5741
|
+
if (nn) {
|
|
5742
|
+
rn(null);
|
|
5727
5743
|
return;
|
|
5728
5744
|
}
|
|
5729
|
-
let e =
|
|
5745
|
+
let e = jt.current;
|
|
5730
5746
|
if (e.length !== 1) return;
|
|
5731
|
-
let t =
|
|
5732
|
-
t && (t.type === F.POLYGON || t.type === F.LINE) && t.interaction?.editable !== !1 && !t.readOnly &&
|
|
5747
|
+
let t = Ut.current.getShapes().find((t) => t.id === e[0]);
|
|
5748
|
+
t && (t.type === F.POLYGON || t.type === F.LINE) && t.interaction?.editable !== !1 && !t.readOnly && rn(e[0]);
|
|
5733
5749
|
},
|
|
5734
|
-
bringToFront:
|
|
5735
|
-
sendToBack:
|
|
5736
|
-
zoomIn: () =>
|
|
5737
|
-
zoomOut: () =>
|
|
5750
|
+
bringToFront: tr,
|
|
5751
|
+
sendToBack: nr,
|
|
5752
|
+
zoomIn: () => $(1.2),
|
|
5753
|
+
zoomOut: () => $(1 / 1.2),
|
|
5738
5754
|
zoom100: () => U.current?.zoom100(),
|
|
5739
5755
|
zoomFit: () => U.current?.fit(),
|
|
5740
|
-
toggleMinimap: () =>
|
|
5741
|
-
toggleCursorGuide: () =>
|
|
5756
|
+
toggleMinimap: () => We((e) => !e),
|
|
5757
|
+
toggleCursorGuide: () => gt((e) => ({
|
|
5742
5758
|
...e,
|
|
5743
5759
|
showCursorGuide: !e.showCursorGuide
|
|
5744
5760
|
})),
|
|
5745
|
-
togglePixelation: () =>
|
|
5761
|
+
togglePixelation: () => gt((e) => ({
|
|
5746
5762
|
...e,
|
|
5747
5763
|
imageSmoothing: !e.imageSmoothing
|
|
5748
5764
|
})),
|
|
5749
|
-
selectTool: () => H?.(
|
|
5750
|
-
rectangleTool: () => H?.(
|
|
5751
|
-
rotatedRectangleTool: () => H?.(
|
|
5752
|
-
circleTool: () => H?.(
|
|
5753
|
-
polygonTool: () => H?.(
|
|
5754
|
-
pathTool: () => H?.(
|
|
5755
|
-
brushTool: () => H?.(
|
|
5756
|
-
pointTool: () => H?.(
|
|
5765
|
+
selectTool: () => H?.(W.SELECT),
|
|
5766
|
+
rectangleTool: () => H?.(W.RECTANGLE),
|
|
5767
|
+
rotatedRectangleTool: () => H?.(W.ROTATED_RECTANGLE),
|
|
5768
|
+
circleTool: () => H?.(W.CIRCLE),
|
|
5769
|
+
polygonTool: () => H?.(W.POLYGON),
|
|
5770
|
+
pathTool: () => H?.(W.PATH),
|
|
5771
|
+
brushTool: () => H?.(W.BRUSH),
|
|
5772
|
+
pointTool: () => H?.(W.POINT)
|
|
5757
5773
|
},
|
|
5758
|
-
spaceRef:
|
|
5759
|
-
shiftRef:
|
|
5774
|
+
spaceRef: Wt,
|
|
5775
|
+
shiftRef: Gt,
|
|
5760
5776
|
onSpaceDown: () => {
|
|
5761
|
-
U.current?.setPanMode(!0),
|
|
5777
|
+
U.current?.setPanMode(!0), Jt();
|
|
5762
5778
|
},
|
|
5763
5779
|
onSpaceUp: () => {
|
|
5764
|
-
U.current?.setPanMode(!1),
|
|
5780
|
+
U.current?.setPanMode(!1), Kt.current === "panning" ? Zt("idle") : Jt();
|
|
5765
5781
|
},
|
|
5766
|
-
nudge:
|
|
5782
|
+
nudge: rr
|
|
5767
5783
|
});
|
|
5768
|
-
let Dr = C(() =>
|
|
5769
|
-
let e =
|
|
5784
|
+
let Dr = C(() => pr.filter((e) => J.includes(e.id) && ie(e)), [pr, J]), Or = C(() => gn ? [...Dr, gn] : Dr, [Dr, gn]), kr = J.length > 0, Ar = q.shapes.some((e) => J.includes(e.id) && oe(e)), jr = !Z && J.length === 1 && (() => {
|
|
5785
|
+
let e = q.shapes.find((e) => e.id === J[0]);
|
|
5770
5786
|
return !!e && (e.type === F.POLYGON || e.type === F.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
|
|
5771
|
-
})(), Mr =
|
|
5772
|
-
let e =
|
|
5787
|
+
})(), Mr = ir(), Nr = Z || Mr.length < 2 || (M ? !M(Mr) : !1), Pr = !!de && !Z, Fr = Pr && J.length === 1 ? (() => {
|
|
5788
|
+
let e = q.shapes.find((e) => e.id === J[0]);
|
|
5773
5789
|
return e && e.type === F.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
|
|
5774
5790
|
})() : null, Ir = [
|
|
5775
5791
|
{
|
|
5776
5792
|
id: "copy",
|
|
5777
|
-
label:
|
|
5793
|
+
label: X.contextMenu.copy,
|
|
5778
5794
|
shortcut: "⌘C",
|
|
5779
5795
|
disabled: !Ar,
|
|
5780
|
-
onClick:
|
|
5796
|
+
onClick: Zn
|
|
5781
5797
|
},
|
|
5782
5798
|
{
|
|
5783
5799
|
id: "paste",
|
|
5784
|
-
label:
|
|
5800
|
+
label: X.contextMenu.paste,
|
|
5785
5801
|
shortcut: "⌘V",
|
|
5786
|
-
disabled:
|
|
5787
|
-
onClick: () =>
|
|
5802
|
+
disabled: Z || !Qn(),
|
|
5803
|
+
onClick: () => $n(ze?.img)
|
|
5788
5804
|
},
|
|
5789
5805
|
{
|
|
5790
5806
|
id: "duplicate",
|
|
5791
|
-
label:
|
|
5807
|
+
label: X.contextMenu.duplicate,
|
|
5792
5808
|
shortcut: "⌘D",
|
|
5793
|
-
disabled: !Ar ||
|
|
5794
|
-
onClick:
|
|
5809
|
+
disabled: !Ar || Z,
|
|
5810
|
+
onClick: er
|
|
5795
5811
|
},
|
|
5796
5812
|
{
|
|
5797
5813
|
id: "delete",
|
|
5798
|
-
label:
|
|
5814
|
+
label: X.contextMenu.delete,
|
|
5799
5815
|
shortcut: "Del",
|
|
5800
5816
|
danger: !0,
|
|
5801
|
-
disabled: !Ar ||
|
|
5802
|
-
onClick:
|
|
5817
|
+
disabled: !Ar || Z,
|
|
5818
|
+
onClick: Xn
|
|
5803
5819
|
},
|
|
5804
5820
|
{ separator: !0 },
|
|
5805
5821
|
{
|
|
5806
5822
|
id: "editVertices",
|
|
5807
|
-
label:
|
|
5823
|
+
label: X.contextMenu.editVertices,
|
|
5808
5824
|
shortcut: "Enter",
|
|
5809
5825
|
disabled: !jr,
|
|
5810
|
-
onClick: () =>
|
|
5826
|
+
onClick: () => rn(J[0])
|
|
5811
5827
|
},
|
|
5812
5828
|
{
|
|
5813
5829
|
id: "merge",
|
|
5814
|
-
label:
|
|
5830
|
+
label: X.contextMenu.merge,
|
|
5815
5831
|
disabled: Nr,
|
|
5816
|
-
onClick:
|
|
5832
|
+
onClick: ar
|
|
5817
5833
|
},
|
|
5818
5834
|
...Pr ? [{
|
|
5819
5835
|
id: "assistExpand",
|
|
5820
|
-
label:
|
|
5836
|
+
label: X.contextMenu.assistExpand,
|
|
5821
5837
|
icon: /* @__PURE__ */ O(o, { size: 14 }),
|
|
5822
5838
|
disabled: !Fr,
|
|
5823
5839
|
onClick: () => {
|
|
5824
|
-
|
|
5840
|
+
ze && Fr && Q.refineShape(Fr, ze.img, !0);
|
|
5825
5841
|
}
|
|
5826
5842
|
}, {
|
|
5827
5843
|
id: "assistExclude",
|
|
5828
|
-
label:
|
|
5844
|
+
label: X.contextMenu.assistExclude,
|
|
5829
5845
|
icon: /* @__PURE__ */ O(o, { size: 14 }),
|
|
5830
5846
|
disabled: !Fr,
|
|
5831
5847
|
onClick: () => {
|
|
5832
|
-
|
|
5848
|
+
ze && Fr && Q.refineShape(Fr, ze.img, !1);
|
|
5833
5849
|
}
|
|
5834
5850
|
}] : [],
|
|
5835
5851
|
{
|
|
5836
5852
|
id: "bringToFront",
|
|
5837
|
-
label:
|
|
5838
|
-
disabled: !Ar ||
|
|
5839
|
-
onClick:
|
|
5853
|
+
label: X.contextMenu.bringToFront,
|
|
5854
|
+
disabled: !Ar || Z,
|
|
5855
|
+
onClick: tr
|
|
5840
5856
|
},
|
|
5841
5857
|
{
|
|
5842
5858
|
id: "sendToBack",
|
|
5843
|
-
label:
|
|
5844
|
-
disabled: !Ar ||
|
|
5845
|
-
onClick:
|
|
5859
|
+
label: X.contextMenu.sendToBack,
|
|
5860
|
+
disabled: !Ar || Z,
|
|
5861
|
+
onClick: nr
|
|
5846
5862
|
},
|
|
5847
5863
|
{ separator: !0 },
|
|
5848
5864
|
{
|
|
5849
5865
|
id: "undo",
|
|
5850
|
-
label:
|
|
5866
|
+
label: X.contextMenu.undo,
|
|
5851
5867
|
shortcut: "⌘Z",
|
|
5852
|
-
disabled:
|
|
5868
|
+
disabled: Z || !An() && !q.canUndo(),
|
|
5853
5869
|
onClick: () => {
|
|
5854
|
-
|
|
5870
|
+
On() || q.undo();
|
|
5855
5871
|
}
|
|
5856
5872
|
},
|
|
5857
5873
|
{
|
|
5858
5874
|
id: "redo",
|
|
5859
|
-
label:
|
|
5875
|
+
label: X.contextMenu.redo,
|
|
5860
5876
|
shortcut: "⇧⌘Z",
|
|
5861
|
-
disabled:
|
|
5877
|
+
disabled: Z || !jn() && !q.canRedo(),
|
|
5862
5878
|
onClick: () => {
|
|
5863
|
-
|
|
5879
|
+
kn() || q.redo();
|
|
5864
5880
|
}
|
|
5865
5881
|
},
|
|
5866
5882
|
{ separator: !0 },
|
|
5867
5883
|
{
|
|
5868
5884
|
id: "selectAll",
|
|
5869
|
-
label:
|
|
5885
|
+
label: X.contextMenu.selectAll,
|
|
5870
5886
|
shortcut: "⌘A",
|
|
5871
|
-
onClick:
|
|
5887
|
+
onClick: Jn
|
|
5872
5888
|
},
|
|
5873
5889
|
{
|
|
5874
5890
|
id: "clearSelection",
|
|
5875
|
-
label:
|
|
5891
|
+
label: X.contextMenu.clearSelection,
|
|
5876
5892
|
disabled: !kr,
|
|
5877
|
-
onClick:
|
|
5893
|
+
onClick: Yn
|
|
5878
5894
|
},
|
|
5879
5895
|
{
|
|
5880
5896
|
id: "zoomToSelection",
|
|
5881
|
-
label:
|
|
5897
|
+
label: X.contextMenu.zoomToSelection,
|
|
5882
5898
|
disabled: !kr,
|
|
5883
|
-
onClick:
|
|
5899
|
+
onClick: cr
|
|
5884
5900
|
}
|
|
5885
|
-
], Lr = l ? Ir.filter((e) => "separator" in e || !!e.id &&
|
|
5886
|
-
selectedIds:
|
|
5887
|
-
readOnly:
|
|
5888
|
-
}) : Lr, zr =
|
|
5901
|
+
], Lr = l ? Ir.filter((e) => "separator" in e || !!e.id && Cr.has(e.id)) : Ir, Rr = A ? A(Lr, {
|
|
5902
|
+
selectedIds: J,
|
|
5903
|
+
readOnly: Z
|
|
5904
|
+
}) : Lr, zr = gr({
|
|
5889
5905
|
engineRef: U,
|
|
5890
|
-
image:
|
|
5891
|
-
wheelZoom:
|
|
5906
|
+
image: G,
|
|
5907
|
+
wheelZoom: Y.wheelZoom,
|
|
5892
5908
|
minimapSize: 204
|
|
5893
5909
|
}), Br = v(() => {
|
|
5894
5910
|
U.current?.zoom100();
|
|
5895
5911
|
}, []), Vr = v(() => {
|
|
5896
|
-
|
|
5912
|
+
We((e) => !e);
|
|
5897
5913
|
}, []), Hr = v(() => {
|
|
5898
|
-
|
|
5914
|
+
Ke((e) => !e);
|
|
5899
5915
|
}, []), Ur = v(() => {
|
|
5900
|
-
|
|
5916
|
+
Ke(!1);
|
|
5901
5917
|
}, []);
|
|
5902
5918
|
return /* @__PURE__ */ k("div", {
|
|
5903
5919
|
className: "aivex:relative aivex:h-full aivex:w-full aivex:overflow-hidden aivex:bg-black",
|
|
@@ -5906,17 +5922,17 @@ function Dr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5906
5922
|
ref: we,
|
|
5907
5923
|
className: "aivex:h-full aivex:w-full",
|
|
5908
5924
|
style: {
|
|
5909
|
-
opacity: +!!
|
|
5910
|
-
transition:
|
|
5925
|
+
opacity: +!!Me,
|
|
5926
|
+
transition: Me ? "opacity 0.3s ease" : "none"
|
|
5911
5927
|
}
|
|
5912
5928
|
}),
|
|
5913
|
-
|
|
5914
|
-
status:
|
|
5929
|
+
tt !== "ready" && /* @__PURE__ */ O(Le, {
|
|
5930
|
+
status: tt,
|
|
5915
5931
|
render: n,
|
|
5916
|
-
loadingLabel:
|
|
5917
|
-
errorLabel:
|
|
5932
|
+
loadingLabel: X.imageLoading,
|
|
5933
|
+
errorLabel: X.imageLoadError
|
|
5918
5934
|
}),
|
|
5919
|
-
|
|
5935
|
+
K && G && /* @__PURE__ */ O("div", {
|
|
5920
5936
|
className: "aivex:pointer-events-none aivex:absolute aivex:inset-0 aivex:overflow-hidden",
|
|
5921
5937
|
children: /* @__PURE__ */ k("div", {
|
|
5922
5938
|
ref: Ee,
|
|
@@ -5924,8 +5940,8 @@ function Dr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5924
5940
|
position: "absolute",
|
|
5925
5941
|
top: 0,
|
|
5926
5942
|
left: 0,
|
|
5927
|
-
width:
|
|
5928
|
-
height:
|
|
5943
|
+
width: G.w,
|
|
5944
|
+
height: G.h,
|
|
5929
5945
|
transformOrigin: "0 0"
|
|
5930
5946
|
},
|
|
5931
5947
|
children: [
|
|
@@ -5934,8 +5950,8 @@ function Dr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5934
5950
|
position: "absolute",
|
|
5935
5951
|
left: 0,
|
|
5936
5952
|
top: 0,
|
|
5937
|
-
width:
|
|
5938
|
-
height:
|
|
5953
|
+
width: G.w,
|
|
5954
|
+
height: G.h,
|
|
5939
5955
|
pointerEvents: "none"
|
|
5940
5956
|
},
|
|
5941
5957
|
children: L.map((e) => /* @__PURE__ */ O("div", {
|
|
@@ -5963,7 +5979,7 @@ function Dr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5963
5979
|
}, e.id))
|
|
5964
5980
|
}),
|
|
5965
5981
|
B?.({
|
|
5966
|
-
image:
|
|
5982
|
+
image: G,
|
|
5967
5983
|
viewport: U.current?.viewport ?? {
|
|
5968
5984
|
scale: 1,
|
|
5969
5985
|
x: 0,
|
|
@@ -5975,57 +5991,57 @@ function Dr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5975
5991
|
getLabel: ce,
|
|
5976
5992
|
hideDot: V,
|
|
5977
5993
|
formatInfo: le,
|
|
5978
|
-
register:
|
|
5994
|
+
register: mn
|
|
5979
5995
|
}),
|
|
5980
|
-
de && (
|
|
5981
|
-
image:
|
|
5982
|
-
points:
|
|
5983
|
-
boxes:
|
|
5984
|
-
status:
|
|
5996
|
+
de && (Q.status === "loading" || Q.boxes.length > 0) && /* @__PURE__ */ O(Pe, {
|
|
5997
|
+
image: G,
|
|
5998
|
+
points: Q.points,
|
|
5999
|
+
boxes: Q.boxes,
|
|
6000
|
+
status: Q.status
|
|
5985
6001
|
})
|
|
5986
6002
|
]
|
|
5987
6003
|
})
|
|
5988
6004
|
}),
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
image:
|
|
5992
|
-
imageUrl:
|
|
5993
|
-
imageVisible:
|
|
5994
|
-
loading: !
|
|
5995
|
-
maskDataUrl:
|
|
5996
|
-
region:
|
|
5997
|
-
roiMaskId:
|
|
5998
|
-
shapes:
|
|
5999
|
-
view:
|
|
6000
|
-
viewDefaults:
|
|
6001
|
-
onChangeView:
|
|
6005
|
+
K && Y.showCursorGuide && /* @__PURE__ */ O(Ie, { color: "#1e88e5" }),
|
|
6006
|
+
G && w && /* @__PURE__ */ O(Xe, {
|
|
6007
|
+
image: G,
|
|
6008
|
+
imageUrl: et,
|
|
6009
|
+
imageVisible: Me,
|
|
6010
|
+
loading: !K,
|
|
6011
|
+
maskDataUrl: xt,
|
|
6012
|
+
region: St,
|
|
6013
|
+
roiMaskId: Oe,
|
|
6014
|
+
shapes: pr,
|
|
6015
|
+
view: Y,
|
|
6016
|
+
viewDefaults: pt,
|
|
6017
|
+
onChangeView: _t,
|
|
6002
6018
|
nav: zr,
|
|
6003
|
-
registerShape:
|
|
6019
|
+
registerShape: ln,
|
|
6004
6020
|
rectRef: Te,
|
|
6005
6021
|
zoomLabelRef: De,
|
|
6006
6022
|
onZoom100: Br,
|
|
6007
|
-
open:
|
|
6023
|
+
open: Ue,
|
|
6008
6024
|
onToggleOpen: Vr,
|
|
6009
|
-
labels:
|
|
6010
|
-
settingsLabels:
|
|
6025
|
+
labels: X.minimap,
|
|
6026
|
+
settingsLabels: X.viewSettings,
|
|
6011
6027
|
showSettings: D,
|
|
6012
|
-
settingsOpen:
|
|
6028
|
+
settingsOpen: Ge,
|
|
6013
6029
|
onToggleSettings: Hr,
|
|
6014
6030
|
onCloseSettings: Ur
|
|
6015
6031
|
}),
|
|
6016
|
-
|
|
6017
|
-
x:
|
|
6018
|
-
y:
|
|
6032
|
+
ze && /* @__PURE__ */ O(Fe, {
|
|
6033
|
+
x: ze.x,
|
|
6034
|
+
y: ze.y,
|
|
6019
6035
|
items: Rr,
|
|
6020
|
-
onClose: () =>
|
|
6036
|
+
onClose: () => Be(null)
|
|
6021
6037
|
})
|
|
6022
6038
|
]
|
|
6023
6039
|
});
|
|
6024
6040
|
}
|
|
6025
6041
|
//#endregion
|
|
6026
6042
|
//#region src/components/ShapeEditor/ShapeViewer.tsx
|
|
6027
|
-
async function
|
|
6028
|
-
let t = await
|
|
6043
|
+
async function Er(e) {
|
|
6044
|
+
let t = await Fn(e);
|
|
6029
6045
|
return await new Promise((n, r) => {
|
|
6030
6046
|
let i = new Image();
|
|
6031
6047
|
t || (i.crossOrigin = "anonymous"), i.onload = () => n({
|
|
@@ -6036,16 +6052,16 @@ async function Or(e) {
|
|
|
6036
6052
|
}, i.src = t ?? e;
|
|
6037
6053
|
});
|
|
6038
6054
|
}
|
|
6039
|
-
function
|
|
6055
|
+
function Dr(e, t, n) {
|
|
6040
6056
|
if (t.length !== 0) {
|
|
6041
6057
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
6042
6058
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
6043
6059
|
n && e.closePath();
|
|
6044
6060
|
}
|
|
6045
6061
|
}
|
|
6046
|
-
function
|
|
6062
|
+
function Or(e, t, n, r) {
|
|
6047
6063
|
if (t.interaction?.visible === !1) return;
|
|
6048
|
-
let i =
|
|
6064
|
+
let i = Ue(t, {
|
|
6049
6065
|
strokeWidth: r,
|
|
6050
6066
|
pointRadius: 2
|
|
6051
6067
|
});
|
|
@@ -6060,10 +6076,10 @@ function Ar(e, t, n, r) {
|
|
|
6060
6076
|
let i = Math.min(n.x, r.x), a = Math.min(n.y, r.y), o = Math.abs(r.x - n.x), s = Math.abs(r.y - n.y);
|
|
6061
6077
|
e.beginPath(), t.type === F.ELLIPSE ? e.ellipse(i + o / 2, a + s / 2, o / 2, s / 2, 0, 0, Math.PI * 2) : e.rect(i, a, o, s);
|
|
6062
6078
|
}
|
|
6063
|
-
} else
|
|
6079
|
+
} else Dr(e, t.points, t.type !== F.LINE);
|
|
6064
6080
|
i.fillVisible && (e.save(), e.fillStyle = i.color, e.globalAlpha *= i.fillAlpha, e.fill(), e.restore()), t.style?.alternateColor && i.dash?.length && (e.setLineDash([]), e.strokeStyle = t.style.alternateColor, e.stroke()), e.setLineDash((i.dash ?? []).map((e) => e / n)), e.strokeStyle = i.color, e.stroke(), e.restore();
|
|
6065
6081
|
}
|
|
6066
|
-
function
|
|
6082
|
+
function kr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes: r = [], regionMask: i, guideMask: a, maskPalette: o, focusedShapeId: s, focusFit: c = "contain", zoomPadding: l = .3, strokeSize: u = 1, brightness: d = 1, contrast: f = 1, imageSmoothing: p = !0, lazy: m = !0, className: h, style: g, renderImageState: _ }) {
|
|
6067
6083
|
let v = T(null), b = T(null), x = T(null), [S, w] = E(!m), [D, A] = E("loading"), [j, M] = E(0);
|
|
6068
6084
|
y(() => {
|
|
6069
6085
|
if (!m || S) return;
|
|
@@ -6084,7 +6100,7 @@ function jr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6084
6100
|
return;
|
|
6085
6101
|
}
|
|
6086
6102
|
let t = !0;
|
|
6087
|
-
return A("loading"),
|
|
6103
|
+
return A("loading"), Er(e).then((e) => {
|
|
6088
6104
|
if (!t) {
|
|
6089
6105
|
e.revoke?.();
|
|
6090
6106
|
return;
|
|
@@ -6098,7 +6114,7 @@ function jr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6098
6114
|
}, [e, S]), y(() => () => {
|
|
6099
6115
|
x.current?.revoke?.(), x.current = null;
|
|
6100
6116
|
}, []);
|
|
6101
|
-
let N = C(() => r.find((e) => e.id === s), [s, r]), P = C(() => a && o ?
|
|
6117
|
+
let N = C(() => r.find((e) => e.id === s), [s, r]), P = C(() => a && o ? Ot(a, o) : null, [a, o]);
|
|
6102
6118
|
return y(() => {
|
|
6103
6119
|
if (D === "error") {
|
|
6104
6120
|
let e = b.current;
|
|
@@ -6121,20 +6137,20 @@ function jr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6121
6137
|
y = Math.min(o / (t + r * 2), s / (n + r * 2)), c === "cover" && (y = Math.max(y, Math.max(o / g, s / _))), S = o / 2 - (e.minX + e.maxX) / 2 * y, C = s / 2 - (e.minY + e.maxY) / 2 * y, c === "cover" && (S = Math.min(0, Math.max(S, o - g * y)), C = Math.min(0, Math.max(C, s - _ * y)));
|
|
6122
6138
|
}
|
|
6123
6139
|
h.setTransform(m, 0, 0, m, 0, 0), h.clearRect(0, 0, o, s), h.save(), h.translate(S, C), h.scale(y, y), h.imageSmoothingEnabled = p, h.filter = `brightness(${d}) contrast(${f})`, h.drawImage(a.image, 0, 0, g, _), h.filter = "none", P && (h.save(), h.globalAlpha = .55, h.drawImage(P, 0, 0, g, _), h.restore());
|
|
6124
|
-
let w = i ?
|
|
6125
|
-
if (w && (
|
|
6140
|
+
let w = i ? zt(i, g, _) : null;
|
|
6141
|
+
if (w && (Ft(h, w, g, _), w.outlineStyles)) {
|
|
6126
6142
|
let e = (e, t) => {
|
|
6127
6143
|
if (h.lineWidth = t.width / y, t.underlayColor) {
|
|
6128
6144
|
h.setLineDash([]), h.strokeStyle = t.underlayColor;
|
|
6129
|
-
for (let [t, n] of e)
|
|
6145
|
+
for (let [t, n] of e) Dr(h, [t, n], !1), h.stroke();
|
|
6130
6146
|
}
|
|
6131
6147
|
h.save(), h.globalAlpha *= t.opacity, h.setLineDash(t.dash.map((e) => e / y)), h.strokeStyle = t.color;
|
|
6132
|
-
for (let [t, n] of e)
|
|
6148
|
+
for (let [t, n] of e) Dr(h, [t, n], !1), h.stroke();
|
|
6133
6149
|
h.restore();
|
|
6134
6150
|
};
|
|
6135
6151
|
e(w.visibleOutline, w.outlineStyles.visible), e(w.occludedOutline, w.outlineStyles.occluded);
|
|
6136
6152
|
}
|
|
6137
|
-
for (let e of R(r))
|
|
6153
|
+
for (let e of R(r)) Or(h, e, y, u);
|
|
6138
6154
|
h.restore();
|
|
6139
6155
|
}, [
|
|
6140
6156
|
d,
|
|
@@ -6174,6 +6190,6 @@ function jr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6174
6190
|
});
|
|
6175
6191
|
}
|
|
6176
6192
|
//#endregion
|
|
6177
|
-
export {
|
|
6193
|
+
export { Oe as DEFAULT_EDITOR_STRINGS, Ae as DEFAULT_VIEW_SETTINGS, F as SHAPE_TYPE, Tr as ShapeEditor, Tr as default, kr as ShapeViewer, W as TOOL, se as generateId };
|
|
6178
6194
|
|
|
6179
6195
|
//# sourceMappingURL=shape-editor.js.map
|