PageSourceSearch

https://assets.oneroof.co.nz/rebuild/aws/20260921155645/_next/static/chunks/d5ad3d22.f902cde1c05e2ce3.js

js oneroof.co.nz collected 2026-09-24 19:33:08 UTC 193,463 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[325],{16796:function(e,t,n){var r,s,a,i,o,l,u,c,h;n.d(t,{yW:function(){return tu}});class f{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}get isPointer(){return!1}getTypeName(){return this.name}}class p{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class d extends f{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class m extends f{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}getTypeName(){return`array<${this.format.getTypeName()}, ${this.count}>`}}class g extends f{constructor(e,t,n){super(e,n),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class _ extends f{constructor(e,t,n,r){super(e,n),this.format=t,this.access=r}get isTemplate(){return!0}getTypeName(){let e=this.name;if(null!==this.format){if("vec2"===e||"vec3"===e||"vec4"===e||"mat2x2"===e||"mat2x3"===e||"mat2x4"===e||"mat3x2"===e||"mat3x3"===e||"mat3x4"===e||"mat4x2"===e||"mat4x3"===e||"mat4x4"===e){if("f32"===this.format.name)return e+"f";if("i32"===this.format.name)return e+"i";if("u32"===this.format.name)return e+"u";if("bool"===this.format.name)return e+"b";if("f16"===this.format.name)return e+"h"}e+=`<${this.format.name}>`}return e}}(o=r||(r={}))[o.Uniform=0]="Uniform",o[o.Storage=1]="Storage",o[o.Texture=2]="Texture",o[o.Sampler=3]="Sampler",o[o.StorageTexture=4]="StorageTexture";class x{constructor(e,t,n,r,s,a,i){this.name=e,this.type=t,this.group=n,this.binding=r,this.attributes=s,this.resourceType=a,this.access=i}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class y{constructor(e,t){this.name=e,this.type=t}}class b{constructor(e,t,n,r){this.name=e,this.type=t,this.locationType=n,this.location=r,this.interpolation=null}}class v{constructor(e,t,n,r){this.name=e,this.type=t,this.locationType=n,this.location=r}}class w{constructor(e,t,n,r){this.name=e,this.type=t,this.attributes=n,this.id=r}}class k{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n}}class I{constructor(e,t=null,n){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=n}}class T{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}let S=new Float32Array(1),A=new Int32Array(S.buffer),E=new Uint16Array(1),$=new Uint32Array(1),L=new Float32Array($.buffer,0,1);function D(e){return $[0]=112+(e>>6&31)<<23|(63&e)<<17,L[0]}function O(e,t,n,r){let s=[0,0,0,0];for(let a=0;a<r;++a)switch(n){case"8unorm":s[a]=e[t]/255,t++;break;case"8snorm":s[a]=e[t]/255*2-1,t++;break;case"8uint":s[a]=e[t],t++;break;case"8sint":s[a]=e[t]-127,t++;break;case"16uint":s[a]=e[t]|e[t+1]<<8,t+=2;break;case"16sint":s[a]=(e[t]|e[t+1]<<8)-32768,t+=2;break;case"16float":s[a]=function(e){var t=(32768&e)>>15,n=(31744&e)>>10,r=1023&e;return 0==n?(t?-1:1)*6103515625e-14*(r/1024):31==n?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,n-15)*(1+r/1024)}(e[t]|e[t+1]<<8),t+=2;break;case"32uint":case"32sint":s[a]=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,t+=4;break;case"32float":s[a]=new Float32Array(e.buffer,t,1)[0],t+=4}return s}
1function N(e,t,n,r,s){for(let a=0;a<r;++a)switch(n){case"8unorm":e[t]=255*s[a],t++;break;case"8snorm":e[t]=.5*(s[a]+1)*255,t++;break;case"8uint":e[t]=s[a],t++;break;case"8sint":e[t]=s[a]+127,t++;break;case"16uint":new Uint16Array(e.buffer,t,1)[0]=s[a],t+=2;break;case"16sint":new Int16Array(e.buffer,t,1)[0]=s[a],t+=2;break;case"16float":{let n=function(e){S[0]=e;let t=A[0],n=t>>31&1,r=t>>23&255,s=8388607&t;if(255===r)return E[0]=n<<15|31744|(0!==s?512:0),E[0];if(0===r){if(0===s)return E[0]=n<<15,E[0];s|=8388608;let e=113;for(;!(8388608&s);)s<<=1,e--;return s&=8388607,(r=127-e)>0?(s=(s>>126-r)+(s>>127-r&1),E[0]=n<<15|r<<10|s>>13):E[0]=n<<15,E[0]}return(r=r-127+15)>=31?E[0]=n<<15|31744:r<=0?r<-10?E[0]=n<<15:(s=(8388608|s)>>1-r,E[0]=n<<15|s>>13):(s>>=13,E[0]=n<<15|r<<10|s),E[0]}(s[a]);new Uint16Array(e.buffer,t,1)[0]=n,t+=2;break}case"32uint":new Uint32Array(e.buffer,t,1)[0]=s[a],t+=4;break;case"32sint":new Int32Array(e.buffer,t,1)[0]=s[a],t+=4;break;case"32float":new Float32Array(e.buffer,t,1)[0]=s[a],t+=4}return s}let B={r8unorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8snorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8uint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8sint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg8unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8snorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"rgba8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8snorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},bgra8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bgra8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r16uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16float:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg16uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba16uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r32uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg32uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba32uint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32sint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32float:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rg11b10ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},stencil8:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!1,hasStencil:!0,channels:1},depth16unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},depth24plus:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,depthOnlyFormat:"depth32float",channels:1},"depth24plus-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,depthOnlyFormat:"depth32float",channels:1},depth32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},"depth32float-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,stencilOnlyFormat:"depth32float",channels:1},rgb9e5ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bc1-rgba-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc1-rgba-unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc4-r-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc4-r-snorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc5-rg-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc5-rg-snorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc6h-rgb-ufloat":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc6h-rgb-float":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"eac-r11unorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-r11snorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-rg11unorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"eac-rg11snorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"astc-4x4-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-4x4-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x5-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-5x5-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x6-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-6x6-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-8x5-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x5-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x6-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x6-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x8-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-8x8-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-10x5-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x5-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x6-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x6-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x8-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x8-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x10-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-10x10-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x12-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4},"astc-12x12-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4}};class V{constructor(){this.id=V._id++,this.line=0}get isAstNode(){return!0}get astNodeType(){return""}search(e){e(this)}
1searchBlock(e,t){if(e){for(let n of(t(C.instance),e))n instanceof Array?this.searchBlock(n,t):n.search(t);t(F.instance)}}constEvaluate(e,t){throw Error("Cannot evaluate node")}constEvaluateString(e){return this.constEvaluate(e).toString()}}V._id=0;class C extends V{}C.instance=new C;class F extends V{}F.instance=new F;let M=new Set(["all","all","any","select","arrayLength","abs","acos","acosh","asin","asinh","atan","atanh","atan2","ceil","clamp","cos","cosh","countLeadingZeros","countOneBits","countTrailingZeros","cross","degrees","determinant","distance","dot","dot4U8Packed","dot4I8Packed","exp","exp2","extractBits","faceForward","firstLeadingBit","firstTrailingBit","floor","fma","fract","frexp","insertBits","inverseSqrt","ldexp","length","log","log2","max","min","mix","modf","normalize","pow","quantizeToF16","radians","reflect","refract","reverseBits","round","saturate","sign","sin","sinh","smoothStep","sqrt","step","tan","tanh","transpose","trunc","dpdx","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","textureDimensions","textureGather","textureGatherCompare","textureLoad","textureNumLayers","textureNumLevels","textureNumSamples","textureSample","textureSampleBias","textureSampleCompare","textureSampleCompareLevel","textureSampleGrad","textureSampleLevel","textureSampleBaseClampToEdge","textureStore","atomicLoad","atomicStore","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","atomicExchange","atomicCompareExchangeWeak","pack4x8snorm","pack4x8unorm","pack4xI8","pack4xU8","pack4x8Clamp","pack4xU8Clamp","pack2x16snorm","pack2x16unorm","pack2x16float","unpack4x8snorm","unpack4x8unorm","unpack4xI8","unpack4xU8","unpack2x16snorm","unpack2x16unorm","unpack2x16float","storageBarrier","textureBarrier","workgroupBarrier","workgroupUniformLoad","subgroupAdd","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","subgroupAnd","subgroupAny","subgroupBallot","subgroupBroadcast","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","subgroupShuffleUp","subgroupShuffleXor","subgroupXor","quadBroadcast","quadSwapDiagonal","quadSwapX","quadSwapY"]);class U extends V{constructor(){super()}}class P extends U{constructor(e,t,n,r,s,a){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=n,this.body=r,this.startLine=s,this.endLine=a}get astNodeType(){return"function"}search(e){if(this.attributes)for(let t of this.attributes)e(t);for(let t of(e(this),this.args))e(t);this.searchBlock(this.body,e)}}class W extends U{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}}class q extends U{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class H extends U{constructor(e,t){super(),this.body=e,this.loopId=t}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}}class z extends U{constructor(e,t,n,r){super(),this.init=e,this.condition=t,this.increment=n,this.body=r}get astNodeType(){return"for"}search(e){var t,n,r;null===(t=this.init)||void 0===t||t.search(e),null===(n=this.condition)||void 0===n||n.search(e),null===(r=this.increment)||void 0===r||r.search(e),this.searchBlock(this.body,e)}}class G extends U{constructor(e,t,n,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=r,this.value=s}get astNodeType(){return"var"}search(e){var t;e(this),null===(t=this.value)||void 0===t||t.search(e)}}class R extends U{constructor(e,t,n){super(),this.attributes=null,this.name=e,this.type=t,this.value=n}get astNodeType(){return"override"}search(e){var t;null===(t=this.value)||void 0===t||t.search(e)}}class X extends U{constructor(e,t,n,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=r,this.value=s}get astNodeType(){return"let"}search(e){var t;e(this),null===(t=this.value)||void 0===t||t.search(e)}}
1class j extends U{constructor(e,t,n,r,s){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=r,this.value=s}get astNodeType(){return"const"}constEvaluate(e,t){return this.value.constEvaluate(e,t)}search(e){var t;e(this),null===(t=this.value)||void 0===t||t.search(e)}}(l=s||(s={})).increment="++",l.decrement="--",(u=s||(s={})).parse=function(e){if("parse"==e)throw Error("Invalid value for IncrementOperator");return u[e]};class Z extends U{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}}(c=a||(a={})).assign="=",c.addAssign="+=",c.subtractAssin="-=",c.multiplyAssign="*=",c.divideAssign="/=",c.moduloAssign="%=",c.andAssign="&=",c.orAssign="|=",c.xorAssign="^=",c.shiftLeftAssign="<<=",c.shiftRightAssign=">>=",(a||(a={})).parse=function(e){if("parse"==e)throw Error("Invalid value for AssignOperator");return e};class Q extends U{constructor(e,t,n){super(),this.operator=e,this.variable=t,this.value=n}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}}class Y extends U{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return M.has(this.name)}search(e){for(let t of this.args)t.search(e);e(this)}}class K extends U{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}search(e){var t;this.searchBlock(this.body,e),null===(t=this.continuing)||void 0===t||t.search(e)}}class J extends U{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return"switch"}search(e){for(let t of(e(this),this.cases))t.search(e)}}class ee extends U{constructor(e,t,n,r){super(),this.condition=e,this.body=t,this.elseif=n,this.else=r}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}}class et extends U{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;null===(t=this.value)||void 0===t||t.search(e)}}class en extends U{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}}class er extends U{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}}class es extends U{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}}class ea extends U{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}}class ei extends U{constructor(){super()}get astNodeType(){return"discard"}}class eo extends U{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}}class el extends U{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}}class eu extends U{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if("f32"===t.name)return t;for(let n=1;n<e.length;++n){let r=eu._priority.get(t.name);eu._priority.get(e[n].name)<r&&(t=e[n])}return"x32"===t.name?eu.i32:t}getTypeName(){return this.name}}eu.x32=new eu("x32"),eu.f32=new eu("f32"),eu.i32=new eu("i32"),eu.u32=new eu("u32"),eu.f16=new eu("f16"),eu.bool=new eu("bool"),eu.void=new eu("void"),eu._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class ec extends eu{constructor(e){super(e)}}class eh extends eu{constructor(e,t,n,r){super(e),this.members=t,this.startLine=n,this.endLine=r}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name==e)return t;return -1}search(e){for(let t of this.members)e(t)}}class ef extends eu{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return"template"}getTypeName(){let e=this.name;if(null!==this.format){if("vec2"===e||"vec3"===e||"vec4"===e||"mat2x2"===e||"mat2x3"===e||"mat2x4"===e||"mat3x2"===e||"mat3x3"===e||"mat3x4"===e||"mat4x2"===e||"mat4x3"===e||"mat4x4"===e){if("f32"===this.format.name)return e+"f";if("i32"===this.format.name)return e+"i";if("u32"===this.format.name)return e+"u";if("bool"===this.format.name)return e+"b";if("f16"===this.format.name)return e+"h"}e+=`<${this.format.name}>`}return e}}ef.vec2f=new ef("vec2",eu.f32,null),ef.vec3f=new ef("vec3",eu.f32,null),ef.vec4f=new ef("vec4",eu.f32,null),ef.vec2i=new ef("vec2",eu.i32,null),ef.vec3i=new ef("vec3",eu.i32,null),ef.vec4i=new ef("vec4",eu.i32,null),ef.vec2u=new ef("vec2",eu.u32,null),ef.vec3u=new ef("vec3",eu.u32,null),ef.vec4u=new ef("vec4",eu.u32,null),ef.vec2h=new ef("vec2",eu.f16,null),ef.vec3h=new ef("vec3",eu.f16,null),ef.vec4h=new ef("vec4",eu.f16,null),ef.vec2b=new ef("vec2",eu.bool,null),ef.vec3b=new ef("vec3",eu.bool,null),ef.vec4b=new ef("vec4",eu.bool,null),ef.mat2x2f=new ef("mat2x2",eu.f32,null),ef.mat2x3f=new ef("mat2x3",eu.f32,null),ef.mat2x4f=new ef("mat2x4",eu.f32,null),ef.mat3x2f=new ef("mat3x2",eu.f32,null),ef.mat3x3f=new ef("mat3x3",eu.f32,null),ef.mat3x4f=new ef("mat3x4",eu.f32,null),ef.mat4x2f=new ef("mat4x2",eu.f32,null),ef.mat4x3f=new ef("mat4x3",eu.f32,null),ef.mat4x4f=new ef("mat4x4",eu.f32,null),ef.mat2x2h=new ef("mat2x2",eu.f16,null),ef.mat2x3h=new ef("mat2x3",eu.f16,null),ef.mat2x4h=new ef("mat2x4",eu.f16,null),ef.mat3x2h=new ef("mat3x2",eu.f16,null),ef.mat3x3h=new ef("mat3x3",eu.f16,null),ef.mat3x4h=new ef("mat3x4",eu.f16,null),ef.mat4x2h=new ef("mat4x2",eu.f16,null),ef.mat4x3h=new ef("mat4x3",eu.f16,null),ef.mat4x4h=new ef("mat4x4",eu.f16,null),ef.mat2x2i=new ef("mat2x2",eu.i32,null),ef.mat2x3i=new ef("mat2x3",eu.i32,null),ef.mat2x4i=new ef("mat2x4",eu.i32,null),ef.mat3x2i=new ef("mat3x2",eu.i32,null),ef.mat3x3i=new ef("mat3x3",eu.i32,null),ef.mat3x4i=new ef("mat3x4",eu.i32,null),ef.mat4x2i=new ef("mat4x2",eu.i32,null),ef.mat4x3i=new ef("mat4x3",eu.i32,null),ef.mat4x4i=new ef("mat4x4",eu.i32,null),ef.mat2x2u=new ef("mat2x2",eu.u32,null),ef.mat2x3u=new ef("mat2x3",eu.u32,null),ef.mat2x4u=new ef("mat2x4",eu.u32,null),ef.mat3x2u=new ef("mat3x2",eu.u32,null),ef.mat3x3u=new ef("mat3x3",eu.u32,null),ef.mat3x4u=new ef("mat3x4",eu.u32,null),ef.mat4x2u=new ef("mat4x2",eu.u32,null),ef.mat4x3u=new ef("mat4x3",eu.u32,null),ef.mat4x4u=new ef("mat4x4",eu.u32,null);class ep extends eu{constructor(e,t,n,r){super(e),this.storage=t,this.type=n,this.access=r}get astNodeType(){return"pointer"}}class ed extends eu{constructor(e,t,n,r){super(e),this.attributes=t,this.format=n,this.count=r}get astNodeType(){return"array"}get isArray(){return!0}}class em extends eu{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return"sampler"}}class eg extends V{constructor(){super(),this.postfix=null}}class e_ extends eg{constructor(e){super(),this.value=e}
1get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}}class ex extends eg{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(let t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}}class ey extends eg{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return M.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(let t of this.args)t.search(e);e(this)}}class eb extends eg{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}}class ev extends eg{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}constEvaluate(e,t){if(this.initializer){let t=e.evalExpression(this.initializer,e.context);return null!==t&&this.postfix?t.getSubData(e,this.postfix,e.context):t}return null}search(e){this.initializer.search(e)}}class ew extends eg{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return"literalExpr"}constEvaluate(e,t){return void 0!==t&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof eU}get isVector(){return this.value instanceof eP||this.value instanceof eW}get scalarValue(){return this.value instanceof eU?this.value.value:(console.error("Value is not scalar."),0)}get vectorValue(){return this.value instanceof eP||this.value instanceof eW?this.value.data:(console.error("Value is not a vector or matrix."),new Float32Array(0))}}class ek extends eg{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}}class eI extends eg{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class eT extends eg{constructor(){super()}}class eS extends eT{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}}class eA extends eT{constructor(e,t,n){super(),this.operator=e,this.left=t,this.right=n}get astNodeType(){return"binaryOp"}_getPromotedType(e,t){return e.name===t.name?e:"f32"===e.name||"f32"===t.name?eu.f32:"u32"===e.name||"u32"===t.name?eu.u32:eu.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}}class eE extends V{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class e$ extends eg{constructor(){super()}get astNodeType(){return"default"}}class eL extends eE{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}class eD extends eE{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}}class eO extends V{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"argument"}}class eN extends V{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class eB extends V{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"member"}}class eV extends V{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}}class eC{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=eC._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,n,r){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,n){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.getTypeName()}>`}}eC._id=0;class eF extends eC{constructor(){super(new f("void",null),null)}toString(){return"void"}}eF.void=new eF;class eM extends eC{constructor(e){super(new g("pointer",e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,n,r){this.reference.setDataValue(e,t,n,r)}getSubData(e,t,n){return t?this.reference.getSubData(e,t,n):this}toString(){return`&${this.reference.toString()}`}}class eU extends eC{constructor(e,t,n=null){super(t,n),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:"x32"===this.typeInfo.name?e-Math.floor(e)!=0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):"i32"===this.typeInfo.name||"bool"===this.typeInfo.name?this.data=new Int32Array([e]):"u32"===this.typeInfo.name?this.data=new Uint32Array([e]):"f32"===this.typeInfo.name||"f16"===this.typeInfo.name?this.data=new Float32Array([e]):console.error("ScalarData2: Invalid type",t)}clone(){if(this.data instanceof Float32Array)return new eU(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new eU(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new eU(new Uint32Array(this.data),this.typeInfo,null);throw"ScalarData: Invalid data type"}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,n,r){if(n)return void console.error("SetDataValue: Scalar data does not support postfix",n);if(!(t instanceof eU))return void console.error("SetDataValue: Invalid value",t);let s=t.data[0];"i32"===this.typeInfo.name||"u32"===this.typeInfo.name?s=Math.floor(s):"bool"===this.typeInfo.name&&(s=s?1:0),this.data[0]=s}getSubData(e,t,n){return t?(console.error("getSubData: Scalar data does not support postfix",t),null):this}toString(){return`${this.value}`}}class eP extends eC{constructor(e,t,n=null){if(super(t,n),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;
1else{let t=this.typeInfo.name;"vec2f"===t||"vec3f"===t||"vec4f"===t?this.data=new Float32Array(e):"vec2i"===t||"vec3i"===t||"vec4i"===t?this.data=new Int32Array(e):"vec2u"===t||"vec3u"===t||"vec4u"===t?this.data=new Uint32Array(e):"vec2h"===t||"vec3h"===t||"vec4h"===t?this.data=new Float32Array(e):"vec2b"===t||"vec3b"===t||"vec4b"===t?this.data=new Int32Array(e):"vec2"===t||"vec3"===t||"vec4"===t?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${t}`)}}clone(){if(this.data instanceof Float32Array)return new eP(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new eP(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new eP(new Uint32Array(this.data),this.typeInfo,null);throw"VectorData: Invalid data type"}setDataValue(e,t,n,r){n instanceof e_?console.error("TODO: Set vector postfix"):t instanceof eP?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,n){if(null===t)return this;let r=e.getTypeInfo("f32");if(this.typeInfo instanceof _)r=this.typeInfo.format||r;else{let t=this.typeInfo.name;"vec2f"===t||"vec3f"===t||"vec4f"===t?r=e.getTypeInfo("f32"):"vec2i"===t||"vec3i"===t||"vec4i"===t?r=e.getTypeInfo("i32"):"vec2b"===t||"vec3b"===t||"vec4b"===t?r=e.getTypeInfo("bool"):"vec2u"===t||"vec3u"===t||"vec4u"===t?r=e.getTypeInfo("u32"):"vec2h"===t||"vec3h"===t||"vec4h"===t?r=e.getTypeInfo("f16"):console.error(`GetSubData: Unknown type ${t}`)}let s=this;for(;null!==t&&null!==s;){if(t instanceof eI){let a=t.index,i=-1;if(a instanceof ew){if(!(a.value instanceof eU))return console.error(`GetSubData: Invalid array index ${a.value}`),null;i=a.value.value}else{let t=e.evalExpression(a,n);if(!(t instanceof eU))return console.error("GetSubData: Unknown index type",a),null;i=t.value}if(i<0||i>=s.data.length)return console.error("GetSubData: Index out of range",i),null;if(s.data instanceof Float32Array)return new eU(new Float32Array(s.data.buffer,s.data.byteOffset+4*i,1),r);if(s.data instanceof Int32Array)return new eU(new Int32Array(s.data.buffer,s.data.byteOffset+4*i,1),r);if(s.data instanceof Uint32Array)return new eU(new Uint32Array(s.data.buffer,s.data.byteOffset+4*i,1),r);throw"GetSubData: Invalid data type"}if(!(t instanceof e_))return console.error("GetSubData: Unknown postfix",t),null;{let n=t.value.toLowerCase();if(1===n.length){let e=0;if("x"===n||"r"===n)e=0;else if("y"===n||"g"===n)e=1;else if("z"===n||"b"===n)e=2;else{if("w"!==n&&"a"!==n)return console.error(`GetSubData: Unknown member ${n}`),null;e=3}if(this.data instanceof Float32Array)return new eU(new Float32Array(this.data.buffer,this.data.byteOffset+4*e,1),r,this);if(this.data instanceof Int32Array)return new eU(new Int32Array(this.data.buffer,this.data.byteOffset+4*e,1),r,this);if(this.data instanceof Uint32Array)return new eU(new Uint32Array(this.data.buffer,this.data.byteOffset+4*e,1),r,this)}let a=[];for(let e of n)"x"===e||"r"===e?a.push(this.data[0]):"y"===e||"g"===e?a.push(this.data[1]):"z"===e||"b"===e?a.push(this.data[2]):"w"===e||"a"===e?a.push(this.data[3]):console.error(`GetDataValue: Unknown member ${e}`);s=function(e,t,n){let r=t.length;return 2===r?"f32"===n?new eP(new Float32Array(t),e.getTypeInfo("vec2f")):"i32"===n||"bool"===n?new eP(new Int32Array(t),e.getTypeInfo("vec2i")):"u32"===n?new eP(new Uint32Array(t),e.getTypeInfo("vec2u")):"f16"===n?new eP(new Float32Array(t),e.getTypeInfo("vec2h")):(console.error(`getSubData: Unknown format ${n}`),null):3===r?"f32"===n?new eP(new Float32Array(t),e.getTypeInfo("vec3f")):"i32"===n||"bool"===n?new eP(new Int32Array(t),e.getTypeInfo("vec3i")):"u32"===n?new eP(new Uint32Array(t),e.getTypeInfo("vec3u")):"f16"===n?new eP(new Float32Array(t),e.getTypeInfo("vec3h")):(console.error(`getSubData: Unknown format ${n}`),null):4===r?"f32"===n?new eP(new Float32Array(t),e.getTypeInfo("vec4f")):"i32"===n||"bool"===n?new eP(new Int32Array(t),e.getTypeInfo("vec4i")):"u32"===n?new eP(new Uint32Array(t),e.getTypeInfo("vec4u")):"f16"===n?new eP(new Float32Array(t),e.getTypeInfo("vec4h")):(console.error(`getSubData: Unknown format ${n}`),null):(console.error(`getSubData: Invalid vector size ${t.length}`),null)}(e,a,r.name)}t=t.postfix}return s}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class eW extends eC{constructor(e,t,n=null){super(t,n),e instanceof Float32Array?this.data=e:this.data=new Float32Array(e)}
1clone(){return new eW(new Float32Array(this.data),this.typeInfo,null)}setDataValue(e,t,n,r){n instanceof e_?console.error("TODO: Set matrix postfix"):t instanceof eW?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,n){if(null===t)return this;let r=this.typeInfo.name;if(e.getTypeInfo("f32"),this.typeInfo instanceof _)this.typeInfo.format;else if(r.endsWith("f"))e.getTypeInfo("f32");else if(r.endsWith("i"))e.getTypeInfo("i32");else if(r.endsWith("u"))e.getTypeInfo("u32");else{if(!r.endsWith("h"))return console.error(`GetDataValue: Unknown type ${r}`),null;e.getTypeInfo("f16")}if(t instanceof eI){let s;let a=t.index,i=-1;if(a instanceof ew){if(!(a.value instanceof eU))return console.error(`GetDataValue: Invalid array index ${a.value}`),null;i=a.value.value}else{let t=e.evalExpression(a,n);if(!(t instanceof eU))return console.error("GetDataValue: Unknown index type",a),null;i=t.value}if(i<0||i>=this.data.length)return console.error("GetDataValue: Index out of range",i),null;let o=r.endsWith("h")?"h":"f";if("mat2x2"===r||"mat2x2f"===r||"mat2x2h"===r||"mat3x2"===r||"mat3x2f"===r||"mat3x2h"===r||"mat4x2"===r||"mat4x2f"===r||"mat4x2h"===r)s=new eP(new Float32Array(this.data.buffer,this.data.byteOffset+2*i*4,2),e.getTypeInfo(`vec2${o}`));else if("mat2x3"===r||"mat2x3f"===r||"mat2x3h"===r||"mat3x3"===r||"mat3x3f"===r||"mat3x3h"===r||"mat4x3"===r||"mat4x3f"===r||"mat4x3h"===r)s=new eP(new Float32Array(this.data.buffer,this.data.byteOffset+3*i*4,3),e.getTypeInfo(`vec3${o}`));else{if("mat2x4"!==r&&"mat2x4f"!==r&&"mat2x4h"!==r&&"mat3x4"!==r&&"mat3x4f"!==r&&"mat3x4h"!==r&&"mat4x4"!==r&&"mat4x4f"!==r&&"mat4x4h"!==r)return console.error(`GetDataValue: Unknown type ${r}`),null;s=new eP(new Float32Array(this.data.buffer,this.data.byteOffset+4*i*4,4),e.getTypeInfo(`vec4${o}`))}return t.postfix?s.getSubData(e,t.postfix,n):s}return console.error("GetDataValue: Invalid postfix",t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class eq extends eC{constructor(e,t,n=0,r=null){super(t,r),this.buffer=e instanceof ArrayBuffer?e:e.buffer,this.offset=n}clone(){return new eq(new Uint8Array(new Uint8Array(this.buffer,this.offset,this.typeInfo.size)).buffer,this.typeInfo,0,null)}setDataValue(e,t,n,r){if(null===t)return void console.log("setDataValue: NULL data.");let s=this.offset,a=this.typeInfo;for(;n;){if(n instanceof eI){if(a instanceof m){let t=n.index;if(t instanceof ew){if(!(t.value instanceof eU))return void console.error(`SetDataValue: Invalid index type ${t.value}`);s+=t.value.value*a.stride}else{let n=e.evalExpression(t,r);if(!(n instanceof eU))return void console.error("SetDataValue: Unknown index type",t);s+=n.value*a.stride}a=a.format}else console.error(`SetDataValue: Type ${a.getTypeName()} is not an array`)}else{if(!(n instanceof e_))return void console.error("SetDataValue: Unknown postfix type",n);{let e=n.value;if(a instanceof d){let t=!1;for(let n of a.members)if(n.name===e){s+=n.offset,a=n.type,t=!0;break}if(!t)return void console.error(`SetDataValue: Member ${e} not found`)}else if(a instanceof f){let n=a.getTypeName(),r=0;if("x"===e||"r"===e)r=0;else if("y"===e||"g"===e)r=1;else if("z"===e||"b"===e)r=2;else{if("w"!==e&&"a"!==e)return void console.error(`SetDataValue: Unknown member ${e}`);r=3}if(!(t instanceof eU))return void console.error("SetDataValue: Invalid value",t);let i=t.value;return"vec2f"===n?void(new Float32Array(this.buffer,s,2)[r]=i):"vec3f"===n?void(new Float32Array(this.buffer,s,3)[r]=i):"vec4f"===n?void(new Float32Array(this.buffer,s,4)[r]=i):"vec2i"===n?void(new Int32Array(this.buffer,s,2)[r]=i):"vec3i"===n?void(new Int32Array(this.buffer,s,3)[r]=i):"vec4i"===n?void(new Int32Array(this.buffer,s,4)[r]=i):"vec2u"===n?void(new Uint32Array(this.buffer,s,2)[r]=i):"vec3u"===n?void(new Uint32Array(this.buffer,s,3)[r]=i):"vec4u"===n?void(new Uint32Array(this.buffer,s,4)[r]=i):void console.error(`SetDataValue: Type ${n} is not a struct`)}}}n=n.postfix}this.setData(e,t,a,s,r)}setData(e,t,n,r,s){let a=n.getTypeName();if("f32"!==a&&"f16"!==a){if("i32"!==a&&"atomic<i32>"!==a&&"x32"!==a){if("u32"!==a&&"atomic<u32>"!==a){if("bool"!==a){if("vec2f"===a||"vec2h"===a){let e=new Float32Array(this.buffer,r,2);return void(t instanceof eP?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3f"===a||"vec3h"===a){let e=new Float32Array(this.buffer,r,3);return void(t instanceof eP?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4f"===a||"vec4h"===a){let e=new Float32Array(this.buffer,r,4);return void(t instanceof eP?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2i"===a){let e=new Int32Array(this.buffer,r,2);return void(t instanceof eP?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3i"===a){let e=new Int32Array(this.buffer,r,3);return void(t instanceof eP?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4i"===a){let e=new Int32Array(this.buffer,r,4);return void(t instanceof eP?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2u"===a){let e=new Uint32Array(this.buffer,r,2);return void(t instanceof eP?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3u"===a){let e=new Uint32Array(this.buffer,r,3);return void(t instanceof eP?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4u"===a){let e=new Uint32Array(this.buffer,r,4);return void(t instanceof eP?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2b"===a){let e=new Uint32Array(this.buffer,r,2);return void(t instanceof eP?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3b"===a){let e=new Uint32Array(this.buffer,r,3);return void(t instanceof eP?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4b"===a){let e=new Uint32Array(this.buffer,r,4);return void(t instanceof eP?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("mat2x2f"===a||"mat2x2h"===a){let e=new Float32Array(this.buffer,r,4);return void(t instanceof eW?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("mat2x3f"===a||"mat2x3h"===a){let e=new Float32Array(this.buffer,r,6);return void(t instanceof eW?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if("mat2x4f"===a||"mat2x4h"===a){let e=new Float32Array(this.buffer,r,8);return void(t instanceof eW?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7]
1))}if("mat3x2f"===a||"mat3x2h"===a){let e=new Float32Array(this.buffer,r,6);return void(t instanceof eW?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if("mat3x3f"===a||"mat3x3h"===a){let e=new Float32Array(this.buffer,r,9);return void(t instanceof eW?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8]))}if("mat3x4f"===a||"mat3x4h"===a){let e=new Float32Array(this.buffer,r,12);return void(t instanceof eW?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11]))}if("mat4x2f"===a||"mat4x2h"===a){let e=new Float32Array(this.buffer,r,8);return void(t instanceof eW?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7]))}if("mat4x3f"===a||"mat4x3h"===a){let e=new Float32Array(this.buffer,r,12);return void(t instanceof eW?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11]))}if("mat4x4f"===a||"mat4x4h"===a){let e=new Float32Array(this.buffer,r,16);return void(t instanceof eW?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11],e[12]=t.data[12],e[13]=t.data[13],e[14]=t.data[14],e[15]=t.data[15]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]))}if(t instanceof eq){if(n===t.typeInfo)return void new Uint8Array(this.buffer,r,t.buffer.byteLength).set(new Uint8Array(t.buffer));console.error("SetDataValue: Type mismatch",a,t.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${a}`)}else t instanceof eU&&(new Int32Array(this.buffer,r,1)[0]=t.value)}else t instanceof eU&&(new Uint32Array(this.buffer,r,1)[0]=t.value)}else t instanceof eU&&(new Int32Array(this.buffer,r,1)[0]=t.value)}else t instanceof eU&&(new Float32Array(this.buffer,r,1)[0]=t.value)}getSubData(e,t,n){var r,s,a;if(null===t)return this;let i=this.offset,o=this.typeInfo;for(;t;){if(t instanceof eI){let r=t.index,s=r instanceof eg?e.evalExpression(r,n):r,a=0;if(s instanceof eU?a=s.value:"number"==typeof s?a=s:console.error("GetDataValue: Invalid index type",r),o instanceof m)i+=a*o.stride,o=o.format;else{let t=o.getTypeName();"mat4x4"===t||"mat4x4f"===t||"mat4x4h"===t?(i+=16*a,o=e.getTypeInfo("vec4f")):console.error(`getDataValue: Type ${o.getTypeName()} is not an array`)}}else{if(!(t instanceof e_))return console.error("GetDataValue: Unknown postfix type",t),null;{let n=t.value;if(o instanceof d){let e=!1;for(let t of o.members)if(t.name===n){i+=t.offset,o=t.type,e=!0;break}if(!e)return console.error(`GetDataValue: Member ${n} not found`),null}else if(o instanceof f){let t=o.getTypeName();if("vec2f"===t||"vec3f"===t||"vec4f"===t||"vec2i"===t||"vec3i"===t||"vec4i"===t||"vec2u"===t||"vec3u"===t||"vec4u"===t||"vec2b"===t||"vec3b"===t||"vec4b"===t||"vec2h"===t||"vec3h"===t||"vec4h"===t||"vec2"===t||"vec3"===t||"vec4"===t){if(n.length>0&&n.length<5){let r="f",s=[];for(let a=0;a<n.length;++a){let o=n[a].toLowerCase(),l=0;if("x"===o||"r"===o)l=0;else if("y"===o||"g"===o)l=1;else if("z"===o||"b"===o)l=2;else{if("w"!==o&&"a"!==o)return console.error(`Unknown member ${n}`),null;l=3}if(1===n.length){if(t.endsWith("f"))return this.buffer.byteLength<i+4*l+4?(console.log("Insufficient buffer data"),null):new eU(new Float32Array(this.buffer,i+4*l,1),e.getTypeInfo("f32"),this);if(t.endsWith("h"))return new eU(new Float32Array(this.buffer,i+4*l,1),e.getTypeInfo("f16"),this);if(t.endsWith("i"))return new eU(new Int32Array(this.buffer,i+4*l,1),e.getTypeInfo("i32"),this);if(t.endsWith("b"))return new eU(new Int32Array(this.buffer,i+4*l,1),e.getTypeInfo("bool"),this);if(t.endsWith("u"))return new eU(new Uint32Array(this.buffer,i+4*l,1),e.getTypeInfo("i32"),this)}if("vec2f"===t)s.push(new Float32Array(this.buffer,i,2)[l]);else if("vec3f"===t){if(i+12>=this.buffer.byteLength)return console.log("Insufficient buffer data"),null;let e=new Float32Array(this.buffer,i,3);s.push(e[l])}else if("vec4f"===t)s.push(new Float32Array(this.buffer,i,4)[l]);else if("vec2i"===t)r="i",s.push(new Int32Array(this.buffer,i,2)[l]);else if("vec3i"===t)r="i",s.push(new Int32Array(this.buffer,i,3)[l]);else if("vec4i"===t)r="i",s.push(new Int32Array(this.buffer,i,4)[l]);else if("vec2u"===t){r="u";let e=new Uint32Array(this.buffer,i,2);s.push(e[l])}else"vec3u"===t?(r="u",s.push(new Uint32Array(this.buffer,i,3)[l])):"vec4u"===t&&(r="u",s.push(new Uint32Array(this.buffer,i,4)[l]))}return 2===s.length?o=e.getTypeInfo(`vec2${r}`):3===s.length?o=e.getTypeInfo(`vec3${r}`):4===s.length?o=e.getTypeInfo(`vec4${r}`):console.error(`GetDataValue: Invalid vector length ${s.length}`),new eP(s,o,null)}return console.error(`GetDataValue: Unknown member ${n}`),null}return console.error(`GetDataValue: Type ${t} is not a struct`),null}}}t=t.postfix}let l=o.getTypeName();return"f32"===l?new eU(new Float32Array(this.buffer,i,1),o,this):"i32"===l?new eU(new Int32Array(this.buffer,i,1),o,this):"u32"===l?new eU(new Uint32Array(this.buffer,i,1),o,this):"vec2f"===l?new eP(new Float32Array(this.buffer,i,2),o,this):"vec3f"===l?new eP(new Float32Array(this.buffer,i,3),o,this):"vec4f"===l?new eP(new Float32Array(this.buffer,i,4),o,this):"vec2i"===l?new eP(new Int32Array(this.buffer,i,2),o,this):"vec3i"===l?new eP(new Int32Array(this.buffer,i,3),o,this):"vec4i"===l?new eP(new Int32Array(this.buffer,i,4),o,this):"vec2u"===l?new eP(new Uint32Array(this.buffer,i,2),o,this):"vec3u"===l?new eP(new Uint32Array(this.buffer,i,3),o,this):"vec4u"===l?new eP(new Uint32Array(this.buffer,i,4),o,this):o instanceof _&&"atomic"===o.name?"u32"===(null===(r=o.format)||void 0===r?void 0:r.name)?new eU(new Uint32Array(this.buffer,i,1)[0],o.format,this):"i32"===(null===(s=o.format)||void 0===s?void 0:s.name)?new eU(new Int32Array(this.buffer,i,1)[0],o.format,this):(console.error(`GetDataValue: Invalid atomic format ${null===(a=o.format)||void 0===a?void 0:a.name}`),null):new eq(this.buffer,o,i,this)}toString(){let e="";
1if(this.typeInfo instanceof m){if("f32"===this.typeInfo.format.name){let t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if("i32"===this.typeInfo.format.name){let t=new Int32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if("u32"===this.typeInfo.format.name){let t=new Uint32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if("vec2f"===this.typeInfo.format.name){let t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}]`;for(let n=1;n<t.length/2;++n)e+=`, [${t[2*n]}, ${t[2*n+1]}]`}else if("vec3f"===this.typeInfo.format.name){let t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}]`;for(let n=4;n<t.length;n+=4)e+=`, [${t[n]}, ${t[n+1]}, ${t[n+2]}]`}else if("vec4f"===this.typeInfo.format.name){let t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}]`;for(let n=4;n<t.length;n+=4)e+=`, [${t[n]}, ${t[n+1]}, ${t[n+2]}, ${t[n+3]}]`}else e="[...]"}else this.typeInfo instanceof d?e+="{...}":e="[...]";return e}}class eH extends eC{constructor(e,t,n,r){super(t,null),this.data=e,this.descriptor=n,this.view=r}clone(){return new eH(this.data,this.typeInfo,this.descriptor,this.view)}get width(){var e,t;let n=this.descriptor.size;return n instanceof Array&&n.length>0?null!==(e=n[0])&&void 0!==e?e:0:n instanceof Object&&null!==(t=n.width)&&void 0!==t?t:0}get height(){var e,t;let n=this.descriptor.size;return n instanceof Array&&n.length>1?null!==(e=n[1])&&void 0!==e?e:0:n instanceof Object&&null!==(t=n.height)&&void 0!==t?t:0}get depthOrArrayLayers(){var e,t;let n=this.descriptor.size;return n instanceof Array&&n.length>2?null!==(e=n[2])&&void 0!==e?e:0:n instanceof Object&&null!==(t=n.depthOrArrayLayers)&&void 0!==t?t:0}get format(){var e;return this.descriptor&&null!==(e=this.descriptor.format)&&void 0!==e?e:"rgba8unorm"}get sampleCount(){var e;return this.descriptor&&null!==(e=this.descriptor.sampleCount)&&void 0!==e?e:1}get mipLevelCount(){var e;return this.descriptor&&null!==(e=this.descriptor.mipLevelCount)&&void 0!==e?e:1}get dimension(){var e;return this.descriptor&&null!==(e=this.descriptor.dimension)&&void 0!==e?e:"2d"}getMipLevelSize(e){if(e>=this.mipLevelCount)return[0,0,0];let t=[this.width,this.height,this.depthOrArrayLayers];for(let n=0;n<t.length;++n)t[n]=Math.max(1,t[n]>>e);return t}get texelByteSize(){let e=B[this.format];return e?e.isDepthStencil?4:e.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){let e=B[this.format];return!!e&&e.isDepthStencil}getGpuSize(){let e=this.format,t=B[e],n=this.width;if(!e||n<=0||!t)return -1;let r=this.height,s=this.depthOrArrayLayers,a=this.dimension;return n/t.blockWidth*("1d"===a?1:r/t.blockHeight)*t.bytesPerBlock*s}getPixel(e,t,n=0,r=0){let s=this.texelByteSize,a=this.bytesPerRow,i=this.height;return function(e,t,n,r,s,a,i,o,l){let u=r*(i>>=s)*(a>>=s)+n*i+t*o;switch(l){case"r8unorm":return[O(e,u,"8unorm",1)[0]];case"r8snorm":return[O(e,u,"8snorm",1)[0]];case"r8uint":return[O(e,u,"8uint",1)[0]];case"r8sint":return[O(e,u,"8sint",1)[0]];case"rg8unorm":{let t=O(e,u,"8unorm",2);return[t[0],t[1]]}case"rg8snorm":{let t=O(e,u,"8snorm",2);return[t[0],t[1]]}case"rg8uint":{let t=O(e,u,"8uint",2);return[t[0],t[1]]}case"rg8sint":{let t=O(e,u,"8sint",2);return[t[0],t[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{let t=O(e,u,"8unorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8snorm":{let t=O(e,u,"8snorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8uint":{let t=O(e,u,"8uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba8sint":{let t=O(e,u,"8sint",4);return[t[0],t[1],t[2],t[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{let t=O(e,u,"8unorm",4);return[t[2],t[1],t[0],t[3]]}case"r16uint":return[O(e,u,"16uint",1)[0]];case"r16sint":return[O(e,u,"16sint",1)[0]];case"r16float":return[O(e,u,"16float",1)[0]];case"rg16uint":{let t=O(e,u,"16uint",2);return[t[0],t[1]]}case"rg16sint":{let t=O(e,u,"16sint",2);return[t[0],t[1]]}case"rg16float":{let t=O(e,u,"16float",2);return[t[0],t[1]]}case"rgba16uint":{let t=O(e,u,"16uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16sint":{let t=O(e,u,"16sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16float":{let t=O(e,u,"16float",4);return[t[0],t[1],t[2],t[3]]}case"r32uint":return[O(e,u,"32uint",1)[0]];case"r32sint":return[O(e,u,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[O(e,u,"32float",1)[0]];case"rg32uint":{let t=O(e,u,"32uint",2);return[t[0],t[1]]}case"rg32sint":{let t=O(e,u,"32sint",2);return[t[0],t[1]]}case"rg32float":{let t=O(e,u,"32float",2);return[t[0],t[1]]}case"rgba32uint":{let t=O(e,u,"32uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32sint":{let t=O(e,u,"32sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32float":{let t=O(e,u,"32float",4);return[t[0],t[1],t[2],t[3]]}case"rg11b10ufloat":{var c;let t=new Uint32Array(e.buffer,u,1)[0];return[D(2047&t),D((4192256&t)>>11),(c=(4290772992&t)>>22,$[0]=112+(c>>5&31)<<23|(31&c)<<18,L[0]),1]}}return null}(new Uint8Array(this.data[r]),e,t,n,r,i,a,s,this.format)}
1setPixel(e,t,n,r,s){let a=this.texelByteSize,i=this.bytesPerRow,o=this.height;!function(e,t,n,r,s,a,i,o,l,u){let c=r*(i>>=s)*(a>>=s)+n*i+t*o;switch(l){case"r8unorm":return void N(e,c,"8unorm",1,u);case"r8snorm":return void N(e,c,"8snorm",1,u);case"r8uint":return void N(e,c,"8uint",1,u);case"r8sint":return void N(e,c,"8sint",1,u);case"rg8unorm":return void N(e,c,"8unorm",2,u);case"rg8snorm":return void N(e,c,"8snorm",2,u);case"rg8uint":return void N(e,c,"8uint",2,u);case"rg8sint":return void N(e,c,"8sint",2,u);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void N(e,c,"8unorm",4,u);case"rgba8snorm":return void N(e,c,"8snorm",4,u);case"rgba8uint":return void N(e,c,"8uint",4,u);case"rgba8sint":return void N(e,c,"8sint",4,u);case"r16uint":return void N(e,c,"16uint",1,u);case"r16sint":return void N(e,c,"16sint",1,u);case"r16float":return void N(e,c,"16float",1,u);case"rg16uint":return void N(e,c,"16uint",2,u);case"rg16sint":return void N(e,c,"16sint",2,u);case"rg16float":return void N(e,c,"16float",2,u);case"rgba16uint":return void N(e,c,"16uint",4,u);case"rgba16sint":return void N(e,c,"16sint",4,u);case"rgba16float":return void N(e,c,"16float",4,u);case"r32uint":return void N(e,c,"32uint",1,u);case"r32sint":return void N(e,c,"32sint",1,u);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void N(e,c,"32float",1,u);case"rg32uint":return void N(e,c,"32uint",2,u);case"rg32sint":return void N(e,c,"32sint",2,u);case"rg32float":return void N(e,c,"32float",2,u);case"rgba32uint":return void N(e,c,"32uint",4,u);case"rgba32sint":return void N(e,c,"32sint",4,u);case"rgba32float":return void N(e,c,"32float",4,u);case"rg11b10ufloat":console.error("TODO: rg11b10ufloat not supported for writing")}}(new Uint8Array(this.data[r]),e,t,n,r,o,i,a,this.format,s)}}(h=i||(i={}))[h.token=0]="token",h[h.keyword=1]="keyword",h[h.reserved=2]="reserved";class ez{constructor(e,t,n){this.name=e,this.type=t,this.rule=n}toString(){return this.name}}class eG{}eG.none=new ez("",i.reserved,""),eG.eof=new ez("EOF",i.token,""),eG.reserved={asm:new ez("asm",i.reserved,"asm"),bf16:new ez("bf16",i.reserved,"bf16"),do:new ez("do",i.reserved,"do"),enum:new ez("enum",i.reserved,"enum"),f16:new ez("f16",i.reserved,"f16"),f64:new ez("f64",i.reserved,"f64"),handle:new ez("handle",i.reserved,"handle"),i8:new ez("i8",i.reserved,"i8"),i16:new ez("i16",i.reserved,"i16"),i64:new ez("i64",i.reserved,"i64"),mat:new ez("mat",i.reserved,"mat"),premerge:new ez("premerge",i.reserved,"premerge"),regardless:new ez("regardless",i.reserved,"regardless"),typedef:new ez("typedef",i.reserved,"typedef"),u8:new ez("u8",i.reserved,"u8"),u16:new ez("u16",i.reserved,"u16"),u64:new ez("u64",i.reserved,"u64"),unless:new ez("unless",i.reserved,"unless"),using:new ez("using",i.reserved,"using"),vec:new ez("vec",i.reserved,"vec"),void:new ez("void",i.reserved,"void")},eG.keywords={array:new ez("array",i.keyword,"array"),atomic:new ez("atomic",i.keyword,"atomic"),bool:new ez("bool",i.keyword,"bool"),f32:new ez("f32",i.keyword,"f32"),i32:new ez("i32",i.keyword,"i32"),mat2x2:new ez("mat2x2",i.keyword,"mat2x2"),mat2x3:new ez("mat2x3",i.keyword,"mat2x3"),mat2x4:new ez("mat2x4",i.keyword,"mat2x4"),mat3x2:new ez("mat3x2",i.keyword,"mat3x2"),mat3x3:new ez("mat3x3",i.keyword,"mat3x3"),mat3x4:new ez("mat3x4",i.keyword,"mat3x4"),mat4x2:new ez("mat4x2",i.keyword,"mat4x2"),mat4x3:new ez("mat4x3",i.keyword,"mat4x3"),mat4x4:new ez("mat4x4",i.keyword,"mat4x4"),ptr:new ez("ptr",i.keyword,"ptr"),sampler:new ez("sampler",i.keyword,"sampler"),sampler_comparison:new ez("sampler_comparison",i.keyword,"sampler_comparison"),struct:new ez("struct",i.keyword,"struct"),texture_1d:new ez("texture_1d",i.keyword,"texture_1d"),texture_2d:new ez("texture_2d",i.keyword,"texture_2d"),texture_2d_array:new ez("texture_2d_array",i.keyword,"texture_2d_array"),texture_3d:new ez("texture_3d",i.keyword,"texture_3d"),texture_cube:new ez("texture_cube",i.keyword,"texture_cube"),texture_cube_array:new ez("texture_cube_array",i.keyword,"texture_cube_array"),texture_multisampled_2d:new ez("texture_multisampled_2d",i.keyword,"texture_multisampled_2d"),texture_storage_1d:new ez("texture_storage_1d",i.keyword,"texture_storage_1d"),texture_storage_2d:new ez("texture_storage_2d",i.keyword,"texture_storage_2d"),texture_storage_2d_array:new ez("texture_storage_2d_array",i.keyword,"texture_storage_2d_array"),texture_storage_3d:new ez("texture_storage_3d",i.keyword,"texture_storage_3d"),texture_depth_2d:new ez("texture_depth_2d",i.keyword,"texture_depth_2d"),texture_depth_2d_array:new ez("texture_depth_2d_array",i.keyword,"texture_depth_2d_array"),texture_depth_cube:new ez("texture_depth_cube",i.keyword,"texture_depth_cube"),texture_depth_cube_array:new ez("texture_depth_cube_array",i.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new ez("texture_depth_multisampled_2d",i.keyword,"texture_depth_multisampled_2d"),texture_external:new ez("texture_external",i.keyword,"texture_external"),u32:new ez("u32",i.
vendor: 9,736 bytes, line 1
1keyword,"u32"),vec2:new ez("vec2",i.keyword,"vec2"),vec3:new ez("vec3",i.keyword,"vec3"),vec4:new ez("vec4",i.keyword,"vec4"),bitcast:new ez("bitcast",i.keyword,"bitcast"),block:new ez("block",i.keyword,"block"),break:new ez("break",i.keyword,"break"),case:new ez("case",i.keyword,"case"),continue:new ez("continue",i.keyword,"continue"),continuing:new ez("continuing",i.keyword,"continuing"),default:new ez("default",i.keyword,"default"),diagnostic:new ez("diagnostic",i.keyword,"diagnostic"),discard:new ez("discard",i.keyword,"discard"),else:new ez("else",i.keyword,"else"),enable:new ez("enable",i.keyword,"enable"),fallthrough:new ez("fallthrough",i.keyword,"fallthrough"),false:new ez("false",i.keyword,"false"),fn:new ez("fn",i.keyword,"fn"),for:new ez("for",i.keyword,"for"),function:new ez("function",i.keyword,"function"),if:new ez("if",i.keyword,"if"),let:new ez("let",i.keyword,"let"),const:new ez("const",i.keyword,"const"),loop:new ez("loop",i.keyword,"loop"),while:new ez("while",i.keyword,"while"),private:new ez("private",i.keyword,"private"),read:new ez("read",i.keyword,"read"),read_write:new ez("read_write",i.keyword,"read_write"),return:new ez("return",i.keyword,"return"),requires:new ez("requires",i.keyword,"requires"),storage:new ez("storage",i.keyword,"storage"),switch:new ez("switch",i.keyword,"switch"),true:new ez("true",i.keyword,"true"),alias:new ez("alias",i.keyword,"alias"),type:new ez("type",i.keyword,"type"),uniform:new ez("uniform",i.keyword,"uniform"),var:new ez("var",i.keyword,"var"),override:new ez("override",i.keyword,"override"),workgroup:new ez("workgroup",i.keyword,"workgroup"),write:new ez("write",i.keyword,"write"),r8unorm:new ez("r8unorm",i.keyword,"r8unorm"),r8snorm:new ez("r8snorm",i.keyword,"r8snorm"),r8uint:new ez("r8uint",i.keyword,"r8uint"),r8sint:new ez("r8sint",i.keyword,"r8sint"),r16uint:new ez("r16uint",i.keyword,"r16uint"),r16sint:new ez("r16sint",i.keyword,"r16sint"),r16float:new ez("r16float",i.keyword,"r16float"),rg8unorm:new ez("rg8unorm",i.keyword,"rg8unorm"),rg8snorm:new ez("rg8snorm",i.keyword,"rg8snorm"),rg8uint:new ez("rg8uint",i.keyword,"rg8uint"),rg8sint:new ez("rg8sint",i.keyword,"rg8sint"),r32uint:new ez("r32uint",i.keyword,"r32uint"),r32sint:new ez("r32sint",i.keyword,"r32sint"),r32float:new ez("r32float",i.keyword,"r32float"),rg16uint:new ez("rg16uint",i.keyword,"rg16uint"),rg16sint:new ez("rg16sint",i.keyword,"rg16sint"),rg16float:new ez("rg16float",i.keyword,"rg16float"),rgba8unorm:new ez("rgba8unorm",i.keyword,"rgba8unorm"),rgba8unorm_srgb:new ez("rgba8unorm_srgb",i.keyword,"rgba8unorm_srgb"),rgba8snorm:new ez("rgba8snorm",i.keyword,"rgba8snorm"),rgba8uint:new ez("rgba8uint",i.keyword,"rgba8uint"),rgba8sint:new ez("rgba8sint",i.keyword,"rgba8sint"),bgra8unorm:new ez("bgra8unorm",i.keyword,"bgra8unorm"),bgra8unorm_srgb:new ez("bgra8unorm_srgb",i.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new ez("rgb10a2unorm",i.keyword,"rgb10a2unorm"),rg11b10float:new ez("rg11b10float",i.keyword,"rg11b10float"),rg32uint:new ez("rg32uint",i.keyword,"rg32uint"),rg32sint:new ez("rg32sint",i.keyword,"rg32sint"),rg32float:new ez("rg32float",i.keyword,"rg32float"),rgba16uint:new ez("rgba16uint",i.keyword,"rgba16uint"),rgba16sint:new ez("rgba16sint",i.keyword,"rgba16sint"),rgba16float:new ez("rgba16float",i.keyword,"rgba16float"),rgba32uint:new ez("rgba32uint",i.keyword,"rgba32uint"),rgba32sint:new ez("rgba32sint",i.keyword,"rgba32sint"),rgba32float:new ez("rgba32float",i.keyword,"rgba32float"),static_assert:new ez("static_assert",i.keyword,"static_assert")},eG.tokens={decimal_float_literal:new ez("decimal_float_literal",i.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?[fh]?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+[fh]?)|(-?[0-9]+[fh])/),hex_float_literal:new ez("hex_float_literal",i.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+[fh]?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+[fh]?))/),int_literal:new ez("int_literal",i.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new ez("uint_literal",i.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new ez("name",i.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new ez("ident",i.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new ez("and",i.token,"&"),and_and:new ez("and_and",i.token,"&&"),arrow:new ez("arrow ",i.token,"->"),attr:new ez("attr",i.token,"@"),forward_slash:new ez("forward_slash",i.token,"/"),bang:new ez("bang",i.token,"!"),bracket_left:new ez("bracket_left",i.token,"["),bracket_right:new ez("bracket_right",i.token,"]"),brace_left:new ez("brace_left",i.token,"{"),brace_right:new ez("brace_right",i.token,"}"),colon:new ez("colon",i.token,":"),comma:new ez("comma",i.token,","),equal:new ez("equal",i.token,"="),equal_equal:new ez("equal_equal",i.token,"=="),not_equal:new ez("not_equal",i.token,"!="),greater_than:new ez("greater_than",i.token,">"),greater_than_equal:new ez("greater_than_equal",i.token,">="),shift_right:new ez("shift_right",i.token,">>"),less_than:new ez("less_than",i.token,"<"),less_than_equal:new ez("less_than_equal",i.token,"<="),shift_left:new ez("shift_left",i.token,"<<"),modulo:new ez("modulo",i.token,"%"),minus:new ez("minus",i.token,"-"),minus_minus:new ez("minus_minus",i.token,"--"),period:new ez("period",i.token,"."),plus:new ez("plus",i.token,"+"),plus_plus:new ez("plus_plus",i.token,"++"),or:new ez("or",i.token,"|"),or_or:new ez("or_or",i.token,"||"),paren_left:new ez("paren_left",i.token,"("),paren_right:new ez("paren_right",i.token,")"),semicolon:new ez("semicolon",i.token,";"),star:new ez("star",i.token,"*"),tilde:new ez("tilde",i.token,"~"),underscore:new ez("underscore",i.token,"_"),xor:new ez("xor",i.token,"^"),plus_equal:new ez("plus_equal",i.token,"+="),minus_equal:new ez("minus_equal",i.token,"-="),times_equal:new ez("times_equal",i.token,"*="),division_equal:new ez("division_equal",i.token,"/="),modulo_equal:new ez("modulo_equal",i.token,"%="),and_equal:new ez("and_equal",i.token,"&="),or_equal:new ez("or_equal",i.token,"|="),xor_equal:new ez("xor_equal",i.token,"^="),shift_right_equal:new ez("shift_right_equal",i.token,">>="),shift_left_equal:new ez("shift_left_equal",i.token,"<<=")},eG.simpleTokens={"@":eG.tokens.attr,"{":eG.tokens.brace_left,"}":eG.tokens.brace_right,":":eG.tokens.colon,",":eG.tokens.comma,"(":eG.tokens.paren_left,")":eG.tokens.paren_right,";":eG.tokens.semicolon},eG.literalTokens={"&":eG.tokens.and,"&&":eG.tokens.and_and,"->":eG.tokens.arrow,"/":eG.tokens.forward_slash,"!":eG.tokens.bang,"[":eG.tokens.bracket_left,"]":eG.tokens.bracket_right,"=":eG.tokens.equal,"==":eG.tokens.equal_equal,"!=":eG.tokens.not_equal,">":eG.tokens.greater_than,">=":eG.tokens.greater_than_equal,">>":eG.tokens.shift_right,"<":eG.tokens.less_than,"<=":eG.tokens.less_than_equal,"<<":eG.tokens.shift_left,"%":eG.tokens.modulo,"-":eG.tokens.minus,"--":eG.tokens.minus_minus,".":eG.tokens.period,"+":eG.tokens.plus,"++":eG.tokens.plus_plus,"|":eG.tokens.or,"||":eG.tokens.or_or,"*":eG.tokens.star,"~":eG.tokens.tilde,_:eG.tokens.underscore,"^":eG.tokens.xor,"+=":eG.tokens.plus_equal,"-=":eG.tokens.minus_equal,"*=":eG.tokens.times_equal,"/=":eG.tokens.division_equal,"%=":eG.tokens.modulo_equal,"&=":eG.tokens.and_equal,"|=":eG.tokens.or_equal,"^=":eG.tokens.xor_equal,">>=":eG.tokens.shift_right_equal,"<<=":eG.tokens.shift_left_equal},eG.regexTokens={decimal_float_literal:eG.tokens.decimal_float_literal,hex_float_literal:eG.tokens.hex_float_literal,int_literal:eG.tokens.int_literal,uint_literal:eG.tokens.uint_literal,ident:eG.tokens.ident},eG.storage_class=[eG.keywords.function,eG.keywords.private,eG.keywords.workgroup,eG.keywords.uniform,eG.keywords.storage],eG.access_mode=[eG.keywords.read,eG.keywords.write,eG.keywords.read_write],eG.sampler_type=[eG.keywords.sampler,eG.keywords.sampler_comparison],eG.sampled_texture_type=[eG.keywords.texture_1d,eG.keywords.texture_2d,eG.keywords.texture_2d_array,eG.keywords.texture_3d,eG.keywords.texture_cube,eG.keywords.texture_cube_array],eG.multisampled_texture_type=[eG.keywords.texture_multisampled_2d],eG.storage_texture_type=[eG.keywords.texture_storage_1d,eG.keywords.texture_storage_2d,eG.keywords.texture_storage_2d_array,eG.keywords.texture_storage_3d],eG.depth_texture_type=[eG.keywords.texture_depth_2d,eG.keywords.texture_depth_2d_array,eG.keywords.texture_depth_cube,eG.keywords.texture_depth_cube_array,eG.keywords.texture_depth_multisampled_2d],eG.texture_external_type=[eG.keywords.texture_external],eG.any_texture_type=[...eG.sampled_texture_type,...eG.multisampled_texture_type,...eG.storage_texture_type,...eG.depth_texture_type,...eG.texture_external_type],eG.texel_format=[eG.keywords.r8unorm,eG.keywords.r8snorm,eG.keywords.r8uint,eG.keywords.r8sint,eG.keywords.r16uint,eG.keywords.r16sint,eG.keywords.r16float,eG.keywords.rg8unorm,eG.keywords.rg8snorm,eG.keywords.rg8uint,eG.keywords.rg8sint,eG.keywords.r32uint,eG.keywords.r32sint,eG.keywords.r32float,eG.keywords.rg16uint,eG.keywords.rg16sint,eG.keywords.rg16float,eG.keywords.rgba8unorm,eG.keywords.rgba8unorm_srgb,eG.keywords.rgba8snorm,eG.keywords.rgba8uint,eG.keywords.rgba8sint,eG.keywords.bgra8unorm,eG.keywords.bgra8unorm_srgb,eG.keywords.rgb10a2unorm,eG.keywords.rg11b10float,eG.keywords.rg32uint,eG.keywords.rg32sint,eG.keywords.rg32float,eG.keywords.rgba16uint,eG.keywords.rgba16sint,eG.keywords.rgba16float,eG.keywords.rgba32uint,eG.keywords.rgba32sint,eG.keywords.rgba32float],eG.const_literal=[eG.tokens.int_literal,eG.tokens.uint_literal,eG.tokens.decimal_float_literal,eG.tokens.hex_float_literal,eG.keywords.true,eG.keywords.false],eG.literal_or_ident=[eG.tokens.ident,eG.tokens.int_literal,eG.tokens.uint_literal,eG.tokens.decimal_float_literal,eG.tokens.hex_float_literal,eG.tokens.name],eG.element_c
1ount_expression=[eG.tokens.int_literal,eG.tokens.uint_literal,eG.tokens.ident],eG.template_types=[eG.keywords.vec2,eG.keywords.vec3,eG.keywords.vec4,eG.keywords.mat2x2,eG.keywords.mat2x3,eG.keywords.mat2x4,eG.keywords.mat3x2,eG.keywords.mat3x3,eG.keywords.mat3x4,eG.keywords.mat4x2,eG.keywords.mat4x3,eG.keywords.mat4x4,eG.keywords.atomic,eG.keywords.bitcast,...eG.any_texture_type],eG.attribute_name=[eG.tokens.ident,eG.keywords.block,eG.keywords.diagnostic],eG.assignment_operators=[eG.tokens.equal,eG.tokens.plus_equal,eG.tokens.minus_equal,eG.tokens.times_equal,eG.tokens.division_equal,eG.tokens.modulo_equal,eG.tokens.and_equal,eG.tokens.or_equal,eG.tokens.xor_equal,eG.tokens.shift_right_equal,eG.tokens.shift_left_equal],eG.increment_operators=[eG.tokens.plus_plus,eG.tokens.minus_minus];class eR{constructor(e,t,n,r,s){this.type=e,this.lexeme=t,this.line=n,this.start=r,this.end=s}toString(){return this.lexeme}isTemplateType(){return -1!=eG.template_types.indexOf(this.type)}isArrayType(){return this.type==eG.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class eX{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=null!=e?e:""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new eR(eG.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if("\n"==e)return this._line++,!0;if(this._isWhitespace(e))return!0;if("/"==e){if("/"==this._peekAhead()){for(;"\n"!=e;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}if("*"==this._peekAhead()){this._advance();let t=1;for(;t>0&&!this._isAtEnd();)if("\n"==(e=this._advance()))this._line++;else if("*"==e){if("/"==this._peekAhead()&&(this._advance(),0==--t))break}else"/"==e&&"*"==this._peekAhead()&&(this._advance(),t++);return!0}}let t=eG.simpleTokens[e];if(t)return this._addToken(t),!0;let n=eG.none,r=this._isAlpha(e),s="_"===e;if(this._isAlphaNumeric(e)){let t=this._peekAhead();for(;this._isAlphaNumeric(t);)e+=this._advance(),t=this._peekAhead()}if(r){let t=eG.keywords[e];if(t)return this._addToken(t),!0}if(r||s)return this._addToken(eG.tokens.ident),!0;for(;;){let t=this._findType(e),r=this._peekAhead();if("-"==e&&this._tokens.length>0){if("="==r)return this._current++,e+=r,this._addToken(eG.tokens.minus_equal),!0;if("-"==r)return this._current++,e+=r,this._addToken(eG.tokens.minus_minus),!0;let n=this._tokens.length-1;if((-1!=eG.literal_or_ident.indexOf(this._tokens[n].type)||this._tokens[n].type==eG.tokens.paren_right)&&">"!=r)return this._addToken(t),!0}if(">"==e&&(">"==r||"="==r)){let e=!1,n=this._tokens.length-1;for(let t=0;t<5&&n>=0&&-1===eG.assignment_operators.indexOf(this._tokens[n].type);++t,--n)if(this._tokens[n].type===eG.tokens.less_than){n>0&&this._tokens[n-1].isArrayOrTemplateType()&&(e=!0);break}if(e)return this._addToken(t),!0}if(t===eG.none){let r=e,s=0;for(let e=0;e<2;++e)if(r+=this._peekAhead(e),(t=this._findType(r))!==eG.none){s=e;break}if(t===eG.none)return n!==eG.none&&(this._current--,this._addToken(n),!0);e=r,this._current+=s+1}if(n=t,this._isAtEnd())break;e+=this._advance()}return n!==eG.none&&(this._addToken(n),!0)}_findType(e){for(let t in eG.regexTokens){let n=eG.regexTokens[t];if(this._match(e,n.rule))return n}return eG.literalTokens[e]||eG.none}_match(e,t){let n=t.exec(e);return n&&0==n.index&&n[0]==e}_isAtEnd(){return this._current>=this._source.length}_isAlpha(e){return!this._isNumeric(e)&&!this._isWhitespace(e)&&"_"!==e&&"."!==e&&"("!==e&&")"!==e&&"["!==e&&"]"!==e&&"{"!==e&&"}"!==e&&","!==e&&";"!==e&&":"!==e&&"="!==e&&"!"!==e&&"<"!==e&&">"!==e&&"+"!==e&&"-"!==e&&"*"!==e&&"/"!==e&&"%"!==e&&"&"!==e&&"|"!==e&&"^"!==e&&"~"!==e&&"@"!==e&&"#"!==e&&"?"!==e&&"'"!==e&&"`"!==e&&'"'!==e&&"\\"!==e&&"\n"!==e&&"\r"!==e&&"	"!==e&&"\0"!==e}_isNumeric(e){return e>="0"&&e<="9"}_isAlphaNumeric(e){return this._isAlpha(e)||this._isNumeric(e)||"_"===e}_isWhitespace(e){return" "==e||"	"==e||"\r"==e}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){let t=this._source.substring(this._start,this._current);this._tokens.push(new eR(e,t,this._line,this._start,this._current))}}function ej(e){return Array.isArray(e)||(null==e?void 0:e.buffer)instanceof ArrayBuffer}let eZ=new Float32Array(1),eQ=new Uint32Array(eZ.buffer),eY=new Uint32Array(eZ.buffer),eK=new Int32Array(1),eJ=new Float32Array(eK.buffer),e2=new Uint32Array(eK.buffer),e3=new Uint32Array(1),e1=new Float32Array(e3.buffer),e4=new Int32Array(e3.buffer);function e0(e,t,n){if(t===n)return e;if("f32"===t){if("i32"===n||"x32"===n)return eZ[0]=e,eQ[0];if("u32"===n)return eZ[0]=e,eY[0]}else if("i32"===t||"x32"===t){if("f32"===n)return eK[0]=e,eJ[0];if("u32"===n)return eK[0]=e,e2[0]}else if("u32"===t){if("f32"===n)return e3[0]=e,e1[0];if("i32"===n||"x32"===n)return e3[0]=e,e4[0]}return console.error(`Unsupported cast from ${t} to ${n}`),e}class e6{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class e8{constructor(e,t){this.align=e,this.size=t}}class e5{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new T,this.functions=[],this._types=new Map,this._functions=new Map}_isStorageTexture(e){return"texture_storage_1d"==e.name||"texture_storage_2d"==e.name||"texture_storage_2d_array"==e.name||"texture_storage_3d"==e.name}updateAST(e){for(let t of e)t instanceof P&&this._functions.set(t.name,new e6(t));for(let t of e)if(t instanceof eh){let e=this.getTypeInfo(t,null);e instanceof d&&this.structs.push(e)}for(let t of e)if(t instanceof ea)this.aliases.push(this._getAliasInfo(t));else{if(t instanceof R){let e=this._getAttributeNum(t.attributes,"id",0),n=null!=t.type?this.getTypeInfo(t.type,t.attributes):null;this.overrides.push(new w(t.name,n,t.attributes,e));continue}if(this._isUniformVar(t)){let e=this._getAttributeNum(t.attributes,"group",0),n=this._getAttributeNum(t.attributes,"binding",0),s=this.getTypeInfo(t.type,t.attributes),a=new x(t.name,s,e,n,t.attributes,r.Uniform,t.access);a.access||(a.access="read"),this.uniforms.push(a);continue}if(this._isStorageVar(t)){let e=this._getAttributeNum(t.attributes,"group",0),n=this._getAttributeNum(t.attributes,"binding",0),s=this.getTypeInfo(t.type,t.attributes),a=this._isStorageTexture(s),i=new x(t.name,s,e,n,t.attributes,a?r.StorageTexture:r.Storage,t.access);i.access||(i.access="read"),this.storage.push(i);continue}if(this._isTextureVar(t)){let e=this._getAttributeNum(t.attributes,"group",0),n=this._getAttributeNum(t.attributes,"binding",0),s=this.getTypeInfo(t.type,t.attributes),a=this._isStorageTexture(s),i=new x(t.name,s,e,n,t.attributes,a?r.StorageTexture:r.Texture,t.access);i.access||(i.access="read"),a?this.storage.push(i):this.textures.push(i);continue}if(this._isSamplerVar(t)){let e=this._getAttributeNum(t.attributes,"group",0),n=this._getAttributeNum(t.attributes,"binding",0),s=this.getTypeInfo(t.type,t.attributes),a=new x(t.name,s,e,n,t.attributes,r.Sampler,t.access);this.samplers.push(a);continue}}for(let t of e)if(t instanceof P){let e=this._getAttribute(t,"vertex"),n=this._getAttribute(t,"fragment"),r=this._getAttribute(t,"compute"),s=e||n||r,a=new I(t.name,null==s?void 0:s.name,t.attributes);a.attributes=t.attributes,a.startLine=t.startLine,a.endLine=t.endLine,this.functions.push(a),this._functions.get(t.name).info=a,s&&(this._functions.get(t.name).inUse=!0,a.inUse=!0,a.resources=this._findResources(t,!!s),a.inputs=this._getInputs(t.args),a.outputs=this._getOutputs(t.returnType),this.entry[s.name].push(a)),a.arguments=t.args.map(e=>new k(e.name,this.getTypeInfo(e.type,e.attributes),e.attributes)),a.returnType=t.returnType?this.getTypeInfo(t.returnType,t.attributes):null;continue}for(let e of this._functions.values())e.info&&(e.info.inUse=e.inUse,this._addCalls(e.node,e.info.calls));for(let e of this._functions.values())e.node.search(t=>{var n,r,s;if(t instanceof eV){if(t.value){if(ej(t.value))for(let r of t.value)for(let t of this.overrides)r===t.name&&(null===(n=e.info)||void 0===n||n.overrides.push(t));else for(let n of this.overrides)t.value===n.name&&(null===(r=e.info)||void 0===r||r.overrides.push(n))}}else if(t instanceof eb)for(let n of this.overrides)t.name===n.name&&(null===(s=e.info)||void 0===s||s.overrides.push(n))});for(let e of this.uniforms)this._markStructsInUse(e.type);for(let e of this.storage)this._markStructsInUse(e.type)}getFunctionInfo(e){for(let t of this.functions)if(t.name==e)return t;return null}getStructInfo(e){for(let t of this.structs)if(t.name==e)return t;return null}getOverrideInfo(e){for(let t of this.overrides)if(t.name==e)return t;return null}_markStructsInUse(e){if(e){if(e.isStruct){if(e.inUse=!0,e.members)for(let t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{let t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}}_addCalls(e,t){var n;for(let r of e.calls){let e=null===(n=this._functions.get(r.name))||void 0===n?void 0:n.info;e&&t.add(e)}}findResource(e,t,n){if(n){for(let r of this.entry.compute)if(r.name===n){for(let n of r.resources)if(n.group==e&&n.binding==t)return n}for(let r of this.entry.vertex)if(r.name===n){for(let n of r.resources)if(n.group==e&&n.binding==t)return n}for(let r of this.entry.fragment)if(r.name===n){for(let n of r.resources)if(n.group==e&&n.binding==t)return n}}for(let n of this.uniforms)if(n.group==e&&n.binding==t)return n;for(let n of this.storage)if(n.group==e&&n.binding==t)return n;for(let n of this.textures)if(n.group==e&&n.binding==t)return n;for(let n of this.samplers)if(n.group==e&&n.binding==t)return n;return null}_findResource(e){for(let t of this.uniforms)if(t.name==e)return t;for(let t of this.storage)if(t.name==e)return t;for(let t of this.textures)if(t.name==e)return t;for(let t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){let t=this.getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){let n=[],r=this,s=[];return e.search(a=>{if(a instanceof C)s.push({});else if(a instanceof F)s.pop();else if(a instanceof G)t&&null!==a.type&&this._markStructsFromAST(a.type),s.length>0&&(s[s.length-1][a.name]=a);else if(a instanceof ex)t&&null!==a.type&&this._markStructsFromAST(a.type);else if(a instanceof X)t&&null!==a.type&&this._markStructsFromAST(a.type),s.length>0&&(s[s.length-1][a.name]=a);else if(a instanceof eb){if(s.length>0&&s[s.length-1][a.name])return;let e=r._findResource(a.name);e&&n.push(e)}else if(a instanceof ey){let s=r._functions.get(a.name);s&&(t&&(s.inUse=!0),e.calls.add(s.node),null===s.resources&&(s.resources=r._findResources(s.node,t)),n.push(...s.resources))}else if(a instanceof Y){let s=r._functions.get(a.name);s&&(t&&(s.inUse=!0),e.calls.add(s.node),null===s.resources&&(s.resources=r._findResources(s.node,t)),n.push(...s.resources))}}),[...new Map(n.map(e=>[e.name,e])).values()]}getBindGroups(){let e=[];function t(t,n){t>=e.length&&(e.length=t+1),void 0===e[t]&&(e[t]=[]),n>=e[t].length&&(e[t].length=n+1)}for(let n of this.uniforms)t(n.group,n.binding),e[n.group][n.binding]=n;for(let n of this.storage)t(n.group,n.binding),e[n.group][n.binding]=n;for(let n of this.textures)t(n.group,n.binding),e[n.group][n.binding]=n;for(let n of this.samplers)t(n.group,n.binding),e[n.group][n.binding]=n;return e}_getOutputs(e,t){if(void 0===t&&(t=[]),e instanceof eh)this._getStructOutputs(e,t);else{let n=this._getOutputInfo(e);null!==n&&t.push(n)}return t}_getStructOutputs(e,t){for(let n of e.members)if(n.type instanceof eh)this._getStructOutputs(n.t
1ype,t);else{let e=this._getAttribute(n,"location")||this._getAttribute(n,"builtin");if(null!==e){let r=this.getTypeInfo(n.type,n.type.attributes),s=this._parseInt(e.value),a=new v(n.name,r,e.name,s);t.push(a)}}}_getOutputInfo(e){let t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(null!==t){let n=this.getTypeInfo(e,e.attributes),r=this._parseInt(t.value);return new v("",n,t.name,r)}return null}_getInputs(e,t){for(let n of(void 0===t&&(t=[]),e))if(n.type instanceof eh)this._getStructInputs(n.type,t);else{let e=this._getInputInfo(n);null!==e&&t.push(e)}return t}_getStructInputs(e,t){for(let n of e.members)if(n.type instanceof eh)this._getStructInputs(n.type,t);else{let e=this._getInputInfo(n);null!==e&&t.push(e)}}_getInputInfo(e){let t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(null!==t){let n=this._getAttribute(e,"interpolation"),r=this.getTypeInfo(e.type,e.attributes),s=this._parseInt(t.value),a=new b(e.name,r,t.name,s);return null!==n&&(a.interpolation=this._parseString(n.value)),a}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);let t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(let t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new y(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(let t of this.structs)if(t.name==e)return t;for(let t of this.aliases)if(t.name==e)return t.type;return null}getTypeInfo(e,t=null){if(this._types.has(e))return this._types.get(e);if(e instanceof ep){let n=e.type?this.getTypeInfo(e.type,e.attributes):null,r=new g(e.name,n,t);return this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof ed){let n=e.format?this.getTypeInfo(e.format,e.attributes):null,r=new m(e.name,t);return r.format=n,r.count=e.count,this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof eh){let n=new d(e.name,t);for(let t of(n.startLine=e.startLine,n.endLine=e.endLine,e.members)){let e=this.getTypeInfo(t.type,t.attributes);n.members.push(new p(t.name,e,t.attributes))}return this._types.set(e,n),this._updateTypeInfo(n),n}if(e instanceof em){let n=e.format instanceof eu,r=e.format?n?this.getTypeInfo(e.format,null):new f(e.format,null):null,s=new _(e.name,r,t,e.access);return this._types.set(e,s),this._updateTypeInfo(s),s}if(e instanceof ef){let n=e.format?this.getTypeInfo(e.format,null):null,r=new _(e.name,n,t,e.access);return this._types.set(e,r),this._updateTypeInfo(r),r}let n=new f(e.name,t);return this._types.set(e,n),this._updateTypeInfo(n),n}_updateTypeInfo(e){var t,n,r;let s=this._getTypeSize(e);if(e.size=null!==(t=null==s?void 0:s.size)&&void 0!==t?t:0,e instanceof m&&e.format){let t=this._getTypeSize(e.format);e.stride=Math.max(null!==(n=null==t?void 0:t.size)&&void 0!==n?n:0,null!==(r=null==t?void 0:t.align)&&void 0!==r?r:0),this._updateTypeInfo(e.format)}e instanceof g&&this._updateTypeInfo(e.format),e instanceof d&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let n=0,r=0,s=0,a=0;for(let i=0,o=e.members.length;i<o;++i){let o=e.members[i],l=this._getTypeSize(o);if(!l)continue;null!==(t=this._getAlias(o.type.name))&&void 0!==t||o.type;let u=l.align,c=l.size;n=this._roundUp(u,n+r),r=c,s=n,a=Math.max(a,u),o.offset=n,o.size=c,this._updateTypeInfo(o.type)}e.size=this._roundUp(a,s+r),e.align=a}_getTypeSize(e){var t,n;if(null==e)return null;let r=this._getAttributeNum(e.attributes,"size",0),s=this._getAttributeNum(e.attributes,"align",0);if(e instanceof p&&(e=e.type),e instanceof f){let t=this._getAlias(e.name);null!==t&&(e=t)}{let n=e5._typeInfo[e.name];if(void 0!==n){let a="f16"===(null===(t=e.format)||void 0===t?void 0:t.name)?2:1;return new e8(Math.max(s,n.align/a),Math.max(r,n.size/a))}}{let t=e5._typeInfo[e.name.substring(0,e.name.length-1)];if(t){let n="h"===e.name[e.name.length-1]?2:1;return new e8(Math.max(s,t.align/n),Math.max(r,t.size/n))}}if(e instanceof m){let t=e,a=8,i=8,o=this._getTypeSize(t.format);return null!==o&&(i=o.size,a=o.align),i=t.count*this._getAttributeNum(null!==(n=null==e?void 0:e.attributes)&&void 0!==n?n:null,"stride",this._roundUp(a,i)),r&&(i=r),new e8(Math.max(s,a),Math.max(r,
1i))}if(e instanceof d){let t=0,n=0,a=0,i=0,o=0;for(let n of e.members){let e=this._getTypeSize(n.type);null!==e&&(t=Math.max(e.align,t),a=this._roundUp(e.align,a+i),i=e.size,o=a)}return n=this._roundUp(t,o+i),new e8(Math.max(s,t),Math.max(r,n))}return null}_isUniformVar(e){return e instanceof G&&"uniform"==e.storage}_isStorageVar(e){return e instanceof G&&"storage"==e.storage}_isTextureVar(e){return e instanceof G&&null!==e.type&&-1!=e5._textureTypes.indexOf(e.type.name)}_isSamplerVar(e){return e instanceof G&&null!==e.type&&-1!=e5._samplerTypes.indexOf(e.type.name)}_getAttribute(e,t){if(!e||!e.attributes)return null;for(let n of e.attributes)if(n.name==t)return n;return null}_getAttributeNum(e,t,n){if(null===e)return n;for(let r of e)if(r.name==t){let e=null!==r&&null!==r.value?r.value:n;return e instanceof Array&&(e=e[0]),"number"==typeof e?e:"string"==typeof e?parseInt(e):n}return n}_roundUp(e,t){return Math.ceil(t/e)*e}}e5._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}},e5._textureTypes=eG.any_texture_type.map(e=>e.name),e5._samplerTypes=eG.sampler_type.map(e=>e.name);let e7=0;class e9{constructor(e,t,n){this.id=e7++,this.name=e,this.value=t,this.node=n}clone(){return new e9(this.name,this.value,this.node)}}class te{constructor(e){this.id=e7++,this.name=e.name,this.node=e}clone(){return new te(this.node)}}class tt{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",this.id=e7++,e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var t;return this.variables.has(e)?null!==(t=this.variables.get(e))&&void 0!==t?t:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var t;return this.functions.has(e)?null!==(t=this.functions.get(e))&&void 0!==t?t:null:this.parent?this.parent.getFunction(e):null}createVariable(e,t,n){this.variables.set(e,new e9(e,t,null!=n?n:null))}setVariable(e,t,n){let r=this.getVariable(e);null!==r?r.value=t:this.createVariable(e,t,n)}getVariableValue(e){var t;let n=this.getVariable(e);return null!==(t=null==n?void 0:n.value)&&void 0!==t?t:null}clone(){return new tt(this)}}class tn{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}}class tr{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,t){let n=this.exec.evalExpression(e.args[0],t),r=!0;if(n instanceof eP)return n.data.forEach(e=>{e||(r=!1)}),new eU(r?1:0,this.getTypeInfo("bool"));throw Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,t){let n=this.exec.evalExpression(e.args[0],t);
1if(n instanceof eP)return new eU(n.data.some(e=>e)?1:0,this.getTypeInfo("bool"));throw Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,t){let n=this.exec.evalExpression(e.args[2],t);if(!(n instanceof eU))throw Error(`Select() expects a bool condition. Line ${e.line}`);return n.value?this.exec.evalExpression(e.args[1],t):this.exec.evalExpression(e.args[0],t)}ArrayLength(e,t){let n=e.args[0];n instanceof eS&&(n=n.right);let r=this.exec.evalExpression(n,t);if(r instanceof eq&&0===r.typeInfo.size){let e=r.typeInfo;return new eU(r.buffer.byteLength/e.stride,this.getTypeInfo("u32"))}return new eU(r.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.abs(e)),n.typeInfo):new eU(Math.abs(n.value),n.typeInfo)}Acos(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.acos(e)),n.typeInfo):new eU(Math.acos(n.value),n.typeInfo)}Acosh(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.acosh(e)),n.typeInfo):new eU(Math.acosh(n.value),n.typeInfo)}Asin(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.asin(e)),n.typeInfo):new eU(Math.asin(n.value),n.typeInfo)}Asinh(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.asinh(e)),n.typeInfo):new eU(Math.asinh(n.value),n.typeInfo)}Atan(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.atan(e)),n.typeInfo):new eU(Math.atan(n.value),n.typeInfo)}Atanh(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.atanh(e)),n.typeInfo):new eU(Math.atanh(n.value),n.typeInfo)}Atan2(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);return n instanceof eP&&r instanceof eP?new eP(n.data.map((e,t)=>Math.atan2(e,r.data[t])),n.typeInfo):new eU(Math.atan2(n.value,r.value),n.typeInfo)}Ceil(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.ceil(e)),n.typeInfo):new eU(Math.ceil(n.value),n.typeInfo)}_clamp(e,t,n){return Math.min(Math.max(e,t),n)}Clamp(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);return n instanceof eP&&r instanceof eP&&s instanceof eP?new eP(n.data.map((e,t)=>this._clamp(e,r.data[t],s.data[t])),n.typeInfo):new eU(this._clamp(n.value,r.value,s.value),n.typeInfo)}Cos(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.cos(e)),n.typeInfo):new eU(Math.cos(n.value),n.typeInfo)}Cosh(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.cosh(e)),n.typeInfo):new eU(Math.cos(n.value),n.typeInfo)}CountLeadingZeros(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.clz32(e)),n.typeInfo):new eU(Math.clz32(n.value),n.typeInfo)}_countOneBits(e){let t=0;for(;0!==e;)1&e&&t++,e>>=1;return t}CountOneBits(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>this._countOneBits(e)),n.typeInfo):new eU(this._countOneBits(n.value),n.typeInfo)}_countTrailingZeros(e){if(0===e)return 32;let t=0;for(;!(1&e);)e>>=1,t++;return t}CountTrailingZeros(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>this._countTrailingZeros(e)),n.typeInfo):new eU(this._countTrailingZeros(n.value),n.typeInfo)}Cross(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(n instanceof eP&&r instanceof eP){if(3!==n.data.length||3!==r.data.length)return console.error(`Cross() expects 3D vectors. Line ${e.line}`),null;let t=n.data,s=r.data;return new eP([t[1]*s[2]-s[1]*t[2],t[2]*s[0]-s[2]*t[0],t[0]*s[1]-s[0]*t[1]],n.typeInfo)}return console.error(`Cross() expects vector arguments. Line ${e.line}`),null}Degrees(e,t){let n=this.exec.evalExpression(e.args[0],t),r=180/Math.PI;return n instanceof eP?new eP(n.data.map(e=>e*r),n.typeInfo):new eU(n.value*r,this.getTypeInfo("f32"))}Determinant(e,t){let n=this.exec.evalExpression(e.args[0],t);
1if(n instanceof eW){let e=n.data,t=n.typeInfo.getTypeName(),r=t.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t)return new eU(e[0]*e[3]-e[1]*e[2],r);if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t)return new eU(e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]),r);if("mat2x4"===t||"mat2x4f"===t||"mat2x4h"===t)console.error(`TODO: Determinant for ${t}`);else if("mat3x2"===t||"mat3x2f"===t||"mat3x2h"===t)console.error(`TODO: Determinant for ${t}`);else{if("mat3x3"===t||"mat3x3f"===t||"mat3x3h"===t)return new eU(e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]),r);"mat3x4"===t||"mat3x4f"===t||"mat3x4h"===t||"mat4x2"===t||"mat4x2f"===t||"mat4x2h"===t||"mat4x3"===t||"mat4x3f"===t||"mat4x3h"===t?console.error(`TODO: Determinant for ${t}`):"mat4x4"!==t&&"mat4x4f"!==t&&"mat4x4h"!==t||console.error(`TODO: Determinant for ${t}`)}}return console.error(`Determinant expects a matrix argument. Line ${e.line}`),null}Distance(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(n instanceof eP&&r instanceof eP){let e=0;for(let t=0;t<n.data.length;++t)e+=(n.data[t]-r.data[t])*(n.data[t]-r.data[t]);return new eU(Math.sqrt(e),this.getTypeInfo("f32"))}return new eU(Math.abs(n.value-r.value),n.typeInfo)}_dot(e,t){let n=0;for(let r=0;r<e.length;++r)n+=t[r]*e[r];return n}Dot(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);return n instanceof eP&&r instanceof eP?new eU(this._dot(n.data,r.data),this.getTypeInfo("f32")):(console.error(`Dot() expects vector arguments. Line ${e.line}`),null)}Dot4U8Packed(e,t){return console.error(`TODO: dot4U8Packed. Line ${e.line}`),null}Dot4I8Packed(e,t){return console.error(`TODO: dot4I8Packed. Line ${e.line}`),null}Exp(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.exp(e)),n.typeInfo):new eU(Math.exp(n.value),n.typeInfo)}Exp2(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.pow(2,e)),n.typeInfo):new eU(Math.pow(2,n.value),n.typeInfo)}ExtractBits(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if("u32"!==r.typeInfo.name&&"x32"!==r.typeInfo.name)return console.error(`ExtractBits() expects an i32 offset argument. Line ${e.line}`),null;if("u32"!==s.typeInfo.name&&"x32"!==s.typeInfo.name)return console.error(`ExtractBits() expects an i32 count argument. Line ${e.line}`),null;let a=r.value,i=s.value;return n instanceof eP?new eP(n.data.map(e=>e>>a&(1<<i)-1),n.typeInfo):"i32"!==n.typeInfo.name&&"x32"!==n.typeInfo.name?(console.error(`ExtractBits() expects an i32 argument. Line ${e.line}`),null):new eU(n.value>>a&(1<<i)-1,this.getTypeInfo("i32"))}FaceForward(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);return n instanceof eP&&r instanceof eP&&s instanceof eP?new eP(0>this._dot(r.data,s.data)?Array.from(n.data):n.data.map(e=>-e),n.typeInfo):(console.error(`FaceForward() expects vector arguments. Line ${e.line}`),null)}_firstLeadingBit(e){return 0===e?-1:31-Math.clz32(e)}FirstLeadingBit(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>this._firstLeadingBit(e)),n.typeInfo):new eU(this._firstLeadingBit(n.value),n.typeInfo)}_firstTrailingBit(e){return 0===e?-1:Math.log2(e&-e)}FirstTrailingBit(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>this._firstTrailingBit(e)),n.typeInfo):new eU(this._firstTrailingBit(n.value),n.typeInfo)}Floor(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.floor(e)),n.typeInfo):new eU(Math.floor(n.value),n.typeInfo)}Fma(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);return n instanceof eP&&r instanceof eP&&s instanceof eP?n.data.length!==r.data.length||n.data.length!==s.data.length?(console.error(`Fma() expects vectors of the same length. Line ${e.line}`),null):new eP(n.data.map((e,t)=>e*r.data[t]+s.data[t]),n.typeInfo):new eU(n.value*r.value+s.value,
1n.typeInfo)}Fract(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>e-Math.floor(e)),n.typeInfo):new eU(n.value-Math.floor(n.value),n.typeInfo)}Frexp(e,t){return console.error(`TODO: frexp. Line ${e.line}`),null}InsertBits(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t),a=this.exec.evalExpression(e.args[3],t);if("u32"!==s.typeInfo.name&&"x32"!==s.typeInfo.name)return console.error(`InsertBits() expects an i32 offset argument. Line ${e.line}`),null;let i=s.value,o=(1<<a.value)-1<<i,l=~o;return n instanceof eP&&r instanceof eP?new eP(n.data.map((e,t)=>e&l|r.data[t]<<i&o),n.typeInfo):new eU(n.value&l|r.value<<i&o,n.typeInfo)}InverseSqrt(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>1/Math.sqrt(e)),n.typeInfo):new eU(1/Math.sqrt(n.value),n.typeInfo)}Ldexp(e,t){return console.error(`TODO: ldexp. Line ${e.line}`),null}Length(e,t){let n=this.exec.evalExpression(e.args[0],t);
1if(n instanceof eP){let e=0;return n.data.forEach(t=>{e+=t*t}),new eU(Math.sqrt(e),this.getTypeInfo("f32"))}return new eU(Math.abs(n.value),n.typeInfo)}Log(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.log(e)),n.typeInfo):new eU(Math.log(n.value),n.typeInfo)}Log2(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.log2(e)),n.typeInfo):new eU(Math.log2(n.value),n.typeInfo)}Max(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);return n instanceof eP&&r instanceof eP?new eP(n.data.map((e,t)=>Math.max(e,r.data[t])),n.typeInfo):new eU(Math.max(n.value,r.value),n.typeInfo)}Min(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);return n instanceof eP&&r instanceof eP?new eP(n.data.map((e,t)=>Math.min(e,r.data[t])),n.typeInfo):new eU(Math.min(n.value,r.value),n.typeInfo)}Mix(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);return n instanceof eP&&r instanceof eP&&s instanceof eP?new eP(n.data.map((e,t)=>n.data[t]*(1-s.data[t])+r.data[t]*s.data[t]),n.typeInfo):new eU(n.value*(1-s.value)+r.value*s.value,n.typeInfo)}Modf(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);return n instanceof eP&&r instanceof eP?new eP(n.data.map((e,t)=>e%r.data[t]),n.typeInfo):new eU(n.value%r.value,n.typeInfo)}Normalize(e,t){let n=this.exec.evalExpression(e.args[0],t);
1if(n instanceof eP){let r=this.Length(e,t).value;return new eP(n.data.map(e=>e/r),n.typeInfo)}return console.error(`Normalize() expects a vector argument. Line ${e.line}`),null}Pow(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);return n instanceof eP&&r instanceof eP?new eP(n.data.map((e,t)=>Math.pow(e,r.data[t])),n.typeInfo):new eU(Math.pow(n.value,r.value),n.typeInfo)}QuantizeToF16(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>e),n.typeInfo):new eU(n.value,n.typeInfo)}Radians(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>e*Math.PI/180),n.typeInfo):new eU(n.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(n instanceof eP&&r instanceof eP){let e=this._dot(n.data,r.data);return new eP(n.data.map((t,n)=>t-2*e*r.data[n]),n.typeInfo)}return console.error(`Reflect() expects vector arguments. Line ${e.line}`),null}Refract(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);if(n instanceof eP&&r instanceof eP&&s instanceof eU){let e=this._dot(r.data,n.data);return new eP(n.data.map((t,n)=>{let a=1-s.value*s.value*(1-e*e);return a<0?0:s.value*t-(s.value*e+Math.sqrt(a))*r.data[n]}),n.typeInfo)}return console.error(`Refract() expects vector arguments and a scalar argument. Line ${e.line}`),null}ReverseBits(e,t){return console.error(`TODO: reverseBits. Line ${e.line}`),null}Round(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.round(e)),n.typeInfo):new eU(Math.round(n.value),n.typeInfo)}Saturate(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.min(Math.max(e,0),1)),n.typeInfo):new eU(Math.min(Math.max(n.value,0),1),n.typeInfo)}Sign(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.sign(e)),n.typeInfo):new eU(Math.sign(n.value),n.typeInfo)}Sin(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.sin(e)),n.typeInfo):new eU(Math.sin(n.value),n.typeInfo)}Sinh(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.sinh(e)),n.typeInfo):new eU(Math.sinh(n.value),n.typeInfo)}_smoothstep(e,t,n){let r=Math.min(Math.max((n-e)/(t-e),0),1);return r*r*(3-2*r)}SmoothStep(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),s=this.exec.evalExpression(e.args[2],t);return s instanceof eP&&n instanceof eP&&r instanceof eP?new eP(s.data.map((e,t)=>this._smoothstep(n.data[t],r.data[t],e)),s.typeInfo):new eU(this._smoothstep(n.value,r.value,s.value),s.typeInfo)}Sqrt(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.sqrt(e)),n.typeInfo):new eU(Math.sqrt(n.value),n.typeInfo)}Step(e,t){let n=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);return r instanceof eP&&n instanceof eP?new eP(r.data.map((e,t)=>e<n.data[t]?0:1),r.typeInfo):new eU(r.value<n.value?0:1,n.typeInfo)}Tan(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.tan(e)),n.typeInfo):new eU(Math.tan(n.value),n.typeInfo)}Tanh(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.tanh(e)),n.typeInfo):new eU(Math.tanh(n.value),n.typeInfo)}_getTransposeType(e){let t=e.getTypeName();return"mat2x2f"===t||"mat2x2h"===t?e:"mat2x3f"===t?this.getTypeInfo("mat3x2f"):"mat2x3h"===t?this.getTypeInfo("mat3x2h"):"mat2x4f"===t?this.getTypeInfo("mat4x2f"):"mat2x4h"===t?this.getTypeInfo("mat4x2h"):"mat3x2f"===t?this.getTypeInfo("mat2x3f"):"mat3x2h"===t?this.getTypeInfo("mat2x3h"):"mat3x3f"===t||"mat3x3h"===t?e:"mat3x4f"===t?this.getTypeInfo("mat4x3f"):"mat3x4h"===t?this.getTypeInfo("mat4x3h"):"mat4x2f"===t?this.getTypeInfo("mat2x4f"):"mat4x2h"===t?this.getTypeInfo("mat2x4h"):"mat4x3f"===t?this.getTypeInfo("mat3x4f"):"mat4x3h"===t?this.getTypeInfo("mat3x4h"):("mat4x4f"===t||"mat4x4h"===t||console.error(`Invalid matrix type ${t}`),e)}Transpose(e,t){let n=this.exec.evalExpression(e.args[0],t);
1if(!(n instanceof eW))return console.error(`Transpose() expects a matrix argument. Line ${e.line}`),null;let r=this._getTransposeType(n.typeInfo);if("mat2x2"===n.typeInfo.name||"mat2x2f"===n.typeInfo.name||"mat2x2h"===n.typeInfo.name){let e=n.data;return new eW([e[0],e[2],e[1],e[3]],r)}if("mat2x3"===n.typeInfo.name||"mat2x3f"===n.typeInfo.name||"mat2x3h"===n.typeInfo.name){let e=n.data;return new eW([e[0],e[3],e[6],e[1],e[4],e[7]],r)}if("mat2x4"===n.typeInfo.name||"mat2x4f"===n.typeInfo.name||"mat2x4h"===n.typeInfo.name){let e=n.data;return new eW([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13]],r)}if("mat3x2"===n.typeInfo.name||"mat3x2f"===n.typeInfo.name||"mat3x2h"===n.typeInfo.name){let e=n.data;return new eW([e[0],e[3],e[1],e[4],e[2],e[5]],r)}if("mat3x3"===n.typeInfo.name||"mat3x3f"===n.typeInfo.name||"mat3x3h"===n.typeInfo.name){let e=n.data;return new eW([e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]],r)}if("mat3x4"===n.typeInfo.name||"mat3x4f"===n.typeInfo.name||"mat3x4h"===n.typeInfo.name){let e=n.data;return new eW([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14]],r)}if("mat4x2"===n.typeInfo.name||"mat4x2f"===n.typeInfo.name||"mat4x2h"===n.typeInfo.name){let e=n.data;return new eW([e[0],e[4],e[1],e[5],e[2],e[6]],r)}if("mat4x3"===n.typeInfo.name||"mat4x3f"===n.typeInfo.name||"mat4x3h"===n.typeInfo.name){let e=n.data;return new eW([e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]],r)}if("mat4x4"===n.typeInfo.name||"mat4x4f"===n.typeInfo.name||"mat4x4h"===n.typeInfo.name){let e=n.data;return new eW([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15]],r)}return console.error(`Invalid matrix type ${n.typeInfo.name}`),null}Trunc(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof eP?new eP(n.data.map(e=>Math.trunc(e)),n.typeInfo):new eU(Math.trunc(n.value),n.typeInfo)}Dpdx(e,t){return console.error(`TODO: dpdx. Line ${e.line}`),null}DpdxCoarse(e,t){return console.error(`TODO: dpdxCoarse. Line ${e.line}`),null}DpdxFine(e,t){return console.error("TODO: dpdxFine"),null}Dpdy(e,t){return console.error("TODO: dpdy"),null}DpdyCoarse(e,t){return console.error("TODO: dpdyCoarse"),null}DpdyFine(e,t){return console.error("TODO: dpdyFine"),null}Fwidth(e,t){return console.error("TODO: fwidth"),null}FwidthCoarse(e,t){return console.error("TODO: fwidthCoarse"),null}FwidthFine(e,t){return console.error("TODO: fwidthFine"),null}TextureDimensions(e,t){let n=e.args[0],r=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(n instanceof eb){let s=n.name,a=t.getVariableValue(s);if(a instanceof eH){if(r<0||r>=a.mipLevelCount)return console.error(`Invalid mip level for textureDimensions. Line ${e.line}`),null;let t=a.getMipLevelSize(r),n=a.dimension;return"1d"===n?new eU(t[0],this.getTypeInfo("u32")):"3d"===n?new eP(t,this.getTypeInfo("vec3u")):"2d"===n?new eP(t.slice(0,2),this.getTypeInfo("vec2u")):(console.error(`Invalid texture dimension ${n} not found. Line ${e.line}`),null)}return console.error(`Texture ${s} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureDimensions. Line ${e.line}`),null}TextureGather(e,t){return console.error("TODO: textureGather"),null}TextureGatherCompare(e,t){return console.error("TODO: textureGatherCompare"),null}TextureLoad(e,t){let n=e.args[0],r=this.exec.evalExpression(e.args[1],t),s=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(r instanceof eP)||2!==r.data.length)return console.error(`Invalid UV argument for textureLoad. Line ${e.line}`),null;if(n instanceof eb){let a=n.name,i=t.getVariableValue(a);if(i instanceof eH){let t=Math.floor(r.data[0]),n=Math.floor(r.data[1]);if(t<0||t>=i.width||n<0||n>=i.height)return console.error(`Texture ${a} out of bounds. Line ${e.line}`),null;let o=i.getPixel(t,n,0,s);return null===o?(console.error(`Invalid texture format for textureLoad. Line ${e.line}`),null):new eP(o,this.getTypeInfo("vec4f"))}return console.error(`Texture ${a} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureLoad. Line ${e.line}`),null}TextureNumLayers(e,t){let n=e.args[0];if(n instanceof eb){let r=n.name,s=t.getVariableValue(r);return s instanceof eH?new eU(s.depthOrArrayLayers,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLayers. Line ${e.line}`),null}TextureNumLevels(e,t){let n=e.args[0];if(n instanceof eb){let r=n.name,s=t.getVariableValue(r);return s instanceof eH?new eU(s.mipLevelCount,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLevels. Line ${e.line}`),null}TextureNumSamples(e,t){let n=e.args[0];if(n instanceof eb){let r=n.name,s=t.getVariableValue(r);return s instanceof eH?new eU(s.sampleCount,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumSamples. Line ${e.line}`),null}TextureSample(e,t){return console.error("TODO: textureSample"),null}TextureSampleBias(e,t){return console.error("TODO: textureSampleBias"),null}TextureSampleCompare(e,t){return console.error("TODO: textureSampleCompare"),null}TextureSampleCompareLevel(e,t){return console.error("TODO: textureSampleCompareLevel"),null}TextureSampleGrad(e,t){return console.error("TODO: textureSampleGrad"),null}TextureSampleLevel(e,t){return console.error("TODO: textureSampleLevel"),null}TextureSampleBaseClampToEdge(e,t){return console.error("TODO: textureSampleBaseClampToEdge"),null}TextureStore(e,t){let n=e.args[0],r=this.exec.evalExpression(e.args[1],t),s=4===e.args.length?this.exec.evalExpression(e.args[2],t).value:0,a=4===e.args.length?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(4!==a.length)return console.error(`Invalid value argument for textureStore. Line ${e.line}`),null;if(!(r instanceof eP)||2!==r.data.length)return console.error(`Invalid UV argument for textureStore. Line ${e.line}`),null;if(n instanceof eb){let i=n.name,o=t.getVariableValue(i);
1if(o instanceof eH){let t=o.getMipLevelSize(0),n=Math.floor(r.data[0]),l=Math.floor(r.data[1]);return n<0||n>=t[0]||l<0||l>=t[1]?console.error(`Texture ${i} out of bounds. Line ${e.line}`):o.setPixel(n,l,0,s,Array.from(a)),null}return console.error(`Texture ${i} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureStore. Line ${e.line}`),null}AtomicLoad(e,t){let n=e.args[0];n instanceof eS&&(n=n.right);let r=this.exec.getVariableName(n,t);return t.getVariable(r).value.getSubData(this.exec,n.postfix,t)}AtomicStore(e,t){let n=e.args[0];n instanceof eS&&(n=n.right);let r=this.exec.getVariableName(n,t),s=t.getVariable(r),a=e.args[1],i=this.exec.evalExpression(a,t),o=s.value.getSubData(this.exec,n.postfix,t);return o instanceof eU&&i instanceof eU&&(o.value=i.value),s.value instanceof eq&&s.value.setDataValue(this.exec,o,n.postfix,t),null}AtomicAdd(e,t){let n=e.args[0];n instanceof eS&&(n=n.right);let r=this.exec.getVariableName(n,t),s=t.getVariable(r),a=e.args[1],i=this.exec.evalExpression(a,t),o=s.value.getSubData(this.exec,n.postfix,t),l=new eU(o.value,o.typeInfo);return o instanceof eU&&i instanceof eU&&(o.value+=i.value),s.value instanceof eq&&s.value.setDataValue(this.exec,o,n.postfix,t),l}AtomicSub(e,t){let n=e.args[0];n instanceof eS&&(n=n.right);let r=this.exec.getVariableName(n,t),s=t.getVariable(r),a=e.args[1],i=this.exec.evalExpression(a,t),o=s.value.getSubData(this.exec,n.postfix,t),l=new eU(o.value,o.typeInfo);return o instanceof eU&&i instanceof eU&&(o.value-=i.value),s.value instanceof eq&&s.value.setDataValue(this.exec,o,n.postfix,t),l}AtomicMax(e,t){let n=e.args[0];n instanceof eS&&(n=n.right);let r=this.exec.getVariableName(n,t),s=t.getVariable(r),a=e.args[1],i=this.exec.evalExpression(a,t),o=s.value.getSubData(this.exec,n.postfix,t),l=new eU(o.value,o.typeInfo);return o instanceof eU&&i instanceof eU&&(o.value=Math.max(o.value,i.value)),s.value instanceof eq&&s.value.setDataValue(this.exec,o,n.postfix,t),l}AtomicMin(e,t){let n=e.args[0];n instanceof eS&&(n=n.right);let r=this.exec.getVariableName(n,t),s=t.getVariable(r),a=e.args[1],i=this.exec.evalExpression(a,t),o=s.value.getSubData(this.exec,n.postfix,t),l=new eU(o.value,o.typeInfo);return o instanceof eU&&i instanceof eU&&(o.value=Math.min(o.value,i.value)),s.value instanceof eq&&s.value.setDataValue(this.exec,o,n.postfix,t),l}AtomicAnd(e,t){let n=e.args[0];n instanceof eS&&(n=n.right);let r=this.exec.getVariableName(n,t),s=t.getVariable(r),a=e.args[1],i=this.exec.evalExpression(a,t),o=s.value.getSubData(this.exec,n.postfix,t),l=new eU(o.value,o.typeInfo);return o instanceof eU&&i instanceof eU&&(o.value=o.value&i.value),s.value instanceof eq&&s.value.setDataValue(this.exec,o,n.postfix,t),l}AtomicOr(e,t){let n=e.args[0];n instanceof eS&&(n=n.right);let r=this.exec.getVariableName(n,t),s=t.getVariable(r),a=e.args[1],i=this.exec.evalExpression(a,t),o=s.value.getSubData(this.exec,n.postfix,t),l=new eU(o.value,o.typeInfo);return o instanceof eU&&i instanceof eU&&(o.value=o.value|i.value),s.value instanceof eq&&s.value.setDataValue(this.exec,o,n.postfix,t),l}AtomicXor(e,t){let n=e.args[0];n instanceof eS&&(n=n.right);let r=this.exec.getVariableName(n,t),s=t.getVariable(r),a=e.args[1],i=this.exec.evalExpression(a,t),o=s.value.getSubData(this.exec,n.postfix,t),l=new eU(o.value,o.typeInfo);return o instanceof eU&&i instanceof eU&&(o.value=o.value^i.value),s.value instanceof eq&&s.value.setDataValue(this.exec,o,n.postfix,t),l}AtomicExchange(e,t){let n=e.args[0];n instanceof eS&&(n=n.right);let r=this.exec.getVariableName(n,t),s=t.getVariable(r),a=e.args[1],i=this.exec.evalExpression(a,t),o=s.value.getSubData(this.exec,n.postfix,t),l=new eU(o.value,o.typeInfo);return o instanceof eU&&i instanceof eU&&(o.value=i.value),s.value instanceof eq&&s.value.setDataValue(this.exec,o,n.postfix,t),l}AtomicCompareExchangeWeak(e,t){return console.error("TODO: atomicCompareExchangeWeak"),null}Pack4x8snorm(e,t){return console.error("TODO: pack4x8snorm"),null}Pack4x8unorm(e,t){return console.error("TODO: pack4x8unorm"),null}Pack4xI8(e,t){return console.error("TODO: pack4xI8"),null}Pack4xU8(e,t){return console.error("TODO: pack4xU8"),null}Pack4x8Clamp(e,t){return console.error("TODO: pack4x8Clamp"),null}Pack4xU8Clamp(e,t){return console.error("TODO: pack4xU8Clamp"),null}Pack2x16snorm(e,t){return console.error("TODO: pack2x16snorm"),null}Pack2x16unorm(e,t){return console.error("TODO: pack2x16unorm"),null}Pack2x16float(e,t){return console.error("TODO: pack2x16float"),null}Unpack4x8snorm(e,t){return console.error("TODO: unpack4x8snorm"),null}Unpack4x8unorm(e,t){return console.error("TODO: unpack4x8unorm"),null}Unpack4xI8(e,t){return console.error("TODO: unpack4xI8"),null}Unpack4xU8(e,t){return console.error("TODO: unpack4xU8"),null}Unpack2x16snorm(e,t){return console.error("TODO: unpack2x16snorm"),null}Unpack2x16unorm(e,t){return console.error("TODO: unpack2x16unorm"),null}Unpack2x16float(e,t){return console.error("TODO: unpack2x16float"),null}StorageBarrier(e,t){return null}TextureBarrier(e,t){return null}WorkgroupBarrier(e,t){return null}WorkgroupUniformLoad(e,t){return null}SubgroupAdd(e,t){return console.error("TODO: subgroupAdd"),null}SubgroupExclusiveAdd(e,t){return console.error("TODO: subgroupExclusiveAdd"),null}SubgroupInclusiveAdd(e,t){return console.error("TODO: subgroupInclusiveAdd"),null}SubgroupAll(e,t){return console.error("TODO: subgroupAll"),null}SubgroupAnd(e,t){return console.error("TODO: subgroupAnd"),null}SubgroupAny(e,t){return console.error("TODO: subgroupAny"),null}SubgroupBallot(e,t){return console.error("TODO: subgroupBallot"),null}SubgroupBroadcast(e,t){return console.error("TODO: subgroupBroadcast"),null}SubgroupBroadcastFirst(e,t){return console.error("TODO: subgroupBroadcastFirst"),null}SubgroupElect(e,t){return console.error("TODO: subgroupElect"),null}SubgroupMax(e,t){return console.error("TODO: subgroupMax"),null}SubgroupMin(e,t){return console.error("TODO: subgroupMin"),null}SubgroupMul(e,t){return console.error("TODO: subgroupMul"),null}SubgroupExclusiveMul(e,t){return console.error("TODO: subgroupExclusiveMul"),null}SubgroupInclusiveMul(e,t){return console.error("TODO: subgroupInclusiveMul"),null}SubgroupOr(e,t){return console.error("TODO: subgroupOr"),null}SubgroupShuffle(e,t){return console.error("TODO: subgroupShuffle"),null}SubgroupShuffleDown(e,t){return console.error("TODO: subgroupShuffleDown"),null}SubgroupShuffleUp(e,t){return console.error("TODO: subgroupShuffleUp"),null}SubgroupShuffleXor(e,t){return console.error("TODO: subgroupShuffleXor"),null}SubgroupXor(e,t){return console.error("TODO: subgroupXor"),null}QuadBroadcast(e,t){return console.error("TODO: quadBroadcast"),null}QuadSwapDiagonal(e,t){return console.error("TODO: quadSwapDiagonal"),null}QuadSwapX(e,t){return console.error("TODO: quadSwapX"),null}QuadSwapY(e,t){return console.error("TODO: quadSwapY"),null}}let ts={vec2:2,vec2f:2,vec2i:2,vec2u:2,vec2b:2,vec2h:2,vec3:3,vec3f:3,vec3i:3,vec3u:3,vec3b:3,vec3h:3,vec4:4,vec4f:4,vec4i:4,vec4u:4,vec4b:4,vec4h:4},ta={mat2x2:[2,2,4],mat2x2f:[2,2,4],mat2x2h:[2,2,4],mat2x3:[2,3,6],mat2x3f:[2,3,6],mat2x3h:[2,3,6],mat2x4:[2,4,8],mat2x4f:[2,4,8],mat2x4h:[2,4,8],mat3x2:[3,2,6],mat3x2f:[3,2,6],mat3x2h:[3,2,6],mat3x3:[3,3,9],mat3x3f:[3,3,9],mat3x3h:[3,3,9],mat3x4:[3,4,12],mat3x4f:[3,4,12],mat3x4h:[3,4,12],mat4x2:[4,2,8],mat4x2f:[4,2,8],mat4x2h:[4,2,8],mat4x3:[4,3,12],mat4x3f
1:[4,3,12],mat4x3h:[4,3,12],mat4x4:[4,4,16],mat4x4f:[4,4,16],mat4x4h:[4,4,16]};class ti extends tn{constructor(e,t){var n;super(),this.ast=null!=e?e:[],this.reflection=new e5,this.reflection.updateAST(this.ast),this.context=null!==(n=null==t?void 0:t.clone())&&void 0!==n?n:new tt,this.builtins=new tr(this),this.typeInfo={bool:this.getTypeInfo(eu.bool),i32:this.getTypeInfo(eu.i32),u32:this.getTypeInfo(eu.u32),f32:this.getTypeInfo(eu.f32),f16:this.getTypeInfo(eu.f16),vec2f:this.getTypeInfo(ef.vec2f),vec2u:this.getTypeInfo(ef.vec2u),vec2i:this.getTypeInfo(ef.vec2i),vec2h:this.getTypeInfo(ef.vec2h),vec3f:this.getTypeInfo(ef.vec3f),vec3u:this.getTypeInfo(ef.vec3u),vec3i:this.getTypeInfo(ef.vec3i),vec3h:this.getTypeInfo(ef.vec3h),vec4f:this.getTypeInfo(ef.vec4f),vec4u:this.getTypeInfo(ef.vec4u),vec4i:this.getTypeInfo(ef.vec4i),vec4h:this.getTypeInfo(ef.vec4h),mat2x2f:this.getTypeInfo(ef.mat2x2f),mat2x3f:this.getTypeInfo(ef.mat2x3f),mat2x4f:this.getTypeInfo(ef.mat2x4f),mat3x2f:this.getTypeInfo(ef.mat3x2f),mat3x3f:this.getTypeInfo(ef.mat3x3f),mat3x4f:this.getTypeInfo(ef.mat3x4f),mat4x2f:this.getTypeInfo(ef.mat4x2f),mat4x3f:this.getTypeInfo(ef.mat4x3f),mat4x4f:this.getTypeInfo(ef.mat4x4f)}}getVariableValue(e){var t,n;let r=null!==(n=null===(t=this.context.getVariable(e))||void 0===t?void 0:t.value)&&void 0!==n?n:null;if(null===r)return null;if(r instanceof eU)return r.value;if(r instanceof eP||r instanceof eW)return Array.from(r.data);if(r instanceof eq&&r.typeInfo instanceof m){if("u32"===r.typeInfo.format.name)return Array.from(new Uint32Array(r.buffer,r.offset,r.typeInfo.count));if("i32"===r.typeInfo.format.name)return Array.from(new Int32Array(r.buffer,r.offset,r.typeInfo.count));if("f32"===r.typeInfo.format.name)return Array.from(new Float32Array(r.buffer,r.offset,r.typeInfo.count))}return console.error(`Unsupported return variable type ${r.typeInfo.name}`),null}execute(e){(e=null!=e?e:{}).constants&&this._setOverrides(e.constants,this.context),this._execStatements(this.ast,this.context)}dispatchWorkgroups(e,t,n,r){let s=this.context.clone();(r=null!=r?r:{}).constants&&this._setOverrides(r.constants,s),this._execStatements(this.ast,s);let a=s.getFunction(e);if(!a)return void console.error(`Function ${e} not found`);if("number"==typeof t)t=[t,1,1];else{if(0===t.length)return void console.error("Invalid dispatch count");1===t.length?t=[t[0],1,1]:2===t.length?t=[t[0],t[1],1]:t.length>3&&(t=[t[0],t[1],t[2]])}let i=t[0],o=t[1],l=t[2],u=this.getTypeInfo("vec3u");s.setVariable("@num_workgroups",new eP(t,u));let c=this.reflection.getFunctionInfo(e);for(let t in null===c&&console.error(`Function ${e} not found in reflection data`),n)for(let e in n[t]){let r=n[t][e];
1s.variables.forEach(n=>{var s;let a=n.node;if(null==a?void 0:a.attributes){let i=null,o=null;for(let e of a.attributes)"binding"===e.name?i=e.value:"group"===e.name&&(o=e.value);if(e==i&&t==o){let i=!1;for(let r of c.resources)if(r.name===n.name&&r.group===parseInt(t)&&r.binding===parseInt(e)){i=!0;break}if(i){if(void 0!==r.texture&&void 0!==r.descriptor){let e=new eH(r.texture,this.getTypeInfo(a.type),r.descriptor,null!==(s=r.texture.view)&&void 0!==s?s:null);n.value=e}else void 0!==r.uniform?n.value=new eq(r.uniform,this.getTypeInfo(a.type)):n.value=new eq(r,this.getTypeInfo(a.type))}}}})}for(let e=0;e<l;++e)for(let t=0;t<o;++t)for(let n=0;n<i;++n)s.setVariable("@workgroup_id",new eP([n,t,e],this.getTypeInfo("vec3u"))),this._dispatchWorkgroup(a,[n,t,e],s)}execStatement(e,t){if(e instanceof et)return this.evalExpression(e.value,t);if(e instanceof eo){if(e.condition){let n=this.evalExpression(e.condition,t);if(!(n instanceof eU))throw Error("Invalid break-if condition");if(!n.value)return null}return ti._breakObj}if(e instanceof el)return ti._continueObj;if(e instanceof X)this._let(e,t);else if(e instanceof G)this._var(e,t);else if(e instanceof j)this._const(e,t);else if(e instanceof P)this._function(e,t);else{if(e instanceof ee)return this._if(e,t);if(e instanceof J)return this._switch(e,t);if(e instanceof z)return this._for(e,t);if(e instanceof q)return this._while(e,t);if(e instanceof K)return this._loop(e,t);if(e instanceof H){let n=t.clone();return n.currentFunctionName=t.currentFunctionName,this._execStatements(e.body,n)}if(e instanceof Q)this._assign(e,t);else if(e instanceof Z)this._increment(e,t);else{if(e instanceof eh)return null;if(e instanceof R){let n=e.name;null===t.getVariable(n)&&t.setVariable(n,new eU(0,this.getTypeInfo("u32")))}else if(e instanceof Y)this._call(e,t);else{if(e instanceof es||e instanceof ea)return null;console.error("Invalid statement type.",e,`Line ${e.line}`)}}}return null}evalExpression(e,t){return e instanceof eA?this._evalBinaryOp(e,t):e instanceof ew?this._evalLiteral(e,t):e instanceof eb?this._evalVariable(e,t):e instanceof ey?this._evalCall(e,t):e instanceof ex?this._evalCreate(e,t):e instanceof ev?this._evalConst(e,t):e instanceof ek?this._evalBitcast(e,t):e instanceof eS?this._evalUnaryOp(e,t):(console.error("Invalid expression type",e,`Line ${e.line}`),null)}getTypeInfo(e){var t;if(e instanceof eu){let t=this.reflection.getTypeInfo(e);if(null!==t)return t}let n=null!==(t=this.typeInfo[e])&&void 0!==t?t:null;return null!==n||(n=this.reflection.getTypeInfoByName(e)),n}_setOverrides(e,t){for(let n in e){let r=e[n],s=this.reflection.getOverrideInfo(n);null!==s?(null===s.type&&(s.type=this.getTypeInfo("u32")),"u32"===s.type.name||"i32"===s.type.name||"f32"===s.type.name||"f16"===s.type.name?t.setVariable(n,new eU(r,s.type)):"bool"===s.type.name?t.setVariable(n,new eU(r?1:0,s.type)):"vec2"===s.type.name||"vec3"===s.type.name||"vec4"===s.type.name||"vec2f"===s.type.name||"vec3f"===s.type.name||"vec4f"===s.type.name||"vec2i"===s.type.name||"vec3i"===s.type.name||"vec4i"===s.type.name||"vec2u"===s.type.name||"vec3u"===s.type.name||"vec4u"===s.type.name||"vec2h"===s.type.name||"vec3h"===s.type.name||"vec4h"===s.type.name?t.setVariable(n,new eP(r,s.type)):console.error(`Invalid constant type for ${n}`)):console.error(`Override ${n} does not exist in the shader.`)}}_dispatchWorkgroup(e,t,n){let r=[1,1,1];for(let t of e.node.attributes)if("workgroup_size"===t.name){if(t.value.length>0){let e=n.getVariableValue(t.value[0]);r[0]=e instanceof eU?e.value:parseInt(t.value[0])}if(t.value.length>1){let e=n.getVariableValue(t.value[1]);r[1]=e instanceof eU?e.value:parseInt(t.value[1])}if(t.value.length>2){let e=n.getVariableValue(t.value[2]);r[2]=e instanceof eU?e.value:parseInt(t.value[2])}}let s=this.getTypeInfo("vec3u"),a=this.getTypeInfo("u32");n.setVariable("@workgroup_size",new eP(r,s));let i=r[0],o=r[1],l=r[2];for(let u=0,c=0;u<l;++u)for(let l=0;l<o;++l)for(let o=0;o<i;++o,++c){let i=[o,l,u],h=[o+t[0]*r[0],l+t[1]*r[1],u+t[2]*r[2]];n.setVariable("@local_invocation_id",new eP(i,s)),n.setVariable("@global_invocation_id",new eP(h,s)),n.setVariable("@local_invocation_index",new eU(c,a)),this._dispatchExec(e,n)}}_dispatchExec(e,t){for(let n of e.node.args)for(let e of n.attributes)if("builtin"===e.name){let r=`@${e.value}`,s=t.getVariable(r);void 0!==s&&t.variables.set(n.name,s)}this._execStatements(e.node.body,t)}getVariableName(e,t){for(;e instanceof eS;)e=e.right;return e instanceof eb?e.name:(console.error("Unknown variable type",e,"Line",e.line),null)}_execStatements(e,t){for(let n of e){if(n instanceof Array){let e=t.clone(),r=this._execStatements(n,e);if(r)return r;continue}
1let e=this.execStatement(n,t);if(e)return e}return null}_call(e,t){let n=t.clone();n.currentFunctionName=e.name;let r=t.getFunction(e.name);if(r){for(let t=0;t<r.node.args.length;++t){let s=r.node.args[t],a=this.evalExpression(e.args[t],n);n.setVariable(s.name,a,s)}this._execStatements(r.node.body,n)}else e.isBuiltin?this._callBuiltinFunction(e,n):this.getTypeInfo(e.name)&&this._evalCreate(e,t)}_increment(e,t){let n=this.getVariableName(e.variable,t),r=t.getVariable(n);r?"++"===e.operator?r.value instanceof eU?r.value.value++:console.error(`Variable ${n} is not a scalar. Line ${e.line}`):"--"===e.operator?r.value instanceof eU?r.value.value--:console.error(`Variable ${n} is not a scalar. Line ${e.line}`):console.error(`Unknown increment operator ${e.operator}. Line ${e.line}`):console.error(`Variable ${n} not found. Line ${e.line}`)}_getVariableData(e,t){if(e instanceof eb){let n=this.getVariableName(e,t),r=t.getVariable(n);return null===r?(console.error(`Variable ${n} not found. Line ${e.line}`),null):r.value.getSubData(this,e.postfix,t)}if(e instanceof eS){if("*"===e.operator){let n=this._getVariableData(e.right,t);return n instanceof eM?n.reference.getSubData(this,e.postfix,t):(console.error(`Variable ${e.right} is not a pointer. Line ${e.line}`),null)}if("&"===e.operator)return new eM(this._getVariableData(e.right,t))}return null}_assign(e,t){let n=null,r="<var>",s=null;if(e.variable instanceof eS){let n=this._getVariableData(e.variable,t),r=this.evalExpression(e.value,t),s=e.operator;if("="===s){if(n instanceof eU||n instanceof eP||n instanceof eW){if(r instanceof eU||r instanceof eP||r instanceof eW&&n.data.length===r.data.length)return void n.data.set(r.data);console.error(`Invalid assignment. Line ${e.line}`)}else if(n instanceof eq&&r instanceof eq&&n.buffer.byteLength-n.offset>=r.buffer.byteLength-r.offset)return void(n.buffer.byteLength%4==0?new Uint32Array(n.buffer,n.offset,n.typeInfo.size/4).set(new Uint32Array(r.buffer,r.offset,r.typeInfo.size/4)):new Uint8Array(n.buffer,n.offset,n.typeInfo.size).set(new Uint8Array(r.buffer,r.offset,r.typeInfo.size)));return console.error(`Invalid assignment. Line ${e.line}`),null}if("+="===s)return n instanceof eU||n instanceof eP||n instanceof eW?r instanceof eU||r instanceof eP||r instanceof eW?void n.data.set(r.data.map((e,t)=>n.data[t]+e)):void console.error(`Invalid assignment . Line ${e.line}`):void console.error(`Invalid assignment. Line ${e.line}`);if("-="===s)return(n instanceof eU||n instanceof eP||n instanceof eW)&&(r instanceof eU||r instanceof eP||r instanceof eW)?void n.data.set(r.data.map((e,t)=>n.data[t]-e)):void console.error(`Invalid assignment. Line ${e.line}`)}if(e.variable instanceof eS){if("*"===e.variable.operator){r=this.getVariableName(e.variable.right,t);let s=t.getVariable(r);if(!(s&&s.value instanceof eM))return void console.error(`Variable ${r} is not a pointer. Line ${e.line}`);n=s.value.reference;let a=e.variable.postfix;if(!a){let t=e.variable.right;for(;t instanceof eS;){if(t.postfix){a=t.postfix;break}t=t.right}}a&&(n=n.getSubData(this,a,t))}}else{s=e.variable.postfix,r=this.getVariableName(e.variable,t);let a=t.getVariable(r);if(null===a)return void console.error(`Variable ${r} not found. Line ${e.line}`);n=a.value}if(n instanceof eM&&(n=n.reference),null===n)return void console.error(`Variable ${r} not found. Line ${e.line}`);let a=this.evalExpression(e.value,t),i=e.operator;if("="!==i){let r=n.getSubData(this,s,t);if(r instanceof eP&&a instanceof eU){let t=r.data,n=a.value;if("+="===i)for(let e=0;e<t.length;++e)t[e]+=n;else if("-="===i)for(let e=0;e<t.length;++e)t[e]-=n;else if("*="===i)for(let e=0;e<t.length;++e)t[e]*=n;else if("/="===i)for(let e=0;e<t.length;++e)t[e]/=n;else if("%="===i)for(let e=0;e<t.length;++e)t[e]%=n;else if("&="===i)for(let e=0;e<t.length;++e)t[e]&=n;else if("|="===i)for(let e=0;e<t.length;++e)t[e]|=n;else if("^="===i)for(let e=0;e<t.length;++e)t[e]^=n;else if("<<="===i)for(let e=0;e<t.length;++e)t[e]<<=n;else if(">>="===i)for(let e=0;e<t.length;++e)t[e]>>=n;else console.error(`Invalid operator ${i}. Line ${e.line}`)}else if(r instanceof eP&&a instanceof eP){let t=r.data,n=a.data;if(t.length!==n.length)return void console.error(`Vector length mismatch. Line ${e.line}`);if("+="===i)for(let e=0;e<t.length;++e)t[e]+=n[e];else if("-="===i)for(let e=0;e<t.length;++e)t[e]-=n[e];else if("*="===i)for(let e=0;e<t.length;++e)t[e]*=n[e];else if("/="===i)for(let e=0;e<t.length;++e)t[e]/=n[e];else if("%="===i)for(let e=0;e<t.length;++e)t[e]%=n[e];else if("&="===i)for(let e=0;e<t.length;++e)t[e]&=n[e];else if("|="===i)for(let e=0;e<t.length;++e)t[e]|=n[e];else if("^="===i)for(let e=0;e<t.length;++e)t[e]^=n[e];else if("<<="===i)for(let e=0;e<t.length;++e)t[e]<<=n[e];else if(">>="===i)for(let e=0;e<t.length;++e)t[e]>>=n[e];else console.error(`Invalid operator ${i}. Line ${e.line}`)}else{if(!(r instanceof eU&&a instanceof eU))return void console.error(`Invalid type for ${e.operator} operator. Line ${e.line}`);"+="===i?r.value+=a.value:"-="===i?r.value-=a.value:"*="===i?r.value*=a.value:"/="===i?r.value/=a.value:"%="===i?r.value%=a.value:"&="===i?r.value&=a.value:"|="===i?r.value|=a.value:"^="===i?r.value^=a.value:"<<="===i?r.value<<=a.value:">>="===i?r.value>>=a.value:console.error(`Invalid operator ${i}. Line ${e.line}`)}return void(n instanceof eq&&n.setDataValue(this,r,s,t))}if(n instanceof eq)n.setDataValue(this,a,s,t);else if(s){if(!(n instanceof eP||n instanceof eW))return void console.error(`Variable ${r} is not a vector or matrix. Line ${e.line}`);if(s instanceof eI){let i=this.evalExpression(s.index,t).value;if(n instanceof eP){if(!(a instanceof eU))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);n.data[i]=a.value}else{if(!(n instanceof eW))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);{let i=this.evalExpression(s.index,t).value;if(i<0||!(a instanceof eP))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);{let t=n.typeInfo.getTypeName();if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t){if(!(i<2&&2===a.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);n.data[2*i]=a.data[0],n.data[2*i+1]=a.data[1]}else if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t){if(!(i<2&&3===a.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);
1n.data[3*i]=a.data[0],n.data[3*i+1]=a.data[1],n.data[3*i+2]=a.data[2]}else if("mat2x4"===t||"mat2x4f"===t||"mat2x4h"===t){if(!(i<2&&4===a.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);n.data[4*i]=a.data[0],n.data[4*i+1]=a.data[1],n.data[4*i+2]=a.data[2],n.data[4*i+3]=a.data[3]}else if("mat3x2"===t||"mat3x2f"===t||"mat3x2h"===t){if(!(i<3&&2===a.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);n.data[2*i]=a.data[0],n.data[2*i+1]=a.data[1]}else if("mat3x3"===t||"mat3x3f"===t||"mat3x3h"===t){if(!(i<3&&3===a.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);n.data[3*i]=a.data[0],n.data[3*i+1]=a.data[1],n.data[3*i+2]=a.data[2]}else if("mat3x4"===t||"mat3x4f"===t||"mat3x4h"===t){if(!(i<3&&4===a.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);n.data[4*i]=a.data[0],n.data[4*i+1]=a.data[1],n.data[4*i+2]=a.data[2],n.data[4*i+3]=a.data[3]}else if("mat4x2"===t||"mat4x2f"===t||"mat4x2h"===t){if(!(i<4&&2===a.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);n.data[2*i]=a.data[0],n.data[2*i+1]=a.data[1]}else if("mat4x3"===t||"mat4x3f"===t||"mat4x3h"===t){if(!(i<4&&3===a.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);n.data[3*i]=a.data[0],n.data[3*i+1]=a.data[1],n.data[3*i+2]=a.data[2]}else{if("mat4x4"!==t&&"mat4x4f"!==t&&"mat4x4h"!==t||!(i<4&&4===a.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);n.data[4*i]=a.data[0],n.data[4*i+1]=a.data[1],n.data[4*i+2]=a.data[2],n.data[4*i+3]=a.data[3]}}}}}else if(s instanceof e_){let t=s.value;if(!(n instanceof eP))return void console.error(`Invalid assignment to ${t}. Variable ${r} is not a vector. Line ${e.line}`);if(a instanceof eU){if(t.length>1)return void console.error(`Invalid assignment to ${t} for variable ${r}. Line ${e.line}`);if("x"===t)n.data[0]=a.value;else if("y"===t){if(n.data.length<2)return void console.error(`Invalid assignment to ${t} for variable ${r}. Line ${e.line}`);n.data[1]=a.value}else if("z"===t){if(n.data.length<3)return void console.error(`Invalid assignment to ${t} for variable ${r}. Line ${e.line}`);n.data[2]=a.value}else if("w"===t){if(n.data.length<4)return void console.error(`Invalid assignment to ${t} for variable ${r}. Line ${e.line}`);n.data[3]=a.value}}else{if(!(a instanceof eP))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(t.length!==a.data.length)return void console.error(`Invalid assignment to ${t} for variable ${r}. Line ${e.line}`);for(let s=0;s<t.length;++s){let i=t[s];if("x"===i||"r"===i)n.data[0]=a.data[s];else if("y"===i||"g"===i){if(a.data.length<2)return void console.error(`Invalid assignment to ${i} for variable ${r}. Line ${e.line}`);n.data[1]=a.data[s]}else if("z"===i||"b"===i){if(a.data.length<3)return void console.error(`Invalid assignment to ${i} for variable ${r}. Line ${e.line}`);n.data[2]=a.data[s]}else{if("w"!==i&&"a"!==i||a.data.length<4)return void console.error(`Invalid assignment to ${i} for variable ${r}. Line ${e.line}`);n.data[3]=a.data[s]}}}}}else n instanceof eU&&a instanceof eU?n.value=a.value:n instanceof eP&&a instanceof eP||n instanceof eW&&a 
1instanceof eW?n.data.set(a.data):console.error(`Invalid assignment to ${r}. Line ${e.line}`)}_function(e,t){let n=new te(e);t.functions.set(e.name,n)}_const(e,t){let n=null;null!==e.value&&(n=this.evalExpression(e.value,t)),t.createVariable(e.name,n,e)}_let(e,t){let n=null;if(null!==e.value){if(null===(n=this.evalExpression(e.value,t)))return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof eS||(n=n.clone())}else{let r=e.type.name;if("f32"===r||"i32"===r||"u32"===r||"bool"===r||"f16"===r||"vec2"===r||"vec3"===r||"vec4"===r||"vec2f"===r||"vec3f"===r||"vec4f"===r||"vec2i"===r||"vec3i"===r||"vec4i"===r||"vec2u"===r||"vec3u"===r||"vec4u"===r||"vec2h"===r||"vec3h"===r||"vec4h"===r||"vec2b"===r||"vec3b"===r||"vec4b"===r||"mat2x2"===r||"mat2x3"===r||"mat2x4"===r||"mat3x2"===r||"mat3x3"===r||"mat3x4"===r||"mat4x2"===r||"mat4x3"===r||"mat4x4"===r||"mat2x2f"===r||"mat2x3f"===r||"mat2x4f"===r||"mat3x2f"===r||"mat3x3f"===r||"mat3x4f"===r||"mat4x2f"===r||"mat4x3f"===r||"mat4x4f"===r||"mat2x2h"===r||"mat2x3h"===r||"mat2x4h"===r||"mat3x2h"===r||"mat3x3h"===r||"mat3x4h"===r||"mat4x2h"===r||"mat4x3h"===r||"mat4x4h"===r||"array"===r){let r=new ex(e.type,[]);n=this._evalCreate(r,t)}}t.createVariable(e.name,n,e)}_var(e,t){let n=null;if(null!==e.value){if(null===(n=this.evalExpression(e.value,t)))return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof eS||(n=n.clone())}else{if(null===e.type)return void console.error(`Variable ${e.name} has no type. Line ${e.line}`);let r=e.type.name;if("f32"===r||"i32"===r||"u32"===r||"bool"===r||"f16"===r||"vec2"===r||"vec3"===r||"vec4"===r||"vec2f"===r||"vec3f"===r||"vec4f"===r||"vec2i"===r||"vec3i"===r||"vec4i"===r||"vec2u"===r||"vec3u"===r||"vec4u"===r||"vec2h"===r||"vec3h"===r||"vec4h"===r||"vec2b"===r||"vec3b"===r||"vec4b"===r||"mat2x2"===r||"mat2x3"===r||"mat2x4"===r||"mat3x2"===r||"mat3x3"===r||"mat3x4"===r||"mat4x2"===r||"mat4x3"===r||"mat4x4"===r||"mat2x2f"===r||"mat2x3f"===r||"mat2x4f"===r||"mat3x2f"===r||"mat3x3f"===r||"mat3x4f"===r||"mat4x2f"===r||"mat4x3f"===r||"mat4x4f"===r||"mat2x2h"===r||"mat2x3h"===r||"mat2x4h"===r||"mat3x2h"===r||"mat3x3h"===r||"mat3x4h"===r||"mat4x2h"===r||"mat4x3h"===r||"mat4x4h"===r||e.type instanceof ed||e.type instanceof eh||e.type instanceof ef){let r=new ex(e.type,[]);n=this._evalCreate(r,t)}}t.createVariable(e.name,n,e)}_switch(e,t){t=t.clone();let n=this.evalExpression(e.condition,t);if(!(n instanceof eU))return console.error(`Invalid if condition. Line ${e.line}`),null;let r=null;for(let s of e.cases)if(s instanceof eL)for(let a of s.selectors){if(a instanceof e$){r=s;continue}let i=this.evalExpression(a,t);if(!(i instanceof eU))return console.error(`Invalid case selector. Line ${e.line}`),null;if(i.value===n.value)return this._execStatements(s.body,t)}else s instanceof eD&&(r=s);return r?this._execStatements(r.body,t):null}_if(e,t){t=t.clone();let n=this.evalExpression(e.condition,t);if(!(n instanceof eU))return console.error(`Invalid if condition. Line ${e.line}`),null;if(n.value)return this._execStatements(e.body,t);for(let n of e.elseif){let r=this.evalExpression(n.condition,t);if(!(r instanceof eU))return console.error(`Invalid if condition. Line ${e.line}`),null;if(r.value)return this._execStatements(n.body,t)}return e.else?this._execStatements(e.else,t):null}_getScalarValue(e){return e instanceof eU?e.value:(console.error("Expected scalar value.",e),0)}_for(e,t){for(t=t.clone(),this.execStatement(e.init,t);this._getScalarValue(this.evalExpression(e.condition,t));){let n=this._execStatements(e.body,t);if(n===ti._breakObj)break;if(null!==n&&n!==ti._continueObj)return n;this.execStatement(e.increment,t)}return null}_loop(e,t){for(t=t.clone();;){let n=this._execStatements(e.body,t);if(n===ti._breakObj)break;if(n===ti._continueObj){if(e.continuing&&this._execStatements(e.continuing.body,t)===ti._breakObj)break}else if(null!==n)return n}return null}_while(e,t){for(t=t.clone();this._getScalarValue(this.evalExpression(e.condition,t));){let n=this._execStatements(e.body,t);if(n===ti._breakObj)break;if(n!==ti._continueObj&&null!==n)return n}return null}_evalBitcast(e,t){let n=this.evalExpression(e.value,t),r=e.type;
1if(n instanceof eU)return new eU(e0(n.value,n.typeInfo.name,r.name),this.getTypeInfo(r));if(n instanceof eP){let t=n.typeInfo.getTypeName(),s="";if(t.endsWith("f"))s="f32";else if(t.endsWith("i"))s="i32";else if(t.endsWith("u"))s="u32";else if(t.endsWith("b"))s="bool";else{if(!t.endsWith("h"))return console.error(`Unknown vector type ${t}. Line ${e.line}`),null;s="f16"}let a=r.getTypeName(),i="";if(a.endsWith("f"))i="f32";else if(a.endsWith("i"))i="i32";else if(a.endsWith("u"))i="u32";else if(a.endsWith("b"))i="bool";else{if(!a.endsWith("h"))return console.error(`Unknown vector type ${i}. Line ${e.line}`),null;i="f16"}return new eP(function(e,t,n){if(t===n)return e;let r=Array(e.length);for(let s=0;s<e.length;s++)r[s]=e0(e[s],t,n);return r}(Array.from(n.data),s,i),this.getTypeInfo(r))}return console.error(`TODO: bitcast for ${n.typeInfo.name}. Line ${e.line}`),null}_evalConst(e,t){return t.getVariableValue(e.name).clone().getSubData(this,e.postfix,t)}_evalCreate(e,t){var n;if(e instanceof ex){if(null===e.type)return eF.void;switch(e.type.getTypeName()){case"bool":case"i32":case"u32":case"f32":case"f16":return this._callConstructorValue(e,t);case"vec2":case"vec3":case"vec4":case"vec2f":case"vec3f":case"vec4f":case"vec2h":case"vec3h":case"vec4h":case"vec2i":case"vec3i":case"vec4i":case"vec2u":case"vec3u":case"vec4u":case"vec2b":case"vec3b":case"vec4b":return this._callConstructorVec(e,t);case"mat2x2":case"mat2x2f":case"mat2x2h":case"mat2x3":case"mat2x3f":case"mat2x3h":case"mat2x4":case"mat2x4f":case"mat2x4h":case"mat3x2":case"mat3x2f":case"mat3x2h":case"mat3x3":case"mat3x3f":case"mat3x3h":case"mat3x4":case"mat3x4f":case"mat3x4h":case"mat4x2":case"mat4x2f":case"mat4x2h":case"mat4x3":case"mat4x3f":case"mat4x3h":case"mat4x4":case"mat4x4f":case"mat4x4h":return this._callConstructorMatrix(e,t)}}let r=e instanceof ex?e.type.name:e.name,s=e instanceof ex?this.getTypeInfo(e.type):this.getTypeInfo(e.name);if(null===s)return console.error(`Unknown type ${r}. Line ${e.line}`),null;if(0===s.size)return null;let a=new eq(new ArrayBuffer(s.size),s,0);if(s instanceof d){if(e.args)for(let n=0;n<e.args.length;++n){let r=s.members[n],i=e.args[n],o=this.evalExpression(i,t);a.setData(this,o,r.type,r.offset,t)}}else if(s instanceof m){let r=0;if(e.args)for(let i=0;i<e.args.length;++i){let o=e.args[i],l=this.evalExpression(o,t);null===s.format&&("x32"===(null===(n=l.typeInfo)||void 0===n?void 0:n.name)?s.format=this.getTypeInfo("i32"):s.format=l.typeInfo),a.setData(this,l,s.format,r,t),r+=s.stride}}else console.error(`Unknown type "${r}". Line ${e.line}`);return e instanceof ex?a.getSubData(this,e.postfix,t):a}_evalLiteral(e,t){let n=this.getTypeInfo(e.type),r=n.name;return"x32"===r||"u32"===r||"f32"===r||"f16"===r||"i32"===r||"bool"===r?new eU(e.scalarValue,n):"vec2"===r||"vec3"===r||"vec4"===r||"vec2f"===r||"vec3f"===r||"vec4f"===r||"vec2h"===r||"vec3h"===r||"vec4h"===r||"vec2i"===r||"vec3i"===r||"vec4i"===r||"vec2u"===r||"vec3u"===r||"vec4u"===r?this._callConstructorVec(e,t):"mat2x2"===r||"mat2x3"===r||"mat2x4"===r||"mat3x2"===r||"mat3x3"===r||"mat3x4"===r||"mat4x2"===r||"mat4x3"===r||"mat4x4"===r||"mat2x2f"===r||"mat2x3f"===r||"mat2x4f"===r||"mat3x2f"===r||"mat3x3f"===r||"mat3x4f"===r||"mat4x2f"===r||"mat4x3f"===r||"mat4x4f"===r||"mat2x2h"===r||"mat2x3h"===r||"mat2x4h"===r||"mat3x2h"===r||"mat3x3h"===r||"mat3x4h"===r||"mat4x2h"===r||"mat4x3h"===r||"mat4x4h"===r?this._callConstructorMatrix(e,t):e.value}_evalVariable(e,t){let n=t.getVariableValue(e.name);return null===n?n:n.getSubData(this,e.postfix,t)}_maxFormatTypeInfo(e){let t=e[0];if("f32"===t.name)return t;for(let n=1;n<e.length;++n){let r=ti._priority.get(t.name);ti._priority.get(e[n].name)<r&&(t=e[n])}return"x32"===t.name?this.getTypeInfo("i32"):t}_evalUnaryOp(e,t){let n=this.evalExpression(e.right,t);if("&"===e.operator)return new eM(n);if("*"===e.operator)return n instanceof eM?n.reference.getSubData(this,e.postfix,t):(console.error(`Invalid dereference. Line ${e.line}`),null);let r=n instanceof eU?n.value:n instanceof eP?Array.from(n.data):null;switch(e.operator){case"+":if(ej(r))return new eP(r.map((e,t)=>+e),n.typeInfo);return new eU(+r,this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]));case"-":if(ej(r))return new eP(r.map((e,t)=>-e),n.typeInfo);return new eU(-r,this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]));case"!":if(ej(r))return new eP(r.map((e,t)=>e?0:1),n.typeInfo);return new eU(r?0:1,this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]));case"~":if(ej(r))return new eP(r.map((e,t)=>~e),n.typeInfo);return new eU(~r,this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]))}return console.error(`Invalid unary operator ${e.operator}. Line ${e.line}`),null}_evalBinaryOp(e,t){let n=this.evalExpression(e.left,t),r=this.evalExpression(e.right,t),s=n instanceof eU?n.value:n instanceof eP||n instanceof eW?Array.from(n.data):null,a=r instanceof eU?r.value:r instanceof eP||r instanceof eW?Array.from(r.data):null;
1switch(e.operator){case"+":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e+a[t]),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e+a),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s+e),r.typeInfo);return new eU(s+a,this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]));case"-":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e-a[t]),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e-a),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s-e),r.typeInfo);return new eU(s-a,this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]));case"*":if(ej(s)&&ej(a)){if(n instanceof eW&&r instanceof eW){let t=function(e,t,n,r){if(void 0===ta[t.name]||void 0===ta[r.name])return null;let s=ta[t.name][0],a=ta[t.name][1],i=ta[r.name][0];if(s!==ta[r.name][1])return null;let o=Array(i*a);for(let t=0;t<a;t++)for(let r=0;r<i;r++){let l=0;for(let i=0;i<s;i++)l+=e[i*a+t]*n[r*s+i];o[t*i+r]=l}return o}(s,n.typeInfo,a,r.typeInfo);if(null===t)return console.error(`Matrix multiplication failed. Line ${e.line}.`),null;let i=ta[r.typeInfo.name][0],o=ta[n.typeInfo.name][1];return new eW(t,this.getTypeInfo(`mat${i}x${o}f`))}if(n instanceof eW&&r instanceof eP){let t=function(e,t,n,r){if(void 0===ta[t.name]||void 0===ts[r.name])return null;let s=ta[t.name][0],a=ta[t.name][1];if(s!==n.length)return null;let i=Array(a);for(let t=0;t<a;t++){let r=0;for(let i=0;i<s;i++)r+=e[i*a+t]*n[i];i[t]=r}return i}(s,n.typeInfo,a,r.typeInfo);return null===t?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new eP(t,r.typeInfo)}if(n instanceof eP&&r instanceof eW){let t=function(e,t,n,r){if(void 0===ts[t.name]||void 0===ta[r.name])return null;let s=ta[r.name][0],a=ta[r.name][1];if(a!==e.length)return null;let i=[];for(let t=0;t<s;t++){let r=0;for(let i=0;i<a;i++)r+=e[i]*n[i*s+t];i[t]=r}return i}(s,n.typeInfo,a,r.typeInfo);return null===t?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new eP(t,n.typeInfo)}if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e*a[t]),n.typeInfo)}if(ej(s)){let e=s.map((e,t)=>e*a);return n instanceof eW?new eW(e,n.typeInfo):new eP(e,n.typeInfo)}if(ej(a)){let e=a.map((e,t)=>s*e);return r instanceof eW?new eW(e,r.typeInfo):new eP(e,r.typeInfo)}return new eU(s*a,this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]));case"%":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e%a[t]),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e%a),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s%e),r.typeInfo);return new eU(s%a,this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]));case"/":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e/a[t]),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e/a),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s/e),r.typeInfo);return new eU(s/a,this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]));case"&":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e&a[t]),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e&a),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s&e),r.typeInfo);return new eU(s&a,this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]));case"|":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e|a[t]),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e|a),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s|e),r.typeInfo);return new eU(s|a,this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]));case"^":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e^a[t]),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e^a),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s^e),r.typeInfo);return new eU(s^a,this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]));
1case"<<":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e<<a[t]),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e<<a),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s<<e),r.typeInfo);return new eU(s<<a,this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]));case">>":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e>>a[t]),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e>>a),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s>>e),r.typeInfo);return new eU(s>>a,this._maxFormatTypeInfo([n.typeInfo,r.typeInfo]));case">":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e>a[t]?1:0),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e>a?1:0),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s>e?1:0),r.typeInfo);return new eU(s>a?1:0,this.getTypeInfo("bool"));case"<":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e<a[t]?1:0),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e<a?1:0),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s<e?1:0),r.typeInfo);return new eU(s<a?1:0,this.getTypeInfo("bool"));case"==":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e===a[t]?1:0),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e==a?1:0),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s==e?1:0),r.typeInfo);return new eU(s===a?1:0,this.getTypeInfo("bool"));case"!=":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e!==a[t]?1:0),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e!==a?1:0),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s!==e?1:0),r.typeInfo);return new eU(s!==a?1:0,this.getTypeInfo("bool"));case">=":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e>=a[t]?1:0),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e>=a?1:0),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s>=e?1:0),r.typeInfo);return new eU(s>=a?1:0,this.getTypeInfo("bool"));case"<=":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e<=a[t]?1:0),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e<=a?1:0),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s<=e?1:0),r.typeInfo);return new eU(s<=a?1:0,this.getTypeInfo("bool"));case"&&":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e&&a[t]?1:0),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e&&a?1:0),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s&&e?1:0),r.typeInfo);return new eU(s&&a?1:0,this.getTypeInfo("bool"));case"||":if(ej(s)&&ej(a)){if(s.length!==a.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;return new eP(s.map((e,t)=>e||a[t]?1:0),n.typeInfo)}if(ej(s))return new eP(s.map((e,t)=>e||a?1:0),n.typeInfo);if(ej(a))return new eP(a.map((e,t)=>s||e?1:0),r.typeInfo);return new eU(s||a?1:0,this.getTypeInfo("bool"))}return console.error(`Unknown operator ${e.operator}. Line ${e.line}`),null}_evalCall(e,t){if(null!==e.cachedReturnValue)return e.cachedReturnValue;let n=t.clone();n.currentFunctionName=e.name;let r=t.getFunction(e.name);
1if(!r)return e.isBuiltin?this._callBuiltinFunction(e,n):this.getTypeInfo(e.name)?this._evalCreate(e,t):(console.error(`Unknown function "${e.name}". Line ${e.line}`),null);for(let t=0;t<r.node.args.length;++t){let s=r.node.args[t],a=this.evalExpression(e.args[t],n);n.createVariable(s.name,a,s)}return this._execStatements(r.node.body,n)}_callBuiltinFunction(e,t){switch(e.name){case"all":return this.builtins.All(e,t);case"any":return this.builtins.Any(e,t);case"select":return this.builtins.Select(e,t);case"arrayLength":return this.builtins.ArrayLength(e,t);case"abs":return this.builtins.Abs(e,t);case"acos":return this.builtins.Acos(e,t);case"acosh":return this.builtins.Acosh(e,t);case"asin":return this.builtins.Asin(e,t);case"asinh":return this.builtins.Asinh(e,t);case"atan":return this.builtins.Atan(e,t);case"atanh":return this.builtins.Atanh(e,t);case"atan2":return this.builtins.Atan2(e,t);case"ceil":return this.builtins.Ceil(e,t);case"clamp":return this.builtins.Clamp(e,t);case"cos":return this.builtins.Cos(e,t);case"cosh":return this.builtins.Cosh(e,t);case"countLeadingZeros":return this.builtins.CountLeadingZeros(e,t);case"countOneBits":return this.builtins.CountOneBits(e,t);case"countTrailingZeros":return this.builtins.CountTrailingZeros(e,t);case"cross":return this.builtins.Cross(e,t);case"degrees":return this.builtins.Degrees(e,t);case"determinant":return this.builtins.Determinant(e,t);case"distance":return this.builtins.Distance(e,t);case"dot":return this.builtins.Dot(e,t);case"dot4U8Packed":return this.builtins.Dot4U8Packed(e,t);case"dot4I8Packed":return this.builtins.Dot4I8Packed(e,t);case"exp":return this.builtins.Exp(e,t);case"exp2":return this.builtins.Exp2(e,t);case"extractBits":return this.builtins.ExtractBits(e,t);case"faceForward":return this.builtins.FaceForward(e,t);case"firstLeadingBit":return this.builtins.FirstLeadingBit(e,t);case"firstTrailingBit":return this.builtins.FirstTrailingBit(e,t);case"floor":return this.builtins.Floor(e,t);case"fma":return this.builtins.Fma(e,t);case"fract":return this.builtins.Fract(e,t);case"frexp":return this.builtins.Frexp(e,t);case"insertBits":return this.builtins.InsertBits(e,t);case"inverseSqrt":return this.builtins.InverseSqrt(e,t);case"ldexp":return this.builtins.Ldexp(e,t);case"length":return this.builtins.Length(e,t);case"log":return this.builtins.Log(e,t);case"log2":return this.builtins.Log2(e,t);case"max":return this.builtins.Max(e,t);case"min":return this.builtins.Min(e,t);case"mix":return this.builtins.Mix(e,t);case"modf":return this.builtins.Modf(e,t);case"normalize":return this.builtins.Normalize(e,t);case"pow":return this.builtins.Pow(e,t);case"quantizeToF16":return this.builtins.QuantizeToF16(e,t);case"radians":return this.builtins.Radians(e,t);case"reflect":return this.builtins.Reflect(e,t);case"refract":return this.builtins.Refract(e,t);case"reverseBits":return this.builtins.ReverseBits(e,t);case"round":return this.builtins.Round(e,t);case"saturate":return this.builtins.Saturate(e,t);case"sign":return this.builtins.Sign(e,t);case"sin":return this.builtins.Sin(e,t);case"sinh":return this.builtins.Sinh(e,t);case"smoothstep":return this.builtins.SmoothStep(e,t);case"sqrt":return this.builtins.Sqrt(e,t);case"step":return this.builtins.Step(e,t);case"tan":return this.builtins.Tan(e,t);case"tanh":return this.builtins.Tanh(e,t);case"transpose":return this.builtins.Transpose(e,t);case"trunc":return this.builtins.Trunc(e,t);case"dpdx":return this.builtins.Dpdx(e,t);case"dpdxCoarse":return this.builtins.DpdxCoarse(e,t);case"dpdxFine":return this.builtins.DpdxFine(e,t);case"dpdy":return this.builtins.Dpdy(e,t);case"dpdyCoarse":return this.builtins.DpdyCoarse(e,t);case"dpdyFine":return this.builtins.DpdyFine(e,t);case"fwidth":return this.builtins.Fwidth(e,t);case"fwidthCoarse":return this.builtins.FwidthCoarse(e,t);case"fwidthFine":return this.builtins.FwidthFine(e,t);case"textureDimensions":return this.builtins.TextureDimensions(e,t);case"textureGather":return this.builtins.TextureGather(e,t);case"textureGatherCompare":return this.builtins.TextureGatherCompare(e,t);case"textureLoad":return this.builtins.TextureLoad(e,t);case"textureNumLayers":return this.builtins.TextureNumLayers(e,t);case"textureNumLevels":return this.builtins.TextureNumLevels(e,t);case"textureNumSamples":return this.builtins.TextureNumSamples(e,t);case"textureSample":return this.builtins.TextureSample(e,t);case"textureSampleBias":return this.builtins.TextureSampleBias(e,t);case"textureSampleCompare":return this.builtins.TextureSampleCompare(e,t);case"textureSampleCompareLevel":return this.builtins.TextureSampleCompareLevel(e,t);case"textureSampleGrad":return this.builtins.TextureSampleGrad(e,t);case"textureSampleLevel":return this.builtins.TextureSampleLevel(e,t);case"textureSampleBaseClampToEdge":return this.builtins.TextureSampleBaseClampToEdge(e,t);case"textureStore":return this.builtins.TextureStore(e,t);case"atomicLoad":return this.builtins.AtomicLoad(e,t);case"atomicStore":return this.builtins.AtomicStore(e,t);case"atomicAdd":return this.builtins.AtomicAdd(e,t);case"atomicSub":return this.builtins.AtomicSub(e,t);case"atomicMax":return this.builtins.AtomicMax(e,t);case"atomicMin":return this.builtins.AtomicMin(e,t);case"atomicAnd":return this.builtins.AtomicAnd(e,t);case"atomicOr":return this.builtins.AtomicOr(e,t);case"atomicXor":return this.builtins.AtomicXor(e,t);case"atomicExchange":return this.builtins.AtomicExchange(e,t);case"atomicCompareExchangeWeak":return this.builtins.AtomicCompareExchangeWeak(e,t);case"pack4x8snorm":return this.builtins.Pack4x8snorm(e,t);case"pack4x8unorm":return this.builtins.Pack4x8unorm(e,t);case"pack4xI8":return this.builtins.Pack4xI8(e,t);case"pack4xU8":return this.builtins.Pack4xU8(e,t);case"pack4x8Clamp":return this.builtins.Pack4x8Clamp(e,t);case"pack4xU8Clamp":return this.builtins.Pack4xU8Clamp(e,t);case"pack2x16snorm":return this.builtins.Pack2x16snorm(e,t);case"pack2x16unorm":return this.builtins.Pack2x16unorm(e,t);case"pack2x16float":return this.builtins.Pack2x16float(e,t);case"unpack4x8snorm":return this.builtins.Unpack4x8snorm(e,t);case"unpack4x8unorm":return this.builtins.Unpack4x8unorm(e,t);case"unpack4xI8":return this.builtins.Unpack4xI8(e,t);case"unpack4xU8":return this.builtins.Unpack4xU8(e,t);case"unpack2x16snorm":return this.builtins.Unpack2x16snorm(e,t);case"unpack2x16unorm":return this.builtins.Unpack2x16unorm(e,t);case"unpack2x16float":return this.builtins.Unpack2x16float(e,t);case"storageBarrier":return this.builtins.StorageBarrier(e,t);case"textureBarrier":return this.builtins.TextureBarrier(e,t);case"workgroupBarrier":return this.builtins.WorkgroupBarrier(e,t);case"workgroupUniformLoad":return this.builtins.WorkgroupUniformLoad(e,t);case"subgroupAdd":return this.builtins.SubgroupAdd(e,t);case"subgroupExclusiveAdd":return this.builtins.SubgroupExclusiveAdd(e,t);case"subgroupInclusiveAdd":return this.builtins.SubgroupInclusiveAdd(e,t);case"subgroupAll":return this.builtins.SubgroupAll(e,t);case"subgroupAnd":return this.builtins.SubgroupAnd(e,t);case"subgroupAny":return this.builtins.SubgroupAny(e,t);case"subgroupBallot":return this.builtins.SubgroupBallot(e,t);case"subgroupBroadcast":return this.builtins.SubgroupBroadcast(e,t);case"subgroupBroadcastFirst":return this.builtins.SubgroupBroadcastFirst(e,t);case"subgroupElect":return this.builtins.SubgroupElect(e,t);case"subgroupMax":return this.builtins.SubgroupMax(e,t);case"subgroupMin":return this.builtins.SubgroupMin(e,t);case"subgroupMul":return this.builtins.SubgroupMul(e,t);case"subgroupExclusiveMul":return this.builtins.SubgroupExclusiveMul(e,t);case"subgroupInclusiveMul":return this.builtins.SubgroupInclusiveMul(e,t);case"subgroupOr":return this.builtins.SubgroupOr(e,t);case"subgroupShuffle":return this.builtins.SubgroupShuffle(e,t);case"subgroupShuffleDown":return this.builtins.SubgroupShuffleDown(e,t);case"subgroupShuffleUp":return this.builtins.SubgroupShuffleUp(e,t);case"subgroupShuffleXor":return this.builtins.SubgroupShuffleXor(e,t);case"subgroupXor":return this.builtins.SubgroupXor(e,t);case"quadBroadcast":return this.builtins.QuadBroadcast(e,t);case"quadSwapDiagonal":return this.builtins.QuadSwapDiagonal(e,t);case"quadSwapX":return this.builtins.QuadSwapX(e,t);case"quadSwapY":return this.builtins.QuadSwapY(e,t)}let n=t.getFunction(e.name);if(n){let r=t.clone();for(let t=0;t<n.node.args.length;++t){let s=n.node.args[t],a=this.evalExpression(e.args[t],r);r.setVariable(s.name,a,s)}return this._execStatements(n.node.body,r)}return null}_callConstructorValue(e,t){if(!e.args||0===e.args.length)return new eU(0,this.getTypeInfo(e.type));let n=this.evalExpression(e.args[0],t);return n.typeInfo=this.getTypeInfo(e.type),n.getSubData(this,e.postfix,t).clone()}_callConstructorVec(e,t){let n=this.getTypeInfo(e.type),r=e.type.getTypeName(),s=ts[r];if(void 0===s)return console.error(`Invalid vec constructor ${r}. Line ${e.line}`),null;let a=[];if(e instanceof ew){if(e.isVector)for(let t of e.vectorValue)a.push(t);else a.push(e.scalarValue)}else if(e.args)for(let n of e.args){let e=this.evalExpression(n,t);if(e instanceof eP){let t=e.data;for(let e=0;e<t.length;++e){let n=t[e];a.push(n)}}else if(e instanceof eU){let t=e.value;a.push(t)}}if(e.type instanceof ef&&null===e.type.format&&(e.type.format=ef.f32),0===a.length)return new eP(Array(s).fill(0),n).getSubData(this,e.postfix,t);if(1===a.length)for(;a.length<s;)a.push(a[0]);return a.length<s?(console.error(`Invalid vec constructor. Line ${e.line}`),null):new eP(a.length>s?a.slice(0,s):a,n).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){let n=this.getTypeInfo(e.type),r=e.type.getTypeName(),s=ta[r];if(void 0===s)return console.error(`Invalid matrix constructor ${r}. Line ${e.line}`),null;let a=[];if(e instanceof ew){if(e.isVector)for(let t of e.vectorValue)a.push(t);else a.push(e.scalarValue)}else if(e.args)for(let n of e.args){let e=this.evalExpression(n,t);e instanceof eP?a.push(...e.data):e instanceof eU?a.push(e.value):e instanceof eW&&a.push(...e.data)}return(n instanceof _&&null===n.format&&(n.format=this.getTypeInfo("f32")),0===a.length)?new eW(Array(s[2]).fill(0),n).getSubData(this,e.postfix,t):a.length!==s[2]?(console.error(`Invalid matrix constructor. Line ${e.line}`),null):new eW(a,n).getSubData(this,e.postfix,t)}}ti._breakObj=new eC(new f("BREAK",null),null),ti._continueObj=new eC(new f("CONTINUE",null),null),ti._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class to{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class tl{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new to,this._exec=new ti,this._forwardTypeCount=0}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;let t=[];for(;!this._isAtEnd();){let e=this._global_decl_or_directive();if(!e)break;t.push(e)}if(this._deferArrayCountEval.length>0){for(let e of this._deferArrayCountEval){let t=e.arrayType,n=e.countNode;if(n instanceof eb){let e=n.name,r=this._context.constants.get(e);if(r)try{let e=r.constEvaluate(this._exec);t.count=e}catch(e){}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(let e of t)e.search(e=>{e instanceof eB||e instanceof ep?e.type=this._forwardType(e.type):e instanceof ed?e.format=this._forwardType(e.format):e instanceof G||e instanceof X||e instanceof j?e.type=this._forwardType(e.type):e instanceof P?e.returnType=this._forwardType(e.returnType):e instanceof eO&&(e.type=this._forwardType(e.type))});return t}_forwardType(e){if(e instanceof ec){let t=this._getType(e.name);if(t)return t}else e instanceof ep?e.type=this._forwardType(e.type):e instanceof ed&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e){if("string"==typeof e){let t=new eX(e);this._tokens=t.scanTokens()}else this._tokens=e}else this._tokens=[];this._current=0}_updateNode(e,t){return e.line=null!=t?t:this._currentLine,e}_error(e,t){return{token:e,message:t,toString:()=>`${t}`}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==eG.eof}_match(e){if(e instanceof ez)return!!this._check(e)&&(this._advance(),!0);for(let t=0,n=e.length;t<n;++t){let n=e[t];if(this._check(n))return this._advance(),!0}return!1}_consume(e,t){if(this._check(e))return this._advance();throw this._error(this._peek(),`${t}. Line:${this._currentLine}`)}_check(e){if(this._isAtEnd())return!1;let t=this._peek();if(e instanceof Array){let n=t.type,r=!1;for(let t of e){if(n===t)return!0;t===eG.tokens.name&&(r=!0)}if(r){let e=eG.tokens.name.rule.exec(t.lexeme);if(e&&0==e.index&&e[0]==t.lexeme)return!0}return!1}if(t.type===e)return!0;
1if(e===eG.tokens.name){let e=eG.tokens.name.rule.exec(t.lexeme);return e&&0==e.index&&e[0]==t.lexeme}return!1}_advance(){var e,t;return this._currentLine=null!==(t=null===(e=this._peek())||void 0===e?void 0:e.line)&&void 0!==t?t:-1,this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(eG.tokens.semicolon)&&!this._isAtEnd(););if(this._match(eG.keywords.alias)){let e=this._type_alias();return this._consume(eG.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([e]),e}if(this._match(eG.keywords.diagnostic)){let e=this._diagnostic();return this._consume(eG.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([e]),e}if(this._match(eG.keywords.requires)){let e=this._requires_directive();return this._consume(eG.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([e]),e}if(this._match(eG.keywords.enable)){let e=this._enable_directive();return this._consume(eG.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([e]),e}let e=this._attribute();if(this._check(eG.keywords.var)){let t=this._global_variable_decl();return null!=t&&(t.attributes=e),this._consume(eG.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(eG.keywords.override)){let t=this._override_variable_decl();return null!=t&&(t.attributes=e),this._consume(eG.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(eG.keywords.let)){let t=this._global_let_decl();return null!=t&&(t.attributes=e),this._consume(eG.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(eG.keywords.const)){let t=this._global_const_decl();return null!=t&&(t.attributes=e),this._consume(eG.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(eG.keywords.struct)){let t=this._struct_decl();return null!=t&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}if(this._check(eG.keywords.fn)){let t=this._function_decl();return null!=t&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}return null}_function_decl(){if(!this._match(eG.keywords.fn))return null;let e=this._currentLine,t=this._consume(eG.tokens.ident,"Expected function name.").toString();this._consume(eG.tokens.paren_left,"Expected '(' for function arguments.");let n=[];if(!this._check(eG.tokens.paren_right))do{if(this._check(eG.tokens.paren_right))break;let e=this._attribute(),t=this._consume(eG.tokens.name,"Expected argument name.").toString();this._consume(eG.tokens.colon,"Expected ':' for argument type.");let r=this._attribute(),s=this._type_decl();null!=s&&(s.attributes=r,n.push(this._updateNode(new eO(t,s,e))))}while(this._match(eG.tokens.comma));this._consume(eG.tokens.paren_right,"Expected ')' after function arguments.");let r=null;if(this._match(eG.tokens.arrow)){let e=this._attribute();null!=(r=this._type_decl())&&(r.attributes=e)}let s=this._compound_statement(),a=this._currentLine;return this._updateNode(new P(t,n,r,s,e,a),e)}_compound_statement(){let e=[];for(this._consume(eG.tokens.brace_left,"Expected '{' for block.");!this._check(eG.tokens.brace_right);){let t=this._statement();null!==t&&e.push(t)}return this._consume(eG.tokens.brace_right,"Expected '}' for block."),e}_statement(){for(;this._match(eG.tokens.semicolon)&&!this._isAtEnd(););if(this._check(eG.tokens.attr)&&this._attribute(),this._check(eG.keywords.if))return this._if_statement();if(this._check(eG.keywords.switch))return this._switch_statement();if(this._check(eG.keywords.loop))return this._loop_statement();if(this._check(eG.keywords.for))return this._for_statement();if(this._check(eG.keywords.while))return this._while_statement();if(this._check(eG.keywords.continuing))return this._continuing_statement();if(this._check(eG.keywords.static_assert))return this._static_assert_statement();if(this._check(eG.tokens.brace_left))return this._compound_statement();let e=null;if(this._check(eG.keywords.return))e=this._return_statement();else if(this._check([eG.keywords.var,eG.keywords.let,eG.keywords.const]))e=this._variable_statement
1();else if(this._match(eG.keywords.discard))e=this._updateNode(new ei);else if(this._match(eG.keywords.break)){let t=this._updateNode(new eo);if(this._currentLoop.length>0){let e=this._currentLoop[this._currentLoop.length-1];t.loopId=e.id}e=t,this._check(eG.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match(eG.keywords.continue)){let t=this._updateNode(new el);if(!(this._currentLoop.length>0))throw this._error(this._peek(),`Continue statement must be inside a loop. Line: ${t.line}`);{let e=this._currentLoop[this._currentLoop.length-1];t.loopId=e.id}e=t}else e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement();return null!=e&&this._consume(eG.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match(eG.keywords.static_assert))return null;let e=this._currentLine,t=this._optional_paren_expression();return this._updateNode(new W(t),e)}_while_statement(){if(!this._match(eG.keywords.while))return null;let e=this._updateNode(new q(null,null));return this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(eG.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_continuing_statement(){let e=this._currentLoop.length>0?this._currentLoop[this._currentLoop.length-1].id:-1;if(!this._match(eG.keywords.continuing))return null;let t=this._currentLine,n=this._compound_statement();return this._updateNode(new H(n,e),t)}_for_statement(){if(!this._match(eG.keywords.for))return null;this._consume(eG.tokens.paren_left,"Expected '('.");let e=this._updateNode(new z(null,null,null,null));return this._currentLoop.push(e),e.init=this._check(eG.tokens.semicolon)?null:this._for_init(),this._consume(eG.tokens.semicolon,"Expected ';'."),e.condition=this._check(eG.tokens.semicolon)?null:this._short_circuit_or_expression(),this._consume(eG.tokens.semicolon,"Expected ';'."),e.increment=this._check(eG.tokens.paren_right)?null:this._for_increment(),this._consume(eG.tokens.paren_right,"Expected ')'."),this._check(eG.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(eG.keywords.var)){let e=this._variable_decl();if(null===e)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match(eG.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new G(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match(eG.keywords.let)){let e=this._currentLine,t=this._consume(eG.tokens.name,"Expected name for let.").toString(),n=null;if(this._match(eG.tokens.colon)){let e=this._attribute();null!=(n=this._type_decl())&&(n.attributes=e)}this._consume(eG.tokens.equal,"Expected '=' for let.");let r=this._short_circuit_or_expression();return this._updateNode(new X(t,n,null,null,r),e)}if(this._match(eG.keywords.const)){let e=this._currentLine,t=this._consume(eG.tokens.name,"Expected name for const.").toString(),n=null;if(this._match(eG.tokens.colon)){let e=this._attribute();null!=(n=this._type_decl())&&(n.attributes=e)}this._consume(eG.tokens.equal,"Expected '=' for const.");let r=this._short_circuit_or_expression();return null===n&&r instanceof ew&&(n=r.type),this._updateNode(new j(t,n,null,null,r),e)}return null}_increment_decrement_statement(){let e=this._current,t=this._unary_expression();if(null==t)return null;if(!this._check(eG.increment_operators))return this._current=e,null;let n=this._consume(eG.increment_operators,"Expected increment operator");return this._updateNode(new Z(n.type===eG.tokens.plus_plus?s.increment:s.decrement,t))}_assignment_statement(){let e=null,t=this._currentLine;if(this._check(eG.tokens.brace_right))return null;let n=this._match(eG.tokens.underscore);if(n||(e=this._unary_expression()),!n&&null==e)return null;let r=this._consume(eG.assignment_operators,"Expected assignment operator."),s=this._short_circuit_or_expression();return this._updateNode(new Q(a.parse(r.lexeme),e,s),t)}
1_func_call_statement(){if(!this._check(eG.tokens.ident))return null;let e=this._currentLine,t=this._current,n=this._consume(eG.tokens.ident,"Expected function name."),r=this._argument_expression_list();return null===r?(this._current=t,null):this._updateNode(new Y(n.lexeme,r),e)}_loop_statement(){if(!this._match(eG.keywords.loop))return null;this._check(eG.tokens.attr)&&this._attribute(),this._consume(eG.tokens.brace_left,"Expected '{' for loop.");let e=this._updateNode(new K([],null));this._currentLoop.push(e);let t=this._statement();for(;null!==t;){if(Array.isArray(t))for(let n of t)e.body.push(n);else e.body.push(t);if(t instanceof H){e.continuing=t;break}t=this._statement()}return this._currentLoop.pop(),this._consume(eG.tokens.brace_right,"Expected '}' for loop."),e}_switch_statement(){if(!this._match(eG.keywords.switch))return null;let e=this._updateNode(new J(null,[]));if(this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(eG.tokens.attr)&&this._attribute(),this._consume(eG.tokens.brace_left,"Expected '{' for switch."),e.cases=this._switch_body(),null==e.cases||0==e.cases.length)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(eG.tokens.brace_right,"Expected '}' for switch."),this._currentLoop.pop(),e}_switch_body(){let e=[],t=!1;for(;this._check([eG.keywords.default,eG.keywords.case]);){if(this._match(eG.keywords.case)){let n=this._case_selectors();for(let e of n)if(e instanceof e$){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!0;break}this._match(eG.tokens.colon),this._check(eG.tokens.attr)&&this._attribute(),this._consume(eG.tokens.brace_left,"Exected '{' for switch case.");let r=this._case_body();this._consume(eG.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new eL(n,r)))}if(this._match(eG.keywords.default)){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");this._match(eG.tokens.colon),this._check(eG.tokens.attr)&&this._attribute(),this._consume(eG.tokens.brace_left,"Exected '{' for switch default.");let n=this._case_body();this._consume(eG.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new eD(n)))}}return e}_case_selectors(){let e=[];for(this._match(eG.keywords.default)?e.push(this._updateNode(new e$)):e.push(this._shift_expression());this._match(eG.tokens.comma);)this._match(eG.keywords.default)?e.push(this._updateNode(new e$)):e.push(this._shift_expression());return e}_case_body(){if(this._match(eG.keywords.fallthrough))return this._consume(eG.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(null==e)return[];e instanceof Array||(e=[e]);let t=this._case_body();return 0==t.length?e:[...e,t[0]]}_if_statement(){if(!this._match(eG.keywords.if))return null;let e=this._currentLine,t=this._optional_paren_expression();this._check(eG.tokens.attr)&&this._attribute();let n=this._compound_statement(),r=[];this._match_elseif()&&(this._check(eG.tokens.attr)&&this._attribute(),r=this._elseif_statement(r));let s=null;return this._match(eG.keywords.else)&&(this._check(eG.tokens.attr)&&this._attribute(),s=this._compound_statement()),this._updateNode(new ee(t,n,r,s),e)}_match_elseif(){return this._tokens[this._current].type===eG.keywords.else&&this._tokens[this._current+1].type===eG.keywords.if&&(this._advance(),this._advance(),!0)}_elseif_statement(e=[]){let t=this._optional_paren_expression(),n=this._compound_statement();return e.push(this._updateNode(new eN(t,n))),this._match_elseif()&&(this._check(eG.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match(eG.keywords.return))return null;let e=this._short_circuit_or_expression();return this._updateNode(new et(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(eG.tokens.or_or);)e=this._updateNode(new eA(this._previous().toString(),e,this._short_circuit_and_expr()));return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(eG.tokens.and_and);)e=this._updateNode(new eA(this._previous().toString(),e,this._inclusive_or_expression()));return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(eG.tokens.or);)e=this._updateNode(new eA(this._previous().toString(),e,this._exclusive_or_expression()));return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(eG.tokens.xor);)e=this._updateNode(new eA(this._previous().toString(),e,this._and_expression()));return e}_and_expression(){let e=this._equality_expression();for(;this._match(eG.tokens.and);)e=this._updateNode(new eA(this._previous().toString(),e,this._equality_expression()));return e}_equality_expression(){let e=this._relational_expression();return this._match([eG.tokens.equal_equal,eG.tokens.not_equal])?this._updateNode(new eA(this._previous().toString(),e,this._relational_expression())):e}_relational_expression(){let e=this._shift_expression();for(;this._match([eG.tokens.less_than,eG.tokens.greater_than,eG.tokens.less_than_equal,eG.tokens.greater_than_equal]);)e=this._updateNode(new eA(this._previous().toString(),e,this._shift_expression()));return e}_shift_expression(){let e=this._additive_expression();for(;this._match([eG.tokens.shift_left,eG.tokens.shift_right]);)e=this._updateNode(new eA(this._previous().toString(),e,this._additive_expression()));return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([eG.tokens.plus,eG.tokens.minus]);)e=this._updateNode(new eA(this._previous().toString(),e,this._multiplicative_expression()));return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([eG.tokens.star,eG.tokens.forward_slash,eG.tokens.modulo]);)e=this._updateNode(new eA(this._previous().toString(),e,this._unary_expression()));return e}_unary_expression(){return this._match([eG.tokens.minus,eG.tokens.bang,eG.tokens.tilde,eG.tokens.star,eG.tokens.and])?this._updateNode(new eS(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){let e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match(eG.tokens.bracket_left)){let e=this._short_circuit_or_expression();this._consume(eG.tokens.bracket_right,"Expected ']'.");let t=this._updateNode(new eI(e)),n=this._postfix_expression();return n&&(t.postfix=n),t}if(this._match(eG.tokens.period)){let e=this._consume(eG.tokens.name,"Expected member name."),t=this._postfix_expression(),n=this._updateNode(new e_(e.lexeme));return t&&(n.postfix=t),n}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_getType(e){let t=this._getStruct(e);
1if(null!==t)return t;switch(e){case"void":return eu.void;case"bool":return eu.bool;case"i32":return eu.i32;case"u32":return eu.u32;case"f32":return eu.f32;case"f16":return eu.f16;case"vec2f":return ef.vec2f;case"vec3f":return ef.vec3f;case"vec4f":return ef.vec4f;case"vec2i":return ef.vec2i;case"vec3i":return ef.vec3i;case"vec4i":return ef.vec4i;case"vec2u":return ef.vec2u;case"vec3u":return ef.vec3u;case"vec4u":return ef.vec4u;case"vec2h":return ef.vec2h;case"vec3h":return ef.vec3h;case"vec4h":return ef.vec4h;case"mat2x2f":return ef.mat2x2f;case"mat2x3f":return ef.mat2x3f;case"mat2x4f":return ef.mat2x4f;case"mat3x2f":return ef.mat3x2f;case"mat3x3f":return ef.mat3x3f;case"mat3x4f":return ef.mat3x4f;case"mat4x2f":return ef.mat4x2f;case"mat4x3f":return ef.mat4x3f;case"mat4x4f":return ef.mat4x4f;case"mat2x2h":return ef.mat2x2h;case"mat2x3h":return ef.mat2x3h;case"mat2x4h":return ef.mat2x4h;case"mat3x2h":return ef.mat3x2h;case"mat3x3h":return ef.mat3x3h;case"mat3x4h":return ef.mat3x4h;case"mat4x2h":return ef.mat4x2h;case"mat4x3h":return ef.mat4x3h;case"mat4x4h":return ef.mat4x4h;case"mat2x2i":return ef.mat2x2i;case"mat2x3i":return ef.mat2x3i;case"mat2x4i":return ef.mat2x4i;case"mat3x2i":return ef.mat3x2i;case"mat3x3i":return ef.mat3x3i;case"mat3x4i":return ef.mat3x4i;case"mat4x2i":return ef.mat4x2i;case"mat4x3i":return ef.mat4x3i;case"mat4x4i":return ef.mat4x4i;case"mat2x2u":return ef.mat2x2u;case"mat2x3u":return ef.mat2x3u;case"mat2x4u":return ef.mat2x4u;case"mat3x2u":return ef.mat3x2u;case"mat3x3u":return ef.mat3x3u;case"mat3x4u":return ef.mat3x4u;case"mat4x2u":return ef.mat4x2u;case"mat4x3u":return ef.mat4x3u;case"mat4x4u":return ef.mat4x4u}return null}_validateTypeRange(e,t){if("i32"===t.name){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}. Line: ${this._currentLine}.`)}else if("u32"===t.name&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}. Line: ${this._currentLine}.`)}_primary_expression(){if(this._match(eG.tokens.ident)){let e=this._previous().toString();if(this._check(eG.tokens.paren_left)){let t=this._argument_expression_list(),n=this._getType(e);return null!==n?this._updateNode(new ex(n,t)):this._updateNode(new ey(e,t))}if(this._context.constants.has(e)){let t=this._context.constants.get(e);return this._updateNode(new ev(e,t.value))}return this._updateNode(new eb(e))}if(this._match(eG.tokens.int_literal)){let e=this._previous().toString(),t=e.endsWith("i")||e.endsWith("i")?eu.i32:e.endsWith("u")||e.endsWith("U")?eu.u32:eu.x32,n=parseInt(e);return this._validateTypeRange(n,t),this._updateNode(new ew(new eU(n,this._exec.getTypeInfo(t)),t))}if(this._match(eG.tokens.uint_literal)){let e=parseInt(this._previous().toString());return this._validateTypeRange(e,eu.u32),this._updateNode(new ew(new eU(e,this._exec.getTypeInfo(eu.u32)),eu.u32))}if(this._match([eG.tokens.decimal_float_literal,eG.tokens.hex_float_literal])){let e=this._previous().toString(),t=e.endsWith("h");t&&(e=e.substring(0,e.length-1));let n=parseFloat(e);this._validateTypeRange(n,t?eu.f16:eu.f32);let r=t?eu.f16:eu.f32;return this._updateNode(new ew(new eU(n,this._exec.getTypeInfo(r)),r))}if(this._match([eG.keywords.true,eG.keywords.false])){let e=this._previous().toString()===eG.keywords.true.rule;return this._updateNode(new ew(new eU(e?1:0,this._exec.getTypeInfo(eu.bool)),eu.bool))}if(this._check(eG.tokens.paren_left))return this._paren_expression();if(this._match(eG.keywords.bitcast)){this._consume(eG.tokens.less_than,"Expected '<'.");let e=this._type_decl();this._consume(eG.tokens.greater_than,"Expected '>'.");let t=this._paren_expression();return this._updateNode(new ek(e,t))}let e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new ex(e,t))}_argument_expression_list(){if(!this._match(eG.tokens.paren_left))return null;let e=[];do{if(this._check(eG.tokens.paren_right))break;let t=this._short_circuit_or_expression();e.push(t)}while(this._match(eG.tokens.comma));return this._consume(eG.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(eG.tokens.paren_left);let e=this._short_circuit_or_expression();return this._match(eG.tokens.paren_right),e}_paren_expression(){this._consume(eG.tokens.paren_left,"Expected '('.");let e=this._short_circuit_or_expression();return this._consume(eG.tokens.paren_right,"Expected ')'."),e}
1_struct_decl(){if(!this._match(eG.keywords.struct))return null;let e=this._currentLine,t=this._consume(eG.tokens.ident,"Expected name for struct.").toString();this._consume(eG.tokens.brace_left,"Expected '{' for struct body.");let n=[];for(;!this._check(eG.tokens.brace_right);){let e=this._attribute(),t=this._consume(eG.tokens.name,"Expected variable name.").toString();this._consume(eG.tokens.colon,"Expected ':' for struct member type.");let r=this._attribute(),s=this._type_decl();null!=s&&(s.attributes=r),this._check(eG.tokens.brace_right)?this._match(eG.tokens.comma):this._consume(eG.tokens.comma,"Expected ',' for struct member."),n.push(this._updateNode(new eB(t,s,e)))}this._consume(eG.tokens.brace_right,"Expected '}' after struct body.");let r=this._currentLine,s=this._updateNode(new eh(t,n,e,r),e);return this._context.structs.set(t,s),s}_global_variable_decl(){let e=this._variable_decl();if(!e)return null;if(this._match(eG.tokens.equal)){let t=this._const_expression();e.value=t}if(null!==e.type&&e.value instanceof ew){if("x32"!==e.value.type.name&&e.type.getTypeName()!==e.value.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${e.value.type.name} to ${e.type.name}. Line:${this._currentLine}`);e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else null===e.type&&e.value instanceof ew&&(e.type="x32"===e.value.type.name?eu.i32:e.value.type,e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type));return e}_override_variable_decl(){let e=this._override_decl();return e&&this._match(eG.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){var e;if(!this._match(eG.keywords.const))return null;let t=this._consume(eG.tokens.name,"Expected variable name"),n=this._currentLine,r=null;if(this._match(eG.tokens.colon)){let e=this._attribute();null!=(r=this._type_decl())&&(r.attributes=e)}let s=null;this._consume(eG.tokens.equal,"const declarations require an assignment");let a=this._short_circuit_or_expression();try{let e=[eu.f32],n=a.constEvaluate(this._exec,e);n instanceof eU&&this._validateTypeRange(n.value,e[0]),e[0]instanceof ef&&null===e[0].format&&n.typeInfo instanceof _&&null!==n.typeInfo.format&&("f16"===n.typeInfo.format.name?e[0].format=eu.f16:"f32"===n.typeInfo.format.name?e[0].format=eu.f32:"i32"===n.typeInfo.format.name?e[0].format=eu.i32:"u32"===n.typeInfo.format.name?e[0].format=eu.u32:"bool"===n.typeInfo.format.name?e[0].format=eu.bool:console.error(`TODO: impelement template format type ${n.typeInfo.format.name}`)),s=this._updateNode(new ew(n,e[0])),this._exec.context.setVariable(t.toString(),n)}catch(e){s=a}if(null!==r&&s instanceof ew){if("x32"!==s.type.name&&r.getTypeName()!==s.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${s.type.name} to ${r.name}. Line:${this._currentLine}`);s.type=r,s.isScalar&&this._validateTypeRange(s.scalarValue,s.type)}else null===r&&s instanceof ew&&(r=null!==(e=null==s?void 0:s.type)&&void 0!==e?e:eu.f32)===eu.x32&&(r=eu.i32);let i=this._updateNode(new j(t.toString(),r,"","",s),n);return this._context.constants.set(i.name,i),i}_global_let_decl(){if(!this._match(eG.keywords.let))return null;let e=this._currentLine,t=this._consume(eG.tokens.name,"Expected variable name"),n=null;if(this._match(eG.tokens.colon)){let e=this._attribute();null!=(n=this._type_decl())&&(n.attributes=e)}let r=null;if(this._match(eG.tokens.equal)&&(r=this._const_expression()),null!==n&&r instanceof ew){if("x32"!==r.type.name&&n.getTypeName()!==r.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${r.type.n
1ame} to ${n.name}. Line:${this._currentLine}`);r.type=n}else null===n&&r instanceof ew&&(n="x32"===r.type.name?eu.i32:r.type);return r instanceof ew&&r.isScalar&&this._validateTypeRange(r.scalarValue,n),this._updateNode(new X(t.toString(),n,"","",r),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match(eG.keywords.var))return null;let e=this._currentLine,t="",n="";this._match(eG.tokens.less_than)&&(t=this._consume(eG.storage_class,"Expected storage_class.").toString(),this._match(eG.tokens.comma)&&(n=this._consume(eG.access_mode,"Expected access_mode.").toString()),this._consume(eG.tokens.greater_than,"Expected '>'."));let r=this._consume(eG.tokens.name,"Expected variable name"),s=null;if(this._match(eG.tokens.colon)){let e=this._attribute();null!=(s=this._type_decl())&&(s.attributes=e)}return this._updateNode(new G(r.toString(),s,t,n,null),e)}_override_decl(){if(!this._match(eG.keywords.override))return null;let e=this._consume(eG.tokens.name,"Expected variable name"),t=null;if(this._match(eG.tokens.colon)){let e=this._attribute();null!=(t=this._type_decl())&&(t.attributes=e)}return this._updateNode(new R(e.toString(),t,null))}_diagnostic(){this._consume(eG.tokens.paren_left,"Expected '('");let e=this._consume(eG.tokens.ident,"Expected severity control name.");this._consume(eG.tokens.comma,"Expected ','");let t=this._consume(eG.tokens.ident,"Expected diagnostic rule name.").toString();return this._match(eG.tokens.period)&&(t+=`.${this._consume(eG.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume(eG.tokens.paren_right,"Expected ')'"),this._updateNode(new es(e.toString(),t))}_enable_directive(){let e=this._consume(eG.tokens.ident,"identity expected.");return this._updateNode(new en(e.toString()))}_requires_directive(){let e=[this._consume(eG.tokens.ident,"identity expected.").toString()];for(;this._match(eG.tokens.comma);){let t=this._consume(eG.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new er(e))}_type_alias(){let e=this._consume(eG.tokens.ident,"identity expected.");this._consume(eG.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(null===t)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);let n=this._updateNode(new ea(e.toString(),t));return this._context.aliases.set(n.name,n),n}_type_decl(){if(this._check([eG.tokens.ident,...eG.texel_format,eG.keywords.bool,eG.keywords.f32,eG.keywords.i32,eG.keywords.u32])){let e=this._advance().toString();if(this._context.structs.has(e))return this._context.structs.get(e);if(this._context.aliases.has(e))return this._context.aliases.get(e).type;if(!this._getType(e)){let t=this._updateNode(new ec(e));return this._forwardTypeCount++,t}return this._updateNode(new eu(e))}let e=this._texture_sampler_types();if(e)return e;if(this._check(eG.template_types)){let e=this._advance().toString(),t=null,n=null;return this._match(eG.tokens.less_than)&&(t=this._type_decl(),n=null,this._match(eG.tokens.comma)&&(n=this._consume(eG.access_mode,"Expected access_mode for pointer").toString()),this._consume(eG.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new ef(e,t,n))}if(this._match(eG.keywords.ptr)){let e=this._previous().toString();this._consume(eG.tokens.less_than,"Expected '<' for pointer.");let t=this._consume(eG.storage_class,"Expected storage_class for pointer");this._consume(eG.tokens.comma,"Expected ',' for pointer.");let n=this._type_decl(),r=null;return this._match(eG.tokens.comma)&&(r=this._consume(eG.access_mode,"Expected access_mode for pointer").toString()),this._consume(eG.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new ep(e,t.toString(),n,r))}let t=this._attribute();if(this._match(eG.keywords.array)){let e=null,n=-1,r=this._previous(),s=null;if(this._match(eG.tokens.less_than)){e=this._type_decl(),this._context.aliases.has(e.name)&&(e=this._context.aliases.get(e.name).type);let t="";if(this._match(eG.tokens.comma)){s=this._shift_expression();try{t=s.constEvaluate(this._exec).toString(),s=null}catch(e){t="1"}}this._consume(eG.tokens.greater_than,"Expected '>' for array."),n=t?parseInt(t):0}let a=this._updateNode(new ed(r.toString(),t,e,n));return s&&this._deferArrayCountEval.push({arrayType:a,countNode:s}),a}return null}_texture_sampler_types(){if(this._match(eG.sampler_type)||this._match(eG.depth_texture_type))return this._updateNode(new em(this._previous().toString(),null,null));if(this._match(eG.sampled_texture_type)||this._match(eG.multisampled_texture_type)){let e=this._previous();this._consume(eG.tokens.less_than,"Expected '<' for sampler type.");let t=this._type_decl();return this._consume(eG.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new em(e.toString(),t,null))}if(this._match(eG.storage_texture_type)){let e=this._previous();this._consume(eG.tokens.less_than,"Expected '<' for sampler type.");let t=this._consume(eG.texel_format,"Invalid texel format.").toString();this._consume(eG.tokens.comma,"Expected ',' after texel format.");let n=this._consume(eG.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(eG.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new em(e.toString(),t,n))}return null}_attribute(){let e=[];for(;this._match(eG.tokens.attr);){let t=this._consume(eG.attribute_name,"Expected attribute name"),n=this._updateNode(new eV(t.toString(),null));if(this._match(eG.tokens.paren_left)){if(n.value=this._consume(eG.literal_or_ident,"Expected attribute value").toString(),this._check(eG.tokens.comma)){this._advance();do{let e=this._consume(eG.literal_or_ident,"Expected attribute value").toString();n.value instanceof Array||(n.value=[n.value]),n.value.push(e)}while(this._match(eG.tokens.comma))}this._consume(eG.tokens.paren_right,"Expected ')'")}e.push(n)}return 0==e.length?null:e}}class tu extends e5{constructor(e){super(),e&&this.update(e)}update(e){let t=(new tl).parse(e);this.updateAST(t)}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.