@wonderyard/vivarium 1.4.0 → 1.4.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 (2) hide show
  1. package/dist/webgpu/setup.js +858 -859
  2. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { x as b, k as m, p, y as be, M as rr, J as Wt, i as ye, R as Xn, d as T, s as nr, m as Bt, o as c, _ as Ae, D as jt, e as Ui, h as Se, F as Fe, f as pe, v as C, g as I, u as Dr, j as Oe, q as $t, r as Yr, P as ve, t as Tt, w as qr, l as Be, z as _t, N as Tn, B as U, E as g, H as Nt, Y as Is, I as ze, K as y, L as la, Q as Es, U as Us, V as xe, W as Ke, X as ti, Z as Gr, $ as Pe, a0 as lt, a1 as Ms, a2 as le, a3 as Ue, a4 as ot, a5 as ri, a6 as He, a7 as et, a8 as ni, a9 as _n, aa as ar, ab as un, ac as It, ad as Ps, ae as Dt, af as ku, ag as Ss, ah as zs, ai as Vr, aj as Zn, ak as x, al as re, am as ca, an as de, ao as Au, ap as Gu, aq as Ou, ar as Bu, as as Cu, at as Fu, au as Nu, av as Wr, aw as Jr, ax as Lu, ay as Ru, az as ks, aA as ai, aB as Wu, aC as ju, aD as Du, aE as Yu, aF as qu, aG as Vu, aH as Ju, aI as Xu, aJ as Zu, aK as Qu, aL as Ku, aM as Hu, aN as el, aO as tl, aP as rl, aQ as nl, aR as al, aS as il, aT as sl, aU as ol, aV as ul, aW as ll, aX as ii, aY as cl, aZ as pl, a_ as dl, a$ as ml, b0 as hl, b1 as fl, b2 as yl, b3 as gl, b4 as vl, b5 as wl, b6 as xl, b7 as bl, b8 as $l, b9 as Tl, ba as _l, bb as Il, bc as El, bd as Ul, be as Ml, bf as As, bg as Yt, bh as si, bi as Ie, bj as Pl, bk as jn, bl as Gs, bm as Sl, bn as oi, bo as An, bp as Mt, bq as we, br as zl, bs as Os, bt as j, bu as Ct, bv as kl, bw as er, bx as Al, by as Mi, bz as Or, bA as Pi, bB as Si, bC as Bs, bD as Br, bE as Gl, bF as ui, bG as Ol, bH as Pa, bI as V, bJ as Bl, bK as Pr, bL as hr, bM as Gn, bN as zi, bO as Cl, bP as Fl, bQ as On, bR as Nl, bS as Ll, bT as Ye, bU as Pt, bV as Qn, bW as ki, bX as fn, bY as Cs, bZ as ct, b_ as Rl, b$ as Wl, c0 as jl, c1 as Dl, c2 as Yl, c3 as Ai, c4 as pa, c5 as li, c6 as Fs, c7 as ql, c8 as Sa, c9 as Lr, ca as Gi, cb as Oi, cc as Vl, cd as Jl, ce as Xl, cf as Bi, cg as Kn, ch as Zl, ci as Ql, b as za, a as ka, G as Ns, cj as Aa, O as Ot, A as Hr, T as Ci } from "../constants-D4GX9YB2.js";
2
- import { compileGpuAutomaton as Kl } from "./compiler.js";
1
+ import { x as b, k as m, p, y as be, M as nr, J as Wt, i as ye, R as Xn, d as T, s as ar, m as Bt, o as c, _ as Ae, D as jt, e as Ui, h as Se, F as Fe, f as pe, v as C, g as I, u as Dr, j as Oe, q as $t, r as Yr, P as ve, t as Tt, w as qr, l as Be, z as _t, N as Tn, B as U, E as g, H as Nt, Y as Is, I as ze, K as y, L as la, Q as Es, U as Us, V as xe, W as Ke, X as ti, Z as Gr, $ as Pe, a0 as lt, a1 as Ms, a2 as le, a3 as Ue, a4 as ot, a5 as ri, a6 as He, a7 as et, a8 as ni, a9 as _n, aa as ir, ab as un, ac as It, ad as Ps, ae as Dt, af as zu, ag as Ss, ah as zs, ai as Vr, aj as Zn, ak as x, al as re, am as ca, an as de, ao as ku, ap as Au, aq as Gu, ar as Ou, as as Bu, at as Cu, au as Fu, av as Wr, aw as Jr, ax as Nu, ay as Lu, az as ks, aA as ai, aB as Ru, aC as Wu, aD as ju, aE as Du, aF as Yu, aG as qu, aH as Vu, aI as Ju, aJ as Xu, aK as Zu, aL as Qu, aM as Ku, aN as Hu, aO as el, aP as tl, aQ as rl, aR as nl, aS as al, aT as il, aU as sl, aV as ol, aW as ul, aX as ii, aY as ll, aZ as cl, a_ as pl, a$ as dl, b0 as ml, b1 as hl, b2 as fl, b3 as yl, b4 as gl, b5 as vl, b6 as wl, b7 as xl, b8 as bl, b9 as $l, ba as Tl, bb as _l, bc as Il, bd as El, be as Ul, bf as As, bg as Yt, bh as si, bi as Ie, bj as Ml, bk as jn, bl as Gs, bm as Pl, bn as oi, bo as An, bp as Mt, bq as we, br as Sl, bs as Os, bt as j, bu as Ct, bv as zl, bw as tr, bx as kl, by as Mi, bz as Or, bA as Pi, bB as Si, bC as Bs, bD as Br, bE as Al, bF as ui, bG as Gl, bH as Pa, bI as V, bJ as Ol, bK as Sr, bL as fr, bM as Gn, bN as zi, bO as Bl, bP as Cl, bQ as On, bR as Fl, bS as Nl, bT as Ye, bU as Pt, bV as Qn, bW as ki, bX as fn, bY as Cs, bZ as ct, b_ as Ll, b$ as Rl, c0 as Wl, c1 as jl, c2 as Dl, c3 as Ai, c4 as pa, c5 as li, c6 as Fs, c7 as Yl, c8 as Sa, c9 as Lr, ca as Gi, cb as Oi, cc as ql, cd as Vl, ce as Jl, cf as Bi, cg as Kn, ch as Xl, ci as Zl, b as za, a as ka, G as Ns, cj as Aa, O as Ot, A as Hr, T as Ci } from "../constants-D4GX9YB2.js";
2
+ import { compileGpuAutomaton as Ql } from "./compiler.js";
3
3
  var Xr = class {
4
4
  };
5
5
  function ci(e) {
@@ -10,10 +10,10 @@ function ci(e) {
10
10
  if (a.length !== 0 && a.length !== e.columns * e.rows) throw new Error(`'${e.type}' constructor called with invalid number of arguments.`);
11
11
  for (let i = a.length; i < e.columns * e.rows; ++i) a.push(0);
12
12
  return new e.MatImpl(...a);
13
- }, ignoreImplicitCastWarning: !0, signature: (...n) => ({ argTypes: n.map((a) => nr(a) ? a : b), returnType: r }), codegenImpl: (...n) => p`${e.type}(${n})` }), r = Object.assign(t, { type: e.type, identity: ic[e.columns], translation: e.columns === 4 ? da : void 0, scaling: e.columns === 4 ? ma : void 0, rotationX: e.columns === 4 ? ha : void 0, rotationY: e.columns === 4 ? fa : void 0, rotationZ: e.columns === 4 ? ya : void 0 });
13
+ }, ignoreImplicitCastWarning: !0, signature: (...n) => ({ argTypes: n.map((a) => ar(a) ? a : b), returnType: r }), codegenImpl: (...n) => p`${e.type}(${n})` }), r = Object.assign(t, { type: e.type, identity: ac[e.columns], translation: e.columns === 4 ? da : void 0, scaling: e.columns === 4 ? ma : void 0, rotationX: e.columns === 4 ? ha : void 0, rotationY: e.columns === 4 ? fa : void 0, rotationZ: e.columns === 4 ? ya : void 0 });
14
14
  return e.MatImpl.prototype.schema = r, r;
15
15
  }
16
- var Hl = class extends Xr {
16
+ var Kl = class extends Xr {
17
17
  [c] = !0;
18
18
  columns;
19
19
  length = 4;
@@ -53,12 +53,12 @@ var Hl = class extends Xr {
53
53
  toString() {
54
54
  return this[U]().value;
55
55
  }
56
- }, ec = class extends Hl {
56
+ }, Hl = class extends Kl {
57
57
  kind = "mat2x2f";
58
58
  makeColumn(t, r) {
59
59
  return I(t, r);
60
60
  }
61
- }, tc = class extends Xr {
61
+ }, ec = class extends Xr {
62
62
  [c] = !0;
63
63
  columns;
64
64
  length = 12;
@@ -143,12 +143,12 @@ var Hl = class extends Xr {
143
143
  toString() {
144
144
  return this[U]().value;
145
145
  }
146
- }, rc = class extends tc {
146
+ }, tc = class extends ec {
147
147
  kind = "mat3x3f";
148
148
  makeColumn(t, r, n) {
149
149
  return T(t, r, n);
150
150
  }
151
- }, nc = class extends Xr {
151
+ }, rc = class extends Xr {
152
152
  [c] = !0;
153
153
  columns;
154
154
  constructor(...t) {
@@ -260,12 +260,12 @@ var Hl = class extends Xr {
260
260
  toString() {
261
261
  return this[U]().value;
262
262
  }
263
- }, ac = class extends nc {
263
+ }, nc = class extends rc {
264
264
  kind = "mat4x4f";
265
265
  makeColumn(t, r, n, a) {
266
266
  return C(t, r, n, a);
267
267
  }
268
- }, Ls = Wt(() => St(1, 0, 0, 1)).$name("identity2"), Rs = Wt(() => zt(1, 0, 0, 0, 1, 0, 0, 0, 1)).$name("identity3"), Ws = Wt(() => H(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)).$name("identity4"), ic = { 2: Ls, 3: Rs, 4: Ws }, da = m({ name: "translation4", normalImpl: (e) => H(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, e.x, e.y, e.z, 1), get signature() {
268
+ }, Ls = Wt(() => St(1, 0, 0, 1)).$name("identity2"), Rs = Wt(() => zt(1, 0, 0, 0, 1, 0, 0, 0, 1)).$name("identity3"), Ws = Wt(() => H(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)).$name("identity4"), ac = { 2: Ls, 3: Rs, 4: Ws }, da = m({ name: "translation4", normalImpl: (e) => H(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, e.x, e.y, e.z, 1), get signature() {
269
269
  return { argTypes: [T], returnType: H };
270
270
  }, codegenImpl: (e) => p`mat4x4f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, ${e}.x, ${e}.y, ${e}.z, 1)` }), ma = m({ name: "scaling4", normalImpl: (e) => H(e.x, 0, 0, 0, 0, e.y, 0, 0, 0, 0, e.z, 0, 0, 0, 0, 1), get signature() {
271
271
  return { argTypes: [T], returnType: H };
@@ -275,15 +275,15 @@ var Hl = class extends Xr {
275
275
  return { argTypes: [b], returnType: H };
276
276
  }, codegenImpl: (e) => p`mat4x4f(cos(${e}), 0, -sin(${e}), 0, 0, 1, 0, 0, sin(${e}), 0, cos(${e}), 0, 0, 0, 0, 1)` }), ya = m({ name: "rotationZ4", normalImpl: (e) => H(Math.cos(e), Math.sin(e), 0, 0, -Math.sin(e), Math.cos(e), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), get signature() {
277
277
  return { argTypes: [b], returnType: H };
278
- }, codegenImpl: (e) => p`mat4x4f(cos(${e}), sin(${e}), 0, 0, -sin(${e}), cos(${e}), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)` }), St = ci({ type: "mat2x2f", rows: 2, columns: 2, MatImpl: ec }), zt = ci({ type: "mat3x3f", rows: 3, columns: 3, MatImpl: rc }), H = ci({ type: "mat4x4f", rows: 4, columns: 4, MatImpl: ac });
279
- function sc(e) {
278
+ }, codegenImpl: (e) => p`mat4x4f(cos(${e}), sin(${e}), 0, 0, -sin(${e}), cos(${e}), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)` }), St = ci({ type: "mat2x2f", rows: 2, columns: 2, MatImpl: Hl }), zt = ci({ type: "mat3x3f", rows: 3, columns: 3, MatImpl: tc }), H = ci({ type: "mat4x4f", rows: 4, columns: 4, MatImpl: nc });
279
+ function ic(e) {
280
280
  return e.kind === "mat3x3f" ? [e[0], e[1], e[2], e[4], e[5], e[6], e[8], e[9], e[10]] : Array.from({ length: e.length }).map((t, r) => e[r]);
281
281
  }
282
282
  var Ht = (e, t, r) => {
283
283
  if (e === t) return 0;
284
284
  let n = z((r - e) / (t - e), 0, 1);
285
285
  return n * n * (3 - 2 * n);
286
- }, z = (e, t, r) => Math.min(Math.max(t, e), r), fr = (e, t) => t === 0 ? e : Math.trunc(e / t);
286
+ }, z = (e, t, r) => Math.min(Math.max(t, e), r), yr = (e, t) => t === 0 ? e : Math.trunc(e / t);
287
287
  function rt(e) {
288
288
  let t = new DataView(new ArrayBuffer(4));
289
289
  return t.setUint32(0, e, !0), t.getFloat32(0, !0);
@@ -292,7 +292,7 @@ function nt(e) {
292
292
  let t = new DataView(new ArrayBuffer(4));
293
293
  return t.setUint32(0, e, !0), t.getInt32(0, !0);
294
294
  }
295
- var Ne = qr[c].jsImpl, We = I[c].jsImpl, vt = _t[c].jsImpl, Cr = pe[c].jsImpl, ln = Be[c].jsImpl, Le = Yr[c].jsImpl, Ge = T[c].jsImpl, at = Tt[c].jsImpl, Fr = Fe[c].jsImpl, cn = ve[c].jsImpl, Re = Dr[c].jsImpl, je = C[c].jsImpl, wt = $t[c].jsImpl, Nr = Se[c].jsImpl, pn = Oe[c].jsImpl, yr = (e) => Math.sqrt(e.x ** 2 + e.y ** 2), gr = (e) => Math.sqrt(e.x ** 2 + e.y ** 2 + e.z ** 2), vr = (e) => Math.sqrt(e.x ** 2 + e.y ** 2 + e.z ** 2 + e.w ** 2), Bn = (e, t) => e.x * t.x + e.y * t.y, Cn = (e, t) => e.x * t.x + e.y * t.y + e.z * t.z, Fn = (e, t) => e.x * t.x + e.y * t.y + e.z * t.z + e.w * t.w, Q = (e) => (t) => We(e(t.x), e(t.y)), ae = (e) => (t) => vt(e(t.x), e(t.y)), wr = (e) => (t) => Cr(e(t.x), e(t.y)), en = (e) => (t) => ln(e(t.x), e(t.y)), X = (e) => (t) => Ge(e(t.x), e(t.y), e(t.z)), ie = (e) => (t) => at(e(t.x), e(t.y), e(t.z)), xr = (e) => (t) => Fr(e(t.x), e(t.y), e(t.z)), tn = (e) => (t) => cn(e(t.x), e(t.y), e(t.z)), J = (e) => (t) => je(e(t.x), e(t.y), e(t.z), e(t.w)), se = (e) => (t) => wt(e(t.x), e(t.y), e(t.z), e(t.w)), br = (e) => (t) => Nr(e(t.x), e(t.y), e(t.z), e(t.w)), rn = (e) => (t) => pn(e(t.x), e(t.y), e(t.z), e(t.w)), Fi = (e) => (t) => {
295
+ var Ne = qr[c].jsImpl, We = I[c].jsImpl, vt = _t[c].jsImpl, Cr = pe[c].jsImpl, ln = Be[c].jsImpl, Le = Yr[c].jsImpl, Ge = T[c].jsImpl, at = Tt[c].jsImpl, Fr = Fe[c].jsImpl, cn = ve[c].jsImpl, Re = Dr[c].jsImpl, je = C[c].jsImpl, wt = $t[c].jsImpl, Nr = Se[c].jsImpl, pn = Oe[c].jsImpl, gr = (e) => Math.sqrt(e.x ** 2 + e.y ** 2), vr = (e) => Math.sqrt(e.x ** 2 + e.y ** 2 + e.z ** 2), wr = (e) => Math.sqrt(e.x ** 2 + e.y ** 2 + e.z ** 2 + e.w ** 2), Bn = (e, t) => e.x * t.x + e.y * t.y, Cn = (e, t) => e.x * t.x + e.y * t.y + e.z * t.z, Fn = (e, t) => e.x * t.x + e.y * t.y + e.z * t.z + e.w * t.w, Q = (e) => (t) => We(e(t.x), e(t.y)), ae = (e) => (t) => vt(e(t.x), e(t.y)), xr = (e) => (t) => Cr(e(t.x), e(t.y)), en = (e) => (t) => ln(e(t.x), e(t.y)), X = (e) => (t) => Ge(e(t.x), e(t.y), e(t.z)), ie = (e) => (t) => at(e(t.x), e(t.y), e(t.z)), br = (e) => (t) => Fr(e(t.x), e(t.y), e(t.z)), tn = (e) => (t) => cn(e(t.x), e(t.y), e(t.z)), J = (e) => (t) => je(e(t.x), e(t.y), e(t.z), e(t.w)), se = (e) => (t) => wt(e(t.x), e(t.y), e(t.z), e(t.w)), $r = (e) => (t) => Nr(e(t.x), e(t.y), e(t.z), e(t.w)), rn = (e) => (t) => pn(e(t.x), e(t.y), e(t.z), e(t.w)), Fi = (e) => (t) => {
296
296
  let r = t.columns;
297
297
  return St(Q(e)(r[0]), Q(e)(r[1]));
298
298
  }, Ni = (e) => (t) => {
@@ -301,16 +301,16 @@ var Ne = qr[c].jsImpl, We = I[c].jsImpl, vt = _t[c].jsImpl, Cr = pe[c].jsImpl, l
301
301
  }, Li = (e) => (t) => {
302
302
  let r = t.columns;
303
303
  return H(J(e)(r[0]), J(e)(r[1]), J(e)(r[2]), J(e)(r[3]));
304
- }, gt = (e) => (t, r) => We(e(t.x, r.x), e(t.y, r.y)), Zt = (e) => (t, r) => vt(e(t.x, r.x), e(t.y, r.y)), $r = (e) => (t, r) => Cr(e(t.x, r.x), e(t.y, r.y)), Tr = (e) => (t, r) => ln(e(t.x, r.x), e(t.y, r.y)), it = (e) => (t, r) => Ge(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z)), Qt = (e) => (t, r) => at(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z)), _r = (e) => (t, r) => Fr(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z)), Ir = (e) => (t, r) => cn(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z)), Ze = (e) => (t, r) => je(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z), e(t.w, r.w)), Kt = (e) => (t, r) => wt(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z), e(t.w, r.w)), Er = (e) => (t, r) => Nr(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z), e(t.w, r.w)), Ur = (e) => (t, r) => pn(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z), e(t.w, r.w)), oc = (e) => (t, r) => {
304
+ }, gt = (e) => (t, r) => We(e(t.x, r.x), e(t.y, r.y)), Zt = (e) => (t, r) => vt(e(t.x, r.x), e(t.y, r.y)), Tr = (e) => (t, r) => Cr(e(t.x, r.x), e(t.y, r.y)), _r = (e) => (t, r) => ln(e(t.x, r.x), e(t.y, r.y)), it = (e) => (t, r) => Ge(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z)), Qt = (e) => (t, r) => at(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z)), Ir = (e) => (t, r) => Fr(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z)), Er = (e) => (t, r) => cn(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z)), Ze = (e) => (t, r) => je(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z), e(t.w, r.w)), Kt = (e) => (t, r) => wt(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z), e(t.w, r.w)), Ur = (e) => (t, r) => Nr(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z), e(t.w, r.w)), Mr = (e) => (t, r) => pn(e(t.x, r.x), e(t.y, r.y), e(t.z, r.z), e(t.w, r.w)), sc = (e) => (t, r) => {
305
305
  let n = t.columns, a = r.columns;
306
306
  return St(gt(e)(n[0], a[0]), gt(e)(n[1], a[1]));
307
- }, uc = (e) => (t, r) => {
307
+ }, oc = (e) => (t, r) => {
308
308
  let n = t.columns, a = r.columns;
309
309
  return zt(it(e)(n[0], a[0]), it(e)(n[1], a[1]), it(e)(n[2], a[2]));
310
- }, lc = (e) => (t, r) => {
310
+ }, uc = (e) => (t, r) => {
311
311
  let n = t.columns, a = r.columns;
312
312
  return H(Ze(e)(n[0], a[0]), Ze(e)(n[1], a[1]), Ze(e)(n[2], a[2]), Ze(e)(n[3], a[3]));
313
- }, cc = (e) => (t, r, n) => We(e(t.x, r.x, n.x), e(t.y, r.y, n.y)), pc = (e) => (t, r, n) => vt(e(t.x, r.x, n.x), e(t.y, r.y, n.y)), dc = (e) => (t, r, n) => Ge(e(t.x, r.x, n.x), e(t.y, r.y, n.y), e(t.z, r.z, n.z)), mc = (e) => (t, r, n) => at(e(t.x, r.x, n.x), e(t.y, r.y, n.y), e(t.z, r.z, n.z)), hc = (e) => (t, r, n) => je(e(t.x, r.x, n.x), e(t.y, r.y, n.y), e(t.z, r.z, n.z), e(t.w, r.w, n.w)), fc = (e) => (t, r, n) => wt(e(t.x, r.x, n.x), e(t.y, r.y, n.y), e(t.z, r.z, n.z), e(t.w, r.w, n.w)), _ = { eq: { vec2f: (e, t) => Ne(e.x === t.x, e.y === t.y), vec2h: (e, t) => Ne(e.x === t.x, e.y === t.y), vec2i: (e, t) => Ne(e.x === t.x, e.y === t.y), vec2u: (e, t) => Ne(e.x === t.x, e.y === t.y), "vec2<bool>": (e, t) => Ne(e.x === t.x, e.y === t.y), vec3f: (e, t) => Le(e.x === t.x, e.y === t.y, e.z === t.z), vec3h: (e, t) => Le(e.x === t.x, e.y === t.y, e.z === t.z), vec3i: (e, t) => Le(e.x === t.x, e.y === t.y, e.z === t.z), vec3u: (e, t) => Le(e.x === t.x, e.y === t.y, e.z === t.z), "vec3<bool>": (e, t) => Le(e.x === t.x, e.y === t.y, e.z === t.z), vec4f: (e, t) => Re(e.x === t.x, e.y === t.y, e.z === t.z, e.w === t.w), vec4h: (e, t) => Re(e.x === t.x, e.y === t.y, e.z === t.z, e.w === t.w), vec4i: (e, t) => Re(e.x === t.x, e.y === t.y, e.z === t.z, e.w === t.w), vec4u: (e, t) => Re(e.x === t.x, e.y === t.y, e.z === t.z, e.w === t.w), "vec4<bool>": (e, t) => Re(e.x === t.x, e.y === t.y, e.z === t.z, e.w === t.w) }, lt: { vec2f: (e, t) => Ne(e.x < t.x, e.y < t.y), vec2h: (e, t) => Ne(e.x < t.x, e.y < t.y), vec2i: (e, t) => Ne(e.x < t.x, e.y < t.y), vec2u: (e, t) => Ne(e.x < t.x, e.y < t.y), vec3f: (e, t) => Le(e.x < t.x, e.y < t.y, e.z < t.z), vec3h: (e, t) => Le(e.x < t.x, e.y < t.y, e.z < t.z), vec3i: (e, t) => Le(e.x < t.x, e.y < t.y, e.z < t.z), vec3u: (e, t) => Le(e.x < t.x, e.y < t.y, e.z < t.z), vec4f: (e, t) => Re(e.x < t.x, e.y < t.y, e.z < t.z, e.w < t.w), vec4h: (e, t) => Re(e.x < t.x, e.y < t.y, e.z < t.z, e.w < t.w), vec4i: (e, t) => Re(e.x < t.x, e.y < t.y, e.z < t.z, e.w < t.w), vec4u: (e, t) => Re(e.x < t.x, e.y < t.y, e.z < t.z, e.w < t.w) }, or: { "vec2<bool>": (e, t) => Ne(e.x || t.x, e.y || t.y), "vec3<bool>": (e, t) => Le(e.x || t.x, e.y || t.y, e.z || t.z), "vec4<bool>": (e, t) => Re(e.x || t.x, e.y || t.y, e.z || t.z, e.w || t.w) }, all: { "vec2<bool>": (e) => e.x && e.y, "vec3<bool>": (e) => e.x && e.y && e.z, "vec4<bool>": (e) => e.x && e.y && e.z && e.w }, abs: { vec2f: Q(Math.abs), vec2h: ae(Math.abs), vec2i: wr(Math.abs), vec2u: en(Math.abs), vec3f: X(Math.abs), vec3h: ie(Math.abs), vec3i: xr(Math.abs), vec3u: tn(Math.abs), vec4f: J(Math.abs), vec4h: se(Math.abs), vec4i: br(Math.abs), vec4u: rn(Math.abs) }, atan2: { vec2f: gt(Math.atan2), vec2h: Zt(Math.atan2), vec3f: it(Math.atan2), vec3h: Qt(Math.atan2), vec4f: Ze(Math.atan2), vec4h: Kt(Math.atan2) }, acos: { vec2f: Q(Math.acos), vec2h: ae(Math.acos), vec2i: wr(Math.acos), vec2u: en(Math.acos), vec3f: X(Math.acos), vec3h: ie(Math.acos), vec3i: xr(Math.acos), vec3u: tn(Math.acos), vec4f: J(Math.acos), vec4h: se(Math.acos), vec4i: br(Math.acos), vec4u: rn(Math.acos) }, acosh: { vec2f: Q(Math.acosh), vec2h: ae(Math.acosh), vec3f: X(Math.acosh), vec3h: ie(Math.acosh), vec4f: J(Math.acosh), vec4h: se(Math.acosh) }, asin: { vec2f: Q(Math.asin), vec2h: ae(Math.asin), vec3f: X(Math.asin), vec3h: ie(Math.asin), vec4f: J(Math.asin), vec4h: se(Math.asin) }, asinh: { vec2f: Q(Math.asinh), vec2h: ae(Math.asinh), vec3f: X(Math.asinh), vec3h: ie(Math.asinh), vec4f: J(Math.asinh), vec4h: se(Math.asinh) }, atan: { vec2f: Q(Math.atan), vec2h: ae(Math.atan), vec3f: X(Math.atan), vec3h: ie(Math.atan), vec4f: J(Math.atan), vec4h: se(Math.atan) }, atanh: { vec2f: Q(Math.atanh), vec2h: ae(Math.atanh), vec3f: X(Math.atanh), vec3h: ie(Math.atanh), vec4f: J(Math.atanh), vec4h: se(Math.atanh) }, ceil: { vec2f: Q(Math.ceil), vec2h: ae(Math.ceil), vec3f: X(Math.ceil), vec3h: ie(Math.ceil), vec4f: J(Math.ceil), vec4h: se(Math.ceil) }, clamp: { vec2f: (e, t, r) => We(z(e.x, t.x, r.x), z(e.y, t.y, r.y)), vec2h: (e, t, r) => vt(z(e.x, t.x, r.x), z(e.y, t.y, r.y)), vec2i: (e, t, r) => Cr(z(e.x, t.x, r.x), z(e.y, t.y, r.y)), vec2u: (e, t, r) => ln(z(e.x, t.x, r.x), z(e.y, t.y, r.y)), vec3f: (e, t, r) => Ge(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z)), vec3h: (e, t, r) => at(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z)), vec3i: (e, t, r) => Fr(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z)), vec3u: (e, t, r) => cn(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z)), vec4f: (e, t, r) => je(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z), z(e.w, t.w, r.w)), vec4h: (e, t, r) => wt(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z), z(e.w, t.w, r.w)), vec4i: (e, t, r) => Nr(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z), z(e.w, t.w, r.w)), vec4u: (e, t, r) => pn(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z), z(e.w, t.w, r.w)) }, length: { vec2f: yr, vec2h: yr, vec3f: gr, vec3h: gr, vec4f: vr, vec4h: vr }, add: { vec2f: gt((e, t) => e + t), vec2h: Zt((e, t) => e + t), vec2i: $r((e, t) => e + t), vec2u: Tr((e, t) => e + t), vec3f: it((e, t) => e + t), vec3h: Qt((e, t) => e + t), vec3i: _r((e, t) => e + t), vec3u: Ir((e, t) => e + t), vec4f: Ze((e, t) => e + t), vec4h: Kt((e, t) => e + t), vec4i: Er((e, t) => e + t), vec4u: Ur((e, t) => e + t), mat2x2f: oc((e, t) => e + t), mat3x3f: uc((e, t) => e + t), mat4x4f: lc((e, t) => e + t) }, smoothstep: { vec2f: cc(Ht), vec2h: pc(Ht), vec3f: dc(Ht), vec3h: mc(Ht), vec4f: hc(Ht), vec4h: fc(Ht) }, addMixed: { vec2f: (e, t) => Q((r) => r + t)(e), vec2h: (e, t) => ae((r) => r + t)(e), vec2i: (e, t) => wr((r) => r + t)(e), vec2u: (e, t) => en((r) => r + t)(e), vec3f: (e, t) => X((r) => r + t)(e), vec3h: (e, t) => ie((r) => r + t)(e), vec3i: (e, t) => xr((r) => r + t)(e), vec3u: (e, t) => tn((r) => r + t)(e), vec4f: (e, t) => J((r) => r + t)(e), vec4h: (e, t) => se((r) => r + t)(e), vec4i: (e, t) => br((r) => r + t)(e), vec4u: (e, t) => rn((r) => r + t)(e), mat2x2f: (e, t) => Fi((r) => r + t)(e), mat3x3f: (e, t) => Ni((r) => r + t)(e), mat4x4f: (e, t) => Li((r) => r + t)(e) }, mulSxV: { vec2f: (e, t) => Q((r) => e * r)(t), vec2h: (e, t) => ae((r) => e * r)(t), vec2i: (e, t) => wr((r) => e * r)(t), vec2u: (e, t) => en((r) => e * r)(t), vec3f: (e, t) => X((r) => e * r)(t), vec3h: (e, t) => ie((r) => e * r)(t), vec3i: (e, t) => xr((r) => e * r)(t), vec3u: (e, t) => tn((r) => e * r)(t), vec4f: (e, t) => J((r) => e * r)(t), vec4h: (e, t) => se((r) => e * r)(t), vec4i: (e, t) => br((r) => e * r)(t), vec4u: (e, t) => rn((r) => e * r)(t), mat2x2f: (e, t) => Fi((r) => e * r)(t), mat3x3f: (e, t) => Ni((r) => e * r)(t), mat4x4f: (e, t) => Li((r) => e * r)(t) }, mulVxV: { vec2f: gt((e, t) => e * t), vec2h: Zt((e, t) => e * t), vec2i: $r((e, t) => e * t), vec2u: Tr((e, t) => e * t), vec3f: it((e, t) => e * t), vec3h: Qt((e, t) => e * t), vec3i: _r((e, t) => e * t), vec3u: Ir((e, t) => e * t), vec4f: Ze((e, t) => e * t), vec4h: Kt((e, t) => e * t), vec4i: Er((e, t) => e * t), vec4u: Ur((e, t) => e * t), mat2x2f: (e, t) => {
313
+ }, lc = (e) => (t, r, n) => We(e(t.x, r.x, n.x), e(t.y, r.y, n.y)), cc = (e) => (t, r, n) => vt(e(t.x, r.x, n.x), e(t.y, r.y, n.y)), pc = (e) => (t, r, n) => Ge(e(t.x, r.x, n.x), e(t.y, r.y, n.y), e(t.z, r.z, n.z)), dc = (e) => (t, r, n) => at(e(t.x, r.x, n.x), e(t.y, r.y, n.y), e(t.z, r.z, n.z)), mc = (e) => (t, r, n) => je(e(t.x, r.x, n.x), e(t.y, r.y, n.y), e(t.z, r.z, n.z), e(t.w, r.w, n.w)), hc = (e) => (t, r, n) => wt(e(t.x, r.x, n.x), e(t.y, r.y, n.y), e(t.z, r.z, n.z), e(t.w, r.w, n.w)), _ = { eq: { vec2f: (e, t) => Ne(e.x === t.x, e.y === t.y), vec2h: (e, t) => Ne(e.x === t.x, e.y === t.y), vec2i: (e, t) => Ne(e.x === t.x, e.y === t.y), vec2u: (e, t) => Ne(e.x === t.x, e.y === t.y), "vec2<bool>": (e, t) => Ne(e.x === t.x, e.y === t.y), vec3f: (e, t) => Le(e.x === t.x, e.y === t.y, e.z === t.z), vec3h: (e, t) => Le(e.x === t.x, e.y === t.y, e.z === t.z), vec3i: (e, t) => Le(e.x === t.x, e.y === t.y, e.z === t.z), vec3u: (e, t) => Le(e.x === t.x, e.y === t.y, e.z === t.z), "vec3<bool>": (e, t) => Le(e.x === t.x, e.y === t.y, e.z === t.z), vec4f: (e, t) => Re(e.x === t.x, e.y === t.y, e.z === t.z, e.w === t.w), vec4h: (e, t) => Re(e.x === t.x, e.y === t.y, e.z === t.z, e.w === t.w), vec4i: (e, t) => Re(e.x === t.x, e.y === t.y, e.z === t.z, e.w === t.w), vec4u: (e, t) => Re(e.x === t.x, e.y === t.y, e.z === t.z, e.w === t.w), "vec4<bool>": (e, t) => Re(e.x === t.x, e.y === t.y, e.z === t.z, e.w === t.w) }, lt: { vec2f: (e, t) => Ne(e.x < t.x, e.y < t.y), vec2h: (e, t) => Ne(e.x < t.x, e.y < t.y), vec2i: (e, t) => Ne(e.x < t.x, e.y < t.y), vec2u: (e, t) => Ne(e.x < t.x, e.y < t.y), vec3f: (e, t) => Le(e.x < t.x, e.y < t.y, e.z < t.z), vec3h: (e, t) => Le(e.x < t.x, e.y < t.y, e.z < t.z), vec3i: (e, t) => Le(e.x < t.x, e.y < t.y, e.z < t.z), vec3u: (e, t) => Le(e.x < t.x, e.y < t.y, e.z < t.z), vec4f: (e, t) => Re(e.x < t.x, e.y < t.y, e.z < t.z, e.w < t.w), vec4h: (e, t) => Re(e.x < t.x, e.y < t.y, e.z < t.z, e.w < t.w), vec4i: (e, t) => Re(e.x < t.x, e.y < t.y, e.z < t.z, e.w < t.w), vec4u: (e, t) => Re(e.x < t.x, e.y < t.y, e.z < t.z, e.w < t.w) }, or: { "vec2<bool>": (e, t) => Ne(e.x || t.x, e.y || t.y), "vec3<bool>": (e, t) => Le(e.x || t.x, e.y || t.y, e.z || t.z), "vec4<bool>": (e, t) => Re(e.x || t.x, e.y || t.y, e.z || t.z, e.w || t.w) }, all: { "vec2<bool>": (e) => e.x && e.y, "vec3<bool>": (e) => e.x && e.y && e.z, "vec4<bool>": (e) => e.x && e.y && e.z && e.w }, abs: { vec2f: Q(Math.abs), vec2h: ae(Math.abs), vec2i: xr(Math.abs), vec2u: en(Math.abs), vec3f: X(Math.abs), vec3h: ie(Math.abs), vec3i: br(Math.abs), vec3u: tn(Math.abs), vec4f: J(Math.abs), vec4h: se(Math.abs), vec4i: $r(Math.abs), vec4u: rn(Math.abs) }, atan2: { vec2f: gt(Math.atan2), vec2h: Zt(Math.atan2), vec3f: it(Math.atan2), vec3h: Qt(Math.atan2), vec4f: Ze(Math.atan2), vec4h: Kt(Math.atan2) }, acos: { vec2f: Q(Math.acos), vec2h: ae(Math.acos), vec2i: xr(Math.acos), vec2u: en(Math.acos), vec3f: X(Math.acos), vec3h: ie(Math.acos), vec3i: br(Math.acos), vec3u: tn(Math.acos), vec4f: J(Math.acos), vec4h: se(Math.acos), vec4i: $r(Math.acos), vec4u: rn(Math.acos) }, acosh: { vec2f: Q(Math.acosh), vec2h: ae(Math.acosh), vec3f: X(Math.acosh), vec3h: ie(Math.acosh), vec4f: J(Math.acosh), vec4h: se(Math.acosh) }, asin: { vec2f: Q(Math.asin), vec2h: ae(Math.asin), vec3f: X(Math.asin), vec3h: ie(Math.asin), vec4f: J(Math.asin), vec4h: se(Math.asin) }, asinh: { vec2f: Q(Math.asinh), vec2h: ae(Math.asinh), vec3f: X(Math.asinh), vec3h: ie(Math.asinh), vec4f: J(Math.asinh), vec4h: se(Math.asinh) }, atan: { vec2f: Q(Math.atan), vec2h: ae(Math.atan), vec3f: X(Math.atan), vec3h: ie(Math.atan), vec4f: J(Math.atan), vec4h: se(Math.atan) }, atanh: { vec2f: Q(Math.atanh), vec2h: ae(Math.atanh), vec3f: X(Math.atanh), vec3h: ie(Math.atanh), vec4f: J(Math.atanh), vec4h: se(Math.atanh) }, ceil: { vec2f: Q(Math.ceil), vec2h: ae(Math.ceil), vec3f: X(Math.ceil), vec3h: ie(Math.ceil), vec4f: J(Math.ceil), vec4h: se(Math.ceil) }, clamp: { vec2f: (e, t, r) => We(z(e.x, t.x, r.x), z(e.y, t.y, r.y)), vec2h: (e, t, r) => vt(z(e.x, t.x, r.x), z(e.y, t.y, r.y)), vec2i: (e, t, r) => Cr(z(e.x, t.x, r.x), z(e.y, t.y, r.y)), vec2u: (e, t, r) => ln(z(e.x, t.x, r.x), z(e.y, t.y, r.y)), vec3f: (e, t, r) => Ge(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z)), vec3h: (e, t, r) => at(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z)), vec3i: (e, t, r) => Fr(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z)), vec3u: (e, t, r) => cn(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z)), vec4f: (e, t, r) => je(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z), z(e.w, t.w, r.w)), vec4h: (e, t, r) => wt(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z), z(e.w, t.w, r.w)), vec4i: (e, t, r) => Nr(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z), z(e.w, t.w, r.w)), vec4u: (e, t, r) => pn(z(e.x, t.x, r.x), z(e.y, t.y, r.y), z(e.z, t.z, r.z), z(e.w, t.w, r.w)) }, length: { vec2f: gr, vec2h: gr, vec3f: vr, vec3h: vr, vec4f: wr, vec4h: wr }, add: { vec2f: gt((e, t) => e + t), vec2h: Zt((e, t) => e + t), vec2i: Tr((e, t) => e + t), vec2u: _r((e, t) => e + t), vec3f: it((e, t) => e + t), vec3h: Qt((e, t) => e + t), vec3i: Ir((e, t) => e + t), vec3u: Er((e, t) => e + t), vec4f: Ze((e, t) => e + t), vec4h: Kt((e, t) => e + t), vec4i: Ur((e, t) => e + t), vec4u: Mr((e, t) => e + t), mat2x2f: sc((e, t) => e + t), mat3x3f: oc((e, t) => e + t), mat4x4f: uc((e, t) => e + t) }, smoothstep: { vec2f: lc(Ht), vec2h: cc(Ht), vec3f: pc(Ht), vec3h: dc(Ht), vec4f: mc(Ht), vec4h: hc(Ht) }, addMixed: { vec2f: (e, t) => Q((r) => r + t)(e), vec2h: (e, t) => ae((r) => r + t)(e), vec2i: (e, t) => xr((r) => r + t)(e), vec2u: (e, t) => en((r) => r + t)(e), vec3f: (e, t) => X((r) => r + t)(e), vec3h: (e, t) => ie((r) => r + t)(e), vec3i: (e, t) => br((r) => r + t)(e), vec3u: (e, t) => tn((r) => r + t)(e), vec4f: (e, t) => J((r) => r + t)(e), vec4h: (e, t) => se((r) => r + t)(e), vec4i: (e, t) => $r((r) => r + t)(e), vec4u: (e, t) => rn((r) => r + t)(e), mat2x2f: (e, t) => Fi((r) => r + t)(e), mat3x3f: (e, t) => Ni((r) => r + t)(e), mat4x4f: (e, t) => Li((r) => r + t)(e) }, mulSxV: { vec2f: (e, t) => Q((r) => e * r)(t), vec2h: (e, t) => ae((r) => e * r)(t), vec2i: (e, t) => xr((r) => e * r)(t), vec2u: (e, t) => en((r) => e * r)(t), vec3f: (e, t) => X((r) => e * r)(t), vec3h: (e, t) => ie((r) => e * r)(t), vec3i: (e, t) => br((r) => e * r)(t), vec3u: (e, t) => tn((r) => e * r)(t), vec4f: (e, t) => J((r) => e * r)(t), vec4h: (e, t) => se((r) => e * r)(t), vec4i: (e, t) => $r((r) => e * r)(t), vec4u: (e, t) => rn((r) => e * r)(t), mat2x2f: (e, t) => Fi((r) => e * r)(t), mat3x3f: (e, t) => Ni((r) => e * r)(t), mat4x4f: (e, t) => Li((r) => e * r)(t) }, mulVxV: { vec2f: gt((e, t) => e * t), vec2h: Zt((e, t) => e * t), vec2i: Tr((e, t) => e * t), vec2u: _r((e, t) => e * t), vec3f: it((e, t) => e * t), vec3h: Qt((e, t) => e * t), vec3i: Ir((e, t) => e * t), vec3u: Er((e, t) => e * t), vec4f: Ze((e, t) => e * t), vec4h: Kt((e, t) => e * t), vec4i: Ur((e, t) => e * t), vec4u: Mr((e, t) => e * t), mat2x2f: (e, t) => {
314
314
  let r = e.columns, n = t.columns;
315
315
  return St(r[0].x * n[0].x + r[1].x * n[0].y, r[0].y * n[0].x + r[1].y * n[0].y, r[0].x * n[1].x + r[1].x * n[1].y, r[0].y * n[1].x + r[1].y * n[1].y);
316
316
  }, mat3x3f: (e, t) => {
@@ -337,43 +337,43 @@ var Ne = qr[c].jsImpl, We = I[c].jsImpl, vt = _t[c].jsImpl, Cr = pe[c].jsImpl, l
337
337
  }, mat4x4f: (e, t) => {
338
338
  let r = t.columns;
339
339
  return je(e.x * r[0].x + e.y * r[0].y + e.z * r[0].z + e.w * r[0].w, e.x * r[1].x + e.y * r[1].y + e.z * r[1].z + e.w * r[1].w, e.x * r[2].x + e.y * r[2].y + e.z * r[2].z + e.w * r[2].w, e.x * r[3].x + e.y * r[3].y + e.z * r[3].z + e.w * r[3].w);
340
- } }, div: { vec2f: gt((e, t) => e / t), vec2h: Zt((e, t) => e / t), vec2i: $r(fr), vec2u: Tr(fr), vec3f: it((e, t) => e / t), vec3h: Qt((e, t) => e / t), vec3i: _r(fr), vec3u: Ir(fr), vec4f: Ze((e, t) => e / t), vec4h: Kt((e, t) => e / t), vec4i: Er(fr), vec4u: Ur(fr) }, dot: { vec2f: Bn, vec2h: Bn, vec2i: Bn, vec2u: Bn, vec3f: Cn, vec3h: Cn, vec3i: Cn, vec3u: Cn, vec4f: Fn, vec4h: Fn, vec4i: Fn, vec4u: Fn }, normalize: { vec2f: (e) => {
341
- let t = yr(e);
340
+ } }, div: { vec2f: gt((e, t) => e / t), vec2h: Zt((e, t) => e / t), vec2i: Tr(yr), vec2u: _r(yr), vec3f: it((e, t) => e / t), vec3h: Qt((e, t) => e / t), vec3i: Ir(yr), vec3u: Er(yr), vec4f: Ze((e, t) => e / t), vec4h: Kt((e, t) => e / t), vec4i: Ur(yr), vec4u: Mr(yr) }, dot: { vec2f: Bn, vec2h: Bn, vec2i: Bn, vec2u: Bn, vec3f: Cn, vec3h: Cn, vec3i: Cn, vec3u: Cn, vec4f: Fn, vec4h: Fn, vec4i: Fn, vec4u: Fn }, normalize: { vec2f: (e) => {
341
+ let t = gr(e);
342
342
  return We(e.x / t, e.y / t);
343
343
  }, vec2h: (e) => {
344
- let t = yr(e);
344
+ let t = gr(e);
345
345
  return vt(e.x / t, e.y / t);
346
346
  }, vec2i: (e) => {
347
- let t = yr(e);
347
+ let t = gr(e);
348
348
  return Cr(e.x / t, e.y / t);
349
349
  }, vec2u: (e) => {
350
- let t = yr(e);
350
+ let t = gr(e);
351
351
  return ln(e.x / t, e.y / t);
352
352
  }, vec3f: (e) => {
353
- let t = gr(e);
353
+ let t = vr(e);
354
354
  return Ge(e.x / t, e.y / t, e.z / t);
355
355
  }, vec3h: (e) => {
356
- let t = gr(e);
356
+ let t = vr(e);
357
357
  return at(e.x / t, e.y / t, e.z / t);
358
358
  }, vec3i: (e) => {
359
- let t = gr(e);
359
+ let t = vr(e);
360
360
  return Fr(e.x / t, e.y / t, e.z / t);
361
361
  }, vec3u: (e) => {
362
- let t = gr(e);
362
+ let t = vr(e);
363
363
  return cn(e.x / t, e.y / t, e.z / t);
364
364
  }, vec4f: (e) => {
365
- let t = vr(e);
365
+ let t = wr(e);
366
366
  return je(e.x / t, e.y / t, e.z / t, e.w / t);
367
367
  }, vec4h: (e) => {
368
- let t = vr(e);
368
+ let t = wr(e);
369
369
  return wt(e.x / t, e.y / t, e.z / t, e.w / t);
370
370
  }, vec4i: (e) => {
371
- let t = vr(e);
371
+ let t = wr(e);
372
372
  return Nr(e.x / t, e.y / t, e.z / t, e.w / t);
373
373
  }, vec4u: (e) => {
374
- let t = vr(e);
374
+ let t = wr(e);
375
375
  return pn(e.x / t, e.y / t, e.z / t, e.w / t);
376
- } }, cross: { vec3f: (e, t) => Ge(e.y * t.z - e.z * t.y, e.z * t.x - e.x * t.z, e.x * t.y - e.y * t.x), vec3h: (e, t) => at(e.y * t.z - e.z * t.y, e.z * t.x - e.x * t.z, e.x * t.y - e.y * t.x) }, mod: { vec2f: gt((e, t) => e % t), vec2h: Zt((e, t) => e % t), vec2i: $r((e, t) => e % t), vec2u: Tr((e, t) => e % t), vec3f: it((e, t) => e % t), vec3h: Qt((e, t) => e % t), vec3i: _r((e, t) => e % t), vec3u: Ir((e, t) => e % t), vec4f: Ze((e, t) => e % t), vec4h: Kt((e, t) => e % t), vec4i: Er((e, t) => e % t), vec4u: Ur((e, t) => e % t) }, floor: { vec2f: Q(Math.floor), vec2h: ae(Math.floor), vec3f: X(Math.floor), vec3h: ie(Math.floor), vec4f: J(Math.floor), vec4h: se(Math.floor) }, max: { vec2f: gt(Math.max), vec2h: Zt(Math.max), vec2i: $r(Math.max), vec2u: Tr(Math.max), vec3f: it(Math.max), vec3h: Qt(Math.max), vec3i: _r(Math.max), vec3u: Ir(Math.max), vec4f: Ze(Math.max), vec4h: Kt(Math.max), vec4i: Er(Math.max), vec4u: Ur(Math.max) }, min: { vec2f: gt(Math.min), vec2h: Zt(Math.min), vec2i: $r(Math.min), vec2u: Tr(Math.min), vec3f: it(Math.min), vec3h: Qt(Math.min), vec3i: _r(Math.min), vec3u: Ir(Math.min), vec4f: Ze(Math.min), vec4h: Kt(Math.min), vec4i: Er(Math.min), vec4u: Ur(Math.min) }, pow: { vec2f: (e, t) => We(e.x ** t.x, e.y ** t.y), vec2h: (e, t) => vt(e.x ** t.x, e.y ** t.y), vec3f: (e, t) => Ge(e.x ** t.x, e.y ** t.y, e.z ** t.z), vec3h: (e, t) => at(e.x ** t.x, e.y ** t.y, e.z ** t.z), vec4f: (e, t) => je(e.x ** t.x, e.y ** t.y, e.z ** t.z, e.w ** t.w), vec4h: (e, t) => wt(e.x ** t.x, e.y ** t.y, e.z ** t.z, e.w ** t.w) }, sign: { vec2f: Q(Math.sign), vec2h: ae(Math.sign), vec2i: wr(Math.sign), vec3f: X(Math.sign), vec3h: ie(Math.sign), vec3i: xr(Math.sign), vec4f: J(Math.sign), vec4h: se(Math.sign), vec4i: br(Math.sign) }, sqrt: { vec2f: Q(Math.sqrt), vec2h: ae(Math.sqrt), vec3f: X(Math.sqrt), vec3h: ie(Math.sqrt), vec4f: J(Math.sqrt), vec4h: se(Math.sqrt) }, mix: { vec2f: (e, t, r) => typeof r == "number" ? We(e.x * (1 - r) + t.x * r, e.y * (1 - r) + t.y * r) : We(e.x * (1 - r.x) + t.x * r.x, e.y * (1 - r.y) + t.y * r.y), vec2h: (e, t, r) => typeof r == "number" ? vt(e.x * (1 - r) + t.x * r, e.y * (1 - r) + t.y * r) : vt(e.x * (1 - r.x) + t.x * r.x, e.y * (1 - r.y) + t.y * r.y), vec3f: (e, t, r) => typeof r == "number" ? Ge(e.x * (1 - r) + t.x * r, e.y * (1 - r) + t.y * r, e.z * (1 - r) + t.z * r) : Ge(e.x * (1 - r.x) + t.x * r.x, e.y * (1 - r.y) + t.y * r.y, e.z * (1 - r.z) + t.z * r.z), vec3h: (e, t, r) => typeof r == "number" ? at(e.x * (1 - r) + t.x * r, e.y * (1 - r) + t.y * r, e.z * (1 - r) + t.z * r) : at(e.x * (1 - r.x) + t.x * r.x, e.y * (1 - r.y) + t.y * r.y, e.z * (1 - r.z) + t.z * r.z), vec4f: (e, t, r) => typeof r == "number" ? je(e.x * (1 - r) + t.x * r, e.y * (1 - r) + t.y * r, e.z * (1 - r) + t.z * r, e.w * (1 - r) + t.w * r) : je(e.x * (1 - r.x) + t.x * r.x, e.y * (1 - r.y) + t.y * r.y, e.z * (1 - r.z) + t.z * r.z, e.w * (1 - r.w) + t.w * r.w), vec4h: (e, t, r) => typeof r == "number" ? wt(e.x * (1 - r) + t.x * r, e.y * (1 - r) + t.y * r, e.z * (1 - r) + t.z * r, e.w * (1 - r) + t.w * r) : wt(e.x * (1 - r.x) + t.x * r.x, e.y * (1 - r.y) + t.y * r.y, e.z * (1 - r.z) + t.z * r.z, e.w * (1 - r.w) + t.w * r.w) }, sin: { vec2f: Q(Math.sin), vec2h: ae(Math.sin), vec3f: X(Math.sin), vec3h: ie(Math.sin), vec4f: J(Math.sin), vec4h: se(Math.sin) }, cos: { vec2f: Q(Math.cos), vec2h: ae(Math.cos), vec3f: X(Math.cos), vec3h: ie(Math.cos), vec4f: J(Math.cos), vec4h: se(Math.cos) }, cosh: { vec2f: Q(Math.cosh), vec2h: ae(Math.cosh), vec3f: X(Math.cosh), vec3h: ie(Math.cosh), vec4f: J(Math.cosh), vec4h: se(Math.cosh) }, exp: { vec2f: Q(Math.exp), vec2h: ae(Math.exp), vec3f: X(Math.exp), vec3h: ie(Math.exp), vec4f: J(Math.exp), vec4h: se(Math.exp) }, exp2: { vec2f: Q((e) => 2 ** e), vec2h: ae((e) => 2 ** e), vec3f: X((e) => 2 ** e), vec3h: ie((e) => 2 ** e), vec4f: J((e) => 2 ** e), vec4h: se((e) => 2 ** e) }, log: { vec2f: Q(Math.log), vec2h: ae(Math.log), vec3f: X(Math.log), vec3h: ie(Math.log), vec4f: J(Math.log), vec4h: se(Math.log) }, log2: { vec2f: Q(Math.log2), vec2h: ae(Math.log2), vec3f: X(Math.log2), vec3h: ie(Math.log2), vec4f: J(Math.log2), vec4h: se(Math.log2) }, fract: { vec2f: Q((e) => e - Math.floor(e)), vec2h: ae((e) => e - Math.floor(e)), vec3f: X((e) => e - Math.floor(e)), vec3h: ie((e) => e - Math.floor(e)), vec4f: J((e) => e - Math.floor(e)), vec4h: se((e) => e - Math.floor(e)) }, isCloseToZero: { vec2f: (e, t) => Math.abs(e.x) <= t && Math.abs(e.y) <= t, vec2h: (e, t) => Math.abs(e.x) <= t && Math.abs(e.y) <= t, vec3f: (e, t) => Math.abs(e.x) <= t && Math.abs(e.y) <= t && Math.abs(e.z) <= t, vec3h: (e, t) => Math.abs(e.x) <= t && Math.abs(e.y) <= t && Math.abs(e.z) <= t, vec4f: (e, t) => Math.abs(e.x) <= t && Math.abs(e.y) <= t && Math.abs(e.z) <= t && Math.abs(e.w) <= t, vec4h: (e, t) => Math.abs(e.x) <= t && Math.abs(e.y) <= t && Math.abs(e.z) <= t && Math.abs(e.w) <= t }, neg: { vec2f: Q((e) => -e), vec2h: ae((e) => -e), vec2i: wr((e) => -e), vec2u: en((e) => -e), "vec2<bool>": (e) => Ne(!e.x, !e.y), vec3f: X((e) => -e), vec3h: ie((e) => -e), vec3i: xr((e) => -e), vec3u: tn((e) => -e), "vec3<bool>": (e) => Le(!e.x, !e.y, !e.z), vec4f: J((e) => -e), vec4h: se((e) => -e), vec4i: br((e) => -e), vec4u: rn((e) => -e), "vec4<bool>": (e) => Re(!e.x, !e.y, !e.z, !e.w) }, select: { vec2f: (e, t, r) => We(r.x ? t.x : e.x, r.y ? t.y : e.y), vec2h: (e, t, r) => vt(r.x ? t.x : e.x, r.y ? t.y : e.y), vec2i: (e, t, r) => Cr(r.x ? t.x : e.x, r.y ? t.y : e.y), vec2u: (e, t, r) => ln(r.x ? t.x : e.x, r.y ? t.y : e.y), "vec2<bool>": (e, t, r) => Ne(r.x ? t.x : e.x, r.y ? t.y : e.y), vec3f: (e, t, r) => Ge(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z), vec3h: (e, t, r) => at(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z), vec3i: (e, t, r) => Fr(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z), vec3u: (e, t, r) => cn(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z), "vec3<bool>": (e, t, r) => Le(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z), vec4f: (e, t, r) => je(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z, r.w ? t.w : e.w), vec4h: (e, t, r) => wt(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z, r.w ? t.w : e.w), vec4i: (e, t, r) => Nr(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z, r.w ? t.w : e.w), vec4u: (e, t, r) => pn(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z, r.w ? t.w : e.w), "vec4<bool>": (e, t, r) => Re(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z, r.w ? t.w : e.w) }, tanh: { vec2f: Q(Math.tanh), vec2h: ae(Math.tanh), vec3f: X(Math.tanh), vec3h: ie(Math.tanh), vec4f: J(Math.tanh), vec4h: se(Math.tanh) }, bitcastU32toF32: { vec2u: (e) => We(rt(e.x), rt(e.y)), vec3u: (e) => Ge(rt(e.x), rt(e.y), rt(e.z)), vec4u: (e) => je(rt(e.x), rt(e.y), rt(e.z), rt(e.w)) }, bitcastU32toI32: { vec2u: (e) => Cr(nt(e.x), nt(e.y)), vec3u: (e) => Fr(nt(e.x), nt(e.y), nt(e.z)), vec4u: (e) => Nr(nt(e.x), nt(e.y), nt(e.z), nt(e.w)) } };
376
+ } }, cross: { vec3f: (e, t) => Ge(e.y * t.z - e.z * t.y, e.z * t.x - e.x * t.z, e.x * t.y - e.y * t.x), vec3h: (e, t) => at(e.y * t.z - e.z * t.y, e.z * t.x - e.x * t.z, e.x * t.y - e.y * t.x) }, mod: { vec2f: gt((e, t) => e % t), vec2h: Zt((e, t) => e % t), vec2i: Tr((e, t) => e % t), vec2u: _r((e, t) => e % t), vec3f: it((e, t) => e % t), vec3h: Qt((e, t) => e % t), vec3i: Ir((e, t) => e % t), vec3u: Er((e, t) => e % t), vec4f: Ze((e, t) => e % t), vec4h: Kt((e, t) => e % t), vec4i: Ur((e, t) => e % t), vec4u: Mr((e, t) => e % t) }, floor: { vec2f: Q(Math.floor), vec2h: ae(Math.floor), vec3f: X(Math.floor), vec3h: ie(Math.floor), vec4f: J(Math.floor), vec4h: se(Math.floor) }, max: { vec2f: gt(Math.max), vec2h: Zt(Math.max), vec2i: Tr(Math.max), vec2u: _r(Math.max), vec3f: it(Math.max), vec3h: Qt(Math.max), vec3i: Ir(Math.max), vec3u: Er(Math.max), vec4f: Ze(Math.max), vec4h: Kt(Math.max), vec4i: Ur(Math.max), vec4u: Mr(Math.max) }, min: { vec2f: gt(Math.min), vec2h: Zt(Math.min), vec2i: Tr(Math.min), vec2u: _r(Math.min), vec3f: it(Math.min), vec3h: Qt(Math.min), vec3i: Ir(Math.min), vec3u: Er(Math.min), vec4f: Ze(Math.min), vec4h: Kt(Math.min), vec4i: Ur(Math.min), vec4u: Mr(Math.min) }, pow: { vec2f: (e, t) => We(e.x ** t.x, e.y ** t.y), vec2h: (e, t) => vt(e.x ** t.x, e.y ** t.y), vec3f: (e, t) => Ge(e.x ** t.x, e.y ** t.y, e.z ** t.z), vec3h: (e, t) => at(e.x ** t.x, e.y ** t.y, e.z ** t.z), vec4f: (e, t) => je(e.x ** t.x, e.y ** t.y, e.z ** t.z, e.w ** t.w), vec4h: (e, t) => wt(e.x ** t.x, e.y ** t.y, e.z ** t.z, e.w ** t.w) }, sign: { vec2f: Q(Math.sign), vec2h: ae(Math.sign), vec2i: xr(Math.sign), vec3f: X(Math.sign), vec3h: ie(Math.sign), vec3i: br(Math.sign), vec4f: J(Math.sign), vec4h: se(Math.sign), vec4i: $r(Math.sign) }, sqrt: { vec2f: Q(Math.sqrt), vec2h: ae(Math.sqrt), vec3f: X(Math.sqrt), vec3h: ie(Math.sqrt), vec4f: J(Math.sqrt), vec4h: se(Math.sqrt) }, mix: { vec2f: (e, t, r) => typeof r == "number" ? We(e.x * (1 - r) + t.x * r, e.y * (1 - r) + t.y * r) : We(e.x * (1 - r.x) + t.x * r.x, e.y * (1 - r.y) + t.y * r.y), vec2h: (e, t, r) => typeof r == "number" ? vt(e.x * (1 - r) + t.x * r, e.y * (1 - r) + t.y * r) : vt(e.x * (1 - r.x) + t.x * r.x, e.y * (1 - r.y) + t.y * r.y), vec3f: (e, t, r) => typeof r == "number" ? Ge(e.x * (1 - r) + t.x * r, e.y * (1 - r) + t.y * r, e.z * (1 - r) + t.z * r) : Ge(e.x * (1 - r.x) + t.x * r.x, e.y * (1 - r.y) + t.y * r.y, e.z * (1 - r.z) + t.z * r.z), vec3h: (e, t, r) => typeof r == "number" ? at(e.x * (1 - r) + t.x * r, e.y * (1 - r) + t.y * r, e.z * (1 - r) + t.z * r) : at(e.x * (1 - r.x) + t.x * r.x, e.y * (1 - r.y) + t.y * r.y, e.z * (1 - r.z) + t.z * r.z), vec4f: (e, t, r) => typeof r == "number" ? je(e.x * (1 - r) + t.x * r, e.y * (1 - r) + t.y * r, e.z * (1 - r) + t.z * r, e.w * (1 - r) + t.w * r) : je(e.x * (1 - r.x) + t.x * r.x, e.y * (1 - r.y) + t.y * r.y, e.z * (1 - r.z) + t.z * r.z, e.w * (1 - r.w) + t.w * r.w), vec4h: (e, t, r) => typeof r == "number" ? wt(e.x * (1 - r) + t.x * r, e.y * (1 - r) + t.y * r, e.z * (1 - r) + t.z * r, e.w * (1 - r) + t.w * r) : wt(e.x * (1 - r.x) + t.x * r.x, e.y * (1 - r.y) + t.y * r.y, e.z * (1 - r.z) + t.z * r.z, e.w * (1 - r.w) + t.w * r.w) }, sin: { vec2f: Q(Math.sin), vec2h: ae(Math.sin), vec3f: X(Math.sin), vec3h: ie(Math.sin), vec4f: J(Math.sin), vec4h: se(Math.sin) }, cos: { vec2f: Q(Math.cos), vec2h: ae(Math.cos), vec3f: X(Math.cos), vec3h: ie(Math.cos), vec4f: J(Math.cos), vec4h: se(Math.cos) }, cosh: { vec2f: Q(Math.cosh), vec2h: ae(Math.cosh), vec3f: X(Math.cosh), vec3h: ie(Math.cosh), vec4f: J(Math.cosh), vec4h: se(Math.cosh) }, exp: { vec2f: Q(Math.exp), vec2h: ae(Math.exp), vec3f: X(Math.exp), vec3h: ie(Math.exp), vec4f: J(Math.exp), vec4h: se(Math.exp) }, exp2: { vec2f: Q((e) => 2 ** e), vec2h: ae((e) => 2 ** e), vec3f: X((e) => 2 ** e), vec3h: ie((e) => 2 ** e), vec4f: J((e) => 2 ** e), vec4h: se((e) => 2 ** e) }, log: { vec2f: Q(Math.log), vec2h: ae(Math.log), vec3f: X(Math.log), vec3h: ie(Math.log), vec4f: J(Math.log), vec4h: se(Math.log) }, log2: { vec2f: Q(Math.log2), vec2h: ae(Math.log2), vec3f: X(Math.log2), vec3h: ie(Math.log2), vec4f: J(Math.log2), vec4h: se(Math.log2) }, fract: { vec2f: Q((e) => e - Math.floor(e)), vec2h: ae((e) => e - Math.floor(e)), vec3f: X((e) => e - Math.floor(e)), vec3h: ie((e) => e - Math.floor(e)), vec4f: J((e) => e - Math.floor(e)), vec4h: se((e) => e - Math.floor(e)) }, isCloseToZero: { vec2f: (e, t) => Math.abs(e.x) <= t && Math.abs(e.y) <= t, vec2h: (e, t) => Math.abs(e.x) <= t && Math.abs(e.y) <= t, vec3f: (e, t) => Math.abs(e.x) <= t && Math.abs(e.y) <= t && Math.abs(e.z) <= t, vec3h: (e, t) => Math.abs(e.x) <= t && Math.abs(e.y) <= t && Math.abs(e.z) <= t, vec4f: (e, t) => Math.abs(e.x) <= t && Math.abs(e.y) <= t && Math.abs(e.z) <= t && Math.abs(e.w) <= t, vec4h: (e, t) => Math.abs(e.x) <= t && Math.abs(e.y) <= t && Math.abs(e.z) <= t && Math.abs(e.w) <= t }, neg: { vec2f: Q((e) => -e), vec2h: ae((e) => -e), vec2i: xr((e) => -e), vec2u: en((e) => -e), "vec2<bool>": (e) => Ne(!e.x, !e.y), vec3f: X((e) => -e), vec3h: ie((e) => -e), vec3i: br((e) => -e), vec3u: tn((e) => -e), "vec3<bool>": (e) => Le(!e.x, !e.y, !e.z), vec4f: J((e) => -e), vec4h: se((e) => -e), vec4i: $r((e) => -e), vec4u: rn((e) => -e), "vec4<bool>": (e) => Re(!e.x, !e.y, !e.z, !e.w) }, select: { vec2f: (e, t, r) => We(r.x ? t.x : e.x, r.y ? t.y : e.y), vec2h: (e, t, r) => vt(r.x ? t.x : e.x, r.y ? t.y : e.y), vec2i: (e, t, r) => Cr(r.x ? t.x : e.x, r.y ? t.y : e.y), vec2u: (e, t, r) => ln(r.x ? t.x : e.x, r.y ? t.y : e.y), "vec2<bool>": (e, t, r) => Ne(r.x ? t.x : e.x, r.y ? t.y : e.y), vec3f: (e, t, r) => Ge(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z), vec3h: (e, t, r) => at(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z), vec3i: (e, t, r) => Fr(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z), vec3u: (e, t, r) => cn(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z), "vec3<bool>": (e, t, r) => Le(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z), vec4f: (e, t, r) => je(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z, r.w ? t.w : e.w), vec4h: (e, t, r) => wt(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z, r.w ? t.w : e.w), vec4i: (e, t, r) => Nr(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z, r.w ? t.w : e.w), vec4u: (e, t, r) => pn(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z, r.w ? t.w : e.w), "vec4<bool>": (e, t, r) => Re(r.x ? t.x : e.x, r.y ? t.y : e.y, r.z ? t.z : e.z, r.w ? t.w : e.w) }, tanh: { vec2f: Q(Math.tanh), vec2h: ae(Math.tanh), vec3f: X(Math.tanh), vec3h: ie(Math.tanh), vec4f: J(Math.tanh), vec4h: se(Math.tanh) }, bitcastU32toF32: { vec2u: (e) => We(rt(e.x), rt(e.y)), vec3u: (e) => Ge(rt(e.x), rt(e.y), rt(e.z)), vec4u: (e) => je(rt(e.x), rt(e.y), rt(e.z), rt(e.w)) }, bitcastU32toI32: { vec2u: (e) => Cr(nt(e.x), nt(e.y)), vec3u: (e) => Fr(nt(e.x), nt(e.y), nt(e.z)), vec4u: (e) => Nr(nt(e.x), nt(e.y), nt(e.z), nt(e.w)) } };
377
377
  function js(e, t) {
378
378
  if (typeof e == "number" && typeof t == "number") return e + t;
379
379
  if (typeof e == "number" && ye(t)) return _.addMixed[t.kind](t, e);
@@ -383,15 +383,15 @@ function js(e, t) {
383
383
  }
384
384
  var B = m({ name: "add", signature: (...e) => {
385
385
  let t = be(e) ?? e;
386
- return { argTypes: t, returnType: rr(t[0]) ? t[1] : t[0] };
386
+ return { argTypes: t, returnType: nr(t[0]) ? t[1] : t[0] };
387
387
  }, normalImpl: js, codegenImpl: (e, t) => p`(${e} + ${t})` });
388
- function yc(e, t) {
388
+ function fc(e, t) {
389
389
  return js(e, Ds(-1, t));
390
390
  }
391
391
  var W = m({ name: "sub", signature: (...e) => {
392
392
  let t = be(e) ?? e;
393
- return { argTypes: t, returnType: rr(t[0]) ? t[1] : t[0] };
394
- }, normalImpl: yc, codegenImpl: (e, t) => p`(${e} - ${t})` });
393
+ return { argTypes: t, returnType: nr(t[0]) ? t[1] : t[0] };
394
+ }, normalImpl: fc, codegenImpl: (e, t) => p`(${e} - ${t})` });
395
395
  function Ds(e, t) {
396
396
  if (typeof e == "number" && typeof t == "number") return e * t;
397
397
  if (typeof e == "number" && (ye(t) || Bt(t))) return _.mulSxV[t.kind](e, t);
@@ -403,10 +403,10 @@ function Ds(e, t) {
403
403
  throw new Error("Mul called with invalid arguments.");
404
404
  }
405
405
  var N = m({ name: "mul", signature: (...e) => {
406
- let t = be(e) ?? e, r = rr(t[0]) ? t[1] : rr(t[1]) || t[0].type.startsWith("vec") ? t[0] : t[1].type.startsWith("vec") ? t[1] : t[0];
406
+ let t = be(e) ?? e, r = nr(t[0]) ? t[1] : nr(t[1]) || t[0].type.startsWith("vec") ? t[0] : t[1].type.startsWith("vec") ? t[1] : t[0];
407
407
  return { argTypes: t, returnType: r };
408
408
  }, normalImpl: Ds, codegenImpl: (e, t) => p`(${e} * ${t})` });
409
- function gc(e, t) {
409
+ function yc(e, t) {
410
410
  if (typeof e == "number" && typeof t == "number") return e / t;
411
411
  if (typeof e == "number" && ye(t)) {
412
412
  let r = Xn[t.kind][c].jsImpl;
@@ -421,10 +421,10 @@ function gc(e, t) {
421
421
  }
422
422
  var ga = m({ name: "div", signature: (...e) => {
423
423
  let t = be(e, [b, Ae, jt]) ?? e;
424
- return { argTypes: t, returnType: rr(t[0]) ? t[1] : t[0] };
425
- }, normalImpl: gc, codegenImpl: (e, t) => p`(${e} / ${t})`, ignoreImplicitCastWarning: !0 }), vc = m({ name: "mod", signature: (...e) => {
424
+ return { argTypes: t, returnType: nr(t[0]) ? t[1] : t[0] };
425
+ }, normalImpl: yc, codegenImpl: (e, t) => p`(${e} / ${t})`, ignoreImplicitCastWarning: !0 }), gc = m({ name: "mod", signature: (...e) => {
426
426
  let t = be(e) ?? e;
427
- return { argTypes: t, returnType: rr(t[0]) ? t[1] : t[0] };
427
+ return { argTypes: t, returnType: nr(t[0]) ? t[1] : t[0] };
428
428
  }, normalImpl(e, t) {
429
429
  if (typeof e == "number" && typeof t == "number") return e % t;
430
430
  if (typeof e == "number" && ye(t)) {
@@ -438,10 +438,10 @@ var ga = m({ name: "div", signature: (...e) => {
438
438
  if (ye(e) && ye(t)) return _.mod[e.kind](e, t);
439
439
  throw new Error("Mod called with invalid arguments, expected types: number or vector.");
440
440
  }, codegenImpl: (e, t) => p`(${e} % ${t})` });
441
- function wc(e) {
441
+ function vc(e) {
442
442
  return typeof e == "number" ? -e : _.neg[e.kind](e);
443
443
  }
444
- var Ys = m({ name: "neg", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: wc, codegenImpl: (e) => p`-(${e})` });
444
+ var Ys = m({ name: "neg", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: vc, codegenImpl: (e) => p`-(${e})` });
445
445
  function Ga(e) {
446
446
  if ("multisampled" in e) {
447
447
  if (e.multisampled) {
@@ -535,19 +535,19 @@ function ro(e, t) {
535
535
  let r = t || "write-only", n = `texture_storage_3d<${e}, ${In[r]}>`;
536
536
  return Ee(n, () => va("texture_storage_3d", { dimension: "3d", format: e, access: r }));
537
537
  }
538
- function xc() {
538
+ function wc() {
539
539
  return Ee("texture_depth_2d", () => qe("texture_depth_2d", { dimension: "2d", sampleType: b, multisampled: !1 }));
540
540
  }
541
- function bc() {
541
+ function xc() {
542
542
  return Ee("texture_depth_multisampled_2d", () => qe("texture_depth_multisampled_2d", { dimension: "2d", sampleType: b, multisampled: !0 }));
543
543
  }
544
- function $c() {
544
+ function bc() {
545
545
  return Ee("texture_depth_2d_array", () => qe("texture_depth_2d_array", { dimension: "2d-array", sampleType: b, multisampled: !1 }));
546
546
  }
547
- function Tc() {
547
+ function $c() {
548
548
  return Ee("texture_depth_cube", () => qe("texture_depth_cube", { dimension: "cube", sampleType: b, multisampled: !1 }));
549
549
  }
550
- function _c() {
550
+ function Tc() {
551
551
  return Ee("texture_depth_cube_array", () => qe("texture_depth_cube_array", { dimension: "cube-array", sampleType: b, multisampled: !1 }));
552
552
  }
553
553
  function no() {
@@ -559,9 +559,9 @@ function ao(e) {
559
559
  function Oa(e) {
560
560
  return !!e[c] && typeof e.format == "string" && typeof e.access == "string";
561
561
  }
562
- var Ic = ["vec2f", "vec3f", "vec4f", "vec2h", "vec3h", "vec4h", "vec2i", "vec3i", "vec4i", "vec2u", "vec3u", "vec4u", "mat2x2f", "mat3x3f", "mat4x4f"], Ba = { add: B, sub: W, mul: N, div: ga }, Ec = { f: { 1: b, 2: I, 3: T, 4: C }, h: { 1: Ae, 2: _t, 3: Tt, 4: $t }, i: { 1: Ue, 2: pe, 3: Fe, 4: Se }, u: { 1: y, 2: Be, 3: ve, 4: Oe }, b: { 1: le, 2: qr, 3: Yr, 4: Dr } };
562
+ var _c = ["vec2f", "vec3f", "vec4f", "vec2h", "vec3h", "vec4h", "vec2i", "vec3i", "vec4i", "vec2u", "vec3u", "vec4u", "mat2x2f", "mat3x3f", "mat4x4f"], Ba = { add: B, sub: W, mul: N, div: ga }, Ic = { f: { 1: b, 2: I, 3: T, 4: C }, h: { 1: Ae, 2: _t, 3: Tt, 4: $t }, i: { 1: Ue, 2: pe, 3: Fe, 4: Se }, u: { 1: y, 2: Be, 3: ve, 4: Oe }, b: { 1: le, 2: qr, 3: Yr, 4: Dr } };
563
563
  function pi(e, t) {
564
- if (Ic.includes(e.dataType.type) && t in Ba) return g(new Is(t, e, Ba[t][c].gpuImpl), Nt, e.origin);
564
+ if (_c.includes(e.dataType.type) && t in Ba) return g(new Is(t, e, Ba[t][c].gpuImpl), Nt, e.origin);
565
565
  if (ze(e.dataType) && t === "length") return e.dataType.elementCount === 0 ? g(p`arrayLength(&${e})`, y, "runtime") : g(e.dataType.elementCount, la, "constant");
566
566
  if (Es(e.dataType) && t === "columns") return g(new Us(e), Nt, e.origin);
567
567
  if (xe(e.dataType) || Ke(e.dataType)) {
@@ -572,10 +572,10 @@ function pi(e, t) {
572
572
  let n = Ms(e);
573
573
  return t === "$" ? n : pi(n, t);
574
574
  }
575
- if (nr(e.dataType) && t === "kind") return g(e.dataType.type, Nt, "constant");
575
+ if (ar(e.dataType) && t === "kind") return g(e.dataType.type, Nt, "constant");
576
576
  let r = t.length;
577
- if (nr(e.dataType) && r >= 1 && r <= 4) {
578
- let n = e.dataType.type.includes("bool") ? "b" : e.dataType.type[4], a = Ec[n][r];
577
+ if (ar(e.dataType) && r >= 1 && r <= 4) {
578
+ let n = e.dataType.type.includes("bool") ? "b" : e.dataType.type[4], a = Ic[n][r];
579
579
  return a ? g(ot(e) ? e.value[t] : p`${e}.${t}`, a, e.origin === "argument" && r === 1 ? "argument" : e.origin === "constant" || e.origin === "constant-tgpu-const-ref" ? "constant" : "runtime") : void 0;
580
580
  }
581
581
  if (ot(e) || e.dataType.type === "unknown") return ri(e.value[t]);
@@ -586,24 +586,24 @@ function di() {
586
586
  function mi() {
587
587
  return { [c]: !0, type: "sampler_comparison", [Tn]: void 0 };
588
588
  }
589
- function Uc(e) {
589
+ function Ec(e) {
590
590
  return !!e[c] && e.type === "sampler";
591
591
  }
592
- function Mc(e) {
592
+ function Uc(e) {
593
593
  return !!e[c] && e.type === "sampler_comparison";
594
594
  }
595
595
  function io(e) {
596
- return new Pc(e);
596
+ return new Mc(e);
597
597
  }
598
- var Pc = class {
598
+ var Mc = class {
599
599
  constructor(e) {
600
600
  this.inner = e;
601
601
  }
602
602
  [c] = !0;
603
603
  type = "atomic";
604
- }, Sc = { f32: 4, f16: 2, i32: 4, u32: 4, bool: 4, u16: 2, vec2f: 8, vec2h: 4, vec2i: 8, vec2u: 8, vec2b: 8, vec3f: 16, vec3h: 8, vec3i: 16, vec3u: 16, vec3b: 16, vec4f: 16, vec4h: 8, vec4i: 16, vec4u: 16, vec4b: 16, mat2x2f: 8, mat3x3f: 16, mat4x4f: 16, atomic: 4 };
605
- function zc(e) {
606
- let t = e?.type, r = Sc[t];
604
+ }, Pc = { f32: 4, f16: 2, i32: 4, u32: 4, bool: 4, u16: 2, vec2f: 8, vec2h: 4, vec2i: 8, vec2u: 8, vec2b: 8, vec3f: 16, vec3h: 8, vec3i: 16, vec3u: 16, vec3b: 16, vec4f: 16, vec4h: 8, vec4i: 16, vec4u: 16, vec4b: 16, mat2x2f: 8, mat3x3f: 16, mat4x4f: 16, atomic: 4 };
605
+ function Sc(e) {
606
+ let t = e?.type, r = Pc[t];
607
607
  if (r !== void 0) return r;
608
608
  if (xe(e)) return Object.values(e.propTypes).map(oe).reduce((n, a) => n > a ? n : a);
609
609
  if (ze(e)) return oe(e.elementType);
@@ -616,7 +616,7 @@ function zc(e) {
616
616
  if (Ps.has(t)) return 1;
617
617
  throw new Error(`Cannot determine alignment of data: ${Dt(e)}`);
618
618
  }
619
- function kc(e) {
619
+ function zc(e) {
620
620
  if (Ke(e)) {
621
621
  let t = Object.values(e.propTypes)[0];
622
622
  return t ? De(t) : 1;
@@ -626,20 +626,20 @@ function kc(e) {
626
626
  var Wi = /* @__PURE__ */ new WeakMap(), ji = /* @__PURE__ */ new WeakMap();
627
627
  function oe(e) {
628
628
  let t = Wi.get(e);
629
- return t === void 0 && (t = zc(e), Wi.set(e, t)), t;
629
+ return t === void 0 && (t = Sc(e), Wi.set(e, t)), t;
630
630
  }
631
631
  function De(e) {
632
632
  let t = ji.get(e);
633
- return t === void 0 && (t = kc(e), ji.set(e, t)), t;
633
+ return t === void 0 && (t = zc(e), ji.set(e, t)), t;
634
634
  }
635
- function Ac(e) {
635
+ function kc(e) {
636
636
  return oe(e);
637
637
  }
638
638
  var Ce = (e, t) => {
639
639
  let r = t - 1, n = ~r;
640
640
  return (e & r) === 0 ? e : (e & n) + t;
641
- }, Gc = { bool: 4, f32: 4, f16: 2, i32: 4, u32: 4, u16: 2, vec2f: 8, vec2h: 4, vec2i: 8, vec2u: 8, "vec2<bool>": 8, vec3f: 12, vec3h: 6, vec3i: 12, vec3u: 12, "vec3<bool>": 12, vec4f: 16, vec4h: 8, vec4i: 16, vec4u: 16, "vec4<bool>": 16, mat2x2f: 16, mat3x3f: 48, mat4x4f: 64, uint8: 1, uint8x2: 2, uint8x4: 4, sint8: 1, sint8x2: 2, sint8x4: 4, unorm8: 1, unorm8x2: 2, unorm8x4: 4, snorm8: 1, snorm8x2: 2, snorm8x4: 4, uint16: 2, uint16x2: 4, uint16x4: 8, sint16: 2, sint16x2: 4, sint16x4: 8, unorm16: 2, unorm16x2: 4, unorm16x4: 8, snorm16: 2, snorm16x2: 4, snorm16x4: 8, float16: 2, float16x2: 4, float16x4: 8, float32: 4, float32x2: 8, float32x3: 12, float32x4: 16, uint32: 4, uint32x2: 8, uint32x3: 12, uint32x4: 16, sint32: 4, sint32x2: 8, sint32x3: 12, sint32x4: 16, "unorm10-10-10-2": 4, "unorm8x4-bgra": 4, atomic: 4 };
642
- function Oc(e) {
641
+ }, Ac = { bool: 4, f32: 4, f16: 2, i32: 4, u32: 4, u16: 2, vec2f: 8, vec2h: 4, vec2i: 8, vec2u: 8, "vec2<bool>": 8, vec3f: 12, vec3h: 6, vec3i: 12, vec3u: 12, "vec3<bool>": 12, vec4f: 16, vec4h: 8, vec4i: 16, vec4u: 16, "vec4<bool>": 16, mat2x2f: 16, mat3x3f: 48, mat4x4f: 64, uint8: 1, uint8x2: 2, uint8x4: 4, sint8: 1, sint8x2: 2, sint8x4: 4, unorm8: 1, unorm8x2: 2, unorm8x4: 4, snorm8: 1, snorm8x2: 2, snorm8x4: 4, uint16: 2, uint16x2: 4, uint16x4: 8, sint16: 2, sint16x2: 4, sint16x4: 8, unorm16: 2, unorm16x2: 4, unorm16x4: 8, snorm16: 2, snorm16x2: 4, snorm16x4: 8, float16: 2, float16x2: 4, float16x4: 8, float32: 4, float32x2: 8, float32x3: 12, float32x4: 16, uint32: 4, uint32x2: 8, uint32x3: 12, uint32x4: 16, sint32: 4, sint32x2: 8, sint32x3: 12, sint32x4: 16, "unorm10-10-10-2": 4, "unorm8x4-bgra": 4, atomic: 4 };
642
+ function Gc(e) {
643
643
  let t = 0, r = e.propTypes;
644
644
  for (let n of Object.values(r)) {
645
645
  if (Number.isNaN(t)) throw new Error("Only the last property of a struct can be unbounded");
@@ -647,7 +647,7 @@ function Oc(e) {
647
647
  }
648
648
  return Ce(t, oe(e));
649
649
  }
650
- function Bc(e) {
650
+ function Oc(e) {
651
651
  let t = 0, r = e.propTypes;
652
652
  for (let n of Object.values(r)) {
653
653
  let a = De(n);
@@ -655,11 +655,11 @@ function Bc(e) {
655
655
  }
656
656
  return t;
657
657
  }
658
- function Cc(e) {
659
- let t = Gc[e?.type];
658
+ function Bc(e) {
659
+ let t = Ac[e?.type];
660
660
  if (t !== void 0) return t;
661
- if (xe(e)) return Oc(e);
662
- if (Ke(e)) return Bc(e);
661
+ if (xe(e)) return Gc(e);
662
+ if (Ke(e)) return Oc(e);
663
663
  if (ze(e)) {
664
664
  if (e.elementCount === 0) return Number.NaN;
665
665
  let r = oe(e.elementType);
@@ -669,33 +669,33 @@ function Cc(e) {
669
669
  let r = De(e.elementType);
670
670
  return Ce(F(e.elementType), r) * e.elementCount;
671
671
  }
672
- if (He(e) || et(e)) return ku(e) ?? F(e.inner);
672
+ if (He(e) || et(e)) return zu(e) ?? F(e.inner);
673
673
  throw new Error(`Cannot determine size of data: ${e}`);
674
674
  }
675
675
  var Di = /* @__PURE__ */ new WeakMap();
676
676
  function F(e) {
677
677
  let t = Di.get(e);
678
- return t === void 0 && (t = Cc(e), Di.set(e, t)), t;
678
+ return t === void 0 && (t = Bc(e), Di.set(e, t)), t;
679
679
  }
680
- function Fc(e) {
680
+ function Cc(e) {
681
681
  return F(e);
682
682
  }
683
683
  function Zr(e, t) {
684
684
  return He(e) ? new Yi(e.inner, [t, ...e.attribs]) : et(e) ? new qi(e.inner, [t, ...e.attribs]) : _n(e) ? new qi(e, [t]) : new Yi(e, [t]);
685
685
  }
686
- function Nc(e, t) {
686
+ function Fc(e, t) {
687
687
  return Zr(t, { [c]: !0, type: "@align", params: [e] });
688
688
  }
689
- function Lc(e, t) {
689
+ function Nc(e, t) {
690
690
  return Zr(t, { [c]: !0, type: "@size", params: [e] });
691
691
  }
692
692
  function Hn(e, t) {
693
693
  return Zr(t, { [c]: !0, type: "@location", params: [e] });
694
694
  }
695
- function Rc(e, t) {
695
+ function Lc(e, t) {
696
696
  return Zr(t, { [c]: !0, type: "@interpolate", params: [e] });
697
697
  }
698
- function Wc(e) {
698
+ function Rc(e) {
699
699
  if (!Et(e)) throw new Error("The @invariant attribute must only be applied to the position built-in value.");
700
700
  let t = He(e) || et(e) ? e.attribs.find(ni) : void 0;
701
701
  if (!t || t.params[0] !== "position") throw new Error("The @invariant attribute must only be applied to the position built-in value.");
@@ -732,40 +732,40 @@ var so = class {
732
732
  function Vi(e, t) {
733
733
  let r = (n) => {
734
734
  if (n && n.length !== t) throw new Error(`Array schema of ${t} elements of type ${e.type} called with ${n.length} argument(s).`);
735
- return Array.from({ length: t }, (a, i) => ar(e, n?.[i]));
735
+ return Array.from({ length: t }, (a, i) => ir(e, n?.[i]));
736
736
  };
737
- if (Object.setPrototypeOf(r, jc), Number.isNaN(F(e))) throw new Error("Cannot nest runtime sized arrays.");
737
+ if (Object.setPrototypeOf(r, Wc), Number.isNaN(F(e))) throw new Error("Cannot nest runtime sized arrays.");
738
738
  if (r.elementType = e, !Number.isInteger(t) || t < 0) throw new Error(`Cannot create array schema with invalid element count: ${t}.`);
739
739
  return r.elementCount = t, r;
740
740
  }
741
- var jc = { [c]: !0, type: "array", toString() {
741
+ var Wc = { [c]: !0, type: "array", toString() {
742
742
  return `arrayOf(${this.elementType}, ${this.elementCount})`;
743
743
  } };
744
744
  function Me(e, t) {
745
745
  return Zr(e, { [c]: !0, type: "@builtin", params: [t] });
746
746
  }
747
- var fi = { vertexIndex: Me(y, "vertex_index"), instanceIndex: Me(y, "instance_index"), position: Me(C, "position"), clipDistances: Me(te(y, 8), "clip_distances"), frontFacing: Me(le, "front_facing"), fragDepth: Me(b, "frag_depth"), sampleIndex: Me(y, "sample_index"), sampleMask: Me(y, "sample_mask"), localInvocationId: Me(ve, "local_invocation_id"), localInvocationIndex: Me(y, "local_invocation_index"), globalInvocationId: Me(ve, "global_invocation_id"), workgroupId: Me(ve, "workgroup_id"), numWorkgroups: Me(ve, "num_workgroups"), subgroupInvocationId: Me(y, "subgroup_invocation_id"), subgroupSize: Me(y, "subgroup_size") }, Dc = Wt(((e, t) => t === void 0 ? (r) => Ji(e, r) : Ji(e, t))).$name("disarrayOf");
747
+ var fi = { vertexIndex: Me(y, "vertex_index"), instanceIndex: Me(y, "instance_index"), position: Me(C, "position"), clipDistances: Me(te(y, 8), "clip_distances"), frontFacing: Me(le, "front_facing"), fragDepth: Me(b, "frag_depth"), sampleIndex: Me(y, "sample_index"), sampleMask: Me(y, "sample_mask"), localInvocationId: Me(ve, "local_invocation_id"), localInvocationIndex: Me(y, "local_invocation_index"), globalInvocationId: Me(ve, "global_invocation_id"), workgroupId: Me(ve, "workgroup_id"), numWorkgroups: Me(ve, "num_workgroups"), subgroupInvocationId: Me(y, "subgroup_invocation_id"), subgroupSize: Me(y, "subgroup_size") }, jc = Wt(((e, t) => t === void 0 ? (r) => Ji(e, r) : Ji(e, t))).$name("disarrayOf");
748
748
  function Ji(e, t) {
749
749
  let r = (n) => {
750
750
  if (n && n.length !== t) throw new Error(`Disarray schema of ${t} elements of type ${e.type} called with ${n.length} argument(s).`);
751
- return Array.from({ length: t }, (a, i) => ar(e, n?.[i]));
751
+ return Array.from({ length: t }, (a, i) => ir(e, n?.[i]));
752
752
  };
753
- if (Object.setPrototypeOf(r, Yc), r.elementType = e, !Number.isInteger(t) || t < 0) throw new Error(`Cannot create disarray schema with invalid element count: ${t}.`);
753
+ if (Object.setPrototypeOf(r, Dc), r.elementType = e, !Number.isInteger(t) || t < 0) throw new Error(`Cannot create disarray schema with invalid element count: ${t}.`);
754
754
  return r.elementCount = t, r;
755
755
  }
756
- var Yc = { [c]: !0, type: "disarray", toString() {
756
+ var Dc = { [c]: !0, type: "disarray", toString() {
757
757
  return `disarrayOf(${this.elementType}, ${this.elementCount})`;
758
758
  } };
759
- function qc(e) {
760
- let t = (r) => Object.fromEntries(Object.entries(e).map(([n, a]) => [n, ar(a, r?.[n])]));
761
- return Object.setPrototypeOf(t, Vc), t.propTypes = e, t;
759
+ function Yc(e) {
760
+ let t = (r) => Object.fromEntries(Object.entries(e).map(([n, a]) => [n, ir(a, r?.[n])]));
761
+ return Object.setPrototypeOf(t, qc), t.propTypes = e, t;
762
762
  }
763
- var Vc = { [c]: !0, type: "unstruct", $name(e) {
763
+ var qc = { [c]: !0, type: "unstruct", $name(e) {
764
764
  return re(this, e), this;
765
765
  }, toString() {
766
766
  return `unstruct:${x(this) ?? "<unnamed>"}`;
767
767
  } };
768
- function Sr(e, t) {
768
+ function zr(e, t) {
769
769
  if (e === t) return !0;
770
770
  if (e.type !== t.type) return !1;
771
771
  if (xe(e) && xe(t) || Ke(e) && Ke(t)) {
@@ -773,15 +773,15 @@ function Sr(e, t) {
773
773
  if (a.length !== i.length) return !1;
774
774
  for (let s = 0; s < a.length; s++) {
775
775
  let o = a[s], u = i[s];
776
- if (o !== u || !o || !u || !Sr(r[o], n[u])) return !1;
776
+ if (o !== u || !o || !u || !zr(r[o], n[u])) return !1;
777
777
  }
778
778
  return !0;
779
779
  }
780
- if (ze(e) && ze(t) || It(e) && It(t)) return e.elementCount === t.elementCount && Sr(e.elementType, t.elementType);
781
- if (lt(e) && lt(t)) return e.addressSpace === t.addressSpace && e.access === t.access && Sr(e.inner, t.inner);
782
- if (Zn(e) && Zn(t)) return Sr(e.inner, t.inner);
780
+ if (ze(e) && ze(t) || It(e) && It(t)) return e.elementCount === t.elementCount && zr(e.elementType, t.elementType);
781
+ if (lt(e) && lt(t)) return e.addressSpace === t.addressSpace && e.access === t.access && zr(e.inner, t.inner);
782
+ if (Zn(e) && Zn(t)) return zr(e.inner, t.inner);
783
783
  if (He(e) && He(t) || et(e) && et(t)) {
784
- if (!Sr(e.inner, t.inner) || e.attribs.length !== t.attribs.length) return !1;
784
+ if (!zr(e.inner, t.inner) || e.attribs.length !== t.attribs.length) return !1;
785
785
  let r = (i) => {
786
786
  let s = i;
787
787
  return `${s.type}(${(s.params ?? []).join(",")})`;
@@ -790,44 +790,44 @@ function Sr(e, t) {
790
790
  }
791
791
  return !0;
792
792
  }
793
- function or(e, t) {
793
+ function ur(e, t) {
794
794
  let r = e.prototype, n = Ba[t][c].jsImpl;
795
795
  r[t] = function(a) {
796
796
  return n(this, a);
797
797
  };
798
798
  }
799
- or(ca, "add");
800
- or(ca, "sub");
801
- or(ca, "mul");
802
- or(ca, "div");
803
- or(Xr, "add");
804
- or(Xr, "sub");
805
- or(Xr, "mul");
799
+ ur(ca, "add");
800
+ ur(ca, "sub");
801
+ ur(ca, "mul");
802
+ ur(ca, "div");
803
+ ur(Xr, "add");
804
+ ur(Xr, "sub");
805
+ ur(Xr, "mul");
806
806
  const K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
807
807
  __proto__: null,
808
808
  Void: de,
809
- align: Nc,
810
- alignmentOf: Ac,
809
+ align: Fc,
810
+ alignmentOf: kc,
811
811
  arrayOf: te,
812
812
  atomic: io,
813
813
  bool: le,
814
814
  builtin: fi,
815
815
  comparisonSampler: mi,
816
- deepEqual: Sr,
817
- disarrayOf: Dc,
816
+ deepEqual: zr,
817
+ disarrayOf: jc,
818
818
  f16: Ae,
819
819
  f32: b,
820
- float16: Au,
821
- float16x2: Gu,
822
- float16x4: Ou,
823
- float32: Bu,
824
- float32x2: Cu,
825
- float32x3: Fu,
826
- float32x4: Nu,
820
+ float16: ku,
821
+ float16x2: Au,
822
+ float16x4: Gu,
823
+ float32: Ou,
824
+ float32x2: Bu,
825
+ float32x3: Cu,
826
+ float32x4: Fu,
827
827
  formatToWGSLType: Wr,
828
828
  i32: Ue,
829
- interpolate: Rc,
830
- invariant: Wc,
829
+ interpolate: Lc,
830
+ invariant: Rc,
831
831
  isAlignAttrib: Ss,
832
832
  isAtomic: Zn,
833
833
  isBuiltin: Et,
@@ -835,8 +835,8 @@ const K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
835
835
  isData: Jr,
836
836
  isDecorated: He,
837
837
  isDisarray: It,
838
- isInterpolateAttrib: Lu,
839
- isLocationAttrib: Ru,
838
+ isInterpolateAttrib: Nu,
839
+ isLocationAttrib: Lu,
840
840
  isLooseData: _n,
841
841
  isLooseDecorated: et,
842
842
  isPackedData: ks,
@@ -850,34 +850,34 @@ const K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
850
850
  mat2x2f: St,
851
851
  mat3x3f: zt,
852
852
  mat4x4f: H,
853
- matToArray: sc,
853
+ matToArray: ic,
854
854
  packedFormats: Ps,
855
855
  ptrFn: ai,
856
- ptrHandle: Wu,
857
- ptrPrivate: ju,
858
- ptrStorage: Du,
859
- ptrUniform: Yu,
860
- ptrWorkgroup: qu,
861
- ref: Vu,
856
+ ptrHandle: Ru,
857
+ ptrPrivate: Wu,
858
+ ptrStorage: ju,
859
+ ptrUniform: Du,
860
+ ptrWorkgroup: Yu,
861
+ ref: qu,
862
862
  sampler: di,
863
- sint16: Ju,
864
- sint16x2: Xu,
865
- sint16x4: Zu,
866
- sint32: Qu,
867
- sint32x2: Ku,
868
- sint32x3: Hu,
869
- sint32x4: el,
870
- sint8: tl,
871
- sint8x2: rl,
872
- sint8x4: nl,
873
- size: Lc,
874
- sizeOf: Fc,
875
- snorm16: al,
876
- snorm16x2: il,
877
- snorm16x4: sl,
878
- snorm8: ol,
879
- snorm8x2: ul,
880
- snorm8x4: ll,
863
+ sint16: Vu,
864
+ sint16x2: Ju,
865
+ sint16x4: Xu,
866
+ sint32: Zu,
867
+ sint32x2: Qu,
868
+ sint32x3: Ku,
869
+ sint32x4: Hu,
870
+ sint8: el,
871
+ sint8x2: tl,
872
+ sint8x4: rl,
873
+ size: Nc,
874
+ sizeOf: Cc,
875
+ snorm16: nl,
876
+ snorm16x2: al,
877
+ snorm16x4: il,
878
+ snorm8: sl,
879
+ snorm8x2: ol,
880
+ snorm8x4: ul,
881
881
  struct: ii,
882
882
  texture1d: qs,
883
883
  texture2d: Vs,
@@ -885,38 +885,38 @@ const K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
885
885
  texture3d: Ks,
886
886
  textureCube: Zs,
887
887
  textureCubeArray: Qs,
888
- textureDepth2d: xc,
889
- textureDepth2dArray: $c,
890
- textureDepthCube: Tc,
891
- textureDepthCubeArray: _c,
892
- textureDepthMultisampled2d: bc,
888
+ textureDepth2d: wc,
889
+ textureDepth2dArray: bc,
890
+ textureDepthCube: $c,
891
+ textureDepthCubeArray: Tc,
892
+ textureDepthMultisampled2d: xc,
893
893
  textureExternal: no,
894
894
  textureMultisampled2d: Js,
895
895
  textureStorage1d: Hs,
896
896
  textureStorage2d: eo,
897
897
  textureStorage2dArray: to,
898
898
  textureStorage3d: ro,
899
- u16: cl,
899
+ u16: ll,
900
900
  u32: y,
901
- uint16: pl,
902
- uint16x2: dl,
903
- uint16x4: ml,
904
- uint32: hl,
905
- uint32x2: fl,
906
- uint32x3: yl,
907
- uint32x4: gl,
908
- uint8: vl,
909
- uint8x2: wl,
910
- uint8x4: xl,
911
- unorm10_10_10_2: bl,
912
- unorm16: $l,
913
- unorm16x2: Tl,
914
- unorm16x4: _l,
915
- unorm8: Il,
916
- unorm8x2: El,
917
- unorm8x4: Ul,
918
- unorm8x4_bgra: Ml,
919
- unstruct: qc,
901
+ uint16: cl,
902
+ uint16x2: pl,
903
+ uint16x4: dl,
904
+ uint32: ml,
905
+ uint32x2: hl,
906
+ uint32x3: fl,
907
+ uint32x4: yl,
908
+ uint8: gl,
909
+ uint8x2: vl,
910
+ uint8x4: wl,
911
+ unorm10_10_10_2: xl,
912
+ unorm16: bl,
913
+ unorm16x2: $l,
914
+ unorm16x4: Tl,
915
+ unorm8: _l,
916
+ unorm8x2: Il,
917
+ unorm8x4: El,
918
+ unorm8x4_bgra: Ul,
919
+ unstruct: Yc,
920
920
  vec2b: qr,
921
921
  vec2f: I,
922
922
  vec2h: _t,
@@ -936,7 +936,7 @@ const K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
936
936
  function Rr(e, t) {
937
937
  for (let [r, n] of Object.entries(t)) e[r] = n, n && (typeof n == "object" || typeof n == "function") && x(n) === void 0 && re(n, r);
938
938
  }
939
- function Jc(e, t, r) {
939
+ function Vc(e, t, r) {
940
940
  let n = [...e.matchAll(/:\s*(?<arg>.*?)\s*[,)]/g)].map((a) => a ? a[1] : void 0);
941
941
  r(Object.fromEntries(t.flatMap((a, i) => {
942
942
  let s = n ? n[i] : void 0;
@@ -947,13 +947,13 @@ function oo(e, t, r) {
947
947
  let n = e.match(/->\s(?<output>[\w\d_]+)\s{/), a = n ? n[1]?.trim() : void 0;
948
948
  xe(t) && a && !/\s/g.test(a) && r({ [a]: t });
949
949
  }
950
- function Xc(e) {
950
+ function Jc(e) {
951
951
  return new RegExp(`(?<![\\w\\$_.])${e.replaceAll(".", "\\.").replaceAll("$", "\\$")}(?![\\w\\$_])`, "g");
952
952
  }
953
953
  function En(e, t, r) {
954
954
  return Object.entries(t).reduce((n, [a, i]) => {
955
- let s = Xc(a);
956
- if (r && a !== "Out" && a !== "In" && !s.test(r) && console.warn(`The external '${a}' wasn't used in the resolved template.`), Pl(i) || _n(i) || jn(i)) return n.replaceAll(s, e.resolve(i).value);
955
+ let s = Jc(a);
956
+ if (r && a !== "Out" && a !== "In" && !s.test(r) && console.warn(`The external '${a}' wasn't used in the resolved template.`), Ml(i) || _n(i) || jn(i)) return n.replaceAll(s, e.resolve(i).value);
957
957
  if (i !== null && typeof i == "object") {
958
958
  let o = [...r.matchAll(new RegExp(`${a.replaceAll(".", "\\.").replaceAll("$", "\\$")}\\.(?<prop>.*?)(?![\\w\\$_])`, "g"))].map((u) => u[1]);
959
959
  return [...new Set(o)].reduce((u, l) => l && l in i ? En(e, { [`${a}.${l}`]: i[l] }, u) : u, n);
@@ -961,16 +961,16 @@ function En(e, t, r) {
961
961
  return console.warn(`During resolution, the external '${a}' has been omitted. Only TGPU resources, 'use gpu' functions, primitives, and plain JS objects can be used as externals.`), n;
962
962
  }, r);
963
963
  }
964
- function Zc(e) {
965
- let { strippedCode: t, argRange: r } = Qc(e), n = new uo(t);
964
+ function Xc(e) {
965
+ let { strippedCode: t, argRange: r } = Zc(e), n = new uo(t);
966
966
  n.consume("(");
967
967
  let a = [];
968
968
  for (; !n.isAt(")"); ) {
969
969
  let s = [];
970
970
  for (; n.isAt("@"); ) n.parseUntil(Xi, Zi), n.consume(")"), s.push(n.lastParsed);
971
- n.parseUntil(Hc);
971
+ n.parseUntil(Kc);
972
972
  let o = n.lastParsed, u;
973
- n.isAt(":") && (n.consume(":"), n.parseUntil(ep, rp), u = n.lastParsed), a.push({ identifier: o, attributes: s, type: u }), n.isAt(",") && n.consume(",");
973
+ n.isAt(":") && (n.consume(":"), n.parseUntil(Hc, tp), u = n.lastParsed), a.push({ identifier: o, attributes: s, type: u }), n.isAt(",") && n.consume(",");
974
974
  }
975
975
  n.consume(")");
976
976
  let i;
@@ -982,10 +982,10 @@ function Zc(e) {
982
982
  }
983
983
  return { args: a, ret: i, range: { begin: r[0], end: r[1] } };
984
984
  }
985
- function Qc(e) {
985
+ function Zc(e) {
986
986
  let t = new uo(e), r = "", n;
987
987
  for (; !t.isFinished(); ) {
988
- if (t.isAt(Kc)) {
988
+ if (t.isAt(Qc)) {
989
989
  t.advanceBy(1);
990
990
  continue;
991
991
  }
@@ -994,7 +994,7 @@ function Qc(e) {
994
994
  continue;
995
995
  }
996
996
  if (t.isAt("/*")) {
997
- t.parseUntil(tp, np), t.consume("*/");
997
+ t.parseUntil(ep, rp), t.consume("*/");
998
998
  continue;
999
999
  }
1000
1000
  if (t.isAt("{")) return { strippedCode: r, argRange: [n, t.pos] };
@@ -1043,7 +1043,7 @@ var uo = class {
1043
1043
  this.advanceBy(t.length);
1044
1044
  }
1045
1045
  }, lo = /* @__PURE__ */ new Set([`
1046
- `, "\v", "\f", "\r", "…", "\u2028", "\u2029"]), Kc = /* @__PURE__ */ new Set([...lo, " ", " ", "‎", "‏"]), Xi = /* @__PURE__ */ new Set([")"]), Hc = /* @__PURE__ */ new Set([":", ",", ")"]), ep = /* @__PURE__ */ new Set([",", ")"]), tp = /* @__PURE__ */ new Set(["*/"]), Zi = ["(", ")"], rp = ["<", ">"], np = ["/*", "*/"];
1046
+ `, "\v", "\f", "\r", "…", "\u2028", "\u2029"]), Qc = /* @__PURE__ */ new Set([...lo, " ", " ", "‎", "‏"]), Xi = /* @__PURE__ */ new Set([")"]), Kc = /* @__PURE__ */ new Set([":", ",", ")"]), Hc = /* @__PURE__ */ new Set([",", ")"]), ep = /* @__PURE__ */ new Set(["*/"]), Zi = ["(", ")"], tp = ["<", ">"], rp = ["/*", "*/"];
1047
1047
  function Un(e, t = "") {
1048
1048
  let r = [], n = { applyExternals(i) {
1049
1049
  r.push(i);
@@ -1058,9 +1058,9 @@ function Un(e, t = "") {
1058
1058
  let ne = xe(s[0]) ? `(in: ${i.resolve(s[0]).value})` : "()", Vt = Vr(o) ? hi(o) : "", Jt = o !== de ? xe(o) ? `-> ${i.resolve(o).value}` : `-> ${Vt !== "" ? Vt : "@location(0)"} ${i.resolve(o).value}` : "";
1059
1059
  ee = `${ne} ${Jt} `, fe = D;
1060
1060
  } else {
1061
- let ne = Zc(D);
1061
+ let ne = Xc(D);
1062
1062
  if (ne.args.length !== s.length) throw new Error(`WGSL implementation has ${ne.args.length} arguments, while the shell has ${s.length} arguments.`);
1063
- let Vt = ne.args.map((pr, kn) => `${pr.identifier}: ${Qi(i, `parameter ${pr.identifier}`, pr.type, s[kn])}`).join(", "), Jt = o === de ? "" : `-> ${Qi(i, "return type", ne.ret?.type, o)}`;
1063
+ let Vt = ne.args.map((dr, kn) => `${dr.identifier}: ${Qi(i, `parameter ${dr.identifier}`, dr.type, s[kn])}`).join(", "), Jt = o === de ? "" : `-> ${Qi(i, "return type", ne.ret?.type, o)}`;
1064
1064
  ee = `(${Vt}) ${Jt}`, fe = D.slice(ne.range.end);
1065
1065
  }
1066
1066
  return i.addDeclaration(`${t}fn ${l}${ee}${fe}`), g(l, o, "runtime");
@@ -1073,7 +1073,7 @@ function Un(e, t = "") {
1073
1073
  let f = d?.ast;
1074
1074
  if (!f) throw new Error("Missing metadata for tgpu.fn function body (either missing 'use gpu' directive, or misconfigured `unplugin-typegpu`)");
1075
1075
  let w = f.externalNames.filter((D) => !(D in u));
1076
- if (w.length > 0) throw new Sl(x(this), w);
1076
+ if (w.length > 0) throw new Pl(x(this), w);
1077
1077
  let $ = f.params[1];
1078
1078
  $ && $.type === "i" && t !== "" && Rr(u, { [$.name]: ti(o) });
1079
1079
  let { head: S, body: O, returnType: G } = i.fnToWgsl({ functionType: t.includes("@compute") ? "compute" : t.includes("@vertex") ? "vertex" : t.includes("@fragment") ? "fragment" : "normal", argTypes: s, params: f.params, returnType: o, body: f.body, externalMap: u });
@@ -1088,7 +1088,7 @@ function Qi(e, t, r, n) {
1088
1088
  if (i !== a) throw new Error(`Type mismatch between TGPU shell and WGSL code string: ${t}, JS type "${a}", WGSL type "${i}".`);
1089
1089
  return r;
1090
1090
  }
1091
- function ap(e, t = {}) {
1091
+ function np(e, t = {}) {
1092
1092
  let r = 0, n = /* @__PURE__ */ new Set();
1093
1093
  return Object.fromEntries(Object.entries(e ?? {}).map(([a, i]) => {
1094
1094
  let s = Yt(i);
@@ -1106,23 +1106,23 @@ function ap(e, t = {}) {
1106
1106
  }));
1107
1107
  }
1108
1108
  function Mn(e, t = {}) {
1109
- return Jr(e) ? As(e) || Et(e) || Yt(e) !== void 0 ? e : Hn(0, e) : ii(ap(e, t));
1109
+ return Jr(e) ? As(e) || Et(e) || Yt(e) !== void 0 ? e : Hn(0, e) : ii(np(e, t));
1110
1110
  }
1111
1111
  function wa(e, ...t) {
1112
- return ip(e) ? sp(e, ...t) : e;
1112
+ return ap(e) ? ip(e, ...t) : e;
1113
1113
  }
1114
- function ip(e) {
1114
+ function ap(e) {
1115
1115
  return Array.isArray(e) && "raw" in e && Array.isArray(e.raw) && e.raw.every((t) => typeof t == "string");
1116
1116
  }
1117
- function sp(e, ...t) {
1117
+ function ip(e, ...t) {
1118
1118
  return e.slice(1).reduce((r, n, a) => `${r}${t[a]}${n}`, e[0]);
1119
1119
  }
1120
- function op(e) {
1120
+ function sp(e) {
1121
1121
  if (Object.keys(e.out).length === 0) throw new Error("A vertexFn output cannot be empty since it must include the 'position' builtin.");
1122
1122
  let t = { in: e.in, out: e.out, argTypes: e.in && Object.keys(e.in).length !== 0 ? [Mn(e.in)] : [], isEntry: !0 };
1123
- return Object.assign((r, ...n) => up(t, wa(r, ...n)), t);
1123
+ return Object.assign((r, ...n) => op(t, wa(r, ...n)), t);
1124
1124
  }
1125
- function up(e, t) {
1125
+ function op(e, t) {
1126
1126
  let r = Un(t, "@vertex "), n = e.argTypes[0];
1127
1127
  return { shell: e, $uses(a) {
1128
1128
  return r.applyExternals(a), this;
@@ -1135,49 +1135,49 @@ function up(e, t) {
1135
1135
  return `vertexFn:${x(r) ?? "<unnamed>"}`;
1136
1136
  } };
1137
1137
  }
1138
- var co = Object.defineProperty, lp = (e, t, r) => t in e ? co(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, cp = (e, t) => {
1138
+ var co = Object.defineProperty, up = (e, t, r) => t in e ? co(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, lp = (e, t) => {
1139
1139
  for (var r in t)
1140
1140
  co(e, r, { get: t[r], enumerable: !0 });
1141
- }, k = (e, t, r) => lp(e, typeof t != "symbol" ? t + "" : t, r), pp = {};
1142
- cp(pp, {
1141
+ }, k = (e, t, r) => up(e, typeof t != "symbol" ? t + "" : t, r), cp = {};
1142
+ lp(cp, {
1143
1143
  BufferReader: () => Lt,
1144
- BufferWriter: () => ur,
1144
+ BufferWriter: () => lr,
1145
1145
  MaxValue: () => me,
1146
1146
  Measurer: () => ue,
1147
- UnresolvedReferenceError: () => tr,
1147
+ UnresolvedReferenceError: () => rr,
1148
1148
  ValidationError: () => xa,
1149
- arrayOf: () => yp,
1150
- bool: () => vp,
1151
- byte: () => _p,
1152
- chars: () => Fp,
1153
- concat: () => Wp,
1154
- dynamicArrayOf: () => Dp,
1155
- f16: () => Gp,
1156
- f32: () => Bp,
1157
- f32Array: () => sd,
1158
- f64Array: () => od,
1159
- generic: () => Lp,
1160
- genericEnum: () => Rp,
1161
- i16: () => Ep,
1162
- i16Array: () => ad,
1163
- i32: () => Sp,
1164
- i32Array: () => id,
1165
- i8: () => $p,
1166
- i8Array: () => nd,
1167
- keyed: () => Vp,
1168
- object: () => Np,
1169
- optional: () => Xp,
1170
- string: () => xp,
1171
- tupleOf: () => Kp,
1172
- u16: () => Mp,
1173
- u16Array: () => td,
1174
- u32: () => kp,
1175
- u32Array: () => rd,
1149
+ arrayOf: () => fp,
1150
+ bool: () => gp,
1151
+ byte: () => Tp,
1152
+ chars: () => Cp,
1153
+ concat: () => Rp,
1154
+ dynamicArrayOf: () => jp,
1155
+ f16: () => Ap,
1156
+ f32: () => Op,
1157
+ f32Array: () => id,
1158
+ f64Array: () => sd,
1159
+ generic: () => Np,
1160
+ genericEnum: () => Lp,
1161
+ i16: () => Ip,
1162
+ i16Array: () => nd,
1163
+ i32: () => Pp,
1164
+ i32Array: () => ad,
1165
+ i8: () => bp,
1166
+ i8Array: () => rd,
1167
+ keyed: () => qp,
1168
+ object: () => Fp,
1169
+ optional: () => Jp,
1170
+ string: () => wp,
1171
+ tupleOf: () => Qp,
1172
+ u16: () => Up,
1173
+ u16Array: () => ed,
1174
+ u32: () => zp,
1175
+ u32Array: () => td,
1176
1176
  u8: () => yo,
1177
- u8Array: () => Hp,
1178
- u8ClampedArray: () => ed
1177
+ u8Array: () => Kp,
1178
+ u8ClampedArray: () => Hp
1179
1179
  });
1180
- var tr = class po extends Error {
1180
+ var rr = class po extends Error {
1181
1181
  constructor(t) {
1182
1182
  super(t), Object.setPrototypeOf(this, po.prototype);
1183
1183
  }
@@ -1185,7 +1185,7 @@ var tr = class po extends Error {
1185
1185
  constructor(t) {
1186
1186
  super(t), Object.setPrototypeOf(this, mo.prototype);
1187
1187
  }
1188
- }, dp = class {
1188
+ }, pp = class {
1189
1189
  constructor() {
1190
1190
  k(this, "size", Number.NaN), k(this, "unbounded", this), k(this, "isUnbounded", !0);
1191
1191
  }
@@ -1195,9 +1195,9 @@ var tr = class po extends Error {
1195
1195
  fork() {
1196
1196
  return this;
1197
1197
  }
1198
- }, mp = new dp(), ue = class ho {
1198
+ }, dp = new pp(), ue = class ho {
1199
1199
  constructor() {
1200
- k(this, "size", 0), k(this, "unbounded", mp), k(this, "isUnbounded", !1);
1200
+ k(this, "size", 0), k(this, "unbounded", dp), k(this, "isUnbounded", !1);
1201
1201
  }
1202
1202
  add(t) {
1203
1203
  return this.size += t, this;
@@ -1218,14 +1218,14 @@ var tr = class po extends Error {
1218
1218
  seekProperty(e, t) {
1219
1219
  return null;
1220
1220
  }
1221
- }, hp = class {
1221
+ }, mp = class {
1222
1222
  constructor(e) {
1223
1223
  this.key = e;
1224
1224
  }
1225
1225
  }, dn = {
1226
1226
  STRING: "string",
1227
1227
  ENUM: "enum"
1228
- }, fp = class extends $e {
1228
+ }, hp = class extends $e {
1229
1229
  constructor(e, t) {
1230
1230
  super(), this._unstableElementSchema = e, this.length = t, k(this, "elementSchema"), this.elementSchema = e;
1231
1231
  }
@@ -1267,10 +1267,10 @@ var tr = class po extends Error {
1267
1267
  }
1268
1268
  };
1269
1269
  // @__NO_SIDE_EFFECTS__
1270
- function yp(e, t) {
1271
- return new fp(e, t);
1270
+ function fp(e, t) {
1271
+ return new hp(e, t);
1272
1272
  }
1273
- var gp = class extends $e {
1273
+ var yp = class extends $e {
1274
1274
  constructor() {
1275
1275
  super(...arguments), k(this, "maxSize", 1);
1276
1276
  }
@@ -1283,7 +1283,7 @@ var gp = class extends $e {
1283
1283
  measure(e, t = new ue()) {
1284
1284
  return t.add(1);
1285
1285
  }
1286
- }, vp = new gp(), fo = class an extends $e {
1286
+ }, gp = new yp(), fo = class an extends $e {
1287
1287
  static get _encoder() {
1288
1288
  return an._cachedEncoder || (an._cachedEncoder = new TextEncoder()), an._cachedEncoder;
1289
1289
  }
@@ -1301,7 +1301,7 @@ var gp = class extends $e {
1301
1301
  }
1302
1302
  };
1303
1303
  k(fo, "_cachedEncoder");
1304
- var wp = fo, xp = new wp(), bp = class extends $e {
1304
+ var vp = fo, wp = new vp(), xp = class extends $e {
1305
1305
  constructor() {
1306
1306
  super(...arguments), k(this, "maxSize", 1);
1307
1307
  }
@@ -1314,7 +1314,7 @@ var wp = fo, xp = new wp(), bp = class extends $e {
1314
1314
  measure(e, t = new ue()) {
1315
1315
  return t.add(1);
1316
1316
  }
1317
- }, $p = new bp(), Tp = class extends $e {
1317
+ }, bp = new xp(), $p = class extends $e {
1318
1318
  constructor() {
1319
1319
  super(...arguments), k(this, "maxSize", 1);
1320
1320
  }
@@ -1327,7 +1327,7 @@ var wp = fo, xp = new wp(), bp = class extends $e {
1327
1327
  measure(e, t = new ue()) {
1328
1328
  return t.add(1);
1329
1329
  }
1330
- }, yo = new Tp(), _p = yo, Ip = class extends $e {
1330
+ }, yo = new $p(), Tp = yo, _p = class extends $e {
1331
1331
  constructor() {
1332
1332
  super(...arguments), k(this, "maxSize", 2);
1333
1333
  }
@@ -1340,7 +1340,7 @@ var wp = fo, xp = new wp(), bp = class extends $e {
1340
1340
  measure(e, t = new ue()) {
1341
1341
  return t.add(2);
1342
1342
  }
1343
- }, Ep = new Ip(), Up = class extends $e {
1343
+ }, Ip = new _p(), Ep = class extends $e {
1344
1344
  constructor() {
1345
1345
  super(...arguments), k(this, "maxSize", 2);
1346
1346
  }
@@ -1353,7 +1353,7 @@ var wp = fo, xp = new wp(), bp = class extends $e {
1353
1353
  measure(e, t = new ue()) {
1354
1354
  return t.add(2);
1355
1355
  }
1356
- }, Mp = new Up(), Pp = class extends $e {
1356
+ }, Up = new Ep(), Mp = class extends $e {
1357
1357
  constructor() {
1358
1358
  super(...arguments), k(this, "maxSize", 4);
1359
1359
  }
@@ -1366,7 +1366,7 @@ var wp = fo, xp = new wp(), bp = class extends $e {
1366
1366
  measure(e, t = new ue()) {
1367
1367
  return t.add(4);
1368
1368
  }
1369
- }, Sp = new Pp(), zp = class extends $e {
1369
+ }, Pp = new Mp(), Sp = class extends $e {
1370
1370
  constructor() {
1371
1371
  super(...arguments), k(this, "maxSize", 4);
1372
1372
  }
@@ -1379,7 +1379,7 @@ var wp = fo, xp = new wp(), bp = class extends $e {
1379
1379
  measure(e, t = new ue()) {
1380
1380
  return t.add(4);
1381
1381
  }
1382
- }, kp = new zp(), Ap = class extends $e {
1382
+ }, zp = new Sp(), kp = class extends $e {
1383
1383
  constructor() {
1384
1384
  super(...arguments), k(this, "maxSize", 2);
1385
1385
  }
@@ -1392,7 +1392,7 @@ var wp = fo, xp = new wp(), bp = class extends $e {
1392
1392
  measure(e, t = new ue()) {
1393
1393
  return t.add(2);
1394
1394
  }
1395
- }, Gp = new Ap(), Op = class extends $e {
1395
+ }, Ap = new kp(), Gp = class extends $e {
1396
1396
  constructor() {
1397
1397
  super(...arguments), k(this, "maxSize", 4);
1398
1398
  }
@@ -1405,7 +1405,7 @@ var wp = fo, xp = new wp(), bp = class extends $e {
1405
1405
  measure(e, t = new ue()) {
1406
1406
  return t.add(4);
1407
1407
  }
1408
- }, Bp = new Op(), Cp = class extends $e {
1408
+ }, Op = new Gp(), Bp = class extends $e {
1409
1409
  constructor(e) {
1410
1410
  super(), this.length = e;
1411
1411
  }
@@ -1428,8 +1428,8 @@ var wp = fo, xp = new wp(), bp = class extends $e {
1428
1428
  }
1429
1429
  };
1430
1430
  // @__NO_SIDE_EFFECTS__
1431
- function Fp(e) {
1432
- return new Cp(e);
1431
+ function Cp(e) {
1432
+ return new Bp(e);
1433
1433
  }
1434
1434
  // @__NO_SIDE_EFFECTS__
1435
1435
  function Ft(e) {
@@ -1495,7 +1495,7 @@ var yi = class extends $e {
1495
1495
  }
1496
1496
  };
1497
1497
  // @__NO_SIDE_EFFECTS__
1498
- function Np(e) {
1498
+ function Fp(e) {
1499
1499
  return new yi(e);
1500
1500
  }
1501
1501
  var vo = class extends $e {
@@ -1569,22 +1569,22 @@ var vo = class extends $e {
1569
1569
  }
1570
1570
  };
1571
1571
  // @__NO_SIDE_EFFECTS__
1572
- function Lp(e, t) {
1572
+ function Np(e, t) {
1573
1573
  return new vo(dn.STRING, e, t);
1574
1574
  }
1575
1575
  // @__NO_SIDE_EFFECTS__
1576
- function Rp(e, t) {
1576
+ function Lp(e, t) {
1577
1577
  return new vo(dn.ENUM, e, t);
1578
1578
  }
1579
1579
  // @__NO_SIDE_EFFECTS__
1580
- function Wp(e) {
1580
+ function Rp(e) {
1581
1581
  return new yi(
1582
1582
  Object.fromEntries(
1583
1583
  e.flatMap(({ properties: t }) => Object.entries(t))
1584
1584
  )
1585
1585
  );
1586
1586
  }
1587
- var jp = class extends $e {
1587
+ var Wp = class extends $e {
1588
1588
  constructor(e) {
1589
1589
  super(), this._unstableElementType = e, k(this, "elementType"), this.elementType = e;
1590
1590
  }
@@ -1644,39 +1644,39 @@ var jp = class extends $e {
1644
1644
  }
1645
1645
  };
1646
1646
  // @__NO_SIDE_EFFECTS__
1647
- function Dp(e) {
1648
- return new jp(e);
1647
+ function jp(e) {
1648
+ return new Wp(e);
1649
1649
  }
1650
1650
  var wo = class {
1651
1651
  constructor(e) {
1652
- k(this, "__unwrapped"), k(this, "ref"), this.ref = new hp(e);
1652
+ k(this, "__unwrapped"), k(this, "ref"), this.ref = new mp(e);
1653
1653
  }
1654
1654
  resolveReferences() {
1655
- throw new tr(
1655
+ throw new rr(
1656
1656
  "Tried to resolve a reference directly. Do it through a RefResolver instead."
1657
1657
  );
1658
1658
  }
1659
1659
  read() {
1660
- throw new tr(
1660
+ throw new rr(
1661
1661
  "Tried to read a reference directly. Resolve it instead."
1662
1662
  );
1663
1663
  }
1664
1664
  write() {
1665
- throw new tr(
1665
+ throw new rr(
1666
1666
  "Tried to write a reference directly. Resolve it instead."
1667
1667
  );
1668
1668
  }
1669
1669
  measure() {
1670
- throw new tr(
1670
+ throw new rr(
1671
1671
  "Tried to measure size of a reference directly. Resolve it instead."
1672
1672
  );
1673
1673
  }
1674
1674
  seekProperty() {
1675
- throw new tr(
1675
+ throw new rr(
1676
1676
  "Tried to seek property of a reference directly. Resolve it instead."
1677
1677
  );
1678
1678
  }
1679
- }, Yp = class {
1679
+ }, Dp = class {
1680
1680
  constructor() {
1681
1681
  k(this, "registry", {});
1682
1682
  }
@@ -1691,15 +1691,15 @@ var wo = class {
1691
1691
  const r = e.ref.key;
1692
1692
  if (this.registry[r] !== void 0)
1693
1693
  return this.registry[r];
1694
- throw new tr(
1694
+ throw new rr(
1695
1695
  `Couldn't resolve reference to ${r}. Unknown key.`
1696
1696
  );
1697
1697
  }
1698
1698
  return e.resolveReferences(this), e;
1699
1699
  }
1700
- }, qp = class {
1700
+ }, Yp = class {
1701
1701
  constructor(e, t) {
1702
- this.key = e, k(this, "__unwrapped"), k(this, "__keyDefinition"), k(this, "innerType"), this.innerType = t(new wo(e)), this.resolveReferences(new Yp());
1702
+ this.key = e, k(this, "__unwrapped"), k(this, "__keyDefinition"), k(this, "innerType"), this.innerType = t(new wo(e)), this.resolveReferences(new Dp());
1703
1703
  }
1704
1704
  resolveReferences(e) {
1705
1705
  e.hasKey(this.key) || (e.register(this.key, this.innerType), this.innerType.resolveReferences(e));
@@ -1729,10 +1729,10 @@ var wo = class {
1729
1729
  }
1730
1730
  };
1731
1731
  // @__NO_SIDE_EFFECTS__
1732
- function Vp(e, t) {
1733
- return new qp(e, t);
1732
+ function qp(e, t) {
1733
+ return new Yp(e, t);
1734
1734
  }
1735
- var Jp = class extends $e {
1735
+ var Vp = class extends $e {
1736
1736
  constructor(e) {
1737
1737
  super(), this._innerUnstableSchema = e, k(this, "innerSchema"), this.innerSchema = e;
1738
1738
  }
@@ -1762,19 +1762,19 @@ var Jp = class extends $e {
1762
1762
  }
1763
1763
  };
1764
1764
  // @__NO_SIDE_EFFECTS__
1765
- function Xp(e) {
1766
- return new Jp(e);
1765
+ function Jp(e) {
1766
+ return new Vp(e);
1767
1767
  }
1768
1768
  // @__NO_SIDE_EFFECTS__
1769
- function Zp(e, t) {
1769
+ function Xp(e, t) {
1770
1770
  return t.map((r) => e.resolve(r));
1771
1771
  }
1772
- var Qp = class extends $e {
1772
+ var Zp = class extends $e {
1773
1773
  constructor(e) {
1774
1774
  super(), this._unstableSchemas = e, k(this, "schemas"), this.schemas = e;
1775
1775
  }
1776
1776
  resolveReferences(e) {
1777
- this.schemas = /* @__PURE__ */ Zp(e, this._unstableSchemas);
1777
+ this.schemas = /* @__PURE__ */ Xp(e, this._unstableSchemas);
1778
1778
  }
1779
1779
  write(e, t) {
1780
1780
  if (t.length !== this.schemas.length)
@@ -1813,8 +1813,8 @@ var Qp = class extends $e {
1813
1813
  }
1814
1814
  };
1815
1815
  // @__NO_SIDE_EFFECTS__
1816
- function Kp(e) {
1817
- return new Qp(e);
1816
+ function Qp(e) {
1817
+ return new Zp(e);
1818
1818
  }
1819
1819
  var kt = class extends $e {
1820
1820
  constructor(e, t) {
@@ -1830,15 +1830,15 @@ var kt = class extends $e {
1830
1830
  measure(e, t = new ue()) {
1831
1831
  return t.add(this.byteLength);
1832
1832
  }
1833
- }, Hp = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Uint8Array), ed = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Uint8ClampedArray), td = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Uint16Array), rd = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Uint32Array), nd = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Int8Array), ad = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Int16Array), id = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Int32Array), sd = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Float32Array), od = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Float64Array);
1833
+ }, Kp = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Uint8Array), Hp = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Uint8ClampedArray), ed = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Uint16Array), td = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Uint32Array), rd = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Int8Array), nd = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Int16Array), ad = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Int32Array), id = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Float32Array), sd = /* @__NO_SIDE_EFFECTS__ */ (e) => new kt(e, Float64Array);
1834
1834
  // @__NO_SIDE_EFFECTS__
1835
- function ud() {
1835
+ function od() {
1836
1836
  const e = new Uint8Array(4), t = new Uint32Array(e.buffer);
1837
1837
  return t[0] = 1, e[0] === 0;
1838
1838
  }
1839
1839
  // @__NO_SIDE_EFFECTS__
1840
1840
  function xo() {
1841
- return /* @__PURE__ */ ud() ? "big" : "little";
1841
+ return /* @__PURE__ */ od() ? "big" : "little";
1842
1842
  }
1843
1843
  // @__NO_SIDE_EFFECTS__
1844
1844
  function gi(e) {
@@ -1865,14 +1865,14 @@ var bo = class {
1865
1865
  this.byteOffset += e;
1866
1866
  }
1867
1867
  };
1868
- function ld(e) {
1868
+ function ud(e) {
1869
1869
  if (e === 0) return 0;
1870
1870
  if (Number.isNaN(e)) return 32256;
1871
1871
  if (!Number.isFinite(e)) return e > 0 ? 31744 : 64512;
1872
1872
  const t = e < 0 ? 1 : 0, r = Math.abs(e), n = Math.floor(Math.log2(r)), a = r / 2 ** n - 1, i = n + 15, s = Math.floor(a * 1024);
1873
1873
  return t << 15 | i << 10 | s;
1874
1874
  }
1875
- function cd(e) {
1875
+ function ld(e) {
1876
1876
  const t = (e & 32768) >> 15, r = (e & 31744) >> 10, n = e & 1023;
1877
1877
  return r === 0 ? t === 0 ? n / 1024 : -n / 1024 : r === 31 ? n === 0 ? t === 0 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY : Number.NaN : (t === 0 ? 1 : -1) * (1 + n / 1024) * 2 ** (r - 15);
1878
1878
  }
@@ -1913,7 +1913,7 @@ var Lt = class extends bo {
1913
1913
  }
1914
1914
  readFloat16() {
1915
1915
  const e = this.dataView.getUint16(this.byteOffset, this.littleEndian);
1916
- return this.byteOffset += 2, cd(e);
1916
+ return this.byteOffset += 2, ld(e);
1917
1917
  }
1918
1918
  readFloat32() {
1919
1919
  const e = this.dataView.getFloat32(this.byteOffset, this.littleEndian);
@@ -1936,7 +1936,7 @@ var Lt = class extends bo {
1936
1936
  for (let i = 0; i < r; ++i)
1937
1937
  a[i] = this.dataView.getUint8(this.byteOffset++);
1938
1938
  }
1939
- }, ur = class extends bo {
1939
+ }, lr = class extends bo {
1940
1940
  constructor() {
1941
1941
  super(...arguments), k(this, "_cachedTextEncoder");
1942
1942
  }
@@ -1970,7 +1970,7 @@ var Lt = class extends bo {
1970
1970
  writeFloat16(e) {
1971
1971
  this.dataView.setUint16(
1972
1972
  this.byteOffset,
1973
- ld(e),
1973
+ ud(e),
1974
1974
  this.littleEndian
1975
1975
  ), this.byteOffset += 2;
1976
1976
  }
@@ -2011,96 +2011,96 @@ function To(e) {
2011
2011
  return n;
2012
2012
  };
2013
2013
  }
2014
- function pd(e) {
2014
+ function cd(e) {
2015
2015
  return typeof e == "number" ? Math.abs(e) : _.abs[e.kind](e);
2016
2016
  }
2017
- var dd = m({ name: "abs", signature: A, normalImpl: pd, codegenImpl: (e) => p`abs(${e})` });
2018
- function md(e) {
2017
+ var pd = m({ name: "abs", signature: A, normalImpl: cd, codegenImpl: (e) => p`abs(${e})` });
2018
+ function dd(e) {
2019
2019
  return typeof e == "number" ? Math.acos(e) : _.acos[e.kind](e);
2020
2020
  }
2021
- var hd = m({ name: "acos", signature: A, normalImpl: md, codegenImpl: (e) => p`acos(${e})` });
2022
- function fd(e) {
2021
+ var md = m({ name: "acos", signature: A, normalImpl: dd, codegenImpl: (e) => p`acos(${e})` });
2022
+ function hd(e) {
2023
2023
  return typeof e == "number" ? Math.acosh(e) : _.acosh[e.kind](e);
2024
2024
  }
2025
- var yd = m({ name: "acosh", signature: A, normalImpl: fd, codegenImpl: (e) => p`acosh(${e})` });
2026
- function gd(e) {
2025
+ var fd = m({ name: "acosh", signature: A, normalImpl: hd, codegenImpl: (e) => p`acosh(${e})` });
2026
+ function yd(e) {
2027
2027
  return typeof e == "number" ? Math.asin(e) : _.asin[e.kind](e);
2028
2028
  }
2029
- var vd = m({ name: "asin", signature: A, normalImpl: gd, codegenImpl: (e) => p`asin(${e})` });
2030
- function wd(e) {
2029
+ var gd = m({ name: "asin", signature: A, normalImpl: yd, codegenImpl: (e) => p`asin(${e})` });
2030
+ function vd(e) {
2031
2031
  return typeof e == "number" ? Math.asinh(e) : _.asinh[e.kind](e);
2032
2032
  }
2033
- var xd = m({ name: "asinh", signature: A, normalImpl: wd, codegenImpl: (e) => p`asinh(${e})` });
2034
- function bd(e) {
2033
+ var wd = m({ name: "asinh", signature: A, normalImpl: vd, codegenImpl: (e) => p`asinh(${e})` });
2034
+ function xd(e) {
2035
2035
  return typeof e == "number" ? Math.atan(e) : _.atan[e.kind](e);
2036
2036
  }
2037
- var $d = m({ name: "atan", signature: A, normalImpl: bd, codegenImpl: (e) => p`atan(${e})` });
2038
- function Td(e) {
2037
+ var bd = m({ name: "atan", signature: A, normalImpl: xd, codegenImpl: (e) => p`atan(${e})` });
2038
+ function $d(e) {
2039
2039
  return typeof e == "number" ? Math.atanh(e) : _.atanh[e.kind](e);
2040
2040
  }
2041
- var _d = m({ name: "atanh", signature: A, normalImpl: Td, codegenImpl: (e) => p`atanh(${e})` });
2042
- function Id(e, t) {
2041
+ var Td = m({ name: "atanh", signature: A, normalImpl: $d, codegenImpl: (e) => p`atanh(${e})` });
2042
+ function _d(e, t) {
2043
2043
  return typeof e == "number" && typeof t == "number" ? Math.atan2(e, t) : _.atan2[e.kind](e, t);
2044
2044
  }
2045
- var Ed = m({ name: "atan2", signature: (...e) => {
2045
+ var Id = m({ name: "atan2", signature: (...e) => {
2046
2046
  let t = be(e, [b, Ae, jt]) ?? e;
2047
2047
  return { argTypes: t, returnType: t[0] };
2048
- }, normalImpl: Id, codegenImpl: (e, t) => p`atan2(${e}, ${t})` });
2049
- function Ud(e) {
2048
+ }, normalImpl: _d, codegenImpl: (e, t) => p`atan2(${e}, ${t})` });
2049
+ function Ed(e) {
2050
2050
  return typeof e == "number" ? Math.ceil(e) : _.ceil[e.kind](e);
2051
2051
  }
2052
- var _o = m({ name: "ceil", signature: A, normalImpl: Ud, codegenImpl: (e) => p`ceil(${e})` });
2053
- function Md(e, t, r) {
2052
+ var _o = m({ name: "ceil", signature: A, normalImpl: Ed, codegenImpl: (e) => p`ceil(${e})` });
2053
+ function Ud(e, t, r) {
2054
2054
  return typeof e == "number" ? Math.min(Math.max(t, e), r) : _.clamp[e.kind](e, t, r);
2055
2055
  }
2056
- var Pd = m({ name: "clamp", signature: ba, normalImpl: Md, codegenImpl: (e, t, r) => p`clamp(${e}, ${t}, ${r})` });
2057
- function Sd(e) {
2056
+ var Md = m({ name: "clamp", signature: ba, normalImpl: Ud, codegenImpl: (e, t, r) => p`clamp(${e}, ${t}, ${r})` });
2057
+ function Pd(e) {
2058
2058
  return typeof e == "number" ? Math.cos(e) : _.cos[e.kind](e);
2059
2059
  }
2060
- var Qe = m({ name: "cos", signature: A, normalImpl: Sd, codegenImpl: (e) => p`cos(${e})` });
2061
- function zd(e) {
2060
+ var Qe = m({ name: "cos", signature: A, normalImpl: Pd, codegenImpl: (e) => p`cos(${e})` });
2061
+ function Sd(e) {
2062
2062
  return typeof e == "number" ? Math.cosh(e) : _.cosh[e.kind](e);
2063
2063
  }
2064
- var kd = m({ name: "cosh", signature: A, normalImpl: zd, codegenImpl: (e) => p`cosh(${e})` }), Ad = m({ name: "countLeadingZeros", signature: A, normalImpl: "CPU implementation for countLeadingZeros not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`countLeadingZeros(${e})` }), Gd = m({ name: "countOneBits", signature: A, normalImpl: "CPU implementation for countOneBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`countOneBits(${e})` }), Od = m({ name: "countTrailingZeros", signature: A, normalImpl: "CPU implementation for countTrailingZeros not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`countTrailingZeros(${e})` }), Bd = m({ name: "cross", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: (e, t) => _.cross[e.kind](e, t), codegenImpl: (e, t) => p`cross(${e}, ${t})` });
2065
- function Cd(e) {
2064
+ var zd = m({ name: "cosh", signature: A, normalImpl: Sd, codegenImpl: (e) => p`cosh(${e})` }), kd = m({ name: "countLeadingZeros", signature: A, normalImpl: "CPU implementation for countLeadingZeros not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`countLeadingZeros(${e})` }), Ad = m({ name: "countOneBits", signature: A, normalImpl: "CPU implementation for countOneBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`countOneBits(${e})` }), Gd = m({ name: "countTrailingZeros", signature: A, normalImpl: "CPU implementation for countTrailingZeros not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`countTrailingZeros(${e})` }), Od = m({ name: "cross", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: (e, t) => _.cross[e.kind](e, t), codegenImpl: (e, t) => p`cross(${e}, ${t})` });
2065
+ function Bd(e) {
2066
2066
  if (typeof e == "number") return e * 180 / Math.PI;
2067
2067
  throw new Mt("CPU implementation for degrees on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues");
2068
2068
  }
2069
- var Fd = m({ name: "degrees", signature: A, normalImpl: Cd, codegenImpl: (e) => p`degrees(${e})` }), Nd = m({ name: "determinant", signature: A, normalImpl: "CPU implementation for determinant not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`determinant(${e})` });
2070
- function Ld(e, t) {
2069
+ var Cd = m({ name: "degrees", signature: A, normalImpl: Bd, codegenImpl: (e) => p`degrees(${e})` }), Fd = m({ name: "determinant", signature: A, normalImpl: "CPU implementation for determinant not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`determinant(${e})` });
2070
+ function Nd(e, t) {
2071
2071
  return typeof e == "number" && typeof t == "number" ? Math.abs(e - t) : ea(W(e, t));
2072
2072
  }
2073
- var Rd = m({ name: "distance", signature: (...e) => ({ argTypes: e, returnType: oi(e[0]) ? Ae : b }), normalImpl: Ld, codegenImpl: (e, t) => p`distance(${e}, ${t})` }), ce = m({ name: "dot", signature: (...e) => ({ argTypes: e, returnType: e[0].primitive }), normalImpl: (e, t) => _.dot[e.kind](e, t), codegenImpl: (e, t) => p`dot(${e}, ${t})` }), Wd = m({ name: "dot4U8Packed", signature: { argTypes: [y, y], returnType: y }, normalImpl: "CPU implementation for dot4U8Packed not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e, t) => p`dot4U8Packed(${e}, ${t})` }), jd = m({ name: "dot4I8Packed", signature: { argTypes: [y, y], returnType: Ue }, normalImpl: "CPU implementation for dot4I8Packed not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e, t) => p`dot4I8Packed(${e}, ${t})` });
2074
- function Dd(e) {
2073
+ var Ld = m({ name: "distance", signature: (...e) => ({ argTypes: e, returnType: oi(e[0]) ? Ae : b }), normalImpl: Nd, codegenImpl: (e, t) => p`distance(${e}, ${t})` }), ce = m({ name: "dot", signature: (...e) => ({ argTypes: e, returnType: e[0].primitive }), normalImpl: (e, t) => _.dot[e.kind](e, t), codegenImpl: (e, t) => p`dot(${e}, ${t})` }), Rd = m({ name: "dot4U8Packed", signature: { argTypes: [y, y], returnType: y }, normalImpl: "CPU implementation for dot4U8Packed not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e, t) => p`dot4U8Packed(${e}, ${t})` }), Wd = m({ name: "dot4I8Packed", signature: { argTypes: [y, y], returnType: Ue }, normalImpl: "CPU implementation for dot4I8Packed not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e, t) => p`dot4I8Packed(${e}, ${t})` });
2074
+ function jd(e) {
2075
2075
  return typeof e == "number" ? Math.exp(e) : _.exp[e.kind](e);
2076
2076
  }
2077
- var Yd = m({ name: "exp", signature: A, normalImpl: Dd, codegenImpl: (e) => p`exp(${e})` });
2078
- function qd(e) {
2077
+ var Dd = m({ name: "exp", signature: A, normalImpl: jd, codegenImpl: (e) => p`exp(${e})` });
2078
+ function Yd(e) {
2079
2079
  return typeof e == "number" ? 2 ** e : _.exp2[e.kind](e);
2080
2080
  }
2081
- var Vd = m({ name: "exp2", signature: A, normalImpl: qd, codegenImpl: (e) => p`exp2(${e})` }), Jd = m({ name: "extractBits", signature: (e, t, r) => ({ argTypes: [e, y, y], returnType: e }), normalImpl: "CPU implementation for extractBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e, t, r) => p`extractBits(${e}, ${t}, ${r})` }), Xd = m({ name: "faceForward", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: "CPU implementation for faceForward not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e, t, r) => p`faceForward(${e}, ${t}, ${r})` }), Zd = m({ name: "firstLeadingBit", signature: A, normalImpl: "CPU implementation for firstLeadingBit not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`firstLeadingBit(${e})` }), Qd = m({ name: "firstTrailingBit", signature: A, normalImpl: "CPU implementation for firstTrailingBit not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`firstTrailingBit(${e})` });
2082
- function Kd(e) {
2081
+ var qd = m({ name: "exp2", signature: A, normalImpl: Yd, codegenImpl: (e) => p`exp2(${e})` }), Vd = m({ name: "extractBits", signature: (e, t, r) => ({ argTypes: [e, y, y], returnType: e }), normalImpl: "CPU implementation for extractBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e, t, r) => p`extractBits(${e}, ${t}, ${r})` }), Jd = m({ name: "faceForward", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: "CPU implementation for faceForward not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e, t, r) => p`faceForward(${e}, ${t}, ${r})` }), Xd = m({ name: "firstLeadingBit", signature: A, normalImpl: "CPU implementation for firstLeadingBit not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`firstLeadingBit(${e})` }), Zd = m({ name: "firstTrailingBit", signature: A, normalImpl: "CPU implementation for firstTrailingBit not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`firstTrailingBit(${e})` });
2082
+ function Qd(e) {
2083
2083
  return typeof e == "number" ? Math.floor(e) : _.floor[e.kind](e);
2084
2084
  }
2085
- var ir = m({ name: "floor", signature: A, normalImpl: Kd, codegenImpl: (e) => p`floor(${e})` });
2086
- function Hd(e, t, r) {
2085
+ var sr = m({ name: "floor", signature: A, normalImpl: Qd, codegenImpl: (e) => p`floor(${e})` });
2086
+ function Kd(e, t, r) {
2087
2087
  if (typeof e == "number") return e * t + r;
2088
2088
  throw new Mt("CPU implementation for fma on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues");
2089
2089
  }
2090
- var em = m({ name: "fma", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: Hd, codegenImpl: (e, t, r) => p`fma(${e}, ${t}, ${r})` });
2091
- function tm(e) {
2090
+ var Hd = m({ name: "fma", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: Kd, codegenImpl: (e, t, r) => p`fma(${e}, ${t}, ${r})` });
2091
+ function em(e) {
2092
2092
  return typeof e == "number" ? e - Math.floor(e) : _.fract[e.kind](e);
2093
2093
  }
2094
- var xt = m({ name: "fract", signature: A, normalImpl: tm, codegenImpl: (e) => p`fract(${e})` }), rm = { f32: we({ fract: b, exp: Ue }), f16: we({ fract: Ae, exp: Ue }), abstractFloat: we({ fract: jt, exp: la }), vec2f: we({ fract: I, exp: pe }), vec3f: we({ fract: T, exp: Fe }), vec4f: we({ fract: C, exp: Se }), vec2h: we({ fract: _t, exp: pe }), vec3h: we({ fract: Tt, exp: Fe }), vec4h: we({ fract: $t, exp: Se }) }, nm = m({ name: "frexp", normalImpl: "CPU implementation for frexp not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", signature: (e) => {
2095
- let t = rm[e.type];
2094
+ var xt = m({ name: "fract", signature: A, normalImpl: em, codegenImpl: (e) => p`fract(${e})` }), tm = { f32: we({ fract: b, exp: Ue }), f16: we({ fract: Ae, exp: Ue }), abstractFloat: we({ fract: jt, exp: la }), vec2f: we({ fract: I, exp: pe }), vec3f: we({ fract: T, exp: Fe }), vec4f: we({ fract: C, exp: Se }), vec2h: we({ fract: _t, exp: pe }), vec3h: we({ fract: Tt, exp: Fe }), vec4h: we({ fract: $t, exp: Se }) }, rm = m({ name: "frexp", normalImpl: "CPU implementation for frexp not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", signature: (e) => {
2095
+ let t = tm[e.type];
2096
2096
  if (!t) throw new Error(`Unsupported data type for frexp: ${e.type}. Supported types are f32, f16, abstractFloat, vec2f, vec3f, vec4f, vec2h, vec3h, vec4h.`);
2097
2097
  return { argTypes: [e], returnType: t };
2098
- }, codegenImpl: (e) => p`frexp(${e})` }), am = m({ name: "insertBits", signature: (e, t, r, n) => ({ argTypes: [e, t, y, y], returnType: e }), normalImpl: "CPU implementation for insertBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e, t, r, n) => p`insertBits(${e}, ${t}, ${r}, ${n})` });
2099
- function im(e) {
2098
+ }, codegenImpl: (e) => p`frexp(${e})` }), nm = m({ name: "insertBits", signature: (e, t, r, n) => ({ argTypes: [e, t, y, y], returnType: e }), normalImpl: "CPU implementation for insertBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e, t, r, n) => p`insertBits(${e}, ${t}, ${r}, ${n})` });
2099
+ function am(e) {
2100
2100
  if (typeof e == "number") return 1 / Math.sqrt(e);
2101
2101
  throw new Mt("CPU implementation for inverseSqrt on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues");
2102
2102
  }
2103
- var sm = m({ name: "inverseSqrt", signature: A, normalImpl: im, codegenImpl: (e) => p`inverseSqrt(${e})` }), om = m({ name: "ldexp", signature: (e, t) => {
2103
+ var im = m({ name: "inverseSqrt", signature: A, normalImpl: am, codegenImpl: (e) => p`inverseSqrt(${e})` }), sm = m({ name: "ldexp", signature: (e, t) => {
2104
2104
  switch (e.type) {
2105
2105
  case "abstractFloat":
2106
2106
  return { argTypes: [e, la], returnType: e };
@@ -2120,27 +2120,27 @@ var sm = m({ name: "inverseSqrt", signature: A, normalImpl: im, codegenImpl: (e)
2120
2120
  throw new Error(`Unsupported data type for ldexp: ${e.type}. Supported types are abstractFloat, f32, f16, vec2f, vec2h, vec3f, vec3h, vec4f, vec4h.`);
2121
2121
  }
2122
2122
  }, normalImpl: "CPU implementation for ldexp not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e, t) => p`ldexp(${e}, ${t})` });
2123
- function um(e) {
2123
+ function om(e) {
2124
2124
  return typeof e == "number" ? Math.abs(e) : _.length[e.kind](e);
2125
2125
  }
2126
- var ea = m({ name: "length", signature: (e) => ({ argTypes: [e], returnType: oi(e) ? Ae : b }), normalImpl: um, codegenImpl: (e) => p`length(${e})` });
2127
- function lm(e) {
2126
+ var ea = m({ name: "length", signature: (e) => ({ argTypes: [e], returnType: oi(e) ? Ae : b }), normalImpl: om, codegenImpl: (e) => p`length(${e})` });
2127
+ function um(e) {
2128
2128
  return typeof e == "number" ? Math.log(e) : _.log[e.kind](e);
2129
2129
  }
2130
- var yn = m({ name: "log", signature: A, normalImpl: lm, codegenImpl: (e) => p`log(${e})` });
2131
- function cm(e) {
2130
+ var yn = m({ name: "log", signature: A, normalImpl: um, codegenImpl: (e) => p`log(${e})` });
2131
+ function lm(e) {
2132
2132
  return typeof e == "number" ? Math.log2(e) : _.log2[e.kind](e);
2133
2133
  }
2134
- var pm = m({ name: "log2", signature: A, normalImpl: cm, codegenImpl: (e) => p`log2(${e})` });
2135
- function dm(e, t) {
2134
+ var cm = m({ name: "log2", signature: A, normalImpl: lm, codegenImpl: (e) => p`log2(${e})` });
2135
+ function pm(e, t) {
2136
2136
  return typeof e == "number" ? Math.max(e, t) : _.max[e.kind](e, t);
2137
2137
  }
2138
- var mm = m({ name: "max", signature: ba, normalImpl: $o(dm), codegenImpl: To("max") });
2139
- function hm(e, t) {
2138
+ var dm = m({ name: "max", signature: ba, normalImpl: $o(pm), codegenImpl: To("max") });
2139
+ function mm(e, t) {
2140
2140
  return typeof e == "number" ? Math.min(e, t) : _.min[e.kind](e, t);
2141
2141
  }
2142
- var fm = m({ name: "min", signature: ba, normalImpl: $o(hm), codegenImpl: To("min") });
2143
- function ym(e, t, r) {
2142
+ var hm = m({ name: "min", signature: ba, normalImpl: $o(mm), codegenImpl: To("min") });
2143
+ function fm(e, t, r) {
2144
2144
  if (typeof e == "number") {
2145
2145
  if (typeof r != "number" || typeof t != "number") throw new Error("When e1 and e2 are numbers, the blend factor must be a number.");
2146
2146
  return e * (1 - r) + t * r;
@@ -2148,98 +2148,98 @@ function ym(e, t, r) {
2148
2148
  if (typeof e == "number" || typeof t == "number") throw new Error("e1 and e2 need to both be vectors of the same kind.");
2149
2149
  return _.mix[e.kind](e, t, r);
2150
2150
  }
2151
- var yt = m({ name: "mix", signature: ba, normalImpl: ym, codegenImpl: (e, t, r) => p`mix(${e}, ${t}, ${r})` }), gm = { f32: we({ fract: b, whole: b }), f16: we({ fract: Ae, whole: Ae }), abstractFloat: we({ fract: jt, whole: jt }), vec2f: we({ fract: I, whole: I }), vec3f: we({ fract: T, whole: T }), vec4f: we({ fract: C, whole: C }), vec2h: we({ fract: _t, whole: _t }), vec3h: we({ fract: Tt, whole: Tt }), vec4h: we({ fract: $t, whole: $t }) }, vm = m({ name: "modf", signature: (e) => {
2152
- let t = gm[e.type];
2151
+ var yt = m({ name: "mix", signature: ba, normalImpl: fm, codegenImpl: (e, t, r) => p`mix(${e}, ${t}, ${r})` }), ym = { f32: we({ fract: b, whole: b }), f16: we({ fract: Ae, whole: Ae }), abstractFloat: we({ fract: jt, whole: jt }), vec2f: we({ fract: I, whole: I }), vec3f: we({ fract: T, whole: T }), vec4f: we({ fract: C, whole: C }), vec2h: we({ fract: _t, whole: _t }), vec3h: we({ fract: Tt, whole: Tt }), vec4h: we({ fract: $t, whole: $t }) }, gm = m({ name: "modf", signature: (e) => {
2152
+ let t = ym[e.type];
2153
2153
  if (!t) throw new Error(`Unsupported data type for modf: ${e.type}. Supported types are f32, f16, abstractFloat, vec2f, vec3f, vec4f, vec2h, vec3h, vec4h.`);
2154
2154
  return { argTypes: [e], returnType: t };
2155
2155
  }, normalImpl: "CPU implementation for modf not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`modf(${e})` }), gn = m({ name: "normalize", signature: A, normalImpl: (e) => _.normalize[e.kind](e), codegenImpl: (e) => p`normalize(${e})` });
2156
- function wm(e, t) {
2156
+ function vm(e, t) {
2157
2157
  if (typeof e == "number" && typeof t == "number") return e ** t;
2158
2158
  if (ye(e) && ye(t)) return _.pow[e.kind](e, t);
2159
2159
  throw new Error("Invalid arguments to pow()");
2160
2160
  }
2161
2161
  var ta = m({ name: "pow", signature: (...e) => {
2162
2162
  let t = be(e, [b, Ae, jt]) ?? e;
2163
- return { argTypes: t, returnType: rr(t[0]) ? t[1] : t[0] };
2164
- }, normalImpl: wm, codegenImpl: (e, t) => p`pow(${e}, ${t})` }), xm = m({ name: "quantizeToF16", signature: A, normalImpl: "CPU implementation for quantizeToF16 not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`quantizeToF16(${e})` });
2165
- function bm(e) {
2163
+ return { argTypes: t, returnType: nr(t[0]) ? t[1] : t[0] };
2164
+ }, normalImpl: vm, codegenImpl: (e, t) => p`pow(${e}, ${t})` }), wm = m({ name: "quantizeToF16", signature: A, normalImpl: "CPU implementation for quantizeToF16 not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`quantizeToF16(${e})` });
2165
+ function xm(e) {
2166
2166
  if (typeof e == "number") return e * Math.PI / 180;
2167
2167
  throw new Mt("CPU implementation for radians on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues");
2168
2168
  }
2169
- var $m = m({ name: "radians", signature: (...e) => {
2169
+ var bm = m({ name: "radians", signature: (...e) => {
2170
2170
  let t = be(e, [b, Ae, jt]) ?? e;
2171
2171
  return { argTypes: t, returnType: t[0] };
2172
- }, normalImpl: bm, codegenImpl: (e) => p`radians(${e})` }), Tm = m({ name: "reflect", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: (e, t) => W(e, N(2 * ce(t, e), t)), codegenImpl: (e, t) => p`reflect(${e}, ${t})` }), _m = m({ name: "refract", normalImpl: "CPU implementation for refract not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e, t, r) => p`refract(${e}, ${t}, ${r})`, signature: (e, t, r) => ({ argTypes: [e, t, oi(e) ? Ae : b], returnType: e }) }), Im = m({ name: "reverseBits", signature: A, normalImpl: "CPU implementation for reverseBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`reverseBits(${e})` });
2173
- function Em(e) {
2172
+ }, normalImpl: xm, codegenImpl: (e) => p`radians(${e})` }), $m = m({ name: "reflect", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: (e, t) => W(e, N(2 * ce(t, e), t)), codegenImpl: (e, t) => p`reflect(${e}, ${t})` }), Tm = m({ name: "refract", normalImpl: "CPU implementation for refract not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e, t, r) => p`refract(${e}, ${t}, ${r})`, signature: (e, t, r) => ({ argTypes: [e, t, oi(e) ? Ae : b], returnType: e }) }), _m = m({ name: "reverseBits", signature: A, normalImpl: "CPU implementation for reverseBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`reverseBits(${e})` });
2173
+ function Im(e) {
2174
2174
  if (typeof e == "number") return Math.round(e);
2175
2175
  throw new Mt("CPU implementation for round on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues");
2176
2176
  }
2177
- var Um = m({ name: "round", signature: A, normalImpl: Em, codegenImpl: (e) => p`round(${e})` });
2178
- function Mm(e) {
2177
+ var Em = m({ name: "round", signature: A, normalImpl: Im, codegenImpl: (e) => p`round(${e})` });
2178
+ function Um(e) {
2179
2179
  if (typeof e == "number") return Math.max(0, Math.min(1, e));
2180
2180
  throw new Mt("CPU implementation for saturate on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues");
2181
2181
  }
2182
- var Pm = m({ name: "saturate", signature: A, normalImpl: Mm, codegenImpl: (e) => p`saturate(${e})` });
2183
- function Sm(e) {
2182
+ var Mm = m({ name: "saturate", signature: A, normalImpl: Um, codegenImpl: (e) => p`saturate(${e})` });
2183
+ function Pm(e) {
2184
2184
  return typeof e == "number" ? Math.sign(e) : _.sign[e.kind](e);
2185
2185
  }
2186
- var vn = m({ name: "sign", signature: A, normalImpl: Sm, codegenImpl: (e) => p`sign(${e})` });
2187
- function zm(e) {
2186
+ var vn = m({ name: "sign", signature: A, normalImpl: Pm, codegenImpl: (e) => p`sign(${e})` });
2187
+ function Sm(e) {
2188
2188
  return typeof e == "number" ? Math.sin(e) : _.sin[e.kind](e);
2189
2189
  }
2190
- var Ut = m({ name: "sin", signature: A, normalImpl: zm, codegenImpl: (e) => p`sin(${e})` });
2191
- function km(e) {
2190
+ var Ut = m({ name: "sin", signature: A, normalImpl: Sm, codegenImpl: (e) => p`sin(${e})` });
2191
+ function zm(e) {
2192
2192
  if (typeof e == "number") return Math.sinh(e);
2193
2193
  throw new Mt("CPU implementation for sinh on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues");
2194
2194
  }
2195
- var Am = m({ name: "sinh", signature: A, normalImpl: km, codegenImpl: (e) => p`sinh(${e})` });
2196
- function Gm(e, t, r) {
2195
+ var km = m({ name: "sinh", signature: A, normalImpl: zm, codegenImpl: (e) => p`sinh(${e})` });
2196
+ function Am(e, t, r) {
2197
2197
  return typeof r == "number" ? Ht(e, t, r) : _.smoothstep[r.kind](e, t, r);
2198
2198
  }
2199
- var Om = m({ name: "smoothstep", signature: (...e) => ({ argTypes: e, returnType: e[2] }), normalImpl: Gm, codegenImpl: (e, t, r) => p`smoothstep(${e}, ${t}, ${r})` });
2200
- function Bm(e) {
2199
+ var Gm = m({ name: "smoothstep", signature: (...e) => ({ argTypes: e, returnType: e[2] }), normalImpl: Am, codegenImpl: (e, t, r) => p`smoothstep(${e}, ${t}, ${r})` });
2200
+ function Om(e) {
2201
2201
  return typeof e == "number" ? Math.sqrt(e) : _.sqrt[e.kind](e);
2202
2202
  }
2203
- var sr = m({ name: "sqrt", signature: A, normalImpl: Bm, codegenImpl: (e) => p`sqrt(${e})` });
2204
- function Cm(e, t) {
2203
+ var or = m({ name: "sqrt", signature: A, normalImpl: Om, codegenImpl: (e) => p`sqrt(${e})` });
2204
+ function Bm(e, t) {
2205
2205
  if (typeof e == "number") return e <= t ? 1 : 0;
2206
2206
  throw new Mt("CPU implementation for step on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues");
2207
2207
  }
2208
2208
  var Ca = m({ name: "step", signature: (...e) => {
2209
2209
  let t = be(e, [b, Ae, jt]) ?? e;
2210
2210
  return { argTypes: t, returnType: t[0] };
2211
- }, normalImpl: Cm, codegenImpl: (e, t) => p`step(${e}, ${t})` });
2212
- function Fm(e) {
2211
+ }, normalImpl: Bm, codegenImpl: (e, t) => p`step(${e}, ${t})` });
2212
+ function Cm(e) {
2213
2213
  if (typeof e == "number") return Math.tan(e);
2214
2214
  throw new Mt("CPU implementation for tan on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues");
2215
2215
  }
2216
- var Fa = m({ name: "tan", signature: A, normalImpl: Fm, codegenImpl: (e) => p`tan(${e})` });
2217
- function Nm(e) {
2216
+ var Fa = m({ name: "tan", signature: A, normalImpl: Cm, codegenImpl: (e) => p`tan(${e})` });
2217
+ function Fm(e) {
2218
2218
  return typeof e == "number" ? Math.tanh(e) : _.tanh[e.kind](e);
2219
2219
  }
2220
- var Lm = m({ name: "tanh", signature: A, normalImpl: Nm, codegenImpl: (e) => p`tanh(${e})` }), Rm = m({ name: "transpose", signature: A, normalImpl: "CPU implementation for transpose not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`transpose(${e})` }), Wm = m({ name: "trunc", signature: A, normalImpl: "CPU implementation for trunc not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`trunc(${e})` }), Io = m({ name: "bitcastU32toF32", normalImpl: ((e) => typeof e == "number" ? rt(e) : _.bitcastU32toF32[e.kind](e)), codegenImpl: (e) => p`bitcast<f32>(${e})`, signature: (...e) => {
2220
+ var Nm = m({ name: "tanh", signature: A, normalImpl: Fm, codegenImpl: (e) => p`tanh(${e})` }), Lm = m({ name: "transpose", signature: A, normalImpl: "CPU implementation for transpose not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`transpose(${e})` }), Rm = m({ name: "trunc", signature: A, normalImpl: "CPU implementation for trunc not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues", codegenImpl: (e) => p`trunc(${e})` }), Io = m({ name: "bitcastU32toF32", normalImpl: ((e) => typeof e == "number" ? rt(e) : _.bitcastU32toF32[e.kind](e)), codegenImpl: (e) => p`bitcast<f32>(${e})`, signature: (...e) => {
2221
2221
  let t = be(e, [y]) ?? e;
2222
- return { argTypes: t, returnType: nr(t[0]) ? t[0].type === "vec2u" ? I : t[0].type === "vec3u" ? T : C : b };
2222
+ return { argTypes: t, returnType: ar(t[0]) ? t[0].type === "vec2u" ? I : t[0].type === "vec3u" ? T : C : b };
2223
2223
  } }), Eo = m({ name: "bitcastU32toI32", normalImpl: ((e) => typeof e == "number" ? nt(e) : _.bitcastU32toI32[e.kind](e)), codegenImpl: (e) => p`bitcast<i32>(${e})`, signature: (...e) => {
2224
2224
  let t = be(e, [y]) ?? e;
2225
- return { argTypes: t, returnType: nr(t[0]) ? t[0].type === "vec2u" ? pe : t[0].type === "vec3u" ? Fe : Se : Ue };
2225
+ return { argTypes: t, returnType: ar(t[0]) ? t[0].type === "vec2u" ? pe : t[0].type === "vec3u" ? Fe : Se : Ue };
2226
2226
  } }), Uo = m({ name: "unpack2x16float", normalImpl: (e) => {
2227
2227
  let t = new ArrayBuffer(4);
2228
- new ur(t).writeUint32(e);
2228
+ new lr(t).writeUint32(e);
2229
2229
  let r = new Lt(t);
2230
2230
  return I(r.readFloat16(), r.readFloat16());
2231
- }, signature: { argTypes: [y], returnType: I }, codegenImpl: (e) => p`unpack2x16float(${e})` }), jm = m({ name: "pack2x16float", normalImpl: (e) => {
2232
- let t = new ArrayBuffer(4), r = new ur(t);
2231
+ }, signature: { argTypes: [y], returnType: I }, codegenImpl: (e) => p`unpack2x16float(${e})` }), Wm = m({ name: "pack2x16float", normalImpl: (e) => {
2232
+ let t = new ArrayBuffer(4), r = new lr(t);
2233
2233
  r.writeFloat16(e.x), r.writeFloat16(e.y);
2234
2234
  let n = new Lt(t);
2235
2235
  return y(n.readUint32());
2236
- }, signature: { argTypes: [I], returnType: y }, codegenImpl: (e) => p`pack2x16float(${e})` }), Dm = m({ name: "unpack4x8unorm", normalImpl: (e) => {
2236
+ }, signature: { argTypes: [I], returnType: y }, codegenImpl: (e) => p`pack2x16float(${e})` }), jm = m({ name: "unpack4x8unorm", normalImpl: (e) => {
2237
2237
  let t = new ArrayBuffer(4);
2238
- new ur(t).writeUint32(e);
2238
+ new lr(t).writeUint32(e);
2239
2239
  let r = new Lt(t);
2240
2240
  return C(r.readUint8() / 255, r.readUint8() / 255, r.readUint8() / 255, r.readUint8() / 255);
2241
- }, signature: { argTypes: [y], returnType: C }, codegenImpl: (e) => p`unpack4x8unorm(${e})` }), Ym = m({ name: "pack4x8unorm", normalImpl: (e) => {
2242
- let t = new ArrayBuffer(4), r = new ur(t);
2241
+ }, signature: { argTypes: [y], returnType: C }, codegenImpl: (e) => p`unpack4x8unorm(${e})` }), Dm = m({ name: "pack4x8unorm", normalImpl: (e) => {
2242
+ let t = new ArrayBuffer(4), r = new lr(t);
2243
2243
  r.writeUint8(e.x * 255), r.writeUint8(e.y * 255), r.writeUint8(e.z * 255), r.writeUint8(e.w * 255);
2244
2244
  let n = new Lt(t);
2245
2245
  return y(n.readUint32());
@@ -2247,51 +2247,51 @@ var Lm = m({ name: "tanh", signature: A, normalImpl: Nm, codegenImpl: (e) => p`t
2247
2247
  function Qr(e) {
2248
2248
  return e.type.includes("2") ? qr : e.type.includes("3") ? Yr : Dr;
2249
2249
  }
2250
- var Mo = m({ name: "allEq", signature: (...e) => ({ argTypes: e, returnType: le }), normalImpl: (e, t) => wi(Pn(e, t)), codegenImpl: (e, t) => p`all(${e} == ${t})` }), Pn = (e, t) => _.eq[e.kind](e, t), qm = m({ name: "eq", signature: (...e) => ({ argTypes: e, returnType: Qr(e[0]) }), normalImpl: Pn, codegenImpl: (e, t) => p`(${e} == ${t})` }), Vm = m({ name: "ne", signature: (...e) => ({ argTypes: e, returnType: Qr(e[0]) }), normalImpl: (e, t) => bt(Pn(e, t)), codegenImpl: (e, t) => p`(${e} != ${t})` }), $a = (e, t) => _.lt[e.kind](e, t), Jm = m({ name: "lt", signature: (...e) => ({ argTypes: e, returnType: Qr(e[0]) }), normalImpl: $a, codegenImpl: (e, t) => p`(${e} < ${t})` }), Xm = m({ name: "le", signature: (...e) => ({ argTypes: e, returnType: Qr(e[0]) }), normalImpl: (e, t) => vi($a(e, t), Pn(e, t)), codegenImpl: (e, t) => p`(${e} <= ${t})` }), Zm = m({ name: "gt", signature: (...e) => ({ argTypes: e, returnType: Qr(e[0]) }), normalImpl: (e, t) => Po(bt($a(e, t)), bt(Pn(e, t))), codegenImpl: (e, t) => p`(${e} > ${t})` }), Qm = m({ name: "ge", signature: (...e) => ({ argTypes: e, returnType: Qr(e[0]) }), normalImpl: (e, t) => bt($a(e, t)), codegenImpl: (e, t) => p`(${e} >= ${t})` }), bt = (e) => _.neg[e.kind](e), Km = m({ name: "not", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: bt, codegenImpl: (e) => p`!(${e})` }), vi = (e, t) => _.or[e.kind](e, t), Hm = m({ name: "or", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: vi, codegenImpl: (e, t) => p`(${e} | ${t})` }), Po = (e, t) => bt(vi(bt(e), bt(t))), eh = m({ name: "and", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: Po, codegenImpl: (e, t) => p`(${e} & ${t})` }), wi = (e) => _.all[e.kind](e), th = m({ name: "all", signature: (...e) => ({ argTypes: e, returnType: le }), normalImpl: wi, codegenImpl: (e) => p`all(${e})` }), rh = m({ name: "any", signature: (...e) => ({ argTypes: e, returnType: le }), normalImpl: (e) => !wi(bt(e)), codegenImpl: (e) => p`any(${e})` }), nh = m({ name: "isCloseTo", signature: (...e) => ({ argTypes: e, returnType: le }), normalImpl: (e, t, r = 0.01) => typeof e == "number" && typeof t == "number" ? Math.abs(e - t) < r : ye(e) && ye(t) ? _.isCloseToZero[e.kind](W[c].jsImpl(e, t), r) : !1, codegenImpl: (e, t, r = g(0.01, b, "constant")) => An(e) && An(t) ? p`(abs(f32(${e}) - f32(${t})) <= ${r})` : !An(e) && !An(t) ? p`all(abs(${e} - ${t}) <= (${e} - ${e}) + ${r})` : "false" });
2251
- function ah(e, t, r) {
2250
+ var Mo = m({ name: "allEq", signature: (...e) => ({ argTypes: e, returnType: le }), normalImpl: (e, t) => wi(Pn(e, t)), codegenImpl: (e, t) => p`all(${e} == ${t})` }), Pn = (e, t) => _.eq[e.kind](e, t), Ym = m({ name: "eq", signature: (...e) => ({ argTypes: e, returnType: Qr(e[0]) }), normalImpl: Pn, codegenImpl: (e, t) => p`(${e} == ${t})` }), qm = m({ name: "ne", signature: (...e) => ({ argTypes: e, returnType: Qr(e[0]) }), normalImpl: (e, t) => bt(Pn(e, t)), codegenImpl: (e, t) => p`(${e} != ${t})` }), $a = (e, t) => _.lt[e.kind](e, t), Vm = m({ name: "lt", signature: (...e) => ({ argTypes: e, returnType: Qr(e[0]) }), normalImpl: $a, codegenImpl: (e, t) => p`(${e} < ${t})` }), Jm = m({ name: "le", signature: (...e) => ({ argTypes: e, returnType: Qr(e[0]) }), normalImpl: (e, t) => vi($a(e, t), Pn(e, t)), codegenImpl: (e, t) => p`(${e} <= ${t})` }), Xm = m({ name: "gt", signature: (...e) => ({ argTypes: e, returnType: Qr(e[0]) }), normalImpl: (e, t) => Po(bt($a(e, t)), bt(Pn(e, t))), codegenImpl: (e, t) => p`(${e} > ${t})` }), Zm = m({ name: "ge", signature: (...e) => ({ argTypes: e, returnType: Qr(e[0]) }), normalImpl: (e, t) => bt($a(e, t)), codegenImpl: (e, t) => p`(${e} >= ${t})` }), bt = (e) => _.neg[e.kind](e), Qm = m({ name: "not", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: bt, codegenImpl: (e) => p`!(${e})` }), vi = (e, t) => _.or[e.kind](e, t), Km = m({ name: "or", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: vi, codegenImpl: (e, t) => p`(${e} | ${t})` }), Po = (e, t) => bt(vi(bt(e), bt(t))), Hm = m({ name: "and", signature: (...e) => ({ argTypes: e, returnType: e[0] }), normalImpl: Po, codegenImpl: (e, t) => p`(${e} & ${t})` }), wi = (e) => _.all[e.kind](e), eh = m({ name: "all", signature: (...e) => ({ argTypes: e, returnType: le }), normalImpl: wi, codegenImpl: (e) => p`all(${e})` }), th = m({ name: "any", signature: (...e) => ({ argTypes: e, returnType: le }), normalImpl: (e) => !wi(bt(e)), codegenImpl: (e) => p`any(${e})` }), rh = m({ name: "isCloseTo", signature: (...e) => ({ argTypes: e, returnType: le }), normalImpl: (e, t, r = 0.01) => typeof e == "number" && typeof t == "number" ? Math.abs(e - t) < r : ye(e) && ye(t) ? _.isCloseToZero[e.kind](W[c].jsImpl(e, t), r) : !1, codegenImpl: (e, t, r = g(0.01, b, "constant")) => An(e) && An(t) ? p`(abs(f32(${e}) - f32(${t})) <= ${r})` : !An(e) && !An(t) ? p`all(abs(${e} - ${t}) <= (${e} - ${e}) + ${r})` : "false" });
2251
+ function nh(e, t, r) {
2252
2252
  return typeof r == "boolean" ? r ? t : e : _.select[e.kind](e, t, r);
2253
2253
  }
2254
2254
  var pt = m({ name: "select", signature: (e, t, r) => {
2255
2255
  let [n, a] = be([e, t]) ?? [e, t];
2256
2256
  return { argTypes: [n, a, r], returnType: n };
2257
- }, normalImpl: ah, codegenImpl: (e, t, r) => p`select(${e}, ${t}, ${r})` }), ih = { channelType: b, vectorType: C, sampleTypes: ["depth", "unfilterable-float"], texelSize: "non-copyable" }, sh = { channelType: b, vectorType: C, sampleTypes: ["depth", "unfilterable-float"], texelSize: 2 }, oh = { channelType: b, vectorType: C, sampleTypes: ["depth", "unfilterable-float"], texelSize: 4 }, uh = { channelType: y, vectorType: Oe, sampleTypes: ["uint"], texelSize: 1 }, Ki = /* @__PURE__ */ new Map();
2257
+ }, normalImpl: nh, codegenImpl: (e, t, r) => p`select(${e}, ${t}, ${r})` }), ah = { channelType: b, vectorType: C, sampleTypes: ["depth", "unfilterable-float"], texelSize: "non-copyable" }, ih = { channelType: b, vectorType: C, sampleTypes: ["depth", "unfilterable-float"], texelSize: 2 }, sh = { channelType: b, vectorType: C, sampleTypes: ["depth", "unfilterable-float"], texelSize: 4 }, oh = { channelType: y, vectorType: Oe, sampleTypes: ["uint"], texelSize: 1 }, Ki = /* @__PURE__ */ new Map();
2258
2258
  function Sn(e) {
2259
2259
  let t = Ki.get(e);
2260
- return t === void 0 && (t = lh(e), Ki.set(e, t)), t;
2260
+ return t === void 0 && (t = uh(e), Ki.set(e, t)), t;
2261
+ }
2262
+ function uh(e) {
2263
+ let t = ph(e), r = lh(e), n = e.includes("stencil");
2264
+ return { channelType: t, vectorType: t === y ? Oe : t === Ue ? Se : C, texelSize: dh(e), sampleTypes: mh(e), canRenderAttachment: ch(e), ...r && { depthAspect: r }, ...n && { stencilAspect: oh } };
2261
2265
  }
2262
2266
  function lh(e) {
2263
- let t = dh(e), r = ch(e), n = e.includes("stencil");
2264
- return { channelType: t, vectorType: t === y ? Oe : t === Ue ? Se : C, texelSize: mh(e), sampleTypes: hh(e), canRenderAttachment: ph(e), ...r && { depthAspect: r }, ...n && { stencilAspect: uh } };
2267
+ if (e === "depth16unorm") return ih;
2268
+ if (e === "depth32float" || e === "depth32float-stencil8") return sh;
2269
+ if (e === "depth24plus" || e === "depth24plus-stencil8") return ah;
2265
2270
  }
2266
2271
  function ch(e) {
2267
- if (e === "depth16unorm") return sh;
2268
- if (e === "depth32float" || e === "depth32float-stencil8") return oh;
2269
- if (e === "depth24plus" || e === "depth24plus-stencil8") return ih;
2270
- }
2271
- function ph(e) {
2272
2272
  return !(e.startsWith("bc") || e.startsWith("etc2") || e.startsWith("eac") || e.startsWith("astc") || e === "rgb9e5ufloat");
2273
2273
  }
2274
- function dh(e) {
2274
+ function ph(e) {
2275
2275
  return e === "stencil8" ? y : e.includes("uint") ? y : e.includes("sint") ? Ue : b;
2276
2276
  }
2277
- function mh(e) {
2277
+ function dh(e) {
2278
2278
  let [, t, r] = e.match(/^(rgba|bgra|rg|r)(8|16|32)/) ?? [];
2279
2279
  return t && r ? t.length * Number(r) / 8 : e === "stencil8" ? 1 : e === "depth16unorm" ? 2 : e === "depth32float" ? 4 : e === "depth32float-stencil8" ? 5 : e === "depth24plus" || e === "depth24plus-stencil8" ? "non-copyable" : /^(bc[14]-|etc2-rgb8|eac-r11)/.test(e) ? 8 : /^(bc|astc-|etc2-rgba|eac-rg)/.test(e) ? 16 : 4;
2280
2280
  }
2281
- function hh(e) {
2281
+ function mh(e) {
2282
2282
  return e === "stencil8" ? ["uint"] : e.includes("uint") ? ["uint"] : e.includes("sint") ? ["sint"] : e.includes("depth") ? ["depth", "unfilterable-float"] : /^(r|rg|rgba)16(u|s)norm$/.test(e) ? ["unfilterable-float"] : ["float", "unfilterable-float"];
2283
2283
  }
2284
- var fh = /* @__PURE__ */ new Set(["r32float", "rg32float", "rgba32float"]);
2285
- function yh(e, t) {
2286
- return fh.has(t) && !e.features.has("float32-filterable") ? ["unfilterable-float"] : Sn(t).sampleTypes;
2284
+ var hh = /* @__PURE__ */ new Set(["r32float", "rg32float", "rgba32float"]);
2285
+ function fh(e, t) {
2286
+ return hh.has(t) && !e.features.has("float32-filterable") ? ["unfilterable-float"] : Sn(t).sampleTypes;
2287
2287
  }
2288
- var xi = ["f16", "clip_distances", "dual_source_blending", "subgroups", "primitive_index"], So = { f16: "shader-f16", clip_distances: "clip-distances", dual_source_blending: "dual-source-blending", subgroups: "subgroups", primitive_index: "primitive-index" }, gh = { block: 0, binaryExpr: 1, assignmentExpr: 2, logicalExpr: 3, unaryExpr: 4, numericLiteral: 5, call: 6, memberAccess: 7, indexAccess: 8, return: 10, if: 11, let: 12, const: 13, for: 14, while: 15, continue: 16, break: 17, arrayExpr: 100, preUpdate: 101, postUpdate: 102, stringLiteral: 103, objectExpr: 104 }, Na = { identifier: "i", destructuredObject: "d" };
2289
- const vh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2288
+ var xi = ["f16", "clip_distances", "dual_source_blending", "subgroups", "primitive_index"], So = { f16: "shader-f16", clip_distances: "clip-distances", dual_source_blending: "dual-source-blending", subgroups: "subgroups", primitive_index: "primitive-index" }, yh = { block: 0, binaryExpr: 1, assignmentExpr: 2, logicalExpr: 3, unaryExpr: 4, numericLiteral: 5, call: 6, memberAccess: 7, indexAccess: 8, return: 10, if: 11, let: 12, const: 13, for: 14, while: 15, continue: 16, break: 17, arrayExpr: 100, preUpdate: 101, postUpdate: 102, stringLiteral: 103, objectExpr: 104 }, Na = { identifier: "i", destructuredObject: "d" };
2289
+ const gh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2290
2290
  __proto__: null,
2291
2291
  FuncParameterType: Na,
2292
- NodeTypeCatalog: gh
2292
+ NodeTypeCatalog: yh
2293
2293
  }, Symbol.toStringTag, { value: "Module" }));
2294
- function wh(e) {
2294
+ function vh(e) {
2295
2295
  return e?.[j];
2296
2296
  }
2297
2297
  var Ve = { get(e, t) {
@@ -2304,14 +2304,14 @@ var Ve = { get(e, t) {
2304
2304
  function Ta(e) {
2305
2305
  let t = e;
2306
2306
  for (; ; ) {
2307
- let r = wh(t);
2307
+ let r = vh(t);
2308
2308
  if (!r) break;
2309
2309
  t = r;
2310
2310
  }
2311
2311
  return t;
2312
2312
  }
2313
2313
  function La(e, t) {
2314
- return new xh(e, t);
2314
+ return new wh(e, t);
2315
2315
  }
2316
2316
  function zo(e) {
2317
2317
  let t = Reflect.ownKeys(e);
@@ -2321,7 +2321,7 @@ function zo(e) {
2321
2321
  }
2322
2322
  return Object.freeze(e);
2323
2323
  }
2324
- var xh = class {
2324
+ var wh = class {
2325
2325
  constructor(t, r) {
2326
2326
  this.dataType = t, this.#e = r && typeof r == "object" ? zo(r) : r;
2327
2327
  }
@@ -2350,10 +2350,10 @@ var xh = class {
2350
2350
  return this.$;
2351
2351
  }
2352
2352
  };
2353
- function bh(e) {
2354
- return new $h(e);
2353
+ function xh(e) {
2354
+ return new bh(e);
2355
2355
  }
2356
- var $h = class {
2356
+ var bh = class {
2357
2357
  constructor(t) {
2358
2358
  this.declaration = t;
2359
2359
  }
@@ -2374,9 +2374,9 @@ var $h = class {
2374
2374
  };
2375
2375
  function ko(e) {
2376
2376
  let t = { argTypes: e.in && Object.keys(e.in).length !== 0 ? [Mn(e.in)] : [], returnType: de, workgroupSize: [e.workgroupSize[0] ?? 1, e.workgroupSize[1] ?? 1, e.workgroupSize[2] ?? 1], isEntry: !0 };
2377
- return Object.assign((r, ...n) => Th(t, e.workgroupSize, wa(r, ...n)), t);
2377
+ return Object.assign((r, ...n) => $h(t, e.workgroupSize, wa(r, ...n)), t);
2378
2378
  }
2379
- function Th(e, t, r) {
2379
+ function $h(e, t, r) {
2380
2380
  let n = Un(r, `@compute @workgroup_size(${t.join(", ")}) `), a = e.argTypes[0];
2381
2381
  return { shell: e, $uses(i) {
2382
2382
  return n.applyExternals(i), this;
@@ -2390,15 +2390,15 @@ function Th(e, t, r) {
2390
2390
  }
2391
2391
  function R(e, t) {
2392
2392
  let r = { [c]: !0, argTypes: e, returnType: t ?? de, isEntry: !1 };
2393
- return Object.assign((n, ...a) => Ih(r, wa(n, ...a)), r);
2393
+ return Object.assign((n, ...a) => _h(r, wa(n, ...a)), r);
2394
2394
  }
2395
2395
  function Ao(e) {
2396
2396
  return ui(e) && e?.resourceType === "function";
2397
2397
  }
2398
- function _h([e, t]) {
2398
+ function Th([e, t]) {
2399
2399
  return `${x(e) ?? "<unnamed>"}=${t}`;
2400
2400
  }
2401
- function Ih(e, t) {
2401
+ function _h(e, t) {
2402
2402
  let r = Un(t, ""), n = { shell: e, resourceType: "function", $uses(s) {
2403
2403
  return r.applyExternals(s), this;
2404
2404
  }, [Ie]: r, $name(s) {
@@ -2406,12 +2406,12 @@ function Ih(e, t) {
2406
2406
  }, with(s, o) {
2407
2407
  return Go(i, [[pa(s) ? s.slot : s, o]]);
2408
2408
  }, [U](s) {
2409
- return typeof t == "string" && (Jc(t, e.argTypes, r.applyExternals), oo(t, e.returnType, r.applyExternals)), r.resolve(s, e.argTypes, e.returnType);
2410
- } }, a = m({ name: "tgpuFnCall", noComptime: !0, signature: { argTypes: e.argTypes, returnType: e.returnType }, normalImpl: (...s) => Rl(() => {
2409
+ return typeof t == "string" && (Vc(t, e.argTypes, r.applyExternals), oo(t, e.returnType, r.applyExternals)), r.resolve(s, e.argTypes, e.returnType);
2410
+ } }, a = m({ name: "tgpuFnCall", noComptime: !0, signature: { argTypes: e.argTypes, returnType: e.returnType }, normalImpl: (...s) => Ll(() => {
2411
2411
  try {
2412
2412
  if (typeof t == "string") throw new Error("Cannot execute on the CPU functions constructed with raw WGSL");
2413
- let o = s.map((l, d) => ar(e.argTypes[d], l)), u = t(...o);
2414
- return ar(e.returnType, u);
2413
+ let o = s.map((l, d) => ir(e.argTypes[d], l)), u = t(...o);
2414
+ return ir(e.returnType, u);
2415
2415
  } catch (o) {
2416
2416
  throw o instanceof Ai ? o.appendToTrace(i) : new Ai(o, [i]);
2417
2417
  }
@@ -2435,13 +2435,13 @@ function Go(e, t) {
2435
2435
  return s.withResetIndentLevel(() => p`${s.resolve(a).value}(${i})`);
2436
2436
  } }), a = Object.assign(n, r);
2437
2437
  return a[c].implementation = e[c].implementation, Object.defineProperty(a, "toString", { value() {
2438
- return `fn:${x(e) ?? "<unnamed>"}[${t.map(_h).join(", ")}]`;
2438
+ return `fn:${x(e) ?? "<unnamed>"}[${t.map(Th).join(", ")}]`;
2439
2439
  } }), a;
2440
2440
  }
2441
- function Eh(e, t, r = "runtime") {
2442
- return new Uh(e, t, r);
2441
+ function Ih(e, t, r = "runtime") {
2442
+ return new Eh(e, t, r);
2443
2443
  }
2444
- var Uh = class {
2444
+ var Eh = class {
2445
2445
  [c];
2446
2446
  dataType;
2447
2447
  origin;
@@ -2476,11 +2476,11 @@ var Uh = class {
2476
2476
  return this.$;
2477
2477
  }
2478
2478
  };
2479
- function Mh(e) {
2479
+ function Uh(e) {
2480
2480
  let t = { in: e.in, out: e.out, returnType: Mn(e.out), isEntry: !0 };
2481
- return Object.assign((r, ...n) => Ph(t, wa(r, ...n)), t);
2481
+ return Object.assign((r, ...n) => Mh(t, wa(r, ...n)), t);
2482
2482
  }
2483
- function Ph(e, t) {
2483
+ function Mh(e, t) {
2484
2484
  let r = Un(t, "@fragment "), n = e.returnType;
2485
2485
  return typeof t == "string" && oo(t, n, (a) => r.applyExternals(a)), { shell: e, outputType: n, $uses(a) {
2486
2486
  return r.applyExternals(a), this;
@@ -2494,7 +2494,7 @@ function Ph(e, t) {
2494
2494
  } };
2495
2495
  }
2496
2496
  var Oo = /* @__PURE__ */ new Set(["alias", "break", "case", "const", "const_assert", "continue", "continuing", "default", "diagnostic", "discard", "else", "enable", "false", "fn", "for", "if", "let", "loop", "override", "requires", "return", "struct", "switch", "true", "var", "while", "NULL", "Self", "abstract", "active", "alignas", "alignof", "as", "asm", "asm_fragment", "async", "attribute", "auto", "await", "become", "cast", "catch", "class", "co_await", "co_return", "co_yield", "coherent", "column_major", "common", "compile", "compile_fragment", "concept", "const_cast", "consteval", "constexpr", "constinit", "crate", "debugger", "decltype", "delete", "demote", "demote_to_helper", "do", "dynamic_cast", "enum", "explicit", "export", "extends", "extern", "external", "fallthrough", "filter", "final", "finally", "friend", "from", "fxgroup", "get", "goto", "groupshared", "highp", "impl", "implements", "import", "inline", "instanceof", "interface", "layout", "lowp", "macro", "macro_rules", "match", "mediump", "meta", "mod", "module", "move", "mut", "mutable", "namespace", "new", "nil", "noexcept", "noinline", "nointerpolation", "non_coherent", "noncoherent", "noperspective", "null", "nullptr", "of", "operator", "package", "packoffset", "partition", "pass", "patch", "pixelfragment", "precise", "precision", "premerge", "priv", "protected", "pub", "public", "readonly", "ref", "regardless", "register", "reinterpret_cast", "require", "resource", "restrict", "self", "set", "shared", "sizeof", "smooth", "snorm", "static", "static_assert", "static_cast", "std", "subroutine", "super", "target", "template", "this", "thread_local", "throw", "trait", "try", "type", "typedef", "typeid", "typename", "typeof", "union", "unless", "unorm", "unsafe", "unsized", "use", "using", "varying", "virtual", "volatile", "wgsl", "where", "with", "writeonly", "yield", "sampler"]);
2497
- function Sh(e) {
2497
+ function Ph(e) {
2498
2498
  return e ? e.replaceAll(/\s/g, "_").replaceAll(/[^\w\d]/g, "") : "item";
2499
2499
  }
2500
2500
  function Bo(e) {
@@ -2512,7 +2512,7 @@ var Co = class {
2512
2512
  return this.#t[this.#t.length - 1];
2513
2513
  }
2514
2514
  makeUnique(t, r) {
2515
- let n = Sh(t), a = this.getUniqueVariant(n);
2515
+ let n = Ph(t), a = this.getUniqueVariant(n);
2516
2516
  return r ? this.#e.add(a) : this.usedFunctionScopeNames?.add(a), a;
2517
2517
  }
2518
2518
  makeValid(t) {
@@ -2527,21 +2527,21 @@ var Co = class {
2527
2527
  popFunctionScope() {
2528
2528
  this.#t.pop();
2529
2529
  }
2530
- }, zh = class extends Co {
2530
+ }, Sh = class extends Co {
2531
2531
  #e = 0;
2532
2532
  getUniqueVariant(t) {
2533
2533
  let r = `${t}_${this.#e++}`;
2534
2534
  for (; this.isUsed(r); ) r = `${t}_${this.#e++}`;
2535
2535
  return r;
2536
2536
  }
2537
- }, kh = class extends Co {
2537
+ }, zh = class extends Co {
2538
2538
  getUniqueVariant(t) {
2539
2539
  let r = 0, n = t;
2540
2540
  for (; this.isUsed(n); ) r++, n = `${t}_${r}`;
2541
2541
  return n;
2542
2542
  }
2543
2543
  };
2544
- function Ah(e, t) {
2544
+ function kh(e, t) {
2545
2545
  let r = Un(t, "");
2546
2546
  return { [c]: !0, [Ie]: r, resourceType: "shellless-impl", argTypes: e, [U](n) {
2547
2547
  return r.resolve(n, e, void 0);
@@ -2552,19 +2552,19 @@ function Ah(e, t) {
2552
2552
  function Ra(e, t) {
2553
2553
  return e.type !== t.type ? !1 : e.type === "ptr" && t.type === "ptr" ? e.access === t.access && e.addressSpace === t.addressSpace && e.implicit === t.implicit && Ra(e.inner, t.inner) : e.type === "array" && t.type === "array" ? e.elementCount === t.elementCount && Ra(e.elementType, t.elementType) : e.type === "struct" && t.type === "struct" ? e === t : !0;
2554
2554
  }
2555
- var Gh = class {
2555
+ var Ah = class {
2556
2556
  cache = /* @__PURE__ */ new Map();
2557
2557
  get(t, r) {
2558
2558
  let n = Gs(t);
2559
2559
  if (!n?.ast) return;
2560
2560
  if (!r && n.ast.params.length > 0) throw new Error(`Cannot resolve '${x(t)}' directly, because it expects arguments. Either call it from another function, or wrap it in a shell`);
2561
2561
  let a = (r ?? []).map((o, u) => {
2562
- if (o.value instanceof Pr) {
2562
+ if (o.value instanceof Sr) {
2563
2563
  if (o.dataType.type === "unknown") throw new V("d.ref() created with primitive types must be stored in a variable before use");
2564
2564
  return o.dataType;
2565
2565
  }
2566
2566
  if (o.dataType.type === "unknown") throw new Error(`Passed illegal value ${o.value} as the #${u} argument to ${n.name}(...)`);
2567
- let l = er(o.dataType);
2567
+ let l = tr(o.dataType);
2568
2568
  if (o.origin === "constant-tgpu-const-ref" || o.origin === "runtime-tgpu-const-ref") {
2569
2569
  let d = ct();
2570
2570
  throw new Error(`Cannot pass constant references as function arguments. Explicitly copy them by wrapping them in a schema: '${d.resolve(l).value}(...)'`);
@@ -2575,13 +2575,13 @@ var Gh = class {
2575
2575
  let o = i.find((u) => u.argTypes.length === a.length && u.argTypes.every((l, d) => Ra(l, a[d])));
2576
2576
  if (o) return o;
2577
2577
  } else i = [], this.cache.set(t, i);
2578
- let s = Ah(a, t);
2578
+ let s = kh(a, t);
2579
2579
  return i.push(s), s;
2580
2580
  }
2581
- }, Oh = class {
2581
+ }, Gh = class {
2582
2582
  [c];
2583
2583
  constructor(t) {
2584
- this[c] = { nameRegistry: t, shelllessRepo: new Gh(), memoizedResolves: /* @__PURE__ */ new WeakMap(), memoizedDerived: /* @__PURE__ */ new WeakMap(), listeners: { name: /* @__PURE__ */ new Set() } };
2584
+ this[c] = { nameRegistry: t, shelllessRepo: new Ah(), memoizedResolves: /* @__PURE__ */ new WeakMap(), memoizedDerived: /* @__PURE__ */ new WeakMap(), listeners: { name: /* @__PURE__ */ new Set() } };
2585
2585
  }
2586
2586
  on(t, r) {
2587
2587
  if (t === "name") {
@@ -2591,19 +2591,19 @@ var Gh = class {
2591
2591
  throw new Error(`Unsupported event: ${t}`);
2592
2592
  }
2593
2593
  };
2594
- function Bh(e, t) {
2594
+ function Oh(e, t) {
2595
2595
  let r = e.nameRegistry.makeUnique(x(t), !0);
2596
2596
  for (let n of e.listeners.name) n({ target: t, name: r });
2597
2597
  return r;
2598
2598
  }
2599
2599
  function Kr(e) {
2600
2600
  let { names: t = "strict" } = e ?? {};
2601
- return new Oh(t === "strict" ? new kh() : new zh());
2601
+ return new Gh(t === "strict" ? new zh() : new Sh());
2602
2602
  }
2603
2603
  function _a(e) {
2604
2604
  return typeof e?.format == "string";
2605
2605
  }
2606
- function Ch(e, t) {
2606
+ function Bh(e, t) {
2607
2607
  let r = [];
2608
2608
  if (Jr(e)) {
2609
2609
  if (!_a(t)) throw new Error("Shader expected a single attribute, not a record of attributes to be passed in.");
@@ -2619,47 +2619,47 @@ function Ch(e, t) {
2619
2619
  }
2620
2620
  return { usedVertexLayouts: r, bufferDefinitions: n };
2621
2621
  }
2622
- var Fh = ["bool", "f32", "f16", "i32", "u32", "vec2f", "vec3f", "vec4f", "vec2h", "vec3h", "vec4h", "vec2i", "vec3i", "vec4i", "vec2u", "vec3u", "vec4u", "vec2<bool>", "vec3<bool>", "vec4<bool>", "mat2x2f", "mat3x3f", "mat4x4f", "texture_external"];
2623
- function Nh(e) {
2624
- return Fh.includes(e.type);
2622
+ var Ch = ["bool", "f32", "f16", "i32", "u32", "vec2f", "vec3f", "vec4f", "vec2h", "vec3h", "vec4h", "vec2i", "vec3i", "vec4i", "vec2u", "vec3u", "vec4u", "vec2<bool>", "vec3<bool>", "vec4<bool>", "mat2x2f", "mat3x3f", "mat4x4f", "texture_external"];
2623
+ function Fh(e) {
2624
+ return Ch.includes(e.type);
2625
2625
  }
2626
2626
  function Wa(e, [t, r]) {
2627
2627
  if (!Bo(t)) throw new Error(`Property key '${t}' is a reserved WGSL word. Choose a different name.`);
2628
2628
  return ` ${hi(r)}${t}: ${e.resolve(r).value},
2629
2629
  `;
2630
2630
  }
2631
- function Lh(e, t) {
2631
+ function Nh(e, t) {
2632
2632
  if (t[c].isAbstruct) throw new Error("Cannot resolve abstract struct types to WGSL.");
2633
2633
  let r = e.getUniqueName(t);
2634
2634
  return e.addDeclaration(`struct ${r} {
2635
2635
  ${Object.entries(t.propTypes).map((n) => Wa(e, n)).join("")}}`), r;
2636
2636
  }
2637
- function Rh(e, t) {
2637
+ function Lh(e, t) {
2638
2638
  let r = e.getUniqueName(t);
2639
2639
  return e.addDeclaration(`struct ${r} {
2640
2640
  ${Object.entries(t.propTypes).map((n) => _a(n[1]) ? Wa(e, [n[0], Wr[n[1].format]]) : Wa(e, n)).join("")}
2641
2641
  }`), r;
2642
2642
  }
2643
- function Wh(e, t) {
2643
+ function Rh(e, t) {
2644
2644
  let r = e.resolve(t.elementType).value;
2645
2645
  return t.elementCount === 0 ? `array<${r}>` : `array<${r}, ${t.elementCount}>`;
2646
2646
  }
2647
- function jh(e, t) {
2647
+ function Wh(e, t) {
2648
2648
  let r = e.resolve(_a(t.elementType) ? Wr[t.elementType.format] : t.elementType).value;
2649
2649
  return t.elementCount === 0 ? `array<${r}>` : `array<${r}, ${t.elementCount}>`;
2650
2650
  }
2651
2651
  function Fo(e, t) {
2652
- if (_n(t)) return t.type === "unstruct" ? Rh(e, t) : t.type === "disarray" ? jh(e, t) : t.type === "loose-decorated" ? e.resolve(_a(t.inner) ? Wr[t.inner.format] : t.inner).value : e.resolve(Wr[t.type]).value;
2653
- if (Nh(t)) return t.type;
2654
- if (t.type === "struct") return Lh(e, t);
2655
- if (t.type === "array") return Wh(e, t);
2652
+ if (_n(t)) return t.type === "unstruct" ? Lh(e, t) : t.type === "disarray" ? Wh(e, t) : t.type === "loose-decorated" ? e.resolve(_a(t.inner) ? Wr[t.inner.format] : t.inner).value : e.resolve(Wr[t.type]).value;
2653
+ if (Fh(t)) return t.type;
2654
+ if (t.type === "struct") return Nh(e, t);
2655
+ if (t.type === "array") return Rh(e, t);
2656
2656
  if (t.type === "atomic") return `atomic<${Fo(e, t.inner)}>`;
2657
2657
  if (t.type === "decorated") return e.resolve(t.inner).value;
2658
2658
  if (t.type === "ptr") return t.addressSpace === "storage" ? `ptr<storage, ${e.resolve(t.inner).value}, ${t.access === "read-write" ? "read_write" : t.access}>` : `ptr<${t.addressSpace}, ${e.resolve(t.inner).value}>`;
2659
2659
  if (t.type === "abstractInt" || t.type === "abstractFloat" || t.type === "void" || t.type === "u16") throw new Error(`${t.type} has no representation in WGSL`);
2660
2660
  if (Oa(t)) return `${t.type}<${t.format}, ${In[t.access]}>`;
2661
2661
  if (ao(t)) return t.type.startsWith("texture_depth") ? t.type : `${t.type}<${t.sampleType.type}>`;
2662
- if (Mc(t) || Uc(t)) return t.type;
2662
+ if (Uc(t) || Ec(t)) return t.type;
2663
2663
  fn(t, "resolveData");
2664
2664
  }
2665
2665
  var No = class ja {
@@ -2674,15 +2674,15 @@ var No = class ja {
2674
2674
  return new ja([...this.bindings, ...r.bindings]);
2675
2675
  }
2676
2676
  };
2677
- function* Dh(e) {
2677
+ function* jh(e) {
2678
2678
  let t = 0;
2679
2679
  for (; ; ) e.has(t) || (yield t), t++;
2680
2680
  }
2681
- function Yh(e, t) {
2681
+ function Dh(e, t) {
2682
2682
  let r = "size" in e ? e.size : e.currentByteOffset, n = t - 1, a = r & n;
2683
2683
  "skipBytes" in e ? e.skipBytes(t - a & n) : e.add(t - a & n);
2684
2684
  }
2685
- var ge = Yh, Hi = /* @__PURE__ */ new WeakMap();
2685
+ var ge = Dh, Hi = /* @__PURE__ */ new WeakMap();
2686
2686
  function Lo(e) {
2687
2687
  let t = Hi.get(e);
2688
2688
  if (t) return t;
@@ -2697,13 +2697,13 @@ function Lo(e) {
2697
2697
  }
2698
2698
  return a && (a.padding = Ce(F(e), oe(e)) - r.size), Hi.set(e, n), n;
2699
2699
  }
2700
- var qh = (() => {
2700
+ var Yh = (() => {
2701
2701
  try {
2702
2702
  return new Function("return true"), !0;
2703
2703
  } catch {
2704
2704
  return !1;
2705
2705
  }
2706
- })(), Ia = /* @__PURE__ */ new WeakMap(), Nn = { u32: "u32", vec2u: "u32", vec3u: "u32", vec4u: "u32", u16: "u16", i32: "i32", vec2i: "i32", vec3i: "i32", vec4i: "i32", f32: "f32", vec2f: "f32", vec3f: "f32", vec4f: "f32", f16: "f16", vec2h: "f16", vec3h: "f16", vec4h: "f16", mat2x2f: "f32", mat3x3f: "f32", mat4x4f: "f32" }, Vh = { uint8: "u8", uint8x2: "u8", uint8x4: "u8", sint8: "i8", sint8x2: "i8", sint8x4: "i8", unorm8: "u8", unorm8x2: "u8", unorm8x4: "u8", snorm8: "i8", snorm8x2: "i8", snorm8x4: "i8", uint16: "u16", uint16x2: "u16", uint16x4: "u16", sint16: "i16", sint16x2: "i16", sint16x4: "i16", unorm16: "u16", unorm16x2: "u16", unorm16x4: "u16", snorm16: "i16", snorm16x2: "i16", snorm16x4: "i16", float16: "f16", float16x2: "f16", float16x4: "f16", float32: "f32", float32x2: "f32", float32x3: "f32", float32x4: "f32", uint32: "u32", uint32x2: "u32", uint32x3: "u32", uint32x4: "u32", sint32: "i32", sint32x2: "i32", sint32x3: "i32", sint32x4: "i32" }, Ln = { u32: "setUint32", i32: "setInt32", f32: "setFloat32", u16: "setUint16", i16: "setInt16", f16: "setFloat16", u8: "setUint8", i8: "setInt8" }, Jh = { unorm8: (e) => `Math.round(${e} * 255)`, unorm8x2: (e) => `Math.round(${e} * 255)`, unorm8x4: (e) => `Math.round(${e} * 255)`, snorm8: (e) => `Math.round(${e} * 127)`, snorm8x2: (e) => `Math.round(${e} * 127)`, snorm8x4: (e) => `Math.round(${e} * 127)`, unorm16: (e) => `Math.round(${e} * 65535)`, unorm16x2: (e) => `Math.round(${e} * 65535)`, unorm16x4: (e) => `Math.round(${e} * 65535)`, snorm16: (e) => `Math.round(${e} * 32767)`, snorm16x2: (e) => `Math.round(${e} * 32767)`, snorm16x4: (e) => `Math.round(${e} * 32767)` }, es = { "unorm10-10-10-2": { writeFunction: "setUint32", generator: (e, t) => `output.setUint32(${e}, ((${t}.x*1023&0x3FF)<<22)|((${t}.y*1023&0x3FF)<<12)|((${t}.z*1023&0x3FF)<<2)|(${t}.w*3&3), littleEndian);
2706
+ })(), Ia = /* @__PURE__ */ new WeakMap(), Nn = { u32: "u32", vec2u: "u32", vec3u: "u32", vec4u: "u32", u16: "u16", i32: "i32", vec2i: "i32", vec3i: "i32", vec4i: "i32", f32: "f32", vec2f: "f32", vec3f: "f32", vec4f: "f32", f16: "f16", vec2h: "f16", vec3h: "f16", vec4h: "f16", mat2x2f: "f32", mat3x3f: "f32", mat4x4f: "f32" }, qh = { uint8: "u8", uint8x2: "u8", uint8x4: "u8", sint8: "i8", sint8x2: "i8", sint8x4: "i8", unorm8: "u8", unorm8x2: "u8", unorm8x4: "u8", snorm8: "i8", snorm8x2: "i8", snorm8x4: "i8", uint16: "u16", uint16x2: "u16", uint16x4: "u16", sint16: "i16", sint16x2: "i16", sint16x4: "i16", unorm16: "u16", unorm16x2: "u16", unorm16x4: "u16", snorm16: "i16", snorm16x2: "i16", snorm16x4: "i16", float16: "f16", float16x2: "f16", float16x4: "f16", float32: "f32", float32x2: "f32", float32x3: "f32", float32x4: "f32", uint32: "u32", uint32x2: "u32", uint32x3: "u32", uint32x4: "u32", sint32: "i32", sint32x2: "i32", sint32x3: "i32", sint32x4: "i32" }, Ln = { u32: "setUint32", i32: "setInt32", f32: "setFloat32", u16: "setUint16", i16: "setInt16", f16: "setFloat16", u8: "setUint8", i8: "setInt8" }, Vh = { unorm8: (e) => `Math.round(${e} * 255)`, unorm8x2: (e) => `Math.round(${e} * 255)`, unorm8x4: (e) => `Math.round(${e} * 255)`, snorm8: (e) => `Math.round(${e} * 127)`, snorm8x2: (e) => `Math.round(${e} * 127)`, snorm8x4: (e) => `Math.round(${e} * 127)`, unorm16: (e) => `Math.round(${e} * 65535)`, unorm16x2: (e) => `Math.round(${e} * 65535)`, unorm16x4: (e) => `Math.round(${e} * 65535)`, snorm16: (e) => `Math.round(${e} * 32767)`, snorm16x2: (e) => `Math.round(${e} * 32767)`, snorm16x4: (e) => `Math.round(${e} * 32767)` }, es = { "unorm10-10-10-2": { writeFunction: "setUint32", generator: (e, t) => `output.setUint32(${e}, ((${t}.x*1023&0x3FF)<<22)|((${t}.y*1023&0x3FF)<<12)|((${t}.z*1023&0x3FF)<<2)|(${t}.w*3&3), littleEndian);
2707
2707
  ` }, "unorm8x4-bgra": { writeFunction: "setUint8", generator: (e, t) => {
2708
2708
  let r = ["z", "y", "x", "w"], n = "";
2709
2709
  for (let a = 0; a < 4; a++) n += `output.setUint8((${e} + ${a}), Math.round(${t}.${r[a]} * 255), littleEndian);
@@ -2727,14 +2727,14 @@ function Dn(e, t, r, n = 0) {
2727
2727
  `, o += Dn(e.elementType, `(${t} + ${a} * ${s})`, `${r}[${a}]`, n + 1), o += `}
2728
2728
  `, o;
2729
2729
  }
2730
- if (nr(e)) {
2730
+ if (ar(e)) {
2731
2731
  let s = Nn[e.type], o = "", u = Ln[s], l = ["x", "y", "z", "w"], d = Gi(e) ? 2 : Oi(e) ? 3 : 4;
2732
2732
  for (let h = 0; h < d; h++) o += `output.${u}((${t} + ${h * 4}), ${r}.${l[h]}, littleEndian);
2733
2733
  `;
2734
2734
  return o;
2735
2735
  }
2736
2736
  if (Es(e)) {
2737
- let s = Nn[e.type], o = Ln[s], u = Vl(e) ? 2 : Jl(e) ? 3 : 4, l = u * u, d = Ce(u * 4, 8), h = "";
2737
+ let s = Nn[e.type], o = Ln[s], u = ql(e) ? 2 : Vl(e) ? 3 : 4, l = u * u, d = Ce(u * 4, 8), h = "";
2738
2738
  for (let f = 0; f < l; f++) {
2739
2739
  let w = Math.floor(f / u), $ = f % u, S = w * d + $ * 4;
2740
2740
  h += `output.${o}((${t} + ${S}), ${r}.columns[${w}].${["x", "y", "z", "w"][$]}, littleEndian);
@@ -2745,7 +2745,7 @@ function Dn(e, t, r, n = 0) {
2745
2745
  if (ks(e)) {
2746
2746
  let s = e.type;
2747
2747
  if (s in es) return es[s].generator(t, r);
2748
- let o = Vh[s], u = Ln[o], l = Wr[s], d = Xl(l) ? 4 : Oi(l) ? 3 : Gi(l) ? 2 : 1, h = o === "u8" || o === "i8" ? 1 : o === "u16" || o === "i16" || o === "f16" ? 2 : 4, f = ["x", "y", "z", "w"], w = Jh[s], $ = "";
2748
+ let o = qh[s], u = Ln[o], l = Wr[s], d = Jl(l) ? 4 : Oi(l) ? 3 : Gi(l) ? 2 : 1, h = o === "u8" || o === "i8" ? 1 : o === "u16" || o === "i16" || o === "f16" ? 2 : 4, f = ["x", "y", "z", "w"], w = Vh[s], $ = "";
2749
2749
  for (let S = 0; S < d; S++) {
2750
2750
  let O = d === 1 ? r : `${r}.${f[S]}`, G = w ? w(O) : O;
2751
2751
  $ += `output.${u}((${t} + ${S * h}), ${G}, littleEndian);
@@ -2759,7 +2759,7 @@ function Dn(e, t, r, n = 0) {
2759
2759
  `;
2760
2760
  }
2761
2761
  function ts(e) {
2762
- if (!qh) {
2762
+ if (!Yh) {
2763
2763
  console.warn("This environment does not allow eval - using default writer as fallback");
2764
2764
  return;
2765
2765
  }
@@ -2773,7 +2773,7 @@ Reason: ${t instanceof Error ? t.message : String(t)}
2773
2773
  Falling back to default writer`);
2774
2774
  }
2775
2775
  }
2776
- var zr = { bool() {
2776
+ var kr = { bool() {
2777
2777
  throw new Error("Booleans are not host-shareable");
2778
2778
  }, f32(e, t, r) {
2779
2779
  e.writeFloat32(r);
@@ -2836,12 +2836,12 @@ var zr = { bool() {
2836
2836
  }, ptr() {
2837
2837
  throw new Error("Pointers are not host-shareable");
2838
2838
  }, atomic(e, t, r) {
2839
- zr[t.inner.type]?.(e, t, r);
2839
+ kr[t.inner.type]?.(e, t, r);
2840
2840
  }, decorated(e, t, r) {
2841
2841
  let n = De(t);
2842
2842
  ge(e, n);
2843
2843
  let a = e.currentByteOffset;
2844
- zr[t.inner?.type]?.(e, t.inner, r), e.seekTo(a + F(t));
2844
+ kr[t.inner?.type]?.(e, t.inner, r), e.seekTo(a + F(t));
2845
2845
  }, uint8(e, t, r) {
2846
2846
  e.writeUint8(r);
2847
2847
  }, uint8x2(e, t, r) {
@@ -2929,23 +2929,23 @@ var zr = { bool() {
2929
2929
  let n = oe(t);
2930
2930
  ge(e, n);
2931
2931
  let a = e.currentByteOffset;
2932
- for (let i = 0; i < Math.min(t.elementCount, r.length); i++) ge(e, n), zr[t.elementType?.type]?.(e, t.elementType, r[i]);
2932
+ for (let i = 0; i < Math.min(t.elementCount, r.length); i++) ge(e, n), kr[t.elementType?.type]?.(e, t.elementType, r[i]);
2933
2933
  e.seekTo(a + F(t));
2934
2934
  }, unstruct(e, t, r) {
2935
2935
  let n = t.propTypes;
2936
- for (let [a, i] of Object.entries(n)) zr[i.type]?.(e, i, r[a]);
2936
+ for (let [a, i] of Object.entries(n)) kr[i.type]?.(e, i, r[a]);
2937
2937
  }, "loose-decorated"(e, t, r) {
2938
2938
  let n = De(t);
2939
2939
  ge(e, n);
2940
- let a = e.currentByteOffset, i = zr[t.inner?.type];
2940
+ let a = e.currentByteOffset, i = kr[t.inner?.type];
2941
2941
  return i?.(e, t.inner, r), e.seekTo(a + F(t)), r;
2942
2942
  } };
2943
2943
  function ra(e, t, r) {
2944
- let n = zr[t.type];
2944
+ let n = kr[t.type];
2945
2945
  if (!n) throw new Error(`Cannot write data of type '${t.type}'.`);
2946
2946
  n(e, t, r);
2947
2947
  }
2948
- var Xh = { bool() {
2948
+ var Jh = { bool() {
2949
2949
  throw new Error("Booleans are not host-shareable");
2950
2950
  }, f32(e) {
2951
2951
  return e.readFloat32();
@@ -3043,14 +3043,14 @@ var Xh = { bool() {
3043
3043
  return e.seekTo(r + F(t)), n;
3044
3044
  } };
3045
3045
  function st(e, t) {
3046
- let r = Xh[t.type];
3046
+ let r = Jh[t.type];
3047
3047
  if (!r) throw new Error(`Cannot read data of type '${t.type}'.`);
3048
3048
  return r(e, t);
3049
3049
  }
3050
- function Zh(e, t) {
3050
+ function Xh(e, t) {
3051
3051
  let r = F(e);
3052
3052
  if (r === 0 || t === void 0 || t === null) return [];
3053
- let n = new ArrayBuffer(r), a = new ur(n), i = [];
3053
+ let n = new ArrayBuffer(r), a = new lr(n), i = [];
3054
3054
  function s(l, d, h, f) {
3055
3055
  if (d != null) {
3056
3056
  if (xe(l) || Ke(l)) {
@@ -3122,7 +3122,7 @@ var jo = { uniform: "uniform", mutable: "storage, read_write", readonly: "storag
3122
3122
  get $() {
3123
3123
  let e = Qn(), t = Kn();
3124
3124
  if (e.type === "normal") throw new Bi(t ? `Cannot access ${String(this.buffer)}. TypeGPU functions that depends on GPU resources need to be part of a compute dispatch, draw call or simulation` : ".$ and .value are inaccessible during normal JS execution. Try `.read()`");
3125
- return e.type === "codegen" ? this[j] : e.type === "simulate" ? (e.buffers.has(this.buffer) || e.buffers.set(this.buffer, ar(this.buffer.dataType, this.buffer.initial)), e.buffers.get(this.buffer)) : fn(e, "bufferUsage.ts#TgpuFixedBufferImpl/$");
3125
+ return e.type === "codegen" ? this[j] : e.type === "simulate" ? (e.buffers.has(this.buffer) || e.buffers.set(this.buffer, ir(this.buffer.dataType, this.buffer.initial)), e.buffers.get(this.buffer)) : fn(e, "bufferUsage.ts#TgpuFixedBufferImpl/$");
3126
3126
  }
3127
3127
  get value() {
3128
3128
  return this.$;
@@ -3168,31 +3168,31 @@ var jo = { uniform: "uniform", mutable: "storage, read_write", readonly: "storag
3168
3168
  return this.$;
3169
3169
  }
3170
3170
  }, as = /* @__PURE__ */ new WeakMap();
3171
- function Qh(e) {
3171
+ function Zh(e) {
3172
3172
  if (!na(e)) throw new Error(`Cannot pass ${e} to asMutable, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);
3173
3173
  let t = as.get(e);
3174
3174
  return t || (t = new bi("mutable", e), as.set(e, t)), t;
3175
3175
  }
3176
3176
  var is = /* @__PURE__ */ new WeakMap();
3177
- function Kh(e) {
3177
+ function Qh(e) {
3178
3178
  if (!na(e)) throw new Error(`Cannot pass ${e} to asReadonly, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);
3179
3179
  let t = is.get(e);
3180
3180
  return t || (t = new bi("readonly", e), is.set(e, t)), t;
3181
3181
  }
3182
3182
  var ss = /* @__PURE__ */ new WeakMap();
3183
- function Hh(e) {
3183
+ function Kh(e) {
3184
3184
  if (!Wo(e)) throw new Error(`Cannot pass ${e} to asUniform, as it is not allowed to be used as a uniform. To allow it, call .$usage('uniform') when creating the buffer.`);
3185
3185
  let t = ss.get(e);
3186
3186
  return t || (t = new bi("uniform", e), ss.set(e, t)), t;
3187
3187
  }
3188
- var ef = { uniform: Hh, mutable: Qh, readonly: Kh };
3188
+ var Hh = { uniform: Kh, mutable: Zh, readonly: Qh };
3189
3189
  function Rn(e, t, r) {
3190
3190
  return Vr(t) ? new os(e, t, r) : new os(e, t, r, ["storage", "uniform"]);
3191
3191
  }
3192
3192
  function mn(e) {
3193
3193
  return e.resourceType === "buffer";
3194
3194
  }
3195
- var tf = /* @__PURE__ */ xo(), os = class {
3195
+ var ef = /* @__PURE__ */ xo(), os = class {
3196
3196
  constructor(t, r, n, a) {
3197
3197
  this.dataType = r, this.initialOrBuffer = n, this._disallowedUsages = a, this.#e = t.device, Sa(n) ? (this._ownBuffer = !1, this._buffer = n) : (this._ownBuffer = !0, this.initial = n);
3198
3198
  }
@@ -3236,13 +3236,13 @@ var tf = /* @__PURE__ */ xo(), os = class {
3236
3236
  _writeToTarget(t, r) {
3237
3237
  let n = ts(this.dataType);
3238
3238
  if (n) try {
3239
- n(new DataView(t), 0, r, tf === "little");
3239
+ n(new DataView(t), 0, r, ef === "little");
3240
3240
  return;
3241
3241
  } catch (a) {
3242
3242
  console.error(`Error when using compiled writer for buffer ${x(this) ?? "<unnamed>"} - this is likely a bug, please submit an issue at https://github.com/software-mansion/TypeGPU/issues
3243
3243
  Using fallback writer instead.`, a);
3244
3244
  }
3245
- ra(new ur(t), this.dataType, r);
3245
+ ra(new lr(t), this.dataType, r);
3246
3246
  }
3247
3247
  write(t) {
3248
3248
  let r = this.buffer;
@@ -3255,7 +3255,7 @@ Using fallback writer instead.`, a);
3255
3255
  this._hostBuffer || (this._hostBuffer = new ArrayBuffer(n)), this._writeToTarget(this._hostBuffer, t), this.#e.queue.writeBuffer(r, 0, this._hostBuffer, 0, n);
3256
3256
  }
3257
3257
  writePartial(t) {
3258
- let r = this.buffer, n = Zh(this.dataType, t);
3258
+ let r = this.buffer, n = Xh(this.dataType, t);
3259
3259
  if (r.mapState === "mapped") {
3260
3260
  let a = r.getMappedRange(), i = new Uint8Array(a);
3261
3261
  for (let s of n) i.set(s.data, s.data.byteOffset);
@@ -3292,7 +3292,7 @@ Using fallback writer instead.`, a);
3292
3292
  return r.unmap(), r.destroy(), a;
3293
3293
  }
3294
3294
  as(t) {
3295
- return ef[t]?.(this);
3295
+ return Hh[t]?.(this);
3296
3296
  }
3297
3297
  destroy() {
3298
3298
  this._destroyed || (this._destroyed = !0, this._ownBuffer && this._buffer?.destroy());
@@ -3301,10 +3301,10 @@ Using fallback writer instead.`, a);
3301
3301
  return `buffer:${x(this) ?? "<unnamed>"}`;
3302
3302
  }
3303
3303
  };
3304
- function rf(e, t) {
3304
+ function tf(e, t) {
3305
3305
  return new qo(di(), e, t);
3306
3306
  }
3307
- function nf(e, t) {
3307
+ function rf(e, t) {
3308
3308
  return new qo(mi(), e, t);
3309
3309
  }
3310
3310
  function Do(e) {
@@ -3315,7 +3315,7 @@ function Yo(e) {
3315
3315
  let t = e;
3316
3316
  return t?.resourceType === "sampler-comparison" && !!t[c];
3317
3317
  }
3318
- var af = class {
3318
+ var nf = class {
3319
3319
  constructor(t, r) {
3320
3320
  this.schema = t, this.#e = r, this.resourceType = t.type === "sampler_comparison" ? "sampler-comparison" : "sampler", re(this, r.key);
3321
3321
  }
@@ -3375,7 +3375,7 @@ var af = class {
3375
3375
  toString() {
3376
3376
  return `${this.resourceType}:${x(this) ?? "<unnamed>"}`;
3377
3377
  }
3378
- }, sf = class {
3378
+ }, af = class {
3379
3379
  constructor(t, r) {
3380
3380
  this.schema = t, this.#e = r, re(this, r.key);
3381
3381
  }
@@ -3414,7 +3414,7 @@ function Vo(e) {
3414
3414
  if (o && u) return { width: o, height: u };
3415
3415
  throw new Error("Cannot determine dimensions of the provided image source.");
3416
3416
  }
3417
- var of = `
3417
+ var sf = `
3418
3418
  struct VertexOutput {
3419
3419
  @builtin(position) pos: vec4f,
3420
3420
  @location(0) uv: vec2f,
@@ -3425,14 +3425,14 @@ fn vs_main(@builtin(vertex_index) i: u32) -> VertexOutput {
3425
3425
  const pos = array(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));
3426
3426
  const uv = array(vec2f(0, 1), vec2f(2, 1), vec2f(0, -1));
3427
3427
  return VertexOutput(vec4f(pos[i], 0, 1), uv[i]);
3428
- }`, uf = `
3428
+ }`, of = `
3429
3429
  @group(0) @binding(0) var src: texture_2d<f32>;
3430
3430
  @group(0) @binding(1) var samp: sampler;
3431
3431
 
3432
3432
  @fragment
3433
3433
  fn fs_main(@location(0) uv: vec2f) -> @location(0) vec4f {
3434
3434
  return textureSample(src, samp, uv);
3435
- }`, lf = `
3435
+ }`, uf = `
3436
3436
  @group(0) @binding(0) var src: texture_2d<f32>;
3437
3437
  @group(0) @binding(1) var samp: sampler;
3438
3438
 
@@ -3444,13 +3444,13 @@ fn fs_main(@location(0) uv: vec2f) -> @location(0) vec4f {
3444
3444
  let a = textureGather(3, src, samp, uv);
3445
3445
  return vec4f(dot(r, vec4f(0.25)), dot(g, vec4f(0.25)), dot(b, vec4f(0.25)), dot(a, vec4f(0.25)));
3446
3446
  }`, Da = /* @__PURE__ */ new WeakMap();
3447
- function cf(e) {
3447
+ function lf(e) {
3448
3448
  let t = Da.get(e);
3449
- return t || (t = { vertexModule: e.createShaderModule({ code: of }), filterableResources: /* @__PURE__ */ new Map(), layoutResources: /* @__PURE__ */ new Map() }, Da.set(e, t)), t;
3449
+ return t || (t = { vertexModule: e.createShaderModule({ code: sf }), filterableResources: /* @__PURE__ */ new Map(), layoutResources: /* @__PURE__ */ new Map() }, Da.set(e, t)), t;
3450
3450
  }
3451
- function pf(e, t, r) {
3452
- let n = cf(e), a = n.filterableResources.get(t);
3453
- a || (a = { fragmentModule: e.createShaderModule({ code: t ? uf : lf }), sampler: (globalThis.__TYPEGPU_AUTONAME__ ?? ((o) => o))(e.createSampler(t ? { magFilter: "linear", minFilter: "linear" } : {}), "sampler") }, n.filterableResources.set(t, a));
3451
+ function cf(e, t, r) {
3452
+ let n = lf(e), a = n.filterableResources.get(t);
3453
+ a || (a = { fragmentModule: e.createShaderModule({ code: t ? of : uf }), sampler: (globalThis.__TYPEGPU_AUTONAME__ ?? ((o) => o))(e.createSampler(t ? { magFilter: "linear", minFilter: "linear" } : {}), "sampler") }, n.filterableResources.set(t, a));
3454
3454
  let i = `${t}:${r}`, s = n.layoutResources.get(i);
3455
3455
  if (!s) {
3456
3456
  let o = e.createBindGroupLayout({ entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: r } }, { binding: 1, visibility: GPUShaderStage.FRAGMENT, sampler: { type: t ? "filtering" : "non-filtering" } }] });
@@ -3459,19 +3459,19 @@ function pf(e, t, r) {
3459
3459
  return { vertexModule: n.vertexModule, ...a, ...s };
3460
3460
  }
3461
3461
  function Jo(e) {
3462
- let { device: t, source: r, destination: n, format: a, filterable: i, sampleType: s } = e, o = pf(t, i, s), u = t.createRenderPipeline({ layout: o.pipelineLayout, vertex: { module: o.vertexModule }, fragment: { module: o.fragmentModule, targets: [{ format: a }] }, primitive: { topology: "triangle-list" } }), l = t.createBindGroup({ layout: o.bindGroupLayout, entries: [{ binding: 0, resource: r }, { binding: 1, resource: o.sampler }] }), d = !e.encoder, h = e.encoder ?? t.createCommandEncoder(), f = h.beginRenderPass({ colorAttachments: [{ view: n, loadOp: "clear", storeOp: "store" }] });
3462
+ let { device: t, source: r, destination: n, format: a, filterable: i, sampleType: s } = e, o = cf(t, i, s), u = t.createRenderPipeline({ layout: o.pipelineLayout, vertex: { module: o.vertexModule }, fragment: { module: o.fragmentModule, targets: [{ format: a }] }, primitive: { topology: "triangle-list" } }), l = t.createBindGroup({ layout: o.bindGroupLayout, entries: [{ binding: 0, resource: r }, { binding: 1, resource: o.sampler }] }), d = !e.encoder, h = e.encoder ?? t.createCommandEncoder(), f = h.beginRenderPass({ colorAttachments: [{ view: n, loadOp: "clear", storeOp: "store" }] });
3463
3463
  f.setPipeline(u), f.setBindGroup(0, l), f.draw(3), f.end(), d && t.queue.submit([h.finish()]);
3464
3464
  }
3465
- function df(e) {
3465
+ function pf(e) {
3466
3466
  Da.delete(e);
3467
3467
  }
3468
3468
  function Xo(e, t, r) {
3469
- let n = Sn(t), a = yh(e, t), i = a.includes("float"), s = a.includes("unfilterable-float");
3469
+ let n = Sn(t), a = fh(e, t), i = a.includes("float"), s = a.includes("unfilterable-float");
3470
3470
  if (!i && !s) throw new Error(`Cannot ${r} for format '${t}': only float formats are supported.`);
3471
3471
  if (!n.canRenderAttachment) throw new Error(`Cannot ${r} for format '${t}': format does not support render attachments.`);
3472
3472
  return { filterable: i, sampleType: i ? "float" : "unfilterable-float" };
3473
3473
  }
3474
- function mf(e, t, r = 0, n) {
3474
+ function df(e, t, r = 0, n) {
3475
3475
  if (t.dimension !== "2d") throw new Error("Mipmap generation only supports 2D textures.");
3476
3476
  let { filterable: a, sampleType: i } = Xo(e, t.format, "generate mipmaps"), s = n ?? t.mipLevelCount - r;
3477
3477
  for (let o = 0; o < t.depthOrArrayLayers; o++) for (let u = r; u < r + s - 1; u++) {
@@ -3479,18 +3479,18 @@ function mf(e, t, r = 0, n) {
3479
3479
  Jo({ device: e, source: t.createView(l(u)), destination: t.createView(l(u + 1)), format: t.format, filterable: a, sampleType: i });
3480
3480
  }
3481
3481
  }
3482
- function hf(e, t, r, n = 0) {
3482
+ function mf(e, t, r, n = 0) {
3483
3483
  if (t.dimension !== "2d") throw new Error("Resampling only supports 2D textures.");
3484
3484
  let { filterable: a } = Xo(e, t.format, "resample"), { width: i, height: s } = Vo(r), o = (globalThis.__TYPEGPU_AUTONAME__ ?? ((d) => d))(e.createTexture({ size: [i, s], format: "rgba8unorm", usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT }), "s");
3485
3485
  e.queue.copyExternalImageToTexture({ source: r }, { texture: o }, [i, s]);
3486
3486
  let u = (globalThis.__TYPEGPU_AUTONAME__ ?? ((d) => d))(e.createTexture({ size: [t.width, t.height], format: t.format, usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC }), "u"), l = e.createCommandEncoder();
3487
3487
  Jo({ device: e, source: o.createView(), destination: u.createView(), format: t.format, filterable: a, sampleType: "float", encoder: l }), l.copyTextureToTexture({ texture: u }, { texture: t, origin: { x: 0, y: 0, z: n } }, { width: t.width, height: t.height, depthOrArrayLayers: 1 }), e.queue.submit([l.finish()]), o.destroy(), u.destroy();
3488
3488
  }
3489
- function ff(e) {
3489
+ function hf(e) {
3490
3490
  return { dimension: e.dimension ?? "2d", sampleType: Sn(e.format).channelType, multisampled: (e.sampleCount ?? 1) !== 1 };
3491
3491
  }
3492
- function yf(e, t) {
3493
- return new gf(e, t);
3492
+ function ff(e, t) {
3493
+ return new yf(e, t);
3494
3494
  }
3495
3495
  function wn(e) {
3496
3496
  return e?.resourceType === "texture" && !!e[c];
@@ -3498,7 +3498,7 @@ function wn(e) {
3498
3498
  function xn(e) {
3499
3499
  return e?.resourceType === "texture-view" && !!e[c];
3500
3500
  }
3501
- var gf = class {
3501
+ var yf = class {
3502
3502
  constructor(t, r) {
3503
3503
  this.props = t;
3504
3504
  let n = t.format;
@@ -3528,7 +3528,7 @@ var gf = class {
3528
3528
  return this.#n |= n ? GPUTextureUsage.TEXTURE_BINDING : 0, this.#n |= r ? GPUTextureUsage.STORAGE_BINDING : 0, this.#n |= a ? GPUTextureUsage.RENDER_ATTACHMENT : 0, this.usableAsStorage ||= r, this.usableAsSampled ||= n, this.usableAsRender ||= a, this;
3529
3529
  }
3530
3530
  createView(t, r) {
3531
- return t === "render" ? new wf(this, r) : new vf(t ?? Ga(ff(this.props)), this, r);
3531
+ return t === "render" ? new vf(this, r) : new gf(t ?? Ga(hf(this.props)), this, r);
3532
3532
  }
3533
3533
  #s(t = 0) {
3534
3534
  let r = 2 ** t, [n, a, i] = [Math.max(1, Math.floor((this.props.size[0] ?? 1) / r)), Math.max(1, Math.floor((this.props.size[1] ?? 1) / r)), Math.max(1, Math.floor((this.props.size[2] ?? 1) / r))], s = this.#e.texelSize;
@@ -3549,7 +3549,7 @@ var gf = class {
3549
3549
  return;
3550
3550
  }
3551
3551
  if (t >= (this.props.mipLevelCount ?? 1)) throw new Error(`Base mip level ${t} is out of range. Texture has ${this.props.mipLevelCount ?? 1} mip levels.`);
3552
- mf(this.#i.device, this[c].unwrap(), t, n);
3552
+ df(this.#i.device, this[c].unwrap(), t, n);
3553
3553
  }
3554
3554
  write(t, r = 0) {
3555
3555
  if (t instanceof ArrayBuffer || ArrayBuffer.isView(t)) {
@@ -3578,7 +3578,7 @@ var gf = class {
3578
3578
  #o(t, r) {
3579
3579
  let n = this.props.size[0], a = this.props.size[1] ?? 1, { width: i, height: s } = Vo(t);
3580
3580
  if (i !== n || s !== a) {
3581
- hf(this.#i.device, this[c].unwrap(), t, r);
3581
+ mf(this.#i.device, this[c].unwrap(), t, r);
3582
3582
  return;
3583
3583
  }
3584
3584
  this.#i.device.queue.copyExternalImageToTexture({ source: t }, { texture: this[c].unwrap(), ...r !== void 0 && { origin: { x: 0, y: 0, z: r } } }, r !== void 0 ? [n, a, 1] : this.props.size);
@@ -3595,7 +3595,7 @@ var gf = class {
3595
3595
  destroy() {
3596
3596
  this.#r || (this.#r = !0, this.#a?.destroy());
3597
3597
  }
3598
- }, vf = class {
3598
+ }, gf = class {
3599
3599
  constructor(t, r, n) {
3600
3600
  this.schema = t, this.#e = r, this.#r = n, this[c] = { unwrap: () => {
3601
3601
  if (!this.#t) {
@@ -3660,22 +3660,22 @@ var gf = class {
3660
3660
  get value() {
3661
3661
  return this.$;
3662
3662
  }
3663
- }, wf = class {
3663
+ }, vf = class {
3664
3664
  constructor(e, t = {}) {
3665
3665
  this.descriptor = t, this[c] = { unwrap: () => e[c].unwrap().createView({ label: x(this) ?? "<unnamed>", ...this.descriptor }) };
3666
3666
  }
3667
3667
  [c];
3668
3668
  resourceType = "texture-view";
3669
3669
  };
3670
- function xf(e) {
3670
+ function wf(e) {
3671
3671
  return !!e?.usableAsSampled;
3672
3672
  }
3673
- var bf = class Zo extends Error {
3673
+ var xf = class Zo extends Error {
3674
3674
  constructor(t) {
3675
3675
  super(`Resource '${x(t) ?? "<unnamed>"}' cannot be bound as 'sampled'. Use .$usage('sampled') to allow it.`), Object.setPrototypeOf(this, Zo.prototype);
3676
3676
  }
3677
3677
  };
3678
- function $f(e) {
3678
+ function bf(e) {
3679
3679
  let t = {};
3680
3680
  for (let [r, n] of Object.entries(e)) {
3681
3681
  if (n === null) {
@@ -3693,8 +3693,8 @@ function $f(e) {
3693
3693
  return t;
3694
3694
  }
3695
3695
  function Qo(e) {
3696
- let t = $f(e);
3697
- return new _f(t);
3696
+ let t = bf(e);
3697
+ return new Tf(t);
3698
3698
  }
3699
3699
  function Ko(e) {
3700
3700
  return !!e && e.resourceType === "bind-group-layout";
@@ -3702,11 +3702,11 @@ function Ko(e) {
3702
3702
  function aa(e) {
3703
3703
  return !!e && e.resourceType === "bind-group";
3704
3704
  }
3705
- var Tf = class Ho extends Error {
3705
+ var $f = class Ho extends Error {
3706
3706
  constructor(t, r) {
3707
3707
  super(`Bind group '${t ?? "<unnamed>"}' is missing a required binding '${r}'`), Object.setPrototypeOf(this, Ho.prototype);
3708
3708
  }
3709
- }, ls = ["compute", "fragment"], nn = ["compute", "vertex", "fragment"], _f = class {
3709
+ }, ls = ["compute", "fragment"], nn = ["compute", "vertex", "fragment"], Tf = class {
3710
3710
  constructor(e) {
3711
3711
  this.entries = e;
3712
3712
  let t = 0;
@@ -3720,7 +3720,7 @@ var Tf = class Ho extends Error {
3720
3720
  let i = "type" in n.storage ? n.storage : n.storage(0);
3721
3721
  this.bound[r] = new ns(n.access ?? "readonly", i, a);
3722
3722
  }
3723
- "texture" in n && (this.bound[r] = new us(n.texture, a)), "storageTexture" in n && (this.bound[r] = new us(n.storageTexture, a)), "externalTexture" in n && (this.bound[r] = new sf(n.externalTexture, a)), "sampler" in n && (this.bound[r] = new af(n.sampler === "comparison" ? mi() : di(), a)), Object.defineProperty(this.value, r, { get: () => this.bound[r].value }), t++;
3723
+ "texture" in n && (this.bound[r] = new us(n.texture, a)), "storageTexture" in n && (this.bound[r] = new us(n.storageTexture, a)), "externalTexture" in n && (this.bound[r] = new af(n.externalTexture, a)), "sampler" in n && (this.bound[r] = new nf(n.sampler === "comparison" ? mi() : di(), a)), Object.defineProperty(this.value, r, { get: () => this.bound[r].value }), t++;
3724
3724
  }
3725
3725
  }
3726
3726
  [c] = !0;
@@ -3766,7 +3766,7 @@ var Tf = class Ho extends Error {
3766
3766
  }, eu = class {
3767
3767
  constructor(e, t) {
3768
3768
  this.layout = e, this.entries = t;
3769
- for (let r of Object.keys(e.entries)) if (e.entries[r] !== null && !(r in t)) throw new Tf(x(e), r);
3769
+ for (let r of Object.keys(e.entries)) if (e.entries[r] !== null && !(r in t)) throw new $f(x(e), r);
3770
3770
  }
3771
3771
  resourceType = "bind-group";
3772
3772
  unwrap(e) {
@@ -3777,7 +3777,7 @@ var Tf = class Ho extends Error {
3777
3777
  if ("uniform" in r) {
3778
3778
  let i;
3779
3779
  if (mn(a)) {
3780
- if (!Wo(a)) throw new ql(a);
3780
+ if (!Wo(a)) throw new Yl(a);
3781
3781
  i = { buffer: e.unwrap(a) };
3782
3782
  } else i = { buffer: a };
3783
3783
  return { binding: n, resource: i };
@@ -3793,7 +3793,7 @@ var Tf = class Ho extends Error {
3793
3793
  if ("texture" in r) {
3794
3794
  let i;
3795
3795
  if (wn(a)) {
3796
- if (!xf(a)) throw new bf(a);
3796
+ if (!wf(a)) throw new xf(a);
3797
3797
  i = e.unwrap(a.createView(r.texture));
3798
3798
  } else xn(a) ? i = e.unwrap(a) : i = a;
3799
3799
  return { binding: n, resource: i };
@@ -3813,9 +3813,9 @@ var Tf = class Ho extends Error {
3813
3813
  }
3814
3814
  };
3815
3815
  function ia(e) {
3816
- return new If(e);
3816
+ return new _f(e);
3817
3817
  }
3818
- var If = class {
3818
+ var _f = class {
3819
3819
  constructor(e = void 0) {
3820
3820
  this.defaultValue = e;
3821
3821
  }
@@ -3893,7 +3893,7 @@ var tu = class {
3893
3893
  set value(t) {
3894
3894
  this.$ = t;
3895
3895
  }
3896
- }, ru = sa(y, 0).$name("dataBlockIndex"), nu = sa(y, 0).$name("dataByteIndex"), au = ia().$name("dataBuffer"), Ef = R([], y)`() {
3896
+ }, ru = sa(y, 0).$name("dataBlockIndex"), nu = sa(y, 0).$name("dataByteIndex"), au = ia().$name("dataBuffer"), If = R([], y)`() {
3897
3897
  let i = dataByteIndex;
3898
3898
  dataByteIndex = dataByteIndex + 1u;
3899
3899
  return i;
@@ -3999,7 +3999,7 @@ var tu = class {
3999
3999
  ${v} = bitcast<u32>(m[3][2]);
4000
4000
  ${v} = bitcast<u32>(m[3][3]);
4001
4001
  }` };
4002
- for (let [e, t] of Object.entries(iu)) t.$name(`serialize${e[0].toLocaleUpperCase()}${e.slice(1)}`).$uses({ dataBlockIndex: ru, nextByteIndex: Ef, dataBuffer: au });
4002
+ for (let [e, t] of Object.entries(iu)) t.$name(`serialize${e[0].toLocaleUpperCase()}${e.slice(1)}`).$uses({ dataBlockIndex: ru, nextByteIndex: If, dataBuffer: au });
4003
4003
  function su(e) {
4004
4004
  return `(${e.map((t, r) => `_arg_${r}`).join(", ")})`;
4005
4005
  }
@@ -4022,7 +4022,7 @@ function uu(e, t) {
4022
4022
  `);
4023
4023
  return n`${a} {\n${i}\n}`.$uses(r).$name("compoundSerializer");
4024
4024
  }
4025
- function Uf(e, t, r, n, a) {
4025
+ function Ef(e, t, r, n, a) {
4026
4026
  let i = t.map(F).reduce((u, l) => u + l, 0);
4027
4027
  if (i > a.logSizeLimit) throw new Error(`Logged data needs to fit in ${a.logSizeLimit} bytes (one of the logs requires ${i} bytes). Consider increasing the limit by passing appropriate options to tgpu.init().`);
4028
4028
  let s = uu(t, r).$name(`log${e}serializer`), o = su(t);
@@ -4037,26 +4037,26 @@ function Uf(e, t, r, n, a) {
4037
4037
  compoundSerializer${o};
4038
4038
  }`.$uses({ indexBuffer: n, dataBuffer: r, dataBlockIndex: ru, dataByteIndex: nu, compoundSerializer: s }).$name(`log${e}`);
4039
4039
  }
4040
- var Mf = ["log", "debug", "info", "warn", "error", "clear"], Pf = { logCountLimit: 64, logSizeLimit: 252, messagePrefix: " GPU " }, lu = g("/* console.log() */", de, "runtime"), Sf = class {
4040
+ var Uf = ["log", "debug", "info", "warn", "error", "clear"], Mf = { logCountLimit: 64, logSizeLimit: 252, messagePrefix: " GPU " }, lu = g("/* console.log() */", de, "runtime"), Pf = class {
4041
4041
  get logResources() {
4042
4042
  }
4043
4043
  generateLog() {
4044
4044
  return console.warn("'console.log' is only supported when resolving pipelines."), lu;
4045
4045
  }
4046
- }, zf = class {
4046
+ }, Sf = class {
4047
4047
  #e;
4048
4048
  #t;
4049
4049
  #r = 1;
4050
4050
  #n;
4051
4051
  #a;
4052
4052
  constructor(t) {
4053
- this.#e = { ...Pf, ...t[c].logOptions }, this.#t = /* @__PURE__ */ new Map();
4053
+ this.#e = { ...Mf, ...t[c].logOptions }, this.#t = /* @__PURE__ */ new Map();
4054
4054
  let r = ii({ id: y, serializedData: te(y, Math.ceil(this.#e.logSizeLimit / 4)) }).$name("SerializedLogData");
4055
4055
  this.#a = t.createMutable(te(r, this.#e.logCountLimit)).$name("dataBuffer"), this.#n = t.createMutable(io(y)).$name("indexBuffer");
4056
4056
  }
4057
4057
  generateLog(t, r, n) {
4058
- if (!Mf.includes(r)) return console.warn(`Unsupported log method '${r}' was used in TGSL.`), lu;
4059
- let a = Wl(n), i = this.#r++, s = a.filter((l) => l.dataType !== Nt), o = Uf(i, s.map((l) => l.dataType), this.#a, this.#n, this.#e), u = a.map((l) => l.dataType === Nt ? l.value : l.dataType);
4058
+ if (!Uf.includes(r)) return console.warn(`Unsupported log method '${r}' was used in TGSL.`), lu;
4059
+ let a = Rl(n), i = this.#r++, s = a.filter((l) => l.dataType !== Nt), o = Ef(i, s.map((l) => l.dataType), this.#a, this.#n, this.#e), u = a.map((l) => l.dataType === Nt ? l.value : l.dataType);
4060
4060
  return this.#t.set(i, { op: r, argTypes: u }), g(p`${t.resolve(o).value}(${s})`, de, "runtime");
4061
4061
  }
4062
4062
  get logResources() {
@@ -4068,7 +4068,7 @@ function cu(e, t) {
4068
4068
  let r = e.dataType.elementType, n = Pe(r), a = Gr(e), i = t.origin === "constant", s;
4069
4069
  return e.origin === "constant-tgpu-const-ref" ? i ? s = n ? "constant" : "constant-tgpu-const-ref" : s = n ? "runtime" : "runtime-tgpu-const-ref" : e.origin === "runtime-tgpu-const-ref" ? s = n ? "runtime" : "runtime-tgpu-const-ref" : !a && !n ? s = e.origin : i && e.origin === "constant" ? s = "constant" : s = "runtime", g(ot(e) && ot(t) ? e.value[t.value] : p`${e}[${t}]`, r, s);
4070
4070
  }
4071
- if (nr(e.dataType)) return g(ot(e) && ot(t) ? e.value[t.value] : p`${e}[${t}]`, e.dataType.primitive, e.origin === "constant" || e.origin === "constant-tgpu-const-ref" ? "constant" : "runtime");
4071
+ if (ar(e.dataType)) return g(ot(e) && ot(t) ? e.value[t.value] : p`${e}[${t}]`, e.dataType.primitive, e.origin === "constant" || e.origin === "constant-tgpu-const-ref" ? "constant" : "runtime");
4072
4072
  if (lt(e.dataType)) return cu(Ms(e), t);
4073
4073
  if (e.value instanceof Us) {
4074
4074
  let r = ps[e.value.matrix.dataType.type];
@@ -4077,7 +4077,7 @@ function cu(e, t) {
4077
4077
  if (e.dataType.type in ps) throw new Error("The only way of accessing matrix elements in TGSL is through the 'columns' property.");
4078
4078
  if (ot(e) && ot(t) || e.dataType.type === "unknown") return ri(e.value[t.value]);
4079
4079
  }
4080
- var { NodeTypeCatalog: Y } = vh, kf = ["==", "!=", "===", "!==", "<", "<=", ">", ">=", "<<", ">>", "+", "-", "*", "/", "%", "|", "^", "&", "&&", "||"], Af = ["&&", "||", "==", "!=", "===", "!==", "<", "<=", ">", ">="], ds = { "===": "==", "!==": "!=", get ">>>"() {
4080
+ var { NodeTypeCatalog: Y } = gh, zf = ["==", "!=", "===", "!==", "<", "<=", ">", ">=", "<<", ">>", "+", "-", "*", "/", "%", "|", "^", "&", "&&", "||"], kf = ["&&", "||", "==", "!=", "===", "!==", "<", "<=", ">", ">="], ds = { "===": "==", "!==": "!=", get ">>>"() {
4081
4081
  throw new Error("The `>>>` operator is unsupported in TypeGPU functions.");
4082
4082
  }, get in() {
4083
4083
  throw new Error("The `in` operator is unsupported in TypeGPU functions.");
@@ -4099,9 +4099,9 @@ var { NodeTypeCatalog: Y } = vh, kf = ["==", "!=", "===", "!==", "<", "<=", ">",
4099
4099
  throw new Error("The `||=` operator is unsupported in TypeGPU functions.");
4100
4100
  } };
4101
4101
  function ms(e, t, r) {
4102
- return r ? Af.includes(t) ? le : t === "=" ? r : e : t === "!" || t === "~" ? le : e;
4102
+ return r ? kf.includes(t) ? le : t === "=" ? r : e : t === "!" || t === "~" ? le : e;
4103
4103
  }
4104
- var Gf = { "-": Ys[c].gpuImpl }, Of = { "+": B[c].gpuImpl, "-": W[c].gpuImpl, "*": N[c].gpuImpl, "/": ga[c].gpuImpl, "**": ta[c].gpuImpl }, Bf = class {
4104
+ var Af = { "-": Ys[c].gpuImpl }, Gf = { "+": B[c].gpuImpl, "-": W[c].gpuImpl, "*": N[c].gpuImpl, "/": ga[c].gpuImpl, "**": ta[c].gpuImpl }, Of = class {
4105
4105
  #e = void 0;
4106
4106
  initGenerator(e) {
4107
4107
  this.#e = e;
@@ -4124,12 +4124,12 @@ ${this.ctx.pre}}`;
4124
4124
  }
4125
4125
  }
4126
4126
  refVariable(e, t) {
4127
- let r = this.ctx.makeNameValid(e), n = ai(t), a = g(new Pr(g(r, t, "function"), n), n, "function");
4127
+ let r = this.ctx.makeNameValid(e), n = ai(t), a = g(new Sr(g(r, t, "function"), n), n, "function");
4128
4128
  return this.ctx.defineVariable(e, a), r;
4129
4129
  }
4130
4130
  blockVariable(e, t, r, n) {
4131
4131
  let a = Pe(r), i;
4132
- n === "constant-tgpu-const-ref" || n === "runtime-tgpu-const-ref" ? i = n : n === "argument" ? a ? i = "runtime" : i = "argument" : a ? n === "constant" && e === "const" ? i = "constant" : i = "runtime" : i = jl(n) ? "this-function" : n;
4132
+ n === "constant-tgpu-const-ref" || n === "runtime-tgpu-const-ref" ? i = n : n === "argument" ? a ? i = "runtime" : i = "argument" : a ? n === "constant" && e === "const" ? i = "constant" : i = "runtime" : i = Wl(n) ? "this-function" : n;
4133
4133
  let s = g(this.ctx.makeNameValid(t), r, i);
4134
4134
  return this.ctx.defineVariable(t, s), s;
4135
4135
  }
@@ -4144,7 +4144,7 @@ ${this.ctx.pre}}`;
4144
4144
  this.ctx.expectedType = t;
4145
4145
  try {
4146
4146
  let n = this.expression(e);
4147
- return hr(n, t);
4147
+ return fr(n, t);
4148
4148
  } finally {
4149
4149
  this.ctx.expectedType = r;
4150
4150
  }
@@ -4154,12 +4154,12 @@ ${this.ctx.pre}}`;
4154
4154
  if (typeof e == "boolean") return g(e, le, "constant");
4155
4155
  if (e[0] === Y.logicalExpr || e[0] === Y.binaryExpr || e[0] === Y.assignmentExpr) {
4156
4156
  let [t, r, n, a] = e, i = this.expression(r), s = this.expression(a);
4157
- if (s.value instanceof Pr) throw new V(p`Cannot assign a ref to an existing variable '${i}', define a new variable instead.`);
4157
+ if (s.value instanceof Sr) throw new V(p`Cannot assign a ref to an existing variable '${i}', define a new variable instead.`);
4158
4158
  if (n === "==") throw new Error("Please use the === operator instead of ==");
4159
4159
  if (n === "===" && ot(i) && ot(s)) return g(i.value === s.value, le, "constant");
4160
4160
  if (i.dataType.type === "unknown") throw new V(`Left-hand side of '${n}' is of unknown type`);
4161
4161
  if (s.dataType.type === "unknown") throw new V(`Right-hand side of '${n}' is of unknown type`);
4162
- let o = Of[n];
4162
+ let o = Gf[n];
4163
4163
  if (o) return o(i, s);
4164
4164
  let u = t === Y.assignmentExpr ? [i.dataType] : void 0, [l, d] = Gn([i, s], u) ?? [i, s], h = this.ctx.resolve(l.value, l.dataType).value, f = this.ctx.resolve(d.value, d.dataType).value, w = ms(l.dataType, n, d.dataType);
4165
4165
  if (t === Y.assignmentExpr) {
@@ -4174,14 +4174,14 @@ Try '${h} = ${this.ctx.resolve(s.dataType).value}(${f})' to copy the value inste
4174
4174
  Try '${h} = ${this.ctx.resolve(s.dataType).value}(${f})' to copy the value instead.
4175
4175
  -----`);
4176
4176
  }
4177
- return g(kf.includes(n) ? `(${h} ${ds[n] ?? n} ${f})` : `${h} ${ds[n] ?? n} ${f}`, w, "runtime");
4177
+ return g(zf.includes(n) ? `(${h} ${ds[n] ?? n} ${f})` : `${h} ${ds[n] ?? n} ${f}`, w, "runtime");
4178
4178
  }
4179
4179
  if (e[0] === Y.postUpdate) {
4180
4180
  let [t, r, n] = e, a = this.expression(n), i = this.ctx.resolve(a.value, a.dataType).value;
4181
4181
  return g(`${i}${r}`, a.dataType, "runtime");
4182
4182
  }
4183
4183
  if (e[0] === Y.unaryExpr) {
4184
- let [t, r, n] = e, a = this.expression(n), i = Gf[r];
4184
+ let [t, r, n] = e, a = this.expression(n), i = Af[r];
4185
4185
  if (i) return i(a);
4186
4186
  let s = this.ctx.resolve(a.value, a.dataType).value, o = ms(a.dataType, r);
4187
4187
  return g(`${r}${s}`, o, "runtime");
@@ -4202,7 +4202,7 @@ Try '${h} = ${this.ctx.resolve(s.dataType).value}(${f})' to copy the value inste
4202
4202
  return o;
4203
4203
  }
4204
4204
  if (e[0] === Y.numericLiteral) {
4205
- let t = typeof e[1] == "string" ? Pa(Ff(e[1])) : Pa(e[1]);
4205
+ let t = typeof e[1] == "string" ? Pa(Cf(e[1])) : Pa(e[1]);
4206
4206
  if (!t) throw new Error(`Invalid numeric literal ${e[1]}`);
4207
4207
  return t;
4208
4208
  }
@@ -4225,7 +4225,7 @@ Try '${h} = ${this.ctx.resolve(s.dataType).value}(${f})' to copy the value inste
4225
4225
  if (u) {
4226
4226
  let l = o.map((d, h) => {
4227
4227
  let f = u.argTypes[h];
4228
- return hr(d, f, !1);
4228
+ return fr(d, f, !1);
4229
4229
  });
4230
4230
  return this.ctx.withResetIndentLevel(() => {
4231
4231
  let d = this.ctx.resolve(u);
@@ -4249,11 +4249,11 @@ Try '${h} = ${this.ctx.resolve(s.dataType).value}(${f})' to copy the value inste
4249
4249
  });
4250
4250
  else {
4251
4251
  let l = n.map((d) => this.expression(d));
4252
- i === "keep" ? o = l : i === "unify" ? o = Gn(l) ?? l : o = i(...l).map((d, h) => [d, l[h]]).map(([d, h]) => hr(h, d));
4252
+ i === "keep" ? o = l : i === "unify" ? o = Gn(l) ?? l : o = i(...l).map((d, h) => [d, l[h]]).map(([d, h]) => fr(h, d));
4253
4253
  }
4254
4254
  if (a.value instanceof zi) return this.ctx.generateLog(a.value.op, o);
4255
4255
  let u = a.value(...o);
4256
- if (!Cl(u)) throw new Error("Functions running in codegen mode must return snippets");
4256
+ if (!Bl(u)) throw new Error("Functions running in codegen mode must return snippets");
4257
4257
  return u;
4258
4258
  } catch (o) {
4259
4259
  throw o instanceof Br ? o : new Br(o, [{ toString: () => `fn:${x(a.value)}` }]);
@@ -4267,7 +4267,7 @@ Try '${h} = ${this.ctx.resolve(s.dataType).value}(${f})' to copy the value inste
4267
4267
  if (o === void 0) throw new V(`Missing property ${i} in object literal for struct ${r}`);
4268
4268
  let u = this.typedExpression(o, s);
4269
4269
  return [i, u];
4270
- })), a = Fl(r, n);
4270
+ })), a = Cl(r, n);
4271
4271
  return g(p`${this.ctx.resolve(r).value}(${a})`, r, "runtime");
4272
4272
  }
4273
4273
  if (e[0] === Y.arrayExpr) {
@@ -4278,7 +4278,7 @@ Try '${h} = ${this.ctx.resolve(s.dataType).value}(${f})' to copy the value inste
4278
4278
  let o = r.map((l) => {
4279
4279
  let d = this.expression(l);
4280
4280
  if (d.origin === "argument" && !Pe(d.dataType) || !Gr(d)) {
4281
- let h = this.ctx.resolve(d.value, d.dataType).value, f = this.ctx.resolve(er(d.dataType)).value;
4281
+ let h = this.ctx.resolve(d.value, d.dataType).value, f = this.ctx.resolve(tr(d.dataType)).value;
4282
4282
  throw new V(`'${h}' reference cannot be used in an array constructor.
4283
4283
  -----
4284
4284
  Try '${f}(${h})' or 'arrayOf(${f}, count)([...])' to copy the value instead.
@@ -4289,14 +4289,14 @@ Try '${f}(${h})' or 'arrayOf(${f}, count)([...])' to copy the value instead.
4289
4289
  if (o.length === 0) throw new V("Cannot infer the type of an empty array literal.");
4290
4290
  let u = Gn(o);
4291
4291
  if (!u) throw new V("The given values cannot be automatically converted to a common type. Consider wrapping the array in an appropriate schema");
4292
- i = u, a = er(i[0]?.dataType);
4292
+ i = u, a = tr(i[0]?.dataType);
4293
4293
  }
4294
4294
  let s = `array<${this.ctx.resolve(a).value}, ${i.length}>`;
4295
4295
  return g(p`${s}(${i})`, te[c].jsImpl(a, i.length), "runtime");
4296
4296
  }
4297
4297
  if (e[0] === Y.stringLiteral) return g(e[1], Nt, "constant");
4298
4298
  if (e[0] === Y.preUpdate) throw new Error("Cannot use pre-updates in TGSL.");
4299
- Cf(e);
4299
+ Bf(e);
4300
4300
  }
4301
4301
  functionDefinition(e) {
4302
4302
  return this.block(e);
@@ -4308,7 +4308,7 @@ Try '${f}(${h})' or 'arrayOf(${f}, count)([...])' to copy the value instead.
4308
4308
  let t = e[1];
4309
4309
  if (t !== void 0) {
4310
4310
  let r = this.ctx.topFunctionReturnType, n = r ? this.typedExpression(t, r) : this.expression(t);
4311
- if (n.value instanceof Pr) throw new V(p`Cannot return references, returning '${n.value.snippet}'`);
4311
+ if (n.value instanceof Sr) throw new V(p`Cannot return references, returning '${n.value.snippet}'`);
4312
4312
  if (n.origin === "argument" && !Pe(n.dataType) && this.ctx.topFunctionScope?.functionType === "normal") throw new V(p`Cannot return references to arguments, returning '${n}'. Copy the argument before returning it.`);
4313
4313
  if (!r && !Gr(n) && n.origin !== "this-function") {
4314
4314
  let a = this.ctx.resolve(n.value, n.dataType).value, i = this.ctx.resolve(On(n.dataType)).value;
@@ -4317,7 +4317,7 @@ Try '${f}(${h})' or 'arrayOf(${f}, count)([...])' to copy the value instead.
4317
4317
  Try 'return ${i}(${a});' instead.
4318
4318
  -----`);
4319
4319
  }
4320
- return n = hr(n, On(n.dataType), !1), Ct(n.dataType.type !== "unknown", "Return type should be known"), this.ctx.reportReturnType(n.dataType), p`${this.ctx.pre}return ${n};`;
4320
+ return n = fr(n, On(n.dataType), !1), Ct(n.dataType.type !== "unknown", "Return type should be known"), this.ctx.reportReturnType(n.dataType), p`${this.ctx.pre}return ${n};`;
4321
4321
  }
4322
4322
  return `${this.ctx.pre}return;`;
4323
4323
  }
@@ -4332,10 +4332,10 @@ ${this.ctx.pre}else ${o}` : p`${this.ctx.pre}if (${i}) ${s}`;
4332
4332
  if (!i) throw new Error(`Cannot create variable '${n}' without an initial value.`);
4333
4333
  let s = Gr(i), o = i.dataType, u = Pe(o);
4334
4334
  if (_n(i.dataType)) throw new Error(`Cannot create variable '${n}' with loose data type.`);
4335
- if (i.value instanceof Pr) {
4335
+ if (i.value instanceof Sr) {
4336
4336
  if (i.dataType.type !== "unknown") throw new V("Cannot store d.ref() in a variable if it references another value. Copy the value passed into d.ref() instead.");
4337
- let d = i.value.snippet, h = this.refVariable(n, er(d.dataType));
4338
- return p`${this.ctx.pre}var ${h} = ${hr(d, d.dataType, !1)};`;
4337
+ let d = i.value.snippet, h = this.refVariable(n, tr(d.dataType));
4338
+ return p`${this.ctx.pre}var ${h} = ${fr(d, d.dataType, !1)};`;
4339
4339
  }
4340
4340
  if (s) {
4341
4341
  if (r === Y.const) i.origin === "argument" ? t = "let" : u && (t = i.origin === "constant" ? "const" : "let");
@@ -4360,14 +4360,14 @@ ${this.ctx.pre}else ${o}` : p`${this.ctx.pre}if (${i}) ${s}`;
4360
4360
  else if (i.origin === "runtime-tgpu-const-ref") t = "let";
4361
4361
  else {
4362
4362
  if (t = "let", !lt(o)) {
4363
- let d = Nl(i.origin, er(o));
4363
+ let d = Fl(i.origin, tr(o));
4364
4364
  Ct(d !== void 0, `Creating pointer type from origin ${i.origin}`), o = d;
4365
4365
  }
4366
- i.value instanceof Pr || (o = Ll(o));
4366
+ i.value instanceof Sr || (o = Nl(o));
4367
4367
  }
4368
4368
  }
4369
- let l = this.blockVariable(t, n, er(o), i.origin);
4370
- return p`${this.ctx.pre}${t} ${l.value} = ${hr(i, o, !1)};`;
4369
+ let l = this.blockVariable(t, n, tr(o), i.origin);
4370
+ return p`${this.ctx.pre}${t} ${l.value} = ${fr(i, o, !1)};`;
4371
4371
  }
4372
4372
  if (e[0] === Y.block) return this.block(e);
4373
4373
  if (e[0] === Y.for) {
@@ -4381,16 +4381,16 @@ ${this.ctx.pre}else ${o}` : p`${this.ctx.pre}if (${i}) ${s}`;
4381
4381
  return e[0] === Y.continue ? `${this.ctx.pre}continue;` : e[0] === Y.break ? `${this.ctx.pre}break;` : `${this.ctx.pre}${this.ctx.resolve(this.expression(e).value).value};`;
4382
4382
  }
4383
4383
  };
4384
- function Cf(e) {
4384
+ function Bf(e) {
4385
4385
  throw new Error(`'${Dt(e)}' was not handled by the WGSL generator.`);
4386
4386
  }
4387
- function Ff(e) {
4387
+ function Cf(e) {
4388
4388
  return /^0x[0-9a-f]+$/i.test(e) ? Number.parseInt(e) : /^0b[01]+$/i.test(e) ? Number.parseInt(e.slice(2), 2) : Number.parseFloat(e);
4389
4389
  }
4390
4390
  function Wn(e) {
4391
4391
  return typeof e != "object" || e[0] !== Y.block ? [Y.block, [e]] : e;
4392
4392
  }
4393
- var Nf = new Bf(), pu = Nf, du = "#CATCHALL#", Lf = class {
4393
+ var Ff = new Of(), pu = Ff, du = "#CATCHALL#", Nf = class {
4394
4394
  _stack = [];
4395
4395
  _itemDepth = 0;
4396
4396
  get itemDepth() {
@@ -4472,7 +4472,7 @@ var Nf = new Bf(), pu = Nf, du = "#CATCHALL#", Lf = class {
4472
4472
  }
4473
4473
  throw new Error("No block scope found to define a variable in.");
4474
4474
  }
4475
- }, Yn = ["", " ", " ", " ", " ", " ", " ", " ", " "], Ea = Yn.length - 1, Rf = class {
4475
+ }, Yn = ["", " ", " ", " ", " ", " ", " ", " ", " "], Ea = Yn.length - 1, Lf = class {
4476
4476
  identLevel = 0;
4477
4477
  get pre() {
4478
4478
  return Yn[this.identLevel] ?? Yn[Ea].repeat(this.identLevel / Ea) + Yn[this.identLevel % Ea];
@@ -4496,8 +4496,8 @@ var Nf = new Bf(), pu = Nf, du = "#CATCHALL#", Lf = class {
4496
4496
  }, mu = class {
4497
4497
  #e;
4498
4498
  #t;
4499
- _indentController = new Rf();
4500
- _itemStateStack = new Lf();
4499
+ _indentController = new Lf();
4500
+ _itemStateStack = new Nf();
4501
4501
  #r = [];
4502
4502
  _declarations = [];
4503
4503
  _varyingLocations;
@@ -4513,10 +4513,10 @@ var Nf = new Bf(), pu = Nf, du = "#CATCHALL#", Lf = class {
4513
4513
  enableExtensions;
4514
4514
  expectedType;
4515
4515
  constructor(e) {
4516
- this.enableExtensions = e.enableExtensions, this.#t = e.shaderGenerator ?? pu, this.#a = e.root ? new zf(e.root) : new Sf(), this.#e = e.namespace[c];
4516
+ this.enableExtensions = e.enableExtensions, this.#t = e.shaderGenerator ?? pu, this.#a = e.root ? new Sf(e.root) : new Pf(), this.#e = e.namespace[c];
4517
4517
  }
4518
4518
  getUniqueName(e) {
4519
- return Bh(this.#e, e);
4519
+ return Oh(this.#e, e);
4520
4520
  }
4521
4521
  makeNameValid(e) {
4522
4522
  return this.#e.nameRegistry.makeValid(e);
@@ -4597,13 +4597,13 @@ var Nf = new Bf(), pu = Nf, du = "#CATCHALL#", Lf = class {
4597
4597
  let o = [...a.reportedReturnTypes];
4598
4598
  if (o.length === 0) s = de;
4599
4599
  else {
4600
- let u = kl(o);
4600
+ let u = zl(o);
4601
4601
  u && !u.hasImplicitConversions && (s = u.targetType);
4602
4602
  }
4603
4603
  if (!s) throw new Error(`Expected function to have a single return type, got [${o.join(", ")}]. Cast explicitly to the desired type.`);
4604
- s = er(s);
4604
+ s = tr(s);
4605
4605
  }
4606
- return { head: Wf(this, r, s), body: i, returnType: s };
4606
+ return { head: Rf(this, r, s), body: i, returnType: s };
4607
4607
  } finally {
4608
4608
  t && this._itemStateStack.popFunctionScope(), this.#e.nameRegistry.popFunctionScope();
4609
4609
  }
@@ -4621,7 +4621,7 @@ var Nf = new Bf(), pu = Nf, du = "#CATCHALL#", Lf = class {
4621
4621
  }
4622
4622
  readSlot(e) {
4623
4623
  let t = this._itemStateStack.readSlot(e);
4624
- if (t === void 0) throw new Al(e);
4624
+ if (t === void 0) throw new kl(e);
4625
4625
  return t;
4626
4626
  }
4627
4627
  withSlots(e, t) {
@@ -4677,7 +4677,7 @@ var Nf = new Bf(), pu = Nf, du = "#CATCHALL#", Lf = class {
4677
4677
  let r;
4678
4678
  if (Jr(e)) r = g(Fo(this, e), de, "runtime");
4679
4679
  else if (Si(e) || Pi(e)) r = this.resolve(this.unwrap(e));
4680
- else if (Gl(e)) r = e[U](this);
4680
+ else if (Al(e)) r = e[U](this);
4681
4681
  else if (jn(e)) {
4682
4682
  let a = this.#e.shelllessRepo.get(e, void 0);
4683
4683
  if (!a) throw new Error(`Couldn't resolve ${e.name}. Make sure it's a function that accepts no arguments, or call it from another TypeGPU function.`);
@@ -4700,7 +4700,7 @@ var Nf = new Bf(), pu = Nf, du = "#CATCHALL#", Lf = class {
4700
4700
  if (Mi(e)) return this.withSlots(e[Or].pairs, () => this.resolve(e[Or].inner, t));
4701
4701
  if (ui(e) || jn(e)) {
4702
4702
  if (this._itemStateStack.itemDepth === 0) try {
4703
- this.pushMode(new Ol());
4703
+ this.pushMode(new Gl());
4704
4704
  let r = Os(this, () => this._getOrInstantiate(e));
4705
4705
  return g(`${[...this._declarations].join(`
4706
4706
 
@@ -4738,11 +4738,11 @@ var Nf = new Bf(), pu = Nf, du = "#CATCHALL#", Lf = class {
4738
4738
  e !== void 0 && Ct(t?.type === e, "Unexpected mode");
4739
4739
  }
4740
4740
  get mode() {
4741
- return this.#r[this.#r.length - 1] ?? Bl;
4741
+ return this.#r[this.#r.length - 1] ?? Ol;
4742
4742
  }
4743
4743
  };
4744
4744
  function jr(e, t) {
4745
- let r = new mu(t), n = (t.config ? r.withSlots(t.config(new No([])).bindings, () => r.resolve(e)) : r.resolve(e)).value, a = r.bindGroupLayoutsToPlaceholderMap, i = [], s = new Set([...a.keys()].map((h) => h.index).filter((h) => h !== void 0)), o = Dh(s), u = r.fixedBindings.map((h, f) => [String(f), h.layoutEntry]), l = () => {
4745
+ let r = new mu(t), n = (t.config ? r.withSlots(t.config(new No([])).bindings, () => r.resolve(e)) : r.resolve(e)).value, a = r.bindGroupLayoutsToPlaceholderMap, i = [], s = new Set([...a.keys()].map((h) => h.index).filter((h) => h !== void 0)), o = jh(s), u = r.fixedBindings.map((h, f) => [String(f), h.layoutEntry]), l = () => {
4746
4746
  let h = o.next().value, f = Qo(Object.fromEntries(u));
4747
4747
  return i[h] = f, n = n.replaceAll(du, String(h)), [h, new eu(f, Object.fromEntries(r.fixedBindings.map((w, $) => [String($), w.resource])))];
4748
4748
  }, d = u.length > 0 ? l() : void 0;
@@ -4755,7 +4755,7 @@ function jr(e, t) {
4755
4755
 
4756
4756
  ${n}`), { code: n, usedBindGroupLayouts: i, catchall: d, logResources: r.logResources };
4757
4757
  }
4758
- function Wf(e, t, r) {
4758
+ function Rf(e, t, r) {
4759
4759
  let n = t.map((a) => `${a.value}: ${e.resolve(a.dataType).value}`).join(", ");
4760
4760
  return r.type !== "void" ? `(${n}) -> ${hi(r)}${e.resolve(r).value} ` : `(${n}) `;
4761
4761
  }
@@ -4767,16 +4767,16 @@ function fu(e) {
4767
4767
  let t = e;
4768
4768
  return t?.resourceType === "render-pipeline" && !!t[c];
4769
4769
  }
4770
- function jf(e) {
4770
+ function Wf(e) {
4771
4771
  return fu(e) || hu(e);
4772
4772
  }
4773
4773
  function Ya(e, t) {
4774
- return Array.isArray(e) ? qf(e, t) : Yf(e);
4774
+ return Array.isArray(e) ? Yf(e, t) : Df(e);
4775
4775
  }
4776
- function Df(e, t) {
4776
+ function jf(e, t) {
4777
4777
  return Array.isArray(e) ? Ya(e, t).code : Ya(e).code;
4778
4778
  }
4779
- function Yf(e) {
4779
+ function Df(e) {
4780
4780
  let { template: t, externals: r, shaderGenerator: n, names: a = "strict", config: i, enableExtensions: s } = e;
4781
4781
  t || console.warn("Calling resolve with an empty template is deprecated and will soon return an empty string. Consider using the 'tgpu.resolve(resolvableArray, options)' API instead.");
4782
4782
  let o = {};
@@ -4786,21 +4786,21 @@ function Yf(e) {
4786
4786
  }, toString: () => "<root>" };
4787
4787
  return jr(u, { namespace: typeof a == "string" ? Kr({ names: a }) : a, enableExtensions: s, shaderGenerator: n, config: i, root: yu(Object.values(r)) });
4788
4788
  }
4789
- function qf(e, t) {
4789
+ function Yf(e, t) {
4790
4790
  let { shaderGenerator: r, names: n = "strict", config: a, enableExtensions: i } = t ?? {}, s = { [c]: !0, [U](o) {
4791
4791
  return e.forEach((u) => o.resolve(u)), g("", de, "runtime");
4792
4792
  }, toString: () => "<root>" };
4793
4793
  return jr(s, { namespace: typeof n == "string" ? Kr({ names: n }) : n, enableExtensions: i, shaderGenerator: r, config: a, root: yu(e) });
4794
4794
  }
4795
4795
  function yu(e) {
4796
- let t = e.filter(jf);
4796
+ let t = e.filter(Wf);
4797
4797
  if (t.length > 1) throw new Error(`Found ${t.length} pipelines but can only resolve one at a time.`);
4798
4798
  return t[0]?.[c].branch;
4799
4799
  }
4800
- function Vf(e) {
4800
+ function qf(e) {
4801
4801
  let t = ct() ?? new mu({ namespace: Kr(), shaderGenerator: pu }), r = [1, 1, 1], n = [1, 1, 1], a = [r[0] * n[0], r[1] * n[1], r[2] * n[2]], i = /* @__PURE__ */ new Map(), s = Array.from({ length: r[0] }, () => Array.from({ length: r[1] }, () => Array.from({ length: r[2] }, () => /* @__PURE__ */ new Map()))), o = Array.from({ length: a[0] }, () => Array.from({ length: a[1] }, () => Array.from({ length: a[2] }, () => /* @__PURE__ */ new Map()))), u = Array.from({ length: a[0] }, (l, d) => Array.from({ length: a[1] }, (h, f) => Array.from({ length: a[2] }, (w, $) => {
4802
4802
  let S = Math.floor(d / n[0]), O = Math.floor(f / n[1]), G = Math.floor($ / n[2]);
4803
- return new zl(i, { private: o[d][f][$], workgroup: s[S][O][G] });
4803
+ return new Sl(i, { private: o[d][f][$], workgroup: s[S][O][G] });
4804
4804
  })));
4805
4805
  t.pushMode(u[0][0][0]);
4806
4806
  try {
@@ -4809,14 +4809,14 @@ function Vf(e) {
4809
4809
  t.popMode("simulate");
4810
4810
  }
4811
4811
  }
4812
- function Jf(e, t, r, n) {
4813
- return new Xf(e, t, r, n);
4812
+ function Vf(e, t, r, n) {
4813
+ return new Jf(e, t, r, n);
4814
4814
  }
4815
4815
  function $i(e) {
4816
4816
  let t = e;
4817
4817
  return t?.resourceType === "query-set" && !!t[c];
4818
4818
  }
4819
- var Xf = class {
4819
+ var Jf = class {
4820
4820
  constructor(e, t, r, n) {
4821
4821
  this.type = t, this.count = r, this.rawQuerySet = n, this.#e = e.device, this._ownQuerySet = !n, this._querySet = n || null;
4822
4822
  }
@@ -4913,18 +4913,18 @@ var Xf = class {
4913
4913
  [U](e) {
4914
4914
  return e.resolve(this.#e);
4915
4915
  }
4916
- }, P = (e) => Io(e ?? 0), tt = (e) => Eo(e ?? 0), Mr = (e) => Uo(e ?? 0), Zf = { f32: (e) => P(e[0]), f16: (e) => Mr(e[0]).x, i32: (e) => tt(e[0]), u32: (e) => e[0] ?? 0, bool: (e) => !!e[0], vec2f: (e) => I(P(e[0]), P(e[1])), vec3f: (e) => T(P(e[0]), P(e[1]), P(e[2])), vec4f: (e) => C(P(e[0]), P(e[1]), P(e[2]), P(e[3])), vec2h(e) {
4917
- let t = Mr(e[0]);
4916
+ }, P = (e) => Io(e ?? 0), tt = (e) => Eo(e ?? 0), Pr = (e) => Uo(e ?? 0), Xf = { f32: (e) => P(e[0]), f16: (e) => Pr(e[0]).x, i32: (e) => tt(e[0]), u32: (e) => e[0] ?? 0, bool: (e) => !!e[0], vec2f: (e) => I(P(e[0]), P(e[1])), vec3f: (e) => T(P(e[0]), P(e[1]), P(e[2])), vec4f: (e) => C(P(e[0]), P(e[1]), P(e[2]), P(e[3])), vec2h(e) {
4917
+ let t = Pr(e[0]);
4918
4918
  return _t(t.x, t.y);
4919
4919
  }, vec3h(e) {
4920
- let t = Mr(e[0]), r = Mr(e[1]);
4920
+ let t = Pr(e[0]), r = Pr(e[1]);
4921
4921
  return Tt(t.x, t.y, r.x);
4922
4922
  }, vec4h(e) {
4923
- let t = Mr(e[0]), r = Mr(e[1]);
4923
+ let t = Pr(e[0]), r = Pr(e[1]);
4924
4924
  return $t(t.x, t.y, r.x, r.y);
4925
4925
  }, vec2i: (e) => pe(tt(e[0]), tt(e[1])), vec3i: (e) => Fe(tt(e[0]), tt(e[1]), tt(e[2])), vec4i: (e) => Se(tt(e[0]), tt(e[1]), tt(e[2]), tt(e[3])), vec2u: (e) => Be(e[0] ?? 0, e[1] ?? 0), vec3u: (e) => ve(e[0] ?? 0, e[1] ?? 0, e[2] ?? 0), vec4u: (e) => Oe(e[0] ?? 0, e[1] ?? 0, e[2] ?? 0, e[3] ?? 0), "vec2<bool>": (e) => qr(!!e[0], !!e[1]), "vec3<bool>": (e) => Yr(!!e[0], !!e[1], !!e[2]), "vec4<bool>": (e) => Dr(!!e[0], !!e[1], !!e[2], !!e[3]), mat2x2f: (e) => St(P(e[0]), P(e[1]), P(e[2]), P(e[3])), mat3x3f: (e) => zt(P(e[0]), P(e[1]), P(e[2]), P(e[4]), P(e[5]), P(e[6]), P(e[8]), P(e[9]), P(e[10])), mat4x4f: (e) => H(P(e[0]), P(e[1]), P(e[2]), P(e[3]), P(e[4]), P(e[5]), P(e[6]), P(e[7]), P(e[8]), P(e[9]), P(e[10]), P(e[11]), P(e[12]), P(e[13]), P(e[14]), P(e[15])) };
4926
- function Qf(e, t) {
4927
- let r = Zf[t.type];
4926
+ function Zf(e, t) {
4927
+ let r = Xf[t.type];
4928
4928
  if (r) return r(e);
4929
4929
  if (xe(t)) {
4930
4930
  let n = Object.keys(t.propTypes), a = Object.values(t.propTypes), i = qa(e, a);
@@ -4940,18 +4940,18 @@ function qa(e, t) {
4940
4940
  let r = 0;
4941
4941
  return t.map((n) => {
4942
4942
  if (!Vr(n)) return n;
4943
- let a = Math.ceil(F(n) / 4), i = Qf(e.subarray(r, r + a), n);
4943
+ let a = Math.ceil(F(n) / 4), i = Zf(e.subarray(r, r + a), n);
4944
4944
  return r += a, i;
4945
4945
  });
4946
4946
  }
4947
- function Kf(e, t) {
4948
- return qa(e, t).map(Zl);
4947
+ function Qf(e, t) {
4948
+ return qa(e, t).map(Xl);
4949
4949
  }
4950
4950
  function Va(e) {
4951
4951
  let { indexBuffer: t, dataBuffer: r, logIdToMeta: n, options: a } = e;
4952
4952
  r.read().then((i) => {
4953
4953
  i.filter((s) => s.id).forEach(({ id: s, serializedData: o }) => {
4954
- let { argTypes: u, op: l } = n.get(s), d = Kf(new Uint32Array(o), u);
4954
+ let { argTypes: u, op: l } = n.get(s), d = Qf(new Uint32Array(o), u);
4955
4955
  d.length === 0 && d.push(""), console[l](`%c${a.messagePrefix}%c ${d[0]}`, "background: #936ff5; color: white;", "color: inherit; background: none", ...d.slice(1));
4956
4956
  });
4957
4957
  }), t.read().then((i) => {
@@ -4985,10 +4985,10 @@ function Ja({ root: e, priors: t }) {
4985
4985
  await n(s, o);
4986
4986
  });
4987
4987
  }
4988
- function Hf(e, t, r) {
4989
- return new ey(new ty(e, t, r), {});
4988
+ function Kf(e, t, r) {
4989
+ return new Hf(new ey(e, t, r), {});
4990
4990
  }
4991
- var ey = class sn {
4991
+ var Hf = class sn {
4992
4992
  constructor(t, r) {
4993
4993
  this._core = t, this._priors = r, this[c] = { get rawPipeline() {
4994
4994
  return t.unwrap().pipeline;
@@ -5037,7 +5037,7 @@ var ey = class sn {
5037
5037
  $name(t) {
5038
5038
  return re(this._core, t), this;
5039
5039
  }
5040
- }, ty = class {
5040
+ }, ey = class {
5041
5041
  constructor(e, t, r) {
5042
5042
  this.branch = e, this._slotBindings = t, this._entryFn = r;
5043
5043
  }
@@ -5070,7 +5070,7 @@ var ey = class sn {
5070
5070
  }
5071
5071
  };
5072
5072
  function fs(e, t = "vertex") {
5073
- return new ry(e, t);
5073
+ return new ty(e, t);
5074
5074
  }
5075
5075
  function xu(e) {
5076
5076
  return e?.resourceType === "vertex-layout";
@@ -5098,13 +5098,13 @@ function qn(e, t, r, n, a) {
5098
5098
  }));
5099
5099
  }
5100
5100
  if ("type" in t && typeof t.type == "string") {
5101
- if (Dl.includes(t.type)) return { _layout: e, format: t.type, offset: r };
5102
- let i = Yl[t.type];
5101
+ if (jl.includes(t.type)) return { _layout: e, format: t.type, offset: r };
5102
+ let i = Dl[t.type];
5103
5103
  if (i) return { _layout: e, format: i, offset: r };
5104
5104
  }
5105
5105
  throw new Error(`Unsupported data used in vertex layout: ${String(t)}`);
5106
5106
  }
5107
- var ry = class {
5107
+ var ty = class {
5108
5108
  constructor(e, t) {
5109
5109
  this.schemaForCount = e, this.stepMode = t;
5110
5110
  let r = e(0);
@@ -5127,13 +5127,13 @@ var ry = class {
5127
5127
  return re(this, e), this;
5128
5128
  }
5129
5129
  };
5130
- function ny(e) {
5130
+ function ry(e) {
5131
5131
  return typeof e?.loadOp == "string";
5132
5132
  }
5133
- function ay(e, t) {
5133
+ function ny(e, t) {
5134
5134
  if (Jr(e)) {
5135
5135
  if (Et(e)) return [];
5136
- if (!ny(t)) throw new Error("Expected a single color attachment, not a record.");
5136
+ if (!ry(t)) throw new Error("Expected a single color attachment, not a record.");
5137
5137
  return [t];
5138
5138
  }
5139
5139
  let r = [];
@@ -5146,14 +5146,14 @@ function ay(e, t) {
5146
5146
  }
5147
5147
  return r;
5148
5148
  }
5149
- function iy(e) {
5149
+ function ay(e) {
5150
5150
  return typeof e?.format == "string";
5151
5151
  }
5152
- function sy(e, t) {
5152
+ function iy(e, t) {
5153
5153
  if (Jr(e)) {
5154
5154
  if (As(e)) return [];
5155
5155
  if (e.type === "decorated") return [];
5156
- if (!iy(t)) throw new Error("Expected a single color target configuration, not a record.");
5156
+ if (!ay(t)) throw new Error("Expected a single color target configuration, not a record.");
5157
5157
  return [t];
5158
5158
  }
5159
5159
  let r = [];
@@ -5167,9 +5167,9 @@ function sy(e, t) {
5167
5167
  return r;
5168
5168
  }
5169
5169
  function bu(e) {
5170
- return new oy(new uy(e), {});
5170
+ return new sy(new oy(e), {});
5171
5171
  }
5172
- var oy = class Je {
5172
+ var sy = class Je {
5173
5173
  [c];
5174
5174
  resourceType = "render-pipeline";
5175
5175
  [Ie];
@@ -5223,7 +5223,7 @@ var oy = class Je {
5223
5223
  return new Je(i.core, { ...i.priors, indexBuffer: { buffer: t, indexFormat: s[o.type], offsetBytes: r !== void 0 ? r * F(o) : void 0, sizeBytes: a !== void 0 ? a * F(o) : void 0 } });
5224
5224
  }
5225
5225
  setupRenderPass(t) {
5226
- let r = this[c], n = r.core.unwrap(), { branch: a, fragmentFn: i } = r.core.options, s = i ? ay(i.shell.out, r.priors.colorAttachment ?? {}).map((f) => wn(f.view) ? { ...f, view: a.unwrap(f.view).createView() } : xn(f.view) ? { ...f, view: a.unwrap(f.view) } : f) : [null], o = { label: x(r.core) ?? "<unnamed>", colorAttachments: s, ...wu(r.priors, a) }, u = r.priors.depthStencilAttachment;
5226
+ let r = this[c], n = r.core.unwrap(), { branch: a, fragmentFn: i } = r.core.options, s = i ? ny(i.shell.out, r.priors.colorAttachment ?? {}).map((f) => wn(f.view) ? { ...f, view: a.unwrap(f.view).createView() } : xn(f.view) ? { ...f, view: a.unwrap(f.view) } : f) : [null], o = { label: x(r.core) ?? "<unnamed>", colorAttachments: s, ...wu(r.priors, a) }, u = r.priors.depthStencilAttachment;
5227
5227
  if (u !== void 0) {
5228
5228
  let f = wn(u.view) ? a.unwrap(u.view).createView() : xn(u.view) ? a.unwrap(u.view) : u.view;
5229
5229
  o.depthStencilAttachment = { ...u, view: f };
@@ -5256,11 +5256,11 @@ var oy = class Je {
5256
5256
  let { logResources: o } = s.core.unwrap(), { branch: u } = s.core.options, { buffer: l, indexFormat: d, offsetBytes: h, sizeBytes: f } = s.priors.indexBuffer, w = u.device.createCommandEncoder(), $ = this.setupRenderPass(w);
5257
5257
  Sa(l) ? $.setIndexBuffer(l, d, h, f) : $.setIndexBuffer(u.unwrap(l), d, h, f), $.drawIndexed(t, r, n, a, i), $.end(), u.device.queue.submit([w.finish()]), o && Va(o), s.priors.performanceCallback && Ja({ root: u, priors: s.priors });
5258
5258
  }
5259
- }, uy = class {
5259
+ }, oy = class {
5260
5260
  constructor(e) {
5261
5261
  this.options = e;
5262
- let t = Ch(e.vertexFn.shell.in ?? {}, e.vertexAttribs);
5263
- this._vertexBufferLayouts = t.bufferDefinitions, this.usedVertexLayouts = t.usedVertexLayouts, this._targets = e.fragmentFn && e.targets ? sy(e.fragmentFn.shell.out, e.targets) : [null];
5262
+ let t = Bh(e.vertexFn.shell.in ?? {}, e.vertexAttribs);
5263
+ this._vertexBufferLayouts = t.bufferDefinitions, this.usedVertexLayouts = t.usedVertexLayouts, this._targets = e.fragmentFn && e.targets ? iy(e.fragmentFn.shell.out, e.targets) : [null];
5264
5264
  }
5265
5265
  [c] = !0;
5266
5266
  usedVertexLayouts;
@@ -5268,7 +5268,7 @@ var oy = class Je {
5268
5268
  _vertexBufferLayouts;
5269
5269
  _targets;
5270
5270
  [U](e) {
5271
- let { vertexFn: t, fragmentFn: r, slotBindings: n } = this.options, a = ly(t.shell.out, r?.shell.in, x(t) ?? "<unnamed>", x(r) ?? "<unnamed>");
5271
+ let { vertexFn: t, fragmentFn: r, slotBindings: n } = this.options, a = uy(t.shell.out, r?.shell.in, x(t) ?? "<unnamed>", x(r) ?? "<unnamed>");
5272
5272
  return e.withVaryingLocations(a, () => e.withSlots(n, () => (e.resolve(t), r && e.resolve(r), g("", de, "runtime"))));
5273
5273
  }
5274
5274
  toString() {
@@ -5294,7 +5294,7 @@ var oy = class Je {
5294
5294
  return this._memo;
5295
5295
  }
5296
5296
  };
5297
- function ly(e, t, r, n) {
5297
+ function uy(e, t, r, n) {
5298
5298
  let a = {}, i = /* @__PURE__ */ new Set();
5299
5299
  function s(u, l) {
5300
5300
  a[u] = l, i.add(l);
@@ -5314,11 +5314,11 @@ function ly(e, t, r, n) {
5314
5314
  }
5315
5315
  return a;
5316
5316
  }
5317
- function cy(e) {
5317
+ function ly(e) {
5318
5318
  if (e.includes(0)) throw new Error("Size and workgroupSize cannot contain zeroes.");
5319
5319
  return ve(e[0] ?? 1, e[1] ?? 1, e[2] ?? 1);
5320
5320
  }
5321
- var py = [ve(1, 1, 1), ve(256, 1, 1), ve(16, 16, 1), ve(8, 8, 4)], dy = class $u {
5321
+ var cy = [ve(1, 1, 1), ve(256, 1, 1), ve(16, 16, 1), ve(8, 8, 4)], py = class $u {
5322
5322
  #e;
5323
5323
  #t;
5324
5324
  #r;
@@ -5331,7 +5331,7 @@ var py = [ve(1, 1, 1), ve(256, 1, 1), ve(16, 16, 1), ve(8, 8, 4)], dy = class $u
5331
5331
  return new $u(this.#e, this.#t.with(t), this.#r, this.#n);
5332
5332
  }
5333
5333
  dispatchThreads(...t) {
5334
- let r = cy(t), n = _o(T(r).div(T(this.#n)));
5334
+ let r = ly(t), n = _o(T(r).div(T(this.#n)));
5335
5335
  Mo(r, this.#a) || (this.#a = r, this.#r.write(r)), this.#t.dispatchWorkgroups(n.x, n.y, n.z);
5336
5336
  }
5337
5337
  get pipeline() {
@@ -5340,7 +5340,7 @@ var py = [ve(1, 1, 1), ve(256, 1, 1), ve(16, 16, 1), ve(8, 8, 4)], dy = class $u
5340
5340
  get sizeUniform() {
5341
5341
  return this.#r;
5342
5342
  }
5343
- }, my = class Za {
5343
+ }, dy = class Za {
5344
5344
  constructor(t, r) {
5345
5345
  this._getRoot = t, this._slotBindings = r;
5346
5346
  }
@@ -5348,39 +5348,39 @@ var py = [ve(1, 1, 1), ve(256, 1, 1), ve(16, 16, 1), ve(8, 8, 4)], dy = class $u
5348
5348
  return new Za(this._getRoot, [...this._slotBindings, [pa(t) ? t.slot : t, r]]);
5349
5349
  }
5350
5350
  withCompute(t) {
5351
- return new hy(this._getRoot(), this._slotBindings, t);
5351
+ return new my(this._getRoot(), this._slotBindings, t);
5352
5352
  }
5353
5353
  createGuardedComputePipeline(t) {
5354
5354
  let r = this._getRoot();
5355
5355
  if (t.length >= 4) throw new Error("Guarded compute callback only supports up to three dimensions.");
5356
- let n = py[t.length], a = R([y, y, y])(t), i = (globalThis.__TYPEGPU_AUTONAME__ ?? ((u) => u))(r.createUniform(ve), "a"), s = ko({ workgroupSize: n, in: { id: fi.globalInvocationId } })`{
5356
+ let n = cy[t.length], a = R([y, y, y])(t), i = (globalThis.__TYPEGPU_AUTONAME__ ?? ((u) => u))(r.createUniform(ve), "a"), s = ko({ workgroupSize: n, in: { id: fi.globalInvocationId } })`{
5357
5357
  if (any(in.id >= sizeUniform)) {
5358
5358
  return;
5359
5359
  }
5360
5360
  wrappedCallback(in.id.x, in.id.y, in.id.z);
5361
5361
  }`.$uses({ sizeUniform: i, wrappedCallback: a }), o = (globalThis.__TYPEGPU_AUTONAME__ ?? ((u) => u))(this.withCompute(s).createPipeline(), "s");
5362
- return new dy(r, o, i, n);
5362
+ return new py(r, o, i, n);
5363
5363
  }
5364
5364
  withVertex(t, r) {
5365
- return new fy({ branch: this._getRoot(), primitiveState: void 0, depthStencilState: void 0, slotBindings: this._slotBindings, vertexFn: t, vertexAttribs: r ?? {}, multisampleState: void 0 });
5365
+ return new hy({ branch: this._getRoot(), primitiveState: void 0, depthStencilState: void 0, slotBindings: this._slotBindings, vertexFn: t, vertexAttribs: r ?? {}, multisampleState: void 0 });
5366
5366
  }
5367
5367
  pipe(t) {
5368
5368
  let r = t(new No([]));
5369
5369
  return new Za(this._getRoot, [...this._slotBindings, ...r.bindings]);
5370
5370
  }
5371
- }, hy = class {
5371
+ }, my = class {
5372
5372
  constructor(e, t, r) {
5373
5373
  this._root = e, this._slotBindings = t, this._entryFn = r;
5374
5374
  }
5375
5375
  createPipeline() {
5376
- return Hf(this._root, this._slotBindings, this._entryFn);
5376
+ return Kf(this._root, this._slotBindings, this._entryFn);
5377
5377
  }
5378
- }, fy = class Vn {
5378
+ }, hy = class Vn {
5379
5379
  constructor(t) {
5380
5380
  this._options = t;
5381
5381
  }
5382
5382
  withFragment(t, r, n) {
5383
- return Ct(typeof t != "string", "Just type mismatch validation"), Ct(r === void 0 || typeof r != "string", "Just type mismatch validation"), new yy({ ...this._options, fragmentFn: t, targets: r ?? {} });
5383
+ return Ct(typeof t != "string", "Just type mismatch validation"), Ct(r === void 0 || typeof r != "string", "Just type mismatch validation"), new fy({ ...this._options, fragmentFn: t, targets: r ?? {} });
5384
5384
  }
5385
5385
  withPrimitive(t) {
5386
5386
  return new Vn({ ...this._options, primitiveState: t });
@@ -5394,7 +5394,7 @@ var py = [ve(1, 1, 1), ve(256, 1, 1), ve(16, 16, 1), ve(8, 8, 4)], dy = class $u
5394
5394
  createPipeline() {
5395
5395
  return bu({ ...this._options, fragmentFn: null, targets: null });
5396
5396
  }
5397
- }, yy = class Jn {
5397
+ }, fy = class Jn {
5398
5398
  constructor(t) {
5399
5399
  this._options = t;
5400
5400
  }
@@ -5410,7 +5410,7 @@ var py = [ve(1, 1, 1), ve(256, 1, 1), ve(16, 16, 1), ve(8, 8, 4)], dy = class $u
5410
5410
  createPipeline() {
5411
5411
  return bu(this._options);
5412
5412
  }
5413
- }, Tu = class extends my {
5413
+ }, Tu = class extends dy {
5414
5414
  constructor(t, r, n, a, i) {
5415
5415
  super(() => this, []), this.device = t, this.nameRegistrySetting = r, this._ownDevice = n, this.shaderGenerator = i, this["~unstable"] = this, this[c] = { logOptions: a };
5416
5416
  }
@@ -5437,22 +5437,22 @@ var py = [ve(1, 1, 1), ve(256, 1, 1), ve(16, 16, 1), ve(8, 8, 4)], dy = class $u
5437
5437
  return new Ua("readonly", n);
5438
5438
  }
5439
5439
  createQuerySet(t, r, n) {
5440
- return Jf(this, t, r, n);
5440
+ return Vf(this, t, r, n);
5441
5441
  }
5442
5442
  createBindGroup(t, r) {
5443
5443
  return new eu(t, r);
5444
5444
  }
5445
5445
  destroy() {
5446
- df(this.device), this._ownDevice && this.device.destroy();
5446
+ pf(this.device), this._ownDevice && this.device.destroy();
5447
5447
  }
5448
5448
  createTexture(t) {
5449
- return yf(t, this);
5449
+ return ff(t, this);
5450
5450
  }
5451
5451
  createSampler(t) {
5452
- return rf(t, this);
5452
+ return tf(t, this);
5453
5453
  }
5454
5454
  createComparisonSampler(t) {
5455
- return nf(t, this);
5455
+ return rf(t, this);
5456
5456
  }
5457
5457
  unwrap(t) {
5458
5458
  if (hu(t)) return t[c].rawPipeline;
@@ -5529,7 +5529,7 @@ var py = [ve(1, 1, 1), ve(256, 1, 1), ve(16, 16, 1), ve(8, 8, 4)], dy = class $u
5529
5529
  console.warn("flush() has been deprecated, and has no effect.");
5530
5530
  }
5531
5531
  };
5532
- async function gy(e) {
5532
+ async function yy(e) {
5533
5533
  let { adapter: t, device: r, unstable_names: n = "strict", unstable_logOptions: a } = e ?? {};
5534
5534
  if (!navigator.gpu) throw new Error("WebGPU is not supported by this browser.");
5535
5535
  let i = await navigator.gpu.requestAdapter(t);
@@ -5543,14 +5543,14 @@ async function gy(e) {
5543
5543
  let o = await i.requestDevice({ ...r, requiredFeatures: s });
5544
5544
  return new Tu(o, n, !0, a ?? {}, e?.shaderGenerator);
5545
5545
  }
5546
- function vy(e) {
5546
+ function gy(e) {
5547
5547
  let { device: t, unstable_names: r = "strict", unstable_logOptions: n } = e ?? {};
5548
5548
  return new Tu(t, r, !1, n ?? {}, e?.shaderGenerator);
5549
5549
  }
5550
- function wy(e, t) {
5551
- return new xy(e, t);
5550
+ function vy(e, t) {
5551
+ return new wy(e, t);
5552
5552
  }
5553
- var xy = class {
5553
+ var wy = class {
5554
5554
  constructor(e, t = void 0) {
5555
5555
  this.schema = e, this.defaultValue = t, this.slot = ia(t), this[Ie] = this.slot;
5556
5556
  }
@@ -5568,7 +5568,7 @@ var xy = class {
5568
5568
  if (r) return r;
5569
5569
  e.pushMode(new Bs());
5570
5570
  try {
5571
- let n = ar(this.schema, t);
5571
+ let n = ir(this.schema, t);
5572
5572
  return g(n, this.schema, "constant");
5573
5573
  } finally {
5574
5574
  e.popMode("normal");
@@ -5592,13 +5592,13 @@ var xy = class {
5592
5592
  return g(e.resolve(t.value, t.dataType).value, t.dataType, t.origin);
5593
5593
  }
5594
5594
  };
5595
- function by(e) {
5596
- return Ty(e);
5595
+ function xy(e) {
5596
+ return $y(e);
5597
5597
  }
5598
- function $y([e, t]) {
5598
+ function by([e, t]) {
5599
5599
  return `${x(e) ?? "<unnamed>"}=${t}`;
5600
5600
  }
5601
- function Ty(e) {
5601
+ function $y(e) {
5602
5602
  if (ct()) throw new Error("Cannot create tgpu.derived objects at the resolution stage.");
5603
5603
  return { [c]: !0, resourceType: "derived", "~compute": e, get [j]() {
5604
5604
  let t = ct();
@@ -5628,48 +5628,48 @@ function _u(e, t) {
5628
5628
  }, with(r, n) {
5629
5629
  return _u(e, [...t, [r, n]]);
5630
5630
  }, toString() {
5631
- return `derived[${t.map($y).join(", ")}]`;
5631
+ return `derived[${t.map(by).join(", ")}]`;
5632
5632
  } };
5633
5633
  }
5634
- var _y = { fn: R, bindGroupLayout: Qo, vertexLayout: fs, slot: ia, init: gy, initFromDevice: vy, resolve: Df, resolveWithContext: Ya, privateVar: sa, workgroupVar: cs, const: La, "~unstable": { fn: R, fragmentFn: Mh, vertexFn: op, computeFn: ko, comptime: Wt, vertexLayout: fs, namespace: Kr, derived: by, slot: ia, accessor: wy, privateVar: sa, workgroupVar: cs, const: La, declare: bh, rawCodeSnippet: Eh, simulate: Vf } }, M = _y, Iy = m({ name: "discard", normalImpl: "`discard` relies on GPU resources and cannot be executed outside of a draw call", signature: { argTypes: [], returnType: de }, codegenImpl: () => "discard;" }), zn = N[c].jsImpl, Ey = da[c].jsImpl, Uy = da[c].gpuImpl, My = ma[c].jsImpl, Py = ma[c].gpuImpl, Sy = ha[c].jsImpl, zy = ha[c].gpuImpl, ky = fa[c].jsImpl, Ay = fa[c].gpuImpl, Gy = ya[c].jsImpl, Oy = ya[c].gpuImpl, By = m({ name: "translate4", normalImpl: (e, t) => zn(Ey(t), e), signature: { argTypes: [H, T], returnType: H }, codegenImpl: (e, t) => p`(${Uy(t)} * ${e})` }), Cy = m({ name: "scale4", normalImpl: (e, t) => zn(My(t), e), signature: { argTypes: [H, T], returnType: H }, codegenImpl: (e, t) => p`(${Py(t)} * ${e})` }), Ti = { argTypes: [H, b], returnType: H }, Fy = m({ name: "rotateX4", normalImpl: (e, t) => zn(Sy(t), e), signature: Ti, codegenImpl: (e, t) => p`(${zy(t)} * ${e})` }), Ny = m({ name: "rotateY4", normalImpl: (e, t) => zn(ky(t), e), signature: Ti, codegenImpl: (e, t) => p`(${Ay(t)} * ${e})` }), Ly = m({ name: "rotateZ4", normalImpl: (e, t) => zn(Gy(t), e), signature: Ti, codegenImpl: (e, t) => p`(${Oy(t)} * ${e})` }), Ry = m({ name: "workgroupBarrier", normalImpl: "workgroupBarrier is a no-op outside of CODEGEN mode.", signature: { argTypes: [], returnType: de }, codegenImpl: () => "workgroupBarrier()" }), Wy = m({ name: "storageBarrier", normalImpl: "storageBarrier is a no-op outside of CODEGEN mode.", signature: { argTypes: [], returnType: de }, codegenImpl: () => "storageBarrier()" }), jy = m({ name: "textureBarrier", normalImpl: "textureBarrier is a no-op outside of CODEGEN mode.", signature: { argTypes: [], returnType: de }, codegenImpl: () => "textureBarrier()" }), At = "Atomic operations are not supported outside of CODEGEN mode.", Dy = m({ name: "atomicLoad", normalImpl: At, signature: (e) => {
5634
+ var Ty = { fn: R, bindGroupLayout: Qo, vertexLayout: fs, slot: ia, init: yy, initFromDevice: gy, resolve: jf, resolveWithContext: Ya, privateVar: sa, workgroupVar: cs, const: La, "~unstable": { fn: R, fragmentFn: Uh, vertexFn: sp, computeFn: ko, comptime: Wt, vertexLayout: fs, namespace: Kr, derived: xy, slot: ia, accessor: vy, privateVar: sa, workgroupVar: cs, const: La, declare: xh, rawCodeSnippet: Ih, simulate: qf } }, M = Ty, _y = m({ name: "discard", normalImpl: "`discard` relies on GPU resources and cannot be executed outside of a draw call", signature: { argTypes: [], returnType: de }, codegenImpl: () => "discard;" }), zn = N[c].jsImpl, Iy = da[c].jsImpl, Ey = da[c].gpuImpl, Uy = ma[c].jsImpl, My = ma[c].gpuImpl, Py = ha[c].jsImpl, Sy = ha[c].gpuImpl, zy = fa[c].jsImpl, ky = fa[c].gpuImpl, Ay = ya[c].jsImpl, Gy = ya[c].gpuImpl, Oy = m({ name: "translate4", normalImpl: (e, t) => zn(Iy(t), e), signature: { argTypes: [H, T], returnType: H }, codegenImpl: (e, t) => p`(${Ey(t)} * ${e})` }), By = m({ name: "scale4", normalImpl: (e, t) => zn(Uy(t), e), signature: { argTypes: [H, T], returnType: H }, codegenImpl: (e, t) => p`(${My(t)} * ${e})` }), Ti = { argTypes: [H, b], returnType: H }, Cy = m({ name: "rotateX4", normalImpl: (e, t) => zn(Py(t), e), signature: Ti, codegenImpl: (e, t) => p`(${Sy(t)} * ${e})` }), Fy = m({ name: "rotateY4", normalImpl: (e, t) => zn(zy(t), e), signature: Ti, codegenImpl: (e, t) => p`(${ky(t)} * ${e})` }), Ny = m({ name: "rotateZ4", normalImpl: (e, t) => zn(Ay(t), e), signature: Ti, codegenImpl: (e, t) => p`(${Gy(t)} * ${e})` }), Ly = m({ name: "workgroupBarrier", normalImpl: "workgroupBarrier is a no-op outside of CODEGEN mode.", signature: { argTypes: [], returnType: de }, codegenImpl: () => "workgroupBarrier()" }), Ry = m({ name: "storageBarrier", normalImpl: "storageBarrier is a no-op outside of CODEGEN mode.", signature: { argTypes: [], returnType: de }, codegenImpl: () => "storageBarrier()" }), Wy = m({ name: "textureBarrier", normalImpl: "textureBarrier is a no-op outside of CODEGEN mode.", signature: { argTypes: [], returnType: de }, codegenImpl: () => "textureBarrier()" }), At = "Atomic operations are not supported outside of CODEGEN mode.", jy = m({ name: "atomicLoad", normalImpl: At, signature: (e) => {
5635
5635
  if (e.type !== "atomic") throw new Error(`Invalid atomic type: ${Dt(e)}`);
5636
5636
  return { argTypes: [e], returnType: e.inner };
5637
- }, codegenImpl: (e) => p`atomicLoad(&${e})` }), Yy = (e, t) => {
5637
+ }, codegenImpl: (e) => p`atomicLoad(&${e})` }), Dy = (e, t) => {
5638
5638
  if (e.type !== "atomic") throw new Error(`Invalid atomic type: ${Dt(e)}`);
5639
5639
  return { argTypes: [e, e.inner.type === "u32" ? y : Ue], returnType: de };
5640
- }, lr = (e, t) => {
5640
+ }, cr = (e, t) => {
5641
5641
  if (e.type !== "atomic") throw new Error(`Invalid atomic type: ${Dt(e)}`);
5642
5642
  let r = e.inner.type === "u32" ? y : Ue;
5643
5643
  return { argTypes: [e, r], returnType: r };
5644
- }, qy = m({ name: "atomicStore", normalImpl: At, signature: Yy, codegenImpl: (e, t) => p`atomicStore(&${e}, ${t})` }), Vy = m({ name: "atomicAdd", normalImpl: At, signature: lr, codegenImpl: (e, t) => p`atomicAdd(&${e}, ${t})` }), Jy = m({ name: "atomicSub", normalImpl: At, signature: lr, codegenImpl: (e, t) => p`atomicSub(&${e}, ${t})` }), Xy = m({ name: "atomicMax", normalImpl: At, signature: lr, codegenImpl: (e, t) => p`atomicMax(&${e}, ${t})` }), Zy = m({ name: "atomicMin", normalImpl: At, signature: lr, codegenImpl: (e, t) => p`atomicMin(&${e}, ${t})` }), Qy = m({ name: "atomicAnd", normalImpl: At, signature: lr, codegenImpl: (e, t) => p`atomicAnd(&${e}, ${t})` }), Ky = m({ name: "atomicOr", normalImpl: At, signature: lr, codegenImpl: (e, t) => p`atomicOr(&${e}, ${t})` }), Hy = m({ name: "atomicXor", normalImpl: At, signature: lr, codegenImpl: (e, t) => p`atomicXor(&${e}, ${t})` }), Gt = "Derivative builtins are not allowed on the CPU", eg = m({ name: "dpdx", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`dpdx(${e})` }), tg = m({ name: "dpdxCoarse", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`dpdxCoarse(${e})` }), rg = m({ name: "dpdxFine", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`dpdxFine(${e})` }), ng = m({ name: "dpdy", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`dpdy(${e})` }), ag = m({ name: "dpdyCoarse", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`dpdyCoarse(${e})` }), ig = m({ name: "dpdyFine", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`dpdyFine(${e})` }), sg = m({ name: "fwidth", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`fwidth(${e})` }), og = m({ name: "fwidthCoarse", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`fwidthCoarse(${e})` }), ug = m({ name: "fwidthFine", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`fwidthFine(${e})` }), ys = (e) => lt(e) && ze(e.inner) ? e.inner.elementCount : 0, lg = m({ name: "arrayLength", signature: (e) => {
5644
+ }, Yy = m({ name: "atomicStore", normalImpl: At, signature: Dy, codegenImpl: (e, t) => p`atomicStore(&${e}, ${t})` }), qy = m({ name: "atomicAdd", normalImpl: At, signature: cr, codegenImpl: (e, t) => p`atomicAdd(&${e}, ${t})` }), Vy = m({ name: "atomicSub", normalImpl: At, signature: cr, codegenImpl: (e, t) => p`atomicSub(&${e}, ${t})` }), Jy = m({ name: "atomicMax", normalImpl: At, signature: cr, codegenImpl: (e, t) => p`atomicMax(&${e}, ${t})` }), Xy = m({ name: "atomicMin", normalImpl: At, signature: cr, codegenImpl: (e, t) => p`atomicMin(&${e}, ${t})` }), Zy = m({ name: "atomicAnd", normalImpl: At, signature: cr, codegenImpl: (e, t) => p`atomicAnd(&${e}, ${t})` }), Qy = m({ name: "atomicOr", normalImpl: At, signature: cr, codegenImpl: (e, t) => p`atomicOr(&${e}, ${t})` }), Ky = m({ name: "atomicXor", normalImpl: At, signature: cr, codegenImpl: (e, t) => p`atomicXor(&${e}, ${t})` }), Gt = "Derivative builtins are not allowed on the CPU", Hy = m({ name: "dpdx", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`dpdx(${e})` }), eg = m({ name: "dpdxCoarse", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`dpdxCoarse(${e})` }), tg = m({ name: "dpdxFine", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`dpdxFine(${e})` }), rg = m({ name: "dpdy", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`dpdy(${e})` }), ng = m({ name: "dpdyCoarse", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`dpdyCoarse(${e})` }), ag = m({ name: "dpdyFine", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`dpdyFine(${e})` }), ig = m({ name: "fwidth", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`fwidth(${e})` }), sg = m({ name: "fwidthCoarse", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`fwidthCoarse(${e})` }), og = m({ name: "fwidthFine", normalImpl: Gt, signature: (e) => ({ argTypes: [e], returnType: e }), codegenImpl: (e) => p`fwidthFine(${e})` }), ys = (e) => lt(e) && ze(e.inner) ? e.inner.elementCount : 0, ug = m({ name: "arrayLength", signature: (e) => {
5645
5645
  let t = lt(e) ? e : ai(e);
5646
5646
  return { argTypes: [t], returnType: ys(t) > 0 ? la : y };
5647
- }, normalImpl: (e) => Ql(e) ? e.$.length : e.length, codegenImpl(e) {
5647
+ }, normalImpl: (e) => Zl(e) ? e.$.length : e.length, codegenImpl(e) {
5648
5648
  let t = ys(e.dataType);
5649
5649
  return t > 0 ? String(t) : p`arrayLength(${e})`;
5650
5650
  } });
5651
- function cg(e, t, r, n, a) {
5651
+ function lg(e, t, r, n, a) {
5652
5652
  throw new Error("Texture sampling relies on GPU resources and cannot be executed outside of a draw call");
5653
5653
  }
5654
- var pg = m({ name: "textureSample", normalImpl: cg, codegenImpl: (...e) => p`textureSample(${e})`, signature: (...e) => {
5654
+ var cg = m({ name: "textureSample", normalImpl: lg, codegenImpl: (...e) => p`textureSample(${e})`, signature: (...e) => {
5655
5655
  let t = e[0].type.startsWith("texture_depth");
5656
5656
  return { argTypes: e, returnType: t ? b : C };
5657
5657
  } });
5658
- function dg(e, t, r, n, a, i) {
5658
+ function pg(e, t, r, n, a, i) {
5659
5659
  throw new Error("Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call");
5660
5660
  }
5661
- var mg = m({ name: "textureSampleBias", normalImpl: dg, codegenImpl: (...e) => p`textureSampleBias(${e})`, signature: (...e) => ({ argTypes: e, returnType: C }) });
5662
- function hg(e, t, r, n, a, i) {
5661
+ var dg = m({ name: "textureSampleBias", normalImpl: pg, codegenImpl: (...e) => p`textureSampleBias(${e})`, signature: (...e) => ({ argTypes: e, returnType: C }) });
5662
+ function mg(e, t, r, n, a, i) {
5663
5663
  throw new Error("Texture sampling relies on GPU resources and cannot be executed outside of a draw call");
5664
5664
  }
5665
- var fg = m({ name: "textureSampleLevel", normalImpl: hg, codegenImpl: (...e) => p`textureSampleLevel(${e})`, signature: (...e) => {
5665
+ var hg = m({ name: "textureSampleLevel", normalImpl: mg, codegenImpl: (...e) => p`textureSampleLevel(${e})`, signature: (...e) => {
5666
5666
  let t = e[0].type.startsWith("texture_depth");
5667
5667
  return { argTypes: e, returnType: t ? b : C };
5668
5668
  } });
5669
- function yg(e, t, r) {
5669
+ function fg(e, t, r) {
5670
5670
  throw new Error("`textureLoad` relies on GPU resources and cannot be executed outside of a draw call");
5671
5671
  }
5672
- var gg = m({ name: "textureLoad", normalImpl: yg, codegenImpl: (...e) => p`textureLoad(${e})`, signature: (...e) => {
5672
+ var yg = m({ name: "textureLoad", normalImpl: fg, codegenImpl: (...e) => p`textureLoad(${e})`, signature: (...e) => {
5673
5673
  let t = e[0];
5674
5674
  if (ao(t)) {
5675
5675
  let a = t.type.startsWith("texture_depth"), i = t.sampleType;
@@ -5678,206 +5678,206 @@ var gg = m({ name: "textureLoad", normalImpl: yg, codegenImpl: (...e) => p`textu
5678
5678
  let r = t.format, n = Sn(r).vectorType;
5679
5679
  return { argTypes: e, returnType: n };
5680
5680
  } });
5681
- function vg(e, t, r, n) {
5681
+ function gg(e, t, r, n) {
5682
5682
  throw new Error("`textureStore` relies on GPU resources and cannot be executed outside of a draw call");
5683
5683
  }
5684
- var wg = m({ name: "textureStore", normalImpl: vg, codegenImpl: (...e) => p`textureStore(${e})`, signature: (...e) => ({ argTypes: e, returnType: de }) });
5685
- function xg(e, t) {
5684
+ var vg = m({ name: "textureStore", normalImpl: gg, codegenImpl: (...e) => p`textureStore(${e})`, signature: (...e) => ({ argTypes: e, returnType: de }) });
5685
+ function wg(e, t) {
5686
5686
  throw new Error("`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call");
5687
5687
  }
5688
- var bg = m({ name: "textureDimensions", normalImpl: xg, codegenImpl: (...e) => p`textureDimensions(${e})`, signature: (...e) => {
5688
+ var xg = m({ name: "textureDimensions", normalImpl: wg, codegenImpl: (...e) => p`textureDimensions(${e})`, signature: (...e) => {
5689
5689
  let t = e[0].dimension;
5690
5690
  return t === "1d" ? { argTypes: e, returnType: y } : t === "3d" ? { argTypes: e, returnType: ve } : { argTypes: e, returnType: Be };
5691
5691
  } });
5692
- function $g(e, t, r, n, a, i) {
5692
+ function bg(e, t, r, n, a, i) {
5693
5693
  throw new Error("Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call");
5694
5694
  }
5695
- var Tg = m({ name: "textureSampleCompare", normalImpl: $g, codegenImpl: (...e) => p`textureSampleCompare(${e})`, signature: (...e) => ({ argTypes: e, returnType: b }) });
5696
- function _g(e, t, r) {
5695
+ var $g = m({ name: "textureSampleCompare", normalImpl: bg, codegenImpl: (...e) => p`textureSampleCompare(${e})`, signature: (...e) => ({ argTypes: e, returnType: b }) });
5696
+ function Tg(e, t, r) {
5697
5697
  throw new Error("Texture sampling with base clamp to edge is not supported outside of GPU mode.");
5698
5698
  }
5699
- var Ig = m({ name: "textureSampleBaseClampToEdge", normalImpl: _g, codegenImpl: (...e) => p`textureSampleBaseClampToEdge(${e})`, signature: (...e) => ({ argTypes: e, returnType: C }) }), he = "Subgroup operations can only be used in the GPU context.", Eg = m({ name: "subgroupAdd", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupAdd(${e})` }), Ug = m({ name: "subgroupExclusiveAdd", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupExclusiveAdd(${e})` }), Mg = m({ name: "subgroupInclusiveAdd", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupInclusiveAdd(${e})` }), Pg = m({ name: "subgroupAll", signature: { argTypes: [le], returnType: le }, normalImpl: he, codegenImpl: (e) => p`subgroupAll(${e})` }), Sg = m({ name: "subgroupAnd", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupAnd(${e})` }), zg = m({ name: "subgroupAny", signature: { argTypes: [le], returnType: le }, normalImpl: he, codegenImpl: (e) => p`subgroupAny(${e})` }), kg = m({ name: "subgroupBallot", signature: { argTypes: [le], returnType: Oe }, normalImpl: he, codegenImpl: (e) => p`subgroupBallot(${e})` }), Ag = m({ name: "subgroupBroadcast", signature: (...e) => {
5699
+ var _g = m({ name: "textureSampleBaseClampToEdge", normalImpl: Tg, codegenImpl: (...e) => p`textureSampleBaseClampToEdge(${e})`, signature: (...e) => ({ argTypes: e, returnType: C }) }), he = "Subgroup operations can only be used in the GPU context.", Ig = m({ name: "subgroupAdd", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupAdd(${e})` }), Eg = m({ name: "subgroupExclusiveAdd", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupExclusiveAdd(${e})` }), Ug = m({ name: "subgroupInclusiveAdd", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupInclusiveAdd(${e})` }), Mg = m({ name: "subgroupAll", signature: { argTypes: [le], returnType: le }, normalImpl: he, codegenImpl: (e) => p`subgroupAll(${e})` }), Pg = m({ name: "subgroupAnd", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupAnd(${e})` }), Sg = m({ name: "subgroupAny", signature: { argTypes: [le], returnType: le }, normalImpl: he, codegenImpl: (e) => p`subgroupAny(${e})` }), zg = m({ name: "subgroupBallot", signature: { argTypes: [le], returnType: Oe }, normalImpl: he, codegenImpl: (e) => p`subgroupBallot(${e})` }), kg = m({ name: "subgroupBroadcast", signature: (...e) => {
5700
5700
  let t = be([e[1]], [Ue, y]);
5701
5701
  if (!t) throw new Error(`subgroupBroadcast's second argument has to be compatible with i32 or u32. Got: ${e[1].type}`);
5702
5702
  return { argTypes: [e[0], t[0]], returnType: e[0] };
5703
- }, normalImpl: he, codegenImpl: (e, t) => p`subgroupBroadcast(${e}, ${t})` }), Gg = m({ name: "subgroupBroadcastFirst", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupBroadcastFirst(${e})` }), Og = m({ name: "subgroupElect", signature: { argTypes: [], returnType: le }, normalImpl: he, codegenImpl: () => p`subgroupElect()` }), Bg = m({ name: "subgroupMax", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupMax(${e})` }), Cg = m({ name: "subgroupMin", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupMin(${e})` }), Fg = m({ name: "subgroupMul", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupMul(${e})` }), Ng = m({ name: "subgroupExclusiveMul", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupExclusiveMul(${e})` }), Lg = m({ name: "subgroupInclusiveMul", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupInclusiveMul(${e})` }), Rg = m({ name: "subgroupOr", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupOr(${e})` }), Wg = m({ name: "subgroupShuffle", signature: (...e) => {
5703
+ }, normalImpl: he, codegenImpl: (e, t) => p`subgroupBroadcast(${e}, ${t})` }), Ag = m({ name: "subgroupBroadcastFirst", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupBroadcastFirst(${e})` }), Gg = m({ name: "subgroupElect", signature: { argTypes: [], returnType: le }, normalImpl: he, codegenImpl: () => p`subgroupElect()` }), Og = m({ name: "subgroupMax", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupMax(${e})` }), Bg = m({ name: "subgroupMin", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupMin(${e})` }), Cg = m({ name: "subgroupMul", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupMul(${e})` }), Fg = m({ name: "subgroupExclusiveMul", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupExclusiveMul(${e})` }), Ng = m({ name: "subgroupInclusiveMul", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupInclusiveMul(${e})` }), Lg = m({ name: "subgroupOr", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupOr(${e})` }), Rg = m({ name: "subgroupShuffle", signature: (...e) => {
5704
5704
  let t = be([e[1]], [Ue, y]);
5705
5705
  if (!t) throw new Error(`subgroupShuffle's second argument has to be compatible with i32 or u32. Got: ${e[1].type}`);
5706
5706
  return { argTypes: [e[0], t[0]], returnType: e[0] };
5707
- }, normalImpl: he, codegenImpl: (e, t) => p`subgroupShuffle(${e}, ${t})` }), jg = m({ name: "subgroupShuffleDown", signature: (...e) => {
5707
+ }, normalImpl: he, codegenImpl: (e, t) => p`subgroupShuffle(${e}, ${t})` }), Wg = m({ name: "subgroupShuffleDown", signature: (...e) => {
5708
5708
  let t = be([e[1]], [y]);
5709
5709
  if (!t) throw new Error(`subgroupShuffleDown's second argument has to be compatible with u32. Got: ${e[1].type}`);
5710
5710
  return { argTypes: [e[0], t[0]], returnType: e[0] };
5711
- }, normalImpl: he, codegenImpl: (e, t) => p`subgroupShuffleDown(${e}, ${t})` }), Dg = m({ name: "subgroupShuffleUp", signature: (...e) => {
5711
+ }, normalImpl: he, codegenImpl: (e, t) => p`subgroupShuffleDown(${e}, ${t})` }), jg = m({ name: "subgroupShuffleUp", signature: (...e) => {
5712
5712
  let t = be([e[1]], [y]);
5713
5713
  if (!t) throw new Error(`subgroupShuffleUp's second argument has to be compatible with u32. Got: ${e[1].type}`);
5714
5714
  return { argTypes: [e[0], t[0]], returnType: e[0] };
5715
- }, normalImpl: he, codegenImpl: (e, t) => p`subgroupShuffleUp(${e}, ${t})` }), Yg = m({ name: "subgroupShuffleXor", signature: (...e) => {
5715
+ }, normalImpl: he, codegenImpl: (e, t) => p`subgroupShuffleUp(${e}, ${t})` }), Dg = m({ name: "subgroupShuffleXor", signature: (...e) => {
5716
5716
  let t = be([e[1]], [y]);
5717
5717
  if (!t) throw new Error(`subgroupShuffleXor's second argument has to be compatible with u32. Got: ${e[1].type}`);
5718
5718
  return { argTypes: [e[0], t[0]], returnType: e[0] };
5719
- }, normalImpl: he, codegenImpl: (e, t) => p`subgroupShuffleXor(${e}, ${t})` }), qg = m({ name: "subgroupXor", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupXor(${e})` }), Vg = Wt((e) => {
5719
+ }, normalImpl: he, codegenImpl: (e, t) => p`subgroupShuffleXor(${e}, ${t})` }), Yg = m({ name: "subgroupXor", signature: (e) => ({ argTypes: [e], returnType: e }), normalImpl: he, codegenImpl: (e) => p`subgroupXor(${e})` }), qg = Wt((e) => {
5720
5720
  let t = ct();
5721
5721
  if (!t) throw new Error("Functions using `extensionEnabled` cannot be called directly. Either generate WGSL from them, or use tgpu['~unstable'].simulate(...)");
5722
5722
  if (typeof e != "string" || !xi.includes(e)) throw new Error(`extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: '${e}'`);
5723
5723
  return (t.enableExtensions ?? []).includes(e);
5724
5724
  });
5725
- const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5725
+ const pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5726
5726
  __proto__: null,
5727
- abs: dd,
5728
- acos: hd,
5729
- acosh: yd,
5727
+ abs: pd,
5728
+ acos: md,
5729
+ acosh: fd,
5730
5730
  add: B,
5731
- all: th,
5731
+ all: eh,
5732
5732
  allEq: Mo,
5733
- and: eh,
5734
- any: rh,
5735
- arrayLength: lg,
5736
- asin: vd,
5737
- asinh: xd,
5738
- atan: $d,
5739
- atan2: Ed,
5740
- atanh: _d,
5741
- atomicAdd: Vy,
5742
- atomicAnd: Qy,
5743
- atomicLoad: Dy,
5744
- atomicMax: Xy,
5745
- atomicMin: Zy,
5746
- atomicOr: Ky,
5747
- atomicStore: qy,
5748
- atomicSub: Jy,
5749
- atomicXor: Hy,
5733
+ and: Hm,
5734
+ any: th,
5735
+ arrayLength: ug,
5736
+ asin: gd,
5737
+ asinh: wd,
5738
+ atan: bd,
5739
+ atan2: Id,
5740
+ atanh: Td,
5741
+ atomicAdd: qy,
5742
+ atomicAnd: Zy,
5743
+ atomicLoad: jy,
5744
+ atomicMax: Jy,
5745
+ atomicMin: Xy,
5746
+ atomicOr: Qy,
5747
+ atomicStore: Yy,
5748
+ atomicSub: Vy,
5749
+ atomicXor: Ky,
5750
5750
  bitcastU32toF32: Io,
5751
5751
  bitcastU32toI32: Eo,
5752
5752
  ceil: _o,
5753
- clamp: Pd,
5753
+ clamp: Md,
5754
5754
  cos: Qe,
5755
- cosh: kd,
5756
- countLeadingZeros: Ad,
5757
- countOneBits: Gd,
5758
- countTrailingZeros: Od,
5759
- cross: Bd,
5760
- degrees: Fd,
5761
- determinant: Nd,
5762
- discard: Iy,
5763
- distance: Rd,
5755
+ cosh: zd,
5756
+ countLeadingZeros: kd,
5757
+ countOneBits: Ad,
5758
+ countTrailingZeros: Gd,
5759
+ cross: Od,
5760
+ degrees: Cd,
5761
+ determinant: Fd,
5762
+ discard: _y,
5763
+ distance: Ld,
5764
5764
  div: ga,
5765
5765
  dot: ce,
5766
- dot4I8Packed: jd,
5767
- dot4U8Packed: Wd,
5768
- dpdx: eg,
5769
- dpdxCoarse: tg,
5770
- dpdxFine: rg,
5771
- dpdy: ng,
5772
- dpdyCoarse: ag,
5773
- dpdyFine: ig,
5774
- eq: qm,
5775
- exp: Yd,
5776
- exp2: Vd,
5777
- extensionEnabled: Vg,
5778
- extractBits: Jd,
5779
- faceForward: Xd,
5780
- firstLeadingBit: Zd,
5781
- firstTrailingBit: Qd,
5782
- floor: ir,
5783
- fma: em,
5766
+ dot4I8Packed: Wd,
5767
+ dot4U8Packed: Rd,
5768
+ dpdx: Hy,
5769
+ dpdxCoarse: eg,
5770
+ dpdxFine: tg,
5771
+ dpdy: rg,
5772
+ dpdyCoarse: ng,
5773
+ dpdyFine: ag,
5774
+ eq: Ym,
5775
+ exp: Dd,
5776
+ exp2: qd,
5777
+ extensionEnabled: qg,
5778
+ extractBits: Vd,
5779
+ faceForward: Jd,
5780
+ firstLeadingBit: Xd,
5781
+ firstTrailingBit: Zd,
5782
+ floor: sr,
5783
+ fma: Hd,
5784
5784
  fract: xt,
5785
- frexp: nm,
5786
- fwidth: sg,
5787
- fwidthCoarse: og,
5788
- fwidthFine: ug,
5789
- ge: Qm,
5790
- gt: Zm,
5785
+ frexp: rm,
5786
+ fwidth: ig,
5787
+ fwidthCoarse: sg,
5788
+ fwidthFine: og,
5789
+ ge: Zm,
5790
+ gt: Xm,
5791
5791
  identity2: Ls,
5792
5792
  identity3: Rs,
5793
5793
  identity4: Ws,
5794
- insertBits: am,
5795
- inverseSqrt: sm,
5796
- isCloseTo: nh,
5797
- ldexp: om,
5798
- le: Xm,
5794
+ insertBits: nm,
5795
+ inverseSqrt: im,
5796
+ isCloseTo: rh,
5797
+ ldexp: sm,
5798
+ le: Jm,
5799
5799
  length: ea,
5800
5800
  log: yn,
5801
- log2: pm,
5802
- lt: Jm,
5803
- max: mm,
5804
- min: fm,
5801
+ log2: cm,
5802
+ lt: Vm,
5803
+ max: dm,
5804
+ min: hm,
5805
5805
  mix: yt,
5806
- mod: vc,
5807
- modf: vm,
5806
+ mod: gc,
5807
+ modf: gm,
5808
5808
  mul: N,
5809
- ne: Vm,
5809
+ ne: qm,
5810
5810
  neg: Ys,
5811
5811
  normalize: gn,
5812
- not: Km,
5813
- or: Hm,
5814
- pack2x16float: jm,
5815
- pack4x8unorm: Ym,
5812
+ not: Qm,
5813
+ or: Km,
5814
+ pack2x16float: Wm,
5815
+ pack4x8unorm: Dm,
5816
5816
  pow: ta,
5817
- quantizeToF16: xm,
5818
- radians: $m,
5819
- reflect: Tm,
5820
- refract: _m,
5821
- reverseBits: Im,
5822
- rotateX4: Fy,
5823
- rotateY4: Ny,
5824
- rotateZ4: Ly,
5817
+ quantizeToF16: wm,
5818
+ radians: bm,
5819
+ reflect: $m,
5820
+ refract: Tm,
5821
+ reverseBits: _m,
5822
+ rotateX4: Cy,
5823
+ rotateY4: Fy,
5824
+ rotateZ4: Ny,
5825
5825
  rotationX4: ha,
5826
5826
  rotationY4: fa,
5827
5827
  rotationZ4: ya,
5828
- round: Um,
5829
- saturate: Pm,
5830
- scale4: Cy,
5828
+ round: Em,
5829
+ saturate: Mm,
5830
+ scale4: By,
5831
5831
  scaling4: ma,
5832
5832
  select: pt,
5833
5833
  sign: vn,
5834
5834
  sin: Ut,
5835
- sinh: Am,
5836
- smoothstep: Om,
5837
- sqrt: sr,
5835
+ sinh: km,
5836
+ smoothstep: Gm,
5837
+ sqrt: or,
5838
5838
  step: Ca,
5839
- storageBarrier: Wy,
5839
+ storageBarrier: Ry,
5840
5840
  sub: W,
5841
- subgroupAdd: Eg,
5842
- subgroupAll: Pg,
5843
- subgroupAnd: Sg,
5844
- subgroupAny: zg,
5845
- subgroupBallot: kg,
5846
- subgroupBroadcast: Ag,
5847
- subgroupBroadcastFirst: Gg,
5848
- subgroupElect: Og,
5849
- subgroupExclusiveAdd: Ug,
5850
- subgroupExclusiveMul: Ng,
5851
- subgroupInclusiveAdd: Mg,
5852
- subgroupInclusiveMul: Lg,
5853
- subgroupMax: Bg,
5854
- subgroupMin: Cg,
5855
- subgroupMul: Fg,
5856
- subgroupOr: Rg,
5857
- subgroupShuffle: Wg,
5858
- subgroupShuffleDown: jg,
5859
- subgroupShuffleUp: Dg,
5860
- subgroupShuffleXor: Yg,
5861
- subgroupXor: qg,
5841
+ subgroupAdd: Ig,
5842
+ subgroupAll: Mg,
5843
+ subgroupAnd: Pg,
5844
+ subgroupAny: Sg,
5845
+ subgroupBallot: zg,
5846
+ subgroupBroadcast: kg,
5847
+ subgroupBroadcastFirst: Ag,
5848
+ subgroupElect: Gg,
5849
+ subgroupExclusiveAdd: Eg,
5850
+ subgroupExclusiveMul: Fg,
5851
+ subgroupInclusiveAdd: Ug,
5852
+ subgroupInclusiveMul: Ng,
5853
+ subgroupMax: Og,
5854
+ subgroupMin: Bg,
5855
+ subgroupMul: Cg,
5856
+ subgroupOr: Lg,
5857
+ subgroupShuffle: Rg,
5858
+ subgroupShuffleDown: Wg,
5859
+ subgroupShuffleUp: jg,
5860
+ subgroupShuffleXor: Dg,
5861
+ subgroupXor: Yg,
5862
5862
  tan: Fa,
5863
- tanh: Lm,
5864
- textureBarrier: jy,
5865
- textureDimensions: bg,
5866
- textureLoad: gg,
5867
- textureSample: pg,
5868
- textureSampleBaseClampToEdge: Ig,
5869
- textureSampleBias: mg,
5870
- textureSampleCompare: Tg,
5871
- textureSampleLevel: fg,
5872
- textureStore: wg,
5873
- translate4: By,
5863
+ tanh: Nm,
5864
+ textureBarrier: Wy,
5865
+ textureDimensions: xg,
5866
+ textureLoad: yg,
5867
+ textureSample: cg,
5868
+ textureSampleBaseClampToEdge: _g,
5869
+ textureSampleBias: dg,
5870
+ textureSampleCompare: $g,
5871
+ textureSampleLevel: hg,
5872
+ textureStore: vg,
5873
+ translate4: Oy,
5874
5874
  translation4: da,
5875
- transpose: Rm,
5876
- trunc: Wm,
5875
+ transpose: Lm,
5876
+ trunc: Rm,
5877
5877
  unpack2x16float: Uo,
5878
- unpack4x8unorm: Dm,
5879
- workgroupBarrier: Ry
5880
- }, Symbol.toStringTag, { value: "Module" })), Jg = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], b), "randomGeneratorShell"), Xg = (() => {
5878
+ unpack4x8unorm: jm,
5879
+ workgroupBarrier: Ly
5880
+ }, Symbol.toStringTag, { value: "Module" })), Vg = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], b), "randomGeneratorShell"), Jg = (() => {
5881
5881
  const e = (globalThis.__TYPEGPU_AUTONAME__ ?? ((t) => t))(M.privateVar(I), "seed");
5882
5882
  return {
5883
5883
  seed: (globalThis.__TYPEGPU_AUTONAME__ ?? ((t) => t))(M.fn([b])(((t) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(t.f = ((r) => {
@@ -5912,7 +5912,7 @@ const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5912
5912
  ast: { params: [{ type: "i", name: "value" }], body: [0, [[2, [7, "seed", "value"], "=", [6, "add", [[7, "value", "xy"], [7, "value", "zw"]]]]]], externalNames: ["seed", "add"] },
5913
5913
  externals: () => ({ seed: e, add: B })
5914
5914
  }) && t.f)({})), "seed4"),
5915
- sample: Jg(((t) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(t.f = ((r) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(r.f = (() => {
5915
+ sample: Vg(((t) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(t.f = ((r) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(r.f = (() => {
5916
5916
  "use gpu";
5917
5917
  const n = ce(e.value, I(23.14077926, 232.61690225)), a = ce(e.value, I(54.47856553, 345.84153136));
5918
5918
  return e.value.x = xt(Qe(n) * 136.8168), e.value.y = xt(Qe(a) * 534.7645), e.value.y;
@@ -5928,9 +5928,9 @@ const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5928
5928
  externals: () => ({ dot: ce, seed: e, d: K, fract: xt, cos: Qe })
5929
5929
  }) && t.f)({}))
5930
5930
  };
5931
- })(), Zg = Xg, L = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.slot(
5932
- Zg
5933
- ), "randomGeneratorSlot"), qt = Math.PI * 2, hn = 1e-7, Qg = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([b])(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
5931
+ })(), Xg = Jg, L = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.slot(
5932
+ Xg
5933
+ ), "randomGeneratorSlot"), qt = Math.PI * 2, hn = 1e-7, Zg = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([b])(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
5934
5934
  L.value.seed(t);
5935
5935
  }), {
5936
5936
  v: 1,
@@ -5951,19 +5951,19 @@ const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5951
5951
  name: void 0,
5952
5952
  ast: { params: [{ type: "i", name: "seed" }], body: [0, [[6, [7, [7, "randomGeneratorSlot", "value"], "seed3"], ["seed"]]]], externalNames: ["randomGeneratorSlot"] },
5953
5953
  externals: () => ({ randomGeneratorSlot: L })
5954
- }) && e.f)({})), "randSeed3"), Kg = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([C])(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
5954
+ }) && e.f)({})), "randSeed3"), Qg = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([C])(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
5955
5955
  L.value.seed4(t);
5956
5956
  }), {
5957
5957
  v: 1,
5958
5958
  name: void 0,
5959
5959
  ast: { params: [{ type: "i", name: "seed" }], body: [0, [[6, [7, [7, "randomGeneratorSlot", "value"], "seed4"], ["seed"]]]], externalNames: ["randomGeneratorSlot"] },
5960
5960
  externals: () => ({ randomGeneratorSlot: L })
5961
- }) && e.f)({})), "randSeed4"), Hg = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], b)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (() => L.value.sample()), {
5961
+ }) && e.f)({})), "randSeed4"), Kg = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], b)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (() => L.value.sample()), {
5962
5962
  v: 1,
5963
5963
  name: void 0,
5964
5964
  ast: { params: [], body: [0, [[10, [6, [7, [7, "randomGeneratorSlot", "value"], "sample"], []]]]], externalNames: ["randomGeneratorSlot"] },
5965
5965
  externals: () => ({ randomGeneratorSlot: L })
5966
- }) && e.f)({})), "randFloat01"), ev = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], T)(
5966
+ }) && e.f)({})), "randFloat01"), Hg = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], T)(
5967
5967
  ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (() => T(
5968
5968
  L.value.sample(),
5969
5969
  L.value.sample(),
@@ -5974,7 +5974,7 @@ const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5974
5974
  ast: { params: [], body: [0, [[10, [6, [7, "d", "vec3f"], [[6, [7, [7, "randomGeneratorSlot", "value"], "sample"], []], [6, [7, [7, "randomGeneratorSlot", "value"], "sample"], []], [6, [7, [7, "randomGeneratorSlot", "value"], "sample"], []]]]]]], externalNames: ["d", "randomGeneratorSlot"] },
5975
5975
  externals: () => ({ d: K, randomGeneratorSlot: L })
5976
5976
  }) && e.f)({})
5977
- ), "randInUnitCube"), tv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], T)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (() => {
5977
+ ), "randInUnitCube"), ev = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], T)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (() => {
5978
5978
  const t = y(L.value.sample() * 6), r = t % 3, n = T();
5979
5979
  return n[r] = b(pt(0, 1, t > 2)), n[(r + 1) % 3] = L.value.sample(), n[(r + 2) % 3] = L.value.sample(), n;
5980
5980
  }), {
@@ -5982,14 +5982,14 @@ const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5982
5982
  name: void 0,
5983
5983
  ast: { params: [], body: [0, [[13, "face", [6, [7, "d", "u32"], [[1, [6, [7, [7, "randomGeneratorSlot", "value"], "sample"], []], "*", [5, "6"]]]]], [13, "axis", [1, "face", "%", [5, "3"]]], [13, "result", [6, [7, "d", "vec3f"], []]], [2, [8, "result", "axis"], "=", [6, [7, "d", "f32"], [[6, "select", [[5, "0"], [5, "1"], [1, "face", ">", [5, "2"]]]]]]], [2, [8, "result", [1, [1, "axis", "+", [5, "1"]], "%", [5, "3"]]], "=", [6, [7, [7, "randomGeneratorSlot", "value"], "sample"], []]], [2, [8, "result", [1, [1, "axis", "+", [5, "2"]], "%", [5, "3"]]], "=", [6, [7, [7, "randomGeneratorSlot", "value"], "sample"], []]], [10, "result"]]], externalNames: ["d", "randomGeneratorSlot", "select"] },
5984
5984
  externals: () => ({ d: K, randomGeneratorSlot: L, select: pt })
5985
- }) && e.f)({})), "randOnUnitCube"), rv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], I)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (() => {
5986
- const t = sr(L.value.sample()), r = L.value.sample() * qt;
5985
+ }) && e.f)({})), "randOnUnitCube"), tv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], I)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (() => {
5986
+ const t = or(L.value.sample()), r = L.value.sample() * qt;
5987
5987
  return I(Qe(r) * t, Ut(r) * t);
5988
5988
  }), {
5989
5989
  v: 1,
5990
5990
  name: void 0,
5991
5991
  ast: { params: [], body: [0, [[13, "radius", [6, "sqrt", [[6, [7, [7, "randomGeneratorSlot", "value"], "sample"], []]]]], [13, "angle", [1, [6, [7, [7, "randomGeneratorSlot", "value"], "sample"], []], "*", "TWO_PI"]], [10, [6, [7, "d", "vec2f"], [[1, [6, "cos", ["angle"]], "*", "radius"], [1, [6, "sin", ["angle"]], "*", "radius"]]]]]], externalNames: ["sqrt", "randomGeneratorSlot", "TWO_PI", "d", "cos", "sin"] },
5992
- externals: () => ({ sqrt: sr, randomGeneratorSlot: L, TWO_PI: qt, d: K, cos: Qe, sin: Ut })
5992
+ externals: () => ({ sqrt: or, randomGeneratorSlot: L, TWO_PI: qt, d: K, cos: Qe, sin: Ut })
5993
5993
  }) && e.f)({})), "randInUnitCircle"), Ha = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], I)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (() => {
5994
5994
  const t = L.value.sample() * qt;
5995
5995
  return I(Qe(t), Ut(t));
@@ -6017,14 +6017,14 @@ const ei = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], T)(((e) => (
6017
6017
  ast: { params: [], body: [0, [[13, "u", [6, [7, [7, "randomGeneratorSlot", "value"], "sample"], []]], [13, "v", [6, [7, "d", "vec3f"], [[6, "randNormal", [[5, "0"], [5, "1"]]], [6, "randNormal", [[5, "0"], [5, "1"]]], [6, "randNormal", [[5, "0"], [5, "1"]]]]]], [13, "vNorm", [6, "normalize", ["v"]]], [10, [6, [7, "vNorm", "mul"], [[6, "pow", ["u", [5, "0.33"]]]]]]]], externalNames: ["randomGeneratorSlot", "d", "randNormal", "normalize", "pow"] },
6018
6018
  externals: () => ({ randomGeneratorSlot: L, d: K, randNormal: on, normalize: gn, pow: ta })
6019
6019
  }) && e.f)({})), "randInUnitSphere"), bn = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], T)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = (() => {
6020
- const t = 2 * L.value.sample() - 1, r = sr(1 - t * t), n = qt * L.value.sample(), a = Qe(n) * r, i = Ut(n) * r;
6020
+ const t = 2 * L.value.sample() - 1, r = or(1 - t * t), n = qt * L.value.sample(), a = Qe(n) * r, i = Ut(n) * r;
6021
6021
  return T(a, i, t);
6022
6022
  }), {
6023
6023
  v: 1,
6024
6024
  name: void 0,
6025
6025
  ast: { params: [], body: [0, [[13, "z", [1, [1, [5, "2"], "*", [6, [7, [7, "randomGeneratorSlot", "value"], "sample"], []]], "-", [5, "1"]]], [13, "oneMinusZSq", [6, "sqrt", [[1, [5, "1"], "-", [1, "z", "*", "z"]]]]], [13, "theta", [1, "TWO_PI", "*", [6, [7, [7, "randomGeneratorSlot", "value"], "sample"], []]]], [13, "x", [1, [6, "cos", ["theta"]], "*", "oneMinusZSq"]], [13, "y", [1, [6, "sin", ["theta"]], "*", "oneMinusZSq"]], [10, [6, [7, "d", "vec3f"], ["x", "y", "z"]]]]], externalNames: ["randomGeneratorSlot", "sqrt", "TWO_PI", "cos", "sin", "d"] },
6026
- externals: () => ({ randomGeneratorSlot: L, sqrt: sr, TWO_PI: qt, cos: Qe, sin: Ut, d: K })
6027
- }) && e.f)({})), "randOnUnitSphere"), nv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([T], T)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
6026
+ externals: () => ({ randomGeneratorSlot: L, sqrt: or, TWO_PI: qt, cos: Qe, sin: Ut, d: K })
6027
+ }) && e.f)({})), "randOnUnitSphere"), rv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([T], T)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
6028
6028
  const r = ei(), n = ce(t, r);
6029
6029
  return N(vn(n), r);
6030
6030
  }), {
@@ -6032,7 +6032,7 @@ const ei = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], T)(((e) => (
6032
6032
  name: void 0,
6033
6033
  ast: { params: [{ type: "i", name: "normal" }], body: [0, [[13, "value", [6, "randInUnitSphere", []]], [13, "alignment", [6, "dot", ["normal", "value"]]], [10, [6, "mul", [[6, "sign", ["alignment"]], "value"]]]]], externalNames: ["randInUnitSphere", "dot", "mul", "sign"] },
6034
6034
  externals: () => ({ randInUnitSphere: ei, dot: ce, mul: N, sign: vn })
6035
- }) && e.f)({})), "randInUnitHemisphere"), av = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([T], T)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
6035
+ }) && e.f)({})), "randInUnitHemisphere"), nv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([T], T)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
6036
6036
  const r = bn(), n = ce(t, r);
6037
6037
  return N(vn(n), r);
6038
6038
  }), {
@@ -6047,13 +6047,13 @@ const ei = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], T)(((e) => (
6047
6047
  externals: () => ({ randomGeneratorSlot: L, EPS: hn })
6048
6048
  }) && e.f)({})), "randUniformExclusive"), on = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([b, b], b)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t, r) => {
6049
6049
  const n = qt * Rt();
6050
- return sr(-2 * yn(Rt())) * Ut(n) * r + t;
6050
+ return or(-2 * yn(Rt())) * Ut(n) * r + t;
6051
6051
  }), {
6052
6052
  v: 1,
6053
6053
  name: void 0,
6054
6054
  ast: { params: [{ type: "i", name: "mu" }, { type: "i", name: "sigma" }], body: [0, [[13, "theta", [1, "TWO_PI", "*", [6, "randUniformExclusive", []]]], [13, "R", [6, "sqrt", [[1, [4, "-", [5, "2"]], "*", [6, "log", [[6, "randUniformExclusive", []]]]]]]], [10, [1, [1, [1, "R", "*", [6, "sin", ["theta"]]], "*", "sigma"], "+", "mu"]]]], externalNames: ["TWO_PI", "randUniformExclusive", "sqrt", "log", "sin"] },
6055
- externals: () => ({ TWO_PI: qt, randUniformExclusive: Rt, sqrt: sr, log: yn, sin: Ut })
6056
- }) && e.f)({})), "randNormal"), iv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([b], b)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
6055
+ externals: () => ({ TWO_PI: qt, randUniformExclusive: Rt, sqrt: or, log: yn, sin: Ut })
6056
+ }) && e.f)({})), "randNormal"), av = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([b], b)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
6057
6057
  const r = Rt();
6058
6058
  return -1 / t * yn(r);
6059
6059
  }), {
@@ -6061,7 +6061,7 @@ const ei = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], T)(((e) => (
6061
6061
  name: void 0,
6062
6062
  ast: { params: [{ type: "i", name: "rate" }], body: [0, [[13, "u", [6, "randUniformExclusive", []]], [10, [1, [1, [4, "-", [5, "1"]], "/", "rate"], "*", [6, "log", ["u"]]]]]], externalNames: ["randUniformExclusive", "log"] },
6063
6063
  externals: () => ({ randUniformExclusive: Rt, log: yn })
6064
- }) && e.f)({})), "randExponential"), sv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([b, b], b)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t, r) => {
6064
+ }) && e.f)({})), "randExponential"), iv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([b, b], b)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t, r) => {
6065
6065
  const n = Rt();
6066
6066
  return t + r * Fa(Math.PI * (n - 0.5));
6067
6067
  }), {
@@ -6069,7 +6069,7 @@ const ei = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], T)(((e) => (
6069
6069
  name: void 0,
6070
6070
  ast: { params: [{ type: "i", name: "x0" }, { type: "i", name: "gamma" }], body: [0, [[13, "u", [6, "randUniformExclusive", []]], [10, [1, "x0", "+", [1, "gamma", "*", [6, "tan", [[1, [7, "Math", "PI"], "*", [1, "u", "-", [5, "0.5"]]]]]]]]]], externalNames: ["randUniformExclusive", "tan", "Math"] },
6071
6071
  externals: () => ({ randUniformExclusive: Rt, tan: Fa, Math })
6072
- }) && e.f)({})), "randCauchy"), ov = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([b], b)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
6072
+ }) && e.f)({})), "randCauchy"), sv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([b], b)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
6073
6073
  const r = L.value.sample();
6074
6074
  return Ca(r, t);
6075
6075
  }), {
@@ -6105,23 +6105,23 @@ const ei = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([], T)(((e) => (
6105
6105
  externals: () => ({ mul: N, add: B, sub: W })
6106
6106
  }) && e.f)({}), vs = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([I], I)(Eu), "quinticDerivative2");
6107
6107
  (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([T], T)(Eu), "quinticDerivative3");
6108
- const uv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([pe], I)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => (Qa(N(1e-3, I(t))), Ha())), {
6108
+ const ov = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([pe], I)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => (Qa(N(1e-3, I(t))), Ha())), {
6109
6109
  v: 1,
6110
6110
  name: void 0,
6111
6111
  ast: { params: [{ type: "i", name: "pos" }], body: [0, [[6, "randSeed2", [[6, "mul", [[5, "0.001"], [6, [7, "d", "vec2f"], ["pos"]]]]]], [10, [6, "randOnUnitCircle", []]]]], externalNames: ["randSeed2", "mul", "d", "randOnUnitCircle"] },
6112
6112
  externals: () => ({ randSeed2: Qa, mul: N, d: K, randOnUnitCircle: Ha })
6113
- }) && e.f)({})), "computeJunctionGradient"), ut = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.slot(uv), "getJunctionGradientSlot");
6113
+ }) && e.f)({})), "computeJunctionGradient"), ut = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.slot(ov), "getJunctionGradientSlot");
6114
6114
  (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([I], b)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
6115
- const r = pe(ir(t)), n = xt(t), a = oa(n), i = ut.$(r), s = ut.$(B(r, pe(1, 0))), o = ut.$(B(r, pe(0, 1))), u = ut.$(B(r, pe(1, 1))), l = ce(i, W(n, I(0, 0))), d = ce(s, W(n, I(1, 0))), h = ce(o, W(n, I(0, 1))), f = ce(u, W(n, I(1, 1)));
6115
+ const r = pe(sr(t)), n = xt(t), a = oa(n), i = ut.$(r), s = ut.$(B(r, pe(1, 0))), o = ut.$(B(r, pe(0, 1))), u = ut.$(B(r, pe(1, 1))), l = ce(i, W(n, I(0, 0))), d = ce(s, W(n, I(1, 0))), h = ce(o, W(n, I(0, 1))), f = ce(u, W(n, I(1, 1)));
6116
6116
  return l + a.x * (d - l) + a.y * (h - l) + a.x * a.y * (l - d - h + f);
6117
6117
  }), {
6118
6118
  v: 1,
6119
6119
  name: void 0,
6120
6120
  ast: { params: [{ type: "i", name: "pos" }], body: [0, [[13, "i", [6, [7, "d", "vec2i"], [[6, "floor", ["pos"]]]]], [13, "f", [6, "fract", ["pos"]]], [13, "u", [6, "quinticInterpolation2", ["f"]]], [13, "ga", [6, [7, "getJunctionGradientSlot", "$"], ["i"]]], [13, "gb", [6, [7, "getJunctionGradientSlot", "$"], [[6, "add", ["i", [6, [7, "d", "vec2i"], [[5, "1"], [5, "0"]]]]]]]], [13, "gc", [6, [7, "getJunctionGradientSlot", "$"], [[6, "add", ["i", [6, [7, "d", "vec2i"], [[5, "0"], [5, "1"]]]]]]]], [13, "gd", [6, [7, "getJunctionGradientSlot", "$"], [[6, "add", ["i", [6, [7, "d", "vec2i"], [[5, "1"], [5, "1"]]]]]]]], [13, "va", [6, "dot", ["ga", [6, "sub", ["f", [6, [7, "d", "vec2f"], [[5, "0"], [5, "0"]]]]]]]], [13, "vb", [6, "dot", ["gb", [6, "sub", ["f", [6, [7, "d", "vec2f"], [[5, "1"], [5, "0"]]]]]]]], [13, "vc", [6, "dot", ["gc", [6, "sub", ["f", [6, [7, "d", "vec2f"], [[5, "0"], [5, "1"]]]]]]]], [13, "vd", [6, "dot", ["gd", [6, "sub", ["f", [6, [7, "d", "vec2f"], [[5, "1"], [5, "1"]]]]]]]], [13, "noise", [1, [1, [1, "va", "+", [1, [7, "u", "x"], "*", [1, "vb", "-", "va"]]], "+", [1, [7, "u", "y"], "*", [1, "vc", "-", "va"]]], "+", [1, [1, [7, "u", "x"], "*", [7, "u", "y"]], "*", [1, [1, [1, "va", "-", "vb"], "-", "vc"], "+", "vd"]]]], [10, "noise"]]], externalNames: ["d", "floor", "fract", "quinticInterpolation2", "getJunctionGradientSlot", "add", "dot", "sub"] },
6121
- externals: () => ({ d: K, floor: ir, fract: xt, quinticInterpolation2: oa, getJunctionGradientSlot: ut, add: B, dot: ce, sub: W })
6121
+ externals: () => ({ d: K, floor: sr, fract: xt, quinticInterpolation2: oa, getJunctionGradientSlot: ut, add: B, dot: ce, sub: W })
6122
6122
  }) && e.f)({})), "sample");
6123
6123
  (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([I], T)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
6124
- const r = pe(ir(t)), n = xt(t), a = oa(n), i = vs(n), s = ut.$(r), o = ut.$(B(r, pe(1, 0))), u = ut.$(B(r, pe(0, 1))), l = ut.$(B(r, pe(1, 1))), d = ce(s, W(n, I(0, 0))), h = ce(o, W(n, I(1, 0))), f = ce(u, W(n, I(0, 1))), w = ce(l, W(n, I(1, 1))), $ = d + a.x * (h - d) + a.y * (f - d) + a.x * a.y * (d - h - f + w), S = B(
6124
+ const r = pe(sr(t)), n = xt(t), a = oa(n), i = vs(n), s = ut.$(r), o = ut.$(B(r, pe(1, 0))), u = ut.$(B(r, pe(0, 1))), l = ut.$(B(r, pe(1, 1))), d = ce(s, W(n, I(0, 0))), h = ce(o, W(n, I(1, 0))), f = ce(u, W(n, I(0, 1))), w = ce(l, W(n, I(1, 1))), $ = d + a.x * (h - d) + a.y * (f - d) + a.x * a.y * (d - h - f + w), S = B(
6125
6125
  s,
6126
6126
  B(
6127
6127
  B(
@@ -6136,16 +6136,16 @@ const uv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([pe], I)(((e) =>
6136
6136
  v: 1,
6137
6137
  name: void 0,
6138
6138
  ast: { params: [{ type: "i", name: "pos" }], body: [0, [[13, "i", [6, [7, "d", "vec2i"], [[6, "floor", ["pos"]]]]], [13, "f", [6, "fract", ["pos"]]], [13, "u", [6, "quinticInterpolation2", ["f"]]], [13, "du", [6, "quinticDerivative2", ["f"]]], [13, "ga", [6, [7, "getJunctionGradientSlot", "$"], ["i"]]], [13, "gb", [6, [7, "getJunctionGradientSlot", "$"], [[6, "add", ["i", [6, [7, "d", "vec2i"], [[5, "1"], [5, "0"]]]]]]]], [13, "gc", [6, [7, "getJunctionGradientSlot", "$"], [[6, "add", ["i", [6, [7, "d", "vec2i"], [[5, "0"], [5, "1"]]]]]]]], [13, "gd", [6, [7, "getJunctionGradientSlot", "$"], [[6, "add", ["i", [6, [7, "d", "vec2i"], [[5, "1"], [5, "1"]]]]]]]], [13, "va", [6, "dot", ["ga", [6, "sub", ["f", [6, [7, "d", "vec2f"], [[5, "0"], [5, "0"]]]]]]]], [13, "vb", [6, "dot", ["gb", [6, "sub", ["f", [6, [7, "d", "vec2f"], [[5, "1"], [5, "0"]]]]]]]], [13, "vc", [6, "dot", ["gc", [6, "sub", ["f", [6, [7, "d", "vec2f"], [[5, "0"], [5, "1"]]]]]]]], [13, "vd", [6, "dot", ["gd", [6, "sub", ["f", [6, [7, "d", "vec2f"], [[5, "1"], [5, "1"]]]]]]]], [13, "noise", [1, [1, [1, "va", "+", [1, [7, "u", "x"], "*", [1, "vb", "-", "va"]]], "+", [1, [7, "u", "y"], "*", [1, "vc", "-", "va"]]], "+", [1, [1, [7, "u", "x"], "*", [7, "u", "y"]], "*", [1, [1, [1, "va", "-", "vb"], "-", "vc"], "+", "vd"]]]], [13, "grad", [6, "add", ["ga", [6, "add", [[6, "add", [[6, "add", [[6, "mul", [[7, "u", "x"], [6, "sub", ["gb", "ga"]]]], [6, "mul", [[7, "u", "y"], [6, "sub", ["gc", "ga"]]]]]], [6, "mul", [[7, "u", "x"], [6, "mul", [[7, "u", "y"], [6, "add", [[6, "sub", [[6, "sub", ["ga", "gb"]], "gc"]], "gd"]]]]]]]], [6, "mul", ["du", [6, "sub", [[6, "add", [[6, "mul", [[7, "u", "yx"], [1, [1, [1, "va", "-", "vb"], "-", "vc"], "+", "vd"]]], [6, [7, "d", "vec2f"], ["vb", "vc"]]]], "va"]]]]]]]]], [10, [6, [7, "d", "vec3f"], ["noise", "grad"]]]]], externalNames: ["d", "floor", "fract", "quinticInterpolation2", "quinticDerivative2", "getJunctionGradientSlot", "add", "dot", "sub", "mul"] },
6139
- externals: () => ({ d: K, floor: ir, fract: xt, quinticInterpolation2: oa, quinticDerivative2: vs, getJunctionGradientSlot: ut, add: B, dot: ce, sub: W, mul: N })
6139
+ externals: () => ({ d: K, floor: sr, fract: xt, quinticInterpolation2: oa, quinticDerivative2: vs, getJunctionGradientSlot: ut, add: B, dot: ce, sub: W, mul: N })
6140
6140
  }) && e.f)({})), "sampleWithGradient");
6141
6141
  te(I);
6142
6142
  te(I);
6143
- const lv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([Fe], T)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => (Ka(N(1e-3, T(t))), bn())), {
6143
+ const uv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([Fe], T)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => (Ka(N(1e-3, T(t))), bn())), {
6144
6144
  v: 1,
6145
6145
  name: void 0,
6146
6146
  ast: { params: [{ type: "i", name: "pos" }], body: [0, [[6, "randSeed3", [[6, "mul", [[5, "0.001"], [6, [7, "d", "vec3f"], ["pos"]]]]]], [10, [6, "randOnUnitSphere", []]]]], externalNames: ["randSeed3", "mul", "d", "randOnUnitSphere"] },
6147
6147
  externals: () => ({ randSeed3: Ka, mul: N, d: K, randOnUnitSphere: bn })
6148
- }) && e.f)({})), "computeJunctionGradient"), ws = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.slot(lv), "getJunctionGradientSlot"), mt = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([T, T], b)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t, r) => {
6148
+ }) && e.f)({})), "computeJunctionGradient"), ws = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.slot(uv), "getJunctionGradientSlot"), mt = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([T, T], b)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t, r) => {
6149
6149
  const n = W(t, r), a = ws.value(Fe(r));
6150
6150
  return ce(n, a);
6151
6151
  }), {
@@ -6155,40 +6155,37 @@ const lv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([Fe], T)(((e) =>
6155
6155
  externals: () => ({ sub: W, getJunctionGradientSlot: ws, d: K, dot: ce })
6156
6156
  }) && e.f)({})), "dotProdGrid");
6157
6157
  (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M.fn([T], b)(((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t) => {
6158
- const r = ir(t), n = mt(t, r), a = mt(t, B(r, T(0, 0, 1))), i = mt(t, B(r, T(0, 1, 0))), s = mt(t, B(r, T(0, 1, 1))), o = mt(t, B(r, T(1, 0, 0))), u = mt(t, B(r, T(1, 0, 1))), l = mt(t, B(r, T(1, 1, 0))), d = mt(t, B(r, T(1, 1, 1))), h = W(t, r), f = gs(h), w = yt(n, a, f.z), $ = yt(i, s, f.z), S = yt(o, u, f.z), O = yt(l, d, f.z), G = yt(w, $, f.y), D = yt(S, O, f.y);
6158
+ const r = sr(t), n = mt(t, r), a = mt(t, B(r, T(0, 0, 1))), i = mt(t, B(r, T(0, 1, 0))), s = mt(t, B(r, T(0, 1, 1))), o = mt(t, B(r, T(1, 0, 0))), u = mt(t, B(r, T(1, 0, 1))), l = mt(t, B(r, T(1, 1, 0))), d = mt(t, B(r, T(1, 1, 1))), h = W(t, r), f = gs(h), w = yt(n, a, f.z), $ = yt(i, s, f.z), S = yt(o, u, f.z), O = yt(l, d, f.z), G = yt(w, $, f.y), D = yt(S, O, f.y);
6159
6159
  return yt(G, D, f.x);
6160
6160
  }), {
6161
6161
  v: 1,
6162
6162
  name: void 0,
6163
6163
  ast: { params: [{ type: "i", name: "pos" }], body: [0, [[13, "minJunction", [6, "floor", ["pos"]]], [13, "xyz", [6, "dotProdGrid", ["pos", "minJunction"]]], [13, "xyZ", [6, "dotProdGrid", ["pos", [6, "add", ["minJunction", [6, [7, "d", "vec3f"], [[5, "0"], [5, "0"], [5, "1"]]]]]]]], [13, "xYz", [6, "dotProdGrid", ["pos", [6, "add", ["minJunction", [6, [7, "d", "vec3f"], [[5, "0"], [5, "1"], [5, "0"]]]]]]]], [13, "xYZ", [6, "dotProdGrid", ["pos", [6, "add", ["minJunction", [6, [7, "d", "vec3f"], [[5, "0"], [5, "1"], [5, "1"]]]]]]]], [13, "Xyz", [6, "dotProdGrid", ["pos", [6, "add", ["minJunction", [6, [7, "d", "vec3f"], [[5, "1"], [5, "0"], [5, "0"]]]]]]]], [13, "XyZ", [6, "dotProdGrid", ["pos", [6, "add", ["minJunction", [6, [7, "d", "vec3f"], [[5, "1"], [5, "0"], [5, "1"]]]]]]]], [13, "XYz", [6, "dotProdGrid", ["pos", [6, "add", ["minJunction", [6, [7, "d", "vec3f"], [[5, "1"], [5, "1"], [5, "0"]]]]]]]], [13, "XYZ", [6, "dotProdGrid", ["pos", [6, "add", ["minJunction", [6, [7, "d", "vec3f"], [[5, "1"], [5, "1"], [5, "1"]]]]]]]], [13, "partial", [6, "sub", ["pos", "minJunction"]]], [13, "smoothPartial", [6, "quinticInterpolation3", ["partial"]]], [13, "xy", [6, "mix", ["xyz", "xyZ", [7, "smoothPartial", "z"]]]], [13, "xY", [6, "mix", ["xYz", "xYZ", [7, "smoothPartial", "z"]]]], [13, "Xy", [6, "mix", ["Xyz", "XyZ", [7, "smoothPartial", "z"]]]], [13, "XY", [6, "mix", ["XYz", "XYZ", [7, "smoothPartial", "z"]]]], [13, "x", [6, "mix", ["xy", "xY", [7, "smoothPartial", "y"]]]], [13, "X", [6, "mix", ["Xy", "XY", [7, "smoothPartial", "y"]]]], [10, [6, "mix", ["x", "X", [7, "smoothPartial", "x"]]]]]], externalNames: ["floor", "dotProdGrid", "add", "d", "sub", "quinticInterpolation3", "mix"] },
6164
- externals: () => ({ floor: ir, dotProdGrid: mt, add: B, d: K, sub: W, quinticInterpolation3: gs, mix: yt })
6164
+ externals: () => ({ floor: sr, dotProdGrid: mt, add: B, d: K, sub: W, quinticInterpolation3: gs, mix: yt })
6165
6165
  }) && e.f)({})), "sample");
6166
6166
  te(T);
6167
6167
  te(T);
6168
6168
  const Ma = {
6169
- seed: Qg,
6169
+ seed: Zg,
6170
6170
  seed2: Qa,
6171
6171
  seed3: Ka,
6172
- seed4: Kg,
6173
- sample: Hg,
6172
+ seed4: Qg,
6173
+ sample: Kg,
6174
6174
  sampleExclusive: Rt,
6175
6175
  normal: on,
6176
- exponential: iv,
6177
- cauchy: sv,
6178
- bernoulli: ov,
6179
- inUnitCircle: rv,
6176
+ exponential: av,
6177
+ cauchy: iv,
6178
+ bernoulli: sv,
6179
+ inUnitCircle: tv,
6180
6180
  onUnitCircle: Ha,
6181
- inUnitCube: ev,
6182
- onUnitCube: tv,
6183
- inHemisphere: nv,
6184
- onHemisphere: av,
6181
+ inUnitCube: Hg,
6182
+ onUnitCube: ev,
6183
+ inHemisphere: rv,
6184
+ onHemisphere: nv,
6185
6185
  inUnitSphere: ei,
6186
6186
  onUnitSphere: bn
6187
- }, Uu = await navigator.gpu.requestAdapter();
6188
- if (!Uu)
6189
- throw new Error("No adapter");
6190
- const kr = await Uu.requestDevice();
6191
- kr.lost.then(() => {
6187
+ }, lv = await navigator.gpu.requestAdapter(), er = await lv?.requestDevice();
6188
+ er?.lost.then(() => {
6192
6189
  throw new Error("Device lost");
6193
6190
  });
6194
6191
  let ht = 0, $n;
@@ -6233,7 +6230,7 @@ const Wv = (e) => {
6233
6230
  v: 1,
6234
6231
  name: "testNeighbor",
6235
6232
  ast: { params: [{ type: "i", name: "checkId" }, { type: "i", name: "x" }, { type: "i", name: "y" }], body: [0, [[10, [6, [7, "std", "select"], [[6, [7, "d", "u32"], [[5, "0"]]], [6, [7, "d", "u32"], [[5, "1"]]], [1, [8, [7, [7, [7, "gridLayout", "bound"], "ids"], "$"], [6, "pointToIndex", ["x", "y"]]], "===", "checkId"]]]]]], externalNames: ["std", "d", "gridLayout", "pointToIndex"] },
6236
- externals: () => ({ std: cr, d: K, gridLayout: Z, pointToIndex: ke })
6233
+ externals: () => ({ std: pr, d: K, gridLayout: Z, pointToIndex: ke })
6237
6234
  }) && e.f)({}), Xe = ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t, r, n) => {
6238
6235
  "use gpu";
6239
6236
  const a = Z.bound.ids.$[ke(r, n)];
@@ -6249,7 +6246,7 @@ const Wv = (e) => {
6249
6246
  v: 1,
6250
6247
  name: "testIdInPack",
6251
6248
  ast: { params: [{ type: "i", name: "packedIds" }, { type: "i", name: "x" }, { type: "i", name: "y" }], body: [0, [[13, "idMask", [8, [7, [7, [7, "gridLayout", "bound"], "ids"], "$"], [6, "pointToIndex", ["x", "y"]]]], [10, [6, [7, "std", "select"], [[6, [7, "d", "u32"], [[5, "0"]]], [6, [7, "d", "u32"], [[5, "1"]]], [1, [1, "packedIds", "&", [1, [6, [7, "d", "u32"], [[5, "1"]]], "<<", "idMask"]], "!==", [6, [7, "d", "u32"], [[5, "0"]]]]]]]]], externalNames: ["gridLayout", "pointToIndex", "std", "d"] },
6252
- externals: () => ({ gridLayout: Z, pointToIndex: ke, std: cr, d: K })
6249
+ externals: () => ({ gridLayout: Z, pointToIndex: ke, std: pr, d: K })
6253
6250
  }) && e.f)({}), ua = ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t, r, n, a) => {
6254
6251
  "use gpu";
6255
6252
  const i = ft(n, t - 1, r - 1) + ft(n, t, r - 1) + ft(n, t + 1, r - 1) + ft(n, t - 1, r) + ft(n, t + 1, r) + ft(n, t - 1, r + 1) + ft(n, t, r + 1) + ft(n, t + 1, r + 1);
@@ -6262,7 +6259,7 @@ const Wv = (e) => {
6262
6259
  v: 1,
6263
6260
  name: "checkIdCount",
6264
6261
  ast: { params: [{ type: "i", name: "x" }, { type: "i", name: "y" }, { type: "i", name: "checkId" }, { type: "i", name: "packedCount" }], body: [0, [[13, "countMask", [1, [1, [1, [1, [1, [1, [1, [6, "testNeighbor", ["checkId", [1, "x", "-", [5, "1"]], [1, "y", "-", [5, "1"]]]], "+", [6, "testNeighbor", ["checkId", "x", [1, "y", "-", [5, "1"]]]]], "+", [6, "testNeighbor", ["checkId", [1, "x", "+", [5, "1"]], [1, "y", "-", [5, "1"]]]]], "+", [6, "testNeighbor", ["checkId", [1, "x", "-", [5, "1"]], "y"]]], "+", [6, "testNeighbor", ["checkId", [1, "x", "+", [5, "1"]], "y"]]], "+", [6, "testNeighbor", ["checkId", [1, "x", "-", [5, "1"]], [1, "y", "+", [5, "1"]]]]], "+", [6, "testNeighbor", ["checkId", "x", [1, "y", "+", [5, "1"]]]]], "+", [6, "testNeighbor", ["checkId", [1, "x", "+", [5, "1"]], [1, "y", "+", [5, "1"]]]]]], [10, [6, [7, "std", "select"], [[6, [7, "d", "u32"], [[5, "0"]]], [6, [7, "d", "u32"], [[5, "1"]]], [1, [1, "packedCount", "&", [1, [6, [7, "d", "u32"], [[5, "1"]]], "<<", "countMask"]], "!==", [6, [7, "d", "u32"], [[5, "0"]]]]]]]]], externalNames: ["testNeighbor", "std", "d"] },
6265
- externals: () => ({ testNeighbor: ft, std: cr, d: K })
6262
+ externals: () => ({ testNeighbor: ft, std: pr, d: K })
6266
6263
  }) && e.f)({}), xs = ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t, r, n, a) => {
6267
6264
  "use gpu";
6268
6265
  const i = Xe(n, t - 1, r - 1) + Xe(n, t, r - 1) + Xe(n, t + 1, r - 1) + Xe(n, t - 1, r) + Xe(n, t + 1, r) + Xe(n, t - 1, r + 1) + Xe(n, t, r + 1) + Xe(n, t + 1, r + 1);
@@ -6275,7 +6272,7 @@ const Wv = (e) => {
6275
6272
  v: 1,
6276
6273
  name: "checkIdsCount",
6277
6274
  ast: { params: [{ type: "i", name: "x" }, { type: "i", name: "y" }, { type: "i", name: "packedIds" }, { type: "i", name: "packedCount" }], body: [0, [[13, "countMask", [1, [1, [1, [1, [1, [1, [1, [6, "testIdInPack", ["packedIds", [1, "x", "-", [5, "1"]], [1, "y", "-", [5, "1"]]]], "+", [6, "testIdInPack", ["packedIds", "x", [1, "y", "-", [5, "1"]]]]], "+", [6, "testIdInPack", ["packedIds", [1, "x", "+", [5, "1"]], [1, "y", "-", [5, "1"]]]]], "+", [6, "testIdInPack", ["packedIds", [1, "x", "-", [5, "1"]], "y"]]], "+", [6, "testIdInPack", ["packedIds", [1, "x", "+", [5, "1"]], "y"]]], "+", [6, "testIdInPack", ["packedIds", [1, "x", "-", [5, "1"]], [1, "y", "+", [5, "1"]]]]], "+", [6, "testIdInPack", ["packedIds", "x", [1, "y", "+", [5, "1"]]]]], "+", [6, "testIdInPack", ["packedIds", [1, "x", "+", [5, "1"]], [1, "y", "+", [5, "1"]]]]]], [10, [6, [7, "std", "select"], [[6, [7, "d", "u32"], [[5, "0"]]], [6, [7, "d", "u32"], [[5, "1"]]], [1, [1, "packedCount", "&", [1, [6, [7, "d", "u32"], [[5, "1"]]], "<<", "countMask"]], "!==", [6, [7, "d", "u32"], [[5, "0"]]]]]]]]], externalNames: ["testIdInPack", "std", "d"] },
6278
- externals: () => ({ testIdInPack: Xe, std: cr, d: K })
6275
+ externals: () => ({ testIdInPack: Xe, std: pr, d: K })
6279
6276
  }) && e.f)({}), bs = ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t, r, n, a) => {
6280
6277
  "use gpu";
6281
6278
  const i = ke(
@@ -6303,7 +6300,7 @@ const Wv = (e) => {
6303
6300
  v: 1,
6304
6301
  name: "comparePointWithId",
6305
6302
  ast: { params: [{ type: "i", name: "x" }, { type: "i", name: "y" }, { type: "i", name: "comparePoint" }, { type: "i", name: "withId" }], body: [0, [[13, "comparePointIndex", [6, "pointToIndex", [[1, "x", "+", [7, "comparePoint", "x"]], [1, "y", "+", [7, "comparePoint", "y"]]]]], [10, [6, [7, "std", "select"], [[6, [7, "d", "u32"], [[5, "0"]]], [6, [7, "d", "u32"], [[5, "1"]]], [1, [8, [7, [7, [7, "gridLayout", "bound"], "ids"], "$"], "comparePointIndex"], "===", "withId"]]]]]], externalNames: ["pointToIndex", "std", "d", "gridLayout"] },
6306
- externals: () => ({ pointToIndex: ke, std: cr, d: K, gridLayout: Z })
6303
+ externals: () => ({ pointToIndex: ke, std: pr, d: K, gridLayout: Z })
6307
6304
  }) && e.f)({}), Ts = ((e) => (globalThis.__TYPEGPU_META__ ??= /* @__PURE__ */ new WeakMap()).set(e.f = ((t, r, n, a) => {
6308
6305
  "use gpu";
6309
6306
  return Xe(a, t + n.x, r + n.y);
@@ -6327,7 +6324,7 @@ const Wv = (e) => {
6327
6324
  v: 1,
6328
6325
  name: "comparePointWithPoint",
6329
6326
  ast: { params: [{ type: "i", name: "x" }, { type: "i", name: "y" }, { type: "i", name: "comparePoint" }, { type: "i", name: "withPoint" }], body: [0, [[13, "comparePointIndex", [6, "pointToIndex", [[1, "x", "+", [7, "comparePoint", "x"]], [1, "y", "+", [7, "comparePoint", "y"]]]]], [13, "withPointIndex", [6, "pointToIndex", [[1, "x", "+", [7, "withPoint", "x"]], [1, "y", "+", [7, "withPoint", "y"]]]]], [10, [6, [7, "std", "select"], [[6, [7, "d", "u32"], [[5, "0"]]], [6, [7, "d", "u32"], [[5, "1"]]], [1, [8, [7, [7, [7, "gridLayout", "bound"], "ids"], "$"], "comparePointIndex"], "===", [8, [7, [7, [7, "gridLayout", "bound"], "ids"], "$"], "withPointIndex"]]]]]]], externalNames: ["pointToIndex", "std", "d", "gridLayout"] },
6330
- externals: () => ({ pointToIndex: ke, std: cr, d: K, gridLayout: Z })
6327
+ externals: () => ({ pointToIndex: ke, std: pr, d: K, gridLayout: Z })
6331
6328
  }) && e.f)({}), cv = (globalThis.__TYPEGPU_AUTONAME__ ?? ((e) => e))(M["~unstable"].computeFn({
6332
6329
  workgroupSize: Aa,
6333
6330
  in: { pos: fi.globalInvocationId }
@@ -6385,13 +6382,15 @@ const Wv = (e) => {
6385
6382
  v: 1,
6386
6383
  name: void 0,
6387
6384
  ast: { params: [{ type: "d", props: [{ name: "pos", alias: "pos" }] }], body: [0, [[13, "x", [7, "pos", "x"]], [13, "y", [7, "pos", "y"]], [13, "index", [6, "pointToIndex", ["x", "y"]]], [13, "color", [8, [7, [7, [7, "gridLayout", "bound"], "colors"], "$"], "index"]], [13, "id", [8, [7, [7, [7, "gridLayout", "bound"], "ids"], "$"], "index"]], [13, "element", [8, [7, [7, [7, "automatonLayout", "bound"], "elements"], "$"], "id"]], [13, "ruleStart", [7, "element", "ruleStart"]], [13, "ruleEnd", [7, "element", "ruleEnd"]], [14, [12, "i", "ruleStart"], [1, "i", "<", "ruleEnd"], [102, "++", "i"], [0, [[13, "rule", [8, [7, [7, [7, "automatonLayout", "bound"], "rules"], "$"], "i"]], [13, "accept", [7, "rule", "accept"]], [12, "passing", [6, [7, "d", "u32"], [[5, "0"]]]], [13, "conditionsStart", [7, "rule", "conditionsStart"]], [13, "conditionsEnd", [7, "rule", "conditionsEnd"]], [13, "conditionsCount", [1, "conditionsEnd", "-", "conditionsStart"]], [14, [12, "j", "conditionsStart"], [1, "j", "<", "conditionsEnd"], [102, "++", "j"], [0, [[13, "condition", [8, [7, [7, [7, "automatonLayout", "bound"], "conditions"], "$"], "j"]], [13, "opcode", [7, "condition", "opcode"]], [11, [1, "opcode", "===", [7, "Opcode", "COUNT_ELEMENT"]], [0, [[13, "checkId", [7, "condition", "checkId"]], [13, "count", [7, "condition", "countOrWithId"]], [2, "passing", "+=", [6, "checkIdCount", ["x", "y", "checkId", "count"]]]]], [11, [1, "opcode", "===", [7, "Opcode", "COUNT_POINT"]], [0, [[13, "checkPoint", [7, "condition", "checkPointOrComparePoint"]], [13, "count", [7, "condition", "countOrWithId"]], [2, "passing", "+=", [6, "checkPointCount", ["x", "y", "checkPoint", "count"]]]]], [11, [1, "opcode", "===", [7, "Opcode", "COUNT_KIND"]], [0, [[13, "packedIds", [7, "condition", "checkId"]], [13, "count", [7, "condition", "countOrWithId"]], [2, "passing", "+=", [6, "checkIdsCount", ["x", "y", "packedIds", "count"]]]]], [11, [1, "opcode", "===", [7, "Opcode", "IS_ELEMENT"]], [0, [[13, "comparePoint", [7, "condition", "checkPointOrComparePoint"]], [13, "withId", [7, "condition", "countOrWithId"]], [2, "passing", "+=", [6, "comparePointWithId", ["x", "y", "comparePoint", "withId"]]]]], [11, [1, "opcode", "===", [7, "Opcode", "IS_POINT"]], [0, [[13, "comparePoint", [7, "condition", "checkPointOrComparePoint"]], [13, "withPoint", [7, "condition", "withPoint"]], [2, "passing", "+=", [6, "comparePointWithPoint", ["x", "y", "comparePoint", "withPoint"]]]]], [11, [1, "opcode", "===", [7, "Opcode", "IS_KIND"]], [0, [[13, "comparePoint", [7, "condition", "checkPointOrComparePoint"]], [13, "packedIds", [7, "condition", "countOrWithId"]], [2, "passing", "+=", [6, "comparePointWithKindId", ["x", "y", "comparePoint", "packedIds"]]]]], [11, [1, "opcode", "===", [7, "Opcode", "CHANCE"]], [0, [[13, "chance", [7, "condition", "chance"]], [6, [7, "randf", "seed3"], [[6, [7, "d", "vec3f"], [[6, [7, "std", "div"], [[6, [7, "d", "vec2f"], [[7, "pos", "xy"]]], [6, [7, "d", "vec2f"], [[7, [7, [7, [7, "gridLayout", "bound"], "dimensions"], "$"], "xy"]]]]], [7, "seed", "$"]]]]], [2, "passing", "+=", [6, [7, "std", "select"], [[6, [7, "d", "u32"], [[5, "0"]]], [6, [7, "d", "u32"], [[5, "1"]]], [1, [6, [7, "randf", "sample"], []], "<", "chance"]]]]]]]]]]]]]]]], [11, [3, [3, [3, [3, [1, "accept", "===", [7, "Accept", "ALL"]], "&&", [1, "passing", "===", "conditionsCount"]], "||", [3, [1, "accept", "===", [7, "Accept", "ANY"]], "&&", [1, "passing", ">=", [6, [7, "d", "u32"], [[5, "1"]]]]]], "||", [3, [1, "accept", "===", [7, "Accept", "ONE"]], "&&", [1, "passing", "===", [6, [7, "d", "u32"], [[5, "1"]]]]]], "||", [3, [1, "accept", "===", [7, "Accept", "NONE"]], "&&", [1, "passing", "===", [6, [7, "d", "u32"], [[5, "0"]]]]]], [0, [[12, "resolvedId", [7, "rule", "toId"]], [13, "toType", [7, "rule", "toType"]], [11, [1, "toType", "===", [7, "To", "POINT"]], [0, [[13, "pointIndex", [6, "pointToIndex", [[1, "x", "+", [6, [7, "d", "u32"], [[7, [7, "rule", "toNeighbor"], "x"]]]], [1, "y", "+", [6, [7, "d", "u32"], [[7, [7, "rule", "toNeighbor"], "y"]]]]]]], [2, "resolvedId", "=", [8, [7, [7, [7, "gridLayout", "bound"], "ids"], "$"], "pointIndex"]]]]], [2, [8, [7, [7, [7, "gridLayout", "bound"], "newIds"], "$"], "index"], "=", "resolvedId"], [2, [8, [7, [7, [7, "gridLayout", "bound"], "newColors"], "$"], "index"], "=", [7, [8, [7, [7, [7, "automatonLayout", "bound"], "elements"], "$"], "resolvedId"], "color"]], [10]]]]]]], [2, [8, [7, [7, [7, "gridLayout", "bound"], "newIds"], "$"], "index"], "=", "id"], [2, [8, [7, [7, [7, "gridLayout", "bound"], "newColors"], "$"], "index"], "=", "color"]]], externalNames: ["pointToIndex", "gridLayout", "automatonLayout", "d", "Opcode", "checkIdCount", "checkPointCount", "checkIdsCount", "comparePointWithId", "comparePointWithPoint", "comparePointWithKindId", "randf", "std", "seed", "Accept", "To"] },
6388
- externals: () => ({ pointToIndex: ke, gridLayout: Z, automatonLayout: Ar, d: K, Opcode: Ot, checkIdCount: ua, checkPointCount: bs, checkIdsCount: xs, comparePointWithId: $s, comparePointWithPoint: _s, comparePointWithKindId: Ts, randf: Ma, std: cr, seed: $n, Accept: Hr, To: Ci })
6385
+ externals: () => ({ pointToIndex: ke, gridLayout: Z, automatonLayout: Ar, d: K, Opcode: Ot, checkIdCount: ua, checkPointCount: bs, checkIdsCount: xs, comparePointWithId: $s, comparePointWithPoint: _s, comparePointWithKindId: Ts, randf: Ma, std: pr, seed: $n, Accept: Hr, To: Ci })
6389
6386
  }) && e.f)({})), "mainCompute"), jv = ({
6390
6387
  canvas: e,
6391
6388
  automaton: t,
6392
6389
  initialGrid: r
6393
6390
  }) => {
6394
- const n = M.initFromDevice({ device: kr }), a = (globalThis.__TYPEGPU_AUTONAME__ ?? ((E) => E))(n["~unstable"].withCompute(cv).createPipeline(), "pipeline");
6391
+ if (!er)
6392
+ throw Error("No adapter");
6393
+ const n = M.initFromDevice({ device: er }), a = (globalThis.__TYPEGPU_AUTONAME__ ?? ((E) => E))(n["~unstable"].withCompute(cv).createPipeline(), "pipeline");
6395
6394
  ht = 0, $n = (globalThis.__TYPEGPU_AUTONAME__ ?? ((E) => E))(n.createUniform(b), "seed");
6396
6395
  const { width: i, height: s } = e, o = e.getContext("2d"), u = Math.ceil(i / Aa[0]), l = Math.ceil(s / Aa[1]), d = (globalThis.__TYPEGPU_AUTONAME__ ?? ((E) => E))(n.createBuffer(Be, Be(i, s)).$usage("uniform"), "dimensions"), h = (globalThis.__TYPEGPU_AUTONAME__ ?? ((E) => E))(n.createBuffer(te(y, i * s)).$usage("storage"), "colors0"), f = (globalThis.__TYPEGPU_AUTONAME__ ?? ((E) => E))(n.createBuffer(te(y, i * s)).$usage("storage"), "colors1"), w = (globalThis.__TYPEGPU_AUTONAME__ ?? ((E) => E))(n.createBuffer(te(y, i * s)).$usage("storage"), "ids0"), $ = (globalThis.__TYPEGPU_AUTONAME__ ?? ((E) => E))(n.createBuffer(te(y, i * s)).$usage("storage"), "ids1"), S = (globalThis.__TYPEGPU_AUTONAME__ ?? ((E) => E))(n.createBuffer(te(y, i * s)).$addFlags(GPUBufferUsage.MAP_READ), "colorsStagingBuffer"), O = n.createBindGroup(Z, {
6397
6396
  dimensions: d,
@@ -6408,25 +6407,25 @@ const Wv = (e) => {
6408
6407
  });
6409
6408
  let D, ee = [];
6410
6409
  const fe = ({ automaton: E }) => {
6411
- const { gpuNeighborhood: q, gpuElements: Te, gpuRules: Xt, gpuConditions: dr } = Kl(E);
6410
+ const { gpuNeighborhood: q, gpuElements: Te, gpuRules: Xt, gpuConditions: mr } = Ql(E);
6412
6411
  ee = Te.map((_e) => _e.color);
6413
- const mr = Xt.length > 0 ? Xt : [ka()], dt = dr.length > 0 ? dr : [za()];
6412
+ const hr = Xt.length > 0 ? Xt : [ka()], dt = mr.length > 0 ? mr : [za()];
6414
6413
  D = n.createBindGroup(Ar, {
6415
6414
  neighborhood: (globalThis.__TYPEGPU_AUTONAME__ ?? ((_e) => _e))(n.createBuffer(y, q).$usage("uniform"), "neighborhood"),
6416
6415
  elements: (globalThis.__TYPEGPU_AUTONAME__ ?? ((_e) => _e))(n.createBuffer(
6417
6416
  te(Ns, Math.max(Te.length, 1)),
6418
6417
  Te
6419
6418
  ).$usage("storage"), "elements"),
6420
- rules: (globalThis.__TYPEGPU_AUTONAME__ ?? ((_e) => _e))(n.createBuffer(te(ka, mr.length), mr).$usage("storage"), "rules"),
6419
+ rules: (globalThis.__TYPEGPU_AUTONAME__ ?? ((_e) => _e))(n.createBuffer(te(ka, hr.length), hr).$usage("storage"), "rules"),
6421
6420
  conditions: (globalThis.__TYPEGPU_AUTONAME__ ?? ((_e) => _e))(n.createBuffer(te(za, dt.length), dt).$usage("storage"), "conditions")
6422
6421
  });
6423
6422
  };
6424
6423
  fe({ automaton: t });
6425
- const ne = new Uint32Array(i * s), Vt = new Uint32Array(i * s), Jt = t.elements.length, pr = r?.flat();
6424
+ const ne = new Uint32Array(i * s), Vt = new Uint32Array(i * s), Jt = t.elements.length, dr = r?.flat();
6426
6425
  for (let E = 0; E < ne.length; E++) {
6427
6426
  let q;
6428
- if (pr !== void 0) {
6429
- const Te = pr[E] ?? 0;
6427
+ if (dr !== void 0) {
6428
+ const Te = dr[E] ?? 0;
6430
6429
  if (!Number.isFinite(Te) || !Number.isInteger(Te) || Te < 0 || Te >= Jt)
6431
6430
  throw new Error(
6432
6431
  `Element index ${Te} from initialGrid is invalid. Expected a finite integer in range [0, ${Jt - 1}]. Make sure to use ElementBlueprint.index to build the initialGrid with pre-existing indices.`
@@ -6437,7 +6436,7 @@ const Wv = (e) => {
6437
6436
  ne[E] = ee[q], Vt[E] = q;
6438
6437
  }
6439
6438
  h.write(Array.from(ne)), w.write(Array.from(Vt));
6440
- const kn = o.createImageData(i, s), Mu = new Uint32Array(kn.data.buffer), Pu = async () => {
6439
+ const kn = o.createImageData(i, s), Uu = new Uint32Array(kn.data.buffer), Mu = async () => {
6441
6440
  const q = await (ht % 2 === 0 ? w : $).read();
6442
6441
  return Array.from(q);
6443
6442
  }, _i = (E, q) => {
@@ -6449,11 +6448,11 @@ const Wv = (e) => {
6449
6448
  throw new Error(
6450
6449
  `Element index ${q} is invalid. Expected a finite integer in range [0, ${ee.length - 1}].`
6451
6450
  );
6452
- const Te = ht % 2 === 0 ? w : $, Xt = ht % 2 === 0 ? h : f, dr = new Uint32Array([q]);
6453
- kr.queue.writeBuffer(Te.buffer, E * 4, dr);
6454
- const mr = new Uint32Array([ee[q]]);
6455
- kr.queue.writeBuffer(Xt.buffer, E * 4, mr);
6456
- }, Su = (E, q, Te) => {
6451
+ const Te = ht % 2 === 0 ? w : $, Xt = ht % 2 === 0 ? h : f, mr = new Uint32Array([q]);
6452
+ er.queue.writeBuffer(Te.buffer, E * 4, mr);
6453
+ const hr = new Uint32Array([ee[q]]);
6454
+ er.queue.writeBuffer(Xt.buffer, E * 4, hr);
6455
+ }, Pu = (E, q, Te) => {
6457
6456
  if (E < 0 || E >= i)
6458
6457
  throw new Error(
6459
6458
  `Column ${E} is out of bounds. Expected a value in range [0, ${i - 1}].`
@@ -6463,7 +6462,7 @@ const Wv = (e) => {
6463
6462
  `Row ${q} is out of bounds. Expected a value in range [0, ${s - 1}].`
6464
6463
  );
6465
6464
  _i(q * i + E, Te);
6466
- }, zu = (E) => {
6465
+ }, Su = (E) => {
6467
6466
  const q = i * s;
6468
6467
  if (E.length !== q)
6469
6468
  throw new Error(
@@ -6478,14 +6477,14 @@ const Wv = (e) => {
6478
6477
  );
6479
6478
  Te[dt] = _e, Xt[dt] = ee[_e];
6480
6479
  }
6481
- const dr = ht % 2 === 0 ? w : $, mr = ht % 2 === 0 ? h : f;
6482
- kr.queue.writeBuffer(dr.buffer, 0, Te), kr.queue.writeBuffer(mr.buffer, 0, Xt);
6480
+ const mr = ht % 2 === 0 ? w : $, hr = ht % 2 === 0 ? h : f;
6481
+ er.queue.writeBuffer(mr.buffer, 0, Te), er.queue.writeBuffer(hr.buffer, 0, Xt);
6483
6482
  }, Ii = () => {
6484
6483
  $n.write(Math.random()), a.with(D).with(ht % 2 === 0 ? O : G).dispatchWorkgroups(u, l), ht++;
6485
6484
  }, Ei = async () => {
6486
6485
  S.copyFrom(ht % 2 === 0 ? h : f);
6487
6486
  const E = S.buffer;
6488
- await E.mapAsync(GPUMapMode.READ), Mu.set(new Uint32Array(E.getMappedRange())), o.putImageData(kn, 0, 0), E.unmap();
6487
+ await E.mapAsync(GPUMapMode.READ), Uu.set(new Uint32Array(E.getMappedRange())), o.putImageData(kn, 0, 0), E.unmap();
6489
6488
  };
6490
6489
  return {
6491
6490
  update: Ii,
@@ -6493,10 +6492,10 @@ const Wv = (e) => {
6493
6492
  evolve: async () => {
6494
6493
  Ii(), await Ei();
6495
6494
  },
6496
- readGrid: Pu,
6495
+ readGrid: Mu,
6497
6496
  writeCell: _i,
6498
- writeCellAt: Su,
6499
- writeGrid: zu,
6497
+ writeCellAt: Pu,
6498
+ writeGrid: Su,
6500
6499
  setAutomaton: fe,
6501
6500
  tgpuRoot: n
6502
6501
  };