typegpu 0.8.0-alpha.2 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +33 -6
  2. package/chunk-2UXPGML5.js +7 -0
  3. package/chunk-2UXPGML5.js.map +1 -0
  4. package/chunk-3246CM7C.cjs +2 -0
  5. package/chunk-3246CM7C.cjs.map +1 -0
  6. package/{chunk-BDGVKGU4.js → chunk-4W5Z7BO4.js} +6 -6
  7. package/chunk-4W5Z7BO4.js.map +1 -0
  8. package/{chunk-ESIHND6W.cjs → chunk-5Y6GTBWR.cjs} +3 -3
  9. package/{chunk-ESIHND6W.cjs.map → chunk-5Y6GTBWR.cjs.map} +1 -1
  10. package/{chunk-DH4X56C7.js → chunk-7S3IK3D4.js} +2 -2
  11. package/{chunk-MJ6A4DOA.js → chunk-7XFSK632.js} +2 -2
  12. package/{chunk-WDMOZFKN.cjs → chunk-PRMFGUQT.cjs} +2 -2
  13. package/{chunk-WDMOZFKN.cjs.map → chunk-PRMFGUQT.cjs.map} +1 -1
  14. package/{chunk-44LAYHPR.cjs → chunk-TRE7NUKE.cjs} +6 -6
  15. package/chunk-TRE7NUKE.cjs.map +1 -0
  16. package/chunk-VOVQAOVG.js +2 -0
  17. package/chunk-VOVQAOVG.js.map +1 -0
  18. package/chunk-ZYGTVBDH.cjs +7 -0
  19. package/chunk-ZYGTVBDH.cjs.map +1 -0
  20. package/common/index.cjs +1 -1
  21. package/common/index.d.cts +1 -1
  22. package/common/index.d.ts +1 -1
  23. package/common/index.js +1 -1
  24. package/data/index.cjs +1 -1
  25. package/data/index.d.cts +3 -3
  26. package/data/index.d.ts +3 -3
  27. package/data/index.js +1 -1
  28. package/index.cjs +51 -51
  29. package/index.cjs.map +1 -1
  30. package/index.d.cts +2 -2
  31. package/index.d.ts +2 -2
  32. package/index.js +40 -40
  33. package/index.js.map +1 -1
  34. package/{matrix-UOB09LaW.d.cts → matrix-DHFT4O8f.d.cts} +1 -1
  35. package/{matrix-CjLuYXH1.d.ts → matrix-DLipCOZF.d.ts} +1 -1
  36. package/package.json +2 -2
  37. package/std/index.cjs +1 -1
  38. package/std/index.cjs.map +1 -1
  39. package/std/index.d.cts +2 -2
  40. package/std/index.d.ts +2 -2
  41. package/std/index.js +1 -1
  42. package/std/index.js.map +1 -1
  43. package/{tgpuConstant-sKeoSjPD.d.ts → tgpuConstant-BU72w5qs.d.cts} +15 -13
  44. package/{tgpuConstant-sKeoSjPD.d.cts → tgpuConstant-BU72w5qs.d.ts} +15 -13
  45. package/chunk-44LAYHPR.cjs.map +0 -1
  46. package/chunk-6OJFCDQF.js +0 -7
  47. package/chunk-6OJFCDQF.js.map +0 -1
  48. package/chunk-BDGVKGU4.js.map +0 -1
  49. package/chunk-CODEFPMD.cjs +0 -2
  50. package/chunk-CODEFPMD.cjs.map +0 -1
  51. package/chunk-HLB6TY7I.cjs +0 -7
  52. package/chunk-HLB6TY7I.cjs.map +0 -1
  53. package/chunk-ZYSFFI3M.js +0 -2
  54. package/chunk-ZYSFFI3M.js.map +0 -1
  55. /package/{chunk-DH4X56C7.js.map → chunk-7S3IK3D4.js.map} +0 -0
  56. /package/{chunk-MJ6A4DOA.js.map → chunk-7XFSK632.js.map} +0 -0
package/README.md CHANGED
@@ -8,12 +8,39 @@
8
8
 
9
9
  </div>
10
10
 
11
- **TypeGPU** is a TypeScript library that enhances the WebGPU API, allowing
12
- resource management in a type-safe, declarative way.
13
-
14
- <div align="center">
15
- <video autoplay muted loop playsinline src="https://github.com/user-attachments/assets/5bca716d-477d-44a1-a839-5df0c8d9044c"></video>
16
- </div>
11
+ **TypeGPU** is a modular and open-ended toolkit for WebGPU, with advanced type
12
+ inference and the ability to write shaders in TypeScript.
13
+
14
+ ```ts
15
+ const neighborhood = (a: number, r: number) => {
16
+ 'use gpu';
17
+ return d.vec2f(a - r, a + r);
18
+ };
19
+
20
+ //
21
+ // #1) Can be called in JS
22
+ //
23
+ const range = neighborhood(1.1, 0.5);
24
+ // ^? d.v2f
25
+
26
+ //
27
+ // #2) Used to generate WGSL
28
+ //
29
+ const main = () => {
30
+ 'use gpu';
31
+ return neighborhood(1.1, 0.5);
32
+ };
33
+
34
+ const wgsl = tgpu.resolve({ externals: { main } });
35
+ // ^? string
36
+
37
+ //
38
+ // #3) Executed on the GPU (generates WGSL underneath)
39
+ //
40
+ root['~unstable']
41
+ .createGuardedComputePipeline(main)
42
+ .dispatchThreads();
43
+ ```
17
44
 
18
45
  ## Documentation
19
46
 
@@ -0,0 +1,7 @@
1
+ import{$a as Oe,A as wt,C as Se,D as Le,Da as Qt,E as St,Ea as o,Ha as F,Ia as lt,Ja as $t,Ka as Xt,La as W,Ma as B,N as H,Na as u,O as ut,Oa as ge,Pa as C,Q as Ot,Qa as Q,R as Kt,Ra as P,S as qt,Ta as xe,Ua as T,V as jt,Va as V,W as k,X as Mt,Xa as R,Y as It,Ya as re,Z as At,Za as se,_ as ct,_a as Ne,a as l,aa as c,ab as G,b as Ge,ba as Zt,bb as ae,ca as Ht,cb as oe,db as Ke,e as ot,eb as qe,f as D,fb as E,g as de,gb as ue,h as Lt,hb as ce,ib as je,j as fe,jb as Ze,k as Nt,kb as He,la as ne,lb as Yt,r as v,sc as I,tc as Jt,ua as it,v as Ee,w as Z,z as bt}from"./chunk-4W5Z7BO4.js";var Qe=class{};function Wt(e){let t=W((...r)=>{let a=[];for(let s of r)if(typeof s=="number")a.push(s);else for(let i=0;i<s.length;++i)a.push(s[i]);if(a.length!==0&&a.length!==e.columns*e.rows)throw new Error(`'${e.type}' constructor called with invalid number of arguments.`);for(let s=a.length;s<e.columns*e.rows;++s)a.push(0);return new e.MatImpl(...a)},(...r)=>c(o`${e.type}(${r})`,n),e.type),n=Object.assign(t,{type:e.type,identity:fn[e.columns],translation:e.columns===4?gn:void 0,scaling:e.columns===4?hn:void 0,rotationX:e.columns===4?vn:void 0,rotationY:e.columns===4?bn:void 0,rotationZ:e.columns===4?wn:void 0});return n}var zt=class extends Qe{[l]=!0;columns;length=4;constructor(...t){super(),this.columns=[this.makeColumn(t[0],t[1]),this.makeColumn(t[2],t[3])]}get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[1].x}get 3(){return this.columns[1].y}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[1].x=t}set 3(t){this.columns[1].y=t}*[Symbol.iterator](){yield this[0],yield this[1],yield this[2],yield this[3]}[D](){return c(`${this.kind}(${Array.from({length:this.length}).map((t,n)=>this[n]).join(", ")})`,ie)}toString(){return this[D]().value}},Vt=class extends zt{kind="mat2x2f";makeColumn(t,n){return R(t,n)}},Ft=class extends Qe{[l]=!0;columns;length=12;constructor(...t){super(),this.columns=[this.makeColumn(t[0],t[1],t[2]),this.makeColumn(t[3],t[4],t[5]),this.makeColumn(t[6],t[7],t[8])]}get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[0].z}get 3(){return 0}get 4(){return this.columns[1].x}get 5(){return this.columns[1].y}get 6(){return this.columns[1].z}get 7(){return 0}get 8(){return this.columns[2].x}get 9(){return this.columns[2].y}get 10(){return this.columns[2].z}get 11(){return 0}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[0].z=t}set 3(t){}set 4(t){this.columns[1].x=t}set 5(t){this.columns[1].y=t}set 6(t){this.columns[1].z=t}set 7(t){}set 8(t){this.columns[2].x=t}set 9(t){this.columns[2].y=t}set 10(t){this.columns[2].z=t}set 11(t){}*[Symbol.iterator](){for(let t=0;t<12;t++)yield this[t]}[D](){return c(`${this.kind}(${this[0]}, ${this[1]}, ${this[2]}, ${this[4]}, ${this[5]}, ${this[6]}, ${this[8]}, ${this[9]}, ${this[10]})`,le)}toString(){return this[D]().value}},Ct=class extends Ft{kind="mat3x3f";makeColumn(t,n,r){return G(t,n,r)}},Pt=class extends Qe{[l]=!0;columns;constructor(...t){super(),this.columns=[this.makeColumn(t[0],t[1],t[2],t[3]),this.makeColumn(t[4],t[5],t[6],t[7]),this.makeColumn(t[8],t[9],t[10],t[11]),this.makeColumn(t[12],t[13],t[14],t[15])]}length=16;get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[0].z}get 3(){return this.columns[0].w}get 4(){return this.columns[1].x}get 5(){return this.columns[1].y}get 6(){return this.columns[1].z}get 7(){return this.columns[1].w}get 8(){return this.columns[2].x}get 9(){return this.columns[2].y}get 10(){return this.columns[2].z}get 11(){return this.columns[2].w}get 12(){return this.columns[3].x}get 13(){return this.columns[3].y}get 14(){return this.columns[3].z}get 15(){return this.columns[3].w}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[0].z=t}set 3(t){this.columns[0].w=t}set 4(t){this.columns[1].x=t}set 5(t){this.columns[1].y=t}set 6(t){this.columns[1].z=t}set 7(t){this.columns[1].w=t}set 8(t){this.columns[2].x=t}set 9(t){this.columns[2].y=t}set 10(t){this.columns[2].z=t}set 11(t){this.columns[2].w=t}set 12(t){this.columns[3].x=t}set 13(t){this.columns[3].y=t}set 14(t){this.columns[3].z=t}set 15(t){this.columns[3].w=t}*[Symbol.iterator](){for(let t=0;t<16;t++)yield this[t]}[D](){return c(`${this.kind}(${Array.from({length:this.length}).map((t,n)=>this[n]).join(", ")})`,A)}toString(){return this[D]().value}},kt=class extends Pt{kind="mat4x4f";makeColumn(t,n,r,a){return E(t,n,r,a)}},Tn=W(()=>ie(1,0,0,1),()=>c("mat2x2f(1, 0, 0, 1)",ie),"identity2"),xn=W(()=>le(1,0,0,0,1,0,0,0,1),()=>c("mat3x3f(1, 0, 0, 0, 1, 0, 0, 0, 1)",le),"identity3"),dn=W(()=>A(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),()=>c("mat4x4f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)",A),"identity4"),fn={2:Tn,3:xn,4:dn},gn=W(e=>A(1,0,0,0,0,1,0,0,0,0,1,0,e.x,e.y,e.z,1),e=>c(o`mat4x4f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, ${e}.x, ${e}.y, ${e}.z, 1)`,A),"translation4"),hn=W(e=>A(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1),e=>c(o`mat4x4f(${e}.x, 0, 0, 0, 0, ${e}.y, 0, 0, 0, 0, ${e}.z, 0, 0, 0, 0, 1)`,A),"scaling4"),vn=W(e=>A(1,0,0,0,0,Math.cos(e),Math.sin(e),0,0,-Math.sin(e),Math.cos(e),0,0,0,0,1),e=>c(o`mat4x4f(1, 0, 0, 0, 0, cos(${e}), sin(${e}), 0, 0, -sin(${e}), cos(${e}), 0, 0, 0, 0, 1)`,A),"rotationX4"),bn=W(e=>A(Math.cos(e),0,-Math.sin(e),0,0,1,0,0,Math.sin(e),0,Math.cos(e),0,0,0,0,1),e=>c(o`mat4x4f(cos(${e}), 0, -sin(${e}), 0, 0, 1, 0, 0, sin(${e}), 0, cos(${e}), 0, 0, 0, 0, 1)`,A),"rotationY4"),wn=W(e=>A(Math.cos(e),Math.sin(e),0,0,-Math.sin(e),Math.cos(e),0,0,0,0,1,0,0,0,0,1),e=>c(o`mat4x4f(cos(${e}), sin(${e}), 0, 0, -sin(${e}), cos(${e}), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)`,A),"rotationZ4"),ie=Wt({type:"mat2x2f",rows:2,columns:2,MatImpl:Vt}),le=Wt({type:"mat3x3f",rows:3,columns:3,MatImpl:Ct}),A=Wt({type:"mat4x4f",rows:4,columns:4,MatImpl:kt});function Hr(e){return e.kind==="mat3x3f"?[e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]]:Array.from({length:e.length}).map((t,n)=>e[n])}function en(e){return e?.[Ge]}var Sn={f:{1:T,2:R,3:G,4:E},h:{1:V,2:re,3:ae,4:ue},i:{1:xe,2:se,3:oe,4:ce},u:{1:P,2:Ne,3:Ke,4:je},b:{1:Q,2:Oe,3:qe,4:Ze}},Mn={vec2f:R,vec2h:re,vec2i:se,vec2u:Ne,"vec2<bool>":Oe,vec3f:G,vec3h:ae,vec3i:oe,vec3u:Ke,"vec3<bool>":qe,vec4f:E,vec4h:ue,vec4i:ce,vec4u:je,"vec4<bool>":Ze,mat2x2f:ie,mat3x3f:le,mat4x4f:A};function Xe(e,t){if(Le(e)||qt(e))return e.propTypes[t]??k;if(e===Q||H(e))return k;let n=t.length;if(Ee(e)&&n>=1&&n<=4){let r=e.type.includes("bool")?"b":e.type[4],a=Sn[r][n];if(a)return a}return k}var tn={mat2x2f:R,mat3x3f:G,mat4x4f:E};function mt(e){return Se(e)||Kt(e)?e.elementType:Ee(e)?e.primitive:e.type in tn?tn[e.type]:k}function pt(e){return e>=2**63||e<-(2**63)?c(e,C):Number.isInteger(e)?(Number.isSafeInteger(e)||console.warn(`The integer ${e} exceeds the safe integer range and may have lost precision.`),c(e,ge)):c(e,C)}function yt(e){return e.type==="abstractFloat"?T:e.type==="abstractInt"?xe:e}function os(e){return e.map(t=>c(t.value,yt(t.dataType)))}function Tt(e){if(ct(e))return e;let t=it(e);return t||(v(e)||Z(e)?c(e,Mn[e.kind]):typeof e=="string"||typeof e=="function"||typeof e=="object"||typeof e=="symbol"||typeof e>"u"||e===null?c(e,k):typeof e=="number"?pt(e):typeof e=="boolean"?c(e,Q):c(e,k))}var _t={get(e,t){if(t in e)return Reflect.get(e,t);if(t==="toString"||t===Symbol.toStringTag||t===Symbol.toPrimitive)return()=>e.toString();if(typeof t=="symbol")return;let r=it(e).dataType,a=Xe(r,String(t));if(a.type!=="unknown")return new Proxy({[l]:!0,[D]:s=>c(`${s.resolve(e).value}.${String(t)}`,a),get[ot](){return c(this,a)},toString:()=>`${String(e)}.${t}`},_t)}};function ys(e){let t=e;for(;;){let n=en(t);if(!n)break;t=n}return t}function nn(e,t){return new Ut(e,t)}var Ut=class{constructor(t,n){this.dataType=t;this.#e=n}[l]={};#e;$name(t){return Nt(this,t),this}[D](t){let n=t.getUniqueName(this),r=t.resolve(this.dataType).value,a=t.resolve(this.#e,this.dataType).value;return t.addDeclaration(`const ${n}: ${r} = ${a};`),c(n,this.dataType)}toString(){return`const:${fe(this)??"<unnamed>"}`}get[Ge](){let t=this.dataType;return new Proxy({[l]:!0,get[ot](){return c(this,t)},[D]:n=>n.resolve(this),toString:()=>`const:${fe(this)??"<unnamed>"}.$`},_t)}get value(){return Qt()?this[Ge]:this.#e}get $(){return this.value}};function ws(){return{[l]:!0,type:"sampler",[de]:void 0}}function Ss(){return{[l]:!0,type:"sampler_comparison",[de]:void 0}}function Ms(e){return!!e[l]&&e.type==="sampler"}function Is(e){return!!e[l]&&e.type==="sampler_comparison"}function Vs(e){if("multisampled"in e){if(e.multisampled){if(e.dimension==="2d")return $n(e.sampleType);throw new Error(`Multisampled textures only support '2d' dimension, got '${e.dimension}'`)}switch(e.dimension){case"1d":return In(e.sampleType);case"2d":return An(e.sampleType);case"2d-array":return zn(e.sampleType);case"3d":return Cn(e.sampleType);case"cube":return Vn(e.sampleType);case"cube-array":return Fn(e.sampleType);default:throw new Error(`Unsupported texture dimension: '${e.dimension}'`)}}if(!("access"in e))throw new Error("Descriptor is neither a sampled nor a storage texture");switch(e.dimension){case"1d":return Pn(e.format,e.access);case"2d":return kn(e.format,e.access);case"2d-array":return Wn(e.format,e.access);case"3d":return _n(e.format,e.access);default:throw new Error(`Unsupported storage texture dimension: '${e.dimension}'`)}}function L(e,t){let r=e.startsWith("texture_depth")?["depth","float","unfilterable-float"]:t.sampleType.type==="i32"?["sint"]:t.sampleType.type==="u32"?["uint"]:["float","unfilterable-float"];return{[l]:!0,[de]:void 0,type:e,bindingSampleType:r,...t}}function xt(e,t){return{[l]:!0,[de]:void 0,type:e,...t}}var rn=new Map,dt={"write-only":"write","read-only":"read","read-write":"read_write"};function $(e,t){let n=rn.get(e);return n||(n=t(),rn.set(e,n)),n}function In(e){let t=e||T,n=`texture_1d<${t.type}>`;return $(n,()=>L("texture_1d",{dimension:"1d",sampleType:t,multisampled:!1}))}function An(e){let t=e||T,n=`texture_2d<${t.type}>`;return $(n,()=>L("texture_2d",{dimension:"2d",sampleType:t,multisampled:!1}))}function $n(e){let t=e||T,n=`texture_multisampled_2d<${t.type}>`;return $(n,()=>L("texture_multisampled_2d",{dimension:"2d",sampleType:t,multisampled:!0}))}function zn(e){let t=e||T,n=`texture_2d_array<${t.type}>`;return $(n,()=>L("texture_2d_array",{dimension:"2d-array",sampleType:t,multisampled:!1}))}function Vn(e){let t=e||T,n=`texture_cube<${t.type}>`;return $(n,()=>L("texture_cube",{dimension:"cube",sampleType:t,multisampled:!1}))}function Fn(e){let t=e||T,n=`texture_cube_array<${t.type}>`;return $(n,()=>L("texture_cube_array",{dimension:"cube-array",sampleType:t,multisampled:!1}))}function Cn(e){let t=e||T,n=`texture_3d<${t.type}>`;return $(n,()=>L("texture_3d",{dimension:"3d",sampleType:t,multisampled:!1}))}function Pn(e,t){let n=t||"write-only",r=`texture_storage_1d<${e}, ${dt[n]}>`;return $(r,()=>xt("texture_storage_1d",{dimension:"1d",format:e,access:n}))}function kn(e,t){let n=t||"write-only",r=`texture_storage_2d<${e}, ${dt[n]}>`;return $(r,()=>xt("texture_storage_2d",{dimension:"2d",format:e,access:n}))}function Wn(e,t){let n=t||"write-only",r=`texture_storage_2d_array<${e}, ${dt[n]}>`;return $(r,()=>xt("texture_storage_2d_array",{dimension:"2d-array",format:e,access:n}))}function _n(e,t){let n=t||"write-only",r=`texture_storage_3d<${e}, ${dt[n]}>`;return $(r,()=>xt("texture_storage_3d",{dimension:"3d",format:e,access:n}))}function Fs(){return $("texture_depth_2d",()=>L("texture_depth_2d",{dimension:"2d",sampleType:T,multisampled:!1}))}function Cs(){return $("texture_depth_multisampled_2d",()=>L("texture_depth_multisampled_2d",{dimension:"2d",sampleType:T,multisampled:!0}))}function Ps(){return $("texture_depth_2d_array",()=>L("texture_depth_2d_array",{dimension:"2d-array",sampleType:T,multisampled:!1}))}function ks(){return $("texture_depth_cube",()=>L("texture_depth_cube",{dimension:"cube",sampleType:T,multisampled:!1}))}function Ws(){return $("texture_depth_cube_array",()=>L("texture_depth_cube_array",{dimension:"cube-array",sampleType:T,multisampled:!1}))}function _s(){return $("texture_external",()=>({[l]:!0,[de]:void 0,type:"texture_external",dimension:"2d"}))}function Us(e){return!!e[l]&&typeof e.multisampled=="boolean"}function Ds(e){return!!e[l]&&typeof e.format=="string"&&typeof e.access=="string"}function Gs(e){return new Dt(e)}var Dt=class{constructor(t){this.inner=t}[l]=!0;type="atomic"};var me=(e,t,n)=>{if(e===t)return 0;let r=y((n-e)/(t-e),0,1);return r*r*(3-2*r)},y=(e,t,n)=>Math.min(Math.max(t,e),n),he=(e,t)=>t===0?e:Math.trunc(e/t);function Y(e){let t=new DataView(new ArrayBuffer(4));return t.setUint32(0,e,!0),t.getFloat32(0,!0)}function J(e){let t=new DataView(new ArrayBuffer(4));return t.setUint32(0,e,!0),t.getInt32(0,!0)}var N=Oe[l].jsImpl,q=R[l].jsImpl,ye=re[l].jsImpl,Ue=se[l].jsImpl,tt=Ne[l].jsImpl,O=qe[l].jsImpl,_=G[l].jsImpl,ee=ae[l].jsImpl,De=oe[l].jsImpl,nt=Ke[l].jsImpl,K=Ze[l].jsImpl,j=E[l].jsImpl,Te=ue[l].jsImpl,Be=ce[l].jsImpl,rt=je[l].jsImpl,Me=e=>Math.sqrt(e.x**2+e.y**2),Ie=e=>Math.sqrt(e.x**2+e.y**2+e.z**2),Ae=e=>Math.sqrt(e.x**2+e.y**2+e.z**2+e.w**2),ft=(e,t)=>e.x*t.x+e.y*t.y,gt=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z,ht=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,h=e=>t=>q(e(t.x),e(t.y)),b=e=>t=>ye(e(t.x),e(t.y)),$e=e=>t=>Ue(e(t.x),e(t.y)),Ye=e=>t=>tt(e(t.x),e(t.y)),f=e=>t=>_(e(t.x),e(t.y),e(t.z)),w=e=>t=>ee(e(t.x),e(t.y),e(t.z)),ze=e=>t=>De(e(t.x),e(t.y),e(t.z)),Je=e=>t=>nt(e(t.x),e(t.y),e(t.z)),x=e=>t=>j(e(t.x),e(t.y),e(t.z),e(t.w)),S=e=>t=>Te(e(t.x),e(t.y),e(t.z),e(t.w)),Ve=e=>t=>Be(e(t.x),e(t.y),e(t.z),e(t.w)),et=e=>t=>rt(e(t.x),e(t.y),e(t.z),e(t.w)),sn=e=>t=>{let n=t.columns;return ie(h(e)(n[0]),h(e)(n[1]))},an=e=>t=>{let n=t.columns;return le(f(e)(n[0]),f(e)(n[1]),f(e)(n[2]))},on=e=>t=>{let n=t.columns;return A(x(e)(n[0]),x(e)(n[1]),x(e)(n[2]),x(e)(n[3]))},pe=e=>(t,n)=>q(e(t.x,n.x),e(t.y,n.y)),ve=e=>(t,n)=>ye(e(t.x,n.x),e(t.y,n.y)),Fe=e=>(t,n)=>Ue(e(t.x,n.x),e(t.y,n.y)),Ce=e=>(t,n)=>tt(e(t.x,n.x),e(t.y,n.y)),te=e=>(t,n)=>_(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),be=e=>(t,n)=>ee(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),Pe=e=>(t,n)=>De(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),ke=e=>(t,n)=>nt(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),X=e=>(t,n)=>j(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),we=e=>(t,n)=>Te(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),We=e=>(t,n)=>Be(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),_e=e=>(t,n)=>rt(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),Un=e=>(t,n)=>{let r=t.columns,a=n.columns;return ie(pe(e)(r[0],a[0]),pe(e)(r[1],a[1]))},Dn=e=>(t,n)=>{let r=t.columns,a=n.columns;return le(te(e)(r[0],a[0]),te(e)(r[1],a[1]),te(e)(r[2],a[2]))},Bn=e=>(t,n)=>{let r=t.columns,a=n.columns;return A(X(e)(r[0],a[0]),X(e)(r[1],a[1]),X(e)(r[2],a[2]),X(e)(r[3],a[3]))},Rn=e=>(t,n,r)=>q(e(t.x,n.x,r.x),e(t.y,n.y,r.y)),Gn=e=>(t,n,r)=>ye(e(t.x,n.x,r.x),e(t.y,n.y,r.y)),En=e=>(t,n,r)=>_(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z)),Ln=e=>(t,n,r)=>ee(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z)),Nn=e=>(t,n,r)=>j(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z),e(t.w,n.w,r.w)),On=e=>(t,n,r)=>Te(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z),e(t.w,n.w,r.w)),m={eq:{vec2f:(e,t)=>N(e.x===t.x,e.y===t.y),vec2h:(e,t)=>N(e.x===t.x,e.y===t.y),vec2i:(e,t)=>N(e.x===t.x,e.y===t.y),vec2u:(e,t)=>N(e.x===t.x,e.y===t.y),"vec2<bool>":(e,t)=>N(e.x===t.x,e.y===t.y),vec3f:(e,t)=>O(e.x===t.x,e.y===t.y,e.z===t.z),vec3h:(e,t)=>O(e.x===t.x,e.y===t.y,e.z===t.z),vec3i:(e,t)=>O(e.x===t.x,e.y===t.y,e.z===t.z),vec3u:(e,t)=>O(e.x===t.x,e.y===t.y,e.z===t.z),"vec3<bool>":(e,t)=>O(e.x===t.x,e.y===t.y,e.z===t.z),vec4f:(e,t)=>K(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4h:(e,t)=>K(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4i:(e,t)=>K(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4u:(e,t)=>K(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),"vec4<bool>":(e,t)=>K(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w)},lt:{vec2f:(e,t)=>N(e.x<t.x,e.y<t.y),vec2h:(e,t)=>N(e.x<t.x,e.y<t.y),vec2i:(e,t)=>N(e.x<t.x,e.y<t.y),vec2u:(e,t)=>N(e.x<t.x,e.y<t.y),vec3f:(e,t)=>O(e.x<t.x,e.y<t.y,e.z<t.z),vec3h:(e,t)=>O(e.x<t.x,e.y<t.y,e.z<t.z),vec3i:(e,t)=>O(e.x<t.x,e.y<t.y,e.z<t.z),vec3u:(e,t)=>O(e.x<t.x,e.y<t.y,e.z<t.z),vec4f:(e,t)=>K(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4h:(e,t)=>K(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4i:(e,t)=>K(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4u:(e,t)=>K(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w)},or:{"vec2<bool>":(e,t)=>N(e.x||t.x,e.y||t.y),"vec3<bool>":(e,t)=>O(e.x||t.x,e.y||t.y,e.z||t.z),"vec4<bool>":(e,t)=>K(e.x||t.x,e.y||t.y,e.z||t.z,e.w||t.w)},all:{"vec2<bool>":e=>e.x&&e.y,"vec3<bool>":e=>e.x&&e.y&&e.z,"vec4<bool>":e=>e.x&&e.y&&e.z&&e.w},abs:{vec2f:h(Math.abs),vec2h:b(Math.abs),vec2i:$e(Math.abs),vec2u:Ye(Math.abs),vec3f:f(Math.abs),vec3h:w(Math.abs),vec3i:ze(Math.abs),vec3u:Je(Math.abs),vec4f:x(Math.abs),vec4h:S(Math.abs),vec4i:Ve(Math.abs),vec4u:et(Math.abs)},atan2:{vec2f:pe(Math.atan2),vec2h:ve(Math.atan2),vec3f:te(Math.atan2),vec3h:be(Math.atan2),vec4f:X(Math.atan2),vec4h:we(Math.atan2)},acos:{vec2f:h(Math.acos),vec2h:b(Math.acos),vec2i:$e(Math.acos),vec2u:Ye(Math.acos),vec3f:f(Math.acos),vec3h:w(Math.acos),vec3i:ze(Math.acos),vec3u:Je(Math.acos),vec4f:x(Math.acos),vec4h:S(Math.acos),vec4i:Ve(Math.acos),vec4u:et(Math.acos)},acosh:{vec2f:h(Math.acosh),vec2h:b(Math.acosh),vec3f:f(Math.acosh),vec3h:w(Math.acosh),vec4f:x(Math.acosh),vec4h:S(Math.acosh)},asin:{vec2f:h(Math.asin),vec2h:b(Math.asin),vec3f:f(Math.asin),vec3h:w(Math.asin),vec4f:x(Math.asin),vec4h:S(Math.asin)},asinh:{vec2f:h(Math.asinh),vec2h:b(Math.asinh),vec3f:f(Math.asinh),vec3h:w(Math.asinh),vec4f:x(Math.asinh),vec4h:S(Math.asinh)},atan:{vec2f:h(Math.atan),vec2h:b(Math.atan),vec3f:f(Math.atan),vec3h:w(Math.atan),vec4f:x(Math.atan),vec4h:S(Math.atan)},atanh:{vec2f:h(Math.atanh),vec2h:b(Math.atanh),vec3f:f(Math.atanh),vec3h:w(Math.atanh),vec4f:x(Math.atanh),vec4h:S(Math.atanh)},ceil:{vec2f:h(Math.ceil),vec2h:b(Math.ceil),vec3f:f(Math.ceil),vec3h:w(Math.ceil),vec4f:x(Math.ceil),vec4h:S(Math.ceil)},clamp:{vec2f:(e,t,n)=>q(y(e.x,t.x,n.x),y(e.y,t.y,n.y)),vec2h:(e,t,n)=>ye(y(e.x,t.x,n.x),y(e.y,t.y,n.y)),vec2i:(e,t,n)=>Ue(y(e.x,t.x,n.x),y(e.y,t.y,n.y)),vec2u:(e,t,n)=>tt(y(e.x,t.x,n.x),y(e.y,t.y,n.y)),vec3f:(e,t,n)=>_(y(e.x,t.x,n.x),y(e.y,t.y,n.y),y(e.z,t.z,n.z)),vec3h:(e,t,n)=>ee(y(e.x,t.x,n.x),y(e.y,t.y,n.y),y(e.z,t.z,n.z)),vec3i:(e,t,n)=>De(y(e.x,t.x,n.x),y(e.y,t.y,n.y),y(e.z,t.z,n.z)),vec3u:(e,t,n)=>nt(y(e.x,t.x,n.x),y(e.y,t.y,n.y),y(e.z,t.z,n.z)),vec4f:(e,t,n)=>j(y(e.x,t.x,n.x),y(e.y,t.y,n.y),y(e.z,t.z,n.z),y(e.w,t.w,n.w)),vec4h:(e,t,n)=>Te(y(e.x,t.x,n.x),y(e.y,t.y,n.y),y(e.z,t.z,n.z),y(e.w,t.w,n.w)),vec4i:(e,t,n)=>Be(y(e.x,t.x,n.x),y(e.y,t.y,n.y),y(e.z,t.z,n.z),y(e.w,t.w,n.w)),vec4u:(e,t,n)=>rt(y(e.x,t.x,n.x),y(e.y,t.y,n.y),y(e.z,t.z,n.z),y(e.w,t.w,n.w))},length:{vec2f:Me,vec2h:Me,vec3f:Ie,vec3h:Ie,vec4f:Ae,vec4h:Ae},add:{vec2f:pe((e,t)=>e+t),vec2h:ve((e,t)=>e+t),vec2i:Fe((e,t)=>e+t),vec2u:Ce((e,t)=>e+t),vec3f:te((e,t)=>e+t),vec3h:be((e,t)=>e+t),vec3i:Pe((e,t)=>e+t),vec3u:ke((e,t)=>e+t),vec4f:X((e,t)=>e+t),vec4h:we((e,t)=>e+t),vec4i:We((e,t)=>e+t),vec4u:_e((e,t)=>e+t),mat2x2f:Un((e,t)=>e+t),mat3x3f:Dn((e,t)=>e+t),mat4x4f:Bn((e,t)=>e+t)},smoothstep:{vec2f:Rn(me),vec2h:Gn(me),vec3f:En(me),vec3h:Ln(me),vec4f:Nn(me),vec4h:On(me)},addMixed:{vec2f:(e,t)=>h(n=>n+t)(e),vec2h:(e,t)=>b(n=>n+t)(e),vec2i:(e,t)=>$e(n=>n+t)(e),vec2u:(e,t)=>Ye(n=>n+t)(e),vec3f:(e,t)=>f(n=>n+t)(e),vec3h:(e,t)=>w(n=>n+t)(e),vec3i:(e,t)=>ze(n=>n+t)(e),vec3u:(e,t)=>Je(n=>n+t)(e),vec4f:(e,t)=>x(n=>n+t)(e),vec4h:(e,t)=>S(n=>n+t)(e),vec4i:(e,t)=>Ve(n=>n+t)(e),vec4u:(e,t)=>et(n=>n+t)(e),mat2x2f:(e,t)=>sn(n=>n+t)(e),mat3x3f:(e,t)=>an(n=>n+t)(e),mat4x4f:(e,t)=>on(n=>n+t)(e)},mulSxV:{vec2f:(e,t)=>h(n=>e*n)(t),vec2h:(e,t)=>b(n=>e*n)(t),vec2i:(e,t)=>$e(n=>e*n)(t),vec2u:(e,t)=>Ye(n=>e*n)(t),vec3f:(e,t)=>f(n=>e*n)(t),vec3h:(e,t)=>w(n=>e*n)(t),vec3i:(e,t)=>ze(n=>e*n)(t),vec3u:(e,t)=>Je(n=>e*n)(t),vec4f:(e,t)=>x(n=>e*n)(t),vec4h:(e,t)=>S(n=>e*n)(t),vec4i:(e,t)=>Ve(n=>e*n)(t),vec4u:(e,t)=>et(n=>e*n)(t),mat2x2f:(e,t)=>sn(n=>e*n)(t),mat3x3f:(e,t)=>an(n=>e*n)(t),mat4x4f:(e,t)=>on(n=>e*n)(t)},mulVxV:{vec2f:pe((e,t)=>e*t),vec2h:ve((e,t)=>e*t),vec2i:Fe((e,t)=>e*t),vec2u:Ce((e,t)=>e*t),vec3f:te((e,t)=>e*t),vec3h:be((e,t)=>e*t),vec3i:Pe((e,t)=>e*t),vec3u:ke((e,t)=>e*t),vec4f:X((e,t)=>e*t),vec4h:we((e,t)=>e*t),vec4i:We((e,t)=>e*t),vec4u:_e((e,t)=>e*t),mat2x2f:(e,t)=>{let n=e.columns,r=t.columns;return ie(n[0].x*r[0].x+n[1].x*r[0].y,n[0].y*r[0].x+n[1].y*r[0].y,n[0].x*r[1].x+n[1].x*r[1].y,n[0].y*r[1].x+n[1].y*r[1].y)},mat3x3f:(e,t)=>{let n=e.columns,r=t.columns;return le(n[0].x*r[0].x+n[1].x*r[0].y+n[2].x*r[0].z,n[0].y*r[0].x+n[1].y*r[0].y+n[2].y*r[0].z,n[0].z*r[0].x+n[1].z*r[0].y+n[2].z*r[0].z,n[0].x*r[1].x+n[1].x*r[1].y+n[2].x*r[1].z,n[0].y*r[1].x+n[1].y*r[1].y+n[2].y*r[1].z,n[0].z*r[1].x+n[1].z*r[1].y+n[2].z*r[1].z,n[0].x*r[2].x+n[1].x*r[2].y+n[2].x*r[2].z,n[0].y*r[2].x+n[1].y*r[2].y+n[2].y*r[2].z,n[0].z*r[2].x+n[1].z*r[2].y+n[2].z*r[2].z)},mat4x4f:(e,t)=>{let n=e.columns,r=t.columns;return A(n[0].x*r[0].x+n[1].x*r[0].y+n[2].x*r[0].z+n[3].x*r[0].w,n[0].y*r[0].x+n[1].y*r[0].y+n[2].y*r[0].z+n[3].y*r[0].w,n[0].z*r[0].x+n[1].z*r[0].y+n[2].z*r[0].z+n[3].z*r[0].w,n[0].w*r[0].x+n[1].w*r[0].y+n[2].w*r[0].z+n[3].w*r[0].w,n[0].x*r[1].x+n[1].x*r[1].y+n[2].x*r[1].z+n[3].x*r[1].w,n[0].y*r[1].x+n[1].y*r[1].y+n[2].y*r[1].z+n[3].y*r[1].w,n[0].z*r[1].x+n[1].z*r[1].y+n[2].z*r[1].z+n[3].z*r[1].w,n[0].w*r[1].x+n[1].w*r[1].y+n[2].w*r[1].z+n[3].w*r[1].w,n[0].x*r[2].x+n[1].x*r[2].y+n[2].x*r[2].z+n[3].x*r[2].w,n[0].y*r[2].x+n[1].y*r[2].y+n[2].y*r[2].z+n[3].y*r[2].w,n[0].z*r[2].x+n[1].z*r[2].y+n[2].z*r[2].z+n[3].z*r[2].w,n[0].w*r[2].x+n[1].w*r[2].y+n[2].w*r[2].z+n[3].w*r[2].w,n[0].x*r[3].x+n[1].x*r[3].y+n[2].x*r[3].z+n[3].x*r[3].w,n[0].y*r[3].x+n[1].y*r[3].y+n[2].y*r[3].z+n[3].y*r[3].w,n[0].z*r[3].x+n[1].z*r[3].y+n[2].z*r[3].z+n[3].z*r[3].w,n[0].w*r[3].x+n[1].w*r[3].y+n[2].w*r[3].z+n[3].w*r[3].w)}},mulMxV:{mat2x2f:(e,t)=>{let n=e.columns;return q(n[0].x*t.x+n[1].x*t.y,n[0].y*t.x+n[1].y*t.y)},mat3x3f:(e,t)=>{let n=e.columns;return _(n[0].x*t.x+n[1].x*t.y+n[2].x*t.z,n[0].y*t.x+n[1].y*t.y+n[2].y*t.z,n[0].z*t.x+n[1].z*t.y+n[2].z*t.z)},mat4x4f:(e,t)=>{let n=e.columns;return j(n[0].x*t.x+n[1].x*t.y+n[2].x*t.z+n[3].x*t.w,n[0].y*t.x+n[1].y*t.y+n[2].y*t.z+n[3].y*t.w,n[0].z*t.x+n[1].z*t.y+n[2].z*t.z+n[3].z*t.w,n[0].w*t.x+n[1].w*t.y+n[2].w*t.z+n[3].w*t.w)}},mulVxM:{mat2x2f:(e,t)=>{let n=t.columns;return q(e.x*n[0].x+e.y*n[0].y,e.x*n[1].x+e.y*n[1].y)},mat3x3f:(e,t)=>{let n=t.columns;return _(e.x*n[0].x+e.y*n[0].y+e.z*n[0].z,e.x*n[1].x+e.y*n[1].y+e.z*n[1].z,e.x*n[2].x+e.y*n[2].y+e.z*n[2].z)},mat4x4f:(e,t)=>{let n=t.columns;return j(e.x*n[0].x+e.y*n[0].y+e.z*n[0].z+e.w*n[0].w,e.x*n[1].x+e.y*n[1].y+e.z*n[1].z+e.w*n[1].w,e.x*n[2].x+e.y*n[2].y+e.z*n[2].z+e.w*n[2].w,e.x*n[3].x+e.y*n[3].y+e.z*n[3].z+e.w*n[3].w)}},div:{vec2f:pe((e,t)=>e/t),vec2h:ve((e,t)=>e/t),vec2i:Fe(he),vec2u:Ce(he),vec3f:te((e,t)=>e/t),vec3h:be((e,t)=>e/t),vec3i:Pe(he),vec3u:ke(he),vec4f:X((e,t)=>e/t),vec4h:we((e,t)=>e/t),vec4i:We(he),vec4u:_e(he)},dot:{vec2f:ft,vec2h:ft,vec2i:ft,vec2u:ft,vec3f:gt,vec3h:gt,vec3i:gt,vec3u:gt,vec4f:ht,vec4h:ht,vec4i:ht,vec4u:ht},normalize:{vec2f:e=>{let t=Me(e);return q(e.x/t,e.y/t)},vec2h:e=>{let t=Me(e);return ye(e.x/t,e.y/t)},vec2i:e=>{let t=Me(e);return Ue(e.x/t,e.y/t)},vec2u:e=>{let t=Me(e);return tt(e.x/t,e.y/t)},vec3f:e=>{let t=Ie(e);return _(e.x/t,e.y/t,e.z/t)},vec3h:e=>{let t=Ie(e);return ee(e.x/t,e.y/t,e.z/t)},vec3i:e=>{let t=Ie(e);return De(e.x/t,e.y/t,e.z/t)},vec3u:e=>{let t=Ie(e);return nt(e.x/t,e.y/t,e.z/t)},vec4f:e=>{let t=Ae(e);return j(e.x/t,e.y/t,e.z/t,e.w/t)},vec4h:e=>{let t=Ae(e);return Te(e.x/t,e.y/t,e.z/t,e.w/t)},vec4i:e=>{let t=Ae(e);return Be(e.x/t,e.y/t,e.z/t,e.w/t)},vec4u:e=>{let t=Ae(e);return rt(e.x/t,e.y/t,e.z/t,e.w/t)}},cross:{vec3f:(e,t)=>_(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x),vec3h:(e,t)=>ee(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x)},mod:{vec2f:pe((e,t)=>e%t),vec2h:ve((e,t)=>e%t),vec2i:Fe((e,t)=>e%t),vec2u:Ce((e,t)=>e%t),vec3f:te((e,t)=>e%t),vec3h:be((e,t)=>e%t),vec3i:Pe((e,t)=>e%t),vec3u:ke((e,t)=>e%t),vec4f:X((e,t)=>e%t),vec4h:we((e,t)=>e%t),vec4i:We((e,t)=>e%t),vec4u:_e((e,t)=>e%t)},floor:{vec2f:h(Math.floor),vec2h:b(Math.floor),vec3f:f(Math.floor),vec3h:w(Math.floor),vec4f:x(Math.floor),vec4h:S(Math.floor)},max:{vec2f:pe(Math.max),vec2h:ve(Math.max),vec2i:Fe(Math.max),vec2u:Ce(Math.max),vec3f:te(Math.max),vec3h:be(Math.max),vec3i:Pe(Math.max),vec3u:ke(Math.max),vec4f:X(Math.max),vec4h:we(Math.max),vec4i:We(Math.max),vec4u:_e(Math.max)},min:{vec2f:pe(Math.min),vec2h:ve(Math.min),vec2i:Fe(Math.min),vec2u:Ce(Math.min),vec3f:te(Math.min),vec3h:be(Math.min),vec3i:Pe(Math.min),vec3u:ke(Math.min),vec4f:X(Math.min),vec4h:we(Math.min),vec4i:We(Math.min),vec4u:_e(Math.min)},pow:{vec2f:(e,t)=>q(e.x**t.x,e.y**t.y),vec2h:(e,t)=>ye(e.x**t.x,e.y**t.y),vec3f:(e,t)=>_(e.x**t.x,e.y**t.y,e.z**t.z),vec3h:(e,t)=>ee(e.x**t.x,e.y**t.y,e.z**t.z),vec4f:(e,t)=>j(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w),vec4h:(e,t)=>Te(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w)},sign:{vec2f:h(Math.sign),vec2h:b(Math.sign),vec2i:$e(Math.sign),vec3f:f(Math.sign),vec3h:w(Math.sign),vec3i:ze(Math.sign),vec4f:x(Math.sign),vec4h:S(Math.sign),vec4i:Ve(Math.sign)},sqrt:{vec2f:h(Math.sqrt),vec2h:b(Math.sqrt),vec3f:f(Math.sqrt),vec3h:w(Math.sqrt),vec4f:x(Math.sqrt),vec4h:S(Math.sqrt)},mix:{vec2f:(e,t,n)=>typeof n=="number"?q(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n):q(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y),vec2h:(e,t,n)=>typeof n=="number"?ye(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n):ye(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y),vec3f:(e,t,n)=>typeof n=="number"?_(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n):_(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z),vec3h:(e,t,n)=>typeof n=="number"?ee(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n):ee(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z),vec4f:(e,t,n)=>typeof n=="number"?j(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n,e.w*(1-n)+t.w*n):j(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z,e.w*(1-n.w)+t.w*n.w),vec4h:(e,t,n)=>typeof n=="number"?Te(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n,e.w*(1-n)+t.w*n):Te(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z,e.w*(1-n.w)+t.w*n.w)},sin:{vec2f:h(Math.sin),vec2h:b(Math.sin),vec3f:f(Math.sin),vec3h:w(Math.sin),vec4f:x(Math.sin),vec4h:S(Math.sin)},cos:{vec2f:h(Math.cos),vec2h:b(Math.cos),vec3f:f(Math.cos),vec3h:w(Math.cos),vec4f:x(Math.cos),vec4h:S(Math.cos)},cosh:{vec2f:h(Math.cosh),vec2h:b(Math.cosh),vec3f:f(Math.cosh),vec3h:w(Math.cosh),vec4f:x(Math.cosh),vec4h:S(Math.cosh)},exp:{vec2f:h(Math.exp),vec2h:b(Math.exp),vec3f:f(Math.exp),vec3h:w(Math.exp),vec4f:x(Math.exp),vec4h:S(Math.exp)},exp2:{vec2f:h(e=>2**e),vec2h:b(e=>2**e),vec3f:f(e=>2**e),vec3h:w(e=>2**e),vec4f:x(e=>2**e),vec4h:S(e=>2**e)},log:{vec2f:h(Math.log),vec2h:b(Math.log),vec3f:f(Math.log),vec3h:w(Math.log),vec4f:x(Math.log),vec4h:S(Math.log)},log2:{vec2f:h(Math.log2),vec2h:b(Math.log2),vec3f:f(Math.log2),vec3h:w(Math.log2),vec4f:x(Math.log2),vec4h:S(Math.log2)},fract:{vec2f:h(e=>e-Math.floor(e)),vec2h:b(e=>e-Math.floor(e)),vec3f:f(e=>e-Math.floor(e)),vec3h:w(e=>e-Math.floor(e)),vec4f:x(e=>e-Math.floor(e)),vec4h:S(e=>e-Math.floor(e))},isCloseToZero:{vec2f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t,vec2h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t,vec3f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t,vec3h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t,vec4f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t&&Math.abs(e.w)<=t,vec4h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t&&Math.abs(e.w)<=t},neg:{vec2f:h(e=>-e),vec2h:b(e=>-e),vec2i:$e(e=>-e),vec2u:Ye(e=>-e),"vec2<bool>":e=>N(!e.x,!e.y),vec3f:f(e=>-e),vec3h:w(e=>-e),vec3i:ze(e=>-e),vec3u:Je(e=>-e),"vec3<bool>":e=>O(!e.x,!e.y,!e.z),vec4f:x(e=>-e),vec4h:S(e=>-e),vec4i:Ve(e=>-e),vec4u:et(e=>-e),"vec4<bool>":e=>K(!e.x,!e.y,!e.z,!e.w)},select:{vec2f:(e,t,n)=>q(n.x?t.x:e.x,n.y?t.y:e.y),vec2h:(e,t,n)=>ye(n.x?t.x:e.x,n.y?t.y:e.y),vec2i:(e,t,n)=>Ue(n.x?t.x:e.x,n.y?t.y:e.y),vec2u:(e,t,n)=>tt(n.x?t.x:e.x,n.y?t.y:e.y),"vec2<bool>":(e,t,n)=>N(n.x?t.x:e.x,n.y?t.y:e.y),vec3f:(e,t,n)=>_(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec3h:(e,t,n)=>ee(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec3i:(e,t,n)=>De(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec3u:(e,t,n)=>nt(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),"vec3<bool>":(e,t,n)=>O(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec4f:(e,t,n)=>j(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w),vec4h:(e,t,n)=>Te(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w),vec4i:(e,t,n)=>Be(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w),vec4u:(e,t,n)=>rt(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w),"vec4<bool>":(e,t,n)=>K(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w)},tanh:{vec2f:h(Math.tanh),vec2h:b(Math.tanh),vec3f:f(Math.tanh),vec3h:w(Math.tanh),vec4f:x(Math.tanh),vec4h:S(Math.tanh)},bitcastU32toF32:{vec2u:e=>q(Y(e.x),Y(e.y)),vec3u:e=>_(Y(e.x),Y(e.y),Y(e.z)),vec4u:e=>j(Y(e.x),Y(e.y),Y(e.z),Y(e.w))},bitcastU32toI32:{vec2u:e=>Ue(J(e.x),J(e.y)),vec3u:e=>De(J(e.x),J(e.y),J(e.z)),vec4u:e=>Be(J(e.x),J(e.y),J(e.z),J(e.w))}};function un(e,t){if(typeof e=="number"&&typeof t=="number")return e+t;if(typeof e=="number"&&v(t))return m.addMixed[t.kind](t,e);if(v(e)&&typeof t=="number")return m.addMixed[e.kind](e,t);if(v(e)&&v(t)||Z(e)&&Z(t))return m.add[e.kind](e,t);throw new Error("Add/Sub called with invalid arguments.")}var Bt=u({name:"add",signature:(...e)=>{let t=F(e)??e;return{argTypes:t,returnType:H(t[0])?t[1]:t[0]}},normalImpl:un,codegenImpl:(e,t)=>o`(${e} + ${t})`});function Kn(e,t){return un(e,cn(-1,t))}var Re=u({name:"sub",signature:(...e)=>{let t=F(e)??e;return{argTypes:t,returnType:H(t[0])?t[1]:t[0]}},normalImpl:Kn,codegenImpl:(e,t)=>o`(${e} - ${t})`});function cn(e,t){if(typeof e=="number"&&typeof t=="number")return e*t;if(typeof e=="number"&&(v(t)||Z(t)))return m.mulSxV[t.kind](e,t);if((v(e)||Z(e))&&typeof t=="number")return m.mulSxV[e.kind](t,e);if(v(e)&&v(t))return m.mulVxV[e.kind](e,t);if(wt(e)&&Z(t))return m.mulVxM[t.kind](e,t);if(Z(e)&&wt(t))return m.mulMxV[e.kind](e,t);if(Z(e)&&Z(t))return m.mulVxV[e.kind](e,t);throw new Error("Mul called with invalid arguments.")}var st=u({name:"mul",signature:(...e)=>{let t=F(e)??e,n=H(t[0])?t[1]:H(t[1])||t[0].type.startsWith("vec")?t[0]:t[1].type.startsWith("vec")?t[1]:t[0];return{argTypes:t,returnType:n}},normalImpl:cn,codegenImpl:(e,t)=>o`(${e} * ${t})`});function qn(e,t){if(typeof e=="number"&&typeof t=="number")return e/t;if(typeof e=="number"&&v(t)){let n=He[t.kind][l].jsImpl;return m.div[t.kind](n(e),t)}if(v(e)&&typeof t=="number"){let n=He[e.kind][l].jsImpl;return m.div[e.kind](e,n(t))}if(v(e)&&v(t))return m.div[e.kind](e,t);throw new Error("Div called with invalid arguments.")}var Rt=u({name:"div",signature:(...e)=>{let t=F(e,[T,V,C])??e;return{argTypes:t,returnType:H(t[0])?t[1]:t[0]}},normalImpl:qn,codegenImpl:(e,t)=>o`(${e} / ${t})`,ignoreImplicitCastWarning:!0}),na=u({name:"mod",signature:(...e)=>{let t=F(e)??e;return{argTypes:t,returnType:H(t[0])?t[1]:t[0]}},normalImpl(e,t){if(typeof e=="number"&&typeof t=="number")return e%t;if(typeof e=="number"&&v(t)){let n=He[t.kind];return m.mod[t.kind](n(e),t)}if(v(e)&&typeof t=="number"){let n=He[e.kind];return m.mod[e.kind](e,n(t))}if(v(e)&&v(t))return m.mod[e.kind](e,t);throw new Error("Mod called with invalid arguments, expected types: number or vector.")},codegenImpl:(e,t)=>o`(${e} % ${t})`});function jn(e){return typeof e=="number"?-e:m.neg[e.kind](e)}var ra=u({name:"neg",signature:e=>({argTypes:[e],returnType:e}),normalImpl:jn,codegenImpl:e=>o`-(${e})`});function Zn(e){return typeof e=="number"?Math.abs(e):m.abs[e.kind](e)}var da=u({name:"abs",signature:e=>({argTypes:[e],returnType:e}),normalImpl:Zn,codegenImpl:e=>o`abs(${e})`});function Hn(e){return typeof e=="number"?Math.acos(e):m.acos[e.kind](e)}var fa=u({name:"acos",signature:e=>({argTypes:[e],returnType:e}),normalImpl:Hn,codegenImpl:e=>o`acos(${e})`});function Qn(e){return typeof e=="number"?Math.acosh(e):m.acosh[e.kind](e)}var ga=u({name:"acosh",signature:e=>({argTypes:[e],returnType:e}),normalImpl:Qn,codegenImpl:e=>o`acosh(${e})`});function Xn(e){return typeof e=="number"?Math.asin(e):m.asin[e.kind](e)}var ha=u({name:"asin",signature:e=>({argTypes:[e],returnType:e}),normalImpl:Xn,codegenImpl:e=>o`asin(${e})`});function Yn(e){return typeof e=="number"?Math.asinh(e):m.asinh[e.kind](e)}var va=u({name:"asinh",signature:e=>({argTypes:[e],returnType:e}),normalImpl:Yn,codegenImpl:e=>o`asinh(${e})`});function Jn(e){return typeof e=="number"?Math.atan(e):m.atan[e.kind](e)}var ba=u({name:"atan",signature:e=>({argTypes:[e],returnType:e}),normalImpl:Jn,codegenImpl:e=>o`atan(${e})`});function er(e){return typeof e=="number"?Math.atanh(e):m.atanh[e.kind](e)}var wa=u({name:"atanh",signature:e=>({argTypes:[e],returnType:e}),normalImpl:er,codegenImpl:e=>o`atanh(${e})`});function tr(e,t){return typeof e=="number"&&typeof t=="number"?Math.atan2(e,t):m.atan2[e.kind](e,t)}var Sa=u({name:"atan2",signature:(...e)=>{let t=F(e,[T,V,C])??e;return{argTypes:t,returnType:t[0]}},normalImpl:tr,codegenImpl:(e,t)=>o`atan2(${e}, ${t})`});function nr(e){return typeof e=="number"?Math.ceil(e):m.ceil[e.kind](e)}var Ma=u({name:"ceil",signature:e=>({argTypes:[e],returnType:e}),normalImpl:nr,codegenImpl:e=>o`ceil(${e})`});function rr(e,t,n){return typeof e=="number"?Math.min(Math.max(t,e),n):m.clamp[e.kind](e,t,n)}var Ia=u({name:"clamp",signature:(...e)=>{let t=F(e)??e;return{argTypes:t,returnType:t[0]}},normalImpl:rr,codegenImpl:(e,t,n)=>o`clamp(${e}, ${t}, ${n})`});function sr(e){return typeof e=="number"?Math.cos(e):m.cos[e.kind](e)}var Aa=u({name:"cos",signature:e=>({argTypes:[e],returnType:e}),normalImpl:sr,codegenImpl:e=>o`cos(${e})`});function ar(e){return typeof e=="number"?Math.cosh(e):m.cosh[e.kind](e)}var $a=u({name:"cosh",signature:e=>({argTypes:[e],returnType:e}),normalImpl:ar,codegenImpl:e=>o`cosh(${e})`});var za=u({name:"countLeadingZeros",signature:e=>({argTypes:[e],returnType:e}),normalImpl:"CPU implementation for countLeadingZeros not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>o`countLeadingZeros(${e})`});var Va=u({name:"countOneBits",signature:e=>({argTypes:[e],returnType:e}),normalImpl:"CPU implementation for countOneBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>o`countOneBits(${e})`});var Fa=u({name:"countTrailingZeros",signature:e=>({argTypes:[e],returnType:e}),normalImpl:"CPU implementation for countTrailingZeros not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>o`countTrailingZeros(${e})`}),Ca=u({name:"cross",signature:(e,t)=>({argTypes:[e,t],returnType:e}),normalImpl:(e,t)=>m.cross[e.kind](e,t),codegenImpl:(e,t)=>o`cross(${e}, ${t})`});function or(e){if(typeof e=="number")return e*180/Math.PI;throw new B("CPU implementation for degrees on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var Pa=u({name:"degrees",signature:e=>({argTypes:[e],returnType:e}),normalImpl:or,codegenImpl:e=>o`degrees(${e})`}),ka=u({name:"determinant",signature:e=>({argTypes:[e],returnType:T}),normalImpl:"CPU implementation for determinant not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>o`determinant(${e})`});function ur(e,t){return typeof e=="number"&&typeof t=="number"?Math.abs(e-t):fr(Re(e,t))}var Wa=u({name:"distance",signature:(e,t)=>({argTypes:[e,t],returnType:ut(e)?V:T}),normalImpl:ur,codegenImpl:(e,t)=>o`distance(${e}, ${t})`}),cr=u({name:"dot",signature:(e,t)=>({argTypes:[e,t],returnType:e.primitive}),normalImpl:(e,t)=>m.dot[e.kind](e,t),codegenImpl:(e,t)=>o`dot(${e}, ${t})`}),_a=u({name:"dot4U8Packed",signature:(e,t)=>({argTypes:[P,P],returnType:P}),normalImpl:"CPU implementation for dot4U8Packed not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:(e,t)=>o`dot4U8Packed(${e}, ${t})`}),Ua=u({name:"dot4I8Packed",signature:(e,t)=>({argTypes:[P,P],returnType:xe}),normalImpl:"CPU implementation for dot4I8Packed not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:(e,t)=>o`dot4I8Packed(${e}, ${t})`});function ir(e){return typeof e=="number"?Math.exp(e):m.exp[e.kind](e)}var Da=u({name:"exp",signature:e=>({argTypes:[e],returnType:e}),normalImpl:ir,codegenImpl:e=>o`exp(${e})`});function lr(e){return typeof e=="number"?2**e:m.exp2[e.kind](e)}var Ba=u({name:"exp2",signature:e=>({argTypes:[e],returnType:e}),normalImpl:lr,codegenImpl:e=>o`exp2(${e})`});var Ra=u({name:"extractBits",signature:(e,t,n)=>({argTypes:[e,P,P],returnType:e}),normalImpl:"CPU implementation for extractBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:(e,t,n)=>o`extractBits(${e}, ${t}, ${n})`}),Ga=u({name:"faceForward",signature:(e,t,n)=>({argTypes:[e,t,n],returnType:e}),normalImpl:"CPU implementation for faceForward not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:(e,t,n)=>o`faceForward(${e}, ${t}, ${n})`});var Ea=u({name:"firstLeadingBit",signature:e=>({argTypes:[e],returnType:e}),normalImpl:"CPU implementation for firstLeadingBit not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>o`firstLeadingBit(${e})`});var La=u({name:"firstTrailingBit",signature:e=>({argTypes:[e],returnType:e}),normalImpl:"CPU implementation for firstTrailingBit not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>o`firstTrailingBit(${e})`});function mr(e){return typeof e=="number"?Math.floor(e):m.floor[e.kind](e)}var Na=u({name:"floor",signature:(...e)=>({argTypes:e,returnType:e[0]}),normalImpl:mr,codegenImpl:e=>o`floor(${e})`});function pr(e,t,n){if(typeof e=="number")return e*t+n;throw new B("CPU implementation for fma on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var Oa=u({name:"fma",signature:(e,t,n)=>({argTypes:[e,t,n],returnType:e}),normalImpl:pr,codegenImpl:(e,t,n)=>o`fma(${e}, ${t}, ${n})`});function yr(e){return typeof e=="number"?e-Math.floor(e):m.fract[e.kind](e)}var Ka=u({name:"fract",signature:(...e)=>({argTypes:e,returnType:e[0]}),normalImpl:yr,codegenImpl:e=>o`fract(${e})`}),Tr={f32:I({fract:T,exp:xe}),f16:I({fract:V,exp:xe}),abstractFloat:I({fract:C,exp:ge}),vec2f:I({fract:R,exp:se}),vec3f:I({fract:G,exp:oe}),vec4f:I({fract:E,exp:ce}),vec2h:I({fract:re,exp:se}),vec3h:I({fract:ae,exp:oe}),vec4h:I({fract:ue,exp:ce})},qa=W(e=>{throw new B("CPU implementation for frexp not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")},e=>{let t=Tr[e.dataType.type];if(!t)throw new Error(`Unsupported data type for frexp: ${e.dataType.type}. Supported types are f32, f16, abstractFloat, vec2f, vec3f, vec4f, vec2h, vec3h, vec4h.`);return c(o`frexp(${e})`,t)},"frexp");var ja=u({name:"insertBits",signature:(e,t,n,r)=>({argTypes:[e,t,P,P],returnType:e}),normalImpl:"CPU implementation for insertBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:(e,t,n,r)=>o`insertBits(${e}, ${t}, ${n}, ${r})`});function xr(e){if(typeof e=="number")return 1/Math.sqrt(e);throw new B("CPU implementation for inverseSqrt on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var Za=u({name:"inverseSqrt",signature:e=>({argTypes:[e],returnType:e}),normalImpl:xr,codegenImpl:e=>o`inverseSqrt(${e})`});var Ha=u({name:"ldexp",signature:(e,t)=>{switch(e.type){case"abstractFloat":return{argTypes:[C,ge],returnType:e};case"f32":case"f16":return{argTypes:[e,xe],returnType:e};case"vec2f":case"vec2h":return{argTypes:[e,se],returnType:e};case"vec3f":case"vec3h":return{argTypes:[e,oe],returnType:e};case"vec4f":case"vec4h":return{argTypes:[e,ce],returnType:e};default:throw new Error(`Unsupported data type for ldexp: ${e.type}. Supported types are abstractFloat, f32, f16, vec2f, vec2h, vec3f, vec3h, vec4f, vec4h.`)}},normalImpl:"CPU implementation for ldexp not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:(e,t)=>o`ldexp(${e}, ${t})`});function dr(e){return typeof e=="number"?Math.abs(e):m.length[e.kind](e)}var fr=u({name:"length",signature:e=>({argTypes:[e],returnType:ut(e)?V:T}),normalImpl:dr,codegenImpl:e=>o`length(${e})`});function gr(e){return typeof e=="number"?Math.log(e):m.log[e.kind](e)}var Qa=u({name:"log",signature:e=>({argTypes:[e],returnType:e}),normalImpl:gr,codegenImpl:e=>o`log(${e})`});function hr(e){return typeof e=="number"?Math.log2(e):m.log2[e.kind](e)}var Xa=u({name:"log2",signature:e=>({argTypes:[e],returnType:e}),normalImpl:hr,codegenImpl:e=>o`log2(${e})`});function vr(e,t){return typeof e=="number"?Math.max(e,t):m.max[e.kind](e,t)}var Ya=u({name:"max",signature:(...e)=>{let t=F(e)??e;return{argTypes:t,returnType:t[0]}},normalImpl:vr,codegenImpl:(e,t)=>o`max(${e}, ${t})`});function br(e,t){return typeof e=="number"?Math.min(e,t):m.min[e.kind](e,t)}var Ja=u({name:"min",signature:(...e)=>{let t=F(e)??e;return{argTypes:t,returnType:t[0]}},normalImpl:br,codegenImpl:(e,t)=>o`min(${e}, ${t})`});function wr(e,t,n){if(typeof e=="number"){if(typeof n!="number"||typeof t!="number")throw new Error("When e1 and e2 are numbers, the blend factor must be a number.");return e*(1-n)+t*n}if(typeof e=="number"||typeof t=="number")throw new Error("e1 and e2 need to both be vectors of the same kind.");return m.mix[e.kind](e,t,n)}var eo=u({name:"mix",signature:(e,t,n)=>({argTypes:[e,t,n],returnType:e}),normalImpl:wr,codegenImpl:(e,t,n)=>o`mix(${e}, ${t}, ${n})`}),Sr={f32:I({fract:T,whole:T}),f16:I({fract:V,whole:V}),abstractFloat:I({fract:C,whole:C}),vec2f:I({fract:R,whole:R}),vec3f:I({fract:G,whole:G}),vec4f:I({fract:E,whole:E}),vec2h:I({fract:re,whole:re}),vec3h:I({fract:ae,whole:ae}),vec4h:I({fract:ue,whole:ue})};var to=u({name:"modf",signature:e=>{let t=Sr[e.type];if(!t)throw new Error(`Unsupported data type for modf: ${e.type}. Supported types are f32, f16, abstractFloat, vec2f, vec3f, vec4f, vec2h, vec3h, vec4h.`);return{argTypes:[e],returnType:t}},normalImpl:"CPU implementation for modf not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>o`modf(${e})`}),no=u({name:"normalize",signature:e=>({argTypes:[e],returnType:e}),normalImpl:e=>m.normalize[e.kind](e),codegenImpl:e=>o`normalize(${e})`});function Mr(e,t){if(typeof e=="number"&&typeof t=="number")return e**t;if(v(e)&&v(t))return m.pow[e.kind](e,t);throw new Error("Invalid arguments to pow()")}var ln=u({name:"pow",signature:(...e)=>{let t=F(e,[T,V,C])??e;return{argTypes:t,returnType:H(t[0])?t[1]:t[0]}},normalImpl:Mr,codegenImpl:(e,t)=>o`pow(${e}, ${t})`});var ro=u({name:"quantizeToF16",signature:e=>({argTypes:[e],returnType:e}),normalImpl:"CPU implementation for quantizeToF16 not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>o`quantizeToF16(${e})`});function Ir(e){if(typeof e=="number")return e*Math.PI/180;throw new B("CPU implementation for radians on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var so=u({name:"radians",signature:(...e)=>{let t=F(e,[T,V,C])??e;return{argTypes:t,returnType:t[0]}},normalImpl:Ir,codegenImpl:e=>o`radians(${e})`}),ao=u({name:"reflect",signature:(e,t)=>({argTypes:[e,t],returnType:e}),normalImpl:(e,t)=>Re(e,st(2*cr(t,e),t)),codegenImpl:(e,t)=>o`reflect(${e}, ${t})`}),oo=W((e,t,n)=>{throw new B("CPU implementation for refract not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")},(e,t,n)=>c(o`refract(${e}, ${t}, ${n})`,e.dataType),"refract",(e,t,n)=>[e.dataType,t.dataType,ut(e)?V:T]);var uo=u({name:"reverseBits",signature:e=>({argTypes:[e],returnType:e}),normalImpl:"CPU implementation for reverseBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>o`reverseBits(${e})`});function Ar(e){if(typeof e=="number")return Math.round(e);throw new B("CPU implementation for round on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var co=u({name:"round",signature:e=>({argTypes:[e],returnType:e}),normalImpl:Ar,codegenImpl:e=>o`round(${e})`});function $r(e){if(typeof e=="number")return Math.max(0,Math.min(1,e));throw new B("CPU implementation for saturate on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var io=u({name:"saturate",signature:e=>({argTypes:[e],returnType:e}),normalImpl:$r,codegenImpl:e=>o`saturate(${e})`});function zr(e){return typeof e=="number"?Math.sign(e):m.sign[e.kind](e)}var lo=u({name:"sign",signature:e=>({argTypes:[e],returnType:e}),normalImpl:zr,codegenImpl:e=>o`sign(${e})`});function Vr(e){return typeof e=="number"?Math.sin(e):m.sin[e.kind](e)}var mo=u({name:"sin",signature:e=>({argTypes:[e],returnType:e}),normalImpl:Vr,codegenImpl:e=>o`sin(${e})`});function Fr(e){if(typeof e=="number")return Math.sinh(e);throw new B("CPU implementation for sinh on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var po=u({name:"sinh",signature:e=>({argTypes:[e],returnType:e}),normalImpl:Fr,codegenImpl:e=>o`sinh(${e})`});function Cr(e,t,n){return typeof n=="number"?me(e,t,n):m.smoothstep[n.kind](e,t,n)}var yo=u({name:"smoothstep",signature:(e,t,n)=>({argTypes:[e,t,n],returnType:n}),normalImpl:Cr,codegenImpl:(e,t,n)=>o`smoothstep(${e}, ${t}, ${n})`});function Pr(e){return typeof e=="number"?Math.sqrt(e):m.sqrt[e.kind](e)}var To=u({name:"sqrt",signature:e=>({argTypes:[e],returnType:e}),normalImpl:Pr,codegenImpl:e=>o`sqrt(${e})`});function kr(e,t){if(typeof e=="number")return e<=t?1:0;throw new B("CPU implementation for step on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var xo=u({name:"step",signature:(...e)=>{let t=F(e,[T,V,C])??e;return{argTypes:t,returnType:t[0]}},normalImpl:kr,codegenImpl:(e,t)=>o`step(${e}, ${t})`});function Wr(e){if(typeof e=="number")return Math.tan(e);throw new B("CPU implementation for tan on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var fo=u({name:"tan",signature:e=>({argTypes:[e],returnType:e}),normalImpl:Wr,codegenImpl:e=>o`tan(${e})`});function _r(e){return typeof e=="number"?Math.tanh(e):m.tanh[e.kind](e)}var go=u({name:"tanh",signature:e=>({argTypes:[e],returnType:e}),normalImpl:_r,codegenImpl:e=>o`tanh(${e})`}),ho=u({name:"transpose",signature:e=>({argTypes:[e],returnType:e}),normalImpl:"CPU implementation for transpose not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>o`transpose(${e})`});var vo=u({name:"trunc",signature:e=>({argTypes:[e],returnType:e}),normalImpl:"CPU implementation for trunc not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>o`trunc(${e})`});import*as Ur from"tinyest";var{NodeTypeCatalog:g}=Ur,Dr=["==","!=","<","<=",">",">=","<<",">>","+","-","*","/","%","|","^","&","&&","||"],Br=["&&","||","==","!=","<","<=",">",">="],Rr=["vec2f","vec3f","vec4f","vec2h","vec3h","vec4h","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","mat2x2f","mat3x3f","mat4x4f"],mn={add:Bt,sub:Re,mul:st,div:Rt};function pn(e,t,n){return n?Br.includes(t)?Q:t==="="?n:e:t==="!"||t==="~"?Q:e}var Gr={"+":Bt[l].gpuImpl,"-":Re[l].gpuImpl,"*":st[l].gpuImpl,"/":Rt[l].gpuImpl,"**":ln[l].gpuImpl},Gt=class{#e=void 0;initGenerator(t){this.#e=t}get ctx(){if(!this.#e)throw new Error("WGSL Generator has not yet been initialized. Please call initialize(ctx) before using the generator.");return this.#e}block([t,n]){this.ctx.pushBlockScope();try{this.ctx.indent();let r=n.map(a=>this.statement(a)).join(`
2
+ `);return this.ctx.dedent(),`{
3
+ ${r}
4
+ ${this.ctx.pre}}`}finally{this.ctx.popBlockScope()}}blockVariable(t,n){let r=c(this.ctx.makeNameValid(t),n);return this.ctx.defineVariable(t,r),r}identifier(t){if(!t)throw new Error("Cannot resolve an empty identifier");let n=this.ctx.getById(t);if(!n)throw new Error(`Identifier ${t} not found`);return n}typedExpression(t,n){let r=this.ctx.expectedType;this.ctx.expectedType=n;try{let a=this.expression(t);return $t(a,n)}finally{this.ctx.expectedType=r}}expression(t){if(typeof t=="string")return this.identifier(t);if(typeof t=="boolean")return c(t,Q);if(t[0]===g.logicalExpr||t[0]===g.binaryExpr||t[0]===g.assignmentExpr){let[n,r,a,s]=t,i=this.expression(r),p=this.expression(s),d=Gr[a];if(d)return d(i,p);let M=t[0]===g.assignmentExpr?i.dataType.type==="ptr"?[i.dataType.inner]:[i.dataType]:void 0,[z,U]=lt([i,p],M)??[i,p],at=this.ctx.resolve(z.value,z.dataType).value,Et=this.ctx.resolve(U.value,U.dataType).value,yn=pn(z.dataType,a,U.dataType);return c(Dr.includes(a)?`(${at} ${a} ${Et})`:`${at} ${a} ${Et}`,yn)}if(t[0]===g.postUpdate){let[n,r,a]=t,s=this.expression(a),i=this.ctx.resolve(s.value,s.dataType).value;return c(`${i}${r}`,s.dataType)}if(t[0]===g.unaryExpr){let[n,r,a]=t,s=this.expression(a),i=this.ctx.resolve(s.value,s.dataType).value,p=pn(s.dataType,r);return c(`${r}${i}`,p)}if(t[0]===g.memberAccess){let[n,r,a]=t,s=this.expression(r);if(s.value===console)return c(new At(a),k);if(Rr.includes(s.dataType.type)&&a in mn)return{value:new Mt(a,s,mn[a][l].gpuImpl),dataType:k};if(s.dataType.type==="unknown"){let i=s.value[a];return Tt(i)}return St(s.dataType)?c(`(*${this.ctx.resolve(s.value).value}).${a}`,Xe(s.dataType.inner,a)):Se(s.dataType)&&a==="length"?s.dataType.elementCount===0?c(`arrayLength(&${this.ctx.resolve(s.value).value})`,P):c(String(s.dataType.elementCount),ge):bt(s.dataType)&&a==="columns"?c(new It(s),k):Ee(s.dataType)&&v(s.value)?Tt(s.value[a]):c(`${this.ctx.resolve(s.value).value}.${a}`,Xe(s.dataType,a))}if(t[0]===g.indexAccess){let[n,r,a]=t,s=this.expression(r),i=this.expression(a),p=this.ctx.resolve(i.value,i.dataType).value;if(s.value instanceof It)return c(o`${s.value.matrix}[${p}]`,mt(s.value.matrix.dataType));let d=this.ctx.resolve(s.value,s.dataType).value;if(s.dataType.type==="unknown"){if(Array.isArray(a)&&a[0]===g.numericLiteral)return Tt(s.value[a[1]]);throw new Error(`Unable to index a value of unknown type with index ${p}. If the value is an array, to address this, consider one of the following approaches: (1) declare the array using 'tgpu.const', (2) store the array in a buffer, or (3) define the array within the GPU function scope.`)}if(bt(s.dataType))throw new Error("The only way of accessing matrix elements in TGSL is through the 'columns' property.");return St(s.dataType)?c(`(*${d})[${p}]`,mt(s.dataType.inner)):c(`${d}[${p}]`,jt(s.dataType)?mt(s.dataType):k)}if(t[0]===g.numericLiteral){let n=typeof t[1]=="string"?pt(Lr(t[1])):pt(t[1]);if(!n)throw new Error(`Invalid numeric literal ${t[1]}`);return n}if(t[0]===g.call){let[n,r,a]=t,s=this.expression(r);if(Le(s.value)||Se(s.value)){if(a.length>1)throw new ne("Array and struct schemas should always be called with at most 1 argument");if(!a[0])return c(`${this.ctx.resolve(s.value).value}()`,s.value);let p=this.typedExpression(a[0],s.value);return c(this.ctx.resolve(p.value,s.value).value,s.value)}if(s.value===nn)throw new Error("Constants cannot be defined within TypeGPU function scope. To address this, move the constant definition outside the function scope.");if(s.value instanceof Mt){if(!a[0])throw new ne(`An infix operator '${s.value.name}' was called without any arguments`);let p=this.expression(a[0]);return s.value.operator(s.value.lhs,p)}if(!Lt(s.value)){let p=a.map(M=>this.expression(M)),d=this.ctx.shelllessRepo.get(s.value,p);if(d)return this.ctx.withResetIndentLevel(()=>{let M=this.ctx.resolve(d);return c(o`${M.value}(${p})`,M.dataType)});throw new Error(`Function '${fe(s.value)??String(s.value)}' is not marked with the 'use gpu' directive and cannot be used in a shader`)}let i=s.value[l]?.argConversionHint??"keep";try{let p;if(Array.isArray(i))p=a.map((M,z)=>{let U=i[z];if(!U)throw new ne(`Function '${fe(s.value)}' was called with too many arguments`);return this.typedExpression(M,U)});else{let M=a.map(z=>this.expression(z));i==="keep"?p=M:i==="unify"?p=lt(M)??M:p=i(...M).map((z,U)=>[z,M[U]]).map(([z,U])=>$t(U,z))}if(s.value instanceof At)return this.ctx.generateLog(s.value.op,p);let d=s.value(...p);if(!ct(d))throw new Error("Functions running in codegen mode must return snippets");return d}catch(p){throw new Ht(p,[{toString:()=>fe(s.value)}])}}if(t[0]===g.objectExpr){let n=t[1],r=this.ctx.expectedType;if(!r||!Le(r))throw new ne(`No target type could be inferred for object with keys [${Object.keys(n).join(", ")}], please wrap the object in the corresponding schema.`);let a=Object.fromEntries(Object.entries(r.propTypes).map(([i,p])=>{let d=n[i];if(d===void 0)throw new ne(`Missing property ${i} in object literal for struct ${r}`);let M=this.typedExpression(d,p);return[i,M]})),s=Xt(r,a);return c(o`${this.ctx.resolve(r).value}(${s})`,r)}if(t[0]===g.arrayExpr){let[n,r]=t,a=this.ctx.expectedType,s,i;if(Se(a)){if(s=a.elementType,i=r.map(d=>this.typedExpression(d,s)),i.length!==a.elementCount)throw new ne(`Cannot create value of type '${a}' from an array of length: ${i.length}`)}else{let d=r.map(z=>this.expression(z));if(d.length===0)throw new ne("Cannot infer the type of an empty array literal.");let M=lt(d);if(!M)throw new ne("The given values cannot be automatically converted to a common type. Consider wrapping the array in an appropriate schema");i=M,s=yt(i[0]?.dataType)}let p=`array<${this.ctx.resolve(s).value}, ${i.length}>`;return c(o`${p}(${i})`,Jt[l].jsImpl(s,i.length))}if(t[0]===g.stringLiteral)return c(t[1],k);if(t[0]===g.preUpdate)throw new Error("Cannot use pre-updates in TGSL.");Er(t)}functionDefinition(t){return this.block(t)}statement(t){if(typeof t=="string")return`${this.ctx.pre}${this.ctx.resolve(this.identifier(t).value).value};`;if(typeof t=="boolean")return`${this.ctx.pre}${t?"true":"false"};`;if(t[0]===g.return){let n=t[1];if(n!==void 0){let r=this.ctx.topFunctionReturnType,a=r?this.typedExpression(n,r):this.expression(n);return Zt(a.dataType.type!=="unknown","Return type should be known"),this.ctx.reportReturnType(a.dataType),o`${this.ctx.pre}return ${a};`}return`${this.ctx.pre}return;`}if(t[0]===g.if){let[n,r,a,s]=t,i=this.typedExpression(r,Q),p=i.value===!1?void 0:this.block(vt(a)),d=i.value===!0||!s?void 0:this.block(vt(s));return i.value===!0?`${this.ctx.pre}${p}`:i.value===!1?d?`${this.ctx.pre}${d}`:"":d?o`\
5
+ ${this.ctx.pre}if (${i}) ${p}
6
+ ${this.ctx.pre}else ${d}`:o`${this.ctx.pre}if (${i}) ${p}`}if(t[0]===g.let||t[0]===g.const){let[n,r,a]=t,s=a!==void 0?this.expression(a):void 0;if(!s)throw new Error(`Cannot create variable '${r}' without an initial value.`);if(Ot(s.dataType))throw new Error(`Cannot create variable '${r}' with loose data type.`);let i=this.blockVariable(r,yt(s.dataType));return o`${this.ctx.pre}var ${i.value} = ${s};`}if(t[0]===g.block)return this.block(t);if(t[0]===g.for){let[n,r,a,s,i]=t,[p,d,M]=this.ctx.withResetIndentLevel(()=>[r?this.statement(r):void 0,a?this.typedExpression(a,Q):void 0,s?this.statement(s):void 0]),z=p?p.slice(0,-1):"",U=M?M.slice(0,-1):"",at=this.block(vt(i));return o`${this.ctx.pre}for (${z}; ${d}; ${U}) ${at}`}if(t[0]===g.while){let[n,r,a]=t,s=this.typedExpression(r,Q),i=this.ctx.resolve(s.value).value,p=this.block(vt(a));return`${this.ctx.pre}while (${i}) ${p}`}return t[0]===g.continue?`${this.ctx.pre}continue;`:t[0]===g.break?`${this.ctx.pre}break;`:`${this.ctx.pre}${this.ctx.resolve(this.expression(t).value).value};`}};function Er(e){throw new Error(`'${Yt(e)}' was not handled by the WGSL generator.`)}function Lr(e){return/^0x[0-9a-f]+$/i.test(e)?Number.parseInt(e):/^0b[01]+$/i.test(e)?Number.parseInt(e.slice(2),2):Number.parseFloat(e)}function vt(e){return typeof e!="object"||e[0]!==g.block?[g.block,[e]]:e}var Nr=new Gt,Bo=Nr;export{Qe as a,Tn as b,xn as c,dn as d,gn as e,hn as f,vn as g,bn as h,wn as i,ie as j,le as k,A as l,Hr as m,pt as n,yt as o,os as p,Tt as q,_t as r,ys as s,nn as t,ws as u,Ss as v,Ms as w,Is as x,Vs as y,dt as z,In as A,An as B,$n as C,zn as D,Vn as E,Fn as F,Cn as G,Pn as H,kn as I,Wn as J,_n as K,Fs as L,Cs as M,Ps as N,ks as O,Ws as P,_s as Q,Us as R,Ds as S,Gs as T,Y as U,J as V,m as W,Bt as X,Re as Y,st as Z,Rt as _,na as $,ra as aa,da as ba,fa as ca,ga as da,ha as ea,va as fa,ba as ga,wa as ha,Sa as ia,Ma as ja,Ia as ka,Aa as la,$a as ma,za as na,Va as oa,Fa as pa,Ca as qa,Pa as ra,ka as sa,Wa as ta,cr as ua,_a as va,Ua as wa,Da as xa,Ba as ya,Ra as za,Ga as Aa,Ea as Ba,La as Ca,Na as Da,Oa as Ea,Ka as Fa,qa as Ga,ja as Ha,Za as Ia,Ha as Ja,fr as Ka,Qa as La,Xa as Ma,Ya as Na,Ja as Oa,eo as Pa,to as Qa,no as Ra,ln as Sa,ro as Ta,so as Ua,ao as Va,oo as Wa,uo as Xa,co as Ya,io as Za,lo as _a,mo as $a,po as ab,yo as bb,To as cb,xo as db,fo as eb,go as fb,ho as gb,vo as hb,mn as ib,Bo as jb};
7
+ //# sourceMappingURL=chunk-2UXPGML5.js.map