textmode.export.js 1.1.0 → 1.2.1

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,296 +1,289 @@
1
- class At {
2
- $extractFramebufferData(t) {
3
- return { characterPixels: t.readPixels(0), primaryColorPixels: t.readPixels(1), secondaryColorPixels: t.readPixels(2) };
1
+ class Ae {
2
+ $extractFramebufferData(e) {
3
+ return { characterPixels: e.readPixels(0), primaryColorPixels: e.readPixels(1), secondaryColorPixels: e.readPixels(2) };
4
4
  }
5
- $getCharacterIndex(t, e) {
6
- return t[e] + (t[e + 1] << 8);
5
+ $getCharacterIndex(e, t) {
6
+ return e[t] + (e[t + 1] << 8);
7
7
  }
8
8
  }
9
9
  class Q {
10
- $downloadFile(t, e) {
10
+ $downloadFile(e, t) {
11
11
  try {
12
- const r = this._sanitizeFilename(e), a = URL.createObjectURL(t), i = document.createElement("a");
12
+ const r = this._sanitizeFilename(t), a = URL.createObjectURL(e), i = document.createElement("a");
13
13
  i.href = a, i.download = r, i.style.display = "none", i.rel = "noopener", document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(a);
14
14
  } catch (r) {
15
15
  console.error("[textmode-export] Failed to download file:", r);
16
16
  }
17
17
  }
18
- _sanitizeFilename(t) {
19
- if (!t) return this._generateDefaultFilename();
20
- const e = t.trim();
21
- return e ? e.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255) || this._generateDefaultFilename() : this._generateDefaultFilename();
18
+ _sanitizeFilename(e) {
19
+ if (!e) return this._generateDefaultFilename();
20
+ const t = e.trim();
21
+ return t ? t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255) || this._generateDefaultFilename() : this._generateDefaultFilename();
22
22
  }
23
23
  _generateDefaultFilename() {
24
24
  return `textmode-export-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-")}`;
25
25
  }
26
26
  }
27
- function ft(s, t) {
28
- return { r: s[t], g: s[t + 1], b: s[t + 2], a: s[t + 3] };
27
+ function fe(o, e) {
28
+ return { r: o[e], g: o[e + 1], b: o[e + 2], a: o[e + 3] };
29
29
  }
30
- class Wt extends At {
31
- _extractTransformData(t, e) {
32
- const r = t[e + 2], a = !!(1 & r), i = !!(2 & r), n = !!(4 & r), c = t[e + 3] / 255;
33
- return { isInverted: a, flipHorizontal: i, flipVertical: n, rotation: Math.round(360 * c * 100) / 100 };
30
+ class qe extends Ae {
31
+ _extractTransformData(e, t) {
32
+ const r = e[t + 2], a = !!(1 & r), i = !!(2 & r), s = !!(4 & r), c = e[t + 3] / 255;
33
+ return { isInverted: a, flipHorizontal: i, flipVertical: s, rotation: Math.round(360 * c * 100) / 100 };
34
34
  }
35
- _calculateCellPosition(t, e, r) {
36
- return { x: t, y: e, cellX: t * r.cellWidth, cellY: e * r.cellHeight };
35
+ _calculateCellPosition(e, t, r) {
36
+ return { x: e, y: t, cellX: e * r.cellWidth, cellY: t * r.cellHeight };
37
37
  }
38
- $extractSVGCellData(t, e) {
38
+ $extractSVGCellData(e, t) {
39
39
  const r = [];
40
40
  let a = 0;
41
- for (let i = 0; i < e.rows; i++) for (let n = 0; n < e.cols; n++) {
42
- const c = 4 * a, l = this.$getCharacterIndex(t.characterPixels, c);
43
- let p = ft(t.primaryColorPixels, c), o = ft(t.secondaryColorPixels, c);
44
- const d = this._extractTransformData(t.characterPixels, c);
41
+ for (let i = 0; i < t.rows; i++) for (let s = 0; s < t.cols; s++) {
42
+ const c = 4 * a, l = this.$getCharacterIndex(e.characterPixels, c);
43
+ let p = fe(e.primaryColorPixels, c), n = fe(e.secondaryColorPixels, c);
44
+ const d = this._extractTransformData(e.characterPixels, c);
45
45
  if (d.isInverted) {
46
46
  const m = p;
47
- p = o, o = m;
47
+ p = n, n = m;
48
48
  }
49
- const u = this._calculateCellPosition(n, i, e);
50
- r.push({ charIndex: l, primaryColor: p, secondaryColor: o, transform: d, position: u }), a++;
49
+ const u = this._calculateCellPosition(s, i, t);
50
+ r.push({ charIndex: l, primaryColor: p, secondaryColor: n, transform: d, position: u }), a++;
51
51
  }
52
52
  return r;
53
53
  }
54
54
  }
55
- class qt {
56
- _createGlyphPath(t, e, r, a, i) {
57
- const n = i / t.head.unitsPerEm;
58
- return console.log("Scale factor:", n), { getBoundingBox: () => ({ x1: r + e.xMin * n, y1: a + -e.yMax * n, x2: r + e.xMax * n, y2: a + -e.yMin * n }), toSVG: () => this._glyphToSVGPath(e, r, a, n) };
55
+ class He {
56
+ _createGlyphPath(e, t, r, a, i) {
57
+ const s = i / e.head.unitsPerEm;
58
+ return { getBoundingBox: () => ({ x1: r + t.xMin * s, y1: a + -t.yMax * s, x2: r + t.xMax * s, y2: a + -t.yMin * s }), toSVG: () => this._glyphToSVGPath(t, r, a, s) };
59
59
  }
60
- _glyphToSVGPath(t, e, r, a) {
61
- if (!t || !t.xs) return "";
62
- const { xs: i, ys: n, endPts: c, flags: l } = t;
63
- if (!(i && n && c && l)) return "";
64
- let p = "", o = 0;
60
+ _glyphToSVGPath(e, t, r, a) {
61
+ if (!e || !e.xs) return "";
62
+ const { xs: i, ys: s, endPts: c, flags: l } = e;
63
+ if (!(i && s && c && l)) return "";
64
+ let p = "", n = 0;
65
65
  for (let d = 0; d < c.length; d++) {
66
66
  const u = c[d];
67
- if (!(u < o)) {
68
- if (u >= o) {
69
- const m = e + i[o] * a, x = r - n[o] * a;
67
+ if (!(u < n)) {
68
+ if (u >= n) {
69
+ const m = t + i[n] * a, x = r - s[n] * a;
70
70
  p += `M${m.toFixed(2)},${x.toFixed(2)}`;
71
- let h = o + 1;
71
+ let h = n + 1;
72
72
  for (; h <= u; )
73
73
  if (1 & l[h]) {
74
- const f = e + i[h] * a, _ = r - n[h] * a;
75
- p += `L${f.toFixed(2)},${_.toFixed(2)}`, h++;
74
+ const g = t + i[h] * a, _ = r - s[h] * a;
75
+ p += `L${g.toFixed(2)},${_.toFixed(2)}`, h++;
76
76
  } else {
77
- const f = e + i[h] * a, _ = r - n[h] * a;
78
- let v = h + 1 > u ? o : h + 1;
77
+ const g = t + i[h] * a, _ = r - s[h] * a;
78
+ let v = h + 1 > u ? n : h + 1;
79
79
  if (1 & l[v]) {
80
- const g = e + i[v] * a, C = r - n[v] * a;
81
- p += `Q${f.toFixed(2)},${_.toFixed(2)} ${g.toFixed(2)},${C.toFixed(2)}`, h = v + 1;
80
+ const f = t + i[v] * a, C = r - s[v] * a;
81
+ p += `Q${g.toFixed(2)},${_.toFixed(2)} ${f.toFixed(2)},${C.toFixed(2)}`, h = v + 1;
82
82
  } else {
83
- const g = (f + (e + i[v] * a)) / 2, C = (_ + (r - n[v] * a)) / 2;
84
- p += `Q${f.toFixed(2)},${_.toFixed(2)} ${g.toFixed(2)},${C.toFixed(2)}`, h = v;
83
+ const f = (g + (t + i[v] * a)) / 2, C = (_ + (r - s[v] * a)) / 2;
84
+ p += `Q${g.toFixed(2)},${_.toFixed(2)} ${f.toFixed(2)},${C.toFixed(2)}`, h = v;
85
85
  }
86
86
  }
87
87
  p += "Z";
88
88
  }
89
- o = u + 1;
89
+ n = u + 1;
90
90
  }
91
91
  }
92
92
  return p;
93
93
  }
94
- _generateCharacterPath(t, e, r, a, i) {
95
- const n = e.characterMap.get(t).glyphData;
96
- return console.log("Glyph data for character", t, n), n ? this._createGlyphPath(e.font, n, r, a, i) : null;
94
+ _generateCharacterPath(e, t, r, a, i) {
95
+ const s = t.characterMap.get(e)?.glyphData;
96
+ return s ? this._createGlyphPath(t.font, s, r, a, i) : null;
97
97
  }
98
- $generatePositionedCharacterPath(t, e, r, a, i, n, c, l) {
98
+ $generatePositionedCharacterPath(e, t, r, a, i, s, c, l) {
99
99
  if (!l) return null;
100
- const p = c / e.font.head.unitsPerEm, o = r + (i - l.advanceWidth * p) / 2, d = a + (n + 0.7 * c) / 2, u = this._generateCharacterPath(t, e, o, d, c);
100
+ const p = c / t.font.head.unitsPerEm, n = r + (i - l.advanceWidth * p) / 2, d = a + (s + 0.7 * c) / 2, u = this._generateCharacterPath(e, t, n, d, c);
101
101
  return u && u.toSVG() || null;
102
102
  }
103
103
  }
104
- class Ht {
104
+ class je {
105
105
  _pathGenerator;
106
106
  constructor() {
107
- this._pathGenerator = new qt();
107
+ this._pathGenerator = new He();
108
108
  }
109
- $generateSVGHeader(t) {
110
- const { width: e, height: r } = t;
111
- return `<?xml version="1.0" encoding="UTF-8"?><svg width="${e}" height="${r}" viewBox="0 0 ${e} ${r}" xmlns="http://www.w3.org/2000/svg"><title>textmode.js sketch</title>`;
109
+ $generateSVGHeader(e) {
110
+ const { width: t, height: r } = e;
111
+ return `<?xml version="1.0" encoding="UTF-8"?><svg width="${t}" height="${r}" viewBox="0 0 ${t} ${r}" xmlns="http://www.w3.org/2000/svg"><title>textmode.js sketch</title>`;
112
112
  }
113
113
  $generateSVGFooter() {
114
114
  return "</g></svg>";
115
115
  }
116
- _generateTransformAttribute(t, e) {
117
- const { transform: r, position: a } = t;
116
+ _generateTransformAttribute(e, t) {
117
+ const { transform: r, position: a } = e;
118
118
  if (!r.flipHorizontal && !r.flipVertical && !r.rotation) return "";
119
- const i = a.cellX + e.cellWidth / 2, n = a.cellY + e.cellHeight / 2, c = [];
119
+ const i = a.cellX + t.cellWidth / 2, s = a.cellY + t.cellHeight / 2, c = [];
120
120
  if (r.flipHorizontal || r.flipVertical) {
121
121
  const l = r.flipHorizontal ? -1 : 1, p = r.flipVertical ? -1 : 1;
122
- c.push(`translate(${i} ${n})scale(${l} ${p})translate(${-i} ${-n})`);
122
+ c.push(`translate(${i} ${s})scale(${l} ${p})translate(${-i} ${-s})`);
123
123
  }
124
- return r.rotation && c.push(`rotate(${r.rotation} ${i} ${n})`), ` transform="${c.join(" ")}"`;
124
+ return r.rotation && c.push(`rotate(${r.rotation} ${i} ${s})`), ` transform="${c.join(" ")}"`;
125
125
  }
126
- _generateCellBackground(t, e, r) {
127
- if (!r.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
128
- const { position: a } = t, { r: i, g: n, b: c, a: l } = t.secondaryColor, p = `rgba(${i},${n},${c},${l / 255})`;
129
- return r.drawMode === "stroke" ? `<rect x="${a.cellX}" y="${a.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${p}" fill="none" stroke-width="${r.strokeWidth}"/>` : `<rect x="${a.cellX}" y="${a.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${p}"/>`;
126
+ _generateCellBackground(e, t, r) {
127
+ if (!r.includeBackgroundRectangles || e.secondaryColor.a === 0) return "";
128
+ const { position: a } = e, { r: i, g: s, b: c, a: l } = e.secondaryColor, p = `rgba(${i},${s},${c},${l / 255})`;
129
+ return r.drawMode === "stroke" ? `<rect x="${a.cellX}" y="${a.cellY}" width="${t.cellWidth}" height="${t.cellHeight}" stroke="${p}" fill="none" stroke-width="${r.strokeWidth}"/>` : `<rect x="${a.cellX}" y="${a.cellY}" width="${t.cellWidth}" height="${t.cellHeight}" fill="${p}"/>`;
130
130
  }
131
- _generateCharacterPath(t, e, r, a) {
132
- const i = r.characters[t.charIndex];
131
+ _generateCharacterPath(e, t, r, a) {
132
+ const i = r.characters[e.charIndex];
133
133
  if (!i) return "";
134
- const n = this._pathGenerator.$generatePositionedCharacterPath(i.character, r, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, r.fontSize, i.glyphData);
135
- if (!n) return "";
136
- const { r: c, g: l, b: p, a: o } = t.primaryColor, d = `rgba(${c},${l},${p},${o / 255})`;
137
- return a.drawMode === "stroke" ? `<path d="${n}" stroke="${d}" stroke-width="${a.strokeWidth}" fill="none"/>` : `<path d="${n}" fill="${d}"/>`;
138
- }
139
- $generateCellContent(t, e, r, a) {
140
- const i = [], n = this._generateCellBackground(t, e, a);
141
- n && i.push(n);
142
- const c = this._generateCharacterPath(t, e, r, a);
134
+ const s = this._pathGenerator.$generatePositionedCharacterPath(i.character, r, e.position.cellX, e.position.cellY, t.cellWidth, t.cellHeight, r.fontSize, i.glyphData);
135
+ if (!s) return "";
136
+ const { r: c, g: l, b: p, a: n } = e.primaryColor, d = `rgba(${c},${l},${p},${n / 255})`;
137
+ return a.drawMode === "stroke" ? `<path d="${s}" stroke="${d}" stroke-width="${a.strokeWidth}" fill="none"/>` : `<path d="${s}" fill="${d}"/>`;
138
+ }
139
+ $generateCellContent(e, t, r, a) {
140
+ const i = [], s = this._generateCellBackground(e, t, a);
141
+ s && i.push(s);
142
+ const c = this._generateCharacterPath(e, t, r, a);
143
143
  if (c) {
144
- const l = this._generateTransformAttribute(t, e);
144
+ const l = this._generateTransformAttribute(e, t);
145
145
  i.push(l ? `<g${l}>${c}</g>` : c);
146
146
  }
147
147
  return i.join("");
148
148
  }
149
- $generateSVGContent(t, e, r, a) {
150
- const i = [this.$generateSVGHeader(e), '<g id="ascii-cells">'];
151
- for (const n of t) i.push(this.$generateCellContent(n, e, r, a));
149
+ $generateSVGContent(e, t, r, a) {
150
+ const i = [this.$generateSVGHeader(t), '<g id="ascii-cells">'];
151
+ for (const s of e) i.push(this.$generateCellContent(s, t, r, a));
152
152
  return i.push(this.$generateSVGFooter()), i.join("");
153
153
  }
154
- $optimizeSVGContent(t) {
155
- return t.replace(/<path[^>]*d=""[^>]*\/>/g, "").replace(/\s+/g, " ").replace(/> </g, "><");
154
+ $optimizeSVGContent(e) {
155
+ return e.replace(/\s+/g, " ").replace(/> </g, "><");
156
156
  }
157
157
  }
158
- class gt {
159
- _applyDefaultOptions(t) {
160
- return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, filename: t.filename };
158
+ class ge {
159
+ _applyDefaultOptions(e) {
160
+ return { includeBackgroundRectangles: e.includeBackgroundRectangles ?? !0, drawMode: e.drawMode ?? "fill", strokeWidth: e.strokeWidth ?? 1, filename: e.filename };
161
161
  }
162
- $generateSVG(t, e = {}) {
163
- const r = new Wt(), a = new Ht(), i = r.$extractSVGCellData(r.$extractFramebufferData(t.drawFramebuffer), t.grid), n = a.$generateSVGContent(i, t.grid, t.font, this._applyDefaultOptions(e));
164
- return a.$optimizeSVGContent(n);
162
+ $generateSVG(e, t = {}) {
163
+ const r = new qe(), a = new je(), i = r.$extractSVGCellData(r.$extractFramebufferData(e.layers.base.drawFramebuffer), e.grid), s = a.$generateSVGContent(i, e.grid, e.font, this._applyDefaultOptions(t));
164
+ return a.$optimizeSVGContent(s);
165
165
  }
166
- $saveSVG(t, e = {}) {
167
- new Q().$downloadFile(new Blob([this.$generateSVG(t, e)], { type: "image/svg+xml;charset=utf-8" }), e.filename);
166
+ $saveSVG(e, t = {}) {
167
+ new Q().$downloadFile(new Blob([this.$generateSVG(e, t)], { type: "image/svg+xml;charset=utf-8" }), t.filename);
168
168
  }
169
169
  }
170
- const st = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, lt = { png: ".png", jpg: ".jpg", webp: ".webp" };
171
- class bt {
172
- _applyDefaultOptions(t) {
173
- return { format: t.format ?? "png", scale: Math.abs(t.scale ?? 1), filename: t.filename };
170
+ const se = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, le = { png: ".png", jpg: ".jpg", webp: ".webp" };
171
+ class be {
172
+ _applyDefaultOptions(e) {
173
+ return { format: e.format ?? "png", scale: Math.abs(e.scale ?? 1), filename: e.filename };
174
174
  }
175
- _validateOptions(t) {
176
- if (!(t.format in st)) throw new Error(`Saving '${t.format}' files is not supported`);
175
+ _validateOptions(e) {
176
+ if (!(e.format in se)) throw new Error(`Saving '${e.format}' files is not supported`);
177
177
  }
178
- async $generateImageBlob(t, e) {
179
- const r = t, a = document.createElement("canvas"), i = a.getContext("2d"), n = Math.round(r.width * e.scale), c = Math.round(r.height * e.scale);
180
- return a.width = n, a.height = c, i.imageSmoothingEnabled = !1, i.clearRect(0, 0, n, c), i.drawImage(r, 0, 0, r.width, r.height, 0, 0, n, c), await new Promise((l, p) => {
181
- a.toBlob((o) => {
182
- o ? l(o) : p(new Error(`Failed to generate ${e.format.toUpperCase()} blob`));
183
- }, st[e.format]);
178
+ async $generateImageBlob(e, t) {
179
+ const r = e, a = document.createElement("canvas"), i = a.getContext("2d"), s = Math.round(r.width * t.scale), c = Math.round(r.height * t.scale);
180
+ return a.width = s, a.height = c, i.imageSmoothingEnabled = !1, i.clearRect(0, 0, s, c), i.drawImage(r, 0, 0, r.width, r.height, 0, 0, s, c), await new Promise((l, p) => {
181
+ a.toBlob((n) => {
182
+ n ? l(n) : p(new Error(`Failed to generate ${t.format.toUpperCase()} blob`));
183
+ }, se[t.format]);
184
184
  });
185
185
  }
186
- async $saveImage(t, e = {}) {
187
- const r = this._applyDefaultOptions(e);
186
+ async $saveImage(e, t = {}) {
187
+ const r = this._applyDefaultOptions(t);
188
188
  this._validateOptions(r);
189
- const a = await this.$generateImageBlob(t, r);
189
+ const a = await this.$generateImageBlob(e, r);
190
190
  new Q().$downloadFile(a, r.filename);
191
191
  }
192
- async $copyImageToClipboard(t, e = {}) {
192
+ async $copyImageToClipboard(e, t = {}) {
193
193
  if (typeof navigator > "u" || !navigator.clipboard || typeof navigator.clipboard.write != "function") throw new Error("Clipboard API is not available in this environment");
194
- const r = this._applyDefaultOptions(e);
194
+ const r = this._applyDefaultOptions(t);
195
195
  this._validateOptions(r);
196
- const a = await this.$generateImageBlob(t, r), i = new ClipboardItem({ [st[r.format]]: a });
196
+ const a = await this.$generateImageBlob(e, r), i = new ClipboardItem({ [se[r.format]]: a });
197
197
  await navigator.clipboard.write([i]);
198
198
  }
199
199
  }
200
- class vt {
201
- _applyDefaultOptions(t) {
202
- return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename };
203
- }
204
- _createTXTContent(t, e) {
205
- const r = new At();
206
- let a = r.$extractFramebufferData(t.drawFramebuffer);
207
- const i = [];
208
- let n = 0;
209
- for (let l = 0; l < t.grid.rows; l++) {
210
- const p = [];
211
- for (let o = 0; o < t.grid.cols; o++) {
212
- const d = 4 * n, u = r.$getCharacterIndex(a.characterPixels, d), m = t.font.characters[u]?.character || e.emptyCharacter;
213
- p.push(m), n++;
200
+ class ve {
201
+ _applyDefaultOptions(e) {
202
+ return { preserveTrailingSpaces: e.preserveTrailingSpaces ?? !1, emptyCharacter: e.emptyCharacter ?? " ", filename: e.filename };
203
+ }
204
+ _createTXTContent(e, t) {
205
+ const r = new Ae(), a = e.layers.base.drawFramebuffer, i = r.$extractFramebufferData(a), s = [];
206
+ let c = 0;
207
+ for (let l = 0; l < e.grid.rows; l++) {
208
+ let p = "";
209
+ for (let n = 0; n < e.grid.cols; n++) {
210
+ const d = 4 * c, u = r.$getCharacterIndex(i.characterPixels, d);
211
+ p += e.font.characters[u]?.character || t.emptyCharacter, c++;
214
212
  }
215
- i.push(p);
216
- }
217
- const c = [];
218
- for (const l of i) {
219
- let p = l.join("");
220
- e.preserveTrailingSpaces || (p = p.replace(/\s+$/, "")), c.push(p);
213
+ t.preserveTrailingSpaces || (p = p.trimEnd()), s.push(p);
221
214
  }
222
- return c.join(`
215
+ return s.join(`
223
216
  `);
224
217
  }
225
- $generateTXT(t, e = {}) {
226
- return this._createTXTContent(t, this._applyDefaultOptions(e));
218
+ $generateTXT(e, t = {}) {
219
+ return this._createTXTContent(e, this._applyDefaultOptions(t));
227
220
  }
228
- $saveTXT(t, e = {}) {
229
- const r = this._applyDefaultOptions(e), a = this._createTXTContent(t, r), i = new Blob([a], { type: "text/plain;charset=utf-8" });
221
+ $saveTXT(e, t = {}) {
222
+ const r = this._applyDefaultOptions(t), a = this._createTXTContent(e, r), i = new Blob([a], { type: "text/plain;charset=utf-8" });
230
223
  new Q().$downloadFile(i, r.filename);
231
224
  }
232
225
  }
233
- class jt {
226
+ class Qe {
234
227
  _canvas;
235
228
  _ctx;
236
- async $record(t, e, r, a) {
237
- const i = Math.max(1, Math.round(e.frameRate)), n = Math.round(1e3 / i), c = Math.max(1, Math.round(e.frameCount));
229
+ async $record(e, t, r, a) {
230
+ const i = Math.max(1, Math.round(t.frameRate)), s = Math.round(1e3 / i), c = Math.max(1, Math.round(t.frameCount));
238
231
  return await new Promise((l, p) => {
239
- const o = [];
232
+ const n = [];
240
233
  let d, u = 0, m = !1;
241
234
  const x = () => {
242
235
  d && (d(), d = void 0);
243
236
  }, h = (_) => {
244
237
  m || (m = !0, x(), l(_));
245
- }, f = () => {
246
- if (u >= c) h(o);
238
+ }, g = () => {
239
+ if (u >= c) h(n);
247
240
  else try {
248
- const _ = e.scale, v = Math.max(1, Math.round(t.width * _)), g = Math.max(1, Math.round(t.height * _));
249
- this._canvas || (this._canvas = document.createElement("canvas")), this._canvas.width === v && this._canvas.height === g || (this._canvas.width = v, this._canvas.height = g), this._ctx || (this._ctx = this._canvas.getContext("2d"));
241
+ const _ = t.scale, v = Math.max(1, Math.round(e.width * _)), f = Math.max(1, Math.round(e.height * _));
242
+ this._canvas || (this._canvas = document.createElement("canvas")), this._canvas.width === v && this._canvas.height === f || (this._canvas.width = v, this._canvas.height = f), this._ctx || (this._ctx = this._canvas.getContext("2d"));
250
243
  const C = this._ctx;
251
- C.imageSmoothingEnabled = !1, C.clearRect(0, 0, v, g), C.drawImage(t, 0, 0, t.width, t.height, 0, 0, v, g);
252
- const S = { imageData: C.getImageData(0, 0, v, g), width: v, height: g, delayMs: n };
253
- o.push(S), u += 1, a?.({ state: "recording", frameIndex: u, totalFrames: c }), u >= c && h(o);
244
+ C.imageSmoothingEnabled = !1, C.clearRect(0, 0, v, f), C.drawImage(e, 0, 0, e.width, e.height, 0, 0, v, f);
245
+ const F = { imageData: C.getImageData(0, 0, v, f), width: v, height: f, delayMs: s };
246
+ n.push(F), u += 1, a?.({ state: "recording", frameIndex: u, totalFrames: c }), u >= c && h(n);
254
247
  } catch (_) {
255
248
  ((v) => {
256
249
  if (m) return;
257
250
  m = !0, x();
258
- const g = v instanceof Error ? v.message : "GIF recording failed";
259
- a?.({ state: "error", message: g }), p(v instanceof Error ? v : new Error(String(v)));
251
+ const f = v instanceof Error ? v.message : "GIF recording failed";
252
+ a?.({ state: "error", message: f }), p(v instanceof Error ? v : new Error(String(v)));
260
253
  })(_);
261
254
  }
262
255
  };
263
256
  d = r(() => {
264
- f();
257
+ g();
265
258
  }), a?.({ state: "recording", frameIndex: 0, totalFrames: c });
266
259
  });
267
260
  }
268
261
  }
269
- var Pt = Object.defineProperty, Qt = (s) => Pt(s, "__esModule", { value: !0 }), Xt = (s, t) => () => (t || s((t = { exports: {} }).exports, t), t.exports), Yt = (s, t) => {
270
- for (var e in t) Pt(s, e, { get: t[e], enumerable: !0 });
271
- }, Jt = Xt((s) => {
272
- function t(d, u, m) {
262
+ var Pe = Object.defineProperty, Xe = (o) => Pe(o, "__esModule", { value: !0 }), Ye = (o, e) => () => (e || o((e = { exports: {} }).exports, e), e.exports), Je = (o, e) => {
263
+ for (var t in e) Pe(o, t, { get: e[t], enumerable: !0 });
264
+ }, Ke = Ye((o) => {
265
+ function e(d, u, m) {
273
266
  return 0.29889531 * d + 0.58662247 * u + 0.11448223 * m;
274
267
  }
275
- function e(d, u, m) {
268
+ function t(d, u, m) {
276
269
  return 0.59597799 * d - 0.2741761 * u - 0.32180189 * m;
277
270
  }
278
271
  function r(d, u, m) {
279
272
  return 0.21147017 * d - 0.52261711 * u + 0.31114694 * m;
280
273
  }
281
274
  function a(d, u) {
282
- let m = d[0] - u[0], x = d[1] - u[1], h = d[2] - u[2], f = i(d) - i(u);
283
- return m * m * 0.5053 + x * x * 0.299 + h * h * 0.1957 + f * f;
275
+ let m = d[0] - u[0], x = d[1] - u[1], h = d[2] - u[2], g = i(d) - i(u);
276
+ return m * m * 0.5053 + x * x * 0.299 + h * h * 0.1957 + g * g;
284
277
  }
285
278
  function i(d) {
286
279
  return d[3] != null ? d[3] : 255;
287
280
  }
288
- function n(d, u) {
281
+ function s(d, u) {
289
282
  return Math.sqrt(a(d, u));
290
283
  }
291
284
  function c(d, u) {
292
- let [m, x, h] = d, [f, _, v] = u, g = t(m, x, h) - t(f, _, v), C = e(m, x, h) - e(f, _, v), S = r(m, x, h) - r(f, _, v), E = i(d) - i(u);
293
- return g * g * 0.5053 + C * C * 0.299 + S * S * 0.1957 + E * E;
285
+ let [m, x, h] = d, [g, _, v] = u, f = e(m, x, h) - e(g, _, v), C = t(m, x, h) - t(g, _, v), F = r(m, x, h) - r(g, _, v), E = i(d) - i(u);
286
+ return f * f * 0.5053 + C * C * 0.299 + F * F * 0.1957 + E * E;
294
287
  }
295
288
  function l(d, u) {
296
289
  return Math.sqrt(c(d, u));
@@ -303,60 +296,60 @@ var Pt = Object.defineProperty, Qt = (s) => Pt(s, "__esModule", { value: !0 }),
303
296
  }
304
297
  return x;
305
298
  }
306
- function o(d, u) {
299
+ function n(d, u) {
307
300
  return Math.sqrt(p(d, u));
308
301
  }
309
- Qt(s), Yt(s, { colorDifferenceRGBToYIQ: () => l, colorDifferenceRGBToYIQSquared: () => c, colorDifferenceYIQ: () => n, colorDifferenceYIQSquared: () => a, euclideanDistance: () => o, euclideanDistanceSquared: () => p });
310
- }), Kt = { trailer: 59 };
311
- function Dt(s = 256) {
312
- let t = 0, e = new Uint8Array(s);
302
+ Xe(o), Je(o, { colorDifferenceRGBToYIQ: () => l, colorDifferenceRGBToYIQSquared: () => c, colorDifferenceYIQ: () => s, colorDifferenceYIQSquared: () => a, euclideanDistance: () => n, euclideanDistanceSquared: () => p });
303
+ }), Ze = { trailer: 59 };
304
+ function De(o = 256) {
305
+ let e = 0, t = new Uint8Array(o);
313
306
  return { get buffer() {
314
- return e.buffer;
307
+ return t.buffer;
315
308
  }, reset() {
316
- t = 0;
317
- }, bytesView: () => e.subarray(0, t), bytes: () => e.slice(0, t), writeByte(a) {
318
- r(t + 1), e[t] = a, t++;
319
- }, writeBytes(a, i = 0, n = a.length) {
320
- r(t + n);
321
- for (let c = 0; c < n; c++) e[t++] = a[c + i];
322
- }, writeBytesView(a, i = 0, n = a.byteLength) {
323
- r(t + n), e.set(a.subarray(i, i + n), t), t += n;
309
+ e = 0;
310
+ }, bytesView: () => t.subarray(0, e), bytes: () => t.slice(0, e), writeByte(a) {
311
+ r(e + 1), t[e] = a, e++;
312
+ }, writeBytes(a, i = 0, s = a.length) {
313
+ r(e + s);
314
+ for (let c = 0; c < s; c++) t[e++] = a[c + i];
315
+ }, writeBytesView(a, i = 0, s = a.byteLength) {
316
+ r(e + s), t.set(a.subarray(i, i + s), e), e += s;
324
317
  } };
325
318
  function r(a) {
326
- var i = e.length;
319
+ var i = t.length;
327
320
  if (i >= a) return;
328
321
  a = Math.max(a, i * (i < 1048576 ? 2 : 1.125) >>> 0), i != 0 && (a = Math.max(a, 256));
329
- let n = e;
330
- e = new Uint8Array(a), t > 0 && e.set(n.subarray(0, t), 0);
322
+ let s = t;
323
+ t = new Uint8Array(a), e > 0 && t.set(s.subarray(0, e), 0);
331
324
  }
332
325
  }
333
- var Z = 12, xt = 5003, Zt = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535];
334
- function te(s, t, e, r, a, i, n, c) {
335
- a = a || Dt(512), i = i || new Uint8Array(256), n = n || new Int32Array(xt), c = c || new Int32Array(xt);
336
- let l = n.length, p = Math.max(2, r);
326
+ var Z = 12, xe = 5003, et = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535];
327
+ function tt(o, e, t, r, a, i, s, c) {
328
+ a = a || De(512), i = i || new Uint8Array(256), s = s || new Int32Array(xe), c = c || new Int32Array(xe);
329
+ let l = s.length, p = Math.max(2, r);
337
330
  i.fill(0), c.fill(0), L();
338
- let o = 0, d = 0, u = p + 1, m = u, x = !1, h = m, f = D(h), _ = 1 << u - 1, v = _ + 1, g = _ + 2, C = 0, S = e[0], E = 0;
331
+ let n = 0, d = 0, u = p + 1, m = u, x = !1, h = m, g = D(h), _ = 1 << u - 1, v = _ + 1, f = _ + 2, C = 0, F = t[0], E = 0;
339
332
  for (let k = l; k < 65536; k *= 2) ++E;
340
- E = 8 - E, a.writeByte(p), O(_);
341
- for (let k = 1; k < e.length; k++) V(e[k]);
342
- return O(S), O(v), a.writeByte(0), a.bytesView();
333
+ E = 8 - E, a.writeByte(p), T(_);
334
+ for (let k = 1; k < t.length; k++) V(t[k]);
335
+ return T(F), T(v), a.writeByte(0), a.bytesView();
343
336
  function A(k) {
344
337
  i[C++] = k, C >= 254 && B();
345
338
  }
346
339
  function L() {
347
- n.fill(-1);
340
+ s.fill(-1);
348
341
  }
349
342
  function V(k) {
350
- let R = (k << Z) + S, y = k << E ^ S;
351
- if (n[y] === R) S = c[y];
343
+ let R = (k << Z) + F, y = k << E ^ F;
344
+ if (s[y] === R) F = c[y];
352
345
  else {
353
- if (n[y] >= 0) {
346
+ if (s[y] >= 0) {
354
347
  let w = y === 0 ? 1 : l - y;
355
348
  do
356
- if (y -= w, y < 0 && (y += l), n[y] === R) return void (S = c[y]);
357
- while (n[y] >= 0);
349
+ if (y -= w, y < 0 && (y += l), s[y] === R) return void (F = c[y]);
350
+ while (s[y] >= 0);
358
351
  }
359
- O(S), S = k, g < 1 << Z ? (c[y] = g++, n[y] = R) : (L(), g = _ + 2, x = !0, O(_));
352
+ T(F), F = k, f < 1 << Z ? (c[y] = f++, s[y] = R) : (L(), f = _ + 2, x = !0, T(_));
360
353
  }
361
354
  }
362
355
  function B() {
@@ -365,249 +358,250 @@ function te(s, t, e, r, a, i, n, c) {
365
358
  function D(k) {
366
359
  return (1 << k) - 1;
367
360
  }
368
- function O(k) {
369
- for (o &= Zt[d], d > 0 ? o |= k << d : o = k, d += h; d >= 8; ) A(255 & o), o >>= 8, d -= 8;
370
- if ((g > f || x) && (x ? (h = m, f = D(h), x = !1) : (++h, f = h == Z ? 1 << Z : D(h))), k == v) {
371
- for (; d > 0; ) A(255 & o), o >>= 8, d -= 8;
361
+ function T(k) {
362
+ for (n &= et[d], d > 0 ? n |= k << d : n = k, d += h; d >= 8; ) A(255 & n), n >>= 8, d -= 8;
363
+ if ((f > g || x) && (x ? (h = m, g = D(h), x = !1) : (++h, g = h == Z ? 1 << Z : D(h))), k == v) {
364
+ for (; d > 0; ) A(255 & n), n >>= 8, d -= 8;
372
365
  B();
373
366
  }
374
367
  }
375
368
  }
376
- var ee = te;
377
- function Vt(s, t, e) {
378
- return s << 8 & 63488 | t << 2 & 992 | e >> 3 & 31;
369
+ var rt = tt;
370
+ function Ve(o, e, t) {
371
+ return o << 8 & 63488 | e << 2 & 992 | t >> 3 & 31;
379
372
  }
380
- function Tt(s, t, e, r) {
381
- return s >> 4 | 240 & t | (240 & e) << 4 | (240 & r) << 8;
373
+ function Oe(o, e, t, r) {
374
+ return o >> 4 | 240 & e | (240 & t) << 4 | (240 & r) << 8;
382
375
  }
383
- function Ot(s, t, e) {
384
- return s >> 4 << 8 | t >> 4 << 4 | e >> 4;
376
+ function Te(o, e, t) {
377
+ return o >> 4 << 8 | e >> 4 << 4 | t >> 4;
385
378
  }
386
- function tt(s, t, e) {
387
- return s < t ? t : s > e ? e : s;
379
+ function ee(o, e, t) {
380
+ return o < e ? e : o > t ? t : o;
388
381
  }
389
- function at(s) {
390
- return s * s;
382
+ function ae(o) {
383
+ return o * o;
391
384
  }
392
- function yt(s, t, e) {
393
- for (var r = 0, a = 1e100, i = s[t], n = i.cnt, c = (i.ac, i.rc), l = i.gc, p = i.bc, o = i.fw; o != 0; o = s[o].fw) {
394
- var d = s[o].cnt, u = n * d / (n + d);
385
+ function ye(o, e, t) {
386
+ for (var r = 0, a = 1e100, i = o[e], s = i.cnt, c = (i.ac, i.rc), l = i.gc, p = i.bc, n = i.fw; n != 0; n = o[n].fw) {
387
+ var d = o[n].cnt, u = s * d / (s + d);
395
388
  if (!(u >= a)) {
396
389
  var m = 0;
397
- !((m += u * at(s[o].rc - c)) >= a) && !((m += u * at(s[o].gc - l)) >= a) && !((m += u * at(s[o].bc - p)) >= a) && (a = m, r = o);
390
+ !((m += u * ae(o[n].rc - c)) >= a) && !((m += u * ae(o[n].gc - l)) >= a) && !((m += u * ae(o[n].bc - p)) >= a) && (a = m, r = n);
398
391
  }
399
392
  }
400
393
  i.err = a, i.nn = r;
401
394
  }
402
- function dt() {
395
+ function de() {
403
396
  return { ac: 0, rc: 0, gc: 0, bc: 0, cnt: 0, nn: 0, fw: 0, bk: 0, tm: 0, mtm: 0, err: 0 };
404
397
  }
405
- function re(s, t) {
406
- let e = new Array(t === "rgb444" ? 4096 : 65536), r = s.length;
407
- if (t === "rgba4444") for (let a = 0; a < r; ++a) {
408
- let i = s[a], n = i >> 24 & 255, c = i >> 16 & 255, l = i >> 8 & 255, p = 255 & i, o = Tt(p, l, c, n), d = o in e ? e[o] : e[o] = dt();
409
- d.rc += p, d.gc += l, d.bc += c, d.ac += n, d.cnt++;
398
+ function at(o, e) {
399
+ let t = new Array(e === "rgb444" ? 4096 : 65536), r = o.length;
400
+ if (e === "rgba4444") for (let a = 0; a < r; ++a) {
401
+ let i = o[a], s = i >> 24 & 255, c = i >> 16 & 255, l = i >> 8 & 255, p = 255 & i, n = Oe(p, l, c, s), d = n in t ? t[n] : t[n] = de();
402
+ d.rc += p, d.gc += l, d.bc += c, d.ac += s, d.cnt++;
410
403
  }
411
- else if (t === "rgb444") for (let a = 0; a < r; ++a) {
412
- let i = s[a], n = i >> 16 & 255, c = i >> 8 & 255, l = 255 & i, p = Ot(l, c, n), o = p in e ? e[p] : e[p] = dt();
413
- o.rc += l, o.gc += c, o.bc += n, o.cnt++;
404
+ else if (e === "rgb444") for (let a = 0; a < r; ++a) {
405
+ let i = o[a], s = i >> 16 & 255, c = i >> 8 & 255, l = 255 & i, p = Te(l, c, s), n = p in t ? t[p] : t[p] = de();
406
+ n.rc += l, n.gc += c, n.bc += s, n.cnt++;
414
407
  }
415
408
  else for (let a = 0; a < r; ++a) {
416
- let i = s[a], n = i >> 16 & 255, c = i >> 8 & 255, l = 255 & i, p = Vt(l, c, n), o = p in e ? e[p] : e[p] = dt();
417
- o.rc += l, o.gc += c, o.bc += n, o.cnt++;
409
+ let i = o[a], s = i >> 16 & 255, c = i >> 8 & 255, l = 255 & i, p = Ve(l, c, s), n = p in t ? t[p] : t[p] = de();
410
+ n.rc += l, n.gc += c, n.bc += s, n.cnt++;
418
411
  }
419
- return e;
412
+ return t;
420
413
  }
421
- function ae(s, t, e) {
422
- let { format: r = "rgb565", clearAlpha: a = !0, clearAlphaColor: i = 0, clearAlphaThreshold: n = 0, oneBitAlpha: c = !1 } = e || {}, l = e.useSqrt !== !1, p = r === "rgba4444", o = re(s, r), d = o.length, u = d - 1, m = new Uint32Array(d + 1);
423
- for (var x = 0, h = 0; h < o.length; ++h) {
424
- let k = o[h];
414
+ function it(o, e, t) {
415
+ let { format: r = "rgb565", clearAlpha: a = !0, clearAlphaColor: i = 0, clearAlphaThreshold: s = 0, oneBitAlpha: c = !1 } = t || {}, l = t.useSqrt !== !1, p = r === "rgba4444", n = at(o, r), d = n.length, u = d - 1, m = new Uint32Array(d + 1);
416
+ for (var x = 0, h = 0; h < n.length; ++h) {
417
+ let k = n[h];
425
418
  if (k != null) {
426
- var f = 1 / k.cnt;
427
- p && (k.ac *= f), k.rc *= f, k.gc *= f, k.bc *= f, o[x++] = k;
419
+ var g = 1 / k.cnt;
420
+ p && (k.ac *= g), k.rc *= g, k.gc *= g, k.bc *= g, n[x++] = k;
428
421
  }
429
422
  }
430
- for (at(t) / x < 0.022 && (l = !1), h = 0; h < x - 1; ++h) o[h].fw = h + 1, o[h + 1].bk = h, l && (o[h].cnt = Math.sqrt(o[h].cnt));
431
- var _, v, g;
432
- for (l && (o[h].cnt = Math.sqrt(o[h].cnt)), h = 0; h < x; ++h) {
433
- yt(o, h);
434
- var C = o[h].err;
435
- for (v = ++m[0]; v > 1 && !(o[_ = m[g = v >> 1]].err <= C); v = g) m[v] = _;
423
+ for (ae(e) / x < 0.022 && (l = !1), h = 0; h < x - 1; ++h) n[h].fw = h + 1, n[h + 1].bk = h, l && (n[h].cnt = Math.sqrt(n[h].cnt));
424
+ var _, v, f;
425
+ for (l && (n[h].cnt = Math.sqrt(n[h].cnt)), h = 0; h < x; ++h) {
426
+ ye(n, h);
427
+ var C = n[h].err;
428
+ for (v = ++m[0]; v > 1 && !(n[_ = m[f = v >> 1]].err <= C); v = f) m[v] = _;
436
429
  m[v] = h;
437
430
  }
438
- var S = x - t;
439
- for (h = 0; h < S; ) {
431
+ var F = x - e;
432
+ for (h = 0; h < F; ) {
440
433
  for (var E; ; ) {
441
434
  var A = m[1];
442
- if ((E = o[A]).tm >= E.mtm && o[E.nn].mtm <= E.tm) break;
443
- for (E.mtm == u ? A = m[1] = m[m[0]--] : (yt(o, A), E.tm = h), C = o[A].err, v = 1; (g = v + v) <= m[0] && (g < m[0] && o[m[g]].err > o[m[g + 1]].err && g++, !(C <= o[_ = m[g]].err)); v = g) m[v] = _;
435
+ if ((E = n[A]).tm >= E.mtm && n[E.nn].mtm <= E.tm) break;
436
+ for (E.mtm == u ? A = m[1] = m[m[0]--] : (ye(n, A), E.tm = h), C = n[A].err, v = 1; (f = v + v) <= m[0] && (f < m[0] && n[m[f]].err > n[m[f + 1]].err && f++, !(C <= n[_ = m[f]].err)); v = f) m[v] = _;
444
437
  m[v] = A;
445
438
  }
446
- var L = o[E.nn], V = E.cnt, B = L.cnt;
447
- f = 1 / (V + B), p && (E.ac = f * (V * E.ac + B * L.ac)), E.rc = f * (V * E.rc + B * L.rc), E.gc = f * (V * E.gc + B * L.gc), E.bc = f * (V * E.bc + B * L.bc), E.cnt += L.cnt, E.mtm = ++h, o[L.bk].fw = L.fw, o[L.fw].bk = L.bk, L.mtm = u;
439
+ var L = n[E.nn], V = E.cnt, B = L.cnt;
440
+ g = 1 / (V + B), p && (E.ac = g * (V * E.ac + B * L.ac)), E.rc = g * (V * E.rc + B * L.rc), E.gc = g * (V * E.gc + B * L.gc), E.bc = g * (V * E.bc + B * L.bc), E.cnt += L.cnt, E.mtm = ++h, n[L.bk].fw = L.fw, n[L.fw].bk = L.bk, L.mtm = u;
448
441
  }
449
442
  let D = [];
450
- var O = 0;
451
- for (h = 0; ; ++O) {
452
- let k = tt(Math.round(o[h].rc), 0, 255), R = tt(Math.round(o[h].gc), 0, 255), y = tt(Math.round(o[h].bc), 0, 255), w = 255;
453
- p && (w = tt(Math.round(o[h].ac), 0, 255), c && (w = w <= (typeof c == "number" ? c : 127) ? 0 : 255), a && w <= n && (k = R = y = i, w = 0));
454
- let F = p ? [k, R, y, w] : [k, R, y];
455
- if (ie(D, F) || D.push(F), (h = o[h].fw) == 0) break;
443
+ var T = 0;
444
+ for (h = 0; ; ++T) {
445
+ let k = ee(Math.round(n[h].rc), 0, 255), R = ee(Math.round(n[h].gc), 0, 255), y = ee(Math.round(n[h].bc), 0, 255), w = 255;
446
+ p && (w = ee(Math.round(n[h].ac), 0, 255), c && (w = w <= (typeof c == "number" ? c : 127) ? 0 : 255), a && w <= s && (k = R = y = i, w = 0));
447
+ let S = p ? [k, R, y, w] : [k, R, y];
448
+ if (ot(D, S) || D.push(S), (h = n[h].fw) == 0) break;
456
449
  }
457
450
  return D;
458
451
  }
459
- function ie(s, t) {
460
- for (let e = 0; e < s.length; e++) {
461
- let r = s[e], a = r[0] === t[0] && r[1] === t[1] && r[2] === t[2], i = !(r.length >= 4 && t.length >= 4) || r[3] === t[3];
452
+ function ot(o, e) {
453
+ for (let t = 0; t < o.length; t++) {
454
+ let r = o[t], a = r[0] === e[0] && r[1] === e[1] && r[2] === e[2], i = !(r.length >= 4 && e.length >= 4) || r[3] === e[3];
462
455
  if (a && i) return !0;
463
456
  }
464
457
  return !1;
465
458
  }
466
- function oe(s, t, e) {
467
- let r = (e = e || "rgb565") === "rgb444" ? 4096 : 65536, a = new Uint8Array(s.length), i = new Array(r);
468
- if (e === "rgba4444") for (let n = 0; n < s.length; n++) {
469
- let c, l = s[n], p = l >> 24 & 255, o = l >> 16 & 255, d = l >> 8 & 255, u = 255 & l, m = Tt(u, d, o, p);
470
- i[m] != null ? c = i[m] : (c = ne(u, d, o, p, t), i[m] = c), a[n] = c;
459
+ function nt(o, e, t) {
460
+ let r = (t = t || "rgb565") === "rgb444" ? 4096 : 65536, a = new Uint8Array(o.length), i = new Array(r);
461
+ if (t === "rgba4444") for (let s = 0; s < o.length; s++) {
462
+ let c, l = o[s], p = l >> 24 & 255, n = l >> 16 & 255, d = l >> 8 & 255, u = 255 & l, m = Oe(u, d, n, p);
463
+ i[m] != null ? c = i[m] : (c = st(u, d, n, p, e), i[m] = c), a[s] = c;
471
464
  }
472
- else for (let n = 0; n < s.length; n++) {
473
- let c, l = s[n], p = l >> 16 & 255, o = l >> 8 & 255, d = 255 & l, u = e === "rgb444" ? Ot(d, o, p) : Vt(d, o, p);
474
- i[u] != null ? c = i[u] : (c = se(d, o, p, t), i[u] = c), a[n] = c;
465
+ else for (let s = 0; s < o.length; s++) {
466
+ let c, l = o[s], p = l >> 16 & 255, n = l >> 8 & 255, d = 255 & l, u = t === "rgb444" ? Te(d, n, p) : Ve(d, n, p);
467
+ i[u] != null ? c = i[u] : (c = lt(d, n, p, e), i[u] = c), a[s] = c;
475
468
  }
476
469
  return a;
477
470
  }
478
- function ne(s, t, e, r, a) {
479
- let i = 0, n = 1e100;
471
+ function st(o, e, t, r, a) {
472
+ let i = 0, s = 1e100;
480
473
  for (let c = 0; c < a.length; c++) {
481
- let l = a[c], p = l[0], o = l[1], d = l[2], u = W(l[3] - r);
482
- u > n || (u += W(p - s), !(u > n) && (u += W(o - t), !(u > n) && (u += W(d - e), !(u > n) && (n = u, i = c))));
474
+ let l = a[c], p = l[0], n = l[1], d = l[2], u = W(l[3] - r);
475
+ u > s || (u += W(p - o), !(u > s) && (u += W(n - e), !(u > s) && (u += W(d - t), !(u > s) && (s = u, i = c))));
483
476
  }
484
477
  return i;
485
478
  }
486
- function se(s, t, e, r) {
479
+ function lt(o, e, t, r) {
487
480
  let a = 0, i = 1e100;
488
- for (let n = 0; n < r.length; n++) {
489
- let c = r[n], l = c[0], p = c[1], o = c[2], d = W(l - s);
490
- d > i || (d += W(p - t), !(d > i) && (d += W(o - e), !(d > i) && (i = d, a = n)));
481
+ for (let s = 0; s < r.length; s++) {
482
+ let c = r[s], l = c[0], p = c[1], n = c[2], d = W(l - o);
483
+ d > i || (d += W(p - e), !(d > i) && (d += W(n - t), !(d > i) && (i = d, a = s)));
491
484
  }
492
485
  return a;
493
486
  }
494
- function W(s) {
495
- return s * s;
487
+ function W(o) {
488
+ return o * o;
496
489
  }
497
- function le(s = {}) {
498
- let { initialCapacity: t = 4096, auto: e = !0 } = s, r = Dt(t), a = new Uint8Array(256), i = new Int32Array(5003), n = new Int32Array(5003), c = !1;
490
+ function dt(o = {}) {
491
+ let { initialCapacity: e = 4096, auto: t = !0 } = o, r = De(e), a = new Uint8Array(256), i = new Int32Array(5003), s = new Int32Array(5003), c = !1;
499
492
  return { reset() {
500
493
  r.reset(), c = !1;
501
494
  }, finish() {
502
- r.writeByte(Kt.trailer);
495
+ r.writeByte(Ze.trailer);
503
496
  }, bytes: () => r.bytes(), bytesView: () => r.bytesView(), get buffer() {
504
497
  return r.buffer;
505
498
  }, get stream() {
506
499
  return r;
507
- }, writeHeader: l, writeFrame(p, o, d, u = {}) {
508
- let { transparent: m = !1, transparentIndex: x = 0, delay: h = 0, palette: f = null, repeat: _ = 0, colorDepth: v = 8, dispose: g = -1 } = u, C = !1;
509
- if (e ? c || (C = !0, l(), c = !0) : C = !!u.first, o = Math.max(0, Math.floor(o)), d = Math.max(0, Math.floor(d)), C) {
510
- if (!f) throw new Error("First frame must include a { palette } option");
511
- ce(r, o, d, f, v), _t(r, f), _ >= 0 && ue(r, _);
500
+ }, writeHeader: l, writeFrame(p, n, d, u = {}) {
501
+ let { transparent: m = !1, transparentIndex: x = 0, delay: h = 0, palette: g = null, repeat: _ = 0, colorDepth: v = 8, dispose: f = -1 } = u, C = !1;
502
+ if (t ? c || (C = !0, l(), c = !0) : C = !!u.first, n = Math.max(0, Math.floor(n)), d = Math.max(0, Math.floor(d)), C) {
503
+ if (!g) throw new Error("First frame must include a { palette } option");
504
+ ut(r, n, d, g, v), _e(r, g), _ >= 0 && pt(r, _);
512
505
  }
513
- let S = Math.round(h / 10);
514
- de(r, g, S, m, x);
515
- let E = !!f && !C;
516
- pe(r, o, d, E ? f : null), E && _t(r, f), he(r, p, o, d, v, a, i, n);
506
+ let F = Math.round(h / 10);
507
+ ct(r, f, F, m, x);
508
+ let E = !!g && !C;
509
+ ht(r, n, d, E ? g : null), E && _e(r, g), mt(r, p, n, d, v, a, i, s);
517
510
  } };
518
511
  function l() {
519
- Rt(r, "GIF89a");
512
+ Re(r, "GIF89a");
520
513
  }
521
514
  }
522
- function de(s, t, e, r, a) {
523
- var i, n;
524
- s.writeByte(33), s.writeByte(249), s.writeByte(4), a < 0 && (a = 0, r = !1), r ? (i = 1, n = 2) : (i = 0, n = 0), t >= 0 && (n = 7 & t), n <<= 2, s.writeByte(0 | n | i), N(s, e), s.writeByte(a || 0), s.writeByte(0);
515
+ function ct(o, e, t, r, a) {
516
+ var i, s;
517
+ o.writeByte(33), o.writeByte(249), o.writeByte(4), a < 0 && (a = 0, r = !1), r ? (i = 1, s = 2) : (i = 0, s = 0), e >= 0 && (s = 7 & e), s <<= 2, o.writeByte(0 | s | i), N(o, t), o.writeByte(a || 0), o.writeByte(0);
525
518
  }
526
- function ce(s, t, e, r, a = 8) {
527
- let i = 128 | a - 1 << 4 | ht(r.length) - 1;
528
- N(s, t), N(s, e), s.writeBytes([i, 0, 0]);
519
+ function ut(o, e, t, r, a = 8) {
520
+ let i = 128 | a - 1 << 4 | he(r.length) - 1;
521
+ N(o, e), N(o, t), o.writeBytes([i, 0, 0]);
529
522
  }
530
- function ue(s, t) {
531
- s.writeByte(33), s.writeByte(255), s.writeByte(11), Rt(s, "NETSCAPE2.0"), s.writeByte(3), s.writeByte(1), N(s, t), s.writeByte(0);
523
+ function pt(o, e) {
524
+ o.writeByte(33), o.writeByte(255), o.writeByte(11), Re(o, "NETSCAPE2.0"), o.writeByte(3), o.writeByte(1), N(o, e), o.writeByte(0);
532
525
  }
533
- function _t(s, t) {
534
- let e = 1 << ht(t.length);
535
- for (let r = 0; r < e; r++) {
526
+ function _e(o, e) {
527
+ let t = 1 << he(e.length);
528
+ for (let r = 0; r < t; r++) {
536
529
  let a = [0, 0, 0];
537
- r < t.length && (a = t[r]), s.writeByte(a[0]), s.writeByte(a[1]), s.writeByte(a[2]);
530
+ r < e.length && (a = e[r]), o.writeByte(a[0]), o.writeByte(a[1]), o.writeByte(a[2]);
538
531
  }
539
532
  }
540
- function pe(s, t, e, r) {
541
- if (s.writeByte(44), N(s, 0), N(s, 0), N(s, t), N(s, e), r) {
542
- let a = 0, i = 0, n = ht(r.length) - 1;
543
- s.writeByte(128 | a | i | n);
544
- } else s.writeByte(0);
533
+ function ht(o, e, t, r) {
534
+ if (o.writeByte(44), N(o, 0), N(o, 0), N(o, e), N(o, t), r) {
535
+ let a = 0, i = 0, s = he(r.length) - 1;
536
+ o.writeByte(128 | a | i | s);
537
+ } else o.writeByte(0);
545
538
  }
546
- function he(s, t, e, r, a = 8, i, n, c) {
547
- ee(e, r, t, a, s, i, n, c);
539
+ function mt(o, e, t, r, a = 8, i, s, c) {
540
+ rt(t, r, e, a, o, i, s, c);
548
541
  }
549
- function N(s, t) {
550
- s.writeByte(255 & t), s.writeByte(t >> 8 & 255);
542
+ function N(o, e) {
543
+ o.writeByte(255 & e), o.writeByte(e >> 8 & 255);
551
544
  }
552
- function Rt(s, t) {
553
- for (var e = 0; e < t.length; e++) s.writeByte(t.charCodeAt(e));
545
+ function Re(o, e) {
546
+ for (var t = 0; t < e.length; t++) o.writeByte(e.charCodeAt(t));
554
547
  }
555
- function ht(s) {
556
- return Math.max(Math.ceil(Math.log2(s)), 1);
548
+ function he(o) {
549
+ return Math.max(Math.ceil(Math.log2(o)), 1);
557
550
  }
558
- Jt();
559
- class me {
551
+ Ke();
552
+ class ft {
560
553
  _recorder;
561
554
  _textmodifier;
562
555
  _registerPostDrawHook;
563
- constructor(t, e) {
564
- this._recorder = new jt(), this._textmodifier = t, this._registerPostDrawHook = e;
556
+ constructor(e, t) {
557
+ this._recorder = new Qe(), this._textmodifier = e, this._registerPostDrawHook = t;
565
558
  }
566
- async $saveGIF(t = {}) {
567
- const e = this._textmodifier.canvas, r = this._applyDefaultOptions(t), a = t.onProgress;
559
+ async $saveGIF(e = {}) {
560
+ const t = this._textmodifier.canvas, r = this._applyDefaultOptions(e), a = e.onProgress;
568
561
  try {
569
- const i = await this._recorder.$record(e, r, this._registerPostDrawHook, a), n = le(), { repeat: c } = t;
570
- i.forEach((o, d) => {
571
- const { width: u, height: m, imageData: x, delayMs: h } = o, f = new Uint32Array(x.data.buffer.slice(0)), _ = ae(f, 256, {}), v = oe(f, _);
572
- n.writeFrame(v, u, m, { palette: _, delay: h, repeat: d === 0 ? c : -1 });
573
- }), n.finish();
574
- const l = n.bytes(), p = l.buffer.slice(l.byteOffset, l.byteOffset + l.byteLength);
562
+ const i = await this._recorder.$record(t, r, this._registerPostDrawHook, a), s = dt(), { repeat: c } = e;
563
+ for (let n = 0; n < i.length; n++) {
564
+ const d = i[n], { width: u, height: m, imageData: x, delayMs: h } = d, g = new Uint32Array(x.data.buffer), _ = it(g, 256, {}), v = nt(g, _);
565
+ s.writeFrame(v, u, m, { palette: _, delay: h, repeat: n === 0 ? c : -1 }), n % 2 != 0 && n !== i.length - 1 || (a?.({ state: "encoding", frameIndex: n + 1, totalFrames: i.length }), await new Promise((f) => setTimeout(f, 0)));
566
+ }
567
+ s.finish();
568
+ const l = s.bytes(), p = l.buffer.slice(l.byteOffset, l.byteOffset + l.byteLength);
575
569
  new Q().$downloadFile(new Blob([p], { type: "image/gif" }), r.filename), a?.({ state: "completed", totalFrames: r.frameCount });
576
570
  } catch (i) {
577
571
  throw a?.({ state: "error", message: i instanceof Error ? i.message : "GIF export failed" }), i;
578
572
  }
579
573
  }
580
- _applyDefaultOptions(t) {
581
- const e = Math.abs(Math.round(t.frameCount ?? 300)), r = Math.abs(t.frameRate ?? 60), a = Math.abs(t.scale ?? 1), i = Math.max(-1, Math.round(t.repeat ?? 0));
582
- return { filename: t.filename, frameCount: e, frameRate: r, scale: a, repeat: i };
574
+ _applyDefaultOptions(e) {
575
+ const t = Math.abs(Math.round(e.frameCount ?? 300)), r = Math.abs(e.frameRate ?? 60), a = Math.abs(e.scale ?? 1), i = Math.max(-1, Math.round(e.repeat ?? 0));
576
+ return { filename: e.filename, frameCount: t, frameRate: r, scale: a, repeat: i };
583
577
  }
584
578
  }
585
- function fe(s) {
586
- return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
579
+ function gt(o) {
580
+ return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
587
581
  }
588
- var wt, Ct = { exports: {} };
589
- function ge() {
590
- return wt || (wt = 1, s = Ct, (function() {
591
- function t(l, p) {
592
- return (function(o) {
593
- if (typeof o != "string" || !o.match(/^data:image\/webp;base64,/i)) throw new Error("Failed to decode WebP Base64 URL");
594
- return window.atob(o.substring(23));
582
+ var we, Ce = { exports: {} };
583
+ function bt() {
584
+ return we || (we = 1, o = Ce, (function() {
585
+ function e(l, p) {
586
+ return (function(n) {
587
+ if (typeof n != "string" || !n.match(/^data:image\/webp;base64,/i)) throw new Error("Failed to decode WebP Base64 URL");
588
+ return window.atob(n.substring(23));
595
589
  })(typeof l == "string" && /^data:image\/webp/.test(l) ? l : l.toDataURL("image/webp", p));
596
590
  }
597
- function e(l) {
591
+ function t(l) {
598
592
  return (l.charCodeAt(0) | l.charCodeAt(1) << 8 | l.charCodeAt(2) << 16 | l.charCodeAt(3) << 24) >>> 0;
599
593
  }
600
594
  function r(l) {
601
595
  let p = l.indexOf("VP8", 12);
602
596
  if (p === -1) throw new Error("Bad image format, does this browser support WebP?");
603
- let o = !1;
597
+ let n = !1;
604
598
  for (; p < l.length - 8; ) {
605
599
  let d, u;
606
- switch (u = l.substring(p, p + 4), p += 4, d = e(l.substring(p, p + 4)), p += 4, u) {
600
+ switch (u = l.substring(p, p + 4), p += 4, d = t(l.substring(p, p + 4)), p += 4, u) {
607
601
  case "VP8 ":
608
- return { frame: l.substring(p, p + d), hasAlpha: o };
602
+ return { frame: l.substring(p, p + d), hasAlpha: n };
609
603
  case "ALPH":
610
- o = !0;
604
+ n = !0;
611
605
  }
612
606
  p += d, 1 & d && p++;
613
607
  }
@@ -619,32 +613,32 @@ function ge() {
619
613
  function i(l) {
620
614
  this.value = l;
621
615
  }
622
- function n(l, p, o) {
623
- if (Array.isArray(o)) for (let d = 0; d < o.length; d++) n(l, p, o[d]);
624
- else if (typeof o == "string") l.writeString(o);
625
- else if (o instanceof Uint8Array) l.writeBytes(o);
616
+ function s(l, p, n) {
617
+ if (Array.isArray(n)) for (let d = 0; d < n.length; d++) s(l, p, n[d]);
618
+ else if (typeof n == "string") l.writeString(n);
619
+ else if (n instanceof Uint8Array) l.writeBytes(n);
626
620
  else {
627
- if (!o.id) throw new Error("Bad EBML datatype " + typeof o.data);
628
- if (o.offset = l.pos + p, l.writeUnsignedIntBE(o.id), Array.isArray(o.data)) {
621
+ if (!n.id) throw new Error("Bad EBML datatype " + typeof n.data);
622
+ if (n.offset = l.pos + p, l.writeUnsignedIntBE(n.id), Array.isArray(n.data)) {
629
623
  let d, u, m;
630
- o.size === -1 ? l.writeByte(255) : o.size === -2 ? (d = l.pos, l.writeBytes([15, 255, 255, 255, 255])) : (d = l.pos, l.writeBytes([0, 0, 0, 0])), u = l.pos, o.dataOffset = u + p, n(l, p, o.data), o.size !== -1 && o.size !== -2 && (m = l.pos, o.size = m - u, l.seek(d), l.writeEBMLVarIntWidth(o.size, 4), l.seek(m));
631
- } else if (typeof o.data == "string") l.writeEBMLVarInt(o.data.length), o.dataOffset = l.pos + p, l.writeString(o.data);
632
- else if (typeof o.data == "number") o.size || (o.size = l.measureUnsignedInt(o.data)), l.writeEBMLVarInt(o.size), o.dataOffset = l.pos + p, l.writeUnsignedIntBE(o.data, o.size);
633
- else if (o.data instanceof i) l.writeEBMLVarInt(8), o.dataOffset = l.pos + p, l.writeDoubleBE(o.data.value);
634
- else if (o.data instanceof a) l.writeEBMLVarInt(4), o.dataOffset = l.pos + p, l.writeFloatBE(o.data.value);
624
+ n.size === -1 ? l.writeByte(255) : n.size === -2 ? (d = l.pos, l.writeBytes([15, 255, 255, 255, 255])) : (d = l.pos, l.writeBytes([0, 0, 0, 0])), u = l.pos, n.dataOffset = u + p, s(l, p, n.data), n.size !== -1 && n.size !== -2 && (m = l.pos, n.size = m - u, l.seek(d), l.writeEBMLVarIntWidth(n.size, 4), l.seek(m));
625
+ } else if (typeof n.data == "string") l.writeEBMLVarInt(n.data.length), n.dataOffset = l.pos + p, l.writeString(n.data);
626
+ else if (typeof n.data == "number") n.size || (n.size = l.measureUnsignedInt(n.data)), l.writeEBMLVarInt(n.size), n.dataOffset = l.pos + p, l.writeUnsignedIntBE(n.data, n.size);
627
+ else if (n.data instanceof i) l.writeEBMLVarInt(8), n.dataOffset = l.pos + p, l.writeDoubleBE(n.data.value);
628
+ else if (n.data instanceof a) l.writeEBMLVarInt(4), n.dataOffset = l.pos + p, l.writeFloatBE(n.data.value);
635
629
  else {
636
- if (!(o.data instanceof Uint8Array)) throw new Error("Bad EBML datatype " + typeof o.data);
637
- l.writeEBMLVarInt(o.data.byteLength), o.dataOffset = l.pos + p, l.writeBytes(o.data);
630
+ if (!(n.data instanceof Uint8Array)) throw new Error("Bad EBML datatype " + typeof n.data);
631
+ l.writeEBMLVarInt(n.data.byteLength), n.dataOffset = l.pos + p, l.writeBytes(n.data);
638
632
  }
639
633
  }
640
634
  }
641
635
  let c = function(l, p) {
642
- return function(o) {
643
- let d, u, m = !1, x = 0, h = 0, f = null, _ = null, v = null, g = [], C = 0, S = 0, E = { quality: 0.95, transparent: !1, alphaQuality: void 0, fileWriter: null, fd: null, frameDuration: null, frameRate: null }, A = { Cues: { id: new Uint8Array([28, 83, 187, 107]), positionEBML: null }, SegmentInfo: { id: new Uint8Array([21, 73, 169, 102]), positionEBML: null }, Tracks: { id: new Uint8Array([22, 84, 174, 107]), positionEBML: null } }, L = { id: 17545, data: new i(0) }, V = [], B = new p(o.fileWriter || o.fd);
636
+ return function(n) {
637
+ let d, u, m = !1, x = 0, h = 0, g = null, _ = null, v = null, f = [], C = 0, F = 0, E = { quality: 0.95, transparent: !1, alphaQuality: void 0, fileWriter: null, fd: null, frameDuration: null, frameRate: null }, A = { Cues: { id: new Uint8Array([28, 83, 187, 107]), positionEBML: null }, SegmentInfo: { id: new Uint8Array([21, 73, 169, 102]), positionEBML: null }, Tracks: { id: new Uint8Array([22, 84, 174, 107]), positionEBML: null } }, L = { id: 17545, data: new i(0) }, V = [], B = new p(n.fileWriter || n.fd);
644
638
  function D(y) {
645
639
  return y - d.dataOffset;
646
640
  }
647
- function O() {
641
+ function T() {
648
642
  u = (function() {
649
643
  let M = { id: 21420, size: 5, data: 0 }, U = { id: 290298740, data: [] };
650
644
  for (let I in A) {
@@ -654,55 +648,55 @@ function ge() {
654
648
  return U;
655
649
  })();
656
650
  let y = { id: 357149030, data: [{ id: 2807729, data: 1e6 }, { id: 19840, data: "webm-writer-js" }, { id: 22337, data: "webm-writer-js" }, L] }, w = [{ id: 176, data: x }, { id: 186, data: h }];
657
- o.transparent && w.push({ id: 21440, data: 1 });
658
- let F = { id: 374648427, data: [{ id: 174, data: [{ id: 215, data: 1 }, { id: 29637, data: 1 }, { id: 156, data: 0 }, { id: 2274716, data: "und" }, { id: 134, data: "V_VP8" }, { id: 2459272, data: "VP8" }, { id: 131, data: 1 }, { id: 224, data: w }] }] };
659
- d = { id: 408125543, size: -2, data: [u, y, F] };
651
+ n.transparent && w.push({ id: 21440, data: 1 });
652
+ let S = { id: 374648427, data: [{ id: 174, data: [{ id: 215, data: 1 }, { id: 29637, data: 1 }, { id: 156, data: 0 }, { id: 2274716, data: "und" }, { id: 134, data: "V_VP8" }, { id: 2459272, data: "VP8" }, { id: 131, data: 1 }, { id: 224, data: w }] }] };
653
+ d = { id: 408125543, size: -2, data: [u, y, S] };
660
654
  let $ = new l(256);
661
- n($, B.pos, [{ id: 440786851, data: [{ id: 17030, data: 1 }, { id: 17143, data: 1 }, { id: 17138, data: 4 }, { id: 17139, data: 8 }, { id: 17026, data: "webm" }, { id: 17031, data: 2 }, { id: 17029, data: 2 }] }, d]), B.write($.getAsDataArray()), A.SegmentInfo.positionEBML.data = D(y.offset), A.Tracks.positionEBML.data = D(F.offset), m = !0;
655
+ s($, B.pos, [{ id: 440786851, data: [{ id: 17030, data: 1 }, { id: 17143, data: 1 }, { id: 17138, data: 4 }, { id: 17139, data: 8 }, { id: 17026, data: "webm" }, { id: 17031, data: 2 }, { id: 17029, data: 2 }] }, d]), B.write($.getAsDataArray()), A.SegmentInfo.positionEBML.data = D(y.offset), A.Tracks.positionEBML.data = D(S.offset), m = !0;
662
656
  }
663
657
  function k(y) {
664
658
  return y.alpha ? (function(w) {
665
- let F, $, M = new l(4);
659
+ let S, $, M = new l(4);
666
660
  if (!(w.trackNumber > 0 && w.trackNumber < 127)) throw new Error("TrackNumber must be > 0 and < 127");
667
- return M.writeEBMLVarInt(w.trackNumber), M.writeU16BE(w.timecode), M.writeByte(0), F = { id: 161, data: [M.getAsDataArray(), w.frame] }, $ = { id: 30113, data: [{ id: 166, data: [{ id: 238, data: 1 }, { id: 165, data: w.alpha }] }] }, { id: 160, data: [F, $] };
661
+ return M.writeEBMLVarInt(w.trackNumber), M.writeU16BE(w.timecode), M.writeByte(0), S = { id: 161, data: [M.getAsDataArray(), w.frame] }, $ = { id: 30113, data: [{ id: 166, data: [{ id: 238, data: 1 }, { id: 165, data: w.alpha }] }] }, { id: 160, data: [S, $] };
668
662
  })(y) : (function(w) {
669
- let F = new l(4);
663
+ let S = new l(4);
670
664
  if (!(w.trackNumber > 0 && w.trackNumber < 127)) throw new Error("TrackNumber must be > 0 and < 127");
671
- return F.writeEBMLVarInt(w.trackNumber), F.writeU16BE(w.timecode), F.writeByte(128), { id: 163, data: [F.getAsDataArray(), w.frame] };
665
+ return S.writeEBMLVarInt(w.trackNumber), S.writeU16BE(w.timecode), S.writeByte(128), { id: 163, data: [S.getAsDataArray(), w.frame] };
672
666
  })(y);
673
667
  }
674
668
  function R() {
675
- if (g.length === 0) return;
669
+ if (f.length === 0) return;
676
670
  let y = 0;
677
- for (let I = 0; I < g.length; I++) y += g[I].frame.length + (g[I].alpha ? g[I].alpha.length : 0);
678
- let w = new l(y + 64 * g.length), F = (function(I) {
671
+ for (let I = 0; I < f.length; I++) y += f[I].frame.length + (f[I].alpha ? f[I].alpha.length : 0);
672
+ let w = new l(y + 64 * f.length), S = (function(I) {
679
673
  return { id: 524531317, data: [{ id: 231, data: Math.round(I.timecode) }] };
680
674
  })({ timecode: Math.round(C) });
681
- for (let I = 0; I < g.length; I++) F.data.push(k(g[I]));
675
+ for (let I = 0; I < f.length; I++) S.data.push(k(f[I]));
682
676
  var $, M, U;
683
- n(w, B.pos, F), B.write(w.getAsDataArray()), $ = 1, M = Math.round(C), U = F.offset, V.push({ id: 187, data: [{ id: 179, data: M }, { id: 183, data: [{ id: 247, data: $ }, { id: 241, data: D(U) }] }] }), g = [], C += S, S = 0;
677
+ s(w, B.pos, S), B.write(w.getAsDataArray()), $ = 1, M = Math.round(C), U = S.offset, V.push({ id: 187, data: [{ id: 179, data: M }, { id: 183, data: [{ id: 247, data: $ }, { id: 241, data: D(U) }] }] }), f = [], C += F, F = 0;
684
678
  }
685
- this.addFrame = function(y, w, F) {
686
- m || (x = y.width || 0, h = y.height || 0, O());
687
- let $, M = r(t(y, o.quality)), U = null;
688
- $ = F || (typeof w == "number" ? w : o.frameDuration), o.transparent && (w instanceof HTMLCanvasElement || typeof w == "string" ? U = w : M.hasAlpha && (U = (function(I) {
689
- f !== null && f.width === I.width && f.height === I.height || (f = document.createElement("canvas"), f.width = I.width, f.height = I.height, _ = f.getContext("2d"), v = _.createImageData(f.width, f.height));
690
- let q = I.getContext("2d").getImageData(0, 0, I.width, I.height).data, J = v.data, K = 0, zt = I.width * I.height * 4;
691
- for (let ot = 3; ot < zt; ot += 4) {
692
- let nt = q[ot];
693
- J[K++] = nt, J[K++] = nt, J[K++] = nt, J[K++] = 255;
679
+ this.addFrame = function(y, w, S) {
680
+ m || (x = y.width || 0, h = y.height || 0, T());
681
+ let $, M = r(e(y, n.quality)), U = null;
682
+ $ = S || (typeof w == "number" ? w : n.frameDuration), n.transparent && (w instanceof HTMLCanvasElement || typeof w == "string" ? U = w : M.hasAlpha && (U = (function(I) {
683
+ g !== null && g.width === I.width && g.height === I.height || (g = document.createElement("canvas"), g.width = I.width, g.height = I.height, _ = g.getContext("2d"), v = _.createImageData(g.width, g.height));
684
+ let q = I.getContext("2d").getImageData(0, 0, I.width, I.height).data, J = v.data, K = 0, We = I.width * I.height * 4;
685
+ for (let oe = 3; oe < We; oe += 4) {
686
+ let ne = q[oe];
687
+ J[K++] = ne, J[K++] = ne, J[K++] = ne, J[K++] = 255;
694
688
  }
695
- return _.putImageData(v, 0, 0), f;
689
+ return _.putImageData(v, 0, 0), g;
696
690
  })(y))), (function(I) {
697
- I.trackNumber = 1, I.timecode = Math.round(S), g.push(I), S += I.duration, S >= 5e3 && R();
698
- })({ frame: M.frame, duration: $, alpha: U ? r(t(U, o.alphaQuality)).frame : null });
691
+ I.trackNumber = 1, I.timecode = Math.round(F), f.push(I), F += I.duration, F >= 5e3 && R();
692
+ })({ frame: M.frame, duration: $, alpha: U ? r(e(U, n.alphaQuality)).frame : null });
699
693
  }, this.complete = function() {
700
- return m || O(), R(), (function() {
694
+ return m || T(), R(), (function() {
701
695
  let y = { id: 475249515, data: V }, w = new l(16 + 32 * V.length);
702
- n(w, B.pos, y), B.write(w.getAsDataArray()), A.Cues.positionEBML.data = D(y.offset);
696
+ s(w, B.pos, y), B.write(w.getAsDataArray()), A.Cues.positionEBML.data = D(y.offset);
703
697
  })(), (function() {
704
698
  let y = new l(u.size), w = B.pos;
705
- n(y, u.dataOffset, u.data), B.seek(u.dataOffset), B.write(y.getAsDataArray()), B.seek(w);
699
+ s(y, u.dataOffset, u.data), B.seek(u.dataOffset), B.write(y.getAsDataArray()), B.seek(w);
706
700
  })(), (function() {
707
701
  let y = new l(8), w = B.pos;
708
702
  y.writeDoubleBE(C), B.seek(L.dataOffset), B.write(y.getAsDataArray()), B.seek(w);
@@ -712,107 +706,107 @@ function ge() {
712
706
  })(), B.complete("video/webm");
713
707
  }, this.getWrittenSize = function() {
714
708
  return B.length;
715
- }, o = (function(y, w) {
716
- let F = {};
709
+ }, n = (function(y, w) {
710
+ let S = {};
717
711
  return [y, w].forEach(function($) {
718
- for (let M in $) Object.prototype.hasOwnProperty.call($, M) && (F[M] = $[M]);
719
- }), F;
720
- })(E, o || {}), (function() {
721
- if (!o.frameDuration) {
722
- if (!o.frameRate) throw new Error("Missing required frameDuration or frameRate setting");
723
- o.frameDuration = 1e3 / o.frameRate;
712
+ for (let M in $) Object.prototype.hasOwnProperty.call($, M) && (S[M] = $[M]);
713
+ }), S;
714
+ })(E, n || {}), (function() {
715
+ if (!n.frameDuration) {
716
+ if (!n.frameRate) throw new Error("Missing required frameDuration or frameRate setting");
717
+ n.frameDuration = 1e3 / n.frameRate;
724
718
  }
725
- o.quality = Math.max(Math.min(o.quality, 0.99999), 0), o.alphaQuality === void 0 ? o.alphaQuality = o.quality : o.alphaQuality = Math.max(Math.min(o.alphaQuality, 0.99999), 0);
719
+ n.quality = Math.max(Math.min(n.quality, 0.99999), 0), n.alphaQuality === void 0 ? n.alphaQuality = n.quality : n.alphaQuality = Math.max(Math.min(n.alphaQuality, 0.99999), 0);
726
720
  })();
727
721
  };
728
722
  };
729
- s.exports = c;
730
- })()), Ct.exports;
731
- var s;
732
- }
733
- var Et, kt = { exports: {} };
734
- function be() {
735
- return Et || (Et = 1, s = kt, (function() {
736
- let t = function(e) {
737
- this.data = new Uint8Array(e), this.pos = 0;
723
+ o.exports = c;
724
+ })()), Ce.exports;
725
+ var o;
726
+ }
727
+ var Ee, ke = { exports: {} };
728
+ function vt() {
729
+ return Ee || (Ee = 1, o = ke, (function() {
730
+ let e = function(t) {
731
+ this.data = new Uint8Array(t), this.pos = 0;
738
732
  };
739
- t.prototype.seek = function(e) {
740
- this.pos = e;
741
- }, t.prototype.writeBytes = function(e) {
742
- for (let r = 0; r < e.length; r++) this.data[this.pos++] = e[r];
743
- }, t.prototype.writeByte = function(e) {
744
- this.data[this.pos++] = e;
745
- }, t.prototype.writeU8 = t.prototype.writeByte, t.prototype.writeU16BE = function(e) {
746
- this.data[this.pos++] = e >> 8, this.data[this.pos++] = e;
747
- }, t.prototype.writeDoubleBE = function(e) {
748
- let r = new Uint8Array(new Float64Array([e]).buffer);
733
+ e.prototype.seek = function(t) {
734
+ this.pos = t;
735
+ }, e.prototype.writeBytes = function(t) {
736
+ for (let r = 0; r < t.length; r++) this.data[this.pos++] = t[r];
737
+ }, e.prototype.writeByte = function(t) {
738
+ this.data[this.pos++] = t;
739
+ }, e.prototype.writeU8 = e.prototype.writeByte, e.prototype.writeU16BE = function(t) {
740
+ this.data[this.pos++] = t >> 8, this.data[this.pos++] = t;
741
+ }, e.prototype.writeDoubleBE = function(t) {
742
+ let r = new Uint8Array(new Float64Array([t]).buffer);
749
743
  for (let a = r.length - 1; a >= 0; a--) this.writeByte(r[a]);
750
- }, t.prototype.writeFloatBE = function(e) {
751
- let r = new Uint8Array(new Float32Array([e]).buffer);
744
+ }, e.prototype.writeFloatBE = function(t) {
745
+ let r = new Uint8Array(new Float32Array([t]).buffer);
752
746
  for (let a = r.length - 1; a >= 0; a--) this.writeByte(r[a]);
753
- }, t.prototype.writeString = function(e) {
754
- for (let r = 0; r < e.length; r++) this.data[this.pos++] = e.charCodeAt(r);
755
- }, t.prototype.writeEBMLVarIntWidth = function(e, r) {
747
+ }, e.prototype.writeString = function(t) {
748
+ for (let r = 0; r < t.length; r++) this.data[this.pos++] = t.charCodeAt(r);
749
+ }, e.prototype.writeEBMLVarIntWidth = function(t, r) {
756
750
  switch (r) {
757
751
  case 1:
758
- this.writeU8(128 | e);
752
+ this.writeU8(128 | t);
759
753
  break;
760
754
  case 2:
761
- this.writeU8(64 | e >> 8), this.writeU8(e);
755
+ this.writeU8(64 | t >> 8), this.writeU8(t);
762
756
  break;
763
757
  case 3:
764
- this.writeU8(32 | e >> 16), this.writeU8(e >> 8), this.writeU8(e);
758
+ this.writeU8(32 | t >> 16), this.writeU8(t >> 8), this.writeU8(t);
765
759
  break;
766
760
  case 4:
767
- this.writeU8(16 | e >> 24), this.writeU8(e >> 16), this.writeU8(e >> 8), this.writeU8(e);
761
+ this.writeU8(16 | t >> 24), this.writeU8(t >> 16), this.writeU8(t >> 8), this.writeU8(t);
768
762
  break;
769
763
  case 5:
770
- this.writeU8(8 | e / 4294967296 & 7), this.writeU8(e >> 24), this.writeU8(e >> 16), this.writeU8(e >> 8), this.writeU8(e);
764
+ this.writeU8(8 | t / 4294967296 & 7), this.writeU8(t >> 24), this.writeU8(t >> 16), this.writeU8(t >> 8), this.writeU8(t);
771
765
  break;
772
766
  default:
773
767
  throw new Error("Bad EBML VINT size " + r);
774
768
  }
775
- }, t.prototype.measureEBMLVarInt = function(e) {
776
- if (e < 127) return 1;
777
- if (e < 16383) return 2;
778
- if (e < 2097151) return 3;
779
- if (e < 268435455) return 4;
780
- if (e < 34359738367) return 5;
781
- throw new Error("EBML VINT size not supported " + e);
782
- }, t.prototype.writeEBMLVarInt = function(e) {
783
- this.writeEBMLVarIntWidth(e, this.measureEBMLVarInt(e));
784
- }, t.prototype.writeUnsignedIntBE = function(e, r) {
785
- switch (r === void 0 && (r = this.measureUnsignedInt(e)), r) {
769
+ }, e.prototype.measureEBMLVarInt = function(t) {
770
+ if (t < 127) return 1;
771
+ if (t < 16383) return 2;
772
+ if (t < 2097151) return 3;
773
+ if (t < 268435455) return 4;
774
+ if (t < 34359738367) return 5;
775
+ throw new Error("EBML VINT size not supported " + t);
776
+ }, e.prototype.writeEBMLVarInt = function(t) {
777
+ this.writeEBMLVarIntWidth(t, this.measureEBMLVarInt(t));
778
+ }, e.prototype.writeUnsignedIntBE = function(t, r) {
779
+ switch (r === void 0 && (r = this.measureUnsignedInt(t)), r) {
786
780
  case 5:
787
- this.writeU8(Math.floor(e / 4294967296));
781
+ this.writeU8(Math.floor(t / 4294967296));
788
782
  case 4:
789
- this.writeU8(e >> 24);
783
+ this.writeU8(t >> 24);
790
784
  case 3:
791
- this.writeU8(e >> 16);
785
+ this.writeU8(t >> 16);
792
786
  case 2:
793
- this.writeU8(e >> 8);
787
+ this.writeU8(t >> 8);
794
788
  case 1:
795
- this.writeU8(e);
789
+ this.writeU8(t);
796
790
  break;
797
791
  default:
798
792
  throw new Error("Bad UINT size " + r);
799
793
  }
800
- }, t.prototype.measureUnsignedInt = function(e) {
801
- return e < 256 ? 1 : e < 65536 ? 2 : e < 1 << 24 ? 3 : e < 4294967296 ? 4 : 5;
802
- }, t.prototype.getAsDataArray = function() {
794
+ }, e.prototype.measureUnsignedInt = function(t) {
795
+ return t < 256 ? 1 : t < 65536 ? 2 : t < 1 << 24 ? 3 : t < 4294967296 ? 4 : 5;
796
+ }, e.prototype.getAsDataArray = function() {
803
797
  if (this.pos < this.data.byteLength) return this.data.subarray(0, this.pos);
804
798
  if (this.pos == this.data.byteLength) return this.data;
805
799
  throw new Error("ArrayBufferDataStream's pos lies beyond end of buffer");
806
- }, s.exports = t;
807
- })()), kt.exports;
808
- var s;
809
- }
810
- var Bt, It, St, Ft = { exports: {} };
811
- function ve() {
812
- return Bt || (Bt = 1, s = Ft, (function() {
813
- let t = function(e) {
800
+ }, o.exports = e;
801
+ })()), ke.exports;
802
+ var o;
803
+ }
804
+ var Be, Ie, Fe, Se = { exports: {} };
805
+ function xt() {
806
+ return Be || (Be = 1, o = Se, (function() {
807
+ let e = function(t) {
814
808
  return function(r) {
815
- let a = [], i = Promise.resolve(), n = null, c = null;
809
+ let a = [], i = Promise.resolve(), s = null, c = null;
816
810
  function l(d) {
817
811
  return new Promise(function(u, m) {
818
812
  let x = new FileReader();
@@ -830,45 +824,45 @@ function ve() {
830
824
  }));
831
825
  });
832
826
  }
833
- function o(d) {
827
+ function n(d) {
834
828
  let u = d.byteLength || d.length || d.size;
835
829
  if (!Number.isInteger(u)) throw new Error("Failed to determine size of element");
836
830
  return u;
837
831
  }
838
- r && r.constructor.name === "FileWriter" ? n = r : e && r && (c = r), this.pos = 0, this.length = 0, this.seek = function(d) {
832
+ r && r.constructor.name === "FileWriter" ? s = r : t && r && (c = r), this.pos = 0, this.length = 0, this.seek = function(d) {
839
833
  if (d < 0) throw new Error("Offset may not be negative");
840
834
  if (isNaN(d)) throw new Error("Offset may not be NaN");
841
835
  if (d > this.length) throw new Error("Seeking beyond the end of file is not allowed");
842
836
  this.pos = d;
843
837
  }, this.write = function(d) {
844
- let u = { offset: this.pos, data: d, length: o(d) }, m = u.offset >= this.length;
838
+ let u = { offset: this.pos, data: d, length: n(d) }, m = u.offset >= this.length;
845
839
  this.pos += u.length, this.length = Math.max(this.length, this.pos), i = i.then(function() {
846
840
  if (c) return new Promise(function(x, h) {
847
- p(u.data).then(function(f) {
848
- let _ = 0, v = Buffer.from(f.buffer), g = function(C, S, E) {
849
- _ += S, _ >= E.length ? x() : e.write(c, E, _, E.length - _, u.offset + _, g);
841
+ p(u.data).then(function(g) {
842
+ let _ = 0, v = Buffer.from(g.buffer), f = function(C, F, E) {
843
+ _ += F, _ >= E.length ? x() : t.write(c, E, _, E.length - _, u.offset + _, f);
850
844
  };
851
- e.write(c, v, 0, v.length, u.offset, g);
845
+ t.write(c, v, 0, v.length, u.offset, f);
852
846
  });
853
847
  });
854
- if (n) return new Promise(function(x, h) {
855
- n.onwriteend = x, n.seek(u.offset), n.write(new Blob([u.data]));
848
+ if (s) return new Promise(function(x, h) {
849
+ s.onwriteend = x, s.seek(u.offset), s.write(new Blob([u.data]));
856
850
  });
857
851
  if (!m) for (let x = 0; x < a.length; x++) {
858
852
  let h = a[x];
859
853
  if (!(u.offset + u.length <= h.offset || u.offset >= h.offset + h.length)) {
860
854
  if (u.offset < h.offset || u.offset + u.length > h.offset + h.length) throw new Error("Overwrite crosses blob boundaries");
861
- return u.offset == h.offset && u.length == h.length ? void (h.data = u.data) : p(h.data).then(function(f) {
862
- return h.data = f, p(u.data);
863
- }).then(function(f) {
864
- u.data = f, h.data.set(u.data, u.offset - h.offset);
855
+ return u.offset == h.offset && u.length == h.length ? void (h.data = u.data) : p(h.data).then(function(g) {
856
+ return h.data = g, p(u.data);
857
+ }).then(function(g) {
858
+ u.data = g, h.data.set(u.data, u.offset - h.offset);
865
859
  });
866
860
  }
867
861
  }
868
862
  a.push(u);
869
863
  });
870
864
  }, this.complete = function(d) {
871
- return i = c || n ? i.then(function() {
865
+ return i = c || s ? i.then(function() {
872
866
  return null;
873
867
  }) : i.then(function() {
874
868
  let u = [];
@@ -878,87 +872,87 @@ function ve() {
878
872
  };
879
873
  };
880
874
  };
881
- s.exports = t;
882
- })()), Ft.exports;
883
- var s;
884
- }
885
- function xe() {
886
- return St ? It : (St = 1, It = ge()(be(), ve()(null)));
887
- }
888
- var ye = xe();
889
- const _e = fe(ye);
890
- class we {
891
- async $record(t, e, r, a) {
892
- const i = Math.max(1, Math.round(e.frameRate)), n = Math.max(1, Math.round(e.frameCount)), c = new _e({ quality: e.quality, alphaQuality: e.transparent ? e.quality : void 0, transparent: e.transparent, frameRate: i }), l = this._createSnapshotSurface();
893
- return await new Promise((p, o) => {
875
+ o.exports = e;
876
+ })()), Se.exports;
877
+ var o;
878
+ }
879
+ function yt() {
880
+ return Fe ? Ie : (Fe = 1, Ie = bt()(vt(), xt()(null)));
881
+ }
882
+ var _t = yt();
883
+ const wt = gt(_t);
884
+ class Ct {
885
+ async $record(e, t, r, a) {
886
+ const i = Math.max(1, Math.round(t.frameRate)), s = Math.max(1, Math.round(t.frameCount)), c = new wt({ quality: t.quality, alphaQuality: t.transparent ? t.quality : void 0, transparent: t.transparent, frameRate: i }), l = this._createSnapshotSurface();
887
+ return await new Promise((p, n) => {
894
888
  let d, u = "capturing", m = !1, x = 0;
895
889
  const h = () => {
896
890
  d && (d(), d = void 0);
897
- }, f = () => {
898
- a?.({ state: "recording", frameIndex: x, totalFrames: n });
899
- }, _ = (g) => {
891
+ }, g = () => {
892
+ a?.({ state: "recording", frameIndex: x, totalFrames: s });
893
+ }, _ = (f) => {
900
894
  if (m) return;
901
895
  m = !0, h();
902
- const C = g instanceof Error ? g.message : "WEBM export failed";
903
- a?.({ state: "error", message: C }), o(g instanceof Error ? g : new Error(String(g)));
896
+ const C = f instanceof Error ? f.message : "WEBM export failed";
897
+ a?.({ state: "error", message: C }), n(f instanceof Error ? f : new Error(String(f)));
904
898
  }, v = () => {
905
- u !== "capturing" || m || (u = "encoding", h(), c.complete().then((g) => {
899
+ u !== "capturing" || m || (u = "encoding", h(), c.complete().then((f) => {
906
900
  ((C) => {
907
- m || (m = !0, a?.({ state: "completed", frameIndex: Math.min(n, x), totalFrames: n }), p(C));
908
- })(g);
901
+ m || (m = !0, a?.({ state: "completed", frameIndex: Math.min(s, x), totalFrames: s }), p(C));
902
+ })(f);
909
903
  }).catch(_));
910
904
  };
911
905
  d = r(() => {
912
906
  (() => {
913
- if (u === "capturing") if (x >= n) v();
907
+ if (u === "capturing") if (x >= s) v();
914
908
  else try {
915
- const g = l(t);
916
- c.addFrame(g), x += 1, f(), x >= n && v();
917
- } catch (g) {
918
- _(g);
909
+ const f = l(e);
910
+ c.addFrame(f), x += 1, g(), x >= s && v();
911
+ } catch (f) {
912
+ _(f);
919
913
  }
920
914
  })();
921
- }), f();
915
+ }), g();
922
916
  });
923
917
  }
924
918
  _createSnapshotSurface() {
925
- let t = null, e = null;
919
+ let e = null, t = null;
926
920
  return (r) => {
927
- const a = Math.max(1, r.width), i = Math.max(1, r.height), n = ((c, l) => (t || (t = document.createElement("canvas")), t.width !== c || t.height !== l ? (t.width = c, t.height = l, e = t.getContext("2d"), e && (e.imageSmoothingEnabled = !1)) : e || (e = t.getContext("2d"), e && (e.imageSmoothingEnabled = !1)), e ? t : null))(a, i);
928
- return n && e ? (e.clearRect(0, 0, a, i), e.drawImage(r, 0, 0, a, i), n) : r;
921
+ const a = Math.max(1, r.width), i = Math.max(1, r.height), s = ((c, l) => (e || (e = document.createElement("canvas")), e.width !== c || e.height !== l ? (e.width = c, e.height = l, t = e.getContext("2d"), t && (t.imageSmoothingEnabled = !1)) : t || (t = e.getContext("2d"), t && (t.imageSmoothingEnabled = !1)), t ? e : null))(a, i);
922
+ return s && t ? (t.clearRect(0, 0, a, i), t.drawImage(r, 0, 0, a, i), s) : r;
929
923
  };
930
924
  }
931
925
  }
932
- class Ce {
926
+ class Et {
933
927
  _recorder;
934
928
  _textmodifier;
935
929
  _registerPostDrawHook;
936
- constructor(t, e) {
937
- this._recorder = new we(), this._textmodifier = t, this._registerPostDrawHook = e;
930
+ constructor(e, t) {
931
+ this._recorder = new Ct(), this._textmodifier = e, this._registerPostDrawHook = t;
938
932
  }
939
- async $saveWEBM(t = {}) {
940
- const e = this._textmodifier.canvas, r = this._applyDefaultOptions(t);
933
+ async $saveWEBM(e = {}) {
934
+ const t = this._textmodifier.canvas, r = this._applyDefaultOptions(e);
941
935
  try {
942
- const a = await this._recorder.$record(e, r, this._registerPostDrawHook, t.onProgress);
936
+ const a = await this._recorder.$record(t, r, this._registerPostDrawHook, e.onProgress);
943
937
  new Q().$downloadFile(a, r.filename);
944
938
  } catch (a) {
945
- throw t.onProgress?.({ state: "error", message: a instanceof Error ? a.message : "WEBM export failed" }), a;
939
+ throw e.onProgress?.({ state: "error", message: a instanceof Error ? a.message : "WEBM export failed" }), a;
946
940
  }
947
941
  }
948
- _applyDefaultOptions(t) {
949
- return { filename: t.filename, frameRate: Math.abs(Math.round(t.frameRate ?? 60)), frameCount: Math.abs(Math.round(t.frameCount ?? 300)), quality: Math.abs(Math.min(Math.max(t.quality ?? 1, 0), 1)), transparent: !!t.transparent, debugLogging: !!t.debugLogging };
942
+ _applyDefaultOptions(e) {
943
+ return { filename: e.filename, frameRate: Math.abs(Math.round(e.frameRate ?? 60)), frameCount: Math.abs(Math.round(e.frameCount ?? 300)), quality: Math.abs(Math.min(Math.max(e.quality ?? 1, 0), 1)), transparent: !!e.transparent, debugLogging: !!e.debugLogging };
950
944
  }
951
945
  }
952
946
  const b = { root: "textmode-export-overlay", stack: "textmode-export-overlay__stack", stackDense: "textmode-export-overlay__stack--dense", stackCompact: "textmode-export-overlay__stack--compact", section: "textmode-export-overlay__section", header: "textmode-export-overlay__header", headerTitleRow: "textmode-export-overlay__header-title-row", headerLinks: "textmode-export-overlay__header-links", row: "textmode-export-overlay__row", label: "textmode-export-overlay__label", field: "textmode-export-overlay__field", fieldCompact: "textmode-export-overlay__field--compact", fieldDense: "textmode-export-overlay__field--dense", fieldFull: "textmode-export-overlay__field--full", fieldChannel: "textmode-export-overlay__field--channel", input: "textmode-export-overlay__input", checkbox: "textmode-export-overlay__checkbox", muted: "textmode-export-overlay__muted", status: "textmode-export-overlay__status", statusGif: "textmode-export-overlay__status--gif", statusVideo: "textmode-export-overlay__status--video", statusTitle: "textmode-export-overlay__status-title", statusValue: "textmode-export-overlay__status-value", divider: "textmode-export-overlay__divider", title: "textmode-export-overlay__title", button: "textmode-export-overlay__button", buttonPrimary: "textmode-export-overlay__button--primary", buttonSecondary: "textmode-export-overlay__button--secondary", buttonFull: "textmode-export-overlay__button--full", supportLink: "textmode-export-overlay__support-link", supportIcon: "textmode-export-overlay__support-icon", linkIcon: "textmode-export-overlay__link-icon" };
953
- class T {
947
+ class O {
954
948
  element;
955
949
  mounted = !1;
956
950
  destroyed = !1;
957
- mount(t) {
951
+ mount(e) {
958
952
  if (this.destroyed) throw new Error("Cannot mount a destroyed component");
959
953
  if (this.mounted) return;
960
- const e = this.render();
961
- t.appendChild(e), this.element = e, this.onMount(), this.mounted = !0;
954
+ const t = this.render();
955
+ e.appendChild(t), this.element = t, this.onMount(), this.mounted = !0;
962
956
  }
963
957
  unmount() {
964
958
  this.mounted && this.element && (this._onUnmount(), this.element.remove(), this.element = void 0, this.mounted = !1);
@@ -966,8 +960,8 @@ class T {
966
960
  destroy() {
967
961
  this.destroyed || (this.unmount(), this._onDestroy(), this.destroyed = !0);
968
962
  }
969
- update(t) {
970
- this.mounted && this.onUpdate(t);
963
+ update(e) {
964
+ this.mounted && this.onUpdate(e);
971
965
  }
972
966
  onMount() {
973
967
  }
@@ -975,7 +969,7 @@ class T {
975
969
  }
976
970
  _onDestroy() {
977
971
  }
978
- onUpdate(t) {
972
+ onUpdate(e) {
979
973
  }
980
974
  get root() {
981
975
  if (!this.element) throw new Error("Component is not mounted yet");
@@ -985,92 +979,92 @@ class T {
985
979
  return this.mounted;
986
980
  }
987
981
  }
988
- class H extends T {
982
+ class H extends O {
989
983
  static _iconNamespace = "http://www.w3.org/2000/svg";
990
984
  render() {
991
- const t = document.createElement("div");
992
- t.classList.add(b.stack, b.stackDense, b.header);
993
985
  const e = document.createElement("div");
994
- e.classList.add(b.headerTitleRow);
986
+ e.classList.add(b.stack, b.stackDense, b.header);
987
+ const t = document.createElement("div");
988
+ t.classList.add(b.headerTitleRow);
995
989
  const r = document.createElement("strong");
996
990
  r.textContent = "textmode.export.js", r.classList.add(b.title);
997
991
  const a = document.createElement("div");
998
992
  a.classList.add(b.headerLinks);
999
- const i = this._createLink("https://github.com/humanbydefinition/textmode.export.js", "View repository on GitHub", b.linkIcon, [{ d: "M0 0h24v24H0z", fill: "none", stroke: "none" }, { d: "M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" }]), n = this._createLink("https://code.textmode.art/support.html", "Support textmode.export.js", b.supportIcon, [{ d: "M0 0h24v24H0z", fill: "none", stroke: "none" }, { d: "M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1" }, { d: "M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2" }, { d: "M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2" }, { d: "M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z" }, { d: "M16.746 16.726a3 3 0 1 0 .252 -5.555" }]);
1000
- a.appendChild(i), a.appendChild(n), e.appendChild(r), e.appendChild(a);
993
+ const i = this._createLink("https://github.com/humanbydefinition/textmode.export.js", "View repository on GitHub", b.linkIcon, [{ d: "M0 0h24v24H0z", fill: "none", stroke: "none" }, { d: "M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" }]), s = this._createLink("https://code.textmode.art/support.html", "Support textmode.export.js", b.supportIcon, [{ d: "M0 0h24v24H0z", fill: "none", stroke: "none" }, { d: "M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1" }, { d: "M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2" }, { d: "M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2" }, { d: "M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z" }, { d: "M16.746 16.726a3 3 0 1 0 .252 -5.555" }]);
994
+ a.appendChild(i), a.appendChild(s), t.appendChild(r), t.appendChild(a);
1001
995
  const c = document.createElement("div");
1002
- return c.classList.add(b.divider), t.appendChild(e), t.appendChild(c), t;
996
+ return c.classList.add(b.divider), e.appendChild(t), e.appendChild(c), e;
1003
997
  }
1004
- _createLink(t, e, r, a) {
998
+ _createLink(e, t, r, a) {
1005
999
  const i = document.createElement("a");
1006
- return i.href = t, i.target = "_blank", i.rel = "noopener noreferrer", i.classList.add(b.supportLink), i.setAttribute("aria-label", e), i.appendChild(this._createIcon(r, a)), i;
1000
+ return i.href = e, i.target = "_blank", i.rel = "noopener noreferrer", i.classList.add(b.supportLink), i.setAttribute("aria-label", t), i.appendChild(this._createIcon(r, a)), i;
1007
1001
  }
1008
- _createIcon(t, e) {
1002
+ _createIcon(e, t) {
1009
1003
  const r = document.createElementNS(H._iconNamespace, "svg");
1010
- r.setAttribute("xmlns", H._iconNamespace), r.setAttribute("width", "18"), r.setAttribute("height", "18"), r.setAttribute("viewBox", "0 0 24 24"), r.setAttribute("fill", "none"), r.setAttribute("stroke", "currentColor"), r.setAttribute("stroke-width", "2"), r.setAttribute("stroke-linecap", "round"), r.setAttribute("stroke-linejoin", "round"), r.classList.add(t);
1011
- for (const a of e) {
1004
+ r.setAttribute("xmlns", H._iconNamespace), r.setAttribute("width", "18"), r.setAttribute("height", "18"), r.setAttribute("viewBox", "0 0 24 24"), r.setAttribute("fill", "none"), r.setAttribute("stroke", "currentColor"), r.setAttribute("stroke-width", "2"), r.setAttribute("stroke-linecap", "round"), r.setAttribute("stroke-linejoin", "round"), r.classList.add(e);
1005
+ for (const a of t) {
1012
1006
  const i = document.createElementNS(H._iconNamespace, "path");
1013
- for (const [n, c] of Object.entries(a)) i.setAttribute(n, c);
1007
+ for (const [s, c] of Object.entries(a)) i.setAttribute(s, c);
1014
1008
  r.appendChild(i);
1015
1009
  }
1016
1010
  return r;
1017
1011
  }
1018
1012
  }
1019
- class P extends T {
1013
+ class P extends O {
1020
1014
  props;
1021
- constructor(t) {
1022
- super(), this.props = t;
1015
+ constructor(e) {
1016
+ super(), this.props = e;
1023
1017
  }
1024
1018
  render() {
1025
- const t = document.createElement("div");
1026
- t.classList.add(b.field), this.applyVariant(t, this.props.variant);
1027
- const e = document.createElement("label");
1028
- if (e.classList.add(b.label), e.textContent = this.props.label, this.props.labelFor && (e.htmlFor = this.props.labelFor), t.appendChild(e), this.props.description) {
1019
+ const e = document.createElement("div");
1020
+ e.classList.add(b.field), this.applyVariant(e, this.props.variant);
1021
+ const t = document.createElement("label");
1022
+ if (t.classList.add(b.label), t.textContent = this.props.label, this.props.labelFor && (t.htmlFor = this.props.labelFor), e.appendChild(t), this.props.description) {
1029
1023
  const r = document.createElement("span");
1030
- r.classList.add(b.muted), r.textContent = this.props.description, t.appendChild(r);
1024
+ r.classList.add(b.muted), r.textContent = this.props.description, e.appendChild(r);
1031
1025
  }
1032
- return t;
1026
+ return e;
1033
1027
  }
1034
- attachControl(t) {
1035
- this.root.appendChild(t);
1028
+ attachControl(e) {
1029
+ this.root.appendChild(e);
1036
1030
  }
1037
- update(t) {
1038
- this.props = t, super.update(t);
1031
+ update(e) {
1032
+ this.props = e, super.update(e);
1039
1033
  }
1040
- onUpdate(t) {
1041
- const e = this.root;
1042
- for (; e.firstChild; ) e.removeChild(e.firstChild);
1043
- this.props = t, e.classList.add(b.field), this.applyVariant(e, t.variant);
1034
+ onUpdate(e) {
1035
+ const t = this.root;
1036
+ for (; t.firstChild; ) t.removeChild(t.firstChild);
1037
+ this.props = e, t.classList.add(b.field), this.applyVariant(t, e.variant);
1044
1038
  const r = document.createElement("label");
1045
- if (r.classList.add(b.label), r.textContent = t.label, t.labelFor && (r.htmlFor = t.labelFor), e.appendChild(r), t.description) {
1039
+ if (r.classList.add(b.label), r.textContent = e.label, e.labelFor && (r.htmlFor = e.labelFor), t.appendChild(r), e.description) {
1046
1040
  const a = document.createElement("span");
1047
- a.classList.add(b.muted), a.textContent = t.description, e.appendChild(a);
1041
+ a.classList.add(b.muted), a.textContent = e.description, t.appendChild(a);
1048
1042
  }
1049
1043
  }
1050
- applyVariant(t, e) {
1051
- switch (t.classList.remove(b.fieldCompact, b.fieldDense, b.fieldFull, b.fieldChannel), e) {
1044
+ applyVariant(e, t) {
1045
+ switch (e.classList.remove(b.fieldCompact, b.fieldDense, b.fieldFull, b.fieldChannel), t) {
1052
1046
  case "compact":
1053
- t.classList.add(b.fieldCompact);
1047
+ e.classList.add(b.fieldCompact);
1054
1048
  break;
1055
1049
  case "dense":
1056
- t.classList.add(b.fieldDense);
1050
+ e.classList.add(b.fieldDense);
1057
1051
  break;
1058
1052
  case "full":
1059
- t.classList.add(b.fieldFull);
1053
+ e.classList.add(b.fieldFull);
1060
1054
  break;
1061
1055
  case "channel":
1062
- t.classList.add(b.fieldChannel);
1056
+ e.classList.add(b.fieldChannel);
1063
1057
  }
1064
1058
  }
1065
1059
  }
1066
- class mt extends T {
1060
+ class me extends O {
1067
1061
  props;
1068
1062
  select;
1069
1063
  handleChange = () => {
1070
1064
  this.props.defaultValue = this.select.value;
1071
1065
  };
1072
- constructor(t) {
1073
- super(), this.props = t;
1066
+ constructor(e) {
1067
+ super(), this.props = e;
1074
1068
  }
1075
1069
  render() {
1076
1070
  return this.select = document.createElement("select"), this.select.classList.add(b.input), this.props.id && (this.select.id = this.props.id), this.populateOptions(), this.select.addEventListener("change", this.handleChange), this.select;
@@ -1081,34 +1075,34 @@ class mt extends T {
1081
1075
  get value() {
1082
1076
  return this.select.value;
1083
1077
  }
1084
- set value(t) {
1085
- this.select && (this.select.value = t), this.props.defaultValue = t;
1078
+ set value(e) {
1079
+ this.select && (this.select.value = e), this.props.defaultValue = e;
1086
1080
  }
1087
1081
  _onUnmount() {
1088
1082
  this.select.removeEventListener("change", this.handleChange);
1089
1083
  }
1090
- onUpdate(t) {
1091
- this.props = t, this.populateOptions(), t.defaultValue && (this.select.value = t.defaultValue);
1084
+ onUpdate(e) {
1085
+ this.props = e, this.populateOptions(), e.defaultValue && (this.select.value = e.defaultValue);
1092
1086
  }
1093
- update(t) {
1094
- this.props = { ...this.props, ...t }, this.select && (t.id && (this.select.id = t.id), t.options && this.populateOptions(), t.defaultValue !== void 0 && (this.select.value = t.defaultValue));
1087
+ update(e) {
1088
+ this.props = { ...this.props, ...e }, this.select && (e.id && (this.select.id = e.id), e.options && this.populateOptions(), e.defaultValue !== void 0 && (this.select.value = e.defaultValue));
1095
1089
  }
1096
1090
  populateOptions() {
1097
1091
  if (this.select) {
1098
1092
  this.select.innerHTML = "";
1099
- for (const t of this.props.options) {
1100
- const e = document.createElement("option");
1101
- e.value = t.value, e.textContent = t.label, this.select.appendChild(e);
1093
+ for (const e of this.props.options) {
1094
+ const t = document.createElement("option");
1095
+ t.value = e.value, t.textContent = e.label, this.select.appendChild(t);
1102
1096
  }
1103
1097
  this.props.defaultValue && (this.select.value = this.props.defaultValue);
1104
1098
  }
1105
1099
  }
1106
1100
  }
1107
- class Lt extends T {
1101
+ class Le extends O {
1108
1102
  props;
1109
1103
  button;
1110
- constructor(t) {
1111
- super(), this.props = t;
1104
+ constructor(e) {
1105
+ super(), this.props = e;
1112
1106
  }
1113
1107
  render() {
1114
1108
  return this.button = document.createElement("button"), this.button.type = "button", this.button.textContent = this.props.label, this.button.classList.add(b.button), this.props.variant === "secondary" ? this.button.classList.add(b.buttonSecondary) : this.button.classList.add(b.buttonPrimary), this.props.fullWidth && this.button.classList.add(b.buttonFull), this.button.disabled = !!this.props.disabled, this.button;
@@ -1116,87 +1110,87 @@ class Lt extends T {
1116
1110
  get buttonElement() {
1117
1111
  return this.button;
1118
1112
  }
1119
- setLabel(t) {
1120
- this.props.label = t, this.button.textContent = t;
1113
+ setLabel(e) {
1114
+ this.props.label = e, this.button.textContent = e;
1121
1115
  }
1122
- setDisabled(t) {
1123
- this.props.disabled = t, this.button.disabled = t;
1116
+ setDisabled(e) {
1117
+ this.props.disabled = e, this.button.disabled = e;
1124
1118
  }
1125
- onUpdate(t) {
1126
- 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);
1119
+ onUpdate(e) {
1120
+ this.props = e, this.button.textContent = e.label, this.button.disabled = !!e.disabled, e.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, !!e.fullWidth);
1127
1121
  }
1128
1122
  }
1129
- class Ee {
1123
+ class kt {
1130
1124
  api;
1131
- constructor(t) {
1132
- this.api = t;
1125
+ constructor(e) {
1126
+ this.api = e;
1133
1127
  }
1134
- async $copy(t, e) {
1135
- switch (t) {
1128
+ async $copy(e, t) {
1129
+ switch (e) {
1136
1130
  case "txt": {
1137
- const r = this.api.toString(e);
1131
+ const r = this.api.toString(t);
1138
1132
  await navigator.clipboard.writeText(r);
1139
1133
  break;
1140
1134
  }
1141
1135
  case "svg": {
1142
- const r = this.api.toSVG(e);
1136
+ const r = this.api.toSVG(t);
1143
1137
  await navigator.clipboard.writeText(r);
1144
1138
  break;
1145
1139
  }
1146
1140
  case "image":
1147
- await this.api.copyCanvas(e);
1141
+ await this.api.copyCanvas(t);
1148
1142
  break;
1149
1143
  default:
1150
- throw new Error(`Clipboard not supported for ${t}`);
1144
+ throw new Error(`Clipboard not supported for ${e}`);
1151
1145
  }
1152
1146
  }
1153
1147
  }
1154
- class ke {
1148
+ class Bt {
1155
1149
  api;
1156
1150
  events;
1157
- constructor(t, e) {
1158
- this.api = t, this.events = e;
1151
+ constructor(e, t) {
1152
+ this.api = e, this.events = t;
1159
1153
  }
1160
- async $requestExport(t, e, r = {}) {
1161
- this.events.$emit("export:request", { format: t });
1154
+ async $requestExport(e, t, r = {}) {
1155
+ this.events.$emit("export:request", { format: e });
1162
1156
  try {
1163
1157
  const a = { onGIFProgress: r.onGIFProgress ? (i) => {
1164
- r.onGIFProgress?.(i), this.events.$emit("export:progress", { format: t, progress: i });
1165
- } : t === "gif" ? (i) => this.events.$emit("export:progress", { format: t, progress: i }) : void 0, onVideoProgress: r.onVideoProgress ? (i) => {
1166
- r.onVideoProgress?.(i), this.events.$emit("export:progress", { format: t, progress: i });
1167
- } : t === "video" ? (i) => this.events.$emit("export:progress", { format: t, progress: i }) : void 0 };
1168
- await this._execute(t, e, a), this.events.$emit("export:success", { format: t });
1158
+ r.onGIFProgress?.(i), this.events.$emit("export:progress", { format: e, progress: i });
1159
+ } : e === "gif" ? (i) => this.events.$emit("export:progress", { format: e, progress: i }) : void 0, onVideoProgress: r.onVideoProgress ? (i) => {
1160
+ r.onVideoProgress?.(i), this.events.$emit("export:progress", { format: e, progress: i });
1161
+ } : e === "video" ? (i) => this.events.$emit("export:progress", { format: e, progress: i }) : void 0 };
1162
+ await this._execute(e, t, a), this.events.$emit("export:success", { format: e });
1169
1163
  } catch (a) {
1170
- throw this.events.$emit("export:error", { format: t, error: a }), a;
1164
+ throw this.events.$emit("export:error", { format: e, error: a }), a;
1171
1165
  }
1172
1166
  }
1173
- _execute(t, e, r) {
1174
- switch (t) {
1167
+ _execute(e, t, r) {
1168
+ switch (e) {
1175
1169
  case "txt":
1176
- return Promise.resolve(this.api.saveStrings(e));
1170
+ return Promise.resolve(this.api.saveStrings(t));
1177
1171
  case "image":
1178
- return this.api.saveCanvas(e);
1172
+ return this.api.saveCanvas(t);
1179
1173
  case "svg":
1180
- return Promise.resolve(this.api.saveSVG(e));
1174
+ return Promise.resolve(this.api.saveSVG(t));
1181
1175
  case "gif": {
1182
- const a = { ...e, onProgress: r.onGIFProgress };
1176
+ const a = { ...t, onProgress: r.onGIFProgress };
1183
1177
  return this.api.saveGIF(a);
1184
1178
  }
1185
1179
  case "video": {
1186
- const a = { ...e, onProgress: r.onVideoProgress };
1180
+ const a = { ...t, onProgress: r.onVideoProgress };
1187
1181
  return this.api.saveWEBM(a);
1188
1182
  }
1189
1183
  }
1190
1184
  }
1191
1185
  }
1192
- class Be {
1186
+ class It {
1193
1187
  modifier;
1194
1188
  overlay;
1195
1189
  animationFrameId = null;
1196
1190
  handleUpdate;
1197
1191
  bound = !1;
1198
- constructor(t, e) {
1199
- this.modifier = t, this.overlay = e, this.handleUpdate = () => this.scheduleUpdate();
1192
+ constructor(e, t) {
1193
+ this.modifier = e, this.overlay = t, this.handleUpdate = () => this.scheduleUpdate();
1200
1194
  }
1201
1195
  scheduleUpdate() {
1202
1196
  this.animationFrameId !== null && cancelAnimationFrame(this.animationFrameId), this.animationFrameId = requestAnimationFrame(() => this.update());
@@ -1206,20 +1200,20 @@ class Be {
1206
1200
  }
1207
1201
  update() {
1208
1202
  this.animationFrameId = null;
1209
- const t = this.modifier.canvas.getBoundingClientRect();
1210
- this.overlay.style.top = `${t.top + window.scrollY + 8}px`, this.overlay.style.left = `${t.left + window.scrollX + 8}px`;
1203
+ const e = this.modifier.canvas.getBoundingClientRect();
1204
+ this.overlay.style.top = `${e.top + window.scrollY + 8}px`, this.overlay.style.left = `${e.left + window.scrollX + 8}px`;
1211
1205
  }
1212
1206
  dispose() {
1213
1207
  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);
1214
1208
  }
1215
1209
  }
1216
- const X = "textmode-export-number-input", Ie = `${X}__field`, Se = `${X}__controls`, Fe = `${X}__control`, Ut = `${X}__display`, et = `${Ut}--visible`, Le = (s) => {
1217
- s.dispatchEvent(new Event("input", { bubbles: !0 })), s.dispatchEvent(new Event("change", { bubbles: !0 }));
1218
- }, Mt = (s) => {
1219
- const t = document.createElement("button");
1220
- return t.type = "button", t.className = Fe, t.textContent = s > 0 ? "▲" : "▼", t;
1210
+ const X = "textmode-export-number-input", Ft = `${X}__field`, St = `${X}__controls`, Lt = `${X}__control`, Ue = `${X}__display`, te = `${Ue}--visible`, Mt = (o) => {
1211
+ o.dispatchEvent(new Event("input", { bubbles: !0 })), o.dispatchEvent(new Event("change", { bubbles: !0 }));
1212
+ }, Me = (o) => {
1213
+ const e = document.createElement("button");
1214
+ return e.type = "button", e.className = Lt, e.textContent = o > 0 ? "▲" : "▼", e;
1221
1215
  };
1222
- class G extends T {
1216
+ class G extends O {
1223
1217
  props;
1224
1218
  input;
1225
1219
  display;
@@ -1230,14 +1224,14 @@ class G extends T {
1230
1224
  holdIntervalId;
1231
1225
  activePointerId;
1232
1226
  disabledObserver;
1233
- constructor(t) {
1234
- super(), this.props = t;
1227
+ constructor(e) {
1228
+ super(), this.props = e;
1235
1229
  }
1236
1230
  render() {
1237
- const t = document.createElement("div");
1238
- t.className = X, 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 = Ie, this.display = document.createElement("div"), this.display.className = Ut;
1239
1231
  const e = document.createElement("div");
1240
- return e.className = Se, this.incrementButton = Mt(1), this.decrementButton = Mt(-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;
1232
+ e.className = X, 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 = Ft, this.display = document.createElement("div"), this.display.className = Ue;
1233
+ const t = document.createElement("div");
1234
+ return t.className = St, this.incrementButton = Me(1), this.decrementButton = Me(-1), t.appendChild(this.incrementButton), t.appendChild(this.decrementButton), e.appendChild(this.input), e.appendChild(this.display), e.appendChild(t), this.bindStepControls(), this.bindHoldBehavior(), this.bindInputListeners(), this.observeDisabledState(e), this.updateDisplay(), e;
1241
1235
  }
1242
1236
  get inputElement() {
1243
1237
  return this.input;
@@ -1245,8 +1239,8 @@ class G extends T {
1245
1239
  get value() {
1246
1240
  return this.input.value;
1247
1241
  }
1248
- set value(t) {
1249
- this.input.value = t, this.updateDisplay();
1242
+ set value(e) {
1243
+ this.input.value = e, this.updateDisplay();
1250
1244
  }
1251
1245
  refresh() {
1252
1246
  this.updateDisplay();
@@ -1255,29 +1249,29 @@ class G extends T {
1255
1249
  this.clearHoldTimers(), this.disabledObserver?.disconnect();
1256
1250
  }
1257
1251
  bindStepControls() {
1258
- const t = (i) => () => {
1252
+ const e = (i) => () => {
1259
1253
  if (this.input.disabled) return;
1260
- const n = this.input.value, c = this.input.getAttribute("step");
1254
+ const s = this.input.value, c = this.input.getAttribute("step");
1261
1255
  if (c && c !== "any") i > 0 ? this.input.stepUp() : this.input.stepDown();
1262
1256
  else {
1263
- const l = i > 0 ? 1 : -1, p = Number.parseFloat(this.input.value || "0"), o = Number.isFinite(p) ? p + l : l;
1264
- this.input.value = String(o);
1257
+ const l = i > 0 ? 1 : -1, p = Number.parseFloat(this.input.value || "0"), n = Number.isFinite(p) ? p + l : l;
1258
+ this.input.value = String(n);
1265
1259
  }
1266
- this.input.value !== n && Le(this.input), this.updateDisplay(), this.input.focus({ preventScroll: !0 });
1267
- }, e = t(1), r = t(-1), a = (i, n) => (c) => {
1260
+ this.input.value !== s && Mt(this.input), this.updateDisplay(), this.input.focus({ preventScroll: !0 });
1261
+ }, t = e(1), r = e(-1), a = (i, s) => (c) => {
1268
1262
  if (this.suppressClickAfterPointer.get(i)) return this.suppressClickAfterPointer.set(i, !1), void c.preventDefault();
1269
- n();
1263
+ s();
1270
1264
  };
1271
- this.incrementButton.addEventListener("click", a(this.incrementButton, e)), this.decrementButton.addEventListener("click", a(this.decrementButton, r));
1265
+ this.incrementButton.addEventListener("click", a(this.incrementButton, t)), this.decrementButton.addEventListener("click", a(this.decrementButton, r));
1272
1266
  }
1273
1267
  bindHoldBehavior() {
1274
- const t = (e, r) => {
1268
+ const e = (t, r) => {
1275
1269
  const a = r > 0 ? () => this.incrementButton.click() : () => this.decrementButton.click();
1276
- e.addEventListener("pointerdown", (c) => {
1270
+ t.addEventListener("pointerdown", (c) => {
1277
1271
  if (c.button === 0) {
1278
- c.preventDefault(), this.suppressClickAfterPointer.set(e, !0), this.activePointerId = c.pointerId;
1272
+ c.preventDefault(), this.suppressClickAfterPointer.set(t, !0), this.activePointerId = c.pointerId;
1279
1273
  try {
1280
- e.setPointerCapture(c.pointerId);
1274
+ t.setPointerCapture(c.pointerId);
1281
1275
  } catch {
1282
1276
  }
1283
1277
  a(), this.holdTimeoutId = window.setTimeout(() => {
@@ -1288,175 +1282,185 @@ class G extends T {
1288
1282
  const i = () => {
1289
1283
  if (this.activePointerId !== void 0) {
1290
1284
  try {
1291
- e.releasePointerCapture(this.activePointerId);
1285
+ t.releasePointerCapture(this.activePointerId);
1292
1286
  } catch {
1293
1287
  }
1294
1288
  this.activePointerId = void 0;
1295
1289
  }
1296
- }, n = () => {
1290
+ }, s = () => {
1297
1291
  this.clearHoldTimers(), i();
1298
1292
  };
1299
- e.addEventListener("pointerup", n), e.addEventListener("pointerleave", n), e.addEventListener("pointercancel", n);
1293
+ t.addEventListener("pointerup", s), t.addEventListener("pointerleave", s), t.addEventListener("pointercancel", s);
1300
1294
  };
1301
- t(this.incrementButton, 1), t(this.decrementButton, -1);
1295
+ e(this.incrementButton, 1), e(this.decrementButton, -1);
1302
1296
  }
1303
1297
  bindInputListeners() {
1304
- const t = () => {
1298
+ const e = () => {
1305
1299
  this.props.defaultValue = this.input.value, this.updateDisplay();
1306
1300
  };
1307
- this.input.addEventListener("input", t), this.input.addEventListener("change", t);
1301
+ this.input.addEventListener("input", e), this.input.addEventListener("change", e);
1308
1302
  }
1309
- observeDisabledState(t) {
1310
- const e = () => {
1303
+ observeDisabledState(e) {
1304
+ const t = () => {
1311
1305
  const r = this.input.disabled;
1312
- this.incrementButton.disabled = r, this.decrementButton.disabled = r, t.classList.toggle("is-disabled", r), r ? (this.display.classList.remove(et), this.input.style.removeProperty("color"), this.input.style.removeProperty("caretColor")) : this.updateDisplay();
1306
+ this.incrementButton.disabled = r, this.decrementButton.disabled = r, e.classList.toggle("is-disabled", r), r ? (this.display.classList.remove(te), this.input.style.removeProperty("color"), this.input.style.removeProperty("caretColor")) : this.updateDisplay();
1313
1307
  };
1314
- typeof MutationObserver < "u" && (this.disabledObserver = new MutationObserver(e), this.disabledObserver.observe(this.input, { attributes: !0, attributeFilter: ["disabled"] })), e();
1308
+ typeof MutationObserver < "u" && (this.disabledObserver = new MutationObserver(t), this.disabledObserver.observe(this.input, { attributes: !0, attributeFilter: ["disabled"] })), t();
1315
1309
  }
1316
1310
  updateDisplay() {
1317
- const t = this.props.formatDisplay;
1318
- if (!t) return this.display.textContent = "", this.display.classList.remove(et), this.input.style.removeProperty("color"), void this.input.style.removeProperty("caretColor");
1319
- const e = this.input.value, r = Number.parseFloat(e), a = t(Number.isFinite(r) ? r : Number.NaN, e, this.input);
1320
- a ? (this.display.textContent = a, this.display.classList.add(et), this.input.style.color = "transparent", this.input.style.caretColor = "#f8fafc") : (this.display.textContent = "", this.display.classList.remove(et), this.input.style.removeProperty("color"), this.input.style.removeProperty("caretColor"));
1311
+ const e = this.props.formatDisplay;
1312
+ if (!e) return this.display.textContent = "", this.display.classList.remove(te), this.input.style.removeProperty("color"), void this.input.style.removeProperty("caretColor");
1313
+ const t = this.input.value, r = Number.parseFloat(t), a = e(Number.isFinite(r) ? r : Number.NaN, t, this.input);
1314
+ a ? (this.display.textContent = a, this.display.classList.add(te), this.input.style.color = "transparent", this.input.style.caretColor = "#f8fafc") : (this.display.textContent = "", this.display.classList.remove(te), this.input.style.removeProperty("color"), this.input.style.removeProperty("caretColor"));
1321
1315
  }
1322
1316
  clearHoldTimers() {
1323
1317
  this.holdTimeoutId !== void 0 && (window.clearTimeout(this.holdTimeoutId), this.holdTimeoutId = void 0), this.holdIntervalId !== void 0 && (window.clearInterval(this.holdIntervalId), this.holdIntervalId = void 0);
1324
1318
  }
1325
1319
  }
1326
- class j extends T {
1320
+ class j extends O {
1327
1321
  variant;
1328
1322
  additionalClasses;
1329
- constructor(t = "stack", e = []) {
1330
- super(), this.variant = t, this.additionalClasses = e;
1323
+ constructor(e = "stack", t = []) {
1324
+ super(), this.variant = e, this.additionalClasses = t;
1331
1325
  }
1332
1326
  render() {
1333
- const t = document.createElement("div"), e = [this.variant === "stack" ? b.stack : void 0, this.variant === "stackDense" ? b.stackDense : void 0, this.variant === "stackCompact" ? b.stackCompact : void 0, this.variant === "row" ? b.row : void 0, this.variant === "section" ? b.section : void 0, ...this.additionalClasses].filter(Boolean);
1334
- return t.classList.add(...e), t;
1327
+ const e = document.createElement("div"), t = [this.variant === "stack" ? b.stack : void 0, this.variant === "stackDense" ? b.stackDense : void 0, this.variant === "stackCompact" ? b.stackCompact : void 0, this.variant === "row" ? b.row : void 0, this.variant === "section" ? b.section : void 0, ...this.additionalClasses].filter(Boolean);
1328
+ return e.classList.add(...t), e;
1335
1329
  }
1336
1330
  }
1337
- const $t = { neutral: "textmode-export-overlay__status-value--neutral", active: "textmode-export-overlay__status-value--active", alert: "textmode-export-overlay__status-value--alert" };
1338
- class Nt extends T {
1331
+ const $e = { neutral: "textmode-export-overlay__status-value--neutral", active: "textmode-export-overlay__status-value--active", alert: "textmode-export-overlay__status-value--alert" };
1332
+ class Ne extends O {
1339
1333
  props;
1340
1334
  container;
1341
1335
  messageElement;
1342
- constructor(t) {
1343
- super(), this.props = t;
1336
+ constructor(e) {
1337
+ super(), this.props = e;
1344
1338
  }
1345
1339
  render() {
1346
1340
  this.container = document.createElement("div"), this.container.classList.add(b.status), this.props.context === "gif" ? this.container.classList.add(b.statusGif) : this.props.context === "video" && this.container.classList.add(b.statusVideo);
1347
- const t = document.createElement("span");
1348
- return t.classList.add(b.statusTitle), t.textContent = this.props.title, this.messageElement = document.createElement("span"), this.messageElement.classList.add(b.statusValue), this.messageElement.textContent = this.props.message, this.applyVariant(this.props.variant ?? "neutral"), this.container.appendChild(t), this.container.appendChild(this.messageElement), this.container;
1341
+ const e = document.createElement("span");
1342
+ return e.classList.add(b.statusTitle), e.textContent = this.props.title, this.messageElement = document.createElement("span"), this.messageElement.classList.add(b.statusValue), this.messageElement.textContent = this.props.message, this.applyVariant(this.props.variant ?? "neutral"), this.container.appendChild(e), this.container.appendChild(this.messageElement), this.container;
1349
1343
  }
1350
- setMessage(t, e = "neutral") {
1351
- this.messageElement.textContent = t, this.applyVariant(e);
1344
+ setMessage(e, t = "neutral") {
1345
+ this.messageElement.textContent = e, this.applyVariant(t);
1352
1346
  }
1353
- onUpdate(t) {
1354
- this.props = t, this.setMessage(t.message, t.variant ?? "neutral");
1347
+ onUpdate(e) {
1348
+ this.props = e, this.setMessage(e.message, e.variant ?? "neutral");
1355
1349
  }
1356
- applyVariant(t) {
1357
- this.messageElement.classList.remove(...Object.values($t)), this.messageElement.classList.add($t[t]);
1350
+ applyVariant(e) {
1351
+ this.messageElement.classList.remove(...Object.values($e)), this.messageElement.classList.add($e[e]);
1358
1352
  }
1359
1353
  }
1360
- class Y extends T {
1354
+ class Y extends O {
1361
1355
  _config;
1362
1356
  _managedComponents = /* @__PURE__ */ new Set();
1363
- constructor(t) {
1364
- super(), this._config = t;
1357
+ constructor(e) {
1358
+ super(), this._config = e;
1365
1359
  }
1366
- _manageComponent(t) {
1367
- return this._managedComponents.add(t), t;
1360
+ _manageComponent(e) {
1361
+ return this._managedComponents.add(e), e;
1368
1362
  }
1369
1363
  _onUnmount() {
1370
- for (const t of this._managedComponents) t.unmount();
1364
+ for (const e of this._managedComponents) e.unmount();
1371
1365
  }
1372
1366
  _onDestroy() {
1373
- for (const t of this._managedComponents) t.destroy();
1367
+ for (const e of this._managedComponents) e.destroy();
1374
1368
  this._managedComponents.clear();
1375
1369
  }
1376
1370
  }
1377
1371
  const z = { frameCount: 300, frameRate: 60, scale: 1, repeat: 0 };
1378
- class ut extends Y {
1372
+ class ue extends Y {
1379
1373
  frameCountInput = this._manageComponent(new G({ defaultValue: String(z.frameCount), attributes: { min: "1", max: "600", step: "1" } }));
1380
1374
  frameRateInput = this._manageComponent(new G({ defaultValue: String(z.frameRate), attributes: { min: "1", max: "60", step: "1" } }));
1381
1375
  scaleInput = this._manageComponent(new G({ defaultValue: String(z.scale), attributes: { min: "0.1", max: "8", step: "0.1" } }));
1382
- repeatInput = this._manageComponent(new G({ defaultValue: "0", attributes: { min: "0", max: "50", step: "1" }, formatDisplay: (t, e) => Number.isFinite(t) ? t === 0 ? "∞" : null : e.trim() === "" ? null : e }));
1383
- status = this._manageComponent(new Nt({ title: "status", message: "ready to record", variant: "neutral", context: "gif" }));
1376
+ repeatInput = this._manageComponent(new G({ defaultValue: "0", attributes: { min: "0", max: "50", step: "1" }, formatDisplay: (e, t) => Number.isFinite(e) ? e === 0 ? "∞" : null : t.trim() === "" ? null : t }));
1377
+ status = this._manageComponent(new Ne({ title: "status", message: "ready to record", variant: "neutral", context: "gif" }));
1384
1378
  recordingState = "idle";
1385
- constructor(t) {
1386
- super(t);
1379
+ constructor(e) {
1380
+ super(e);
1387
1381
  }
1388
1382
  render() {
1389
- const t = document.createElement("div");
1390
- t.classList.add(b.stack);
1391
- const e = new j("row");
1392
- e.mount(t);
1383
+ const e = document.createElement("div");
1384
+ e.classList.add(b.stack);
1385
+ const t = new j("row");
1386
+ t.mount(e);
1393
1387
  const r = new P({ label: "number of frames", labelFor: "textmode-export-gif-frame-count", variant: "dense" });
1394
- r.mount(e.root), this.frameCountInput.mount(r.root), this.frameCountInput.inputElement.id = "textmode-export-gif-frame-count";
1388
+ r.mount(t.root), this.frameCountInput.mount(r.root), this.frameCountInput.inputElement.id = "textmode-export-gif-frame-count";
1395
1389
  const a = new P({ label: "frame rate (fps)", labelFor: "textmode-export-gif-frame-rate", variant: "dense" });
1396
- a.mount(e.root), this.frameRateInput.mount(a.root), this.frameRateInput.inputElement.id = "textmode-export-gif-frame-rate";
1390
+ a.mount(t.root), this.frameRateInput.mount(a.root), this.frameRateInput.inputElement.id = "textmode-export-gif-frame-rate";
1397
1391
  const i = new j("row");
1398
- i.mount(t);
1399
- const n = new P({ label: "scale", labelFor: "textmode-export-gif-scale", variant: "dense" });
1400
- n.mount(i.root), this.scaleInput.mount(n.root), this.scaleInput.inputElement.id = "textmode-export-gif-scale";
1392
+ i.mount(e);
1393
+ const s = new P({ label: "scale", labelFor: "textmode-export-gif-scale", variant: "dense" });
1394
+ s.mount(i.root), this.scaleInput.mount(s.root), this.scaleInput.inputElement.id = "textmode-export-gif-scale";
1401
1395
  const c = new P({ label: "loop count", labelFor: "textmode-export-gif-repeat", variant: "dense" });
1402
- return c.mount(i.root), this.repeatInput.mount(c.root), this.repeatInput.inputElement.id = "textmode-export-gif-repeat", this.status.mount(t), t;
1396
+ return c.mount(i.root), this.repeatInput.mount(c.root), this.repeatInput.inputElement.id = "textmode-export-gif-repeat", this.status.mount(e), e;
1403
1397
  }
1404
1398
  getOptions() {
1405
- const t = this._config.defaultOptions ?? {};
1406
- return { frameCount: this.safeParseInt(this.frameCountInput.value, t.frameCount ?? 300), frameRate: this.safeParseInt(this.frameRateInput.value, t.frameRate ?? 60), scale: this.safeParseFloat(this.scaleInput.value, t.scale ?? 1), repeat: this.safeParseInt(this.repeatInput.value, t.repeat ?? 0) };
1399
+ const e = this._config.defaultOptions ?? {};
1400
+ return { frameCount: this.safeParseInt(this.frameCountInput.value, e.frameCount ?? 300), frameRate: this.safeParseInt(this.frameRateInput.value, e.frameRate ?? 60), scale: this.safeParseFloat(this.scaleInput.value, e.scale ?? 1), repeat: this.safeParseInt(this.repeatInput.value, e.repeat ?? 0) };
1407
1401
  }
1408
1402
  reset() {
1409
1403
  this.recordingState = "idle", this.applyDefaults(), this.setRecordingState("idle");
1410
1404
  }
1411
1405
  validate() {
1412
- const t = Number.parseInt(this.frameCountInput.value, 10), e = Number.parseInt(this.frameRateInput.value, 10), r = Number.parseFloat(this.scaleInput.value);
1413
- return Number.isFinite(t) && t > 0 && Number.isFinite(e) && e > 0 && Number.isFinite(r) && r > 0;
1406
+ const e = Number.parseInt(this.frameCountInput.value, 10), t = Number.parseInt(this.frameRateInput.value, 10), r = Number.parseFloat(this.scaleInput.value);
1407
+ return Number.isFinite(e) && e > 0 && Number.isFinite(t) && t > 0 && Number.isFinite(r) && r > 0;
1414
1408
  }
1415
1409
  isRecording() {
1416
- return this.recordingState === "recording";
1410
+ return this.recordingState === "recording" || this.recordingState === "encoding";
1417
1411
  }
1418
- setRecordingState(t, e) {
1419
- this.recordingState = t;
1420
- const r = t === "recording";
1421
- switch (this.frameCountInput.inputElement.disabled = r, this.frameRateInput.inputElement.disabled = r, this.scaleInput.inputElement.disabled = r, this.repeatInput.inputElement.disabled = r, t) {
1412
+ setRecordingState(e, t) {
1413
+ this.recordingState = e;
1414
+ const r = e === "recording" || e === "encoding";
1415
+ switch (this.frameCountInput.inputElement.disabled = r, this.frameRateInput.inputElement.disabled = r, this.scaleInput.inputElement.disabled = r, this.repeatInput.inputElement.disabled = r, e) {
1422
1416
  case "recording":
1423
- if (e?.totalFrames) {
1424
- const a = e.frameIndex ?? 0;
1425
- this.status.setMessage(`recording ${a}/${e.totalFrames}`, "active");
1417
+ if (t?.totalFrames) {
1418
+ const a = t.frameIndex ?? 0;
1419
+ this.status.setMessage(`recording ${a}/${t.totalFrames}`, "active");
1426
1420
  } else this.status.setMessage("recording…", "active");
1427
1421
  break;
1422
+ case "encoding":
1423
+ if (t?.totalFrames) {
1424
+ const a = t.frameIndex ?? 0;
1425
+ this.status.setMessage(`encoding ${a}/${t.totalFrames}`, "active");
1426
+ } else this.status.setMessage("encoding…", "active");
1427
+ break;
1428
1428
  case "completed":
1429
1429
  this.status.setMessage("GIF saved successfully", "active");
1430
1430
  break;
1431
1431
  case "error":
1432
- this.status.setMessage(e?.message ?? "failed to export GIF", "alert");
1432
+ this.status.setMessage(t?.message ?? "failed to export GIF", "alert");
1433
1433
  break;
1434
1434
  default:
1435
1435
  this.status.setMessage("ready to record", "neutral");
1436
1436
  }
1437
1437
  }
1438
- handleProgress(t) {
1439
- t.state === "recording" && t.totalFrames ? this.status.setMessage(`recording ${t.frameIndex ?? 0}/${t.totalFrames}`, "active") : t.state === "completed" ? this.status.setMessage("GIF saved successfully", "active") : t.state === "error" && this.status.setMessage(t.message ?? "failed to export GIF", "alert");
1438
+ handleProgress(e) {
1439
+ if (e.state !== "recording" && e.state !== "encoding" || !e.totalFrames) e.state === "completed" ? this.status.setMessage("GIF saved successfully", "active") : e.state === "error" && this.status.setMessage(e.message ?? "failed to export GIF", "alert");
1440
+ else {
1441
+ const t = e.state === "recording" ? "recording" : "encoding";
1442
+ this.status.setMessage(`${t} ${e.frameIndex ?? 0}/${e.totalFrames}`, "active");
1443
+ }
1440
1444
  }
1441
1445
  applyDefaults() {
1442
- const t = this._config.defaultOptions ?? {}, e = t.frameCount ?? z.frameCount, r = t.frameRate ?? z.frameRate, a = t.scale ?? z.scale, i = t.repeat ?? z.repeat;
1443
- this.frameCountInput.value = String(e), this.frameRateInput.value = String(r), this.scaleInput.value = String(a), this.repeatInput.value = String(i), this.frameCountInput.refresh(), this.frameRateInput.refresh(), this.scaleInput.refresh(), this.repeatInput.refresh();
1446
+ const e = this._config.defaultOptions ?? {}, t = e.frameCount ?? z.frameCount, r = e.frameRate ?? z.frameRate, a = e.scale ?? z.scale, i = e.repeat ?? z.repeat;
1447
+ this.frameCountInput.value = String(t), this.frameRateInput.value = String(r), this.scaleInput.value = String(a), this.repeatInput.value = String(i), this.frameCountInput.refresh(), this.frameRateInput.refresh(), this.scaleInput.refresh(), this.repeatInput.refresh();
1444
1448
  }
1445
- safeParseInt(t, e) {
1446
- const r = Number.parseInt(t, 10);
1447
- return Number.isFinite(r) ? r : e;
1449
+ safeParseInt(e, t) {
1450
+ const r = Number.parseInt(e, 10);
1451
+ return Number.isFinite(r) ? r : t;
1448
1452
  }
1449
- safeParseFloat(t, e) {
1450
- const r = Number.parseFloat(t);
1451
- return Number.isFinite(r) ? r : e;
1453
+ safeParseFloat(e, t) {
1454
+ const r = Number.parseFloat(e);
1455
+ return Number.isFinite(r) ? r : t;
1452
1456
  }
1453
1457
  }
1454
- const it = "textmode-export-range-input", Me = `${it}__field`, $e = `${it}__tooltip`, ct = `${it}__tooltip--visible`, rt = (s, t) => {
1455
- if (typeof s != "string" || s.length === 0) return t;
1456
- const e = Number.parseFloat(s);
1457
- return Number.isFinite(e) ? e : t;
1458
- }, Ae = (s, t, e) => Math.min(e, Math.max(t, s));
1459
- class Pe extends T {
1458
+ const ie = "textmode-export-range-input", $t = `${ie}__field`, At = `${ie}__tooltip`, ce = `${ie}__tooltip--visible`, re = (o, e) => {
1459
+ if (typeof o != "string" || o.length === 0) return e;
1460
+ const t = Number.parseFloat(o);
1461
+ return Number.isFinite(t) ? t : e;
1462
+ }, Pt = (o, e, t) => Math.min(t, Math.max(e, o));
1463
+ class Dt extends O {
1460
1464
  props;
1461
1465
  input;
1462
1466
  tooltip;
@@ -1467,12 +1471,12 @@ class Pe extends T {
1467
1471
  activePointerId;
1468
1472
  disabledObserver;
1469
1473
  resizeObserver;
1470
- constructor(t) {
1471
- super(), this.props = t;
1474
+ constructor(e) {
1475
+ super(), this.props = e;
1472
1476
  }
1473
1477
  render() {
1474
- const t = document.createElement("div");
1475
- return t.className = it, 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 = Me, this.tooltip = document.createElement("div"), this.tooltip.className = $e, t.appendChild(this.input), t.appendChild(this.tooltip), this.bindEvents(t), this.updateTooltip(), this.syncDisabledState(t), t;
1478
+ const e = document.createElement("div");
1479
+ return e.className = ie, 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 = $t, this.tooltip = document.createElement("div"), this.tooltip.className = At, e.appendChild(this.input), e.appendChild(this.tooltip), this.bindEvents(e), this.updateTooltip(), this.syncDisabledState(e), e;
1476
1480
  }
1477
1481
  get inputElement() {
1478
1482
  return this.input;
@@ -1480,13 +1484,13 @@ class Pe extends T {
1480
1484
  get value() {
1481
1485
  return this.input.value;
1482
1486
  }
1483
- set value(t) {
1484
- this.input.value = t, this.updateTooltip();
1487
+ set value(e) {
1488
+ this.input.value = e, this.updateTooltip();
1485
1489
  }
1486
1490
  _onDestroy() {
1487
1491
  this.disabledObserver?.disconnect(), this.resizeObserver?.disconnect();
1488
1492
  }
1489
- bindEvents(t) {
1493
+ bindEvents(e) {
1490
1494
  this.input.addEventListener("pointerenter", () => {
1491
1495
  this.hoverActive = !0, this.refreshTooltipVisibility();
1492
1496
  }), this.input.addEventListener("pointerleave", () => {
@@ -1509,27 +1513,27 @@ class Pe extends T {
1509
1513
  this.activePointerId = void 0;
1510
1514
  }
1511
1515
  });
1512
- const e = () => {
1516
+ const t = () => {
1513
1517
  this.pointerActive = !1, this.suppressFocusFromPointer = !1, this.hoverActive = this.input.matches(":hover"), this.releasePointerCapture(), this.refreshTooltipVisibility();
1514
1518
  };
1515
- this.input.addEventListener("pointerup", e), this.input.addEventListener("pointercancel", e), this.input.addEventListener("lostpointercapture", e), this.input.addEventListener("input", () => {
1519
+ this.input.addEventListener("pointerup", t), this.input.addEventListener("pointercancel", t), this.input.addEventListener("lostpointercapture", t), this.input.addEventListener("input", () => {
1516
1520
  (this.hoverActive || this.focusActive || this.pointerActive) && this.updateTooltip(), this.props.defaultValue = this.input.value;
1517
1521
  }), this.input.addEventListener("change", () => {
1518
1522
  this.pointerActive || this.updateTooltip(), this.props.defaultValue = this.input.value;
1519
1523
  }), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => {
1520
- this.tooltip.classList.contains(ct) && this.updateTooltipPosition();
1521
- }), this.resizeObserver.observe(t));
1524
+ this.tooltip.classList.contains(ce) && this.updateTooltipPosition();
1525
+ }), this.resizeObserver.observe(e));
1522
1526
  }
1523
1527
  refreshTooltipVisibility() {
1524
- const t = (this.hoverActive || this.focusActive || this.pointerActive) && !this.input.disabled;
1525
- t && this.updateTooltip(), this.tooltip.classList.toggle(ct, t);
1528
+ const e = (this.hoverActive || this.focusActive || this.pointerActive) && !this.input.disabled;
1529
+ e && this.updateTooltip(), this.tooltip.classList.toggle(ce, e);
1526
1530
  }
1527
- syncDisabledState(t) {
1528
- const e = () => {
1531
+ syncDisabledState(e) {
1532
+ const t = () => {
1529
1533
  const r = this.input.disabled;
1530
- t.classList.toggle("is-disabled", r), r && (this.hoverActive = !1, this.focusActive = !1, this.pointerActive = !1, this.suppressFocusFromPointer = !1, this.releasePointerCapture(), this.tooltip.classList.remove(ct));
1534
+ e.classList.toggle("is-disabled", r), r && (this.hoverActive = !1, this.focusActive = !1, this.pointerActive = !1, this.suppressFocusFromPointer = !1, this.releasePointerCapture(), this.tooltip.classList.remove(ce));
1531
1535
  };
1532
- typeof MutationObserver < "u" && (this.disabledObserver = new MutationObserver(e), this.disabledObserver.observe(this.input, { attributes: !0, attributeFilter: ["disabled"] })), e();
1536
+ typeof MutationObserver < "u" && (this.disabledObserver = new MutationObserver(t), this.disabledObserver.observe(this.input, { attributes: !0, attributeFilter: ["disabled"] })), t();
1533
1537
  }
1534
1538
  releasePointerCapture() {
1535
1539
  if (this.activePointerId !== void 0) {
@@ -1544,78 +1548,78 @@ class Pe extends T {
1544
1548
  this.updateTooltipContent(), this.updateTooltipPosition();
1545
1549
  }
1546
1550
  updateTooltipContent() {
1547
- const t = this.props.formatValue ?? ((r) => `${r}`), e = this.getCurrentValue();
1548
- this.tooltip.textContent = t(e, this.input);
1551
+ const e = this.props.formatValue ?? ((r) => `${r}`), t = this.getCurrentValue();
1552
+ this.tooltip.textContent = e(t, this.input);
1549
1553
  }
1550
1554
  updateTooltipPosition() {
1551
- const t = this.getMin(), e = this.getMax(), r = Ae(this.getCurrentValue(), t, e), a = e - t, i = a === 0 ? 0 : (r - t) / a;
1555
+ const e = this.getMin(), t = this.getMax(), r = Pt(this.getCurrentValue(), e, t), a = t - e, i = a === 0 ? 0 : (r - e) / a;
1552
1556
  this.tooltip.style.left = 100 * i + "%";
1553
1557
  }
1554
1558
  getMin() {
1555
- return rt(this.input.min, 0);
1559
+ return re(this.input.min, 0);
1556
1560
  }
1557
1561
  getMax() {
1558
- return rt(this.input.max, 100);
1562
+ return re(this.input.max, 100);
1559
1563
  }
1560
1564
  getCurrentValue() {
1561
- return rt(this.input.value, rt(this.props.defaultValue, 0));
1565
+ return re(this.input.value, re(this.props.defaultValue, 0));
1562
1566
  }
1563
1567
  }
1564
- function De(s) {
1565
- if (!Number.isFinite(s)) return "default quality";
1566
- const t = Math.max(0, Math.min(1, s));
1567
- return t >= 0.995 ? "near-lossless" : t >= 0.98 ? "maximum detail" : t >= 0.88 ? "ultra quality" : t >= 0.7 ? "high quality" : t >= 0.5 ? "balanced" : t >= 0.25 ? "compact" : t >= 0.1 ? "lightweight" : "draft";
1568
+ function Vt(o) {
1569
+ if (!Number.isFinite(o)) return "default quality";
1570
+ const e = Math.max(0, Math.min(1, o));
1571
+ return e >= 0.995 ? "near-lossless" : e >= 0.98 ? "maximum detail" : e >= 0.88 ? "ultra quality" : e >= 0.7 ? "high quality" : e >= 0.5 ? "balanced" : e >= 0.25 ? "compact" : e >= 0.1 ? "lightweight" : "draft";
1568
1572
  }
1569
- function Ve(s) {
1570
- return `${De(s)} (quality ≈ ${s.toFixed(3)})`;
1573
+ function Ot(o) {
1574
+ return `${Vt(o)} (quality ≈ ${o.toFixed(3)})`;
1571
1575
  }
1572
- class pt extends Y {
1573
- frameRateInput = this._manageComponent(new G({ defaultValue: String(60), attributes: { min: String(1), max: String(60), step: "1" }, formatDisplay: (t) => Number.isFinite(t) ? `${t} fps` : null }));
1576
+ class pe extends Y {
1577
+ frameRateInput = this._manageComponent(new G({ defaultValue: String(60), attributes: { min: String(1), max: String(60), step: "1" }, formatDisplay: (e) => Number.isFinite(e) ? `${e} fps` : null }));
1574
1578
  frameCountInput = this._manageComponent(new G({ defaultValue: String(480), attributes: { min: String(1), max: String(3600), step: "1" } }));
1575
- qualityInput = this._manageComponent(new Pe({ defaultValue: String(0.7), attributes: { min: String(0), max: String(1), step: "0.001" }, formatValue: (t) => Ve(t) }));
1576
- status = this._manageComponent(new Nt({ title: "status", message: "ready to record", variant: "neutral", context: "video" }));
1579
+ qualityInput = this._manageComponent(new Dt({ defaultValue: String(0.7), attributes: { min: String(0), max: String(1), step: "0.001" }, formatValue: (e) => Ot(e) }));
1580
+ status = this._manageComponent(new Ne({ title: "status", message: "ready to record", variant: "neutral", context: "video" }));
1577
1581
  recordingState = "idle";
1578
- constructor(t) {
1579
- super(t);
1582
+ constructor(e) {
1583
+ super(e);
1580
1584
  }
1581
1585
  render() {
1582
- const t = document.createElement("div");
1583
- t.classList.add(b.stack);
1584
- const e = new j("row");
1585
- e.mount(t);
1586
+ const e = document.createElement("div");
1587
+ e.classList.add(b.stack);
1588
+ const t = new j("row");
1589
+ t.mount(e);
1586
1590
  const r = new P({ label: "number of frames", labelFor: "textmode-export-video-frame-count", variant: "compact" });
1587
- r.mount(e.root), this.frameCountInput.mount(r.root), this.frameCountInput.inputElement.id = "textmode-export-video-frame-count";
1591
+ r.mount(t.root), this.frameCountInput.mount(r.root), this.frameCountInput.inputElement.id = "textmode-export-video-frame-count";
1588
1592
  const a = new P({ label: "frame rate (fps)", labelFor: "textmode-export-video-frame-rate", variant: "compact" });
1589
- a.mount(e.root), this.frameRateInput.mount(a.root), this.frameRateInput.inputElement.id = "textmode-export-video-frame-rate";
1593
+ a.mount(t.root), this.frameRateInput.mount(a.root), this.frameRateInput.inputElement.id = "textmode-export-video-frame-rate";
1590
1594
  const i = new P({ label: "quality", labelFor: "textmode-export-video-quality", variant: "full" });
1591
- return i.mount(t), this.qualityInput.mount(i.root), this.qualityInput.inputElement.id = "textmode-export-video-quality", this.status.mount(t), t;
1595
+ return i.mount(e), this.qualityInput.mount(i.root), this.qualityInput.inputElement.id = "textmode-export-video-quality", this.status.mount(e), e;
1592
1596
  }
1593
1597
  getOptions() {
1594
- const t = this._config.defaultOptions ?? {}, e = Number.parseInt(this.frameCountInput.value, 10), r = Number.parseFloat(this.frameRateInput.value), a = Number.parseFloat(this.qualityInput.value);
1595
- return { frameCount: Number.isFinite(e) ? e : t.frameCount ?? 480, frameRate: Number.isFinite(r) ? r : t.frameRate ?? 60, quality: Number.isFinite(a) ? a : t.quality ?? 0.7 };
1598
+ const e = this._config.defaultOptions ?? {}, t = Number.parseInt(this.frameCountInput.value, 10), r = Number.parseFloat(this.frameRateInput.value), a = Number.parseFloat(this.qualityInput.value);
1599
+ return { frameCount: Number.isFinite(t) ? t : e.frameCount ?? 480, frameRate: Number.isFinite(r) ? r : e.frameRate ?? 60, quality: Number.isFinite(a) ? a : e.quality ?? 0.7 };
1596
1600
  }
1597
1601
  reset() {
1598
1602
  this.recordingState = "idle", this.applyDefaults(), this.status.setMessage("ready to record", "neutral");
1599
1603
  }
1600
1604
  validate() {
1601
- const t = Number.parseInt(this.frameCountInput.value, 10), e = Number.parseFloat(this.frameRateInput.value);
1602
- return Number.isFinite(t) && t >= 1 && Number.isFinite(e) && e >= 1;
1605
+ const e = Number.parseInt(this.frameCountInput.value, 10), t = Number.parseFloat(this.frameRateInput.value);
1606
+ return Number.isFinite(e) && e >= 1 && Number.isFinite(t) && t >= 1;
1603
1607
  }
1604
1608
  isRecording() {
1605
1609
  return this.recordingState === "recording";
1606
1610
  }
1607
- setRecordingState(t, e) {
1608
- this.recordingState = t;
1609
- const r = t === "recording";
1610
- this.frameCountInput.inputElement.disabled = r, this.frameRateInput.inputElement.disabled = r, this.qualityInput.inputElement.disabled = r, this.syncStatus(t, e);
1611
+ setRecordingState(e, t) {
1612
+ this.recordingState = e;
1613
+ const r = e === "recording";
1614
+ this.frameCountInput.inputElement.disabled = r, this.frameRateInput.inputElement.disabled = r, this.qualityInput.inputElement.disabled = r, this.syncStatus(e, t);
1611
1615
  }
1612
- handleProgress(t) {
1613
- this.syncStatus(t.state, t);
1616
+ handleProgress(e) {
1617
+ this.syncStatus(e.state, e);
1614
1618
  }
1615
- syncStatus(t, e) {
1616
- switch (t) {
1619
+ syncStatus(e, t) {
1620
+ switch (e) {
1617
1621
  case "recording": {
1618
- const r = e?.frameIndex ?? 0, a = e?.totalFrames ?? this.resolvePlannedFrameCount();
1622
+ const r = t?.frameIndex ?? 0, a = t?.totalFrames ?? this.resolvePlannedFrameCount();
1619
1623
  if (a) {
1620
1624
  const i = Math.min(Math.max(0, Math.round(r)), a);
1621
1625
  this.status.setMessage(`recording ${i}/${a} frames`, "active");
@@ -1626,23 +1630,23 @@ class pt extends Y {
1626
1630
  this.status.setMessage("saved to disk", "active");
1627
1631
  break;
1628
1632
  case "error":
1629
- this.status.setMessage(e?.message ? `error: ${e.message}` : "recording failed", "alert");
1633
+ this.status.setMessage(t?.message ? `error: ${t.message}` : "recording failed", "alert");
1630
1634
  break;
1631
1635
  default:
1632
1636
  this.status.setMessage("ready to record", "neutral");
1633
1637
  }
1634
1638
  }
1635
1639
  resolvePlannedFrameCount() {
1636
- const t = Number.parseInt(this.frameCountInput.value, 10);
1637
- return Number.isFinite(t) && t > 0 ? Math.round(t) : void 0;
1640
+ const e = Number.parseInt(this.frameCountInput.value, 10);
1641
+ return Number.isFinite(e) && e > 0 ? Math.round(e) : void 0;
1638
1642
  }
1639
1643
  applyDefaults() {
1640
- const t = this._config.defaultOptions ?? {}, e = t.frameCount ?? 480, r = t.frameRate ?? 60, a = t.quality ?? 0.7;
1641
- this.frameCountInput.value = String(e), this.frameRateInput.value = String(r), this.qualityInput.value = String(a), this.frameCountInput.refresh(), this.frameRateInput.refresh();
1644
+ const e = this._config.defaultOptions ?? {}, t = e.frameCount ?? 480, r = e.frameRate ?? 60, a = e.quality ?? 0.7;
1645
+ this.frameCountInput.value = String(t), this.frameRateInput.value = String(r), this.qualityInput.value = String(a), this.frameCountInput.refresh(), this.frameRateInput.refresh();
1642
1646
  }
1643
1647
  }
1644
- const Te = `@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;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;inset: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;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}}`;
1645
- class Oe {
1648
+ const Tt = `@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;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;inset: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;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}}`;
1649
+ class Rt {
1646
1650
  _textmodifier;
1647
1651
  _state;
1648
1652
  _events;
@@ -1659,102 +1663,114 @@ class Oe {
1659
1663
  _positionService;
1660
1664
  _header = new H();
1661
1665
  _formatField = new P({ label: "export format", labelFor: "textmode-export-format", variant: "full" });
1662
- _formatSelect = new mt({ id: "textmode-export-format", options: [] });
1663
- _exportButton = new Lt({ label: "download file", fullWidth: !0, variant: "primary" });
1664
- _copyButton = new Lt({ label: "copy to clipboard", fullWidth: !0, variant: "primary" });
1666
+ _formatSelect = new me({ id: "textmode-export-format", options: [] });
1667
+ _exportButton = new Le({ label: "download file", fullWidth: !0, variant: "primary" });
1668
+ _copyButton = new Le({ label: "copy to clipboard", fullWidth: !0, variant: "primary" });
1665
1669
  _currentFormat;
1666
1670
  _currentBlade;
1667
1671
  _handleFormatSelectChange = () => {
1668
1672
  this._handleFormatChange(this._formatSelect.value);
1669
1673
  };
1670
1674
  _handleExportClickSafe = () => {
1671
- this._handleExportClick().catch((t) => {
1672
- console.error("[textmode-export] Export failed", t);
1675
+ this._handleExportClick().catch((e) => {
1676
+ console.error("[textmode-export] Export failed", e);
1673
1677
  });
1674
1678
  };
1675
1679
  _handleCopyClickSafe = () => {
1676
- this._handleCopyClick().catch((t) => {
1677
- console.error("[textmode-export] Copy failed", t);
1680
+ this._handleCopyClick().catch((e) => {
1681
+ console.error("[textmode-export] Copy failed", e);
1678
1682
  });
1679
1683
  };
1680
- constructor(t, e, r, a, i) {
1681
- this._textmodifier = t, this._state = r, this._events = a, this._exportService = new ke(e, a), this._clipboardService = new Ee(e), this._definitions = i, this._currentFormat = r.snapshot.format, this._initializeFormatMap(), this._registerEventHandlers();
1684
+ constructor(e, t, r, a, i) {
1685
+ this._textmodifier = e, this._state = r, this._events = a, this._exportService = new Bt(t, a), this._clipboardService = new kt(t), this._definitions = i, this._currentFormat = r.snapshot.format, this._initializeFormatMap(), this._registerEventHandlers();
1682
1686
  }
1683
1687
  $mount() {
1684
- this._createOverlay(), this._renderStaticContent(), this._positionService = new Be(this._textmodifier, this._shadowHost), this._positionService.bind(), this._switchFormat(this._currentFormat);
1688
+ this._createOverlay(), this._renderStaticContent(), this._positionService = new It(this._textmodifier, this._shadowHost), this._positionService.bind(), this._switchFormat(this._currentFormat);
1689
+ }
1690
+ show() {
1691
+ this._shadowHost && (this._shadowHost.style.display = "");
1692
+ }
1693
+ hide() {
1694
+ this._shadowHost && (this._shadowHost.style.display = "none");
1695
+ }
1696
+ toggle() {
1697
+ this.isVisible() ? this.hide() : this.show();
1698
+ }
1699
+ isVisible() {
1700
+ return !!this._shadowHost && this._shadowHost.style.display !== "none";
1685
1701
  }
1686
1702
  $dispose() {
1687
1703
  this._formatSelect.isMounted() && this._formatSelect.selectElement.removeEventListener("change", this._handleFormatSelectChange), this._exportButton.isMounted() && this._exportButton.buttonElement.removeEventListener("click", this._handleExportClickSafe), this._copyButton.isMounted() && this._copyButton.buttonElement.removeEventListener("click", this._handleCopyClickSafe);
1688
- for (const t of this._eventUnsubscribers) t();
1704
+ for (const e of this._eventUnsubscribers) e();
1689
1705
  this._eventUnsubscribers.length = 0, this._events.$clear();
1690
- for (const t of this._formats.values()) t.blade.destroy();
1706
+ for (const e of this._formats.values()) e.blade.destroy();
1691
1707
  this._formats.clear(), this._currentBlade = void 0, this._shadowHost?.isConnected && this._shadowHost.remove(), this._positionService?.dispose();
1692
1708
  }
1693
1709
  _initializeFormatMap() {
1694
- for (const t of this._definitions) {
1695
- const e = t.createBlade();
1696
- this._formats.set(t.format, { definition: t, blade: e, initialized: !1 });
1710
+ for (const e of this._definitions) {
1711
+ const t = e.createBlade();
1712
+ this._formats.set(e.format, { definition: e, blade: t, initialized: !1 });
1697
1713
  }
1698
1714
  }
1699
1715
  _createOverlay() {
1700
1716
  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" });
1701
- const t = document.createElement("style");
1702
- t.textContent = Te, this._shadowRoot.appendChild(t), 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);
1717
+ const e = document.createElement("style");
1718
+ e.textContent = Tt, this._shadowRoot.appendChild(e), 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);
1703
1719
  }
1704
1720
  _renderStaticContent() {
1705
1721
  this._header.mount(this._overlayElement);
1706
- const t = document.createElement("div");
1707
- t.classList.add(b.section), this._overlayElement.appendChild(t), this._formatField.mount(t), this._prepareFormatOptions(), this._formatSelect.mount(this._formatField.root), this._formatSelect.selectElement.addEventListener("change", this._handleFormatSelectChange), this._optionsContainer = document.createElement("div"), this._optionsContainer.classList.add(b.stack, b.stackCompact), this._overlayElement.appendChild(this._optionsContainer), this._exportButton.mount(this._overlayElement), this._exportButton.buttonElement.addEventListener("click", this._handleExportClickSafe), this._copyButtonContainer = document.createElement("div"), this._copyButtonContainer.classList.add(b.stack, b.stackDense), this._overlayElement.appendChild(this._copyButtonContainer), this._copyButton.mount(this._copyButtonContainer), this._copyButton.buttonElement.dataset.defaultLabel = "copy to clipboard", this._copyButton.buttonElement.addEventListener("click", this._handleCopyClickSafe);
1722
+ const e = document.createElement("div");
1723
+ e.classList.add(b.section), this._overlayElement.appendChild(e), this._formatField.mount(e), this._prepareFormatOptions(), this._formatSelect.mount(this._formatField.root), this._formatSelect.selectElement.addEventListener("change", this._handleFormatSelectChange), this._optionsContainer = document.createElement("div"), this._optionsContainer.classList.add(b.stack, b.stackCompact), this._overlayElement.appendChild(this._optionsContainer), this._exportButton.mount(this._overlayElement), this._exportButton.buttonElement.addEventListener("click", this._handleExportClickSafe), this._copyButtonContainer = document.createElement("div"), this._copyButtonContainer.classList.add(b.stack, b.stackDense), this._overlayElement.appendChild(this._copyButtonContainer), this._copyButton.mount(this._copyButtonContainer), this._copyButton.buttonElement.dataset.defaultLabel = "copy to clipboard", this._copyButton.buttonElement.addEventListener("click", this._handleCopyClickSafe);
1708
1724
  }
1709
1725
  _prepareFormatOptions() {
1710
- const t = this._definitions.map((e) => ({ value: e.format, label: e.label }));
1711
- this._formatSelect.update({ options: t, defaultValue: this._currentFormat });
1726
+ const e = this._definitions.map((t) => ({ value: t.format, label: t.label }));
1727
+ this._formatSelect.update({ options: e, defaultValue: this._currentFormat });
1712
1728
  }
1713
1729
  _registerEventHandlers() {
1714
- this._eventUnsubscribers.push(this._events.$on("export:request", ({ format: t }) => {
1715
- t === this._currentFormat && (this._state.$set({ isBusy: !0, error: void 0 }), this._updateExportButton());
1716
- }), this._events.$on("export:success", ({ format: t }) => {
1717
- if (t === this._currentFormat) {
1718
- const e = { isBusy: !1 };
1719
- t === "gif" && (e.gifProgress = void 0), t === "video" && (e.videoProgress = void 0), this._state.$set(e), this._updateExportButton();
1730
+ this._eventUnsubscribers.push(this._events.$on("export:request", ({ format: e }) => {
1731
+ e === this._currentFormat && (this._state.$set({ isBusy: !0, error: void 0 }), this._updateExportButton());
1732
+ }), this._events.$on("export:success", ({ format: e }) => {
1733
+ if (e === this._currentFormat) {
1734
+ const t = { isBusy: !1 };
1735
+ e === "gif" && (t.gifProgress = void 0), e === "video" && (t.videoProgress = void 0), this._state.$set(t), this._updateExportButton();
1720
1736
  }
1721
- }), this._events.$on("export:error", ({ format: t, error: e }) => {
1722
- t === this._currentFormat && (this._state.$set({ isBusy: !1, error: e }), this._updateExportButton());
1723
- }), this._events.$on("export:progress", ({ format: t, progress: e }) => {
1724
- if (e) {
1725
- if (t === "gif" && this._currentBlade?.blade instanceof ut) {
1726
- const r = e;
1737
+ }), this._events.$on("export:error", ({ format: e, error: t }) => {
1738
+ e === this._currentFormat && (this._state.$set({ isBusy: !1, error: t }), this._updateExportButton());
1739
+ }), this._events.$on("export:progress", ({ format: e, progress: t }) => {
1740
+ if (t) {
1741
+ if (e === "gif" && this._currentBlade?.blade instanceof ue) {
1742
+ const r = t;
1727
1743
  this._state.$set({ gifProgress: r }), this._currentBlade.blade.handleProgress(r);
1728
- } else if (t === "video" && this._currentBlade?.blade instanceof pt) {
1729
- const r = e;
1744
+ } else if (e === "video" && this._currentBlade?.blade instanceof pe) {
1745
+ const r = t;
1730
1746
  this._state.$set({ videoProgress: r }), this._currentBlade.blade.handleProgress(r);
1731
1747
  }
1732
1748
  this._updateExportButton();
1733
1749
  }
1734
1750
  }));
1735
1751
  }
1736
- _handleFormatChange(t) {
1737
- this._currentFormat = t, this._state.$set({ format: t }), this._switchFormat(t), this._events.$emit("format:change", { format: t });
1752
+ _handleFormatChange(e) {
1753
+ this._currentFormat = e, this._state.$set({ format: e }), this._switchFormat(e), this._events.$emit("format:change", { format: e });
1738
1754
  }
1739
- _switchFormat(t) {
1740
- const e = this._formats.get(t);
1741
- if (!e) throw new Error(`Unknown export format: ${t}`);
1742
- this._currentBlade && this._currentBlade.blade.unmount(), this._optionsContainer.innerHTML = "", e.blade.mount(this._optionsContainer), e.initialized || (e.blade.reset(), e.initialized = !0), this._currentBlade = e, this._formatSelect.value = t, this._updateCopyButtonState(), this._updateExportButton(), this._positionService?.scheduleUpdate();
1755
+ _switchFormat(e) {
1756
+ const t = this._formats.get(e);
1757
+ if (!t) throw new Error(`Unknown export format: ${e}`);
1758
+ this._currentBlade && this._currentBlade.blade.unmount(), this._optionsContainer.innerHTML = "", t.blade.mount(this._optionsContainer), t.initialized || (t.blade.reset(), t.initialized = !0), this._currentBlade = t, this._formatSelect.value = e, this._updateCopyButtonState(), this._updateExportButton(), this._positionService?.scheduleUpdate();
1743
1759
  }
1744
1760
  _updateCopyButtonState() {
1745
- const t = this._currentBlade?.definition.supportsClipboard ?? !1;
1746
- this._copyButtonContainer.style.display = t ? "flex" : "none", this._copyButton.setDisabled(!t);
1761
+ const e = this._currentBlade?.definition.supportsClipboard ?? !1;
1762
+ this._copyButtonContainer.style.display = e ? "flex" : "none", this._copyButton.setDisabled(!e);
1747
1763
  }
1748
1764
  async _handleExportClick() {
1749
1765
  if (!this._currentBlade) return;
1750
- const t = this._currentBlade.definition.format, e = this._currentBlade.blade.getOptions();
1766
+ const e = this._currentBlade.definition.format, t = this._currentBlade.blade.getOptions();
1751
1767
  if (this._currentBlade.blade.validate()) {
1752
- if (t === "gif") {
1768
+ if (e === "gif") {
1753
1769
  const r = this._currentBlade.blade;
1754
1770
  if (r.isRecording()) return;
1755
1771
  r.setRecordingState("recording");
1756
1772
  try {
1757
- await this._exportService.$requestExport("gif", e, { onGIFProgress: (a) => {
1773
+ await this._exportService.$requestExport("gif", t, { onGIFProgress: (a) => {
1758
1774
  r.setRecordingState(a.state, a);
1759
1775
  } });
1760
1776
  } catch (a) {
@@ -1764,12 +1780,12 @@ class Oe {
1764
1780
  r.setRecordingState("idle"), this._updateExportButton();
1765
1781
  }, 1600);
1766
1782
  }
1767
- if (t === "video") {
1783
+ if (e === "video") {
1768
1784
  const r = this._currentBlade.blade;
1769
1785
  if (r.isRecording()) return;
1770
1786
  r.setRecordingState("recording");
1771
1787
  try {
1772
- await this._exportService.$requestExport("video", e, { onVideoProgress: (a) => {
1788
+ await this._exportService.$requestExport("video", t, { onVideoProgress: (a) => {
1773
1789
  r.setRecordingState(a.state, a);
1774
1790
  } });
1775
1791
  } catch (a) {
@@ -1781,7 +1797,7 @@ class Oe {
1781
1797
  }
1782
1798
  this._exportButton.setDisabled(!0), this._exportButton.setLabel("exporting…");
1783
1799
  try {
1784
- await this._exportService.$requestExport(t, e);
1800
+ await this._exportService.$requestExport(e, t);
1785
1801
  } finally {
1786
1802
  this._exportButton.setDisabled(!1), this._exportButton.setLabel("download file");
1787
1803
  }
@@ -1789,10 +1805,10 @@ class Oe {
1789
1805
  }
1790
1806
  async _handleCopyClick() {
1791
1807
  if (!this._currentBlade || !this._currentBlade.definition.supportsClipboard) return;
1792
- const t = this._currentBlade.definition.format, e = this._currentBlade.blade.getOptions(), r = this._copyButton.buttonElement.dataset.defaultLabel ?? "copy to clipboard";
1808
+ const e = this._currentBlade.definition.format, t = this._currentBlade.blade.getOptions(), r = this._copyButton.buttonElement.dataset.defaultLabel ?? "copy to clipboard";
1793
1809
  this._copyButton.setDisabled(!0), this._copyButton.setLabel("copying…");
1794
1810
  try {
1795
- await this._clipboardService.$copy(t, e), this._copyButton.setLabel("copied!");
1811
+ await this._clipboardService.$copy(e, t), this._copyButton.setLabel("copied!");
1796
1812
  } catch (a) {
1797
1813
  console.error("[textmode-export] Failed to copy to clipboard", a), this._copyButton.setLabel("copy failed!");
1798
1814
  } finally {
@@ -1803,17 +1819,20 @@ class Oe {
1803
1819
  }
1804
1820
  _updateExportButton() {
1805
1821
  if (!this._currentBlade) return;
1806
- const t = this._currentBlade.definition.format;
1807
- if (t === "gif" && this._currentBlade.blade instanceof ut) {
1822
+ const e = this._currentBlade.definition.format;
1823
+ if (e === "gif" && this._currentBlade.blade instanceof ue) {
1808
1824
  const r = this._currentBlade.blade, a = this._state.snapshot.gifProgress;
1809
1825
  if (r.isRecording()) if (this._exportButton.setDisabled(!0), a?.totalFrames) {
1810
- const i = a.frameIndex ?? 0;
1811
- this._exportButton.setLabel(`recording ${i}/${a.totalFrames}`);
1812
- } else this._exportButton.setLabel("recording…");
1826
+ const i = a.frameIndex ?? 0, s = a.state === "encoding" ? "encoding" : "recording";
1827
+ this._exportButton.setLabel(`${s} ${i}/${a.totalFrames}`);
1828
+ } else {
1829
+ const i = a?.state === "encoding" ? "encoding" : "recording";
1830
+ this._exportButton.setLabel(`${i}…`);
1831
+ }
1813
1832
  else this._exportButton.setDisabled(!1), this._exportButton.setLabel("start recording");
1814
1833
  return;
1815
1834
  }
1816
- if (t === "video" && this._currentBlade.blade instanceof pt) {
1835
+ if (e === "video" && this._currentBlade.blade instanceof pe) {
1817
1836
  const r = this._currentBlade.blade, a = this._state.snapshot.videoProgress;
1818
1837
  if (r.isRecording()) if (this._exportButton.setDisabled(!0), a?.totalFrames) {
1819
1838
  const i = a.frameIndex ?? 0;
@@ -1822,23 +1841,23 @@ class Oe {
1822
1841
  else this._exportButton.setDisabled(!1), this._exportButton.setLabel("start recording");
1823
1842
  return;
1824
1843
  }
1825
- const e = this._state.snapshot.isBusy;
1826
- this._exportButton.setDisabled(e), this._exportButton.setLabel(e ? "exporting…" : "download file");
1844
+ const t = this._state.snapshot.isBusy;
1845
+ this._exportButton.setDisabled(t), this._exportButton.setLabel(t ? "exporting…" : "download file");
1827
1846
  }
1828
1847
  }
1829
- class Re {
1848
+ class Ut {
1830
1849
  _listeners = /* @__PURE__ */ new Map();
1831
- $on(t, e) {
1832
- this._listeners.has(t) || this._listeners.set(t, /* @__PURE__ */ new Set());
1833
- const r = this._listeners.get(t);
1834
- return r.add(e), () => {
1835
- r.delete(e), r.size === 0 && this._listeners.delete(t);
1850
+ $on(e, t) {
1851
+ this._listeners.has(e) || this._listeners.set(e, /* @__PURE__ */ new Set());
1852
+ const r = this._listeners.get(e);
1853
+ return r.add(t), () => {
1854
+ r.delete(t), r.size === 0 && this._listeners.delete(e);
1836
1855
  };
1837
1856
  }
1838
- $emit(t, e) {
1839
- const r = this._listeners.get(t);
1857
+ $emit(e, t) {
1858
+ const r = this._listeners.get(e);
1840
1859
  if (r) for (const a of [...r]) try {
1841
- a(e);
1860
+ a(t);
1842
1861
  } catch (i) {
1843
1862
  console.error("[textmode-export] Event handler failed", i);
1844
1863
  }
@@ -1847,50 +1866,50 @@ class Re {
1847
1866
  this._listeners.clear();
1848
1867
  }
1849
1868
  }
1850
- class Ue {
1869
+ class Nt {
1851
1870
  _state;
1852
1871
  _listeners = /* @__PURE__ */ new Set();
1853
- constructor(t) {
1854
- this._state = t;
1872
+ constructor(e) {
1873
+ this._state = e;
1855
1874
  }
1856
1875
  get snapshot() {
1857
1876
  return Object.freeze({ ...this._state });
1858
1877
  }
1859
- $set(t) {
1860
- this._state = Object.assign({}, this._state, t);
1861
- const e = this.snapshot;
1878
+ $set(e) {
1879
+ this._state = Object.assign({}, this._state, e);
1880
+ const t = this.snapshot;
1862
1881
  for (const r of [...this._listeners]) try {
1863
- r(e);
1882
+ r(t);
1864
1883
  } catch (a) {
1865
1884
  console.error("[textmode-export] State listener failed", a);
1866
1885
  }
1867
1886
  }
1868
- $subscribe(t) {
1869
- return this._listeners.add(t), t(this.snapshot), () => {
1870
- this._listeners.delete(t);
1887
+ $subscribe(e) {
1888
+ return this._listeners.add(e), e(this.snapshot), () => {
1889
+ this._listeners.delete(e);
1871
1890
  };
1872
1891
  }
1873
- $reset(t) {
1874
- this._state = t;
1875
- const e = this.snapshot;
1876
- for (const r of [...this._listeners]) r(e);
1892
+ $reset(e) {
1893
+ this._state = e;
1894
+ const t = this.snapshot;
1895
+ for (const r of [...this._listeners]) r(t);
1877
1896
  }
1878
1897
  }
1879
- const Ne = (s) => ({ format: s, isBusy: !1 });
1880
- class Gt extends T {
1898
+ const Gt = (o) => ({ format: o, isBusy: !1 });
1899
+ class Ge extends O {
1881
1900
  props;
1882
1901
  checkbox;
1883
1902
  labelElement;
1884
1903
  handleChange = () => {
1885
1904
  this.props.defaultChecked = this.checkbox.checked;
1886
1905
  };
1887
- constructor(t) {
1888
- super(), this.props = t;
1906
+ constructor(e) {
1907
+ super(), this.props = e;
1889
1908
  }
1890
1909
  render() {
1891
1910
  this.labelElement = document.createElement("label"), this.labelElement.classList.add(b.checkbox), this.checkbox = document.createElement("input"), this.checkbox.type = "checkbox", this.props.id && (this.checkbox.id = this.props.id), this.checkbox.checked = !!this.props.defaultChecked, this.checkbox.addEventListener("change", this.handleChange);
1892
- const t = document.createElement("span");
1893
- return t.textContent = this.props.label, this.labelElement.htmlFor = this.props.id ?? "", this.labelElement.appendChild(this.checkbox), this.labelElement.appendChild(t), this.labelElement;
1911
+ const e = document.createElement("span");
1912
+ return e.textContent = this.props.label, this.labelElement.htmlFor = this.props.id ?? "", this.labelElement.appendChild(this.checkbox), this.labelElement.appendChild(e), this.labelElement;
1894
1913
  }
1895
1914
  get inputElement() {
1896
1915
  return this.checkbox;
@@ -1898,24 +1917,24 @@ class Gt extends T {
1898
1917
  get checked() {
1899
1918
  return this.checkbox.checked;
1900
1919
  }
1901
- set checked(t) {
1902
- this.checkbox.checked = t;
1920
+ set checked(e) {
1921
+ this.checkbox.checked = e;
1903
1922
  }
1904
1923
  _onUnmount() {
1905
1924
  this.checkbox.removeEventListener("change", this.handleChange);
1906
1925
  }
1907
- onUpdate(t) {
1908
- 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);
1926
+ onUpdate(e) {
1927
+ this.props = e, e.id && (this.checkbox.id = e.id, this.labelElement.htmlFor = e.id), this.checkbox.checked = !!e.defaultChecked, this.labelElement.lastElementChild && (this.labelElement.lastElementChild.textContent = e.label);
1909
1928
  }
1910
1929
  }
1911
- class Ge extends T {
1930
+ class zt extends O {
1912
1931
  props;
1913
1932
  input;
1914
1933
  handleInput = () => {
1915
1934
  this.props.defaultValue = this.input.value;
1916
1935
  };
1917
- constructor(t) {
1918
- super(), this.props = t;
1936
+ constructor(e) {
1937
+ super(), this.props = e;
1919
1938
  }
1920
1939
  render() {
1921
1940
  return this.input = document.createElement("input"), this.input.type = "text", this.input.classList.add(b.input), this.props.id && (this.input.id = this.props.id), this.props.maxLength !== void 0 && (this.input.maxLength = this.props.maxLength), this.props.defaultValue !== void 0 && (this.input.value = this.props.defaultValue), this.input.addEventListener("input", this.handleInput), this.input;
@@ -1926,31 +1945,31 @@ class Ge extends T {
1926
1945
  get value() {
1927
1946
  return this.input.value;
1928
1947
  }
1929
- set value(t) {
1930
- this.input.value = t;
1948
+ set value(e) {
1949
+ this.input.value = e;
1931
1950
  }
1932
1951
  _onUnmount() {
1933
1952
  this.input.removeEventListener("input", this.handleInput);
1934
1953
  }
1935
- onUpdate(t) {
1936
- 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);
1954
+ onUpdate(e) {
1955
+ this.props = e, e.id && (this.input.id = e.id), e.maxLength !== void 0 && (this.input.maxLength = e.maxLength), e.defaultValue !== void 0 && (this.input.value = e.defaultValue);
1937
1956
  }
1938
1957
  }
1939
- class ze extends Y {
1940
- trailingSpaces = this._manageComponent(new Gt({ label: "preserve trailing spaces", defaultChecked: !1 }));
1941
- emptyCharacter = this._manageComponent(new Ge({ id: "textmode-export-empty-character", defaultValue: " ", maxLength: 1 }));
1942
- constructor(t) {
1943
- super(t);
1958
+ class Wt extends Y {
1959
+ trailingSpaces = this._manageComponent(new Ge({ label: "preserve trailing spaces", defaultChecked: !1 }));
1960
+ emptyCharacter = this._manageComponent(new zt({ id: "textmode-export-empty-character", defaultValue: " ", maxLength: 1 }));
1961
+ constructor(e) {
1962
+ super(e);
1944
1963
  }
1945
1964
  render() {
1946
- const t = document.createElement("div");
1947
- t.classList.add(b.stack), this.trailingSpaces.mount(t);
1948
- const e = new P({ label: "empty character", labelFor: "textmode-export-empty-character", variant: "full" });
1949
- return e.mount(t), this.emptyCharacter.mount(e.root), t;
1965
+ const e = document.createElement("div");
1966
+ e.classList.add(b.stack), this.trailingSpaces.mount(e);
1967
+ const t = new P({ label: "empty character", labelFor: "textmode-export-empty-character", variant: "full" });
1968
+ return t.mount(e), this.emptyCharacter.mount(t.root), e;
1950
1969
  }
1951
1970
  getOptions() {
1952
- const t = this._config.defaultOptions ?? {}, e = this.emptyCharacter.value || t.emptyCharacter || " ";
1953
- return { preserveTrailingSpaces: this.trailingSpaces.checked, emptyCharacter: e };
1971
+ const e = this._config.defaultOptions ?? {}, t = this.emptyCharacter.value || e.emptyCharacter || " ";
1972
+ return { preserveTrailingSpaces: this.trailingSpaces.checked, emptyCharacter: t };
1954
1973
  }
1955
1974
  reset() {
1956
1975
  this.applyDefaults();
@@ -1959,60 +1978,60 @@ class ze extends Y {
1959
1978
  return this.emptyCharacter.value.length <= 1;
1960
1979
  }
1961
1980
  applyDefaults() {
1962
- const t = this._config.defaultOptions ?? {};
1963
- this.trailingSpaces.checked = t.preserveTrailingSpaces ?? !1, this.emptyCharacter.value = t.emptyCharacter ?? " ";
1981
+ const e = this._config.defaultOptions ?? {};
1982
+ this.trailingSpaces.checked = e.preserveTrailingSpaces ?? !1, this.emptyCharacter.value = e.emptyCharacter ?? " ";
1964
1983
  }
1965
1984
  }
1966
- class We extends Y {
1967
- formatSelect = this._manageComponent(new mt({ id: "textmode-export-image-format", options: [{ value: "png", label: `PNG (${lt.png})` }, { value: "jpg", label: `JPG (${lt.jpg})` }, { value: "webp", label: `WEBP (${lt.webp})` }], defaultValue: "png" }));
1985
+ class qt extends Y {
1986
+ formatSelect = this._manageComponent(new me({ id: "textmode-export-image-format", options: [{ value: "png", label: `PNG (${le.png})` }, { value: "jpg", label: `JPG (${le.jpg})` }, { value: "webp", label: `WEBP (${le.webp})` }], defaultValue: "png" }));
1968
1987
  scaleInput = this._manageComponent(new G({ defaultValue: "1", attributes: { min: "0.1", step: "0.1" } }));
1969
- constructor(t) {
1970
- super(t);
1988
+ constructor(e) {
1989
+ super(e);
1971
1990
  }
1972
1991
  render() {
1973
- const t = document.createElement("div");
1974
- t.classList.add(b.stack);
1975
- const e = new j("row");
1976
- e.mount(t);
1992
+ const e = document.createElement("div");
1993
+ e.classList.add(b.stack);
1994
+ const t = new j("row");
1995
+ t.mount(e);
1977
1996
  const r = new P({ label: "image format", labelFor: "textmode-export-image-format", variant: "compact" });
1978
- r.mount(e.root), this.formatSelect.mount(r.root);
1997
+ r.mount(t.root), this.formatSelect.mount(r.root);
1979
1998
  const a = new P({ label: "scale", labelFor: "textmode-export-image-scale", variant: "dense" });
1980
- return a.mount(e.root), this.scaleInput.mount(a.root), this.scaleInput.inputElement.id = "textmode-export-image-scale", t;
1999
+ return a.mount(t.root), this.scaleInput.mount(a.root), this.scaleInput.inputElement.id = "textmode-export-image-scale", e;
1981
2000
  }
1982
2001
  getOptions() {
1983
- const t = Number.parseFloat(this.scaleInput.value);
1984
- return { format: this.formatSelect.value, scale: Number.isFinite(t) ? t : this._config.defaultOptions?.scale ?? 1 };
2002
+ const e = Number.parseFloat(this.scaleInput.value);
2003
+ return { format: this.formatSelect.value, scale: Number.isFinite(e) ? e : this._config.defaultOptions?.scale ?? 1 };
1985
2004
  }
1986
2005
  reset() {
1987
2006
  this.applyDefaults(), this.scaleInput.refresh();
1988
2007
  }
1989
2008
  validate() {
1990
- const t = Number.parseFloat(this.scaleInput.value);
1991
- return Number.isFinite(t) && t > 0;
2009
+ const e = Number.parseFloat(this.scaleInput.value);
2010
+ return Number.isFinite(e) && e > 0;
1992
2011
  }
1993
2012
  applyDefaults() {
1994
- const t = this._config.defaultOptions ?? {};
1995
- this.formatSelect.value = t.format ?? "png";
1996
- const e = t.scale ?? 1;
1997
- this.scaleInput.value = String(e);
2013
+ const e = this._config.defaultOptions ?? {};
2014
+ this.formatSelect.value = e.format ?? "png";
2015
+ const t = e.scale ?? 1;
2016
+ this.scaleInput.value = String(t);
1998
2017
  }
1999
2018
  }
2000
- class qe extends Y {
2001
- includeBackground = this._manageComponent(new Gt({ id: "textmode-export-svg-include-backgrounds", label: "include cell backgrounds", defaultChecked: !0 }));
2002
- drawMode = this._manageComponent(new mt({ id: "textmode-export-svg-draw-mode", options: [{ value: "fill", label: "fill" }, { value: "stroke", label: "stroke" }], defaultValue: "fill" }));
2019
+ class Ht extends Y {
2020
+ includeBackground = this._manageComponent(new Ge({ id: "textmode-export-svg-include-backgrounds", label: "include cell backgrounds", defaultChecked: !0 }));
2021
+ drawMode = this._manageComponent(new me({ id: "textmode-export-svg-draw-mode", options: [{ value: "fill", label: "fill" }, { value: "stroke", label: "stroke" }], defaultValue: "fill" }));
2003
2022
  strokeWidth = this._manageComponent(new G({ defaultValue: "1", attributes: { min: "0", step: "0.1" } }));
2004
- constructor(t) {
2005
- super(t);
2023
+ constructor(e) {
2024
+ super(e);
2006
2025
  }
2007
2026
  render() {
2008
- const t = document.createElement("div");
2009
- t.classList.add(b.stack), this.includeBackground.mount(t);
2010
- const e = new j("row");
2011
- e.mount(t);
2027
+ const e = document.createElement("div");
2028
+ e.classList.add(b.stack), this.includeBackground.mount(e);
2029
+ const t = new j("row");
2030
+ t.mount(e);
2012
2031
  const r = new P({ label: "draw mode", labelFor: "textmode-export-svg-draw-mode", variant: "compact" });
2013
- r.mount(e.root), this.drawMode.mount(r.root);
2032
+ r.mount(t.root), this.drawMode.mount(r.root);
2014
2033
  const a = new P({ label: "stroke width", labelFor: "textmode-export-svg-stroke-width", variant: "compact" });
2015
- return a.mount(e.root), this.strokeWidth.mount(a.root), this.strokeWidth.inputElement.id = "textmode-export-svg-stroke-width", this.drawMode.selectElement.addEventListener("change", () => this.updateStrokeControls()), this.updateStrokeControls(), t;
2034
+ return a.mount(t.root), this.strokeWidth.mount(a.root), this.strokeWidth.inputElement.id = "textmode-export-svg-stroke-width", this.drawMode.selectElement.addEventListener("change", () => this.updateStrokeControls()), this.updateStrokeControls(), e;
2016
2035
  }
2017
2036
  getOptions() {
2018
2037
  return { includeBackgroundRectangles: this.includeBackground.checked, drawMode: this.drawMode.value, strokeWidth: Number.parseFloat(this.strokeWidth.value) };
@@ -2021,45 +2040,47 @@ class qe extends Y {
2021
2040
  this.applyDefaults(), this.updateStrokeControls();
2022
2041
  }
2023
2042
  validate() {
2024
- const t = Number.parseFloat(this.strokeWidth.value);
2025
- return this.drawMode.value !== "stroke" || Number.isFinite(t) && t >= 0;
2043
+ const e = Number.parseFloat(this.strokeWidth.value);
2044
+ return this.drawMode.value !== "stroke" || Number.isFinite(e) && e >= 0;
2026
2045
  }
2027
2046
  updateStrokeControls() {
2028
- const t = this.drawMode.value === "stroke";
2029
- this.strokeWidth.inputElement.disabled = !t, this.strokeWidth.refresh();
2047
+ const e = this.drawMode.value === "stroke";
2048
+ this.strokeWidth.inputElement.disabled = !e, this.strokeWidth.refresh();
2030
2049
  }
2031
2050
  applyDefaults() {
2032
- const t = this._config.defaultOptions ?? {};
2033
- this.includeBackground.checked = t.includeBackgroundRectangles ?? !0, this.drawMode.value = t.drawMode ?? "fill";
2034
- const e = t.strokeWidth ?? 1;
2035
- this.strokeWidth.value = String(e), this.strokeWidth.refresh();
2036
- }
2037
- }
2038
- const He = [{ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, createBlade: () => new ze({ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, defaultOptions: { preserveTrailingSpaces: !1, emptyCharacter: " " } }) }, { format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, createBlade: () => new We({ format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, defaultOptions: { format: "png", scale: 1 } }) }, { format: "svg", label: "vector (.svg)", supportsClipboard: !0, createBlade: () => new qe({ format: "svg", label: "vector (.svg)", supportsClipboard: !0, defaultOptions: { includeBackgroundRectangles: !0, drawMode: "fill", strokeWidth: 1 } }) }, { format: "gif", label: "animated GIF (.gif)", supportsClipboard: !1, createBlade: () => new ut({ 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 pt({ format: "video", label: "video (.webm)", supportsClipboard: !1, defaultOptions: { frameCount: 480, frameRate: 60, quality: 0.7 } }) }];
2039
- function je() {
2040
- return He;
2041
- }
2042
- function Qe(s, t) {
2043
- const e = je(), r = e[0]?.format, a = new Ue(Ne(r)), i = new Re(), n = new Oe(s, t, a, i, e);
2044
- return n.$mount(), n;
2045
- }
2046
- const Xe = (s = {}) => {
2047
- const t = s.overlay ?? !0;
2048
- let e;
2049
- return { name: "textmode-export", version: "1.0.0", async install(r, a) {
2050
- const i = { saveCanvas: async (n = {}) => new bt().$saveImage(r.canvas, n), copyCanvas: async (n = {}) => new bt().$copyImageToClipboard(r.canvas, n), saveSVG: (n = {}) => {
2051
- new gt().$saveSVG(r, n);
2052
- }, saveStrings: (n = {}) => {
2053
- new vt().$saveTXT(r, n);
2054
- }, toSVG: (n = {}) => new gt().$generateSVG(r, n), toString: (n = {}) => new vt().$generateTXT(r, n), saveGIF: async (n = {}) => new me(r, a.registerPostDrawHook).$saveGIF(n), saveWEBM: async (n = {}) => new Ce(r, a.registerPostDrawHook).$saveWEBM(n) };
2055
- Object.assign(r, i), t && (e = Qe(r, i));
2056
- }, async uninstall(r) {
2057
- e?.$dispose(), e = void 0;
2058
- const a = ["saveCanvas", "copyCanvas", "saveSVG", "saveStrings", "toSVG", "toString", "saveGIF", "saveWEBM"];
2059
- for (const i of a) delete r[i];
2060
- } };
2051
+ const e = this._config.defaultOptions ?? {};
2052
+ this.includeBackground.checked = e.includeBackgroundRectangles ?? !0, this.drawMode.value = e.drawMode ?? "fill";
2053
+ const t = e.strokeWidth ?? 1;
2054
+ this.strokeWidth.value = String(t), this.strokeWidth.refresh();
2055
+ }
2056
+ }
2057
+ const jt = [{ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, createBlade: () => new Wt({ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, defaultOptions: { preserveTrailingSpaces: !1, emptyCharacter: " " } }) }, { format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, createBlade: () => new qt({ format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, defaultOptions: { format: "png", scale: 1 } }) }, { format: "svg", label: "vector (.svg)", supportsClipboard: !0, createBlade: () => new Ht({ format: "svg", label: "vector (.svg)", supportsClipboard: !0, defaultOptions: { includeBackgroundRectangles: !0, drawMode: "fill", strokeWidth: 1 } }) }, { format: "gif", label: "animated GIF (.gif)", supportsClipboard: !1, createBlade: () => new ue({ 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 pe({ format: "video", label: "video (.webm)", supportsClipboard: !1, defaultOptions: { frameCount: 480, frameRate: 60, quality: 0.7 } }) }];
2058
+ function Qt() {
2059
+ return jt;
2060
+ }
2061
+ function Xt(o, e) {
2062
+ const t = Qt(), r = t[0]?.format, a = new Nt(Gt(r)), i = new Ut(), s = new Rt(o, e, a, i, t);
2063
+ return s.$mount(), s;
2064
+ }
2065
+ const ze = { name: "textmode.export", version: "1.2.1", async install(o, e) {
2066
+ const t = { saveCanvas: async (s = {}) => new be().$saveImage(o.canvas, s), copyCanvas: async (s = {}) => new be().$copyImageToClipboard(o.canvas, s), saveSVG: (s = {}) => {
2067
+ new ge().$saveSVG(o, s);
2068
+ }, saveStrings: (s = {}) => {
2069
+ new ve().$saveTXT(o, s);
2070
+ }, toSVG: (s = {}) => new ge().$generateSVG(o, s), toString: (s = {}) => new ve().$generateTXT(o, s), saveGIF: async (s = {}) => new ft(o, e.registerPostDrawHook).$saveGIF(s), saveWEBM: async (s = {}) => new Et(o, e.registerPostDrawHook).$saveWEBM(s) }, r = Xt(o, t), a = { show: () => r.show(), hide: () => r.hide(), toggle: () => r.toggle(), isVisible: () => r.isVisible() }, i = { ...t, exportOverlay: a };
2071
+ Object.assign(o, i), o._exportOverlayController = r;
2072
+ }, async uninstall(o) {
2073
+ o._exportOverlayController?.$dispose(), delete o._exportOverlayController;
2074
+ const t = ["exportOverlay", "saveCanvas", "copyCanvas", "saveSVG", "saveStrings", "toSVG", "toString", "saveGIF", "saveWEBM"];
2075
+ for (const r of t) delete o[r];
2076
+ } }, Yt = (o = {}) => {
2077
+ const e = o.overlay ?? !0, t = { ...ze }, r = t.install;
2078
+ return t.install = async (a, i) => {
2079
+ await r.call(t, a, i), !e && a.exportOverlay.hide();
2080
+ }, t;
2061
2081
  };
2062
- typeof window < "u" && (window.createTextmodeExportPlugin = Xe);
2082
+ typeof window < "u" && (window.ExportPlugin = ze, window.createTextmodeExportPlugin = Yt);
2063
2083
  export {
2064
- Xe as createTextmodeExportPlugin
2084
+ ze as ExportPlugin,
2085
+ Yt as createTextmodeExportPlugin
2065
2086
  };