@aivex/ui 1.2.0-dev.40 → 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.
@@ -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 = "var(--editor-overlay-inverse-scale, 1)", _t = 6, Z = {
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 vt(e) {
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 yt(e) {
1302
- return `translate3d(${e.width}px, ${e.height}px, 0) scale(${gt}) translate(-100%, ${_t}px)`;
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 bt(e, t) {
1305
- let n = vt(t);
1306
- e.style.transform = `translate3d(${n.x}px, ${n.y}px, 0)`;
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 xt(e, t) {
1324
+ function Ct(e, t) {
1311
1325
  return {
1312
1326
  shape: e,
1313
- ...vt(t)
1327
+ ...Z(t)
1314
1328
  };
1315
1329
  }
1316
- function St(e) {
1330
+ function wt(e) {
1317
1331
  return `${Math.round(e.width)} x ${Math.round(e.height)} px`;
1318
1332
  }
1319
- function Ct({ color: e, striped: t }) {
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 wt({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i }) {
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 a = vt(e.points), o = e.type === R.POINT, s = o ? void 0 : t?.(e), c = e.style?.color ?? "#00e5ff", l = !!e.style?.dashed || !!e.style?.dash, u = xt(e, e.points), d = r ? r(u) : St(u);
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: `translate3d(${a.x}px, ${a.y}px, 0)`,
1341
- willChange: "transform",
1358
+ transform: vt(o, a),
1342
1359
  pointerEvents: "none"
1343
1360
  },
1344
- children: [!!s && /* @__PURE__ */ S("div", {
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: `scale(${gt}) translateY(calc(-100% - ${_t}px))`,
1353
- transformOrigin: "left top",
1354
- ...Z
1369
+ transform: `translateY(calc(-100% - ${gt}px))`,
1370
+ ..._t
1355
1371
  },
1356
- children: [!n && /* @__PURE__ */ x(Ct, {
1357
- color: c,
1358
- striped: l
1359
- }), /* @__PURE__ */ x("span", { children: s })]
1360
- }), !o && !!d && /* @__PURE__ */ x("div", {
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
- transformOrigin: "left top",
1368
- willChange: "transform",
1369
- ...Z
1382
+ transform: yt(o, a),
1383
+ ..._t
1370
1384
  },
1371
- children: d
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 Tt = "AIVEX_SHAPE_EDITOR:", Et = 1, Dt = new Set(Object.values(R)), Ot = null, kt = "unavailable", At = 0;
1379
- function jt(e) {
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 Mt(e) {
1398
+ function Nt(e) {
1385
1399
  if (!e || typeof e != "object") return !1;
1386
1400
  let t = e;
1387
- return typeof t.type == "string" && Dt.has(t.type) && Array.isArray(t.points) && t.points.length > 0 && t.points.every(jt);
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 Nt(e, t, n) {
1403
+ function Pt(e, t, n) {
1390
1404
  return {
1391
1405
  kind: "aivex-shape-editor",
1392
- version: Et,
1406
+ version: Ot,
1393
1407
  scope: n,
1394
1408
  documentId: t,
1395
1409
  shapes: e
1396
1410
  };
1397
1411
  }
1398
- function Pt(e) {
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
- if (!e.startsWith(Tt)) return null;
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 !== Et || !Array.isArray(t.shapes) || t.shapes.length === 0 || !t.shapes.every(Mt) || t.scope !== void 0 && typeof t.scope != "string" || t.documentId !== void 0 && typeof t.documentId != "string" ? null : t;
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 Q(e) {
1416
- Ot = e;
1417
- let t = ++At;
1429
+ function Lt(e) {
1430
+ At = e;
1431
+ let t = ++jt;
1418
1432
  if (typeof navigator > "u" || !navigator.clipboard?.writeText) {
1419
- kt = "unavailable";
1433
+ Q = "unavailable";
1420
1434
  return;
1421
1435
  }
1422
1436
  let n;
1423
1437
  try {
1424
- n = Ft(e);
1438
+ n = It(e);
1425
1439
  } catch {
1426
- kt = "unavailable";
1440
+ Q = "unavailable";
1427
1441
  return;
1428
1442
  }
1429
- kt = "pending", navigator.clipboard.writeText(n).then(() => {
1430
- t === At && (kt = "written");
1443
+ Q = "pending", navigator.clipboard.writeText(n).then(() => {
1444
+ t === jt && (Q = "written");
1431
1445
  }, () => {
1432
- t === At && (kt = "unavailable");
1446
+ t === jt && (Q = "unavailable");
1433
1447
  });
1434
1448
  }
1435
- function Lt(e, t) {
1449
+ function Rt(e, t) {
1436
1450
  return !!e && e.scope === t;
1437
1451
  }
1438
- function Rt(e) {
1439
- return Lt(Ot, e) || typeof navigator < "u" && typeof navigator.clipboard?.readText == "function";
1452
+ function zt(e) {
1453
+ return Rt(At, e) || typeof navigator < "u" && typeof navigator.clipboard?.readText == "function";
1440
1454
  }
1441
- async function zt(e) {
1442
- let t = Lt(Ot, e) ? Ot : null;
1443
- if (t && kt !== "written") return 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 = It(await navigator.clipboard.readText());
1446
- return t?.scope === e ? (Ot = t, t) : null;
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 Bt(e, t, n) {
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 Vt = new Set([
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
- ]), Ht = {
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
- }, Ut = [
1492
+ }, Wt = [
1479
1493
  "ew-resize",
1480
1494
  "nwse-resize",
1481
1495
  "ns-resize",
1482
1496
  "nesw-resize"
1483
- ], Wt = "grab-unselected", Gt = new Set([
1497
+ ], Gt = "grab-unselected", Kt = new Set([
1484
1498
  q.RECTANGLE,
1485
1499
  q.ROTATED_RECTANGLE,
1486
1500
  q.CIRCLE
1487
1501
  ]);
1488
- function Kt(e, t = 0) {
1489
- let n = ((Ht[e] + t * 180 / Math.PI) % 180 + 180) % 180;
1490
- return Ut[Math.round(n / 45) % 4];
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 qt({ tool: e, externalToolCursor: t, isSpacePressed: n, isPolygonDrawing: r }) {
1493
- return n ? "grab" : t || (e === q.SELECT ? "default" : Vt.has(e) ? r ? "default" : "crosshair" : "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 Jt({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode: r, rendererCursorHint: i, isPolygonDrawing: a }) {
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 : Gt.has(e) && i && i !== "grab-unselected" ? i : qt({
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 Yt(e, t) {
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 Xt = (e) => [
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 Zt(e, t) {
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 Qt(e, t, n) {
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 $t(e, t, n) {
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(...Qt(s, c, e));
1557
- if (n) for (let e of n) l.push(...Qt(s, c, e));
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 = Zt(m, o) ? m : h, _ = g === m ? h : m;
1572
- t.some((e) => e !== o && Zt(_, e)) || n && !n.some((e) => Zt(g, e)) || i.push([a(s, c, r), a(s, c, u)]);
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 en(e) {
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 tn(e, t, n, r) {
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) Yt(e, n.points), e.fill();
1619
+ for (let n of t.zones) Xt(e, n.points), e.fill();
1606
1620
  }
1607
1621
  e.restore();
1608
1622
  }
1609
- function nn(e) {
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 rn(e) {
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 an = {
1635
+ var on = {
1622
1636
  color: "#000000",
1623
1637
  opacity: .5
1624
- }, on = {
1638
+ }, sn = {
1625
1639
  color: "#ffffff",
1626
1640
  opacity: 1,
1627
1641
  width: 2,
1628
1642
  dash: [6, 6],
1629
1643
  underlayColor: "#000000"
1630
- }, sn = {
1644
+ }, cn = {
1631
1645
  color: "#dc2626",
1632
1646
  opacity: .8,
1633
1647
  width: 2,
1634
1648
  dash: [6, 6],
1635
1649
  underlayColor: "#000000"
1636
- }, cn = (e, t, n) => {
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 = en(a), s = {
1645
- ...an,
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
- ...on,
1673
+ ...sn,
1660
1674
  ...c?.visibleStyle
1661
1675
  },
1662
1676
  occluded: {
1663
- ...sn,
1677
+ ...cn,
1664
1678
  ...c?.occludedStyle
1665
1679
  }
1666
- }, u = i.map(Xt), d = a.map(Xt), f = r.map((e) => e.points);
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: rn(u),
1673
- occludedOutline: rn(f),
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: [...$t(u, [...u, ...f], null), ...$t(f, f, d)],
1694
+ visibleOutline: [...en(u, [...u, ...f], null), ...en(f, f, d)],
1681
1695
  occludedOutline: [],
1682
1696
  outlineStyles: l
1683
1697
  };
1684
- }, ln = .3, un = .05;
1685
- function dn(e) {
1698
+ }, un = .3, dn = .05;
1699
+ function fn(e) {
1686
1700
  return 1 - (1 - e) ** 3;
1687
1701
  }
1688
- function fn(e) {
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 pn(e, t) {
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 mn(e) {
1729
+ function hn(e) {
1716
1730
  if (!e.length) return null;
1717
- let t = e.map((e) => pn(e.type, e.points)).filter((e) => e !== null);
1718
- return t.length ? fn(U(t.flatMap((e) => [{
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 hn(e, t, n, r = {}) {
1727
- let { containerRatio: i = ln, minScale: a = un, maxScale: o = 20 } = r;
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 gn(e, t, n, r = 80) {
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(un, Math.min(20, Math.min((t - r) / i, (n - r) / a))), s = (e.minX + e.maxX) / 2, c = (e.minY + e.maxY) / 2;
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 _n(e, t, n, r = 300) {
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 = dn(c);
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 vn(e) {
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 yn({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistantRef: i }) {
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 bn(e, t, n) {
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 xn(e, t = 1.5) {
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 = bn(e[t], e[0], e[a]);
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 Sn = 4096, Cn = 4;
2239
- function wn(e) {
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 Tn(e, t, n) {
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 En(e) {
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 Dn(e, t, n, r, i) {
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 On(e, t, n) {
2266
- let r = Tn(e, t, n), i = [];
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 = An(En(Dn(r, t, n, e, a)), t, n);
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 kn(e, t, n, r, i) {
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 An(e, t, n) {
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 (kn(e, t, n, o, a)) {
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 (kn(e, t, n, d, f)) {
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 jn(e, t) {
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 Mn(e) {
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 Nn(e) {
2354
- return e.map(Mn).filter((e) => !!e && e.length >= 3);
2367
+ function Pn(e) {
2368
+ return e.map(Nn).filter((e) => !!e && e.length >= 3);
2355
2369
  }
2356
- function Pn(e, t, n = []) {
2370
+ function Fn(e, t, n = []) {
2357
2371
  if (t <= 0 || !e.length && !n.length) return null;
2358
- let r = jn(e, n);
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, Sn / Math.max(o, s, 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 Fn(e, t = 1.5) {
2400
- let { canvas: n, ox: r, oy: i, scale: a } = e, o = On(n.getContext("2d").getImageData(0, 0, n.width, n.height).data, n.width, n.height);
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 = xn(n, t), i = r.length >= 3 ? r : n;
2408
- i.length >= 3 && wn(i) >= Cn && c.push(i);
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 In(e, t) {
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 Ln(e) {
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 Rn(e, t) {
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 zn(e) {
2443
+ function Bn(e) {
2430
2444
  return e.map((e) => ({ ...e }));
2431
2445
  }
2432
- function Bn(e, t) {
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 Vn = 10;
2438
- function Hn(e, t) {
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 Un({ 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 }) {
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 && Hn(n, t) || (_.current = t, p.current?.(t));
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 = Pn(e, a.current, E.current);
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: zn(r),
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 = Ln(e), n = O.current, r = k.current, i = n[r];
2522
- i && Rn(i, t) || (O.current = [...n.slice(0, r + 1), t], k.current += 1, z());
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 && Bn(r, e) || (x.current = [...t.slice(0, n + 1), zn(e)], S.current += 1);
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(() => zn(v.current), []), le = w(() => v.current.length > 0, []), ue = w((t, n) => {
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: zn(n),
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 = Ln(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 = Ln(O.current[k.current]), B(), z(), !0), [z, B]), xe = w(() => S.current <= 0 ? !1 : (--S.current, v.current = zn(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 = zn(x.current[S.current]), b.current = /* @__PURE__ */ new Set(), B(), z(), !0), [z, B]), Ce = w(() => {
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 = Nn(r);
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: zn(v.current),
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 = Pn(e, a.current, t);
2618
+ let l = Fn(e, a.current, t);
2605
2619
  if (!l) return V(), !1;
2606
- let u = Fn(l, o.current);
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) => wn(t) - wn(e));
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 = xn(t, o.current);
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 = Vn / (t.viewport.scale || 1);
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: zn(v.current),
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 Wn(e, t) {
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 Gn(e, t) {
2795
+ function Kn(e, t) {
2782
2796
  switch (t.type) {
2783
- case "CREATE": return Wn(e, [...e.shapes, ...t.shapes]);
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 Wn(e, e.shapes.map((e) => n.get(e.id) ?? e));
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 Wn(e, e.shapes.filter((e) => !n.has(e.id)));
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 Wn(e, [...e.shapes.filter((e) => !n.has(e.id)), ...t.shapes]);
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 : Wn(e, t.edge === "front" ? [...i, ...r] : [...r, ...i]);
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 Kn(e) {
2819
- let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = A(Gn, {
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 = Gn(o.current, e), a(e);
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 qn = {
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
- }, Jn = {
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 Yn(e) {
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] : $[t] ? $[t] : Jn[e.key] ? Jn[e.key] : null;
2962
+ return r ? r[1] : Yn[t] ? Yn[t] : Xn[e.key] ? Xn[e.key] : null;
2949
2963
  }
2950
- function Xn(e) {
2951
- let t = Yn(e);
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 Zn(e) {
2970
+ function $n(e) {
2957
2971
  let t = /* @__PURE__ */ new Map();
2958
- for (let n of Object.keys(qn)) {
2959
- let r = e?.[n], i = r === void 0 ? qn[n] : r === null ? [] : Array.isArray(r) ? r : [r];
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 Qn = {
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 $n(e) {
2973
- let { spaceRef: t } = e, n = k(() => Zn(e.keymap), [e.keymap]), r = j(e);
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 = Qn[n.key];
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 = Xn(n);
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 er(e, t) {
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 tr(e) {
3011
- let t = await er(e, { crossOrigin: !0 });
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,11 +3035,51 @@ async function tr(e) {
3021
3035
  } catch {
3022
3036
  return null;
3023
3037
  }
3024
- return er(e, { crossOrigin: !0 });
3038
+ return nr(e, { crossOrigin: !0 });
3039
+ }
3040
+ async function ir(e) {
3041
+ for (let t of ["default", "reload"]) try {
3042
+ let n = await fetch(e, {
3043
+ mode: "cors",
3044
+ credentials: "omit",
3045
+ cache: t
3046
+ });
3047
+ return n.ok ? await n.blob() : null;
3048
+ } catch {}
3049
+ return null;
3050
+ }
3051
+ async function ar(e) {
3052
+ let t = await ir(e);
3053
+ if (t) try {
3054
+ let e = await createImageBitmap(t);
3055
+ return {
3056
+ source: e,
3057
+ width: e.width,
3058
+ height: e.height,
3059
+ release: () => e.close()
3060
+ };
3061
+ } catch {}
3062
+ let n = await rr(e);
3063
+ return n ? {
3064
+ source: n,
3065
+ width: n.naturalWidth,
3066
+ height: n.naturalHeight,
3067
+ release: () => {}
3068
+ } : null;
3069
+ }
3070
+ var or = 2, sr = 0, cr = [];
3071
+ async function lr(e) {
3072
+ sr < or ? sr += 1 : await new Promise((e) => cr.push(e));
3073
+ try {
3074
+ return await e();
3075
+ } finally {
3076
+ let e = cr.shift();
3077
+ e ? e() : --sr;
3078
+ }
3025
3079
  }
3026
3080
  //#endregion
3027
3081
  //#region src/components/ShapeEditor/_model/imageDiagnosis.ts
3028
- function nr(e) {
3082
+ function ur(e) {
3029
3083
  return new Promise((t) => {
3030
3084
  let n = null, r = !1, i = () => {
3031
3085
  r || (r = !0, clearTimeout(o), document.removeEventListener("securitypolicyviolation", a), t(n));
@@ -3033,29 +3087,29 @@ function nr(e) {
3033
3087
  let r = t.effectiveDirective ?? t.violatedDirective ?? "";
3034
3088
  r.includes("img-src") && (n = `CSP ${r} blocked ${t.blockedURI || e}`);
3035
3089
  }, o = setTimeout(i, 1e4);
3036
- document.addEventListener("securitypolicyviolation", a), er(e, { crossOrigin: !0 }).then(() => {
3090
+ document.addEventListener("securitypolicyviolation", a), nr(e, { crossOrigin: !0 }).then(() => {
3037
3091
  setTimeout(i, 0);
3038
3092
  });
3039
3093
  });
3040
3094
  }
3041
- var rr = 3e4, ir = 200, ar = /* @__PURE__ */ new Map();
3042
- function or(e) {
3043
- let t = ar.get(e), n = Date.now();
3044
- if (t && n - t.at < rr) return t.result;
3045
- let r = sr(e).catch((t) => (ar.delete(e), {
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), {
3046
3100
  kind: "unknown",
3047
3101
  detail: t instanceof Error ? t.message : String(t)
3048
3102
  }));
3049
- if (ar.set(e, {
3103
+ if (pr.set(e, {
3050
3104
  at: n,
3051
3105
  result: r
3052
- }), ar.size > ir) {
3053
- let e = ar.keys().next().value;
3054
- e !== void 0 && ar.delete(e);
3106
+ }), pr.size > fr) {
3107
+ let e = pr.keys().next().value;
3108
+ e !== void 0 && pr.delete(e);
3055
3109
  }
3056
3110
  return r;
3057
3111
  }
3058
- async function sr(e) {
3112
+ async function hr(e) {
3059
3113
  let t = e;
3060
3114
  try {
3061
3115
  t = new URL(e, location.href).origin;
@@ -3098,7 +3152,7 @@ async function sr(e) {
3098
3152
  kind: "unexpected-content",
3099
3153
  detail: `HTTP ${r} (${t})${n.redirected ? " via redirect" : ""}`
3100
3154
  };
3101
- let i = await nr(e);
3155
+ let i = await ur(e);
3102
3156
  return i ? {
3103
3157
  kind: "csp-img",
3104
3158
  detail: i
@@ -3135,7 +3189,7 @@ async function sr(e) {
3135
3189
  detail: `HTTP ${r}`
3136
3190
  };
3137
3191
  }
3138
- function cr() {
3192
+ function gr() {
3139
3193
  try {
3140
3194
  let e = document.createElement("canvas");
3141
3195
  return !!(e.getContext("webgl2") ?? e.getContext("webgl"));
@@ -3143,12 +3197,12 @@ function cr() {
3143
3197
  return !1;
3144
3198
  }
3145
3199
  }
3146
- function lr(e) {
3200
+ function _r(e) {
3147
3201
  let t = e instanceof Error ? e.message : String(e);
3148
3202
  return /unsafe-eval/i.test(t) ? {
3149
3203
  kind: "csp-eval",
3150
3204
  detail: t
3151
- } : cr() ? {
3205
+ } : gr() ? {
3152
3206
  kind: "renderer-init",
3153
3207
  detail: t || "renderer init failed"
3154
3208
  } : {
@@ -3158,8 +3212,8 @@ function lr(e) {
3158
3212
  }
3159
3213
  //#endregion
3160
3214
  //#region src/components/ShapeEditor/_model/imageTiles.ts
3161
- var ur = 4e3;
3162
- function dr(e, t, n = ur) {
3215
+ var vr = 4e3;
3216
+ function yr(e, t, n = vr) {
3163
3217
  if (e <= 0 || t <= 0) return [];
3164
3218
  let r = Math.ceil(e / n), i = Math.ceil(t / n);
3165
3219
  return Array.from({ length: i }, (a, o) => Array.from({ length: r }, (a, s) => {
@@ -3174,7 +3228,7 @@ function dr(e, t, n = ur) {
3174
3228
  };
3175
3229
  })).flat();
3176
3230
  }
3177
- function fr(e, t) {
3231
+ function br(e, t) {
3178
3232
  let n = document.createElement("canvas");
3179
3233
  n.width = t.width, n.height = t.height;
3180
3234
  let r = n.getContext("2d");
@@ -3182,7 +3236,7 @@ function fr(e, t) {
3182
3236
  }
3183
3237
  //#endregion
3184
3238
  //#region src/components/ShapeEditor/_model/konva.ts
3185
- function pr(e, t, n) {
3239
+ function xr(e, t, n) {
3186
3240
  if (t === R.POINT) {
3187
3241
  e.setAttrs({
3188
3242
  x: n[0].x,
@@ -3218,17 +3272,17 @@ function pr(e, t, n) {
3218
3272
  }
3219
3273
  //#endregion
3220
3274
  //#region src/components/ShapeEditor/_model/pinIcon.ts
3221
- var mr = "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", hr = "#ffffff", gr = 1.5;
3222
- function _r(e) {
3223
- return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${mr}" fill="${e}" stroke="${hr}" stroke-width="${gr}"/></svg>`;
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>`;
3224
3278
  }
3225
3279
  //#endregion
3226
3280
  //#region src/components/ShapeEditor/_renderers/transformSession.ts
3227
- var vr = Math.PI / 12;
3228
- function yr(e, t) {
3281
+ var Er = Math.PI / 12;
3282
+ function Dr(e, t) {
3229
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;
3230
3284
  }
3231
- function br(e, t, n) {
3285
+ function Or(e, t, n) {
3232
3286
  if (e.kind === "resize") {
3233
3287
  let r = n ? e.box : ue(e.anchor, e.box, t.x, t.y);
3234
3288
  return {
@@ -3259,7 +3313,7 @@ function br(e, t, n) {
3259
3313
  }
3260
3314
  if (e.kind === "rotate") {
3261
3315
  let n = Math.atan2(t.y - e.center.y, t.x - e.center.x) - e.startAngle;
3262
- return e.shiftKey && (n = Math.round(n / vr) * vr), {
3316
+ return e.shiftKey && (n = Math.round(n / Er) * Er), {
3263
3317
  updates: [{
3264
3318
  id: e.id,
3265
3319
  points: e.points.map((t) => fe(t, e.center, n))
@@ -3279,13 +3333,13 @@ function br(e, t, n) {
3279
3333
  box: U(a)
3280
3334
  };
3281
3335
  }
3282
- function xr(e, t) {
3336
+ function kr(e, t) {
3283
3337
  return t.kind === "move" || t.kind === "vertex" ? t.start : t.kind === "rotate" ? {
3284
3338
  x: t.center.x + Math.cos(t.startAngle),
3285
3339
  y: t.center.y + Math.sin(t.startAngle)
3286
- } : yr(e, t) ? Ce(t.shapes[0].points)[H.indexOf(t.anchor)] : le(t.anchor, t.box);
3340
+ } : Dr(e, t) ? Ce(t.shapes[0].points)[H.indexOf(t.anchor)] : le(t.anchor, t.box);
3287
3341
  }
3288
- function Sr(e, t, n) {
3342
+ function Ar(e, t, n) {
3289
3343
  let r = e.filter((e) => t.includes(e.id) && oe(e)).map((e) => ({
3290
3344
  id: e.id,
3291
3345
  points: e.points
@@ -3297,23 +3351,23 @@ function Sr(e, t, n) {
3297
3351
  shapes: r
3298
3352
  } : null;
3299
3353
  }
3300
- function Cr(e) {
3354
+ function jr(e) {
3301
3355
  return e.map((e) => ({
3302
3356
  ...e,
3303
3357
  points: e.points.map((e) => ({ ...e }))
3304
3358
  }));
3305
3359
  }
3306
- function wr(e, t) {
3360
+ function Mr(e, t) {
3307
3361
  let n = new Set(t);
3308
3362
  return e.filter((e) => n.has(e.id) && ae(e));
3309
3363
  }
3310
- function Tr(e, t) {
3364
+ function Nr(e, t) {
3311
3365
  return e.filter((e) => B(e) && Fe(e, t)).map((e) => e.id);
3312
3366
  }
3313
- function Er(e, t, n) {
3367
+ function Pr(e, t, n) {
3314
3368
  return (e ? at(e, { strokeWidth: t }).pointRadius : 5) / (n || 1);
3315
3369
  }
3316
- function Dr(e, t) {
3370
+ function Fr(e, t) {
3317
3371
  return {
3318
3372
  minX: e.x - t,
3319
3373
  minY: e.y - t,
@@ -3321,9 +3375,9 @@ function Dr(e, t) {
3321
3375
  maxY: e.y + t
3322
3376
  };
3323
3377
  }
3324
- function Or(e, t, n) {
3378
+ function Ir(e, t, n) {
3325
3379
  if (e.type === R.ROTATED_RECTANGLE) return t;
3326
- let r = e.type === R.POINT ? Dr(t[0], n) : U(t);
3380
+ let r = e.type === R.POINT ? Fr(t[0], n) : U(t);
3327
3381
  return pe([{
3328
3382
  x: r.minX,
3329
3383
  y: r.minY
@@ -3332,17 +3386,17 @@ function Or(e, t, n) {
3332
3386
  y: r.maxY
3333
3387
  }]);
3334
3388
  }
3335
- function kr(e) {
3389
+ function Lr(e) {
3336
3390
  return 24 / (e || 1);
3337
3391
  }
3338
- function Ar(e, t) {
3392
+ function Rr(e, t) {
3339
3393
  return Math.atan2(t.y - e.y, t.x - e.x);
3340
3394
  }
3341
3395
  //#endregion
3342
3396
  //#region src/components/ShapeEditor/_renderers/KonvaRenderer.ts
3343
- var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3397
+ var zr = 2, Br = "#1e88e5", Vr = "#669def", Hr = class {
3344
3398
  constructor(e, t) {
3345
- 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 = jr, 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 = {
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 = {
3346
3400
  x: 0,
3347
3401
  y: 0
3348
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({
@@ -3437,7 +3491,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3437
3491
  }
3438
3492
  bindShapeCursor(e, t) {
3439
3493
  if (!oe(t)) return this.bindCursor(e, "default");
3440
- this.bindCursor(e, () => this.selected.includes(t.id) ? "grab" : Wt);
3494
+ this.bindCursor(e, () => this.selected.includes(t.id) ? "grab" : Gt);
3441
3495
  }
3442
3496
  bindCursor(e, t) {
3443
3497
  let n = () => {
@@ -3460,7 +3514,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3460
3514
  return this.world.getAbsoluteTransform().point(e);
3461
3515
  }
3462
3516
  async setImage(e, t, n) {
3463
- let r = ++this.imageLoadToken, i = await tr(e);
3517
+ let r = ++this.imageLoadToken, i = await rr(e);
3464
3518
  if (r !== this.imageLoadToken) return !0;
3465
3519
  if (!i) return this.imageWidth ||= 800, this.imageHeight ||= 600, !1;
3466
3520
  this.imageWidth = t?.width ?? i.naturalWidth, this.imageHeight = t?.height ?? i.naturalHeight;
@@ -3469,7 +3523,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3469
3523
  x: a / i.naturalWidth,
3470
3524
  y: o / i.naturalHeight
3471
3525
  }), this.bgGroup.destroyChildren();
3472
- for (let e of dr(i.naturalWidth, i.naturalHeight)) this.bgGroup.add(new N.Image({
3526
+ for (let e of yr(i.naturalWidth, i.naturalHeight)) this.bgGroup.add(new N.Image({
3473
3527
  image: i,
3474
3528
  x: e.x,
3475
3529
  y: e.y,
@@ -3504,7 +3558,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3504
3558
  }
3505
3559
  setOverlays(e, t) {
3506
3560
  if (this.setRegionOverlay(e), this.dimOverlayGroup.destroyChildren(), t && this.imageWidth) {
3507
- let e = nn(this.host);
3561
+ let e = rn(this.host);
3508
3562
  this.dimOverlayGroup.add(new N.Rect({
3509
3563
  x: 0,
3510
3564
  y: 0,
@@ -3523,7 +3577,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3523
3577
  if (this.regionOverlayGroup.add(new N.Shape({
3524
3578
  listening: !1,
3525
3579
  sceneFunc: (r) => {
3526
- tn(r._context, e, t, n);
3580
+ nn(r._context, e, t, n);
3527
3581
  }
3528
3582
  })), e.outlineStyles) {
3529
3583
  let t = (e, t) => {
@@ -3579,7 +3633,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3579
3633
  let e = this.lastPreviewPoly;
3580
3634
  e && this.previewPoly(e.points, e.cursor, e.style, e.closed, e.selectedPointIndices, e.showVertices);
3581
3635
  }
3582
- this.activeDrag ? this.dragTransform(this.lastDragImg ?? xr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.layer.batchDraw(), this.cb.onViewportChange?.();
3636
+ this.activeDrag ? this.dragTransform(this.lastDragImg ?? kr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.layer.batchDraw(), this.cb.onViewportChange?.();
3583
3637
  }
3584
3638
  fit() {
3585
3639
  if (!this.imageWidth || !this.imageHeight) return;
@@ -3608,7 +3662,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3608
3662
  });
3609
3663
  }
3610
3664
  setShapes(e, t) {
3611
- if (this.shapes = Cr(e), this.selected = t, !this.activeDrag) {
3665
+ if (this.shapes = jr(e), this.selected = t, !this.activeDrag) {
3612
3666
  this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
3613
3667
  for (let t of se(e).filter(z)) {
3614
3668
  let e = this.makeNode(t), n = at(t, { strokeWidth: this.strokeSize });
@@ -3654,7 +3708,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3654
3708
  if (t === R.POINT) {
3655
3709
  let t = 1 / (this.world.scaleX() || 1), a = new N.Path({
3656
3710
  id: e.id,
3657
- data: mr,
3711
+ data: Sr,
3658
3712
  x: n[0].x,
3659
3713
  y: n[0].y,
3660
3714
  offsetX: 16 / 2,
@@ -3662,8 +3716,8 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3662
3716
  scaleX: t,
3663
3717
  scaleY: t,
3664
3718
  fill: r.color,
3665
- stroke: hr,
3666
- strokeWidth: gr,
3719
+ stroke: Cr,
3720
+ strokeWidth: wr,
3667
3721
  strokeScaleEnabled: !1,
3668
3722
  shadowColor: "#000",
3669
3723
  shadowBlur: 2,
@@ -3709,13 +3763,13 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3709
3763
  liveUpdateShape(e, t) {
3710
3764
  let n = this.nodes.get(e), r = this.shapes.find((t) => t.id === e);
3711
3765
  if (n && r) {
3712
- pr(n, r.type, t);
3766
+ xr(n, r.type, t);
3713
3767
  let i = this.altNodes.get(e);
3714
- i && pr(i, r.type, t), r.type === R.POINT && n instanceof N.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
3768
+ i && xr(i, r.type, t), r.type === R.POINT && n instanceof N.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
3715
3769
  }
3716
3770
  }
3717
3771
  pointRadius(e) {
3718
- return Er(e, this.strokeSize, this.world.scaleX() || 1);
3772
+ return Pr(e, this.strokeSize, this.world.scaleX() || 1);
3719
3773
  }
3720
3774
  scaledDash(e) {
3721
3775
  return e;
@@ -3735,7 +3789,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3735
3789
  }
3736
3790
  }
3737
3791
  shapesIntersecting(e) {
3738
- return Tr(this.shapes, e);
3792
+ return Nr(this.shapes, e);
3739
3793
  }
3740
3794
  drawSelectionBorders() {
3741
3795
  let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && B(t)) : [];
@@ -3744,7 +3798,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3744
3798
  this.selectionBorders = t.map(() => {
3745
3799
  let e = new N.Line({
3746
3800
  closed: !0,
3747
- stroke: Nr,
3801
+ stroke: Vr,
3748
3802
  strokeWidth: 1.5,
3749
3803
  strokeScaleEnabled: !1,
3750
3804
  listening: !1
@@ -3765,7 +3819,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3765
3819
  }
3766
3820
  }
3767
3821
  selectionOutlinePoints(e, t) {
3768
- return Or(e, t, this.pointRadius(e));
3822
+ return Ir(e, t, this.pointRadius(e));
3769
3823
  }
3770
3824
  clearPreview() {
3771
3825
  this.lastPreviewPoly = null, this.previewGroup.destroyChildren(), this.layer.batchDraw();
@@ -3828,8 +3882,8 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3828
3882
  x: n.x,
3829
3883
  y: n.y,
3830
3884
  radius: (r ? 6 : 5) / l,
3831
- fill: r ? Mr : "#ffffff",
3832
- stroke: r ? "#ffffff" : Mr,
3885
+ fill: r ? Br : "#ffffff",
3886
+ stroke: r ? "#ffffff" : Br,
3833
3887
  strokeWidth: 1.5,
3834
3888
  strokeScaleEnabled: !1,
3835
3889
  listening: !1
@@ -3839,7 +3893,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3839
3893
  }
3840
3894
  previewScalarMask(e, t) {
3841
3895
  this.previewGroup.destroyChildren();
3842
- let n = In(e, t.length === 7 ? `${t}99` : t);
3896
+ let n = Ln(e, t.length === 7 ? `${t}99` : t);
3843
3897
  this.previewGroup.add(new N.Image({
3844
3898
  image: n,
3845
3899
  x: e.ox,
@@ -3883,14 +3937,14 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3883
3937
  setTransformerOutlinePoints(e) {
3884
3938
  e.length < 2 || (this.transformerOutline || (this.transformerOutline = new N.Line({
3885
3939
  closed: !0,
3886
- stroke: Mr,
3940
+ stroke: Br,
3887
3941
  strokeWidth: 1,
3888
3942
  strokeScaleEnabled: !1,
3889
3943
  listening: !1
3890
3944
  }), this.selGroup.add(this.transformerOutline)), this.transformerOutline.points(e.flatMap((e) => [e.x, e.y])));
3891
3945
  }
3892
3946
  rotationHandleGap() {
3893
- return kr(this.viewport.scale);
3947
+ return Lr(this.viewport.scale);
3894
3948
  }
3895
3949
  rotationHandleScreenPoint(e) {
3896
3950
  return this.imgToScreen(we(e, this.rotationHandleGap()));
@@ -3909,7 +3963,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3909
3963
  n.x,
3910
3964
  n.y
3911
3965
  ],
3912
- stroke: Mr,
3966
+ stroke: Br,
3913
3967
  strokeWidth: 1,
3914
3968
  listening: !1
3915
3969
  }), this.handleGroup.add(this.rotLineNode));
@@ -3924,7 +3978,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3924
3978
  }), e.rotation(n * 180 / Math.PI);
3925
3979
  }
3926
3980
  orientedHandleAngle(e) {
3927
- return Ar(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
3981
+ return Rr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
3928
3982
  }
3929
3983
  repositionOrientedHandles(e) {
3930
3984
  let t = this.orientedHandleAngle(e);
@@ -3946,7 +4000,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3946
4000
  for (let e of this.vertexNodes) e.destroy();
3947
4001
  for (let e of this.midNodes) e.destroy();
3948
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;
3949
- let e = wr(this.shapes, this.selected);
4003
+ let e = Mr(this.shapes, this.selected);
3950
4004
  if (!e.length || e.length === 1 && e[0].type === R.POINT) return;
3951
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));
3952
4006
  r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
@@ -3961,12 +4015,12 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3961
4015
  offsetY: 4,
3962
4016
  rotation: a * 180 / Math.PI,
3963
4017
  fill: "#ffffff",
3964
- stroke: Mr,
4018
+ stroke: Br,
3965
4019
  strokeWidth: 1
3966
- }), r = Kt(e, a);
4020
+ }), r = qt(e, a);
3967
4021
  this.bindCursor(n, r), n.on("mousedown", (t) => {
3968
4022
  t.cancelBubble = !0, this.emitCursorHint(r), this.emitInteractionMode("resizing");
3969
- let n = wr(this.shapes, this.selected);
4023
+ let n = Mr(this.shapes, this.selected);
3970
4024
  this.activeDrag = {
3971
4025
  kind: "resize",
3972
4026
  anchor: e,
@@ -3983,7 +4037,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3983
4037
  radius: i * .8,
3984
4038
  fill: "#ffffff",
3985
4039
  opacity: .6,
3986
- stroke: Mr,
4040
+ stroke: Br,
3987
4041
  strokeWidth: 1,
3988
4042
  visible: !1,
3989
4043
  listening: !1
@@ -4043,8 +4097,8 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
4043
4097
  x: a.x,
4044
4098
  y: a.y,
4045
4099
  radius: i,
4046
- fill: o ? Mr : "#ffffff",
4047
- stroke: o ? "#ffffff" : Mr,
4100
+ fill: o ? Br : "#ffffff",
4101
+ stroke: o ? "#ffffff" : Br,
4048
4102
  strokeWidth: Math.max(1.5, i * .3)
4049
4103
  });
4050
4104
  this.bindCursor(s, "pointer"), s.on("mousedown", (t) => {
@@ -4069,7 +4123,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
4069
4123
  y: r.y,
4070
4124
  radius: 6,
4071
4125
  fill: "#ffffff",
4072
- stroke: Mr,
4126
+ stroke: Br,
4073
4127
  strokeWidth: 1.5
4074
4128
  });
4075
4129
  this.bindCursor(i, "grab"), i.on("mousedown", (e) => {
@@ -4088,7 +4142,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
4088
4142
  this.layer.batchDraw();
4089
4143
  }
4090
4144
  beginMove(e, t) {
4091
- let n = Sr(this.shapes, t, e);
4145
+ let n = Ar(this.shapes, t, e);
4092
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));
4093
4147
  }
4094
4148
  repositionHandles(e) {
@@ -4130,7 +4184,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
4130
4184
  let t = this.activeDrag;
4131
4185
  if (!t) return;
4132
4186
  this.applyCursor();
4133
- let n = yr(this.shapes, t), { updates: r, box: i } = br(t, e, n);
4187
+ let n = Dr(this.shapes, t), { updates: r, box: i } = Or(t, e, n);
4134
4188
  for (let e of r) this.liveUpdateShape(e.id, e.points);
4135
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") {
4136
4190
  n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
@@ -4167,18 +4221,18 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
4167
4221
  this.cb.onTransformPreview?.([]), this.drawTransformer();
4168
4222
  return;
4169
4223
  }
4170
- let { updates: n } = br(e, t, yr(this.shapes, e));
4224
+ let { updates: n } = Or(e, t, Dr(this.shapes, e));
4171
4225
  this.commitTransformUpdates(n);
4172
4226
  }
4173
- }, Fr = 2, Ir = 58879, Lr = 6725103;
4174
- function Rr(e) {
4175
- if (!e) return Ir;
4227
+ }, Ur = 2, Wr = 58879, Gr = 6725103;
4228
+ function Kr(e) {
4229
+ if (!e) return Wr;
4176
4230
  let t = e.replace("#", "");
4177
4231
  return Number.parseInt(t.length === 3 ? t.replace(/./g, "$&$&") : t, 16);
4178
4232
  }
4179
- var zr = class {
4233
+ var qr = class {
4180
4234
  constructor(e, t) {
4181
- 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 = ur, 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 = Fr, 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;
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;
4182
4236
  }
4183
4237
  ev(e) {
4184
4238
  return {
@@ -4208,7 +4262,7 @@ var zr = class {
4208
4262
  }
4209
4263
  this.host.appendChild(this.app.canvas);
4210
4264
  let e = this.app.renderer.gl, t = e?.getParameter(e.MAX_TEXTURE_SIZE);
4211
- typeof t == "number" && t > 1 && (this.tileSize = Math.min(ur, 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({
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({
4212
4266
  mask: this.regionDimMaskG,
4213
4267
  inverse: !0
4214
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) => {
@@ -4285,14 +4339,14 @@ var zr = class {
4285
4339
  };
4286
4340
  }
4287
4341
  async setImage(e, t, n) {
4288
- let r = ++this.imageLoadToken, i = await tr(e);
4342
+ let r = ++this.imageLoadToken, i = await rr(e);
4289
4343
  if (this.destroyed || r !== this.imageLoadToken) return !0;
4290
4344
  if (!i) return this.imageWidth ||= t?.width ?? 800, this.imageHeight ||= t?.height ?? 600, !1;
4291
4345
  this.imageWidth = t?.width ?? i.naturalWidth, this.imageHeight = t?.height ?? i.naturalHeight;
4292
4346
  let a = n?.width ?? this.imageWidth, o = n?.height ?? this.imageHeight;
4293
4347
  this.bgLayer.scale.set(a / i.naturalWidth, o / i.naturalHeight), this.clearImageTiles();
4294
- for (let e of dr(i.naturalWidth, i.naturalHeight, this.tileSize)) {
4295
- let t = re.from(fr(i, e));
4348
+ for (let e of yr(i.naturalWidth, i.naturalHeight, this.tileSize)) {
4349
+ let t = re.from(br(i, e));
4296
4350
  t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
4297
4351
  let n = new ne(t);
4298
4352
  n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
@@ -4337,9 +4391,9 @@ var zr = class {
4337
4391
  this.setRegionOverlay(e);
4338
4392
  for (let e of this.dimOverlayLayer.removeChildren()) e.destroy();
4339
4393
  if (t && this.imageWidth) {
4340
- let e = nn(this.host);
4394
+ let e = rn(this.host);
4341
4395
  this.dimOverlayLayer.addChild(new L().rect(0, 0, this.imageWidth, this.imageHeight).fill({
4342
- color: Rr(e.color),
4396
+ color: Kr(e.color),
4343
4397
  alpha: e.opacity
4344
4398
  }));
4345
4399
  }
@@ -4347,7 +4401,7 @@ var zr = class {
4347
4401
  }
4348
4402
  setRegionOverlay(e) {
4349
4403
  if (this.region = e, this.regionDimMaskG.clear(), this.regionDimG.clear(), this.regionZoneMaskG.clear(), this.regionZoneG.clear(), this.regionOutlineG.clear(), !e) return;
4350
- let t = Rr(e.dim.color);
4404
+ let t = Kr(e.dim.color);
4351
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);
4352
4406
  this.regionDimG.rect(0, 0, this.imageWidth, this.imageHeight).fill({
4353
4407
  color: t,
@@ -4368,7 +4422,7 @@ var zr = class {
4368
4422
  }
4369
4423
  applyViewport(e) {
4370
4424
  let t = e.scale !== this.lastAppliedScale;
4371
- 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 ?? xr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.cb.onViewportChange?.();
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?.();
4372
4426
  }
4373
4427
  fit() {
4374
4428
  if (!this.imageWidth || !this.imageHeight) return;
@@ -4404,7 +4458,7 @@ var zr = class {
4404
4458
  });
4405
4459
  }
4406
4460
  setShapes(e, t) {
4407
- this.shapes = Cr(e), this.selected = t, !this.activeDrag && (this.drawShapes(), this.drawSelectionBorders(), this.drawTransformer());
4461
+ this.shapes = jr(e), this.selected = t, !this.activeDrag && (this.drawShapes(), this.drawSelectionBorders(), this.drawTransformer());
4408
4462
  }
4409
4463
  setSelection(e) {
4410
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());
@@ -4427,10 +4481,10 @@ var zr = class {
4427
4481
  this.handleLayer.interactiveChildren = !e;
4428
4482
  }
4429
4483
  strokeW(e) {
4430
- return (e ? at(e, { strokeWidth: this.strokeSize }).strokeWidth : Fr) / this.world.scale.x;
4484
+ return (e ? at(e, { strokeWidth: this.strokeSize }).strokeWidth : Ur) / this.world.scale.x;
4431
4485
  }
4432
4486
  pointRadius(e) {
4433
- return Er(e, this.strokeSize, this.world.scale.x);
4487
+ return Pr(e, this.strokeSize, this.world.scale.x);
4434
4488
  }
4435
4489
  dashForShape(e) {
4436
4490
  let t = at(e, { strokeWidth: this.strokeSize }).dash;
@@ -4445,7 +4499,7 @@ var zr = class {
4445
4499
  for (let e of se(this.shapes).filter(z)) {
4446
4500
  let t = new L();
4447
4501
  this.paintShape(t, e), t.eventMode = B(e) ? "static" : "none", t.cursor = void 0, B(e) && oe(e) && (t.on("pointerover", () => {
4448
- this.activeDrag || !this.transformEnabled || this.emitCursorHint(this.selected.includes(e.id) ? "grab" : Wt);
4502
+ this.activeDrag || !this.transformEnabled || this.emitCursorHint(this.selected.includes(e.id) ? "grab" : Gt);
4449
4503
  }), t.on("pointerout", () => {
4450
4504
  this.activeDrag || this.emitCursorHint(null);
4451
4505
  })), t.on("pointerdown", (t) => {
@@ -4455,9 +4509,9 @@ var zr = class {
4455
4509
  }
4456
4510
  paintShape(e, t) {
4457
4511
  e.clear();
4458
- let n = at(t, { strokeWidth: this.strokeSize }), r = Rr(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
4512
+ let n = at(t, { strokeWidth: this.strokeSize }), r = Kr(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
4459
4513
  if (t.type === R.POINT) {
4460
- e.svg(_r(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
4514
+ e.svg(Tr(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
4461
4515
  let r = 1 / (this.world.scale.x || 1);
4462
4516
  e.scale.set(r, r), e.alpha = a;
4463
4517
  return;
@@ -4482,7 +4536,7 @@ var zr = class {
4482
4536
  if (o) {
4483
4537
  t.style?.alternateColor && (this.path(e, t), e.stroke({
4484
4538
  width: i,
4485
- color: Rr(t.style.alternateColor),
4539
+ color: Kr(t.style.alternateColor),
4486
4540
  alpha: a
4487
4541
  })), this.dashedStrokeShape(e, t, i, r, a, o);
4488
4542
  return;
@@ -4501,7 +4555,7 @@ var zr = class {
4501
4555
  });
4502
4556
  }
4503
4557
  shapesIntersecting(e) {
4504
- return Tr(this.shapes, e);
4558
+ return Nr(this.shapes, e);
4505
4559
  }
4506
4560
  shapesAt(e) {
4507
4561
  return this.shapes.filter((t) => {
@@ -4538,16 +4592,16 @@ var zr = class {
4538
4592
  }, a = this.strokeW(i);
4539
4593
  r.alternateColor && (this.path(this.previewG, i), this.previewG.stroke({
4540
4594
  width: a,
4541
- color: Rr(r.alternateColor)
4595
+ color: Kr(r.alternateColor)
4542
4596
  }));
4543
4597
  let o = this.dashForShape(i);
4544
4598
  if (o) {
4545
- this.dashedStrokeShape(this.previewG, i, a, Rr(r.color ?? "#00e5ff"), r.opacity ?? 1, o);
4599
+ this.dashedStrokeShape(this.previewG, i, a, Kr(r.color ?? "#00e5ff"), r.opacity ?? 1, o);
4546
4600
  return;
4547
4601
  }
4548
4602
  this.path(this.previewG, i), this.previewG.stroke({
4549
4603
  width: a,
4550
- color: Rr(r.color ?? "#00e5ff"),
4604
+ color: Kr(r.color ?? "#00e5ff"),
4551
4605
  alpha: r.opacity ?? 1
4552
4606
  });
4553
4607
  }
@@ -4569,12 +4623,12 @@ var zr = class {
4569
4623
  }, c = this.strokeW(s);
4570
4624
  n.alternateColor && (this.path(this.previewG, s), this.previewG.stroke({
4571
4625
  width: c,
4572
- color: Rr(n.alternateColor)
4626
+ color: Kr(n.alternateColor)
4573
4627
  }));
4574
4628
  let l = this.dashForShape(s);
4575
- if (l ? this.dashedStrokeShape(this.previewG, s, c, Rr(n.color ?? "#00e5ff"), n.opacity ?? 1, l) : (this.path(this.previewG, s), this.previewG.stroke({
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({
4576
4630
  width: c,
4577
- color: Rr(n.color ?? "#00e5ff"),
4631
+ color: Kr(n.color ?? "#00e5ff"),
4578
4632
  alpha: n.opacity ?? 1
4579
4633
  })), !a) return;
4580
4634
  let u = new Set(i), d = 5 / this.world.scale.x, f = 6 / this.world.scale.x;
@@ -4588,12 +4642,12 @@ var zr = class {
4588
4642
  }
4589
4643
  previewScalarMask(e, t) {
4590
4644
  this.lastPreview = null, this.ensurePreview(), this.previewG.clear();
4591
- let n = In(e, t.length === 7 ? `${t}99` : t);
4645
+ let n = Ln(e, t.length === 7 ? `${t}99` : t);
4592
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;
4593
4647
  }
4594
4648
  previewMarquee(e, t) {
4595
4649
  this.ensurePreview(), this.marqueeG.clear();
4596
- 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 = Rr(nt);
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);
4597
4651
  this.marqueeG.rect(n, r, i, a).fill({
4598
4652
  color: o,
4599
4653
  alpha: rt
@@ -4627,8 +4681,8 @@ var zr = class {
4627
4681
  o.y
4628
4682
  ], !1).stroke({
4629
4683
  width: i,
4630
- color: Rr(r.underlayColor)
4631
- }), this.strokeDashedPolyline(e, [n, o], !1, i, Rr(r.color), r.opacity, a);
4684
+ color: Kr(r.underlayColor)
4685
+ }), this.strokeDashedPolyline(e, [n, o], !1, i, Kr(r.color), r.opacity, a);
4632
4686
  };
4633
4687
  r(this.region.visibleOutline, t.visible), r(this.region.occludedOutline, t.occluded);
4634
4688
  }
@@ -4740,7 +4794,7 @@ var zr = class {
4740
4794
  let r = this.selectionBorderGfx[t];
4741
4795
  r.clear(), r.poly(this.selectionOutlinePoints(e, e.points).flatMap((e) => [e.x, e.y]), !0).stroke({
4742
4796
  width: n,
4743
- color: Lr
4797
+ color: Gr
4744
4798
  });
4745
4799
  });
4746
4800
  }
@@ -4751,12 +4805,12 @@ var zr = class {
4751
4805
  let a = this.selectionBorderGfx[r++];
4752
4806
  a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
4753
4807
  width: n,
4754
- color: Lr
4808
+ color: Gr
4755
4809
  }));
4756
4810
  }
4757
4811
  }
4758
4812
  selectionOutlinePoints(e, t) {
4759
- return Or(e, t, this.pointRadius(e));
4813
+ return Ir(e, t, this.pointRadius(e));
4760
4814
  }
4761
4815
  imgToScreen(e) {
4762
4816
  let t = this.world.toGlobal({
@@ -4785,7 +4839,7 @@ var zr = class {
4785
4839
  }));
4786
4840
  }
4787
4841
  rotationHandleGap() {
4788
- return kr(this.viewport.scale);
4842
+ return Lr(this.viewport.scale);
4789
4843
  }
4790
4844
  rotationHandleScreenPoint(e) {
4791
4845
  return this.imgToScreen(we(e, this.rotationHandleGap()));
@@ -4801,7 +4855,7 @@ var zr = class {
4801
4855
  e.position.set(t.x, t.y), e.rotation = n;
4802
4856
  }
4803
4857
  orientedHandleAngle(e) {
4804
- return Ar(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
4858
+ return Rr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
4805
4859
  }
4806
4860
  drawTransformer() {
4807
4861
  if (this.activeDrag) return;
@@ -4809,7 +4863,7 @@ var zr = class {
4809
4863
  for (let e of this.vertexNodes) e.destroy();
4810
4864
  for (let e of this.midNodes) e.destroy();
4811
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;
4812
- let e = wr(this.shapes, this.selected);
4866
+ let e = Mr(this.shapes, this.selected);
4813
4867
  if (e.length === 0 || e.length === 1 && e[0].type === R.POINT) return;
4814
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));
4815
4869
  r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
@@ -4820,10 +4874,10 @@ var zr = class {
4820
4874
  width: 1,
4821
4875
  color: 2001125
4822
4876
  }), this.layoutResizeHandle(n, t, a), n.eventMode = "static";
4823
- let r = Kt(e, a);
4877
+ let r = qt(e, a);
4824
4878
  this.bindCursor(n, r), n.on("pointerdown", (t) => {
4825
4879
  t.stopPropagation(), this.emitCursorHint(r), this.emitInteractionMode("resizing");
4826
- let n = wr(this.shapes, this.selected);
4880
+ let n = Mr(this.shapes, this.selected);
4827
4881
  this.activeDrag = {
4828
4882
  kind: "resize",
4829
4883
  anchor: e,
@@ -4920,7 +4974,7 @@ var zr = class {
4920
4974
  }
4921
4975
  }
4922
4976
  beginMove(e, t) {
4923
- let n = Sr(this.shapes, t, e);
4977
+ let n = Ar(this.shapes, t, e);
4924
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));
4925
4979
  }
4926
4980
  repositionHandlesForBox(e) {
@@ -4988,7 +5042,7 @@ var zr = class {
4988
5042
  let t = this.activeDrag;
4989
5043
  if (!t) return;
4990
5044
  this.applyCursor();
4991
- let n = yr(this.shapes, t), { updates: r, box: i } = br(t, e, n);
5045
+ let n = Dr(this.shapes, t), { updates: r, box: i } = Or(t, e, n);
4992
5046
  if (t.kind === "move") {
4993
5047
  let n = e.x - t.start.x, r = e.y - t.start.y;
4994
5048
  for (let e of t.shapes) {
@@ -5030,13 +5084,13 @@ var zr = class {
5030
5084
  this.cb.onTransformPreview?.([]), this.drawTransformer();
5031
5085
  return;
5032
5086
  }
5033
- let { updates: n } = br(e, t, yr(this.shapes, e));
5087
+ let { updates: n } = Or(e, t, Dr(this.shapes, e));
5034
5088
  e.kind === "move" && this.resetMoveOffsets(), this.commitTransformUpdates(n);
5035
5089
  }
5036
5090
  };
5037
5091
  //#endregion
5038
5092
  //#region src/components/ShapeEditor/_state/useEngineLifecycle.ts
5039
- function Br({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r }) {
5093
+ function Jr({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r }) {
5040
5094
  if (!r) return e !== null || n !== null ? { kind: "clear" } : { kind: "none" };
5041
5095
  let i = e !== t;
5042
5096
  return !i && n === r ? { kind: "none" } : {
@@ -5044,10 +5098,10 @@ function Br({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r
5044
5098
  docChange: i
5045
5099
  };
5046
5100
  }
5047
- function Vr({ keepZoomOnImageChange: e, viewportSeeded: t }) {
5101
+ function Yr({ keepZoomOnImageChange: e, viewportSeeded: t }) {
5048
5102
  return e && t;
5049
5103
  }
5050
- function Hr({ 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 }) {
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 }) {
5051
5105
  let x = j(i);
5052
5106
  x.current = i;
5053
5107
  let S = j(r);
@@ -5058,12 +5112,12 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
5058
5112
  A.current = b, T(() => {
5059
5113
  let r = t.current;
5060
5114
  if (!r) return;
5061
- let i = !1, a = null, b = null, T = k.current(), j = e === "konva" ? new Pr(r, T) : new zr(r, T);
5115
+ let i = !1, a = null, b = null, T = k.current(), j = e === "konva" ? new Hr(r, T) : new qr(r, T);
5062
5116
  return n.current = j, O.current = !1, (async () => {
5063
5117
  try {
5064
5118
  await j.init();
5065
5119
  } catch (e) {
5066
- i || y("error", lr(e));
5120
+ i || y("error", _r(e));
5067
5121
  return;
5068
5122
  }
5069
5123
  if (i) return;
@@ -5074,7 +5128,7 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
5074
5128
  try {
5075
5129
  n = await j.setImage(e, u.current, d.current);
5076
5130
  } catch (t) {
5077
- !i && x.current === e && y("error", lr(t));
5131
+ !i && x.current === e && y("error", _r(t));
5078
5132
  }
5079
5133
  if (i) return;
5080
5134
  if (n !== null) {
@@ -5085,7 +5139,7 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
5085
5139
  let r = D.current;
5086
5140
  r?.viewport && (r.imageUrl === C.current || o.current.keepZoomOnImageChange) ? j.applyViewport(r.viewport) : j.fit(), O.current = !0, h(), v(!0);
5087
5141
  let a = () => x.current === e;
5088
- n ? a() && y("ready") : or(e).then((e) => {
5142
+ n ? a() && y("ready") : mr(e).then((e) => {
5089
5143
  !i && a() && y("error", e);
5090
5144
  });
5091
5145
  }
@@ -5129,7 +5183,7 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
5129
5183
  }, [e]), T(() => {
5130
5184
  let e = n.current;
5131
5185
  if (!e || !E.current) return;
5132
- let t = Br({
5186
+ let t = Jr({
5133
5187
  currentDocId: w.current,
5134
5188
  documentId: r,
5135
5189
  loadedUrl: C.current,
@@ -5152,7 +5206,7 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
5152
5206
  try {
5153
5207
  i = await e.setImage(s, u.current, d.current);
5154
5208
  } catch (t) {
5155
- !c && n.current === e && y("error", lr(t));
5209
+ !c && n.current === e && y("error", _r(t));
5156
5210
  return;
5157
5211
  }
5158
5212
  if (c || n.current !== e) return;
@@ -5162,7 +5216,7 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
5162
5216
  y("ready");
5163
5217
  return;
5164
5218
  }
5165
- or(s).then((e) => {
5219
+ mr(s).then((e) => {
5166
5220
  c || y("error", e);
5167
5221
  });
5168
5222
  };
@@ -5173,7 +5227,7 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
5173
5227
  w.current = r, g({
5174
5228
  w: e.imageWidth,
5175
5229
  h: e.imageHeight
5176
- }), _(!0), e.setShapes(l.current, f.current), e.setOverlays(o.current.showRegionMask ? p.current : null, m.current), Vr({
5230
+ }), _(!0), e.setShapes(l.current, f.current), e.setOverlays(o.current.showRegionMask ? p.current : null, m.current), Yr({
5177
5231
  keepZoomOnImageChange: o.current.keepZoomOnImageChange,
5178
5232
  viewportSeeded: O.current
5179
5233
  }) || e.fit(), O.current = !0, h(), v(!0), a();
@@ -5184,19 +5238,19 @@ function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
5184
5238
  }
5185
5239
  //#endregion
5186
5240
  //#region src/components/ShapeEditor/_state/useMinimapNavigation.ts
5187
- var Ur = .05, Wr = 20;
5188
- function Gr(e) {
5241
+ var Zr = .05, Qr = 20;
5242
+ function $r(e) {
5189
5243
  let { deltaY: t, deltaX: n, deltaMode: r } = e;
5190
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);
5191
5245
  }
5192
- function Kr(e) {
5246
+ function ei(e) {
5193
5247
  let t = e.currentTarget.getBoundingClientRect();
5194
5248
  return {
5195
5249
  x: e.clientX - t.left,
5196
5250
  y: e.clientY - t.top
5197
5251
  };
5198
5252
  }
5199
- function qr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5253
+ function ti({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5200
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(() => {
5201
5255
  let t = e.current;
5202
5256
  if (!t) return null;
@@ -5234,7 +5288,7 @@ function qr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5234
5288
  let n = e.current, r = d();
5235
5289
  if (!n || !r) return;
5236
5290
  t.preventDefault(), t.stopPropagation();
5237
- let a = Kr(t), o = a.x >= r.x && a.x <= r.x + r.width && a.y >= r.y && a.y <= r.y + r.height ? {
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 ? {
5238
5292
  offsetX: a.x - r.x,
5239
5293
  offsetY: a.y - r.y
5240
5294
  } : {
@@ -5251,7 +5305,7 @@ function qr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5251
5305
  d
5252
5306
  ]), m = w((t) => {
5253
5307
  let n = i.current, r = e.current;
5254
- !n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(Kr(t), r.viewport.scale, n));
5308
+ !n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(ei(t), r.viewport.scale, n));
5255
5309
  }, [f, e]), h = w((e) => {
5256
5310
  let t = i.current;
5257
5311
  !t || t.pointerId !== e.pointerId || (i.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId));
@@ -5259,8 +5313,8 @@ function qr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5259
5313
  let r = e.current;
5260
5314
  if (!r || !n) return;
5261
5315
  t.preventDefault(), t.stopPropagation();
5262
- let i = Gr(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(Ur, Math.min(Wr, s));
5263
- f(Kr(t), c);
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);
5264
5318
  }, [
5265
5319
  f,
5266
5320
  e,
@@ -5297,7 +5351,7 @@ function qr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5297
5351
  }
5298
5352
  //#endregion
5299
5353
  //#region src/components/ShapeEditor/_state/useMinimapSync.ts
5300
- function Jr(e, t, n) {
5354
+ function ni(e, t, n) {
5301
5355
  if (!(!e || !n.length)) {
5302
5356
  if (t.type === R.POINT) {
5303
5357
  e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
@@ -5315,38 +5369,38 @@ function Jr(e, t, n) {
5315
5369
  e.setAttribute("points", n.map((e) => `${e.x},${e.y}`).join(" "));
5316
5370
  }
5317
5371
  }
5318
- function Yr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRectRef: i, minimapSize: a, onViewportChangeRef: o }) {
5319
- let s = j(/* @__PURE__ */ new Map());
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());
5320
5374
  return {
5321
5375
  registerMinimapShape: w((e, t) => {
5322
- t ? s.current.set(e, t) : s.current.delete(e);
5376
+ t ? c.current.set(e, t) : c.current.delete(e);
5323
5377
  }, []),
5324
5378
  applyMinimapPreview: w((e) => {
5325
5379
  let n = t.current.getShapes();
5326
5380
  if (!e.length) {
5327
- for (let e of n) Jr(s.current.get(e.id), e, e.points);
5381
+ for (let e of n) ni(c.current.get(e.id), e, e.points);
5328
5382
  return;
5329
5383
  }
5330
5384
  let r = new Map(n.map((e) => [e.id, e]));
5331
5385
  for (let t of e) {
5332
5386
  let e = r.get(t.id);
5333
- e && Jr(s.current.get(e.id), e, t.points);
5387
+ e && ni(c.current.get(e.id), e, t.points);
5334
5388
  }
5335
5389
  }, [t]),
5336
5390
  syncMinimap: w(() => {
5337
5391
  let t = e.current;
5338
5392
  if (!t?.imageWidth) return;
5339
- let s = t.viewport;
5340
- if (o.current?.(s), n.current) {
5341
- n.current.style.transform = `translate(${s.x}px, ${s.y}px) scale(${s.scale})`;
5342
- let e = 1 / (s.scale || 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);
5343
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}`);
5344
5398
  }
5345
- r.current && (r.current.textContent = `${Math.round(s.scale * 100)}%`);
5346
- let c = i.current;
5347
- if (!c) return;
5348
- let l = Math.min(a / t.imageWidth, a / t.imageHeight), u = (a - t.imageWidth * l) / 2, d = (a - t.imageHeight * l) / 2, { w: f, h: p } = t.screenSize;
5349
- c.style.left = `${-s.x / s.scale * l + u}px`, c.style.top = `${-s.y / s.scale * l + d}px`, c.style.width = `${f / s.scale * l}px`, c.style.height = `${p / s.scale * l}px`;
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`;
5350
5404
  }, [
5351
5405
  e,
5352
5406
  n,
@@ -5359,8 +5413,8 @@ function Yr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
5359
5413
  }
5360
5414
  //#endregion
5361
5415
  //#region src/components/ShapeEditor/_state/useSelectionActions.ts
5362
- var Xr = 12;
5363
- function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMergeSelection: i, clipboardDocumentId: a, clipboardScope: o }) {
5416
+ var ii = 12;
5417
+ function ai({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMergeSelection: i, clipboardDocumentId: a, clipboardScope: o }) {
5364
5418
  let s = j(0), c = j(!0), l = j(n), u = j(a), d = j(o);
5365
5419
  l.current = n, u.current = a, d.current = o, T(() => (c.current = !0, () => {
5366
5420
  c.current = !1;
@@ -5379,22 +5433,22 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5379
5433
  t
5380
5434
  ]), g = w(() => {
5381
5435
  let e = m();
5382
- e.length && (s.current = 0, Q(Nt(e, a, o)));
5436
+ e.length && (s.current = 0, Lt(Pt(e, a, o)));
5383
5437
  }, [
5384
5438
  a,
5385
5439
  o,
5386
5440
  m
5387
- ]), _ = w(() => Rt(o), [o]), v = w((t) => {
5441
+ ]), _ = w(() => zt(o), [o]), v = w((t) => {
5388
5442
  if (n) return;
5389
5443
  let i = a;
5390
- zt(o).then((n) => {
5444
+ Bt(o).then((n) => {
5391
5445
  if (!c.current || l.current || u.current !== i || d.current !== o || !n?.shapes.length) return;
5392
5446
  let f, p, m = n.shapes.flatMap((e) => e.points);
5393
5447
  if (t && m.length) {
5394
5448
  let e = U(m);
5395
5449
  f = t.x - (e.minX + e.maxX) / 2, p = t.y - (e.minY + e.maxY) / 2;
5396
5450
  } else {
5397
- let e = !!n.documentId && n.documentId !== a, t = Bt(s.current, e, Xr);
5451
+ let e = !!n.documentId && n.documentId !== a, t = Vt(s.current, e, ii);
5398
5452
  f = t.offset, s.current = t.nextPasteCount, p = f;
5399
5453
  }
5400
5454
  let h = n.shapes.map((e) => ({
@@ -5419,8 +5473,8 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5419
5473
  ...e,
5420
5474
  id: ce(),
5421
5475
  points: e.points.map((e) => ({
5422
- x: e.x + Xr,
5423
- y: e.y + Xr
5476
+ x: e.x + ii,
5477
+ y: e.y + ii
5424
5478
  }))
5425
5479
  }));
5426
5480
  i.length && (e.create(i), r(i.map((e) => e.id)));
@@ -5478,9 +5532,9 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5478
5532
  if (n) return;
5479
5533
  let t = C();
5480
5534
  if (t.length < 2 || i && !i(t)) return;
5481
- let a = Pn([], 1, Nn(t));
5535
+ let a = Fn([], 1, Pn(t));
5482
5536
  if (!a) return;
5483
- let o = Fn(a, 1);
5537
+ let o = In(a, 1);
5484
5538
  if (!o.length) return;
5485
5539
  let s = t[0], c = o.map((e) => ({
5486
5540
  id: ce(),
@@ -5501,12 +5555,12 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5501
5555
  }
5502
5556
  //#endregion
5503
5557
  //#region src/components/ShapeEditor/_state/useViewportControls.ts
5504
- function Qr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBound: i, ready: a }) {
5558
+ function oi({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBound: i, ready: a }) {
5505
5559
  let o = j(null), s = j(null), c = w(() => {
5506
5560
  o.current?.(), o.current = null;
5507
5561
  }, []), l = w((t, n = r) => {
5508
5562
  let i = e.current;
5509
- i && (c(), o.current = _n(i.viewport, t, (e) => i.applyViewport(e), n));
5563
+ i && (c(), o.current = vn(i.viewport, t, (e) => i.applyViewport(e), n));
5510
5564
  }, [
5511
5565
  c,
5512
5566
  r,
@@ -5514,14 +5568,14 @@ function Qr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
5514
5568
  ]), u = w((t, n = r) => {
5515
5569
  let i = e.current;
5516
5570
  if (!i) return;
5517
- let a = hn(t, i.screenSize.w, i.screenSize.h);
5571
+ let a = gn(t, i.screenSize.w, i.screenSize.h);
5518
5572
  a && l(a, n);
5519
5573
  }, [
5520
5574
  l,
5521
5575
  r,
5522
5576
  e
5523
5577
  ]), d = w((e, n = r) => {
5524
- let i = mn(t.getShapes().filter((t) => e.includes(t.id)));
5578
+ let i = hn(t.getShapes().filter((t) => e.includes(t.id)));
5525
5579
  i && u(i, n);
5526
5580
  }, [
5527
5581
  t,
@@ -5532,7 +5586,7 @@ function Qr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
5532
5586
  if (!r.length) return;
5533
5587
  let i = e.current;
5534
5588
  if (!i) return;
5535
- let a = gn(U(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
5589
+ let a = _n(U(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
5536
5590
  a && l(a);
5537
5591
  }, [
5538
5592
  t,
@@ -5573,16 +5627,16 @@ function Qr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
5573
5627
  }
5574
5628
  //#endregion
5575
5629
  //#region src/components/ShapeEditor/ShapeEditor.tsx
5576
- var $r = "__draft_preview__", ei = new Set([
5630
+ var si = "__draft_preview__", ci = new Set([
5577
5631
  "copy",
5578
5632
  "selectAll",
5579
5633
  "clearSelection",
5580
5634
  "zoomToSelection"
5581
5635
  ]);
5582
- function ti(e, t) {
5636
+ function li(e, t) {
5583
5637
  return e.length === t.length && e.every((e, n) => e === t[n]);
5584
5638
  }
5585
- function ni({ 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 }) {
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 }) {
5586
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({
5587
5641
  active: !1,
5588
5642
  kind: "none",
@@ -5590,7 +5644,7 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5590
5644
  canRedo: !1
5591
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) => {
5592
5646
  nt(e), at(e === "error" ? t ?? null : null);
5593
- }, []), J = Kn({
5647
+ }, []), J = qn({
5594
5648
  onShapesCreated: _e,
5595
5649
  onShapesUpdated: ve,
5596
5650
  onShapesDeleted: ye
@@ -5633,19 +5687,19 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5633
5687
  }
5634
5688
  vt.current?.(X);
5635
5689
  }, [X]);
5636
- let Ct = k(() => !G || !ne ? null : cn(ne, G.w, G.h), [G, ne]), Tt = j(Ct);
5637
- Tt.current = Ct;
5638
- let Et = j(r);
5639
- Et.current = r;
5640
- let Dt = j(G);
5641
- Dt.current = G;
5642
- let Ot = j(qe);
5643
- Ot.current = qe;
5644
- let kt = j(qe?.imageSize);
5645
- kt.current = qe?.imageSize;
5646
- let At = j(Y);
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);
5647
5701
  O(() => {
5648
- At.current = Y;
5702
+ Q.current = Y;
5649
5703
  }, [Y]);
5650
5704
  let jt = j(a);
5651
5705
  jt.current = a;
@@ -5653,12 +5707,12 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5653
5707
  Mt.current = o;
5654
5708
  let Nt = j(s);
5655
5709
  Nt.current = s;
5656
- let Ft = j(I);
5657
- Ft.current = I;
5710
+ let Pt = j(I);
5711
+ Pt.current = I;
5658
5712
  let It = j(X.simplifyStrength);
5659
5713
  It.current = X.simplifyStrength;
5660
- let Q = !!c || !!u, Lt = j(Q);
5661
- Lt.current = Q;
5714
+ let $ = !!c || !!u, Lt = j($);
5715
+ Lt.current = $;
5662
5716
  let Rt = j(l);
5663
5717
  Rt.current = l;
5664
5718
  let zt = j(u);
@@ -5673,22 +5727,22 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5673
5727
  Wt.current = h;
5674
5728
  let Gt = j(J);
5675
5729
  Gt.current = J;
5676
- let Kt = j(!1), qt = j("idle"), Yt = j(null), Xt = w(() => {
5730
+ let Kt = j(!1), qt = j("idle"), Jt = j(null), Xt = w(() => {
5677
5731
  let e = W.current;
5678
5732
  if (!e) return;
5679
5733
  let t = jt.current, n = dt.current.get(t), r = ft.current;
5680
- e.setCursor(Jt({
5734
+ e.setCursor(Yt({
5681
5735
  tool: t,
5682
5736
  externalToolCursor: n?.cursor,
5683
5737
  isSpacePressed: Kt.current,
5684
5738
  interactionMode: qt.current,
5685
- rendererCursorHint: Yt.current,
5739
+ rendererCursorHint: Jt.current,
5686
5740
  isPolygonDrawing: r.kind === "polygon" && r.active
5687
5741
  }));
5688
5742
  }, []), Zt = w((e) => {
5689
5743
  qt.current !== e && (qt.current = e, Xt());
5690
5744
  }, [Xt]), Qt = w((e) => {
5691
- Yt.current !== e && (Yt.current = e, Xt());
5745
+ Jt.current !== e && (Jt.current = e, Xt());
5692
5746
  }, [Xt]), $t = w((e) => {
5693
5747
  let t = /* @__PURE__ */ new Set(), n = new Map(Gt.current.getShapes().map((e) => [e.id, e]));
5694
5748
  return e.filter((e) => {
@@ -5707,7 +5761,7 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5707
5761
  });
5708
5762
  }, []), en = w((e) => {
5709
5763
  let t = $t(e);
5710
- ti(At.current, t) || (lt || ct(t), W.current?.setSelection(t), he?.(t));
5764
+ li(Q.current, t) || (lt || ct(t), W.current?.setSelection(t), he?.(t));
5711
5765
  }, [
5712
5766
  $t,
5713
5767
  he,
@@ -5720,7 +5774,7 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5720
5774
  sn.current = nn, T(() => {
5721
5775
  if (!lt) return;
5722
5776
  let e = $t(i);
5723
- ti(i, e) || he?.(e);
5777
+ li(i, e) || he?.(e);
5724
5778
  }, [
5725
5779
  i,
5726
5780
  J.shapes,
@@ -5728,59 +5782,66 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5728
5782
  he,
5729
5783
  lt
5730
5784
  ]);
5731
- let ln = j(Se);
5732
- ln.current = Se;
5733
- let { registerMinimapShape: un, applyMinimapPreview: dn, syncMinimap: fn } = Yr({
5785
+ let cn = j(Se);
5786
+ cn.current = Se;
5787
+ let un = j(null), { registerMinimapShape: dn, applyMinimapPreview: fn, syncMinimap: pn } = ri({
5734
5788
  engineRef: W,
5735
5789
  docRef: Gt,
5736
5790
  overlayRef: Ee,
5737
5791
  zoomLabelRef: De,
5738
5792
  minimapRectRef: Te,
5739
5793
  minimapSize: 204,
5740
- onViewportChangeRef: ln
5741
- }), pn = j(/* @__PURE__ */ new Map()), mn = j(U);
5742
- mn.current = U;
5743
- let hn = w((e, t) => {
5744
- t ? pn.current.set(e, t) : pn.current.delete(e);
5745
- }, []), gn = j(null), [_n, bn] = M(null), xn = w((e) => {
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) => {
5746
5805
  if (!e.length) return;
5747
5806
  let t = new Map(Gt.current.getShapes().map((e) => [e.id, e]));
5748
- gn.current && t.set(gn.current.id, gn.current);
5807
+ _n.current && t.set(_n.current.id, _n.current);
5749
5808
  for (let { id: n, points: r } of e) {
5750
- let e = pn.current.get(n), i = t.get(n);
5809
+ let e = mn.current.get(n), i = t.get(n);
5751
5810
  if (!e || !i) continue;
5752
- let a = bt(e, r);
5753
- if (a) {
5754
- let e = xt(i, r);
5755
- a.textContent = mn.current?.(e) ?? St(e);
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);
5756
5817
  }
5757
5818
  }
5758
- }, []), Sn = w((e) => {
5759
- dn(e), xn(e), Ce?.(e);
5819
+ }, []), Cn = w((e) => {
5820
+ fn(e), Sn(e), Ce?.(e);
5760
5821
  }, [
5761
- dn,
5762
- xn,
5822
+ fn,
5823
+ Sn,
5763
5824
  Ce
5764
- ]), Cn = w((e) => {
5825
+ ]), wn = w((e) => {
5765
5826
  if (xe?.(e ? {
5766
5827
  ...e,
5767
5828
  meta: Nt.current
5768
5829
  } : null), !e || !Mt.current) {
5769
- gn.current && (gn.current = null, bn(null));
5830
+ _n.current && (_n.current = null, xn(null));
5770
5831
  return;
5771
5832
  }
5772
5833
  let t = {
5773
- id: $r,
5834
+ id: si,
5774
5835
  type: e.type,
5775
5836
  points: e.points,
5776
5837
  style: Mt.current,
5777
5838
  meta: Nt.current
5778
- }, n = gn.current !== null;
5779
- gn.current = t, n ? xn([{
5780
- id: $r,
5839
+ }, n = _n.current !== null;
5840
+ _n.current = t, n ? Sn([{
5841
+ id: si,
5781
5842
  points: e.points
5782
- }]) : bn(t);
5783
- }, [xn, xe]), wn = w((e, t) => {
5843
+ }]) : xn(t);
5844
+ }, [Sn, xe]), Tn = w((e, t) => {
5784
5845
  let n = Mt.current;
5785
5846
  if (!n || Lt.current) return;
5786
5847
  let r = ce();
@@ -5791,15 +5852,15 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5791
5852
  style: n,
5792
5853
  meta: s
5793
5854
  }), tn.current([r]);
5794
- }, [s]), Tn = j(wn);
5795
- Tn.current = wn;
5796
- let En = Un({
5855
+ }, [s]), En = j(Tn);
5856
+ En.current = Tn;
5857
+ let Dn = Wn({
5797
5858
  toolRef: jt,
5798
- selRef: At,
5859
+ selRef: Q,
5799
5860
  docRef: Gt,
5800
5861
  readOnlyRef: Lt,
5801
5862
  draftRef: Mt,
5802
- brushSizeRef: Ft,
5863
+ brushSizeRef: Pt,
5803
5864
  simplifyEpsilonRef: It,
5804
5865
  draftMeta: s,
5805
5866
  engineRef: W,
@@ -5808,57 +5869,57 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5808
5869
  }, [be]),
5809
5870
  onDraftShapeChange: xe,
5810
5871
  changeSelection: en,
5811
- createShape: wn
5812
- }), Dn = j(En);
5813
- Dn.current = En;
5814
- let { reset: On, undoSession: kn, redoSession: An, canUndoSession: jn, canRedoSession: Mn, hasDraftSession: Nn, hasDraftPoints: Pn, commitDraftSession: Fn, setBrushScalarMode: In, getBrushScalarMode: Ln, hasBrushSession: Rn, commitBrush: zn, cancelBrush: Bn, beginBrushEditFromSelection: Vn, deleteDraftSelectedPoints: Hn, handleToolChange: Wn, handleBrushSelectionChange: Gn } = En, qn = j(ue);
5815
- qn.current = ue;
5816
- let $ = yn({
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({
5817
5878
  docRef: Gt,
5818
5879
  draftRef: Mt,
5819
5880
  draftMeta: s,
5820
5881
  changeSelection: en,
5821
- assistantRef: qn
5822
- }), Jn = j($);
5823
- Jn.current = $;
5824
- let Yn = k(() => Pt(Ue), [Ue]), { selectAll: Xn, clearSelection: Zn, deleteSelection: Qn, copySelection: er, canPaste: tr, paste: nr, duplicate: rr, bringToFront: ir, sendToBack: ar, nudgeSelection: or, getMergeTargets: sr, mergeSelection: cr } = Zr({
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({
5825
5886
  doc: J,
5826
- selRef: At,
5827
- effectiveReadOnly: Q,
5887
+ selRef: Q,
5888
+ effectiveReadOnly: $,
5828
5889
  changeSelection: en,
5829
5890
  canMergeSelection: F,
5830
- clipboardDocumentId: Yn,
5831
- clipboardScope: t ?? Yn
5832
- }), { zoomToBounds: lr, zoomToShapes: ur, zoomToSelection: dr, zoomAtCenter: fr } = Qr({
5891
+ clipboardDocumentId: Zn,
5892
+ clipboardScope: t ?? Zn
5893
+ }), { zoomToBounds: dr, zoomToShapes: fr, zoomToSelection: pr, zoomAtCenter: mr } = oi({
5833
5894
  engineRef: W,
5834
5895
  doc: J,
5835
- selRef: At,
5896
+ selRef: Q,
5836
5897
  zoomAnimationDuration: ee,
5837
5898
  zoomBound: L,
5838
5899
  ready: Me
5839
5900
  });
5840
5901
  D(fe, () => ({
5841
5902
  previewRegionMask: (e) => {
5842
- let t = Dt.current;
5903
+ let t = Ot.current;
5843
5904
  if (!t) return;
5844
- let n = e ? cn(e, t.w, t.h) : Tt.current;
5845
- W.current?.setRegionOverlay(pr.current.showRegionMask ? n : null);
5905
+ let n = e ? ln(e, t.w, t.h) : Tt.current;
5906
+ W.current?.setRegionOverlay(hr.current.showRegionMask ? n : null);
5846
5907
  },
5847
5908
  undo: () => {
5848
- Lt.current || kn() || J.undo();
5909
+ Lt.current || An() || J.undo();
5849
5910
  },
5850
5911
  redo: () => {
5851
- Lt.current || An() || J.redo();
5912
+ Lt.current || jn() || J.redo();
5852
5913
  },
5853
- canUndo: () => jn() || J.canUndo(),
5854
- canRedo: () => Mn() || J.canRedo(),
5855
- undoSession: kn,
5856
- redoSession: An,
5857
- canUndoSession: jn,
5858
- canRedoSession: Mn,
5859
- hasDraftSession: Nn,
5860
- cancelDraftSession: On,
5861
- commitDraftSession: Fn,
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,
5862
5923
  setSelection: en,
5863
5924
  createShapes: (e) => {
5864
5925
  !e.length || Ht() || (J.create(e), en(e.map((e) => e.id)));
@@ -5870,14 +5931,14 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5870
5931
  !e.length || Ht() || J.remove(e);
5871
5932
  },
5872
5933
  getShapes: J.getShapes,
5873
- selectAll: Xn,
5874
- clearSelection: Zn,
5875
- deleteSelection: Qn,
5876
- copySelection: er,
5877
- paste: nr,
5878
- duplicate: rr,
5879
- bringToFront: ir,
5880
- sendToBack: ar,
5934
+ selectAll: Qn,
5935
+ clearSelection: $n,
5936
+ deleteSelection: er,
5937
+ copySelection: nr,
5938
+ paste: ir,
5939
+ duplicate: ar,
5940
+ bringToFront: or,
5941
+ sendToBack: sr,
5881
5942
  zoomFit: () => W.current?.fit(),
5882
5943
  zoom100: () => W.current?.zoom100(),
5883
5944
  zoomIn: () => {
@@ -5892,100 +5953,100 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5892
5953
  let { w: t, h: n } = e.screenSize;
5893
5954
  e.zoomAt(t / 2, n / 2, 1 / 1.2);
5894
5955
  },
5895
- zoomToSelection: dr,
5896
- zoomToShapes: ur,
5897
- zoomToBounds: lr,
5956
+ zoomToSelection: pr,
5957
+ zoomToShapes: fr,
5958
+ zoomToBounds: dr,
5898
5959
  brush: {
5899
- setScalarMode: In,
5900
- getScalarMode: Ln,
5901
- hasSession: Rn,
5902
- commit: zn,
5903
- cancel: Bn,
5904
- beginEditFromSelection: Vn
5960
+ setScalarMode: Ln,
5961
+ getScalarMode: Rn,
5962
+ hasSession: zn,
5963
+ commit: Bn,
5964
+ cancel: Vn,
5965
+ beginEditFromSelection: Hn
5905
5966
  }
5906
5967
  }), [
5907
5968
  J,
5908
5969
  en,
5909
5970
  Ht,
5910
- kn,
5911
5971
  An,
5912
- Fn,
5913
- On,
5914
- zn,
5972
+ jn,
5973
+ In,
5974
+ kn,
5915
5975
  Bn,
5916
- Xn,
5917
- Zn,
5976
+ Vn,
5918
5977
  Qn,
5978
+ $n,
5919
5979
  er,
5920
5980
  nr,
5921
- rr,
5922
5981
  ir,
5923
5982
  ar,
5983
+ or,
5984
+ sr,
5985
+ pr,
5986
+ fr,
5924
5987
  dr,
5925
- ur,
5926
- lr,
5927
- In,
5928
5988
  Ln,
5929
5989
  Rn,
5930
- Vn
5990
+ zn,
5991
+ Hn
5931
5992
  ]);
5932
- let pr = j(X);
5933
- pr.current = X;
5934
- let mr = w(() => vn({
5993
+ let hr = j(X);
5994
+ hr.current = X;
5995
+ let gr = w(() => yn({
5935
5996
  engineRef: W,
5936
5997
  toolRef: jt,
5937
5998
  externalToolMapRef: dt,
5938
5999
  spaceRef: Kt,
5939
6000
  docRef: Gt,
5940
- selRef: At,
6001
+ selRef: Q,
5941
6002
  draftRef: Mt,
5942
6003
  readOnlyRef: Lt,
5943
6004
  disableMarqueeRef: Rt,
5944
6005
  lockedRef: zt,
5945
6006
  onLockedInteraction: () => Bt.current?.(),
5946
6007
  onDrawAttemptWithoutDraft: () => Ut.current?.(),
5947
- createRef: Tn,
6008
+ createRef: En,
5948
6009
  selectRef: tn,
5949
6010
  enterEditRef: on,
5950
6011
  editingIdRef: sn,
5951
- drawSessionRef: Dn,
5952
- assistantRef: Jn,
6012
+ drawSessionRef: On,
6013
+ assistantRef: Xn,
5953
6014
  setCursorHint: Qt,
5954
6015
  setInteractionMode: Zt,
5955
- syncMinimap: fn,
5956
- onTransformPreview: Sn,
5957
- onDrawPreview: Cn
6016
+ syncMinimap: pn,
6017
+ onTransformPreview: Cn,
6018
+ onDrawPreview: wn
5958
6019
  }), [
5959
6020
  Qt,
5960
6021
  Zt,
5961
- fn,
5962
- Sn,
5963
- Cn
5964
- ]), hr = j([]);
5965
- Hr({
6022
+ pn,
6023
+ Cn,
6024
+ wn
6025
+ ]), _r = j([]);
6026
+ Xr({
5966
6027
  backend: pe,
5967
6028
  hostRef: we,
5968
6029
  engineRef: W,
5969
6030
  documentId: Ue,
5970
6031
  renderedImageUrl: et,
5971
- makeCallbacks: mr,
5972
- viewRef: pr,
6032
+ makeCallbacks: gr,
6033
+ viewRef: hr,
5973
6034
  readOnlyRef: Lt,
5974
6035
  toolRef: jt,
5975
- renderShapesRef: hr,
5976
- coordinateSizeRef: Ot,
5977
- imageSizeRef: kt,
5978
- selRef: At,
6036
+ renderShapesRef: _r,
6037
+ coordinateSizeRef: kt,
6038
+ imageSizeRef: At,
6039
+ selRef: Q,
5979
6040
  regionOverlayRef: Tt,
5980
- dimmedRef: Et,
5981
- syncMinimap: fn,
6041
+ dimmedRef: Dt,
6042
+ syncMinimap: pn,
5982
6043
  setImage: ke,
5983
6044
  setImageVisible: je,
5984
6045
  setReady: Ne,
5985
6046
  setImageStatus: ot,
5986
6047
  onContextMenuRequest: Fe
5987
6048
  });
5988
- let gr = k(() => {
6049
+ let vr = k(() => {
5989
6050
  let e = h ? J.shapes.map((e) => {
5990
6051
  let t = h(e);
5991
6052
  return t ? {
@@ -6011,71 +6072,71 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6011
6072
  h,
6012
6073
  te
6013
6074
  ]);
6014
- hr.current = gr, T(() => {
6015
- W.current?.setShapes(gr, At.current), fn();
6016
- }, [gr, fn]), T(() => {
6075
+ _r.current = vr, T(() => {
6076
+ W.current?.setShapes(vr, Q.current), pn();
6077
+ }, [vr, pn]), T(() => {
6017
6078
  W.current?.setSelection(Y);
6018
6079
  }, [Y]), T(() => {
6019
6080
  W.current?.setEditing(nn);
6020
6081
  }, [nn, Me]);
6021
- let _r = j(ge);
6022
- _r.current = ge, T(() => {
6023
- _r.current?.(nn);
6082
+ let yr = j(ge);
6083
+ yr.current = ge, T(() => {
6084
+ yr.current?.(nn);
6024
6085
  }, [nn]), T(() => {
6025
6086
  rn(null);
6026
6087
  }, [a]), T(() => {
6027
6088
  nn && (Y.length !== 1 || Y[0] !== nn) && rn(null);
6028
6089
  }, [Y, nn]), T(() => {
6029
6090
  let e = W.current;
6030
- e && (e.setFilter(X.brightness, X.contrast), e.setRenderDefaults({ strokeWidth: X.strokeSize }), e.setImageSmoothing(X.imageSmoothing), fn());
6091
+ e && (e.setFilter(X.brightness, X.contrast), e.setRenderDefaults({ strokeWidth: X.strokeSize }), e.setImageSmoothing(X.imageSmoothing), pn());
6031
6092
  }, [
6032
6093
  X.brightness,
6033
6094
  X.contrast,
6034
6095
  X.strokeSize,
6035
6096
  X.imageSmoothing,
6036
- fn
6097
+ pn
6037
6098
  ]), O(() => {
6038
- Me && W.current?.setOverlays(X.showRegionMask ? Ct : null, r);
6099
+ Me && W.current?.setOverlays(X.showRegionMask ? bt : null, r);
6039
6100
  }, [
6040
6101
  Me,
6041
- Ct,
6102
+ bt,
6042
6103
  X.showRegionMask,
6043
6104
  r
6044
6105
  ]), T(() => {
6045
- !Me || !G || fn();
6106
+ !Me || !G || pn();
6046
6107
  }, [
6047
6108
  Me,
6048
6109
  G,
6049
6110
  X.showRegionMask,
6050
6111
  ne,
6051
- fn
6112
+ pn
6052
6113
  ]), T(() => {
6053
- Me && W.current?.setTransformEnabled(!Q && a !== q.BRUSH);
6114
+ Me && W.current?.setTransformEnabled(!$ && a !== q.BRUSH);
6054
6115
  }, [
6055
- Q,
6116
+ $,
6056
6117
  Me,
6057
6118
  a
6058
6119
  ]), T(() => {
6059
6120
  u && rn(null);
6060
6121
  }, [u]), T(() => {
6061
- Wn(a, dt.current.has(a));
6062
- }, [a, Wn]);
6063
- let vr = $.finalize;
6122
+ Gn(a, dt.current.has(a));
6123
+ }, [a, Gn]);
6124
+ let br = Yn.finalize;
6064
6125
  T(() => {
6065
- vr();
6066
- }, [a, vr]), T(() => {
6067
- qt.current = "idle", Yt.current = null, Xt();
6126
+ br();
6127
+ }, [a, br]), T(() => {
6128
+ qt.current = "idle", Jt.current = null, Xt();
6068
6129
  }, [
6069
6130
  a,
6070
6131
  pe,
6071
6132
  Xt
6072
6133
  ]), T(() => {
6073
- Gn(Y, Q);
6134
+ Kn(Y, $);
6074
6135
  }, [
6075
6136
  Y,
6076
6137
  a,
6077
- Q,
6078
- Gn
6138
+ $,
6139
+ Kn
6079
6140
  ]), T(() => {
6080
6141
  Me && Xt();
6081
6142
  }, [
@@ -6085,25 +6146,25 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6085
6146
  Me,
6086
6147
  Xt
6087
6148
  ]);
6088
- let yr = j(Xe);
6089
- yr.current = Xe;
6090
- let br = e !== null, xr = j(null);
6149
+ let xr = j(Xe);
6150
+ xr.current = Xe;
6151
+ let Sr = e !== null, Cr = j(null);
6091
6152
  T(() => {
6092
- let e = br ? Ue : null;
6093
- xr.current !== e && (xr.current = e, Fe(null), rn(null), qt.current = "idle", Yt.current = null, J.reset(br ? Je ?? [] : []), en(br ? yr.current ?? [] : []), On(), vr(), Xt());
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());
6094
6155
  }, [
6095
- br,
6156
+ Sr,
6096
6157
  Ue,
6097
6158
  Je,
6098
6159
  J.reset,
6099
6160
  en,
6100
- On,
6101
- vr,
6161
+ kn,
6162
+ br,
6102
6163
  Xt
6103
6164
  ]);
6104
- let Sr = w(() => {
6165
+ let wr = w(() => {
6105
6166
  let e = sn.current;
6106
- if (!e || Q) return !1;
6167
+ if (!e || $) return !1;
6107
6168
  let t = W.current, n = new Set(t?.getVertexSelection() ?? []);
6108
6169
  if (!n.size) return !1;
6109
6170
  let r = Gt.current.getShapes().find((t) => t.id === e);
@@ -6113,76 +6174,76 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6113
6174
  ...r,
6114
6175
  points: i
6115
6176
  }]), t?.setVertexSelection([]), !0);
6116
- }, [Q]), Cr = () => J.getShapes().some((e) => At.current.includes(e.id) && ae(e));
6117
- $n({
6177
+ }, [$]), Tr = () => J.getShapes().some((e) => Q.current.includes(e.id) && ae(e));
6178
+ tr({
6118
6179
  keymap: de,
6119
6180
  hostRef: we,
6120
6181
  actions: {
6121
6182
  undo: () => {
6122
- Q || kn() || J.undo();
6183
+ $ || An() || J.undo();
6123
6184
  },
6124
6185
  redo: () => {
6125
- Q || An() || J.redo();
6186
+ $ || jn() || J.redo();
6126
6187
  },
6127
- selectAll: Xn,
6128
- copy: er,
6188
+ selectAll: Qn,
6189
+ copy: nr,
6129
6190
  cut: () => {
6130
- Ht(Cr()) || (er(), Qn());
6191
+ Ht(Tr()) || (nr(), er());
6131
6192
  },
6132
6193
  paste: () => {
6133
- Ht(tr()) || nr();
6194
+ Ht(rr()) || ir();
6134
6195
  },
6135
6196
  duplicate: () => {
6136
- Ht(Cr()) || rr();
6197
+ Ht(Tr()) || ar();
6137
6198
  },
6138
6199
  delete: () => {
6139
- Ht(Cr()) || Pn() && Hn() || Sr() || Qn();
6200
+ Ht(Tr()) || Fn() && Un() || wr() || er();
6140
6201
  },
6141
6202
  cancel: () => {
6142
6203
  let e = dt.current.get(jt.current);
6143
6204
  if (!(e?.onCancel && e.onCancel() !== !1)) {
6144
- if ($.isActive()) {
6145
- $.cancel();
6205
+ if (Yn.isActive()) {
6206
+ Yn.cancel();
6146
6207
  return;
6147
6208
  }
6148
- if (Nn()) {
6149
- On();
6209
+ if (Pn()) {
6210
+ kn();
6150
6211
  return;
6151
6212
  }
6152
6213
  if (nn) {
6153
6214
  rn(null);
6154
6215
  return;
6155
6216
  }
6156
- if (At.current.length) {
6157
- Zn();
6217
+ if (Q.current.length) {
6218
+ $n();
6158
6219
  return;
6159
6220
  }
6160
6221
  m?.();
6161
6222
  }
6162
6223
  },
6163
6224
  commitDraft: () => {
6164
- if ($.isActive()) {
6165
- $.finalize();
6225
+ if (Yn.isActive()) {
6226
+ Yn.finalize();
6166
6227
  return;
6167
6228
  }
6168
- if (Nn()) {
6169
- Fn();
6229
+ if (Pn()) {
6230
+ In();
6170
6231
  return;
6171
6232
  }
6172
- if (Q) return;
6233
+ if ($) return;
6173
6234
  if (nn) {
6174
6235
  rn(null);
6175
6236
  return;
6176
6237
  }
6177
- let e = At.current;
6238
+ let e = Q.current;
6178
6239
  if (e.length !== 1) return;
6179
6240
  let t = Gt.current.getShapes().find((t) => t.id === e[0]);
6180
6241
  t && (t.type === R.POLYGON || t.type === R.LINE) && t.interaction?.editable !== !1 && !t.readOnly && rn(e[0]);
6181
6242
  },
6182
- bringToFront: ir,
6183
- sendToBack: ar,
6184
- zoomIn: () => fr(1.2),
6185
- zoomOut: () => fr(1 / 1.2),
6243
+ bringToFront: or,
6244
+ sendToBack: sr,
6245
+ zoomIn: () => mr(1.2),
6246
+ zoomOut: () => mr(1 / 1.2),
6186
6247
  zoom100: () => W.current?.zoom100(),
6187
6248
  zoomFit: () => W.current?.fit(),
6188
6249
  toggleMinimap: () => ze((e) => !e),
@@ -6210,104 +6271,104 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6210
6271
  onSpaceUp: () => {
6211
6272
  W.current?.setPanMode(!1), qt.current === "panning" ? Zt("idle") : Xt();
6212
6273
  },
6213
- nudge: (e, t) => Ht(Cr()) || or(e, t)
6274
+ nudge: (e, t) => Ht(Tr()) || cr(e, t)
6214
6275
  });
6215
- let wr = k(() => gr.filter((e) => Y.includes(e.id) && z(e)), [gr, Y]), Tr = k(() => _n ? [...wr, _n] : wr, [wr, _n]), Er = Y.length > 0, Dr = J.shapes.some((e) => Y.includes(e.id) && ae(e)), Or = !Q && Y.length === 1 && (() => {
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 && (() => {
6216
6277
  let e = J.shapes.find((e) => e.id === Y[0]);
6217
6278
  return !!e && (e.type === R.POLYGON || e.type === R.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
6218
- })(), kr = sr(), Ar = Q || kr.length < 2 || (F ? !F(kr) : !1), jr = !!ue && !Q, Mr = jr && Y.length === 1 ? (() => {
6279
+ })(), jr = lr(), Mr = $ || jr.length < 2 || (F ? !F(jr) : !1), Nr = !!ue && !$, Pr = Nr && Y.length === 1 ? (() => {
6219
6280
  let e = J.shapes.find((e) => e.id === Y[0]);
6220
6281
  return e && e.type === R.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
6221
- })() : null, Nr = [
6282
+ })() : null, Fr = [
6222
6283
  {
6223
6284
  id: "copy",
6224
6285
  label: Z.contextMenu.copy,
6225
6286
  shortcut: "⌘C",
6226
- disabled: !Dr,
6227
- onClick: er
6287
+ disabled: !kr,
6288
+ onClick: nr
6228
6289
  },
6229
6290
  {
6230
6291
  id: "paste",
6231
6292
  label: Z.contextMenu.paste,
6232
6293
  shortcut: "⌘V",
6233
- disabled: Q || !tr(),
6234
- onClick: () => nr(Pe?.img)
6294
+ disabled: $ || !rr(),
6295
+ onClick: () => ir(Pe?.img)
6235
6296
  },
6236
6297
  {
6237
6298
  id: "duplicate",
6238
6299
  label: Z.contextMenu.duplicate,
6239
6300
  shortcut: "⌘D",
6240
- disabled: !Dr || Q,
6241
- onClick: rr
6301
+ disabled: !kr || $,
6302
+ onClick: ar
6242
6303
  },
6243
6304
  {
6244
6305
  id: "delete",
6245
6306
  label: Z.contextMenu.delete,
6246
6307
  shortcut: "Del",
6247
6308
  danger: !0,
6248
- disabled: !Dr || Q,
6249
- onClick: Qn
6309
+ disabled: !kr || $,
6310
+ onClick: er
6250
6311
  },
6251
6312
  { separator: !0 },
6252
6313
  {
6253
6314
  id: "editVertices",
6254
6315
  label: Z.contextMenu.editVertices,
6255
6316
  shortcut: "Enter",
6256
- disabled: !Or,
6317
+ disabled: !Ar,
6257
6318
  onClick: () => rn(Y[0])
6258
6319
  },
6259
6320
  {
6260
6321
  id: "merge",
6261
6322
  label: Z.contextMenu.merge,
6262
- disabled: Ar,
6263
- onClick: cr
6323
+ disabled: Mr,
6324
+ onClick: ur
6264
6325
  },
6265
- ...jr ? [{
6326
+ ...Nr ? [{
6266
6327
  id: "assistExpand",
6267
6328
  label: Z.contextMenu.assistExpand,
6268
6329
  icon: /* @__PURE__ */ x(d, { size: 14 }),
6269
- disabled: !Mr,
6330
+ disabled: !Pr,
6270
6331
  onClick: () => {
6271
- Pe && Mr && $.refineShape(Mr, Pe.img, !0);
6332
+ Pe && Pr && Yn.refineShape(Pr, Pe.img, !0);
6272
6333
  }
6273
6334
  }, {
6274
6335
  id: "assistExclude",
6275
6336
  label: Z.contextMenu.assistExclude,
6276
6337
  icon: /* @__PURE__ */ x(d, { size: 14 }),
6277
- disabled: !Mr,
6338
+ disabled: !Pr,
6278
6339
  onClick: () => {
6279
- Pe && Mr && $.refineShape(Mr, Pe.img, !1);
6340
+ Pe && Pr && Yn.refineShape(Pr, Pe.img, !1);
6280
6341
  }
6281
6342
  }] : [],
6282
6343
  {
6283
6344
  id: "bringToFront",
6284
6345
  label: Z.contextMenu.bringToFront,
6285
- disabled: !Dr || Q,
6286
- onClick: ir
6346
+ disabled: !kr || $,
6347
+ onClick: or
6287
6348
  },
6288
6349
  {
6289
6350
  id: "sendToBack",
6290
6351
  label: Z.contextMenu.sendToBack,
6291
- disabled: !Dr || Q,
6292
- onClick: ar
6352
+ disabled: !kr || $,
6353
+ onClick: sr
6293
6354
  },
6294
6355
  { separator: !0 },
6295
6356
  {
6296
6357
  id: "undo",
6297
6358
  label: Z.contextMenu.undo,
6298
6359
  shortcut: "⌘Z",
6299
- disabled: Q || !jn() && !J.canUndo(),
6360
+ disabled: $ || !Mn() && !J.canUndo(),
6300
6361
  onClick: () => {
6301
- kn() || J.undo();
6362
+ An() || J.undo();
6302
6363
  }
6303
6364
  },
6304
6365
  {
6305
6366
  id: "redo",
6306
6367
  label: Z.contextMenu.redo,
6307
6368
  shortcut: "⇧⌘Z",
6308
- disabled: Q || !Mn() && !J.canRedo(),
6369
+ disabled: $ || !Nn() && !J.canRedo(),
6309
6370
  onClick: () => {
6310
- An() || J.redo();
6371
+ jn() || J.redo();
6311
6372
  }
6312
6373
  },
6313
6374
  { separator: !0 },
@@ -6315,35 +6376,35 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6315
6376
  id: "selectAll",
6316
6377
  label: Z.contextMenu.selectAll,
6317
6378
  shortcut: "⌘A",
6318
- onClick: Xn
6379
+ onClick: Qn
6319
6380
  },
6320
6381
  {
6321
6382
  id: "clearSelection",
6322
6383
  label: Z.contextMenu.clearSelection,
6323
- disabled: !Er,
6324
- onClick: Zn
6384
+ disabled: !Or,
6385
+ onClick: $n
6325
6386
  },
6326
6387
  {
6327
6388
  id: "zoomToSelection",
6328
6389
  label: Z.contextMenu.zoomToSelection,
6329
- disabled: !Er,
6330
- onClick: dr
6390
+ disabled: !Or,
6391
+ onClick: pr
6331
6392
  }
6332
- ], Pr = c ? Nr.filter((e) => "separator" in e || !!e.id && ei.has(e.id)) : Nr, Fr = A ? A(Pr, {
6393
+ ], Ir = c ? Fr.filter((e) => "separator" in e || !!e.id && ci.has(e.id)) : Fr, Lr = A ? A(Ir, {
6333
6394
  selectedIds: Y,
6334
- readOnly: Q
6335
- }) : Pr, Ir = qr({
6395
+ readOnly: $
6396
+ }) : Ir, Rr = ti({
6336
6397
  engineRef: W,
6337
6398
  image: G,
6338
6399
  wheelZoom: X.wheelZoom,
6339
6400
  minimapSize: 204
6340
- }), Lr = w(() => {
6401
+ }), zr = w(() => {
6341
6402
  W.current?.zoom100();
6342
- }, []), Rr = w(() => {
6403
+ }, []), Br = w(() => {
6343
6404
  ze((e) => !e);
6344
- }, []), zr = w(() => {
6405
+ }, []), Vr = w(() => {
6345
6406
  He((e) => !e);
6346
- }, []), Br = w(() => {
6407
+ }, []), Hr = w(() => {
6347
6408
  He(!1);
6348
6409
  }, []);
6349
6410
  return /* @__PURE__ */ S("div", {
@@ -6370,9 +6431,23 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6370
6431
  errorLabel: Z.imageLoadError,
6371
6432
  errorHints: Z.imageErrorHints
6372
6433
  }),
6373
- Me && G && /* @__PURE__ */ x("div", {
6434
+ Me && G && /* @__PURE__ */ S("div", {
6374
6435
  className: "aivex:pointer-events-none aivex:absolute aivex:inset-0 aivex:overflow-hidden",
6375
- children: /* @__PURE__ */ S("div", {
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", {
6376
6451
  ref: Ee,
6377
6452
  style: {
6378
6453
  position: "absolute",
@@ -6423,21 +6498,14 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6423
6498
  y: 0
6424
6499
  }
6425
6500
  }),
6426
- Tr.length > 0 && /* @__PURE__ */ x(wt, {
6427
- shapes: Tr,
6428
- getLabel: V,
6429
- hideDot: H,
6430
- formatInfo: U,
6431
- register: hn
6432
- }),
6433
- ue && ($.status === "loading" || $.boxes.length > 0) && /* @__PURE__ */ x(Ye, {
6501
+ ue && (Yn.status === "loading" || Yn.boxes.length > 0) && /* @__PURE__ */ x(Ye, {
6434
6502
  image: G,
6435
- points: $.points,
6436
- boxes: $.boxes,
6437
- status: $.status
6503
+ points: Yn.points,
6504
+ boxes: Yn.boxes,
6505
+ status: Yn.status
6438
6506
  })
6439
6507
  ]
6440
- })
6508
+ })]
6441
6509
  }),
6442
6510
  Me && X.showCursorGuide && /* @__PURE__ */ x(Qe, { color: "#1e88e5" }),
6443
6511
  G && y && /* @__PURE__ */ x(ht, {
@@ -6445,47 +6513,99 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6445
6513
  imageUrl: et,
6446
6514
  imageVisible: Ae,
6447
6515
  loading: !Me,
6448
- region: Ct,
6516
+ region: bt,
6449
6517
  roiMaskId: Oe,
6450
- shapes: gr,
6518
+ shapes: vr,
6451
6519
  view: X,
6452
6520
  viewDefaults: pt,
6453
6521
  onChangeView: _t,
6454
- nav: Ir,
6455
- registerShape: un,
6522
+ nav: Rr,
6523
+ registerShape: dn,
6456
6524
  rectRef: Te,
6457
6525
  zoomLabelRef: De,
6458
- onZoom100: Lr,
6526
+ onZoom100: zr,
6459
6527
  open: Re,
6460
- onToggleOpen: Rr,
6528
+ onToggleOpen: Br,
6461
6529
  position: b,
6462
6530
  labels: Z.minimap,
6463
6531
  settingsLabels: Z.viewSettings,
6464
6532
  settingsItems: P,
6465
6533
  showSettings: C,
6466
6534
  settingsOpen: K,
6467
- onToggleSettings: zr,
6468
- onCloseSettings: Br
6535
+ onToggleSettings: Vr,
6536
+ onCloseSettings: Hr
6469
6537
  }),
6470
6538
  Pe && /* @__PURE__ */ x(Ze, {
6471
6539
  x: Pe.x,
6472
6540
  y: Pe.y,
6473
- items: Fr,
6541
+ items: Lr,
6474
6542
  onClose: () => Fe(null)
6475
6543
  })
6476
6544
  ]
6477
6545
  });
6478
6546
  }
6479
6547
  //#endregion
6548
+ //#region src/components/ShapeEditor/_model/viewerPatch.ts
6549
+ function di({ viewport: e, image: t, focusPoints: n, zoomPadding: r, focusFit: i }) {
6550
+ let a = Math.min(e.width / t.width, e.height / t.height);
6551
+ if (!n?.length) return {
6552
+ scale: a,
6553
+ offsetX: (e.width - t.width * a) / 2,
6554
+ offsetY: (e.height - t.height * a) / 2
6555
+ };
6556
+ let o = U(n), s = Math.max(o.maxX - o.minX, 50), c = Math.max(o.maxY - o.minY, 50), l = Math.min(s, c) * r, u = Math.min(e.width / (s + l * 2), e.height / (c + l * 2));
6557
+ i === "cover" && (u = Math.max(u, Math.max(e.width / t.width, e.height / t.height)));
6558
+ let d = e.width / 2 - (o.minX + o.maxX) / 2 * u, f = e.height / 2 - (o.minY + o.maxY) / 2 * u;
6559
+ return i === "cover" && (d = Math.min(0, Math.max(d, e.width - t.width * u)), f = Math.min(0, Math.max(f, e.height - t.height * u))), {
6560
+ scale: u,
6561
+ offsetX: d,
6562
+ offsetY: f
6563
+ };
6564
+ }
6565
+ function fi(e, t, n) {
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);
6567
+ return a <= r || o <= i ? null : {
6568
+ x: r,
6569
+ y: i,
6570
+ width: a - r,
6571
+ height: o - i
6572
+ };
6573
+ }
6574
+ function pi({ visible: e, image: t, natural: n, density: r }) {
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 = {
6576
+ x: o / i,
6577
+ y: s / a,
6578
+ width: c / i,
6579
+ height: l / a
6580
+ };
6581
+ return {
6582
+ source: {
6583
+ x: o,
6584
+ y: s,
6585
+ width: c,
6586
+ height: l
6587
+ },
6588
+ rect: u,
6589
+ outputWidth: Math.max(1, Math.min(c, Math.ceil(u.width * r))),
6590
+ outputHeight: Math.max(1, Math.min(l, Math.ceil(u.height * r)))
6591
+ };
6592
+ }
6593
+ function mi(e, t, n) {
6594
+ let r = 1e-6;
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;
6596
+ let i = Math.min(n.density, n.natural.width / n.image.width), a = Math.min(n.density, n.natural.height / n.image.height);
6597
+ return e.outputWidth / e.rect.width >= i * .99 && e.outputHeight / e.rect.height >= a * .99;
6598
+ }
6599
+ //#endregion
6480
6600
  //#region src/components/ShapeEditor/ShapeViewer.tsx
6481
- function ri(e, t, n) {
6601
+ function hi(e, t, n) {
6482
6602
  if (t.length !== 0) {
6483
6603
  e.beginPath(), e.moveTo(t[0].x, t[0].y);
6484
6604
  for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
6485
6605
  n && e.closePath();
6486
6606
  }
6487
6607
  }
6488
- function ii(e, t, n, r) {
6608
+ function gi(e, t, n, r) {
6489
6609
  if (t.interaction?.visible === !1) return;
6490
6610
  let i = at(t, {
6491
6611
  strokeWidth: r,
@@ -6502,11 +6622,53 @@ function ii(e, t, n, r) {
6502
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);
6503
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);
6504
6624
  }
6505
- } else ri(e, t.points, t.type !== R.LINE);
6625
+ } else hi(e, t.points, t.type !== R.LINE);
6506
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();
6507
6627
  }
6508
- function ai({ 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 }) {
6509
- 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);
6628
+ async function _i(e, t, n) {
6629
+ let r = await ar(e);
6630
+ if (!r) return null;
6631
+ try {
6632
+ let i = {
6633
+ width: r.width,
6634
+ height: r.height
6635
+ }, a = {
6636
+ url: e,
6637
+ smoothing: t,
6638
+ natural: i,
6639
+ bitmap: null,
6640
+ rect: {
6641
+ x: 0,
6642
+ y: 0,
6643
+ width: 0,
6644
+ height: 0
6645
+ },
6646
+ outputWidth: 0,
6647
+ outputHeight: 0
6648
+ }, o = n(i);
6649
+ if (!o?.visibleRect) return a;
6650
+ let s = pi({
6651
+ visible: o.visibleRect,
6652
+ natural: i,
6653
+ ...o
6654
+ }), c = await createImageBitmap(r.source, s.source.x, s.source.y, s.source.width, s.source.height, {
6655
+ resizeWidth: s.outputWidth,
6656
+ resizeHeight: s.outputHeight,
6657
+ resizeQuality: t ? "high" : "pixelated"
6658
+ });
6659
+ return {
6660
+ ...a,
6661
+ ...s,
6662
+ bitmap: c
6663
+ };
6664
+ } catch {
6665
+ return null;
6666
+ } finally {
6667
+ r.release();
6668
+ }
6669
+ }
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 }) {
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);
6510
6672
  T(() => {
6511
6673
  if (!f || y) return;
6512
6674
  let e = g.current;
@@ -6520,29 +6682,72 @@ function ai({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6520
6682
  if (!e) return;
6521
6683
  let t = new ResizeObserver(() => A((e) => e + 1));
6522
6684
  return t.observe(e), () => t.disconnect();
6523
- }, []), T(() => {
6685
+ }, []);
6686
+ let F = k(() => r.find((e) => e.id === a), [a, r]);
6687
+ return T(() => {
6524
6688
  if (!y || !e) {
6525
6689
  w(e ? "loading" : "missing"), D(null);
6526
6690
  return;
6527
6691
  }
6528
- let t = !0;
6529
- return w("loading"), D(null), tr(e).then(async (n) => {
6530
- if (!t) return;
6531
- if (n) {
6532
- v.current = n, w("ready");
6692
+ let t = g.current;
6693
+ if (!t) return;
6694
+ let { width: r, height: i } = t.getBoundingClientRect();
6695
+ if (!r || !i) return;
6696
+ let a = {
6697
+ width: r,
6698
+ height: i
6699
+ }, c = (e) => {
6700
+ let t = n ?? e;
6701
+ if (!t.width || !t.height) return null;
6702
+ let r = di({
6703
+ viewport: a,
6704
+ image: t,
6705
+ focusPoints: F?.points,
6706
+ zoomPadding: s,
6707
+ focusFit: o
6708
+ });
6709
+ return {
6710
+ image: t,
6711
+ visibleRect: fi(r, a, t),
6712
+ density: r.scale * (window.devicePixelRatio || 1)
6713
+ };
6714
+ }, l = v.current;
6715
+ if (l?.url === e && l.smoothing === d) {
6716
+ let e = c(l.natural);
6717
+ if (!e?.visibleRect || l.bitmap && mi(l, e.visibleRect, {
6718
+ ...e,
6719
+ natural: l.natural
6720
+ })) return;
6721
+ } else l?.url !== e && (w("loading"), D(null));
6722
+ let u = !0;
6723
+ return (async () => {
6724
+ let t = await lr(() => u ? _i(e, d, c) : Promise.resolve(void 0));
6725
+ if (!u) {
6726
+ t?.bitmap?.close();
6727
+ return;
6728
+ }
6729
+ if (t === null) {
6730
+ v.current?.bitmap?.close(), v.current = null, w("error");
6731
+ let t = await mr(e);
6732
+ u && D(t);
6533
6733
  return;
6534
6734
  }
6535
- v.current = null, w("error");
6536
- let r = await or(e);
6537
- t && D(r);
6538
- }), () => {
6539
- t = !1;
6735
+ t && (v.current?.bitmap?.close(), v.current = t, w("ready"), P((e) => e + 1));
6736
+ })(), () => {
6737
+ u = !1;
6540
6738
  };
6541
- }, [e, y]), T(() => () => {
6542
- v.current = null;
6543
- }, []);
6544
- let N = k(() => r.find((e) => e.id === a), [a, r]);
6545
- return T(() => {
6739
+ }, [
6740
+ n,
6741
+ F,
6742
+ o,
6743
+ d,
6744
+ e,
6745
+ O,
6746
+ y,
6747
+ s
6748
+ ]), T(() => () => {
6749
+ v.current?.bitmap?.close(), v.current = null;
6750
+ }, []), T(() => {
6546
6751
  if (C === "error") {
6547
6752
  let e = _.current;
6548
6753
  e?.getContext("2d")?.clearRect(0, 0, e.width, e.height);
@@ -6556,41 +6761,54 @@ function ai({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6556
6761
  t.width = Math.max(1, Math.round(f * m)), t.height = Math.max(1, Math.round(p * m)), t.style.width = `${f}px`, t.style.height = `${p}px`;
6557
6762
  let h = t.getContext("2d");
6558
6763
  if (!h) return;
6559
- let y = n?.width ?? a.naturalWidth, b = n?.height ?? a.naturalHeight;
6764
+ let y = n?.width ?? a.natural.width, b = n?.height ?? a.natural.height;
6560
6765
  if (!y || !b) return;
6561
- let x = Math.min(f / y, p / b), S = (f - y * x) / 2, w = (p - b * x) / 2;
6562
- if (N && N.points.length > 0) {
6563
- let e = U(N.points), t = Math.max(e.maxX - e.minX, 50), n = Math.max(e.maxY - e.minY, 50), r = Math.min(t, n) * s;
6564
- x = Math.min(f / (t + r * 2), p / (n + r * 2)), o === "cover" && (x = Math.max(x, Math.max(f / y, p / b))), S = f / 2 - (e.minX + e.maxX) / 2 * x, w = p / 2 - (e.minY + e.maxY) / 2 * x, o === "cover" && (S = Math.min(0, Math.max(S, f - y * x)), w = Math.min(0, Math.max(w, p - b * x)));
6565
- }
6766
+ let { scale: x, offsetX: S, offsetY: w } = di({
6767
+ viewport: {
6768
+ width: f,
6769
+ height: p
6770
+ },
6771
+ image: {
6772
+ width: y,
6773
+ height: b
6774
+ },
6775
+ focusPoints: F?.points,
6776
+ zoomPadding: s,
6777
+ focusFit: o
6778
+ });
6566
6779
  h.setTransform(m, 0, 0, m, 0, 0), h.clearRect(0, 0, f, p), h.save(), h.translate(S, w), h.scale(x, x), h.imageSmoothingEnabled = d;
6567
6780
  let T = We({
6568
6781
  brightness: l,
6569
6782
  contrast: u
6570
6783
  });
6571
- h.filter = `brightness(${T.brightness}) contrast(${T.contrast})`, h.drawImage(a, 0, 0, y, b), h.filter = "none";
6572
- let E = i ? cn(i, y, b) : null;
6573
- if (E && (tn(h, E, y, b), E.outlineStyles)) {
6784
+ if (h.filter = `brightness(${T.brightness}) contrast(${T.contrast})`, a.bitmap) {
6785
+ let { x: e, y: t, width: n, height: r } = a.rect;
6786
+ h.drawImage(a.bitmap, e, t, n, r);
6787
+ }
6788
+ h.filter = "none";
6789
+ let E = i ? ln(i, y, b) : null;
6790
+ if (E && (nn(h, E, y, b), E.outlineStyles)) {
6574
6791
  let e = (e, t) => {
6575
6792
  if (h.lineWidth = t.width / x, t.underlayColor) {
6576
6793
  h.setLineDash([]), h.strokeStyle = t.underlayColor;
6577
- for (let [t, n] of e) ri(h, [t, n], !1), h.stroke();
6794
+ for (let [t, n] of e) hi(h, [t, n], !1), h.stroke();
6578
6795
  }
6579
6796
  h.save(), h.globalAlpha *= t.opacity, h.setLineDash(t.dash.map((e) => e / x)), h.strokeStyle = t.color;
6580
- for (let [t, n] of e) ri(h, [t, n], !1), h.stroke();
6797
+ for (let [t, n] of e) hi(h, [t, n], !1), h.stroke();
6581
6798
  h.restore();
6582
6799
  };
6583
6800
  e(E.visibleOutline, E.outlineStyles.visible), e(E.occludedOutline, E.outlineStyles.occluded);
6584
6801
  }
6585
- for (let e of se(r)) ii(h, e, x, c);
6802
+ for (let e of se(r)) gi(h, e, x, c);
6586
6803
  h.restore();
6587
6804
  }, [
6588
6805
  l,
6589
6806
  u,
6590
6807
  n,
6591
- N,
6808
+ F,
6592
6809
  o,
6593
6810
  d,
6811
+ N,
6594
6812
  i,
6595
6813
  r,
6596
6814
  O,
@@ -6663,6 +6881,6 @@ function ai({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6663
6881
  });
6664
6882
  }
6665
6883
  //#endregion
6666
- export { K as DEFAULT_EDITOR_STRINGS, Ve as DEFAULT_VIEW_SETTINGS, R as SHAPE_TYPE, ni as ShapeEditor, ni as default, ai as ShapeViewer, q as TOOL, He as VIEW_SETTING_RANGES, We as clampViewSettings, ce as generateId };
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 };
6667
6885
 
6668
6886
  //# sourceMappingURL=shape-editor.js.map