marquee-selection 0.0.12 → 0.0.13

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