typegpu 0.5.8 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/chunk-APTRHY5Y.js +41 -0
  2. package/chunk-APTRHY5Y.js.map +1 -0
  3. package/chunk-RC26P3MP.cjs +2 -0
  4. package/chunk-RC26P3MP.cjs.map +1 -0
  5. package/chunk-RK6TMFVW.js +2 -0
  6. package/chunk-RK6TMFVW.js.map +1 -0
  7. package/chunk-S62QJDM6.js +2 -0
  8. package/chunk-S62QJDM6.js.map +1 -0
  9. package/chunk-TG4A6AM3.cjs +2 -0
  10. package/chunk-TG4A6AM3.cjs.map +1 -0
  11. package/chunk-UMHCZDPA.cjs +41 -0
  12. package/chunk-UMHCZDPA.cjs.map +1 -0
  13. package/data/index.cjs +1 -1
  14. package/data/index.cjs.map +1 -1
  15. package/data/index.d.cts +30 -77
  16. package/data/index.d.ts +30 -77
  17. package/data/index.js +1 -1
  18. package/index.cjs +21 -20
  19. package/index.cjs.map +1 -1
  20. package/index.d.cts +65 -12
  21. package/index.d.ts +65 -12
  22. package/index.js +21 -20
  23. package/index.js.map +1 -1
  24. package/matrix-BN6ObiMv.d.cts +122 -0
  25. package/matrix-S8W4dk8I.d.ts +122 -0
  26. package/package.json +1 -1
  27. package/std/index.cjs +1 -1
  28. package/std/index.cjs.map +1 -1
  29. package/std/index.d.cts +69 -2
  30. package/std/index.d.ts +69 -2
  31. package/std/index.js +1 -1
  32. package/std/index.js.map +1 -1
  33. package/{tgpuComputeFn-S61HxwW-.d.ts → tgpuComputeFn-DOUjhQua.d.cts} +402 -127
  34. package/{tgpuComputeFn-S61HxwW-.d.cts → tgpuComputeFn-DOUjhQua.d.ts} +402 -127
  35. package/chunk-7ACLI4JY.cjs +0 -2
  36. package/chunk-7ACLI4JY.cjs.map +0 -1
  37. package/chunk-L7HIBZAX.js +0 -4
  38. package/chunk-L7HIBZAX.js.map +0 -1
  39. package/chunk-SFECI7OX.js +0 -2
  40. package/chunk-SFECI7OX.js.map +0 -1
  41. package/chunk-SLWTVY6K.js +0 -2
  42. package/chunk-SLWTVY6K.js.map +0 -1
  43. package/chunk-TF6YPHJS.cjs +0 -2
  44. package/chunk-TF6YPHJS.cjs.map +0 -1
  45. package/chunk-V4CSEIB2.cjs +0 -4
  46. package/chunk-V4CSEIB2.cjs.map +0 -1
  47. /package/{LICENSE.md → LICENSE} +0 -0
package/index.cjs CHANGED
@@ -1,30 +1,31 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18; var _class19; var _class20; var _class21; var _class22; var _class23; var _class24; var _class25; var _class26; var _class27; var _class28;var _chunk7ACLI4JYcjs = require('./chunk-7ACLI4JY.cjs');var _chunkTF6YPHJScjs = require('./chunk-TF6YPHJS.cjs');var _chunkV4CSEIB2cjs = require('./chunk-V4CSEIB2.cjs');function sn(e){if(typeof _optionalChain([e, 'optionalAccess', _2 => _2[_chunkV4CSEIB2cjs.c]])=="function")return e[_chunkV4CSEIB2cjs.c].bind(e)}function dt(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}var pa={f:{1:_chunkV4CSEIB2cjs.ka,2:_chunkV4CSEIB2cjs.ma,3:_chunkV4CSEIB2cjs.ra,4:_chunkV4CSEIB2cjs.wa},h:{1:_chunkV4CSEIB2cjs.la,2:_chunkV4CSEIB2cjs.na,3:_chunkV4CSEIB2cjs.sa,4:_chunkV4CSEIB2cjs.xa},i:{1:_chunkV4CSEIB2cjs.ja,2:_chunkV4CSEIB2cjs.oa,3:_chunkV4CSEIB2cjs.ta,4:_chunkV4CSEIB2cjs.ya},u:{1:_chunkV4CSEIB2cjs.ia,2:_chunkV4CSEIB2cjs.pa,3:_chunkV4CSEIB2cjs.ua,4:_chunkV4CSEIB2cjs.za},b:{1:_chunkV4CSEIB2cjs.ha,2:_chunkV4CSEIB2cjs.qa,3:_chunkV4CSEIB2cjs.va,4:_chunkV4CSEIB2cjs.Aa}},la={vec2f:_chunkV4CSEIB2cjs.ma,vec2h:_chunkV4CSEIB2cjs.na,vec2i:_chunkV4CSEIB2cjs.oa,vec2u:_chunkV4CSEIB2cjs.pa,"vec2<bool>":_chunkV4CSEIB2cjs.qa,vec3f:_chunkV4CSEIB2cjs.ra,vec3h:_chunkV4CSEIB2cjs.sa,vec3i:_chunkV4CSEIB2cjs.ta,vec3u:_chunkV4CSEIB2cjs.ua,"vec3<bool>":_chunkV4CSEIB2cjs.va,vec4f:_chunkV4CSEIB2cjs.wa,vec4h:_chunkV4CSEIB2cjs.xa,vec4i:_chunkV4CSEIB2cjs.ya,vec4u:_chunkV4CSEIB2cjs.za,"vec4<bool>":_chunkV4CSEIB2cjs.Aa,mat2x2f:_chunkV4CSEIB2cjs.Ca,mat3x3f:_chunkV4CSEIB2cjs.Da,mat4x4f:_chunkV4CSEIB2cjs.Ea},un={vec2f:_chunkV4CSEIB2cjs.ka,vec2h:_chunkV4CSEIB2cjs.la,vec2i:_chunkV4CSEIB2cjs.ja,vec2u:_chunkV4CSEIB2cjs.ia,"vec2<bool>":_chunkV4CSEIB2cjs.ha,vec3f:_chunkV4CSEIB2cjs.ka,vec3h:_chunkV4CSEIB2cjs.la,vec3i:_chunkV4CSEIB2cjs.ja,vec3u:_chunkV4CSEIB2cjs.ia,"vec3<bool>":_chunkV4CSEIB2cjs.ha,vec4f:_chunkV4CSEIB2cjs.ka,vec4h:_chunkV4CSEIB2cjs.la,vec4i:_chunkV4CSEIB2cjs.ja,vec4u:_chunkV4CSEIB2cjs.ia,"vec4<bool>":_chunkV4CSEIB2cjs.ha,mat2x2f:_chunkV4CSEIB2cjs.ma,mat3x3f:_chunkV4CSEIB2cjs.ra,mat4x4f:_chunkV4CSEIB2cjs.wa};function je(e,t){if(_chunkV4CSEIB2cjs.K.call(void 0, e)||_chunkV4CSEIB2cjs.W.call(void 0, e))return _nullishCoalesce(e.propTypes[t], () => (_chunkV4CSEIB2cjs.aa));if(e===_chunkV4CSEIB2cjs.ha||_chunkTF6YPHJScjs.c.call(void 0, e))return _chunkV4CSEIB2cjs.aa;let r=t.length;if(_chunkV4CSEIB2cjs.C.call(void 0, e)&&r>=1&&r<=4){let n=e.type.includes("bool")?"b":e.type[4],a=pa[n][r];if(a)return a}return _chunkV4CSEIB2cjs.aa}function Qt(e){return _chunkV4CSEIB2cjs.J.call(void 0, e)||_chunkV4CSEIB2cjs.V.call(void 0, e)?e.elementType:e.type in un?un[e.type]:_chunkV4CSEIB2cjs.aa}function Xt(e){if(/^0x[0-9a-f]+$/i.test(e))return _chunkV4CSEIB2cjs.ba.call(void 0, e,_chunkV4CSEIB2cjs.fa);if(/^0b[01]+$/i.test(e))return _chunkV4CSEIB2cjs.ba.call(void 0, `${Number.parseInt(e.slice(2),2)}`,_chunkV4CSEIB2cjs.fa);if(/^-?(?:\d+\.\d*|\d*\.\d+)$/i.test(e))return _chunkV4CSEIB2cjs.ba.call(void 0, e,_chunkV4CSEIB2cjs.ga);if(/^-?\d+(?:\.\d+)?e-?\d+$/i.test(e))return _chunkV4CSEIB2cjs.ba.call(void 0, e,_chunkV4CSEIB2cjs.ga);if(/^-?\d+$/i.test(e))return _chunkV4CSEIB2cjs.ba.call(void 0, e,_chunkV4CSEIB2cjs.fa)}var Zt={rank:Number.POSITIVE_INFINITY,action:"none"};function Ae(e){return e.type==="decorated"?e.inner:e}function pn(e){return _chunkV4CSEIB2cjs.C.call(void 0, e)?_chunkV4CSEIB2cjs.Ba[e.type]:void 0}function ft(e,t){let r=Ae(e),n=Ae(t);if(r.type===n.type)return{rank:0,action:"none"};if(r.type==="abstractFloat"){if(n.type==="f32")return{rank:1,action:"none"};if(n.type==="f16")return{rank:2,action:"none"}}if(r.type==="abstractInt"){if(n.type==="i32")return{rank:3,action:"none"};if(n.type==="u32")return{rank:4,action:"none"};if(n.type==="abstractFloat")return{rank:5,action:"none"};if(n.type==="f32")return{rank:6,action:"none"};if(n.type==="f16")return{rank:7,action:"none"}}if(_chunkV4CSEIB2cjs.C.call(void 0, r)&&_chunkV4CSEIB2cjs.C.call(void 0, n)){let a=pn(r),o=pn(n);if(a&&o)return ft(a,o)}return _chunkV4CSEIB2cjs.G.call(void 0, r)&&_chunkV4CSEIB2cjs.G.call(void 0, n)?{rank:0,action:"none"}:Zt}function ma(e,t){let r=Ae(e),n=Ae(t);if(r.type==="ptr"&&ft(r.inner,n).rank<Number.POSITIVE_INFINITY)return{rank:0,action:"deref"};if(n.type==="ptr"&&ft(r,n.inner).rank<Number.POSITIVE_INFINITY)return{rank:1,action:"ref"};let a={f32:0,f16:1,i32:2,u32:3,bool:4};if(r.type in a&&n.type in a){let o=r.type,i=n.type;if(o!==i){let s=a[o];return{rank:a[i]<s?10:20,action:"cast",targetType:n}}}return Zt}function da(e,t,r){let n=ft(e,t);return n.rank<Number.POSITIVE_INFINITY?n:r?ma(e,t):Zt}function ln(e,t,r){let n,a=Number.POSITIVE_INFINITY,o=new Map;for(let u of t){let d=0,g=[],c=!0;for(let y of e){let x=da(y,u,r);if(x.rank===Number.POSITIVE_INFINITY){c=!1;break}d+=x.rank,g.push(x)}c&&d<a&&(a=d,n=u,o.set(n,g))}if(!n)return;let s=o.get(n).map((u,d)=>({sourceIndex:d,action:u.action,...u.action==="cast"&&{targetType:u.targetType}})),l=s.some(u=>u.action==="cast");return{targetType:n,actions:s,hasImplicitConversions:l}}function er(e){return e.type==="abstractFloat"?_chunkV4CSEIB2cjs.ka:e.type==="abstractInt"?_chunkV4CSEIB2cjs.ja:e}function mn(e,t){if(e.length===0)return;let r=[...new Set(e.map(Ae))],n=t?[...new Set(t.map(Ae))]:r,a=ln(e,n,!1);if(a)return a;let o=ln(e,n,!0);if(o)return o.hasImplicitConversions=o.actions.some(i=>i.action==="cast"),o}function fa(e,t,r,n){if(r.action==="none")return _chunkV4CSEIB2cjs.ba.call(void 0, t.value,n);let a=e.resolve(t.value);switch(r.action){case"ref":return _chunkV4CSEIB2cjs.ba.call(void 0, `&${a}`,n);case"deref":return _chunkV4CSEIB2cjs.ba.call(void 0, `*${a}`,n);case"cast":return _chunkV4CSEIB2cjs.ba.call(void 0, `${e.resolve(n)}(${a})`,n);default:dt(r.action,"applyActionToSnippet")}}function W(e,t,r){let n=t.map(o=>o.dataType);if(n.some(o=>o===_chunkV4CSEIB2cjs.aa))return;let a=mn(n,r);if(a)return a.hasImplicitConversions&&console.warn(`Implicit conversions from [
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18; var _class19; var _class20; var _class21; var _class22; var _class23; var _class24; var _class25; var _class26; var _class27; var _class28; var _class29; var _class30;var _chunkRC26P3MPcjs = require('./chunk-RC26P3MP.cjs');var _chunkTG4A6AM3cjs = require('./chunk-TG4A6AM3.cjs');var _chunkUMHCZDPAcjs = require('./chunk-UMHCZDPA.cjs');function Un(e){if(typeof _optionalChain([e, 'optionalAccess', _2 => _2[_chunkUMHCZDPAcjs.c]])=="function")return e[_chunkUMHCZDPAcjs.c].bind(e)}function ht(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}var Fa={f:{1:_chunkUMHCZDPAcjs.pa,2:_chunkUMHCZDPAcjs.ra,3:_chunkUMHCZDPAcjs.wa,4:_chunkUMHCZDPAcjs.Ba},h:{1:_chunkUMHCZDPAcjs.qa,2:_chunkUMHCZDPAcjs.sa,3:_chunkUMHCZDPAcjs.xa,4:_chunkUMHCZDPAcjs.Ca},i:{1:_chunkUMHCZDPAcjs.oa,2:_chunkUMHCZDPAcjs.ta,3:_chunkUMHCZDPAcjs.ya,4:_chunkUMHCZDPAcjs.Da},u:{1:_chunkUMHCZDPAcjs.ma,2:_chunkUMHCZDPAcjs.ua,3:_chunkUMHCZDPAcjs.za,4:_chunkUMHCZDPAcjs.Ea},b:{1:_chunkUMHCZDPAcjs.la,2:_chunkUMHCZDPAcjs.va,3:_chunkUMHCZDPAcjs.Aa,4:_chunkUMHCZDPAcjs.Fa}},Pa={vec2f:_chunkUMHCZDPAcjs.ra,vec2h:_chunkUMHCZDPAcjs.sa,vec2i:_chunkUMHCZDPAcjs.ta,vec2u:_chunkUMHCZDPAcjs.ua,"vec2<bool>":_chunkUMHCZDPAcjs.va,vec3f:_chunkUMHCZDPAcjs.wa,vec3h:_chunkUMHCZDPAcjs.xa,vec3i:_chunkUMHCZDPAcjs.ya,vec3u:_chunkUMHCZDPAcjs.za,"vec3<bool>":_chunkUMHCZDPAcjs.Aa,vec4f:_chunkUMHCZDPAcjs.Ba,vec4h:_chunkUMHCZDPAcjs.Ca,vec4i:_chunkUMHCZDPAcjs.Da,vec4u:_chunkUMHCZDPAcjs.Ea,"vec4<bool>":_chunkUMHCZDPAcjs.Fa,mat2x2f:_chunkUMHCZDPAcjs.Pa,mat3x3f:_chunkUMHCZDPAcjs.Qa,mat4x4f:_chunkUMHCZDPAcjs.Ra},Fn={vec2f:_chunkUMHCZDPAcjs.pa,vec2h:_chunkUMHCZDPAcjs.qa,vec2i:_chunkUMHCZDPAcjs.oa,vec2u:_chunkUMHCZDPAcjs.ma,"vec2<bool>":_chunkUMHCZDPAcjs.la,vec3f:_chunkUMHCZDPAcjs.pa,vec3h:_chunkUMHCZDPAcjs.qa,vec3i:_chunkUMHCZDPAcjs.oa,vec3u:_chunkUMHCZDPAcjs.ma,"vec3<bool>":_chunkUMHCZDPAcjs.la,vec4f:_chunkUMHCZDPAcjs.pa,vec4h:_chunkUMHCZDPAcjs.qa,vec4i:_chunkUMHCZDPAcjs.oa,vec4u:_chunkUMHCZDPAcjs.ma,"vec4<bool>":_chunkUMHCZDPAcjs.la,mat2x2f:_chunkUMHCZDPAcjs.ra,mat3x3f:_chunkUMHCZDPAcjs.wa,mat4x4f:_chunkUMHCZDPAcjs.Ba};function Qe(e,t){if(_chunkUMHCZDPAcjs.O.call(void 0, e)||_chunkUMHCZDPAcjs._.call(void 0, e))return _nullishCoalesce(e.propTypes[t], () => (_chunkUMHCZDPAcjs.ea));if(e===_chunkUMHCZDPAcjs.la||_chunkTG4A6AM3cjs.c.call(void 0, e))return _chunkUMHCZDPAcjs.ea;let r=t.length;if(_chunkUMHCZDPAcjs.G.call(void 0, e)&&r>=1&&r<=4){let n=e.type.includes("bool")?"b":e.type[4],a=Fa[n][r];if(a)return a}return _chunkUMHCZDPAcjs.ea}function pr(e){return _chunkUMHCZDPAcjs.N.call(void 0, e)||_chunkUMHCZDPAcjs.Z.call(void 0, e)?e.elementType:e.type in Fn?Fn[e.type]:_chunkUMHCZDPAcjs.ea}function lr(e){if(/^0x[0-9a-f]+$/i.test(e))return _chunkUMHCZDPAcjs.fa.call(void 0, e,_chunkUMHCZDPAcjs.ja);if(/^0b[01]+$/i.test(e))return _chunkUMHCZDPAcjs.fa.call(void 0, `${Number.parseInt(e.slice(2),2)}`,_chunkUMHCZDPAcjs.ja);if(/^-?(?:\d+\.\d*|\d*\.\d+)$/i.test(e))return _chunkUMHCZDPAcjs.fa.call(void 0, e,_chunkUMHCZDPAcjs.ka);if(/^-?\d+(?:\.\d+)?e-?\d+$/i.test(e))return _chunkUMHCZDPAcjs.fa.call(void 0, e,_chunkUMHCZDPAcjs.ka);if(/^-?\d+$/i.test(e))return _chunkUMHCZDPAcjs.fa.call(void 0, e,_chunkUMHCZDPAcjs.ja)}var mr={rank:Number.POSITIVE_INFINITY,action:"none"};function $e(e){return e.type==="decorated"?e.inner:e}function Pn(e){return _chunkUMHCZDPAcjs.G.call(void 0, e)?_chunkUMHCZDPAcjs.Ga[e.type]:void 0}function bt(e,t){let r=$e(e),n=$e(t);if(r.type===n.type)return{rank:0,action:"none"};if(r.type==="abstractFloat"){if(n.type==="f32")return{rank:1,action:"none"};if(n.type==="f16")return{rank:2,action:"none"}}if(r.type==="abstractInt"){if(n.type==="i32")return{rank:3,action:"none"};if(n.type==="u32")return{rank:4,action:"none"};if(n.type==="abstractFloat")return{rank:5,action:"none"};if(n.type==="f32")return{rank:6,action:"none"};if(n.type==="f16")return{rank:7,action:"none"}}if(_chunkUMHCZDPAcjs.G.call(void 0, r)&&_chunkUMHCZDPAcjs.G.call(void 0, n)){let a=Pn(r),o=Pn(n);if(a&&o)return bt(a,o)}return _chunkUMHCZDPAcjs.K.call(void 0, r)&&_chunkUMHCZDPAcjs.K.call(void 0, n)?{rank:0,action:"none"}:mr}function Ba(e,t){let r=$e(e),n=$e(t);if(r.type==="ptr"&&bt(r.inner,n).rank<Number.POSITIVE_INFINITY)return{rank:0,action:"deref"};if(n.type==="ptr"&&bt(r,n.inner).rank<Number.POSITIVE_INFINITY)return{rank:1,action:"ref"};let a={f32:0,f16:1,i32:2,u32:3,bool:4};if(r.type in a&&n.type in a){let o=r.type,i=n.type;if(o!==i){let s=a[o];return{rank:a[i]<s?10:20,action:"cast",targetType:n}}}return mr}function Aa(e,t,r){let n=bt(e,t);return n.rank<Number.POSITIVE_INFINITY?n:r?Ba(e,t):mr}function Bn(e,t,r){let n,a=Number.POSITIVE_INFINITY,o=new Map;for(let u of t){let f=0,m=[],g=!0;for(let y of e){let x=Aa(y,u,r);if(x.rank===Number.POSITIVE_INFINITY){g=!1;break}f+=x.rank,m.push(x)}g&&f<a&&(a=f,n=u,o.set(n,m))}if(!n)return;let s=o.get(n).map((u,f)=>({sourceIndex:f,action:u.action,...u.action==="cast"&&{targetType:u.targetType}})),p=s.some(u=>u.action==="cast");return{targetType:n,actions:s,hasImplicitConversions:p}}function dr(e){return e.type==="abstractFloat"?_chunkUMHCZDPAcjs.pa:e.type==="abstractInt"?_chunkUMHCZDPAcjs.oa:e}function An(e,t){if(e.length===0)return;let r=[...new Set(e.map($e))],n=t?[...new Set(t.map($e))]:r,a=Bn(e,n,!1);if(a)return a;let o=Bn(e,n,!0);if(o)return o.hasImplicitConversions=o.actions.some(i=>i.action==="cast"),o}function Ca(e,t,r,n){if(r.action==="none")return _chunkUMHCZDPAcjs.fa.call(void 0, t.value,n);let a=e.resolve(t.value);switch(r.action){case"ref":return _chunkUMHCZDPAcjs.fa.call(void 0, `&${a}`,n);case"deref":return _chunkUMHCZDPAcjs.fa.call(void 0, `*${a}`,n);case"cast":return _chunkUMHCZDPAcjs.fa.call(void 0, `${e.resolve(n)}(${a})`,n);default:ht(r.action,"applyActionToSnippet")}}function z(e,t,r){let n=t.map(o=>o.dataType);if(n.some(o=>o===_chunkUMHCZDPAcjs.ea))return;let a=An(n,r);if(a)return a.hasImplicitConversions&&console.warn(`Implicit conversions from [
2
2
  ${t.map(o=>` ${o.value}: ${o.dataType.type}`).join(`,
3
3
  `)}
4
4
  ] to ${a.targetType.type} are supported, but not recommended.
5
- Consider using explicit conversions instead.`),t.map((o,i)=>{let s=a.actions[i];return _chunkV4CSEIB2cjs.h.call(void 0, s,"Action should not be undefined"),fa(e,o,s,a.targetType)})}function tr(e,t,r){return Object.keys(t.propTypes).map(a=>{let o=r[a];if(!o)throw new Error(`Missing property ${a}`);let i=t.propTypes[a];return _nullishCoalesce(_optionalChain([W, 'call', _3 => _3(e,[o],[i]), 'optionalAccess', _4 => _4[0]]), () => (o))})}function fe(e){if(_chunkV4CSEIB2cjs.ca.call(void 0, e))return e;if(_chunkV4CSEIB2cjs.x.call(void 0, e))return _chunkV4CSEIB2cjs.ba.call(void 0, e,e[_chunkV4CSEIB2cjs.b]);if(_chunkV4CSEIB2cjs.z.call(void 0, e)||_chunkV4CSEIB2cjs.D.call(void 0, e))return _chunkV4CSEIB2cjs.ba.call(void 0, e,la[e.kind]);if(Array.isArray(e)){let t=e.map(fe).filter(Boolean),r=_chunkV4CSEIB2cjs.q.call(void 0, );if(!r)throw new Error("Tried to coerce array without a context");let n=W(r,t),a=_optionalChain([mn, 'call', _5 => _5(t.map(o=>o.dataType)), 'optionalAccess', _6 => _6.targetType]);return!n||!a?_chunkV4CSEIB2cjs.ba.call(void 0, e,_chunkV4CSEIB2cjs.aa):_chunkV4CSEIB2cjs.ba.call(void 0, n.map(o=>o.value).join(", "),_chunk7ACLI4JYcjs.X.call(void 0, er(a),e.length))}return typeof e=="string"||typeof e=="function"||typeof e=="object"||typeof e=="symbol"||typeof e>"u"||e===null?_chunkV4CSEIB2cjs.ba.call(void 0, e,_chunkV4CSEIB2cjs.aa):typeof e=="number"||typeof e=="bigint"?_chunkV4CSEIB2cjs.ba.call(void 0, e,_nullishCoalesce(_optionalChain([Xt, 'call', _7 => _7(String(e)), 'optionalAccess', _8 => _8.dataType]), () => (_chunkV4CSEIB2cjs.aa))):typeof e=="boolean"?_chunkV4CSEIB2cjs.ba.call(void 0, e,_chunkV4CSEIB2cjs.ha):_chunkV4CSEIB2cjs.ba.call(void 0, e,_chunkV4CSEIB2cjs.aa)}var q={get(e,t){if(t in e)return Reflect.get(e,t);if(t!=="~providing")return t==="toString"||t===Symbol.toStringTag||t===Symbol.toPrimitive?()=>e.toString():new Proxy({"~resolve":r=>`${r.resolve(e)}.${String(t)}`,toString:()=>`.value(...).${String(t)}:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, e), () => ("<unnamed>"))}`,[_chunkV4CSEIB2cjs.b]:je(e[_chunkV4CSEIB2cjs.b],String(t))},q)}};function ze(e,t){let r=t,n;for(;n=sn(r);)r=n(e);return r}function dn(e,t){return new rr(e,t)}var rr=class{constructor(t,r){this.dataType=t;this._value=r;this[_chunkV4CSEIB2cjs.a]={dataType:t}}$name(t){return _chunkV4CSEIB2cjs.f.call(void 0, this,t),this}"~resolve"(t){let r=t.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this)),n=t.resolveValue(this._value,this.dataType);return t.addDeclaration(`const ${r} = ${n};`),r}toString(){return`const:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}[_chunkV4CSEIB2cjs.c](){return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`,[_chunkV4CSEIB2cjs.b]:this.dataType},q)}get value(){return _chunkV4CSEIB2cjs.t.call(void 0, )?this[_chunkV4CSEIB2cjs.c]():this._value}};function Be(e){return _optionalChain([e, 'optionalAccess', _9 => _9.resourceType])==="slot"}function Re(e){return _optionalChain([e, 'optionalAccess', _10 => _10.resourceType])==="derived"}function Ke(e){return _optionalChain([e, 'optionalAccess', _11 => _11["~providing"]])!==void 0}function He(e){return _optionalChain([e, 'optionalAccess', _12 => _12.resourceType])==="accessor"}function nr(e){return typeof _optionalChain([e, 'optionalAccess', _13 => _13["~resolve"]])=="function"}function gt(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||nr(e)||_chunkV4CSEIB2cjs.I.call(void 0, e)||Be(e)||Re(e)||Ke(e)}function fn(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}function gn(e){return _optionalChain([e, 'optionalAccess', _14 => _14.resourceType])==="buffer-usage"}function ar(e){return!!_optionalChain([e, 'optionalAccess', _15 => _15[_chunkV4CSEIB2cjs.a]])}function ge(e,t){for(let[r,n]of Object.entries(t))e[r]=n,_chunkV4CSEIB2cjs.g.call(void 0, n)&&_chunkV4CSEIB2cjs.e.call(void 0, n)===void 0&&n.$name(r)}function cn(e,t,r){let n=[...e.matchAll(/:\s*(?<arg>.*?)\s*[,)]/g)].map(a=>a?a[1]:void 0);r(Object.fromEntries(t.flatMap((a,o)=>{let i=n?n[o]:void 0;return _chunkV4CSEIB2cjs.K.call(void 0, a)&&i!==void 0?[[i,a]]:[]})))}function Pe(e,t,r){let n=e.match(/->\s(?<output>[\w\d_]+)\s{/),a=n?_optionalChain([n, 'access', _16 => _16[1], 'optionalAccess', _17 => _17.trim, 'call', _18 => _18()]):void 0;_chunkV4CSEIB2cjs.K.call(void 0, t)&&a&&!/\s/g.test(a)&&r({[a]:t})}function ga(e){return new RegExp(`(?<![\\w\\$_.])${e.replaceAll(".","\\.").replaceAll("$","\\$")}(?![\\w\\$_])`,"g")}function ce(e,t,r){return Object.entries(t).reduce((n,[a,o])=>gt(o)||_chunkV4CSEIB2cjs.U.call(void 0, o)?n.replaceAll(ga(a),e.resolve(o)):o!==null&&typeof o=="object"?(_nullishCoalesce([...r.matchAll(new RegExp(`${a.replaceAll(".","\\.").replaceAll("$","\\$")}\\.(?<prop>.*?)(?![\\w\\$_])`,"g"))].map(s=>s[1]), () => ([]))).reduce((s,l)=>l&&l in o?ce(e,{[`${a}.${l}`]:o[l]},s):s,n):n,r)}function yn(e){return new or(e)}var or= (_class =class{constructor(t){;_class.prototype.__init.call(this);this.declaration=t}__init() {this.externalsToApply=[]}$uses(t){return this.externalsToApply.push(t),this}"~resolve"(t){let r={};for(let a of this.externalsToApply)ge(r,a);let n=ce(t,r,this.declaration);return t.addDeclaration(n),""}toString(){return`declare: ${this.declaration}`}}, _class);var Tn=new WeakMap;function xn(e){return Tn.get(e)}function hn(e,t,r){return Tn.set(e,{ast:t,externals:r}),e}function wn(e){return()=>{throw new Error(`The function "${_nullishCoalesce(e, () => ("<unnamed>"))}" is invokable only on the GPU. If you want to use it on the CPU, mark it with the "kernel & js" directive.`)}}var _tinyest = require('tinyest'); var Ea = _interopRequireWildcard(_tinyest);function re(e,t){let r=[];typeof t=="string"&&(e.isEntry?(_chunkV4CSEIB2cjs.K.call(void 0, e.argTypes[0])&&r.push({In:e.argTypes[0]}),_chunkV4CSEIB2cjs.K.call(void 0, e.returnType)&&r.push({Out:e.returnType})):(cn(t,e.argTypes,o=>r.push(o)),Pe(t,e.returnType,o=>r.push(o))));let n={applyExternals(o){r.push(o)},resolve(o,i=""){let s={};for(let u of r)ge(s,u);let l=o.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this));if(typeof t=="string"){let u="";if(e.isEntry){let g=_chunkV4CSEIB2cjs.K.call(void 0, e.argTypes[0])?"(in: In)":"()",c=_chunkV4CSEIB2cjs.I.call(void 0, e.returnType)?_chunk7ACLI4JYcjs.ba.call(void 0, e.returnType):"",y=e.returnType!==_chunkV4CSEIB2cjs.y?_chunkV4CSEIB2cjs.K.call(void 0, e.returnType)?"-> Out":`-> ${c!==""?c:"@location(0)"} ${o.resolve(e.returnType)}`:"";u=`${g} ${y} `}let d=ce(o,s,`${u}${t.trim()}`);o.addDeclaration(`${i}fn ${l}${d}`)}else{let u=xn(t);if(_optionalChain([u, 'optionalAccess', _19 => _19.externals])){let x=Object.fromEntries(Object.entries(u.externals).filter(([w])=>!(w in s)));ge(s,x)}let d=_nullishCoalesce(_optionalChain([u, 'optionalAccess', _20 => _20.ast]), () => (o.transpileFn(String(t)))),g=d.externalNames.filter(x=>!(x in s));if(g.length>0)throw new (0, _chunkV4CSEIB2cjs.l)(_chunkV4CSEIB2cjs.e.call(void 0, this),g);let{head:c,body:y}=o.fnToWgsl({args:e.argTypes.map((x,w)=>_chunkV4CSEIB2cjs.ba.call(void 0, _optionalChain([d, 'access', _21 => _21.params, 'access', _22 => _22[w], 'optionalAccess', _23 => _23.type])===_tinyest.FuncParameterType.identifier?d.params[w].name:`_arg_${w}`,x)),argAliases:Object.fromEntries(d.params.flatMap((x,w)=>x.type===_tinyest.FuncParameterType.destructuredObject?x.props.map(({name:b,alias:U})=>[U,_chunkV4CSEIB2cjs.ba.call(void 0, `_arg_${w}.${b}`,e.argTypes[w].propTypes[b])]):[])),returnType:e.returnType,body:d.body,externalMap:s});o.addDeclaration(`${i}fn ${l}${o.resolve(c)}${o.resolve(y)}`)}return l}},a=_chunkV4CSEIB2cjs.e.call(void 0, t);return a!==void 0&&_chunkV4CSEIB2cjs.f.call(void 0, n,a),n}function ca(e){let t=0;return Object.fromEntries(Object.entries(e).map(([r,n])=>{if(_chunk7ACLI4JYcjs.aa.call(void 0, n))return[r,n];let a=_chunkV4CSEIB2cjs._.call(void 0, n);return a!==void 0?(t=a+1,[r,n]):[r,_chunk7ACLI4JYcjs._.call(void 0, t++,n)]}))}function ne(e){return _chunkV4CSEIB2cjs.$.call(void 0, e)?_chunkV4CSEIB2cjs.T.call(void 0, e)||_chunkV4CSEIB2cjs._.call(void 0, e)!==void 0?e:_chunk7ACLI4JYcjs._.call(void 0, 0,e):_chunk7ACLI4JYcjs.ca.call(void 0, ca(e))}function ae(e,...t){return ya(e)?Ta(e,...t):e}function ya(e){return Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw)&&e.raw.every(t=>typeof t=="string")}function Ta(e,...t){return e.slice(1).reduce((r,n,a)=>`${r}${t[a]}${n}`,e[0])}function Sn(e){let t={argTypes:e.in&&Object.keys(e.in).length!==0?[ne(e.in)]:[],returnType:_chunkV4CSEIB2cjs.y,workgroupSize:[_nullishCoalesce(e.workgroupSize[0], () => (1)),_nullishCoalesce(e.workgroupSize[1], () => (1)),_nullishCoalesce(e.workgroupSize[2], () => (1))],isEntry:!0},r=(n,...a)=>xa(t,e.workgroupSize,ae(n,...a));return Object.assign(Object.assign(r,t),{does:r})}function xa(e,t,r){let n=re(e,r),a=e.argTypes[0];return{shell:e,$uses(o){return n.applyExternals(o),this},[_chunkV4CSEIB2cjs.d]:n,$name(o){return _chunkV4CSEIB2cjs.f.call(void 0, n,o),_chunkV4CSEIB2cjs.g.call(void 0, a)&&a.$name(`${o}_Input`),this},"~resolve"(o){return n.resolve(o,`@compute @workgroup_size(${t.join(", ")}) `)},toString(){return`computeFn:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, n), () => ("<unnamed>"))}`}}}function vn(e,t){let r={[_chunkV4CSEIB2cjs.a]:!0,argTypes:e,returnType:_nullishCoalesce(t, () => (_chunkV4CSEIB2cjs.y)),isEntry:!1},n=(a,...o)=>wa(r,ae(a,...o));return Object.assign(Object.assign(n,r),{does:n})}function ir(e){return!!_optionalChain([e, 'optionalAccess', _24 => _24[_chunkV4CSEIB2cjs.a]])&&_optionalChain([e, 'optionalAccess', _25 => _25.resourceType])==="function"}function ha([e,t]){return`${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, e), () => ("<unnamed>"))}=${t}`}function wa(e,t){let r=re(e,t),n={[_chunkV4CSEIB2cjs.a]:{implementation:t,argTypes:e.argTypes},shell:e,resourceType:"function",$uses(i){return r.applyExternals(i),this},[_chunkV4CSEIB2cjs.d]:r,$name(i){return _chunkV4CSEIB2cjs.f.call(void 0, r,i),this},with(i,s){return Dn(o,[[He(i)?i.slot:i,s]])},"~resolve"(i){if(typeof t=="string")return r.resolve(i);let s=i;if(s.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return s.callStack.push(e.returnType),r.resolve(i)}finally{s.callStack.pop()}}},a=_chunkV4CSEIB2cjs.ea.call(void 0, (...i)=>{if(typeof t=="string")throw new Error("Cannot execute on the CPU functions constructed with raw WGSL");return t(...i)},(...i)=>_chunkV4CSEIB2cjs.ba.call(void 0, new ct(o,i.map(s=>s.value)),_nullishCoalesce(e.returnType, () => (_chunkV4CSEIB2cjs.aa))),e.argTypes);a[_chunkV4CSEIB2cjs.a].implementation=t;let o=Object.assign(a,n);return Object.defineProperty(o,"toString",{value(){return`fn:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, r), () => ("<unnamed>"))}`}}),o}function Dn(e,t){let r={[_chunkV4CSEIB2cjs.a]:{implementation:e[_chunkV4CSEIB2cjs.a].implementation,argTypes:e[_chunkV4CSEIB2cjs.a].argTypes},resourceType:"function",shell:e.shell,"~providing":{inner:e,pairs:t},$uses(o){return e.$uses(o),this},[_chunkV4CSEIB2cjs.d]:e,$name(o){return e.$name(o),this},with(o,i){return Dn(a,[...t,[He(o)?o.slot:o,i]])}},n=_chunkV4CSEIB2cjs.ea.call(void 0, (...o)=>e(...o),(...o)=>_chunkV4CSEIB2cjs.ba.call(void 0, new ct(a,o.map(i=>i.value)),_nullishCoalesce(e.shell.returnType, () => (_chunkV4CSEIB2cjs.aa))),e.shell.argTypes),a=Object.assign(n,r);return Object.defineProperty(a,"toString",{value(){return`fn:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, e), () => ("<unnamed>"))}[${t.map(ha).join(", ")}]`}}),a[_chunkV4CSEIB2cjs.a].implementation=e[_chunkV4CSEIB2cjs.a].implementation,a}var ct=class{constructor(t,r){this._fn=t;this._params=r;this[_chunkV4CSEIB2cjs.d]=t}"~resolve"(t){return t.resolve(`${t.resolve(this._fn)}(${this._params.map(r=>t.resolve(r)).join(", ")})`)}toString(){return`call:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}};function Fn(e){let t={argTypes:e.in&&Object.keys(e.in).length!==0?[ne(e.in)]:[],targets:e.out,returnType:ne(e.out),isEntry:!0},r=(n,...a)=>ba(t,ae(n,...a));return Object.assign(Object.assign(r,t),{does:r})}function ba(e,t){let r=re(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&Pe(t,n,i=>r.applyExternals(i)),{shell:e,outputType:n,$uses(i){return r.applyExternals(i),this},[_chunkV4CSEIB2cjs.d]:r,$name(i){return _chunkV4CSEIB2cjs.f.call(void 0, r,i),_chunkV4CSEIB2cjs.g.call(void 0, n)&&n.$name(`${i}_Output`),_chunkV4CSEIB2cjs.g.call(void 0, a)&&a.$name(`${i}_Input`),this},"~resolve"(i){if(typeof t=="string")return r.resolve(i,"@fragment ");let s=i;if(s.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return s.callStack.push(n),r.resolve(i,"@fragment ")}finally{s.callStack.pop()}},toString(){return`fragmentFn:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, r), () => ("<unnamed>"))}`}}}function In(e){let t={attributes:[_nullishCoalesce(e.in, () => ({}))],returnType:Object.keys(e.out).length!==0?ne(e.out):void 0,argTypes:e.in&&Object.keys(e.in).length!==0?[ne(e.in)]:[],isEntry:!0},r=(n,...a)=>Sa(t,ae(n,...a));return Object.assign(Object.assign(r,t),{does:r})}function Sa(e,t){let r=re(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&Pe(t,n,o=>r.applyExternals(o)),{shell:e,outputType:n,inputType:a,$uses(o){return r.applyExternals(o),this},[_chunkV4CSEIB2cjs.d]:r,$name(o){return _chunkV4CSEIB2cjs.f.call(void 0, r,o),_chunkV4CSEIB2cjs.g.call(void 0, n)&&n.$name(`${o}_Output`),_chunkV4CSEIB2cjs.g.call(void 0, a)&&a.$name(`${o}_Input`),this},"~resolve"(o){if(typeof t=="string")return r.resolve(o,"@vertex ");let i=o;if(i.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return i.callStack.push(n),r.resolve(o,"@vertex ")}finally{i.callStack.pop()}},toString(){return`vertexFn:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, r), () => ("<unnamed>"))}`}}}var oe= (_class2 =class{constructor() { _class2.prototype.__init2.call(this); }__init2() {this.lastUniqueId=0}makeUnique(t){let r;return t?(r=t.replaceAll(/\s/g,"_"),r=r.replaceAll(/[^\w\d]/g,"")):r="item",`${r}_${this.lastUniqueId++}`}}, _class2),ie= exports.StrictNameRegistry = (_class3 =class{constructor() { _class3.prototype.__init3.call(this); }__init3() {this._usedNames=new Set}makeUnique(t){if(t===void 0)throw new Error("Unnamed item found when using a strict name registry");let r=0,n=t;for(;this._usedNames.has(n);)r++,n=`${t}_${r}`;return this._usedNames.add(n),n}}, _class3);function qe(e){return typeof _optionalChain([e, 'optionalAccess', _26 => _26.format])=="string"}function Un(e,t){let r=[];if(_chunkV4CSEIB2cjs.$.call(void 0, e)){if(!qe(t))throw new Error("Shader expected a single attribute, not a record of attributes to be passed in.");return r.push(t._layout),{usedVertexLayouts:r,bufferDefinitions:[{arrayStride:t._layout.stride,stepMode:t._layout.stepMode,attributes:[{format:t.format,offset:t.offset,shaderLocation:_nullishCoalesce(_chunkV4CSEIB2cjs._.call(void 0, e), () => (0))}]}]}}let n=[],a=new WeakMap,o=0;for(let[i,s]of Object.entries(e)){if(_chunk7ACLI4JYcjs.aa.call(void 0, s))continue;let l=t[i];if(!l)throw new Error(`An attribute by the name of '${i}' was not provided to the shader.`);let u=l._layout,d=a.get(u);d||(r.push(u),d=[],n.push({arrayStride:u.stride,stepMode:u.stepMode,attributes:d}),a.set(u,d)),o=_nullishCoalesce(_chunkV4CSEIB2cjs._.call(void 0, s), () => (o)),d.push({format:l.format,offset:l.offset,shaderLocation:o++})}return{usedVertexLayouts:r,bufferDefinitions:n}}var va=["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"];function Da(e){return va.includes(e.type)}function sr(e,[t,r]){return` ${_chunk7ACLI4JYcjs.ba.call(void 0, r)}${t}: ${e.resolve(r)},
6
- `}function Fa(e,t){let r=e.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, t));return e.addDeclaration(`
5
+ Consider using explicit conversions instead.`),t.map((o,i)=>{let s=a.actions[i];return _chunkUMHCZDPAcjs.m.call(void 0, s,"Action should not be undefined"),Ca(e,o,s,a.targetType)})}function fr(e,t,r){return Object.keys(t.propTypes).map(a=>{let o=r[a];if(!o)throw new Error(`Missing property ${a}`);let i=t.propTypes[a];return _nullishCoalesce(_optionalChain([z, 'call', _3 => _3(e,[o],[i]), 'optionalAccess', _4 => _4[0]]), () => (o))})}function he(e){if(_chunkUMHCZDPAcjs.ga.call(void 0, e))return e;if(_chunkUMHCZDPAcjs.B.call(void 0, e))return _chunkUMHCZDPAcjs.fa.call(void 0, e,e[_chunkUMHCZDPAcjs.b]);if(_chunkUMHCZDPAcjs.D.call(void 0, e)||_chunkUMHCZDPAcjs.H.call(void 0, e))return _chunkUMHCZDPAcjs.fa.call(void 0, e,Pa[e.kind]);if(Array.isArray(e)){let t=e.map(he).filter(Boolean),r=_chunkUMHCZDPAcjs.v.call(void 0, );if(!r)throw new Error("Tried to coerce array without a context");let n=z(r,t),a=_optionalChain([An, 'call', _5 => _5(t.map(o=>o.dataType)), 'optionalAccess', _6 => _6.targetType]);return!n||!a?_chunkUMHCZDPAcjs.fa.call(void 0, e,_chunkUMHCZDPAcjs.ea):_chunkUMHCZDPAcjs.fa.call(void 0, n.map(o=>o.value).join(", "),_chunkRC26P3MPcjs.X.call(void 0, dr(a),e.length))}return typeof e=="string"||typeof e=="function"||typeof e=="object"||typeof e=="symbol"||typeof e>"u"||e===null?_chunkUMHCZDPAcjs.fa.call(void 0, e,_chunkUMHCZDPAcjs.ea):typeof e=="number"||typeof e=="bigint"?_chunkUMHCZDPAcjs.fa.call(void 0, e,_nullishCoalesce(_optionalChain([lr, 'call', _7 => _7(String(e)), 'optionalAccess', _8 => _8.dataType]), () => (_chunkUMHCZDPAcjs.ea))):typeof e=="boolean"?_chunkUMHCZDPAcjs.fa.call(void 0, e,_chunkUMHCZDPAcjs.la):_chunkUMHCZDPAcjs.fa.call(void 0, e,_chunkUMHCZDPAcjs.ea)}var H={get(e,t){if(t in e)return Reflect.get(e,t);if(t!==_chunkUMHCZDPAcjs.e)return t==="toString"||t===Symbol.toStringTag||t===Symbol.toPrimitive?()=>e.toString():new Proxy({"~resolve":r=>`${r.resolve(e)}.${String(t)}`,toString:()=>`.value(...).${String(t)}:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, e), () => ("<unnamed>"))}`,[_chunkUMHCZDPAcjs.b]:Qe(e[_chunkUMHCZDPAcjs.b],String(t))},H)}};function Ke(e,t){let r=t,n;for(;n=Un(r);)r=n(e);return r}function Cn(e,t){return new cr(e,t)}var cr=class{constructor(t,r){this.dataType=t;this._value=r;this[_chunkUMHCZDPAcjs.a]={dataType:t}}$name(t){return _chunkUMHCZDPAcjs.j.call(void 0, this,t),this}"~resolve"(t){let r=t.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this)),n=t.resolveValue(this._value,this.dataType),a=t.resolve(this.dataType);return t.addDeclaration(`const ${r}: ${a} = ${n};`),r}toString(){return`const:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}[_chunkUMHCZDPAcjs.c](){return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`,[_chunkUMHCZDPAcjs.b]:this.dataType},H)}get value(){return _chunkUMHCZDPAcjs.y.call(void 0, )?this[_chunkUMHCZDPAcjs.c]():this._value}get $(){return this.value}};function Ge(e){return _optionalChain([e, 'optionalAccess', _9 => _9.resourceType])==="slot"}function Ve(e){return _optionalChain([e, 'optionalAccess', _10 => _10.resourceType])==="derived"}function He(e){return _optionalChain([e, 'optionalAccess', _11 => _11[_chunkUMHCZDPAcjs.e]])!==void 0}function Ee(e){return _optionalChain([e, 'optionalAccess', _12 => _12.resourceType])==="accessor"}function gr(e){return typeof _optionalChain([e, 'optionalAccess', _13 => _13["~resolve"]])=="function"}function wt(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||gr(e)||_chunkUMHCZDPAcjs.M.call(void 0, e)||Ge(e)||Ve(e)||He(e)}function Ye(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}function Rn(e){return _optionalChain([e, 'optionalAccess', _14 => _14.resourceType])==="buffer-usage"}function yr(e){return!!_optionalChain([e, 'optionalAccess', _15 => _15[_chunkUMHCZDPAcjs.a]])}function be(e,t){for(let[r,n]of Object.entries(t))e[r]=n,_chunkUMHCZDPAcjs.k.call(void 0, n)&&_chunkUMHCZDPAcjs.i.call(void 0, n)===void 0&&n.$name(r)}function $n(e,t,r){let n=[...e.matchAll(/:\s*(?<arg>.*?)\s*[,)]/g)].map(a=>a?a[1]:void 0);r(Object.fromEntries(t.flatMap((a,o)=>{let i=n?n[o]:void 0;return _chunkUMHCZDPAcjs.O.call(void 0, a)&&i!==void 0?[[i,a]]:[]})))}function St(e,t,r){let n=e.match(/->\s(?<output>[\w\d_]+)\s{/),a=n?_optionalChain([n, 'access', _16 => _16[1], 'optionalAccess', _17 => _17.trim, 'call', _18 => _18()]):void 0;_chunkUMHCZDPAcjs.O.call(void 0, t)&&a&&!/\s/g.test(a)&&r({[a]:t})}function Ra(e){return new RegExp(`(?<![\\w\\$_.])${e.replaceAll(".","\\.").replaceAll("$","\\$")}(?![\\w\\$_])`,"g")}function we(e,t,r){return Object.entries(t).reduce((n,[a,o])=>wt(o)||_chunkUMHCZDPAcjs.Y.call(void 0, o)?n.replaceAll(Ra(a),e.resolve(o)):o!==null&&typeof o=="object"?(_nullishCoalesce([...r.matchAll(new RegExp(`${a.replaceAll(".","\\.").replaceAll("$","\\$")}\\.(?<prop>.*?)(?![\\w\\$_])`,"g"))].map(s=>s[1]), () => ([]))).reduce((s,p)=>p&&p in o?we(e,{[`${a}.${p}`]:o[p]},s):s,n):n,r)}function Gn(e){return new Tr(e)}var Tr= (_class =class{constructor(t){;_class.prototype.__init.call(this);this.declaration=t}__init() {this.externalsToApply=[]}$uses(t){return this.externalsToApply.push(t),this}"~resolve"(t){let r={};for(let a of this.externalsToApply)be(r,a);let n=we(t,r,this.declaration);return t.addDeclaration(n),""}toString(){return`declare: ${this.declaration}`}}, _class);var _tinyest = require('tinyest'); var uo = _interopRequireWildcard(_tinyest);function _n(e){let{strippedCode:t,argRange:r}=$a(e),n=new vt(t);n.consume("(");let a=[];for(;!n.isAt(")");){let i=[];for(;n.isAt("@");)n.parseUntil(Vn,En),n.consume(")"),i.push(n.lastParsed);n.parseUntil(Va);let s=n.lastParsed,p;n.isAt(":")&&(n.consume(":"),n.parseUntil(Ea,ka),p=n.lastParsed),a.push({identifier:s,attributes:i,type:p}),n.isAt(",")&&n.consume(",")}n.consume(")");let o;if(n.isAt("->")){n.consume("->");let i=[];for(;n.isAt("@");)n.parseUntil(Vn,En),n.consume(")"),i.push(n.lastParsed);o={type:n.str.slice(n.pos),attributes:i}}return{args:a,ret:o,range:{begin:r[0],end:r[1]}}}function $a(e){let t=new vt(e),r="",n;for(;!t.isFinished();){if(t.isAt(Ga)){t.advanceBy(1);continue}if(t.isAt("//")){t.consume("//"),t.parseUntil(kn),t.advanceBy(1);continue}if(t.isAt("/*")){t.parseUntil(_a,La),t.consume("*/");continue}if(t.isAt("{"))return{strippedCode:r,argRange:[n,t.pos]};t.isAt("(")&&n===void 0&&(n=t.pos),n!==void 0&&(r+=t.str[t.pos]),t.advanceBy(1)}throw new Error("Invalid wgsl code!")}var vt=class{constructor(t){this.str=t;this.#e=0}#t;#e;get pos(){return this.#e}get lastParsed(){if(this.#t===void 0)throw new Error("Parse was not called yet!");return this.str.slice(this.#t,this.pos)}isFinished(){return this.#e>=this.str.length}isAt(t){if(typeof t=="string"){for(let r=0;r<t.length;r++)if(this.str[this.#e+r]!==t[r])return!1;return!0}for(let r of t)if(this.isAt(r))return!0;return!1}parseUntil(t,r){this.#t=this.#e;let n=0;for(;this.#e<this.str.length;){if(r&&this.isAt(r[0])&&(n+=1),r&&this.isAt(r[1])&&(n-=1),n===0&&this.isAt(t))return this.#e;this.#e+=1}throw new Error("Reached the end of the string without finding a match!")}advanceBy(t){this.#e+=t}consume(t){if(!this.isAt(t))throw new Error(`Expected '${t}' at position ${this.#e}, but found '${this.str.slice(this.#e,this.#e+t.length)}'`);this.advanceBy(t.length)}},kn=new Set([`
6
+ `,"\v","\f","\r","\x85","\u2028","\u2029"]),Ga=new Set([...kn," "," ","\u200E","\u200F"]),Vn=new Set([")"]),Va=new Set([":",",",")"]),Ea=new Set([",",")"]),_a=new Set(["*/"]),En=["(",")"],ka=["<",">"],La=["/*","*/"];function ie(e,t=""){let r=[],n={applyExternals(o){r.push(o)},resolve(o,i,s){let p={};for(let f of r)be(p,f);let u=o.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this));if(typeof e=="string"){let f=we(o,p,e),m="",g="";if(t!==""){let y=_chunkUMHCZDPAcjs.O.call(void 0, i[0])?`(in: ${o.resolve(i[0])})`:"()",x=_chunkUMHCZDPAcjs.M.call(void 0, s)?_chunkRC26P3MPcjs.ba.call(void 0, s):"",b=s!==_chunkUMHCZDPAcjs.C?_chunkUMHCZDPAcjs.O.call(void 0, s)?`-> ${o.resolve(s)}`:`-> ${x!==""?x:"@location(0)"} ${o.resolve(s)}`:"";m=`${y} ${b} `,g=f}else{let y=_n(f);if(y.args.length!==i.length)throw new Error(`WGSL implementation has ${y.args.length} arguments, while the shell has ${i.length} arguments.`);let x=y.args.map((I,P)=>`${I.identifier}: ${On(o,`parameter ${I.identifier}`,I.type,i[P])}`).join(", "),b=s===_chunkUMHCZDPAcjs.C?"":`-> ${On(o,"return type",_optionalChain([y, 'access', _19 => _19.ret, 'optionalAccess', _20 => _20.type]),s)}`;m=`(${x}) ${b}`,g=f.slice(y.range.end)}o.addDeclaration(`${t}fn ${u}${m}${g}`)}else{let f=_chunkUMHCZDPAcjs.l.call(void 0, e);if(_optionalChain([f, 'optionalAccess', _21 => _21.externals])){let b=Object.fromEntries(Object.entries(f.externals).filter(([I])=>!(I in p)));be(p,b)}let m=_optionalChain([f, 'optionalAccess', _22 => _22.ast]);if(!m)throw new Error("Missing metadata for tgpu.fn function body (either missing 'kernel' directive, or misconfigured `unplugin-typegpu`)");let g=m.externalNames.filter(b=>!(b in p));if(g.length>0)throw new (0, _chunkUMHCZDPAcjs.q)(_chunkUMHCZDPAcjs.i.call(void 0, this),g);let{head:y,body:x}=o.fnToWgsl({args:i.map((b,I)=>_chunkUMHCZDPAcjs.fa.call(void 0, _optionalChain([m, 'access', _23 => _23.params, 'access', _24 => _24[I], 'optionalAccess', _25 => _25.type])===_tinyest.FuncParameterType.identifier?m.params[I].name:`_arg_${I}`,b)),argAliases:Object.fromEntries(m.params.flatMap((b,I)=>b.type===_tinyest.FuncParameterType.destructuredObject?b.props.map(({name:P,alias:Ua})=>[Ua,_chunkUMHCZDPAcjs.fa.call(void 0, `_arg_${I}.${P}`,i[I].propTypes[P])]):[])),returnType:s,body:m.body,externalMap:p});o.addDeclaration(`${t}fn ${u}${o.resolve(y)}${o.resolve(x)}`)}return u}},a=_chunkUMHCZDPAcjs.i.call(void 0, e);return a!==void 0&&_chunkUMHCZDPAcjs.j.call(void 0, n,a),n}function On(e,t,r,n){let a=e.resolve(n).replace(/\s/g,"");if(!r)return a;let o=r.replace(/\s/g,"");if(o!==a)throw new Error(`Type mismatch between TGPU shell and WGSL code string: ${t}, JS type "${a}", WGSL type "${o}".`);return r}function Oa(e,t={}){let r=0,n=new Set;return Object.fromEntries(Object.entries(_nullishCoalesce(e, () => ({}))).map(([a,o])=>{let i=_chunkUMHCZDPAcjs.ca.call(void 0, o);if(i!==void 0){if(n.has(i))throw new Error("Duplicate custom location attributes found");n.add(i)}return[a,o]}).map(([a,o])=>{if(_chunkRC26P3MPcjs.aa.call(void 0, o))return[a,o];if(_chunkUMHCZDPAcjs.ca.call(void 0, o)!==void 0)return[a,o];if(t[a])return[a,_chunkRC26P3MPcjs._.call(void 0, t[a],o)];for(;n.has(r);)r++;return[a,_chunkRC26P3MPcjs._.call(void 0, r++,o)]}))}function se(e,t={}){return _chunkUMHCZDPAcjs.da.call(void 0, e)?_chunkUMHCZDPAcjs.X.call(void 0, e)||_chunkUMHCZDPAcjs.ca.call(void 0, e)!==void 0?e:_chunkRC26P3MPcjs._.call(void 0, 0,e):_chunkRC26P3MPcjs.da.call(void 0, Oa(e,t))}function ue(e,...t){return Wa(e)?Ma(e,...t):e}function Wa(e){return Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw)&&e.raw.every(t=>typeof t=="string")}function Ma(e,...t){return e.slice(1).reduce((r,n,a)=>`${r}${t[a]}${n}`,e[0])}function Wn(e){let t={argTypes:e.in&&Object.keys(e.in).length!==0?[se(e.in)]:[],returnType:_chunkUMHCZDPAcjs.C,workgroupSize:[_nullishCoalesce(e.workgroupSize[0], () => (1)),_nullishCoalesce(e.workgroupSize[1], () => (1)),_nullishCoalesce(e.workgroupSize[2], () => (1))],isEntry:!0},r=(n,...a)=>Na(t,e.workgroupSize,ue(n,...a));return Object.assign(Object.assign(r,t),{does:r})}function Na(e,t,r){let n=ie(r,`@compute @workgroup_size(${t.join(", ")}) `),a=e.argTypes[0];return{shell:e,$uses(i){return n.applyExternals(i),this},[_chunkUMHCZDPAcjs.a]:!0,[_chunkUMHCZDPAcjs.d]:n,$name(i){return _chunkUMHCZDPAcjs.j.call(void 0, n,i),_chunkUMHCZDPAcjs.k.call(void 0, a)&&a.$name(`${i}_Input`),this},"~resolve"(i){return n.resolve(i,e.argTypes,e.returnType)},toString(){return`computeFn:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, n), () => ("<unnamed>"))}`}}}function xr(e,t){let r={[_chunkUMHCZDPAcjs.a]:!0,argTypes:e,returnType:_nullishCoalesce(t, () => (_chunkUMHCZDPAcjs.C)),isEntry:!1};return Object.assign((a,...o)=>ja(r,ue(a,...o)),r)}function hr(e){return!!_optionalChain([e, 'optionalAccess', _26 => _26[_chunkUMHCZDPAcjs.a]])&&_optionalChain([e, 'optionalAccess', _27 => _27.resourceType])==="function"}function za([e,t]){return`${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, e), () => ("<unnamed>"))}=${t}`}function ja(e,t){let r=ie(t,""),n={[_chunkUMHCZDPAcjs.a]:{implementation:t,argTypes:e.argTypes},shell:e,resourceType:"function",$uses(i){return r.applyExternals(i),this},[_chunkUMHCZDPAcjs.d]:r,$name(i){return _chunkUMHCZDPAcjs.j.call(void 0, r,i),this},with(i,s){return Mn(o,[[Ee(i)?i.slot:i,s]])},"~resolve"(i){if(typeof t=="string")return $n(t,e.argTypes,r.applyExternals),St(t,e.returnType,r.applyExternals),r.resolve(i,e.argTypes,e.returnType);let s=i;if(s.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return s.callStack.push(e.returnType),r.resolve(i,e.argTypes,e.returnType)}finally{s.callStack.pop()}}},a=_chunkUMHCZDPAcjs.ia.call(void 0, (...i)=>{if(typeof t=="string")throw new Error("Cannot execute on the CPU functions constructed with raw WGSL");let s=i.map((p,u)=>_chunkRC26P3MPcjs.ca.call(void 0, e.argTypes[u],p));return t(...s)},(...i)=>_chunkUMHCZDPAcjs.fa.call(void 0, new Dt(o,i.map(s=>s.value)),_nullishCoalesce(e.returnType, () => (_chunkUMHCZDPAcjs.ea))),"tgpuFnCall",e.argTypes);a[_chunkUMHCZDPAcjs.a].implementation=t;let o=Object.assign(a,n);return Object.defineProperty(o,"toString",{value(){return`fn:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, r), () => ("<unnamed>"))}`}}),o}function Mn(e,t){let r={[_chunkUMHCZDPAcjs.a]:{implementation:e[_chunkUMHCZDPAcjs.a].implementation,argTypes:e[_chunkUMHCZDPAcjs.a].argTypes},resourceType:"function",shell:e.shell,[_chunkUMHCZDPAcjs.e]:{inner:e,pairs:t},$uses(o){return e.$uses(o),this},[_chunkUMHCZDPAcjs.d]:e,$name(o){return e.$name(o),this},with(o,i){return Mn(a,[...t,[Ee(o)?o.slot:o,i]])}},n=_chunkUMHCZDPAcjs.ia.call(void 0, (...o)=>e(...o),(...o)=>_chunkUMHCZDPAcjs.fa.call(void 0, new Dt(a,o.map(i=>i.value)),_nullishCoalesce(e.shell.returnType, () => (_chunkUMHCZDPAcjs.ea))),"tgpuFnCall",e.shell.argTypes),a=Object.assign(n,r);return Object.defineProperty(a,"toString",{value(){return`fn:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, e), () => ("<unnamed>"))}[${t.map(za).join(", ")}]`}}),a[_chunkUMHCZDPAcjs.a].implementation=e[_chunkUMHCZDPAcjs.a].implementation,a}var Dt=class{constructor(t,r){this._fn=t;this._params=r;this[_chunkUMHCZDPAcjs.d]=t}"~resolve"(t){return t.resolve(`${t.resolve(this._fn)}(${this._params.map(r=>t.resolve(r)).join(", ")})`)}toString(){return`call:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}};function Nn(e){let t={in:e.in,out:e.out,returnType:se(e.out),isEntry:!0},r=(n,...a)=>qa(t,ue(n,...a));return Object.assign(Object.assign(r,t),{does:r})}function qa(e,t){let r=ie(t,"@fragment "),n=e.returnType;return typeof t=="string"&&St(t,n,o=>r.applyExternals(o)),{shell:e,outputType:n,$uses(o){return r.applyExternals(o),this},[_chunkUMHCZDPAcjs.a]:!0,[_chunkUMHCZDPAcjs.d]:r,$name(o){return _chunkUMHCZDPAcjs.j.call(void 0, r,o),_chunkUMHCZDPAcjs.k.call(void 0, n)&&n.$name(`${o}_Output`),this},"~resolve"(o){let i=e.in?se(e.in,o.varyingLocations).$name(`${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => (""))}_Input`):void 0;if(i&&r.applyExternals({In:i}),r.applyExternals({Out:n}),typeof t=="string")return r.resolve(o,i?[i]:[],e.returnType);let s=o;if(s.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return s.callStack.push(n),r.resolve(o,i?[i]:[],e.returnType)}finally{s.callStack.pop()}},toString(){return`fragmentFn:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, r), () => ("<unnamed>"))}`}}}function zn(e){if(Object.keys(e.out).length===0)throw new Error("A vertexFn output cannot be empty since it must include the 'position' builtin.");let t={in:e.in,out:e.out,argTypes:e.in&&Object.keys(e.in).length!==0?[se(e.in)]:[],isEntry:!0},r=(n,...a)=>Qa(t,ue(n,...a));return Object.assign(Object.assign(r,t),{does:r})}function Qa(e,t){let r=ie(t,"@vertex "),n=e.argTypes[0];return{shell:e,$uses(o){return r.applyExternals(o),this},[_chunkUMHCZDPAcjs.a]:!0,[_chunkUMHCZDPAcjs.d]:r,$name(o){return _chunkUMHCZDPAcjs.j.call(void 0, r,o),_chunkUMHCZDPAcjs.k.call(void 0, n)&&n.$name(`${o}_Input`),this},"~resolve"(o){let i=se(e.out,o.varyingLocations).$name(`${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => (""))}_Output`);if(typeof t=="string")return n&&r.applyExternals({In:n}),r.applyExternals({Out:i}),r.resolve(o,e.argTypes,i);let s=o;if(s.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return s.callStack.push(i),r.resolve(o,e.argTypes,i)}finally{s.callStack.pop()}},toString(){return`vertexFn:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, r), () => ("<unnamed>"))}`}}}var pe= (_class2 =class{constructor() { _class2.prototype.__init2.call(this); }__init2() {this.lastUniqueId=0}makeUnique(t){let r;return t?(r=t.replaceAll(/\s/g,"_"),r=r.replaceAll(/[^\w\d]/g,"")):r="item",`${r}_${this.lastUniqueId++}`}}, _class2),le= exports.StrictNameRegistry = (_class3 =class{constructor() { _class3.prototype.__init3.call(this); }__init3() {this._usedNames=new Set}makeUnique(t){if(t===void 0)throw new Error("Unnamed item found when using a strict name registry");let r=0,n=t;for(;this._usedNames.has(n);)r++,n=`${t}_${r}`;return this._usedNames.add(n),n}}, _class3);function Je(e){return typeof _optionalChain([e, 'optionalAccess', _28 => _28.format])=="string"}function jn(e,t){let r=[];if(_chunkUMHCZDPAcjs.da.call(void 0, e)){if(!Je(t))throw new Error("Shader expected a single attribute, not a record of attributes to be passed in.");return r.push(t._layout),{usedVertexLayouts:r,bufferDefinitions:[{arrayStride:t._layout.stride,stepMode:t._layout.stepMode,attributes:[{format:t.format,offset:t.offset,shaderLocation:_nullishCoalesce(_chunkUMHCZDPAcjs.ca.call(void 0, e), () => (0))}]}]}}let n=[],a=new WeakMap,o=0;for(let[i,s]of Object.entries(e)){if(_chunkRC26P3MPcjs.aa.call(void 0, s))continue;let p=t[i];if(!p)throw new Error(`An attribute by the name of '${i}' was not provided to the shader.`);let u=p._layout,f=a.get(u);f||(r.push(u),f=[],n.push({arrayStride:u.stride,stepMode:u.stepMode,attributes:f}),a.set(u,f)),o=_nullishCoalesce(_chunkUMHCZDPAcjs.ca.call(void 0, s), () => (o)),f.push({format:p.format,offset:p.offset,shaderLocation:o++})}return{usedVertexLayouts:r,bufferDefinitions:n}}var Ka=["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"];function Ha(e){return Ka.includes(e.type)}function br(e,[t,r]){return` ${_chunkRC26P3MPcjs.ba.call(void 0, r)}${t}: ${e.resolve(r)},
7
+ `}function Ya(e,t){let r=e.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, t));return e.addDeclaration(`
7
8
  struct ${r} {
8
- ${Object.entries(t.propTypes).map(n=>sr(e,n)).join("")}}
9
- `),r}function Ia(e,t){let r=e.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, t));return e.addDeclaration(`
9
+ ${Object.entries(t.propTypes).map(n=>br(e,n)).join("")}}
10
+ `),r}function Ja(e,t){let r=e.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, t));return e.addDeclaration(`
10
11
  struct ${r} {
11
- ${Object.entries(t.propTypes).map(n=>qe(n[1])?sr(e,[n[0],_chunk7ACLI4JYcjs.b[n[1].format]]):sr(e,n)).join("")}
12
+ ${Object.entries(t.propTypes).map(n=>Je(n[1])?br(e,[n[0],_chunkRC26P3MPcjs.b[n[1].format]]):br(e,n)).join("")}
12
13
  }
13
- `),r}function Ua(e,t){let r=e.resolve(t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function Aa(e,t){let r=e.resolve(qe(t.elementType)?_chunk7ACLI4JYcjs.b[t.elementType.format]:t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function ur(e,t){if(_chunkV4CSEIB2cjs.U.call(void 0, t))return t.type==="unstruct"?Ia(e,t):t.type==="disarray"?Aa(e,t):t.type==="loose-decorated"?e.resolve(qe(t.inner)?_chunk7ACLI4JYcjs.b[t.inner.format]:t.inner):e.resolve(_chunk7ACLI4JYcjs.b[t.type]);if(Da(t))return t.type;if(t.type==="struct")return Fa(e,t);if(t.type==="array")return Ua(e,t);if(t.type==="atomic")return`atomic<${ur(e,t.inner)}>`;if(t.type==="decorated")return e.resolve(t.inner);if(t.type==="ptr")return t.addressSpace==="storage"?`ptr<storage, ${e.resolve(t.inner)}, ${t.access==="read-write"?"read_write":t.access}>`:`ptr<${t.addressSpace}, ${e.resolve(t.inner)}>`;if(t.type==="abstractInt"||t.type==="abstractFloat")throw new Error("Abstract types have no concrete representation in WGSL");if(t.type==="void")throw new Error("Void has no representation in WGSL");dt(t,"resolveData")}var _typedbinary = require('typed-binary');function Ba(e,t){let r="size"in e?e.size:e.currentByteOffset,n=t-1,a=r&n;"skipBytes"in e?e.skipBytes(t-a&n):e.add(t-a&n)}var R=Ba;var An=new WeakMap;function yt(e){let t=An.get(e);if(t)return t;let r=new _typedbinary.Measurer,n={},a;for(let o in e.propTypes){let i=e.propTypes[o];if(i===void 0)throw new Error(`Property ${o} is undefined in struct`);let s=r.size;R(r,_chunkV4CSEIB2cjs.W.call(void 0, e)?_chunk7ACLI4JYcjs.T.call(void 0, i):_chunk7ACLI4JYcjs.S.call(void 0, i)),a&&(a.padding=r.size-s);let l=_chunk7ACLI4JYcjs.V.call(void 0, i);n[o]={offset:r.size,size:l},a=n[o],r.add(l)}return a&&(a.padding=_chunk7ACLI4JYcjs.a.call(void 0, _chunk7ACLI4JYcjs.V.call(void 0, e),_chunk7ACLI4JYcjs.S.call(void 0, e))-r.size),An.set(e,n),n}var xt=(()=>{try{return new Function("return true"),!0}catch (e2){return!1}})(),pr=new WeakMap,lr={u32:"u32",vec2u:"u32",vec3u:"u32",vec4u:"u32",i32:"i32",vec2i:"i32",vec3i:"i32",vec4i:"i32",f32:"f32",vec2f:"f32",vec3f:"f32",vec4f:"f32",vec2h:"f32",vec3h:"f32",vec4h:"f32",mat2x2f:"f32",mat3x3f:"f32",mat4x4f:"f32"},mr={u32:"setUint32",i32:"setInt32",f32:"setFloat32"};function Tt(e,t,r){if(_chunkV4CSEIB2cjs.M.call(void 0, e)||_chunkV4CSEIB2cjs.S.call(void 0, e))return Tt(e.inner,t,r);if(_chunkV4CSEIB2cjs.K.call(void 0, e)||_chunkV4CSEIB2cjs.W.call(void 0, e)){let a=yt(e),o=Object.entries(a).sort((s,l)=>s[1].offset-l[1].offset),i="";for(let[s,l]of o){let u=e.propTypes[s];u&&(i+=Tt(u,`(${t} + ${l.offset})`,`${r}.${s}`))}return i}if(_chunkV4CSEIB2cjs.J.call(void 0, e)||_chunkV4CSEIB2cjs.V.call(void 0, e)){let a=e,o=_chunk7ACLI4JYcjs.a.call(void 0, _chunk7ACLI4JYcjs.V.call(void 0, a.elementType),_chunk7ACLI4JYcjs.S.call(void 0, a.elementType)),i="";return i+=`for (let i = 0; i < ${a.elementCount}; i++) {
14
- `,i+=Tt(a.elementType,`(${t} + i * ${o})`,`${r}[i]`),i+=`}
15
- `,i}if(_chunkV4CSEIB2cjs.C.call(void 0, e)){let a=lr[e.type],o="",i=mr[a],s=["x","y","z","w"],l=_chunkV4CSEIB2cjs.A.call(void 0, e)?2:_chunkV4CSEIB2cjs.B.call(void 0, e)?3:4;for(let u=0;u<l;u++)o+=`output.${i}((${t} + ${u*4}), ${r}.${s[u]}, littleEndian);
16
- `;return o}if(_chunkV4CSEIB2cjs.G.call(void 0, e)){let a=lr[e.type],o=mr[a],i=_chunkV4CSEIB2cjs.E.call(void 0, e)?2:_chunkV4CSEIB2cjs.F.call(void 0, e)?3:4,s=i*i,l=_chunk7ACLI4JYcjs.a.call(void 0, i*4,8),u="";for(let d=0;d<s;d++){let g=Math.floor(d/i),c=d%i,y=g*l+c*4;u+=`output.${o}((${t} + ${y}), ${r}.columns[${g}].${["x","y","z","w"][c]}, littleEndian);
17
- `}return u}let n=lr[e.type];return`output.${mr[n]}(${t}, ${r}, littleEndian);
18
- `}function ht(e){if(pr.has(e))return pr.get(e);let t=Tt(e,"offset","value"),r=new Function("output","offset","value","littleEndian=true",t);return pr.set(e,r),r}var Ce={bool(){throw new Error("Booleans are not host-shareable")},f32(e,t,r){e.writeFloat32(r)},f16(e,t,r){e.writeFloat16(r)},i32(e,t,r){e.writeInt32(r)},u32(e,t,r){e.writeUint32(r)},vec2f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},vec2h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},vec2i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},vec2u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},"vec2<bool>"(){throw new Error("Booleans are not host-shareable")},vec3f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},vec3h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z)},vec3i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},vec3u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},"vec3<bool>"(){throw new Error("Booleans are not host-shareable")},vec4f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},vec4h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},vec4i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},vec4u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},"vec4<bool>"(){throw new Error("Booleans are not host-shareable")},mat2x2f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat3x3f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat4x4f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},struct(e,t,r){let n=_chunk7ACLI4JYcjs.S.call(void 0, t);R(e,n);for(let[a,o]of Object.entries(t.propTypes))R(e,_chunk7ACLI4JYcjs.S.call(void 0, o)),se(e,o,r[a]);R(e,n)},array(e,t,r){if(t.elementCount===0)throw new Error("Cannot write using a runtime-sized schema.");let n=_chunk7ACLI4JYcjs.S.call(void 0, t);R(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)R(e,n),se(e,t.elementType,r[o]);e.seekTo(a+_chunk7ACLI4JYcjs.V.call(void 0, t))},ptr(){throw new Error("Pointers are not host-shareable")},atomic(e,t,r){_optionalChain([Ce, 'access', _27 => _27[t.inner.type], 'optionalCall', _28 => _28(e,t,r)])},decorated(e,t,r){let n=_chunk7ACLI4JYcjs.T.call(void 0, t);R(e,n);let a=e.currentByteOffset;_optionalChain([Ce, 'access', _29 => _29[_optionalChain([t, 'access', _30 => _30.inner, 'optionalAccess', _31 => _31.type])], 'optionalCall', _32 => _32(e,t.inner,r)]),e.seekTo(a+_chunk7ACLI4JYcjs.V.call(void 0, t))},uint8(e,t,r){e.writeUint8(r)},uint8x2(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y)},uint8x4(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y),e.writeUint8(r.z),e.writeUint8(r.w)},sint8(e,t,r){e.writeInt8(r)},sint8x2(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y)},sint8x4(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y),e.writeInt8(r.z),e.writeInt8(r.w)},unorm8(e,t,r){e.writeUint8(r*255)},unorm8x2(e,t,r){e.writeUint8(r.x*255),e.writeUint8(r.y*255)},unorm8x4(e,t,r){e.writeUint8(r.x*255),e.writeUint8(r.y*255),e.writeUint8(r.z*255),e.writeUint8(r.w*255)},snorm8(e,t,r){e.writeUint8(r*127+128)},snorm8x2(e,t,r){e.writeUint8(r.x*127+128),e.writeUint8(r.y*127+128)},snorm8x4(e,t,r){e.writeUint8(r.x*127+128),e.writeUint8(r.y*127+128),e.writeUint8(r.z*127+128),e.writeUint8(r.w*127+128)},uint16(e,t,r){e.writeUint16(r)},uint16x2(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y)},uint16x4(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y),e.writeUint16(r.z),e.writeUint16(r.w)},sint16(e,t,r){e.writeInt16(r)},sint16x2(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y)},sint16x4(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y),e.writeInt16(r.z),e.writeInt16(r.w)},unorm16(e,t,r){e.writeUint16(r*65535)},unorm16x2(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535)},unorm16x4(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535),e.writeUint16(r.z*65535),e.writeUint16(r.w*65535)},snorm16(e,t,r){e.writeUint16(r*32767+32768)},snorm16x2(e,t,r){e.writeUint16(r.x*32767+32768),e.writeUint16(r.y*32767+32768)},snorm16x4(e,t,r){e.writeUint16(r.x*32767+32768),e.writeUint16(r.y*32767+32768),e.writeUint16(r.z*32767+32768),e.writeUint16(r.w*32767+32768)},float16(e,t,r){e.writeFloat16(r)},float16x2(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},float16x4(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},float32(e,t,r){e.writeFloat32(r)},float32x2(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},float32x3(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},float32x4(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},uint32(e,t,r){e.writeUint32(r)},uint32x2(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},uint32x3(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},uint32x4(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},sint32(e,t,r){e.writeInt32(r)},sint32x2(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},sint32x3(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},sint32x4(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},"unorm10-10-10-2"(e,t,r){let n=0;n|=(r.x*1023&1023)<<22,n|=(r.x*1023&1023)<<12,n|=(r.y*1023&1023)<<2,n|=r.z*3&3,e.writeUint32(n)},"unorm8x4-bgra"(e,t,r){e.writeUint8(r.z*255),e.writeUint8(r.y*255),e.writeUint8(r.x*255),e.writeUint8(r.w*255)},disarray(e,t,r){let n=_chunk7ACLI4JYcjs.S.call(void 0, t);R(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)R(e,n),_optionalChain([Ce, 'access', _33 => _33[_optionalChain([t, 'access', _34 => _34.elementType, 'optionalAccess', _35 => _35.type])], 'optionalCall', _36 => _36(e,t.elementType,r[o])]);e.seekTo(a+_chunk7ACLI4JYcjs.V.call(void 0, t))},unstruct(e,t,r){for(let[n,a]of Object.entries(t.propTypes))_optionalChain([Ce, 'access', _37 => _37[a.type], 'optionalCall', _38 => _38(e,a,r[n])])},"loose-decorated"(e,t,r){let n=_chunk7ACLI4JYcjs.T.call(void 0, t);R(e,n);let a=e.currentByteOffset,o=Ce[_optionalChain([t, 'access', _39 => _39.inner, 'optionalAccess', _40 => _40.type])];return _optionalChain([o, 'optionalCall', _41 => _41(e,t.inner,r)]),e.seekTo(a+_chunk7ACLI4JYcjs.V.call(void 0, t)),r}};function se(e,t,r){let n=Ce[t.type];if(!n)throw new Error(`Cannot write data of type '${t.type}'.`);n(e,t,r)}var ye={bool(){throw new Error("Booleans are not host-shareable")},f32(e){return e.readFloat32()},f16(e){return e.readFloat16()},i32(e){return e.readInt32()},u32(e){return e.readUint32()},vec2f(e){return _chunkV4CSEIB2cjs.ma.call(void 0, e.readFloat32(),e.readFloat32())},vec3f(e){return _chunkV4CSEIB2cjs.ra.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32())},vec4f(e){return _chunkV4CSEIB2cjs.wa.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},vec2h(e){return _chunkV4CSEIB2cjs.na.call(void 0, e.readFloat16(),e.readFloat16())},vec3h(e){return _chunkV4CSEIB2cjs.sa.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16())},vec4h(e){return _chunkV4CSEIB2cjs.xa.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16())},vec2i(e){return _chunkV4CSEIB2cjs.oa.call(void 0, e.readInt32(),e.readInt32())},vec3i(e){return _chunkV4CSEIB2cjs.ta.call(void 0, e.readInt32(),e.readInt32(),e.readInt32())},vec4i(e){return _chunkV4CSEIB2cjs.ya.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32())},vec2u(e){return _chunkV4CSEIB2cjs.pa.call(void 0, e.readUint32(),e.readUint32())},vec3u(e){return _chunkV4CSEIB2cjs.ua.call(void 0, e.readUint32(),e.readUint32(),e.readUint32())},vec4u(e){return _chunkV4CSEIB2cjs.za.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32())},"vec2<bool>"(){throw new Error("Booleans are not host-shareable")},"vec3<bool>"(){throw new Error("Booleans are not host-shareable")},"vec4<bool>"(){throw new Error("Booleans are not host-shareable")},mat2x2f(e){return _chunkV4CSEIB2cjs.Ca.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},mat3x3f(e){let t=()=>{let r=e.readFloat32();return e.readFloat32(),r};return _chunkV4CSEIB2cjs.Da.call(void 0, e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t())},mat4x4f(e){return _chunkV4CSEIB2cjs.Ea.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},struct(e,t){let r=_chunk7ACLI4JYcjs.S.call(void 0, t);R(e,r);let n={};for(let[a,o]of Object.entries(t.propTypes))R(e,_chunk7ACLI4JYcjs.S.call(void 0, o)),n[a]=N(e,o);return R(e,r),n},array(e,t){if(t.elementCount===0)throw new Error("Cannot read using a runtime-sized schema.");let r=_chunk7ACLI4JYcjs.S.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++){R(e,r);let o=t.elementType,i=N(e,o);n.push(i)}return R(e,r),n},ptr(){throw new Error("Pointers are not host-shareable")},atomic(e,t){return N(e,t.inner)},decorated(e,t){let r=_chunk7ACLI4JYcjs.T.call(void 0, t);R(e,r);let n=e.currentByteOffset,a=N(e,t.inner);return e.seekTo(n+_chunk7ACLI4JYcjs.V.call(void 0, t)),a},uint8:e=>e.readUint8(),uint8x2:e=>_chunkV4CSEIB2cjs.pa.call(void 0, e.readUint8(),e.readUint8()),uint8x4:e=>_chunkV4CSEIB2cjs.za.call(void 0, e.readUint8(),e.readUint8(),e.readUint8(),e.readUint8()),sint8:e=>e.readInt8(),sint8x2:e=>_chunkV4CSEIB2cjs.oa.call(void 0, e.readInt8(),e.readInt8()),sint8x4:e=>_chunkV4CSEIB2cjs.ya.call(void 0, e.readInt8(),e.readInt8(),e.readInt8(),e.readInt8()),unorm8:e=>e.readUint8()/255,unorm8x2:e=>_chunkV4CSEIB2cjs.ma.call(void 0, e.readUint8()/255,e.readUint8()/255),unorm8x4:e=>_chunkV4CSEIB2cjs.wa.call(void 0, e.readUint8()/255,e.readUint8()/255,e.readUint8()/255,e.readUint8()/255),snorm8:e=>(e.readUint8()-128)/127,snorm8x2:e=>_chunkV4CSEIB2cjs.ma.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127),snorm8x4:e=>_chunkV4CSEIB2cjs.wa.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127,(e.readUint8()-128)/127,(e.readUint8()-128)/127),uint16:e=>e.readUint16(),uint16x2:e=>_chunkV4CSEIB2cjs.pa.call(void 0, e.readUint16(),e.readUint16()),uint16x4:e=>_chunkV4CSEIB2cjs.za.call(void 0, e.readUint16(),e.readUint16(),e.readUint16(),e.readUint16()),sint16:e=>e.readInt16(),sint16x2:e=>_chunkV4CSEIB2cjs.oa.call(void 0, e.readInt16(),e.readInt16()),sint16x4:e=>_chunkV4CSEIB2cjs.ya.call(void 0, e.readInt16(),e.readInt16(),e.readInt16(),e.readInt16()),unorm16:e=>e.readUint16()/65535,unorm16x2:e=>_chunkV4CSEIB2cjs.ma.call(void 0, e.readUint16()/65535,e.readUint16()/65535),unorm16x4:e=>_chunkV4CSEIB2cjs.wa.call(void 0, e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535),snorm16:e=>(e.readUint16()-32768)/32767,snorm16x2:e=>_chunkV4CSEIB2cjs.ma.call(void 0, ye.snorm16(e),ye.snorm16(e)),snorm16x4:e=>_chunkV4CSEIB2cjs.wa.call(void 0, ye.snorm16(e),ye.snorm16(e),ye.snorm16(e),ye.snorm16(e)),float16(e){return e.readFloat16()},float16x2:e=>_chunkV4CSEIB2cjs.ma.call(void 0, e.readFloat16(),e.readFloat16()),float16x4:e=>_chunkV4CSEIB2cjs.wa.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16()),float32:e=>e.readFloat32(),float32x2:e=>_chunkV4CSEIB2cjs.ma.call(void 0, e.readFloat32(),e.readFloat32()),float32x3:e=>_chunkV4CSEIB2cjs.ra.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32()),float32x4:e=>_chunkV4CSEIB2cjs.wa.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32()),uint32:e=>e.readUint32(),uint32x2:e=>_chunkV4CSEIB2cjs.pa.call(void 0, e.readUint32(),e.readUint32()),uint32x3:e=>_chunkV4CSEIB2cjs.ua.call(void 0, e.readUint32(),e.readUint32(),e.readUint32()),uint32x4:e=>_chunkV4CSEIB2cjs.za.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32()),sint32:e=>e.readInt32(),sint32x2:e=>_chunkV4CSEIB2cjs.oa.call(void 0, e.readInt32(),e.readInt32()),sint32x3:e=>_chunkV4CSEIB2cjs.ta.call(void 0, e.readInt32(),e.readInt32(),e.readInt32()),sint32x4:e=>_chunkV4CSEIB2cjs.ya.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32()),"unorm10-10-10-2"(e){let t=e.readUint32(),r=(t>>22)/1023,n=(t>>12&1023)/1023,a=(t>>2&1023)/1023,o=(t&3)/3;return _chunkV4CSEIB2cjs.wa.call(void 0, r,n,a,o)},"unorm8x4-bgra"(e){let t=e.readByte()/255,r=e.readByte()/255,n=e.readByte()/255,a=e.readByte()/255;return _chunkV4CSEIB2cjs.wa.call(void 0, n,r,t,a)},unstruct(e,t){let r={};for(let[n,a]of Object.entries(t.propTypes))r[n]=N(e,a);return r},disarray(e,t){let r=_chunk7ACLI4JYcjs.S.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++)R(e,r),n.push(N(e,t.elementType));return R(e,r),n},"loose-decorated"(e,t){R(e,_chunk7ACLI4JYcjs.T.call(void 0, t));let r=e.currentByteOffset,n=N(e,t.inner);return e.seekTo(r+_chunk7ACLI4JYcjs.V.call(void 0, t)),n}};function N(e,t){let r=ye[t.type];if(!r)throw new Error(`Cannot read data of type '${t.type}'.`);return r(e,t)}function Bn(e,t){let r=_chunk7ACLI4JYcjs.V.call(void 0, e);if(r===0||t===void 0||t===null)return[];let n=new ArrayBuffer(r),a=new (0, _typedbinary.BufferWriter)(n),o=[];function i(u,d,g,c){if(d!=null){if(_chunkV4CSEIB2cjs.K.call(void 0, u)||_chunkV4CSEIB2cjs.W.call(void 0, u)){let y=yt(u);for(let[x,w]of Object.entries(y)){let b=u.propTypes[x];if(!b)continue;let U=d[x];U!==void 0&&i(b,U,g+w.offset,_nullishCoalesce(w.padding, () => (c)))}return}if(_chunkV4CSEIB2cjs.J.call(void 0, u)||_chunkV4CSEIB2cjs.V.call(void 0, u)){let y=u,x=_chunk7ACLI4JYcjs.a.call(void 0, _chunk7ACLI4JYcjs.V.call(void 0, y.elementType),_chunk7ACLI4JYcjs.S.call(void 0, y.elementType));if(!Array.isArray(d))throw new Error("Partial value for array must be an array");let w=_nullishCoalesce(d, () => ([]));w.sort((b,U)=>b.idx-U.idx);for(let{idx:b,value:U}of w)i(y.elementType,U,g+b*x,x-_chunk7ACLI4JYcjs.V.call(void 0, y.elementType))}else{let y=_chunk7ACLI4JYcjs.V.call(void 0, u);a.seekTo(g),se(a,u,d),o.push({start:g,end:g+y,padding:c})}}}if(i(e,t,0),o.length===0)return[];let s=[],l=o[0];for(let u=1;u<o.length;u++){let d=o[u];if(!d||!l)throw new Error("Internal error: missing segment");d.start===l.end+(_nullishCoalesce(l.padding, () => (0)))?(l.end=d.end,l.padding=d.padding):(s.push({data:new Uint8Array(n,l.start,l.end-l.start)}),l=d)}if(!l)throw new Error("Internal error: missing segment");return s.push({data:new Uint8Array(n,l.start,l.end-l.start)}),s}function Te(e){return!!_optionalChain([e, 'optionalAccess', _42 => _42.usableAsStorage])}var Je=class e extends Error{constructor(t){super(`Resource '${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, t), () => ("<unnamed>"))}' cannot be bound as 'storage'. Use .$usage('storage') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function wt(e){return!!e.usableAsUniform}var Vn={uniform:"uniform",mutable:"storage, read_write",readonly:"storage, read"},Ye= (_class4 =class{constructor(t,r){;_class4.prototype.__init4.call(this);this.usage=t;this.buffer=r;this[_chunkV4CSEIB2cjs.a]={dataType:r.dataType},this[_chunkV4CSEIB2cjs.d]=r}__init4() {this.resourceType="buffer-usage"}$name(t){return this.buffer.$name(t),this}"~resolve"(t){let r=t.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this)),{group:n,binding:a}=t.allocateFixedEntry(this.usage==="uniform"?{uniform:this.buffer.dataType}:{storage:this.buffer.dataType,access:this.usage},this.buffer),o=Vn[this.usage];return t.addDeclaration(`@group(${n}) @binding(${a}) var<${o}> ${r}: ${t.resolve(this.buffer.dataType)};`),r}write(t){this.buffer.write(t)}toString(){return`${this.usage}:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}[_chunkV4CSEIB2cjs.c](){return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`,[_chunkV4CSEIB2cjs.b]:this.buffer.dataType},q)}get value(){if(!_chunkV4CSEIB2cjs.t.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return this[_chunkV4CSEIB2cjs.c]()}}, _class4),Qe= (_class5 =class{constructor(t,r,n){;_class5.prototype.__init5.call(this);this.usage=t;this.dataType=r;this._membership=n;this[_chunkV4CSEIB2cjs.a]={dataType:r},_chunkV4CSEIB2cjs.f.call(void 0, this,n.key)}__init5() {this.resourceType="buffer-usage"}"~resolve"(t){let r=t.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this)),n=t.allocateLayoutEntry(this._membership.layout),a=Vn[this.usage];return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var<${a}> ${r}: ${t.resolve(this.dataType)};`),r}toString(){return`${this.usage}:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}[_chunkV4CSEIB2cjs.c](){return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`,[_chunkV4CSEIB2cjs.b]:this.dataType},q)}get value(){if(!_chunkV4CSEIB2cjs.t.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return this[_chunkV4CSEIB2cjs.c]()}}, _class5),Rn=new WeakMap;function dr(e){if(!Te(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.`);let t=Rn.get(e);return t||(t=new Ye("mutable",e),Rn.set(e,t)),t}var Pn=new WeakMap;function fr(e){if(!Te(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.`);let t=Pn.get(e);return t||(t=new Ye("readonly",e),Pn.set(e,t)),t}var Cn=new WeakMap;function gr(e){if(!wt(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.`);let t=Cn.get(e);return t||(t=new Ye("uniform",e),Cn.set(e,t)),t}var $a={uniform:gr,mutable:dr,readonly:fr};function kn(e,t,r){return _chunkV4CSEIB2cjs.I.call(void 0, t)?new bt(e,t,r):new bt(e,t,r,["storage","uniform"])}function ue(e){return e.resourceType==="buffer"}function ka(e){return!!e.usableAsVertex}var $n=_typedbinary.getSystemEndianness.call(void 0, ),bt= (_class6 =class{constructor(t,r,n,a){;_class6.prototype.__init6.call(this);_class6.prototype.__init7.call(this);_class6.prototype.__init8.call(this);_class6.prototype.__init9.call(this);_class6.prototype.__init10.call(this);_class6.prototype.__init11.call(this);_class6.prototype.__init12.call(this);this._group=t;this.dataType=r;this.initialOrBuffer=n;this._disallowedUsages=a;fn(n)?(this._ownBuffer=!1,this._buffer=n):(this._ownBuffer=!0,this.initial=n)}__init6() {this.resourceType="buffer"}__init7() {this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC}__init8() {this._buffer=null}__init9() {this._destroyed=!1}__init10() {this.usableAsUniform=!1}__init11() {this.usableAsStorage=!1}__init12() {this.usableAsVertex=!1}get buffer(){let t=this._group.device;if(this._destroyed)throw new Error("This buffer has been destroyed");if(!this._buffer&&(this._buffer=t.createBuffer({size:_chunk7ACLI4JYcjs.V.call(void 0, this.dataType),usage:this.flags,mappedAtCreation:!!this.initial,label:_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}),this.initial)){let r=new (0, _typedbinary.BufferWriter)(this._buffer.getMappedRange());se(r,this.dataType,this.initial),this._buffer.unmap()}return this._buffer}get destroyed(){return this._destroyed}$name(t){return _chunkV4CSEIB2cjs.f.call(void 0, this,t),this._buffer&&(this._buffer.label=t),this}$usage(...t){for(let r of t){if(_optionalChain([this, 'access', _43 => _43._disallowedUsages, 'optionalAccess', _44 => _44.includes, 'call', _45 => _45(r)]))throw new Error(`Buffer of type ${this.dataType.type} cannot be used as ${r}`);this.flags|=r==="uniform"?GPUBufferUsage.UNIFORM:0,this.flags|=r==="storage"?GPUBufferUsage.STORAGE:0,this.flags|=r==="vertex"?GPUBufferUsage.VERTEX:0,this.usableAsUniform=this.usableAsUniform||r==="uniform",this.usableAsStorage=this.usableAsStorage||r==="storage",this.usableAsVertex=this.usableAsVertex||r==="vertex"}return this}$addFlags(t){if(!this._ownBuffer)throw new Error("Cannot add flags to a buffer that is not managed by TypeGPU.");return t&GPUBufferUsage.MAP_READ?(this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this):t&GPUBufferUsage.MAP_WRITE?(this.flags=GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,this):(this.flags|=t,this)}compileWriter(){if(xt)ht(this.dataType);else throw new Error("This environment does not allow eval")}write(t){let r=this.buffer,n=this._group.device;if(r.mapState==="mapped"){let o=r.getMappedRange();if(xt){ht(this.dataType)(new DataView(o),0,t,$n==="little");return}se(new (0, _typedbinary.BufferWriter)(o),this.dataType,t);return}let a=_chunk7ACLI4JYcjs.V.call(void 0, this.dataType);this._hostBuffer||(this._hostBuffer=new ArrayBuffer(a)),this._group.flush(),xt?ht(this.dataType)(new DataView(this._hostBuffer),0,t,$n==="little"):se(new (0, _typedbinary.BufferWriter)(this._hostBuffer),this.dataType,t),n.queue.writeBuffer(r,0,this._hostBuffer,0,a)}writePartial(t){let r=this.buffer,n=this._group.device,a=Bn(this.dataType,t);if(r.mapState==="mapped"){let o=r.getMappedRange(),i=new Uint8Array(o);for(let s of a)i.set(s.data,s.data.byteOffset)}else for(let o of a)n.queue.writeBuffer(r,o.data.byteOffset,o.data,0,o.data.byteLength)}copyFrom(t){if(this.buffer.mapState==="mapped")throw new Error("Cannot copy to a mapped buffer.");let r=_chunk7ACLI4JYcjs.V.call(void 0, this.dataType);this._group.commandEncoder.copyBufferToBuffer(t.buffer,0,this.buffer,0,r)}async read(){this._group.flush();let t=this.buffer,r=this._group.device;if(t.mapState==="mapped"){let i=t.getMappedRange();return N(new (0, _typedbinary.BufferReader)(i),this.dataType)}if(t.usage&GPUBufferUsage.MAP_READ){await t.mapAsync(GPUMapMode.READ);let i=t.getMappedRange(),s=N(new (0, _typedbinary.BufferReader)(i),this.dataType);return t.unmap(),s}let n=r.createBuffer({size:_chunk7ACLI4JYcjs.V.call(void 0, this.dataType),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder();a.copyBufferToBuffer(t,0,n,0,_chunk7ACLI4JYcjs.V.call(void 0, this.dataType)),r.queue.submit([a.finish()]),await r.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,_chunk7ACLI4JYcjs.V.call(void 0, this.dataType));let o=N(new (0, _typedbinary.BufferReader)(n.getMappedRange()),this.dataType);return n.unmap(),n.destroy(),o}as(t){return _optionalChain([$a, 'access', _46 => _46[t], 'optionalCall', _47 => _47(this)])}destroy(){this._destroyed||(this._destroyed=!0,this._ownBuffer&&_optionalChain([this, 'access', _48 => _48._buffer, 'optionalAccess', _49 => _49.destroy, 'call', _50 => _50()]))}toString(){return`buffer:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}}, _class6);function _n(e){return new Tr(e)}function En(e){return new xr(e)}function Xe(e){let t=e;return _optionalChain([t, 'optionalAccess', _51 => _51.resourceType])==="sampler"&&!!t[_chunkV4CSEIB2cjs.a]}function Ze(e){let t=e;return _optionalChain([t, 'optionalAccess', _52 => _52.resourceType])==="sampler-comparison"&&!!t[_chunkV4CSEIB2cjs.a]}var St= (_class7 =class{constructor(t){;_class7.prototype.__init13.call(this);this._membership=t;this[_chunkV4CSEIB2cjs.b]=this,this[_chunkV4CSEIB2cjs.a]={},_chunkV4CSEIB2cjs.f.call(void 0, this,t.key)}__init13() {this.resourceType="sampler"}"~resolve"(t){let r=t.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this)),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}}, _class7),vt= (_class8 =class{constructor(t){;_class8.prototype.__init14.call(this);this._membership=t;this[_chunkV4CSEIB2cjs.b]=this,this[_chunkV4CSEIB2cjs.a]={},_chunkV4CSEIB2cjs.f.call(void 0, this,t.key)}__init14() {this.resourceType="sampler-comparison"}"~resolve"(t){let r=t.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this)),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler_comparison;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}}, _class8),Tr= (_class9 =class{constructor(t){;_class9.prototype.__init15.call(this);_class9.prototype.__init16.call(this);this._props=t;this[_chunkV4CSEIB2cjs.b]=this,this[_chunkV4CSEIB2cjs.a]={unwrap:r=>(this._sampler||(this._sampler=r.device.createSampler({...this._props,label:_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))})),this._sampler)},this._filtering=t.minFilter==="linear"||t.magFilter==="linear"||t.mipmapFilter==="linear"}__init15() {this.resourceType="sampler"}__init16() {this._sampler=null}$name(t){return _chunkV4CSEIB2cjs.f.call(void 0, this,t),this}"~resolve"(t){let r=t.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this)),{group:n,binding:a}=t.allocateFixedEntry({sampler:this._filtering?"filtering":"non-filtering"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}}, _class9),xr= (_class10 =class{constructor(t){;_class10.prototype.__init17.call(this);_class10.prototype.__init18.call(this);this._props=t;this[_chunkV4CSEIB2cjs.b]=this,this[_chunkV4CSEIB2cjs.a]={unwrap:r=>(this._sampler||(this._sampler=r.device.createSampler({...this._props,label:_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))})),this._sampler)}}__init17() {this.resourceType="sampler-comparison"}__init18() {this._sampler=null}$name(t){return _chunkV4CSEIB2cjs.f.call(void 0, this,t),this}"~resolve"(t){let r=t.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this)),{group:n,binding:a}=t.allocateFixedEntry({sampler:"comparison"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler_comparison;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}}, _class10);var Dt= (_class11 =class{constructor(t){;_class11.prototype.__init19.call(this);this._membership=t;_chunkV4CSEIB2cjs.f.call(void 0, this,t.key)}__init19() {this.resourceType="external-texture"}"~resolve"(t){let r=t.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this)),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: texture_external;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}}, _class11);var Gn={r8unorm:_chunkV4CSEIB2cjs.ka,r8snorm:_chunkV4CSEIB2cjs.ka,r8uint:_chunkV4CSEIB2cjs.ia,r8sint:_chunkV4CSEIB2cjs.ja,r16uint:_chunkV4CSEIB2cjs.ia,r16sint:_chunkV4CSEIB2cjs.ja,r16float:_chunkV4CSEIB2cjs.ka,rg8unorm:_chunkV4CSEIB2cjs.ka,rg8snorm:_chunkV4CSEIB2cjs.ka,rg8uint:_chunkV4CSEIB2cjs.ia,rg8sint:_chunkV4CSEIB2cjs.ja,r32uint:_chunkV4CSEIB2cjs.ia,r32sint:_chunkV4CSEIB2cjs.ja,r32float:_chunkV4CSEIB2cjs.ka,rg16uint:_chunkV4CSEIB2cjs.ia,rg16sint:_chunkV4CSEIB2cjs.ja,rg16float:_chunkV4CSEIB2cjs.ka,rgba8unorm:_chunkV4CSEIB2cjs.ka,"rgba8unorm-srgb":_chunkV4CSEIB2cjs.ka,rgba8snorm:_chunkV4CSEIB2cjs.ka,rgba8uint:_chunkV4CSEIB2cjs.ia,rgba8sint:_chunkV4CSEIB2cjs.ja,bgra8unorm:_chunkV4CSEIB2cjs.ka,"bgra8unorm-srgb":_chunkV4CSEIB2cjs.ka,rgb9e5ufloat:_chunkV4CSEIB2cjs.ka,rgb10a2uint:_chunkV4CSEIB2cjs.ia,rgb10a2unorm:_chunkV4CSEIB2cjs.ka,rg11b10ufloat:_chunkV4CSEIB2cjs.ka,rg32uint:_chunkV4CSEIB2cjs.ia,rg32sint:_chunkV4CSEIB2cjs.ja,rg32float:_chunkV4CSEIB2cjs.ka,rgba16uint:_chunkV4CSEIB2cjs.ia,rgba16sint:_chunkV4CSEIB2cjs.ja,rgba16float:_chunkV4CSEIB2cjs.ka,rgba32uint:_chunkV4CSEIB2cjs.ia,rgba32sint:_chunkV4CSEIB2cjs.ja,rgba32float:_chunkV4CSEIB2cjs.ka,stencil8:_chunkV4CSEIB2cjs.ka,depth16unorm:_chunkV4CSEIB2cjs.ka,depth24plus:_chunkV4CSEIB2cjs.ka,"depth24plus-stencil8":_chunkV4CSEIB2cjs.ka,depth32float:_chunkV4CSEIB2cjs.ka,"depth32float-stencil8":_chunkV4CSEIB2cjs.ka,"bc1-rgba-unorm":_chunkV4CSEIB2cjs.ka,"bc1-rgba-unorm-srgb":_chunkV4CSEIB2cjs.ka,"bc2-rgba-unorm":_chunkV4CSEIB2cjs.ka,"bc2-rgba-unorm-srgb":_chunkV4CSEIB2cjs.ka,"bc3-rgba-unorm":_chunkV4CSEIB2cjs.ka,"bc3-rgba-unorm-srgb":_chunkV4CSEIB2cjs.ka,"bc4-r-unorm":_chunkV4CSEIB2cjs.ka,"bc4-r-snorm":_chunkV4CSEIB2cjs.ka,"bc5-rg-unorm":_chunkV4CSEIB2cjs.ka,"bc5-rg-snorm":_chunkV4CSEIB2cjs.ka,"bc6h-rgb-ufloat":_chunkV4CSEIB2cjs.ka,"bc6h-rgb-float":_chunkV4CSEIB2cjs.ka,"bc7-rgba-unorm":_chunkV4CSEIB2cjs.ka,"bc7-rgba-unorm-srgb":_chunkV4CSEIB2cjs.ka,"etc2-rgb8unorm":_chunkV4CSEIB2cjs.ka,"etc2-rgb8unorm-srgb":_chunkV4CSEIB2cjs.ka,"etc2-rgb8a1unorm":_chunkV4CSEIB2cjs.ka,"etc2-rgb8a1unorm-srgb":_chunkV4CSEIB2cjs.ka,"etc2-rgba8unorm":_chunkV4CSEIB2cjs.ka,"etc2-rgba8unorm-srgb":_chunkV4CSEIB2cjs.ka,"eac-r11unorm":_chunkV4CSEIB2cjs.ka,"eac-r11snorm":_chunkV4CSEIB2cjs.ka,"eac-rg11unorm":_chunkV4CSEIB2cjs.ka,"eac-rg11snorm":_chunkV4CSEIB2cjs.ka,"astc-4x4-unorm":_chunkV4CSEIB2cjs.ka,"astc-4x4-unorm-srgb":_chunkV4CSEIB2cjs.ka,"astc-5x4-unorm":_chunkV4CSEIB2cjs.ka,"astc-5x4-unorm-srgb":_chunkV4CSEIB2cjs.ka,"astc-5x5-unorm":_chunkV4CSEIB2cjs.ka,"astc-5x5-unorm-srgb":_chunkV4CSEIB2cjs.ka,"astc-6x5-unorm":_chunkV4CSEIB2cjs.ka,"astc-6x5-unorm-srgb":_chunkV4CSEIB2cjs.ka,"astc-6x6-unorm":_chunkV4CSEIB2cjs.ka,"astc-6x6-unorm-srgb":_chunkV4CSEIB2cjs.ka,"astc-8x5-unorm":_chunkV4CSEIB2cjs.ka,"astc-8x5-unorm-srgb":_chunkV4CSEIB2cjs.ka,"astc-8x6-unorm":_chunkV4CSEIB2cjs.ka,"astc-8x6-unorm-srgb":_chunkV4CSEIB2cjs.ka,"astc-8x8-unorm":_chunkV4CSEIB2cjs.ka,"astc-8x8-unorm-srgb":_chunkV4CSEIB2cjs.ka,"astc-10x5-unorm":_chunkV4CSEIB2cjs.ka,"astc-10x5-unorm-srgb":_chunkV4CSEIB2cjs.ka,"astc-10x6-unorm":_chunkV4CSEIB2cjs.ka,"astc-10x6-unorm-srgb":_chunkV4CSEIB2cjs.ka,"astc-10x8-unorm":_chunkV4CSEIB2cjs.ka,"astc-10x8-unorm-srgb":_chunkV4CSEIB2cjs.ka,"astc-10x10-unorm":_chunkV4CSEIB2cjs.ka,"astc-10x10-unorm-srgb":_chunkV4CSEIB2cjs.ka,"astc-12x10-unorm":_chunkV4CSEIB2cjs.ka,"astc-12x10-unorm-srgb":_chunkV4CSEIB2cjs.ka,"astc-12x12-unorm":_chunkV4CSEIB2cjs.ka,"astc-12x12-unorm-srgb":_chunkV4CSEIB2cjs.ka},et={rgba8unorm:_chunkV4CSEIB2cjs.wa,rgba8snorm:_chunkV4CSEIB2cjs.wa,rgba8uint:_chunkV4CSEIB2cjs.za,rgba8sint:_chunkV4CSEIB2cjs.ya,rgba16uint:_chunkV4CSEIB2cjs.za,rgba16sint:_chunkV4CSEIB2cjs.ya,rgba16float:_chunkV4CSEIB2cjs.wa,r32uint:_chunkV4CSEIB2cjs.za,r32sint:_chunkV4CSEIB2cjs.ya,r32float:_chunkV4CSEIB2cjs.wa,rg32uint:_chunkV4CSEIB2cjs.za,rg32sint:_chunkV4CSEIB2cjs.ya,rg32float:_chunkV4CSEIB2cjs.wa,rgba32uint:_chunkV4CSEIB2cjs.za,rgba32sint:_chunkV4CSEIB2cjs.ya,rgba32float:_chunkV4CSEIB2cjs.wa,bgra8unorm:_chunkV4CSEIB2cjs.wa},Ln={f32:"float",u32:"uint",i32:"sint"},On={float:_chunkV4CSEIB2cjs.ka,"unfilterable-float":_chunkV4CSEIB2cjs.ka,uint:_chunkV4CSEIB2cjs.ia,sint:_chunkV4CSEIB2cjs.ja,depth:_chunkV4CSEIB2cjs.ka};function Mn(e,t){return new hr(e,t)}function Q(e){return _optionalChain([e, 'optionalAccess', _53 => _53.resourceType])==="texture"&&!!e[_chunkV4CSEIB2cjs.a]}function tt(e){return _optionalChain([e, 'optionalAccess', _54 => _54.resourceType])==="texture-storage-view"&&!!e[_chunkV4CSEIB2cjs.a]}function rt(e){return _optionalChain([e, 'optionalAccess', _55 => _55.resourceType])==="texture-sampled-view"&&!!e[_chunkV4CSEIB2cjs.a]}var Wn={mutable:"read_write",readonly:"read",writeonly:"write"},hr= (_class12 =class{constructor(t,r){;_class12.prototype.__init20.call(this);_class12.prototype.__init21.call(this);_class12.prototype.__init22.call(this);_class12.prototype.__init23.call(this);_class12.prototype.__init24.call(this);_class12.prototype.__init25.call(this);_class12.prototype.__init26.call(this);this.props=t;this._branch=r;this[_chunkV4CSEIB2cjs.a]={unwrap:()=>{if(this._destroyed)throw new Error("This texture has been destroyed");return this._texture||(this._texture=this._branch.device.createTexture({label:_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>")),format:this.props.format,size:this.props.size,usage:this._flags,dimension:_nullishCoalesce(this.props.dimension, () => ("2d")),viewFormats:_nullishCoalesce(this.props.viewFormats, () => ([])),mipLevelCount:_nullishCoalesce(this.props.mipLevelCount, () => (1)),sampleCount:_nullishCoalesce(this.props.sampleCount, () => (1))})),this._texture}}}__init20() {this.resourceType="texture"}__init21() {this.usableAsSampled=!1}__init22() {this.usableAsStorage=!1}__init23() {this.usableAsRender=!1}__init24() {this._destroyed=!1}__init25() {this._flags=GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC}__init26() {this._texture=null}$name(t){return _chunkV4CSEIB2cjs.f.call(void 0, this,t),this}$usage(...t){let r=t.includes("storage"),n=t.includes("sampled"),a=t.includes("render");return this._flags|=n?GPUTextureUsage.TEXTURE_BINDING:0,this._flags|=r?GPUTextureUsage.STORAGE_BINDING:0,this._flags|=a?GPUTextureUsage.RENDER_ATTACHMENT:0,this.usableAsStorage||=r,this.usableAsSampled||=n,this.usableAsRender||=a,this}createView(t,r){if(t==="sampled")return this._asSampled(r);let n=r;switch(t){case"mutable":return this._asMutable(n);case"readonly":return this._asReadonly(n);case"writeonly":return this._asWriteonly(n)}}_asStorage(t,r){if(!this.usableAsStorage)throw new Error("Unusable as storage");let n=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _56 => _56.format]), () => (this.props.format)),a=et[n];return _chunkV4CSEIB2cjs.h.call(void 0, !!a,`Unsupported storage texture format: ${n}`),new wr(_nullishCoalesce(t, () => ({})),r,this)}_asReadonly(t){return this._asStorage(t,"readonly")}_asWriteonly(t){return this._asStorage(t,"writeonly")}_asMutable(t){return this._asStorage(t,"mutable")}_asSampled(t){if(!this.usableAsSampled)throw new Error("Unusable as sampled");let r=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _57 => _57.format]), () => (this.props.format));if(!et[r])throw new Error(`Unsupported storage texture format: ${r}`);return new br(t,this)}destroy(){this._destroyed||(this._destroyed=!0,_optionalChain([this, 'access', _58 => _58._texture, 'optionalAccess', _59 => _59.destroy, 'call', _60 => _60()]))}}, _class12),Ut={"1d":"1d","2d":"2d","2d-array":"2d_array",cube:"cube","cube-array":"cube_array","3d":"3d"},wr= (_class13 =class{constructor(t,r,n){;_class13.prototype.__init27.call(this);this.access=r;this._texture=n;this[_chunkV4CSEIB2cjs.b]=this,this[_chunkV4CSEIB2cjs.a]={unwrap:()=>(this._view||(this._view=this._texture[_chunkV4CSEIB2cjs.a].unwrap().createView({label:`${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))} - View`,format:this._format,dimension:this.dimension})),this._view)},this[_chunkV4CSEIB2cjs.d]=n,this.dimension=_nullishCoalesce(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _61 => _61.dimension]), () => (n.props.dimension)), () => ("2d")),this._format=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _62 => _62.format]), () => (n.props.format)),this.texelDataType=et[this._format]}__init27() {this.resourceType="texture-storage-view"}$name(t){return this._texture.$name(t),this}"~resolve"(t){let r=t.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this)),{group:n,binding:a}=t.allocateFixedEntry({storageTexture:this._format,access:this.access,viewDimension:this.dimension},this),o=`texture_storage_${Ut[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: ${o}<${this._format}, ${Wn[this.access]}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}}, _class13),Ft= (_class14 =class{constructor(t,r,n,a){;_class14.prototype.__init28.call(this);this._format=t;this.dimension=r;this.access=n;this._membership=a;this[_chunkV4CSEIB2cjs.b]=this,this[_chunkV4CSEIB2cjs.a]={},this.texelDataType=et[this._format],_chunkV4CSEIB2cjs.f.call(void 0, this,a.key)}__init28() {this.resourceType="texture-storage-view"}"~resolve"(t){let r=t.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this)),n=t.allocateLayoutEntry(this._membership.layout),a=`texture_storage_${Ut[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${this._format}, ${Wn[this.access]}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}}, _class14),br= (_class15 =class{constructor(t,r){;_class15.prototype.__init29.call(this);this._props=t;this._texture=r;this[_chunkV4CSEIB2cjs.b]=this,this[_chunkV4CSEIB2cjs.a]={unwrap:()=>(this._view||(this._view=this._texture[_chunkV4CSEIB2cjs.a].unwrap().createView({label:`${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))} - View`,...this._props})),this._view)},this[_chunkV4CSEIB2cjs.d]=r,this.dimension=_nullishCoalesce(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _63 => _63.dimension]), () => (r.props.dimension)), () => ("2d")),this._format=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _64 => _64.format]), () => (r.props.format)),this.channelDataType=Gn[this._format]}__init29() {this.resourceType="texture-sampled-view"}$name(t){return this._texture.$name(t),this}"~resolve"(t){let r=t.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this)),n=(_nullishCoalesce(this._texture.props.sampleCount, () => (1)))>1,{group:a,binding:o}=t.allocateFixedEntry({texture:Ln[this.channelDataType.type],viewDimension:this.dimension,multisampled:n},this),i=n?"texture_multisampled_2d":`texture_${Ut[this.dimension]}`;return t.addDeclaration(`@group(${a}) @binding(${o}) var ${r}: ${i}<${t.resolve(this.channelDataType)}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}}, _class15),It= (_class16 =class{constructor(t,r,n,a){;_class16.prototype.__init30.call(this);this.dimension=r;this._multisampled=n;this._membership=a;this[_chunkV4CSEIB2cjs.b]=this,this[_chunkV4CSEIB2cjs.a]={},_chunkV4CSEIB2cjs.f.call(void 0, this,a.key),this.channelDataType=On[t]}__init30() {this.resourceType="texture-sampled-view"}"~resolve"(t){let r=t.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this)),n=t.allocateLayoutEntry(this._membership.layout),a=this._multisampled?"texture_multisampled_2d":`texture_${Ut[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${t.resolve(this.channelDataType)}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}}, _class16);function Sr(e){return!!_optionalChain([e, 'optionalAccess', _65 => _65.usableAsSampled])}function _a(e){return!!_optionalChain([e, 'optionalAccess', _66 => _66.usableAsRender])}var At=class e extends Error{constructor(t){super(`Resource '${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, t), () => ("<unnamed>"))}' cannot be bound as 'sampled'. Use .$usage('sampled') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function Bt(e){return new Dr(e)}function Rt(e){return!!e&&e.resourceType==="bind-group-layout"}function Fr(e){return!!e&&e.resourceType==="bind-group"}var vr=class e extends Error{constructor(t,r){super(`Bind group '${_nullishCoalesce(t, () => ("<unnamed>"))}' is missing a required binding '${r}'`),Object.setPrototypeOf(this,e.prototype)}},Nn=["compute"],Ve=["compute","vertex","fragment"],Dr= (_class17 =class{constructor(t){;_class17.prototype.__init31.call(this);_class17.prototype.__init32.call(this);_class17.prototype.__init33.call(this);_class17.prototype.__init34.call(this);this.entries=t;let r=0;for(let[n,a]of Object.entries(t)){if(a===null){r++;continue}let o={layout:this,key:n,idx:r};if("uniform"in a&&(this.bound[n]=new Qe("uniform",a.uniform,o)),"storage"in a){let i="type"in a.storage?a.storage:a.storage(0);this.bound[n]=new Qe(_nullishCoalesce(a.access, () => ("readonly")),i,o)}"texture"in a&&(this.bound[n]=new It(a.texture,_nullishCoalesce(a.viewDimension, () => ("2d")),_nullishCoalesce(a.multisampled, () => (!1)),o)),"storageTexture"in a&&(this.bound[n]=new Ft(a.storageTexture,_nullishCoalesce(a.viewDimension, () => ("2d")),_nullishCoalesce(a.access, () => ("writeonly")),o)),"externalTexture"in a&&(this.bound[n]=new Dt(o)),"sampler"in a&&(a.sampler==="comparison"?this.bound[n]=new vt(o):this.bound[n]=new St(o)),"texture"in a||"storageTexture"in a||"externalTexture"in a||"sampler"in a?this.value[n]=this.bound[n]:Object.defineProperty(this.value,n,{get:()=>this.bound[n].value}),r++}}__init31() {this.resourceType="bind-group-layout"}__init32() {this.bound={}}__init33() {this.value={}}__init34() {this.$=this.value}toString(){return`bindGroupLayout:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}get index(){return this._index}$name(t){return _chunkV4CSEIB2cjs.f.call(void 0, this,t),this}$idx(t){return this._index=t,this}unwrap(t){return t.device.createBindGroupLayout({label:_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>")),entries:Object.values(this.entries).map((n,a)=>{if(n===null)return null;let o=n.visibility,i={binding:a,visibility:0};if("uniform"in n)o=_nullishCoalesce(o, () => (Ve)),i.buffer={type:"uniform"};else if("storage"in n)o=_nullishCoalesce(o, () => ((n.access==="mutable"?Nn:Ve))),i.buffer={type:n.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in n)o=_nullishCoalesce(o, () => (Ve)),i.sampler={type:n.sampler};else if("texture"in n)o=_nullishCoalesce(o, () => (Ve)),i.texture={sampleType:n.texture,viewDimension:_nullishCoalesce(n.viewDimension, () => ("2d")),multisampled:_nullishCoalesce(n.multisampled, () => (!1))};else if("storageTexture"in n){let s=_nullishCoalesce(n.access, () => ("writeonly"));o=_nullishCoalesce(o, () => ((s==="readonly"?Ve:Nn))),i.storageTexture={format:n.storageTexture,access:{mutable:"read-write",readonly:"read-only",writeonly:"write-only"}[s],viewDimension:_nullishCoalesce(n.viewDimension, () => ("2d"))}}else"externalTexture"in n&&(o=_nullishCoalesce(o, () => (Ve)),i.externalTexture={});return _optionalChain([o, 'optionalAccess', _67 => _67.includes, 'call', _68 => _68("compute")])&&(i.visibility|=GPUShaderStage.COMPUTE),_optionalChain([o, 'optionalAccess', _69 => _69.includes, 'call', _70 => _70("vertex")])&&(i.visibility|=GPUShaderStage.VERTEX),_optionalChain([o, 'optionalAccess', _71 => _71.includes, 'call', _72 => _72("fragment")])&&(i.visibility|=GPUShaderStage.FRAGMENT),i}).filter(n=>n!==null)})}}, _class17),$e= (_class18 =class{constructor(t,r){;_class18.prototype.__init35.call(this);this.layout=t;this.entries=r;for(let n of Object.keys(t.entries))if(t.entries[n]!==null&&!(n in r))throw new vr(_chunkV4CSEIB2cjs.e.call(void 0, t),n)}__init35() {this.resourceType="bind-group"}unwrap(t){return t.device.createBindGroup({label:_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this.layout), () => ("<unnamed>")),layout:t.unwrap(this.layout),entries:Object.entries(this.layout.entries).map(([n,a],o)=>{if(a===null)return null;let i=this.entries[n];if(i===void 0)throw new Error(`'${n}' is a resource required to populate bind group layout '${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this.layout), () => ("<unnamed>"))}'.`);if("uniform"in a){let s;if(ue(i)){if(!wt(i))throw new (0, _chunkV4CSEIB2cjs.k)(i);s={buffer:t.unwrap(i)}}else s={buffer:i};return{binding:o,resource:s}}if("storage"in a){let s;if(ue(i)){if(!Te(i))throw new Je(i);s={buffer:t.unwrap(i)}}else s={buffer:i};return{binding:o,resource:s}}if("texture"in a){let s;if(Q(i)){if(!Sr(i))throw new At(i);s=t.unwrap(i.createView("sampled"))}else rt(i)?s=t.unwrap(i):s=i;return{binding:o,resource:s}}if("storageTexture"in a){let s;if(Q(i)){if(!Te(i))throw new Je(i);a.access==="readonly"?s=t.unwrap(i.createView("readonly")):a.access==="mutable"?s=t.unwrap(i.createView("mutable")):s=t.unwrap(i.createView("writeonly"))}else tt(i)?s=t.unwrap(i):s=i;return{binding:o,resource:s}}if("sampler"in a)return Xe(i)||Ze(i)?{binding:o,resource:t.unwrap(i)}:{binding:o,resource:i};if("externalTexture"in a)return{binding:o,resource:i};throw new Error(`Malformed bind group entry: ${i} (${JSON.stringify(i)})`)}).filter(n=>n!==null)})}}, _class18);var{NodeTypeCatalog:F}=Ea,Ga=["==","!=","<","<=",">",">=","<<",">>","+","-","*","/","%","|","^","&","&&","||"],La=["&&","||","==","!=","<","<=",">",">="];function jn(e,t,r){return r?La.includes(t)?_chunkV4CSEIB2cjs.ha:t==="="?r:e:t==="!"||t==="~"?_chunkV4CSEIB2cjs.ha:e}function Oa(e){throw new Error(`'${JSON.stringify(e)}' was not handled by the WGSL generator.`)}function zn(e,[t,r]){e.pushBlockScope();try{return`${e.indent()}{
19
- ${r.map(n=>xe(e,n)).join(`
14
+ `),r}function Xa(e,t){let r=e.resolve(t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function Za(e,t){let r=e.resolve(Je(t.elementType)?_chunkRC26P3MPcjs.b[t.elementType.format]:t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function wr(e,t){if(_chunkUMHCZDPAcjs.Y.call(void 0, t))return t.type==="unstruct"?Ja(e,t):t.type==="disarray"?Za(e,t):t.type==="loose-decorated"?e.resolve(Je(t.inner)?_chunkRC26P3MPcjs.b[t.inner.format]:t.inner):e.resolve(_chunkRC26P3MPcjs.b[t.type]);if(Ha(t))return t.type;if(t.type==="struct")return Ya(e,t);if(t.type==="array")return Xa(e,t);if(t.type==="atomic")return`atomic<${wr(e,t.inner)}>`;if(t.type==="decorated")return e.resolve(t.inner);if(t.type==="ptr")return t.addressSpace==="storage"?`ptr<storage, ${e.resolve(t.inner)}, ${t.access==="read-write"?"read_write":t.access}>`:`ptr<${t.addressSpace}, ${e.resolve(t.inner)}>`;if(t.type==="abstractInt"||t.type==="abstractFloat"||t.type==="void"||t.type==="u16")throw new Error(`${t.type} has no representation in WGSL`);ht(t,"resolveData")}var _typedbinary = require('typed-binary');function eo(e,t){let r="size"in e?e.size:e.currentByteOffset,n=t-1,a=r&n;"skipBytes"in e?e.skipBytes(t-a&n):e.add(t-a&n)}var A=eo;var qn=new WeakMap;function It(e){let t=qn.get(e);if(t)return t;let r=new _typedbinary.Measurer,n={},a;for(let o in e.propTypes){let i=e.propTypes[o];if(i===void 0)throw new Error(`Property ${o} is undefined in struct`);let s=r.size;A(r,_chunkUMHCZDPAcjs._.call(void 0, e)?_chunkRC26P3MPcjs.T.call(void 0, i):_chunkRC26P3MPcjs.S.call(void 0, i)),a&&(a.padding=r.size-s);let p=_chunkRC26P3MPcjs.V.call(void 0, i);n[o]={offset:r.size,size:p},a=n[o],r.add(p)}return a&&(a.padding=_chunkRC26P3MPcjs.a.call(void 0, _chunkRC26P3MPcjs.V.call(void 0, e),_chunkRC26P3MPcjs.S.call(void 0, e))-r.size),qn.set(e,n),n}var Ft=(()=>{try{return new Function("return true"),!0}catch (e2){return!1}})(),Sr=new WeakMap,vr={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",vec2h:"f32",vec3h:"f32",vec4h:"f32",mat2x2f:"f32",mat3x3f:"f32",mat4x4f:"f32"},Dr={u32:"setUint32",i32:"setInt32",f32:"setFloat32",u16:"setUint16"};function Ut(e,t,r){if(_chunkUMHCZDPAcjs.Q.call(void 0, e)||_chunkUMHCZDPAcjs.W.call(void 0, e))return Ut(e.inner,t,r);if(_chunkUMHCZDPAcjs.O.call(void 0, e)||_chunkUMHCZDPAcjs._.call(void 0, e)){let a=It(e),o=Object.entries(a).sort((s,p)=>s[1].offset-p[1].offset),i="";for(let[s,p]of o){let u=e.propTypes[s];u&&(i+=Ut(u,`(${t} + ${p.offset})`,`${r}.${s}`))}return i}if(_chunkUMHCZDPAcjs.N.call(void 0, e)||_chunkUMHCZDPAcjs.Z.call(void 0, e)){let a=e,o=_chunkRC26P3MPcjs.a.call(void 0, _chunkRC26P3MPcjs.V.call(void 0, a.elementType),_chunkRC26P3MPcjs.S.call(void 0, a.elementType)),i="";return i+=`for (let i = 0; i < ${a.elementCount}; i++) {
15
+ `,i+=Ut(a.elementType,`(${t} + i * ${o})`,`${r}[i]`),i+=`}
16
+ `,i}if(_chunkUMHCZDPAcjs.G.call(void 0, e)){let a=vr[e.type],o="",i=Dr[a],s=["x","y","z","w"],p=_chunkUMHCZDPAcjs.E.call(void 0, e)?2:_chunkUMHCZDPAcjs.F.call(void 0, e)?3:4;for(let u=0;u<p;u++)o+=`output.${i}((${t} + ${u*4}), ${r}.${s[u]}, littleEndian);
17
+ `;return o}if(_chunkUMHCZDPAcjs.K.call(void 0, e)){let a=vr[e.type],o=Dr[a],i=_chunkUMHCZDPAcjs.I.call(void 0, e)?2:_chunkUMHCZDPAcjs.J.call(void 0, e)?3:4,s=i*i,p=_chunkRC26P3MPcjs.a.call(void 0, i*4,8),u="";for(let f=0;f<s;f++){let m=Math.floor(f/i),g=f%i,y=m*p+g*4;u+=`output.${o}((${t} + ${y}), ${r}.columns[${m}].${["x","y","z","w"][g]}, littleEndian);
18
+ `}return u}let n=vr[e.type];return`output.${Dr[n]}(${t}, ${r}, littleEndian);
19
+ `}function Pt(e){if(Sr.has(e))return Sr.get(e);let t=Ut(e,"offset","value"),r=new Function("output","offset","value","littleEndian=true",t);return Sr.set(e,r),r}var _e={bool(){throw new Error("Booleans are not host-shareable")},f32(e,t,r){e.writeFloat32(r)},f16(e,t,r){e.writeFloat16(r)},i32(e,t,r){e.writeInt32(r)},u32(e,t,r){e.writeUint32(r)},u16(e,t,r){e.writeUint16(r)},vec2f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},vec2h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},vec2i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},vec2u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},"vec2<bool>"(){throw new Error("Booleans are not host-shareable")},vec3f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},vec3h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z)},vec3i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},vec3u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},"vec3<bool>"(){throw new Error("Booleans are not host-shareable")},vec4f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},vec4h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},vec4i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},vec4u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},"vec4<bool>"(){throw new Error("Booleans are not host-shareable")},mat2x2f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat3x3f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat4x4f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},struct(e,t,r){let n=_chunkRC26P3MPcjs.S.call(void 0, t);A(e,n);for(let[a,o]of Object.entries(t.propTypes))A(e,_chunkRC26P3MPcjs.S.call(void 0, o)),me(e,o,r[a]);A(e,n)},array(e,t,r){if(t.elementCount===0)throw new Error("Cannot write using a runtime-sized schema.");let n=_chunkRC26P3MPcjs.S.call(void 0, t);A(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)A(e,n),me(e,t.elementType,r[o]);e.seekTo(a+_chunkRC26P3MPcjs.V.call(void 0, t))},ptr(){throw new Error("Pointers are not host-shareable")},atomic(e,t,r){_optionalChain([_e, 'access', _29 => _29[t.inner.type], 'optionalCall', _30 => _30(e,t,r)])},decorated(e,t,r){let n=_chunkRC26P3MPcjs.T.call(void 0, t);A(e,n);let a=e.currentByteOffset;_optionalChain([_e, 'access', _31 => _31[_optionalChain([t, 'access', _32 => _32.inner, 'optionalAccess', _33 => _33.type])], 'optionalCall', _34 => _34(e,t.inner,r)]),e.seekTo(a+_chunkRC26P3MPcjs.V.call(void 0, t))},uint8(e,t,r){e.writeUint8(r)},uint8x2(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y)},uint8x4(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y),e.writeUint8(r.z),e.writeUint8(r.w)},sint8(e,t,r){e.writeInt8(r)},sint8x2(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y)},sint8x4(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y),e.writeInt8(r.z),e.writeInt8(r.w)},unorm8(e,t,r){e.writeUint8(r*255)},unorm8x2(e,t,r){e.writeUint8(r.x*255),e.writeUint8(r.y*255)},unorm8x4(e,t,r){e.writeUint8(r.x*255),e.writeUint8(r.y*255),e.writeUint8(r.z*255),e.writeUint8(r.w*255)},snorm8(e,t,r){e.writeUint8(r*127+128)},snorm8x2(e,t,r){e.writeUint8(r.x*127+128),e.writeUint8(r.y*127+128)},snorm8x4(e,t,r){e.writeUint8(r.x*127+128),e.writeUint8(r.y*127+128),e.writeUint8(r.z*127+128),e.writeUint8(r.w*127+128)},uint16(e,t,r){e.writeUint16(r)},uint16x2(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y)},uint16x4(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y),e.writeUint16(r.z),e.writeUint16(r.w)},sint16(e,t,r){e.writeInt16(r)},sint16x2(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y)},sint16x4(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y),e.writeInt16(r.z),e.writeInt16(r.w)},unorm16(e,t,r){e.writeUint16(r*65535)},unorm16x2(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535)},unorm16x4(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535),e.writeUint16(r.z*65535),e.writeUint16(r.w*65535)},snorm16(e,t,r){e.writeUint16(r*32767+32768)},snorm16x2(e,t,r){e.writeUint16(r.x*32767+32768),e.writeUint16(r.y*32767+32768)},snorm16x4(e,t,r){e.writeUint16(r.x*32767+32768),e.writeUint16(r.y*32767+32768),e.writeUint16(r.z*32767+32768),e.writeUint16(r.w*32767+32768)},float16(e,t,r){e.writeFloat16(r)},float16x2(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},float16x4(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},float32(e,t,r){e.writeFloat32(r)},float32x2(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},float32x3(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},float32x4(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},uint32(e,t,r){e.writeUint32(r)},uint32x2(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},uint32x3(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},uint32x4(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},sint32(e,t,r){e.writeInt32(r)},sint32x2(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},sint32x3(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},sint32x4(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},"unorm10-10-10-2"(e,t,r){let n=0;n|=(r.x*1023&1023)<<22,n|=(r.x*1023&1023)<<12,n|=(r.y*1023&1023)<<2,n|=r.z*3&3,e.writeUint32(n)},"unorm8x4-bgra"(e,t,r){e.writeUint8(r.z*255),e.writeUint8(r.y*255),e.writeUint8(r.x*255),e.writeUint8(r.w*255)},disarray(e,t,r){let n=_chunkRC26P3MPcjs.S.call(void 0, t);A(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)A(e,n),_optionalChain([_e, 'access', _35 => _35[_optionalChain([t, 'access', _36 => _36.elementType, 'optionalAccess', _37 => _37.type])], 'optionalCall', _38 => _38(e,t.elementType,r[o])]);e.seekTo(a+_chunkRC26P3MPcjs.V.call(void 0, t))},unstruct(e,t,r){for(let[n,a]of Object.entries(t.propTypes))_optionalChain([_e, 'access', _39 => _39[a.type], 'optionalCall', _40 => _40(e,a,r[n])])},"loose-decorated"(e,t,r){let n=_chunkRC26P3MPcjs.T.call(void 0, t);A(e,n);let a=e.currentByteOffset,o=_e[_optionalChain([t, 'access', _41 => _41.inner, 'optionalAccess', _42 => _42.type])];return _optionalChain([o, 'optionalCall', _43 => _43(e,t.inner,r)]),e.seekTo(a+_chunkRC26P3MPcjs.V.call(void 0, t)),r}};function me(e,t,r){let n=_e[t.type];if(!n)throw new Error(`Cannot write data of type '${t.type}'.`);n(e,t,r)}var Se={bool(){throw new Error("Booleans are not host-shareable")},f32(e){return e.readFloat32()},f16(e){return e.readFloat16()},i32(e){return e.readInt32()},u32(e){return e.readUint32()},u16(e){return e.readUint16()},vec2f(e){return _chunkUMHCZDPAcjs.ra.call(void 0, e.readFloat32(),e.readFloat32())},vec3f(e){return _chunkUMHCZDPAcjs.wa.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32())},vec4f(e){return _chunkUMHCZDPAcjs.Ba.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},vec2h(e){return _chunkUMHCZDPAcjs.sa.call(void 0, e.readFloat16(),e.readFloat16())},vec3h(e){return _chunkUMHCZDPAcjs.xa.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16())},vec4h(e){return _chunkUMHCZDPAcjs.Ca.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16())},vec2i(e){return _chunkUMHCZDPAcjs.ta.call(void 0, e.readInt32(),e.readInt32())},vec3i(e){return _chunkUMHCZDPAcjs.ya.call(void 0, e.readInt32(),e.readInt32(),e.readInt32())},vec4i(e){return _chunkUMHCZDPAcjs.Da.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32())},vec2u(e){return _chunkUMHCZDPAcjs.ua.call(void 0, e.readUint32(),e.readUint32())},vec3u(e){return _chunkUMHCZDPAcjs.za.call(void 0, e.readUint32(),e.readUint32(),e.readUint32())},vec4u(e){return _chunkUMHCZDPAcjs.Ea.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32())},"vec2<bool>"(){throw new Error("Booleans are not host-shareable")},"vec3<bool>"(){throw new Error("Booleans are not host-shareable")},"vec4<bool>"(){throw new Error("Booleans are not host-shareable")},mat2x2f(e){return _chunkUMHCZDPAcjs.Pa.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},mat3x3f(e){let t=()=>{let r=e.readFloat32();return e.readFloat32(),r};return _chunkUMHCZDPAcjs.Qa.call(void 0, e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t())},mat4x4f(e){return _chunkUMHCZDPAcjs.Ra.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},struct(e,t){let r=_chunkRC26P3MPcjs.S.call(void 0, t);A(e,r);let n={};for(let[a,o]of Object.entries(t.propTypes))A(e,_chunkRC26P3MPcjs.S.call(void 0, o)),n[a]=j(e,o);return A(e,r),n},array(e,t){if(t.elementCount===0)throw new Error("Cannot read using a runtime-sized schema.");let r=_chunkRC26P3MPcjs.S.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++){A(e,r);let o=t.elementType,i=j(e,o);n.push(i)}return A(e,r),n},ptr(){throw new Error("Pointers are not host-shareable")},atomic(e,t){return j(e,t.inner)},decorated(e,t){let r=_chunkRC26P3MPcjs.T.call(void 0, t);A(e,r);let n=e.currentByteOffset,a=j(e,t.inner);return e.seekTo(n+_chunkRC26P3MPcjs.V.call(void 0, t)),a},uint8:e=>e.readUint8(),uint8x2:e=>_chunkUMHCZDPAcjs.ua.call(void 0, e.readUint8(),e.readUint8()),uint8x4:e=>_chunkUMHCZDPAcjs.Ea.call(void 0, e.readUint8(),e.readUint8(),e.readUint8(),e.readUint8()),sint8:e=>e.readInt8(),sint8x2:e=>_chunkUMHCZDPAcjs.ta.call(void 0, e.readInt8(),e.readInt8()),sint8x4:e=>_chunkUMHCZDPAcjs.Da.call(void 0, e.readInt8(),e.readInt8(),e.readInt8(),e.readInt8()),unorm8:e=>e.readUint8()/255,unorm8x2:e=>_chunkUMHCZDPAcjs.ra.call(void 0, e.readUint8()/255,e.readUint8()/255),unorm8x4:e=>_chunkUMHCZDPAcjs.Ba.call(void 0, e.readUint8()/255,e.readUint8()/255,e.readUint8()/255,e.readUint8()/255),snorm8:e=>(e.readUint8()-128)/127,snorm8x2:e=>_chunkUMHCZDPAcjs.ra.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127),snorm8x4:e=>_chunkUMHCZDPAcjs.Ba.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127,(e.readUint8()-128)/127,(e.readUint8()-128)/127),uint16:e=>e.readUint16(),uint16x2:e=>_chunkUMHCZDPAcjs.ua.call(void 0, e.readUint16(),e.readUint16()),uint16x4:e=>_chunkUMHCZDPAcjs.Ea.call(void 0, e.readUint16(),e.readUint16(),e.readUint16(),e.readUint16()),sint16:e=>e.readInt16(),sint16x2:e=>_chunkUMHCZDPAcjs.ta.call(void 0, e.readInt16(),e.readInt16()),sint16x4:e=>_chunkUMHCZDPAcjs.Da.call(void 0, e.readInt16(),e.readInt16(),e.readInt16(),e.readInt16()),unorm16:e=>e.readUint16()/65535,unorm16x2:e=>_chunkUMHCZDPAcjs.ra.call(void 0, e.readUint16()/65535,e.readUint16()/65535),unorm16x4:e=>_chunkUMHCZDPAcjs.Ba.call(void 0, e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535),snorm16:e=>(e.readUint16()-32768)/32767,snorm16x2:e=>_chunkUMHCZDPAcjs.ra.call(void 0, Se.snorm16(e),Se.snorm16(e)),snorm16x4:e=>_chunkUMHCZDPAcjs.Ba.call(void 0, Se.snorm16(e),Se.snorm16(e),Se.snorm16(e),Se.snorm16(e)),float16(e){return e.readFloat16()},float16x2:e=>_chunkUMHCZDPAcjs.ra.call(void 0, e.readFloat16(),e.readFloat16()),float16x4:e=>_chunkUMHCZDPAcjs.Ba.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16()),float32:e=>e.readFloat32(),float32x2:e=>_chunkUMHCZDPAcjs.ra.call(void 0, e.readFloat32(),e.readFloat32()),float32x3:e=>_chunkUMHCZDPAcjs.wa.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32()),float32x4:e=>_chunkUMHCZDPAcjs.Ba.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32()),uint32:e=>e.readUint32(),uint32x2:e=>_chunkUMHCZDPAcjs.ua.call(void 0, e.readUint32(),e.readUint32()),uint32x3:e=>_chunkUMHCZDPAcjs.za.call(void 0, e.readUint32(),e.readUint32(),e.readUint32()),uint32x4:e=>_chunkUMHCZDPAcjs.Ea.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32()),sint32:e=>e.readInt32(),sint32x2:e=>_chunkUMHCZDPAcjs.ta.call(void 0, e.readInt32(),e.readInt32()),sint32x3:e=>_chunkUMHCZDPAcjs.ya.call(void 0, e.readInt32(),e.readInt32(),e.readInt32()),sint32x4:e=>_chunkUMHCZDPAcjs.Da.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32()),"unorm10-10-10-2"(e){let t=e.readUint32(),r=(t>>22)/1023,n=(t>>12&1023)/1023,a=(t>>2&1023)/1023,o=(t&3)/3;return _chunkUMHCZDPAcjs.Ba.call(void 0, r,n,a,o)},"unorm8x4-bgra"(e){let t=e.readByte()/255,r=e.readByte()/255,n=e.readByte()/255,a=e.readByte()/255;return _chunkUMHCZDPAcjs.Ba.call(void 0, n,r,t,a)},unstruct(e,t){let r={};for(let[n,a]of Object.entries(t.propTypes))r[n]=j(e,a);return r},disarray(e,t){let r=_chunkRC26P3MPcjs.S.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++)A(e,r),n.push(j(e,t.elementType));return A(e,r),n},"loose-decorated"(e,t){A(e,_chunkRC26P3MPcjs.T.call(void 0, t));let r=e.currentByteOffset,n=j(e,t.inner);return e.seekTo(r+_chunkRC26P3MPcjs.V.call(void 0, t)),n}};function j(e,t){let r=Se[t.type];if(!r)throw new Error(`Cannot read data of type '${t.type}'.`);return r(e,t)}function Qn(e,t){let r=_chunkRC26P3MPcjs.V.call(void 0, e);if(r===0||t===void 0||t===null)return[];let n=new ArrayBuffer(r),a=new (0, _typedbinary.BufferWriter)(n),o=[];function i(u,f,m,g){if(f!=null){if(_chunkUMHCZDPAcjs.O.call(void 0, u)||_chunkUMHCZDPAcjs._.call(void 0, u)){let y=It(u);for(let[x,b]of Object.entries(y)){let I=u.propTypes[x];if(!I)continue;let P=f[x];P!==void 0&&i(I,P,m+b.offset,_nullishCoalesce(b.padding, () => (g)))}return}if(_chunkUMHCZDPAcjs.N.call(void 0, u)||_chunkUMHCZDPAcjs.Z.call(void 0, u)){let y=u,x=_chunkRC26P3MPcjs.a.call(void 0, _chunkRC26P3MPcjs.V.call(void 0, y.elementType),_chunkRC26P3MPcjs.S.call(void 0, y.elementType));if(!Array.isArray(f))throw new Error("Partial value for array must be an array");let b=_nullishCoalesce(f, () => ([]));b.sort((I,P)=>I.idx-P.idx);for(let{idx:I,value:P}of b)i(y.elementType,P,m+I*x,x-_chunkRC26P3MPcjs.V.call(void 0, y.elementType))}else{let y=_chunkRC26P3MPcjs.V.call(void 0, u);a.seekTo(m),me(a,u,f),o.push({start:m,end:m+y,padding:g})}}}if(i(e,t,0),o.length===0)return[];let s=[],p=o[0];for(let u=1;u<o.length;u++){let f=o[u];if(!f||!p)throw new Error("Internal error: missing segment");f.start===p.end+(_nullishCoalesce(p.padding, () => (0)))?(p.end=f.end,p.padding=f.padding):(s.push({data:new Uint8Array(n,p.start,p.end-p.start)}),p=f)}if(!p)throw new Error("Internal error: missing segment");return s.push({data:new Uint8Array(n,p.start,p.end-p.start)}),s}function ve(e){return!!_optionalChain([e, 'optionalAccess', _44 => _44.usableAsStorage])}var Xe=class e extends Error{constructor(t){super(`Resource '${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, t), () => ("<unnamed>"))}' cannot be bound as 'storage'. Use .$usage('storage') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function Bt(e){return!!e.usableAsUniform}var Jn={uniform:"uniform",mutable:"storage, read_write",readonly:"storage, read"},Ze= (_class4 =class{constructor(t,r){;_class4.prototype.__init4.call(this);this.usage=t;this.buffer=r;this[_chunkUMHCZDPAcjs.a]={dataType:r.dataType},this[_chunkUMHCZDPAcjs.d]=r}__init4() {this.resourceType="buffer-usage"}$name(t){return this.buffer.$name(t),this}"~resolve"(t){let r=t.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this)),{group:n,binding:a}=t.allocateFixedEntry(this.usage==="uniform"?{uniform:this.buffer.dataType}:{storage:this.buffer.dataType,access:this.usage},this.buffer),o=Jn[this.usage];return t.addDeclaration(`@group(${n}) @binding(${a}) var<${o}> ${r}: ${t.resolve(this.buffer.dataType)};`),r}toString(){return`${this.usage}:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}[_chunkUMHCZDPAcjs.c](){return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`,[_chunkUMHCZDPAcjs.b]:this.buffer.dataType},H)}get value(){if(!_chunkUMHCZDPAcjs.y.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return this[_chunkUMHCZDPAcjs.c]()}get $(){return this.value}}, _class4),et= (_class5 =class{constructor(t,r,n){;_class5.prototype.__init5.call(this);this.usage=t;this.dataType=r;this._membership=n;this[_chunkUMHCZDPAcjs.a]={dataType:r},_chunkUMHCZDPAcjs.j.call(void 0, this,n.key)}__init5() {this.resourceType="buffer-usage"}"~resolve"(t){let r=t.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this)),n=t.allocateLayoutEntry(this._membership.layout),a=Jn[this.usage];return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var<${a}> ${r}: ${t.resolve(this.dataType)};`),r}toString(){return`${this.usage}:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}[_chunkUMHCZDPAcjs.c](){return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`,[_chunkUMHCZDPAcjs.b]:this.dataType},H)}get value(){if(!_chunkUMHCZDPAcjs.y.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return this[_chunkUMHCZDPAcjs.c]()}get $(){return this.value}}, _class5),Kn=new WeakMap;function Ir(e){if(!ve(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.`);let t=Kn.get(e);return t||(t=new Ze("mutable",e),Kn.set(e,t)),t}var Hn=new WeakMap;function Ur(e){if(!ve(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.`);let t=Hn.get(e);return t||(t=new Ze("readonly",e),Hn.set(e,t)),t}var Yn=new WeakMap;function Fr(e){if(!Bt(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.`);let t=Yn.get(e);return t||(t=new Ze("uniform",e),Yn.set(e,t)),t}var oo={uniform:Fr,mutable:Ir,readonly:Ur};function tt(e,t,r){return _chunkUMHCZDPAcjs.M.call(void 0, t)?new At(e,t,r):new At(e,t,r,["storage","uniform"])}function de(e){return e.resourceType==="buffer"}function io(e){return!!e.usableAsVertex}var Xn=_typedbinary.getSystemEndianness.call(void 0, ),At= (_class6 =class{constructor(t,r,n,a){;_class6.prototype.__init6.call(this);_class6.prototype.__init7.call(this);_class6.prototype.__init8.call(this);_class6.prototype.__init9.call(this);_class6.prototype.__init10.call(this);_class6.prototype.__init11.call(this);_class6.prototype.__init12.call(this);_class6.prototype.__init13.call(this);_class6.prototype.__init14.call(this);this._group=t;this.dataType=r;this.initialOrBuffer=n;this._disallowedUsages=a;Ye(n)?(this._ownBuffer=!1,this._buffer=n):(this._ownBuffer=!0,this.initial=n)}__init6() {this[_chunkUMHCZDPAcjs.a]=!0}__init7() {this.resourceType="buffer"}__init8() {this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC}__init9() {this._buffer=null}__init10() {this._destroyed=!1}__init11() {this.usableAsUniform=!1}__init12() {this.usableAsStorage=!1}__init13() {this.usableAsVertex=!1}__init14() {this.usableAsIndex=!1}get buffer(){let t=this._group.device;if(this._destroyed)throw new Error("This buffer has been destroyed");if(!this._buffer&&(this._buffer=t.createBuffer({size:_chunkRC26P3MPcjs.V.call(void 0, this.dataType),usage:this.flags,mappedAtCreation:!!this.initial,label:_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}),this.initial)){let r=new (0, _typedbinary.BufferWriter)(this._buffer.getMappedRange());me(r,this.dataType,this.initial),this._buffer.unmap()}return this._buffer}get destroyed(){return this._destroyed}$name(t){return _chunkUMHCZDPAcjs.j.call(void 0, this,t),this._buffer&&(this._buffer.label=t),this}$usage(...t){for(let r of t){if(_optionalChain([this, 'access', _45 => _45._disallowedUsages, 'optionalAccess', _46 => _46.includes, 'call', _47 => _47(r)]))throw new Error(`Buffer of type ${this.dataType.type} cannot be used as ${r}`);this.flags|=r==="uniform"?GPUBufferUsage.UNIFORM:0,this.flags|=r==="storage"?GPUBufferUsage.STORAGE:0,this.flags|=r==="vertex"?GPUBufferUsage.VERTEX:0,this.flags|=r==="index"?GPUBufferUsage.INDEX:0,this.usableAsUniform=this.usableAsUniform||r==="uniform",this.usableAsStorage=this.usableAsStorage||r==="storage",this.usableAsVertex=this.usableAsVertex||r==="vertex",this.usableAsIndex=this.usableAsIndex||r==="index"}return this}$addFlags(t){if(!this._ownBuffer)throw new Error("Cannot add flags to a buffer that is not managed by TypeGPU.");return t&GPUBufferUsage.MAP_READ?(this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this):t&GPUBufferUsage.MAP_WRITE?(this.flags=GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,this):(this.flags|=t,this)}compileWriter(){if(Ft)Pt(this.dataType);else throw new Error("This environment does not allow eval")}write(t){let r=this.buffer,n=this._group.device;if(r.mapState==="mapped"){let o=r.getMappedRange();if(Ft){Pt(this.dataType)(new DataView(o),0,t,Xn==="little");return}me(new (0, _typedbinary.BufferWriter)(o),this.dataType,t);return}let a=_chunkRC26P3MPcjs.V.call(void 0, this.dataType);this._hostBuffer||(this._hostBuffer=new ArrayBuffer(a)),this._group.flush(),Ft?Pt(this.dataType)(new DataView(this._hostBuffer),0,t,Xn==="little"):me(new (0, _typedbinary.BufferWriter)(this._hostBuffer),this.dataType,t),n.queue.writeBuffer(r,0,this._hostBuffer,0,a)}writePartial(t){let r=this.buffer,n=this._group.device,a=Qn(this.dataType,t);if(r.mapState==="mapped"){let o=r.getMappedRange(),i=new Uint8Array(o);for(let s of a)i.set(s.data,s.data.byteOffset)}else for(let o of a)n.queue.writeBuffer(r,o.data.byteOffset,o.data,0,o.data.byteLength)}copyFrom(t){if(this.buffer.mapState==="mapped")throw new Error("Cannot copy to a mapped buffer.");let r=_chunkRC26P3MPcjs.V.call(void 0, this.dataType);this._group.commandEncoder.copyBufferToBuffer(t.buffer,0,this.buffer,0,r)}async read(){this._group.flush();let t=this.buffer,r=this._group.device;if(t.mapState==="mapped"){let i=t.getMappedRange();return j(new (0, _typedbinary.BufferReader)(i),this.dataType)}if(t.usage&GPUBufferUsage.MAP_READ){await t.mapAsync(GPUMapMode.READ);let i=t.getMappedRange(),s=j(new (0, _typedbinary.BufferReader)(i),this.dataType);return t.unmap(),s}let n=r.createBuffer({size:_chunkRC26P3MPcjs.V.call(void 0, this.dataType),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder();a.copyBufferToBuffer(t,0,n,0,_chunkRC26P3MPcjs.V.call(void 0, this.dataType)),r.queue.submit([a.finish()]),await r.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,_chunkRC26P3MPcjs.V.call(void 0, this.dataType));let o=j(new (0, _typedbinary.BufferReader)(n.getMappedRange()),this.dataType);return n.unmap(),n.destroy(),o}as(t){return _optionalChain([oo, 'access', _48 => _48[t], 'optionalCall', _49 => _49(this)])}destroy(){this._destroyed||(this._destroyed=!0,this._ownBuffer&&_optionalChain([this, 'access', _50 => _50._buffer, 'optionalAccess', _51 => _51.destroy, 'call', _52 => _52()]))}toString(){return`buffer:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}}, _class6);function Zn(e){return new Ar(e)}function ea(e){return new Cr(e)}function rt(e){let t=e;return _optionalChain([t, 'optionalAccess', _53 => _53.resourceType])==="sampler"&&!!t[_chunkUMHCZDPAcjs.a]}function nt(e){let t=e;return _optionalChain([t, 'optionalAccess', _54 => _54.resourceType])==="sampler-comparison"&&!!t[_chunkUMHCZDPAcjs.a]}var Ct= (_class7 =class{constructor(t){;_class7.prototype.__init15.call(this);this._membership=t;this[_chunkUMHCZDPAcjs.b]=this,this[_chunkUMHCZDPAcjs.a]={},_chunkUMHCZDPAcjs.j.call(void 0, this,t.key)}__init15() {this.resourceType="sampler"}"~resolve"(t){let r=t.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this)),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}}, _class7),Rt= (_class8 =class{constructor(t){;_class8.prototype.__init16.call(this);this._membership=t;this[_chunkUMHCZDPAcjs.b]=this,this[_chunkUMHCZDPAcjs.a]={},_chunkUMHCZDPAcjs.j.call(void 0, this,t.key)}__init16() {this.resourceType="sampler-comparison"}"~resolve"(t){let r=t.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this)),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler_comparison;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}}, _class8),Ar= (_class9 =class{constructor(t){;_class9.prototype.__init17.call(this);_class9.prototype.__init18.call(this);this._props=t;this[_chunkUMHCZDPAcjs.b]=this,this[_chunkUMHCZDPAcjs.a]={unwrap:r=>(this._sampler||(this._sampler=r.device.createSampler({...this._props,label:_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))})),this._sampler)},this._filtering=t.minFilter==="linear"||t.magFilter==="linear"||t.mipmapFilter==="linear"}__init17() {this.resourceType="sampler"}__init18() {this._sampler=null}$name(t){return _chunkUMHCZDPAcjs.j.call(void 0, this,t),this}"~resolve"(t){let r=t.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this)),{group:n,binding:a}=t.allocateFixedEntry({sampler:this._filtering?"filtering":"non-filtering"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}}, _class9),Cr= (_class10 =class{constructor(t){;_class10.prototype.__init19.call(this);_class10.prototype.__init20.call(this);this._props=t;this[_chunkUMHCZDPAcjs.b]=this,this[_chunkUMHCZDPAcjs.a]={unwrap:r=>(this._sampler||(this._sampler=r.device.createSampler({...this._props,label:_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))})),this._sampler)}}__init19() {this.resourceType="sampler-comparison"}__init20() {this._sampler=null}$name(t){return _chunkUMHCZDPAcjs.j.call(void 0, this,t),this}"~resolve"(t){let r=t.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this)),{group:n,binding:a}=t.allocateFixedEntry({sampler:"comparison"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler_comparison;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}}, _class10);var $t= (_class11 =class{constructor(t){;_class11.prototype.__init21.call(this);this._membership=t;_chunkUMHCZDPAcjs.j.call(void 0, this,t.key)}__init21() {this.resourceType="external-texture"}"~resolve"(t){let r=t.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this)),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: texture_external;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}}, _class11);var ta={r8unorm:_chunkUMHCZDPAcjs.pa,r8snorm:_chunkUMHCZDPAcjs.pa,r8uint:_chunkUMHCZDPAcjs.ma,r8sint:_chunkUMHCZDPAcjs.oa,r16uint:_chunkUMHCZDPAcjs.ma,r16sint:_chunkUMHCZDPAcjs.oa,r16float:_chunkUMHCZDPAcjs.pa,rg8unorm:_chunkUMHCZDPAcjs.pa,rg8snorm:_chunkUMHCZDPAcjs.pa,rg8uint:_chunkUMHCZDPAcjs.ma,rg8sint:_chunkUMHCZDPAcjs.oa,r32uint:_chunkUMHCZDPAcjs.ma,r32sint:_chunkUMHCZDPAcjs.oa,r32float:_chunkUMHCZDPAcjs.pa,rg16uint:_chunkUMHCZDPAcjs.ma,rg16sint:_chunkUMHCZDPAcjs.oa,rg16float:_chunkUMHCZDPAcjs.pa,rgba8unorm:_chunkUMHCZDPAcjs.pa,"rgba8unorm-srgb":_chunkUMHCZDPAcjs.pa,rgba8snorm:_chunkUMHCZDPAcjs.pa,rgba8uint:_chunkUMHCZDPAcjs.ma,rgba8sint:_chunkUMHCZDPAcjs.oa,bgra8unorm:_chunkUMHCZDPAcjs.pa,"bgra8unorm-srgb":_chunkUMHCZDPAcjs.pa,rgb9e5ufloat:_chunkUMHCZDPAcjs.pa,rgb10a2uint:_chunkUMHCZDPAcjs.ma,rgb10a2unorm:_chunkUMHCZDPAcjs.pa,rg11b10ufloat:_chunkUMHCZDPAcjs.pa,rg32uint:_chunkUMHCZDPAcjs.ma,rg32sint:_chunkUMHCZDPAcjs.oa,rg32float:_chunkUMHCZDPAcjs.pa,rgba16uint:_chunkUMHCZDPAcjs.ma,rgba16sint:_chunkUMHCZDPAcjs.oa,rgba16float:_chunkUMHCZDPAcjs.pa,rgba32uint:_chunkUMHCZDPAcjs.ma,rgba32sint:_chunkUMHCZDPAcjs.oa,rgba32float:_chunkUMHCZDPAcjs.pa,stencil8:_chunkUMHCZDPAcjs.pa,depth16unorm:_chunkUMHCZDPAcjs.pa,depth24plus:_chunkUMHCZDPAcjs.pa,"depth24plus-stencil8":_chunkUMHCZDPAcjs.pa,depth32float:_chunkUMHCZDPAcjs.pa,"depth32float-stencil8":_chunkUMHCZDPAcjs.pa,"bc1-rgba-unorm":_chunkUMHCZDPAcjs.pa,"bc1-rgba-unorm-srgb":_chunkUMHCZDPAcjs.pa,"bc2-rgba-unorm":_chunkUMHCZDPAcjs.pa,"bc2-rgba-unorm-srgb":_chunkUMHCZDPAcjs.pa,"bc3-rgba-unorm":_chunkUMHCZDPAcjs.pa,"bc3-rgba-unorm-srgb":_chunkUMHCZDPAcjs.pa,"bc4-r-unorm":_chunkUMHCZDPAcjs.pa,"bc4-r-snorm":_chunkUMHCZDPAcjs.pa,"bc5-rg-unorm":_chunkUMHCZDPAcjs.pa,"bc5-rg-snorm":_chunkUMHCZDPAcjs.pa,"bc6h-rgb-ufloat":_chunkUMHCZDPAcjs.pa,"bc6h-rgb-float":_chunkUMHCZDPAcjs.pa,"bc7-rgba-unorm":_chunkUMHCZDPAcjs.pa,"bc7-rgba-unorm-srgb":_chunkUMHCZDPAcjs.pa,"etc2-rgb8unorm":_chunkUMHCZDPAcjs.pa,"etc2-rgb8unorm-srgb":_chunkUMHCZDPAcjs.pa,"etc2-rgb8a1unorm":_chunkUMHCZDPAcjs.pa,"etc2-rgb8a1unorm-srgb":_chunkUMHCZDPAcjs.pa,"etc2-rgba8unorm":_chunkUMHCZDPAcjs.pa,"etc2-rgba8unorm-srgb":_chunkUMHCZDPAcjs.pa,"eac-r11unorm":_chunkUMHCZDPAcjs.pa,"eac-r11snorm":_chunkUMHCZDPAcjs.pa,"eac-rg11unorm":_chunkUMHCZDPAcjs.pa,"eac-rg11snorm":_chunkUMHCZDPAcjs.pa,"astc-4x4-unorm":_chunkUMHCZDPAcjs.pa,"astc-4x4-unorm-srgb":_chunkUMHCZDPAcjs.pa,"astc-5x4-unorm":_chunkUMHCZDPAcjs.pa,"astc-5x4-unorm-srgb":_chunkUMHCZDPAcjs.pa,"astc-5x5-unorm":_chunkUMHCZDPAcjs.pa,"astc-5x5-unorm-srgb":_chunkUMHCZDPAcjs.pa,"astc-6x5-unorm":_chunkUMHCZDPAcjs.pa,"astc-6x5-unorm-srgb":_chunkUMHCZDPAcjs.pa,"astc-6x6-unorm":_chunkUMHCZDPAcjs.pa,"astc-6x6-unorm-srgb":_chunkUMHCZDPAcjs.pa,"astc-8x5-unorm":_chunkUMHCZDPAcjs.pa,"astc-8x5-unorm-srgb":_chunkUMHCZDPAcjs.pa,"astc-8x6-unorm":_chunkUMHCZDPAcjs.pa,"astc-8x6-unorm-srgb":_chunkUMHCZDPAcjs.pa,"astc-8x8-unorm":_chunkUMHCZDPAcjs.pa,"astc-8x8-unorm-srgb":_chunkUMHCZDPAcjs.pa,"astc-10x5-unorm":_chunkUMHCZDPAcjs.pa,"astc-10x5-unorm-srgb":_chunkUMHCZDPAcjs.pa,"astc-10x6-unorm":_chunkUMHCZDPAcjs.pa,"astc-10x6-unorm-srgb":_chunkUMHCZDPAcjs.pa,"astc-10x8-unorm":_chunkUMHCZDPAcjs.pa,"astc-10x8-unorm-srgb":_chunkUMHCZDPAcjs.pa,"astc-10x10-unorm":_chunkUMHCZDPAcjs.pa,"astc-10x10-unorm-srgb":_chunkUMHCZDPAcjs.pa,"astc-12x10-unorm":_chunkUMHCZDPAcjs.pa,"astc-12x10-unorm-srgb":_chunkUMHCZDPAcjs.pa,"astc-12x12-unorm":_chunkUMHCZDPAcjs.pa,"astc-12x12-unorm-srgb":_chunkUMHCZDPAcjs.pa,r16snorm:_chunkUMHCZDPAcjs.pa,r16unorm:_chunkUMHCZDPAcjs.pa,rg16unorm:_chunkUMHCZDPAcjs.pa,rg16snorm:_chunkUMHCZDPAcjs.pa,rgba16unorm:_chunkUMHCZDPAcjs.pa,rgba16snorm:_chunkUMHCZDPAcjs.pa},at={rgba8unorm:_chunkUMHCZDPAcjs.Ba,rgba8snorm:_chunkUMHCZDPAcjs.Ba,rgba8uint:_chunkUMHCZDPAcjs.Ea,rgba8sint:_chunkUMHCZDPAcjs.Da,rgba16uint:_chunkUMHCZDPAcjs.Ea,rgba16sint:_chunkUMHCZDPAcjs.Da,rgba16float:_chunkUMHCZDPAcjs.Ba,r32uint:_chunkUMHCZDPAcjs.Ea,r32sint:_chunkUMHCZDPAcjs.Da,r32float:_chunkUMHCZDPAcjs.Ba,rg32uint:_chunkUMHCZDPAcjs.Ea,rg32sint:_chunkUMHCZDPAcjs.Da,rg32float:_chunkUMHCZDPAcjs.Ba,rgba32uint:_chunkUMHCZDPAcjs.Ea,rgba32sint:_chunkUMHCZDPAcjs.Da,rgba32float:_chunkUMHCZDPAcjs.Ba,bgra8unorm:_chunkUMHCZDPAcjs.Ba},ra={f32:"float",u32:"uint",i32:"sint"},na={float:_chunkUMHCZDPAcjs.pa,"unfilterable-float":_chunkUMHCZDPAcjs.pa,uint:_chunkUMHCZDPAcjs.ma,sint:_chunkUMHCZDPAcjs.oa,depth:_chunkUMHCZDPAcjs.pa};function aa(e,t){return new Rr(e,t)}function Z(e){return _optionalChain([e, 'optionalAccess', _55 => _55.resourceType])==="texture"&&!!e[_chunkUMHCZDPAcjs.a]}function ot(e){return _optionalChain([e, 'optionalAccess', _56 => _56.resourceType])==="texture-storage-view"&&!!e[_chunkUMHCZDPAcjs.a]}function it(e){return _optionalChain([e, 'optionalAccess', _57 => _57.resourceType])==="texture-sampled-view"&&!!e[_chunkUMHCZDPAcjs.a]}var oa={mutable:"read_write",readonly:"read",writeonly:"write"},Rr= (_class12 =class{constructor(t,r){;_class12.prototype.__init22.call(this);_class12.prototype.__init23.call(this);_class12.prototype.__init24.call(this);_class12.prototype.__init25.call(this);_class12.prototype.__init26.call(this);_class12.prototype.__init27.call(this);_class12.prototype.__init28.call(this);this.props=t;this._branch=r;this[_chunkUMHCZDPAcjs.a]={unwrap:()=>{if(this._destroyed)throw new Error("This texture has been destroyed");return this._texture||(this._texture=this._branch.device.createTexture({label:_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>")),format:this.props.format,size:this.props.size,usage:this._flags,dimension:_nullishCoalesce(this.props.dimension, () => ("2d")),viewFormats:_nullishCoalesce(this.props.viewFormats, () => ([])),mipLevelCount:_nullishCoalesce(this.props.mipLevelCount, () => (1)),sampleCount:_nullishCoalesce(this.props.sampleCount, () => (1))})),this._texture}}}__init22() {this.resourceType="texture"}__init23() {this.usableAsSampled=!1}__init24() {this.usableAsStorage=!1}__init25() {this.usableAsRender=!1}__init26() {this._destroyed=!1}__init27() {this._flags=GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC}__init28() {this._texture=null}$name(t){return _chunkUMHCZDPAcjs.j.call(void 0, this,t),this}$usage(...t){let r=t.includes("storage"),n=t.includes("sampled"),a=t.includes("render");return this._flags|=n?GPUTextureUsage.TEXTURE_BINDING:0,this._flags|=r?GPUTextureUsage.STORAGE_BINDING:0,this._flags|=a?GPUTextureUsage.RENDER_ATTACHMENT:0,this.usableAsStorage||=r,this.usableAsSampled||=n,this.usableAsRender||=a,this}createView(t,r){if(t==="sampled")return this._asSampled(r);let n=r;switch(t){case"mutable":return this._asMutable(n);case"readonly":return this._asReadonly(n);case"writeonly":return this._asWriteonly(n)}}_asStorage(t,r){if(!this.usableAsStorage)throw new Error("Unusable as storage");let n=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _58 => _58.format]), () => (this.props.format)),a=at[n];return _chunkUMHCZDPAcjs.m.call(void 0, !!a,`Unsupported storage texture format: ${n}`),new $r(_nullishCoalesce(t, () => ({})),r,this)}_asReadonly(t){return this._asStorage(t,"readonly")}_asWriteonly(t){return this._asStorage(t,"writeonly")}_asMutable(t){return this._asStorage(t,"mutable")}_asSampled(t){if(!this.usableAsSampled)throw new Error("Unusable as sampled");let r=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _59 => _59.format]), () => (this.props.format));if(!at[r])throw new Error(`Unsupported storage texture format: ${r}`);return new Gr(t,this)}destroy(){this._destroyed||(this._destroyed=!0,_optionalChain([this, 'access', _60 => _60._texture, 'optionalAccess', _61 => _61.destroy, 'call', _62 => _62()]))}}, _class12),Et={"1d":"1d","2d":"2d","2d-array":"2d_array",cube:"cube","cube-array":"cube_array","3d":"3d"},$r= (_class13 =class{constructor(t,r,n){;_class13.prototype.__init29.call(this);this.access=r;this._texture=n;this[_chunkUMHCZDPAcjs.b]=this,this[_chunkUMHCZDPAcjs.a]={unwrap:()=>(this._view||(this._view=this._texture[_chunkUMHCZDPAcjs.a].unwrap().createView({label:`${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))} - View`,format:this._format,dimension:this.dimension})),this._view)},this[_chunkUMHCZDPAcjs.d]=n,this.dimension=_nullishCoalesce(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _63 => _63.dimension]), () => (n.props.dimension)), () => ("2d")),this._format=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _64 => _64.format]), () => (n.props.format)),this.texelDataType=at[this._format]}__init29() {this.resourceType="texture-storage-view"}$name(t){return this._texture.$name(t),this}"~resolve"(t){let r=t.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this)),{group:n,binding:a}=t.allocateFixedEntry({storageTexture:this._format,access:this.access,viewDimension:this.dimension},this),o=`texture_storage_${Et[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: ${o}<${this._format}, ${oa[this.access]}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}}, _class13),Gt= (_class14 =class{constructor(t,r,n,a){;_class14.prototype.__init30.call(this);this._format=t;this.dimension=r;this.access=n;this._membership=a;this[_chunkUMHCZDPAcjs.b]=this,this[_chunkUMHCZDPAcjs.a]={},this.texelDataType=at[this._format],_chunkUMHCZDPAcjs.j.call(void 0, this,a.key)}__init30() {this.resourceType="texture-storage-view"}"~resolve"(t){let r=t.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this)),n=t.allocateLayoutEntry(this._membership.layout),a=`texture_storage_${Et[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${this._format}, ${oa[this.access]}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}}, _class14),Gr= (_class15 =class{constructor(t,r){;_class15.prototype.__init31.call(this);this._props=t;this._texture=r;this[_chunkUMHCZDPAcjs.b]=this,this[_chunkUMHCZDPAcjs.a]={unwrap:()=>(this._view||(this._view=this._texture[_chunkUMHCZDPAcjs.a].unwrap().createView({label:`${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))} - View`,...this._props})),this._view)},this[_chunkUMHCZDPAcjs.d]=r,this.dimension=_nullishCoalesce(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _65 => _65.dimension]), () => (r.props.dimension)), () => ("2d")),this._format=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _66 => _66.format]), () => (r.props.format)),this.channelDataType=ta[this._format]}__init31() {this.resourceType="texture-sampled-view"}$name(t){return this._texture.$name(t),this}"~resolve"(t){let r=t.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this)),n=(_nullishCoalesce(this._texture.props.sampleCount, () => (1)))>1,{group:a,binding:o}=t.allocateFixedEntry({texture:ra[this.channelDataType.type],viewDimension:this.dimension,multisampled:n},this),i=n?"texture_multisampled_2d":`texture_${Et[this.dimension]}`;return t.addDeclaration(`@group(${a}) @binding(${o}) var ${r}: ${i}<${t.resolve(this.channelDataType)}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}}, _class15),Vt= (_class16 =class{constructor(t,r,n,a){;_class16.prototype.__init32.call(this);this.dimension=r;this._multisampled=n;this._membership=a;this[_chunkUMHCZDPAcjs.b]=this,this[_chunkUMHCZDPAcjs.a]={},_chunkUMHCZDPAcjs.j.call(void 0, this,a.key),this.channelDataType=na[t]}__init32() {this.resourceType="texture-sampled-view"}"~resolve"(t){let r=t.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this)),n=t.allocateLayoutEntry(this._membership.layout),a=this._multisampled?"texture_multisampled_2d":`texture_${Et[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${t.resolve(this.channelDataType)}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}}, _class16);function Vr(e){return!!_optionalChain([e, 'optionalAccess', _67 => _67.usableAsSampled])}function so(e){return!!_optionalChain([e, 'optionalAccess', _68 => _68.usableAsRender])}var _t=class e extends Error{constructor(t){super(`Resource '${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, t), () => ("<unnamed>"))}' cannot be bound as 'sampled'. Use .$usage('sampled') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function kt(e){return new _r(e)}function Lt(e){return!!e&&e.resourceType==="bind-group-layout"}function kr(e){return!!e&&e.resourceType==="bind-group"}var Er=class e extends Error{constructor(t,r){super(`Bind group '${_nullishCoalesce(t, () => ("<unnamed>"))}' is missing a required binding '${r}'`),Object.setPrototypeOf(this,e.prototype)}},ia=["compute"],ke=["compute","vertex","fragment"],_r= (_class17 =class{constructor(t){;_class17.prototype.__init33.call(this);_class17.prototype.__init34.call(this);_class17.prototype.__init35.call(this);_class17.prototype.__init36.call(this);_class17.prototype.__init37.call(this);this.entries=t;let r=0;for(let[n,a]of Object.entries(t)){if(a===null){r++;continue}let o={layout:this,key:n,idx:r};if("uniform"in a&&(this.bound[n]=new et("uniform",a.uniform,o)),"storage"in a){let i="type"in a.storage?a.storage:a.storage(0);this.bound[n]=new et(_nullishCoalesce(a.access, () => ("readonly")),i,o)}"texture"in a&&(this.bound[n]=new Vt(a.texture,_nullishCoalesce(a.viewDimension, () => ("2d")),_nullishCoalesce(a.multisampled, () => (!1)),o)),"storageTexture"in a&&(this.bound[n]=new Gt(a.storageTexture,_nullishCoalesce(a.viewDimension, () => ("2d")),_nullishCoalesce(a.access, () => ("writeonly")),o)),"externalTexture"in a&&(this.bound[n]=new $t(o)),"sampler"in a&&(a.sampler==="comparison"?this.bound[n]=new Rt(o):this.bound[n]=new Ct(o)),"texture"in a||"storageTexture"in a||"externalTexture"in a||"sampler"in a?this.value[n]=this.bound[n]:Object.defineProperty(this.value,n,{get:()=>this.bound[n].value}),r++}}__init33() {this[_chunkUMHCZDPAcjs.a]=!0}__init34() {this.resourceType="bind-group-layout"}__init35() {this.bound={}}__init36() {this.value={}}__init37() {this.$=this.value}toString(){return`bindGroupLayout:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}get index(){return this._index}$name(t){return _chunkUMHCZDPAcjs.j.call(void 0, this,t),this}$idx(t){return this._index=t,this}unwrap(t){return t.device.createBindGroupLayout({label:_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>")),entries:Object.values(this.entries).map((n,a)=>{if(n===null)return null;let o=n.visibility,i={binding:a,visibility:0};if("uniform"in n)o=_nullishCoalesce(o, () => (ke)),i.buffer={type:"uniform"};else if("storage"in n)o=_nullishCoalesce(o, () => ((n.access==="mutable"?ia:ke))),i.buffer={type:n.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in n)o=_nullishCoalesce(o, () => (ke)),i.sampler={type:n.sampler};else if("texture"in n)o=_nullishCoalesce(o, () => (ke)),i.texture={sampleType:n.texture,viewDimension:_nullishCoalesce(n.viewDimension, () => ("2d")),multisampled:_nullishCoalesce(n.multisampled, () => (!1))};else if("storageTexture"in n){let s=_nullishCoalesce(n.access, () => ("writeonly"));o=_nullishCoalesce(o, () => ((s==="readonly"?ke:ia))),i.storageTexture={format:n.storageTexture,access:{mutable:"read-write",readonly:"read-only",writeonly:"write-only"}[s],viewDimension:_nullishCoalesce(n.viewDimension, () => ("2d"))}}else"externalTexture"in n&&(o=_nullishCoalesce(o, () => (ke)),i.externalTexture={});return _optionalChain([o, 'optionalAccess', _69 => _69.includes, 'call', _70 => _70("compute")])&&(i.visibility|=GPUShaderStage.COMPUTE),_optionalChain([o, 'optionalAccess', _71 => _71.includes, 'call', _72 => _72("vertex")])&&(i.visibility|=GPUShaderStage.VERTEX),_optionalChain([o, 'optionalAccess', _73 => _73.includes, 'call', _74 => _74("fragment")])&&(i.visibility|=GPUShaderStage.FRAGMENT),i}).filter(n=>n!==null)})}}, _class17),Le= (_class18 =class{constructor(t,r){;_class18.prototype.__init38.call(this);this.layout=t;this.entries=r;for(let n of Object.keys(t.entries))if(t.entries[n]!==null&&!(n in r))throw new Er(_chunkUMHCZDPAcjs.i.call(void 0, t),n)}__init38() {this.resourceType="bind-group"}unwrap(t){return t.device.createBindGroup({label:_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this.layout), () => ("<unnamed>")),layout:t.unwrap(this.layout),entries:Object.entries(this.layout.entries).map(([n,a],o)=>{if(a===null)return null;let i=this.entries[n];if(i===void 0)throw new Error(`'${n}' is a resource required to populate bind group layout '${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this.layout), () => ("<unnamed>"))}'.`);if("uniform"in a){let s;if(de(i)){if(!Bt(i))throw new (0, _chunkUMHCZDPAcjs.p)(i);s={buffer:t.unwrap(i)}}else s={buffer:i};return{binding:o,resource:s}}if("storage"in a){let s;if(de(i)){if(!ve(i))throw new Xe(i);s={buffer:t.unwrap(i)}}else s={buffer:i};return{binding:o,resource:s}}if("texture"in a){let s;if(Z(i)){if(!Vr(i))throw new _t(i);s=t.unwrap(i.createView("sampled"))}else it(i)?s=t.unwrap(i):s=i;return{binding:o,resource:s}}if("storageTexture"in a){let s;if(Z(i)){if(!ve(i))throw new Xe(i);a.access==="readonly"?s=t.unwrap(i.createView("readonly")):a.access==="mutable"?s=t.unwrap(i.createView("mutable")):s=t.unwrap(i.createView("writeonly"))}else ot(i)?s=t.unwrap(i):s=i;return{binding:o,resource:s}}if("sampler"in a)return rt(i)||nt(i)?{binding:o,resource:t.unwrap(i)}:{binding:o,resource:i};if("externalTexture"in a)return{binding:o,resource:i};throw new Error(`Malformed bind group entry: ${i} (${JSON.stringify(i)})`)}).filter(n=>n!==null)})}}, _class18);var{NodeTypeCatalog:D}=uo,po=["==","!=","<","<=",">",">=","<<",">>","+","-","*","/","%","|","^","&","&&","||"],lo=["&&","||","==","!=","<","<=",">",">="];function sa(e,t,r){return r?lo.includes(t)?_chunkUMHCZDPAcjs.la:t==="="?r:e:t==="!"||t==="~"?_chunkUMHCZDPAcjs.la:e}function mo(e){throw new Error(`'${JSON.stringify(e)}' was not handled by the WGSL generator.`)}function ua(e,[t,r]){e.pushBlockScope();try{return`${e.indent()}{
20
+ ${r.map(n=>De(e,n)).join(`
20
21
  `)}
21
- ${e.dedent()}}`}finally{e.popBlockScope()}}function Ma(e,t,r){return e.defineVariable(t,r)}function Ir(e,t){let r=e.getById(t);if(!r)throw new Error(`Identifier ${t} not found`);return r}function $(e,t){if(typeof t=="string")return Ir(e,t);if(typeof t=="boolean")return _chunkV4CSEIB2cjs.ba.call(void 0, t?"true":"false",_chunkV4CSEIB2cjs.ha);if(t[0]===F.logicalExpr||t[0]===F.binaryExpr||t[0]===F.assignmentExpr){let[r,n,a,o]=t,i=$(e,n),s=$(e,o),l=W(e,[i,s]),[u,d]=l||[i,s],g=e.resolve(u.value),c=e.resolve(d.value),y=jn(u.dataType,a,d.dataType);return _chunkV4CSEIB2cjs.ba.call(void 0, Ga.includes(a)?`(${g} ${a} ${c})`:`${g} ${a} ${c}`,y)}if(t[0]===F.postUpdate){let[r,n,a]=t,o=$(e,a),i=e.resolve(o.value);return _chunkV4CSEIB2cjs.ba.call(void 0, `${i}${n}`,o.dataType)}if(t[0]===F.unaryExpr){let[r,n,a]=t,o=$(e,a),i=e.resolve(o.value),s=jn(o.dataType,n);return _chunkV4CSEIB2cjs.ba.call(void 0, `${n}${i}`,s)}if(t[0]===F.memberAccess){let[r,n,a]=t,o=$(e,n);if(o.dataType.type==="unknown"){let i=o.value[a];return fe(i)}return _chunkV4CSEIB2cjs.L.call(void 0, o.dataType)?_chunkV4CSEIB2cjs.ba.call(void 0, `(*${e.resolve(o.value)}).${a}`,je(o.dataType.inner,a)):_chunkV4CSEIB2cjs.J.call(void 0, o.dataType)&&a==="length"?o.dataType.elementCount===0?_chunkV4CSEIB2cjs.ba.call(void 0, `arrayLength(&${e.resolve(o.value)})`,_chunkV4CSEIB2cjs.ia):_chunkV4CSEIB2cjs.ba.call(void 0, String(o.dataType.elementCount),_chunkV4CSEIB2cjs.fa):_chunkV4CSEIB2cjs.G.call(void 0, o.dataType)&&a==="columns"?_chunkV4CSEIB2cjs.ba.call(void 0, o.value,o.dataType):_chunkV4CSEIB2cjs.C.call(void 0, o.dataType)&&_chunkV4CSEIB2cjs.z.call(void 0, o.value)?fe(o.value[a]):_chunkV4CSEIB2cjs.ba.call(void 0, `${e.resolve(o.value)}.${a}`,je(o.dataType,a))}if(t[0]===F.indexAccess){let[r,n,a]=t,o=$(e,n),i=$(e,a),s=e.resolve(o.value),l=e.resolve(i.value);if(o.dataType.type==="unknown"){if(Array.isArray(a)&&a[0]===F.numericLiteral)return fe(o.value[a[1]]);throw new Error(`Cannot index value ${s} of unknown type with index ${l}`)}return _chunkV4CSEIB2cjs.L.call(void 0, o.dataType)?_chunkV4CSEIB2cjs.ba.call(void 0, `(*${s})[${l}]`,Qt(o.dataType.inner)):_chunkV4CSEIB2cjs.ba.call(void 0, `${s}[${l}]`,_chunkV4CSEIB2cjs.$.call(void 0, o.dataType)?Qt(o.dataType):_chunkV4CSEIB2cjs.aa)}if(t[0]===F.numericLiteral){let r=Xt(t[1]);if(!r)throw new Error(`Invalid numeric literal ${t[1]}`);return r}if(t[0]===F.call){let[r,n,a]=t,o=$(e,n);e.callStack.push(o.value);let s=a.map(c=>$(e,c)).map(c=>_chunkV4CSEIB2cjs.ba.call(void 0, e.resolve(c.value),c.dataType)),l=s.map(c=>c.value);if(e.callStack.pop(),s.forEach((c,y)=>{if(c.dataType===_chunkV4CSEIB2cjs.aa)throw new Error(`Tried to pass '${c.value}' of unknown type as argument #${y} to '${typeof o.value=="string"?o.value:_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, o.value), () => ("<unnamed>"))}()'`)}),typeof o.value=="string")return _chunkV4CSEIB2cjs.ba.call(void 0, `${o.value}(${l.join(", ")})`,o.dataType);if(_chunkV4CSEIB2cjs.K.call(void 0, o.value)){let c=e.resolve(o.value);return _chunkV4CSEIB2cjs.ba.call(void 0, `${c}(${l.join(", ")})`,o.value)}if(!ar(o.value))throw new Error(`Function ${String(o.value)} has not been created using TypeGPU APIs. Did you mean to wrap the function with tgpu.fn(args, return)(...) ?`);let u=_optionalChain([o, 'access', _73 => _73.value, 'access', _74 => _74[_chunkV4CSEIB2cjs.a], 'optionalAccess', _75 => _75.argTypes]),d;!u||u==="keep"?d=s:u==="coerce"?d=_nullishCoalesce(W(e,s), () => (s)):d=(Array.isArray(u)?u:u(...s)).map((y,x)=>[y,s[x]]).map(([y,x])=>{if(x.dataType.type==="unknown")return console.warn(`Internal error: unknown type when generating expression: ${t}`),x;let w=_optionalChain([W, 'call', _76 => _76(e,[x],[y]), 'optionalAccess', _77 => _77[0]]);if(!w)throw new Error(`Cannot convert ${e.resolve(x.dataType)} to ${e.resolve(y)}`);return w});let g=o.value(...d);return _chunkV4CSEIB2cjs.ba.call(void 0, e.resolve(g.value),g.dataType)}if(t[0]===F.objectExpr){let r=t[1],n=e.callStack[e.callStack.length-1];if(_chunkV4CSEIB2cjs.K.call(void 0, n)){let a=Object.keys(n.propTypes),o=Object.fromEntries(a.map(s=>{let l=r[s];if(l===void 0)throw new Error(`Missing property ${s} in object literal for struct ${n}`);return[s,$(e,l)]})),i=tr(e,n,o);return _chunkV4CSEIB2cjs.ba.call(void 0, i.map(s=>e.resolve(s.value)).join(", "),n)}if(ar(n)){let a=_optionalChain([n, 'access', _78 => _78[_chunkV4CSEIB2cjs.a], 'optionalAccess', _79 => _79.argTypes]);if(typeof a=="object"&&a!==null){let o=Object.keys(a),i={};for(let s of o){let l=r[s];if(l===void 0)throw new Error(`Missing property ${s} in object literal for function ${n}`);let u=$(e,l),d=a[s],g=W(e,[u],[d]);i[s]=_nullishCoalesce(_optionalChain([g, 'optionalAccess', _80 => _80[0]]), () => (u))}return _chunkV4CSEIB2cjs.ba.call(void 0, i,_chunkV4CSEIB2cjs.aa)}}throw new Error("Object expressions are only allowed as return values of functions or as arguments to structs.")}if(t[0]===F.arrayExpr){let[r,n]=t,a=n.map(g=>$(e,g));if(a.length===0)throw new Error("Cannot create empty array literal.");let o=W(e,a);if(!o)throw new Error("The given values cannot be automatically converted to a common type. Consider explicitly casting them.");let i=_optionalChain([o, 'access', _81 => _81[0], 'optionalAccess', _82 => _82.dataType]),s=i.type==="abstractFloat"?_chunkV4CSEIB2cjs.ka:i.type==="abstractInt"?_chunkV4CSEIB2cjs.ja:i,u=`array<${e.resolve(s)}, ${a.length}>`,d=o.map(g=>e.resolve(g.value));return _chunkV4CSEIB2cjs.ba.call(void 0, `${u}( ${d.join(", ")} )`,_chunk7ACLI4JYcjs.X.call(void 0, s,a.length))}if(t[0]===F.stringLiteral)throw new Error("Cannot use string literals in TGSL.");if(t[0]===F.preUpdate)throw new Error("Cannot use pre-updates in TGSL.");Oa(t)}function Pt(e){return typeof e!="object"||e[0]!==F.block?[F.block,[e]]:e}function xe(e,t){if(typeof t=="string")return`${e.pre}${e.resolve(Ir(e,t).value)};`;if(typeof t=="boolean")return`${e.pre}${t?"true":"false"};`;if(t[0]===F.return){let r=t[1],n=r!==void 0?e.resolve($(e,r).value):void 0;if(_chunkV4CSEIB2cjs.K.call(void 0, e.callStack[e.callStack.length-1])&&typeof r=="object"&&r[0]===F.objectExpr){let a=e.resolve(e.callStack[e.callStack.length-1]);return`${e.pre}return ${a}(${n});`}return n?`${e.pre}return ${n};`:`${e.pre}return;`}if(t[0]===F.if){let[r,n,a,o]=t,i=$(e,n),s=i,l=W(e,[i],[_chunkV4CSEIB2cjs.ha]);_optionalChain([l, 'optionalAccess', _83 => _83[0]])&&([s]=l);let u=e.resolve(s.value);e.indent();let d=xe(e,Pt(a));e.dedent(),e.indent();let g=o?xe(e,Pt(o)):void 0;return e.dedent(),g?`${e.pre}if (${u})
22
- ${d}
22
+ ${e.dedent()}}`}finally{e.popBlockScope()}}function fo(e,t,r){return e.defineVariable(t,r)}function Lr(e,t){let r=e.getById(t);if(!r)throw new Error(`Identifier ${t} not found`);return r}function G(e,t){if(typeof t=="string")return Lr(e,t);if(typeof t=="boolean")return _chunkUMHCZDPAcjs.fa.call(void 0, t?"true":"false",_chunkUMHCZDPAcjs.la);if(t[0]===D.logicalExpr||t[0]===D.binaryExpr||t[0]===D.assignmentExpr){let[r,n,a,o]=t,i=G(e,n),s=G(e,o),p=t[0]===D.assignmentExpr?[i.dataType]:[],u=z(e,[i,s],p),[f,m]=u||[i,s],g=e.resolve(f.value),y=e.resolve(m.value),x=sa(f.dataType,a,m.dataType);return _chunkUMHCZDPAcjs.fa.call(void 0, po.includes(a)?`(${g} ${a} ${y})`:`${g} ${a} ${y}`,x)}if(t[0]===D.postUpdate){let[r,n,a]=t,o=G(e,a),i=e.resolve(o.value);return _chunkUMHCZDPAcjs.fa.call(void 0, `${i}${n}`,o.dataType)}if(t[0]===D.unaryExpr){let[r,n,a]=t,o=G(e,a),i=e.resolve(o.value),s=sa(o.dataType,n);return _chunkUMHCZDPAcjs.fa.call(void 0, `${n}${i}`,s)}if(t[0]===D.memberAccess){let[r,n,a]=t,o=G(e,n);if(o.dataType.type==="unknown"){let i=o.value[a];return he(i)}return _chunkUMHCZDPAcjs.P.call(void 0, o.dataType)?_chunkUMHCZDPAcjs.fa.call(void 0, `(*${e.resolve(o.value)}).${a}`,Qe(o.dataType.inner,a)):_chunkUMHCZDPAcjs.N.call(void 0, o.dataType)&&a==="length"?o.dataType.elementCount===0?_chunkUMHCZDPAcjs.fa.call(void 0, `arrayLength(&${e.resolve(o.value)})`,_chunkUMHCZDPAcjs.ma):_chunkUMHCZDPAcjs.fa.call(void 0, String(o.dataType.elementCount),_chunkUMHCZDPAcjs.ja):_chunkUMHCZDPAcjs.K.call(void 0, o.dataType)&&a==="columns"?_chunkUMHCZDPAcjs.fa.call(void 0, o.value,o.dataType):_chunkUMHCZDPAcjs.G.call(void 0, o.dataType)&&_chunkUMHCZDPAcjs.D.call(void 0, o.value)?he(o.value[a]):_chunkUMHCZDPAcjs.fa.call(void 0, `${e.resolve(o.value)}.${a}`,Qe(o.dataType,a))}if(t[0]===D.indexAccess){let[r,n,a]=t,o=G(e,n),i=G(e,a),s=e.resolve(o.value),p=e.resolve(i.value);if(o.dataType.type==="unknown"){if(Array.isArray(a)&&a[0]===D.numericLiteral)return he(o.value[a[1]]);throw new Error(`Cannot index value ${s} of unknown type with index ${p}`)}return _chunkUMHCZDPAcjs.P.call(void 0, o.dataType)?_chunkUMHCZDPAcjs.fa.call(void 0, `(*${s})[${p}]`,pr(o.dataType.inner)):_chunkUMHCZDPAcjs.fa.call(void 0, `${s}[${p}]`,_chunkUMHCZDPAcjs.da.call(void 0, o.dataType)?pr(o.dataType):_chunkUMHCZDPAcjs.ea)}if(t[0]===D.numericLiteral){let r=lr(t[1]);if(!r)throw new Error(`Invalid numeric literal ${t[1]}`);return r}if(t[0]===D.call){let[r,n,a]=t,o=G(e,n);e.callStack.push(o.value);let s=a.map(m=>G(e,m)).map(m=>_chunkUMHCZDPAcjs.fa.call(void 0, e.resolve(m.value),m.dataType)),p=s.map(m=>m.value);if(e.callStack.pop(),s.forEach((m,g)=>{if(m.dataType===_chunkUMHCZDPAcjs.ea)throw new Error(`Tried to pass '${m.value}' of unknown type as argument #${g} to '${typeof o.value=="string"?o.value:_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, o.value), () => ("<unnamed>"))}()'`)}),typeof o.value=="string")return _chunkUMHCZDPAcjs.fa.call(void 0, `${o.value}(${p.join(", ")})`,o.dataType);if(_chunkUMHCZDPAcjs.O.call(void 0, o.value)){let m=e.resolve(o.value);return _chunkUMHCZDPAcjs.fa.call(void 0, `${m}(${p.join(", ")})`,o.value)}if(!yr(o.value))throw new Error(`Function ${String(o.value)} ${_chunkUMHCZDPAcjs.i.call(void 0, o.value)} has not been created using TypeGPU APIs. Did you mean to wrap the function with tgpu.fn(args, return)(...) ?`);let u=_optionalChain([o, 'access', _75 => _75.value, 'access', _76 => _76[_chunkUMHCZDPAcjs.a], 'optionalAccess', _77 => _77.argTypes]),f;try{!u||u==="keep"?f=s:u==="coerce"?f=_nullishCoalesce(z(e,s), () => (s)):f=(Array.isArray(u)?u:u(...s)).map((y,x)=>[y,s[x]]).map(([y,x])=>{if(x.dataType.type==="unknown")return console.warn(`Internal error: unknown type when generating expression: ${t}`),x;let b=_optionalChain([z, 'call', _78 => _78(e,[x],[y]), 'optionalAccess', _79 => _79[0]]);if(!b)throw new (0, _chunkUMHCZDPAcjs.n)(`Cannot convert argument of type '${x.dataType.type}' to '${y.type}' for function ${_chunkUMHCZDPAcjs.i.call(void 0, o.value)}`,[{function:o.value,callStack:e.callStack,error:`Cannot convert argument of type '${x.dataType.type}' to '${y.type}'`,toString:()=>_chunkUMHCZDPAcjs.i.call(void 0, o.value)}]);return b});let m=o.value(...f);return _chunkUMHCZDPAcjs.fa.call(void 0, e.resolve(m.value),m.dataType)}catch(m){throw new (0, _chunkUMHCZDPAcjs.n)(m,[{toString:()=>_chunkUMHCZDPAcjs.i.call(void 0, o.value)}])}}if(t[0]===D.objectExpr){let r=t[1],n=e.callStack[e.callStack.length-1];if(_chunkUMHCZDPAcjs.O.call(void 0, n)){let a=Object.keys(n.propTypes),o=Object.fromEntries(a.map(s=>{let p=r[s];if(p===void 0)throw new Error(`Missing property ${s} in object literal for struct ${n}`);return[s,G(e,p)]})),i=fr(e,n,o);return _chunkUMHCZDPAcjs.fa.call(void 0, i.map(s=>e.resolve(s.value)).join(", "),n)}if(yr(n)){let a=_optionalChain([n, 'access', _80 => _80[_chunkUMHCZDPAcjs.a], 'optionalAccess', _81 => _81.argTypes]);if(typeof a=="object"&&a!==null){let o=Object.keys(a),i={};for(let s of o){let p=r[s];if(p===void 0)throw new Error(`Missing property ${s} in object literal for function ${n}`);let u=G(e,p),f=a[s],m=z(e,[u],[f]);i[s]=_nullishCoalesce(_optionalChain([m, 'optionalAccess', _82 => _82[0]]), () => (u))}return _chunkUMHCZDPAcjs.fa.call(void 0, i,_chunkUMHCZDPAcjs.ea)}}throw new Error("Object expressions are only allowed as return values of functions or as arguments to structs.")}if(t[0]===D.arrayExpr){let[r,n]=t,a=n.map(m=>G(e,m));if(a.length===0)throw new Error("Cannot create empty array literal.");let o=z(e,a);if(!o)throw new Error("The given values cannot be automatically converted to a common type. Consider explicitly casting them.");let i=_optionalChain([o, 'access', _83 => _83[0], 'optionalAccess', _84 => _84.dataType]),s=i.type==="abstractFloat"?_chunkUMHCZDPAcjs.pa:i.type==="abstractInt"?_chunkUMHCZDPAcjs.oa:i,u=`array<${e.resolve(s)}, ${a.length}>`,f=o.map(m=>e.resolve(m.value));return _chunkUMHCZDPAcjs.fa.call(void 0, `${u}( ${f.join(", ")} )`,_chunkRC26P3MPcjs.X.call(void 0, s,a.length))}if(t[0]===D.stringLiteral)throw new Error("Cannot use string literals in TGSL.");if(t[0]===D.preUpdate)throw new Error("Cannot use pre-updates in TGSL.");mo(t)}function Ot(e){return typeof e!="object"||e[0]!==D.block?[D.block,[e]]:e}function De(e,t){if(typeof t=="string")return`${e.pre}${e.resolve(Lr(e,t).value)};`;if(typeof t=="boolean")return`${e.pre}${t?"true":"false"};`;if(t[0]===D.return){let r=t[1],n=r!==void 0?e.resolve(G(e,r).value):void 0;if(_chunkUMHCZDPAcjs.O.call(void 0, e.callStack[e.callStack.length-1])&&typeof r=="object"&&r[0]===D.objectExpr){let a=e.resolve(e.callStack[e.callStack.length-1]);return`${e.pre}return ${a}(${n});`}return n?`${e.pre}return ${n};`:`${e.pre}return;`}if(t[0]===D.if){let[r,n,a,o]=t,i=G(e,n),s=i,p=z(e,[i],[_chunkUMHCZDPAcjs.la]);_optionalChain([p, 'optionalAccess', _85 => _85[0]])&&([s]=p);let u=e.resolve(s.value);e.indent();let f=De(e,Ot(a));e.dedent(),e.indent();let m=o?De(e,Ot(o)):void 0;return e.dedent(),m?`${e.pre}if (${u})
23
+ ${f}
23
24
  ${e.pre}else
24
- ${g}`:`${e.pre}if (${u})
25
- ${d}`}if(t[0]===F.let||t[0]===F.const){let[r,n,a]=t,o=a!==void 0?$(e,a):void 0;if(!o)throw new Error(`Cannot create variable '${n}' without an initial value.`);if(_chunkV4CSEIB2cjs.U.call(void 0, o.dataType))throw new Error(`Cannot create variable '${n}' with loose data type.`);Ma(e,n,er(o.dataType));let i=e.resolve(Ir(e,n).value);if(typeof a=="object"&&a[0]===F.objectExpr&&_chunkV4CSEIB2cjs.K.call(void 0, e.callStack[e.callStack.length-1])){let s=e.callStack[e.callStack.length-1],l=a[1],u={};for(let[c,y]of Object.entries(l)){if(!y)throw new Error(`Missing property ${c} in object literal`);u[c]=$(e,y)}let d=tr(e,s,u),g=e.resolve(s);return`${e.pre}var ${i} = ${g}(${d.map(c=>e.resolve(c.value)).join(", ")});`}return`${e.pre}var ${i} = ${e.resolve(o.value)};`}if(t[0]===F.block)return zn(e,t);if(t[0]===F.for){let[r,n,a,o,i]=t,s=n?xe(e,n):void 0,l=s?s.slice(0,-1):"",u=a?$(e,a):void 0,d=u;if(u){let w=W(e,[u],[_chunkV4CSEIB2cjs.ha]);_optionalChain([w, 'optionalAccess', _84 => _84[0]])&&([d]=w)}let g=d?e.resolve(d.value):"",c=o?xe(e,o):void 0,y=c?c.slice(0,-1):"";e.indent();let x=xe(e,Pt(i));return e.dedent(),`${e.pre}for (${l}; ${g}; ${y})
26
- ${x}`}if(t[0]===F.while){let[r,n,a]=t,o=$(e,n),i=o;if(o){let u=W(e,[o],[_chunkV4CSEIB2cjs.ha]);_optionalChain([u, 'optionalAccess', _85 => _85[0]])&&([i]=u)}let s=e.resolve(i.value);e.indent();let l=xe(e,Pt(a));return e.dedent(),`${e.pre}while (${s})
27
- ${l}`}return t[0]===F.continue?`${e.pre}continue;`:t[0]===F.break?`${e.pre}break;`:`${e.pre}${e.resolve($(e,t).value)};`}function Kn(e,t){return zn(e,t)}var Hn="#CATCHALL#",Ar= (_class19 =class{constructor() { _class19.prototype.__init36.call(this);_class19.prototype.__init37.call(this); }__init36() {this._stack=[]}__init37() {this._itemDepth=0}get itemDepth(){return this._itemDepth}get topItem(){let t=this._stack[this._stack.length-1];if(!t||t.type!=="item")throw new Error("Internal error, expected item layer to be on top.");return t}pushItem(){this._itemDepth++,this._stack.push({type:"item",usedSlots:new Set})}popItem(){this.pop("item")}pushSlotBindings(t){this._stack.push({type:"slotBinding",bindingMap:new WeakMap(t)})}popSlotBindings(){this.pop("slotBinding")}pushFunctionScope(t,r,n,a){this._stack.push({type:"functionScope",args:t,argAliases:r,returnType:n,externalMap:a})}popFunctionScope(){this.pop("functionScope")}pushBlockScope(){this._stack.push({type:"blockScope",declarations:new Map})}popBlockScope(){this.pop("blockScope")}pop(t){let r=this._stack[this._stack.length-1];if(!r||t&&r.type!==t)throw new Error(`Internal error, expected a ${t} layer to be on top.`);this._stack.pop(),t==="item"&&this._itemDepth--}readSlot(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if(_optionalChain([n, 'optionalAccess', _86 => _86.type])==="item")n.usedSlots.add(t);else if(_optionalChain([n, 'optionalAccess', _87 => _87.type])==="slotBinding"){let a=n.bindingMap.get(t);if(a!==void 0)return a}else if(!(_optionalChain([n, 'optionalAccess', _88 => _88.type])==="functionScope"||_optionalChain([n, 'optionalAccess', _89 => _89.type])==="blockScope"))throw new Error("Unknown layer type.")}return t.defaultValue}getSnippetById(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if(_optionalChain([n, 'optionalAccess', _90 => _90.type])==="functionScope"){let a=n.args.find(i=>i.value===t);if(a!==void 0)return a;if(n.argAliases[t])return n.argAliases[t];let o=n.externalMap[t];return o!=null?fe(o):void 0}if(_optionalChain([n, 'optionalAccess', _91 => _91.type])==="blockScope"){let a=n.declarations.get(t);if(a!==void 0)return _chunkV4CSEIB2cjs.ba.call(void 0, t,a)}}}defineBlockVariable(t,r){if(r.type==="unknown")throw Error(`Tried to define variable '${t}' of unknown type`);for(let n=this._stack.length-1;n>=0;--n){let a=this._stack[n];if(_optionalChain([a, 'optionalAccess', _92 => _92.type])==="blockScope")return a.declarations.set(t,r),_chunkV4CSEIB2cjs.ba.call(void 0, t,r)}throw new Error("No block scope found to define a variable in.")}}, _class19),Ct=[""," "," "," "," "," "," "," "," "],Ur=Ct.length-1,Br= (_class20 =class{constructor() { _class20.prototype.__init38.call(this); }__init38() {this.identLevel=0}get pre(){return _nullishCoalesce(Ct[this.identLevel], () => (Ct[Ur].repeat(this.identLevel/Ur)+Ct[this.identLevel%Ur]))}indent(){let t=this.pre;return this.identLevel++,t}dedent(){return this.identLevel--,this.pre}}, _class20),Rr= (_class21 =class{__init39() {this._memoizedResolves=new WeakMap}__init40() {this._memoizedDerived=new WeakMap}__init41() {this._indentController=new Br}__init42() {this._itemStateStack=new Ar}__init43() {this._declarations=[]}__init44() {this[_chunkV4CSEIB2cjs.a]={itemStateStack:this._itemStateStack}}__init45() {this.bindGroupLayoutsToPlaceholderMap=new Map}__init46() {this._nextFreeLayoutPlaceholderIdx=0}__init47() {this.fixedBindings=[]}__init48() {this.callStack=[]}constructor(t){;_class21.prototype.__init39.call(this);_class21.prototype.__init40.call(this);_class21.prototype.__init41.call(this);_class21.prototype.__init42.call(this);_class21.prototype.__init43.call(this);_class21.prototype.__init44.call(this);_class21.prototype.__init45.call(this);_class21.prototype.__init46.call(this);_class21.prototype.__init47.call(this);_class21.prototype.__init48.call(this);this.names=t.names,this._jitTranspiler=t.jitTranspiler}get pre(){return this._indentController.pre}indent(){return this._indentController.indent()}dedent(){return this._indentController.dedent()}getById(t){let r=this._itemStateStack.getSnippetById(t);return r===void 0?null:r}defineVariable(t,r){return this._itemStateStack.defineBlockVariable(t,r)}pushBlockScope(){this._itemStateStack.pushBlockScope()}popBlockScope(){this._itemStateStack.popBlockScope()}transpileFn(t){if(!this._jitTranspiler)throw new Error("Tried to execute a tgpu.fn function without providing a JIT transpiler, or transpiling at build time.");return this._jitTranspiler.transpileFn(t)}fnToWgsl(t){this._itemStateStack.pushFunctionScope(t.args,t.argAliases,t.returnType,t.externalMap);try{return{head:Wa(this,t.args,t.returnType),body:Kn(this,t.body)}}finally{this._itemStateStack.popFunctionScope()}}addDeclaration(t){this._declarations.push(t)}allocateLayoutEntry(t){let r=this.bindGroupLayoutsToPlaceholderMap,n=r.get(t);return n||(n=`#BIND_GROUP_LAYOUT_${this._nextFreeLayoutPlaceholderIdx++}#`,r.set(t,n)),n}allocateFixedEntry(t,r){let n=this.fixedBindings.length;return this.fixedBindings.push({layoutEntry:t,resource:r}),{group:Hn,binding:n}}readSlot(t){let r=this._itemStateStack.readSlot(t);if(r===void 0)throw new (0, _chunkV4CSEIB2cjs.j)(t);return r}withSlots(t,r){this._itemStateStack.pushSlotBindings(t);try{return r()}finally{this._itemStateStack.popSlotBindings()}}unwrap(t){if(Ke(t))return this.withSlots(t["~providing"].pairs,()=>this.unwrap(t["~providing"].inner));let r=t;for(;;)if(Be(r))r=this.readSlot(r);else if(Re(r))r=this._getOrCompute(r);else break;return r}_getOrCompute(t){let r=_nullishCoalesce(this._memoizedDerived.get(t), () => ([]));this._itemStateStack.pushItem();try{for(let o of r)if([...o.slotToValueMap.entries()].every(([s,l])=>s.areEqual(this._itemStateStack.readSlot(s),l)))return o.result;_chunkV4CSEIB2cjs.r.call(void 0, _chunkV4CSEIB2cjs.o.CPU);let n;try{n=t["~compute"]()}finally{_chunkV4CSEIB2cjs.s.call(void 0, _chunkV4CSEIB2cjs.o.CPU)}let a=new Map;for(let o of this._itemStateStack.topItem.usedSlots)a.set(o,this._itemStateStack.readSlot(o));return r.push({slotToValueMap:a,result:n}),this._memoizedDerived.set(t,r),n}catch(n){throw n instanceof _chunkV4CSEIB2cjs.i?n.appendToTrace(t):new (0, _chunkV4CSEIB2cjs.i)(n,[t])}finally{this._itemStateStack.popItem()}}_getOrInstantiate(t){let r=_nullishCoalesce(this._memoizedResolves.get(t), () => ([]));this._itemStateStack.pushItem();try{for(let o of r)if([...o.slotToValueMap.entries()].every(([s,l])=>s.areEqual(this._itemStateStack.readSlot(s),l)))return o.result;let n;_chunkV4CSEIB2cjs.$.call(void 0, t)?n=ur(this,t):Re(t)||Be(t)?n=this.resolve(this.unwrap(t)):nr(t)?n=t["~resolve"](this):n=this.resolveValue(t);let a=new Map;for(let o of this._itemStateStack.topItem.usedSlots)a.set(o,this._itemStateStack.readSlot(o));return r.push({slotToValueMap:a,result:n}),this._memoizedResolves.set(t,r),n}catch(n){throw n instanceof _chunkV4CSEIB2cjs.i?n.appendToTrace(t):new (0, _chunkV4CSEIB2cjs.i)(n,[t])}finally{this._itemStateStack.popItem()}}resolve(t){if(Ke(t))return this.withSlots(t["~providing"].pairs,()=>this.resolve(t["~providing"].inner));if(t&&typeof t=="object"||typeof t=="function"){if(this._itemStateStack.itemDepth===0)try{_chunkV4CSEIB2cjs.r.call(void 0, _chunkV4CSEIB2cjs.o.GPU);let r=_chunkV4CSEIB2cjs.p.call(void 0, this,()=>this._getOrInstantiate(t));return`${[...this._declarations].join(`
25
+ ${m}`:`${e.pre}if (${u})
26
+ ${f}`}if(t[0]===D.let||t[0]===D.const){let[r,n,a]=t,o=a!==void 0?G(e,a):void 0;if(!o)throw new Error(`Cannot create variable '${n}' without an initial value.`);if(_chunkUMHCZDPAcjs.Y.call(void 0, o.dataType))throw new Error(`Cannot create variable '${n}' with loose data type.`);fo(e,n,dr(o.dataType));let i=e.resolve(Lr(e,n).value);if(typeof a=="object"&&a[0]===D.objectExpr&&_chunkUMHCZDPAcjs.O.call(void 0, e.callStack[e.callStack.length-1])){let s=e.callStack[e.callStack.length-1],p=a[1],u={};for(let[g,y]of Object.entries(p)){if(!y)throw new Error(`Missing property ${g} in object literal`);u[g]=G(e,y)}let f=fr(e,s,u),m=e.resolve(s);return`${e.pre}var ${i} = ${m}(${f.map(g=>e.resolve(g.value)).join(", ")});`}return`${e.pre}var ${i} = ${e.resolve(o.value)};`}if(t[0]===D.block)return ua(e,t);if(t[0]===D.for){let[r,n,a,o,i]=t,s=n?De(e,n):void 0,p=s?s.slice(0,-1):"",u=a?G(e,a):void 0,f=u;if(u){let b=z(e,[u],[_chunkUMHCZDPAcjs.la]);_optionalChain([b, 'optionalAccess', _86 => _86[0]])&&([f]=b)}let m=f?e.resolve(f.value):"",g=o?De(e,o):void 0,y=g?g.slice(0,-1):"";e.indent();let x=De(e,Ot(i));return e.dedent(),`${e.pre}for (${p}; ${m}; ${y})
27
+ ${x}`}if(t[0]===D.while){let[r,n,a]=t,o=G(e,n),i=o;if(o){let u=z(e,[o],[_chunkUMHCZDPAcjs.la]);_optionalChain([u, 'optionalAccess', _87 => _87[0]])&&([i]=u)}let s=e.resolve(i.value);e.indent();let p=De(e,Ot(a));return e.dedent(),`${e.pre}while (${s})
28
+ ${p}`}return t[0]===D.continue?`${e.pre}continue;`:t[0]===D.break?`${e.pre}break;`:`${e.pre}${e.resolve(G(e,t).value)};`}function pa(e,t){return ua(e,t)}var la="#CATCHALL#",Wr= (_class19 =class{constructor() { _class19.prototype.__init39.call(this);_class19.prototype.__init40.call(this); }__init39() {this._stack=[]}__init40() {this._itemDepth=0}get itemDepth(){return this._itemDepth}get topItem(){let t=this._stack[this._stack.length-1];if(!t||t.type!=="item")throw new Error("Internal error, expected item layer to be on top.");return t}pushItem(){this._itemDepth++,this._stack.push({type:"item",usedSlots:new Set})}popItem(){this.pop("item")}pushSlotBindings(t){this._stack.push({type:"slotBinding",bindingMap:new WeakMap(t)})}popSlotBindings(){this.pop("slotBinding")}pushFunctionScope(t,r,n,a){this._stack.push({type:"functionScope",args:t,argAliases:r,returnType:n,externalMap:a})}popFunctionScope(){this.pop("functionScope")}pushBlockScope(){this._stack.push({type:"blockScope",declarations:new Map})}popBlockScope(){this.pop("blockScope")}pop(t){let r=this._stack[this._stack.length-1];if(!r||t&&r.type!==t)throw new Error(`Internal error, expected a ${t} layer to be on top.`);this._stack.pop(),t==="item"&&this._itemDepth--}readSlot(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if(_optionalChain([n, 'optionalAccess', _88 => _88.type])==="item")n.usedSlots.add(t);else if(_optionalChain([n, 'optionalAccess', _89 => _89.type])==="slotBinding"){let a=n.bindingMap.get(t);if(a!==void 0)return a}else if(!(_optionalChain([n, 'optionalAccess', _90 => _90.type])==="functionScope"||_optionalChain([n, 'optionalAccess', _91 => _91.type])==="blockScope"))throw new Error("Unknown layer type.")}return t.defaultValue}getSnippetById(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if(_optionalChain([n, 'optionalAccess', _92 => _92.type])==="functionScope"){let a=n.args.find(i=>i.value===t);if(a!==void 0)return a;if(n.argAliases[t])return n.argAliases[t];let o=n.externalMap[t];return o!=null?he(o):void 0}if(_optionalChain([n, 'optionalAccess', _93 => _93.type])==="blockScope"){let a=n.declarations.get(t);if(a!==void 0)return _chunkUMHCZDPAcjs.fa.call(void 0, t,a)}}}defineBlockVariable(t,r){if(r.type==="unknown")throw Error(`Tried to define variable '${t}' of unknown type`);for(let n=this._stack.length-1;n>=0;--n){let a=this._stack[n];if(_optionalChain([a, 'optionalAccess', _94 => _94.type])==="blockScope")return a.declarations.set(t,r),_chunkUMHCZDPAcjs.fa.call(void 0, t,r)}throw new Error("No block scope found to define a variable in.")}}, _class19),Wt=[""," "," "," "," "," "," "," "," "],Or=Wt.length-1,Mr= (_class20 =class{constructor() { _class20.prototype.__init41.call(this); }__init41() {this.identLevel=0}get pre(){return _nullishCoalesce(Wt[this.identLevel], () => (Wt[Or].repeat(this.identLevel/Or)+Wt[this.identLevel%Or]))}indent(){let t=this.pre;return this.identLevel++,t}dedent(){return this.identLevel--,this.pre}}, _class20),Nr= (_class21 =class{__init42() {this._memoizedResolves=new WeakMap}__init43() {this._memoizedDerived=new WeakMap}__init44() {this._indentController=new Mr}__init45() {this._itemStateStack=new Wr}__init46() {this._declarations=[]}get varyingLocations(){return this._varyingLocations}__init47() {this[_chunkUMHCZDPAcjs.a]={itemStateStack:this._itemStateStack}}__init48() {this.bindGroupLayoutsToPlaceholderMap=new Map}__init49() {this._nextFreeLayoutPlaceholderIdx=0}__init50() {this.fixedBindings=[]}__init51() {this.callStack=[]}constructor(t){;_class21.prototype.__init42.call(this);_class21.prototype.__init43.call(this);_class21.prototype.__init44.call(this);_class21.prototype.__init45.call(this);_class21.prototype.__init46.call(this);_class21.prototype.__init47.call(this);_class21.prototype.__init48.call(this);_class21.prototype.__init49.call(this);_class21.prototype.__init50.call(this);_class21.prototype.__init51.call(this);this.names=t.names}get pre(){return this._indentController.pre}indent(){return this._indentController.indent()}dedent(){return this._indentController.dedent()}getById(t){let r=this._itemStateStack.getSnippetById(t);return r===void 0?null:r}defineVariable(t,r){return this._itemStateStack.defineBlockVariable(t,r)}pushBlockScope(){this._itemStateStack.pushBlockScope()}popBlockScope(){this._itemStateStack.popBlockScope()}fnToWgsl(t){this._itemStateStack.pushFunctionScope(t.args,t.argAliases,t.returnType,t.externalMap);try{return{head:co(this,t.args,t.returnType),body:pa(this,t.body)}}finally{this._itemStateStack.popFunctionScope()}}addDeclaration(t){this._declarations.push(t)}allocateLayoutEntry(t){let r=this.bindGroupLayoutsToPlaceholderMap,n=r.get(t);return n||(n=`#BIND_GROUP_LAYOUT_${this._nextFreeLayoutPlaceholderIdx++}#`,r.set(t,n)),n}allocateFixedEntry(t,r){let n=this.fixedBindings.length;return this.fixedBindings.push({layoutEntry:t,resource:r}),{group:la,binding:n}}readSlot(t){let r=this._itemStateStack.readSlot(t);if(r===void 0)throw new (0, _chunkUMHCZDPAcjs.o)(t);return r}withSlots(t,r){this._itemStateStack.pushSlotBindings(t);try{return r()}finally{this._itemStateStack.popSlotBindings()}}withVaryingLocations(t,r){this._varyingLocations=t;try{return r()}finally{this._varyingLocations=void 0}}unwrap(t){if(He(t))return this.withSlots(t[_chunkUMHCZDPAcjs.e].pairs,()=>this.unwrap(t[_chunkUMHCZDPAcjs.e].inner));let r=t;for(;;)if(Ge(r))r=this.readSlot(r);else if(Ve(r))r=this._getOrCompute(r);else break;return r}_getOrCompute(t){let r=_nullishCoalesce(this._memoizedDerived.get(t), () => ([]));this._itemStateStack.pushItem();try{for(let o of r)if([...o.slotToValueMap.entries()].every(([s,p])=>s.areEqual(this._itemStateStack.readSlot(s),p)))return o.result;_chunkUMHCZDPAcjs.w.call(void 0, _chunkUMHCZDPAcjs.t.CPU);let n;try{n=t["~compute"]()}finally{_chunkUMHCZDPAcjs.x.call(void 0, _chunkUMHCZDPAcjs.t.CPU)}let a=new Map;for(let o of this._itemStateStack.topItem.usedSlots)a.set(o,this._itemStateStack.readSlot(o));return r.push({slotToValueMap:a,result:n}),this._memoizedDerived.set(t,r),n}catch(n){throw n instanceof _chunkUMHCZDPAcjs.n?n.appendToTrace(t):new (0, _chunkUMHCZDPAcjs.n)(n,[t])}finally{this._itemStateStack.popItem()}}_getOrInstantiate(t){let r=_nullishCoalesce(this._memoizedResolves.get(t), () => ([]));this._itemStateStack.pushItem();try{for(let o of r)if([...o.slotToValueMap.entries()].every(([s,p])=>s.areEqual(this._itemStateStack.readSlot(s),p)))return o.result;let n;_chunkUMHCZDPAcjs.da.call(void 0, t)?n=wr(this,t):Ve(t)||Ge(t)?n=this.resolve(this.unwrap(t)):gr(t)?n=t["~resolve"](this):n=this.resolveValue(t);let a=new Map;for(let o of this._itemStateStack.topItem.usedSlots)a.set(o,this._itemStateStack.readSlot(o));return r.push({slotToValueMap:a,result:n}),this._memoizedResolves.set(t,r),n}catch(n){throw n instanceof _chunkUMHCZDPAcjs.n?n.appendToTrace(t):new (0, _chunkUMHCZDPAcjs.n)(n,[t])}finally{this._itemStateStack.popItem()}}resolve(t){if(He(t))return this.withSlots(t[_chunkUMHCZDPAcjs.e].pairs,()=>this.resolve(t[_chunkUMHCZDPAcjs.e].inner));if(t&&typeof t=="object"||typeof t=="function"){if(this._itemStateStack.itemDepth===0)try{_chunkUMHCZDPAcjs.w.call(void 0, _chunkUMHCZDPAcjs.t.GPU);let r=_chunkUMHCZDPAcjs.u.call(void 0, this,()=>this._getOrInstantiate(t));return`${[...this._declarations].join(`
28
29
 
29
- `)}${r}`}finally{_chunkV4CSEIB2cjs.s.call(void 0, _chunkV4CSEIB2cjs.o.GPU)}return this._getOrInstantiate(t)}return String(t)}resolveValue(t,r){if(gt(t))return this.resolve(t);if(r&&_chunkV4CSEIB2cjs.J.call(void 0, r))return`array(${t.map(n=>this.resolveValue(n,r.elementType))})`;if(Array.isArray(t))return`array(${t.map(n=>this.resolveValue(n))})`;if(r&&_chunkV4CSEIB2cjs.K.call(void 0, r))return`${this.resolve(r)}(${Object.entries(r.propTypes).map(([n,a])=>this.resolveValue(t[n],a))})`;throw new Error(`Value ${t} (as json: ${JSON.stringify(t)}) of schema ${r} is not resolvable to WGSL`)}}, _class21);function ke(e,t){let r=new Rr(t),n=r.resolve(e),a=r.bindGroupLayoutsToPlaceholderMap,o=[],i=new Set([...a.keys()].map(g=>g.index).filter(g=>g!==void 0)),s=_chunkV4CSEIB2cjs.da.call(void 0, i),l=r.fixedBindings.map((g,c)=>[String(c),g.layoutEntry]),u=()=>{let g=s.next().value,c=Bt(Object.fromEntries(l));return o[g]=c,n=n.replaceAll(Hn,String(g)),[g,new $e(c,Object.fromEntries(r.fixedBindings.map((y,x)=>[String(x),y.resource])))]},d=l.length>0?u():null;for(let[g,c]of a.entries()){let y=_nullishCoalesce(g.index, () => (s.next().value));o[y]=g,n=n.replaceAll(c,String(y))}return{code:n,bindGroupLayouts:o,catchall:d}}function Wa(e,t,r){let n=t.map(a=>`${a.value}: ${e.resolve(a.dataType)}`).join(", ");return r.type!=="void"?`(${n}) -> ${_chunk7ACLI4JYcjs.ba.call(void 0, r)} ${e.resolve(r)}`:`(${n})`}function qn(e){let{externals:t,template:r,names:n,unstable_jitTranspiler:a}=e,o={};ge(o,_nullishCoalesce(t, () => ({})));let i={"~resolve"(l){return ce(l,o,_nullishCoalesce(r, () => ("")))},toString:()=>"<root>"},{code:s}=ke(i,{names:n==="strict"?new ie:new oe,jitTranspiler:a});return s}var nt= (_class22 =class{constructor(t){;_class22.prototype.__init49.call(this);this._make=t}__init49() {this._map=new WeakMap}getOrMake(t,...r){if(this._map.has(t))return this._map.get(t);let n=this._make(t,...r);return this._map.set(t,n),n}}, _class22);function Jn(e,t,r){return new Pr(new Cr(e,t,r),{})}function Yn(e){let t=e;return _optionalChain([t, 'optionalAccess', _93 => _93.resourceType])==="compute-pipeline"&&!!t[_chunkV4CSEIB2cjs.a]}var Pr= (_class23 =class e{constructor(t,r){;_class23.prototype.__init50.call(this);this._core=t;this._priors=r;this[_chunkV4CSEIB2cjs.a]={get rawPipeline(){return t.unwrap().pipeline}},this[_chunkV4CSEIB2cjs.d]=t}__init50() {this.resourceType="compute-pipeline"}get rawPipeline(){return this._core.unwrap().pipeline}with(t,r){return new e(this._core,{bindGroupLayoutMap:new Map([..._nullishCoalesce(this._priors.bindGroupLayoutMap, () => ([])),[t,r]])})}dispatchWorkgroups(t,r,n){let a=this._core.unwrap(),{branch:o}=this._core,i=o.commandEncoder.beginComputePass({label:_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this._core), () => ("<unnamed>"))});i.setPipeline(a.pipeline);let s=new Set(a.bindGroupLayouts);if(a.bindGroupLayouts.forEach((l,u)=>{if(a.catchall&&u===a.catchall[0])i.setBindGroup(u,o.unwrap(a.catchall[1])),s.delete(l);else{let d=_optionalChain([this, 'access', _94 => _94._priors, 'access', _95 => _95.bindGroupLayoutMap, 'optionalAccess', _96 => _96.get, 'call', _97 => _97(l)]);d!==void 0&&(s.delete(l),i.setBindGroup(u,o.unwrap(d)))}}),s.size>0)throw new (0, _chunkV4CSEIB2cjs.m)(s);i.dispatchWorkgroups(t,r,n),i.end()}$name(t){return _chunkV4CSEIB2cjs.f.call(void 0, this._core,t),this}}, _class23),Cr=class{constructor(t,r,n){this.branch=t;this._slotBindings=r;this._entryFn=n}unwrap(){if(this._memo===void 0){let t=this.branch.device,{code:r,bindGroupLayouts:n,catchall:a}=ke({"~resolve":o=>(o.withSlots(this._slotBindings,()=>{o.resolve(this._entryFn)}),""),toString:()=>`computePipeline:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`},{names:this.branch.nameRegistry,jitTranspiler:this.branch.jitTranspiler});a!==null&&_optionalChain([n, 'access', _98 => _98[a[0]], 'optionalAccess', _99 => _99.$name, 'call', _100 => _100(`${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))} - Automatic Bind Group & Layout`)]),this._memo={pipeline:t.createComputePipeline({label:_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>")),layout:t.createPipelineLayout({label:`${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:n.map(o=>this.branch.unwrap(o))}),compute:{module:t.createShaderModule({label:`${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))} - Shader`,code:r})}}),bindGroupLayouts:n,catchall:a}}return this._memo}};function kr(e,t="vertex"){return new $r(e,t)}function $t(e){return _optionalChain([e, 'optionalAccess', _101 => _101.resourceType])==="vertex-layout"}var Vr=Symbol("defaultAttribEntry");function Vt(e,t,r,n,a){if(_chunkV4CSEIB2cjs.S.call(void 0, t)||_chunkV4CSEIB2cjs.X.call(void 0, t)){let o=_chunkV4CSEIB2cjs._.call(void 0, t);return o!==void 0&&(n[_nullishCoalesce(a, () => (Vr))]=o),Vt(e,t.inner,_chunk7ACLI4JYcjs.a.call(void 0, r,_chunk7ACLI4JYcjs.T.call(void 0, t)),n)}if(_chunkV4CSEIB2cjs.K.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,s])=>{o=_chunk7ACLI4JYcjs.a.call(void 0, o,_chunk7ACLI4JYcjs.S.call(void 0, s));let l=[i,Vt(e,s,o,n,i)];return o+=_chunk7ACLI4JYcjs.V.call(void 0, s),l}))}if(_chunkV4CSEIB2cjs.W.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,s])=>{o=_chunk7ACLI4JYcjs.a.call(void 0, o,_chunk7ACLI4JYcjs.T.call(void 0, s));let l=[i,Vt(e,s,o,n,i)];return o+=_chunk7ACLI4JYcjs.V.call(void 0, s),l}))}if("type"in t&&typeof t.type=="string"){if(_chunkV4CSEIB2cjs.u.includes(t.type))return{_layout:e,format:t.type,offset:r};let o=_chunkV4CSEIB2cjs.v[t.type];if(o)return{_layout:e,format:o,offset:r}}throw new Error(`Unsupported data used in vertex layout: ${String(t)}`)}var $r= (_class24 =class{constructor(t,r){;_class24.prototype.__init51.call(this);_class24.prototype.__init52.call(this);this.schemaForCount=t;this.stepMode=r;let n=t(0);this.stride=_chunk7ACLI4JYcjs.a.call(void 0, _chunk7ACLI4JYcjs.V.call(void 0, n.elementType),_chunk7ACLI4JYcjs.S.call(void 0, n)),this.attrib=Vt(this,n.elementType,0,this._customLocationMap)}__init51() {this.resourceType="vertex-layout"}__init52() {this._customLocationMap={}}get vertexLayout(){if(this._customLocationMap[Vr]!==void 0){if(typeof this.attrib.format!="string"||typeof this.attrib.offset!="number")throw new Error("Single attribute vertex layouts must have a format and offset.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[{format:this.attrib.format,offset:this.attrib.offset,shaderLocation:this._customLocationMap[Vr]}]}}if(!Object.keys(this.attrib).every(r=>this._customLocationMap[r]!==void 0))throw new Error("All attributes must have custom locations in order to unwrap a vertex layout.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[...Object.entries(this.attrib).map(([r,n])=>({format:n.format,offset:n.offset,shaderLocation:this._customLocationMap[r]}))]}}$name(t){return _chunkV4CSEIB2cjs.f.call(void 0, this,t),this}}, _class24);function Na(e){return typeof _optionalChain([e, 'optionalAccess', _102 => _102.loadOp])=="string"}function Qn(e,t){if(_chunkV4CSEIB2cjs.$.call(void 0, e)){if(!Na(t))throw new Error("Expected a single color attachment, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=t[n];if(!a)throw new Error(`A color attachment by the name of '${n}' was not provided to the shader.`);r.push(a)}return r}function ja(e){return typeof _optionalChain([e, 'optionalAccess', _103 => _103.format])=="string"}function Xn(e,t){if(_chunkV4CSEIB2cjs.$.call(void 0, e)){if(_chunkV4CSEIB2cjs.T.call(void 0, e))return[];if(!ja(t))throw new Error("Expected a single color target configuration, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=t[n];if(!a)throw new Error(`A color target by the name of '${n}' was not provided to the shader.`);r.push(a)}return r}function Zn(e){return new _r(new Er(e),{})}function ea(e){let t=e;return _optionalChain([t, 'optionalAccess', _104 => _104.resourceType])==="render-pipeline"&&!!t[_chunkV4CSEIB2cjs.a]}var _r= (_class25 =class e{__init53() {this.resourceType="render-pipeline"}constructor(t,r){;_class25.prototype.__init53.call(this);this[_chunkV4CSEIB2cjs.a]={core:t,priors:r},this[_chunkV4CSEIB2cjs.d]=t}$name(t){return _chunkV4CSEIB2cjs.f.call(void 0, this[_chunkV4CSEIB2cjs.a].core,t),this}with(t,r){let n=this[_chunkV4CSEIB2cjs.a];if(Rt(t))return new e(n.core,{...n.priors,bindGroupLayoutMap:new Map([..._nullishCoalesce(n.priors.bindGroupLayoutMap, () => ([])),[t,r]])});if($t(t))return new e(n.core,{...n.priors,vertexLayoutMap:new Map([..._nullishCoalesce(n.priors.vertexLayoutMap, () => ([])),[t,r]])});throw new Error("Unsupported value passed into .with()")}withColorAttachment(t){let r=this[_chunkV4CSEIB2cjs.a];return new e(r.core,{...r.priors,colorAttachment:t})}withDepthStencilAttachment(t){let r=this[_chunkV4CSEIB2cjs.a];return new e(r.core,{...r.priors,depthStencilAttachment:t})}draw(t,r,n,a){let o=this[_chunkV4CSEIB2cjs.a],i=o.core.unwrap(),{branch:s,fragmentFn:l}=o.core.options,d={colorAttachments:Qn(l.shell.targets,_nullishCoalesce(o.priors.colorAttachment, () => ({}))).map(b=>Q(b.view)?{...b,view:s.unwrap(b.view).createView()}:b)},g=_chunkV4CSEIB2cjs.e.call(void 0, o.core);if(g!==void 0&&(d.label=g),o.priors.depthStencilAttachment!==void 0){let b=o.priors.depthStencilAttachment;Q(b.view)?d.depthStencilAttachment={...b,view:s.unwrap(b.view).createView()}:d.depthStencilAttachment=b}let c=s.commandEncoder.beginRenderPass(d);c.setPipeline(i.pipeline);let y=new Set(i.bindGroupLayouts);i.bindGroupLayouts.forEach((b,U)=>{if(i.catchall&&U===i.catchall[0])c.setBindGroup(U,s.unwrap(i.catchall[1])),y.delete(b);else{let _e=_optionalChain([o, 'access', _105 => _105.priors, 'access', _106 => _106.bindGroupLayoutMap, 'optionalAccess', _107 => _107.get, 'call', _108 => _108(b)]);_e!==void 0&&(y.delete(b),c.setBindGroup(U,s.unwrap(_e)))}});let x=new Set(o.core.usedVertexLayouts);if(o.core.usedVertexLayouts.forEach((b,U)=>{let _e=_optionalChain([o, 'access', _109 => _109.priors, 'access', _110 => _110.vertexLayoutMap, 'optionalAccess', _111 => _111.get, 'call', _112 => _112(b)]);_e&&(x.delete(b),c.setVertexBuffer(U,s.unwrap(_e)))}),y.size>0)throw new (0, _chunkV4CSEIB2cjs.m)(y);if(x.size>0)throw new (0, _chunkV4CSEIB2cjs.n)(x);c.draw(t,r,n,a),c.end(),s.flush()}}, _class25),Er=class{constructor(t){this.options=t;let r=Un(t.vertexFn.shell.attributes[0],t.vertexAttribs);this._vertexBufferLayouts=r.bufferDefinitions,this.usedVertexLayouts=r.usedVertexLayouts,this._targets=Xn(t.fragmentFn.shell.targets,t.targets)}unwrap(){if(this._memo===void 0){let{branch:t,vertexFn:r,fragmentFn:n,slotBindings:a,primitiveState:o,depthStencilState:i,multisampleState:s}=this.options,{code:l,bindGroupLayouts:u,catchall:d}=ke({"~resolve":w=>(w.withSlots(a,()=>{w.resolve(r),w.resolve(n)}),""),toString:()=>`renderPipeline:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`},{names:t.nameRegistry,jitTranspiler:t.jitTranspiler});d!==null&&_optionalChain([u, 'access', _113 => _113[d[0]], 'optionalAccess', _114 => _114.$name, 'call', _115 => _115(`${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))} - Automatic Bind Group & Layout`)]);let g=t.device,c=g.createShaderModule({label:`${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))} - Shader`,code:l}),y={layout:g.createPipelineLayout({label:`${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:u.map(w=>t.unwrap(w))}),vertex:{module:c,buffers:this._vertexBufferLayouts},fragment:{module:c,targets:this._targets}},x=_chunkV4CSEIB2cjs.e.call(void 0, this);x!==void 0&&(y.label=x),o&&(y.primitive=o),i&&(y.depthStencil=i),s&&(y.multisample=s),this._memo={pipeline:g.createRenderPipeline(y),bindGroupLayouts:u,catchall:d}}return this._memo}};var Gr=class e{constructor(t,r){this._getRoot=t;this._slotBindings=r}with(t,r){return new e(this._getRoot,[...this._slotBindings,[He(t)?t.slot:t,r]])}withCompute(t){return new Lr(this._getRoot(),this._slotBindings,t)}withVertex(t,r){return new Or({branch:this._getRoot(),primitiveState:void 0,depthStencilState:void 0,slotBindings:this._slotBindings,vertexFn:t,vertexAttribs:r,multisampleState:void 0})}},Lr=class{constructor(t,r,n){this._root=t;this._slotBindings=r;this._entryFn=n}createPipeline(){return Jn(this._root,this._slotBindings,this._entryFn)}},Or=class{constructor(t){this._options=t}withFragment(t,r,n){return _chunkV4CSEIB2cjs.h.call(void 0, typeof t!="string","Just type mismatch validation"),_chunkV4CSEIB2cjs.h.call(void 0, typeof r!="string","Just type mismatch validation"),new Mr({...this._options,fragmentFn:t,targets:r})}},Mr=class e{constructor(t){this._options=t}withPrimitive(t){return new e({...this._options,primitiveState:t})}withDepthStencil(t){return new e({...this._options,depthStencilState:t})}withMultisample(t){return new e({...this._options,multisampleState:t})}createPipeline(){return Zn(this._options)}},kt= (_class26 =class extends Gr{constructor(r,n,a,o){super(()=>this,[]);_class26.prototype.__init54.call(this);_class26.prototype.__init55.call(this);_class26.prototype.__init56.call(this);_class26.prototype.__init57.call(this);;this.device=r;this.nameRegistry=n;this.jitTranspiler=a;this._ownDevice=o;this["~unstable"]=this}__init54() {this._disposables=[]}__init55() {this._unwrappedBindGroupLayouts=new nt(r=>r.unwrap(this))}__init56() {this._unwrappedBindGroups=new nt(r=>r.unwrap(this))}__init57() {this._commandEncoder=null}get commandEncoder(){return this._commandEncoder||(this._commandEncoder=this.device.createCommandEncoder()),this._commandEncoder}createBuffer(r,n){let a=kn(this,r,n);return this._disposables.push(a),a}createUniform(r,n){return this.createBuffer(r,n).$usage("uniform").as("uniform")}createMutable(r,n){return this.createBuffer(r,n).$usage("storage").as("mutable")}createReadonly(r,n){return this.createBuffer(r,n).$usage("storage").as("readonly")}createBindGroup(r,n){return new $e(r,n)}destroy(){for(let r of this._disposables)r.destroy();this._ownDevice&&this.device.destroy()}createTexture(r){let n=Mn(r,this);return this._disposables.push(n),n}unwrap(r){if(Yn(r))return r[_chunkV4CSEIB2cjs.a].rawPipeline;if(ea(r))return r[_chunkV4CSEIB2cjs.a].core.unwrap().pipeline;if(Rt(r))return this._unwrappedBindGroupLayouts.getOrMake(r);if(Fr(r))return this._unwrappedBindGroups.getOrMake(r);if(ue(r))return r.buffer;if(Q(r))return r[_chunkV4CSEIB2cjs.a].unwrap();if(tt(r)){if(r[_chunkV4CSEIB2cjs.a].unwrap)return r[_chunkV4CSEIB2cjs.a].unwrap();throw new Error("Cannot unwrap laid-out texture view.")}if(rt(r)){if(r[_chunkV4CSEIB2cjs.a].unwrap)return r[_chunkV4CSEIB2cjs.a].unwrap();throw new Error("Cannot unwrap laid-out texture view.")}if($t(r))return r.vertexLayout;if(Xe(r)){if(r[_chunkV4CSEIB2cjs.a].unwrap)return r[_chunkV4CSEIB2cjs.a].unwrap(this);throw new Error("Cannot unwrap laid-out sampler.")}if(Ze(r)){if(r[_chunkV4CSEIB2cjs.a].unwrap)return r[_chunkV4CSEIB2cjs.a].unwrap(this);throw new Error("Cannot unwrap laid-out comparison sampler.")}throw new Error(`Unknown resource type: ${r}`)}beginRenderPass(r,n){let a=this.commandEncoder.beginRenderPass(r),o=new Map,i=new Map,s,l=()=>{if(!s)throw new Error("Cannot draw without a call to pass.setPipeline");let{core:u,priors:d}=s[_chunkV4CSEIB2cjs.a],g=u.unwrap();a.setPipeline(g.pipeline);let c=new Set(g.bindGroupLayouts);g.bindGroupLayouts.forEach((x,w)=>{if(g.catchall&&w===g.catchall[0])a.setBindGroup(w,this.unwrap(g.catchall[1])),c.delete(x);else{let b=_nullishCoalesce(_optionalChain([d, 'access', _116 => _116.bindGroupLayoutMap, 'optionalAccess', _117 => _117.get, 'call', _118 => _118(x)]), () => (o.get(x)));b!==void 0&&(c.delete(x),Fr(b)?a.setBindGroup(w,this.unwrap(b)):a.setBindGroup(w,b))}});let y=new Set;if(u.usedVertexLayouts.forEach((x,w)=>{let b=_optionalChain([d, 'access', _119 => _119.vertexLayoutMap, 'optionalAccess', _120 => _120.get, 'call', _121 => _121(x)]),U=b?{buffer:b,offset:void 0,size:void 0}:i.get(x);!U||!U.buffer?y.add(x):ue(U.buffer)?a.setVertexBuffer(w,this.unwrap(U.buffer),U.offset,U.size):a.setVertexBuffer(w,U.buffer,U.offset,U.size)}),c.size>0)throw new (0, _chunkV4CSEIB2cjs.m)(c);if(y.size>0)throw new (0, _chunkV4CSEIB2cjs.n)(y)};n({setViewport(...u){a.setViewport(...u)},setScissorRect(...u){a.setScissorRect(...u)},setBlendConstant(...u){a.setBlendConstant(...u)},setStencilReference(...u){a.setStencilReference(...u)},beginOcclusionQuery(...u){a.beginOcclusionQuery(...u)},endOcclusionQuery(...u){a.endOcclusionQuery(...u)},executeBundles(...u){a.executeBundles(...u)},setPipeline(u){s=u},setIndexBuffer:(u,d,g,c)=>{ue(u)?a.setIndexBuffer(this.unwrap(u),d,g,c):a.setIndexBuffer(u,d,g,c)},setVertexBuffer(u,d,g,c){i.set(u,{buffer:d,offset:g,size:c})},setBindGroup(u,d){o.set(u,d)},draw(u,d,g,c){l(),a.draw(u,d,g,c)},drawIndexed(...u){l(),a.drawIndexed(...u)},drawIndirect(...u){l(),a.drawIndirect(...u)},drawIndexedIndirect(...u){l(),a.drawIndexedIndirect(...u)}}),a.end()}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}}, _class26);async function ta(e){let{adapter:t,device:r,unstable_names:n="random",unstable_jitTranspiler:a}=_nullishCoalesce(e, () => ({}));if(!navigator.gpu)throw new Error("WebGPU is not supported by this browser.");let o=await navigator.gpu.requestAdapter(t);if(!o)throw new Error("Could not find a compatible GPU");return new kt(await o.requestDevice(r),n==="random"?new oe:new ie,a,!0)}function ra(e){let{device:t,unstable_names:r="random",unstable_jitTranspiler:n}=_nullishCoalesce(e, () => ({}));return new kt(t,r==="random"?new oe:new ie,n,!1)}function _t(e){return new Wr(e)}var Wr= (_class27 =class{constructor(t=void 0){;_class27.prototype.__init58.call(this);this.defaultValue=t}__init58() {this.resourceType="slot"}$name(t){return _chunkV4CSEIB2cjs.f.call(void 0, this,t),this}areEqual(t,r){return Object.is(t,r)}toString(){return`slot:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}[_chunkV4CSEIB2cjs.c](t){return ze(t,t.unwrap(this))}get value(){let t=_chunkV4CSEIB2cjs.q.call(void 0, );if(!t)throw new Error("Cannot access tgpu.slot's value outside of resolution.");return this[_chunkV4CSEIB2cjs.c](t)}}, _class27);function na(e,t){return new Nr(e,t)}var Nr= (_class28 =class{constructor(t,r=void 0){;_class28.prototype.__init59.call(this);this.schema=t;this.defaultValue=r;this.slot=_t(r),this[_chunkV4CSEIB2cjs.d]=this.slot}__init59() {this.resourceType="accessor"}$name(t){return this.slot.$name(t),this}toString(){return`accessor:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}[_chunkV4CSEIB2cjs.c](){return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`,[_chunkV4CSEIB2cjs.b]:this.schema},q)}get value(){if(!_chunkV4CSEIB2cjs.t.call(void 0, ))throw new Error("`tgpu.accessor` values are only accessible on the GPU");return this[_chunkV4CSEIB2cjs.c]()}"~resolve"(t){let r=t.unwrap(this.slot);return gn(r)?t.resolve(r):ir(r)?`${t.resolve(r)}()`:t.resolveValue(r,this.schema)}}, _class28);function aa(e){return Ka(e)}function za([e,t]){return`${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, e), () => ("<unnamed>"))}=${t}`}function Ka(e){if(_chunkV4CSEIB2cjs.q.call(void 0, ))throw new Error("Cannot create tgpu.derived objects at the resolution stage.");return{resourceType:"derived","~compute":e,[_chunkV4CSEIB2cjs.w]:void 0,"~gpuRepr":void 0,[_chunkV4CSEIB2cjs.c](r){return ze(r,r.unwrap(this))},get value(){let r=_chunkV4CSEIB2cjs.q.call(void 0, );if(!r)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return this[_chunkV4CSEIB2cjs.c](r)},with(r,n){return oa(this,[[r,n]])},toString(){return"derived"}}}function oa(e,t){return{resourceType:"derived",[_chunkV4CSEIB2cjs.w]:void 0,"~gpuRepr":void 0,"~compute"(){throw new Error("'~compute' should never be read on bound derived items.")},"~providing":{inner:e,pairs:t},[_chunkV4CSEIB2cjs.c](n){return ze(n,n.unwrap(this))},get value(){let n=_chunkV4CSEIB2cjs.q.call(void 0, );if(!n)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return this[_chunkV4CSEIB2cjs.c](n)},with(n,a){return oa(e,[...t,[n,a]])},toString(){return`derived[${t.map(za).join(", ")}]`}}}function ia(e,t){return new Et("private",e,t)}function sa(e){return new Et("workgroup",e)}var Et=class{constructor(t,r,n){this.scope=t;this._dataType=r;this._initialValue=n;this[_chunkV4CSEIB2cjs.a]={scope:t}}"~resolve"(t){let r=t.names.makeUnique(_chunkV4CSEIB2cjs.e.call(void 0, this));return this._initialValue?t.addDeclaration(`var<${this.scope}> ${r}: ${t.resolve(this._dataType)} = ${t.resolveValue(this._initialValue,this._dataType)};`):t.addDeclaration(`var<${this.scope}> ${r}: ${t.resolve(this._dataType)};`),r}$name(t){return _chunkV4CSEIB2cjs.f.call(void 0, this,t),this}toString(){return`var:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`}[_chunkV4CSEIB2cjs.c](){return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(_chunkV4CSEIB2cjs.e.call(void 0, this), () => ("<unnamed>"))}`,[_chunkV4CSEIB2cjs.b]:this._dataType},q)}get value(){if(!_chunkV4CSEIB2cjs.t.call(void 0, ))throw new Error("`tgpu.var` values are only accessible on the GPU");return this[_chunkV4CSEIB2cjs.c]()}};var ua={bindGroupLayout:Bt,vertexLayout:kr,init:ta,initFromDevice:ra,resolve:qn,"~unstable":{fn:vn,fragmentFn:Fn,vertexFn:In,computeFn:Sn,vertexLayout:kr,derived:aa,slot:_t,accessor:na,privateVar:ia,workgroupVar:sa,const:dn,declare:yn,sampler:_n,comparisonSampler:En}},rl= exports.default =ua;Object.assign(ua,{__assignAst:hn,__removedJsImpl:wn});exports.MissingBindGroupsError = _chunkV4CSEIB2cjs.m; exports.MissingLinksError = _chunkV4CSEIB2cjs.l; exports.MissingSlotValueError = _chunkV4CSEIB2cjs.j; exports.MissingVertexBuffersError = _chunkV4CSEIB2cjs.n; exports.NotUniformError = _chunkV4CSEIB2cjs.k; exports.RandomNameRegistry = oe; exports.ResolutionError = _chunkV4CSEIB2cjs.i; exports.StrictNameRegistry = ie; exports.default = rl; exports.isBuffer = ue; exports.isComparisonSampler = Ze; exports.isDerived = Re; exports.isSampledTextureView = rt; exports.isSampler = Xe; exports.isSlot = Be; exports.isStorageTextureView = tt; exports.isTexture = Q; exports.isTgpuFn = ir; exports.isUsableAsRender = _a; exports.isUsableAsSampled = Sr; exports.isUsableAsStorage = Te; exports.isUsableAsUniform = wt; exports.isUsableAsVertex = ka; exports.tgpu = ua; exports.unstable_asMutable = dr; exports.unstable_asReadonly = fr; exports.unstable_asUniform = gr;
30
+ `)}${r}`}finally{_chunkUMHCZDPAcjs.x.call(void 0, _chunkUMHCZDPAcjs.t.GPU)}return this._getOrInstantiate(t)}return String(t)}resolveValue(t,r){if(wt(t))return this.resolve(t);if(r&&_chunkUMHCZDPAcjs.N.call(void 0, r))return`array(${t.map(n=>this.resolveValue(n,r.elementType))})`;if(Array.isArray(t))return`array(${t.map(n=>this.resolveValue(n))})`;if(r&&_chunkUMHCZDPAcjs.O.call(void 0, r))return`${this.resolve(r)}(${Object.entries(r.propTypes).map(([n,a])=>this.resolveValue(t[n],a))})`;throw new Error(`Value ${t} (as json: ${JSON.stringify(t)}) of schema ${r} is not resolvable to WGSL`)}}, _class21);function fe(e,t){let r=new Nr(t),n=r.resolve(e),a=r.bindGroupLayoutsToPlaceholderMap,o=[],i=new Set([...a.keys()].map(m=>m.index).filter(m=>m!==void 0)),s=_chunkUMHCZDPAcjs.ha.call(void 0, i),p=r.fixedBindings.map((m,g)=>[String(g),m.layoutEntry]),u=()=>{let m=s.next().value,g=kt(Object.fromEntries(p));return o[m]=g,n=n.replaceAll(la,String(m)),[m,new Le(g,Object.fromEntries(r.fixedBindings.map((y,x)=>[String(x),y.resource])))]},f=p.length>0?u():void 0;for(let[m,g]of a.entries()){let y=_nullishCoalesce(m.index, () => (s.next().value));o[y]=m,n=n.replaceAll(g,String(y))}return{code:n,usedBindGroupLayouts:o,catchall:f}}function co(e,t,r){let n=t.map(a=>`${a.value}: ${e.resolve(a.dataType)}`).join(", ");return r.type!=="void"?`(${n}) -> ${_chunkRC26P3MPcjs.ba.call(void 0, r)} ${e.resolve(r)}`:`(${n})`}function zr(e){let{externals:t,template:r,names:n}=e,a={};return be(a,_nullishCoalesce(t, () => ({}))),fe({"~resolve"(i){return we(i,a,_nullishCoalesce(r, () => ("")))},toString:()=>"<root>"},{names:n==="strict"?new le:new pe})}function ma(e){return zr(e).code}function da(e,t,r,n){return new jr(e,t,r,n)}function st(e){let t=e;return _optionalChain([t, 'optionalAccess', _95 => _95.resourceType])==="query-set"&&!!t[_chunkUMHCZDPAcjs.a]}var jr= (_class22 =class{constructor(t,r,n,a){;_class22.prototype.__init52.call(this);_class22.prototype.__init53.call(this);_class22.prototype.__init54.call(this);_class22.prototype.__init55.call(this);_class22.prototype.__init56.call(this);_class22.prototype.__init57.call(this);this._group=t;this.type=r;this.count=n;this.rawQuerySet=a;this._ownQuerySet=!a,this._querySet=a||null}__init52() {this.resourceType="query-set"}__init53() {this._querySet=null}__init54() {this._destroyed=!1}__init55() {this._available=!0}__init56() {this._readBuffer=null}__init57() {this._resolveBuffer=null}get querySet(){if(this._destroyed)throw new Error("This QuerySet has been destroyed.");return this.rawQuerySet?this.rawQuerySet:this._querySet?this._querySet:(this._querySet=this._group.device.createQuerySet({type:this.type,count:this.count}),this._querySet)}get destroyed(){return this._destroyed}get available(){return this._available}get[_chunkUMHCZDPAcjs.a](){let t=this;return{get readBuffer(){return t._readBuffer||(t._readBuffer=t._group.device.createBuffer({size:t.count*BigUint64Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})),t._readBuffer},get resolveBuffer(){return t._resolveBuffer||(t._resolveBuffer=t._group.device.createBuffer({size:t.count*BigUint64Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC})),t._resolveBuffer}}}$name(t){return _chunkUMHCZDPAcjs.j.call(void 0, this,t),this._querySet&&(this._querySet.label=t),this}resolve(){if(this._destroyed)throw new Error("This QuerySet has been destroyed.");if(!this._available)throw new Error("This QuerySet is busy resolving or reading.");let t=this._group.device.createCommandEncoder();t.resolveQuerySet(this.querySet,0,this.count,this[_chunkUMHCZDPAcjs.a].resolveBuffer,0),this._group.device.queue.submit([t.finish()])}async read(){if(this._group.flush(),!this._resolveBuffer)throw new Error("QuerySet must be resolved before reading.");this._available=!1;try{let t=this._group.device.createCommandEncoder();t.copyBufferToBuffer(this[_chunkUMHCZDPAcjs.a].resolveBuffer,0,this[_chunkUMHCZDPAcjs.a].readBuffer,0,this.count*BigUint64Array.BYTES_PER_ELEMENT),this._group.device.queue.submit([t.finish()]),await this._group.device.queue.onSubmittedWorkDone();let r=this[_chunkUMHCZDPAcjs.a].readBuffer;await r.mapAsync(GPUMapMode.READ);let n=new BigUint64Array(r.getMappedRange().slice());return r.unmap(),Array.from(n)}finally{this._available=!0}}destroy(){this._destroyed||(this._destroyed=!0,this._querySet&&this._ownQuerySet&&this._querySet.destroy(),_optionalChain([this, 'access', _96 => _96._readBuffer, 'optionalAccess', _97 => _97.destroy, 'call', _98 => _98()]),_optionalChain([this, 'access', _99 => _99._resolveBuffer, 'optionalAccess', _100 => _100.destroy, 'call', _101 => _101()]),this._readBuffer=this._resolveBuffer=null)}}, _class22);var ut= (_class23 =class{constructor(t){;_class23.prototype.__init58.call(this);this._make=t}__init58() {this._map=new WeakMap}getOrMake(t,...r){if(this._map.has(t))return this._map.get(t);let n=this._make(t,...r);return this._map.set(t,n),n}}, _class23);function Mt(e,t,r){if(!r.enabledFeatures.has("timestamp-query"))throw new Error('Performance callback requires the "timestamp-query" feature to be enabled on GPU device.');return e.timestampWrites?{...e,performanceCallback:t}:{...e,performanceCallback:t,hasAutoQuerySet:!0,timestampWrites:{querySet:r.createQuerySet("timestamp",2),beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}}}function Nt(e,t,r){if(!r.enabledFeatures.has("timestamp-query"))throw new Error('Timestamp writes require the "timestamp-query" feature to be enabled on GPU device.');e.hasAutoQuerySet&&e.timestampWrites&&e.timestampWrites.querySet.destroy();let n={querySet:t.querySet};return t.beginningOfPassWriteIndex!==void 0&&(n.beginningOfPassWriteIndex=t.beginningOfPassWriteIndex),t.endOfPassWriteIndex!==void 0&&(n.endOfPassWriteIndex=t.endOfPassWriteIndex),{...e,hasAutoQuerySet:!1,timestampWrites:n}}function zt(e,t){if(!e.timestampWrites)return{};let{querySet:r,beginningOfPassWriteIndex:n,endOfPassWriteIndex:a}=e.timestampWrites,o={querySet:st(r)?t.unwrap(r):r};return n!==void 0&&(o.beginningOfPassWriteIndex=n),a!==void 0&&(o.endOfPassWriteIndex=a),{timestampWrites:o}}function pt({root:e,priors:t}){let r=_optionalChain([t, 'access', _102 => _102.timestampWrites, 'optionalAccess', _103 => _103.querySet]),n=t.performanceCallback;if(!r)throw new Error("Cannot dispatch workgroups with performance callback without a query set.");if(!st(r))throw new Error("Performance callback with raw GPUQuerySet is not supported. Use TgpuQuerySet instead.");e.commandEncoder.resolveQuerySet(e.unwrap(r),0,r.count,r[_chunkUMHCZDPAcjs.a].resolveBuffer,0),e.flush(),e.device.queue.onSubmittedWorkDone().then(async()=>{if(!r.available)return;let a=await r.read(),o=a[_nullishCoalesce(_optionalChain([t, 'access', _104 => _104.timestampWrites, 'optionalAccess', _105 => _105.beginningOfPassWriteIndex]), () => (0))],i=a[_nullishCoalesce(_optionalChain([t, 'access', _106 => _106.timestampWrites, 'optionalAccess', _107 => _107.endOfPassWriteIndex]), () => (1))];if(o===void 0||i===void 0)throw new Error("QuerySet did not return valid timestamps.");await n(o,i)})}function fa(e,t,r){return new qr(new Qr(e,t,r),{})}function ca(e){let t=e;return _optionalChain([t, 'optionalAccess', _108 => _108.resourceType])==="compute-pipeline"&&!!t[_chunkUMHCZDPAcjs.a]}var qr= (_class24 =class e{constructor(t,r){;_class24.prototype.__init59.call(this);this._core=t;this._priors=r;this[_chunkUMHCZDPAcjs.a]={get rawPipeline(){return t.unwrap().pipeline},get priors(){return r}},this[_chunkUMHCZDPAcjs.d]=t}__init59() {this.resourceType="compute-pipeline"}"~resolve"(t){return t.resolve(this._core)}toString(){return`computePipeline:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}get rawPipeline(){return this._core.unwrap().pipeline}with(t,r){return new e(this._core,{...this._priors,bindGroupLayoutMap:new Map([..._nullishCoalesce(this._priors.bindGroupLayoutMap, () => ([])),[t,r]])})}withPerformanceCallback(t){let r=Mt(this._priors,t,this._core.branch);return new e(this._core,r)}withTimestampWrites(t){let r=Nt(this._priors,t,this._core.branch);return new e(this._core,r)}dispatchWorkgroups(t,r,n){let a=this._core.unwrap(),{branch:o}=this._core,i={label:_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this._core), () => ("<unnamed>")),...zt(this._priors,o)},s=o.commandEncoder.beginComputePass(i);s.setPipeline(a.pipeline);let p=new Set(a.usedBindGroupLayouts);if(a.usedBindGroupLayouts.forEach((u,f)=>{if(a.catchall&&f===a.catchall[0])s.setBindGroup(f,o.unwrap(a.catchall[1])),p.delete(u);else{let m=_optionalChain([this, 'access', _109 => _109._priors, 'access', _110 => _110.bindGroupLayoutMap, 'optionalAccess', _111 => _111.get, 'call', _112 => _112(u)]);m!==void 0&&(p.delete(u),s.setBindGroup(f,o.unwrap(m)))}}),p.size>0)throw new (0, _chunkUMHCZDPAcjs.r)(p);s.dispatchWorkgroups(t,r,n),s.end(),this._priors.performanceCallback&&pt({root:o,priors:this._priors})}$name(t){return _chunkUMHCZDPAcjs.j.call(void 0, this._core,t),this}}, _class24),Qr=class{constructor(t,r,n){this.branch=t;this._slotBindings=r;this._entryFn=n}"~resolve"(t){return t.withSlots(this._slotBindings,()=>(t.resolve(this._entryFn),""))}toString(){return"computePipelineCore"}unwrap(){if(this._memo===void 0){let t=this.branch.device,r,n;if(_optionalChain([_chunkUMHCZDPAcjs.h, 'optionalAccess', _113 => _113.enabled])){let p=performance.mark("typegpu:resolution:start");r=fe(this,{names:this.branch.nameRegistry}),n=performance.measure("typegpu:resolution",{start:p.name})}else r=fe(this,{names:this.branch.nameRegistry});let{code:a,usedBindGroupLayouts:o,catchall:i}=r;i!==void 0&&_optionalChain([o, 'access', _114 => _114[i[0]], 'optionalAccess', _115 => _115.$name, 'call', _116 => _116(`${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))} - Automatic Bind Group & Layout`)]);let s=t.createShaderModule({label:`${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))} - Shader`,code:a});this._memo={pipeline:t.createComputePipeline({label:_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>")),layout:t.createPipelineLayout({label:`${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:o.map(p=>this.branch.unwrap(p))}),compute:{module:s}}),usedBindGroupLayouts:o,catchall:i},_optionalChain([_chunkUMHCZDPAcjs.h, 'optionalAccess', _117 => _117.enabled])&&(async()=>{let p=performance.mark("typegpu:compile-start");await t.queue.onSubmittedWorkDone();let u=performance.measure("typegpu:compiled",{start:p.name});_optionalChain([_chunkUMHCZDPAcjs.h, 'optionalAccess', _118 => _118.record, 'call', _119 => _119("resolution",{resolveDuration:_optionalChain([n, 'optionalAccess', _120 => _120.duration]),compileDuration:u.duration,wgslSize:a.length})])})()}return this._memo}};function Yr(e,t="vertex"){return new Hr(e,t)}function qt(e){return _optionalChain([e, 'optionalAccess', _121 => _121.resourceType])==="vertex-layout"}var Kr=Symbol("defaultAttribEntry");function jt(e,t,r,n,a){if(_chunkUMHCZDPAcjs.W.call(void 0, t)||_chunkUMHCZDPAcjs.$.call(void 0, t)){let o=_chunkUMHCZDPAcjs.ca.call(void 0, t);return o!==void 0&&(n[_nullishCoalesce(a, () => (Kr))]=o),jt(e,t.inner,_chunkRC26P3MPcjs.a.call(void 0, r,_chunkRC26P3MPcjs.T.call(void 0, t)),n)}if(_chunkUMHCZDPAcjs.O.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,s])=>{o=_chunkRC26P3MPcjs.a.call(void 0, o,_chunkRC26P3MPcjs.S.call(void 0, s));let p=[i,jt(e,s,o,n,i)];return o+=_chunkRC26P3MPcjs.V.call(void 0, s),p}))}if(_chunkUMHCZDPAcjs._.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,s])=>{o=_chunkRC26P3MPcjs.a.call(void 0, o,_chunkRC26P3MPcjs.T.call(void 0, s));let p=[i,jt(e,s,o,n,i)];return o+=_chunkRC26P3MPcjs.V.call(void 0, s),p}))}if("type"in t&&typeof t.type=="string"){if(_chunkUMHCZDPAcjs.z.includes(t.type))return{_layout:e,format:t.type,offset:r};let o=_chunkUMHCZDPAcjs.A[t.type];if(o)return{_layout:e,format:o,offset:r}}throw new Error(`Unsupported data used in vertex layout: ${String(t)}`)}var Hr= (_class25 =class{constructor(t,r){;_class25.prototype.__init60.call(this);_class25.prototype.__init61.call(this);_class25.prototype.__init62.call(this);this.schemaForCount=t;this.stepMode=r;let n=t(0);this.stride=_chunkRC26P3MPcjs.a.call(void 0, _chunkRC26P3MPcjs.V.call(void 0, n.elementType),_chunkRC26P3MPcjs.S.call(void 0, n)),this.attrib=jt(this,n.elementType,0,this._customLocationMap)}__init60() {this[_chunkUMHCZDPAcjs.a]=!0}__init61() {this.resourceType="vertex-layout"}__init62() {this._customLocationMap={}}get vertexLayout(){if(this._customLocationMap[Kr]!==void 0){if(typeof this.attrib.format!="string"||typeof this.attrib.offset!="number")throw new Error("Single attribute vertex layouts must have a format and offset.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[{format:this.attrib.format,offset:this.attrib.offset,shaderLocation:this._customLocationMap[Kr]}]}}if(!Object.keys(this.attrib).every(r=>this._customLocationMap[r]!==void 0))throw new Error("All attributes must have custom locations in order to unwrap a vertex layout.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[...Object.entries(this.attrib).map(([r,n])=>({format:n.format,offset:n.offset,shaderLocation:this._customLocationMap[r]}))]}}$name(t){return _chunkUMHCZDPAcjs.j.call(void 0, this,t),this}}, _class25);function go(e){return typeof _optionalChain([e, 'optionalAccess', _122 => _122.loadOp])=="string"}function ga(e,t){if(_chunkUMHCZDPAcjs.da.call(void 0, e)){if(!go(t))throw new Error("Expected a single color attachment, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=t[n];if(!a)throw new Error(`A color attachment by the name of '${n}' was not provided to the shader.`);r.push(a)}return r}function yo(e){return typeof _optionalChain([e, 'optionalAccess', _123 => _123.format])=="string"}function ya(e,t){if(_chunkUMHCZDPAcjs.da.call(void 0, e)){if(_chunkUMHCZDPAcjs.X.call(void 0, e))return[];if(!yo(t))throw new Error("Expected a single color target configuration, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=t[n];if(!a)throw new Error(`A color target by the name of '${n}' was not provided to the shader.`);r.push(a)}return r}function Ta(e){return new Jr(new Xr(e),{})}function xa(e){let t=e;return _optionalChain([t, 'optionalAccess', _124 => _124.resourceType])==="render-pipeline"&&!!t[_chunkUMHCZDPAcjs.a]}var Jr= (_class26 =class e{__init63() {this.resourceType="render-pipeline"}__init64() {this.hasIndexBuffer=!1}constructor(t,r){;_class26.prototype.__init63.call(this);_class26.prototype.__init64.call(this);this[_chunkUMHCZDPAcjs.a]={core:t,priors:r},this[_chunkUMHCZDPAcjs.d]=t}"~resolve"(t){return t.resolve(this[_chunkUMHCZDPAcjs.a].core)}toString(){return`renderPipeline:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}$name(t){return _chunkUMHCZDPAcjs.j.call(void 0, this[_chunkUMHCZDPAcjs.a].core,t),this}with(t,r){let n=this[_chunkUMHCZDPAcjs.a];if(Lt(t))return new e(n.core,{...n.priors,bindGroupLayoutMap:new Map([..._nullishCoalesce(n.priors.bindGroupLayoutMap, () => ([])),[t,r]])});if(qt(t))return new e(n.core,{...n.priors,vertexLayoutMap:new Map([..._nullishCoalesce(n.priors.vertexLayoutMap, () => ([])),[t,r]])});throw new Error("Unsupported value passed into .with()")}withPerformanceCallback(t){let r=this[_chunkUMHCZDPAcjs.a],n=Mt(r.priors,t,r.core.options.branch);return new e(r.core,n)}withTimestampWrites(t){let r=this[_chunkUMHCZDPAcjs.a],n=Nt(r.priors,t,r.core.options.branch);return new e(r.core,n)}withColorAttachment(t){let r=this[_chunkUMHCZDPAcjs.a];return new e(r.core,{...r.priors,colorAttachment:t})}withDepthStencilAttachment(t){let r=this[_chunkUMHCZDPAcjs.a];return new e(r.core,{...r.priors,depthStencilAttachment:t})}withIndexBuffer(t,r,n,a){let o=this[_chunkUMHCZDPAcjs.a];if(Ye(t)){if(typeof r!="string")throw new Error("If a GPUBuffer is passed, indexFormat must be provided.");return new e(o.core,{...o.priors,indexBuffer:{buffer:t,indexFormat:r,offsetBytes:n,sizeBytes:a}})}let i={u32:"uint32",u16:"uint16"},s=t.dataType.elementType;return new e(o.core,{...o.priors,indexBuffer:{buffer:t,indexFormat:i[s.type],offsetBytes:r!==void 0?r*_chunkRC26P3MPcjs.W.call(void 0, s):void 0,sizeBytes:a!==void 0?a*_chunkRC26P3MPcjs.W.call(void 0, s):void 0}})}setupRenderPass(){let t=this[_chunkUMHCZDPAcjs.a],r=t.core.unwrap(),{branch:n,fragmentFn:a}=t.core.options,o=ga(a.shell.out,_nullishCoalesce(t.priors.colorAttachment, () => ({}))).map(m=>Z(m.view)?{...m,view:n.unwrap(m.view).createView()}:m),i={label:_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, t.core), () => ("<unnamed>")),colorAttachments:o,...zt(t.priors,n)};if(t.priors.depthStencilAttachment!==void 0){let m=t.priors.depthStencilAttachment;Z(m.view)?i.depthStencilAttachment={...m,view:n.unwrap(m.view).createView()}:i.depthStencilAttachment=m}let s=n.commandEncoder.beginRenderPass(i);s.setPipeline(r.pipeline);let p=new Set(r.usedBindGroupLayouts);r.usedBindGroupLayouts.forEach((m,g)=>{if(r.catchall&&g===r.catchall[0])s.setBindGroup(g,n.unwrap(r.catchall[1])),p.delete(m);else{let y=_optionalChain([t, 'access', _125 => _125.priors, 'access', _126 => _126.bindGroupLayoutMap, 'optionalAccess', _127 => _127.get, 'call', _128 => _128(m)]);y!==void 0&&(p.delete(m),s.setBindGroup(g,n.unwrap(y)))}});let u=new Set(t.core.usedVertexLayouts);if(t.core.usedVertexLayouts.forEach((m,g)=>{let y=_optionalChain([t, 'access', _129 => _129.priors, 'access', _130 => _130.vertexLayoutMap, 'optionalAccess', _131 => _131.get, 'call', _132 => _132(m)]);y&&(u.delete(m),s.setVertexBuffer(g,n.unwrap(y)))}),p.size>0)throw new (0, _chunkUMHCZDPAcjs.r)(p);if(u.size>0)throw new (0, _chunkUMHCZDPAcjs.s)(u);return s}draw(t,r,n,a){let o=this[_chunkUMHCZDPAcjs.a],i=this.setupRenderPass(),{branch:s}=o.core.options;i.draw(t,r,n,a),i.end(),o.priors.performanceCallback?pt({root:s,priors:o.priors}):s.flush()}drawIndexed(t,r,n,a,o){let i=this[_chunkUMHCZDPAcjs.a];if(!i.priors.indexBuffer)throw new Error("No index buffer set for this render pipeline.");let{buffer:s,indexFormat:p,offsetBytes:u,sizeBytes:f}=i.priors.indexBuffer,m=this.setupRenderPass(),{branch:g}=i.core.options;Ye(s)?m.setIndexBuffer(s,p,u,f):m.setIndexBuffer(g.unwrap(s),p,u,f),m.drawIndexed(t,r,n,a,o),m.end(),i.priors.performanceCallback?pt({root:g,priors:i.priors}):g.flush()}}, _class26),Xr=class{constructor(t){this.options=t;let r=jn(_nullishCoalesce(t.vertexFn.shell.in, () => ({})),t.vertexAttribs);this._vertexBufferLayouts=r.bufferDefinitions,this.usedVertexLayouts=r.usedVertexLayouts,this._targets=ya(t.fragmentFn.shell.out,t.targets)}"~resolve"(t){let{vertexFn:r,fragmentFn:n,slotBindings:a}=this.options,o=To(r.shell.out,n.shell.in,_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, r), () => ("<unnamed>")),_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, n), () => ("<unnamed>")));return t.withVaryingLocations(o,()=>t.withSlots(a,()=>(t.resolve(r),t.resolve(n),"")))}toString(){return"renderPipelineCore"}unwrap(){if(this._memo===void 0){let{branch:t,primitiveState:r,depthStencilState:n,multisampleState:a}=this.options,o=t.device,i,s;if(_optionalChain([_chunkUMHCZDPAcjs.h, 'optionalAccess', _133 => _133.enabled])){let x=performance.mark("typegpu:resolution:start");i=fe(this,{names:t.nameRegistry}),s=performance.measure("typegpu:resolution",{start:x.name})}else i=fe(this,{names:t.nameRegistry});let{code:p,usedBindGroupLayouts:u,catchall:f}=i;f!==void 0&&_optionalChain([u, 'access', _134 => _134[f[0]], 'optionalAccess', _135 => _135.$name, 'call', _136 => _136(`${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))} - Automatic Bind Group & Layout`)]);let m=o.createShaderModule({label:`${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))} - Shader`,code:p}),g={layout:o.createPipelineLayout({label:`${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:u.map(x=>t.unwrap(x))}),vertex:{module:m,buffers:this._vertexBufferLayouts},fragment:{module:m,targets:this._targets}},y=_chunkUMHCZDPAcjs.i.call(void 0, this);y!==void 0&&(g.label=y),r&&(_chunkUMHCZDPAcjs.M.call(void 0, r.stripIndexFormat)?g.primitive={...r,stripIndexFormat:{u32:"uint32",u16:"uint16"}[r.stripIndexFormat.type]}:g.primitive=r),n&&(g.depthStencil=n),a&&(g.multisample=a),this._memo={pipeline:o.createRenderPipeline(g),usedBindGroupLayouts:u,catchall:f},_optionalChain([_chunkUMHCZDPAcjs.h, 'optionalAccess', _137 => _137.enabled])&&(async()=>{let x=performance.mark("typegpu:compile-start");await o.queue.onSubmittedWorkDone();let b=performance.measure("typegpu:compiled",{start:x.name});_optionalChain([_chunkUMHCZDPAcjs.h, 'optionalAccess', _138 => _138.record, 'call', _139 => _139("resolution",{resolveDuration:_optionalChain([s, 'optionalAccess', _140 => _140.duration]),compileDuration:b.duration,wgslSize:p.length})])})()}return this._memo}};function To(e,t,r,n){let a={},o=new Set;function i(p,u){a[p]=u,o.add(u)}for(let[p,u]of Object.entries(e)){let f=_chunkUMHCZDPAcjs.ca.call(void 0, u);f!==void 0&&i(p,f)}for(let[p,u]of Object.entries(_nullishCoalesce(t, () => ({})))){let f=_chunkUMHCZDPAcjs.ca.call(void 0, u);f!==void 0&&(a[p]===void 0?i(p,f):a[p]!==f&&console.warn(`Mismatched location between vertexFn (${r}) output (${a[p]}) and fragmentFn (${n}) input (${f}) for the key "${p}", using the location set on vertex output.`))}let s=0;for(let p of Object.keys(_nullishCoalesce(e, () => ({}))))if(!(_chunkRC26P3MPcjs.aa.call(void 0, e[p])||a[p]!==void 0)){for(;o.has(s);)s++;i(p,s)}return a}function Zr(e){return e instanceof Ie}var Ie= (_class27 =class{constructor(t,r){;_class27.prototype.__init65.call(this);this.resourceType=t;this.buffer=r;this[_chunkUMHCZDPAcjs.d]=r,this.#t=this.buffer.as(this.resourceType)}__init65() {this[_chunkUMHCZDPAcjs.a]=!0}#t;$name(t){return _chunkUMHCZDPAcjs.j.call(void 0, this[_chunkUMHCZDPAcjs.d],t),this}write(t){this.buffer.write(t)}writePartial(t){this.buffer.writePartial(t)}read(){return this.buffer.read()}get value(){return this.#t.value}"~resolve"(t){return t.resolve(this.#t)}get $(){return this.value}}, _class27);var en=class e{constructor(t){this.bindings=t}with(t,r){return new e([...this.bindings,[Ee(t)?t.slot:t,r]])}pipe(t){let r=t(this);return new e([...this.bindings,...r.bindings])}},tn=class e{constructor(t,r){this._getRoot=t;this._slotBindings=r}with(t,r){return new e(this._getRoot,[...this._slotBindings,[Ee(t)?t.slot:t,r]])}withCompute(t){return new rn(this._getRoot(),this._slotBindings,t)}withVertex(t,r){return new nn({branch:this._getRoot(),primitiveState:void 0,depthStencilState:void 0,slotBindings:this._slotBindings,vertexFn:t,vertexAttribs:r,multisampleState:void 0})}pipe(t){let r=t(new en([]));return new e(this._getRoot,[...this._slotBindings,...r.bindings])}},rn=class{constructor(t,r,n){this._root=t;this._slotBindings=r;this._entryFn=n}createPipeline(){return fa(this._root,this._slotBindings,this._entryFn)}},nn=class{constructor(t){this._options=t}withFragment(t,r,n){return _chunkUMHCZDPAcjs.m.call(void 0, typeof t!="string","Just type mismatch validation"),_chunkUMHCZDPAcjs.m.call(void 0, typeof r!="string","Just type mismatch validation"),new an({...this._options,fragmentFn:t,targets:r})}},an=class e{constructor(t){this._options=t}withPrimitive(t){return new e({...this._options,primitiveState:t})}withDepthStencil(t){return new e({...this._options,depthStencilState:t})}withMultisample(t){return new e({...this._options,multisampleState:t})}createPipeline(){return Ta(this._options)}},Qt= (_class28 =class extends tn{constructor(r,n,a){super(()=>this,[]);_class28.prototype.__init66.call(this);_class28.prototype.__init67.call(this);_class28.prototype.__init68.call(this);_class28.prototype.__init69.call(this);;this.device=r;this.nameRegistry=n;this._ownDevice=a;this["~unstable"]=this}__init66() {this._disposables=[]}__init67() {this._unwrappedBindGroupLayouts=new ut(r=>r.unwrap(this))}__init68() {this._unwrappedBindGroups=new ut(r=>r.unwrap(this))}__init69() {this._commandEncoder=null}get commandEncoder(){return this._commandEncoder||(this._commandEncoder=this.device.createCommandEncoder()),this._commandEncoder}get enabledFeatures(){return new Set(this.device.features)}createBuffer(r,n){let a=tt(this,r,n);return this._disposables.push(a),a}createUniform(r,n){let a=tt(this,r,n).$usage("uniform");return this._disposables.push(a),new Ie("uniform",a)}createMutable(r,n){let a=tt(this,r,n).$usage("storage");return this._disposables.push(a),new Ie("mutable",a)}createReadonly(r,n){let a=tt(this,r,n).$usage("storage");return this._disposables.push(a),new Ie("readonly",a)}createQuerySet(r,n,a){return da(this,r,n,a)}createBindGroup(r,n){return new Le(r,n)}destroy(){for(let r of this._disposables)r.destroy();this._ownDevice&&this.device.destroy()}createTexture(r){let n=aa(r,this);return this._disposables.push(n),n}unwrap(r){if(ca(r))return r[_chunkUMHCZDPAcjs.a].rawPipeline;if(xa(r))return r[_chunkUMHCZDPAcjs.a].core.unwrap().pipeline;if(Lt(r))return this._unwrappedBindGroupLayouts.getOrMake(r);if(kr(r))return this._unwrappedBindGroups.getOrMake(r);if(de(r))return r.buffer;if(Z(r))return r[_chunkUMHCZDPAcjs.a].unwrap();if(ot(r)){if(r[_chunkUMHCZDPAcjs.a].unwrap)return r[_chunkUMHCZDPAcjs.a].unwrap();throw new Error("Cannot unwrap laid-out texture view.")}if(it(r)){if(r[_chunkUMHCZDPAcjs.a].unwrap)return r[_chunkUMHCZDPAcjs.a].unwrap();throw new Error("Cannot unwrap laid-out texture view.")}if(qt(r))return r.vertexLayout;if(rt(r)){if(r[_chunkUMHCZDPAcjs.a].unwrap)return r[_chunkUMHCZDPAcjs.a].unwrap(this);throw new Error("Cannot unwrap laid-out sampler.")}if(nt(r)){if(r[_chunkUMHCZDPAcjs.a].unwrap)return r[_chunkUMHCZDPAcjs.a].unwrap(this);throw new Error("Cannot unwrap laid-out comparison sampler.")}if(st(r))return r.querySet;throw new Error(`Unknown resource type: ${r}`)}beginRenderPass(r,n){let a=this.commandEncoder.beginRenderPass(r),o=new Map,i=new Map,s,p=()=>{if(!s)throw new Error("Cannot draw without a call to pass.setPipeline");let{core:u,priors:f}=s[_chunkUMHCZDPAcjs.a],m=u.unwrap();a.setPipeline(m.pipeline);let g=new Set(m.usedBindGroupLayouts);m.usedBindGroupLayouts.forEach((x,b)=>{if(m.catchall&&b===m.catchall[0])a.setBindGroup(b,this.unwrap(m.catchall[1])),g.delete(x);else{let I=_nullishCoalesce(_optionalChain([f, 'access', _141 => _141.bindGroupLayoutMap, 'optionalAccess', _142 => _142.get, 'call', _143 => _143(x)]), () => (o.get(x)));I!==void 0&&(g.delete(x),kr(I)?a.setBindGroup(b,this.unwrap(I)):a.setBindGroup(b,I))}});let y=new Set;if(u.usedVertexLayouts.forEach((x,b)=>{let I=_optionalChain([f, 'access', _144 => _144.vertexLayoutMap, 'optionalAccess', _145 => _145.get, 'call', _146 => _146(x)]),P=I?{buffer:I,offset:void 0,size:void 0}:i.get(x);!P||!P.buffer?y.add(x):de(P.buffer)?a.setVertexBuffer(b,this.unwrap(P.buffer),P.offset,P.size):a.setVertexBuffer(b,P.buffer,P.offset,P.size)}),g.size>0)throw new (0, _chunkUMHCZDPAcjs.r)(g);if(y.size>0)throw new (0, _chunkUMHCZDPAcjs.s)(y)};n({setViewport(...u){a.setViewport(...u)},setScissorRect(...u){a.setScissorRect(...u)},setBlendConstant(...u){a.setBlendConstant(...u)},setStencilReference(...u){a.setStencilReference(...u)},beginOcclusionQuery(...u){a.beginOcclusionQuery(...u)},endOcclusionQuery(...u){a.endOcclusionQuery(...u)},executeBundles(...u){a.executeBundles(...u)},setPipeline(u){s=u},setIndexBuffer:(u,f,m,g)=>{de(u)?a.setIndexBuffer(this.unwrap(u),f,m,g):a.setIndexBuffer(u,f,m,g)},setVertexBuffer(u,f,m,g){i.set(u,{buffer:f,offset:m,size:g})},setBindGroup(u,f){o.set(u,f)},draw(u,f,m,g){p(),a.draw(u,f,m,g)},drawIndexed(...u){p(),a.drawIndexed(...u)},drawIndirect(...u){p(),a.drawIndirect(...u)},drawIndexedIndirect(...u){p(),a.drawIndexedIndirect(...u)}}),a.end()}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}}, _class28);async function ha(e){let{adapter:t,device:r,unstable_names:n="random"}=_nullishCoalesce(e, () => ({}));if(!navigator.gpu)throw new Error("WebGPU is not supported by this browser.");let a=await navigator.gpu.requestAdapter(t);if(!a)throw new Error("Could not find a compatible GPU");let o=[];for(let i of _nullishCoalesce(_optionalChain([r, 'optionalAccess', _147 => _147.requiredFeatures]), () => ([]))){if(!a.features.has(i))throw new Error(`Requested feature "${i}" is not supported by the adapter.`);o.push(i)}for(let i of _nullishCoalesce(_optionalChain([r, 'optionalAccess', _148 => _148.optionalFeatures]), () => ([])))a.features.has(i)?o.push(i):console.warn(`Optional feature "${i}" is not supported by the adapter.`);return new Qt(await a.requestDevice({...r,requiredFeatures:o}),n==="random"?new pe:new le,!0)}function ba(e){let{device:t,unstable_names:r="random"}=_nullishCoalesce(e, () => ({}));return new Qt(t,r==="random"?new pe:new le,!1)}function lt(e){return new on(e)}var on= (_class29 =class{constructor(t=void 0){;_class29.prototype.__init70.call(this);_class29.prototype.__init71.call(this);this.defaultValue=t}__init70() {this[_chunkUMHCZDPAcjs.a]=!0}__init71() {this.resourceType="slot"}$name(t){return _chunkUMHCZDPAcjs.j.call(void 0, this,t),this}areEqual(t,r){return Object.is(t,r)}toString(){return`slot:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}[_chunkUMHCZDPAcjs.c](t){return Ke(t,t.unwrap(this))}get value(){let t=_chunkUMHCZDPAcjs.v.call(void 0, );if(!t)throw new Error("Cannot access tgpu.slot's value outside of resolution.");return this[_chunkUMHCZDPAcjs.c](t)}get $(){return this.value}}, _class29);function wa(e,t){return new sn(e,t)}var sn= (_class30 =class{constructor(t,r=void 0){;_class30.prototype.__init72.call(this);_class30.prototype.__init73.call(this);this.schema=t;this.defaultValue=r;this.slot=lt(r),this[_chunkUMHCZDPAcjs.d]=this.slot}__init72() {this[_chunkUMHCZDPAcjs.a]=!0}__init73() {this.resourceType="accessor"}$name(t){return this.slot.$name(t),this}toString(){return`accessor:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}[_chunkUMHCZDPAcjs.c](){return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`,[_chunkUMHCZDPAcjs.b]:this.schema},H)}get value(){if(!_chunkUMHCZDPAcjs.y.call(void 0, ))throw new Error("`tgpu.accessor` values are only accessible on the GPU");return this[_chunkUMHCZDPAcjs.c]()}get $(){return this.value}"~resolve"(t){let r=t.unwrap(this.slot);return Rn(r)||Zr(r)?t.resolve(r):hr(r)?`${t.resolve(r)}()`:t.resolveValue(r,this.schema)}}, _class30);function Sa(e){return ho(e)}function xo([e,t]){return`${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, e), () => ("<unnamed>"))}=${t}`}function ho(e){if(_chunkUMHCZDPAcjs.v.call(void 0, ))throw new Error("Cannot create tgpu.derived objects at the resolution stage.");return{resourceType:"derived","~compute":e,[_chunkUMHCZDPAcjs.f]:void 0,[_chunkUMHCZDPAcjs.g]:void 0,[_chunkUMHCZDPAcjs.c](r){return Ke(r,r.unwrap(this))},get value(){let r=_chunkUMHCZDPAcjs.v.call(void 0, );if(!r)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return this[_chunkUMHCZDPAcjs.c](r)},get $(){return this.value},with(r,n){return va(this,[[r,n]])},toString(){return"derived"}}}function va(e,t){return{resourceType:"derived",[_chunkUMHCZDPAcjs.f]:void 0,[_chunkUMHCZDPAcjs.g]:void 0,"~compute"(){throw new Error("'~compute' should never be read on bound derived items.")},[_chunkUMHCZDPAcjs.e]:{inner:e,pairs:t},[_chunkUMHCZDPAcjs.c](n){return Ke(n,n.unwrap(this))},get value(){let n=_chunkUMHCZDPAcjs.v.call(void 0, );if(!n)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return this[_chunkUMHCZDPAcjs.c](n)},get $(){return this.value},with(n,a){return va(e,[...t,[n,a]])},toString(){return`derived[${t.map(xo).join(", ")}]`}}}function Da(e,t){return new Kt("private",e,t)}function Ia(e){return new Kt("workgroup",e)}var Kt=class{constructor(t,r,n){this.scope=t;this._dataType=r;this._initialValue=n;this[_chunkUMHCZDPAcjs.a]={scope:t}}"~resolve"(t){let r=t.names.makeUnique(_chunkUMHCZDPAcjs.i.call(void 0, this));return this._initialValue?t.addDeclaration(`var<${this.scope}> ${r}: ${t.resolve(this._dataType)} = ${t.resolveValue(this._initialValue,this._dataType)};`):t.addDeclaration(`var<${this.scope}> ${r}: ${t.resolve(this._dataType)};`),r}$name(t){return _chunkUMHCZDPAcjs.j.call(void 0, this,t),this}toString(){return`var:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`}[_chunkUMHCZDPAcjs.c](){return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(_chunkUMHCZDPAcjs.i.call(void 0, this), () => ("<unnamed>"))}`,[_chunkUMHCZDPAcjs.b]:this._dataType},H)}get value(){if(!_chunkUMHCZDPAcjs.y.call(void 0, ))throw new Error("`tgpu.var` values are only accessible on the GPU");return this[_chunkUMHCZDPAcjs.c]()}};var bo={fn:xr,bindGroupLayout:kt,vertexLayout:Yr,slot:lt,init:ha,initFromDevice:ba,resolve:ma,resolveWithContext:zr,"~unstable":{fn:xr,fragmentFn:Nn,vertexFn:zn,computeFn:Wn,vertexLayout:Yr,derived:Sa,slot:lt,accessor:wa,privateVar:Da,workgroupVar:Ia,const:Cn,declare:Gn,sampler:Zn,comparisonSampler:ea}},um= exports.default =bo;exports.MissingBindGroupsError = _chunkUMHCZDPAcjs.r; exports.MissingLinksError = _chunkUMHCZDPAcjs.q; exports.MissingSlotValueError = _chunkUMHCZDPAcjs.o; exports.MissingVertexBuffersError = _chunkUMHCZDPAcjs.s; exports.NotUniformError = _chunkUMHCZDPAcjs.p; exports.RandomNameRegistry = pe; exports.ResolutionError = _chunkUMHCZDPAcjs.n; exports.StrictNameRegistry = le; exports.default = um; exports.isBuffer = de; exports.isBufferShorthand = Zr; exports.isComparisonSampler = nt; exports.isDerived = Ve; exports.isSampledTextureView = it; exports.isSampler = rt; exports.isSlot = Ge; exports.isStorageTextureView = ot; exports.isTexture = Z; exports.isTgpuFn = hr; exports.isUsableAsRender = so; exports.isUsableAsSampled = Vr; exports.isUsableAsStorage = ve; exports.isUsableAsUniform = Bt; exports.isUsableAsVertex = io; exports.tgpu = bo; exports.unstable_asMutable = Ir; exports.unstable_asReadonly = Ur; exports.unstable_asUniform = Fr;
30
31
  //# sourceMappingURL=index.cjs.map