@aivex/ui 1.2.0-dev.41 → 1.2.0-dev.42
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/comment.cjs +3 -2
- package/dist/comment.cjs.map +1 -1
- package/dist/comment.js +61 -30
- package/dist/comment.js.map +1 -1
- package/dist/components/Comment/mentionContent.d.ts +5 -0
- package/dist/components/Comment/mentionContent.test.d.ts +1 -0
- package/dist/components/ShapeEditor/_components/SelectionInfo.d.ts +7 -2
- package/dist/components/ShapeEditor/_state/useMinimapSync.d.ts +3 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/shape-editor.cjs +1 -1
- package/dist/shape-editor.cjs.map +1 -1
- package/dist/shape-editor.js +680 -652
- package/dist/shape-editor.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/shape-editor.js
CHANGED
|
@@ -1280,7 +1280,7 @@ var X = {
|
|
|
1280
1280
|
className: `aivex:absolute ${X[E]} aivex:w-[220px] aivex:rounded-[12px] aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:p-md aivex:shadow-[0_4px_12px_rgba(13,13,18,0.24)]`,
|
|
1281
1281
|
children: [te ? R : re, te ? re : R]
|
|
1282
1282
|
});
|
|
1283
|
-
}), gt =
|
|
1283
|
+
}), gt = 6, _t = {
|
|
1284
1284
|
fontFamily: "Pretendard, sans-serif",
|
|
1285
1285
|
fontSize: 12,
|
|
1286
1286
|
fontWeight: 500,
|
|
@@ -1289,7 +1289,7 @@ var X = {
|
|
|
1289
1289
|
textShadow: "0 0 4px #000, 0 0 4px #000",
|
|
1290
1290
|
whiteSpace: "nowrap"
|
|
1291
1291
|
};
|
|
1292
|
-
function
|
|
1292
|
+
function Z(e) {
|
|
1293
1293
|
let t = U(e);
|
|
1294
1294
|
return {
|
|
1295
1295
|
x: t.minX,
|
|
@@ -1298,25 +1298,39 @@ function vt(e) {
|
|
|
1298
1298
|
height: t.maxY - t.minY
|
|
1299
1299
|
};
|
|
1300
1300
|
}
|
|
1301
|
-
function
|
|
1302
|
-
return `
|
|
1301
|
+
function vt(e, t) {
|
|
1302
|
+
return `translate(${t.x + e.x * t.scale}px, ${t.y + e.y * t.scale}px)`;
|
|
1303
1303
|
}
|
|
1304
|
-
function
|
|
1305
|
-
|
|
1306
|
-
|
|
1304
|
+
function yt(e, t) {
|
|
1305
|
+
return `translate(${e.width * t.scale}px, ${e.height * t.scale}px) translate(-100%, ${gt}px)`;
|
|
1306
|
+
}
|
|
1307
|
+
function bt(e, t, n) {
|
|
1308
|
+
e.dataset.bx = String(t.x), e.dataset.by = String(t.y), e.dataset.bw = String(t.width), e.dataset.bh = String(t.height), e.style.transform = vt(t, n);
|
|
1307
1309
|
let r = e.querySelector("[data-selinfo-dim]");
|
|
1308
|
-
return r && (r.style.transform = yt(n)), r;
|
|
1310
|
+
return r && (r.style.transform = yt(t, n)), r;
|
|
1311
|
+
}
|
|
1312
|
+
function xt(e, t, n) {
|
|
1313
|
+
return bt(e, Z(t), n);
|
|
1314
|
+
}
|
|
1315
|
+
function St(e, t) {
|
|
1316
|
+
let { bx: n, by: r, bw: i, bh: a } = e.dataset;
|
|
1317
|
+
n == null || r == null || i == null || a == null || bt(e, {
|
|
1318
|
+
x: Number(n),
|
|
1319
|
+
y: Number(r),
|
|
1320
|
+
width: Number(i),
|
|
1321
|
+
height: Number(a)
|
|
1322
|
+
}, t);
|
|
1309
1323
|
}
|
|
1310
|
-
function
|
|
1324
|
+
function Ct(e, t) {
|
|
1311
1325
|
return {
|
|
1312
1326
|
shape: e,
|
|
1313
|
-
...
|
|
1327
|
+
...Z(t)
|
|
1314
1328
|
};
|
|
1315
1329
|
}
|
|
1316
|
-
function
|
|
1330
|
+
function wt(e) {
|
|
1317
1331
|
return `${Math.round(e.width)} x ${Math.round(e.height)} px`;
|
|
1318
1332
|
}
|
|
1319
|
-
function
|
|
1333
|
+
function Tt({ color: e, striped: t }) {
|
|
1320
1334
|
return /* @__PURE__ */ x("span", { style: {
|
|
1321
1335
|
display: "inline-block",
|
|
1322
1336
|
width: 12,
|
|
@@ -1328,20 +1342,23 @@ function Ct({ color: e, striped: t }) {
|
|
|
1328
1342
|
} : { background: e }
|
|
1329
1343
|
} });
|
|
1330
1344
|
}
|
|
1331
|
-
function
|
|
1345
|
+
function Et({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i, viewport: a }) {
|
|
1332
1346
|
return /* @__PURE__ */ x(b, { children: e.map((e) => {
|
|
1333
|
-
let
|
|
1347
|
+
let o = Z(e.points), s = e.type === R.POINT, c = s ? void 0 : t?.(e), l = e.style?.color ?? "#00e5ff", u = !!e.style?.dashed || !!e.style?.dash, d = Ct(e, e.points), f = r ? r(d) : wt(d);
|
|
1334
1348
|
return /* @__PURE__ */ S("div", {
|
|
1335
1349
|
ref: (t) => i(e.id, t),
|
|
1350
|
+
"data-bx": o.x,
|
|
1351
|
+
"data-by": o.y,
|
|
1352
|
+
"data-bw": o.width,
|
|
1353
|
+
"data-bh": o.height,
|
|
1336
1354
|
style: {
|
|
1337
1355
|
position: "absolute",
|
|
1338
1356
|
left: 0,
|
|
1339
1357
|
top: 0,
|
|
1340
|
-
transform:
|
|
1341
|
-
willChange: "transform",
|
|
1358
|
+
transform: vt(o, a),
|
|
1342
1359
|
pointerEvents: "none"
|
|
1343
1360
|
},
|
|
1344
|
-
children: [!!
|
|
1361
|
+
children: [!!c && /* @__PURE__ */ S("div", {
|
|
1345
1362
|
style: {
|
|
1346
1363
|
position: "absolute",
|
|
1347
1364
|
left: 0,
|
|
@@ -1349,105 +1366,102 @@ function wt({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1349
1366
|
display: "flex",
|
|
1350
1367
|
alignItems: "center",
|
|
1351
1368
|
gap: 4,
|
|
1352
|
-
transform: `
|
|
1353
|
-
|
|
1354
|
-
...Z
|
|
1369
|
+
transform: `translateY(calc(-100% - ${gt}px))`,
|
|
1370
|
+
..._t
|
|
1355
1371
|
},
|
|
1356
|
-
children: [!n && /* @__PURE__ */ x(
|
|
1357
|
-
color:
|
|
1358
|
-
striped:
|
|
1359
|
-
}), /* @__PURE__ */ x("span", { children:
|
|
1360
|
-
}), !
|
|
1372
|
+
children: [!n && /* @__PURE__ */ x(Tt, {
|
|
1373
|
+
color: l,
|
|
1374
|
+
striped: u
|
|
1375
|
+
}), /* @__PURE__ */ x("span", { children: c })]
|
|
1376
|
+
}), !s && !!f && /* @__PURE__ */ x("div", {
|
|
1361
1377
|
"data-selinfo-dim": !0,
|
|
1362
1378
|
style: {
|
|
1363
1379
|
position: "absolute",
|
|
1364
1380
|
left: 0,
|
|
1365
1381
|
top: 0,
|
|
1366
|
-
transform: yt(a),
|
|
1367
|
-
|
|
1368
|
-
willChange: "transform",
|
|
1369
|
-
...Z
|
|
1382
|
+
transform: yt(o, a),
|
|
1383
|
+
..._t
|
|
1370
1384
|
},
|
|
1371
|
-
children:
|
|
1385
|
+
children: f
|
|
1372
1386
|
})]
|
|
1373
1387
|
}, e.id);
|
|
1374
1388
|
}) });
|
|
1375
1389
|
}
|
|
1376
1390
|
//#endregion
|
|
1377
1391
|
//#region src/components/ShapeEditor/_model/clipboard.ts
|
|
1378
|
-
var
|
|
1379
|
-
function
|
|
1392
|
+
var Dt = "AIVEX_SHAPE_EDITOR:", Ot = 1, kt = new Set(Object.values(R)), At = null, Q = "unavailable", jt = 0;
|
|
1393
|
+
function Mt(e) {
|
|
1380
1394
|
if (!e || typeof e != "object") return !1;
|
|
1381
1395
|
let t = e;
|
|
1382
1396
|
return Number.isFinite(t.x) && Number.isFinite(t.y);
|
|
1383
1397
|
}
|
|
1384
|
-
function
|
|
1398
|
+
function Nt(e) {
|
|
1385
1399
|
if (!e || typeof e != "object") return !1;
|
|
1386
1400
|
let t = e;
|
|
1387
|
-
return typeof t.type == "string" &&
|
|
1401
|
+
return typeof t.type == "string" && kt.has(t.type) && Array.isArray(t.points) && t.points.length > 0 && t.points.every(Mt);
|
|
1388
1402
|
}
|
|
1389
|
-
function
|
|
1403
|
+
function Pt(e, t, n) {
|
|
1390
1404
|
return {
|
|
1391
1405
|
kind: "aivex-shape-editor",
|
|
1392
|
-
version:
|
|
1406
|
+
version: Ot,
|
|
1393
1407
|
scope: n,
|
|
1394
1408
|
documentId: t,
|
|
1395
1409
|
shapes: e
|
|
1396
1410
|
};
|
|
1397
1411
|
}
|
|
1398
|
-
function
|
|
1412
|
+
function Ft(e) {
|
|
1399
1413
|
let t = 2166136261;
|
|
1400
1414
|
for (let n = 0; n < e.length; n += 1) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
1401
1415
|
return `fnv1a:${(t >>> 0).toString(36)}`;
|
|
1402
1416
|
}
|
|
1403
|
-
function Ft(e) {
|
|
1404
|
-
return `${Tt}${JSON.stringify(e)}`;
|
|
1405
|
-
}
|
|
1406
1417
|
function It(e) {
|
|
1407
|
-
|
|
1418
|
+
return `${Dt}${JSON.stringify(e)}`;
|
|
1419
|
+
}
|
|
1420
|
+
function $(e) {
|
|
1421
|
+
if (!e.startsWith(Dt)) return null;
|
|
1408
1422
|
try {
|
|
1409
1423
|
let t = JSON.parse(e.slice(19));
|
|
1410
|
-
return t.kind !== "aivex-shape-editor" || t.version !==
|
|
1424
|
+
return t.kind !== "aivex-shape-editor" || t.version !== Ot || !Array.isArray(t.shapes) || t.shapes.length === 0 || !t.shapes.every(Nt) || t.scope !== void 0 && typeof t.scope != "string" || t.documentId !== void 0 && typeof t.documentId != "string" ? null : t;
|
|
1411
1425
|
} catch {
|
|
1412
1426
|
return null;
|
|
1413
1427
|
}
|
|
1414
1428
|
}
|
|
1415
|
-
function
|
|
1416
|
-
|
|
1417
|
-
let t = ++
|
|
1429
|
+
function Lt(e) {
|
|
1430
|
+
At = e;
|
|
1431
|
+
let t = ++jt;
|
|
1418
1432
|
if (typeof navigator > "u" || !navigator.clipboard?.writeText) {
|
|
1419
|
-
|
|
1433
|
+
Q = "unavailable";
|
|
1420
1434
|
return;
|
|
1421
1435
|
}
|
|
1422
1436
|
let n;
|
|
1423
1437
|
try {
|
|
1424
|
-
n =
|
|
1438
|
+
n = It(e);
|
|
1425
1439
|
} catch {
|
|
1426
|
-
|
|
1440
|
+
Q = "unavailable";
|
|
1427
1441
|
return;
|
|
1428
1442
|
}
|
|
1429
|
-
|
|
1430
|
-
t ===
|
|
1443
|
+
Q = "pending", navigator.clipboard.writeText(n).then(() => {
|
|
1444
|
+
t === jt && (Q = "written");
|
|
1431
1445
|
}, () => {
|
|
1432
|
-
t ===
|
|
1446
|
+
t === jt && (Q = "unavailable");
|
|
1433
1447
|
});
|
|
1434
1448
|
}
|
|
1435
|
-
function
|
|
1449
|
+
function Rt(e, t) {
|
|
1436
1450
|
return !!e && e.scope === t;
|
|
1437
1451
|
}
|
|
1438
|
-
function
|
|
1439
|
-
return
|
|
1452
|
+
function zt(e) {
|
|
1453
|
+
return Rt(At, e) || typeof navigator < "u" && typeof navigator.clipboard?.readText == "function";
|
|
1440
1454
|
}
|
|
1441
|
-
async function
|
|
1442
|
-
let t =
|
|
1443
|
-
if (t &&
|
|
1455
|
+
async function Bt(e) {
|
|
1456
|
+
let t = Rt(At, e) ? At : null;
|
|
1457
|
+
if (t && Q !== "written") return t;
|
|
1444
1458
|
if (typeof navigator < "u" && navigator.clipboard?.readText) try {
|
|
1445
|
-
let t =
|
|
1446
|
-
return t?.scope === e ? (
|
|
1459
|
+
let t = $(await navigator.clipboard.readText());
|
|
1460
|
+
return t?.scope === e ? (At = t, t) : null;
|
|
1447
1461
|
} catch {}
|
|
1448
1462
|
return t;
|
|
1449
1463
|
}
|
|
1450
|
-
function
|
|
1464
|
+
function Vt(e, t, n) {
|
|
1451
1465
|
return {
|
|
1452
1466
|
offset: n * (t ? e : e + 1),
|
|
1453
1467
|
nextPasteCount: e + 1
|
|
@@ -1455,7 +1469,7 @@ function Bt(e, t, n) {
|
|
|
1455
1469
|
}
|
|
1456
1470
|
//#endregion
|
|
1457
1471
|
//#region src/components/ShapeEditor/_model/cursors.ts
|
|
1458
|
-
var
|
|
1472
|
+
var Ht = new Set([
|
|
1459
1473
|
q.RECTANGLE,
|
|
1460
1474
|
q.ROTATED_RECTANGLE,
|
|
1461
1475
|
q.CIRCLE,
|
|
@@ -1466,7 +1480,7 @@ var Vt = new Set([
|
|
|
1466
1480
|
q.ASSISTANT_POLYGON,
|
|
1467
1481
|
q.ASSISTANT_RECT,
|
|
1468
1482
|
q.ASSISTANT_POINT
|
|
1469
|
-
]),
|
|
1483
|
+
]), Ut = {
|
|
1470
1484
|
tl: -135,
|
|
1471
1485
|
t: -90,
|
|
1472
1486
|
tr: -45,
|
|
@@ -1475,25 +1489,25 @@ var Vt = new Set([
|
|
|
1475
1489
|
b: 90,
|
|
1476
1490
|
bl: 135,
|
|
1477
1491
|
l: 180
|
|
1478
|
-
},
|
|
1492
|
+
}, Wt = [
|
|
1479
1493
|
"ew-resize",
|
|
1480
1494
|
"nwse-resize",
|
|
1481
1495
|
"ns-resize",
|
|
1482
1496
|
"nesw-resize"
|
|
1483
|
-
],
|
|
1497
|
+
], Gt = "grab-unselected", Kt = new Set([
|
|
1484
1498
|
q.RECTANGLE,
|
|
1485
1499
|
q.ROTATED_RECTANGLE,
|
|
1486
1500
|
q.CIRCLE
|
|
1487
1501
|
]);
|
|
1488
|
-
function
|
|
1489
|
-
let n = ((
|
|
1490
|
-
return
|
|
1502
|
+
function qt(e, t = 0) {
|
|
1503
|
+
let n = ((Ut[e] + t * 180 / Math.PI) % 180 + 180) % 180;
|
|
1504
|
+
return Wt[Math.round(n / 45) % 4];
|
|
1491
1505
|
}
|
|
1492
|
-
function
|
|
1493
|
-
return n ? "grab" : t || (e === q.SELECT ? "default" :
|
|
1506
|
+
function Jt({ tool: e, externalToolCursor: t, isSpacePressed: n, isPolygonDrawing: r }) {
|
|
1507
|
+
return n ? "grab" : t || (e === q.SELECT ? "default" : Ht.has(e) ? r ? "default" : "crosshair" : "default");
|
|
1494
1508
|
}
|
|
1495
|
-
function
|
|
1496
|
-
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e === q.SELECT && i ? i === "grab-unselected" ? "grab" : i :
|
|
1509
|
+
function Yt({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode: r, rendererCursorHint: i, isPolygonDrawing: a }) {
|
|
1510
|
+
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e === q.SELECT && i ? i === "grab-unselected" ? "grab" : i : Kt.has(e) && i && i !== "grab-unselected" ? i : Jt({
|
|
1497
1511
|
tool: e,
|
|
1498
1512
|
externalToolCursor: t,
|
|
1499
1513
|
isSpacePressed: n,
|
|
@@ -1502,12 +1516,12 @@ function Jt({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode
|
|
|
1502
1516
|
}
|
|
1503
1517
|
//#endregion
|
|
1504
1518
|
//#region src/components/ShapeEditor/_model/overlays.ts
|
|
1505
|
-
function
|
|
1519
|
+
function Xt(e, t) {
|
|
1506
1520
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
1507
1521
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
1508
1522
|
e.closePath();
|
|
1509
1523
|
}
|
|
1510
|
-
var
|
|
1524
|
+
var Zt = (e) => [
|
|
1511
1525
|
{
|
|
1512
1526
|
x: e.x,
|
|
1513
1527
|
y: e.y
|
|
@@ -1525,7 +1539,7 @@ var Xt = (e) => [
|
|
|
1525
1539
|
y: e.y + e.h
|
|
1526
1540
|
}
|
|
1527
1541
|
];
|
|
1528
|
-
function
|
|
1542
|
+
function Qt(e, t) {
|
|
1529
1543
|
let n = !1;
|
|
1530
1544
|
for (let r = 0, i = t.length - 1; r < t.length; i = r, r += 1) {
|
|
1531
1545
|
let a = t[r], o = t[i];
|
|
@@ -1536,7 +1550,7 @@ function Zt(e, t) {
|
|
|
1536
1550
|
}
|
|
1537
1551
|
return n;
|
|
1538
1552
|
}
|
|
1539
|
-
function
|
|
1553
|
+
function $t(e, t, n) {
|
|
1540
1554
|
let r = [], i = t.x - e.x, a = t.y - e.y;
|
|
1541
1555
|
for (let t = 0; t < n.length; t += 1) {
|
|
1542
1556
|
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;
|
|
@@ -1546,15 +1560,15 @@ function Qt(e, t, n) {
|
|
|
1546
1560
|
}
|
|
1547
1561
|
return r;
|
|
1548
1562
|
}
|
|
1549
|
-
function
|
|
1563
|
+
function en(e, t, n) {
|
|
1550
1564
|
let r = .001, i = [], a = (e, t, n) => ({
|
|
1551
1565
|
x: e.x + (t.x - e.x) * n,
|
|
1552
1566
|
y: e.y + (t.y - e.y) * n
|
|
1553
1567
|
});
|
|
1554
1568
|
for (let o of e) if (!(o.length < 2)) for (let e = 0; e < o.length; e += 1) {
|
|
1555
1569
|
let s = o[e], c = o[(e + 1) % o.length], l = [0, 1];
|
|
1556
|
-
for (let e of t) e !== o && l.push(
|
|
1557
|
-
if (n) for (let e of n) l.push(
|
|
1570
|
+
for (let e of t) e !== o && l.push(...$t(s, c, e));
|
|
1571
|
+
if (n) for (let e of n) l.push(...$t(s, c, e));
|
|
1558
1572
|
let u = Math.hypot(c.x - s.x, c.y - s.y);
|
|
1559
1573
|
if (!u) continue;
|
|
1560
1574
|
let d = -(c.y - s.y) / u * r, f = (c.x - s.x) / u * r;
|
|
@@ -1568,13 +1582,13 @@ function $t(e, t, n) {
|
|
|
1568
1582
|
}, h = {
|
|
1569
1583
|
x: p.x - d,
|
|
1570
1584
|
y: p.y - f
|
|
1571
|
-
}, g =
|
|
1572
|
-
t.some((e) => e !== o &&
|
|
1585
|
+
}, g = Qt(m, o) ? m : h, _ = g === m ? h : m;
|
|
1586
|
+
t.some((e) => e !== o && Qt(_, e)) || n && !n.some((e) => Qt(g, e)) || i.push([a(s, c, r), a(s, c, u)]);
|
|
1573
1587
|
}
|
|
1574
1588
|
}
|
|
1575
1589
|
return i;
|
|
1576
1590
|
}
|
|
1577
|
-
function
|
|
1591
|
+
function tn(e) {
|
|
1578
1592
|
let t = [...new Set(e.flatMap((e) => [e.x, e.x + e.w]))].sort((e, t) => e - t), n = [];
|
|
1579
1593
|
for (let r = 0; r + 1 < t.length; r += 1) {
|
|
1580
1594
|
let i = t[r], a = t[r + 1];
|
|
@@ -1595,45 +1609,45 @@ function en(e) {
|
|
|
1595
1609
|
}
|
|
1596
1610
|
return n;
|
|
1597
1611
|
}
|
|
1598
|
-
function
|
|
1612
|
+
function nn(e, t, n, r) {
|
|
1599
1613
|
e.save(), e.globalAlpha *= t.dim.opacity, e.fillStyle = t.dim.color, e.beginPath(), e.rect(0, 0, n, r);
|
|
1600
1614
|
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();
|
|
1601
1615
|
if (e.fill(), t.zones.length) {
|
|
1602
1616
|
e.beginPath();
|
|
1603
1617
|
for (let n of t.rects) e.rect(n.x, n.y, n.w, n.h);
|
|
1604
1618
|
e.clip();
|
|
1605
|
-
for (let n of t.zones)
|
|
1619
|
+
for (let n of t.zones) Xt(e, n.points), e.fill();
|
|
1606
1620
|
}
|
|
1607
1621
|
e.restore();
|
|
1608
1622
|
}
|
|
1609
|
-
function
|
|
1623
|
+
function rn(e) {
|
|
1610
1624
|
let t = getComputedStyle(e);
|
|
1611
1625
|
return {
|
|
1612
1626
|
color: t.getPropertyValue("--aivex-static-black").trim() || "#17171c",
|
|
1613
1627
|
opacity: Number.parseFloat(t.getPropertyValue("--aivex-opacity-dim")) || .32
|
|
1614
1628
|
};
|
|
1615
1629
|
}
|
|
1616
|
-
function
|
|
1630
|
+
function an(e) {
|
|
1617
1631
|
let t = [];
|
|
1618
1632
|
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]]);
|
|
1619
1633
|
return t;
|
|
1620
1634
|
}
|
|
1621
|
-
var
|
|
1635
|
+
var on = {
|
|
1622
1636
|
color: "#000000",
|
|
1623
1637
|
opacity: .5
|
|
1624
|
-
},
|
|
1638
|
+
}, sn = {
|
|
1625
1639
|
color: "#ffffff",
|
|
1626
1640
|
opacity: 1,
|
|
1627
1641
|
width: 2,
|
|
1628
1642
|
dash: [6, 6],
|
|
1629
1643
|
underlayColor: "#000000"
|
|
1630
|
-
},
|
|
1644
|
+
}, cn = {
|
|
1631
1645
|
color: "#dc2626",
|
|
1632
1646
|
opacity: .8,
|
|
1633
1647
|
width: 2,
|
|
1634
1648
|
dash: [6, 6],
|
|
1635
1649
|
underlayColor: "#000000"
|
|
1636
|
-
},
|
|
1650
|
+
}, ln = (e, t, n) => {
|
|
1637
1651
|
let r = e.occludedAreas?.filter((e) => e.points.length >= 3) ?? [];
|
|
1638
1652
|
if (!t || !n || !e.visibleAreas.length && !r.length) return null;
|
|
1639
1653
|
let i = e.visibleAreas, a = i.length ? i : [{
|
|
@@ -1641,8 +1655,8 @@ var an = {
|
|
|
1641
1655
|
y: 0,
|
|
1642
1656
|
w: t,
|
|
1643
1657
|
h: n
|
|
1644
|
-
}], o =
|
|
1645
|
-
...
|
|
1658
|
+
}], o = tn(a), s = {
|
|
1659
|
+
...on,
|
|
1646
1660
|
...e.dim
|
|
1647
1661
|
}, c = e.outline;
|
|
1648
1662
|
if (c === !1) return {
|
|
@@ -1656,36 +1670,36 @@ var an = {
|
|
|
1656
1670
|
};
|
|
1657
1671
|
let l = {
|
|
1658
1672
|
visible: {
|
|
1659
|
-
...
|
|
1673
|
+
...sn,
|
|
1660
1674
|
...c?.visibleStyle
|
|
1661
1675
|
},
|
|
1662
1676
|
occluded: {
|
|
1663
|
-
...
|
|
1677
|
+
...cn,
|
|
1664
1678
|
...c?.occludedStyle
|
|
1665
1679
|
}
|
|
1666
|
-
}, u = i.map(
|
|
1680
|
+
}, u = i.map(Zt), d = a.map(Zt), f = r.map((e) => e.points);
|
|
1667
1681
|
return c?.mode === "separate" ? {
|
|
1668
1682
|
rects: a,
|
|
1669
1683
|
zones: r,
|
|
1670
1684
|
dimHoles: o,
|
|
1671
1685
|
dim: s,
|
|
1672
|
-
visibleOutline:
|
|
1673
|
-
occludedOutline:
|
|
1686
|
+
visibleOutline: an(u),
|
|
1687
|
+
occludedOutline: an(f),
|
|
1674
1688
|
outlineStyles: l
|
|
1675
1689
|
} : {
|
|
1676
1690
|
rects: a,
|
|
1677
1691
|
zones: r,
|
|
1678
1692
|
dimHoles: o,
|
|
1679
1693
|
dim: s,
|
|
1680
|
-
visibleOutline: [
|
|
1694
|
+
visibleOutline: [...en(u, [...u, ...f], null), ...en(f, f, d)],
|
|
1681
1695
|
occludedOutline: [],
|
|
1682
1696
|
outlineStyles: l
|
|
1683
1697
|
};
|
|
1684
|
-
},
|
|
1685
|
-
function
|
|
1698
|
+
}, un = .3, dn = .05;
|
|
1699
|
+
function fn(e) {
|
|
1686
1700
|
return 1 - (1 - e) ** 3;
|
|
1687
1701
|
}
|
|
1688
|
-
function
|
|
1702
|
+
function pn(e) {
|
|
1689
1703
|
return {
|
|
1690
1704
|
x: e.minX,
|
|
1691
1705
|
y: e.minY,
|
|
@@ -1693,7 +1707,7 @@ function fn(e) {
|
|
|
1693
1707
|
height: Math.max(0, e.maxY - e.minY)
|
|
1694
1708
|
};
|
|
1695
1709
|
}
|
|
1696
|
-
function
|
|
1710
|
+
function mn(e, t) {
|
|
1697
1711
|
if (!t.length) return null;
|
|
1698
1712
|
if (e === R.POINT) {
|
|
1699
1713
|
let e = t[0];
|
|
@@ -1712,10 +1726,10 @@ function pn(e, t) {
|
|
|
1712
1726
|
height: i
|
|
1713
1727
|
};
|
|
1714
1728
|
}
|
|
1715
|
-
function
|
|
1729
|
+
function hn(e) {
|
|
1716
1730
|
if (!e.length) return null;
|
|
1717
|
-
let t = e.map((e) =>
|
|
1718
|
-
return t.length ?
|
|
1731
|
+
let t = e.map((e) => mn(e.type, e.points)).filter((e) => e !== null);
|
|
1732
|
+
return t.length ? pn(U(t.flatMap((e) => [{
|
|
1719
1733
|
x: e.x,
|
|
1720
1734
|
y: e.y
|
|
1721
1735
|
}, {
|
|
@@ -1723,8 +1737,8 @@ function mn(e) {
|
|
|
1723
1737
|
y: e.y + e.height
|
|
1724
1738
|
}]))) : null;
|
|
1725
1739
|
}
|
|
1726
|
-
function
|
|
1727
|
-
let { containerRatio: i =
|
|
1740
|
+
function gn(e, t, n, r = {}) {
|
|
1741
|
+
let { containerRatio: i = un, minScale: a = dn, maxScale: o = 20 } = r;
|
|
1728
1742
|
if (!t || !n || e.width <= 0 || e.height <= 0) return null;
|
|
1729
1743
|
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;
|
|
1730
1744
|
return {
|
|
@@ -1733,18 +1747,18 @@ function hn(e, t, n, r = {}) {
|
|
|
1733
1747
|
y: n / 2 - u * c
|
|
1734
1748
|
};
|
|
1735
1749
|
}
|
|
1736
|
-
function
|
|
1750
|
+
function _n(e, t, n, r = 80) {
|
|
1737
1751
|
if (!t || !n) return null;
|
|
1738
|
-
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(
|
|
1752
|
+
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(dn, Math.min(20, Math.min((t - r) / i, (n - r) / a))), s = (e.minX + e.maxX) / 2, c = (e.minY + e.maxY) / 2;
|
|
1739
1753
|
return {
|
|
1740
1754
|
scale: o,
|
|
1741
1755
|
x: t / 2 - s * o,
|
|
1742
1756
|
y: n / 2 - c * o
|
|
1743
1757
|
};
|
|
1744
1758
|
}
|
|
1745
|
-
function
|
|
1759
|
+
function vn(e, t, n, r = 300) {
|
|
1746
1760
|
let i = Date.now(), a = 0, o = () => {
|
|
1747
|
-
let s = Date.now() - i, c = Math.min(s / r, 1), l =
|
|
1761
|
+
let s = Date.now() - i, c = Math.min(s / r, 1), l = fn(c);
|
|
1748
1762
|
n({
|
|
1749
1763
|
scale: e.scale + (t.scale - e.scale) * l,
|
|
1750
1764
|
x: e.x + (t.x - e.x) * l,
|
|
@@ -1755,7 +1769,7 @@ function _n(e, t, n, r = 300) {
|
|
|
1755
1769
|
}
|
|
1756
1770
|
//#endregion
|
|
1757
1771
|
//#region src/components/ShapeEditor/_state/createInteractionController.ts
|
|
1758
|
-
function
|
|
1772
|
+
function yn(e) {
|
|
1759
1773
|
let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, docRef: a, selRef: o, draftRef: s, readOnlyRef: c, disableMarqueeRef: l, lockedRef: u, onLockedInteraction: d, onDrawAttemptWithoutDraft: 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 = !1, N = "", P = null, F = null, I = null, L = (e) => e === q.RECTANGLE || e === q.ROTATED_RECTANGLE || e === q.CIRCLE, ee = (e) => e === q.ASSISTANT_POLYGON || e === q.ASSISTANT_RECT, te = (e) => e === q.POLYGON, ne = (e) => L(e) || ee(e) || te(e) || e === q.PATH || e === q.BRUSH || e === q.POINT, re = (e, t) => {
|
|
1760
1774
|
let n = !1;
|
|
1761
1775
|
D && !L(t) && !ee(t) && (D = null, e.clearPreview(), C(null), n = !0), (O === "path" && t !== q.PATH || O === "scalar" && t !== q.BRUSH) && (O = null, n = !0), k && !te(t) && (k = null, n = !0), A && t !== q.SELECT && (A = null, j = null, M = !1, e.clearMarquee(), n = !0), P && t !== q.POINT && (P = null, n = !0), n && b("idle");
|
|
@@ -2047,7 +2061,7 @@ function vn(e) {
|
|
|
2047
2061
|
}
|
|
2048
2062
|
//#endregion
|
|
2049
2063
|
//#region src/components/ShapeEditor/_state/useAssistant.ts
|
|
2050
|
-
function
|
|
2064
|
+
function bn({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistantRef: i }) {
|
|
2051
2065
|
let [a, o] = M("idle"), [s, c] = M([]), [l, u] = M([]), d = j([]), f = j([]), p = j([]), m = j("idle"), h = j(0), g = j(null), _ = j(null), v = j(0), y = w((e) => {
|
|
2052
2066
|
d.current = e(d.current), u(d.current);
|
|
2053
2067
|
}, []), b = w((e) => {
|
|
@@ -2212,17 +2226,17 @@ function yn({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
2212
2226
|
}
|
|
2213
2227
|
//#endregion
|
|
2214
2228
|
//#region src/components/ShapeEditor/_model/brush.ts
|
|
2215
|
-
function
|
|
2229
|
+
function xn(e, t, n) {
|
|
2216
2230
|
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);
|
|
2217
2231
|
return i === 0 ? 0 : r * 2 / i;
|
|
2218
2232
|
}
|
|
2219
|
-
function
|
|
2233
|
+
function Sn(e, t = 1.5) {
|
|
2220
2234
|
if (e.length <= 2) return e;
|
|
2221
2235
|
let n = (e, t) => {
|
|
2222
2236
|
if (e.length < 3) return e;
|
|
2223
2237
|
let r = 0, i = 0, a = e.length - 1;
|
|
2224
2238
|
for (let t = 1; t < a; t++) {
|
|
2225
|
-
let n =
|
|
2239
|
+
let n = xn(e[t], e[0], e[a]);
|
|
2226
2240
|
n > r && (i = t, r = n);
|
|
2227
2241
|
}
|
|
2228
2242
|
if (r > t) {
|
|
@@ -2235,8 +2249,8 @@ function xn(e, t = 1.5) {
|
|
|
2235
2249
|
}
|
|
2236
2250
|
//#endregion
|
|
2237
2251
|
//#region src/components/ShapeEditor/_model/scalarMask.ts
|
|
2238
|
-
var
|
|
2239
|
-
function
|
|
2252
|
+
var Cn = 4096, wn = 4;
|
|
2253
|
+
function Tn(e) {
|
|
2240
2254
|
let t = 0;
|
|
2241
2255
|
for (let n = 0; n < e.length; n++) {
|
|
2242
2256
|
let r = e[n], i = e[(n + 1) % e.length];
|
|
@@ -2244,17 +2258,17 @@ function wn(e) {
|
|
|
2244
2258
|
}
|
|
2245
2259
|
return Math.abs(t / 2);
|
|
2246
2260
|
}
|
|
2247
|
-
function
|
|
2261
|
+
function En(e, t, n) {
|
|
2248
2262
|
let r = new Uint8Array(t * n);
|
|
2249
2263
|
for (let i = 0; i < t * n; i++) r[i] = e[i * 4 + 3] > 128 ? 255 : 0;
|
|
2250
2264
|
return r;
|
|
2251
2265
|
}
|
|
2252
|
-
function
|
|
2266
|
+
function Dn(e) {
|
|
2253
2267
|
let t = new Uint8ClampedArray(e.length * 4);
|
|
2254
2268
|
for (let n = 0; n < e.length; n++) e[n] > 128 && (t[n * 4 + 3] = 255);
|
|
2255
2269
|
return t;
|
|
2256
2270
|
}
|
|
2257
|
-
function
|
|
2271
|
+
function On(e, t, n, r, i) {
|
|
2258
2272
|
let a = new Uint8Array(t * n), o = [[r, i]];
|
|
2259
2273
|
for (; o.length;) {
|
|
2260
2274
|
let [r, i] = o.pop(), s = i * t + r;
|
|
@@ -2262,8 +2276,8 @@ function Dn(e, t, n, r, i) {
|
|
|
2262
2276
|
}
|
|
2263
2277
|
return a;
|
|
2264
2278
|
}
|
|
2265
|
-
function
|
|
2266
|
-
let r =
|
|
2279
|
+
function kn(e, t, n) {
|
|
2280
|
+
let r = En(e, t, n), i = [];
|
|
2267
2281
|
for (;;) {
|
|
2268
2282
|
let e = -1, a = -1;
|
|
2269
2283
|
outer: for (let i = 0; i < n; i++) for (let n = 0; n < t; n++) if (r[i * t + n] > 128) {
|
|
@@ -2271,17 +2285,17 @@ function On(e, t, n) {
|
|
|
2271
2285
|
break outer;
|
|
2272
2286
|
}
|
|
2273
2287
|
if (e < 0) break;
|
|
2274
|
-
let o =
|
|
2288
|
+
let o = jn(Dn(On(r, t, n, e, a)), t, n);
|
|
2275
2289
|
o.length >= 3 && i.push(o);
|
|
2276
2290
|
}
|
|
2277
2291
|
return i;
|
|
2278
2292
|
}
|
|
2279
|
-
function
|
|
2293
|
+
function An(e, t, n, r, i) {
|
|
2280
2294
|
return r < 0 || i < 0 || r >= t || i >= n ? !1 : e[(i * t + r) * 4 + 3] > 128;
|
|
2281
2295
|
}
|
|
2282
|
-
function
|
|
2296
|
+
function jn(e, t, n) {
|
|
2283
2297
|
let r = -1, i = -1;
|
|
2284
|
-
outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if (
|
|
2298
|
+
outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if (An(e, t, n, o, a)) {
|
|
2285
2299
|
r = o, i = a;
|
|
2286
2300
|
break outer;
|
|
2287
2301
|
}
|
|
@@ -2316,7 +2330,7 @@ function An(e, t, n) {
|
|
|
2316
2330
|
let r = !1;
|
|
2317
2331
|
for (let i = 0; i < 8; i++) {
|
|
2318
2332
|
let s = (u + i) % 8, d = c + a[s], f = l + o[s];
|
|
2319
|
-
if (
|
|
2333
|
+
if (An(e, t, n, d, f)) {
|
|
2320
2334
|
c = d, l = f, u = (s + 6) % 8, r = !0;
|
|
2321
2335
|
break;
|
|
2322
2336
|
}
|
|
@@ -2325,13 +2339,13 @@ function An(e, t, n) {
|
|
|
2325
2339
|
} while (c !== d.x || l !== d.y || s.length === 1);
|
|
2326
2340
|
return s;
|
|
2327
2341
|
}
|
|
2328
|
-
function
|
|
2342
|
+
function Mn(e, t) {
|
|
2329
2343
|
let n = [];
|
|
2330
2344
|
for (let t of e) for (let e of t.points) n.push(e);
|
|
2331
2345
|
for (let e of t) for (let t of e) n.push(t);
|
|
2332
2346
|
return n;
|
|
2333
2347
|
}
|
|
2334
|
-
function
|
|
2348
|
+
function Nn(e) {
|
|
2335
2349
|
switch (e.type) {
|
|
2336
2350
|
case R.RECTANGLE: return e.points.length < 2 ? null : pe(e.points);
|
|
2337
2351
|
case R.POLYGON:
|
|
@@ -2350,14 +2364,14 @@ function Mn(e) {
|
|
|
2350
2364
|
default: return null;
|
|
2351
2365
|
}
|
|
2352
2366
|
}
|
|
2353
|
-
function
|
|
2354
|
-
return e.map(
|
|
2367
|
+
function Pn(e) {
|
|
2368
|
+
return e.map(Nn).filter((e) => !!e && e.length >= 3);
|
|
2355
2369
|
}
|
|
2356
|
-
function
|
|
2370
|
+
function Fn(e, t, n = []) {
|
|
2357
2371
|
if (t <= 0 || !e.length && !n.length) return null;
|
|
2358
|
-
let r =
|
|
2372
|
+
let r = Mn(e, n);
|
|
2359
2373
|
if (!r.length) return null;
|
|
2360
|
-
let i = t + 4, a = U(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1,
|
|
2374
|
+
let i = t + 4, a = U(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1, Cn / Math.max(o, s, 1));
|
|
2361
2375
|
o = Math.max(1, Math.ceil(o * c)), s = Math.max(1, Math.ceil(s * c));
|
|
2362
2376
|
let l = a.minX - i, u = a.minY - i, d = (e) => ({
|
|
2363
2377
|
x: (e.x - l) * c,
|
|
@@ -2396,20 +2410,20 @@ function Pn(e, t, n = []) {
|
|
|
2396
2410
|
scale: c
|
|
2397
2411
|
};
|
|
2398
2412
|
}
|
|
2399
|
-
function
|
|
2400
|
-
let { canvas: n, ox: r, oy: i, scale: a } = e, o =
|
|
2413
|
+
function In(e, t = 1.5) {
|
|
2414
|
+
let { canvas: n, ox: r, oy: i, scale: a } = e, o = kn(n.getContext("2d").getImageData(0, 0, n.width, n.height).data, n.width, n.height);
|
|
2401
2415
|
if (!o.length) return [];
|
|
2402
2416
|
let s = (e) => ({
|
|
2403
2417
|
x: e.x / a + r,
|
|
2404
2418
|
y: e.y / a + i
|
|
2405
2419
|
}), c = [];
|
|
2406
2420
|
for (let e of o) {
|
|
2407
|
-
let n = e.map(s), r =
|
|
2408
|
-
i.length >= 3 &&
|
|
2421
|
+
let n = e.map(s), r = Sn(n, t), i = r.length >= 3 ? r : n;
|
|
2422
|
+
i.length >= 3 && Tn(i) >= wn && c.push(i);
|
|
2409
2423
|
}
|
|
2410
2424
|
return c;
|
|
2411
2425
|
}
|
|
2412
|
-
function
|
|
2426
|
+
function Ln(e, t) {
|
|
2413
2427
|
let { canvas: n } = e, r = document.createElement("canvas");
|
|
2414
2428
|
r.width = n.width, r.height = n.height;
|
|
2415
2429
|
let i = r.getContext("2d");
|
|
@@ -2417,30 +2431,30 @@ function In(e, t) {
|
|
|
2417
2431
|
}
|
|
2418
2432
|
//#endregion
|
|
2419
2433
|
//#region src/components/ShapeEditor/_state/drawSessionState.ts
|
|
2420
|
-
function
|
|
2434
|
+
function Rn(e) {
|
|
2421
2435
|
return e.map((e) => ({
|
|
2422
2436
|
mode: e.mode,
|
|
2423
2437
|
points: e.points.map((e) => ({ ...e }))
|
|
2424
2438
|
}));
|
|
2425
2439
|
}
|
|
2426
|
-
function
|
|
2440
|
+
function zn(e, t) {
|
|
2427
2441
|
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));
|
|
2428
2442
|
}
|
|
2429
|
-
function
|
|
2443
|
+
function Bn(e) {
|
|
2430
2444
|
return e.map((e) => ({ ...e }));
|
|
2431
2445
|
}
|
|
2432
|
-
function
|
|
2446
|
+
function Vn(e, t) {
|
|
2433
2447
|
return e.length === t.length && e.every((e, n) => e.x === t[n].x && e.y === t[n].y);
|
|
2434
2448
|
}
|
|
2435
2449
|
//#endregion
|
|
2436
2450
|
//#region src/components/ShapeEditor/_state/useDrawSession.ts
|
|
2437
|
-
var
|
|
2438
|
-
function
|
|
2451
|
+
var Hn = 10;
|
|
2452
|
+
function Un(e, t) {
|
|
2439
2453
|
if (e.active !== t.active || e.kind !== t.kind || e.canUndo !== t.canUndo || e.canRedo !== t.canRedo) return !1;
|
|
2440
2454
|
let n = e.brush, r = t.brush;
|
|
2441
2455
|
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]);
|
|
2442
2456
|
}
|
|
2443
|
-
function
|
|
2457
|
+
function Wn({ 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 }) {
|
|
2444
2458
|
let p = j(l);
|
|
2445
2459
|
p.current = l;
|
|
2446
2460
|
let m = j(u);
|
|
@@ -2470,7 +2484,7 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2470
2484
|
editTargetIds: [...D.current]
|
|
2471
2485
|
} : void 0
|
|
2472
2486
|
}, n = _.current;
|
|
2473
|
-
n &&
|
|
2487
|
+
n && Un(n, t) || (_.current = t, p.current?.(t));
|
|
2474
2488
|
}, []), ie = w(() => {
|
|
2475
2489
|
O.current = [[]], k.current = 0;
|
|
2476
2490
|
}, []), B = w(() => {
|
|
@@ -2486,7 +2500,7 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2486
2500
|
t.clearPreview();
|
|
2487
2501
|
return;
|
|
2488
2502
|
}
|
|
2489
|
-
let n =
|
|
2503
|
+
let n = Fn(e, a.current, E.current);
|
|
2490
2504
|
if (!n) {
|
|
2491
2505
|
t.clearPreview();
|
|
2492
2506
|
return;
|
|
@@ -2508,7 +2522,7 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2508
2522
|
let e = m.current;
|
|
2509
2523
|
e && r !== C.current && (C.current = r, e({
|
|
2510
2524
|
type: R.POLYGON,
|
|
2511
|
-
points:
|
|
2525
|
+
points: Bn(r),
|
|
2512
2526
|
meta: h.current
|
|
2513
2527
|
}));
|
|
2514
2528
|
}
|
|
@@ -2518,11 +2532,11 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2518
2532
|
c,
|
|
2519
2533
|
e
|
|
2520
2534
|
]), oe = w((e) => {
|
|
2521
|
-
let t =
|
|
2522
|
-
i &&
|
|
2535
|
+
let t = Rn(e), n = O.current, r = k.current, i = n[r];
|
|
2536
|
+
i && zn(i, t) || (O.current = [...n.slice(0, r + 1), t], k.current += 1, z());
|
|
2523
2537
|
}, [z]), se = w((e) => {
|
|
2524
2538
|
let t = x.current, n = S.current, r = t[n];
|
|
2525
|
-
r &&
|
|
2539
|
+
r && Vn(r, e) || (x.current = [...t.slice(0, n + 1), Bn(e)], S.current += 1);
|
|
2526
2540
|
}, []), V = w(() => {
|
|
2527
2541
|
v.current = [], T.current = [], E.current = [], D.current = [], y.current = null, b.current = /* @__PURE__ */ new Set(), x.current = [[]], S.current = 0, C.current = null, ie(), c.current?.clearPreview(), m.current?.(null), z();
|
|
2528
2542
|
}, [
|
|
@@ -2535,7 +2549,7 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2535
2549
|
z,
|
|
2536
2550
|
se,
|
|
2537
2551
|
B
|
|
2538
|
-
]), U = w(() =>
|
|
2552
|
+
]), U = w(() => Bn(v.current), []), le = w(() => v.current.length > 0, []), ue = w((t, n) => {
|
|
2539
2553
|
if (e.current !== q.POLYGON) return !1;
|
|
2540
2554
|
let r = v.current;
|
|
2541
2555
|
if (r.length < 3) return !1;
|
|
@@ -2549,7 +2563,7 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2549
2563
|
if (e < 0 || e >= n.length) return null;
|
|
2550
2564
|
let r = new Set(b.current);
|
|
2551
2565
|
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), b.current = r, y.current = null, B(), z(), {
|
|
2552
|
-
base:
|
|
2566
|
+
base: Bn(n),
|
|
2553
2567
|
indices: Array.from(r)
|
|
2554
2568
|
};
|
|
2555
2569
|
}, [z, B]), pe = w((e) => {
|
|
@@ -2573,7 +2587,7 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2573
2587
|
B
|
|
2574
2588
|
]), ve = w((e) => {
|
|
2575
2589
|
y.current = e ? { ...e } : null, B();
|
|
2576
|
-
}, [B]), ye = w(() => v.current.length > 0 ? (v.current = [], B(), z(), !0) : k.current <= 0 ? !1 : (--k.current, T.current =
|
|
2590
|
+
}, [B]), ye = w(() => v.current.length > 0 ? (v.current = [], B(), z(), !0) : k.current <= 0 ? !1 : (--k.current, T.current = Rn(O.current[k.current]), B(), z(), !0), [z, B]), be = w(() => v.current.length > 0 || k.current >= O.current.length - 1 ? !1 : (k.current += 1, T.current = Rn(O.current[k.current]), B(), z(), !0), [z, B]), xe = w(() => S.current <= 0 ? !1 : (--S.current, v.current = Bn(x.current[S.current]), b.current = /* @__PURE__ */ new Set(), B(), z(), !0), [z, B]), Se = w(() => S.current >= x.current.length - 1 ? !1 : (S.current += 1, v.current = Bn(x.current[S.current]), b.current = /* @__PURE__ */ new Set(), B(), z(), !0), [z, B]), Ce = w(() => {
|
|
2577
2591
|
let t = e.current;
|
|
2578
2592
|
return t === q.BRUSH ? ye() : t === q.POLYGON || t === q.PATH ? xe() : !1;
|
|
2579
2593
|
}, [
|
|
@@ -2590,24 +2604,24 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2590
2604
|
]), W = w(() => {
|
|
2591
2605
|
let e = t.current;
|
|
2592
2606
|
if (!e.length) return D.current.length > 0;
|
|
2593
|
-
let r = n.current.getShapes().filter((t) => e.includes(t.id) && ae(t)), i =
|
|
2607
|
+
let r = n.current.getShapes().filter((t) => e.includes(t.id) && ae(t)), i = Pn(r);
|
|
2594
2608
|
return i.length ? (D.current = r.map((e) => e.id), E.current = i, !0) : (D.current = [], E.current = [], !1);
|
|
2595
2609
|
}, [n, t]), Te = w(() => {
|
|
2596
2610
|
if (r.current) return !1;
|
|
2597
2611
|
let e = [...T.current];
|
|
2598
2612
|
v.current.length && e.push({
|
|
2599
|
-
points:
|
|
2613
|
+
points: Bn(v.current),
|
|
2600
2614
|
mode: M()
|
|
2601
2615
|
});
|
|
2602
2616
|
let t = E.current, c = [...D.current];
|
|
2603
2617
|
if (!e.length && !t.length) return !1;
|
|
2604
|
-
let l =
|
|
2618
|
+
let l = Fn(e, a.current, t);
|
|
2605
2619
|
if (!l) return V(), !1;
|
|
2606
|
-
let u =
|
|
2620
|
+
let u = In(l, o.current);
|
|
2607
2621
|
if (c.length) {
|
|
2608
2622
|
let e = n.current.getShapes().filter((e) => c.includes(e.id));
|
|
2609
2623
|
if (!u.length) return n.current.remove(c), V(), d([]), !0;
|
|
2610
|
-
u.sort((e, t) =>
|
|
2624
|
+
u.sort((e, t) => Tn(t) - Tn(e));
|
|
2611
2625
|
let t = [], r = [], i = [];
|
|
2612
2626
|
for (let n = 0; n < u.length; n++) {
|
|
2613
2627
|
let a = u[n];
|
|
@@ -2662,7 +2676,7 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2662
2676
|
]), De = w(() => {
|
|
2663
2677
|
let t = v.current;
|
|
2664
2678
|
if (e.current === q.PATH && t.length >= 3) {
|
|
2665
|
-
let e =
|
|
2679
|
+
let e = Sn(t, o.current);
|
|
2666
2680
|
e.length >= 3 && g.current(R.POLYGON, e);
|
|
2667
2681
|
}
|
|
2668
2682
|
V();
|
|
@@ -2688,7 +2702,7 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2688
2702
|
}, [H]), Ae = w((e) => {
|
|
2689
2703
|
let t = c.current, n = v.current;
|
|
2690
2704
|
if (!t || !n.length) return -1;
|
|
2691
|
-
let r =
|
|
2705
|
+
let r = Hn / (t.viewport.scale || 1);
|
|
2692
2706
|
for (let t = n.length - 1; t >= 0; t--) {
|
|
2693
2707
|
let i = n[t];
|
|
2694
2708
|
if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
|
|
@@ -2696,7 +2710,7 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2696
2710
|
return -1;
|
|
2697
2711
|
}, [c]), je = w(() => {
|
|
2698
2712
|
v.current.length >= 1 && (T.current.push({
|
|
2699
|
-
points:
|
|
2713
|
+
points: Bn(v.current),
|
|
2700
2714
|
mode: M()
|
|
2701
2715
|
}), v.current = [], oe(T.current)), B(), z();
|
|
2702
2716
|
}, [
|
|
@@ -2771,31 +2785,31 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2771
2785
|
}
|
|
2772
2786
|
//#endregion
|
|
2773
2787
|
//#region src/components/ShapeEditor/_state/useEditorDocument.ts
|
|
2774
|
-
function
|
|
2788
|
+
function Gn(e, t) {
|
|
2775
2789
|
return {
|
|
2776
2790
|
shapes: t,
|
|
2777
2791
|
past: [...e.past, e.shapes],
|
|
2778
2792
|
future: []
|
|
2779
2793
|
};
|
|
2780
2794
|
}
|
|
2781
|
-
function
|
|
2795
|
+
function Kn(e, t) {
|
|
2782
2796
|
switch (t.type) {
|
|
2783
|
-
case "CREATE": return
|
|
2797
|
+
case "CREATE": return Gn(e, [...e.shapes, ...t.shapes]);
|
|
2784
2798
|
case "UPDATE": {
|
|
2785
2799
|
let n = new Map(t.shapes.map((e) => [e.id, e]));
|
|
2786
|
-
return
|
|
2800
|
+
return Gn(e, e.shapes.map((e) => n.get(e.id) ?? e));
|
|
2787
2801
|
}
|
|
2788
2802
|
case "DELETE": {
|
|
2789
2803
|
let n = new Set(t.ids);
|
|
2790
|
-
return
|
|
2804
|
+
return Gn(e, e.shapes.filter((e) => !n.has(e.id)));
|
|
2791
2805
|
}
|
|
2792
2806
|
case "REPLACE": {
|
|
2793
2807
|
let n = new Set(t.removeIds);
|
|
2794
|
-
return
|
|
2808
|
+
return Gn(e, [...e.shapes.filter((e) => !n.has(e.id)), ...t.shapes]);
|
|
2795
2809
|
}
|
|
2796
2810
|
case "REORDER": {
|
|
2797
2811
|
let n = new Set(t.ids), r = e.shapes.filter((e) => n.has(e.id)), i = e.shapes.filter((e) => !n.has(e.id));
|
|
2798
|
-
return r.length === 0 ? e :
|
|
2812
|
+
return r.length === 0 ? e : Gn(e, t.edge === "front" ? [...i, ...r] : [...r, ...i]);
|
|
2799
2813
|
}
|
|
2800
2814
|
case "RESET": return {
|
|
2801
2815
|
shapes: t.shapes,
|
|
@@ -2815,15 +2829,15 @@ function Gn(e, t) {
|
|
|
2815
2829
|
default: return e;
|
|
2816
2830
|
}
|
|
2817
2831
|
}
|
|
2818
|
-
function
|
|
2819
|
-
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = A(
|
|
2832
|
+
function qn(e) {
|
|
2833
|
+
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = A(Kn, {
|
|
2820
2834
|
shapes: [],
|
|
2821
2835
|
past: [],
|
|
2822
2836
|
future: []
|
|
2823
2837
|
}), o = j(i);
|
|
2824
2838
|
o.current = i;
|
|
2825
2839
|
let s = w((e) => {
|
|
2826
|
-
o.current =
|
|
2840
|
+
o.current = Kn(o.current, e), a(e);
|
|
2827
2841
|
}, []), c = w((e, i) => {
|
|
2828
2842
|
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));
|
|
2829
2843
|
s.length && t?.(s);
|
|
@@ -2892,7 +2906,7 @@ function Kn(e) {
|
|
|
2892
2906
|
}
|
|
2893
2907
|
//#endregion
|
|
2894
2908
|
//#region src/components/ShapeEditor/_model/keymap.ts
|
|
2895
|
-
var
|
|
2909
|
+
var Jn = {
|
|
2896
2910
|
undo: ["mod+z"],
|
|
2897
2911
|
redo: ["mod+shift+z"],
|
|
2898
2912
|
selectAll: ["mod+a"],
|
|
@@ -2920,7 +2934,7 @@ var qn = {
|
|
|
2920
2934
|
pathTool: ["g"],
|
|
2921
2935
|
brushTool: ["b"],
|
|
2922
2936
|
pointTool: ["i"]
|
|
2923
|
-
},
|
|
2937
|
+
}, Yn = {
|
|
2924
2938
|
Equal: "=",
|
|
2925
2939
|
Minus: "-",
|
|
2926
2940
|
BracketLeft: "[",
|
|
@@ -2930,7 +2944,7 @@ var qn = {
|
|
|
2930
2944
|
Comma: ",",
|
|
2931
2945
|
Slash: "/",
|
|
2932
2946
|
Backquote: "`"
|
|
2933
|
-
},
|
|
2947
|
+
}, Xn = {
|
|
2934
2948
|
Escape: "escape",
|
|
2935
2949
|
Enter: "enter",
|
|
2936
2950
|
Backspace: "backspace",
|
|
@@ -2941,36 +2955,36 @@ var qn = {
|
|
|
2941
2955
|
ArrowLeft: "arrowleft",
|
|
2942
2956
|
ArrowRight: "arrowright"
|
|
2943
2957
|
};
|
|
2944
|
-
function
|
|
2958
|
+
function Zn(e) {
|
|
2945
2959
|
let t = e.code, n = /^Key([A-Z])$/.exec(t);
|
|
2946
2960
|
if (n) return n[1].toLowerCase();
|
|
2947
2961
|
let r = /^Digit([0-9])$/.exec(t);
|
|
2948
|
-
return r ? r[1] :
|
|
2962
|
+
return r ? r[1] : Yn[t] ? Yn[t] : Xn[e.key] ? Xn[e.key] : null;
|
|
2949
2963
|
}
|
|
2950
|
-
function
|
|
2951
|
-
let t =
|
|
2964
|
+
function Qn(e) {
|
|
2965
|
+
let t = Zn(e);
|
|
2952
2966
|
if (!t) return null;
|
|
2953
2967
|
let n = [];
|
|
2954
2968
|
return (e.metaKey || e.ctrlKey) && n.push("mod"), e.shiftKey && n.push("shift"), e.altKey && n.push("alt"), n.push(t), n.join("+");
|
|
2955
2969
|
}
|
|
2956
|
-
function
|
|
2970
|
+
function $n(e) {
|
|
2957
2971
|
let t = /* @__PURE__ */ new Map();
|
|
2958
|
-
for (let n of Object.keys(
|
|
2959
|
-
let r = e?.[n], i = r === void 0 ?
|
|
2972
|
+
for (let n of Object.keys(Jn)) {
|
|
2973
|
+
let r = e?.[n], i = r === void 0 ? Jn[n] : r === null ? [] : Array.isArray(r) ? r : [r];
|
|
2960
2974
|
for (let e of i) t.set(e.toLowerCase(), n);
|
|
2961
2975
|
}
|
|
2962
2976
|
return t;
|
|
2963
2977
|
}
|
|
2964
2978
|
//#endregion
|
|
2965
2979
|
//#region src/components/ShapeEditor/_state/useEditorHotkeys.ts
|
|
2966
|
-
var
|
|
2980
|
+
var er = {
|
|
2967
2981
|
ArrowUp: [0, -1],
|
|
2968
2982
|
ArrowDown: [0, 1],
|
|
2969
2983
|
ArrowLeft: [-1, 0],
|
|
2970
2984
|
ArrowRight: [1, 0]
|
|
2971
2985
|
};
|
|
2972
|
-
function
|
|
2973
|
-
let { spaceRef: t } = e, n = k(() =>
|
|
2986
|
+
function tr(e) {
|
|
2987
|
+
let { spaceRef: t } = e, n = k(() => $n(e.keymap), [e.keymap]), r = j(e);
|
|
2974
2988
|
r.current = e;
|
|
2975
2989
|
let i = j(n);
|
|
2976
2990
|
i.current = n, T(() => {
|
|
@@ -2979,13 +2993,13 @@ function $n(e) {
|
|
|
2979
2993
|
let a = (n) => {
|
|
2980
2994
|
if (n.defaultPrevented && n.key !== "Escape" || y(n.target) || !g(e, n.target)) return;
|
|
2981
2995
|
n.code === "Space" && (t.current = !0, r.current.onSpaceDown());
|
|
2982
|
-
let a =
|
|
2996
|
+
let a = er[n.key];
|
|
2983
2997
|
if (a) {
|
|
2984
2998
|
let e = n.shiftKey ? 10 : 1;
|
|
2985
2999
|
r.current.nudge(a[0] * e, a[1] * e) !== !1 && n.preventDefault();
|
|
2986
3000
|
return;
|
|
2987
3001
|
}
|
|
2988
|
-
let o =
|
|
3002
|
+
let o = Qn(n);
|
|
2989
3003
|
if (!o) return;
|
|
2990
3004
|
let s = i.current.get(o);
|
|
2991
3005
|
s && r.current.actions[s]?.() !== !1 && n.preventDefault();
|
|
@@ -3001,14 +3015,14 @@ function $n(e) {
|
|
|
3001
3015
|
}
|
|
3002
3016
|
//#endregion
|
|
3003
3017
|
//#region src/components/ShapeEditor/_model/imageLoad.ts
|
|
3004
|
-
function
|
|
3018
|
+
function nr(e, t) {
|
|
3005
3019
|
return new Promise((n) => {
|
|
3006
3020
|
let r = new Image();
|
|
3007
3021
|
t?.crossOrigin && (r.crossOrigin = "anonymous"), r.onload = () => n(r), r.onerror = () => n(null), r.src = e;
|
|
3008
3022
|
});
|
|
3009
3023
|
}
|
|
3010
|
-
async function
|
|
3011
|
-
let t = await
|
|
3024
|
+
async function rr(e) {
|
|
3025
|
+
let t = await nr(e, { crossOrigin: !0 });
|
|
3012
3026
|
if (t) return t;
|
|
3013
3027
|
try {
|
|
3014
3028
|
let t = await fetch(e, {
|
|
@@ -3021,9 +3035,9 @@ async function tr(e) {
|
|
|
3021
3035
|
} catch {
|
|
3022
3036
|
return null;
|
|
3023
3037
|
}
|
|
3024
|
-
return
|
|
3038
|
+
return nr(e, { crossOrigin: !0 });
|
|
3025
3039
|
}
|
|
3026
|
-
async function
|
|
3040
|
+
async function ir(e) {
|
|
3027
3041
|
for (let t of ["default", "reload"]) try {
|
|
3028
3042
|
let n = await fetch(e, {
|
|
3029
3043
|
mode: "cors",
|
|
@@ -3034,8 +3048,8 @@ async function nr(e) {
|
|
|
3034
3048
|
} catch {}
|
|
3035
3049
|
return null;
|
|
3036
3050
|
}
|
|
3037
|
-
async function
|
|
3038
|
-
let t = await
|
|
3051
|
+
async function ar(e) {
|
|
3052
|
+
let t = await ir(e);
|
|
3039
3053
|
if (t) try {
|
|
3040
3054
|
let e = await createImageBitmap(t);
|
|
3041
3055
|
return {
|
|
@@ -3045,7 +3059,7 @@ async function rr(e) {
|
|
|
3045
3059
|
release: () => e.close()
|
|
3046
3060
|
};
|
|
3047
3061
|
} catch {}
|
|
3048
|
-
let n = await
|
|
3062
|
+
let n = await rr(e);
|
|
3049
3063
|
return n ? {
|
|
3050
3064
|
source: n,
|
|
3051
3065
|
width: n.naturalWidth,
|
|
@@ -3053,19 +3067,19 @@ async function rr(e) {
|
|
|
3053
3067
|
release: () => {}
|
|
3054
3068
|
} : null;
|
|
3055
3069
|
}
|
|
3056
|
-
var
|
|
3057
|
-
async function
|
|
3058
|
-
|
|
3070
|
+
var or = 2, sr = 0, cr = [];
|
|
3071
|
+
async function lr(e) {
|
|
3072
|
+
sr < or ? sr += 1 : await new Promise((e) => cr.push(e));
|
|
3059
3073
|
try {
|
|
3060
3074
|
return await e();
|
|
3061
3075
|
} finally {
|
|
3062
|
-
let e =
|
|
3063
|
-
e ? e() : --
|
|
3076
|
+
let e = cr.shift();
|
|
3077
|
+
e ? e() : --sr;
|
|
3064
3078
|
}
|
|
3065
3079
|
}
|
|
3066
3080
|
//#endregion
|
|
3067
3081
|
//#region src/components/ShapeEditor/_model/imageDiagnosis.ts
|
|
3068
|
-
function
|
|
3082
|
+
function ur(e) {
|
|
3069
3083
|
return new Promise((t) => {
|
|
3070
3084
|
let n = null, r = !1, i = () => {
|
|
3071
3085
|
r || (r = !0, clearTimeout(o), document.removeEventListener("securitypolicyviolation", a), t(n));
|
|
@@ -3073,29 +3087,29 @@ function cr(e) {
|
|
|
3073
3087
|
let r = t.effectiveDirective ?? t.violatedDirective ?? "";
|
|
3074
3088
|
r.includes("img-src") && (n = `CSP ${r} blocked ${t.blockedURI || e}`);
|
|
3075
3089
|
}, o = setTimeout(i, 1e4);
|
|
3076
|
-
document.addEventListener("securitypolicyviolation", a),
|
|
3090
|
+
document.addEventListener("securitypolicyviolation", a), nr(e, { crossOrigin: !0 }).then(() => {
|
|
3077
3091
|
setTimeout(i, 0);
|
|
3078
3092
|
});
|
|
3079
3093
|
});
|
|
3080
3094
|
}
|
|
3081
|
-
var
|
|
3082
|
-
function
|
|
3083
|
-
let t =
|
|
3084
|
-
if (t && n - t.at <
|
|
3085
|
-
let r =
|
|
3095
|
+
var dr = 3e4, fr = 200, pr = /* @__PURE__ */ new Map();
|
|
3096
|
+
function mr(e) {
|
|
3097
|
+
let t = pr.get(e), n = Date.now();
|
|
3098
|
+
if (t && n - t.at < dr) return t.result;
|
|
3099
|
+
let r = hr(e).catch((t) => (pr.delete(e), {
|
|
3086
3100
|
kind: "unknown",
|
|
3087
3101
|
detail: t instanceof Error ? t.message : String(t)
|
|
3088
3102
|
}));
|
|
3089
|
-
if (
|
|
3103
|
+
if (pr.set(e, {
|
|
3090
3104
|
at: n,
|
|
3091
3105
|
result: r
|
|
3092
|
-
}),
|
|
3093
|
-
let e =
|
|
3094
|
-
e !== void 0 &&
|
|
3106
|
+
}), pr.size > fr) {
|
|
3107
|
+
let e = pr.keys().next().value;
|
|
3108
|
+
e !== void 0 && pr.delete(e);
|
|
3095
3109
|
}
|
|
3096
3110
|
return r;
|
|
3097
3111
|
}
|
|
3098
|
-
async function
|
|
3112
|
+
async function hr(e) {
|
|
3099
3113
|
let t = e;
|
|
3100
3114
|
try {
|
|
3101
3115
|
t = new URL(e, location.href).origin;
|
|
@@ -3138,7 +3152,7 @@ async function pr(e) {
|
|
|
3138
3152
|
kind: "unexpected-content",
|
|
3139
3153
|
detail: `HTTP ${r} (${t})${n.redirected ? " via redirect" : ""}`
|
|
3140
3154
|
};
|
|
3141
|
-
let i = await
|
|
3155
|
+
let i = await ur(e);
|
|
3142
3156
|
return i ? {
|
|
3143
3157
|
kind: "csp-img",
|
|
3144
3158
|
detail: i
|
|
@@ -3175,7 +3189,7 @@ async function pr(e) {
|
|
|
3175
3189
|
detail: `HTTP ${r}`
|
|
3176
3190
|
};
|
|
3177
3191
|
}
|
|
3178
|
-
function
|
|
3192
|
+
function gr() {
|
|
3179
3193
|
try {
|
|
3180
3194
|
let e = document.createElement("canvas");
|
|
3181
3195
|
return !!(e.getContext("webgl2") ?? e.getContext("webgl"));
|
|
@@ -3183,12 +3197,12 @@ function mr() {
|
|
|
3183
3197
|
return !1;
|
|
3184
3198
|
}
|
|
3185
3199
|
}
|
|
3186
|
-
function
|
|
3200
|
+
function _r(e) {
|
|
3187
3201
|
let t = e instanceof Error ? e.message : String(e);
|
|
3188
3202
|
return /unsafe-eval/i.test(t) ? {
|
|
3189
3203
|
kind: "csp-eval",
|
|
3190
3204
|
detail: t
|
|
3191
|
-
} :
|
|
3205
|
+
} : gr() ? {
|
|
3192
3206
|
kind: "renderer-init",
|
|
3193
3207
|
detail: t || "renderer init failed"
|
|
3194
3208
|
} : {
|
|
@@ -3198,8 +3212,8 @@ function hr(e) {
|
|
|
3198
3212
|
}
|
|
3199
3213
|
//#endregion
|
|
3200
3214
|
//#region src/components/ShapeEditor/_model/imageTiles.ts
|
|
3201
|
-
var
|
|
3202
|
-
function
|
|
3215
|
+
var vr = 4e3;
|
|
3216
|
+
function yr(e, t, n = vr) {
|
|
3203
3217
|
if (e <= 0 || t <= 0) return [];
|
|
3204
3218
|
let r = Math.ceil(e / n), i = Math.ceil(t / n);
|
|
3205
3219
|
return Array.from({ length: i }, (a, o) => Array.from({ length: r }, (a, s) => {
|
|
@@ -3214,7 +3228,7 @@ function _r(e, t, n = gr) {
|
|
|
3214
3228
|
};
|
|
3215
3229
|
})).flat();
|
|
3216
3230
|
}
|
|
3217
|
-
function
|
|
3231
|
+
function br(e, t) {
|
|
3218
3232
|
let n = document.createElement("canvas");
|
|
3219
3233
|
n.width = t.width, n.height = t.height;
|
|
3220
3234
|
let r = n.getContext("2d");
|
|
@@ -3222,7 +3236,7 @@ function vr(e, t) {
|
|
|
3222
3236
|
}
|
|
3223
3237
|
//#endregion
|
|
3224
3238
|
//#region src/components/ShapeEditor/_model/konva.ts
|
|
3225
|
-
function
|
|
3239
|
+
function xr(e, t, n) {
|
|
3226
3240
|
if (t === R.POINT) {
|
|
3227
3241
|
e.setAttrs({
|
|
3228
3242
|
x: n[0].x,
|
|
@@ -3258,17 +3272,17 @@ function yr(e, t, n) {
|
|
|
3258
3272
|
}
|
|
3259
3273
|
//#endregion
|
|
3260
3274
|
//#region src/components/ShapeEditor/_model/pinIcon.ts
|
|
3261
|
-
var
|
|
3262
|
-
function
|
|
3263
|
-
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${
|
|
3275
|
+
var Sr = "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", Cr = "#ffffff", wr = 1.5;
|
|
3276
|
+
function Tr(e) {
|
|
3277
|
+
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${Sr}" fill="${e}" stroke="${Cr}" stroke-width="${wr}"/></svg>`;
|
|
3264
3278
|
}
|
|
3265
3279
|
//#endregion
|
|
3266
3280
|
//#region src/components/ShapeEditor/_renderers/transformSession.ts
|
|
3267
|
-
var
|
|
3268
|
-
function
|
|
3281
|
+
var Er = Math.PI / 12;
|
|
3282
|
+
function Dr(e, t) {
|
|
3269
3283
|
return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type === R.ROTATED_RECTANGLE;
|
|
3270
3284
|
}
|
|
3271
|
-
function
|
|
3285
|
+
function Or(e, t, n) {
|
|
3272
3286
|
if (e.kind === "resize") {
|
|
3273
3287
|
let r = n ? e.box : ue(e.anchor, e.box, t.x, t.y);
|
|
3274
3288
|
return {
|
|
@@ -3299,7 +3313,7 @@ function Er(e, t, n) {
|
|
|
3299
3313
|
}
|
|
3300
3314
|
if (e.kind === "rotate") {
|
|
3301
3315
|
let n = Math.atan2(t.y - e.center.y, t.x - e.center.x) - e.startAngle;
|
|
3302
|
-
return e.shiftKey && (n = Math.round(n /
|
|
3316
|
+
return e.shiftKey && (n = Math.round(n / Er) * Er), {
|
|
3303
3317
|
updates: [{
|
|
3304
3318
|
id: e.id,
|
|
3305
3319
|
points: e.points.map((t) => fe(t, e.center, n))
|
|
@@ -3319,13 +3333,13 @@ function Er(e, t, n) {
|
|
|
3319
3333
|
box: U(a)
|
|
3320
3334
|
};
|
|
3321
3335
|
}
|
|
3322
|
-
function
|
|
3336
|
+
function kr(e, t) {
|
|
3323
3337
|
return t.kind === "move" || t.kind === "vertex" ? t.start : t.kind === "rotate" ? {
|
|
3324
3338
|
x: t.center.x + Math.cos(t.startAngle),
|
|
3325
3339
|
y: t.center.y + Math.sin(t.startAngle)
|
|
3326
|
-
} :
|
|
3340
|
+
} : Dr(e, t) ? Ce(t.shapes[0].points)[H.indexOf(t.anchor)] : le(t.anchor, t.box);
|
|
3327
3341
|
}
|
|
3328
|
-
function
|
|
3342
|
+
function Ar(e, t, n) {
|
|
3329
3343
|
let r = e.filter((e) => t.includes(e.id) && oe(e)).map((e) => ({
|
|
3330
3344
|
id: e.id,
|
|
3331
3345
|
points: e.points
|
|
@@ -3337,23 +3351,23 @@ function Or(e, t, n) {
|
|
|
3337
3351
|
shapes: r
|
|
3338
3352
|
} : null;
|
|
3339
3353
|
}
|
|
3340
|
-
function
|
|
3354
|
+
function jr(e) {
|
|
3341
3355
|
return e.map((e) => ({
|
|
3342
3356
|
...e,
|
|
3343
3357
|
points: e.points.map((e) => ({ ...e }))
|
|
3344
3358
|
}));
|
|
3345
3359
|
}
|
|
3346
|
-
function
|
|
3360
|
+
function Mr(e, t) {
|
|
3347
3361
|
let n = new Set(t);
|
|
3348
3362
|
return e.filter((e) => n.has(e.id) && ae(e));
|
|
3349
3363
|
}
|
|
3350
|
-
function
|
|
3364
|
+
function Nr(e, t) {
|
|
3351
3365
|
return e.filter((e) => B(e) && Fe(e, t)).map((e) => e.id);
|
|
3352
3366
|
}
|
|
3353
|
-
function
|
|
3367
|
+
function Pr(e, t, n) {
|
|
3354
3368
|
return (e ? at(e, { strokeWidth: t }).pointRadius : 5) / (n || 1);
|
|
3355
3369
|
}
|
|
3356
|
-
function
|
|
3370
|
+
function Fr(e, t) {
|
|
3357
3371
|
return {
|
|
3358
3372
|
minX: e.x - t,
|
|
3359
3373
|
minY: e.y - t,
|
|
@@ -3361,9 +3375,9 @@ function Nr(e, t) {
|
|
|
3361
3375
|
maxY: e.y + t
|
|
3362
3376
|
};
|
|
3363
3377
|
}
|
|
3364
|
-
function
|
|
3378
|
+
function Ir(e, t, n) {
|
|
3365
3379
|
if (e.type === R.ROTATED_RECTANGLE) return t;
|
|
3366
|
-
let r = e.type === R.POINT ?
|
|
3380
|
+
let r = e.type === R.POINT ? Fr(t[0], n) : U(t);
|
|
3367
3381
|
return pe([{
|
|
3368
3382
|
x: r.minX,
|
|
3369
3383
|
y: r.minY
|
|
@@ -3372,17 +3386,17 @@ function Pr(e, t, n) {
|
|
|
3372
3386
|
y: r.maxY
|
|
3373
3387
|
}]);
|
|
3374
3388
|
}
|
|
3375
|
-
function
|
|
3389
|
+
function Lr(e) {
|
|
3376
3390
|
return 24 / (e || 1);
|
|
3377
3391
|
}
|
|
3378
|
-
function
|
|
3392
|
+
function Rr(e, t) {
|
|
3379
3393
|
return Math.atan2(t.y - e.y, t.x - e.x);
|
|
3380
3394
|
}
|
|
3381
3395
|
//#endregion
|
|
3382
3396
|
//#region src/components/ShapeEditor/_renderers/KonvaRenderer.ts
|
|
3383
|
-
var
|
|
3397
|
+
var zr = 2, Br = "#1e88e5", Vr = "#669def", Hr = class {
|
|
3384
3398
|
constructor(e, t) {
|
|
3385
|
-
this.layer = new N.Layer(), this.world = new N.Group(), this.bgGroup = new N.Group(), this.overlayGroup = new N.Group({ listening: !1 }), this.regionOverlayGroup = new N.Group({ listening: !1 }), this.dimOverlayGroup = new N.Group({ listening: !1 }), this.shapeGroup = new N.Group(), this.selGroup = new N.Group(), this.previewGroup = new N.Group(), this.handleGroup = new N.Group(), this.baseCursor = "default", this.strokeSize =
|
|
3399
|
+
this.layer = new N.Layer(), this.world = new N.Group(), this.bgGroup = new N.Group(), this.overlayGroup = new N.Group({ listening: !1 }), this.regionOverlayGroup = new N.Group({ listening: !1 }), this.dimOverlayGroup = new N.Group({ listening: !1 }), this.shapeGroup = new N.Group(), this.selGroup = new N.Group(), this.previewGroup = new N.Group(), this.handleGroup = new N.Group(), this.baseCursor = "default", this.strokeSize = zr, 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 = {
|
|
3386
3400
|
x: 0,
|
|
3387
3401
|
y: 0
|
|
3388
3402
|
}, 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 N.Stage({
|
|
@@ -3477,7 +3491,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3477
3491
|
}
|
|
3478
3492
|
bindShapeCursor(e, t) {
|
|
3479
3493
|
if (!oe(t)) return this.bindCursor(e, "default");
|
|
3480
|
-
this.bindCursor(e, () => this.selected.includes(t.id) ? "grab" :
|
|
3494
|
+
this.bindCursor(e, () => this.selected.includes(t.id) ? "grab" : Gt);
|
|
3481
3495
|
}
|
|
3482
3496
|
bindCursor(e, t) {
|
|
3483
3497
|
let n = () => {
|
|
@@ -3500,7 +3514,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3500
3514
|
return this.world.getAbsoluteTransform().point(e);
|
|
3501
3515
|
}
|
|
3502
3516
|
async setImage(e, t, n) {
|
|
3503
|
-
let r = ++this.imageLoadToken, i = await
|
|
3517
|
+
let r = ++this.imageLoadToken, i = await rr(e);
|
|
3504
3518
|
if (r !== this.imageLoadToken) return !0;
|
|
3505
3519
|
if (!i) return this.imageWidth ||= 800, this.imageHeight ||= 600, !1;
|
|
3506
3520
|
this.imageWidth = t?.width ?? i.naturalWidth, this.imageHeight = t?.height ?? i.naturalHeight;
|
|
@@ -3509,7 +3523,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3509
3523
|
x: a / i.naturalWidth,
|
|
3510
3524
|
y: o / i.naturalHeight
|
|
3511
3525
|
}), this.bgGroup.destroyChildren();
|
|
3512
|
-
for (let e of
|
|
3526
|
+
for (let e of yr(i.naturalWidth, i.naturalHeight)) this.bgGroup.add(new N.Image({
|
|
3513
3527
|
image: i,
|
|
3514
3528
|
x: e.x,
|
|
3515
3529
|
y: e.y,
|
|
@@ -3544,7 +3558,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3544
3558
|
}
|
|
3545
3559
|
setOverlays(e, t) {
|
|
3546
3560
|
if (this.setRegionOverlay(e), this.dimOverlayGroup.destroyChildren(), t && this.imageWidth) {
|
|
3547
|
-
let e =
|
|
3561
|
+
let e = rn(this.host);
|
|
3548
3562
|
this.dimOverlayGroup.add(new N.Rect({
|
|
3549
3563
|
x: 0,
|
|
3550
3564
|
y: 0,
|
|
@@ -3563,7 +3577,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3563
3577
|
if (this.regionOverlayGroup.add(new N.Shape({
|
|
3564
3578
|
listening: !1,
|
|
3565
3579
|
sceneFunc: (r) => {
|
|
3566
|
-
|
|
3580
|
+
nn(r._context, e, t, n);
|
|
3567
3581
|
}
|
|
3568
3582
|
})), e.outlineStyles) {
|
|
3569
3583
|
let t = (e, t) => {
|
|
@@ -3619,7 +3633,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3619
3633
|
let e = this.lastPreviewPoly;
|
|
3620
3634
|
e && this.previewPoly(e.points, e.cursor, e.style, e.closed, e.selectedPointIndices, e.showVertices);
|
|
3621
3635
|
}
|
|
3622
|
-
this.activeDrag ? this.dragTransform(this.lastDragImg ??
|
|
3636
|
+
this.activeDrag ? this.dragTransform(this.lastDragImg ?? kr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.layer.batchDraw(), this.cb.onViewportChange?.();
|
|
3623
3637
|
}
|
|
3624
3638
|
fit() {
|
|
3625
3639
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -3648,7 +3662,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3648
3662
|
});
|
|
3649
3663
|
}
|
|
3650
3664
|
setShapes(e, t) {
|
|
3651
|
-
if (this.shapes =
|
|
3665
|
+
if (this.shapes = jr(e), this.selected = t, !this.activeDrag) {
|
|
3652
3666
|
this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
|
|
3653
3667
|
for (let t of se(e).filter(z)) {
|
|
3654
3668
|
let e = this.makeNode(t), n = at(t, { strokeWidth: this.strokeSize });
|
|
@@ -3694,7 +3708,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3694
3708
|
if (t === R.POINT) {
|
|
3695
3709
|
let t = 1 / (this.world.scaleX() || 1), a = new N.Path({
|
|
3696
3710
|
id: e.id,
|
|
3697
|
-
data:
|
|
3711
|
+
data: Sr,
|
|
3698
3712
|
x: n[0].x,
|
|
3699
3713
|
y: n[0].y,
|
|
3700
3714
|
offsetX: 16 / 2,
|
|
@@ -3702,8 +3716,8 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3702
3716
|
scaleX: t,
|
|
3703
3717
|
scaleY: t,
|
|
3704
3718
|
fill: r.color,
|
|
3705
|
-
stroke:
|
|
3706
|
-
strokeWidth:
|
|
3719
|
+
stroke: Cr,
|
|
3720
|
+
strokeWidth: wr,
|
|
3707
3721
|
strokeScaleEnabled: !1,
|
|
3708
3722
|
shadowColor: "#000",
|
|
3709
3723
|
shadowBlur: 2,
|
|
@@ -3749,13 +3763,13 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3749
3763
|
liveUpdateShape(e, t) {
|
|
3750
3764
|
let n = this.nodes.get(e), r = this.shapes.find((t) => t.id === e);
|
|
3751
3765
|
if (n && r) {
|
|
3752
|
-
|
|
3766
|
+
xr(n, r.type, t);
|
|
3753
3767
|
let i = this.altNodes.get(e);
|
|
3754
|
-
i &&
|
|
3768
|
+
i && xr(i, r.type, t), r.type === R.POINT && n instanceof N.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
|
|
3755
3769
|
}
|
|
3756
3770
|
}
|
|
3757
3771
|
pointRadius(e) {
|
|
3758
|
-
return
|
|
3772
|
+
return Pr(e, this.strokeSize, this.world.scaleX() || 1);
|
|
3759
3773
|
}
|
|
3760
3774
|
scaledDash(e) {
|
|
3761
3775
|
return e;
|
|
@@ -3775,7 +3789,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3775
3789
|
}
|
|
3776
3790
|
}
|
|
3777
3791
|
shapesIntersecting(e) {
|
|
3778
|
-
return
|
|
3792
|
+
return Nr(this.shapes, e);
|
|
3779
3793
|
}
|
|
3780
3794
|
drawSelectionBorders() {
|
|
3781
3795
|
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && B(t)) : [];
|
|
@@ -3784,7 +3798,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3784
3798
|
this.selectionBorders = t.map(() => {
|
|
3785
3799
|
let e = new N.Line({
|
|
3786
3800
|
closed: !0,
|
|
3787
|
-
stroke:
|
|
3801
|
+
stroke: Vr,
|
|
3788
3802
|
strokeWidth: 1.5,
|
|
3789
3803
|
strokeScaleEnabled: !1,
|
|
3790
3804
|
listening: !1
|
|
@@ -3805,7 +3819,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3805
3819
|
}
|
|
3806
3820
|
}
|
|
3807
3821
|
selectionOutlinePoints(e, t) {
|
|
3808
|
-
return
|
|
3822
|
+
return Ir(e, t, this.pointRadius(e));
|
|
3809
3823
|
}
|
|
3810
3824
|
clearPreview() {
|
|
3811
3825
|
this.lastPreviewPoly = null, this.previewGroup.destroyChildren(), this.layer.batchDraw();
|
|
@@ -3868,8 +3882,8 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3868
3882
|
x: n.x,
|
|
3869
3883
|
y: n.y,
|
|
3870
3884
|
radius: (r ? 6 : 5) / l,
|
|
3871
|
-
fill: r ?
|
|
3872
|
-
stroke: r ? "#ffffff" :
|
|
3885
|
+
fill: r ? Br : "#ffffff",
|
|
3886
|
+
stroke: r ? "#ffffff" : Br,
|
|
3873
3887
|
strokeWidth: 1.5,
|
|
3874
3888
|
strokeScaleEnabled: !1,
|
|
3875
3889
|
listening: !1
|
|
@@ -3879,7 +3893,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3879
3893
|
}
|
|
3880
3894
|
previewScalarMask(e, t) {
|
|
3881
3895
|
this.previewGroup.destroyChildren();
|
|
3882
|
-
let n =
|
|
3896
|
+
let n = Ln(e, t.length === 7 ? `${t}99` : t);
|
|
3883
3897
|
this.previewGroup.add(new N.Image({
|
|
3884
3898
|
image: n,
|
|
3885
3899
|
x: e.ox,
|
|
@@ -3923,14 +3937,14 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3923
3937
|
setTransformerOutlinePoints(e) {
|
|
3924
3938
|
e.length < 2 || (this.transformerOutline || (this.transformerOutline = new N.Line({
|
|
3925
3939
|
closed: !0,
|
|
3926
|
-
stroke:
|
|
3940
|
+
stroke: Br,
|
|
3927
3941
|
strokeWidth: 1,
|
|
3928
3942
|
strokeScaleEnabled: !1,
|
|
3929
3943
|
listening: !1
|
|
3930
3944
|
}), this.selGroup.add(this.transformerOutline)), this.transformerOutline.points(e.flatMap((e) => [e.x, e.y])));
|
|
3931
3945
|
}
|
|
3932
3946
|
rotationHandleGap() {
|
|
3933
|
-
return
|
|
3947
|
+
return Lr(this.viewport.scale);
|
|
3934
3948
|
}
|
|
3935
3949
|
rotationHandleScreenPoint(e) {
|
|
3936
3950
|
return this.imgToScreen(we(e, this.rotationHandleGap()));
|
|
@@ -3949,7 +3963,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3949
3963
|
n.x,
|
|
3950
3964
|
n.y
|
|
3951
3965
|
],
|
|
3952
|
-
stroke:
|
|
3966
|
+
stroke: Br,
|
|
3953
3967
|
strokeWidth: 1,
|
|
3954
3968
|
listening: !1
|
|
3955
3969
|
}), this.handleGroup.add(this.rotLineNode));
|
|
@@ -3964,7 +3978,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3964
3978
|
}), e.rotation(n * 180 / Math.PI);
|
|
3965
3979
|
}
|
|
3966
3980
|
orientedHandleAngle(e) {
|
|
3967
|
-
return
|
|
3981
|
+
return Rr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
3968
3982
|
}
|
|
3969
3983
|
repositionOrientedHandles(e) {
|
|
3970
3984
|
let t = this.orientedHandleAngle(e);
|
|
@@ -3986,7 +4000,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
3986
4000
|
for (let e of this.vertexNodes) e.destroy();
|
|
3987
4001
|
for (let e of this.midNodes) e.destroy();
|
|
3988
4002
|
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;
|
|
3989
|
-
let e =
|
|
4003
|
+
let e = Mr(this.shapes, this.selected);
|
|
3990
4004
|
if (!e.length || e.length === 1 && e[0].type === R.POINT) return;
|
|
3991
4005
|
let t = e.length === 1 && (e[0].type === R.POLYGON || e[0].type === R.LINE) && this.editingId === e[0].id ? e[0] : null, n = U(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === R.ROTATED_RECTANGLE ? e[0] : null, i = r ? Ce(r.points) : H.map((e) => le(e, n));
|
|
3992
4006
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
@@ -4001,12 +4015,12 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
4001
4015
|
offsetY: 4,
|
|
4002
4016
|
rotation: a * 180 / Math.PI,
|
|
4003
4017
|
fill: "#ffffff",
|
|
4004
|
-
stroke:
|
|
4018
|
+
stroke: Br,
|
|
4005
4019
|
strokeWidth: 1
|
|
4006
|
-
}), r =
|
|
4020
|
+
}), r = qt(e, a);
|
|
4007
4021
|
this.bindCursor(n, r), n.on("mousedown", (t) => {
|
|
4008
4022
|
t.cancelBubble = !0, this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
4009
|
-
let n =
|
|
4023
|
+
let n = Mr(this.shapes, this.selected);
|
|
4010
4024
|
this.activeDrag = {
|
|
4011
4025
|
kind: "resize",
|
|
4012
4026
|
anchor: e,
|
|
@@ -4023,7 +4037,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
4023
4037
|
radius: i * .8,
|
|
4024
4038
|
fill: "#ffffff",
|
|
4025
4039
|
opacity: .6,
|
|
4026
|
-
stroke:
|
|
4040
|
+
stroke: Br,
|
|
4027
4041
|
strokeWidth: 1,
|
|
4028
4042
|
visible: !1,
|
|
4029
4043
|
listening: !1
|
|
@@ -4083,8 +4097,8 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
4083
4097
|
x: a.x,
|
|
4084
4098
|
y: a.y,
|
|
4085
4099
|
radius: i,
|
|
4086
|
-
fill: o ?
|
|
4087
|
-
stroke: o ? "#ffffff" :
|
|
4100
|
+
fill: o ? Br : "#ffffff",
|
|
4101
|
+
stroke: o ? "#ffffff" : Br,
|
|
4088
4102
|
strokeWidth: Math.max(1.5, i * .3)
|
|
4089
4103
|
});
|
|
4090
4104
|
this.bindCursor(s, "pointer"), s.on("mousedown", (t) => {
|
|
@@ -4109,7 +4123,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
4109
4123
|
y: r.y,
|
|
4110
4124
|
radius: 6,
|
|
4111
4125
|
fill: "#ffffff",
|
|
4112
|
-
stroke:
|
|
4126
|
+
stroke: Br,
|
|
4113
4127
|
strokeWidth: 1.5
|
|
4114
4128
|
});
|
|
4115
4129
|
this.bindCursor(i, "grab"), i.on("mousedown", (e) => {
|
|
@@ -4128,7 +4142,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
4128
4142
|
this.layer.batchDraw();
|
|
4129
4143
|
}
|
|
4130
4144
|
beginMove(e, t) {
|
|
4131
|
-
let n =
|
|
4145
|
+
let n = Ar(this.shapes, t, e);
|
|
4132
4146
|
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 === R.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4133
4147
|
}
|
|
4134
4148
|
repositionHandles(e) {
|
|
@@ -4170,7 +4184,7 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
4170
4184
|
let t = this.activeDrag;
|
|
4171
4185
|
if (!t) return;
|
|
4172
4186
|
this.applyCursor();
|
|
4173
|
-
let n =
|
|
4187
|
+
let n = Dr(this.shapes, t), { updates: r, box: i } = Or(t, e, n);
|
|
4174
4188
|
for (let e of r) this.liveUpdateShape(e.id, e.points);
|
|
4175
4189
|
if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
|
|
4176
4190
|
n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
|
|
@@ -4207,18 +4221,18 @@ var Lr = 2, Rr = "#1e88e5", zr = "#669def", Br = class {
|
|
|
4207
4221
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
4208
4222
|
return;
|
|
4209
4223
|
}
|
|
4210
|
-
let { updates: n } =
|
|
4224
|
+
let { updates: n } = Or(e, t, Dr(this.shapes, e));
|
|
4211
4225
|
this.commitTransformUpdates(n);
|
|
4212
4226
|
}
|
|
4213
|
-
},
|
|
4214
|
-
function
|
|
4215
|
-
if (!e) return
|
|
4227
|
+
}, Ur = 2, Wr = 58879, Gr = 6725103;
|
|
4228
|
+
function Kr(e) {
|
|
4229
|
+
if (!e) return Wr;
|
|
4216
4230
|
let t = e.replace("#", "");
|
|
4217
4231
|
return Number.parseInt(t.length === 3 ? t.replace(/./g, "$&$&") : t, 16);
|
|
4218
4232
|
}
|
|
4219
|
-
var
|
|
4233
|
+
var qr = class {
|
|
4220
4234
|
constructor(e, t) {
|
|
4221
|
-
this.app = new P(), this.world = new I(), this.bgLayer = new I(), this.overlayLayer = new I(), this.regionOverlayLayer = new I(), this.dimOverlayLayer = new I(), this.shapeLayer = new I(), this.selLayer = new I(), this.previewLayer = new I(), this.handleLayer = new I(), this.filter = new F(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.tileSize =
|
|
4235
|
+
this.app = new P(), this.world = new I(), this.bgLayer = new I(), this.overlayLayer = new I(), this.regionOverlayLayer = new I(), this.dimOverlayLayer = new I(), this.shapeLayer = new I(), this.selLayer = new I(), this.previewLayer = new I(), this.handleLayer = new I(), this.filter = new F(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.tileSize = vr, this.region = null, this.regionDimMaskG = new L(), this.regionDimG = new L(), this.regionZoneMaskG = new L(), this.regionZoneG = new L(), this.regionOutlineG = new L(), this.baseCursor = "default", this.strokeSize = Ur, 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 L(), this.marqueeG = new L(), this.previewMaskSprite = null, this.previewMaskTexture = null, this.previewReady = !1, this.lastPreview = null, this.host = e, this.cb = t;
|
|
4222
4236
|
}
|
|
4223
4237
|
ev(e) {
|
|
4224
4238
|
return {
|
|
@@ -4248,7 +4262,7 @@ var Gr = class {
|
|
|
4248
4262
|
}
|
|
4249
4263
|
this.host.appendChild(this.app.canvas);
|
|
4250
4264
|
let e = this.app.renderer.gl, t = e?.getParameter(e.MAX_TEXTURE_SIZE);
|
|
4251
|
-
typeof t == "number" && t > 1 && (this.tileSize = Math.min(
|
|
4265
|
+
typeof t == "number" && t > 1 && (this.tileSize = Math.min(vr, t - 1)), this.applyCursor(), this.overlayLayer.addChild(this.regionOverlayLayer, this.dimOverlayLayer), this.regionOverlayLayer.addChild(this.regionDimMaskG, this.regionDimG, this.regionZoneMaskG, this.regionZoneG, this.regionOutlineG), this.regionDimG.setMask({
|
|
4252
4266
|
mask: this.regionDimMaskG,
|
|
4253
4267
|
inverse: !0
|
|
4254
4268
|
}), this.regionZoneG.setMask({ mask: this.regionZoneMaskG }), this.world.addChild(this.bgLayer, this.overlayLayer, this.shapeLayer, this.selLayer, this.previewLayer), this.app.stage.addChild(this.world, this.handleLayer), this.world.visible = !1, this.app.stage.eventMode = "static", this.syncHitArea(), this.app.stage.on("pointerdown", (e) => {
|
|
@@ -4325,14 +4339,14 @@ var Gr = class {
|
|
|
4325
4339
|
};
|
|
4326
4340
|
}
|
|
4327
4341
|
async setImage(e, t, n) {
|
|
4328
|
-
let r = ++this.imageLoadToken, i = await
|
|
4342
|
+
let r = ++this.imageLoadToken, i = await rr(e);
|
|
4329
4343
|
if (this.destroyed || r !== this.imageLoadToken) return !0;
|
|
4330
4344
|
if (!i) return this.imageWidth ||= t?.width ?? 800, this.imageHeight ||= t?.height ?? 600, !1;
|
|
4331
4345
|
this.imageWidth = t?.width ?? i.naturalWidth, this.imageHeight = t?.height ?? i.naturalHeight;
|
|
4332
4346
|
let a = n?.width ?? this.imageWidth, o = n?.height ?? this.imageHeight;
|
|
4333
4347
|
this.bgLayer.scale.set(a / i.naturalWidth, o / i.naturalHeight), this.clearImageTiles();
|
|
4334
|
-
for (let e of
|
|
4335
|
-
let t = re.from(
|
|
4348
|
+
for (let e of yr(i.naturalWidth, i.naturalHeight, this.tileSize)) {
|
|
4349
|
+
let t = re.from(br(i, e));
|
|
4336
4350
|
t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
|
|
4337
4351
|
let n = new ne(t);
|
|
4338
4352
|
n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
|
|
@@ -4377,9 +4391,9 @@ var Gr = class {
|
|
|
4377
4391
|
this.setRegionOverlay(e);
|
|
4378
4392
|
for (let e of this.dimOverlayLayer.removeChildren()) e.destroy();
|
|
4379
4393
|
if (t && this.imageWidth) {
|
|
4380
|
-
let e =
|
|
4394
|
+
let e = rn(this.host);
|
|
4381
4395
|
this.dimOverlayLayer.addChild(new L().rect(0, 0, this.imageWidth, this.imageHeight).fill({
|
|
4382
|
-
color:
|
|
4396
|
+
color: Kr(e.color),
|
|
4383
4397
|
alpha: e.opacity
|
|
4384
4398
|
}));
|
|
4385
4399
|
}
|
|
@@ -4387,7 +4401,7 @@ var Gr = class {
|
|
|
4387
4401
|
}
|
|
4388
4402
|
setRegionOverlay(e) {
|
|
4389
4403
|
if (this.region = e, this.regionDimMaskG.clear(), this.regionDimG.clear(), this.regionZoneMaskG.clear(), this.regionZoneG.clear(), this.regionOutlineG.clear(), !e) return;
|
|
4390
|
-
let t =
|
|
4404
|
+
let t = Kr(e.dim.color);
|
|
4391
4405
|
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);
|
|
4392
4406
|
this.regionDimG.rect(0, 0, this.imageWidth, this.imageHeight).fill({
|
|
4393
4407
|
color: t,
|
|
@@ -4408,7 +4422,7 @@ var Gr = class {
|
|
|
4408
4422
|
}
|
|
4409
4423
|
applyViewport(e) {
|
|
4410
4424
|
let t = e.scale !== this.lastAppliedScale;
|
|
4411
|
-
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 ??
|
|
4425
|
+
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 ?? kr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.cb.onViewportChange?.();
|
|
4412
4426
|
}
|
|
4413
4427
|
fit() {
|
|
4414
4428
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -4444,7 +4458,7 @@ var Gr = class {
|
|
|
4444
4458
|
});
|
|
4445
4459
|
}
|
|
4446
4460
|
setShapes(e, t) {
|
|
4447
|
-
this.shapes =
|
|
4461
|
+
this.shapes = jr(e), this.selected = t, !this.activeDrag && (this.drawShapes(), this.drawSelectionBorders(), this.drawTransformer());
|
|
4448
4462
|
}
|
|
4449
4463
|
setSelection(e) {
|
|
4450
4464
|
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());
|
|
@@ -4467,10 +4481,10 @@ var Gr = class {
|
|
|
4467
4481
|
this.handleLayer.interactiveChildren = !e;
|
|
4468
4482
|
}
|
|
4469
4483
|
strokeW(e) {
|
|
4470
|
-
return (e ? at(e, { strokeWidth: this.strokeSize }).strokeWidth :
|
|
4484
|
+
return (e ? at(e, { strokeWidth: this.strokeSize }).strokeWidth : Ur) / this.world.scale.x;
|
|
4471
4485
|
}
|
|
4472
4486
|
pointRadius(e) {
|
|
4473
|
-
return
|
|
4487
|
+
return Pr(e, this.strokeSize, this.world.scale.x);
|
|
4474
4488
|
}
|
|
4475
4489
|
dashForShape(e) {
|
|
4476
4490
|
let t = at(e, { strokeWidth: this.strokeSize }).dash;
|
|
@@ -4485,7 +4499,7 @@ var Gr = class {
|
|
|
4485
4499
|
for (let e of se(this.shapes).filter(z)) {
|
|
4486
4500
|
let t = new L();
|
|
4487
4501
|
this.paintShape(t, e), t.eventMode = B(e) ? "static" : "none", t.cursor = void 0, B(e) && oe(e) && (t.on("pointerover", () => {
|
|
4488
|
-
this.activeDrag || !this.transformEnabled || this.emitCursorHint(this.selected.includes(e.id) ? "grab" :
|
|
4502
|
+
this.activeDrag || !this.transformEnabled || this.emitCursorHint(this.selected.includes(e.id) ? "grab" : Gt);
|
|
4489
4503
|
}), t.on("pointerout", () => {
|
|
4490
4504
|
this.activeDrag || this.emitCursorHint(null);
|
|
4491
4505
|
})), t.on("pointerdown", (t) => {
|
|
@@ -4495,9 +4509,9 @@ var Gr = class {
|
|
|
4495
4509
|
}
|
|
4496
4510
|
paintShape(e, t) {
|
|
4497
4511
|
e.clear();
|
|
4498
|
-
let n = at(t, { strokeWidth: this.strokeSize }), r =
|
|
4512
|
+
let n = at(t, { strokeWidth: this.strokeSize }), r = Kr(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
|
|
4499
4513
|
if (t.type === R.POINT) {
|
|
4500
|
-
e.svg(
|
|
4514
|
+
e.svg(Tr(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
|
|
4501
4515
|
let r = 1 / (this.world.scale.x || 1);
|
|
4502
4516
|
e.scale.set(r, r), e.alpha = a;
|
|
4503
4517
|
return;
|
|
@@ -4522,7 +4536,7 @@ var Gr = class {
|
|
|
4522
4536
|
if (o) {
|
|
4523
4537
|
t.style?.alternateColor && (this.path(e, t), e.stroke({
|
|
4524
4538
|
width: i,
|
|
4525
|
-
color:
|
|
4539
|
+
color: Kr(t.style.alternateColor),
|
|
4526
4540
|
alpha: a
|
|
4527
4541
|
})), this.dashedStrokeShape(e, t, i, r, a, o);
|
|
4528
4542
|
return;
|
|
@@ -4541,7 +4555,7 @@ var Gr = class {
|
|
|
4541
4555
|
});
|
|
4542
4556
|
}
|
|
4543
4557
|
shapesIntersecting(e) {
|
|
4544
|
-
return
|
|
4558
|
+
return Nr(this.shapes, e);
|
|
4545
4559
|
}
|
|
4546
4560
|
shapesAt(e) {
|
|
4547
4561
|
return this.shapes.filter((t) => {
|
|
@@ -4578,16 +4592,16 @@ var Gr = class {
|
|
|
4578
4592
|
}, a = this.strokeW(i);
|
|
4579
4593
|
r.alternateColor && (this.path(this.previewG, i), this.previewG.stroke({
|
|
4580
4594
|
width: a,
|
|
4581
|
-
color:
|
|
4595
|
+
color: Kr(r.alternateColor)
|
|
4582
4596
|
}));
|
|
4583
4597
|
let o = this.dashForShape(i);
|
|
4584
4598
|
if (o) {
|
|
4585
|
-
this.dashedStrokeShape(this.previewG, i, a,
|
|
4599
|
+
this.dashedStrokeShape(this.previewG, i, a, Kr(r.color ?? "#00e5ff"), r.opacity ?? 1, o);
|
|
4586
4600
|
return;
|
|
4587
4601
|
}
|
|
4588
4602
|
this.path(this.previewG, i), this.previewG.stroke({
|
|
4589
4603
|
width: a,
|
|
4590
|
-
color:
|
|
4604
|
+
color: Kr(r.color ?? "#00e5ff"),
|
|
4591
4605
|
alpha: r.opacity ?? 1
|
|
4592
4606
|
});
|
|
4593
4607
|
}
|
|
@@ -4609,12 +4623,12 @@ var Gr = class {
|
|
|
4609
4623
|
}, c = this.strokeW(s);
|
|
4610
4624
|
n.alternateColor && (this.path(this.previewG, s), this.previewG.stroke({
|
|
4611
4625
|
width: c,
|
|
4612
|
-
color:
|
|
4626
|
+
color: Kr(n.alternateColor)
|
|
4613
4627
|
}));
|
|
4614
4628
|
let l = this.dashForShape(s);
|
|
4615
|
-
if (l ? this.dashedStrokeShape(this.previewG, s, c,
|
|
4629
|
+
if (l ? this.dashedStrokeShape(this.previewG, s, c, Kr(n.color ?? "#00e5ff"), n.opacity ?? 1, l) : (this.path(this.previewG, s), this.previewG.stroke({
|
|
4616
4630
|
width: c,
|
|
4617
|
-
color:
|
|
4631
|
+
color: Kr(n.color ?? "#00e5ff"),
|
|
4618
4632
|
alpha: n.opacity ?? 1
|
|
4619
4633
|
})), !a) return;
|
|
4620
4634
|
let u = new Set(i), d = 5 / this.world.scale.x, f = 6 / this.world.scale.x;
|
|
@@ -4628,12 +4642,12 @@ var Gr = class {
|
|
|
4628
4642
|
}
|
|
4629
4643
|
previewScalarMask(e, t) {
|
|
4630
4644
|
this.lastPreview = null, this.ensurePreview(), this.previewG.clear();
|
|
4631
|
-
let n =
|
|
4645
|
+
let n = Ln(e, t.length === 7 ? `${t}99` : t);
|
|
4632
4646
|
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;
|
|
4633
4647
|
}
|
|
4634
4648
|
previewMarquee(e, t) {
|
|
4635
4649
|
this.ensurePreview(), this.marqueeG.clear();
|
|
4636
|
-
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 =
|
|
4650
|
+
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 = Kr(nt);
|
|
4637
4651
|
this.marqueeG.rect(n, r, i, a).fill({
|
|
4638
4652
|
color: o,
|
|
4639
4653
|
alpha: rt
|
|
@@ -4667,8 +4681,8 @@ var Gr = class {
|
|
|
4667
4681
|
o.y
|
|
4668
4682
|
], !1).stroke({
|
|
4669
4683
|
width: i,
|
|
4670
|
-
color:
|
|
4671
|
-
}), this.strokeDashedPolyline(e, [n, o], !1, i,
|
|
4684
|
+
color: Kr(r.underlayColor)
|
|
4685
|
+
}), this.strokeDashedPolyline(e, [n, o], !1, i, Kr(r.color), r.opacity, a);
|
|
4672
4686
|
};
|
|
4673
4687
|
r(this.region.visibleOutline, t.visible), r(this.region.occludedOutline, t.occluded);
|
|
4674
4688
|
}
|
|
@@ -4780,7 +4794,7 @@ var Gr = class {
|
|
|
4780
4794
|
let r = this.selectionBorderGfx[t];
|
|
4781
4795
|
r.clear(), r.poly(this.selectionOutlinePoints(e, e.points).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4782
4796
|
width: n,
|
|
4783
|
-
color:
|
|
4797
|
+
color: Gr
|
|
4784
4798
|
});
|
|
4785
4799
|
});
|
|
4786
4800
|
}
|
|
@@ -4791,12 +4805,12 @@ var Gr = class {
|
|
|
4791
4805
|
let a = this.selectionBorderGfx[r++];
|
|
4792
4806
|
a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4793
4807
|
width: n,
|
|
4794
|
-
color:
|
|
4808
|
+
color: Gr
|
|
4795
4809
|
}));
|
|
4796
4810
|
}
|
|
4797
4811
|
}
|
|
4798
4812
|
selectionOutlinePoints(e, t) {
|
|
4799
|
-
return
|
|
4813
|
+
return Ir(e, t, this.pointRadius(e));
|
|
4800
4814
|
}
|
|
4801
4815
|
imgToScreen(e) {
|
|
4802
4816
|
let t = this.world.toGlobal({
|
|
@@ -4825,7 +4839,7 @@ var Gr = class {
|
|
|
4825
4839
|
}));
|
|
4826
4840
|
}
|
|
4827
4841
|
rotationHandleGap() {
|
|
4828
|
-
return
|
|
4842
|
+
return Lr(this.viewport.scale);
|
|
4829
4843
|
}
|
|
4830
4844
|
rotationHandleScreenPoint(e) {
|
|
4831
4845
|
return this.imgToScreen(we(e, this.rotationHandleGap()));
|
|
@@ -4841,7 +4855,7 @@ var Gr = class {
|
|
|
4841
4855
|
e.position.set(t.x, t.y), e.rotation = n;
|
|
4842
4856
|
}
|
|
4843
4857
|
orientedHandleAngle(e) {
|
|
4844
|
-
return
|
|
4858
|
+
return Rr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
4845
4859
|
}
|
|
4846
4860
|
drawTransformer() {
|
|
4847
4861
|
if (this.activeDrag) return;
|
|
@@ -4849,7 +4863,7 @@ var Gr = class {
|
|
|
4849
4863
|
for (let e of this.vertexNodes) e.destroy();
|
|
4850
4864
|
for (let e of this.midNodes) e.destroy();
|
|
4851
4865
|
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;
|
|
4852
|
-
let e =
|
|
4866
|
+
let e = Mr(this.shapes, this.selected);
|
|
4853
4867
|
if (e.length === 0 || e.length === 1 && e[0].type === R.POINT) return;
|
|
4854
4868
|
let t = e.length === 1 && (e[0].type === R.POLYGON || e[0].type === R.LINE) && this.editingId === e[0].id ? e[0] : null, n = U(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === R.ROTATED_RECTANGLE ? e[0] : null, i = r ? Ce(r.points) : H.map((e) => le(e, n));
|
|
4855
4869
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
@@ -4860,10 +4874,10 @@ var Gr = class {
|
|
|
4860
4874
|
width: 1,
|
|
4861
4875
|
color: 2001125
|
|
4862
4876
|
}), this.layoutResizeHandle(n, t, a), n.eventMode = "static";
|
|
4863
|
-
let r =
|
|
4877
|
+
let r = qt(e, a);
|
|
4864
4878
|
this.bindCursor(n, r), n.on("pointerdown", (t) => {
|
|
4865
4879
|
t.stopPropagation(), this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
4866
|
-
let n =
|
|
4880
|
+
let n = Mr(this.shapes, this.selected);
|
|
4867
4881
|
this.activeDrag = {
|
|
4868
4882
|
kind: "resize",
|
|
4869
4883
|
anchor: e,
|
|
@@ -4960,7 +4974,7 @@ var Gr = class {
|
|
|
4960
4974
|
}
|
|
4961
4975
|
}
|
|
4962
4976
|
beginMove(e, t) {
|
|
4963
|
-
let n =
|
|
4977
|
+
let n = Ar(this.shapes, t, e);
|
|
4964
4978
|
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 === R.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4965
4979
|
}
|
|
4966
4980
|
repositionHandlesForBox(e) {
|
|
@@ -5028,7 +5042,7 @@ var Gr = class {
|
|
|
5028
5042
|
let t = this.activeDrag;
|
|
5029
5043
|
if (!t) return;
|
|
5030
5044
|
this.applyCursor();
|
|
5031
|
-
let n =
|
|
5045
|
+
let n = Dr(this.shapes, t), { updates: r, box: i } = Or(t, e, n);
|
|
5032
5046
|
if (t.kind === "move") {
|
|
5033
5047
|
let n = e.x - t.start.x, r = e.y - t.start.y;
|
|
5034
5048
|
for (let e of t.shapes) {
|
|
@@ -5070,13 +5084,13 @@ var Gr = class {
|
|
|
5070
5084
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
5071
5085
|
return;
|
|
5072
5086
|
}
|
|
5073
|
-
let { updates: n } =
|
|
5087
|
+
let { updates: n } = Or(e, t, Dr(this.shapes, e));
|
|
5074
5088
|
e.kind === "move" && this.resetMoveOffsets(), this.commitTransformUpdates(n);
|
|
5075
5089
|
}
|
|
5076
5090
|
};
|
|
5077
5091
|
//#endregion
|
|
5078
5092
|
//#region src/components/ShapeEditor/_state/useEngineLifecycle.ts
|
|
5079
|
-
function
|
|
5093
|
+
function Jr({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r }) {
|
|
5080
5094
|
if (!r) return e !== null || n !== null ? { kind: "clear" } : { kind: "none" };
|
|
5081
5095
|
let i = e !== t;
|
|
5082
5096
|
return !i && n === r ? { kind: "none" } : {
|
|
@@ -5084,10 +5098,10 @@ function Kr({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r
|
|
|
5084
5098
|
docChange: i
|
|
5085
5099
|
};
|
|
5086
5100
|
}
|
|
5087
|
-
function
|
|
5101
|
+
function Yr({ keepZoomOnImageChange: e, viewportSeeded: t }) {
|
|
5088
5102
|
return e && t;
|
|
5089
5103
|
}
|
|
5090
|
-
function
|
|
5104
|
+
function Xr({ 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, regionOverlayRef: p, dimmedRef: m, syncMinimap: h, setImage: g, setImageVisible: _, setReady: v, setImageStatus: y, onContextMenuRequest: b }) {
|
|
5091
5105
|
let x = j(i);
|
|
5092
5106
|
x.current = i;
|
|
5093
5107
|
let S = j(r);
|
|
@@ -5098,12 +5112,12 @@ function Jr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5098
5112
|
A.current = b, T(() => {
|
|
5099
5113
|
let r = t.current;
|
|
5100
5114
|
if (!r) return;
|
|
5101
|
-
let i = !1, a = null, b = null, T = k.current(), j = e === "konva" ? new
|
|
5115
|
+
let i = !1, a = null, b = null, T = k.current(), j = e === "konva" ? new Hr(r, T) : new qr(r, T);
|
|
5102
5116
|
return n.current = j, O.current = !1, (async () => {
|
|
5103
5117
|
try {
|
|
5104
5118
|
await j.init();
|
|
5105
5119
|
} catch (e) {
|
|
5106
|
-
i || y("error",
|
|
5120
|
+
i || y("error", _r(e));
|
|
5107
5121
|
return;
|
|
5108
5122
|
}
|
|
5109
5123
|
if (i) return;
|
|
@@ -5114,7 +5128,7 @@ function Jr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5114
5128
|
try {
|
|
5115
5129
|
n = await j.setImage(e, u.current, d.current);
|
|
5116
5130
|
} catch (t) {
|
|
5117
|
-
!i && x.current === e && y("error",
|
|
5131
|
+
!i && x.current === e && y("error", _r(t));
|
|
5118
5132
|
}
|
|
5119
5133
|
if (i) return;
|
|
5120
5134
|
if (n !== null) {
|
|
@@ -5125,7 +5139,7 @@ function Jr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5125
5139
|
let r = D.current;
|
|
5126
5140
|
r?.viewport && (r.imageUrl === C.current || o.current.keepZoomOnImageChange) ? j.applyViewport(r.viewport) : j.fit(), O.current = !0, h(), v(!0);
|
|
5127
5141
|
let a = () => x.current === e;
|
|
5128
|
-
n ? a() && y("ready") :
|
|
5142
|
+
n ? a() && y("ready") : mr(e).then((e) => {
|
|
5129
5143
|
!i && a() && y("error", e);
|
|
5130
5144
|
});
|
|
5131
5145
|
}
|
|
@@ -5169,7 +5183,7 @@ function Jr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5169
5183
|
}, [e]), T(() => {
|
|
5170
5184
|
let e = n.current;
|
|
5171
5185
|
if (!e || !E.current) return;
|
|
5172
|
-
let t =
|
|
5186
|
+
let t = Jr({
|
|
5173
5187
|
currentDocId: w.current,
|
|
5174
5188
|
documentId: r,
|
|
5175
5189
|
loadedUrl: C.current,
|
|
@@ -5192,7 +5206,7 @@ function Jr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5192
5206
|
try {
|
|
5193
5207
|
i = await e.setImage(s, u.current, d.current);
|
|
5194
5208
|
} catch (t) {
|
|
5195
|
-
!c && n.current === e && y("error",
|
|
5209
|
+
!c && n.current === e && y("error", _r(t));
|
|
5196
5210
|
return;
|
|
5197
5211
|
}
|
|
5198
5212
|
if (c || n.current !== e) return;
|
|
@@ -5202,7 +5216,7 @@ function Jr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5202
5216
|
y("ready");
|
|
5203
5217
|
return;
|
|
5204
5218
|
}
|
|
5205
|
-
|
|
5219
|
+
mr(s).then((e) => {
|
|
5206
5220
|
c || y("error", e);
|
|
5207
5221
|
});
|
|
5208
5222
|
};
|
|
@@ -5213,7 +5227,7 @@ function Jr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5213
5227
|
w.current = r, g({
|
|
5214
5228
|
w: e.imageWidth,
|
|
5215
5229
|
h: e.imageHeight
|
|
5216
|
-
}), _(!0), e.setShapes(l.current, f.current), e.setOverlays(o.current.showRegionMask ? p.current : null, m.current),
|
|
5230
|
+
}), _(!0), e.setShapes(l.current, f.current), e.setOverlays(o.current.showRegionMask ? p.current : null, m.current), Yr({
|
|
5217
5231
|
keepZoomOnImageChange: o.current.keepZoomOnImageChange,
|
|
5218
5232
|
viewportSeeded: O.current
|
|
5219
5233
|
}) || e.fit(), O.current = !0, h(), v(!0), a();
|
|
@@ -5224,19 +5238,19 @@ function Jr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5224
5238
|
}
|
|
5225
5239
|
//#endregion
|
|
5226
5240
|
//#region src/components/ShapeEditor/_state/useMinimapNavigation.ts
|
|
5227
|
-
var
|
|
5228
|
-
function
|
|
5241
|
+
var Zr = .05, Qr = 20;
|
|
5242
|
+
function $r(e) {
|
|
5229
5243
|
let { deltaY: t, deltaX: n, deltaMode: r } = e;
|
|
5230
5244
|
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);
|
|
5231
5245
|
}
|
|
5232
|
-
function
|
|
5246
|
+
function ei(e) {
|
|
5233
5247
|
let t = e.currentTarget.getBoundingClientRect();
|
|
5234
5248
|
return {
|
|
5235
5249
|
x: e.clientX - t.left,
|
|
5236
5250
|
y: e.clientY - t.top
|
|
5237
5251
|
};
|
|
5238
5252
|
}
|
|
5239
|
-
function
|
|
5253
|
+
function ti({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
5240
5254
|
let i = j(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 = w(() => {
|
|
5241
5255
|
let t = e.current;
|
|
5242
5256
|
if (!t) return null;
|
|
@@ -5274,7 +5288,7 @@ function $r({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5274
5288
|
let n = e.current, r = d();
|
|
5275
5289
|
if (!n || !r) return;
|
|
5276
5290
|
t.preventDefault(), t.stopPropagation();
|
|
5277
|
-
let a =
|
|
5291
|
+
let a = ei(t), o = a.x >= r.x && a.x <= r.x + r.width && a.y >= r.y && a.y <= r.y + r.height ? {
|
|
5278
5292
|
offsetX: a.x - r.x,
|
|
5279
5293
|
offsetY: a.y - r.y
|
|
5280
5294
|
} : {
|
|
@@ -5291,7 +5305,7 @@ function $r({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5291
5305
|
d
|
|
5292
5306
|
]), m = w((t) => {
|
|
5293
5307
|
let n = i.current, r = e.current;
|
|
5294
|
-
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(
|
|
5308
|
+
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(ei(t), r.viewport.scale, n));
|
|
5295
5309
|
}, [f, e]), h = w((e) => {
|
|
5296
5310
|
let t = i.current;
|
|
5297
5311
|
!t || t.pointerId !== e.pointerId || (i.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId));
|
|
@@ -5299,8 +5313,8 @@ function $r({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5299
5313
|
let r = e.current;
|
|
5300
5314
|
if (!r || !n) return;
|
|
5301
5315
|
t.preventDefault(), t.stopPropagation();
|
|
5302
|
-
let i =
|
|
5303
|
-
f(
|
|
5316
|
+
let i = $r(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(Zr, Math.min(Qr, s));
|
|
5317
|
+
f(ei(t), c);
|
|
5304
5318
|
}, [
|
|
5305
5319
|
f,
|
|
5306
5320
|
e,
|
|
@@ -5337,7 +5351,7 @@ function $r({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5337
5351
|
}
|
|
5338
5352
|
//#endregion
|
|
5339
5353
|
//#region src/components/ShapeEditor/_state/useMinimapSync.ts
|
|
5340
|
-
function
|
|
5354
|
+
function ni(e, t, n) {
|
|
5341
5355
|
if (!(!e || !n.length)) {
|
|
5342
5356
|
if (t.type === R.POINT) {
|
|
5343
5357
|
e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
|
|
@@ -5355,38 +5369,38 @@ function ei(e, t, n) {
|
|
|
5355
5369
|
e.setAttribute("points", n.map((e) => `${e.x},${e.y}`).join(" "));
|
|
5356
5370
|
}
|
|
5357
5371
|
}
|
|
5358
|
-
function
|
|
5359
|
-
let
|
|
5372
|
+
function ri({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRectRef: i, minimapSize: a, onViewportChangeRef: o, onScreenOverlaySyncRef: s }) {
|
|
5373
|
+
let c = j(/* @__PURE__ */ new Map());
|
|
5360
5374
|
return {
|
|
5361
5375
|
registerMinimapShape: w((e, t) => {
|
|
5362
|
-
t ?
|
|
5376
|
+
t ? c.current.set(e, t) : c.current.delete(e);
|
|
5363
5377
|
}, []),
|
|
5364
5378
|
applyMinimapPreview: w((e) => {
|
|
5365
5379
|
let n = t.current.getShapes();
|
|
5366
5380
|
if (!e.length) {
|
|
5367
|
-
for (let e of n)
|
|
5381
|
+
for (let e of n) ni(c.current.get(e.id), e, e.points);
|
|
5368
5382
|
return;
|
|
5369
5383
|
}
|
|
5370
5384
|
let r = new Map(n.map((e) => [e.id, e]));
|
|
5371
5385
|
for (let t of e) {
|
|
5372
5386
|
let e = r.get(t.id);
|
|
5373
|
-
e &&
|
|
5387
|
+
e && ni(c.current.get(e.id), e, t.points);
|
|
5374
5388
|
}
|
|
5375
5389
|
}, [t]),
|
|
5376
5390
|
syncMinimap: w(() => {
|
|
5377
5391
|
let t = e.current;
|
|
5378
5392
|
if (!t?.imageWidth) return;
|
|
5379
|
-
let
|
|
5380
|
-
if (o.current?.(
|
|
5381
|
-
n.current.style.transform = `translate(${
|
|
5382
|
-
let e = 1 / (
|
|
5393
|
+
let c = t.viewport;
|
|
5394
|
+
if (o.current?.(c), n.current) {
|
|
5395
|
+
n.current.style.transform = `translate(${c.x}px, ${c.y}px) scale(${c.scale})`;
|
|
5396
|
+
let e = 1 / (c.scale || 1);
|
|
5383
5397
|
n.current.style.setProperty("--editor-overlay-stroke", `${e}`), n.current.style.setProperty("--editor-overlay-dash", `${4 * e}`), n.current.style.setProperty("--editor-overlay-inverse-scale", `${e}`);
|
|
5384
5398
|
}
|
|
5385
|
-
r.current && (r.current.textContent = `${Math.round(
|
|
5386
|
-
let
|
|
5387
|
-
if (!
|
|
5388
|
-
let
|
|
5389
|
-
|
|
5399
|
+
s.current?.(c), r.current && (r.current.textContent = `${Math.round(c.scale * 100)}%`);
|
|
5400
|
+
let l = i.current;
|
|
5401
|
+
if (!l) return;
|
|
5402
|
+
let u = Math.min(a / t.imageWidth, a / t.imageHeight), d = (a - t.imageWidth * u) / 2, f = (a - t.imageHeight * u) / 2, { w: p, h: m } = t.screenSize;
|
|
5403
|
+
l.style.left = `${-c.x / c.scale * u + d}px`, l.style.top = `${-c.y / c.scale * u + f}px`, l.style.width = `${p / c.scale * u}px`, l.style.height = `${m / c.scale * u}px`;
|
|
5390
5404
|
}, [
|
|
5391
5405
|
e,
|
|
5392
5406
|
n,
|
|
@@ -5399,8 +5413,8 @@ function ti({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
5399
5413
|
}
|
|
5400
5414
|
//#endregion
|
|
5401
5415
|
//#region src/components/ShapeEditor/_state/useSelectionActions.ts
|
|
5402
|
-
var
|
|
5403
|
-
function
|
|
5416
|
+
var ii = 12;
|
|
5417
|
+
function ai({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMergeSelection: i, clipboardDocumentId: a, clipboardScope: o }) {
|
|
5404
5418
|
let s = j(0), c = j(!0), l = j(n), u = j(a), d = j(o);
|
|
5405
5419
|
l.current = n, u.current = a, d.current = o, T(() => (c.current = !0, () => {
|
|
5406
5420
|
c.current = !1;
|
|
@@ -5419,22 +5433,22 @@ function ri({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5419
5433
|
t
|
|
5420
5434
|
]), g = w(() => {
|
|
5421
5435
|
let e = m();
|
|
5422
|
-
e.length && (s.current = 0,
|
|
5436
|
+
e.length && (s.current = 0, Lt(Pt(e, a, o)));
|
|
5423
5437
|
}, [
|
|
5424
5438
|
a,
|
|
5425
5439
|
o,
|
|
5426
5440
|
m
|
|
5427
|
-
]), _ = w(() =>
|
|
5441
|
+
]), _ = w(() => zt(o), [o]), v = w((t) => {
|
|
5428
5442
|
if (n) return;
|
|
5429
5443
|
let i = a;
|
|
5430
|
-
|
|
5444
|
+
Bt(o).then((n) => {
|
|
5431
5445
|
if (!c.current || l.current || u.current !== i || d.current !== o || !n?.shapes.length) return;
|
|
5432
5446
|
let f, p, m = n.shapes.flatMap((e) => e.points);
|
|
5433
5447
|
if (t && m.length) {
|
|
5434
5448
|
let e = U(m);
|
|
5435
5449
|
f = t.x - (e.minX + e.maxX) / 2, p = t.y - (e.minY + e.maxY) / 2;
|
|
5436
5450
|
} else {
|
|
5437
|
-
let e = !!n.documentId && n.documentId !== a, t =
|
|
5451
|
+
let e = !!n.documentId && n.documentId !== a, t = Vt(s.current, e, ii);
|
|
5438
5452
|
f = t.offset, s.current = t.nextPasteCount, p = f;
|
|
5439
5453
|
}
|
|
5440
5454
|
let h = n.shapes.map((e) => ({
|
|
@@ -5459,8 +5473,8 @@ function ri({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5459
5473
|
...e,
|
|
5460
5474
|
id: ce(),
|
|
5461
5475
|
points: e.points.map((e) => ({
|
|
5462
|
-
x: e.x +
|
|
5463
|
-
y: e.y +
|
|
5476
|
+
x: e.x + ii,
|
|
5477
|
+
y: e.y + ii
|
|
5464
5478
|
}))
|
|
5465
5479
|
}));
|
|
5466
5480
|
i.length && (e.create(i), r(i.map((e) => e.id)));
|
|
@@ -5518,9 +5532,9 @@ function ri({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5518
5532
|
if (n) return;
|
|
5519
5533
|
let t = C();
|
|
5520
5534
|
if (t.length < 2 || i && !i(t)) return;
|
|
5521
|
-
let a =
|
|
5535
|
+
let a = Fn([], 1, Pn(t));
|
|
5522
5536
|
if (!a) return;
|
|
5523
|
-
let o =
|
|
5537
|
+
let o = In(a, 1);
|
|
5524
5538
|
if (!o.length) return;
|
|
5525
5539
|
let s = t[0], c = o.map((e) => ({
|
|
5526
5540
|
id: ce(),
|
|
@@ -5541,12 +5555,12 @@ function ri({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5541
5555
|
}
|
|
5542
5556
|
//#endregion
|
|
5543
5557
|
//#region src/components/ShapeEditor/_state/useViewportControls.ts
|
|
5544
|
-
function
|
|
5558
|
+
function oi({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBound: i, ready: a }) {
|
|
5545
5559
|
let o = j(null), s = j(null), c = w(() => {
|
|
5546
5560
|
o.current?.(), o.current = null;
|
|
5547
5561
|
}, []), l = w((t, n = r) => {
|
|
5548
5562
|
let i = e.current;
|
|
5549
|
-
i && (c(), o.current =
|
|
5563
|
+
i && (c(), o.current = vn(i.viewport, t, (e) => i.applyViewport(e), n));
|
|
5550
5564
|
}, [
|
|
5551
5565
|
c,
|
|
5552
5566
|
r,
|
|
@@ -5554,14 +5568,14 @@ function ii({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5554
5568
|
]), u = w((t, n = r) => {
|
|
5555
5569
|
let i = e.current;
|
|
5556
5570
|
if (!i) return;
|
|
5557
|
-
let a =
|
|
5571
|
+
let a = gn(t, i.screenSize.w, i.screenSize.h);
|
|
5558
5572
|
a && l(a, n);
|
|
5559
5573
|
}, [
|
|
5560
5574
|
l,
|
|
5561
5575
|
r,
|
|
5562
5576
|
e
|
|
5563
5577
|
]), d = w((e, n = r) => {
|
|
5564
|
-
let i =
|
|
5578
|
+
let i = hn(t.getShapes().filter((t) => e.includes(t.id)));
|
|
5565
5579
|
i && u(i, n);
|
|
5566
5580
|
}, [
|
|
5567
5581
|
t,
|
|
@@ -5572,7 +5586,7 @@ function ii({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5572
5586
|
if (!r.length) return;
|
|
5573
5587
|
let i = e.current;
|
|
5574
5588
|
if (!i) return;
|
|
5575
|
-
let a =
|
|
5589
|
+
let a = _n(U(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
|
|
5576
5590
|
a && l(a);
|
|
5577
5591
|
}, [
|
|
5578
5592
|
t,
|
|
@@ -5613,16 +5627,16 @@ function ii({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5613
5627
|
}
|
|
5614
5628
|
//#endregion
|
|
5615
5629
|
//#region src/components/ShapeEditor/ShapeEditor.tsx
|
|
5616
|
-
var
|
|
5630
|
+
var si = "__draft_preview__", ci = new Set([
|
|
5617
5631
|
"copy",
|
|
5618
5632
|
"selectAll",
|
|
5619
5633
|
"clearSelection",
|
|
5620
5634
|
"zoomToSelection"
|
|
5621
5635
|
]);
|
|
5622
|
-
function
|
|
5636
|
+
function li(e, t) {
|
|
5623
5637
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
5624
5638
|
}
|
|
5625
|
-
function
|
|
5639
|
+
function ui({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !1, selectedIds: i, activeTool: a, draftStyle: o, draftMeta: s, readOnly: c, disableMarquee: l, locked: u, onLockedInteraction: f, onDrawAttemptWithoutDraft: p, onIdleEscape: m, overrideShapeInteraction: h, defaultViewSettings: g, viewSettings: _, onViewSettingsChange: v, showMinimap: y = !0, minimapPosition: b = "bottom-left", showViewSettings: C = !0, getContextMenuItems: A, strings: N, viewSettingItems: P, canMergeSelection: F, brushSize: I = 20, zoomBound: L, zoomAnimationDuration: ee = 300, decorationShapes: te, regionMask: ne, overlayMarkers: re, renderOverlayMarker: ie, onOverlayMarkerClick: oe, renderImageOverlay: se, getSelectionLabel: V, hideSelectionLabelDot: H, formatSelectionInfo: U, externalTools: le, assistant: ue, keymap: de, handleRef: fe, backend: pe = "pixi", onActiveToolChange: me, onSelectionChange: he, onEditingChange: ge, onShapesCreated: _e, onShapesUpdated: ve, onShapesDeleted: ye, onDrawSessionChange: be, onDraftShapeChange: xe, onViewportChange: Se, onShapesTransformPreview: Ce }) {
|
|
5626
5640
|
let we = j(null), W = j(null), Te = j(null), Ee = j(null), De = j(null), Oe = `${E()}-minimap`, [G, ke] = M(null), [Ae, je] = M(!1), [Me, Ne] = M(!1), [Pe, Fe] = M(null), [Ie, Le] = M({
|
|
5627
5641
|
active: !1,
|
|
5628
5642
|
kind: "none",
|
|
@@ -5630,7 +5644,7 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5630
5644
|
canRedo: !1
|
|
5631
5645
|
}), [Re, ze] = M(!0), [K, He] = M(!1), Ue = e?.id ?? "", Ge = e?.imageUrl ?? "", Ke = e?.displayImageUrl, qe = e?.coordinateSize, Je = e?.initialShapes, Xe = e?.initialSelectedIds, et = Ke ?? Ge, [tt, nt] = M("loading"), rt = tt === "loading" && e !== null && !et ? "missing" : tt, [it, at] = M(null), ot = w((e, t) => {
|
|
5632
5646
|
nt(e), at(e === "error" ? t ?? null : null);
|
|
5633
|
-
}, []), J =
|
|
5647
|
+
}, []), J = qn({
|
|
5634
5648
|
onShapesCreated: _e,
|
|
5635
5649
|
onShapesUpdated: ve,
|
|
5636
5650
|
onShapesDeleted: ye
|
|
@@ -5673,19 +5687,19 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5673
5687
|
}
|
|
5674
5688
|
vt.current?.(X);
|
|
5675
5689
|
}, [X]);
|
|
5676
|
-
let
|
|
5677
|
-
Tt.current =
|
|
5678
|
-
let
|
|
5679
|
-
|
|
5680
|
-
let
|
|
5681
|
-
|
|
5682
|
-
let
|
|
5683
|
-
|
|
5684
|
-
let
|
|
5685
|
-
|
|
5686
|
-
let
|
|
5690
|
+
let bt = k(() => !G || !ne ? null : ln(ne, G.w, G.h), [G, ne]), Tt = j(bt);
|
|
5691
|
+
Tt.current = bt;
|
|
5692
|
+
let Dt = j(r);
|
|
5693
|
+
Dt.current = r;
|
|
5694
|
+
let Ot = j(G);
|
|
5695
|
+
Ot.current = G;
|
|
5696
|
+
let kt = j(qe);
|
|
5697
|
+
kt.current = qe;
|
|
5698
|
+
let At = j(qe?.imageSize);
|
|
5699
|
+
At.current = qe?.imageSize;
|
|
5700
|
+
let Q = j(Y);
|
|
5687
5701
|
O(() => {
|
|
5688
|
-
|
|
5702
|
+
Q.current = Y;
|
|
5689
5703
|
}, [Y]);
|
|
5690
5704
|
let jt = j(a);
|
|
5691
5705
|
jt.current = a;
|
|
@@ -5693,12 +5707,12 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5693
5707
|
Mt.current = o;
|
|
5694
5708
|
let Nt = j(s);
|
|
5695
5709
|
Nt.current = s;
|
|
5696
|
-
let
|
|
5697
|
-
|
|
5710
|
+
let Pt = j(I);
|
|
5711
|
+
Pt.current = I;
|
|
5698
5712
|
let It = j(X.simplifyStrength);
|
|
5699
5713
|
It.current = X.simplifyStrength;
|
|
5700
|
-
let
|
|
5701
|
-
Lt.current =
|
|
5714
|
+
let $ = !!c || !!u, Lt = j($);
|
|
5715
|
+
Lt.current = $;
|
|
5702
5716
|
let Rt = j(l);
|
|
5703
5717
|
Rt.current = l;
|
|
5704
5718
|
let zt = j(u);
|
|
@@ -5713,22 +5727,22 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5713
5727
|
Wt.current = h;
|
|
5714
5728
|
let Gt = j(J);
|
|
5715
5729
|
Gt.current = J;
|
|
5716
|
-
let Kt = j(!1), qt = j("idle"),
|
|
5730
|
+
let Kt = j(!1), qt = j("idle"), Jt = j(null), Xt = w(() => {
|
|
5717
5731
|
let e = W.current;
|
|
5718
5732
|
if (!e) return;
|
|
5719
5733
|
let t = jt.current, n = dt.current.get(t), r = ft.current;
|
|
5720
|
-
e.setCursor(
|
|
5734
|
+
e.setCursor(Yt({
|
|
5721
5735
|
tool: t,
|
|
5722
5736
|
externalToolCursor: n?.cursor,
|
|
5723
5737
|
isSpacePressed: Kt.current,
|
|
5724
5738
|
interactionMode: qt.current,
|
|
5725
|
-
rendererCursorHint:
|
|
5739
|
+
rendererCursorHint: Jt.current,
|
|
5726
5740
|
isPolygonDrawing: r.kind === "polygon" && r.active
|
|
5727
5741
|
}));
|
|
5728
5742
|
}, []), Zt = w((e) => {
|
|
5729
5743
|
qt.current !== e && (qt.current = e, Xt());
|
|
5730
5744
|
}, [Xt]), Qt = w((e) => {
|
|
5731
|
-
|
|
5745
|
+
Jt.current !== e && (Jt.current = e, Xt());
|
|
5732
5746
|
}, [Xt]), $t = w((e) => {
|
|
5733
5747
|
let t = /* @__PURE__ */ new Set(), n = new Map(Gt.current.getShapes().map((e) => [e.id, e]));
|
|
5734
5748
|
return e.filter((e) => {
|
|
@@ -5747,7 +5761,7 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5747
5761
|
});
|
|
5748
5762
|
}, []), en = w((e) => {
|
|
5749
5763
|
let t = $t(e);
|
|
5750
|
-
|
|
5764
|
+
li(Q.current, t) || (lt || ct(t), W.current?.setSelection(t), he?.(t));
|
|
5751
5765
|
}, [
|
|
5752
5766
|
$t,
|
|
5753
5767
|
he,
|
|
@@ -5760,7 +5774,7 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5760
5774
|
sn.current = nn, T(() => {
|
|
5761
5775
|
if (!lt) return;
|
|
5762
5776
|
let e = $t(i);
|
|
5763
|
-
|
|
5777
|
+
li(i, e) || he?.(e);
|
|
5764
5778
|
}, [
|
|
5765
5779
|
i,
|
|
5766
5780
|
J.shapes,
|
|
@@ -5768,59 +5782,66 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5768
5782
|
he,
|
|
5769
5783
|
lt
|
|
5770
5784
|
]);
|
|
5771
|
-
let
|
|
5772
|
-
|
|
5773
|
-
let { registerMinimapShape:
|
|
5785
|
+
let cn = j(Se);
|
|
5786
|
+
cn.current = Se;
|
|
5787
|
+
let un = j(null), { registerMinimapShape: dn, applyMinimapPreview: fn, syncMinimap: pn } = ri({
|
|
5774
5788
|
engineRef: W,
|
|
5775
5789
|
docRef: Gt,
|
|
5776
5790
|
overlayRef: Ee,
|
|
5777
5791
|
zoomLabelRef: De,
|
|
5778
5792
|
minimapRectRef: Te,
|
|
5779
5793
|
minimapSize: 204,
|
|
5780
|
-
onViewportChangeRef:
|
|
5781
|
-
|
|
5782
|
-
mn
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5794
|
+
onViewportChangeRef: cn,
|
|
5795
|
+
onScreenOverlaySyncRef: un
|
|
5796
|
+
}), mn = j(/* @__PURE__ */ new Map()), hn = j(U);
|
|
5797
|
+
hn.current = U;
|
|
5798
|
+
let gn = w((e, t) => {
|
|
5799
|
+
t ? mn.current.set(e, t) : mn.current.delete(e);
|
|
5800
|
+
}, []);
|
|
5801
|
+
un.current = (e) => {
|
|
5802
|
+
for (let t of mn.current.values()) St(t, e);
|
|
5803
|
+
};
|
|
5804
|
+
let _n = j(null), [vn, xn] = M(null), Sn = w((e) => {
|
|
5786
5805
|
if (!e.length) return;
|
|
5787
5806
|
let t = new Map(Gt.current.getShapes().map((e) => [e.id, e]));
|
|
5788
|
-
|
|
5807
|
+
_n.current && t.set(_n.current.id, _n.current);
|
|
5789
5808
|
for (let { id: n, points: r } of e) {
|
|
5790
|
-
let e =
|
|
5809
|
+
let e = mn.current.get(n), i = t.get(n);
|
|
5791
5810
|
if (!e || !i) continue;
|
|
5792
|
-
let a =
|
|
5793
|
-
if (a)
|
|
5794
|
-
|
|
5795
|
-
|
|
5811
|
+
let a = W.current?.viewport;
|
|
5812
|
+
if (!a) continue;
|
|
5813
|
+
let o = xt(e, r, a);
|
|
5814
|
+
if (o) {
|
|
5815
|
+
let e = Ct(i, r);
|
|
5816
|
+
o.textContent = hn.current?.(e) ?? wt(e);
|
|
5796
5817
|
}
|
|
5797
5818
|
}
|
|
5798
|
-
}, []),
|
|
5799
|
-
|
|
5819
|
+
}, []), Cn = w((e) => {
|
|
5820
|
+
fn(e), Sn(e), Ce?.(e);
|
|
5800
5821
|
}, [
|
|
5801
|
-
|
|
5802
|
-
|
|
5822
|
+
fn,
|
|
5823
|
+
Sn,
|
|
5803
5824
|
Ce
|
|
5804
|
-
]),
|
|
5825
|
+
]), wn = w((e) => {
|
|
5805
5826
|
if (xe?.(e ? {
|
|
5806
5827
|
...e,
|
|
5807
5828
|
meta: Nt.current
|
|
5808
5829
|
} : null), !e || !Mt.current) {
|
|
5809
|
-
|
|
5830
|
+
_n.current && (_n.current = null, xn(null));
|
|
5810
5831
|
return;
|
|
5811
5832
|
}
|
|
5812
5833
|
let t = {
|
|
5813
|
-
id:
|
|
5834
|
+
id: si,
|
|
5814
5835
|
type: e.type,
|
|
5815
5836
|
points: e.points,
|
|
5816
5837
|
style: Mt.current,
|
|
5817
5838
|
meta: Nt.current
|
|
5818
|
-
}, n =
|
|
5819
|
-
|
|
5820
|
-
id:
|
|
5839
|
+
}, n = _n.current !== null;
|
|
5840
|
+
_n.current = t, n ? Sn([{
|
|
5841
|
+
id: si,
|
|
5821
5842
|
points: e.points
|
|
5822
|
-
}]) :
|
|
5823
|
-
}, [
|
|
5843
|
+
}]) : xn(t);
|
|
5844
|
+
}, [Sn, xe]), Tn = w((e, t) => {
|
|
5824
5845
|
let n = Mt.current;
|
|
5825
5846
|
if (!n || Lt.current) return;
|
|
5826
5847
|
let r = ce();
|
|
@@ -5831,15 +5852,15 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5831
5852
|
style: n,
|
|
5832
5853
|
meta: s
|
|
5833
5854
|
}), tn.current([r]);
|
|
5834
|
-
}, [s]),
|
|
5835
|
-
|
|
5836
|
-
let
|
|
5855
|
+
}, [s]), En = j(Tn);
|
|
5856
|
+
En.current = Tn;
|
|
5857
|
+
let Dn = Wn({
|
|
5837
5858
|
toolRef: jt,
|
|
5838
|
-
selRef:
|
|
5859
|
+
selRef: Q,
|
|
5839
5860
|
docRef: Gt,
|
|
5840
5861
|
readOnlyRef: Lt,
|
|
5841
5862
|
draftRef: Mt,
|
|
5842
|
-
brushSizeRef:
|
|
5863
|
+
brushSizeRef: Pt,
|
|
5843
5864
|
simplifyEpsilonRef: It,
|
|
5844
5865
|
draftMeta: s,
|
|
5845
5866
|
engineRef: W,
|
|
@@ -5848,57 +5869,57 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5848
5869
|
}, [be]),
|
|
5849
5870
|
onDraftShapeChange: xe,
|
|
5850
5871
|
changeSelection: en,
|
|
5851
|
-
createShape:
|
|
5852
|
-
}),
|
|
5853
|
-
|
|
5854
|
-
let { reset:
|
|
5855
|
-
|
|
5856
|
-
let
|
|
5872
|
+
createShape: Tn
|
|
5873
|
+
}), On = j(Dn);
|
|
5874
|
+
On.current = Dn;
|
|
5875
|
+
let { reset: kn, undoSession: An, redoSession: jn, canUndoSession: Mn, canRedoSession: Nn, hasDraftSession: Pn, hasDraftPoints: Fn, commitDraftSession: In, setBrushScalarMode: Ln, getBrushScalarMode: Rn, hasBrushSession: zn, commitBrush: Bn, cancelBrush: Vn, beginBrushEditFromSelection: Hn, deleteDraftSelectedPoints: Un, handleToolChange: Gn, handleBrushSelectionChange: Kn } = Dn, Jn = j(ue);
|
|
5876
|
+
Jn.current = ue;
|
|
5877
|
+
let Yn = bn({
|
|
5857
5878
|
docRef: Gt,
|
|
5858
5879
|
draftRef: Mt,
|
|
5859
5880
|
draftMeta: s,
|
|
5860
5881
|
changeSelection: en,
|
|
5861
|
-
assistantRef:
|
|
5862
|
-
}),
|
|
5863
|
-
|
|
5864
|
-
let
|
|
5882
|
+
assistantRef: Jn
|
|
5883
|
+
}), Xn = j(Yn);
|
|
5884
|
+
Xn.current = Yn;
|
|
5885
|
+
let Zn = k(() => Ft(Ue), [Ue]), { selectAll: Qn, clearSelection: $n, deleteSelection: er, copySelection: nr, canPaste: rr, paste: ir, duplicate: ar, bringToFront: or, sendToBack: sr, nudgeSelection: cr, getMergeTargets: lr, mergeSelection: ur } = ai({
|
|
5865
5886
|
doc: J,
|
|
5866
|
-
selRef:
|
|
5867
|
-
effectiveReadOnly:
|
|
5887
|
+
selRef: Q,
|
|
5888
|
+
effectiveReadOnly: $,
|
|
5868
5889
|
changeSelection: en,
|
|
5869
5890
|
canMergeSelection: F,
|
|
5870
|
-
clipboardDocumentId:
|
|
5871
|
-
clipboardScope: t ??
|
|
5872
|
-
}), { zoomToBounds:
|
|
5891
|
+
clipboardDocumentId: Zn,
|
|
5892
|
+
clipboardScope: t ?? Zn
|
|
5893
|
+
}), { zoomToBounds: dr, zoomToShapes: fr, zoomToSelection: pr, zoomAtCenter: mr } = oi({
|
|
5873
5894
|
engineRef: W,
|
|
5874
5895
|
doc: J,
|
|
5875
|
-
selRef:
|
|
5896
|
+
selRef: Q,
|
|
5876
5897
|
zoomAnimationDuration: ee,
|
|
5877
5898
|
zoomBound: L,
|
|
5878
5899
|
ready: Me
|
|
5879
5900
|
});
|
|
5880
5901
|
D(fe, () => ({
|
|
5881
5902
|
previewRegionMask: (e) => {
|
|
5882
|
-
let t =
|
|
5903
|
+
let t = Ot.current;
|
|
5883
5904
|
if (!t) return;
|
|
5884
|
-
let n = e ?
|
|
5885
|
-
W.current?.setRegionOverlay(
|
|
5905
|
+
let n = e ? ln(e, t.w, t.h) : Tt.current;
|
|
5906
|
+
W.current?.setRegionOverlay(hr.current.showRegionMask ? n : null);
|
|
5886
5907
|
},
|
|
5887
5908
|
undo: () => {
|
|
5888
|
-
Lt.current ||
|
|
5909
|
+
Lt.current || An() || J.undo();
|
|
5889
5910
|
},
|
|
5890
5911
|
redo: () => {
|
|
5891
|
-
Lt.current ||
|
|
5912
|
+
Lt.current || jn() || J.redo();
|
|
5892
5913
|
},
|
|
5893
|
-
canUndo: () =>
|
|
5894
|
-
canRedo: () =>
|
|
5895
|
-
undoSession:
|
|
5896
|
-
redoSession:
|
|
5897
|
-
canUndoSession:
|
|
5898
|
-
canRedoSession:
|
|
5899
|
-
hasDraftSession:
|
|
5900
|
-
cancelDraftSession:
|
|
5901
|
-
commitDraftSession:
|
|
5914
|
+
canUndo: () => Mn() || J.canUndo(),
|
|
5915
|
+
canRedo: () => Nn() || J.canRedo(),
|
|
5916
|
+
undoSession: An,
|
|
5917
|
+
redoSession: jn,
|
|
5918
|
+
canUndoSession: Mn,
|
|
5919
|
+
canRedoSession: Nn,
|
|
5920
|
+
hasDraftSession: Pn,
|
|
5921
|
+
cancelDraftSession: kn,
|
|
5922
|
+
commitDraftSession: In,
|
|
5902
5923
|
setSelection: en,
|
|
5903
5924
|
createShapes: (e) => {
|
|
5904
5925
|
!e.length || Ht() || (J.create(e), en(e.map((e) => e.id)));
|
|
@@ -5910,14 +5931,14 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5910
5931
|
!e.length || Ht() || J.remove(e);
|
|
5911
5932
|
},
|
|
5912
5933
|
getShapes: J.getShapes,
|
|
5913
|
-
selectAll:
|
|
5914
|
-
clearSelection:
|
|
5915
|
-
deleteSelection:
|
|
5916
|
-
copySelection:
|
|
5917
|
-
paste:
|
|
5918
|
-
duplicate:
|
|
5919
|
-
bringToFront:
|
|
5920
|
-
sendToBack:
|
|
5934
|
+
selectAll: Qn,
|
|
5935
|
+
clearSelection: $n,
|
|
5936
|
+
deleteSelection: er,
|
|
5937
|
+
copySelection: nr,
|
|
5938
|
+
paste: ir,
|
|
5939
|
+
duplicate: ar,
|
|
5940
|
+
bringToFront: or,
|
|
5941
|
+
sendToBack: sr,
|
|
5921
5942
|
zoomFit: () => W.current?.fit(),
|
|
5922
5943
|
zoom100: () => W.current?.zoom100(),
|
|
5923
5944
|
zoomIn: () => {
|
|
@@ -5932,100 +5953,100 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5932
5953
|
let { w: t, h: n } = e.screenSize;
|
|
5933
5954
|
e.zoomAt(t / 2, n / 2, 1 / 1.2);
|
|
5934
5955
|
},
|
|
5935
|
-
zoomToSelection:
|
|
5936
|
-
zoomToShapes:
|
|
5937
|
-
zoomToBounds:
|
|
5956
|
+
zoomToSelection: pr,
|
|
5957
|
+
zoomToShapes: fr,
|
|
5958
|
+
zoomToBounds: dr,
|
|
5938
5959
|
brush: {
|
|
5939
|
-
setScalarMode:
|
|
5940
|
-
getScalarMode:
|
|
5941
|
-
hasSession:
|
|
5942
|
-
commit:
|
|
5943
|
-
cancel:
|
|
5944
|
-
beginEditFromSelection:
|
|
5960
|
+
setScalarMode: Ln,
|
|
5961
|
+
getScalarMode: Rn,
|
|
5962
|
+
hasSession: zn,
|
|
5963
|
+
commit: Bn,
|
|
5964
|
+
cancel: Vn,
|
|
5965
|
+
beginEditFromSelection: Hn
|
|
5945
5966
|
}
|
|
5946
5967
|
}), [
|
|
5947
5968
|
J,
|
|
5948
5969
|
en,
|
|
5949
5970
|
Ht,
|
|
5950
|
-
kn,
|
|
5951
5971
|
An,
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5972
|
+
jn,
|
|
5973
|
+
In,
|
|
5974
|
+
kn,
|
|
5955
5975
|
Bn,
|
|
5956
|
-
|
|
5957
|
-
Zn,
|
|
5976
|
+
Vn,
|
|
5958
5977
|
Qn,
|
|
5978
|
+
$n,
|
|
5959
5979
|
er,
|
|
5960
5980
|
nr,
|
|
5961
|
-
rr,
|
|
5962
5981
|
ir,
|
|
5963
5982
|
ar,
|
|
5983
|
+
or,
|
|
5984
|
+
sr,
|
|
5985
|
+
pr,
|
|
5986
|
+
fr,
|
|
5964
5987
|
dr,
|
|
5965
|
-
ur,
|
|
5966
|
-
lr,
|
|
5967
|
-
In,
|
|
5968
5988
|
Ln,
|
|
5969
5989
|
Rn,
|
|
5970
|
-
|
|
5990
|
+
zn,
|
|
5991
|
+
Hn
|
|
5971
5992
|
]);
|
|
5972
|
-
let
|
|
5973
|
-
|
|
5974
|
-
let
|
|
5993
|
+
let hr = j(X);
|
|
5994
|
+
hr.current = X;
|
|
5995
|
+
let gr = w(() => yn({
|
|
5975
5996
|
engineRef: W,
|
|
5976
5997
|
toolRef: jt,
|
|
5977
5998
|
externalToolMapRef: dt,
|
|
5978
5999
|
spaceRef: Kt,
|
|
5979
6000
|
docRef: Gt,
|
|
5980
|
-
selRef:
|
|
6001
|
+
selRef: Q,
|
|
5981
6002
|
draftRef: Mt,
|
|
5982
6003
|
readOnlyRef: Lt,
|
|
5983
6004
|
disableMarqueeRef: Rt,
|
|
5984
6005
|
lockedRef: zt,
|
|
5985
6006
|
onLockedInteraction: () => Bt.current?.(),
|
|
5986
6007
|
onDrawAttemptWithoutDraft: () => Ut.current?.(),
|
|
5987
|
-
createRef:
|
|
6008
|
+
createRef: En,
|
|
5988
6009
|
selectRef: tn,
|
|
5989
6010
|
enterEditRef: on,
|
|
5990
6011
|
editingIdRef: sn,
|
|
5991
|
-
drawSessionRef:
|
|
5992
|
-
assistantRef:
|
|
6012
|
+
drawSessionRef: On,
|
|
6013
|
+
assistantRef: Xn,
|
|
5993
6014
|
setCursorHint: Qt,
|
|
5994
6015
|
setInteractionMode: Zt,
|
|
5995
|
-
syncMinimap:
|
|
5996
|
-
onTransformPreview:
|
|
5997
|
-
onDrawPreview:
|
|
6016
|
+
syncMinimap: pn,
|
|
6017
|
+
onTransformPreview: Cn,
|
|
6018
|
+
onDrawPreview: wn
|
|
5998
6019
|
}), [
|
|
5999
6020
|
Qt,
|
|
6000
6021
|
Zt,
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
]),
|
|
6005
|
-
|
|
6022
|
+
pn,
|
|
6023
|
+
Cn,
|
|
6024
|
+
wn
|
|
6025
|
+
]), _r = j([]);
|
|
6026
|
+
Xr({
|
|
6006
6027
|
backend: pe,
|
|
6007
6028
|
hostRef: we,
|
|
6008
6029
|
engineRef: W,
|
|
6009
6030
|
documentId: Ue,
|
|
6010
6031
|
renderedImageUrl: et,
|
|
6011
|
-
makeCallbacks:
|
|
6012
|
-
viewRef:
|
|
6032
|
+
makeCallbacks: gr,
|
|
6033
|
+
viewRef: hr,
|
|
6013
6034
|
readOnlyRef: Lt,
|
|
6014
6035
|
toolRef: jt,
|
|
6015
|
-
renderShapesRef:
|
|
6016
|
-
coordinateSizeRef:
|
|
6017
|
-
imageSizeRef:
|
|
6018
|
-
selRef:
|
|
6036
|
+
renderShapesRef: _r,
|
|
6037
|
+
coordinateSizeRef: kt,
|
|
6038
|
+
imageSizeRef: At,
|
|
6039
|
+
selRef: Q,
|
|
6019
6040
|
regionOverlayRef: Tt,
|
|
6020
|
-
dimmedRef:
|
|
6021
|
-
syncMinimap:
|
|
6041
|
+
dimmedRef: Dt,
|
|
6042
|
+
syncMinimap: pn,
|
|
6022
6043
|
setImage: ke,
|
|
6023
6044
|
setImageVisible: je,
|
|
6024
6045
|
setReady: Ne,
|
|
6025
6046
|
setImageStatus: ot,
|
|
6026
6047
|
onContextMenuRequest: Fe
|
|
6027
6048
|
});
|
|
6028
|
-
let
|
|
6049
|
+
let vr = k(() => {
|
|
6029
6050
|
let e = h ? J.shapes.map((e) => {
|
|
6030
6051
|
let t = h(e);
|
|
6031
6052
|
return t ? {
|
|
@@ -6051,71 +6072,71 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6051
6072
|
h,
|
|
6052
6073
|
te
|
|
6053
6074
|
]);
|
|
6054
|
-
|
|
6055
|
-
W.current?.setShapes(
|
|
6056
|
-
}, [
|
|
6075
|
+
_r.current = vr, T(() => {
|
|
6076
|
+
W.current?.setShapes(vr, Q.current), pn();
|
|
6077
|
+
}, [vr, pn]), T(() => {
|
|
6057
6078
|
W.current?.setSelection(Y);
|
|
6058
6079
|
}, [Y]), T(() => {
|
|
6059
6080
|
W.current?.setEditing(nn);
|
|
6060
6081
|
}, [nn, Me]);
|
|
6061
|
-
let
|
|
6062
|
-
|
|
6063
|
-
|
|
6082
|
+
let yr = j(ge);
|
|
6083
|
+
yr.current = ge, T(() => {
|
|
6084
|
+
yr.current?.(nn);
|
|
6064
6085
|
}, [nn]), T(() => {
|
|
6065
6086
|
rn(null);
|
|
6066
6087
|
}, [a]), T(() => {
|
|
6067
6088
|
nn && (Y.length !== 1 || Y[0] !== nn) && rn(null);
|
|
6068
6089
|
}, [Y, nn]), T(() => {
|
|
6069
6090
|
let e = W.current;
|
|
6070
|
-
e && (e.setFilter(X.brightness, X.contrast), e.setRenderDefaults({ strokeWidth: X.strokeSize }), e.setImageSmoothing(X.imageSmoothing),
|
|
6091
|
+
e && (e.setFilter(X.brightness, X.contrast), e.setRenderDefaults({ strokeWidth: X.strokeSize }), e.setImageSmoothing(X.imageSmoothing), pn());
|
|
6071
6092
|
}, [
|
|
6072
6093
|
X.brightness,
|
|
6073
6094
|
X.contrast,
|
|
6074
6095
|
X.strokeSize,
|
|
6075
6096
|
X.imageSmoothing,
|
|
6076
|
-
|
|
6097
|
+
pn
|
|
6077
6098
|
]), O(() => {
|
|
6078
|
-
Me && W.current?.setOverlays(X.showRegionMask ?
|
|
6099
|
+
Me && W.current?.setOverlays(X.showRegionMask ? bt : null, r);
|
|
6079
6100
|
}, [
|
|
6080
6101
|
Me,
|
|
6081
|
-
|
|
6102
|
+
bt,
|
|
6082
6103
|
X.showRegionMask,
|
|
6083
6104
|
r
|
|
6084
6105
|
]), T(() => {
|
|
6085
|
-
!Me || !G ||
|
|
6106
|
+
!Me || !G || pn();
|
|
6086
6107
|
}, [
|
|
6087
6108
|
Me,
|
|
6088
6109
|
G,
|
|
6089
6110
|
X.showRegionMask,
|
|
6090
6111
|
ne,
|
|
6091
|
-
|
|
6112
|
+
pn
|
|
6092
6113
|
]), T(() => {
|
|
6093
|
-
Me && W.current?.setTransformEnabled(
|
|
6114
|
+
Me && W.current?.setTransformEnabled(!$ && a !== q.BRUSH);
|
|
6094
6115
|
}, [
|
|
6095
|
-
|
|
6116
|
+
$,
|
|
6096
6117
|
Me,
|
|
6097
6118
|
a
|
|
6098
6119
|
]), T(() => {
|
|
6099
6120
|
u && rn(null);
|
|
6100
6121
|
}, [u]), T(() => {
|
|
6101
|
-
|
|
6102
|
-
}, [a,
|
|
6103
|
-
let
|
|
6122
|
+
Gn(a, dt.current.has(a));
|
|
6123
|
+
}, [a, Gn]);
|
|
6124
|
+
let br = Yn.finalize;
|
|
6104
6125
|
T(() => {
|
|
6105
|
-
|
|
6106
|
-
}, [a,
|
|
6107
|
-
qt.current = "idle",
|
|
6126
|
+
br();
|
|
6127
|
+
}, [a, br]), T(() => {
|
|
6128
|
+
qt.current = "idle", Jt.current = null, Xt();
|
|
6108
6129
|
}, [
|
|
6109
6130
|
a,
|
|
6110
6131
|
pe,
|
|
6111
6132
|
Xt
|
|
6112
6133
|
]), T(() => {
|
|
6113
|
-
|
|
6134
|
+
Kn(Y, $);
|
|
6114
6135
|
}, [
|
|
6115
6136
|
Y,
|
|
6116
6137
|
a,
|
|
6117
|
-
|
|
6118
|
-
|
|
6138
|
+
$,
|
|
6139
|
+
Kn
|
|
6119
6140
|
]), T(() => {
|
|
6120
6141
|
Me && Xt();
|
|
6121
6142
|
}, [
|
|
@@ -6125,25 +6146,25 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6125
6146
|
Me,
|
|
6126
6147
|
Xt
|
|
6127
6148
|
]);
|
|
6128
|
-
let
|
|
6129
|
-
|
|
6130
|
-
let
|
|
6149
|
+
let xr = j(Xe);
|
|
6150
|
+
xr.current = Xe;
|
|
6151
|
+
let Sr = e !== null, Cr = j(null);
|
|
6131
6152
|
T(() => {
|
|
6132
|
-
let e =
|
|
6133
|
-
|
|
6153
|
+
let e = Sr ? Ue : null;
|
|
6154
|
+
Cr.current !== e && (Cr.current = e, Fe(null), rn(null), qt.current = "idle", Jt.current = null, J.reset(Sr ? Je ?? [] : []), en(Sr ? xr.current ?? [] : []), kn(), br(), Xt());
|
|
6134
6155
|
}, [
|
|
6135
|
-
|
|
6156
|
+
Sr,
|
|
6136
6157
|
Ue,
|
|
6137
6158
|
Je,
|
|
6138
6159
|
J.reset,
|
|
6139
6160
|
en,
|
|
6140
|
-
|
|
6141
|
-
|
|
6161
|
+
kn,
|
|
6162
|
+
br,
|
|
6142
6163
|
Xt
|
|
6143
6164
|
]);
|
|
6144
|
-
let
|
|
6165
|
+
let wr = w(() => {
|
|
6145
6166
|
let e = sn.current;
|
|
6146
|
-
if (!e ||
|
|
6167
|
+
if (!e || $) return !1;
|
|
6147
6168
|
let t = W.current, n = new Set(t?.getVertexSelection() ?? []);
|
|
6148
6169
|
if (!n.size) return !1;
|
|
6149
6170
|
let r = Gt.current.getShapes().find((t) => t.id === e);
|
|
@@ -6153,76 +6174,76 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6153
6174
|
...r,
|
|
6154
6175
|
points: i
|
|
6155
6176
|
}]), t?.setVertexSelection([]), !0);
|
|
6156
|
-
}, [
|
|
6157
|
-
|
|
6177
|
+
}, [$]), Tr = () => J.getShapes().some((e) => Q.current.includes(e.id) && ae(e));
|
|
6178
|
+
tr({
|
|
6158
6179
|
keymap: de,
|
|
6159
6180
|
hostRef: we,
|
|
6160
6181
|
actions: {
|
|
6161
6182
|
undo: () => {
|
|
6162
|
-
|
|
6183
|
+
$ || An() || J.undo();
|
|
6163
6184
|
},
|
|
6164
6185
|
redo: () => {
|
|
6165
|
-
|
|
6186
|
+
$ || jn() || J.redo();
|
|
6166
6187
|
},
|
|
6167
|
-
selectAll:
|
|
6168
|
-
copy:
|
|
6188
|
+
selectAll: Qn,
|
|
6189
|
+
copy: nr,
|
|
6169
6190
|
cut: () => {
|
|
6170
|
-
Ht(
|
|
6191
|
+
Ht(Tr()) || (nr(), er());
|
|
6171
6192
|
},
|
|
6172
6193
|
paste: () => {
|
|
6173
|
-
Ht(
|
|
6194
|
+
Ht(rr()) || ir();
|
|
6174
6195
|
},
|
|
6175
6196
|
duplicate: () => {
|
|
6176
|
-
Ht(
|
|
6197
|
+
Ht(Tr()) || ar();
|
|
6177
6198
|
},
|
|
6178
6199
|
delete: () => {
|
|
6179
|
-
Ht(
|
|
6200
|
+
Ht(Tr()) || Fn() && Un() || wr() || er();
|
|
6180
6201
|
},
|
|
6181
6202
|
cancel: () => {
|
|
6182
6203
|
let e = dt.current.get(jt.current);
|
|
6183
6204
|
if (!(e?.onCancel && e.onCancel() !== !1)) {
|
|
6184
|
-
if (
|
|
6185
|
-
|
|
6205
|
+
if (Yn.isActive()) {
|
|
6206
|
+
Yn.cancel();
|
|
6186
6207
|
return;
|
|
6187
6208
|
}
|
|
6188
|
-
if (
|
|
6189
|
-
|
|
6209
|
+
if (Pn()) {
|
|
6210
|
+
kn();
|
|
6190
6211
|
return;
|
|
6191
6212
|
}
|
|
6192
6213
|
if (nn) {
|
|
6193
6214
|
rn(null);
|
|
6194
6215
|
return;
|
|
6195
6216
|
}
|
|
6196
|
-
if (
|
|
6197
|
-
|
|
6217
|
+
if (Q.current.length) {
|
|
6218
|
+
$n();
|
|
6198
6219
|
return;
|
|
6199
6220
|
}
|
|
6200
6221
|
m?.();
|
|
6201
6222
|
}
|
|
6202
6223
|
},
|
|
6203
6224
|
commitDraft: () => {
|
|
6204
|
-
if (
|
|
6205
|
-
|
|
6225
|
+
if (Yn.isActive()) {
|
|
6226
|
+
Yn.finalize();
|
|
6206
6227
|
return;
|
|
6207
6228
|
}
|
|
6208
|
-
if (
|
|
6209
|
-
|
|
6229
|
+
if (Pn()) {
|
|
6230
|
+
In();
|
|
6210
6231
|
return;
|
|
6211
6232
|
}
|
|
6212
|
-
if (
|
|
6233
|
+
if ($) return;
|
|
6213
6234
|
if (nn) {
|
|
6214
6235
|
rn(null);
|
|
6215
6236
|
return;
|
|
6216
6237
|
}
|
|
6217
|
-
let e =
|
|
6238
|
+
let e = Q.current;
|
|
6218
6239
|
if (e.length !== 1) return;
|
|
6219
6240
|
let t = Gt.current.getShapes().find((t) => t.id === e[0]);
|
|
6220
6241
|
t && (t.type === R.POLYGON || t.type === R.LINE) && t.interaction?.editable !== !1 && !t.readOnly && rn(e[0]);
|
|
6221
6242
|
},
|
|
6222
|
-
bringToFront:
|
|
6223
|
-
sendToBack:
|
|
6224
|
-
zoomIn: () =>
|
|
6225
|
-
zoomOut: () =>
|
|
6243
|
+
bringToFront: or,
|
|
6244
|
+
sendToBack: sr,
|
|
6245
|
+
zoomIn: () => mr(1.2),
|
|
6246
|
+
zoomOut: () => mr(1 / 1.2),
|
|
6226
6247
|
zoom100: () => W.current?.zoom100(),
|
|
6227
6248
|
zoomFit: () => W.current?.fit(),
|
|
6228
6249
|
toggleMinimap: () => ze((e) => !e),
|
|
@@ -6250,104 +6271,104 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6250
6271
|
onSpaceUp: () => {
|
|
6251
6272
|
W.current?.setPanMode(!1), qt.current === "panning" ? Zt("idle") : Xt();
|
|
6252
6273
|
},
|
|
6253
|
-
nudge: (e, t) => Ht(
|
|
6274
|
+
nudge: (e, t) => Ht(Tr()) || cr(e, t)
|
|
6254
6275
|
});
|
|
6255
|
-
let
|
|
6276
|
+
let Er = k(() => vr.filter((e) => Y.includes(e.id) && z(e)), [vr, Y]), Dr = k(() => vn ? [...Er, vn] : Er, [Er, vn]), Or = Y.length > 0, kr = J.shapes.some((e) => Y.includes(e.id) && ae(e)), Ar = !$ && Y.length === 1 && (() => {
|
|
6256
6277
|
let e = J.shapes.find((e) => e.id === Y[0]);
|
|
6257
6278
|
return !!e && (e.type === R.POLYGON || e.type === R.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
|
|
6258
|
-
})(),
|
|
6279
|
+
})(), jr = lr(), Mr = $ || jr.length < 2 || (F ? !F(jr) : !1), Nr = !!ue && !$, Pr = Nr && Y.length === 1 ? (() => {
|
|
6259
6280
|
let e = J.shapes.find((e) => e.id === Y[0]);
|
|
6260
6281
|
return e && e.type === R.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
|
|
6261
|
-
})() : null,
|
|
6282
|
+
})() : null, Fr = [
|
|
6262
6283
|
{
|
|
6263
6284
|
id: "copy",
|
|
6264
6285
|
label: Z.contextMenu.copy,
|
|
6265
6286
|
shortcut: "⌘C",
|
|
6266
|
-
disabled: !
|
|
6267
|
-
onClick:
|
|
6287
|
+
disabled: !kr,
|
|
6288
|
+
onClick: nr
|
|
6268
6289
|
},
|
|
6269
6290
|
{
|
|
6270
6291
|
id: "paste",
|
|
6271
6292
|
label: Z.contextMenu.paste,
|
|
6272
6293
|
shortcut: "⌘V",
|
|
6273
|
-
disabled:
|
|
6274
|
-
onClick: () =>
|
|
6294
|
+
disabled: $ || !rr(),
|
|
6295
|
+
onClick: () => ir(Pe?.img)
|
|
6275
6296
|
},
|
|
6276
6297
|
{
|
|
6277
6298
|
id: "duplicate",
|
|
6278
6299
|
label: Z.contextMenu.duplicate,
|
|
6279
6300
|
shortcut: "⌘D",
|
|
6280
|
-
disabled: !
|
|
6281
|
-
onClick:
|
|
6301
|
+
disabled: !kr || $,
|
|
6302
|
+
onClick: ar
|
|
6282
6303
|
},
|
|
6283
6304
|
{
|
|
6284
6305
|
id: "delete",
|
|
6285
6306
|
label: Z.contextMenu.delete,
|
|
6286
6307
|
shortcut: "Del",
|
|
6287
6308
|
danger: !0,
|
|
6288
|
-
disabled: !
|
|
6289
|
-
onClick:
|
|
6309
|
+
disabled: !kr || $,
|
|
6310
|
+
onClick: er
|
|
6290
6311
|
},
|
|
6291
6312
|
{ separator: !0 },
|
|
6292
6313
|
{
|
|
6293
6314
|
id: "editVertices",
|
|
6294
6315
|
label: Z.contextMenu.editVertices,
|
|
6295
6316
|
shortcut: "Enter",
|
|
6296
|
-
disabled: !
|
|
6317
|
+
disabled: !Ar,
|
|
6297
6318
|
onClick: () => rn(Y[0])
|
|
6298
6319
|
},
|
|
6299
6320
|
{
|
|
6300
6321
|
id: "merge",
|
|
6301
6322
|
label: Z.contextMenu.merge,
|
|
6302
|
-
disabled:
|
|
6303
|
-
onClick:
|
|
6323
|
+
disabled: Mr,
|
|
6324
|
+
onClick: ur
|
|
6304
6325
|
},
|
|
6305
|
-
...
|
|
6326
|
+
...Nr ? [{
|
|
6306
6327
|
id: "assistExpand",
|
|
6307
6328
|
label: Z.contextMenu.assistExpand,
|
|
6308
6329
|
icon: /* @__PURE__ */ x(d, { size: 14 }),
|
|
6309
|
-
disabled: !
|
|
6330
|
+
disabled: !Pr,
|
|
6310
6331
|
onClick: () => {
|
|
6311
|
-
Pe &&
|
|
6332
|
+
Pe && Pr && Yn.refineShape(Pr, Pe.img, !0);
|
|
6312
6333
|
}
|
|
6313
6334
|
}, {
|
|
6314
6335
|
id: "assistExclude",
|
|
6315
6336
|
label: Z.contextMenu.assistExclude,
|
|
6316
6337
|
icon: /* @__PURE__ */ x(d, { size: 14 }),
|
|
6317
|
-
disabled: !
|
|
6338
|
+
disabled: !Pr,
|
|
6318
6339
|
onClick: () => {
|
|
6319
|
-
Pe &&
|
|
6340
|
+
Pe && Pr && Yn.refineShape(Pr, Pe.img, !1);
|
|
6320
6341
|
}
|
|
6321
6342
|
}] : [],
|
|
6322
6343
|
{
|
|
6323
6344
|
id: "bringToFront",
|
|
6324
6345
|
label: Z.contextMenu.bringToFront,
|
|
6325
|
-
disabled: !
|
|
6326
|
-
onClick:
|
|
6346
|
+
disabled: !kr || $,
|
|
6347
|
+
onClick: or
|
|
6327
6348
|
},
|
|
6328
6349
|
{
|
|
6329
6350
|
id: "sendToBack",
|
|
6330
6351
|
label: Z.contextMenu.sendToBack,
|
|
6331
|
-
disabled: !
|
|
6332
|
-
onClick:
|
|
6352
|
+
disabled: !kr || $,
|
|
6353
|
+
onClick: sr
|
|
6333
6354
|
},
|
|
6334
6355
|
{ separator: !0 },
|
|
6335
6356
|
{
|
|
6336
6357
|
id: "undo",
|
|
6337
6358
|
label: Z.contextMenu.undo,
|
|
6338
6359
|
shortcut: "⌘Z",
|
|
6339
|
-
disabled:
|
|
6360
|
+
disabled: $ || !Mn() && !J.canUndo(),
|
|
6340
6361
|
onClick: () => {
|
|
6341
|
-
|
|
6362
|
+
An() || J.undo();
|
|
6342
6363
|
}
|
|
6343
6364
|
},
|
|
6344
6365
|
{
|
|
6345
6366
|
id: "redo",
|
|
6346
6367
|
label: Z.contextMenu.redo,
|
|
6347
6368
|
shortcut: "⇧⌘Z",
|
|
6348
|
-
disabled:
|
|
6369
|
+
disabled: $ || !Nn() && !J.canRedo(),
|
|
6349
6370
|
onClick: () => {
|
|
6350
|
-
|
|
6371
|
+
jn() || J.redo();
|
|
6351
6372
|
}
|
|
6352
6373
|
},
|
|
6353
6374
|
{ separator: !0 },
|
|
@@ -6355,35 +6376,35 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6355
6376
|
id: "selectAll",
|
|
6356
6377
|
label: Z.contextMenu.selectAll,
|
|
6357
6378
|
shortcut: "⌘A",
|
|
6358
|
-
onClick:
|
|
6379
|
+
onClick: Qn
|
|
6359
6380
|
},
|
|
6360
6381
|
{
|
|
6361
6382
|
id: "clearSelection",
|
|
6362
6383
|
label: Z.contextMenu.clearSelection,
|
|
6363
|
-
disabled: !
|
|
6364
|
-
onClick:
|
|
6384
|
+
disabled: !Or,
|
|
6385
|
+
onClick: $n
|
|
6365
6386
|
},
|
|
6366
6387
|
{
|
|
6367
6388
|
id: "zoomToSelection",
|
|
6368
6389
|
label: Z.contextMenu.zoomToSelection,
|
|
6369
|
-
disabled: !
|
|
6370
|
-
onClick:
|
|
6390
|
+
disabled: !Or,
|
|
6391
|
+
onClick: pr
|
|
6371
6392
|
}
|
|
6372
|
-
],
|
|
6393
|
+
], Ir = c ? Fr.filter((e) => "separator" in e || !!e.id && ci.has(e.id)) : Fr, Lr = A ? A(Ir, {
|
|
6373
6394
|
selectedIds: Y,
|
|
6374
|
-
readOnly:
|
|
6375
|
-
}) :
|
|
6395
|
+
readOnly: $
|
|
6396
|
+
}) : Ir, Rr = ti({
|
|
6376
6397
|
engineRef: W,
|
|
6377
6398
|
image: G,
|
|
6378
6399
|
wheelZoom: X.wheelZoom,
|
|
6379
6400
|
minimapSize: 204
|
|
6380
|
-
}),
|
|
6401
|
+
}), zr = w(() => {
|
|
6381
6402
|
W.current?.zoom100();
|
|
6382
|
-
}, []),
|
|
6403
|
+
}, []), Br = w(() => {
|
|
6383
6404
|
ze((e) => !e);
|
|
6384
|
-
}, []),
|
|
6405
|
+
}, []), Vr = w(() => {
|
|
6385
6406
|
He((e) => !e);
|
|
6386
|
-
}, []),
|
|
6407
|
+
}, []), Hr = w(() => {
|
|
6387
6408
|
He(!1);
|
|
6388
6409
|
}, []);
|
|
6389
6410
|
return /* @__PURE__ */ S("div", {
|
|
@@ -6410,9 +6431,23 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6410
6431
|
errorLabel: Z.imageLoadError,
|
|
6411
6432
|
errorHints: Z.imageErrorHints
|
|
6412
6433
|
}),
|
|
6413
|
-
Me && G && /* @__PURE__ */
|
|
6434
|
+
Me && G && /* @__PURE__ */ S("div", {
|
|
6414
6435
|
className: "aivex:pointer-events-none aivex:absolute aivex:inset-0 aivex:overflow-hidden",
|
|
6415
|
-
children: /* @__PURE__ */
|
|
6436
|
+
children: [Dr.length > 0 && /* @__PURE__ */ x("div", {
|
|
6437
|
+
className: "aivex:absolute aivex:inset-0",
|
|
6438
|
+
children: /* @__PURE__ */ x(Et, {
|
|
6439
|
+
shapes: Dr,
|
|
6440
|
+
getLabel: V,
|
|
6441
|
+
hideDot: H,
|
|
6442
|
+
formatInfo: U,
|
|
6443
|
+
register: gn,
|
|
6444
|
+
viewport: W.current?.viewport ?? {
|
|
6445
|
+
scale: 1,
|
|
6446
|
+
x: 0,
|
|
6447
|
+
y: 0
|
|
6448
|
+
}
|
|
6449
|
+
})
|
|
6450
|
+
}), /* @__PURE__ */ S("div", {
|
|
6416
6451
|
ref: Ee,
|
|
6417
6452
|
style: {
|
|
6418
6453
|
position: "absolute",
|
|
@@ -6463,21 +6498,14 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6463
6498
|
y: 0
|
|
6464
6499
|
}
|
|
6465
6500
|
}),
|
|
6466
|
-
|
|
6467
|
-
shapes: Tr,
|
|
6468
|
-
getLabel: V,
|
|
6469
|
-
hideDot: H,
|
|
6470
|
-
formatInfo: U,
|
|
6471
|
-
register: hn
|
|
6472
|
-
}),
|
|
6473
|
-
ue && ($.status === "loading" || $.boxes.length > 0) && /* @__PURE__ */ x(Ye, {
|
|
6501
|
+
ue && (Yn.status === "loading" || Yn.boxes.length > 0) && /* @__PURE__ */ x(Ye, {
|
|
6474
6502
|
image: G,
|
|
6475
|
-
points:
|
|
6476
|
-
boxes:
|
|
6477
|
-
status:
|
|
6503
|
+
points: Yn.points,
|
|
6504
|
+
boxes: Yn.boxes,
|
|
6505
|
+
status: Yn.status
|
|
6478
6506
|
})
|
|
6479
6507
|
]
|
|
6480
|
-
})
|
|
6508
|
+
})]
|
|
6481
6509
|
}),
|
|
6482
6510
|
Me && X.showCursorGuide && /* @__PURE__ */ x(Qe, { color: "#1e88e5" }),
|
|
6483
6511
|
G && y && /* @__PURE__ */ x(ht, {
|
|
@@ -6485,32 +6513,32 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6485
6513
|
imageUrl: et,
|
|
6486
6514
|
imageVisible: Ae,
|
|
6487
6515
|
loading: !Me,
|
|
6488
|
-
region:
|
|
6516
|
+
region: bt,
|
|
6489
6517
|
roiMaskId: Oe,
|
|
6490
|
-
shapes:
|
|
6518
|
+
shapes: vr,
|
|
6491
6519
|
view: X,
|
|
6492
6520
|
viewDefaults: pt,
|
|
6493
6521
|
onChangeView: _t,
|
|
6494
|
-
nav:
|
|
6495
|
-
registerShape:
|
|
6522
|
+
nav: Rr,
|
|
6523
|
+
registerShape: dn,
|
|
6496
6524
|
rectRef: Te,
|
|
6497
6525
|
zoomLabelRef: De,
|
|
6498
|
-
onZoom100:
|
|
6526
|
+
onZoom100: zr,
|
|
6499
6527
|
open: Re,
|
|
6500
|
-
onToggleOpen:
|
|
6528
|
+
onToggleOpen: Br,
|
|
6501
6529
|
position: b,
|
|
6502
6530
|
labels: Z.minimap,
|
|
6503
6531
|
settingsLabels: Z.viewSettings,
|
|
6504
6532
|
settingsItems: P,
|
|
6505
6533
|
showSettings: C,
|
|
6506
6534
|
settingsOpen: K,
|
|
6507
|
-
onToggleSettings:
|
|
6508
|
-
onCloseSettings:
|
|
6535
|
+
onToggleSettings: Vr,
|
|
6536
|
+
onCloseSettings: Hr
|
|
6509
6537
|
}),
|
|
6510
6538
|
Pe && /* @__PURE__ */ x(Ze, {
|
|
6511
6539
|
x: Pe.x,
|
|
6512
6540
|
y: Pe.y,
|
|
6513
|
-
items:
|
|
6541
|
+
items: Lr,
|
|
6514
6542
|
onClose: () => Fe(null)
|
|
6515
6543
|
})
|
|
6516
6544
|
]
|
|
@@ -6518,7 +6546,7 @@ function ci({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6518
6546
|
}
|
|
6519
6547
|
//#endregion
|
|
6520
6548
|
//#region src/components/ShapeEditor/_model/viewerPatch.ts
|
|
6521
|
-
function
|
|
6549
|
+
function di({ viewport: e, image: t, focusPoints: n, zoomPadding: r, focusFit: i }) {
|
|
6522
6550
|
let a = Math.min(e.width / t.width, e.height / t.height);
|
|
6523
6551
|
if (!n?.length) return {
|
|
6524
6552
|
scale: a,
|
|
@@ -6534,7 +6562,7 @@ function li({ viewport: e, image: t, focusPoints: n, zoomPadding: r, focusFit: i
|
|
|
6534
6562
|
offsetY: f
|
|
6535
6563
|
};
|
|
6536
6564
|
}
|
|
6537
|
-
function
|
|
6565
|
+
function fi(e, t, n) {
|
|
6538
6566
|
let r = Math.max(0, -e.offsetX / e.scale), i = Math.max(0, -e.offsetY / e.scale), a = Math.min(n.width, (t.width - e.offsetX) / e.scale), o = Math.min(n.height, (t.height - e.offsetY) / e.scale);
|
|
6539
6567
|
return a <= r || o <= i ? null : {
|
|
6540
6568
|
x: r,
|
|
@@ -6543,7 +6571,7 @@ function ui(e, t, n) {
|
|
|
6543
6571
|
height: o - i
|
|
6544
6572
|
};
|
|
6545
6573
|
}
|
|
6546
|
-
function
|
|
6574
|
+
function pi({ visible: e, image: t, natural: n, density: r }) {
|
|
6547
6575
|
let i = n.width / t.width, a = n.height / t.height, o = Math.max(0, Math.floor(e.x * i)), s = Math.max(0, Math.floor(e.y * a)), c = Math.min(n.width, Math.ceil((e.x + e.width) * i)) - o, l = Math.min(n.height, Math.ceil((e.y + e.height) * a)) - s, u = {
|
|
6548
6576
|
x: o / i,
|
|
6549
6577
|
y: s / a,
|
|
@@ -6562,7 +6590,7 @@ function di({ visible: e, image: t, natural: n, density: r }) {
|
|
|
6562
6590
|
outputHeight: Math.max(1, Math.min(l, Math.ceil(u.height * r)))
|
|
6563
6591
|
};
|
|
6564
6592
|
}
|
|
6565
|
-
function
|
|
6593
|
+
function mi(e, t, n) {
|
|
6566
6594
|
let r = 1e-6;
|
|
6567
6595
|
if (!(e.rect.x <= t.x + r && e.rect.y <= t.y + r && e.rect.x + e.rect.width >= t.x + t.width - r && e.rect.y + e.rect.height >= t.y + t.height - r)) return !1;
|
|
6568
6596
|
let i = Math.min(n.density, n.natural.width / n.image.width), a = Math.min(n.density, n.natural.height / n.image.height);
|
|
@@ -6570,14 +6598,14 @@ function fi(e, t, n) {
|
|
|
6570
6598
|
}
|
|
6571
6599
|
//#endregion
|
|
6572
6600
|
//#region src/components/ShapeEditor/ShapeViewer.tsx
|
|
6573
|
-
function
|
|
6601
|
+
function hi(e, t, n) {
|
|
6574
6602
|
if (t.length !== 0) {
|
|
6575
6603
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
6576
6604
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
6577
6605
|
n && e.closePath();
|
|
6578
6606
|
}
|
|
6579
6607
|
}
|
|
6580
|
-
function
|
|
6608
|
+
function gi(e, t, n, r) {
|
|
6581
6609
|
if (t.interaction?.visible === !1) return;
|
|
6582
6610
|
let i = at(t, {
|
|
6583
6611
|
strokeWidth: r,
|
|
@@ -6594,11 +6622,11 @@ function mi(e, t, n, r) {
|
|
|
6594
6622
|
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);
|
|
6595
6623
|
e.beginPath(), t.type === R.ELLIPSE ? e.ellipse(i + o / 2, a + s / 2, o / 2, s / 2, 0, 0, Math.PI * 2) : e.rect(i, a, o, s);
|
|
6596
6624
|
}
|
|
6597
|
-
} else
|
|
6625
|
+
} else hi(e, t.points, t.type !== R.LINE);
|
|
6598
6626
|
i.fillVisible && (e.save(), e.fillStyle = i.color, e.globalAlpha *= i.fillAlpha, e.fill("evenodd"), 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();
|
|
6599
6627
|
}
|
|
6600
|
-
async function
|
|
6601
|
-
let r = await
|
|
6628
|
+
async function _i(e, t, n) {
|
|
6629
|
+
let r = await ar(e);
|
|
6602
6630
|
if (!r) return null;
|
|
6603
6631
|
try {
|
|
6604
6632
|
let i = {
|
|
@@ -6619,7 +6647,7 @@ async function hi(e, t, n) {
|
|
|
6619
6647
|
outputHeight: 0
|
|
6620
6648
|
}, o = n(i);
|
|
6621
6649
|
if (!o?.visibleRect) return a;
|
|
6622
|
-
let s =
|
|
6650
|
+
let s = pi({
|
|
6623
6651
|
visible: o.visibleRect,
|
|
6624
6652
|
natural: i,
|
|
6625
6653
|
...o
|
|
@@ -6639,7 +6667,7 @@ async function hi(e, t, n) {
|
|
|
6639
6667
|
r.release();
|
|
6640
6668
|
}
|
|
6641
6669
|
}
|
|
6642
|
-
function
|
|
6670
|
+
function vi({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes: r = [], regionMask: i, focusedShapeId: a, focusFit: o = "contain", zoomPadding: s = .3, strokeSize: c = 1, brightness: l = 1, contrast: u = 1, imageSmoothing: d = !0, lazy: f = !0, className: p, style: m, renderImageState: h }) {
|
|
6643
6671
|
let g = j(null), _ = j(null), v = j(null), [y, b] = M(!f), [C, w] = M("loading"), [E, D] = M(null), [O, A] = M(0), [N, P] = M(0);
|
|
6644
6672
|
T(() => {
|
|
6645
6673
|
if (!f || y) return;
|
|
@@ -6671,7 +6699,7 @@ function gi({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6671
6699
|
}, c = (e) => {
|
|
6672
6700
|
let t = n ?? e;
|
|
6673
6701
|
if (!t.width || !t.height) return null;
|
|
6674
|
-
let r =
|
|
6702
|
+
let r = di({
|
|
6675
6703
|
viewport: a,
|
|
6676
6704
|
image: t,
|
|
6677
6705
|
focusPoints: F?.points,
|
|
@@ -6680,27 +6708,27 @@ function gi({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6680
6708
|
});
|
|
6681
6709
|
return {
|
|
6682
6710
|
image: t,
|
|
6683
|
-
visibleRect:
|
|
6711
|
+
visibleRect: fi(r, a, t),
|
|
6684
6712
|
density: r.scale * (window.devicePixelRatio || 1)
|
|
6685
6713
|
};
|
|
6686
6714
|
}, l = v.current;
|
|
6687
6715
|
if (l?.url === e && l.smoothing === d) {
|
|
6688
6716
|
let e = c(l.natural);
|
|
6689
|
-
if (!e?.visibleRect || l.bitmap &&
|
|
6717
|
+
if (!e?.visibleRect || l.bitmap && mi(l, e.visibleRect, {
|
|
6690
6718
|
...e,
|
|
6691
6719
|
natural: l.natural
|
|
6692
6720
|
})) return;
|
|
6693
6721
|
} else l?.url !== e && (w("loading"), D(null));
|
|
6694
6722
|
let u = !0;
|
|
6695
6723
|
return (async () => {
|
|
6696
|
-
let t = await
|
|
6724
|
+
let t = await lr(() => u ? _i(e, d, c) : Promise.resolve(void 0));
|
|
6697
6725
|
if (!u) {
|
|
6698
6726
|
t?.bitmap?.close();
|
|
6699
6727
|
return;
|
|
6700
6728
|
}
|
|
6701
6729
|
if (t === null) {
|
|
6702
6730
|
v.current?.bitmap?.close(), v.current = null, w("error");
|
|
6703
|
-
let t = await
|
|
6731
|
+
let t = await mr(e);
|
|
6704
6732
|
u && D(t);
|
|
6705
6733
|
return;
|
|
6706
6734
|
}
|
|
@@ -6735,7 +6763,7 @@ function gi({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6735
6763
|
if (!h) return;
|
|
6736
6764
|
let y = n?.width ?? a.natural.width, b = n?.height ?? a.natural.height;
|
|
6737
6765
|
if (!y || !b) return;
|
|
6738
|
-
let { scale: x, offsetX: S, offsetY: w } =
|
|
6766
|
+
let { scale: x, offsetX: S, offsetY: w } = di({
|
|
6739
6767
|
viewport: {
|
|
6740
6768
|
width: f,
|
|
6741
6769
|
height: p
|
|
@@ -6758,20 +6786,20 @@ function gi({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6758
6786
|
h.drawImage(a.bitmap, e, t, n, r);
|
|
6759
6787
|
}
|
|
6760
6788
|
h.filter = "none";
|
|
6761
|
-
let E = i ?
|
|
6762
|
-
if (E && (
|
|
6789
|
+
let E = i ? ln(i, y, b) : null;
|
|
6790
|
+
if (E && (nn(h, E, y, b), E.outlineStyles)) {
|
|
6763
6791
|
let e = (e, t) => {
|
|
6764
6792
|
if (h.lineWidth = t.width / x, t.underlayColor) {
|
|
6765
6793
|
h.setLineDash([]), h.strokeStyle = t.underlayColor;
|
|
6766
|
-
for (let [t, n] of e)
|
|
6794
|
+
for (let [t, n] of e) hi(h, [t, n], !1), h.stroke();
|
|
6767
6795
|
}
|
|
6768
6796
|
h.save(), h.globalAlpha *= t.opacity, h.setLineDash(t.dash.map((e) => e / x)), h.strokeStyle = t.color;
|
|
6769
|
-
for (let [t, n] of e)
|
|
6797
|
+
for (let [t, n] of e) hi(h, [t, n], !1), h.stroke();
|
|
6770
6798
|
h.restore();
|
|
6771
6799
|
};
|
|
6772
6800
|
e(E.visibleOutline, E.outlineStyles.visible), e(E.occludedOutline, E.outlineStyles.occluded);
|
|
6773
6801
|
}
|
|
6774
|
-
for (let e of se(r))
|
|
6802
|
+
for (let e of se(r)) gi(h, e, x, c);
|
|
6775
6803
|
h.restore();
|
|
6776
6804
|
}, [
|
|
6777
6805
|
l,
|
|
@@ -6853,6 +6881,6 @@ function gi({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6853
6881
|
});
|
|
6854
6882
|
}
|
|
6855
6883
|
//#endregion
|
|
6856
|
-
export { K as DEFAULT_EDITOR_STRINGS, Ve as DEFAULT_VIEW_SETTINGS, R as SHAPE_TYPE,
|
|
6884
|
+
export { K as DEFAULT_EDITOR_STRINGS, Ve as DEFAULT_VIEW_SETTINGS, R as SHAPE_TYPE, ui as ShapeEditor, ui as default, vi as ShapeViewer, q as TOOL, He as VIEW_SETTING_RANGES, We as clampViewSettings, ce as generateId };
|
|
6857
6885
|
|
|
6858
6886
|
//# sourceMappingURL=shape-editor.js.map
|