@munusshih/p5.export 0.1.0-beta.10 → 0.1.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/p5.export.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @munusshih/p5.export v0.1.0-beta.10 | Created by Munus Shih | MIT License | https://github.com/munusshih/p5.export */
1
+ /*! @munusshih/p5.export v0.1.0-beta.11 | Created by Munus Shih | MIT License | https://github.com/munusshih/p5.export */
2
2
  function St(t, e) {
3
3
  const i = URL.createObjectURL(t), r = document.createElement("a");
4
4
  r.href = i, r.download = e, r.style.display = "none", document.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(i), 0);
@@ -24,24 +24,24 @@ function Li(t) {
24
24
  const i = e.drawingContext;
25
25
  return !!(i && typeof i.fillRect != "function" || e.GL);
26
26
  }
27
- const ls = {
27
+ const hs = {
28
28
  png: "image/png",
29
29
  jpg: "image/jpeg",
30
30
  jpeg: "image/jpeg",
31
31
  webp: "image/webp"
32
32
  };
33
- async function rn(t, e, i, r) {
33
+ async function nn(t, e, i, r) {
34
34
  const n = t && t._p5ExportSVGRecorder;
35
35
  if (!n || !n.ops || n.ops.length === 0) return null;
36
36
  const s = At(t);
37
37
  if (!s) return null;
38
- const a = typeof t.pixelDensity == "function" ? t.pixelDensity() : 1, o = Math.max(1, Math.round(s.width / a)), f = Math.max(1, Math.round(s.height / a)), g = o * e, v = f * e, u = document.createElement("canvas");
39
- u.width = g, u.height = v;
40
- const l = u.getContext("2d");
38
+ const a = typeof t.pixelDensity == "function" ? t.pixelDensity() : 1, o = Math.max(1, Math.round(s.width / a)), p = Math.max(1, Math.round(s.height / a)), w = o * e, v = p * e, m = document.createElement("canvas");
39
+ m.width = w, m.height = v;
40
+ const l = m.getContext("2d");
41
41
  if (!l) return null;
42
42
  const d = e / a, c = n.ops;
43
- for (let w = 0; w < c.length; w++) {
44
- const y = c[w];
43
+ for (let g = 0; g < c.length; g++) {
44
+ const y = c[g];
45
45
  try {
46
46
  if (y[0] === 0) {
47
47
  const M = y[1];
@@ -55,16 +55,16 @@ async function rn(t, e, i, r) {
55
55
  } catch {
56
56
  }
57
57
  }
58
- const m = ls[i] || "image/png";
59
- return new Promise((w, y) => {
60
- u.toBlob(
61
- (M) => M ? w(M) : y(new Error("[p5.export] toBlob returned null")),
62
- m,
58
+ const u = hs[i] || "image/png";
59
+ return new Promise((g, y) => {
60
+ m.toBlob(
61
+ (M) => M ? g(M) : y(new Error("[p5.export] toBlob returned null")),
62
+ u,
63
63
  r
64
64
  );
65
65
  });
66
66
  }
67
- async function nn(t, e, i) {
67
+ async function sn(t, e, i) {
68
68
  if (!e || e <= 1) return i();
69
69
  const r = typeof t.pixelDensity == "function" ? t.pixelDensity() : 1;
70
70
  if (e <= r) return i();
@@ -76,16 +76,16 @@ async function nn(t, e, i) {
76
76
  t.pixelDensity(r), typeof t.redraw == "function" && await t.redraw(), n && typeof t.loop == "function" && t.loop();
77
77
  }
78
78
  }
79
- const hs = {
79
+ const ds = {
80
80
  png: "image/png",
81
81
  jpg: "image/jpeg",
82
82
  jpeg: "image/jpeg",
83
83
  webp: "image/webp"
84
84
  };
85
- function Bi(t, e, i) {
85
+ function Fi(t, e, i) {
86
86
  const r = At(t);
87
87
  if (!r) return Promise.reject(new Error("[p5.export] no canvas found"));
88
- const n = hs[e];
88
+ const n = ds[e];
89
89
  return n ? new Promise((s, a) => {
90
90
  r.toBlob(
91
91
  (o) => o ? s(o) : a(new Error("[p5.export] toBlob returned null")),
@@ -95,13 +95,13 @@ function Bi(t, e, i) {
95
95
  }) : Promise.reject(new Error(`[p5.export] unknown image format: ${e}`));
96
96
  }
97
97
  async function Ze(t, e, i, r) {
98
- if (!e || e <= 1) return Bi(t, i, r);
98
+ if (!e || e <= 1) return Fi(t, i, r);
99
99
  const n = typeof t.pixelDensity == "function" ? t.pixelDensity() : 1;
100
- if (e <= n) return Bi(t, i, r);
101
- const s = await rn(t, e, i, r);
102
- return s || nn(t, e, () => Bi(t, i, r));
100
+ if (e <= n) return Fi(t, i, r);
101
+ const s = await nn(t, e, i, r);
102
+ return s || sn(t, e, () => Fi(t, i, r));
103
103
  }
104
- function ds(t, e) {
104
+ function cs(t, e) {
105
105
  e.savePNG = async function(i, r = {}) {
106
106
  const n = await Ze(this, r.scale, "png");
107
107
  return St(n, i ? Et(i, "png") : Ct("png")), n;
@@ -117,10 +117,10 @@ function ds(t, e) {
117
117
  return St(s, r ? Et(r, i) : Ct(i)), s;
118
118
  };
119
119
  }
120
- function cs(t) {
120
+ function ps(t) {
121
121
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
122
122
  }
123
- var sn = { exports: {} };
123
+ var an = { exports: {} };
124
124
  /*!!
125
125
  * Canvas 2 Svg v1.0.15
126
126
  * A low level canvas to SVG converter. Uses a mock canvas context to build an SVG document.
@@ -137,29 +137,29 @@ var sn = { exports: {} };
137
137
  (function() {
138
138
  var e, i, r, n, s;
139
139
  function a(l, d) {
140
- var c = Object.keys(d), m;
141
- for (m = 0; m < c.length; m++)
142
- l = l.replace(new RegExp("\\{" + c[m] + "\\}", "gi"), d[c[m]]);
140
+ var c = Object.keys(d), u;
141
+ for (u = 0; u < c.length; u++)
142
+ l = l.replace(new RegExp("\\{" + c[u] + "\\}", "gi"), d[c[u]]);
143
143
  return l;
144
144
  }
145
145
  function o(l) {
146
- var d, c, m;
146
+ var d, c, u;
147
147
  if (!l)
148
148
  throw new Error("cannot create a random attribute name for an undefined object");
149
149
  d = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz", c = "";
150
150
  do
151
- for (c = "", m = 0; m < 12; m++)
151
+ for (c = "", u = 0; u < 12; u++)
152
152
  c += d[Math.floor(Math.random() * d.length)];
153
153
  while (l[c]);
154
154
  return c;
155
155
  }
156
- function f(l, d) {
157
- var c, m, w = {}, y;
156
+ function p(l, d) {
157
+ var c, u, g = {}, y;
158
158
  for (l = l.split(","), d = d || 10, c = 0; c < l.length; c += 2)
159
- m = "&" + l[c + 1] + ";", y = parseInt(l[c], d), w[m] = "&#" + y + ";";
160
- return w["\\xa0"] = "&#160;", w;
159
+ u = "&" + l[c + 1] + ";", y = parseInt(l[c], d), g[u] = "&#" + y + ";";
160
+ return g["\\xa0"] = "&#160;", g;
161
161
  }
162
- function g(l) {
162
+ function w(l) {
163
163
  var d = { left: "start", right: "end", center: "middle", start: "start", end: "end" };
164
164
  return d[l] || d.start;
165
165
  }
@@ -167,7 +167,7 @@ var sn = { exports: {} };
167
167
  var d = { alphabetic: "alphabetic", hanging: "hanging", top: "text-before-edge", bottom: "text-after-edge", middle: "central" };
168
168
  return d[l] || d.alphabetic;
169
169
  }
170
- s = f(
170
+ s = p(
171
171
  "50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",
172
172
  32
173
173
  ), e = {
@@ -243,8 +243,8 @@ var sn = { exports: {} };
243
243
  }, r = function(l, d) {
244
244
  this.__root = l, this.__ctx = d;
245
245
  }, r.prototype.addColorStop = function(l, d) {
246
- var c = this.__ctx.__createElement("stop"), m, w;
247
- c.setAttribute("offset", l), d.indexOf("rgba") !== -1 ? (m = /rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi, w = m.exec(d), c.setAttribute("stop-color", a("rgb({r},{g},{b})", { r: w[1], g: w[2], b: w[3] })), c.setAttribute("stop-opacity", w[4])) : c.setAttribute("stop-color", d), this.__root.appendChild(c);
246
+ var c = this.__ctx.__createElement("stop"), u, g;
247
+ c.setAttribute("offset", l), d.indexOf("rgba") !== -1 ? (u = /rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi, g = u.exec(d), c.setAttribute("stop-color", a("rgb({r},{g},{b})", { r: g[1], g: g[2], b: g[3] })), c.setAttribute("stop-opacity", g[4])) : c.setAttribute("stop-color", d), this.__root.appendChild(c);
248
248
  }, n = function(l, d) {
249
249
  this.__root = l, this.__ctx = d;
250
250
  }, i = function(l) {
@@ -254,40 +254,40 @@ var sn = { exports: {} };
254
254
  this.width = c.width || d.width, this.height = c.height || d.height, this.enableMirroring = c.enableMirroring !== void 0 ? c.enableMirroring : d.enableMirroring, this.canvas = this, this.__document = c.document || document, this.__canvas = this.__document.createElement("canvas"), this.__ctx = this.__canvas.getContext("2d"), this.__setDefaultStyles(), this.__stack = [this.__getStyleState()], this.__groupStack = [], this.__root = this.__document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.__root.setAttribute("version", 1.1), this.__root.setAttribute("xmlns", "http://www.w3.org/2000/svg"), this.__root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink"), this.__root.setAttribute("width", this.width), this.__root.setAttribute("height", this.height), this.__ids = {}, this.__defs = this.__document.createElementNS("http://www.w3.org/2000/svg", "defs"), this.__root.appendChild(this.__defs), this.__currentElement = this.__document.createElementNS("http://www.w3.org/2000/svg", "g"), this.__root.appendChild(this.__currentElement);
255
255
  }, i.prototype.__createElement = function(l, d, c) {
256
256
  typeof d > "u" && (d = {});
257
- var m = this.__document.createElementNS("http://www.w3.org/2000/svg", l), w = Object.keys(d), y, M;
258
- for (c && (m.setAttribute("fill", "none"), m.setAttribute("stroke", "none")), y = 0; y < w.length; y++)
259
- M = w[y], m.setAttribute(M, d[M]);
260
- return m;
257
+ var u = this.__document.createElementNS("http://www.w3.org/2000/svg", l), g = Object.keys(d), y, M;
258
+ for (c && (u.setAttribute("fill", "none"), u.setAttribute("stroke", "none")), y = 0; y < g.length; y++)
259
+ M = g[y], u.setAttribute(M, d[M]);
260
+ return u;
261
261
  }, i.prototype.__setDefaultStyles = function() {
262
262
  var l = Object.keys(e), d, c;
263
263
  for (d = 0; d < l.length; d++)
264
264
  c = l[d], this[c] = e[c].canvas;
265
265
  }, i.prototype.__applyStyleState = function(l) {
266
- var d = Object.keys(l), c, m;
266
+ var d = Object.keys(l), c, u;
267
267
  for (c = 0; c < d.length; c++)
268
- m = d[c], this[m] = l[m];
268
+ u = d[c], this[u] = l[u];
269
269
  }, i.prototype.__getStyleState = function() {
270
- var l, d = {}, c = Object.keys(e), m;
270
+ var l, d = {}, c = Object.keys(e), u;
271
271
  for (l = 0; l < c.length; l++)
272
- m = c[l], d[m] = this[m];
272
+ u = c[l], d[u] = this[u];
273
273
  return d;
274
274
  }, i.prototype.__applyStyleToCurrentElement = function(l) {
275
- var d = Object.keys(e), c, m, w, y, M, S;
275
+ var d = Object.keys(e), c, u, g, y, M, S;
276
276
  for (c = 0; c < d.length; c++)
277
- if (m = e[d[c]], w = this[d[c]], m.apply)
278
- if (m.apply.indexOf("fill") !== -1 && w instanceof n) {
279
- if (w.__ctx)
280
- for (; w.__ctx.__defs.childNodes.length; )
281
- y = w.__ctx.__defs.childNodes[0].getAttribute("id"), this.__ids[y] = y, this.__defs.appendChild(w.__ctx.__defs.childNodes[0]);
282
- this.__currentElement.setAttribute("fill", a("url(#{id})", { id: w.__root.getAttribute("id") }));
283
- } else m.apply.indexOf("fill") !== -1 && w instanceof r ? this.__currentElement.setAttribute("fill", a("url(#{id})", { id: w.__root.getAttribute("id") })) : m.apply.indexOf(l) !== -1 && m.svg !== w && ((m.svgAttr === "stroke" || m.svgAttr === "fill") && w.indexOf("rgba") !== -1 ? (M = /rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi, S = M.exec(w), this.__currentElement.setAttribute(m.svgAttr, a("rgb({r},{g},{b})", { r: S[1], g: S[2], b: S[3] })), this.__currentElement.setAttribute(m.svgAttr + "-opacity", S[4])) : this.__currentElement.setAttribute(m.svgAttr, w));
277
+ if (u = e[d[c]], g = this[d[c]], u.apply)
278
+ if (u.apply.indexOf("fill") !== -1 && g instanceof n) {
279
+ if (g.__ctx)
280
+ for (; g.__ctx.__defs.childNodes.length; )
281
+ y = g.__ctx.__defs.childNodes[0].getAttribute("id"), this.__ids[y] = y, this.__defs.appendChild(g.__ctx.__defs.childNodes[0]);
282
+ this.__currentElement.setAttribute("fill", a("url(#{id})", { id: g.__root.getAttribute("id") }));
283
+ } else u.apply.indexOf("fill") !== -1 && g instanceof r ? this.__currentElement.setAttribute("fill", a("url(#{id})", { id: g.__root.getAttribute("id") })) : u.apply.indexOf(l) !== -1 && u.svg !== g && ((u.svgAttr === "stroke" || u.svgAttr === "fill") && g.indexOf("rgba") !== -1 ? (M = /rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi, S = M.exec(g), this.__currentElement.setAttribute(u.svgAttr, a("rgb({r},{g},{b})", { r: S[1], g: S[2], b: S[3] })), this.__currentElement.setAttribute(u.svgAttr + "-opacity", S[4])) : this.__currentElement.setAttribute(u.svgAttr, g));
284
284
  }, i.prototype.__closestGroupOrSvg = function(l) {
285
285
  return l = l || this.__currentElement, l.nodeName === "g" || l.nodeName === "svg" ? l : this.__closestGroupOrSvg(l.parentNode);
286
286
  }, i.prototype.getSerializedSvg = function(l) {
287
- var d = new XMLSerializer().serializeToString(this.__root), c, m, w, y, M, S;
287
+ var d = new XMLSerializer().serializeToString(this.__root), c, u, g, y, M, S;
288
288
  if (S = /xmlns="http:\/\/www\.w3\.org\/2000\/svg".+xmlns="http:\/\/www\.w3\.org\/2000\/svg/gi, S.test(d) && (d = d.replace('xmlns="http://www.w3.org/2000/svg', 'xmlns:xlink="http://www.w3.org/1999/xlink')), l)
289
- for (c = Object.keys(s), m = 0; m < c.length; m++)
290
- w = c[m], y = s[w], M = new RegExp(w, "gi"), M.test(d) && (d = d.replace(M, y));
289
+ for (c = Object.keys(s), u = 0; u < c.length; u++)
290
+ g = c[u], y = s[g], M = new RegExp(g, "gi"), M.test(d) && (d = d.replace(M, y));
291
291
  return d;
292
292
  }, i.prototype.getSvg = function() {
293
293
  return this.__root;
@@ -304,8 +304,8 @@ var sn = { exports: {} };
304
304
  var c = this.__createElement("g");
305
305
  d.appendChild(c), this.__currentElement = c;
306
306
  }
307
- var m = this.__currentElement.getAttribute("transform");
308
- m ? m += " " : m = "", m += l, this.__currentElement.setAttribute("transform", m);
307
+ var u = this.__currentElement.getAttribute("transform");
308
+ u ? u += " " : u = "", u += l, this.__currentElement.setAttribute("transform", u);
309
309
  }, i.prototype.scale = function(l, d) {
310
310
  d === void 0 && (d = l), this.__addTransform(a("scale({x},{y})", { x: l, y: d }));
311
311
  }, i.prototype.rotate = function(l) {
@@ -313,8 +313,8 @@ var sn = { exports: {} };
313
313
  this.__addTransform(a("rotate({angle},{cx},{cy})", { angle: d, cx: 0, cy: 0 }));
314
314
  }, i.prototype.translate = function(l, d) {
315
315
  this.__addTransform(a("translate({x},{y})", { x: l, y: d }));
316
- }, i.prototype.transform = function(l, d, c, m, w, y) {
317
- this.__addTransform(a("matrix({a},{b},{c},{d},{e},{f})", { a: l, b: d, c, d: m, e: w, f: y }));
316
+ }, i.prototype.transform = function(l, d, c, u, g, y) {
317
+ this.__addTransform(a("matrix({a},{b},{c},{d},{e},{f})", { a: l, b: d, c, d: u, e: g, f: y }));
318
318
  }, i.prototype.beginPath = function() {
319
319
  var l, d;
320
320
  this.__currentDefaultPath = "", this.__currentPosition = {}, l = this.__createElement("path", {}, !0), d = this.__closestGroupOrSvg(), d.appendChild(l), this.__currentElement = l;
@@ -332,36 +332,36 @@ var sn = { exports: {} };
332
332
  this.__addPathCommand("Z");
333
333
  }, i.prototype.lineTo = function(l, d) {
334
334
  this.__currentPosition = { x: l, y: d }, this.__currentDefaultPath.indexOf("M") > -1 ? this.__addPathCommand(a("L {x} {y}", { x: l, y: d })) : this.__addPathCommand(a("M {x} {y}", { x: l, y: d }));
335
- }, i.prototype.bezierCurveTo = function(l, d, c, m, w, y) {
336
- this.__currentPosition = { x: w, y }, this.__addPathCommand(a(
335
+ }, i.prototype.bezierCurveTo = function(l, d, c, u, g, y) {
336
+ this.__currentPosition = { x: g, y }, this.__addPathCommand(a(
337
337
  "C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}",
338
- { cp1x: l, cp1y: d, cp2x: c, cp2y: m, x: w, y }
338
+ { cp1x: l, cp1y: d, cp2x: c, cp2y: u, x: g, y }
339
339
  ));
340
- }, i.prototype.quadraticCurveTo = function(l, d, c, m) {
341
- this.__currentPosition = { x: c, y: m }, this.__addPathCommand(a("Q {cpx} {cpy} {x} {y}", { cpx: l, cpy: d, x: c, y: m }));
340
+ }, i.prototype.quadraticCurveTo = function(l, d, c, u) {
341
+ this.__currentPosition = { x: c, y: u }, this.__addPathCommand(a("Q {cpx} {cpy} {x} {y}", { cpx: l, cpy: d, x: c, y: u }));
342
342
  };
343
- var u = function(l) {
343
+ var m = function(l) {
344
344
  var d = Math.sqrt(l[0] * l[0] + l[1] * l[1]);
345
345
  return [l[0] / d, l[1] / d];
346
346
  };
347
- i.prototype.arcTo = function(l, d, c, m, w) {
347
+ i.prototype.arcTo = function(l, d, c, u, g) {
348
348
  var y = this.__currentPosition && this.__currentPosition.x, M = this.__currentPosition && this.__currentPosition.y;
349
349
  if (!(typeof y > "u" || typeof M > "u")) {
350
- if (w < 0)
351
- throw new Error("IndexSizeError: The radius provided (" + w + ") is negative.");
352
- if (y === l && M === d || l === c && d === m || w === 0) {
350
+ if (g < 0)
351
+ throw new Error("IndexSizeError: The radius provided (" + g + ") is negative.");
352
+ if (y === l && M === d || l === c && d === u || g === 0) {
353
353
  this.lineTo(l, d);
354
354
  return;
355
355
  }
356
- var S = u([y - l, M - d]), _ = u([c - l, m - d]);
356
+ var S = m([y - l, M - d]), _ = m([c - l, u - d]);
357
357
  if (S[0] * _[1] === S[1] * _[0]) {
358
358
  this.lineTo(l, d);
359
359
  return;
360
360
  }
361
- var E = S[0] * _[0] + S[1] * _[1], D = Math.acos(Math.abs(E)), I = u([
361
+ var E = S[0] * _[0] + S[1] * _[1], D = Math.acos(Math.abs(E)), I = m([
362
362
  S[0] + _[0],
363
363
  S[1] + _[1]
364
- ]), V = w / Math.sin(D / 2), N = l + V * I[0], Y = d + V * I[1], q = [
364
+ ]), V = g / Math.sin(D / 2), N = l + V * I[0], Y = d + V * I[1], q = [
365
365
  -S[1],
366
366
  S[0]
367
367
  ], H = [
@@ -372,56 +372,56 @@ var sn = { exports: {} };
372
372
  return G >= 0 ? Math.acos(rt) : -Math.acos(rt);
373
373
  }, J = lt(q), Wt = lt(H);
374
374
  this.lineTo(
375
- N + q[0] * w,
376
- Y + q[1] * w
377
- ), this.arc(N, Y, w, J, Wt);
375
+ N + q[0] * g,
376
+ Y + q[1] * g
377
+ ), this.arc(N, Y, g, J, Wt);
378
378
  }
379
379
  }, i.prototype.stroke = function() {
380
380
  this.__currentElement.nodeName === "path" && this.__currentElement.setAttribute("paint-order", "fill stroke markers"), this.__applyCurrentDefaultPath(), this.__applyStyleToCurrentElement("stroke");
381
381
  }, i.prototype.fill = function() {
382
382
  this.__currentElement.nodeName === "path" && this.__currentElement.setAttribute("paint-order", "stroke fill markers"), this.__applyCurrentDefaultPath(), this.__applyStyleToCurrentElement("fill");
383
- }, i.prototype.rect = function(l, d, c, m) {
384
- this.__currentElement.nodeName !== "path" && this.beginPath(), this.moveTo(l, d), this.lineTo(l + c, d), this.lineTo(l + c, d + m), this.lineTo(l, d + m), this.lineTo(l, d), this.closePath();
385
- }, i.prototype.fillRect = function(l, d, c, m) {
386
- var w, y;
387
- w = this.__createElement("rect", {
383
+ }, i.prototype.rect = function(l, d, c, u) {
384
+ this.__currentElement.nodeName !== "path" && this.beginPath(), this.moveTo(l, d), this.lineTo(l + c, d), this.lineTo(l + c, d + u), this.lineTo(l, d + u), this.lineTo(l, d), this.closePath();
385
+ }, i.prototype.fillRect = function(l, d, c, u) {
386
+ var g, y;
387
+ g = this.__createElement("rect", {
388
388
  x: l,
389
389
  y: d,
390
390
  width: c,
391
- height: m
392
- }, !0), y = this.__closestGroupOrSvg(), y.appendChild(w), this.__currentElement = w, this.__applyStyleToCurrentElement("fill");
393
- }, i.prototype.strokeRect = function(l, d, c, m) {
394
- var w, y;
395
- w = this.__createElement("rect", {
391
+ height: u
392
+ }, !0), y = this.__closestGroupOrSvg(), y.appendChild(g), this.__currentElement = g, this.__applyStyleToCurrentElement("fill");
393
+ }, i.prototype.strokeRect = function(l, d, c, u) {
394
+ var g, y;
395
+ g = this.__createElement("rect", {
396
396
  x: l,
397
397
  y: d,
398
398
  width: c,
399
- height: m
400
- }, !0), y = this.__closestGroupOrSvg(), y.appendChild(w), this.__currentElement = w, this.__applyStyleToCurrentElement("stroke");
401
- }, i.prototype.clearRect = function(l, d, c, m) {
402
- var w, y = this.__closestGroupOrSvg();
403
- w = this.__createElement("rect", {
399
+ height: u
400
+ }, !0), y = this.__closestGroupOrSvg(), y.appendChild(g), this.__currentElement = g, this.__applyStyleToCurrentElement("stroke");
401
+ }, i.prototype.clearRect = function(l, d, c, u) {
402
+ var g, y = this.__closestGroupOrSvg();
403
+ g = this.__createElement("rect", {
404
404
  x: l,
405
405
  y: d,
406
406
  width: c,
407
- height: m,
407
+ height: u,
408
408
  fill: "#FFFFFF"
409
- }, !0), y.appendChild(w);
410
- }, i.prototype.createLinearGradient = function(l, d, c, m) {
411
- var w = this.__createElement("linearGradient", {
409
+ }, !0), y.appendChild(g);
410
+ }, i.prototype.createLinearGradient = function(l, d, c, u) {
411
+ var g = this.__createElement("linearGradient", {
412
412
  id: o(this.__ids),
413
413
  x1: l + "px",
414
414
  x2: c + "px",
415
415
  y1: d + "px",
416
- y2: m + "px",
416
+ y2: u + "px",
417
417
  gradientUnits: "userSpaceOnUse"
418
418
  }, !1);
419
- return this.__defs.appendChild(w), new r(w, this);
420
- }, i.prototype.createRadialGradient = function(l, d, c, m, w, y) {
419
+ return this.__defs.appendChild(g), new r(g, this);
420
+ }, i.prototype.createRadialGradient = function(l, d, c, u, g, y) {
421
421
  var M = this.__createElement("radialGradient", {
422
422
  id: o(this.__ids),
423
- cx: m + "px",
424
- cy: w + "px",
423
+ cx: u + "px",
424
+ cy: g + "px",
425
425
  r: y + "px",
426
426
  fx: l + "px",
427
427
  fy: d + "px",
@@ -444,63 +444,63 @@ var sn = { exports: {} };
444
444
  return c.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", l.href), c.appendChild(d), c;
445
445
  }
446
446
  return d;
447
- }, i.prototype.__applyText = function(l, d, c, m) {
448
- var w = this.__parseFont(), y = this.__closestGroupOrSvg(), M = this.__createElement("text", {
449
- "font-family": w.family,
450
- "font-size": w.size,
451
- "font-style": w.style,
452
- "font-weight": w.weight,
453
- "text-decoration": w.decoration,
447
+ }, i.prototype.__applyText = function(l, d, c, u) {
448
+ var g = this.__parseFont(), y = this.__closestGroupOrSvg(), M = this.__createElement("text", {
449
+ "font-family": g.family,
450
+ "font-size": g.size,
451
+ "font-style": g.style,
452
+ "font-weight": g.weight,
453
+ "text-decoration": g.decoration,
454
454
  x: d,
455
455
  y: c,
456
- "text-anchor": g(this.textAlign),
456
+ "text-anchor": w(this.textAlign),
457
457
  "dominant-baseline": v(this.textBaseline)
458
458
  }, !0);
459
- M.appendChild(this.__document.createTextNode(l)), this.__currentElement = M, this.__applyStyleToCurrentElement(m), y.appendChild(this.__wrapTextLink(w, M));
459
+ M.appendChild(this.__document.createTextNode(l)), this.__currentElement = M, this.__applyStyleToCurrentElement(u), y.appendChild(this.__wrapTextLink(g, M));
460
460
  }, i.prototype.fillText = function(l, d, c) {
461
461
  this.__applyText(l, d, c, "fill");
462
462
  }, i.prototype.strokeText = function(l, d, c) {
463
463
  this.__applyText(l, d, c, "stroke");
464
464
  }, i.prototype.measureText = function(l) {
465
465
  return this.__ctx.font = this.font, this.__ctx.measureText(l);
466
- }, i.prototype.arc = function(l, d, c, m, w, y) {
467
- if (m !== w) {
468
- m = m % (2 * Math.PI), w = w % (2 * Math.PI), m === w && (w = (w + 2 * Math.PI - 1e-3 * (y ? -1 : 1)) % (2 * Math.PI));
469
- var M = l + c * Math.cos(w), S = d + c * Math.sin(w), _ = l + c * Math.cos(m), E = d + c * Math.sin(m), D = y ? 0 : 1, I = 0, V = w - m;
466
+ }, i.prototype.arc = function(l, d, c, u, g, y) {
467
+ if (u !== g) {
468
+ u = u % (2 * Math.PI), g = g % (2 * Math.PI), u === g && (g = (g + 2 * Math.PI - 1e-3 * (y ? -1 : 1)) % (2 * Math.PI));
469
+ var M = l + c * Math.cos(g), S = d + c * Math.sin(g), _ = l + c * Math.cos(u), E = d + c * Math.sin(u), D = y ? 0 : 1, I = 0, V = g - u;
470
470
  V < 0 && (V += 2 * Math.PI), y ? I = V > Math.PI ? 0 : 1 : I = V > Math.PI ? 1 : 0, this.lineTo(_, E), this.__addPathCommand(a(
471
471
  "A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",
472
472
  { rx: c, ry: c, xAxisRotation: 0, largeArcFlag: I, sweepFlag: D, endX: M, endY: S }
473
473
  )), this.__currentPosition = { x: M, y: S };
474
474
  }
475
475
  }, i.prototype.clip = function() {
476
- var l = this.__closestGroupOrSvg(), d = this.__createElement("clipPath"), c = o(this.__ids), m = this.__createElement("g");
477
- l.removeChild(this.__currentElement), d.setAttribute("id", c), d.appendChild(this.__currentElement), this.__defs.appendChild(d), l.setAttribute("clip-path", a("url(#{id})", { id: c })), l.appendChild(m), this.__currentElement = m;
476
+ var l = this.__closestGroupOrSvg(), d = this.__createElement("clipPath"), c = o(this.__ids), u = this.__createElement("g");
477
+ l.removeChild(this.__currentElement), d.setAttribute("id", c), d.appendChild(this.__currentElement), this.__defs.appendChild(d), l.setAttribute("clip-path", a("url(#{id})", { id: c })), l.appendChild(u), this.__currentElement = u;
478
478
  }, i.prototype.drawImage = function() {
479
- var l = Array.prototype.slice.call(arguments), d = l[0], c, m, w, y, M = 0, S = 0, _, E, D, I, V, N, Y, q, H, lt, J;
479
+ var l = Array.prototype.slice.call(arguments), d = l[0], c, u, g, y, M = 0, S = 0, _, E, D, I, V, N, Y, q, H, lt, J;
480
480
  if (l.length === 3)
481
- c = l[1], m = l[2], _ = d.width, E = d.height, w = _, y = E;
481
+ c = l[1], u = l[2], _ = d.width, E = d.height, g = _, y = E;
482
482
  else if (l.length === 5)
483
- c = l[1], m = l[2], w = l[3], y = l[4], _ = d.width, E = d.height;
483
+ c = l[1], u = l[2], g = l[3], y = l[4], _ = d.width, E = d.height;
484
484
  else if (l.length === 9)
485
- M = l[1], S = l[2], _ = l[3], E = l[4], c = l[5], m = l[6], w = l[7], y = l[8];
485
+ M = l[1], S = l[2], _ = l[3], E = l[4], c = l[5], u = l[6], g = l[7], y = l[8];
486
486
  else
487
487
  throw new Error("Inavlid number of arguments passed to drawImage: " + arguments.length);
488
488
  if (D = this.__closestGroupOrSvg(), Y = this.__currentElement, d instanceof i) {
489
489
  for (I = d.getSvg(), V = I.childNodes[0]; V.childNodes.length; )
490
490
  J = V.childNodes[0].getAttribute("id"), this.__ids[J] = J, this.__defs.appendChild(V.childNodes[0]);
491
- N = I.childNodes[1], D.appendChild(N), this.__currentElement = N, this.translate(c, m), this.__currentElement = Y;
492
- } else (d.nodeName === "CANVAS" || d.nodeName === "IMG") && (q = this.__createElement("image"), q.setAttribute("width", w), q.setAttribute("height", y), q.setAttribute("preserveAspectRatio", "none"), (M || S || _ !== d.width || E !== d.height) && (H = this.__document.createElement("canvas"), H.width = w, H.height = y, lt = H.getContext("2d"), lt.drawImage(d, M, S, _, E, 0, 0, w, y), d = H), q.setAttributeNS(
491
+ N = I.childNodes[1], D.appendChild(N), this.__currentElement = N, this.translate(c, u), this.__currentElement = Y;
492
+ } else (d.nodeName === "CANVAS" || d.nodeName === "IMG") && (q = this.__createElement("image"), q.setAttribute("width", g), q.setAttribute("height", y), q.setAttribute("preserveAspectRatio", "none"), (M || S || _ !== d.width || E !== d.height) && (H = this.__document.createElement("canvas"), H.width = g, H.height = y, lt = H.getContext("2d"), lt.drawImage(d, M, S, _, E, 0, 0, g, y), d = H), q.setAttributeNS(
493
493
  "http://www.w3.org/1999/xlink",
494
494
  "xlink:href",
495
495
  d.nodeName === "CANVAS" ? d.toDataURL() : d.getAttribute("src")
496
- ), D.appendChild(q), this.__currentElement = q, this.translate(c, m), this.__currentElement = Y);
496
+ ), D.appendChild(q), this.__currentElement = q, this.translate(c, u), this.__currentElement = Y);
497
497
  }, i.prototype.createPattern = function(l, d) {
498
- var c = this.__document.createElementNS("http://www.w3.org/2000/svg", "pattern"), m = o(this.__ids), w;
499
- return c.setAttribute("id", m), c.setAttribute("width", l.width), c.setAttribute("height", l.height), l.nodeName === "CANVAS" || l.nodeName === "IMG" ? (w = this.__document.createElementNS("http://www.w3.org/2000/svg", "image"), w.setAttribute("width", l.width), w.setAttribute("height", l.height), w.setAttributeNS(
498
+ var c = this.__document.createElementNS("http://www.w3.org/2000/svg", "pattern"), u = o(this.__ids), g;
499
+ return c.setAttribute("id", u), c.setAttribute("width", l.width), c.setAttribute("height", l.height), l.nodeName === "CANVAS" || l.nodeName === "IMG" ? (g = this.__document.createElementNS("http://www.w3.org/2000/svg", "image"), g.setAttribute("width", l.width), g.setAttribute("height", l.height), g.setAttributeNS(
500
500
  "http://www.w3.org/1999/xlink",
501
501
  "xlink:href",
502
502
  l.nodeName === "CANVAS" ? l.toDataURL() : l.getAttribute("src")
503
- ), c.appendChild(w), this.__defs.appendChild(c)) : l instanceof i && (c.appendChild(l.__root.childNodes[1]), this.__defs.appendChild(c)), new n(c, this);
503
+ ), c.appendChild(g), this.__defs.appendChild(c)) : l instanceof i && (c.appendChild(l.__root.childNodes[1]), this.__defs.appendChild(c)), new n(c, this);
504
504
  }, i.prototype.drawFocusRing = function() {
505
505
  }, i.prototype.createImageData = function() {
506
506
  }, i.prototype.getImageData = function() {
@@ -509,14 +509,14 @@ var sn = { exports: {} };
509
509
  }, i.prototype.setTransform = function() {
510
510
  }, typeof window == "object" && (window.C2S = i), t.exports = i;
511
511
  })();
512
- })(sn);
513
- var ps = sn.exports;
514
- const yt = /* @__PURE__ */ cs(ps), fs = Math.PI * 2;
515
- let us = 0;
516
- function ms() {
517
- return `p5ExportPattern_${++us}`;
512
+ })(an);
513
+ var fs = an.exports;
514
+ const yt = /* @__PURE__ */ ps(fs), us = Math.PI * 2;
515
+ let ms = 0;
516
+ function gs() {
517
+ return `p5ExportPattern_${++ms}`;
518
518
  }
519
- function gs(t) {
519
+ function ws(t) {
520
520
  const e = t._patternControler, i = e && Array.isArray(e.colors) ? e.colors : null;
521
521
  if (!i || i.length === 0) return "#888888";
522
522
  const r = i[i.length - 1];
@@ -528,18 +528,18 @@ function xe(t, e, i, r, n) {
528
528
  function Vr(t) {
529
529
  return t._renderer && t._renderer.states && t._renderer.states.rectMode || "corner";
530
530
  }
531
- function Fi(t) {
531
+ function Di(t) {
532
532
  return t._renderer && t._renderer.states && t._renderer.states.ellipseMode || "center";
533
533
  }
534
- function ws(t, e, i) {
534
+ function vs(t, e, i) {
535
535
  const r = t._p5ExportSVGRecorder;
536
536
  r && r.ops.push([3, e, i]);
537
537
  }
538
- function vs(t, e) {
538
+ function ys(t, e) {
539
539
  const i = t._p5ExportSVGRecorder;
540
540
  i && i.ops.push([2, "beginRaster", e]);
541
541
  }
542
- function ys(t) {
542
+ function bs(t) {
543
543
  const e = t._p5ExportSVGRecorder;
544
544
  e && e.ops.push([2, "endRaster"]);
545
545
  }
@@ -549,22 +549,22 @@ function zt(t, e, i) {
549
549
  let s, a;
550
550
  try {
551
551
  if (a = i(this, n), a) {
552
- s = ms();
553
- const f = gs(this);
554
- ws(this, a.kind, { ...a, color: f, patternId: s });
552
+ s = gs();
553
+ const p = ws(this);
554
+ vs(this, a.kind, { ...a, color: p, patternId: s });
555
555
  }
556
556
  } catch {
557
557
  }
558
558
  const o = !!this._p5ExportSVGRecorder && !!s && !!a;
559
- o && vs(this, { bbox: a, patternId: s });
559
+ o && ys(this, { bbox: a, patternId: s });
560
560
  try {
561
561
  return r.apply(this, n);
562
562
  } finally {
563
- o && ys(this);
563
+ o && bs(this);
564
564
  }
565
565
  }, t[e].__p5ExportWrapped = !0);
566
566
  }
567
- const bs = [
567
+ const _s = [
568
568
  "rectPattern",
569
569
  "squarePattern",
570
570
  "ellipsePattern",
@@ -602,37 +602,37 @@ function Lr(t, e) {
602
602
  ...xe(a[0], a[1], a[2], a[2], Vr(s))
603
603
  })), zt(i, "ellipsePattern", (s, a) => ({
604
604
  kind: "ellipse",
605
- ...xe(a[0], a[1], a[2], a[3], Fi(s))
605
+ ...xe(a[0], a[1], a[2], a[3], Di(s))
606
606
  })), zt(i, "circlePattern", (s, a) => ({
607
607
  kind: "ellipse",
608
- ...xe(a[0], a[1], a[2], a[2], Fi(s))
608
+ ...xe(a[0], a[1], a[2], a[2], Di(s))
609
609
  })), zt(i, "arcPattern", (s, a) => ({
610
610
  kind: "ellipse",
611
- ...xe(a[0], a[1], a[2], a[3], Fi(s))
611
+ ...xe(a[0], a[1], a[2], a[3], Di(s))
612
612
  })), zt(i, "trianglePattern", (s, a) => {
613
- const o = [a[0], a[2], a[4]], f = [a[1], a[3], a[5]], g = Math.min(...o), v = Math.max(...o), u = Math.min(...f), l = Math.max(...f);
613
+ const o = [a[0], a[2], a[4]], p = [a[1], a[3], a[5]], w = Math.min(...o), v = Math.max(...o), m = Math.min(...p), l = Math.max(...p);
614
614
  return {
615
615
  kind: "polygon",
616
616
  points: [[a[0], a[1]], [a[2], a[3]], [a[4], a[5]]],
617
- x: g,
618
- y: u,
619
- w: v - g,
620
- h: l - u
617
+ x: w,
618
+ y: m,
619
+ w: v - w,
620
+ h: l - m
621
621
  };
622
622
  }), zt(i, "quadPattern", (s, a) => {
623
- const o = [a[0], a[2], a[4], a[6]], f = [a[1], a[3], a[5], a[7]], g = Math.min(...o), v = Math.max(...o), u = Math.min(...f), l = Math.max(...f);
623
+ const o = [a[0], a[2], a[4], a[6]], p = [a[1], a[3], a[5], a[7]], w = Math.min(...o), v = Math.max(...o), m = Math.min(...p), l = Math.max(...p);
624
624
  return {
625
625
  kind: "polygon",
626
626
  points: [[a[0], a[1]], [a[2], a[3]], [a[4], a[5]], [a[6], a[7]]],
627
- x: g,
628
- y: u,
629
- w: v - g,
630
- h: l - u
627
+ x: w,
628
+ y: m,
629
+ w: v - w,
630
+ h: l - m
631
631
  };
632
632
  }));
633
633
  const n = e && e._isGlobal && e || typeof window < "u" && window.p5 && window.p5.instance || null;
634
634
  if (n && n._isGlobal && typeof window < "u")
635
- for (const s of bs) {
635
+ for (const s of _s) {
636
636
  const a = i[s];
637
637
  if (typeof a == "function")
638
638
  try {
@@ -643,7 +643,7 @@ function Lr(t, e) {
643
643
  get() {
644
644
  return o;
645
645
  },
646
- set(f) {
646
+ set(p) {
647
647
  }
648
648
  });
649
649
  } catch {
@@ -651,17 +651,17 @@ function Lr(t, e) {
651
651
  }
652
652
  return !0;
653
653
  }
654
- const an = "p5ExportSharedRaster";
655
- function _s(t, e, i, r) {
654
+ const on = "p5ExportSharedRaster";
655
+ function xs(t, e, i, r) {
656
656
  if (!i || !t) return;
657
657
  const n = t.fillStyle;
658
- i.patternId ? t.fillStyle = `url(#${i.patternId})` : t.fillStyle = `url(#${an})`;
658
+ i.patternId ? t.fillStyle = `url(#${i.patternId})` : t.fillStyle = `url(#${on})`;
659
659
  try {
660
660
  if (e === "rect")
661
661
  t.beginPath(), t.rect(i.x, i.y, i.w, i.h), t.fill();
662
662
  else if (e === "ellipse") {
663
- const s = i.w / 2, a = i.h / 2, o = i.x + s, f = i.y + a;
664
- t.beginPath(), t.ellipse(o, f, s, a, 0, 0, fs), t.fill();
663
+ const s = i.w / 2, a = i.h / 2, o = i.x + s, p = i.y + a;
664
+ t.beginPath(), t.ellipse(o, p, s, a, 0, 0, us), t.fill();
665
665
  } else if (e === "polygon") {
666
666
  const s = i.points || [];
667
667
  if (s.length >= 2) {
@@ -675,43 +675,43 @@ function _s(t, e, i, r) {
675
675
  }
676
676
  }
677
677
  let Gr = !1;
678
- function xs() {
678
+ function Ss() {
679
679
  if (Gr) return;
680
- Gr = !0, yt.prototype.setTransform = function(r, n, s, a, o, f) {
681
- const v = this.__groupStack && this.__groupStack.length > 0 ? this.__closestGroupOrSvg() : this.__root, u = this.__createElement("g");
682
- v.appendChild(u), this.__currentElement = u, r === 1 && n === 0 && s === 0 && a === 1 && o === 0 && f === 0 || this.__currentElement.setAttribute("transform", `matrix(${r},${n},${s},${a},${o},${f})`);
680
+ Gr = !0, yt.prototype.setTransform = function(r, n, s, a, o, p) {
681
+ const v = this.__groupStack && this.__groupStack.length > 0 ? this.__closestGroupOrSvg() : this.__root, m = this.__createElement("g");
682
+ v.appendChild(m), this.__currentElement = m, r === 1 && n === 0 && s === 0 && a === 1 && o === 0 && p === 0 || this.__currentElement.setAttribute("transform", `matrix(${r},${n},${s},${a},${o},${p})`);
683
683
  }, yt.prototype.resetTransform = function() {
684
684
  this.setTransform(1, 0, 0, 1, 0, 0);
685
- }, yt.prototype.ellipse = function(r, n, s, a, o, f, g, v) {
686
- if (f === g) return;
685
+ }, yt.prototype.ellipse = function(r, n, s, a, o, p, w, v) {
686
+ if (p === w) return;
687
687
  o = o || 0;
688
- const u = Math.PI * 2, l = Math.abs(g - f) >= u - 1e-10;
689
- f = f % u, g = g % u;
690
- const d = Math.cos(o), c = Math.sin(o), m = (D) => {
688
+ const m = Math.PI * 2, l = Math.abs(w - p) >= m - 1e-10;
689
+ p = p % m, w = w % m;
690
+ const d = Math.cos(o), c = Math.sin(o), u = (D) => {
691
691
  const I = s * Math.cos(D), V = a * Math.sin(D);
692
692
  return { x: r + I * d - V * c, y: n + I * c + V * d };
693
- }, w = m(f), y = v ? 0 : 1, M = o * 180 / Math.PI;
694
- if (this.lineTo(w.x, w.y), l) {
695
- const D = m(f + (v ? -Math.PI : Math.PI));
693
+ }, g = u(p), y = v ? 0 : 1, M = o * 180 / Math.PI;
694
+ if (this.lineTo(g.x, g.y), l) {
695
+ const D = u(p + (v ? -Math.PI : Math.PI));
696
696
  this.__addPathCommand(
697
697
  "A " + s + " " + a + " " + M + " 0 " + y + " " + D.x + " " + D.y
698
698
  ), this.__addPathCommand(
699
- "A " + s + " " + a + " " + M + " 0 " + y + " " + w.x + " " + w.y
700
- ), this.__currentPosition = { x: w.x, y: w.y };
699
+ "A " + s + " " + a + " " + M + " 0 " + y + " " + g.x + " " + g.y
700
+ ), this.__currentPosition = { x: g.x, y: g.y };
701
701
  return;
702
702
  }
703
- const S = m(g);
704
- let _ = g - f;
705
- _ < 0 && (_ += u);
703
+ const S = u(w);
704
+ let _ = w - p;
705
+ _ < 0 && (_ += m);
706
706
  const E = v ? _ > Math.PI ? 0 : 1 : _ > Math.PI ? 1 : 0;
707
707
  this.__addPathCommand(
708
708
  "A " + s + " " + a + " " + M + " " + E + " " + y + " " + S.x + " " + S.y
709
709
  ), this.__currentPosition = { x: S.x, y: S.y };
710
710
  }, typeof yt.prototype.roundRect != "function" && (yt.prototype.roundRect = function(r, n, s, a, o) {
711
- let f, g, v, u;
712
- typeof o == "number" ? f = g = v = u = o : Array.isArray(o) ? o.length === 1 ? f = g = v = u = o[0] : o.length === 2 ? (f = v = o[0], g = u = o[1]) : [f, g, v, u] = [o[0], o[1], o[2], o[3] ?? o[1]] : f = g = v = u = 0;
711
+ let p, w, v, m;
712
+ typeof o == "number" ? p = w = v = m = o : Array.isArray(o) ? o.length === 1 ? p = w = v = m = o[0] : o.length === 2 ? (p = v = o[0], w = m = o[1]) : [p, w, v, m] = [o[0], o[1], o[2], o[3] ?? o[1]] : p = w = v = m = 0;
713
713
  const l = Math.min(Math.abs(s), Math.abs(a)) / 2;
714
- f = Math.min(f, l), g = Math.min(g, l), v = Math.min(v, l), u = Math.min(u, l), this.moveTo(r + f, n), this.lineTo(r + s - g, n), this.ellipse(r + s - g, n + g, g, g, 0, -Math.PI / 2, 0), this.lineTo(r + s, n + a - v), this.ellipse(r + s - v, n + a - v, v, v, 0, 0, Math.PI / 2), this.lineTo(r + u, n + a), this.ellipse(r + u, n + a - u, u, u, 0, Math.PI / 2, Math.PI), this.lineTo(r, n + f), this.ellipse(r + f, n + f, f, f, 0, Math.PI, Math.PI * 1.5);
714
+ p = Math.min(p, l), w = Math.min(w, l), v = Math.min(v, l), m = Math.min(m, l), this.moveTo(r + p, n), this.lineTo(r + s - w, n), this.ellipse(r + s - w, n + w, w, w, 0, -Math.PI / 2, 0), this.lineTo(r + s, n + a - v), this.ellipse(r + s - v, n + a - v, v, v, 0, 0, Math.PI / 2), this.lineTo(r + m, n + a), this.ellipse(r + m, n + a - m, m, m, 0, Math.PI / 2, Math.PI), this.lineTo(r, n + p), this.ellipse(r + p, n + p, p, p, 0, Math.PI, Math.PI * 1.5);
715
715
  }), delete yt.prototype.globalCompositeOperation;
716
716
  const t = yt.prototype.__applyStyleToCurrentElement, e = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i, i = (r) => {
717
717
  if (typeof r != "string") return r;
@@ -730,9 +730,9 @@ function xs() {
730
730
  }
731
731
  };
732
732
  }
733
- const Ss = 60, te = /* @__PURE__ */ new WeakMap();
733
+ const Cs = 60, te = /* @__PURE__ */ new WeakMap();
734
734
  let Nr = !1;
735
- function Cs() {
735
+ function Es() {
736
736
  if (Nr || typeof Path2D > "u") return;
737
737
  Nr = !0;
738
738
  const t = Path2D.prototype, e = [
@@ -752,7 +752,7 @@ function Cs() {
752
752
  if (typeof n != "function" || n.__p5ExportWrapped) continue;
753
753
  const s = function(...a) {
754
754
  let o = te.get(this);
755
- return o || (o = [], te.set(this, o)), o.push([r, a.map((f) => Array.isArray(f) ? f.slice() : f)]), n.apply(this, a);
755
+ return o || (o = [], te.set(this, o)), o.push([r, a.map((p) => Array.isArray(p) ? p.slice() : p)]), n.apply(this, a);
756
756
  };
757
757
  s.__p5ExportWrapped = !0;
758
758
  try {
@@ -767,8 +767,8 @@ function Cs() {
767
767
  if (a && a.length) {
768
768
  let o = te.get(this);
769
769
  o || (o = [], te.set(this, o));
770
- const f = s ? [s.a, s.b, s.c, s.d, s.e, s.f] : null;
771
- o.push(["addPath", a.map(([g, v]) => [g, v.slice()]), f]);
770
+ const p = s ? [s.a, s.b, s.c, s.d, s.e, s.f] : null;
771
+ o.push(["addPath", a.map(([w, v]) => [w, v.slice()]), p]);
772
772
  }
773
773
  return i.apply(this, arguments);
774
774
  };
@@ -779,14 +779,14 @@ function Cs() {
779
779
  }
780
780
  }
781
781
  }
782
- function Es(t) {
782
+ function ks(t) {
783
783
  if (!t || typeof t != "object") return null;
784
784
  const e = te.get(t);
785
785
  return e ? {
786
786
  __p5ExportPath2D: e.map((i) => i[0] === "addPath" ? ["addPath", i[1].map(([r, n]) => [r, n.slice()]), i[2] && i[2].slice()] : [i[0], i[1].map((r) => Array.isArray(r) ? r.slice() : r)])
787
787
  } : null;
788
788
  }
789
- function ks(t, e) {
789
+ function Ts(t, e) {
790
790
  const i = e && e.__p5ExportPath2D;
791
791
  if (!i) return !1;
792
792
  t.beginPath();
@@ -803,7 +803,7 @@ function ks(t, e) {
803
803
  };
804
804
  return r(i), !0;
805
805
  }
806
- const on = /* @__PURE__ */ new Set([
806
+ const ln = /* @__PURE__ */ new Set([
807
807
  "fillStyle",
808
808
  "strokeStyle",
809
809
  "lineWidth",
@@ -819,16 +819,16 @@ const on = /* @__PURE__ */ new Set([
819
819
  "shadowOffsetX",
820
820
  "shadowOffsetY"
821
821
  ]);
822
- let Ts = 0;
823
- const ln = /* @__PURE__ */ new Map();
824
- function As() {
825
- return `p5ExportGrad_${++Ts}`;
822
+ let As = 0;
823
+ const hn = /* @__PURE__ */ new Map();
824
+ function Ms() {
825
+ return `p5ExportGrad_${++As}`;
826
826
  }
827
- function Ms(t) {
827
+ function Ps(t) {
828
828
  const e = [], i = [0], r = {
829
829
  proxy: null,
830
830
  ops: e,
831
- maxFrames: Ss,
831
+ maxFrames: Cs,
832
832
  paused: !1,
833
833
  // null = inherit from window.p5ExportConfig.svgTextOutlines; set via
834
834
  // fn.setSVGTextMode(). When true, saveSVG converts text to vector paths.
@@ -854,62 +854,62 @@ function Ms(t) {
854
854
  if (a > 0) {
855
855
  const o = {};
856
856
  for (let v = 0; v < a; v++) {
857
- const u = e[v];
858
- u[0] === 1 && on.has(u[1]) && (o[u[1]] = u[2]);
857
+ const m = e[v];
858
+ m[0] === 1 && ln.has(m[1]) && (o[m[1]] = m[2]);
859
859
  }
860
860
  e.splice(0, a);
861
- const f = [];
862
- for (const v in o) f.push([1, v, o[v]]);
863
- f.length && e.unshift(...f);
864
- const g = f.length - a;
865
- for (let v = 1; v < i.length; v++) i[v] += g;
861
+ const p = [];
862
+ for (const v in o) p.push([1, v, o[v]]);
863
+ p.length && e.unshift(...p);
864
+ const w = p.length - a;
865
+ for (let v = 1; v < i.length; v++) i[v] += w;
866
866
  }
867
867
  i.shift();
868
868
  }
869
869
  }
870
- }, n = /* @__PURE__ */ new Set(["createLinearGradient", "createRadialGradient", "createConicGradient"]), s = (a, o, f) => {
870
+ }, n = /* @__PURE__ */ new Set(["createLinearGradient", "createRadialGradient", "createConicGradient"]), s = (a, o, p) => {
871
871
  if (!a) return a;
872
- const g = As(), v = { id: g, kind: o, args: Array.from(f), stops: [] };
873
- ln.set(g, v);
872
+ const w = Ms(), v = { id: w, kind: o, args: Array.from(p), stops: [] };
873
+ hn.set(w, v);
874
874
  try {
875
- a.__p5ExportGradId = g;
875
+ a.__p5ExportGradId = w;
876
876
  } catch {
877
877
  }
878
878
  return new Proxy(a, {
879
- get(u, l) {
880
- if (l === "__p5ExportRealGrad") return u;
881
- if (l === "addColorStop" && typeof u[l] == "function")
882
- return function(c, m) {
883
- return v.stops.push({ offset: c, color: m }), u[l].call(u, c, m);
879
+ get(m, l) {
880
+ if (l === "__p5ExportRealGrad") return m;
881
+ if (l === "addColorStop" && typeof m[l] == "function")
882
+ return function(c, u) {
883
+ return v.stops.push({ offset: c, color: u }), m[l].call(m, c, u);
884
884
  };
885
- const d = u[l];
886
- return typeof d == "function" ? d.bind(u) : d;
885
+ const d = m[l];
886
+ return typeof d == "function" ? d.bind(m) : d;
887
887
  }
888
888
  });
889
889
  };
890
890
  return r.proxy = new Proxy(t, {
891
891
  get(a, o) {
892
- const f = a[o];
893
- return typeof f == "function" ? function(...g) {
892
+ const p = a[o];
893
+ return typeof p == "function" ? function(...w) {
894
894
  if (!r.paused) {
895
- const u = g.map((l) => Es(l) || l);
896
- e.push([0, o, u]);
895
+ const m = w.map((l) => ks(l) || l);
896
+ e.push([0, o, m]);
897
897
  }
898
- const v = f.apply(a, g);
899
- return n.has(o) ? s(v, o, g) : v;
900
- } : f;
898
+ const v = p.apply(a, w);
899
+ return n.has(o) ? s(v, o, w) : v;
900
+ } : p;
901
901
  },
902
- set(a, o, f) {
903
- if ((o === "fillStyle" || o === "strokeStyle") && f && typeof f == "object") {
904
- const g = f.__p5ExportGradId;
905
- r.paused || e.push([1, o, g ? { __p5ExportGradId: g } : f]), a[o] = f.__p5ExportRealGrad || f;
902
+ set(a, o, p) {
903
+ if ((o === "fillStyle" || o === "strokeStyle") && p && typeof p == "object") {
904
+ const w = p.__p5ExportGradId;
905
+ r.paused || e.push([1, o, w ? { __p5ExportGradId: w } : p]), a[o] = p.__p5ExportRealGrad || p;
906
906
  } else
907
- r.paused || e.push([1, o, f]), a[o] = f;
907
+ r.paused || e.push([1, o, p]), a[o] = p;
908
908
  return !0;
909
909
  }
910
910
  }), r;
911
911
  }
912
- function Ps(t) {
912
+ function Is(t) {
913
913
  return !!(t && typeof t.fillRect == "function");
914
914
  }
915
915
  function $r(t) {
@@ -917,40 +917,40 @@ function $r(t) {
917
917
  const e = t._renderer;
918
918
  if (!e) return;
919
919
  const i = e.drawingContext;
920
- if (!Ps(i)) return;
921
- const r = Ms(i), n = typeof window < "u" && window.p5ExportConfig || {};
920
+ if (!Is(i)) return;
921
+ const r = Ps(i), n = typeof window < "u" && window.p5ExportConfig || {};
922
922
  typeof n.svgMaxFrames == "number" && (r.maxFrames = n.svgMaxFrames > 0 ? n.svgMaxFrames : 1 / 0), t._p5ExportSVGRecorder = r;
923
923
  const s = { value: r.proxy, configurable: !0, writable: !0, enumerable: !0 };
924
924
  Object.defineProperty(e, "drawingContext", s), Object.defineProperty(t, "drawingContext", s);
925
925
  }
926
- function mi(t) {
926
+ function gi(t) {
927
927
  if (typeof t != "string") return t;
928
928
  const e = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);
929
929
  if (!e) return t;
930
930
  const i = parseInt(e[4], 16) / 255;
931
931
  return `rgba(${parseInt(e[1], 16)},${parseInt(e[2], 16)},${parseInt(e[3], 16)},${i})`;
932
932
  }
933
- function Is(t) {
933
+ function Rs(t) {
934
934
  if (typeof t != "string") return !0;
935
935
  let e = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);
936
936
  return e ? parseInt(e[4], 16) === 255 : (e = /^rgba\(\s*[^,]+,\s*[^,]+,\s*[^,]+,\s*([\d.]+)\s*\)$/i.exec(t), e ? parseFloat(e[1]) >= 1 : (e = /^#[0-9a-f]{3}([0-9a-f])$/i.exec(t), e ? parseInt(e[1], 16) === 15 : !0));
937
937
  }
938
- function hn(t, e, i) {
938
+ function dn(t, e, i) {
939
939
  let r = -1, n = "#000000";
940
940
  const s = 0.5;
941
941
  let a = !1;
942
942
  for (let o = 0; o < t.length; o++) {
943
- const f = t[o];
944
- if (f[0] === 2) {
945
- f[1] === "beginRaster" ? a = !0 : f[1] === "endRaster" && (a = !1);
943
+ const p = t[o];
944
+ if (p[0] === 2) {
945
+ p[1] === "beginRaster" ? a = !0 : p[1] === "endRaster" && (a = !1);
946
946
  continue;
947
947
  }
948
948
  if (!a) {
949
- if (f[0] === 1 && f[1] === "fillStyle")
950
- n = f[2];
951
- else if (f[0] === 0 && (f[1] === "fillRect" || f[1] === "clearRect")) {
952
- const g = f[2], v = g[0], u = g[1], l = g[2], d = g[3];
953
- Math.abs(v) <= s && Math.abs(u) <= s && Math.abs(l - e) <= s && Math.abs(d - i) <= s && (f[1] === "clearRect" || Is(n)) && (r = o);
949
+ if (p[0] === 1 && p[1] === "fillStyle")
950
+ n = p[2];
951
+ else if (p[0] === 0 && (p[1] === "fillRect" || p[1] === "clearRect")) {
952
+ const w = p[2], v = w[0], m = w[1], l = w[2], d = w[3];
953
+ Math.abs(v) <= s && Math.abs(m) <= s && Math.abs(l - e) <= s && Math.abs(d - i) <= s && (p[1] === "clearRect" || Rs(n)) && (r = o);
954
954
  }
955
955
  }
956
956
  }
@@ -963,7 +963,7 @@ function jr(t, e) {
963
963
  const r = typeof window < "u" && window.p5ExportConfig || {};
964
964
  return typeof r.svgTextOutlines == "boolean" ? r.svgTextOutlines : !0;
965
965
  }
966
- function Rs(t, e, i, r) {
966
+ function Bs(t, e, i, r) {
967
967
  const n = i && i.font;
968
968
  if (!n || typeof n.textToPaths != "function" || !n.data) return !1;
969
969
  const s = e._renderer;
@@ -985,43 +985,43 @@ function Rs(t, e, i, r) {
985
985
  }
986
986
  if (!a || !a.length) return !0;
987
987
  t.save(), t.beginPath();
988
- for (let f = 0; f < a.length; f++) {
989
- const g = a[f];
990
- switch (g[0]) {
988
+ for (let p = 0; p < a.length; p++) {
989
+ const w = a[p];
990
+ switch (w[0]) {
991
991
  case "M":
992
- t.moveTo(g[1], g[2]);
992
+ t.moveTo(w[1], w[2]);
993
993
  break;
994
994
  case "L":
995
- t.lineTo(g[1], g[2]);
995
+ t.lineTo(w[1], w[2]);
996
996
  break;
997
997
  case "C":
998
- t.bezierCurveTo(g[1], g[2], g[3], g[4], g[5], g[6]);
998
+ t.bezierCurveTo(w[1], w[2], w[3], w[4], w[5], w[6]);
999
999
  break;
1000
1000
  case "Q":
1001
- t.quadraticCurveTo(g[1], g[2], g[3], g[4]);
1001
+ t.quadraticCurveTo(w[1], w[2], w[3], w[4]);
1002
1002
  break;
1003
1003
  case "Z":
1004
1004
  t.closePath();
1005
1005
  break;
1006
1006
  }
1007
1007
  }
1008
- return i.fill && (t.fillStyle = mi(i.fill), t.fill()), i.hasStroke && i.stroke && (t.strokeStyle = mi(i.stroke), i.strokeWeight != null && (t.lineWidth = i.strokeWeight), t.stroke()), t.restore(), !0;
1008
+ return i.fill && (t.fillStyle = gi(i.fill), t.fill()), i.hasStroke && i.stroke && (t.strokeStyle = gi(i.stroke), i.strokeWeight != null && (t.lineWidth = i.strokeWeight), t.stroke()), t.restore(), !0;
1009
1009
  }
1010
1010
  function Hr(t, e = {}) {
1011
- xs();
1011
+ Ss();
1012
1012
  const i = !!e.outlineText, r = t._p5ExportSVGRecorder, n = t.width || 100, s = t.height || 100, a = new yt(n, s);
1013
1013
  if (a.setTransform(1, 0, 0, 1, 0, 0), !r) return a.getSerializedSvg();
1014
- let o = "#000000", f = "#000000";
1015
- const g = /* @__PURE__ */ new Set(), v = "http://www.w3.org/2000/svg", u = (G) => {
1016
- if (!G || g.has(G.id)) return !0;
1014
+ let o = "#000000", p = "#000000";
1015
+ const w = /* @__PURE__ */ new Set(), v = "http://www.w3.org/2000/svg", m = (G) => {
1016
+ if (!G || w.has(G.id)) return !0;
1017
1017
  const k = a.__defs, U = a.__document;
1018
1018
  let b;
1019
1019
  if (G.kind === "createLinearGradient") {
1020
1020
  const [z, Q, dt, Mt] = G.args;
1021
1021
  b = U.createElementNS(v, "linearGradient"), b.setAttribute("gradientUnits", "userSpaceOnUse"), b.setAttribute("x1", String(z)), b.setAttribute("y1", String(Q)), b.setAttribute("x2", String(dt)), b.setAttribute("y2", String(Mt));
1022
1022
  } else if (G.kind === "createRadialGradient") {
1023
- const [z, Q, dt, Mt, be, Ri] = G.args;
1024
- b = U.createElementNS(v, "radialGradient"), b.setAttribute("gradientUnits", "userSpaceOnUse"), b.setAttribute("fx", String(z)), b.setAttribute("fy", String(Q)), b.setAttribute("fr", String(dt)), b.setAttribute("cx", String(Mt)), b.setAttribute("cy", String(be)), b.setAttribute("r", String(Ri));
1023
+ const [z, Q, dt, Mt, be, Bi] = G.args;
1024
+ b = U.createElementNS(v, "radialGradient"), b.setAttribute("gradientUnits", "userSpaceOnUse"), b.setAttribute("fx", String(z)), b.setAttribute("fy", String(Q)), b.setAttribute("fr", String(dt)), b.setAttribute("cx", String(Mt)), b.setAttribute("cy", String(be)), b.setAttribute("r", String(Bi));
1025
1025
  } else
1026
1026
  return !1;
1027
1027
  b.setAttribute("id", G.id);
@@ -1029,12 +1029,12 @@ function Hr(t, e = {}) {
1029
1029
  const Q = U.createElementNS(v, "stop");
1030
1030
  Q.setAttribute("offset", String(z.offset)), Q.setAttribute("stop-color", String(z.color)), b.appendChild(Q);
1031
1031
  }
1032
- return k.appendChild(b), g.add(G.id), !0;
1033
- }, l = typeof t.pixelDensity == "function" ? t.pixelDensity() : 1, d = 1 / l, c = r.ops.slice(), m = hn(c, n, s);
1034
- let w = 0;
1035
- if (m > 0) {
1032
+ return k.appendChild(b), w.add(G.id), !0;
1033
+ }, l = typeof t.pixelDensity == "function" ? t.pixelDensity() : 1, d = 1 / l, c = r.ops.slice(), u = dn(c, n, s);
1034
+ let g = 0;
1035
+ if (u > 0) {
1036
1036
  let G = 0, k = -1;
1037
- for (let b = m - 1; b >= 0; b--)
1037
+ for (let b = u - 1; b >= 0; b--)
1038
1038
  if (c[b][0] === 0) {
1039
1039
  if (c[b][1] === "restore") G++;
1040
1040
  else if (c[b][1] === "save") {
@@ -1045,15 +1045,15 @@ function Hr(t, e = {}) {
1045
1045
  G--;
1046
1046
  }
1047
1047
  }
1048
- w = k >= 0 ? k : m;
1048
+ g = k >= 0 ? k : u;
1049
1049
  const U = {};
1050
- for (let b = 0; b < w; b++) {
1050
+ for (let b = 0; b < g; b++) {
1051
1051
  const z = c[b];
1052
- z[0] === 1 && on.has(z[1]) && (U[z[1]] = z[2]);
1052
+ z[0] === 1 && ln.has(z[1]) && (U[z[1]] = z[2]);
1053
1053
  }
1054
1054
  for (const b in U) {
1055
1055
  const z = U[b];
1056
- b === "fillStyle" || b === "strokeStyle" ? typeof z == "string" ? (b === "fillStyle" ? o = z : f = z, a[b] = mi(z)) : a[b] = b === "fillStyle" ? o : f : a[b] = z;
1056
+ b === "fillStyle" || b === "strokeStyle" ? typeof z == "string" ? (b === "fillStyle" ? o = z : p = z, a[b] = gi(z)) : a[b] = b === "fillStyle" ? o : p : a[b] = z;
1057
1057
  }
1058
1058
  }
1059
1059
  const y = At(t), M = y ? y.width : n * l, S = y ? y.height : s * l;
@@ -1075,15 +1075,15 @@ function Hr(t, e = {}) {
1075
1075
  } catch {
1076
1076
  return;
1077
1077
  }
1078
- const Ri = a.__defs, Pt = a.__document.createElementNS(Y, "pattern");
1078
+ const Bi = a.__defs, Pt = a.__document.createElementNS(Y, "pattern");
1079
1079
  Pt.setAttribute("id", G.patternId), Pt.setAttribute("patternUnits", "userSpaceOnUse"), Pt.setAttribute("x", String(k.x)), Pt.setAttribute("y", String(k.y)), Pt.setAttribute("width", String(k.w)), Pt.setAttribute("height", String(k.h));
1080
1080
  const It = a.__document.createElementNS(Y, "image");
1081
- It.setAttribute("x", "0"), It.setAttribute("y", "0"), It.setAttribute("width", String(k.w)), It.setAttribute("height", String(k.h)), It.setAttributeNS(q, "xlink:href", be), It.setAttribute("href", be), It.setAttribute("preserveAspectRatio", "none"), Pt.appendChild(It), Ri.appendChild(Pt);
1081
+ It.setAttribute("x", "0"), It.setAttribute("y", "0"), It.setAttribute("width", String(k.w)), It.setAttribute("height", String(k.h)), It.setAttributeNS(q, "xlink:href", be), It.setAttribute("href", be), It.setAttribute("preserveAspectRatio", "none"), Pt.appendChild(It), Bi.appendChild(Pt);
1082
1082
  }, Wt = () => {
1083
1083
  if (!(!I || !N))
1084
1084
  try {
1085
1085
  const G = I.toDataURL(), k = a.__defs, U = a.__document.createElementNS(Y, "pattern");
1086
- U.setAttribute("id", an), U.setAttribute("patternUnits", "userSpaceOnUse"), U.setAttribute("x", "0"), U.setAttribute("y", "0"), U.setAttribute("width", String(n)), U.setAttribute("height", String(s));
1086
+ U.setAttribute("id", on), U.setAttribute("patternUnits", "userSpaceOnUse"), U.setAttribute("x", "0"), U.setAttribute("y", "0"), U.setAttribute("width", String(n)), U.setAttribute("height", String(s));
1087
1087
  const b = a.__document.createElementNS(Y, "image");
1088
1088
  b.setAttribute("x", "0"), b.setAttribute("y", "0"), b.setAttribute("width", String(n)), b.setAttribute("height", String(s)), b.setAttributeNS(q, "xlink:href", G), b.setAttribute("href", G), U.appendChild(b), k.appendChild(U);
1089
1089
  const z = a.__document.createElementNS(Y, "image");
@@ -1092,10 +1092,10 @@ function Hr(t, e = {}) {
1092
1092
  }
1093
1093
  };
1094
1094
  let ht = !1, rt = !1;
1095
- for (let G = w; G < c.length; G++) {
1095
+ for (let G = g; G < c.length; G++) {
1096
1096
  const k = c[G];
1097
1097
  if (k[0] === 5) {
1098
- k[1] === "textStart" ? rt = i ? Rs(a, t, k[2], r) : !1 : k[1] === "textEnd" && (rt = !1);
1098
+ k[1] === "textStart" ? rt = i ? Bs(a, t, k[2], r) : !1 : k[1] === "textEnd" && (rt = !1);
1099
1099
  continue;
1100
1100
  }
1101
1101
  if (rt) continue;
@@ -1108,7 +1108,7 @@ function Hr(t, e = {}) {
1108
1108
  }
1109
1109
  if (k[0] === 3) {
1110
1110
  try {
1111
- _s(a, k[1], k[2], !0);
1111
+ xs(a, k[1], k[2], !0);
1112
1112
  } catch {
1113
1113
  }
1114
1114
  continue;
@@ -1121,7 +1121,7 @@ function Hr(t, e = {}) {
1121
1121
  const b = k[2];
1122
1122
  U === a ? U.setTransform(b[0] * d, b[1] * d, b[2] * d, b[3] * d, b[4] * d, b[5] * d) : U.setTransform(b[0], b[1], b[2], b[3], b[4], b[5]);
1123
1123
  } else if ((k[1] === "fill" || k[1] === "stroke" || k[1] === "clip") && k[2] && k[2][0] && k[2][0].__p5ExportPath2D) {
1124
- ks(U, k[2][0]);
1124
+ Ts(U, k[2][0]);
1125
1125
  const b = U[k[1]];
1126
1126
  typeof b == "function" && b.apply(U, k[2].slice(1));
1127
1127
  } else {
@@ -1131,12 +1131,12 @@ function Hr(t, e = {}) {
1131
1131
  else if (k[1] === "fillStyle" || k[1] === "strokeStyle") {
1132
1132
  const b = k[2], z = k[1] === "fillStyle";
1133
1133
  if (typeof b == "string")
1134
- z ? o = b : f = b, U[k[1]] = U === a ? mi(b) : b;
1134
+ z ? o = b : p = b, U[k[1]] = U === a ? gi(b) : b;
1135
1135
  else if (b && typeof b == "object" && b.__p5ExportGradId) {
1136
- const Q = ln.get(b.__p5ExportGradId);
1137
- U === a && u(Q) ? U[k[1]] = `url(#${Q.id})` : U === a && (U[k[1]] = z ? o : f);
1136
+ const Q = hn.get(b.__p5ExportGradId);
1137
+ U === a && m(Q) ? U[k[1]] = `url(#${Q.id})` : U === a && (U[k[1]] = z ? o : p);
1138
1138
  } else if (U === a)
1139
- U[k[1]] = z ? o : f;
1139
+ U[k[1]] = z ? o : p;
1140
1140
  else
1141
1141
  try {
1142
1142
  U[k[1]] = b;
@@ -1160,17 +1160,17 @@ function Hr(t, e = {}) {
1160
1160
  }
1161
1161
  return D && J(D), Wt(), a.getSerializedSvg();
1162
1162
  }
1163
- function Bs(t) {
1163
+ function Fs(t) {
1164
1164
  const e = t.toDataURL("image/png"), i = t.width, r = t.height;
1165
1165
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${i}" height="${r}" viewBox="0 0 ${i} ${r}"><image href="${e}" width="${i}" height="${r}"/></svg>`;
1166
1166
  }
1167
- function Fs(t, e, i) {
1168
- Cs(), e.saveSVG = function(s, a = {}) {
1167
+ function Ds(t, e, i) {
1168
+ Es(), e.saveSVG = function(s, a = {}) {
1169
1169
  let o;
1170
- const f = !!this._p5ExportSVGRecorder, g = 2e6;
1170
+ const p = !!this._p5ExportSVGRecorder, w = 2e6;
1171
1171
  let v = 0;
1172
- if (f) {
1173
- const c = this._p5ExportSVGRecorder.ops.slice(), m = this.width || 100, w = this.height || 100, y = hn(c, m, w);
1172
+ if (p) {
1173
+ const c = this._p5ExportSVGRecorder.ops.slice(), u = this.width || 100, g = this.height || 100, y = dn(c, u, g);
1174
1174
  let M = 0;
1175
1175
  if (y > 0) {
1176
1176
  let _ = 0;
@@ -1196,9 +1196,9 @@ function Fs(t, e, i) {
1196
1196
  E[0] !== 5 && (S || v++);
1197
1197
  }
1198
1198
  }
1199
- const u = f && !a.forceVector && v > g;
1200
- if (!a.raster && (!f || u) && !a.silent && typeof window < "u" && typeof window.confirm == "function") {
1201
- const c = u ? `This sketch produced ${v.toLocaleString()} vector ops — too many to render as vector SVG cleanly (viewers crash above ~250k paths).` : "This sketch's renderer (likely WEBGL) can't be captured as vector. SVG would only contain a single embedded PNG.";
1199
+ const m = p && !a.forceVector && v > w;
1200
+ if (!a.raster && (!p || m) && !a.silent && typeof window < "u" && typeof window.confirm == "function") {
1201
+ const c = m ? `This sketch produced ${v.toLocaleString()} vector ops — too many to render as vector SVG cleanly (viewers crash above ~250k paths).` : "This sketch's renderer (likely WEBGL) can't be captured as vector. SVG would only contain a single embedded PNG.";
1202
1202
  if (!window.confirm(
1203
1203
  `[p5.export] SVG export problem
1204
1204
 
@@ -1214,10 +1214,10 @@ Tips:
1214
1214
  ))
1215
1215
  return console.info("[p5.export] saveSVG cancelled by user"), null;
1216
1216
  }
1217
- if (a.raster || !f || u) {
1217
+ if (a.raster || !p || m) {
1218
1218
  const c = At(this);
1219
1219
  if (!c) throw new Error("[p5.export] saveSVG: no canvas found");
1220
- u ? console.warn(`[p5.export] saveSVG: ${v.toLocaleString()} vector ops — falling back to raster.`) : !f && !a.raster && console.info("[p5.export] saveSVG: WebGL renderer detected — embedding canvas as raster <image> in SVG."), o = Bs(c);
1220
+ m ? console.warn(`[p5.export] saveSVG: ${v.toLocaleString()} vector ops — falling back to raster.`) : !p && !a.raster && console.info("[p5.export] saveSVG: WebGL renderer detected — embedding canvas as raster <image> in SVG."), o = Fs(c);
1221
1221
  } else
1222
1222
  o = Hr(this, { outlineText: jr(this, a) });
1223
1223
  const d = new Blob([o], { type: "image/svg+xml" });
@@ -1253,15 +1253,15 @@ Tips:
1253
1253
  return a;
1254
1254
  });
1255
1255
  const n = e.text;
1256
- if (typeof n == "function" && (e.text = function(s, a, o, f, g) {
1257
- const v = this._p5ExportSVGRecorder, u = this._renderer;
1258
- if (!v || !u || !u.states) return n.apply(this, arguments);
1259
- const l = u.states, d = l.textFont && l.textFont.font, c = {
1256
+ if (typeof n == "function" && (e.text = function(s, a, o, p, w) {
1257
+ const v = this._p5ExportSVGRecorder, m = this._renderer;
1258
+ if (!v || !m || !m.states) return n.apply(this, arguments);
1259
+ const l = m.states, d = l.textFont && l.textFont.font, c = {
1260
1260
  str: s,
1261
1261
  x: a,
1262
1262
  y: o,
1263
- w: f,
1264
- h: g,
1263
+ w: p,
1264
+ h: w,
1265
1265
  font: d,
1266
1266
  // p5.Font (outlineable) or a string
1267
1267
  textSize: l.textSize,
@@ -1275,13 +1275,13 @@ Tips:
1275
1275
  stroke: null
1276
1276
  };
1277
1277
  v.ops.push([5, "textStart", c]);
1278
- let m;
1278
+ let u;
1279
1279
  try {
1280
- m = n.apply(this, arguments), c.fill = this.drawingContext.fillStyle, c.hasStroke && (c.stroke = this.drawingContext.strokeStyle);
1280
+ u = n.apply(this, arguments), c.fill = this.drawingContext.fillStyle, c.hasStroke && (c.stroke = this.drawingContext.strokeStyle);
1281
1281
  } finally {
1282
1282
  v.ops.push([5, "textEnd"]);
1283
1283
  }
1284
- return m;
1284
+ return u;
1285
1285
  }), i && typeof i == "object") {
1286
1286
  const s = i.presetup;
1287
1287
  i.presetup = function() {
@@ -1301,14 +1301,14 @@ Tips:
1301
1301
  };
1302
1302
  }
1303
1303
  }
1304
- function Ds(t) {
1304
+ function Us(t) {
1305
1305
  return new Promise((e, i) => {
1306
1306
  const r = new FileReader();
1307
1307
  r.onload = () => e(r.result), r.onerror = i, r.readAsDataURL(t);
1308
1308
  });
1309
1309
  }
1310
1310
  let Qe = null;
1311
- function Us() {
1311
+ function Ws() {
1312
1312
  return Qe || (Qe = (async () => {
1313
1313
  if (typeof window < "u") {
1314
1314
  if (window.jspdf && window.jspdf.jsPDF) return window.jspdf.jsPDF;
@@ -1324,24 +1324,24 @@ function Us() {
1324
1324
  );
1325
1325
  })(), Qe);
1326
1326
  }
1327
- function Ws(t, e) {
1327
+ function zs(t, e) {
1328
1328
  e.savePDF = async function(i, r = {}) {
1329
1329
  const n = At(this);
1330
1330
  if (!n) throw new Error("[p5.export] savePDF: no canvas found");
1331
- const s = await Us(), a = (r.imageFormat || "png").toUpperCase(), o = a === "JPEG" ? "image/jpeg" : a === "WEBP" ? "image/webp" : "image/png", f = n.width, g = n.height, v = a === "JPEG" ? "jpg" : a === "WEBP" ? "webp" : "png", u = r.scale;
1331
+ const s = await Ws(), a = (r.imageFormat || "png").toUpperCase(), o = a === "JPEG" ? "image/jpeg" : a === "WEBP" ? "image/webp" : "image/png", p = n.width, w = n.height, v = a === "JPEG" ? "jpg" : a === "WEBP" ? "webp" : "png", m = r.scale;
1332
1332
  let l;
1333
- if (!u || u <= 1 || u <= (this.pixelDensity ? this.pixelDensity() : 1))
1333
+ if (!m || m <= 1 || m <= (this.pixelDensity ? this.pixelDensity() : 1))
1334
1334
  l = n.toDataURL(o, r.quality);
1335
1335
  else {
1336
- const V = await rn(this, u, v, r.quality);
1337
- V ? l = await Ds(V) : l = await nn(this, u, () => At(this).toDataURL(o, r.quality));
1336
+ const V = await nn(this, m, v, r.quality);
1337
+ V ? l = await Us(V) : l = await sn(this, m, () => At(this).toDataURL(o, r.quality));
1338
1338
  }
1339
- const d = r.unit || "pt", c = r.orientation || (f >= g ? "l" : "p"), m = r.format || [f, g], w = new s({ orientation: c, unit: d, format: m }), y = w.internal.pageSize.getWidth(), M = w.internal.pageSize.getHeight(), S = Math.min(y / f, M / g), _ = f * S, E = g * S, D = (y - _) / 2, I = (M - E) / 2;
1340
- return w.addImage(l, a, D, I, _, E), w.save(i ? Et(i, "pdf") : Ct("pdf")), w;
1339
+ const d = r.unit || "pt", c = r.orientation || (p >= w ? "l" : "p"), u = r.format || [p, w], g = new s({ orientation: c, unit: d, format: u }), y = g.internal.pageSize.getWidth(), M = g.internal.pageSize.getHeight(), S = Math.min(y / p, M / w), _ = p * S, E = w * S, D = (y - _) / 2, I = (M - E) / 2;
1340
+ return g.addImage(l, a, D, I, _, E), g.save(i ? Et(i, "pdf") : Ct("pdf")), g;
1341
1341
  };
1342
1342
  }
1343
- var zs = { trailer: 59 };
1344
- function dn(t = 256) {
1343
+ var Os = { trailer: 59 };
1344
+ function cn(t = 256) {
1345
1345
  let e = 0, i = new Uint8Array(t);
1346
1346
  return { get buffer() {
1347
1347
  return i.buffer;
@@ -1368,191 +1368,191 @@ function dn(t = 256) {
1368
1368
  i = new Uint8Array(n), e > 0 && i.set(o.subarray(0, e), 0);
1369
1369
  }
1370
1370
  }
1371
- var Di = 12, qr = 5003, Os = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535];
1372
- function Vs(t, e, i, r, n = dn(512), s = new Uint8Array(256), a = new Int32Array(qr), o = new Int32Array(qr)) {
1373
- let f = a.length, g = Math.max(2, r);
1371
+ var Ui = 12, qr = 5003, Vs = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535];
1372
+ function Ls(t, e, i, r, n = cn(512), s = new Uint8Array(256), a = new Int32Array(qr), o = new Int32Array(qr)) {
1373
+ let p = a.length, w = Math.max(2, r);
1374
1374
  s.fill(0), o.fill(0), a.fill(-1);
1375
- let v = 0, u = 0, l = g + 1, d = l, c = !1, m = d, w = (1 << m) - 1, y = 1 << l - 1, M = y + 1, S = y + 2, _ = 0, E = i[0], D = 0;
1376
- for (let N = f; N < 65536; N *= 2) ++D;
1377
- D = 8 - D, n.writeByte(g), V(y);
1375
+ let v = 0, m = 0, l = w + 1, d = l, c = !1, u = d, g = (1 << u) - 1, y = 1 << l - 1, M = y + 1, S = y + 2, _ = 0, E = i[0], D = 0;
1376
+ for (let N = p; N < 65536; N *= 2) ++D;
1377
+ D = 8 - D, n.writeByte(w), V(y);
1378
1378
  let I = i.length;
1379
1379
  for (let N = 1; N < I; N++)
1380
1380
  t: {
1381
- let Y = i[N], q = (Y << Di) + E, H = Y << D ^ E;
1381
+ let Y = i[N], q = (Y << Ui) + E, H = Y << D ^ E;
1382
1382
  if (a[H] === q) {
1383
1383
  E = o[H];
1384
1384
  break t;
1385
1385
  }
1386
- let lt = H === 0 ? 1 : f - H;
1387
- for (; a[H] >= 0; ) if (H -= lt, H < 0 && (H += f), a[H] === q) {
1386
+ let lt = H === 0 ? 1 : p - H;
1387
+ for (; a[H] >= 0; ) if (H -= lt, H < 0 && (H += p), a[H] === q) {
1388
1388
  E = o[H];
1389
1389
  break t;
1390
1390
  }
1391
- V(E), E = Y, S < 1 << Di ? (o[H] = S++, a[H] = q) : (a.fill(-1), S = y + 2, c = !0, V(y));
1391
+ V(E), E = Y, S < 1 << Ui ? (o[H] = S++, a[H] = q) : (a.fill(-1), S = y + 2, c = !0, V(y));
1392
1392
  }
1393
1393
  return V(E), V(M), n.writeByte(0), n.bytesView();
1394
1394
  function V(N) {
1395
- for (v &= Os[u], u > 0 ? v |= N << u : v = N, u += m; u >= 8; ) s[_++] = v & 255, _ >= 254 && (n.writeByte(_), n.writeBytesView(s, 0, _), _ = 0), v >>= 8, u -= 8;
1396
- if ((S > w || c) && (c ? (m = d, w = (1 << m) - 1, c = !1) : (++m, w = m === Di ? 1 << m : (1 << m) - 1)), N == M) {
1397
- for (; u > 0; ) s[_++] = v & 255, _ >= 254 && (n.writeByte(_), n.writeBytesView(s, 0, _), _ = 0), v >>= 8, u -= 8;
1395
+ for (v &= Vs[m], m > 0 ? v |= N << m : v = N, m += u; m >= 8; ) s[_++] = v & 255, _ >= 254 && (n.writeByte(_), n.writeBytesView(s, 0, _), _ = 0), v >>= 8, m -= 8;
1396
+ if ((S > g || c) && (c ? (u = d, g = (1 << u) - 1, c = !1) : (++u, g = u === Ui ? 1 << u : (1 << u) - 1)), N == M) {
1397
+ for (; m > 0; ) s[_++] = v & 255, _ >= 254 && (n.writeByte(_), n.writeBytesView(s, 0, _), _ = 0), v >>= 8, m -= 8;
1398
1398
  _ > 0 && (n.writeByte(_), n.writeBytesView(s, 0, _), _ = 0);
1399
1399
  }
1400
1400
  }
1401
1401
  }
1402
- var Ls = Vs;
1403
- function cn(t, e, i) {
1402
+ var Gs = Ls;
1403
+ function pn(t, e, i) {
1404
1404
  return t << 8 & 63488 | e << 2 & 992 | i >> 3;
1405
1405
  }
1406
- function pn(t, e, i, r) {
1406
+ function fn(t, e, i, r) {
1407
1407
  return t >> 4 | e & 240 | (i & 240) << 4 | (r & 240) << 8;
1408
1408
  }
1409
- function fn(t, e, i) {
1409
+ function un(t, e, i) {
1410
1410
  return t >> 4 << 8 | e & 240 | i >> 4;
1411
1411
  }
1412
1412
  function ti(t, e, i) {
1413
1413
  return t < e ? e : t > i ? i : t;
1414
1414
  }
1415
- function ri(t) {
1415
+ function ni(t) {
1416
1416
  return t * t;
1417
1417
  }
1418
1418
  function Xr(t, e, i) {
1419
1419
  var r = 0, n = 1e100;
1420
1420
  let s = t[e], a = s.cnt;
1421
1421
  s.ac;
1422
- let o = s.rc, f = s.gc, g = s.bc;
1422
+ let o = s.rc, p = s.gc, w = s.bc;
1423
1423
  for (var v = s.fw; v != 0; v = t[v].fw) {
1424
1424
  let l = t[v], d = l.cnt, c = a * d / (a + d);
1425
1425
  if (!(c >= n)) {
1426
- var u = 0;
1427
- u += c * ri(l.rc - o), !(u >= n) && (u += c * ri(l.gc - f), !(u >= n) && (u += c * ri(l.bc - g), !(u >= n) && (n = u, r = v)));
1426
+ var m = 0;
1427
+ m += c * ni(l.rc - o), !(m >= n) && (m += c * ni(l.gc - p), !(m >= n) && (m += c * ni(l.bc - w), !(m >= n) && (n = m, r = v)));
1428
1428
  }
1429
1429
  }
1430
1430
  s.err = n, s.nn = r;
1431
1431
  }
1432
- function Ui() {
1432
+ function Wi() {
1433
1433
  return { ac: 0, rc: 0, gc: 0, bc: 0, cnt: 0, nn: 0, fw: 0, bk: 0, tm: 0, mtm: 0, err: 0 };
1434
1434
  }
1435
- function Gs(t, e) {
1435
+ function Ns(t, e) {
1436
1436
  let i = e === "rgb444" ? 4096 : 65536, r = new Array(i), n = t.length;
1437
1437
  if (e === "rgba4444") for (let s = 0; s < n; ++s) {
1438
- let a = t[s], o = a >> 24 & 255, f = a >> 16 & 255, g = a >> 8 & 255, v = a & 255, u = pn(v, g, f, o), l = u in r ? r[u] : r[u] = Ui();
1439
- l.rc += v, l.gc += g, l.bc += f, l.ac += o, l.cnt++;
1438
+ let a = t[s], o = a >> 24 & 255, p = a >> 16 & 255, w = a >> 8 & 255, v = a & 255, m = fn(v, w, p, o), l = m in r ? r[m] : r[m] = Wi();
1439
+ l.rc += v, l.gc += w, l.bc += p, l.ac += o, l.cnt++;
1440
1440
  }
1441
1441
  else if (e === "rgb444") for (let s = 0; s < n; ++s) {
1442
- let a = t[s], o = a >> 16 & 255, f = a >> 8 & 255, g = a & 255, v = fn(g, f, o), u = v in r ? r[v] : r[v] = Ui();
1443
- u.rc += g, u.gc += f, u.bc += o, u.cnt++;
1442
+ let a = t[s], o = a >> 16 & 255, p = a >> 8 & 255, w = a & 255, v = un(w, p, o), m = v in r ? r[v] : r[v] = Wi();
1443
+ m.rc += w, m.gc += p, m.bc += o, m.cnt++;
1444
1444
  }
1445
1445
  else for (let s = 0; s < n; ++s) {
1446
- let a = t[s], o = a >> 16 & 255, f = a >> 8 & 255, g = a & 255, v = cn(g, f, o), u = v in r ? r[v] : r[v] = Ui();
1447
- u.rc += g, u.gc += f, u.bc += o, u.cnt++;
1446
+ let a = t[s], o = a >> 16 & 255, p = a >> 8 & 255, w = a & 255, v = pn(w, p, o), m = v in r ? r[v] : r[v] = Wi();
1447
+ m.rc += w, m.gc += p, m.bc += o, m.cnt++;
1448
1448
  }
1449
1449
  return r;
1450
1450
  }
1451
- function un(t, e, i = {}) {
1451
+ function mn(t, e, i = {}) {
1452
1452
  let { format: r = "rgb565", clearAlpha: n = !0, clearAlphaColor: s = 0, clearAlphaThreshold: a = 0, oneBitAlpha: o = !1 } = i;
1453
1453
  if (!t || !t.buffer) throw new Error("quantize() expected RGBA Uint8Array data");
1454
1454
  if (!(t instanceof Uint8Array) && !(t instanceof Uint8ClampedArray)) throw new Error("quantize() expected RGBA Uint8Array data");
1455
- let f = new Uint32Array(t.buffer), g = i.useSqrt !== !1, v = r === "rgba4444", u = Gs(f, r), l = u.length, d = l - 1, c = new Uint32Array(l + 1);
1456
- for (var m = 0, w = 0; w < l; ++w) {
1457
- let J = u[w];
1455
+ let p = new Uint32Array(t.buffer), w = i.useSqrt !== !1, v = r === "rgba4444", m = Ns(p, r), l = m.length, d = l - 1, c = new Uint32Array(l + 1);
1456
+ for (var u = 0, g = 0; g < l; ++g) {
1457
+ let J = m[g];
1458
1458
  if (J != null) {
1459
1459
  var y = 1 / J.cnt;
1460
- v && (J.ac *= y), J.rc *= y, J.gc *= y, J.bc *= y, u[m++] = J;
1460
+ v && (J.ac *= y), J.rc *= y, J.gc *= y, J.bc *= y, m[u++] = J;
1461
1461
  }
1462
1462
  }
1463
- ri(e) / m < 0.022 && (g = !1);
1464
- for (var w = 0; w < m - 1; ++w) u[w].fw = w + 1, u[w + 1].bk = w, g && (u[w].cnt = Math.sqrt(u[w].cnt));
1465
- g && (u[w].cnt = Math.sqrt(u[w].cnt));
1463
+ ni(e) / u < 0.022 && (w = !1);
1464
+ for (var g = 0; g < u - 1; ++g) m[g].fw = g + 1, m[g + 1].bk = g, w && (m[g].cnt = Math.sqrt(m[g].cnt));
1465
+ w && (m[g].cnt = Math.sqrt(m[g].cnt));
1466
1466
  var M, S, _;
1467
- for (w = 0; w < m; ++w) {
1468
- Xr(u, w);
1469
- var E = u[w].err;
1470
- for (S = ++c[0]; S > 1 && (_ = S >> 1, !(u[M = c[_]].err <= E)); S = _) c[S] = M;
1471
- c[S] = w;
1472
- }
1473
- var D = m - e;
1474
- for (w = 0; w < D; ) {
1467
+ for (g = 0; g < u; ++g) {
1468
+ Xr(m, g);
1469
+ var E = m[g].err;
1470
+ for (S = ++c[0]; S > 1 && (_ = S >> 1, !(m[M = c[_]].err <= E)); S = _) c[S] = M;
1471
+ c[S] = g;
1472
+ }
1473
+ var D = u - e;
1474
+ for (g = 0; g < D; ) {
1475
1475
  for (var I; ; ) {
1476
1476
  var V = c[1];
1477
- if (I = u[V], I.tm >= I.mtm && u[I.nn].mtm <= I.tm) break;
1478
- I.mtm == d ? V = c[1] = c[c[0]--] : (Xr(u, V), I.tm = w);
1479
- var E = u[V].err;
1480
- for (S = 1; (_ = S + S) <= c[0] && (_ < c[0] && u[c[_]].err > u[c[_ + 1]].err && _++, !(E <= u[M = c[_]].err)); S = _) c[S] = M;
1477
+ if (I = m[V], I.tm >= I.mtm && m[I.nn].mtm <= I.tm) break;
1478
+ I.mtm == d ? V = c[1] = c[c[0]--] : (Xr(m, V), I.tm = g);
1479
+ var E = m[V].err;
1480
+ for (S = 1; (_ = S + S) <= c[0] && (_ < c[0] && m[c[_]].err > m[c[_ + 1]].err && _++, !(E <= m[M = c[_]].err)); S = _) c[S] = M;
1481
1481
  c[S] = V;
1482
1482
  }
1483
- var N = u[I.nn], Y = I.cnt, q = N.cnt, y = 1 / (Y + q);
1484
- v && (I.ac = y * (Y * I.ac + q * N.ac)), I.rc = y * (Y * I.rc + q * N.rc), I.gc = y * (Y * I.gc + q * N.gc), I.bc = y * (Y * I.bc + q * N.bc), I.cnt += N.cnt, I.mtm = ++w, u[N.bk].fw = N.fw, u[N.fw].bk = N.bk, N.mtm = d;
1483
+ var N = m[I.nn], Y = I.cnt, q = N.cnt, y = 1 / (Y + q);
1484
+ v && (I.ac = y * (Y * I.ac + q * N.ac)), I.rc = y * (Y * I.rc + q * N.rc), I.gc = y * (Y * I.gc + q * N.gc), I.bc = y * (Y * I.bc + q * N.bc), I.cnt += N.cnt, I.mtm = ++g, m[N.bk].fw = N.fw, m[N.fw].bk = N.bk, N.mtm = d;
1485
1485
  }
1486
1486
  let H = [];
1487
1487
  var lt = 0;
1488
- for (w = 0; ; ++lt) {
1489
- let J = ti(Math.round(u[w].rc), 0, 255), Wt = ti(Math.round(u[w].gc), 0, 255), ht = ti(Math.round(u[w].bc), 0, 255), rt = 255;
1490
- v && (rt = ti(Math.round(u[w].ac), 0, 255), o && (rt = rt <= (typeof o == "number" ? o : 127) ? 0 : 255), n && rt <= a && (J = Wt = ht = s, rt = 0));
1488
+ for (g = 0; ; ++lt) {
1489
+ let J = ti(Math.round(m[g].rc), 0, 255), Wt = ti(Math.round(m[g].gc), 0, 255), ht = ti(Math.round(m[g].bc), 0, 255), rt = 255;
1490
+ v && (rt = ti(Math.round(m[g].ac), 0, 255), o && (rt = rt <= (typeof o == "number" ? o : 127) ? 0 : 255), n && rt <= a && (J = Wt = ht = s, rt = 0));
1491
1491
  let G = v ? [J, Wt, ht, rt] : [J, Wt, ht];
1492
- if (Ns(H, G) || H.push(G), (w = u[w].fw) == 0) break;
1492
+ if ($s(H, G) || H.push(G), (g = m[g].fw) == 0) break;
1493
1493
  }
1494
1494
  return H;
1495
1495
  }
1496
- function Ns(t, e) {
1496
+ function $s(t, e) {
1497
1497
  for (let i = 0; i < t.length; i++) {
1498
1498
  let r = t[i], n = r[0] === e[0] && r[1] === e[1] && r[2] === e[2], s = r.length >= 4 && e.length >= 4 ? r[3] === e[3] : !0;
1499
1499
  if (n && s) return !0;
1500
1500
  }
1501
1501
  return !1;
1502
1502
  }
1503
- function mn(t, e, i = "rgb565") {
1503
+ function gn(t, e, i = "rgb565") {
1504
1504
  if (!t || !t.buffer) throw new Error("quantize() expected RGBA Uint8Array data");
1505
1505
  if (!(t instanceof Uint8Array) && !(t instanceof Uint8ClampedArray)) throw new Error("quantize() expected RGBA Uint8Array data");
1506
1506
  if (e.length > 256) throw new Error("applyPalette() only works with 256 colors or less");
1507
1507
  let r = new Uint32Array(t.buffer), n = r.length, s = i === "rgb444" ? 4096 : 65536, a = new Uint8Array(n), o = new Array(s);
1508
- if (i === "rgba4444") for (let f = 0; f < n; f++) {
1509
- let g = r[f], v = g >> 24 & 255, u = g >> 16 & 255, l = g >> 8 & 255, d = g & 255, c = pn(d, l, u, v), m = c in o ? o[c] : o[c] = $s(d, l, u, v, e);
1510
- a[f] = m;
1508
+ if (i === "rgba4444") for (let p = 0; p < n; p++) {
1509
+ let w = r[p], v = w >> 24 & 255, m = w >> 16 & 255, l = w >> 8 & 255, d = w & 255, c = fn(d, l, m, v), u = c in o ? o[c] : o[c] = js(d, l, m, v, e);
1510
+ a[p] = u;
1511
1511
  }
1512
1512
  else {
1513
- let f = i === "rgb444" ? fn : cn;
1514
- for (let g = 0; g < n; g++) {
1515
- let v = r[g], u = v >> 16 & 255, l = v >> 8 & 255, d = v & 255, c = f(d, l, u), m = c in o ? o[c] : o[c] = js(d, l, u, e);
1516
- a[g] = m;
1513
+ let p = i === "rgb444" ? un : pn;
1514
+ for (let w = 0; w < n; w++) {
1515
+ let v = r[w], m = v >> 16 & 255, l = v >> 8 & 255, d = v & 255, c = p(d, l, m), u = c in o ? o[c] : o[c] = Hs(d, l, m, e);
1516
+ a[w] = u;
1517
1517
  }
1518
1518
  }
1519
1519
  return a;
1520
1520
  }
1521
- function $s(t, e, i, r, n) {
1521
+ function js(t, e, i, r, n) {
1522
1522
  let s = 0, a = 1e100;
1523
1523
  for (let o = 0; o < n.length; o++) {
1524
- let f = n[o], g = f[3], v = Xt(g - r);
1524
+ let p = n[o], w = p[3], v = Xt(w - r);
1525
1525
  if (v > a) continue;
1526
- let u = f[0];
1527
- if (v += Xt(u - t), v > a) continue;
1528
- let l = f[1];
1526
+ let m = p[0];
1527
+ if (v += Xt(m - t), v > a) continue;
1528
+ let l = p[1];
1529
1529
  if (v += Xt(l - e), v > a) continue;
1530
- let d = f[2];
1530
+ let d = p[2];
1531
1531
  v += Xt(d - i), !(v > a) && (a = v, s = o);
1532
1532
  }
1533
1533
  return s;
1534
1534
  }
1535
- function js(t, e, i, r) {
1535
+ function Hs(t, e, i, r) {
1536
1536
  let n = 0, s = 1e100;
1537
1537
  for (let a = 0; a < r.length; a++) {
1538
- let o = r[a], f = o[0], g = Xt(f - t);
1539
- if (g > s) continue;
1538
+ let o = r[a], p = o[0], w = Xt(p - t);
1539
+ if (w > s) continue;
1540
1540
  let v = o[1];
1541
- if (g += Xt(v - e), g > s) continue;
1542
- let u = o[2];
1543
- g += Xt(u - i), !(g > s) && (s = g, n = a);
1541
+ if (w += Xt(v - e), w > s) continue;
1542
+ let m = o[2];
1543
+ w += Xt(m - i), !(w > s) && (s = w, n = a);
1544
1544
  }
1545
1545
  return n;
1546
1546
  }
1547
1547
  function Xt(t) {
1548
1548
  return t * t;
1549
1549
  }
1550
- function gn(t = {}) {
1551
- let { initialCapacity: e = 4096, auto: i = !0 } = t, r = dn(e), n = 5003, s = new Uint8Array(256), a = new Int32Array(n), o = new Int32Array(n), f = !1;
1550
+ function wn(t = {}) {
1551
+ let { initialCapacity: e = 4096, auto: i = !0 } = t, r = cn(e), n = 5003, s = new Uint8Array(256), a = new Int32Array(n), o = new Int32Array(n), p = !1;
1552
1552
  return { reset() {
1553
- r.reset(), f = !1;
1553
+ r.reset(), p = !1;
1554
1554
  }, finish() {
1555
- r.writeByte(zs.trailer);
1555
+ r.writeByte(Os.trailer);
1556
1556
  }, bytes() {
1557
1557
  return r.bytes();
1558
1558
  }, bytesView() {
@@ -1561,32 +1561,32 @@ function gn(t = {}) {
1561
1561
  return r.buffer;
1562
1562
  }, get stream() {
1563
1563
  return r;
1564
- }, writeHeader: g, writeFrame(v, u, l, d = {}) {
1565
- let { transparent: c = !1, transparentIndex: m = 0, delay: w = 0, palette: y = null, repeat: M = 0, colorDepth: S = 8, dispose: _ = -1 } = d, E = !1;
1566
- if (i ? f || (E = !0, g(), f = !0) : E = !!d.first, u = Math.max(0, Math.floor(u)), l = Math.max(0, Math.floor(l)), E) {
1564
+ }, writeHeader: w, writeFrame(v, m, l, d = {}) {
1565
+ let { transparent: c = !1, transparentIndex: u = 0, delay: g = 0, palette: y = null, repeat: M = 0, colorDepth: S = 8, dispose: _ = -1 } = d, E = !1;
1566
+ if (i ? p || (E = !0, w(), p = !0) : E = !!d.first, m = Math.max(0, Math.floor(m)), l = Math.max(0, Math.floor(l)), E) {
1567
1567
  if (!y) throw new Error("First frame must include a { palette } option");
1568
- qs(r, u, l, y, S), Yr(r, y), M >= 0 && Xs(r, M);
1568
+ Xs(r, m, l, y, S), Yr(r, y), M >= 0 && Ys(r, M);
1569
1569
  }
1570
- let D = Math.round(w / 10);
1571
- Hs(r, _, D, c, m);
1570
+ let D = Math.round(g / 10);
1571
+ qs(r, _, D, c, u);
1572
1572
  let I = !!y && !E;
1573
- Ys(r, u, l, I ? y : null), I && Yr(r, y), Js(r, v, u, l, S, s, a, o);
1573
+ Js(r, m, l, I ? y : null), I && Yr(r, y), Ks(r, v, m, l, S, s, a, o);
1574
1574
  } };
1575
- function g() {
1576
- wn(r, "GIF89a");
1575
+ function w() {
1576
+ vn(r, "GIF89a");
1577
1577
  }
1578
1578
  }
1579
- function Hs(t, e, i, r, n) {
1579
+ function qs(t, e, i, r, n) {
1580
1580
  t.writeByte(33), t.writeByte(249), t.writeByte(4), n < 0 && (n = 0, r = !1);
1581
1581
  var s, a;
1582
1582
  r ? (s = 1, a = 2) : (s = 0, a = 0), e >= 0 && (a = e & 7), a <<= 2, t.writeByte(0 | a | 0 | s), Ft(t, i), t.writeByte(n || 0), t.writeByte(0);
1583
1583
  }
1584
- function qs(t, e, i, r, n = 8) {
1585
- let s = 1, a = 0, o = dr(r.length) - 1, f = s << 7 | n - 1 << 4 | a << 3 | o;
1586
- Ft(t, e), Ft(t, i), t.writeBytes([f, 0, 0]);
1584
+ function Xs(t, e, i, r, n = 8) {
1585
+ let s = 1, a = 0, o = dr(r.length) - 1, p = s << 7 | n - 1 << 4 | a << 3 | o;
1586
+ Ft(t, e), Ft(t, i), t.writeBytes([p, 0, 0]);
1587
1587
  }
1588
- function Xs(t, e) {
1589
- t.writeByte(33), t.writeByte(255), t.writeByte(11), wn(t, "NETSCAPE2.0"), t.writeByte(3), t.writeByte(1), Ft(t, e), t.writeByte(0);
1588
+ function Ys(t, e) {
1589
+ t.writeByte(33), t.writeByte(255), t.writeByte(11), vn(t, "NETSCAPE2.0"), t.writeByte(3), t.writeByte(1), Ft(t, e), t.writeByte(0);
1590
1590
  }
1591
1591
  function Yr(t, e) {
1592
1592
  let i = 1 << dr(e.length);
@@ -1595,25 +1595,25 @@ function Yr(t, e) {
1595
1595
  r < e.length && (n = e[r]), t.writeByte(n[0]), t.writeByte(n[1]), t.writeByte(n[2]);
1596
1596
  }
1597
1597
  }
1598
- function Ys(t, e, i, r) {
1598
+ function Js(t, e, i, r) {
1599
1599
  if (t.writeByte(44), Ft(t, 0), Ft(t, 0), Ft(t, e), Ft(t, i), r) {
1600
1600
  let n = 0, s = 0, a = dr(r.length) - 1;
1601
1601
  t.writeByte(128 | n | s | 0 | a);
1602
1602
  } else t.writeByte(0);
1603
1603
  }
1604
- function Js(t, e, i, r, n = 8, s, a, o) {
1605
- Ls(i, r, e, n, t, s, a, o);
1604
+ function Ks(t, e, i, r, n = 8, s, a, o) {
1605
+ Gs(i, r, e, n, t, s, a, o);
1606
1606
  }
1607
1607
  function Ft(t, e) {
1608
1608
  t.writeByte(e & 255), t.writeByte(e >> 8 & 255);
1609
1609
  }
1610
- function wn(t, e) {
1610
+ function vn(t, e) {
1611
1611
  for (var i = 0; i < e.length; i++) t.writeByte(e.charCodeAt(i));
1612
1612
  }
1613
1613
  function dr(t) {
1614
1614
  return Math.max(Math.ceil(Math.log2(t)), 1);
1615
1615
  }
1616
- class Ks {
1616
+ class Zs {
1617
1617
  /**
1618
1618
  * @param {object} opts
1619
1619
  * @param {HTMLCanvasElement} opts.canvas
@@ -1661,21 +1661,21 @@ class Ks {
1661
1661
  return this.active = !1, this._encode();
1662
1662
  }
1663
1663
  async _encode() {
1664
- const e = gn(), i = Math.round(1e3 / this.fps), r = this.frames.length;
1664
+ const e = wn(), i = Math.round(1e3 / this.fps), r = this.frames.length;
1665
1665
  for (let n = 0; n < r; n++) {
1666
- const s = this.frames[n], a = un(s.data, this.maxColors), o = mn(s.data, a);
1667
- e.writeFrame(o, s.width, s.height, { palette: a, delay: i }), this.onProgress((n + 1) / r), n % 4 === 3 && await new Promise((f) => setTimeout(f, 0));
1666
+ const s = this.frames[n], a = mn(s.data, this.maxColors), o = gn(s.data, a);
1667
+ e.writeFrame(o, s.width, s.height, { palette: a, delay: i }), this.onProgress((n + 1) / r), n % 4 === 3 && await new Promise((p) => setTimeout(p, 0));
1668
1668
  }
1669
1669
  return e.finish(), new Blob([e.bytes()], { type: "image/gif" });
1670
1670
  }
1671
1671
  }
1672
- function Zs(t, e, i) {
1672
+ function Qs(t, e, i) {
1673
1673
  if (e.recordGIF = function(r = {}) {
1674
1674
  const n = At(this);
1675
1675
  if (!n) throw new Error("[p5.export] recordGIF: no canvas found");
1676
1676
  if (this._p5ExportGIF && this._p5ExportGIF.active)
1677
1677
  throw new Error("[p5.export] a GIF recording is already in progress");
1678
- const s = new Ks({ canvas: n, ...r });
1678
+ const s = new Zs({ canvas: n, ...r });
1679
1679
  return s.start(), this._p5ExportGIF = s, s;
1680
1680
  }, e.stopGIF = function() {
1681
1681
  const r = this._p5ExportGIF;
@@ -1687,7 +1687,7 @@ function Zs(t, e, i) {
1687
1687
  };
1688
1688
  }
1689
1689
  }
1690
- class Qs {
1690
+ class ta {
1691
1691
  /**
1692
1692
  * @param {object} opts
1693
1693
  * @param {HTMLCanvasElement} opts.canvas
@@ -1742,21 +1742,21 @@ class Qs {
1742
1742
  var cr = (t, e, i) => {
1743
1743
  if (!e.has(t))
1744
1744
  throw TypeError("Cannot " + i);
1745
- }, p = (t, e, i) => (cr(t, e, "read from private field"), i ? i.call(t) : e.get(t)), W = (t, e, i) => {
1745
+ }, f = (t, e, i) => (cr(t, e, "read from private field"), i ? i.call(t) : e.get(t)), W = (t, e, i) => {
1746
1746
  if (e.has(t))
1747
1747
  throw TypeError("Cannot add the same private member more than once");
1748
1748
  e instanceof WeakSet ? e.add(t) : e.set(t, i);
1749
- }, et = (t, e, i, r) => (cr(t, e, "write to private field"), e.set(t, i), i), ta = (t, e, i, r) => ({
1749
+ }, et = (t, e, i, r) => (cr(t, e, "write to private field"), e.set(t, i), i), ea = (t, e, i, r) => ({
1750
1750
  set _(n) {
1751
1751
  et(t, e, n);
1752
1752
  },
1753
1753
  get _() {
1754
- return p(t, e, r);
1754
+ return f(t, e, r);
1755
1755
  }
1756
- }), O = (t, e, i) => (cr(t, e, "access private method"), i), L = new Uint8Array(8), vt = new DataView(L.buffer), Z = (t) => [(t % 256 + 256) % 256], j = (t) => (vt.setUint16(0, t, !1), [L[0], L[1]]), ea = (t) => (vt.setInt16(0, t, !1), [L[0], L[1]]), vn = (t) => (vt.setUint32(0, t, !1), [L[1], L[2], L[3]]), C = (t) => (vt.setUint32(0, t, !1), [L[0], L[1], L[2], L[3]]), ia = (t) => (vt.setInt32(0, t, !1), [L[0], L[1], L[2], L[3]]), Zt = (t) => (vt.setUint32(0, Math.floor(t / 2 ** 32), !1), vt.setUint32(4, t, !1), [L[0], L[1], L[2], L[3], L[4], L[5], L[6], L[7]]), pr = (t) => (vt.setInt16(0, 2 ** 8 * t, !1), [L[0], L[1]]), mt = (t) => (vt.setInt32(0, 2 ** 16 * t, !1), [L[0], L[1], L[2], L[3]]), Wi = (t) => (vt.setInt32(0, 2 ** 30 * t, !1), [L[0], L[1], L[2], L[3]]), ot = (t, e = !1) => {
1756
+ }), O = (t, e, i) => (cr(t, e, "access private method"), i), L = new Uint8Array(8), vt = new DataView(L.buffer), Z = (t) => [(t % 256 + 256) % 256], j = (t) => (vt.setUint16(0, t, !1), [L[0], L[1]]), ia = (t) => (vt.setInt16(0, t, !1), [L[0], L[1]]), yn = (t) => (vt.setUint32(0, t, !1), [L[1], L[2], L[3]]), C = (t) => (vt.setUint32(0, t, !1), [L[0], L[1], L[2], L[3]]), ra = (t) => (vt.setInt32(0, t, !1), [L[0], L[1], L[2], L[3]]), Zt = (t) => (vt.setUint32(0, Math.floor(t / 2 ** 32), !1), vt.setUint32(4, t, !1), [L[0], L[1], L[2], L[3], L[4], L[5], L[6], L[7]]), pr = (t) => (vt.setInt16(0, 2 ** 8 * t, !1), [L[0], L[1]]), mt = (t) => (vt.setInt32(0, 2 ** 16 * t, !1), [L[0], L[1], L[2], L[3]]), zi = (t) => (vt.setInt32(0, 2 ** 30 * t, !1), [L[0], L[1], L[2], L[3]]), ot = (t, e = !1) => {
1757
1757
  let i = Array(t.length).fill(null).map((r, n) => t.charCodeAt(n));
1758
1758
  return e && i.push(0), i;
1759
- }, gi = (t) => t && t[t.length - 1], fr = (t) => {
1759
+ }, wi = (t) => t && t[t.length - 1], fr = (t) => {
1760
1760
  let e;
1761
1761
  for (let i of t)
1762
1762
  (!e || i.presentationTimestamp > e.presentationTimestamp) && (e = i);
@@ -1764,7 +1764,7 @@ var cr = (t, e, i) => {
1764
1764
  }, wt = (t, e, i = !0) => {
1765
1765
  let r = t * e;
1766
1766
  return i ? Math.round(r) : r;
1767
- }, yn = (t) => {
1767
+ }, bn = (t) => {
1768
1768
  let e = t * (Math.PI / 180), i = Math.cos(e), r = Math.sin(e);
1769
1769
  return [
1770
1770
  i,
@@ -1777,25 +1777,25 @@ var cr = (t, e, i) => {
1777
1777
  0,
1778
1778
  1
1779
1779
  ];
1780
- }, bn = yn(0), _n = (t) => [
1780
+ }, _n = bn(0), xn = (t) => [
1781
1781
  mt(t[0]),
1782
1782
  mt(t[1]),
1783
- Wi(t[2]),
1783
+ zi(t[2]),
1784
1784
  mt(t[3]),
1785
1785
  mt(t[4]),
1786
- Wi(t[5]),
1786
+ zi(t[5]),
1787
1787
  mt(t[6]),
1788
1788
  mt(t[7]),
1789
- Wi(t[8])
1789
+ zi(t[8])
1790
1790
  ], Me = (t) => !t || typeof t != "object" ? t : Array.isArray(t) ? t.map(Me) : Object.fromEntries(Object.entries(t).map(([e, i]) => [e, Me(i)])), me = (t) => t >= 0 && t < 2 ** 32, K = (t, e, i) => ({
1791
1791
  type: t,
1792
1792
  contents: e && new Uint8Array(e.flat(10)),
1793
1793
  children: i
1794
1794
  }), X = (t, e, i, r, n) => K(
1795
1795
  t,
1796
- [Z(e), vn(i), r ?? []],
1796
+ [Z(e), yn(i), r ?? []],
1797
1797
  n
1798
- ), ra = (t) => {
1798
+ ), na = (t) => {
1799
1799
  let e = 512;
1800
1800
  return t.fragmented ? K("ftyp", [
1801
1801
  ot("iso5"),
@@ -1816,11 +1816,11 @@ var cr = (t, e, i) => {
1816
1816
  t.holdsAvc ? ot("avc1") : [],
1817
1817
  ot("mp41")
1818
1818
  ]);
1819
- }, Gi = (t) => ({ type: "mdat", largeSize: t }), na = (t) => ({ type: "free", size: t }), ni = (t, e, i = !1) => K("moov", null, [
1820
- sa(e, t),
1821
- ...t.map((r) => aa(r, e)),
1822
- i ? Wa(t) : null
1823
- ]), sa = (t, e) => {
1819
+ }, Gi = (t) => ({ type: "mdat", largeSize: t }), sa = (t) => ({ type: "free", size: t }), si = (t, e, i = !1) => K("moov", null, [
1820
+ aa(e, t),
1821
+ ...t.map((r) => oa(r, e)),
1822
+ i ? za(t) : null
1823
+ ]), aa = (t, e) => {
1824
1824
  let i = wt(Math.max(
1825
1825
  0,
1826
1826
  ...e.filter((a) => a.samples.length > 0).map((a) => {
@@ -1843,22 +1843,22 @@ var cr = (t, e, i) => {
1843
1843
  // Preferred volume
1844
1844
  Array(10).fill(0),
1845
1845
  // Reserved
1846
- _n(bn),
1846
+ xn(_n),
1847
1847
  // Matrix
1848
1848
  Array(24).fill(0),
1849
1849
  // Pre-defined
1850
1850
  C(r)
1851
1851
  // Next track ID
1852
1852
  ]);
1853
- }, aa = (t, e) => K("trak", null, [
1854
- oa(t, e),
1855
- la(t, e)
1856
- ]), oa = (t, e) => {
1853
+ }, oa = (t, e) => K("trak", null, [
1854
+ la(t, e),
1855
+ ha(t, e)
1856
+ ]), la = (t, e) => {
1857
1857
  let i = fr(t.samples), r = wt(
1858
1858
  i ? i.presentationTimestamp + i.duration : 0,
1859
1859
  ji
1860
1860
  ), n = !me(e) || !me(r), s = n ? Zt : C, a;
1861
- return t.info.type === "video" ? a = typeof t.info.rotation == "number" ? yn(t.info.rotation) : t.info.rotation : a = bn, X("tkhd", +n, 3, [
1861
+ return t.info.type === "video" ? a = typeof t.info.rotation == "number" ? bn(t.info.rotation) : t.info.rotation : a = _n, X("tkhd", +n, 3, [
1862
1862
  s(e),
1863
1863
  // Creation time
1864
1864
  s(e),
@@ -1879,18 +1879,18 @@ var cr = (t, e, i) => {
1879
1879
  // Volume
1880
1880
  j(0),
1881
1881
  // Reserved
1882
- _n(a),
1882
+ xn(a),
1883
1883
  // Matrix
1884
1884
  mt(t.info.type === "video" ? t.info.width : 0),
1885
1885
  // Track width
1886
1886
  mt(t.info.type === "video" ? t.info.height : 0)
1887
1887
  // Track height
1888
1888
  ]);
1889
- }, la = (t, e) => K("mdia", null, [
1890
- ha(t, e),
1891
- da(t.info.type === "video" ? "vide" : "soun"),
1892
- ca(t)
1893
- ]), ha = (t, e) => {
1889
+ }, ha = (t, e) => K("mdia", null, [
1890
+ da(t, e),
1891
+ ca(t.info.type === "video" ? "vide" : "soun"),
1892
+ pa(t)
1893
+ ]), da = (t, e) => {
1894
1894
  let i = fr(t.samples), r = wt(
1895
1895
  i ? i.presentationTimestamp + i.duration : 0,
1896
1896
  t.timescale
@@ -1909,7 +1909,7 @@ var cr = (t, e, i) => {
1909
1909
  j(0)
1910
1910
  // Quality
1911
1911
  ]);
1912
- }, da = (t) => X("hdlr", 0, 0, [
1912
+ }, ca = (t) => X("hdlr", 0, 0, [
1913
1913
  ot("mhlr"),
1914
1914
  // Component type
1915
1915
  ot(t),
@@ -1922,11 +1922,11 @@ var cr = (t, e, i) => {
1922
1922
  // Component flags mask
1923
1923
  ot("mp4-muxer-hdlr", !0)
1924
1924
  // Component name
1925
- ]), ca = (t) => K("minf", null, [
1926
- t.info.type === "video" ? pa() : fa(),
1927
- ua(),
1928
- wa(t)
1929
- ]), pa = () => X("vmhd", 0, 1, [
1925
+ ]), pa = (t) => K("minf", null, [
1926
+ t.info.type === "video" ? fa() : ua(),
1927
+ ma(),
1928
+ va(t)
1929
+ ]), fa = () => X("vmhd", 0, 1, [
1930
1930
  j(0),
1931
1931
  // Graphics mode
1932
1932
  j(0),
@@ -1935,41 +1935,41 @@ var cr = (t, e, i) => {
1935
1935
  // Opcolor G
1936
1936
  j(0)
1937
1937
  // Opcolor B
1938
- ]), fa = () => X("smhd", 0, 0, [
1938
+ ]), ua = () => X("smhd", 0, 0, [
1939
1939
  j(0),
1940
1940
  // Balance
1941
1941
  j(0)
1942
1942
  // Reserved
1943
- ]), ua = () => K("dinf", null, [
1944
- ma()
1945
- ]), ma = () => X("dref", 0, 0, [
1943
+ ]), ma = () => K("dinf", null, [
1944
+ ga()
1945
+ ]), ga = () => X("dref", 0, 0, [
1946
1946
  C(1)
1947
1947
  // Entry count
1948
1948
  ], [
1949
- ga()
1950
- ]), ga = () => X("url ", 0, 1), wa = (t) => {
1949
+ wa()
1950
+ ]), wa = () => X("url ", 0, 1), va = (t) => {
1951
1951
  const e = t.compositionTimeOffsetTable.length > 1 || t.compositionTimeOffsetTable.some((i) => i.sampleCompositionTimeOffset !== 0);
1952
1952
  return K("stbl", null, [
1953
- va(t),
1954
- Ia(t),
1953
+ ya(t),
1955
1954
  Ra(t),
1956
1955
  Ba(t),
1957
1956
  Fa(t),
1958
1957
  Da(t),
1959
- e ? Ua(t) : null
1958
+ Ua(t),
1959
+ e ? Wa(t) : null
1960
1960
  ]);
1961
- }, va = (t) => X("stsd", 0, 0, [
1961
+ }, ya = (t) => X("stsd", 0, 0, [
1962
1962
  C(1)
1963
1963
  // Entry count
1964
1964
  ], [
1965
- t.info.type === "video" ? ya(
1966
- qa[t.info.codec],
1965
+ t.info.type === "video" ? ba(
1966
+ Xa[t.info.codec],
1967
1967
  t
1968
- ) : Aa(
1969
- Ya[t.info.codec],
1968
+ ) : Ma(
1969
+ Ja[t.info.codec],
1970
1970
  t
1971
1971
  )
1972
- ]), ya = (t, e) => K(t, [
1972
+ ]), ba = (t, e) => K(t, [
1973
1973
  Array(6).fill(0),
1974
1974
  // Reserved
1975
1975
  j(1),
@@ -1996,26 +1996,26 @@ var cr = (t, e, i) => {
1996
1996
  // Compressor name
1997
1997
  j(24),
1998
1998
  // Depth
1999
- ea(65535)
1999
+ ia(65535)
2000
2000
  // Pre-defined
2001
2001
  ], [
2002
- Xa[e.info.codec](e),
2003
- e.info.decoderConfig.colorSpace ? Sa(e) : null
2004
- ]), ba = {
2002
+ Ya[e.info.codec](e),
2003
+ e.info.decoderConfig.colorSpace ? Ca(e) : null
2004
+ ]), _a = {
2005
2005
  bt709: 1,
2006
2006
  // ITU-R BT.709
2007
2007
  bt470bg: 5,
2008
2008
  // ITU-R BT.470BG
2009
2009
  smpte170m: 6
2010
2010
  // ITU-R BT.601 525 - SMPTE 170M
2011
- }, _a = {
2011
+ }, xa = {
2012
2012
  bt709: 1,
2013
2013
  // ITU-R BT.709
2014
2014
  smpte170m: 6,
2015
2015
  // SMPTE 170M
2016
2016
  "iec61966-2-1": 13
2017
2017
  // IEC 61966-2-1
2018
- }, xa = {
2018
+ }, Sa = {
2019
2019
  rgb: 0,
2020
2020
  // Identity
2021
2021
  bt709: 1,
@@ -2024,24 +2024,24 @@ var cr = (t, e, i) => {
2024
2024
  // ITU-R BT.470BG
2025
2025
  smpte170m: 6
2026
2026
  // SMPTE 170M
2027
- }, Sa = (t) => K("colr", [
2027
+ }, Ca = (t) => K("colr", [
2028
2028
  ot("nclx"),
2029
2029
  // Colour type
2030
- j(ba[t.info.decoderConfig.colorSpace.primaries]),
2030
+ j(_a[t.info.decoderConfig.colorSpace.primaries]),
2031
2031
  // Colour primaries
2032
- j(_a[t.info.decoderConfig.colorSpace.transfer]),
2032
+ j(xa[t.info.decoderConfig.colorSpace.transfer]),
2033
2033
  // Transfer characteristics
2034
- j(xa[t.info.decoderConfig.colorSpace.matrix]),
2034
+ j(Sa[t.info.decoderConfig.colorSpace.matrix]),
2035
2035
  // Matrix coefficients
2036
2036
  Z((t.info.decoderConfig.colorSpace.fullRange ? 1 : 0) << 7)
2037
2037
  // Full range flag
2038
- ]), Ca = (t) => t.info.decoderConfig && K("avcC", [
2038
+ ]), Ea = (t) => t.info.decoderConfig && K("avcC", [
2039
2039
  // For AVC, description is an AVCDecoderConfigurationRecord, so nothing else to do here
2040
2040
  ...new Uint8Array(t.info.decoderConfig.description)
2041
- ]), Ea = (t) => t.info.decoderConfig && K("hvcC", [
2041
+ ]), ka = (t) => t.info.decoderConfig && K("hvcC", [
2042
2042
  // For HEVC, description is a HEVCDecoderConfigurationRecord, so nothing else to do here
2043
2043
  ...new Uint8Array(t.info.decoderConfig.description)
2044
- ]), ka = (t) => {
2044
+ ]), Ta = (t) => {
2045
2045
  if (!t.info.decoderConfig)
2046
2046
  return null;
2047
2047
  let e = t.info.decoderConfig;
@@ -2064,7 +2064,7 @@ var cr = (t, e, i) => {
2064
2064
  j(0)
2065
2065
  // Codec initialization data size
2066
2066
  ]);
2067
- }, Ta = () => {
2067
+ }, Aa = () => {
2068
2068
  let i = (1 << 7) + 1;
2069
2069
  return K("av1C", [
2070
2070
  i,
@@ -2072,7 +2072,7 @@ var cr = (t, e, i) => {
2072
2072
  0,
2073
2073
  0
2074
2074
  ]);
2075
- }, Aa = (t, e) => K(t, [
2075
+ }, Ma = (t, e) => K(t, [
2076
2076
  Array(6).fill(0),
2077
2077
  // Reserved
2078
2078
  j(1),
@@ -2094,8 +2094,8 @@ var cr = (t, e, i) => {
2094
2094
  mt(e.info.sampleRate)
2095
2095
  // Sample rate
2096
2096
  ], [
2097
- Ja[e.info.codec](e)
2098
- ]), Ma = (t) => {
2097
+ Ka[e.info.codec](e)
2098
+ ]), Pa = (t) => {
2099
2099
  let e = new Uint8Array(t.info.decoderConfig.description);
2100
2100
  return X("esds", 0, 0, [
2101
2101
  // https://stackoverflow.com/a/54803118
@@ -2115,7 +2115,7 @@ var cr = (t, e, i) => {
2115
2115
  // MPEG-4 Audio
2116
2116
  Z(21),
2117
2117
  // stream type(6bits)=5 audio, flags(2bits)=1
2118
- vn(0),
2118
+ yn(0),
2119
2119
  // 24bit buffer size
2120
2120
  C(130071),
2121
2121
  // max bitrate
@@ -2133,7 +2133,7 @@ var cr = (t, e, i) => {
2133
2133
  Z(2)
2134
2134
  // data
2135
2135
  ]);
2136
- }, Pa = (t) => {
2136
+ }, Ia = (t) => {
2137
2137
  var n;
2138
2138
  let e = 3840, i = 0;
2139
2139
  const r = (n = t.info.decoderConfig) == null ? void 0 : n.description;
@@ -2156,7 +2156,7 @@ var cr = (t, e, i) => {
2156
2156
  Z(0)
2157
2157
  // ChannelMappingFamily
2158
2158
  ]);
2159
- }, Ia = (t) => X("stts", 0, 0, [
2159
+ }, Ra = (t) => X("stts", 0, 0, [
2160
2160
  C(t.timeToSampleTable.length),
2161
2161
  // Number of entries
2162
2162
  t.timeToSampleTable.map((e) => [
@@ -2166,7 +2166,7 @@ var cr = (t, e, i) => {
2166
2166
  C(e.sampleDelta)
2167
2167
  // Sample duration
2168
2168
  ])
2169
- ]), Ra = (t) => {
2169
+ ]), Ba = (t) => {
2170
2170
  if (t.samples.every((i) => i.type === "key"))
2171
2171
  return null;
2172
2172
  let e = [...t.samples.entries()].filter(([, i]) => i.type === "key");
@@ -2176,7 +2176,7 @@ var cr = (t, e, i) => {
2176
2176
  e.map(([i]) => C(i + 1))
2177
2177
  // Sync sample table
2178
2178
  ]);
2179
- }, Ba = (t) => X("stsc", 0, 0, [
2179
+ }, Fa = (t) => X("stsc", 0, 0, [
2180
2180
  C(t.compactlyCodedChunkTable.length),
2181
2181
  // Number of entries
2182
2182
  t.compactlyCodedChunkTable.map((e) => [
@@ -2188,14 +2188,14 @@ var cr = (t, e, i) => {
2188
2188
  C(1)
2189
2189
  // Sample description index
2190
2190
  ])
2191
- ]), Fa = (t) => X("stsz", 0, 0, [
2191
+ ]), Da = (t) => X("stsz", 0, 0, [
2192
2192
  C(0),
2193
2193
  // Sample size (0 means non-constant size)
2194
2194
  C(t.samples.length),
2195
2195
  // Number of entries
2196
2196
  t.samples.map((e) => C(e.size))
2197
2197
  // Sample size table
2198
- ]), Da = (t) => t.finalizedChunks.length > 0 && gi(t.finalizedChunks).offset >= 2 ** 32 ? X("co64", 0, 0, [
2198
+ ]), Ua = (t) => t.finalizedChunks.length > 0 && wi(t.finalizedChunks).offset >= 2 ** 32 ? X("co64", 0, 0, [
2199
2199
  C(t.finalizedChunks.length),
2200
2200
  // Number of entries
2201
2201
  t.finalizedChunks.map((e) => Zt(e.offset))
@@ -2205,7 +2205,7 @@ var cr = (t, e, i) => {
2205
2205
  // Number of entries
2206
2206
  t.finalizedChunks.map((e) => C(e.offset))
2207
2207
  // Chunk offset table
2208
- ]), Ua = (t) => X("ctts", 0, 0, [
2208
+ ]), Wa = (t) => X("ctts", 0, 0, [
2209
2209
  C(t.compositionTimeOffsetTable.length),
2210
2210
  // Number of entries
2211
2211
  t.compositionTimeOffsetTable.map((e) => [
@@ -2215,7 +2215,7 @@ var cr = (t, e, i) => {
2215
2215
  C(e.sampleCompositionTimeOffset)
2216
2216
  // Sample offset
2217
2217
  ])
2218
- ]), Wa = (t) => K("mvex", null, t.map(za)), za = (t) => X("trex", 0, 0, [
2218
+ ]), za = (t) => K("mvex", null, t.map(Oa)), Oa = (t) => X("trex", 0, 0, [
2219
2219
  C(t.id),
2220
2220
  // Track ID
2221
2221
  C(1),
@@ -2227,25 +2227,25 @@ var cr = (t, e, i) => {
2227
2227
  C(0)
2228
2228
  // Default sample flags
2229
2229
  ]), Jr = (t, e) => K("moof", null, [
2230
- Oa(t),
2231
- ...e.map(Va)
2232
- ]), Oa = (t) => X("mfhd", 0, 0, [
2230
+ Va(t),
2231
+ ...e.map(La)
2232
+ ]), Va = (t) => X("mfhd", 0, 0, [
2233
2233
  C(t)
2234
2234
  // Sequence number
2235
- ]), xn = (t) => {
2235
+ ]), Sn = (t) => {
2236
2236
  let e = 0, i = 0, r = 0, n = 0, s = t.type === "delta";
2237
2237
  return i |= +s, s ? e |= 1 : e |= 2, e << 24 | i << 16 | r << 8 | n;
2238
- }, Va = (t) => K("traf", null, [
2239
- La(t),
2238
+ }, La = (t) => K("traf", null, [
2240
2239
  Ga(t),
2241
- Na(t)
2242
- ]), La = (t) => {
2240
+ Na(t),
2241
+ $a(t)
2242
+ ]), Ga = (t) => {
2243
2243
  let e = 0;
2244
2244
  e |= 8, e |= 16, e |= 32, e |= 131072;
2245
2245
  let i = t.currentChunk.samples[1] ?? t.currentChunk.samples[0], r = {
2246
2246
  duration: i.timescaleUnitsToNextSample,
2247
2247
  size: i.size,
2248
- flags: xn(i)
2248
+ flags: Sn(i)
2249
2249
  };
2250
2250
  return X("tfhd", 0, e, [
2251
2251
  C(t.id),
@@ -2257,32 +2257,32 @@ var cr = (t, e, i) => {
2257
2257
  C(r.flags)
2258
2258
  // Default sample flags
2259
2259
  ]);
2260
- }, Ga = (t) => X("tfdt", 1, 0, [
2260
+ }, Na = (t) => X("tfdt", 1, 0, [
2261
2261
  Zt(wt(t.currentChunk.startTimestamp, t.timescale))
2262
2262
  // Base Media Decode Time
2263
- ]), Na = (t) => {
2264
- let e = t.currentChunk.samples.map((m) => m.timescaleUnitsToNextSample), i = t.currentChunk.samples.map((m) => m.size), r = t.currentChunk.samples.map(xn), n = t.currentChunk.samples.map((m) => wt(m.presentationTimestamp - m.decodeTimestamp, t.timescale)), s = new Set(e), a = new Set(i), o = new Set(r), f = new Set(n), g = o.size === 2 && r[0] !== r[1], v = s.size > 1, u = a.size > 1, l = !g && o.size > 1, d = f.size > 1 || [...f].some((m) => m !== 0), c = 0;
2265
- return c |= 1, c |= 4 * +g, c |= 256 * +v, c |= 512 * +u, c |= 1024 * +l, c |= 2048 * +d, X("trun", 1, c, [
2263
+ ]), $a = (t) => {
2264
+ let e = t.currentChunk.samples.map((u) => u.timescaleUnitsToNextSample), i = t.currentChunk.samples.map((u) => u.size), r = t.currentChunk.samples.map(Sn), n = t.currentChunk.samples.map((u) => wt(u.presentationTimestamp - u.decodeTimestamp, t.timescale)), s = new Set(e), a = new Set(i), o = new Set(r), p = new Set(n), w = o.size === 2 && r[0] !== r[1], v = s.size > 1, m = a.size > 1, l = !w && o.size > 1, d = p.size > 1 || [...p].some((u) => u !== 0), c = 0;
2265
+ return c |= 1, c |= 4 * +w, c |= 256 * +v, c |= 512 * +m, c |= 1024 * +l, c |= 2048 * +d, X("trun", 1, c, [
2266
2266
  C(t.currentChunk.samples.length),
2267
2267
  // Sample count
2268
2268
  C(t.currentChunk.offset - t.currentChunk.moofOffset || 0),
2269
2269
  // Data offset
2270
- g ? C(r[0]) : [],
2271
- t.currentChunk.samples.map((m, w) => [
2272
- v ? C(e[w]) : [],
2270
+ w ? C(r[0]) : [],
2271
+ t.currentChunk.samples.map((u, g) => [
2272
+ v ? C(e[g]) : [],
2273
2273
  // Sample duration
2274
- u ? C(i[w]) : [],
2274
+ m ? C(i[g]) : [],
2275
2275
  // Sample size
2276
- l ? C(r[w]) : [],
2276
+ l ? C(r[g]) : [],
2277
2277
  // Sample flags
2278
2278
  // Sample composition time offsets
2279
- d ? ia(n[w]) : []
2279
+ d ? ra(n[g]) : []
2280
2280
  ])
2281
2281
  ]);
2282
- }, $a = (t) => K("mfra", null, [
2283
- ...t.map(ja),
2284
- Ha()
2285
- ]), ja = (t, e) => X("tfra", 1, 0, [
2282
+ }, ja = (t) => K("mfra", null, [
2283
+ ...t.map(Ha),
2284
+ qa()
2285
+ ]), Ha = (t, e) => X("tfra", 1, 0, [
2286
2286
  C(t.id),
2287
2287
  // Track ID
2288
2288
  C(63),
@@ -2301,33 +2301,33 @@ var cr = (t, e, i) => {
2301
2301
  C(1)
2302
2302
  // Sample number
2303
2303
  ])
2304
- ]), Ha = () => X("mfro", 0, 0, [
2304
+ ]), qa = () => X("mfro", 0, 0, [
2305
2305
  // This value needs to be overwritten manually from the outside, where the actual size of the enclosing mfra box
2306
2306
  // is known
2307
2307
  C(0)
2308
2308
  // Size
2309
- ]), qa = {
2309
+ ]), Xa = {
2310
2310
  avc: "avc1",
2311
2311
  hevc: "hvc1",
2312
2312
  vp9: "vp09",
2313
2313
  av1: "av01"
2314
- }, Xa = {
2315
- avc: Ca,
2316
- hevc: Ea,
2317
- vp9: ka,
2318
- av1: Ta
2319
2314
  }, Ya = {
2315
+ avc: Ea,
2316
+ hevc: ka,
2317
+ vp9: Ta,
2318
+ av1: Aa
2319
+ }, Ja = {
2320
2320
  aac: "mp4a",
2321
2321
  opus: "Opus"
2322
- }, Ja = {
2323
- aac: Ma,
2324
- opus: Pa
2325
- }, Ai = class {
2326
- }, Sn = class extends Ai {
2322
+ }, Ka = {
2323
+ aac: Pa,
2324
+ opus: Ia
2325
+ }, Mi = class {
2326
+ }, Cn = class extends Mi {
2327
2327
  constructor() {
2328
2328
  super(...arguments), this.buffer = null;
2329
2329
  }
2330
- }, Cn = class extends Ai {
2330
+ }, En = class extends Mi {
2331
2331
  constructor(e) {
2332
2332
  if (super(), this.options = e, typeof e != "object")
2333
2333
  throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");
@@ -2344,7 +2344,7 @@ var cr = (t, e, i) => {
2344
2344
  if (e.chunkSize !== void 0 && (!Number.isInteger(e.chunkSize) || e.chunkSize < 1024))
2345
2345
  throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.");
2346
2346
  }
2347
- }, Ka = class extends Ai {
2347
+ }, Za = class extends Mi {
2348
2348
  constructor(e, i) {
2349
2349
  if (super(), this.stream = e, this.options = i, !(e instanceof FileSystemWritableFileStream))
2350
2350
  throw new TypeError("FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.");
@@ -2353,24 +2353,24 @@ var cr = (t, e, i) => {
2353
2353
  if (i && i.chunkSize !== void 0 && (!Number.isInteger(i.chunkSize) || i.chunkSize <= 0))
2354
2354
  throw new TypeError("options.chunkSize, when provided, must be a positive integer");
2355
2355
  }
2356
- }, Ot, ee, En = class {
2356
+ }, Ot, ee, kn = class {
2357
2357
  constructor() {
2358
- this.pos = 0, W(this, Ot, new Uint8Array(8)), W(this, ee, new DataView(p(this, Ot).buffer)), this.offsets = /* @__PURE__ */ new WeakMap();
2358
+ this.pos = 0, W(this, Ot, new Uint8Array(8)), W(this, ee, new DataView(f(this, Ot).buffer)), this.offsets = /* @__PURE__ */ new WeakMap();
2359
2359
  }
2360
2360
  /** Sets the current position for future writes to a new one. */
2361
2361
  seek(e) {
2362
2362
  this.pos = e;
2363
2363
  }
2364
2364
  writeU32(e) {
2365
- p(this, ee).setUint32(0, e, !1), this.write(p(this, Ot).subarray(0, 4));
2365
+ f(this, ee).setUint32(0, e, !1), this.write(f(this, Ot).subarray(0, 4));
2366
2366
  }
2367
2367
  writeU64(e) {
2368
- p(this, ee).setUint32(0, Math.floor(e / 2 ** 32), !1), p(this, ee).setUint32(4, e, !1), this.write(p(this, Ot).subarray(0, 8));
2368
+ f(this, ee).setUint32(0, Math.floor(e / 2 ** 32), !1), f(this, ee).setUint32(4, e, !1), this.write(f(this, Ot).subarray(0, 8));
2369
2369
  }
2370
2370
  writeAscii(e) {
2371
2371
  for (let i = 0; i < e.length; i++)
2372
- p(this, ee).setUint8(i % 8, e.charCodeAt(i)), i % 8 === 7 && this.write(p(this, Ot));
2373
- e.length % 8 !== 0 && this.write(p(this, Ot).subarray(0, e.length % 8));
2372
+ f(this, ee).setUint8(i % 8, e.charCodeAt(i)), i % 8 === 7 && this.write(f(this, Ot));
2373
+ e.length % 8 !== 0 && this.write(f(this, Ot).subarray(0, e.length % 8));
2374
2374
  }
2375
2375
  writeBox(e) {
2376
2376
  if (this.offsets.set(e, this.pos), e.contents && !e.children)
@@ -2408,47 +2408,47 @@ var cr = (t, e, i) => {
2408
2408
  };
2409
2409
  Ot = /* @__PURE__ */ new WeakMap();
2410
2410
  ee = /* @__PURE__ */ new WeakMap();
2411
- var si, Yt, Ge, Se, ai, Ni, Za = class extends En {
2411
+ var ai, Yt, Ge, Se, oi, Ni, Qa = class extends kn {
2412
2412
  constructor(e) {
2413
- super(), W(this, ai), W(this, si, void 0), W(this, Yt, new ArrayBuffer(2 ** 16)), W(this, Ge, new Uint8Array(p(this, Yt))), W(this, Se, 0), et(this, si, e);
2413
+ super(), W(this, oi), W(this, ai, void 0), W(this, Yt, new ArrayBuffer(2 ** 16)), W(this, Ge, new Uint8Array(f(this, Yt))), W(this, Se, 0), et(this, ai, e);
2414
2414
  }
2415
2415
  write(e) {
2416
- O(this, ai, Ni).call(this, this.pos + e.byteLength), p(this, Ge).set(e, this.pos), this.pos += e.byteLength, et(this, Se, Math.max(p(this, Se), this.pos));
2416
+ O(this, oi, Ni).call(this, this.pos + e.byteLength), f(this, Ge).set(e, this.pos), this.pos += e.byteLength, et(this, Se, Math.max(f(this, Se), this.pos));
2417
2417
  }
2418
2418
  finalize() {
2419
- O(this, ai, Ni).call(this, this.pos), p(this, si).buffer = p(this, Yt).slice(0, Math.max(p(this, Se), this.pos));
2419
+ O(this, oi, Ni).call(this, this.pos), f(this, ai).buffer = f(this, Yt).slice(0, Math.max(f(this, Se), this.pos));
2420
2420
  }
2421
2421
  };
2422
- si = /* @__PURE__ */ new WeakMap();
2422
+ ai = /* @__PURE__ */ new WeakMap();
2423
2423
  Yt = /* @__PURE__ */ new WeakMap();
2424
2424
  Ge = /* @__PURE__ */ new WeakMap();
2425
2425
  Se = /* @__PURE__ */ new WeakMap();
2426
- ai = /* @__PURE__ */ new WeakSet();
2426
+ oi = /* @__PURE__ */ new WeakSet();
2427
2427
  Ni = function(t) {
2428
- let e = p(this, Yt).byteLength;
2428
+ let e = f(this, Yt).byteLength;
2429
2429
  for (; e < t; )
2430
2430
  e *= 2;
2431
- if (e === p(this, Yt).byteLength)
2431
+ if (e === f(this, Yt).byteLength)
2432
2432
  return;
2433
2433
  let i = new ArrayBuffer(e), r = new Uint8Array(i);
2434
- r.set(p(this, Ge), 0), et(this, Yt, i), et(this, Ge, r);
2434
+ r.set(f(this, Ge), 0), et(this, Yt, i), et(this, Ge, r);
2435
2435
  };
2436
- var Qa = 2 ** 24, to = 2, Pe, Vt, Ce, kt, st, wi, $i, ur, kn, mr, Tn, Ie, vi, gr = class extends En {
2436
+ var to = 2 ** 24, eo = 2, Pe, Vt, Ce, kt, st, vi, $i, ur, Tn, mr, An, Ie, yi, gr = class extends kn {
2437
2437
  constructor(e) {
2438
2438
  var i, r;
2439
- super(), W(this, wi), W(this, ur), W(this, mr), W(this, Ie), W(this, Pe, void 0), W(this, Vt, []), W(this, Ce, void 0), W(this, kt, void 0), W(this, st, []), et(this, Pe, e), et(this, Ce, ((i = e.options) == null ? void 0 : i.chunked) ?? !1), et(this, kt, ((r = e.options) == null ? void 0 : r.chunkSize) ?? Qa);
2439
+ super(), W(this, vi), W(this, ur), W(this, mr), W(this, Ie), W(this, Pe, void 0), W(this, Vt, []), W(this, Ce, void 0), W(this, kt, void 0), W(this, st, []), et(this, Pe, e), et(this, Ce, ((i = e.options) == null ? void 0 : i.chunked) ?? !1), et(this, kt, ((r = e.options) == null ? void 0 : r.chunkSize) ?? to);
2440
2440
  }
2441
2441
  write(e) {
2442
- p(this, Vt).push({
2442
+ f(this, Vt).push({
2443
2443
  data: e.slice(),
2444
2444
  start: this.pos
2445
2445
  }), this.pos += e.byteLength;
2446
2446
  }
2447
2447
  flush() {
2448
2448
  var r, n;
2449
- if (p(this, Vt).length === 0)
2449
+ if (f(this, Vt).length === 0)
2450
2450
  return;
2451
- let e = [], i = [...p(this, Vt)].sort((s, a) => s.start - a.start);
2451
+ let e = [], i = [...f(this, Vt)].sort((s, a) => s.start - a.start);
2452
2452
  e.push({
2453
2453
  start: i[0].start,
2454
2454
  size: i[0].data.byteLength
@@ -2462,14 +2462,14 @@ var Qa = 2 ** 24, to = 2, Pe, Vt, Ce, kt, st, wi, $i, ur, kn, mr, Tn, Ie, vi, gr
2462
2462
  }
2463
2463
  for (let s of e) {
2464
2464
  s.data = new Uint8Array(s.size);
2465
- for (let a of p(this, Vt))
2465
+ for (let a of f(this, Vt))
2466
2466
  s.start <= a.start && a.start < s.start + s.size && s.data.set(a.data, a.start - s.start);
2467
- p(this, Ce) ? (O(this, wi, $i).call(this, s.data, s.start), O(this, Ie, vi).call(this)) : (n = (r = p(this, Pe).options).onData) == null || n.call(r, s.data, s.start);
2467
+ f(this, Ce) ? (O(this, vi, $i).call(this, s.data, s.start), O(this, Ie, yi).call(this)) : (n = (r = f(this, Pe).options).onData) == null || n.call(r, s.data, s.start);
2468
2468
  }
2469
- p(this, Vt).length = 0;
2469
+ f(this, Vt).length = 0;
2470
2470
  }
2471
2471
  finalize() {
2472
- p(this, Ce) && O(this, Ie, vi).call(this, !0);
2472
+ f(this, Ce) && O(this, Ie, yi).call(this, !0);
2473
2473
  }
2474
2474
  };
2475
2475
  Pe = /* @__PURE__ */ new WeakMap();
@@ -2477,25 +2477,25 @@ Vt = /* @__PURE__ */ new WeakMap();
2477
2477
  Ce = /* @__PURE__ */ new WeakMap();
2478
2478
  kt = /* @__PURE__ */ new WeakMap();
2479
2479
  st = /* @__PURE__ */ new WeakMap();
2480
- wi = /* @__PURE__ */ new WeakSet();
2480
+ vi = /* @__PURE__ */ new WeakSet();
2481
2481
  $i = function(t, e) {
2482
- let i = p(this, st).findIndex((o) => o.start <= e && e < o.start + p(this, kt));
2483
- i === -1 && (i = O(this, mr, Tn).call(this, e));
2484
- let r = p(this, st)[i], n = e - r.start, s = t.subarray(0, Math.min(p(this, kt) - n, t.byteLength));
2482
+ let i = f(this, st).findIndex((o) => o.start <= e && e < o.start + f(this, kt));
2483
+ i === -1 && (i = O(this, mr, An).call(this, e));
2484
+ let r = f(this, st)[i], n = e - r.start, s = t.subarray(0, Math.min(f(this, kt) - n, t.byteLength));
2485
2485
  r.data.set(s, n);
2486
2486
  let a = {
2487
2487
  start: n,
2488
2488
  end: n + s.byteLength
2489
2489
  };
2490
- if (O(this, ur, kn).call(this, r, a), r.written[0].start === 0 && r.written[0].end === p(this, kt) && (r.shouldFlush = !0), p(this, st).length > to) {
2491
- for (let o = 0; o < p(this, st).length - 1; o++)
2492
- p(this, st)[o].shouldFlush = !0;
2493
- O(this, Ie, vi).call(this);
2490
+ if (O(this, ur, Tn).call(this, r, a), r.written[0].start === 0 && r.written[0].end === f(this, kt) && (r.shouldFlush = !0), f(this, st).length > eo) {
2491
+ for (let o = 0; o < f(this, st).length - 1; o++)
2492
+ f(this, st)[o].shouldFlush = !0;
2493
+ O(this, Ie, yi).call(this);
2494
2494
  }
2495
- s.byteLength < t.byteLength && O(this, wi, $i).call(this, t.subarray(s.byteLength), e + s.byteLength);
2495
+ s.byteLength < t.byteLength && O(this, vi, $i).call(this, t.subarray(s.byteLength), e + s.byteLength);
2496
2496
  };
2497
2497
  ur = /* @__PURE__ */ new WeakSet();
2498
- kn = function(t, e) {
2498
+ Tn = function(t, e) {
2499
2499
  let i = 0, r = t.written.length - 1, n = -1;
2500
2500
  for (; i <= r; ) {
2501
2501
  let s = Math.floor(i + (r - i + 1) / 2);
@@ -2505,35 +2505,35 @@ kn = function(t, e) {
2505
2505
  t.written[n].end = Math.max(t.written[n].end, t.written[n + 1].end), t.written.splice(n + 1, 1);
2506
2506
  };
2507
2507
  mr = /* @__PURE__ */ new WeakSet();
2508
- Tn = function(t) {
2508
+ An = function(t) {
2509
2509
  let i = {
2510
- start: Math.floor(t / p(this, kt)) * p(this, kt),
2511
- data: new Uint8Array(p(this, kt)),
2510
+ start: Math.floor(t / f(this, kt)) * f(this, kt),
2511
+ data: new Uint8Array(f(this, kt)),
2512
2512
  written: [],
2513
2513
  shouldFlush: !1
2514
2514
  };
2515
- return p(this, st).push(i), p(this, st).sort((r, n) => r.start - n.start), p(this, st).indexOf(i);
2515
+ return f(this, st).push(i), f(this, st).sort((r, n) => r.start - n.start), f(this, st).indexOf(i);
2516
2516
  };
2517
2517
  Ie = /* @__PURE__ */ new WeakSet();
2518
- vi = function(t = !1) {
2518
+ yi = function(t = !1) {
2519
2519
  var e, i;
2520
- for (let r = 0; r < p(this, st).length; r++) {
2521
- let n = p(this, st)[r];
2520
+ for (let r = 0; r < f(this, st).length; r++) {
2521
+ let n = f(this, st)[r];
2522
2522
  if (!(!n.shouldFlush && !t)) {
2523
2523
  for (let s of n.written)
2524
- (i = (e = p(this, Pe).options).onData) == null || i.call(
2524
+ (i = (e = f(this, Pe).options).onData) == null || i.call(
2525
2525
  e,
2526
2526
  n.data.subarray(s.start, s.end),
2527
2527
  n.start + s.start
2528
2528
  );
2529
- p(this, st).splice(r--, 1);
2529
+ f(this, st).splice(r--, 1);
2530
2530
  }
2531
2531
  }
2532
2532
  };
2533
- var eo = class extends gr {
2533
+ var io = class extends gr {
2534
2534
  constructor(e) {
2535
2535
  var i;
2536
- super(new Cn({
2536
+ super(new En({
2537
2537
  onData: (r, n) => e.stream.write({
2538
2538
  type: "write",
2539
2539
  data: r,
@@ -2543,20 +2543,20 @@ var eo = class extends gr {
2543
2543
  chunkSize: (i = e.options) == null ? void 0 : i.chunkSize
2544
2544
  }));
2545
2545
  }
2546
- }, ji = 1e3, io = ["avc", "hevc", "vp9", "av1"], ro = ["aac", "opus"], no = 2082844800, so = ["strict", "offset", "cross-track-offset"], P, B, yi, nt, it, tt, re, oe, wr, Lt, Gt, Re, Hi, An, qi, Mn, vr, Pn, Xi, In, yr, Rn, oi, Yi, ct, bt, br, Bn, Be, bi, _i, _r, ge, Ye, li, Ji, ao = class {
2546
+ }, ji = 1e3, ro = ["avc", "hevc", "vp9", "av1"], no = ["aac", "opus"], so = 2082844800, ao = ["strict", "offset", "cross-track-offset"], P, B, bi, nt, it, tt, re, oe, wr, Lt, Gt, Re, Hi, Mn, qi, Pn, vr, In, Xi, Rn, yr, Bn, li, Yi, ct, bt, br, Fn, Be, _i, xi, _r, ge, Ye, hi, Ji, oo = class {
2547
2547
  constructor(e) {
2548
- if (W(this, Hi), W(this, qi), W(this, vr), W(this, Xi), W(this, yr), W(this, oi), W(this, ct), W(this, br), W(this, Be), W(this, _i), W(this, ge), W(this, li), W(this, P, void 0), W(this, B, void 0), W(this, yi, void 0), W(this, nt, void 0), W(this, it, null), W(this, tt, null), W(this, re, Math.floor(Date.now() / 1e3) + no), W(this, oe, []), W(this, wr, 1), W(this, Lt, []), W(this, Gt, []), W(this, Re, !1), O(this, Hi, An).call(this, e), e.video = Me(e.video), e.audio = Me(e.audio), e.fastStart = Me(e.fastStart), this.target = e.target, et(this, P, {
2548
+ if (W(this, Hi), W(this, qi), W(this, vr), W(this, Xi), W(this, yr), W(this, li), W(this, ct), W(this, br), W(this, Be), W(this, xi), W(this, ge), W(this, hi), W(this, P, void 0), W(this, B, void 0), W(this, bi, void 0), W(this, nt, void 0), W(this, it, null), W(this, tt, null), W(this, re, Math.floor(Date.now() / 1e3) + so), W(this, oe, []), W(this, wr, 1), W(this, Lt, []), W(this, Gt, []), W(this, Re, !1), O(this, Hi, Mn).call(this, e), e.video = Me(e.video), e.audio = Me(e.audio), e.fastStart = Me(e.fastStart), this.target = e.target, et(this, P, {
2549
2549
  firstTimestampBehavior: "strict",
2550
2550
  ...e
2551
- }), e.target instanceof Sn)
2552
- et(this, B, new Za(e.target));
2553
- else if (e.target instanceof Cn)
2551
+ }), e.target instanceof Cn)
2552
+ et(this, B, new Qa(e.target));
2553
+ else if (e.target instanceof En)
2554
2554
  et(this, B, new gr(e.target));
2555
- else if (e.target instanceof Ka)
2556
- et(this, B, new eo(e.target));
2555
+ else if (e.target instanceof Za)
2556
+ et(this, B, new io(e.target));
2557
2557
  else
2558
2558
  throw new Error(`Invalid target: ${e.target}`);
2559
- O(this, Xi, In).call(this), O(this, qi, Mn).call(this);
2559
+ O(this, Xi, Rn).call(this), O(this, qi, Pn).call(this);
2560
2560
  }
2561
2561
  addVideoChunk(e, i, r, n) {
2562
2562
  if (!(e instanceof EncodedVideoChunk))
@@ -2596,19 +2596,19 @@ var eo = class extends gr {
2596
2596
  throw new TypeError(
2597
2597
  "addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number."
2598
2598
  );
2599
- if (O(this, li, Ji).call(this), !p(this, P).video)
2599
+ if (O(this, hi, Ji).call(this), !f(this, P).video)
2600
2600
  throw new Error("No video track declared.");
2601
- if (typeof p(this, P).fastStart == "object" && p(this, it).samples.length === p(this, P).fastStart.expectedVideoChunks)
2602
- throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${p(this, P).fastStart.expectedVideoChunks}).`);
2603
- let o = O(this, oi, Yi).call(this, p(this, it), e, i, r, n, s, a);
2604
- if (p(this, P).fastStart === "fragmented" && p(this, tt)) {
2605
- for (; p(this, Gt).length > 0 && p(this, Gt)[0].decodeTimestamp <= o.decodeTimestamp; ) {
2606
- let f = p(this, Gt).shift();
2607
- O(this, ct, bt).call(this, p(this, tt), f);
2601
+ if (typeof f(this, P).fastStart == "object" && f(this, it).samples.length === f(this, P).fastStart.expectedVideoChunks)
2602
+ throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${f(this, P).fastStart.expectedVideoChunks}).`);
2603
+ let o = O(this, li, Yi).call(this, f(this, it), e, i, r, n, s, a);
2604
+ if (f(this, P).fastStart === "fragmented" && f(this, tt)) {
2605
+ for (; f(this, Gt).length > 0 && f(this, Gt)[0].decodeTimestamp <= o.decodeTimestamp; ) {
2606
+ let p = f(this, Gt).shift();
2607
+ O(this, ct, bt).call(this, f(this, tt), p);
2608
2608
  }
2609
- o.decodeTimestamp <= p(this, tt).lastDecodeTimestamp ? O(this, ct, bt).call(this, p(this, it), o) : p(this, Lt).push(o);
2609
+ o.decodeTimestamp <= f(this, tt).lastDecodeTimestamp ? O(this, ct, bt).call(this, f(this, it), o) : f(this, Lt).push(o);
2610
2610
  } else
2611
- O(this, ct, bt).call(this, p(this, it), o);
2611
+ O(this, ct, bt).call(this, f(this, it), o);
2612
2612
  }
2613
2613
  addAudioChunk(e, i, r) {
2614
2614
  if (!(e instanceof EncodedAudioChunk))
@@ -2633,75 +2633,75 @@ var eo = class extends gr {
2633
2633
  throw new TypeError("addAudioChunkRaw's fourth argument (duration) must be a non-negative real number.");
2634
2634
  if (s && typeof s != "object")
2635
2635
  throw new TypeError("addAudioChunkRaw's fifth argument (meta), when provided, must be an object.");
2636
- if (O(this, li, Ji).call(this), !p(this, P).audio)
2636
+ if (O(this, hi, Ji).call(this), !f(this, P).audio)
2637
2637
  throw new Error("No audio track declared.");
2638
- if (typeof p(this, P).fastStart == "object" && p(this, tt).samples.length === p(this, P).fastStart.expectedAudioChunks)
2639
- throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${p(this, P).fastStart.expectedAudioChunks}).`);
2640
- let a = O(this, oi, Yi).call(this, p(this, tt), e, i, r, n, s);
2641
- if (p(this, P).fastStart === "fragmented" && p(this, it)) {
2642
- for (; p(this, Lt).length > 0 && p(this, Lt)[0].decodeTimestamp <= a.decodeTimestamp; ) {
2643
- let o = p(this, Lt).shift();
2644
- O(this, ct, bt).call(this, p(this, it), o);
2638
+ if (typeof f(this, P).fastStart == "object" && f(this, tt).samples.length === f(this, P).fastStart.expectedAudioChunks)
2639
+ throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${f(this, P).fastStart.expectedAudioChunks}).`);
2640
+ let a = O(this, li, Yi).call(this, f(this, tt), e, i, r, n, s);
2641
+ if (f(this, P).fastStart === "fragmented" && f(this, it)) {
2642
+ for (; f(this, Lt).length > 0 && f(this, Lt)[0].decodeTimestamp <= a.decodeTimestamp; ) {
2643
+ let o = f(this, Lt).shift();
2644
+ O(this, ct, bt).call(this, f(this, it), o);
2645
2645
  }
2646
- a.decodeTimestamp <= p(this, it).lastDecodeTimestamp ? O(this, ct, bt).call(this, p(this, tt), a) : p(this, Gt).push(a);
2646
+ a.decodeTimestamp <= f(this, it).lastDecodeTimestamp ? O(this, ct, bt).call(this, f(this, tt), a) : f(this, Gt).push(a);
2647
2647
  } else
2648
- O(this, ct, bt).call(this, p(this, tt), a);
2648
+ O(this, ct, bt).call(this, f(this, tt), a);
2649
2649
  }
2650
2650
  /** Finalizes the file, making it ready for use. Must be called after all video and audio chunks have been added. */
2651
2651
  finalize() {
2652
- if (p(this, Re))
2652
+ if (f(this, Re))
2653
2653
  throw new Error("Cannot finalize a muxer more than once.");
2654
- if (p(this, P).fastStart === "fragmented") {
2655
- for (let i of p(this, Lt))
2656
- O(this, ct, bt).call(this, p(this, it), i);
2657
- for (let i of p(this, Gt))
2658
- O(this, ct, bt).call(this, p(this, tt), i);
2659
- O(this, _i, _r).call(this, !1);
2654
+ if (f(this, P).fastStart === "fragmented") {
2655
+ for (let i of f(this, Lt))
2656
+ O(this, ct, bt).call(this, f(this, it), i);
2657
+ for (let i of f(this, Gt))
2658
+ O(this, ct, bt).call(this, f(this, tt), i);
2659
+ O(this, xi, _r).call(this, !1);
2660
2660
  } else
2661
- p(this, it) && O(this, Be, bi).call(this, p(this, it)), p(this, tt) && O(this, Be, bi).call(this, p(this, tt));
2662
- let e = [p(this, it), p(this, tt)].filter(Boolean);
2663
- if (p(this, P).fastStart === "in-memory") {
2661
+ f(this, it) && O(this, Be, _i).call(this, f(this, it)), f(this, tt) && O(this, Be, _i).call(this, f(this, tt));
2662
+ let e = [f(this, it), f(this, tt)].filter(Boolean);
2663
+ if (f(this, P).fastStart === "in-memory") {
2664
2664
  let i;
2665
2665
  for (let n = 0; n < 2; n++) {
2666
- let s = ni(e, p(this, re)), a = p(this, B).measureBox(s);
2667
- i = p(this, B).measureBox(p(this, nt));
2668
- let o = p(this, B).pos + a + i;
2669
- for (let f of p(this, oe)) {
2670
- f.offset = o;
2671
- for (let { data: g } of f.samples)
2672
- o += g.byteLength, i += g.byteLength;
2666
+ let s = si(e, f(this, re)), a = f(this, B).measureBox(s);
2667
+ i = f(this, B).measureBox(f(this, nt));
2668
+ let o = f(this, B).pos + a + i;
2669
+ for (let p of f(this, oe)) {
2670
+ p.offset = o;
2671
+ for (let { data: w } of p.samples)
2672
+ o += w.byteLength, i += w.byteLength;
2673
2673
  }
2674
2674
  if (o < 2 ** 32)
2675
2675
  break;
2676
- i >= 2 ** 32 && (p(this, nt).largeSize = !0);
2676
+ i >= 2 ** 32 && (f(this, nt).largeSize = !0);
2677
2677
  }
2678
- let r = ni(e, p(this, re));
2679
- p(this, B).writeBox(r), p(this, nt).size = i, p(this, B).writeBox(p(this, nt));
2680
- for (let n of p(this, oe))
2678
+ let r = si(e, f(this, re));
2679
+ f(this, B).writeBox(r), f(this, nt).size = i, f(this, B).writeBox(f(this, nt));
2680
+ for (let n of f(this, oe))
2681
2681
  for (let s of n.samples)
2682
- p(this, B).write(s.data), s.data = null;
2683
- } else if (p(this, P).fastStart === "fragmented") {
2684
- let i = p(this, B).pos, r = $a(e);
2685
- p(this, B).writeBox(r);
2686
- let n = p(this, B).pos - i;
2687
- p(this, B).seek(p(this, B).pos - 4), p(this, B).writeU32(n);
2682
+ f(this, B).write(s.data), s.data = null;
2683
+ } else if (f(this, P).fastStart === "fragmented") {
2684
+ let i = f(this, B).pos, r = ja(e);
2685
+ f(this, B).writeBox(r);
2686
+ let n = f(this, B).pos - i;
2687
+ f(this, B).seek(f(this, B).pos - 4), f(this, B).writeU32(n);
2688
2688
  } else {
2689
- let i = p(this, B).offsets.get(p(this, nt)), r = p(this, B).pos - i;
2690
- p(this, nt).size = r, p(this, nt).largeSize = r >= 2 ** 32, p(this, B).patchBox(p(this, nt));
2691
- let n = ni(e, p(this, re));
2692
- if (typeof p(this, P).fastStart == "object") {
2693
- p(this, B).seek(p(this, yi)), p(this, B).writeBox(n);
2694
- let s = i - p(this, B).pos;
2695
- p(this, B).writeBox(na(s));
2689
+ let i = f(this, B).offsets.get(f(this, nt)), r = f(this, B).pos - i;
2690
+ f(this, nt).size = r, f(this, nt).largeSize = r >= 2 ** 32, f(this, B).patchBox(f(this, nt));
2691
+ let n = si(e, f(this, re));
2692
+ if (typeof f(this, P).fastStart == "object") {
2693
+ f(this, B).seek(f(this, bi)), f(this, B).writeBox(n);
2694
+ let s = i - f(this, B).pos;
2695
+ f(this, B).writeBox(sa(s));
2696
2696
  } else
2697
- p(this, B).writeBox(n);
2697
+ f(this, B).writeBox(n);
2698
2698
  }
2699
- O(this, ge, Ye).call(this), p(this, B).finalize(), et(this, Re, !0);
2699
+ O(this, ge, Ye).call(this), f(this, B).finalize(), et(this, Re, !0);
2700
2700
  }
2701
2701
  };
2702
2702
  P = /* @__PURE__ */ new WeakMap();
2703
2703
  B = /* @__PURE__ */ new WeakMap();
2704
- yi = /* @__PURE__ */ new WeakMap();
2704
+ bi = /* @__PURE__ */ new WeakMap();
2705
2705
  nt = /* @__PURE__ */ new WeakMap();
2706
2706
  it = /* @__PURE__ */ new WeakMap();
2707
2707
  tt = /* @__PURE__ */ new WeakMap();
@@ -2712,13 +2712,13 @@ Lt = /* @__PURE__ */ new WeakMap();
2712
2712
  Gt = /* @__PURE__ */ new WeakMap();
2713
2713
  Re = /* @__PURE__ */ new WeakMap();
2714
2714
  Hi = /* @__PURE__ */ new WeakSet();
2715
- An = function(t) {
2715
+ Mn = function(t) {
2716
2716
  if (typeof t != "object")
2717
2717
  throw new TypeError("The muxer requires an options object to be passed to its constructor.");
2718
- if (!(t.target instanceof Ai))
2718
+ if (!(t.target instanceof Mi))
2719
2719
  throw new TypeError("The target must be provided and an instance of Target.");
2720
2720
  if (t.video) {
2721
- if (!io.includes(t.video.codec))
2721
+ if (!ro.includes(t.video.codec))
2722
2722
  throw new TypeError(`Unsupported video codec: ${t.video.codec}`);
2723
2723
  if (!Number.isInteger(t.video.width) || t.video.width <= 0)
2724
2724
  throw new TypeError(`Invalid video width: ${t.video.width}. Must be a positive integer.`);
@@ -2735,7 +2735,7 @@ An = function(t) {
2735
2735
  );
2736
2736
  }
2737
2737
  if (t.audio) {
2738
- if (!ro.includes(t.audio.codec))
2738
+ if (!no.includes(t.audio.codec))
2739
2739
  throw new TypeError(`Unsupported audio codec: ${t.audio.codec}`);
2740
2740
  if (!Number.isInteger(t.audio.numberOfChannels) || t.audio.numberOfChannels <= 0)
2741
2741
  throw new TypeError(
@@ -2746,7 +2746,7 @@ An = function(t) {
2746
2746
  `Invalid audio sample rate: ${t.audio.sampleRate}. Must be a positive integer.`
2747
2747
  );
2748
2748
  }
2749
- if (t.firstTimestampBehavior && !so.includes(t.firstTimestampBehavior))
2749
+ if (t.firstTimestampBehavior && !ao.includes(t.firstTimestampBehavior))
2750
2750
  throw new TypeError(`Invalid first timestamp behavior: ${t.firstTimestampBehavior}`);
2751
2751
  if (typeof t.fastStart == "object") {
2752
2752
  if (t.video) {
@@ -2767,48 +2767,48 @@ An = function(t) {
2767
2767
  throw new TypeError("'minFragmentDuration' must be a non-negative number.");
2768
2768
  };
2769
2769
  qi = /* @__PURE__ */ new WeakSet();
2770
- Mn = function() {
2770
+ Pn = function() {
2771
2771
  var t;
2772
- if (p(this, B).writeBox(ra({
2773
- holdsAvc: ((t = p(this, P).video) == null ? void 0 : t.codec) === "avc",
2774
- fragmented: p(this, P).fastStart === "fragmented"
2775
- })), et(this, yi, p(this, B).pos), p(this, P).fastStart === "in-memory")
2772
+ if (f(this, B).writeBox(na({
2773
+ holdsAvc: ((t = f(this, P).video) == null ? void 0 : t.codec) === "avc",
2774
+ fragmented: f(this, P).fastStart === "fragmented"
2775
+ })), et(this, bi, f(this, B).pos), f(this, P).fastStart === "in-memory")
2776
2776
  et(this, nt, Gi(!1));
2777
- else if (p(this, P).fastStart !== "fragmented") {
2778
- if (typeof p(this, P).fastStart == "object") {
2779
- let e = O(this, vr, Pn).call(this);
2780
- p(this, B).seek(p(this, B).pos + e);
2777
+ else if (f(this, P).fastStart !== "fragmented") {
2778
+ if (typeof f(this, P).fastStart == "object") {
2779
+ let e = O(this, vr, In).call(this);
2780
+ f(this, B).seek(f(this, B).pos + e);
2781
2781
  }
2782
- et(this, nt, Gi(!0)), p(this, B).writeBox(p(this, nt));
2782
+ et(this, nt, Gi(!0)), f(this, B).writeBox(f(this, nt));
2783
2783
  }
2784
2784
  O(this, ge, Ye).call(this);
2785
2785
  };
2786
2786
  vr = /* @__PURE__ */ new WeakSet();
2787
- Pn = function() {
2788
- if (typeof p(this, P).fastStart != "object")
2787
+ In = function() {
2788
+ if (typeof f(this, P).fastStart != "object")
2789
2789
  return;
2790
2790
  let t = 0, e = [
2791
- p(this, P).fastStart.expectedVideoChunks,
2792
- p(this, P).fastStart.expectedAudioChunks
2791
+ f(this, P).fastStart.expectedVideoChunks,
2792
+ f(this, P).fastStart.expectedAudioChunks
2793
2793
  ];
2794
2794
  for (let i of e)
2795
2795
  i && (t += 8 * Math.ceil(2 / 3 * i), t += 4 * i, t += 12 * Math.ceil(2 / 3 * i), t += 4 * i, t += 8 * i);
2796
2796
  return t += 4096, t;
2797
2797
  };
2798
2798
  Xi = /* @__PURE__ */ new WeakSet();
2799
- In = function() {
2800
- if (p(this, P).video && et(this, it, {
2799
+ Rn = function() {
2800
+ if (f(this, P).video && et(this, it, {
2801
2801
  id: 1,
2802
2802
  info: {
2803
2803
  type: "video",
2804
- codec: p(this, P).video.codec,
2805
- width: p(this, P).video.width,
2806
- height: p(this, P).video.height,
2807
- rotation: p(this, P).video.rotation ?? 0,
2804
+ codec: f(this, P).video.codec,
2805
+ width: f(this, P).video.width,
2806
+ height: f(this, P).video.height,
2807
+ rotation: f(this, P).video.rotation ?? 0,
2808
2808
  decoderConfig: null
2809
2809
  },
2810
2810
  // The fallback contains many common frame rates as factors
2811
- timescale: p(this, P).video.frameRate ?? 57600,
2811
+ timescale: f(this, P).video.frameRate ?? 57600,
2812
2812
  samples: [],
2813
2813
  finalizedChunks: [],
2814
2814
  currentChunk: null,
@@ -2819,16 +2819,16 @@ In = function() {
2819
2819
  lastTimescaleUnits: null,
2820
2820
  lastSample: null,
2821
2821
  compactlyCodedChunkTable: []
2822
- }), p(this, P).audio && (et(this, tt, {
2823
- id: p(this, P).video ? 2 : 1,
2822
+ }), f(this, P).audio && (et(this, tt, {
2823
+ id: f(this, P).video ? 2 : 1,
2824
2824
  info: {
2825
2825
  type: "audio",
2826
- codec: p(this, P).audio.codec,
2827
- numberOfChannels: p(this, P).audio.numberOfChannels,
2828
- sampleRate: p(this, P).audio.sampleRate,
2826
+ codec: f(this, P).audio.codec,
2827
+ numberOfChannels: f(this, P).audio.numberOfChannels,
2828
+ sampleRate: f(this, P).audio.sampleRate,
2829
2829
  decoderConfig: null
2830
2830
  },
2831
- timescale: p(this, P).audio.sampleRate,
2831
+ timescale: f(this, P).audio.sampleRate,
2832
2832
  samples: [],
2833
2833
  finalizedChunks: [],
2834
2834
  currentChunk: null,
@@ -2839,67 +2839,67 @@ In = function() {
2839
2839
  lastTimescaleUnits: null,
2840
2840
  lastSample: null,
2841
2841
  compactlyCodedChunkTable: []
2842
- }), p(this, P).audio.codec === "aac")) {
2843
- let t = O(this, yr, Rn).call(
2842
+ }), f(this, P).audio.codec === "aac")) {
2843
+ let t = O(this, yr, Bn).call(
2844
2844
  this,
2845
2845
  2,
2846
2846
  // Object type for AAC-LC, since it's the most common
2847
- p(this, P).audio.sampleRate,
2848
- p(this, P).audio.numberOfChannels
2847
+ f(this, P).audio.sampleRate,
2848
+ f(this, P).audio.numberOfChannels
2849
2849
  );
2850
- p(this, tt).info.decoderConfig = {
2851
- codec: p(this, P).audio.codec,
2850
+ f(this, tt).info.decoderConfig = {
2851
+ codec: f(this, P).audio.codec,
2852
2852
  description: t,
2853
- numberOfChannels: p(this, P).audio.numberOfChannels,
2854
- sampleRate: p(this, P).audio.sampleRate
2853
+ numberOfChannels: f(this, P).audio.numberOfChannels,
2854
+ sampleRate: f(this, P).audio.sampleRate
2855
2855
  };
2856
2856
  }
2857
2857
  };
2858
2858
  yr = /* @__PURE__ */ new WeakSet();
2859
- Rn = function(t, e, i) {
2859
+ Bn = function(t, e, i) {
2860
2860
  let n = [96e3, 88200, 64e3, 48e3, 44100, 32e3, 24e3, 22050, 16e3, 12e3, 11025, 8e3, 7350].indexOf(e), s = i, a = "";
2861
2861
  a += t.toString(2).padStart(5, "0"), a += n.toString(2).padStart(4, "0"), n === 15 && (a += e.toString(2).padStart(24, "0")), a += s.toString(2).padStart(4, "0");
2862
2862
  let o = Math.ceil(a.length / 8) * 8;
2863
2863
  a = a.padEnd(o, "0");
2864
- let f = new Uint8Array(a.length / 8);
2865
- for (let g = 0; g < a.length; g += 8)
2866
- f[g / 8] = parseInt(a.slice(g, g + 8), 2);
2867
- return f;
2864
+ let p = new Uint8Array(a.length / 8);
2865
+ for (let w = 0; w < a.length; w += 8)
2866
+ p[w / 8] = parseInt(a.slice(w, w + 8), 2);
2867
+ return p;
2868
2868
  };
2869
- oi = /* @__PURE__ */ new WeakSet();
2869
+ li = /* @__PURE__ */ new WeakSet();
2870
2870
  Yi = function(t, e, i, r, n, s, a) {
2871
- let o = r / 1e6, f = (r - (a ?? 0)) / 1e6, g = n / 1e6, v = O(this, br, Bn).call(this, o, f, t);
2872
- return o = v.presentationTimestamp, f = v.decodeTimestamp, s != null && s.decoderConfig && (t.info.decoderConfig === null ? t.info.decoderConfig = s.decoderConfig : Object.assign(t.info.decoderConfig, s.decoderConfig)), {
2871
+ let o = r / 1e6, p = (r - (a ?? 0)) / 1e6, w = n / 1e6, v = O(this, br, Fn).call(this, o, p, t);
2872
+ return o = v.presentationTimestamp, p = v.decodeTimestamp, s != null && s.decoderConfig && (t.info.decoderConfig === null ? t.info.decoderConfig = s.decoderConfig : Object.assign(t.info.decoderConfig, s.decoderConfig)), {
2873
2873
  presentationTimestamp: o,
2874
- decodeTimestamp: f,
2875
- duration: g,
2874
+ decodeTimestamp: p,
2875
+ duration: w,
2876
2876
  data: e,
2877
2877
  size: e.byteLength,
2878
2878
  type: i,
2879
2879
  // Will be refined once the next sample comes in
2880
- timescaleUnitsToNextSample: wt(g, t.timescale)
2880
+ timescaleUnitsToNextSample: wt(w, t.timescale)
2881
2881
  };
2882
2882
  };
2883
2883
  ct = /* @__PURE__ */ new WeakSet();
2884
2884
  bt = function(t, e) {
2885
- p(this, P).fastStart !== "fragmented" && t.samples.push(e);
2885
+ f(this, P).fastStart !== "fragmented" && t.samples.push(e);
2886
2886
  const i = wt(e.presentationTimestamp - e.decodeTimestamp, t.timescale);
2887
2887
  if (t.lastTimescaleUnits !== null) {
2888
2888
  let n = wt(e.decodeTimestamp, t.timescale, !1), s = Math.round(n - t.lastTimescaleUnits);
2889
- if (t.lastTimescaleUnits += s, t.lastSample.timescaleUnitsToNextSample = s, p(this, P).fastStart !== "fragmented") {
2890
- let a = gi(t.timeToSampleTable);
2889
+ if (t.lastTimescaleUnits += s, t.lastSample.timescaleUnitsToNextSample = s, f(this, P).fastStart !== "fragmented") {
2890
+ let a = wi(t.timeToSampleTable);
2891
2891
  a.sampleCount === 1 ? (a.sampleDelta = s, a.sampleCount++) : a.sampleDelta === s ? a.sampleCount++ : (a.sampleCount--, t.timeToSampleTable.push({
2892
2892
  sampleCount: 2,
2893
2893
  sampleDelta: s
2894
2894
  }));
2895
- const o = gi(t.compositionTimeOffsetTable);
2895
+ const o = wi(t.compositionTimeOffsetTable);
2896
2896
  o.sampleCompositionTimeOffset === i ? o.sampleCount++ : t.compositionTimeOffsetTable.push({
2897
2897
  sampleCount: 1,
2898
2898
  sampleCompositionTimeOffset: i
2899
2899
  });
2900
2900
  }
2901
2901
  } else
2902
- t.lastTimescaleUnits = 0, p(this, P).fastStart !== "fragmented" && (t.timeToSampleTable.push({
2902
+ t.lastTimescaleUnits = 0, f(this, P).fastStart !== "fragmented" && (t.timeToSampleTable.push({
2903
2903
  sampleCount: 1,
2904
2904
  sampleDelta: wt(e.duration, t.timescale)
2905
2905
  }), t.compositionTimeOffsetTable.push({
@@ -2912,22 +2912,22 @@ bt = function(t, e) {
2912
2912
  r = !0;
2913
2913
  else {
2914
2914
  let n = e.presentationTimestamp - t.currentChunk.startTimestamp;
2915
- if (p(this, P).fastStart === "fragmented") {
2916
- let s = p(this, it) ?? p(this, tt);
2917
- const a = p(this, P).minFragmentDuration ?? 1;
2918
- t === s && e.type === "key" && n >= a && (r = !0, O(this, _i, _r).call(this));
2915
+ if (f(this, P).fastStart === "fragmented") {
2916
+ let s = f(this, it) ?? f(this, tt);
2917
+ const a = f(this, P).minFragmentDuration ?? 1;
2918
+ t === s && e.type === "key" && n >= a && (r = !0, O(this, xi, _r).call(this));
2919
2919
  } else
2920
2920
  r = n >= 0.5;
2921
2921
  }
2922
- r && (t.currentChunk && O(this, Be, bi).call(this, t), t.currentChunk = {
2922
+ r && (t.currentChunk && O(this, Be, _i).call(this, t), t.currentChunk = {
2923
2923
  startTimestamp: e.presentationTimestamp,
2924
2924
  samples: []
2925
2925
  }), t.currentChunk.samples.push(e);
2926
2926
  };
2927
2927
  br = /* @__PURE__ */ new WeakSet();
2928
- Bn = function(t, e, i) {
2928
+ Fn = function(t, e, i) {
2929
2929
  var a, o;
2930
- const r = p(this, P).firstTimestampBehavior === "strict", n = i.lastDecodeTimestamp === -1;
2930
+ const r = f(this, P).firstTimestampBehavior === "strict", n = i.lastDecodeTimestamp === -1;
2931
2931
  if (r && n && e !== 0)
2932
2932
  throw new Error(
2933
2933
  `The first chunk for your media track must have a timestamp of 0 (received DTS=${e}).Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of thedocument, which is probably what you want.
@@ -2935,13 +2935,13 @@ Bn = function(t, e, i) {
2935
2935
  If you want to offset all timestamps of a track such that the first one is zero, set firstTimestampBehavior: 'offset' in the options.
2936
2936
  `
2937
2937
  );
2938
- if (p(this, P).firstTimestampBehavior === "offset" || p(this, P).firstTimestampBehavior === "cross-track-offset") {
2938
+ if (f(this, P).firstTimestampBehavior === "offset" || f(this, P).firstTimestampBehavior === "cross-track-offset") {
2939
2939
  i.firstDecodeTimestamp === void 0 && (i.firstDecodeTimestamp = e);
2940
- let f;
2941
- p(this, P).firstTimestampBehavior === "offset" ? f = i.firstDecodeTimestamp : f = Math.min(
2942
- ((a = p(this, it)) == null ? void 0 : a.firstDecodeTimestamp) ?? 1 / 0,
2943
- ((o = p(this, tt)) == null ? void 0 : o.firstDecodeTimestamp) ?? 1 / 0
2944
- ), e -= f, t -= f;
2940
+ let p;
2941
+ f(this, P).firstTimestampBehavior === "offset" ? p = i.firstDecodeTimestamp : p = Math.min(
2942
+ ((a = f(this, it)) == null ? void 0 : a.firstDecodeTimestamp) ?? 1 / 0,
2943
+ ((o = f(this, tt)) == null ? void 0 : o.firstDecodeTimestamp) ?? 1 / 0
2944
+ ), e -= p, t -= p;
2945
2945
  }
2946
2946
  if (e < i.lastDecodeTimestamp)
2947
2947
  throw new Error(
@@ -2950,66 +2950,66 @@ If you want to offset all timestamps of a track such that the first one is zero,
2950
2950
  return i.lastDecodeTimestamp = e, { presentationTimestamp: t, decodeTimestamp: e };
2951
2951
  };
2952
2952
  Be = /* @__PURE__ */ new WeakSet();
2953
- bi = function(t) {
2954
- if (p(this, P).fastStart === "fragmented")
2953
+ _i = function(t) {
2954
+ if (f(this, P).fastStart === "fragmented")
2955
2955
  throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");
2956
2956
  if (t.currentChunk) {
2957
- if (t.finalizedChunks.push(t.currentChunk), p(this, oe).push(t.currentChunk), (t.compactlyCodedChunkTable.length === 0 || gi(t.compactlyCodedChunkTable).samplesPerChunk !== t.currentChunk.samples.length) && t.compactlyCodedChunkTable.push({
2957
+ if (t.finalizedChunks.push(t.currentChunk), f(this, oe).push(t.currentChunk), (t.compactlyCodedChunkTable.length === 0 || wi(t.compactlyCodedChunkTable).samplesPerChunk !== t.currentChunk.samples.length) && t.compactlyCodedChunkTable.push({
2958
2958
  firstChunk: t.finalizedChunks.length,
2959
2959
  // 1-indexed
2960
2960
  samplesPerChunk: t.currentChunk.samples.length
2961
- }), p(this, P).fastStart === "in-memory") {
2961
+ }), f(this, P).fastStart === "in-memory") {
2962
2962
  t.currentChunk.offset = 0;
2963
2963
  return;
2964
2964
  }
2965
- t.currentChunk.offset = p(this, B).pos;
2965
+ t.currentChunk.offset = f(this, B).pos;
2966
2966
  for (let e of t.currentChunk.samples)
2967
- p(this, B).write(e.data), e.data = null;
2967
+ f(this, B).write(e.data), e.data = null;
2968
2968
  O(this, ge, Ye).call(this);
2969
2969
  }
2970
2970
  };
2971
- _i = /* @__PURE__ */ new WeakSet();
2971
+ xi = /* @__PURE__ */ new WeakSet();
2972
2972
  _r = function(t = !0) {
2973
- if (p(this, P).fastStart !== "fragmented")
2973
+ if (f(this, P).fastStart !== "fragmented")
2974
2974
  throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");
2975
- let e = [p(this, it), p(this, tt)].filter((o) => o && o.currentChunk);
2975
+ let e = [f(this, it), f(this, tt)].filter((o) => o && o.currentChunk);
2976
2976
  if (e.length === 0)
2977
2977
  return;
2978
- let i = ta(this, wr)._++;
2978
+ let i = ea(this, wr)._++;
2979
2979
  if (i === 1) {
2980
- let o = ni(e, p(this, re), !0);
2981
- p(this, B).writeBox(o);
2980
+ let o = si(e, f(this, re), !0);
2981
+ f(this, B).writeBox(o);
2982
2982
  }
2983
- let r = p(this, B).pos, n = Jr(i, e);
2984
- p(this, B).writeBox(n);
2983
+ let r = f(this, B).pos, n = Jr(i, e);
2984
+ f(this, B).writeBox(n);
2985
2985
  {
2986
- let o = Gi(!1), f = 0;
2986
+ let o = Gi(!1), p = 0;
2987
2987
  for (let v of e)
2988
- for (let u of v.currentChunk.samples)
2989
- f += u.size;
2990
- let g = p(this, B).measureBox(o) + f;
2991
- g >= 2 ** 32 && (o.largeSize = !0, g = p(this, B).measureBox(o) + f), o.size = g, p(this, B).writeBox(o);
2988
+ for (let m of v.currentChunk.samples)
2989
+ p += m.size;
2990
+ let w = f(this, B).measureBox(o) + p;
2991
+ w >= 2 ** 32 && (o.largeSize = !0, w = f(this, B).measureBox(o) + p), o.size = w, f(this, B).writeBox(o);
2992
2992
  }
2993
2993
  for (let o of e) {
2994
- o.currentChunk.offset = p(this, B).pos, o.currentChunk.moofOffset = r;
2995
- for (let f of o.currentChunk.samples)
2996
- p(this, B).write(f.data), f.data = null;
2994
+ o.currentChunk.offset = f(this, B).pos, o.currentChunk.moofOffset = r;
2995
+ for (let p of o.currentChunk.samples)
2996
+ f(this, B).write(p.data), p.data = null;
2997
2997
  }
2998
- let s = p(this, B).pos;
2999
- p(this, B).seek(p(this, B).offsets.get(n));
2998
+ let s = f(this, B).pos;
2999
+ f(this, B).seek(f(this, B).offsets.get(n));
3000
3000
  let a = Jr(i, e);
3001
- p(this, B).writeBox(a), p(this, B).seek(s);
3001
+ f(this, B).writeBox(a), f(this, B).seek(s);
3002
3002
  for (let o of e)
3003
- o.finalizedChunks.push(o.currentChunk), p(this, oe).push(o.currentChunk), o.currentChunk = null;
3003
+ o.finalizedChunks.push(o.currentChunk), f(this, oe).push(o.currentChunk), o.currentChunk = null;
3004
3004
  t && O(this, ge, Ye).call(this);
3005
3005
  };
3006
3006
  ge = /* @__PURE__ */ new WeakSet();
3007
3007
  Ye = function() {
3008
- p(this, B) instanceof gr && p(this, B).flush();
3008
+ f(this, B) instanceof gr && f(this, B).flush();
3009
3009
  };
3010
- li = /* @__PURE__ */ new WeakSet();
3010
+ hi = /* @__PURE__ */ new WeakSet();
3011
3011
  Ji = function() {
3012
- if (p(this, Re))
3012
+ if (f(this, Re))
3013
3013
  throw new Error("Cannot add new video or audio chunks after the file has been finalized.");
3014
3014
  };
3015
3015
  var xr = (t, e, i) => {
@@ -3019,7 +3019,7 @@ var xr = (t, e, i) => {
3019
3019
  if (e.has(t))
3020
3020
  throw TypeError("Cannot add the same private member more than once");
3021
3021
  e instanceof WeakSet ? e.add(t) : e.set(t, i);
3022
- }, F = (t, e, i, r) => (xr(t, e, "write to private field"), e.set(t, i), i), T = (t, e, i) => (xr(t, e, "access private method"), i), Fn = class {
3022
+ }, F = (t, e, i, r) => (xr(t, e, "write to private field"), e.set(t, i), i), T = (t, e, i) => (xr(t, e, "access private method"), i), Dn = class {
3023
3023
  constructor(t) {
3024
3024
  this.value = t;
3025
3025
  }
@@ -3027,7 +3027,7 @@ var xr = (t, e, i) => {
3027
3027
  constructor(t) {
3028
3028
  this.value = t;
3029
3029
  }
3030
- }, Dn = (t) => t < 256 ? 1 : t < 65536 ? 2 : t < 1 << 24 ? 3 : t < 2 ** 32 ? 4 : t < 2 ** 40 ? 5 : 6, oo = (t) => {
3030
+ }, Un = (t) => t < 256 ? 1 : t < 65536 ? 2 : t < 1 << 24 ? 3 : t < 2 ** 32 ? 4 : t < 2 ** 40 ? 5 : 6, lo = (t) => {
3031
3031
  if (t < 127)
3032
3032
  return 1;
3033
3033
  if (t < 16383)
@@ -3044,21 +3044,21 @@ var xr = (t, e, i) => {
3044
3044
  }, Qt = (t, e, i) => {
3045
3045
  let r = 0;
3046
3046
  for (let n = e; n < i; n++) {
3047
- let s = Math.floor(n / 8), a = t[s], o = 7 - (n & 7), f = (a & 1 << o) >> o;
3048
- r <<= 1, r |= f;
3047
+ let s = Math.floor(n / 8), a = t[s], o = 7 - (n & 7), p = (a & 1 << o) >> o;
3048
+ r <<= 1, r |= p;
3049
3049
  }
3050
3050
  return r;
3051
- }, lo = (t, e, i, r) => {
3051
+ }, ho = (t, e, i, r) => {
3052
3052
  for (let n = e; n < i; n++) {
3053
3053
  let s = Math.floor(n / 8), a = t[s], o = 7 - (n & 7);
3054
3054
  a &= ~(1 << o), a |= (r & 1 << i - n - 1) >> i - n - 1 << o, t[s] = a;
3055
3055
  }
3056
- }, Mi = class {
3057
- }, Un = class extends Mi {
3056
+ }, Pi = class {
3057
+ }, Wn = class extends Pi {
3058
3058
  constructor() {
3059
3059
  super(...arguments), this.buffer = null;
3060
3060
  }
3061
- }, Wn = class extends Mi {
3061
+ }, zn = class extends Pi {
3062
3062
  constructor(t) {
3063
3063
  if (super(), this.options = t, typeof t != "object")
3064
3064
  throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");
@@ -3079,7 +3079,7 @@ var xr = (t, e, i) => {
3079
3079
  if (t.chunkSize !== void 0 && (!Number.isInteger(t.chunkSize) || t.chunkSize < 1024))
3080
3080
  throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.");
3081
3081
  }
3082
- }, ho = class extends Mi {
3082
+ }, co = class extends Pi {
3083
3083
  constructor(t, e) {
3084
3084
  if (super(), this.stream = t, this.options = e, !(t instanceof FileSystemWritableFileStream))
3085
3085
  throw new TypeError("FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.");
@@ -3088,14 +3088,14 @@ var xr = (t, e, i) => {
3088
3088
  if (e && e.chunkSize !== void 0 && (!Number.isInteger(e.chunkSize) || e.chunkSize <= 0))
3089
3089
  throw new TypeError("options.chunkSize, when provided, must be a positive integer");
3090
3090
  }
3091
- }, Dt, $, Ki, zn, Zi, On, Qi, Vn, hi, tr, er, Ln, Gn = class {
3091
+ }, Dt, $, Ki, On, Zi, Vn, Qi, Ln, di, tr, er, Gn, Nn = class {
3092
3092
  constructor() {
3093
- x(this, Ki), x(this, Zi), x(this, Qi), x(this, hi), x(this, er), this.pos = 0, x(this, Dt, new Uint8Array(8)), x(this, $, new DataView(h(this, Dt).buffer)), this.offsets = /* @__PURE__ */ new WeakMap(), this.dataOffsets = /* @__PURE__ */ new WeakMap();
3093
+ x(this, Ki), x(this, Zi), x(this, Qi), x(this, di), x(this, er), this.pos = 0, x(this, Dt, new Uint8Array(8)), x(this, $, new DataView(h(this, Dt).buffer)), this.offsets = /* @__PURE__ */ new WeakMap(), this.dataOffsets = /* @__PURE__ */ new WeakMap();
3094
3094
  }
3095
3095
  seek(t) {
3096
3096
  this.pos = t;
3097
3097
  }
3098
- writeEBMLVarInt(t, e = oo(t)) {
3098
+ writeEBMLVarInt(t, e = lo(t)) {
3099
3099
  let i = 0;
3100
3100
  switch (e) {
3101
3101
  case 1:
@@ -3128,36 +3128,36 @@ var xr = (t, e, i) => {
3128
3128
  else if (Array.isArray(t))
3129
3129
  for (let e of t)
3130
3130
  this.writeEBML(e);
3131
- else if (this.offsets.set(t, this.pos), T(this, hi, tr).call(this, t.id), Array.isArray(t.data)) {
3131
+ else if (this.offsets.set(t, this.pos), T(this, di, tr).call(this, t.id), Array.isArray(t.data)) {
3132
3132
  let e = this.pos, i = t.size === -1 ? 1 : t.size ?? 4;
3133
- t.size === -1 ? T(this, Ki, zn).call(this, 255) : this.seek(this.pos + i);
3133
+ t.size === -1 ? T(this, Ki, On).call(this, 255) : this.seek(this.pos + i);
3134
3134
  let r = this.pos;
3135
3135
  if (this.dataOffsets.set(t, r), this.writeEBML(t.data), t.size !== -1) {
3136
3136
  let n = this.pos - r, s = this.pos;
3137
3137
  this.seek(e), this.writeEBMLVarInt(n, i), this.seek(s);
3138
3138
  }
3139
3139
  } else if (typeof t.data == "number") {
3140
- let e = t.size ?? Dn(t.data);
3141
- this.writeEBMLVarInt(e), T(this, hi, tr).call(this, t.data, e);
3142
- } else typeof t.data == "string" ? (this.writeEBMLVarInt(t.data.length), T(this, er, Ln).call(this, t.data)) : t.data instanceof Uint8Array ? (this.writeEBMLVarInt(t.data.byteLength, t.size), this.write(t.data)) : t.data instanceof Fn ? (this.writeEBMLVarInt(4), T(this, Zi, On).call(this, t.data.value)) : t.data instanceof Sr && (this.writeEBMLVarInt(8), T(this, Qi, Vn).call(this, t.data.value));
3140
+ let e = t.size ?? Un(t.data);
3141
+ this.writeEBMLVarInt(e), T(this, di, tr).call(this, t.data, e);
3142
+ } else typeof t.data == "string" ? (this.writeEBMLVarInt(t.data.length), T(this, er, Gn).call(this, t.data)) : t.data instanceof Uint8Array ? (this.writeEBMLVarInt(t.data.byteLength, t.size), this.write(t.data)) : t.data instanceof Dn ? (this.writeEBMLVarInt(4), T(this, Zi, Vn).call(this, t.data.value)) : t.data instanceof Sr && (this.writeEBMLVarInt(8), T(this, Qi, Ln).call(this, t.data.value));
3143
3143
  }
3144
3144
  };
3145
3145
  Dt = /* @__PURE__ */ new WeakMap();
3146
3146
  $ = /* @__PURE__ */ new WeakMap();
3147
3147
  Ki = /* @__PURE__ */ new WeakSet();
3148
- zn = function(t) {
3148
+ On = function(t) {
3149
3149
  h(this, $).setUint8(0, t), this.write(h(this, Dt).subarray(0, 1));
3150
3150
  };
3151
3151
  Zi = /* @__PURE__ */ new WeakSet();
3152
- On = function(t) {
3152
+ Vn = function(t) {
3153
3153
  h(this, $).setFloat32(0, t, !1), this.write(h(this, Dt).subarray(0, 4));
3154
3154
  };
3155
3155
  Qi = /* @__PURE__ */ new WeakSet();
3156
- Vn = function(t) {
3156
+ Ln = function(t) {
3157
3157
  h(this, $).setFloat64(0, t, !1), this.write(h(this, Dt));
3158
3158
  };
3159
- hi = /* @__PURE__ */ new WeakSet();
3160
- tr = function(t, e = Dn(t)) {
3159
+ di = /* @__PURE__ */ new WeakSet();
3160
+ tr = function(t, e = Un(t)) {
3161
3161
  let i = 0;
3162
3162
  switch (e) {
3163
3163
  case 6:
@@ -3179,24 +3179,24 @@ tr = function(t, e = Dn(t)) {
3179
3179
  this.write(h(this, Dt).subarray(0, i));
3180
3180
  };
3181
3181
  er = /* @__PURE__ */ new WeakSet();
3182
- Ln = function(t) {
3182
+ Gn = function(t) {
3183
3183
  this.write(new Uint8Array(t.split("").map((e) => e.charCodeAt(0))));
3184
3184
  };
3185
- var di, Jt, Ne, ci, ir, co = class extends Gn {
3185
+ var ci, Jt, Ne, pi, ir, po = class extends Nn {
3186
3186
  constructor(t) {
3187
- super(), x(this, ci), x(this, di, void 0), x(this, Jt, new ArrayBuffer(2 ** 16)), x(this, Ne, new Uint8Array(h(this, Jt))), F(this, di, t);
3187
+ super(), x(this, pi), x(this, ci, void 0), x(this, Jt, new ArrayBuffer(2 ** 16)), x(this, Ne, new Uint8Array(h(this, Jt))), F(this, ci, t);
3188
3188
  }
3189
3189
  write(t) {
3190
- T(this, ci, ir).call(this, this.pos + t.byteLength), h(this, Ne).set(t, this.pos), this.pos += t.byteLength;
3190
+ T(this, pi, ir).call(this, this.pos + t.byteLength), h(this, Ne).set(t, this.pos), this.pos += t.byteLength;
3191
3191
  }
3192
3192
  finalize() {
3193
- T(this, ci, ir).call(this, this.pos), h(this, di).buffer = h(this, Jt).slice(0, this.pos);
3193
+ T(this, pi, ir).call(this, this.pos), h(this, ci).buffer = h(this, Jt).slice(0, this.pos);
3194
3194
  }
3195
3195
  };
3196
- di = /* @__PURE__ */ new WeakMap();
3196
+ ci = /* @__PURE__ */ new WeakMap();
3197
3197
  Jt = /* @__PURE__ */ new WeakMap();
3198
3198
  Ne = /* @__PURE__ */ new WeakMap();
3199
- ci = /* @__PURE__ */ new WeakSet();
3199
+ pi = /* @__PURE__ */ new WeakSet();
3200
3200
  ir = function(t) {
3201
3201
  let e = h(this, Jt).byteLength;
3202
3202
  for (; e < t; )
@@ -3206,7 +3206,7 @@ ir = function(t) {
3206
3206
  let i = new ArrayBuffer(e), r = new Uint8Array(i);
3207
3207
  r.set(h(this, Ne), 0), F(this, Jt, i), F(this, Ne, r);
3208
3208
  };
3209
- var ie, pt, ft, Nt, Je = class extends Gn {
3209
+ var ie, pt, ft, Nt, Je = class extends Nn {
3210
3210
  constructor(t) {
3211
3211
  super(), this.target = t, x(this, ie, !1), x(this, pt, void 0), x(this, ft, void 0), x(this, Nt, void 0);
3212
3212
  }
@@ -3246,10 +3246,10 @@ ie = /* @__PURE__ */ new WeakMap();
3246
3246
  pt = /* @__PURE__ */ new WeakMap();
3247
3247
  ft = /* @__PURE__ */ new WeakMap();
3248
3248
  Nt = /* @__PURE__ */ new WeakMap();
3249
- var po = 2 ** 24, fo = 2, $t, le, Fe, Ee, Tt, at, xi, rr, Cr, Nn, Er, $n, De, Si, kr = class extends Je {
3249
+ var fo = 2 ** 24, uo = 2, $t, le, Fe, Ee, Tt, at, Si, rr, Cr, $n, Er, jn, De, Ci, kr = class extends Je {
3250
3250
  constructor(t, e) {
3251
3251
  var i, r;
3252
- super(t), x(this, xi), x(this, Cr), x(this, Er), x(this, De), x(this, $t, []), x(this, le, 0), x(this, Fe, void 0), x(this, Ee, void 0), x(this, Tt, void 0), x(this, at, []), F(this, Fe, e), F(this, Ee, ((i = t.options) == null ? void 0 : i.chunked) ?? !1), F(this, Tt, ((r = t.options) == null ? void 0 : r.chunkSize) ?? po);
3252
+ super(t), x(this, Si), x(this, Cr), x(this, Er), x(this, De), x(this, $t, []), x(this, le, 0), x(this, Fe, void 0), x(this, Ee, void 0), x(this, Tt, void 0), x(this, at, []), F(this, Fe, e), F(this, Ee, ((i = t.options) == null ? void 0 : i.chunked) ?? !1), F(this, Tt, ((r = t.options) == null ? void 0 : r.chunkSize) ?? fo);
3253
3253
  }
3254
3254
  write(t) {
3255
3255
  super.write(t), h(this, $t).push({
@@ -3278,7 +3278,7 @@ var po = 2 ** 24, fo = 2, $t, le, Fe, Ee, Tt, at, xi, rr, Cr, Nn, Er, $n, De, Si
3278
3278
  for (let s of h(this, $t))
3279
3279
  n.start <= s.start && s.start < n.start + n.size && n.data.set(s.data, s.start - n.start);
3280
3280
  if (h(this, Ee))
3281
- T(this, xi, rr).call(this, n.data, n.start), T(this, De, Si).call(this);
3281
+ T(this, Si, rr).call(this, n.data, n.start), T(this, De, Ci).call(this);
3282
3282
  else {
3283
3283
  if (h(this, Fe) && n.start < h(this, le))
3284
3284
  throw new Error("Internal error: Monotonicity violation.");
@@ -3288,7 +3288,7 @@ var po = 2 ** 24, fo = 2, $t, le, Fe, Ee, Tt, at, xi, rr, Cr, Nn, Er, $n, De, Si
3288
3288
  h(this, $t).length = 0;
3289
3289
  }
3290
3290
  finalize() {
3291
- h(this, Ee) && T(this, De, Si).call(this, !0);
3291
+ h(this, Ee) && T(this, De, Ci).call(this, !0);
3292
3292
  }
3293
3293
  };
3294
3294
  $t = /* @__PURE__ */ new WeakMap();
@@ -3297,25 +3297,25 @@ Fe = /* @__PURE__ */ new WeakMap();
3297
3297
  Ee = /* @__PURE__ */ new WeakMap();
3298
3298
  Tt = /* @__PURE__ */ new WeakMap();
3299
3299
  at = /* @__PURE__ */ new WeakMap();
3300
- xi = /* @__PURE__ */ new WeakSet();
3300
+ Si = /* @__PURE__ */ new WeakSet();
3301
3301
  rr = function(t, e) {
3302
3302
  let i = h(this, at).findIndex((o) => o.start <= e && e < o.start + h(this, Tt));
3303
- i === -1 && (i = T(this, Er, $n).call(this, e));
3303
+ i === -1 && (i = T(this, Er, jn).call(this, e));
3304
3304
  let r = h(this, at)[i], n = e - r.start, s = t.subarray(0, Math.min(h(this, Tt) - n, t.byteLength));
3305
3305
  r.data.set(s, n);
3306
3306
  let a = {
3307
3307
  start: n,
3308
3308
  end: n + s.byteLength
3309
3309
  };
3310
- if (T(this, Cr, Nn).call(this, r, a), r.written[0].start === 0 && r.written[0].end === h(this, Tt) && (r.shouldFlush = !0), h(this, at).length > fo) {
3310
+ if (T(this, Cr, $n).call(this, r, a), r.written[0].start === 0 && r.written[0].end === h(this, Tt) && (r.shouldFlush = !0), h(this, at).length > uo) {
3311
3311
  for (let o = 0; o < h(this, at).length - 1; o++)
3312
3312
  h(this, at)[o].shouldFlush = !0;
3313
- T(this, De, Si).call(this);
3313
+ T(this, De, Ci).call(this);
3314
3314
  }
3315
- s.byteLength < t.byteLength && T(this, xi, rr).call(this, t.subarray(s.byteLength), e + s.byteLength);
3315
+ s.byteLength < t.byteLength && T(this, Si, rr).call(this, t.subarray(s.byteLength), e + s.byteLength);
3316
3316
  };
3317
3317
  Cr = /* @__PURE__ */ new WeakSet();
3318
- Nn = function(t, e) {
3318
+ $n = function(t, e) {
3319
3319
  let i = 0, r = t.written.length - 1, n = -1;
3320
3320
  for (; i <= r; ) {
3321
3321
  let s = Math.floor(i + (r - i + 1) / 2);
@@ -3325,7 +3325,7 @@ Nn = function(t, e) {
3325
3325
  t.written[n].end = Math.max(t.written[n].end, t.written[n + 1].end), t.written.splice(n + 1, 1);
3326
3326
  };
3327
3327
  Er = /* @__PURE__ */ new WeakSet();
3328
- $n = function(t) {
3328
+ jn = function(t) {
3329
3329
  let i = {
3330
3330
  start: Math.floor(t / h(this, Tt)) * h(this, Tt),
3331
3331
  data: new Uint8Array(h(this, Tt)),
@@ -3335,7 +3335,7 @@ $n = function(t) {
3335
3335
  return h(this, at).push(i), h(this, at).sort((r, n) => r.start - n.start), h(this, at).indexOf(i);
3336
3336
  };
3337
3337
  De = /* @__PURE__ */ new WeakSet();
3338
- Si = function(t = !1) {
3338
+ Ci = function(t = !1) {
3339
3339
  var e, i;
3340
3340
  for (let r = 0; r < h(this, at).length; r++) {
3341
3341
  let n = h(this, at)[r];
@@ -3353,10 +3353,10 @@ Si = function(t = !1) {
3353
3353
  }
3354
3354
  }
3355
3355
  };
3356
- var uo = class extends kr {
3356
+ var mo = class extends kr {
3357
3357
  constructor(t, e) {
3358
3358
  var i;
3359
- super(new Wn({
3359
+ super(new zn({
3360
3360
  onData: (r, n) => t.stream.write({
3361
3361
  type: "write",
3362
3362
  data: r,
@@ -3366,23 +3366,23 @@ var uo = class extends kr {
3366
3366
  chunkSize: (i = t.options) == null ? void 0 : i.chunkSize
3367
3367
  }), e);
3368
3368
  }
3369
- }, we = 1, $e = 2, Ci = 3, mo = 1, go = 2, wo = 17, vo = 2 ** 15, Ue = 2 ** 13, Kr = "https://github.com/Vanilagy/webm-muxer", jn = 6, Hn = 5, yo = ["strict", "offset", "permissive"], R, A, je, He, xt, ve, ne, Kt, ye, Ut, he, de, gt, Ke, ce, Rt, Bt, jt, We, ze, pe, fe, Ei, qe, Oe, nr, qn, sr, Xn, Tr, Yn, Ar, Jn, Mr, Kn, Pr, Zn, Ir, Qn, Pi, Rr, Ii, Br, Fr, ts, Ht, se, qt, ae, ar, es, or, is, ke, pi, Te, fi, Dr, rs, ut, _t, ue, Xe, Ve, ki, Ur, ns, Ti, Wr, Ae, ui, bo = class {
3369
+ }, we = 1, $e = 2, Ei = 3, go = 1, wo = 2, vo = 17, yo = 2 ** 15, Ue = 2 ** 13, Kr = "https://github.com/Vanilagy/webm-muxer", Hn = 6, qn = 5, bo = ["strict", "offset", "permissive"], R, A, je, He, xt, ve, ne, Kt, ye, Ut, he, de, gt, Ke, ce, Rt, Bt, jt, We, ze, pe, fe, ki, qe, Oe, nr, Xn, sr, Yn, Tr, Jn, Ar, Kn, Mr, Zn, Pr, Qn, Ir, ts, Ii, Rr, Ri, Br, Fr, es, Ht, se, qt, ae, ar, is, or, rs, ke, fi, Te, ui, Dr, ns, ut, _t, ue, Xe, Ve, Ti, Ur, ss, Ai, Wr, Ae, mi, _o = class {
3370
3370
  constructor(t) {
3371
- x(this, nr), x(this, sr), x(this, Tr), x(this, Ar), x(this, Mr), x(this, Pr), x(this, Ir), x(this, Pi), x(this, Ii), x(this, Fr), x(this, Ht), x(this, qt), x(this, ar), x(this, or), x(this, ke), x(this, Te), x(this, Dr), x(this, ut), x(this, ue), x(this, Ve), x(this, Ur), x(this, Ti), x(this, Ae), x(this, R, void 0), x(this, A, void 0), x(this, je, void 0), x(this, He, void 0), x(this, xt, void 0), x(this, ve, void 0), x(this, ne, void 0), x(this, Kt, void 0), x(this, ye, void 0), x(this, Ut, void 0), x(this, he, void 0), x(this, de, void 0), x(this, gt, void 0), x(this, Ke, void 0), x(this, ce, 0), x(this, Rt, []), x(this, Bt, []), x(this, jt, []), x(this, We, void 0), x(this, ze, void 0), x(this, pe, -1), x(this, fe, -1), x(this, Ei, -1), x(this, qe, void 0), x(this, Oe, !1), T(this, nr, qn).call(this, t), F(this, R, {
3371
+ x(this, nr), x(this, sr), x(this, Tr), x(this, Ar), x(this, Mr), x(this, Pr), x(this, Ir), x(this, Ii), x(this, Ri), x(this, Fr), x(this, Ht), x(this, qt), x(this, ar), x(this, or), x(this, ke), x(this, Te), x(this, Dr), x(this, ut), x(this, ue), x(this, Ve), x(this, Ur), x(this, Ai), x(this, Ae), x(this, R, void 0), x(this, A, void 0), x(this, je, void 0), x(this, He, void 0), x(this, xt, void 0), x(this, ve, void 0), x(this, ne, void 0), x(this, Kt, void 0), x(this, ye, void 0), x(this, Ut, void 0), x(this, he, void 0), x(this, de, void 0), x(this, gt, void 0), x(this, Ke, void 0), x(this, ce, 0), x(this, Rt, []), x(this, Bt, []), x(this, jt, []), x(this, We, void 0), x(this, ze, void 0), x(this, pe, -1), x(this, fe, -1), x(this, ki, -1), x(this, qe, void 0), x(this, Oe, !1), T(this, nr, Xn).call(this, t), F(this, R, {
3372
3372
  type: "webm",
3373
3373
  firstTimestampBehavior: "strict",
3374
3374
  ...t
3375
3375
  }), this.target = t.target;
3376
3376
  let e = !!h(this, R).streaming;
3377
- if (t.target instanceof Un)
3378
- F(this, A, new co(t.target));
3379
- else if (t.target instanceof Wn)
3377
+ if (t.target instanceof Wn)
3378
+ F(this, A, new po(t.target));
3379
+ else if (t.target instanceof zn)
3380
3380
  F(this, A, new kr(t.target, e));
3381
- else if (t.target instanceof ho)
3382
- F(this, A, new uo(t.target, e));
3381
+ else if (t.target instanceof co)
3382
+ F(this, A, new mo(t.target, e));
3383
3383
  else
3384
3384
  throw new Error(`Invalid target: ${t.target}`);
3385
- T(this, sr, Xn).call(this);
3385
+ T(this, sr, Yn).call(this);
3386
3386
  }
3387
3387
  addVideoChunk(t, e, i) {
3388
3388
  if (!(t instanceof EncodedVideoChunk))
@@ -3405,15 +3405,15 @@ var uo = class extends kr {
3405
3405
  throw new TypeError("addVideoChunkRaw's third argument (timestamp) must be a non-negative real number.");
3406
3406
  if (r && typeof r != "object")
3407
3407
  throw new TypeError("addVideoChunkRaw's fourth argument (meta), when provided, must be an object.");
3408
- if (T(this, Ae, ui).call(this), !h(this, R).video)
3408
+ if (T(this, Ae, mi).call(this), !h(this, R).video)
3409
3409
  throw new Error("No video track declared.");
3410
- h(this, We) === void 0 && F(this, We, i), r && T(this, ar, es).call(this, r);
3411
- let n = T(this, Te, fi).call(this, t, e, i, we);
3412
- for (h(this, R).video.codec === "V_VP9" && T(this, or, is).call(this, n), F(this, pe, n.timestamp); h(this, Bt).length > 0 && h(this, Bt)[0].timestamp <= n.timestamp; ) {
3410
+ h(this, We) === void 0 && F(this, We, i), r && T(this, ar, is).call(this, r);
3411
+ let n = T(this, Te, ui).call(this, t, e, i, we);
3412
+ for (h(this, R).video.codec === "V_VP9" && T(this, or, rs).call(this, n), F(this, pe, n.timestamp); h(this, Bt).length > 0 && h(this, Bt)[0].timestamp <= n.timestamp; ) {
3413
3413
  let s = h(this, Bt).shift();
3414
3414
  T(this, ut, _t).call(this, s, !1);
3415
3415
  }
3416
- !h(this, R).audio || n.timestamp <= h(this, fe) ? T(this, ut, _t).call(this, n, !0) : h(this, Rt).push(n), T(this, ke, pi).call(this), T(this, Ht, se).call(this);
3416
+ !h(this, R).audio || n.timestamp <= h(this, fe) ? T(this, ut, _t).call(this, n, !0) : h(this, Rt).push(n), T(this, ke, fi).call(this), T(this, Ht, se).call(this);
3417
3417
  }
3418
3418
  addAudioChunk(t, e, i) {
3419
3419
  if (!(t instanceof EncodedAudioChunk))
@@ -3436,15 +3436,15 @@ var uo = class extends kr {
3436
3436
  throw new TypeError("addAudioChunkRaw's third argument (timestamp) must be a non-negative real number.");
3437
3437
  if (r && typeof r != "object")
3438
3438
  throw new TypeError("addAudioChunkRaw's fourth argument (meta), when provided, must be an object.");
3439
- if (T(this, Ae, ui).call(this), !h(this, R).audio)
3439
+ if (T(this, Ae, mi).call(this), !h(this, R).audio)
3440
3440
  throw new Error("No audio track declared.");
3441
- h(this, ze) === void 0 && F(this, ze, i), r != null && r.decoderConfig && (h(this, R).streaming ? F(this, Ut, T(this, ue, Xe).call(this, r.decoderConfig.description)) : T(this, Ve, ki).call(this, h(this, Ut), r.decoderConfig.description));
3442
- let n = T(this, Te, fi).call(this, t, e, i, $e);
3441
+ h(this, ze) === void 0 && F(this, ze, i), r != null && r.decoderConfig && (h(this, R).streaming ? F(this, Ut, T(this, ue, Xe).call(this, r.decoderConfig.description)) : T(this, Ve, Ti).call(this, h(this, Ut), r.decoderConfig.description));
3442
+ let n = T(this, Te, ui).call(this, t, e, i, $e);
3443
3443
  for (F(this, fe, n.timestamp); h(this, Rt).length > 0 && h(this, Rt)[0].timestamp <= n.timestamp; ) {
3444
3444
  let s = h(this, Rt).shift();
3445
3445
  T(this, ut, _t).call(this, s, !0);
3446
3446
  }
3447
- !h(this, R).video || n.timestamp <= h(this, pe) ? T(this, ut, _t).call(this, n, !h(this, R).video) : h(this, Bt).push(n), T(this, ke, pi).call(this), T(this, Ht, se).call(this);
3447
+ !h(this, R).video || n.timestamp <= h(this, pe) ? T(this, ut, _t).call(this, n, !h(this, R).video) : h(this, Bt).push(n), T(this, ke, fi).call(this), T(this, Ht, se).call(this);
3448
3448
  }
3449
3449
  addSubtitleChunk(t, e, i) {
3450
3450
  if (typeof t != "object" || !t)
@@ -3459,11 +3459,11 @@ var uo = class extends kr {
3459
3459
  throw new TypeError("additions, when present, must be an instance of Uint8Array.");
3460
3460
  if (typeof e != "object")
3461
3461
  throw new TypeError("addSubtitleChunk's second argument (meta) must be an object.");
3462
- if (T(this, Ae, ui).call(this), !h(this, R).subtitles)
3462
+ if (T(this, Ae, mi).call(this), !h(this, R).subtitles)
3463
3463
  throw new Error("No subtitle track declared.");
3464
- e != null && e.decoderConfig && (h(this, R).streaming ? F(this, he, T(this, ue, Xe).call(this, e.decoderConfig.description)) : T(this, Ve, ki).call(this, h(this, he), e.decoderConfig.description));
3465
- let r = T(this, Te, fi).call(this, t.body, "key", i ?? t.timestamp, Ci, t.duration, t.additions);
3466
- F(this, Ei, r.timestamp), h(this, jt).push(r), T(this, ke, pi).call(this), T(this, Ht, se).call(this);
3464
+ e != null && e.decoderConfig && (h(this, R).streaming ? F(this, he, T(this, ue, Xe).call(this, e.decoderConfig.description)) : T(this, Ve, Ti).call(this, h(this, he), e.decoderConfig.description));
3465
+ let r = T(this, Te, ui).call(this, t.body, "key", i ?? t.timestamp, Ei, t.duration, t.additions);
3466
+ F(this, ki, r.timestamp), h(this, jt).push(r), T(this, ke, fi).call(this), T(this, Ht, se).call(this);
3467
3467
  }
3468
3468
  finalize() {
3469
3469
  if (h(this, Oe))
@@ -3474,9 +3474,9 @@ var uo = class extends kr {
3474
3474
  T(this, ut, _t).call(this, h(this, Bt).shift(), !0);
3475
3475
  for (; h(this, jt).length > 0 && h(this, jt)[0].timestamp <= h(this, ce); )
3476
3476
  T(this, ut, _t).call(this, h(this, jt).shift(), !1);
3477
- if (h(this, gt) && T(this, Ti, Wr).call(this), h(this, A).writeEBML(h(this, de)), !h(this, R).streaming) {
3477
+ if (h(this, gt) && T(this, Ai, Wr).call(this), h(this, A).writeEBML(h(this, de)), !h(this, R).streaming) {
3478
3478
  let t = h(this, A).pos, e = h(this, A).pos - h(this, qt, ae);
3479
- h(this, A).seek(h(this, A).offsets.get(h(this, je)) + 4), h(this, A).writeEBMLVarInt(e, jn), h(this, ne).data = new Sr(h(this, ce)), h(this, A).seek(h(this, A).offsets.get(h(this, ne))), h(this, A).writeEBML(h(this, ne)), h(this, xt).data[0].data[1].data = h(this, A).offsets.get(h(this, de)) - h(this, qt, ae), h(this, xt).data[1].data[1].data = h(this, A).offsets.get(h(this, He)) - h(this, qt, ae), h(this, xt).data[2].data[1].data = h(this, A).offsets.get(h(this, ve)) - h(this, qt, ae), h(this, A).seek(h(this, A).offsets.get(h(this, xt))), h(this, A).writeEBML(h(this, xt)), h(this, A).seek(t);
3479
+ h(this, A).seek(h(this, A).offsets.get(h(this, je)) + 4), h(this, A).writeEBMLVarInt(e, Hn), h(this, ne).data = new Sr(h(this, ce)), h(this, A).seek(h(this, A).offsets.get(h(this, ne))), h(this, A).writeEBML(h(this, ne)), h(this, xt).data[0].data[1].data = h(this, A).offsets.get(h(this, de)) - h(this, qt, ae), h(this, xt).data[1].data[1].data = h(this, A).offsets.get(h(this, He)) - h(this, qt, ae), h(this, xt).data[2].data[1].data = h(this, A).offsets.get(h(this, ve)) - h(this, qt, ae), h(this, A).seek(h(this, A).offsets.get(h(this, xt))), h(this, A).writeEBML(h(this, xt)), h(this, A).seek(t);
3480
3480
  }
3481
3481
  T(this, Ht, se).call(this), h(this, A).finalize(), F(this, Oe, !0);
3482
3482
  }
@@ -3503,14 +3503,14 @@ We = /* @__PURE__ */ new WeakMap();
3503
3503
  ze = /* @__PURE__ */ new WeakMap();
3504
3504
  pe = /* @__PURE__ */ new WeakMap();
3505
3505
  fe = /* @__PURE__ */ new WeakMap();
3506
- Ei = /* @__PURE__ */ new WeakMap();
3506
+ ki = /* @__PURE__ */ new WeakMap();
3507
3507
  qe = /* @__PURE__ */ new WeakMap();
3508
3508
  Oe = /* @__PURE__ */ new WeakMap();
3509
3509
  nr = /* @__PURE__ */ new WeakSet();
3510
- qn = function(t) {
3510
+ Xn = function(t) {
3511
3511
  if (typeof t != "object")
3512
3512
  throw new TypeError("The muxer requires an options object to be passed to its constructor.");
3513
- if (!(t.target instanceof Mi))
3513
+ if (!(t.target instanceof Pi))
3514
3514
  throw new TypeError("The target must be provided and an instance of Target.");
3515
3515
  if (t.video) {
3516
3516
  if (typeof t.video.codec != "string")
@@ -3546,17 +3546,17 @@ qn = function(t) {
3546
3546
  throw new TypeError(`Invalid subtitles codec: ${t.subtitles.codec}. Must be a string.`);
3547
3547
  if (t.type !== void 0 && !["webm", "matroska"].includes(t.type))
3548
3548
  throw new TypeError(`Invalid type: ${t.type}. Must be 'webm' or 'matroska'.`);
3549
- if (t.firstTimestampBehavior && !yo.includes(t.firstTimestampBehavior))
3549
+ if (t.firstTimestampBehavior && !bo.includes(t.firstTimestampBehavior))
3550
3550
  throw new TypeError(`Invalid first timestamp behavior: ${t.firstTimestampBehavior}`);
3551
3551
  if (t.streaming !== void 0 && typeof t.streaming != "boolean")
3552
3552
  throw new TypeError(`Invalid streaming option: ${t.streaming}. Must be a boolean.`);
3553
3553
  };
3554
3554
  sr = /* @__PURE__ */ new WeakSet();
3555
- Xn = function() {
3556
- h(this, A) instanceof Je && h(this, A).target.options.onHeader && h(this, A).startTrackingWrites(), T(this, Tr, Yn).call(this), h(this, R).streaming || T(this, Pr, Zn).call(this), T(this, Ir, Qn).call(this), T(this, Ar, Jn).call(this), T(this, Mr, Kn).call(this), h(this, R).streaming || (T(this, Pi, Rr).call(this), T(this, Ii, Br).call(this)), T(this, Fr, ts).call(this), T(this, Ht, se).call(this);
3555
+ Yn = function() {
3556
+ h(this, A) instanceof Je && h(this, A).target.options.onHeader && h(this, A).startTrackingWrites(), T(this, Tr, Jn).call(this), h(this, R).streaming || T(this, Pr, Qn).call(this), T(this, Ir, ts).call(this), T(this, Ar, Kn).call(this), T(this, Mr, Zn).call(this), h(this, R).streaming || (T(this, Ii, Rr).call(this), T(this, Ri, Br).call(this)), T(this, Fr, es).call(this), T(this, Ht, se).call(this);
3557
3557
  };
3558
3558
  Tr = /* @__PURE__ */ new WeakSet();
3559
- Yn = function() {
3559
+ Jn = function() {
3560
3560
  let t = { id: 440786851, data: [
3561
3561
  { id: 17030, data: 1 },
3562
3562
  { id: 17143, data: 1 },
@@ -3569,11 +3569,11 @@ Yn = function() {
3569
3569
  h(this, A).writeEBML(t);
3570
3570
  };
3571
3571
  Ar = /* @__PURE__ */ new WeakSet();
3572
- Jn = function() {
3572
+ Kn = function() {
3573
3573
  F(this, ye, { id: 236, size: 4, data: new Uint8Array(Ue) }), F(this, Ut, { id: 236, size: 4, data: new Uint8Array(Ue) }), F(this, he, { id: 236, size: 4, data: new Uint8Array(Ue) });
3574
3574
  };
3575
3575
  Mr = /* @__PURE__ */ new WeakSet();
3576
- Kn = function() {
3576
+ Zn = function() {
3577
3577
  F(this, Kt, { id: 21936, data: [
3578
3578
  { id: 21937, data: 2 },
3579
3579
  { id: 21946, data: 2 },
@@ -3582,7 +3582,7 @@ Kn = function() {
3582
3582
  ] });
3583
3583
  };
3584
3584
  Pr = /* @__PURE__ */ new WeakSet();
3585
- Zn = function() {
3585
+ Qn = function() {
3586
3586
  const t = new Uint8Array([28, 83, 187, 107]), e = new Uint8Array([21, 73, 169, 102]), i = new Uint8Array([22, 84, 174, 107]);
3587
3587
  F(this, xt, { id: 290298740, data: [
3588
3588
  { id: 19899, data: [
@@ -3600,7 +3600,7 @@ Zn = function() {
3600
3600
  ] });
3601
3601
  };
3602
3602
  Ir = /* @__PURE__ */ new WeakSet();
3603
- Qn = function() {
3603
+ ts = function() {
3604
3604
  let t = { id: 17545, data: new Sr(0) };
3605
3605
  F(this, ne, t);
3606
3606
  let e = { id: 357149030, data: [
@@ -3611,13 +3611,13 @@ Qn = function() {
3611
3611
  ] };
3612
3612
  F(this, He, e);
3613
3613
  };
3614
- Pi = /* @__PURE__ */ new WeakSet();
3614
+ Ii = /* @__PURE__ */ new WeakSet();
3615
3615
  Rr = function() {
3616
3616
  let t = { id: 374648427, data: [] };
3617
3617
  F(this, ve, t), h(this, R).video && t.data.push({ id: 174, data: [
3618
3618
  { id: 215, data: we },
3619
3619
  { id: 29637, data: we },
3620
- { id: 131, data: mo },
3620
+ { id: 131, data: go },
3621
3621
  { id: 134, data: h(this, R).video.codec },
3622
3622
  h(this, ye),
3623
3623
  h(this, R).video.frameRate ? { id: 2352003, data: 1e9 / h(this, R).video.frameRate } : null,
@@ -3630,27 +3630,27 @@ Rr = function() {
3630
3630
  ] }), h(this, R).audio && (F(this, Ut, h(this, R).streaming ? h(this, Ut) || null : { id: 236, size: 4, data: new Uint8Array(Ue) }), t.data.push({ id: 174, data: [
3631
3631
  { id: 215, data: $e },
3632
3632
  { id: 29637, data: $e },
3633
- { id: 131, data: go },
3633
+ { id: 131, data: wo },
3634
3634
  { id: 134, data: h(this, R).audio.codec },
3635
3635
  h(this, Ut),
3636
3636
  { id: 225, data: [
3637
- { id: 181, data: new Fn(h(this, R).audio.sampleRate) },
3637
+ { id: 181, data: new Dn(h(this, R).audio.sampleRate) },
3638
3638
  { id: 159, data: h(this, R).audio.numberOfChannels },
3639
3639
  h(this, R).audio.bitDepth ? { id: 25188, data: h(this, R).audio.bitDepth } : null
3640
3640
  ] }
3641
3641
  ] })), h(this, R).subtitles && t.data.push({ id: 174, data: [
3642
- { id: 215, data: Ci },
3643
- { id: 29637, data: Ci },
3644
- { id: 131, data: wo },
3642
+ { id: 215, data: Ei },
3643
+ { id: 29637, data: Ei },
3644
+ { id: 131, data: vo },
3645
3645
  { id: 134, data: h(this, R).subtitles.codec },
3646
3646
  h(this, he)
3647
3647
  ] });
3648
3648
  };
3649
- Ii = /* @__PURE__ */ new WeakSet();
3649
+ Ri = /* @__PURE__ */ new WeakSet();
3650
3650
  Br = function() {
3651
3651
  let t = {
3652
3652
  id: 408125543,
3653
- size: h(this, R).streaming ? -1 : jn,
3653
+ size: h(this, R).streaming ? -1 : Hn,
3654
3654
  data: [
3655
3655
  h(this, R).streaming ? null : h(this, xt),
3656
3656
  h(this, He),
@@ -3663,7 +3663,7 @@ Br = function() {
3663
3663
  }
3664
3664
  };
3665
3665
  Fr = /* @__PURE__ */ new WeakSet();
3666
- ts = function() {
3666
+ es = function() {
3667
3667
  F(this, de, { id: 475249515, data: [] });
3668
3668
  };
3669
3669
  Ht = /* @__PURE__ */ new WeakSet();
@@ -3675,7 +3675,7 @@ ae = function() {
3675
3675
  return h(this, A).dataOffsets.get(h(this, je));
3676
3676
  };
3677
3677
  ar = /* @__PURE__ */ new WeakSet();
3678
- es = function(t) {
3678
+ is = function(t) {
3679
3679
  if (t.decoderConfig) {
3680
3680
  if (t.decoderConfig.colorSpace) {
3681
3681
  let e = t.decoderConfig.colorSpace;
@@ -3702,11 +3702,11 @@ es = function(t) {
3702
3702
  h(this, A).seek(h(this, A).offsets.get(h(this, Kt))), h(this, A).writeEBML(h(this, Kt)), h(this, A).seek(i);
3703
3703
  }
3704
3704
  }
3705
- t.decoderConfig.description && (h(this, R).streaming ? F(this, ye, T(this, ue, Xe).call(this, t.decoderConfig.description)) : T(this, Ve, ki).call(this, h(this, ye), t.decoderConfig.description));
3705
+ t.decoderConfig.description && (h(this, R).streaming ? F(this, ye, T(this, ue, Xe).call(this, t.decoderConfig.description)) : T(this, Ve, Ti).call(this, h(this, ye), t.decoderConfig.description));
3706
3706
  }
3707
3707
  };
3708
3708
  or = /* @__PURE__ */ new WeakSet();
3709
- is = function(t) {
3709
+ rs = function(t) {
3710
3710
  if (t.type !== "key" || !h(this, qe))
3711
3711
  return;
3712
3712
  let e = 0;
@@ -3732,10 +3732,10 @@ is = function(t) {
3732
3732
  bt470bg: 1,
3733
3733
  smpte170m: 3
3734
3734
  }[h(this, qe).matrix];
3735
- lo(t.data, e + 0, e + 3, a);
3735
+ ho(t.data, e + 0, e + 3, a);
3736
3736
  };
3737
3737
  ke = /* @__PURE__ */ new WeakSet();
3738
- pi = function() {
3738
+ fi = function() {
3739
3739
  let t = Math.min(
3740
3740
  h(this, R).video ? h(this, pe) : 1 / 0,
3741
3741
  h(this, R).audio ? h(this, fe) : 1 / 0
@@ -3744,8 +3744,8 @@ pi = function() {
3744
3744
  T(this, ut, _t).call(this, e.shift(), !h(this, R).video && !h(this, R).audio);
3745
3745
  };
3746
3746
  Te = /* @__PURE__ */ new WeakSet();
3747
- fi = function(t, e, i, r, n, s) {
3748
- let a = T(this, Dr, rs).call(this, i, r);
3747
+ ui = function(t, e, i, r, n, s) {
3748
+ let a = T(this, Dr, ns).call(this, i, r);
3749
3749
  return {
3750
3750
  data: t,
3751
3751
  additions: s,
@@ -3756,9 +3756,9 @@ fi = function(t, e, i, r, n, s) {
3756
3756
  };
3757
3757
  };
3758
3758
  Dr = /* @__PURE__ */ new WeakSet();
3759
- rs = function(t, e) {
3760
- let i = e === we ? h(this, pe) : e === $e ? h(this, fe) : h(this, Ei);
3761
- if (e !== Ci) {
3759
+ ns = function(t, e) {
3760
+ let i = e === we ? h(this, pe) : e === $e ? h(this, fe) : h(this, ki);
3761
+ if (e !== Ei) {
3762
3762
  let r = e === we ? h(this, We) : h(this, ze);
3763
3763
  if (h(this, R).firstTimestampBehavior === "strict" && i === -1 && t !== 0)
3764
3764
  throw new Error(
@@ -3780,28 +3780,28 @@ If you want to allow non-zero first timestamps, set firstTimestampBehavior: 'per
3780
3780
  };
3781
3781
  ut = /* @__PURE__ */ new WeakSet();
3782
3782
  _t = function(t, e) {
3783
- h(this, R).streaming && !h(this, ve) && (T(this, Pi, Rr).call(this), T(this, Ii, Br).call(this));
3784
- let i = Math.floor(t.timestamp / 1e3), r = i - h(this, Ke), n = e && t.type === "key" && r >= 1e3, s = r >= vo;
3785
- if ((!h(this, gt) || n || s) && (T(this, Ur, ns).call(this, i), r = 0), r < 0)
3783
+ h(this, R).streaming && !h(this, ve) && (T(this, Ii, Rr).call(this), T(this, Ri, Br).call(this));
3784
+ let i = Math.floor(t.timestamp / 1e3), r = i - h(this, Ke), n = e && t.type === "key" && r >= 1e3, s = r >= yo;
3785
+ if ((!h(this, gt) || n || s) && (T(this, Ur, ss).call(this, i), r = 0), r < 0)
3786
3786
  return;
3787
3787
  let a = new Uint8Array(4), o = new DataView(a.buffer);
3788
3788
  if (o.setUint8(0, 128 | t.trackNumber), o.setInt16(1, r, !1), t.duration === void 0 && !t.additions) {
3789
3789
  o.setUint8(3, +(t.type === "key") << 7);
3790
- let f = { id: 163, data: [
3790
+ let p = { id: 163, data: [
3791
3791
  a,
3792
3792
  t.data
3793
3793
  ] };
3794
- h(this, A).writeEBML(f);
3794
+ h(this, A).writeEBML(p);
3795
3795
  } else {
3796
- let f = Math.floor(t.duration / 1e3), g = { id: 160, data: [
3796
+ let p = Math.floor(t.duration / 1e3), w = { id: 160, data: [
3797
3797
  { id: 161, data: [
3798
3798
  a,
3799
3799
  t.data
3800
3800
  ] },
3801
- t.duration !== void 0 ? { id: 155, data: f } : null,
3801
+ t.duration !== void 0 ? { id: 155, data: p } : null,
3802
3802
  t.additions ? { id: 30113, data: t.additions } : null
3803
3803
  ] };
3804
- h(this, A).writeEBML(g);
3804
+ h(this, A).writeEBML(w);
3805
3805
  }
3806
3806
  F(this, ce, Math.max(h(this, ce), i));
3807
3807
  };
@@ -3810,7 +3810,7 @@ Xe = function(t) {
3810
3810
  return { id: 25506, size: 4, data: new Uint8Array(t) };
3811
3811
  };
3812
3812
  Ve = /* @__PURE__ */ new WeakSet();
3813
- ki = function(t, e) {
3813
+ Ti = function(t, e) {
3814
3814
  let i = h(this, A).pos;
3815
3815
  h(this, A).seek(h(this, A).offsets.get(t));
3816
3816
  let r = 6 + e.byteLength, n = Ue - r;
@@ -3824,10 +3824,10 @@ ki = function(t, e) {
3824
3824
  ], h(this, A).writeEBML(t), h(this, A).seek(i);
3825
3825
  };
3826
3826
  Ur = /* @__PURE__ */ new WeakSet();
3827
- ns = function(t) {
3828
- h(this, gt) && T(this, Ti, Wr).call(this), h(this, A) instanceof Je && h(this, A).target.options.onCluster && h(this, A).startTrackingWrites(), F(this, gt, {
3827
+ ss = function(t) {
3828
+ h(this, gt) && T(this, Ai, Wr).call(this), h(this, A) instanceof Je && h(this, A).target.options.onCluster && h(this, A).startTrackingWrites(), F(this, gt, {
3829
3829
  id: 524531317,
3830
- size: h(this, R).streaming ? -1 : Hn,
3830
+ size: h(this, R).streaming ? -1 : qn,
3831
3831
  data: [
3832
3832
  { id: 231, data: t }
3833
3833
  ]
@@ -3845,11 +3845,11 @@ ns = function(t) {
3845
3845
  ] } : null
3846
3846
  ] });
3847
3847
  };
3848
- Ti = /* @__PURE__ */ new WeakSet();
3848
+ Ai = /* @__PURE__ */ new WeakSet();
3849
3849
  Wr = function() {
3850
3850
  if (!h(this, R).streaming) {
3851
3851
  let t = h(this, A).pos - h(this, A).dataOffsets.get(h(this, gt)), e = h(this, A).pos;
3852
- h(this, A).seek(h(this, A).offsets.get(h(this, gt)) + 4), h(this, A).writeEBMLVarInt(t, Hn), h(this, A).seek(e);
3852
+ h(this, A).seek(h(this, A).offsets.get(h(this, gt)) + 4), h(this, A).writeEBMLVarInt(t, qn), h(this, A).seek(e);
3853
3853
  }
3854
3854
  if (h(this, A) instanceof Je && h(this, A).target.options.onCluster) {
3855
3855
  let { data: t, start: e } = h(this, A).getTrackedWrites();
@@ -3857,24 +3857,24 @@ Wr = function() {
3857
3857
  }
3858
3858
  };
3859
3859
  Ae = /* @__PURE__ */ new WeakSet();
3860
- ui = function() {
3860
+ mi = function() {
3861
3861
  if (h(this, Oe))
3862
3862
  throw new Error("Cannot add new video or audio chunks after the file has been finalized.");
3863
3863
  };
3864
3864
  new TextEncoder();
3865
- async function _o(t, e = {}) {
3865
+ async function xo(t, e = {}) {
3866
3866
  if (!t.frames.length) throw new Error("[p5.export] encodeGIF: no frames to encode");
3867
- const i = gn(), r = Math.round(1e3 / t.fps), n = e.maxColors ?? 256, s = t.frames.length;
3867
+ const i = wn(), r = Math.round(1e3 / t.fps), n = e.maxColors ?? 256, s = t.frames.length;
3868
3868
  for (let a = 0; a < s; a++) {
3869
- const o = t.frames[a], f = un(o, n), g = mn(o, f);
3870
- i.writeFrame(g, t.width, t.height, { palette: f, delay: r }), e.onProgress && e.onProgress((a + 1) / s), (a & 15) === 15 && await new Promise((v) => setTimeout(v, 0));
3869
+ const o = t.frames[a], p = mn(o, n), w = gn(o, p);
3870
+ i.writeFrame(w, t.width, t.height, { palette: p, delay: r }), e.onProgress && e.onProgress((a + 1) / s), (a & 15) === 15 && await new Promise((v) => setTimeout(v, 0));
3871
3871
  }
3872
3872
  return i.finish(), new Blob([i.bytes()], { type: "image/gif" });
3873
3873
  }
3874
- function xo() {
3874
+ function So() {
3875
3875
  return typeof window < "u" && typeof window.VideoEncoder == "function" && typeof window.VideoFrame == "function";
3876
3876
  }
3877
- const So = {
3877
+ const Co = {
3878
3878
  mp4: [
3879
3879
  "avc1.640028",
3880
3880
  // H.264 High @ 4.0 — most modern devices
@@ -3891,13 +3891,13 @@ const So = {
3891
3891
  "vp8",
3892
3892
  "av01.0.04M.08"
3893
3893
  ]
3894
- }, Co = { avc1: "avc", av01: "av1", hvc1: "hevc", hev1: "hevc" }, Eo = { vp09: "V_VP9", vp9: "V_VP9", vp8: "V_VP8", av01: "V_AV1" };
3895
- function ko(t, e) {
3894
+ }, Eo = { avc1: "avc", av01: "av1", hvc1: "hevc", hev1: "hevc" }, ko = { vp09: "V_VP9", vp9: "V_VP9", vp8: "V_VP8", av01: "V_AV1" };
3895
+ function To(t, e) {
3896
3896
  const i = e.split(".")[0].toLowerCase();
3897
- return (t === "mp4" ? Co : Eo)[i] || (t === "mp4" ? "avc" : "V_VP9");
3897
+ return (t === "mp4" ? Eo : ko)[i] || (t === "mp4" ? "avc" : "V_VP9");
3898
3898
  }
3899
- async function To(t, { width: e, height: i, fps: r, bitrate: n }) {
3900
- for (const s of So[t] || [])
3899
+ async function Ao(t, { width: e, height: i, fps: r, bitrate: n }) {
3900
+ for (const s of Co[t] || [])
3901
3901
  for (const a of [{ hardwareAcceleration: "prefer-hardware" }, {}])
3902
3902
  try {
3903
3903
  const o = await VideoEncoder.isConfigSupported({
@@ -3913,23 +3913,23 @@ async function To(t, { width: e, height: i, fps: r, bitrate: n }) {
3913
3913
  }
3914
3914
  return null;
3915
3915
  }
3916
- async function Ao(t, e) {
3917
- const i = e.format === "mp4" ? "mp4" : "webm", r = t.width, n = t.height, s = t.fps, a = e.bitsPerSecond ?? Math.min(4e7, Math.max(15e5, Math.round(r * n * s * 0.2))), o = await To(i, { width: r, height: n, fps: s, bitrate: a });
3916
+ async function Mo(t, e) {
3917
+ const i = e.format === "mp4" ? "mp4" : "webm", r = t.width, n = t.height, s = t.fps, a = e.bitsPerSecond ?? Math.min(4e7, Math.max(15e5, Math.round(r * n * s * 0.2))), o = await Ao(i, { width: r, height: n, fps: s, bitrate: a });
3918
3918
  if (!o)
3919
3919
  throw new Error(`[p5.export] WebCodecs: no supported ${i.toUpperCase()} codec for ${r}×${n} @ ${s}fps`);
3920
- const f = i === "mp4" ? new Sn() : new Un(), g = ko(i, o), v = i === "mp4" ? new ao({
3921
- target: f,
3922
- video: { codec: g, width: r, height: n, frameRate: s },
3920
+ const p = i === "mp4" ? new Cn() : new Wn(), w = To(i, o), v = i === "mp4" ? new oo({
3921
+ target: p,
3922
+ video: { codec: w, width: r, height: n, frameRate: s },
3923
3923
  fastStart: "in-memory"
3924
- }) : new bo({
3925
- target: f,
3926
- video: { codec: g, width: r, height: n, frameRate: s }
3924
+ }) : new _o({
3925
+ target: p,
3926
+ video: { codec: w, width: r, height: n, frameRate: s }
3927
3927
  });
3928
- let u = null;
3928
+ let m = null;
3929
3929
  const l = new VideoEncoder({
3930
3930
  output: (E, D) => v.addVideoChunk(E, D),
3931
3931
  error: (E) => {
3932
- u = u || E;
3932
+ m = m || E;
3933
3933
  }
3934
3934
  }), d = { codec: o, width: r, height: n, bitrate: a, framerate: s };
3935
3935
  o.startsWith("avc1") && (d.avc = { format: "avc" });
@@ -3938,32 +3938,32 @@ async function Ao(t, e) {
3938
3938
  { ...d }
3939
3939
  // no hint at all
3940
3940
  ];
3941
- let m = null;
3941
+ let u = null;
3942
3942
  for (const E of c)
3943
3943
  try {
3944
- l.configure(E), m = E;
3944
+ l.configure(E), u = E;
3945
3945
  break;
3946
3946
  } catch {
3947
3947
  }
3948
- if (!m)
3948
+ if (!u)
3949
3949
  throw new Error(`[p5.export] could not configure VideoEncoder for ${o}`);
3950
- const w = 1e6 / s, y = t.frames.length, M = Math.max(1, Math.round(s * 2)), S = 16;
3950
+ const g = 1e6 / s, y = t.frames.length, M = Math.max(1, Math.round(s * 2)), S = 16;
3951
3951
  for (let E = 0; E < y; E++) {
3952
- if (u) throw u;
3952
+ if (m) throw m;
3953
3953
  for (; l.encodeQueueSize > S; )
3954
- if (await new Promise((I) => setTimeout(I, 0)), u) throw u;
3954
+ if (await new Promise((I) => setTimeout(I, 0)), m) throw m;
3955
3955
  const D = new VideoFrame(t.frames[E], {
3956
3956
  format: "RGBA",
3957
3957
  codedWidth: r,
3958
3958
  codedHeight: n,
3959
- timestamp: Math.round(E * w),
3960
- duration: Math.round(w)
3959
+ timestamp: Math.round(E * g),
3960
+ duration: Math.round(g)
3961
3961
  });
3962
3962
  l.encode(D, { keyFrame: E % M === 0 }), D.close(), e.onProgress && e.onProgress((E + 1) / y), (E & 31) === 31 && await new Promise((I) => setTimeout(I, 0));
3963
3963
  }
3964
- if (await l.flush(), u) throw u;
3964
+ if (await l.flush(), m) throw m;
3965
3965
  v.finalize();
3966
- const _ = new Blob([f.buffer], {
3966
+ const _ = new Blob([p.buffer], {
3967
3967
  type: i === "mp4" ? "video/mp4" : "video/webm"
3968
3968
  });
3969
3969
  return _.__ext = i, _;
@@ -3972,29 +3972,29 @@ const ei = {
3972
3972
  webm: ["video/webm;codecs=vp9", "video/webm;codecs=vp8", "video/webm"],
3973
3973
  mp4: ["video/mp4;codecs=avc1", "video/mp4;codecs=h264", "video/mp4"]
3974
3974
  };
3975
- function Mo(t) {
3975
+ function Po(t) {
3976
3976
  const e = t === "mp4" ? [...ei.mp4, ...ei.webm] : [...ei.webm, ...ei.mp4];
3977
3977
  for (const i of e)
3978
3978
  if (typeof MediaRecorder < "u" && MediaRecorder.isTypeSupported(i))
3979
3979
  return { mime: i, ext: i.startsWith("video/mp4") ? "mp4" : "webm" };
3980
3980
  return null;
3981
3981
  }
3982
- function Po(t, e) {
3982
+ function Io(t, e) {
3983
3983
  return new Promise((i, r) => {
3984
- const n = e.format || "webm", s = Mo(n);
3984
+ const n = e.format || "webm", s = Po(n);
3985
3985
  if (!s) return r(new Error("[p5.export] MediaRecorder fallback: no supported mime"));
3986
3986
  n === "mp4" && s.ext !== "mp4" && console.warn("[p5.export] MP4 unsupported here — falling back to WebM.");
3987
3987
  const a = document.createElement("canvas");
3988
3988
  a.width = t.width, a.height = t.height;
3989
- const o = a.getContext("2d"), f = a.captureStream(t.fps), g = { mimeType: s.mime };
3990
- e.bitsPerSecond && (g.videoBitsPerSecond = e.bitsPerSecond);
3991
- const v = new MediaRecorder(f, g), u = [];
3992
- v.ondataavailable = (m) => {
3993
- m.data && m.data.size && u.push(m.data);
3994
- }, v.onerror = (m) => r(m.error || new Error("MediaRecorder error")), v.onstop = () => {
3995
- f.getTracks().forEach((w) => w.stop());
3996
- const m = new Blob(u, { type: s.mime });
3997
- m.__ext = s.ext, i(m);
3989
+ const o = a.getContext("2d"), p = a.captureStream(t.fps), w = { mimeType: s.mime };
3990
+ e.bitsPerSecond && (w.videoBitsPerSecond = e.bitsPerSecond);
3991
+ const v = new MediaRecorder(p, w), m = [];
3992
+ v.ondataavailable = (u) => {
3993
+ u.data && u.data.size && m.push(u.data);
3994
+ }, v.onerror = (u) => r(u.error || new Error("MediaRecorder error")), v.onstop = () => {
3995
+ p.getTracks().forEach((g) => g.stop());
3996
+ const u = new Blob(m, { type: s.mime });
3997
+ u.__ext = s.ext, i(u);
3998
3998
  }, o.putImageData(new ImageData(t.frames[0], t.width, t.height), 0, 0), v.start();
3999
3999
  const l = 1e3 / t.fps;
4000
4000
  let d = 1;
@@ -4008,12 +4008,12 @@ function Po(t, e) {
4008
4008
  setTimeout(c, l);
4009
4009
  });
4010
4010
  }
4011
- async function Io(t, e = {}) {
4011
+ async function Ro(t, e = {}) {
4012
4012
  if (!t.frames.length) throw new Error("[p5.export] encodeVideo: no frames to encode");
4013
- if (xo()) {
4013
+ if (So()) {
4014
4014
  const i = performance.now();
4015
4015
  try {
4016
- const r = await Ao(t, e), n = performance.now() - i | 0;
4016
+ const r = await Mo(t, e), n = performance.now() - i | 0;
4017
4017
  return console.info(`[p5.export] WebCodecs encoded ${t.frames.length} frames in ${n}ms (${t.frames.length / (n / 1e3) | 0} fps).`), r;
4018
4018
  } catch (r) {
4019
4019
  console.warn(
@@ -4023,38 +4023,38 @@ async function Io(t, e = {}) {
4023
4023
  }
4024
4024
  } else
4025
4025
  console.info("[p5.export] WebCodecs not available in this browser; using MediaRecorder (real-time).");
4026
- return Po(t, e);
4026
+ return Io(t, e);
4027
4027
  }
4028
- async function Ro(t, e = {}) {
4028
+ async function Bo(t, e = {}) {
4029
4029
  if (!t || !t.frames.length)
4030
4030
  throw new Error("[p5.export] encodeAnimatedWebP: buffer has no frames");
4031
- const { width: i, height: r, fps: n, frames: s } = t, a = Lo(e.quality ?? 0.85), o = Math.max(0, e.loop ?? 0), f = Math.max(1, Math.round(1e3 / (n || 30)));
4032
- await Bo(i, r);
4033
- const g = document.createElement("canvas");
4034
- g.width = i, g.height = r;
4035
- const v = g.getContext("2d"), u = v.createImageData(i, r), l = [];
4036
- for (let m = 0; m < s.length; m++) {
4037
- u.data.set(s[m]), v.putImageData(u, 0, 0);
4038
- const w = await ss(g, a), y = new Uint8Array(await w.arrayBuffer());
4039
- l.push(Fo(y)), e.onProgress && e.onProgress((m + 1) / s.length);
4040
- }
4041
- const d = zo([
4042
- zi("VP8X", Do(i, r)),
4043
- zi("ANIM", Uo(o)),
4044
- ...l.map((m) => zi("ANMF", Wo(i, r, f, m)))
4031
+ const { width: i, height: r, fps: n, frames: s } = t, a = Go(e.quality ?? 0.85), o = Math.max(0, e.loop ?? 0), p = Math.max(1, Math.round(1e3 / (n || 30)));
4032
+ await Fo(i, r);
4033
+ const w = document.createElement("canvas");
4034
+ w.width = i, w.height = r;
4035
+ const v = w.getContext("2d"), m = v.createImageData(i, r), l = [];
4036
+ for (let u = 0; u < s.length; u++) {
4037
+ m.data.set(s[u]), v.putImageData(m, 0, 0);
4038
+ const g = await as(w, a), y = new Uint8Array(await g.arrayBuffer());
4039
+ l.push(Do(y)), e.onProgress && e.onProgress((u + 1) / s.length);
4040
+ }
4041
+ const d = Oo([
4042
+ Oi("VP8X", Uo(i, r)),
4043
+ Oi("ANIM", Wo(o)),
4044
+ ...l.map((u) => Oi("ANMF", zo(i, r, p, u)))
4045
4045
  ]), c = new Uint8Array(12 + d.length);
4046
- return lr(c, 0, "RIFF"), as(c, 4, 4 + d.length), lr(c, 8, "WEBP"), c.set(d, 12), new Blob([c], { type: "image/webp" });
4046
+ return lr(c, 0, "RIFF"), os(c, 4, 4 + d.length), lr(c, 8, "WEBP"), c.set(d, 12), new Blob([c], { type: "image/webp" });
4047
4047
  }
4048
- async function Bo(t, e) {
4048
+ async function Fo(t, e) {
4049
4049
  const i = document.createElement("canvas");
4050
4050
  i.width = Math.min(8, t), i.height = Math.min(8, e);
4051
- const r = await ss(i, 0.9);
4051
+ const r = await as(i, 0.9);
4052
4052
  if (!r || r.type !== "image/webp")
4053
4053
  throw new Error(
4054
4054
  "[p5.export] This browser doesn't encode WebP from canvas — animated WebP export is unavailable. Use MP4 or WebM instead, or try the latest Chrome/Firefox/Safari."
4055
4055
  );
4056
4056
  }
4057
- function ss(t, e) {
4057
+ function as(t, e) {
4058
4058
  return new Promise((i, r) => {
4059
4059
  t.toBlob(
4060
4060
  (n) => n ? i(n) : r(new Error("canvas.toBlob returned null")),
@@ -4063,35 +4063,35 @@ function ss(t, e) {
4063
4063
  );
4064
4064
  });
4065
4065
  }
4066
- function Fo(t) {
4066
+ function Do(t) {
4067
4067
  let e = 12;
4068
4068
  for (; e + 8 <= t.length; ) {
4069
- const i = String.fromCharCode(t[e], t[e + 1], t[e + 2], t[e + 3]), r = Vo(t, e + 4), n = r + (r & 1);
4069
+ const i = String.fromCharCode(t[e], t[e + 1], t[e + 2], t[e + 3]), r = Lo(t, e + 4), n = r + (r & 1);
4070
4070
  if (i === "VP8 " || i === "VP8L")
4071
4071
  return t.slice(e, e + 8 + n);
4072
4072
  e += 8 + n;
4073
4073
  }
4074
4074
  throw new Error("[p5.export] no VP8/VP8L chunk found in encoded WebP frame");
4075
4075
  }
4076
- function Do(t, e) {
4076
+ function Uo(t, e) {
4077
4077
  const i = new Uint8Array(10);
4078
4078
  return i[0] = 2, Le(i, 4, t - 1), Le(i, 7, e - 1), i;
4079
4079
  }
4080
- function Uo(t) {
4080
+ function Wo(t) {
4081
4081
  const e = new Uint8Array(6);
4082
- return Oo(e, 4, t), e;
4082
+ return Vo(e, 4, t), e;
4083
4083
  }
4084
- function Wo(t, e, i, r) {
4084
+ function zo(t, e, i, r) {
4085
4085
  const n = new Uint8Array(16);
4086
4086
  Le(n, 6, t - 1), Le(n, 9, e - 1), Le(n, 12, i), n[15] = 0;
4087
4087
  const s = new Uint8Array(n.length + r.length);
4088
4088
  return s.set(n, 0), s.set(r, n.length), s;
4089
4089
  }
4090
- function zi(t, e) {
4090
+ function Oi(t, e) {
4091
4091
  const i = e.length & 1, r = new Uint8Array(8 + e.length + i);
4092
- return lr(r, 0, t), as(r, 4, e.length), r.set(e, 8), r;
4092
+ return lr(r, 0, t), os(r, 4, e.length), r.set(e, 8), r;
4093
4093
  }
4094
- function zo(t) {
4094
+ function Oo(t) {
4095
4095
  let e = 0;
4096
4096
  for (const n of t) e += n.length;
4097
4097
  const i = new Uint8Array(e);
@@ -4103,33 +4103,47 @@ function zo(t) {
4103
4103
  function lr(t, e, i) {
4104
4104
  for (let r = 0; r < i.length; r++) t[e + r] = i.charCodeAt(r);
4105
4105
  }
4106
- function Oo(t, e, i) {
4106
+ function Vo(t, e, i) {
4107
4107
  t[e] = i & 255, t[e + 1] = i >> 8 & 255;
4108
4108
  }
4109
4109
  function Le(t, e, i) {
4110
4110
  t[e] = i & 255, t[e + 1] = i >> 8 & 255, t[e + 2] = i >> 16 & 255;
4111
4111
  }
4112
- function as(t, e, i) {
4112
+ function os(t, e, i) {
4113
4113
  t[e] = i & 255, t[e + 1] = i >> 8 & 255, t[e + 2] = i >> 16 & 255, t[e + 3] = i >> 24 & 255;
4114
4114
  }
4115
- function Vo(t, e) {
4115
+ function Lo(t, e) {
4116
4116
  return t[e] | t[e + 1] << 8 | t[e + 2] << 16 | t[e + 3] << 24 >>> 0;
4117
4117
  }
4118
- function Lo(t) {
4118
+ function Go(t) {
4119
4119
  return Math.max(0, Math.min(1, t));
4120
4120
  }
4121
+ function No(t, e) {
4122
+ let i = e;
4123
+ return i == null && typeof t.getTargetFrameRate == "function" && (i = t.getTargetFrameRate()), i == null && (i = t._targetFrameRate), i = Number(i), Number.isFinite(i) && i > 0 ? i : 30;
4124
+ }
4125
+ function $o(t, e) {
4126
+ const i = typeof t.pixelDensity == "function" ? t.pixelDensity() : 1, r = Number(e);
4127
+ if (!(Number.isFinite(r) && r > 0 && r !== i)) return () => {
4128
+ };
4129
+ t.pixelDensity(r), typeof t.redraw == "function" && t.redraw();
4130
+ let s = !1;
4131
+ return () => {
4132
+ s || (s = !0, t.pixelDensity(i), typeof t.redraw == "function" && t.redraw());
4133
+ };
4134
+ }
4121
4135
  const ii = {
4122
4136
  webm: ["video/webm;codecs=vp9", "video/webm;codecs=vp8", "video/webm"],
4123
4137
  mp4: ["video/mp4;codecs=avc1", "video/mp4;codecs=h264", "video/mp4"]
4124
4138
  };
4125
- function Go(t) {
4139
+ function jo(t) {
4126
4140
  const e = t === "mp4" ? [...ii.mp4, ...ii.webm] : [...ii.webm, ...ii.mp4];
4127
4141
  for (const i of e)
4128
4142
  if (typeof MediaRecorder < "u" && MediaRecorder.isTypeSupported(i))
4129
4143
  return { mime: i, ext: i.startsWith("video/mp4") ? "mp4" : "webm" };
4130
4144
  return null;
4131
4145
  }
4132
- class No {
4146
+ class Ho {
4133
4147
  /**
4134
4148
  * @param {object} opts
4135
4149
  * @param {HTMLCanvasElement} opts.canvas
@@ -4140,7 +4154,7 @@ class No {
4140
4154
  * @param {string} [opts.filename]
4141
4155
  */
4142
4156
  constructor(e) {
4143
- const i = Go(e.format || "webm");
4157
+ const i = jo(e.format || "webm");
4144
4158
  if (!i) throw new Error("[p5.export] no supported MediaRecorder mime type found");
4145
4159
  this.ext = i.ext, e.format === "mp4" && this.ext !== "mp4" && console.warn("[p5.export] MP4 not supported by this browser — falling back to WebM"), this.stream = e.canvas.captureStream(e.fps || 60);
4146
4160
  const r = { mimeType: i.mime };
@@ -4164,13 +4178,13 @@ class No {
4164
4178
  return this.recorder.state;
4165
4179
  }
4166
4180
  }
4167
- function $o(t, e, i) {
4181
+ function qo(t, e, i) {
4168
4182
  if (e.recordVideo = function(r = {}) {
4169
4183
  const n = At(this);
4170
4184
  if (!n) throw new Error("[p5.export] recordVideo: no canvas found");
4171
4185
  if (this._p5ExportVideo && this._p5ExportVideo.state === "recording")
4172
4186
  throw new Error("[p5.export] a video recording is already in progress");
4173
- const s = new No({ canvas: n, ...r });
4187
+ const s = new Ho({ canvas: n, ...r });
4174
4188
  return s.start(), this._p5ExportVideo = s, s;
4175
4189
  }, e.recordWebM = function(r = {}) {
4176
4190
  return e.recordVideo.call(this, { ...r, format: "webm" });
@@ -4184,13 +4198,10 @@ function $o(t, e, i) {
4184
4198
  if (!n) throw new Error("[p5.export] createVideoBuffer: no canvas found");
4185
4199
  if (this._p5ExportBuffer && this._p5ExportBuffer.recording)
4186
4200
  throw new Error("[p5.export] a video buffer is already recording");
4187
- const s = this, a = r.scale, o = typeof s.pixelDensity == "function" ? s.pixelDensity() : 1, f = a && a > 0 && a !== o;
4188
- f && (s.pixelDensity(a), typeof s.redraw == "function" && s.redraw());
4189
- const g = new Qs({ canvas: n, ...r }), v = g.stop.bind(g);
4190
- let u = !f;
4191
- return g.stop = function() {
4192
- v(), u || (u = !0, s.pixelDensity(o), typeof s.redraw == "function" && s.redraw());
4193
- }, g.start(), this._p5ExportBuffer = g, g;
4201
+ const s = this, a = No(s, r.fps), o = $o(s, r.scale), p = new ta({ canvas: n, ...r, fps: a }), w = p.stop.bind(p);
4202
+ return p.stop = function() {
4203
+ w(), o();
4204
+ }, p.start(), this._p5ExportBuffer = p, p;
4194
4205
  }, e.stopVideoBuffer = function() {
4195
4206
  const r = this._p5ExportBuffer;
4196
4207
  return r && r.stop(), r || null;
@@ -4200,15 +4211,15 @@ function $o(t, e, i) {
4200
4211
  const s = (n.format || "webm").toLowerCase();
4201
4212
  let a, o;
4202
4213
  if (s === "gif")
4203
- a = await _o(r, n), o = "gif";
4214
+ a = await xo(r, n), o = "gif";
4204
4215
  else if (s === "webp")
4205
- a = await Ro(r, n), o = "webp";
4216
+ a = await Bo(r, n), o = "webp";
4206
4217
  else if (s === "webm" || s === "mp4")
4207
- a = await Io(r, { ...n, format: s }), o = a.__ext || (s === "mp4" ? "mp4" : "webm");
4218
+ a = await Ro(r, { ...n, format: s }), o = a.__ext || (s === "mp4" ? "mp4" : "webm");
4208
4219
  else
4209
4220
  throw new Error(`[p5.export] unsupported video format: ${s}`);
4210
- const f = n.filename ? Et(n.filename, o) : Ct(o);
4211
- return St(a, f), a;
4221
+ const p = n.filename ? Et(n.filename, o) : Ct(o);
4222
+ return St(a, p), a;
4212
4223
  }, i && typeof i == "object") {
4213
4224
  const r = i.postdraw;
4214
4225
  i.postdraw = function() {
@@ -4221,7 +4232,7 @@ function $o(t, e, i) {
4221
4232
  function Zr(t, e) {
4222
4233
  return e && Array.isArray(e.vertices) && Array.isArray(e.faces) ? e : typeof e == "function" && typeof t.buildGeometry == "function" ? t.buildGeometry(e) : null;
4223
4234
  }
4224
- function jo(t, e) {
4235
+ function Xo(t, e) {
4225
4236
  e.saveSTL = function(i, r, n = {}) {
4226
4237
  const s = Zr(this, i);
4227
4238
  if (!s || typeof s.saveStl != "function") {
@@ -4240,13 +4251,13 @@ function jo(t, e) {
4240
4251
  n.saveObj(s);
4241
4252
  };
4242
4253
  }
4243
- const Ho = ".p5export-panel{--p5export-pink: #ed225d;--p5export-pink-dark: #d4144f;--p5export-ink: #333;--p5export-muted: #6b6b6b;--p5export-line: #b5b5b5;--p5export-line-soft: #d6d6d6;--p5export-toolbar: #f4f4f4;--p5export-canvas: #fff;position:fixed;top:16px;right:16px;z-index:99999;width:276px;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);overflow:hidden;color:var(--p5export-ink);background:var(--p5export-canvas);border:1px solid var(--p5export-line);border-radius:0;box-shadow:3px 3px #0000001f;font-family:Montserrat,sans-serif;font-size:12px;font-style:normal;font-weight:400;line-height:normal;letter-spacing:normal;word-spacing:0;-webkit-user-select:none;user-select:none}.p5export-panel *,.p5export-panel *:before,.p5export-panel *:after{box-sizing:border-box}.p5export-header{display:flex;min-height:42px;align-items:center;justify-content:space-between;padding:0 8px 0 0;background:var(--p5export-toolbar);border-bottom:1px dashed var(--p5export-line);cursor:grab;touch-action:none}.p5export-header:active{cursor:grabbing}.p5export-title{display:inline-flex;align-items:center;gap:9px;min-width:0;font-size:12px;font-weight:400}.p5export-brand-mark{display:inline-flex;width:48px;min-height:41px;align-items:center;justify-content:center;color:#fff;background:var(--p5export-pink);font-size:17px;font-weight:700;letter-spacing:-.8px}.p5export-toggle{width:26px;height:26px;padding:0;color:var(--p5export-ink);background:transparent;border:1px solid transparent;border-radius:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;font-family:inherit;font-size:18px;line-height:22px}.p5export-toggle:hover{background:#e1e1e1;border-color:var(--p5export-line)}.p5export-tabs{display:grid;grid-template-columns:1fr 1fr;padding:0;background:var(--p5export-toolbar);border-bottom:1px solid var(--p5export-line)}.p5export-tab{min-height:35px;margin:0;padding:0 12px;color:var(--p5export-muted);background:transparent;border:0;border-right:1px solid var(--p5export-line-soft);border-bottom:3px solid transparent;border-radius:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;font:inherit;text-align:left}.p5export-tab:last-child{border-right:0}.p5export-tab:hover{color:var(--p5export-ink);background:#e9e9e9}.p5export-tab.is-active{color:var(--p5export-pink);background:var(--p5export-canvas);border-bottom-color:var(--p5export-pink);font-weight:400}.p5export-body{max-height:calc(100vh - 94px);padding:14px 12px 12px;overflow-y:auto}.p5export-panel.is-collapsed .p5export-body,.p5export-panel.is-collapsed .p5export-tabs{display:none}.p5export-view:not([hidden]){display:flex;flex-direction:column;gap:10px}.p5export-row{display:grid;grid-template-columns:68px minmax(0,1fr);align-items:center;gap:8px}.p5export-row>label:first-child{color:var(--p5export-muted);font-size:12px;font-weight:400}.p5export-check{display:flex;min-height:30px;align-items:center;gap:7px;color:var(--p5export-ink);cursor:pointer}.p5export-check input{width:14px;height:14px;margin:0;accent-color:var(--p5export-pink);cursor:pointer}.p5export-input,.p5export-select{width:100%;min-height:32px;padding:6px 8px;color:var(--p5export-ink);background:#fff;border:1px solid var(--p5export-line);border-radius:0;outline:0;font:inherit}.p5export-input:hover,.p5export-select:hover{border-color:#777}.p5export-input:focus,.p5export-select:focus{border-color:var(--p5export-pink);box-shadow:0 0 0 1px var(--p5export-pink)}.p5export-input::placeholder{color:#929292}.p5export-select{cursor:pointer}.p5export-input:disabled,.p5export-select:disabled{color:#8d8d8d;background:#ececec;cursor:not-allowed}.p5export-btn{min-height:34px;padding:7px 12px;color:#fff;background:var(--p5export-pink);border:1px solid var(--p5export-pink);border-radius:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;font:inherit;font-weight:700;line-height:12px}.p5export-btn:hover{background:var(--p5export-pink-dark);border-color:var(--p5export-pink-dark)}.p5export-btn:active{transform:translate(1px,1px)}.p5export-btn.is-ghost{color:var(--p5export-ink);background:var(--p5export-toolbar);border-color:var(--p5export-line)}.p5export-btn.is-ghost:hover{background:#e5e5e5}.p5export-btn.is-danger{color:#fff;background:#b52b46;border-color:#b52b46}.p5export-btn:disabled{opacity:.45;cursor:not-allowed;transform:none}.p5export-status{padding:7px 8px;color:var(--p5export-muted);background:var(--p5export-toolbar);border-left:3px solid var(--p5export-line)}.p5export-status.is-error{color:#8d1732;background:#fff0f4;border-left-color:var(--p5export-pink)}.p5export-status[hidden]{display:none}.p5export-preview:not([hidden]){display:flex;flex-direction:column;gap:6px}.p5export-preview-canvas{display:block;width:100%;background:#eee;border:1px solid var(--p5export-line);border-radius:0;image-rendering:pixelated}.p5export-preview-controls{display:flex;align-items:center;gap:8px;padding:6px 0}.p5export-play{width:24px;height:24px;padding:6px;color:#fff;background:var(--p5export-pink);border:0;border-radius:50%;cursor:pointer}.p5export-play:hover{background:var(--p5export-pink-dark)}.p5export-play svg{display:block;width:100%;height:100%}.p5export-timeline{flex:1;height:3px;margin:0;background:var(--p5export-line);border-radius:0;outline:0;-moz-appearance:none;appearance:none;-webkit-appearance:none;cursor:pointer}.p5export-timeline::-webkit-slider-thumb{width:10px;height:16px;background:var(--p5export-pink);border:0;border-radius:0;-moz-appearance:none;appearance:none;-webkit-appearance:none;cursor:grab}.p5export-timeline::-moz-range-thumb{width:10px;height:16px;background:var(--p5export-pink);border:0;border-radius:0;cursor:grab}.p5export-time{min-width:29px;color:var(--p5export-muted);font-variant-numeric:tabular-nums;text-align:right}.p5export-tab:focus-visible,.p5export-toggle:focus-visible,.p5export-btn:focus-visible,.p5export-play:focus-visible{outline:2px solid var(--p5export-pink);outline-offset:-2px}@media (prefers-reduced-motion: reduce){.p5export-btn:active{transform:none}}";
4254
+ const Yo = ".p5export-panel{--p5export-pink: #ed225d;--p5export-pink-dark: #d4144f;--p5export-ink: #333;--p5export-muted: #6b6b6b;--p5export-line: #b5b5b5;--p5export-line-soft: #d6d6d6;--p5export-toolbar: #f4f4f4;--p5export-canvas: #fff;position:fixed;top:16px;right:16px;z-index:99999;width:276px;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);overflow:hidden;color:var(--p5export-ink);background:var(--p5export-canvas);border:1px solid var(--p5export-line);border-radius:0;box-shadow:3px 3px #0000001f;font-family:Montserrat,sans-serif;font-size:12px;font-style:normal;font-weight:400;line-height:normal;letter-spacing:normal;word-spacing:0;-webkit-user-select:none;user-select:none}.p5export-panel *,.p5export-panel *:before,.p5export-panel *:after{box-sizing:border-box}.p5export-header{display:flex;min-height:42px;align-items:center;justify-content:space-between;padding:0 8px 0 0;background:var(--p5export-toolbar);border-bottom:1px dashed var(--p5export-line);cursor:grab;touch-action:none}.p5export-header:active{cursor:grabbing}.p5export-title{display:inline-flex;align-items:center;gap:9px;min-width:0;font-size:12px;font-weight:400}.p5export-brand-mark{display:inline-flex;width:48px;min-height:41px;align-items:center;justify-content:center;color:#fff;background:var(--p5export-pink);font-size:17px;font-weight:700;letter-spacing:-.8px}.p5export-toggle{width:26px;height:26px;padding:0;color:var(--p5export-ink);background:transparent;border:1px solid transparent;border-radius:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;font-family:inherit;font-size:18px;line-height:22px}.p5export-toggle:hover{background:#e1e1e1;border-color:var(--p5export-line)}.p5export-tabs{display:grid;grid-template-columns:1fr 1fr;padding:0;background:var(--p5export-toolbar);border-bottom:1px solid var(--p5export-line)}.p5export-tab{min-height:35px;margin:0;padding:0 12px;color:var(--p5export-muted);background:transparent;border:0;border-right:1px solid var(--p5export-line-soft);border-bottom:3px solid transparent;border-radius:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;font:inherit;text-align:left}.p5export-tab:last-child{border-right:0}.p5export-tab:hover{color:var(--p5export-ink);background:#e9e9e9}.p5export-tab.is-active{color:var(--p5export-pink);background:var(--p5export-canvas);border-bottom-color:var(--p5export-pink);font-weight:400}.p5export-body{max-height:calc(100vh - 94px);padding:14px 12px 12px;overflow-y:auto}.p5export-panel.is-collapsed .p5export-body,.p5export-panel.is-collapsed .p5export-tabs{display:none}.p5export-view:not([hidden]){display:flex;flex-direction:column;gap:10px}.p5export-row{display:grid;grid-template-columns:68px minmax(0,1fr);align-items:center;gap:8px}.p5export-row>label:first-child{color:var(--p5export-muted);font-size:12px;font-weight:400}.p5export-check{display:flex;min-height:30px;align-items:center;gap:7px;color:var(--p5export-ink);cursor:pointer}.p5export-check input{width:14px;height:14px;margin:0;accent-color:var(--p5export-pink);cursor:pointer}.p5export-input,.p5export-select{width:100%;min-height:32px;padding:6px 8px;color:var(--p5export-ink);background:#fff;border:1px solid var(--p5export-line);border-radius:0;outline:0;font:inherit}.p5export-input:hover,.p5export-select:hover{border-color:#777}.p5export-input:focus,.p5export-select:focus{border-color:var(--p5export-pink);box-shadow:0 0 0 1px var(--p5export-pink)}.p5export-input::placeholder{color:#929292}.p5export-select{cursor:pointer}.p5export-input:disabled,.p5export-select:disabled{color:#8d8d8d;background:#ececec;cursor:not-allowed}.p5export-btn{min-height:34px;padding:7px 12px;color:#fff;background:var(--p5export-pink);border:1px solid var(--p5export-pink);border-radius:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;font:inherit;font-weight:700;line-height:12px}.p5export-btn:hover{background:var(--p5export-pink-dark);border-color:var(--p5export-pink-dark)}.p5export-btn:active{transform:translate(1px,1px)}.p5export-btn.is-ghost{color:var(--p5export-ink);background:var(--p5export-toolbar);border-color:var(--p5export-line)}.p5export-btn.is-ghost:hover{background:#e5e5e5}.p5export-btn.is-danger{color:#fff;background:#b52b46;border-color:#b52b46}.p5export-btn:disabled{opacity:.45;cursor:not-allowed;transform:none}.p5export-status{padding:7px 8px;color:var(--p5export-muted);background:var(--p5export-toolbar);border-left:3px solid var(--p5export-line)}.p5export-status.is-error{color:#8d1732;background:#fff0f4;border-left-color:var(--p5export-pink)}.p5export-status[hidden]{display:none}.p5export-preview:not([hidden]){display:flex;flex-direction:column;gap:6px}.p5export-preview-canvas{display:block;width:100%;background:#eee;border:1px solid var(--p5export-line);border-radius:0;image-rendering:pixelated}.p5export-preview-controls{display:flex;align-items:center;gap:8px;padding:6px 0}.p5export-play{width:24px;height:24px;padding:6px;color:#fff;background:var(--p5export-pink);border:0;border-radius:50%;cursor:pointer}.p5export-play:hover{background:var(--p5export-pink-dark)}.p5export-play svg{display:block;width:100%;height:100%}.p5export-timeline{flex:1;height:3px;margin:0;background:var(--p5export-line);border-radius:0;outline:0;-moz-appearance:none;appearance:none;-webkit-appearance:none;cursor:pointer}.p5export-timeline::-webkit-slider-thumb{width:10px;height:16px;background:var(--p5export-pink);border:0;border-radius:0;-moz-appearance:none;appearance:none;-webkit-appearance:none;cursor:grab}.p5export-timeline::-moz-range-thumb{width:10px;height:16px;background:var(--p5export-pink);border:0;border-radius:0;cursor:grab}.p5export-time{min-width:29px;color:var(--p5export-muted);font-variant-numeric:tabular-nums;text-align:right}.p5export-tab:focus-visible,.p5export-toggle:focus-visible,.p5export-btn:focus-visible,.p5export-play:focus-visible{outline:2px solid var(--p5export-pink);outline-offset:-2px}@media (prefers-reduced-motion: reduce){.p5export-btn:active{transform:none}}";
4244
4255
  let Qr = !1;
4245
- function qo() {
4256
+ function Jo() {
4246
4257
  if (Qr || typeof document > "u") return;
4247
4258
  Qr = !0;
4248
4259
  const t = document.createElement("style");
4249
- t.setAttribute("data-p5-export", ""), t.textContent = Ho, document.head.appendChild(t);
4260
+ t.setAttribute("data-p5-export", ""), t.textContent = Yo, document.head.appendChild(t);
4250
4261
  }
4251
4262
  const tn = [
4252
4263
  { value: "png", label: "PNG (image)" },
@@ -4254,20 +4265,20 @@ const tn = [
4254
4265
  { value: "webp", label: "WebP (image)" },
4255
4266
  { value: "svg", label: "SVG (vector)" },
4256
4267
  { value: "pdf", label: "PDF (vector)" }
4257
- ], Xo = [
4268
+ ], Ko = [
4258
4269
  { value: "stl", label: "STL (3D)" },
4259
4270
  { value: "obj", label: "OBJ (3D)" }
4260
- ], Yo = [
4271
+ ], Zo = [
4261
4272
  { value: "webm", label: "WebM (video)" },
4262
4273
  { value: "mp4", label: "MP4 (video)" },
4263
4274
  { value: "webp", label: "WebP (animation)" },
4264
4275
  { value: "gif", label: "GIF (animation)" }
4265
- ], Jo = [
4276
+ ], en = [
4266
4277
  { value: "1", label: "1×" },
4267
4278
  { value: "2", label: "2×" },
4268
4279
  { value: "3", label: "3×" },
4269
4280
  { value: "4", label: "4×" }
4270
- ], en = /* @__PURE__ */ new Set(["png", "jpg", "webp", "pdf"]), hr = '<path d="M2 1.2 L9 5 L2 8.8 Z" fill="currentColor"/>', Ko = '<rect x="2" y="1.5" width="2" height="7" rx="0.5" fill="currentColor"/><rect x="6" y="1.5" width="2" height="7" rx="0.5" fill="currentColor"/>', Zo = `
4281
+ ], rn = /* @__PURE__ */ new Set(["png", "jpg", "webp", "pdf"]), hr = '<path d="M2 1.2 L9 5 L2 8.8 Z" fill="currentColor"/>', Qo = '<rect x="2" y="1.5" width="2" height="7" rx="0.5" fill="currentColor"/><rect x="6" y="1.5" width="2" height="7" rx="0.5" fill="currentColor"/>', tl = `
4271
4282
  <div class="p5export-panel">
4272
4283
  <div class="p5export-header" data-el="header">
4273
4284
  <span class="p5export-title" data-el="title">
@@ -4317,6 +4328,10 @@ const tn = [
4317
4328
  <label>Duration</label>
4318
4329
  <input class="p5export-input" type="number" min="0.5" step="0.5" value="3" data-el="videoDuration">
4319
4330
  </div>
4331
+ <div class="p5export-row">
4332
+ <label>Scale</label>
4333
+ <select class="p5export-select" data-el="videoScale"></select>
4334
+ </div>
4320
4335
  <div class="p5export-row">
4321
4336
  <label>Name</label>
4322
4337
  <input class="p5export-input" type="text" placeholder="filename" data-el="videoFilename">
@@ -4337,9 +4352,9 @@ const tn = [
4337
4352
  </div>
4338
4353
  </div>
4339
4354
  </div>`.trim();
4340
- class Qo {
4355
+ class el {
4341
4356
  constructor(e, i = {}) {
4342
- qo(), this.p = e, this.opts = i, this.tab = "image", this.videoState = "idle", this.buffer = null, this._statusTimer = null, this.el = document.createRange().createContextualFragment(Zo).firstElementChild;
4357
+ Jo(), this.p = e, this.opts = i, this.tab = "image", this.videoState = "idle", this.buffer = null, this._statusTimer = null, this.el = document.createRange().createContextualFragment(tl).firstElementChild;
4343
4358
  for (const r of this.el.querySelectorAll("[data-el]"))
4344
4359
  this[r.dataset.el] = r;
4345
4360
  for (const r of this.el.querySelectorAll("[data-action]"))
@@ -4353,8 +4368,8 @@ class Qo {
4353
4368
  }
4354
4369
  // ─── Bootstrapping helpers ─────────────────────────────────────────────
4355
4370
  _populateOptions() {
4356
- const e = Li(this.p) ? [...tn, ...Xo] : tn;
4357
- this.imageFormat.innerHTML = Oi(e), this.imageScale.innerHTML = Oi(Jo), this.videoFormat.innerHTML = Oi(Yo), this.opts.filename && (this.imageFilename.value = this.opts.filename, this.videoFilename.value = this.opts.filename);
4371
+ const e = Li(this.p) ? [...tn, ...Ko] : tn;
4372
+ this.imageFormat.innerHTML = ri(e), this.imageScale.innerHTML = ri(en), this.videoFormat.innerHTML = ri(Zo), this.videoScale.innerHTML = ri(en), this.opts.filename && (this.imageFilename.value = this.opts.filename, this.videoFilename.value = this.opts.filename);
4358
4373
  }
4359
4374
  _wireExtras() {
4360
4375
  this.imageFormat.addEventListener("change", () => this._refreshImageScaleEnabled()), this._refreshImageScaleEnabled(), this.timeline.addEventListener("input", () => {
@@ -4378,11 +4393,11 @@ class Qo {
4378
4393
  // ─── Image tab ─────────────────────────────────────────────────────────
4379
4394
  /** Scale only applies to raster formats; grey it out for SVG. */
4380
4395
  _refreshImageScaleEnabled() {
4381
- const e = this.imageFormat.value, i = en.has(e);
4396
+ const e = this.imageFormat.value, i = rn.has(e);
4382
4397
  this.imageScale.disabled = !i, this.imageScaleRow.style.opacity = i ? "" : "0.45", this.svgOutlineRow && this.svgOutlineRow.toggleAttribute("hidden", e !== "svg");
4383
4398
  }
4384
4399
  async _saveImage() {
4385
- const e = this.imageFormat.value, i = this.imageFilename.value || void 0, r = Number(this.imageScale.value) || 1, n = en.has(e) ? { scale: r } : void 0, s = `${e.toUpperCase()}${n && r > 1 ? ` @ ${r}×` : ""}`;
4400
+ const e = this.imageFormat.value, i = this.imageFilename.value || void 0, r = Number(this.imageScale.value) || 1, n = rn.has(e) ? { scale: r } : void 0, s = `${e.toUpperCase()}${n && r > 1 ? ` @ ${r}×` : ""}`;
4386
4401
  this._setStatus(this.imageStatus, `Saving ${s}…`);
4387
4402
  try {
4388
4403
  if (e === "png") await this.p.savePNG(i, n);
@@ -4411,20 +4426,20 @@ class Qo {
4411
4426
  if (this.videoState === "recorded") return this._export(this.videoFormat.value);
4412
4427
  }
4413
4428
  _startRecording() {
4414
- const e = Number(this.videoDuration.value) || void 0;
4429
+ const e = Number(this.videoDuration.value) || void 0, i = Number(this.videoScale.value) || 1;
4415
4430
  try {
4416
- this.buffer = this.p.createVideoBuffer({ duration: e, fps: 30, scale: 1 });
4417
- } catch (r) {
4418
- console.error(r), this._setStatus(this.recordedStatus, `Error: ${r.message}`, "error");
4431
+ this.buffer = this.p.createVideoBuffer({ duration: e, scale: i });
4432
+ } catch (n) {
4433
+ console.error(n), this._setStatus(this.recordedStatus, `Error: ${n.message}`, "error");
4419
4434
  return;
4420
4435
  }
4421
4436
  this.videoState = "recording", this._updateVideoState();
4422
- const i = performance.now();
4437
+ const r = performance.now();
4423
4438
  this._statusTimer = setInterval(() => {
4424
- const r = (performance.now() - i) / 1e3, n = e ? ` / ${e.toFixed(1)}s` : "";
4439
+ const n = (performance.now() - r) / 1e3, s = e ? ` / ${e.toFixed(1)}s` : "";
4425
4440
  this._setStatus(
4426
4441
  this.recordedStatus,
4427
- `Recording ${r.toFixed(1)}s${n} · ${this.buffer.framesRecorded} frames`
4442
+ `Recording ${n.toFixed(1)}s${s} · ${this.buffer.framesRecorded} frames`
4428
4443
  ), this.buffer.recording || this._finishRecording();
4429
4444
  }, 100);
4430
4445
  }
@@ -4459,7 +4474,7 @@ class Qo {
4459
4474
  /** Drive every video-tab visual difference from one place. */
4460
4475
  _updateVideoState() {
4461
4476
  const e = this.videoState, i = e === "recorded" || e === "encoding", r = e === "recording";
4462
- this.videoFormat.disabled = r, this.videoDuration.disabled = r, this.videoFilename.disabled = r, this.previewWrap.toggleAttribute("hidden", !i), this.rerecordBtn.toggleAttribute("hidden", !i), this.videoPrimaryBtn.className = "p5export-btn" + (e === "recording" ? " is-danger" : ""), this.videoPrimaryBtn.textContent = e === "recording" ? "Stop" : i ? "Export" : "Record";
4477
+ this.videoFormat.disabled = r, this.videoDuration.disabled = r, this.videoScale.disabled = r, this.videoFilename.disabled = r, this.previewWrap.toggleAttribute("hidden", !i), this.rerecordBtn.toggleAttribute("hidden", !i), this.videoPrimaryBtn.className = "p5export-btn" + (e === "recording" ? " is-danger" : ""), this.videoPrimaryBtn.textContent = e === "recording" ? "Stop" : i ? "Export" : "Record";
4463
4478
  const n = e === "encoding";
4464
4479
  this.videoPrimaryBtn.disabled = n, this.rerecordBtn.disabled = n;
4465
4480
  }
@@ -4492,7 +4507,7 @@ class Qo {
4492
4507
  }
4493
4508
  _playPreview() {
4494
4509
  if (!this.buffer || !this.buffer.frames.length) return;
4495
- this._previewPlaying = !0, this.playIcon.innerHTML = Ko;
4510
+ this._previewPlaying = !0, this.playIcon.innerHTML = Qo;
4496
4511
  const i = 1e3 / (this.buffer.fps || 30);
4497
4512
  let r = performance.now();
4498
4513
  const n = (s) => {
@@ -4519,41 +4534,41 @@ class Qo {
4519
4534
  // ─── Dragging ──────────────────────────────────────────────────────────
4520
4535
  _wireDrag() {
4521
4536
  let i = 0, r = 0, n = 0, s = 0, a = !1, o = null;
4522
- const f = (d, c, m) => Math.min(Math.max(d, c), Math.max(c, m)), g = (d, c) => {
4523
- const m = this.el.getBoundingClientRect(), w = window.innerWidth - m.width - 8, y = window.innerHeight - m.height - 8;
4524
- this.el.style.left = f(d, 8, w) + "px", this.el.style.top = f(c, 8, y) + "px", this.el.style.right = "auto";
4537
+ const p = (d, c, u) => Math.min(Math.max(d, c), Math.max(c, u)), w = (d, c) => {
4538
+ const u = this.el.getBoundingClientRect(), g = window.innerWidth - u.width - 8, y = window.innerHeight - u.height - 8;
4539
+ this.el.style.left = p(d, 8, g) + "px", this.el.style.top = p(c, 8, y) + "px", this.el.style.right = "auto";
4525
4540
  };
4526
4541
  this._clampToViewport = () => {
4527
4542
  const d = this.el.getBoundingClientRect();
4528
- g(d.left, d.top);
4543
+ w(d.left, d.top);
4529
4544
  };
4530
4545
  const v = (d) => {
4531
- !a || d.pointerId !== o || g(
4546
+ !a || d.pointerId !== o || w(
4532
4547
  n + d.clientX - i,
4533
4548
  s + d.clientY - r
4534
4549
  );
4535
- }, u = (d) => {
4550
+ }, m = (d) => {
4536
4551
  !a || d.pointerId !== o || (a = !1, this.header.hasPointerCapture(o) && this.header.releasePointerCapture(o), o = null);
4537
4552
  }, l = (d) => {
4538
4553
  if (d.button !== 0 || d.target.closest(".p5export-toggle")) return;
4539
4554
  d.preventDefault(), a = !0, o = d.pointerId, i = d.clientX, r = d.clientY;
4540
4555
  const c = this.el.getBoundingClientRect();
4541
- n = c.left, s = c.top, g(n, s), this.header.setPointerCapture(o);
4556
+ n = c.left, s = c.top, w(n, s), this.header.setPointerCapture(o);
4542
4557
  };
4543
- this.header.addEventListener("pointerdown", l), this.header.addEventListener("pointermove", v), this.header.addEventListener("pointerup", u), this.header.addEventListener("pointercancel", u), window.addEventListener("resize", this._clampToViewport), typeof ResizeObserver < "u" && (this._dragResizeObserver = new ResizeObserver(this._clampToViewport), this._dragResizeObserver.observe(this.el)), this._dragHandlers = { onDown: l, onMove: v, onUp: u }, this._clampToViewport();
4558
+ this.header.addEventListener("pointerdown", l), this.header.addEventListener("pointermove", v), this.header.addEventListener("pointerup", m), this.header.addEventListener("pointercancel", m), window.addEventListener("resize", this._clampToViewport), typeof ResizeObserver < "u" && (this._dragResizeObserver = new ResizeObserver(this._clampToViewport), this._dragResizeObserver.observe(this.el)), this._dragHandlers = { onDown: l, onMove: v, onUp: m }, this._clampToViewport();
4544
4559
  }
4545
4560
  destroy() {
4546
4561
  clearInterval(this._statusTimer), this._pausePreview(), this.buffer && this.buffer.clear(), this._dragHandlers && (this.header.removeEventListener("pointerdown", this._dragHandlers.onDown), this.header.removeEventListener("pointermove", this._dragHandlers.onMove), this.header.removeEventListener("pointerup", this._dragHandlers.onUp), this.header.removeEventListener("pointercancel", this._dragHandlers.onUp)), this._clampToViewport && window.removeEventListener("resize", this._clampToViewport), this._dragResizeObserver && this._dragResizeObserver.disconnect(), this.el.remove();
4547
4562
  }
4548
4563
  }
4549
- function Oi(t) {
4564
+ function ri(t) {
4550
4565
  return t.map((e) => `<option value="${e.value}">${e.label}</option>`).join("");
4551
4566
  }
4552
- function tl(t, e, i) {
4567
+ function il(t, e, i) {
4553
4568
  if (e.createExportGUI = function(r = {}) {
4554
4569
  if (this._p5ExportPanel)
4555
4570
  return Object.assign(this._p5ExportPanel.opts, r), this._p5ExportPanel;
4556
- const n = new Qo(this, r);
4571
+ const n = new el(this, r);
4557
4572
  return this._p5ExportPanel = n, n;
4558
4573
  }, e.removeExportGUI = function() {
4559
4574
  this._p5ExportPanel && (this._p5ExportPanel.destroy(), this._p5ExportPanel = null);
@@ -4565,11 +4580,11 @@ function tl(t, e, i) {
4565
4580
  }
4566
4581
  }
4567
4582
  function zr(t, e, i) {
4568
- ds(t, e), Fs(t, e, i), Ws(t, e), Zs(t, e, i), $o(t, e, i), jo(t, e), tl(t, e, i), el(t), e.downloadBlob = function(r, n) {
4583
+ cs(t, e), Ds(t, e, i), zs(t, e), Qs(t, e, i), qo(t, e, i), Xo(t, e), il(t, e, i), rl(t), e.downloadBlob = function(r, n) {
4569
4584
  return St(r, n);
4570
4585
  };
4571
4586
  }
4572
- function el(t) {
4587
+ function rl(t) {
4573
4588
  const e = t && t.Graphics;
4574
4589
  if (!e || !e.prototype || e.prototype.__p5ExportGraphicsRandomPatched) return;
4575
4590
  const i = t.prototype;
@@ -4580,16 +4595,16 @@ function el(t) {
4580
4595
  });
4581
4596
  e.prototype.__p5ExportGraphicsRandomPatched = !0;
4582
4597
  }
4583
- function os(t) {
4598
+ function ls(t) {
4584
4599
  if (!t || !t.prototype) return !1;
4585
4600
  if (t.prototype.__p5ExportInstalled) return !0;
4586
4601
  t.prototype.__p5ExportInstalled = !0;
4587
4602
  const e = {};
4588
4603
  zr(t, t.prototype, e);
4589
4604
  const i = (r, n) => typeof n == "function" && typeof t.prototype.registerMethod == "function" && t.prototype.registerMethod(r, n);
4590
- return i("beforeSetup", e.presetup), i("afterSetup", e.postsetup), i("pre", e.predraw), i("post", e.postdraw), il(t), console.info("[p5.export] Registered against p5 1.x — vector SVG, image, GIF, video, PDF exports available. Use p5 2.0 for full feature parity."), !0;
4605
+ return i("beforeSetup", e.presetup), i("afterSetup", e.postsetup), i("pre", e.predraw), i("post", e.postdraw), nl(t), console.info("[p5.export] Registered against p5 1.x — vector SVG, image, GIF, video, PDF exports available. Use p5 2.0 for full feature parity."), !0;
4591
4606
  }
4592
- function il(t) {
4607
+ function nl(t) {
4593
4608
  if (typeof window > "u") return;
4594
4609
  const e = Date.now(), i = setInterval(() => {
4595
4610
  if ((window.p5ExportConfig || {}).autoGUI === !1) {
@@ -4608,25 +4623,25 @@ function il(t) {
4608
4623
  Date.now() - e > 3e4 && clearInterval(i);
4609
4624
  }, 150);
4610
4625
  }
4611
- function rl(t) {
4626
+ function sl(t) {
4612
4627
  if (!t) throw new Error("[p5.export] register() called with no p5 constructor");
4613
4628
  if (typeof t.registerAddon == "function") {
4614
4629
  t.registerAddon(zr);
4615
4630
  return;
4616
4631
  }
4617
- if (!os(t))
4632
+ if (!ls(t))
4618
4633
  throw new Error("[p5.export] Could not register — no registerAddon and no prototype.registerMethod.");
4619
4634
  }
4620
4635
  function Vi() {
4621
- return typeof window > "u" || !window.p5 ? !1 : window.p5.prototype && window.p5.prototype.__p5ExportInstalled || window.p5.__p5ExportAutoRegistered ? !0 : typeof window.p5.registerAddon == "function" ? (window.p5.registerAddon(zr), window.p5.__p5ExportAutoRegistered = !0, !0) : os(window.p5);
4636
+ return typeof window > "u" || !window.p5 ? !1 : window.p5.prototype && window.p5.prototype.__p5ExportInstalled || window.p5.__p5ExportAutoRegistered ? !0 : typeof window.p5.registerAddon == "function" ? (window.p5.registerAddon(zr), window.p5.__p5ExportAutoRegistered = !0, !0) : ls(window.p5);
4622
4637
  }
4623
- function nl() {
4638
+ function al() {
4624
4639
  typeof window > "u" || window.__p5ExportModuleTried || (window.__p5ExportModuleTried = !0, import(
4625
4640
  /* @vite-ignore */
4626
4641
  "p5"
4627
4642
  ).then((t) => {
4628
4643
  const e = t && (t.default || t.p5) || t;
4629
- !e || typeof e != "function" && !e.prototype || e.__p5ExportAutoRegistered || e.prototype && e.prototype.__p5ExportInstalled || (rl(e), e.__p5ExportAutoRegistered = !0);
4644
+ !e || typeof e != "function" && !e.prototype || e.__p5ExportAutoRegistered || e.prototype && e.prototype.__p5ExportInstalled || (sl(e), e.__p5ExportAutoRegistered = !0);
4630
4645
  }).catch(() => {
4631
4646
  }));
4632
4647
  }
@@ -4634,11 +4649,11 @@ if (typeof window < "u" && !Vi()) {
4634
4649
  const t = setInterval(() => {
4635
4650
  Vi() && clearInterval(t);
4636
4651
  }, 10);
4637
- setTimeout(() => clearInterval(t), 5e3), window.addEventListener("p5Ready", Vi, { once: !0 }), nl();
4652
+ setTimeout(() => clearInterval(t), 5e3), window.addEventListener("p5Ready", Vi, { once: !0 }), al();
4638
4653
  }
4639
4654
  export {
4640
4655
  zr as default,
4641
4656
  zr as p5ExportAddon,
4642
- rl as register
4657
+ sl as register
4643
4658
  };
4644
4659
  //# sourceMappingURL=p5.export.js.map