textmode.export.js 1.3.0-beta.1 → 1.3.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.
@@ -1,13 +1,16 @@
1
- var Jt = Object.defineProperty;
2
- var Xt = (i, r, t) => r in i ? Jt(i, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[r] = t;
3
- var p = (i, r, t) => Xt(i, typeof r != "symbol" ? r + "" : r, t);
1
+ var Yt = Object.defineProperty;
2
+ var Qt = (i, r, t) => r in i ? Yt(i, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[r] = t;
3
+ var p = (i, r, t) => Qt(i, typeof r != "symbol" ? r + "" : r, t);
4
4
  class xt {
5
5
  $extractFramebufferData(r) {
6
6
  return { characterPixels: r.readPixels(0), primaryColorPixels: r.readPixels(1), secondaryColorPixels: r.readPixels(2) };
7
7
  }
8
- $getCharacterIndex(r, t) {
8
+ $getEncodedCharacterValue(r, t) {
9
9
  return r[t] + (r[t + 1] << 8);
10
10
  }
11
+ $getCharacterIndex(r, t) {
12
+ return this.$getEncodedCharacterValue(r, t);
13
+ }
11
14
  $extractCellTransform(r, t) {
12
15
  const e = r[t + 2], a = r[t + 3] / 255;
13
16
  return { isInverted: !!(1 & e), flipHorizontal: !!(2 & e), flipVertical: !!(4 & e), rotation: Math.round(360 * a * 100) / 100 };
@@ -31,10 +34,23 @@ class H {
31
34
  return `textmode-export-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-")}`;
32
35
  }
33
36
  }
37
+ const wt = /* @__PURE__ */ new WeakMap();
38
+ function Kt(i) {
39
+ return Math.round(255 * i[0]) + (Math.round(255 * i[1]) << 8);
40
+ }
41
+ function yt(i, r) {
42
+ let t = wt.get(i);
43
+ if (!t) {
44
+ t = /* @__PURE__ */ new Map();
45
+ for (const e of i.characters) t.set(Kt(e.color), e);
46
+ wt.set(i, t);
47
+ }
48
+ return t.get(r);
49
+ }
34
50
  function it(i, r) {
35
51
  return { r: i[r], g: i[r + 1], b: i[r + 2], a: i[r + 3] };
36
52
  }
37
- class Yt extends xt {
53
+ class Zt extends xt {
38
54
  _calculateCellPosition(r, t, e) {
39
55
  return { x: r, y: t, cellX: r * e.cellWidth, cellY: t * e.cellHeight };
40
56
  }
@@ -42,7 +58,7 @@ class Yt extends xt {
42
58
  const e = [];
43
59
  let a = 0;
44
60
  for (let o = 0; o < t.rows; o++) for (let s = 0; s < t.cols; s++) {
45
- const d = 4 * a, l = this.$getCharacterIndex(r.characterPixels, d);
61
+ const d = 4 * a, l = this.$getEncodedCharacterValue(r.characterPixels, d);
46
62
  let h = it(r.primaryColorPixels, d), n = it(r.secondaryColorPixels, d);
47
63
  const c = this.$extractCellTransform(r.characterPixels, d);
48
64
  if (c.isInverted) {
@@ -50,12 +66,12 @@ class Yt extends xt {
50
66
  h = n, n = f;
51
67
  }
52
68
  const u = this._calculateCellPosition(s, o, t);
53
- e.push({ charIndex: l, primaryColor: h, secondaryColor: n, transform: c, position: u }), a++;
69
+ e.push({ encodedGlyphSlot: l, primaryColor: h, secondaryColor: n, transform: c, position: u }), a++;
54
70
  }
55
71
  return e;
56
72
  }
57
73
  }
58
- class Qt {
74
+ class te {
59
75
  _createGlyphPath(r, t, e, a, o) {
60
76
  const s = o / r.head.unitsPerEm;
61
77
  return { getBoundingBox: () => ({ x1: e + t.xMin * s, y1: a + -t.yMax * s, x2: e + t.xMax * s, y2: a + -t.yMin * s }), toSVG: () => this._glyphToSVGPath(t, e, a, s) };
@@ -93,21 +109,16 @@ class Qt {
93
109
  }
94
110
  return h;
95
111
  }
96
- _generateCharacterPath(r, t, e, a, o) {
97
- var d;
98
- const s = (d = t.characterMap.get(r)) == null ? void 0 : d.glyphData;
99
- return s ? this._createGlyphPath(t.font, s, e, a, o) : null;
100
- }
101
112
  $generatePositionedCharacterPath(r, t, e, a, o, s, d, l) {
102
113
  if (!l) return null;
103
- const h = d / t.font.head.unitsPerEm, n = e + (o - l.advanceWidth * h) / 2, c = a + (s + 0.7 * d) / 2, u = this._generateCharacterPath(r, t, n, c, d);
104
- return u && u.toSVG() || null;
114
+ const h = t.font, n = d / h.head.unitsPerEm, c = e + (o - l.advanceWidth * n) / 2, u = a + h.hhea.ascender * n;
115
+ return this._createGlyphPath(h, l, c, u, d).toSVG() || null;
105
116
  }
106
117
  }
107
- class Kt {
118
+ class ee {
108
119
  constructor() {
109
120
  p(this, "_pathGenerator");
110
- this._pathGenerator = new Qt();
121
+ this._pathGenerator = new te();
111
122
  }
112
123
  $generateSVGHeader(r) {
113
124
  const { width: t, height: e } = r;
@@ -132,7 +143,7 @@ class Kt {
132
143
  return e.drawMode === "stroke" ? `<rect x="${a.cellX}" y="${a.cellY}" width="${t.cellWidth}" height="${t.cellHeight}" stroke="${h}" fill="none" stroke-width="${e.strokeWidth}"/>` : `<rect x="${a.cellX}" y="${a.cellY}" width="${t.cellWidth}" height="${t.cellHeight}" fill="${h}"/>`;
133
144
  }
134
145
  _generateCharacterPath(r, t, e, a) {
135
- const o = e.characters[r.charIndex];
146
+ const o = yt(e, r.encodedGlyphSlot);
136
147
  if (!o) return "";
137
148
  const s = this._pathGenerator.$generatePositionedCharacterPath(o.character, e, r.position.cellX, r.position.cellY, t.cellWidth, t.cellHeight, e.fontSize, o.glyphData);
138
149
  if (!s) return "";
@@ -158,12 +169,12 @@ class Kt {
158
169
  return r.replace(/\s+/g, " ").replace(/> </g, "><");
159
170
  }
160
171
  }
161
- class _t {
172
+ class Ct {
162
173
  _applyDefaultOptions(r) {
163
174
  return { includeBackgroundRectangles: r.includeBackgroundRectangles ?? !0, drawMode: r.drawMode ?? "fill", strokeWidth: r.strokeWidth ?? 1, filename: r.filename };
164
175
  }
165
176
  $generateSVG(r, t = {}) {
166
- const e = new Yt(), a = new Kt(), o = e.$extractSVGCellData(e.$extractFramebufferData(r.layers.base.drawFramebuffer), r.grid), s = a.$generateSVGContent(o, r.grid, r.font, this._applyDefaultOptions(t));
177
+ const e = new Zt(), a = new ee(), o = e.$extractSVGCellData(e.$extractFramebufferData(r.layers.base.drawFramebuffer), r.grid), s = a.$generateSVGContent(o, r.grid, r.font, this._applyDefaultOptions(t));
167
178
  return a.$optimizeSVGContent(s);
168
179
  }
169
180
  $saveSVG(r, t = {}) {
@@ -171,7 +182,7 @@ class _t {
171
182
  }
172
183
  }
173
184
  const ut = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, pt = { png: ".png", jpg: ".jpg", webp: ".webp" };
174
- class wt {
185
+ class Et {
175
186
  _applyDefaultOptions(r) {
176
187
  return { format: r.format ?? "png", scale: Math.abs(r.scale ?? 1), filename: r.filename };
177
188
  }
@@ -200,7 +211,7 @@ class wt {
200
211
  await navigator.clipboard.write([o]);
201
212
  }
202
213
  }
203
- class Ct {
214
+ class kt {
204
215
  _applyDefaultOptions(r) {
205
216
  return { preserveTrailingSpaces: r.preserveTrailingSpaces ?? !1, emptyCharacter: r.emptyCharacter ?? " ", filename: r.filename };
206
217
  }
@@ -211,8 +222,8 @@ class Ct {
211
222
  for (let h = 0; h < r.grid.rows; h++) {
212
223
  let n = "";
213
224
  for (let c = 0; c < r.grid.cols; c++) {
214
- const u = 4 * d, f = e.$getCharacterIndex(o.characterPixels, u);
215
- n += ((l = r.font.characters[f]) == null ? void 0 : l.character) || t.emptyCharacter, d++;
225
+ const u = 4 * d, f = e.$getEncodedCharacterValue(o.characterPixels, u);
226
+ n += ((l = yt(r.font, f)) == null ? void 0 : l.character) || t.emptyCharacter, d++;
216
227
  }
217
228
  t.preserveTrailingSpaces || (n = n.trimEnd()), s.push(n);
218
229
  }
@@ -227,7 +238,7 @@ class Ct {
227
238
  new H().$downloadFile(o, e.filename);
228
239
  }
229
240
  }
230
- class Zt {
241
+ class re {
231
242
  constructor() {
232
243
  p(this, "_canvas");
233
244
  p(this, "_ctx");
@@ -265,9 +276,9 @@ class Zt {
265
276
  });
266
277
  }
267
278
  }
268
- var Tt = Object.defineProperty, te = (i) => Tt(i, "__esModule", { value: !0 }), ee = (i, r) => () => (r || i((r = { exports: {} }).exports, r), r.exports), re = (i, r) => {
269
- for (var t in r) Tt(i, t, { get: r[t], enumerable: !0 });
270
- }, ae = ee((i) => {
279
+ var Nt = Object.defineProperty, ae = (i) => Nt(i, "__esModule", { value: !0 }), oe = (i, r) => () => (r || i((r = { exports: {} }).exports, r), r.exports), ie = (i, r) => {
280
+ for (var t in r) Nt(i, t, { get: r[t], enumerable: !0 });
281
+ }, ne = oe((i) => {
271
282
  function r(c, u, f) {
272
283
  return 0.29889531 * c + 0.58662247 * u + 0.11448223 * f;
273
284
  }
@@ -305,9 +316,9 @@ var Tt = Object.defineProperty, te = (i) => Tt(i, "__esModule", { value: !0 }),
305
316
  function n(c, u) {
306
317
  return Math.sqrt(h(c, u));
307
318
  }
308
- te(i), re(i, { colorDifferenceRGBToYIQ: () => l, colorDifferenceRGBToYIQSquared: () => d, colorDifferenceYIQ: () => s, colorDifferenceYIQSquared: () => a, euclideanDistance: () => n, euclideanDistanceSquared: () => h });
309
- }), oe = { trailer: 59 };
310
- function Rt(i = 256) {
319
+ ae(i), ie(i, { colorDifferenceRGBToYIQ: () => l, colorDifferenceRGBToYIQSquared: () => d, colorDifferenceYIQ: () => s, colorDifferenceYIQSquared: () => a, euclideanDistance: () => n, euclideanDistanceSquared: () => h });
320
+ }), se = { trailer: 59 };
321
+ function Ut(i = 256) {
311
322
  let r = 0, t = new Uint8Array(i);
312
323
  return { get buffer() {
313
324
  return t.buffer;
@@ -329,9 +340,9 @@ function Rt(i = 256) {
329
340
  t = new Uint8Array(a), r > 0 && t.set(s.subarray(0, r), 0);
330
341
  }
331
342
  }
332
- var tt = 12, Et = 5003, ie = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535];
333
- function ne(i, r, t, e, a, o, s, d) {
334
- a = a || Rt(512), o = o || new Uint8Array(256), s = s || new Int32Array(Et), d = d || new Int32Array(Et);
343
+ var tt = 12, Bt = 5003, le = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535];
344
+ function de(i, r, t, e, a, o, s, d) {
345
+ a = a || Ut(512), o = o || new Uint8Array(256), s = s || new Int32Array(Bt), d = d || new Int32Array(Bt);
335
346
  let l = s.length, h = Math.max(2, e);
336
347
  o.fill(0), d.fill(0), L();
337
348
  let n = 0, c = 0, u = h + 1, f = u, y = !1, m = f, v = D(m), w = 1 << u - 1, x = w + 1, g = w + 2, E = 0, F = t[0], k = 0;
@@ -365,21 +376,21 @@ function ne(i, r, t, e, a, o, s, d) {
365
376
  return (1 << B) - 1;
366
377
  }
367
378
  function R(B) {
368
- for (n &= ie[c], c > 0 ? n |= B << c : n = B, c += m; c >= 8; ) A(255 & n), n >>= 8, c -= 8;
379
+ for (n &= le[c], c > 0 ? n |= B << c : n = B, c += m; c >= 8; ) A(255 & n), n >>= 8, c -= 8;
369
380
  if ((g > v || y) && (y ? (m = f, v = D(m), y = !1) : (++m, v = m == tt ? 1 << tt : D(m))), B == x) {
370
381
  for (; c > 0; ) A(255 & n), n >>= 8, c -= 8;
371
382
  S();
372
383
  }
373
384
  }
374
385
  }
375
- var se = ne;
376
- function Nt(i, r, t) {
386
+ var ce = de;
387
+ function Gt(i, r, t) {
377
388
  return i << 8 & 63488 | r << 2 & 992 | t >> 3 & 31;
378
389
  }
379
- function Ut(i, r, t, e) {
390
+ function zt(i, r, t, e) {
380
391
  return i >> 4 | 240 & r | (240 & t) << 4 | (240 & e) << 8;
381
392
  }
382
- function Gt(i, r, t) {
393
+ function Wt(i, r, t) {
383
394
  return i >> 4 << 8 | r >> 4 << 4 | t >> 4;
384
395
  }
385
396
  function et(i, r, t) {
@@ -388,7 +399,7 @@ function et(i, r, t) {
388
399
  function ot(i) {
389
400
  return i * i;
390
401
  }
391
- function kt(i, r, t) {
402
+ function St(i, r, t) {
392
403
  for (var e = 0, a = 1e100, o = i[r], s = o.cnt, d = (o.ac, o.rc), l = o.gc, h = o.bc, n = o.fw; n != 0; n = i[n].fw) {
393
404
  var c = i[n].cnt, u = s * c / (s + c);
394
405
  if (!(u >= a)) {
@@ -401,24 +412,24 @@ function kt(i, r, t) {
401
412
  function ht() {
402
413
  return { ac: 0, rc: 0, gc: 0, bc: 0, cnt: 0, nn: 0, fw: 0, bk: 0, tm: 0, mtm: 0, err: 0 };
403
414
  }
404
- function le(i, r) {
415
+ function ue(i, r) {
405
416
  let t = new Array(r === "rgb444" ? 4096 : 65536), e = i.length;
406
417
  if (r === "rgba4444") for (let a = 0; a < e; ++a) {
407
- let o = i[a], s = o >> 24 & 255, d = o >> 16 & 255, l = o >> 8 & 255, h = 255 & o, n = Ut(h, l, d, s), c = n in t ? t[n] : t[n] = ht();
418
+ let o = i[a], s = o >> 24 & 255, d = o >> 16 & 255, l = o >> 8 & 255, h = 255 & o, n = zt(h, l, d, s), c = n in t ? t[n] : t[n] = ht();
408
419
  c.rc += h, c.gc += l, c.bc += d, c.ac += s, c.cnt++;
409
420
  }
410
421
  else if (r === "rgb444") for (let a = 0; a < e; ++a) {
411
- let o = i[a], s = o >> 16 & 255, d = o >> 8 & 255, l = 255 & o, h = Gt(l, d, s), n = h in t ? t[h] : t[h] = ht();
422
+ let o = i[a], s = o >> 16 & 255, d = o >> 8 & 255, l = 255 & o, h = Wt(l, d, s), n = h in t ? t[h] : t[h] = ht();
412
423
  n.rc += l, n.gc += d, n.bc += s, n.cnt++;
413
424
  }
414
425
  else for (let a = 0; a < e; ++a) {
415
- let o = i[a], s = o >> 16 & 255, d = o >> 8 & 255, l = 255 & o, h = Nt(l, d, s), n = h in t ? t[h] : t[h] = ht();
426
+ let o = i[a], s = o >> 16 & 255, d = o >> 8 & 255, l = 255 & o, h = Gt(l, d, s), n = h in t ? t[h] : t[h] = ht();
416
427
  n.rc += l, n.gc += d, n.bc += s, n.cnt++;
417
428
  }
418
429
  return t;
419
430
  }
420
- function de(i, r, t) {
421
- let { format: e = "rgb565", clearAlpha: a = !0, clearAlphaColor: o = 0, clearAlphaThreshold: s = 0, oneBitAlpha: d = !1 } = t || {}, l = t.useSqrt !== !1, h = e === "rgba4444", n = le(i, e), c = n.length, u = c - 1, f = new Uint32Array(c + 1);
431
+ function pe(i, r, t) {
432
+ let { format: e = "rgb565", clearAlpha: a = !0, clearAlphaColor: o = 0, clearAlphaThreshold: s = 0, oneBitAlpha: d = !1 } = t || {}, l = t.useSqrt !== !1, h = e === "rgba4444", n = ue(i, e), c = n.length, u = c - 1, f = new Uint32Array(c + 1);
422
433
  for (var y = 0, m = 0; m < n.length; ++m) {
423
434
  let B = n[m];
424
435
  if (B != null) {
@@ -429,7 +440,7 @@ function de(i, r, t) {
429
440
  for (ot(r) / y < 0.022 && (l = !1), m = 0; m < y - 1; ++m) n[m].fw = m + 1, n[m + 1].bk = m, l && (n[m].cnt = Math.sqrt(n[m].cnt));
430
441
  var w, x, g;
431
442
  for (l && (n[m].cnt = Math.sqrt(n[m].cnt)), m = 0; m < y; ++m) {
432
- kt(n, m);
443
+ St(n, m);
433
444
  var E = n[m].err;
434
445
  for (x = ++f[0]; x > 1 && !(n[w = f[g = x >> 1]].err <= E); x = g) f[x] = w;
435
446
  f[x] = m;
@@ -439,7 +450,7 @@ function de(i, r, t) {
439
450
  for (var k; ; ) {
440
451
  var A = f[1];
441
452
  if ((k = n[A]).tm >= k.mtm && n[k.nn].mtm <= k.tm) break;
442
- for (k.mtm == u ? A = f[1] = f[f[0]--] : (kt(n, A), k.tm = m), E = n[A].err, x = 1; (g = x + x) <= f[0] && (g < f[0] && n[f[g]].err > n[f[g + 1]].err && g++, !(E <= n[w = f[g]].err)); x = g) f[x] = w;
453
+ for (k.mtm == u ? A = f[1] = f[f[0]--] : (St(n, A), k.tm = m), E = n[A].err, x = 1; (g = x + x) <= f[0] && (g < f[0] && n[f[g]].err > n[f[g + 1]].err && g++, !(E <= n[w = f[g]].err)); x = g) f[x] = w;
443
454
  f[x] = A;
444
455
  }
445
456
  var L = n[k.nn], V = k.cnt, S = L.cnt;
@@ -451,54 +462,54 @@ function de(i, r, t) {
451
462
  let B = et(Math.round(n[m].rc), 0, 255), N = et(Math.round(n[m].gc), 0, 255), _ = et(Math.round(n[m].bc), 0, 255), C = 255;
452
463
  h && (C = et(Math.round(n[m].ac), 0, 255), d && (C = C <= (typeof d == "number" ? d : 127) ? 0 : 255), a && C <= s && (B = N = _ = o, C = 0));
453
464
  let M = h ? [B, N, _, C] : [B, N, _];
454
- if (ce(D, M) || D.push(M), (m = n[m].fw) == 0) break;
465
+ if (he(D, M) || D.push(M), (m = n[m].fw) == 0) break;
455
466
  }
456
467
  return D;
457
468
  }
458
- function ce(i, r) {
469
+ function he(i, r) {
459
470
  for (let t = 0; t < i.length; t++) {
460
471
  let e = i[t], a = e[0] === r[0] && e[1] === r[1] && e[2] === r[2], o = !(e.length >= 4 && r.length >= 4) || e[3] === r[3];
461
472
  if (a && o) return !0;
462
473
  }
463
474
  return !1;
464
475
  }
465
- function ue(i, r, t) {
476
+ function me(i, r, t) {
466
477
  let e = (t = t || "rgb565") === "rgb444" ? 4096 : 65536, a = new Uint8Array(i.length), o = new Array(e);
467
478
  if (t === "rgba4444") for (let s = 0; s < i.length; s++) {
468
- let d, l = i[s], h = l >> 24 & 255, n = l >> 16 & 255, c = l >> 8 & 255, u = 255 & l, f = Ut(u, c, n, h);
469
- o[f] != null ? d = o[f] : (d = pe(u, c, n, h, r), o[f] = d), a[s] = d;
479
+ let d, l = i[s], h = l >> 24 & 255, n = l >> 16 & 255, c = l >> 8 & 255, u = 255 & l, f = zt(u, c, n, h);
480
+ o[f] != null ? d = o[f] : (d = fe(u, c, n, h, r), o[f] = d), a[s] = d;
470
481
  }
471
482
  else for (let s = 0; s < i.length; s++) {
472
- let d, l = i[s], h = l >> 16 & 255, n = l >> 8 & 255, c = 255 & l, u = t === "rgb444" ? Gt(c, n, h) : Nt(c, n, h);
473
- o[u] != null ? d = o[u] : (d = he(c, n, h, r), o[u] = d), a[s] = d;
483
+ let d, l = i[s], h = l >> 16 & 255, n = l >> 8 & 255, c = 255 & l, u = t === "rgb444" ? Wt(c, n, h) : Gt(c, n, h);
484
+ o[u] != null ? d = o[u] : (d = ge(c, n, h, r), o[u] = d), a[s] = d;
474
485
  }
475
486
  return a;
476
487
  }
477
- function pe(i, r, t, e, a) {
488
+ function fe(i, r, t, e, a) {
478
489
  let o = 0, s = 1e100;
479
490
  for (let d = 0; d < a.length; d++) {
480
- let l = a[d], h = l[0], n = l[1], c = l[2], u = W(l[3] - e);
481
- u > s || (u += W(h - i), !(u > s) && (u += W(n - r), !(u > s) && (u += W(c - t), !(u > s) && (s = u, o = d))));
491
+ let l = a[d], h = l[0], n = l[1], c = l[2], u = j(l[3] - e);
492
+ u > s || (u += j(h - i), !(u > s) && (u += j(n - r), !(u > s) && (u += j(c - t), !(u > s) && (s = u, o = d))));
482
493
  }
483
494
  return o;
484
495
  }
485
- function he(i, r, t, e) {
496
+ function ge(i, r, t, e) {
486
497
  let a = 0, o = 1e100;
487
498
  for (let s = 0; s < e.length; s++) {
488
- let d = e[s], l = d[0], h = d[1], n = d[2], c = W(l - i);
489
- c > o || (c += W(h - r), !(c > o) && (c += W(n - t), !(c > o) && (o = c, a = s)));
499
+ let d = e[s], l = d[0], h = d[1], n = d[2], c = j(l - i);
500
+ c > o || (c += j(h - r), !(c > o) && (c += j(n - t), !(c > o) && (o = c, a = s)));
490
501
  }
491
502
  return a;
492
503
  }
493
- function W(i) {
504
+ function j(i) {
494
505
  return i * i;
495
506
  }
496
- function me(i = {}) {
497
- let { initialCapacity: r = 4096, auto: t = !0 } = i, e = Rt(r), a = new Uint8Array(256), o = new Int32Array(5003), s = new Int32Array(5003), d = !1;
507
+ function be(i = {}) {
508
+ let { initialCapacity: r = 4096, auto: t = !0 } = i, e = Ut(r), a = new Uint8Array(256), o = new Int32Array(5003), s = new Int32Array(5003), d = !1;
498
509
  return { reset() {
499
510
  e.reset(), d = !1;
500
511
  }, finish() {
501
- e.writeByte(oe.trailer);
512
+ e.writeByte(se.trailer);
502
513
  }, bytes: () => e.bytes(), bytesView: () => e.bytesView(), get buffer() {
503
514
  return e.buffer;
504
515
  }, get stream() {
@@ -507,67 +518,67 @@ function me(i = {}) {
507
518
  let { transparent: f = !1, transparentIndex: y = 0, delay: m = 0, palette: v = null, repeat: w = 0, colorDepth: x = 8, dispose: g = -1 } = u, E = !1;
508
519
  if (t ? d || (E = !0, l(), d = !0) : E = !!u.first, n = Math.max(0, Math.floor(n)), c = Math.max(0, Math.floor(c)), E) {
509
520
  if (!v) throw new Error("First frame must include a { palette } option");
510
- ge(e, n, c, v, x), Bt(e, v), w >= 0 && be(e, w);
521
+ xe(e, n, c, v, x), It(e, v), w >= 0 && ye(e, w);
511
522
  }
512
523
  let F = Math.round(m / 10);
513
- fe(e, g, F, f, y);
524
+ ve(e, g, F, f, y);
514
525
  let k = !!v && !E;
515
- ve(e, n, c, k ? v : null), k && Bt(e, v), xe(e, h, n, c, x, a, o, s);
526
+ _e(e, n, c, k ? v : null), k && It(e, v), we(e, h, n, c, x, a, o, s);
516
527
  } };
517
528
  function l() {
518
- zt(e, "GIF89a");
529
+ jt(e, "GIF89a");
519
530
  }
520
531
  }
521
- function fe(i, r, t, e, a) {
532
+ function ve(i, r, t, e, a) {
522
533
  var o, s;
523
534
  i.writeByte(33), i.writeByte(249), i.writeByte(4), a < 0 && (a = 0, e = !1), e ? (o = 1, s = 2) : (o = 0, s = 0), r >= 0 && (s = 7 & r), s <<= 2, i.writeByte(0 | s | o), G(i, t), i.writeByte(a || 0), i.writeByte(0);
524
535
  }
525
- function ge(i, r, t, e, a = 8) {
526
- let o = 128 | a - 1 << 4 | yt(e.length) - 1;
536
+ function xe(i, r, t, e, a = 8) {
537
+ let o = 128 | a - 1 << 4 | _t(e.length) - 1;
527
538
  G(i, r), G(i, t), i.writeBytes([o, 0, 0]);
528
539
  }
529
- function be(i, r) {
530
- i.writeByte(33), i.writeByte(255), i.writeByte(11), zt(i, "NETSCAPE2.0"), i.writeByte(3), i.writeByte(1), G(i, r), i.writeByte(0);
540
+ function ye(i, r) {
541
+ i.writeByte(33), i.writeByte(255), i.writeByte(11), jt(i, "NETSCAPE2.0"), i.writeByte(3), i.writeByte(1), G(i, r), i.writeByte(0);
531
542
  }
532
- function Bt(i, r) {
533
- let t = 1 << yt(r.length);
543
+ function It(i, r) {
544
+ let t = 1 << _t(r.length);
534
545
  for (let e = 0; e < t; e++) {
535
546
  let a = [0, 0, 0];
536
547
  e < r.length && (a = r[e]), i.writeByte(a[0]), i.writeByte(a[1]), i.writeByte(a[2]);
537
548
  }
538
549
  }
539
- function ve(i, r, t, e) {
550
+ function _e(i, r, t, e) {
540
551
  if (i.writeByte(44), G(i, 0), G(i, 0), G(i, r), G(i, t), e) {
541
- let a = 0, o = 0, s = yt(e.length) - 1;
552
+ let a = 0, o = 0, s = _t(e.length) - 1;
542
553
  i.writeByte(128 | a | o | s);
543
554
  } else i.writeByte(0);
544
555
  }
545
- function xe(i, r, t, e, a = 8, o, s, d) {
546
- se(t, e, r, a, i, o, s, d);
556
+ function we(i, r, t, e, a = 8, o, s, d) {
557
+ ce(t, e, r, a, i, o, s, d);
547
558
  }
548
559
  function G(i, r) {
549
560
  i.writeByte(255 & r), i.writeByte(r >> 8 & 255);
550
561
  }
551
- function zt(i, r) {
562
+ function jt(i, r) {
552
563
  for (var t = 0; t < r.length; t++) i.writeByte(r.charCodeAt(t));
553
564
  }
554
- function yt(i) {
565
+ function _t(i) {
555
566
  return Math.max(Math.ceil(Math.log2(i)), 1);
556
567
  }
557
- ae();
558
- class ye {
568
+ ne();
569
+ class Ce {
559
570
  constructor(r, t) {
560
571
  p(this, "_recorder");
561
572
  p(this, "_textmodifier");
562
573
  p(this, "_registerPostDrawHook");
563
- this._recorder = new Zt(), this._textmodifier = r, this._registerPostDrawHook = t;
574
+ this._recorder = new re(), this._textmodifier = r, this._registerPostDrawHook = t;
564
575
  }
565
576
  async $saveGIF(r = {}) {
566
577
  const t = this._textmodifier.canvas, e = this._applyDefaultOptions(r), a = r.onProgress;
567
578
  try {
568
- const o = await this._recorder.$record(t, e, this._registerPostDrawHook, a), s = me(), { repeat: d } = r;
579
+ const o = await this._recorder.$record(t, e, this._registerPostDrawHook, a), s = be(), { repeat: d } = r;
569
580
  for (let n = 0; n < o.length; n++) {
570
- const c = o[n], { width: u, height: f, imageData: y, delayMs: m } = c, v = new Uint32Array(y.data.buffer), w = de(v, 256, {}), x = ue(v, w);
581
+ const c = o[n], { width: u, height: f, imageData: y, delayMs: m } = c, v = new Uint32Array(y.data.buffer), w = pe(v, 256, {}), x = me(v, w);
571
582
  s.writeFrame(x, u, f, { palette: w, delay: m, repeat: n === 0 ? d : -1 }), n % 2 != 0 && n !== o.length - 1 || (a == null || a({ state: "encoding", frameIndex: n + 1, totalFrames: o.length }), await new Promise((g) => setTimeout(g, 0)));
572
583
  }
573
584
  s.finish();
@@ -582,12 +593,12 @@ class ye {
582
593
  return { filename: r.filename, frameCount: t, frameRate: e, scale: a, repeat: o };
583
594
  }
584
595
  }
585
- function _e(i) {
596
+ function Ee(i) {
586
597
  return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
587
598
  }
588
- var St, It = { exports: {} };
589
- function we() {
590
- return St || (St = 1, i = It, (function() {
599
+ var Ft, Mt = { exports: {} };
600
+ function ke() {
601
+ return Ft || (Ft = 1, i = Mt, (function() {
591
602
  function r(l, h) {
592
603
  return (function(n) {
593
604
  if (typeof n != "string" || !n.match(/^data:image\/webp;base64,/i)) throw new Error("Failed to decode WebP Base64 URL");
@@ -687,8 +698,8 @@ function we() {
687
698
  let P, $ = e(r(_, n.quality)), U = null;
688
699
  P = M || (typeof C == "number" ? C : n.frameDuration), n.transparent && (C instanceof HTMLCanvasElement || typeof C == "string" ? U = C : $.hasAlpha && (U = (function(I) {
689
700
  v !== null && v.width === I.width && v.height === I.height || (v = document.createElement("canvas"), v.width = I.width, v.height = I.height, w = v.getContext("2d"), x = w.createImageData(v.width, v.height));
690
- let X = I.getContext("2d").getImageData(0, 0, I.width, I.height).data, K = x.data, Z = 0, Ht = I.width * I.height * 4;
691
- for (let dt = 3; dt < Ht; dt += 4) {
701
+ let X = I.getContext("2d").getImageData(0, 0, I.width, I.height).data, K = x.data, Z = 0, Xt = I.width * I.height * 4;
702
+ for (let dt = 3; dt < Xt; dt += 4) {
692
703
  let ct = X[dt];
693
704
  K[Z++] = ct, K[Z++] = ct, K[Z++] = ct, K[Z++] = 255;
694
705
  }
@@ -727,12 +738,12 @@ function we() {
727
738
  };
728
739
  };
729
740
  i.exports = d;
730
- })()), It.exports;
741
+ })()), Mt.exports;
731
742
  var i;
732
743
  }
733
- var Ft, Mt = { exports: {} };
734
- function Ce() {
735
- return Ft || (Ft = 1, i = Mt, (function() {
744
+ var Lt, $t = { exports: {} };
745
+ function Be() {
746
+ return Lt || (Lt = 1, i = $t, (function() {
736
747
  let r = function(t) {
737
748
  this.data = new Uint8Array(t), this.pos = 0;
738
749
  };
@@ -804,12 +815,12 @@ function Ce() {
804
815
  if (this.pos == this.data.byteLength) return this.data;
805
816
  throw new Error("ArrayBufferDataStream's pos lies beyond end of buffer");
806
817
  }, i.exports = r;
807
- })()), Mt.exports;
818
+ })()), $t.exports;
808
819
  var i;
809
820
  }
810
- var Lt, $t, Pt, At = { exports: {} };
811
- function Ee() {
812
- return Lt || (Lt = 1, i = At, (function() {
821
+ var Pt, At, Ot, Dt = { exports: {} };
822
+ function Se() {
823
+ return Pt || (Pt = 1, i = Dt, (function() {
813
824
  let r = function(t) {
814
825
  return function(e) {
815
826
  let a = [], o = Promise.resolve(), s = null, d = null;
@@ -879,17 +890,17 @@ function Ee() {
879
890
  };
880
891
  };
881
892
  i.exports = r;
882
- })()), At.exports;
893
+ })()), Dt.exports;
883
894
  var i;
884
895
  }
885
- function ke() {
886
- return Pt ? $t : (Pt = 1, $t = we()(Ce(), Ee()(null)));
896
+ function Ie() {
897
+ return Ot ? At : (Ot = 1, At = ke()(Be(), Se()(null)));
887
898
  }
888
- var Be = ke();
889
- const Se = _e(Be);
890
- class Ie {
899
+ var Fe = Ie();
900
+ const Me = Ee(Fe);
901
+ class Le {
891
902
  async $record(r, t, e, a) {
892
- const o = Math.max(1, Math.round(t.frameRate)), s = Math.max(1, Math.round(t.frameCount)), d = new Se({ quality: t.quality, alphaQuality: t.transparent ? t.quality : void 0, transparent: t.transparent, frameRate: o }), l = this._createSnapshotSurface();
903
+ const o = Math.max(1, Math.round(t.frameRate)), s = Math.max(1, Math.round(t.frameCount)), d = new Me({ quality: t.quality, alphaQuality: t.transparent ? t.quality : void 0, transparent: t.transparent, frameRate: o }), l = this._createSnapshotSurface();
893
904
  return await new Promise((h, n) => {
894
905
  let c, u = "capturing", f = !1, y = 0;
895
906
  const m = () => {
@@ -929,12 +940,12 @@ class Ie {
929
940
  };
930
941
  }
931
942
  }
932
- class Fe {
943
+ class $e {
933
944
  constructor(r, t) {
934
945
  p(this, "_recorder");
935
946
  p(this, "_textmodifier");
936
947
  p(this, "_registerPostDrawHook");
937
- this._recorder = new Ie(), this._textmodifier = r, this._registerPostDrawHook = t;
948
+ this._recorder = new Le(), this._textmodifier = r, this._registerPostDrawHook = t;
938
949
  }
939
950
  async $saveWEBM(r = {}) {
940
951
  var a;
@@ -950,19 +961,19 @@ class Fe {
950
961
  return { filename: r.filename, frameRate: Math.abs(Math.round(r.frameRate ?? 60)), frameCount: Math.abs(Math.round(r.frameCount ?? 300)), quality: Math.abs(Math.min(Math.max(r.quality ?? 1, 0), 1)), transparent: !!r.transparent, debugLogging: !!r.debugLogging };
951
962
  }
952
963
  }
953
- class Me extends xt {
964
+ class Pe extends xt {
954
965
  $extractCellData(r) {
955
966
  var s;
956
967
  const t = r.layers.base.drawFramebuffer, e = this.$extractFramebufferData(t), a = [];
957
968
  let o = 0;
958
969
  for (let d = 0; d < r.grid.rows; d++) for (let l = 0; l < r.grid.cols; l++) {
959
- const h = 4 * o, n = this.$getCharacterIndex(e.characterPixels, h), c = this.$extractCellTransform(e.characterPixels, h), u = ((s = r.font.characters[n]) == null ? void 0 : s.character) ?? " ";
970
+ const h = 4 * o, n = this.$getEncodedCharacterValue(e.characterPixels, h), c = this.$extractCellTransform(e.characterPixels, h), u = ((s = yt(r.font, n)) == null ? void 0 : s.character) ?? " ";
960
971
  a.push({ x: l, y: d, character: u, foreground: it(e.primaryColorPixels, h), background: it(e.secondaryColorPixels, h), transform: { invert: c.isInverted, flipX: c.flipHorizontal, flipY: c.flipVertical, rotation: c.rotation } }), o++;
961
972
  }
962
973
  return a;
963
974
  }
964
975
  }
965
- const Le = "https://textmode.art/schemas/textmode-layer-1.0.schema.json";
976
+ const Ae = "https://textmode.art/schemas/textmode-layer-1.0.schema.json";
966
977
  class mt {
967
978
  _applyDefaultOptions(r) {
968
979
  return { pretty: r.pretty ?? !0, colorMode: r.colorMode ?? "hex", includeMetadata: r.includeMetadata ?? !0, filename: r.filename };
@@ -979,8 +990,8 @@ class mt {
979
990
  return { encoding: "object-rows-v1", rows: a };
980
991
  }
981
992
  $generateJSONData(r, t = {}) {
982
- const e = this._applyDefaultOptions(t), a = new Me().$extractCellData(r), o = this._createObjectRowsCells(a, r, e.colorMode);
983
- return { $schema: Le, format: "textmode.layer", formatVersion: "1.0.0", ...e.includeMetadata ? { metadata: { createdAt: (/* @__PURE__ */ new Date()).toISOString(), generator: { name: "textmode.export.js", version: "1.2.1" } } } : {}, canvas: { width: r.grid.width, height: r.grid.height }, grid: { cols: r.grid.cols, rows: r.grid.rows, cellWidth: r.grid.cellWidth, cellHeight: r.grid.cellHeight }, layer: { id: "base", cells: o } };
993
+ const e = this._applyDefaultOptions(t), a = new Pe().$extractCellData(r), o = this._createObjectRowsCells(a, r, e.colorMode);
994
+ return { $schema: Ae, format: "textmode.layer", formatVersion: "1.0.0", ...e.includeMetadata ? { metadata: { createdAt: (/* @__PURE__ */ new Date()).toISOString(), generator: { name: "textmode.export.js", version: "1.2.1" } } } : {}, canvas: { width: r.grid.width, height: r.grid.height }, grid: { cols: r.grid.cols, rows: r.grid.rows, cellWidth: r.grid.cellWidth, cellHeight: r.grid.cellHeight }, layer: { id: "base", cells: o } };
984
995
  }
985
996
  $generateJSONString(r, t = {}) {
986
997
  const e = this._applyDefaultOptions(t), a = this.$generateJSONData(r, e), o = typeof e.pretty == "number" ? e.pretty : e.pretty ? 2 : 0;
@@ -1151,7 +1162,7 @@ class st extends T {
1151
1162
  }
1152
1163
  }
1153
1164
  }
1154
- class Ot extends T {
1165
+ class Vt extends T {
1155
1166
  constructor(t) {
1156
1167
  super();
1157
1168
  p(this, "props");
@@ -1174,7 +1185,7 @@ class Ot extends T {
1174
1185
  this.props = t, this.button.textContent = t.label, this.button.disabled = !!t.disabled, t.variant === "secondary" ? (this.button.classList.add(b.buttonSecondary), this.button.classList.remove(b.buttonPrimary)) : (this.button.classList.add(b.buttonPrimary), this.button.classList.remove(b.buttonSecondary)), this.button.classList.toggle(b.buttonFull, !!t.fullWidth);
1175
1186
  }
1176
1187
  }
1177
- class $e {
1188
+ class Oe {
1178
1189
  constructor(r) {
1179
1190
  p(this, "api");
1180
1191
  this.api = r;
@@ -1204,7 +1215,7 @@ class $e {
1204
1215
  }
1205
1216
  }
1206
1217
  }
1207
- class Pe {
1218
+ class De {
1208
1219
  constructor(r, t) {
1209
1220
  p(this, "api");
1210
1221
  p(this, "events");
@@ -1246,7 +1257,7 @@ class Pe {
1246
1257
  }
1247
1258
  }
1248
1259
  }
1249
- class Ae {
1260
+ class Ve {
1250
1261
  constructor(r, t) {
1251
1262
  p(this, "modifier");
1252
1263
  p(this, "overlay");
@@ -1270,11 +1281,11 @@ class Ae {
1270
1281
  this.animationFrameId !== null && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null), this.bound && (window.removeEventListener("resize", this.handleUpdate), window.removeEventListener("scroll", this.handleUpdate, !0), this.bound = !1);
1271
1282
  }
1272
1283
  }
1273
- const Q = "textmode-export-number-input", Oe = `${Q}__field`, De = `${Q}__controls`, Ve = `${Q}__control`, jt = `${Q}__display`, rt = `${jt}--visible`, Te = (i) => {
1284
+ const Q = "textmode-export-number-input", Te = `${Q}__field`, Re = `${Q}__controls`, Ne = `${Q}__control`, qt = `${Q}__display`, rt = `${qt}--visible`, Ue = (i) => {
1274
1285
  i.dispatchEvent(new Event("input", { bubbles: !0 })), i.dispatchEvent(new Event("change", { bubbles: !0 }));
1275
- }, Dt = (i) => {
1286
+ }, Tt = (i) => {
1276
1287
  const r = document.createElement("button");
1277
- return r.type = "button", r.className = Ve, r.textContent = i > 0 ? "▲" : "▼", r;
1288
+ return r.type = "button", r.className = Ne, r.textContent = i > 0 ? "▲" : "▼", r;
1278
1289
  };
1279
1290
  class z extends T {
1280
1291
  constructor(t) {
@@ -1293,9 +1304,9 @@ class z extends T {
1293
1304
  }
1294
1305
  render() {
1295
1306
  const t = document.createElement("div");
1296
- t.className = Q, this.input = document.createElement("input"), this.input.type = "number", this.input.value = this.props.defaultValue, Object.assign(this.input, this.props.attributes), this.input.className = Oe, this.display = document.createElement("div"), this.display.className = jt;
1307
+ t.className = Q, this.input = document.createElement("input"), this.input.type = "number", this.input.value = this.props.defaultValue, Object.assign(this.input, this.props.attributes), this.input.className = Te, this.display = document.createElement("div"), this.display.className = qt;
1297
1308
  const e = document.createElement("div");
1298
- return e.className = De, this.incrementButton = Dt(1), this.decrementButton = Dt(-1), e.appendChild(this.incrementButton), e.appendChild(this.decrementButton), t.appendChild(this.input), t.appendChild(this.display), t.appendChild(e), this.bindStepControls(), this.bindHoldBehavior(), this.bindInputListeners(), this.observeDisabledState(t), this.updateDisplay(), t;
1309
+ return e.className = Re, this.incrementButton = Tt(1), this.decrementButton = Tt(-1), e.appendChild(this.incrementButton), e.appendChild(this.decrementButton), t.appendChild(this.input), t.appendChild(this.display), t.appendChild(e), this.bindStepControls(), this.bindHoldBehavior(), this.bindInputListeners(), this.observeDisabledState(t), this.updateDisplay(), t;
1299
1310
  }
1300
1311
  get inputElement() {
1301
1312
  return this.input;
@@ -1322,7 +1333,7 @@ class z extends T {
1322
1333
  const h = s > 0 ? 1 : -1, n = Number.parseFloat(this.input.value || "0"), c = Number.isFinite(n) ? n + h : h;
1323
1334
  this.input.value = String(c);
1324
1335
  }
1325
- this.input.value !== d && Te(this.input), this.updateDisplay(), this.input.focus({ preventScroll: !0 });
1336
+ this.input.value !== d && Ue(this.input), this.updateDisplay(), this.input.focus({ preventScroll: !0 });
1326
1337
  }, e = t(1), a = t(-1), o = (s, d) => (l) => {
1327
1338
  if (this.suppressClickAfterPointer.get(s)) return this.suppressClickAfterPointer.set(s, !1), void l.preventDefault();
1328
1339
  d();
@@ -1394,8 +1405,8 @@ class Y extends T {
1394
1405
  return t.classList.add(...e), t;
1395
1406
  }
1396
1407
  }
1397
- const Vt = { neutral: "textmode-export-overlay__status-value--neutral", active: "textmode-export-overlay__status-value--active", alert: "textmode-export-overlay__status-value--alert" };
1398
- class Wt extends T {
1408
+ const Rt = { neutral: "textmode-export-overlay__status-value--neutral", active: "textmode-export-overlay__status-value--active", alert: "textmode-export-overlay__status-value--alert" };
1409
+ class Ht extends T {
1399
1410
  constructor(t) {
1400
1411
  super();
1401
1412
  p(this, "props");
@@ -1415,7 +1426,7 @@ class Wt extends T {
1415
1426
  this.props = t, this.setMessage(t.message, t.variant ?? "neutral");
1416
1427
  }
1417
1428
  applyVariant(t) {
1418
- this.messageElement.classList.remove(...Object.values(Vt)), this.messageElement.classList.add(Vt[t]);
1429
+ this.messageElement.classList.remove(...Object.values(Rt)), this.messageElement.classList.add(Rt[t]);
1419
1430
  }
1420
1431
  }
1421
1432
  class J extends T {
@@ -1436,15 +1447,15 @@ class J extends T {
1436
1447
  this._managedComponents.clear();
1437
1448
  }
1438
1449
  }
1439
- const j = { frameCount: 300, frameRate: 60, scale: 1, repeat: 0 };
1450
+ const W = { frameCount: 300, frameRate: 60, scale: 1, repeat: 0 };
1440
1451
  class bt extends J {
1441
1452
  constructor(t) {
1442
1453
  super(t);
1443
- p(this, "frameCountInput", this._manageComponent(new z({ defaultValue: String(j.frameCount), attributes: { min: "1", max: "600", step: "1" } })));
1444
- p(this, "frameRateInput", this._manageComponent(new z({ defaultValue: String(j.frameRate), attributes: { min: "1", max: "60", step: "1" } })));
1445
- p(this, "scaleInput", this._manageComponent(new z({ defaultValue: String(j.scale), attributes: { min: "0.1", max: "8", step: "0.1" } })));
1454
+ p(this, "frameCountInput", this._manageComponent(new z({ defaultValue: String(W.frameCount), attributes: { min: "1", max: "600", step: "1" } })));
1455
+ p(this, "frameRateInput", this._manageComponent(new z({ defaultValue: String(W.frameRate), attributes: { min: "1", max: "60", step: "1" } })));
1456
+ p(this, "scaleInput", this._manageComponent(new z({ defaultValue: String(W.scale), attributes: { min: "0.1", max: "8", step: "0.1" } })));
1446
1457
  p(this, "repeatInput", this._manageComponent(new z({ defaultValue: "0", attributes: { min: "0", max: "50", step: "1" }, formatDisplay: (t, e) => Number.isFinite(t) ? t === 0 ? "∞" : null : e.trim() === "" ? null : e })));
1447
- p(this, "status", this._manageComponent(new Wt({ title: "status", message: "ready to record", variant: "neutral", context: "gif" })));
1458
+ p(this, "status", this._manageComponent(new Ht({ title: "status", message: "ready to record", variant: "neutral", context: "gif" })));
1448
1459
  p(this, "recordingState", "idle");
1449
1460
  }
1450
1461
  render() {
@@ -1511,7 +1522,7 @@ class bt extends J {
1511
1522
  }
1512
1523
  }
1513
1524
  applyDefaults() {
1514
- const t = this._config.defaultOptions ?? {}, e = t.frameCount ?? j.frameCount, a = t.frameRate ?? j.frameRate, o = t.scale ?? j.scale, s = t.repeat ?? j.repeat;
1525
+ const t = this._config.defaultOptions ?? {}, e = t.frameCount ?? W.frameCount, a = t.frameRate ?? W.frameRate, o = t.scale ?? W.scale, s = t.repeat ?? W.repeat;
1515
1526
  this.frameCountInput.value = String(e), this.frameRateInput.value = String(a), this.scaleInput.value = String(o), this.repeatInput.value = String(s), this.frameCountInput.refresh(), this.frameRateInput.refresh(), this.scaleInput.refresh(), this.repeatInput.refresh();
1516
1527
  }
1517
1528
  safeParseInt(t, e) {
@@ -1523,12 +1534,12 @@ class bt extends J {
1523
1534
  return Number.isFinite(a) ? a : e;
1524
1535
  }
1525
1536
  }
1526
- const lt = "textmode-export-range-input", Re = `${lt}__field`, Ne = `${lt}__tooltip`, ft = `${lt}__tooltip--visible`, at = (i, r) => {
1537
+ const lt = "textmode-export-range-input", Ge = `${lt}__field`, ze = `${lt}__tooltip`, ft = `${lt}__tooltip--visible`, at = (i, r) => {
1527
1538
  if (typeof i != "string" || i.length === 0) return r;
1528
1539
  const t = Number.parseFloat(i);
1529
1540
  return Number.isFinite(t) ? t : r;
1530
- }, Ue = (i, r, t) => Math.min(t, Math.max(r, i));
1531
- class Ge extends T {
1541
+ }, We = (i, r, t) => Math.min(t, Math.max(r, i));
1542
+ class je extends T {
1532
1543
  constructor(t) {
1533
1544
  super();
1534
1545
  p(this, "props");
@@ -1545,7 +1556,7 @@ class Ge extends T {
1545
1556
  }
1546
1557
  render() {
1547
1558
  const t = document.createElement("div");
1548
- return t.className = lt, this.input = document.createElement("input"), this.input.type = "range", this.input.value = this.props.defaultValue, Object.assign(this.input, this.props.attributes), this.input.className = Re, this.tooltip = document.createElement("div"), this.tooltip.className = Ne, t.appendChild(this.input), t.appendChild(this.tooltip), this.bindEvents(t), this.updateTooltip(), this.syncDisabledState(t), t;
1559
+ return t.className = lt, this.input = document.createElement("input"), this.input.type = "range", this.input.value = this.props.defaultValue, Object.assign(this.input, this.props.attributes), this.input.className = Ge, this.tooltip = document.createElement("div"), this.tooltip.className = ze, t.appendChild(this.input), t.appendChild(this.tooltip), this.bindEvents(t), this.updateTooltip(), this.syncDisabledState(t), t;
1549
1560
  }
1550
1561
  get inputElement() {
1551
1562
  return this.input;
@@ -1622,7 +1633,7 @@ class Ge extends T {
1622
1633
  this.tooltip.textContent = t(e, this.input);
1623
1634
  }
1624
1635
  updateTooltipPosition() {
1625
- const t = this.getMin(), e = this.getMax(), a = Ue(this.getCurrentValue(), t, e), o = e - t, s = o === 0 ? 0 : (a - t) / o;
1636
+ const t = this.getMin(), e = this.getMax(), a = We(this.getCurrentValue(), t, e), o = e - t, s = o === 0 ? 0 : (a - t) / o;
1626
1637
  this.tooltip.style.left = 100 * s + "%";
1627
1638
  }
1628
1639
  getMin() {
@@ -1635,21 +1646,21 @@ class Ge extends T {
1635
1646
  return at(this.input.value, at(this.props.defaultValue, 0));
1636
1647
  }
1637
1648
  }
1638
- function ze(i) {
1649
+ function qe(i) {
1639
1650
  if (!Number.isFinite(i)) return "default quality";
1640
1651
  const r = Math.max(0, Math.min(1, i));
1641
1652
  return r >= 0.995 ? "near-lossless" : r >= 0.98 ? "maximum detail" : r >= 0.88 ? "ultra quality" : r >= 0.7 ? "high quality" : r >= 0.5 ? "balanced" : r >= 0.25 ? "compact" : r >= 0.1 ? "lightweight" : "draft";
1642
1653
  }
1643
- function je(i) {
1644
- return `${ze(i)} (quality ≈ ${i.toFixed(3)})`;
1654
+ function He(i) {
1655
+ return `${qe(i)} (quality ≈ ${i.toFixed(3)})`;
1645
1656
  }
1646
1657
  class vt extends J {
1647
1658
  constructor(t) {
1648
1659
  super(t);
1649
1660
  p(this, "frameRateInput", this._manageComponent(new z({ defaultValue: String(60), attributes: { min: String(1), max: String(60), step: "1" }, formatDisplay: (t) => Number.isFinite(t) ? `${t} fps` : null })));
1650
1661
  p(this, "frameCountInput", this._manageComponent(new z({ defaultValue: String(480), attributes: { min: String(1), max: String(3600), step: "1" } })));
1651
- p(this, "qualityInput", this._manageComponent(new Ge({ defaultValue: String(0.7), attributes: { min: String(0), max: String(1), step: "0.001" }, formatValue: (t) => je(t) })));
1652
- p(this, "status", this._manageComponent(new Wt({ title: "status", message: "ready to record", variant: "neutral", context: "video" })));
1662
+ p(this, "qualityInput", this._manageComponent(new je({ defaultValue: String(0.7), attributes: { min: String(0), max: String(1), step: "0.001" }, formatValue: (t) => He(t) })));
1663
+ p(this, "status", this._manageComponent(new Ht({ title: "status", message: "ready to record", variant: "neutral", context: "video" })));
1653
1664
  p(this, "recordingState", "idle");
1654
1665
  }
1655
1666
  render() {
@@ -1715,8 +1726,8 @@ class vt extends J {
1715
1726
  this.frameCountInput.value = String(e), this.frameRateInput.value = String(a), this.qualityInput.value = String(o), this.frameCountInput.refresh(), this.frameRateInput.refresh();
1716
1727
  }
1717
1728
  }
1718
- const We = `@layer textmode-export-overlay{.textmode-export-overlay{--overlay-bg: rgba(20, 20, 20, .8);--overlay-surface: rgba(40, 40, 40, .9);--overlay-border: rgba(255, 255, 255, .14);--overlay-border-strong: rgba(255, 255, 255, .2);--overlay-border-focus: rgba(160, 160, 160, .6);--overlay-focus-shadow: 0 0 0 1px rgba(140, 140, 140, .28);--overlay-text: #ffffff;--overlay-muted: rgba(200, 200, 200, .74);--overlay-radius: .75rem;--overlay-stack-gap: .55rem;position:absolute;top:0;left:0;display:flex;flex-direction:column;gap:var(--overlay-stack-gap);min-width:236px;max-width:236px;padding:.65rem .8rem;background:var(--overlay-bg);color:var(--overlay-text);border-radius:var(--overlay-radius);border:1px solid var(--overlay-border);box-shadow:0 12px 28px #0000004d;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:.82rem;line-height:1.35;pointer-events:auto;z-index:2147483647}.textmode-export-overlay *{box-sizing:border-box}.textmode-export-overlay__header{display:flex;flex-direction:column;gap:.4rem}.textmode-export-overlay__header-title-row{display:flex;align-items:center;justify-content:space-between;gap:.4rem}.textmode-export-overlay__header-links{display:inline-flex;align-items:center;gap:.3rem}.textmode-export-overlay__support-link{display:inline-flex;align-items:center;justify-content:center;padding:.2rem;border-radius:.45rem;border:1px solid transparent;color:#d7d7d7d1;background:transparent;text-decoration:none;line-height:0;transition:background .18s ease,color .18s ease,transform .18s ease,border-color .18s ease}.textmode-export-overlay__support-link:hover{color:#fff;background:#5a5a5a4d;border-color:#c8c8c824}.textmode-export-overlay__support-link:focus-visible{outline:none;border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow)}.textmode-export-overlay__support-icon,.textmode-export-overlay__link-icon{display:block;width:1rem;height:1rem}.textmode-export-overlay__stack{display:flex;flex-direction:column;gap:var(--overlay-stack-gap)}.textmode-export-overlay__stack--dense{gap:.3rem}.textmode-export-overlay__stack--compact{gap:.45rem}.textmode-export-overlay__section{display:flex;flex-direction:column;gap:.4rem}.textmode-export-overlay__title{font-size:.92rem;font-weight:600}.textmode-export-overlay__divider{width:100%;height:1px;background:#ffffff29;margin-top:.25rem}.textmode-export-overlay__label{font-weight:500;opacity:.9}.textmode-export-overlay__checkbox{display:flex;align-items:center;gap:.5rem}.textmode-export-overlay__checkbox input[type=checkbox]{width:1rem;height:1rem;accent-color:rgba(100,100,100,.9)}.textmode-export-overlay__row{display:flex;gap:.6rem;flex-wrap:wrap;align-items:flex-start;width:100%}.textmode-export-overlay__field{display:flex;flex-direction:column;gap:.3rem;flex:1 1 120px;min-width:120px}.textmode-export-overlay__field--compact{flex:1 1 100px;min-width:100px}.textmode-export-overlay__field--dense{flex:1 1 90px;min-width:90px}.textmode-export-overlay__field--channel{flex:1 1 0;min-width:0}.textmode-export-overlay__field--full{width:100%;flex:1 1 100%}.textmode-export-overlay__input,.textmode-export-overlay select.textmode-export-overlay__input,.textmode-export-overlay input.textmode-export-overlay__input{width:100%;padding:.35rem .5rem;border-radius:.4rem;border:1px solid var(--overlay-border-strong);background:var(--overlay-surface);color:var(--overlay-text);font:inherit;line-height:1.35;transition:border-color .18s ease,box-shadow .18s ease,background .18s ease}.textmode-export-overlay select.textmode-export-overlay__input{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(200, 200, 200, 0.74)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right .5rem center;background-size:1rem;padding-right:2rem}.textmode-export-overlay__input:focus{outline:none;border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow);background:#2d2f42eb}.textmode-export-overlay__input::placeholder{color:var(--overlay-muted);opacity:.7}.textmode-export-overlay__muted{font-size:.75rem;opacity:.7;display:block}.textmode-export-overlay__button{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;border-radius:.45rem;border:none;font-weight:600;padding:.45rem .7rem;cursor:pointer;transition:background .2s ease,transform .2s ease,box-shadow .2s ease}.textmode-export-overlay__button--primary{background:#505050;color:#fff}.textmode-export-overlay__button--secondary{background:#606060;color:#fff}.textmode-export-overlay__button--full{width:100%}.textmode-export-overlay__button:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 7px 18px #00000073}.textmode-export-overlay__button--primary:hover:not(:disabled){background:#404040}.textmode-export-overlay__button--secondary:hover:not(:disabled){background:#4a4a4a}.textmode-export-overlay__button:disabled{cursor:default;opacity:.55;transform:none;box-shadow:none}.textmode-export-overlay__status{display:flex;flex-direction:column;gap:.25rem;padding:.45rem .55rem;border-radius:.45rem;border:1px solid rgba(110,110,110,.22);background:#4646462e}.textmode-export-overlay__status--gif{background:#5050501f;border-color:#78787840}.textmode-export-overlay__status--video{background:#4646461f;border-color:#6e6e6e40}.textmode-export-overlay__status-title{font-weight:600;font-size:.75rem;opacity:.85;text-transform:uppercase;letter-spacing:.04em}.textmode-export-overlay__status-value{font-size:.82rem;color:#dedede;transition:color .18s ease}.textmode-export-overlay__status-value--neutral{color:#cfcfcf}.textmode-export-overlay__status-value--active{color:#f5f5f5}.textmode-export-overlay__status-value--alert{color:#b8b8b8}.textmode-export-number-input,.textmode-export-overlay .textmode-export-number-input{display:flex;align-items:stretch;width:100%;background:var(--overlay-surface);border:1px solid var(--overlay-border-strong);border-radius:.4rem;overflow:hidden;transition:border-color .18s ease,box-shadow .18s ease,background .18s ease;position:relative}.textmode-export-number-input:focus-within{border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow)}.textmode-export-number-input.is-disabled{opacity:.55}.textmode-export-number-input__field{flex:1 1 auto;min-width:0;border:none;background:transparent;color:var(--overlay-text);font:inherit;padding:.35rem .5rem;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}.textmode-export-number-input__field::-webkit-outer-spin-button,.textmode-export-number-input__field::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.textmode-export-number-input__field:focus{outline:none}.textmode-export-number-input__controls{display:flex;flex-direction:column;border-left:1px solid rgba(255,255,255,.12);min-width:1.6rem}.textmode-export-number-input__control{display:flex;align-items:center;justify-content:center;width:100%;flex:1;border:none;background:#32323299;color:#d0d0d0;font-size:.68rem;line-height:1;cursor:pointer;transition:background .15s ease,color .15s ease;padding:0}.textmode-export-number-input__control:hover:not(:disabled){background:#5a5a5ad9;color:#fff}.textmode-export-number-input__control:disabled{cursor:default;opacity:.4;background:#28282880;color:#c8c8c866}.textmode-export-number-input:focus-within .textmode-export-number-input__control{background:#3c3c3cbf;color:#e8e8e8}.textmode-export-number-input__display{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;padding:.4rem .55rem;pointer-events:none;color:#f8fafc;opacity:0;transition:opacity .14s ease}.textmode-export-number-input__display--visible{opacity:1}.textmode-export-range-input{position:relative;width:100%}.textmode-export-range-input.is-disabled{opacity:.55}.textmode-export-range-input__field{width:100%;height:1.4rem;padding:0;margin:0;background:transparent;cursor:pointer;-moz-appearance:none;appearance:none;-webkit-appearance:none}.textmode-export-range-input__field::-webkit-slider-thumb{width:12px;height:12px;margin-top:-3.5px;-webkit-appearance:none;border-radius:50%;background:#a0a0a0;border:2px solid #303030;box-shadow:0 0 0 2px #00000059}.textmode-export-range-input__field::-webkit-slider-runnable-track{height:5px;border-radius:999px;background:linear-gradient(90deg,#8c8c8cd9,#646464a6)}.textmode-export-range-input__field::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:#a0a0a0;border:2px solid #303030;margin-top:-3.5px}.textmode-export-range-input__field::-moz-range-track{height:5px;border-radius:999px;background:linear-gradient(90deg,#8c8c8cd9,#646464a6)}.textmode-export-range-input__tooltip{position:absolute;top:-1.5rem;left:0;transform:translate(-50%);padding:.2rem .35rem;border-radius:.35rem;background:#1e1e1ee0;color:#f8fafc;font-size:.68rem;line-height:1;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s ease}.textmode-export-range-input__tooltip--visible{opacity:1}}`;
1719
- class qe {
1729
+ const Je = `@layer textmode-export-overlay{.textmode-export-overlay{--overlay-bg: rgba(20, 20, 20, .8);--overlay-surface: rgba(40, 40, 40, .9);--overlay-border: rgba(255, 255, 255, .14);--overlay-border-strong: rgba(255, 255, 255, .2);--overlay-border-focus: rgba(160, 160, 160, .6);--overlay-focus-shadow: 0 0 0 1px rgba(140, 140, 140, .28);--overlay-text: #ffffff;--overlay-muted: rgba(200, 200, 200, .74);--overlay-radius: .75rem;--overlay-stack-gap: .55rem;position:absolute;top:0;left:0;display:flex;flex-direction:column;gap:var(--overlay-stack-gap);min-width:236px;max-width:236px;padding:.65rem .8rem;background:var(--overlay-bg);color:var(--overlay-text);border-radius:var(--overlay-radius);border:1px solid var(--overlay-border);box-shadow:0 12px 28px #0000004d;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:.82rem;line-height:1.35;pointer-events:auto;z-index:2147483647}.textmode-export-overlay *{box-sizing:border-box}.textmode-export-overlay__header{display:flex;flex-direction:column;gap:.4rem}.textmode-export-overlay__header-title-row{display:flex;align-items:center;justify-content:space-between;gap:.4rem}.textmode-export-overlay__header-links{display:inline-flex;align-items:center;gap:.3rem}.textmode-export-overlay__support-link{display:inline-flex;align-items:center;justify-content:center;padding:.2rem;border-radius:.45rem;border:1px solid transparent;color:#d7d7d7d1;background:transparent;text-decoration:none;line-height:0;transition:background .18s ease,color .18s ease,transform .18s ease,border-color .18s ease}.textmode-export-overlay__support-link:hover{color:#fff;background:#5a5a5a4d;border-color:#c8c8c824}.textmode-export-overlay__support-link:focus-visible{outline:none;border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow)}.textmode-export-overlay__support-icon,.textmode-export-overlay__link-icon{display:block;width:1rem;height:1rem}.textmode-export-overlay__stack{display:flex;flex-direction:column;gap:var(--overlay-stack-gap)}.textmode-export-overlay__stack--dense{gap:.3rem}.textmode-export-overlay__stack--compact{gap:.45rem}.textmode-export-overlay__section{display:flex;flex-direction:column;gap:.4rem}.textmode-export-overlay__title{font-size:.92rem;font-weight:600}.textmode-export-overlay__divider{width:100%;height:1px;background:#ffffff29;margin-top:.25rem}.textmode-export-overlay__label{font-weight:500;opacity:.9}.textmode-export-overlay__checkbox{display:flex;align-items:center;gap:.5rem}.textmode-export-overlay__checkbox input[type=checkbox]{width:1rem;height:1rem;accent-color:rgba(100,100,100,.9)}.textmode-export-overlay__row{display:flex;gap:.6rem;flex-wrap:wrap;align-items:flex-start;width:100%}.textmode-export-overlay__field{display:flex;flex-direction:column;gap:.3rem;flex:1 1 120px;min-width:120px}.textmode-export-overlay__field--compact{flex:1 1 100px;min-width:100px}.textmode-export-overlay__field--dense{flex:1 1 90px;min-width:90px}.textmode-export-overlay__field--channel{flex:1 1 0;min-width:0}.textmode-export-overlay__field--full{width:100%;flex:1 1 100%}.textmode-export-overlay__input,.textmode-export-overlay select.textmode-export-overlay__input,.textmode-export-overlay input.textmode-export-overlay__input{width:100%;padding:.35rem .5rem;border-radius:.4rem;border:1px solid var(--overlay-border-strong);background:var(--overlay-surface);color:var(--overlay-text);font:inherit;line-height:1.35;transition:border-color .18s ease,box-shadow .18s ease,background .18s ease}.textmode-export-overlay select.textmode-export-overlay__input{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(200, 200, 200, 0.74)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right .5rem center;background-size:1rem;padding-right:2rem}.textmode-export-overlay__input:focus{outline:none;border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow);background:#2d2f42eb}.textmode-export-overlay__input::placeholder{color:var(--overlay-muted);opacity:.7}.textmode-export-overlay__muted{font-size:.75rem;opacity:.7;display:block}.textmode-export-overlay__button{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;border-radius:.45rem;border:none;font-weight:600;padding:.45rem .7rem;cursor:pointer;transition:background .2s ease,transform .2s ease,box-shadow .2s ease}.textmode-export-overlay__button--primary{background:#505050;color:#fff}.textmode-export-overlay__button--secondary{background:#606060;color:#fff}.textmode-export-overlay__button--full{width:100%}.textmode-export-overlay__button:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 7px 18px #00000073}.textmode-export-overlay__button--primary:hover:not(:disabled){background:#404040}.textmode-export-overlay__button--secondary:hover:not(:disabled){background:#4a4a4a}.textmode-export-overlay__button:disabled{cursor:default;opacity:.55;transform:none;box-shadow:none}.textmode-export-overlay__status{display:flex;flex-direction:column;gap:.25rem;padding:.45rem .55rem;border-radius:.45rem;border:1px solid rgba(110,110,110,.22);background:#4646462e}.textmode-export-overlay__status--gif{background:#5050501f;border-color:#78787840}.textmode-export-overlay__status--video{background:#4646461f;border-color:#6e6e6e40}.textmode-export-overlay__status-title{font-weight:600;font-size:.75rem;opacity:.85;text-transform:uppercase;letter-spacing:.04em}.textmode-export-overlay__status-value{font-size:.82rem;color:#dedede;transition:color .18s ease}.textmode-export-overlay__status-value--neutral{color:#cfcfcf}.textmode-export-overlay__status-value--active{color:#f5f5f5}.textmode-export-overlay__status-value--alert{color:#b8b8b8}.textmode-export-number-input,.textmode-export-overlay .textmode-export-number-input{display:flex;align-items:stretch;width:100%;background:var(--overlay-surface);border:1px solid var(--overlay-border-strong);border-radius:.4rem;overflow:hidden;transition:border-color .18s ease,box-shadow .18s ease,background .18s ease;position:relative}.textmode-export-number-input:focus-within{border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow)}.textmode-export-number-input.is-disabled{opacity:.55}.textmode-export-number-input__field{flex:1 1 auto;min-width:0;border:none;background:transparent;color:var(--overlay-text);font:inherit;padding:.35rem .5rem;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}.textmode-export-number-input__field::-webkit-outer-spin-button,.textmode-export-number-input__field::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.textmode-export-number-input__field:focus{outline:none}.textmode-export-number-input__controls{display:flex;flex-direction:column;border-left:1px solid rgba(255,255,255,.12);min-width:1.6rem}.textmode-export-number-input__control{display:flex;align-items:center;justify-content:center;width:100%;flex:1;border:none;background:#32323299;color:#d0d0d0;font-size:.68rem;line-height:1;cursor:pointer;transition:background .15s ease,color .15s ease;padding:0}.textmode-export-number-input__control:hover:not(:disabled){background:#5a5a5ad9;color:#fff}.textmode-export-number-input__control:disabled{cursor:default;opacity:.4;background:#28282880;color:#c8c8c866}.textmode-export-number-input:focus-within .textmode-export-number-input__control{background:#3c3c3cbf;color:#e8e8e8}.textmode-export-number-input__display{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;padding:.4rem .55rem;pointer-events:none;color:#f8fafc;opacity:0;transition:opacity .14s ease}.textmode-export-number-input__display--visible{opacity:1}.textmode-export-range-input{position:relative;width:100%}.textmode-export-range-input.is-disabled{opacity:.55}.textmode-export-range-input__field{width:100%;height:1.4rem;padding:0;margin:0;background:transparent;cursor:pointer;-moz-appearance:none;appearance:none;-webkit-appearance:none}.textmode-export-range-input__field::-webkit-slider-thumb{width:12px;height:12px;margin-top:-3.5px;-webkit-appearance:none;border-radius:50%;background:#a0a0a0;border:2px solid #303030;box-shadow:0 0 0 2px #00000059}.textmode-export-range-input__field::-webkit-slider-runnable-track{height:5px;border-radius:999px;background:linear-gradient(90deg,#8c8c8cd9,#646464a6)}.textmode-export-range-input__field::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:#a0a0a0;border:2px solid #303030;margin-top:-3.5px}.textmode-export-range-input__field::-moz-range-track{height:5px;border-radius:999px;background:linear-gradient(90deg,#8c8c8cd9,#646464a6)}.textmode-export-range-input__tooltip{position:absolute;top:-1.5rem;left:0;transform:translate(-50%);padding:.2rem .35rem;border-radius:.35rem;background:#1e1e1ee0;color:#f8fafc;font-size:.68rem;line-height:1;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s ease}.textmode-export-range-input__tooltip--visible{opacity:1}}`;
1730
+ class Xe {
1720
1731
  constructor(r, t, e, a, o) {
1721
1732
  p(this, "_textmodifier");
1722
1733
  p(this, "_state");
@@ -1735,8 +1746,8 @@ class qe {
1735
1746
  p(this, "_header", new gt());
1736
1747
  p(this, "_formatField", new O({ label: "export format", labelFor: "textmode-export-format", variant: "full" }));
1737
1748
  p(this, "_formatSelect", new st({ id: "textmode-export-format", options: [] }));
1738
- p(this, "_exportButton", new Ot({ label: "download file", fullWidth: !0, variant: "primary" }));
1739
- p(this, "_copyButton", new Ot({ label: "copy to clipboard", fullWidth: !0, variant: "primary" }));
1749
+ p(this, "_exportButton", new Vt({ label: "download file", fullWidth: !0, variant: "primary" }));
1750
+ p(this, "_copyButton", new Vt({ label: "copy to clipboard", fullWidth: !0, variant: "primary" }));
1740
1751
  p(this, "_currentFormat");
1741
1752
  p(this, "_currentBlade");
1742
1753
  p(this, "_handleFormatSelectChange", () => {
@@ -1752,10 +1763,10 @@ class qe {
1752
1763
  console.error("[textmode-export] Copy failed", r);
1753
1764
  });
1754
1765
  });
1755
- this._textmodifier = r, this._state = e, this._events = a, this._exportService = new Pe(t, a), this._clipboardService = new $e(t), this._definitions = o, this._currentFormat = e.snapshot.format, this._initializeFormatMap(), this._registerEventHandlers();
1766
+ this._textmodifier = r, this._state = e, this._events = a, this._exportService = new De(t, a), this._clipboardService = new Oe(t), this._definitions = o, this._currentFormat = e.snapshot.format, this._initializeFormatMap(), this._registerEventHandlers();
1756
1767
  }
1757
1768
  $mount() {
1758
- this._createOverlay(), this._renderStaticContent(), this._positionService = new Ae(this._textmodifier, this._shadowHost), this._positionService.bind(), this._switchFormat(this._currentFormat);
1769
+ this._createOverlay(), this._renderStaticContent(), this._positionService = new Ve(this._textmodifier, this._shadowHost), this._positionService.bind(), this._switchFormat(this._currentFormat);
1759
1770
  }
1760
1771
  show() {
1761
1772
  this._shadowHost && (this._shadowHost.style.display = "");
@@ -1786,7 +1797,7 @@ class qe {
1786
1797
  _createOverlay() {
1787
1798
  this._shadowHost = document.createElement("div"), this._shadowHost.dataset.plugin = "textmode-export-overlay-host", this._shadowHost.style.cssText = "position: absolute; top: 0; left: 0; pointer-events: none; z-index: 2147483647;", this._shadowRoot = this._shadowHost.attachShadow({ mode: "open" });
1788
1799
  const r = document.createElement("style");
1789
- r.textContent = We, this._shadowRoot.appendChild(r), this._overlayElement = document.createElement("div"), this._overlayElement.dataset.plugin = "textmode-export-overlay", this._overlayElement.classList.add(b.root, b.stack), this._shadowRoot.appendChild(this._overlayElement), document.body.appendChild(this._shadowHost);
1800
+ r.textContent = Je, this._shadowRoot.appendChild(r), this._overlayElement = document.createElement("div"), this._overlayElement.dataset.plugin = "textmode-export-overlay", this._overlayElement.classList.add(b.root, b.stack), this._shadowRoot.appendChild(this._overlayElement), document.body.appendChild(this._shadowHost);
1790
1801
  }
1791
1802
  _renderStaticContent() {
1792
1803
  this._header.mount(this._overlayElement);
@@ -1935,7 +1946,7 @@ class qe {
1935
1946
  this._exportButton.setDisabled(t), this._exportButton.setLabel(t ? "exporting…" : "download file");
1936
1947
  }
1937
1948
  }
1938
- class He {
1949
+ class Ye {
1939
1950
  constructor() {
1940
1951
  p(this, "_listeners", {});
1941
1952
  }
@@ -1963,7 +1974,7 @@ class He {
1963
1974
  for (const r of Object.keys(this._listeners)) delete this._listeners[r];
1964
1975
  }
1965
1976
  }
1966
- class Je {
1977
+ class Qe {
1967
1978
  constructor(r) {
1968
1979
  p(this, "_state");
1969
1980
  p(this, "_listeners", /* @__PURE__ */ new Set());
@@ -1992,7 +2003,7 @@ class Je {
1992
2003
  for (const e of [...this._listeners]) e(t);
1993
2004
  }
1994
2005
  }
1995
- const Xe = (i) => ({ format: i, isBusy: !1 });
2006
+ const Ke = (i) => ({ format: i, isBusy: !1 });
1996
2007
  class nt extends T {
1997
2008
  constructor(t) {
1998
2009
  super();
@@ -2025,7 +2036,7 @@ class nt extends T {
2025
2036
  this.props = t, t.id && (this.checkbox.id = t.id, this.labelElement.htmlFor = t.id), this.checkbox.checked = !!t.defaultChecked, this.labelElement.lastElementChild && (this.labelElement.lastElementChild.textContent = t.label);
2026
2037
  }
2027
2038
  }
2028
- class Ye extends T {
2039
+ class Ze extends T {
2029
2040
  constructor(t) {
2030
2041
  super();
2031
2042
  p(this, "props");
@@ -2054,11 +2065,11 @@ class Ye extends T {
2054
2065
  this.props = t, t.id && (this.input.id = t.id), t.maxLength !== void 0 && (this.input.maxLength = t.maxLength), t.defaultValue !== void 0 && (this.input.value = t.defaultValue);
2055
2066
  }
2056
2067
  }
2057
- class Qe extends J {
2068
+ class tr extends J {
2058
2069
  constructor(t) {
2059
2070
  super(t);
2060
2071
  p(this, "trailingSpaces", this._manageComponent(new nt({ label: "preserve trailing spaces", defaultChecked: !1 })));
2061
- p(this, "emptyCharacter", this._manageComponent(new Ye({ id: "textmode-export-empty-character", defaultValue: " ", maxLength: 1 })));
2072
+ p(this, "emptyCharacter", this._manageComponent(new Ze({ id: "textmode-export-empty-character", defaultValue: " ", maxLength: 1 })));
2062
2073
  }
2063
2074
  render() {
2064
2075
  const t = document.createElement("div");
@@ -2081,7 +2092,7 @@ class Qe extends J {
2081
2092
  this.trailingSpaces.checked = t.preserveTrailingSpaces ?? !1, this.emptyCharacter.value = t.emptyCharacter ?? " ";
2082
2093
  }
2083
2094
  }
2084
- class Ke extends J {
2095
+ class er extends J {
2085
2096
  constructor(t) {
2086
2097
  super(t);
2087
2098
  p(this, "prettyPrint", this._manageComponent(new nt({ id: "textmode-export-json-pretty", label: "pretty print", defaultChecked: !0 })));
@@ -2108,7 +2119,7 @@ class Ke extends J {
2108
2119
  this.prettyPrint.checked = typeof t.pretty == "number" ? t.pretty > 0 : t.pretty ?? !0, this.includeMetadata.checked = t.includeMetadata ?? !0, this.colorMode.value = t.colorMode ?? "hex";
2109
2120
  }
2110
2121
  }
2111
- class Ze extends J {
2122
+ class rr extends J {
2112
2123
  constructor(t) {
2113
2124
  super(t);
2114
2125
  p(this, "formatSelect", this._manageComponent(new st({ id: "textmode-export-image-format", options: [{ value: "png", label: `PNG (${pt.png})` }, { value: "jpg", label: `JPG (${pt.jpg})` }, { value: "webp", label: `WEBP (${pt.webp})` }], defaultValue: "png" })));
@@ -2143,7 +2154,7 @@ class Ze extends J {
2143
2154
  this.scaleInput.value = String(e);
2144
2155
  }
2145
2156
  }
2146
- class tr extends J {
2157
+ class ar extends J {
2147
2158
  constructor(t) {
2148
2159
  super(t);
2149
2160
  p(this, "includeBackground", this._manageComponent(new nt({ id: "textmode-export-svg-include-backgrounds", label: "include cell backgrounds", defaultChecked: !0 })));
@@ -2181,39 +2192,39 @@ class tr extends J {
2181
2192
  this.strokeWidth.value = String(e), this.strokeWidth.refresh();
2182
2193
  }
2183
2194
  }
2184
- const er = [{ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, createBlade: () => new Qe({ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, defaultOptions: { preserveTrailingSpaces: !1, emptyCharacter: " " } }) }, { format: "json", label: "layer data (.json)", supportsClipboard: !0, createBlade: () => new Ke({ format: "json", label: "layer data (.json)", supportsClipboard: !0, defaultOptions: { pretty: !0, includeMetadata: !0, colorMode: "hex" } }) }, { format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, createBlade: () => new Ze({ format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, defaultOptions: { format: "png", scale: 1 } }) }, { format: "svg", label: "vector (.svg)", supportsClipboard: !0, createBlade: () => new tr({ format: "svg", label: "vector (.svg)", supportsClipboard: !0, defaultOptions: { includeBackgroundRectangles: !0, drawMode: "fill", strokeWidth: 1 } }) }, { format: "gif", label: "animated GIF (.gif)", supportsClipboard: !1, createBlade: () => new bt({ format: "gif", label: "animated GIF (.gif)", supportsClipboard: !1, defaultOptions: { frameCount: 300, frameRate: 60, scale: 1, repeat: 0 } }) }, { format: "video", label: "video (.webm)", supportsClipboard: !1, createBlade: () => new vt({ format: "video", label: "video (.webm)", supportsClipboard: !1, defaultOptions: { frameCount: 480, frameRate: 60, quality: 0.7 } }) }];
2185
- function rr() {
2186
- return er;
2195
+ const or = [{ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, createBlade: () => new tr({ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, defaultOptions: { preserveTrailingSpaces: !1, emptyCharacter: " " } }) }, { format: "json", label: "layer data (.json)", supportsClipboard: !0, createBlade: () => new er({ format: "json", label: "layer data (.json)", supportsClipboard: !0, defaultOptions: { pretty: !0, includeMetadata: !0, colorMode: "hex" } }) }, { format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, createBlade: () => new rr({ format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, defaultOptions: { format: "png", scale: 1 } }) }, { format: "svg", label: "vector (.svg)", supportsClipboard: !0, createBlade: () => new ar({ format: "svg", label: "vector (.svg)", supportsClipboard: !0, defaultOptions: { includeBackgroundRectangles: !0, drawMode: "fill", strokeWidth: 1 } }) }, { format: "gif", label: "animated GIF (.gif)", supportsClipboard: !1, createBlade: () => new bt({ format: "gif", label: "animated GIF (.gif)", supportsClipboard: !1, defaultOptions: { frameCount: 300, frameRate: 60, scale: 1, repeat: 0 } }) }, { format: "video", label: "video (.webm)", supportsClipboard: !1, createBlade: () => new vt({ format: "video", label: "video (.webm)", supportsClipboard: !1, defaultOptions: { frameCount: 480, frameRate: 60, quality: 0.7 } }) }];
2196
+ function ir() {
2197
+ return or;
2187
2198
  }
2188
- function ar(i, r) {
2199
+ function nr(i, r) {
2189
2200
  var d;
2190
- const t = rr(), e = (d = t[0]) == null ? void 0 : d.format, a = new Je(Xe(e)), o = new He(), s = new qe(i, r, a, o, t);
2201
+ const t = ir(), e = (d = t[0]) == null ? void 0 : d.format, a = new Qe(Ke(e)), o = new Ye(), s = new Xe(i, r, a, o, t);
2191
2202
  return s.$mount(), s;
2192
2203
  }
2193
- const qt = { name: "textmode.export", version: "1.2.1", async install(i, r) {
2194
- const t = { saveCanvas: async (d = {}) => new wt().$saveImage(i.canvas, d), copyCanvas: async (d = {}) => new wt().$copyImageToClipboard(i.canvas, d), saveSVG: (d = {}) => {
2195
- new _t().$saveSVG(i, d);
2204
+ const Jt = { name: "textmode.export", version: "1.2.1", async install(i, r) {
2205
+ const t = { saveCanvas: async (d = {}) => new Et().$saveImage(i.canvas, d), copyCanvas: async (d = {}) => new Et().$copyImageToClipboard(i.canvas, d), saveSVG: (d = {}) => {
2206
+ new Ct().$saveSVG(i, d);
2196
2207
  }, saveStrings: (d = {}) => {
2197
- new Ct().$saveTXT(i, d);
2198
- }, toSVG: (d = {}) => new _t().$generateSVG(i, d), toString: (d = {}) => new Ct().$generateTXT(i, d), toJSON: (d = {}) => new mt().$generateJSONData(i, d), toJSONString: (d = {}) => new mt().$generateJSONString(i, d), saveJSON: (d = {}) => {
2208
+ new kt().$saveTXT(i, d);
2209
+ }, toSVG: (d = {}) => new Ct().$generateSVG(i, d), toString: (d = {}) => new kt().$generateTXT(i, d), toJSON: (d = {}) => new mt().$generateJSONData(i, d), toJSONString: (d = {}) => new mt().$generateJSONString(i, d), saveJSON: (d = {}) => {
2199
2210
  new mt().$saveJSON(i, d);
2200
- }, saveGIF: async (d = {}) => new ye(i, r.registerPostDrawHook).$saveGIF(d), saveWEBM: async (d = {}) => new Fe(i, r.registerPostDrawHook).$saveWEBM(d) }, e = ar(i, t), a = { show: () => e.show(), hide: () => e.hide(), toggle: () => e.toggle(), isVisible: () => e.isVisible() }, o = { ...t, exportOverlay: a }, s = i;
2211
+ }, saveGIF: async (d = {}) => new Ce(i, r.registerPostDrawHook).$saveGIF(d), saveWEBM: async (d = {}) => new $e(i, r.registerPostDrawHook).$saveWEBM(d) }, e = nr(i, t), a = { show: () => e.show(), hide: () => e.hide(), toggle: () => e.toggle(), isVisible: () => e.isVisible() }, o = { ...t, exportOverlay: a }, s = i;
2201
2212
  Object.assign(s, o), s._exportOverlayController = e;
2202
2213
  }, async uninstall(i) {
2203
2214
  const r = i, t = r._exportOverlayController;
2204
2215
  t == null || t.$dispose(), delete r._exportOverlayController;
2205
2216
  const e = ["exportOverlay", "saveCanvas", "copyCanvas", "saveSVG", "saveStrings", "toSVG", "toString", "toJSON", "toJSONString", "saveJSON", "saveGIF", "saveWEBM"];
2206
2217
  for (const a of e) delete r[a];
2207
- } }, or = (i = {}) => {
2208
- const r = i.overlay ?? !0, t = { ...qt }, e = t.install;
2218
+ } }, sr = (i = {}) => {
2219
+ const r = i.overlay ?? !0, t = { ...Jt }, e = t.install;
2209
2220
  return t.install = async (a, o) => {
2210
2221
  var d;
2211
2222
  const s = a;
2212
2223
  await e.call(t, s, o), r || ((d = s.exportOverlay) == null || d.hide());
2213
2224
  }, t;
2214
2225
  };
2215
- typeof window < "u" && (window.ExportPlugin = qt, window.createTextmodeExportPlugin = or);
2226
+ typeof window < "u" && (window.ExportPlugin = Jt, window.createTextmodeExportPlugin = sr);
2216
2227
  export {
2217
- qt as ExportPlugin,
2218
- or as createTextmodeExportPlugin
2228
+ Jt as ExportPlugin,
2229
+ sr as createTextmodeExportPlugin
2219
2230
  };