@extable/core 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- function zt(c) {
2
- const t = c.payload;
1
+ function se(l) {
2
+ const t = l.payload;
3
3
  if (!t) return null;
4
4
  const e = t.batchId;
5
5
  return typeof e == "string" && e.length ? e : null;
6
6
  }
7
- class Gt {
7
+ class oe {
8
8
  constructor(t = 100) {
9
9
  this.applied = [], this.undone = [], this.cap = t;
10
10
  }
11
11
  enqueue(t) {
12
- const e = zt(t), i = this.applied.at(-1);
12
+ const e = se(t), i = this.applied.at(-1);
13
13
  for (e && i && i.batchId === e ? i.commands.push(t) : this.applied.push({ batchId: e, commands: [t] }); this.applied.length > this.cap; ) this.applied.shift();
14
14
  this.undone = [];
15
15
  }
@@ -42,41 +42,41 @@ class Gt {
42
42
  this.applied = [], this.undone = [];
43
43
  }
44
44
  }
45
- function vt() {
45
+ function It() {
46
46
  return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `row_${Math.random().toString(16).slice(2)}`;
47
47
  }
48
- function Ct(c) {
49
- if (c !== void 0)
50
- return Array.isArray(c) ? c : [c];
48
+ function Et(l) {
49
+ if (l !== void 0)
50
+ return Array.isArray(l) ? l : [l];
51
51
  }
52
- function _(c) {
53
- if (c)
52
+ function _(l) {
53
+ if (l)
54
54
  try {
55
- c.remove();
55
+ l.remove();
56
56
  } catch {
57
57
  }
58
58
  }
59
- const j = (c, t = 2) => c.toString().padStart(t, "0"), Et = {
60
- yyyy: (c) => j(c.getFullYear(), 4),
61
- MM: (c) => j(c.getMonth() + 1),
62
- dd: (c) => j(c.getDate()),
63
- HH: (c) => j(c.getHours()),
64
- hh: (c) => {
65
- const t = c.getHours() % 12 || 12;
66
- return j(t);
59
+ const Q = (l, t = 2) => l.toString().padStart(t, "0"), Lt = {
60
+ yyyy: (l) => Q(l.getFullYear(), 4),
61
+ MM: (l) => Q(l.getMonth() + 1),
62
+ dd: (l) => Q(l.getDate()),
63
+ HH: (l) => Q(l.getHours()),
64
+ hh: (l) => {
65
+ const t = l.getHours() % 12 || 12;
66
+ return Q(t);
67
67
  },
68
- mm: (c) => j(c.getMinutes()),
69
- ss: (c) => j(c.getSeconds()),
70
- a: (c) => c.getHours() >= 12 ? "PM" : "AM"
71
- }, Tt = Object.keys(Et).sort((c, t) => t.length - c.length), Dt = /* @__PURE__ */ new Set(["yyyy", "MM", "dd"]), Ht = /* @__PURE__ */ new Set(["HH", "hh", "mm", "ss", "a"]), Qt = /* @__PURE__ */ new Set([...Dt, ...Ht]), tt = {
68
+ mm: (l) => Q(l.getMinutes()),
69
+ ss: (l) => Q(l.getSeconds()),
70
+ a: (l) => l.getHours() >= 12 ? "PM" : "AM"
71
+ }, Vt = Object.keys(Lt).sort((l, t) => t.length - l.length), _t = /* @__PURE__ */ new Set(["yyyy", "MM", "dd"]), Pt = /* @__PURE__ */ new Set(["HH", "hh", "mm", "ss", "a"]), le = /* @__PURE__ */ new Set([..._t, ...Pt]), rt = {
72
72
  iso: "yyyy-MM-dd",
73
73
  us: "MM/dd/yyyy",
74
74
  eu: "dd.MM.yyyy"
75
- }, et = {
75
+ }, at = {
76
76
  iso: "HH:mm:ss",
77
77
  "24h": "HH:mm",
78
78
  "12h": "hh:mm a"
79
- }, it = {
79
+ }, ct = {
80
80
  iso: "yyyy-MM-dd'T'HH:mm:ss'Z'",
81
81
  "iso-24h": "yyyy-MM-dd'T'HH:mm:ss'Z'",
82
82
  "iso-12h": "yyyy-MM-dd hh:mm a",
@@ -87,11 +87,11 @@ const j = (c, t = 2) => c.toString().padStart(t, "0"), Et = {
87
87
  "eu-24h": "dd.MM.yyyy HH:mm",
88
88
  "eu-12h": "dd.MM.yyyy hh:mm a"
89
89
  };
90
- function dt(c) {
91
- const t = new Date(c);
90
+ function bt(l) {
91
+ const t = new Date(l);
92
92
  return Number.isNaN(t.getTime()) ? null : t;
93
93
  }
94
- function At(c, t) {
94
+ function Bt(l, t) {
95
95
  let e = "", i = 0, n = !1;
96
96
  for (; i < t.length; ) {
97
97
  const s = t[i];
@@ -104,22 +104,22 @@ function At(c, t) {
104
104
  continue;
105
105
  }
106
106
  let o = !1;
107
- for (const r of Tt)
107
+ for (const r of Vt)
108
108
  if (t.startsWith(r, i)) {
109
- e += Et[r](c), i += r.length, o = !0;
109
+ e += Lt[r](l), i += r.length, o = !0;
110
110
  break;
111
111
  }
112
112
  o || (e += s, i += 1);
113
113
  }
114
114
  return e;
115
115
  }
116
- function Zt(c, t) {
117
- return t === "date" ? Dt.has(c) : t === "time" ? Ht.has(c) : Qt.has(c);
116
+ function re(l, t) {
117
+ return t === "date" ? _t.has(l) : t === "time" ? Pt.has(l) : le.has(l);
118
118
  }
119
- function Jt(c, t) {
119
+ function ae(l, t) {
120
120
  let e = 0, i = !1;
121
- for (; e < c.length; ) {
122
- if (c[e] === "'") {
121
+ for (; e < l.length; ) {
122
+ if (l[e] === "'") {
123
123
  i = !i, e += 1;
124
124
  continue;
125
125
  }
@@ -128,9 +128,9 @@ function Jt(c, t) {
128
128
  continue;
129
129
  }
130
130
  let s = !1;
131
- for (const o of Tt)
132
- if (c.startsWith(o, e)) {
133
- if (!Zt(o, t)) return !1;
131
+ for (const o of Vt)
132
+ if (l.startsWith(o, e)) {
133
+ if (!re(o, t)) return !1;
134
134
  e += o.length, s = !0;
135
135
  break;
136
136
  }
@@ -138,27 +138,27 @@ function Jt(c, t) {
138
138
  }
139
139
  return !0;
140
140
  }
141
- function Y(c, t) {
142
- if (!c)
143
- return t === "date" ? tt.iso : t === "time" ? et.iso : it.iso;
144
- if (t === "date" && tt[c]) return tt[c];
145
- if (t === "time" && et[c]) return et[c];
146
- if (t === "datetime" && it[c]) return it[c];
147
- const e = t === "date" ? tt.iso : t === "time" ? et.iso : it.iso;
148
- return Jt(c, t) ? c : e;
141
+ function J(l, t) {
142
+ if (!l)
143
+ return t === "date" ? rt.iso : t === "time" ? at.iso : ct.iso;
144
+ if (t === "date" && rt[l]) return rt[l];
145
+ if (t === "time" && at[l]) return at[l];
146
+ if (t === "datetime" && ct[l]) return ct[l];
147
+ const e = t === "date" ? rt.iso : t === "time" ? at.iso : ct.iso;
148
+ return ae(l, t) ? l : e;
149
149
  }
150
- const St = (c) => !Number.isNaN(c.getTime()), te = (c) => {
151
- if (typeof c == "string") return c;
152
- if (c && typeof c == "object") {
153
- const t = c;
150
+ const Tt = (l) => !Number.isNaN(l.getTime()), ce = (l) => {
151
+ if (typeof l == "string") return l;
152
+ if (l && typeof l == "object") {
153
+ const t = l;
154
154
  if (t.kind === "enum")
155
155
  return typeof t.value == "string" ? t.value : null;
156
156
  }
157
157
  return null;
158
- }, ee = (c) => {
159
- if (Array.isArray(c) && c.every((t) => typeof t == "string")) return c;
160
- if (c && typeof c == "object") {
161
- const t = c;
158
+ }, de = (l) => {
159
+ if (Array.isArray(l) && l.every((t) => typeof t == "string")) return l;
160
+ if (l && typeof l == "object") {
161
+ const t = l;
162
162
  if (t.kind === "tags") {
163
163
  const e = t.values;
164
164
  return Array.isArray(e) && e.every((i) => typeof i == "string") ? e : null;
@@ -166,32 +166,32 @@ const St = (c) => !Number.isNaN(c.getTime()), te = (c) => {
166
166
  }
167
167
  return null;
168
168
  };
169
- function ie(c, t) {
170
- if (c == null) return null;
169
+ function he(l, t) {
170
+ if (l == null) return null;
171
171
  switch (t.type) {
172
172
  case "string": {
173
- if (typeof c != "string") return "Expected a string";
174
- if (t.string?.maxLength !== void 0 && c.length > t.string.maxLength)
173
+ if (typeof l != "string") return "Expected a string";
174
+ if (t.string?.maxLength !== void 0 && l.length > t.string.maxLength)
175
175
  return `Too long (max ${t.string.maxLength})`;
176
176
  if (t.string?.regex)
177
177
  try {
178
- if (!new RegExp(t.string.regex).test(c)) return "Does not match pattern";
178
+ if (!new RegExp(t.string.regex).test(l)) return "Does not match pattern";
179
179
  } catch {
180
180
  }
181
181
  return null;
182
182
  }
183
183
  case "number":
184
- return typeof c != "number" || !Number.isFinite(c) ? "Expected a number" : t.number?.signed === !1 && c < 0 ? "Expected a non-negative number" : null;
184
+ return typeof l != "number" || !Number.isFinite(l) ? "Expected a number" : t.number?.signed === !1 && l < 0 ? "Expected a non-negative number" : null;
185
185
  case "boolean":
186
- return typeof c != "boolean" ? "Expected a boolean" : null;
186
+ return typeof l != "boolean" ? "Expected a boolean" : null;
187
187
  case "enum": {
188
- const e = te(c);
188
+ const e = ce(l);
189
189
  if (!e) return "Expected an enum value";
190
190
  const i = t.enum?.allowCustom ?? !1, n = t.enum?.options ?? [];
191
191
  return !i && n.length && !n.includes(e) ? "Not in allowed options" : null;
192
192
  }
193
193
  case "tags": {
194
- const e = ee(c);
194
+ const e = de(l);
195
195
  if (!e) return "Expected a list of tags";
196
196
  const i = t.tags?.allowCustom ?? !1, n = t.tags?.options ?? [];
197
197
  if (!i && n.length) {
@@ -203,10 +203,10 @@ function ie(c, t) {
203
203
  case "date":
204
204
  case "time":
205
205
  case "datetime": {
206
- if (t.type === "date" ? Y(t.dateFormat, "date") : t.type === "time" ? Y(t.timeFormat, "time") : Y(t.dateTimeFormat, "datetime"), c instanceof Date) return St(c) ? null : "Invalid date";
207
- if (typeof c == "string") {
208
- const e = dt(c);
209
- return e && St(e) ? null : "Invalid date/time";
206
+ if (t.type === "date" ? J(t.dateFormat, "date") : t.type === "time" ? J(t.timeFormat, "time") : J(t.dateTimeFormat, "datetime"), l instanceof Date) return Tt(l) ? null : "Invalid date";
207
+ if (typeof l == "string") {
208
+ const e = bt(l);
209
+ return e && Tt(e) ? null : "Invalid date/time";
210
210
  }
211
211
  return "Expected a date/time string";
212
212
  }
@@ -214,7 +214,7 @@ function ie(c, t) {
214
214
  return null;
215
215
  }
216
216
  }
217
- class ne {
217
+ class ue {
218
218
  constructor(t, e, i) {
219
219
  this.rows = [], this.baseIndexById = /* @__PURE__ */ new Map(), this.dataVersion = 0, this.visibleRowsCache = null, this.distinctValueCache = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Map(), this.rowVersion = /* @__PURE__ */ new Map(), this.listeners = /* @__PURE__ */ new Set(), this.cellStyles = /* @__PURE__ */ new Map(), this.cellConditionalStyles = /* @__PURE__ */ new Map(), this.computedCache = /* @__PURE__ */ new Map(), this.conditionalCache = /* @__PURE__ */ new Map(), this.rowConditionalCache = /* @__PURE__ */ new Map(), this.formulaDiagnostics = /* @__PURE__ */ new Map(), this.conditionalDiagnostics = /* @__PURE__ */ new Map(), this.baseValidationErrors = /* @__PURE__ */ new Map(), this.uniqueValidationErrors = /* @__PURE__ */ new Map(), this.notifySuspended = !1, this.notifyDirty = !1, this.schema = e, this.view = i, this.setData(t ?? []);
220
220
  }
@@ -238,7 +238,7 @@ class ne {
238
238
  }
239
239
  setData(t) {
240
240
  this.dataVersion += 1, this.pending.clear(), this.cellStyles.clear(), this.cellConditionalStyles.clear(), this.computedCache.clear(), this.conditionalCache.clear(), this.rowConditionalCache.clear(), this.formulaDiagnostics.clear(), this.conditionalDiagnostics.clear(), this.baseValidationErrors.clear(), this.uniqueValidationErrors.clear(), this.rows = (t ?? []).map((e, i) => {
241
- const n = vt();
241
+ const n = It();
242
242
  return this.rowVersion.set(n, 0), {
243
243
  id: n,
244
244
  raw: e,
@@ -330,16 +330,16 @@ class ne {
330
330
  const s = this.findRow(t);
331
331
  if (!s) return;
332
332
  const o = s.row, r = () => {
333
- const l = this.rowVersion.get(t) ?? 0;
334
- this.rowVersion.set(t, l + 1);
333
+ const c = this.rowVersion.get(t) ?? 0;
334
+ this.rowVersion.set(t, c + 1);
335
335
  };
336
336
  if (n)
337
337
  o.raw[e] = i, this.pending.delete(t), r();
338
338
  else {
339
- const l = this.getRawCell(t, e), h = this.pending.get(t) ?? {};
340
- this.isEqual(l, i) ? delete h[e] : h[e] = i, Object.keys(h).length > 0 ? this.pending.set(t, h) : this.pending.delete(t), r();
339
+ const c = this.getRawCell(t, e), u = this.pending.get(t) ?? {};
340
+ this.isEqual(c, i) ? delete u[e] : u[e] = i, Object.keys(u).length > 0 ? this.pending.set(t, u) : this.pending.delete(t), r();
341
341
  }
342
- this.updateValidationForCell(t, e, this.getCell(t, e)), this.schema.columns.find((l) => l.key === e)?.unique && this.recomputeUniqueValidationForColumn(e), this.clearDiagnosticsForCell(t, e), this.notify();
342
+ this.updateValidationForCell(t, e, this.getCell(t, e)), this.schema.columns.find((c) => c.key === e)?.unique && this.recomputeUniqueValidationForColumn(e), this.clearDiagnosticsForCell(t, e), this.notify();
343
343
  }
344
344
  applyPending(t) {
345
345
  this.dataVersion += 1;
@@ -350,7 +350,7 @@ class ne {
350
350
  const n = i.row, s = /* @__PURE__ */ new Set();
351
351
  for (const [o, r] of Object.entries(e)) {
352
352
  n.raw[o] = r, this.updateValidationForCell(t, o, r);
353
- const a = this.schema.columns.find((l) => String(l.key) === String(o));
353
+ const a = this.schema.columns.find((c) => String(c.key) === String(o));
354
354
  a?.unique && s.add(a.key), this.clearDiagnosticsForCell(t, o);
355
355
  }
356
356
  this.pending.delete(t);
@@ -372,7 +372,7 @@ class ne {
372
372
  }
373
373
  insertRowAt(t, e, i) {
374
374
  this.dataVersion += 1;
375
- const n = i ?? vt(), s = Math.max(0, Math.min(e, this.rows.length));
375
+ const n = i ?? It(), s = Math.max(0, Math.min(e, this.rows.length));
376
376
  return this.rows.splice(s, 0, { id: n, raw: t, displayIndex: 0 }), this.reindexRows(), this.rowVersion.set(n, 0), this.rebuildBaseIndex(), this.recomputeValidationErrors(), this.notify(), n;
377
377
  }
378
378
  removeRow(t) {
@@ -410,30 +410,30 @@ class ne {
410
410
  getFilterSortKey(t) {
411
411
  const e = t?.excludeColumnKey, i = t?.includeSort ?? !0, n = this.view, s = (n.filters ?? []).filter((a) => {
412
412
  if (e === void 0) return !0;
413
- const l = a?.key;
414
- return String(l) !== String(e);
413
+ const c = a?.key;
414
+ return String(c) !== String(e);
415
415
  }).map((a) => {
416
416
  if (a?.kind === "values") {
417
- const u = a;
417
+ const d = a;
418
418
  return {
419
419
  kind: "values",
420
- key: String(u.key),
421
- includeBlanks: !!u.includeBlanks,
422
- values: (u.values ?? []).map((f) => this.stableValueKey(f))
420
+ key: String(d.key),
421
+ includeBlanks: !!d.includeBlanks,
422
+ values: (d.values ?? []).map((f) => this.stableValueKey(f))
423
423
  };
424
424
  }
425
- const h = a;
425
+ const u = a;
426
426
  return {
427
427
  kind: "op",
428
- key: String(h.key),
429
- op: String(h.op ?? ""),
430
- value: this.stableValueKey(h.value)
428
+ key: String(u.key),
429
+ op: String(u.op ?? ""),
430
+ value: this.stableValueKey(u.value)
431
431
  };
432
- }).sort((a, l) => a.key === l.key ? a.kind < l.kind ? -1 : 1 : a.key < l.key ? -1 : 1), o = Object.entries(n.columnDiagnostics ?? {}).filter(([a]) => e !== void 0 ? String(a) !== String(e) : !0).map(([a, l]) => ({
432
+ }).sort((a, c) => a.key === c.key ? a.kind < c.kind ? -1 : 1 : a.key < c.key ? -1 : 1), o = Object.entries(n.columnDiagnostics ?? {}).filter(([a]) => e !== void 0 ? String(a) !== String(e) : !0).map(([a, c]) => ({
433
433
  key: String(a),
434
- errors: !!l?.errors,
435
- warnings: !!l?.warnings
436
- })).filter((a) => a.errors || a.warnings).sort((a, l) => a.key < l.key ? -1 : a.key > l.key ? 1 : 0), r = i ? (n.sorts ?? []).slice(0, 1).map((a) => ({ key: String(a.key), dir: a.dir })) : [];
434
+ errors: !!c?.errors,
435
+ warnings: !!c?.warnings
436
+ })).filter((a) => a.errors || a.warnings).sort((a, c) => a.key < c.key ? -1 : a.key > c.key ? 1 : 0), r = i ? (n.sorts ?? []).slice(0, 1).map((a) => ({ key: String(a.key), dir: a.dir })) : [];
437
437
  return JSON.stringify({ filters: s, columnDiagnosticsEntries: o, sorts: r });
438
438
  }
439
439
  stableValueKey(t) {
@@ -477,58 +477,58 @@ class ne {
477
477
  rowPassesColumnDiagnostics(t, e, i) {
478
478
  const n = !!i.errors, s = !!i.warnings;
479
479
  if (!n && !s) return !0;
480
- const o = this.resolveFilterColumnKey(e), r = this.getColumns().find((l) => String(l.key) === String(o));
480
+ const o = this.resolveFilterColumnKey(e), r = this.getColumns().find((c) => String(c.key) === String(o));
481
481
  r && (this.resolveCellValue(t, r), this.resolveConditionalStyle(t, r));
482
482
  const a = this.getCellMarker(t, o);
483
483
  return a ? a.level === "error" ? n : s : !1;
484
484
  }
485
485
  computeRowsAfterFilter(t) {
486
- const e = t?.excludeColumnKey, i = t?.includeSort ?? !0, n = this.view, s = this.getSchema(), o = (n.filters ?? []).filter((d) => {
486
+ const e = t?.excludeColumnKey, i = t?.includeSort ?? !0, n = this.view, s = this.getSchema(), o = (n.filters ?? []).filter((p) => {
487
487
  if (e === void 0) return !0;
488
- const m = d?.key;
489
- return String(m) !== String(e);
488
+ const h = p?.key;
489
+ return String(h) !== String(e);
490
490
  }), r = Object.entries(n.columnDiagnostics ?? {}).filter(
491
- ([d]) => e !== void 0 ? String(d) !== String(e) : !0
491
+ ([p]) => e !== void 0 ? String(p) !== String(e) : !0
492
492
  ), a = [];
493
- for (const d of this.rows) {
494
- let m = !0;
495
- for (const g of o)
496
- if (g?.kind === "values" && !this.valuesFilterMatches(d.id, g)) {
497
- m = !1;
493
+ for (const p of this.rows) {
494
+ let h = !0;
495
+ for (const m of o)
496
+ if (m?.kind === "values" && !this.valuesFilterMatches(p.id, m)) {
497
+ h = !1;
498
498
  break;
499
499
  }
500
- if (m) {
501
- for (const [g, y] of r)
502
- if (!this.rowPassesColumnDiagnostics(d.id, g, y)) {
503
- m = !1;
500
+ if (h) {
501
+ for (const [m, y] of r)
502
+ if (!this.rowPassesColumnDiagnostics(p.id, m, y)) {
503
+ h = !1;
504
504
  break;
505
505
  }
506
- m && a.push(d);
506
+ h && a.push(p);
507
507
  }
508
508
  }
509
509
  if (!i) return a;
510
- const l = (n.sorts ?? []).slice(0, 1)[0];
511
- if (!l) return a;
512
- const h = s.columns.find((d) => String(d.key) === String(l.key));
513
- if (!h) return a;
514
- const u = l.dir === "desc" ? -1 : 1, f = a.map((d) => {
515
- const m = this.getFilterCellValue(d.id, h.key), g = this.isBlankValue(m), y = this.baseIndexById.get(d.id) ?? 0;
516
- return { row: d, v: m, blank: g, baseIndex: y };
517
- }), p = (d, m) => {
518
- if (d === m) return 0;
519
- if (d instanceof Date && m instanceof Date) return d.getTime() - m.getTime();
520
- if (typeof d == "number" && typeof m == "number") return d - m;
521
- if (typeof d == "boolean" && typeof m == "boolean") return d === m ? 0 : d ? 1 : -1;
522
- const g = d instanceof Date ? d.toISOString() : typeof d == "string" ? d : String(d), y = m instanceof Date ? m.toISOString() : typeof m == "string" ? m : String(m);
523
- return g === y ? 0 : g < y ? -1 : 1;
510
+ const c = (n.sorts ?? []).slice(0, 1)[0];
511
+ if (!c) return a;
512
+ const u = s.columns.find((p) => String(p.key) === String(c.key));
513
+ if (!u) return a;
514
+ const d = c.dir === "desc" ? -1 : 1, f = a.map((p) => {
515
+ const h = this.getFilterCellValue(p.id, u.key), m = this.isBlankValue(h), y = this.baseIndexById.get(p.id) ?? 0;
516
+ return { row: p, v: h, blank: m, baseIndex: y };
517
+ }), g = (p, h) => {
518
+ if (p === h) return 0;
519
+ if (p instanceof Date && h instanceof Date) return p.getTime() - h.getTime();
520
+ if (typeof p == "number" && typeof h == "number") return p - h;
521
+ if (typeof p == "boolean" && typeof h == "boolean") return p === h ? 0 : p ? 1 : -1;
522
+ const m = p instanceof Date ? p.toISOString() : typeof p == "string" ? p : String(p), y = h instanceof Date ? h.toISOString() : typeof h == "string" ? h : String(h);
523
+ return m === y ? 0 : m < y ? -1 : 1;
524
524
  };
525
- return f.sort((d, m) => {
526
- if (d.blank && m.blank) return d.baseIndex - m.baseIndex;
527
- if (d.blank) return 1;
528
- if (m.blank) return -1;
529
- const g = p(d.v, m.v);
530
- return g !== 0 ? g * u : d.baseIndex - m.baseIndex;
531
- }), f.map((d) => d.row);
525
+ return f.sort((p, h) => {
526
+ if (p.blank && h.blank) return p.baseIndex - h.baseIndex;
527
+ if (p.blank) return 1;
528
+ if (h.blank) return -1;
529
+ const m = g(p.v, h.v);
530
+ return m !== 0 ? m * d : p.baseIndex - h.baseIndex;
531
+ }), f.map((p) => p.row);
532
532
  }
533
533
  computeVisibleRows() {
534
534
  const t = this.getFilterSortKey(), e = this.visibleRowsCache;
@@ -544,44 +544,44 @@ class ne {
544
544
  getDistinctValuesForColumn(t) {
545
545
  const e = `${String(t)}|${this.getFilterSortKey({ excludeColumnKey: t, includeSort: !1 })}`, i = this.distinctValueCache.get(e);
546
546
  if (i && i.version === this.dataVersion) return i;
547
- const n = this.computeRowsAfterFilter({ excludeColumnKey: t, includeSort: !1 }), s = this.getSchema().columns.find((h) => String(h.key) === String(t));
547
+ const n = this.computeRowsAfterFilter({ excludeColumnKey: t, includeSort: !1 }), s = this.getSchema().columns.find((u) => String(u.key) === String(t));
548
548
  if (!s) {
549
- const h = { version: this.dataVersion, values: [], hasBlanks: !1, total: 0 };
550
- return this.distinctValueCache.set(e, h), h;
549
+ const u = { version: this.dataVersion, values: [], hasBlanks: !1, total: 0 };
550
+ return this.distinctValueCache.set(e, u), u;
551
551
  }
552
552
  const o = /* @__PURE__ */ new Map();
553
553
  let r = !1;
554
- for (const h of n) {
555
- const u = this.getFilterCellValue(h.id, s.key);
556
- if (this.isBlankValue(u)) {
554
+ for (const u of n) {
555
+ const d = this.getFilterCellValue(u.id, s.key);
556
+ if (this.isBlankValue(d)) {
557
557
  r = !0;
558
558
  continue;
559
559
  }
560
- const f = this.stableValueKey(u);
560
+ const f = this.stableValueKey(d);
561
561
  if (o.has(f)) continue;
562
- const p = (() => {
563
- if (u instanceof Date) return u.toISOString();
564
- if (typeof u == "string") return u;
565
- if (typeof u == "number" || typeof u == "boolean") return String(u);
566
- if (typeof u == "object" && u) {
567
- const d = u, m = d.kind;
568
- if (m === "enum" && typeof d.value == "string") return d.value;
569
- if (m === "tags" && Array.isArray(d.values))
570
- return d.values.filter((g) => typeof g == "string").join(", ");
562
+ const g = (() => {
563
+ if (d instanceof Date) return d.toISOString();
564
+ if (typeof d == "string") return d;
565
+ if (typeof d == "number" || typeof d == "boolean") return String(d);
566
+ if (typeof d == "object" && d) {
567
+ const p = d, h = p.kind;
568
+ if (h === "enum" && typeof p.value == "string") return p.value;
569
+ if (h === "tags" && Array.isArray(p.values))
570
+ return p.values.filter((m) => typeof m == "string").join(", ");
571
571
  }
572
- return String(u);
572
+ return String(d);
573
573
  })();
574
- o.set(f, { value: u, label: p });
574
+ o.set(f, { value: d, label: g });
575
575
  }
576
576
  const a = [...o.values()].sort(
577
- (h, u) => h.label < u.label ? -1 : h.label > u.label ? 1 : 0
578
- ), l = {
577
+ (u, d) => u.label < d.label ? -1 : u.label > d.label ? 1 : 0
578
+ ), c = {
579
579
  version: this.dataVersion,
580
580
  values: a,
581
581
  hasBlanks: r,
582
582
  total: a.length + (r ? 1 : 0)
583
583
  };
584
- return this.distinctValueCache.set(e, l), l;
584
+ return this.distinctValueCache.set(e, c), c;
585
585
  }
586
586
  cellStyleKey(t, e) {
587
587
  return `${t}::${String(e)}`;
@@ -637,24 +637,24 @@ class ne {
637
637
  try {
638
638
  const r = e.formula(o);
639
639
  if (Array.isArray(r) && r.length >= 2 && r[1] instanceof Error) {
640
- const l = {
640
+ const c = {
641
641
  level: "warning",
642
642
  message: r[1].message,
643
643
  source: "formula"
644
- }, h = r[0];
645
- return this.computedCache.set(n, { version: i, formulaRef: e.formula, value: h, diagnostic: l }), this.formulaDiagnostics.set(n, l), { value: h, diagnostic: l };
644
+ }, u = r[0];
645
+ return this.computedCache.set(n, { version: i, formulaRef: e.formula, value: u, diagnostic: c }), this.formulaDiagnostics.set(n, c), { value: u, diagnostic: c };
646
646
  }
647
647
  const a = r;
648
648
  return this.computedCache.set(n, { version: i, formulaRef: e.formula, value: a, diagnostic: null }), this.formulaDiagnostics.delete(n), { value: a, diagnostic: null };
649
649
  } catch (r) {
650
- const l = { level: "error", message: r instanceof Error ? r.message : String(r), source: "formula" };
650
+ const c = { level: "error", message: r instanceof Error ? r.message : String(r), source: "formula" };
651
651
  return this.computedCache.set(n, {
652
652
  version: i,
653
653
  formulaRef: e.formula,
654
654
  value: null,
655
655
  textOverride: "#ERROR",
656
- diagnostic: l
657
- }), this.formulaDiagnostics.set(n, l), { value: null, textOverride: "#ERROR", diagnostic: l };
656
+ diagnostic: c
657
+ }), this.formulaDiagnostics.set(n, c), { value: null, textOverride: "#ERROR", diagnostic: c };
658
658
  }
659
659
  }
660
660
  setCellConditionalStyle(t, e, i) {
@@ -696,28 +696,28 @@ class ne {
696
696
  return this.rowConditionalCache.set(t, { version: i, fnRef: e, ...o }), o;
697
697
  }
698
698
  resolveConditionalStyle(t, e) {
699
- const i = this.getRowVersion(t), n = this.cellStyleKey(t, e.key), s = this.getRowObjectEffective(t), o = this.resolveRowConditionalStyle(t), r = (f, p) => p ? f ? { ...f, ...p } : { ...p } : f;
700
- let a = null, l = null, h = !1;
701
- if (a = r(a, o.delta), o.diagnostic && (l = o.diagnostic), h = h || o.forceErrorText, e.conditionalStyle && s) {
702
- const f = `${t}::${String(e.key)}::col`, p = this.conditionalCache.get(f);
703
- if (p && p.version === i && p.fnRef === e.conditionalStyle)
704
- a = r(a, p.delta), p.diagnostic && (l === null || l.level !== "error") && (l = p.diagnostic), h = h || p.forceErrorText;
699
+ const i = this.getRowVersion(t), n = this.cellStyleKey(t, e.key), s = this.getRowObjectEffective(t), o = this.resolveRowConditionalStyle(t), r = (f, g) => g ? f ? { ...f, ...g } : { ...g } : f;
700
+ let a = null, c = null, u = !1;
701
+ if (a = r(a, o.delta), o.diagnostic && (c = o.diagnostic), u = u || o.forceErrorText, e.conditionalStyle && s) {
702
+ const f = `${t}::${String(e.key)}::col`, g = this.conditionalCache.get(f);
703
+ if (g && g.version === i && g.fnRef === e.conditionalStyle)
704
+ a = r(a, g.delta), g.diagnostic && (c === null || c.level !== "error") && (c = g.diagnostic), u = u || g.forceErrorText;
705
705
  else {
706
- const d = this.evalConditionalStyleFn(e.conditionalStyle, s);
707
- this.conditionalCache.set(f, { version: i, fnRef: e.conditionalStyle, ...d }), a = r(a, d.delta), d.diagnostic && (l === null || l.level !== "error") && (l = d.diagnostic), h = h || d.forceErrorText;
706
+ const p = this.evalConditionalStyleFn(e.conditionalStyle, s);
707
+ this.conditionalCache.set(f, { version: i, fnRef: e.conditionalStyle, ...p }), a = r(a, p.delta), p.diagnostic && (c === null || c.level !== "error") && (c = p.diagnostic), u = u || p.forceErrorText;
708
708
  }
709
709
  }
710
- const u = this.cellConditionalStyles.get(n);
711
- if (u && s) {
710
+ const d = this.cellConditionalStyles.get(n);
711
+ if (d && s) {
712
712
  const f = this.conditionalCache.get(n);
713
- if (f && f.version === i && f.fnRef === u)
714
- a = r(a, f.delta), f.diagnostic && (l === null || l.level !== "error") && (l = f.diagnostic), h = h || f.forceErrorText;
713
+ if (f && f.version === i && f.fnRef === d)
714
+ a = r(a, f.delta), f.diagnostic && (c === null || c.level !== "error") && (c = f.diagnostic), u = u || f.forceErrorText;
715
715
  else {
716
- const p = this.evalConditionalStyleFn(u, s);
717
- this.conditionalCache.set(n, { version: i, fnRef: u, ...p }), a = r(a, p.delta), p.diagnostic && (l === null || l.level !== "error") && (l = p.diagnostic), h = h || p.forceErrorText;
716
+ const g = this.evalConditionalStyleFn(d, s);
717
+ this.conditionalCache.set(n, { version: i, fnRef: d, ...g }), a = r(a, g.delta), g.diagnostic && (c === null || c.level !== "error") && (c = g.diagnostic), u = u || g.forceErrorText;
718
718
  }
719
719
  }
720
- return l ? this.conditionalDiagnostics.set(n, l) : this.conditionalDiagnostics.delete(n), { delta: a, diagnostic: l, forceErrorText: h };
720
+ return c ? this.conditionalDiagnostics.set(n, c) : this.conditionalDiagnostics.delete(n), { delta: a, diagnostic: c, forceErrorText: u };
721
721
  }
722
722
  getValidationErrors() {
723
723
  const t = /* @__PURE__ */ new Map();
@@ -750,7 +750,7 @@ ${s}` : n : s;
750
750
  updateValidationForCell(t, e, i) {
751
751
  const n = this.schema.columns.find((r) => String(r.key) === String(e));
752
752
  if (!n) return;
753
- const s = ie(i, n), o = this.cellStyleKey(t, e);
753
+ const s = he(i, n), o = this.cellStyleKey(t, e);
754
754
  s ? this.baseValidationErrors.set(o, { rowId: t, colKey: e, message: s }) : this.baseValidationErrors.delete(o);
755
755
  }
756
756
  recomputeValidationErrors() {
@@ -831,23 +831,23 @@ Rows: ${o}`
831
831
  e.displayIndex = t, t += 1;
832
832
  }
833
833
  }
834
- function se(c, t) {
835
- const e = c.getSchema(), i = c.listRows(), n = (o, r) => {
834
+ function fe(l, t) {
835
+ const e = l.getSchema(), i = l.listRows(), n = (o, r) => {
836
836
  if (!Number.isInteger(o) || !Number.isInteger(r) || o < 0 || o >= i.length || r < 0 || r >= e.columns.length) return null;
837
- const a = i[o], l = e.columns[r];
838
- return { rowId: a.id, colKey: l.key, rowIndex: o, colIndex: r };
837
+ const a = i[o], c = e.columns[r];
838
+ return { rowId: a.id, colKey: c.key, rowIndex: o, colIndex: r };
839
839
  }, s = (o, r) => {
840
- const a = c.getRowIndex(o);
840
+ const a = l.getRowIndex(o);
841
841
  if (a < 0) return null;
842
- const l = e.columns.findIndex((h) => h.key === r);
843
- return l < 0 ? null : { rowId: o, colKey: r, rowIndex: a, colIndex: l };
842
+ const c = e.columns.findIndex((u) => u.key === r);
843
+ return c < 0 ? null : { rowId: o, colKey: r, rowIndex: a, colIndex: c };
844
844
  };
845
845
  if ("rowId" in t && "colKey" in t)
846
846
  return s(t.rowId, t.colKey);
847
847
  if ("rowIndex" in t && "colIndex" in t)
848
848
  return n(t.rowIndex, t.colIndex);
849
849
  if ("rowId" in t && "colIndex" in t) {
850
- const o = c.getRowIndex(t.rowId);
850
+ const o = l.getRowIndex(t.rowId);
851
851
  return o < 0 ? null : n(o, t.colIndex);
852
852
  }
853
853
  if ("rowIndex" in t && "colKey" in t) {
@@ -856,35 +856,35 @@ function se(c, t) {
856
856
  }
857
857
  return null;
858
858
  }
859
- function oe() {
859
+ function ge() {
860
860
  return { caseInsensitive: !1, regex: !1 };
861
861
  }
862
- function at(c, t) {
863
- if (c == null) return "";
864
- if (c instanceof Date) return c.toISOString();
865
- if (typeof c == "string") return c;
866
- if (typeof c == "number" || typeof c == "boolean") return String(c);
867
- if (typeof c == "object") {
868
- const e = c, i = e.kind;
862
+ function mt(l, t) {
863
+ if (l == null) return "";
864
+ if (l instanceof Date) return l.toISOString();
865
+ if (typeof l == "string") return l;
866
+ if (typeof l == "number" || typeof l == "boolean") return String(l);
867
+ if (typeof l == "object") {
868
+ const e = l, i = e.kind;
869
869
  if (i === "enum" && typeof e.value == "string") return e.value;
870
870
  if (i === "tags" && Array.isArray(e.values))
871
871
  return e.values.filter((n) => typeof n == "string").join(", ");
872
872
  }
873
- return t.type === "boolean" ? String(c).toLowerCase() === "true" ? "TRUE" : "FALSE" : String(c);
873
+ return t.type === "boolean" ? String(l).toLowerCase() === "true" ? "TRUE" : "FALSE" : String(l);
874
874
  }
875
- function re(c) {
876
- return c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
875
+ function pe(l) {
876
+ return l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
877
877
  }
878
- function xt(c, t) {
879
- return t <= 0 ? -1 : Math.max(0, Math.min(t - 1, c));
878
+ function At(l, t) {
879
+ return t <= 0 ? -1 : Math.max(0, Math.min(t - 1, l));
880
880
  }
881
- class le {
881
+ class me {
882
882
  constructor(t, e, i, n) {
883
883
  this.dataModel = t, this.navigateToCell = e, this.applyEdit = i, this.canEdit = n, this.state = {
884
884
  query: "",
885
885
  replace: "",
886
886
  mode: "find",
887
- options: oe(),
887
+ options: ge(),
888
888
  matches: [],
889
889
  activeIndex: -1,
890
890
  error: null
@@ -924,7 +924,7 @@ class le {
924
924
  this.activateIndex(t);
925
925
  }
926
926
  activateIndex(t) {
927
- const e = xt(t, this.state.matches.length);
927
+ const e = At(t, this.state.matches.length);
928
928
  if (e < 0) return;
929
929
  const i = this.state.matches[e];
930
930
  i && (this.setState({ ...this.state, activeIndex: e }), this.navigateToCell(i.rowId, i.colKey));
@@ -936,7 +936,7 @@ class le {
936
936
  if (!e || !this.canEdit(e.rowId, e.colKey)) return;
937
937
  const n = this.dataModel.getSchema().columns[e.colIndex];
938
938
  if (!n) return;
939
- const s = this.dataModel.getCell(e.rowId, e.colKey), o = at(s, n), r = this.applyReplacement(o, e);
939
+ const s = this.dataModel.getCell(e.rowId, e.colKey), o = mt(s, n), r = this.applyReplacement(o, e);
940
940
  this.applyEdit(e.rowId, e.colKey, r), this.recompute();
941
941
  }
942
942
  replaceAll() {
@@ -947,10 +947,10 @@ class le {
947
947
  for (const [i, n] of e.entries()) {
948
948
  const [s, o] = i.split("|"), r = n[0];
949
949
  if (!r) continue;
950
- const a = r.colIndex, l = t.columns[a];
951
- if (!l || !s || !o) continue;
952
- const h = o, u = this.dataModel.getCell(s, h), f = at(u, l), p = this.applyReplacementAllInCell(f, n);
953
- this.applyEdit(s, h, p);
950
+ const a = r.colIndex, c = t.columns[a];
951
+ if (!c || !s || !o) continue;
952
+ const u = o, d = this.dataModel.getCell(s, u), f = mt(d, c), g = this.applyReplacementAllInCell(f, n);
953
+ this.applyEdit(s, u, g);
954
954
  }
955
955
  this.recompute();
956
956
  }
@@ -961,9 +961,9 @@ class le {
961
961
  try {
962
962
  const o = `g${s.caseInsensitive ? "i" : ""}`, r = new RegExp(i, o);
963
963
  let a = -1;
964
- return t.replace(r, (l, ...h) => {
965
- const u = h[h.length - 2];
966
- return typeof u != "number" || u !== e.start || a === u ? l : (a = u, n);
964
+ return t.replace(r, (c, ...u) => {
965
+ const d = u[u.length - 2];
966
+ return typeof d != "number" || d !== e.start || a === d ? c : (a = d, n);
967
967
  });
968
968
  } catch {
969
969
  return t;
@@ -976,12 +976,12 @@ class le {
976
976
  if (!i) return t;
977
977
  if (s.regex)
978
978
  try {
979
- const a = `g${s.caseInsensitive ? "i" : ""}`, l = new RegExp(i, a);
980
- return t.replace(l, n);
979
+ const a = `g${s.caseInsensitive ? "i" : ""}`, c = new RegExp(i, a);
980
+ return t.replace(c, n);
981
981
  } catch {
982
982
  return t;
983
983
  }
984
- const o = [...e].sort((a, l) => l.start - a.start);
984
+ const o = [...e].sort((a, c) => c.start - a.start);
985
985
  let r = t;
986
986
  for (const a of o)
987
987
  r = r.slice(0, a.start) + n + r.slice(a.end);
@@ -1002,14 +1002,14 @@ class le {
1002
1002
  let r = null, a = null;
1003
1003
  if (e.regex)
1004
1004
  try {
1005
- const h = `g${e.caseInsensitive ? "i" : ""}`;
1006
- a = new RegExp(t, h);
1007
- } catch (h) {
1008
- r = h instanceof Error ? h.message : "Invalid pattern";
1005
+ const u = `g${e.caseInsensitive ? "i" : ""}`;
1006
+ a = new RegExp(t, u);
1007
+ } catch (u) {
1008
+ r = u instanceof Error ? u.message : "Invalid pattern";
1009
1009
  }
1010
1010
  else {
1011
- const h = e.caseInsensitive ? "gi" : "g";
1012
- a = new RegExp(re(t), h);
1011
+ const u = e.caseInsensitive ? "gi" : "g";
1012
+ a = new RegExp(pe(t), u);
1013
1013
  }
1014
1014
  if (!a || r) {
1015
1015
  this.setState({
@@ -1020,40 +1020,40 @@ class le {
1020
1020
  });
1021
1021
  return;
1022
1022
  }
1023
- for (let h = 0; h < s.length; h += 1) {
1024
- const u = s[h];
1025
- if (u)
1023
+ for (let u = 0; u < s.length; u += 1) {
1024
+ const d = s[u];
1025
+ if (d)
1026
1026
  for (let f = 0; f < i.columns.length; f += 1) {
1027
- const p = i.columns[f];
1028
- if (!p || n.hiddenColumns?.some((y) => String(y) === String(p.key))) continue;
1029
- const d = this.dataModel.getCell(u.id, p.key), m = at(d, p);
1030
- if (!m) continue;
1027
+ const g = i.columns[f];
1028
+ if (!g || n.hiddenColumns?.some((y) => String(y) === String(g.key))) continue;
1029
+ const p = this.dataModel.getCell(d.id, g.key), h = mt(p, g);
1030
+ if (!h) continue;
1031
1031
  a.lastIndex = 0;
1032
- let g = a.exec(m);
1033
- for (; g; ) {
1034
- const y = g.index, w = y + (g[0]?.length ?? 0);
1032
+ let m = a.exec(h);
1033
+ for (; m; ) {
1034
+ const y = m.index, w = y + (m[0]?.length ?? 0);
1035
1035
  if (o.push({
1036
- rowId: u.id,
1037
- colKey: p.key,
1038
- rowIndex: h,
1036
+ rowId: d.id,
1037
+ colKey: g.key,
1038
+ rowIndex: u,
1039
1039
  colIndex: f,
1040
1040
  start: y,
1041
1041
  end: w,
1042
- text: m
1043
- }), g[0] === "") break;
1044
- g = a.exec(m);
1042
+ text: h
1043
+ }), m[0] === "") break;
1044
+ m = a.exec(h);
1045
1045
  }
1046
1046
  }
1047
1047
  }
1048
- const l = o.length ? xt(this.state.activeIndex, o.length) : -1;
1049
- this.setState({ ...this.state, matches: o, activeIndex: l, error: null });
1048
+ const c = o.length ? At(this.state.activeIndex, o.length) : -1;
1049
+ this.setState({ ...this.state, matches: o, activeIndex: c, error: null });
1050
1050
  }
1051
1051
  setState(t) {
1052
1052
  this.state = t;
1053
1053
  for (const e of this.listeners) e(this.state);
1054
1054
  }
1055
1055
  }
1056
- class ae {
1056
+ class ye {
1057
1057
  constructor(t, e, i) {
1058
1058
  this.lockedRows = /* @__PURE__ */ new Set(), this.mode = "none", this.mode = t, this.server = e, this.user = i;
1059
1059
  }
@@ -1094,66 +1094,819 @@ class ae {
1094
1094
  return new Set(this.lockedRows);
1095
1095
  }
1096
1096
  }
1097
- const ct = 864e5;
1098
- function Rt(c) {
1099
- const t = dt(c);
1097
+ const yt = 864e5;
1098
+ function Ht(l) {
1099
+ const t = bt(l);
1100
1100
  return t ? Number.isNaN(t.getTime()) ? null : t : null;
1101
1101
  }
1102
- function ce(c) {
1103
- const t = /* @__PURE__ */ new Date(`1970-01-01T${c}`);
1102
+ function we(l) {
1103
+ const t = /* @__PURE__ */ new Date(`1970-01-01T${l}`);
1104
1104
  return Number.isNaN(t.getTime()) ? null : t;
1105
1105
  }
1106
- function de(c, t, e) {
1106
+ function be(l, t, e) {
1107
1107
  if (t == null || e.type === "string") return null;
1108
1108
  if (e.type === "boolean") return String(!!t);
1109
1109
  if (e.type === "number" && typeof t == "number") return String(t);
1110
1110
  if (e.type === "datetime") {
1111
- const i = t instanceof Date ? t : Rt(String(t));
1111
+ const i = t instanceof Date ? t : Ht(String(t));
1112
1112
  return i ? String(i.getTime()) : null;
1113
1113
  }
1114
1114
  if (e.type === "date") {
1115
- const i = t instanceof Date ? t : Rt(String(t));
1115
+ const i = t instanceof Date ? t : Ht(String(t));
1116
1116
  if (!i) return null;
1117
- const n = Math.floor(i.getTime() / ct) * ct;
1117
+ const n = Math.floor(i.getTime() / yt) * yt;
1118
1118
  return String(n);
1119
1119
  }
1120
1120
  if (e.type === "time") {
1121
- const i = t instanceof Date ? t : ce(String(t));
1122
- return i ? String(i.getTime() % ct) : null;
1121
+ const i = t instanceof Date ? t : we(String(t));
1122
+ return i ? String(i.getTime() % yt) : null;
1123
1123
  }
1124
1124
  return null;
1125
1125
  }
1126
- const Ft = 24, ht = 48, ut = 24;
1127
- function W(c, t, e = 100) {
1126
+ const nt = 24, Y = 48, st = 24;
1127
+ function X(l, t, e = 100) {
1128
1128
  const i = {
1129
1129
  // Reserve extra space for browser UI affordances (e.g. date picker icon) and formatting.
1130
1130
  date: 8
1131
1131
  };
1132
- return c.columns.map((n) => {
1132
+ return l.columns.map((n) => {
1133
1133
  const s = t.columnWidths?.[String(n.key)] ?? n.width ?? e, o = i[n.type] ?? 0;
1134
1134
  return s + o;
1135
1135
  });
1136
1136
  }
1137
- function he(c) {
1137
+ const dt = (l) => l.trim().normalize("NFKC").toLowerCase().replace(/\s+/g, " "), Se = (l) => {
1138
+ const t = [];
1139
+ if (l)
1140
+ for (const e of l) {
1141
+ const i = e.trim();
1142
+ !i || t.includes(i) || t.push(i);
1143
+ }
1144
+ return t.length === 0 ? t.push("en") : t.includes("en") || t.push("en"), t;
1145
+ }, ve = (l, t) => {
1146
+ const e = l.items.indexOf(t);
1147
+ if (e !== -1)
1148
+ return e;
1149
+ if (!l.aliases)
1150
+ return null;
1151
+ const i = l.aliases[t];
1152
+ if (!i)
1153
+ return null;
1154
+ const n = l.items.indexOf(i);
1155
+ return n === -1 ? null : n;
1156
+ }, Ce = (l, t) => {
1157
+ const e = dt(t);
1158
+ if (dt(l.id).includes(e))
1159
+ return !0;
1160
+ for (const i of l.items)
1161
+ if (dt(i).includes(e))
1162
+ return !0;
1163
+ return l.aliases ? Object.keys(l.aliases).some(
1164
+ (i) => dt(i).includes(e)
1165
+ ) : !1;
1166
+ }, xe = (l, t) => {
1167
+ if (l.langs.length === 0)
1168
+ return 0;
1169
+ let e = Number.POSITIVE_INFINITY;
1170
+ for (const i of l.langs) {
1171
+ const n = t.indexOf(i);
1172
+ n !== -1 && n < e && (e = n);
1173
+ }
1174
+ return e;
1175
+ }, Re = (l, t) => !l.langs || l.langs.length === 0 ? !0 : l.langs.some((e) => t.includes(e));
1176
+ class Me {
1177
+ constructor(t) {
1178
+ this.lists = [], this.matchers = [], this.langs = Se(t?.langs);
1179
+ }
1180
+ register(t) {
1181
+ const e = this.lists.findIndex((i) => i.id === t.id);
1182
+ e === -1 ? this.lists.push(t) : this.lists[e] = t;
1183
+ }
1184
+ registerMatch(t) {
1185
+ const e = this.matchers.findIndex((i) => i.id === t.id);
1186
+ e === -1 ? this.matchers.push(t) : this.matchers[e] = t;
1187
+ }
1188
+ unregister(t) {
1189
+ this.lists = this.lists.filter((e) => e.id !== t), this.matchers = this.matchers.filter((e) => e.id !== t);
1190
+ }
1191
+ list(t) {
1192
+ let e = [...this.lists];
1193
+ if (t?.enabledIds && t.enabledIds.length > 0) {
1194
+ const n = new Set(t.enabledIds);
1195
+ e = e.filter((s) => n.has(s.id));
1196
+ }
1197
+ const i = t?.queryText;
1198
+ return i && (e = e.filter((n) => Ce(n, i))), e;
1199
+ }
1200
+ match(t, e) {
1201
+ if (t.length === 0)
1202
+ return null;
1203
+ let i = null, n = Number.NEGATIVE_INFINITY;
1204
+ const s = e?.enabledIds ? new Set(e.enabledIds) : null;
1205
+ for (const r of this.matchers) {
1206
+ if (s && !s.has(r.id) || !Re(r, this.langs))
1207
+ continue;
1208
+ const a = r.match(t);
1209
+ if (!a)
1210
+ continue;
1211
+ const c = a.score;
1212
+ Number.isFinite(c) && c > n && (n = c, i = {
1213
+ kind: "matcher",
1214
+ matcher: r,
1215
+ step: a.step ?? 1,
1216
+ state: a.state
1217
+ });
1218
+ }
1219
+ const o = this.list(e).map((r) => ({ list: r, rank: xe(r, this.langs) })).filter((r) => Number.isFinite(r.rank)).sort((r, a) => r.rank - a.rank);
1220
+ for (const { list: r, rank: a } of o) {
1221
+ const c = [];
1222
+ let u = !1;
1223
+ for (const g of t) {
1224
+ const p = ve(r, g);
1225
+ if (p === null) {
1226
+ u = !0;
1227
+ break;
1228
+ }
1229
+ c.push(p);
1230
+ }
1231
+ if (u)
1232
+ continue;
1233
+ const d = this.inferStep(r, c);
1234
+ if (d === null)
1235
+ continue;
1236
+ const f = 10 - a;
1237
+ f > n && (n = f, i = {
1238
+ kind: "list",
1239
+ list: r,
1240
+ startIndex: c[c.length - 1] ?? 0,
1241
+ step: d
1242
+ });
1243
+ }
1244
+ return i;
1245
+ }
1246
+ inferStep(t, e) {
1247
+ if (e.length < 2)
1248
+ return 1;
1249
+ const i = t.items.length, n = this.stepBetween(t.mode, i, e[0], e[1]);
1250
+ if (n === null)
1251
+ return null;
1252
+ for (let s = 2; s < e.length; s += 1) {
1253
+ const o = this.nextIndex(t.mode, i, e[s - 1], n);
1254
+ if (o === null || o !== e[s])
1255
+ return null;
1256
+ }
1257
+ return n;
1258
+ }
1259
+ stepBetween(t, e, i, n) {
1260
+ if (t === "cycle")
1261
+ return (n - i + e) % e;
1262
+ const s = n - i;
1263
+ return s < 0 ? null : s;
1264
+ }
1265
+ nextIndex(t, e, i, n) {
1266
+ if (t === "cycle")
1267
+ return (i + n) % e;
1268
+ const s = i + n;
1269
+ return s >= e ? null : s;
1270
+ }
1271
+ }
1272
+ const ke = {
1273
+ id: "weekdays-en",
1274
+ mode: "cycle",
1275
+ langs: ["en"],
1276
+ items: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
1277
+ aliases: {
1278
+ Mon: "Monday",
1279
+ Tue: "Tuesday",
1280
+ Tues: "Tuesday",
1281
+ Wed: "Wednesday",
1282
+ Thu: "Thursday",
1283
+ Thur: "Thursday",
1284
+ Thurs: "Thursday",
1285
+ Fri: "Friday",
1286
+ Sat: "Saturday",
1287
+ Sun: "Sunday"
1288
+ }
1289
+ }, Ie = {
1290
+ id: "weekdays-ja",
1291
+ mode: "cycle",
1292
+ langs: ["ja"],
1293
+ items: ["月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日", "日曜日"],
1294
+ aliases: {
1295
+ 月曜: "月曜日",
1296
+ 月: "月曜日",
1297
+ 火曜: "火曜日",
1298
+ 火: "火曜日",
1299
+ 水曜: "水曜日",
1300
+ 水: "水曜日",
1301
+ 木曜: "木曜日",
1302
+ 木: "木曜日",
1303
+ 金曜: "金曜日",
1304
+ 金: "金曜日",
1305
+ 土曜: "土曜日",
1306
+ 土: "土曜日",
1307
+ 日曜: "日曜日",
1308
+ 日: "日曜日"
1309
+ }
1310
+ }, Ee = {
1311
+ id: "months-en",
1312
+ mode: "cycle",
1313
+ langs: ["en"],
1314
+ items: [
1315
+ "January",
1316
+ "February",
1317
+ "March",
1318
+ "April",
1319
+ "May",
1320
+ "June",
1321
+ "July",
1322
+ "August",
1323
+ "September",
1324
+ "October",
1325
+ "November",
1326
+ "December"
1327
+ ],
1328
+ aliases: {
1329
+ Jan: "January",
1330
+ Feb: "February",
1331
+ Mar: "March",
1332
+ Apr: "April",
1333
+ Jun: "June",
1334
+ Jul: "July",
1335
+ Aug: "August",
1336
+ Sep: "September",
1337
+ Sept: "September",
1338
+ Oct: "October",
1339
+ Nov: "November",
1340
+ Dec: "December"
1341
+ }
1342
+ }, Te = {
1343
+ id: "months-ja",
1344
+ mode: "cycle",
1345
+ langs: ["ja"],
1346
+ items: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]
1347
+ }, Ae = {
1348
+ id: "months-ja-traditional",
1349
+ mode: "cycle",
1350
+ langs: ["ja"],
1351
+ items: ["睦月", "如月", "弥生", "卯月", "皐月", "水無月", "文月", "葉月", "長月", "神無月", "霜月", "師走"]
1352
+ }, He = {
1353
+ id: "quarters-en",
1354
+ mode: "cycle",
1355
+ langs: ["en"],
1356
+ items: ["Q1", "Q2", "Q3", "Q4"]
1357
+ }, De = {
1358
+ id: "quarters-ja",
1359
+ mode: "cycle",
1360
+ langs: ["ja"],
1361
+ items: ["第1四半期", "第2四半期", "第3四半期", "第4四半期"]
1362
+ }, Ke = {
1363
+ id: "zodiac-animals-ja",
1364
+ mode: "cycle",
1365
+ langs: ["ja"],
1366
+ items: ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
1367
+ }, Fe = {
1368
+ id: "zodiac-signs-en",
1369
+ mode: "cycle",
1370
+ langs: ["en"],
1371
+ items: [
1372
+ "Aries",
1373
+ "Taurus",
1374
+ "Gemini",
1375
+ "Cancer",
1376
+ "Leo",
1377
+ "Virgo",
1378
+ "Libra",
1379
+ "Scorpio",
1380
+ "Sagittarius",
1381
+ "Capricorn",
1382
+ "Aquarius",
1383
+ "Pisces"
1384
+ ]
1385
+ }, Le = {
1386
+ id: "zodiac-signs-ja",
1387
+ mode: "cycle",
1388
+ langs: ["ja"],
1389
+ items: ["牡羊座", "牡牛座", "双子座", "蟹座", "獅子座", "乙女座", "天秤座", "蠍座", "射手座", "山羊座", "水瓶座", "魚座"],
1390
+ aliases: {
1391
+ さそり座: "蠍座"
1392
+ }
1393
+ }, Ve = {
1394
+ id: "directions-16-en",
1395
+ mode: "cycle",
1396
+ langs: ["en"],
1397
+ items: [
1398
+ "North",
1399
+ "North-Northeast",
1400
+ "Northeast",
1401
+ "East-Northeast",
1402
+ "East",
1403
+ "East-Southeast",
1404
+ "Southeast",
1405
+ "South-Southeast",
1406
+ "South",
1407
+ "South-Southwest",
1408
+ "Southwest",
1409
+ "West-Southwest",
1410
+ "West",
1411
+ "West-Northwest",
1412
+ "Northwest",
1413
+ "North-Northwest"
1414
+ ]
1415
+ }, _e = {
1416
+ id: "directions-16-ja",
1417
+ mode: "cycle",
1418
+ langs: ["ja"],
1419
+ items: [
1420
+ "北",
1421
+ "北北東",
1422
+ "北東",
1423
+ "東北東",
1424
+ "東",
1425
+ "東南東",
1426
+ "南東",
1427
+ "南南東",
1428
+ "南",
1429
+ "南南西",
1430
+ "南西",
1431
+ "西南西",
1432
+ "西",
1433
+ "西北西",
1434
+ "北西",
1435
+ "北北西"
1436
+ ]
1437
+ }, Pe = {
1438
+ id: "ampm-en",
1439
+ mode: "cycle",
1440
+ langs: ["en"],
1441
+ items: ["AM", "PM"],
1442
+ aliases: {
1443
+ "A.M.": "AM",
1444
+ "P.M.": "PM"
1445
+ }
1446
+ }, Be = {
1447
+ id: "ampm-ja",
1448
+ mode: "cycle",
1449
+ langs: ["ja"],
1450
+ items: ["午前", "午後"]
1451
+ }, Ne = {
1452
+ id: "seasons-en",
1453
+ mode: "cycle",
1454
+ langs: ["en"],
1455
+ items: ["Spring", "Summer", "Autumn", "Winter"],
1456
+ aliases: {
1457
+ Fall: "Autumn"
1458
+ }
1459
+ }, $e = {
1460
+ id: "seasons-ja",
1461
+ mode: "cycle",
1462
+ langs: ["ja"],
1463
+ items: ["春", "夏", "秋", "冬"]
1464
+ }, Oe = {
1465
+ id: "solfege-ja",
1466
+ mode: "cycle",
1467
+ langs: ["ja"],
1468
+ items: ["ド", "レ", "ミ", "ファ", "ソ", "ラ", "シ"]
1469
+ }, qe = {
1470
+ id: "solfege-en",
1471
+ mode: "cycle",
1472
+ langs: ["en"],
1473
+ items: ["Do", "Re", "Mi", "Fa", "Sol", "La", "Ti"],
1474
+ aliases: {
1475
+ So: "Sol",
1476
+ Si: "Ti"
1477
+ }
1478
+ }, We = {
1479
+ id: "greek-letters-en",
1480
+ mode: "cycle",
1481
+ langs: ["en"],
1482
+ items: [
1483
+ "Alpha",
1484
+ "Beta",
1485
+ "Gamma",
1486
+ "Delta",
1487
+ "Epsilon",
1488
+ "Zeta",
1489
+ "Eta",
1490
+ "Theta",
1491
+ "Iota",
1492
+ "Kappa",
1493
+ "Lambda",
1494
+ "Mu",
1495
+ "Nu",
1496
+ "Xi",
1497
+ "Omicron",
1498
+ "Pi",
1499
+ "Rho",
1500
+ "Sigma",
1501
+ "Tau",
1502
+ "Upsilon",
1503
+ "Phi",
1504
+ "Chi",
1505
+ "Psi",
1506
+ "Omega"
1507
+ ]
1508
+ }, je = {
1509
+ id: "greek-letters-ja",
1510
+ mode: "cycle",
1511
+ langs: ["ja"],
1512
+ items: [
1513
+ "アルファ",
1514
+ "ベータ",
1515
+ "ガンマ",
1516
+ "デルタ",
1517
+ "イプシロン",
1518
+ "ゼータ",
1519
+ "イータ",
1520
+ "シータ",
1521
+ "イオタ",
1522
+ "カッパ",
1523
+ "ラムダ",
1524
+ "ミュー",
1525
+ "ニュー",
1526
+ "クサイ",
1527
+ "オミクロン",
1528
+ "パイ",
1529
+ "ロー",
1530
+ "シグマ",
1531
+ "タウ",
1532
+ "ウプシロン",
1533
+ "ファイ",
1534
+ "カイ",
1535
+ "プサイ",
1536
+ "オメガ"
1537
+ ]
1538
+ }, Ue = {
1539
+ id: "greek-letters-symbols",
1540
+ mode: "cycle",
1541
+ langs: ["en", "ja"],
1542
+ items: [
1543
+ "α",
1544
+ "β",
1545
+ "γ",
1546
+ "δ",
1547
+ "ε",
1548
+ "ζ",
1549
+ "η",
1550
+ "θ",
1551
+ "ι",
1552
+ "κ",
1553
+ "λ",
1554
+ "μ",
1555
+ "ν",
1556
+ "ξ",
1557
+ "ο",
1558
+ "π",
1559
+ "ρ",
1560
+ "σ",
1561
+ "τ",
1562
+ "υ",
1563
+ "φ",
1564
+ "χ",
1565
+ "ψ",
1566
+ "ω"
1567
+ ],
1568
+ aliases: {
1569
+ ς: "σ"
1570
+ }
1571
+ }, Xe = {
1572
+ id: "rokuyo-ja",
1573
+ mode: "cycle",
1574
+ langs: ["ja"],
1575
+ items: ["先勝", "友引", "先負", "仏滅", "大安", "赤口"]
1576
+ }, ze = {
1577
+ id: "heavenly-stems-ja",
1578
+ mode: "finite",
1579
+ langs: ["ja"],
1580
+ items: ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"]
1581
+ }, Ge = {
1582
+ id: "planets-en",
1583
+ mode: "finite",
1584
+ langs: ["en"],
1585
+ items: ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
1586
+ }, Qe = {
1587
+ id: "planets-ja",
1588
+ mode: "finite",
1589
+ langs: ["ja"],
1590
+ items: ["水星", "金星", "地球", "火星", "木星", "土星", "天王星", "海王星"]
1591
+ }, Ye = {
1592
+ id: "kuji-in-ja",
1593
+ mode: "finite",
1594
+ langs: ["ja"],
1595
+ items: ["臨", "兵", "闘", "者", "皆", "陣", "烈", "在", "前"]
1596
+ }, Je = {
1597
+ id: "eight-virtues-ja",
1598
+ mode: "finite",
1599
+ langs: ["ja"],
1600
+ items: ["仁", "義", "礼", "智", "忠", "信", "孝", "悌"]
1601
+ }, Ze = [
1602
+ ke,
1603
+ Ie,
1604
+ Ee,
1605
+ Te,
1606
+ Ae,
1607
+ He,
1608
+ De,
1609
+ Ke,
1610
+ Fe,
1611
+ Le,
1612
+ Ve,
1613
+ _e,
1614
+ Pe,
1615
+ Be,
1616
+ Ne,
1617
+ $e,
1618
+ Oe,
1619
+ qe,
1620
+ We,
1621
+ je,
1622
+ Ue,
1623
+ Xe,
1624
+ ze,
1625
+ Ge,
1626
+ Qe,
1627
+ Ye,
1628
+ Je
1629
+ ], Nt = (l) => {
1630
+ const t = l % 100;
1631
+ if (t >= 11 && t <= 13) return "th";
1632
+ const e = l % 10;
1633
+ return e === 1 ? "st" : e === 2 ? "nd" : e === 3 ? "rd" : "th";
1634
+ }, Dt = (l) => {
1635
+ const t = /^(\d+)(st|nd|rd|th)$/.exec(l);
1636
+ if (!t) return null;
1637
+ const e = Number(t[1]);
1638
+ if (!Number.isFinite(e) || e <= 0) return null;
1639
+ const i = t[2];
1640
+ return Nt(e) !== i ? null : e;
1641
+ }, ti = {
1642
+ id: "ordinal-en",
1643
+ langs: ["en"],
1644
+ match(l) {
1645
+ if (l.length < 2) return null;
1646
+ const t = l.map((n) => Dt(n));
1647
+ if (t.some((n) => n === null)) return null;
1648
+ const e = t, i = e[1] - e[0];
1649
+ for (let n = 2; n < e.length; n += 1)
1650
+ if (e[n] - e[n - 1] !== i) return null;
1651
+ return { score: 80, step: i };
1652
+ },
1653
+ createIterator(l, t) {
1654
+ let e = Dt(l[l.length - 1] ?? "") ?? 0;
1655
+ return {
1656
+ next() {
1657
+ return e += t.step, e <= 0 || !Number.isFinite(e) ? { value: void 0, done: !0 } : { value: `${e}${Nt(e)}`, done: !1 };
1658
+ }
1659
+ };
1660
+ }
1661
+ }, ei = (l) => {
1662
+ for (const t of Ze)
1663
+ l.register(t);
1664
+ }, ii = (l) => {
1665
+ l.registerMatch(ti);
1666
+ }, $t = (l) => {
1667
+ const t = new Me({ langs: l });
1668
+ return ei(t), ii(t), t;
1669
+ }, ni = (l) => {
1670
+ let t = 0;
1138
1671
  return {
1139
- ...c,
1140
- startRow: Math.min(c.startRow, c.endRow),
1141
- endRow: Math.max(c.startRow, c.endRow),
1142
- startCol: Math.min(c.startCol, c.endCol),
1143
- endCol: Math.max(c.startCol, c.endCol)
1672
+ next() {
1673
+ if (l.length === 0)
1674
+ return { value: void 0, done: !0 };
1675
+ const e = l[t % l.length];
1676
+ return t += 1, { value: e, done: !1 };
1677
+ }
1144
1678
  };
1679
+ };
1680
+ class U {
1681
+ constructor(...t) {
1682
+ const e = t;
1683
+ this.seed = e, this.kind = e.length === 1 ? "copy" : "seed-repeat", this.iterator = ni(e);
1684
+ }
1685
+ static fromSeed(t, e, i) {
1686
+ const n = new U(...t);
1687
+ return n.kind = e, n.iterator = i, n;
1688
+ }
1689
+ next() {
1690
+ return this.iterator.next();
1691
+ }
1692
+ [Symbol.iterator]() {
1693
+ return this;
1694
+ }
1145
1695
  }
1146
- function st(c) {
1147
- const t = /^(.*?)(\d+)$/.exec(c);
1148
- if (!t) return null;
1149
- const e = t[1] ?? "", i = t[2] ?? "", n = Number(i);
1150
- return Number.isFinite(n) ? { prefix: e, num: n, width: i.length } : null;
1696
+ const Ot = 1e-9, si = 100, oi = (l) => ({
1697
+ next() {
1698
+ return { value: l, done: !1 };
1699
+ }
1700
+ }), Kt = (l) => {
1701
+ let t = 0;
1702
+ return {
1703
+ next() {
1704
+ if (l.length === 0)
1705
+ return { value: void 0, done: !0 };
1706
+ const e = l[t % l.length];
1707
+ return t += 1, { value: e, done: !1 };
1708
+ }
1709
+ };
1710
+ }, li = (l, t) => {
1711
+ let e = 0;
1712
+ return {
1713
+ next() {
1714
+ return e += 1, { value: l + t * e, done: !1 };
1715
+ }
1716
+ };
1717
+ }, ri = (l, t) => {
1718
+ let e = 0;
1719
+ return {
1720
+ next() {
1721
+ return e += 1, { value: new Date(l.getTime() + t * e), done: !1 };
1722
+ }
1723
+ };
1724
+ }, ai = (l, t) => {
1725
+ let e = 0;
1726
+ return {
1727
+ next() {
1728
+ return e += 1, { value: l * t ** e, done: !1 };
1729
+ }
1730
+ };
1731
+ }, ci = (l, t) => {
1732
+ if (l.kind === "matcher")
1733
+ return l.matcher.createIterator(t, { step: l.step, state: l.state });
1734
+ const { list: e, startIndex: i, step: n } = l, s = e.items.length;
1735
+ let o = i;
1736
+ return {
1737
+ next() {
1738
+ if (e.mode === "finite") {
1739
+ const r = o + n;
1740
+ return r >= s ? { value: void 0, done: !0 } : (o = r, { value: e.items[o], done: !1 });
1741
+ }
1742
+ return o = (o + n) % s, { value: e.items[o], done: !1 };
1743
+ }
1744
+ };
1745
+ }, di = (l) => l.every((t) => typeof t == "number" && Number.isFinite(t)), hi = (l) => l.every((t) => t instanceof Date && !Number.isNaN(t.getTime())), ui = (l) => l.every((t) => typeof t == "string"), fi = (l) => {
1746
+ const t = /^(.*?)(-?\d+)([^0-9]*)$/.exec(l);
1747
+ if (!t)
1748
+ return null;
1749
+ const e = t[1] ?? "", i = t[2] ?? "", n = t[3] ?? "", s = Number(i);
1750
+ if (!Number.isFinite(s))
1751
+ return null;
1752
+ const o = i.replace("-", "").length;
1753
+ return { prefix: e, num: s, width: o, suffix: n };
1754
+ }, gi = (l, t, e) => {
1755
+ let i = 0;
1756
+ return {
1757
+ next() {
1758
+ i += 1;
1759
+ const n = t + e * i, s = n < 0 ? "-" : "", o = Math.abs(n).toString().padStart(l.width, "0");
1760
+ return { value: `${l.prefix}${s}${o}${l.suffix}`, done: !1 };
1761
+ }
1762
+ };
1763
+ }, qt = [
1764
+ ["C", 100],
1765
+ ["XC", 90],
1766
+ ["L", 50],
1767
+ ["XL", 40],
1768
+ ["X", 10],
1769
+ ["IX", 9],
1770
+ ["V", 5],
1771
+ ["IV", 4],
1772
+ ["I", 1]
1773
+ ], Wt = (l) => {
1774
+ if (l < 1 || l > si)
1775
+ return null;
1776
+ let t = l, e = "";
1777
+ for (const [i, n] of qt)
1778
+ for (; t >= n; )
1779
+ e += i, t -= n;
1780
+ return e;
1781
+ }, pi = (l) => {
1782
+ if (l.length === 0 || l !== l.toUpperCase())
1783
+ return null;
1784
+ let t = l, e = 0;
1785
+ for (const [n, s] of qt)
1786
+ for (; t.startsWith(n); )
1787
+ e += s, t = t.slice(n.length);
1788
+ if (t.length > 0)
1789
+ return null;
1790
+ const i = Wt(e);
1791
+ return !i || i !== l ? null : e;
1792
+ }, mi = (l, t) => {
1793
+ let e = 0;
1794
+ return {
1795
+ next() {
1796
+ e += 1;
1797
+ const i = l + t * e, n = Wt(i);
1798
+ return n ? { value: n, done: !1 } : { value: void 0, done: !0 };
1799
+ }
1800
+ };
1801
+ }, ut = (l) => {
1802
+ if (l.length < 2)
1803
+ return null;
1804
+ const t = l[1] - l[0];
1805
+ for (let e = 2; e < l.length; e += 1)
1806
+ if (Math.abs(l[e] - l[e - 1] - t) > Ot)
1807
+ return null;
1808
+ return t;
1809
+ }, yi = (l) => {
1810
+ if (l.length < 2 || l[0] === 0)
1811
+ return null;
1812
+ const t = l[1] / l[0];
1813
+ for (let e = 2; e < l.length; e += 1)
1814
+ if (l[e - 1] === 0 || Math.abs(l[e] / l[e - 1] - t) > Ot)
1815
+ return null;
1816
+ return t;
1817
+ }, wi = (l) => {
1818
+ const t = l.map((i) => fi(i));
1819
+ if (t.every(Boolean)) {
1820
+ const i = t[0], n = t[t.length - 1];
1821
+ if (t.every(
1822
+ (s) => s?.prefix === i.prefix && s?.suffix === i.suffix
1823
+ )) {
1824
+ const s = t.map((r) => r?.num ?? 0), o = ut(s);
1825
+ if (o !== null)
1826
+ return {
1827
+ kind: "arithmetic",
1828
+ iterator: gi(
1829
+ { prefix: n.prefix, suffix: n.suffix, width: n.width },
1830
+ n.num,
1831
+ o
1832
+ )
1833
+ };
1834
+ }
1835
+ }
1836
+ const e = l.map((i) => pi(i));
1837
+ if (e.every((i) => i !== null)) {
1838
+ const i = e, n = ut(i);
1839
+ if (n !== null) {
1840
+ const s = i[i.length - 1];
1841
+ return {
1842
+ kind: "arithmetic",
1843
+ iterator: mi(s, n)
1844
+ };
1845
+ }
1846
+ }
1847
+ return null;
1848
+ }, bi = (l, t) => {
1849
+ const e = t.match(l);
1850
+ return e ? {
1851
+ kind: "list",
1852
+ iterator: ci(e, l)
1853
+ } : null;
1854
+ };
1855
+ function wt(l, t) {
1856
+ const e = t?.registry ?? $t();
1857
+ if (l.length === 0)
1858
+ return U.fromSeed(l, "seed-repeat", Kt(l));
1859
+ if (l.length === 1)
1860
+ return U.fromSeed(l, "copy", oi(l[0]));
1861
+ if (ui(l)) {
1862
+ const i = bi(l, e);
1863
+ if (i)
1864
+ return U.fromSeed(l, i.kind, i.iterator);
1865
+ const n = wi(l);
1866
+ if (n)
1867
+ return U.fromSeed(l, n.kind, n.iterator);
1868
+ }
1869
+ if (di(l)) {
1870
+ const i = ut(l);
1871
+ if (i !== null)
1872
+ return U.fromSeed(
1873
+ l,
1874
+ "arithmetic",
1875
+ li(l[l.length - 1], i)
1876
+ );
1877
+ const n = yi(l);
1878
+ if (n !== null)
1879
+ return U.fromSeed(
1880
+ l,
1881
+ "geometric",
1882
+ ai(l[l.length - 1], n)
1883
+ );
1884
+ }
1885
+ if (hi(l)) {
1886
+ const i = l.map((s) => s.getTime()), n = ut(i);
1887
+ if (n !== null)
1888
+ return U.fromSeed(
1889
+ l,
1890
+ "arithmetic",
1891
+ ri(l[l.length - 1], n)
1892
+ );
1893
+ }
1894
+ return U.fromSeed(l, "seed-repeat", Kt(l));
1151
1895
  }
1152
- function Mt(c) {
1153
- if (c instanceof Date) return c;
1154
- if (typeof c == "number" && Number.isFinite(c)) return new Date(c);
1155
- if (typeof c == "string") {
1156
- const t = c.trim();
1896
+ function Si(l) {
1897
+ return {
1898
+ ...l,
1899
+ startRow: Math.min(l.startRow, l.endRow),
1900
+ endRow: Math.max(l.startRow, l.endRow),
1901
+ startCol: Math.min(l.startCol, l.endCol),
1902
+ endCol: Math.max(l.startCol, l.endCol)
1903
+ };
1904
+ }
1905
+ function vi(l) {
1906
+ if (l instanceof Date) return l;
1907
+ if (typeof l == "number" && Number.isFinite(l)) return new Date(l);
1908
+ if (typeof l == "string") {
1909
+ const t = l.trim();
1157
1910
  if (/^\d{1,2}:\d{2}(:\d{2}(\.\d{1,3})?)?$/.test(t)) {
1158
1911
  const i = /* @__PURE__ */ new Date(`1970-01-01T${t}`);
1159
1912
  return Number.isNaN(i.getTime()) ? null : i;
@@ -1163,150 +1916,117 @@ function Mt(c) {
1163
1916
  }
1164
1917
  return null;
1165
1918
  }
1166
- function kt(c) {
1167
- if (c instanceof Date) return c;
1168
- if (typeof c == "number" && Number.isFinite(c)) return new Date(c);
1169
- if (typeof c == "string") {
1170
- const t = new Date(c);
1919
+ function Ci(l) {
1920
+ if (l instanceof Date) return l;
1921
+ if (typeof l == "number" && Number.isFinite(l)) return new Date(l);
1922
+ if (typeof l == "string") {
1923
+ const t = new Date(l);
1171
1924
  return Number.isNaN(t.getTime()) ? null : t;
1172
1925
  }
1173
1926
  return null;
1174
1927
  }
1175
- function ue(c, t) {
1176
- return new Date(Date.UTC(c, t + 1, 0)).getUTCDate();
1177
- }
1178
- function Kt(c, t) {
1179
- const e = c.getUTCFullYear(), i = c.getUTCMonth(), n = c.getUTCDate(), s = c.getUTCHours(), o = c.getUTCMinutes(), r = c.getUTCSeconds(), a = c.getUTCMilliseconds(), l = e * 12 + i + t, h = Math.floor(l / 12), u = (l % 12 + 12) % 12, f = ue(h, u), p = Math.min(n, f);
1180
- return new Date(Date.UTC(h, u, p, s, o, r, a));
1181
- }
1182
- function fe(c, t) {
1183
- return Kt(c, t * 12);
1184
- }
1185
- function Lt(c, t) {
1186
- const e = c.getFullYear(), i = c.getMonth(), n = c.getDate(), s = c.getHours(), o = c.getMinutes(), r = c.getSeconds(), a = c.getMilliseconds(), l = e * 12 + i + t, h = Math.floor(l / 12), u = (l % 12 + 12) % 12, f = new Date(h, u + 1, 0).getDate(), p = Math.min(n, f);
1187
- return new Date(h, u, p, s, o, r, a);
1188
- }
1189
- function pe(c, t) {
1190
- return Lt(c, t * 12);
1191
- }
1192
- function Vt(c, t) {
1928
+ function jt(l, t) {
1193
1929
  if (t.length !== 1) return null;
1194
- const e = he(t[0]);
1930
+ const e = Si(t[0]);
1195
1931
  if (e.kind !== "cells") return null;
1196
1932
  const i = e.endCol - e.startCol + 1, n = e.endRow - e.startRow + 1;
1197
- if (i !== 1 || n !== 1 && n !== 2) return null;
1198
- const o = c.getSchema().columns[e.startCol];
1199
- if (!o) return null;
1200
- if (o.type === "boolean")
1201
- return n !== 1 ? null : {
1202
- colKey: o.key,
1203
- colIndex: e.startCol,
1204
- startRowIndex: e.startRow,
1205
- endRowIndex: e.endRow,
1206
- mode: "copy"
1207
- };
1208
- if (n === 1)
1209
- return {
1210
- colKey: o.key,
1211
- colIndex: e.startCol,
1212
- startRowIndex: e.startRow,
1213
- endRowIndex: e.endRow,
1214
- mode: "copy"
1215
- };
1216
- if (o.type === "string") {
1217
- const r = c.listRows(), a = r[e.startRow], l = r[e.endRow];
1218
- if (!a || !l) return null;
1219
- const h = String(c.getCell(a.id, o.key) ?? ""), u = String(c.getCell(l.id, o.key) ?? ""), f = st(h), p = st(u);
1220
- return !f || !p || f.prefix !== p.prefix || f.width !== p.width ? null : {
1221
- colKey: o.key,
1222
- colIndex: e.startCol,
1223
- startRowIndex: e.startRow,
1224
- endRowIndex: e.endRow,
1225
- mode: "sequence"
1226
- };
1227
- }
1228
- return o.type === "number" || o.type === "date" || o.type === "time" || o.type === "datetime" ? {
1933
+ if (i !== 1 || n < 1) return null;
1934
+ const o = l.getSchema().columns[e.startCol];
1935
+ return o ? n === 1 ? {
1936
+ colKey: o.key,
1937
+ colIndex: e.startCol,
1938
+ startRowIndex: e.startRow,
1939
+ endRowIndex: e.endRow,
1940
+ mode: "copy"
1941
+ } : o.type === "boolean" ? null : o.type === "number" || o.type === "date" || o.type === "time" || o.type === "datetime" || o.type === "string" ? {
1229
1942
  colKey: o.key,
1230
1943
  colIndex: e.startCol,
1231
1944
  startRowIndex: e.startRow,
1232
1945
  endRowIndex: e.endRow,
1233
1946
  mode: "sequence"
1234
- } : null;
1947
+ } : null : null;
1235
1948
  }
1236
- function ge(c, t) {
1237
- const e = c.getSchema(), i = c.listRows(), n = e.columns[t.colIndex];
1238
- if (!n) return null;
1239
- const s = i[t.startRowIndex], o = i[t.endRowIndex];
1240
- if (!s || !o) return null;
1241
- const r = c.getCell(s.id, n.key), a = c.getCell(o.id, n.key);
1242
- if (t.mode === "copy")
1949
+ function xi(l, t, e) {
1950
+ const i = l.getSchema(), n = l.listRows(), s = i.columns[t.colIndex];
1951
+ if (!s) return null;
1952
+ const o = [];
1953
+ for (let a = t.startRowIndex; a <= t.endRowIndex; a += 1) {
1954
+ const c = n[a];
1955
+ if (!c) return null;
1956
+ o.push(l.getCell(c.id, s.key));
1957
+ }
1958
+ if (t.mode === "copy") {
1959
+ const a = o[o.length - 1];
1243
1960
  return () => a;
1244
- if (n.type === "number") {
1245
- const l = typeof r == "number" ? r : Number(r), h = typeof a == "number" ? a : Number(a);
1246
- if (!Number.isFinite(l) || !Number.isFinite(h)) return null;
1247
- const u = h - l;
1248
- return (f) => h + u * f;
1249
- }
1250
- if (n.type === "date" || n.type === "time" || n.type === "datetime") {
1251
- const l = n.type === "time" ? Mt(r) : kt(r), h = n.type === "time" ? Mt(a) : kt(a);
1252
- if (!l || !h) return null;
1253
- const u = l.getTime(), f = h.getTime(), p = f - u;
1254
- if (n.type === "time")
1255
- return (d) => new Date(f + p * d);
1256
- if (n.type === "date") {
1257
- const d = l.getUTCDate() === h.getUTCDate();
1258
- if (d && l.getUTCMonth() === h.getUTCMonth()) {
1259
- const g = h.getUTCFullYear() - l.getUTCFullYear();
1260
- if (g !== 0) {
1261
- const y = new Date(Date.UTC(h.getUTCFullYear(), h.getUTCMonth(), h.getUTCDate()));
1262
- return (w) => fe(y, g * w);
1263
- }
1264
- } else if (d) {
1265
- const g = (h.getUTCFullYear() - l.getUTCFullYear()) * 12 + (h.getUTCMonth() - l.getUTCMonth());
1266
- if (g !== 0) {
1267
- const y = new Date(Date.UTC(h.getUTCFullYear(), h.getUTCMonth(), h.getUTCDate()));
1268
- return (w) => Kt(y, g * w);
1961
+ }
1962
+ const r = $t(e);
1963
+ if (s.type === "number") {
1964
+ const a = o.map((f) => typeof f == "number" ? f : Number(f));
1965
+ if (!a.every((f) => Number.isFinite(f))) return null;
1966
+ const c = wt(a, { registry: r }), u = [];
1967
+ let d = !1;
1968
+ return (f) => {
1969
+ for (; !d && u.length < f; ) {
1970
+ const g = c.next();
1971
+ if (g.done) {
1972
+ d = !0;
1973
+ break;
1269
1974
  }
1975
+ u.push(g.value);
1270
1976
  }
1271
- } else {
1272
- const d = l.getDate() === h.getDate();
1273
- if (d && l.getMonth() === h.getMonth()) {
1274
- const g = h.getFullYear() - l.getFullYear();
1275
- if (g !== 0)
1276
- return (y) => pe(h, g * y);
1277
- } else if (d) {
1278
- const g = (h.getFullYear() - l.getFullYear()) * 12 + (h.getMonth() - l.getMonth());
1279
- if (g !== 0)
1280
- return (y) => Lt(h, g * y);
1977
+ return f <= 0 ? null : u[f - 1] ?? null;
1978
+ };
1979
+ }
1980
+ if (s.type === "date" || s.type === "time" || s.type === "datetime") {
1981
+ const a = o.map(
1982
+ (f) => s.type === "time" ? vi(f) : Ci(f)
1983
+ );
1984
+ if (!a.every((f) => f instanceof Date)) return null;
1985
+ const c = wt(a, { registry: r }), u = [];
1986
+ let d = !1;
1987
+ return (f) => {
1988
+ for (; !d && u.length < f; ) {
1989
+ const g = c.next();
1990
+ if (g.done) {
1991
+ d = !0;
1992
+ break;
1993
+ }
1994
+ u.push(g.value);
1281
1995
  }
1282
- }
1283
- return (d) => new Date(f + p * d);
1996
+ return f <= 0 ? null : u[f - 1] ?? null;
1997
+ };
1284
1998
  }
1285
- if (n.type === "string") {
1286
- const l = String(r ?? ""), h = String(a ?? ""), u = st(l), f = st(h);
1287
- if (!u || !f || u.prefix !== f.prefix || u.width !== f.width) return null;
1288
- const p = f.num - u.num;
1289
- return (d) => {
1290
- const m = f.num + p * d, g = m < 0 ? "-" : "", y = Math.abs(m), w = String(y).padStart(f.width, "0");
1291
- return `${f.prefix}${g}${w}`;
1999
+ if (s.type === "string") {
2000
+ const a = o.map((f) => String(f ?? "")), c = wt(a, { registry: r }), u = [];
2001
+ let d = !1;
2002
+ return (f) => {
2003
+ for (; !d && u.length < f; ) {
2004
+ const g = c.next();
2005
+ if (g.done) {
2006
+ d = !0;
2007
+ break;
2008
+ }
2009
+ u.push(g.value);
2010
+ }
2011
+ return f <= 0 ? null : u[f - 1] ?? null;
1292
2012
  };
1293
2013
  }
1294
2014
  return null;
1295
2015
  }
1296
- const _t = 12, Pt = 14;
1297
- function Bt(c, t = _t) {
1298
- return new DOMRect(c.right - t - 1, c.bottom - t - 1, t, t);
2016
+ const Ut = 12, Xt = 14;
2017
+ function zt(l, t = Ut) {
2018
+ return new DOMRect(l.right - t - 1, l.bottom - t - 1, t, t);
1299
2019
  }
1300
- function $t(c, t, e) {
1301
- return c >= e.left && c <= e.right && t >= e.top && t <= e.bottom;
2020
+ function Gt(l, t, e) {
2021
+ return l >= e.left && l <= e.right && t >= e.top && t <= e.bottom;
1302
2022
  }
1303
- function ot(c, t, e, i, n) {
2023
+ function ft(l, t, e, i, n) {
1304
2024
  if (n === "readonly") return !1;
1305
- const s = Vt(c, t);
1306
- return !(!s || !e || e === "__all__" || i === null || i === "__all__" || i === null || i !== s.colKey || c.isReadonly(e, i));
2025
+ const s = jt(l, t);
2026
+ return !(!s || !e || e === "__all__" || i === null || i === "__all__" || i === null || i !== s.colKey || l.isReadonly(e, i));
1307
2027
  }
1308
- function ft(c) {
1309
- const t = c.style, e = t?.decorations;
2028
+ function St(l) {
2029
+ const t = l.style, e = t?.decorations;
1310
2030
  return {
1311
2031
  backgroundColor: t?.backgroundColor,
1312
2032
  textColor: t?.textColor,
@@ -1316,59 +2036,59 @@ function ft(c) {
1316
2036
  strike: e?.strike
1317
2037
  };
1318
2038
  }
1319
- function X(c, t) {
2039
+ function Z(l, t) {
1320
2040
  return t ? {
1321
- backgroundColor: t.backgroundColor ?? c.backgroundColor,
1322
- textColor: t.textColor ?? c.textColor,
1323
- bold: t.bold ?? c.bold,
1324
- italic: t.italic ?? c.italic,
1325
- underline: t.underline ?? c.underline,
1326
- strike: t.strike ?? c.strike
1327
- } : c;
2041
+ backgroundColor: t.backgroundColor ?? l.backgroundColor,
2042
+ textColor: t.textColor ?? l.textColor,
2043
+ bold: t.bold ?? l.bold,
2044
+ italic: t.italic ?? l.italic,
2045
+ underline: t.underline ?? l.underline,
2046
+ strike: t.strike ?? l.strike
2047
+ } : l;
1328
2048
  }
1329
- function me(c, t, e) {
1330
- const i = ft(e), n = c.resolveConditionalStyle(t, e).delta ?? {}, s = c.getCellStyle(t, e.key) ?? {}, o = X(X(i, n), s);
2049
+ function Ri(l, t, e) {
2050
+ const i = St(e), n = l.resolveConditionalStyle(t, e).delta ?? {}, s = l.getCellStyle(t, e.key) ?? {}, o = Z(Z(i, n), s);
1331
2051
  return { columnStyle: i, cellStyle: s, resolved: o };
1332
2052
  }
1333
- function It(c) {
2053
+ function Ft(l) {
1334
2054
  let t = "";
1335
- c.backgroundColor && (t += `background-color:${c.backgroundColor};`), c.textColor && (t += `color:${c.textColor};`), c.bold && (t += "font-weight:600;"), c.italic && (t += "font-style:italic;");
2055
+ l.backgroundColor && (t += `background-color:${l.backgroundColor};`), l.textColor && (t += `color:${l.textColor};`), l.bold && (t += "font-weight:600;"), l.italic && (t += "font-style:italic;");
1336
2056
  const e = [];
1337
- return c.underline && e.push("underline"), c.strike && e.push("line-through"), e.length && (t += `text-decoration-line:${e.join(" ")};`), t;
2057
+ return l.underline && e.push("underline"), l.strike && e.push("line-through"), e.length && (t += `text-decoration-line:${e.join(" ")};`), t;
1338
2058
  }
1339
- function Nt(c, t) {
1340
- const e = c.sorts?.[0];
2059
+ function Qt(l, t) {
2060
+ const e = l.sorts?.[0];
1341
2061
  return e && e.key === t ? e.dir : null;
1342
2062
  }
1343
- function Ot(c, t) {
1344
- if ((c.filters ?? []).some((n) => {
2063
+ function Yt(l, t) {
2064
+ if ((l.filters ?? []).some((n) => {
1345
2065
  const s = n;
1346
2066
  return s?.kind === "values" && s.key === t;
1347
2067
  })) return !0;
1348
- const i = c.columnDiagnostics?.[t];
2068
+ const i = l.columnDiagnostics?.[t];
1349
2069
  return !!(i?.errors || i?.warnings);
1350
2070
  }
1351
- function ye() {
2071
+ function Mi() {
1352
2072
  return `
1353
2073
  <svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true" focusable="false">
1354
2074
  <path d="M3 5h18l-7 8v6l-4 2v-8L3 5z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/>
1355
2075
  </svg>
1356
2076
  `.trim();
1357
2077
  }
1358
- function we(c) {
2078
+ function ki(l) {
1359
2079
  return `
1360
2080
  <svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true" focusable="false">
1361
- <path d="${c === "asc" ? "M12 6l6 8H6l6-8z" : "M12 18l-6-8h12l-6 8z"}" fill="currentColor"/>
2081
+ <path d="${l === "asc" ? "M12 6l6 8H6l6-8z" : "M12 18l-6-8h12l-6 8z"}" fill="currentColor"/>
1362
2082
  </svg>
1363
2083
  `.trim();
1364
2084
  }
1365
- function be(c, t, e, i, n, s) {
2085
+ function Ii(l, t, e, i, n, s) {
1366
2086
  const o = Math.min(10, Math.floor(Math.min(i, n) / 2));
1367
2087
  if (o <= 0) return;
1368
2088
  const r = s === "error" ? "#ef4444" : "#f59e0b";
1369
- c.save(), c.fillStyle = r, c.beginPath(), c.moveTo(t + i, e), c.lineTo(t + i - o, e), c.lineTo(t + i, e + o), c.closePath(), c.fill(), c.restore();
2089
+ l.save(), l.fillStyle = r, l.beginPath(), l.moveTo(t + i, e), l.lineTo(t + i - o, e), l.lineTo(t + i, e + o), l.closePath(), l.fill(), l.restore();
1370
2090
  }
1371
- class qt {
2091
+ class Jt {
1372
2092
  constructor() {
1373
2093
  this.numberFormatCache = /* @__PURE__ */ new Map(), this.dateParseCache = /* @__PURE__ */ new Map();
1374
2094
  }
@@ -1380,22 +2100,22 @@ class qt {
1380
2100
  parseIsoDate(t) {
1381
2101
  const e = this.dateParseCache.get(t);
1382
2102
  if (e) return e;
1383
- const i = dt(t);
2103
+ const i = bt(t);
1384
2104
  return !i || Number.isNaN(i.getTime()) ? null : (this.dateParseCache.set(t, i), i);
1385
2105
  }
1386
2106
  }
1387
- function ve(c, t, e, i, n) {
1388
- c.save(), c.globalAlpha = n, c.strokeStyle = "rgba(15,23,42,1)", c.lineWidth = 2, c.lineJoin = "round", c.beginPath(), c.moveTo(t, e), c.lineTo(t + i, e), c.lineTo(t + Math.round(i * 0.62), e + Math.round(i * 0.46)), c.lineTo(t + Math.round(i * 0.38), e + Math.round(i * 0.46)), c.closePath(), c.stroke(), c.beginPath(), c.moveTo(t + Math.round(i * 0.46), e + Math.round(i * 0.46)), c.lineTo(t + Math.round(i * 0.46), e + i), c.lineTo(t + Math.round(i * 0.54), e + i - 2), c.lineTo(t + Math.round(i * 0.54), e + Math.round(i * 0.46)), c.stroke(), c.restore();
2107
+ function Ei(l, t, e, i, n) {
2108
+ l.save(), l.globalAlpha = n, l.strokeStyle = "rgba(15,23,42,1)", l.lineWidth = 2, l.lineJoin = "round", l.beginPath(), l.moveTo(t, e), l.lineTo(t + i, e), l.lineTo(t + Math.round(i * 0.62), e + Math.round(i * 0.46)), l.lineTo(t + Math.round(i * 0.38), e + Math.round(i * 0.46)), l.closePath(), l.stroke(), l.beginPath(), l.moveTo(t + Math.round(i * 0.46), e + Math.round(i * 0.46)), l.lineTo(t + Math.round(i * 0.46), e + i), l.lineTo(t + Math.round(i * 0.54), e + i - 2), l.lineTo(t + Math.round(i * 0.54), e + Math.round(i * 0.46)), l.stroke(), l.restore();
1389
2109
  }
1390
- function Ce(c, t, e, i, n, s) {
1391
- c.save(), c.globalAlpha = n, c.fillStyle = "rgba(15,23,42,1)", c.beginPath(), s === "asc" ? (c.moveTo(t + i / 2, e), c.lineTo(t + i, e + i), c.lineTo(t, e + i)) : (c.moveTo(t, e), c.lineTo(t + i, e), c.lineTo(t + i / 2, e + i)), c.closePath(), c.fill(), c.restore();
2110
+ function Ti(l, t, e, i, n, s) {
2111
+ l.save(), l.globalAlpha = n, l.fillStyle = "rgba(15,23,42,1)", l.beginPath(), s === "asc" ? (l.moveTo(t + i / 2, e), l.lineTo(t + i, e + i), l.lineTo(t, e + i)) : (l.moveTo(t, e), l.lineTo(t + i, e), l.lineTo(t + i / 2, e + i)), l.closePath(), l.fill(), l.restore();
1392
2112
  }
1393
- class pt {
2113
+ class vt {
1394
2114
  constructor(t) {
1395
2115
  this.n = t, this.tree = new Array(t + 1).fill(0);
1396
2116
  }
1397
2117
  static from(t) {
1398
- const e = new pt(t.length);
2118
+ const e = new vt(t.length);
1399
2119
  for (let i = 0; i < t.length; i += 1) e.add(i, t[i] ?? 0);
1400
2120
  return e;
1401
2121
  }
@@ -1435,9 +2155,9 @@ class pt {
1435
2155
  return Math.min(this.n - 1, i);
1436
2156
  }
1437
2157
  }
1438
- class nt {
2158
+ class ht {
1439
2159
  constructor(t) {
1440
- this.dataModel = t, this.tableEl = null, this.defaultRowHeight = ut, this.rowHeaderWidth = ht, this.activeRowId = null, this.activeColKey = null, this.selection = [], this.valueFormatCache = new qt(), this.measureCache = /* @__PURE__ */ new Map(), this.frame = 0;
2160
+ this.dataModel = t, this.tableEl = null, this.defaultRowHeight = st, this.rowHeaderWidth = Y, this.activeRowId = null, this.activeColKey = null, this.selection = [], this.valueFormatCache = new Jt(), this.measureCache = /* @__PURE__ */ new Map(), this.frame = 0;
1441
2161
  }
1442
2162
  mount(t) {
1443
2163
  this.tableEl = document.createElement("table"), this.tableEl.dataset.extableRenderer = "html", t.innerHTML = "", t.appendChild(this.tableEl), this.render();
@@ -1452,19 +2172,19 @@ class nt {
1452
2172
  if (this.frame += 1, !this.tableEl) return;
1453
2173
  const e = this.tableEl.parentElement, i = e?.scrollTop ?? 0, n = e?.scrollLeft ?? 0, s = this.dataModel.getSchema(), o = this.dataModel.getView(), r = this.dataModel.listRows();
1454
2174
  this.tableEl.innerHTML = "";
1455
- const a = W(s, o), l = s.columns.map((m) => ft(m)), h = l.map((m) => It(m)), u = this.rowHeaderWidth + a.reduce((m, g) => m + (g ?? 0), 0), f = document.createElement("colgroup"), p = document.createElement("col");
1456
- p.style.width = `${this.rowHeaderWidth}px`, f.appendChild(p);
1457
- for (const m of a) {
1458
- const g = document.createElement("col");
1459
- m && (g.style.width = `${m}px`), f.appendChild(g);
1460
- }
1461
- this.tableEl.appendChild(f), this.tableEl.style.width = `${u}px`, this.tableEl.appendChild(this.renderHeader(s, a));
1462
- const d = document.createElement("tbody");
1463
- for (const m of r)
1464
- d.appendChild(this.renderRow(m, s, a, l, h));
1465
- this.tableEl.appendChild(d), this.updateActiveClasses(), this.applySelectionClasses(), e && (e.scrollTop = i, e.scrollLeft = n);
1466
- for (const [m, g] of Array.from(this.measureCache.entries()))
1467
- g.frame !== this.frame && this.measureCache.delete(m);
2175
+ const a = X(s, o), c = s.columns.map((h) => St(h)), u = c.map((h) => Ft(h)), d = this.rowHeaderWidth + a.reduce((h, m) => h + (m ?? 0), 0), f = document.createElement("colgroup"), g = document.createElement("col");
2176
+ g.style.width = `${this.rowHeaderWidth}px`, f.appendChild(g);
2177
+ for (const h of a) {
2178
+ const m = document.createElement("col");
2179
+ h && (m.style.width = `${h}px`), f.appendChild(m);
2180
+ }
2181
+ this.tableEl.appendChild(f), this.tableEl.style.width = `${d}px`, this.tableEl.appendChild(this.renderHeader(s, a));
2182
+ const p = document.createElement("tbody");
2183
+ for (const h of r)
2184
+ p.appendChild(this.renderRow(h, s, a, c, u));
2185
+ this.tableEl.appendChild(p), this.updateActiveClasses(), this.applySelectionClasses(), e && (e.scrollTop = i, e.scrollLeft = n);
2186
+ for (const [h, m] of Array.from(this.measureCache.entries()))
2187
+ m.frame !== this.frame && this.measureCache.delete(h);
1468
2188
  }
1469
2189
  destroy() {
1470
2190
  _(this.tableEl), this.tableEl = null;
@@ -1509,18 +2229,18 @@ class nt {
1509
2229
  for (let r = 0; r < t.columns.length; r += 1) {
1510
2230
  const a = t.columns[r];
1511
2231
  if (!a) continue;
1512
- const l = document.createElement("th");
1513
- l.dataset.colKey = a.key;
1514
- const h = Nt(o, a.key), u = Ot(o, a.key);
1515
- h ? l.dataset.extableSortDir = h : l.removeAttribute("data-extable-sort-dir"), u ? l.dataset.extableFsActive = "1" : l.removeAttribute("data-extable-fs-active");
2232
+ const c = document.createElement("th");
2233
+ c.dataset.colKey = a.key;
2234
+ const u = Qt(o, a.key), d = Yt(o, a.key);
2235
+ u ? c.dataset.extableSortDir = u : c.removeAttribute("data-extable-sort-dir"), d ? c.dataset.extableFsActive = "1" : c.removeAttribute("data-extable-fs-active");
1516
2236
  const f = document.createElement("div");
1517
2237
  f.className = "extable-col-header";
1518
- const p = document.createElement("span");
1519
- p.className = "extable-col-header-text", p.textContent = a.header ?? a.key;
1520
- const d = document.createElement("button");
1521
- d.type = "button", d.className = "extable-filter-sort-trigger", d.dataset.extableFsOpen = "1", d.dataset.extableColKey = a.key, d.title = "Filter / Sort", d.innerHTML = h ? we(h) : ye(), f.appendChild(p), f.appendChild(d), l.appendChild(f);
1522
- const m = e[r] ?? a.width;
1523
- m && (l.style.width = `${m}px`), l.dataset.colKey = a.key, this.activeColKey !== null && this.activeColKey === a.key && l.classList.add("extable-active-col-header"), n.appendChild(l);
2238
+ const g = document.createElement("span");
2239
+ g.className = "extable-col-header-text", g.textContent = a.header ?? a.key;
2240
+ const p = document.createElement("button");
2241
+ p.type = "button", p.className = "extable-filter-sort-trigger", p.dataset.extableFsOpen = "1", p.dataset.extableColKey = a.key, p.title = "Filter / Sort", p.innerHTML = u ? ki(u) : Mi(), f.appendChild(g), f.appendChild(p), c.appendChild(f);
2242
+ const h = e[r] ?? a.width;
2243
+ h && (c.style.width = `${h}px`), c.dataset.colKey = a.key, this.activeColKey !== null && this.activeColKey === a.key && c.classList.add("extable-active-col-header"), n.appendChild(c);
1524
2244
  }
1525
2245
  return i.appendChild(n), i;
1526
2246
  }
@@ -1529,59 +2249,59 @@ class nt {
1529
2249
  o.dataset.rowId = t.id;
1530
2250
  const r = this.dataModel.getView(), a = document.createElement("th");
1531
2251
  a.scope = "row", a.classList.add("extable-row-header");
1532
- const l = this.dataModel.getDisplayIndex(t.id) ?? "";
1533
- a.textContent = String(l), a.style.width = `${this.rowHeaderWidth}px`, this.activeRowId === t.id && a.classList.add("extable-active-row-header"), o.appendChild(a);
1534
- for (let u = 0; u < e.columns.length; u += 1) {
1535
- const f = e.columns[u];
2252
+ const c = this.dataModel.getDisplayIndex(t.id) ?? "";
2253
+ a.textContent = String(c), a.style.width = `${this.rowHeaderWidth}px`, this.activeRowId === t.id && a.classList.add("extable-active-row-header"), o.appendChild(a);
2254
+ for (let d = 0; d < e.columns.length; d += 1) {
2255
+ const f = e.columns[d];
1536
2256
  if (!f) continue;
1537
- const p = document.createElement("td");
1538
- p.classList.add("extable-cell"), p.dataset.colKey = f.key, f.type === "boolean" && p.classList.add("extable-boolean");
1539
- const d = this.dataModel.hasPending(t.id, f.key), m = this.dataModel.resolveConditionalStyle(t.id, f), g = this.dataModel.getCellStyle(t.id, f.key);
1540
- if (!g && !m.delta && !d) {
1541
- const M = s[u] ?? "";
1542
- M && (p.style.cssText = M);
2257
+ const g = document.createElement("td");
2258
+ g.classList.add("extable-cell"), g.dataset.colKey = f.key, f.type === "boolean" && g.classList.add("extable-boolean");
2259
+ const p = this.dataModel.hasPending(t.id, f.key), h = this.dataModel.resolveConditionalStyle(t.id, f), m = this.dataModel.getCellStyle(t.id, f.key);
2260
+ if (!m && !h.delta && !p) {
2261
+ const M = s[d] ?? "";
2262
+ M && (g.style.cssText = M);
1543
2263
  } else {
1544
- const M = n[u] ?? {}, A = m.delta ? X(M, m.delta) : M, K = g ? X(A, g) : A, H = d ? { ...K, textColor: void 0 } : K, P = It(H);
1545
- P && (p.style.cssText = P);
2264
+ const M = n[d] ?? {}, P = h.delta ? Z(M, h.delta) : M, H = m ? Z(P, m) : P, D = p ? { ...H, textColor: void 0 } : H, F = Ft(D);
2265
+ F && (g.style.cssText = F);
1546
2266
  }
1547
- const y = i[u] ?? r.columnWidths?.[f.key] ?? f.width;
1548
- y && (p.style.width = `${y}px`);
2267
+ const y = i[d] ?? r.columnWidths?.[f.key] ?? f.width;
2268
+ y && (g.style.width = `${y}px`);
1549
2269
  const w = r.wrapText?.[f.key] ?? f.wrapText;
1550
- p.classList.add(w ? "cell-wrap" : "cell-nowrap");
1551
- const S = this.dataModel.getRawCell(t.id, f.key), b = this.dataModel.resolveCellValue(t.id, f), C = b.textOverride ?? (m.forceErrorText ? "#ERROR" : void 0), v = C ? { text: C } : this.formatValue(b.value, f);
1552
- p.textContent = v.text, v.color && (p.style.color = v.color);
1553
- const R = this.dataModel.getCellMarker(t.id, f.key);
1554
- R ? (p.classList.toggle("extable-diag-warning", R.level === "warning"), p.classList.toggle("extable-diag-error", R.level === "error"), p.dataset.extableDiagMessage = R.message) : (p.classList.remove("extable-diag-warning", "extable-diag-error"), p.removeAttribute("data-extable-diag-message"));
1555
- const I = f.style?.align ?? (f.type === "number" ? "right" : "left");
1556
- p.classList.add(I === "right" ? "align-right" : "align-left");
1557
- const x = de(S, b.value, f);
1558
- if (x !== null)
1559
- p.dataset.raw = x;
2270
+ g.classList.add(w ? "cell-wrap" : "cell-nowrap");
2271
+ const C = this.dataModel.getRawCell(t.id, f.key), v = this.dataModel.resolveCellValue(t.id, f), b = v.textOverride ?? (h.forceErrorText ? "#ERROR" : void 0), S = b ? { text: b } : this.formatValue(v.value, f);
2272
+ g.textContent = S.text, S.color && (g.style.color = S.color);
2273
+ const x = this.dataModel.getCellMarker(t.id, f.key);
2274
+ x ? (g.classList.toggle("extable-diag-warning", x.level === "warning"), g.classList.toggle("extable-diag-error", x.level === "error"), g.dataset.extableDiagMessage = x.message) : (g.classList.remove("extable-diag-warning", "extable-diag-error"), g.removeAttribute("data-extable-diag-message"));
2275
+ const R = f.style?.align ?? (f.type === "number" ? "right" : "left");
2276
+ g.classList.add(R === "right" ? "align-right" : "align-left");
2277
+ const E = be(C, v.value, f);
2278
+ if (E !== null)
2279
+ g.dataset.raw = E;
1560
2280
  else {
1561
- const M = S == null ? "" : String(S);
1562
- p.dataset.raw = M;
2281
+ const M = C == null ? "" : String(C);
2282
+ g.dataset.raw = M;
1563
2283
  }
1564
- d && p.classList.add("pending"), this.dataModel.isReadonly(t.id, f.key) ? p.classList.add("extable-readonly", "extable-readonly-muted") : p.classList.add("extable-editable"), this.activeRowId === t.id && this.activeColKey !== null && this.activeColKey === f.key && p.classList.add("extable-active-cell"), o.appendChild(p);
2284
+ p && g.classList.add("pending"), this.dataModel.isReadonly(t.id, f.key) ? g.classList.add("extable-readonly", "extable-readonly-muted") : g.classList.add("extable-editable"), this.activeRowId === t.id && this.activeColKey !== null && this.activeColKey === f.key && g.classList.add("extable-active-cell"), o.appendChild(g);
1565
2285
  }
1566
- if (e.columns.some((u) => r.wrapText?.[u.key] ?? u.wrapText)) {
1567
- let u = this.defaultRowHeight;
2286
+ if (e.columns.some((d) => r.wrapText?.[d.key] ?? d.wrapText)) {
2287
+ let d = this.defaultRowHeight;
1568
2288
  for (let f = 0; f < e.columns.length; f += 1) {
1569
- const p = e.columns[f];
1570
- if (!p || !p.wrapText) continue;
1571
- const d = i[f] ?? r.columnWidths?.[p.key] ?? p.width ?? 100, m = this.dataModel.resolveCellValue(t.id, p), g = this.dataModel.resolveConditionalStyle(t.id, p), w = m.textOverride ?? (g.forceErrorText ? "#ERROR" : void 0) ? "#ERROR" : m.value === null || m.value === void 0 ? "" : String(m.value), S = this.dataModel.getRowVersion(t.id), b = `${t.id}|${p.key}|${S}|${d}|${w}`, C = this.measureCache.get(b);
1572
- if (C) {
1573
- C.frame = this.frame, this.measureCache.set(b, C), u = Math.max(u, C.height);
2289
+ const g = e.columns[f];
2290
+ if (!g || !g.wrapText) continue;
2291
+ const p = i[f] ?? r.columnWidths?.[g.key] ?? g.width ?? 100, h = this.dataModel.resolveCellValue(t.id, g), m = this.dataModel.resolveConditionalStyle(t.id, g), w = h.textOverride ?? (m.forceErrorText ? "#ERROR" : void 0) ? "#ERROR" : h.value === null || h.value === void 0 ? "" : String(h.value), C = this.dataModel.getRowVersion(t.id), v = `${t.id}|${g.key}|${C}|${p}|${w}`, b = this.measureCache.get(v);
2292
+ if (b) {
2293
+ b.frame = this.frame, this.measureCache.set(v, b), d = Math.max(d, b.height);
1574
2294
  continue;
1575
2295
  }
1576
- const v = document.createElement("span");
1577
- v.style.visibility = "hidden", v.style.position = "absolute", v.style.left = "-10000px", v.style.top = "0", v.style.whiteSpace = "pre-wrap", v.style.overflowWrap = "anywhere", v.style.display = "inline-block", v.style.width = `${d}px`, v.textContent = w;
1578
- const R = this.tableEl?.parentElement;
1579
- if (!R) continue;
1580
- R.appendChild(v);
1581
- const I = v.clientHeight + 10;
1582
- v.remove(), this.measureCache.set(b, { height: I, frame: this.frame }), u = Math.max(u, I);
2296
+ const S = document.createElement("span");
2297
+ S.style.visibility = "hidden", S.style.position = "absolute", S.style.left = "-10000px", S.style.top = "0", S.style.whiteSpace = "pre-wrap", S.style.overflowWrap = "anywhere", S.style.display = "inline-block", S.style.width = `${p}px`, S.textContent = w;
2298
+ const x = this.tableEl?.parentElement;
2299
+ if (!x) continue;
2300
+ x.appendChild(S);
2301
+ const R = S.clientHeight + 10;
2302
+ S.remove(), this.measureCache.set(v, { height: R, frame: this.frame }), d = Math.max(d, R);
1583
2303
  }
1584
- o.style.height = `${u}px`, this.dataModel.setRowHeight(t.id, u);
2304
+ o.style.height = `${d}px`, this.dataModel.setRowHeight(t.id, d);
1585
2305
  } else
1586
2306
  o.style.height = `${this.defaultRowHeight}px`, this.dataModel.setRowHeight(t.id, this.defaultRowHeight);
1587
2307
  return o;
@@ -1626,14 +2346,14 @@ class nt {
1626
2346
  for (const i of this.selection) {
1627
2347
  const n = Math.max(0, Math.min(i.startRow, i.endRow)), s = Math.min(t.length - 1, Math.max(i.startRow, i.endRow)), o = Math.max(0, Math.min(i.startCol, i.endCol)), r = Math.min(e.columns.length - 1, Math.max(i.startCol, i.endCol));
1628
2348
  for (let a = n; a <= s; a += 1) {
1629
- const l = t[a];
1630
- if (!l) continue;
1631
- const h = l.querySelector("th.extable-row-header");
1632
- h && h.classList.add("extable-selected");
1633
- const u = Array.from(l.querySelectorAll("td"));
2349
+ const c = t[a];
2350
+ if (!c) continue;
2351
+ const u = c.querySelector("th.extable-row-header");
2352
+ u && u.classList.add("extable-selected");
2353
+ const d = Array.from(c.querySelectorAll("td"));
1634
2354
  for (let f = o; f <= r; f += 1) {
1635
- const p = u[f];
1636
- p && p.classList.add("extable-selected");
2355
+ const g = d[f];
2356
+ g && g.classList.add("extable-selected");
1637
2357
  }
1638
2358
  }
1639
2359
  }
@@ -1649,35 +2369,35 @@ class nt {
1649
2369
  return { text: s, color: o };
1650
2370
  }
1651
2371
  if ((e.type === "date" || e.type === "time" || e.type === "datetime") && (t instanceof Date || typeof t == "string")) {
1652
- const i = e.type === "date" ? Y(e.dateFormat, "date") : e.type === "time" ? Y(e.timeFormat, "time") : Y(e.dateTimeFormat, "datetime");
2372
+ const i = e.type === "date" ? J(e.dateFormat, "date") : e.type === "time" ? J(e.timeFormat, "time") : J(e.dateTimeFormat, "datetime");
1653
2373
  let n = null;
1654
- return t instanceof Date ? n = t : n = this.valueFormatCache.parseIsoDate(t), n ? { text: At(n, i) } : { text: String(t) };
2374
+ return t instanceof Date ? n = t : n = this.valueFormatCache.parseIsoDate(t), n ? { text: Bt(n, i) } : { text: String(t) };
1655
2375
  }
1656
2376
  return { text: String(t) };
1657
2377
  }
1658
2378
  }
1659
- const O = class O {
2379
+ const W = class W {
1660
2380
  constructor(t, e = () => "direct") {
1661
- this.getEditMode = e, this.root = null, this.canvas = null, this.spacer = null, this.overlayLayer = null, this.tooltip = null, this.tooltipTarget = null, this.tooltipMessage = null, this.rowHeight = ut, this.headerHeight = Ft, this.lineHeight = 16, this.padding = 12, this.rowHeaderWidth = ht, this.activeRowId = null, this.activeColKey = null, this.selection = [], this.valueFormatCache = new qt(), this.textMeasureCache = /* @__PURE__ */ new Map(), this.frame = 0, this.cursorTimer = null, this.pendingCursorPoint = null, this.hoverHeaderColKey = null, this.hoverHeaderIcon = !1, this.rowHeightCacheKey = null, this.rowHeightMeasuredVersion = /* @__PURE__ */ new Map(), this.rowHeightMeasureRaf = null, this.rowHeightMeasureTask = null, this.heightIndex = null, this.handleClick = (i) => {
2381
+ this.getEditMode = e, this.root = null, this.canvas = null, this.spacer = null, this.overlayLayer = null, this.tooltip = null, this.tooltipTarget = null, this.tooltipMessage = null, this.rowHeight = st, this.headerHeight = nt, this.lineHeight = 16, this.padding = 12, this.rowHeaderWidth = Y, this.activeRowId = null, this.activeColKey = null, this.selection = [], this.valueFormatCache = new Jt(), this.textMeasureCache = /* @__PURE__ */ new Map(), this.frame = 0, this.cursorTimer = null, this.pendingCursorPoint = null, this.hoverHeaderColKey = null, this.hoverHeaderIcon = !1, this.rowHeightCacheKey = null, this.rowHeightMeasuredVersion = /* @__PURE__ */ new Map(), this.rowHeightMeasureRaf = null, this.rowHeightMeasureTask = null, this.heightIndex = null, this.handleClick = (i) => {
1662
2382
  if (!this.root || !this.canvas) return;
1663
2383
  const n = this.canvas.getBoundingClientRect(), s = i.clientX - n.left, o = i.clientY - n.top, r = s + this.root.scrollLeft, a = o;
1664
2384
  if (a >= this.headerHeight || r < this.rowHeaderWidth) return;
1665
- const l = this.dataModel.getSchema(), h = this.dataModel.getView(), u = W(l, h);
1666
- let f = this.rowHeaderWidth, p = -1;
1667
- for (let C = 0; C < u.length; C += 1) {
1668
- const v = u[C] ?? 100;
1669
- if (r >= f && r <= f + v) {
1670
- p = C;
2385
+ const c = this.dataModel.getSchema(), u = this.dataModel.getView(), d = X(c, u);
2386
+ let f = this.rowHeaderWidth, g = -1;
2387
+ for (let b = 0; b < d.length; b += 1) {
2388
+ const S = d[b] ?? 100;
2389
+ if (r >= f && r <= f + S) {
2390
+ g = b;
1671
2391
  break;
1672
2392
  }
1673
- f += v;
2393
+ f += S;
1674
2394
  }
1675
- if (p < 0) return;
1676
- const d = l.columns[p];
1677
- if (!d) return;
1678
- const m = u[p] ?? 100, g = 18, w = f + m - g - 4, S = Math.floor((this.headerHeight - g) / 2);
1679
- r >= w && r <= w + g && a >= S && a <= S + g && this.root.dispatchEvent(
1680
- new CustomEvent("extable:filter-sort-open", { bubbles: !0, detail: { colKey: d.key } })
2395
+ if (g < 0) return;
2396
+ const p = c.columns[g];
2397
+ if (!p) return;
2398
+ const h = d[g] ?? 100, m = 18, w = f + h - m - 4, C = Math.floor((this.headerHeight - m) / 2);
2399
+ r >= w && r <= w + m && a >= C && a <= C + m && this.root.dispatchEvent(
2400
+ new CustomEvent("extable:filter-sort-open", { bubbles: !0, detail: { colKey: p.key } })
1681
2401
  );
1682
2402
  }, this.handlePointerMove = (i) => {
1683
2403
  this.pendingCursorPoint = { x: i.clientX, y: i.clientY }, !this.cursorTimer && (this.cursorTimer = window.setTimeout(() => {
@@ -1691,7 +2411,7 @@ const O = class O {
1691
2411
  }
1692
2412
  mount(t) {
1693
2413
  this.root = t, this.canvas = document.createElement("canvas");
1694
- const e = O.MAX_CANVAS_DIM_PX;
2414
+ const e = W.MAX_CANVAS_DIM_PX;
1695
2415
  this.canvas.width = Math.max(1, Math.min(e, Math.floor(t.clientWidth || 600))), this.canvas.height = Math.max(1, Math.min(e, Math.floor(t.clientHeight || 400))), this.canvas.style.width = `${this.canvas.width}px`, this.canvas.style.height = `${this.canvas.height}px`, this.canvas.dataset.extableRenderer = "canvas", this.canvas.style.position = "sticky", this.canvas.style.top = "0", this.canvas.style.left = "0", this.canvas.style.zIndex = "1", this.canvas.style.cursor = "cell", this.canvas.addEventListener("pointermove", this.handlePointerMove), this.canvas.addEventListener("pointerleave", this.handlePointerLeave), this.canvas.addEventListener("click", this.handleClick), this.spacer = document.createElement("div"), this.spacer.style.width = "1px", this.tooltip && this.tooltip.remove(), this.overlayLayer && this.overlayLayer.remove(), this.overlayLayer = document.createElement("div"), this.overlayLayer.className = "extable-overlay-layer", this.tooltip = document.createElement("div"), this.tooltip.className = "extable-tooltip", this.tooltip.dataset.visible = "0", this.overlayLayer.appendChild(this.tooltip), t.innerHTML = "", t.style.position = "relative", t.appendChild(this.overlayLayer), t.appendChild(this.canvas), t.appendChild(this.spacer), this.render();
1696
2416
  }
1697
2417
  setActiveCell(t, e) {
@@ -1707,142 +2427,138 @@ const O = class O {
1707
2427
  if (!e) return;
1708
2428
  e.font = "14px sans-serif";
1709
2429
  let i = e.font;
1710
- const n = this.activeRowId === "__all__" && this.activeColKey === "__all__", s = this.dataModel.getSchema(), o = this.dataModel.getView(), r = this.dataModel.listRows(), a = W(s, o), l = s.columns.map((k) => ft(k)), h = /* @__PURE__ */ new Map(), u = s.columns.some((k) => o.wrapText?.[k.key] ?? k.wrapText), f = u ? this.getRowHeightCacheKey(s, o, a) : null;
1711
- f !== this.rowHeightCacheKey && (this.rowHeightCacheKey = f, this.rowHeightMeasuredVersion.clear(), this.rowHeightMeasureTask = null), u || this.cancelRowHeightMeasurement(), this.ensureHeightIndex(r, u ? f : null, u);
1712
- const p = this.heightIndex;
1713
- if (!p) return;
1714
- const d = this.rowHeaderWidth + a.reduce((k, D) => k + (D ?? 0), 0), m = t?.clientWidth ?? (this.root.clientWidth || 600), g = t?.clientHeight ?? (this.root.clientHeight || this.canvas.height || 400), y = O.MAX_CANVAS_DIM_PX, w = Math.max(1, Math.min(y, Math.floor(m))), S = Math.max(1, Math.min(y, Math.floor(g)));
1715
- this.canvas.width !== w && (this.canvas.width = w), this.canvas.height !== S && (this.canvas.height = S), this.canvas.style.width = `${w}px`, this.canvas.style.height = `${S}px`, e.font = "14px sans-serif", i = e.font, this.refreshTooltipPosition();
1716
- const b = t?.scrollTop ?? this.root.scrollTop, C = t?.scrollLeft ?? this.root.scrollLeft, v = (k) => {
1717
- const D = k + 1, E = Math.max(
2430
+ const n = this.activeRowId === "__all__" && this.activeColKey === "__all__", s = this.dataModel.getSchema(), o = this.dataModel.getView(), r = this.dataModel.listRows(), a = X(s, o), c = s.columns.map((k) => St(k)), u = /* @__PURE__ */ new Map(), d = s.columns.some((k) => o.wrapText?.[k.key] ?? k.wrapText), f = d ? this.getRowHeightCacheKey(s, o, a) : null;
2431
+ f !== this.rowHeightCacheKey && (this.rowHeightCacheKey = f, this.rowHeightMeasuredVersion.clear(), this.rowHeightMeasureTask = null), d || this.cancelRowHeightMeasurement(), this.ensureHeightIndex(r, d ? f : null, d);
2432
+ const g = this.heightIndex;
2433
+ if (!g) return;
2434
+ const p = this.rowHeaderWidth + a.reduce((k, A) => k + (A ?? 0), 0), h = t?.clientWidth ?? (this.root.clientWidth || 600), m = t?.clientHeight ?? (this.root.clientHeight || this.canvas.height || 400), y = W.MAX_CANVAS_DIM_PX, w = Math.max(1, Math.min(y, Math.floor(h))), C = Math.max(1, Math.min(y, Math.floor(m)));
2435
+ this.canvas.width !== w && (this.canvas.width = w), this.canvas.height !== C && (this.canvas.height = C), this.canvas.style.width = `${w}px`, this.canvas.style.height = `${C}px`, e.font = "14px sans-serif", i = e.font, this.refreshTooltipPosition();
2436
+ const v = t?.scrollTop ?? this.root.scrollTop, b = t?.scrollLeft ?? this.root.scrollLeft, S = (k) => {
2437
+ const A = k + 1, I = Math.max(
1718
2438
  0,
1719
- Math.min(r.length - 1, p.fenwick.lowerBound(D))
1720
- ), q = p.fenwick.sum(E);
1721
- let F = E, $ = 0;
1722
- const B = (this.canvas?.height ?? 0) + this.rowHeight * 2;
1723
- for (let T = E; T < r.length && $ < B; T += 1)
1724
- $ += p.heights[T] ?? this.rowHeight, F = T + 1;
1725
- return { accum: q, visibleStart: E, visibleEnd: F };
2439
+ Math.min(r.length - 1, g.fenwick.lowerBound(A))
2440
+ ), j = g.fenwick.sum(I);
2441
+ let K = I, $ = 0;
2442
+ const N = (this.canvas?.height ?? 0) + this.rowHeight * 2;
2443
+ for (let T = I; T < r.length && $ < N; T += 1)
2444
+ $ += g.heights[T] ?? this.rowHeight, K = T + 1;
2445
+ return { accum: j, visibleStart: I, visibleEnd: K };
1726
2446
  };
1727
- let R = p.fenwick.total(), I = Math.max(
1728
- 0,
1729
- Math.min(b, Math.max(0, R - this.rowHeight))
1730
- ), { accum: x, visibleStart: M, visibleEnd: A } = v(I);
1731
- if (u && f) {
2447
+ let x = g.fenwick.total();
2448
+ const R = this.canvas?.height ?? this.root.clientHeight, E = Math.max(0, R - this.headerHeight);
2449
+ let M = Math.max(0, x - E), P = Math.max(0, Math.min(v, M)), { accum: H, visibleStart: D, visibleEnd: F } = S(P);
2450
+ if (d && f) {
1732
2451
  const k = {};
1733
- for (let D = M; D < A; D += 1) {
1734
- const E = r[D];
1735
- if (!E) continue;
1736
- const q = this.dataModel.getRowVersion(E.id);
1737
- if (this.rowHeightMeasuredVersion.get(E.id) === q) continue;
1738
- const F = this.measureRowHeight(e, E, s, a);
1739
- k[E.id] = F, this.rowHeightMeasuredVersion.set(E.id, q);
2452
+ for (let A = D; A < F; A += 1) {
2453
+ const I = r[A];
2454
+ if (!I) continue;
2455
+ const j = this.dataModel.getRowVersion(I.id);
2456
+ if (this.rowHeightMeasuredVersion.get(I.id) === j) continue;
2457
+ const K = this.measureRowHeight(e, I, s, a);
2458
+ k[I.id] = K, this.rowHeightMeasuredVersion.set(I.id, j);
1740
2459
  }
1741
- this.applyRowHeightUpdates(k), R = p.fenwick.total(), this.dataModel.setRowHeightsBulk(k), I = Math.max(
1742
- 0,
1743
- Math.min(b, Math.max(0, R - this.rowHeight))
1744
- ), { accum: x, visibleStart: M, visibleEnd: A } = v(I), (this.rowHeightMeasureTask || Object.keys(k).length > 0) && this.scheduleRowHeightMeasurement();
2460
+ this.applyRowHeightUpdates(k), x = g.fenwick.total(), this.dataModel.setRowHeightsBulk(k), M = Math.max(0, x - E), P = Math.max(0, Math.min(v, M)), { accum: H, visibleStart: D, visibleEnd: F } = S(P), (this.rowHeightMeasureTask || Object.keys(k).length > 0) && this.scheduleRowHeightMeasurement();
1745
2461
  }
1746
- this.spacer && (this.spacer.style.height = `${R + this.headerHeight}px`, this.spacer.style.width = `${d}px`);
1747
- const K = this.rowHeaderWidth - C;
2462
+ this.spacer && (this.spacer.style.height = `${M}px`, this.spacer.style.width = `${p}px`);
2463
+ const O = this.rowHeaderWidth - b;
1748
2464
  e.clearRect(0, 0, this.canvas.width, this.canvas.height), e.fillStyle = "#e5e7eb", e.fillRect(0, 0, this.rowHeaderWidth, this.canvas.height);
1749
- let H = this.headerHeight + x - I;
1750
- for (let k = M; k < A; k += 1) {
1751
- const D = r[k], E = p.heights[k] ?? this.rowHeight;
1752
- e.strokeStyle = "#d0d7de", e.fillStyle = "#e5e7eb", e.fillRect(0, H, this.rowHeaderWidth, E), e.strokeRect(0, H, this.rowHeaderWidth, E);
1753
- const q = this.dataModel.getDisplayIndex(D.id) ?? "";
1754
- this.activeRowId === D.id && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(0, H, this.rowHeaderWidth, E)), e.fillStyle = "#0f172a", e.font = "bold 14px sans-serif", e.textAlign = "center", e.textBaseline = "middle", e.fillText(String(q), this.rowHeaderWidth / 2, H + E / 2), e.font = i, e.textAlign = "left", e.textBaseline = "alphabetic", e.save(), e.beginPath(), e.rect(
2465
+ let B = this.headerHeight + H - P;
2466
+ for (let k = D; k < F; k += 1) {
2467
+ const A = r[k], I = g.heights[k] ?? this.rowHeight;
2468
+ e.strokeStyle = "#d0d7de", e.fillStyle = "#e5e7eb", e.fillRect(0, B, this.rowHeaderWidth, I), e.strokeRect(0, B, this.rowHeaderWidth, I);
2469
+ const j = this.dataModel.getDisplayIndex(A.id) ?? "";
2470
+ this.activeRowId === A.id && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(0, B, this.rowHeaderWidth, I)), e.fillStyle = "#0f172a", e.font = "bold 14px sans-serif", e.textAlign = "center", e.textBaseline = "middle", e.fillText(String(j), this.rowHeaderWidth / 2, B + I / 2), e.font = i, e.textAlign = "left", e.textBaseline = "alphabetic", e.save(), e.beginPath(), e.rect(
1755
2471
  this.rowHeaderWidth,
1756
2472
  this.headerHeight,
1757
2473
  this.canvas.width - this.rowHeaderWidth,
1758
2474
  this.canvas.height - this.headerHeight
1759
- ), e.clip(), e.translate(K, 0);
1760
- let F = 0, $ = "";
1761
- for (let B = 0; B < s.columns.length; B += 1) {
1762
- const T = s.columns[B], L = a[B] ?? 100;
2475
+ ), e.clip(), e.translate(O, 0);
2476
+ let K = 0, $ = "";
2477
+ for (let N = 0; N < s.columns.length; N += 1) {
2478
+ const T = s.columns[N], L = a[N] ?? 100;
1763
2479
  if (!T) {
1764
- F += L;
2480
+ K += L;
1765
2481
  continue;
1766
2482
  }
1767
- const V = this.dataModel.isReadonly(D.id, T.key);
2483
+ const V = this.dataModel.isReadonly(A.id, T.key);
1768
2484
  e.strokeStyle = "#d0d7de";
1769
- const Z = this.dataModel.resolveConditionalStyle(D.id, T), z = this.dataModel.getCellStyle(D.id, T.key), G = l[B] ?? {}, gt = Z.delta ? X(G, Z.delta) : G, U = z ? X(gt, z) : gt, Ut = V ? "#f3f4f6" : U.backgroundColor ?? "#ffffff";
1770
- e.fillStyle = Ut, e.fillRect(F, H, L, E), e.strokeRect(F, H, L, E);
1771
- const mt = this.dataModel.resolveCellValue(D.id, T), lt = mt.textOverride ?? (Z.forceErrorText ? "#ERROR" : void 0) ? { text: "#ERROR" } : this.formatValue(mt.value, T), Wt = lt.text, jt = T.style?.align ?? (T.type === "number" ? "right" : "left");
1772
- if (this.activeRowId === D.id && this.activeColKey !== null && this.activeColKey === T.key && (e.strokeStyle = "#3b82f6", e.lineWidth = 2, e.strokeRect(F + 1, H + 1, L - 2, E - 2), e.lineWidth = 1, ot(
2485
+ const ot = this.dataModel.resolveConditionalStyle(A.id, T), tt = this.dataModel.getCellStyle(A.id, T.key), et = c[N] ?? {}, Ct = ot.delta ? Z(et, ot.delta) : et, G = tt ? Z(Ct, tt) : Ct, Zt = V ? "#f3f4f6" : G.backgroundColor ?? "#ffffff";
2486
+ e.fillStyle = Zt, e.fillRect(K, B, L, I), e.strokeRect(K, B, L, I);
2487
+ const xt = this.dataModel.resolveCellValue(A.id, T), pt = xt.textOverride ?? (ot.forceErrorText ? "#ERROR" : void 0) ? { text: "#ERROR" } : this.formatValue(xt.value, T), te = pt.text, ee = T.style?.align ?? (T.type === "number" ? "right" : "left");
2488
+ if (this.activeRowId === A.id && this.activeColKey !== null && this.activeColKey === T.key && (e.strokeStyle = "#3b82f6", e.lineWidth = 2, e.strokeRect(K + 1, B + 1, L - 2, I - 2), e.lineWidth = 1, ft(
1773
2489
  this.dataModel,
1774
2490
  this.selection,
1775
2491
  this.activeRowId,
1776
2492
  this.activeColKey,
1777
2493
  this.getEditMode()
1778
2494
  ))) {
1779
- const N = _t, Q = F + L - N - 1, J = H + E - N - 1;
1780
- e.fillStyle = "#3b82f6", e.fillRect(Q, J, N, N), e.strokeStyle = "#ffffff", e.strokeRect(Q + 0.5, J + 0.5, N - 1, N - 1);
2495
+ const q = Ut, it = K + L - q - 1, lt = B + I - q - 1;
2496
+ e.fillStyle = "#3b82f6", e.fillRect(it, lt, q, q), e.strokeStyle = "#ffffff", e.strokeRect(it + 0.5, lt + 0.5, q - 1, q - 1);
1781
2497
  }
1782
- e.fillStyle = this.dataModel.hasPending(D.id, T.key) ? "#b91c1c" : lt.color ? lt.color : V ? "#94a3b8" : U.textColor ?? "#0f172a";
1783
- const Yt = o.wrapText?.[T.key] ?? T.wrapText ?? !1, yt = T.type === "boolean" && (!T.booleanDisplay || T.booleanDisplay === "checkbox"), Xt = T.type === "boolean" && !!(T.booleanDisplay && T.booleanDisplay !== "checkbox");
1784
- if (yt)
2498
+ e.fillStyle = this.dataModel.hasPending(A.id, T.key) ? "#b91c1c" : pt.color ? pt.color : V ? "#94a3b8" : G.textColor ?? "#0f172a";
2499
+ const ie = o.wrapText?.[T.key] ?? T.wrapText ?? !1, Rt = T.type === "boolean" && (!T.booleanDisplay || T.booleanDisplay === "checkbox"), ne = T.type === "boolean" && !!(T.booleanDisplay && T.booleanDisplay !== "checkbox");
2500
+ if (Rt)
1785
2501
  e.font = i, $ = "";
1786
2502
  else {
1787
- const N = `${U.italic ? "i" : ""}${U.bold ? "b" : ""}`;
1788
- if (N !== $) {
1789
- const Q = h.get(N);
1790
- if (Q) e.font = Q;
2503
+ const q = `${G.italic ? "i" : ""}${G.bold ? "b" : ""}`;
2504
+ if (q !== $) {
2505
+ const it = u.get(q);
2506
+ if (it) e.font = it;
1791
2507
  else {
1792
- const J = U.bold ? "600 " : "", bt = `${U.italic ? "italic " : ""}${J}14px sans-serif`.trim();
1793
- h.set(N, bt), e.font = bt;
2508
+ const lt = G.bold ? "600 " : "", kt = `${G.italic ? "italic " : ""}${lt}14px sans-serif`.trim();
2509
+ u.set(q, kt), e.font = kt;
1794
2510
  }
1795
- $ = N;
2511
+ $ = q;
1796
2512
  }
1797
2513
  }
1798
2514
  this.drawCellText(
1799
2515
  e,
1800
- Wt,
1801
- F + 8,
1802
- H + 6,
2516
+ te,
2517
+ K + 8,
2518
+ B + 2,
1803
2519
  L - 12,
1804
- E - 12,
1805
- Yt,
1806
- jt,
1807
- yt,
1808
- Xt,
1809
- { underline: !!U.underline, strike: !!U.strike }
2520
+ I - 8,
2521
+ ie,
2522
+ ee,
2523
+ Rt,
2524
+ ne,
2525
+ { underline: !!G.underline, strike: !!G.strike }
1810
2526
  );
1811
- const wt = this.dataModel.getCellMarker(D.id, T.key);
1812
- wt && be(e, F, H, L, E, wt.level), F += L;
2527
+ const Mt = this.dataModel.getCellMarker(A.id, T.key);
2528
+ Mt && Ii(e, K, B, L, I, Mt.level), K += L;
1813
2529
  }
1814
- e.restore(), H += E;
2530
+ e.restore(), B += I;
1815
2531
  }
1816
- e.fillStyle = "#e5e7eb", e.fillRect(0, 0, this.canvas.width, this.headerHeight), e.strokeStyle = "#d0d7de", e.strokeRect(0, 0, this.rowHeaderWidth, this.headerHeight), e.fillStyle = "#9ca3af", e.beginPath(), e.moveTo(4, 4), e.lineTo(16, 4), e.lineTo(4, 16), e.closePath(), e.fill(), this.activeRowId && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(0, 0, this.rowHeaderWidth, this.headerHeight)), e.save(), e.beginPath(), e.rect(this.rowHeaderWidth, 0, this.canvas.width - this.rowHeaderWidth, this.headerHeight), e.clip(), e.translate(K, 0);
1817
- let P = 0;
2532
+ e.fillStyle = "#e5e7eb", e.fillRect(0, 0, this.canvas.width, this.headerHeight), e.strokeStyle = "#d0d7de", e.strokeRect(0, 0, this.rowHeaderWidth, this.headerHeight), e.fillStyle = "#9ca3af", e.beginPath(), e.moveTo(4, 4), e.lineTo(16, 4), e.lineTo(4, 16), e.closePath(), e.fill(), this.activeRowId && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(0, 0, this.rowHeaderWidth, this.headerHeight)), e.save(), e.beginPath(), e.rect(this.rowHeaderWidth, 0, this.canvas.width - this.rowHeaderWidth, this.headerHeight), e.clip(), e.translate(O, 0);
2533
+ let z = 0;
1818
2534
  for (let k = 0; k < s.columns.length; k += 1) {
1819
- const D = s.columns[k], E = a[k] ?? 100;
1820
- if (!D) {
1821
- P += E;
2535
+ const A = s.columns[k], I = a[k] ?? 100;
2536
+ if (!A) {
2537
+ z += I;
1822
2538
  continue;
1823
2539
  }
1824
- this.activeColKey !== null && this.activeColKey === D.key && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(P, 0, E, this.headerHeight)), e.strokeStyle = "#d0d7de", e.strokeRect(P, 0, E, this.headerHeight), e.fillStyle = "#0f172a", e.font = "bold 14px sans-serif", e.fillText(D.header ?? D.key, P + 8, this.headerHeight - 8), e.font = i;
1825
- const F = Nt(o, D.key), $ = Ot(o, D.key), B = this.hoverHeaderColKey !== null && this.hoverHeaderColKey === D.key;
1826
- if (!!F || $ || B) {
1827
- const L = B ? 0.9 : $ || F ? 0.75 : 0.45, V = 16, z = P + E - V - 6, G = Math.floor((this.headerHeight - V) / 2);
1828
- F ? Ce(e, z + 3, G + 3, V - 6, L, F) : ve(e, z + 2, G + 2, V - 4, L);
2540
+ this.activeColKey !== null && this.activeColKey === A.key && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(z, 0, I, this.headerHeight)), e.strokeStyle = "#d0d7de", e.strokeRect(z, 0, I, this.headerHeight), e.fillStyle = "#0f172a", e.font = "bold 14px sans-serif", e.fillText(A.header ?? A.key, z + 8, this.headerHeight - 8), e.font = i;
2541
+ const K = Qt(o, A.key), $ = Yt(o, A.key), N = this.hoverHeaderColKey !== null && this.hoverHeaderColKey === A.key;
2542
+ if (!!K || $ || N) {
2543
+ const L = N ? 0.9 : $ || K ? 0.75 : 0.45, V = 16, tt = z + I - V - 6, et = Math.floor((this.headerHeight - V) / 2);
2544
+ K ? Ti(e, tt + 3, et + 3, V - 6, L, K) : Ei(e, tt + 2, et + 2, V - 4, L);
1829
2545
  }
1830
- P += E;
2546
+ z += I;
1831
2547
  }
1832
2548
  if (e.restore(), this.selection.length) {
1833
2549
  e.save(), e.strokeStyle = "#3b82f6", e.fillStyle = "rgba(59,130,246,0.12)";
1834
2550
  for (const k of this.selection) {
1835
- const D = Math.max(0, Math.min(k.startRow, k.endRow)), E = Math.min(r.length - 1, Math.max(k.startRow, k.endRow)), q = Math.max(0, Math.min(k.startCol, k.endCol)), F = Math.min(
2551
+ const A = Math.max(0, Math.min(k.startRow, k.endRow)), I = Math.min(r.length - 1, Math.max(k.startRow, k.endRow)), j = Math.max(0, Math.min(k.startCol, k.endCol)), K = Math.min(
1836
2552
  s.columns.length - 1,
1837
2553
  Math.max(k.startCol, k.endCol)
1838
- ), $ = this.headerHeight + p.fenwick.sum(D) - I, B = p.fenwick.sum(E + 1) - p.fenwick.sum(D);
2554
+ ), $ = this.headerHeight + g.fenwick.sum(A) - P, N = g.fenwick.sum(I + 1) - g.fenwick.sum(A);
1839
2555
  let T = this.rowHeaderWidth;
1840
- for (let V = 0; V < q; V += 1)
2556
+ for (let V = 0; V < j; V += 1)
1841
2557
  T += a[V] ?? 100;
1842
2558
  let L = 0;
1843
- for (let V = q; V <= F; V += 1)
2559
+ for (let V = j; V <= K; V += 1)
1844
2560
  L += a[V] ?? 100;
1845
- T -= C, e.fillRect(T, $, L, B), e.strokeRect(T + 0.5, $ + 0.5, L - 1, B - 1);
2561
+ T -= b, e.fillRect(T, $, L, N), e.strokeRect(T + 0.5, $ + 0.5, L - 1, N - 1);
1846
2562
  }
1847
2563
  e.restore();
1848
2564
  }
@@ -1862,19 +2578,19 @@ const O = class O {
1862
2578
  const a = t[r];
1863
2579
  if (!a) continue;
1864
2580
  o.set(a.id, r);
1865
- let l = this.rowHeight;
2581
+ let c = this.rowHeight;
1866
2582
  if (i && e) {
1867
- const h = this.dataModel.getRowVersion(a.id), u = this.rowHeightMeasuredVersion.get(a.id), f = this.dataModel.getRowHeight(a.id);
1868
- u === h && typeof f == "number" && (l = f);
2583
+ const u = this.dataModel.getRowVersion(a.id), d = this.rowHeightMeasuredVersion.get(a.id), f = this.dataModel.getRowHeight(a.id);
2584
+ d === u && typeof f == "number" && (c = f);
1869
2585
  }
1870
- s[r] = l;
2586
+ s[r] = c;
1871
2587
  }
1872
2588
  this.heightIndex = {
1873
2589
  key: e,
1874
2590
  rowsRef: t,
1875
2591
  idToIndex: o,
1876
2592
  heights: s,
1877
- fenwick: pt.from(s)
2593
+ fenwick: vt.from(s)
1878
2594
  };
1879
2595
  }
1880
2596
  applyRowHeightUpdates(t) {
@@ -1904,101 +2620,95 @@ const O = class O {
1904
2620
  const t = this.canvas.getContext("2d");
1905
2621
  if (!t) return;
1906
2622
  t.font = "14px sans-serif";
1907
- const e = this.dataModel.getSchema(), i = this.dataModel.getView(), n = W(e, i);
2623
+ const e = this.dataModel.getSchema(), i = this.dataModel.getView(), n = X(e, i);
1908
2624
  if (!e.columns.some((f) => i.wrapText?.[f.key] ?? f.wrapText)) return;
1909
2625
  const o = this.getRowHeightCacheKey(e, i, n);
1910
2626
  this.rowHeightCacheKey !== o && (this.rowHeightCacheKey = o, this.rowHeightMeasuredVersion.clear(), this.rowHeightMeasureTask = null);
1911
2627
  const r = this.rowHeightMeasureTask ?? { key: o, nextIndex: 0 };
1912
2628
  if (r.key !== o) return;
1913
- const a = this.dataModel.listRows(), l = {};
1914
- let h = 0;
1915
- const u = performance.now();
1916
- for (; r.nextIndex < a.length && h < O.ROW_HEIGHT_MEASURE_CHUNK && !(performance.now() - u > O.ROW_HEIGHT_MEASURE_TIME_BUDGET_MS); ) {
2629
+ const a = this.dataModel.listRows(), c = {};
2630
+ let u = 0;
2631
+ const d = performance.now();
2632
+ for (; r.nextIndex < a.length && u < W.ROW_HEIGHT_MEASURE_CHUNK && !(performance.now() - d > W.ROW_HEIGHT_MEASURE_TIME_BUDGET_MS); ) {
1917
2633
  const f = a[r.nextIndex];
1918
2634
  if (r.nextIndex += 1, !f) continue;
1919
- const p = this.dataModel.getRowVersion(f.id);
1920
- if (this.rowHeightMeasuredVersion.get(f.id) === p) continue;
1921
- const d = this.measureRowHeight(t, f, e, n);
1922
- l[f.id] = d, this.rowHeightMeasuredVersion.set(f.id, p), h += 1;
2635
+ const g = this.dataModel.getRowVersion(f.id);
2636
+ if (this.rowHeightMeasuredVersion.get(f.id) === g) continue;
2637
+ const p = this.measureRowHeight(t, f, e, n);
2638
+ c[f.id] = p, this.rowHeightMeasuredVersion.set(f.id, g), u += 1;
1923
2639
  }
1924
- this.rowHeightMeasureTask = r.nextIndex < a.length ? r : null, this.ensureHeightIndex(a, this.rowHeightCacheKey, !0), this.applyRowHeightUpdates(l), this.dataModel.setRowHeightsBulk(l), this.rowHeightMeasureTask && this.scheduleRowHeightMeasurement();
2640
+ this.rowHeightMeasureTask = r.nextIndex < a.length ? r : null, this.ensureHeightIndex(a, this.rowHeightCacheKey, !0), this.applyRowHeightUpdates(c), this.dataModel.setRowHeightsBulk(c), this.rowHeightMeasureTask && this.scheduleRowHeightMeasurement();
1925
2641
  }
1926
2642
  getCellElements() {
1927
2643
  return null;
1928
2644
  }
1929
2645
  hitTest(t) {
1930
2646
  if (!this.root || !this.canvas) return null;
1931
- const e = this.canvas.getBoundingClientRect(), i = t.clientX - e.left, n = t.clientY - e.top, s = i + this.root.scrollLeft, o = this.dataModel.getSchema(), r = this.dataModel.getView(), a = this.dataModel.listRows(), l = this.headerHeight, h = W(o, r), u = o.columns.some((x) => r.wrapText?.[x.key] ?? x.wrapText), f = u ? this.getRowHeightCacheKey(o, r, h) : null;
1932
- this.ensureHeightIndex(a, f, u);
1933
- const p = this.heightIndex;
1934
- if (!p) return null;
1935
- const d = p.fenwick.total(), m = Math.max(
1936
- 0,
1937
- Math.min(
1938
- this.root.scrollTop - this.headerHeight,
1939
- Math.max(0, d - this.rowHeight)
1940
- )
1941
- );
1942
- if (n < l && i < this.rowHeaderWidth)
2647
+ const e = this.canvas.getBoundingClientRect(), i = t.clientX - e.left, n = t.clientY - e.top, s = i + this.root.scrollLeft, o = this.dataModel.getSchema(), r = this.dataModel.getView(), a = this.dataModel.listRows(), c = this.headerHeight, u = X(o, r), d = o.columns.some((H) => r.wrapText?.[H.key] ?? H.wrapText), f = d ? this.getRowHeightCacheKey(o, r, u) : null;
2648
+ this.ensureHeightIndex(a, f, d);
2649
+ const g = this.heightIndex;
2650
+ if (!g) return null;
2651
+ const p = g.fenwick.total(), h = this.canvas?.height ?? this.root.clientHeight, m = Math.max(0, h - this.headerHeight), y = Math.max(0, p - m), w = Math.max(0, Math.min(this.root.scrollTop, y));
2652
+ if (n < c && i < this.rowHeaderWidth)
1943
2653
  return {
1944
2654
  rowId: "__all__",
1945
2655
  colKey: "__all__",
1946
- rect: new DOMRect(e.left, e.top, this.rowHeaderWidth, l)
2656
+ rect: new DOMRect(e.left, e.top, this.rowHeaderWidth, c)
1947
2657
  };
1948
- if (n < l) {
1949
- let x = this.rowHeaderWidth, M = -1;
1950
- for (let A = 0; A < h.length; A += 1) {
1951
- const K = h[A] ?? 100;
1952
- if (s >= x && s <= x + K) {
1953
- M = A;
2658
+ if (n < c) {
2659
+ let H = this.rowHeaderWidth, D = -1;
2660
+ for (let F = 0; F < u.length; F += 1) {
2661
+ const O = u[F] ?? 100;
2662
+ if (s >= H && s <= H + O) {
2663
+ D = F;
1954
2664
  break;
1955
2665
  }
1956
- x += K;
2666
+ H += O;
1957
2667
  }
1958
- if (M >= 0) {
1959
- const A = o.columns[M], K = new DOMRect(
1960
- e.left + x - this.root.scrollLeft,
2668
+ if (D >= 0) {
2669
+ const F = o.columns[D], O = new DOMRect(
2670
+ e.left + H - this.root.scrollLeft,
1961
2671
  e.top,
1962
- h[M] ?? 100,
1963
- l
2672
+ u[D] ?? 100,
2673
+ c
1964
2674
  );
1965
- return { rowId: "__header__", colKey: A.key, rect: K };
2675
+ return { rowId: "__header__", colKey: F.key, rect: O };
1966
2676
  }
1967
2677
  return null;
1968
2678
  }
1969
2679
  if (i < this.rowHeaderWidth) {
1970
- const x = n - l + m, M = Math.max(
2680
+ const H = n - c + w, D = Math.max(
1971
2681
  0,
1972
- Math.min(a.length - 1, p.fenwick.lowerBound(x + 1))
1973
- ), A = p.fenwick.sum(M);
1974
- if (M < 0 || M >= a.length) return null;
1975
- const K = a[M], H = e.top + l + A - m, P = new DOMRect(
2682
+ Math.min(a.length - 1, g.fenwick.lowerBound(H + 1))
2683
+ ), F = g.fenwick.sum(D);
2684
+ if (D < 0 || D >= a.length) return null;
2685
+ const O = a[D], B = e.top + c + F - w, z = new DOMRect(
1976
2686
  e.left,
1977
- H,
2687
+ B,
1978
2688
  this.rowHeaderWidth,
1979
- p.heights[M] ?? this.rowHeight
2689
+ g.heights[D] ?? this.rowHeight
1980
2690
  );
1981
- return { rowId: K.id, colKey: null, rect: P };
1982
- }
1983
- const g = n - l + m, y = Math.max(0, Math.min(a.length - 1, p.fenwick.lowerBound(g + 1))), w = p.fenwick.sum(y);
1984
- if (y < 0 || y >= a.length) return null;
1985
- let S = this.rowHeaderWidth, b = -1;
1986
- for (let x = 0; x < h.length; x += 1) {
1987
- const M = h[x] ?? 100;
1988
- if (s >= S && s <= S + M) {
1989
- b = x;
2691
+ return { rowId: O.id, colKey: null, rect: z };
2692
+ }
2693
+ const C = n - c + w, v = Math.max(0, Math.min(a.length - 1, g.fenwick.lowerBound(C + 1))), b = g.fenwick.sum(v);
2694
+ if (v < 0 || v >= a.length) return null;
2695
+ let S = this.rowHeaderWidth, x = -1;
2696
+ for (let H = 0; H < u.length; H += 1) {
2697
+ const D = u[H] ?? 100;
2698
+ if (s >= S && s <= S + D) {
2699
+ x = H;
1990
2700
  break;
1991
2701
  }
1992
- S += M;
2702
+ S += D;
1993
2703
  }
1994
- if (b === -1) return null;
1995
- const C = a[y], v = o.columns[b], R = w, I = new DOMRect(
2704
+ if (x === -1) return null;
2705
+ const R = a[v], E = o.columns[x], M = b, P = new DOMRect(
1996
2706
  e.left + S - this.root.scrollLeft,
1997
- e.top + l + R - this.root.scrollTop,
1998
- h[b] ?? 100,
1999
- p.heights[y] ?? this.rowHeight
2707
+ e.top + c + M - this.root.scrollTop,
2708
+ u[x] ?? 100,
2709
+ g.heights[v] ?? this.rowHeight
2000
2710
  );
2001
- return { rowId: C.id, colKey: v.key, rect: I };
2711
+ return { rowId: R.id, colKey: E.key, rect: P };
2002
2712
  }
2003
2713
  isPointInSelection(t, e) {
2004
2714
  if (!this.selection.length) return !1;
@@ -2006,8 +2716,8 @@ const O = class O {
2006
2716
  if (n < 0 || s < 0) return !1;
2007
2717
  for (const o of this.selection) {
2008
2718
  if (o.kind !== "cells") continue;
2009
- const r = Math.min(o.startRow, o.endRow), a = Math.max(o.startRow, o.endRow), l = Math.min(o.startCol, o.endCol), h = Math.max(o.startCol, o.endCol);
2010
- if (n >= r && n <= a && s >= l && s <= h)
2719
+ const r = Math.min(o.startRow, o.endRow), a = Math.max(o.startRow, o.endRow), c = Math.min(o.startCol, o.endCol), u = Math.max(o.startCol, o.endCol);
2720
+ if (n >= r && n <= a && s >= c && s <= u)
2011
2721
  return !0;
2012
2722
  }
2013
2723
  return !1;
@@ -2016,8 +2726,8 @@ const O = class O {
2016
2726
  if (!this.tooltip || !this.root) return;
2017
2727
  const e = 8, i = this.root.getBoundingClientRect(), n = this.root.clientWidth, s = this.root.clientHeight;
2018
2728
  let o = t.right - i.left + e, r = t.top - i.top + e, a = "right";
2019
- const l = this.tooltip.getBoundingClientRect();
2020
- o + l.width > n && (o = Math.max(0, t.left - i.left - l.width - e), a = "left"), r + l.height > s && (r = Math.max(0, s - l.height - e)), this.tooltip.style.left = `${o}px`, this.tooltip.style.top = `${r}px`, this.tooltip.dataset.side = a;
2729
+ const c = this.tooltip.getBoundingClientRect();
2730
+ o + c.width > n && (o = Math.max(0, t.left - i.left - c.width - e), a = "left"), r + c.height > s && (r = Math.max(0, s - c.height - e)), this.tooltip.style.left = `${o}px`, this.tooltip.style.top = `${r}px`, this.tooltip.dataset.side = a;
2021
2731
  }
2022
2732
  refreshTooltipPosition() {
2023
2733
  if (!this.tooltip || this.tooltip.dataset.visible !== "1" || !this.tooltipTarget || !this.tooltipMessage) return;
@@ -2030,20 +2740,20 @@ const O = class O {
2030
2740
  }
2031
2741
  getCellRect(t, e) {
2032
2742
  if (!this.root || !this.canvas) return null;
2033
- const i = this.canvas.getBoundingClientRect(), n = this.dataModel.getSchema(), s = this.dataModel.getView(), o = this.dataModel.listRows(), r = this.dataModel.getRowIndex(t), a = n.columns.findIndex((m) => m.key === e);
2743
+ const i = this.canvas.getBoundingClientRect(), n = this.dataModel.getSchema(), s = this.dataModel.getView(), o = this.dataModel.listRows(), r = this.dataModel.getRowIndex(t), a = n.columns.findIndex((h) => h.key === e);
2034
2744
  if (r < 0 || a < 0) return null;
2035
- const l = W(n, s), h = n.columns.some((m) => s.wrapText?.[m.key] ?? m.wrapText), u = h ? this.getRowHeightCacheKey(n, s, l) : null;
2036
- this.ensureHeightIndex(o, u, h);
2745
+ const c = X(n, s), u = n.columns.some((h) => s.wrapText?.[h.key] ?? h.wrapText), d = u ? this.getRowHeightCacheKey(n, s, c) : null;
2746
+ this.ensureHeightIndex(o, d, u);
2037
2747
  const f = this.heightIndex;
2038
2748
  if (!f) return null;
2039
- const p = f.fenwick.sum(r);
2040
- let d = this.rowHeaderWidth;
2041
- for (let m = 0; m < a; m += 1)
2042
- d += l[m] ?? 100;
2749
+ const g = f.fenwick.sum(r);
2750
+ let p = this.rowHeaderWidth;
2751
+ for (let h = 0; h < a; h += 1)
2752
+ p += c[h] ?? 100;
2043
2753
  return new DOMRect(
2044
- i.left + d - this.root.scrollLeft,
2045
- i.top + this.headerHeight + p - this.root.scrollTop,
2046
- l[a] ?? 100,
2754
+ i.left + p - this.root.scrollLeft,
2755
+ i.top + this.headerHeight + g - this.root.scrollTop,
2756
+ c[a] ?? 100,
2047
2757
  f.heights[r] ?? this.rowHeight
2048
2758
  );
2049
2759
  }
@@ -2054,28 +2764,28 @@ const O = class O {
2054
2764
  return;
2055
2765
  }
2056
2766
  {
2057
- const l = this.canvas.getBoundingClientRect(), h = t - l.left, u = e - l.top, f = h + this.root.scrollLeft, p = u, d = this.hoverHeaderColKey, m = this.hoverHeaderIcon;
2058
- let g = null, y = !1;
2059
- if (p >= 0 && p < this.headerHeight && f >= this.rowHeaderWidth) {
2060
- const S = this.dataModel.getSchema(), b = this.dataModel.getView(), C = W(S, b);
2061
- let v = this.rowHeaderWidth, R = -1;
2062
- for (let x = 0; x < C.length; x += 1) {
2063
- const M = C[x] ?? 100;
2064
- if (f >= v && f <= v + M) {
2065
- R = x;
2767
+ const c = this.canvas.getBoundingClientRect(), u = t - c.left, d = e - c.top, f = u + this.root.scrollLeft, g = d, p = this.hoverHeaderColKey, h = this.hoverHeaderIcon;
2768
+ let m = null, y = !1;
2769
+ if (g >= 0 && g < this.headerHeight && f >= this.rowHeaderWidth) {
2770
+ const C = this.dataModel.getSchema(), v = this.dataModel.getView(), b = X(C, v);
2771
+ let S = this.rowHeaderWidth, x = -1;
2772
+ for (let E = 0; E < b.length; E += 1) {
2773
+ const M = b[E] ?? 100;
2774
+ if (f >= S && f <= S + M) {
2775
+ x = E;
2066
2776
  break;
2067
2777
  }
2068
- v += M;
2778
+ S += M;
2069
2779
  }
2070
- const I = R >= 0 ? S.columns[R] : null;
2071
- if (I) {
2072
- g = I.key;
2073
- const x = C[R] ?? 100, M = 18, K = v + x - M - 4, H = Math.floor((this.headerHeight - M) / 2);
2074
- y = f >= K && f <= K + M && p >= H && p <= H + M;
2780
+ const R = x >= 0 ? C.columns[x] : null;
2781
+ if (R) {
2782
+ m = R.key;
2783
+ const E = b[x] ?? 100, M = 18, H = S + E - M - 4, D = Math.floor((this.headerHeight - M) / 2);
2784
+ y = f >= H && f <= H + M && g >= D && g <= D + M;
2075
2785
  }
2076
2786
  }
2077
- const w = String(d ?? "") !== String(g ?? "") || !!m != !!y;
2078
- if (this.hoverHeaderColKey = g, this.hoverHeaderIcon = y, g !== null) {
2787
+ const w = String(p ?? "") !== String(m ?? "") || !!h != !!y;
2788
+ if (this.hoverHeaderColKey = m, this.hoverHeaderIcon = y, m !== null) {
2079
2789
  this.canvas.style.cursor = y ? "pointer" : "default", this.tooltip && (this.tooltip.dataset.visible = "0"), this.tooltipTarget = null, this.tooltipMessage = null, w && this.render();
2080
2790
  return;
2081
2791
  }
@@ -2097,11 +2807,11 @@ const O = class O {
2097
2807
  }
2098
2808
  const s = this.dataModel.getCellMarker(n.rowId, n.colKey);
2099
2809
  if (this.tooltip && s) {
2100
- const l = this.tooltipTarget && this.tooltipTarget.rowId === n.rowId && this.tooltipTarget.colKey === n.colKey, h = this.tooltipMessage === s.message;
2101
- if (!l || !h || this.tooltip.dataset.visible !== "1") {
2810
+ const c = this.tooltipTarget && this.tooltipTarget.rowId === n.rowId && this.tooltipTarget.colKey === n.colKey, u = this.tooltipMessage === s.message;
2811
+ if (!c || !u || this.tooltip.dataset.visible !== "1") {
2102
2812
  this.tooltipTarget = { rowId: n.rowId, colKey: n.colKey }, this.tooltipMessage = s.message, this.tooltip.textContent = s.message;
2103
- const u = this.getCellRect(n.rowId, n.colKey);
2104
- u ? (this.positionTooltipAtRect(u), this.tooltip.dataset.visible = "1") : this.tooltip.dataset.visible = "0";
2813
+ const d = this.getCellRect(n.rowId, n.colKey);
2814
+ d ? (this.positionTooltipAtRect(d), this.tooltip.dataset.visible = "1") : this.tooltip.dataset.visible = "0";
2105
2815
  }
2106
2816
  } else this.tooltip && (this.tooltip.dataset.visible = "0", this.tooltipTarget = null, this.tooltipMessage = null);
2107
2817
  if (!this.isPointInSelection(n.rowId, n.colKey)) {
@@ -2112,23 +2822,23 @@ const O = class O {
2112
2822
  this.canvas.style.cursor = "cell";
2113
2823
  return;
2114
2824
  }
2115
- if (this.activeRowId && this.activeColKey !== null && this.activeRowId !== "__all__" && this.activeColKey !== "__all__" && ot(
2825
+ if (this.activeRowId && this.activeColKey !== null && this.activeRowId !== "__all__" && this.activeColKey !== "__all__" && ft(
2116
2826
  this.dataModel,
2117
2827
  this.selection,
2118
2828
  this.activeRowId,
2119
2829
  this.activeColKey,
2120
2830
  this.getEditMode()
2121
2831
  )) {
2122
- const l = this.getCellRect(this.activeRowId, this.activeColKey);
2123
- if (l) {
2124
- const h = Bt(l, Pt);
2125
- if ($t(t, e, h)) {
2832
+ const c = this.getCellRect(this.activeRowId, this.activeColKey);
2833
+ if (c) {
2834
+ const u = zt(c, Xt);
2835
+ if (Gt(t, e, u)) {
2126
2836
  this.canvas.style.cursor = "crosshair";
2127
2837
  return;
2128
2838
  }
2129
2839
  }
2130
2840
  }
2131
- const r = this.dataModel.getSchema().columns.find((l) => l.key === n.colKey);
2841
+ const r = this.dataModel.getSchema().columns.find((c) => c.key === n.colKey);
2132
2842
  this.dataModel.isReadonly(n.rowId, n.colKey) || r?.type === "boolean" ? i = "default" : i = "text", this.canvas.style.cursor = i;
2133
2843
  }
2134
2844
  measureRowHeight(t, e, i, n) {
@@ -2137,8 +2847,8 @@ const O = class O {
2137
2847
  for (let r = 0; r < i.columns.length; r += 1) {
2138
2848
  const a = i.columns[r];
2139
2849
  if (!a || !(o.wrapText?.[a.key] ?? a.wrapText)) continue;
2140
- const h = (n[r] ?? 100) - this.padding, u = this.dataModel.resolveCellValue(e.id, a), f = this.dataModel.resolveConditionalStyle(e.id, a), d = u.textOverride ?? (f.forceErrorText ? "#ERROR" : void 0) ? "#ERROR" : this.formatValue(u.value, a).text, g = this.wrapLines(t, d, h).length * this.lineHeight + this.padding;
2141
- s = Math.max(s, g);
2850
+ const u = (n[r] ?? 100) - this.padding, d = this.dataModel.resolveCellValue(e.id, a), f = this.dataModel.resolveConditionalStyle(e.id, a), p = d.textOverride ?? (f.forceErrorText ? "#ERROR" : void 0) ? "#ERROR" : this.formatValue(d.value, a).text, m = this.wrapLines(t, p, u).length * this.lineHeight + this.padding;
2851
+ s = Math.max(s, m);
2142
2852
  }
2143
2853
  return s;
2144
2854
  }
@@ -2149,59 +2859,59 @@ const O = class O {
2149
2859
  const o = e.split(`
2150
2860
  `), r = [];
2151
2861
  for (const a of o) {
2152
- let l = a;
2153
- for (; t.measureText(l).width > i && l.length > 1; ) {
2154
- let h = l.length;
2155
- for (; h > 1 && t.measureText(l.slice(0, h)).width > i; )
2156
- h -= 1;
2157
- r.push(l.slice(0, h)), l = l.slice(h);
2862
+ let c = a;
2863
+ for (; t.measureText(c).width > i && c.length > 1; ) {
2864
+ let u = c.length;
2865
+ for (; u > 1 && t.measureText(c.slice(0, u)).width > i; )
2866
+ u -= 1;
2867
+ r.push(c.slice(0, u)), c = c.slice(u);
2158
2868
  }
2159
- r.push(l);
2869
+ r.push(c);
2160
2870
  }
2161
- for (this.textMeasureCache.set(n, { lines: r }); this.textMeasureCache.size > O.TEXT_MEASURE_CACHE_MAX; ) {
2871
+ for (this.textMeasureCache.set(n, { lines: r }); this.textMeasureCache.size > W.TEXT_MEASURE_CACHE_MAX; ) {
2162
2872
  const a = this.textMeasureCache.keys().next().value;
2163
2873
  if (!a) break;
2164
2874
  this.textMeasureCache.delete(a);
2165
2875
  }
2166
2876
  return r;
2167
2877
  }
2168
- drawCellText(t, e, i, n, s, o, r, a = "left", l = !1, h = !1, u) {
2878
+ drawCellText(t, e, i, n, s, o, r, a = "left", c = !1, u = !1, d) {
2169
2879
  t.save(), t.beginPath(), t.rect(i - 4, n - 4, s + 8, o + 8), t.clip();
2170
2880
  const f = t.font;
2171
- l ? t.font = "28px sans-serif" : h && (t.font = "14px sans-serif");
2172
- const p = (d, m) => {
2173
- const g = n + this.lineHeight * m;
2881
+ c ? t.font = "28px sans-serif" : u && (t.font = "14px sans-serif");
2882
+ const g = (p, h) => {
2883
+ const m = n + this.lineHeight * h;
2174
2884
  let y = i, w = i;
2175
2885
  if (a === "right")
2176
- t.textAlign = "right", w = i + s, y = w - t.measureText(d).width, t.fillText(d, w, g);
2886
+ t.textAlign = "right", w = i + s, y = w - t.measureText(p).width, t.fillText(p, w, m);
2177
2887
  else if (a === "center") {
2178
2888
  t.textAlign = "center";
2179
- const S = i + s / 2, b = t.measureText(d).width;
2180
- y = S - b / 2, w = S + b / 2, t.fillText(d, S, g);
2889
+ const C = i + s / 2, v = t.measureText(p).width;
2890
+ y = C - v / 2, w = C + v / 2, t.fillText(p, C, m);
2181
2891
  } else
2182
- t.textAlign = "left", y = i, w = i + t.measureText(d).width, t.fillText(d, i, g);
2183
- if (u?.underline || u?.strike) {
2184
- const S = t.strokeStyle, b = t.lineWidth;
2185
- if (t.strokeStyle = t.fillStyle, t.lineWidth = 1, t.beginPath(), u.underline) {
2186
- const C = g + 2;
2187
- t.moveTo(y, C), t.lineTo(w, C);
2892
+ t.textAlign = "left", y = i, w = i + t.measureText(p).width, t.fillText(p, i, m);
2893
+ if (d?.underline || d?.strike) {
2894
+ const C = t.strokeStyle, v = t.lineWidth;
2895
+ if (t.strokeStyle = t.fillStyle, t.lineWidth = 1, t.beginPath(), d.underline) {
2896
+ const b = m + 2;
2897
+ t.moveTo(y, b), t.lineTo(w, b);
2188
2898
  }
2189
- if (u.strike) {
2190
- const C = g - Math.floor(this.lineHeight / 2) + 2;
2191
- t.moveTo(y, C), t.lineTo(w, C);
2899
+ if (d.strike) {
2900
+ const b = m - Math.floor(this.lineHeight / 2) + 2;
2901
+ t.moveTo(y, b), t.lineTo(w, b);
2192
2902
  }
2193
- t.stroke(), t.strokeStyle = S, t.lineWidth = b;
2903
+ t.stroke(), t.strokeStyle = C, t.lineWidth = v;
2194
2904
  }
2195
2905
  };
2196
2906
  if (r) {
2197
- const d = this.wrapLines(t, e, s);
2198
- for (let m = 0; m < d.length; m += 1)
2199
- p(d[m], m + 1);
2907
+ const p = this.wrapLines(t, e, s);
2908
+ for (let h = 0; h < p.length; h += 1)
2909
+ g(p[h], h + 1);
2200
2910
  } else {
2201
- let d = e;
2202
- for (; t.measureText(d).width > s && d.length > 1; )
2203
- d = `${d.slice(0, -2)}…`;
2204
- p(d, 1);
2911
+ let p = e;
2912
+ for (; t.measureText(p).width > s && p.length > 1; )
2913
+ p = `${p.slice(0, -2)}…`;
2914
+ g(p, 1);
2205
2915
  }
2206
2916
  t.textAlign = "left", t.font = f, t.restore();
2207
2917
  }
@@ -2218,52 +2928,56 @@ const O = class O {
2218
2928
  if ((e.type === "date" || e.type === "time" || e.type === "datetime") && (t instanceof Date || typeof t == "string")) {
2219
2929
  const i = e.type === "date" ? e.dateFormat ?? "yyyy-MM-dd" : e.type === "time" ? e.timeFormat ?? "HH:mm" : e.dateTimeFormat ?? "yyyy-MM-dd'T'HH:mm:ss'Z'";
2220
2930
  let n = null;
2221
- return t instanceof Date ? n = t : n = this.valueFormatCache.parseIsoDate(t), n ? { text: At(n, i) } : { text: String(t) };
2931
+ return t instanceof Date ? n = t : n = this.valueFormatCache.parseIsoDate(t), n ? { text: Bt(n, i) } : { text: String(t) };
2222
2932
  }
2223
2933
  return { text: String(t) };
2224
2934
  }
2225
2935
  };
2226
- O.MAX_CANVAS_DIM_PX = 8192, O.ROW_HEIGHT_MEASURE_CHUNK = 500, O.ROW_HEIGHT_MEASURE_TIME_BUDGET_MS = 8, O.TEXT_MEASURE_CACHE_MAX = 2e3;
2227
- let rt = O;
2228
- class Se {
2229
- constructor(t, e, i, n, s, o, r, a, l, h, u, f, p) {
2230
- this.dataModel = r, this.onActiveChange = l, this.onSelectionChange = u, this.onUndo = f, this.onRedo = p, this.handleDocumentContextMenu = null, this.selectionRanges = [], this.inputEl = null, this.floatingInputWrapper = null, this.selectionInput = null, this.copyToastEl = null, this.copyToastTimer = null, this.selectionMode = !0, this.lastBooleanCell = null, this.selectionAnchor = null, this.dragging = !1, this.dragStart = null, this.pointerDownClient = null, this.dragMoved = !1, this.dragSelectionChanged = !1, this.suppressNextClick = !1, this.fillDragging = !1, this.fillSource = null, this.fillEndRowIndex = null, this.rootCursorBackup = null, this.lastPointerClient = null, this.autoScrollRaf = null, this.autoScrollActive = !1, this.activeCell = null, this.activeHost = null, this.activeHostOriginalText = null, this.composing = !1, this.lastCompositionEnd = 0, this.handleSelectionBlur = () => this.teardownSelectionInput(), this.handlePointerDown = (d) => {
2231
- if (d.button !== 0) return;
2232
- const m = d.target;
2233
- if (m?.closest('button[data-extable-fs-open="1"]') || m?.closest(".extable-filter-sort-trigger") || this.inputEl && d.target && this.inputEl.contains(d.target)) return;
2936
+ W.MAX_CANVAS_DIM_PX = 8192, W.ROW_HEIGHT_MEASURE_CHUNK = 500, W.ROW_HEIGHT_MEASURE_TIME_BUDGET_MS = 8, W.TEXT_MEASURE_CACHE_MAX = 2e3;
2937
+ let gt = W;
2938
+ class Ai {
2939
+ constructor(t, e, i, n, s, o, r, a, c, u, d, f, g, p) {
2940
+ this.dataModel = r, this.onActiveChange = u, this.onSelectionChange = f, this.onUndo = g, this.onRedo = p, this.handleDocumentContextMenu = null, this.selectionRanges = [], this.inputEl = null, this.floatingInputWrapper = null, this.selectionInput = null, this.copyToastEl = null, this.copyToastTimer = null, this.selectionMode = !0, this.lastBooleanCell = null, this.selectionAnchor = null, this.dragging = !1, this.dragStart = null, this.pointerDownClient = null, this.dragMoved = !1, this.dragSelectionChanged = !1, this.suppressNextClick = !1, this.fillDragging = !1, this.fillSource = null, this.fillEndRowIndex = null, this.rootCursorBackup = null, this.lastPointerClient = null, this.autoScrollRaf = null, this.autoScrollActive = !1, this.activeCell = null, this.activeHost = null, this.activeHostOriginalText = null, this.composing = !1, this.lastCompositionEnd = 0, this.handleSelectionBlur = () => this.teardownSelectionInput(), this.handleRootKeydown = async (h) => {
2941
+ if (h.defaultPrevented || !this.selectionMode || this.inputEl || h.isComposing || this.composing || !(typeof navigator < "u" && /mac/i.test(navigator.platform) ? h.metaKey : h.ctrlKey)) return;
2942
+ const w = h.key.toLowerCase();
2943
+ w === "c" ? (h.preventDefault(), await this.copySelection()) : w === "x" && (h.preventDefault(), await this.copySelection(), this.clearSelectionValues());
2944
+ }, this.handlePointerDown = (h) => {
2945
+ if (h.button !== 0) return;
2946
+ const m = h.target;
2947
+ if (m?.closest('button[data-extable-fs-open="1"]') || m?.closest(".extable-filter-sort-trigger") || this.inputEl && h.target && this.inputEl.contains(h.target)) return;
2234
2948
  if (this.inputEl && this.activeCell && this.activeCell.colKey !== null) {
2235
- const { rowId: R, colKey: I } = this.activeCell, x = this.readActiveValue();
2236
- this.commitEdit(R, I, x), this.onMove(R), this.teardownInput(!1);
2949
+ const { rowId: R, colKey: E } = this.activeCell, M = this.readActiveValue();
2950
+ this.commitEdit(R, E, M), this.onMove(R), this.teardownInput(!1);
2237
2951
  }
2238
2952
  if (this.fillDragging) return;
2239
- const g = this.hitTest(d);
2240
- if (!g || g.rowId === "__all__" && g.colKey === "__all__" || g.colKey === "__all__") return;
2241
- const y = Vt(this.dataModel, this.selectionRanges);
2242
- if (y && this.activeCell) {
2243
- const R = this.dataModel.getSchema(), I = this.dataModel.listRows(), x = y.endRowIndex, M = y.colIndex, A = I[x], K = R.columns[M];
2244
- if (A && K) {
2245
- const H = this.findHtmlCellElement(A.id, K.key)?.getBoundingClientRect() ?? this.computeCanvasCellRect(A.id, K.key);
2246
- if (H && ot(
2953
+ const y = this.hitTest(h);
2954
+ if (!y || y.rowId === "__all__" && y.colKey === "__all__" || y.colKey === "__all__") return;
2955
+ const w = jt(this.dataModel, this.selectionRanges);
2956
+ if (w && this.activeCell) {
2957
+ const R = this.dataModel.getSchema(), E = this.dataModel.listRows(), M = w.endRowIndex, P = w.colIndex, H = E[M], D = R.columns[P];
2958
+ if (H && D) {
2959
+ const F = this.findHtmlCellElement(H.id, D.key)?.getBoundingClientRect() ?? this.computeCanvasCellRect(H.id, D.key);
2960
+ if (F && ft(
2247
2961
  this.dataModel,
2248
2962
  this.selectionRanges,
2249
2963
  this.activeCell.rowId,
2250
2964
  this.activeCell.colKey,
2251
2965
  this.editMode
2252
2966
  )) {
2253
- const P = Bt(H, Pt);
2254
- if ($t(d.clientX, d.clientY, P)) {
2255
- d.preventDefault(), this.fillDragging = !0, this.fillSource = y, this.fillEndRowIndex = y.endRowIndex, this.root.dataset.extableFillDragging = "1", this.rootCursorBackup === null && (this.rootCursorBackup = this.root.style.cursor || ""), this.root.style.cursor = "crosshair", this.lastPointerClient = { x: d.clientX, y: d.clientY }, this.dragging = !1, this.dragStart = null, this.suppressNextClick = !0;
2967
+ const O = zt(F, Xt);
2968
+ if (Gt(h.clientX, h.clientY, O)) {
2969
+ h.preventDefault(), this.fillDragging = !0, this.fillSource = w, this.fillEndRowIndex = w.endRowIndex, this.root.dataset.extableFillDragging = "1", this.rootCursorBackup === null && (this.rootCursorBackup = this.root.style.cursor || ""), this.root.style.cursor = "crosshair", this.lastPointerClient = { x: h.clientX, y: h.clientY }, this.dragging = !1, this.dragStart = null, this.suppressNextClick = !0;
2256
2970
  try {
2257
- d.target?.setPointerCapture?.(d.pointerId);
2971
+ h.target?.setPointerCapture?.(h.pointerId);
2258
2972
  } catch {
2259
2973
  }
2260
2974
  this.selectionRanges = [
2261
2975
  {
2262
2976
  kind: "cells",
2263
- startRow: y.startRowIndex,
2264
- endRow: y.endRowIndex,
2265
- startCol: y.colIndex,
2266
- endCol: y.colIndex
2977
+ startRow: w.startRowIndex,
2978
+ endRow: w.endRowIndex,
2979
+ startCol: w.colIndex,
2980
+ endCol: w.colIndex
2267
2981
  }
2268
2982
  ], this.onSelectionChange(this.selectionRanges), this.startAutoScroll();
2269
2983
  return;
@@ -2271,52 +2985,52 @@ class Se {
2271
2985
  }
2272
2986
  }
2273
2987
  }
2274
- const w = this.dataModel.getSchema(), S = this.dataModel.listRows(), b = g.rowId === "__header__" ? 0 : this.dataModel.getRowIndex(g.rowId), C = w.columns.findIndex((R) => String(R.key) === String(g.colKey));
2275
- if (C < 0) return;
2276
- if (g.rowId === "__header__") {
2277
- if (!S.length) return;
2988
+ const C = this.dataModel.getSchema(), v = this.dataModel.listRows(), b = y.rowId === "__header__" ? 0 : this.dataModel.getRowIndex(y.rowId), S = C.columns.findIndex((R) => String(R.key) === String(y.colKey));
2989
+ if (S < 0) return;
2990
+ if (y.rowId === "__header__") {
2991
+ if (!v.length) return;
2278
2992
  const R = {
2279
2993
  kind: "cells",
2280
2994
  startRow: 0,
2281
- endRow: S.length - 1,
2282
- startCol: C,
2283
- endCol: C
2995
+ endRow: v.length - 1,
2996
+ startCol: S,
2997
+ endCol: S
2284
2998
  };
2285
- this.selectionRanges = [R], this.onSelectionChange(this.selectionRanges), this.dragging = !1, this.selectionMode = !1, this.dragStart = null, this.selectionAnchor = null, this.suppressNextClick = !0;
2286
- const I = S[0], x = w.columns[C];
2287
- I && x && (this.activeCell = { rowId: I.id, colKey: x.key }, this.onActiveChange(I.id, x.key));
2999
+ this.selectionRanges = [R], this.onSelectionChange(this.selectionRanges), this.dragging = !1, this.selectionMode = !0, this.dragStart = null, this.selectionAnchor = null, this.suppressNextClick = !1;
3000
+ const E = v[0], M = C.columns[S];
3001
+ E && M && (this.activeCell = { rowId: E.id, colKey: M.key }, this.onActiveChange(E.id, M.key)), this.focusSelectionInput("");
2288
3002
  return;
2289
3003
  }
2290
3004
  if (b < 0) return;
2291
- const v = g.colKey === null ? "rows" : "cells";
2292
- this.dragging = !0, this.pointerDownClient = { x: d.clientX, y: d.clientY }, this.dragMoved = !1, this.dragSelectionChanged = !1, this.dragStart = { rowIndex: b, colIndex: C, kind: v }, this.suppressNextClick = !1, this.selectionMode = !0, this.selectionAnchor = null, this.lastPointerClient = { x: d.clientX, y: d.clientY };
3005
+ const x = y.colKey === null ? "rows" : "cells";
3006
+ this.dragging = !0, this.pointerDownClient = { x: h.clientX, y: h.clientY }, this.dragMoved = !1, this.dragSelectionChanged = !1, this.dragStart = { rowIndex: b, colIndex: S, kind: x }, this.suppressNextClick = !1, this.selectionMode = !0, this.selectionAnchor = null, this.lastPointerClient = { x: h.clientX, y: h.clientY };
2293
3007
  try {
2294
- d.target?.setPointerCapture?.(d.pointerId);
3008
+ h.target?.setPointerCapture?.(h.pointerId);
2295
3009
  } catch {
2296
3010
  }
2297
3011
  this.startAutoScroll();
2298
- }, this.handlePointerMove = (d) => {
2299
- if (this.lastPointerClient = { x: d.clientX, y: d.clientY }, this.fillDragging && this.fillSource) {
2300
- this.updateFillDragFromClientPoint(d.clientX, d.clientY);
3012
+ }, this.handlePointerMove = (h) => {
3013
+ if (this.lastPointerClient = { x: h.clientX, y: h.clientY }, this.fillDragging && this.fillSource) {
3014
+ this.updateFillDragFromClientPoint(h.clientX, h.clientY);
2301
3015
  return;
2302
3016
  }
2303
3017
  if (!(!this.dragging || !this.dragStart)) {
2304
3018
  if (!this.dragMoved && this.pointerDownClient) {
2305
- const m = d.clientX - this.pointerDownClient.x, g = d.clientY - this.pointerDownClient.y;
2306
- if (m * m + g * g < 9) return;
3019
+ const m = h.clientX - this.pointerDownClient.x, y = h.clientY - this.pointerDownClient.y;
3020
+ if (m * m + y * y < 9) return;
2307
3021
  this.dragMoved = !0;
2308
3022
  }
2309
- this.updateDragFromClientPoint(d.clientX, d.clientY);
3023
+ this.updateDragFromClientPoint(h.clientX, h.clientY);
2310
3024
  }
2311
- }, this.handlePointerUp = (d) => {
3025
+ }, this.handlePointerUp = (h) => {
2312
3026
  if (this.fillDragging && this.fillSource) {
2313
- const g = this.fillSource, y = this.fillEndRowIndex ?? g.endRowIndex;
3027
+ const y = this.fillSource, w = this.fillEndRowIndex ?? y.endRowIndex;
2314
3028
  this.fillDragging = !1, this.fillSource = null, this.fillEndRowIndex = null, this.root.dataset.extableFillDragging = "", this.rootCursorBackup !== null && (this.root.style.cursor = this.rootCursorBackup, this.rootCursorBackup = null), this.stopAutoScroll();
2315
3029
  try {
2316
- d.target?.releasePointerCapture?.(d.pointerId);
3030
+ h.target?.releasePointerCapture?.(h.pointerId);
2317
3031
  } catch {
2318
3032
  }
2319
- this.commitFill(g, y), this.suppressNextClick = !0;
3033
+ this.commitFill(y, w), this.suppressNextClick = !0;
2320
3034
  return;
2321
3035
  }
2322
3036
  if (!this.dragging) return;
@@ -2324,48 +3038,48 @@ class Se {
2324
3038
  const m = this.dragSelectionChanged;
2325
3039
  this.pointerDownClient = null, this.dragMoved = !1, this.dragSelectionChanged = !1, this.stopAutoScroll();
2326
3040
  try {
2327
- d.target?.releasePointerCapture?.(d.pointerId);
3041
+ h.target?.releasePointerCapture?.(h.pointerId);
2328
3042
  } catch {
2329
3043
  }
2330
3044
  if (m && (this.suppressNextClick = !0), this.suppressNextClick && this.activeCell && this.activeCell.colKey !== null) {
2331
- const g = this.dataModel.getCell(this.activeCell.rowId, this.activeCell.colKey);
2332
- this.focusSelectionInput(this.cellToClipboardString(g));
3045
+ const y = this.dataModel.getCell(this.activeCell.rowId, this.activeCell.colKey);
3046
+ this.focusSelectionInput(this.cellToClipboardString(y));
2333
3047
  }
2334
- }, this.handleSelectionCopy = (d) => {
3048
+ }, this.handleSelectionCopy = (h) => {
2335
3049
  if (!this.selectionMode) return;
2336
3050
  const m = this.buildSelectionClipboardPayload();
2337
- m && (d.preventDefault(), d.clipboardData?.setData("text/plain", m.text), d.clipboardData?.setData("text/tab-separated-values", m.text), d.clipboardData?.setData("text/html", m.html), this.showCopyToast(`Copied ${m.cellCount} cells`, "info"));
2338
- }, this.handleSelectionCut = (d) => {
3051
+ m && (h.preventDefault(), h.clipboardData?.setData("text/plain", m.text), h.clipboardData?.setData("text/tab-separated-values", m.text), h.clipboardData?.setData("text/html", m.html), this.showCopyToast(`Copied ${m.cellCount} cells`, "info"));
3052
+ }, this.handleSelectionCut = (h) => {
2339
3053
  if (!this.selectionMode) return;
2340
3054
  const m = this.buildSelectionClipboardPayload();
2341
- m && (d.preventDefault(), d.clipboardData?.setData("text/plain", m.text), d.clipboardData?.setData("text/tab-separated-values", m.text), d.clipboardData?.setData("text/html", m.html), this.clearSelectionValues());
2342
- }, this.handleSelectionPaste = (d) => {
3055
+ m && (h.preventDefault(), h.clipboardData?.setData("text/plain", m.text), h.clipboardData?.setData("text/tab-separated-values", m.text), h.clipboardData?.setData("text/html", m.html), this.clearSelectionValues());
3056
+ }, this.handleSelectionPaste = (h) => {
2343
3057
  if (!this.selectionMode) return;
2344
- d.preventDefault();
2345
- const m = d.clipboardData?.getData("text/html") ?? "", g = d.clipboardData?.getData("text/tab-separated-values") ?? "", y = d.clipboardData?.getData("text/plain") ?? "", w = this.parseClipboardGrid({ html: m, tsv: g, text: y });
2346
- w && this.applyClipboardGrid(w);
3058
+ h.preventDefault();
3059
+ const m = h.clipboardData?.getData("text/html") ?? "", y = h.clipboardData?.getData("text/tab-separated-values") ?? "", w = h.clipboardData?.getData("text/plain") ?? "", C = this.parseClipboardGrid({ html: m, tsv: y, text: w });
3060
+ C && this.applyClipboardGrid(C);
2347
3061
  }, this.handleSelectionCompositionStart = () => {
2348
3062
  this.selectionMode && (this.selectionMode = !1, this.teardownSelectionInput(), this.openEditorAtActiveCell());
2349
- }, this.handleSelectionKeydown = (d) => {
2350
- if (!this.selectionMode || !this.activeCell || d.isComposing || this.composing || d.key === "Shift" || d.key === "Control" || d.key === "Alt" || d.key === "Meta" || d.key === "CapsLock" || d.key === "NumLock" || d.key === "ScrollLock")
3063
+ }, this.handleSelectionKeydown = async (h) => {
3064
+ if (!this.selectionMode || !this.activeCell || h.isComposing || this.composing || h.key === "Shift" || h.key === "Control" || h.key === "Alt" || h.key === "Meta" || h.key === "CapsLock" || h.key === "NumLock" || h.key === "ScrollLock")
2351
3065
  return;
2352
3066
  const m = typeof navigator < "u" && /mac/i.test(navigator.platform);
2353
- if (m ? d.metaKey : d.ctrlKey) {
2354
- const b = d.key.toLowerCase();
3067
+ if (m ? h.metaKey : h.ctrlKey) {
3068
+ const b = h.key.toLowerCase();
2355
3069
  if (b === "z") {
2356
- d.preventDefault(), m && d.shiftKey ? this.onRedo() : this.onUndo(), this.selectionAnchor = null;
3070
+ h.preventDefault(), m && h.shiftKey ? this.onRedo() : this.onUndo(), this.selectionAnchor = null;
2357
3071
  return;
2358
3072
  }
2359
3073
  if (b === "y") {
2360
- d.preventDefault(), this.onRedo(), this.selectionAnchor = null;
3074
+ h.preventDefault(), this.onRedo(), this.selectionAnchor = null;
2361
3075
  return;
2362
3076
  }
2363
3077
  if (b === "c") {
2364
- d.preventDefault(), document.execCommand("copy"), this.selectionAnchor = null;
3078
+ h.preventDefault(), await this.copySelection(), this.selectionAnchor = null;
2365
3079
  return;
2366
3080
  }
2367
3081
  if (b === "x") {
2368
- d.preventDefault(), document.execCommand("cut"), this.selectionAnchor = null;
3082
+ h.preventDefault(), await this.copySelection(), this.clearSelectionValues(), this.selectionAnchor = null;
2369
3083
  return;
2370
3084
  }
2371
3085
  if (b === "v") {
@@ -2373,74 +3087,104 @@ class Se {
2373
3087
  return;
2374
3088
  }
2375
3089
  }
2376
- if (d.key === " " && this.activeCell.colKey !== null) {
2377
- this.findColumn(this.activeCell.colKey)?.type === "boolean" && (d.preventDefault(), this.toggleBoolean(this.activeCell.rowId, this.activeCell.colKey)), this.selectionAnchor = null;
3090
+ if (h.key === " " && this.activeCell.colKey !== null) {
3091
+ this.findColumn(this.activeCell.colKey)?.type === "boolean" && (h.preventDefault(), this.toggleBoolean(this.activeCell.rowId, this.activeCell.colKey)), this.selectionAnchor = null;
2378
3092
  return;
2379
3093
  }
2380
- const y = d.key === "Tab", w = d.key === "Enter", S = d.key === "ArrowLeft" || d.key === "ArrowRight" || d.key === "ArrowUp" || d.key === "ArrowDown";
2381
- if (y || w || S) {
2382
- if (d.preventDefault(), this.teardownSelectionInput(), y) {
2383
- this.moveActiveCell(0, d.shiftKey ? -1 : 1, !1);
3094
+ const w = h.key === "Tab", C = h.key === "Enter", v = h.key === "ArrowLeft" || h.key === "ArrowRight" || h.key === "ArrowUp" || h.key === "ArrowDown";
3095
+ if (w || C || v) {
3096
+ if (h.preventDefault(), this.teardownSelectionInput(), w) {
3097
+ this.moveActiveCell(0, h.shiftKey ? -1 : 1, !1);
2384
3098
  return;
2385
3099
  }
2386
- if (w) {
2387
- this.moveActiveCell(d.shiftKey ? -1 : 1, 0, !1);
3100
+ if (C) {
3101
+ this.moveActiveCell(h.shiftKey ? -1 : 1, 0, !1);
2388
3102
  return;
2389
3103
  }
2390
- const b = d.shiftKey;
2391
- d.key === "ArrowLeft" ? this.moveActiveCell(0, -1, b) : d.key === "ArrowRight" ? this.moveActiveCell(0, 1, b) : d.key === "ArrowUp" ? this.moveActiveCell(-1, 0, b) : d.key === "ArrowDown" && this.moveActiveCell(1, 0, b);
3104
+ const b = h.shiftKey;
3105
+ h.key === "ArrowLeft" ? this.moveActiveCell(0, -1, b) : h.key === "ArrowRight" ? this.moveActiveCell(0, 1, b) : h.key === "ArrowUp" ? this.moveActiveCell(-1, 0, b) : h.key === "ArrowDown" && this.moveActiveCell(1, 0, b);
2392
3106
  return;
2393
3107
  }
2394
3108
  this.selectionMode = !1, this.selectionAnchor = null, this.teardownSelectionInput(), this.openEditorAtActiveCell();
2395
- }, this.handleClick = (d) => {
2396
- if (d.button !== 0 || d.target?.closest('button[data-extable-fs-open="1"]'))
3109
+ }, this.handleClick = (h) => {
3110
+ if (h.button !== 0 || h.target?.closest('button[data-extable-fs-open="1"]'))
2397
3111
  return;
2398
3112
  if (this.suppressNextClick) {
2399
3113
  this.suppressNextClick = !1;
2400
3114
  return;
2401
3115
  }
2402
- if (this.inputEl && d.target && this.inputEl.contains(d.target))
3116
+ if (this.inputEl && h.target && this.inputEl.contains(h.target))
2403
3117
  return;
2404
3118
  if (this.inputEl && this.activeCell && this.activeCell.colKey !== null) {
2405
- const { rowId: v, colKey: R } = this.activeCell, I = this.readActiveValue();
2406
- this.commitEdit(v, R, I), this.onMove(v), this.teardownInput(!1);
3119
+ const { rowId: x, colKey: R } = this.activeCell, E = this.readActiveValue();
3120
+ this.commitEdit(x, R, E), this.onMove(x), this.teardownInput(!1);
2407
3121
  }
2408
- const g = typeof document.elementFromPoint == "function" ? this.getHitAtClientPoint(d.clientX, d.clientY) : this.hitTest(d);
2409
- if (!g) return;
2410
- const y = this.selectionMode && !d.shiftKey && !d.metaKey && !d.ctrlKey && this.activeCell?.rowId === g.rowId && String(this.activeCell?.colKey) === String(g.colKey);
2411
- if (g.rowId === "__all__" && g.colKey === "__all__") {
2412
- this.teardownInput(!1), this.activeCell = null, this.onActiveChange("__all__", "__all__"), this.selectionAnchor = null;
3122
+ const y = typeof document.elementFromPoint == "function" ? this.getHitAtClientPoint(h.clientX, h.clientY) : this.hitTest(h);
3123
+ if (!y) return;
3124
+ const w = this.selectionMode && !h.shiftKey && !h.metaKey && !h.ctrlKey && this.activeCell?.rowId === y.rowId && String(this.activeCell?.colKey) === String(y.colKey);
3125
+ if (y.rowId === "__all__" && y.colKey === "__all__") {
3126
+ const x = this.dataModel.getSchema(), R = this.dataModel.listRows();
3127
+ this.teardownInput(!1), R.length && x.columns.length ? (this.selectionRanges = [
3128
+ {
3129
+ kind: "cells",
3130
+ startRow: 0,
3131
+ endRow: R.length - 1,
3132
+ startCol: 0,
3133
+ endCol: x.columns.length - 1
3134
+ }
3135
+ ], this.activeCell = { rowId: "__all__", colKey: "__all__" }, this.onActiveChange("__all__", "__all__"), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput("")) : (this.activeCell = null, this.onActiveChange("__all__", "__all__"), this.selectionAnchor = null);
3136
+ return;
3137
+ }
3138
+ if (this.onRowSelect(y.rowId), y.rowId === "__header__") {
3139
+ const x = this.dataModel.getSchema(), R = this.dataModel.listRows(), E = x.columns.findIndex((M) => String(M.key) === String(y.colKey));
3140
+ R.length && E >= 0 && (this.selectionRanges = [
3141
+ {
3142
+ kind: "cells",
3143
+ startRow: 0,
3144
+ endRow: R.length - 1,
3145
+ startCol: E,
3146
+ endCol: E
3147
+ }
3148
+ ], this.activeCell = { rowId: R[0].id, colKey: y.colKey }, this.onActiveChange(this.activeCell.rowId, this.activeCell.colKey), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput(""));
3149
+ return;
3150
+ }
3151
+ if (this.applySelectionFromHit(h, y), y.colKey === null || y.colKey === "__all__") {
3152
+ this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput("");
2413
3153
  return;
2414
3154
  }
2415
- if (this.onRowSelect(g.rowId), this.applySelectionFromHit(d, g), g.colKey === null || g.colKey === "__all__")
3155
+ if (y.rowId === "__header__") {
3156
+ this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput("");
2416
3157
  return;
2417
- if (this.isCellReadonly(g.rowId, g.colKey)) {
2418
- this.selectionMode = !0, this.selectionAnchor = null, this.teardownInput(!1), this.teardownSelectionInput();
3158
+ }
3159
+ if (this.isCellReadonly(y.rowId, y.colKey)) {
3160
+ this.selectionMode = !0, this.selectionAnchor = null, this.teardownInput(!1);
3161
+ const x = this.dataModel.getCell(y.rowId, y.colKey);
3162
+ this.focusSelectionInput(this.cellToClipboardString(x));
2419
3163
  return;
2420
3164
  }
2421
- if (this.findColumn(g.colKey)?.type === "boolean") {
2422
- const v = this.lastBooleanCell?.rowId === g.rowId && String(this.lastBooleanCell?.colKey) === String(g.colKey);
2423
- if (this.lastBooleanCell = { rowId: g.rowId, colKey: g.colKey }, this.selectionMode = !0, this.selectionAnchor = null, this.teardownInput(!1), this.teardownSelectionInput(), v) {
2424
- this.toggleBoolean(g.rowId, g.colKey), this.focusSelectionInput("");
3165
+ if (this.findColumn(y.colKey)?.type === "boolean") {
3166
+ const x = this.lastBooleanCell?.rowId === y.rowId && String(this.lastBooleanCell?.colKey) === String(y.colKey);
3167
+ if (this.lastBooleanCell = { rowId: y.rowId, colKey: y.colKey }, this.selectionMode = !0, this.selectionAnchor = null, this.teardownInput(!1), this.teardownSelectionInput(), x) {
3168
+ this.toggleBoolean(y.rowId, y.colKey), this.focusSelectionInput("");
2425
3169
  return;
2426
3170
  }
2427
3171
  this.focusSelectionInput("");
2428
3172
  return;
2429
3173
  }
2430
3174
  this.lastBooleanCell = null, this.selectionAnchor = null, this.teardownInput(!1);
2431
- const b = this.dataModel.getCell(g.rowId, g.colKey), C = this.cellToClipboardString(b);
2432
- this.focusSelectionInput(C), y && (this.selectionMode = !1, this.teardownSelectionInput(), this.openEditorAtActiveCell());
2433
- }, this.handleContextMenu = (d) => {
2434
- const m = d.target;
2435
- if (d.ctrlKey) {
2436
- d.preventDefault();
3175
+ const b = this.dataModel.getCell(y.rowId, y.colKey), S = this.cellToClipboardString(b);
3176
+ this.focusSelectionInput(S), w && (this.selectionMode = !1, this.teardownSelectionInput(), this.openEditorAtActiveCell());
3177
+ }, this.handleContextMenu = (h) => {
3178
+ const m = h.target;
3179
+ if (h.ctrlKey) {
3180
+ h.preventDefault();
2437
3181
  return;
2438
3182
  }
2439
3183
  if (!m || !this.root.contains(m)) return;
2440
- d.preventDefault(), d.stopPropagation();
2441
- const g = this.hitTest(d), y = g?.rowId ?? null, w = g?.colKey ?? null;
2442
- this.onContextMenu(y, w, d.clientX, d.clientY);
2443
- }, this.root = t, this.editMode = e, this.onEdit = i, this.onRowSelect = n, this.onMove = s, this.hitTest = o, this.isCellReadonly = a, this.onContextMenu = h, this.bind();
3184
+ h.preventDefault(), h.stopPropagation();
3185
+ const y = this.hitTest(h), w = y?.rowId ?? null, C = y?.colKey ?? null;
3186
+ this.onContextMenu(w, C, h.clientX, h.clientY);
3187
+ }, this.root = t, this.editMode = e, this.onEdit = i, this.onRowSelect = n, this.onMove = s, this.hitTest = o, this.sequenceLangs = a, this.isCellReadonly = c, this.onContextMenu = d, this.bind();
2444
3188
  }
2445
3189
  setEditMode(t) {
2446
3190
  this.editMode = t;
@@ -2465,37 +3209,37 @@ class Se {
2465
3209
  }
2466
3210
  ], w = !0;
2467
3211
  else {
2468
- const S = this.selectionRanges.map((b) => {
2469
- const C = (R, I) => Math.max(0, Math.min(I, R)), v = {
2470
- ...b,
2471
- startRow: C(b.startRow, i),
2472
- endRow: C(b.endRow, i),
2473
- startCol: C(b.startCol, n),
2474
- endCol: C(b.endCol, n)
3212
+ const C = this.selectionRanges.map((v) => {
3213
+ const b = (x, R) => Math.max(0, Math.min(R, x)), S = {
3214
+ ...v,
3215
+ startRow: b(v.startRow, i),
3216
+ endRow: b(v.endRow, i),
3217
+ startCol: b(v.startCol, n),
3218
+ endCol: b(v.endCol, n)
2475
3219
  };
2476
- return (v.startRow !== b.startRow || v.endRow !== b.endRow || v.startCol !== b.startCol || v.endCol !== b.endCol) && (w = !0), v;
3220
+ return (S.startRow !== v.startRow || S.endRow !== v.endRow || S.startCol !== v.startCol || S.endCol !== v.endCol) && (w = !0), S;
2477
3221
  });
2478
- this.selectionRanges = S;
3222
+ this.selectionRanges = C;
2479
3223
  }
2480
3224
  w && this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag();
2481
3225
  return;
2482
3226
  }
2483
- const l = o ?? t.columns[0]?.key ?? "";
2484
- let h = t.columns.findIndex((w) => String(w.key) === String(l));
2485
- h < 0 && (h = 0);
2486
- const u = t.columns[h]?.key ?? "", f = s ? this.dataModel.getBaseRowIndex(s) : 0, p = e[e.length - 1] ?? e[0] ?? null, d = e.find((w) => this.dataModel.getBaseRowIndex(w.id) >= f) ?? p;
2487
- if (!d) return;
2488
- const m = d.id, g = this.dataModel.getRowIndex(m);
3227
+ const c = o ?? t.columns[0]?.key ?? "";
3228
+ let u = t.columns.findIndex((w) => String(w.key) === String(c));
3229
+ u < 0 && (u = 0);
3230
+ const d = t.columns[u]?.key ?? "", f = s ? this.dataModel.getBaseRowIndex(s) : 0, g = e[e.length - 1] ?? e[0] ?? null, p = e.find((w) => this.dataModel.getBaseRowIndex(w.id) >= f) ?? g;
3231
+ if (!p) return;
3232
+ const h = p.id, m = this.dataModel.getRowIndex(h);
2489
3233
  this.selectionAnchor = null, this.lastBooleanCell = null, this.teardownInput(!1), this.selectionRanges = [
2490
3234
  {
2491
3235
  kind: "cells",
2492
- startRow: g,
2493
- endRow: g,
2494
- startCol: h,
2495
- endCol: h
3236
+ startRow: m,
3237
+ endRow: m,
3238
+ startCol: u,
3239
+ endCol: u
2496
3240
  }
2497
- ], this.activeCell = { rowId: m, colKey: u }, this.onActiveChange(m, u), this.onSelectionChange(this.selectionRanges), this.ensureVisibleCell(m, u);
2498
- const y = this.dataModel.getCell(m, u);
3241
+ ], this.activeCell = { rowId: h, colKey: d }, this.onActiveChange(h, d), this.onSelectionChange(this.selectionRanges), this.ensureVisibleCell(h, d);
3242
+ const y = this.dataModel.getCell(h, d);
2499
3243
  this.focusSelectionInput(this.cellToClipboardString(y)), this.updateFillHandleFlag();
2500
3244
  }
2501
3245
  navigateToCell(t, e) {
@@ -2517,17 +3261,17 @@ class Se {
2517
3261
  this.teardownInput(!0);
2518
3262
  }
2519
3263
  destroy() {
2520
- this.root.removeEventListener("click", this.handleClick), this.root.removeEventListener("pointerdown", this.handlePointerDown), this.root.removeEventListener("pointermove", this.handlePointerMove), this.root.removeEventListener("pointerup", this.handlePointerUp), this.root.removeEventListener("pointercancel", this.handlePointerUp), this.handleDocumentContextMenu && document.removeEventListener("contextmenu", this.handleDocumentContextMenu, !0), this.teardownInput(!0), this.teardownSelectionInput(), this.teardownCopyToast(), this.stopAutoScroll();
3264
+ this.root.removeEventListener("click", this.handleClick), this.root.removeEventListener("pointerdown", this.handlePointerDown), this.root.removeEventListener("pointermove", this.handlePointerMove), this.root.removeEventListener("pointerup", this.handlePointerUp), this.root.removeEventListener("pointercancel", this.handlePointerUp), this.root.removeEventListener("keydown", this.handleRootKeydown), this.handleDocumentContextMenu && document.removeEventListener("contextmenu", this.handleDocumentContextMenu, !0), this.teardownInput(!0), this.teardownSelectionInput(), this.teardownCopyToast(), this.stopAutoScroll();
2521
3265
  }
2522
3266
  onScroll(t, e) {
2523
3267
  this.positionCopyToast();
2524
3268
  }
2525
3269
  bind() {
2526
- this.root.addEventListener("click", this.handleClick), this.root.addEventListener("pointerdown", this.handlePointerDown), this.root.addEventListener("pointermove", this.handlePointerMove), this.root.addEventListener("pointerup", this.handlePointerUp), this.root.addEventListener("pointercancel", this.handlePointerUp), this.handleDocumentContextMenu = (t) => this.handleContextMenu(t), document.addEventListener("contextmenu", this.handleDocumentContextMenu, { capture: !0 });
3270
+ this.root.addEventListener("click", this.handleClick), this.root.addEventListener("pointerdown", this.handlePointerDown), this.root.addEventListener("pointermove", this.handlePointerMove), this.root.addEventListener("pointerup", this.handlePointerUp), this.root.addEventListener("pointercancel", this.handlePointerUp), this.root.addEventListener("keydown", this.handleRootKeydown), this.handleDocumentContextMenu = (t) => this.handleContextMenu(t), document.addEventListener("contextmenu", this.handleDocumentContextMenu, { capture: !0 });
2527
3271
  }
2528
3272
  updateFillHandleFlag() {
2529
3273
  const t = this.activeCell?.colKey ?? null, e = this.activeCell?.rowId ?? null;
2530
- this.root.dataset.extableFillHandle = ot(
3274
+ this.root.dataset.extableFillHandle = ft(
2531
3275
  this.dataModel,
2532
3276
  this.selectionRanges,
2533
3277
  e,
@@ -2576,20 +3320,25 @@ class Se {
2576
3320
  if (this.copyToastEl) return this.copyToastEl;
2577
3321
  window.getComputedStyle(this.root).position === "static" && (this.root.style.position = "relative");
2578
3322
  const e = document.createElement("div");
2579
- return e.className = "extable-toast", e.dataset.extableCopyToast = "1", e.setAttribute("popover", "manual"), e.style.position = "absolute", e.style.left = "0", e.style.top = "0", e.style.pointerEvents = "none", e.style.zIndex = "1000", e.style.margin = "0", this.root.appendChild(e), this.copyToastEl = e, e;
3323
+ return e.className = "extable-toast", e.dataset.extableCopyToast = "1", e.style.position = "absolute", e.style.left = "0", e.style.top = "0", e.style.pointerEvents = "none", e.style.zIndex = "1000", e.style.display = "none", e.style.margin = "0", this.root.appendChild(e), this.copyToastEl = e, e;
2580
3324
  }
2581
3325
  teardownCopyToast() {
2582
- this.copyToastTimer && (window.clearTimeout(this.copyToastTimer), this.copyToastTimer = null), this.copyToastEl && (this.copyToastEl.hidePopover?.(), _(this.copyToastEl), this.copyToastEl = null);
3326
+ this.copyToastTimer && (window.clearTimeout(this.copyToastTimer), this.copyToastTimer = null), this.copyToastEl && (this.copyToastEl.style.display = "none", _(this.copyToastEl), this.copyToastEl = null);
2583
3327
  }
2584
3328
  positionCopyToast() {
2585
3329
  if (!this.copyToastEl) return;
2586
- const t = this.copyToastEl.offsetWidth || 0, e = this.copyToastEl.offsetHeight || 0, i = 16, n = Math.max(0, this.root.scrollLeft + this.root.clientWidth - t - i), s = Math.max(0, this.root.scrollTop + this.root.clientHeight - e - i);
3330
+ const t = this.copyToastEl.offsetWidth || 0, e = this.copyToastEl.offsetHeight || 0, i = 16, n = Math.max(0, this.root.scrollLeft + this.root.clientWidth - t - i), s = Math.max(0, this.root.scrollTop + this.root.clientHeight - e - i), o = Math.max(0, this.root.scrollLeft + i), r = Math.max(0, this.root.scrollTop + i), a = this.root.getBoundingClientRect(), c = this.getActiveCellRect();
3331
+ if (c) {
3332
+ const u = c.right - a.left + this.root.scrollLeft - t + 8, d = c.top - a.top + this.root.scrollTop - e + 8, f = Math.min(n, Math.max(o, u)), g = Math.min(s, Math.max(r, d));
3333
+ this.copyToastEl.style.left = `${f}px`, this.copyToastEl.style.top = `${g}px`;
3334
+ return;
3335
+ }
2587
3336
  this.copyToastEl.style.left = `${n}px`, this.copyToastEl.style.top = `${s}px`;
2588
3337
  }
2589
3338
  showCopyToast(t, e = "info", i = 1200) {
2590
3339
  const n = this.ensureCopyToast();
2591
- n.textContent = t, n.dataset.variant = e, n.hidePopover?.(), n.showPopover?.(), this.positionCopyToast(), this.copyToastTimer && (window.clearTimeout(this.copyToastTimer), this.copyToastTimer = null), this.copyToastTimer = window.setTimeout(() => {
2592
- n.hidePopover?.();
3340
+ n.textContent = t, n.dataset.variant = e, n.style.display = "block", this.positionCopyToast(), this.copyToastTimer && (window.clearTimeout(this.copyToastTimer), this.copyToastTimer = null), this.copyToastTimer = window.setTimeout(() => {
3341
+ n.style.display = "none";
2593
3342
  }, i);
2594
3343
  }
2595
3344
  ensureSelectionInput() {
@@ -2642,20 +3391,66 @@ class Se {
2642
3391
  ) ? this.getCanvasCellMetrics(t, e) : null;
2643
3392
  }
2644
3393
  getCanvasCellMetrics(t, e) {
2645
- const i = this.dataModel.getSchema(), n = this.dataModel.getView(), s = this.dataModel.listRows(), o = s.findIndex((g) => g.id === t), r = i.columns.findIndex((g) => String(g.key) === String(e));
3394
+ const i = this.dataModel.getSchema(), n = this.dataModel.getView(), s = this.dataModel.listRows(), o = s.findIndex((m) => m.id === t), r = i.columns.findIndex((m) => String(m.key) === String(e));
2646
3395
  if (o < 0 || r < 0) return null;
2647
- const a = Ft, l = ht, h = ut, u = W(i, n);
2648
- let f = l;
2649
- for (let g = 0; g < r; g += 1) f += u[g] ?? 100;
2650
- let p = a;
2651
- for (let g = 0; g < o; g += 1) {
2652
- const y = s[g];
3396
+ const a = nt, c = Y, u = st, d = X(i, n);
3397
+ let f = c;
3398
+ for (let m = 0; m < r; m += 1) f += d[m] ?? 100;
3399
+ let g = a;
3400
+ for (let m = 0; m < o; m += 1) {
3401
+ const y = s[m];
2653
3402
  if (!y) return null;
2654
- const w = this.dataModel.getRowHeight(y.id) ?? h;
2655
- p += w;
3403
+ const w = this.dataModel.getRowHeight(y.id) ?? u;
3404
+ g += w;
3405
+ }
3406
+ const p = this.dataModel.getRowHeight(t) ?? u, h = d[r] ?? 100;
3407
+ return { left: f, top: g, width: h, height: p, rowIndex: o, colIndex: r };
3408
+ }
3409
+ getActiveCellRect() {
3410
+ const t = this.activeCell;
3411
+ if (!t) return null;
3412
+ const e = this.root.getBoundingClientRect(), i = this.dataModel.getSchema(), n = this.dataModel.getView();
3413
+ if (t.rowId === "__all__" && t.colKey === "__all__")
3414
+ return new DOMRect(e.left, e.top, Y, nt);
3415
+ if (t.rowId === "__header__" && t.colKey !== null) {
3416
+ const o = this.escapeCssAttrValue(String(t.colKey)), r = this.root.querySelector(`th[data-col-key="${o}"]`);
3417
+ if (r) return r.getBoundingClientRect();
3418
+ const a = i.columns.findIndex((c) => String(c.key) === String(t.colKey));
3419
+ if (a >= 0) {
3420
+ const c = X(i, n);
3421
+ let u = Y;
3422
+ for (let f = 0; f < a; f += 1) u += c[f] ?? 100;
3423
+ const d = c[a] ?? 100;
3424
+ return new DOMRect(
3425
+ e.left + u - this.root.scrollLeft,
3426
+ e.top,
3427
+ d,
3428
+ nt
3429
+ );
3430
+ }
3431
+ }
3432
+ if (t.colKey === null) {
3433
+ const o = this.dataModel.getRowIndex(t.rowId);
3434
+ if (o >= 0) {
3435
+ let r = nt;
3436
+ const a = this.dataModel.listRows();
3437
+ for (let u = 0; u < o; u += 1) {
3438
+ const d = a[u];
3439
+ if (!d) break;
3440
+ r += this.dataModel.getRowHeight(d.id) ?? st;
3441
+ }
3442
+ const c = this.dataModel.getRowHeight(t.rowId) ?? st;
3443
+ return new DOMRect(
3444
+ e.left,
3445
+ e.top + r - this.root.scrollTop,
3446
+ Y,
3447
+ c
3448
+ );
3449
+ }
2656
3450
  }
2657
- const d = this.dataModel.getRowHeight(t) ?? h, m = u[r] ?? 100;
2658
- return { left: f, top: p, width: m, height: d, rowIndex: o, colIndex: r };
3451
+ if (t.colKey === null) return null;
3452
+ const s = this.findHtmlCellElement(t.rowId, t.colKey);
3453
+ return s ? s.getBoundingClientRect() : this.computeCanvasCellRect(t.rowId, t.colKey);
2659
3454
  }
2660
3455
  ensureVisibleCell(t, e) {
2661
3456
  const i = this.findHtmlCellElement(t, e);
@@ -2665,8 +3460,8 @@ class Se {
2665
3460
  }
2666
3461
  const n = this.getCanvasCellMetrics(t, e);
2667
3462
  if (!n) return;
2668
- const s = n.left, o = n.left + n.width, r = n.top, a = n.top + n.height, l = this.root.scrollLeft, h = this.root.scrollLeft + this.root.clientWidth, u = this.root.scrollTop, f = this.root.scrollTop + this.root.clientHeight;
2669
- s < l ? this.root.scrollLeft = Math.max(0, s) : o > h && (this.root.scrollLeft = Math.max(0, o - this.root.clientWidth)), r < u ? this.root.scrollTop = Math.max(0, r) : a > f && (this.root.scrollTop = Math.max(0, a - this.root.clientHeight));
3463
+ const s = n.left, o = n.left + n.width, r = n.top, a = n.top + n.height, c = this.root.scrollLeft, u = this.root.scrollLeft + this.root.clientWidth, d = this.root.scrollTop, f = this.root.scrollTop + this.root.clientHeight;
3464
+ s < c ? this.root.scrollLeft = Math.max(0, s) : o > u && (this.root.scrollLeft = Math.max(0, o - this.root.clientWidth)), r < d ? this.root.scrollTop = Math.max(0, r) : a > f && (this.root.scrollTop = Math.max(0, a - this.root.clientHeight));
2670
3465
  }
2671
3466
  moveActiveCell(t, e, i = !1) {
2672
3467
  const n = this.dataModel.getSchema(), s = this.dataModel.listRows();
@@ -2675,27 +3470,27 @@ class Se {
2675
3470
  i || (this.selectionAnchor = null);
2676
3471
  const a = i && this.selectionAnchor ? this.selectionAnchor : i ? { rowIndex: o, colIndex: r } : null;
2677
3472
  i && !this.selectionAnchor && (this.selectionAnchor = { rowIndex: o, colIndex: r });
2678
- const l = Math.max(0, Math.min(s.length - 1, o + t)), h = Math.max(0, Math.min(n.columns.length - 1, r + e));
3473
+ const c = Math.max(0, Math.min(s.length - 1, o + t)), u = Math.max(0, Math.min(n.columns.length - 1, r + e));
2679
3474
  {
2680
- const u = s[l];
2681
- if (!u) return;
2682
- const f = n.columns[h];
3475
+ const d = s[c];
3476
+ if (!d) return;
3477
+ const f = n.columns[u];
2683
3478
  if (!f) return;
2684
- const p = u.id, d = f.key, m = a ? {
3479
+ const g = d.id, p = f.key, h = a ? {
2685
3480
  kind: "cells",
2686
3481
  startRow: a.rowIndex,
2687
- endRow: l,
3482
+ endRow: c,
2688
3483
  startCol: a.colIndex,
2689
- endCol: h
3484
+ endCol: u
2690
3485
  } : {
2691
3486
  kind: "cells",
2692
- startRow: l,
2693
- endRow: l,
2694
- startCol: h,
2695
- endCol: h
3487
+ startRow: c,
3488
+ endRow: c,
3489
+ startCol: u,
3490
+ endCol: u
2696
3491
  };
2697
- this.selectionRanges = [m], this.activeCell = { rowId: p, colKey: d }, this.onActiveChange(p, d), this.onSelectionChange(this.selectionRanges), this.ensureVisibleCell(p, d);
2698
- const g = this.dataModel.getCell(p, d), y = this.cellToClipboardString(g);
3492
+ this.selectionRanges = [h], this.activeCell = { rowId: g, colKey: p }, this.onActiveChange(g, p), this.onSelectionChange(this.selectionRanges), this.ensureVisibleCell(g, p);
3493
+ const m = this.dataModel.getCell(g, p), y = this.cellToClipboardString(m);
2699
3494
  this.focusSelectionInput(y), this.updateFillHandleFlag();
2700
3495
  return;
2701
3496
  }
@@ -2714,10 +3509,10 @@ class Se {
2714
3509
  };
2715
3510
  const s = i.closest("th.extable-row-header:not(.extable-corner)");
2716
3511
  if (s) {
2717
- const l = s.closest("tr[data-row-id]");
2718
- if (l)
3512
+ const c = s.closest("tr[data-row-id]");
3513
+ if (c)
2719
3514
  return {
2720
- rowId: l.dataset.rowId ?? "",
3515
+ rowId: c.dataset.rowId ?? "",
2721
3516
  colKey: null,
2722
3517
  element: s,
2723
3518
  rect: s.getBoundingClientRect()
@@ -2749,34 +3544,34 @@ class Se {
2749
3544
  return;
2750
3545
  const n = this.dataModel.getSchema(), s = this.dataModel.listRows(), o = this.dataModel.getRowIndex(i.rowId);
2751
3546
  if (o < 0) return;
2752
- const r = this.dragStart.kind === "rows" ? n.columns.length - 1 : n.columns.findIndex((d) => String(d.key) === String(i.colKey));
3547
+ const r = this.dragStart.kind === "rows" ? n.columns.length - 1 : n.columns.findIndex((p) => String(p.key) === String(i.colKey));
2753
3548
  if (r < 0) return;
2754
- const a = this.dragStart.rowIndex, l = this.dragStart.kind === "rows" ? 0 : this.dragStart.colIndex, h = this.dragStart.kind === "rows" ? n.columns.length - 1 : r;
2755
- (o !== a || h !== l) && (this.dragSelectionChanged = !0);
2756
- const u = {
3549
+ const a = this.dragStart.rowIndex, c = this.dragStart.kind === "rows" ? 0 : this.dragStart.colIndex, u = this.dragStart.kind === "rows" ? n.columns.length - 1 : r;
3550
+ (o !== a || u !== c) && (this.dragSelectionChanged = !0);
3551
+ const d = {
2757
3552
  kind: this.dragStart.kind,
2758
3553
  startRow: a,
2759
3554
  endRow: o,
2760
- startCol: l,
2761
- endCol: h
3555
+ startCol: c,
3556
+ endCol: u
2762
3557
  };
2763
- this.selectionRanges = [u];
2764
- const f = s[o]?.id ?? i.rowId, p = this.dragStart.kind === "rows" ? n.columns[0]?.key ?? i.colKey : n.columns[r]?.key ?? i.colKey;
2765
- this.activeCell = { rowId: f, colKey: p }, this.onActiveChange(f, p), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag();
3558
+ this.selectionRanges = [d];
3559
+ const f = s[o]?.id ?? i.rowId, g = this.dragStart.kind === "rows" ? n.columns[0]?.key ?? i.colKey : n.columns[r]?.key ?? i.colKey;
3560
+ this.activeCell = { rowId: f, colKey: g }, this.onActiveChange(f, g), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag();
2766
3561
  }
2767
3562
  updateFillDragFromClientPoint(t, e) {
2768
3563
  if (!this.fillDragging || !this.fillSource) return;
2769
3564
  const i = this.getHitAtClientPoint(t, e);
2770
3565
  if (!i || i.colKey === "__all__" || i.colKey === null) return;
2771
3566
  const n = this.dataModel.getSchema(), s = this.dataModel.listRows(), o = this.dataModel.getRowIndex(i.rowId);
2772
- if (o < 0 || n.columns.findIndex((l) => String(l.key) === String(i.colKey)) !== this.fillSource.colIndex) return;
3567
+ if (o < 0 || n.columns.findIndex((c) => String(c.key) === String(i.colKey)) !== this.fillSource.colIndex) return;
2773
3568
  const a = Math.max(this.fillSource.endRowIndex, o);
2774
3569
  if (this.fillEndRowIndex !== a) {
2775
3570
  this.fillEndRowIndex = a;
2776
- const l = s[a]?.id ?? i.rowId, h = n.columns[this.fillSource.colIndex];
2777
- if (!h) return;
2778
- const u = h.key;
2779
- this.activeCell = { rowId: l, colKey: u }, this.onActiveChange(l, u), this.selectionRanges = [
3571
+ const c = s[a]?.id ?? i.rowId, u = n.columns[this.fillSource.colIndex];
3572
+ if (!u) return;
3573
+ const d = u.key;
3574
+ this.activeCell = { rowId: c, colKey: d }, this.onActiveChange(c, d), this.selectionRanges = [
2780
3575
  {
2781
3576
  kind: "cells",
2782
3577
  startRow: this.fillSource.startRowIndex,
@@ -2819,24 +3614,24 @@ class Se {
2819
3614
  commitFill(t, e) {
2820
3615
  const i = this.dataModel.getSchema(), n = this.dataModel.listRows(), s = i.columns[t.colIndex];
2821
3616
  if (!s || e <= t.endRowIndex) return;
2822
- const o = ge(this.dataModel, t);
3617
+ const o = xi(this.dataModel, t, this.sequenceLangs);
2823
3618
  if (!o) return;
2824
3619
  const r = this.editMode === "direct", a = `fill:${Date.now()}:${Math.random().toString(16).slice(2)}`;
2825
- for (let u = t.endRowIndex + 1; u <= e; u += 1) {
2826
- const f = n[u];
3620
+ for (let d = t.endRowIndex + 1; d <= e; d += 1) {
3621
+ const f = n[d];
2827
3622
  if (!f) break;
2828
3623
  if (this.isCellReadonly(f.id, s.key)) continue;
2829
- const p = u - t.endRowIndex, d = o(p), m = {
3624
+ const g = d - t.endRowIndex, p = o(g), h = {
2830
3625
  kind: "edit",
2831
3626
  rowId: f.id,
2832
3627
  colKey: s.key,
2833
- next: d,
3628
+ next: p,
2834
3629
  payload: { batchId: a }
2835
3630
  };
2836
- this.onEdit(m, r);
3631
+ this.onEdit(h, r);
2837
3632
  }
2838
- const l = n[e];
2839
- if (!l) return;
3633
+ const c = n[e];
3634
+ if (!c) return;
2840
3635
  this.selectionRanges = [
2841
3636
  {
2842
3637
  kind: "cells",
@@ -2845,9 +3640,9 @@ class Se {
2845
3640
  startCol: t.colIndex,
2846
3641
  endCol: t.colIndex
2847
3642
  }
2848
- ], this.activeCell = { rowId: l.id, colKey: s.key }, this.onActiveChange(l.id, s.key), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), this.ensureVisibleCell(l.id, s.key);
2849
- const h = this.dataModel.getCell(l.id, s.key);
2850
- this.focusSelectionInput(this.cellToClipboardString(h));
3643
+ ], this.activeCell = { rowId: c.id, colKey: s.key }, this.onActiveChange(c.id, s.key), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), this.ensureVisibleCell(c.id, s.key);
3644
+ const u = this.dataModel.getCell(c.id, s.key);
3645
+ this.focusSelectionInput(this.cellToClipboardString(u));
2851
3646
  }
2852
3647
  teardownSelectionInput() {
2853
3648
  const t = this.selectionInput;
@@ -2874,8 +3669,8 @@ class Se {
2874
3669
  }
2875
3670
  return !1;
2876
3671
  }, o = () => {
2877
- const a = this.ensureSelectionInput(), l = a.value;
2878
- a.value = e, a.select(), document.execCommand?.("copy"), a.value = l;
3672
+ const a = this.ensureSelectionInput(), c = a.value;
3673
+ a.value = e, a.select(), document.execCommand?.("copy"), a.value = c;
2879
3674
  };
2880
3675
  await s() || o(), this.showCopyToast(`Copied ${n} cells`, "info");
2881
3676
  }
@@ -2909,7 +3704,15 @@ class Se {
2909
3704
  const t = this.dataModel.getSchema();
2910
3705
  if (this.selectionRanges.length > 0) {
2911
3706
  const s = this.selectionRanges[0];
2912
- return s ? this.normalizeRange(s) : null;
3707
+ if (!s) return null;
3708
+ const o = this.normalizeRange(s);
3709
+ return o.kind === "rows" ? {
3710
+ kind: "cells",
3711
+ startRow: o.startRow,
3712
+ endRow: o.endRow,
3713
+ startCol: o.startCol,
3714
+ endCol: o.endCol
3715
+ } : o;
2913
3716
  }
2914
3717
  if (!this.activeCell) return null;
2915
3718
  const e = this.activeCell;
@@ -2938,21 +3741,21 @@ class Se {
2938
3741
  if (!i || i.kind !== "cells") return null;
2939
3742
  const n = [], s = [], o = "border-collapse:collapse;border-spacing:0;", r = "border:1px solid #d0d7de;padding:4px 6px;vertical-align:top;";
2940
3743
  let a = 0;
2941
- for (let u = i.startRow; u <= i.endRow; u += 1) {
2942
- const f = e[u];
3744
+ for (let d = i.startRow; d <= i.endRow; d += 1) {
3745
+ const f = e[d];
2943
3746
  if (!f) continue;
2944
- const p = [], d = [];
2945
- for (let m = i.startCol; m <= i.endCol; m += 1) {
2946
- const g = t.columns[m];
2947
- if (!g) continue;
2948
- const y = this.dataModel.getCell(f.id, g.key), w = this.cellToClipboardString(y);
2949
- p.push(w), d.push(`<td style="${r}">${this.escapeHtml(w)}</td>`), a += 1;
3747
+ const g = [], p = [];
3748
+ for (let h = i.startCol; h <= i.endCol; h += 1) {
3749
+ const m = t.columns[h];
3750
+ if (!m) continue;
3751
+ const y = this.dataModel.getCell(f.id, m.key), w = this.cellToClipboardString(y);
3752
+ g.push(w), p.push(`<td style="${r}">${this.escapeHtml(w)}</td>`), a += 1;
2950
3753
  }
2951
- n.push(p.join(" ")), s.push(`<tr>${d.join("")}</tr>`);
3754
+ n.push(g.join(" ")), s.push(`<tr>${p.join("")}</tr>`);
2952
3755
  }
2953
- const l = n.join(`\r
2954
- `), h = `<table style="${o}"><tbody>${s.join("")}</tbody></table>`;
2955
- return { text: l, html: h, cellCount: a };
3756
+ const c = n.join(`\r
3757
+ `), u = `<table style="${o}"><tbody>${s.join("")}</tbody></table>`;
3758
+ return { text: c, html: u, cellCount: a };
2956
3759
  }
2957
3760
  clearSelectionValues() {
2958
3761
  const t = this.dataModel.getSchema(), e = this.dataModel.listRows(), i = this.getCopyRange();
@@ -2962,16 +3765,16 @@ class Se {
2962
3765
  const r = e[o];
2963
3766
  if (r)
2964
3767
  for (let a = i.startCol; a <= i.endCol; a += 1) {
2965
- const l = t.columns[a];
2966
- if (!l || this.isCellReadonly(r.id, l.key)) continue;
2967
- const h = l.type === "boolean" ? !1 : "", u = {
3768
+ const c = t.columns[a];
3769
+ if (!c || this.isCellReadonly(r.id, c.key)) continue;
3770
+ const u = c.type === "boolean" ? !1 : "", d = {
2968
3771
  kind: "edit",
2969
3772
  rowId: r.id,
2970
- colKey: l.key,
2971
- next: h,
3773
+ colKey: c.key,
3774
+ next: u,
2972
3775
  payload: { batchId: s }
2973
3776
  };
2974
- this.onEdit(u, n);
3777
+ this.onEdit(d, n);
2975
3778
  }
2976
3779
  }
2977
3780
  }
@@ -2996,10 +3799,10 @@ class Se {
2996
3799
  for (const r of s) {
2997
3800
  const a = Array.from(r.querySelectorAll("th,td"));
2998
3801
  if (a.some(
2999
- (l) => l.rowSpan > 1 || l.colSpan > 1
3802
+ (c) => c.rowSpan > 1 || c.colSpan > 1
3000
3803
  ))
3001
3804
  return null;
3002
- o.push(a.map((l) => (l.textContent ?? "").trim()));
3805
+ o.push(a.map((c) => (c.textContent ?? "").trim()));
3003
3806
  }
3004
3807
  return o.length ? o : null;
3005
3808
  } catch {
@@ -3023,21 +3826,21 @@ class Se {
3023
3826
  applyClipboardGrid(t) {
3024
3827
  const e = this.dataModel.getSchema(), i = this.dataModel.listRows(), { rowIndex: n, colIndex: s } = this.getActiveIndices(), o = this.editMode === "direct", r = `paste:${Date.now()}:${Math.random().toString(16).slice(2)}`;
3025
3828
  for (let a = 0; a < t.length; a += 1) {
3026
- const l = i[n + a];
3027
- if (!l) break;
3028
- const h = t[a] ?? [];
3029
- for (let u = 0; u < h.length; u += 1) {
3030
- const f = e.columns[s + u];
3829
+ const c = i[n + a];
3830
+ if (!c) break;
3831
+ const u = t[a] ?? [];
3832
+ for (let d = 0; d < u.length; d += 1) {
3833
+ const f = e.columns[s + d];
3031
3834
  if (!f) break;
3032
- if (this.isCellReadonly(l.id, f.key)) continue;
3033
- const p = this.coerceCellValue(h[u] ?? "", f.key), d = {
3835
+ if (this.isCellReadonly(c.id, f.key)) continue;
3836
+ const g = this.coerceCellValue(u[d] ?? "", f.key), p = {
3034
3837
  kind: "edit",
3035
- rowId: l.id,
3838
+ rowId: c.id,
3036
3839
  colKey: f.key,
3037
- next: p,
3840
+ next: g,
3038
3841
  payload: { batchId: r }
3039
3842
  };
3040
- this.onEdit(d, o);
3843
+ this.onEdit(p, o);
3041
3844
  }
3042
3845
  }
3043
3846
  }
@@ -3065,28 +3868,28 @@ class Se {
3065
3868
  if (i?.type === "enum" || i?.type === "tags") {
3066
3869
  const o = i.enum?.allowCustom ?? i.tags?.allowCustom, r = i.enum?.options ?? i.tags?.options ?? [];
3067
3870
  if (o === !1) {
3068
- const u = document.createElement("select"), f = document.createElement("option");
3069
- f.value = "", f.textContent = "", u.appendChild(f);
3070
- for (const p of r) {
3071
- const d = document.createElement("option");
3072
- d.value = p, d.textContent = p, e === p && (d.selected = !0), u.appendChild(d);
3871
+ const d = document.createElement("select"), f = document.createElement("option");
3872
+ f.value = "", f.textContent = "", d.appendChild(f);
3873
+ for (const g of r) {
3874
+ const p = document.createElement("option");
3875
+ p.value = g, p.textContent = g, e === g && (p.selected = !0), d.appendChild(p);
3073
3876
  }
3074
- return { control: u, value: e };
3877
+ return { control: d, value: e };
3075
3878
  }
3076
3879
  const a = document.createElement("input");
3077
3880
  a.type = "text";
3078
- const l = `extable-datalist-${String(t)}`;
3079
- a.setAttribute("list", l), a.value = e;
3080
- let h = document.getElementById(l);
3081
- if (!h) {
3082
- h = document.createElement("datalist"), h.id = l;
3083
- for (const u of r) {
3881
+ const c = `extable-datalist-${String(t)}`;
3882
+ a.setAttribute("list", c), a.value = e;
3883
+ let u = document.getElementById(c);
3884
+ if (!u) {
3885
+ u = document.createElement("datalist"), u.id = c;
3886
+ for (const d of r) {
3084
3887
  const f = document.createElement("option");
3085
- f.value = u, h.appendChild(f);
3888
+ f.value = d, u.appendChild(f);
3086
3889
  }
3087
- this.root.appendChild(h);
3890
+ this.root.appendChild(u);
3088
3891
  }
3089
- return { control: a, value: e, datalistId: l };
3892
+ return { control: a, value: e, datalistId: c };
3090
3893
  }
3091
3894
  const s = document.createElement("input");
3092
3895
  return s.type = "text", s.value = e, { control: s, value: e };
@@ -3106,7 +3909,7 @@ class Se {
3106
3909
  this.onEdit(o, r), this.onMove(t);
3107
3910
  }
3108
3911
  applySelectionFromHit(t, e) {
3109
- const i = this.dataModel.getSchema(), n = this.dataModel.getRowIndex(e.rowId), s = e.colKey === null, o = s ? i.columns.length > 0 ? 0 : -1 : i.columns.findIndex((h) => String(h.key) === String(e.colKey));
3912
+ const i = this.dataModel.getSchema(), n = this.dataModel.getRowIndex(e.rowId), s = e.colKey === null, o = s ? i.columns.length > 0 ? 0 : -1 : i.columns.findIndex((u) => String(u.key) === String(e.colKey));
3110
3913
  if (o < 0) return;
3111
3914
  const r = s ? {
3112
3915
  kind: "rows",
@@ -3123,24 +3926,24 @@ class Se {
3123
3926
  };
3124
3927
  let a = [];
3125
3928
  if (t.shiftKey && this.activeCell) {
3126
- const h = this.activeCell, u = this.dataModel.getRowIndex(h.rowId), f = i.columns.findIndex((d) => String(d.key) === String(h.colKey));
3929
+ const u = this.activeCell, d = this.dataModel.getRowIndex(u.rowId), f = i.columns.findIndex((p) => String(p.key) === String(u.colKey));
3127
3930
  a = [s ? {
3128
3931
  kind: "rows",
3129
- startRow: u,
3932
+ startRow: d,
3130
3933
  endRow: n,
3131
3934
  startCol: 0,
3132
3935
  endCol: i.columns.length - 1
3133
3936
  } : {
3134
3937
  kind: "cells",
3135
- startRow: u,
3938
+ startRow: d,
3136
3939
  endRow: n,
3137
3940
  startCol: Math.max(0, f),
3138
3941
  endCol: Math.max(0, o)
3139
3942
  }];
3140
3943
  } else t.metaKey || t.ctrlKey ? a = [...this.selectionRanges, r] : a = [r];
3141
3944
  this.selectionRanges = this.mergeRanges(a);
3142
- const l = r.kind === "rows" ? { rowId: e.rowId, colKey: i.columns[o]?.key ?? null } : { rowId: e.rowId, colKey: e.colKey };
3143
- this.activeCell = l, this.onActiveChange(l.rowId, l.colKey), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag();
3945
+ const c = r.kind === "rows" ? { rowId: e.rowId, colKey: i.columns[o]?.key ?? null } : { rowId: e.rowId, colKey: e.colKey };
3946
+ this.activeCell = c, this.onActiveChange(c.rowId, c.colKey), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), r.kind === "rows" && (this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput(""));
3144
3947
  }
3145
3948
  mergeRanges(t) {
3146
3949
  const e = [], i = [...t].sort((n, s) => n.kind !== s.kind ? n.kind === "rows" ? -1 : 1 : n.startRow !== s.startRow ? n.startRow - s.startRow : n.startCol !== s.startCol ? n.startCol - s.startCol : n.endRow !== s.endRow ? n.endRow - s.endRow : n.endCol - s.endCol);
@@ -3160,12 +3963,12 @@ class Se {
3160
3963
  continue;
3161
3964
  }
3162
3965
  } else {
3163
- const o = s.startCol === n.startCol && s.endCol === n.endCol, r = s.startRow === n.startRow && s.endRow === n.endRow, a = s.startRow <= n.endRow + 1 && n.startRow <= s.endRow + 1, l = s.startCol <= n.endCol + 1 && n.startCol <= s.endCol + 1;
3966
+ const o = s.startCol === n.startCol && s.endCol === n.endCol, r = s.startRow === n.startRow && s.endRow === n.endRow, a = s.startRow <= n.endRow + 1 && n.startRow <= s.endRow + 1, c = s.startCol <= n.endCol + 1 && n.startCol <= s.endCol + 1;
3164
3967
  if (o && a) {
3165
3968
  s.startRow = Math.min(s.startRow, n.startRow), s.endRow = Math.max(s.endRow, n.endRow);
3166
3969
  continue;
3167
3970
  }
3168
- if (r && l) {
3971
+ if (r && c) {
3169
3972
  s.startCol = Math.min(s.startCol, n.startCol), s.endCol = Math.max(s.endCol, n.endCol);
3170
3973
  continue;
3171
3974
  }
@@ -3176,18 +3979,18 @@ class Se {
3176
3979
  }
3177
3980
  activateCellElement(t, e, i, n) {
3178
3981
  this.teardownInput(), this.activeCell = { rowId: e, colKey: i }, this.activeHost = t, this.activeHostOriginalText = t.textContent ?? "";
3179
- const s = this.dataModel.getCell(e, i), o = n?.initialValueOverride ?? (s == null ? "" : String(s)), { control: r, value: a } = this.createEditor(i, o), l = r;
3180
- l.value = a, l.style.width = "calc(100% - 4px)", l.style.boxSizing = "border-box", l.style.margin = "2px", l.style.padding = "4px 6px", l.style.border = "none", l.style.borderRadius = "0", l.style.boxShadow = "none", l.style.background = "#fff", l.style.outline = "none", l.style.fontSize = "14px", l.style.fontFamily = "inherit", l.style.lineHeight = "1.2", l.style.fontWeight = "inherit";
3181
- const h = this.findColumn(i);
3182
- if (l.style.textAlign = h?.style?.align ?? (h?.type === "number" ? "right" : "left"), l.addEventListener("keydown", (u) => this.handleKey(u, t)), l.addEventListener("focus", () => {
3183
- (l instanceof HTMLInputElement || l instanceof HTMLTextAreaElement) && l.select();
3184
- }), this.bindImmediateCommit(l), t.textContent = "", t.appendChild(l), l.tagName.toLowerCase() === "textarea" && requestAnimationFrame(() => {
3185
- l instanceof HTMLTextAreaElement && this.autosize(l);
3186
- }), l.focus({ preventScroll: !0 }), n?.placeCursorAtEnd && (l instanceof HTMLInputElement || l instanceof HTMLTextAreaElement)) {
3187
- const u = l.value.length;
3188
- l.setSelectionRange(u, u);
3189
- }
3190
- this.inputEl = l;
3982
+ const s = this.dataModel.getCell(e, i), o = n?.initialValueOverride ?? (s == null ? "" : String(s)), { control: r, value: a } = this.createEditor(i, o), c = r;
3983
+ c.value = a, c.style.width = "calc(100% - 4px)", c.style.boxSizing = "border-box", c.style.margin = "2px", c.style.padding = "4px 6px", c.style.border = "none", c.style.borderRadius = "0", c.style.boxShadow = "none", c.style.background = "#fff", c.style.outline = "none", c.style.fontSize = "14px", c.style.fontFamily = "inherit", c.style.lineHeight = "1.2", c.style.fontWeight = "inherit";
3984
+ const u = this.findColumn(i);
3985
+ if (c.style.textAlign = u?.style?.align ?? (u?.type === "number" ? "right" : "left"), c.addEventListener("keydown", (d) => this.handleKey(d, t)), c.addEventListener("focus", () => {
3986
+ (c instanceof HTMLInputElement || c instanceof HTMLTextAreaElement) && c.select();
3987
+ }), this.bindImmediateCommit(c), t.textContent = "", t.appendChild(c), c.tagName.toLowerCase() === "textarea" && requestAnimationFrame(() => {
3988
+ c instanceof HTMLTextAreaElement && this.autosize(c);
3989
+ }), c.focus({ preventScroll: !0 }), n?.placeCursorAtEnd && (c instanceof HTMLInputElement || c instanceof HTMLTextAreaElement)) {
3990
+ const d = c.value.length;
3991
+ c.setSelectionRange(d, d);
3992
+ }
3993
+ this.inputEl = c;
3191
3994
  }
3192
3995
  activateFloating(t, e, i, n) {
3193
3996
  this.teardownInput(), this.activeCell = { rowId: e, colKey: i };
@@ -3195,18 +3998,18 @@ class Se {
3195
3998
  if (!s) return;
3196
3999
  const o = document.createElement("div");
3197
4000
  this.activeHost = o, this.activeHostOriginalText = null, o.style.position = "absolute", o.dataset.extableFloating = "fixed", o.style.pointerEvents = "auto", o.style.padding = "0", o.style.zIndex = "10";
3198
- const r = this.dataModel.getCell(e, i), a = n?.initialValueOverride ?? (r == null ? "" : String(r)), { control: l, value: h } = this.createEditor(i, a), u = l;
3199
- u.value = h, u.style.width = "calc(100% - 4px)", u.style.height = "calc(100% - 4px)", u.style.boxSizing = "border-box", u.style.margin = "2px", u.style.padding = "4px 6px", u.style.border = "none", u.style.borderRadius = "0", u.style.boxShadow = "none", u.style.background = "#fff", u.style.outline = "none", u.style.fontSize = "14px", u.style.fontFamily = "inherit", u.style.lineHeight = "1.2", u.style.fontWeight = "inherit";
4001
+ const r = this.dataModel.getCell(e, i), a = n?.initialValueOverride ?? (r == null ? "" : String(r)), { control: c, value: u } = this.createEditor(i, a), d = c;
4002
+ d.value = u, d.style.width = "calc(100% - 4px)", d.style.height = "calc(100% - 4px)", d.style.boxSizing = "border-box", d.style.margin = "2px", d.style.padding = "4px 6px", d.style.border = "none", d.style.borderRadius = "0", d.style.boxShadow = "none", d.style.background = "#fff", d.style.outline = "none", d.style.fontSize = "14px", d.style.fontFamily = "inherit", d.style.lineHeight = "1.2", d.style.fontWeight = "inherit";
3200
4003
  const f = this.findColumn(i);
3201
- if (u.style.textAlign = f?.style?.align ?? (f?.type === "number" ? "right" : "left"), u.style.pointerEvents = "auto", u.addEventListener("keydown", (p) => this.handleKey(p, o)), u.addEventListener("focus", () => {
3202
- (u instanceof HTMLInputElement || u instanceof HTMLTextAreaElement) && u.select();
3203
- }), this.bindImmediateCommit(u), o.appendChild(u), u.tagName.toLowerCase() === "textarea" && requestAnimationFrame(() => {
3204
- u instanceof HTMLTextAreaElement && this.autosize(u);
3205
- }), this.root.appendChild(o), this.positionFloatingContentBox(s, o), u.focus({ preventScroll: !0 }), n?.placeCursorAtEnd && (u instanceof HTMLInputElement || u instanceof HTMLTextAreaElement)) {
3206
- const p = u.value.length;
3207
- u.setSelectionRange(p, p);
4004
+ if (d.style.textAlign = f?.style?.align ?? (f?.type === "number" ? "right" : "left"), d.style.pointerEvents = "auto", d.addEventListener("keydown", (g) => this.handleKey(g, o)), d.addEventListener("focus", () => {
4005
+ (d instanceof HTMLInputElement || d instanceof HTMLTextAreaElement) && d.select();
4006
+ }), this.bindImmediateCommit(d), o.appendChild(d), d.tagName.toLowerCase() === "textarea" && requestAnimationFrame(() => {
4007
+ d instanceof HTMLTextAreaElement && this.autosize(d);
4008
+ }), this.root.appendChild(o), this.positionFloatingContentBox(s, o), d.focus({ preventScroll: !0 }), n?.placeCursorAtEnd && (d instanceof HTMLInputElement || d instanceof HTMLTextAreaElement)) {
4009
+ const g = d.value.length;
4010
+ d.setSelectionRange(g, g);
3208
4011
  }
3209
- this.inputEl = u, this.floatingInputWrapper = o;
4012
+ this.inputEl = d, this.floatingInputWrapper = o;
3210
4013
  }
3211
4014
  handleKey(t, e) {
3212
4015
  if (!this.activeCell || !this.inputEl) return;
@@ -3214,9 +4017,9 @@ class Se {
3214
4017
  if (t.isComposing || this.composing || i - this.lastCompositionEnd < 24) return;
3215
4018
  const { rowId: n, colKey: s } = this.activeCell;
3216
4019
  if (s === null) return;
3217
- const o = this.inputEl.tagName.toLowerCase() === "textarea", r = t.key === "Enter" && t.altKey, a = (l, h) => {
3218
- const u = this.readActiveValue();
3219
- this.commitEdit(n, s, u), this.onMove(n), this.teardownInput(!1), this.moveActiveCell(l, h);
4020
+ const o = this.inputEl.tagName.toLowerCase() === "textarea", r = t.key === "Enter" && t.altKey, a = (c, u) => {
4021
+ const d = this.readActiveValue();
4022
+ this.commitEdit(n, s, d), this.onMove(n), this.teardownInput(!1), this.moveActiveCell(c, u);
3220
4023
  };
3221
4024
  if (t.key === "Tab") {
3222
4025
  t.preventDefault(), a(0, t.shiftKey ? -1 : 1);
@@ -3230,8 +4033,8 @@ class Se {
3230
4033
  }
3231
4034
  if (t.key === "Escape") {
3232
4035
  if (t.preventDefault(), this.cancelEdit(e), this.onMove(), this.activeCell && this.activeCell.colKey !== null) {
3233
- const l = this.dataModel.getCell(this.activeCell.rowId, this.activeCell.colKey), h = this.cellToClipboardString(l);
3234
- this.focusSelectionInput(h);
4036
+ const c = this.dataModel.getCell(this.activeCell.rowId, this.activeCell.colKey), u = this.cellToClipboardString(c);
4037
+ this.focusSelectionInput(u);
3235
4038
  }
3236
4039
  } else t.key === "Backspace" && this.inputEl.value === "" && (t.preventDefault(), this.commitEdit(n, s, ""), this.onMove(n), this.teardownInput(!1), this.moveActiveCell(0, 0));
3237
4040
  }
@@ -3291,16 +4094,16 @@ class Se {
3291
4094
  _(this.inputEl), _(this.floatingInputWrapper), this.activeHost && this.activeHostOriginalText !== null && (this.activeHost.textContent = this.activeHostOriginalText), this.inputEl = null, this.floatingInputWrapper = null, this.activeHost = null, this.activeHostOriginalText = null, t && (this.activeCell = null, this.onActiveChange(null, null));
3292
4095
  }
3293
4096
  }
3294
- const Ie = (c) => c;
3295
- class xe {
4097
+ const Li = (l) => l;
4098
+ class Hi {
3296
4099
  constructor(t) {
3297
- this.shell = null, this.viewportEl = null, this.viewportResizeObserver = null, this.selectionManager = null, this.resizeHandler = null, this.scrollHandler = null, this.viewportState = null, this.rafId = null, this.contextMenu = null, this.contextMenuRowId = null, this.handleGlobalPointer = null, this.toast = null, this.toastTimer = null, this.findReplace = null, this.findReplaceSidebar = null, this.findReplaceSidebarUnsub = null, this.findReplaceEnabled = !0, this.findReplaceUiEnabled = !0, this.findReplaceEnableSearch = !1, this.mounted = !1, this.filterSortSidebar = null, this.filterSortSidebarUnsub = null, this.filterSortKeydown = null, this.filterSortClickCapture = null, this.filterSortOpenEvent = null, this.filterSortActiveColumnKey = null, this.filterSortDraft = null, this.tableStateListeners = /* @__PURE__ */ new Set(), this.selectionListeners = /* @__PURE__ */ new Set(), this.lastTableState = null, this.lastSelectionSnapshot = null, this.selectionRanges = [], this.activeCell = null, this.activeErrors = [], this.rowStateListeners = /* @__PURE__ */ new Set(), this.lastRowStates = /* @__PURE__ */ new Map(), this.root = t.root, this.root.classList.add("extable-root"), this.renderMode = t.options?.renderMode ?? "auto", this.editMode = t.options?.editMode ?? "direct", this.lockMode = t.options?.lockMode ?? "none", this.loadingEnabled = t.options?.loading?.enabled ?? !0, this.findReplaceEnabled = t.options?.findReplace?.enabled ?? !0, this.findReplaceUiEnabled = t.options?.findReplace?.sidebar ?? t.options?.findReplace?.dialog ?? !0, this.findReplaceEnableSearch = t.options?.findReplace?.enableSearch ?? !0, this.server = t.options?.server, this.user = t.options?.user;
4100
+ this.shell = null, this.viewportEl = null, this.viewportResizeObserver = null, this.selectionManager = null, this.resizeHandler = null, this.scrollHandler = null, this.viewportState = null, this.rafId = null, this.contextMenu = null, this.contextMenuRowId = null, this.handleGlobalPointer = null, this.toast = null, this.toastTimer = null, this.findReplace = null, this.findReplaceSidebar = null, this.findReplaceSidebarUnsub = null, this.findReplaceEnabled = !0, this.findReplaceUiEnabled = !0, this.findReplaceEnableSearch = !1, this.mounted = !1, this.filterSortSidebar = null, this.filterSortSidebarUnsub = null, this.filterSortKeydown = null, this.filterSortClickCapture = null, this.filterSortOpenEvent = null, this.filterSortActiveColumnKey = null, this.filterSortDraft = null, this.tableStateListeners = /* @__PURE__ */ new Set(), this.selectionListeners = /* @__PURE__ */ new Set(), this.lastTableState = null, this.lastSelectionSnapshot = null, this.selectionRanges = [], this.activeCell = null, this.activeErrors = [], this.rowStateListeners = /* @__PURE__ */ new Set(), this.lastRowStates = /* @__PURE__ */ new Map(), this.root = t.root, this.root.classList.add("extable-root"), this.renderMode = t.options?.renderMode ?? "auto", this.editMode = t.options?.editMode ?? "direct", this.lockMode = t.options?.lockMode ?? "none", this.loadingEnabled = t.options?.loading?.enabled ?? !0, this.findReplaceEnabled = t.options?.findReplace?.enabled ?? !0, this.findReplaceUiEnabled = t.options?.findReplace?.sidebar ?? t.options?.findReplace?.dialog ?? !0, this.findReplaceEnableSearch = t.options?.findReplace?.enableSearch ?? !0, this.server = t.options?.server, this.user = t.options?.user, this.sequenceLangs = t.options?.langs;
3298
4101
  const e = t.defaultData ?? null, i = e ?? [];
3299
- this.dataLoaded = e != null, this.dataModel = new ne(
4102
+ this.dataLoaded = e != null, this.dataModel = new ue(
3300
4103
  i,
3301
4104
  t.schema,
3302
4105
  t.defaultView
3303
- ), this.commandQueue = new Gt(), this.lockManager = new ae(this.lockMode, this.server, this.user), this.renderer = this.chooseRenderer(this.renderMode), this.applyRootDecor(t.options), this.applyReadonlyClass(), this.loadInitial();
4106
+ ), this.commandQueue = new oe(), this.lockManager = new ye(this.lockMode, this.server, this.user), this.renderer = this.chooseRenderer(this.renderMode), this.applyRootDecor(t.options), this.applyReadonlyClass(), this.loadInitial();
3304
4107
  }
3305
4108
  isCellReadonly(t, e) {
3306
4109
  return this.editMode === "readonly" || this.dataModel.isReadonly(t, e);
@@ -3336,7 +4139,7 @@ class xe {
3336
4139
  this.mount();
3337
4140
  }
3338
4141
  applyRootDecor(t) {
3339
- const e = Ct(t?.defaultClass);
4142
+ const e = Et(t?.defaultClass);
3340
4143
  if (e?.length && this.root.classList.add(...e), t?.defaultStyle)
3341
4144
  for (const [i, n] of Object.entries(t.defaultStyle))
3342
4145
  this.root.style[i] = n ?? "";
@@ -3347,11 +4150,11 @@ class xe {
3347
4150
  chooseRenderer(t) {
3348
4151
  if (t === "auto") {
3349
4152
  const e = typeof navigator < "u" ? navigator.userAgent : "";
3350
- return /bot|crawl|spider/i.test(e) || typeof navigator < "u" && "userAgentData" in navigator && navigator.userAgentData?.brands?.some(
4153
+ return /bot|crawl|spider|playwright|puppeteer|selenium|phantomjs/i.test(e) || typeof navigator < "u" && "userAgentData" in navigator && navigator.userAgentData?.brands?.some(
3351
4154
  (n) => /bot/i.test(n.brand ?? "")
3352
- ) ? new nt(this.dataModel) : new rt(this.dataModel, () => this.editMode);
4155
+ ) ? new ht(this.dataModel) : new gt(this.dataModel, () => this.editMode);
3353
4156
  }
3354
- return t === "html" ? new nt(this.dataModel) : new rt(this.dataModel, () => this.editMode);
4157
+ return t === "html" ? new ht(this.dataModel) : new gt(this.dataModel, () => this.editMode);
3355
4158
  }
3356
4159
  ensureShell() {
3357
4160
  if (this.shell && this.viewportEl && this.shell.parentElement === this.root) return;
@@ -3376,7 +4179,7 @@ class xe {
3376
4179
  this.root.dataset.extable = "loading", this.bindViewport(), this.ensureFindReplace(), this.ensureFilterSort(), this.emitTableState(), this.emitSelection("data");
3377
4180
  return;
3378
4181
  }
3379
- this.selectionManager = new Se(
4182
+ this.selectionManager = new Ai(
3380
4183
  e,
3381
4184
  this.editMode,
3382
4185
  (i, n) => this.handleEdit(i, n),
@@ -3388,6 +4191,7 @@ class xe {
3388
4191
  },
3389
4192
  (i) => this.renderer.hitTest(i),
3390
4193
  this.dataModel,
4194
+ this.sequenceLangs,
3391
4195
  (i, n) => this.isCellReadonly(i, n),
3392
4196
  (i, n) => {
3393
4197
  const s = i && n !== null ? { rowId: i, colKey: n } : null;
@@ -3406,7 +4210,7 @@ class xe {
3406
4210
  }
3407
4211
  // editMode/lockMode are configured only at construction time for consistency.
3408
4212
  setRootClass(t) {
3409
- this.root.className = "", this.root.classList.add(...Ct(t) ?? []);
4213
+ this.root.className = "", this.root.classList.add(...Et(t) ?? []);
3410
4214
  }
3411
4215
  setRootStyle(t) {
3412
4216
  for (const [e, i] of Object.entries(t))
@@ -3528,7 +4332,7 @@ class xe {
3528
4332
  const a = r;
3529
4333
  if (a.kind === "enum" && typeof a.value == "string") return a.value;
3530
4334
  if (a.kind === "tags" && Array.isArray(a.values))
3531
- return a.values.filter((h) => typeof h == "string").join(", ");
4335
+ return a.values.filter((u) => typeof u == "string").join(", ");
3532
4336
  }
3533
4337
  return String(r);
3534
4338
  }
@@ -3728,11 +4532,11 @@ class xe {
3728
4532
  if (this.ensureContextMenu(), !this.contextMenu || !this.contextMenu.isConnected && (this.contextMenu = null, this.ensureContextMenu(), !this.contextMenu))
3729
4533
  return;
3730
4534
  this.contextMenuRowId = t;
3731
- for (const l of Array.from(
4535
+ for (const c of Array.from(
3732
4536
  this.contextMenu.querySelectorAll("button[data-action]")
3733
4537
  )) {
3734
- const h = l.dataset.action;
3735
- h === "undo" ? l.disabled = !this.commandQueue.canUndo() : h === "redo" && (l.disabled = !this.commandQueue.canRedo());
4538
+ const u = c.dataset.action;
4539
+ u === "undo" ? c.disabled = !this.commandQueue.canUndo() : u === "redo" && (c.disabled = !this.commandQueue.canRedo());
3736
4540
  }
3737
4541
  const n = window.innerWidth, s = window.innerHeight, o = { width: 220, height: 160 };
3738
4542
  let r = e, a = i;
@@ -3838,25 +4642,25 @@ class xe {
3838
4642
  }
3839
4643
  // Public API: table-level state callbacks
3840
4644
  getTableState() {
3841
- const t = this.renderer instanceof nt ? "html" : "canvas", e = this.commandQueue.listApplied(), i = this.editMode === "commit" ? e : [], n = i.length, s = (() => {
3842
- const l = /* @__PURE__ */ new Set();
3843
- for (const h of i)
3844
- h.kind === "edit" && (!h.rowId || h.colKey === void 0 || l.add(`${h.rowId}::${String(h.colKey)}`));
3845
- return l.size;
3846
- })(), o = this.dataModel.getValidationErrors().map((l) => ({
4645
+ const t = this.renderer instanceof ht ? "html" : "canvas", e = this.commandQueue.listApplied(), i = this.editMode === "commit" ? e : [], n = i.length, s = (() => {
4646
+ const c = /* @__PURE__ */ new Set();
4647
+ for (const u of i)
4648
+ u.kind === "edit" && (!u.rowId || u.colKey === void 0 || c.add(`${u.rowId}::${String(u.colKey)}`));
4649
+ return c.size;
4650
+ })(), o = this.dataModel.getValidationErrors().map((c) => ({
3847
4651
  scope: "validation",
3848
- message: l.message,
3849
- target: { rowId: l.rowId, colKey: l.colKey }
3850
- })), r = this.dataModel.getDiagnostics().map((l) => l.diag ? {
3851
- scope: l.diag.source,
3852
- message: l.diag.message,
3853
- target: { rowId: l.rowId, colKey: l.colKey }
4652
+ message: c.message,
4653
+ target: { rowId: c.rowId, colKey: c.colKey }
4654
+ })), r = this.dataModel.getDiagnostics().map((c) => c.diag ? {
4655
+ scope: c.diag.source,
4656
+ message: c.diag.message,
4657
+ target: { rowId: c.rowId, colKey: c.colKey }
3854
4658
  } : null).filter(Boolean);
3855
- r.sort((l, h) => {
3856
- const u = l.target?.rowId ? this.dataModel.getRowIndex(l.target.rowId) : -1, f = h.target?.rowId ? this.dataModel.getRowIndex(h.target.rowId) : -1;
3857
- if (u !== f) return u - f;
3858
- const p = l.target?.colKey !== void 0 ? this.dataModel.getColumnIndex(l.target.colKey) : -1, d = h.target?.colKey !== void 0 ? this.dataModel.getColumnIndex(h.target.colKey) : -1;
3859
- return p !== d ? p - d : l.scope !== h.scope ? l.scope < h.scope ? -1 : 1 : l.message < h.message ? -1 : l.message > h.message ? 1 : 0;
4659
+ r.sort((c, u) => {
4660
+ const d = c.target?.rowId ? this.dataModel.getRowIndex(c.target.rowId) : -1, f = u.target?.rowId ? this.dataModel.getRowIndex(u.target.rowId) : -1;
4661
+ if (d !== f) return d - f;
4662
+ const g = c.target?.colKey !== void 0 ? this.dataModel.getColumnIndex(c.target.colKey) : -1, p = u.target?.colKey !== void 0 ? this.dataModel.getColumnIndex(u.target.colKey) : -1;
4663
+ return g !== p ? g - p : c.scope !== u.scope ? c.scope < u.scope ? -1 : 1 : c.message < u.message ? -1 : c.message > u.message ? 1 : 0;
3860
4664
  });
3861
4665
  const a = [
3862
4666
  ...o,
@@ -3882,8 +4686,8 @@ class xe {
3882
4686
  for (let s = 0; s < t.activeErrors.length; s += 1) {
3883
4687
  const o = e.activeErrors[s], r = t.activeErrors[s];
3884
4688
  if (!o || !r || o.scope !== r.scope || o.message !== r.message) return !1;
3885
- const a = o.target, l = r.target;
3886
- if (!(!a && !l) && (!a || !l || (a.rowId ?? null) !== (l.rowId ?? null) || String(a.colKey ?? "") !== String(l.colKey ?? "")))
4689
+ const a = o.target, c = r.target;
4690
+ if (!(!a && !c) && (!a || !c || (a.rowId ?? null) !== (c.rowId ?? null) || String(a.colKey ?? "") !== String(c.colKey ?? "")))
3887
4691
  return !1;
3888
4692
  }
3889
4693
  return !0;
@@ -3895,29 +4699,29 @@ class xe {
3895
4699
  }
3896
4700
  // Public API: selection callbacks
3897
4701
  getSelectionSnapshot() {
3898
- const t = this.selectionRanges, e = this.dataModel.getSchema(), i = this.activeCell, n = i?.rowId ?? null, s = i?.colKey ?? null, o = n ? this.dataModel.getRowIndex(n) : null, r = s !== null ? e.columns.findIndex((y) => String(y.key) === String(s)) : null, a = r !== null && r >= 0 ? e.columns[r] : null, l = n && a ? this.dataModel.resolveCellValue(n, a) : null, h = n && a ? this.dataModel.resolveConditionalStyle(n, a) : null, u = l?.textOverride ?? (h?.forceErrorText ? "#ERROR" : void 0), f = l ? l.value : null, p = (() => {
3899
- if (u) return u;
4702
+ const t = this.selectionRanges, e = this.dataModel.getSchema(), i = this.activeCell, n = i?.rowId ?? null, s = i?.colKey ?? null, o = n ? this.dataModel.getRowIndex(n) : null, r = s !== null ? e.columns.findIndex((y) => String(y.key) === String(s)) : null, a = r !== null && r >= 0 ? e.columns[r] : null, c = n && a ? this.dataModel.resolveCellValue(n, a) : null, u = n && a ? this.dataModel.resolveConditionalStyle(n, a) : null, d = c?.textOverride ?? (u?.forceErrorText ? "#ERROR" : void 0), f = c ? c.value : null, g = (() => {
4703
+ if (d) return d;
3900
4704
  const y = f;
3901
4705
  if (y == null) return "";
3902
4706
  if (y instanceof Date) return y.toISOString();
3903
4707
  if (typeof y == "string") return y;
3904
4708
  if (typeof y == "number" || typeof y == "boolean") return String(y);
3905
4709
  if (typeof y == "object") {
3906
- const w = y, S = w.kind;
3907
- if (S === "enum" && typeof w.value == "string") return w.value;
3908
- if (S === "tags" && Array.isArray(w.values))
3909
- return w.values.filter((b) => typeof b == "string").join(", ");
4710
+ const w = y, C = w.kind;
4711
+ if (C === "enum" && typeof w.value == "string") return w.value;
4712
+ if (C === "tags" && Array.isArray(w.values))
4713
+ return w.values.filter((v) => typeof v == "string").join(", ");
3910
4714
  }
3911
4715
  return String(y);
3912
- })(), d = a?.type ?? null, m = n && s !== null ? this.dataModel.getCellDiagnostic(n, s) : null, g = (() => {
4716
+ })(), p = a?.type ?? null, h = n && s !== null ? this.dataModel.getCellDiagnostic(n, s) : null, m = (() => {
3913
4717
  if (!n || !a)
3914
4718
  return { columnStyle: {}, cellStyle: {}, resolved: {} };
3915
- const { columnStyle: y, cellStyle: w, resolved: S } = me(
4719
+ const { columnStyle: y, cellStyle: w, resolved: C } = Ri(
3916
4720
  this.dataModel,
3917
4721
  n,
3918
4722
  a
3919
4723
  );
3920
- return { columnStyle: y, cellStyle: w, resolved: S };
4724
+ return { columnStyle: y, cellStyle: w, resolved: C };
3921
4725
  })();
3922
4726
  return {
3923
4727
  ranges: [...t],
@@ -3926,10 +4730,10 @@ class xe {
3926
4730
  activeColumnIndex: r !== null && r >= 0 ? r : null,
3927
4731
  activeColumnKey: s,
3928
4732
  activeValueRaw: f,
3929
- activeValueDisplay: p,
3930
- activeValueType: d,
3931
- diagnostic: m,
3932
- styles: g
4733
+ activeValueDisplay: g,
4734
+ activeValueType: p,
4735
+ diagnostic: h,
4736
+ styles: m
3933
4737
  };
3934
4738
  }
3935
4739
  subscribeSelection(t) {
@@ -3978,7 +4782,7 @@ class xe {
3978
4782
  }
3979
4783
  // Public API: value updates
3980
4784
  setCellValue(t, e, i) {
3981
- const n = typeof t == "string" ? t : this.dataModel.listRows()[t]?.id, s = n ? se(this.dataModel, { rowId: n, colKey: e }) : null;
4785
+ const n = typeof t == "string" ? t : this.dataModel.listRows()[t]?.id, s = n ? fe(this.dataModel, { rowId: n, colKey: e }) : null;
3982
4786
  if (!s || this.isCellReadonly(s.rowId, s.colKey)) return;
3983
4787
  const o = this.dataModel.getCell(s.rowId, s.colKey), r = typeof i == "function" ? i(o) : i;
3984
4788
  this.handleEdit(
@@ -3990,18 +4794,18 @@ class xe {
3990
4794
  const e = this.dataModel.getSchema(), i = this.dataModel.listRows(), n = /* @__PURE__ */ new Set();
3991
4795
  for (const s of this.selectionRanges) {
3992
4796
  if (s.kind !== "cells") continue;
3993
- const o = Math.min(s.startRow, s.endRow), r = Math.max(s.startRow, s.endRow), a = Math.min(s.startCol, s.endCol), l = Math.max(s.startCol, s.endCol);
3994
- for (let h = o; h <= r; h += 1) {
3995
- const u = i[h];
3996
- if (u)
3997
- for (let f = a; f <= l; f += 1) {
3998
- const p = e.columns[f];
3999
- if (!p) continue;
4000
- const d = `${u.id}::${String(p.key)}`;
4001
- if (n.has(d) || (n.add(d), this.isCellReadonly(u.id, p.key))) continue;
4002
- const m = this.dataModel.getCell(u.id, p.key), g = typeof t == "function" ? t(m) : t;
4797
+ const o = Math.min(s.startRow, s.endRow), r = Math.max(s.startRow, s.endRow), a = Math.min(s.startCol, s.endCol), c = Math.max(s.startCol, s.endCol);
4798
+ for (let u = o; u <= r; u += 1) {
4799
+ const d = i[u];
4800
+ if (d)
4801
+ for (let f = a; f <= c; f += 1) {
4802
+ const g = e.columns[f];
4803
+ if (!g) continue;
4804
+ const p = `${d.id}::${String(g.key)}`;
4805
+ if (n.has(p) || (n.add(p), this.isCellReadonly(d.id, g.key))) continue;
4806
+ const h = this.dataModel.getCell(d.id, g.key), m = typeof t == "function" ? t(h) : t;
4003
4807
  this.handleEdit(
4004
- { kind: "edit", rowId: u.id, colKey: p.key, next: g },
4808
+ { kind: "edit", rowId: d.id, colKey: g.key, next: m },
4005
4809
  this.editMode === "direct"
4006
4810
  );
4007
4811
  }
@@ -4016,7 +4820,7 @@ class xe {
4016
4820
  this.hideSearchPanel();
4017
4821
  }
4018
4822
  ensureFindReplace() {
4019
- this.findReplaceEnabled && (this.findReplace || (this.findReplace = new le(
4823
+ this.findReplaceEnabled && (this.findReplace || (this.findReplace = new me(
4020
4824
  this.dataModel,
4021
4825
  (t, e) => this.selectionManager?.navigateToCell(t, e),
4022
4826
  (t, e, i) => this.handleEdit({ kind: "edit", rowId: t, colKey: e, next: i }, this.editMode === "direct"),
@@ -4076,12 +4880,12 @@ class xe {
4076
4880
  'input[data-extable-fr="replace-toggle"]'
4077
4881
  ), o = e.querySelector(
4078
4882
  '[data-extable-fr="replace-toggle-row"]'
4079
- ), r = e.querySelector('input[data-extable-fr="case"]'), a = e.querySelector('input[data-extable-fr="regex"]'), l = e.querySelector('button[data-extable-fr="prev"]'), h = e.querySelector('button[data-extable-fr="next"]'), u = e.querySelector(
4883
+ ), r = e.querySelector('input[data-extable-fr="case"]'), a = e.querySelector('input[data-extable-fr="regex"]'), c = e.querySelector('button[data-extable-fr="prev"]'), u = e.querySelector('button[data-extable-fr="next"]'), d = e.querySelector(
4080
4884
  'button[data-extable-fr="replace-current"]'
4081
4885
  ), f = e.querySelector(
4082
4886
  'button[data-extable-fr="replace-all"]'
4083
- ), p = e.querySelector('button[data-extable-fr="close"]'), d = e.querySelector('[data-extable-fr="results-tbody"]');
4084
- if (!i || !n || !s || !o || !r || !a || !l || !h || !u || !f || !p || !d) {
4887
+ ), g = e.querySelector('button[data-extable-fr="close"]'), p = e.querySelector('[data-extable-fr="results-tbody"]');
4888
+ if (!i || !n || !s || !o || !r || !a || !c || !u || !d || !f || !g || !p) {
4085
4889
  _(e), this.findReplaceSidebar = null;
4086
4890
  return;
4087
4891
  }
@@ -4096,30 +4900,30 @@ class xe {
4096
4900
  s.checked = !1, this.findReplace?.setMode("find"), e.dataset.extableFrMode = "find";
4097
4901
  return;
4098
4902
  }
4099
- const g = s.checked ? "replace" : "find";
4100
- this.findReplace?.setMode(g), e.dataset.extableFrMode = g;
4101
- }), this.updateFindReplaceReadonlyUI(), l.addEventListener("click", () => this.findReplace?.prev()), h.addEventListener("click", () => this.findReplace?.next()), u.addEventListener("click", () => this.findReplace?.replaceCurrent()), f.addEventListener("click", () => this.findReplace?.replaceAll()), p.addEventListener("click", () => this.hideSearchPanel());
4102
- const m = (g, y = 140) => g.length > y ? `${g.slice(0, y - 1)}…` : g;
4103
- d.addEventListener("click", (g) => {
4104
- const y = g.target?.closest("tr[data-index]"), w = y ? Number(y.dataset.index) : -1;
4903
+ const m = s.checked ? "replace" : "find";
4904
+ this.findReplace?.setMode(m), e.dataset.extableFrMode = m;
4905
+ }), this.updateFindReplaceReadonlyUI(), c.addEventListener("click", () => this.findReplace?.prev()), u.addEventListener("click", () => this.findReplace?.next()), d.addEventListener("click", () => this.findReplace?.replaceCurrent()), f.addEventListener("click", () => this.findReplace?.replaceAll()), g.addEventListener("click", () => this.hideSearchPanel());
4906
+ const h = (m, y = 140) => m.length > y ? `${m.slice(0, y - 1)}…` : m;
4907
+ p.addEventListener("click", (m) => {
4908
+ const y = m.target?.closest("tr[data-index]"), w = y ? Number(y.dataset.index) : -1;
4105
4909
  Number.isFinite(w) && w >= 0 && this.findReplace?.activateIndex(w);
4106
- }), d.addEventListener("keydown", (g) => {
4107
- if (g.key !== "Enter") return;
4108
- const y = g.target?.closest("tr[data-index]"), w = y ? Number(y.dataset.index) : -1;
4910
+ }), p.addEventListener("keydown", (m) => {
4911
+ if (m.key !== "Enter") return;
4912
+ const y = m.target?.closest("tr[data-index]"), w = y ? Number(y.dataset.index) : -1;
4109
4913
  Number.isFinite(w) && w >= 0 && this.findReplace?.activateIndex(w);
4110
- }), this.updateFindReplaceReadonlyUI(), this.findReplaceSidebarUnsub = this.findReplace?.subscribe((g) => {
4111
- const y = e.querySelector('[data-extable-fr="replace-row"]'), w = e.querySelector('[data-extable-fr="status"]'), S = e.querySelector('[data-extable-fr="error"]');
4112
- if (!(!y || !w || !S)) {
4113
- i.value = g.query, n.value = g.replace, r.checked = g.options.caseInsensitive, a.checked = g.options.regex, s.checked = g.mode === "replace", y.style.display = g.mode === "replace" ? "block" : "none", u.style.display = g.mode === "replace" ? "inline-block" : "none", f.style.display = g.mode === "replace" ? "inline-block" : "none", w.textContent = `${g.matches.length} matches`, S.textContent = g.error ?? "", l.disabled = g.matches.length === 0, h.disabled = g.matches.length === 0, u.disabled = g.matches.length === 0 || g.activeIndex < 0, f.disabled = g.matches.length === 0, d.innerHTML = "";
4114
- for (let b = 0; b < g.matches.length; b += 1) {
4115
- const C = g.matches[b];
4116
- if (!C) continue;
4117
- const v = document.createElement("tr");
4118
- v.dataset.index = String(b), v.tabIndex = 0, v.className = "extable-search-result-row", b === g.activeIndex && (v.dataset.active = "1");
4119
- const R = document.createElement("td");
4120
- R.textContent = `R${C.rowIndex + 1}C${C.colIndex + 1}`;
4121
- const I = document.createElement("td"), x = m(C.text);
4122
- I.textContent = x, I.title = C.text, v.appendChild(R), v.appendChild(I), d.appendChild(v);
4914
+ }), this.updateFindReplaceReadonlyUI(), this.findReplaceSidebarUnsub = this.findReplace?.subscribe((m) => {
4915
+ const y = e.querySelector('[data-extable-fr="replace-row"]'), w = e.querySelector('[data-extable-fr="status"]'), C = e.querySelector('[data-extable-fr="error"]');
4916
+ if (!(!y || !w || !C)) {
4917
+ i.value = m.query, n.value = m.replace, r.checked = m.options.caseInsensitive, a.checked = m.options.regex, s.checked = m.mode === "replace", y.style.display = m.mode === "replace" ? "block" : "none", d.style.display = m.mode === "replace" ? "inline-block" : "none", f.style.display = m.mode === "replace" ? "inline-block" : "none", w.textContent = `${m.matches.length} matches`, C.textContent = m.error ?? "", c.disabled = m.matches.length === 0, u.disabled = m.matches.length === 0, d.disabled = m.matches.length === 0 || m.activeIndex < 0, f.disabled = m.matches.length === 0, p.innerHTML = "";
4918
+ for (let v = 0; v < m.matches.length; v += 1) {
4919
+ const b = m.matches[v];
4920
+ if (!b) continue;
4921
+ const S = document.createElement("tr");
4922
+ S.dataset.index = String(v), S.tabIndex = 0, S.className = "extable-search-result-row", v === m.activeIndex && (S.dataset.active = "1");
4923
+ const x = document.createElement("td");
4924
+ x.textContent = `R${b.rowIndex + 1}C${b.colIndex + 1}`;
4925
+ const R = document.createElement("td"), E = h(b.text);
4926
+ R.textContent = E, R.title = b.text, S.appendChild(x), S.appendChild(R), p.appendChild(S);
4123
4927
  }
4124
4928
  }
4125
4929
  }) ?? null;
@@ -4210,16 +5014,16 @@ class xe {
4210
5014
  `, t.appendChild(e), this.filterSortSidebar = e;
4211
5015
  const i = e.querySelector('button[data-extable-fs="close"]'), n = e.querySelector('input[data-extable-fs="col-errors"]'), s = e.querySelector(
4212
5016
  'input[data-extable-fs="col-warnings"]'
4213
- ), o = e.querySelector('input[data-extable-fs="search"]'), r = e.querySelector('[data-extable-fs="values"]'), a = e.querySelector('button[data-extable-fs="select-all"]'), l = e.querySelector('button[data-extable-fs="select-none"]'), h = e.querySelector(
5017
+ ), o = e.querySelector('input[data-extable-fs="search"]'), r = e.querySelector('[data-extable-fs="values"]'), a = e.querySelector('button[data-extable-fs="select-all"]'), c = e.querySelector('button[data-extable-fs="select-none"]'), u = e.querySelector(
4214
5018
  'button[data-extable-fs="apply-filter"]'
4215
- ), u = e.querySelector(
5019
+ ), d = e.querySelector(
4216
5020
  'button[data-extable-fs="clear-filter"]'
4217
- ), f = e.querySelector('button[data-extable-fs="sort-asc"]'), p = e.querySelector(
5021
+ ), f = e.querySelector('button[data-extable-fs="sort-asc"]'), g = e.querySelector(
4218
5022
  'button[data-extable-fs="sort-desc"]'
4219
- ), d = e.querySelector(
5023
+ ), p = e.querySelector(
4220
5024
  'button[data-extable-fs="clear-sort"]'
4221
5025
  );
4222
- if (!i || !n || !s || !o || !r || !a || !l || !h || !u || !f || !p || !d) {
5026
+ if (!i || !n || !s || !o || !r || !a || !c || !u || !d || !f || !g || !p) {
4223
5027
  _(e), this.filterSortSidebar = null;
4224
5028
  return;
4225
5029
  }
@@ -4229,18 +5033,18 @@ class xe {
4229
5033
  this.filterSortDraft && (this.filterSortDraft.diagWarnings = s.checked);
4230
5034
  }), o.addEventListener("input", () => {
4231
5035
  this.filterSortDraft && (this.filterSortDraft.search = o.value, this.renderFilterSortValues());
4232
- }), r.addEventListener("change", (m) => {
4233
- const g = m.target?.closest(
5036
+ }), r.addEventListener("change", (h) => {
5037
+ const m = h.target?.closest(
4234
5038
  'input[type="checkbox"][data-fs-val]'
4235
5039
  );
4236
- if (!g || !this.filterSortDraft) return;
4237
- const y = g.dataset.fsVal ?? "";
4238
- y && (y === "__blanks__" ? this.filterSortDraft.includeBlanks = g.checked : g.checked ? this.filterSortDraft.selected.add(y) : this.filterSortDraft.selected.delete(y));
5040
+ if (!m || !this.filterSortDraft) return;
5041
+ const y = m.dataset.fsVal ?? "";
5042
+ y && (y === "__blanks__" ? this.filterSortDraft.includeBlanks = m.checked : m.checked ? this.filterSortDraft.selected.add(y) : this.filterSortDraft.selected.delete(y));
4239
5043
  }), a.addEventListener("click", () => {
4240
- this.filterSortDraft && (this.filterSortDraft.selected = new Set(this.filterSortDraft.values.map((m) => m.key)), this.filterSortDraft.includeBlanks = this.filterSortDraft.hasBlanks, this.renderFilterSortValues());
4241
- }), l.addEventListener("click", () => {
5044
+ this.filterSortDraft && (this.filterSortDraft.selected = new Set(this.filterSortDraft.values.map((h) => h.key)), this.filterSortDraft.includeBlanks = this.filterSortDraft.hasBlanks, this.renderFilterSortValues());
5045
+ }), c.addEventListener("click", () => {
4242
5046
  this.filterSortDraft && (this.filterSortDraft.selected = /* @__PURE__ */ new Set(), this.filterSortDraft.includeBlanks = !1, this.renderFilterSortValues());
4243
- }), h.addEventListener("click", () => this.applyFilterSortDraft()), u.addEventListener("click", () => this.clearFilterSortForActiveColumn()), f.addEventListener("click", () => this.setSortForActiveColumn("asc")), p.addEventListener("click", () => this.setSortForActiveColumn("desc")), d.addEventListener("click", () => this.clearSort()), this.filterSortSidebarUnsub = this.dataModel.subscribe(() => {
5047
+ }), u.addEventListener("click", () => this.applyFilterSortDraft()), d.addEventListener("click", () => this.clearFilterSortForActiveColumn()), f.addEventListener("click", () => this.setSortForActiveColumn("asc")), g.addEventListener("click", () => this.setSortForActiveColumn("desc")), p.addEventListener("click", () => this.clearSort()), this.filterSortSidebarUnsub = this.dataModel.subscribe(() => {
4244
5048
  this.isFilterSortPanelVisible() && this.filterSortActiveColumnKey && (this.buildFilterSortDraft(this.filterSortActiveColumnKey), this.renderFilterSortSidebar());
4245
5049
  });
4246
5050
  }
@@ -4261,20 +5065,20 @@ class xe {
4261
5065
  }
4262
5066
  const s = this.filterSortDraft && String(this.filterSortDraft.colKey) === String(n.key) ? this.filterSortDraft.search : "", o = this.dataModel.getDistinctValuesForColumn(n.key), r = o.values.map((f) => ({ ...f, key: this.stableValueKey(f.value) })), a = (e.filters ?? []).find(
4263
5067
  (f) => f.kind === "values" && String(f.key) === String(n.key)
4264
- ), l = /* @__PURE__ */ new Set();
5068
+ ), c = /* @__PURE__ */ new Set();
4265
5069
  if (a)
4266
- for (const f of a.values ?? []) l.add(this.stableValueKey(f));
5070
+ for (const f of a.values ?? []) c.add(this.stableValueKey(f));
4267
5071
  else
4268
- for (const f of r) l.add(f.key);
4269
- const h = a ? !!a.includeBlanks : o.hasBlanks, u = e.columnDiagnostics?.[String(n.key)];
5072
+ for (const f of r) c.add(f.key);
5073
+ const u = a ? !!a.includeBlanks : o.hasBlanks, d = e.columnDiagnostics?.[String(n.key)];
4270
5074
  this.filterSortDraft = {
4271
5075
  colKey: n.key,
4272
5076
  values: r,
4273
5077
  hasBlanks: o.hasBlanks,
4274
- selected: l,
4275
- includeBlanks: h,
4276
- diagErrors: !!u?.errors,
4277
- diagWarnings: !!u?.warnings,
5078
+ selected: c,
5079
+ includeBlanks: u,
5080
+ diagErrors: !!d?.errors,
5081
+ diagWarnings: !!d?.warnings,
4278
5082
  search: s
4279
5083
  };
4280
5084
  }
@@ -4297,9 +5101,9 @@ class xe {
4297
5101
  t.textContent = "Sort/Filter", e.checked = !1, i.checked = !1, n.value = "", s && (s.dataset.active = "0"), o && (o.dataset.active = "0"), this.renderFilterSortValues();
4298
5102
  return;
4299
5103
  }
4300
- const h = this.dataModel.getSchema().columns.find((p) => String(p.key) === String(r.colKey))?.header ?? String(r.colKey);
4301
- t.textContent = `Sort/Filter: ${h}`, e.checked = r.diagErrors, i.checked = r.diagWarnings, n.value = r.search;
4302
- const f = this.dataModel.getView().sorts?.find((p) => String(p.key) === String(r.colKey));
5104
+ const u = this.dataModel.getSchema().columns.find((g) => String(g.key) === String(r.colKey))?.header ?? String(r.colKey);
5105
+ t.textContent = `Sort/Filter: ${u}`, e.checked = r.diagErrors, i.checked = r.diagWarnings, n.value = r.search;
5106
+ const f = this.dataModel.getView().sorts?.find((g) => String(g.key) === String(r.colKey));
4303
5107
  s && (s.dataset.active = f?.dir === "asc" ? "1" : "0"), o && (o.dataset.active = f?.dir === "desc" ? "1" : "0"), this.renderFilterSortValues();
4304
5108
  }
4305
5109
  renderFilterSortValues() {
@@ -4325,8 +5129,8 @@ class xe {
4325
5129
  for (const o of s.slice(0, 200)) {
4326
5130
  const r = document.createElement("label"), a = document.createElement("input");
4327
5131
  a.type = "checkbox", a.dataset.fsVal = o.key, a.checked = e.selected.has(o.key);
4328
- const l = document.createElement("span");
4329
- l.textContent = o.label, r.appendChild(a), r.appendChild(l), t.appendChild(r);
5132
+ const c = document.createElement("span");
5133
+ c.textContent = o.label, r.appendChild(a), r.appendChild(c), t.appendChild(r);
4330
5134
  }
4331
5135
  }
4332
5136
  applyFilterSortDraft() {
@@ -4420,26 +5224,26 @@ class xe {
4420
5224
  this.viewportState = i, this.rafId === null && (this.rafId = requestAnimationFrame(() => this.flushRender()));
4421
5225
  }
4422
5226
  flushRender() {
4423
- this.rafId = null, this.viewportState && (this.selectionManager?.onScroll(this.viewportState.scrollTop, this.viewportState.scrollLeft), !(this.renderer instanceof nt) && this.safeRender(this.viewportState));
5227
+ this.rafId = null, this.viewportState && (this.selectionManager?.onScroll(this.viewportState.scrollTop, this.viewportState.scrollLeft), !(this.renderer instanceof ht) && this.safeRender(this.viewportState));
4424
5228
  }
4425
5229
  }
4426
- function Ee(c, t) {
4427
- return new xe({
5230
+ function Vi(l, t) {
5231
+ return new Hi({
4428
5232
  root: document.createElement("div"),
4429
- defaultData: c.data,
4430
- defaultView: c.view,
4431
- schema: c.schema,
5233
+ defaultData: l.data,
5234
+ defaultView: l.view,
5235
+ schema: l.schema,
4432
5236
  options: t
4433
5237
  });
4434
5238
  }
4435
- function Te(c, t) {
4436
- return t.remount(c), t;
5239
+ function _i(l, t) {
5240
+ return t.remount(l), t;
4437
5241
  }
4438
5242
  export {
4439
- xe as ExtableCore,
4440
- le as FindReplaceController,
4441
- Ee as createTablePlaceholder,
4442
- Ie as defineSchema,
4443
- Te as mountTable
5243
+ Hi as ExtableCore,
5244
+ me as FindReplaceController,
5245
+ Vi as createTablePlaceholder,
5246
+ Li as defineSchema,
5247
+ _i as mountTable
4444
5248
  };
4445
5249
  //# sourceMappingURL=index.js.map