New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

typegpu

Package Overview
Dependencies
Maintainers
3
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typegpu - npm Package Compare versions

Comparing version
0.8.2
to
0.9.0
+2
chunk-5ABKYSJD.js
import{n as Q,o as K,p as j,q as a,s as U,t as Y}from"./chunk-EHLRP4V2.js";import{Ab as R,Bb as H,Cc as p,La as t,N as _,O as S,_a as l,a as q,cb as f,db as r,eb as N,fa as $,fb as I,ga as z,gb as P,hb as c,jb as d,kb as i,lb as T,nb as y,ob as C,pb as A,r as h,rb as Z,sb as v,tb as k,ub as V,v as L,wb as W,xb as m,yb as M,zb as x}from"./chunk-SHSILTWI.js";var s=e=>({argTypes:[e],returnType:e}),E=(...e)=>{let n=l(e)??e;return{argTypes:n,returnType:n[0]}};function J(e){return(n,...o)=>{let u=n;for(let w of o)u=e(u,w);return u}}function X(e){return(n,...o)=>{let u=t`${n}`;for(let w of o)u=t`${e}(${u}, ${w})`;return u}}function te(e){return typeof e=="number"?Math.abs(e):a.abs[e.kind](e)}var fn=r({name:"abs",signature:s,normalImpl:te,codegenImpl:e=>t`abs(${e})`});function re(e){return typeof e=="number"?Math.acos(e):a.acos[e.kind](e)}var dn=r({name:"acos",signature:s,normalImpl:re,codegenImpl:e=>t`acos(${e})`});function oe(e){return typeof e=="number"?Math.acosh(e):a.acosh[e.kind](e)}var yn=r({name:"acosh",signature:s,normalImpl:oe,codegenImpl:e=>t`acosh(${e})`});function ae(e){return typeof e=="number"?Math.asin(e):a.asin[e.kind](e)}var bn=r({name:"asin",signature:s,normalImpl:ae,codegenImpl:e=>t`asin(${e})`});function se(e){return typeof e=="number"?Math.asinh(e):a.asinh[e.kind](e)}var gn=r({name:"asinh",signature:s,normalImpl:se,codegenImpl:e=>t`asinh(${e})`});function ue(e){return typeof e=="number"?Math.atan(e):a.atan[e.kind](e)}var In=r({name:"atan",signature:s,normalImpl:ue,codegenImpl:e=>t`atan(${e})`});function ce(e){return typeof e=="number"?Math.atanh(e):a.atanh[e.kind](e)}var xn=r({name:"atanh",signature:s,normalImpl:ce,codegenImpl:e=>t`atanh(${e})`});function ie(e,n){return typeof e=="number"&&typeof n=="number"?Math.atan2(e,n):a.atan2[e.kind](e,n)}var hn=r({name:"atan2",signature:(...e)=>{let n=l(e,[i,T,I])??e;return{argTypes:n,returnType:n[0]}},normalImpl:ie,codegenImpl:(e,n)=>t`atan2(${e}, ${n})`});function pe(e){return typeof e=="number"?Math.ceil(e):a.ceil[e.kind](e)}var An=r({name:"ceil",signature:s,normalImpl:pe,codegenImpl:e=>t`ceil(${e})`});function me(e,n,o){return typeof e=="number"?Math.min(Math.max(n,e),o):a.clamp[e.kind](e,n,o)}var vn=r({name:"clamp",signature:E,normalImpl:me,codegenImpl:(e,n,o)=>t`clamp(${e}, ${n}, ${o})`});function le(e){return typeof e=="number"?Math.cos(e):a.cos[e.kind](e)}var Vn=r({name:"cos",signature:s,normalImpl:le,codegenImpl:e=>t`cos(${e})`});function Te(e){return typeof e=="number"?Math.cosh(e):a.cosh[e.kind](e)}var Fn=r({name:"cosh",signature:s,normalImpl:Te,codegenImpl:e=>t`cosh(${e})`});var wn=r({name:"countLeadingZeros",signature:s,normalImpl:"CPU implementation for countLeadingZeros not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>t`countLeadingZeros(${e})`});var $n=r({name:"countOneBits",signature:s,normalImpl:"CPU implementation for countOneBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>t`countOneBits(${e})`});var Pn=r({name:"countTrailingZeros",signature:s,normalImpl:"CPU implementation for countTrailingZeros not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>t`countTrailingZeros(${e})`}),Un=r({name:"cross",signature:(...e)=>({argTypes:e,returnType:e[0]}),normalImpl:(e,n)=>a.cross[e.kind](e,n),codegenImpl:(e,n)=>t`cross(${e}, ${n})`});function fe(e){if(typeof e=="number")return e*180/Math.PI;throw new f("CPU implementation for degrees on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var Bn=r({name:"degrees",signature:s,normalImpl:fe,codegenImpl:e=>t`degrees(${e})`}),Sn=r({name:"determinant",signature:s,normalImpl:"CPU implementation for determinant not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>t`determinant(${e})`});function de(e,n){return typeof e=="number"&&typeof n=="number"?Math.abs(e-n):Fe(U(e,n))}var Cn=r({name:"distance",signature:(...e)=>({argTypes:e,returnType:S(e[0])?T:i}),normalImpl:de,codegenImpl:(e,n)=>t`distance(${e}, ${n})`}),ye=r({name:"dot",signature:(...e)=>({argTypes:e,returnType:e[0].primitive}),normalImpl:(e,n)=>a.dot[e.kind](e,n),codegenImpl:(e,n)=>t`dot(${e}, ${n})`}),kn=r({name:"dot4U8Packed",signature:{argTypes:[c,c],returnType:c},normalImpl:"CPU implementation for dot4U8Packed not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:(e,n)=>t`dot4U8Packed(${e}, ${n})`}),Mn=r({name:"dot4I8Packed",signature:{argTypes:[c,c],returnType:d},normalImpl:"CPU implementation for dot4I8Packed not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:(e,n)=>t`dot4I8Packed(${e}, ${n})`});function be(e){return typeof e=="number"?Math.exp(e):a.exp[e.kind](e)}var En=r({name:"exp",signature:s,normalImpl:be,codegenImpl:e=>t`exp(${e})`});function ge(e){return typeof e=="number"?2**e:a.exp2[e.kind](e)}var Gn=r({name:"exp2",signature:s,normalImpl:ge,codegenImpl:e=>t`exp2(${e})`});var Ln=r({name:"extractBits",signature:(e,n,o)=>({argTypes:[e,c,c],returnType:e}),normalImpl:"CPU implementation for extractBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:(e,n,o)=>t`extractBits(${e}, ${n}, ${o})`}),Nn=r({name:"faceForward",signature:(...e)=>({argTypes:e,returnType:e[0]}),normalImpl:"CPU implementation for faceForward not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:(e,n,o)=>t`faceForward(${e}, ${n}, ${o})`});var Rn=r({name:"firstLeadingBit",signature:s,normalImpl:"CPU implementation for firstLeadingBit not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>t`firstLeadingBit(${e})`});var Dn=r({name:"firstTrailingBit",signature:s,normalImpl:"CPU implementation for firstTrailingBit not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>t`firstTrailingBit(${e})`});function Ie(e){return typeof e=="number"?Math.floor(e):a.floor[e.kind](e)}var On=r({name:"floor",signature:s,normalImpl:Ie,codegenImpl:e=>t`floor(${e})`});function xe(e,n,o){if(typeof e=="number")return e*n+o;throw new f("CPU implementation for fma on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var qn=r({name:"fma",signature:(...e)=>({argTypes:e,returnType:e[0]}),normalImpl:xe,codegenImpl:(e,n,o)=>t`fma(${e}, ${n}, ${o})`});function he(e){return typeof e=="number"?e-Math.floor(e):a.fract[e.kind](e)}var _n=r({name:"fract",signature:s,normalImpl:he,codegenImpl:e=>t`fract(${e})`}),Ae={f32:p({fract:i,exp:d}),f16:p({fract:T,exp:d}),abstractFloat:p({fract:I,exp:N}),vec2f:p({fract:y,exp:A}),vec3f:p({fract:v,exp:V}),vec4f:p({fract:m,exp:x}),vec2h:p({fract:C,exp:A}),vec3h:p({fract:k,exp:V}),vec4h:p({fract:M,exp:x})},zn=r({name:"frexp",normalImpl:"CPU implementation for frexp not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",signature:e=>{let n=Ae[e.type];if(!n)throw new Error(`Unsupported data type for frexp: ${e.type}. Supported types are f32, f16, abstractFloat, vec2f, vec3f, vec4f, vec2h, vec3h, vec4h.`);return{argTypes:[e],returnType:n}},codegenImpl:e=>t`frexp(${e})`});var Zn=r({name:"insertBits",signature:(e,n,o,u)=>({argTypes:[e,n,c,c],returnType:e}),normalImpl:"CPU implementation for insertBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:(e,n,o,u)=>t`insertBits(${e}, ${n}, ${o}, ${u})`});function ve(e){if(typeof e=="number")return 1/Math.sqrt(e);throw new f("CPU implementation for inverseSqrt on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var Wn=r({name:"inverseSqrt",signature:s,normalImpl:ve,codegenImpl:e=>t`inverseSqrt(${e})`});var Hn=r({name:"ldexp",signature:(e,n)=>{switch(e.type){case"abstractFloat":return{argTypes:[e,N],returnType:e};case"f32":case"f16":return{argTypes:[e,d],returnType:e};case"vec2f":case"vec2h":return{argTypes:[e,A],returnType:e};case"vec3f":case"vec3h":return{argTypes:[e,V],returnType:e};case"vec4f":case"vec4h":return{argTypes:[e,x],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,n)=>t`ldexp(${e}, ${n})`});function Ve(e){return typeof e=="number"?Math.abs(e):a.length[e.kind](e)}var Fe=r({name:"length",signature:e=>({argTypes:[e],returnType:S(e)?T:i}),normalImpl:Ve,codegenImpl:e=>t`length(${e})`});function we(e){return typeof e=="number"?Math.log(e):a.log[e.kind](e)}var Qn=r({name:"log",signature:s,normalImpl:we,codegenImpl:e=>t`log(${e})`});function $e(e){return typeof e=="number"?Math.log2(e):a.log2[e.kind](e)}var Kn=r({name:"log2",signature:s,normalImpl:$e,codegenImpl:e=>t`log2(${e})`});function Pe(e,n){return typeof e=="number"?Math.max(e,n):a.max[e.kind](e,n)}var jn=r({name:"max",signature:E,normalImpl:J(Pe),codegenImpl:X("max")});function Ue(e,n){return typeof e=="number"?Math.min(e,n):a.min[e.kind](e,n)}var Yn=r({name:"min",signature:E,normalImpl:J(Ue),codegenImpl:X("min")});function Be(e,n,o){if(typeof e=="number"){if(typeof o!="number"||typeof n!="number")throw new Error("When e1 and e2 are numbers, the blend factor must be a number.");return e*(1-o)+n*o}if(typeof e=="number"||typeof n=="number")throw new Error("e1 and e2 need to both be vectors of the same kind.");return a.mix[e.kind](e,n,o)}var Jn=r({name:"mix",signature:E,normalImpl:Be,codegenImpl:(e,n,o)=>t`mix(${e}, ${n}, ${o})`}),Se={f32:p({fract:i,whole:i}),f16:p({fract:T,whole:T}),abstractFloat:p({fract:I,whole:I}),vec2f:p({fract:y,whole:y}),vec3f:p({fract:v,whole:v}),vec4f:p({fract:m,whole:m}),vec2h:p({fract:C,whole:C}),vec3h:p({fract:k,whole:k}),vec4h:p({fract:M,whole:M})};var Xn=r({name:"modf",signature:e=>{let n=Se[e.type];if(!n)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:n}},normalImpl:"CPU implementation for modf not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>t`modf(${e})`}),et=r({name:"normalize",signature:s,normalImpl:e=>a.normalize[e.kind](e),codegenImpl:e=>t`normalize(${e})`});function Ce(e,n){if(typeof e=="number"&&typeof n=="number")return e**n;if(h(e)&&h(n))return a.pow[e.kind](e,n);throw new Error("Invalid arguments to pow()")}var nt=r({name:"pow",signature:(...e)=>{let n=l(e,[i,T,I])??e;return{argTypes:n,returnType:_(n[0])?n[1]:n[0]}},normalImpl:Ce,codegenImpl:(e,n)=>t`pow(${e}, ${n})`});var tt=r({name:"quantizeToF16",signature:s,normalImpl:"CPU implementation for quantizeToF16 not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>t`quantizeToF16(${e})`});function ke(e){if(typeof e=="number")return e*Math.PI/180;throw new f("CPU implementation for radians on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var rt=r({name:"radians",signature:(...e)=>{let n=l(e,[i,T,I])??e;return{argTypes:n,returnType:n[0]}},normalImpl:ke,codegenImpl:e=>t`radians(${e})`}),ot=r({name:"reflect",signature:(...e)=>({argTypes:e,returnType:e[0]}),normalImpl:(e,n)=>U(e,Y(2*ye(n,e),n)),codegenImpl:(e,n)=>t`reflect(${e}, ${n})`}),at=r({name:"refract",normalImpl:"CPU implementation for refract not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:(e,n,o)=>t`refract(${e}, ${n}, ${o})`,signature:(e,n,o)=>({argTypes:[e,n,S(e)?T:i],returnType:e})});var st=r({name:"reverseBits",signature:s,normalImpl:"CPU implementation for reverseBits not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>t`reverseBits(${e})`});function Me(e){if(typeof e=="number")return Math.round(e);throw new f("CPU implementation for round on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var ut=r({name:"round",signature:s,normalImpl:Me,codegenImpl:e=>t`round(${e})`});function Ee(e){if(typeof e=="number")return Math.max(0,Math.min(1,e));throw new f("CPU implementation for saturate on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var ct=r({name:"saturate",signature:s,normalImpl:Ee,codegenImpl:e=>t`saturate(${e})`});function Ge(e){return typeof e=="number"?Math.sign(e):a.sign[e.kind](e)}var it=r({name:"sign",signature:s,normalImpl:Ge,codegenImpl:e=>t`sign(${e})`});function Le(e){return typeof e=="number"?Math.sin(e):a.sin[e.kind](e)}var pt=r({name:"sin",signature:s,normalImpl:Le,codegenImpl:e=>t`sin(${e})`});function Ne(e){if(typeof e=="number")return Math.sinh(e);throw new f("CPU implementation for sinh on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var mt=r({name:"sinh",signature:s,normalImpl:Ne,codegenImpl:e=>t`sinh(${e})`});function Re(e,n,o){return typeof o=="number"?Q(e,n,o):a.smoothstep[o.kind](e,n,o)}var lt=r({name:"smoothstep",signature:(...e)=>({argTypes:e,returnType:e[2]}),normalImpl:Re,codegenImpl:(e,n,o)=>t`smoothstep(${e}, ${n}, ${o})`});function De(e){return typeof e=="number"?Math.sqrt(e):a.sqrt[e.kind](e)}var Tt=r({name:"sqrt",signature:s,normalImpl:De,codegenImpl:e=>t`sqrt(${e})`});function Oe(e,n){if(typeof e=="number")return e<=n?1:0;throw new f("CPU implementation for step on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var ft=r({name:"step",signature:(...e)=>{let n=l(e,[i,T,I])??e;return{argTypes:n,returnType:n[0]}},normalImpl:Oe,codegenImpl:(e,n)=>t`step(${e}, ${n})`});function qe(e){if(typeof e=="number")return Math.tan(e);throw new f("CPU implementation for tan on vectors not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues")}var dt=r({name:"tan",signature:s,normalImpl:qe,codegenImpl:e=>t`tan(${e})`});function _e(e){return typeof e=="number"?Math.tanh(e):a.tanh[e.kind](e)}var yt=r({name:"tanh",signature:s,normalImpl:_e,codegenImpl:e=>t`tanh(${e})`}),bt=r({name:"transpose",signature:s,normalImpl:"CPU implementation for transpose not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>t`transpose(${e})`});var gt=r({name:"trunc",signature:s,normalImpl:"CPU implementation for trunc not implemented yet. Please submit an issue at https://github.com/software-mansion/TypeGPU/issues",codegenImpl:e=>t`trunc(${e})`});var Pt=r({name:"bitcastU32toF32",normalImpl:(e=>typeof e=="number"?K(e):a.bitcastU32toF32[e.kind](e)),codegenImpl:e=>t`bitcast<f32>(${e})`,signature:(...e)=>{let n=l(e,[c])??e;return{argTypes:n,returnType:L(n[0])?n[0].type==="vec2u"?y:n[0].type==="vec3u"?v:m:i}}}),Ut=r({name:"bitcastU32toI32",normalImpl:(e=>typeof e=="number"?j(e):a.bitcastU32toI32[e.kind](e)),codegenImpl:e=>t`bitcast<i32>(${e})`,signature:(...e)=>{let n=l(e,[c])??e;return{argTypes:n,returnType:L(n[0])?n[0].type==="vec2u"?A:n[0].type==="vec3u"?V:x:d}}});import*as b from"typed-binary";var Et=r({name:"unpack2x16float",normalImpl:e=>{let n=new ArrayBuffer(4);new b.BufferWriter(n).writeUint32(e);let u=new b.BufferReader(n);return y(u.readFloat16(),u.readFloat16())},signature:{argTypes:[c],returnType:y},codegenImpl:e=>t`unpack2x16float(${e})`}),Gt=r({name:"pack2x16float",normalImpl:e=>{let n=new ArrayBuffer(4),o=new b.BufferWriter(n);o.writeFloat16(e.x),o.writeFloat16(e.y);let u=new b.BufferReader(n);return c(u.readUint32())},signature:{argTypes:[y],returnType:c},codegenImpl:e=>t`pack2x16float(${e})`}),Lt=r({name:"unpack4x8unorm",normalImpl:e=>{let n=new ArrayBuffer(4);new b.BufferWriter(n).writeUint32(e);let u=new b.BufferReader(n);return m(u.readUint8()/255,u.readUint8()/255,u.readUint8()/255,u.readUint8()/255)},signature:{argTypes:[c],returnType:m},codegenImpl:e=>t`unpack4x8unorm(${e})`}),Nt=r({name:"pack4x8unorm",normalImpl:e=>{let n=new ArrayBuffer(4),o=new b.BufferWriter(n);o.writeUint8(e.x*255),o.writeUint8(e.y*255),o.writeUint8(e.z*255),o.writeUint8(e.w*255);let u=new b.BufferReader(n);return c(u.readUint32())},signature:{argTypes:[m],returnType:c},codegenImpl:e=>t`pack4x8unorm(${e})`});function F(e){return e.type.includes("2")?Z:e.type.includes("3")?W:H}var jt=r({name:"allEq",signature:(...e)=>({argTypes:e,returnType:P}),normalImpl:(e,n)=>O(B(e,n)),codegenImpl:(e,n)=>t`all(${e} == ${n})`}),B=(e,n)=>a.eq[e.kind](e,n),Yt=r({name:"eq",signature:(...e)=>({argTypes:e,returnType:F(e[0])}),normalImpl:B,codegenImpl:(e,n)=>t`(${e} == ${n})`}),Jt=r({name:"ne",signature:(...e)=>({argTypes:e,returnType:F(e[0])}),normalImpl:(e,n)=>g(B(e,n)),codegenImpl:(e,n)=>t`(${e} != ${n})`}),G=(e,n)=>a.lt[e.kind](e,n),Xt=r({name:"lt",signature:(...e)=>({argTypes:e,returnType:F(e[0])}),normalImpl:G,codegenImpl:(e,n)=>t`(${e} < ${n})`}),er=r({name:"le",signature:(...e)=>({argTypes:e,returnType:F(e[0])}),normalImpl:(e,n)=>D(G(e,n),B(e,n)),codegenImpl:(e,n)=>t`(${e} <= ${n})`}),nr=r({name:"gt",signature:(...e)=>({argTypes:e,returnType:F(e[0])}),normalImpl:(e,n)=>ee(g(G(e,n)),g(B(e,n))),codegenImpl:(e,n)=>t`(${e} > ${n})`}),tr=r({name:"ge",signature:(...e)=>({argTypes:e,returnType:F(e[0])}),normalImpl:(e,n)=>g(G(e,n)),codegenImpl:(e,n)=>t`(${e} >= ${n})`}),g=e=>a.neg[e.kind](e),rr=r({name:"not",signature:(...e)=>({argTypes:e,returnType:e[0]}),normalImpl:g,codegenImpl:e=>t`!(${e})`}),D=(e,n)=>a.or[e.kind](e,n),or=r({name:"or",signature:(...e)=>({argTypes:e,returnType:e[0]}),normalImpl:D,codegenImpl:(e,n)=>t`(${e} | ${n})`}),ee=(e,n)=>g(D(g(e),g(n))),ar=r({name:"and",signature:(...e)=>({argTypes:e,returnType:e[0]}),normalImpl:ee,codegenImpl:(e,n)=>t`(${e} & ${n})`}),O=e=>a.all[e.kind](e),sr=r({name:"all",signature:(...e)=>({argTypes:e,returnType:P}),normalImpl:O,codegenImpl:e=>t`all(${e})`}),ur=r({name:"any",signature:(...e)=>({argTypes:e,returnType:P}),normalImpl:e=>!O(g(e)),codegenImpl:e=>t`any(${e})`}),cr=r({name:"isCloseTo",signature:(...e)=>({argTypes:e,returnType:P}),normalImpl:(e,n,o=.01)=>typeof e=="number"&&typeof n=="number"?Math.abs(e-n)<o:h(e)&&h(n)?a.isCloseToZero[e.kind](U[q].jsImpl(e,n),o):!1,codegenImpl:(e,n,o=z(.01,i,"constant"))=>$(e)&&$(n)?t`(abs(f32(${e}) - f32(${n})) <= ${o})`:!$(e)&&!$(n)?t`all(abs(${e} - ${n}) <= (${e} - ${e}) + ${o})`:"false"});function ze(e,n,o){return typeof o=="boolean"?o?n:e:a.select[e.kind](e,n,o)}var ir=r({name:"select",signature:(e,n,o)=>{let[u,w]=l([e,n])??[e,n];return{argTypes:[u,w,o],returnType:u}},normalImpl:ze,codegenImpl:(e,n,o)=>t`select(${e}, ${n}, ${o})`});var Ze={channelType:i,vectorType:m,sampleTypes:["depth","unfilterable-float"],texelSize:"non-copyable"},We={channelType:i,vectorType:m,sampleTypes:["depth","unfilterable-float"],texelSize:2},He={channelType:i,vectorType:m,sampleTypes:["depth","unfilterable-float"],texelSize:4},Qe={channelType:c,vectorType:R,sampleTypes:["uint"],texelSize:1},ne=new Map;function Ke(e){let n=ne.get(e);return n===void 0&&(n=je(e),ne.set(e,n)),n}function je(e){let n=Xe(e),o=Ye(e),u=e.includes("stencil");return{channelType:n,vectorType:n===c?R:n===d?x:m,texelSize:en(e),sampleTypes:nn(e),canRenderAttachment:Je(e),...o&&{depthAspect:o},...u&&{stencilAspect:Qe}}}function Ye(e){if(e==="depth16unorm")return We;if(e==="depth32float"||e==="depth32float-stencil8")return He;if(e==="depth24plus"||e==="depth24plus-stencil8")return Ze}function Je(e){return!(e.startsWith("bc")||e.startsWith("etc2")||e.startsWith("eac")||e.startsWith("astc")||e==="rgb9e5ufloat")}function Xe(e){return e==="stencil8"?c:e.includes("uint")?c:e.includes("sint")?d:i}function en(e){let[,n,o]=e.match(/^(rgba|bgra|rg|r)(8|16|32)/)??[];return n&&o?n.length*Number(o)/8:e==="stencil8"?1:e==="depth16unorm"?2:e==="depth32float"?4:e==="depth32float-stencil8"?5:e==="depth24plus"||e==="depth24plus-stencil8"?"non-copyable":/^(bc[14]-|etc2-rgb8|eac-r11)/.test(e)?8:/^(bc|astc-|etc2-rgba|eac-rg)/.test(e)?16:4}function nn(e){return e==="stencil8"?["uint"]:e.includes("uint")?["uint"]:e.includes("sint")?["sint"]:e.includes("depth")?["depth","unfilterable-float"]:/^(r|rg|rgba)16(u|s)norm$/.test(e)?["unfilterable-float"]:["float","unfilterable-float"]}var tn=new Set(["r32float","rg32float","rgba32float"]);function Tr(e,n){return tn.has(n)&&!e.features.has("float32-filterable")?["unfilterable-float"]:Ke(n).sampleTypes}var dr=["f16","clip_distances","dual_source_blending","subgroups","primitive_index"],yr={f16:"shader-f16",clip_distances:"clip-distances",dual_source_blending:"dual-source-blending",subgroups:"subgroups",primitive_index:"primitive-index"};export{Ke as a,Tr as b,fn as c,dn as d,yn as e,bn as f,gn as g,In as h,xn as i,hn as j,An as k,vn as l,Vn as m,Fn as n,wn as o,$n as p,Pn as q,Un as r,Bn as s,Sn as t,Cn as u,ye as v,kn as w,Mn as x,En as y,Gn as z,Ln as A,Nn as B,Rn as C,Dn as D,On as E,qn as F,_n as G,zn as H,Zn as I,Wn as J,Hn as K,Fe as L,Qn as M,Kn as N,jn as O,Yn as P,Jn as Q,Xn as R,et as S,nt as T,tt as U,rt as V,ot as W,at as X,st as Y,ut as Z,ct as _,it as $,pt as aa,mt as ba,lt as ca,Tt as da,ft as ea,dt as fa,yt as ga,bt as ha,gt as ia,Pt as ja,Ut as ka,Et as la,Gt as ma,Lt as na,Nt as oa,dr as pa,yr as qa,jt as ra,Yt as sa,Jt as ta,Xt as ua,er as va,nr as wa,tr as xa,rr as ya,or as za,ar as Aa,sr as Ba,ur as Ca,cr as Da,ir as Ea};
//# sourceMappingURL=chunk-5ABKYSJD.js.map

Sorry, the diff of this file is too big to display

import{i as V,l as C,m as q}from"./chunk-MBB2XFH6.js";import{B as P,Bc as J,Ca as G,D as x,M as N,Q as U,S as H,Y as I,Z as K,a as B,c as D,f as W,ga as E,j as d,k as f,l as M,m as k,ma as _,n as j,q as A}from"./chunk-SHSILTWI.js";function O(n,e){for(let[r,t]of Object.entries(e))n[r]=t,t&&(typeof t=="object"||typeof t=="function")&&d(t)===void 0&&f(t,r)}function Te(n,e,r){let t=[...n.matchAll(/:\s*(?<arg>.*?)\s*[,)]/g)].map(s=>s?s[1]:void 0);r(Object.fromEntries(e.flatMap((s,i)=>{let o=t?t[i]:void 0;return x(s)&&o!==void 0?[[o,s]]:[]})))}function we(n,e,r){let t=n.match(/->\s(?<output>[\w\d_]+)\s{/),s=t?t[1]?.trim():void 0;x(e)&&s&&!/\s/g.test(s)&&r({[s]:e})}function oe(n){return new RegExp(`(?<![\\w\\$_.])${n.replaceAll(".","\\.").replaceAll("$","\\$")}(?![\\w\\$_])`,"g")}function R(n,e,r){return Object.entries(e).reduce((t,[s,i])=>{let o=oe(s);if(r&&s!=="Out"&&s!=="In"&&!o.test(r)&&console.warn(`The external '${s}' wasn't used in the resolved template.`),G(i)||H(i)||k(i))return t.replaceAll(o,n.resolve(i).value);if(i!==null&&typeof i=="object"){let a=[...r.matchAll(new RegExp(`${s.replaceAll(".","\\.").replaceAll("$","\\$")}\\.(?<prop>.*?)(?![\\w\\$_])`,"g"))].map(p=>p[1]);return[...new Set(a)].reduce((p,l)=>l&&l in i?R(n,{[`${s}.${l}`]:i[l]},p):p,t)}return console.warn(`During resolution, the external '${s}' has been omitted. Only TGPU resources, 'use gpu' functions, primitives, and plain JS objects can be used as externals.`),t},r)}function X(n){let{strippedCode:e,argRange:r}=ae(n),t=new T(e);t.consume("(");let s=[];for(;!t.isAt(")");){let o=[];for(;t.isAt("@");)t.parseUntil(z,Q),t.consume(")"),o.push(t.lastParsed);t.parseUntil(pe);let a=t.lastParsed,u;t.isAt(":")&&(t.consume(":"),t.parseUntil(le,de),u=t.lastParsed),s.push({identifier:a,attributes:o,type:u}),t.isAt(",")&&t.consume(",")}t.consume(")");let i;if(t.isAt("->")){t.consume("->");let o=[];for(;t.isAt("@");)t.parseUntil(z,Q),t.consume(")"),o.push(t.lastParsed);i={type:t.str.slice(t.pos),attributes:o}}return{args:s,ret:i,range:{begin:r[0],end:r[1]}}}function ae(n){let e=new T(n),r="",t;for(;!e.isFinished();){if(e.isAt(ue)){e.advanceBy(1);continue}if(e.isAt("//")){e.consume("//"),e.parseUntil(Y),e.advanceBy(1);continue}if(e.isAt("/*")){e.parseUntil(ce,me),e.consume("*/");continue}if(e.isAt("{"))return{strippedCode:r,argRange:[t,e.pos]};e.isAt("(")&&t===void 0&&(t=e.pos),t!==void 0&&(r+=e.str[e.pos]),e.advanceBy(1)}throw new Error("Invalid wgsl code!")}var T=class{constructor(e){this.str=e;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(e){if(typeof e=="string"){for(let r=0;r<e.length;r++)if(this.str[this.#e+r]!==e[r])return!1;return!0}for(let r of e)if(this.isAt(r))return!0;return!1}parseUntil(e,r){this.#t=this.#e;let t=0;for(;this.#e<this.str.length;){if(r&&this.isAt(r[0])&&(t+=1),r&&this.isAt(r[1])&&(t-=1),t===0&&this.isAt(e))return this.#e;this.#e+=1}throw new Error("Reached the end of the string without finding a match!")}advanceBy(e){this.#e+=e}consume(e){if(!this.isAt(e))throw new Error(`Expected '${e}' at position ${this.#e}, but found '${this.str.slice(this.#e,this.#e+e.length)}'`);this.advanceBy(e.length)}},Y=new Set([`
`,"\v","\f","\r","\x85","\u2028","\u2029"]),ue=new Set([...Y," "," ","\u200E","\u200F"]),z=new Set([")"]),pe=new Set([":",",",")"]),le=new Set([",",")"]),ce=new Set(["*/"]),Q=["(",")"],de=["<",">"],me=["/*","*/"];function ee(n,e=""){let r=[],t={applyExternals(i){r.push(i)},resolve(i,o,a){let u={};for(let c of r)O(u,c);let p=i.getUniqueName(this);if(typeof n=="string"){if(!a)throw new Error("Explicit return type is required for string implementation");let c=R(i,u,n),y="",$="";if(e!==""){let m=x(o[0])?`(in: ${i.resolve(o[0]).value})`:"()",h=P(a)?q(a):"",S=a!==A?x(a)?`-> ${i.resolve(a).value}`:`-> ${h!==""?h:"@location(0)"} ${i.resolve(a).value}`:"";y=`${m} ${S} `,$=c}else{let m=X(c);if(m.args.length!==o.length)throw new Error(`WGSL implementation has ${m.args.length} arguments, while the shell has ${o.length} arguments.`);let h=m.args.map((v,se)=>`${v.identifier}: ${Z(i,`parameter ${v.identifier}`,v.type,o[se])}`).join(", "),S=a===A?"":`-> ${Z(i,"return type",m.ret?.type,a)}`;y=`(${h}) ${S}`,$=c.slice(m.range.end)}return i.addDeclaration(`${e}fn ${p}${y}${$}`),E(p,a,"runtime")}let l=j(n),F=typeof l?.externals=="function"?l.externals():l?.externals;if(F){let c=Object.fromEntries(Object.entries(F).filter(([y])=>!(y in u)));O(u,c)}let g=l?.ast;if(!g)throw new Error("Missing metadata for tgpu.fn function body (either missing 'use gpu' directive, or misconfigured `unplugin-typegpu`)");let L=g.externalNames.filter(c=>!(c in u));if(L.length>0)throw new _(d(this),L);let w=g.params[1];w&&w.type==="i"&&e!==""&&O(u,{[w.name]:U(a)});let{head:ne,body:re,returnType:ie}=i.fnToWgsl({functionType:e.includes("@compute")?"compute":e.includes("@vertex")?"vertex":e.includes("@fragment")?"fragment":"normal",argTypes:o,params:g.params,returnType:a,body:g.body,externalMap:u});return i.addDeclaration(`${e}fn ${p}${i.resolve(ne).value}${i.resolve(re).value}`),E(p,ie,"runtime")}},s=d(n);return s!==void 0&&f(t,s),t}function Z(n,e,r,t){let s=n.resolve(t).value.replace(/\s/g,"");if(!r)return s;let i=r.replace(/\s/g,"");if(i!==s)throw new Error(`Type mismatch between TGPU shell and WGSL code string: ${e}, JS type "${s}", WGSL type "${i}".`);return r}function fe(n,e={}){let r=0,t=new Set;return Object.fromEntries(Object.entries(n??{}).map(([s,i])=>{let o=I(i);if(o!==void 0){if(t.has(o))throw new Error("Duplicate custom location attributes found");t.add(o)}return[s,i]}).map(([s,i])=>{if(C(i))return[s,i];if(I(i)!==void 0)return[s,i];if(e[s])return[s,V(e[s],i)];for(;t.has(r);)r++;return[s,V(r++,i)]}))}function b(n,e={}){return K(n)?N(n)||C(n)||I(n)!==void 0?n:V(0,n):J(fe(n,e))}function te(n,...e){return xe(n)?ge(n,...e):n}function xe(n){return Array.isArray(n)&&"raw"in n&&Array.isArray(n.raw)&&n.raw.every(e=>typeof e=="string")}function ge(n,...e){return n.slice(1).reduce((r,t,s)=>`${r}${e[s]}${t}`,n[0])}function qe(n){if(Object.keys(n.out).length===0)throw new Error("A vertexFn output cannot be empty since it must include the 'position' builtin.");let e={in:n.in,out:n.out,argTypes:n.in&&Object.keys(n.in).length!==0?[b(n.in)]:[],isEntry:!0};return Object.assign((t,...s)=>ye(e,te(t,...s)),e)}function ye(n,e){let r=ee(e,"@vertex "),t=n.argTypes[0];return{shell:n,$uses(i){return r.applyExternals(i),this},[B]:!0,[D]:r,$name(i){return f(r,i),M(t)&&t.$name(`${i}_Input`),this},[W](i){let o=b(n.out,i.varyingLocations).$name(`${d(this)??""}_Output`);return typeof e=="string"&&(t&&r.applyExternals({In:t}),r.applyExternals({Out:o})),r.resolve(i,n.argTypes,o)},toString(){return`vertexFn:${d(r)??"<unnamed>"}`}}}export{O as a,Te as b,we as c,R as d,ee as e,b as f,te as g,qe as h};
//# sourceMappingURL=chunk-D5UYO3OX.js.map
{"version":3,"sources":["../src/core/resolve/externals.ts","../src/core/function/extractArgs.ts","../src/core/function/fnCore.ts","../src/core/function/ioSchema.ts","../src/core/function/templateUtils.ts","../src/core/function/tgpuVertexFn.ts"],"sourcesContent":["import { isLooseData } from '../../data/dataTypes.ts';\nimport { isWgslStruct } from '../../data/wgslTypes.ts';\nimport { getName, hasTinyestMetadata, setName } from '../../shared/meta.ts';\nimport { isWgsl, type ResolutionCtx } from '../../types.ts';\n\n/**\n * A key-value mapping where keys represent identifiers within shader code,\n * and values can be any type that can be resolved to a code string.\n */\nexport type ExternalMap = Record<string, unknown>;\n\n/**\n * Merges two external maps into one. If a key is present in both maps, the value from the new map is used.\n * If the external value is a namable object, it is given a name if it does not already have one.\n * @param existing - The existing external map.\n * @param newExternals - The new external map.\n */\nexport function applyExternals(\n existing: ExternalMap,\n newExternals: ExternalMap,\n) {\n for (const [key, value] of Object.entries(newExternals)) {\n existing[key] = value;\n\n // Giving name to external value, if it does not already have one.\n if (\n value && (typeof value === 'object' || typeof value === 'function') &&\n getName(value) === undefined\n ) {\n setName(value, key);\n }\n }\n}\n\nexport function addArgTypesToExternals(\n implementation: string,\n argTypes: unknown[],\n applyExternals: (externals: ExternalMap) => void,\n) {\n const argTypeNames = [\n ...implementation.matchAll(/:\\s*(?<arg>.*?)\\s*[,)]/g),\n ].map((found) => (found ? found[1] : undefined));\n\n applyExternals(\n Object.fromEntries(\n argTypes.flatMap((argType, i) => {\n const argTypeName = argTypeNames ? argTypeNames[i] : undefined;\n return isWgslStruct(argType) && argTypeName !== undefined\n ? [[argTypeName, argType]]\n : [];\n }),\n ),\n );\n}\n\nexport function addReturnTypeToExternals(\n implementation: string,\n returnType: unknown,\n applyExternals: (externals: ExternalMap) => void,\n) {\n const matched = implementation.match(/->\\s(?<output>[\\w\\d_]+)\\s{/);\n const outputName = matched ? matched[1]?.trim() : undefined;\n\n if (isWgslStruct(returnType) && outputName && !/\\s/g.test(outputName)) {\n applyExternals({ [outputName]: returnType });\n }\n}\n\nfunction identifierRegex(name: string) {\n return new RegExp(\n `(?<![\\\\w\\\\$_.])${\n name.replaceAll('.', '\\\\.').replaceAll('$', '\\\\$')\n }(?![\\\\w\\\\$_])`,\n 'g',\n );\n}\n\n/**\n * Replaces all occurrences of external names in WGSL code with their resolved values.\n * It adds all necessary definitions to the resolution context.\n * @param ctx - The resolution context.\n * @param externalMap - The external map.\n * @param wgsl - The WGSL code.\n *\n * @returns The WGSL code with all external names replaced with their resolved values.\n */\nexport function replaceExternalsInWgsl(\n ctx: ResolutionCtx,\n externalMap: ExternalMap,\n wgsl: string,\n): string {\n return Object.entries(externalMap).reduce((acc, [externalName, external]) => {\n const externalRegex = identifierRegex(externalName);\n if (\n wgsl &&\n externalName !== 'Out' &&\n externalName !== 'In' &&\n !externalRegex.test(wgsl)\n ) {\n console.warn(\n `The external '${externalName}' wasn't used in the resolved template.`,\n );\n // continue anyway, we still might need to resolve the external\n }\n\n if (\n isWgsl(external) || isLooseData(external) || hasTinyestMetadata(external)\n ) {\n return acc.replaceAll(externalRegex, ctx.resolve(external).value);\n }\n\n if (external !== null && typeof external === 'object') {\n const foundProperties = [\n ...wgsl.matchAll(\n new RegExp(\n `${\n externalName.replaceAll('.', '\\\\.').replaceAll('$', '\\\\$')\n }\\\\.(?<prop>.*?)(?![\\\\w\\\\$_])`,\n 'g',\n ),\n ),\n ].map((found) => found[1]);\n const uniqueProperties = [...new Set(foundProperties)];\n\n return uniqueProperties.reduce(\n (innerAcc: string, prop) =>\n prop && prop in external\n ? replaceExternalsInWgsl(\n ctx,\n {\n [`${externalName}.${prop}`]:\n external[prop as keyof typeof external],\n },\n innerAcc,\n )\n : innerAcc,\n acc,\n );\n }\n\n console.warn(\n `During resolution, the external '${externalName}' has been omitted. Only TGPU resources, 'use gpu' functions, primitives, and plain JS objects can be used as externals.`,\n );\n\n return acc;\n }, wgsl);\n}\n","interface FunctionArgsInfo {\n args: ArgInfo[];\n ret: ReturnInfo | undefined;\n range: {\n begin: number;\n end: number;\n };\n}\n\ninterface ArgInfo {\n identifier: string;\n attributes: string[];\n type: string | undefined;\n}\n\ninterface ReturnInfo {\n attributes: string[];\n type: string;\n}\n\n/**\n * Extracts info about arguments of a given WGSL function string.\n * @example\n * const code = `\n * fn add(a: i32, @location(0) b: i32, c) -> i32 {\n * return a + b + c;\n * }`;\n *\n * extractArgs(code);\n * // {\n * // args: [\n * // { identifier: 'a', attributes: [], type: 'i32' },\n * // { identifier: 'b', attributes: ['@location(0)'], type: 'i32' },\n * // { identifier: 'c', attributes: [], type: undefined }\n * // ],\n * // ret: { type: 'i32', attributes: [] },\n * // range: { begin: 11, end: 51 }\n * // }\n */\nexport function extractArgs(rawCode: string): FunctionArgsInfo {\n const { strippedCode, argRange: range } = strip(rawCode);\n const code = new ParsableString(strippedCode);\n code.consume('(');\n\n const args: ArgInfo[] = [];\n while (!code.isAt(')')) {\n // In each loop iteration, process all the attributes, the identifier and the potential type of a single argument.\n\n const attributes = [];\n while (code.isAt('@')) {\n code.parseUntil(closingParenthesis, parentheses);\n code.consume(')');\n attributes.push(code.lastParsed);\n }\n\n code.parseUntil(identifierEndSymbols);\n const identifier = code.lastParsed;\n\n let maybeType: string | undefined;\n if (code.isAt(':')) {\n code.consume(':');\n code.parseUntil(typeEndSymbols, angleBrackets);\n maybeType = code.lastParsed;\n }\n\n args.push({\n identifier,\n attributes,\n type: maybeType,\n });\n\n if (code.isAt(',')) {\n code.consume(',');\n }\n }\n code.consume(')');\n\n let maybeRet: ReturnInfo | undefined;\n if (code.isAt('->')) {\n code.consume('->');\n\n const attributes = [];\n while (code.isAt('@')) {\n code.parseUntil(closingParenthesis, parentheses);\n code.consume(')');\n attributes.push(code.lastParsed);\n }\n\n maybeRet = { type: code.str.slice(code.pos), attributes };\n }\n\n return {\n args,\n ret: maybeRet,\n range: { begin: range[0], end: range[1] },\n };\n}\n\n/**\n * Strips comments, whitespaces, the name and the body of the function.\n * @example\n * const code = `\n * fn add( a, // first argument\n * @location(0) b : i32 ) -> i32 {\n * return a + b; // returns the sum\n * }`;\n *\n * strip(code); // \"(a,@location(0)b:i32)->i32\"\n */\nfunction strip(\n rawCode: string,\n): { strippedCode: string; argRange: [number, number] } {\n const code = new ParsableString(rawCode);\n let strippedCode = '';\n let argsStart: number | undefined;\n\n while (!code.isFinished()) {\n // parse character by character while ignoring comments and blankspaces until you find a `{`.\n\n // skip any blankspace\n if (code.isAt(blankSpaces)) {\n code.advanceBy(1); // the blankspace character\n continue;\n }\n\n // skip line comments\n if (code.isAt('//')) {\n code.consume('//');\n code.parseUntil(lineBreaks);\n code.advanceBy(1); // the line break\n continue;\n }\n\n // skip block comments\n if (code.isAt('/*')) {\n code.parseUntil(openingCommentBlock, commentBlocks);\n code.consume('*/');\n continue;\n }\n\n if (code.isAt('{')) {\n return {\n strippedCode,\n argRange: [argsStart as number, code.pos],\n };\n }\n\n if (code.isAt('(') && argsStart === undefined) {\n argsStart = code.pos;\n }\n\n if (argsStart !== undefined) {\n strippedCode += code.str[code.pos];\n }\n code.advanceBy(1); // parsed character\n }\n throw new Error('Invalid wgsl code!');\n}\n\nclass ParsableString {\n #parseStartPos: number | undefined;\n #pos: number;\n constructor(public readonly str: string) {\n this.#pos = 0;\n }\n\n get pos(): number {\n return this.#pos;\n }\n\n /**\n * This property is equivalent to the substring of `this.str`\n * from the position of the last `parseUntil` call, to the current position.\n */\n get lastParsed(): string {\n if (this.#parseStartPos === undefined) {\n throw new Error('Parse was not called yet!');\n }\n return this.str.slice(this.#parseStartPos, this.pos);\n }\n\n isFinished() {\n return this.#pos >= this.str.length;\n }\n\n isAt(substr: string | Set<string>): boolean {\n if (typeof substr === 'string') {\n for (let i = 0; i < substr.length; i++) {\n if (this.str[this.#pos + i] !== substr[i]) {\n return false;\n }\n }\n return true;\n }\n for (const elem of substr) {\n if (this.isAt(elem)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @param toFind a set of strings either of which satisfy the search.\n * @param brackets a pair of brackets that has to be closed for result to be valid. This includes the found character(s).\n * @example\n * // internal state:\n * // '(@attribute(0) identifier: type)'\n * // ^\n * this.parse(new Set(')'), ['(', ')']);\n * // internal state:\n * // '(@attribute(0) identifier: type)'\n * // ^\n */\n parseUntil(\n toFind: Set<string>,\n brackets?: readonly [string, string],\n ): number {\n this.#parseStartPos = this.#pos;\n let openedBrackets = 0;\n while (this.#pos < this.str.length) {\n if (brackets && this.isAt(brackets[0])) {\n openedBrackets += 1;\n }\n if (brackets && this.isAt(brackets[1])) {\n openedBrackets -= 1;\n }\n if (openedBrackets === 0) {\n if (this.isAt(toFind)) {\n return this.#pos;\n }\n }\n this.#pos += 1;\n }\n throw new Error('Reached the end of the string without finding a match!');\n }\n\n advanceBy(steps: number) {\n this.#pos += steps;\n }\n\n consume(str: string): void {\n if (!this.isAt(str)) {\n throw new Error(\n `Expected '${str}' at position ${this.#pos}, but found '${\n this.str.slice(this.#pos, this.#pos + str.length)\n }'`,\n );\n }\n this.advanceBy(str.length);\n }\n}\n\nconst lineBreaks = new Set<string>([\n '\\u000A', // line feed\n '\\u000B', // vertical tab\n '\\u000C', // form feed\n '\\u000D', // carriage return\n '\\u0085', // next line\n '\\u2028', // line separator\n '\\u2029', // paragraph separator\n]);\nconst blankSpaces = new Set<string>([\n ...lineBreaks,\n '\\u0020', // space\n '\\u0009', // horizontal tab\n '\\u200E', // left-to-right mark\n '\\u200F', // right-to-left mark\n]);\nconst closingParenthesis = new Set<string>([')']);\nconst identifierEndSymbols = new Set([':', ',', ')']);\nconst typeEndSymbols = new Set([',', ')']);\nconst openingCommentBlock = new Set(['*/']);\n\nconst parentheses = ['(', ')'] as const;\nconst angleBrackets = ['<', '>'] as const;\nconst commentBlocks = ['/*', '*/'] as const;\n","import { getAttributesString } from '../../data/attributes.ts';\nimport { type AnyData, undecorate } from '../../data/dataTypes.ts';\nimport { type ResolvedSnippet, snip } from '../../data/snippet.ts';\nimport { isWgslData, isWgslStruct, Void } from '../../data/wgslTypes.ts';\nimport { MissingLinksError } from '../../errors.ts';\nimport { getMetaData, getName, setName } from '../../shared/meta.ts';\nimport type { ResolutionCtx } from '../../types.ts';\nimport {\n applyExternals,\n type ExternalMap,\n replaceExternalsInWgsl,\n} from '../resolve/externals.ts';\nimport { extractArgs } from './extractArgs.ts';\nimport type { Implementation } from './fnTypes.ts';\n\nexport interface FnCore {\n applyExternals(newExternals: ExternalMap): void;\n resolve(\n ctx: ResolutionCtx,\n argTypes: AnyData[],\n /**\n * The return type of the function. If undefined, the type should be inferred\n * from the implementation (relevant for shellless functions).\n */\n returnType: AnyData | undefined,\n ): ResolvedSnippet;\n}\n\nexport function createFnCore(\n implementation: Implementation,\n fnAttribute = '',\n): FnCore {\n /**\n * External application has to be deferred until resolution because\n * some externals can reference the owner function which has not been\n * initialized yet (like when accessing the Output struct of a vertex\n * entry fn).\n */\n const externalsToApply: ExternalMap[] = [];\n\n const core = {\n applyExternals(newExternals: ExternalMap): void {\n externalsToApply.push(newExternals);\n },\n\n resolve(\n ctx: ResolutionCtx,\n argTypes: AnyData[],\n returnType: AnyData | undefined,\n ): ResolvedSnippet {\n const externalMap: ExternalMap = {};\n\n for (const externals of externalsToApply) {\n applyExternals(externalMap, externals);\n }\n\n const id = ctx.getUniqueName(this);\n\n if (typeof implementation === 'string') {\n if (!returnType) {\n throw new Error(\n 'Explicit return type is required for string implementation',\n );\n }\n\n const replacedImpl = replaceExternalsInWgsl(\n ctx,\n externalMap,\n implementation,\n );\n\n let header = '';\n let body = '';\n\n if (fnAttribute !== '') {\n const input = isWgslStruct(argTypes[0])\n ? `(in: ${ctx.resolve(argTypes[0]).value})`\n : '()';\n\n const attributes = isWgslData(returnType)\n ? getAttributesString(returnType)\n : '';\n const output = returnType !== Void\n ? isWgslStruct(returnType)\n ? `-> ${ctx.resolve(returnType).value}`\n : `-> ${attributes !== '' ? attributes : '@location(0)'} ${\n ctx.resolve(returnType).value\n }`\n : '';\n\n header = `${input} ${output} `;\n body = replacedImpl;\n } else {\n const providedArgs = extractArgs(replacedImpl);\n\n if (providedArgs.args.length !== argTypes.length) {\n throw new Error(\n `WGSL implementation has ${providedArgs.args.length} arguments, while the shell has ${argTypes.length} arguments.`,\n );\n }\n\n const input = providedArgs.args.map((argInfo, i) =>\n `${argInfo.identifier}: ${\n checkAndReturnType(\n ctx,\n `parameter ${argInfo.identifier}`,\n argInfo.type,\n argTypes[i],\n )\n }`\n ).join(', ');\n\n const output = returnType === Void ? '' : `-> ${\n checkAndReturnType(\n ctx,\n 'return type',\n providedArgs.ret?.type,\n returnType,\n )\n }`;\n\n header = `(${input}) ${output}`;\n\n body = replacedImpl.slice(providedArgs.range.end);\n }\n\n ctx.addDeclaration(`${fnAttribute}fn ${id}${header}${body}`);\n return snip(id, returnType, /* origin */ 'runtime');\n }\n\n // get data generated by the plugin\n const pluginData = getMetaData(implementation);\n\n // Passing a record happens prior to version 0.9.0\n // TODO: Support for this can be removed down the line\n const pluginExternals = typeof pluginData?.externals === 'function'\n ? pluginData.externals()\n : pluginData?.externals;\n\n if (pluginExternals) {\n const missing = Object.fromEntries(\n Object.entries(pluginExternals).filter(\n ([name]) => !(name in externalMap),\n ),\n );\n\n applyExternals(externalMap, missing);\n }\n\n const ast = pluginData?.ast;\n if (!ast) {\n throw new Error(\n \"Missing metadata for tgpu.fn function body (either missing 'use gpu' directive, or misconfigured `unplugin-typegpu`)\",\n );\n }\n\n // verify all required externals are present\n const missingExternals = ast.externalNames.filter(\n (name) => !(name in externalMap),\n );\n if (missingExternals.length > 0) {\n throw new MissingLinksError(getName(this), missingExternals);\n }\n\n // If an entrypoint implementation has a second argument, it represents the output schema.\n // We look at the identifier chosen by the user and add it to externals.\n const maybeSecondArg = ast.params[1];\n if (\n maybeSecondArg && maybeSecondArg.type === 'i' && fnAttribute !== ''\n ) {\n applyExternals(\n externalMap,\n {\n // biome-ignore lint/style/noNonNullAssertion: entry functions cannot be shellless\n [maybeSecondArg.name]: undecorate(returnType!),\n },\n );\n }\n\n // generate wgsl string\n\n const { head, body, returnType: actualReturnType } = ctx.fnToWgsl({\n functionType: fnAttribute.includes('@compute')\n ? 'compute'\n : fnAttribute.includes('@vertex')\n ? 'vertex'\n : fnAttribute.includes('@fragment')\n ? 'fragment'\n : 'normal',\n argTypes,\n params: ast.params,\n returnType,\n body: ast.body,\n externalMap,\n });\n\n ctx.addDeclaration(\n `${fnAttribute}fn ${id}${ctx.resolve(head).value}${\n ctx.resolve(body).value\n }`,\n );\n\n return snip(id, actualReturnType, /* origin */ 'runtime');\n },\n };\n\n // The implementation could have been given a name by a bundler plugin,\n // so we try to transfer it to the core.\n const maybeName = getName(implementation);\n if (maybeName !== undefined) {\n setName(core, maybeName);\n }\n\n return core;\n}\n\nfunction checkAndReturnType(\n ctx: ResolutionCtx,\n name: string,\n wgslType: string | undefined,\n jsType: unknown,\n) {\n const resolvedJsType = ctx.resolve(jsType).value.replace(/\\s/g, '');\n\n if (!wgslType) {\n return resolvedJsType;\n }\n\n const resolvedWgslType = wgslType.replace(/\\s/g, '');\n\n if (resolvedWgslType !== resolvedJsType) {\n throw new Error(\n `Type mismatch between TGPU shell and WGSL code string: ${name}, JS type \"${resolvedJsType}\", WGSL type \"${resolvedWgslType}\".`,\n );\n }\n\n return wgslType;\n}\n","import {\n type Decorate,\n type HasCustomLocation,\n type IsBuiltin,\n location,\n} from '../../data/attributes.ts';\nimport { isBuiltin } from '../../data/attributes.ts';\nimport { getCustomLocation, isData } from '../../data/dataTypes.ts';\nimport { struct } from '../../data/struct.ts';\nimport {\n type BaseData,\n isVoid,\n type Location,\n type WgslStruct,\n} from '../../data/wgslTypes.ts';\nimport type { IOData, IOLayout, IORecord } from './fnTypes.ts';\n\nexport type WithLocations<T extends IORecord> = {\n [Key in keyof T]: IsBuiltin<T[Key]> extends true ? T[Key]\n : HasCustomLocation<T[Key]> extends true ? T[Key]\n : Decorate<T[Key], Location>;\n};\n\nexport type IOLayoutToSchema<T extends IOLayout> = T extends BaseData\n ? Decorate<T, Location<0>>\n : T extends IORecord ? WgslStruct<WithLocations<T>>\n // biome-ignore lint/suspicious/noConfusingVoidType: <it actually is void>\n : T extends { type: 'void' } ? void\n : never;\n\nexport function withLocations<T extends IOData>(\n members: IORecord<T> | undefined,\n locations: Record<string, number> = {},\n): WithLocations<IORecord<T>> {\n let nextLocation = 0;\n const usedCustomLocations = new Set<number>();\n\n return Object.fromEntries(\n Object.entries(members ?? {}).map(([key, member]) => {\n const customLocation = getCustomLocation(member);\n\n if (customLocation !== undefined) {\n if (usedCustomLocations.has(customLocation)) {\n throw new Error('Duplicate custom location attributes found');\n }\n usedCustomLocations.add(customLocation);\n }\n\n return [key, member] as const;\n }).map(([key, member]) => {\n if (isBuiltin(member)) { // skipping builtins\n return [key, member];\n }\n\n if (getCustomLocation(member) !== undefined) { // this member is already marked\n return [key, member];\n }\n\n if (locations[key]) { // location has been determined by a previous procedure\n return [key, location(locations[key], member)];\n }\n\n while (usedCustomLocations.has(nextLocation)) {\n nextLocation++;\n }\n return [key, location(nextLocation++, member)];\n }),\n );\n}\n\nexport function createIoSchema<\n T extends IOData,\n Layout extends IORecord<T> | IOLayout<T>,\n>(layout: Layout, locations: Record<string, number> = {}) {\n return (\n isData(layout)\n ? isVoid(layout)\n ? layout\n : isBuiltin(layout)\n ? layout\n : getCustomLocation(layout) !== undefined\n ? layout\n : location(0, layout)\n : struct(withLocations(layout, locations) as Record<string, T>)\n ) as IOLayoutToSchema<Layout>;\n}\n","import type { Implementation } from './fnTypes.ts';\n\nexport function stripTemplate(\n arg: Implementation | TemplateStringsArray,\n ...values: unknown[]\n): Implementation {\n return isTemplateStringsArray(arg)\n ? templateLiteralIdentity(arg, ...values)\n : arg;\n}\n\nfunction isTemplateStringsArray(value: unknown): value is TemplateStringsArray {\n return (\n Array.isArray(value) &&\n 'raw' in value &&\n Array.isArray(value.raw) &&\n value.raw.every((item) => typeof item === 'string')\n );\n}\n\nfunction templateLiteralIdentity(\n strings: TemplateStringsArray,\n ...values: unknown[]\n): string {\n return strings\n .slice(1)\n .reduce(\n (acc, elem, index) => `${acc}${values[index]}${elem}`,\n strings[0] as string,\n );\n}\n","import type {\n AnyVertexInputBuiltin,\n AnyVertexOutputBuiltin,\n OmitBuiltins,\n} from '../../builtin.ts';\nimport type { ResolvedSnippet } from '../../data/snippet.ts';\nimport type {\n Decorated,\n Interpolate,\n Location,\n WgslStruct,\n} from '../../data/wgslTypes.ts';\nimport {\n getName,\n isNamable,\n setName,\n type TgpuNamable,\n} from '../../shared/meta.ts';\nimport { $getNameForward, $internal, $resolve } from '../../shared/symbols.ts';\nimport type { ResolutionCtx, SelfResolvable } from '../../types.ts';\nimport { createFnCore, type FnCore } from './fnCore.ts';\nimport type {\n BaseIOData,\n Implementation,\n InferIO,\n IORecord,\n} from './fnTypes.ts';\nimport { createIoSchema, type IOLayoutToSchema } from './ioSchema.ts';\nimport { stripTemplate } from './templateUtils.ts';\n\n// ----------\n// Public API\n// ----------\n\nexport type VertexInConstrained = IORecord<\n BaseIOData | Decorated<BaseIOData, Location[]> | AnyVertexInputBuiltin\n>;\n\nexport type VertexOutConstrained = IORecord<\n | BaseIOData\n | Decorated<BaseIOData, (Location | Interpolate)[]>\n | AnyVertexOutputBuiltin\n>;\n\n/**\n * Describes a vertex entry function signature (its arguments, return type and attributes)\n */\ntype TgpuVertexFnShellHeader<\n VertexIn extends VertexInConstrained,\n VertexOut extends VertexOutConstrained,\n> = {\n readonly in: VertexIn | undefined;\n readonly out: VertexOut;\n readonly argTypes: [IOLayoutToSchema<VertexIn>] | [];\n readonly isEntry: true;\n};\n\n/**\n * Describes a vertex entry function signature (its arguments, return type and attributes).\n * Allows creating tgpu vertex functions by calling this shell\n * and passing the implementation (as WGSL string or JS function) as the argument.\n */\nexport type TgpuVertexFnShell<\n VertexIn extends VertexInConstrained,\n VertexOut extends VertexOutConstrained,\n> =\n & TgpuVertexFnShellHeader<VertexIn, VertexOut>\n & ((\n implementation: (\n input: InferIO<VertexIn>,\n out: WgslStruct<VertexOut>,\n ) => InferIO<VertexOut>,\n ) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>)\n & ((\n implementation: string,\n ) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>)\n & ((\n strings: TemplateStringsArray,\n ...values: unknown[]\n ) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>);\n\nexport interface TgpuVertexFn<\n VertexIn extends VertexInConstrained = VertexInConstrained,\n VertexOut extends VertexOutConstrained = VertexOutConstrained,\n> extends TgpuNamable {\n readonly [$internal]: true;\n readonly shell: TgpuVertexFnShellHeader<VertexIn, VertexOut>;\n $uses(dependencyMap: Record<string, unknown>): this;\n}\n\nexport function vertexFn<VertexOut extends VertexOutConstrained>(options: {\n out: VertexOut;\n // biome-ignore lint/complexity/noBannedTypes: it's fine\n}): TgpuVertexFnShell<{}, VertexOut>;\n\nexport function vertexFn<\n VertexIn extends VertexInConstrained,\n // Not allowing single-value output, as it is better practice\n // to properly label what the vertex shader is outputting.\n VertexOut extends VertexOutConstrained,\n>(options: {\n in: VertexIn;\n out: VertexOut;\n}): TgpuVertexFnShell<VertexIn, VertexOut>;\n\n/**\n * Creates a shell of a typed entry function for the vertex shader stage. Any function\n * that implements this shell can run for each vertex, allowing the inner code to process\n * attributes and determine the final position of the vertex.\n *\n * @param options.in\n * Vertex attributes and builtins to be made available to functions that implement this shell.\n * @param options.out\n * A record containing the final position of the vertex, and any information\n * passed onto the fragment shader stage.\n */\nexport function vertexFn<\n VertexIn extends VertexInConstrained,\n // Not allowing single-value output, as it is better practice\n // to properly label what the vertex shader is outputting.\n VertexOut extends VertexOutConstrained,\n>(options: {\n in?: VertexIn;\n out: VertexOut;\n}): TgpuVertexFnShell<VertexIn, VertexOut> {\n if (Object.keys(options.out).length === 0) {\n throw new Error(\n `A vertexFn output cannot be empty since it must include the 'position' builtin.`,\n );\n }\n const shell: TgpuVertexFnShellHeader<VertexIn, VertexOut> = {\n in: options.in,\n out: options.out,\n argTypes: options.in && Object.keys(options.in).length !== 0\n ? [createIoSchema(options.in)]\n : [],\n isEntry: true,\n };\n\n const call = (\n arg: Implementation | TemplateStringsArray,\n ...values: unknown[]\n ) => createVertexFn(shell, stripTemplate(arg, ...values));\n\n return Object.assign(call, shell) as TgpuVertexFnShell<VertexIn, VertexOut>;\n}\n\n// --------------\n// Implementation\n// --------------\n\nfunction createVertexFn(\n shell: TgpuVertexFnShellHeader<VertexInConstrained, VertexOutConstrained>,\n implementation: Implementation,\n): TgpuVertexFn<VertexInConstrained, VertexOutConstrained> {\n type This =\n & TgpuVertexFn<VertexInConstrained, VertexOutConstrained>\n & SelfResolvable\n & {\n [$internal]: true;\n [$getNameForward]: FnCore;\n };\n\n const core = createFnCore(implementation, '@vertex ');\n const inputType = shell.argTypes[0];\n\n const result: This = {\n shell,\n\n $uses(newExternals) {\n core.applyExternals(newExternals);\n return this;\n },\n\n [$internal]: true,\n [$getNameForward]: core,\n $name(newLabel: string): This {\n setName(core, newLabel);\n if (isNamable(inputType)) {\n inputType.$name(`${newLabel}_Input`);\n }\n return this;\n },\n\n [$resolve](ctx: ResolutionCtx): ResolvedSnippet {\n const outputWithLocation = createIoSchema(\n shell.out,\n ctx.varyingLocations,\n ).$name(`${getName(this) ?? ''}_Output`);\n\n if (typeof implementation === 'string') {\n if (inputType) {\n core.applyExternals({ In: inputType });\n }\n core.applyExternals({ Out: outputWithLocation });\n }\n\n return core.resolve(\n ctx,\n shell.argTypes,\n outputWithLocation,\n );\n },\n\n toString() {\n return `vertexFn:${getName(core) ?? '<unnamed>'}`;\n },\n };\n return result;\n}\n"],"mappings":"uOAiBO,SAASA,EACdC,EACAC,EACA,CACA,OAAW,CAACC,EAAKC,CAAK,IAAK,OAAO,QAAQF,CAAY,EACpDD,EAASE,CAAG,EAAIC,EAIdA,IAAU,OAAOA,GAAU,UAAY,OAAOA,GAAU,aACxDC,EAAQD,CAAK,IAAM,QAEnBE,EAAQF,EAAOD,CAAG,CAGxB,CAEO,SAASI,GACdC,EACAC,EACAT,EACA,CACA,IAAMU,EAAe,CACnB,GAAGF,EAAe,SAAS,yBAAyB,CACtD,EAAE,IAAKG,GAAWA,EAAQA,EAAM,CAAC,EAAI,MAAU,EAE/CX,EACE,OAAO,YACLS,EAAS,QAAQ,CAACG,EAAS,IAAM,CAC/B,IAAMC,EAAcH,EAAeA,EAAa,CAAC,EAAI,OACrD,OAAOI,EAAaF,CAAO,GAAKC,IAAgB,OAC5C,CAAC,CAACA,EAAaD,CAAO,CAAC,EACvB,CAAC,CACP,CAAC,CACH,CACF,CACF,CAEO,SAASG,GACdP,EACAQ,EACAhB,EACA,CACA,I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AAAH,EAAK,eAAeG,CAAY,EACzB,IACT,EAEA,CAACC,CAAS,EAAG,GACb,CAACC,CAAe,EAAGL,EACnB,MAAMM,EAAwB,CAC5B,OAAAC,EAAQP,EAAMM,CAAQ,EAClBE,EAAUN,CAAS,GACrBA,EAAU,MAAM,GAAGI,CAAQ,QAAQ,EAE9B,IACT,EAEA,CAACG,CAAQ,EAAEC,EAAqC,CAC9C,IAAMC,EAAqBjB,EACzBD,EAAM,IACNiB,EAAI,gBACN,EAAE,MAAM,GAAGE,EAAQ,IAAI,GAAK,EAAE,SAAS,EAEvC,OAAI,OAAOb,GAAmB,WACxBG,GACFF,EAAK,eAAe,CAAE,GAAIE,CAAU,CAAC,EAEvCF,EAAK,eAAe,CAAE,IAAKW,CAAmB,CAAC,GAG1CX,EAAK,QACVU,EACAjB,EAAM,SACNkB,CACF,CACF,EAEA,UAAW,CACT,MAAO,YAAYC,EAAQZ,CAAI,GAAK,WAAW,EACjD,CACF,CAEF","names":["applyExternals","existing","newExternals","key","value","getName","setName","addArgTypesToExternals","implementation","argTypes","argTypeNames","found","argType","argTypeName","isWgslStruct","addReturnTypeToExternals","returnType","matched","outputName","identifierRegex","name","replaceExternalsInWgsl","ctx","externalMap","wgsl","acc","externalName","external","externalRegex","isWgsl","isLooseData","hasTinyestMetadata","foundProperties","innerAcc","prop","extractArgs","rawCode","strippedCode","range","strip","code","ParsableString","args","attributes","closingParenthesis","parentheses","identifierEndSymbols","identifier","maybeType","typeEndSymbols","angleBrackets","maybeRet","argsStart","blankSpaces","lineBreaks","openingCommentBlock","commentBlocks","str","#pos","#parseStartPos","substr","i","elem","toFind","brackets","openedBrackets","steps","createFnCore","implementation","fnAttribute","externalsToApply","core","newExternals","ctx","argTypes","returnType","externalMap","externals","applyExternals","id","replacedImpl","replaceExternalsInWgsl","header","body","input","isWgslStruct","attributes","isWgslData","getAttributesString","output","Void","providedArgs","extractArgs","argInfo","i","checkAndReturnType","snip","pluginData","getMetaData","pluginExternals","missing","name","ast","missingExternals","MissingLinksError","getName","maybeSecondArg","undecorate","head","actualReturnType","maybeName","setName","wgslType","jsType","resolvedJsType","resolvedWgslType","withLocations","members","locations","nextLocation","usedCustomLocations","key","member","customLocation","getCustomLocation","isBuiltin","location","createIoSchema","layout","isData","isVoid","struct","stripTemplate","arg","values","isTemplateStringsArray","templateLiteralIdentity","value","item","strings","acc","elem","index","vertexFn","options","shell","createIoSchema","arg","values","createVertexFn","stripTemplate","implementation","core","createFnCore","inputType","newExternals","$internal","$getNameForward","newLabel","setName","isNamable","$resolve","ctx","outputWithLocation","getName"]}
import{A as Ae,Ab as Xe,Bb as Ye,Cb as le,Hb as we,La as v,N as R,_a as G,a,db as f,f as D,fb as De,g as ge,ga as ve,kb as i,lb as Re,nb as fe,ob as Ue,pb as Ke,qb as Ne,r as T,rb as Oe,sb as E,tb as Le,ub as Ge,v as Be,vb as Ee,w as C,wb as je,xb as he,yb as qe,zb as Ze}from"./chunk-SHSILTWI.js";var xe=class{};function Pe(e){let t=f({name:e.type,normalImpl:(...s)=>{let l=[];for(let B of s)if(typeof B=="number")l.push(B);else for(let Ve=0;Ve<B.length;++Ve)l.push(B[Ve]);if(l.length!==0&&l.length!==e.columns*e.rows)throw new Error(`'${e.type}' constructor called with invalid number of arguments.`);for(let B=l.length;B<e.columns*e.rows;++B)l.push(0);return new e.MatImpl(...l)},ignoreImplicitCastWarning:!0,signature:(...s)=>({argTypes:s.map(l=>Be(l)?l:i),returnType:r}),codegenImpl:(...s)=>v`${e.type}(${s})`}),r=Object.assign(t,{type:e.type,identity:ut[e.columns],translation:e.columns===4?ct:void 0,scaling:e.columns===4?ot:void 0,rotationX:e.columns===4?lt:void 0,rotationY:e.columns===4?xt:void 0,rotationZ:e.columns===4?mt:void 0});return e.MatImpl.prototype.schema=r,r}var We=class extends xe{[a]=!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 ve(`${this.kind}(${Array.from({length:this.length}).map((t,r)=>this[r]).join(", ")})`,j,"runtime")}toString(){return this[D]().value}},Fe=class extends We{kind="mat2x2f";makeColumn(t,r){return fe(t,r)}},$e=class extends xe{[a]=!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 ve(`${this.kind}(${this[0]}, ${this[1]}, ${this[2]}, ${this[4]}, ${this[5]}, ${this[6]}, ${this[8]}, ${this[9]}, ${this[10]})`,q,"runtime")}toString(){return this[D]().value}},Ce=class extends $e{kind="mat3x3f";makeColumn(t,r,s){return E(t,r,s)}},ke=class extends xe{[a]=!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 ve(`${this.kind}(${Array.from({length:this.length}).map((t,r)=>this[r]).join(", ")})`,g,"runtime")}toString(){return this[D]().value}},Ie=class extends ke{kind="mat4x4f";makeColumn(t,r,s,l){return he(t,r,s,l)}},st=we(()=>j(1,0,0,1)).$name("identity2"),nt=we(()=>q(1,0,0,0,1,0,0,0,1)).$name("identity3"),at=we(()=>g(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)).$name("identity4"),ut={2:st,3:nt,4:at},ct=f({name:"translation4",normalImpl:e=>g(1,0,0,0,0,1,0,0,0,0,1,0,e.x,e.y,e.z,1),get signature(){return{argTypes:[E],returnType:g}},codegenImpl:e=>v`mat4x4f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, ${e}.x, ${e}.y, ${e}.z, 1)`}),ot=f({name:"scaling4",normalImpl:e=>g(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1),get signature(){return{argTypes:[E],returnType:g}},codegenImpl:e=>v`mat4x4f(${e}.x, 0, 0, 0, 0, ${e}.y, 0, 0, 0, 0, ${e}.z, 0, 0, 0, 0, 1)`}),lt=f({name:"rotationX4",normalImpl:e=>g(1,0,0,0,0,Math.cos(e),Math.sin(e),0,0,-Math.sin(e),Math.cos(e),0,0,0,0,1),get signature(){return{argTypes:[i],returnType:g}},codegenImpl:e=>v`mat4x4f(1, 0, 0, 0, 0, cos(${e}), sin(${e}), 0, 0, -sin(${e}), cos(${e}), 0, 0, 0, 0, 1)`}),xt=f({name:"rotationY4",normalImpl:e=>g(Math.cos(e),0,-Math.sin(e),0,0,1,0,0,Math.sin(e),0,Math.cos(e),0,0,0,0,1),get signature(){return{argTypes:[i],returnType:g}},codegenImpl:e=>v`mat4x4f(cos(${e}), 0, -sin(${e}), 0, 0, 1, 0, 0, sin(${e}), 0, cos(${e}), 0, 0, 0, 0, 1)`}),mt=f({name:"rotationZ4",normalImpl:e=>g(Math.cos(e),Math.sin(e),0,0,-Math.sin(e),Math.cos(e),0,0,0,0,1,0,0,0,0,1),get signature(){return{argTypes:[i],returnType:g}},codegenImpl:e=>v`mat4x4f(cos(${e}), sin(${e}), 0, 0, -sin(${e}), cos(${e}), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)`}),j=Pe({type:"mat2x2f",rows:2,columns:2,MatImpl:Fe}),q=Pe({type:"mat3x3f",rows:3,columns:3,MatImpl:Ce}),g=Pe({type:"mat4x4f",rows:4,columns:4,MatImpl:Ie});function Lt(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,r)=>e[r])}var U=(e,t,r)=>{if(e===t)return 0;let s=n((r-e)/(t-e),0,1);return s*s*(3-2*s)},n=(e,t,r)=>Math.min(Math.max(t,e),r),K=(e,t)=>t===0?e:Math.trunc(e/t);function A(e){let t=new DataView(new ArrayBuffer(4));return t.setUint32(0,e,!0),t.getFloat32(0,!0)}function W(e){let t=new DataView(new ArrayBuffer(4));return t.setUint32(0,e,!0),t.getInt32(0,!0)}var w=Oe[a].jsImpl,z=fe[a].jsImpl,I=Ue[a].jsImpl,ue=Ke[a].jsImpl,Te=Ne[a].jsImpl,b=je[a].jsImpl,h=E[a].jsImpl,F=Le[a].jsImpl,ce=Ge[a].jsImpl,de=Ee[a].jsImpl,M=Ye[a].jsImpl,S=he[a].jsImpl,P=qe[a].jsImpl,oe=Ze[a].jsImpl,pe=Xe[a].jsImpl,Z=e=>Math.sqrt(e.x**2+e.y**2),X=e=>Math.sqrt(e.x**2+e.y**2+e.z**2),Y=e=>Math.sqrt(e.x**2+e.y**2+e.z**2+e.w**2),be=(e,t)=>e.x*t.x+e.y*t.y,Me=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z,ze=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,o=e=>t=>z(e(t.x),e(t.y)),x=e=>t=>I(e(t.x),e(t.y)),H=e=>t=>ue(e(t.x),e(t.y)),me=e=>t=>Te(e(t.x),e(t.y)),c=e=>t=>h(e(t.x),e(t.y),e(t.z)),m=e=>t=>F(e(t.x),e(t.y),e(t.z)),J=e=>t=>ce(e(t.x),e(t.y),e(t.z)),ye=e=>t=>de(e(t.x),e(t.y),e(t.z)),u=e=>t=>S(e(t.x),e(t.y),e(t.z),e(t.w)),y=e=>t=>P(e(t.x),e(t.y),e(t.z),e(t.w)),Q=e=>t=>oe(e(t.x),e(t.y),e(t.z),e(t.w)),ie=e=>t=>pe(e(t.x),e(t.y),e(t.z),e(t.w)),He=e=>t=>{let r=t.columns;return j(o(e)(r[0]),o(e)(r[1]))},Je=e=>t=>{let r=t.columns;return q(c(e)(r[0]),c(e)(r[1]),c(e)(r[2]))},Qe=e=>t=>{let r=t.columns;return g(u(e)(r[0]),u(e)(r[1]),u(e)(r[2]),u(e)(r[3]))},k=e=>(t,r)=>z(e(t.x,r.x),e(t.y,r.y)),N=e=>(t,r)=>I(e(t.x,r.x),e(t.y,r.y)),ee=e=>(t,r)=>ue(e(t.x,r.x),e(t.y,r.y)),te=e=>(t,r)=>Te(e(t.x,r.x),e(t.y,r.y)),$=e=>(t,r)=>h(e(t.x,r.x),e(t.y,r.y),e(t.z,r.z)),O=e=>(t,r)=>F(e(t.x,r.x),e(t.y,r.y),e(t.z,r.z)),re=e=>(t,r)=>ce(e(t.x,r.x),e(t.y,r.y),e(t.z,r.z)),se=e=>(t,r)=>de(e(t.x,r.x),e(t.y,r.y),e(t.z,r.z)),V=e=>(t,r)=>S(e(t.x,r.x),e(t.y,r.y),e(t.z,r.z),e(t.w,r.w)),L=e=>(t,r)=>P(e(t.x,r.x),e(t.y,r.y),e(t.z,r.z),e(t.w,r.w)),ne=e=>(t,r)=>oe(e(t.x,r.x),e(t.y,r.y),e(t.z,r.z),e(t.w,r.w)),ae=e=>(t,r)=>pe(e(t.x,r.x),e(t.y,r.y),e(t.z,r.z),e(t.w,r.w)),yt=e=>(t,r)=>{let s=t.columns,l=r.columns;return j(k(e)(s[0],l[0]),k(e)(s[1],l[1]))},it=e=>(t,r)=>{let s=t.columns,l=r.columns;return q($(e)(s[0],l[0]),$(e)(s[1],l[1]),$(e)(s[2],l[2]))},Tt=e=>(t,r)=>{let s=t.columns,l=r.columns;return g(V(e)(s[0],l[0]),V(e)(s[1],l[1]),V(e)(s[2],l[2]),V(e)(s[3],l[3]))},dt=e=>(t,r,s)=>z(e(t.x,r.x,s.x),e(t.y,r.y,s.y)),pt=e=>(t,r,s)=>I(e(t.x,r.x,s.x),e(t.y,r.y,s.y)),gt=e=>(t,r,s)=>h(e(t.x,r.x,s.x),e(t.y,r.y,s.y),e(t.z,r.z,s.z)),vt=e=>(t,r,s)=>F(e(t.x,r.x,s.x),e(t.y,r.y,s.y),e(t.z,r.z,s.z)),ft=e=>(t,r,s)=>S(e(t.x,r.x,s.x),e(t.y,r.y,s.y),e(t.z,r.z,s.z),e(t.w,r.w,s.w)),ht=e=>(t,r,s)=>P(e(t.x,r.x,s.x),e(t.y,r.y,s.y),e(t.z,r.z,s.z),e(t.w,r.w,s.w)),d={eq:{vec2f:(e,t)=>w(e.x===t.x,e.y===t.y),vec2h:(e,t)=>w(e.x===t.x,e.y===t.y),vec2i:(e,t)=>w(e.x===t.x,e.y===t.y),vec2u:(e,t)=>w(e.x===t.x,e.y===t.y),"vec2<bool>":(e,t)=>w(e.x===t.x,e.y===t.y),vec3f:(e,t)=>b(e.x===t.x,e.y===t.y,e.z===t.z),vec3h:(e,t)=>b(e.x===t.x,e.y===t.y,e.z===t.z),vec3i:(e,t)=>b(e.x===t.x,e.y===t.y,e.z===t.z),vec3u:(e,t)=>b(e.x===t.x,e.y===t.y,e.z===t.z),"vec3<bool>":(e,t)=>b(e.x===t.x,e.y===t.y,e.z===t.z),vec4f:(e,t)=>M(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4h:(e,t)=>M(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4i:(e,t)=>M(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4u:(e,t)=>M(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),"vec4<bool>":(e,t)=>M(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w)},lt:{vec2f:(e,t)=>w(e.x<t.x,e.y<t.y),vec2h:(e,t)=>w(e.x<t.x,e.y<t.y),vec2i:(e,t)=>w(e.x<t.x,e.y<t.y),vec2u:(e,t)=>w(e.x<t.x,e.y<t.y),vec3f:(e,t)=>b(e.x<t.x,e.y<t.y,e.z<t.z),vec3h:(e,t)=>b(e.x<t.x,e.y<t.y,e.z<t.z),vec3i:(e,t)=>b(e.x<t.x,e.y<t.y,e.z<t.z),vec3u:(e,t)=>b(e.x<t.x,e.y<t.y,e.z<t.z),vec4f:(e,t)=>M(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4h:(e,t)=>M(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4i:(e,t)=>M(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4u:(e,t)=>M(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w)},or:{"vec2<bool>":(e,t)=>w(e.x||t.x,e.y||t.y),"vec3<bool>":(e,t)=>b(e.x||t.x,e.y||t.y,e.z||t.z),"vec4<bool>":(e,t)=>M(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:o(Math.abs),vec2h:x(Math.abs),vec2i:H(Math.abs),vec2u:me(Math.abs),vec3f:c(Math.abs),vec3h:m(Math.abs),vec3i:J(Math.abs),vec3u:ye(Math.abs),vec4f:u(Math.abs),vec4h:y(Math.abs),vec4i:Q(Math.abs),vec4u:ie(Math.abs)},atan2:{vec2f:k(Math.atan2),vec2h:N(Math.atan2),vec3f:$(Math.atan2),vec3h:O(Math.atan2),vec4f:V(Math.atan2),vec4h:L(Math.atan2)},acos:{vec2f:o(Math.acos),vec2h:x(Math.acos),vec2i:H(Math.acos),vec2u:me(Math.acos),vec3f:c(Math.acos),vec3h:m(Math.acos),vec3i:J(Math.acos),vec3u:ye(Math.acos),vec4f:u(Math.acos),vec4h:y(Math.acos),vec4i:Q(Math.acos),vec4u:ie(Math.acos)},acosh:{vec2f:o(Math.acosh),vec2h:x(Math.acosh),vec3f:c(Math.acosh),vec3h:m(Math.acosh),vec4f:u(Math.acosh),vec4h:y(Math.acosh)},asin:{vec2f:o(Math.asin),vec2h:x(Math.asin),vec3f:c(Math.asin),vec3h:m(Math.asin),vec4f:u(Math.asin),vec4h:y(Math.asin)},asinh:{vec2f:o(Math.asinh),vec2h:x(Math.asinh),vec3f:c(Math.asinh),vec3h:m(Math.asinh),vec4f:u(Math.asinh),vec4h:y(Math.asinh)},atan:{vec2f:o(Math.atan),vec2h:x(Math.atan),vec3f:c(Math.atan),vec3h:m(Math.atan),vec4f:u(Math.atan),vec4h:y(Math.atan)},atanh:{vec2f:o(Math.atanh),vec2h:x(Math.atanh),vec3f:c(Math.atanh),vec3h:m(Math.atanh),vec4f:u(Math.atanh),vec4h:y(Math.atanh)},ceil:{vec2f:o(Math.ceil),vec2h:x(Math.ceil),vec3f:c(Math.ceil),vec3h:m(Math.ceil),vec4f:u(Math.ceil),vec4h:y(Math.ceil)},clamp:{vec2f:(e,t,r)=>z(n(e.x,t.x,r.x),n(e.y,t.y,r.y)),vec2h:(e,t,r)=>I(n(e.x,t.x,r.x),n(e.y,t.y,r.y)),vec2i:(e,t,r)=>ue(n(e.x,t.x,r.x),n(e.y,t.y,r.y)),vec2u:(e,t,r)=>Te(n(e.x,t.x,r.x),n(e.y,t.y,r.y)),vec3f:(e,t,r)=>h(n(e.x,t.x,r.x),n(e.y,t.y,r.y),n(e.z,t.z,r.z)),vec3h:(e,t,r)=>F(n(e.x,t.x,r.x),n(e.y,t.y,r.y),n(e.z,t.z,r.z)),vec3i:(e,t,r)=>ce(n(e.x,t.x,r.x),n(e.y,t.y,r.y),n(e.z,t.z,r.z)),vec3u:(e,t,r)=>de(n(e.x,t.x,r.x),n(e.y,t.y,r.y),n(e.z,t.z,r.z)),vec4f:(e,t,r)=>S(n(e.x,t.x,r.x),n(e.y,t.y,r.y),n(e.z,t.z,r.z),n(e.w,t.w,r.w)),vec4h:(e,t,r)=>P(n(e.x,t.x,r.x),n(e.y,t.y,r.y),n(e.z,t.z,r.z),n(e.w,t.w,r.w)),vec4i:(e,t,r)=>oe(n(e.x,t.x,r.x),n(e.y,t.y,r.y),n(e.z,t.z,r.z),n(e.w,t.w,r.w)),vec4u:(e,t,r)=>pe(n(e.x,t.x,r.x),n(e.y,t.y,r.y),n(e.z,t.z,r.z),n(e.w,t.w,r.w))},length:{vec2f:Z,vec2h:Z,vec3f:X,vec3h:X,vec4f:Y,vec4h:Y},add:{vec2f:k((e,t)=>e+t),vec2h:N((e,t)=>e+t),vec2i:ee((e,t)=>e+t),vec2u:te((e,t)=>e+t),vec3f:$((e,t)=>e+t),vec3h:O((e,t)=>e+t),vec3i:re((e,t)=>e+t),vec3u:se((e,t)=>e+t),vec4f:V((e,t)=>e+t),vec4h:L((e,t)=>e+t),vec4i:ne((e,t)=>e+t),vec4u:ae((e,t)=>e+t),mat2x2f:yt((e,t)=>e+t),mat3x3f:it((e,t)=>e+t),mat4x4f:Tt((e,t)=>e+t)},smoothstep:{vec2f:dt(U),vec2h:pt(U),vec3f:gt(U),vec3h:vt(U),vec4f:ft(U),vec4h:ht(U)},addMixed:{vec2f:(e,t)=>o(r=>r+t)(e),vec2h:(e,t)=>x(r=>r+t)(e),vec2i:(e,t)=>H(r=>r+t)(e),vec2u:(e,t)=>me(r=>r+t)(e),vec3f:(e,t)=>c(r=>r+t)(e),vec3h:(e,t)=>m(r=>r+t)(e),vec3i:(e,t)=>J(r=>r+t)(e),vec3u:(e,t)=>ye(r=>r+t)(e),vec4f:(e,t)=>u(r=>r+t)(e),vec4h:(e,t)=>y(r=>r+t)(e),vec4i:(e,t)=>Q(r=>r+t)(e),vec4u:(e,t)=>ie(r=>r+t)(e),mat2x2f:(e,t)=>He(r=>r+t)(e),mat3x3f:(e,t)=>Je(r=>r+t)(e),mat4x4f:(e,t)=>Qe(r=>r+t)(e)},mulSxV:{vec2f:(e,t)=>o(r=>e*r)(t),vec2h:(e,t)=>x(r=>e*r)(t),vec2i:(e,t)=>H(r=>e*r)(t),vec2u:(e,t)=>me(r=>e*r)(t),vec3f:(e,t)=>c(r=>e*r)(t),vec3h:(e,t)=>m(r=>e*r)(t),vec3i:(e,t)=>J(r=>e*r)(t),vec3u:(e,t)=>ye(r=>e*r)(t),vec4f:(e,t)=>u(r=>e*r)(t),vec4h:(e,t)=>y(r=>e*r)(t),vec4i:(e,t)=>Q(r=>e*r)(t),vec4u:(e,t)=>ie(r=>e*r)(t),mat2x2f:(e,t)=>He(r=>e*r)(t),mat3x3f:(e,t)=>Je(r=>e*r)(t),mat4x4f:(e,t)=>Qe(r=>e*r)(t)},mulVxV:{vec2f:k((e,t)=>e*t),vec2h:N((e,t)=>e*t),vec2i:ee((e,t)=>e*t),vec2u:te((e,t)=>e*t),vec3f:$((e,t)=>e*t),vec3h:O((e,t)=>e*t),vec3i:re((e,t)=>e*t),vec3u:se((e,t)=>e*t),vec4f:V((e,t)=>e*t),vec4h:L((e,t)=>e*t),vec4i:ne((e,t)=>e*t),vec4u:ae((e,t)=>e*t),mat2x2f:(e,t)=>{let r=e.columns,s=t.columns;return j(r[0].x*s[0].x+r[1].x*s[0].y,r[0].y*s[0].x+r[1].y*s[0].y,r[0].x*s[1].x+r[1].x*s[1].y,r[0].y*s[1].x+r[1].y*s[1].y)},mat3x3f:(e,t)=>{let r=e.columns,s=t.columns;return q(r[0].x*s[0].x+r[1].x*s[0].y+r[2].x*s[0].z,r[0].y*s[0].x+r[1].y*s[0].y+r[2].y*s[0].z,r[0].z*s[0].x+r[1].z*s[0].y+r[2].z*s[0].z,r[0].x*s[1].x+r[1].x*s[1].y+r[2].x*s[1].z,r[0].y*s[1].x+r[1].y*s[1].y+r[2].y*s[1].z,r[0].z*s[1].x+r[1].z*s[1].y+r[2].z*s[1].z,r[0].x*s[2].x+r[1].x*s[2].y+r[2].x*s[2].z,r[0].y*s[2].x+r[1].y*s[2].y+r[2].y*s[2].z,r[0].z*s[2].x+r[1].z*s[2].y+r[2].z*s[2].z)},mat4x4f:(e,t)=>{let r=e.columns,s=t.columns;return g(r[0].x*s[0].x+r[1].x*s[0].y+r[2].x*s[0].z+r[3].x*s[0].w,r[0].y*s[0].x+r[1].y*s[0].y+r[2].y*s[0].z+r[3].y*s[0].w,r[0].z*s[0].x+r[1].z*s[0].y+r[2].z*s[0].z+r[3].z*s[0].w,r[0].w*s[0].x+r[1].w*s[0].y+r[2].w*s[0].z+r[3].w*s[0].w,r[0].x*s[1].x+r[1].x*s[1].y+r[2].x*s[1].z+r[3].x*s[1].w,r[0].y*s[1].x+r[1].y*s[1].y+r[2].y*s[1].z+r[3].y*s[1].w,r[0].z*s[1].x+r[1].z*s[1].y+r[2].z*s[1].z+r[3].z*s[1].w,r[0].w*s[1].x+r[1].w*s[1].y+r[2].w*s[1].z+r[3].w*s[1].w,r[0].x*s[2].x+r[1].x*s[2].y+r[2].x*s[2].z+r[3].x*s[2].w,r[0].y*s[2].x+r[1].y*s[2].y+r[2].y*s[2].z+r[3].y*s[2].w,r[0].z*s[2].x+r[1].z*s[2].y+r[2].z*s[2].z+r[3].z*s[2].w,r[0].w*s[2].x+r[1].w*s[2].y+r[2].w*s[2].z+r[3].w*s[2].w,r[0].x*s[3].x+r[1].x*s[3].y+r[2].x*s[3].z+r[3].x*s[3].w,r[0].y*s[3].x+r[1].y*s[3].y+r[2].y*s[3].z+r[3].y*s[3].w,r[0].z*s[3].x+r[1].z*s[3].y+r[2].z*s[3].z+r[3].z*s[3].w,r[0].w*s[3].x+r[1].w*s[3].y+r[2].w*s[3].z+r[3].w*s[3].w)}},mulMxV:{mat2x2f:(e,t)=>{let r=e.columns;return z(r[0].x*t.x+r[1].x*t.y,r[0].y*t.x+r[1].y*t.y)},mat3x3f:(e,t)=>{let r=e.columns;return h(r[0].x*t.x+r[1].x*t.y+r[2].x*t.z,r[0].y*t.x+r[1].y*t.y+r[2].y*t.z,r[0].z*t.x+r[1].z*t.y+r[2].z*t.z)},mat4x4f:(e,t)=>{let r=e.columns;return S(r[0].x*t.x+r[1].x*t.y+r[2].x*t.z+r[3].x*t.w,r[0].y*t.x+r[1].y*t.y+r[2].y*t.z+r[3].y*t.w,r[0].z*t.x+r[1].z*t.y+r[2].z*t.z+r[3].z*t.w,r[0].w*t.x+r[1].w*t.y+r[2].w*t.z+r[3].w*t.w)}},mulVxM:{mat2x2f:(e,t)=>{let r=t.columns;return z(e.x*r[0].x+e.y*r[0].y,e.x*r[1].x+e.y*r[1].y)},mat3x3f:(e,t)=>{let r=t.columns;return h(e.x*r[0].x+e.y*r[0].y+e.z*r[0].z,e.x*r[1].x+e.y*r[1].y+e.z*r[1].z,e.x*r[2].x+e.y*r[2].y+e.z*r[2].z)},mat4x4f:(e,t)=>{let r=t.columns;return S(e.x*r[0].x+e.y*r[0].y+e.z*r[0].z+e.w*r[0].w,e.x*r[1].x+e.y*r[1].y+e.z*r[1].z+e.w*r[1].w,e.x*r[2].x+e.y*r[2].y+e.z*r[2].z+e.w*r[2].w,e.x*r[3].x+e.y*r[3].y+e.z*r[3].z+e.w*r[3].w)}},div:{vec2f:k((e,t)=>e/t),vec2h:N((e,t)=>e/t),vec2i:ee(K),vec2u:te(K),vec3f:$((e,t)=>e/t),vec3h:O((e,t)=>e/t),vec3i:re(K),vec3u:se(K),vec4f:V((e,t)=>e/t),vec4h:L((e,t)=>e/t),vec4i:ne(K),vec4u:ae(K)},dot:{vec2f:be,vec2h:be,vec2i:be,vec2u:be,vec3f:Me,vec3h:Me,vec3i:Me,vec3u:Me,vec4f:ze,vec4h:ze,vec4i:ze,vec4u:ze},normalize:{vec2f:e=>{let t=Z(e);return z(e.x/t,e.y/t)},vec2h:e=>{let t=Z(e);return I(e.x/t,e.y/t)},vec2i:e=>{let t=Z(e);return ue(e.x/t,e.y/t)},vec2u:e=>{let t=Z(e);return Te(e.x/t,e.y/t)},vec3f:e=>{let t=X(e);return h(e.x/t,e.y/t,e.z/t)},vec3h:e=>{let t=X(e);return F(e.x/t,e.y/t,e.z/t)},vec3i:e=>{let t=X(e);return ce(e.x/t,e.y/t,e.z/t)},vec3u:e=>{let t=X(e);return de(e.x/t,e.y/t,e.z/t)},vec4f:e=>{let t=Y(e);return S(e.x/t,e.y/t,e.z/t,e.w/t)},vec4h:e=>{let t=Y(e);return P(e.x/t,e.y/t,e.z/t,e.w/t)},vec4i:e=>{let t=Y(e);return oe(e.x/t,e.y/t,e.z/t,e.w/t)},vec4u:e=>{let t=Y(e);return pe(e.x/t,e.y/t,e.z/t,e.w/t)}},cross:{vec3f:(e,t)=>h(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)=>F(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:k((e,t)=>e%t),vec2h:N((e,t)=>e%t),vec2i:ee((e,t)=>e%t),vec2u:te((e,t)=>e%t),vec3f:$((e,t)=>e%t),vec3h:O((e,t)=>e%t),vec3i:re((e,t)=>e%t),vec3u:se((e,t)=>e%t),vec4f:V((e,t)=>e%t),vec4h:L((e,t)=>e%t),vec4i:ne((e,t)=>e%t),vec4u:ae((e,t)=>e%t)},floor:{vec2f:o(Math.floor),vec2h:x(Math.floor),vec3f:c(Math.floor),vec3h:m(Math.floor),vec4f:u(Math.floor),vec4h:y(Math.floor)},max:{vec2f:k(Math.max),vec2h:N(Math.max),vec2i:ee(Math.max),vec2u:te(Math.max),vec3f:$(Math.max),vec3h:O(Math.max),vec3i:re(Math.max),vec3u:se(Math.max),vec4f:V(Math.max),vec4h:L(Math.max),vec4i:ne(Math.max),vec4u:ae(Math.max)},min:{vec2f:k(Math.min),vec2h:N(Math.min),vec2i:ee(Math.min),vec2u:te(Math.min),vec3f:$(Math.min),vec3h:O(Math.min),vec3i:re(Math.min),vec3u:se(Math.min),vec4f:V(Math.min),vec4h:L(Math.min),vec4i:ne(Math.min),vec4u:ae(Math.min)},pow:{vec2f:(e,t)=>z(e.x**t.x,e.y**t.y),vec2h:(e,t)=>I(e.x**t.x,e.y**t.y),vec3f:(e,t)=>h(e.x**t.x,e.y**t.y,e.z**t.z),vec3h:(e,t)=>F(e.x**t.x,e.y**t.y,e.z**t.z),vec4f:(e,t)=>S(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w),vec4h:(e,t)=>P(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w)},sign:{vec2f:o(Math.sign),vec2h:x(Math.sign),vec2i:H(Math.sign),vec3f:c(Math.sign),vec3h:m(Math.sign),vec3i:J(Math.sign),vec4f:u(Math.sign),vec4h:y(Math.sign),vec4i:Q(Math.sign)},sqrt:{vec2f:o(Math.sqrt),vec2h:x(Math.sqrt),vec3f:c(Math.sqrt),vec3h:m(Math.sqrt),vec4f:u(Math.sqrt),vec4h:y(Math.sqrt)},mix:{vec2f:(e,t,r)=>typeof r=="number"?z(e.x*(1-r)+t.x*r,e.y*(1-r)+t.y*r):z(e.x*(1-r.x)+t.x*r.x,e.y*(1-r.y)+t.y*r.y),vec2h:(e,t,r)=>typeof r=="number"?I(e.x*(1-r)+t.x*r,e.y*(1-r)+t.y*r):I(e.x*(1-r.x)+t.x*r.x,e.y*(1-r.y)+t.y*r.y),vec3f:(e,t,r)=>typeof r=="number"?h(e.x*(1-r)+t.x*r,e.y*(1-r)+t.y*r,e.z*(1-r)+t.z*r):h(e.x*(1-r.x)+t.x*r.x,e.y*(1-r.y)+t.y*r.y,e.z*(1-r.z)+t.z*r.z),vec3h:(e,t,r)=>typeof r=="number"?F(e.x*(1-r)+t.x*r,e.y*(1-r)+t.y*r,e.z*(1-r)+t.z*r):F(e.x*(1-r.x)+t.x*r.x,e.y*(1-r.y)+t.y*r.y,e.z*(1-r.z)+t.z*r.z),vec4f:(e,t,r)=>typeof r=="number"?S(e.x*(1-r)+t.x*r,e.y*(1-r)+t.y*r,e.z*(1-r)+t.z*r,e.w*(1-r)+t.w*r):S(e.x*(1-r.x)+t.x*r.x,e.y*(1-r.y)+t.y*r.y,e.z*(1-r.z)+t.z*r.z,e.w*(1-r.w)+t.w*r.w),vec4h:(e,t,r)=>typeof r=="number"?P(e.x*(1-r)+t.x*r,e.y*(1-r)+t.y*r,e.z*(1-r)+t.z*r,e.w*(1-r)+t.w*r):P(e.x*(1-r.x)+t.x*r.x,e.y*(1-r.y)+t.y*r.y,e.z*(1-r.z)+t.z*r.z,e.w*(1-r.w)+t.w*r.w)},sin:{vec2f:o(Math.sin),vec2h:x(Math.sin),vec3f:c(Math.sin),vec3h:m(Math.sin),vec4f:u(Math.sin),vec4h:y(Math.sin)},cos:{vec2f:o(Math.cos),vec2h:x(Math.cos),vec3f:c(Math.cos),vec3h:m(Math.cos),vec4f:u(Math.cos),vec4h:y(Math.cos)},cosh:{vec2f:o(Math.cosh),vec2h:x(Math.cosh),vec3f:c(Math.cosh),vec3h:m(Math.cosh),vec4f:u(Math.cosh),vec4h:y(Math.cosh)},exp:{vec2f:o(Math.exp),vec2h:x(Math.exp),vec3f:c(Math.exp),vec3h:m(Math.exp),vec4f:u(Math.exp),vec4h:y(Math.exp)},exp2:{vec2f:o(e=>2**e),vec2h:x(e=>2**e),vec3f:c(e=>2**e),vec3h:m(e=>2**e),vec4f:u(e=>2**e),vec4h:y(e=>2**e)},log:{vec2f:o(Math.log),vec2h:x(Math.log),vec3f:c(Math.log),vec3h:m(Math.log),vec4f:u(Math.log),vec4h:y(Math.log)},log2:{vec2f:o(Math.log2),vec2h:x(Math.log2),vec3f:c(Math.log2),vec3h:m(Math.log2),vec4f:u(Math.log2),vec4h:y(Math.log2)},fract:{vec2f:o(e=>e-Math.floor(e)),vec2h:x(e=>e-Math.floor(e)),vec3f:c(e=>e-Math.floor(e)),vec3h:m(e=>e-Math.floor(e)),vec4f:u(e=>e-Math.floor(e)),vec4h:y(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:o(e=>-e),vec2h:x(e=>-e),vec2i:H(e=>-e),vec2u:me(e=>-e),"vec2<bool>":e=>w(!e.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h),vec3h:m(Math.tanh),vec4f:u(Math.tanh),vec4h:y(Math.tanh)},bitcastU32toF32:{vec2u:e=>z(A(e.x),A(e.y)),vec3u:e=>h(A(e.x),A(e.y),A(e.z)),vec4u:e=>S(A(e.x),A(e.y),A(e.z),A(e.w))},bitcastU32toI32:{vec2u:e=>ue(W(e.x),W(e.y)),vec3u:e=>ce(W(e.x),W(e.y),W(e.z)),vec4u:e=>oe(W(e.x),W(e.y),W(e.z),W(e.w))}};function et(e,t){if(typeof e=="number"&&typeof t=="number")return e+t;if(typeof e=="number"&&T(t))return d.addMixed[t.kind](t,e);if(T(e)&&typeof t=="number")return d.addMixed[e.kind](e,t);if(T(e)&&T(t)||C(e)&&C(t))return d.add[e.kind](e,t);throw new Error("Add/Sub called with invalid arguments.")}var ar=f({name:"add",signature:(...e)=>{let t=G(e)??e;return{argTypes:t,returnType:R(t[0])?t[1]:t[0]}},normalImpl:et,codegenImpl:(e,t)=>v`(${e} + ${t})`});function wt(e,t){return et(e,tt(-1,t))}var ur=f({name:"sub",signature:(...e)=>{let t=G(e)??e;return{argTypes:t,returnType:R(t[0])?t[1]:t[0]}},normalImpl:wt,codegenImpl:(e,t)=>v`(${e} - ${t})`});function tt(e,t){if(typeof e=="number"&&typeof t=="number")return e*t;if(typeof e=="number"&&(T(t)||C(t)))return d.mulSxV[t.kind](e,t);if((T(e)||C(e))&&typeof t=="number")return d.mulSxV[e.kind](t,e);if(T(e)&&T(t))return d.mulVxV[e.kind](e,t);if(Ae(e)&&C(t))return d.mulVxM[t.kind](e,t);if(C(e)&&Ae(t))return d.mulMxV[e.kind](e,t);if(C(e)&&C(t))return d.mulVxV[e.kind](e,t);throw new Error("Mul called with invalid arguments.")}var cr=f({name:"mul",signature:(...e)=>{let t=G(e)??e,r=R(t[0])?t[1]:R(t[1])||t[0].type.startsWith("vec")?t[0]:t[1].type.startsWith("vec")?t[1]:t[0];return{argTypes:t,returnType:r}},normalImpl:tt,codegenImpl:(e,t)=>v`(${e} * ${t})`});function bt(e,t){if(typeof e=="number"&&typeof t=="number")return e/t;if(typeof e=="number"&&T(t)){let r=le[t.kind][a].jsImpl;return d.div[t.kind](r(e),t)}if(T(e)&&typeof t=="number"){let r=le[e.kind][a].jsImpl;return d.div[e.kind](e,r(t))}if(T(e)&&T(t))return d.div[e.kind](e,t);throw new Error("Div called with invalid arguments.")}var or=f({name:"div",signature:(...e)=>{let t=G(e,[i,Re,De])??e;return{argTypes:t,returnType:R(t[0])?t[1]:t[0]}},normalImpl:bt,codegenImpl:(e,t)=>v`(${e} / ${t})`,ignoreImplicitCastWarning:!0}),lr=f({name:"mod",signature:(...e)=>{let t=G(e)??e;return{argTypes:t,returnType:R(t[0])?t[1]:t[0]}},normalImpl(e,t){if(typeof e=="number"&&typeof t=="number")return e%t;if(typeof e=="number"&&T(t)){let r=le[t.kind];return d.mod[t.kind](r(e),t)}if(T(e)&&typeof t=="number"){let r=le[e.kind];return d.mod[e.kind](e,r(t))}if(T(e)&&T(t))return d.mod[e.kind](e,t);throw new Error("Mod called with invalid arguments, expected types: number or vector.")},codegenImpl:(e,t)=>v`(${e} % ${t})`});function Mt(e){return typeof e=="number"?-e:d.neg[e.kind](e)}var xr=f({name:"neg",signature:e=>({argTypes:[e],returnType:e}),normalImpl:Mt,codegenImpl:e=>v`-(${e})`});function Tr(e){if("multisampled"in e){if(e.multisampled){if(e.dimension==="2d")return _t(e.sampleType);throw new Error(`Multisampled textures only support '2d' dimension, got '${e.dimension}'`)}switch(e.dimension){case"1d":return zt(e.sampleType);case"2d":return St(e.sampleType);case"2d-array":return Vt(e.sampleType);case"3d":return Ft(e.sampleType);case"cube":return At(e.sampleType);case"cube-array":return Wt(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 $t(e.format,e.access);case"2d":return Ct(e.format,e.access);case"2d-array":return kt(e.format,e.access);case"3d":return It(e.format,e.access);default:throw new Error(`Unsupported storage texture dimension: '${e.dimension}'`)}}function _(e,t){let s=e.startsWith("texture_depth")?["depth","float","unfilterable-float"]:t.sampleType.type==="i32"?["sint"]:t.sampleType.type==="u32"?["uint"]:["float","unfilterable-float"];return{[a]:!0,[ge]:void 0,type:e,bindingSampleType:s,...t}}function Se(e,t){return{[a]:!0,[ge]:void 0,type:e,...t}}var rt=new Map,_e={"write-only":"write","read-only":"read","read-write":"read_write"};function p(e,t){let r=rt.get(e);return r||(r=t(),rt.set(e,r)),r}function zt(e){let t=e||i,r=`texture_1d<${t.type}>`;return p(r,()=>_("texture_1d",{dimension:"1d",sampleType:t,multisampled:!1}))}function St(e){let t=e||i,r=`texture_2d<${t.type}>`;return p(r,()=>_("texture_2d",{dimension:"2d",sampleType:t,multisampled:!1}))}function _t(e){let t=e||i,r=`texture_multisampled_2d<${t.type}>`;return p(r,()=>_("texture_multisampled_2d",{dimension:"2d",sampleType:t,multisampled:!0}))}function Vt(e){let t=e||i,r=`texture_2d_array<${t.type}>`;return p(r,()=>_("texture_2d_array",{dimension:"2d-array",sampleType:t,multisampled:!1}))}function At(e){let t=e||i,r=`texture_cube<${t.type}>`;return p(r,()=>_("texture_cube",{dimension:"cube",sampleType:t,multisampled:!1}))}function Wt(e){let t=e||i,r=`texture_cube_array<${t.type}>`;return p(r,()=>_("texture_cube_array",{dimension:"cube-array",sampleType:t,multisampled:!1}))}function Ft(e){let t=e||i,r=`texture_3d<${t.type}>`;return p(r,()=>_("texture_3d",{dimension:"3d",sampleType:t,multisampled:!1}))}function $t(e,t){let r=t||"write-only",s=`texture_storage_1d<${e}, ${_e[r]}>`;return p(s,()=>Se("texture_storage_1d",{dimension:"1d",format:e,access:r}))}function Ct(e,t){let r=t||"write-only",s=`texture_storage_2d<${e}, ${_e[r]}>`;return p(s,()=>Se("texture_storage_2d",{dimension:"2d",format:e,access:r}))}function kt(e,t){let r=t||"write-only",s=`texture_storage_2d_array<${e}, ${_e[r]}>`;return p(s,()=>Se("texture_storage_2d_array",{dimension:"2d-array",format:e,access:r}))}function It(e,t){let r=t||"write-only",s=`texture_storage_3d<${e}, ${_e[r]}>`;return p(s,()=>Se("texture_storage_3d",{dimension:"3d",format:e,access:r}))}function dr(){return p("texture_depth_2d",()=>_("texture_depth_2d",{dimension:"2d",sampleType:i,multisampled:!1}))}function pr(){return p("texture_depth_multisampled_2d",()=>_("texture_depth_multisampled_2d",{dimension:"2d",sampleType:i,multisampled:!0}))}function gr(){return p("texture_depth_2d_array",()=>_("texture_depth_2d_array",{dimension:"2d-array",sampleType:i,multisampled:!1}))}function vr(){return p("texture_depth_cube",()=>_("texture_depth_cube",{dimension:"cube",sampleType:i,multisampled:!1}))}function fr(){return p("texture_depth_cube_array",()=>_("texture_depth_cube_array",{dimension:"cube-array",sampleType:i,multisampled:!1}))}function hr(){return p("texture_external",()=>({[a]:!0,[ge]:void 0,type:"texture_external",dimension:"2d"}))}function wr(e){return!!e[a]&&typeof e.multisampled=="boolean"}function br(e){return!!e[a]&&typeof e.format=="string"&&typeof e.access=="string"}export{xe as a,st as b,nt as c,at as d,ct as e,ot as f,lt as g,xt as h,mt as i,j,q as k,g as l,Lt as m,U as n,A as o,W as p,d as q,ar as r,ur as s,cr as t,or as u,lr as v,xr as w,Tr as x,_e as y,zt as z,St as A,_t as B,Vt as C,At as D,Wt as E,Ft as F,$t as G,Ct as H,kt as I,It as J,dr as K,pr as L,gr as M,vr as N,fr as O,hr as P,wr as Q,br as R};
//# sourceMappingURL=chunk-EHLRP4V2.js.map

Sorry, the diff of this file is too big to display

import{r as q,s as H,t as J,u as Q}from"./chunk-EHLRP4V2.js";import{$ as M,Ab as E,Ba as l,Bb as K,C as y,D as S,E as x,Gb as j,La as s,P as h,Q as v,U as T,Xa as b,_ as t,a as o,aa as U,da as $,eb as w,g as p,ga as a,gb as W,hb as d,jb as g,kb as C,lb as P,nb as z,ob as A,pb as F,qb as I,rb as G,sb as k,tb as D,ub as L,v as m,vb as V,wb as O,xb as R,yb as _,z as f,zb as B}from"./chunk-SHSILTWI.js";var Y=["vec2f","vec3f","vec4f","vec2h","vec3h","vec4h","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","mat2x2f","mat3x3f","mat4x4f"],X={add:q,sub:H,mul:J,div:Q},Z={f:{1:C,2:z,3:k,4:R},h:{1:P,2:A,3:D,4:_},i:{1:g,2:F,3:L,4:B},u:{1:d,2:I,3:V,4:E},b:{1:W,2:G,3:O,4:K}};function N(e,r){if(Y.includes(e.dataType.type)&&r in X)return a(new M(r,e,X[r][o].gpuImpl),t,e.origin);if(y(e.dataType)&&r==="length")return e.dataType.elementCount===0?a(s`arrayLength(&${e})`,d,"runtime"):a(e.dataType.elementCount,w,"constant");if(f(e.dataType)&&r==="columns")return a(new U(e),t,e.origin);if(S(e.dataType)||T(e.dataType)){let n=e.dataType.propTypes[r];return n?(n=v(n),a(s`${e}.${r}`,n,e.origin==="argument"?"argument":!$(e)&&!h(n)?e.origin:e.origin==="constant"||e.origin==="constant-tgpu-const-ref"?"constant":"runtime")):void 0}if(x(e.dataType)){let n=b(e);return r==="$"?n:N(n,r)}if(m(e.dataType)&&r==="kind")return a(e.dataType.type,t,"constant");let i=r.length;if(m(e.dataType)&&i>=1&&i<=4){let n=e.dataType.type.includes("bool")?"b":e.dataType.type[4],u=Z[n][i];return u?a(l(e)?e.value[r]:s`${e}.${r}`,u,e.origin==="argument"&&i===1?"argument":e.origin==="constant"||e.origin==="constant-tgpu-const-ref"?"constant":"runtime"):void 0}if(l(e)||e.dataType.type==="unknown")return j(e.value[r])}function ue(){return{[o]:!0,type:"sampler",[p]:void 0}}function fe(){return{[o]:!0,type:"sampler_comparison",[p]:void 0}}function ye(e){return!!e[o]&&e.type==="sampler"}function Se(e){return!!e[o]&&e.type==="sampler_comparison"}function ve(e){return new c(e)}var c=class{constructor(r){this.inner=r}[o]=!0;type="atomic"};export{X as a,N as b,ue as c,fe as d,ye as e,Se as f,ve as g};
//# sourceMappingURL=chunk-LMPPDGRD.js.map
{"version":3,"sources":["../src/tgsl/accessProp.ts","../src/data/sampler.ts","../src/data/atomic.ts"],"sourcesContent":["import { stitch } from '../core/resolve/stitch.ts';\nimport {\n type AnyData,\n InfixDispatch,\n isUnstruct,\n MatrixColumnsAccess,\n undecorate,\n UnknownData,\n} from '../data/dataTypes.ts';\nimport { abstractInt, bool, f16, f32, i32, u32 } from '../data/numeric.ts';\nimport { derefSnippet } from '../data/ref.ts';\nimport { isEphemeralSnippet, snip, type Snippet } from '../data/snippet.ts';\nimport {\n vec2b,\n vec2f,\n vec2h,\n vec2i,\n vec2u,\n vec3b,\n vec3f,\n vec3h,\n vec3i,\n vec3u,\n vec4b,\n vec4f,\n vec4h,\n vec4i,\n vec4u,\n} from '../data/vector.ts';\nimport {\n isMat,\n isNaturallyEphemeral,\n isPtr,\n isVec,\n isWgslArray,\n isWgslStruct,\n} from '../data/wgslTypes.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { add, div, mul, sub } from '../std/operators.ts';\nimport { isKnownAtComptime } from '../types.ts';\nimport { coerceToSnippet } from './generationHelpers.ts';\n\nconst infixKinds = [\n 'vec2f',\n 'vec3f',\n 'vec4f',\n 'vec2h',\n 'vec3h',\n 'vec4h',\n 'vec2i',\n 'vec3i',\n 'vec4i',\n 'vec2u',\n 'vec3u',\n 'vec4u',\n 'mat2x2f',\n 'mat3x3f',\n 'mat4x4f',\n];\n\nexport const infixOperators = {\n add,\n sub,\n mul,\n div,\n} as const;\n\nexport type InfixOperator = keyof typeof infixOperators;\n\ntype SwizzleableType = 'f' | 'h' | 'i' | 'u' | 'b';\ntype SwizzleLength = 1 | 2 | 3 | 4;\n\nconst swizzleLenToType: Record<\n SwizzleableType,\n Record<SwizzleLength, AnyData>\n> = {\n f: {\n 1: f32,\n 2: vec2f,\n 3: vec3f,\n 4: vec4f,\n },\n h: {\n 1: f16,\n 2: vec2h,\n 3: vec3h,\n 4: vec4h,\n },\n i: {\n 1: i32,\n 2: vec2i,\n 3: vec3i,\n 4: vec4i,\n },\n u: {\n 1: u32,\n 2: vec2u,\n 3: vec3u,\n 4: vec4u,\n },\n b: {\n 1: bool,\n 2: vec2b,\n 3: vec3b,\n 4: vec4b,\n },\n} as const;\n\nexport function accessProp(\n target: Snippet,\n propName: string,\n): Snippet | undefined {\n if (infixKinds.includes(target.dataType.type) && propName in infixOperators) {\n return snip(\n new InfixDispatch(\n propName,\n target,\n infixOperators[propName as InfixOperator][$internal].gpuImpl,\n ),\n UnknownData,\n /* origin */ target.origin,\n );\n }\n\n if (isWgslArray(target.dataType) && propName === 'length') {\n if (target.dataType.elementCount === 0) {\n // Dynamically-sized array\n return snip(stitch`arrayLength(&${target})`, u32, /* origin */ 'runtime');\n }\n\n return snip(\n target.dataType.elementCount,\n abstractInt,\n /* origin */ 'constant',\n );\n }\n\n if (isMat(target.dataType) && propName === 'columns') {\n return snip(\n new MatrixColumnsAccess(target),\n UnknownData,\n /* origin */ target.origin,\n );\n }\n\n if (isWgslStruct(target.dataType) || isUnstruct(target.dataType)) {\n let propType = target.dataType.propTypes[propName];\n if (!propType) {\n return undefined;\n }\n propType = undecorate(propType);\n\n return snip(\n stitch`${target}.${propName}`,\n propType,\n /* origin */ target.origin === 'argument'\n ? 'argument'\n : !isEphemeralSnippet(target) && !isNaturallyEphemeral(propType)\n ? target.origin\n : target.origin === 'constant' ||\n target.origin === 'constant-tgpu-const-ref'\n ? 'constant'\n : 'runtime',\n );\n }\n\n if (isPtr(target.dataType)) {\n const derefed = derefSnippet(target);\n\n if (propName === '$') {\n // Dereference pointer\n return derefed;\n }\n\n // Sometimes values that are typed as pointers aren't instances of `d.ref`, so we\n // allow access to member props as if it wasn't a pointer.\n return accessProp(derefed, propName);\n }\n\n if (isVec(target.dataType)) {\n // Example: d.vec3f().kind === 'vec3f'\n if (propName === 'kind') {\n return snip(target.dataType.type, UnknownData, 'constant');\n }\n }\n\n const propLength = propName.length;\n if (isVec(target.dataType) && propLength >= 1 && propLength <= 4) {\n const swizzleTypeChar = target.dataType.type.includes('bool')\n ? 'b'\n : (target.dataType.type[4] as SwizzleableType);\n const swizzleType =\n swizzleLenToType[swizzleTypeChar][propLength as SwizzleLength];\n if (!swizzleType) {\n return undefined;\n }\n\n return snip(\n isKnownAtComptime(target)\n // biome-ignore lint/suspicious/noExplicitAny: it's fine, the prop is there\n ? (target.value as any)[propName]\n : stitch`${target}.${propName}`,\n swizzleType,\n // Swizzling creates new vectors (unless they're on the lhs of an assignment, but that's not yet supported in WGSL)\n /* origin */ target.origin === 'argument' && propLength === 1\n ? 'argument'\n : target.origin === 'constant' ||\n target.origin === 'constant-tgpu-const-ref'\n ? 'constant'\n : 'runtime',\n );\n }\n\n if (isKnownAtComptime(target) || target.dataType.type === 'unknown') {\n // biome-ignore lint/suspicious/noExplicitAny: we either know exactly what it is, or have no idea at all\n return coerceToSnippet((target.value as any)[propName]);\n }\n\n return undefined;\n}\n","import { $internal, $repr } from '../shared/symbols.ts';\nimport type { BaseData } from './wgslTypes.ts';\n\nexport interface WgslSamplerProps {\n addressModeU?: GPUAddressMode;\n addressModeV?: GPUAddressMode;\n /**\n * Specifies the address modes for the texture width, height, and depth\n * coordinates, respectively.\n */\n addressModeW?: GPUAddressMode;\n /**\n * Specifies the sampling behavior when the sample footprint is smaller than or equal to one\n * texel.\n */\n magFilter?: GPUFilterMode;\n /**\n * Specifies the sampling behavior when the sample footprint is larger than one texel.\n */\n minFilter?: GPUFilterMode;\n /**\n * Specifies behavior for sampling between mipmap levels.\n */\n mipmapFilter?: GPUMipmapFilterMode;\n lodMinClamp?: number;\n /**\n * Specifies the minimum and maximum levels of detail, respectively, used internally when\n * sampling a texture.\n */\n lodMaxClamp?: number;\n /**\n * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is\n * enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it.\n * Anisotropic filtering improves the image quality of textures sampled at oblique viewing\n * angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of\n * anisotropy supported when filtering.\n *\n * Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range\n * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy}\n * will be clamped to the maximum value that the platform supports.\n * The precise filtering behavior is implementation-dependent.\n */\n maxAnisotropy?: number;\n}\n\nexport interface WgslComparisonSamplerProps {\n compare: GPUCompareFunction;\n addressModeU?: GPUAddressMode;\n addressModeV?: GPUAddressMode;\n /**\n * Specifies the address modes for the texture width, height, and depth\n * coordinates, respectively.\n */\n addressModeW?: GPUAddressMode;\n /**\n * Specifies the sampling behavior when the sample footprint is smaller than or equal to one\n * texel.\n */\n magFilter?: GPUFilterMode;\n /**\n * Specifies the sampling behavior when the sample footprint is larger than one texel.\n */\n minFilter?: GPUFilterMode;\n /**\n * Specifies behavior for sampling between mipmap levels.\n */\n mipmapFilter?: GPUMipmapFilterMode;\n lodMinClamp?: number;\n /**\n * Specifies the minimum and maximum levels of detail, respectively, used internally when\n * sampling a texture.\n */\n lodMaxClamp?: number;\n /**\n * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is\n * enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it.\n * Anisotropic filtering improves the image quality of textures sampled at oblique viewing\n * angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of\n * anisotropy supported when filtering.\n *\n * Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range\n * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy}\n * will be clamped to the maximum value that the platform supports.\n * The precise filtering behavior is implementation-dependent.\n */\n maxAnisotropy?: number;\n}\n\nconst SamplerPropsDefaults: WgslSamplerProps = {\n addressModeU: 'clamp-to-edge',\n addressModeV: 'clamp-to-edge',\n addressModeW: 'clamp-to-edge',\n magFilter: 'nearest',\n minFilter: 'nearest',\n mipmapFilter: 'nearest',\n lodMinClamp: 0,\n lodMaxClamp: 32,\n maxAnisotropy: 1,\n};\n\nexport interface sampler {\n [$internal]: true;\n type: 'sampler';\n}\n\nexport function sampler(): WgslSampler {\n return {\n [$internal]: true,\n type: 'sampler',\n [$repr]: undefined as unknown as sampler,\n };\n}\n\nexport interface comparisonSampler {\n [$internal]: true;\n type: 'sampler_comparison';\n}\n\nexport function comparisonSampler(): WgslComparisonSampler {\n return {\n [$internal]: true,\n type: 'sampler_comparison',\n [$repr]: undefined as unknown as comparisonSampler,\n };\n}\n\nexport interface WgslSampler extends BaseData {\n readonly [$repr]: sampler;\n readonly type: 'sampler';\n}\n\nexport interface WgslComparisonSampler extends BaseData {\n readonly [$repr]: comparisonSampler;\n readonly type: 'sampler_comparison';\n}\n\nexport function isWgslSampler(value: unknown): value is WgslSampler {\n return (\n !!(value as WgslSampler)[$internal] &&\n (value as WgslSampler).type === 'sampler'\n );\n}\n\nexport function isWgslComparisonSampler(\n value: unknown,\n): value is WgslComparisonSampler {\n return (\n !!(value as WgslComparisonSampler)[$internal] &&\n (value as WgslComparisonSampler).type === 'sampler_comparison'\n );\n}\n","import type { Infer, MemIdentity } from '../shared/repr.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport {\n $gpuRepr,\n $memIdent,\n $repr,\n $validStorageSchema,\n $validUniformSchema,\n $validVertexSchema,\n} from '../shared/symbols.ts';\nimport type { Atomic, atomicI32, atomicU32, I32, U32 } from './wgslTypes.ts';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Marks a concrete integer scalar type schema (u32 or i32) as a WGSL atomic.\n *\n * @example\n * const atomicU32 = d.atomic(d.u32);\n * const atomicI32 = d.atomic(d.i32);\n *\n * @param data Underlying type schema.\n */\nexport function atomic<TSchema extends U32 | I32>(\n data: TSchema,\n): Atomic<TSchema> {\n return new AtomicImpl(data);\n}\n\n// --------------\n// Implementation\n// --------------\n\nclass AtomicImpl<TSchema extends U32 | I32> implements Atomic<TSchema> {\n public readonly [$internal] = true;\n public readonly type = 'atomic';\n\n // Type-tokens, not available at runtime\n declare readonly [$repr]: Infer<TSchema>;\n declare readonly [$memIdent]: MemIdentity<TSchema>;\n declare readonly [$gpuRepr]: TSchema extends U32 ? atomicU32 : atomicI32;\n declare readonly [$validStorageSchema]: true;\n declare readonly [$validUniformSchema]: true;\n declare readonly [$validVertexSchema]: true;\n // ---\n\n constructor(public readonly inner: TSchema) {}\n}\n"],"mappings":"kZA0CA,IAAMA,EAAa,CACjB,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,UACA,UACA,SACF,EAEaC,EAAiB,CAC5B,IAAAC,EACA,IAAAC,EACA,IAAAC,EACA,IAAAC,CACF,EAOMC,EAGF,CACF,EAAG,CACD,EAAGC,EACH,EAAGC,EACH,EAAGC,EACH,EAAGC,CACL,EACA,EAAG,CACD,EAAGC,EACH,EAAGC,EACH,EAAGC,EACH,EAAGC,CACL,EACA,EAAG,CACD,EAAGC,EACH,EAAGC,EACH,EAAGC,EACH,EAAGC,CACL,EACA,EAAG,CACD,EAAGC,EACH,EAAGC,EACH,EAAGC,EACH,EAAGC,CACL,EACA,EAAG,CACD,EAAGC,EACH,EAAGC,EACH,EAAGC,EACH,EAAGC,CACL,CACF,EAEO,SAASC,EACdC,EACAC,EACqB,CACrB,GAAI7B,EAAW,SAAS4B,EAAO,SAAS,IAAI,GAAKC,KAAY5B,EAC3D,OAAO6B,EACL,IAAIC,EACFF,EACAD,EACA3B,EAAe4B,CAAyB,EAAEG,CAAS,EAAE,OACvD,EACAC,EACaL,EAAO,MACtB,EAGF,GAAIM,EAAYN,EAAO,QAAQ,GAAKC,IAAa,SAC/C,OAAID,EAAO,SAAS,eAAiB,EAE5BE,EAAKK,iBAAsBP,CAAM,IAAKT,EAAkB,SAAS,EAGnEW,EACLF,EAAO,SAAS,aAChBQ,EACa,UACf,EAGF,GAAIC,EAAMT,EAAO,QAAQ,GAAKC,IAAa,UACzC,OAAOC,EACL,IAAIQ,EAAoBV,CAAM,EAC9BK,EACaL,EAAO,MACtB,EAGF,GAAIW,EAA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M,UACN,CAACC,CAAK,EAAG,MACX,CACF,CAOO,SAASC,IAA2C,CACzD,MAAO,CACL,CAACF,CAAS,EAAG,GACb,KAAM,qBACN,CAACC,CAAK,EAAG,MACX,CACF,CAYO,SAASE,GAAcC,EAAsC,CAClE,MACE,CAAC,CAAEA,EAAsBJ,CAAS,GACjCI,EAAsB,OAAS,SAEpC,CAEO,SAASC,GACdD,EACgC,CAChC,MACE,CAAC,CAAEA,EAAgCJ,CAAS,GAC3CI,EAAgC,OAAS,oBAE9C,CC7HO,SAASE,GACdC,EACiB,CACjB,OAAO,IAAIC,EAAWD,CAAI,CAC5B,CAMA,IAAMC,EAAN,KAAuE,CAarE,YAA4BC,EAAgB,CAAhB,WAAAA,CAAiB,CAZ7C,CAAiBC,CAAS,EAAI,GACd,KAAO,QAYzB","names":["infixKinds","infixOperators","add","sub","mul","div","swizzleLenToType","f32","vec2f","vec3f","vec4f","f16","vec2h","vec3h","vec4h","i32","vec2i","vec3i","vec4i","u32","vec2u","vec3u","vec4u","bool","vec2b","vec3b","vec4b","accessProp","target","propName","snip","InfixDispatch","$internal","UnknownData","isWgslArray","stitch","abstractInt","isMat","MatrixColumnsAccess","isWgslStruct","isUnstruct","propType","undecorate","isEphemeralSnippet","isNaturallyEphemeral","isPtr","derefed","derefSnippet","isVec","propLength","swizzleTypeChar","swizzleType","isKnownAtComptime","coerceToSnippet","sampler","$internal","$repr","comparisonSampler","isWgslSampler","value","isWgslComparisonSampler","atomic","data","AtomicImpl","inner","$internal"]}
import{Ac as V,B as S,C as T,D,G as w,H as _,Hb as h,Ib as E,K as v,L as p,Lb as O,S as L,T as x,U as b,V as u,W as d,X as k,a as o,gb as $,hb as c,kb as W,vb as g,xb as z}from"./chunk-SHSILTWI.js";var R={f32:4,f16:2,i32:4,u32:4,bool:4,u16:2,vec2f:8,vec2h:4,vec2i:8,vec2u:8,vec2b:8,vec3f:16,vec3h:8,vec3i:16,vec3u:16,vec3b:16,vec4f:16,vec4h:8,vec4i:16,vec4u:16,vec4b:16,mat2x2f:8,mat3x3f:16,mat4x4f:16,atomic:4};function j(e){let t=e?.type,r=R[t];if(r!==void 0)return r;if(D(e))return Object.values(e.propTypes).map(s).reduce((n,a)=>n>a?n:a);if(T(e))return s(e.elementType);if(b(e)){let n=Object.values(e.propTypes)[0];return n?d(n)??1:1}if(x(e))return d(e.elementType)??1;if(p(e)||u(e))return d(e)??s(e.inner);if(O.has(t))return 1;throw new Error(`Cannot determine alignment of data: ${E(e)}`)}function G(e){if(b(e)){let t=Object.values(e.propTypes)[0];return t?y(t):1}return x(e)?y(e.elementType):u(e)?d(e)??y(e.inner):d(e)??1}var U=new WeakMap,C=new WeakMap;function s(e){let t=U.get(e);return t===void 0&&(t=j(e),U.set(e,t)),t}function y(e){let t=C.get(e);return t===void 0&&(t=G(e),C.set(e,t)),t}function ne(e){return s(e)}var f=(e,t)=>{let r=t-1,n=~r;return(e&r)===0?e:(e&n)+t};var K={bool:4,f32:4,f16:2,i32:4,u32:4,u16:2,vec2f:8,vec2h:4,vec2i:8,vec2u:8,"vec2<bool>":8,vec3f:12,vec3h:6,vec3i:12,vec3u:12,"vec3<bool>":12,vec4f:16,vec4h:8,vec4i:16,vec4u:16,"vec4<bool>":16,mat2x2f:16,mat3x3f:48,mat4x4f:64,uint8:1,uint8x2:2,uint8x4:4,sint8:1,sint8x2:2,sint8x4:4,unorm8:1,unorm8x2:2,unorm8x4:4,snorm8:1,snorm8x2:2,snorm8x4:4,uint16:2,uint16x2:4,uint16x4:8,sint16:2,sint16x2:4,sint16x4:8,unorm16:2,unorm16x2:4,unorm16x4:8,snorm16:2,snorm16x2:4,snorm16x4:8,float16:2,float16x2:4,float16x4:8,float32:4,float32x2:8,float32x3:12,float32x4:16,uint32:4,uint32x2:8,uint32x3:12,uint32x4:16,sint32:4,sint32x2:8,sint32x3:12,sint32x4:16,"unorm10-10-10-2":4,"unorm8x4-bgra":4,atomic:4};function H(e){let t=0,r=e.propTypes;for(let n of Object.values(r)){if(Number.isNaN(t))throw new Error("Only the last property of a struct can be unbounded");if(t=f(t,s(n)),t+=l(n),Number.isNaN(t)&&n.type!=="array")throw new Error("Cannot nest unbounded struct within another struct")}return f(t,s(e))}function q(e){let t=0,r=e.propTypes;for(let n of Object.values(r)){let a=y(n);t=f(t,a),t+=l(n)}return t}function J(e){let t=K[e?.type];if(t!==void 0)return t;if(D(e))return H(e);if(b(e))return q(e);if(T(e)){if(e.elementCount===0)return Number.NaN;let r=s(e.elementType);return f(l(e.elementType),r)*e.elementCount}if(x(e)){let r=y(e.elementType);return f(l(e.elementType),r)*e.elementCount}if(p(e)||u(e))return k(e)??l(e.inner);throw new Error(`Cannot determine size of data: ${e}`)}var N=new WeakMap;function l(e){let t=N.get(e);return t===void 0&&(t=J(e),N.set(e,t)),t}function ue(e){return l(e)}function m(e,t){return p(e)?new B(e.inner,[t,...e.attribs]):u(e)?new A(e.inner,[t,...e.attribs]):L(e)?new A(e,[t]):new B(e,[t])}function xe(e,t){return m(t,{[o]:!0,type:"@align",params:[e]})}function be(e,t){return m(t,{[o]:!0,type:"@size",params:[e]})}function ge(e,t){return m(t,{[o]:!0,type:"@location",params:[e]})}function Te(e,t){return m(t,{[o]:!0,type:"@interpolate",params:[e]})}function De(e){if(!Q(e))throw new Error("The @invariant attribute must only be applied to the position built-in value.");let t=p(e)||u(e)?e.attribs.find(v):void 0;if(!t||t.params[0]!=="position")throw new Error("The @invariant attribute must only be applied to the position built-in value.");return m(e,{[o]:!0,type:"@invariant",params:[]})}function Q(e){return(p(e)||u(e))&&e.attribs.find(v)!==void 0}function Ie(e){return!p(e)&&!u(e)?"":e.attribs.map(t=>t.params.length===0?`${t.type} `:`${t.type}(${t.params.join(", ")}) `).join("")}var I=class{constructor(t,r){this.inner=t;this.attribs=r;let n=r.find(w)?.params[0],a=r.find(_)?.params[0];if(n!==void 0){if(n<=0)throw new Error(`Custom data alignment must be a positive number, got: ${n}.`);if(Math.log2(n)%1!==0)throw new Error(`Alignment has to be a power of 2, got: ${n}.`);if(S(this.inner)&&n%s(this.inner)!==0)throw new Error(`Custom alignment has to be a multiple of the standard data alignment. Got: ${n}, expected multiple of: ${s(this.inner)}.`)}if(a!==void 0){if(a<l(this.inner))throw new Error(`Custom data size cannot be smaller then the standard data size. Got: ${a}, expected at least: ${l(this.inner)}.`);if(a<=0)throw new Error(`Custom data size must be a positive number. Got: ${a}.`)}}[o]=!0},B=class extends I{[o]=!0;type="decorated"},A=class extends I{[o]=!0;type="loose-decorated"};var F=h(((e,t)=>t===void 0?h(r=>P(e,r)):P(e,t))).$name("arrayOf");function P(e,t){let r=n=>{if(n&&n.length!==t)throw new Error(`Array schema of ${t} elements of type ${e.type} called with ${n.length} argument(s).`);return Array.from({length:t},(a,M)=>V(e,n?.[M]))};if(Object.setPrototypeOf(r,X),Number.isNaN(l(e)))throw new Error("Cannot nest runtime sized arrays.");if(r.elementType=e,!Number.isInteger(t)||t<0)throw new Error(`Cannot create array schema with invalid element count: ${t}.`);return r.elementCount=t,r}var X={[o]:!0,type:"array",toString(){return`arrayOf(${this.elementType}, ${this.elementCount})`}};function i(e,t){return m(e,{[o]:!0,type:"@builtin",params:[t]})}var ze={vertexIndex:i(c,"vertex_index"),instanceIndex:i(c,"instance_index"),position:i(z,"position"),clipDistances:i(F(c,8),"clip_distances"),frontFacing:i($,"front_facing"),fragDepth:i(W,"frag_depth"),sampleIndex:i(c,"sample_index"),sampleMask:i(c,"sample_mask"),localInvocationId:i(g,"local_invocation_id"),localInvocationIndex:i(c,"local_invocation_index"),globalInvocationId:i(g,"global_invocation_id"),workgroupId:i(g,"workgroup_id"),numWorkgroups:i(g,"num_workgroups"),subgroupInvocationId:i(c,"subgroup_invocation_id"),subgroupSize:i(c,"subgroup_size")};export{s as a,y as b,ne as c,f as d,l as e,ue as f,xe as g,be as h,ge as i,Te as j,De as k,Q as l,Ie as m,F as n,ze as o};
//# sourceMappingURL=chunk-MBB2XFH6.js.map
{"version":3,"sources":["../src/data/alignmentOf.ts","../src/mathUtils.ts","../src/data/sizeOf.ts","../src/data/attributes.ts","../src/data/array.ts","../src/builtin.ts"],"sourcesContent":["import { safeStringify } from '../shared/stringify.ts';\nimport {\n type AnyData,\n getCustomAlignment,\n isDisarray,\n isLooseDecorated,\n isUnstruct,\n} from './dataTypes.ts';\nimport { packedFormats } from './vertexFormatData.ts';\nimport {\n type BaseData,\n isDecorated,\n isWgslArray,\n isWgslStruct,\n} from './wgslTypes.ts';\n\nconst knownAlignmentMap: Record<string, number> = {\n f32: 4,\n f16: 2,\n i32: 4,\n u32: 4,\n bool: 4,\n u16: 2,\n vec2f: 8,\n vec2h: 4,\n vec2i: 8,\n vec2u: 8,\n vec2b: 8,\n vec3f: 16,\n vec3h: 8,\n vec3i: 16,\n vec3u: 16,\n vec3b: 16,\n vec4f: 16,\n vec4h: 8,\n vec4i: 16,\n vec4u: 16,\n vec4b: 16,\n mat2x2f: 8,\n mat3x3f: 16,\n mat4x4f: 16,\n atomic: 4,\n};\n\nfunction computeAlignment(data: object): number {\n const dataType = (data as BaseData)?.type;\n const knownAlignment = knownAlignmentMap[dataType];\n if (knownAlignment !== undefined) {\n return knownAlignment;\n }\n\n if (isWgslStruct(data)) {\n return Object.values(data.propTypes as Record<string, BaseData>)\n .map(alignmentOf)\n .reduce((a, b) => (a > b ? a : b));\n }\n\n if (isWgslArray(data)) {\n return alignmentOf(data.elementType);\n }\n\n if (isUnstruct(data)) {\n // A loose struct is aligned to its first property.\n const firstProp =\n Object.values(data.propTypes as Record<string, BaseData>)[0];\n return firstProp ? (getCustomAlignment(firstProp) ?? 1) : 1;\n }\n\n if (isDisarray(data)) {\n return getCustomAlignment(data.elementType) ?? 1;\n }\n\n if (isDecorated(data) || isLooseDecorated(data)) {\n return getCustomAlignment(data) ?? alignmentOf(data.inner);\n }\n\n if (packedFormats.has(dataType)) {\n return 1;\n }\n\n throw new Error(\n `Cannot determine alignment of data: ${safeStringify(data)}`,\n );\n}\n\nfunction computeCustomAlignment(data: BaseData): number {\n if (isUnstruct(data)) {\n // A loose struct is aligned to its first property.\n const firstProp =\n Object.values(data.propTypes as Record<string, BaseData>)[0];\n return firstProp ? customAlignmentOf(firstProp) : 1;\n }\n\n if (isDisarray(data)) {\n return customAlignmentOf(data.elementType);\n }\n\n if (isLooseDecorated(data)) {\n return getCustomAlignment(data) ?? customAlignmentOf(data.inner);\n }\n\n return getCustomAlignment(data) ?? 1;\n}\n\n/**\n * Since alignments can be inferred from data types, they are not stored on them.\n * Instead, this weak map acts as an extended property of those data types.\n */\nconst cachedAlignments = new WeakMap<object, number>();\n\nconst cachedCustomAlignments = new WeakMap<object, number>();\n\nexport function alignmentOf(data: BaseData): number {\n let alignment = cachedAlignments.get(data);\n if (alignment === undefined) {\n alignment = computeAlignment(data);\n cachedAlignments.set(data, alignment);\n }\n\n return alignment;\n}\n\nexport function customAlignmentOf(data: BaseData): number {\n let alignment = cachedCustomAlignments.get(data);\n if (alignment === undefined) {\n alignment = computeCustomAlignment(data);\n cachedCustomAlignments.set(data, alignment);\n }\n\n return alignment;\n}\n\n/**\n * Returns the alignment (in bytes) of data represented by the `schema`.\n */\nexport function PUBLIC_alignmentOf(schema: AnyData): number {\n return alignmentOf(schema);\n}\n","/**\n * @param value\n * @param modulo has to be power of 2\n */\nexport const roundUp = (value: number, modulo: number) => {\n const bitMask = modulo - 1;\n const invBitMask = ~bitMask;\n return (value & bitMask) === 0 ? value : (value & invBitMask) + modulo;\n};\n","import { roundUp } from '../mathUtils.ts';\nimport { alignmentOf, customAlignmentOf } from './alignmentOf.ts';\nimport type { AnyData, LooseTypeLiteral, Unstruct } from './dataTypes.ts';\nimport {\n getCustomSize,\n isDisarray,\n isLooseDecorated,\n isUnstruct,\n} from './dataTypes.ts';\nimport type { BaseData, WgslStruct, WgslTypeLiteral } from './wgslTypes.ts';\nimport { isDecorated, isWgslArray, isWgslStruct } from './wgslTypes.ts';\n\nconst knownSizesMap: Record<string, number> = {\n bool: 4,\n f32: 4,\n f16: 2,\n i32: 4,\n u32: 4,\n u16: 2,\n vec2f: 8,\n vec2h: 4,\n vec2i: 8,\n vec2u: 8,\n 'vec2<bool>': 8,\n vec3f: 12,\n vec3h: 6,\n vec3i: 12,\n vec3u: 12,\n 'vec3<bool>': 12,\n vec4f: 16,\n vec4h: 8,\n vec4i: 16,\n vec4u: 16,\n 'vec4<bool>': 16,\n mat2x2f: 16,\n mat3x3f: 48,\n mat4x4f: 64,\n uint8: 1,\n uint8x2: 2,\n uint8x4: 4,\n sint8: 1,\n sint8x2: 2,\n sint8x4: 4,\n unorm8: 1,\n unorm8x2: 2,\n unorm8x4: 4,\n snorm8: 1,\n snorm8x2: 2,\n snorm8x4: 4,\n uint16: 2,\n uint16x2: 4,\n uint16x4: 8,\n sint16: 2,\n sint16x2: 4,\n sint16x4: 8,\n unorm16: 2,\n unorm16x2: 4,\n unorm16x4: 8,\n snorm16: 2,\n snorm16x2: 4,\n snorm16x4: 8,\n float16: 2,\n float16x2: 4,\n float16x4: 8,\n float32: 4,\n float32x2: 8,\n float32x3: 12,\n float32x4: 16,\n uint32: 4,\n uint32x2: 8,\n uint32x3: 12,\n uint32x4: 16,\n sint32: 4,\n sint32x2: 8,\n sint32x3: 12,\n sint32x4: 16,\n 'unorm10-10-10-2': 4,\n 'unorm8x4-bgra': 4,\n atomic: 4,\n} satisfies Partial<Record<WgslTypeLiteral | LooseTypeLiteral, number>>;\n\nfunction sizeOfStruct(struct: WgslStruct) {\n let size = 0;\n const propTypes = struct.propTypes as Record<string, BaseData>;\n for (const property of Object.values(propTypes)) {\n if (Number.isNaN(size)) {\n throw new Error('Only the last property of a struct can be unbounded');\n }\n\n size = roundUp(size, alignmentOf(property));\n size += sizeOf(property);\n\n if (Number.isNaN(size) && property.type !== 'array') {\n throw new Error('Cannot nest unbounded struct within another struct');\n }\n }\n\n return roundUp(size, alignmentOf(struct));\n}\n\nfunction sizeOfUnstruct(data: Unstruct) {\n let size = 0;\n\n const propTypes = data.propTypes as Record<string, BaseData>;\n for (const property of Object.values(propTypes)) {\n const alignment = customAlignmentOf(property);\n size = roundUp(size, alignment);\n size += sizeOf(property);\n }\n\n return size;\n}\n\nfunction computeSize(data: object): number {\n const knownSize = knownSizesMap[(data as BaseData)?.type];\n\n if (knownSize !== undefined) {\n return knownSize;\n }\n\n if (isWgslStruct(data)) {\n return sizeOfStruct(data);\n }\n\n if (isUnstruct(data)) {\n return sizeOfUnstruct(data);\n }\n\n if (isWgslArray(data)) {\n if (data.elementCount === 0) {\n return Number.NaN;\n }\n\n const alignment = alignmentOf(data.elementType);\n const stride = roundUp(sizeOf(data.elementType), alignment);\n return stride * data.elementCount;\n }\n\n if (isDisarray(data)) {\n const alignment = customAlignmentOf(data.elementType);\n const stride = roundUp(sizeOf(data.elementType), alignment);\n return stride * data.elementCount;\n }\n\n if (isDecorated(data) || isLooseDecorated(data)) {\n return getCustomSize(data) ?? sizeOf(data.inner);\n }\n\n throw new Error(`Cannot determine size of data: ${data}`);\n}\n\n/**\n * Since sizes can be inferred from data types, they are not stored on them.\n * Instead, this weak map acts as an extended property of those data types.\n */\nconst cachedSizes = new WeakMap<BaseData, number>();\n\nexport function sizeOf(schema: BaseData): number {\n let size = cachedSizes.get(schema);\n\n if (size === undefined) {\n size = computeSize(schema);\n cachedSizes.set(schema, size);\n }\n\n return size;\n}\n\n/**\n * Returns the size (in bytes) of data represented by the `schema`.\n */\nexport function PUBLIC_sizeOf(schema: AnyData): number {\n return sizeOf(schema);\n}\n","import type {\n Infer,\n InferGPU,\n InferPartial,\n IsValidStorageSchema,\n IsValidUniformSchema,\n IsValidVertexSchema,\n MemIdentity,\n} from '../shared/repr.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport {\n $gpuRepr,\n $invalidSchemaReason,\n $memIdent,\n $repr,\n $reprPartial,\n $validStorageSchema,\n $validUniformSchema,\n $validVertexSchema,\n} from '../shared/symbols.ts';\nimport { alignmentOf } from './alignmentOf.ts';\nimport {\n type AnyData,\n type AnyLooseData,\n isLooseData,\n isLooseDecorated,\n type LooseDecorated,\n type LooseTypeLiteral,\n type Undecorate,\n} from './dataTypes.ts';\nimport { sizeOf } from './sizeOf.ts';\nimport {\n type Align,\n type AnyWgslData,\n type BaseData,\n type Builtin,\n type Decorated,\n type FlatInterpolatableData,\n type FlatInterpolationType,\n type Interpolate,\n type InterpolationType,\n type Invariant,\n isAlignAttrib,\n isBuiltinAttrib,\n isDecorated,\n isSizeAttrib,\n isWgslData,\n type Location,\n type PerspectiveOrLinearInterpolatableData,\n type PerspectiveOrLinearInterpolationType,\n type Size,\n type Vec4f,\n type WgslTypeLiteral,\n} from './wgslTypes.ts';\n\n// ----------\n// Public API\n// ----------\n\nexport const builtinNames = [\n 'vertex_index',\n 'instance_index',\n 'position',\n 'clip_distances',\n 'front_facing',\n 'frag_depth',\n 'sample_index',\n 'sample_mask',\n 'fragment',\n 'local_invocation_id',\n 'local_invocation_index',\n 'global_invocation_id',\n 'workgroup_id',\n 'num_workgroups',\n 'subgroup_invocation_id',\n 'subgroup_size',\n] as const;\n\nexport type BuiltinName = (typeof builtinNames)[number];\n\nexport type AnyAttribute<\n AllowedBuiltins extends Builtin<BuiltinName> = Builtin<BuiltinName>,\n> =\n | Align<number>\n | Size<number>\n | Location<number>\n | Interpolate<InterpolationType>\n | Invariant\n | AllowedBuiltins;\n\nexport type ExtractAttributes<T> = T extends {\n readonly attribs: unknown[];\n} ? T['attribs']\n : [];\n\n/**\n * Decorates a data-type `TData` with an attribute `TAttrib`.\n *\n * - if `TData` is loose\n * - if `TData` is already `LooseDecorated`\n * - Prepend `TAttrib` to the existing attribute tuple.\n * - else\n * - Wrap `TData` with `LooseDecorated` and a single attribute `[TAttrib]`\n * - else\n * - if `TData` is already `Decorated`\n * - Prepend `TAttrib` to the existing attribute tuple.\n * - else\n * - Wrap `TData` with `Decorated` and a single attribute `[TAttrib]`\n */\nexport type Decorate<\n TData extends BaseData,\n TAttrib extends AnyAttribute,\n> = TData['type'] extends WgslTypeLiteral\n ? Decorated<Undecorate<TData>, [TAttrib, ...ExtractAttributes<TData>]>\n : TData['type'] extends LooseTypeLiteral\n ? LooseDecorated<Undecorate<TData>, [TAttrib, ...ExtractAttributes<TData>]>\n : never;\n\nexport type IsBuiltin<T> = ExtractAttributes<T>[number] extends [] ? false\n : ExtractAttributes<T>[number] extends Builtin<BuiltinName> ? true\n : false;\n\nexport type HasCustomLocation<T> = ExtractAttributes<T>[number] extends []\n ? false\n : ExtractAttributes<T>[number] extends Location ? true\n : false;\n\nexport function attribute<TData extends BaseData, TAttrib extends AnyAttribute>(\n data: TData,\n attrib: TAttrib,\n): Decorated | LooseDecorated {\n if (isDecorated(data)) {\n return new DecoratedImpl(data.inner, [\n attrib,\n ...data.attribs,\n ]) as Decorated;\n }\n\n if (isLooseDecorated(data)) {\n return new LooseDecoratedImpl(data.inner, [\n attrib,\n ...data.attribs,\n ]) as LooseDecorated;\n }\n\n if (isLooseData(data)) {\n return new LooseDecoratedImpl(data, [attrib]) as unknown as LooseDecorated;\n }\n\n return new DecoratedImpl(data, [attrib]) as unknown as Decorated;\n}\n\n/**\n * Gives the wrapped data-type a custom byte alignment. Useful in order to\n * fulfill uniform alignment requirements.\n *\n * @example\n * const Data = d.struct({\n * a: u32, // takes up 4 bytes\n * // 12 bytes of padding, because `b` is custom aligned to multiples of 16 bytes\n * b: d.align(16, u32),\n * });\n *\n * @param alignment The multiple of bytes this data should align itself to.\n * @param data The data-type to align.\n */\nexport function align<TAlign extends number, TData extends AnyData>(\n alignment: TAlign,\n data: TData,\n): Decorate<TData, Align<TAlign>> {\n return attribute(data, {\n [$internal]: true,\n type: '@align',\n params: [alignment],\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n }) as any;\n}\n\n/**\n * Adds padding bytes after the wrapped data-type, until the whole value takes up `size` bytes.\n *\n * @example\n * const Data = d.struct({\n * a: d.size(16, u32), // takes up 16 bytes, instead of 4\n * b: u32, // starts at byte 16, because `a` has a custom size\n * });\n *\n * @param size The amount of bytes that should be reserved for this data-type.\n * @param data The data-type to wrap.\n */\nexport function size<TSize extends number, TData extends AnyData>(\n size: TSize,\n data: TData,\n): Decorate<TData, Size<TSize>> {\n return attribute(data, {\n [$internal]: true,\n type: '@size',\n params: [size],\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n }) as any;\n}\n\n/**\n * Assigns an explicit numeric location to a struct member or a parameter that has this type.\n *\n * @example\n * const VertexOutput = {\n * a: d.u32, // has implicit location 0\n * b: d.location(5, d.u32),\n * c: d.u32, // has implicit location 6\n * };\n *\n * @param location The explicit numeric location.\n * @param data The data-type to wrap.\n */\nexport function location<TLocation extends number, TData extends AnyData>(\n location: TLocation,\n data: TData,\n): Decorate<TData, Location<TLocation>> {\n return attribute(data, {\n [$internal]: true,\n type: '@location',\n params: [location],\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n }) as any;\n}\n\n/**\n * Specifies how user-defined vertex shader output (fragment shader input)\n * must be interpolated.\n *\n * Tip: Integer outputs cannot be interpolated.\n *\n * @example\n * const VertexOutput = {\n * a: d.f32, // has implicit 'perspective, center' interpolation\n * b: d.interpolate('linear, sample', d.f32),\n * };\n *\n * @param interpolationType How data should be interpolated.\n * @param data The data-type to wrap.\n */\nexport function interpolate<\n TInterpolation extends PerspectiveOrLinearInterpolationType,\n TData extends PerspectiveOrLinearInterpolatableData,\n>(\n interpolationType: TInterpolation,\n data: TData,\n): Decorate<TData, Interpolate<TInterpolation>>;\n\n/**\n * Specifies how user-defined vertex shader output (fragment shader input)\n * must be interpolated.\n *\n * Tip: Default sampling method of `flat` is `first`. Unless you specifically\n * need deterministic behavior provided by `'flat, first'`, prefer explicit\n * `'flat, either'` as it could be slightly faster in hardware.\n *\n * @example\n * const VertexOutput = {\n * a: d.f32, // has implicit 'perspective, center' interpolation\n * b: d.interpolate('flat, either', d.u32), // integer outputs cannot interpolate\n * };\n *\n * @param interpolationType How data should be interpolated.\n * @param data The data-type to wrap.\n */\nexport function interpolate<\n TInterpolation extends FlatInterpolationType,\n TData extends FlatInterpolatableData,\n>(\n interpolationType: TInterpolation,\n data: TData,\n): Decorate<TData, Interpolate<TInterpolation>>;\n\nexport function interpolate<\n TInterpolation extends InterpolationType,\n TData extends AnyData,\n>(\n interpolationType: TInterpolation,\n data: TData,\n): Decorate<TData, Interpolate<TInterpolation>> {\n return attribute(data, {\n [$internal]: true,\n type: '@interpolate',\n params: [interpolationType],\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n }) as any;\n}\n\n/**\n * Marks a position built-in output value as invariant in vertex shaders.\n * If the data and control flow match for two position outputs in different\n * entry points, then the result values are guaranteed to be the same.\n *\n * Must only be applied to the position built-in value.\n *\n * @example\n * const VertexOutput = {\n * pos: d.invariant(d.builtin.position),\n * };\n *\n * @param data The position built-in data-type to mark as invariant.\n */\nexport function invariant(\n data: Decorated<Vec4f, [Builtin<'position'>]>,\n): Decorated<Vec4f, [Builtin<'position'>, Invariant]> {\n // Validate that invariant is only applied to position built-in\n if (!isBuiltin(data)) {\n throw new Error(\n 'The @invariant attribute must only be applied to the position built-in value.',\n );\n }\n\n // Find the builtin attribute to check if it's position\n const builtinAttrib = (isDecorated(data) || isLooseDecorated(data))\n ? data.attribs.find(isBuiltinAttrib)\n : undefined;\n\n if (!builtinAttrib || builtinAttrib.params[0] !== 'position') {\n throw new Error(\n 'The @invariant attribute must only be applied to the position built-in value.',\n );\n }\n\n return attribute(data, {\n [$internal]: true,\n type: '@invariant',\n params: [],\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n }) as any;\n}\n\nexport function isBuiltin<\n T extends\n | Decorated<AnyWgslData, AnyAttribute[]>\n | LooseDecorated<AnyLooseData, AnyAttribute[]>,\n>(value: T | unknown): value is T {\n return (\n (isDecorated(value) || isLooseDecorated(value)) &&\n value.attribs.find(isBuiltinAttrib) !== undefined\n );\n}\n\nexport function getAttributesString<T extends BaseData>(field: T): string {\n if (!isDecorated(field) && !isLooseDecorated(field)) {\n return '';\n }\n\n return (field.attribs as AnyAttribute[])\n .map((attrib) => {\n if (attrib.params.length === 0) {\n return `${attrib.type} `;\n }\n return `${attrib.type}(${attrib.params.join(', ')}) `;\n })\n .join('');\n}\n\n// --------------\n// Implementation\n// --------------\n\nclass BaseDecoratedImpl<TInner extends BaseData, TAttribs extends unknown[]> {\n public readonly [$internal] = true;\n\n // Type-tokens, not available at runtime\n declare readonly [$repr]: Infer<TInner>;\n declare readonly [$gpuRepr]: InferGPU<TInner>;\n declare readonly [$reprPartial]: InferPartial<TInner>;\n // ---\n\n constructor(\n public readonly inner: TInner,\n public readonly attribs: TAttribs,\n ) {\n const alignAttrib = attribs.find(isAlignAttrib)?.params[0];\n const sizeAttrib = attribs.find(isSizeAttrib)?.params[0];\n\n if (alignAttrib !== undefined) {\n if (alignAttrib <= 0) {\n throw new Error(\n `Custom data alignment must be a positive number, got: ${alignAttrib}.`,\n );\n }\n\n if (Math.log2(alignAttrib) % 1 !== 0) {\n throw new Error(\n `Alignment has to be a power of 2, got: ${alignAttrib}.`,\n );\n }\n\n if (isWgslData(this.inner)) {\n if (alignAttrib % alignmentOf(this.inner) !== 0) {\n throw new Error(\n `Custom alignment has to be a multiple of the standard data alignment. Got: ${alignAttrib}, expected multiple of: ${\n alignmentOf(this.inner)\n }.`,\n );\n }\n }\n }\n\n if (sizeAttrib !== undefined) {\n if (sizeAttrib < sizeOf(this.inner)) {\n throw new Error(\n `Custom data size cannot be smaller then the standard data size. Got: ${sizeAttrib}, expected at least: ${\n sizeOf(this.inner)\n }.`,\n );\n }\n\n if (sizeAttrib <= 0) {\n throw new Error(\n `Custom data size must be a positive number. Got: ${sizeAttrib}.`,\n );\n }\n }\n }\n}\n\nclass DecoratedImpl<TInner extends BaseData, TAttribs extends unknown[]>\n extends BaseDecoratedImpl<TInner, TAttribs>\n implements Decorated<TInner, TAttribs> {\n public readonly [$internal] = true;\n public readonly type = 'decorated';\n\n // Type-tokens, not available at runtime\n declare readonly [$memIdent]: TAttribs extends Location[]\n ? MemIdentity<TInner> | Decorated<MemIdentity<TInner>, TAttribs>\n : Decorated<MemIdentity<TInner>, TAttribs>;\n declare readonly [$invalidSchemaReason]:\n Decorated[typeof $invalidSchemaReason];\n declare readonly [$validStorageSchema]: IsValidStorageSchema<TInner>;\n declare readonly [$validUniformSchema]: IsValidUniformSchema<TInner>;\n declare readonly [$validVertexSchema]: IsValidVertexSchema<TInner>;\n // ---\n}\n\nclass LooseDecoratedImpl<TInner extends BaseData, TAttribs extends unknown[]>\n extends BaseDecoratedImpl<TInner, TAttribs>\n implements LooseDecorated<TInner, TAttribs> {\n public readonly [$internal] = true;\n public readonly type = 'loose-decorated';\n\n // Type-tokens, not available at runtime\n declare readonly [$invalidSchemaReason]:\n LooseDecorated[typeof $invalidSchemaReason];\n declare readonly [$validVertexSchema]: IsValidVertexSchema<TInner>;\n // ---\n}\n","import { comptime } from '../core/function/comptime.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { schemaCallWrapper } from './schemaCallWrapper.ts';\nimport { sizeOf } from './sizeOf.ts';\nimport type { AnyWgslData, WgslArray } from './wgslTypes.ts';\n\n// ----------\n// Public API\n// ----------\n\ninterface WgslArrayConstructor {\n <TElement extends AnyWgslData>(\n elementType: TElement,\n ): (elementCount: number) => WgslArray<TElement>;\n\n <TElement extends AnyWgslData>(\n elementType: TElement,\n elementCount: number,\n ): WgslArray<TElement>;\n}\n\n/**\n * Creates an array schema that can be used to construct gpu buffers.\n * Describes arrays with fixed-size length, storing elements of the same type.\n *\n * @example\n * const LENGTH = 3;\n * const array = d.arrayOf(d.u32, LENGTH);\n *\n * If `elementCount` is not specified, a partially applied function is returned.\n * @example\n * const array = d.arrayOf(d.vec3f);\n * // ^? (n: number) => WgslArray<d.Vec3f>\n *\n * @param elementType The type of elements in the array.\n * @param elementCount The number of elements in the array.\n */\nexport const arrayOf = comptime(\n ((elementType, elementCount) => {\n if (elementCount === undefined) {\n return comptime((count: number) => cpu_arrayOf(elementType, count));\n }\n return cpu_arrayOf(elementType, elementCount);\n }) as WgslArrayConstructor,\n).$name('arrayOf');\n\n// --------------\n// Implementation\n// --------------\n\nfunction cpu_arrayOf<TElement extends AnyWgslData>(\n elementType: TElement,\n elementCount: number,\n): WgslArray<TElement> {\n // In the schema call, create and return a deep copy\n // by wrapping all the values in `elementType` schema calls.\n const arraySchema = (elements?: TElement[]) => {\n if (elements && elements.length !== elementCount) {\n throw new Error(\n `Array schema of ${elementCount} elements of type ${elementType.type} called with ${elements.length} argument(s).`,\n );\n }\n\n return Array.from(\n { length: elementCount },\n (_, i) => schemaCallWrapper(elementType, elements?.[i]),\n );\n };\n Object.setPrototypeOf(arraySchema, WgslArrayImpl);\n\n if (Number.isNaN(sizeOf(elementType))) {\n throw new Error('Cannot nest runtime sized arrays.');\n }\n arraySchema.elementType = elementType;\n\n if (!Number.isInteger(elementCount) || elementCount < 0) {\n throw new Error(\n `Cannot create array schema with invalid element count: ${elementCount}.`,\n );\n }\n arraySchema.elementCount = elementCount;\n\n return arraySchema as unknown as WgslArray<TElement>;\n}\n\nconst WgslArrayImpl = {\n [$internal]: true,\n type: 'array',\n\n toString(this: WgslArray): string {\n return `arrayOf(${this.elementType}, ${this.elementCount})`;\n },\n};\n","import { arrayOf } from './data/array.ts';\nimport { attribute } from './data/attributes.ts';\nimport type { LooseDecorated } from './data/dataTypes.ts';\nimport { bool, f32, u32 } from './data/numeric.ts';\nimport { vec3u, vec4f } from './data/vector.ts';\nimport type {\n AnyWgslData,\n BaseData,\n Bool,\n Builtin,\n Decorated,\n F32,\n U32,\n Vec3u,\n Vec4f,\n WgslArray,\n} from './data/wgslTypes.ts';\nimport { $internal } from './shared/symbols.ts';\n\n// ----------\n// Public API\n// ----------\n\nexport type BuiltinVertexIndex = Decorated<U32, [Builtin<'vertex_index'>]>;\nexport type BuiltinInstanceIndex = Decorated<U32, [Builtin<'instance_index'>]>;\nexport type BuiltinPosition = Decorated<Vec4f, [Builtin<'position'>]>;\nexport type BuiltinClipDistances = Decorated<\n WgslArray<U32>,\n [Builtin<'clip_distances'>]\n>;\nexport type BuiltinFrontFacing = Decorated<Bool, [Builtin<'front_facing'>]>;\nexport type BuiltinFragDepth = Decorated<F32, [Builtin<'frag_depth'>]>;\nexport type BuiltinSampleIndex = Decorated<U32, [Builtin<'sample_index'>]>;\nexport type BuiltinSampleMask = Decorated<U32, [Builtin<'sample_mask'>]>;\nexport type BuiltinLocalInvocationId = Decorated<\n Vec3u,\n [Builtin<'local_invocation_id'>]\n>;\nexport type BuiltinLocalInvocationIndex = Decorated<\n U32,\n [Builtin<'local_invocation_index'>]\n>;\nexport type BuiltinGlobalInvocationId = Decorated<\n Vec3u,\n [Builtin<'global_invocation_id'>]\n>;\nexport type BuiltinWorkgroupId = Decorated<Vec3u, [Builtin<'workgroup_id'>]>;\nexport type BuiltinNumWorkgroups = Decorated<\n Vec3u,\n [Builtin<'num_workgroups'>]\n>;\nexport type BuiltinSubgroupInvocationId = Decorated<\n U32,\n [Builtin<'subgroup_invocation_id'>]\n>;\nexport type BuiltinSubgroupSize = Decorated<U32, [Builtin<'subgroup_size'>]>;\n\nfunction defineBuiltin<T extends Decorated | LooseDecorated>(\n dataType: AnyWgslData,\n value: T['attribs'][0] extends { params: [infer TValue] } ? TValue : never,\n): T {\n return attribute(dataType, {\n [$internal]: true,\n type: '@builtin',\n // biome-ignore lint/suspicious/noExplicitAny: it's fine\n params: [value as any],\n }) as T;\n}\n\nexport const builtin = {\n vertexIndex: defineBuiltin<BuiltinVertexIndex>(u32, 'vertex_index'),\n instanceIndex: defineBuiltin<BuiltinInstanceIndex>(u32, 'instance_index'),\n position: defineBuiltin<BuiltinPosition>(vec4f, 'position'),\n clipDistances: defineBuiltin<BuiltinClipDistances>(\n arrayOf(u32, 8),\n 'clip_distances',\n ),\n frontFacing: defineBuiltin<BuiltinFrontFacing>(bool, 'front_facing'),\n fragDepth: defineBuiltin<BuiltinFragDepth>(f32, 'frag_depth'),\n sampleIndex: defineBuiltin<BuiltinSampleIndex>(u32, 'sample_index'),\n sampleMask: defineBuiltin<BuiltinSampleMask>(u32, 'sample_mask'),\n localInvocationId: defineBuiltin<BuiltinLocalInvocationId>(\n vec3u,\n 'local_invocation_id',\n ),\n localInvocationIndex: defineBuiltin<BuiltinLocalInvocationIndex>(\n u32,\n 'local_invocation_index',\n ),\n globalInvocationId: defineBuiltin<BuiltinGlobalInvocationId>(\n vec3u,\n 'global_invocation_id',\n ),\n workgroupId: defineBuiltin<BuiltinWorkgroupId>(vec3u, 'workgroup_id'),\n numWorkgroups: defineBuiltin<BuiltinNumWorkgroups>(vec3u, 'num_workgroups'),\n subgroupInvocationId: defineBuiltin<BuiltinSubgroupInvocationId>(\n u32,\n 'subgroup_invocation_id',\n ),\n subgroupSize: defineBuiltin<BuiltinSubgroupSize>(u32, 'subgroup_size'),\n} as const;\n\nexport type AnyBuiltin = (typeof builtin)[keyof typeof builtin];\nexport type AnyComputeBuiltin =\n | BuiltinLocalInvocationId\n | BuiltinLocalInvocationIndex\n | BuiltinGlobalInvocationId\n | BuiltinWorkgroupId\n | BuiltinNumWorkgroups\n | BuiltinSubgroupInvocationId\n | BuiltinSubgroupSize;\nexport type AnyVertexInputBuiltin = BuiltinVertexIndex | BuiltinInstanceIndex;\nexport type AnyVertexOutputBuiltin = BuiltinClipDistances | BuiltinPosition;\nexport type AnyFragmentInputBuiltin =\n | BuiltinPosition\n | BuiltinFrontFacing\n | BuiltinSampleIndex\n | BuiltinSampleMask\n | BuiltinSubgroupInvocationId\n | BuiltinSubgroupSize;\nexport type AnyFragmentOutputBuiltin = BuiltinFragDepth | BuiltinSampleMask;\n\nexport type OmitBuiltins<S> = S extends AnyBuiltin ? never\n : S extends BaseData ? S\n : {\n [Key in keyof S as S[Key] extends AnyBuiltin ? never : Key]: S[Key];\n };\n"],"mappings":"sMAgBA,IAAMA,EAA4C,CAChD,IAAK,EACL,IAAK,EACL,IAAK,EACL,IAAK,EACL,KAAM,EACN,IAAK,EACL,MAAO,EACP,MAAO,EACP,MAAO,EACP,MAAO,EACP,MAA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tB,CAAC,OAAO,UAAUC,CAAY,GAAKA,EAAe,EACpD,MAAM,IAAI,MACR,0DAA0DA,CAAY,GACxE,EAEF,OAAAG,EAAY,aAAeH,EAEpBG,CACT,CAEA,IAAMK,EAAgB,CACpB,CAACE,CAAS,EAAG,GACb,KAAM,QAEN,UAAkC,CAChC,MAAO,WAAW,KAAK,WAAW,KAAK,KAAK,YAAY,GAC1D,CACF,ECnCA,SAASC,EACPC,EACAC,EACG,CACH,OAAOC,EAAUF,EAAU,CACzB,CAACG,CAAS,EAAG,GACb,KAAM,WAEN,OAAQ,CAACF,CAAY,CACvB,CAAC,CACH,CAEO,IAAMG,GAAU,CACrB,YAAaL,EAAkCM,EAAK,cAAc,EAClE,cAAeN,EAAoCM,EAAK,gBAAgB,EACxE,SAAUN,EAA+BO,EAAO,UAAU,EAC1D,cAAeP,EACbQ,EAAQF,EAAK,CAAC,EACd,gBACF,EACA,YAAaN,EAAkCS,EAAM,cAAc,EACnE,UAAWT,EAAgCU,EAAK,YAAY,EAC5D,YAAaV,EAAkCM,EAAK,cAAc,EAClE,WAAYN,EAAiCM,EAAK,aAAa,EAC/D,kBAAmBN,EACjBW,EACA,qBACF,EACA,qBAAsBX,EACpBM,EACA,wBACF,EACA,mBAAoBN,EAClBW,EACA,sBACF,EACA,YAAaX,EAAkCW,EAAO,cAAc,EACpE,cAAeX,EAAoCW,EAAO,gBAAgB,EAC1E,qBAAsBX,EACpBM,EACA,wBACF,EACA,aAAcN,EAAmCM,EAAK,eAAe,CACvE","names":["knownAlignmentMap","computeAlignment","data","dataType","knownAlignment","isWgslStruct","alignmentOf","a","b","isWgslArray","isUnstruct","firstProp","getCustomAlignment","isDisarray","isDecorated","isLooseDecorated","packedFormats","safeStringify","computeCustomAlignment","customAlignmentOf","cachedAlignments","cachedCustomAlignments","alignment","PUBLIC_alignmentOf","schema","roundUp","value","modulo","bitMask","invBitMask","knownSizesMap","sizeOfStruct","struct","size","propTypes","property","roundUp","alignmentOf","sizeOf","sizeOfUnstruct","data","alignment","customAlignmentOf","computeSize","knownSize","isWgslStruct","isUnstruct","isWgslArray","isDisarray","isDecorated","isLooseDecorated","getCustomSize","cachedSizes","schema","PUBLIC_sizeOf","attribute","data","attrib","isDecorated","DecoratedImpl","isLooseDecorated","LooseDecoratedImpl","isLooseData","align","alignment","$internal","size","location","interpolate","interpolationType","invariant","isBuiltin","builtinAttrib","isBuiltinAttrib","value","getAttributesString","field","BaseDecoratedImpl","inner","attribs","alignAttrib","isAlignAttrib","sizeAttrib","isSizeAttrib","isWgslData","alignmentOf","sizeOf","arrayOf","comptime","elementType","elementCount","count","cpu_arrayOf","arraySchema","elements","_","i","schemaCallWrapper","WgslArrayImpl","sizeOf","$internal","defineBuiltin","dataType","value","attribute","$internal","builtin","u32","vec4f","arrayOf","bool","f32","vec3u"]}
var m="0.9.0";var o=Symbol(`typegpu:${m}:$internal`),dn=Symbol(`typegpu:${m}:$gpuValueOf`),B=Symbol(`typegpu:${m}:$getNameForward`),Re=Symbol(`typegpu:${m}:$providing`),de=Symbol(`typegpu:${m}:$ownSnippet`),R=Symbol(`typegpu:${m}:$resolve`),Ne=Symbol(`typegpu:${m}:$repr`),mn=Symbol(`typegpu:${m}:$gpuRepr`),fn=Symbol(`typegpu:${m}:$reprPartial`),wn=Symbol(`typegpu:${m}:$memIdent`),Tn=Symbol(`typegpu:${m}:$invalidStorageSchema`),gn=Symbol(`typegpu:${m}:$validUniformSchema`),Vn=Symbol(`typegpu:${m}:$validVertexSchema`),vn=Symbol(`typegpu:${m}:$invalidSchemaReason`);function u(e){return!!e?.[o]}var Sn={[o]:!0,type:"void",toString(){return"void"}},It=["bool","f32","f16","i32","u32","u16","vec2f","vec2h","vec2i","vec2u","vec2<bool>","vec3f","vec3h","vec3i","vec3u","vec3<bool>","vec4f","vec4h","vec4i","vec4u","vec4<bool>","mat2x2f","mat3x3f","mat4x4f","struct","array","ptr","atomic","decorated","abstractInt","abstractFloat","void","texture_1d","texture_storage_1d","texture_2d","texture_storage_2d","texture_multisampled_2d","texture_depth_2d","texture_depth_multisampled_2d","texture_2d_array","texture_storage_2d_array","texture_depth_2d_array","texture_cube","texture_depth_cube","texture_cube_array","texture_depth_cube_array","texture_3d","texture_storage_3d","texture_external","sampler","sampler_comparison"];function ie(e){let t=e;return u(t)&&typeof t.kind=="string"&&t.kind.startsWith("vec")}function At(e){let t=e;return u(t)&&typeof t.type=="string"&&t.type.startsWith("vec2")}function $t(e){let t=e;return u(t)&&typeof t.type=="string"&&t.type.startsWith("vec3")}function Dt(e){let t=e;return u(t)&&typeof t.type=="string"&&t.type.startsWith("vec4")}function se(e){return At(e)||$t(e)||Dt(e)}function me(e){let t=e;return u(t)&&typeof t.kind?.startsWith=="function"&&t.kind.startsWith("mat")}function kt(e){return u(e)&&e?.type==="mat2x2f"}function Ft(e){return u(e)&&e?.type==="mat3x3f"}function Pt(e){return u(e)&&e?.type==="mat4x4f"}function _e(e){return kt(e)||Ft(e)||Pt(e)}function _n(e){return ie(e)&&["vec2f","vec3f","vec4f"].includes(e.kind)}function fe(e){return u(e)&&It.includes(e?.type)}function In(e){return u(e)&&e?.type==="array"}function An(e){return u(e)&&e?.type==="struct"}function Ee(e){return u(e)&&e?.type==="ptr"}function $n(e){return u(e)&&e?.type==="atomic"}function Ue(e){return u(e)&&e?.type==="@align"}function Ce(e){return u(e)&&e?.type==="@size"}function Be(e){return u(e)&&e?.type==="@location"}function Dn(e){return u(e)&&e?.type==="@interpolate"}function kn(e){return u(e)&&e?.type==="@builtin"}function Fn(e){return u(e)&&e?.type==="decorated"}function Pn(e){return u(e)&&e.type==="void"}function Me(e){let t=e?.type;return u(e)&&(t==="abstractInt"||t==="abstractFloat"||t==="f32"||t==="f16"||t==="i32"||t==="u32")}function Rn(e){let t=e?.type;return u(e)&&(t==="f16"||t==="vec2h"||t==="vec3h"||t==="vec4h")}var Rt=["abstractInt","abstractFloat","f32","f16","i32","u32","bool"];function Oe(e){return!u(e)||Rt.includes(e?.type)}function We(e){return e.schema}var b=process.env.NODE_ENV==="development",M=process.env.NODE_ENV==="test";Object.assign(globalThis,{__TYPEGPU_AUTONAME__:(e,t)=>(Et(e)&&u(e)&&!z(e)&&e.$name(t),e)});var oe=globalThis,Cn=(b||M)&&{get enabled(){return!!oe.__TYPEGPU_MEASURE_PERF__},record(e,t){let n=oe.__TYPEGPU_PERF_RECORDS__??=new Map,r=n.get(e);r||(r=[],n.set(e,r)),r.push(t)}}||void 0;function je(e){return!!e?.[B]}function z(e){return je(e)?z(e[B]):Ge(e)?.name}function g(e,t){je(e)&&g(e[B],t),Ut(e,{name:t})}function Et(e){return!!e?.$name}function Le(e){return!!Ge(e)?.ast}function Ge(e){return oe.__TYPEGPU_META__.get(e)}function Ut(e,t){oe.__TYPEGPU_META__??=new WeakMap;let n=oe.__TYPEGPU_META__;n.set(e,{...n.get(e),...t})}var Ke=["uint8","uint8x2","uint8x4","sint8","sint8x2","sint8x4","unorm8","unorm8x2","unorm8x4","snorm8","snorm8x2","snorm8x4","uint16","uint16x2","uint16x4","sint16","sint16x2","sint16x4","unorm16","unorm16x2","unorm16x4","snorm16","snorm16x2","snorm16x4","float16","float16x2","float16x4","float32","float32x2","float32x3","float32x4","uint32","uint32x2","uint32x3","uint32x4","sint32","sint32x2","sint32x3","sint32x4","unorm10-10-10-2","unorm8x4-bgra"],Mn={f32:"float32",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",f16:"float16",vec2h:"float16x2",vec4h:"float16x4",u32:"uint32",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",i32:"sint32",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4"};function I(e){return e.type==="decorated"||e.type==="loose-decorated"?e.inner:e}function Kn(e){return e.type==="ptr"?e.inner:e}var Ct=["unstruct","disarray","loose-decorated",...Ke];function Bt(e){return u(e)&&Ct.includes(e?.type)}function Yn(e){return u(e)&&e?.type==="disarray"}function Hn(e){return u(e)&&e?.type==="unstruct"}function qn(e){return u(e)&&e?.type==="loose-decorated"}function Jn(e){return e.attribs?.find(Ue)?.params[0]}function Xn(e){return e.attribs?.find(Ce)?.params[0]}function Zn(e){return e.attribs?.find(Be)?.params[0]}function Qn(e){return fe(e)||Bt(e)}var ae={type:"unknown",toString(){return"unknown"}},Ye=class{constructor(t,n,r){this.name=t;this.lhs=n;this.operator=r}},He=class{constructor(t){this.matrix=t}},qe=class{constructor(t){this.op=t;g(this,"consoleLog")}[o]=!0};var Ie="Invariant failed";function we(e,t){if(e)return;if(!b&&!M)throw new Error(Ie);let n=typeof t=="function"?t():t,r=n?`${Ie}: ${n}`:Ie;throw new Error(r)}var Je=class e extends Error{constructor(n,r){let i=r.map(s=>`- ${Le(s)?`fn*:${z(s)}`:s}`);i.length>20&&(i=[...i.slice(0,11),"...",...i.slice(-10)]);super(`Resolution of the following tree failed:
${i.join(`
`)}: ${n&&typeof n=="object"&&"message"in n?n.message:n}`);this.cause=n;this.trace=r;Object.setPrototypeOf(this,e.prototype)}appendToTrace(n){let r=[n,...this.trace];return new e(this.cause,r)}},Xe=class e extends Error{constructor(n,r){let i=r.map(s=>`- ${s}`);i.length>20&&(i=[...i.slice(0,11),"...",...i.slice(-10)]);super(`Execution of the following tree failed:
${i.join(`
`)}: ${n&&typeof n=="object"&&"message"in n?n.message:n}`);this.cause=n;this.trace=r;Object.setPrototypeOf(this,e.prototype)}appendToTrace(n){let r=[n,...this.trace];return new e(this.cause,r)}},Ze=class e extends Error{constructor(n){super(`Missing value for '${n}'`);this.slot=n;Object.setPrototypeOf(this,e.prototype)}},Qe=class e extends Error{constructor(t){super(`Buffer '${z(t)??"<unnamed>"}' is not bindable as a uniform. Use .$usage('uniform') to allow it.`),Object.setPrototypeOf(this,e.prototype)}},et=class e extends Error{constructor(t,n){super(`The function '${t??"<unnamed>"}' is missing links to the following external values: ${n}.`),Object.setPrototypeOf(this,e.prototype)}},tt=class e extends Error{constructor(t){super(`Missing bind groups for layouts: '${[...t].map(n=>z(n)??"<unnamed>").join(", ")}'. Please provide it using pipeline.with(bindGroup).(...)`),Object.setPrototypeOf(this,e.prototype)}},nt=class e extends Error{constructor(t){super(`Missing vertex buffers for layouts: '${[...t].map(n=>z(n)??"<unnamed>").join(", ")}'. Please provide it using pipeline.with(layout, buffer).(...)`),Object.setPrototypeOf(this,e.prototype)}},rt=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},it=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},A=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function st(e){return e?.resourceType==="slot"}function ot(e){return e?.resourceType==="derived"}function at(e){return e?.[Re]!==void 0}function ar(e){return e?.resourceType==="accessor"}function Mt(e){return e==="runtime"||e==="constant"||e==="argument"}function lr(e){return Mt(e.origin)}var ut={uniform:{space:"uniform",access:"read"},readonly:{space:"storage",access:"read"},mutable:{space:"storage",access:"read-write"},workgroup:{space:"workgroup",access:"read-write"},private:{space:"private",access:"read-write"},function:{space:"function",access:"read-write"},"this-function":{space:"function",access:"read-write"}},Te=class{constructor(t,n,r){this.value=t;this.dataType=n;this.origin=r}};function ue(e){return e instanceof Te}function hr(e){return Me(e.dataType)}function y(e,t,n){if(b&&ue(e))throw new Error("Cannot nest snippets");return new Te(e,I(t),n)}function fr(e){return S("function",e,"read-write")}function wr(e){return S("private",e,"read-write")}function Tr(e){return S("workgroup",e,"read-write")}function gr(e,t="read"){return S("storage",e,t)}function Vr(e){return S("uniform",e,"read")}function vr(e){return S("handle",e,"read")}function S(e,t,n,r=!1){return{[o]:!0,type:"ptr",addressSpace:e,inner:t,access:n,implicit:r,toString:()=>`ptr<${e}, ${t}, ${n}>`}}function yt(e,t){let n=ut[e];if(n)return S(n.space,t,n.access)}function br(e){return S(e.addressSpace,e.inner,e.access,!0)}function ct(e){return S(e.addressSpace,e.inner,e.access,!1)}var $=class{type="normal"},pt=class{type="codegen"},lt=class{constructor(t,n){this.buffers=t;this.vars=n}type="simulate"};function Ot(e){return!!e?.[R]}function Ae(e){return e?.[de]}function ye(e){return(typeof e.value!="string"||e.dataType.type==="unknown")&&Ae(e.value)===void 0}function Dr(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||Ot(e)||fe(e)||st(e)||ot(e)||at(e)}function kr(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}var ge=!1;function Nr(e){if(ge)return e();try{return ge=!0,e()}finally{ge=!1}}function Er(){return ge}var D;function Ur(e,t){if(we(D===void 0||D===e,"Cannot nest context providers"),D===e)return t();D=e;try{return t()}finally{D=void 0}}function O(){return D}var Wt=new $;function Cr(){return D?.mode??Wt}function Ve(){return D?.mode.type==="codegen"}function p(e,...t){let n=O();function r(s){return ue(s)?n.resolve(s.value,s.dataType).value:s}let i="";for(let s=0;s<e.length;++s){i+=e[s];let c=t[s];Array.isArray(c)?i+=c.filter(l=>l!==void 0).map(r).join(", "):c&&(i+=r(c))}return i}var Zr=(()=>{let e=r=>{if(r.origin==="argument")throw new A(p`d.ref(${r}) is illegal, cannot take a reference of an argument. Copy the value locally first, and take a reference of the copy.`);if(r.dataType.type==="ptr")return y(r.value,ct(r.dataType),r.origin);let i=yt(r.origin,r.dataType);return y(new W(r,i),i??ae,"runtime")},t=r=>new ve(r),n=r=>Ve()?e(r):t(r);return g(n,"ref"),n.toString=()=>"ref",Object.defineProperty(n,o,{value:{jsImpl:t,gpuImpl:e,strictSignature:void 0,argConversionHint:"keep"}}),n})();function ht(e){return e instanceof ve}var ve=class{[o];type;#e;constructor(t){this[o]=!0,this.type="ref",this.#e=t}get $(){return this.#e}set $(t){if(t&&typeof t=="object")for(let n of Object.keys(t))this.#e[n]=t[n];else this.#e=t}},W=class{[o];snippet;#e;constructor(t,n){this[o]=!0,this.snippet=t,this.#e=n}get[de](){if(!this.#e)throw new Error(p`Cannot take a reference of ${this.snippet}`);return y(this,this.#e,this.snippet.origin)}[R](t){if(!this.#e)throw new Error(p`Cannot take a reference of ${this.snippet}`);return y(p`(&${this.snippet})`,this.#e,this.snippet.origin)}};function xt(e){if(!Ee(e.dataType))return e;let t=e.dataType.inner,n=Oe(t)?"runtime":e.origin;return e.value instanceof W?y(p`${e.value.snippet}`,t,n):y(p`(*${e})`,t,n)}function dt(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}var $e={rank:Number.POSITIVE_INFINITY,action:"none"};function be(e,t){let n=I(e),r=I(t);if(n.type===r.type)return{rank:0,action:"none"};if(n.type==="abstractFloat"){if(r.type==="f32")return{rank:1,action:"none"};if(r.type==="f16")return{rank:2,action:"none"}}if(n.type==="abstractInt"){if(r.type==="i32")return{rank:3,action:"none"};if(r.type==="u32")return{rank:4,action:"none"};if(r.type==="abstractFloat")return{rank:5,action:"none"};if(r.type==="f32")return{rank:6,action:"none"};if(r.type==="f16")return{rank:7,action:"none"}}return se(n)&&se(r)?be(n.primitive,r.primitive):_e(n)&&_e(r)?{rank:0,action:"none"}:$e}function jt(e,t){let n=I(e),r=I(t);if(n.type==="ptr"&&n.implicit&&be(n.inner,r).rank<Number.POSITIVE_INFINITY)return{rank:0,action:"deref"};if(r.type==="ptr"&&be(n,r.inner).rank<Number.POSITIVE_INFINITY)return{rank:1,action:"ref"};let i={f32:0,f16:1,i32:2,u32:3,bool:4};if(n.type in i&&r.type in i){let s=n.type,c=r.type;if(s!==c){let l=i[s];return{rank:i[c]<l?10:20,action:"cast",targetType:r}}}if(n.type==="abstractFloat"){if(r.type==="u32")return{rank:2,action:"cast",targetType:r};if(r.type==="i32")return{rank:1,action:"cast",targetType:r}}return $e}function Lt(e,t,n){let r=be(e,t);return r.rank<Number.POSITIVE_INFINITY?r:n?jt(e,t):$e}function mt(e,t,n){let r;for(let s of t){let c=[],l=0;for(let d of e){let h=Lt(d,s,n);if(l+=h.rank,h.rank===Number.POSITIVE_INFINITY)break;c.push(h)}l<(r?.sum??Number.POSITIVE_INFINITY)&&(r={type:s,details:c,sum:l})}if(!r)return;let i=r.details.map((s,c)=>({sourceIndex:c,action:s.action,...s.action==="cast"&&{targetType:s.targetType}}));return{targetType:r.type,actions:i,hasImplicitConversions:i.some(s=>s.action==="cast")}}function ft(e,t){if(e.length===0)return;let n=[...new Set((t||e).map(I))],r=mt(e,n,!1);if(r)return r;let i=mt(e,n,!0);if(i)return i}function Gt(e,t,n){if(t.action==="none")return y(e.value,n,e.origin);switch(t.action){case"ref":return y(new W(e,n),n,e.origin);case"deref":return xt(e);case"cast":return n(e);default:dt(t.action,"applyActionToSnippet")}}function yi(e,t){if(e.some(r=>r.type==="unknown"))return;let n=ft(e,t);if(n)return e.map(()=>n.targetType)}function wt(e,t,n=!0){let r=e.map(s=>s.dataType);if(r.some(s=>s.type==="unknown"))return;b&&Array.isArray(t)&&t.length===0&&console.warn("convertToCommonType was called with an empty restrictTo array, which prevents any conversions from being made. If you intend to allow all conversions, pass undefined instead. If this was intended call the function conditionally since the result will always be undefined.");let i=ft(r,t);if(i)return(M||b)&&n&&i.hasImplicitConversions&&console.warn(`Implicit conversions from [
${e.map(s=>` ${s.value}: ${s.dataType.type}`).join(`,
`)}
] to ${i.targetType.type} are supported, but not recommended.
Consider using explicit conversions instead.`),e.map((s,c)=>{let l=i.actions[c];return we(l,"Action should not be undefined"),Gt(s,l,i.targetType)})}function Tt(e,t,n=!0){if(t===e.dataType)return y(e.value,t,e.origin);if(e.dataType.type==="unknown")return y(p`${y(e.value,t,e.origin)}`,t,e.origin);let r=wt([e],[t],n);if(!r)throw new A(`Cannot convert value of type '${String(e.dataType)}' to type '${t.type}'`);return r[0]}function ci(e,t){return Object.keys(e.propTypes).map(r=>{let i=t[r];if(!i)throw new Error(`Missing property ${r}`);let s=e.propTypes[r];return wt([i],[s])?.[0]??i})}var ze=class extends Error{constructor(t){super(t),this.name=this.constructor.name}};function k(e){let t=(...r)=>{let i=O(),{argTypes:s,returnType:c}=typeof e.signature=="function"?e.signature(...r.map(h=>h.dataType.type==="ptr"&&h.dataType.implicit?h.dataType.inner:h.dataType)):e.signature,d=r.map((h,P)=>{let C=s[P];if(!C)throw new Error("Function called with invalid arguments");return Tt(h,C,!e.ignoreImplicitCastWarning)});if(!e.noComptime&&d.every(h=>ye(h))&&typeof e.normalImpl=="function"){i.pushMode(new $);try{return y(e.normalImpl(...d.map(h=>h.value)),c,"constant")}catch(h){if(!(h instanceof ze))throw h}finally{i.popMode("normal")}}return y(e.codegenImpl(...d),c,"runtime")},n=((...r)=>{if(Ve())return t(...r);if(typeof e.normalImpl=="string")throw new ze(e.normalImpl);return e.normalImpl(...r)});return g(n,e.name),n.toString=()=>e.name,Object.defineProperty(n,o,{value:{jsImpl:e.normalImpl,gpuImpl:t,get strictSignature(){return typeof e.signature!="function"?e.signature:void 0},argConversionHint:"keep"}}),n}var gt={[o]:!0,type:"abstractInt",toString(){return"abstractInt"}},De={[o]:!0,type:"abstractFloat",toString(){return"abstractFloat"}},Kt=k({name:"bool",signature:e=>({argTypes:e?[e]:[],returnType:V}),normalImpl(e){return e===void 0?!1:typeof e=="boolean"?e:!!e},codegenImpl:e=>e.dataType.type==="bool"?p`${e}`:p`bool(${e})`}),V=Object.assign(Kt,{type:"bool"}),Yt=k({name:"u32",signature:e=>({argTypes:e?[e]:[],returnType:T}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:(e&4294967295)>>>0},codegenImpl:e=>e.dataType.type==="u32"?p`${e}`:p`u32(${e})`}),T=Object.assign(Yt,{type:"u32"}),Ht=k({name:"i32",signature:e=>({argTypes:e?[e]:[],returnType:f}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:e|0},codegenImpl:e=>e.dataType.type==="i32"?p`${e}`:p`i32(${e})`}),vi={[o]:!0,type:"u16"},f=Object.assign(Ht,{type:"i32"}),qt=k({name:"f32",signature:e=>({argTypes:e?[e]:[],returnType:x}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:Math.fround(e)},codegenImpl:e=>e.dataType.type==="f32"?p`${e}`:p`f32(${e})`}),x=Object.assign(qt,{type:"f32"}),Vt=new ArrayBuffer(4),Jt=new Float32Array(Vt),Xt=new Uint32Array(Vt);function Zt(e){Jt[0]=e;let t=Xt[0],n=t>>>31&1,r=t>>>23&255,i=t&8388607;return r===255?n<<15|31744|(i?512:0):(r=r-127+15,r<=0?r<-10?n<<15:(i=(i|8388608)>>1-r,i=i+4096>>13,n<<15|i):r>=31||(i=i+4096,i&8388608&&(i=0,++r,r>=31))?n<<15|31744:n<<15|r<<10|i>>13)}function Qt(e){let t=e&32768?-1:1,n=e>>10&31,r=e&1023;return n===0?r?t*r*2**-24:t*0:n===31?r?Number.NaN:t===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t*(1+r/1024)*2**(n-15)}function en(e){return Qt(Zt(e))}var tn=k({name:"f16",signature:e=>({argTypes:e?[e]:[],returnType:_}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:en(e)},codegenImpl:e=>e.dataType.type==="f16"?p`${e}`:p`f16(${e})`}),_=Object.assign(tn,{type:"f16"});var ce=class extends Array{castElement(){return this[o].elementSchema[o].jsImpl}[R](){let t=this[o].elementSchema;return this.every(n=>!n)?y(`${this.kind}()`,t,"constant"):this.every(n=>this[0]===n)?y(`${this.kind}(${this[0]})`,t,"runtime"):y(`${this.kind}(${this.join(", ")})`,t,"runtime")}toString(){return this[R]().value}get xx(){return new this._Vec2(this[0],this[0])}get xy(){return new this._Vec2(this[0],this[1])}get xz(){return new this._Vec2(this[0],this[2])}get xw(){return new this._Vec2(this[0],this[3])}get yx(){return new this._Vec2(this[1],this[0])}get yy(){return new this._Vec2(this[1],this[1])}get yz(){return new this._Vec2(this[1],this[2])}get yw(){return new this._Vec2(this[1],this[3])}get zx(){return new this._Vec2(this[2],this[0])}get zy(){return new this._Vec2(this[2],this[1])}get zz(){return new this._Vec2(this[2],this[2])}get zw(){return new this._Vec2(this[2],this[3])}get wx(){return new this._Vec2(this[3],this[0])}get wy(){return new this._Vec2(this[3],this[1])}get wz(){return new this._Vec2(this[3],this[2])}get ww(){return new this._Vec2(this[3],this[3])}get xxx(){return new this._Vec3(this[0],this[0],this[0])}get xxy(){return new this._Vec3(this[0],this[0],this[1])}get xxz(){return new this._Vec3(this[0],this[0],this[2])}get xxw(){return new this._Vec3(this[0],this[0],this[3])}get xyx(){return new this._Vec3(this[0],this[1],this[0])}get xyy(){return new this._Vec3(this[0],this[1],this[1])}get xyz(){return new this._Vec3(this[0],this[1],this[2])}get xyw(){return new this._Vec3(this[0],this[1],this[3])}get xzx(){return new this._Vec3(this[0],this[2],this[0])}get xzy(){return new this._Vec3(this[0],this[2],this[1])}get xzz(){return new this._Vec3(this[0],this[2],this[2])}get xzw(){return new this._Vec3(this[0],this[2],this[3])}get xwx(){return new this._Vec3(this[0],this[3],this[0])}get xwy(){return new this._Vec3(this[0],this[3],this[1])}get xwz(){return new this._Vec3(this[0],this[3],this[2])}get xww(){return new this._Vec3(this[0],this[3],this[3])}get yxx(){return new this._Vec3(this[1],this[0],this[0])}get yxy(){return new this._Vec3(this[1],this[0],this[1])}get yxz(){return new this._Vec3(this[1],this[0],this[2])}get yxw(){return new this._Vec3(this[1],this[0],this[3])}get yyx(){return new this._Vec3(this[1],this[1],this[0])}get yyy(){return new this._Vec3(this[1],this[1],this[1])}get yyz(){return new this._Vec3(this[1],this[1],this[2])}get yyw(){return new this._Vec3(this[1],this[1],this[3])}get yzx(){return new this._Vec3(this[1],this[2],this[0])}get yzy(){return new this._Vec3(this[1],this[2],this[1])}get yzz(){return new this._Vec3(this[1],this[2],this[2])}get yzw(){return new this._Vec3(this[1],this[2],this[3])}get ywx(){return new this._Vec3(this[1],this[3],this[0])}get ywy(){return new this._Vec3(this[1],this[3],this[1])}get ywz(){return new this._Vec3(this[1],this[3],this[2])}get yww(){return new this._Vec3(this[1],this[3],this[3])}get zxx(){return new this._Vec3(this[2],this[0],this[0])}get zxy(){return new this._Vec3(this[2],this[0],this[1])}get zxz(){return new this._Vec3(this[2],this[0],this[2])}get zxw(){return new this._Vec3(this[2],this[0],this[3])}get zyx(){return new this._Vec3(this[2],this[1],this[0])}get zyy(){return new this._Vec3(this[2],this[1],this[1])}get zyz(){return new this._Vec3(this[2],this[1],this[2])}get zyw(){return new this._Vec3(this[2],this[1],this[3])}get zzx(){return new this._Vec3(this[2],this[2],this[0])}get zzy(){return new this._Vec3(this[2],this[2],this[1])}get zzz(){return new this._Vec3(this[2],this[2],this[2])}get zzw(){return new this._Vec3(this[2],this[2],this[3])}get zwx(){return new this._Vec3(this[2],this[3],this[0])}get zwy(){return new this._Vec3(this[2],this[3],this[1])}get zwz(){return new this._Vec3(this[2],this[3],this[2])}get zww(){return new this._Vec3(this[2],this[3],this[3])}get wxx(){return new this._Vec3(this[3],this[0],this[0])}get wxy(){return new this._Vec3(this[3],this[0],this[1])}get wxz(){return new this._Vec3(this[3],this[0],this[2])}get wxw(){return new this._Vec3(this[3],this[0],this[3])}get wyx(){return new this._Vec3(this[3],this[1],this[0])}get wyy(){return new this._Vec3(this[3],this[1],this[1])}get wyz(){return new this._Vec3(this[3],this[1],this[2])}get wyw(){return new this._Vec3(this[3],this[1],this[3])}get wzx(){return new this._Vec3(this[3],this[2],this[0])}get wzy(){return new this._Vec3(this[3],this[2],this[1])}get wzz(){return new this._Vec3(this[3],this[2],this[2])}get wzw(){return new this._Vec3(this[3],this[2],this[3])}get wwx(){return new this._Vec3(this[3],this[3],this[0])}get wwy(){return new this._Vec3(this[3],this[3],this[1])}get wwz(){return new this._Vec3(this[3],this[3],this[2])}get www(){return new this._Vec3(this[3],this[3],this[3])}get xxxx(){return new this._Vec4(this[0],this[0],this[0],this[0])}get xxxy(){return new this._Vec4(this[0],this[0],this[0],this[1])}get xxxz(){return new this._Vec4(this[0],this[0],this[0],this[2])}get xxxw(){return new this._Vec4(this[0],this[0],this[0],this[3])}get xxyx(){return new this._Vec4(this[0],this[0],this[1],this[0])}get xxyy(){return new this._Vec4(this[0],this[0],this[1],this[1])}get xxyz(){return new this._Vec4(this[0],this[0],this[1],this[2])}get xxyw(){return new this._Vec4(this[0],this[0],this[1],this[3])}get xxzx(){return new this._Vec4(this[0],this[0],this[2],this[0])}get xxzy(){return new this._Vec4(this[0],this[0],this[2],this[1])}get xxzz(){return new this._Vec4(this[0],this[0],this[2],this[2])}get xxzw(){return new this._Vec4(this[0],this[0],this[2],this[3])}get xxwx(){return new this._Vec4(this[0],this[0],this[3],this[0])}get xxwy(){return new this._Vec4(this[0],this[0],this[3],this[1])}get xxwz(){return new this._Vec4(this[0],this[0],this[3],this[2])}get xxww(){return new this._Vec4(this[0],this[0],this[3],this[3])}get xyxx(){return new this._Vec4(this[0],this[1],this[0],this[0])}get xyxy(){return new this._Vec4(this[0],this[1],this[0],this[1])}get xyxz(){return new this._Vec4(this[0],this[1],this[0],this[2])}get xyxw(){return new this._Vec4(this[0],this[1],this[0],this[3])}get xyyx(){return new this._Vec4(this[0],this[1],this[1],this[0])}get xyyy(){return new this._Vec4(this[0],this[1],this[1],this[1])}get xyyz(){return new this._Vec4(this[0],this[1],this[1],this[2])}get xyyw(){return new this._Vec4(this[0],this[1],this[1],this[3])}get xyzx(){return new this._Vec4(this[0],this[1],this[2],this[0])}get xyzy(){return new this._Vec4(this[0],this[1],this[2],this[1])}get xyzz(){return new this._Vec4(this[0],this[1],this[2],this[2])}get xyzw(){return new this._Vec4(this[0],this[1],this[2],this[3])}get xywx(){return new this._Vec4(this[0],this[1],this[3],this[0])}get xywy(){return new this._Vec4(this[0],this[1],this[3],this[1])}get xywz(){return new this._Vec4(this[0],this[1],this[3],this[2])}get xyww(){return new this._Vec4(this[0],this[1],this[3],this[3])}get xzxx(){return new this._Vec4(this[0],this[2],this[0],this[0])}get xzxy(){return new this._Vec4(this[0],this[2],this[0],this[1])}get xzxz(){return new this._Vec4(this[0],this[2],this[0],this[2])}get xzxw(){return new this._Vec4(this[0],this[2],this[0],this[3])}get xzyx(){return new this._Vec4(this[0],this[2],this[1],this[0])}get xzyy(){return new this._Vec4(this[0],this[2],this[1],this[1])}get xzyz(){return new this._Vec4(this[0],this[2],this[1],this[2])}get xzyw(){return new this._Vec4(this[0],this[2],this[1],this[3])}get xzzx(){return new this._Vec4(this[0],this[2],this[2],this[0])}get xzzy(){return new this._Vec4(this[0],this[2],this[2],this[1])}get xzzz(){return new this._Vec4(this[0],this[2],this[2],this[2])}get xzzw(){return new this._Vec4(this[0],this[2],this[2],this[3])}get xzwx(){return new this._Vec4(this[0],this[2],this[3],this[0])}get xzwy(){return new this._Vec4(this[0],this[2],this[3],this[1])}get xzwz(){return new this._Vec4(this[0],this[2],this[3],this[2])}get xzww(){return new this._Vec4(this[0],this[2],this[3],this[3])}get xwxx(){return new this._Vec4(this[0],this[3],this[0],this[0])}get xwxy(){return new this._Vec4(this[0],this[3],this[0],this[1])}get xwxz(){return new this._Vec4(this[0],this[3],this[0],this[2])}get xwxw(){return new this._Vec4(this[0],this[3],this[0],this[3])}get xwyx(){return new this._Vec4(this[0],this[3],this[1],this[0])}get xwyy(){return new this._Vec4(this[0],this[3],this[1],this[1])}get xwyz(){return new this._Vec4(this[0],this[3],this[1],this[2])}get xwyw(){return new this._Vec4(this[0],this[3],this[1],this[3])}get xwzx(){return new this._Vec4(this[0],this[3],this[2],this[0])}get xwzy(){return new this._Vec4(this[0],this[3],this[2],this[1])}get xwzz(){return new this._Vec4(this[0],this[3],this[2],this[2])}get xwzw(){return new this._Vec4(this[0],this[3],this[2],this[3])}get xwwx(){return new this._Vec4(this[0],this[3],this[3],this[0])}get xwwy(){return new this._Vec4(this[0],this[3],this[3],this[1])}get xwwz(){return new this._Vec4(this[0],this[3],this[3],this[2])}get xwww(){return new this._Vec4(this[0],this[3],this[3],this[3])}get yxxx(){return new this._Vec4(this[1],this[0],this[0],this[0])}get yxxy(){return new this._Vec4(this[1],this[0],this[0],this[1])}get yxxz(){return new this._Vec4(this[1],this[0],this[0],this[2])}get yxxw(){return new this._Vec4(this[1],this[0],this[0],this[3])}get yxyx(){return new this._Vec4(this[1],this[0],this[1],this[0])}get yxyy(){return new this._Vec4(this[1],this[0],this[1],this[1])}get yxyz(){return new this._Vec4(this[1],this[0],this[1],this[2])}get yxyw(){return new this._Vec4(this[1],this[0],this[1],this[3])}get yxzx(){return new this._Vec4(this[1],this[0],this[2],this[0])}get yxzy(){return new this._Vec4(this[1],this[0],this[2],this[1])}get yxzz(){return new this._Vec4(this[1],this[0],this[2],this[2])}get yxzw(){return new this._Vec4(this[1],this[0],this[2],this[3])}get yxwx(){return new this._Vec4(this[1],this[0],this[3],this[0])}get yxwy(){return new this._Vec4(this[1],this[0],this[3],this[1])}get yxwz(){return new this._Vec4(this[1],this[0],this[3],this[2])}get yxww(){return new this._Vec4(this[1],this[0],this[3],this[3])}get yyxx(){return new this._Vec4(this[1],this[1],this[0],this[0])}get yyxy(){return new this._Vec4(this[1],this[1],this[0],this[1])}get yyxz(){return new this._Vec4(this[1],this[1],this[0],this[2])}get yyxw(){return new this._Vec4(this[1],this[1],this[0],this[3])}get yyyx(){return new this._Vec4(this[1],this[1],this[1],this[0])}get yyyy(){return new this._Vec4(this[1],this[1],this[1],this[1])}get yyyz(){return new this._Vec4(this[1],this[1],this[1],this[2])}get yyyw(){return new this._Vec4(this[1],this[1],this[1],this[3])}get yyzx(){return new this._Vec4(this[1],this[1],this[2],this[0])}get yyzy(){return new this._Vec4(this[1],this[1],this[2],this[1])}get yyzz(){return new this._Vec4(this[1],this[1],this[2],this[2])}get yyzw(){return new this._Vec4(this[1],this[1],this[2],this[3])}get yywx(){return new this._Vec4(this[1],this[1],this[3],this[0])}get yywy(){return new this._Vec4(this[1],this[1],this[3],this[1])}get yywz(){return new this._Vec4(this[1],this[1],this[3],this[2])}get yyww(){return new this._Vec4(this[1],this[1],this[3],this[3])}get yzxx(){return new this._Vec4(this[1],this[2],this[0],this[0])}get yzxy(){return new this._Vec4(this[1],this[2],this[0],this[1])}get yzxz(){return new this._Vec4(this[1],this[2],this[0],this[2])}get yzxw(){return new this._Vec4(this[1],this[2],this[0],this[3])}get yzyx(){return new this._Vec4(this[1],this[2],this[1],this[0])}get yzyy(){return new this._Vec4(this[1],this[2],this[1],this[1])}get yzyz(){return new this._Vec4(this[1],this[2],this[1],this[2])}get yzyw(){return new this._Vec4(this[1],this[2],this[1],this[3])}get yzzx(){return new this._Vec4(this[1],this[2],this[2],this[0])}get yzzy(){return new this._Vec4(this[1],this[2],this[2],this[1])}get yzzz(){return new this._Vec4(this[1],this[2],this[2],this[2])}get yzzw(){return new this._Vec4(this[1],this[2],this[2],this[3])}get yzwx(){return new this._Vec4(this[1],this[2],this[3],this[0])}get yzwy(){return new this._Vec4(this[1],this[2],this[3],this[1])}get yzwz(){return new this._Vec4(this[1],this[2],this[3],this[2])}get yzww(){return new this._Vec4(this[1],this[2],this[3],this[3])}get ywxx(){return new this._Vec4(this[1],this[3],this[0],this[0])}get ywxy(){return new this._Vec4(this[1],this[3],this[0],this[1])}get ywxz(){return new this._Vec4(this[1],this[3],this[0],this[2])}get ywxw(){return new this._Vec4(this[1],this[3],this[0],this[3])}get ywyx(){return new this._Vec4(this[1],this[3],this[1],this[0])}get ywyy(){return new this._Vec4(this[1],this[3],this[1],this[1])}get ywyz(){return new this._Vec4(this[1],this[3],this[1],this[2])}get ywyw(){return new this._Vec4(this[1],this[3],this[1],this[3])}get ywzx(){return new this._Vec4(this[1],this[3],this[2],this[0])}get ywzy(){return new this._Vec4(this[1],this[3],this[2],this[1])}get ywzz(){return new this._Vec4(this[1],this[3],this[2],this[2])}get ywzw(){return new this._Vec4(this[1],this[3],this[2],this[3])}get ywwx(){return new this._Vec4(this[1],this[3],this[3],this[0])}get ywwy(){return new this._Vec4(this[1],this[3],this[3],this[1])}get ywwz(){return new this._Vec4(this[1],this[3],this[3],this[2])}get ywww(){return new this._Vec4(this[1],this[3],this[3],this[3])}get zxxx(){return new this._Vec4(this[2],this[0],this[0],this[0])}get zxxy(){return new this._Vec4(this[2],this[0],this[0],this[1])}get zxxz(){return new this._Vec4(this[2],this[0],this[0],this[2])}get zxxw(){return new this._Vec4(this[2],this[0],this[0],this[3])}get zxyx(){return new this._Vec4(this[2],this[0],this[1],this[0])}get zxyy(){return new this._Vec4(this[2],this[0],this[1],this[1])}get zxyz(){return new this._Vec4(this[2],this[0],this[1],this[2])}get zxyw(){return new this._Vec4(this[2],this[0],this[1],this[3])}get zxzx(){return new this._Vec4(this[2],this[0],this[2],this[0])}get zxzy(){return new this._Vec4(this[2],this[0],this[2],this[1])}get zxzz(){return new this._Vec4(this[2],this[0],this[2],this[2])}get zxzw(){return new this._Vec4(this[2],this[0],this[2],this[3])}get zxwx(){return new this._Vec4(this[2],this[0],this[3],this[0])}get zxwy(){return new this._Vec4(this[2],this[0],this[3],this[1])}get zxwz(){return new this._Vec4(this[2],this[0],this[3],this[2])}get zxww(){return new this._Vec4(this[2],this[0],this[3],this[3])}get zyxx(){return new this._Vec4(this[2],this[1],this[0],this[0])}get zyxy(){return new this._Vec4(this[2],this[1],this[0],this[1])}get zyxz(){return new this._Vec4(this[2],this[1],this[0],this[2])}get zyxw(){return new this._Vec4(this[2],this[1],this[0],this[3])}get zyyx(){return new this._Vec4(this[2],this[1],this[1],this[0])}get zyyy(){return new this._Vec4(this[2],this[1],this[1],this[1])}get zyyz(){return new this._Vec4(this[2],this[1],this[1],this[2])}get zyyw(){return new this._Vec4(this[2],this[1],this[1],this[3])}get zyzx(){return new this._Vec4(this[2],this[1],this[2],this[0])}get zyzy(){return new this._Vec4(this[2],this[1],this[2],this[1])}get zyzz(){return new this._Vec4(this[2],this[1],this[2],this[2])}get zyzw(){return new this._Vec4(this[2],this[1],this[2],this[3])}get zywx(){return new this._Vec4(this[2],this[1],this[3],this[0])}get zywy(){return new this._Vec4(this[2],this[1],this[3],this[1])}get zywz(){return new this._Vec4(this[2],this[1],this[3],this[2])}get zyww(){return new this._Vec4(this[2],this[1],this[3],this[3])}get zzxx(){return new this._Vec4(this[2],this[2],this[0],this[0])}get zzxy(){return new this._Vec4(this[2],this[2],this[0],this[1])}get zzxz(){return new this._Vec4(this[2],this[2],this[0],this[2])}get zzxw(){return new this._Vec4(this[2],this[2],this[0],this[3])}get zzyx(){return new this._Vec4(this[2],this[2],this[1],this[0])}get zzyy(){return new this._Vec4(this[2],this[2],this[1],this[1])}get zzyz(){return new this._Vec4(this[2],this[2],this[1],this[2])}get zzyw(){return new this._Vec4(this[2],this[2],this[1],this[3])}get zzzx(){return new this._Vec4(this[2],this[2],this[2],this[0])}get zzzy(){return new this._Vec4(this[2],this[2],this[2],this[1])}get zzzz(){return new this._Vec4(this[2],this[2],this[2],this[2])}get zzzw(){return new this._Vec4(this[2],this[2],this[2],this[3])}get zzwx(){return new this._Vec4(this[2],this[2],this[3],this[0])}get zzwy(){return new this._Vec4(this[2],this[2],this[3],this[1])}get zzwz(){return new this._Vec4(this[2],this[2],this[3],this[2])}get zzww(){return new this._Vec4(this[2],this[2],this[3],this[3])}get zwxx(){return new this._Vec4(this[2],this[3],this[0],this[0])}get zwxy(){return new this._Vec4(this[2],this[3],this[0],this[1])}get zwxz(){return new this._Vec4(this[2],this[3],this[0],this[2])}get zwxw(){return new this._Vec4(this[2],this[3],this[0],this[3])}get zwyx(){return new this._Vec4(this[2],this[3],this[1],this[0])}get zwyy(){return new this._Vec4(this[2],this[3],this[1],this[1])}get zwyz(){return new this._Vec4(this[2],this[3],this[1],this[2])}get zwyw(){return new this._Vec4(this[2],this[3],this[1],this[3])}get zwzx(){return new this._Vec4(this[2],this[3],this[2],this[0])}get zwzy(){return new this._Vec4(this[2],this[3],this[2],this[1])}get zwzz(){return new this._Vec4(this[2],this[3],this[2],this[2])}get zwzw(){return new this._Vec4(this[2],this[3],this[2],this[3])}get zwwx(){return new this._Vec4(this[2],this[3],this[3],this[0])}get zwwy(){return new this._Vec4(this[2],this[3],this[3],this[1])}get zwwz(){return new this._Vec4(this[2],this[3],this[3],this[2])}get zwww(){return new this._Vec4(this[2],this[3],this[3],this[3])}get wxxx(){return new this._Vec4(this[3],this[0],this[0],this[0])}get wxxy(){return new this._Vec4(this[3],this[0],this[0],this[1])}get wxxz(){return new this._Vec4(this[3],this[0],this[0],this[2])}get wxxw(){return new this._Vec4(this[3],this[0],this[0],this[3])}get wxyx(){return new this._Vec4(this[3],this[0],this[1],this[0])}get wxyy(){return new this._Vec4(this[3],this[0],this[1],this[1])}get wxyz(){return new this._Vec4(this[3],this[0],this[1],this[2])}get wxyw(){return new this._Vec4(this[3],this[0],this[1],this[3])}get wxzx(){return new this._Vec4(this[3],this[0],this[2],this[0])}get wxzy(){return new this._Vec4(this[3],this[0],this[2],this[1])}get wxzz(){return new this._Vec4(this[3],this[0],this[2],this[2])}get wxzw(){return new this._Vec4(this[3],this[0],this[2],this[3])}get wxwx(){return new this._Vec4(this[3],this[0],this[3],this[0])}get wxwy(){return new this._Vec4(this[3],this[0],this[3],this[1])}get wxwz(){return new this._Vec4(this[3],this[0],this[3],this[2])}get wxww(){return new this._Vec4(this[3],this[0],this[3],this[3])}get wyxx(){return new this._Vec4(this[3],this[1],this[0],this[0])}get wyxy(){return new this._Vec4(this[3],this[1],this[0],this[1])}get wyxz(){return new this._Vec4(this[3],this[1],this[0],this[2])}get wyxw(){return new this._Vec4(this[3],this[1],this[0],this[3])}get wyyx(){return new this._Vec4(this[3],this[1],this[1],this[0])}get wyyy(){return new this._Vec4(this[3],this[1],this[1],this[1])}get wyyz(){return new this._Vec4(this[3],this[1],this[1],this[2])}get wyyw(){return new this._Vec4(this[3],this[1],this[1],this[3])}get wyzx(){return new this._Vec4(this[3],this[1],this[2],this[0])}get wyzy(){return new this._Vec4(this[3],this[1],this[2],this[1])}get wyzz(){return new this._Vec4(this[3],this[1],this[2],this[2])}get wyzw(){return new this._Vec4(this[3],this[1],this[2],this[3])}get wywx(){return new this._Vec4(this[3],this[1],this[3],this[0])}get wywy(){return new this._Vec4(this[3],this[1],this[3],this[1])}get wywz(){return new this._Vec4(this[3],this[1],this[3],this[2])}get wyww(){return new this._Vec4(this[3],this[1],this[3],this[3])}get wzxx(){return new this._Vec4(this[3],this[2],this[0],this[0])}get wzxy(){return new this._Vec4(this[3],this[2],this[0],this[1])}get wzxz(){return new this._Vec4(this[3],this[2],this[0],this[2])}get wzxw(){return new this._Vec4(this[3],this[2],this[0],this[3])}get wzyx(){return new this._Vec4(this[3],this[2],this[1],this[0])}get wzyy(){return new this._Vec4(this[3],this[2],this[1],this[1])}get wzyz(){return new this._Vec4(this[3],this[2],this[1],this[2])}get wzyw(){return new this._Vec4(this[3],this[2],this[1],this[3])}get wzzx(){return new this._Vec4(this[3],this[2],this[2],this[0])}get wzzy(){return new this._Vec4(this[3],this[2],this[2],this[1])}get wzzz(){return new this._Vec4(this[3],this[2],this[2],this[2])}get wzzw(){return new this._Vec4(this[3],this[2],this[2],this[3])}get wzwx(){return new this._Vec4(this[3],this[2],this[3],this[0])}get wzwy(){return new this._Vec4(this[3],this[2],this[3],this[1])}get wzwz(){return new this._Vec4(this[3],this[2],this[3],this[2])}get wzww(){return new this._Vec4(this[3],this[2],this[3],this[3])}get wwxx(){return new this._Vec4(this[3],this[3],this[0],this[0])}get wwxy(){return new this._Vec4(this[3],this[3],this[0],this[1])}get wwxz(){return new this._Vec4(this[3],this[3],this[0],this[2])}get wwxw(){return new this._Vec4(this[3],this[3],this[0],this[3])}get wwyx(){return new this._Vec4(this[3],this[3],this[1],this[0])}get wwyy(){return new this._Vec4(this[3],this[3],this[1],this[1])}get wwyz(){return new this._Vec4(this[3],this[3],this[1],this[2])}get wwyw(){return new this._Vec4(this[3],this[3],this[1],this[3])}get wwzx(){return new this._Vec4(this[3],this[3],this[2],this[0])}get wwzy(){return new this._Vec4(this[3],this[3],this[2],this[1])}get wwzz(){return new this._Vec4(this[3],this[3],this[2],this[2])}get wwzw(){return new this._Vec4(this[3],this[3],this[2],this[3])}get wwwx(){return new this._Vec4(this[3],this[3],this[3],this[0])}get wwwy(){return new this._Vec4(this[3],this[3],this[3],this[1])}get wwwz(){return new this._Vec4(this[3],this[3],this[3],this[2])}get wwww(){return new this._Vec4(this[3],this[3],this[3],this[3])}},N=class extends ce{e0;e1;constructor(t,n){super(2),this.e0=this.castElement()(t),this.e1=this.castElement()(n??t)}get 0(){return this.e0}get 1(){return this.e1}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}set x(t){this[0]=this.castElement()(t)}set y(t){this[1]=this.castElement()(t)}},E=class extends ce{e0;e1;e2;constructor(t,n,r){super(3),this.e0=this.castElement()(t),this.e1=this.castElement()(n??t),this.e2=this.castElement()(r??t)}get 0(){return this.e0}get 1(){return this.e1}get 2(){return this.e2}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}set 2(t){this.e2=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(t){this[0]=this.castElement()(t)}set y(t){this[1]=this.castElement()(t)}set z(t){this[2]=this.castElement()(t)}},U=class extends ce{e0;e1;e2;e3;constructor(t,n,r,i){super(4),this.e0=this.castElement()(t),this.e1=this.castElement()(n??t),this.e2=this.castElement()(r??t),this.e3=this.castElement()(i??t)}get 0(){return this.e0}get 1(){return this.e1}get 2(){return this.e2}get 3(){return this.e3}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}set 2(t){this.e2=this.castElement()(t)}set 3(t){this.e3=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}get w(){return this[3]}set x(t){this[0]=t}set y(t){this[1]=t}set z(t){this[2]=t}set w(t){this[3]=t}},j=class e extends N{get[o](){return{elementSchema:x}}get kind(){return"vec2f"}get _Vec2(){return e}get _Vec3(){return H}get _Vec4(){return Q}},L=class e extends N{get[o](){return{elementSchema:_}}get kind(){return"vec2h"}get _Vec2(){return e}get _Vec3(){return q}get _Vec4(){return ee}},G=class e extends N{get[o](){return{elementSchema:f}}get kind(){return"vec2i"}get _Vec2(){return e}get _Vec3(){return J}get _Vec4(){return te}},K=class e extends N{get[o](){return{elementSchema:T}}get kind(){return"vec2u"}get _Vec2(){return e}get _Vec3(){return X}get _Vec4(){return ne}},Y=class e extends N{get[o](){return{elementSchema:V}}get kind(){return"vec2<bool>"}get _Vec2(){return e}get _Vec3(){return Z}get _Vec4(){return re}},H=class e extends E{get[o](){return{elementSchema:x}}get kind(){return"vec3f"}get _Vec2(){return j}get _Vec3(){return e}get _Vec4(){return Q}},q=class e extends E{get[o](){return{elementSchema:_}}get kind(){return"vec3h"}get _Vec2(){return L}get _Vec3(){return e}get _Vec4(){return ee}},J=class e extends E{get[o](){return{elementSchema:f}}get kind(){return"vec3i"}get _Vec2(){return G}get _Vec3(){return e}get _Vec4(){return te}},X=class e extends E{get[o](){return{elementSchema:T}}get kind(){return"vec3u"}get _Vec2(){return K}get _Vec3(){return e}get _Vec4(){return ne}},Z=class e extends E{get[o](){return{elementSchema:V}}get kind(){return"vec3<bool>"}get _Vec2(){return Y}get _Vec3(){return e}get _Vec4(){return re}},Q=class e extends U{get[o](){return{elementSchema:x}}get kind(){return"vec4f"}get _Vec2(){return j}get _Vec3(){return H}get _Vec4(){return e}},ee=class e extends U{get[o](){return{elementSchema:_}}get kind(){return"vec4h"}get _Vec2(){return L}get _Vec3(){return q}get _Vec4(){return e}},te=class e extends U{get[o](){return{elementSchema:f}}get kind(){return"vec4i"}get _Vec2(){return G}get _Vec3(){return J}get _Vec4(){return e}},ne=class e extends U{get[o](){return{elementSchema:T}}get kind(){return"vec4u"}get _Vec2(){return K}get _Vec3(){return X}get _Vec4(){return e}},re=class e extends U{get[o](){return{elementSchema:V}}get kind(){return"vec4<bool>"}get _Vec2(){return Y}get _Vec3(){return Z}get _Vec4(){return e}};var F=w(j,x),nn=w(L,_),pe=w(G,f),le=w(K,T),rn=w(Y,V),ke=w(H,x),sn=w(q,_),Fe=w(J,f),Pe=w(X,T),on=w(Z,V),v=w(Q,x),an=w(ee,_),he=w(te,f),xe=w(ne,T),un=w(re,V),Ri={vec2f:F,vec2h:nn,vec2i:pe,vec2u:le,"vec2<bool>":rn,vec3f:ke,vec3h:sn,vec3i:Fe,vec3u:Pe,"vec3<bool>":on,vec4f:v,vec4h:an,vec4i:he,vec4u:xe,"vec4<bool>":un};function w(e,t){let{kind:n,length:r}=new e,s=k({name:n,signature:(...l)=>({argTypes:l.map(d=>se(d)?d:t),returnType:c}),normalImpl:(...l)=>{let d=new Array(l.length),h=0;for(let P of l)if(typeof P=="number"||typeof P=="boolean")d[h++]=P;else for(let C=0;C<P.length;++C)d[h++]=P[C];if(d.length<=1||d.length===r)return new e(...d);throw new Error(`'${n}' constructor called with invalid number of arguments.`)},ignoreImplicitCastWarning:!0,codegenImpl:(...l)=>l.length===1&&l[0]?.dataType===c?p`${l[0]}`:p`${n}(${l})`}),c=Object.assign(s,{type:n,primitive:t,[Ne]:void 0});return e.prototype.schema=c,c}function yn(e){return e>=2**63||e<-(2**63)?y(e,De,"constant"):Number.isInteger(e)?(Number.isSafeInteger(e)||console.warn(`The integer ${e} exceeds the safe integer range and may have lost precision.`),y(e,gt,"constant")):y(e,De,"constant")}function cn(e){return e.type==="abstractFloat"?x:e.type==="abstractInt"?f:e}function Wi(e){return e.map(t=>y(t.value,cn(t.dataType),t.origin))}function vt(e){if(ue(e))return e;if(ht(e))throw new Error("Cannot use refs (d.ref(...)) from the outer scope.");let t=Ae(e);return t||(ie(e)||me(e)?y(e,We(e),"constant"):typeof e=="string"||typeof e=="function"||typeof e=="object"||typeof e=="symbol"||typeof e>"u"||e===null?y(e,ae,"constant"):typeof e=="number"?yn(e):typeof e=="boolean"?y(e,V,"constant"):y(e,ae,"constant"))}function Ji(e){let t=(...r)=>{let i=r;if(!i.every(s=>ye(s)))throw new A(`Called comptime function with runtime-known values: ${i.filter(s=>!ye(s)).map(s=>`'${s.value}'`).join(", ")}`);return vt(e(...i.map(s=>s.value)))},n=((...r)=>{let i=O();if(i?.mode.type==="codegen"){i.pushMode(new $);try{return t(...r)}finally{i.popMode("normal")}}return e(...r)});return n.toString=()=>"comptime",n[B]=e,n.$name=r=>(g(e,r),n),Object.defineProperty(n,o,{value:{jsImpl:e,gpuImpl:t,argConversionHint:"keep"}}),n}var a=class{constructor(t){this.type=t}[o]=!0},Se={uint8:T,uint8x2:le,uint8x4:xe,sint8:f,sint8x2:pe,sint8x4:he,unorm8:x,unorm8x2:F,unorm8x4:v,snorm8:x,snorm8x2:F,snorm8x4:v,uint16:T,uint16x2:le,uint16x4:xe,sint16:f,sint16x2:pe,sint16x4:he,unorm16:x,unorm16x2:F,unorm16x4:v,snorm16:x,snorm16x2:F,snorm16x4:v,float16:x,float16x2:F,float16x4:v,float32:x,float32x2:F,float32x3:ke,float32x4:v,uint32:T,uint32x2:le,uint32x3:Pe,uint32x4:xe,sint32:f,sint32x2:pe,sint32x3:Fe,sint32x4:he,"unorm10-10-10-2":v,"unorm8x4-bgra":v},pn=new Set(Object.keys(Se)),ns=new a("uint8"),rs=new a("uint8x2"),is=new a("uint8x4"),ss=new a("sint8"),os=new a("sint8x2"),as=new a("sint8x4"),us=new a("unorm8"),ys=new a("unorm8x2"),cs=new a("unorm8x4"),ps=new a("snorm8"),ls=new a("snorm8x2"),hs=new a("snorm8x4"),xs=new a("uint16"),ds=new a("uint16x2"),ms=new a("uint16x4"),fs=new a("sint16"),ws=new a("sint16x2"),Ts=new a("sint16x4"),gs=new a("unorm16"),Vs=new a("unorm16x2"),vs=new a("unorm16x4"),bs=new a("snorm16"),zs=new a("snorm16x2"),Ss=new a("snorm16x4"),_s=new a("float16"),Is=new a("float16x2"),As=new a("float16x4"),$s=new a("float32"),Ds=new a("float32x2"),ks=new a("float32x3"),Fs=new a("float32x4"),Ps=new a("uint32"),Rs=new a("uint32x2"),Ns=new a("uint32x3"),Es=new a("uint32x4"),Us=new a("sint32"),Cs=new a("sint32x2"),Bs=new a("sint32x3"),Ms=new a("sint32x4"),Os=new a("unorm10-10-10-2"),Ws=new a("unorm8x4-bgra");function js(e){return u(e)&&pn.has(e?.type)}function bt(e,t){let n=e?.type,r=n in Se?Se[n]:e;return typeof r!="function"?t:t===void 0?r():r(t)}function Js(e){return zt(e,!1)}function Xs(e){return zt(e,!0)}function zt(e,t){let n=r=>Object.fromEntries(Object.entries(e).map(([i,s])=>[i,bt(s,r?.[i])]));return Object.setPrototypeOf(n,ln),n.propTypes=e,Object.defineProperty(n,o,{value:{isAbstruct:t}}),n}var ln={type:"struct",$name(e){return g(this,e),this},toString(){return`struct:${z(this)??"<unnamed>"}`}};function eo(e){let t=String(e);if(t!=="[object Object]")return t;try{return JSON.stringify(e)}catch(n){return console.error("Error parsing JSON:",n),"<invalid json>"}}function St(e){return ie(e)||me(e)?e.toString():Array.isArray(e)?`[${e.map(St).join(", ")}]`:e&&typeof e=="object"?`{ ${Object.entries(e).map(([t,n])=>`${t}: ${St(n)}`).join(", ")} }`:String(e)}export{o as a,dn as b,B as c,Re as d,de as e,R as f,Ne as g,u as h,Cn as i,z as j,g as k,Et as l,Le as m,Ge as n,Ke as o,Mn as p,Sn as q,ie as r,At as s,$t as t,Dt as u,se as v,me as w,kt as x,Ft as y,_e as z,_n as A,fe as B,In as C,An as D,Ee as E,$n as F,Ue as G,Ce as H,Be as I,Dn as J,kn as K,Fn as L,Pn as M,Me as N,Rn as O,Oe as P,I as Q,Kn as R,Bt as S,Yn as T,Hn as U,qn as V,Jn as W,Xn as X,Zn as Y,Qn as Z,ae as _,Ye as $,He as aa,qe as ba,Mt as ca,lr as da,ue as ea,hr as fa,y as ga,we as ha,Je as ia,Xe as ja,Ze as ka,Qe as la,et as ma,tt as na,nt as oa,rt as pa,it as qa,A as ra,st as sa,ot as ta,at as ua,ar as va,$ as wa,pt as xa,lt as ya,Ot as za,Ae as Aa,ye as Ba,Dr as Ca,kr as Da,Nr as Ea,Er as Fa,Ur as Ga,O as Ha,Wt as Ia,Cr as Ja,Ve as Ka,p as La,fr as Ma,wr as Na,Tr as Oa,gr as Pa,Vr as Qa,vr as Ra,yt as Sa,br as Ta,Zr as Ua,ht as Va,W as Wa,xt as Xa,dt as Ya,ft as Za,yi as _a,wt as $a,Tt as ab,ci as bb,ze as cb,k as db,gt as eb,De as fb,V as gb,T as hb,vi as ib,f as jb,x as kb,_ as lb,ce as mb,F as nb,nn as ob,pe as pb,le as qb,rn as rb,ke as sb,sn as tb,Fe as ub,Pe as vb,on as wb,v as xb,an as yb,he as zb,xe as Ab,un as Bb,Ri as Cb,yn as Db,cn as Eb,Wi as Fb,vt as Gb,Ji as Hb,eo as Ib,St as Jb,Se as Kb,pn as Lb,ns as Mb,rs as Nb,is as Ob,ss as Pb,os as Qb,as as Rb,us as Sb,ys as Tb,cs as Ub,ps as Vb,ls as Wb,hs as Xb,xs as Yb,ds as Zb,ms as _b,fs as $b,ws as ac,Ts as bc,gs as cc,Vs as dc,vs as ec,bs as fc,zs as gc,Ss as hc,_s as ic,Is as jc,As as kc,$s as lc,Ds as mc,ks as nc,Fs as oc,Ps as pc,Rs as qc,Ns as rc,Es as sc,Us as tc,Cs as uc,Bs as vc,Ms as wc,Os as xc,Ws as yc,js as zc,bt as Ac,Js as Bc,Xs as Cc};
//# sourceMappingURL=chunk-SHSILTWI.js.map

Sorry, the diff of this file is too big to display

import { dO as DualFn, e8 as TgpuNamable, e9 as $getNameForward } from './tgpuConstant-BOn7U_lv.js';
type TgpuComptime<T extends (...args: never[]) => unknown> = DualFn<T> & TgpuNamable & {
[$getNameForward]: unknown;
};
/**
* Creates a version of `func` that can called safely in a TypeGPU function to
* precompute and inject a value into the final shader code.
*
* Note how the function passed into `comptime` doesn't have to be marked with
* 'use gpu'. That's because the function doesn't execute on the GPU, it gets
* executed before the shader code gets sent to the GPU.
*
* @example
* ```ts
* const injectRand01 = tgpu['~unstable']
* .comptime(() => Math.random());
*
* const getColor = (diffuse: d.v3f) => {
* 'use gpu';
* const albedo = hsvToRgb(injectRand01(), 1, 0.5);
* return albedo.mul(diffuse);
* };
* ```
*/
declare function comptime<T extends (...args: never[]) => unknown>(func: T): TgpuComptime<T>;
export { type TgpuComptime as T, comptime as c };
import { bE as Mat2x2f, bF as Mat3x3f, bG as Mat4x4f, bB as m2x2f, bC as m3x3f, bD as m4x4f, dO as DualFn, bN as v3f } from './tgpuConstant-BOn7U_lv.js';
import { T as TgpuComptime } from './comptime-DKpw1IVu.js';
/**
* Returns a 2-by-2 identity matrix.
* @returns {m2x2f} The result matrix.
*/
declare const identity2: TgpuComptime<() => m2x2f>;
/**
* Returns a 3-by-3 identity matrix.
* @returns {m3x3f} The result matrix.
*/
declare const identity3: TgpuComptime<() => m3x3f>;
/**
* Returns a 4-by-4 identity matrix.
* @returns {m4x4f} The result matrix.
*/
declare const identity4: TgpuComptime<() => m4x4f>;
/**
* Creates a 4-by-4 matrix which translates by the given vector v.
* @param {v3f} vector - The vector by which to translate.
* @returns {m4x4f} The translation matrix.
*/
declare const translation4: DualFn<(vector: v3f) => m4x4f>;
/**
* Creates a 4-by-4 matrix which scales in each dimension by an amount given by the corresponding entry in the given vector.
* @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.
* @returns {m4x4f} The scaling matrix.
*/
declare const scaling4: DualFn<(vector: v3f) => m4x4f>;
/**
* Creates a 4-by-4 matrix which rotates around the x-axis by the given angle.
* @param {number} angle - The angle by which to rotate (in radians).
* @returns {m4x4f} The rotation matrix.
*/
declare const rotationX4: DualFn<(a: number) => m4x4f>;
/**
* Creates a 4-by-4 matrix which rotates around the y-axis by the given angle.
* @param {number} angle - The angle by which to rotate (in radians).
* @returns {m4x4f} The rotation matrix.
*/
declare const rotationY4: DualFn<(a: number) => m4x4f>;
/**
* Creates a 4-by-4 matrix which rotates around the z-axis by the given angle.
* @param {number} angle - The angle by which to rotate (in radians).
* @returns {m4x4f} The rotation matrix.
*/
declare const rotationZ4: DualFn<(a: number) => m4x4f>;
/**
* Schema representing mat2x2f - a matrix with 2 rows and 2 columns, with elements of type f32.
* Also a constructor function for this matrix type.
*
* @example
* const zero2x2 = mat2x2f(); // filled with zeros
*
* @example
* const mat = mat2x2f(0, 1, 2, 3);
* mat.columns[0] // vec2f(0, 1)
* mat.columns[1] // vec2f(2, 3)
*
* @example
* const mat = mat2x2f(
* vec2f(0, 1), // column 0
* vec2f(1, 2), // column 1
* );
*
* @example
* const buffer = root.createBuffer(d.mat2x2f, d.mat2x2f(0, 1, 2, 3)); // buffer holding a d.mat2x2f value, with an initial value of ((0, 1), (2, 3))
*/
declare const mat2x2f: Mat2x2f;
/**
* Schema representing mat3x3f - a matrix with 3 rows and 3 columns, with elements of type f32.
* Also a constructor function for this matrix type.
*
* @example
* const zero3x3 = mat3x3f(); // filled with zeros
*
* @example
* const mat = mat3x3f(0, 1, 2, 3, 4, 5, 6, 7, 8);
* mat.columns[0] // vec3f(0, 1, 2)
* mat.columns[1] // vec3f(3, 4, 5)
* mat.columns[2] // vec3f(6, 7, 8)
*
* @example
* const mat = mat3x3f(
* vec3f(0, 1, 2), // column 0
* vec3f(2, 3, 4), // column 1
* vec3f(5, 6, 7), // column 2
* );
*
* @example
* const buffer = root.createBuffer(d.mat3x3f, d.mat3x3f()); // buffer holding a d.mat3x3f value, with an initial value of mat3x3f filled with zeros
*/
declare const mat3x3f: Mat3x3f;
/**
* Schema representing mat4x4f - a matrix with 4 rows and 4 columns, with elements of type f32.
* Also a constructor function for this matrix type.
*
* @example
* const zero4x4 = mat4x4f(); // filled with zeros
*
* @example
* const mat = mat4x4f(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
* mat.columns[0] // vec4f(0, 1, 2, 3)
* mat.columns[1] // vec4f(4, 5, 6, 7)
* mat.columns[2] // vec4f(8, 9, 10, 11)
* mat.columns[3] // vec4f(12, 13, 14, 15)
*
* @example
* const mat = mat4x4f(
* vec4f(0, 1, 2, 3), // column 0
* vec4f(4, 5, 6, 7), // column 1
* vec4f(8, 9, 10, 11), // column 2
* vec4f(12, 13, 14, 15), // column 3
* );
*
* @example
* const buffer = root.createBuffer(d.mat4x4f, d.mat4x4f()); // buffer holding a d.mat4x4f value, with an initial value of mat4x4f filled with zeros
*/
declare const mat4x4f: Mat4x4f;
declare function matToArray(mat: m2x2f | m3x3f | m4x4f): number[];
export { mat3x3f as a, mat4x4f as b, matToArray as c, identity3 as d, identity4 as e, rotationY4 as f, rotationZ4 as g, identity2 as i, mat2x2f as m, rotationX4 as r, scaling4 as s, translation4 as t };

Sorry, the diff of this file is too big to display

+1
-1

@@ -1,2 +0,2 @@

import { aH as TgpuVertexFn, aP as Vec2f } from '../tgpuConstant-BTQFNlQH.js';
import { aL as TgpuVertexFn, aT as Vec2f } from '../tgpuConstant-BOn7U_lv.js';
import 'tinyest';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

import{h as n}from"../chunk-CGQB3SER.js";import{Xa as r,uc as e}from"../chunk-CRZWTZM2.js";var o=n({in:{vertexIndex:e.vertexIndex},out:{pos:e.position,uv:r}})`{
import{h as n}from"../chunk-D5UYO3OX.js";import{o as e}from"../chunk-MBB2XFH6.js";import{nb as r}from"../chunk-SHSILTWI.js";var o=n({in:{vertexIndex:e.vertexIndex},out:{pos:e.position,uv:r}})`{
const pos = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));

@@ -3,0 +3,0 @@ const uv = array<vec2f, 3>(vec2f(0, 1), vec2f(2, 1), vec2f(0, -1));

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/common/fullScreenTriangle.ts"],"sourcesContent":["import { builtin } from '../builtin.ts';\nimport { vertexFn } from '../core/function/tgpuVertexFn.ts';\nimport { vec2f } from '../data/vector.ts';\n\n/**\n * A vertex function that defines a single full-screen triangle out\n * of three points.\n *\n * @example\n * ```ts\n * import { fullScreenTriangle } from 'typegpu/common';\n *\n * const pipeline = root['~unstable']\n * .withVertex(fullScreenTriangle)\n * .withFragment(yourFragmentShader)\n * .createPipeline();\n *\n * pipeline.draw(3);\n * ```\n */\nexport const fullScreenTriangle = vertexFn({\n in: { vertexIndex: builtin.vertexIndex },\n out: { pos: builtin.position, uv: vec2f },\n})`{\n const pos = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n const uv = array<vec2f, 3>(vec2f(0, 1), vec2f(2, 1), vec2f(0, -1));\n\n return Out(vec4f(pos[in.vertexIndex], 0, 1), uv[in.vertexIndex]);\n}`;\n"],"mappings":"2FAoBO,IAAMA,EAAqBC,EAAS,CACzC,GAAI,CAAE,YAAaC,EAAQ,WAAY,EACvC,IAAK,CAAE,IAAKA,EAAQ,SAAU,GAAIC,CAAM,CAC1C,CAAC;AAAA;AAAA;AAAA;AAAA;","names":["fullScreenTriangle","vertexFn","builtin","vec2f"]}
{"version":3,"sources":["../../src/common/fullScreenTriangle.ts"],"sourcesContent":["import { builtin } from '../builtin.ts';\nimport { vertexFn } from '../core/function/tgpuVertexFn.ts';\nimport { vec2f } from '../data/vector.ts';\n\n/**\n * A vertex function that defines a single full-screen triangle out\n * of three points.\n *\n * @example\n * ```ts\n * import { fullScreenTriangle } from 'typegpu/common';\n *\n * const pipeline = root['~unstable']\n * .withVertex(fullScreenTriangle)\n * .withFragment(yourFragmentShader)\n * .createPipeline();\n *\n * pipeline.draw(3);\n * ```\n */\nexport const fullScreenTriangle = vertexFn({\n in: { vertexIndex: builtin.vertexIndex },\n out: { pos: builtin.position, uv: vec2f },\n})`{\n const pos = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n const uv = array<vec2f, 3>(vec2f(0, 1), vec2f(2, 1), vec2f(0, -1));\n\n return Out(vec4f(pos[in.vertexIndex], 0, 1), uv[in.vertexIndex]);\n}`;\n"],"mappings":"4HAoBO,IAAMA,EAAqBC,EAAS,CACzC,GAAI,CAAE,YAAaC,EAAQ,WAAY,EACvC,IAAK,CAAE,IAAKA,EAAQ,SAAU,GAAIC,CAAM,CAC1C,CAAC;AAAA;AAAA;AAAA;AAAA;","names":["fullScreenTriangle","vertexFn","builtin","vec2f"]}

@@ -1,7 +0,127 @@

import { aQ as Vec2b, aP as Vec2f, aR as Vec2h, aS as Vec2i, aT as Vec2u, aU as Vec3b, aV as Vec3f, aW as Vec3h, aX as Vec3i, aY as Vec3u, aZ as Vec4b, a_ as Vec4f, a$ as Vec4h, b0 as Vec4i, b1 as Vec4u, b2 as Bool, b3 as F16, b4 as F32, b5 as I32, b6 as U16, b7 as U32, j as AnyWgslData, b8 as WgslStruct, b9 as DualFn, o as WgslArray, ba as StorableData, bb as Ptr, A as AnyData, D as Disarray, bc as BaseData, bd as Unstruct, be as Atomic } from '../tgpuConstant-BTQFNlQH.js';
export { br as Align, cx as AnyAttribute, cL as AnyBuiltin, bR as AnyLooseData, bs as AnyVecInstance, bt as AnyWgslStruct, bu as Builtin, cM as BuiltinClipDistances, cN as BuiltinFragDepth, cO as BuiltinFrontFacing, cP as BuiltinGlobalInvocationId, cQ as BuiltinInstanceIndex, cR as BuiltinLocalInvocationId, cS as BuiltinLocalInvocationIndex, cT as BuiltinNumWorkgroups, cU as BuiltinPosition, cV as BuiltinSampleIndex, cW as BuiltinSampleMask, cX as BuiltinVertexIndex, cY as BuiltinWorkgroupId, bv as Decorated, c$ as FormatToWGSLType, cy as HasCustomLocation, I as Infer, cZ as InferGPU, c_ as InferPartial, bw as Interpolate, cB as IsBuiltin, bx as Location, bS as LooseDecorated, bB as Mat2x2f, bC as Mat3x3f, bD as Mat4x4f, dJ as PackedData, bE as Size, d0 as TgpuVertexFormatData, bq as Void, cu as WgslComparisonSampler, c8 as WgslExternalTexture, cv as WgslSampler, c9 as WgslStorageTexture, ca as WgslStorageTexture1d, cb as WgslStorageTexture2d, cc as WgslStorageTexture2dArray, cd as WgslStorageTexture3d, ce as WgslStorageTextureProps, cf as WgslTexture, cg as WgslTexture1d, ch as WgslTexture2d, ci as WgslTexture2dArray, cj as WgslTexture3d, ck as WgslTextureCube, cl as WgslTextureCubeArray, cm as WgslTextureDepth2d, cn as WgslTextureDepth2dArray, co as WgslTextureDepthCube, cp as WgslTextureDepthCubeArray, cq as WgslTextureDepthMultisampled2d, cr as WgslTextureMultisampled2d, cw as align, cK as builtin, cs as comparisonSampler, ds as float16, dt as float16x2, du as float16x4, dv as float32, dw as float32x2, dx as float32x3, dy as float32x4, d1 as formatToWGSLType, cz as interpolate, cA as invariant, bf as isAlignAttrib, bg as isAtomic, cC as isBuiltin, bh as isBuiltinAttrib, cF as isData, bi as isDecorated, cG as isDisarray, bj as isInterpolateAttrib, bk as isLocationAttrib, cH as isLooseData, cI as isLooseDecorated, dK as isPackedData, bl as isPtr, bm as isSizeAttrib, cJ as isUnstruct, bn as isWgslArray, bo as isWgslData, bp as isWgslStruct, cD as location, by as m2x2f, bz as m3x3f, bA as m4x4f, d2 as packedFormats, ct as sampler, di as sint16, dj as sint16x2, dk as sint16x4, dD as sint32, dE as sint32x2, dF as sint32x3, dG as sint32x4, d6 as sint8, d7 as sint8x2, d8 as sint8x4, cE as size, dp as snorm16, dq as snorm16x2, dr as snorm16x4, dc as snorm8, dd as snorm8x2, de as snorm8x4, bT as texture1d, bU as texture2d, bV as texture2dArray, bW as texture3d, bX as textureCube, bY as textureCubeArray, bZ as textureDepth2d, b_ as textureDepth2dArray, b$ as textureDepthCube, c0 as textureDepthCubeArray, c1 as textureDepthMultisampled2d, c2 as textureExternal, c3 as textureMultisampled2d, c4 as textureStorage1d, c5 as textureStorage2d, c6 as textureStorage2dArray, c7 as textureStorage3d, df as uint16, dg as uint16x2, dh as uint16x4, dz as uint32, dA as uint32x2, dB as uint32x3, dC as uint32x4, d3 as uint8, d4 as uint8x2, d5 as uint8x4, dH as unorm10_10_10_2, dl as unorm16, dm as unorm16x2, dn as unorm16x4, d9 as unorm8, da as unorm8x2, db as unorm8x4, dI as unorm8x4_bgra, bF as v2b, bG as v2f, bH as v2i, bI as v2u, bJ as v3b, bK as v3f, bL as v3i, bM as v3u, bN as v4b, bO as v4f, bP as v4i, bQ as v4u } from '../tgpuConstant-BTQFNlQH.js';
export { m as mat2x2f, a as mat3x3f, b as mat4x4f, c as matToArray } from '../matrix-DIfOiRyz.js';
import { aU as Bool, aV as F16, aW as F32, aX as I32, aY as U16, aZ as U32, k as AnyWgslData, a_ as WgslStruct, r as WgslArray, a$ as StorableData, b0 as Ptr, b1 as Vec2b, aT as Vec2f, b2 as Vec2h, b3 as Vec2i, b4 as Vec2u, b5 as Vec3b, b6 as Vec3f, b7 as Vec3h, b8 as Vec3i, b9 as Vec3u, ba as Vec4b, bb as Vec4f, bc as Vec4h, bd as Vec4i, be as Vec4u, A as AnyData, D as Disarray, bf as BaseData, bg as Unstruct, bh as Atomic } from '../tgpuConstant-BOn7U_lv.js';
export { bu as Align, cB as AnyAttribute, cP as AnyBuiltin, bU as AnyLooseData, bv as AnyVecInstance, bw as AnyWgslStruct, bx as Builtin, cQ as BuiltinClipDistances, cR as BuiltinFragDepth, cS as BuiltinFrontFacing, cT as BuiltinGlobalInvocationId, cU as BuiltinInstanceIndex, cV as BuiltinLocalInvocationId, cW as BuiltinLocalInvocationIndex, cX as BuiltinNumWorkgroups, cY as BuiltinPosition, cZ as BuiltinSampleIndex, c_ as BuiltinSampleMask, c$ as BuiltinVertexIndex, d0 as BuiltinWorkgroupId, by as Decorated, d2 as FormatToWGSLType, cC as HasCustomLocation, o as Infer, I as InferGPU, d1 as InferPartial, bz as Interpolate, cF as IsBuiltin, bA as Location, bV as LooseDecorated, bE as Mat2x2f, bF as Mat3x3f, bG as Mat4x4f, dM as PackedData, bH as Size, d3 as TgpuVertexFormatData, bt as Void, cx as WgslComparisonSampler, cb as WgslExternalTexture, cy as WgslSampler, cc as WgslStorageTexture, cd as WgslStorageTexture1d, ce as WgslStorageTexture2d, cf as WgslStorageTexture2dArray, cg as WgslStorageTexture3d, ch as WgslStorageTextureProps, ci as WgslTexture, cj as WgslTexture1d, ck as WgslTexture2d, cl as WgslTexture2dArray, cm as WgslTexture3d, cn as WgslTextureCube, co as WgslTextureCubeArray, cp as WgslTextureDepth2d, cq as WgslTextureDepth2dArray, cr as WgslTextureDepthCube, cs as WgslTextureDepthCubeArray, ct as WgslTextureDepthMultisampled2d, cu as WgslTextureMultisampled2d, cA as align, cO as builtin, cv as comparisonSampler, dv as float16, dw as float16x2, dx as float16x4, dy as float32, dz as float32x2, dA as float32x3, dB as float32x4, d4 as formatToWGSLType, cD as interpolate, cE as invariant, bi as isAlignAttrib, bj as isAtomic, cG as isBuiltin, bk as isBuiltinAttrib, cJ as isData, bl as isDecorated, cK as isDisarray, bm as isInterpolateAttrib, bn as isLocationAttrib, cL as isLooseData, cM as isLooseDecorated, dN as isPackedData, bo as isPtr, bp as isSizeAttrib, cN as isUnstruct, bq as isWgslArray, br as isWgslData, bs as isWgslStruct, cH as location, bB as m2x2f, bC as m3x3f, bD as m4x4f, d5 as packedFormats, cz as ref, cw as sampler, dl as sint16, dm as sint16x2, dn as sint16x4, dG as sint32, dH as sint32x2, dI as sint32x3, dJ as sint32x4, d9 as sint8, da as sint8x2, db as sint8x4, cI as size, ds as snorm16, dt as snorm16x2, du as snorm16x4, df as snorm8, dg as snorm8x2, dh as snorm8x4, bW as texture1d, bX as texture2d, bY as texture2dArray, bZ as texture3d, b_ as textureCube, b$ as textureCubeArray, c0 as textureDepth2d, c1 as textureDepth2dArray, c2 as textureDepthCube, c3 as textureDepthCubeArray, c4 as textureDepthMultisampled2d, c5 as textureExternal, c6 as textureMultisampled2d, c7 as textureStorage1d, c8 as textureStorage2d, c9 as textureStorage2dArray, ca as textureStorage3d, di as uint16, dj as uint16x2, dk as uint16x4, dC as uint32, dD as uint32x2, dE as uint32x3, dF as uint32x4, d6 as uint8, d7 as uint8x2, d8 as uint8x4, dK as unorm10_10_10_2, dp as unorm16, dq as unorm16x2, dr as unorm16x4, dc as unorm8, dd as unorm8x2, de as unorm8x4, dL as unorm8x4_bgra, bI as v2b, bJ as v2f, bK as v2i, bL as v2u, bM as v3b, bN as v3f, bO as v3i, bP as v3u, bQ as v4b, bR as v4f, bS as v4i, bT as v4u } from '../tgpuConstant-BOn7U_lv.js';
import { T as TgpuComptime } from '../comptime-DKpw1IVu.js';
export { m as mat2x2f, a as mat3x3f, b as mat4x4f, c as matToArray } from '../matrix-C4IFKU1R.js';
import 'tinyest';
/**
* A schema that represents a boolean value. (equivalent to `bool` in WGSL)
*
* Can also be called to cast a value to a bool in accordance with WGSL casting rules.
*
* @example
* const value = bool(); // false
* @example
* const value = bool(0); // false
* @example
* const value = bool(-0); // false
* @example
* const value = bool(21.37); // true
*/
declare const bool: Bool;
/**
* A schema that represents an unsigned 32-bit integer value. (equivalent to `u32` in WGSL)
*
* Can also be called to cast a value to an u32 in accordance with WGSL casting rules.
*
* @example
* const value = u32(); // 0
* @example
* const value = u32(7); // 7
* @example
* const value = u32(3.14); // 3
* @example
* const value = u32(-1); // 4294967295
* @example
* const value = u32(-3.1); // 0
*/
declare const u32: U32;
declare const u16: U16;
/**
* A schema that represents a signed 32-bit integer value. (equivalent to `i32` in WGSL)
*
* Can also be called to cast a value to an i32 in accordance with WGSL casting rules.
*
* @example
* const value = i32(); // 0
* @example
* const value = i32(3.14); // 3
* @example
* const value = i32(-3.9); // -3
* @example
* const value = i32(10000000000) // 1410065408
*/
declare const i32: I32;
/**
* A schema that represents a 32-bit float value. (equivalent to `f32` in WGSL)
*
* Can also be called to cast a value to an f32.
*
* @example
* const value = f32(); // 0
* @example
* const value = f32(1.23); // 1.23
* @example
* const value = f32(true); // 1
*/
declare const f32: F32;
/**
* A schema that represents a 16-bit float value. (equivalent to `f16` in WGSL)
*
* Can also be called to cast a value to an f16.
*
* @example
* const value = f16(); // 0
* @example
* const value = f32(1.23); // 1.23
* @example
* const value = f16(true); // 1
* @example
* const value = f16(21877.5); // 21872
*/
declare const f16: F16;
/**
* Creates a struct schema that can be used to construct GPU buffers.
* Ensures proper alignment and padding of properties (as opposed to a `d.unstruct` schema).
* The order of members matches the passed in properties object.
*
* @example
* const CircleStruct = d.struct({ radius: d.f32, pos: d.vec3f });
*
* @param props Record with `string` keys and `TgpuData` values,
* each entry describing one struct member.
*/
declare function struct<TProps extends Record<string, AnyWgslData>>(props: TProps): WgslStruct<TProps>;
interface WgslArrayConstructor {
<TElement extends AnyWgslData>(elementType: TElement): (elementCount: number) => WgslArray<TElement>;
<TElement extends AnyWgslData>(elementType: TElement, elementCount: number): WgslArray<TElement>;
}
/**
* Creates an array schema that can be used to construct gpu buffers.
* Describes arrays with fixed-size length, storing elements of the same type.
*
* @example
* const LENGTH = 3;
* const array = d.arrayOf(d.u32, LENGTH);
*
* If `elementCount` is not specified, a partially applied function is returned.
* @example
* const array = d.arrayOf(d.vec3f);
* // ^? (n: number) => WgslArray<d.Vec3f>
*
* @param elementType The type of elements in the array.
* @param elementCount The number of elements in the array.
*/
declare const arrayOf: TgpuComptime<WgslArrayConstructor>;
declare function ptrFn<T extends StorableData>(inner: T): Ptr<'function', T, 'read-write'>;
declare function ptrPrivate<T extends StorableData>(inner: T): Ptr<'private', T, 'read-write'>;
declare function ptrWorkgroup<T extends StorableData>(inner: T): Ptr<'workgroup', T, 'read-write'>;
declare function ptrStorage<T extends StorableData, TAccess extends 'read' | 'read-write' = 'read'>(inner: T, access?: TAccess): Ptr<'storage', T, TAccess>;
declare function ptrUniform<T extends StorableData>(inner: T): Ptr<'uniform', T, 'read'>;
declare function ptrHandle<T extends StorableData>(inner: T): Ptr<'handle', T, 'read'>;
/**
* Schema representing vec2f - a vector with 2 elements of type f32.

@@ -193,121 +313,2 @@ * Also a constructor function for this vector value.

/**
* A schema that represents a boolean value. (equivalent to `bool` in WGSL)
*
* Can also be called to cast a value to a bool in accordance with WGSL casting rules.
*
* @example
* const value = bool(); // false
* @example
* const value = bool(0); // false
* @example
* const value = bool(-0); // false
* @example
* const value = bool(21.37); // true
*/
declare const bool: Bool;
/**
* A schema that represents an unsigned 32-bit integer value. (equivalent to `u32` in WGSL)
*
* Can also be called to cast a value to an u32 in accordance with WGSL casting rules.
*
* @example
* const value = u32(); // 0
* @example
* const value = u32(7); // 7
* @example
* const value = u32(3.14); // 3
* @example
* const value = u32(-1); // 4294967295
* @example
* const value = u32(-3.1); // 0
*/
declare const u32: U32;
declare const u16: U16;
/**
* A schema that represents a signed 32-bit integer value. (equivalent to `i32` in WGSL)
*
* Can also be called to cast a value to an i32 in accordance with WGSL casting rules.
*
* @example
* const value = i32(); // 0
* @example
* const value = i32(3.14); // 3
* @example
* const value = i32(-3.9); // -3
* @example
* const value = i32(10000000000) // 1410065408
*/
declare const i32: I32;
/**
* A schema that represents a 32-bit float value. (equivalent to `f32` in WGSL)
*
* Can also be called to cast a value to an f32.
*
* @example
* const value = f32(); // 0
* @example
* const value = f32(1.23); // 1.23
* @example
* const value = f32(true); // 1
*/
declare const f32: F32;
/**
* A schema that represents a 16-bit float value. (equivalent to `f16` in WGSL)
*
* Can also be called to cast a value to an f16.
*
* @example
* const value = f16(); // 0
* @example
* const value = f32(1.23); // 1.23
* @example
* const value = f16(true); // 1
* @example
* const value = f16(21877.5); // 21872
*/
declare const f16: F16;
/**
* Creates a struct schema that can be used to construct GPU buffers.
* Ensures proper alignment and padding of properties (as opposed to a `d.unstruct` schema).
* The order of members matches the passed in properties object.
*
* @example
* const CircleStruct = d.struct({ radius: d.f32, pos: d.vec3f });
*
* @param props Record with `string` keys and `TgpuData` values,
* each entry describing one struct member.
*/
declare function struct<TProps extends Record<string, AnyWgslData>>(props: TProps): WgslStruct<TProps>;
interface WgslArrayConstructor {
<TElement extends AnyWgslData>(elementType: TElement): (elementCount: number) => WgslArray<TElement>;
<TElement extends AnyWgslData>(elementType: TElement, elementCount: number): WgslArray<TElement>;
}
/**
* Creates an array schema that can be used to construct gpu buffers.
* Describes arrays with fixed-size length, storing elements of the same type.
*
* @example
* const LENGTH = 3;
* const array = d.arrayOf(d.u32, LENGTH);
*
* If `elementCount` is not specified, a partially applied function is returned.
* @example
* const array = d.arrayOf(d.vec3f);
* // ^? (n: number) => WgslArray<d.Vec3f>
*
* @param elementType The type of elements in the array.
* @param elementCount The number of elements in the array.
*/
declare const arrayOf: DualFn<WgslArrayConstructor>;
declare function ptrFn<T extends StorableData>(inner: T): Ptr<'function', T, 'read-write'>;
declare function ptrPrivate<T extends StorableData>(inner: T): Ptr<'private', T, 'read-write'>;
declare function ptrWorkgroup<T extends StorableData>(inner: T): Ptr<'workgroup', T, 'read-write'>;
declare function ptrStorage<T extends StorableData, TAccess extends 'read' | 'read-write' = 'read'>(inner: T, access?: TAccess): Ptr<'storage', T, TAccess>;
declare function ptrUniform<T extends StorableData>(inner: T): Ptr<'uniform', T, 'read'>;
declare function ptrHandle<T extends StorableData>(inner: T): Ptr<'handle', T, 'read'>;
interface DisarrayConstructor {

@@ -339,3 +340,3 @@ <TElement extends AnyData>(elementType: TElement): (elementCount: number) => Disarray<TElement>;

*/
declare const disarrayOf: DualFn<DisarrayConstructor>;
declare const disarrayOf: TgpuComptime<DisarrayConstructor>;

@@ -342,0 +343,0 @@ /**

@@ -1,2 +0,2 @@

import{a as jb,b as kb,c as lb,d as mb,e as nb,f as ob,g as pb,h as qb,i as rb}from"../chunk-6U5HPHCJ.js";import{A as Ra,B as Sa,C as Ta,D as Ua,E as Va,F as Wa,G as Xa,H as Ya,I as Za,J as _a,K as $a,L as ab,M as bb,N as cb,O as db,P as eb,Q as fb,T as hb,j as M,k as N,l as O,m as P,u as Pa,v as Qa}from"../chunk-ECR2EGZX.js";import{$a as B,$b as Ca,Ab as ba,B as b,Bb as ca,C as c,Cb as da,D as d,Db as ea,E as e,Eb as fa,F as f,Fb as ga,G as g,Gb as ha,H as h,Hb as ia,I as i,Ib as ja,J as j,Jb as ka,K as k,Kb as la,L as l,Lb as ma,Mb as na,Nb as oa,Ob as pa,Pb as qa,Q as m,Qa as r,Qb as ra,R as n,Ra as s,Rb as sa,S as o,Sa as t,Sb as ta,T as p,Ta as u,Tb as ua,Ua as v,Ub as va,V as q,Va as w,Vb as wa,Wb as xa,Xa as x,Xb as ya,Ya as y,Yb as za,Za as z,Zb as Aa,_a as A,_b as Ba,ab as C,ac as Da,bb as D,bc as Ea,cb as E,cc as Fa,db as F,eb as G,fb as H,fc as Ga,gb as I,hb as J,ib as K,ic as Ha,jb as L,jc as Ia,kc as Ja,lc as Ka,mc as La,nb as Q,nc as Ma,ob as R,oc as Na,pb as S,q as a,qb as T,rb as U,rc as Oa,sb as V,tb as W,tc as gb,ub as X,uc as ib,vb as Y,wb as Z,xb as _,yb as $,zb as aa}from"../chunk-CRZWTZM2.js";export{a as Void,Ia as align,Ga as alignmentOf,gb as arrayOf,hb as atomic,r as bool,ib as builtin,Qa as comparisonSampler,rb as deepEqual,pb as disarrayOf,w as f16,v as f32,oa as float16,pa as float16x2,qa as float16x4,ra as float32,sa as float32x2,ta as float32x3,ua as float32x4,Q as formatToWGSLType,u as i32,La as interpolate,Ma as invariant,g as isAlignAttrib,f as isAtomic,Na as isBuiltin,k as isBuiltinAttrib,q as isData,l as isDecorated,n as isDisarray,j as isInterpolateAttrib,i as isLocationAttrib,m as isLooseData,p as isLooseDecorated,Fa as isPackedData,e as isPtr,h as isSizeAttrib,o as isUnstruct,c as isWgslArray,b as isWgslData,d as isWgslStruct,Ka as location,M as mat2x2f,N as mat3x3f,O as mat4x4f,P as matToArray,R as packedFormats,jb as ptrFn,ob as ptrHandle,kb as ptrPrivate,mb as ptrStorage,nb as ptrUniform,lb as ptrWorkgroup,Pa as sampler,fa as sint16,ga as sint16x2,ha as sint16x4,za as sint32,Aa as sint32x2,Ba as sint32x3,Ca as sint32x4,V as sint8,W as sint8x2,X as sint8x4,Ja as size,Ha as sizeOf,la as snorm16,ma as snorm16x2,na as snorm16x4,$ as snorm8,aa as snorm8x2,ba as snorm8x4,Oa as struct,Ra as texture1d,Sa as texture2d,Ua as texture2dArray,Xa as texture3d,Va as textureCube,Wa as textureCubeArray,ab as textureDepth2d,cb as textureDepth2dArray,db as textureDepthCube,eb as textureDepthCubeArray,bb as textureDepthMultisampled2d,fb as textureExternal,Ta as textureMultisampled2d,Ya as textureStorage1d,Za as textureStorage2d,_a as textureStorage2dArray,$a as textureStorage3d,t as u16,s as u32,ca as uint16,da as uint16x2,ea as uint16x4,va as uint32,wa as uint32x2,xa as uint32x3,ya as uint32x4,S as uint8,T as uint8x2,U as uint8x4,Da as unorm10_10_10_2,ia as unorm16,ja as unorm16x2,ka as unorm16x4,Y as unorm8,Z as unorm8x2,_ as unorm8x4,Ea as unorm8x4_bgra,qb as unstruct,B as vec2b,x as vec2f,y as vec2h,z as vec2i,A as vec2u,G as vec3b,C as vec3f,D as vec3h,E as vec3i,F as vec3u,L as vec4b,H as vec4f,I as vec4h,J as vec4i,K as vec4u};
import{a as B,c as vt,d as bt,g as _t}from"../chunk-LMPPDGRD.js";import{c as xt,f as dt,g as gt,h as Dt,i as At,j as Tt,k as ht,l as Wt,n as Nt,o as qt}from"../chunk-MBB2XFH6.js";import{A as St,B as Ot,C as Vt,D as Pt,E as Et,F as wt,G as Ct,H as kt,I as $t,J as Ut,K as Lt,L as Mt,M as jt,N as Ft,O as zt,P as Kt,a as A,j as yt,k as mt,l as ct,m as ft,z as Bt}from"../chunk-EHLRP4V2.js";import{$b as ce,Ab as ut,Ac as T,B as V,Bb as lt,Bc as It,C as y,D as m,E as c,F as f,G as P,H as E,Hb as b,I as w,J as C,K as k,Kb as Qt,L as x,Lb as Xt,Ma as L,Mb as Yt,Na as M,Nb as Zt,Oa as j,Ob as te,Pa as F,Pb as ee,Qa as z,Qb as re,Ra as K,Rb as ae,S as $,Sb as ne,T as d,Tb as se,U as g,Ua as N,Ub as oe,V as D,Vb as ie,Wb as pe,Xb as ue,Yb as le,Z as U,Zb as ye,_b as me,a as p,ac as fe,bc as xe,cc as de,dc as ge,ec as De,fc as Ae,gb as _,gc as Te,hb as q,hc as he,ib as G,ic as We,j as I,jb as H,jc as Ie,k as v,kb as R,kc as ve,lb as J,lc as be,mb as l,mc as Be,nb as Q,nc as Se,ob as X,oc as Oe,pb as Y,pc as Ve,q as O,qb as Z,qc as Pe,rb as tt,rc as Ee,sb as et,sc as we,tb as rt,tc as Ce,ub as at,uc as ke,vb as nt,vc as $e,wb as st,wc as Ue,xb as ot,xc as Le,yb as it,yc as Me,zb as pt,zc as je}from"../chunk-SHSILTWI.js";var Gt=b(((e,t)=>t===void 0?r=>S(e,r):S(e,t))).$name("disarrayOf");function S(e,t){let r=a=>{if(a&&a.length!==t)throw new Error(`Disarray schema of ${t} elements of type ${e.type} called with ${a.length} argument(s).`);return Array.from({length:t},(s,n)=>T(e,a?.[n]))};if(Object.setPrototypeOf(r,Ht),r.elementType=e,!Number.isInteger(t)||t<0)throw new Error(`Cannot create disarray schema with invalid element count: ${t}.`);return r.elementCount=t,r}var Ht={[p]:!0,type:"disarray",toString(){return`disarrayOf(${this.elementType}, ${this.elementCount})`}};function Rt(e){let t=r=>Object.fromEntries(Object.entries(e).map(([a,s])=>[a,T(s,r?.[a])]));return Object.setPrototypeOf(t,Jt),t.propTypes=e,t}var Jt={[p]:!0,type:"unstruct",$name(e){return v(this,e),this},toString(){return`unstruct:${I(this)??"<unnamed>"}`}};function u(e,t){if(e===t)return!0;if(e.type!==t.type)return!1;if(m(e)&&m(t)||g(e)&&g(t)){let r=e.propTypes,a=t.propTypes,s=Object.keys(r),n=Object.keys(a);if(s.length!==n.length)return!1;for(let o=0;o<s.length;o++){let h=s[o],W=n[o];if(h!==W||!h||!W||!u(r[h],a[W]))return!1}return!0}if(y(e)&&y(t)||d(e)&&d(t))return e.elementCount===t.elementCount&&u(e.elementType,t.elementType);if(c(e)&&c(t))return e.addressSpace===t.addressSpace&&e.access===t.access&&u(e.inner,t.inner);if(f(e)&&f(t))return u(e.inner,t.inner);if(x(e)&&x(t)||D(e)&&D(t)){if(!u(e.inner,t.inner)||e.attribs.length!==t.attribs.length)return!1;let r=n=>{let o=n;return`${o.type}(${(o.params??[]).join(",")})`},a=e.attribs.map(r),s=t.attribs.map(r);for(let n=0;n<a.length;n++)if(a[n]!==s[n])return!1}return!0}function i(e,t){let r=e.prototype,a=B[t][p].jsImpl;r[t]=function(s){return a(this,s)}}i(l,"add");i(l,"sub");i(l,"mul");i(l,"div");i(A,"add");i(A,"sub");i(A,"mul");export{O as Void,gt as align,xt as alignmentOf,Nt as arrayOf,_t as atomic,_ as bool,qt as builtin,bt as comparisonSampler,u as deepEqual,Gt as disarrayOf,J as f16,R as f32,We as float16,Ie as float16x2,ve as float16x4,be as float32,Be as float32x2,Se as float32x3,Oe as float32x4,Qt as formatToWGSLType,H as i32,Tt as interpolate,ht as invariant,P as isAlignAttrib,f as isAtomic,Wt as isBuiltin,k as isBuiltinAttrib,U as isData,x as isDecorated,d as isDisarray,C as isInterpolateAttrib,w as isLocationAttrib,$ as isLooseData,D as isLooseDecorated,je as isPackedData,c as isPtr,E as isSizeAttrib,g as isUnstruct,y as isWgslArray,V as isWgslData,m as isWgslStruct,At as location,yt as mat2x2f,mt as mat3x3f,ct as mat4x4f,ft as matToArray,Xt as packedFormats,L as ptrFn,K as ptrHandle,M as ptrPrivate,F as ptrStorage,z as ptrUniform,j as ptrWorkgroup,N as ref,vt as sampler,ce as sint16,fe as sint16x2,xe as sint16x4,Ce as sint32,ke as sint32x2,$e as sint32x3,Ue as sint32x4,ee as sint8,re as sint8x2,ae as sint8x4,Dt as size,dt as sizeOf,Ae as snorm16,Te as snorm16x2,he as snorm16x4,ie as snorm8,pe as snorm8x2,ue as snorm8x4,It as struct,Bt as texture1d,St as texture2d,Vt as texture2dArray,wt as texture3d,Pt as textureCube,Et as textureCubeArray,Lt as textureDepth2d,jt as textureDepth2dArray,Ft as textureDepthCube,zt as textureDepthCubeArray,Mt as textureDepthMultisampled2d,Kt as textureExternal,Ot as textureMultisampled2d,Ct as textureStorage1d,kt as textureStorage2d,$t as textureStorage2dArray,Ut as textureStorage3d,G as u16,q as u32,le as uint16,ye as uint16x2,me as uint16x4,Ve as uint32,Pe as uint32x2,Ee as uint32x3,we as uint32x4,Yt as uint8,Zt as uint8x2,te as uint8x4,Le as unorm10_10_10_2,de as unorm16,ge as unorm16x2,De as unorm16x4,ne as unorm8,se as unorm8x2,oe as unorm8x4,Me as unorm8x4_bgra,Rt as unstruct,tt as vec2b,Q as vec2f,X as vec2h,Y as vec2i,Z as vec2u,st as vec3b,et as vec3f,rt as vec3h,at as vec3i,nt as vec3u,lt as vec4b,ot as vec4f,it as vec4h,pt as vec4i,ut as vec4u};
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
{"version":3,"sources":["../../src/data/disarray.ts","../../src/data/unstruct.ts","../../src/data/deepEqual.ts","../../src/data/index.ts"],"sourcesContent":["import { comptime } from '../core/function/comptime.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport type { AnyData, Disarray } from './dataTypes.ts';\nimport { schemaCallWrapper } from './schemaCallWrapper.ts';\n\n// ----------\n// Public API\n// ----------\n\ninterface DisarrayConstructor {\n <TElement extends AnyData>(\n elementType: TElement,\n ): (elementCount: number) => Disarray<TElement>;\n\n <TElement extends AnyData>(\n elementType: TElement,\n elementCount: number,\n ): Disarray<TElement>;\n}\n\n/**\n * Creates an array schema that can be used to construct vertex buffers.\n * Describes arrays with fixed-size length, storing elements of the same type.\n *\n * Elements in the schema are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n *\n * @example\n * const disarray = d.disarrayOf(d.vec3f, 3); // packed array of vec3f\n *\n * @example\n * const disarray = d.disarrayOf(d.align(16, d.vec3f), 3);\n *\n * If `elementCount` is not specified, a partially applied function is returned.\n * @example\n * const disarray = d.disarrayOf(d.vec3f);\n * // ^? (n: number) => Disarray<d.Vec3f>\n *\n * @param elementType The type of elements in the array.\n * @param elementCount The number of elements in the array.\n */\nexport const disarrayOf = comptime(\n ((elementType, elementCount) => {\n if (elementCount === undefined) {\n return (count: number) => cpu_disarrayOf(elementType, count);\n }\n return cpu_disarrayOf(elementType, elementCount);\n }) as DisarrayConstructor,\n).$name('disarrayOf');\n\nexport function cpu_disarrayOf<TElement extends AnyData>(\n elementType: TElement,\n elementCount: number,\n): Disarray<TElement> {\n // In the schema call, create and return a deep copy\n // by wrapping all the values in `elementType` schema calls.\n const disarraySchema = (elements?: TElement[]) => {\n if (elements && elements.length !== elementCount) {\n throw new Error(\n `Disarray schema of ${elementCount} elements of type ${elementType.type} called with ${elements.length} argument(s).`,\n );\n }\n\n return Array.from(\n { length: elementCount },\n (_, i) => schemaCallWrapper(elementType, elements?.[i]),\n );\n };\n Object.setPrototypeOf(disarraySchema, DisarrayImpl);\n\n disarraySchema.elementType = elementType;\n\n if (!Number.isInteger(elementCount) || elementCount < 0) {\n throw new Error(\n `Cannot create disarray schema with invalid element count: ${elementCount}.`,\n );\n }\n disarraySchema.elementCount = elementCount;\n\n return disarraySchema as unknown as Disarray<TElement>;\n}\n\n// --------------\n// Implementation\n// --------------\n\nconst DisarrayImpl = {\n [$internal]: true,\n type: 'disarray',\n\n toString(this: Disarray): string {\n return `disarrayOf(${this.elementType}, ${this.elementCount})`;\n },\n};\n","import { getName, setName } from '../shared/meta.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport type { AnyData, Unstruct } from './dataTypes.ts';\nimport { schemaCallWrapper } from './schemaCallWrapper.ts';\nimport type { BaseData } from './wgslTypes.ts';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Creates a loose struct schema that can be used to construct vertex buffers.\n * Describes structs with members of both loose and non-loose types.\n *\n * The order of members matches the passed in properties object.\n * Members are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n *\n * @example\n * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.vec3f }); // packed struct with no padding\n *\n * @example\n * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.align(16, d.vec3f) });\n *\n * @param properties Record with `string` keys and `TgpuData` or `TgpuLooseData` values,\n * each entry describing one struct member.\n */\nexport function unstruct<TProps extends Record<string, BaseData>>(\n properties: TProps,\n): Unstruct<TProps> {\n // In the schema call, create and return a deep copy\n // by wrapping all the values in corresponding schema calls.\n const unstructSchema = (instanceProps?: TProps) =>\n Object.fromEntries(\n Object.entries(properties).map(([key, schema]) => [\n key,\n schemaCallWrapper(schema as AnyData, instanceProps?.[key]),\n ]),\n );\n Object.setPrototypeOf(unstructSchema, UnstructImpl);\n unstructSchema.propTypes = properties;\n\n return unstructSchema as unknown as Unstruct<TProps>;\n}\n\n// --------------\n// Implementation\n// --------------\n\nconst UnstructImpl = {\n [$internal]: true,\n type: 'unstruct',\n\n $name(label: string) {\n setName(this, label);\n return this;\n },\n\n toString(): string {\n return `unstruct:${getName(this) ?? '<unnamed>'}`;\n },\n};\n","import type { AnyAttribute } from './attributes.ts';\nimport { isDisarray, isLooseDecorated, isUnstruct } from './dataTypes.ts';\nimport type { AnyData } from './dataTypes.ts';\nimport {\n isAtomic,\n isDecorated,\n isPtr,\n isWgslArray,\n isWgslStruct,\n} from './wgslTypes.ts';\n\n/**\n * Performs a deep comparison of two TypeGPU data schemas.\n *\n * @param a The first data schema to compare.\n * @param b The second data schema to compare.\n * @returns `true` if the schemas are deeply equal, `false` otherwise.\n *\n * @example\n * ```ts\n * import { vec3f, struct, deepEqual } from 'typegpu/data';\n *\n * const schema1 = struct({ a: vec3f });\n * const schema2 = struct({ a: vec3f });\n * const schema3 = struct({ b: vec3f });\n *\n * console.log(deepEqual(schema1, schema2)); // true\n * console.log(deepEqual(schema1, schema3)); // false\n * ```\n */\nexport function deepEqual(a: AnyData, b: AnyData): boolean {\n if (a === b) {\n return true;\n }\n\n if (a.type !== b.type) {\n return false;\n }\n\n if (\n (isWgslStruct(a) && isWgslStruct(b)) ||\n (isUnstruct(a) && isUnstruct(b))\n ) {\n const aProps = a.propTypes;\n const bProps = b.propTypes;\n const aKeys = Object.keys(aProps);\n const bKeys = Object.keys(bProps);\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n for (let i = 0; i < aKeys.length; i++) {\n const keyA = aKeys[i];\n const keyB = bKeys[i];\n if (\n keyA !== keyB || !keyA || !keyB ||\n !deepEqual(aProps[keyA], bProps[keyB])\n ) {\n return false;\n }\n }\n return true;\n }\n\n if ((isWgslArray(a) && isWgslArray(b)) || (isDisarray(a) && isDisarray(b))) {\n return (\n a.elementCount === b.elementCount &&\n deepEqual(a.elementType as AnyData, b.elementType as AnyData)\n );\n }\n\n if (isPtr(a) && isPtr(b)) {\n return (\n a.addressSpace === b.addressSpace &&\n a.access === b.access &&\n deepEqual(a.inner as AnyData, b.inner as AnyData)\n );\n }\n\n if (isAtomic(a) && isAtomic(b)) {\n return deepEqual(a.inner as AnyData, b.inner as AnyData);\n }\n\n if (\n (isDecorated(a) && isDecorated(b)) ||\n (isLooseDecorated(a) && isLooseDecorated(b))\n ) {\n if (!deepEqual(a.inner as AnyData, b.inner as AnyData)) {\n return false;\n }\n if (a.attribs.length !== b.attribs.length) {\n return false;\n }\n\n // Create comparable string representations for each attribute\n const getAttrKey = (attr: unknown): string => {\n const anyAttr = attr as AnyAttribute;\n return `${anyAttr.type}(${(anyAttr.params ?? []).join(',')})`;\n };\n\n const attrsA = a.attribs.map(getAttrKey);\n const attrsB = b.attribs.map(getAttrKey);\n\n for (let i = 0; i < attrsA.length; i++) {\n if (attrsA[i] !== attrsB[i]) {\n return false;\n }\n }\n }\n\n // All other types have been checked for equality at the start\n return true;\n}\n","/**\n * @module typegpu/data\n */\n\nimport { type InfixOperator, infixOperators } from '../tgsl/accessProp.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { MatBase } from './matrix.ts';\nimport { VecBase } from './vectorImpl.ts';\n\nfunction assignInfixOperator<T extends typeof VecBase | typeof MatBase>(\n object: T,\n operator: InfixOperator,\n) {\n type Instance = InstanceType<T>;\n\n const proto = object.prototype as {\n [K in InfixOperator]?: (this: Instance, other: unknown) => unknown;\n };\n const opImpl = infixOperators[operator][$internal].jsImpl as (\n lhs: Instance,\n rhs: unknown,\n ) => unknown;\n\n proto[operator] = function (this: Instance, other: unknown): unknown {\n return opImpl(this, other);\n };\n}\n\nassignInfixOperator(VecBase, 'add');\nassignInfixOperator(VecBase, 'sub');\nassignInfixOperator(VecBase, 'mul');\nassignInfixOperator(VecBase, 'div');\nassignInfixOperator(MatBase, 'add');\nassignInfixOperator(MatBase, 'sub');\nassignInfixOperator(MatBase, 'mul');\n\nexport { bool, f16, f32, i32, u16, u32 } from './numeric.ts';\nexport {\n isAlignAttrib,\n isAtomic,\n isBuiltinAttrib,\n isDecorated,\n isInterpolateAttrib,\n isLocationAttrib,\n isPtr,\n isSizeAttrib,\n isWgslArray,\n isWgslData,\n isWgslStruct,\n Void,\n} from './wgslTypes.ts';\nexport type {\n Align,\n AnyVecInstance,\n AnyWgslData,\n AnyWgslStruct,\n Atomic,\n BaseData,\n BaseData as BaseWgslData,\n Bool,\n Builtin,\n Decorated,\n F16,\n F32,\n I32,\n Interpolate,\n Location,\n m2x2f,\n m3x3f,\n m4x4f,\n Mat2x2f,\n Mat3x3f,\n Mat4x4f,\n Ptr,\n Size,\n StorableData,\n U16,\n U32,\n v2b,\n v2f,\n v2i,\n v2u,\n v3b,\n v3f,\n v3i,\n v3u,\n v4b,\n v4f,\n v4i,\n v4u,\n Vec2b,\n Vec2f,\n Vec2h,\n Vec2i,\n Vec2u,\n Vec3b,\n Vec3f,\n Vec3h,\n Vec3i,\n Vec3u,\n Vec4b,\n Vec4f,\n Vec4h,\n Vec4i,\n Vec4u,\n WgslArray,\n WgslStruct,\n} from './wgslTypes.ts';\nexport { struct } from './struct.ts';\nexport { arrayOf } from './array.ts';\nexport {\n ptrFn,\n ptrHandle,\n ptrPrivate,\n ptrStorage,\n ptrUniform,\n ptrWorkgroup,\n} from './ptr.ts';\nexport type {\n AnyData,\n AnyLooseData,\n Disarray,\n LooseDecorated,\n Unstruct,\n} from './dataTypes.ts';\nexport {\n texture1d,\n texture2d,\n texture2dArray,\n texture3d,\n textureCube,\n textureCubeArray,\n textureDepth2d,\n textureDepth2dArray,\n textureDepthCube,\n textureDepthCubeArray,\n textureDepthMultisampled2d,\n textureExternal,\n textureMultisampled2d,\n textureStorage1d,\n textureStorage2d,\n textureStorage2dArray,\n textureStorage3d,\n type WgslExternalTexture,\n type WgslStorageTexture,\n type WgslStorageTexture1d,\n type WgslStorageTexture2d,\n type WgslStorageTexture2dArray,\n type WgslStorageTexture3d,\n type WgslStorageTextureProps,\n type WgslTexture,\n type WgslTexture1d,\n type WgslTexture2d,\n type WgslTexture2dArray,\n type WgslTexture3d,\n type WgslTextureCube,\n type WgslTextureCubeArray,\n type WgslTextureDepth2d,\n type WgslTextureDepth2dArray,\n type WgslTextureDepthCube,\n type WgslTextureDepthCubeArray,\n type WgslTextureDepthMultisampled2d,\n type WgslTextureMultisampled2d,\n} from './texture.ts';\nexport {\n comparisonSampler,\n sampler,\n type WgslComparisonSampler,\n type WgslSampler,\n} from './sampler.ts';\nexport {\n vec2b,\n vec2f,\n vec2h,\n vec2i,\n vec2u,\n vec3b,\n vec3f,\n vec3h,\n vec3i,\n vec3u,\n vec4b,\n vec4f,\n vec4h,\n vec4i,\n vec4u,\n} from './vector.ts';\nexport { disarrayOf } from './disarray.ts';\nexport { unstruct } from './unstruct.ts';\nexport { mat2x2f, mat3x3f, mat4x4f, matToArray } from './matrix.ts';\nexport * from './vertexFormatData.ts';\nexport { atomic } from './atomic.ts';\nexport { ref } from './ref.ts';\nexport {\n align,\n type AnyAttribute,\n type HasCustomLocation,\n interpolate,\n invariant,\n type IsBuiltin,\n isBuiltin,\n location,\n size,\n} from './attributes.ts';\nexport {\n isData,\n isDisarray,\n isLooseData,\n isLooseDecorated,\n isUnstruct,\n} from './dataTypes.ts';\nexport { PUBLIC_sizeOf as sizeOf } from './sizeOf.ts';\nexport { PUBLIC_alignmentOf as alignmentOf } from './alignmentOf.ts';\nexport { builtin } from '../builtin.ts';\nexport { deepEqual } from './deepEqual.ts';\nexport type {\n AnyBuiltin,\n BuiltinClipDistances,\n BuiltinFragDepth,\n BuiltinFrontFacing,\n BuiltinGlobalInvocationId,\n BuiltinInstanceIndex,\n BuiltinLocalInvocationId,\n BuiltinLocalInvocationIndex,\n BuiltinNumWorkgroups,\n BuiltinPosition,\n BuiltinSampleIndex,\n BuiltinSampleMask,\n BuiltinVertexIndex,\n BuiltinWorkgroupId,\n} from '../builtin.ts';\nexport type { Infer, In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C,MAAO,GAIT,IAAMgB,EAAcC,GAA0B,CAC5C,IAAMC,EAAUD,EAChB,MAAO,GAAGC,EAAQ,IAAI,KAAKA,EAAQ,QAAU,CAAC,GAAG,KAAK,GAAG,CAAC,GAC5D,EAEMC,EAASpB,EAAE,QAAQ,IAAIiB,CAAU,EACjCI,EAASpB,EAAE,QAAQ,IAAIgB,CAAU,EAEvC,QAAST,EAAI,EAAGA,EAAIY,EAAO,OAAQZ,IACjC,GAAIY,EAAOZ,CAAC,IAAMa,EAAOb,CAAC,EACxB,MAAO,EAGb,CAGA,MAAO,EACT,CCxGA,SAASc,EACPC,EACAC,EACA,CAGA,IAAMC,EAAQF,EAAO,UAGfG,EAASC,EAAeH,CAAQ,EAAEI,CAAS,EAAE,OAKnDH,EAAMD,CAAQ,EAAI,SAA0BK,EAAyB,CACnE,OAAOH,EAAO,KAAMG,CAAK,CAC3B,CACF,CAEAP,EAAoBQ,EAAS,KAAK,EAClCR,EAAoBQ,EAAS,KAAK,EAClCR,EAAoBQ,EAAS,KAAK,EAClCR,EAAoBQ,EAAS,KAAK,EAClCR,EAAoBS,EAAS,KAAK,EAClCT,EAAoBS,EAAS,KAAK,EAClCT,EAAoBS,EAAS,KAAK","names":["disarrayOf","comptime","elementType","elementCount","count","cpu_disarrayOf","disarraySchema","elements","_","i","schemaCallWrapper","DisarrayImpl","$internal","unstruct","properties","unstructSchema","instanceProps","key","schema","schemaCallWrapper","UnstructImpl","$internal","label","setName","getName","deepEqual","a","b","isWgslStruct","isUnstruct","aProps","bProps","aKeys","bKeys","i","keyA","keyB","isWgslArray","isDisarray","isPtr","isAtomic","isDecorated","isLooseDecorated","getAttrKey","attr","anyAttr","attrsA","attrsB","assignInfixOperator","object","operator","proto","opImpl","infixOperators","$internal","other","VecBase","MatBase"]}
+114
-25

@@ -1,5 +0,57 @@

import { $ as $internal, S as ShelllessRepository, T as TgpuSlot, R as ResolvedSnippet, a as TgpuDerived, b as TgpuBindGroupLayout, c as TgpuBindGroup, L as LogResources, W as Wgsl, C as Configurable, d as WgslExtension, e as ShaderGenerator, f as TgpuBuffer, A as AnyData, g as TgpuVar, h as LogGeneratorOptions, i as TgpuRoot, j as AnyWgslData, k as TgpuFn, l as TgpuBufferUsage, I as Infer, m as TgpuAccessor, n as TgpuVertexLayout, o as WgslArray, D as Disarray, p as fn, q as bindGroupLayout, v as vertexLayout, r as privateVar, w as workgroupVar, s as constant, t as fragmentFn, u as vertexFn, x as computeFn, y as declare } from './tgpuConstant-BTQFNlQH.js';
export { aw as BindLayoutEntry, aj as Eventual, ax as ExtractBindGroupInputFromLayout, aO as INTERNAL_GlobalExt, a7 as IndexFlag, ay as LayoutEntryToInput, an as RenderFlag, ao as SampledFlag, a3 as Storage, a4 as StorageFlag, am as TextureProps, ad as TgpuBufferMutable, ae as TgpuBufferReadonly, af as TgpuBufferUniform, ar as TgpuComparisonSampler, aL as TgpuComputeFn, aM as TgpuComputeFnShell, a6 as TgpuComputePipeline, ap as TgpuConst, aN as TgpuDeclare, as as TgpuFixedComparisonSampler, at as TgpuFixedSampler, aG as TgpuFnShell, aJ as TgpuFragmentFn, aK as TgpuFragmentFnShell, V as TgpuGuardedComputePipeline, az as TgpuLayoutComparisonSampler, aA as TgpuLayoutEntry, aB as TgpuLayoutExternalTexture, aC as TgpuLayoutSampler, aD as TgpuLayoutStorage, aE as TgpuLayoutTexture, aF as TgpuLayoutUniform, ag as TgpuMutable, av as TgpuQuerySet, ah as TgpuReadonly, a5 as TgpuRenderPipeline, au as TgpuSampler, ak as TgpuTexture, al as TgpuTextureView, ai as TgpuUniform, aH as TgpuVertexFn, aI as TgpuVertexFnShell, a8 as Uniform, a9 as UniformFlag, aa as ValidUsagesFor, X as ValidateBufferSchema, Y as ValidateStorageSchema, Z as ValidateUniformSchema, aq as VariableScope, ab as Vertex, ac as VertexFlag, _ as WithBinding, a0 as WithCompute, a1 as WithFragment, a2 as WithVertex, z as isBuffer, P as isBufferShorthand, G as isComparisonSampler, E as isDerived, H as isSampler, F as isSlot, J as isTexture, Q as isTgpuFn, K as isUsableAsRender, M as isUsableAsSampled, N as isUsableAsStorage, O as isUsableAsUniform, B as isUsableAsVertex, U as isVariable } from './tgpuConstant-BTQFNlQH.js';
import { A as AnyData, O as Origin, I as InferGPU, $ as $internal, S as ShelllessRepository, T as TgpuSlot, R as ResolvedSnippet, a as TgpuDerived, b as TgpuBindGroupLayout, c as TgpuBindGroup, L as LogResources, C as Configurable, W as WgslExtension, d as ShaderGenerator, e as Wgsl, f as ResolvableObject, g as TgpuBuffer, h as TgpuVar, i as LogGeneratorOptions, j as TgpuRoot, k as AnyWgslData, l as TgpuFn, m as TgpuBufferUsage, n as TgpuBufferShorthand, o as Infer, p as TgpuAccessor, q as TgpuVertexLayout, r as WgslArray, D as Disarray, s as fn, t as bindGroupLayout, v as vertexLayout, u as privateVar, w as workgroupVar, x as constant, y as fragmentFn, z as vertexFn, B as computeFn, E as declare } from './tgpuConstant-BOn7U_lv.js';
export { aA as BindLayoutEntry, an as Eventual, aB as ExtractBindGroupInputFromLayout, aS as INTERNAL_GlobalExt, ab as IndexFlag, aC as LayoutEntryToInput, ar as RenderFlag, as as SampledFlag, a7 as Storage, a8 as StorageFlag, aq as TextureProps, ah as TgpuBufferMutable, ai as TgpuBufferReadonly, aj as TgpuBufferUniform, av as TgpuComparisonSampler, aP as TgpuComputeFn, aQ as TgpuComputeFnShell, aa as TgpuComputePipeline, at as TgpuConst, aR as TgpuDeclare, aw as TgpuFixedComparisonSampler, ax as TgpuFixedSampler, aK as TgpuFnShell, aN as TgpuFragmentFn, aO as TgpuFragmentFnShell, _ as TgpuGuardedComputePipeline, aD as TgpuLayoutComparisonSampler, aE as TgpuLayoutEntry, aF as TgpuLayoutExternalTexture, aG as TgpuLayoutSampler, aH as TgpuLayoutStorage, aI as TgpuLayoutTexture, aJ as TgpuLayoutUniform, ak as TgpuMutable, az as TgpuQuerySet, al as TgpuReadonly, a9 as TgpuRenderPipeline, ay as TgpuSampler, ao as TgpuTexture, ap as TgpuTextureView, am as TgpuUniform, aL as TgpuVertexFn, aM as TgpuVertexFnShell, ac as Uniform, ad as UniformFlag, ae as ValidUsagesFor, a0 as ValidateBufferSchema, a1 as ValidateStorageSchema, a2 as ValidateUniformSchema, au as VariableScope, af as Vertex, ag as VertexFlag, a3 as WithBinding, a4 as WithCompute, a5 as WithFragment, a6 as WithVertex, F as isBuffer, X as isBufferShorthand, K as isComparisonSampler, H as isDerived, M as isSampler, J as isSlot, N as isTexture, Y as isTgpuFn, P as isUsableAsRender, Q as isUsableAsSampled, U as isUsableAsStorage, V as isUsableAsUniform, G as isUsableAsVertex, Z as isVariable } from './tgpuConstant-BOn7U_lv.js';
import { c as comptime } from './comptime-DKpw1IVu.js';
export { T as TgpuComptime } from './comptime-DKpw1IVu.js';
import 'tinyest';
/**
* Extra declaration that will be included in final WGSL code
* when resolving objects that use it.
*/
interface TgpuRawCodeSnippet<TDataType extends AnyData> {
$: InferGPU<TDataType>;
value: InferGPU<TDataType>;
$uses(dependencyMap: Record<string, unknown>): this;
}
type RawCodeSnippetOrigin = Exclude<Origin, 'function' | 'this-function' | 'argument' | 'constant-ref'>;
/**
* An advanced API that creates a typed shader expression which
* can be injected into the final shader bundle upon use.
*
* @param expression The code snippet that will be injected in place of `foo.$`
* @param type The type of the expression
* @param [origin='runtime'] Where the value originates from.
*
* **-- Which origin to choose?**
*
* Usually 'runtime' (the default) is a safe bet, but if you're sure that the expression or
* computation is constant (either a reference to a constant, a numeric literal,
* or an operation on constants), then pass 'constant' as it might lead to better
* optimizations.
*
* If what the expression is a direct reference to an existing value (e.g. a uniform, a
* storage binding, ...), then choose from 'uniform', 'mutable', 'readonly', 'workgroup',
* 'private' or 'handle' depending on the address space of the referred value.
*
* @example
* ```ts
* // An identifier that we know will be in the
* // final shader bundle, but we cannot
* // refer to it in any other way.
* const existingGlobal = tgpu['~unstable']
* .rawCodeSnippet('EXISTING_GLOBAL', d.f32, 'constant');
*
* const foo = () => {
* 'use gpu';
* return existingGlobal.$ * 2;
* };
*
* const wgsl = tgpu.resolve([foo]);
* // fn foo() -> f32 {
* // return EXISTING_GLOBAL * 2;
* // }
* ```
*/
declare function rawCodeSnippet<TDataType extends AnyData>(expression: string, type: TDataType, origin?: RawCodeSnippetOrigin | undefined): TgpuRawCodeSnippet<TDataType>;
interface NameRegistry {

@@ -11,4 +63,5 @@ /**

* @param primer Used in the generation process, makes the identifier more recognizable.
* @param global Whether the name should be registered in the global scope (true), or in the current function scope (false)
*/
makeUnique(primer?: string): string;
makeUnique(primer: string | undefined, global: boolean): string;
/**

@@ -26,2 +79,4 @@ * Creates a valid WGSL identifier.

makeValid(primer: string): string;
pushFunctionScope(): void;
popFunctionScope(): void;
}

@@ -78,11 +133,2 @@

/**
* Map of external names to their resolvable values.
*/
externals: Record<string, Wgsl | object>;
/**
* The code template to use for the resolution. All external names will be replaced with their resolved values.
* @default ''
*/
template?: string | undefined;
/**
* The naming strategy used for generating identifiers for resolved externals and their dependencies.

@@ -114,4 +160,15 @@ *

}
interface TgpuExtendedResolveOptions extends TgpuResolveOptions {
/**
* Map of external names to their resolvable values.
*/
externals: Record<string, Wgsl | object>;
/**
* The code template to use for the resolution. All external names will be replaced with their resolved values.
* @default ''
*/
template?: string | undefined;
}
/**
* Resolves a template with external values. Each external will get resolved to a code string and replaced in the template.
* Resolves a template with external values. Each external that is used will get resolved to a code string and replaced in the template.
* Any dependencies of the externals will also be resolved and included in the output.

@@ -124,6 +181,3 @@ * @param options - The options for the resolution.

* ```ts
* const Gradient = d.struct({
* from: d.vec3f,
* to: d.vec3f,
* });
* const Gradient = d.struct({ from: d.vec3f, to: d.vec3f });
*

@@ -151,9 +205,10 @@ * const { code, usedBindGroupLayouts, catchall } = tgpu.resolveWithContext({

*/
declare function resolveWithContext(options: TgpuResolveOptions): ResolutionResult;
declare function resolveWithContext(options: TgpuExtendedResolveOptions): ResolutionResult;
/**
* Resolves a template with external values. Each external will get resolved to a code string and replaced in the template.
* Resolves given TypeGPU resources.
* Any dependencies of the externals will also be resolved and included in the output.
* @param items - An array of items to resolve.
* @param options - The options for the resolution.
*
* @returns The resolved code.
* @returns {ResolutionResult}
*

@@ -167,3 +222,34 @@ * @example

*
* const resolved = tgpu.resolve({
* const { code, usedBindGroupLayouts, catchall } =
* tgpu.resolveWithContext([Gradient]);
*
* console.log(code);
* // struct Gradient_0 {
* // from: vec3f,
* // to: vec3f,
* // }
* ```
*/
declare function resolveWithContext(items: ResolvableObject[], options?: TgpuResolveOptions): ResolutionResult;
/**
* A shorthand for calling `tgpu.resolveWithContext(...).code`.
*
* @example
* ```ts
* const Gradient = d.struct({ from: d.vec3f, to: d.vec3f });
*
* const resolved = tgpu.resolve([Gradient]);
*
* console.log(resolved);
* // struct Gradient_0 {
* // from: vec3f,
* // to: vec3f,
* // }
* ```
*
* @example
* ```ts
* const Gradient = d.struct({ from: d.vec3f, to: d.vec3f });
*
* const code = tgpu.resolve({
* template: `

@@ -179,3 +265,3 @@ * fn getGradientAngle(gradient: Gradient) -> f32 {

*
* console.log(resolved);
* console.log(code);
* // struct Gradient_0 {

@@ -190,3 +276,4 @@ * // from: vec3f,

*/
declare function resolve(options: TgpuResolveOptions): string;
declare function resolve(options: TgpuExtendedResolveOptions): string;
declare function resolve(items: ResolvableObject[], options?: TgpuResolveOptions): string;

@@ -284,3 +371,3 @@ interface SimulationResult<T> {

declare function accessor<T extends AnyWgslData>(schema: T, defaultValue?: TgpuFn<() => T> | TgpuBufferUsage<T> | Infer<T>): TgpuAccessor<T>;
declare function accessor<T extends AnyWgslData>(schema: T, defaultValue?: TgpuFn<() => T> | TgpuBufferUsage<T> | TgpuBufferShorthand<T> | Infer<T>): TgpuAccessor<T>;

@@ -351,2 +438,3 @@ declare function derived<T>(compute: () => T): TgpuDerived<T>;

computeFn: typeof computeFn;
comptime: typeof comptime;
/**

@@ -376,2 +464,3 @@ * @deprecated This feature is now stable, use tgpu.vertexLayout.

declare: typeof declare;
rawCodeSnippet: typeof rawCodeSnippet;
simulate: typeof simulate;

@@ -381,2 +470,2 @@ };

export { Configurable, type InitFromDeviceOptions, type InitOptions, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, type Namespace, NotUniformError, ResolutionError, TgpuAccessor, TgpuBindGroup, TgpuBindGroupLayout, TgpuBuffer, TgpuDerived, TgpuFn, TgpuRoot, TgpuSlot, TgpuVar, TgpuVertexLayout, tgpu as default, tgpu };
export { Configurable, type InitFromDeviceOptions, type InitOptions, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, type Namespace, NotUniformError, type RawCodeSnippetOrigin, ResolutionError, TgpuAccessor, TgpuBindGroup, TgpuBindGroupLayout, TgpuBuffer, TgpuDerived, TgpuFn, type TgpuRawCodeSnippet, TgpuRoot, TgpuSlot, TgpuVar, TgpuVertexLayout, tgpu as default, tgpu };
{
"name": "typegpu",
"private": false,
"version": "0.8.2",
"version": "0.9.0",
"description": "A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.",

@@ -50,3 +50,3 @@ "license": "MIT",

"dependencies": {
"tinyest": "~0.1.2",
"tinyest": "~0.2.0",
"typed-binary": "^4.3.1"

@@ -53,0 +53,0 @@ },

@@ -34,3 +34,3 @@ <div align="center">

const wgsl = tgpu.resolve({ externals: { main } });
const wgsl = tgpu.resolve([main]);
// ^? string

@@ -37,0 +37,0 @@

@@ -1,3 +0,4 @@

import { b9 as DualFn, dL as AnyNumericVecInstance, dM as AnyFloatVecInstance, dN as AnyIntegerVecInstance, bK as v3f, dO as v3h, dP as AnyMatInstance, I as Infer, b8 as WgslStruct, b4 as F32, b5 as I32, b3 as F16, dQ as AbstractFloat, dR as AbstractInt, aP as Vec2f, aS as Vec2i, aV as Vec3f, aX as Vec3i, a_ as Vec4f, b0 as Vec4i, aR as Vec2h, aW as Vec3h, a$ as Vec4h, bG as v2f, dS as v2h, bH as v2i, bL as v3i, bO as v4f, dT as v4h, bP as v4i, dU as AnyFloat32VecInstance, dV as AnySignedVecInstance, dW as vBaseForMat, dX as mBaseForVec, bA as m4x4f, bs as AnyVecInstance, dY as AnyVec2Instance, bF as v2b, dZ as AnyVec3Instance, bJ as v3b, bN as v4b, d_ as AnyBooleanVecInstance, d$ as atomicI32, e0 as atomicU32, bT as texture1d, c4 as textureStorage1d, bU as texture2d, bV as texture2dArray, bX as textureCube, bY as textureCubeArray, c5 as textureStorage2d, c6 as textureStorage2dArray, c2 as textureExternal, bI as v2u, bW as texture3d, c7 as textureStorage3d, bM as v3u, bQ as v4u, $ as $internal, c3 as textureMultisampled2d, e1 as StorageTextureFormats, e2 as TextureFormats, e3 as $repr, ct as sampler, bZ as textureDepth2d, b_ as textureDepth2dArray, b$ as textureDepthCube, cs as comparisonSampler, d as WgslExtension } from '../tgpuConstant-BTQFNlQH.js';
export { i as identity2, d as identity3, e as identity4, r as rotationX4, f as rotationY4, g as rotationZ4, s as scaling4, t as translation4 } from '../matrix-DIfOiRyz.js';
import { dO as DualFn, dP as AnyNumericVecInstance, dQ as AnyFloatVecInstance, dR as AnyIntegerVecInstance, bN as v3f, dS as v3h, dT as AnyMatInstance, o as Infer, a_ as WgslStruct, aW as F32, aX as I32, aV as F16, dU as AbstractFloat, dV as AbstractInt, aT as Vec2f, b3 as Vec2i, b6 as Vec3f, b8 as Vec3i, bb as Vec4f, bd as Vec4i, b2 as Vec2h, b7 as Vec3h, bc as Vec4h, bJ as v2f, dW as v2h, bK as v2i, bO as v3i, bR as v4f, dX as v4h, bS as v4i, dY as AnyFloat32VecInstance, dZ as AnySignedVecInstance, d_ as vBaseForMat, d$ as mBaseForVec, bD as m4x4f, bv as AnyVecInstance, e0 as AnyVec2Instance, bI as v2b, e1 as AnyVec3Instance, bM as v3b, bQ as v4b, e2 as AnyBooleanVecInstance, e3 as atomicI32, e4 as atomicU32, cz as ref, bW as texture1d, c7 as textureStorage1d, bX as texture2d, bY as texture2dArray, b_ as textureCube, b$ as textureCubeArray, c8 as textureStorage2d, c9 as textureStorage2dArray, c5 as textureExternal, bL as v2u, bZ as texture3d, ca as textureStorage3d, bP as v3u, bT as v4u, $ as $internal, c6 as textureMultisampled2d, e5 as StorageTextureFormats, e6 as TextureFormats, e7 as $repr, cw as sampler, c0 as textureDepth2d, c1 as textureDepth2dArray, c2 as textureDepthCube, cv as comparisonSampler, W as WgslExtension } from '../tgpuConstant-BOn7U_lv.js';
export { i as identity2, d as identity3, e as identity4, r as rotationX4, f as rotationY4, g as rotationZ4, s as scaling4, t as translation4 } from '../matrix-C4IFKU1R.js';
import { T as TgpuComptime } from '../comptime-DKpw1IVu.js';
import 'tinyest';

@@ -131,3 +132,3 @@

};
declare const frexp: FrexpOverload;
declare const frexp: DualFn<FrexpOverload>;
declare function cpuInsertBits(e: number, newbits: number, offset: number, count: number): number;

@@ -153,8 +154,8 @@ declare function cpuInsertBits<T extends AnyIntegerVecInstance>(e: T, newbits: T, offset: number, count: number): T;

declare const log2: DualFn<typeof cpuLog2>;
declare function cpuMax(a: number, b: number): number;
declare function cpuMax<T extends NumVec$1>(a: T, b: T): T;
declare const max: DualFn<typeof cpuMax>;
declare function cpuMin(a: number, b: number): number;
declare function cpuMin<T extends NumVec$1>(a: T, b: T): T;
declare const min: DualFn<typeof cpuMin>;
type VariadicOverload = {
(fst: number, ...rest: number[]): number;
<T extends NumVec$1>(fst: T, ...rest: T[]): T;
};
declare const max: DualFn<VariadicOverload>;
declare const min: DualFn<VariadicOverload>;
declare function cpuMix(e1: number, e2: number, e3: number): number;

@@ -459,5 +460,5 @@ declare function cpuMix<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: number): T;

type AnyAtomic = atomicI32 | atomicU32;
declare const workgroupBarrier: DualFn<() => void>;
declare const storageBarrier: DualFn<() => void>;
declare const textureBarrier: DualFn<() => void>;
declare const workgroupBarrier: DualFn<(...args: never[]) => unknown>;
declare const storageBarrier: DualFn<(...args: never[]) => unknown>;
declare const textureBarrier: DualFn<(...args: never[]) => unknown>;
declare const atomicLoad: DualFn<(<T extends AnyAtomic>(a: T) => number)>;

@@ -473,31 +474,14 @@ declare const atomicStore: DualFn<(<T extends AnyAtomic>(a: T, value: number) => void)>;

declare function cpuDpdx(value: number): number;
declare function cpuDpdx<T extends AnyFloat32VecInstance>(value: T): T;
declare const dpdx: DualFn<typeof cpuDpdx>;
declare function cpuDpdxCoarse(value: number): number;
declare function cpuDpdxCoarse<T extends AnyFloat32VecInstance>(value: T): T;
declare const dpdxCoarse: DualFn<typeof cpuDpdxCoarse>;
declare function cpuDpdxFine(value: number): number;
declare function cpuDpdxFine<T extends AnyFloat32VecInstance>(value: T): T;
declare const dpdxFine: DualFn<typeof cpuDpdxFine>;
declare function cpuDpdy(value: number): number;
declare function cpuDpdy<T extends AnyFloat32VecInstance>(value: T): T;
declare const dpdy: DualFn<typeof cpuDpdy>;
declare function cpuDpdyCoarse(value: number): number;
declare function cpuDpdyCoarse<T extends AnyFloat32VecInstance>(value: T): T;
declare const dpdyCoarse: DualFn<typeof cpuDpdyCoarse>;
declare function cpuDpdyFine(value: number): number;
declare function cpuDpdyFine<T extends AnyFloat32VecInstance>(value: T): T;
declare const dpdyFine: DualFn<typeof cpuDpdyFine>;
declare function cpuFwidth(value: number): number;
declare function cpuFwidth<T extends AnyFloat32VecInstance>(value: T): T;
declare const fwidth: DualFn<typeof cpuFwidth>;
declare function cpuFwidthCoarse(value: number): number;
declare function cpuFwidthCoarse<T extends AnyFloat32VecInstance>(value: T): T;
declare const fwidthCoarse: DualFn<typeof cpuFwidthCoarse>;
declare function cpuFwidthFine(value: number): number;
declare function cpuFwidthFine<T extends AnyFloat32VecInstance>(value: T): T;
declare const fwidthFine: DualFn<typeof cpuFwidthFine>;
type DerivativeSignature = ((value: number) => number) & (<T extends AnyFloat32VecInstance>(value: T) => T);
declare const dpdx: DualFn<DerivativeSignature>;
declare const dpdxCoarse: DualFn<DerivativeSignature>;
declare const dpdxFine: DualFn<DerivativeSignature>;
declare const dpdy: DualFn<DerivativeSignature>;
declare const dpdyCoarse: DualFn<DerivativeSignature>;
declare const dpdyFine: DualFn<DerivativeSignature>;
declare const fwidth: DualFn<DerivativeSignature>;
declare const fwidthCoarse: DualFn<DerivativeSignature>;
declare const fwidthFine: DualFn<DerivativeSignature>;
declare const arrayLength: DualFn<(a: unknown[]) => number>;
declare const arrayLength: DualFn<(a: unknown[] | ref<unknown[]>) => number>;

@@ -636,3 +620,3 @@ /**

declare const extensionEnabled: DualFn<(extensionName: WgslExtension) => boolean>;
declare const extensionEnabled: TgpuComptime<(extensionName: WgslExtension) => boolean>;

@@ -639,0 +623,0 @@ type BitcastU32toF32Overload = ((value: number) => number) & ((value: v2u) => v2f) & ((value: v3u) => v3f) & ((value: v4u) => v4f);

@@ -1,2 +0,2 @@

import{a as G,c as nt,d as ut,e as at,f as pt,g as st,h as it,i as P,k as mt,l as dt,m as lt,n as ct,o as xt,p as Tt,q as ft,r as yt,s as bt,t as vt,u as gt,v as It,w as ht,x as wt}from"../chunk-PWBIFP67.js";import{a as U}from"../chunk-6U5HPHCJ.js";import{$ as z,$a as ze,Aa as he,Ba as we,Ca as Ce,Da as Ae,Ea as Se,Fa as Ee,Ga as De,Ha as $e,Ia as Fe,Ja as Oe,Ka as Ve,La as Le,Ma as We,Na as Be,Oa as Ne,Pa as _e,Qa as Me,R as M,Ra as Ge,Sa as Pe,Ta as Ue,Ua as ke,Va as Xe,Wa as Re,X as j,Xa as Ze,Y,Ya as je,Z as F,Za as Ye,_ as q,_a as qe,aa as H,ab as He,b as X,ba as J,bb as Je,c as R,ca as K,cb as Ke,d as Z,da as Q,db as Qe,e as C,ea as ee,eb as et,f as A,fa as te,fb as tt,g as S,ga as re,gb as rt,h as E,ha as oe,hb as ot,i as D,ia as ne,ja as ue,ka as ae,la as pe,ma as se,na as ie,oa as me,pa as de,qa as le,ra as ce,sa as xe,ta as Te,ua as fe,va as ye,wa as be,xa as ve,ya as ge,za as Ie}from"../chunk-ECR2EGZX.js";import{Aa as V,B as l,C as O,Da as L,E as $,Ea as r,Ha as y,La as u,Na as n,Oa as W,Qa as T,Ra as m,Ta as g,Ua as I,_a as B,a as p,aa as o,db as N,fb as b,hb as _,ib as w,lb as c,q as x}from"../chunk-CRZWTZM2.js";var Ct=u(()=>{throw new Error("`discard` relies on GPU resources and cannot be executed outside of a draw call")},()=>o("discard;",x),"discard");var h=F[p].jsImpl,At=C[p].jsImpl,St=C[p].gpuImpl,Et=A[p].jsImpl,Dt=A[p].gpuImpl,$t=S[p].jsImpl,Ft=S[p].gpuImpl,Ot=E[p].jsImpl,Vt=E[p].gpuImpl,Lt=D[p].jsImpl,Wt=D[p].gpuImpl,Bt=u((e,t)=>h(At(t),e),(e,t)=>o(r`(${St(t)} * ${e})`,e.dataType),"translate4"),Nt=u((e,t)=>h(Et(t),e),(e,t)=>o(r`(${Dt(t)} * ${e})`,e.dataType),"scale4"),_t=u((e,t)=>h($t(t),e),(e,t)=>o(r`(${Ft(t)} * ${e})`,e.dataType),"rotateX4"),Mt=u((e,t)=>h(Ot(t),e),(e,t)=>o(r`(${Vt(t)} * ${e})`,e.dataType),"rotateY4"),Gt=u((e,t)=>h(Lt(t),e),(e,t)=>o(r`(${Wt(t)} * ${e})`,e.dataType),"rotateZ4");var Pt=u(()=>console.warn("workgroupBarrier is a no-op outside of CODEGEN mode."),()=>o("workgroupBarrier()",x),"workgroupBarrier"),Ut=u(()=>console.warn("storageBarrier is a no-op outside of CODEGEN mode."),()=>o("storageBarrier()",x),"storageBarrier"),kt=u(()=>console.warn("textureBarrier is a no-op outside of CODEGEN mode."),()=>o("textureBarrier()",x),"textureBarrier"),Xt=u(e=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},e=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicLoad(&${e})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicLoad"),Rt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(!l(e.dataType)||e.dataType.type!=="atomic")throw new Error(`Invalid atomic type: ${c(e.dataType)}`);return o(r`atomicStore(&${e}, ${t})`,x)},"atomicStore"),f=(e,t)=>e.dataType.type==="atomic"&&e.dataType.inner.type==="i32"?[e.dataType,g]:[e.dataType,m],Zt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicAdd(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicAdd",f),jt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicSub(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicSub",f),Yt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicMax(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicMax",f),qt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicMin(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicMin",f),zt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicAnd(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicAnd",f),Ht=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicOr(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicOr",f),Jt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicXor(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicXor",f);function Kt(e){throw new Error("Derivative builtins are not allowed on the cpu")}var Qt=u(Kt,e=>o(r`dpdx(${e})`,e.dataType),"dpdx");function er(e){throw new Error("Derivative builtins are not allowed on the cpu")}var tr=u(er,e=>o(r`dpdxCoarse(${e})`,e.dataType),"dpdxCoarse");function rr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var or=u(rr,e=>o(r`dpdxFine(${e})`,e.dataType),"dpdxFine");function nr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var ur=u(nr,e=>o(r`dpdy(${e})`,e.dataType),"dpdy");function ar(e){throw new Error("Derivative builtins are not allowed on the cpu")}var pr=u(ar,e=>o(r`dpdyCoarse(${e})`,e.dataType),"dpdyCoarse");function sr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var ir=u(sr,e=>o(r`dpdyFine(${e})`,e.dataType),"dpdyFine");function mr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var dr=u(mr,e=>o(r`fwidth(${e})`,e.dataType),"fwidth");function lr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var cr=u(lr,e=>o(r`fwidthCoarse(${e})`,e.dataType),"fwidthCoarse");function xr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var Tr=u(xr,e=>o(r`fwidthFine(${e})`,e.dataType),"fwidthFine");var k=e=>$(e)&&O(e.inner)?e.inner.elementCount:0,fr=n({name:"arrayLength",signature:e=>{let t=$(e)?e:U(e);return{argTypes:[t],returnType:k(t)>0?W:m}},normalImpl:e=>e.length,codegenImpl(e){let t=k(e.dataType);return t>0?String(t):r`arrayLength(${e})`}});function yr(e,t,d,i,s){throw new Error("Texture sampling relies on GPU resources and cannot be executed outside of a draw call")}var br=n({name:"textureSample",normalImpl:yr,codegenImpl:(...e)=>r`textureSample(${e})`,signature:(...e)=>{let t=e[0].type.startsWith("texture_depth");return{argTypes:e,returnType:t?I:b}}});function vr(e,t,d,i,s,v){throw new Error("Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call")}var gr=n({name:"textureSampleBias",normalImpl:vr,codegenImpl:(...e)=>r`textureSampleBias(${e})`,signature:(...e)=>({argTypes:e,returnType:b})});function Ir(e,t,d,i,s,v){throw new Error("Texture sampling relies on GPU resources and cannot be executed outside of a draw call")}var hr=n({name:"textureSampleLevel",normalImpl:Ir,codegenImpl:(...e)=>r`textureSampleLevel(${e})`,signature:(...e)=>{let t=e[0].type.startsWith("texture_depth");return{argTypes:e,returnType:t?I:b}}});function wr(e,t,d){throw new Error("`textureLoad` relies on GPU resources and cannot be executed outside of a draw call")}var Cr=n({name:"textureLoad",normalImpl:wr,codegenImpl:(...e)=>r`textureLoad(${e})`,signature:(...e)=>{let t=e[0];if(M(t)){let s=t.type.startsWith("texture_depth"),v=t.sampleType;return{argTypes:e,returnType:s?I:v.type==="f32"?b:v.type==="u32"?w:_}}let d=t.format,i=G[d].vectorType;return{argTypes:e,returnType:i}}});function Ar(e,t,d,i){throw new Error("`textureStore` relies on GPU resources and cannot be executed outside of a draw call")}var Sr=n({name:"textureStore",normalImpl:Ar,codegenImpl:(...e)=>r`textureStore(${e})`,signature:(...e)=>({argTypes:e,returnType:x})});function Er(e,t){throw new Error("`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call")}var Dr=n({name:"textureDimensions",normalImpl:Er,codegenImpl:(...e)=>r`textureDimensions(${e})`,signature:(...e)=>{let t=e[0].dimension;return t==="1d"?{argTypes:e,returnType:m}:t==="3d"?{argTypes:e,returnType:N}:{argTypes:e,returnType:B}}});function $r(e,t,d,i,s,v){throw new Error("Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call")}var Fr=n({name:"textureSampleCompare",normalImpl:$r,codegenImpl:(...e)=>r`textureSampleCompare(${e})`,signature:(...e)=>({argTypes:e,returnType:I})});function Or(e,t,d){throw new Error("Texture sampling with base clamp to edge is not supported outside of GPU mode.")}var Vr=n({name:"textureSampleBaseClampToEdge",normalImpl:Or,codegenImpl:(...e)=>r`textureSampleBaseClampToEdge(${e})`,signature:(...e)=>({argTypes:e,returnType:b})});var a="Subgroup operations can only be used in the GPU context.",Lr=n({name:"subgroupAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupAdd(${e})`}),Wr=n({name:"subgroupExclusiveAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupExclusiveAdd(${e})`}),Br=n({name:"subgroupInclusiveAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupInclusiveAdd(${e})`}),Nr=n({name:"subgroupAll",signature:{argTypes:[T],returnType:T},normalImpl:a,codegenImpl:e=>r`subgroupAll(${e})`}),_r=n({name:"subgroupAnd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupAnd(${e})`}),Mr=n({name:"subgroupAny",signature:{argTypes:[T],returnType:T},normalImpl:a,codegenImpl:e=>r`subgroupAny(${e})`}),Gr=n({name:"subgroupBallot",signature:{argTypes:[T],returnType:w},normalImpl:a,codegenImpl:e=>r`subgroupBallot(${e})`}),Pr=n({name:"subgroupBroadcast",signature:(...e)=>{let t=y([e[1]],[g,m]);if(!t)throw new Error(`subgroupBroadcast's second argument has to be compatible with i32 or u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:a,codegenImpl:(e,t)=>r`subgroupBroadcast(${e}, ${t})`}),Ur=n({name:"subgroupBroadcastFirst",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupBroadcastFirst(${e})`}),kr=n({name:"subgroupElect",signature:{argTypes:[],returnType:T},normalImpl:a,codegenImpl:()=>r`subgroupElect()`}),Xr=n({name:"subgroupMax",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupMax(${e})`}),Rr=n({name:"subgroupMin",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupMin(${e})`}),Zr=n({name:"subgroupMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupMul(${e})`}),jr=n({name:"subgroupExclusiveMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupExclusiveMul(${e})`}),Yr=n({name:"subgroupInclusiveMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupInclusiveMul(${e})`}),qr=n({name:"subgroupOr",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupOr(${e})`}),zr=n({name:"subgroupShuffle",signature:(...e)=>{let t=y([e[1]],[g,m]);if(!t)throw new Error(`subgroupShuffle's second argument has to be compatible with i32 or u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:a,codegenImpl:(e,t)=>r`subgroupShuffle(${e}, ${t})`}),Hr=n({name:"subgroupShuffleDown",signature:(...e)=>{let t=y([e[1]],[m]);if(!t)throw new Error(`subgroupShuffleDown's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:a,codegenImpl:(e,t)=>r`subgroupShuffleDown(${e}, ${t})`}),Jr=n({name:"subgroupShuffleUp",signature:(...e)=>{let t=y([e[1]],[m]);if(!t)throw new Error(`subgroupShuffleUp's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:a,codegenImpl:(e,t)=>r`subgroupShuffleUp(${e}, ${t})`}),Kr=n({name:"subgroupShuffleXor",signature:(...e)=>{let t=y([e[1]],[m]);if(!t)throw new Error(`subgroupShuffleXor's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:a,codegenImpl:(e,t)=>r`subgroupShuffleXor(${e}, ${t})`}),Qr=n({name:"subgroupXor",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupXor(${e})`});var eo=(()=>{let e=i=>{let s=V();if(!s)throw new Error("extensionEnabled can only be called in a GPU codegen context.");return(s.enableExtensions??[]).includes(i)},t=i=>{let{value:s}=i;if(typeof s!="string"||!P.includes(s))throw new Error(`extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: ${s}`);return o(e(s),T)},d=i=>{if(L())return t(i);throw new Error("extensionEnabled can only be called in a GPU codegen context.")};return Object.defineProperty(d,p,{value:{jsImpl:e,gpuImpl:t,argConversionHint:"keep"}}),d})();export{J as abs,K as acos,Q as acosh,j as add,gt as all,mt as allEq,vt as and,It as any,fr as arrayLength,ee as asin,te as asinh,re as atan,ne as atan2,oe as atanh,Zt as atomicAdd,zt as atomicAnd,Xt as atomicLoad,Yt as atomicMax,qt as atomicMin,Ht as atomicOr,Rt as atomicStore,jt as atomicSub,Jt as atomicXor,nt as bitcastU32toF32,ut as bitcastU32toI32,ue as ceil,ae as clamp,pe as cos,se as cosh,ie as countLeadingZeros,me as countOneBits,de as countTrailingZeros,le as cross,ce as degrees,xe as determinant,Ct as discard,Te as distance,q as div,fe as dot,be as dot4I8Packed,ye as dot4U8Packed,Qt as dpdx,tr as dpdxCoarse,or as dpdxFine,ur as dpdy,pr as dpdyCoarse,ir as dpdyFine,dt as eq,ve as exp,ge as exp2,eo as extensionEnabled,Ie as extractBits,he as faceForward,we as firstLeadingBit,Ce as firstTrailingBit,Ae as floor,Se as fma,Ee as fract,De as frexp,dr as fwidth,cr as fwidthCoarse,Tr as fwidthFine,ft as ge,Tt as gt,X as identity2,R as identity3,Z as identity4,$e as insertBits,Fe as inverseSqrt,ht as isCloseTo,Oe as ldexp,xt as le,Ve as length,Le as log,We as log2,ct as lt,Be as max,Ne as min,_e as mix,z as mod,Me as modf,F as mul,lt as ne,H as neg,Ge as normalize,yt as not,bt as or,pt as pack2x16float,it as pack4x8unorm,Pe as pow,Ue as quantizeToF16,ke as radians,Xe as reflect,Re as refract,Ze as reverseBits,_t as rotateX4,Mt as rotateY4,Gt as rotateZ4,S as rotationX4,E as rotationY4,D as rotationZ4,je as round,Ye as saturate,Nt as scale4,A as scaling4,wt as select,qe as sign,ze as sin,He as sinh,Je as smoothstep,Ke as sqrt,Qe as step,Ut as storageBarrier,Y as sub,Lr as subgroupAdd,Nr as subgroupAll,_r as subgroupAnd,Mr as subgroupAny,Gr as subgroupBallot,Pr as subgroupBroadcast,Ur as subgroupBroadcastFirst,kr as subgroupElect,Wr as subgroupExclusiveAdd,jr as subgroupExclusiveMul,Br as subgroupInclusiveAdd,Yr as subgroupInclusiveMul,Xr as subgroupMax,Rr as subgroupMin,Zr as subgroupMul,qr as subgroupOr,zr as subgroupShuffle,Hr as subgroupShuffleDown,Jr as subgroupShuffleUp,Kr as subgroupShuffleXor,Qr as subgroupXor,et as tan,tt as tanh,kt as textureBarrier,Dr as textureDimensions,Cr as textureLoad,br as textureSample,Vr as textureSampleBaseClampToEdge,gr as textureSampleBias,Fr as textureSampleCompare,hr as textureSampleLevel,Sr as textureStore,Bt as translate4,C as translation4,rt as transpose,ot as trunc,at as unpack2x16float,st as unpack4x8unorm,Pt as workgroupBarrier};
import{$ as Je,A as Ce,Aa as ht,B as Ae,Ba as St,C as $e,Ca as Ct,D as we,Da as At,E as De,Ea as $t,F as Ee,G as Le,H as Oe,I as Be,J as We,K as Fe,L as Ve,M as _e,N as Me,O as Ne,P as Ge,Q as Pe,R as Ue,S as Xe,T as ke,U as Re,V as Ze,W as Ye,X as je,Y as qe,Z as ze,_ as He,a as k,aa as Ke,ba as Qe,c as ee,ca as et,d as te,da as tt,e as re,ea as rt,f as oe,fa as ot,g as ne,ga as nt,h as ue,ha as ut,i as ae,ia as at,j as se,ja as st,k as pe,ka as pt,l as me,la as mt,m as ie,ma as it,n as le,na as lt,o as de,oa as dt,p as ce,pa as R,q as xe,r as fe,ra as ct,s as ge,sa as xt,t as Te,ta as ft,u as ye,ua as gt,v as be,va as Tt,w as ve,wa as yt,x as Ie,xa as bt,y as he,ya as vt,z as Se,za as It}from"../chunk-5ABKYSJD.js";import{Q as X,b as Y,c as j,d as q,e as S,f as C,g as A,h as $,i as w,l as c,r as z,s as H,t as O,u as J,v as K,w as Q}from"../chunk-EHLRP4V2.js";import{Ab as h,C as W,E,Ha as F,Hb as U,Ib as D,La as o,Ma as V,Va as _,_a as g,a,db as r,eb as M,gb as l,hb as u,jb as T,kb as d,q as p,qb as N,sb as L,vb as G,xb as y,zb as P}from"../chunk-SHSILTWI.js";var wt=r({name:"discard",normalImpl:"`discard` relies on GPU resources and cannot be executed outside of a draw call",signature:{argTypes:[],returnType:p},codegenImpl:()=>"discard;"});var I=O[a].jsImpl,Dt=S[a].jsImpl,Et=S[a].gpuImpl,Lt=C[a].jsImpl,Ot=C[a].gpuImpl,Bt=A[a].jsImpl,Wt=A[a].gpuImpl,Ft=$[a].jsImpl,Vt=$[a].gpuImpl,_t=w[a].jsImpl,Mt=w[a].gpuImpl,Nt=r({name:"translate4",normalImpl:(e,t)=>I(Dt(t),e),signature:{argTypes:[c,L],returnType:c},codegenImpl:(e,t)=>o`(${Et(t)} * ${e})`}),Gt=r({name:"scale4",normalImpl:(e,t)=>I(Lt(t),e),signature:{argTypes:[c,L],returnType:c},codegenImpl:(e,t)=>o`(${Ot(t)} * ${e})`}),B={argTypes:[c,d],returnType:c},Pt=r({name:"rotateX4",normalImpl:(e,t)=>I(Bt(t),e),signature:B,codegenImpl:(e,t)=>o`(${Wt(t)} * ${e})`}),Ut=r({name:"rotateY4",normalImpl:(e,t)=>I(Ft(t),e),signature:B,codegenImpl:(e,t)=>o`(${Vt(t)} * ${e})`}),Xt=r({name:"rotateZ4",normalImpl:(e,t)=>I(_t(t),e),signature:B,codegenImpl:(e,t)=>o`(${Mt(t)} * ${e})`});var kt=r({name:"workgroupBarrier",normalImpl:"workgroupBarrier is a no-op outside of CODEGEN mode.",signature:{argTypes:[],returnType:p},codegenImpl:()=>"workgroupBarrier()"}),Rt=r({name:"storageBarrier",normalImpl:"storageBarrier is a no-op outside of CODEGEN mode.",signature:{argTypes:[],returnType:p},codegenImpl:()=>"storageBarrier()"}),Zt=r({name:"textureBarrier",normalImpl:"textureBarrier is a no-op outside of CODEGEN mode.",signature:{argTypes:[],returnType:p},codegenImpl:()=>"textureBarrier()"}),m="Atomic operations are not supported outside of CODEGEN mode.",Yt=r({name:"atomicLoad",normalImpl:m,signature:e=>{if(e.type!=="atomic")throw new Error(`Invalid atomic type: ${D(e)}`);return{argTypes:[e],returnType:e.inner}},codegenImpl:e=>o`atomicLoad(&${e})`}),jt=(e,t)=>{if(e.type!=="atomic")throw new Error(`Invalid atomic type: ${D(e)}`);return{argTypes:[e,e.inner.type==="u32"?u:T],returnType:p}},x=(e,t)=>{if(e.type!=="atomic")throw new Error(`Invalid atomic type: ${D(e)}`);let s=e.inner.type==="u32"?u:T;return{argTypes:[e,s],returnType:s}},qt=r({name:"atomicStore",normalImpl:m,signature:jt,codegenImpl:(e,t)=>o`atomicStore(&${e}, ${t})`}),zt=r({name:"atomicAdd",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicAdd(&${e}, ${t})`}),Ht=r({name:"atomicSub",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicSub(&${e}, ${t})`}),Jt=r({name:"atomicMax",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicMax(&${e}, ${t})`}),Kt=r({name:"atomicMin",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicMin(&${e}, ${t})`}),Qt=r({name:"atomicAnd",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicAnd(&${e}, ${t})`}),er=r({name:"atomicOr",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicOr(&${e}, ${t})`}),tr=r({name:"atomicXor",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicXor(&${e}, ${t})`});var i="Derivative builtins are not allowed on the CPU",rr=r({name:"dpdx",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdx(${e})`}),or=r({name:"dpdxCoarse",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdxCoarse(${e})`}),nr=r({name:"dpdxFine",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdxFine(${e})`}),ur=r({name:"dpdy",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdy(${e})`}),ar=r({name:"dpdyCoarse",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdyCoarse(${e})`}),sr=r({name:"dpdyFine",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdyFine(${e})`}),pr=r({name:"fwidth",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`fwidth(${e})`}),mr=r({name:"fwidthCoarse",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`fwidthCoarse(${e})`}),ir=r({name:"fwidthFine",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`fwidthFine(${e})`});var Z=e=>E(e)&&W(e.inner)?e.inner.elementCount:0,lr=r({name:"arrayLength",signature:e=>{let t=E(e)?e:V(e);return{argTypes:[t],returnType:Z(t)>0?M:u}},normalImpl:e=>_(e)?e.$.length:e.length,codegenImpl(e){let t=Z(e.dataType);return t>0?String(t):o`arrayLength(${e})`}});function dr(e,t,s,f,b){throw new Error("Texture sampling relies on GPU resources and cannot be executed outside of a draw call")}var cr=r({name:"textureSample",normalImpl:dr,codegenImpl:(...e)=>o`textureSample(${e})`,signature:(...e)=>{let t=e[0].type.startsWith("texture_depth");return{argTypes:e,returnType:t?d:y}}});function xr(e,t,s,f,b,v){throw new Error("Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call")}var fr=r({name:"textureSampleBias",normalImpl:xr,codegenImpl:(...e)=>o`textureSampleBias(${e})`,signature:(...e)=>({argTypes:e,returnType:y})});function gr(e,t,s,f,b,v){throw new Error("Texture sampling relies on GPU resources and cannot be executed outside of a draw call")}var Tr=r({name:"textureSampleLevel",normalImpl:gr,codegenImpl:(...e)=>o`textureSampleLevel(${e})`,signature:(...e)=>{let t=e[0].type.startsWith("texture_depth");return{argTypes:e,returnType:t?d:y}}});function yr(e,t,s){throw new Error("`textureLoad` relies on GPU resources and cannot be executed outside of a draw call")}var br=r({name:"textureLoad",normalImpl:yr,codegenImpl:(...e)=>o`textureLoad(${e})`,signature:(...e)=>{let t=e[0];if(X(t)){let b=t.type.startsWith("texture_depth"),v=t.sampleType;return{argTypes:e,returnType:b?d:v.type==="f32"?y:v.type==="u32"?h:P}}let s=t.format,f=k(s).vectorType;return{argTypes:e,returnType:f}}});function vr(e,t,s,f){throw new Error("`textureStore` relies on GPU resources and cannot be executed outside of a draw call")}var Ir=r({name:"textureStore",normalImpl:vr,codegenImpl:(...e)=>o`textureStore(${e})`,signature:(...e)=>({argTypes:e,returnType:p})});function hr(e,t){throw new Error("`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call")}var Sr=r({name:"textureDimensions",normalImpl:hr,codegenImpl:(...e)=>o`textureDimensions(${e})`,signature:(...e)=>{let t=e[0].dimension;return t==="1d"?{argTypes:e,returnType:u}:t==="3d"?{argTypes:e,returnType:G}:{argTypes:e,returnType:N}}});function Cr(e,t,s,f,b,v){throw new Error("Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call")}var Ar=r({name:"textureSampleCompare",normalImpl:Cr,codegenImpl:(...e)=>o`textureSampleCompare(${e})`,signature:(...e)=>({argTypes:e,returnType:d})});function $r(e,t,s){throw new Error("Texture sampling with base clamp to edge is not supported outside of GPU mode.")}var wr=r({name:"textureSampleBaseClampToEdge",normalImpl:$r,codegenImpl:(...e)=>o`textureSampleBaseClampToEdge(${e})`,signature:(...e)=>({argTypes:e,returnType:y})});var n="Subgroup operations can only be used in the GPU context.",Dr=r({name:"subgroupAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupAdd(${e})`}),Er=r({name:"subgroupExclusiveAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupExclusiveAdd(${e})`}),Lr=r({name:"subgroupInclusiveAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupInclusiveAdd(${e})`}),Or=r({name:"subgroupAll",signature:{argTypes:[l],returnType:l},normalImpl:n,codegenImpl:e=>o`subgroupAll(${e})`}),Br=r({name:"subgroupAnd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupAnd(${e})`}),Wr=r({name:"subgroupAny",signature:{argTypes:[l],returnType:l},normalImpl:n,codegenImpl:e=>o`subgroupAny(${e})`}),Fr=r({name:"subgroupBallot",signature:{argTypes:[l],returnType:h},normalImpl:n,codegenImpl:e=>o`subgroupBallot(${e})`}),Vr=r({name:"subgroupBroadcast",signature:(...e)=>{let t=g([e[1]],[T,u]);if(!t)throw new Error(`subgroupBroadcast's second argument has to be compatible with i32 or u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupBroadcast(${e}, ${t})`}),_r=r({name:"subgroupBroadcastFirst",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupBroadcastFirst(${e})`}),Mr=r({name:"subgroupElect",signature:{argTypes:[],returnType:l},normalImpl:n,codegenImpl:()=>o`subgroupElect()`}),Nr=r({name:"subgroupMax",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupMax(${e})`}),Gr=r({name:"subgroupMin",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupMin(${e})`}),Pr=r({name:"subgroupMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupMul(${e})`}),Ur=r({name:"subgroupExclusiveMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupExclusiveMul(${e})`}),Xr=r({name:"subgroupInclusiveMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupInclusiveMul(${e})`}),kr=r({name:"subgroupOr",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupOr(${e})`}),Rr=r({name:"subgroupShuffle",signature:(...e)=>{let t=g([e[1]],[T,u]);if(!t)throw new Error(`subgroupShuffle's second argument has to be compatible with i32 or u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupShuffle(${e}, ${t})`}),Zr=r({name:"subgroupShuffleDown",signature:(...e)=>{let t=g([e[1]],[u]);if(!t)throw new Error(`subgroupShuffleDown's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupShuffleDown(${e}, ${t})`}),Yr=r({name:"subgroupShuffleUp",signature:(...e)=>{let t=g([e[1]],[u]);if(!t)throw new Error(`subgroupShuffleUp's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupShuffleUp(${e}, ${t})`}),jr=r({name:"subgroupShuffleXor",signature:(...e)=>{let t=g([e[1]],[u]);if(!t)throw new Error(`subgroupShuffleXor's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupShuffleXor(${e}, ${t})`}),qr=r({name:"subgroupXor",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupXor(${e})`});var zr=U(e=>{let t=F();if(!t)throw new Error("Functions using `extensionEnabled` cannot be called directly. Either generate WGSL from them, or use tgpu['~unstable'].simulate(...)");if(typeof e!="string"||!R.includes(e))throw new Error(`extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: '${e}'`);return(t.enableExtensions??[]).includes(e)});export{ee as abs,te as acos,re as acosh,z as add,St as all,ct as allEq,ht as and,Ct as any,lr as arrayLength,oe as asin,ne as asinh,ue as atan,se as atan2,ae as atanh,zt as atomicAdd,Qt as atomicAnd,Yt as atomicLoad,Jt as atomicMax,Kt as atomicMin,er as atomicOr,qt as atomicStore,Ht as atomicSub,tr as atomicXor,st as bitcastU32toF32,pt as bitcastU32toI32,pe as ceil,me as clamp,ie as cos,le as cosh,de as countLeadingZeros,ce as countOneBits,xe as countTrailingZeros,fe as cross,ge as degrees,Te as determinant,wt as discard,ye as distance,J as div,be as dot,Ie as dot4I8Packed,ve as dot4U8Packed,rr as dpdx,or as dpdxCoarse,nr as dpdxFine,ur as dpdy,ar as dpdyCoarse,sr as dpdyFine,xt as eq,he as exp,Se as exp2,zr as extensionEnabled,Ce as extractBits,Ae as faceForward,$e as firstLeadingBit,we as firstTrailingBit,De as floor,Ee as fma,Le as fract,Oe as frexp,pr as fwidth,mr as fwidthCoarse,ir as fwidthFine,bt as ge,yt as gt,Y as identity2,j as identity3,q as identity4,Be as insertBits,We as inverseSqrt,At as isCloseTo,Fe as ldexp,Tt as le,Ve as length,_e as log,Me as log2,gt as lt,Ne as max,Ge as min,Pe as mix,K as mod,Ue as modf,O as mul,ft as ne,Q as neg,Xe as normalize,vt as not,It as or,it as pack2x16float,dt as pack4x8unorm,ke as pow,Re as quantizeToF16,Ze as radians,Ye as reflect,je as refract,qe as reverseBits,Pt as rotateX4,Ut as rotateY4,Xt as rotateZ4,A as rotationX4,$ as rotationY4,w as rotationZ4,ze as round,He as saturate,Gt as scale4,C as scaling4,$t as select,Je as sign,Ke as sin,Qe as sinh,et as smoothstep,tt as sqrt,rt as step,Rt as storageBarrier,H as sub,Dr as subgroupAdd,Or as subgroupAll,Br as subgroupAnd,Wr as subgroupAny,Fr as subgroupBallot,Vr as subgroupBroadcast,_r as subgroupBroadcastFirst,Mr as subgroupElect,Er as subgroupExclusiveAdd,Ur as subgroupExclusiveMul,Lr as subgroupInclusiveAdd,Xr as subgroupInclusiveMul,Nr as subgroupMax,Gr as subgroupMin,Pr as subgroupMul,kr as subgroupOr,Rr as subgroupShuffle,Zr as subgroupShuffleDown,Yr as subgroupShuffleUp,jr as subgroupShuffleXor,qr as subgroupXor,ot as tan,nt as tanh,Zt as textureBarrier,Sr as textureDimensions,br as textureLoad,cr as textureSample,wr as textureSampleBaseClampToEdge,fr as textureSampleBias,Ar as textureSampleCompare,Tr as textureSampleLevel,Ir as textureStore,Nt as translate4,S as translation4,ut as transpose,at as trunc,mt as unpack2x16float,lt as unpack4x8unorm,kt as workgroupBarrier};
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/std/discard.ts","../../src/std/matrix.ts","../../src/std/atomic.ts","../../src/std/derivative.ts","../../src/std/array.ts","../../src/std/texture.ts","../../src/std/subgroup.ts","../../src/std/extensions.ts"],"sourcesContent":["import { snip } from '../data/snippet.ts';\nimport { Void } from '../data/wgslTypes.ts';\nimport { createDualImpl } from '../core/function/dualImpl.ts';\n\nexport const discard = createDualImpl(\n // CPU\n (): never => {\n throw new Error(\n '`discard` relies on GPU resources and cannot be executed outside of a draw call',\n );\n },\n // GPU\n () => snip('discard;', Void),\n 'discard',\n);\n","import { stitch } from '../core/resolve/stitch.ts';\nimport { snip } from '../data/snippet.ts';\nimport {\n rotationX4,\n rotationY4,\n rotationZ4,\n scaling4,\n translation4,\n} from '../data/matrix.ts';\nimport type { m4x4f, v3f } from '../data/wgslTypes.ts';\nimport { createDualImpl } from '../core/function/dualImpl.ts';\nimport { mul } from './operators.ts';\nimport { $internal } from '../shared/symbols.ts';\n\nconst cpuMul = mul[$internal].jsImpl;\n\nconst cpuTranslation4 = translation4[$internal].jsImpl;\nconst gpuTranslation4 = translation4[$internal].gpuImpl;\n\nconst cpuScaling4 = scaling4[$internal].jsImpl;\nconst gpuScaling4 = scaling4[$internal].gpuImpl;\n\nconst cpuRotationX4 = rotationX4[$internal].jsImpl;\nconst gpuRotationX4 = rotationX4[$internal].gpuImpl;\n\nconst cpuRotationY4 = rotationY4[$internal].jsImpl;\nconst gpuRotationY4 = rotationY4[$internal].gpuImpl;\n\nconst cpuRotationZ4 = rotationZ4[$internal].jsImpl;\nconst gpuRotationZ4 = rotationZ4[$internal].gpuImpl;\n\n/**\n * Translates the given 4-by-4 matrix by the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - The vector by which to translate the matrix.\n * @returns {m4x4f} The translated matrix.\n */\nexport const translate4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, vector: v3f) => cpuMul(cpuTranslation4(vector), matrix),\n // GPU implementation\n (matrix, vector) =>\n snip(stitch`(${gpuTranslation4(vector)} * ${matrix})`, matrix.dataType),\n 'translate4',\n);\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by an amount given by the corresponding entry in the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.\n * @returns {m4x4f} The scaled matrix.\n */\nexport const scale4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, vector: v3f) => cpuMul(cpuScaling4(vector), matrix),\n // GPU implementation\n (matrix, vector) =>\n snip(stitch`(${(gpuScaling4(vector))} * ${matrix})`, matrix.dataType),\n 'scale4',\n);\n\n/**\n * Rotates the given 4-by-4 matrix around the x-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateX4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, angle: number) => cpuMul(cpuRotationX4(angle), matrix),\n // GPU implementation\n (matrix, angle) =>\n snip(stitch`(${(gpuRotationX4(angle))} * ${matrix})`, matrix.dataType),\n 'rotateX4',\n);\n\n/**\n * Rotates the given 4-by-4 matrix around the y-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateY4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, angle: number) => cpuMul(cpuRotationY4(angle), matrix),\n // GPU implementation\n (matrix, angle) =>\n snip(stitch`(${(gpuRotationY4(angle))} * ${matrix})`, matrix.dataType),\n 'rotateY4',\n);\n\n/**\n * Rotates the given 4-by-4 matrix around the z-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateZ4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, angle: number) => cpuMul(cpuRotationZ4(angle), matrix),\n // GPU implementation\n (matrix, angle) =>\n snip(stitch`(${(gpuRotationZ4(angle))} * ${matrix})`, matrix.dataType),\n 'rotateZ4',\n);\n","import { createDualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { i32, u32 } from '../data/numeric.ts';\nimport { snip, type Snippet } from '../data/snippet.ts';\nimport {\n type AnyWgslData,\n type atomicI32,\n type atomicU32,\n isWgslData,\n Void,\n} from '../data/wgslTypes.ts';\nimport { safeStringify } from '../shared/stringify.ts';\ntype AnyAtomic = atomicI32 | atomicU32;\n\nexport const workgroupBarrier = createDualImpl(\n // CPU implementation\n () => console.warn('workgroupBarrier is a no-op outside of CODEGEN mode.'),\n // CODEGEN implementation\n () => snip('workgroupBarrier()', Void),\n 'workgroupBarrier',\n);\n\nexport const storageBarrier = createDualImpl(\n // CPU implementation\n () => console.warn('storageBarrier is a no-op outside of CODEGEN mode.'),\n // CODEGEN implementation\n () => snip('storageBarrier()', Void),\n 'storageBarrier',\n);\n\nexport const textureBarrier = createDualImpl(\n // CPU implementation\n () => console.warn('textureBarrier is a no-op outside of CODEGEN mode.'),\n // CODEGEN implementation\n () => snip('textureBarrier()', Void),\n 'textureBarrier',\n);\n\nexport const atomicLoad = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicLoad(&${a})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicLoad',\n);\n\nexport const atomicStore = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): void => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (!isWgslData(a.dataType) || a.dataType.type !== 'atomic') {\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n }\n return snip(stitch`atomicStore(&${a}, ${value})`, Void);\n },\n 'atomicStore',\n);\n\nconst atomicTypeFn = (a: Snippet, _value: Snippet): AnyWgslData[] => {\n if (a.dataType.type === 'atomic' && a.dataType.inner.type === 'i32') {\n return [a.dataType, i32];\n }\n return [a.dataType as AnyWgslData, u32];\n};\n\nexport const atomicAdd = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicAdd(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicAdd',\n atomicTypeFn,\n);\n\nexport const atomicSub = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicSub(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicSub',\n atomicTypeFn,\n);\n\nexport const atomicMax = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicMax(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicMax',\n atomicTypeFn,\n);\n\nexport const atomicMin = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicMin(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicMin',\n atomicTypeFn,\n);\n\nexport const atomicAnd = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicAnd(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicAnd',\n atomicTypeFn,\n);\n\nexport const atomicOr = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicOr(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicOr',\n atomicTypeFn,\n);\n\nexport const atomicXor = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicXor(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicXor',\n atomicTypeFn,\n);\n","import { createDualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { snip } from '../data/snippet.ts';\nimport type { AnyFloat32VecInstance } from '../data/wgslTypes.ts';\n\nfunction cpuDpdx(value: number): number;\nfunction cpuDpdx<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdx<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdx = createDualImpl(\n cpuDpdx,\n (value) => snip(stitch`dpdx(${value})`, value.dataType),\n 'dpdx',\n);\n\nfunction cpuDpdxCoarse(value: number): number;\nfunction cpuDpdxCoarse<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdxCoarse<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdxCoarse = createDualImpl(\n cpuDpdxCoarse,\n (value) => snip(stitch`dpdxCoarse(${value})`, value.dataType),\n 'dpdxCoarse',\n);\n\nfunction cpuDpdxFine(value: number): number;\nfunction cpuDpdxFine<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdxFine<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdxFine = createDualImpl(\n cpuDpdxFine,\n (value) => snip(stitch`dpdxFine(${value})`, value.dataType),\n 'dpdxFine',\n);\n\nfunction cpuDpdy(value: number): number;\nfunction cpuDpdy<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdy<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdy = createDualImpl(\n cpuDpdy,\n (value) => snip(stitch`dpdy(${value})`, value.dataType),\n 'dpdy',\n);\n\nfunction cpuDpdyCoarse(value: number): number;\nfunction cpuDpdyCoarse<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdyCoarse<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdyCoarse = createDualImpl(\n cpuDpdyCoarse,\n (value) => snip(stitch`dpdyCoarse(${value})`, value.dataType),\n 'dpdyCoarse',\n);\n\nfunction cpuDpdyFine(value: number): number;\nfunction cpuDpdyFine<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdyFine<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdyFine = createDualImpl(\n cpuDpdyFine,\n (value) => snip(stitch`dpdyFine(${value})`, value.dataType),\n 'dpdyFine',\n);\n\nfunction cpuFwidth(value: number): number;\nfunction cpuFwidth<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuFwidth<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const fwidth = createDualImpl(\n cpuFwidth,\n (value) => snip(stitch`fwidth(${value})`, value.dataType),\n 'fwidth',\n);\n\nfunction cpuFwidthCoarse(value: number): number;\nfunction cpuFwidthCoarse<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuFwidthCoarse<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const fwidthCoarse = createDualImpl(\n cpuFwidthCoarse,\n (value) => snip(stitch`fwidthCoarse(${value})`, value.dataType),\n 'fwidthCoarse',\n);\n\nfunction cpuFwidthFine(value: number): number;\nfunction cpuFwidthFine<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuFwidthFine<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const fwidthFine = createDualImpl(\n cpuFwidthFine,\n (value) => snip(stitch`fwidthFine(${value})`, value.dataType),\n 'fwidthFine',\n);\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { abstractInt, u32 } from '../data/numeric.ts';\nimport { ptrFn } from '../data/ptr.ts';\nimport { isPtr, isWgslArray, type StorableData } from '../data/wgslTypes.ts';\n\nconst sizeOfPointedToArray = (dataType: unknown) =>\n isPtr(dataType) && isWgslArray(dataType.inner)\n ? dataType.inner.elementCount\n : 0;\n\nexport const arrayLength = dualImpl({\n name: 'arrayLength',\n signature: (arg) => {\n const ptrArg = isPtr(arg) ? arg : ptrFn(arg as StorableData);\n return ({\n argTypes: [ptrArg],\n returnType: sizeOfPointedToArray(ptrArg) > 0 ? abstractInt : u32,\n });\n },\n normalImpl: (a: unknown[]) => a.length,\n codegenImpl(a) {\n const length = sizeOfPointedToArray(a.dataType);\n return length > 0 ? String(length) : stitch`arrayLength(${a})`;\n },\n});\n","import { stitch } from '../core/resolve/stitch.ts';\nimport {\n isWgslTexture,\n type WgslExternalTexture,\n type WgslStorageTexture,\n type WgslTexture,\n} from '../data/texture.ts';\nimport type { TexelData } from '../core/texture/texture.ts';\nimport { dualImpl } from '../core/function/dualImpl.ts';\nimport { f32, u32 } from '../data/numeric.ts';\nimport { vec2u, vec3u, vec4f, vec4i, vec4u } from '../data/vector.ts';\nimport {\n type v2f,\n type v2i,\n type v2u,\n type v3f,\n type v3i,\n type v3u,\n type v4f,\n type v4i,\n type v4u,\n Void,\n} from '../data/wgslTypes.ts';\nimport {\n type StorageTextureFormats,\n type TextureFormats,\n textureFormats,\n} from '../core/texture/textureFormats.ts';\nimport type { $internal, $repr } from '../shared/symbols.ts';\nimport type {\n texture1d,\n texture2d,\n texture2dArray,\n texture3d,\n textureCube,\n textureCubeArray,\n textureDepth2d,\n textureDepth2dArray,\n textureDepthCube,\n textureExternal,\n textureMultisampled2d,\n textureStorage1d,\n textureStorage2d,\n textureStorage2dArray,\n textureStorage3d,\n} from '../data/texture.ts';\n\nimport type { AnyData } from '../data/dataTypes.ts';\nimport type { comparisonSampler, sampler } from '../data/sampler.ts';\n\nfunction sampleCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n): v4f;\nfunction sampleCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n): v4f;\nfunction sampleCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n offset: v3i,\n): v4f;\nfunction sampleCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n): v4f;\nfunction sampleCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex?: number,\n): number;\nfunction sampleCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSample = dualImpl({\n name: 'textureSample',\n normalImpl: sampleCpu,\n codegenImpl: (...args) => stitch`textureSample(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args as AnyData[],\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\nfunction sampleBiasCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n bias: number,\n offset?: v3i,\n): v4f;\nfunction sampleBiasCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _biasOrArrayIndex: number,\n _biasOrOffset?: number | v2i | v3i,\n _maybeOffset?: v2i | v3i,\n): v4f {\n throw new Error(\n 'Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleBias = dualImpl({\n name: 'textureSampleBias',\n normalImpl: sampleBiasCpu,\n codegenImpl: (...args) => stitch`textureSampleBias(${args})`,\n signature: (...args) => ({\n argTypes: args as AnyData[],\n returnType: vec4f,\n }),\n});\n\nfunction sampleLevelCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n offset: v3i,\n): v4f;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _level: number,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleLevel = dualImpl({\n name: 'textureSampleLevel',\n normalImpl: sampleLevelCpu,\n codegenImpl: (...args) => stitch`textureSampleLevel(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args,\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\ntype PrimitiveToLoadedType = {\n f32: v4f;\n i32: v4i;\n u32: v4u;\n};\n\ntype TexelFormatToInstanceType<T extends StorageTextureFormats> =\n TextureFormats[T]['vectorType'][typeof $repr];\n\nfunction textureLoadCpu<T extends texture1d>(\n texture: T,\n coords: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2d>(\n texture: T,\n coords: v2i | v2u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture3d>(\n texture: T,\n coords: v3i | v3u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureMultisampled2d>(\n texture: T,\n coords: v2i | v2u,\n sampleIndex: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu(\n _texture: WgslTexture | WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _levelOrArrayIndex?: number,\n): TexelData {\n throw new Error(\n '`textureLoad` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureLoad = dualImpl({\n name: 'textureLoad',\n normalImpl: textureLoadCpu,\n codegenImpl: (...args) => stitch`textureLoad(${args})`,\n signature: (...args) => {\n const texture = args[0] as WgslTexture | WgslStorageTexture;\n if (isWgslTexture(texture)) {\n const isDepth = texture.type.startsWith('texture_depth');\n const sampleType = texture.sampleType;\n return {\n argTypes: args,\n returnType: isDepth\n ? f32\n : sampleType.type === 'f32'\n ? vec4f\n : sampleType.type === 'u32'\n ? vec4u\n : vec4i,\n };\n }\n const format = texture.format;\n const dataType = textureFormats[format].vectorType;\n return {\n argTypes: args,\n returnType: dataType,\n };\n },\n});\n\nfunction textureStoreCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu(\n _texture: WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _arrayIndexOrValue?: number | TexelData,\n _maybeValue?: TexelData,\n): void {\n throw new Error(\n '`textureStore` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureStore = dualImpl({\n name: 'textureStore',\n normalImpl: textureStoreCpu,\n codegenImpl: (...args) => stitch`textureStore(${args})`,\n signature: (...args) => ({ argTypes: args, returnType: Void }),\n});\n\nfunction textureDimensionsCpu<T extends texture1d | textureStorage1d>(\n texture: T,\n): number;\nfunction textureDimensionsCpu<T extends texture1d>(\n texture: T,\n level: number,\n): number;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray\n | textureStorage2d\n | textureStorage2dArray\n | textureExternal,\n>(texture: T): v2u;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray,\n>(texture: T, level: number): v2u;\nfunction textureDimensionsCpu<T extends texture3d | textureStorage3d>(\n texture: T,\n): v3u;\nfunction textureDimensionsCpu<T extends texture3d>(\n texture: T,\n level: number,\n): v3u;\nfunction textureDimensionsCpu(\n _texture: WgslTexture | WgslStorageTexture | WgslExternalTexture,\n _level?: number,\n): number | v2u | v3u {\n throw new Error(\n '`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureDimensions = dualImpl({\n name: 'textureDimensions',\n normalImpl: textureDimensionsCpu,\n codegenImpl: (...args) => stitch`textureDimensions(${args})`,\n signature: (...args) => {\n const dim = (\n args[0] as WgslTexture | WgslStorageTexture | WgslExternalTexture\n ).dimension;\n if (dim === '1d') {\n return {\n argTypes: args,\n returnType: u32,\n };\n }\n if (dim === '3d') {\n return {\n argTypes: args,\n returnType: vec3u,\n };\n }\n return {\n argTypes: args,\n returnType: vec2u,\n };\n },\n});\n\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepthCube>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureCubeArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu(\n _texture: WgslTexture,\n _sampler: comparisonSampler,\n _coords: v2f | v3f,\n _depthRefOrArrayIndex: number,\n _depthRefOrOffset?: number | v2i,\n _maybeOffset?: v2i,\n): number {\n throw new Error(\n 'Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleCompare = dualImpl({\n name: 'textureSampleCompare',\n normalImpl: textureSampleCompareCpu,\n codegenImpl: (...args) => stitch`textureSampleCompare(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: f32,\n }),\n});\n\nfunction textureSampleBaseClampToEdgeCpu<\n T extends texture2d | textureExternal,\n>(texture: T, sampler: sampler, coords: v2f): v4f {\n throw new Error(\n 'Texture sampling with base clamp to edge is not supported outside of GPU mode.',\n );\n}\n\nexport const textureSampleBaseClampToEdge = dualImpl({\n name: 'textureSampleBaseClampToEdge',\n normalImpl: textureSampleBaseClampToEdgeCpu,\n codegenImpl: (...args) => stitch`textureSampleBaseClampToEdge(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: vec4f,\n }),\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { bool, i32, u32 } from '../data/numeric.ts';\nimport { vec4u } from '../data/vector.ts';\nimport type {\n AnyIntegerVecInstance,\n AnyNumericVecInstance,\n AnyWgslData,\n v4u,\n} from '../data/wgslTypes.ts';\nimport { unify } from '../tgsl/conversion.ts';\n\ninterface IdentityNumOrVec {\n (e: number): number;\n <T extends AnyNumericVecInstance>(e: T): T;\n}\n\ninterface IdentityIntNumOrVec {\n (e: number): number;\n <T extends AnyIntegerVecInstance>(e: T): T;\n}\n\ninterface IdentityNumOrVecWithIdx {\n (e: number, index: number): number;\n <T extends AnyNumericVecInstance>(e: T, index: number): T;\n}\n\ninterface IdentityNumOrVecWithDelta {\n (e: number, delta: number): number;\n <T extends AnyNumericVecInstance>(e: T, delta: number): T;\n}\n\ninterface IdentityNumOrVecWithMask {\n (e: number, mask: number): number;\n <T extends AnyNumericVecInstance>(e: T, mask: number): T;\n}\n\nconst errorMessage = 'Subgroup operations can only be used in the GPU context.';\n\nexport const subgroupAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupAdd(${arg})`,\n});\n\nexport const subgroupExclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveAdd(${arg})`,\n});\n\nexport const subgroupInclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveAdd(${arg})`,\n});\n\nexport const subgroupAll = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAll',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAll(${e})`,\n});\n\nexport const subgroupAnd = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupAnd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAnd(${e})`,\n});\n\nexport const subgroupAny = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAny',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAny(${e})`,\n});\n\nexport const subgroupBallot = dualImpl<(e: boolean) => v4u>({\n name: 'subgroupBallot',\n signature: { argTypes: [bool], returnType: vec4u },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBallot(${e})`,\n});\n\nexport const subgroupBroadcast = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupBroadcast',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupBroadcast's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupBroadcast(${e}, ${index})`,\n});\n\nexport const subgroupBroadcastFirst = dualImpl<IdentityNumOrVec>({\n name: 'subgroupBroadcastFirst',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBroadcastFirst(${e})`,\n});\n\nexport const subgroupElect = dualImpl<() => boolean>({\n name: 'subgroupElect',\n signature: { argTypes: [], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: () => stitch`subgroupElect()`,\n});\n\nexport const subgroupMax = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMax',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMax(${arg})`,\n});\n\nexport const subgroupMin = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMin',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMin(${arg})`,\n});\n\nexport const subgroupMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMul(${arg})`,\n});\n\nexport const subgroupExclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveMul(${arg})`,\n});\n\nexport const subgroupInclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveMul(${arg})`,\n});\n\nexport const subgroupOr = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupOr',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupOr(${e})`,\n});\n\nexport const subgroupShuffle = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupShuffle',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupShuffle's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupShuffle(${e}, ${index})`,\n});\n\nexport const subgroupShuffleDown = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleDown',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleDown's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleDown(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleUp = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleUp',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleUp's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleUp(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleXor = dualImpl<IdentityNumOrVecWithMask>({\n name: 'subgroupShuffleXor',\n signature: (...args) => {\n const mask = unify([args[1]] as [AnyWgslData], [u32]);\n if (!mask) {\n throw new Error(\n `subgroupShuffleXor's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], mask[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, mask) => stitch`subgroupShuffleXor(${e}, ${mask})`,\n});\n\nexport const subgroupXor = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupXor',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupXor(${e})`,\n});\n","import type { DualFn } from '../data/dualFn.ts';\nimport { bool } from '../data/index.ts';\nimport { snip, type Snippet } from '../data/snippet.ts';\nimport { getResolutionCtx, inCodegenMode } from '../execMode.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { type WgslExtension, wgslExtensions } from '../wgslExtensions.ts';\n\nexport const extensionEnabled: DualFn<\n (extensionName: WgslExtension) => boolean\n> = (() => {\n const jsImpl = (extensionName: WgslExtension) => {\n const resolutionCtx = getResolutionCtx();\n if (!resolutionCtx) {\n throw new Error(\n 'extensionEnabled can only be called in a GPU codegen context.',\n );\n }\n\n return (resolutionCtx.enableExtensions ?? []).includes(extensionName);\n };\n const gpuImpl = (extensionNameSnippet: Snippet) => {\n const { value } = extensionNameSnippet;\n if (\n typeof value !== 'string' ||\n !(wgslExtensions.includes(value as WgslExtension))\n ) {\n throw new Error(\n `extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: ${value}`,\n );\n }\n return snip(jsImpl(value as WgslExtension), bool);\n };\n\n const impl = (extensionName: WgslExtension) => {\n if (inCodegenMode()) {\n return gpuImpl(extensionName as unknown as Snippet);\n }\n throw new Error(\n 'extensionEnabled can only be called in a GPU codegen context.',\n );\n };\n\n Object.defineProperty(impl, $internal, {\n value: {\n jsImpl,\n gpuImpl,\n argConversionHint: 'keep' as const,\n },\n });\n return impl;\n})() as unknown as DualFn<\n (extensionName: WgslExtension) => boolean\n>;\n"],"mappings":"unCAIO,IAAMA,GAAUC,EAErB,IAAa,CACX,MAAM,IAAI,MACR,iFACF,CACF,EAEA,IAAMC,EAAK,WAAYC,CAAI,EAC3B,SACF,ECAA,IAAMC,EAASC,EAAIC,CAAS,EAAE,OAExBC,GAAkBC,EAAaF,CAAS,EAAE,OAC1CG,GAAkBD,EAAaF,CAAS,EAAE,QAE1CI,GAAcC,EAASL,CAAS,EAAE,OAClCM,GAAcD,EAASL,CAAS,EAAE,QAElCO,GAAgBC,EAAWR,CAAS,EAAE,OACtCS,GAAgBD,EAAWR,CAAS,EAAE,QAEtCU,GAAgBC,EAAWX,CAAS,EAAE,OACtCY,GAAgBD,EAAWX,CAAS,EAAE,QAEtCa,GAAgBC,EAAWd,CAAS,EAAE,OACtCe,GAAgBD,EAAWd,CAAS,EAAE,QAQ/BgB,GAAaC,EAExB,CAACC,EAAeC,IAAgBrB,EAAOG,GAAgBkB,CAAM,EAAGD,CAAM,EAEtE,CAACA,EAAQC,IACPC,EAAKC,KAAUlB,GAAgBgB,CAAM,CAAC,MAAMD,CAAM,IAAKA,EAAO,QAAQ,EACxE,YACF,EAQaI,GAASL,EAEpB,CAACC,EAAeC,IAAgBrB,EAAOM,GAAYe,CAAM,EAAGD,CAAM,EAElE,CAACA,EAAQC,IACPC,EAAKC,KAAWf,GAAYa,CAAM,CAAE,MAAMD,CAAM,IAAKA,EAAO,QAAQ,EACtE,QACF,EAQaK,GAAWN,EAEtB,CAACC,EA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Void","cpuMul","mul","$internal","cpuTranslation4","translation4","gpuTranslation4","cpuScaling4","scaling4","gpuScaling4","cpuRotationX4","rotationX4","gpuRotationX4","cpuRotationY4","rotationY4","gpuRotationY4","cpuRotationZ4","rotationZ4","gpuRotationZ4","translate4","createDualImpl","matrix","vector","snip","stitch","scale4","rotateX4","angle","rotateY4","rotateZ4","workgroupBarrier","createDualImpl","snip","Void","storageBarrier","textureBarrier","atomicLoad","a","isWgslData","stitch","safeStringify","atomicStore","value","atomicTypeFn","_value","i32","u32","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","cpuDpdx","value","dpdx","createDualImpl","snip","stitch","cpuDpdxCoarse","dpdxCoarse","cpuDpdxFine","dpdxFine","cpuDpdy","dpdy","cpuDpdyCoarse","dpdyCoarse","cpuDpdyFine","dpdyFine","cpuFwidth","fwidth","cpuFwidthCoarse","fwidthCoarse","cpuFwidthFine","fwidthFine","sizeOfPointedToArray","dataType","isPtr","isWgslArray","arrayLength","dualImpl","arg","ptrArg","ptrFn","abstractInt","u32","a","length","stitch","sampleCpu","_texture","_sampler","_coords","_offsetOrArrayIndex","_maybeOffset","textureSample","dualImpl","args","stitch","isDepth","f32","vec4f","sampleBiasCpu","_biasOrArrayIndex","_biasOrOffset","textureSampleBias","sampleLevelCpu","_level","textureSampleLevel","textureLoadCpu","_levelOrArrayIndex","textureLoad","texture","isWgslTexture","sampleType","vec4u","vec4i","format","dataType","textureFormats","textureStoreCpu","_arrayIndexOrValue","_maybeValue","textureStore","Void","textureDimensionsCpu","textureDimensions","dim","u32","vec3u","vec2u","textureSampleCompareCpu","_depthRefOrArrayIndex","_depthRefOrOffset","textureSampleCompare","textureSampleBaseClampToEdgeCpu","sampler","coords","textureSampleBaseClampToEdge","errorMessage","subgroupAdd","dualImpl","arg","stitch","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","bool","subgroupAnd","subgroupAny","subgroupBallot","vec4u","subgroupBroadcast","args","id","unify","i32","u32","index","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","delta","subgroupShuffleUp","subgroupShuffleXor","mask","subgroupXor","extensionEnabled","jsImpl","extensionName","resolutionCtx","getResolutionCtx","gpuImpl","extensionNameSnippet","value","wgslExtensions","snip","bool","impl","inCodegenMode","$internal"]}
{"version":3,"sources":["../../src/std/discard.ts","../../src/std/matrix.ts","../../src/std/atomic.ts","../../src/std/derivative.ts","../../src/std/array.ts","../../src/std/texture.ts","../../src/std/subgroup.ts","../../src/std/extensions.ts"],"sourcesContent":["import { dualImpl } from '../core/function/dualImpl.ts';\nimport { Void } from '../data/wgslTypes.ts';\n\nexport const discard = dualImpl<() => never>({\n name: 'discard',\n normalImpl:\n '`discard` relies on GPU resources and cannot be executed outside of a draw call',\n signature: { argTypes: [], returnType: Void },\n codegenImpl: () => 'discard;',\n});\n","import { stitch } from '../core/resolve/stitch.ts';\nimport {\n mat4x4f,\n rotationX4,\n rotationY4,\n rotationZ4,\n scaling4,\n translation4,\n} from '../data/matrix.ts';\nimport type { m4x4f, v3f } from '../data/wgslTypes.ts';\nimport { dualImpl } from '../core/function/dualImpl.ts';\nimport { mul } from './operators.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { vec3f } from '../data/vector.ts';\nimport { f32 } from '../data/numeric.ts';\n\nconst cpuMul = mul[$internal].jsImpl;\n\nconst cpuTranslation4 = translation4[$internal].jsImpl;\nconst gpuTranslation4 = translation4[$internal].gpuImpl;\n\nconst cpuScaling4 = scaling4[$internal].jsImpl;\nconst gpuScaling4 = scaling4[$internal].gpuImpl;\n\nconst cpuRotationX4 = rotationX4[$internal].jsImpl;\nconst gpuRotationX4 = rotationX4[$internal].gpuImpl;\n\nconst cpuRotationY4 = rotationY4[$internal].jsImpl;\nconst gpuRotationY4 = rotationY4[$internal].gpuImpl;\n\nconst cpuRotationZ4 = rotationZ4[$internal].jsImpl;\nconst gpuRotationZ4 = rotationZ4[$internal].gpuImpl;\n\n/**\n * Translates the given 4-by-4 matrix by the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - The vector by which to translate the matrix.\n * @returns {m4x4f} The translated matrix.\n */\nexport const translate4 = dualImpl({\n name: 'translate4',\n normalImpl: (matrix: m4x4f, vector: v3f) =>\n cpuMul(cpuTranslation4(vector), matrix),\n signature: { argTypes: [mat4x4f, vec3f], returnType: mat4x4f },\n codegenImpl: (matrix, vector) =>\n stitch`(${gpuTranslation4(vector)} * ${matrix})`,\n});\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by an amount given by the corresponding entry in the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.\n * @returns {m4x4f} The scaled matrix.\n */\nexport const scale4 = dualImpl({\n name: 'scale4',\n normalImpl: (matrix: m4x4f, vector: v3f) =>\n cpuMul(cpuScaling4(vector), matrix),\n signature: { argTypes: [mat4x4f, vec3f], returnType: mat4x4f },\n codegenImpl: (matrix, vector) =>\n stitch`(${(gpuScaling4(vector))} * ${matrix})`,\n});\n\nconst rotateSignature = { argTypes: [mat4x4f, f32], returnType: mat4x4f };\n\n/**\n * Rotates the given 4-by-4 matrix around the x-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateX4 = dualImpl({\n name: 'rotateX4',\n normalImpl: (matrix: m4x4f, angle: number) =>\n cpuMul(cpuRotationX4(angle), matrix),\n signature: rotateSignature,\n codegenImpl: (matrix, angle) =>\n stitch`(${(gpuRotationX4(angle))} * ${matrix})`,\n});\n\n/**\n * Rotates the given 4-by-4 matrix around the y-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateY4 = dualImpl({\n name: 'rotateY4',\n normalImpl: (matrix: m4x4f, angle: number) =>\n cpuMul(cpuRotationY4(angle), matrix),\n signature: rotateSignature,\n codegenImpl: (matrix, angle) =>\n stitch`(${(gpuRotationY4(angle))} * ${matrix})`,\n});\n\n/**\n * Rotates the given 4-by-4 matrix around the z-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateZ4 = dualImpl({\n name: 'rotateZ4',\n normalImpl: (matrix: m4x4f, angle: number) =>\n cpuMul(cpuRotationZ4(angle), matrix),\n signature: rotateSignature,\n codegenImpl: (matrix, angle) =>\n stitch`(${(gpuRotationZ4(angle))} * ${matrix})`,\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport type { AnyData } from '../data/dataTypes.ts';\nimport { i32, u32 } from '../data/numeric.ts';\nimport { type atomicI32, type atomicU32, Void } from '../data/wgslTypes.ts';\nimport { safeStringify } from '../shared/stringify.ts';\ntype AnyAtomic = atomicI32 | atomicU32;\n\nexport const workgroupBarrier = dualImpl({\n name: 'workgroupBarrier',\n normalImpl: 'workgroupBarrier is a no-op outside of CODEGEN mode.',\n signature: { argTypes: [], returnType: Void },\n codegenImpl: () => 'workgroupBarrier()',\n});\n\nexport const storageBarrier = dualImpl({\n name: 'storageBarrier',\n normalImpl: 'storageBarrier is a no-op outside of CODEGEN mode.',\n signature: { argTypes: [], returnType: Void },\n codegenImpl: () => 'storageBarrier()',\n});\n\nexport const textureBarrier = dualImpl({\n name: 'textureBarrier',\n normalImpl: 'textureBarrier is a no-op outside of CODEGEN mode.',\n signature: { argTypes: [], returnType: Void },\n codegenImpl: () => 'textureBarrier()',\n});\n\nconst atomicNormalError =\n 'Atomic operations are not supported outside of CODEGEN mode.';\n\nexport const atomicLoad = dualImpl<<T extends AnyAtomic>(a: T) => number>({\n name: 'atomicLoad',\n normalImpl: atomicNormalError,\n signature: (a) => {\n if (a.type !== 'atomic') {\n throw new Error(`Invalid atomic type: ${safeStringify(a)}`);\n }\n return { argTypes: [a], returnType: a.inner };\n },\n codegenImpl: (a) => stitch`atomicLoad(&${a})`,\n});\n\nconst atomicActionSignature = (a: AnyData, param: AnyData) => {\n if (a.type !== 'atomic') {\n throw new Error(`Invalid atomic type: ${safeStringify(a)}`);\n }\n return {\n argTypes: [a, a.inner.type === 'u32' ? u32 : i32],\n returnType: Void,\n };\n};\n\nconst atomicOpSignature = (a: AnyData, param: AnyData) => {\n if (a.type !== 'atomic') {\n throw new Error(`Invalid atomic type: ${safeStringify(a)}`);\n }\n const paramType = a.inner.type === 'u32' ? u32 : i32;\n return {\n argTypes: [a, paramType],\n returnType: paramType,\n };\n};\n\nexport const atomicStore = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => void\n>({\n name: 'atomicStore',\n normalImpl: atomicNormalError,\n signature: atomicActionSignature,\n codegenImpl: (a, value) => stitch`atomicStore(&${a}, ${value})`,\n});\n\nexport const atomicAdd = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicAdd',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicAdd(&${a}, ${value})`,\n});\n\nexport const atomicSub = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicSub',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicSub(&${a}, ${value})`,\n});\n\nexport const atomicMax = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicMax',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicMax(&${a}, ${value})`,\n});\n\nexport const atomicMin = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicMin',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicMin(&${a}, ${value})`,\n});\n\nexport const atomicAnd = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicAnd',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicAnd(&${a}, ${value})`,\n});\n\nexport const atomicOr = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicOr',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicOr(&${a}, ${value})`,\n});\n\nexport const atomicXor = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicXor',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicXor(&${a}, ${value})`,\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport type { AnyFloat32VecInstance } from '../data/wgslTypes.ts';\n\ntype DerivativeSignature =\n & ((value: number) => number)\n & (<T extends AnyFloat32VecInstance>(value: T) => T);\n\nconst derivativeNormalError = 'Derivative builtins are not allowed on the CPU';\n\nexport const dpdx = dualImpl<DerivativeSignature>({\n name: 'dpdx',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdx(${value})`,\n});\n\nexport const dpdxCoarse = dualImpl<DerivativeSignature>({\n name: 'dpdxCoarse',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdxCoarse(${value})`,\n});\n\nexport const dpdxFine = dualImpl<DerivativeSignature>({\n name: 'dpdxFine',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdxFine(${value})`,\n});\n\nexport const dpdy = dualImpl<DerivativeSignature>({\n name: 'dpdy',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdy(${value})`,\n});\n\nexport const dpdyCoarse = dualImpl<DerivativeSignature>({\n name: 'dpdyCoarse',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdyCoarse(${value})`,\n});\n\nexport const dpdyFine = dualImpl<DerivativeSignature>({\n name: 'dpdyFine',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdyFine(${value})`,\n});\n\nexport const fwidth = dualImpl<DerivativeSignature>({\n name: 'fwidth',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`fwidth(${value})`,\n});\n\nexport const fwidthCoarse = dualImpl<DerivativeSignature>({\n name: 'fwidthCoarse',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`fwidthCoarse(${value})`,\n});\n\nexport const fwidthFine = dualImpl<DerivativeSignature>({\n name: 'fwidthFine',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`fwidthFine(${value})`,\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { abstractInt, u32 } from '../data/numeric.ts';\nimport { ptrFn } from '../data/ptr.ts';\nimport { isRef, type ref } from '../data/ref.ts';\nimport { isPtr, isWgslArray, type StorableData } from '../data/wgslTypes.ts';\n\nconst sizeOfPointedToArray = (dataType: unknown) =>\n isPtr(dataType) && isWgslArray(dataType.inner)\n ? dataType.inner.elementCount\n : 0;\n\nexport const arrayLength = dualImpl({\n name: 'arrayLength',\n signature: (arg) => {\n const ptrArg = isPtr(arg) ? arg : ptrFn(arg as StorableData);\n return ({\n argTypes: [ptrArg],\n returnType: sizeOfPointedToArray(ptrArg) > 0 ? abstractInt : u32,\n });\n },\n normalImpl: (a: unknown[] | ref<unknown[]>) =>\n isRef(a) ? a.$.length : a.length,\n codegenImpl(a) {\n const length = sizeOfPointedToArray(a.dataType);\n return length > 0 ? String(length) : stitch`arrayLength(${a})`;\n },\n});\n","import { stitch } from '../core/resolve/stitch.ts';\nimport {\n isWgslTexture,\n type WgslExternalTexture,\n type WgslStorageTexture,\n type WgslTexture,\n} from '../data/texture.ts';\nimport type { TexelData } from '../core/texture/texture.ts';\nimport { dualImpl } from '../core/function/dualImpl.ts';\nimport { f32, u32 } from '../data/numeric.ts';\nimport { vec2u, vec3u, vec4f, vec4i, vec4u } from '../data/vector.ts';\nimport {\n type v2f,\n type v2i,\n type v2u,\n type v3f,\n type v3i,\n type v3u,\n type v4f,\n type v4i,\n type v4u,\n Void,\n} from '../data/wgslTypes.ts';\nimport {\n getTextureFormatInfo,\n type StorageTextureFormats,\n type TextureFormats,\n} from '../core/texture/textureFormats.ts';\nimport type { $internal, $repr } from '../shared/symbols.ts';\nimport type {\n texture1d,\n texture2d,\n texture2dArray,\n texture3d,\n textureCube,\n textureCubeArray,\n textureDepth2d,\n textureDepth2dArray,\n textureDepthCube,\n textureExternal,\n textureMultisampled2d,\n textureStorage1d,\n textureStorage2d,\n textureStorage2dArray,\n textureStorage3d,\n} from '../data/texture.ts';\n\nimport type { AnyData } from '../data/dataTypes.ts';\nimport type { comparisonSampler, sampler } from '../data/sampler.ts';\n\nfunction sampleCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n): v4f;\nfunction sampleCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n): v4f;\nfunction sampleCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n offset: v3i,\n): v4f;\nfunction sampleCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n): v4f;\nfunction sampleCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex?: number,\n): number;\nfunction sampleCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSample = dualImpl({\n name: 'textureSample',\n normalImpl: sampleCpu,\n codegenImpl: (...args) => stitch`textureSample(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args as AnyData[],\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\nfunction sampleBiasCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n bias: number,\n offset?: v3i,\n): v4f;\nfunction sampleBiasCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _biasOrArrayIndex: number,\n _biasOrOffset?: number | v2i | v3i,\n _maybeOffset?: v2i | v3i,\n): v4f {\n throw new Error(\n 'Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleBias = dualImpl({\n name: 'textureSampleBias',\n normalImpl: sampleBiasCpu,\n codegenImpl: (...args) => stitch`textureSampleBias(${args})`,\n signature: (...args) => ({\n argTypes: args as AnyData[],\n returnType: vec4f,\n }),\n});\n\nfunction sampleLevelCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n offset: v3i,\n): v4f;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _level: number,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleLevel = dualImpl({\n name: 'textureSampleLevel',\n normalImpl: sampleLevelCpu,\n codegenImpl: (...args) => stitch`textureSampleLevel(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args,\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\ntype PrimitiveToLoadedType = {\n f32: v4f;\n i32: v4i;\n u32: v4u;\n};\n\ntype TexelFormatToInstanceType<T extends StorageTextureFormats> =\n TextureFormats[T]['vectorType'][typeof $repr];\n\nfunction textureLoadCpu<T extends texture1d>(\n texture: T,\n coords: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2d>(\n texture: T,\n coords: v2i | v2u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture3d>(\n texture: T,\n coords: v3i | v3u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureMultisampled2d>(\n texture: T,\n coords: v2i | v2u,\n sampleIndex: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu(\n _texture: WgslTexture | WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _levelOrArrayIndex?: number,\n): TexelData {\n throw new Error(\n '`textureLoad` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureLoad = dualImpl({\n name: 'textureLoad',\n normalImpl: textureLoadCpu,\n codegenImpl: (...args) => stitch`textureLoad(${args})`,\n signature: (...args) => {\n const texture = args[0] as WgslTexture | WgslStorageTexture;\n if (isWgslTexture(texture)) {\n const isDepth = texture.type.startsWith('texture_depth');\n const sampleType = texture.sampleType;\n return {\n argTypes: args,\n returnType: isDepth\n ? f32\n : sampleType.type === 'f32'\n ? vec4f\n : sampleType.type === 'u32'\n ? vec4u\n : vec4i,\n };\n }\n const format = texture.format;\n const dataType = getTextureFormatInfo(format).vectorType;\n return {\n argTypes: args,\n returnType: dataType,\n };\n },\n});\n\nfunction textureStoreCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu(\n _texture: WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _arrayIndexOrValue?: number | TexelData,\n _maybeValue?: TexelData,\n): void {\n throw new Error(\n '`textureStore` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureStore = dualImpl({\n name: 'textureStore',\n normalImpl: textureStoreCpu,\n codegenImpl: (...args) => stitch`textureStore(${args})`,\n signature: (...args) => ({ argTypes: args, returnType: Void }),\n});\n\nfunction textureDimensionsCpu<T extends texture1d | textureStorage1d>(\n texture: T,\n): number;\nfunction textureDimensionsCpu<T extends texture1d>(\n texture: T,\n level: number,\n): number;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray\n | textureStorage2d\n | textureStorage2dArray\n | textureExternal,\n>(texture: T): v2u;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray,\n>(texture: T, level: number): v2u;\nfunction textureDimensionsCpu<T extends texture3d | textureStorage3d>(\n texture: T,\n): v3u;\nfunction textureDimensionsCpu<T extends texture3d>(\n texture: T,\n level: number,\n): v3u;\nfunction textureDimensionsCpu(\n _texture: WgslTexture | WgslStorageTexture | WgslExternalTexture,\n _level?: number,\n): number | v2u | v3u {\n throw new Error(\n '`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureDimensions = dualImpl({\n name: 'textureDimensions',\n normalImpl: textureDimensionsCpu,\n codegenImpl: (...args) => stitch`textureDimensions(${args})`,\n signature: (...args) => {\n const dim = (\n args[0] as WgslTexture | WgslStorageTexture | WgslExternalTexture\n ).dimension;\n if (dim === '1d') {\n return {\n argTypes: args,\n returnType: u32,\n };\n }\n if (dim === '3d') {\n return {\n argTypes: args,\n returnType: vec3u,\n };\n }\n return {\n argTypes: args,\n returnType: vec2u,\n };\n },\n});\n\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepthCube>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureCubeArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu(\n _texture: WgslTexture,\n _sampler: comparisonSampler,\n _coords: v2f | v3f,\n _depthRefOrArrayIndex: number,\n _depthRefOrOffset?: number | v2i,\n _maybeOffset?: v2i,\n): number {\n throw new Error(\n 'Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleCompare = dualImpl({\n name: 'textureSampleCompare',\n normalImpl: textureSampleCompareCpu,\n codegenImpl: (...args) => stitch`textureSampleCompare(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: f32,\n }),\n});\n\nfunction textureSampleBaseClampToEdgeCpu<\n T extends texture2d | textureExternal,\n>(texture: T, sampler: sampler, coords: v2f): v4f {\n throw new Error(\n 'Texture sampling with base clamp to edge is not supported outside of GPU mode.',\n );\n}\n\nexport const textureSampleBaseClampToEdge = dualImpl({\n name: 'textureSampleBaseClampToEdge',\n normalImpl: textureSampleBaseClampToEdgeCpu,\n codegenImpl: (...args) => stitch`textureSampleBaseClampToEdge(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: vec4f,\n }),\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { bool, i32, u32 } from '../data/numeric.ts';\nimport { vec4u } from '../data/vector.ts';\nimport type {\n AnyIntegerVecInstance,\n AnyNumericVecInstance,\n AnyWgslData,\n v4u,\n} from '../data/wgslTypes.ts';\nimport { unify } from '../tgsl/conversion.ts';\n\ninterface IdentityNumOrVec {\n (e: number): number;\n <T extends AnyNumericVecInstance>(e: T): T;\n}\n\ninterface IdentityIntNumOrVec {\n (e: number): number;\n <T extends AnyIntegerVecInstance>(e: T): T;\n}\n\ninterface IdentityNumOrVecWithIdx {\n (e: number, index: number): number;\n <T extends AnyNumericVecInstance>(e: T, index: number): T;\n}\n\ninterface IdentityNumOrVecWithDelta {\n (e: number, delta: number): number;\n <T extends AnyNumericVecInstance>(e: T, delta: number): T;\n}\n\ninterface IdentityNumOrVecWithMask {\n (e: number, mask: number): number;\n <T extends AnyNumericVecInstance>(e: T, mask: number): T;\n}\n\nconst errorMessage = 'Subgroup operations can only be used in the GPU context.';\n\nexport const subgroupAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupAdd(${arg})`,\n});\n\nexport const subgroupExclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveAdd(${arg})`,\n});\n\nexport const subgroupInclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveAdd(${arg})`,\n});\n\nexport const subgroupAll = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAll',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAll(${e})`,\n});\n\nexport const subgroupAnd = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupAnd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAnd(${e})`,\n});\n\nexport const subgroupAny = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAny',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAny(${e})`,\n});\n\nexport const subgroupBallot = dualImpl<(e: boolean) => v4u>({\n name: 'subgroupBallot',\n signature: { argTypes: [bool], returnType: vec4u },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBallot(${e})`,\n});\n\nexport const subgroupBroadcast = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupBroadcast',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupBroadcast's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupBroadcast(${e}, ${index})`,\n});\n\nexport const subgroupBroadcastFirst = dualImpl<IdentityNumOrVec>({\n name: 'subgroupBroadcastFirst',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBroadcastFirst(${e})`,\n});\n\nexport const subgroupElect = dualImpl<() => boolean>({\n name: 'subgroupElect',\n signature: { argTypes: [], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: () => stitch`subgroupElect()`,\n});\n\nexport const subgroupMax = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMax',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMax(${arg})`,\n});\n\nexport const subgroupMin = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMin',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMin(${arg})`,\n});\n\nexport const subgroupMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMul(${arg})`,\n});\n\nexport const subgroupExclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveMul(${arg})`,\n});\n\nexport const subgroupInclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveMul(${arg})`,\n});\n\nexport const subgroupOr = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupOr',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupOr(${e})`,\n});\n\nexport const subgroupShuffle = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupShuffle',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupShuffle's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupShuffle(${e}, ${index})`,\n});\n\nexport const subgroupShuffleDown = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleDown',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleDown's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleDown(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleUp = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleUp',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleUp's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleUp(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleXor = dualImpl<IdentityNumOrVecWithMask>({\n name: 'subgroupShuffleXor',\n signature: (...args) => {\n const mask = unify([args[1]] as [AnyWgslData], [u32]);\n if (!mask) {\n throw new Error(\n `subgroupShuffleXor's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], mask[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, mask) => stitch`subgroupShuffleXor(${e}, ${mask})`,\n});\n\nexport const subgroupXor = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupXor',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupXor(${e})`,\n});\n","import { comptime } from '../core/function/comptime.ts';\nimport { getResolutionCtx } from '../execMode.ts';\nimport { type WgslExtension, wgslExtensions } from '../wgslExtensions.ts';\n\nexport const extensionEnabled = comptime(\n (extensionName: WgslExtension): boolean => {\n const resolutionCtx = getResolutionCtx();\n if (!resolutionCtx) {\n throw new Error(\n \"Functions using `extensionEnabled` cannot be called directly. Either generate WGSL from them, or use tgpu['~unstable'].simulate(...)\",\n );\n }\n\n if (\n typeof extensionName !== 'string' ||\n !(wgslExtensions.includes(extensionName as WgslExtension))\n ) {\n throw new Error(\n `extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: '${extensionName}'`,\n );\n }\n\n return (resolutionCtx.enableExtensions ?? []).includes(extensionName);\n },\n);\n"],"mappings":"ojCAGO,IAAMA,GAAUC,EAAsB,CAC3C,KAAM,UACN,WACE,kFACF,UAAW,CAAE,SAAU,CAAC,EAAG,WAAYC,CAAK,EAC5C,YAAa,IAAM,UACrB,CAAC,ECOD,IAAMC,EAASC,EAAIC,CAAS,EAAE,OAExBC,GAAkBC,EAAaF,CAAS,EAAE,OAC1CG,GAAkBD,EAAaF,CAAS,EAAE,QAE1CI,GAAcC,EAASL,CAAS,EAAE,OAClCM,GAAcD,EAASL,CAAS,EAAE,QAElCO,GAAgBC,EAAWR,CAAS,EAAE,OACtCS,GAAgBD,EAAWR,CAAS,EAAE,QAEtCU,GAAgBC,EAAWX,CAAS,EAAE,OACtCY,GAAgBD,EAAWX,CAAS,EAAE,QAEtCa,GAAgBC,EAAWd,CAAS,EAAE,OACtCe,GAAgBD,EAAWd,CAAS,EAAE,QAQ/BgB,GAAaC,EAAS,CACjC,KAAM,aACN,WAAY,CAACC,EAAeC,IAC1BrB,EAAOG,GAAgBkB,CAAM,EAAGD,CAAM,EACxC,UAAW,CAAE,SAAU,CAACE,EAASC,CAAK,EAAG,WAAYD,CAAQ,EAC7D,YAAa,CAACF,EAAQC,IACpBG,KAAUnB,GAAgBgB,CAAM,CAAC,MAAMD,CAAM,GACjD,CAAC,EAQYK,GAASN,EAAS,CAC7B,KAAM,SACN,WAAY,CAACC,EAAeC,IAC1BrB,EAAOM,GAAYe,CAAM,EAAGD,CAAM,EACpC,UAAW,CAAE,SAAU,CAACE,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C,GAAG,SAASD,CAAa,CACtE,CACF","names":["discard","dualImpl","Void","cpuMul","mul","$internal","cpuTranslation4","translation4","gpuTranslation4","cpuScaling4","scaling4","gpuScaling4","cpuRotationX4","rotationX4","gpuRotationX4","cpuRotationY4","rotationY4","gpuRotationY4","cpuRotationZ4","rotationZ4","gpuRotationZ4","translate4","dualImpl","matrix","vector","mat4x4f","vec3f","stitch","scale4","rotateSignature","f32","rotateX4","angle","rotateY4","rotateZ4","workgroupBarrier","dualImpl","Void","storageBarrier","textureBarrier","atomicNormalError","atomicLoad","a","safeStringify","stitch","atomicActionSignature","param","u32","i32","atomicOpSignature","paramType","atomicStore","value","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","derivativeNormalError","dpdx","dualImpl","value","stitch","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","sizeOfPointedToArray","dataType","isPtr","isWgslArray","arrayLength","dualImpl","arg","ptrArg","ptrFn","abstractInt","u32","a","isRef","length","stitch","sampleCpu","_texture","_sampler","_coords","_offsetOrArrayIndex","_maybeOffset","textureSample","dualImpl","args","stitch","isDepth","f32","vec4f","sampleBiasCpu","_biasOrArrayIndex","_biasOrOffset","textureSampleBias","sampleLevelCpu","_level","textureSampleLevel","textureLoadCpu","_levelOrArrayIndex","textureLoad","texture","isWgslTexture","sampleType","vec4u","vec4i","format","dataType","getTextureFormatInfo","textureStoreCpu","_arrayIndexOrValue","_maybeValue","textureStore","Void","textureDimensionsCpu","textureDimensions","dim","u32","vec3u","vec2u","textureSampleCompareCpu","_depthRefOrArrayIndex","_depthRefOrOffset","textureSampleCompare","textureSampleBaseClampToEdgeCpu","sampler","coords","textureSampleBaseClampToEdge","errorMessage","subgroupAdd","dualImpl","arg","stitch","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","bool","subgroupAnd","subgroupAny","subgroupBallot","vec4u","subgroupBroadcast","args","id","unify","i32","u32","index","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","delta","subgroupShuffleUp","subgroupShuffleXor","mask","subgroupXor","extensionEnabled","comptime","extensionName","resolutionCtx","getResolutionCtx","wgslExtensions"]}
import{a as D,ib as O}from"./chunk-ECR2EGZX.js";import{C as y,D as f,E as m,F as d,L as x,La as P,R as g,S as T,T as A,W as B,Wa as l,a as o,aa as I,j as W,k as w,qc as h}from"./chunk-CRZWTZM2.js";function E(t){return u("function",t,"read-write")}function V(t){return u("private",t,"read-write")}function U(t){return u("workgroup",t,"read-write")}function $(t,e="read"){return u("storage",t,e)}function C(t){return u("uniform",t,"read")}function L(t){return u("handle",t,"read")}function u(t,e,r){return{[o]:!0,type:"ptr",addressSpace:t,inner:e,access:r}}var k=P(((t,e)=>e===void 0?r=>b(t,r):b(t,e)),(t,e)=>{if(e===void 0||e.value===void 0){let r=a=>k[o].gpuImpl(t,a);return r[o]=!0,I(r,B)}if(typeof e.value!="number")throw new Error(`Cannot create disarray schema with count unknown at compile-time: '${e.value}'`);return I(b(t.value,e.value),t.value)},"disarrayOf");function b(t,e){let r=a=>{if(a&&a.length!==e)throw new Error(`Disarray schema of ${e} elements of type ${t.type} called with ${a.length} argument(s).`);return Array.from({length:e},(s,n)=>h(t,a?.[n]))};if(Object.setPrototypeOf(r,M),r.elementType=t,!Number.isInteger(e)||e<0)throw new Error(`Cannot create disarray schema with invalid element count: ${e}.`);return r.elementCount=e,r}var M={[o]:!0,type:"disarray",toString(){return`disarrayOf(${this.elementType}, ${this.elementCount})`}};function j(t){let e=r=>Object.fromEntries(Object.entries(t).map(([a,s])=>[a,h(s,r?.[a])]));return Object.setPrototypeOf(e,F),e.propTypes=t,e}var F={[o]:!0,type:"unstruct",$name(t){return w(this,t),this},toString(){return`unstruct:${W(this)??"<unnamed>"}`}};function c(t,e){if(t===e)return!0;if(t.type!==e.type)return!1;if(f(t)&&f(e)||T(t)&&T(e)){let r=t.propTypes,a=e.propTypes,s=Object.keys(r),n=Object.keys(a);if(s.length!==n.length)return!1;for(let i=0;i<s.length;i++){let S=s[i],v=n[i];if(S!==v||!S||!v||!c(r[S],a[v]))return!1}return!0}if(y(t)&&y(e)||g(t)&&g(e))return t.elementCount===e.elementCount&&c(t.elementType,e.elementType);if(m(t)&&m(e))return t.addressSpace===e.addressSpace&&t.access===e.access&&c(t.inner,e.inner);if(d(t)&&d(e))return c(t.inner,e.inner);if(x(t)&&x(e)||A(t)&&A(e)){if(!c(t.inner,e.inner)||t.attribs.length!==e.attribs.length)return!1;let r=n=>{let i=n;return`${i.type}(${(i.params??[]).join(",")})`},a=t.attribs.map(r),s=e.attribs.map(r);for(let n=0;n<a.length;n++)if(a[n]!==s[n])return!1}return!0}function p(t,e){let r=t.prototype,a=O[e][o].jsImpl;r[e]=function(s){return a(this,s)}}p(l,"add");p(l,"sub");p(l,"mul");p(l,"div");p(D,"add");p(D,"sub");p(D,"mul");export{E as a,V as b,U as c,$ as d,C as e,L as f,k as g,j as h,c as i};
//# sourceMappingURL=chunk-6U5HPHCJ.js.map
{"version":3,"sources":["../src/data/ptr.ts","../src/data/disarray.ts","../src/data/unstruct.ts","../src/data/deepEqual.ts","../src/data/index.ts"],"sourcesContent":["import { $internal } from '../shared/symbols.ts';\nimport type { Access, AddressSpace, Ptr, StorableData } from './wgslTypes.ts';\n\nexport function ptrFn<T extends StorableData>(\n inner: T,\n): Ptr<'function', T, 'read-write'> {\n return INTERNAL_createPtr('function', inner, 'read-write');\n}\n\nexport function ptrPrivate<T extends StorableData>(\n inner: T,\n): Ptr<'private', T, 'read-write'> {\n return INTERNAL_createPtr('private', inner, 'read-write');\n}\n\nexport function ptrWorkgroup<T extends StorableData>(\n inner: T,\n): Ptr<'workgroup', T, 'read-write'> {\n return INTERNAL_createPtr('workgroup', inner, 'read-write');\n}\n\nexport function ptrStorage<\n T extends StorableData,\n TAccess extends 'read' | 'read-write' = 'read',\n>(inner: T, access: TAccess = 'read' as TAccess): Ptr<'storage', T, TAccess> {\n return INTERNAL_createPtr('storage', inner, access);\n}\n\nexport function ptrUniform<T extends StorableData>(\n inner: T,\n): Ptr<'uniform', T, 'read'> {\n return INTERNAL_createPtr('uniform', inner, 'read');\n}\n\nexport function ptrHandle<T extends StorableData>(\n inner: T,\n): Ptr<'handle', T, 'read'> {\n return INTERNAL_createPtr('handle', inner, 'read');\n}\n\nfunction INTERNAL_createPtr<\n TAddressSpace extends AddressSpace,\n TInner extends StorableData,\n TAccess extends Access,\n>(\n addressSpace: TAddressSpace,\n inner: TInner,\n access: TAccess,\n): Ptr<TAddressSpace, TInner, TAccess> {\n return {\n [$internal]: true,\n type: 'ptr',\n addressSpace,\n inner,\n access,\n } as Ptr<TAddressSpace, TInner, TAccess>;\n}\n","import { createDualImpl } from '../core/function/dualImpl.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { UnknownData } from './dataTypes.ts';\nimport { snip, type Snippet } from './snippet.ts';\nimport type { AnyData, Disarray } from './dataTypes.ts';\nimport { schemaCallWrapper } from './schemaCallWrapper.ts';\nimport type { AnyWgslData } from './wgslTypes.ts';\n\n// ----------\n// Public API\n// ----------\n\ninterface DisarrayConstructor {\n <TElement extends AnyData>(\n elementType: TElement,\n ): (elementCount: number) => Disarray<TElement>;\n\n <TElement extends AnyData>(\n elementType: TElement,\n elementCount: number,\n ): Disarray<TElement>;\n}\n\n/**\n * Creates an array schema that can be used to construct vertex buffers.\n * Describes arrays with fixed-size length, storing elements of the same type.\n *\n * Elements in the schema are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n *\n * @example\n * const disarray = d.disarrayOf(d.vec3f, 3); // packed array of vec3f\n *\n * @example\n * const disarray = d.disarrayOf(d.align(16, d.vec3f), 3);\n *\n * If `elementCount` is not specified, a partially applied function is returned.\n * @example\n * const disarray = d.disarrayOf(d.vec3f);\n * // ^? (n: number) => Disarray<d.Vec3f>\n *\n * @param elementType The type of elements in the array.\n * @param elementCount The number of elements in the array.\n */\nexport const disarrayOf = createDualImpl(\n // JS implementation\n ((elementType, elementCount) => {\n if (elementCount === undefined) {\n return (count: number) => cpu_disarrayOf(elementType, count);\n }\n return cpu_disarrayOf(elementType, elementCount);\n }) as DisarrayConstructor,\n // CODEGEN implementation\n (elementType, elementCount) => {\n if (elementCount === undefined || elementCount.value === undefined) {\n const partial = (count: Snippet) =>\n disarrayOf[$internal].gpuImpl(elementType, count);\n // Marking so the WGSL generator lets this function through\n partial[$internal] = true;\n\n return snip(partial, UnknownData);\n }\n\n if (typeof elementCount.value !== 'number') {\n throw new Error(\n `Cannot create disarray schema with count unknown at compile-time: '${elementCount.value}'`,\n );\n }\n\n return snip(\n cpu_disarrayOf(elementType.value as AnyWgslData, elementCount.value),\n elementType.value as AnyWgslData,\n );\n },\n 'disarrayOf',\n);\n\nexport function cpu_disarrayOf<TElement extends AnyData>(\n elementType: TElement,\n elementCount: number,\n): Disarray<TElement> {\n // In the schema call, create and return a deep copy\n // by wrapping all the values in `elementType` schema calls.\n const disarraySchema = (elements?: TElement[]) => {\n if (elements && elements.length !== elementCount) {\n throw new Error(\n `Disarray schema of ${elementCount} elements of type ${elementType.type} called with ${elements.length} argument(s).`,\n );\n }\n\n return Array.from(\n { length: elementCount },\n (_, i) => schemaCallWrapper(elementType, elements?.[i]),\n );\n };\n Object.setPrototypeOf(disarraySchema, DisarrayImpl);\n\n disarraySchema.elementType = elementType;\n\n if (!Number.isInteger(elementCount) || elementCount < 0) {\n throw new Error(\n `Cannot create disarray schema with invalid element count: ${elementCount}.`,\n );\n }\n disarraySchema.elementCount = elementCount;\n\n return disarraySchema as unknown as Disarray<TElement>;\n}\n\n// --------------\n// Implementation\n// --------------\n\nconst DisarrayImpl = {\n [$internal]: true,\n type: 'disarray',\n\n toString(this: Disarray): string {\n return `disarrayOf(${this.elementType}, ${this.elementCount})`;\n },\n};\n","import { getName, setName } from '../shared/meta.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport type { AnyData, Unstruct } from './dataTypes.ts';\nimport { schemaCallWrapper } from './schemaCallWrapper.ts';\nimport type { BaseData } from './wgslTypes.ts';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Creates a loose struct schema that can be used to construct vertex buffers.\n * Describes structs with members of both loose and non-loose types.\n *\n * The order of members matches the passed in properties object.\n * Members are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n *\n * @example\n * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.vec3f }); // packed struct with no padding\n *\n * @example\n * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.align(16, d.vec3f) });\n *\n * @param properties Record with `string` keys and `TgpuData` or `TgpuLooseData` values,\n * each entry describing one struct member.\n */\nexport function unstruct<TProps extends Record<string, BaseData>>(\n properties: TProps,\n): Unstruct<TProps> {\n // In the schema call, create and return a deep copy\n // by wrapping all the values in corresponding schema calls.\n const unstructSchema = (instanceProps?: TProps) =>\n Object.fromEntries(\n Object.entries(properties).map(([key, schema]) => [\n key,\n schemaCallWrapper(schema as AnyData, instanceProps?.[key]),\n ]),\n );\n Object.setPrototypeOf(unstructSchema, UnstructImpl);\n unstructSchema.propTypes = properties;\n\n return unstructSchema as unknown as Unstruct<TProps>;\n}\n\n// --------------\n// Implementation\n// --------------\n\nconst UnstructImpl = {\n [$internal]: true,\n type: 'unstruct',\n\n $name(label: string) {\n setName(this, label);\n return this;\n },\n\n toString(): string {\n return `unstruct:${getName(this) ?? '<unnamed>'}`;\n },\n};\n","import type { AnyAttribute } from './attributes.ts';\nimport { isDisarray, isLooseDecorated, isUnstruct } from './dataTypes.ts';\nimport type { AnyData } from './dataTypes.ts';\nimport {\n isAtomic,\n isDecorated,\n isPtr,\n isWgslArray,\n isWgslStruct,\n} from './wgslTypes.ts';\n\n/**\n * Performs a deep comparison of two TypeGPU data schemas.\n *\n * @param a The first data schema to compare.\n * @param b The second data schema to compare.\n * @returns `true` if the schemas are deeply equal, `false` otherwise.\n *\n * @example\n * ```ts\n * import { vec3f, struct, deepEqual } from 'typegpu/data';\n *\n * const schema1 = struct({ a: vec3f });\n * const schema2 = struct({ a: vec3f });\n * const schema3 = struct({ b: vec3f });\n *\n * console.log(deepEqual(schema1, schema2)); // true\n * console.log(deepEqual(schema1, schema3)); // false\n * ```\n */\nexport function deepEqual(a: AnyData, b: AnyData): boolean {\n if (a === b) {\n return true;\n }\n\n if (a.type !== b.type) {\n return false;\n }\n\n if (\n (isWgslStruct(a) && isWgslStruct(b)) ||\n (isUnstruct(a) && isUnstruct(b))\n ) {\n const aProps = a.propTypes;\n const bProps = b.propTypes;\n const aKeys = Object.keys(aProps);\n const bKeys = Object.keys(bProps);\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n for (let i = 0; i < aKeys.length; i++) {\n const keyA = aKeys[i];\n const keyB = bKeys[i];\n if (\n keyA !== keyB || !keyA || !keyB ||\n !deepEqual(aProps[keyA], bProps[keyB])\n ) {\n return false;\n }\n }\n return true;\n }\n\n if ((isWgslArray(a) && isWgslArray(b)) || (isDisarray(a) && isDisarray(b))) {\n return (\n a.elementCount === b.elementCount &&\n deepEqual(a.elementType as AnyData, b.elementType as AnyData)\n );\n }\n\n if (isPtr(a) && isPtr(b)) {\n return (\n a.addressSpace === b.addressSpace &&\n a.access === b.access &&\n deepEqual(a.inner as AnyData, b.inner as AnyData)\n );\n }\n\n if (isAtomic(a) && isAtomic(b)) {\n return deepEqual(a.inner as AnyData, b.inner as AnyData);\n }\n\n if (\n (isDecorated(a) && isDecorated(b)) ||\n (isLooseDecorated(a) && isLooseDecorated(b))\n ) {\n if (!deepEqual(a.inner as AnyData, b.inner as AnyData)) {\n return false;\n }\n if (a.attribs.length !== b.attribs.length) {\n return false;\n }\n\n // Create comparable string representations for each attribute\n const getAttrKey = (attr: unknown): string => {\n const anyAttr = attr as AnyAttribute;\n return `${anyAttr.type}(${(anyAttr.params ?? []).join(',')})`;\n };\n\n const attrsA = a.attribs.map(getAttrKey);\n const attrsB = b.attribs.map(getAttrKey);\n\n for (let i = 0; i < attrsA.length; i++) {\n if (attrsA[i] !== attrsB[i]) {\n return false;\n }\n }\n }\n\n // All other types have been checked for equality at the start\n return true;\n}\n","/**\n * @module typegpu/data\n */\n\nimport { type InfixOperator, infixOperators } from '../tgsl/wgslGenerator.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { MatBase } from './matrix.ts';\nimport { VecBase } from './vectorImpl.ts';\n\nfunction assignInfixOperator<T extends typeof VecBase | typeof MatBase>(\n object: T,\n operator: InfixOperator,\n) {\n type Instance = InstanceType<T>;\n\n const proto = object.prototype as {\n [K in InfixOperator]?: (this: Instance, other: unknown) => unknown;\n };\n const opImpl = infixOperators[operator][$internal].jsImpl as (\n lhs: Instance,\n rhs: unknown,\n ) => unknown;\n\n proto[operator] = function (this: Instance, other: unknown): unknown {\n return opImpl(this, other);\n };\n}\n\nassignInfixOperator(VecBase, 'add');\nassignInfixOperator(VecBase, 'sub');\nassignInfixOperator(VecBase, 'mul');\nassignInfixOperator(VecBase, 'div');\nassignInfixOperator(MatBase, 'add');\nassignInfixOperator(MatBase, 'sub');\nassignInfixOperator(MatBase, 'mul');\n\nexport { bool, f16, f32, i32, u16, u32 } from './numeric.ts';\nexport {\n isAlignAttrib,\n isAtomic,\n isBuiltinAttrib,\n isDecorated,\n isInterpolateAttrib,\n isLocationAttrib,\n isPtr,\n isSizeAttrib,\n isWgslArray,\n isWgslData,\n isWgslStruct,\n Void,\n} from './wgslTypes.ts';\nexport type {\n Align,\n AnyVecInstance,\n AnyWgslData,\n AnyWgslStruct,\n Atomic,\n BaseData,\n BaseData as BaseWgslData,\n Bool,\n Builtin,\n Decorated,\n F16,\n F32,\n I32,\n Interpolate,\n Location,\n m2x2f,\n m3x3f,\n m4x4f,\n Mat2x2f,\n Mat3x3f,\n Mat4x4f,\n Ptr,\n Size,\n StorableData,\n U16,\n U32,\n v2b,\n v2f,\n v2i,\n v2u,\n v3b,\n v3f,\n v3i,\n v3u,\n v4b,\n v4f,\n v4i,\n v4u,\n Vec2b,\n Vec2f,\n Vec2h,\n Vec2i,\n Vec2u,\n Vec3b,\n Vec3f,\n Vec3h,\n Vec3i,\n Vec3u,\n Vec4b,\n Vec4f,\n Vec4h,\n Vec4i,\n Vec4u,\n WgslArray,\n WgslStruct,\n} from './wgslTypes.ts';\nexport { struct } from './struct.ts';\nexport { arrayOf } from './array.ts';\nexport {\n ptrFn,\n ptrHandle,\n ptrPrivate,\n ptrStorage,\n ptrUniform,\n ptrWorkgroup,\n} from './ptr.ts';\nexport type {\n AnyData,\n AnyLooseData,\n Disarray,\n LooseDecorated,\n Unstruct,\n} from './dataTypes.ts';\nexport {\n texture1d,\n texture2d,\n texture2dArray,\n texture3d,\n textureCube,\n textureCubeArray,\n textureDepth2d,\n textureDepth2dArray,\n textureDepthCube,\n textureDepthCubeArray,\n textureDepthMultisampled2d,\n textureExternal,\n textureMultisampled2d,\n textureStorage1d,\n textureStorage2d,\n textureStorage2dArray,\n textureStorage3d,\n type WgslExternalTexture,\n type WgslStorageTexture,\n type WgslStorageTexture1d,\n type WgslStorageTexture2d,\n type WgslStorageTexture2dArray,\n type WgslStorageTexture3d,\n type WgslStorageTextureProps,\n type WgslTexture,\n type WgslTexture1d,\n type WgslTexture2d,\n type WgslTexture2dArray,\n type WgslTexture3d,\n type WgslTextureCube,\n type WgslTextureCubeArray,\n type WgslTextureDepth2d,\n type WgslTextureDepth2dArray,\n type WgslTextureDepthCube,\n type WgslTextureDepthCubeArray,\n type WgslTextureDepthMultisampled2d,\n type WgslTextureMultisampled2d,\n} from './texture.ts';\nexport {\n comparisonSampler,\n sampler,\n type WgslComparisonSampler,\n type WgslSampler,\n} from './sampler.ts';\nexport {\n vec2b,\n vec2f,\n vec2h,\n vec2i,\n vec2u,\n vec3b,\n vec3f,\n vec3h,\n vec3i,\n vec3u,\n vec4b,\n vec4f,\n vec4h,\n vec4i,\n vec4u,\n} from './vector.ts';\nexport { disarrayOf } from './disarray.ts';\nexport { unstruct } from './unstruct.ts';\nexport { mat2x2f, mat3x3f, mat4x4f, matToArray } from './matrix.ts';\nexport * from './vertexFormatData.ts';\nexport { atomic } from './atomic.ts';\nexport {\n align,\n type AnyAttribute,\n type HasCustomLocation,\n interpolate,\n invariant,\n type IsBuiltin,\n isBuiltin,\n location,\n size,\n} from './attributes.ts';\nexport {\n isData,\n isDisarray,\n isLooseData,\n isLooseDecorated,\n isUnstruct,\n} from './dataTypes.ts';\nexport { PUBLIC_sizeOf as sizeOf } from './sizeOf.ts';\nexport { PUBLIC_alignmentOf as alignmentOf } from './alignmentOf.ts';\nexport { builtin } from '../builtin.ts';\nexport { deepEqual } from './deepEqual.ts';\nexport type {\n AnyBuiltin,\n BuiltinClipDistances,\n BuiltinFragDepth,\n BuiltinFrontFacing,\n BuiltinGlobalInvocationId,\n BuiltinInstanceIndex,\n BuiltinLocalInvocationId,\n BuiltinLocalInvocationIndex,\n BuiltinNumWorkgroups,\n BuiltinPosition,\n BuiltinSampleIndex,\n BuiltinSampleMask,\n BuiltinVertexIndex,\n BuiltinWorkgroupId,\n} from '../builtin.ts';\nexport type { Infer, InferGPU, InferPartial } from '../shared/repr.ts';\n"],"mappings":"qMAGO,SAASA,EACdC,EACkC,CAClC,OAAOC,EAAmB,WAAYD,EAAO,YAAY,CAC3D,CAEO,SAASE,EACdF,EACiC,CACjC,OAAOC,EAAmB,UAAWD,EAAO,YAAY,CAC1D,CAEO,SAASG,EACdH,EACmC,CACnC,OAAOC,EAAmB,YAAaD,EAAO,YAAY,CAC5D,CAEO,SAASI,EAGdJ,EAAUK,EAAkB,OAA+C,CAC3E,OAAOJ,EAAmB,UAAWD,EAAOK,CAAM,CACpD,CAEO,SAASC,EACdN,EAC2B,CAC3B,OAAOC,EAAmB,UAAWD,EAAO,MAAM,CACpD,CAEO,SAASO,EACdP,EAC0B,CAC1B,OAAOC,EAAmB,SAAUD,EAAO,MAAM,CACnD,CAEA,SAASC,EAK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ptrHandle","addressSpace","$internal","disarrayOf","createDualImpl","elementType","elementCount","count","cpu_disarrayOf","partial","$internal","snip","UnknownData","disarraySchema","elements","_","i","schemaCallWrapper","DisarrayImpl","unstruct","properties","unstructSchema","instanceProps","key","schema","schemaCallWrapper","UnstructImpl","$internal","label","setName","getName","deepEqual","a","b","isWgslStruct","isUnstruct","aProps","bProps","aKeys","bKeys","keyA","keyB","isWgslArray","isDisarray","isPtr","isAtomic","isDecorated","isLooseDecorated","getAttrKey","attr","anyAttr","attrsA","attrsB","i","assignInfixOperator","object","operator","proto","opImpl","infixOperators","$internal","other","VecBase","MatBase"]}
import{B as P,D as I,M as N,P as _,Q as U,U as T,V as H,a as L,aa as y,c as D,f as W,ga as K,j as g,k as h,l as k,lc as w,m as M,n as j,oc as q,pc as J,q as C,rc as z,va as G}from"./chunk-CRZWTZM2.js";import{FuncParameterType as ee}from"tinyest";function S(n,e){for(let[r,t]of Object.entries(e))n[r]=t,t&&(typeof t=="object"||typeof t=="function")&&g(t)===void 0&&h(t,r)}function Se(n,e,r){let t=[...n.matchAll(/:\s*(?<arg>.*?)\s*[,)]/g)].map(s=>s?s[1]:void 0);r(Object.fromEntries(e.flatMap((s,i)=>{let o=t?t[i]:void 0;return I(s)&&o!==void 0?[[o,s]]:[]})))}function $e(n,e,r){let t=n.match(/->\s(?<output>[\w\d_]+)\s{/),s=t?t[1]?.trim():void 0;I(e)&&s&&!/\s/g.test(s)&&r({[s]:e})}function ue(n){return new RegExp(`(?<![\\w\\$_.])${n.replaceAll(".","\\.").replaceAll("$","\\$")}(?![\\w\\$_])`,"g")}function R(n,e,r){return Object.entries(e).reduce((t,[s,i])=>{let o=ue(s);if(r&&s!=="Out"&&s!=="In"&&!o.test(r)&&console.warn(`The external '${s}' wasn't used in the resolved template.`),G(i)||U(i)||M(i))return t.replaceAll(o,n.resolve(i).value);if(i!==null&&typeof i=="object"){let a=[...r.matchAll(new RegExp(`${s.replaceAll(".","\\.").replaceAll("$","\\$")}\\.(?<prop>.*?)(?![\\w\\$_])`,"g"))].map(d=>d[1]);return[...new Set(a)].reduce((d,f)=>f&&f in i?R(n,{[`${s}.${f}`]:i[f]},d):d,t)}return console.warn(`During resolution, the external '${s}' has been omitted. Only primitives, TGPU resources and plain JS objects can be used as externals.`),t},r)}function Y(n){let{strippedCode:e,argRange:r}=pe(n),t=new $(e);t.consume("(");let s=[];for(;!t.isAt(")");){let o=[];for(;t.isAt("@");)t.parseUntil(Q,X),t.consume(")"),o.push(t.lastParsed);t.parseUntil(ce);let a=t.lastParsed,l;t.isAt(":")&&(t.consume(":"),t.parseUntil(de,fe),l=t.lastParsed),s.push({identifier:a,attributes:o,type:l}),t.isAt(",")&&t.consume(",")}t.consume(")");let i;if(t.isAt("->")){t.consume("->");let o=[];for(;t.isAt("@");)t.parseUntil(Q,X),t.consume(")"),o.push(t.lastParsed);i={type:t.str.slice(t.pos),attributes:o}}return{args:s,ret:i,range:{begin:r[0],end:r[1]}}}function pe(n){let e=new $(n),r="",t;for(;!e.isFinished();){if(e.isAt(le)){e.advanceBy(1);continue}if(e.isAt("//")){e.consume("//"),e.parseUntil(Z),e.advanceBy(1);continue}if(e.isAt("/*")){e.parseUntil(me,ge),e.consume("*/");continue}if(e.isAt("{"))return{strippedCode:r,argRange:[t,e.pos]};e.isAt("(")&&t===void 0&&(t=e.pos),t!==void 0&&(r+=e.str[e.pos]),e.advanceBy(1)}throw new Error("Invalid wgsl code!")}var $=class{constructor(e){this.str=e;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(e){if(typeof e=="string"){for(let r=0;r<e.length;r++)if(this.str[this.#e+r]!==e[r])return!1;return!0}for(let r of e)if(this.isAt(r))return!0;return!1}parseUntil(e,r){this.#t=this.#e;let t=0;for(;this.#e<this.str.length;){if(r&&this.isAt(r[0])&&(t+=1),r&&this.isAt(r[1])&&(t-=1),t===0&&this.isAt(e))return this.#e;this.#e+=1}throw new Error("Reached the end of the string without finding a match!")}advanceBy(e){this.#e+=e}consume(e){if(!this.isAt(e))throw new Error(`Expected '${e}' at position ${this.#e}, but found '${this.str.slice(this.#e,this.#e+e.length)}'`);this.advanceBy(e.length)}},Z=new Set([`
`,"\v","\f","\r","\x85","\u2028","\u2029"]),le=new Set([...Z," "," ","\u200E","\u200F"]),Q=new Set([")"]),ce=new Set([":",",",")"]),de=new Set([",",")"]),me=new Set(["*/"]),X=["(",")"],fe=["<",">"],ge=["/*","*/"];function ne(n,e=""){let r=[],t={applyExternals(i){r.push(i)},resolve(i,o,a){let l={};for(let u of r)S(l,u);let d=i.getUniqueName(this);if(typeof n=="string"){if(!a)throw new Error("Explicit return type is required for string implementation");let u=R(i,l,n),m="",x="";if(e!==""){let p=I(o[0])?`(in: ${i.resolve(o[0]).value})`:"()",c=P(a)?J(a):"",b=a!==C?I(a)?`-> ${i.resolve(a).value}`:`-> ${c!==""?c:"@location(0)"} ${i.resolve(a).value}`:"";m=`${p} ${b} `,x=u}else{let p=Y(u);if(p.args.length!==o.length)throw new Error(`WGSL implementation has ${p.args.length} arguments, while the shell has ${o.length} arguments.`);let c=p.args.map((E,ae)=>`${E.identifier}: ${te(i,`parameter ${E.identifier}`,E.type,o[ae])}`).join(", "),b=a===C?"":`-> ${te(i,"return type",p.ret?.type,a)}`;m=`(${c}) ${b}`,x=u.slice(p.range.end)}return i.addDeclaration(`${e}fn ${d}${m}${x}`),y(d,a)}let f=j(n);if(f?.externals){let u=Object.fromEntries(Object.entries(f.externals).filter(([m])=>!(m in l)));S(l,u)}let O=f?.ast;if(!O)throw new Error("Missing metadata for tgpu.fn function body (either missing 'use gpu' directive, or misconfigured `unplugin-typegpu`)");let B=O.externalNames.filter(u=>!(u in l));if(B.length>0)throw new K(g(this),B);let A=O.params[1];A&&A.type==="i"&&e!==""&&S(l,{[A.name]:_(a)});let V=[],v=[];for(let[u,m]of o.entries()){let x=O.params[u];switch(x?.type){case ee.identifier:{let p=x.name,c=y(i.makeNameValid(p),m);V.push(c),c.value!==p&&v.push([p,c]);break}case ee.destructuredObject:{V.push(y(`_arg_${u}`,m)),v.push(...x.props.map(({name:p,alias:c})=>[c,y(`_arg_${u}.${p}`,o[u].propTypes[p])]));break}case void 0:V.push(y(`_arg_${u}`,m))}}let{head:ie,body:se,returnType:oe}=i.fnToWgsl({args:V,argAliases:Object.fromEntries(v),returnType:a,body:O.body,externalMap:l});return i.addDeclaration(`${e}fn ${d}${i.resolve(ie).value}${i.resolve(se).value}`),y(d,oe)}},s=g(n);return s!==void 0&&h(t,s),t}function te(n,e,r,t){let s=n.resolve(t).value.replace(/\s/g,"");if(!r)return s;let i=r.replace(/\s/g,"");if(i!==s)throw new Error(`Type mismatch between TGPU shell and WGSL code string: ${e}, JS type "${s}", WGSL type "${i}".`);return r}function xe(n,e={}){let r=0,t=new Set;return Object.fromEntries(Object.entries(n??{}).map(([s,i])=>{let o=T(i);if(o!==void 0){if(t.has(o))throw new Error("Duplicate custom location attributes found");t.add(o)}return[s,i]}).map(([s,i])=>{if(q(i))return[s,i];if(T(i)!==void 0)return[s,i];if(e[s])return[s,w(e[s],i)];for(;t.has(r);)r++;return[s,w(r++,i)]}))}function F(n,e={}){return H(n)?N(n)||T(n)!==void 0?n:w(0,n):z(xe(n,e))}function re(n,...e){return ye(n)?he(n,...e):n}function ye(n){return Array.isArray(n)&&"raw"in n&&Array.isArray(n.raw)&&n.raw.every(e=>typeof e=="string")}function he(n,...e){return n.slice(1).reduce((r,t,s)=>`${r}${e[s]}${t}`,n[0])}function Qe(n){if(Object.keys(n.out).length===0)throw new Error("A vertexFn output cannot be empty since it must include the 'position' builtin.");let e={in:n.in,out:n.out,argTypes:n.in&&Object.keys(n.in).length!==0?[F(n.in)]:[],isEntry:!0},r=(t,...s)=>Ie(e,re(t,...s));return Object.assign(Object.assign(r,e),{does:r})}function Ie(n,e){let r=ne(e,"@vertex "),t=n.argTypes[0];return{shell:n,$uses(i){return r.applyExternals(i),this},[L]:!0,[D]:r,$name(i){return h(r,i),k(t)&&t.$name(`${i}_Input`),this},[W](i){let o=F(n.out,i.varyingLocations).$name(`${g(this)??""}_Output`);return typeof e=="string"&&(t&&r.applyExternals({In:t}),r.applyExternals({Out:o})),r.resolve(i,n.argTypes,o)},toString(){return`vertexFn:${g(r)??"<unnamed>"}`}}}export{S as a,Se as b,$e as c,R as d,ne as e,F as f,re as g,Qe as h};
//# sourceMappingURL=chunk-CGQB3SER.js.map
{"version":3,"sources":["../src/core/function/fnCore.ts","../src/core/resolve/externals.ts","../src/core/function/extractArgs.ts","../src/core/function/ioSchema.ts","../src/core/function/templateUtils.ts","../src/core/function/tgpuVertexFn.ts"],"sourcesContent":["import { FuncParameterType } from 'tinyest';\nimport { getAttributesString } from '../../data/attributes.ts';\nimport { type AnyData, undecorate } from '../../data/dataTypes.ts';\nimport {\n type ResolvedSnippet,\n snip,\n type Snippet,\n} from '../../data/snippet.ts';\nimport {\n isWgslData,\n isWgslStruct,\n Void,\n type WgslStruct,\n} from '../../data/wgslTypes.ts';\nimport { MissingLinksError } from '../../errors.ts';\nimport { getMetaData, getName, setName } from '../../shared/meta.ts';\nimport type { ResolutionCtx } from '../../types.ts';\nimport {\n applyExternals,\n type ExternalMap,\n replaceExternalsInWgsl,\n} from '../resolve/externals.ts';\nimport { extractArgs } from './extractArgs.ts';\nimport type { Implementation } from './fnTypes.ts';\n\nexport interface FnCore {\n applyExternals(newExternals: ExternalMap): void;\n resolve(\n ctx: ResolutionCtx,\n argTypes: AnyData[],\n /**\n * The return type of the function. If undefined, the type should be inferred\n * from the implementation (relevant for shellless functions).\n */\n returnType: AnyData | undefined,\n ): ResolvedSnippet;\n}\n\nexport function createFnCore(\n implementation: Implementation,\n fnAttribute = '',\n): FnCore {\n /**\n * External application has to be deferred until resolution because\n * some externals can reference the owner function which has not been\n * initialized yet (like when accessing the Output struct of a vertex\n * entry fn).\n */\n const externalsToApply: ExternalMap[] = [];\n\n const core = {\n applyExternals(newExternals: ExternalMap): void {\n externalsToApply.push(newExternals);\n },\n\n resolve(\n ctx: ResolutionCtx,\n argTypes: AnyData[],\n returnType: AnyData | undefined,\n ): ResolvedSnippet {\n const externalMap: ExternalMap = {};\n\n for (const externals of externalsToApply) {\n applyExternals(externalMap, externals);\n }\n\n const id = ctx.getUniqueName(this);\n\n if (typeof implementation === 'string') {\n if (!returnType) {\n throw new Error(\n 'Explicit return type is required for string implementation',\n );\n }\n\n const replacedImpl = replaceExternalsInWgsl(\n ctx,\n externalMap,\n implementation,\n );\n\n let header = '';\n let body = '';\n\n if (fnAttribute !== '') {\n const input = isWgslStruct(argTypes[0])\n ? `(in: ${ctx.resolve(argTypes[0]).value})`\n : '()';\n\n const attributes = isWgslData(returnType)\n ? getAttributesString(returnType)\n : '';\n const output = returnType !== Void\n ? isWgslStruct(returnType)\n ? `-> ${ctx.resolve(returnType).value}`\n : `-> ${attributes !== '' ? attributes : '@location(0)'} ${\n ctx.resolve(returnType).value\n }`\n : '';\n\n header = `${input} ${output} `;\n body = replacedImpl;\n } else {\n const providedArgs = extractArgs(replacedImpl);\n\n if (providedArgs.args.length !== argTypes.length) {\n throw new Error(\n `WGSL implementation has ${providedArgs.args.length} arguments, while the shell has ${argTypes.length} arguments.`,\n );\n }\n\n const input = providedArgs.args.map((argInfo, i) =>\n `${argInfo.identifier}: ${\n checkAndReturnType(\n ctx,\n `parameter ${argInfo.identifier}`,\n argInfo.type,\n argTypes[i],\n )\n }`\n ).join(', ');\n\n const output = returnType === Void ? '' : `-> ${\n checkAndReturnType(\n ctx,\n 'return type',\n providedArgs.ret?.type,\n returnType,\n )\n }`;\n\n header = `(${input}) ${output}`;\n\n body = replacedImpl.slice(providedArgs.range.end);\n }\n\n ctx.addDeclaration(`${fnAttribute}fn ${id}${header}${body}`);\n return snip(id, returnType);\n }\n\n // get data generated by the plugin\n const pluginData = getMetaData(implementation);\n\n if (pluginData?.externals) {\n const missing = Object.fromEntries(\n Object.entries(pluginData.externals).filter(\n ([name]) => !(name in externalMap),\n ),\n );\n\n applyExternals(externalMap, missing);\n }\n\n const ast = pluginData?.ast;\n if (!ast) {\n throw new Error(\n \"Missing metadata for tgpu.fn function body (either missing 'use gpu' directive, or misconfigured `unplugin-typegpu`)\",\n );\n }\n\n // verify all required externals are present\n const missingExternals = ast.externalNames.filter(\n (name) => !(name in externalMap),\n );\n if (missingExternals.length > 0) {\n throw new MissingLinksError(getName(this), missingExternals);\n }\n\n // If an entrypoint implementation has a second argument, it represents the output schema.\n // We look at the identifier chosen by the user and add it to externals.\n const maybeSecondArg = ast.params[1];\n if (\n maybeSecondArg && maybeSecondArg.type === 'i' && fnAttribute !== ''\n ) {\n applyExternals(\n externalMap,\n {\n // biome-ignore lint/style/noNonNullAssertion: entry functions cannot be shellless\n [maybeSecondArg.name]: undecorate(returnType!),\n },\n );\n }\n\n // generate wgsl string\n\n const args: Snippet[] = [];\n const argAliases: [string, Snippet][] = [];\n\n for (const [i, argType] of argTypes.entries()) {\n const astParam = ast.params[i];\n\n switch (astParam?.type) {\n case FuncParameterType.identifier: {\n const rawName = astParam.name;\n const snippet = snip(ctx.makeNameValid(rawName), argType);\n args.push(snippet);\n if (snippet.value !== rawName) {\n argAliases.push([rawName, snippet]);\n }\n break;\n }\n case FuncParameterType.destructuredObject: {\n args.push(snip(`_arg_${i}`, argType));\n argAliases.push(...astParam.props.map(({ name, alias }) =>\n [\n alias,\n snip(\n `_arg_${i}.${name}`,\n (argTypes[i] as WgslStruct)\n .propTypes[name],\n ),\n ] as [string, Snippet]\n ));\n break;\n }\n case undefined:\n args.push(snip(`_arg_${i}`, argType));\n }\n }\n\n const { head, body, returnType: actualReturnType } = ctx.fnToWgsl({\n args,\n argAliases: Object.fromEntries(argAliases),\n returnType,\n body: ast.body,\n externalMap,\n });\n\n ctx.addDeclaration(\n `${fnAttribute}fn ${id}${ctx.resolve(head).value}${\n ctx.resolve(body).value\n }`,\n );\n\n return snip(id, actualReturnType);\n },\n };\n\n // The implementation could have been given a name by a bundler plugin,\n // so we try to transfer it to the core.\n const maybeName = getName(implementation);\n if (maybeName !== undefined) {\n setName(core, maybeName);\n }\n\n return core;\n}\n\nfunction checkAndReturnType(\n ctx: ResolutionCtx,\n name: string,\n wgslType: string | undefined,\n jsType: unknown,\n) {\n const resolvedJsType = ctx.resolve(jsType).value.replace(/\\s/g, '');\n\n if (!wgslType) {\n return resolvedJsType;\n }\n\n const resolvedWgslType = wgslType.replace(/\\s/g, '');\n\n if (resolvedWgslType !== resolvedJsType) {\n throw new Error(\n `Type mismatch between TGPU shell and WGSL code string: ${name}, JS type \"${resolvedJsType}\", WGSL type \"${resolvedWgslType}\".`,\n );\n }\n\n return wgslType;\n}\n","import { isLooseData } from '../../data/dataTypes.ts';\nimport { isWgslStruct } from '../../data/wgslTypes.ts';\nimport { getName, hasTinyestMetadata, setName } from '../../shared/meta.ts';\nimport { isWgsl, type ResolutionCtx } from '../../types.ts';\n\n/**\n * A key-value mapping where keys represent identifiers within shader code,\n * and values can be any type that can be resolved to a code string.\n */\nexport type ExternalMap = Record<string, unknown>;\n\n/**\n * Merges two external maps into one. If a key is present in both maps, the value from the new map is used.\n * If the external value is a namable object, it is given a name if it does not already have one.\n * @param existing - The existing external map.\n * @param newExternals - The new external map.\n */\nexport function applyExternals(\n existing: ExternalMap,\n newExternals: ExternalMap,\n) {\n for (const [key, value] of Object.entries(newExternals)) {\n existing[key] = value;\n\n // Giving name to external value, if it does not already have one.\n if (\n value && (typeof value === 'object' || typeof value === 'function') &&\n getName(value) === undefined\n ) {\n setName(value, key);\n }\n }\n}\n\nexport function addArgTypesToExternals(\n implementation: string,\n argTypes: unknown[],\n applyExternals: (externals: ExternalMap) => void,\n) {\n const argTypeNames = [\n ...implementation.matchAll(/:\\s*(?<arg>.*?)\\s*[,)]/g),\n ].map((found) => (found ? found[1] : undefined));\n\n applyExternals(\n Object.fromEntries(\n argTypes.flatMap((argType, i) => {\n const argTypeName = argTypeNames ? argTypeNames[i] : undefined;\n return isWgslStruct(argType) && argTypeName !== undefined\n ? [[argTypeName, argType]]\n : [];\n }),\n ),\n );\n}\n\nexport function addReturnTypeToExternals(\n implementation: string,\n returnType: unknown,\n applyExternals: (externals: ExternalMap) => void,\n) {\n const matched = implementation.match(/->\\s(?<output>[\\w\\d_]+)\\s{/);\n const outputName = matched ? matched[1]?.trim() : undefined;\n\n if (isWgslStruct(returnType) && outputName && !/\\s/g.test(outputName)) {\n applyExternals({ [outputName]: returnType });\n }\n}\n\nfunction identifierRegex(name: string) {\n return new RegExp(\n `(?<![\\\\w\\\\$_.])${\n name.replaceAll('.', '\\\\.').replaceAll('$', '\\\\$')\n }(?![\\\\w\\\\$_])`,\n 'g',\n );\n}\n\n/**\n * Replaces all occurrences of external names in WGSL code with their resolved values.\n * It adds all necessary definitions to the resolution context.\n * @param ctx - The resolution context.\n * @param externalMap - The external map.\n * @param wgsl - The WGSL code.\n *\n * @returns The WGSL code with all external names replaced with their resolved values.\n */\nexport function replaceExternalsInWgsl(\n ctx: ResolutionCtx,\n externalMap: ExternalMap,\n wgsl: string,\n): string {\n return Object.entries(externalMap).reduce((acc, [externalName, external]) => {\n const externalRegex = identifierRegex(externalName);\n if (\n wgsl &&\n externalName !== 'Out' &&\n externalName !== 'In' &&\n !externalRegex.test(wgsl)\n ) {\n console.warn(\n `The external '${externalName}' wasn't used in the resolved template.`,\n );\n // continue anyway, we still might need to resolve the external\n }\n\n if (\n isWgsl(external) || isLooseData(external) || hasTinyestMetadata(external)\n ) {\n return acc.replaceAll(externalRegex, ctx.resolve(external).value);\n }\n\n if (external !== null && typeof external === 'object') {\n const foundProperties = [\n ...wgsl.matchAll(\n new RegExp(\n `${\n externalName.replaceAll('.', '\\\\.').replaceAll('$', '\\\\$')\n }\\\\.(?<prop>.*?)(?![\\\\w\\\\$_])`,\n 'g',\n ),\n ),\n ].map((found) => found[1]);\n const uniqueProperties = [...new Set(foundProperties)];\n\n return uniqueProperties.reduce(\n (innerAcc: string, prop) =>\n prop && prop in external\n ? replaceExternalsInWgsl(\n ctx,\n {\n [`${externalName}.${prop}`]:\n external[prop as keyof typeof external],\n },\n innerAcc,\n )\n : innerAcc,\n acc,\n );\n }\n\n console.warn(\n `During resolution, the external '${externalName}' has been omitted. Only primitives, TGPU resources and plain JS objects can be used as externals.`,\n );\n\n return acc;\n }, wgsl);\n}\n","interface FunctionArgsInfo {\n args: ArgInfo[];\n ret: ReturnInfo | undefined;\n range: {\n begin: number;\n end: number;\n };\n}\n\ninterface ArgInfo {\n identifier: string;\n attributes: string[];\n type: string | undefined;\n}\n\ninterface ReturnInfo {\n attributes: string[];\n type: string;\n}\n\n/**\n * Extracts info about arguments of a given WGSL function string.\n * @example\n * const code = `\n * fn add(a: i32, @location(0) b: i32, c) -> i32 {\n * return a + b + c;\n * }`;\n *\n * extractArgs(code);\n * // {\n * // args: [\n * // { identifier: 'a', attributes: [], type: 'i32' },\n * // { identifier: 'b', attributes: ['@location(0)'], type: 'i32' },\n * // { identifier: 'c', attributes: [], type: undefined }\n * // ],\n * // ret: { type: 'i32', attributes: [] },\n * // range: { begin: 11, end: 51 }\n * // }\n */\nexport function extractArgs(rawCode: string): FunctionArgsInfo {\n const { strippedCode, argRange: range } = strip(rawCode);\n const code = new ParsableString(strippedCode);\n code.consume('(');\n\n const args: ArgInfo[] = [];\n while (!code.isAt(')')) {\n // In each loop iteration, process all the attributes, the identifier and the potential type of a single argument.\n\n const attributes = [];\n while (code.isAt('@')) {\n code.parseUntil(closingParenthesis, parentheses);\n code.consume(')');\n attributes.push(code.lastParsed);\n }\n\n code.parseUntil(identifierEndSymbols);\n const identifier = code.lastParsed;\n\n let maybeType: string | undefined;\n if (code.isAt(':')) {\n code.consume(':');\n code.parseUntil(typeEndSymbols, angleBrackets);\n maybeType = code.lastParsed;\n }\n\n args.push({\n identifier,\n attributes,\n type: maybeType,\n });\n\n if (code.isAt(',')) {\n code.consume(',');\n }\n }\n code.consume(')');\n\n let maybeRet: ReturnInfo | undefined;\n if (code.isAt('->')) {\n code.consume('->');\n\n const attributes = [];\n while (code.isAt('@')) {\n code.parseUntil(closingParenthesis, parentheses);\n code.consume(')');\n attributes.push(code.lastParsed);\n }\n\n maybeRet = { type: code.str.slice(code.pos), attributes };\n }\n\n return {\n args,\n ret: maybeRet,\n range: { begin: range[0], end: range[1] },\n };\n}\n\n/**\n * Strips comments, whitespaces, the name and the body of the function.\n * @example\n * const code = `\n * fn add( a, // first argument\n * @location(0) b : i32 ) -> i32 {\n * return a + b; // returns the sum\n * }`;\n *\n * strip(code); // \"(a,@location(0)b:i32)->i32\"\n */\nfunction strip(\n rawCode: string,\n): { strippedCode: string; argRange: [number, number] } {\n const code = new ParsableString(rawCode);\n let strippedCode = '';\n let argsStart: number | undefined;\n\n while (!code.isFinished()) {\n // parse character by character while ignoring comments and blankspaces until you find a `{`.\n\n // skip any blankspace\n if (code.isAt(blankSpaces)) {\n code.advanceBy(1); // the blankspace character\n continue;\n }\n\n // skip line comments\n if (code.isAt('//')) {\n code.consume('//');\n code.parseUntil(lineBreaks);\n code.advanceBy(1); // the line break\n continue;\n }\n\n // skip block comments\n if (code.isAt('/*')) {\n code.parseUntil(openingCommentBlock, commentBlocks);\n code.consume('*/');\n continue;\n }\n\n if (code.isAt('{')) {\n return {\n strippedCode,\n argRange: [argsStart as number, code.pos],\n };\n }\n\n if (code.isAt('(') && argsStart === undefined) {\n argsStart = code.pos;\n }\n\n if (argsStart !== undefined) {\n strippedCode += code.str[code.pos];\n }\n code.advanceBy(1); // parsed character\n }\n throw new Error('Invalid wgsl code!');\n}\n\nclass ParsableString {\n #parseStartPos: number | undefined;\n #pos: number;\n constructor(public readonly str: string) {\n this.#pos = 0;\n }\n\n get pos(): number {\n return this.#pos;\n }\n\n /**\n * This property is equivalent to the substring of `this.str`\n * from the position of the last `parseUntil` call, to the current position.\n */\n get lastParsed(): string {\n if (this.#parseStartPos === undefined) {\n throw new Error('Parse was not called yet!');\n }\n return this.str.slice(this.#parseStartPos, this.pos);\n }\n\n isFinished() {\n return this.#pos >= this.str.length;\n }\n\n isAt(substr: string | Set<string>): boolean {\n if (typeof substr === 'string') {\n for (let i = 0; i < substr.length; i++) {\n if (this.str[this.#pos + i] !== substr[i]) {\n return false;\n }\n }\n return true;\n }\n for (const elem of substr) {\n if (this.isAt(elem)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @param toFind a set of strings either of which satisfy the search.\n * @param brackets a pair of brackets that has to be closed for result to be valid. This includes the found character(s).\n * @example\n * // internal state:\n * // '(@attribute(0) identifier: type)'\n * // ^\n * this.parse(new Set(')'), ['(', ')']);\n * // internal state:\n * // '(@attribute(0) identifier: type)'\n * // ^\n */\n parseUntil(\n toFind: Set<string>,\n brackets?: readonly [string, string],\n ): number {\n this.#parseStartPos = this.#pos;\n let openedBrackets = 0;\n while (this.#pos < this.str.length) {\n if (brackets && this.isAt(brackets[0])) {\n openedBrackets += 1;\n }\n if (brackets && this.isAt(brackets[1])) {\n openedBrackets -= 1;\n }\n if (openedBrackets === 0) {\n if (this.isAt(toFind)) {\n return this.#pos;\n }\n }\n this.#pos += 1;\n }\n throw new Error('Reached the end of the string without finding a match!');\n }\n\n advanceBy(steps: number) {\n this.#pos += steps;\n }\n\n consume(str: string): void {\n if (!this.isAt(str)) {\n throw new Error(\n `Expected '${str}' at position ${this.#pos}, but found '${\n this.str.slice(this.#pos, this.#pos + str.length)\n }'`,\n );\n }\n this.advanceBy(str.length);\n }\n}\n\nconst lineBreaks = new Set<string>([\n '\\u000A', // line feed\n '\\u000B', // vertical tab\n '\\u000C', // form feed\n '\\u000D', // carriage return\n '\\u0085', // next line\n '\\u2028', // line separator\n '\\u2029', // paragraph separator\n]);\nconst blankSpaces = new Set<string>([\n ...lineBreaks,\n '\\u0020', // space\n '\\u0009', // horizontal tab\n '\\u200E', // left-to-right mark\n '\\u200F', // right-to-left mark\n]);\nconst closingParenthesis = new Set<string>([')']);\nconst identifierEndSymbols = new Set([':', ',', ')']);\nconst typeEndSymbols = new Set([',', ')']);\nconst openingCommentBlock = new Set(['*/']);\n\nconst parentheses = ['(', ')'] as const;\nconst angleBrackets = ['<', '>'] as const;\nconst commentBlocks = ['/*', '*/'] as const;\n","import {\n type Decorate,\n type HasCustomLocation,\n type IsBuiltin,\n location,\n} from '../../data/attributes.ts';\nimport { isBuiltin } from '../../data/attributes.ts';\nimport { getCustomLocation, isData } from '../../data/dataTypes.ts';\nimport { struct } from '../../data/struct.ts';\nimport {\n type BaseData,\n isVoid,\n type Location,\n type WgslStruct,\n} from '../../data/wgslTypes.ts';\nimport type { IOData, IOLayout, IORecord } from './fnTypes.ts';\n\nexport type WithLocations<T extends IORecord> = {\n [Key in keyof T]: IsBuiltin<T[Key]> extends true ? T[Key]\n : HasCustomLocation<T[Key]> extends true ? T[Key]\n : Decorate<T[Key], Location>;\n};\n\nexport type IOLayoutToSchema<T extends IOLayout> = T extends BaseData\n ? Decorate<T, Location<0>>\n : T extends IORecord ? WgslStruct<WithLocations<T>>\n // biome-ignore lint/suspicious/noConfusingVoidType: <it actually is void>\n : T extends { type: 'void' } ? void\n : never;\n\nexport function withLocations<T extends IOData>(\n members: IORecord<T> | undefined,\n locations: Record<string, number> = {},\n): WithLocations<IORecord<T>> {\n let nextLocation = 0;\n const usedCustomLocations = new Set<number>();\n\n return Object.fromEntries(\n Object.entries(members ?? {}).map(([key, member]) => {\n const customLocation = getCustomLocation(member);\n\n if (customLocation !== undefined) {\n if (usedCustomLocations.has(customLocation)) {\n throw new Error('Duplicate custom location attributes found');\n }\n usedCustomLocations.add(customLocation);\n }\n\n return [key, member] as const;\n }).map(([key, member]) => {\n if (isBuiltin(member)) { // skipping builtins\n return [key, member];\n }\n\n if (getCustomLocation(member) !== undefined) { // this member is already marked\n return [key, member];\n }\n\n if (locations[key]) { // location has been determined by a previous procedure\n return [key, location(locations[key], member)];\n }\n\n while (usedCustomLocations.has(nextLocation)) {\n nextLocation++;\n }\n return [key, location(nextLocation++, member)];\n }),\n );\n}\n\nexport function createIoSchema<\n T extends IOData,\n Layout extends IORecord<T> | IOLayout<T>,\n>(layout: Layout, locations: Record<string, number> = {}) {\n return (\n isData(layout)\n ? isVoid(layout)\n ? layout\n : getCustomLocation(layout) !== undefined\n ? layout\n : location(0, layout)\n : struct(withLocations(layout, locations) as Record<string, T>)\n ) as IOLayoutToSchema<Layout>;\n}\n","import type { Implementation } from './fnTypes.ts';\n\nexport function stripTemplate(\n arg: Implementation | TemplateStringsArray,\n ...values: unknown[]\n): Implementation {\n return isTemplateStringsArray(arg)\n ? templateLiteralIdentity(arg, ...values)\n : arg;\n}\n\nfunction isTemplateStringsArray(value: unknown): value is TemplateStringsArray {\n return (\n Array.isArray(value) &&\n 'raw' in value &&\n Array.isArray(value.raw) &&\n value.raw.every((item) => typeof item === 'string')\n );\n}\n\nfunction templateLiteralIdentity(\n strings: TemplateStringsArray,\n ...values: unknown[]\n): string {\n return strings\n .slice(1)\n .reduce(\n (acc, elem, index) => `${acc}${values[index]}${elem}`,\n strings[0] as string,\n );\n}\n","import type {\n AnyVertexInputBuiltin,\n AnyVertexOutputBuiltin,\n OmitBuiltins,\n} from '../../builtin.ts';\nimport type { ResolvedSnippet } from '../../data/snippet.ts';\nimport type {\n Decorated,\n Interpolate,\n Location,\n WgslStruct,\n} from '../../data/wgslTypes.ts';\nimport {\n getName,\n isNamable,\n setName,\n type TgpuNamable,\n} from '../../shared/meta.ts';\nimport { $getNameForward, $internal, $resolve } from '../../shared/symbols.ts';\nimport type { ResolutionCtx, SelfResolvable } from '../../types.ts';\nimport { createFnCore, type FnCore } from './fnCore.ts';\nimport type {\n BaseIOData,\n Implementation,\n InferIO,\n IORecord,\n} from './fnTypes.ts';\nimport { createIoSchema, type IOLayoutToSchema } from './ioSchema.ts';\nimport { stripTemplate } from './templateUtils.ts';\n\n// ----------\n// Public API\n// ----------\n\nexport type VertexInConstrained = IORecord<\n BaseIOData | Decorated<BaseIOData, Location[]> | AnyVertexInputBuiltin\n>;\n\nexport type VertexOutConstrained = IORecord<\n | BaseIOData\n | Decorated<BaseIOData, (Location | Interpolate)[]>\n | AnyVertexOutputBuiltin\n>;\n\n/**\n * Describes a vertex entry function signature (its arguments, return type and attributes)\n */\ntype TgpuVertexFnShellHeader<\n VertexIn extends VertexInConstrained,\n VertexOut extends VertexOutConstrained,\n> = {\n readonly in: VertexIn | undefined;\n readonly out: VertexOut;\n readonly argTypes: [IOLayoutToSchema<VertexIn>] | [];\n readonly isEntry: true;\n};\n\n/**\n * Describes a vertex entry function signature (its arguments, return type and attributes).\n * Allows creating tgpu vertex functions by calling this shell\n * and passing the implementation (as WGSL string or JS function) as the argument.\n */\nexport type TgpuVertexFnShell<\n VertexIn extends VertexInConstrained,\n VertexOut extends VertexOutConstrained,\n> =\n & TgpuVertexFnShellHeader<VertexIn, VertexOut>\n & ((\n implementation: (\n input: InferIO<VertexIn>,\n out: WgslStruct<VertexOut>,\n ) => InferIO<VertexOut>,\n ) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>)\n & ((\n implementation: string,\n ) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>)\n & ((\n strings: TemplateStringsArray,\n ...values: unknown[]\n ) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>)\n & {\n /**\n * @deprecated Invoke the shell as a function instead.\n */\n does:\n & ((\n implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>,\n ) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>)\n & ((\n implementation: string,\n ) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>);\n };\n\nexport interface TgpuVertexFn<\n VertexIn extends VertexInConstrained = VertexInConstrained,\n VertexOut extends VertexOutConstrained = VertexOutConstrained,\n> extends TgpuNamable {\n readonly [$internal]: true;\n readonly shell: TgpuVertexFnShellHeader<VertexIn, VertexOut>;\n $uses(dependencyMap: Record<string, unknown>): this;\n}\n\nexport function vertexFn<VertexOut extends VertexOutConstrained>(options: {\n out: VertexOut;\n // biome-ignore lint/complexity/noBannedTypes: it's fine\n}): TgpuVertexFnShell<{}, VertexOut>;\n\nexport function vertexFn<\n VertexIn extends VertexInConstrained,\n // Not allowing single-value output, as it is better practice\n // to properly label what the vertex shader is outputting.\n VertexOut extends VertexOutConstrained,\n>(options: {\n in: VertexIn;\n out: VertexOut;\n}): TgpuVertexFnShell<VertexIn, VertexOut>;\n\n/**\n * Creates a shell of a typed entry function for the vertex shader stage. Any function\n * that implements this shell can run for each vertex, allowing the inner code to process\n * attributes and determine the final position of the vertex.\n *\n * @param options.in\n * Vertex attributes and builtins to be made available to functions that implement this shell.\n * @param options.out\n * A record containing the final position of the vertex, and any information\n * passed onto the fragment shader stage.\n */\nexport function vertexFn<\n VertexIn extends VertexInConstrained,\n // Not allowing single-value output, as it is better practice\n // to properly label what the vertex shader is outputting.\n VertexOut extends VertexOutConstrained,\n>(options: {\n in?: VertexIn;\n out: VertexOut;\n}): TgpuVertexFnShell<VertexIn, VertexOut> {\n if (Object.keys(options.out).length === 0) {\n throw new Error(\n `A vertexFn output cannot be empty since it must include the 'position' builtin.`,\n );\n }\n const shell: TgpuVertexFnShellHeader<VertexIn, VertexOut> = {\n in: options.in,\n out: options.out,\n argTypes: options.in && Object.keys(options.in).length !== 0\n ? [createIoSchema(options.in)]\n : [],\n isEntry: true,\n };\n\n const call = (\n arg: Implementation | TemplateStringsArray,\n ...values: unknown[]\n ) => createVertexFn(shell, stripTemplate(arg, ...values));\n\n return Object.assign(Object.assign(call, shell), {\n does: call,\n }) as TgpuVertexFnShell<VertexIn, VertexOut>;\n}\n\n// --------------\n// Implementation\n// --------------\n\nfunction createVertexFn(\n shell: TgpuVertexFnShellHeader<VertexInConstrained, VertexOutConstrained>,\n implementation: Implementation,\n): TgpuVertexFn<VertexInConstrained, VertexOutConstrained> {\n type This =\n & TgpuVertexFn<VertexInConstrained, VertexOutConstrained>\n & SelfResolvable\n & {\n [$internal]: true;\n [$getNameForward]: FnCore;\n };\n\n const core = createFnCore(implementation, '@vertex ');\n const inputType = shell.argTypes[0];\n\n const result: This = {\n shell,\n\n $uses(newExternals) {\n core.applyExternals(newExternals);\n return this;\n },\n\n [$internal]: true,\n [$getNameForward]: core,\n $name(newLabel: string): This {\n setName(core, newLabel);\n if (isNamable(inputType)) {\n inputType.$name(`${newLabel}_Input`);\n }\n return this;\n },\n\n [$resolve](ctx: ResolutionCtx): ResolvedSnippet {\n const outputWithLocation = createIoSchema(\n shell.out,\n ctx.varyingLocations,\n ).$name(`${getName(this) ?? ''}_Output`);\n\n if (typeof implementation === 'string') {\n if (inputType) {\n core.applyExternals({ In: inputType });\n }\n core.applyExternals({ Out: outputWithLocation });\n }\n\n return core.resolve(\n ctx,\n shell.argTypes,\n outputWithLocation,\n );\n },\n\n toString() {\n return `vertexFn:${getName(core) ?? '<unnamed>'}`;\n },\n };\n return result;\n}\n"],"mappings":"yMAAA,OAAS,qBAAAA,OAAyB,UCiB3B,SAASC,EACdC,EACAC,EACA,CACA,OAAW,CAACC,EAAKC,CAAK,IAAK,OAAO,QAAQF,CAAY,EACpDD,EAASE,CAAG,EAAIC,EAIdA,IAAU,OAAOA,GAAU,UAAY,OAAOA,GAAU,aACxDC,EAAQD,CAAK,IAAM,QAEnBE,EAAQF,EAAOD,CAAG,CAGxB,CAEO,SAASI,GACdC,EACAC,EACAT,EACA,CACA,IAAMU,EAAe,CACnB,GAAGF,EAAe,SAAS,yBAAyB,CACtD,EAAE,IAAKG,GAAWA,EAAQA,EAAM,CAAC,EAAI,MAAU,EAE/CX,EACE,OAAO,YACLS,EAAS,QAAQ,CAACG,EAAS,IAAM,CAC/B,IAAMC,EAAcH,EAAeA,EAAa,CAAC,EAAI,OACrD,OAAOI,EAAaF,CAAO,GAAKC,IAAgB,OAC5C,CAAC,CAACA,EAAaD,CAAO,CAAC,EACvB,CAAC,CACP,CAAC,CACH,CACF,CACF,CAEO,SAASG,GACdP,EACAQ,EACAhB,EACA,CACA,I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CACF,CAEF","names":["FuncParameterType","applyExternals","existing","newExternals","key","value","getName","setName","addArgTypesToExternals","implementation","argTypes","argTypeNames","found","argType","argTypeName","isWgslStruct","addReturnTypeToExternals","returnType","matched","outputName","identifierRegex","name","replaceExternalsInWgsl","ctx","externalMap","wgsl","acc","externalName","external","externalRegex","isWgsl","isLooseData","hasTinyestMetadata","foundProperties","innerAcc","prop","extractArgs","rawCode","strippedCode","range","strip","code","ParsableString","args","attributes","closingParenthesis","parentheses","identifierEndSymbols","identifier","maybeType","typeEndSymbols","angleBrackets","maybeRet","argsStart","blankSpaces","lineBreaks","openingCommentBlock","commentBlocks","str","#pos","#parseStartPos","substr","i","elem","toFind","brackets","openedBrackets","steps","createFnCore","implementation","fnAttribute","externalsToApply","core","newExternals","ctx","argTypes","returnType","externalMap","externals","applyExternals","id","replacedImpl","replaceExternalsInWgsl","header","body","input","isWgslStruct","attributes","isWgslData","getAttributesString","output","Void","providedArgs","extractArgs","argInfo","i","checkAndReturnType","snip","pluginData","getMetaData","missing","name","ast","missingExternals","MissingLinksError","getName","maybeSecondArg","undecorate","args","argAliases","argType","astParam","FuncParameterType","rawName","snippet","alias","head","actualReturnType","maybeName","setName","wgslType","jsType","resolvedJsType","resolvedWgslType","withLocations","members","locations","nextLocation","usedCustomLocations","key","member","customLocation","getCustomLocation","isBuiltin","location","createIoSchema","layout","isData","isVoid","struct","stripTemplate","arg","values","isTemplateStringsArray","templateLiteralIdentity","value","item","strings","acc","elem","index","vertexFn","options","shell","createIoSchema","call","arg","values","createVertexFn","stripTemplate","implementation","core","createFnCore","inputType","newExternals","$internal","$getNameForward","newLabel","setName","isNamable","$resolve","ctx","outputWithLocation","getName"]}
var m="0.8.2";var o=Symbol(`typegpu:${m}:$internal`),kn=Symbol(`typegpu:${m}:$gpuValueOf`),me=Symbol(`typegpu:${m}:$getNameForward`),He=Symbol(`typegpu:${m}:$providing`),qe=Symbol(`typegpu:${m}:$ownSnippet`),oe=Symbol(`typegpu:${m}:$resolve`),Je=Symbol(`typegpu:${m}:$repr`),Fn=Symbol(`typegpu:${m}:$gpuRepr`),Pn=Symbol(`typegpu:${m}:$reprPartial`),Bn=Symbol(`typegpu:${m}:$memIdent`),En=Symbol(`typegpu:${m}:$invalidStorageSchema`),Un=Symbol(`typegpu:${m}:$validUniformSchema`),Nn=Symbol(`typegpu:${m}:$validVertexSchema`),Rn=Symbol(`typegpu:${m}:$invalidSchemaReason`);function u(e){return!!e?.[o]}var Mn={[o]:!0,type:"void",toString(){return"void"}},Wt=["bool","f32","f16","i32","u32","u16","vec2f","vec2h","vec2i","vec2u","vec2<bool>","vec3f","vec3h","vec3i","vec3u","vec3<bool>","vec4f","vec4h","vec4i","vec4u","vec4<bool>","mat2x2f","mat3x3f","mat4x4f","struct","array","ptr","atomic","decorated","abstractInt","abstractFloat","void","texture_1d","texture_storage_1d","texture_2d","texture_storage_2d","texture_multisampled_2d","texture_depth_2d","texture_depth_multisampled_2d","texture_2d_array","texture_storage_2d_array","texture_depth_2d_array","texture_cube","texture_depth_cube","texture_cube_array","texture_depth_cube_array","texture_3d","texture_storage_3d","texture_external","sampler","sampler_comparison"];function Ee(e){let t=e;return u(t)&&typeof t.kind=="string"&&t.kind.startsWith("vec")}function Ct(e){let t=e;return u(t)&&typeof t.type=="string"&&t.type.startsWith("vec2")}function Ot(e){let t=e;return u(t)&&typeof t.type=="string"&&t.type.startsWith("vec3")}function Mt(e){let t=e;return u(t)&&typeof t.type=="string"&&t.type.startsWith("vec4")}function ae(e){return Ct(e)||Ot(e)||Mt(e)}function Xe(e){let t=e;return u(t)&&typeof t.kind?.startsWith=="function"&&t.kind.startsWith("mat")}function Lt(e){return u(e)&&e?.type==="mat2x2f"}function jt(e){return u(e)&&e?.type==="mat3x3f"}function Gt(e){return u(e)&&e?.type==="mat4x4f"}function Ue(e){return Lt(e)||jt(e)||Gt(e)}function Ln(e){return Ee(e)&&["vec2f","vec3f","vec4f"].includes(e.kind)}function C(e){return u(e)&&Wt.includes(e?.type)}function fe(e){return u(e)&&e?.type==="array"}function we(e){return u(e)&&e?.type==="struct"}function jn(e){return u(e)&&e?.type==="ptr"}function Gn(e){return u(e)&&e?.type==="atomic"}function Te(e){return u(e)&&e?.type==="@align"}function ge(e){return u(e)&&e?.type==="@size"}function Ze(e){return u(e)&&e?.type==="@location"}function Kn(e){return u(e)&&e?.type==="@interpolate"}function Ne(e){return u(e)&&e?.type==="@builtin"}function _(e){return u(e)&&e?.type==="decorated"}function Yn(e){return u(e)&&e.type==="void"}function Qe(e){let t=e?.type;return u(e)&&(t==="abstractInt"||t==="abstractFloat"||t==="f32"||t==="f16"||t==="i32"||t==="u32")}function Hn(e){let t=e?.type;return u(e)&&(t==="f16"||t==="vec2h"||t==="vec3h"||t==="vec4h")}var A=process.env.NODE_ENV==="development",ve=process.env.NODE_ENV==="test";Object.assign(globalThis,{__TYPEGPU_AUTONAME__:(e,t)=>(Yt(e)&&u(e)&&!D(e)&&e.$name(t),e)});var ue=globalThis,Zn=(A||ve)&&{get enabled(){return!!ue.__TYPEGPU_MEASURE_PERF__},record(e,t){let n=ue.__TYPEGPU_PERF_RECORDS__??=new Map,r=n.get(e);r||(r=[],n.set(e,r)),r.push(t)}}||void 0;function et(e){return!!e?.[me]}function D(e){return et(e)?D(e[me]):nt(e)?.name}function k(e,t){et(e)&&k(e[me],t),Ht(e,{name:t})}function Yt(e){return!!e?.$name}function tt(e){return!!nt(e)?.ast}function nt(e){return ue.__TYPEGPU_META__.get(e)}function Ht(e,t){ue.__TYPEGPU_META__??=new WeakMap;let n=ue.__TYPEGPU_META__;n.set(e,{...n.get(e),...t})}var rt=["uint8","uint8x2","uint8x4","sint8","sint8x2","sint8x4","unorm8","unorm8x2","unorm8x4","snorm8","snorm8x2","snorm8x4","uint16","uint16x2","uint16x4","sint16","sint16x2","sint16x4","unorm16","unorm16x2","unorm16x4","snorm16","snorm16x2","snorm16x4","float16","float16x2","float16x4","float32","float32x2","float32x3","float32x4","uint32","uint32x2","uint32x3","uint32x4","sint32","sint32x2","sint32x3","sint32x4","unorm10-10-10-2","unorm8x4-bgra"],er={f32:"float32",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",f16:"float16",vec2h:"float16x2",vec4h:"float16x4",u32:"uint32",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",i32:"sint32",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4"};function S(e){return e.type==="decorated"||e.type==="loose-decorated"?e.inner:e}var qt=["unstruct","disarray","loose-decorated",...rt];function Re(e){return u(e)&&qt.includes(e?.type)}function ce(e){return u(e)&&e?.type==="disarray"}function ye(e){return u(e)&&e?.type==="unstruct"}function I(e){return u(e)&&e?.type==="loose-decorated"}function O(e){return e.attribs?.find(Te)?.params[0]}function at(e){return e.attribs?.find(ge)?.params[0]}function or(e){return e.attribs?.find(Ze)?.params[0]}function ar(e){return C(e)||Re(e)}var ut={type:"unknown",toString(){return"unknown"}},it=class{constructor(t,n,r){this.name=t;this.lhs=n;this.operator=r}},st=class{constructor(t){this.matrix=t}},ot=class{constructor(t){this.op=t;k(this,"consoleLog")}[o]=!0};var We="Invariant failed";function Ve(e,t){if(e)return;if(!A)throw new Error(We);let n=typeof t=="function"?t():t,r=n?`${We}: ${n}`:We;throw new Error(r)}var ct=class e extends Error{constructor(n,r){let i=r.map(s=>`- ${tt(s)?`fn*:${D(s)}`:s}`);i.length>20&&(i=[...i.slice(0,11),"...",...i.slice(-10)]);super(`Resolution of the following tree failed:
${i.join(`
`)}: ${n&&typeof n=="object"&&"message"in n?n.message:n}`);this.cause=n;this.trace=r;Object.setPrototypeOf(this,e.prototype)}appendToTrace(n){let r=[n,...this.trace];return new e(this.cause,r)}},yt=class e extends Error{constructor(n,r){let i=r.map(s=>`- ${s}`);i.length>20&&(i=[...i.slice(0,11),"...",...i.slice(-10)]);super(`Execution of the following tree failed:
${i.join(`
`)}: ${n&&typeof n=="object"&&"message"in n?n.message:n}`);this.cause=n;this.trace=r;Object.setPrototypeOf(this,e.prototype)}appendToTrace(n){let r=[n,...this.trace];return new e(this.cause,r)}},lt=class e extends Error{constructor(n){super(`Missing value for '${n}'`);this.slot=n;Object.setPrototypeOf(this,e.prototype)}},pt=class e extends Error{constructor(t){super(`Buffer '${D(t)??"<unnamed>"}' is not bindable as a uniform. Use .$usage('uniform') to allow it.`),Object.setPrototypeOf(this,e.prototype)}},ht=class e extends Error{constructor(t,n){super(`The function '${t??"<unnamed>"}' is missing links to the following external values: ${n}.`),Object.setPrototypeOf(this,e.prototype)}},xt=class e extends Error{constructor(t){super(`Missing bind groups for layouts: '${[...t].map(n=>D(n)??"<unnamed>").join(", ")}'. Please provide it using pipeline.with(bindGroup).(...)`),Object.setPrototypeOf(this,e.prototype)}},dt=class e extends Error{constructor(t){super(`Missing vertex buffers for layouts: '${[...t].map(n=>D(n)??"<unnamed>").join(", ")}'. Please provide it using pipeline.with(layout, buffer).(...)`),Object.setPrototypeOf(this,e.prototype)}},mt=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},ft=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},be=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function wt(e){return e?.resourceType==="slot"}function Tt(e){return e?.resourceType==="derived"}function gt(e){return e?.[He]!==void 0}function dr(e){return e?.resourceType==="accessor"}var ze=class{constructor(t,n){this.value=t;this.dataType=n}};function Ce(e){return e instanceof ze}function gr(e){return Qe(e.dataType)}function x(e,t){if(A&&Ce(e))throw new Error("Cannot nest snippets");return new ze(e,S(t))}var Se=class{type="normal"},vt=class{type="codegen"},bt=class{constructor(t,n){this.buffers=t;this.vars=n}type="simulate"};function Jt(e){return!!e?.[oe]}function Vt(e){return e?.[qe]}function _r(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||Jt(e)||C(e)||wt(e)||Tt(e)||gt(e)}function Ar(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}var Ie=!1;function Fr(e){if(Ie)return e();try{return Ie=!0,e()}finally{Ie=!1}}function Pr(){return Ie}var F;function Br(e,t){if(Ve(F===void 0||F===e,"Cannot nest context providers"),F===e)return t();F=e;try{return t()}finally{F=void 0}}function zt(){return F}var Xt=new Se;function Er(){return F?.mode??Xt}function Oe(){return F?.mode.type==="codegen"}function d(e,...t){let n=zt();function r(s){return Ce(s)?n.resolve(s.value,s.dataType).value:s}let i="";for(let s=0;s<e.length;++s){i+=e[s];let p=t[s];Array.isArray(p)?i+=p.filter(y=>y!==void 0).map(r).join(", "):p&&(i+=r(p))}return i}function St(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}var Me={rank:Number.POSITIVE_INFINITY,action:"none"};function _e(e,t){let n=S(e),r=S(t);if(n.type===r.type)return{rank:0,action:"none"};if(n.type==="abstractFloat"){if(r.type==="f32")return{rank:1,action:"none"};if(r.type==="f16")return{rank:2,action:"none"}}if(n.type==="abstractInt"){if(r.type==="i32")return{rank:3,action:"none"};if(r.type==="u32")return{rank:4,action:"none"};if(r.type==="abstractFloat")return{rank:5,action:"none"};if(r.type==="f32")return{rank:6,action:"none"};if(r.type==="f16")return{rank:7,action:"none"}}return ae(n)&&ae(r)?_e(n.primitive,r.primitive):Ue(n)&&Ue(r)?{rank:0,action:"none"}:Me}function Zt(e,t){let n=S(e),r=S(t);if(n.type==="ptr"&&_e(n.inner,r).rank<Number.POSITIVE_INFINITY)return{rank:0,action:"deref"};if(r.type==="ptr"&&_e(n,r.inner).rank<Number.POSITIVE_INFINITY)return{rank:1,action:"ref"};let i={f32:0,f16:1,i32:2,u32:3,bool:4};if(n.type in i&&r.type in i){let s=n.type,p=r.type;if(s!==p){let y=i[s];return{rank:i[p]<y?10:20,action:"cast",targetType:r}}}if(n.type==="abstractFloat"){if(r.type==="u32")return{rank:2,action:"cast",targetType:r};if(r.type==="i32")return{rank:1,action:"cast",targetType:r}}return Me}function Qt(e,t,n){let r=_e(e,t);return r.rank<Number.POSITIVE_INFINITY?r:n?Zt(e,t):Me}function It(e,t,n){let r;for(let s of t){let p=[],y=0;for(let l of e){let g=Qt(l,s,n);if(y+=g.rank,g.rank===Number.POSITIVE_INFINITY)break;p.push(g)}y<(r?.sum??Number.POSITIVE_INFINITY)&&(r={type:s,details:p,sum:y})}if(!r)return;let i=r.details.map((s,p)=>({sourceIndex:p,action:s.action,...s.action==="cast"&&{targetType:s.targetType}}));return{targetType:r.type,actions:i,hasImplicitConversions:i.some(s=>s.action==="cast")}}function _t(e,t){if(e.length===0)return;let n=[...new Set((t||e).map(S))],r=It(e,n,!1);if(r)return r;let i=It(e,n,!0);if(i)return i}function en(e,t,n){if(t.action==="none")return x(e.value,n);switch(t.action){case"ref":return x(d`&${e}`,n);case"deref":return x(d`*${e}`,n);case"cast":return n(e);default:St(t.action,"applyActionToSnippet")}}function Hr(e,t){if(e.some(r=>r.type==="unknown"))return;let n=_t(e,t);if(n)return e.map(()=>n.targetType)}function At(e,t,n=!0){let r=e.map(s=>s.dataType);if(r.some(s=>s.type==="unknown"))return;A&&Array.isArray(t)&&t.length===0&&console.warn("convertToCommonType was called with an empty restrictTo array, which prevents any conversions from being made. If you intend to allow all conversions, pass undefined instead. If this was intended call the function conditionally since the result will always be undefined.");let i=_t(r,t);if(i)return(ve||A)&&n&&i.hasImplicitConversions&&console.warn(`Implicit conversions from [
${e.map(s=>` ${s.value}: ${s.dataType.type}`).join(`,
`)}
] to ${i.targetType.type} are supported, but not recommended.
Consider using explicit conversions instead.`),e.map((s,p)=>{let y=i.actions[p];return Ve(y,"Action should not be undefined"),en(s,y,i.targetType)})}function Dt(e,t,n=!0){if(t===e.dataType)return x(e.value,t);if(e.dataType.type==="unknown")return x(d`${x(e.value,t)}`,t);let r=At([e],[t],n);if(!r)throw new be(`Cannot convert value of type '${e.dataType.type}' to type '${t.type}'`);return r[0]}function qr(e,t){return Object.keys(e.propTypes).map(r=>{let i=t[r];if(!i)throw new Error(`Missing property ${r}`);let s=e.propTypes[r];return At([i],[s])?.[0]??i})}function tn(e){return typeof e!="string"&&Vt(e)===void 0}function $t(e,t,n,r="keep"){let i=((...s)=>Oe()?t(...s):e(...s));return k(i,n),i.toString=()=>n,Object.defineProperty(i,o,{value:{jsImpl:e,gpuImpl:t,argConversionHint:r}}),i}var Ae=class extends Error{constructor(t){super(t),this.name=this.constructor.name}};function P(e){let t=(...r)=>{let{argTypes:i,returnType:s}=typeof e.signature=="function"?e.signature(...r.map(l=>l.dataType)):e.signature,y=r.map((l,g)=>Dt(l,i[g],!e.ignoreImplicitCastWarning));if(y.every(l=>tn(l.value))&&typeof e.normalImpl=="function")try{return x(e.normalImpl(...y.map(l=>l.value)),s)}catch(l){if(!(l instanceof Ae))throw l}return x(e.codegenImpl(...y),s)},n=((...r)=>{if(Oe())return t(...r);if(typeof e.normalImpl=="string")throw new Ae(e.normalImpl);return e.normalImpl(...r)});return k(n,e.name),n.toString=()=>e.name,Object.defineProperty(n,o,{value:{jsImpl:e.normalImpl,gpuImpl:t,argConversionHint:"keep"}}),n}var ai={[o]:!0,type:"abstractInt",toString(){return"abstractInt"}},ui={[o]:!0,type:"abstractFloat",toString(){return"abstractFloat"}},nn=P({name:"bool",signature:e=>({argTypes:e?[e]:[],returnType:b}),normalImpl(e){return e===void 0?!1:typeof e=="boolean"?e:!!e},codegenImpl:e=>e.dataType.type==="bool"?d`${e}`:d`bool(${e})`}),b=Object.assign(nn,{type:"bool"}),rn=P({name:"u32",signature:e=>({argTypes:e?[e]:[],returnType:c}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:(e&4294967295)>>>0},codegenImpl:e=>e.dataType.type==="u32"?d`${e}`:d`u32(${e})`}),c=Object.assign(rn,{type:"u32"}),sn=P({name:"i32",signature:e=>({argTypes:e?[e]:[],returnType:T}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:e|0},codegenImpl:e=>e.dataType.type==="i32"?d`${e}`:d`i32(${e})`}),ci={[o]:!0,type:"u16"},T=Object.assign(sn,{type:"i32"}),on=P({name:"f32",signature:e=>({argTypes:e?[e]:[],returnType:h}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:Math.fround(e)},codegenImpl:e=>e.dataType.type==="f32"?d`${e}`:d`f32(${e})`}),h=Object.assign(on,{type:"f32"}),kt=new ArrayBuffer(4),an=new Float32Array(kt),un=new Uint32Array(kt);function cn(e){an[0]=e;let t=un[0],n=t>>>31&1,r=t>>>23&255,i=t&8388607;return r===255?n<<15|31744|(i?512:0):(r=r-127+15,r<=0?r<-10?n<<15:(i=(i|8388608)>>1-r,i=i+4096>>13,n<<15|i):r>=31||(i=i+4096,i&8388608&&(i=0,++r,r>=31))?n<<15|31744:n<<15|r<<10|i>>13)}function yn(e){let t=e&32768?-1:1,n=e>>10&31,r=e&1023;return n===0?r?t*r*2**-24:t*0:n===31?r?Number.NaN:t===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t*(1+r/1024)*2**(n-15)}function ln(e){return yn(cn(e))}var pn=P({name:"f16",signature:e=>({argTypes:e?[e]:[],returnType:$}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:ln(e)},codegenImpl:e=>e.dataType.type==="f16"?d`${e}`:d`f16(${e})`}),$=Object.assign(pn,{type:"f16"});var le=class extends Array{castElement(){return this[o].elementSchema[o].jsImpl}[oe](){let t=this[o].elementSchema;return this.every(n=>!n)?x(`${this.kind}()`,t):this.every(n=>this[0]===n)?x(`${this.kind}(${this[0]})`,t):x(`${this.kind}(${this.join(", ")})`,t)}toString(){return this[oe]().value}get xx(){return new this._Vec2(this[0],this[0])}get xy(){return new this._Vec2(this[0],this[1])}get xz(){return new this._Vec2(this[0],this[2])}get xw(){return new this._Vec2(this[0],this[3])}get yx(){return new this._Vec2(this[1],this[0])}get yy(){return new this._Vec2(this[1],this[1])}get yz(){return new this._Vec2(this[1],this[2])}get yw(){return new this._Vec2(this[1],this[3])}get zx(){return new this._Vec2(this[2],this[0])}get zy(){return new this._Vec2(this[2],this[1])}get zz(){return new this._Vec2(this[2],this[2])}get zw(){return new this._Vec2(this[2],this[3])}get wx(){return new this._Vec2(this[3],this[0])}get wy(){return new this._Vec2(this[3],this[1])}get wz(){return new this._Vec2(this[3],this[2])}get ww(){return new this._Vec2(this[3],this[3])}get xxx(){return new this._Vec3(this[0],this[0],this[0])}get xxy(){return new this._Vec3(this[0],this[0],this[1])}get xxz(){return new this._Vec3(this[0],this[0],this[2])}get xxw(){return new this._Vec3(this[0],this[0],this[3])}get xyx(){return new this._Vec3(this[0],this[1],this[0])}get xyy(){return new this._Vec3(this[0],this[1],this[1])}get xyz(){return new this._Vec3(this[0],this[1],this[2])}get xyw(){return new this._Vec3(this[0],this[1],this[3])}get xzx(){return new this._Vec3(this[0],this[2],this[0])}get xzy(){return new this._Vec3(this[0],this[2],this[1])}get xzz(){return new this._Vec3(this[0],this[2],this[2])}get xzw(){return new this._Vec3(this[0],this[2],this[3])}get xwx(){return new this._Vec3(this[0],this[3],this[0])}get xwy(){return new this._Vec3(this[0],this[3],this[1])}get xwz(){return new this._Vec3(this[0],this[3],this[2])}get xww(){return new this._Vec3(this[0],this[3],this[3])}get yxx(){return new this._Vec3(this[1],this[0],this[0])}get yxy(){return new this._Vec3(this[1],this[0],this[1])}get yxz(){return new this._Vec3(this[1],this[0],this[2])}get yxw(){return new this._Vec3(this[1],this[0],this[3])}get yyx(){return new this._Vec3(this[1],this[1],this[0])}get yyy(){return new this._Vec3(this[1],this[1],this[1])}get yyz(){return new this._Vec3(this[1],this[1],this[2])}get yyw(){return new this._Vec3(this[1],this[1],this[3])}get yzx(){return new this._Vec3(this[1],this[2],this[0])}get yzy(){return new this._Vec3(this[1],this[2],this[1])}get yzz(){return new this._Vec3(this[1],this[2],this[2])}get yzw(){return new this._Vec3(this[1],this[2],this[3])}get ywx(){return new this._Vec3(this[1],this[3],this[0])}get ywy(){return new this._Vec3(this[1],this[3],this[1])}get ywz(){return new this._Vec3(this[1],this[3],this[2])}get yww(){return new this._Vec3(this[1],this[3],this[3])}get zxx(){return new this._Vec3(this[2],this[0],this[0])}get zxy(){return new this._Vec3(this[2],this[0],this[1])}get zxz(){return new this._Vec3(this[2],this[0],this[2])}get zxw(){return new this._Vec3(this[2],this[0],this[3])}get zyx(){return new this._Vec3(this[2],this[1],this[0])}get zyy(){return new this._Vec3(this[2],this[1],this[1])}get zyz(){return new this._Vec3(this[2],this[1],this[2])}get zyw(){return new this._Vec3(this[2],this[1],this[3])}get zzx(){return new this._Vec3(this[2],this[2],this[0])}get zzy(){return new this._Vec3(this[2],this[2],this[1])}get zzz(){return new this._Vec3(this[2],this[2],this[2])}get zzw(){return new this._Vec3(this[2],this[2],this[3])}get zwx(){return new this._Vec3(this[2],this[3],this[0])}get zwy(){return new this._Vec3(this[2],this[3],this[1])}get zwz(){return new this._Vec3(this[2],this[3],this[2])}get zww(){return new this._Vec3(this[2],this[3],this[3])}get wxx(){return new this._Vec3(this[3],this[0],this[0])}get wxy(){return new this._Vec3(this[3],this[0],this[1])}get wxz(){return new this._Vec3(this[3],this[0],this[2])}get wxw(){return new this._Vec3(this[3],this[0],this[3])}get wyx(){return new this._Vec3(this[3],this[1],this[0])}get wyy(){return new this._Vec3(this[3],this[1],this[1])}get wyz(){return new this._Vec3(this[3],this[1],this[2])}get wyw(){return new this._Vec3(this[3],this[1],this[3])}get wzx(){return new this._Vec3(this[3],this[2],this[0])}get wzy(){return new this._Vec3(this[3],this[2],this[1])}get wzz(){return new this._Vec3(this[3],this[2],this[2])}get wzw(){return new this._Vec3(this[3],this[2],this[3])}get wwx(){return new this._Vec3(this[3],this[3],this[0])}get wwy(){return new this._Vec3(this[3],this[3],this[1])}get wwz(){return new this._Vec3(this[3],this[3],this[2])}get www(){return new this._Vec3(this[3],this[3],this[3])}get xxxx(){return new this._Vec4(this[0],this[0],this[0],this[0])}get xxxy(){return new this._Vec4(this[0],this[0],this[0],this[1])}get xxxz(){return new this._Vec4(this[0],this[0],this[0],this[2])}get xxxw(){return new this._Vec4(this[0],this[0],this[0],this[3])}get xxyx(){return new this._Vec4(this[0],this[0],this[1],this[0])}get xxyy(){return new this._Vec4(this[0],this[0],this[1],this[1])}get xxyz(){return new this._Vec4(this[0],this[0],this[1],this[2])}get xxyw(){return new this._Vec4(this[0],this[0],this[1],this[3])}get xxzx(){return new this._Vec4(this[0],this[0],this[2],this[0])}get xxzy(){return new this._Vec4(this[0],this[0],this[2],this[1])}get xxzz(){return new this._Vec4(this[0],this[0],this[2],this[2])}get xxzw(){return new this._Vec4(this[0],this[0],this[2],this[3])}get xxwx(){return new this._Vec4(this[0],this[0],this[3],this[0])}get xxwy(){return new this._Vec4(this[0],this[0],this[3],this[1])}get xxwz(){return new this._Vec4(this[0],this[0],this[3],this[2])}get xxww(){return new this._Vec4(this[0],this[0],this[3],this[3])}get xyxx(){return new this._Vec4(this[0],this[1],this[0],this[0])}get xyxy(){return new this._Vec4(this[0],this[1],this[0],this[1])}get xyxz(){return new this._Vec4(this[0],this[1],this[0],this[2])}get xyxw(){return new this._Vec4(this[0],this[1],this[0],this[3])}get xyyx(){return new this._Vec4(this[0],this[1],this[1],this[0])}get xyyy(){return new this._Vec4(this[0],this[1],this[1],this[1])}get xyyz(){return new this._Vec4(this[0],this[1],this[1],this[2])}get xyyw(){return new this._Vec4(this[0],this[1],this[1],this[3])}get xyzx(){return new this._Vec4(this[0],this[1],this[2],this[0])}get xyzy(){return new this._Vec4(this[0],this[1],this[2],this[1])}get xyzz(){return new this._Vec4(this[0],this[1],this[2],this[2])}get xyzw(){return new this._Vec4(this[0],this[1],this[2],this[3])}get xywx(){return new this._Vec4(this[0],this[1],this[3],this[0])}get xywy(){return new this._Vec4(this[0],this[1],this[3],this[1])}get xywz(){return new this._Vec4(this[0],this[1],this[3],this[2])}get xyww(){return new this._Vec4(this[0],this[1],this[3],this[3])}get xzxx(){return new this._Vec4(this[0],this[2],this[0],this[0])}get xzxy(){return new this._Vec4(this[0],this[2],this[0],this[1])}get xzxz(){return new this._Vec4(this[0],this[2],this[0],this[2])}get xzxw(){return new this._Vec4(this[0],this[2],this[0],this[3])}get xzyx(){return new this._Vec4(this[0],this[2],this[1],this[0])}get xzyy(){return new this._Vec4(this[0],this[2],this[1],this[1])}get xzyz(){return new this._Vec4(this[0],this[2],this[1],this[2])}get xzyw(){return new this._Vec4(this[0],this[2],this[1],this[3])}get xzzx(){return new this._Vec4(this[0],this[2],this[2],this[0])}get xzzy(){return new this._Vec4(this[0],this[2],this[2],this[1])}get xzzz(){return new this._Vec4(this[0],this[2],this[2],this[2])}get xzzw(){return new this._Vec4(this[0],this[2],this[2],this[3])}get xzwx(){return new this._Vec4(this[0],this[2],this[3],this[0])}get xzwy(){return new this._Vec4(this[0],this[2],this[3],this[1])}get xzwz(){return new this._Vec4(this[0],this[2],this[3],this[2])}get xzww(){return new this._Vec4(this[0],this[2],this[3],this[3])}get xwxx(){return new this._Vec4(this[0],this[3],this[0],this[0])}get xwxy(){return new this._Vec4(this[0],this[3],this[0],this[1])}get xwxz(){return new this._Vec4(this[0],this[3],this[0],this[2])}get xwxw(){return new this._Vec4(this[0],this[3],this[0],this[3])}get xwyx(){return new this._Vec4(this[0],this[3],this[1],this[0])}get xwyy(){return new this._Vec4(this[0],this[3],this[1],this[1])}get xwyz(){return new this._Vec4(this[0],this[3],this[1],this[2])}get xwyw(){return new this._Vec4(this[0],this[3],this[1],this[3])}get xwzx(){return new this._Vec4(this[0],this[3],this[2],this[0])}get xwzy(){return new this._Vec4(this[0],this[3],this[2],this[1])}get xwzz(){return new this._Vec4(this[0],this[3],this[2],this[2])}get xwzw(){return new this._Vec4(this[0],this[3],this[2],this[3])}get xwwx(){return new this._Vec4(this[0],this[3],this[3],this[0])}get xwwy(){return new this._Vec4(this[0],this[3],this[3],this[1])}get xwwz(){return new this._Vec4(this[0],this[3],this[3],this[2])}get xwww(){return new this._Vec4(this[0],this[3],this[3],this[3])}get yxxx(){return new this._Vec4(this[1],this[0],this[0],this[0])}get yxxy(){return new this._Vec4(this[1],this[0],this[0],this[1])}get yxxz(){return new this._Vec4(this[1],this[0],this[0],this[2])}get yxxw(){return new this._Vec4(this[1],this[0],this[0],this[3])}get yxyx(){return new this._Vec4(this[1],this[0],this[1],this[0])}get yxyy(){return new this._Vec4(this[1],this[0],this[1],this[1])}get yxyz(){return new this._Vec4(this[1],this[0],this[1],this[2])}get yxyw(){return new this._Vec4(this[1],this[0],this[1],this[3])}get yxzx(){return new this._Vec4(this[1],this[0],this[2],this[0])}get yxzy(){return new this._Vec4(this[1],this[0],this[2],this[1])}get yxzz(){return new this._Vec4(this[1],this[0],this[2],this[2])}get yxzw(){return new this._Vec4(this[1],this[0],this[2],this[3])}get yxwx(){return new this._Vec4(this[1],this[0],this[3],this[0])}get yxwy(){return new this._Vec4(this[1],this[0],this[3],this[1])}get yxwz(){return new this._Vec4(this[1],this[0],this[3],this[2])}get yxww(){return new this._Vec4(this[1],this[0],this[3],this[3])}get yyxx(){return new this._Vec4(this[1],this[1],this[0],this[0])}get yyxy(){return new this._Vec4(this[1],this[1],this[0],this[1])}get yyxz(){return new this._Vec4(this[1],this[1],this[0],this[2])}get yyxw(){return new this._Vec4(this[1],this[1],this[0],this[3])}get yyyx(){return new this._Vec4(this[1],this[1],this[1],this[0])}get yyyy(){return new this._Vec4(this[1],this[1],this[1],this[1])}get yyyz(){return new this._Vec4(this[1],this[1],this[1],this[2])}get yyyw(){return new this._Vec4(this[1],this[1],this[1],this[3])}get yyzx(){return new this._Vec4(this[1],this[1],this[2],this[0])}get yyzy(){return new this._Vec4(this[1],this[1],this[2],this[1])}get yyzz(){return new this._Vec4(this[1],this[1],this[2],this[2])}get yyzw(){return new this._Vec4(this[1],this[1],this[2],this[3])}get yywx(){return new this._Vec4(this[1],this[1],this[3],this[0])}get yywy(){return new this._Vec4(this[1],this[1],this[3],this[1])}get yywz(){return new this._Vec4(this[1],this[1],this[3],this[2])}get yyww(){return new this._Vec4(this[1],this[1],this[3],this[3])}get yzxx(){return new this._Vec4(this[1],this[2],this[0],this[0])}get yzxy(){return new this._Vec4(this[1],this[2],this[0],this[1])}get yzxz(){return new this._Vec4(this[1],this[2],this[0],this[2])}get yzxw(){return new this._Vec4(this[1],this[2],this[0],this[3])}get yzyx(){return new this._Vec4(this[1],this[2],this[1],this[0])}get yzyy(){return new this._Vec4(this[1],this[2],this[1],this[1])}get yzyz(){return new this._Vec4(this[1],this[2],this[1],this[2])}get yzyw(){return new this._Vec4(this[1],this[2],this[1],this[3])}get yzzx(){return new this._Vec4(this[1],this[2],this[2],this[0])}get yzzy(){return new this._Vec4(this[1],this[2],this[2],this[1])}get yzzz(){return new this._Vec4(this[1],this[2],this[2],this[2])}get yzzw(){return new this._Vec4(this[1],this[2],this[2],this[3])}get yzwx(){return new this._Vec4(this[1],this[2],this[3],this[0])}get yzwy(){return new this._Vec4(this[1],this[2],this[3],this[1])}get yzwz(){return new this._Vec4(this[1],this[2],this[3],this[2])}get yzww(){return new this._Vec4(this[1],this[2],this[3],this[3])}get ywxx(){return new this._Vec4(this[1],this[3],this[0],this[0])}get ywxy(){return new this._Vec4(this[1],this[3],this[0],this[1])}get ywxz(){return new this._Vec4(this[1],this[3],this[0],this[2])}get ywxw(){return new this._Vec4(this[1],this[3],this[0],this[3])}get ywyx(){return new this._Vec4(this[1],this[3],this[1],this[0])}get ywyy(){return new this._Vec4(this[1],this[3],this[1],this[1])}get ywyz(){return new this._Vec4(this[1],this[3],this[1],this[2])}get ywyw(){return new this._Vec4(this[1],this[3],this[1],this[3])}get ywzx(){return new this._Vec4(this[1],this[3],this[2],this[0])}get ywzy(){return new this._Vec4(this[1],this[3],this[2],this[1])}get ywzz(){return new this._Vec4(this[1],this[3],this[2],this[2])}get ywzw(){return new this._Vec4(this[1],this[3],this[2],this[3])}get ywwx(){return new this._Vec4(this[1],this[3],this[3],this[0])}get ywwy(){return new this._Vec4(this[1],this[3],this[3],this[1])}get ywwz(){return new this._Vec4(this[1],this[3],this[3],this[2])}get ywww(){return new this._Vec4(this[1],this[3],this[3],this[3])}get zxxx(){return new this._Vec4(this[2],this[0],this[0],this[0])}get zxxy(){return new this._Vec4(this[2],this[0],this[0],this[1])}get zxxz(){return new this._Vec4(this[2],this[0],this[0],this[2])}get zxxw(){return new this._Vec4(this[2],this[0],this[0],this[3])}get zxyx(){return new this._Vec4(this[2],this[0],this[1],this[0])}get zxyy(){return new this._Vec4(this[2],this[0],this[1],this[1])}get zxyz(){return new this._Vec4(this[2],this[0],this[1],this[2])}get zxyw(){return new this._Vec4(this[2],this[0],this[1],this[3])}get zxzx(){return new this._Vec4(this[2],this[0],this[2],this[0])}get zxzy(){return new this._Vec4(this[2],this[0],this[2],this[1])}get zxzz(){return new this._Vec4(this[2],this[0],this[2],this[2])}get zxzw(){return new this._Vec4(this[2],this[0],this[2],this[3])}get zxwx(){return new this._Vec4(this[2],this[0],this[3],this[0])}get zxwy(){return new this._Vec4(this[2],this[0],this[3],this[1])}get zxwz(){return new this._Vec4(this[2],this[0],this[3],this[2])}get zxww(){return new this._Vec4(this[2],this[0],this[3],this[3])}get zyxx(){return new this._Vec4(this[2],this[1],this[0],this[0])}get zyxy(){return new this._Vec4(this[2],this[1],this[0],this[1])}get zyxz(){return new this._Vec4(this[2],this[1],this[0],this[2])}get zyxw(){return new this._Vec4(this[2],this[1],this[0],this[3])}get zyyx(){return new this._Vec4(this[2],this[1],this[1],this[0])}get zyyy(){return new this._Vec4(this[2],this[1],this[1],this[1])}get zyyz(){return new this._Vec4(this[2],this[1],this[1],this[2])}get zyyw(){return new this._Vec4(this[2],this[1],this[1],this[3])}get zyzx(){return new this._Vec4(this[2],this[1],this[2],this[0])}get zyzy(){return new this._Vec4(this[2],this[1],this[2],this[1])}get zyzz(){return new this._Vec4(this[2],this[1],this[2],this[2])}get zyzw(){return new this._Vec4(this[2],this[1],this[2],this[3])}get zywx(){return new this._Vec4(this[2],this[1],this[3],this[0])}get zywy(){return new this._Vec4(this[2],this[1],this[3],this[1])}get zywz(){return new this._Vec4(this[2],this[1],this[3],this[2])}get zyww(){return new this._Vec4(this[2],this[1],this[3],this[3])}get zzxx(){return new this._Vec4(this[2],this[2],this[0],this[0])}get zzxy(){return new this._Vec4(this[2],this[2],this[0],this[1])}get zzxz(){return new this._Vec4(this[2],this[2],this[0],this[2])}get zzxw(){return new this._Vec4(this[2],this[2],this[0],this[3])}get zzyx(){return new this._Vec4(this[2],this[2],this[1],this[0])}get zzyy(){return new this._Vec4(this[2],this[2],this[1],this[1])}get zzyz(){return new this._Vec4(this[2],this[2],this[1],this[2])}get zzyw(){return new this._Vec4(this[2],this[2],this[1],this[3])}get zzzx(){return new this._Vec4(this[2],this[2],this[2],this[0])}get zzzy(){return new this._Vec4(this[2],this[2],this[2],this[1])}get zzzz(){return new this._Vec4(this[2],this[2],this[2],this[2])}get zzzw(){return new this._Vec4(this[2],this[2],this[2],this[3])}get zzwx(){return new this._Vec4(this[2],this[2],this[3],this[0])}get zzwy(){return new this._Vec4(this[2],this[2],this[3],this[1])}get zzwz(){return new this._Vec4(this[2],this[2],this[3],this[2])}get zzww(){return new this._Vec4(this[2],this[2],this[3],this[3])}get zwxx(){return new this._Vec4(this[2],this[3],this[0],this[0])}get zwxy(){return new this._Vec4(this[2],this[3],this[0],this[1])}get zwxz(){return new this._Vec4(this[2],this[3],this[0],this[2])}get zwxw(){return new this._Vec4(this[2],this[3],this[0],this[3])}get zwyx(){return new this._Vec4(this[2],this[3],this[1],this[0])}get zwyy(){return new this._Vec4(this[2],this[3],this[1],this[1])}get zwyz(){return new this._Vec4(this[2],this[3],this[1],this[2])}get zwyw(){return new this._Vec4(this[2],this[3],this[1],this[3])}get zwzx(){return new this._Vec4(this[2],this[3],this[2],this[0])}get zwzy(){return new this._Vec4(this[2],this[3],this[2],this[1])}get zwzz(){return new this._Vec4(this[2],this[3],this[2],this[2])}get zwzw(){return new this._Vec4(this[2],this[3],this[2],this[3])}get zwwx(){return new this._Vec4(this[2],this[3],this[3],this[0])}get zwwy(){return new this._Vec4(this[2],this[3],this[3],this[1])}get zwwz(){return new this._Vec4(this[2],this[3],this[3],this[2])}get zwww(){return new this._Vec4(this[2],this[3],this[3],this[3])}get wxxx(){return new this._Vec4(this[3],this[0],this[0],this[0])}get wxxy(){return new this._Vec4(this[3],this[0],this[0],this[1])}get wxxz(){return new this._Vec4(this[3],this[0],this[0],this[2])}get wxxw(){return new this._Vec4(this[3],this[0],this[0],this[3])}get wxyx(){return new this._Vec4(this[3],this[0],this[1],this[0])}get wxyy(){return new this._Vec4(this[3],this[0],this[1],this[1])}get wxyz(){return new this._Vec4(this[3],this[0],this[1],this[2])}get wxyw(){return new this._Vec4(this[3],this[0],this[1],this[3])}get wxzx(){return new this._Vec4(this[3],this[0],this[2],this[0])}get wxzy(){return new this._Vec4(this[3],this[0],this[2],this[1])}get wxzz(){return new this._Vec4(this[3],this[0],this[2],this[2])}get wxzw(){return new this._Vec4(this[3],this[0],this[2],this[3])}get wxwx(){return new this._Vec4(this[3],this[0],this[3],this[0])}get wxwy(){return new this._Vec4(this[3],this[0],this[3],this[1])}get wxwz(){return new this._Vec4(this[3],this[0],this[3],this[2])}get wxww(){return new this._Vec4(this[3],this[0],this[3],this[3])}get wyxx(){return new this._Vec4(this[3],this[1],this[0],this[0])}get wyxy(){return new this._Vec4(this[3],this[1],this[0],this[1])}get wyxz(){return new this._Vec4(this[3],this[1],this[0],this[2])}get wyxw(){return new this._Vec4(this[3],this[1],this[0],this[3])}get wyyx(){return new this._Vec4(this[3],this[1],this[1],this[0])}get wyyy(){return new this._Vec4(this[3],this[1],this[1],this[1])}get wyyz(){return new this._Vec4(this[3],this[1],this[1],this[2])}get wyyw(){return new this._Vec4(this[3],this[1],this[1],this[3])}get wyzx(){return new this._Vec4(this[3],this[1],this[2],this[0])}get wyzy(){return new this._Vec4(this[3],this[1],this[2],this[1])}get wyzz(){return new this._Vec4(this[3],this[1],this[2],this[2])}get wyzw(){return new this._Vec4(this[3],this[1],this[2],this[3])}get wywx(){return new this._Vec4(this[3],this[1],this[3],this[0])}get wywy(){return new this._Vec4(this[3],this[1],this[3],this[1])}get wywz(){return new this._Vec4(this[3],this[1],this[3],this[2])}get wyww(){return new this._Vec4(this[3],this[1],this[3],this[3])}get wzxx(){return new this._Vec4(this[3],this[2],this[0],this[0])}get wzxy(){return new this._Vec4(this[3],this[2],this[0],this[1])}get wzxz(){return new this._Vec4(this[3],this[2],this[0],this[2])}get wzxw(){return new this._Vec4(this[3],this[2],this[0],this[3])}get wzyx(){return new this._Vec4(this[3],this[2],this[1],this[0])}get wzyy(){return new this._Vec4(this[3],this[2],this[1],this[1])}get wzyz(){return new this._Vec4(this[3],this[2],this[1],this[2])}get wzyw(){return new this._Vec4(this[3],this[2],this[1],this[3])}get wzzx(){return new this._Vec4(this[3],this[2],this[2],this[0])}get wzzy(){return new this._Vec4(this[3],this[2],this[2],this[1])}get wzzz(){return new this._Vec4(this[3],this[2],this[2],this[2])}get wzzw(){return new this._Vec4(this[3],this[2],this[2],this[3])}get wzwx(){return new this._Vec4(this[3],this[2],this[3],this[0])}get wzwy(){return new this._Vec4(this[3],this[2],this[3],this[1])}get wzwz(){return new this._Vec4(this[3],this[2],this[3],this[2])}get wzww(){return new this._Vec4(this[3],this[2],this[3],this[3])}get wwxx(){return new this._Vec4(this[3],this[3],this[0],this[0])}get wwxy(){return new this._Vec4(this[3],this[3],this[0],this[1])}get wwxz(){return new this._Vec4(this[3],this[3],this[0],this[2])}get wwxw(){return new this._Vec4(this[3],this[3],this[0],this[3])}get wwyx(){return new this._Vec4(this[3],this[3],this[1],this[0])}get wwyy(){return new this._Vec4(this[3],this[3],this[1],this[1])}get wwyz(){return new this._Vec4(this[3],this[3],this[1],this[2])}get wwyw(){return new this._Vec4(this[3],this[3],this[1],this[3])}get wwzx(){return new this._Vec4(this[3],this[3],this[2],this[0])}get wwzy(){return new this._Vec4(this[3],this[3],this[2],this[1])}get wwzz(){return new this._Vec4(this[3],this[3],this[2],this[2])}get wwzw(){return new this._Vec4(this[3],this[3],this[2],this[3])}get wwwx(){return new this._Vec4(this[3],this[3],this[3],this[0])}get wwwy(){return new this._Vec4(this[3],this[3],this[3],this[1])}get wwwz(){return new this._Vec4(this[3],this[3],this[3],this[2])}get wwww(){return new this._Vec4(this[3],this[3],this[3],this[3])}},U=class extends le{e0;e1;constructor(t,n){super(2),this.e0=this.castElement()(t),this.e1=this.castElement()(n??t)}get 0(){return this.e0}get 1(){return this.e1}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}set x(t){this[0]=this.castElement()(t)}set y(t){this[1]=this.castElement()(t)}},N=class extends le{e0;e1;e2;constructor(t,n,r){super(3),this.e0=this.castElement()(t),this.e1=this.castElement()(n??t),this.e2=this.castElement()(r??t)}get 0(){return this.e0}get 1(){return this.e1}get 2(){return this.e2}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}set 2(t){this.e2=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(t){this[0]=this.castElement()(t)}set y(t){this[1]=this.castElement()(t)}set z(t){this[2]=this.castElement()(t)}},R=class extends le{e0;e1;e2;e3;constructor(t,n,r,i){super(4),this.e0=this.castElement()(t),this.e1=this.castElement()(n??t),this.e2=this.castElement()(r??t),this.e3=this.castElement()(i??t)}get 0(){return this.e0}get 1(){return this.e1}get 2(){return this.e2}get 3(){return this.e3}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}set 2(t){this.e2=this.castElement()(t)}set 3(t){this.e3=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}get w(){return this[3]}set x(t){this[0]=t}set y(t){this[1]=t}set z(t){this[2]=t}set w(t){this[3]=t}},M=class e extends U{get[o](){return{elementSchema:h}}get kind(){return"vec2f"}get _Vec2(){return e}get _Vec3(){return Y}get _Vec4(){return Z}},L=class e extends U{get[o](){return{elementSchema:$}}get kind(){return"vec2h"}get _Vec2(){return e}get _Vec3(){return H}get _Vec4(){return Q}},j=class e extends U{get[o](){return{elementSchema:T}}get kind(){return"vec2i"}get _Vec2(){return e}get _Vec3(){return q}get _Vec4(){return ee}},G=class e extends U{get[o](){return{elementSchema:c}}get kind(){return"vec2u"}get _Vec2(){return e}get _Vec3(){return J}get _Vec4(){return te}},K=class e extends U{get[o](){return{elementSchema:b}}get kind(){return"vec2<bool>"}get _Vec2(){return e}get _Vec3(){return X}get _Vec4(){return ne}},Y=class e extends N{get[o](){return{elementSchema:h}}get kind(){return"vec3f"}get _Vec2(){return M}get _Vec3(){return e}get _Vec4(){return Z}},H=class e extends N{get[o](){return{elementSchema:$}}get kind(){return"vec3h"}get _Vec2(){return L}get _Vec3(){return e}get _Vec4(){return Q}},q=class e extends N{get[o](){return{elementSchema:T}}get kind(){return"vec3i"}get _Vec2(){return j}get _Vec3(){return e}get _Vec4(){return ee}},J=class e extends N{get[o](){return{elementSchema:c}}get kind(){return"vec3u"}get _Vec2(){return G}get _Vec3(){return e}get _Vec4(){return te}},X=class e extends N{get[o](){return{elementSchema:b}}get kind(){return"vec3<bool>"}get _Vec2(){return K}get _Vec3(){return e}get _Vec4(){return ne}},Z=class e extends R{get[o](){return{elementSchema:h}}get kind(){return"vec4f"}get _Vec2(){return M}get _Vec3(){return Y}get _Vec4(){return e}},Q=class e extends R{get[o](){return{elementSchema:$}}get kind(){return"vec4h"}get _Vec2(){return L}get _Vec3(){return H}get _Vec4(){return e}},ee=class e extends R{get[o](){return{elementSchema:T}}get kind(){return"vec4i"}get _Vec2(){return j}get _Vec3(){return q}get _Vec4(){return e}},te=class e extends R{get[o](){return{elementSchema:c}}get kind(){return"vec4u"}get _Vec2(){return G}get _Vec3(){return J}get _Vec4(){return e}},ne=class e extends R{get[o](){return{elementSchema:b}}get kind(){return"vec4<bool>"}get _Vec2(){return K}get _Vec3(){return X}get _Vec4(){return e}};var B=f(M,h),hn=f(L,$),pe=f(j,T),he=f(G,c),xn=f(K,b),Le=f(Y,h),dn=f(H,$),je=f(q,T),E=f(J,c),mn=f(X,b),v=f(Z,h),fn=f(Q,$),xe=f(ee,T),de=f(te,c),wn=f(ne,b),bi={vec2f:B,vec2h:hn,vec2i:pe,vec2u:he,"vec2<bool>":xn,vec3f:Le,vec3h:dn,vec3i:je,vec3u:E,"vec3<bool>":mn,vec4f:v,vec4h:fn,vec4i:xe,vec4u:de,"vec4<bool>":wn};function f(e,t){let{kind:n,length:r}=new e,s=P({name:n,signature:(...y)=>({argTypes:y.map(l=>{let g=S(l);return ae(g)?g:t}),returnType:p}),normalImpl:(...y)=>{let l=new Array(y.length),g=0;for(let se of y)if(typeof se=="number"||typeof se=="boolean")l[g++]=se;else for(let Be=0;Be<se.length;++Be)l[g++]=se[Be];if(l.length<=1||l.length===r)return new e(...l);throw new Error(`'${n}' constructor called with invalid number of arguments.`)},ignoreImplicitCastWarning:!0,codegenImpl:(...y)=>d`${n}(${y})`}),p=Object.assign(s,{type:n,primitive:t,[Je]:void 0});return p}var a=class{constructor(t){this.type=t}[o]=!0},De={uint8:c,uint8x2:he,uint8x4:de,sint8:T,sint8x2:pe,sint8x4:xe,unorm8:h,unorm8x2:B,unorm8x4:v,snorm8:h,snorm8x2:B,snorm8x4:v,uint16:c,uint16x2:he,uint16x4:de,sint16:T,sint16x2:pe,sint16x4:xe,unorm16:h,unorm16x2:B,unorm16x4:v,snorm16:h,snorm16x2:B,snorm16x4:v,float16:h,float16x2:B,float16x4:v,float32:h,float32x2:B,float32x3:Le,float32x4:v,uint32:c,uint32x2:he,uint32x3:E,uint32x4:de,sint32:T,sint32x2:pe,sint32x3:je,sint32x4:xe,"unorm10-10-10-2":v,"unorm8x4-bgra":v},Ge=new Set(Object.keys(De)),Ai=new a("uint8"),Di=new a("uint8x2"),$i=new a("uint8x4"),ki=new a("sint8"),Fi=new a("sint8x2"),Pi=new a("sint8x4"),Bi=new a("unorm8"),Ei=new a("unorm8x2"),Ui=new a("unorm8x4"),Ni=new a("snorm8"),Ri=new a("snorm8x2"),Wi=new a("snorm8x4"),Ci=new a("uint16"),Oi=new a("uint16x2"),Mi=new a("uint16x4"),Li=new a("sint16"),ji=new a("sint16x2"),Gi=new a("sint16x4"),Ki=new a("unorm16"),Yi=new a("unorm16x2"),Hi=new a("unorm16x4"),qi=new a("snorm16"),Ji=new a("snorm16x2"),Xi=new a("snorm16x4"),Zi=new a("float16"),Qi=new a("float16x2"),es=new a("float16x4"),ts=new a("float32"),ns=new a("float32x2"),rs=new a("float32x3"),is=new a("float32x4"),ss=new a("uint32"),os=new a("uint32x2"),as=new a("uint32x3"),us=new a("uint32x4"),cs=new a("sint32"),ys=new a("sint32x2"),ls=new a("sint32x3"),ps=new a("sint32x4"),hs=new a("unorm10-10-10-2"),xs=new a("unorm8x4-bgra");function ds(e){return u(e)&&Ge.has(e?.type)}function Pt(e){let t=String(e);if(t!=="[object Object]")return t;try{return JSON.stringify(e)}catch(n){return console.error("Error parsing JSON:",n),"<invalid json>"}}function Ft(e){return Ee(e)||Xe(e)?e.toString():Array.isArray(e)?`[${e.map(Ft).join(", ")}]`:e&&typeof e=="object"?`{ ${Object.entries(e).map(([t,n])=>`${t}: ${Ft(n)}`).join(", ")} }`:String(e)}var Tn={f32:4,f16:2,i32:4,u32:4,bool:4,u16:2,vec2f:8,vec2h:4,vec2i:8,vec2u:8,vec2b:8,vec3f:16,vec3h:8,vec3i:16,vec3u:16,vec3b:16,vec4f:16,vec4h:8,vec4i:16,vec4u:16,vec4b:16,mat2x2f:8,mat3x3f:16,mat4x4f:16,atomic:4};function gn(e){let t=e?.type,n=Tn[t];if(n!==void 0)return n;if(we(e))return Object.values(e.propTypes).map(V).reduce((r,i)=>r>i?r:i);if(fe(e))return V(e.elementType);if(ye(e)){let r=Object.values(e.propTypes)[0];return r?O(r)??1:1}if(ce(e))return O(e.elementType)??1;if(_(e)||I(e))return O(e)??V(e.inner);if(Ge.has(t))return 1;throw new Error(`Cannot determine alignment of data: ${Pt(e)}`)}function vn(e){if(ye(e)){let t=Object.values(e.propTypes)[0];return t?re(t):1}return ce(e)?re(e.elementType):I(e)?O(e)??re(e.inner):O(e)??1}var Bt=new WeakMap,Et=new WeakMap;function V(e){let t=Bt.get(e);return t===void 0&&(t=gn(e),Bt.set(e,t)),t}function re(e){let t=Et.get(e);return t===void 0&&(t=vn(e),Et.set(e,t)),t}function Vs(e){return V(e)}var ie=(e,t)=>{let n=t-1,r=~n;return(e&n)===0?e:(e&r)+t};var bn={bool:4,f32:4,f16:2,i32:4,u32:4,u16:2,vec2f:8,vec2h:4,vec2i:8,vec2u:8,"vec2<bool>":8,vec3f:12,vec3h:6,vec3i:12,vec3u:12,"vec3<bool>":12,vec4f:16,vec4h:8,vec4i:16,vec4u:16,"vec4<bool>":16,mat2x2f:16,mat3x3f:48,mat4x4f:64,uint8:1,uint8x2:2,uint8x4:4,sint8:1,sint8x2:2,sint8x4:4,unorm8:1,unorm8x2:2,unorm8x4:4,snorm8:1,snorm8x2:2,snorm8x4:4,uint16:2,uint16x2:4,uint16x4:8,sint16:2,sint16x2:4,sint16x4:8,unorm16:2,unorm16x2:4,unorm16x4:8,snorm16:2,snorm16x2:4,snorm16x4:8,float16:2,float16x2:4,float16x4:8,float32:4,float32x2:8,float32x3:12,float32x4:16,uint32:4,uint32x2:8,uint32x3:12,uint32x4:16,sint32:4,sint32x2:8,sint32x3:12,sint32x4:16,"unorm10-10-10-2":4,"unorm8x4-bgra":4,atomic:4};function Vn(e){let t=0,n=e.propTypes;for(let r of Object.values(n)){if(Number.isNaN(t))throw new Error("Only the last property of a struct can be unbounded");if(t=ie(t,V(r)),t+=z(r),Number.isNaN(t)&&r.type!=="array")throw new Error("Cannot nest unbounded struct within another struct")}return ie(t,V(e))}function zn(e){let t=0,n=e.propTypes;for(let r of Object.values(n)){let i=re(r);t=ie(t,i),t+=z(r)}return t}function Sn(e){let t=bn[e?.type];if(t!==void 0)return t;if(we(e))return Vn(e);if(ye(e))return zn(e);if(fe(e)){if(e.elementCount===0)return Number.NaN;let n=V(e.elementType);return ie(z(e.elementType),n)*e.elementCount}if(ce(e)){let n=re(e.elementType);return ie(z(e.elementType),n)*e.elementCount}if(_(e)||I(e))return at(e)??z(e.inner);throw new Error(`Cannot determine size of data: ${e}`)}var Ut=new WeakMap;function z(e){let t=Ut.get(e);return t===void 0&&(t=Sn(e),Ut.set(e,t)),t}function $s(e){return z(e)}function W(e,t){return _(e)?new ke(e.inner,[t,...e.attribs]):I(e)?new Fe(e.inner,[t,...e.attribs]):Re(e)?new Fe(e,[t]):new ke(e,[t])}function Ns(e,t){return W(t,{[o]:!0,type:"@align",params:[e]})}function Rs(e,t){return W(t,{[o]:!0,type:"@size",params:[e]})}function Ws(e,t){return W(t,{[o]:!0,type:"@location",params:[e]})}function Cs(e,t){return W(t,{[o]:!0,type:"@interpolate",params:[e]})}function Os(e){if(!In(e))throw new Error("The @invariant attribute must only be applied to the position built-in value.");let t=_(e)||I(e)?e.attribs.find(Ne):void 0;if(!t||t.params[0]!=="position")throw new Error("The @invariant attribute must only be applied to the position built-in value.");return W(e,{[o]:!0,type:"@invariant",params:[]})}function In(e){return(_(e)||I(e))&&e.attribs.find(Ne)!==void 0}function Ms(e){return!_(e)&&!I(e)?"":e.attribs.map(t=>t.params.length===0?`${t.type} `:`${t.type}(${t.params.join(", ")}) `).join("")}var $e=class{constructor(t,n){this.inner=t;this.attribs=n;let r=n.find(Te)?.params[0],i=n.find(ge)?.params[0];if(r!==void 0){if(r<=0)throw new Error(`Custom data alignment must be a positive number, got: ${r}.`);if(Math.log2(r)%1!==0)throw new Error(`Alignment has to be a power of 2, got: ${r}.`);if(C(this.inner)&&r%V(this.inner)!==0)throw new Error(`Custom alignment has to be a multiple of the standard data alignment. Got: ${r}, expected multiple of: ${V(this.inner)}.`)}if(i!==void 0){if(i<z(this.inner))throw new Error(`Custom data size cannot be smaller then the standard data size. Got: ${i}, expected at least: ${z(this.inner)}.`);if(i<=0)throw new Error(`Custom data size must be a positive number. Got: ${i}.`)}}[o]=!0},ke=class extends $e{[o]=!0;type="decorated"},Fe=class extends $e{[o]=!0;type="loose-decorated"};function Pe(e,t){let n=e?.type,r=n in De?De[n]:e;return typeof r!="function"?t:t===void 0?r():r(t)}function qs(e){return Nt(e,!1)}function Js(e){return Nt(e,!0)}function Nt(e,t){let n=r=>Object.fromEntries(Object.entries(e).map(([i,s])=>[i,Pe(s,r?.[i])]));return Object.setPrototypeOf(n,_n),n.propTypes=e,Object.defineProperty(n,o,{value:{isAbstruct:t}}),n}var _n={type:"struct",$name(e){return k(this,e),this},toString(){return`struct:${D(this)??"<unnamed>"}`}};var Ye=$t(((e,t)=>t===void 0?n=>Ke(e,n):Ke(e,t)),(e,t)=>{if(t?.value===void 0){let n=r=>Ye[o].gpuImpl(e,r);return n[o]=!0,x(n,ut)}if(typeof t.value!="number")throw new Error(`Cannot create array schema with count unknown at compile-time: '${t.value}'`);return x(Ke(e.value,t.value),e.value)},"arrayOf");function Ke(e,t){let n=r=>{if(r&&r.length!==t)throw new Error(`Array schema of ${t} elements of type ${e.type} called with ${r.length} argument(s).`);return Array.from({length:t},(i,s)=>Pe(e,r?.[s]))};if(Object.setPrototypeOf(n,An),Number.isNaN(z(e)))throw new Error("Cannot nest runtime sized arrays.");if(n.elementType=e,!Number.isInteger(t)||t<0)throw new Error(`Cannot create array schema with invalid element count: ${t}.`);return n.elementCount=t,n}var An={[o]:!0,type:"array",toString(){return`arrayOf(${this.elementType}, ${this.elementCount})`}};function w(e,t){return W(e,{[o]:!0,type:"@builtin",params:[t]})}var yo={vertexIndex:w(c,"vertex_index"),instanceIndex:w(c,"instance_index"),position:w(v,"position"),clipDistances:w(Ye(c,8),"clip_distances"),frontFacing:w(b,"front_facing"),fragDepth:w(h,"frag_depth"),sampleIndex:w(c,"sample_index"),sampleMask:w(c,"sample_mask"),localInvocationId:w(E,"local_invocation_id"),localInvocationIndex:w(c,"local_invocation_index"),globalInvocationId:w(E,"global_invocation_id"),workgroupId:w(E,"workgroup_id"),numWorkgroups:w(E,"num_workgroups"),subgroupInvocationId:w(c,"subgroup_invocation_id"),subgroupSize:w(c,"subgroup_size")};export{o as a,kn as b,me as c,He as d,qe as e,oe as f,Je as g,u as h,Zn as i,D as j,k,Yt as l,tt as m,nt as n,rt as o,er as p,Mn as q,Ee as r,Ct as s,Ot as t,Mt as u,ae as v,Xe as w,Lt as x,jt as y,Ue as z,Ln as A,C as B,fe as C,we as D,jn as E,Gn as F,Te as G,ge as H,Ze as I,Kn as J,Ne as K,_ as L,Yn as M,Qe as N,Hn as O,S as P,Re as Q,ce as R,ye as S,I as T,or as U,ar as V,ut as W,it as X,st as Y,ot as Z,Ce as _,gr as $,x as aa,Ve as ba,ct as ca,yt as da,lt as ea,pt as fa,ht as ga,xt as ha,dt as ia,mt as ja,ft as ka,be as la,wt as ma,Tt as na,gt as oa,dr as pa,Se as qa,vt as ra,bt as sa,Jt as ta,Vt as ua,_r as va,Ar as wa,Fr as xa,Pr as ya,Br as za,zt as Aa,Xt as Ba,Er as Ca,Oe as Da,d as Ea,St as Fa,_t as Ga,Hr as Ha,At as Ia,Dt as Ja,qr as Ka,$t as La,Ae as Ma,P as Na,ai as Oa,ui as Pa,b as Qa,c as Ra,ci as Sa,T as Ta,h as Ua,$ as Va,le as Wa,B as Xa,hn as Ya,pe as Za,he as _a,xn as $a,Le as ab,dn as bb,je as cb,E as db,mn as eb,v as fb,fn as gb,xe as hb,de as ib,wn as jb,bi as kb,Pt as lb,Ft as mb,De as nb,Ge as ob,Ai as pb,Di as qb,$i as rb,ki as sb,Fi as tb,Pi as ub,Bi as vb,Ei as wb,Ui as xb,Ni as yb,Ri as zb,Wi as Ab,Ci as Bb,Oi as Cb,Mi as Db,Li as Eb,ji as Fb,Gi as Gb,Ki as Hb,Yi as Ib,Hi as Jb,qi as Kb,Ji as Lb,Xi as Mb,Zi as Nb,Qi as Ob,es as Pb,ts as Qb,ns as Rb,rs as Sb,is as Tb,ss as Ub,os as Vb,as as Wb,us as Xb,cs as Yb,ys as Zb,ls as _b,ps as $b,hs as ac,xs as bc,ds as cc,V as dc,re as ec,Vs as fc,ie as gc,z as hc,$s as ic,Ns as jc,Rs as kc,Ws as lc,Cs as mc,Os as nc,In as oc,Ms as pc,Pe as qc,qs as rc,Js as sc,Ye as tc,yo as uc};
//# sourceMappingURL=chunk-CRZWTZM2.js.map

Sorry, the diff of this file is too big to display

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-CRZWTZM2.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(`
`);return this.ctx.dedent(),`{
${r}
${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`\
${this.ctx.pre}if (${i}) ${p}
${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};
//# sourceMappingURL=chunk-ECR2EGZX.js.map

Sorry, the diff of this file is too big to display

import{U as q,V as W,W as u,Y as _}from"./chunk-ECR2EGZX.js";import{$ as v,$a as U,Ea as r,Ha as B,La as h,Na as c,Qa as x,Ra as o,Ta as i,Ua as n,Xa as R,Za as F,a as V,aa as y,ab as k,cb as N,eb as D,fb as a,hb as p,ib as f,jb as E,r as z,v as w}from"./chunk-CRZWTZM2.js";var ae=c({name:"bitcastU32toF32",normalImpl:(e=>typeof e=="number"?q(e):u.bitcastU32toF32[e.kind](e)),codegenImpl:e=>r`bitcast<f32>(${e})`,signature:(...e)=>{let t=B(e,[o])??e;return{argTypes:t,returnType:w(t[0])?t[0].type==="vec2u"?R:t[0].type==="vec3u"?k:a:n}}}),ne=c({name:"bitcastU32toI32",normalImpl:(e=>typeof e=="number"?W(e):u.bitcastU32toI32[e.kind](e)),codegenImpl:e=>r`bitcast<i32>(${e})`,signature:(...e)=>{let t=B(e,[o])??e;return{argTypes:t,returnType:w(t[0])?t[0].type==="vec2u"?F:t[0].type==="vec3u"?N:p:i}}});import*as m from"typed-binary";var ie=h(e=>{let t=new ArrayBuffer(4);new m.BufferWriter(t).writeUint32(e);let l=new m.BufferReader(t);return R(l.readFloat16(),l.readFloat16())},e=>y(r`unpack2x16float(${e})`,R),"unpack2x16float"),pe=h(e=>{let t=new ArrayBuffer(4),s=new m.BufferWriter(t);s.writeFloat16(e.x),s.writeFloat16(e.y);let l=new m.BufferReader(t);return o(l.readUint32())},e=>y(r`pack2x16float(${e})`,o),"pack2x16float"),fe=h(e=>{let t=new ArrayBuffer(4);new m.BufferWriter(t).writeUint32(e);let l=new m.BufferReader(t);return a(l.readUint8()/255,l.readUint8()/255,l.readUint8()/255,l.readUint8()/255)},e=>y(r`unpack4x8unorm(${e})`,a),"unpack4x8unorm"),ue=h(e=>{let t=new ArrayBuffer(4),s=new m.BufferWriter(t);s.writeUint8(e.x*255),s.writeUint8(e.y*255),s.writeUint8(e.z*255),s.writeUint8(e.w*255);let l=new m.BufferReader(t);return o(l.readUint32())},e=>y(r`pack4x8unorm(${e})`,o),"pack4x8unorm");function T(e){return e.type.includes("2")?U:e.type.includes("3")?D:E}var Ae=c({name:"allEq",signature:(...e)=>({argTypes:e,returnType:x}),normalImpl:(e,t)=>$(A(e,t)),codegenImpl:(e,t)=>r`all(${e} == ${t})`}),A=(e,t)=>u.eq[e.kind](e,t),Se=c({name:"eq",signature:(...e)=>({argTypes:e,returnType:T(e[0])}),normalImpl:A,codegenImpl:(e,t)=>r`(${e} == ${t})`}),Me=c({name:"ne",signature:(...e)=>({argTypes:e,returnType:T(e[0])}),normalImpl:(e,t)=>d(A(e,t)),codegenImpl:(e,t)=>r`(${e} != ${t})`}),M=(e,t)=>u.lt[e.kind](e,t),ze=c({name:"lt",signature:(...e)=>({argTypes:e,returnType:T(e[0])}),normalImpl:M,codegenImpl:(e,t)=>r`(${e} < ${t})`}),we=c({name:"le",signature:(...e)=>({argTypes:e,returnType:T(e[0])}),normalImpl:(e,t)=>I(M(e,t),A(e,t)),codegenImpl:(e,t)=>r`(${e} <= ${t})`}),Ie=c({name:"gt",signature:(...e)=>({argTypes:e,returnType:T(e[0])}),normalImpl:(e,t)=>O(d(M(e,t)),d(A(e,t))),codegenImpl:(e,t)=>r`(${e} > ${t})`}),$e=c({name:"ge",signature:(...e)=>({argTypes:e,returnType:T(e[0])}),normalImpl:(e,t)=>d(M(e,t)),codegenImpl:(e,t)=>r`(${e} >= ${t})`}),d=e=>u.neg[e.kind](e),Ve=c({name:"not",signature:(...e)=>({argTypes:e,returnType:e[0]}),normalImpl:d,codegenImpl:e=>r`!(${e})`}),I=(e,t)=>u.or[e.kind](e,t),Fe=c({name:"or",signature:(...e)=>({argTypes:e,returnType:e[0]}),normalImpl:I,codegenImpl:(e,t)=>r`(${e} | ${t})`}),O=(e,t)=>d(I(d(e),d(t))),Ue=c({name:"and",signature:(...e)=>({argTypes:e,returnType:e[0]}),normalImpl:O,codegenImpl:(e,t)=>r`(${e} & ${t})`}),$=e=>u.all[e.kind](e),ke=c({name:"all",signature:(...e)=>({argTypes:e,returnType:x}),normalImpl:$,codegenImpl:e=>r`all(${e})`}),Ne=c({name:"any",signature:(...e)=>({argTypes:e,returnType:x}),normalImpl:e=>!$(d(e)),codegenImpl:e=>r`any(${e})`}),De=c({name:"isCloseTo",signature:(...e)=>({argTypes:e,returnType:x}),normalImpl:(e,t,s=.01)=>typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<s:z(e)&&z(t)?u.isCloseToZero[e.kind](_[V].jsImpl(e,t),s):!1,codegenImpl:(e,t,s=y(.01,n))=>v(e)&&v(t)?r`(abs(f32(${e}) - f32(${t})) <= ${s})`:!v(e)&&!v(t)?r`all(abs(${e} - ${t}) <= (${e} - ${e}) + ${s})`:"false"});function j(e,t,s){return typeof s=="boolean"?s?t:e:u.select[e.kind](e,t,s)}var Ee=c({name:"select",signature:(e,t,s)=>{let[l,b]=B([e,t])??[e,t];return{argTypes:[l,b,s],returnType:l}},normalImpl:j,codegenImpl:(e,t,s)=>r`select(${e}, ${t}, ${s})`});var L={r8unorm:{channelType:n,vectorType:a,texelSize:1,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!0,storageBindings:["write-only","read-only","read-write"]},r8snorm:{channelType:n,vectorType:a,texelSize:1,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:["write-only","read-only"]},r8uint:{channelType:o,vectorType:f,texelSize:1,sampleTypes:["uint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},r8sint:{channelType:i,vectorType:p,texelSize:1,sampleTypes:["sint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},rg8unorm:{channelType:n,vectorType:a,texelSize:2,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!0,storageBindings:["write-only","read-only"]},rg8snorm:{channelType:n,vectorType:a,texelSize:2,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:["write-only","read-only"]},rg8uint:{channelType:o,vectorType:f,texelSize:2,sampleTypes:["uint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only"]},rg8sint:{channelType:i,vectorType:p,texelSize:2,sampleTypes:["sint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only"]},rgba8unorm:{channelType:n,vectorType:a,texelSize:4,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!0,storageBindings:["write-only","read-only","read-write"]},"rgba8unorm-srgb":{channelType:n,vectorType:a,texelSize:4,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!0,storageBindings:null},rgba8snorm:{channelType:n,vectorType:a,texelSize:4,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only"]},rgba8uint:{channelType:o,vectorType:f,texelSize:4,sampleTypes:["uint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},rgba8sint:{channelType:i,vectorType:p,texelSize:4,sampleTypes:["sint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},bgra8unorm:{channelType:n,vectorType:a,texelSize:4,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!0,storageBindings:["write-only"]},"bgra8unorm-srgb":{channelType:n,vectorType:a,texelSize:4,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!0,storageBindings:null},r16unorm:{channelType:n,vectorType:a,texelSize:2,sampleTypes:["unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only"]},r16snorm:{channelType:n,vectorType:a,texelSize:2,sampleTypes:["unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only"]},r16uint:{channelType:o,vectorType:f,texelSize:2,sampleTypes:["uint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},r16sint:{channelType:i,vectorType:p,texelSize:2,sampleTypes:["sint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},r16float:{channelType:n,vectorType:a,texelSize:2,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!0,storageBindings:["write-only","read-only","read-write"]},rg16unorm:{channelType:n,vectorType:a,texelSize:4,sampleTypes:["unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only"]},rg16snorm:{channelType:n,vectorType:a,texelSize:4,sampleTypes:["unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only"]},rg16uint:{channelType:o,vectorType:f,texelSize:4,sampleTypes:["uint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only"]},rg16sint:{channelType:i,vectorType:p,texelSize:4,sampleTypes:["sint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only"]},rg16float:{channelType:n,vectorType:a,texelSize:4,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!0,storageBindings:["write-only","read-only"]},rgba16unorm:{channelType:n,vectorType:a,texelSize:8,sampleTypes:["unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only"]},rgba16snorm:{channelType:n,vectorType:a,texelSize:8,sampleTypes:["unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only"]},rgba16uint:{channelType:o,vectorType:f,texelSize:8,sampleTypes:["uint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},rgba16sint:{channelType:i,vectorType:p,texelSize:8,sampleTypes:["sint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},rgba16float:{channelType:n,vectorType:a,texelSize:8,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!0,storageBindings:["write-only","read-only","read-write"]},r32uint:{channelType:o,vectorType:f,texelSize:4,sampleTypes:["uint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},r32sint:{channelType:i,vectorType:p,texelSize:4,sampleTypes:["sint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},r32float:{channelType:n,vectorType:a,texelSize:4,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},rg32uint:{channelType:o,vectorType:f,texelSize:8,sampleTypes:["uint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:["write-only","read-only"]},rg32sint:{channelType:i,vectorType:p,texelSize:8,sampleTypes:["sint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:["write-only","read-only"]},rg32float:{channelType:n,vectorType:a,texelSize:8,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!1,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},rgba32uint:{channelType:o,vectorType:f,texelSize:16,sampleTypes:["uint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},rgba32sint:{channelType:i,vectorType:p,texelSize:16,sampleTypes:["sint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},rgba32float:{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!1,canResolve:!1,storageBindings:["write-only","read-only","read-write"]},rgb10a2uint:{channelType:o,vectorType:f,texelSize:4,sampleTypes:["uint"],aspects:["color"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:["write-only","read-only"]},rgb10a2unorm:{channelType:n,vectorType:a,texelSize:4,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!0,storageBindings:["write-only","read-only"]},rg11b10ufloat:{channelType:n,vectorType:a,texelSize:4,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!0,canBlend:!0,canMultisample:!0,canResolve:!0,storageBindings:["write-only","read-only"]},rgb9e5ufloat:{channelType:n,vectorType:a,texelSize:4,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},stencil8:{channelType:o,vectorType:f,texelSize:1,sampleTypes:["uint"],aspects:["stencil"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:null},depth16unorm:{channelType:n,vectorType:a,texelSize:2,sampleTypes:["depth","unfilterable-float"],aspects:["depth"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:null},depth24plus:{channelType:n,vectorType:a,texelSize:4,sampleTypes:["depth","unfilterable-float"],aspects:["depth"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:null},"depth24plus-stencil8":{channelType:n,vectorType:a,texelSize:4,sampleTypes:["depth","unfilterable-float"],aspects:["depth","stencil"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:null},depth32float:{channelType:n,vectorType:a,texelSize:4,sampleTypes:["depth","unfilterable-float"],aspects:["depth"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:null},"depth32float-stencil8":{channelType:n,vectorType:a,texelSize:4,sampleTypes:["depth","unfilterable-float"],aspects:["depth","stencil"],canRenderAttachment:!0,canBlend:!1,canMultisample:!0,canResolve:!1,storageBindings:null},"bc1-rgba-unorm":{channelType:n,vectorType:a,texelSize:8,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"bc1-rgba-unorm-srgb":{channelType:n,vectorType:a,texelSize:8,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"bc2-rgba-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"bc2-rgba-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"bc3-rgba-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"bc3-rgba-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"bc4-r-unorm":{channelType:n,vectorType:a,texelSize:8,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"bc4-r-snorm":{channelType:n,vectorType:a,texelSize:8,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"bc5-rg-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"bc5-rg-snorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"bc6h-rgb-ufloat":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"bc6h-rgb-float":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"bc7-rgba-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"bc7-rgba-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"etc2-rgb8unorm":{channelType:n,vectorType:a,texelSize:8,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"etc2-rgb8unorm-srgb":{channelType:n,vectorType:a,texelSize:8,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"etc2-rgb8a1unorm":{channelType:n,vectorType:a,texelSize:8,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"etc2-rgb8a1unorm-srgb":{channelType:n,vectorType:a,texelSize:8,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"etc2-rgba8unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"etc2-rgba8unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"eac-r11unorm":{channelType:n,vectorType:a,texelSize:8,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"eac-r11snorm":{channelType:n,vectorType:a,texelSize:8,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"eac-rg11unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"eac-rg11snorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-4x4-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-4x4-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-5x4-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-5x4-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-5x5-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-5x5-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-6x5-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-6x5-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-6x6-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-6x6-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-8x5-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-8x5-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-8x6-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-8x6-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-8x8-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-8x8-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-10x5-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-10x5-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-10x6-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-10x6-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-10x8-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-10x8-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-10x10-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-10x10-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-12x10-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-12x10-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-12x12-unorm":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null},"astc-12x12-unorm-srgb":{channelType:n,vectorType:a,texelSize:16,sampleTypes:["float","unfilterable-float"],aspects:["color"],canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1,storageBindings:null}};function Oe(e,t){let s=L[e];if(!s)throw new Error(`Unknown texture format: ${e}`);let l={...s};switch(e){case"r32float":case"rg32float":case"rgba32float":t.features.has("float32-filterable")||(l={...l,sampleTypes:s.sampleTypes.filter(b=>b!=="float")}),t.features.has("float32-blendable")||(l={...l,canBlend:!1});break;case"bgra8unorm":t.features.has("bgra8unorm-storage")||(l={...l,storageBindings:null});break;case"rg11b10ufloat":t.features.has("rg11b10ufloat-renderable")||(l={...l,canRenderAttachment:!1,canBlend:!1,canMultisample:!1,canResolve:!1});break}if(l.storageBindings){let b=t.features.has("texture-formats-tier1"),G=t.features.has("texture-formats-tier2"),g=[...l.storageBindings],P=["r8unorm","r8uint","r8sint","r16uint","r16sint","r16float","rgba8unorm","rgba8uint","rgba8sint","rgba16uint","rgba16sint","rgba16float","r32uint","r32sint","r32float","rgba32uint","rgba32sint","rgba32float"],C=["r8snorm","rg8unorm","rg8snorm","rg8uint","rg8sint","rgba8snorm","r16unorm","r16snorm","rg16unorm","rg16snorm","rg16uint","rg16sint","rg16float","rgba16unorm","rgba16snorm","rgb10a2uint","rgb10a2unorm","rg11b10ufloat"];P.includes(e)&&!G&&(g=g.filter(S=>S!=="read-write")),C.includes(e)&&!b&&(g=g.filter(S=>S!=="write-only"&&S!=="read-only")),l={...l,storageBindings:g.length>0?g:null}}return l}var Pe=["f16","clip_distances","dual_source_blending","subgroups","primitive_index"],Ce={f16:"shader-f16",clip_distances:"clip-distances",dual_source_blending:"dual-source-blending",subgroups:"subgroups",primitive_index:"primitive-index"};export{L as a,Oe as b,ae as c,ne as d,ie as e,pe as f,fe as g,ue as h,Pe as i,Ce as j,Ae as k,Se as l,Me as m,ze as n,we as o,Ie as p,$e as q,Ve as r,Fe as s,Ue as t,ke as u,Ne as v,De as w,Ee as x};
//# sourceMappingURL=chunk-PWBIFP67.js.map

Sorry, the diff of this file is too big to display

import { bB as Mat2x2f, bC as Mat3x3f, bD as Mat4x4f, by as m2x2f, bz as m3x3f, bA as m4x4f, b9 as DualFn, bK as v3f } from './tgpuConstant-BTQFNlQH.js';
/**
* Returns a 2-by-2 identity matrix.
* @returns {m2x2f} The result matrix.
*/
declare const identity2: DualFn<() => m2x2f>;
/**
* Returns a 3-by-3 identity matrix.
* @returns {m3x3f} The result matrix.
*/
declare const identity3: DualFn<() => m3x3f>;
/**
* Returns a 4-by-4 identity matrix.
* @returns {m4x4f} The result matrix.
*/
declare const identity4: DualFn<() => m4x4f>;
/**
* Creates a 4-by-4 matrix which translates by the given vector v.
* @param {v3f} vector - The vector by which to translate.
* @returns {m4x4f} The translation matrix.
*/
declare const translation4: DualFn<(vector: v3f) => m4x4f>;
/**
* Creates a 4-by-4 matrix which scales in each dimension by an amount given by the corresponding entry in the given vector.
* @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.
* @returns {m4x4f} The scaling matrix.
*/
declare const scaling4: DualFn<(vector: v3f) => m4x4f>;
/**
* Creates a 4-by-4 matrix which rotates around the x-axis by the given angle.
* @param {number} angle - The angle by which to rotate (in radians).
* @returns {m4x4f} The rotation matrix.
*/
declare const rotationX4: DualFn<(a: number) => m4x4f>;
/**
* Creates a 4-by-4 matrix which rotates around the y-axis by the given angle.
* @param {number} angle - The angle by which to rotate (in radians).
* @returns {m4x4f} The rotation matrix.
*/
declare const rotationY4: DualFn<(a: number) => m4x4f>;
/**
* Creates a 4-by-4 matrix which rotates around the z-axis by the given angle.
* @param {number} angle - The angle by which to rotate (in radians).
* @returns {m4x4f} The rotation matrix.
*/
declare const rotationZ4: DualFn<(a: number) => m4x4f>;
/**
* Schema representing mat2x2f - a matrix with 2 rows and 2 columns, with elements of type f32.
* Also a constructor function for this matrix type.
*
* @example
* const zero2x2 = mat2x2f(); // filled with zeros
*
* @example
* const mat = mat2x2f(0, 1, 2, 3);
* mat.columns[0] // vec2f(0, 1)
* mat.columns[1] // vec2f(2, 3)
*
* @example
* const mat = mat2x2f(
* vec2f(0, 1), // column 0
* vec2f(1, 2), // column 1
* );
*
* @example
* const buffer = root.createBuffer(d.mat2x2f, d.mat2x2f(0, 1, 2, 3)); // buffer holding a d.mat2x2f value, with an initial value of ((0, 1), (2, 3))
*/
declare const mat2x2f: Mat2x2f;
/**
* Schema representing mat3x3f - a matrix with 3 rows and 3 columns, with elements of type f32.
* Also a constructor function for this matrix type.
*
* @example
* const zero3x3 = mat3x3f(); // filled with zeros
*
* @example
* const mat = mat3x3f(0, 1, 2, 3, 4, 5, 6, 7, 8);
* mat.columns[0] // vec3f(0, 1, 2)
* mat.columns[1] // vec3f(3, 4, 5)
* mat.columns[2] // vec3f(6, 7, 8)
*
* @example
* const mat = mat3x3f(
* vec3f(0, 1, 2), // column 0
* vec3f(2, 3, 4), // column 1
* vec3f(5, 6, 7), // column 2
* );
*
* @example
* const buffer = root.createBuffer(d.mat3x3f, d.mat3x3f()); // buffer holding a d.mat3x3f value, with an initial value of mat3x3f filled with zeros
*/
declare const mat3x3f: Mat3x3f;
/**
* Schema representing mat4x4f - a matrix with 4 rows and 4 columns, with elements of type f32.
* Also a constructor function for this matrix type.
*
* @example
* const zero4x4 = mat4x4f(); // filled with zeros
*
* @example
* const mat = mat4x4f(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
* mat.columns[0] // vec4f(0, 1, 2, 3)
* mat.columns[1] // vec4f(4, 5, 6, 7)
* mat.columns[2] // vec4f(8, 9, 10, 11)
* mat.columns[3] // vec4f(12, 13, 14, 15)
*
* @example
* const mat = mat4x4f(
* vec4f(0, 1, 2, 3), // column 0
* vec4f(4, 5, 6, 7), // column 1
* vec4f(8, 9, 10, 11), // column 2
* vec4f(12, 13, 14, 15), // column 3
* );
*
* @example
* const buffer = root.createBuffer(d.mat4x4f, d.mat4x4f()); // buffer holding a d.mat4x4f value, with an initial value of mat4x4f filled with zeros
*/
declare const mat4x4f: Mat4x4f;
declare function matToArray(mat: m2x2f | m3x3f | m4x4f): number[];
export { mat3x3f as a, mat4x4f as b, matToArray as c, identity3 as d, identity4 as e, rotationY4 as f, rotationZ4 as g, identity2 as i, mat2x2f as m, rotationX4 as r, scaling4 as s, translation4 as t };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display