@weasel-js/core 1.7.3 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/dist/animation/colorHelpers.js +58 -58
  3. package/dist/animation/colorHelpers.js.map +1 -1
  4. package/dist/animation/engine/axes.js +36 -0
  5. package/dist/animation/engine/axes.js.map +1 -0
  6. package/dist/animation/engine/codec.js +170 -0
  7. package/dist/animation/engine/codec.js.map +1 -0
  8. package/dist/animation/engine/integrator.js +12 -0
  9. package/dist/animation/engine/integrator.js.map +1 -0
  10. package/dist/animation/useAnimator.js +209 -160
  11. package/dist/animation/useAnimator.js.map +1 -1
  12. package/dist/{builtins-C-gRyVRx.d.ts → builtins-CMEh6-Oc.d.ts} +81 -8
  13. package/dist/canvas/SceneCanvas/defaultNodeProperties.js +12 -12
  14. package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
  15. package/dist/canvas/pickWalk.js +2 -2
  16. package/dist/canvas/pickWalk.js.map +1 -1
  17. package/dist/canvas/sceneSlotWiring.js +1 -1
  18. package/dist/canvas/sceneSlotWiring.js.map +1 -1
  19. package/dist/canvas/sceneViewRender.js +1 -1
  20. package/dist/canvas/sceneViewRender.js.map +1 -1
  21. package/dist/core/scene/effectivePose.js +1 -1
  22. package/dist/core/scene/effectivePose.js.map +1 -1
  23. package/dist/core/scene/poseOverrides.js +42 -22
  24. package/dist/core/scene/poseOverrides.js.map +1 -1
  25. package/dist/core/scene/scene.js +9 -0
  26. package/dist/core/scene/scene.js.map +1 -1
  27. package/dist/core/scene/types.js.map +1 -1
  28. package/dist/core/selection/useSelection.js +27 -33
  29. package/dist/core/selection/useSelection.js.map +1 -1
  30. package/dist/core/stableStringify.js +8 -0
  31. package/dist/core/stableStringify.js.map +1 -0
  32. package/dist/index.d.ts +35 -25
  33. package/dist/index.js +269 -268
  34. package/dist/renderer/WeaselRenderer.js +4 -1
  35. package/dist/renderer/WeaselRenderer.js.map +1 -1
  36. package/dist/renderer/batchClip.js +46 -0
  37. package/dist/renderer/batchClip.js.map +1 -0
  38. package/dist/renderer/draw.js +367 -294
  39. package/dist/renderer/draw.js.map +1 -1
  40. package/dist/renderer/drawBatch.js +75 -45
  41. package/dist/renderer/drawBatch.js.map +1 -1
  42. package/dist/renderer/shaders/batchFill.js +3 -2
  43. package/dist/renderer/shaders/batchFill.js.map +1 -1
  44. package/dist/renderer.d.ts +1 -1
  45. package/dist/tools/builtin/text/useTextTool.js +8 -8
  46. package/dist/tools/builtin/text/useTextTool.js.map +1 -1
  47. package/dist/tools/prefs.js.map +1 -1
  48. package/dist/version.js +1 -1
  49. package/package.json +17 -15
@@ -14,19 +14,20 @@ import { outlineStrokeMesh as h, quantizeEmWidth as g } from "./cache/outlineStr
14
14
  import { resolveMarkerSize as _ } from "../core/markerInset.js";
15
15
  import { quantizeStrokeScale as v, strokeMesh as y } from "./cache/strokeMeshCache.js";
16
16
  import { cachedMarkerCommands as b } from "./cache/markerCommandCache.js";
17
- import { COMPOSITE_PROGRAM_ID as ee } from "./effects/composite.js";
18
- import { SYNTHETIC_ITALIC_RADIANS as x } from "./syntheticItalic.js";
19
- import { GLYPH_MODE_MSDF as S, GLYPH_MODE_R8 as te, dynamicPageTextureId as C, ensureFontTexture as ne, glyphFieldScale as re, syncDynamicPageTexture as ie, textureCacheKey as ae } from "@weasel-js/font";
20
- import { cachedLayoutRuns as oe, resolveTextStyle as se, verticalAlignOffset as ce } from "@weasel-js/text";
21
- import { tessellate as le } from "@weasel-js/geom/tessellate";
17
+ import { axisAlignedClipRect as ee, intersectClipRects as x } from "./batchClip.js";
18
+ import { COMPOSITE_PROGRAM_ID as S } from "./effects/composite.js";
19
+ import { SYNTHETIC_ITALIC_RADIANS as te } from "./syntheticItalic.js";
20
+ import { GLYPH_MODE_MSDF as C, GLYPH_MODE_R8 as ne, dynamicPageTextureId as re, ensureFontTexture as ie, glyphFieldScale as ae, syncDynamicPageTexture as oe, textureCacheKey as se } from "@weasel-js/font";
21
+ import { cachedLayoutRuns as ce, resolveTextStyle as le, verticalAlignOffset as ue } from "@weasel-js/text";
22
+ import { tessellate as de } from "@weasel-js/geom/tessellate";
22
23
  //#region src/renderer/draw.ts
23
24
  function w(e, t, n) {
24
25
  e.gl.drawElements(e.gl.TRIANGLES, t, n, 0), e.stats && e.stats.drawCalls++;
25
26
  }
26
- var ue = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap();
27
+ var fe = /* @__PURE__ */ new WeakMap(), pe = /* @__PURE__ */ new WeakMap();
27
28
  function T(e, t) {
28
- let n = ue.get(e);
29
- n || (n = /* @__PURE__ */ new WeakMap(), ue.set(e, n));
29
+ let n = fe.get(e);
30
+ n || (n = /* @__PURE__ */ new WeakMap(), fe.set(e, n));
30
31
  let r = n.get(t);
31
32
  return r || (r = {}, n.set(t, r)), r;
32
33
  }
@@ -35,7 +36,7 @@ function E(e, t) {
35
36
  for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
36
37
  return !0;
37
38
  }
38
- function fe(e, t, n, r, i, a) {
39
+ function me(e, t, n, r, i, a) {
39
40
  let o = t.uniform("u_color");
40
41
  if (o === void 0) return;
41
42
  let s = T(e, t), c = s.color;
@@ -53,9 +54,9 @@ function D(e, t, n) {
53
54
  i.alpha !== n && (e.gl.uniform1f(r, n), i.alpha = n);
54
55
  }
55
56
  var O = o.identity();
56
- function pe(e) {
57
- let t = de.get(e);
58
- return t || (t = o.screenToClip(e.widthCss, e.heightCss), de.set(e, t)), t;
57
+ function he(e) {
58
+ let t = pe.get(e);
59
+ return t || (t = o.screenToClip(e.widthCss, e.heightCss), pe.set(e, t)), t;
59
60
  }
60
61
  var k = /* @__PURE__ */ new Float32Array(16);
61
62
  function A(e, t, n = e.state.colorMatrix) {
@@ -75,31 +76,31 @@ function A(e, t, n = e.state.colorMatrix) {
75
76
  E(i.colorBias, e) || (r.uniform4f(o, e[0], e[1], e[2], e[3]), i.colorBias = Float32Array.from(e));
76
77
  }
77
78
  }
78
- function me(e, t) {
79
- return e.flattenTolerance === void 0 ? f(t) : le(t, { flattenTolerance: e.flattenTolerance });
79
+ function ge(e, t) {
80
+ return e.flattenTolerance === void 0 ? f(t) : de(t, { flattenTolerance: e.flattenTolerance });
80
81
  }
81
- function he(e, t) {
82
+ function _e(e, t) {
82
83
  return e.flattenTolerance === void 0 ? e.meshCache.handleFor(t) : e.meshCache.uploadTransient(t);
83
84
  }
84
- function ge(e, t) {
85
- return he(e, me(e, t));
85
+ function ve(e, t) {
86
+ return _e(e, ge(e, t));
86
87
  }
87
- function j(e, t) {
88
+ function ye(e, t) {
88
89
  switch (t.kind) {
89
- case "group": return Oe(e, t);
90
- case "path": return ke(e, t);
91
- case "text": return bt(e, t);
92
- case "image": return Lt(e, t);
93
- case "sprites": return Rt(e, t);
94
- case "shader": return H(e), we(e, t);
90
+ case "group": return je(e, t);
91
+ case "path": return Le(e, t);
92
+ case "text": return At(e, t);
93
+ case "image": return Jt(e, t);
94
+ case "sprites": return Yt(e, t);
95
+ case "shader": return P(e), De(e, t);
95
96
  }
96
97
  }
97
- var _e = /* @__PURE__ */ new Set();
98
- function ve(e, t) {
98
+ var be = /* @__PURE__ */ new Set();
99
+ function xe(e, t) {
99
100
  let n = `${e}:${t}`;
100
- _e.has(n) || (_e.add(n), (typeof process > "u" || process.env.NODE_ENV !== "production") && console.warn(`weasel drawShader: uniform "${t}" not found in program "${e}". Check spelling, ensure it's used in the shader (unused uniforms are optimized away by the driver).`));
101
+ be.has(n) || (be.add(n), (typeof process > "u" || process.env.NODE_ENV !== "production") && console.warn(`weasel drawShader: uniform "${t}" not found in program "${e}". Check spelling, ensure it's used in the shader (unused uniforms are optimized away by the driver).`));
101
102
  }
102
- function ye(e, t, n, r, i) {
103
+ function Se(e, t, n, r, i) {
103
104
  if (typeof n == "object" && n && !Array.isArray(n) && !(n instanceof Float32Array) && "id" in n && typeof n.id == "string") {
104
105
  let a = n, o = c(a.id);
105
106
  if (!o) {
@@ -137,7 +138,7 @@ function ye(e, t, n, r, i) {
137
138
  return;
138
139
  }
139
140
  }
140
- var be = {
141
+ var Ce = {
141
142
  float: {
142
143
  fn: "uniform1fv",
143
144
  n: 1
@@ -263,11 +264,11 @@ var be = {
263
264
  matrix: !0
264
265
  }
265
266
  };
266
- function xe(e) {
267
+ function we(e) {
267
268
  return Array.isArray(e) || e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint32Array;
268
269
  }
269
- function Se(e, t, n, r) {
270
- let i = typeof process < "u" ? process.env.NODE_ENV !== "production" : !0, a = be[n.type];
270
+ function Te(e, t, n, r) {
271
+ let i = typeof process < "u" ? process.env.NODE_ENV !== "production" : !0, a = Ce[n.type];
271
272
  if (!a) {
272
273
  i && console.warn(`weasel setUniform: array uniform "${t}" has type ${n.type}, which cannot be written as a whole`);
273
274
  return;
@@ -280,22 +281,22 @@ function Se(e, t, n, r) {
280
281
  let o = e[a.fn];
281
282
  a.matrix ? o.call(e, n.location, !1, r) : o.call(e, n.location, r);
282
283
  }
283
- function Ce(e, t, n, r, i, a) {
284
+ function Ee(e, t, n, r, i, a) {
284
285
  for (let [o, s] of Object.entries(r)) {
285
286
  let r = t.uniformArray(o);
286
- if (r && xe(s)) {
287
- Se(e, o, r, s);
287
+ if (r && we(s)) {
288
+ Te(e, o, r, s);
288
289
  continue;
289
290
  }
290
291
  let c = t.uniform(o);
291
292
  if (c === void 0) {
292
- ve(n, o);
293
+ xe(n, o);
293
294
  continue;
294
295
  }
295
- ye(e, c, s, i, a);
296
+ Se(e, c, s, i, a);
296
297
  }
297
298
  }
298
- function we(e, t) {
299
+ function De(e, t) {
299
300
  let { gl: n, programRegistry: r, quadVbo: i, quadIbo: a, textureCache: s } = e, c = r.get(t.program.id);
300
301
  if (!c) {
301
302
  console.warn(`weasel drawShader: program "${t.program.id}" not compiled on this renderer. Call renderer.registerProgram(handle) after the module-level registerProgram().`);
@@ -313,36 +314,36 @@ function we(e, t) {
313
314
  let p = c.uniform("u_bounds");
314
315
  p !== void 0 && n.uniform4f(p, t.bounds.x, t.bounds.y, t.bounds.w, t.bounds.h);
315
316
  let m = c.uniform("u_view");
316
- m !== void 0 && n.uniformMatrix3fv(m, !1, e.state.transform), Ce(n, c, t.program.id, t.uniforms, s, { value: 1 }), Y(e), w(e, 6, e.gl.UNSIGNED_SHORT), l !== void 0 && n.disableVertexAttribArray(l), u !== void 0 && n.disableVertexAttribArray(u), n.bindBuffer(n.ARRAY_BUFFER, null), n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, null);
317
+ m !== void 0 && n.uniformMatrix3fv(m, !1, e.state.transform), Ee(n, c, t.program.id, t.uniforms, s, { value: 1 }), Z(e), w(e, 6, e.gl.UNSIGNED_SHORT), l !== void 0 && n.disableVertexAttribArray(l), u !== void 0 && n.disableVertexAttribArray(u), n.bindBuffer(n.ARRAY_BUFFER, null), n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, null);
317
318
  }
318
- function Te(e, t, n, r, i) {
319
+ function Oe(e, t, n, r, i) {
319
320
  let a = e.gl;
320
- H(e);
321
- let o = e.renderTarget ?? null, s = e.clipDepth, c = a.isEnabled(a.SCISSOR_TEST), l = n.acquire(r, i), u = e.state.pushIsolated({ transform: t.transform });
322
- e.clipDepth = 0, a.bindFramebuffer(a.FRAMEBUFFER, l.fbo), e.renderTarget = l, a.viewport(0, 0, r, i), a.disable(a.SCISSOR_TEST), a.stencilMask(255), a.clear(a.COLOR_BUFFER_BIT | a.STENCIL_BUFFER_BIT);
323
- for (let n of t.children) j(e, n);
324
- H(e), a.disable(a.BLEND);
321
+ P(e);
322
+ let o = e.renderTarget ?? null, s = e.clipDepth, c = e.clipStack, l = e.drawBatch.clip, u = a.isEnabled(a.SCISSOR_TEST), d = n.acquire(r, i), f = e.state.pushIsolated({ transform: t.transform });
323
+ e.clipDepth = 0, e.clipStack = [], e.drawBatch.clip = null, a.bindFramebuffer(a.FRAMEBUFFER, d.fbo), e.renderTarget = d, a.viewport(0, 0, r, i), a.disable(a.SCISSOR_TEST), a.stencilMask(255), a.clear(a.COLOR_BUFFER_BIT | a.STENCIL_BUFFER_BIT);
324
+ for (let n of t.children) ye(e, n);
325
+ G(e), a.disable(a.BLEND);
325
326
  for (let o of t.effects) {
326
327
  let t = e.ensureProgram?.(o.program.id) ?? null;
327
328
  if (!t) {
328
- ve(o.program.id, "(program)");
329
+ xe(o.program.id, "(program)");
329
330
  continue;
330
331
  }
331
332
  let s = n.acquire(r, i);
332
- a.bindFramebuffer(a.FRAMEBUFFER, s.fbo), a.viewport(0, 0, r, i), a.clear(a.COLOR_BUFFER_BIT), De(e, t, l.texture, r, i, o.uniforms, void 0, o.program.id), n.release(l), l = s;
333
+ a.bindFramebuffer(a.FRAMEBUFFER, s.fbo), a.viewport(0, 0, r, i), a.clear(a.COLOR_BUFFER_BIT), Ae(e, t, d.texture, r, i, o.uniforms, void 0, o.program.id), n.release(d), d = s;
333
334
  }
334
- a.enable(a.BLEND), e.state.pop(), e.clipDepth = s, e.renderTarget = o, Ee(e, r, i, c);
335
- let d = e.ensureProgram?.(ee) ?? null;
336
- d && (Y(e), De(e, d, l.texture, r, i, void 0, {
337
- alpha: u.alpha,
338
- colorMatrix: u.colorMatrix
339
- })), n.release(l);
340
- }
341
- function Ee(e, t, n, r) {
335
+ a.enable(a.BLEND), e.state.pop(), e.clipDepth = s, e.clipStack = c, e.drawBatch.clip = l, e.renderTarget = o, ke(e, r, i, u);
336
+ let p = e.ensureProgram?.(S) ?? null;
337
+ p && (Z(e), Ae(e, p, d.texture, r, i, void 0, {
338
+ alpha: f.alpha,
339
+ colorMatrix: f.colorMatrix
340
+ })), n.release(d);
341
+ }
342
+ function ke(e, t, n, r) {
342
343
  let i = e.gl, a = e.renderTarget ?? null;
343
344
  i.bindFramebuffer(i.FRAMEBUFFER, a ? a.fbo : null), a ? i.viewport(0, 0, t, n) : (e.restoreTargetRect?.(), r && i.enable(i.SCISSOR_TEST));
344
345
  }
345
- function De(e, t, n, r, i, a, o, s) {
346
+ function Ae(e, t, n, r, i, a, o, s) {
346
347
  let c = e.gl;
347
348
  c.useProgram(t.handle);
348
349
  let l = t.attribute("a_position"), u = t.attribute("a_uv");
@@ -356,11 +357,11 @@ function De(e, t, n, r, i, a, o, s) {
356
357
  let n = t.uniform("u_alpha");
357
358
  n !== void 0 && c.uniform1f(n, o.alpha), A(e, t, o.colorMatrix);
358
359
  }
359
- a && Ce(c, t, s ?? "effect", a, e.textureCache, { value: 1 }), w(e, 6, e.gl.UNSIGNED_SHORT), l !== void 0 && l >= 0 && c.disableVertexAttribArray(l), u !== void 0 && u >= 0 && c.disableVertexAttribArray(u), c.bindBuffer(c.ARRAY_BUFFER, null), c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, null);
360
+ a && Ee(c, t, s ?? "effect", a, e.textureCache, { value: 1 }), w(e, 6, e.gl.UNSIGNED_SHORT), l !== void 0 && l >= 0 && c.disableVertexAttribArray(l), u !== void 0 && u >= 0 && c.disableVertexAttribArray(u), c.bindBuffer(c.ARRAY_BUFFER, null), c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, null);
360
361
  }
361
- function Oe(e, t) {
362
+ function je(e, t) {
362
363
  if (t.effects && t.effects.length > 0 && e.effectTargets && e.deviceWidth && e.deviceHeight) {
363
- Te(e, t, e.effectTargets, e.deviceWidth, e.deviceHeight);
364
+ Oe(e, t, e.effectTargets, e.deviceWidth, e.deviceHeight);
364
365
  return;
365
366
  }
366
367
  if (e.state.push({
@@ -368,72 +369,129 @@ function Oe(e, t) {
368
369
  alpha: t.alpha,
369
370
  colorMatrix: t.colorMatrix
370
371
  }), t.clip) {
372
+ let n = e.clipStack.reduce((e, t) => e + +(t.depth === 0), 0);
373
+ if (e.clipDepth + n + 1 > 7) throw e.state.pop(), Error("weasel: clip nesting depth exceeded (max 7). You can't nest more than 7 levels of clipped containers in a single draw tree. Flatten the hierarchy or compose poses outside the scene graph.");
374
+ Me(e, t.clip);
375
+ }
376
+ for (let n of t.children) ye(e, n);
377
+ t.clip && Ne(e), e.state.pop();
378
+ }
379
+ function Me(e, t) {
380
+ let n = e.state.transform, r = ee(t, n);
381
+ if (r === null) {
382
+ Pe(e);
383
+ let r = e.clipDepth + 1;
384
+ vt(e, t, r), e.clipDepth = r, e.clipStack.push({
385
+ path: t,
386
+ transform: n,
387
+ rect: null,
388
+ depth: r
389
+ });
390
+ } else e.clipStack.push({
391
+ path: t,
392
+ transform: n,
393
+ rect: r,
394
+ depth: 0
395
+ });
396
+ Fe(e);
397
+ }
398
+ function Ne(e) {
399
+ let t = e.clipStack.pop();
400
+ t.depth > 0 && (yt(e, t.path, t.depth - 1, t.transform), e.clipDepth = t.depth - 1), Fe(e);
401
+ }
402
+ function Pe(e) {
403
+ for (let t of e.clipStack) {
404
+ if (t.depth !== 0) continue;
371
405
  let n = e.clipDepth + 1;
372
- if (n > 7) throw e.state.pop(), Error("weasel: clip nesting depth exceeded (max 7). You can't nest more than 7 levels of clipped containers in a single draw tree. Flatten the hierarchy or compose poses outside the scene graph.");
373
- lt(e, t.clip, n), e.clipDepth = n;
406
+ vt(e, t.path, n, t.transform), t.depth = n, e.clipDepth = n;
374
407
  }
375
- for (let n of t.children) j(e, n);
376
- t.clip && (ut(e, t.clip, e.clipDepth - 1), --e.clipDepth), e.state.pop();
377
408
  }
378
- function ke(e, t) {
379
- t.fill && Ae(e, t), t.stroke?.paint && pt(e, t);
409
+ function Fe(e) {
410
+ let t = null;
411
+ for (let n of e.clipStack) n.rect && (t = t ? x(t, n.rect) : n.rect);
412
+ e.drawBatch.clip = t;
413
+ }
414
+ function Ie(e) {
415
+ let t = e.clipStack;
416
+ if (t.length === 0 || e.uncut) return e.clipDepth;
417
+ for (let e = t.length - 1; e >= 0; e--) if (t[e].rect === null) return t[e].depth;
418
+ for (let e of t) if (e.depth > 0) return e.depth - 1;
419
+ return e.clipDepth;
420
+ }
421
+ function j(e) {
422
+ Pe(e);
423
+ let t = e.drawBatch.clip;
424
+ return e.drawBatch.clip = null, e.uncut = !0, t;
425
+ }
426
+ function M(e, t) {
427
+ e.drawBatch.clip = t, e.uncut = !1;
380
428
  }
381
- function Ae(e, t) {
382
- let n = t.fill, r = n.fill === void 0 || n.fill === "solid", i = !!(t.vertexColors && t.vertexColors.length > 0), a = n, o = z(e, n, i);
429
+ function N(e, t, n, r) {
430
+ let i = j(e);
431
+ r(e, t, n), M(e, i);
432
+ }
433
+ function P(e) {
434
+ G(e), e.clipStack.length > 0 && Pe(e);
435
+ }
436
+ function Le(e, t) {
437
+ t.fill && Re(e, t), t.stroke?.paint && Ct(e, t);
438
+ }
439
+ function Re(e, t) {
440
+ let n = t.fill, r = n.fill === void 0 || n.fill === "solid", i = !!(t.vertexColors && t.vertexColors.length > 0), a = n, o = H(e, n, i);
383
441
  if (o === null) return;
384
442
  if (o !== void 0 && t.path.kind === "rect") {
385
- o.kind === "ramp" ? Je(e, t.path, o) : Ve(e, t.path, o);
443
+ o.kind === "ramp" ? nt(e, t.path, o) : Ye(e, t.path, o);
386
444
  return;
387
445
  }
388
- let s = me(e, t.path);
389
- if (V(e, s, o)) return;
390
- let c = he(e, s);
391
- r && i ? Xe(e, t, a, c) : c.requiresStencil ? dt(e, n, c) : q(e, n, c);
446
+ let s = ge(e, t.path);
447
+ if (W(e, s, o)) return;
448
+ let c = _e(e, s);
449
+ r && i ? it(e, t, a, c) : c.requiresStencil ? bt(e, n, c) : lt(e, n, c);
392
450
  }
393
- var je = new Int32Array(Array.from({ length: t }, (e, t) => t)), M = new Float32Array(2 * t);
394
- function Me(e) {
451
+ var ze = new Int32Array(Array.from({ length: t }, (e, t) => t)), F = new Float32Array(2 * t);
452
+ function Be(e) {
395
453
  return e === s || E(s, e);
396
454
  }
397
- function N(e, t, n, r, i = 0) {
398
- if (t.clipDepth !== e.clipDepth || t.synthBold !== i || !t.foldsAlpha && t.alpha !== e.state.alpha || n !== void 0 && Ne(t, n, r) < 0) return !1;
455
+ function I(e, t, n, r, i = 0) {
456
+ if (t.clipDepth !== (e.clipStack.length === 0 ? e.clipDepth : Ie(e)) || t.synthBold !== i || !t.foldsAlpha && t.alpha !== e.state.alpha || n !== void 0 && Ve(t, n, r) < 0) return !1;
399
457
  let a = e.state.colorMatrix;
400
458
  return t.colorMatrix === a || E(t.colorMatrix, a);
401
459
  }
402
- function Ne(e, t, n) {
460
+ function Ve(e, t, n) {
403
461
  for (let r = 0; r < e.textures.length; r++) {
404
462
  let i = e.textures[r];
405
463
  if (i.kind === "bitmap" && i.image === t) return i.sampling === n ? r + 1 : -1;
406
464
  }
407
- return P(e);
465
+ return L(e);
408
466
  }
409
- function Pe(e) {
467
+ function He(e) {
410
468
  for (let t = 0; t < e.textures.length; t++) if (e.textures[t].kind === "ramps") return t + 1;
411
- return P(e);
469
+ return L(e);
412
470
  }
413
- function Fe(e, t) {
471
+ function Ue(e, t) {
414
472
  for (let n = 0; n < e.textures.length; n++) {
415
473
  let r = e.textures[n];
416
474
  if (r.kind === "atlas" && r.id === t) return n + 1;
417
475
  }
418
- return P(e);
476
+ return L(e);
419
477
  }
420
- function P(e) {
478
+ function L(e) {
421
479
  return e.textures.length + 1 < t ? e.textures.length + 1 : -1;
422
480
  }
423
- var Ie = 256;
424
- function Le(e) {
425
- return !e.requiresStencil && e.vertices.length >> 1 <= Ie;
481
+ var We = 256;
482
+ function Ge(e) {
483
+ return !e.requiresStencil && e.vertices.length >> 1 <= We;
426
484
  }
427
- function F(e, t) {
428
- return e.batchState !== void 0 && !N(e, e.batchState) && H(e), e.drawBatch.wouldOverflow(t) && H(e), I(e);
485
+ function R(e, t) {
486
+ return e.batchState !== void 0 && !I(e, e.batchState) && G(e), e.drawBatch.wouldOverflow(t) && G(e), z(e);
429
487
  }
430
- function I(e) {
488
+ function z(e) {
431
489
  if (e.batchState === void 0) {
432
- let t = e.state.colorMatrix, n = Me(t);
490
+ let t = e.state.colorMatrix, n = Be(t);
433
491
  e.batchState = {
434
492
  alpha: n ? 1 : e.state.alpha,
435
493
  colorMatrix: t,
436
- clipDepth: e.clipDepth,
494
+ clipDepth: Ie(e),
437
495
  synthBold: 0,
438
496
  foldsAlpha: n,
439
497
  textures: []
@@ -441,9 +499,9 @@ function I(e) {
441
499
  }
442
500
  return e.batchState;
443
501
  }
444
- function L(e, t, n) {
445
- e.batchState !== void 0 && !N(e, e.batchState, t, n) && H(e), e.drawBatch.wouldOverflow(4) && H(e);
446
- let r = I(e), i = Ne(r, t, n);
502
+ function B(e, t, n) {
503
+ e.batchState !== void 0 && !I(e, e.batchState, t, n) && G(e), e.drawBatch.wouldOverflow(4) && G(e);
504
+ let r = z(e), i = Ve(r, t, n);
447
505
  return i > r.textures.length && (r.textures.push({
448
506
  kind: "bitmap",
449
507
  image: t,
@@ -453,11 +511,11 @@ function L(e, t, n) {
453
511
  slot: i
454
512
  };
455
513
  }
456
- function Re(e, t, n, r) {
457
- e.batchState !== void 0 && (!N(e, e.batchState, void 0, void 0, r) || Fe(e.batchState, t) < 0) && H(e), e.drawBatch.wouldOverflow(4) && H(e);
458
- let i = I(e);
514
+ function V(e, t, n, r) {
515
+ e.batchState !== void 0 && (!I(e, e.batchState, void 0, void 0, r) || Ue(e.batchState, t) < 0) && G(e), e.drawBatch.wouldOverflow(4) && G(e);
516
+ let i = z(e);
459
517
  i.synthBold = r;
460
- let a = Fe(i, t);
518
+ let a = Ue(i, t);
461
519
  return a > i.textures.length && (i.textures.push({
462
520
  kind: "atlas",
463
521
  id: t,
@@ -467,36 +525,36 @@ function Re(e, t, n, r) {
467
525
  slot: a
468
526
  };
469
527
  }
470
- function ze(e, t, n, r) {
471
- e.gradRamps.wouldReshape(t, n) && H(e), e.batchState !== void 0 && (!N(e, e.batchState) || Pe(e.batchState) < 0) && H(e), e.drawBatch.wouldOverflow(r) && H(e);
472
- let i = I(e), a = Pe(i);
528
+ function Ke(e, t, n, r) {
529
+ e.gradRamps.wouldReshape(t, n) && G(e), e.batchState !== void 0 && (!I(e, e.batchState) || He(e.batchState) < 0) && G(e), e.drawBatch.wouldOverflow(r) && G(e);
530
+ let i = z(e), a = He(i);
473
531
  return a > i.textures.length && (i.textures.push({ kind: "ramps" }), a = i.textures.length), {
474
532
  staged: i,
475
533
  slot: a,
476
534
  rowV: e.gradRamps.rowV(e.gradRamps.upload(t, n))
477
535
  };
478
536
  }
479
- function R(e, t, n) {
537
+ function qe(e, t, n) {
480
538
  return (n ?? 1) * (t.foldsAlpha ? e.state.alpha : 1);
481
539
  }
482
- function Be(e, t, n) {
540
+ function Je(e, t, n) {
483
541
  let [r, i, o, s] = a(n.color);
484
542
  return [
485
543
  r,
486
544
  i,
487
545
  o,
488
- s * R(e, t, n.opacity)
546
+ s * qe(e, t, n.opacity)
489
547
  ];
490
548
  }
491
- function Ve(e, t, n) {
492
- let [r, i, a, o] = Be(e, F(e, 4), n);
493
- e.drawBatch.pushRect(t.x, t.y, t.width, t.height, e.state.transform, r, i, a, o);
549
+ function Ye(e, t, n) {
550
+ let [r, i, a, o] = Je(e, R(e, 4), n);
551
+ e.drawBatch.pushRect(t.x, t.y, t.width, t.height, e.state.transform, r, i, a, o) || N(e, t, n, Ye);
494
552
  }
495
- function He(e, t, n) {
496
- let [r, i, a, o] = Be(e, F(e, t.vertices.length >> 1), n);
497
- e.drawBatch.pushMesh(t, e.state.transform, r, i, a, o);
553
+ function Xe(e, t, n) {
554
+ let [r, i, a, o] = Je(e, R(e, t.vertices.length >> 1), n);
555
+ e.drawBatch.pushMesh(t, e.state.transform, r, i, a, o) || N(e, t, n, Xe);
498
556
  }
499
- function z(e, t, a) {
557
+ function H(e, t, a) {
500
558
  if (a) return;
501
559
  let o = t.fill ?? "solid";
502
560
  if (o === "solid") {
@@ -508,10 +566,10 @@ function z(e, t, a) {
508
566
  };
509
567
  }
510
568
  if (o !== "linear-gradient" && o !== "radial-gradient" && o !== "conic-gradient") return;
511
- let s = t, c = Ue(e, s.units);
512
- return c ? s.fill === "linear-gradient" ? B(s, r, We(c, s)) : s.fill === "radial-gradient" ? B(s, i, Ge(c, s)) : B(s, n, Ke(c, s)) : null;
569
+ let s = t, c = Ze(e, s.units);
570
+ return c ? s.fill === "linear-gradient" ? U(s, r, Qe(c, s)) : s.fill === "radial-gradient" ? U(s, i, $e(c, s)) : U(s, n, et(c, s)) : null;
513
571
  }
514
- function B(e, t, n) {
572
+ function U(e, t, n) {
515
573
  return {
516
574
  kind: "ramp",
517
575
  stops: e.stops,
@@ -521,11 +579,11 @@ function B(e, t, n) {
521
579
  uv: n
522
580
  };
523
581
  }
524
- function Ue(e, t) {
525
- let n = J(e, t);
582
+ function Ze(e, t) {
583
+ let n = X(e, t);
526
584
  return n && o.multiply(n, e.state.transform);
527
585
  }
528
- function We(e, t) {
586
+ function Qe(e, t) {
529
587
  let n = t.to.x - t.from.x, r = t.to.y - t.from.y, i = Math.hypot(n, r) || 1, a = 1 / (i * i);
530
588
  return {
531
589
  ux: (e[0] * n + e[1] * r) * a,
@@ -536,7 +594,7 @@ function We(e, t) {
536
594
  v0: 0
537
595
  };
538
596
  }
539
- function Ge(e, t) {
597
+ function $e(e, t) {
540
598
  let n = 1 / Math.max(t.radius, 1e-4);
541
599
  return {
542
600
  ux: e[0] * n,
@@ -547,7 +605,7 @@ function Ge(e, t) {
547
605
  v0: (e[7] - t.center.y) * n
548
606
  };
549
607
  }
550
- function Ke(e, t) {
608
+ function et(e, t) {
551
609
  let n = Math.cos(t.angle), r = Math.sin(t.angle), i = e[6] - t.center.x, a = e[7] - t.center.y;
552
610
  return {
553
611
  ux: n * e[0] + r * e[1],
@@ -558,7 +616,7 @@ function Ke(e, t) {
558
616
  v0: n * a - r * i
559
617
  };
560
618
  }
561
- function qe(e, t) {
619
+ function tt(e, t) {
562
620
  return e.mode === r ? {
563
621
  uv: {
564
622
  ...e.uv,
@@ -570,28 +628,31 @@ function qe(e, t) {
570
628
  post: t
571
629
  };
572
630
  }
573
- function Je(e, t, n) {
574
- let { staged: r, slot: i, rowV: a } = ze(e, n.stops, n.space, 4), { uv: o, post: s } = qe(n, a);
575
- e.drawBatch.pushGradientRect(t.x, t.y, t.width, t.height, e.state.transform, o, s, i, n.mode, 1, 1, 1, R(e, r, n.opacity));
631
+ function nt(e, t, n) {
632
+ let { staged: r, slot: i, rowV: a } = Ke(e, n.stops, n.space, 4), { uv: o, post: s } = tt(n, a);
633
+ e.drawBatch.pushGradientRect(t.x, t.y, t.width, t.height, e.state.transform, o, s, i, n.mode, 1, 1, 1, qe(e, r, n.opacity)) || N(e, t, n, nt);
576
634
  }
577
- function Ye(e, t, n) {
578
- let { staged: r, slot: i, rowV: a } = ze(e, n.stops, n.space, t.vertices.length >> 1), { uv: o, post: s } = qe(n, a);
579
- e.drawBatch.pushGradientMesh(t, e.state.transform, o, s, i, n.mode, 1, 1, 1, R(e, r, n.opacity));
635
+ function rt(e, t, n) {
636
+ let { staged: r, slot: i, rowV: a } = Ke(e, n.stops, n.space, t.vertices.length >> 1), { uv: o, post: s } = tt(n, a);
637
+ e.drawBatch.pushGradientMesh(t, e.state.transform, o, s, i, n.mode, 1, 1, 1, qe(e, r, n.opacity)) || N(e, t, n, rt);
580
638
  }
581
- function V(e, t, n) {
582
- return n !== void 0 && Le(t) ? (n.kind === "ramp" ? Ye(e, t, n) : He(e, t, n), !0) : (H(e), !1);
639
+ function W(e, t, n) {
640
+ return n !== void 0 && Ge(t) ? (n.kind === "ramp" ? rt(e, t, n) : Xe(e, t, n), !0) : (P(e), !1);
583
641
  }
584
- function H(e) {
642
+ function G(e) {
585
643
  let t = e.drawBatch, n = e.batchState;
586
- if (t.length === 0 || n === void 0) return;
644
+ if (t.length === 0 || n === void 0) {
645
+ e.batchState = void 0;
646
+ return;
647
+ }
587
648
  let r = e.gl, i = e.batchFill;
588
649
  r.useProgram(i.handle);
589
650
  let a = t.uploadAndBind();
590
- W(e, i, O), fe(e, i, 1, 1, 1, 1), D(e, i, n.alpha), r.uniform1f(i.uniform("u_synthBold"), n.synthBold), A(e, i, n.colorMatrix), r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_2D, e.whiteTexture);
651
+ q(e, i, O), me(e, i, 1, 1, 1, 1), D(e, i, n.alpha), r.uniform1f(i.uniform("u_synthBold"), n.synthBold), A(e, i, n.colorMatrix), r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_2D, e.whiteTexture);
591
652
  for (let t = 0; t < n.textures.length; t++) {
592
653
  let i = n.textures[t];
593
654
  if (i.kind === "atlas") {
594
- e.textureCache.bind(i.id, t + 1), M[2 * (t + 1)] = i.fieldScale[0], M[2 * (t + 1) + 1] = i.fieldScale[1];
655
+ e.textureCache.bind(i.id, t + 1), F[2 * (t + 1)] = i.fieldScale[0], F[2 * (t + 1) + 1] = i.fieldScale[1];
595
656
  continue;
596
657
  }
597
658
  if (i.kind === "ramps") {
@@ -600,9 +661,9 @@ function H(e) {
600
661
  }
601
662
  e.imageCache.bind(i.image, t + 1), e.imageCache.setMagFilter(i.image, i.sampling === "nearest" ? r.NEAREST : r.LINEAR);
602
663
  }
603
- r.uniform1iv(i.uniform("u_samplers"), je), r.uniform2fv(i.uniform("u_fieldScale"), M), Y(e, n.clipDepth), w(e, a, e.gl.UNSIGNED_INT), r.activeTexture(r.TEXTURE0), r.bindVertexArray(null), t.reset(), e.batchState = void 0;
664
+ r.uniform1iv(i.uniform("u_samplers"), ze), r.uniform2fv(i.uniform("u_fieldScale"), F), Z(e, n.clipDepth), w(e, a, e.gl.UNSIGNED_INT), r.activeTexture(r.TEXTURE0), r.bindVertexArray(null), t.reset(), e.batchState = void 0;
604
665
  }
605
- function U(e, t) {
666
+ function K(e, t) {
606
667
  let n = t.anchorA, r = t.anchorB, i = t.anchorT;
607
668
  if (!n || !r || !i) return new Float32Array(e);
608
669
  let a = n.length, o = new Float32Array(a * 4);
@@ -612,33 +673,33 @@ function U(e, t) {
612
673
  }
613
674
  return o;
614
675
  }
615
- function Xe(e, t, n, r) {
676
+ function it(e, t, n, r) {
616
677
  let i = e.gl, a = e.pathFillVColor;
617
- i.useProgram(a.handle), i.bindVertexArray(r.vao), W(e, a), G(e, a, n.color, n.opacity), A(e, a);
618
- let o = U(t.vertexColors, r), s = i.createBuffer();
678
+ i.useProgram(a.handle), i.bindVertexArray(r.vao), q(e, a), J(e, a, n.color, n.opacity), A(e, a);
679
+ let o = K(t.vertexColors, r), s = i.createBuffer();
619
680
  if (!s) throw Error("drawPathFillVColor: createBuffer (color VBO) returned null");
620
681
  i.bindBuffer(i.ARRAY_BUFFER, s), i.bufferData(i.ARRAY_BUFFER, o, i.DYNAMIC_DRAW);
621
682
  let c = a.attribute("a_vertexColor");
622
- c !== void 0 && (i.enableVertexAttribArray(c), i.vertexAttribPointer(c, 4, i.FLOAT, !1, 0, 0)), Y(e), w(e, r.indexCount, e.gl.UNSIGNED_INT), i.bindVertexArray(null), i.deleteBuffer(s);
683
+ c !== void 0 && (i.enableVertexAttribArray(c), i.vertexAttribPointer(c, 4, i.FLOAT, !1, 0, 0)), Z(e), w(e, r.indexCount, e.gl.UNSIGNED_INT), i.bindVertexArray(null), i.deleteBuffer(s);
623
684
  }
624
- function W(e, t, n = e.state.transform, r = pe(e)) {
685
+ function q(e, t, n = e.state.transform, r = he(e)) {
625
686
  let i = e.gl, a = T(e, t);
626
687
  E(a.proj, r) || (i.uniformMatrix3fv(t.uniform("u_proj"), !1, r), a.proj = Float32Array.from(r)), E(a.model, n) || (i.uniformMatrix3fv(t.uniform("u_model"), !1, n), a.model = Float32Array.from(n));
627
688
  }
628
- function G(e, t, n, r) {
689
+ function J(e, t, n, r) {
629
690
  let [i, o, s, c] = a(n);
630
- fe(e, t, i, o, s, c * (r ?? 1)), D(e, t, e.state.alpha);
691
+ me(e, t, i, o, s, c * (r ?? 1)), D(e, t, e.state.alpha);
631
692
  }
632
- function K(e, t) {
693
+ function Y(e, t) {
633
694
  let n = t.fill ?? "solid";
634
- if (n === "solid") return tt(e, t);
635
- if (n === "pattern") return nt(e, t);
636
- if (n === "linear-gradient" || n === "radial-gradient" || n === "conic-gradient") return ot(e, t);
695
+ if (n === "solid") return ut(e, t);
696
+ if (n === "pattern") return dt(e, t);
697
+ if (n === "linear-gradient" || n === "radial-gradient" || n === "conic-gradient") return ht(e, t);
637
698
  let r = l(n)?.bind;
638
- return r ? r(Ze(e), t) : null;
699
+ return r ? r(at(e), t) : null;
639
700
  }
640
- function Ze(e) {
641
- let t = Qe.get(e);
701
+ function at(e) {
702
+ let t = ot.get(e);
642
703
  if (t) return t;
643
704
  let n = {
644
705
  gl: e.gl,
@@ -646,41 +707,41 @@ function Ze(e) {
646
707
  return e.state.alpha;
647
708
  },
648
709
  program: (t) => e.ensureProgram?.(t) ?? e.programRegistry.get(t) ?? null,
649
- setProjAndModel: (t) => W(e, t),
650
- spaceInverse: (t) => J(e, t),
651
- spaceToDevice: (t) => at(e, t),
710
+ setProjAndModel: (t) => q(e, t),
711
+ spaceInverse: (t) => X(e, t),
712
+ spaceToDevice: (t) => mt(e, t),
652
713
  get maxTextureSize() {
653
714
  return e.imageCache.maxTextureSide;
654
715
  },
655
- resources: e.paintResources ?? et(e.gl),
716
+ resources: e.paintResources ?? ct(e.gl),
656
717
  bindRamp: (t, n, r) => {
657
718
  let i = e.gradRamps.upload(t, r);
658
719
  return e.gradRamps.bind(n), e.gradRamps.rowV(i);
659
720
  }
660
721
  };
661
- return Qe.set(e, n), n;
722
+ return ot.set(e, n), n;
662
723
  }
663
- var Qe = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap();
664
- function et(t) {
665
- let n = $e.get(t);
666
- return n || (n = e(), $e.set(t, n)), n;
724
+ var ot = /* @__PURE__ */ new WeakMap(), st = /* @__PURE__ */ new WeakMap();
725
+ function ct(t) {
726
+ let n = st.get(t);
727
+ return n || (n = e(), st.set(t, n)), n;
667
728
  }
668
- function q(e, t, n) {
669
- if (!K(e, t)) return;
729
+ function lt(e, t, n) {
730
+ if (!Y(e, t)) return;
670
731
  let r = e.gl;
671
- r.bindVertexArray(n.vao), Y(e), w(e, n.indexCount, e.gl.UNSIGNED_INT), r.bindVertexArray(null);
732
+ r.bindVertexArray(n.vao), Z(e), w(e, n.indexCount, e.gl.UNSIGNED_INT), r.bindVertexArray(null);
672
733
  }
673
- function tt(e, t) {
734
+ function ut(e, t) {
674
735
  let n = e.pathFill;
675
- return e.gl.useProgram(n.handle), W(e, n), G(e, n, t.color, t.opacity), A(e, n), n;
736
+ return e.gl.useProgram(n.handle), q(e, n), J(e, n, t.color, t.opacity), A(e, n), n;
676
737
  }
677
- function nt(e, t) {
678
- return rt(e, e.patternFill, t, e.state.transform);
738
+ function dt(e, t) {
739
+ return ft(e, e.patternFill, t, e.state.transform);
679
740
  }
680
- function rt(e, t, n, r) {
741
+ function ft(e, t, n, r) {
681
742
  let i = n.pattern, a = c(i.id);
682
743
  if (!a) return (typeof process > "u" || process.env.NODE_ENV !== "production") && console.warn(`weasel: pattern TextureHandle "${i.id}" not registered`), null;
683
- let o = J(e, n.units);
744
+ let o = X(e, n.units);
684
745
  if (!o) return null;
685
746
  let s = d(o, n.origin ?? {
686
747
  x: 0,
@@ -689,144 +750,144 @@ function rt(e, t, n, r) {
689
750
  if (!s) return null;
690
751
  e.textureCache.upload(i.id, a.source, "repeat");
691
752
  let l = e.gl;
692
- l.useProgram(t.handle), W(e, t, r), A(e, t), l.uniformMatrix3fv(t.uniform("u_worldInv"), !1, s);
693
- let [u, f] = it(a.source);
753
+ l.useProgram(t.handle), q(e, t, r), A(e, t), l.uniformMatrix3fv(t.uniform("u_worldInv"), !1, s);
754
+ let [u, f] = pt(a.source);
694
755
  return l.uniform2f(t.uniform("u_tileSize"), u, f), e.textureCache.bind(i.id, 0), l.uniform1i(t.uniform("u_sampler"), 0), l.uniform1f(t.uniform("u_opacity"), n.opacity ?? 1), D(e, t, e.state.alpha), t;
695
756
  }
696
- function it(e) {
757
+ function pt(e) {
697
758
  let t = "naturalWidth" in e ? e.naturalWidth : e.width, n = "naturalHeight" in e ? e.naturalHeight : e.height;
698
759
  return [t || 1, n || 1];
699
760
  }
700
- function J(e, t) {
761
+ function X(e, t) {
701
762
  return t === "local" ? o.invert(e.state.transform) : t === "world" && e.viewMatrix ? o.invert(e.viewMatrix) : o.identity();
702
763
  }
703
- function at(e, t) {
704
- let n = J(e, t), r = n && o.invert(n);
764
+ function mt(e, t) {
765
+ let n = X(e, t), r = n && o.invert(n);
705
766
  if (!r) return null;
706
767
  let i = e.deviceWidth && e.widthCss > 0 ? e.deviceWidth / e.widthCss : 1;
707
768
  return o.multiply(o.scaled(o.identity(), i, i), r);
708
769
  }
709
- function ot(e, t) {
710
- return st(e, e.gradFill, t, e.state.transform);
770
+ function ht(e, t) {
771
+ return gt(e, e.gradFill, t, e.state.transform);
711
772
  }
712
- function st(e, t, n, r) {
713
- let i = J(e, n.units);
773
+ function gt(e, t, n, r) {
774
+ let i = X(e, n.units);
714
775
  if (!i) return null;
715
776
  let a = e.gl, o = e.gradRamps.upload(n.stops, n.interpolate ?? "rgb");
716
- if (a.useProgram(t.handle), W(e, t, r), a.uniformMatrix3fv(t.uniform("u_worldInv"), !1, i), A(e, t), e.gradRamps.bind(0), a.uniform1i(t.uniform("u_ramp"), 0), a.uniform1f(t.uniform("u_rampV"), e.gradRamps.rowV(o)), D(e, t, e.state.alpha), a.uniform1f(t.uniform("u_opacity"), n.opacity ?? 1), n.fill === "linear-gradient") {
777
+ if (a.useProgram(t.handle), q(e, t, r), a.uniformMatrix3fv(t.uniform("u_worldInv"), !1, i), A(e, t), e.gradRamps.bind(0), a.uniform1i(t.uniform("u_ramp"), 0), a.uniform1f(t.uniform("u_rampV"), e.gradRamps.rowV(o)), D(e, t, e.state.alpha), a.uniform1f(t.uniform("u_opacity"), n.opacity ?? 1), n.fill === "linear-gradient") {
717
778
  a.uniform1i(t.uniform("u_gradKind"), 0);
718
779
  let e = n.to.x - n.from.x, r = n.to.y - n.from.y, i = Math.hypot(e, r) || 1;
719
780
  a.uniform2f(t.uniform("u_gradP0"), n.from.x, n.from.y), a.uniform2f(t.uniform("u_gradDir"), e / i, r / i), a.uniform1f(t.uniform("u_gradLen"), i), a.uniform1f(t.uniform("u_gradRadius"), 0), a.uniform1f(t.uniform("u_gradAngle"), 0);
720
781
  } else n.fill === "radial-gradient" ? (a.uniform1i(t.uniform("u_gradKind"), 1), a.uniform2f(t.uniform("u_gradP0"), n.center.x, n.center.y), a.uniform2f(t.uniform("u_gradDir"), 0, 0), a.uniform1f(t.uniform("u_gradLen"), 0), a.uniform1f(t.uniform("u_gradRadius"), n.radius), a.uniform1f(t.uniform("u_gradAngle"), 0)) : (a.uniform1i(t.uniform("u_gradKind"), 2), a.uniform2f(t.uniform("u_gradP0"), n.center.x, n.center.y), a.uniform2f(t.uniform("u_gradDir"), 0, 0), a.uniform1f(t.uniform("u_gradLen"), 0), a.uniform1f(t.uniform("u_gradRadius"), 0), a.uniform1f(t.uniform("u_gradAngle"), n.angle));
721
782
  return t;
722
783
  }
723
- function Y(e, t = e.clipDepth) {
784
+ function Z(e, t = e.clipDepth) {
724
785
  let n = e.gl;
725
786
  if (t === 0) {
726
787
  n.disable(n.STENCIL_TEST);
727
788
  return;
728
789
  }
729
- let r = X(t);
790
+ let r = Q(t);
730
791
  n.enable(n.STENCIL_TEST), n.stencilFunc(n.EQUAL, r, r), n.stencilOp(n.KEEP, n.KEEP, n.KEEP);
731
792
  }
732
- function X(e) {
793
+ function Q(e) {
733
794
  return e === 0 ? 0 : (1 << e + 1) - 1 & 254;
734
795
  }
735
- function ct(e, t) {
736
- let n = e.gl, r = ge(e, t);
737
- n.useProgram(e.pathFill.handle), n.bindVertexArray(r.vao), W(e, e.pathFill), w(e, r.indexCount, e.gl.UNSIGNED_INT), n.bindVertexArray(null);
738
- }
739
- function lt(e, t, n) {
740
- H(e);
741
- let r = e.gl, i = X(n - 1), a = 1 << n, o = i | a;
742
- r.enable(r.STENCIL_TEST), r.colorMask(!1, !1, !1, !1), r.stencilMask(a), r.stencilFunc(r.EQUAL, o, i), r.stencilOp(r.KEEP, r.KEEP, r.REPLACE), ct(e, t), r.colorMask(!0, !0, !0, !0), r.stencilMask(255);
743
- }
744
- function ut(e, t, n) {
745
- H(e);
746
- let r = e.gl;
747
- r.enable(r.STENCIL_TEST);
748
- let i = 1 << n + 1, a = X(n) | i;
749
- r.colorMask(!1, !1, !1, !1), r.stencilMask(i), r.stencilFunc(r.EQUAL, a, a), r.stencilOp(r.KEEP, r.KEEP, r.ZERO), ct(e, t), r.colorMask(!0, !0, !0, !0), r.stencilMask(255);
750
- }
751
- function dt(e, t, n) {
796
+ function _t(e, t, n) {
797
+ let r = e.gl, i = ve(e, t);
798
+ r.useProgram(e.pathFill.handle), r.bindVertexArray(i.vao), q(e, e.pathFill, n), w(e, i.indexCount, e.gl.UNSIGNED_INT), r.bindVertexArray(null);
799
+ }
800
+ function vt(e, t, n, r = e.state.transform) {
801
+ G(e);
802
+ let i = e.gl, a = Q(n - 1), o = 1 << n, s = a | o;
803
+ i.enable(i.STENCIL_TEST), i.colorMask(!1, !1, !1, !1), i.stencilMask(o), i.stencilFunc(i.EQUAL, s, a), i.stencilOp(i.KEEP, i.KEEP, i.REPLACE), _t(e, t, r), i.colorMask(!0, !0, !0, !0), i.stencilMask(255);
804
+ }
805
+ function yt(e, t, n, r = e.state.transform) {
806
+ e.batchState !== void 0 && e.batchState.clipDepth > n && G(e);
807
+ let i = e.gl;
808
+ i.enable(i.STENCIL_TEST);
809
+ let a = 1 << n + 1, o = Q(n) | a;
810
+ i.colorMask(!1, !1, !1, !1), i.stencilMask(a), i.stencilFunc(i.EQUAL, o, o), i.stencilOp(i.KEEP, i.KEEP, i.ZERO), _t(e, t, r), i.colorMask(!0, !0, !0, !0), i.stencilMask(255);
811
+ }
812
+ function bt(e, t, n) {
752
813
  let r = e.gl;
753
- r.useProgram(e.pathFill.handle), r.bindVertexArray(n.vao), W(e, e.pathFill), r.enable(r.STENCIL_TEST), r.colorMask(!1, !1, !1, !1), r.stencilMask(1), r.stencilFunc(r.ALWAYS, 0, 1), r.stencilOp(r.KEEP, r.KEEP, r.INVERT), w(e, n.indexCount, e.gl.UNSIGNED_INT);
754
- let i = X(e.clipDepth);
755
- r.colorMask(!0, !0, !0, !0), r.stencilFunc(r.EQUAL, i | 1, i | 1), r.stencilOp(r.KEEP, r.KEEP, r.KEEP), K(e, t) && w(e, n.indexCount, e.gl.UNSIGNED_INT), r.stencilMask(1), r.clear(r.STENCIL_BUFFER_BIT), r.disable(r.STENCIL_TEST), r.bindVertexArray(null);
814
+ r.useProgram(e.pathFill.handle), r.bindVertexArray(n.vao), q(e, e.pathFill), r.enable(r.STENCIL_TEST), r.colorMask(!1, !1, !1, !1), r.stencilMask(1), r.stencilFunc(r.ALWAYS, 0, 1), r.stencilOp(r.KEEP, r.KEEP, r.INVERT), w(e, n.indexCount, e.gl.UNSIGNED_INT);
815
+ let i = Q(e.clipDepth);
816
+ r.colorMask(!0, !0, !0, !0), r.stencilFunc(r.EQUAL, i | 1, i | 1), r.stencilOp(r.KEEP, r.KEEP, r.KEEP), Y(e, t) && w(e, n.indexCount, e.gl.UNSIGNED_INT), r.stencilMask(1), r.clear(r.STENCIL_BUFFER_BIT), r.disable(r.STENCIL_TEST), r.bindVertexArray(null);
756
817
  }
757
- function ft(e, t) {
818
+ function xt(e, t) {
758
819
  let n = t.stroke, { markerStart: r, markerMid: i, markerEnd: a } = n;
759
- if (typeof n.width != "object" && !Z(r) && !Z(i) && !Z(a)) return t;
820
+ if (typeof n.width != "object" && !$(r) && !$(i) && !$(a)) return t;
760
821
  let s = o.meanScaleOf(e.state.transform), c = { ...n };
761
- return typeof n.width == "object" && (c.width = p(n.width, v(n.width.px, s))), Z(r) && (c.markerStart = Q(r, s)), Z(i) && (c.markerMid = Q(i, s)), Z(a) && (c.markerEnd = Q(a, s)), {
822
+ return typeof n.width == "object" && (c.width = p(n.width, v(n.width.px, s))), $(r) && (c.markerStart = St(r, s)), $(i) && (c.markerMid = St(i, s)), $(a) && (c.markerEnd = St(a, s)), {
762
823
  ...t,
763
824
  stroke: c
764
825
  };
765
826
  }
766
- function Z(e) {
827
+ function $(e) {
767
828
  return typeof e == "object" && typeof e.size == "object";
768
829
  }
769
- function Q(e, t) {
830
+ function St(e, t) {
770
831
  return {
771
832
  ...e,
772
833
  size: _(e, 0, v(e.size.px, t))
773
834
  };
774
835
  }
775
- function pt(e, t) {
776
- let n = ft(e, t), r = n.stroke, i = r.align ?? "center";
777
- n.path.kind === "polygon" && i !== "center" ? (H(e), _t(e, n, i)) : mt(e, n);
836
+ function Ct(e, t) {
837
+ let n = xt(e, t), r = n.stroke, i = r.align ?? "center";
838
+ n.path.kind === "polygon" && i !== "center" ? (P(e), Dt(e, n, i)) : wt(e, n);
778
839
  let a = p(r.width ?? 1, 1);
779
- for (let i of b(n.path, t.stroke, r, a, e.flattenTolerance)) ke(e, i);
840
+ for (let i of b(n.path, t.stroke, r, a, e.flattenTolerance)) Le(e, i);
780
841
  }
781
- function mt(e, t) {
842
+ function wt(e, t) {
782
843
  let n = t.stroke, r = n.paint, i = r.fill === void 0 || r.fill === "solid", a = r, o = y(t.path, n, e.flattenTolerance);
783
844
  if (o.indices.length === 0) return;
784
- let s = !!(n.vertexColors && n.vertexColors.length > 0), c = z(e, r, s);
785
- if (c === null || V(e, o, c)) return;
845
+ let s = !!(n.vertexColors && n.vertexColors.length > 0), c = H(e, r, s);
846
+ if (c === null || W(e, o, c)) return;
786
847
  let l = s ? e.meshCache.uploadTransient(o) : e.meshCache.uploadRecurring(o);
787
848
  if (!i && !s) {
788
- q(e, r, l);
849
+ lt(e, r, l);
789
850
  return;
790
851
  }
791
852
  let u = e.gl;
792
853
  if (s) {
793
854
  let t = e.pathFillVColor;
794
- u.useProgram(t.handle), u.bindVertexArray(l.vao), W(e, t), G(e, t, i ? a.color : "#ffffff", r.opacity), A(e, t);
795
- let o = U(n.vertexColors, l), s = u.createBuffer();
855
+ u.useProgram(t.handle), u.bindVertexArray(l.vao), q(e, t), J(e, t, i ? a.color : "#ffffff", r.opacity), A(e, t);
856
+ let o = K(n.vertexColors, l), s = u.createBuffer();
796
857
  if (!s) throw Error("drawPathStrokeUnclipped: createBuffer (color VBO) returned null");
797
858
  u.bindBuffer(u.ARRAY_BUFFER, s), u.bufferData(u.ARRAY_BUFFER, o, u.DYNAMIC_DRAW);
798
859
  let c = t.attribute("a_vertexColor");
799
- c !== void 0 && (u.enableVertexAttribArray(c), u.vertexAttribPointer(c, 4, u.FLOAT, !1, 0, 0)), Y(e), w(e, l.indexCount, e.gl.UNSIGNED_INT), u.bindVertexArray(null), u.deleteBuffer(s);
860
+ c !== void 0 && (u.enableVertexAttribArray(c), u.vertexAttribPointer(c, 4, u.FLOAT, !1, 0, 0)), Z(e), w(e, l.indexCount, e.gl.UNSIGNED_INT), u.bindVertexArray(null), u.deleteBuffer(s);
800
861
  return;
801
862
  }
802
- u.useProgram(e.pathFill.handle), u.bindVertexArray(l.vao), W(e, e.pathFill), G(e, e.pathFill, a.color, a.opacity), A(e, e.pathFill), Y(e), w(e, l.indexCount, e.gl.UNSIGNED_INT), u.bindVertexArray(null);
863
+ u.useProgram(e.pathFill.handle), u.bindVertexArray(l.vao), q(e, e.pathFill), J(e, e.pathFill, a.color, a.opacity), A(e, e.pathFill), Z(e), w(e, l.indexCount, e.gl.UNSIGNED_INT), u.bindVertexArray(null);
803
864
  }
804
- var ht = /* @__PURE__ */ new WeakMap();
805
- function gt(e) {
806
- let t = ht.get(e);
807
- return t === void 0 && (t = e.map((e) => e * 2), ht.set(e, t)), t;
865
+ var Tt = /* @__PURE__ */ new WeakMap();
866
+ function Et(e) {
867
+ let t = Tt.get(e);
868
+ return t === void 0 && (t = e.map((e) => e * 2), Tt.set(e, t)), t;
808
869
  }
809
- function _t(e, t, n) {
870
+ function Dt(e, t, n) {
810
871
  let r = t.stroke, i = r.paint, a = i.fill === void 0 || i.fill === "solid", o = i, s = {
811
872
  ...r,
812
873
  width: p(r.width ?? 1, 1) * 2,
813
- ...r.vertexWidths ? { vertexWidths: gt(r.vertexWidths) } : {},
874
+ ...r.vertexWidths ? { vertexWidths: Et(r.vertexWidths) } : {},
814
875
  align: "center"
815
- }, c = !!(r.vertexColors && r.vertexColors.length > 0), l = ge(e, t.path), u = y(t.path, s, e.flattenTolerance);
876
+ }, c = !!(r.vertexColors && r.vertexColors.length > 0), l = ve(e, t.path), u = y(t.path, s, e.flattenTolerance);
816
877
  if (u.indices.length === 0) return;
817
878
  let d = c ? e.meshCache.uploadTransient(u) : e.meshCache.uploadRecurring(u), f = e.gl, m = c ? e.pathFillVColor : e.pathFill;
818
- f.useProgram(m.handle), W(e, m), f.enable(f.STENCIL_TEST), f.colorMask(!1, !1, !1, !1), f.stencilMask(1), f.stencilFunc(f.ALWAYS, 1, 1), f.stencilOp(f.KEEP, f.KEEP, f.REPLACE), f.bindVertexArray(l.vao), w(e, l.indexCount, e.gl.UNSIGNED_INT);
819
- let h = X(e.clipDepth);
879
+ f.useProgram(m.handle), q(e, m), f.enable(f.STENCIL_TEST), f.colorMask(!1, !1, !1, !1), f.stencilMask(1), f.stencilFunc(f.ALWAYS, 1, 1), f.stencilOp(f.KEEP, f.KEEP, f.REPLACE), f.bindVertexArray(l.vao), w(e, l.indexCount, e.gl.UNSIGNED_INT);
880
+ let h = Q(e.clipDepth);
820
881
  f.colorMask(!0, !0, !0, !0), n === "inner" ? f.stencilFunc(f.EQUAL, h | 1, h | 1) : f.stencilFunc(f.EQUAL, h, h | 1), f.stencilOp(f.KEEP, f.KEEP, f.KEEP);
821
882
  let g = m;
822
- if (c ? (G(e, m, a ? o.color : "#ffffff", i.opacity), A(e, m)) : g = K(e, i), !g) {
883
+ if (c ? (J(e, m, a ? o.color : "#ffffff", i.opacity), A(e, m)) : g = Y(e, i), !g) {
823
884
  f.stencilMask(1), f.clear(f.STENCIL_BUFFER_BIT), f.disable(f.STENCIL_TEST), f.bindVertexArray(null);
824
885
  return;
825
886
  }
826
887
  f.bindVertexArray(d.vao);
827
888
  let _ = null;
828
889
  if (c) {
829
- let e = U(r.vertexColors, d);
890
+ let e = K(r.vertexColors, d);
830
891
  if (_ = f.createBuffer(), !_) throw Error("drawPathStrokeStenciled: createBuffer (color VBO) returned null");
831
892
  f.bindBuffer(f.ARRAY_BUFFER, _), f.bufferData(f.ARRAY_BUFFER, e, f.DYNAMIC_DRAW);
832
893
  let t = g.attribute("a_vertexColor");
@@ -834,13 +895,13 @@ function _t(e, t, n) {
834
895
  }
835
896
  w(e, d.indexCount, e.gl.UNSIGNED_INT), f.stencilMask(1), f.clear(f.STENCIL_BUFFER_BIT), f.disable(f.STENCIL_TEST), f.bindVertexArray(null), _ && f.deleteBuffer(_);
836
897
  }
837
- var vt = 48;
838
- function yt(e) {
898
+ var Ot = 48;
899
+ function kt(e) {
839
900
  let t = Math.hypot(e[0], e[1]), n = Math.hypot(e[3], e[4]);
840
901
  return Math.sqrt(t * n) || 1;
841
902
  }
842
- function bt(e, t) {
843
- let n = se(t.style), r = n.lineHeight, i = t.align ?? n.align, a = t.maxWidth ?? Infinity, o = e.textOutlineMinScreenSize ?? vt, s = Number.isFinite(o) ? o / yt(e.state.transform) : void 0, c = oe(t.runs, {
903
+ function At(e, t) {
904
+ let n = le(t.style), r = n.lineHeight, i = t.align ?? n.align, a = t.maxWidth ?? Infinity, o = e.textOutlineMinScreenSize ?? Ot, s = Number.isFinite(o) ? o / kt(e.state.transform) : void 0, c = ce(t.runs, {
844
905
  maxWidth: a,
845
906
  alignWidth: t.width,
846
907
  lineHeight: r,
@@ -849,35 +910,35 @@ function bt(e, t) {
849
910
  outlineMinSize: s
850
911
  });
851
912
  if (c.groups.length === 0 && c.decorations.length === 0) return;
852
- let l = t.x, u = t.y + ce(t.verticalAlign, t.height, c.bounds.height);
853
- for (let t of c.groups) t.source === "outline" ? xt(e, t, l, u) : kt(e, t, l, u);
854
- Et(e, c.decorations, l, u);
913
+ let l = t.x, u = t.y + ue(t.verticalAlign, t.height, c.bounds.height);
914
+ for (let t of c.groups) t.source === "outline" ? jt(e, t, l, u) : zt(e, t, l, u);
915
+ It(e, c.decorations, l, u);
855
916
  }
856
- function xt(e, t, n, r) {
917
+ function jt(e, t, n, r) {
857
918
  let i = t.fill;
858
919
  if (i !== null) {
859
- let a = Ct(t, n, r);
860
- a && St(e, i, a);
920
+ let a = Nt(t, n, r);
921
+ a && Mt(e, i, a);
861
922
  }
862
923
  let a = t.stroke?.paint;
863
924
  if (!a) return;
864
- let s = wt(t, n, r, o.meanScaleOf(e.state.transform));
865
- s && St(e, a, s);
925
+ let s = Pt(t, n, r, o.meanScaleOf(e.state.transform));
926
+ s && Mt(e, a, s);
866
927
  }
867
- function St(e, t, n) {
868
- let r = z(e, t, !1);
869
- r !== null && (V(e, n, r) || q(e, t, e.meshCache.uploadTransient(n)));
928
+ function Mt(e, t, n) {
929
+ let r = H(e, t, !1);
930
+ r !== null && (W(e, n, r) || lt(e, t, e.meshCache.uploadTransient(n)));
870
931
  }
871
- function Ct(e, t, n) {
872
- return Tt(e, t, n, (e) => m(e.key, e.d));
932
+ function Nt(e, t, n) {
933
+ return Ft(e, t, n, (e) => m(e.key, e.d));
873
934
  }
874
- function wt(e, t, n, r) {
935
+ function Pt(e, t, n, r) {
875
936
  let i = e.stroke;
876
937
  if (!i) return null;
877
938
  let a = p(i.width ?? 1, r);
878
- return a > 0 ? Tt(e, t, n, (e) => e.scale > 0 ? h(e.key, e.d, g(a / e.scale), i) : null) : null;
939
+ return a > 0 ? Ft(e, t, n, (e) => e.scale > 0 ? h(e.key, e.d, g(a / e.scale), i) : null) : null;
879
940
  }
880
- function Tt(e, t, n, r) {
941
+ function Ft(e, t, n, r) {
881
942
  let i = [], a = 0, o = 0;
882
943
  for (let t of e.glyphs) {
883
944
  let e = r(t);
@@ -887,7 +948,7 @@ function Tt(e, t, n, r) {
887
948
  }), a += e.vertices.length, o += e.indices.length);
888
949
  }
889
950
  if (i.length === 0) return null;
890
- let s = e.synthetic.italic ? Math.tan(x) : 0, c = new Float32Array(a), l = new Uint32Array(o), u = 0, d = 0, f = 0;
951
+ let s = e.synthetic.italic ? Math.tan(te) : 0, c = new Float32Array(a), l = new Uint32Array(o), u = 0, d = 0, f = 0;
891
952
  for (let { mesh: e, glyph: r } of i) {
892
953
  let { x: i, baselineY: a, scale: o } = r;
893
954
  for (let r = 0; r < e.vertices.length; r += 2) {
@@ -902,10 +963,10 @@ function Tt(e, t, n, r) {
902
963
  indices: l
903
964
  };
904
965
  }
905
- function Et(e, t, n, r) {
966
+ function It(e, t, n, r) {
906
967
  for (let i of t) {
907
- if (At(i.fill) !== null) {
908
- St(e, i.fill, Dt(i.x0 + n, i.y0 + r, i.x1 + n, i.y1 + r));
968
+ if (Bt(i.fill) !== null) {
969
+ Mt(e, i.fill, Lt(i.x0 + n, i.y0 + r, i.x1 + n, i.y1 + r));
909
970
  continue;
910
971
  }
911
972
  let [t, o, s, c] = "color" in i.fill ? a(i.fill.color) : [
@@ -913,11 +974,16 @@ function Et(e, t, n, r) {
913
974
  0,
914
975
  0,
915
976
  1
916
- ], l = F(e, 4);
917
- e.drawBatch.pushRect(i.x0 + n, i.y0 + r, i.x1 - i.x0, i.y1 - i.y0, e.state.transform, t, o, s, c * (l.foldsAlpha ? e.state.alpha : 1));
977
+ ], l;
978
+ for (;;) {
979
+ let a = R(e, 4);
980
+ if (e.drawBatch.pushRect(i.x0 + n, i.y0 + r, i.x1 - i.x0, i.y1 - i.y0, e.state.transform, t, o, s, c * (a.foldsAlpha ? e.state.alpha : 1))) break;
981
+ l = j(e);
982
+ }
983
+ l !== void 0 && M(e, l);
918
984
  }
919
985
  }
920
- function Dt(e, t, n, r) {
986
+ function Lt(e, t, n, r) {
921
987
  return {
922
988
  vertices: new Float32Array([
923
989
  e,
@@ -939,17 +1005,17 @@ function Dt(e, t, n, r) {
939
1005
  ])
940
1006
  };
941
1007
  }
942
- var Ot = .08;
943
- function kt(e, t, n, r) {
1008
+ var Rt = .08;
1009
+ function zt(e, t, n, r) {
944
1010
  if (t.source === "canvas") {
945
- if (!ie(e.textureCache, t.page)) return;
946
- } else if (!ne(t.family, t.weight, t.style, e.textureCache)) return;
1011
+ if (!oe(e.textureCache, t.page)) return;
1012
+ } else if (!ie(t.family, t.weight, t.style, e.textureCache)) return;
947
1013
  if (t.quads.length === 0) return;
948
- let i = t.source === "canvas" ? C(t.page) : ae(t.family, t.weight, t.style), o = t.source === "canvas" ? te : S, s = re(t.source === "canvas" ? "canvas" : "atlas", t.family, t.weight, t.style);
1014
+ let i = t.source === "canvas" ? re(t.page) : se(t.family, t.weight, t.style), o = t.source === "canvas" ? ne : C, s = ae(t.source === "canvas" ? "canvas" : "atlas", t.family, t.weight, t.style);
949
1015
  if (!s) return;
950
- let c = t.synthetic.bold ? Ot : 0, l = t.synthetic.italic ? Math.tan(x) : 0, u = At(t.fill);
1016
+ let c = t.synthetic.bold ? Rt : 0, l = t.synthetic.italic ? Math.tan(te) : 0, u = Bt(t.fill);
951
1017
  if (u !== null) {
952
- jt(e, t, n, r, u, i, o, c, l, s);
1018
+ Ht(e, t, n, r, u, i, o, c, l, s);
953
1019
  return;
954
1020
  }
955
1021
  let d = t.fill !== null && "color" in t.fill ? a(t.fill.color) : [
@@ -957,37 +1023,43 @@ function kt(e, t, n, r) {
957
1023
  0,
958
1024
  0,
959
1025
  1
960
- ], f = e.drawBatch, p = e.state.transform, { staged: m, slot: h } = Re(e, i, s, c), g = d[3] * (m.foldsAlpha ? e.state.alpha : 1);
961
- for (let a of t.quads) f.wouldOverflow(4) && (H(e), {staged: m, slot: h} = Re(e, i, s, c), g = d[3] * (m.foldsAlpha ? e.state.alpha : 1)), f.pushGlyph(a.x0 + n, a.y0 + r, a.x1 + n, a.y1 + r, a.baselineY + r, l, p, a.u0, a.v0, a.u1, a.v1, d[0], d[1], d[2], g, h, o);
1026
+ ], f = e.drawBatch, p = e.state.transform, { staged: m, slot: h } = V(e, i, s, c), g = d[3] * (m.foldsAlpha ? e.state.alpha : 1);
1027
+ for (let a of t.quads) {
1028
+ f.wouldOverflow(4) && (G(e), {staged: m, slot: h} = V(e, i, s, c), g = d[3] * (m.foldsAlpha ? e.state.alpha : 1));
1029
+ let t;
1030
+ for (; !f.pushGlyph(a.x0 + n, a.y0 + r, a.x1 + n, a.y1 + r, a.baselineY + r, l, p, a.u0, a.v0, a.u1, a.v1, d[0], d[1], d[2], g, h, o);) t = j(e), {staged: m, slot: h} = V(e, i, s, c), g = d[3] * (m.foldsAlpha ? e.state.alpha : 1);
1031
+ t !== void 0 && (M(e, t), {staged: m, slot: h} = V(e, i, s, c), g = d[3] * (m.foldsAlpha ? e.state.alpha : 1));
1032
+ }
962
1033
  }
963
- function At(e) {
1034
+ function Bt(e) {
964
1035
  let t = e?.fill ?? "solid";
965
1036
  return t === "pattern" ? "pattern" : t === "linear-gradient" || t === "radial-gradient" || t === "conic-gradient" ? "gradient" : t === "solid" ? null : "texture";
966
1037
  }
967
- var $ = 1;
968
- function jt(e, t, n, r, i, a, o, s, c, l) {
1038
+ var Vt = 1;
1039
+ function Ht(e, t, n, r, i, a, o, s, c, l) {
969
1040
  let u = e.glyphPaintProgram?.(i);
970
1041
  if (!u) return;
971
- H(e);
1042
+ P(e);
972
1043
  let d = t.fill, f = e.state.transform, p;
973
- if (i === "pattern") p = rt(e, u, d, O);
974
- else if (i === "gradient") p = st(e, u, d, O);
1044
+ if (i === "pattern") p = ft(e, u, d, O);
1045
+ else if (i === "gradient") p = gt(e, u, d, O);
975
1046
  else {
976
- let i = Ft(e, d, Nt(t, n, r, c, f));
977
- p = i && It(e, u, i);
1047
+ let i = Kt(e, d, Wt(t, n, r, c, f));
1048
+ p = i && qt(e, u, i);
978
1049
  }
979
1050
  if (!p) return;
980
1051
  let m = e.gl;
981
- e.textureCache.bind(a, $), m.uniform1i(u.uniform("u_atlas"), $), m.uniform1f(u.uniform("u_synthBold"), s), m.uniform2f(u.uniform("u_fieldScale"), l[0], l[1]), Y(e);
982
- let h = e.drawBatch;
983
- for (let i of t.quads) h.wouldOverflow(4) && Mt(e), h.pushGlyph(i.x0 + n, i.y0 + r, i.x1 + n, i.y1 + r, i.baselineY + r, c, f, i.u0, i.v0, i.u1, i.v1, 1, 1, 1, 1, $, o);
984
- Mt(e), m.activeTexture(m.TEXTURE0), m.bindVertexArray(null);
1052
+ e.textureCache.bind(a, Vt), m.uniform1i(u.uniform("u_atlas"), Vt), m.uniform1f(u.uniform("u_synthBold"), s), m.uniform2f(u.uniform("u_fieldScale"), l[0], l[1]), Z(e);
1053
+ let h = e.drawBatch, g = h.clip;
1054
+ h.clip = null;
1055
+ for (let i of t.quads) h.wouldOverflow(4) && Ut(e), h.pushGlyph(i.x0 + n, i.y0 + r, i.x1 + n, i.y1 + r, i.baselineY + r, c, f, i.u0, i.v0, i.u1, i.v1, 1, 1, 1, 1, Vt, o);
1056
+ Ut(e), h.clip = g, m.activeTexture(m.TEXTURE0), m.bindVertexArray(null);
985
1057
  }
986
- function Mt(e) {
1058
+ function Ut(e) {
987
1059
  let t = e.drawBatch;
988
1060
  t.length !== 0 && (w(e, t.uploadAndBind(), e.gl.UNSIGNED_INT), t.reset());
989
1061
  }
990
- function Nt(e, t, n, r, i) {
1062
+ function Wt(e, t, n, r, i) {
991
1063
  let a = {
992
1064
  x0: Infinity,
993
1065
  y0: Infinity,
@@ -1003,7 +1075,7 @@ function Nt(e, t, n, r, i) {
1003
1075
  }
1004
1076
  return a;
1005
1077
  }
1006
- var Pt = {
1078
+ var Gt = {
1007
1079
  vertices: new Float32Array([
1008
1080
  0,
1009
1081
  0,
@@ -1023,7 +1095,7 @@ var Pt = {
1023
1095
  3
1024
1096
  ])
1025
1097
  };
1026
- function Ft(e, t, n) {
1098
+ function Kt(e, t, n) {
1027
1099
  let r = e.paintScratch, i = l(t.fill)?.bind;
1028
1100
  if (!r || !i) return null;
1029
1101
  let a = e.deviceWidth && e.widthCss > 0 ? e.deviceWidth / e.widthCss : 1, o = e.deviceWidth ?? Math.round(e.widthCss), s = e.deviceHeight ?? Math.round(e.heightCss), c = Math.max(0, Math.floor(n.x0 * a)), u = Math.max(0, Math.floor(n.y0 * a)), d = e.imageCache.maxTextureSide, f = Math.min(d, Math.min(o, Math.ceil(n.x1 * a)) - c), p = Math.min(d, Math.min(s, Math.ceil(n.y1 * a)) - u);
@@ -1048,15 +1120,15 @@ function Ft(e, t, n) {
1048
1120
  -1 - 2 * m / g,
1049
1121
  -1 - 2 * h / _,
1050
1122
  1
1051
- ]), b = Ze(e), ee = {
1123
+ ]), b = at(e), ee = {
1052
1124
  ...b,
1053
1125
  alpha: e.state.alpha,
1054
1126
  maxTextureSize: b.maxTextureSize,
1055
- setProjAndModel: (t) => W(e, t, v, y)
1127
+ setProjAndModel: (t) => q(e, t, v, y)
1056
1128
  }, x = e.gl, S = r.acquire(f, p), te = x.isEnabled(x.SCISSOR_TEST);
1057
1129
  x.activeTexture(x.TEXTURE0), x.bindTexture(x.TEXTURE_2D, null), x.bindFramebuffer(x.FRAMEBUFFER, S.fbo), x.viewport(0, 0, f, p), x.disable(x.SCISSOR_TEST), x.disable(x.STENCIL_TEST), x.clear(x.COLOR_BUFFER_BIT), x.disable(x.BLEND);
1058
1130
  let C = i(ee, t);
1059
- return C && (x.bindVertexArray(e.meshCache.uploadRecurring(Pt).vao), w(e, Pt.indices.length, x.UNSIGNED_INT), x.bindVertexArray(null)), x.enable(x.BLEND), Ee(e, o, s, te), C ? {
1131
+ return C && (x.bindVertexArray(e.meshCache.uploadRecurring(Gt).vao), w(e, Gt.indices.length, x.UNSIGNED_INT), x.bindVertexArray(null)), x.enable(x.BLEND), ke(e, o, s, te), C ? {
1060
1132
  texture: S.texture,
1061
1133
  uvFromScreen: new Float32Array([
1062
1134
  a / S.width,
@@ -1071,13 +1143,13 @@ function Ft(e, t, n) {
1071
1143
  ])
1072
1144
  } : null;
1073
1145
  }
1074
- function It(e, t, n) {
1146
+ function qt(e, t, n) {
1075
1147
  let r = e.gl;
1076
- return r.useProgram(t.handle), W(e, t, O), r.uniformMatrix3fv(t.uniform("u_worldInv"), !1, n.uvFromScreen), r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_2D, n.texture), r.uniform1i(t.uniform("u_sampler"), 0), t;
1148
+ return r.useProgram(t.handle), q(e, t, O), r.uniformMatrix3fv(t.uniform("u_worldInv"), !1, n.uvFromScreen), r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_2D, n.texture), r.uniform1i(t.uniform("u_sampler"), 0), t;
1077
1149
  }
1078
- function Lt(e, t) {
1150
+ function Jt(e, t) {
1079
1151
  e.imageCache.upload(t.image, t.image);
1080
- let { staged: n, slot: r } = L(e, t.image, t.sampling ?? "linear"), i = t.source, a = 0, o = 0, s = 1, c = 1;
1152
+ let { staged: n, slot: r } = B(e, t.image, t.sampling ?? "linear"), i = t.source, a = 0, o = 0, s = 1, c = 1;
1081
1153
  if (i) {
1082
1154
  let e = t.image.width, n = t.image.height;
1083
1155
  a = i.x / e, s = (i.x + i.w) / e, o = i.y / n, c = (i.y + i.h) / n;
@@ -1090,20 +1162,21 @@ function Lt(e, t) {
1090
1162
  let e = o;
1091
1163
  o = c, c = e;
1092
1164
  }
1093
- e.drawBatch.pushQuad(t.x, t.y, t.w, t.h, e.state.transform, a, o, s, c, (t.opacity ?? 1) * (n.foldsAlpha ? e.state.alpha : 1), r);
1165
+ e.drawBatch.pushQuad(t.x, t.y, t.w, t.h, e.state.transform, a, o, s, c, (t.opacity ?? 1) * (n.foldsAlpha ? e.state.alpha : 1), r) || N(e, t, void 0, Jt);
1094
1166
  }
1095
- function Rt(e, t) {
1167
+ function Yt(e, t) {
1096
1168
  let n = t.sprites, r = Math.floor(n.length / u);
1097
1169
  if (r === 0) return;
1098
1170
  e.imageCache.upload(t.image, t.image);
1099
- let i = t.sampling ?? "linear", { staged: a, slot: o } = L(e, t.image, i), s = e.drawBatch, c = e.state.transform, l = a.foldsAlpha ? e.state.alpha : 1, d = t.image.width, f = t.image.height;
1171
+ let i = t.sampling ?? "linear", { staged: a, slot: o } = B(e, t.image, i), s = e.drawBatch, c = e.state.transform, l = a.foldsAlpha ? e.state.alpha : 1, d = t.image.width, f = t.image.height;
1100
1172
  for (let p = 0, m = 0; p < r; p++, m += u) {
1101
- s.wouldOverflow(4) && (H(e), {staged: a, slot: o} = L(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1);
1102
- let r = n[m + 4], u = n[m + 5], p = n[m + 6], h = n[m + 7];
1103
- s.pushQuad(n[m], n[m + 1], n[m + 2], n[m + 3], c, r / d, u / f, (r + p) / d, (u + h) / f, n[m + 8] * l, o);
1173
+ s.wouldOverflow(4) && (G(e), {staged: a, slot: o} = B(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1);
1174
+ let r = n[m + 4], u = n[m + 5], p = n[m + 6], h = n[m + 7], g;
1175
+ for (; !s.pushQuad(n[m], n[m + 1], n[m + 2], n[m + 3], c, r / d, u / f, (r + p) / d, (u + h) / f, n[m + 8] * l, o);) g = j(e), {staged: a, slot: o} = B(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1;
1176
+ g !== void 0 && (M(e, g), {staged: a, slot: o} = B(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1);
1104
1177
  }
1105
1178
  }
1106
1179
  //#endregion
1107
- export { vt as OUTLINE_MIN_SCREEN_PX, j as dispatch, Oe as drawGroup, H as flushBatch, f as getMesh, o as mat3, ut as popClip, lt as pushClip, ye as setUniform, V as tryStageFill };
1180
+ export { Ot as OUTLINE_MIN_SCREEN_PX, ye as dispatch, je as drawGroup, G as flushBatch, f as getMesh, o as mat3, yt as popClip, vt as pushClip, Se as setUniform, W as tryStageFill };
1108
1181
 
1109
1182
  //# sourceMappingURL=draw.js.map