textmode.export.js 0.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,6 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("@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);transition:border-color .18s ease,box-shadow .18s ease,background .18s ease}.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}}")),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
1
  class At {
3
2
  $extractFramebufferData(t) {
4
- const e = t.readPixels(0), r = t.readPixels(1), a = t.readPixels(2), i = t.readPixels(3);
5
- return { characterPixels: e, primaryColorPixels: r, secondaryColorPixels: a, transformPixels: t.readPixels(4), rotationPixels: i };
3
+ return { characterPixels: t.readPixels(0), primaryColorPixels: t.readPixels(1), secondaryColorPixels: t.readPixels(2) };
6
4
  }
7
5
  $getCharacterIndex(t, e) {
8
6
  return t[e] + (t[e + 1] << 8);
@@ -26,13 +24,13 @@ class Q {
26
24
  return `textmode-export-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-")}`;
27
25
  }
28
26
  }
29
- function ft(o, t) {
30
- return { r: o[t], g: o[t + 1], b: o[t + 2], a: o[t + 3] };
27
+ function ft(s, t) {
28
+ return { r: s[t], g: s[t + 1], b: s[t + 2], a: s[t + 3] };
31
29
  }
32
- class qt extends At {
33
- _extractTransformData(t, e, r) {
34
- const a = t[r] === 255, i = t[r + 1] === 255, n = t[r + 2] === 255, c = e[r] + e[r + 1] / 255;
35
- return { isInverted: a, flipHorizontal: i, flipVertical: n, rotation: Math.round(360 * c / 255 * 100) / 100 };
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 };
36
34
  }
37
35
  _calculateCellPosition(t, e, r) {
38
36
  return { x: t, y: e, cellX: t * r.cellWidth, cellY: e * r.cellHeight };
@@ -42,70 +40,71 @@ class qt extends At {
42
40
  let a = 0;
43
41
  for (let i = 0; i < e.rows; i++) for (let n = 0; n < e.cols; n++) {
44
42
  const c = 4 * a, l = this.$getCharacterIndex(t.characterPixels, c);
45
- let h = ft(t.primaryColorPixels, c), s = ft(t.secondaryColorPixels, c);
46
- const d = this._extractTransformData(t.transformPixels, t.rotationPixels, c);
43
+ let p = ft(t.primaryColorPixels, c), o = ft(t.secondaryColorPixels, c);
44
+ const d = this._extractTransformData(t.characterPixels, c);
47
45
  if (d.isInverted) {
48
- const m = h;
49
- h = s, s = m;
46
+ const m = p;
47
+ p = o, o = m;
50
48
  }
51
49
  const u = this._calculateCellPosition(n, i, e);
52
- r.push({ charIndex: l, primaryColor: h, secondaryColor: s, transform: d, position: u }), a++;
50
+ r.push({ charIndex: l, primaryColor: p, secondaryColor: o, transform: d, position: u }), a++;
53
51
  }
54
52
  return r;
55
53
  }
56
54
  }
57
- class zt {
55
+ class qt {
58
56
  _createGlyphPath(t, e, r, a, i) {
59
57
  const n = i / t.head.unitsPerEm;
60
- return { 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) };
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) };
61
59
  }
62
60
  _glyphToSVGPath(t, e, r, a) {
63
61
  if (!t || !t.xs) return "";
64
62
  const { xs: i, ys: n, endPts: c, flags: l } = t;
65
63
  if (!(i && n && c && l)) return "";
66
- let h = "", s = 0;
64
+ let p = "", o = 0;
67
65
  for (let d = 0; d < c.length; d++) {
68
66
  const u = c[d];
69
- if (!(u < s)) {
70
- if (u >= s) {
71
- const m = e + i[s] * a, y = r - n[s] * a;
72
- h += `M${m.toFixed(2)},${y.toFixed(2)}`;
73
- let p = s + 1;
74
- for (; p <= u; )
75
- if (1 & l[p]) {
76
- const f = e + i[p] * a, _ = r - n[p] * a;
77
- h += `L${f.toFixed(2)},${_.toFixed(2)}`, p++;
67
+ if (!(u < o)) {
68
+ if (u >= o) {
69
+ const m = e + i[o] * a, x = r - n[o] * a;
70
+ p += `M${m.toFixed(2)},${x.toFixed(2)}`;
71
+ let h = o + 1;
72
+ for (; h <= u; )
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++;
78
76
  } else {
79
- const f = e + i[p] * a, _ = r - n[p] * a;
80
- let b = p + 1 > u ? s : p + 1;
81
- if (1 & l[b]) {
82
- const g = e + i[b] * a, C = r - n[b] * a;
83
- h += `Q${f.toFixed(2)},${_.toFixed(2)} ${g.toFixed(2)},${C.toFixed(2)}`, p = b + 1;
77
+ const f = e + i[h] * a, _ = r - n[h] * a;
78
+ let v = h + 1 > u ? o : h + 1;
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;
84
82
  } else {
85
- const g = (f + (e + i[b] * a)) / 2, C = (_ + (r - n[b] * a)) / 2;
86
- h += `Q${f.toFixed(2)},${_.toFixed(2)} ${g.toFixed(2)},${C.toFixed(2)}`, p = b;
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;
87
85
  }
88
86
  }
89
- h += "Z";
87
+ p += "Z";
90
88
  }
91
- s = u + 1;
89
+ o = u + 1;
92
90
  }
93
91
  }
94
- return h;
92
+ return p;
95
93
  }
96
94
  _generateCharacterPath(t, e, r, a, i) {
97
- const n = t.codePointAt(0) ?? 0, c = e.getGlyphData(n);
98
- return c ? this._createGlyphPath(e.font, c, r, a, i) : null;
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;
99
97
  }
100
98
  $generatePositionedCharacterPath(t, e, r, a, i, n, c, l) {
101
- const h = r + (i - l * (c / e.font.head.unitsPerEm)) / 2, s = a + (n + 0.7 * c) / 2, d = this._generateCharacterPath(t, e, h, s, c);
102
- return d && d.toSVG() || null;
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);
101
+ return u && u.toSVG() || null;
103
102
  }
104
103
  }
105
- class jt {
104
+ class Ht {
106
105
  _pathGenerator;
107
106
  constructor() {
108
- this._pathGenerator = new zt();
107
+ this._pathGenerator = new qt();
109
108
  }
110
109
  $generateSVGHeader(t) {
111
110
  const { width: e, height: r } = t;
@@ -119,22 +118,22 @@ class jt {
119
118
  if (!r.flipHorizontal && !r.flipVertical && !r.rotation) return "";
120
119
  const i = a.cellX + e.cellWidth / 2, n = a.cellY + e.cellHeight / 2, c = [];
121
120
  if (r.flipHorizontal || r.flipVertical) {
122
- const l = r.flipHorizontal ? -1 : 1, h = r.flipVertical ? -1 : 1;
123
- c.push(`translate(${i} ${n})scale(${l} ${h})translate(${-i} ${-n})`);
121
+ const l = r.flipHorizontal ? -1 : 1, p = r.flipVertical ? -1 : 1;
122
+ c.push(`translate(${i} ${n})scale(${l} ${p})translate(${-i} ${-n})`);
124
123
  }
125
124
  return r.rotation && c.push(`rotate(${r.rotation} ${i} ${n})`), ` transform="${c.join(" ")}"`;
126
125
  }
127
126
  _generateCellBackground(t, e, r) {
128
127
  if (!r.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
129
- const { position: a } = t, { r: i, g: n, b: c, a: l } = t.secondaryColor, h = `rgba(${i},${n},${c},${l / 255})`;
130
- return r.drawMode === "stroke" ? `<rect x="${a.cellX}" y="${a.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${h}" fill="none" stroke-width="${r.strokeWidth}"/>` : `<rect x="${a.cellX}" y="${a.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${h}"/>`;
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}"/>`;
131
130
  }
132
131
  _generateCharacterPath(t, e, r, a) {
133
132
  const i = r.characters[t.charIndex];
134
133
  if (!i) return "";
135
- const n = this._pathGenerator.$generatePositionedCharacterPath(i.character, r, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, r.fontSize, i.advanceWidth);
134
+ const n = this._pathGenerator.$generatePositionedCharacterPath(i.character, r, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, r.fontSize, i.glyphData);
136
135
  if (!n) return "";
137
- const { r: c, g: l, b: h, a: s } = t.primaryColor, d = `rgba(${c},${l},${h},${s / 255})`;
136
+ const { r: c, g: l, b: p, a: o } = t.primaryColor, d = `rgba(${c},${l},${p},${o / 255})`;
138
137
  return a.drawMode === "stroke" ? `<path d="${n}" stroke="${d}" stroke-width="${a.strokeWidth}" fill="none"/>` : `<path d="${n}" fill="${d}"/>`;
139
138
  }
140
139
  $generateCellContent(t, e, r, a) {
@@ -161,27 +160,27 @@ class gt {
161
160
  return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, filename: t.filename };
162
161
  }
163
162
  $generateSVG(t, e = {}) {
164
- const r = new qt(), a = new jt(), i = r.$extractSVGCellData(r.$extractFramebufferData(t.drawFramebuffer), t.grid), n = a.$generateSVGContent(i, t.grid, t.font, this._applyDefaultOptions(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));
165
164
  return a.$optimizeSVGContent(n);
166
165
  }
167
166
  $saveSVG(t, e = {}) {
168
167
  new Q().$downloadFile(new Blob([this.$generateSVG(t, e)], { type: "image/svg+xml;charset=utf-8" }), e.filename);
169
168
  }
170
169
  }
171
- const ot = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, lt = { png: ".png", jpg: ".jpg", webp: ".webp" };
172
- class vt {
170
+ const st = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, lt = { png: ".png", jpg: ".jpg", webp: ".webp" };
171
+ class bt {
173
172
  _applyDefaultOptions(t) {
174
173
  return { format: t.format ?? "png", scale: Math.abs(t.scale ?? 1), filename: t.filename };
175
174
  }
176
175
  _validateOptions(t) {
177
- if (!(t.format in ot)) throw new Error(`Saving '${t.format}' files is not supported`);
176
+ if (!(t.format in st)) throw new Error(`Saving '${t.format}' files is not supported`);
178
177
  }
179
178
  async $generateImageBlob(t, e) {
180
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);
181
- 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, h) => {
182
- a.toBlob((s) => {
183
- s ? l(s) : h(new Error(`Failed to generate ${e.format.toUpperCase()} blob`));
184
- }, ot[e.format]);
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]);
185
184
  });
186
185
  }
187
186
  async $saveImage(t, e = {}) {
@@ -194,11 +193,11 @@ class vt {
194
193
  if (typeof navigator > "u" || !navigator.clipboard || typeof navigator.clipboard.write != "function") throw new Error("Clipboard API is not available in this environment");
195
194
  const r = this._applyDefaultOptions(e);
196
195
  this._validateOptions(r);
197
- const a = await this.$generateImageBlob(t, r), i = new ClipboardItem({ [ot[r.format]]: a });
196
+ const a = await this.$generateImageBlob(t, r), i = new ClipboardItem({ [st[r.format]]: a });
198
197
  await navigator.clipboard.write([i]);
199
198
  }
200
199
  }
201
- class bt {
200
+ class vt {
202
201
  _applyDefaultOptions(t) {
203
202
  return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename };
204
203
  }
@@ -208,17 +207,17 @@ class bt {
208
207
  const i = [];
209
208
  let n = 0;
210
209
  for (let l = 0; l < t.grid.rows; l++) {
211
- const h = [];
212
- for (let s = 0; s < t.grid.cols; s++) {
210
+ const p = [];
211
+ for (let o = 0; o < t.grid.cols; o++) {
213
212
  const d = 4 * n, u = r.$getCharacterIndex(a.characterPixels, d), m = t.font.characters[u]?.character || e.emptyCharacter;
214
- h.push(m), n++;
213
+ p.push(m), n++;
215
214
  }
216
- i.push(h);
215
+ i.push(p);
217
216
  }
218
217
  const c = [];
219
218
  for (const l of i) {
220
- let h = l.join("");
221
- e.preserveTrailingSpaces || (h = h.replace(/\s+$/, "")), c.push(h);
219
+ let p = l.join("");
220
+ e.preserveTrailingSpaces || (p = p.replace(/\s+$/, "")), c.push(p);
222
221
  }
223
222
  return c.join(`
224
223
  `);
@@ -231,33 +230,33 @@ class bt {
231
230
  new Q().$downloadFile(i, r.filename);
232
231
  }
233
232
  }
234
- class Ht {
233
+ class jt {
235
234
  _canvas;
236
235
  _ctx;
237
236
  async $record(t, e, r, a) {
238
237
  const i = Math.max(1, Math.round(e.frameRate)), n = Math.round(1e3 / i), c = Math.max(1, Math.round(e.frameCount));
239
- return await new Promise((l, h) => {
240
- const s = [];
238
+ return await new Promise((l, p) => {
239
+ const o = [];
241
240
  let d, u = 0, m = !1;
242
- const y = () => {
241
+ const x = () => {
243
242
  d && (d(), d = void 0);
244
- }, p = (_) => {
245
- m || (m = !0, y(), l(_));
243
+ }, h = (_) => {
244
+ m || (m = !0, x(), l(_));
246
245
  }, f = () => {
247
- if (u >= c) p(s);
246
+ if (u >= c) h(o);
248
247
  else try {
249
- const _ = e.scale, b = Math.max(1, Math.round(t.width * _)), g = Math.max(1, Math.round(t.height * _));
250
- this._canvas || (this._canvas = document.createElement("canvas")), this._canvas.width === b && this._canvas.height === g || (this._canvas.width = b, this._canvas.height = g), this._ctx || (this._ctx = this._canvas.getContext("2d"));
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"));
251
250
  const C = this._ctx;
252
- C.imageSmoothingEnabled = !1, C.clearRect(0, 0, b, g), C.drawImage(t, 0, 0, t.width, t.height, 0, 0, b, g);
253
- const S = { imageData: C.getImageData(0, 0, b, g), width: b, height: g, delayMs: n };
254
- s.push(S), u += 1, a?.({ state: "recording", frameIndex: u, totalFrames: c }), u >= c && p(s);
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);
255
254
  } catch (_) {
256
- ((b) => {
255
+ ((v) => {
257
256
  if (m) return;
258
- m = !0, y();
259
- const g = b instanceof Error ? b.message : "GIF recording failed";
260
- a?.({ state: "error", message: g }), h(b instanceof Error ? b : new Error(String(b)));
257
+ 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)));
261
260
  })(_);
262
261
  }
263
262
  };
@@ -267,9 +266,9 @@ class Ht {
267
266
  });
268
267
  }
269
268
  }
270
- var Pt = Object.defineProperty, Qt = (o) => Pt(o, "__esModule", { value: !0 }), Xt = (o, t) => () => (t || o((t = { exports: {} }).exports, t), t.exports), Yt = (o, t) => {
271
- for (var e in t) Pt(o, e, { get: t[e], enumerable: !0 });
272
- }, Jt = Xt((o) => {
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) => {
273
272
  function t(d, u, m) {
274
273
  return 0.29889531 * d + 0.58662247 * u + 0.11448223 * m;
275
274
  }
@@ -280,8 +279,8 @@ var Pt = Object.defineProperty, Qt = (o) => Pt(o, "__esModule", { value: !0 }),
280
279
  return 0.21147017 * d - 0.52261711 * u + 0.31114694 * m;
281
280
  }
282
281
  function a(d, u) {
283
- let m = d[0] - u[0], y = d[1] - u[1], p = d[2] - u[2], f = i(d) - i(u);
284
- return m * m * 0.5053 + y * y * 0.299 + p * p * 0.1957 + f * f;
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;
285
284
  }
286
285
  function i(d) {
287
286
  return d[3] != null ? d[3] : 255;
@@ -290,27 +289,27 @@ var Pt = Object.defineProperty, Qt = (o) => Pt(o, "__esModule", { value: !0 }),
290
289
  return Math.sqrt(a(d, u));
291
290
  }
292
291
  function c(d, u) {
293
- let [m, y, p] = d, [f, _, b] = u, g = t(m, y, p) - t(f, _, b), C = e(m, y, p) - e(f, _, b), S = r(m, y, p) - r(f, _, b), E = i(d) - i(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);
294
293
  return g * g * 0.5053 + C * C * 0.299 + S * S * 0.1957 + E * E;
295
294
  }
296
295
  function l(d, u) {
297
296
  return Math.sqrt(c(d, u));
298
297
  }
299
- function h(d, u) {
300
- var m, y = 0;
298
+ function p(d, u) {
299
+ var m, x = 0;
301
300
  for (m = 0; m < d.length; m++) {
302
- let p = d[m] - u[m];
303
- y += p * p;
301
+ let h = d[m] - u[m];
302
+ x += h * h;
304
303
  }
305
- return y;
304
+ return x;
306
305
  }
307
- function s(d, u) {
308
- return Math.sqrt(h(d, u));
306
+ function o(d, u) {
307
+ return Math.sqrt(p(d, u));
309
308
  }
310
- Qt(o), Yt(o, { colorDifferenceRGBToYIQ: () => l, colorDifferenceRGBToYIQSquared: () => c, colorDifferenceYIQ: () => n, colorDifferenceYIQSquared: () => a, euclideanDistance: () => s, euclideanDistanceSquared: () => h });
309
+ Qt(s), Yt(s, { colorDifferenceRGBToYIQ: () => l, colorDifferenceRGBToYIQSquared: () => c, colorDifferenceYIQ: () => n, colorDifferenceYIQSquared: () => a, euclideanDistance: () => o, euclideanDistanceSquared: () => p });
311
310
  }), Kt = { trailer: 59 };
312
- function Dt(o = 256) {
313
- let t = 0, e = new Uint8Array(o);
311
+ function Dt(s = 256) {
312
+ let t = 0, e = new Uint8Array(s);
314
313
  return { get buffer() {
315
314
  return e.buffer;
316
315
  }, reset() {
@@ -331,71 +330,71 @@ function Dt(o = 256) {
331
330
  e = new Uint8Array(a), t > 0 && e.set(n.subarray(0, t), 0);
332
331
  }
333
332
  }
334
- var Z = 12, yt = 5003, Zt = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535];
335
- function te(o, t, e, r, a, i, n, c) {
336
- a = a || Dt(512), i = i || new Uint8Array(256), n = n || new Int32Array(yt), c = c || new Int32Array(yt);
337
- let l = n.length, h = Math.max(2, r);
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);
338
337
  i.fill(0), c.fill(0), L();
339
- let s = 0, d = 0, u = h + 1, m = u, y = !1, p = m, f = D(p), _ = 1 << u - 1, b = _ + 1, g = _ + 2, C = 0, S = e[0], E = 0;
340
- for (let B = l; B < 65536; B *= 2) ++E;
341
- E = 8 - E, a.writeByte(h), T(_);
342
- for (let B = 1; B < e.length; B++) V(e[B]);
343
- return T(S), T(b), a.writeByte(0), a.bytesView();
344
- function A(B) {
345
- i[C++] = B, C >= 254 && I();
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;
339
+ 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();
343
+ function A(k) {
344
+ i[C++] = k, C >= 254 && B();
346
345
  }
347
346
  function L() {
348
347
  n.fill(-1);
349
348
  }
350
- function V(B) {
351
- let R = (B << Z) + S, w = B << E ^ S;
352
- if (n[w] === R) S = c[w];
349
+ function V(k) {
350
+ let R = (k << Z) + S, y = k << E ^ S;
351
+ if (n[y] === R) S = c[y];
353
352
  else {
354
- if (n[w] >= 0) {
355
- let x = w === 0 ? 1 : l - w;
353
+ if (n[y] >= 0) {
354
+ let w = y === 0 ? 1 : l - y;
356
355
  do
357
- if (w -= x, w < 0 && (w += l), n[w] === R) return void (S = c[w]);
358
- while (n[w] >= 0);
356
+ if (y -= w, y < 0 && (y += l), n[y] === R) return void (S = c[y]);
357
+ while (n[y] >= 0);
359
358
  }
360
- T(S), S = B, g < 1 << Z ? (c[w] = g++, n[w] = R) : (L(), g = _ + 2, y = !0, T(_));
359
+ O(S), S = k, g < 1 << Z ? (c[y] = g++, n[y] = R) : (L(), g = _ + 2, x = !0, O(_));
361
360
  }
362
361
  }
363
- function I() {
362
+ function B() {
364
363
  C > 0 && (a.writeByte(C), a.writeBytesView(i, 0, C), C = 0);
365
364
  }
366
- function D(B) {
367
- return (1 << B) - 1;
365
+ function D(k) {
366
+ return (1 << k) - 1;
368
367
  }
369
- function T(B) {
370
- for (s &= Zt[d], d > 0 ? s |= B << d : s = B, d += p; d >= 8; ) A(255 & s), s >>= 8, d -= 8;
371
- if ((g > f || y) && (y ? (p = m, f = D(p), y = !1) : (++p, f = p == Z ? 1 << Z : D(p))), B == b) {
372
- for (; d > 0; ) A(255 & s), s >>= 8, d -= 8;
373
- I();
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;
372
+ B();
374
373
  }
375
374
  }
376
375
  }
377
376
  var ee = te;
378
- function Vt(o, t, e) {
379
- return o << 8 & 63488 | t << 2 & 992 | e >> 3 & 31;
377
+ function Vt(s, t, e) {
378
+ return s << 8 & 63488 | t << 2 & 992 | e >> 3 & 31;
380
379
  }
381
- function Ot(o, t, e, r) {
382
- return o >> 4 | 240 & t | (240 & e) << 4 | (240 & r) << 8;
380
+ function Tt(s, t, e, r) {
381
+ return s >> 4 | 240 & t | (240 & e) << 4 | (240 & r) << 8;
383
382
  }
384
- function Tt(o, t, e) {
385
- return o >> 4 << 8 | t >> 4 << 4 | e >> 4;
383
+ function Ot(s, t, e) {
384
+ return s >> 4 << 8 | t >> 4 << 4 | e >> 4;
386
385
  }
387
- function tt(o, t, e) {
388
- return o < t ? t : o > e ? e : o;
386
+ function tt(s, t, e) {
387
+ return s < t ? t : s > e ? e : s;
389
388
  }
390
- function at(o) {
391
- return o * o;
389
+ function at(s) {
390
+ return s * s;
392
391
  }
393
- function wt(o, t, e) {
394
- for (var r = 0, a = 1e100, i = o[t], n = i.cnt, c = (i.ac, i.rc), l = i.gc, h = i.bc, s = i.fw; s != 0; s = o[s].fw) {
395
- var d = o[s].cnt, u = n * d / (n + d);
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);
396
395
  if (!(u >= a)) {
397
396
  var m = 0;
398
- !((m += u * at(o[s].rc - c)) >= a) && !((m += u * at(o[s].gc - l)) >= a) && !((m += u * at(o[s].bc - h)) >= a) && (a = m, r = s);
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);
399
398
  }
400
399
  }
401
400
  i.err = a, i.nn = r;
@@ -403,100 +402,100 @@ function wt(o, t, e) {
403
402
  function dt() {
404
403
  return { ac: 0, rc: 0, gc: 0, bc: 0, cnt: 0, nn: 0, fw: 0, bk: 0, tm: 0, mtm: 0, err: 0 };
405
404
  }
406
- function re(o, t) {
407
- let e = new Array(t === "rgb444" ? 4096 : 65536), r = o.length;
405
+ function re(s, t) {
406
+ let e = new Array(t === "rgb444" ? 4096 : 65536), r = s.length;
408
407
  if (t === "rgba4444") for (let a = 0; a < r; ++a) {
409
- let i = o[a], n = i >> 24 & 255, c = i >> 16 & 255, l = i >> 8 & 255, h = 255 & i, s = Ot(h, l, c, n), d = s in e ? e[s] : e[s] = dt();
410
- d.rc += h, d.gc += l, d.bc += c, d.ac += n, d.cnt++;
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++;
411
410
  }
412
411
  else if (t === "rgb444") for (let a = 0; a < r; ++a) {
413
- let i = o[a], n = i >> 16 & 255, c = i >> 8 & 255, l = 255 & i, h = Tt(l, c, n), s = h in e ? e[h] : e[h] = dt();
414
- s.rc += l, s.gc += c, s.bc += n, s.cnt++;
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++;
415
414
  }
416
415
  else for (let a = 0; a < r; ++a) {
417
- let i = o[a], n = i >> 16 & 255, c = i >> 8 & 255, l = 255 & i, h = Vt(l, c, n), s = h in e ? e[h] : e[h] = dt();
418
- s.rc += l, s.gc += c, s.bc += n, s.cnt++;
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++;
419
418
  }
420
419
  return e;
421
420
  }
422
- function ae(o, t, e) {
423
- let { format: r = "rgb565", clearAlpha: a = !0, clearAlphaColor: i = 0, clearAlphaThreshold: n = 0, oneBitAlpha: c = !1 } = e || {}, l = e.useSqrt !== !1, h = r === "rgba4444", s = re(o, r), d = s.length, u = d - 1, m = new Uint32Array(d + 1);
424
- for (var y = 0, p = 0; p < s.length; ++p) {
425
- let B = s[p];
426
- if (B != null) {
427
- var f = 1 / B.cnt;
428
- h && (B.ac *= f), B.rc *= f, B.gc *= f, B.bc *= f, s[y++] = B;
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];
425
+ 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;
429
428
  }
430
429
  }
431
- for (at(t) / y < 0.022 && (l = !1), p = 0; p < y - 1; ++p) s[p].fw = p + 1, s[p + 1].bk = p, l && (s[p].cnt = Math.sqrt(s[p].cnt));
432
- var _, b, g;
433
- for (l && (s[p].cnt = Math.sqrt(s[p].cnt)), p = 0; p < y; ++p) {
434
- wt(s, p);
435
- var C = s[p].err;
436
- for (b = ++m[0]; b > 1 && !(s[_ = m[g = b >> 1]].err <= C); b = g) m[b] = _;
437
- m[b] = p;
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] = _;
436
+ m[v] = h;
438
437
  }
439
- var S = y - t;
440
- for (p = 0; p < S; ) {
438
+ var S = x - t;
439
+ for (h = 0; h < S; ) {
441
440
  for (var E; ; ) {
442
441
  var A = m[1];
443
- if ((E = s[A]).tm >= E.mtm && s[E.nn].mtm <= E.tm) break;
444
- for (E.mtm == u ? A = m[1] = m[m[0]--] : (wt(s, A), E.tm = p), C = s[A].err, b = 1; (g = b + b) <= m[0] && (g < m[0] && s[m[g]].err > s[m[g + 1]].err && g++, !(C <= s[_ = m[g]].err)); b = g) m[b] = _;
445
- m[b] = A;
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] = _;
444
+ m[v] = A;
446
445
  }
447
- var L = s[E.nn], V = E.cnt, I = L.cnt;
448
- f = 1 / (V + I), h && (E.ac = f * (V * E.ac + I * L.ac)), E.rc = f * (V * E.rc + I * L.rc), E.gc = f * (V * E.gc + I * L.gc), E.bc = f * (V * E.bc + I * L.bc), E.cnt += L.cnt, E.mtm = ++p, s[L.bk].fw = L.fw, s[L.fw].bk = L.bk, L.mtm = u;
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;
449
448
  }
450
449
  let D = [];
451
- var T = 0;
452
- for (p = 0; ; ++T) {
453
- let B = tt(Math.round(s[p].rc), 0, 255), R = tt(Math.round(s[p].gc), 0, 255), w = tt(Math.round(s[p].bc), 0, 255), x = 255;
454
- h && (x = tt(Math.round(s[p].ac), 0, 255), c && (x = x <= (typeof c == "number" ? c : 127) ? 0 : 255), a && x <= n && (B = R = w = i, x = 0));
455
- let k = h ? [B, R, w, x] : [B, R, w];
456
- if (ie(D, k) || D.push(k), (p = s[p].fw) == 0) break;
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;
457
456
  }
458
457
  return D;
459
458
  }
460
- function ie(o, t) {
461
- for (let e = 0; e < o.length; e++) {
462
- let r = o[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];
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];
463
462
  if (a && i) return !0;
464
463
  }
465
464
  return !1;
466
465
  }
467
- function se(o, t, e) {
468
- let r = (e = e || "rgb565") === "rgb444" ? 4096 : 65536, a = new Uint8Array(o.length), i = new Array(r);
469
- if (e === "rgba4444") for (let n = 0; n < o.length; n++) {
470
- let c, l = o[n], h = l >> 24 & 255, s = l >> 16 & 255, d = l >> 8 & 255, u = 255 & l, m = Ot(u, d, s, h);
471
- i[m] != null ? c = i[m] : (c = ne(u, d, s, h, t), i[m] = c), a[n] = c;
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;
472
471
  }
473
- else for (let n = 0; n < o.length; n++) {
474
- let c, l = o[n], h = l >> 16 & 255, s = l >> 8 & 255, d = 255 & l, u = e === "rgb444" ? Tt(d, s, h) : Vt(d, s, h);
475
- i[u] != null ? c = i[u] : (c = oe(d, s, h, t), i[u] = c), a[n] = c;
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;
476
475
  }
477
476
  return a;
478
477
  }
479
- function ne(o, t, e, r, a) {
478
+ function ne(s, t, e, r, a) {
480
479
  let i = 0, n = 1e100;
481
480
  for (let c = 0; c < a.length; c++) {
482
- let l = a[c], h = l[0], s = l[1], d = l[2], u = q(l[3] - r);
483
- u > n || (u += q(h - o), !(u > n) && (u += q(s - t), !(u > n) && (u += q(d - e), !(u > n) && (n = u, i = 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))));
484
483
  }
485
484
  return i;
486
485
  }
487
- function oe(o, t, e, r) {
486
+ function se(s, t, e, r) {
488
487
  let a = 0, i = 1e100;
489
488
  for (let n = 0; n < r.length; n++) {
490
- let c = r[n], l = c[0], h = c[1], s = c[2], d = q(l - o);
491
- d > i || (d += q(h - t), !(d > i) && (d += q(s - e), !(d > i) && (i = d, a = 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)));
492
491
  }
493
492
  return a;
494
493
  }
495
- function q(o) {
496
- return o * o;
494
+ function W(s) {
495
+ return s * s;
497
496
  }
498
- function le(o = {}) {
499
- let { initialCapacity: t = 4096, auto: e = !0 } = o, r = Dt(t), a = new Uint8Array(256), i = new Int32Array(5003), n = new Int32Array(5003), c = !1;
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;
500
499
  return { reset() {
501
500
  r.reset(), c = !1;
502
501
  }, finish() {
@@ -505,56 +504,56 @@ function le(o = {}) {
505
504
  return r.buffer;
506
505
  }, get stream() {
507
506
  return r;
508
- }, writeHeader: l, writeFrame(h, s, d, u = {}) {
509
- let { transparent: m = !1, transparentIndex: y = 0, delay: p = 0, palette: f = null, repeat: _ = 0, colorDepth: b = 8, dispose: g = -1 } = u, C = !1;
510
- if (e ? c || (C = !0, l(), c = !0) : C = !!u.first, s = Math.max(0, Math.floor(s)), d = Math.max(0, Math.floor(d)), C) {
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) {
511
510
  if (!f) throw new Error("First frame must include a { palette } option");
512
- ce(r, s, d, f, b), _t(r, f), _ >= 0 && ue(r, _);
511
+ ce(r, o, d, f, v), _t(r, f), _ >= 0 && ue(r, _);
513
512
  }
514
- let S = Math.round(p / 10);
515
- de(r, g, S, m, y);
513
+ let S = Math.round(h / 10);
514
+ de(r, g, S, m, x);
516
515
  let E = !!f && !C;
517
- he(r, s, d, E ? f : null), E && _t(r, f), pe(r, h, s, d, b, a, i, n);
516
+ pe(r, o, d, E ? f : null), E && _t(r, f), he(r, p, o, d, v, a, i, n);
518
517
  } };
519
518
  function l() {
520
519
  Rt(r, "GIF89a");
521
520
  }
522
521
  }
523
- function de(o, t, e, r, a) {
522
+ function de(s, t, e, r, a) {
524
523
  var i, n;
525
- o.writeByte(33), o.writeByte(249), o.writeByte(4), a < 0 && (a = 0, r = !1), r ? (i = 1, n = 2) : (i = 0, n = 0), t >= 0 && (n = 7 & t), n <<= 2, o.writeByte(0 | n | i), N(o, e), o.writeByte(a || 0), o.writeByte(0);
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);
526
525
  }
527
- function ce(o, t, e, r, a = 8) {
528
- let i = 128 | a - 1 << 4 | pt(r.length) - 1;
529
- N(o, t), N(o, e), o.writeBytes([i, 0, 0]);
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]);
530
529
  }
531
- function ue(o, t) {
532
- o.writeByte(33), o.writeByte(255), o.writeByte(11), Rt(o, "NETSCAPE2.0"), o.writeByte(3), o.writeByte(1), N(o, t), o.writeByte(0);
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);
533
532
  }
534
- function _t(o, t) {
535
- let e = 1 << pt(t.length);
533
+ function _t(s, t) {
534
+ let e = 1 << ht(t.length);
536
535
  for (let r = 0; r < e; r++) {
537
536
  let a = [0, 0, 0];
538
- r < t.length && (a = t[r]), o.writeByte(a[0]), o.writeByte(a[1]), o.writeByte(a[2]);
537
+ r < t.length && (a = t[r]), s.writeByte(a[0]), s.writeByte(a[1]), s.writeByte(a[2]);
539
538
  }
540
539
  }
541
- function he(o, t, e, r) {
542
- if (o.writeByte(44), N(o, 0), N(o, 0), N(o, t), N(o, e), r) {
543
- let a = 0, i = 0, n = pt(r.length) - 1;
544
- o.writeByte(128 | a | i | n);
545
- } else o.writeByte(0);
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);
546
545
  }
547
- function pe(o, t, e, r, a = 8, i, n, c) {
548
- ee(e, r, t, a, o, i, n, c);
546
+ function he(s, t, e, r, a = 8, i, n, c) {
547
+ ee(e, r, t, a, s, i, n, c);
549
548
  }
550
- function N(o, t) {
551
- o.writeByte(255 & t), o.writeByte(t >> 8 & 255);
549
+ function N(s, t) {
550
+ s.writeByte(255 & t), s.writeByte(t >> 8 & 255);
552
551
  }
553
- function Rt(o, t) {
554
- for (var e = 0; e < t.length; e++) o.writeByte(t.charCodeAt(e));
552
+ function Rt(s, t) {
553
+ for (var e = 0; e < t.length; e++) s.writeByte(t.charCodeAt(e));
555
554
  }
556
- function pt(o) {
557
- return Math.max(Math.ceil(Math.log2(o)), 1);
555
+ function ht(s) {
556
+ return Math.max(Math.ceil(Math.log2(s)), 1);
558
557
  }
559
558
  Jt();
560
559
  class me {
@@ -562,18 +561,18 @@ class me {
562
561
  _textmodifier;
563
562
  _registerPostDrawHook;
564
563
  constructor(t, e) {
565
- this._recorder = new Ht(), this._textmodifier = t, this._registerPostDrawHook = e;
564
+ this._recorder = new jt(), this._textmodifier = t, this._registerPostDrawHook = e;
566
565
  }
567
566
  async $saveGIF(t = {}) {
568
567
  const e = this._textmodifier.canvas, r = this._applyDefaultOptions(t), a = t.onProgress;
569
568
  try {
570
569
  const i = await this._recorder.$record(e, r, this._registerPostDrawHook, a), n = le(), { repeat: c } = t;
571
- i.forEach((s, d) => {
572
- const { width: u, height: m, imageData: y, delayMs: p } = s, f = new Uint32Array(y.data.buffer.slice(0)), _ = ae(f, 256, {}), b = se(f, _);
573
- n.writeFrame(b, u, m, { palette: _, delay: p, repeat: d === 0 ? c : -1 });
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 });
574
573
  }), n.finish();
575
- const l = n.bytes(), h = l.buffer.slice(l.byteOffset, l.byteOffset + l.byteLength);
576
- new Q().$downloadFile(new Blob([h], { type: "image/gif" }), r.filename), a?.({ state: "completed", totalFrames: r.frameCount });
574
+ const l = n.bytes(), p = l.buffer.slice(l.byteOffset, l.byteOffset + l.byteLength);
575
+ new Q().$downloadFile(new Blob([p], { type: "image/gif" }), r.filename), a?.({ state: "completed", totalFrames: r.frameCount });
577
576
  } catch (i) {
578
577
  throw a?.({ state: "error", message: i instanceof Error ? i.message : "GIF export failed" }), i;
579
578
  }
@@ -583,34 +582,34 @@ class me {
583
582
  return { filename: t.filename, frameCount: e, frameRate: r, scale: a, repeat: i };
584
583
  }
585
584
  }
586
- function fe(o) {
587
- return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
585
+ function fe(s) {
586
+ return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
588
587
  }
589
- var xt, Ct = { exports: {} };
588
+ var wt, Ct = { exports: {} };
590
589
  function ge() {
591
- return xt || (xt = 1, o = Ct, (function() {
592
- function t(l, h) {
593
- return (function(s) {
594
- if (typeof s != "string" || !s.match(/^data:image\/webp;base64,/i)) throw new Error("Failed to decode WebP Base64 URL");
595
- return window.atob(s.substring(23));
596
- })(typeof l == "string" && /^data:image\/webp/.test(l) ? l : l.toDataURL("image/webp", h));
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));
595
+ })(typeof l == "string" && /^data:image\/webp/.test(l) ? l : l.toDataURL("image/webp", p));
597
596
  }
598
597
  function e(l) {
599
598
  return (l.charCodeAt(0) | l.charCodeAt(1) << 8 | l.charCodeAt(2) << 16 | l.charCodeAt(3) << 24) >>> 0;
600
599
  }
601
600
  function r(l) {
602
- let h = l.indexOf("VP8", 12);
603
- if (h === -1) throw new Error("Bad image format, does this browser support WebP?");
604
- let s = !1;
605
- for (; h < l.length - 8; ) {
601
+ let p = l.indexOf("VP8", 12);
602
+ if (p === -1) throw new Error("Bad image format, does this browser support WebP?");
603
+ let o = !1;
604
+ for (; p < l.length - 8; ) {
606
605
  let d, u;
607
- switch (u = l.substring(h, h + 4), h += 4, d = e(l.substring(h, h + 4)), h += 4, u) {
606
+ switch (u = l.substring(p, p + 4), p += 4, d = e(l.substring(p, p + 4)), p += 4, u) {
608
607
  case "VP8 ":
609
- return { frame: l.substring(h, h + d), hasAlpha: s };
608
+ return { frame: l.substring(p, p + d), hasAlpha: o };
610
609
  case "ALPH":
611
- s = !0;
610
+ o = !0;
612
611
  }
613
- h += d, 1 & d && h++;
612
+ p += d, 1 & d && p++;
614
613
  }
615
614
  throw new Error("Failed to find VP8 keyframe in WebP image, is this image mistakenly encoded in the Lossless WebP format?");
616
615
  }
@@ -620,120 +619,120 @@ function ge() {
620
619
  function i(l) {
621
620
  this.value = l;
622
621
  }
623
- function n(l, h, s) {
624
- if (Array.isArray(s)) for (let d = 0; d < s.length; d++) n(l, h, s[d]);
625
- else if (typeof s == "string") l.writeString(s);
626
- else if (s instanceof Uint8Array) l.writeBytes(s);
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);
627
626
  else {
628
- if (!s.id) throw new Error("Bad EBML datatype " + typeof s.data);
629
- if (s.offset = l.pos + h, l.writeUnsignedIntBE(s.id), Array.isArray(s.data)) {
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)) {
630
629
  let d, u, m;
631
- s.size === -1 ? l.writeByte(255) : s.size === -2 ? (d = l.pos, l.writeBytes([15, 255, 255, 255, 255])) : (d = l.pos, l.writeBytes([0, 0, 0, 0])), u = l.pos, s.dataOffset = u + h, n(l, h, s.data), s.size !== -1 && s.size !== -2 && (m = l.pos, s.size = m - u, l.seek(d), l.writeEBMLVarIntWidth(s.size, 4), l.seek(m));
632
- } else if (typeof s.data == "string") l.writeEBMLVarInt(s.data.length), s.dataOffset = l.pos + h, l.writeString(s.data);
633
- else if (typeof s.data == "number") s.size || (s.size = l.measureUnsignedInt(s.data)), l.writeEBMLVarInt(s.size), s.dataOffset = l.pos + h, l.writeUnsignedIntBE(s.data, s.size);
634
- else if (s.data instanceof i) l.writeEBMLVarInt(8), s.dataOffset = l.pos + h, l.writeDoubleBE(s.data.value);
635
- else if (s.data instanceof a) l.writeEBMLVarInt(4), s.dataOffset = l.pos + h, l.writeFloatBE(s.data.value);
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);
636
635
  else {
637
- if (!(s.data instanceof Uint8Array)) throw new Error("Bad EBML datatype " + typeof s.data);
638
- l.writeEBMLVarInt(s.data.byteLength), s.dataOffset = l.pos + h, l.writeBytes(s.data);
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);
639
638
  }
640
639
  }
641
640
  }
642
- let c = function(l, h) {
643
- return function(s) {
644
- let d, u, m = !1, y = 0, p = 0, f = null, _ = null, b = 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 = [], I = new h(s.fileWriter || s.fd);
645
- function D(w) {
646
- return w - d.dataOffset;
641
+ 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);
644
+ function D(y) {
645
+ return y - d.dataOffset;
647
646
  }
648
- function T() {
647
+ function O() {
649
648
  u = (function() {
650
649
  let M = { id: 21420, size: 5, data: 0 }, U = { id: 290298740, data: [] };
651
- for (let F in A) {
652
- let z = A[F];
653
- z.positionEBML = Object.create(M), U.data.push({ id: 19899, data: [{ id: 21419, data: z.id }, z.positionEBML] });
650
+ for (let I in A) {
651
+ let q = A[I];
652
+ q.positionEBML = Object.create(M), U.data.push({ id: 19899, data: [{ id: 21419, data: q.id }, q.positionEBML] });
654
653
  }
655
654
  return U;
656
655
  })();
657
- let w = { id: 357149030, data: [{ id: 2807729, data: 1e6 }, { id: 19840, data: "webm-writer-js" }, { id: 22337, data: "webm-writer-js" }, L] }, x = [{ id: 176, data: y }, { id: 186, data: p }];
658
- s.transparent && x.push({ id: 21440, data: 1 });
659
- let k = { 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: x }] }] };
660
- d = { id: 408125543, size: -2, data: [u, w, k] };
656
+ 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] };
661
660
  let $ = new l(256);
662
- n($, I.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]), I.write($.getAsDataArray()), A.SegmentInfo.positionEBML.data = D(w.offset), A.Tracks.positionEBML.data = D(k.offset), m = !0;
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;
663
662
  }
664
- function B(w) {
665
- return w.alpha ? (function(x) {
666
- let k, $, M = new l(4);
667
- if (!(x.trackNumber > 0 && x.trackNumber < 127)) throw new Error("TrackNumber must be > 0 and < 127");
668
- return M.writeEBMLVarInt(x.trackNumber), M.writeU16BE(x.timecode), M.writeByte(0), k = { id: 161, data: [M.getAsDataArray(), x.frame] }, $ = { id: 30113, data: [{ id: 166, data: [{ id: 238, data: 1 }, { id: 165, data: x.alpha }] }] }, { id: 160, data: [k, $] };
669
- })(w) : (function(x) {
670
- let k = new l(4);
671
- if (!(x.trackNumber > 0 && x.trackNumber < 127)) throw new Error("TrackNumber must be > 0 and < 127");
672
- return k.writeEBMLVarInt(x.trackNumber), k.writeU16BE(x.timecode), k.writeByte(128), { id: 163, data: [k.getAsDataArray(), x.frame] };
673
- })(w);
663
+ function k(y) {
664
+ return y.alpha ? (function(w) {
665
+ let F, $, M = new l(4);
666
+ 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, $] };
668
+ })(y) : (function(w) {
669
+ let F = new l(4);
670
+ 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] };
672
+ })(y);
674
673
  }
675
674
  function R() {
676
675
  if (g.length === 0) return;
677
- let w = 0;
678
- for (let F = 0; F < g.length; F++) w += g[F].frame.length + (g[F].alpha ? g[F].alpha.length : 0);
679
- let x = new l(w + 64 * g.length), k = (function(F) {
680
- return { id: 524531317, data: [{ id: 231, data: Math.round(F.timecode) }] };
676
+ 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) {
679
+ return { id: 524531317, data: [{ id: 231, data: Math.round(I.timecode) }] };
681
680
  })({ timecode: Math.round(C) });
682
- for (let F = 0; F < g.length; F++) k.data.push(B(g[F]));
681
+ for (let I = 0; I < g.length; I++) F.data.push(k(g[I]));
683
682
  var $, M, U;
684
- n(x, I.pos, k), I.write(x.getAsDataArray()), $ = 1, M = Math.round(C), U = k.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;
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;
685
684
  }
686
- this.addFrame = function(w, x, k) {
687
- m || (y = w.width || 0, p = w.height || 0, T());
688
- let $, M = r(t(w, s.quality)), U = null;
689
- $ = k || (typeof x == "number" ? x : s.frameDuration), s.transparent && (x instanceof HTMLCanvasElement || typeof x == "string" ? U = x : M.hasAlpha && (U = (function(F) {
690
- f !== null && f.width === F.width && f.height === F.height || (f = document.createElement("canvas"), f.width = F.width, f.height = F.height, _ = f.getContext("2d"), b = _.createImageData(f.width, f.height));
691
- let z = F.getContext("2d").getImageData(0, 0, F.width, F.height).data, J = b.data, K = 0, Wt = F.width * F.height * 4;
692
- for (let st = 3; st < Wt; st += 4) {
693
- let nt = z[st];
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];
694
693
  J[K++] = nt, J[K++] = nt, J[K++] = nt, J[K++] = 255;
695
694
  }
696
- return _.putImageData(b, 0, 0), f;
697
- })(w))), (function(F) {
698
- F.trackNumber = 1, F.timecode = Math.round(S), g.push(F), S += F.duration, S >= 5e3 && R();
699
- })({ frame: M.frame, duration: $, alpha: U ? r(t(U, s.alphaQuality)).frame : null });
695
+ return _.putImageData(v, 0, 0), f;
696
+ })(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 });
700
699
  }, this.complete = function() {
701
- return m || T(), R(), (function() {
702
- let w = { id: 475249515, data: V }, x = new l(16 + 32 * V.length);
703
- n(x, I.pos, w), I.write(x.getAsDataArray()), A.Cues.positionEBML.data = D(w.offset);
700
+ return m || O(), R(), (function() {
701
+ 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);
704
703
  })(), (function() {
705
- let w = new l(u.size), x = I.pos;
706
- n(w, u.dataOffset, u.data), I.seek(u.dataOffset), I.write(w.getAsDataArray()), I.seek(x);
704
+ 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);
707
706
  })(), (function() {
708
- let w = new l(8), x = I.pos;
709
- w.writeDoubleBE(C), I.seek(L.dataOffset), I.write(w.getAsDataArray()), I.seek(x);
707
+ let y = new l(8), w = B.pos;
708
+ y.writeDoubleBE(C), B.seek(L.dataOffset), B.write(y.getAsDataArray()), B.seek(w);
710
709
  })(), (function() {
711
- let w = new l(10), x = I.pos;
712
- w.writeUnsignedIntBE(d.id), w.writeEBMLVarIntWidth(I.pos - d.dataOffset, 5), I.seek(d.offset), I.write(w.getAsDataArray()), I.seek(x);
713
- })(), I.complete("video/webm");
710
+ let y = new l(10), w = B.pos;
711
+ y.writeUnsignedIntBE(d.id), y.writeEBMLVarIntWidth(B.pos - d.dataOffset, 5), B.seek(d.offset), B.write(y.getAsDataArray()), B.seek(w);
712
+ })(), B.complete("video/webm");
714
713
  }, this.getWrittenSize = function() {
715
- return I.length;
716
- }, s = (function(w, x) {
717
- let k = {};
718
- return [w, x].forEach(function($) {
719
- for (let M in $) Object.prototype.hasOwnProperty.call($, M) && (k[M] = $[M]);
720
- }), k;
721
- })(E, s || {}), (function() {
722
- if (!s.frameDuration) {
723
- if (!s.frameRate) throw new Error("Missing required frameDuration or frameRate setting");
724
- s.frameDuration = 1e3 / s.frameRate;
714
+ return B.length;
715
+ }, o = (function(y, w) {
716
+ let F = {};
717
+ 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;
725
724
  }
726
- s.quality = Math.max(Math.min(s.quality, 0.99999), 0), s.alphaQuality === void 0 ? s.alphaQuality = s.quality : s.alphaQuality = Math.max(Math.min(s.alphaQuality, 0.99999), 0);
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);
727
726
  })();
728
727
  };
729
728
  };
730
- o.exports = c;
729
+ s.exports = c;
731
730
  })()), Ct.exports;
732
- var o;
731
+ var s;
733
732
  }
734
- var Et, Bt = { exports: {} };
735
- function ve() {
736
- return Et || (Et = 1, o = Bt, (function() {
733
+ var Et, kt = { exports: {} };
734
+ function be() {
735
+ return Et || (Et = 1, s = kt, (function() {
737
736
  let t = function(e) {
738
737
  this.data = new Uint8Array(e), this.pos = 0;
739
738
  };
@@ -804,34 +803,34 @@ function ve() {
804
803
  if (this.pos < this.data.byteLength) return this.data.subarray(0, this.pos);
805
804
  if (this.pos == this.data.byteLength) return this.data;
806
805
  throw new Error("ArrayBufferDataStream's pos lies beyond end of buffer");
807
- }, o.exports = t;
808
- })()), Bt.exports;
809
- var o;
806
+ }, s.exports = t;
807
+ })()), kt.exports;
808
+ var s;
810
809
  }
811
- var It, Ft, St, kt = { exports: {} };
812
- function be() {
813
- return It || (It = 1, o = kt, (function() {
810
+ var Bt, It, St, Ft = { exports: {} };
811
+ function ve() {
812
+ return Bt || (Bt = 1, s = Ft, (function() {
814
813
  let t = function(e) {
815
814
  return function(r) {
816
815
  let a = [], i = Promise.resolve(), n = null, c = null;
817
816
  function l(d) {
818
817
  return new Promise(function(u, m) {
819
- let y = new FileReader();
820
- y.addEventListener("loadend", function() {
821
- u(y.result);
822
- }), y.readAsArrayBuffer(d);
818
+ let x = new FileReader();
819
+ x.addEventListener("loadend", function() {
820
+ u(x.result);
821
+ }), x.readAsArrayBuffer(d);
823
822
  });
824
823
  }
825
- function h(d) {
824
+ function p(d) {
826
825
  return new Promise(function(u, m) {
827
- d instanceof Uint8Array ? u(d) : d instanceof ArrayBuffer || ArrayBuffer.isView(d) ? u(new Uint8Array(d)) : d instanceof Blob ? u(l(d).then(function(y) {
828
- return new Uint8Array(y);
829
- })) : u(l(new Blob([d])).then(function(y) {
830
- return new Uint8Array(y);
826
+ d instanceof Uint8Array ? u(d) : d instanceof ArrayBuffer || ArrayBuffer.isView(d) ? u(new Uint8Array(d)) : d instanceof Blob ? u(l(d).then(function(x) {
827
+ return new Uint8Array(x);
828
+ })) : u(l(new Blob([d])).then(function(x) {
829
+ return new Uint8Array(x);
831
830
  }));
832
831
  });
833
832
  }
834
- function s(d) {
833
+ function o(d) {
835
834
  let u = d.byteLength || d.length || d.size;
836
835
  if (!Number.isInteger(u)) throw new Error("Failed to determine size of element");
837
836
  return u;
@@ -842,27 +841,27 @@ function be() {
842
841
  if (d > this.length) throw new Error("Seeking beyond the end of file is not allowed");
843
842
  this.pos = d;
844
843
  }, this.write = function(d) {
845
- let u = { offset: this.pos, data: d, length: s(d) }, m = u.offset >= this.length;
844
+ let u = { offset: this.pos, data: d, length: o(d) }, m = u.offset >= this.length;
846
845
  this.pos += u.length, this.length = Math.max(this.length, this.pos), i = i.then(function() {
847
- if (c) return new Promise(function(y, p) {
848
- h(u.data).then(function(f) {
849
- let _ = 0, b = Buffer.from(f.buffer), g = function(C, S, E) {
850
- _ += S, _ >= E.length ? y() : e.write(c, E, _, E.length - _, u.offset + _, g);
846
+ 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);
851
850
  };
852
- e.write(c, b, 0, b.length, u.offset, g);
851
+ e.write(c, v, 0, v.length, u.offset, g);
853
852
  });
854
853
  });
855
- if (n) return new Promise(function(y, p) {
856
- n.onwriteend = y, n.seek(u.offset), n.write(new Blob([u.data]));
854
+ if (n) return new Promise(function(x, h) {
855
+ n.onwriteend = x, n.seek(u.offset), n.write(new Blob([u.data]));
857
856
  });
858
- if (!m) for (let y = 0; y < a.length; y++) {
859
- let p = a[y];
860
- if (!(u.offset + u.length <= p.offset || u.offset >= p.offset + p.length)) {
861
- if (u.offset < p.offset || u.offset + u.length > p.offset + p.length) throw new Error("Overwrite crosses blob boundaries");
862
- return u.offset == p.offset && u.length == p.length ? void (p.data = u.data) : h(p.data).then(function(f) {
863
- return p.data = f, h(u.data);
857
+ if (!m) for (let x = 0; x < a.length; x++) {
858
+ let h = a[x];
859
+ if (!(u.offset + u.length <= h.offset || u.offset >= h.offset + h.length)) {
860
+ 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);
864
863
  }).then(function(f) {
865
- u.data = f, p.data.set(u.data, u.offset - p.offset);
864
+ u.data = f, h.data.set(u.data, u.offset - h.offset);
866
865
  });
867
866
  }
868
867
  }
@@ -879,42 +878,42 @@ function be() {
879
878
  };
880
879
  };
881
880
  };
882
- o.exports = t;
883
- })()), kt.exports;
884
- var o;
881
+ s.exports = t;
882
+ })()), Ft.exports;
883
+ var s;
885
884
  }
886
- function ye() {
887
- return St ? Ft : (St = 1, Ft = ge()(ve(), be()(null)));
885
+ function xe() {
886
+ return St ? It : (St = 1, It = ge()(be(), ve()(null)));
888
887
  }
889
- var we = ye();
890
- const _e = fe(we);
891
- class xe {
888
+ var ye = xe();
889
+ const _e = fe(ye);
890
+ class we {
892
891
  async $record(t, e, r, a) {
893
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();
894
- return await new Promise((h, s) => {
895
- let d, u = "capturing", m = !1, y = 0;
896
- const p = () => {
893
+ return await new Promise((p, o) => {
894
+ let d, u = "capturing", m = !1, x = 0;
895
+ const h = () => {
897
896
  d && (d(), d = void 0);
898
897
  }, f = () => {
899
- a?.({ state: "recording", frameIndex: y, totalFrames: n });
898
+ a?.({ state: "recording", frameIndex: x, totalFrames: n });
900
899
  }, _ = (g) => {
901
900
  if (m) return;
902
- m = !0, p();
901
+ m = !0, h();
903
902
  const C = g instanceof Error ? g.message : "WEBM export failed";
904
- a?.({ state: "error", message: C }), s(g instanceof Error ? g : new Error(String(g)));
905
- }, b = () => {
906
- u !== "capturing" || m || (u = "encoding", p(), c.complete().then((g) => {
903
+ a?.({ state: "error", message: C }), o(g instanceof Error ? g : new Error(String(g)));
904
+ }, v = () => {
905
+ u !== "capturing" || m || (u = "encoding", h(), c.complete().then((g) => {
907
906
  ((C) => {
908
- m || (m = !0, a?.({ state: "completed", frameIndex: Math.min(n, y), totalFrames: n }), h(C));
907
+ m || (m = !0, a?.({ state: "completed", frameIndex: Math.min(n, x), totalFrames: n }), p(C));
909
908
  })(g);
910
909
  }).catch(_));
911
910
  };
912
911
  d = r(() => {
913
912
  (() => {
914
- if (u === "capturing") if (y >= n) b();
913
+ if (u === "capturing") if (x >= n) v();
915
914
  else try {
916
915
  const g = l(t);
917
- c.addFrame(g), y += 1, f(), y >= n && b();
916
+ c.addFrame(g), x += 1, f(), x >= n && v();
918
917
  } catch (g) {
919
918
  _(g);
920
919
  }
@@ -935,7 +934,7 @@ class Ce {
935
934
  _textmodifier;
936
935
  _registerPostDrawHook;
937
936
  constructor(t, e) {
938
- this._recorder = new xe(), this._textmodifier = t, this._registerPostDrawHook = e;
937
+ this._recorder = new we(), this._textmodifier = t, this._registerPostDrawHook = e;
939
938
  }
940
939
  async $saveWEBM(t = {}) {
941
940
  const e = this._textmodifier.canvas, r = this._applyDefaultOptions(t);
@@ -950,8 +949,8 @@ class Ce {
950
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 };
951
950
  }
952
951
  }
953
- const v = { 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" };
954
- class O {
952
+ 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 {
955
954
  element;
956
955
  mounted = !1;
957
956
  destroyed = !1;
@@ -986,49 +985,49 @@ class O {
986
985
  return this.mounted;
987
986
  }
988
987
  }
989
- class j extends O {
988
+ class H extends T {
990
989
  static _iconNamespace = "http://www.w3.org/2000/svg";
991
990
  render() {
992
991
  const t = document.createElement("div");
993
- t.classList.add(v.stack, v.stackDense, v.header);
992
+ t.classList.add(b.stack, b.stackDense, b.header);
994
993
  const e = document.createElement("div");
995
- e.classList.add(v.headerTitleRow);
994
+ e.classList.add(b.headerTitleRow);
996
995
  const r = document.createElement("strong");
997
- r.textContent = "textmode.export.js", r.classList.add(v.title);
996
+ r.textContent = "textmode.export.js", r.classList.add(b.title);
998
997
  const a = document.createElement("div");
999
- a.classList.add(v.headerLinks);
1000
- const i = this._createLink("https://github.com/humanbydefinition/textmode.export.js", "View repository on GitHub", v.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", v.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" }]);
998
+ 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" }]);
1001
1000
  a.appendChild(i), a.appendChild(n), e.appendChild(r), e.appendChild(a);
1002
1001
  const c = document.createElement("div");
1003
- return c.classList.add(v.divider), t.appendChild(e), t.appendChild(c), t;
1002
+ return c.classList.add(b.divider), t.appendChild(e), t.appendChild(c), t;
1004
1003
  }
1005
1004
  _createLink(t, e, r, a) {
1006
1005
  const i = document.createElement("a");
1007
- return i.href = t, i.target = "_blank", i.rel = "noopener noreferrer", i.classList.add(v.supportLink), i.setAttribute("aria-label", e), i.appendChild(this._createIcon(r, a)), i;
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;
1008
1007
  }
1009
1008
  _createIcon(t, e) {
1010
- const r = document.createElementNS(j._iconNamespace, "svg");
1011
- r.setAttribute("xmlns", j._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);
1009
+ 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);
1012
1011
  for (const a of e) {
1013
- const i = document.createElementNS(j._iconNamespace, "path");
1012
+ const i = document.createElementNS(H._iconNamespace, "path");
1014
1013
  for (const [n, c] of Object.entries(a)) i.setAttribute(n, c);
1015
1014
  r.appendChild(i);
1016
1015
  }
1017
1016
  return r;
1018
1017
  }
1019
1018
  }
1020
- class P extends O {
1019
+ class P extends T {
1021
1020
  props;
1022
1021
  constructor(t) {
1023
1022
  super(), this.props = t;
1024
1023
  }
1025
1024
  render() {
1026
1025
  const t = document.createElement("div");
1027
- t.classList.add(v.field), this.applyVariant(t, this.props.variant);
1026
+ t.classList.add(b.field), this.applyVariant(t, this.props.variant);
1028
1027
  const e = document.createElement("label");
1029
- if (e.classList.add(v.label), e.textContent = this.props.label, this.props.labelFor && (e.htmlFor = this.props.labelFor), t.appendChild(e), this.props.description) {
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) {
1030
1029
  const r = document.createElement("span");
1031
- r.classList.add(v.muted), r.textContent = this.props.description, t.appendChild(r);
1030
+ r.classList.add(b.muted), r.textContent = this.props.description, t.appendChild(r);
1032
1031
  }
1033
1032
  return t;
1034
1033
  }
@@ -1041,30 +1040,30 @@ class P extends O {
1041
1040
  onUpdate(t) {
1042
1041
  const e = this.root;
1043
1042
  for (; e.firstChild; ) e.removeChild(e.firstChild);
1044
- this.props = t, e.classList.add(v.field), this.applyVariant(e, t.variant);
1043
+ this.props = t, e.classList.add(b.field), this.applyVariant(e, t.variant);
1045
1044
  const r = document.createElement("label");
1046
- if (r.classList.add(v.label), r.textContent = t.label, t.labelFor && (r.htmlFor = t.labelFor), e.appendChild(r), t.description) {
1045
+ if (r.classList.add(b.label), r.textContent = t.label, t.labelFor && (r.htmlFor = t.labelFor), e.appendChild(r), t.description) {
1047
1046
  const a = document.createElement("span");
1048
- a.classList.add(v.muted), a.textContent = t.description, e.appendChild(a);
1047
+ a.classList.add(b.muted), a.textContent = t.description, e.appendChild(a);
1049
1048
  }
1050
1049
  }
1051
1050
  applyVariant(t, e) {
1052
- switch (t.classList.remove(v.fieldCompact, v.fieldDense, v.fieldFull, v.fieldChannel), e) {
1051
+ switch (t.classList.remove(b.fieldCompact, b.fieldDense, b.fieldFull, b.fieldChannel), e) {
1053
1052
  case "compact":
1054
- t.classList.add(v.fieldCompact);
1053
+ t.classList.add(b.fieldCompact);
1055
1054
  break;
1056
1055
  case "dense":
1057
- t.classList.add(v.fieldDense);
1056
+ t.classList.add(b.fieldDense);
1058
1057
  break;
1059
1058
  case "full":
1060
- t.classList.add(v.fieldFull);
1059
+ t.classList.add(b.fieldFull);
1061
1060
  break;
1062
1061
  case "channel":
1063
- t.classList.add(v.fieldChannel);
1062
+ t.classList.add(b.fieldChannel);
1064
1063
  }
1065
1064
  }
1066
1065
  }
1067
- class mt extends O {
1066
+ class mt extends T {
1068
1067
  props;
1069
1068
  select;
1070
1069
  handleChange = () => {
@@ -1074,7 +1073,7 @@ class mt extends O {
1074
1073
  super(), this.props = t;
1075
1074
  }
1076
1075
  render() {
1077
- return this.select = document.createElement("select"), this.select.classList.add(v.input), this.props.id && (this.select.id = this.props.id), this.populateOptions(), this.select.addEventListener("change", this.handleChange), this.select;
1076
+ 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;
1078
1077
  }
1079
1078
  get selectElement() {
1080
1079
  return this.select;
@@ -1105,14 +1104,14 @@ class mt extends O {
1105
1104
  }
1106
1105
  }
1107
1106
  }
1108
- class Lt extends O {
1107
+ class Lt extends T {
1109
1108
  props;
1110
1109
  button;
1111
1110
  constructor(t) {
1112
1111
  super(), this.props = t;
1113
1112
  }
1114
1113
  render() {
1115
- return this.button = document.createElement("button"), this.button.type = "button", this.button.textContent = this.props.label, this.button.classList.add(v.button), this.props.variant === "secondary" ? this.button.classList.add(v.buttonSecondary) : this.button.classList.add(v.buttonPrimary), this.props.fullWidth && this.button.classList.add(v.buttonFull), this.button.disabled = !!this.props.disabled, this.button;
1114
+ 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
1115
  }
1117
1116
  get buttonElement() {
1118
1117
  return this.button;
@@ -1124,7 +1123,7 @@ class Lt extends O {
1124
1123
  this.props.disabled = t, this.button.disabled = t;
1125
1124
  }
1126
1125
  onUpdate(t) {
1127
- this.props = t, this.button.textContent = t.label, this.button.disabled = !!t.disabled, t.variant === "secondary" ? (this.button.classList.add(v.buttonSecondary), this.button.classList.remove(v.buttonPrimary)) : (this.button.classList.add(v.buttonPrimary), this.button.classList.remove(v.buttonSecondary)), this.button.classList.toggle(v.buttonFull, !!t.fullWidth);
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);
1128
1127
  }
1129
1128
  }
1130
1129
  class Ee {
@@ -1152,7 +1151,7 @@ class Ee {
1152
1151
  }
1153
1152
  }
1154
1153
  }
1155
- class Be {
1154
+ class ke {
1156
1155
  api;
1157
1156
  events;
1158
1157
  constructor(t, e) {
@@ -1190,7 +1189,7 @@ class Be {
1190
1189
  }
1191
1190
  }
1192
1191
  }
1193
- class Ie {
1192
+ class Be {
1194
1193
  modifier;
1195
1194
  overlay;
1196
1195
  animationFrameId = null;
@@ -1214,13 +1213,13 @@ class Ie {
1214
1213
  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);
1215
1214
  }
1216
1215
  }
1217
- const X = "textmode-export-number-input", Fe = `${X}__field`, Se = `${X}__controls`, ke = `${X}__control`, Ut = `${X}__display`, et = `${Ut}--visible`, Le = (o) => {
1218
- o.dispatchEvent(new Event("input", { bubbles: !0 })), o.dispatchEvent(new Event("change", { bubbles: !0 }));
1219
- }, Mt = (o) => {
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) => {
1220
1219
  const t = document.createElement("button");
1221
- return t.type = "button", t.className = ke, t.textContent = o > 0 ? "▲" : "▼", t;
1220
+ return t.type = "button", t.className = Fe, t.textContent = s > 0 ? "▲" : "▼", t;
1222
1221
  };
1223
- class G extends O {
1222
+ class G extends T {
1224
1223
  props;
1225
1224
  input;
1226
1225
  display;
@@ -1236,7 +1235,7 @@ class G extends O {
1236
1235
  }
1237
1236
  render() {
1238
1237
  const t = document.createElement("div");
1239
- 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 = Fe, this.display = document.createElement("div"), this.display.className = Ut;
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;
1240
1239
  const e = document.createElement("div");
1241
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;
1242
1241
  }
@@ -1261,8 +1260,8 @@ class G extends O {
1261
1260
  const n = this.input.value, c = this.input.getAttribute("step");
1262
1261
  if (c && c !== "any") i > 0 ? this.input.stepUp() : this.input.stepDown();
1263
1262
  else {
1264
- const l = i > 0 ? 1 : -1, h = Number.parseFloat(this.input.value || "0"), s = Number.isFinite(h) ? h + l : l;
1265
- this.input.value = String(s);
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);
1266
1265
  }
1267
1266
  this.input.value !== n && Le(this.input), this.updateDisplay(), this.input.focus({ preventScroll: !0 });
1268
1267
  }, e = t(1), r = t(-1), a = (i, n) => (c) => {
@@ -1324,19 +1323,19 @@ class G extends O {
1324
1323
  this.holdTimeoutId !== void 0 && (window.clearTimeout(this.holdTimeoutId), this.holdTimeoutId = void 0), this.holdIntervalId !== void 0 && (window.clearInterval(this.holdIntervalId), this.holdIntervalId = void 0);
1325
1324
  }
1326
1325
  }
1327
- class H extends O {
1326
+ class j extends T {
1328
1327
  variant;
1329
1328
  additionalClasses;
1330
1329
  constructor(t = "stack", e = []) {
1331
1330
  super(), this.variant = t, this.additionalClasses = e;
1332
1331
  }
1333
1332
  render() {
1334
- const t = document.createElement("div"), e = [this.variant === "stack" ? v.stack : void 0, this.variant === "stackDense" ? v.stackDense : void 0, this.variant === "stackCompact" ? v.stackCompact : void 0, this.variant === "row" ? v.row : void 0, this.variant === "section" ? v.section : void 0, ...this.additionalClasses].filter(Boolean);
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);
1335
1334
  return t.classList.add(...e), t;
1336
1335
  }
1337
1336
  }
1338
1337
  const $t = { neutral: "textmode-export-overlay__status-value--neutral", active: "textmode-export-overlay__status-value--active", alert: "textmode-export-overlay__status-value--alert" };
1339
- class Nt extends O {
1338
+ class Nt extends T {
1340
1339
  props;
1341
1340
  container;
1342
1341
  messageElement;
@@ -1344,9 +1343,9 @@ class Nt extends O {
1344
1343
  super(), this.props = t;
1345
1344
  }
1346
1345
  render() {
1347
- this.container = document.createElement("div"), this.container.classList.add(v.status), this.props.context === "gif" ? this.container.classList.add(v.statusGif) : this.props.context === "video" && this.container.classList.add(v.statusVideo);
1346
+ 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);
1348
1347
  const t = document.createElement("span");
1349
- return t.classList.add(v.statusTitle), t.textContent = this.props.title, this.messageElement = document.createElement("span"), this.messageElement.classList.add(v.statusValue), this.messageElement.textContent = this.props.message, this.applyVariant(this.props.variant ?? "neutral"), this.container.appendChild(t), this.container.appendChild(this.messageElement), this.container;
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;
1350
1349
  }
1351
1350
  setMessage(t, e = "neutral") {
1352
1351
  this.messageElement.textContent = t, this.applyVariant(e);
@@ -1358,7 +1357,7 @@ class Nt extends O {
1358
1357
  this.messageElement.classList.remove(...Object.values($t)), this.messageElement.classList.add($t[t]);
1359
1358
  }
1360
1359
  }
1361
- class Y extends O {
1360
+ class Y extends T {
1362
1361
  _config;
1363
1362
  _managedComponents = /* @__PURE__ */ new Set();
1364
1363
  constructor(t) {
@@ -1375,11 +1374,11 @@ class Y extends O {
1375
1374
  this._managedComponents.clear();
1376
1375
  }
1377
1376
  }
1378
- const W = { frameCount: 300, frameRate: 60, scale: 1, repeat: 0 };
1377
+ const z = { frameCount: 300, frameRate: 60, scale: 1, repeat: 0 };
1379
1378
  class ut extends Y {
1380
- frameCountInput = this._manageComponent(new G({ defaultValue: String(W.frameCount), attributes: { min: "1", max: "600", step: "1" } }));
1381
- frameRateInput = this._manageComponent(new G({ defaultValue: String(W.frameRate), attributes: { min: "1", max: "60", step: "1" } }));
1382
- scaleInput = this._manageComponent(new G({ defaultValue: String(W.scale), attributes: { min: "0.1", max: "8", step: "0.1" } }));
1379
+ frameCountInput = this._manageComponent(new G({ defaultValue: String(z.frameCount), attributes: { min: "1", max: "600", step: "1" } }));
1380
+ frameRateInput = this._manageComponent(new G({ defaultValue: String(z.frameRate), attributes: { min: "1", max: "60", step: "1" } }));
1381
+ scaleInput = this._manageComponent(new G({ defaultValue: String(z.scale), attributes: { min: "0.1", max: "8", step: "0.1" } }));
1383
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 }));
1384
1383
  status = this._manageComponent(new Nt({ title: "status", message: "ready to record", variant: "neutral", context: "gif" }));
1385
1384
  recordingState = "idle";
@@ -1388,14 +1387,14 @@ class ut extends Y {
1388
1387
  }
1389
1388
  render() {
1390
1389
  const t = document.createElement("div");
1391
- t.classList.add(v.stack);
1392
- const e = new H("row");
1390
+ t.classList.add(b.stack);
1391
+ const e = new j("row");
1393
1392
  e.mount(t);
1394
1393
  const r = new P({ label: "number of frames", labelFor: "textmode-export-gif-frame-count", variant: "dense" });
1395
1394
  r.mount(e.root), this.frameCountInput.mount(r.root), this.frameCountInput.inputElement.id = "textmode-export-gif-frame-count";
1396
1395
  const a = new P({ label: "frame rate (fps)", labelFor: "textmode-export-gif-frame-rate", variant: "dense" });
1397
1396
  a.mount(e.root), this.frameRateInput.mount(a.root), this.frameRateInput.inputElement.id = "textmode-export-gif-frame-rate";
1398
- const i = new H("row");
1397
+ const i = new j("row");
1399
1398
  i.mount(t);
1400
1399
  const n = new P({ label: "scale", labelFor: "textmode-export-gif-scale", variant: "dense" });
1401
1400
  n.mount(i.root), this.scaleInput.mount(n.root), this.scaleInput.inputElement.id = "textmode-export-gif-scale";
@@ -1440,7 +1439,7 @@ class ut extends Y {
1440
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");
1441
1440
  }
1442
1441
  applyDefaults() {
1443
- const t = this._config.defaultOptions ?? {}, e = t.frameCount ?? W.frameCount, r = t.frameRate ?? W.frameRate, a = t.scale ?? W.scale, i = t.repeat ?? W.repeat;
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;
1444
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();
1445
1444
  }
1446
1445
  safeParseInt(t, e) {
@@ -1452,12 +1451,12 @@ class ut extends Y {
1452
1451
  return Number.isFinite(r) ? r : e;
1453
1452
  }
1454
1453
  }
1455
- const it = "textmode-export-range-input", Me = `${it}__field`, $e = `${it}__tooltip`, ct = `${it}__tooltip--visible`, rt = (o, t) => {
1456
- if (typeof o != "string" || o.length === 0) return t;
1457
- const e = Number.parseFloat(o);
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);
1458
1457
  return Number.isFinite(e) ? e : t;
1459
- }, Ae = (o, t, e) => Math.min(e, Math.max(t, o));
1460
- class Pe extends O {
1458
+ }, Ae = (s, t, e) => Math.min(e, Math.max(t, s));
1459
+ class Pe extends T {
1461
1460
  props;
1462
1461
  input;
1463
1462
  tooltip;
@@ -1562,15 +1561,15 @@ class Pe extends O {
1562
1561
  return rt(this.input.value, rt(this.props.defaultValue, 0));
1563
1562
  }
1564
1563
  }
1565
- function De(o) {
1566
- if (!Number.isFinite(o)) return "default quality";
1567
- const t = Math.max(0, Math.min(1, o));
1564
+ function De(s) {
1565
+ if (!Number.isFinite(s)) return "default quality";
1566
+ const t = Math.max(0, Math.min(1, s));
1568
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";
1569
1568
  }
1570
- function Ve(o) {
1571
- return `${De(o)} (quality ≈ ${o.toFixed(3)})`;
1569
+ function Ve(s) {
1570
+ return `${De(s)} (quality ≈ ${s.toFixed(3)})`;
1572
1571
  }
1573
- class ht extends Y {
1572
+ class pt extends Y {
1574
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 }));
1575
1574
  frameCountInput = this._manageComponent(new G({ defaultValue: String(480), attributes: { min: String(1), max: String(3600), step: "1" } }));
1576
1575
  qualityInput = this._manageComponent(new Pe({ defaultValue: String(0.7), attributes: { min: String(0), max: String(1), step: "0.001" }, formatValue: (t) => Ve(t) }));
@@ -1581,8 +1580,8 @@ class ht extends Y {
1581
1580
  }
1582
1581
  render() {
1583
1582
  const t = document.createElement("div");
1584
- t.classList.add(v.stack);
1585
- const e = new H("row");
1583
+ t.classList.add(b.stack);
1584
+ const e = new j("row");
1586
1585
  e.mount(t);
1587
1586
  const r = new P({ label: "number of frames", labelFor: "textmode-export-video-frame-count", variant: "compact" });
1588
1587
  r.mount(e.root), this.frameCountInput.mount(r.root), this.frameCountInput.inputElement.id = "textmode-export-video-frame-count";
@@ -1642,6 +1641,7 @@ class ht extends Y {
1642
1641
  this.frameCountInput.value = String(e), this.frameRateInput.value = String(r), this.qualityInput.value = String(a), this.frameCountInput.refresh(), this.frameRateInput.refresh();
1643
1642
  }
1644
1643
  }
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
1645
  class Oe {
1646
1646
  _textmodifier;
1647
1647
  _state;
@@ -1651,11 +1651,13 @@ class Oe {
1651
1651
  _definitions;
1652
1652
  _formats = /* @__PURE__ */ new Map();
1653
1653
  _eventUnsubscribers = [];
1654
+ _shadowHost;
1655
+ _shadowRoot;
1654
1656
  _overlayElement;
1655
1657
  _optionsContainer;
1656
1658
  _copyButtonContainer;
1657
1659
  _positionService;
1658
- _header = new j();
1660
+ _header = new H();
1659
1661
  _formatField = new P({ label: "export format", labelFor: "textmode-export-format", variant: "full" });
1660
1662
  _formatSelect = new mt({ id: "textmode-export-format", options: [] });
1661
1663
  _exportButton = new Lt({ label: "download file", fullWidth: !0, variant: "primary" });
@@ -1676,17 +1678,17 @@ class Oe {
1676
1678
  });
1677
1679
  };
1678
1680
  constructor(t, e, r, a, i) {
1679
- this._textmodifier = t, this._state = r, this._events = a, this._exportService = new Be(e, a), this._clipboardService = new Ee(e), this._definitions = i, this._currentFormat = r.snapshot.format, this._initializeFormatMap(), this._registerEventHandlers();
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();
1680
1682
  }
1681
1683
  $mount() {
1682
- this._createOverlay(), this._renderStaticContent(), this._positionService = new Ie(this._textmodifier, this._overlayElement), this._positionService.bind(), this._switchFormat(this._currentFormat);
1684
+ this._createOverlay(), this._renderStaticContent(), this._positionService = new Be(this._textmodifier, this._shadowHost), this._positionService.bind(), this._switchFormat(this._currentFormat);
1683
1685
  }
1684
1686
  $dispose() {
1685
1687
  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);
1686
1688
  for (const t of this._eventUnsubscribers) t();
1687
1689
  this._eventUnsubscribers.length = 0, this._events.$clear();
1688
1690
  for (const t of this._formats.values()) t.blade.destroy();
1689
- this._formats.clear(), this._currentBlade = void 0, this._overlayElement?.isConnected && this._overlayElement.remove(), this._positionService?.dispose();
1691
+ this._formats.clear(), this._currentBlade = void 0, this._shadowHost?.isConnected && this._shadowHost.remove(), this._positionService?.dispose();
1690
1692
  }
1691
1693
  _initializeFormatMap() {
1692
1694
  for (const t of this._definitions) {
@@ -1695,12 +1697,14 @@ class Oe {
1695
1697
  }
1696
1698
  }
1697
1699
  _createOverlay() {
1698
- this._overlayElement = document.createElement("div"), this._overlayElement.dataset.plugin = "textmode-export-overlay", this._overlayElement.classList.add(v.root, v.stack), document.body.appendChild(this._overlayElement);
1700
+ 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);
1699
1703
  }
1700
1704
  _renderStaticContent() {
1701
1705
  this._header.mount(this._overlayElement);
1702
1706
  const t = document.createElement("div");
1703
- t.classList.add(v.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(v.stack, v.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(v.stack, v.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);
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);
1704
1708
  }
1705
1709
  _prepareFormatOptions() {
1706
1710
  const t = this._definitions.map((e) => ({ value: e.format, label: e.label }));
@@ -1721,7 +1725,7 @@ class Oe {
1721
1725
  if (t === "gif" && this._currentBlade?.blade instanceof ut) {
1722
1726
  const r = e;
1723
1727
  this._state.$set({ gifProgress: r }), this._currentBlade.blade.handleProgress(r);
1724
- } else if (t === "video" && this._currentBlade?.blade instanceof ht) {
1728
+ } else if (t === "video" && this._currentBlade?.blade instanceof pt) {
1725
1729
  const r = e;
1726
1730
  this._state.$set({ videoProgress: r }), this._currentBlade.blade.handleProgress(r);
1727
1731
  }
@@ -1809,7 +1813,7 @@ class Oe {
1809
1813
  else this._exportButton.setDisabled(!1), this._exportButton.setLabel("start recording");
1810
1814
  return;
1811
1815
  }
1812
- if (t === "video" && this._currentBlade.blade instanceof ht) {
1816
+ if (t === "video" && this._currentBlade.blade instanceof pt) {
1813
1817
  const r = this._currentBlade.blade, a = this._state.snapshot.videoProgress;
1814
1818
  if (r.isRecording()) if (this._exportButton.setDisabled(!0), a?.totalFrames) {
1815
1819
  const i = a.frameIndex ?? 0;
@@ -1822,7 +1826,7 @@ class Oe {
1822
1826
  this._exportButton.setDisabled(e), this._exportButton.setLabel(e ? "exporting…" : "download file");
1823
1827
  }
1824
1828
  }
1825
- class Te {
1829
+ class Re {
1826
1830
  _listeners = /* @__PURE__ */ new Map();
1827
1831
  $on(t, e) {
1828
1832
  this._listeners.has(t) || this._listeners.set(t, /* @__PURE__ */ new Set());
@@ -1843,7 +1847,7 @@ class Te {
1843
1847
  this._listeners.clear();
1844
1848
  }
1845
1849
  }
1846
- class Re {
1850
+ class Ue {
1847
1851
  _state;
1848
1852
  _listeners = /* @__PURE__ */ new Set();
1849
1853
  constructor(t) {
@@ -1872,8 +1876,8 @@ class Re {
1872
1876
  for (const r of [...this._listeners]) r(e);
1873
1877
  }
1874
1878
  }
1875
- const Ue = (o) => ({ format: o, isBusy: !1 });
1876
- class Gt extends O {
1879
+ const Ne = (s) => ({ format: s, isBusy: !1 });
1880
+ class Gt extends T {
1877
1881
  props;
1878
1882
  checkbox;
1879
1883
  labelElement;
@@ -1884,7 +1888,7 @@ class Gt extends O {
1884
1888
  super(), this.props = t;
1885
1889
  }
1886
1890
  render() {
1887
- this.labelElement = document.createElement("label"), this.labelElement.classList.add(v.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);
1891
+ 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);
1888
1892
  const t = document.createElement("span");
1889
1893
  return t.textContent = this.props.label, this.labelElement.htmlFor = this.props.id ?? "", this.labelElement.appendChild(this.checkbox), this.labelElement.appendChild(t), this.labelElement;
1890
1894
  }
@@ -1904,7 +1908,7 @@ class Gt extends O {
1904
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);
1905
1909
  }
1906
1910
  }
1907
- class Ne extends O {
1911
+ class Ge extends T {
1908
1912
  props;
1909
1913
  input;
1910
1914
  handleInput = () => {
@@ -1914,7 +1918,7 @@ class Ne extends O {
1914
1918
  super(), this.props = t;
1915
1919
  }
1916
1920
  render() {
1917
- return this.input = document.createElement("input"), this.input.type = "text", this.input.classList.add(v.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;
1921
+ 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;
1918
1922
  }
1919
1923
  get inputElement() {
1920
1924
  return this.input;
@@ -1932,15 +1936,15 @@ class Ne extends O {
1932
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);
1933
1937
  }
1934
1938
  }
1935
- class Ge extends Y {
1939
+ class ze extends Y {
1936
1940
  trailingSpaces = this._manageComponent(new Gt({ label: "preserve trailing spaces", defaultChecked: !1 }));
1937
- emptyCharacter = this._manageComponent(new Ne({ id: "textmode-export-empty-character", defaultValue: " ", maxLength: 1 }));
1941
+ emptyCharacter = this._manageComponent(new Ge({ id: "textmode-export-empty-character", defaultValue: " ", maxLength: 1 }));
1938
1942
  constructor(t) {
1939
1943
  super(t);
1940
1944
  }
1941
1945
  render() {
1942
1946
  const t = document.createElement("div");
1943
- t.classList.add(v.stack), this.trailingSpaces.mount(t);
1947
+ t.classList.add(b.stack), this.trailingSpaces.mount(t);
1944
1948
  const e = new P({ label: "empty character", labelFor: "textmode-export-empty-character", variant: "full" });
1945
1949
  return e.mount(t), this.emptyCharacter.mount(e.root), t;
1946
1950
  }
@@ -1967,8 +1971,8 @@ class We extends Y {
1967
1971
  }
1968
1972
  render() {
1969
1973
  const t = document.createElement("div");
1970
- t.classList.add(v.stack);
1971
- const e = new H("row");
1974
+ t.classList.add(b.stack);
1975
+ const e = new j("row");
1972
1976
  e.mount(t);
1973
1977
  const r = new P({ label: "image format", labelFor: "textmode-export-image-format", variant: "compact" });
1974
1978
  r.mount(e.root), this.formatSelect.mount(r.root);
@@ -2002,8 +2006,8 @@ class qe extends Y {
2002
2006
  }
2003
2007
  render() {
2004
2008
  const t = document.createElement("div");
2005
- t.classList.add(v.stack), this.includeBackground.mount(t);
2006
- const e = new H("row");
2009
+ t.classList.add(b.stack), this.includeBackground.mount(t);
2010
+ const e = new j("row");
2007
2011
  e.mount(t);
2008
2012
  const r = new P({ label: "draw mode", labelFor: "textmode-export-svg-draw-mode", variant: "compact" });
2009
2013
  r.mount(e.root), this.drawMode.mount(r.root);
@@ -2031,31 +2035,31 @@ class qe extends Y {
2031
2035
  this.strokeWidth.value = String(e), this.strokeWidth.refresh();
2032
2036
  }
2033
2037
  }
2034
- const ze = [{ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, createBlade: () => new Ge({ 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 ht({ format: "video", label: "video (.webm)", supportsClipboard: !1, defaultOptions: { frameCount: 480, frameRate: 60, quality: 0.7 } }) }];
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 } }) }];
2035
2039
  function je() {
2036
- return ze;
2040
+ return He;
2037
2041
  }
2038
- function He(o, t) {
2039
- const e = je(), r = e[0]?.format, a = new Re(Ue(r)), i = new Te(), n = new Oe(o, t, a, i, e);
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);
2040
2044
  return n.$mount(), n;
2041
2045
  }
2042
- const Qe = (o = {}) => {
2043
- const t = o.overlay ?? !0;
2046
+ const Xe = (s = {}) => {
2047
+ const t = s.overlay ?? !0;
2044
2048
  let e;
2045
2049
  return { name: "textmode-export", version: "1.0.0", async install(r, a) {
2046
- const i = { saveCanvas: async (n = {}) => (a.flushDrawCommands(), new vt().$saveImage(r.canvas, n)), copyCanvas: async (n = {}) => (a.flushDrawCommands(), new vt().$copyImageToClipboard(r.canvas, n)), saveSVG: (n = {}) => {
2047
- a.flushDrawCommands(), new gt().$saveSVG(r, n);
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);
2048
2052
  }, saveStrings: (n = {}) => {
2049
- a.flushDrawCommands(), new bt().$saveTXT(r, n);
2050
- }, toSVG: (n = {}) => (a.flushDrawCommands(), new gt().$generateSVG(r, n)), toString: (n = {}) => (a.flushDrawCommands(), new bt().$generateTXT(r, n)), saveGIF: async (n = {}) => (a.flushDrawCommands(), new me(r, a.registerPostDrawHook).$saveGIF(n)), saveWEBM: async (n = {}) => (a.flushDrawCommands(), new Ce(r, a.registerPostDrawHook).$saveWEBM(n)) };
2051
- Object.assign(r, i), t && (e = He(r, i));
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));
2052
2056
  }, async uninstall(r) {
2053
2057
  e?.$dispose(), e = void 0;
2054
2058
  const a = ["saveCanvas", "copyCanvas", "saveSVG", "saveStrings", "toSVG", "toString", "saveGIF", "saveWEBM"];
2055
2059
  for (const i of a) delete r[i];
2056
2060
  } };
2057
2061
  };
2058
- typeof window < "u" && (window.createTextmodeExportPlugin = Qe);
2062
+ typeof window < "u" && (window.createTextmodeExportPlugin = Xe);
2059
2063
  export {
2060
- Qe as createTextmodeExportPlugin
2064
+ Xe as createTextmodeExportPlugin
2061
2065
  };