marquee-selection 0.0.12 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +1,34 @@
1
- function ce(jt) {
1
+ function ye(Jt) {
2
2
  const {
3
3
  container: B,
4
- selectable: at = "img",
5
- exclude: Q,
6
- selectionMode: ft = "intersects",
7
- minOverlapRatio: Vt = 0,
8
- overlapMetric: Wt = "element",
9
- selectedClass: Z = "selected",
10
- onChange: ut,
11
- preventAncestorSelection: Kt = !0,
12
- conflictStrategy: _t,
4
+ selectable: dt = "img",
5
+ exclude: ot,
6
+ selectionMode: yt = "intersects",
7
+ minOverlapRatio: Qt = 0,
8
+ overlapMetric: Zt = "element",
9
+ selectedClass: st = "selected",
10
+ onChange: gt,
11
+ preventAncestorSelection: te = !0,
12
+ conflictStrategy: ee,
13
13
  groupMode: q = !1,
14
- groupOverlayClass: Mt,
15
- groupColor: pt,
16
- groupRandomColor: Jt = !1,
17
- groupColorPalette: tt,
18
- multi: kt = !1,
19
- combineMode: ht,
20
- hoverHighlight: et = !1,
21
- hoverClass: Rt = "hovered",
22
- onSelectionEnd: It,
23
- quickGroupOnDblClick: dt = !1,
24
- quickGroupSelector: At,
25
- allowIntersectionSelection: X = !0,
26
- allowUnionSelection: H = !0,
27
- allowContainmentSelection: T = !0,
28
- toolbarButtons: yt
29
- } = jt, Lt = Array.isArray(Q) ? Q.filter(Boolean) : Q ? [Q] : [], gt = (t) => {
30
- if (!t || !Lt.length) return !1;
31
- for (const e of Lt)
14
+ groupOverlayClass: It,
15
+ groupColor: mt,
16
+ groupRandomColor: ne = !1,
17
+ groupColorPalette: lt,
18
+ multi: Nt = !1,
19
+ combineMode: bt,
20
+ hoverHighlight: rt = !1,
21
+ hoverClass: Ot = "hovered",
22
+ onSelectionEnd: Gt,
23
+ quickGroupOnDblClick: vt = !1,
24
+ quickGroupSelector: Ft,
25
+ allowIntersectionSelection: V = !0,
26
+ allowUnionSelection: W = !0,
27
+ allowContainmentSelection: K = !0,
28
+ toolbarButtons: M
29
+ } = Jt, Pt = Array.isArray(ot) ? ot.filter(Boolean) : ot ? [ot] : [], xt = (t) => {
30
+ if (!t || !Pt.length) return !1;
31
+ for (const e of Pt)
32
32
  try {
33
33
  if (t instanceof Element && t.matches(e)) return !0;
34
34
  } catch {
@@ -36,33 +36,36 @@ function ce(jt) {
36
36
  return !1;
37
37
  };
38
38
  if (!B) throw new Error("container is required");
39
- let mt = 0, bt = 0, j = !1, $ = null, xt = !1, P = /* @__PURE__ */ new Set(), U = null, vt = "replace", a = [], nt = [], I = [], Y = [];
40
- const Qt = () => `hsl(${Math.floor(Math.random() * 360)}, 70%, 55%)`, wt = () => {
41
- if (pt && typeof pt == "string")
42
- return pt;
43
- if (Jt) {
44
- if (Array.isArray(tt) && tt.length > 0) {
45
- const t = Math.floor(Math.random() * tt.length);
46
- return tt[t];
39
+ let wt = 0, Et = 0, J = !1, $ = null, St = !1, D = /* @__PURE__ */ new Set(), _ = null, Ct = "replace", a = [], it = [], I = [], H = [], U = [];
40
+ const oe = () => (M ?? []).map((t) => ({
41
+ label: (t == null ? void 0 : t.label) ?? "",
42
+ title: (t == null ? void 0 : t.title) ?? ""
43
+ })), Q = (t) => !M || M.length === 0 ? null : (U[t] || (U[t] = oe()), U[t]), se = () => `hsl(${Math.floor(Math.random() * 360)}, 70%, 55%)`, zt = () => {
44
+ if (mt && typeof mt == "string")
45
+ return mt;
46
+ if (ne) {
47
+ if (Array.isArray(lt) && lt.length > 0) {
48
+ const t = Math.floor(Math.random() * lt.length);
49
+ return lt[t];
47
50
  }
48
- return Qt();
51
+ return se();
49
52
  }
50
53
  return "rgba(255, 165, 0, 0.9)";
51
54
  };
52
55
  let k = null;
53
- const V = [], Et = [];
54
- let D = null;
55
- const St = (t) => {
56
+ const Z = [], $t = [];
57
+ let j = null;
58
+ const Mt = (t) => {
56
59
  if (!t.length) return null;
57
60
  const e = new Set(t);
58
61
  for (let r = 0; r < a.length; r++) {
59
62
  const i = a[r] || [];
60
63
  if (i.length !== e.size) continue;
61
64
  let c = !0;
62
- const o = new Set(i);
63
- if (o.size !== e.size && (c = !1), c) {
65
+ const s = new Set(i);
66
+ if (s.size !== e.size && (c = !1), c) {
64
67
  for (const n of e)
65
- if (!o.has(n)) {
68
+ if (!s.has(n)) {
66
69
  c = !1;
67
70
  break;
68
71
  }
@@ -71,351 +74,384 @@ function ce(jt) {
71
74
  }
72
75
  return null;
73
76
  };
74
- let Nt = null;
75
- const Ot = (t) => {
77
+ let Tt = null;
78
+ const Bt = (t) => {
76
79
  const e = !!I[t], r = a[t] || [];
77
80
  for (const i of r)
78
81
  i.style.visibility = e ? "hidden" : "";
79
- }, ot = (t, e) => t < 0 || t >= a.length ? !1 : (I[t] = e, Ot(t), !0);
80
- let W = null;
81
- const st = (t) => {
82
- et && (W && W !== t && W.classList.remove(Rt), t && W !== t && t.classList.add(Rt), W = t);
83
- }, Zt = () => {
82
+ }, ct = (t, e) => t < 0 || t >= a.length ? !1 : (I[t] = e, Bt(t), !0);
83
+ let tt = null;
84
+ const at = (t) => {
85
+ rt && (tt && tt !== t && tt.classList.remove(Ot), t && tt !== t && t.classList.add(Ot), tt = t);
86
+ }, le = () => {
84
87
  const t = document.createElement("div");
85
88
  return t.style.position = "fixed", t.style.left = "0px", t.style.top = "0px", t.style.width = "0px", t.style.height = "0px", t.style.outline = "1px dashed #268aff", t.style.background = "rgba(38,138,255,0.12)", t.style.pointerEvents = "none", t.style.zIndex = "2147483647", t.style.boxSizing = "border-box", document.body.appendChild(t), t;
86
- }, lt = (t, e) => t.left < e.right && t.right > e.left && t.top < e.bottom && t.bottom > e.top, te = (t, e) => t.left <= e.left && t.right >= e.right && t.top <= e.top && t.bottom >= e.bottom, ee = (t, e) => {
87
- const r = Math.max(t.left, e.left), i = Math.min(t.right, e.right), c = Math.max(t.top, e.top), o = Math.min(t.bottom, e.bottom), n = Math.max(0, i - r), s = Math.max(0, o - c), y = n * s, h = Math.max(1, e.width * e.height);
88
- return y / h;
89
- }, ne = (t, e) => {
90
- const r = Math.max(t.left, e.left), i = Math.min(t.right, e.right), c = Math.max(t.top, e.top), o = Math.min(t.bottom, e.bottom), n = Math.max(0, i - r), s = Math.max(0, o - c), y = n * s, h = Math.max(1, t.width * t.height), u = Math.max(1, e.width * e.height), d = h + u - y;
91
- return y / d;
92
- }, Gt = (t, e) => Wt === "iou" ? ne(t, e) : ee(t, e), Bt = (t, e, r, i) => {
93
- const c = Math.min(t, r), o = Math.min(e, i), n = Math.abs(r - t), s = Math.abs(i - e);
94
- return { left: c, top: o, width: n, height: s };
95
- }, Ct = (t) => {
89
+ }, ft = (t, e) => t.left < e.right && t.right > e.left && t.top < e.bottom && t.bottom > e.top, re = (t, e) => t.left <= e.left && t.right >= e.right && t.top <= e.top && t.bottom >= e.bottom, ie = (t, e) => {
90
+ const r = Math.max(t.left, e.left), i = Math.min(t.right, e.right), c = Math.max(t.top, e.top), s = Math.min(t.bottom, e.bottom), n = Math.max(0, i - r), l = Math.max(0, s - c), f = n * l, u = Math.max(1, e.width * e.height);
91
+ return f / u;
92
+ }, ce = (t, e) => {
93
+ const r = Math.max(t.left, e.left), i = Math.min(t.right, e.right), c = Math.max(t.top, e.top), s = Math.min(t.bottom, e.bottom), n = Math.max(0, i - r), l = Math.max(0, s - c), f = n * l, u = Math.max(1, t.width * t.height), p = Math.max(1, e.width * e.height), d = u + p - f;
94
+ return f / d;
95
+ }, qt = (t, e) => Zt === "iou" ? ce(t, e) : ie(t, e), Yt = (t, e, r, i) => {
96
+ const c = Math.min(t, r), s = Math.min(e, i), n = Math.abs(r - t), l = Math.abs(i - e);
97
+ return { left: c, top: s, width: n, height: l };
98
+ }, kt = (t) => {
96
99
  const e = t.map((n) => n.getBoundingClientRect()).filter((n) => n.width > 0 && n.height > 0);
97
100
  if (!e.length) return null;
98
- const r = Math.min(...e.map((n) => n.left)), i = Math.min(...e.map((n) => n.top)), c = Math.max(...e.map((n) => n.right)), o = Math.max(...e.map((n) => n.bottom));
99
- return { left: r, top: i, width: c - r, height: o - i };
100
- }, K = () => {
101
- nt.forEach((t) => t.remove()), nt = [];
101
+ const r = Math.min(...e.map((n) => n.left)), i = Math.min(...e.map((n) => n.top)), c = Math.max(...e.map((n) => n.right)), s = Math.max(...e.map((n) => n.bottom));
102
+ return { left: r, top: i, width: c - r, height: s - i };
103
+ }, et = () => {
104
+ it.forEach((t) => t.remove()), it = [];
102
105
  }, N = () => {
103
- if (K(), !q) return;
106
+ if (et(), !q) return;
104
107
  const t = [], e = (r, i) => r.left < i.right && r.right > i.left && r.top < i.bottom && r.bottom > i.top;
105
108
  a.forEach((r, i) => {
106
- const c = Ct(r);
109
+ const c = kt(r);
107
110
  if (!c) return;
108
- const o = Y[i] || "rgba(255, 165, 0, 0.9)", n = document.createElement("div");
109
- n.style.position = "fixed", n.style.pointerEvents = "none", n.style.zIndex = "2147483646", n.style.left = `${c.left}px`, n.style.top = `${c.top}px`, n.style.width = `${c.width}px`, n.style.height = `${c.height}px`, n.style.boxSizing = "border-box", n.style.outline = `1px solid ${o}`, n.style.background = "transparent", document.body.appendChild(n);
110
- const s = document.createElement("div");
111
- s.style.position = "absolute", s.style.display = "inline-flex", s.style.alignItems = "center", s.style.gap = "6px", s.style.minWidth = "max-content", s.style.padding = "2px 6px", s.style.fontSize = "12px", s.style.lineHeight = "16px", s.style.color = "#fff", s.style.background = o, s.style.borderRadius = "4px", s.style.pointerEvents = "auto";
112
- const y = document.createElement("span");
113
- y.textContent = `组 ${i + 1}`;
114
- const h = document.createElement("button");
115
- h.textContent = I[i] ? "显示" : "隐藏", h.style.background = "rgba(0,0,0,0.15)", h.style.border = "none", h.style.color = "#fff", h.style.padding = "2px 6px", h.style.borderRadius = "3px", h.style.cursor = "pointer", h.onclick = (b) => {
116
- b.stopPropagation(), ot(i, !I[i]), N(), O();
117
- };
111
+ const s = H[i] || "rgba(255, 165, 0, 0.9)", n = document.createElement("div");
112
+ n.style.position = "fixed", n.style.pointerEvents = "none", n.style.zIndex = "2147483646", n.style.left = `${c.left}px`, n.style.top = `${c.top}px`, n.style.width = `${c.width}px`, n.style.height = `${c.height}px`, n.style.boxSizing = "border-box", n.style.outline = `1px solid ${s}`, n.style.background = "transparent", document.body.appendChild(n);
113
+ const l = document.createElement("div");
114
+ l.style.position = "absolute", l.style.display = "inline-grid", l.style.gridTemplateColumns = "1fr 1fr 1fr", l.style.gap = "2px", l.style.minWidth = "max-content", l.style.padding = "3px 4px", l.style.fontSize = "11px", l.style.lineHeight = "14px", l.style.color = "#fff", l.style.background = s, l.style.borderRadius = "4px", l.style.pointerEvents = "auto", l.style.opacity = "0.35", l.style.transition = "opacity 0.15s ease";
115
+ const f = document.createElement("span");
116
+ f.textContent = `${i + 1}`, f.style.position = "absolute", f.style.left = "0", f.style.top = "0", f.style.fontSize = "9px", f.style.lineHeight = "14px", f.style.minWidth = "14px", f.style.textAlign = "center", f.style.padding = "0 3px", f.style.background = s, f.style.color = "#fff", f.style.borderRadius = "0 0 4px 0", f.style.fontWeight = "bold", f.style.pointerEvents = "none", n.appendChild(f);
118
117
  const u = document.createElement("button");
119
- u.textContent = "取消组", u.style.background = "rgba(0,0,0,0.15)", u.style.border = "none", u.style.color = "#fff", u.style.padding = "2px 6px", u.style.borderRadius = "3px", u.style.cursor = "pointer", u.onclick = (b) => {
120
- b.stopPropagation(), ot(i, !1), Ft(i);
121
- }, s.appendChild(y), s.appendChild(h), s.appendChild(u);
122
- const d = (b) => {
123
- const l = c ? new DOMRect(c.left, c.top, c.width, c.height) : null;
124
- if (!l) return [];
125
- const f = [];
126
- return a.forEach((w, p) => {
127
- if (p === b) return;
128
- const v = Ct(w);
129
- if (!v) return;
130
- const S = new DOMRect(v.left, v.top, v.width, v.height);
131
- lt(l, S) && f.push(p);
132
- }), f;
118
+ u.textContent = I[i] ? "显示" : "隐藏", u.style.background = "rgba(0,0,0,0.15)", u.style.border = "none", u.style.color = "#fff", u.style.padding = "2px 4px", u.style.borderRadius = "3px", u.style.cursor = "pointer", u.style.fontSize = "10px", u.style.textAlign = "center", u.onclick = (v) => {
119
+ v.stopPropagation(), ct(i, !I[i]), N(), F();
120
+ };
121
+ const p = document.createElement("button");
122
+ p.textContent = "取消组", p.style.background = "rgba(0,0,0,0.15)", p.style.border = "none", p.style.color = "#fff", p.style.padding = "2px 4px", p.style.borderRadius = "3px", p.style.cursor = "pointer", p.style.fontSize = "10px", p.style.textAlign = "center", p.onclick = (v) => {
123
+ v.stopPropagation(), ct(i, !1), Dt(i);
124
+ }, l.appendChild(u), l.appendChild(p);
125
+ const d = (v) => {
126
+ const o = c ? new DOMRect(c.left, c.top, c.width, c.height) : null;
127
+ if (!o) return [];
128
+ const h = [];
129
+ return a.forEach((y, b) => {
130
+ if (b === v) return;
131
+ const w = kt(y);
132
+ if (!w) return;
133
+ const E = new DOMRect(w.left, w.top, w.width, w.height);
134
+ ft(o, E) && h.push(b);
135
+ }), h;
133
136
  };
134
137
  if ((() => {
135
138
  if (k !== i) return;
136
- const b = d(i);
137
- if (b.length === 0) return;
138
- const l = document.createElement("button");
139
- l.textContent = "合并", l.style.background = "rgba(0,0,0,0.15)", l.style.border = "none", l.style.color = "#fff", l.style.padding = "2px 6px", l.style.borderRadius = "3px", l.style.cursor = "pointer";
140
- const f = () => {
141
- const w = s.querySelector(".merge-panel");
142
- w && w.remove();
143
- const p = document.createElement("div");
144
- p.className = "merge-panel", p.style.position = "absolute", p.style.left = "0", p.style.top = "22px", p.style.minWidth = "160px", p.style.padding = "8px", p.style.background = "#fff", p.style.color = "#333", p.style.border = "1px solid rgba(0,0,0,0.15)", p.style.borderRadius = "6px", p.style.boxShadow = "0 4px 12px rgba(0,0,0,0.15)", p.style.pointerEvents = "auto", p.style.zIndex = "2147483647";
145
- const v = document.createElement("div");
146
- v.textContent = "选择要合并的组", v.style.fontSize = "12px", v.style.marginBottom = "6px", p.appendChild(v);
147
- const S = document.createElement("div");
148
- S.style.maxHeight = "200px", S.style.overflow = "auto";
149
- const L = [];
150
- b.forEach((z) => {
151
- const R = document.createElement("label");
152
- R.style.display = "flex", R.style.alignItems = "center", R.style.gap = "6px", R.style.fontSize = "12px", R.style.margin = "4px 0";
153
- const F = document.createElement("input");
154
- F.type = "checkbox", F.checked = !0, F.value = String(z);
155
- const J = document.createElement("span");
156
- J.textContent = `组 ${z + 1}`, R.appendChild(F), R.appendChild(J), S.appendChild(R), L.push(F);
157
- }), p.appendChild(S);
158
- const G = document.createElement("div");
159
- G.style.display = "flex", G.style.gap = "8px", G.style.marginTop = "8px";
160
- const E = document.createElement("button");
161
- E.textContent = "确认", E.style.padding = "2px 8px", E.style.cursor = "pointer";
162
- const M = document.createElement("button");
163
- M.textContent = "取消", M.style.padding = "2px 8px", M.style.cursor = "pointer", G.appendChild(E), G.appendChild(M), p.appendChild(G), M.onclick = (z) => {
164
- z.stopPropagation(), p.remove();
165
- }, E.onclick = (z) => {
166
- z.stopPropagation();
167
- const R = L.filter((C) => C.checked).map((C) => parseInt(C.value, 10)).filter((C) => !Number.isNaN(C));
168
- if (R.length === 0) {
169
- p.remove();
139
+ const v = d(i);
140
+ if (v.length === 0) return;
141
+ const o = document.createElement("button");
142
+ o.textContent = "合并", o.style.background = "rgba(0,0,0,0.15)", o.style.border = "none", o.style.color = "#fff", o.style.padding = "2px 4px", o.style.borderRadius = "3px", o.style.cursor = "pointer", o.style.fontSize = "10px", o.style.textAlign = "center";
143
+ const h = () => {
144
+ const y = l.querySelector(".merge-panel");
145
+ y && y.remove();
146
+ const b = document.createElement("div");
147
+ b.className = "merge-panel", b.style.position = "absolute", b.style.left = "0", b.style.top = "22px", b.style.minWidth = "160px", b.style.padding = "8px", b.style.background = "#fff", b.style.color = "#333", b.style.border = "1px solid rgba(0,0,0,0.15)", b.style.borderRadius = "6px", b.style.boxShadow = "0 4px 12px rgba(0,0,0,0.15)", b.style.pointerEvents = "auto", b.style.zIndex = "2147483647";
148
+ const w = document.createElement("div");
149
+ w.textContent = "选择要合并的组", w.style.fontSize = "12px", w.style.marginBottom = "6px", b.appendChild(w);
150
+ const E = document.createElement("div");
151
+ E.style.maxHeight = "200px", E.style.overflow = "auto";
152
+ const z = [];
153
+ v.forEach((T) => {
154
+ const G = document.createElement("label");
155
+ G.style.display = "flex", G.style.alignItems = "center", G.style.gap = "6px", G.style.fontSize = "12px", G.style.margin = "4px 0";
156
+ const Y = document.createElement("input");
157
+ Y.type = "checkbox", Y.checked = !0, Y.value = String(T);
158
+ const At = document.createElement("span");
159
+ At.textContent = `组 ${T + 1}`, G.appendChild(Y), G.appendChild(At), E.appendChild(G), z.push(Y);
160
+ }), b.appendChild(E);
161
+ const C = document.createElement("div");
162
+ C.style.display = "flex", C.style.gap = "8px", C.style.marginTop = "8px";
163
+ const R = document.createElement("button");
164
+ R.textContent = "确认", R.style.padding = "2px 8px", R.style.cursor = "pointer";
165
+ const P = document.createElement("button");
166
+ P.textContent = "取消", P.style.padding = "2px 8px", P.style.cursor = "pointer", C.appendChild(R), C.appendChild(P), b.appendChild(C), P.onclick = (T) => {
167
+ T.stopPropagation(), b.remove();
168
+ }, R.onclick = (T) => {
169
+ T.stopPropagation();
170
+ const G = z.filter((S) => S.checked).map((S) => parseInt(S.value, 10)).filter((S) => !Number.isNaN(S));
171
+ if (G.length === 0) {
172
+ b.remove();
170
173
  return;
171
174
  }
172
- const F = /* @__PURE__ */ new Set();
173
- (a[i] || []).forEach((C) => F.add(C)), R.forEach((C) => {
174
- (a[C] || []).forEach((ie) => F.add(ie));
175
- }), a[i] = Array.from(F);
176
- const re = [...R].sort((C, ct) => ct - C);
177
- let $t = i;
178
- re.forEach((C) => {
179
- C < 0 || C >= a.length || C === i || (ot(C, !1), a.splice(C, 1), I.splice(C, 1), Y.splice(C, 1), k !== null && (k === C ? k = null : k > C && k--), C < $t && $t--);
180
- }), k = $t;
181
- const Ut = /* @__PURE__ */ new Set();
182
- a.forEach((C) => C.forEach((ct) => Ut.add(ct))), A(Ut), N(), p.remove(), O();
183
- }, s.appendChild(p);
175
+ const Y = /* @__PURE__ */ new Set();
176
+ (a[i] || []).forEach((S) => Y.add(S)), G.forEach((S) => {
177
+ (a[S] || []).forEach((de) => Y.add(de));
178
+ }), a[i] = Array.from(Y);
179
+ const he = [...G].sort((S, ht) => ht - S);
180
+ let Lt = i;
181
+ he.forEach((S) => {
182
+ S < 0 || S >= a.length || S === i || (ct(S, !1), a.splice(S, 1), I.splice(S, 1), H.splice(S, 1), U.length > S && U.splice(S, 1), k !== null && (k === S ? k = null : k > S && k--), S < Lt && Lt--);
183
+ }), k = Lt;
184
+ const _t = /* @__PURE__ */ new Set();
185
+ a.forEach((S) => S.forEach((ht) => _t.add(ht))), O(_t), N(), b.remove(), F();
186
+ }, l.appendChild(b);
184
187
  };
185
- l.onclick = (w) => {
186
- w.stopPropagation(), f();
187
- }, s.appendChild(l);
188
- })(), n.appendChild(s), yt && yt.length) {
189
- const b = (l) => {
190
- const f = document.createElement("button"), w = {
191
- label: l.label || "按钮",
192
- title: l.title || ""
193
- }, p = () => {
194
- f.textContent = w.label || "", f.title = w.title || "";
188
+ o.onclick = (y) => {
189
+ y.stopPropagation(), h();
190
+ }, l.appendChild(o);
191
+ })(), n.appendChild(l), M && M.length) {
192
+ const v = (o, h) => {
193
+ const y = document.createElement("button"), b = Q(i);
194
+ if (!b) return;
195
+ const w = b[h] ?? (b[h] = {
196
+ label: o.label || "按钮",
197
+ title: o.title || ""
198
+ }), E = () => {
199
+ y.textContent = w.label || "", y.title = w.title || "";
195
200
  };
196
- p(), f.style.background = "rgba(0,0,0,0.15)", f.style.border = "none", f.style.color = "#fff", f.style.padding = "2px 6px", f.style.borderRadius = "3px", f.style.cursor = "pointer", l.className && (f.className += (f.className ? " " : "") + l.className), f.onclick = (v) => {
197
- var G;
198
- v.stopPropagation();
199
- const S = {
201
+ E(), y.style.background = "rgba(0,0,0,0.15)", y.style.border = "none", y.style.color = "#fff", y.style.padding = "2px 4px", y.style.borderRadius = "3px", y.style.cursor = "pointer", y.style.fontSize = "10px", y.style.textAlign = "center", o.className && (y.className += (y.className ? " " : "") + o.className), y.onclick = (z) => {
202
+ var P;
203
+ z.stopPropagation();
204
+ const C = {
200
205
  index: i,
201
206
  group: a[i] || [],
202
- controller: Nt,
203
- getSnapshot: () => it(),
207
+ controller: Tt,
208
+ getSnapshot: () => ut(),
204
209
  refresh: () => {
205
- N(), O();
210
+ N(), F();
206
211
  },
207
- mouseX: v.clientX,
208
- mouseY: v.clientY,
209
- anchorRect: s.getBoundingClientRect(),
210
- anchorEl: s,
212
+ mouseX: z.clientX,
213
+ mouseY: z.clientY,
214
+ anchorRect: l.getBoundingClientRect(),
215
+ anchorEl: l,
211
216
  overlayEl: n,
212
217
  label: w.label,
213
218
  title: w.title,
214
- buttonEl: f
215
- }, L = (E) => {
216
- Object.defineProperty(S, E, {
219
+ buttonEl: y
220
+ }, R = (T) => {
221
+ Object.defineProperty(C, T, {
217
222
  configurable: !0,
218
- get: () => w[E],
219
- set: (M) => {
220
- const z = M ?? "";
221
- w[E] !== z && (w[E] = z, p());
223
+ get: () => w[T],
224
+ set: (G) => {
225
+ const Y = G ?? "";
226
+ w[T] !== Y && (w[T] = Y, E());
222
227
  }
223
228
  });
224
229
  };
225
- L("label"), L("title");
230
+ R("label"), R("title");
226
231
  try {
227
- (G = l.onClick) == null || G.call(l, S);
232
+ (P = o.onClick) == null || P.call(o, C);
228
233
  } catch {
229
234
  }
230
- }, s.appendChild(f);
235
+ }, l.appendChild(y);
231
236
  };
232
- yt.forEach(b);
237
+ M.forEach(
238
+ (o, h) => v(o, h)
239
+ );
233
240
  }
234
241
  (() => {
235
- const b = [
242
+ const v = [
236
243
  "tl",
237
244
  "tr",
238
245
  "bl",
239
246
  "br"
240
- ], l = s.style.visibility;
241
- s.style.visibility = "hidden";
242
- const f = 28, w = 6;
243
- t: for (let p = 0; p < b.length; p++)
244
- for (let v = 0; v < 6; v++) {
245
- s.style.left = "", s.style.right = "", s.style.top = "", s.style.bottom = "";
246
- const S = s.offsetHeight || 22;
247
- b[p] === "tl" ? (s.style.left = "0", s.style.top = `${-S - w + v * f}px`) : b[p] === "tr" ? (s.style.right = "0", s.style.top = `${-S - w + v * f}px`) : b[p] === "bl" ? (s.style.left = "0", s.style.top = `${c.height + w + v * f}px`) : (s.style.right = "0", s.style.top = `${c.height + w + v * f}px`);
248
- const L = s.getBoundingClientRect(), G = {
249
- left: L.left,
250
- top: L.top,
251
- right: L.right,
252
- bottom: L.bottom
247
+ ], o = l.style.visibility;
248
+ l.style.visibility = "hidden";
249
+ const h = 28, y = 6;
250
+ t: for (let b = 0; b < v.length; b++)
251
+ for (let w = 0; w < 6; w++) {
252
+ l.style.left = "", l.style.right = "", l.style.top = "", l.style.bottom = "";
253
+ const E = l.offsetHeight || 22;
254
+ v[b] === "tl" ? (l.style.left = "0", l.style.top = `${-E - y + w * h}px`) : v[b] === "tr" ? (l.style.right = "0", l.style.top = `${-E - y + w * h}px`) : v[b] === "bl" ? (l.style.left = "0", l.style.top = `${c.height + y + w * h}px`) : (l.style.right = "0", l.style.top = `${c.height + y + w * h}px`);
255
+ const z = l.getBoundingClientRect(), C = {
256
+ left: z.left,
257
+ top: z.top,
258
+ right: z.right,
259
+ bottom: z.bottom
253
260
  };
254
- let E = !1;
255
- for (const M of t)
256
- if (e(G, M)) {
257
- E = !0;
261
+ let R = !1;
262
+ for (const P of t)
263
+ if (e(C, P)) {
264
+ R = !0;
258
265
  break;
259
266
  }
260
- if (!E) {
261
- t.push(G);
267
+ if (!R) {
268
+ t.push(C);
262
269
  break t;
263
270
  }
264
271
  }
265
- s.style.visibility = l;
266
- })(), s.addEventListener("mouseenter", () => {
272
+ l.style.visibility = o;
273
+ })();
274
+ const x = () => {
275
+ l.style.opacity = "1";
276
+ }, X = () => {
277
+ l.style.opacity = "0.35";
278
+ };
279
+ l.addEventListener("mouseenter", () => {
280
+ x();
267
281
  try {
268
- nt.forEach((b) => b.style.zIndex = "2147483646"), n.style.zIndex = "2147483647";
282
+ it.forEach((v) => v.style.zIndex = "2147483646"), n.style.zIndex = "2147483647";
269
283
  } catch {
270
284
  }
285
+ }), l.addEventListener("mouseleave", X);
286
+ const A = document.createElement("div");
287
+ A.style.position = "absolute", A.style.inset = "0", A.style.pointerEvents = "auto", A.style.background = "transparent", A.style.zIndex = "0", n.appendChild(A), A.addEventListener("mouseenter", x), A.addEventListener("mouseleave", () => {
288
+ setTimeout(() => {
289
+ !l.matches(":hover") && !A.matches(":hover") && X();
290
+ }, 100);
271
291
  });
272
- const x = (b) => {
273
- const l = document.createElement("div");
274
- l.style.position = "absolute", l.style.pointerEvents = "auto", l.style.background = "transparent", l.style.zIndex = "2147483647";
275
- const f = 8;
276
- b === "top" ? (l.style.cursor = "ns-resize", l.style.left = "-4px", l.style.right = "-4px", l.style.top = `-${f / 2 | 0}px`, l.style.height = `${f}px`) : b === "bottom" ? (l.style.cursor = "ns-resize", l.style.left = "-4px", l.style.right = "-4px", l.style.bottom = `-${f / 2 | 0}px`, l.style.height = `${f}px`) : b === "left" ? (l.style.cursor = "ew-resize", l.style.top = "-4px", l.style.bottom = "-4px", l.style.left = `-${f / 2 | 0}px`, l.style.width = `${f}px`) : b === "right" ? (l.style.cursor = "ew-resize", l.style.top = "-4px", l.style.bottom = "-4px", l.style.right = `-${f / 2 | 0}px`, l.style.width = `${f}px`) : b === "nw" ? (l.style.cursor = "nwse-resize", l.style.left = `-${f / 2 | 0}px`, l.style.top = `-${f / 2 | 0}px`, l.style.width = `${f}px`, l.style.height = `${f}px`) : b === "ne" ? (l.style.cursor = "nesw-resize", l.style.right = `-${f / 2 | 0}px`, l.style.top = `-${f / 2 | 0}px`, l.style.width = `${f}px`, l.style.height = `${f}px`) : b === "sw" ? (l.style.cursor = "nesw-resize", l.style.left = `-${f / 2 | 0}px`, l.style.bottom = `-${f / 2 | 0}px`, l.style.width = `${f}px`, l.style.height = `${f}px`) : b === "se" && (l.style.cursor = "nwse-resize", l.style.right = `-${f / 2 | 0}px`, l.style.bottom = `-${f / 2 | 0}px`, l.style.width = `${f}px`, l.style.height = `${f}px`), l.onmousedown = (w) => {
277
- w.preventDefault(), w.stopPropagation();
278
- const p = {
292
+ const L = (v) => {
293
+ const o = document.createElement("div");
294
+ o.style.position = "absolute", o.style.pointerEvents = "auto", o.style.background = "transparent", o.style.zIndex = "2147483647";
295
+ const h = 8;
296
+ v === "top" ? (o.style.cursor = "ns-resize", o.style.left = "-4px", o.style.right = "-4px", o.style.top = `-${h / 2 | 0}px`, o.style.height = `${h}px`) : v === "bottom" ? (o.style.cursor = "ns-resize", o.style.left = "-4px", o.style.right = "-4px", o.style.bottom = `-${h / 2 | 0}px`, o.style.height = `${h}px`) : v === "left" ? (o.style.cursor = "ew-resize", o.style.top = "-4px", o.style.bottom = "-4px", o.style.left = `-${h / 2 | 0}px`, o.style.width = `${h}px`) : v === "right" ? (o.style.cursor = "ew-resize", o.style.top = "-4px", o.style.bottom = "-4px", o.style.right = `-${h / 2 | 0}px`, o.style.width = `${h}px`) : v === "nw" ? (o.style.cursor = "nwse-resize", o.style.left = `-${h / 2 | 0}px`, o.style.top = `-${h / 2 | 0}px`, o.style.width = `${h}px`, o.style.height = `${h}px`) : v === "ne" ? (o.style.cursor = "nesw-resize", o.style.right = `-${h / 2 | 0}px`, o.style.top = `-${h / 2 | 0}px`, o.style.width = `${h}px`, o.style.height = `${h}px`) : v === "sw" ? (o.style.cursor = "nesw-resize", o.style.left = `-${h / 2 | 0}px`, o.style.bottom = `-${h / 2 | 0}px`, o.style.width = `${h}px`, o.style.height = `${h}px`) : v === "se" && (o.style.cursor = "nwse-resize", o.style.right = `-${h / 2 | 0}px`, o.style.bottom = `-${h / 2 | 0}px`, o.style.width = `${h}px`, o.style.height = `${h}px`), o.onmousedown = (y) => {
297
+ y.preventDefault(), y.stopPropagation();
298
+ const b = {
279
299
  left: parseFloat(n.style.left || "0"),
280
300
  top: parseFloat(n.style.top || "0"),
281
301
  width: parseFloat(n.style.width || "0"),
282
302
  height: parseFloat(n.style.height || "0")
283
303
  };
284
- D = {
304
+ j = {
285
305
  idx: i,
286
- side: b,
287
- startX: w.clientX,
288
- startY: w.clientY,
289
- startRect: p,
306
+ side: v,
307
+ startX: y.clientX,
308
+ startY: y.clientY,
309
+ startRect: b,
290
310
  overlay: n
291
- }, document.addEventListener("mousemove", zt), document.addEventListener("mouseup", oe, { once: !0 });
292
- }, n.appendChild(l);
311
+ }, document.addEventListener("mousemove", Rt), document.addEventListener("mouseup", ae, { once: !0 });
312
+ }, n.appendChild(o);
293
313
  };
294
- x("top"), x("right"), x("bottom"), x("left"), x("nw"), x("ne"), x("sw"), x("se"), Mt && n.classList.add(Mt), nt.push(n);
314
+ L("top"), L("right"), L("bottom"), L("left"), L("nw"), L("ne"), L("sw"), L("se"), It && n.classList.add(It), it.push(n);
295
315
  });
296
- }, zt = (t) => {
297
- if (!D) return;
298
- const { idx: e, side: r, startX: i, startY: c, startRect: o, overlay: n } = D, s = t.clientX - i, y = t.clientY - c;
299
- let h = o.left, u = o.top, d = o.width, g = o.height;
316
+ }, Rt = (t) => {
317
+ if (!j) return;
318
+ const { idx: e, side: r, startX: i, startY: c, startRect: s, overlay: n } = j, l = t.clientX - i, f = t.clientY - c;
319
+ let u = s.left, p = s.top, d = s.width, g = s.height;
300
320
  const m = 4;
301
- r === "left" || r === "nw" || r === "sw" ? (h = o.left + s, d = o.width - s, d < m && (h = o.left + (o.width - m), d = m)) : (r === "right" || r === "ne" || r === "se") && (d = o.width + s, d < m && (d = m)), r === "top" || r === "nw" || r === "ne" ? (u = o.top + y, g = o.height - y, g < m && (u = o.top + (o.height - m), g = m)) : (r === "bottom" || r === "sw" || r === "se") && (g = o.height + y, g < m && (g = m)), n.style.left = `${h}px`, n.style.top = `${u}px`, n.style.width = `${d}px`, n.style.height = `${g}px`;
302
- const x = _(h, u, d, g), b = new Set(a[e] || []), l = /* @__PURE__ */ new Set();
303
- a.forEach((E, M) => {
304
- M !== e && E.forEach((z) => l.add(z));
321
+ r === "left" || r === "nw" || r === "sw" ? (u = s.left + l, d = s.width - l, d < m && (u = s.left + (s.width - m), d = m)) : (r === "right" || r === "ne" || r === "se") && (d = s.width + l, d < m && (d = m)), r === "top" || r === "nw" || r === "ne" ? (p = s.top + f, g = s.height - f, g < m && (p = s.top + (s.height - m), g = m)) : (r === "bottom" || r === "sw" || r === "se") && (g = s.height + f, g < m && (g = m)), n.style.left = `${u}px`, n.style.top = `${p}px`, n.style.width = `${d}px`, n.style.height = `${g}px`;
322
+ const x = nt(u, p, d, g), X = new Set(a[e] || []), A = /* @__PURE__ */ new Set();
323
+ a.forEach((E, z) => {
324
+ z !== e && E.forEach((C) => A.add(C));
305
325
  });
306
- const f = new Set(x);
307
- let w = !1, p = !1;
326
+ const L = new Set(x);
327
+ let v = !1, o = !1;
308
328
  for (let E = 0; E < a.length; E++) {
309
329
  if (E === e) continue;
310
- const M = new Set(a[E] || []);
311
- let z = 0;
312
- for (const R of f) M.has(R) && z++;
313
- if (z !== 0 && !(z === M.size && z === f.size))
314
- if (z === M.size)
315
- p = !0;
316
- else if (z === f.size)
317
- p = !0;
330
+ const z = new Set(a[E] || []);
331
+ let C = 0;
332
+ for (const R of L) z.has(R) && C++;
333
+ if (C !== 0 && !(C === z.size && C === L.size))
334
+ if (C === z.size)
335
+ o = !0;
336
+ else if (C === L.size)
337
+ o = !0;
318
338
  else {
319
- w = !0;
339
+ v = !0;
320
340
  break;
321
341
  }
322
342
  }
323
- const v = x.filter((E) => !b.has(E)).length, S = !X && (w || !T && p), L = !H && v > 0;
324
- if (S || L) {
343
+ const h = x.filter((E) => !X.has(E)).length, y = !V && (v || !K && o), b = !W && h > 0;
344
+ if (y || b) {
325
345
  n.style.outline = "1px dashed #ff4d4f", n.style.background = "rgba(255,77,79,0.06)";
326
346
  const E = /* @__PURE__ */ new Set();
327
- a.forEach((M, z) => {
328
- (z === e ? a[e] || [] : M).forEach((F) => E.add(F));
329
- }), A(E);
347
+ a.forEach((z, C) => {
348
+ (C === e ? a[e] || [] : z).forEach((P) => E.add(P));
349
+ }), O(E);
330
350
  } else {
331
- const E = Y[e] || "rgba(255, 165, 0, 0.9)";
351
+ const E = H[e] || "rgba(255, 165, 0, 0.9)";
332
352
  n.style.outline = `1px solid ${E}`, n.style.background = "transparent";
333
- const M = /* @__PURE__ */ new Set();
334
- a.forEach((z, R) => {
335
- (R === e ? x : z).forEach((J) => M.add(J));
336
- }), A(M);
353
+ const z = /* @__PURE__ */ new Set();
354
+ a.forEach((C, R) => {
355
+ (R === e ? x : C).forEach((T) => z.add(T));
356
+ }), O(z);
337
357
  }
338
- }, oe = (t) => {
339
- if (!D) return;
340
- const { idx: e, overlay: r, startRect: i } = D, c = parseFloat(r.style.left || "0"), o = parseFloat(r.style.top || "0"), n = parseFloat(r.style.width || "0"), s = parseFloat(r.style.height || "0"), y = _(c, o, n, s), h = new Set(a[e] || []), u = /* @__PURE__ */ new Set();
341
- a.forEach((p, v) => {
342
- v !== e && p.forEach((S) => u.add(S));
358
+ }, ae = (t) => {
359
+ if (!j) return;
360
+ const { idx: e, overlay: r, startRect: i } = j, c = parseFloat(r.style.left || "0"), s = parseFloat(r.style.top || "0"), n = parseFloat(r.style.width || "0"), l = parseFloat(r.style.height || "0"), f = nt(c, s, n, l), u = new Set(a[e] || []), p = /* @__PURE__ */ new Set();
361
+ a.forEach((o, h) => {
362
+ h !== e && o.forEach((y) => p.add(y));
343
363
  });
344
- const d = new Set(y);
364
+ const d = new Set(f);
345
365
  let g = !1, m = !1;
346
- for (let p = 0; p < a.length; p++) {
347
- if (p === e) continue;
348
- const v = new Set(a[p] || []);
349
- let S = 0;
350
- for (const L of d) v.has(L) && S++;
351
- if (S !== 0 && !(S === v.size && S === d.size))
352
- if (S === v.size || S === d.size)
366
+ for (let o = 0; o < a.length; o++) {
367
+ if (o === e) continue;
368
+ const h = new Set(a[o] || []);
369
+ let y = 0;
370
+ for (const b of d) h.has(b) && y++;
371
+ if (y !== 0 && !(y === h.size && y === d.size))
372
+ if (y === h.size || y === d.size)
353
373
  m = !0;
354
374
  else {
355
375
  g = !0;
356
376
  break;
357
377
  }
358
378
  }
359
- const x = y.filter((p) => !h.has(p)).length, b = !X && (g || !T && m), l = !H && x > 0;
360
- if (b || l) {
361
- const p = /* @__PURE__ */ new Set();
362
- a.forEach((v) => v.forEach((S) => p.add(S))), A(p), N(), D = null, document.removeEventListener("mousemove", zt), O();
379
+ const x = f.filter((o) => !u.has(o)).length, X = !V && (g || !K && m), A = !W && x > 0;
380
+ if (X || A) {
381
+ const o = /* @__PURE__ */ new Set();
382
+ a.forEach((h) => h.forEach((y) => o.add(y))), O(o), N(), j = null, document.removeEventListener("mousemove", Rt), F();
363
383
  return;
364
384
  }
365
- a[e] = y;
366
- const w = /* @__PURE__ */ new Set();
367
- a.forEach((p) => p.forEach((v) => w.add(v))), A(w), N(), D = null, document.removeEventListener("mousemove", zt), O();
368
- }, Ft = (t) => {
385
+ a[e] = f;
386
+ const v = /* @__PURE__ */ new Set();
387
+ a.forEach((o) => o.forEach((h) => v.add(h))), O(v), N(), j = null, document.removeEventListener("mousemove", Rt), F();
388
+ }, Dt = (t) => {
369
389
  if (t < 0 || t >= a.length) return !1;
370
390
  const e = a[t];
371
- e && e.forEach((i) => i.style.visibility = ""), a.splice(t, 1), I.splice(t, 1), Y.splice(t, 1), k !== null && (k === t ? k = null : k > t && k--), K(), N();
391
+ e && e.forEach((i) => i.style.visibility = ""), a.splice(t, 1), I.splice(t, 1), H.splice(t, 1), U.length > t && U.splice(t, 1), k !== null && (k === t ? k = null : k > t && k--), et(), N();
372
392
  const r = /* @__PURE__ */ new Set();
373
- return a.forEach((i) => i.forEach((c) => r.add(c))), A(r), O(), !0;
374
- }, se = (t) => {
393
+ return a.forEach((i) => i.forEach((c) => r.add(c))), O(r), F(), !0;
394
+ }, fe = (t, e, r) => {
395
+ if (!q || !M || M.length === 0 || t < 0 || t >= a.length || e < 0 || e >= M.length) return !1;
396
+ const i = Q(t);
397
+ if (!i) return !1;
398
+ const c = i[e];
399
+ if (!c) return !1;
400
+ let s = !1;
401
+ if (r.label !== void 0) {
402
+ const n = r.label ?? "";
403
+ c.label !== n && (c.label = n, s = !0);
404
+ }
405
+ if (r.title !== void 0) {
406
+ const n = r.title ?? "";
407
+ c.title !== n && (c.title = n, s = !0);
408
+ }
409
+ return s && N(), s;
410
+ }, pe = (t) => {
375
411
  if (!q || !Array.isArray(t) || t.length === 0) return !1;
376
- const e = Array.from(new Set(t)).filter((u) => {
412
+ const e = Array.from(new Set(t)).filter((p) => {
377
413
  var d;
378
414
  try {
379
- return !!u && B.contains(u) && !gt(u) && ((d = u.matches) == null ? void 0 : d.call(u, at));
415
+ return !!p && B.contains(p) && !xt(p) && ((d = p.matches) == null ? void 0 : d.call(p, dt));
380
416
  } catch {
381
417
  return !1;
382
418
  }
383
419
  });
384
- if (e.length === 0 || St(e) !== null) return !1;
420
+ if (e.length === 0 || Mt(e) !== null) return !1;
385
421
  const i = new Set(e);
386
- let c = !1, o = !1;
387
- for (const u of a) {
388
- const d = new Set(u);
422
+ let c = !1, s = !1;
423
+ for (const p of a) {
424
+ const d = new Set(p);
389
425
  let g = 0;
390
426
  for (const m of i) d.has(m) && g++;
391
427
  if (g !== 0 && !(g === d.size && g === i.size))
392
428
  if (g === d.size || g === i.size)
393
- o = !0;
429
+ s = !0;
394
430
  else {
395
431
  c = !0;
396
432
  break;
397
433
  }
398
434
  }
399
- const n = new Set(P), s = !X && (c || !T && o), y = !H && n.size > 0 && e.length > 0;
400
- if (s || y) return !1;
401
- a.push(e), I.push(!1), Y.push(wt()), k = a.length - 1;
402
- const h = /* @__PURE__ */ new Set();
403
- return a.forEach((u) => u.forEach((d) => h.add(d))), A(h), N(), O(), !0;
404
- }, le = (t) => {
435
+ const n = new Set(D), l = !V && (c || !K && s), f = !W && n.size > 0 && e.length > 0;
436
+ if (l || f) return !1;
437
+ a.push(e), I.push(!1), H.push(zt()), M != null && M.length && Q(a.length - 1), k = a.length - 1;
438
+ const u = /* @__PURE__ */ new Set();
439
+ return a.forEach((p) => p.forEach((d) => u.add(d))), O(u), N(), F(), !0;
440
+ }, ue = (t) => {
405
441
  if (q) return "add";
406
- const e = kt ? ht ?? "add" : "replace";
407
- return kt ? ht === "auto" ? t.shiftKey ? "add" : t.altKey ? "subtract" : t.metaKey || t.ctrlKey ? "toggle" : "add" : ht ?? e : "replace";
408
- }, A = (t) => {
409
- for (const e of Array.from(P))
410
- t.has(e) || e.classList.remove(Z);
442
+ const e = Nt ? bt ?? "add" : "replace";
443
+ return Nt ? bt === "auto" ? t.shiftKey ? "add" : t.altKey ? "subtract" : t.metaKey || t.ctrlKey ? "toggle" : "add" : bt ?? e : "replace";
444
+ }, O = (t) => {
445
+ for (const e of Array.from(D))
446
+ t.has(e) || e.classList.remove(st);
411
447
  for (const e of Array.from(t))
412
- P.has(e) || e.classList.add(Z);
413
- P = t, ut && ut(q ? {
448
+ D.has(e) || e.classList.add(st);
449
+ D = t, gt && gt(q ? {
414
450
  type: "groups",
415
451
  groups: a.slice(),
416
- flat: Array.from(P)
417
- } : { type: "single", selected: Array.from(P) });
418
- }, qt = (t, e, r) => {
452
+ flat: Array.from(D)
453
+ } : { type: "single", selected: Array.from(D) });
454
+ }, Xt = (t, e, r) => {
419
455
  if (r === "replace") return new Set(e);
420
456
  const i = new Set(t);
421
457
  if (r === "add")
@@ -426,212 +462,212 @@ function ce(jt) {
426
462
  for (const c of e)
427
463
  i.has(c) ? i.delete(c) : i.add(c);
428
464
  return i;
429
- }, Pt = (t) => {
465
+ }, Ht = (t) => {
430
466
  if (t.button !== 0) return;
431
467
  const e = t.target;
432
- !B.contains(e) && e !== document.body || (mt = t.clientX, bt = t.clientY, j = !0, $ = Zt(), vt = le(t), U = new Set(P), t.preventDefault());
433
- }, Yt = (t) => {
468
+ !B.contains(e) && e !== document.body || (wt = t.clientX, Et = t.clientY, J = !0, $ = le(), Ct = ue(t), _ = new Set(D), t.preventDefault());
469
+ }, Ut = (t) => {
434
470
  var g;
435
- if (!j && et) {
436
- const m = t.target, x = (g = m == null ? void 0 : m.closest) == null ? void 0 : g.call(m, at);
437
- x && B.contains(x) && !gt(x) ? st(x) : st(null);
471
+ if (!J && rt) {
472
+ const m = t.target, x = (g = m == null ? void 0 : m.closest) == null ? void 0 : g.call(m, dt);
473
+ x && B.contains(x) && !xt(x) ? at(x) : at(null);
438
474
  }
439
- if (!j || !$) return;
440
- const { left: e, top: r, width: i, height: c } = Bt(
441
- mt,
442
- bt,
475
+ if (!J || !$) return;
476
+ const { left: e, top: r, width: i, height: c } = Yt(
477
+ wt,
478
+ Et,
443
479
  t.clientX,
444
480
  t.clientY
445
481
  );
446
482
  $.style.left = `${e}px`, $.style.top = `${r}px`, $.style.width = `${i}px`, $.style.height = `${c}px`;
447
- const o = _(e, r, i, c), n = U ?? /* @__PURE__ */ new Set(), s = new Set(o);
448
- let y = 0;
449
- for (const m of s) n.has(m) && y++;
450
- let h = "disjoint";
451
- y === 0 ? h = "disjoint" : y === s.size && y === n.size ? h = "equal" : y === s.size || y === n.size ? h = "containment" : h = "partial";
452
- const u = !X && (h === "partial" || !T && h === "containment"), d = !H && n.size > 0 && o.length > 0;
453
- if (xt = u || d, $ && (xt ? ($.style.outline = "1px dashed #ff4d4f", $.style.background = "rgba(255,77,79,0.12)") : ($.style.outline = "1px dashed #268aff", $.style.background = "rgba(38,138,255,0.12)")), xt)
454
- A(n);
483
+ const s = nt(e, r, i, c), n = _ ?? /* @__PURE__ */ new Set(), l = new Set(s);
484
+ let f = 0;
485
+ for (const m of l) n.has(m) && f++;
486
+ let u = "disjoint";
487
+ f === 0 ? u = "disjoint" : f === l.size && f === n.size ? u = "equal" : f === l.size || f === n.size ? u = "containment" : u = "partial";
488
+ const p = !V && (u === "partial" || !K && u === "containment"), d = !W && n.size > 0 && s.length > 0;
489
+ if (St = p || d, $ && (St ? ($.style.outline = "1px dashed #ff4d4f", $.style.background = "rgba(255,77,79,0.12)") : ($.style.outline = "1px dashed #268aff", $.style.background = "rgba(38,138,255,0.12)")), St)
490
+ O(n);
455
491
  else {
456
- const m = qt(n, o, vt);
457
- A(m);
492
+ const m = Xt(n, s, Ct);
493
+ O(m);
458
494
  }
459
- }, Dt = (t) => {
460
- if (!j) return;
461
- j = !1, $ && $.parentNode && $.parentNode.removeChild($), $ = null;
462
- const { left: e, top: r, width: i, height: c } = Bt(
463
- mt,
464
- bt,
495
+ }, jt = (t) => {
496
+ if (!J) return;
497
+ J = !1, $ && $.parentNode && $.parentNode.removeChild($), $ = null;
498
+ const { left: e, top: r, width: i, height: c } = Yt(
499
+ wt,
500
+ Et,
465
501
  t.clientX,
466
502
  t.clientY
467
- ), o = _(e, r, i, c), n = U ?? /* @__PURE__ */ new Set(), s = new Set(o);
468
- let y = 0;
469
- for (const x of s) n.has(x) && y++;
470
- let h = "disjoint";
471
- y === 0 ? h = "disjoint" : y === s.size && y === n.size ? h = "equal" : y === s.size || y === n.size ? h = "containment" : h = "partial";
472
- const u = !X && (h === "partial" || !T && h === "containment"), d = !H && n.size > 0 && o.length > 0;
473
- if (u || d) {
474
- A(n), U = null, O();
503
+ ), s = nt(e, r, i, c), n = _ ?? /* @__PURE__ */ new Set(), l = new Set(s);
504
+ let f = 0;
505
+ for (const x of l) n.has(x) && f++;
506
+ let u = "disjoint";
507
+ f === 0 ? u = "disjoint" : f === l.size && f === n.size ? u = "equal" : f === l.size || f === n.size ? u = "containment" : u = "partial";
508
+ const p = !V && (u === "partial" || !K && u === "containment"), d = !W && n.size > 0 && s.length > 0;
509
+ if (p || d) {
510
+ O(n), _ = null, F();
475
511
  return;
476
512
  }
477
- const m = qt(n, o, vt);
478
- if (A(m), q && o.length > 0) {
479
- const x = St(o);
513
+ const m = Xt(n, s, Ct);
514
+ if (O(m), q && s.length > 0) {
515
+ const x = Mt(s);
480
516
  if (x !== null) {
481
517
  try {
482
518
  console.warn(`重复编组被阻止:与已存在的第${x + 1}组元素完全一致`);
483
519
  } catch {
484
520
  }
485
- U = null, O();
521
+ _ = null, F();
486
522
  return;
487
523
  }
488
- a.push(o), k = a.length - 1, I.push(!1), Y.push(wt());
489
- const b = /* @__PURE__ */ new Set();
490
- a.forEach((l) => l.forEach((f) => b.add(f))), A(b), N();
524
+ a.push(s), k = a.length - 1, I.push(!1), H.push(zt()), M != null && M.length && Q(a.length - 1);
525
+ const X = /* @__PURE__ */ new Set();
526
+ a.forEach((A) => A.forEach((L) => X.add(L))), O(X), N();
491
527
  }
492
- U = null, O();
493
- }, Xt = (t) => {
528
+ _ = null, F();
529
+ }, Vt = (t) => {
494
530
  var m;
495
- if (!dt || !q) return;
531
+ if (!vt || !q) return;
496
532
  const e = t.target;
497
533
  if (!e) return;
498
534
  let r = e;
499
- if (At && (r = ((m = e.closest) == null ? void 0 : m.call(e, At)) || null), !r || !B.contains(r)) return;
500
- const i = r.getBoundingClientRect(), c = _(i.left, i.top, i.width, i.height), o = new Set(P), n = new Set(c);
501
- let s = 0;
502
- for (const x of n) o.has(x) && s++;
503
- let y = "disjoint";
504
- s === 0 ? y = "disjoint" : s === n.size && s === o.size ? y = "equal" : s === n.size || s === o.size ? y = "containment" : y = "partial";
505
- const h = !X && (y === "partial" || !T && y === "containment"), u = !H && o.size > 0 && c.length > 0;
506
- if (c.length === 0 || h || u) {
507
- O();
535
+ if (Ft && (r = ((m = e.closest) == null ? void 0 : m.call(e, Ft)) || null), !r || !B.contains(r)) return;
536
+ const i = r.getBoundingClientRect(), c = nt(i.left, i.top, i.width, i.height), s = new Set(D), n = new Set(c);
537
+ let l = 0;
538
+ for (const x of n) s.has(x) && l++;
539
+ let f = "disjoint";
540
+ l === 0 ? f = "disjoint" : l === n.size && l === s.size ? f = "equal" : l === n.size || l === s.size ? f = "containment" : f = "partial";
541
+ const u = !V && (f === "partial" || !K && f === "containment"), p = !W && s.size > 0 && c.length > 0;
542
+ if (c.length === 0 || u || p) {
543
+ F();
508
544
  return;
509
545
  }
510
- const d = St(c);
546
+ const d = Mt(c);
511
547
  if (d !== null) {
512
548
  try {
513
549
  console.warn(`重复编组被阻止:与已存在的第${d + 1}组元素完全一致`);
514
550
  } catch {
515
551
  }
516
- O();
552
+ F();
517
553
  return;
518
554
  }
519
- a.push(c), k = a.length - 1, I.push(!1), Y.push(wt());
555
+ a.push(c), k = a.length - 1, I.push(!1), H.push(zt()), M != null && M.length && Q(a.length - 1);
520
556
  const g = /* @__PURE__ */ new Set();
521
- a.forEach((x) => x.forEach((b) => g.add(b))), A(g), N(), O();
522
- }, Ht = () => st(null);
523
- function _(t, e, r, i) {
557
+ a.forEach((x) => x.forEach((X) => g.add(X))), O(g), N(), F();
558
+ }, Wt = () => at(null);
559
+ function nt(t, e, r, i) {
524
560
  if (r === 0 || i === 0) return [];
525
- const c = B.getBoundingClientRect(), o = new DOMRect(t, e, r, i);
526
- if (!lt(o, c)) return [];
527
- const n = Array.from(B.querySelectorAll(at));
528
- let s = [];
529
- const y = /* @__PURE__ */ new Map();
530
- for (const u of n) {
531
- if (gt(u)) continue;
532
- const d = u.getBoundingClientRect();
533
- if (!lt(d, c)) continue;
561
+ const c = B.getBoundingClientRect(), s = new DOMRect(t, e, r, i);
562
+ if (!ft(s, c)) return [];
563
+ const n = Array.from(B.querySelectorAll(dt));
564
+ let l = [];
565
+ const f = /* @__PURE__ */ new Map();
566
+ for (const p of n) {
567
+ if (xt(p)) continue;
568
+ const d = p.getBoundingClientRect();
569
+ if (!ft(d, c)) continue;
534
570
  let g = !1;
535
- if (ft === "contains")
536
- g = te(o, d);
537
- else if (ft === "center") {
571
+ if (yt === "contains")
572
+ g = re(s, d);
573
+ else if (yt === "center") {
538
574
  const m = d.left + d.width / 2, x = d.top + d.height / 2;
539
- g = m >= o.left && m <= o.right && x >= o.top && x <= o.bottom;
575
+ g = m >= s.left && m <= s.right && x >= s.top && x <= s.bottom;
540
576
  } else
541
- lt(o, d) && (g = Gt(o, d) >= Math.max(0, Math.min(1, Vt)));
577
+ ft(s, d) && (g = qt(s, d) >= Math.max(0, Math.min(1, Qt)));
542
578
  if (g) {
543
- const m = ft === "contains" ? 1 : Gt(o, d);
544
- y.set(u, m), s.push(u);
579
+ const m = yt === "contains" ? 1 : qt(s, d);
580
+ f.set(p, m), l.push(p);
545
581
  }
546
582
  }
547
- const h = _t ?? (Kt ? "leaf" : "none");
548
- if (h !== "none" && s.length > 1) {
549
- if (h === "leaf")
550
- s = s.filter(
551
- (u) => !s.some(
552
- (d) => d !== u && u.contains(d)
583
+ const u = ee ?? (te ? "leaf" : "none");
584
+ if (u !== "none" && l.length > 1) {
585
+ if (u === "leaf")
586
+ l = l.filter(
587
+ (p) => !l.some(
588
+ (d) => d !== p && p.contains(d)
553
589
  )
554
590
  );
555
- else if (h === "best") {
556
- const u = [...s].sort(
557
- (g, m) => (y.get(m) || 0) - (y.get(g) || 0)
591
+ else if (u === "best") {
592
+ const p = [...l].sort(
593
+ (g, m) => (f.get(m) || 0) - (f.get(g) || 0)
558
594
  ), d = [];
559
- for (const g of u)
595
+ for (const g of p)
560
596
  d.find(
561
597
  (x) => x.contains(g) || g.contains(x)
562
598
  ) || d.push(g);
563
- s = d;
599
+ l = d;
564
600
  }
565
601
  }
566
- return s;
602
+ return l;
567
603
  }
568
- document.addEventListener("mousedown", Pt, !0), document.addEventListener("mousemove", Yt), document.addEventListener("mouseup", Dt), et && B.addEventListener("mouseleave", Ht), q && dt && B.addEventListener("dblclick", Xt);
569
- const rt = () => N();
570
- q && (window.addEventListener("scroll", rt, !0), window.addEventListener("resize", rt));
571
- const it = () => {
604
+ document.addEventListener("mousedown", Ht, !0), document.addEventListener("mousemove", Ut), document.addEventListener("mouseup", jt), rt && B.addEventListener("mouseleave", Wt), q && vt && B.addEventListener("dblclick", Vt);
605
+ const pt = () => N();
606
+ q && (window.addEventListener("scroll", pt, !0), window.addEventListener("resize", pt));
607
+ const ut = () => {
572
608
  if (q) {
573
- const t = a.map((o) => Ct(o)), e = Array(a.length).fill(null), r = t.map(
574
- (o) => o ? Math.max(0, o.width * o.height) : Number.POSITIVE_INFINITY
609
+ const t = a.map((s) => kt(s)), e = Array(a.length).fill(null), r = t.map(
610
+ (s) => s ? Math.max(0, s.width * s.height) : Number.POSITIVE_INFINITY
575
611
  );
576
- for (let o = 0; o < a.length; o++) {
577
- const n = t[o];
612
+ for (let s = 0; s < a.length; s++) {
613
+ const n = t[s];
578
614
  if (!n) continue;
579
- let s = null, y = Number.POSITIVE_INFINITY;
580
- for (let h = 0; h < a.length; h++) {
581
- if (o === h) continue;
582
- const u = t[h];
583
- if (!u) continue;
584
- if (u.left <= n.left && u.top <= n.top && u.left + u.width >= n.left + n.width && u.top + u.height >= n.top + n.height) {
585
- const g = Number(r[h]);
586
- g < y && (y = g, s = h);
615
+ let l = null, f = Number.POSITIVE_INFINITY;
616
+ for (let u = 0; u < a.length; u++) {
617
+ if (s === u) continue;
618
+ const p = t[u];
619
+ if (!p) continue;
620
+ if (p.left <= n.left && p.top <= n.top && p.left + p.width >= n.left + n.width && p.top + p.height >= n.top + n.height) {
621
+ const g = Number(r[u]);
622
+ g < f && (f = g, l = u);
587
623
  }
588
624
  }
589
- e[o] = s;
625
+ e[s] = l;
590
626
  }
591
627
  const i = Array.from(
592
628
  { length: a.length },
593
629
  () => []
594
630
  );
595
- for (let o = 0; o < a.length; o++) {
596
- const n = e[o];
597
- n != null && i[n] && i[n].push(o);
631
+ for (let s = 0; s < a.length; s++) {
632
+ const n = e[s];
633
+ n != null && i[n] && i[n].push(s);
598
634
  }
599
635
  const c = [];
600
- for (let o = 0; o < a.length; o++)
601
- (e[o] === null || e[o] === void 0) && c.push(o);
636
+ for (let s = 0; s < a.length; s++)
637
+ (e[s] === null || e[s] === void 0) && c.push(s);
602
638
  return {
603
639
  type: "groups",
604
- groups: a.map((o) => o.slice()),
605
- flat: Array.from(P),
640
+ groups: a.map((s) => s.slice()),
641
+ flat: Array.from(D),
606
642
  hidden: I.slice(),
607
643
  groupRects: t,
608
644
  groupNesting: { parents: e, children: i, roots: c }
609
645
  };
610
646
  }
611
- return { type: "single", selected: Array.from(P) };
612
- }, O = () => {
613
- const t = it();
614
- if (It)
647
+ return { type: "single", selected: Array.from(D) };
648
+ }, F = () => {
649
+ const t = ut();
650
+ if (Gt)
615
651
  try {
616
- It(t);
652
+ Gt(t);
617
653
  } catch {
618
654
  }
619
- for (const r of V)
655
+ for (const r of Z)
620
656
  try {
621
657
  r(t);
622
658
  } catch {
623
659
  }
624
- const e = Et.splice(0);
660
+ const e = $t.splice(0);
625
661
  for (const r of e)
626
662
  try {
627
663
  r(t);
628
664
  } catch {
629
665
  }
630
- }, Tt = {
666
+ }, Kt = {
631
667
  destroy() {
632
- document.removeEventListener("mousedown", Pt), document.removeEventListener("mousemove", Yt), document.removeEventListener("mouseup", Dt), $ && $.parentNode && $.parentNode.removeChild($), $ = null, B.querySelectorAll(`.${Z}`).forEach((e) => e.classList.remove(Z)), et && (B.removeEventListener("mouseleave", Ht), st(null)), q && (window.removeEventListener("scroll", rt, !0), window.removeEventListener("resize", rt)), q && dt && B.removeEventListener("dblclick", Xt), K(), a.forEach(
668
+ document.removeEventListener("mousedown", Ht), document.removeEventListener("mousemove", Ut), document.removeEventListener("mouseup", jt), $ && $.parentNode && $.parentNode.removeChild($), $ = null, B.querySelectorAll(`.${st}`).forEach((e) => e.classList.remove(st)), rt && (B.removeEventListener("mouseleave", Wt), at(null)), q && (window.removeEventListener("scroll", pt, !0), window.removeEventListener("resize", pt)), q && vt && B.removeEventListener("dblclick", Vt), et(), a.forEach(
633
669
  (e) => e.forEach((r) => r.style.visibility = "")
634
- ), a = [], I = [], Y = [], k = null, P.clear(), V.splice(0), Et.splice(0);
670
+ ), a = [], I = [], H = [], U = [], k = null, D.clear(), Z.splice(0), $t.splice(0);
635
671
  },
636
672
  getGroups() {
637
673
  return a.slice();
@@ -639,53 +675,58 @@ function ce(jt) {
639
675
  clearGroups() {
640
676
  a.forEach(
641
677
  (e) => e.forEach((r) => r.style.visibility = "")
642
- ), a = [], I = [], Y = [], k = null, K(), A(/* @__PURE__ */ new Set());
678
+ ), a = [], I = [], H = [], U = [], k = null, et(), O(/* @__PURE__ */ new Set());
643
679
  },
644
680
  removeGroup(t) {
645
- return Ft(t);
681
+ return Dt(t);
646
682
  },
647
683
  addGroup(t) {
648
- return se(t);
684
+ return pe(t);
649
685
  },
650
686
  setGroupVisibility(t, e) {
651
- return ot(t, e);
687
+ return ct(t, e);
652
688
  },
653
689
  toggleGroupVisibility(t) {
654
- return t < 0 || t >= a.length ? !1 : (I[t] = !I[t], Ot(t), N(), !0);
690
+ return t < 0 || t >= a.length ? !1 : (I[t] = !I[t], Bt(t), N(), !0);
655
691
  },
656
692
  getSelectionResult() {
657
- return it();
693
+ return ut();
658
694
  },
659
695
  refresh() {
660
696
  N();
661
697
  },
662
698
  hideOverlays() {
663
- K();
699
+ et();
664
700
  },
665
701
  showAndRefreshOverlays() {
666
702
  N();
667
703
  },
668
704
  // 获取当前组级嵌套信息
669
705
  getGroupNesting() {
670
- const t = it();
706
+ const t = ut();
671
707
  return t.type === "groups" ? t.groupNesting : null;
672
708
  },
709
+ setToolbarButtonProps(t, e, r) {
710
+ return fe(t, e, r);
711
+ },
712
+ setViewScale(t) {
713
+ },
673
714
  onSelectionEnd(t) {
674
- return V.push(t), () => {
675
- const e = V.indexOf(t);
676
- e >= 0 && V.splice(e, 1);
715
+ return Z.push(t), () => {
716
+ const e = Z.indexOf(t);
717
+ e >= 0 && Z.splice(e, 1);
677
718
  };
678
719
  },
679
720
  waitForSelectionEnd() {
680
721
  return new Promise((t) => {
681
- Et.push(t);
722
+ $t.push(t);
682
723
  });
683
724
  }
684
725
  };
685
- return Nt = Tt, Tt;
726
+ return Tt = Kt, Kt;
686
727
  }
687
728
  export {
688
- ce as default,
689
- ce as marqueeSelection
729
+ ye as default,
730
+ ye as marqueeSelection
690
731
  };
691
732
  //# sourceMappingURL=marquee-selection.es.js.map