wesl 0.6.0-pre10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/README.md +31 -0
  2. package/dist/index.js +4468 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/minified.js +3426 -0
  5. package/dist/minified.js.map +1 -0
  6. package/dist/tools/packages/wesl/src/AbstractElems.d.ts +322 -0
  7. package/dist/tools/packages/wesl/src/Assertions.d.ts +27 -0
  8. package/dist/tools/packages/wesl/src/BindIdents.d.ts +70 -0
  9. package/dist/tools/packages/wesl/src/Conditions.d.ts +6 -0
  10. package/dist/tools/packages/wesl/src/FlattenTreeImport.d.ts +11 -0
  11. package/dist/tools/packages/wesl/src/LinkedWesl.d.ts +50 -0
  12. package/dist/tools/packages/wesl/src/Linker.d.ts +87 -0
  13. package/dist/tools/packages/wesl/src/LinkerUtil.d.ts +3 -0
  14. package/dist/tools/packages/wesl/src/LiveDeclarations.d.ts +12 -0
  15. package/dist/tools/packages/wesl/src/LowerAndEmit.d.ts +31 -0
  16. package/dist/tools/packages/wesl/src/Mangler.d.ts +39 -0
  17. package/dist/tools/packages/wesl/src/ParseWESL.d.ts +60 -0
  18. package/dist/tools/packages/wesl/src/ParsedRegistry.d.ts +29 -0
  19. package/dist/tools/packages/wesl/src/PathUtil.d.ts +6 -0
  20. package/dist/tools/packages/wesl/src/RawEmit.d.ts +6 -0
  21. package/dist/tools/packages/wesl/src/Reflection.d.ts +45 -0
  22. package/dist/tools/packages/wesl/src/Scope.d.ts +81 -0
  23. package/dist/tools/packages/wesl/src/StandardTypes.d.ts +13 -0
  24. package/dist/tools/packages/wesl/src/TransformBindingStructs.d.ts +52 -0
  25. package/dist/tools/packages/wesl/src/Util.d.ts +43 -0
  26. package/dist/tools/packages/wesl/src/WESLCollect.d.ts +94 -0
  27. package/dist/tools/packages/wesl/src/WeslBundle.d.ts +13 -0
  28. package/dist/tools/packages/wesl/src/WeslDevice.d.ts +25 -0
  29. package/dist/tools/packages/wesl/src/debug/ASTtoString.d.ts +5 -0
  30. package/dist/tools/packages/wesl/src/debug/ImportToString.d.ts +2 -0
  31. package/dist/tools/packages/wesl/src/debug/LineWrapper.d.ts +21 -0
  32. package/dist/tools/packages/wesl/src/debug/ScopeToString.d.ts +6 -0
  33. package/dist/tools/packages/wesl/src/index.d.ts +11 -0
  34. package/dist/tools/packages/wesl/src/parse/ImportGrammar.d.ts +5 -0
  35. package/dist/tools/packages/wesl/src/parse/Keywords.d.ts +4 -0
  36. package/dist/tools/packages/wesl/src/parse/WeslBaseGrammar.d.ts +5 -0
  37. package/dist/tools/packages/wesl/src/parse/WeslExpression.d.ts +13 -0
  38. package/dist/tools/packages/wesl/src/parse/WeslGrammar.d.ts +80 -0
  39. package/dist/tools/packages/wesl/src/parse/WeslStream.d.ts +44 -0
  40. package/dist/tools/packages/wesl/src/test/BindWESL.test.d.ts +1 -0
  41. package/dist/tools/packages/wesl/src/test/ConditionLinking.test.d.ts +1 -0
  42. package/dist/tools/packages/wesl/src/test/ConditionalTranslationCases.test.d.ts +1 -0
  43. package/dist/tools/packages/wesl/src/test/ErrorLogging.test.d.ts +1 -0
  44. package/dist/tools/packages/wesl/src/test/Expression.test.d.ts +1 -0
  45. package/dist/tools/packages/wesl/src/test/FlattenTreeImport.test.d.ts +1 -0
  46. package/dist/tools/packages/wesl/src/test/ImportCases.test.d.ts +1 -0
  47. package/dist/tools/packages/wesl/src/test/ImportSyntaxCases.test.d.ts +1 -0
  48. package/dist/tools/packages/wesl/src/test/LinkGlob.test.d.ts +1 -0
  49. package/dist/tools/packages/wesl/src/test/LinkPackage.test.d.ts +1 -0
  50. package/dist/tools/packages/wesl/src/test/Linker.test.d.ts +1 -0
  51. package/dist/tools/packages/wesl/src/test/Mangling.test.d.ts +1 -0
  52. package/dist/tools/packages/wesl/src/test/ParseComments.test.d.ts +1 -0
  53. package/dist/tools/packages/wesl/src/test/ParseConditions.test.d.ts +1 -0
  54. package/dist/tools/packages/wesl/src/test/ParseError.test.d.ts +1 -0
  55. package/dist/tools/packages/wesl/src/test/ParseWESL.test.d.ts +1 -0
  56. package/dist/tools/packages/wesl/src/test/PathUtil.test.d.ts +1 -0
  57. package/dist/tools/packages/wesl/src/test/PrettyGrammar.test.d.ts +1 -0
  58. package/dist/tools/packages/wesl/src/test/Reflection.test.d.ts +1 -0
  59. package/dist/tools/packages/wesl/src/test/ScopeWESL.test.d.ts +1 -0
  60. package/dist/tools/packages/wesl/src/test/TestLink.d.ts +21 -0
  61. package/dist/tools/packages/wesl/src/test/TestSetup.d.ts +1 -0
  62. package/dist/tools/packages/wesl/src/test/TestUtil.d.ts +40 -0
  63. package/dist/tools/packages/wesl/src/test/Tokenizer.test.d.ts +1 -0
  64. package/dist/tools/packages/wesl/src/test/TransformBindingStructs.test.d.ts +1 -0
  65. package/dist/tools/packages/wesl/src/test/Util.test.d.ts +1 -0
  66. package/dist/tools/packages/wesl/src/test/VirtualModules.test.d.ts +1 -0
  67. package/dist/tools/packages/wesl/src/test/WeslDevice.test.d.ts +1 -0
  68. package/dist/tools/packages/wesl/src/test/WgslTests.d.ts +0 -0
  69. package/dist/tools/packages/wesl/src/vlq/vlq.d.ts +11 -0
  70. package/package.json +46 -0
  71. package/src/AbstractElems.ts +446 -0
  72. package/src/Assertions.ts +51 -0
  73. package/src/BindIdents.ts +523 -0
  74. package/src/Conditions.ts +74 -0
  75. package/src/FlattenTreeImport.ts +55 -0
  76. package/src/LinkedWesl.ts +184 -0
  77. package/src/Linker.ts +284 -0
  78. package/src/LinkerUtil.ts +29 -0
  79. package/src/LiveDeclarations.ts +31 -0
  80. package/src/LowerAndEmit.ts +413 -0
  81. package/src/Mangler.ts +94 -0
  82. package/src/ParseWESL.ts +157 -0
  83. package/src/ParsedRegistry.ts +120 -0
  84. package/src/PathUtil.ts +31 -0
  85. package/src/RawEmit.ts +102 -0
  86. package/src/Reflection.ts +334 -0
  87. package/src/Scope.ts +162 -0
  88. package/src/StandardTypes.ts +97 -0
  89. package/src/TransformBindingStructs.ts +319 -0
  90. package/src/Util.ts +194 -0
  91. package/src/WESLCollect.ts +614 -0
  92. package/src/WeslBundle.ts +16 -0
  93. package/src/WeslDevice.ts +209 -0
  94. package/src/debug/ASTtoString.ts +290 -0
  95. package/src/debug/ImportToString.ts +29 -0
  96. package/src/debug/LineWrapper.ts +70 -0
  97. package/src/debug/ScopeToString.ts +79 -0
  98. package/src/index.ts +11 -0
  99. package/src/parse/ImportGrammar.ts +157 -0
  100. package/src/parse/Keywords.ts +26 -0
  101. package/src/parse/WeslBaseGrammar.ts +8 -0
  102. package/src/parse/WeslExpression.ts +207 -0
  103. package/src/parse/WeslGrammar.ts +856 -0
  104. package/src/parse/WeslStream.ts +279 -0
  105. package/src/test/BindWESL.test.ts +57 -0
  106. package/src/test/ConditionLinking.test.ts +91 -0
  107. package/src/test/ConditionalTranslationCases.test.ts +56 -0
  108. package/src/test/ErrorLogging.test.ts +30 -0
  109. package/src/test/Expression.test.ts +22 -0
  110. package/src/test/FlattenTreeImport.test.ts +74 -0
  111. package/src/test/ImportCases.test.ts +56 -0
  112. package/src/test/ImportSyntaxCases.test.ts +24 -0
  113. package/src/test/LinkGlob.test.ts +25 -0
  114. package/src/test/LinkPackage.test.ts +26 -0
  115. package/src/test/Linker.test.ts +125 -0
  116. package/src/test/Mangling.test.ts +45 -0
  117. package/src/test/ParseComments.test.ts +36 -0
  118. package/src/test/ParseConditions.test.ts +183 -0
  119. package/src/test/ParseError.test.ts +36 -0
  120. package/src/test/ParseWESL.test.ts +1572 -0
  121. package/src/test/PathUtil.test.ts +34 -0
  122. package/src/test/PrettyGrammar.test.ts +20 -0
  123. package/src/test/Reflection.test.ts +172 -0
  124. package/src/test/ScopeWESL.test.ts +462 -0
  125. package/src/test/TestLink.ts +82 -0
  126. package/src/test/TestSetup.ts +4 -0
  127. package/src/test/TestUtil.ts +126 -0
  128. package/src/test/Tokenizer.test.ts +135 -0
  129. package/src/test/TransformBindingStructs.test.ts +230 -0
  130. package/src/test/Util.test.ts +22 -0
  131. package/src/test/VirtualModules.test.ts +37 -0
  132. package/src/test/WeslDevice.test.ts +265 -0
  133. package/src/test/WgslTests.ts +0 -0
  134. package/src/test/__snapshots__/ParseDirectives.test.ts.snap +25 -0
  135. package/src/test/__snapshots__/ParseWESL.test.ts.snap +119 -0
  136. package/src/test/__snapshots__/RustDirective.test.ts.snap +359 -0
  137. package/src/test/wgsl_1/main.wgsl +3 -0
  138. package/src/test/wgsl_1/util.wgsl +1 -0
  139. package/src/test/wgsl_2/main2.wgsl +3 -0
  140. package/src/test/wgsl_2/util2.wgsl +1 -0
  141. package/src/vlq/vlq.ts +94 -0
@@ -0,0 +1,3426 @@
1
+ var me = (t) => {
2
+ throw TypeError(t);
3
+ };
4
+ var he = (t, e, n) => e.has(t) || me("Cannot " + n);
5
+ var g = (t, e, n) => (he(t, e, "read from private field"), n ? n.call(t) : e.get(t)), I = (t, e, n) => e.has(t) ? me("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), B = (t, e, n, r) => (he(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n);
6
+ function qn(t, e) {
7
+ if (!t)
8
+ throw new Error(e);
9
+ }
10
+ function Tt(t) {
11
+ throw new Un("Unreachable value", { data: t });
12
+ }
13
+ let Un = class extends Error {
14
+ constructor(e, n) {
15
+ super(e, n), this.data = n == null ? void 0 : n.data;
16
+ }
17
+ }, Wn = console.log;
18
+ function Me(t, e, ...n) {
19
+ Vn(Wn, t, e, ...n);
20
+ }
21
+ function Ce(t) {
22
+ return t ? `'${t.replace(/\n/g, "\\n")}'` : "";
23
+ }
24
+ function Vn(t, e, n, ...r) {
25
+ if (typeof e == "string") {
26
+ ge(t, e, n, ...r);
27
+ return;
28
+ }
29
+ const { src: s, positions: o } = zn(e, n);
30
+ ge(t, s.text, o, ...r);
31
+ }
32
+ function zn(t, e) {
33
+ var o, i, a, l;
34
+ const n = t.mapPositions(...[e].flat()), { src: r } = n[0];
35
+ let s;
36
+ return ((i = (o = n[1]) == null ? void 0 : o.src) == null ? void 0 : i.path) === r.path && ((l = (a = n[1]) == null ? void 0 : a.src) == null ? void 0 : l.text) === r.text ? s = n.map((c) => c.position) : s = n[0].position, { src: r, positions: s };
37
+ }
38
+ function ge(t, e, n, ...r) {
39
+ t(...r);
40
+ const { line: s, lineNum: o, linePos: i, linePos2: a } = Xn(e, n);
41
+ t(s, ` Ln ${o}`);
42
+ const l = Gn(i, a);
43
+ t(l);
44
+ }
45
+ function Gn(t, e) {
46
+ const n = " ".repeat(t) + "^";
47
+ let r = "";
48
+ return e && e > t && (r = " ".repeat(e - t - 1) + "^"), n + r;
49
+ }
50
+ const be = /* @__PURE__ */ new Map();
51
+ function Xn(t, e) {
52
+ let n, r;
53
+ typeof e == "number" ? n = e : [n, r] = e;
54
+ const s = Jn(t);
55
+ let o = 0, i = s.length - 1;
56
+ for (n >= s[i] && (o = i); o + 1 < i; ) {
57
+ const d = o + i >> 1;
58
+ n >= s[d] ? o = d : i = d;
59
+ }
60
+ let a;
61
+ r !== void 0 && r >= s[o] && r < s[i] && (a = r - s[o]);
62
+ const l = t.slice(s[o], s[o + 1] || t.length);
63
+ return { line: l.slice(-1) === `
64
+ ` ? l.slice(0, -1) : l, linePos: n - s[o], linePos2: a, lineNum: o + 1 };
65
+ }
66
+ function Jn(t) {
67
+ const e = be.get(t);
68
+ if (e) return e;
69
+ const n = [...t.matchAll(/\n/g)].map((r) => r.index + 1);
70
+ return n.unshift(0), be.set(t, n), n;
71
+ }
72
+ function Kn(t) {
73
+ const e = t.checkpoint(), n = t.nextToken();
74
+ return t.reset(e), n;
75
+ }
76
+ function st(t, e) {
77
+ return G(
78
+ `token '${t}' ${Ce(e)}`,
79
+ function(r) {
80
+ const s = r.stream.checkpoint(), o = r.stream.nextToken();
81
+ return o === null ? null : o.kind !== t || o.text !== e ? (r.stream.reset(s), null) : { value: o };
82
+ }
83
+ );
84
+ }
85
+ function bt(t, e) {
86
+ return G(
87
+ `tokenOf '${t}'`,
88
+ function(r) {
89
+ const s = r.stream.checkpoint(), o = r.stream.nextToken();
90
+ return o === null ? null : o.kind !== t || !e.includes(o.text) ? (r.stream.reset(s), null) : { value: o };
91
+ }
92
+ );
93
+ }
94
+ function Ae(t) {
95
+ return G(
96
+ `tokenKind '${t}'`,
97
+ function(n) {
98
+ const r = n.stream.checkpoint(), s = n.stream.nextToken();
99
+ return s === null ? null : s.kind !== t ? (n.stream.reset(r), null) : { value: s };
100
+ }
101
+ );
102
+ }
103
+ function zt(t) {
104
+ return G(
105
+ `kind '${t}'`,
106
+ function(n) {
107
+ const r = n.stream.checkpoint(), s = n.stream.nextToken();
108
+ return s === null ? null : s.kind !== t ? (n.stream.reset(r), null) : { value: s.text };
109
+ }
110
+ );
111
+ }
112
+ function Pt(t) {
113
+ return G(
114
+ `${Ce(t)}`,
115
+ function(n) {
116
+ const r = n.stream.checkpoint(), s = n.stream.nextToken();
117
+ return s === null ? null : s.text !== t ? (n.stream.reset(r), null) : { value: s.text };
118
+ }
119
+ );
120
+ }
121
+ function u(...t) {
122
+ const e = t.map(k), n = y("seq", function(s) {
123
+ const o = [];
124
+ for (const i of e) {
125
+ const a = i._run(s);
126
+ if (a === null)
127
+ return null;
128
+ o.push(a.value);
129
+ }
130
+ return { value: o };
131
+ });
132
+ return Ht(n, ...e), n;
133
+ }
134
+ function Hn(t) {
135
+ const e = Object.entries(t).map(
136
+ ([r, s]) => [r, k(s)]
137
+ ), n = y("seqObj", function(s) {
138
+ const o = {};
139
+ for (const [i, a] of e) {
140
+ const l = a._run(s);
141
+ if (l === null)
142
+ return null;
143
+ o[i] = l.value;
144
+ }
145
+ return { value: o };
146
+ });
147
+ return Ht(n, ...e.map((r) => r[1])), n;
148
+ }
149
+ function Yn(t) {
150
+ return t.collect({ before: sr, after: or });
151
+ }
152
+ function N(t, e) {
153
+ const n = k(t), r = k(e);
154
+ return y(
155
+ "preceded",
156
+ function(i) {
157
+ return n._run(i) === null ? null : r._run(i);
158
+ }
159
+ );
160
+ }
161
+ function Dt(t, e) {
162
+ const n = k(t), r = k(e);
163
+ return y(
164
+ "terminated",
165
+ function(i) {
166
+ const a = n._run(i);
167
+ return a === null || r._run(i) === null ? null : a;
168
+ }
169
+ );
170
+ }
171
+ function q(t, e, n) {
172
+ const r = k(t), s = k(e), o = k(n);
173
+ return y(
174
+ "delimited",
175
+ function(l) {
176
+ if (r._run(l) === null) return null;
177
+ const d = s._run(l);
178
+ return d === null || o._run(l) === null ? null : d;
179
+ }
180
+ );
181
+ }
182
+ function Zn(t, e, n) {
183
+ const r = k(t), s = k(e), o = k(n);
184
+ return y(
185
+ "terminated",
186
+ function(l) {
187
+ const c = r._run(l);
188
+ if (c === null || s._run(l) === null) return null;
189
+ const p = o._run(l);
190
+ return p === null ? null : { value: [c.value, p.value] };
191
+ }
192
+ );
193
+ }
194
+ function m(...t) {
195
+ const e = t.map(k), n = y("or", function(s) {
196
+ const o = s.stream.checkpoint();
197
+ for (const i of e) {
198
+ s.stream.reset(o);
199
+ const a = i._run(s);
200
+ if (a !== null)
201
+ return a;
202
+ }
203
+ return null;
204
+ });
205
+ return Ht(n, ...e), n;
206
+ }
207
+ function b(t) {
208
+ const e = k(t);
209
+ return y(
210
+ "opt",
211
+ function(s) {
212
+ const o = s.stream.checkpoint(), i = e._run(s);
213
+ return i === null ? (s.stream.reset(o), { value: null }) : i;
214
+ }
215
+ );
216
+ }
217
+ function T(t) {
218
+ const e = k(t);
219
+ return y("repeat", Qn(e));
220
+ }
221
+ function L(t) {
222
+ const e = k(t);
223
+ return u(e, T(e)).map((r) => [r[0], ...r[1]]).setTraceName("repeatPlus");
224
+ }
225
+ function Qn(t, e = () => !0) {
226
+ return function(r) {
227
+ const s = [];
228
+ for (; ; ) {
229
+ const o = r.stream.checkpoint(), i = Le(r, t);
230
+ if (i === null)
231
+ return r.stream.reset(o), { value: s };
232
+ if (!e(i))
233
+ return { value: s };
234
+ s.push(i.value);
235
+ }
236
+ };
237
+ }
238
+ function Gt(t) {
239
+ const e = k(t);
240
+ return y("span", function(s) {
241
+ var l, c;
242
+ const o = ((c = (l = Kn(s.stream)) == null ? void 0 : l.span) == null ? void 0 : c[0]) ?? null, i = e._run(s);
243
+ if (i === null) return null;
244
+ const a = s.stream.checkpoint();
245
+ return {
246
+ value: {
247
+ value: i.value,
248
+ span: [o ?? a, a]
249
+ }
250
+ };
251
+ });
252
+ }
253
+ function tr() {
254
+ return G("eof", function(e) {
255
+ const n = e.stream.checkpoint();
256
+ return e.stream.nextToken() !== null ? (e.stream.reset(n), null) : { value: !0 };
257
+ });
258
+ }
259
+ function f(t, e) {
260
+ const n = k(t);
261
+ return y("req", function(o) {
262
+ const i = n._run(o);
263
+ if (i === null)
264
+ throw new H(e, o.stream.checkpoint());
265
+ return i;
266
+ });
267
+ }
268
+ function xt() {
269
+ return G("yes", function() {
270
+ return { value: null };
271
+ });
272
+ }
273
+ function tt(t, e, n = {}) {
274
+ const { trailing: r = !0, requireOne: s = !1 } = n, o = k(e), i = k(t);
275
+ return y("withSep", function(l) {
276
+ const c = [], d = l.stream.checkpoint(), p = o._run(l);
277
+ if (p === null)
278
+ return l.stream.reset(d), s ? null : {
279
+ value: c
280
+ };
281
+ for (c.push(p.value); ; ) {
282
+ const h = l.stream.checkpoint();
283
+ if (i._run(l) === null) {
284
+ l.stream.reset(h);
285
+ break;
286
+ }
287
+ const P = l.stream.checkpoint(), R = o._run(l);
288
+ if (R === null) {
289
+ r ? l.stream.reset(P) : l.stream.reset(h);
290
+ break;
291
+ }
292
+ c.push(R.value);
293
+ }
294
+ return {
295
+ value: c
296
+ };
297
+ });
298
+ }
299
+ function $t(t, e) {
300
+ return tt(t, e, { requireOne: !0 }).setTraceName("withSepPlus");
301
+ }
302
+ function Re(t) {
303
+ return G(
304
+ "withStreamAction",
305
+ function(n) {
306
+ const r = t(n.stream);
307
+ return r === null ? null : { value: r };
308
+ }
309
+ );
310
+ }
311
+ function k(t) {
312
+ return typeof t == "string" ? Pt(t) : t instanceof Ie ? t : z(t);
313
+ }
314
+ function z(t) {
315
+ return y(
316
+ "fn()",
317
+ function(r) {
318
+ if (!t)
319
+ throw new H(
320
+ "fn parser called before definition",
321
+ r.stream.checkpoint()
322
+ );
323
+ return t()._run(r);
324
+ }
325
+ );
326
+ }
327
+ function er(t, e, n) {
328
+ const r = e.after ?? e, s = e.before;
329
+ let o = r;
330
+ n && (o = (l) => {
331
+ const c = r(l);
332
+ return c != null && Jt(l.tags, n, c), c;
333
+ });
334
+ const i = n ? `${t.debugName}-${n}` : `${t.debugName}`;
335
+ return y(
336
+ "collect",
337
+ function(c) {
338
+ const d = c.stream.checkpoint();
339
+ return s && Nt(c, d, s, `${i}.before`), Xt(t, c, o, i);
340
+ }
341
+ );
342
+ }
343
+ function _(t) {
344
+ const e = k(t);
345
+ return y(
346
+ "tagScope",
347
+ function(s) {
348
+ const o = s.stream.checkpoint();
349
+ let i;
350
+ return Nt(
351
+ s,
352
+ o,
353
+ (a) => {
354
+ i = nr(a.tags), a.tags = {};
355
+ },
356
+ `scope.before ${e.debugName}`
357
+ ), Xt(
358
+ e,
359
+ s,
360
+ (a) => {
361
+ a.tags = i;
362
+ },
363
+ "tagScope"
364
+ );
365
+ }
366
+ );
367
+ }
368
+ function nr(t) {
369
+ const e = Object.entries(t).map(([n, r]) => [n, [...r]]);
370
+ return Object.fromEntries(e);
371
+ }
372
+ function rr(t, e) {
373
+ return y(
374
+ "ctag",
375
+ function(s) {
376
+ return Xt(
377
+ t,
378
+ s,
379
+ (o) => {
380
+ const i = Kt(o._values);
381
+ Jt(o.tags, e, i.value);
382
+ },
383
+ `ctag ${e}`
384
+ );
385
+ }
386
+ );
387
+ }
388
+ function Xt(t, e, n, r = "") {
389
+ const s = e.stream.checkpoint(), o = t._run(e);
390
+ return o && Nt(e, s, n, r), o;
391
+ }
392
+ function Nt(t, e, n, r) {
393
+ const s = cr(t.stream, e);
394
+ t._collect.push({
395
+ srcPosition: s,
396
+ collectFn: n,
397
+ debugName: r
398
+ });
399
+ }
400
+ function sr(t) {
401
+ t._values.push({ value: null, openArray: [] });
402
+ }
403
+ function or(t) {
404
+ const e = Kt(t._values);
405
+ e.openArray === void 0 && console.log("---closeArray: no open array"), t._values.pop(), Be(t, e.openArray);
406
+ }
407
+ function ir(t, e) {
408
+ return y(
409
+ "ptag",
410
+ function(s) {
411
+ const o = s.stream.checkpoint(), i = t._run(s);
412
+ return i && Nt(s, o, (l) => Jt(l.tags, e, i.value), `ptag ${e}`), i;
413
+ }
414
+ );
415
+ }
416
+ function Jt(t, e, n) {
417
+ t[e] === void 0 && (t[e] = []), t[e].push(n);
418
+ }
419
+ function ar(t, e, n) {
420
+ const r = {}, { src: s } = n, i = {
421
+ tags: r,
422
+ src: s,
423
+ start: -1,
424
+ end: -1,
425
+ app: e,
426
+ _values: [{ value: null, openArray: void 0 }]
427
+ };
428
+ t.forEach((a) => {
429
+ const { collectFn: l, srcPosition: c } = a;
430
+ i.start = c.start, i.end = c.end;
431
+ const d = l(i);
432
+ Be(i, d);
433
+ });
434
+ }
435
+ function Be(t, e) {
436
+ if (e !== void 0) {
437
+ const n = Kt(t._values);
438
+ n || console.log("----saveCollectValue: no valueEntry"), n && (n.value = e), (n == null ? void 0 : n.openArray) !== void 0 && n.openArray.push(e);
439
+ }
440
+ }
441
+ function Kt(t) {
442
+ return t[t.length - 1];
443
+ }
444
+ function cr(t, e) {
445
+ const n = t.checkpoint();
446
+ t.reset(e);
447
+ const r = lr(t);
448
+ return t.reset(n), { start: r, end: n };
449
+ }
450
+ function lr(t) {
451
+ const e = t.nextToken();
452
+ return e === null || t.reset(e.span[0]), t.checkpoint();
453
+ }
454
+ class H extends Error {
455
+ constructor(e, n) {
456
+ super(e), this.position = n;
457
+ }
458
+ }
459
+ class Ie {
460
+ constructor(e) {
461
+ this.fn = e.fn;
462
+ }
463
+ /** run the parser given an already created parsing context
464
+ *
465
+ * Execute a parser by running the core parsing fn given the parsing context
466
+ * also:
467
+ * . log if tracing is enabled
468
+ * . backtrack on failure
469
+ * . rollback context on failure
470
+ */
471
+ _run(e) {
472
+ {
473
+ const n = e.app.context, r = e._collect.length, s = this.fn(e);
474
+ return s === null && (e.app.context = n, e._collect.length = r), s;
475
+ }
476
+ }
477
+ /** tag parse results */
478
+ ptag(e) {
479
+ return ir(this, e);
480
+ }
481
+ /** tag collect results */
482
+ ctag(e) {
483
+ return rr(this, e);
484
+ }
485
+ /** record a name for debug tracing */
486
+ setTraceName(e) {
487
+ return this;
488
+ }
489
+ /** trigger tracing for this parser (and by default also this parsers descendants) */
490
+ setTrace(e = {}) {
491
+ return this;
492
+ }
493
+ /** map results to a new value, or add to app state as a side effect.
494
+ * Return null to cause the parser to fail.
495
+ * SAFETY: Side-effects should not be done if backtracking could occur!
496
+ */
497
+ mapExtended(e) {
498
+ return ur(this, e);
499
+ }
500
+ /** map results to a new value.
501
+ */
502
+ map(e) {
503
+ return dr(this, e);
504
+ }
505
+ /** Queue a function that runs later, typically to collect AST elements from the parse.
506
+ * when a commit() is parsed.
507
+ * Collection functions are dropped with parser backtracking, so
508
+ * only succsessful parses are collected. */
509
+ collect(e, n) {
510
+ return er(this, e, n);
511
+ }
512
+ /** switch next parser based on results */
513
+ toParser(e) {
514
+ return fr(this, e);
515
+ }
516
+ /**
517
+ * start parsing
518
+ *
519
+ * @throws {ParseError} when a combinator like `req` fails
520
+ */
521
+ parse(e) {
522
+ const { stream: n, appState: r = { context: {}, stable: [] } } = e, s = [], o = this._run({
523
+ stream: n,
524
+ app: r,
525
+ _collect: s
526
+ });
527
+ return o && ar(s, r, n), o;
528
+ }
529
+ /** name of this parser for debugging/tracing */
530
+ get debugName() {
531
+ return "parser";
532
+ }
533
+ }
534
+ function y(t, e, n) {
535
+ return new Ie({ fn: e, traceName: t, terminal: n });
536
+ }
537
+ function G(t, e) {
538
+ return y(t, e, !0);
539
+ }
540
+ function ur(t, e) {
541
+ return y(
542
+ "mapExtended",
543
+ function(s) {
544
+ const o = Le(s, t);
545
+ if (!o) return null;
546
+ const i = e(o);
547
+ return i === null ? null : { value: i };
548
+ }
549
+ );
550
+ }
551
+ function dr(t, e) {
552
+ return y(
553
+ "map",
554
+ function(s) {
555
+ const o = t._run(s);
556
+ return o === null ? null : { value: e(o.value) };
557
+ }
558
+ );
559
+ }
560
+ function fr(t, e) {
561
+ return y(
562
+ "toParser",
563
+ function(s) {
564
+ const o = t._run(s);
565
+ if (o === null) return null;
566
+ const i = e(o);
567
+ return i === null ? o : i._run(s);
568
+ }
569
+ );
570
+ }
571
+ function Le(t, e) {
572
+ const n = t.stream.checkpoint(), r = e._run(t);
573
+ if (r === null)
574
+ return t.stream.reset(n), null;
575
+ const { app: s } = t;
576
+ return { ...r, app: s };
577
+ }
578
+ function Ht(t, ...e) {
579
+ }
580
+ class Yt {
581
+ constructor(e, n = []) {
582
+ this.dest = e, this.entries = n;
583
+ }
584
+ /** add a new mapping from src to dest ranges.
585
+ * entries must be non-overlapping in the destination
586
+ */
587
+ addEntries(e) {
588
+ this.entries.push(...e);
589
+ }
590
+ /** given positions in the dest string,
591
+ * @return corresponding positions in the src strings */
592
+ mapPositions(...e) {
593
+ return e.map((n) => this.destToSrc(n));
594
+ }
595
+ /** internally compress adjacent entries where possible */
596
+ compact() {
597
+ if (!this.entries.length) return;
598
+ let e = this.entries[0];
599
+ const n = [e];
600
+ for (let r = 1; r < this.entries.length; r++) {
601
+ const s = this.entries[r];
602
+ s.src.path === e.src.path && s.src.text === e.src.text && e.destEnd === s.destStart && e.srcEnd === s.srcStart ? (e.destEnd = s.destEnd, e.srcEnd = s.srcEnd) : (n.push(s), e = s);
603
+ }
604
+ this.entries = n;
605
+ }
606
+ /** sort in destination order */
607
+ sort() {
608
+ this.entries.sort((e, n) => e.destStart - n.destStart);
609
+ }
610
+ /** This SrcMap's destination is a src for the other srcmap,
611
+ * so combine the two and return the result.
612
+ */
613
+ merge(e) {
614
+ if (e === this) return this;
615
+ const n = e.entries.filter(
616
+ (i) => i.src.path === this.dest.path && i.src.text === this.dest.text
617
+ );
618
+ if (n.length === 0)
619
+ return console.log("other source map does not link to this one"), e;
620
+ pr(n);
621
+ const r = n.map((i) => {
622
+ const { src: a, position: l } = this.destToSrc(i.srcStart), { src: c, position: d } = this.destToSrc(i.srcEnd);
623
+ if (c !== a) throw new Error("NYI, need to split");
624
+ return {
625
+ src: a,
626
+ srcStart: l,
627
+ srcEnd: d,
628
+ destStart: i.destStart,
629
+ destEnd: i.destEnd
630
+ };
631
+ }), s = e.entries.filter(
632
+ (i) => i.src.path !== this.dest.path || i.src.text !== this.dest.text
633
+ ), o = new Yt(e.dest, [...s, ...r]);
634
+ return o.sort(), o;
635
+ }
636
+ /**
637
+ * @param entries should be sorted in destStart order
638
+ * @return the source position corresponding to a provided destination position
639
+ *
640
+ */
641
+ destToSrc(e) {
642
+ const n = this.entries.find(
643
+ (r) => r.destStart <= e && r.destEnd >= e
644
+ );
645
+ return n ? {
646
+ src: n.src,
647
+ position: n.srcStart + e - n.destStart
648
+ } : {
649
+ src: this.dest,
650
+ position: e
651
+ };
652
+ }
653
+ }
654
+ function pr(t) {
655
+ t.sort((e, n) => e.srcStart - n.srcStart);
656
+ }
657
+ var Y, O, W;
658
+ class ht {
659
+ constructor(e) {
660
+ I(this, Y, []);
661
+ I(this, O, 0);
662
+ I(this, W, []);
663
+ this.source = e;
664
+ }
665
+ /** append a string fragment to the destination string */
666
+ add(e, n, r) {
667
+ const s = g(this, O);
668
+ B(this, O, g(this, O) + e.length);
669
+ const o = g(this, O);
670
+ g(this, Y).push(e), g(this, W).push({
671
+ src: this.source,
672
+ srcStart: n,
673
+ srcEnd: r,
674
+ destStart: s,
675
+ destEnd: o
676
+ });
677
+ }
678
+ /**
679
+ * Append a fragment to the destination string,
680
+ * mapping source to the pervious,
681
+ * and guessing that the source fragment is just as long as the the dest fragment.
682
+ * (LATER we plan to drop or make optional src end positions)
683
+ */
684
+ appendNext(e) {
685
+ var r;
686
+ const n = ((r = g(this, W).at(-1)) == null ? void 0 : r.destEnd) ?? 0;
687
+ this.add(e, n, n + e.length);
688
+ }
689
+ addSynthetic(e, n, r, s) {
690
+ const o = g(this, O);
691
+ B(this, O, g(this, O) + e.length);
692
+ const i = g(this, O);
693
+ g(this, Y).push(e), g(this, W).push({
694
+ src: { text: n },
695
+ srcStart: r,
696
+ srcEnd: s,
697
+ destStart: o,
698
+ destEnd: i
699
+ });
700
+ }
701
+ /** append a synthetic newline, mapped to previous source location */
702
+ addNl() {
703
+ const e = g(this, W).at(-1) ?? { srcStart: 0, srcEnd: 0 }, { srcStart: n, srcEnd: r } = e;
704
+ this.add(`
705
+ `, n, r);
706
+ }
707
+ /** copy a string fragment from the src to the destination string */
708
+ addCopy(e, n) {
709
+ const r = this.source.text.slice(e, n);
710
+ this.add(r, e, n);
711
+ }
712
+ /** return a SrcMap */
713
+ static build(e) {
714
+ const n = new Yt(
715
+ { text: e.map((r) => g(r, Y).join("")).join("") },
716
+ e.flatMap((r) => g(r, W))
717
+ );
718
+ return n.compact(), n;
719
+ }
720
+ }
721
+ Y = new WeakMap(), O = new WeakMap(), W = new WeakMap();
722
+ class mr {
723
+ constructor(e) {
724
+ this.inner = e, this.cache = new hr(5);
725
+ }
726
+ checkpoint() {
727
+ return this.inner.checkpoint();
728
+ }
729
+ reset(e) {
730
+ this.inner.reset(e);
731
+ }
732
+ nextToken() {
733
+ const e = this.checkpoint(), n = this.cache.get(e);
734
+ if (n !== void 0)
735
+ return this.reset(n.checkpoint), n.token;
736
+ {
737
+ const r = this.inner.nextToken(), s = this.checkpoint();
738
+ return this.cache.set(e, { token: r, checkpoint: s }), r;
739
+ }
740
+ }
741
+ get src() {
742
+ return this.inner.src;
743
+ }
744
+ }
745
+ class hr extends Map {
746
+ constructor(e) {
747
+ super(), this.max = e;
748
+ }
749
+ set(e, n) {
750
+ if (this.size > this.max) {
751
+ const r = this.keys().next().value;
752
+ r && this.delete(r);
753
+ }
754
+ return super.set(e, n);
755
+ }
756
+ }
757
+ function gr(t) {
758
+ const [e, n] = t;
759
+ if (typeof n == "string") {
760
+ const r = `(${je(n)})`;
761
+ return xe(e, new RegExp(r)), r;
762
+ } else
763
+ return xe(e, n), `(${n.source})`;
764
+ }
765
+ function xe(t, e) {
766
+ if (new RegExp("|" + e.source).exec("").length > 1)
767
+ throw new Error(
768
+ `match expression groups must be non-capturing: ${t}: /${e.source}/. Use (?:...) instead.`
769
+ );
770
+ }
771
+ const br = /[$+*.?|(){}[\]\\/^]/g;
772
+ function je(t) {
773
+ return t.replace(br, "\\$&");
774
+ }
775
+ function Mt(t) {
776
+ const n = t.split(/\s+/).sort((r, s) => s.length - r.length).filter((r) => r).map(je);
777
+ return new RegExp(n.join("|"));
778
+ }
779
+ class xr {
780
+ constructor(e, n) {
781
+ this.text = e, this.matchers = n, this.position = 0;
782
+ }
783
+ checkpoint() {
784
+ return this.position;
785
+ }
786
+ reset(e) {
787
+ this.position = e;
788
+ }
789
+ nextToken() {
790
+ const e = this.matchers.execAt(this.text, this.position);
791
+ return e === null ? null : (this.position = e.span[1], e);
792
+ }
793
+ get src() {
794
+ return this.text;
795
+ }
796
+ }
797
+ class kr {
798
+ constructor(e) {
799
+ this.groups = Object.keys(e);
800
+ const n = Object.entries(e).map(gr).join("|");
801
+ this.exp = new RegExp(n, "dyu");
802
+ }
803
+ execAt(e, n) {
804
+ this.exp.lastIndex = n;
805
+ const r = this.exp.exec(e), s = _r(r == null ? void 0 : r.indices);
806
+ if (s) {
807
+ const { span: o, groupDex: i } = s;
808
+ return {
809
+ kind: this.groups[i],
810
+ span: o,
811
+ text: e.slice(o[0], o[1])
812
+ };
813
+ } else
814
+ return null;
815
+ }
816
+ }
817
+ function _r(t) {
818
+ if (t !== void 0)
819
+ for (let e = 1; e < t.length; e++) {
820
+ const n = t[e];
821
+ if (n !== void 0)
822
+ return { span: n, groupDex: e - 1 };
823
+ }
824
+ }
825
+ function j(t) {
826
+ throw new vr("Unreachable value", { data: t });
827
+ }
828
+ class vr extends Error {
829
+ constructor(e, n) {
830
+ super(e, n), this.data = n == null ? void 0 : n.data;
831
+ }
832
+ }
833
+ function yr(t) {
834
+ return t[t.length - 1];
835
+ }
836
+ function Zt(t, e) {
837
+ const n = [];
838
+ for (const r of t) {
839
+ const s = e(r);
840
+ s && n.push(s);
841
+ }
842
+ return n;
843
+ }
844
+ function Er(t, e) {
845
+ for (const n of t) {
846
+ const r = e(n);
847
+ if (r) return r;
848
+ }
849
+ }
850
+ function Sr(t, e) {
851
+ return Object.fromEntries(Object.entries(t).map(([n, r]) => [n, e(r)]));
852
+ }
853
+ function Qt(t, e) {
854
+ t = Math.min(e.length, Math.max(0, t));
855
+ let n = 0, r = 1;
856
+ for (; ; ) {
857
+ const s = e.indexOf(`
858
+ `, n);
859
+ if (s === -1 || t <= s) {
860
+ const o = 1 + (t - n);
861
+ return [r, o];
862
+ } else
863
+ n = s + 1, r += 1;
864
+ }
865
+ }
866
+ function De(t, e) {
867
+ let n = t.lastIndexOf(`
868
+ `, e[0]);
869
+ n === -1 && (n = 0);
870
+ let r = t.indexOf(`
871
+ `, e[0]);
872
+ r === -1 && (r = t.length);
873
+ const s = e[1] - e[0], o = Math.max(1, s), i = e[0] - n;
874
+ return [
875
+ t.slice(n, r),
876
+ " ".repeat(i) + "^".repeat(o)
877
+ ];
878
+ }
879
+ function Oe(t, e) {
880
+ const n = t.attributes;
881
+ if (!n) return !0;
882
+ const r = Er(n, wr);
883
+ return !r || qe(r);
884
+ }
885
+ function Fe(t, e) {
886
+ const { ifAttribute: n } = t;
887
+ return n ? qe(n) : !0;
888
+ }
889
+ function wr(t) {
890
+ const { attribute: e } = t;
891
+ return e.kind === "@if" ? e : void 0;
892
+ }
893
+ function qe(t, e) {
894
+ return K(t.param.expression);
895
+ }
896
+ function K(t, e) {
897
+ const { kind: n } = t;
898
+ if (n == "unary-expression")
899
+ return t.operator.value, !K(t.expression);
900
+ if (n == "binary-expression") {
901
+ const r = t.operator.value, s = K(t.left);
902
+ if (r === "||")
903
+ return s || K(t.right);
904
+ if (r === "&&")
905
+ return s && K(t.right);
906
+ j(r);
907
+ } else if (n == "literal") {
908
+ const { value: r } = t;
909
+ return r === "true";
910
+ } else {
911
+ if (n == "parenthesized-expression")
912
+ return K(t.expression);
913
+ throw new Error("unexpected @if expression ${expression}");
914
+ }
915
+ }
916
+ function ke(t, e) {
917
+ t.kind, e.kind, t.parent, e.parent, e.ifAttribute, t.contents = t.contents.concat(e.contents);
918
+ }
919
+ function Tr() {
920
+ Ue = 0, We = 0;
921
+ }
922
+ let Ue = 0, We = 0;
923
+ function te() {
924
+ return We++;
925
+ }
926
+ function Ve(t, e = "scope") {
927
+ return { id: Ue++, kind: e, parent: t, contents: [] };
928
+ }
929
+ function Pr(t) {
930
+ const { kind: e } = t;
931
+ return e === "partial" || e === "scope";
932
+ }
933
+ function ze(t, e, n) {
934
+ for (const r of t.contents) {
935
+ if (r.kind === "decl" && r.originalName === e)
936
+ return r;
937
+ if (r.kind === "partial" && Fe(r)) {
938
+ const s = ze(r, e);
939
+ if (s) return s;
940
+ }
941
+ }
942
+ }
943
+ var F, V, ct, lt, Z, ut;
944
+ class ee {
945
+ constructor(e = 0, n = 60, r = 2) {
946
+ I(this, F, []);
947
+ I(this, V, 0);
948
+ I(this, ct);
949
+ I(this, lt, !0);
950
+ I(this, Z, !1);
951
+ I(this, ut);
952
+ this.indent = e, this.maxWidth = n, this.hangingIndent = r, B(this, ct, " ".repeat(e)), B(this, ut, " ".repeat(r));
953
+ }
954
+ /** add a new line to the constructed string */
955
+ nl() {
956
+ g(this, F).push(`
957
+ `), B(this, V, 0), B(this, lt, !1), B(this, Z, !1);
958
+ }
959
+ /** add a string, wrapping to the next line if necessary */
960
+ add(e) {
961
+ g(this, V) + $r(e) > this.maxWidth && this.hangingNl(), g(this, V) === 0 && (g(this, F).push(g(this, ct)), g(this, Z) && g(this, F).push(g(this, ut)), B(this, V, this.indent)), g(this, F).push(e), B(this, V, g(this, V) + e.length);
962
+ }
963
+ /** add a raw block of text with no wrapping */
964
+ addBlock(e, n = !0) {
965
+ g(this, F).push(e), n && this.nl();
966
+ }
967
+ /** @return the constructed string */
968
+ get result() {
969
+ return g(this, F).join("");
970
+ }
971
+ /** true if the result contains no newlines */
972
+ get oneLine() {
973
+ return g(this, lt);
974
+ }
975
+ hangingNl() {
976
+ this.nl(), B(this, Z, !0);
977
+ }
978
+ }
979
+ F = new WeakMap(), V = new WeakMap(), ct = new WeakMap(), lt = new WeakMap(), Z = new WeakMap(), ut = new WeakMap();
980
+ function $r(t) {
981
+ const e = t.indexOf(`
982
+ `);
983
+ return e === -1 ? t.length : e;
984
+ }
985
+ function Ge(t, e = 0, n = !0) {
986
+ const { contents: r, kind: s, ifAttribute: o } = t, i = new ee(e), a = o && si(o);
987
+ a && i.add(a + " "), s === "partial" && i.add("-"), i.add("{ ");
988
+ const l = r.length - 1;
989
+ let c = !1, d = !1;
990
+ return r.forEach((p, h) => {
991
+ if (Pr(p)) {
992
+ const P = Ge(p, e + 2, n);
993
+ !c && i.nl(), i.addBlock(P), c = !0, d = !0;
994
+ } else {
995
+ c && i.add(" "), c = !1;
996
+ const x = p;
997
+ n ? i.add(Nr(x)) : i.add(Ct(x)), h < l && i.add(" ");
998
+ }
999
+ }), !d && i.oneLine ? i.add(" }") : (d && !c && i.nl(), i.add("}")), i.add(` #${t.id}`), i.result;
1000
+ }
1001
+ function Wi(t) {
1002
+ return Ge(t, 0, !1);
1003
+ }
1004
+ function Nr(t) {
1005
+ const { kind: e, originalName: n } = t;
1006
+ return `${e === "decl" ? "%" : ""}${n}`;
1007
+ }
1008
+ function Ct(t) {
1009
+ if (!t) return JSON.stringify(t);
1010
+ const { kind: e, originalName: n } = t, r = t.id ? `#${t.id}` : "";
1011
+ if (e === "ref") {
1012
+ const s = Ct(t.refersTo);
1013
+ return `${n} ${r} -> ${s}`;
1014
+ } else {
1015
+ const { mangledName: s } = t, o = s ? `(${s})` : "";
1016
+ return `%${n}${o} ${r} `;
1017
+ }
1018
+ }
1019
+ function Xe(t = null) {
1020
+ return { decls: /* @__PURE__ */ new Map(), parent: t };
1021
+ }
1022
+ function Mr(t, e, n, r) {
1023
+ return Je(n, r);
1024
+ }
1025
+ function Je(t, e) {
1026
+ let n = t, r = 0;
1027
+ for (; e.has(n); )
1028
+ n = t + r++;
1029
+ return n;
1030
+ }
1031
+ function Cr(t) {
1032
+ return e([], [], t.segments, t.finalSegment);
1033
+ function e(n, r, s, o) {
1034
+ if (s.length > 0) {
1035
+ const [i, ...a] = s, l = [...n, i.name], c = [...r, i.name];
1036
+ return e(l, c, a, o);
1037
+ } else {
1038
+ if (o.kind === "import-collection")
1039
+ return o.subtrees.flatMap((i) => e(
1040
+ n,
1041
+ r,
1042
+ i.segments,
1043
+ i.finalSegment
1044
+ ));
1045
+ if (o.kind === "import-item") {
1046
+ const i = [
1047
+ ...n,
1048
+ o.as ?? o.name
1049
+ ], a = [...r, o.name];
1050
+ return [{ importPath: i, modulePath: a }];
1051
+ } else
1052
+ j(o);
1053
+ }
1054
+ }
1055
+ }
1056
+ var Ar = Br((t) => " ".repeat(t)), Rr = 20;
1057
+ "" + Ar(Rr + 3);
1058
+ function Br(t) {
1059
+ const e = /* @__PURE__ */ new Map();
1060
+ return function(...n) {
1061
+ const r = JSON.stringify(n);
1062
+ if (e.has(r))
1063
+ return e.get(r);
1064
+ {
1065
+ const s = t(...n);
1066
+ return e.set(r, s), s;
1067
+ }
1068
+ };
1069
+ }
1070
+ typeof DOMRect > "u" && (globalThis.DOMRect = function() {
1071
+ });
1072
+ function Ir(t) {
1073
+ var n;
1074
+ const e = (n = t.tags.owo) == null ? void 0 : n[0];
1075
+ for (const r of e)
1076
+ t.app.stable.imports.push(r.imports), et(t, r);
1077
+ }
1078
+ function et(t, e) {
1079
+ const n = t.app.context, { openElems: r } = n;
1080
+ r && r.length && r[r.length - 1].contents.push(e);
1081
+ }
1082
+ function dt(t) {
1083
+ const { src: e, start: n, end: r } = t, s = t.app, { srcModule: o } = s.stable, i = e.slice(n, r), a = "ref", l = {
1084
+ kind: a,
1085
+ originalName: i,
1086
+ ast: t.app.stable,
1087
+ id: te(),
1088
+ refIdentElem: null
1089
+ // set below
1090
+ }, c = { kind: a, start: n, end: r, srcModule: o, ident: l };
1091
+ return l.refIdentElem = c, Ye(t, c), et(t, c), c;
1092
+ }
1093
+ function Ke(t) {
1094
+ return He(t, !1);
1095
+ }
1096
+ function At(t) {
1097
+ return He(t, !0);
1098
+ }
1099
+ function He(t, e) {
1100
+ const { src: n, start: r, end: s } = t, o = t.app, { scope: i } = o.context, { srcModule: a } = o.stable, l = n.slice(r, s), c = "decl", p = {
1101
+ declElem: null,
1102
+ kind: c,
1103
+ originalName: l,
1104
+ scope: i,
1105
+ isGlobal: e,
1106
+ id: te(),
1107
+ srcModule: a
1108
+ }, h = { kind: c, start: r, end: s, srcModule: a, ident: p };
1109
+ return Ye(t, h), et(t, h), h;
1110
+ }
1111
+ const ne = S(
1112
+ "typeDecl",
1113
+ (t, e) => {
1114
+ var i, a;
1115
+ const n = (i = t.tags.decl_elem) == null ? void 0 : i[0], r = (a = t.tags.typeRefElem) == null ? void 0 : a[0], s = { ...e, decl: n, typeRef: r };
1116
+ return A(s, t);
1117
+ }
1118
+ );
1119
+ function Ye(t, e) {
1120
+ const { ident: n } = e;
1121
+ n.id = te(), t.app.context.scope.contents.push(n);
1122
+ }
1123
+ function Lr(t) {
1124
+ Ze("scope", t);
1125
+ }
1126
+ function jr(t) {
1127
+ Ze("partial", t);
1128
+ }
1129
+ function Ze(t, e) {
1130
+ const { scope: n } = e.app.context, r = Ve(n, t);
1131
+ n.contents.push(r), e.app.context.scope = r;
1132
+ }
1133
+ function Qe(t) {
1134
+ const e = t.app.context, n = e.scope, r = Dr(t), { parent: s } = n;
1135
+ return s && (e.scope = s), n.ifAttribute = r == null ? void 0 : r[0], n;
1136
+ }
1137
+ function Dr(t) {
1138
+ const e = t.tags.attribute;
1139
+ return tn(e);
1140
+ }
1141
+ function tn(t) {
1142
+ if (t)
1143
+ return Zt(
1144
+ t,
1145
+ (e) => e.attribute.kind === "@if" ? e.attribute : void 0
1146
+ );
1147
+ }
1148
+ function kt(t) {
1149
+ return S(t, (e, n) => {
1150
+ var l, c;
1151
+ const r = (l = e.tags.var_name) == null ? void 0 : l[0], s = (c = e.tags.decl_scope) == null ? void 0 : c[0], o = e.tags.attribute, i = { ...n, name: r, attributes: o }, a = A(i, e);
1152
+ return r.decl.ident.declElem = a, r.decl.ident.scope = s, a;
1153
+ });
1154
+ }
1155
+ const Or = S(
1156
+ "alias",
1157
+ (t, e) => {
1158
+ var l, c, d, p;
1159
+ const n = (l = t.tags.alias_name) == null ? void 0 : l[0], r = (c = t.tags.alias_scope) == null ? void 0 : c[0], s = (d = t.tags.typeRefElem) == null ? void 0 : d[0], o = ((p = t.tags.attributes) == null ? void 0 : p.flat()) ?? [], i = { ...e, name: n, attributes: o, typeRef: s }, a = A(i, t);
1160
+ return n.ident.scope = r, n.ident.declElem = a, a;
1161
+ }
1162
+ ), Fr = S(
1163
+ "fn",
1164
+ (t, e) => {
1165
+ var U;
1166
+ const n = qr(t), { name: r, headerScope: s, returnScope: o, bodyScope: i, body: a, params: l } = n, { attributes: c, returnAttributes: d, returnType: p, fnScope: h } = n, x = {
1167
+ ...e,
1168
+ name: r,
1169
+ attributes: c,
1170
+ params: l,
1171
+ returnAttributes: d,
1172
+ body: a,
1173
+ returnType: p
1174
+ };
1175
+ h.ifAttribute = (U = tn(c)) == null ? void 0 : U[0];
1176
+ const P = s;
1177
+ o && ke(P, o), ke(P, i);
1178
+ const R = [];
1179
+ for (const w of h.contents)
1180
+ w === s || w == o || (w === i ? R.push(P) : R.push(w));
1181
+ return h.contents = R, r.ident.declElem = x, r.ident.scope = P, x;
1182
+ }
1183
+ );
1184
+ function qr(t) {
1185
+ const { fn_attributes: e, fn_name: n, fn_param: r, return_attributes: s } = t.tags, { return_type: o } = t.tags, { header_scope: i, return_scope: a, body_scope: l, body_statement: c } = t.tags, { fn_partial_scope: d } = t.tags, p = n == null ? void 0 : n[0], h = i == null ? void 0 : i[0], x = a == null ? void 0 : a[0], P = l == null ? void 0 : l[0], R = c == null ? void 0 : c[0], U = (r == null ? void 0 : r.flat(3)) ?? [], w = e == null ? void 0 : e.flat(), Dn = s == null ? void 0 : s.flat(), On = o == null ? void 0 : o.flat(3)[0], Fn = d == null ? void 0 : d[0];
1186
+ return {
1187
+ name: p,
1188
+ headerScope: h,
1189
+ returnScope: x,
1190
+ bodyScope: P,
1191
+ body: R,
1192
+ params: U,
1193
+ attributes: w,
1194
+ returnAttributes: Dn,
1195
+ returnType: On,
1196
+ fnScope: Fn
1197
+ };
1198
+ }
1199
+ const Ur = S(
1200
+ "param",
1201
+ (t, e) => {
1202
+ var i, a;
1203
+ const n = (i = t.tags.param_name) == null ? void 0 : i[0], r = ((a = t.tags.attributes) == null ? void 0 : a.flat()) ?? [], s = { ...e, name: n, attributes: r }, o = A(s, t);
1204
+ return n.decl.ident.declElem = o, o;
1205
+ }
1206
+ ), Wr = S(
1207
+ "struct",
1208
+ (t, e) => {
1209
+ var a, l, c;
1210
+ const n = (a = t.tags.type_name) == null ? void 0 : a[0], r = t.tags.members, s = ((l = t.tags.attributes) == null ? void 0 : l.flat()) ?? [];
1211
+ n.ident.scope = (c = t.tags.struct_scope) == null ? void 0 : c[0];
1212
+ const o = { ...e, name: n, attributes: s, members: r }, i = A(o, t);
1213
+ return n.ident.declElem = i, i;
1214
+ }
1215
+ ), Vr = S(
1216
+ "member",
1217
+ (t, e) => {
1218
+ var i, a, l;
1219
+ const n = (i = t.tags.nameElem) == null ? void 0 : i[0], r = (a = t.tags.typeRefElem) == null ? void 0 : a[0], s = (l = t.tags.attribute) == null ? void 0 : l.flat(3), o = { ...e, name: n, attributes: s, typeRef: r };
1220
+ return A(o, t);
1221
+ }
1222
+ ), en = S(
1223
+ "attribute",
1224
+ (t, e) => {
1225
+ var s;
1226
+ const n = (s = t.tags.attr_variant) == null ? void 0 : s[0];
1227
+ return { ...e, attribute: n };
1228
+ }
1229
+ ), zr = re("assert"), ot = re("statement"), Gr = re("switch-clause");
1230
+ function re(t) {
1231
+ return S(t, (e, n) => {
1232
+ var o;
1233
+ const r = (o = e.tags.attribute) == null ? void 0 : o.flat(3), s = { ...n, attributes: r };
1234
+ return A(s, e);
1235
+ });
1236
+ }
1237
+ const Xr = S(
1238
+ "attribute",
1239
+ (t, e) => {
1240
+ var a;
1241
+ const n = t.tags.attrParam, o = { kind: "@attribute", name: (a = t.tags.name) == null ? void 0 : a[0], params: n };
1242
+ return { ...e, attribute: o };
1243
+ }
1244
+ ), Jr = S(
1245
+ "type",
1246
+ // @ts-ignore
1247
+ (t, e) => {
1248
+ var i, a;
1249
+ let n = (i = t.tags.templateParam) == null ? void 0 : i.flat(3);
1250
+ const r = (a = t.tags.typeRefName) == null ? void 0 : a[0], s = typeof r == "string" ? r : r.ident, o = {
1251
+ ...e,
1252
+ name: s,
1253
+ templateParams: n
1254
+ };
1255
+ return A(o, t);
1256
+ }
1257
+ ), nn = S(
1258
+ "expression",
1259
+ (t, e) => {
1260
+ const n = { ...e };
1261
+ return A(n, t);
1262
+ }
1263
+ );
1264
+ function Kr(t) {
1265
+ var r;
1266
+ const e = (r = t.tags.const_assert) == null ? void 0 : r.flat()[0], n = t.app.stable;
1267
+ n.moduleAsserts || (n.moduleAsserts = []), n.moduleAsserts.push(e);
1268
+ }
1269
+ const Hr = S(
1270
+ "stuff",
1271
+ (t, e) => {
1272
+ const n = { ...e };
1273
+ return A(n, t);
1274
+ }
1275
+ ), Yr = S(
1276
+ "memberRef",
1277
+ (t, e) => {
1278
+ const { component: n, structRef: r, extra_components: s } = t.tags, o = n[0], i = r == null ? void 0 : r.flat()[0], a = s == null ? void 0 : s.flat()[0], l = {
1279
+ ...e,
1280
+ name: i,
1281
+ member: o,
1282
+ extraComponents: a
1283
+ };
1284
+ return A(l, t);
1285
+ }
1286
+ );
1287
+ function rn(t) {
1288
+ const { start: e, end: n, src: r, app: s } = t, o = r.slice(e, n), i = { kind: "name", start: e, end: n, name: o };
1289
+ return et(t, i), i;
1290
+ }
1291
+ const Zr = S(
1292
+ "module",
1293
+ (t, e) => {
1294
+ const n = { ...t, start: 0, end: t.src.length }, r = A(e, n), s = t.app.stable;
1295
+ return s.moduleElem = r, r;
1296
+ }
1297
+ );
1298
+ function Qr(t) {
1299
+ var a, l;
1300
+ const { start: e, end: n } = t, r = (a = t.tags.directive) == null ? void 0 : a.flat()[0], i = { kind: "directive", attributes: (l = t.tags.attribute) == null ? void 0 : l.flat(), start: e, end: n, directive: r };
1301
+ return et(t, i), i;
1302
+ }
1303
+ const C = {
1304
+ before: Lr,
1305
+ after: Qe
1306
+ }, sn = {
1307
+ before: jr,
1308
+ after: Qe
1309
+ };
1310
+ function S(t, e) {
1311
+ return {
1312
+ before: (n) => {
1313
+ const r = { kind: t, contents: [] };
1314
+ n.app.context.openElems.push(r);
1315
+ },
1316
+ after: (n) => {
1317
+ const s = n.app.context.openElems.pop();
1318
+ console.assert(s && s.kind === t);
1319
+ const o = e(n, { ...s, start: n.start, end: n.end });
1320
+ return o && et(n, o), o;
1321
+ }
1322
+ };
1323
+ }
1324
+ function A(t, e) {
1325
+ const n = ts(e, t);
1326
+ return { ...t, contents: n };
1327
+ }
1328
+ function ts(t, e) {
1329
+ let { start: n } = t;
1330
+ const r = t.app.stable, { contents: s, end: o } = e, i = s.sort((c, d) => c.start - d.start), a = [];
1331
+ for (const c of i)
1332
+ n < c.start && a.push(l(c.start)), a.push(c), n = c.end;
1333
+ return n < o && a.push(l(o)), a;
1334
+ function l(c) {
1335
+ return { kind: "text", start: n, end: c, srcModule: r.srcModule };
1336
+ }
1337
+ }
1338
+ const M = zt("word");
1339
+ zt("keyword");
1340
+ const ft = $t("::", m(M, "package", "super")), es = zt("number");
1341
+ function Ot(t, e) {
1342
+ return { kind: "import-statement", segments: t, finalSegment: e };
1343
+ }
1344
+ function _t(t) {
1345
+ return { kind: "import-segment", name: t };
1346
+ }
1347
+ function ns(t) {
1348
+ return {
1349
+ kind: "import-collection",
1350
+ subtrees: t
1351
+ };
1352
+ }
1353
+ function _e(t, e) {
1354
+ return { kind: "import-item", name: t, as: e };
1355
+ }
1356
+ function on(t, e) {
1357
+ return e.segments = t.concat(e.segments), e;
1358
+ }
1359
+ let se = null;
1360
+ const oe = u(
1361
+ M,
1362
+ m(
1363
+ N(
1364
+ "::",
1365
+ f(
1366
+ m(
1367
+ z(() => se),
1368
+ z(() => oe)
1369
+ ),
1370
+ "invalid import, expected '{' or name"
1371
+ )
1372
+ ),
1373
+ N("as", f(M, "invalid alias, expected name")).map(
1374
+ (t) => _e("", t)
1375
+ ),
1376
+ xt().map(() => _e(""))
1377
+ // Optional
1378
+ )
1379
+ ).map(([t, e]) => {
1380
+ if (e.kind === "import-collection")
1381
+ return Ot([_t(t)], e);
1382
+ if (e.kind === "import-statement")
1383
+ return on([_t(t)], e);
1384
+ if (e.kind === "import-item")
1385
+ return e.name = t, Ot([], e);
1386
+ j(e);
1387
+ });
1388
+ se = q(
1389
+ "{",
1390
+ $t(",", () => oe).map(ns),
1391
+ f("}", "invalid import collection, expected }")
1392
+ );
1393
+ const rs = m(
1394
+ Dt("package", f("::", "invalid import, expected '::'")).map((t) => [
1395
+ _t(t)
1396
+ ]),
1397
+ L(
1398
+ Dt("super", f("::", "invalid import, expected '::'")).map(
1399
+ _t
1400
+ )
1401
+ )
1402
+ ), ss = Gt(
1403
+ q(
1404
+ "import",
1405
+ Hn({
1406
+ relative: b(rs),
1407
+ collection_or_statement: f(
1408
+ m(se, oe),
1409
+ "invalid import, expected { or name"
1410
+ )
1411
+ }).map(({ relative: t, collection_or_statement: e }) => e.kind === "import-statement" ? on(t ?? [], e) : Ot(t ?? [], e)),
1412
+ f(";", "invalid import, expected ';'")
1413
+ )
1414
+ ).map(
1415
+ (t) => ({
1416
+ kind: "import",
1417
+ imports: t.value,
1418
+ start: t.span[0],
1419
+ end: t.span[1]
1420
+ })
1421
+ ), os = _(
1422
+ T(ss).ptag("owo").collect(Ir)
1423
+ ), is = `alias break case const const_assert continue continuing
1424
+ default diagnostic discard else enable false fn for if
1425
+ let loop override requires return struct switch true var while`.split(/\s+/), as = `NULL Self abstract active alignas alignof as asm asm_fragment async attribute auto await
1426
+ become binding_array cast catch class co_await co_return co_yield coherent column_major
1427
+ common compile compile_fragment concept const_cast consteval constexpr constinit crate
1428
+ debugger decltype delete demote demote_to_helper do dynamic_cast
1429
+ enum explicit export extends extern external fallthrough filter final finally friend from fxgroup
1430
+ get goto groupshared highp impl implements import inline instanceof interface layout lowp
1431
+ macro macro_rules match mediump meta mod module move mut mutable
1432
+ namespace new nil noexcept noinline nointerpolation non_coherent noncoherent noperspective null nullptr
1433
+ of operator package packoffset partition pass patch pixelfragment precise precision premerge
1434
+ priv protected pub public readonly ref regardless register reinterpret_cast require resource restrict
1435
+ self set shared sizeof smooth snorm static static_assert static_cast std subroutine super
1436
+ target template this thread_local throw trait try type typedef typeid typename typeof
1437
+ union unless unorm unsafe unsized use using varying virtual volatile wgsl where with writeonly yield`.split(
1438
+ /\s+/
1439
+ ), cs = /[ \t\n\v\f\r\u{0085}\u{200E}\u{200F}\u{2028}\u{2029}]+/u, ls = "& && -> @ / ! [ ] { } :: : , == = != >>= >> >= > <<= << <= < % - -- . + ++ | || ( ) ; * ~ ^ // /* */ += -= *= /= %= &= |= ^= _", us = /(?:(?:[_\p{XID_Start}][\p{XID_Continue}]+)|(?:[\p{XID_Start}]))/u, ds = new Set(is.concat(as)), fs = new RegExp(
1440
+ // decimal_float_literal
1441
+ /(?:0[fh])|(?:[1-9][0-9]*[fh])/.source + /|(?:[0-9]*\.[0-9]+(?:[eE][+-]?[0-9]+)?[fh]?)/.source + /|(?:[0-9]+\.[0-9]*(?:[eE][+-]?[0-9]+)?[fh]?)/.source + /|(?:[0-9]+[eE][+-]?[0-9]+[fh]?)/.source + // hex_float_literal
1442
+ /|(?:0[xX][0-9a-fA-F]*\.[0-9a-fA-F]+(?:[pP][+-]?[0-9]+[fh]?)?)/.source + /|(?:0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*(?:[pP][+-]?[0-9]+[fh]?)?)/.source + /|(?:0[xX][0-9a-fA-F]+[pP][+-]?[0-9]+[fh]?)/.source + // hex_int_literal
1443
+ /|(?:0[xX][0-9a-fA-F]+[iu]?)/.source + // decimal_int_literal
1444
+ /|(?:0[iu]?)|(?:[1-9][0-9]*[iu]?)/.source
1445
+ ), ps = /\/\/|\/\*/, ms = new kr({
1446
+ word: us,
1447
+ number: fs,
1448
+ blankspaces: cs,
1449
+ commentStart: ps,
1450
+ symbol: Mt(ls),
1451
+ invalid: /[^]/
1452
+ });
1453
+ class hs {
1454
+ constructor(e) {
1455
+ this.src = e, this.eolPattern = /[\n\v\f\u{0085}\u{2028}\u{2029}]|\r\n?/gu, this.blockCommentPattern = /\/\*|\*\//g, this.stream = new mr(new xr(e, ms));
1456
+ }
1457
+ checkpoint() {
1458
+ return this.stream.checkpoint();
1459
+ }
1460
+ reset(e) {
1461
+ this.stream.reset(e);
1462
+ }
1463
+ nextToken() {
1464
+ for (; ; ) {
1465
+ const e = this.stream.nextToken();
1466
+ if (e === null) return null;
1467
+ const n = e.kind;
1468
+ if (n !== "blankspaces")
1469
+ if (n === "commentStart")
1470
+ e.text === "//" ? this.stream.reset(this.skipToEol(e.span[1])) : this.stream.reset(this.skipBlockComment(e.span[1]));
1471
+ else if (n === "word") {
1472
+ let r = e;
1473
+ return ds.has(e.text) && (r.kind = "keyword"), r;
1474
+ } else {
1475
+ if (n === "invalid")
1476
+ throw new H(
1477
+ "Invalid token " + e.text,
1478
+ this.stream.checkpoint()
1479
+ );
1480
+ return e;
1481
+ }
1482
+ }
1483
+ }
1484
+ skipToEol(e) {
1485
+ return this.eolPattern.lastIndex = e, this.eolPattern.exec(this.src) === null ? this.src.length : this.eolPattern.lastIndex;
1486
+ }
1487
+ skipBlockComment(e) {
1488
+ for (; ; ) {
1489
+ this.blockCommentPattern.lastIndex = e;
1490
+ const n = this.blockCommentPattern.exec(this.src);
1491
+ if (n === null)
1492
+ throw new H("Unclosed block comment!", e);
1493
+ if (n[0] === "*/")
1494
+ return this.blockCommentPattern.lastIndex;
1495
+ if (n[0] === "/*")
1496
+ e = this.skipBlockComment(this.blockCommentPattern.lastIndex);
1497
+ else
1498
+ throw new Error("Unreachable, invalid block comment pattern");
1499
+ }
1500
+ }
1501
+ /**
1502
+ * Only matches the `<` token if it is a template
1503
+ * Precondition: An ident was parsed right before this.
1504
+ * Runs the [template list discovery algorithm](https://www.w3.org/TR/WGSL/#template-list-discovery).
1505
+ */
1506
+ nextTemplateStartToken() {
1507
+ const e = this.stream.checkpoint(), n = this.nextToken();
1508
+ return this.stream.reset(e), n === null || n.kind !== "symbol" ? null : n.text === "<" ? this.isTemplateStart(n.span[1]) ? (this.stream.reset(n.span[1]), n) : (this.stream.reset(e), null) : null;
1509
+ }
1510
+ nextTemplateEndToken() {
1511
+ const e = this.stream.checkpoint(), n = this.nextToken();
1512
+ if (this.stream.reset(e), n === null) return null;
1513
+ if (n.kind === "symbol" && n.text[0] === ">") {
1514
+ const r = n.span[0];
1515
+ return this.stream.reset(r + 1), {
1516
+ kind: "symbol",
1517
+ span: [r, r + 1],
1518
+ text: ">"
1519
+ };
1520
+ } else
1521
+ return null;
1522
+ }
1523
+ isTemplateStart(e) {
1524
+ this.stream.reset(e);
1525
+ let n = 1;
1526
+ for (; ; ) {
1527
+ const r = this.stream.nextToken();
1528
+ if (r === null) return !1;
1529
+ if (r.kind === "symbol") {
1530
+ if (r.text === "<")
1531
+ n += 1;
1532
+ else if (r.text[0] === ">") {
1533
+ if (r.text === ">" || r.text == ">=")
1534
+ n -= 1;
1535
+ else if (r.text === ">>=" || r.text === ">>")
1536
+ n -= 2;
1537
+ else
1538
+ throw new Error(
1539
+ "This case should never be reached, looks like we forgot one of the tokens that start with >"
1540
+ );
1541
+ if (n <= 0)
1542
+ return !0;
1543
+ } else if (r.text === "(")
1544
+ this.skipBracketsTo(")");
1545
+ else if (r.text === "[")
1546
+ this.skipBracketsTo("]");
1547
+ else if (r.text === "==" || r.text === "!=" || r.text === ";" || r.text === "{" || r.text === ":" || r.text === "&&" || r.text === "||")
1548
+ return !1;
1549
+ }
1550
+ }
1551
+ }
1552
+ /**
1553
+ * Call this after consuming an opening bracket.
1554
+ * Skips until a closing bracket. This also consumes the closing bracket.
1555
+ */
1556
+ skipBracketsTo(e) {
1557
+ for (; ; ) {
1558
+ const n = this.stream.nextToken();
1559
+ if (n === null)
1560
+ throw new H("Unclosed bracket!", this.stream.checkpoint());
1561
+ if (n.kind === "symbol") {
1562
+ if (n.text === "(")
1563
+ this.skipBracketsTo(")");
1564
+ else if (n.text === "[")
1565
+ this.skipBracketsTo("]");
1566
+ else if (n.text === e)
1567
+ return;
1568
+ }
1569
+ }
1570
+ }
1571
+ }
1572
+ const gs = Re((t) => t.nextTemplateStartToken()), bs = Re((t) => t.nextTemplateEndToken()), pt = b(
1573
+ u(
1574
+ gs,
1575
+ $t(",", () => $s),
1576
+ f(bs, "invalid template, expected '>'")
1577
+ )
1578
+ ), xs = u(
1579
+ ft.collect(dt),
1580
+ pt
1581
+ ), ks = m("true", "false", es), _s = u(
1582
+ "(",
1583
+ () => v,
1584
+ f(")", "invalid expression, expected ')'")
1585
+ ), vs = m(
1586
+ ks,
1587
+ _s,
1588
+ u(xs, b(z(() => ln)))
1589
+ ), vt = L(
1590
+ m(
1591
+ N(".", M),
1592
+ Yn(
1593
+ q(
1594
+ "[",
1595
+ () => v,
1596
+ f("]", "invalid expression, expected ']'")
1597
+ )
1598
+ )
1599
+ )
1600
+ ), an = _(
1601
+ u(
1602
+ ft.collect(dt, "structRef"),
1603
+ u(".", M.collect(rn, "component")),
1604
+ b(vt.collect(Hr, "extra_components"))
1605
+ ).collect(Yr)
1606
+ ), $ = m(
1607
+ u(bt("symbol", ["!", "&", "*", "-", "~"]), () => $),
1608
+ m(
1609
+ an,
1610
+ u(vs, b(vt))
1611
+ )
1612
+ ), ys = m(
1613
+ // LATER I can skip template list discovery in these cases, because a&b<c cannot be a comparison. Must be a template
1614
+ L(u("&", $)),
1615
+ L(u("^", $)),
1616
+ L(u("|", $))
1617
+ ), ve = m("%", "*", "/"), Es = m("+", "-"), ye = (t) => {
1618
+ const e = u("<<", $), n = u(">>", $), r = u(
1619
+ T(u(ve, $)),
1620
+ T(
1621
+ u(
1622
+ Es,
1623
+ $,
1624
+ T(u(ve, $))
1625
+ )
1626
+ )
1627
+ );
1628
+ return t ? m(e, r) : m(e, n, r);
1629
+ }, It = (t) => u(
1630
+ ye(t),
1631
+ b(
1632
+ u(
1633
+ // '<' is unambiguous, since templates were already caught by the primary expression inside of the previous unary_expression!
1634
+ t ? bt("symbol", ["<", "<=", "!=", "=="]) : bt("symbol", [">", ">=", "<", "<=", "!=", "=="]),
1635
+ // LATER I can skip template list discovery in this cases, because a>=b<c cannot be a comparison. Must be a template
1636
+ $,
1637
+ ye(t)
1638
+ )
1639
+ )
1640
+ ), cn = (t) => u(
1641
+ $,
1642
+ m(
1643
+ ys,
1644
+ u(
1645
+ It(t),
1646
+ t ? (
1647
+ // Don't accept || or && in template mode
1648
+ xt()
1649
+ ) : m(
1650
+ L(
1651
+ u("||", u($, It(!1)))
1652
+ ),
1653
+ L(
1654
+ u("&&", u($, It(!1)))
1655
+ ),
1656
+ xt().map(() => [])
1657
+ )
1658
+ )
1659
+ )
1660
+ );
1661
+ let Ss = !1;
1662
+ const v = cn(Ss);
1663
+ let ws = !0;
1664
+ const Ts = cn(ws), Ps = u(
1665
+ ft.collect(dt, "typeRefName"),
1666
+ () => pt
1667
+ ).collect(Jr), J = _(
1668
+ Ps
1669
+ ).ctag("typeRefElem"), $s = m(
1670
+ // LATER Remove this, it's wrong. This should instead be done by inspecting the syntax tree.
1671
+ J.ctag("templateParam"),
1672
+ Ts.collect(nn, "templateParam")
1673
+ ), ln = u(
1674
+ "(",
1675
+ tt(",", v),
1676
+ f(")", "invalid fn arguments, expected ')'")
1677
+ ), it = Ae("word").map(bo), Ns = u(
1678
+ it,
1679
+ b(N(".", f(it, "invalid diagnostic rule name, expected name")))
1680
+ ), un = q(
1681
+ "(",
1682
+ f(
1683
+ Zn(it, ",", Ns),
1684
+ "invalid diagnostic control, expected rule name"
1685
+ ),
1686
+ u(b(","), f(")", "invalid diagnostic control, expected ')'"))
1687
+ ), Ft = tt(",", it, { requireOne: !0 }), dn = _(
1688
+ N(
1689
+ "@",
1690
+ m(
1691
+ // These attributes have no arguments
1692
+ m("compute", "const", "fragment", "invariant", "must_use", "vertex").map((t) => uo([t, []])),
1693
+ // These attributes have arguments, but the argument doesn't have any identifiers
1694
+ N("interpolate", f(q("(", Ft, ")"), "invalid @interpolate, expected '('")).map(fo),
1695
+ N("builtin", f(q("(", it, ")"), "invalid @builtin, expected '('")).map(po),
1696
+ N("diagnostic", f(un, "invalid @diagnostic, expected '('")).map(mo)
1697
+ ).ptag("attr_variant")
1698
+ ).collect(en)
1699
+ ), Ms = _(
1700
+ N(
1701
+ u("@", "if"),
1702
+ Gt(
1703
+ q(
1704
+ "(",
1705
+ z(() => pn),
1706
+ u(b(","), ")")
1707
+ )
1708
+ ).map(go)
1709
+ ).map(ho).ptag("attr_variant").collect(en)
1710
+ ), fn = _(
1711
+ N(
1712
+ "@",
1713
+ m(
1714
+ // These are normal attributes, with required arguments
1715
+ u(
1716
+ m(
1717
+ "workgroup_size",
1718
+ "align",
1719
+ "binding",
1720
+ "blend_src",
1721
+ "group",
1722
+ "id",
1723
+ "location",
1724
+ "size"
1725
+ ).ptag("name"),
1726
+ f(() => Ee, "invalid attribute, expected '('")
1727
+ ),
1728
+ // Everything else is also a normal attribute, optional expression list
1729
+ u(
1730
+ // we don't want this to interfere with if_attribute,
1731
+ // but not("if") isn't necessary for now, since 'if' is a keyword, not a word
1732
+ M.ptag("name"),
1733
+ b(() => Ee)
1734
+ )
1735
+ )
1736
+ ).collect(Xr)
1737
+ ), Ee = q(
1738
+ "(",
1739
+ tt(
1740
+ ",",
1741
+ Gt(z(() => v)).collect(nn, "attrParam")
1742
+ // LATER These unknown expressions have decls inside of them, that's why they're tough to replace!
1743
+ ),
1744
+ f(")", "invalid attribute arguments, expected ')'")
1745
+ ), Cs = m(
1746
+ dn,
1747
+ fn
1748
+ ).ctag("attribute"), As = m(
1749
+ Ms,
1750
+ dn,
1751
+ fn
1752
+ ).ctag("attribute"), E = T(As), qt = T(Cs), Rs = f(
1753
+ M.collect(At, "type_name"),
1754
+ "invalid type name, expected a name"
1755
+ ), Bs = f(
1756
+ M.collect(At, "fn_name"),
1757
+ "missing fn name"
1758
+ ), Is = _(
1759
+ u(
1760
+ M.collect(Ke, "decl_elem"),
1761
+ b(u(":", J))
1762
+ ).collect(ne)
1763
+ ).ctag("var_name"), Ut = f(Is, "invalid ident"), Wt = _(
1764
+ f(
1765
+ u(
1766
+ M.collect(At, "decl_elem"),
1767
+ b(u(":", J))
1768
+ ).collect(ne),
1769
+ "expected identifier"
1770
+ )
1771
+ ).ctag("var_name"), Ls = _(
1772
+ u(
1773
+ E,
1774
+ M.collect(rn, "nameElem"),
1775
+ f(":", "invalid struct member, expected ':'"),
1776
+ f(J, "invalid struct member, expected type specifier")
1777
+ ).collect(Vr)
1778
+ ).ctag("members"), js = u(
1779
+ E.collect((t) => t.tags.attribute, "attributes"),
1780
+ "struct",
1781
+ f(Rs, "invalid struct, expected name"),
1782
+ u(
1783
+ f("{", "invalid struct, expected '{'"),
1784
+ $t(",", Ls),
1785
+ f("}", "invalid struct, expected '}'")
1786
+ ).collect(C, "struct_scope")
1787
+ ).collect(Wr), ie = u(
1788
+ ft.collect(dt),
1789
+ () => pt,
1790
+ ln
1791
+ ), Ds = _(
1792
+ u(
1793
+ E.collect((t) => t.tags.attribute, "attributes"),
1794
+ M.collect(Ke, "decl_elem"),
1795
+ b(u(":", f(J, "invalid fn parameter, expected type specifier"))).collect(ne, "param_name")
1796
+ ).collect(Ur)
1797
+ ).ctag("fn_param"), Os = u("(", tt(",", Ds), ")"), Fs = u(
1798
+ "var",
1799
+ () => pt,
1800
+ Ut,
1801
+ b(u("=", () => v))
1802
+ // no decl_scope, but I think that's ok
1803
+ ).collect(kt("var")), qs = u(
1804
+ "var",
1805
+ () => pt,
1806
+ Wt,
1807
+ // TODO shouldn't decl_scope include the ident type?
1808
+ b(u("=", () => v.collect(C, "decl_scope")))
1809
+ ), Us = m(
1810
+ bt("keyword", ["true", "false"]).map(xo),
1811
+ q(
1812
+ st("symbol", "("),
1813
+ z(() => pn),
1814
+ st("symbol", ")")
1815
+ ).map(_o),
1816
+ Ae("word").map(ko)
1817
+ ), gt = m(
1818
+ u(
1819
+ st("symbol", "!").map(vo),
1820
+ z(() => gt)
1821
+ ).map(yo),
1822
+ Us
1823
+ ), pn = u(
1824
+ gt,
1825
+ m(
1826
+ L(
1827
+ u(
1828
+ st("symbol", "||").map(Se),
1829
+ f(
1830
+ gt,
1831
+ "invalid expression, expected expression"
1832
+ )
1833
+ )
1834
+ ),
1835
+ L(
1836
+ u(
1837
+ st("symbol", "&&").map(Se),
1838
+ f(
1839
+ gt,
1840
+ "invalid expression, expected expression"
1841
+ )
1842
+ )
1843
+ ),
1844
+ xt().map(() => [])
1845
+ )
1846
+ ).map(Eo), mn = u(
1847
+ E,
1848
+ Pt("{"),
1849
+ T(() => yt),
1850
+ f("}", "invalid block, expected }")
1851
+ ).collect(ot), X = _(
1852
+ u(
1853
+ E,
1854
+ u(
1855
+ Pt("{"),
1856
+ T(() => yt),
1857
+ f("}", "invalid block, expected '}'")
1858
+ ).collect(C)
1859
+ ).collect(ot)
1860
+ ), Ws = u(
1861
+ E,
1862
+ m(
1863
+ ie,
1864
+ () => gn,
1865
+ () => ae
1866
+ )
1867
+ ), Vs = u(
1868
+ E,
1869
+ m(ie, () => ae)
1870
+ ), zs = u(
1871
+ // LATER consider allowing @if on for_init, expression and for_update
1872
+ "for",
1873
+ u(
1874
+ f("(", "invalid for loop, expected '('"),
1875
+ b(Ws),
1876
+ f(";", "invalid for loop, expected ';'"),
1877
+ b(v),
1878
+ f(";", "invalid for loop, expected ';'"),
1879
+ b(Vs),
1880
+ f(")", "invalid for loop, expected ')'"),
1881
+ mn
1882
+ ).collect(C)
1883
+ ), Gs = u(
1884
+ "if",
1885
+ f(u(v, X), "invalid if statement"),
1886
+ T(
1887
+ u(
1888
+ "else",
1889
+ "if",
1890
+ f(u(v, X), "invalid else if branch")
1891
+ )
1892
+ ),
1893
+ b(
1894
+ u("else", f(X, "invalid else branch, expected '{'"))
1895
+ )
1896
+ ), Xs = u(
1897
+ "loop",
1898
+ qt,
1899
+ f(
1900
+ u(
1901
+ "{",
1902
+ T(() => yt),
1903
+ b(
1904
+ _(
1905
+ u(
1906
+ E,
1907
+ "continuing",
1908
+ qt,
1909
+ "{",
1910
+ T(() => yt),
1911
+ _(
1912
+ b(
1913
+ u(
1914
+ E,
1915
+ u("break", "if", v, ";")
1916
+ ).collect(ot)
1917
+ )
1918
+ ),
1919
+ "}"
1920
+ ).collect(ot).collect(C)
1921
+ )
1922
+ ),
1923
+ "}"
1924
+ ),
1925
+ "invalid loop statement"
1926
+ )
1927
+ ).collect(C), Js = m("default", v), Ks = _(
1928
+ u(
1929
+ E,
1930
+ m(
1931
+ u(
1932
+ "case",
1933
+ tt(",", Js, { requireOne: !0 }),
1934
+ b(":"),
1935
+ X
1936
+ ),
1937
+ u("default", b(":"), X)
1938
+ ).collect(Gr)
1939
+ )
1940
+ ), Hs = u(E, "{", L(Ks), "}"), Ys = u("switch", v, Hs), Zs = u("while", v, X), hn = m(
1941
+ zs,
1942
+ Gs,
1943
+ Xs,
1944
+ Ys,
1945
+ Zs,
1946
+ u("break", ";"),
1947
+ // ambiguous with break if
1948
+ u("continue", f(";", "invalid statement, expected ';'")),
1949
+ u(";"),
1950
+ // LATER this one cannot have attributes in front of it
1951
+ () => bn,
1952
+ u("discard", f(";", "invalid statement, expected ';'")),
1953
+ u("return", b(v), f(";", "invalid statement, expected ';'")),
1954
+ u(ie, f(";", "invalid statement, expected ';'")),
1955
+ u(
1956
+ () => gn,
1957
+ f(";", "invalid statement, expected ';'")
1958
+ ),
1959
+ u(
1960
+ () => ae,
1961
+ f(";", "invalid statement, expected ';'")
1962
+ )
1963
+ ), Qs = _(
1964
+ u(
1965
+ E,
1966
+ hn
1967
+ ).collect(ot).collect(sn)
1968
+ ), to = _(
1969
+ u(
1970
+ qt,
1971
+ hn
1972
+ )
1973
+ ), yt = m(
1974
+ X,
1975
+ to,
1976
+ Qs
1977
+ ), nt = m(
1978
+ an,
1979
+ u(
1980
+ ft.collect(dt),
1981
+ b(vt)
1982
+ ),
1983
+ u(
1984
+ "(",
1985
+ () => nt,
1986
+ ")",
1987
+ b(vt)
1988
+ // LATER this doesn't find member references.
1989
+ ),
1990
+ u("&", () => nt),
1991
+ u("*", () => nt)
1992
+ ), gn = _(
1993
+ // LATER consider collecting these as var elems and scopes
1994
+ m(
1995
+ // Also covers the = expression case
1996
+ Fs,
1997
+ u("const", Ut, f("=", "invalid const declaration, expected '='"), v),
1998
+ u(
1999
+ "let",
2000
+ Ut,
2001
+ f("=", "invalid let declaration, expected '='"),
2002
+ v
2003
+ )
2004
+ )
2005
+ ), ae = m(
2006
+ u(
2007
+ nt,
2008
+ m("=", "<<=", ">>=", "%=", "&=", "*=", "+=", "-=", "/=", "^=", "|="),
2009
+ v
2010
+ ),
2011
+ u(nt, m("++", "--")),
2012
+ u("_", "=", v)
2013
+ ), eo = u(
2014
+ _(
2015
+ E.collect((t) => t.tags.attribute || [])
2016
+ ).ctag("fn_attributes"),
2017
+ Pt("fn"),
2018
+ f(Bs, "invalid fn, expected function name"),
2019
+ u(
2020
+ f(Os, "invalid fn, expected function parameters").collect(C, "header_scope"),
2021
+ b(u(
2022
+ "->",
2023
+ E.collect((t) => t.tags.attribute, "return_attributes"),
2024
+ J.ctag("return_type").collect(C, "return_scope")
2025
+ )),
2026
+ f(
2027
+ mn,
2028
+ "invalid fn, expected function body"
2029
+ ).ctag("body_statement").collect(C, "body_scope")
2030
+ )
2031
+ ).collect(sn, "fn_partial_scope").collect(Fr), no = m(
2032
+ u(
2033
+ E,
2034
+ "override",
2035
+ Wt,
2036
+ u(b(u("=", v.collect(C, "decl_scope")))),
2037
+ // TODO partial scopes for decl_scopes?
2038
+ ";"
2039
+ ).collect(kt("override")),
2040
+ u(
2041
+ E,
2042
+ "const",
2043
+ Wt,
2044
+ "=",
2045
+ u(v).collect(C, "decl_scope"),
2046
+ ";"
2047
+ ).collect(kt("const"))
2048
+ ), ro = u(
2049
+ E.collect((t) => t.tags.attribute, "attributes"),
2050
+ "alias",
2051
+ f(M, "invalid alias, expected name").collect(At, "alias_name"),
2052
+ f("=", "invalid alias, expected '='"),
2053
+ f(J, "invalid alias, expected type").collect(C, "alias_scope"),
2054
+ f(";", "invalid alias, expected ';'")
2055
+ ).collect(Or), bn = _(
2056
+ u(
2057
+ E,
2058
+ "const_assert",
2059
+ f(v, "invalid const_assert, expected expression"),
2060
+ f(";", "invalid statement, expected ';'")
2061
+ ).collect(zr)
2062
+ ).ctag("const_assert"), so = _(
2063
+ u(
2064
+ E,
2065
+ Dt(
2066
+ m(
2067
+ N("diagnostic", un).map(ao),
2068
+ N("enable", Ft).map(co),
2069
+ N("requires", Ft).map(lo)
2070
+ ).ptag("directive"),
2071
+ ";"
2072
+ )
2073
+ ).collect(Qr)
2074
+ ), oo = _(
2075
+ m(
2076
+ eo,
2077
+ u(
2078
+ E,
2079
+ qs,
2080
+ ";"
2081
+ ).collect(kt("gvar")),
2082
+ no,
2083
+ ";",
2084
+ ro,
2085
+ bn.collect(Kr),
2086
+ js
2087
+ )
2088
+ ), io = u(
2089
+ os,
2090
+ T(so),
2091
+ T(oo),
2092
+ f(tr(), "invalid WESL, expected EOF")
2093
+ ).collect(Zr, "collectModule");
2094
+ function ao([t, e]) {
2095
+ return { kind: "diagnostic", severity: t, rule: e };
2096
+ }
2097
+ function co(t) {
2098
+ return { kind: "enable", extensions: t };
2099
+ }
2100
+ function lo(t) {
2101
+ return { kind: "requires", extensions: t };
2102
+ }
2103
+ function uo([t, e]) {
2104
+ return {
2105
+ kind: "@attribute",
2106
+ name: t,
2107
+ params: e
2108
+ };
2109
+ }
2110
+ function fo(t) {
2111
+ return {
2112
+ kind: "@interpolate",
2113
+ params: t
2114
+ };
2115
+ }
2116
+ function po(t) {
2117
+ return {
2118
+ kind: "@builtin",
2119
+ param: t
2120
+ };
2121
+ }
2122
+ function mo([t, e]) {
2123
+ return {
2124
+ kind: "@diagnostic",
2125
+ severity: t,
2126
+ rule: e
2127
+ };
2128
+ }
2129
+ function ho(t) {
2130
+ return {
2131
+ kind: "@if",
2132
+ param: t
2133
+ };
2134
+ }
2135
+ function go(t) {
2136
+ return {
2137
+ kind: "translate-time-expression",
2138
+ expression: t.value,
2139
+ span: t.span
2140
+ };
2141
+ }
2142
+ function bo(t) {
2143
+ return {
2144
+ kind: "name",
2145
+ name: t.text,
2146
+ start: t.span[0],
2147
+ end: t.span[1]
2148
+ };
2149
+ }
2150
+ function xo(t) {
2151
+ return {
2152
+ kind: "literal",
2153
+ value: t.text,
2154
+ span: t.span
2155
+ };
2156
+ }
2157
+ function ko(t) {
2158
+ return {
2159
+ kind: "translate-time-feature",
2160
+ name: t.text,
2161
+ span: t.span
2162
+ };
2163
+ }
2164
+ function _o(t) {
2165
+ return {
2166
+ kind: "parenthesized-expression",
2167
+ expression: t
2168
+ };
2169
+ }
2170
+ function vo(t) {
2171
+ return {
2172
+ value: t.text,
2173
+ span: t.span
2174
+ };
2175
+ }
2176
+ function Se(t) {
2177
+ return {
2178
+ value: t.text,
2179
+ span: t.span
2180
+ };
2181
+ }
2182
+ function yo([t, e]) {
2183
+ return {
2184
+ kind: "unary-expression",
2185
+ operator: t,
2186
+ expression: e
2187
+ };
2188
+ }
2189
+ function Eo([t, e]) {
2190
+ let n = t;
2191
+ for (const [r, s] of e)
2192
+ n = So([n, r, s]);
2193
+ return n;
2194
+ }
2195
+ function So([t, e, n]) {
2196
+ return {
2197
+ kind: "binary-expression",
2198
+ operator: e,
2199
+ left: t,
2200
+ right: n
2201
+ };
2202
+ }
2203
+ /*!
2204
+ Copyright (c) 2017-2021 [these people](https://github.com/Rich-Harris/vlq/graphs/contributors)
2205
+
2206
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2207
+
2208
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2209
+
2210
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2211
+ */
2212
+ let xn = {};
2213
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split("").forEach(function(t, e) {
2214
+ xn[e] = t;
2215
+ });
2216
+ function we(t) {
2217
+ if (typeof t == "number")
2218
+ return Te(t);
2219
+ let e = "";
2220
+ for (let n = 0; n < t.length; n += 1)
2221
+ e += Te(t[n]);
2222
+ return e;
2223
+ }
2224
+ function Te(t) {
2225
+ let e = "";
2226
+ t < 0 ? t = -t << 1 | 1 : t <<= 1;
2227
+ do {
2228
+ let n = t & 31;
2229
+ t >>>= 5, t > 0 && (n |= 32), e += xn[n];
2230
+ } while (t > 0);
2231
+ return e;
2232
+ }
2233
+ function Vi(t) {
2234
+ const e = [];
2235
+ t.injectError = (r, s) => {
2236
+ const o = e.findLast((i) => i.filter === r);
2237
+ o !== void 0 ? o.errors.push(s) : s.then((i) => {
2238
+ i !== null && n(i);
2239
+ });
2240
+ };
2241
+ function n(r) {
2242
+ t.addEventListener(
2243
+ "uncapturederror",
2244
+ (s) => {
2245
+ if (!s.defaultPrevented)
2246
+ if ("compilationInfo" in s.error) {
2247
+ const o = s.error;
2248
+ if (o.compilationInfo)
2249
+ for (const i of o.compilationInfo.messages)
2250
+ kn({
2251
+ url: i.module.url,
2252
+ text: i.module.text ?? null,
2253
+ lineNumber: i.lineNum,
2254
+ lineColumn: i.linePos,
2255
+ length: i.length,
2256
+ error: new Error(i.type + ": " + i.message)
2257
+ });
2258
+ else
2259
+ console.error(s.error.message);
2260
+ } else
2261
+ console.error(s.error.message);
2262
+ },
2263
+ {
2264
+ // This event listener should only happen for this event!
2265
+ once: !0
2266
+ }
2267
+ ), t.dispatchEvent(
2268
+ new GPUUncapturedErrorEvent("uncapturederror", { error: r })
2269
+ );
2270
+ }
2271
+ return t.pushErrorScope = /* @__PURE__ */ ((r) => function(s) {
2272
+ return e.push({
2273
+ filter: s,
2274
+ errors: []
2275
+ }), r.call(this, s);
2276
+ })(t.pushErrorScope), t.popErrorScope = /* @__PURE__ */ ((r) => function() {
2277
+ const s = e.pop();
2278
+ if (s === void 0)
2279
+ throw new DOMException(
2280
+ "popErrorScope called on empty error scope stack",
2281
+ "OperationError"
2282
+ );
2283
+ return s.errors.push(r.call(this)), Promise.all(s.errors).then(
2284
+ (i) => i.find((a) => a !== null) ?? null
2285
+ );
2286
+ })(t.popErrorScope), t;
2287
+ }
2288
+ function kn({
2289
+ url: t,
2290
+ text: e,
2291
+ lineNumber: n,
2292
+ lineColumn: r,
2293
+ length: s,
2294
+ error: o
2295
+ }) {
2296
+ let i = we([
2297
+ 0,
2298
+ 0,
2299
+ Math.max(0, n - 1),
2300
+ Math.max(0, r - 1)
2301
+ ]) + "," + // Sadly no browser makes use of this info to map the error properly
2302
+ we([
2303
+ 18,
2304
+ // Arbitrary number that is high enough
2305
+ 0,
2306
+ Math.max(0, n - 1),
2307
+ Math.max(0, r - 1) + s
2308
+ ]);
2309
+ const a = {
2310
+ version: 3,
2311
+ file: null,
2312
+ sources: [t],
2313
+ sourcesContent: [e ?? null],
2314
+ names: [],
2315
+ mappings: i
2316
+ };
2317
+ let l = `throw new Error(${JSON.stringify(o.message + "")})`;
2318
+ l += `
2319
+ //# sourceMappingURL=data:application/json;base64,` + btoa(unescape(encodeURIComponent(JSON.stringify(a)))), l += `
2320
+ //# sourceURL=` + a.sources[0];
2321
+ let c = 0;
2322
+ "stackTraceLimit" in Error && (c = Error.stackTraceLimit, Error.stackTraceLimit = 1);
2323
+ try {
2324
+ (0, eval)(l);
2325
+ } catch (d) {
2326
+ throw "stackTraceLimit" in Error && (Error.stackTraceLimit = c), o.message = "", d.cause = o, d;
2327
+ }
2328
+ }
2329
+ class wo extends Error {
2330
+ constructor(e) {
2331
+ const n = e.src.src, [r, s] = Qt(e.cause.position, n);
2332
+ let o = `${e.src.debugFilePath}:${r}:${s}`;
2333
+ o += ` error: ${e.cause.message}
2334
+ `, o += De(n, [
2335
+ e.cause.position,
2336
+ e.cause.position + 1
2337
+ ]).join(`
2338
+ `), super(o, {
2339
+ cause: e.cause
2340
+ }), this.position = e.cause.position, this.src = e.src;
2341
+ }
2342
+ }
2343
+ function ce(t, e) {
2344
+ const n = new hs(t.src), r = _n(t), s = { stream: n, appState: r };
2345
+ try {
2346
+ if (io.parse(s) === null)
2347
+ throw new Error("parseWESL failed");
2348
+ } catch (o) {
2349
+ if (o instanceof H) {
2350
+ const [i, a] = Qt(
2351
+ o.position,
2352
+ t.src
2353
+ ), l = new wo({ cause: o, src: t });
2354
+ kn({
2355
+ url: t.debugFilePath,
2356
+ text: t.src,
2357
+ error: l,
2358
+ lineNumber: i,
2359
+ lineColumn: a,
2360
+ length: 1
2361
+ });
2362
+ } else
2363
+ throw o;
2364
+ }
2365
+ return r.stable;
2366
+ }
2367
+ function To(t, e) {
2368
+ return ce({
2369
+ modulePath: "package::test",
2370
+ // TODO this ought not be used outside of tests
2371
+ debugFilePath: "./test.wesl",
2372
+ src: t
2373
+ });
2374
+ }
2375
+ function _n(t) {
2376
+ const e = Ve(null);
2377
+ return {
2378
+ context: { scope: e, openElems: [] },
2379
+ stable: { srcModule: t, imports: [], rootScope: e, moduleElem: null }
2380
+ };
2381
+ }
2382
+ function zi() {
2383
+ return _n({
2384
+ modulePath: "package::test",
2385
+ debugFilePath: "./test.wesl",
2386
+ src: ""
2387
+ });
2388
+ }
2389
+ function Po(t) {
2390
+ if (t._flatImports) return t._flatImports;
2391
+ const e = t.imports.flatMap(Cr);
2392
+ return t._flatImports = e, e;
2393
+ }
2394
+ const $o = `bitcast all any select arrayLength
2395
+ abs acos acosh asin asinh atan atanh atan2 ceil clamp cos cosh
2396
+ countLeadingZeros countOneBits countTrailingZeros cross
2397
+ degrees determinant distance dot dot4U8Packed dot4I8Packed
2398
+ exp exp2 extractBits faceForward firstLeadingBit firstTrailingBit
2399
+ floor fma fract frexp insertBits inverseSqrt ldexp length log log2
2400
+ max min mix modf normalize pow quantizeToF16 radians reflect refract
2401
+ reverseBits round saturate sign sin sinh smoothstep sqrt step tan tanh
2402
+ transpose trunc
2403
+ dpdx dpdxCoarse dpdxFine dpdy dpdyCoarse dpdyFine fwidth
2404
+ fwidthCoarse fwidthFine
2405
+ textureDimensions textureGather textureGatherCompare textureLoad
2406
+ textureNumLayers textureNumLevels textureNumSamples
2407
+ textureSample textureSampleBias textureSampleCompare textureSampleCompareLevel
2408
+ textureSampleGrad textureSampleLevel textureSampleBaseClampToEdge
2409
+ textureStore
2410
+ atomicLoad atomicStore atomicAdd atomicSub atomicMax atomicMin
2411
+ atomicAnd atomicOr atomicXor atomicExchange atomicCompareExchangeWeak
2412
+ pack4x8snorm pack4x8unorm pack4xI8 pack4xU8 pack4xI8Clamp pack4xU8Clamp
2413
+ pack2x16snorm pack2x16unorm pack2x16float
2414
+ unpack4x8snorm unpack4x8unorm unpack4xI8 unpack4xU8
2415
+ unpack2x16snorm unpack2x16unorm unpack2x16float
2416
+ storageBarrier textureBarrier workgroupBarrier workgroupUniformLoad
2417
+ subgroupAdd subgroupAll subgroupAnd subgroupAny subgroupBallot
2418
+ subgroupBroadcast subgroupBroadcastFirst subgroupElect
2419
+ subgroupExclusiveAdd subgroupExclusiveMul subgroupInclusiveAdd
2420
+ subgroupInclusiveMul subgroupMax subgroupMin subgroupMul subgroupOr
2421
+ subgroupShuffle subgroupShuffleUp subgroupShuffleXor subgroupXor
2422
+ quadBroadcast quadSwapDiagonal quadSwapX quadSwapY`.split(/\s+/), vn = `
2423
+ texture_1d texture_2d texture_2d_array texture_3d
2424
+ texture_cube texture_cube_array
2425
+ `, yn = `
2426
+ texture_multisampled_2d texture_depth_multisampled_2d
2427
+ `, En = `
2428
+ texture_storage_1d texture_storage_2d texture_storage_2d_array
2429
+ texture_storage_3d
2430
+ `, No = `array atomic bool f16 f32 i32
2431
+ mat2x2 mat2x3 mat2x4 mat3x2 mat3x3 mat3x4 mat4x2 mat4x3 mat4x4
2432
+ mat2x2f mat2x3f mat2x4f mat3x2f mat3x3f mat3x4f
2433
+ mat4x2f mat4x3f mat4x4f
2434
+ mat2x2h mat2x3h mat2x4h mat3x2h mat3x3h mat3x4h
2435
+ mat4x2h mat4x3h mat4x4h
2436
+ u32 vec2 vec3 vec4 ptr
2437
+ vec2i vec3i vec4i vec2u vec3u vec4u
2438
+ vec2f vec3f vec4f vec2h vec3h vec4h
2439
+ ${vn}
2440
+ ${yn}
2441
+ texture_external
2442
+ ${En}
2443
+ texture_depth_2d texture_depth_2d_array texture_depth_cube
2444
+ texture_depth_cube_array
2445
+ sampler sampler_comparison
2446
+ rgba8unorm rgba8snorm rgba8uint rgba8sint
2447
+ rgba16uint rgba16sint rgba16float
2448
+ r32uint r32sint r32float rg32uint rg32sint rg32float
2449
+ rgba32uint rgba32sint rgba32float
2450
+ bgra8unorm`.split(/\s+/), Mo = `read write read_write
2451
+ function private workgroup uniform storage
2452
+ rgba8unorm rgba8snorm rgba8uint rgba8sint
2453
+ rgba16uint rgba16sint rgba16float
2454
+ r32uint r32sint r32float rg32uint rg32sint rg32float
2455
+ rgba32uint rgba32sint rgba32float bgra8unorm`.split(/\s+/);
2456
+ function Sn(t) {
2457
+ return No.includes(t);
2458
+ }
2459
+ function Co(t) {
2460
+ return $o.includes(t) || Sn(t);
2461
+ }
2462
+ function Ao(t) {
2463
+ return Mo.includes(t);
2464
+ }
2465
+ function Ro(t) {
2466
+ const { rootAst: e, registry: n, virtuals: r } = t, { conditions: s = {}, mangler: o = Mr } = t, { rootScope: i } = e, a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), c = le(i);
2467
+ c.forEach((w) => {
2468
+ w.mangledName = w.originalName, a.add(w.originalName), l.add(w);
2469
+ });
2470
+ const d = /* @__PURE__ */ new Map(), p = {
2471
+ registry: n,
2472
+ conditions: s,
2473
+ knownDecls: l,
2474
+ foundScopes: /* @__PURE__ */ new Set(),
2475
+ globalNames: a,
2476
+ globalStatements: d,
2477
+ virtuals: r,
2478
+ mangler: o
2479
+ }, h = c.map((w) => [w.originalName, w]), x = { decls: new Map(h), parent: null }, R = Et(i, p, x, !0).filter(Rt), U = [...d.values()];
2480
+ return { decls: R, globalNames: a, newStatements: U };
2481
+ }
2482
+ function le(t, e) {
2483
+ const n = [];
2484
+ for (const r of t.contents)
2485
+ r.kind === "decl" ? (r.declElem, Oe(r.declElem) && n.push(r)) : r.kind === "partial" && n.push(...le(r));
2486
+ return n;
2487
+ }
2488
+ function Et(t, e, n, r = !1) {
2489
+ const { conditions: s, foundScopes: o } = e;
2490
+ if (o.has(t)) return [];
2491
+ o.add(t);
2492
+ const i = [], a = [];
2493
+ t.contents.forEach((c) => {
2494
+ const { kind: d } = c;
2495
+ if (d === "decl") {
2496
+ const p = c;
2497
+ r || n.decls.set(p.originalName, p);
2498
+ } else if (d === "ref") {
2499
+ const p = Bo(c, n, e);
2500
+ p && i.push(p);
2501
+ } else {
2502
+ const p = Io(c, n, e);
2503
+ p && a.push(...p);
2504
+ }
2505
+ });
2506
+ const l = i.flatMap((c) => {
2507
+ const d = c.scope, p = jo(c);
2508
+ {
2509
+ const h = Xe(p);
2510
+ return Et(d, e, h);
2511
+ }
2512
+ });
2513
+ return [i, a, l].flat();
2514
+ }
2515
+ function Bo(t, e, n) {
2516
+ const { registry: r, conditions: s } = n, { virtuals: o } = n;
2517
+ if (!t.refersTo && !t.std) {
2518
+ const i = wn(t, e) ?? qo(t, r, s, o);
2519
+ if (i)
2520
+ return t.refersTo = i.decl, Lo(t, i, n);
2521
+ Fo(t.originalName) ? t.std = !0 : Do(t);
2522
+ }
2523
+ }
2524
+ function Io(t, e, n) {
2525
+ if (!Fe(t)) return;
2526
+ const { kind: r } = t;
2527
+ if (r === "scope") {
2528
+ const s = Xe(e);
2529
+ return Et(t, n, s);
2530
+ } else if (r === "partial")
2531
+ return Et(t, n, e);
2532
+ }
2533
+ function Lo(t, e, n) {
2534
+ const { decl: r, moduleAst: s } = e, { knownDecls: o, globalNames: i, mangler: a, globalStatements: l } = n;
2535
+ if (!o.has(r)) {
2536
+ o.add(r);
2537
+ const { srcModule: c } = r, d = t.originalName;
2538
+ if (Oo(d, r, i, c, a), Rt(r)) {
2539
+ const { moduleAsserts: p } = s, h = p == null ? void 0 : p.map((x) => ({ srcModule: c, elem: x }));
2540
+ return h == null || h.forEach((x) => l.set(x.elem, x)), r;
2541
+ }
2542
+ }
2543
+ }
2544
+ function jo(t, e) {
2545
+ t.isGlobal, Ct(t);
2546
+ let n = t.scope;
2547
+ for (; n.parent; )
2548
+ n = n.parent;
2549
+ const s = le(n).map((i) => [i.originalName, i]);
2550
+ return { decls: new Map(s) };
2551
+ }
2552
+ function Do(t) {
2553
+ const { refIdentElem: e } = t;
2554
+ if (e) {
2555
+ const { srcModule: n, start: r, end: s } = e, { debugFilePath: o } = n, i = `unresolved identifier '${t.originalName}' in file: ${o}`;
2556
+ throw Me(n.src, [r, s], i), new Error(i);
2557
+ }
2558
+ }
2559
+ function Oo(t, e, n, r, s) {
2560
+ if (!e.mangledName) {
2561
+ let o;
2562
+ if (Rt(e)) {
2563
+ const i = t.lastIndexOf("::"), a = i === -1 ? t : t.slice(i + 2);
2564
+ o = s(e, r, a, n);
2565
+ } else
2566
+ o = e.originalName;
2567
+ e.mangledName = o, n.add(o);
2568
+ }
2569
+ }
2570
+ function Fo(t) {
2571
+ return Sn(t) || Co(t) || Ao(t);
2572
+ }
2573
+ function wn(t, e) {
2574
+ const { originalName: n } = t, r = e.decls.get(n);
2575
+ if (r)
2576
+ return { decl: r, moduleAst: t.ast };
2577
+ const { parent: s } = e;
2578
+ if (s)
2579
+ return wn(t, s);
2580
+ }
2581
+ function qo(t, e, n, r) {
2582
+ const s = Po(t.ast), o = t.originalName.split("::"), i = Wo(o, s) ?? Uo(o);
2583
+ if (i) {
2584
+ const { srcModule: a } = t.ast;
2585
+ return Vo(i, a, e, n, r);
2586
+ }
2587
+ }
2588
+ function Uo(t) {
2589
+ if (t.length > 1) return t;
2590
+ }
2591
+ function Wo(t, e) {
2592
+ for (const n of e)
2593
+ if (n.importPath.at(-1) === t.at(0))
2594
+ return [...n.modulePath, ...t.slice(1)];
2595
+ }
2596
+ function Vo(t, e, n, r = {}, s) {
2597
+ const i = zo(t, e).slice(0, -1).join("::"), a = n.modules[i] ?? Go(t[0], r, s);
2598
+ if (!a) {
2599
+ console.log(`ident ${t.join("::")}, but module not found`);
2600
+ return;
2601
+ }
2602
+ const l = yr(t), c = ze(a.rootScope, l);
2603
+ if (c)
2604
+ return { decl: c, moduleAst: a };
2605
+ }
2606
+ function zo(t, e) {
2607
+ const n = t.findLastIndex((r) => r === "super");
2608
+ if (n > -1) {
2609
+ const s = e.modulePath.split("::").slice(0, -(n + 1)), o = t.slice(n + 1);
2610
+ return [...s, ...o];
2611
+ }
2612
+ return t;
2613
+ }
2614
+ function Go(t, e = {}, n) {
2615
+ if (!n) return;
2616
+ const r = n[t];
2617
+ if (r) {
2618
+ const { ast: s, fn: o } = r;
2619
+ if (s) return s;
2620
+ const i = o(e), a = {
2621
+ modulePath: t,
2622
+ debugFilePath: t,
2623
+ src: i
2624
+ };
2625
+ return r.ast = ce(a), r.ast;
2626
+ }
2627
+ }
2628
+ function Rt(t) {
2629
+ const { declElem: e } = t;
2630
+ return e ? ["alias", "const", "override", "fn", "struct", "gvar"].includes(
2631
+ e.kind
2632
+ ) : !1;
2633
+ }
2634
+ function Lt(t, e, n, r = !0) {
2635
+ const s = { conditions: n, srcBuilder: t, extracting: r };
2636
+ e.forEach((o) => ue(o, s));
2637
+ }
2638
+ function ue(t, e) {
2639
+ if (fe(t, e.conditions))
2640
+ switch (t.kind) {
2641
+ // import statements are dropped from from emitted text
2642
+ case "import":
2643
+ return;
2644
+ // terminal elements copy strings to the output
2645
+ case "text":
2646
+ return Xo(t, e);
2647
+ case "name":
2648
+ return Jo(t, e);
2649
+ case "synthetic":
2650
+ return Zo(t, e);
2651
+ // identifiers are copied to the output, but with potentially mangled names
2652
+ case "ref":
2653
+ return Qo(t, e);
2654
+ case "decl":
2655
+ return de(t, e);
2656
+ // container elements just emit their child elements
2657
+ case "param":
2658
+ case "var":
2659
+ case "typeDecl":
2660
+ case "let":
2661
+ case "module":
2662
+ case "member":
2663
+ case "memberRef":
2664
+ case "expression":
2665
+ case "type":
2666
+ case "statement":
2667
+ case "stuff":
2668
+ case "switch-clause":
2669
+ return at(t, e);
2670
+ // root level container elements get some extra newlines to make the output prettier
2671
+ case "override":
2672
+ case "const":
2673
+ case "assert":
2674
+ case "alias":
2675
+ case "gvar":
2676
+ return jt(e), at(t, e);
2677
+ case "fn":
2678
+ return jt(e), Ko(t, e);
2679
+ case "struct":
2680
+ return jt(e), Ho(t, e);
2681
+ case "attribute":
2682
+ return Tn(t, e);
2683
+ case "directive":
2684
+ return ti(t, e);
2685
+ default:
2686
+ j(t);
2687
+ }
2688
+ }
2689
+ function jt(t) {
2690
+ t.extracting && (t.srcBuilder.addNl(), t.srcBuilder.addNl());
2691
+ }
2692
+ function Xo(t, e) {
2693
+ e.srcBuilder.addCopy(t.start, t.end);
2694
+ }
2695
+ function Jo(t, e) {
2696
+ e.srcBuilder.add(t.name, t.start, t.end);
2697
+ }
2698
+ function Ko(t, e) {
2699
+ const { attributes: n, name: r, params: s, returnAttributes: o, returnType: i, body: a } = t, { conditions: l, srcBuilder: c } = e;
2700
+ Pe(n, e), c.add("fn ", r.start - 3, r.start), de(r, e), c.appendNext("(");
2701
+ const d = s.filter((p) => fe(p));
2702
+ d.forEach((p, h) => {
2703
+ Vt(p, e), h < d.length - 1 && c.appendNext(", ");
2704
+ }), c.appendNext(") "), i && (c.appendNext("-> "), Pe(o, e), at(i, e), c.appendNext(" ")), at(a, e);
2705
+ }
2706
+ function Pe(t, e) {
2707
+ t == null || t.forEach((n) => {
2708
+ Tn(n, e), e.srcBuilder.add(" ", n.start, n.end);
2709
+ });
2710
+ }
2711
+ function Ho(t, e) {
2712
+ const { name: n, members: r, start: s, end: o } = t, { srcBuilder: i } = e, a = r.filter((c) => fe(c, e.conditions)), l = a.length;
2713
+ if (l === 0) {
2714
+ Yo(t);
2715
+ return;
2716
+ }
2717
+ i.add("struct ", s, n.start), de(n, e), l === 1 ? (i.add(" { ", n.end, r[0].start), Vt(a[0], e), i.add(` }
2718
+ `, o - 1, o)) : (i.add(` {
2719
+ `, n.end, r[0].start), a.forEach((c) => {
2720
+ i.add(" ", c.start - 1, c.start), Vt(c, e), i.add(",", c.end, c.end + 1), i.addNl();
2721
+ }), i.add(`}
2722
+ `, o - 1, o));
2723
+ }
2724
+ function Yo(t) {
2725
+ const { name: e, members: n } = t, r = n.length ? "(with current conditions)" : "", { debugFilePath: s } = e.srcModule;
2726
+ Me(
2727
+ e.srcModule.src,
2728
+ t.start,
2729
+ `struct ${e.ident.originalName} in ${s} has no members ${r}`
2730
+ );
2731
+ }
2732
+ function Zo(t, e) {
2733
+ const { text: n } = t;
2734
+ e.srcBuilder.addSynthetic(n, n, 0, n.length);
2735
+ }
2736
+ function at(t, e) {
2737
+ t.contents.forEach((n) => ue(n, e));
2738
+ }
2739
+ function Vt(t, e) {
2740
+ t.contents.forEach((n) => {
2741
+ if (n.kind === "text") {
2742
+ const { srcModule: r, start: s, end: o } = n;
2743
+ if (r.src.slice(s, o).trim() === "")
2744
+ return;
2745
+ }
2746
+ ue(n, e);
2747
+ });
2748
+ }
2749
+ function Qo(t, e) {
2750
+ if (t.ident.std)
2751
+ e.srcBuilder.add(t.ident.originalName, t.start, t.end);
2752
+ else {
2753
+ const n = St(t.ident), r = Pn(n);
2754
+ e.srcBuilder.add(r, t.start, t.end);
2755
+ }
2756
+ }
2757
+ function de(t, e) {
2758
+ const n = Pn(t.ident);
2759
+ e.srcBuilder.add(n, t.start, t.end);
2760
+ }
2761
+ function Tn(t, e) {
2762
+ const { kind: n } = t.attribute;
2763
+ if (n === "@attribute") {
2764
+ const { params: r } = t.attribute;
2765
+ if (!r || r.length === 0)
2766
+ e.srcBuilder.add("@" + t.attribute.name, t.start, t.end);
2767
+ else {
2768
+ e.srcBuilder.add(
2769
+ "@" + t.attribute.name + "(",
2770
+ t.start,
2771
+ r[0].start
2772
+ );
2773
+ for (let s = 0; s < r.length; s++)
2774
+ at(r[s], e), s < r.length - 1 && e.srcBuilder.add(",", r[s].end, r[s + 1].start);
2775
+ e.srcBuilder.add(")", r[r.length - 1].end, t.end);
2776
+ }
2777
+ } else n === "@builtin" ? e.srcBuilder.add(
2778
+ "@builtin(" + t.attribute.param.name + ")",
2779
+ t.start,
2780
+ t.end
2781
+ ) : n === "@diagnostic" ? e.srcBuilder.add(
2782
+ "@diagnostic" + mt(t.attribute.severity, t.attribute.rule),
2783
+ t.start,
2784
+ t.end
2785
+ ) : n === "@if" || (n === "@interpolate" ? e.srcBuilder.add(
2786
+ `@interpolate(${t.attribute.params.map((r) => r.name).join(", ")})`,
2787
+ t.start,
2788
+ t.end
2789
+ ) : j(n));
2790
+ }
2791
+ function mt(t, e) {
2792
+ const n = e[0].name + (e[1] !== null ? "." + e[1].name : "");
2793
+ return `(${t.name}, ${n})`;
2794
+ }
2795
+ function D(t) {
2796
+ const { kind: e } = t;
2797
+ if (e === "binary-expression")
2798
+ return `${D(t.left)} ${t.operator.value} ${D(t.right)}`;
2799
+ if (e === "unary-expression")
2800
+ return `${t.operator.value}${D(t.expression)}`;
2801
+ if (e === "ref")
2802
+ return t.ident.originalName;
2803
+ if (e === "literal")
2804
+ return t.value;
2805
+ if (e === "translate-time-feature")
2806
+ return t.name;
2807
+ if (e === "parenthesized-expression")
2808
+ return `(${D(t.expression)})`;
2809
+ if (e === "component-expression")
2810
+ return `${D(t.base)}[${t.access}]`;
2811
+ if (e === "component-member-expression")
2812
+ return `${D(t.base)}.${t.access}`;
2813
+ if (e === "call-expression")
2814
+ return `${t.function.ident.originalName}(${t.arguments.map(D).join(", ")})`;
2815
+ j(e);
2816
+ }
2817
+ function ti(t, e) {
2818
+ const { directive: n } = t, { kind: r } = n;
2819
+ r === "diagnostic" ? e.srcBuilder.add(
2820
+ `diagnostic${mt(n.severity, n.rule)};`,
2821
+ t.start,
2822
+ t.end
2823
+ ) : r === "enable" ? e.srcBuilder.add(
2824
+ `enable ${n.extensions.map((s) => s.name).join(", ")};`,
2825
+ t.start,
2826
+ t.end
2827
+ ) : r === "requires" ? e.srcBuilder.add(
2828
+ `requires ${n.extensions.map((s) => s.name).join(", ")};`,
2829
+ t.start,
2830
+ t.end
2831
+ ) : j(r);
2832
+ }
2833
+ function Pn(t) {
2834
+ return Rt(t) ? (t.mangledName, `${Ct(t)}`, t.mangledName) : t.mangledName || t.originalName;
2835
+ }
2836
+ function St(t) {
2837
+ let e = t;
2838
+ do {
2839
+ if (e.kind === "decl")
2840
+ return e;
2841
+ e = e.refersTo;
2842
+ } while (e);
2843
+ throw new Error(`unresolved identifer: ${t.originalName}`);
2844
+ }
2845
+ function fe(t, e) {
2846
+ const n = t, { kind: r } = n;
2847
+ switch (r) {
2848
+ case "alias":
2849
+ case "assert":
2850
+ case "const":
2851
+ case "directive":
2852
+ case "member":
2853
+ case "var":
2854
+ case "let":
2855
+ case "statement":
2856
+ case "switch-clause":
2857
+ case "override":
2858
+ case "gvar":
2859
+ case "fn":
2860
+ case "struct":
2861
+ case "param":
2862
+ return Oe(n);
2863
+ }
2864
+ return !0;
2865
+ }
2866
+ function ei(t) {
2867
+ return $n(t) + ";";
2868
+ }
2869
+ function $n(t) {
2870
+ return [
2871
+ ...t.segments.map((e) => e.name),
2872
+ ni(t.finalSegment)
2873
+ ].join("::");
2874
+ }
2875
+ function ni(t) {
2876
+ if (t.kind === "import-item") {
2877
+ const { name: e, as: n } = t, r = n ? ` as ${n}` : "";
2878
+ return `${e}${r}`;
2879
+ } else {
2880
+ if (t.kind === "import-collection")
2881
+ return `{${t.subtrees.map((e) => $n(e)).join(", ")}}`;
2882
+ Tt(t);
2883
+ }
2884
+ }
2885
+ const Nn = 150;
2886
+ function wt(t, e = 0) {
2887
+ const { kind: n } = t, r = new ee(e, Nn);
2888
+ r.add(n), ri(t, r);
2889
+ let s = [];
2890
+ return "contents" in t && (s = t.contents.map((o) => wt(o, e + 2))), s.length && (r.nl(), r.addBlock(s.join(`
2891
+ `), !1)), r.result;
2892
+ }
2893
+ function ri(t, e) {
2894
+ const { kind: n } = t;
2895
+ if (n === "text") {
2896
+ const { srcModule: r, start: s, end: o } = t;
2897
+ e.add(` '${r.src.slice(s, o)}'`);
2898
+ } else if (n === "var" || n === "let" || n === "gvar" || n === "const" || n === "override")
2899
+ $e(t.name, e), rt(t.attributes, e);
2900
+ else if (n === "struct")
2901
+ e.add(" " + t.name.ident.originalName);
2902
+ else if (n === "member") {
2903
+ const { name: r, typeRef: s, attributes: o } = t;
2904
+ rt(o, e), e.add(" " + r.name), e.add(": " + Q(s));
2905
+ } else if (n === "name")
2906
+ e.add(" " + t.name);
2907
+ else if (n === "memberRef") {
2908
+ const { extraComponents: r } = t, s = r ? ci(r) : "";
2909
+ e.add(` ${t.name.ident.originalName}.${t.member.name}${s}`);
2910
+ } else if (n === "fn")
2911
+ oi(t, e);
2912
+ else if (n === "alias") {
2913
+ const { name: r, typeRef: s } = t, o = r.ident.kind === "decl" ? "%" : "";
2914
+ e.add(" " + o + r.ident.originalName), e.add("=" + Q(s));
2915
+ } else if (n === "attribute")
2916
+ Mn(t.attribute, e);
2917
+ else if (n === "expression") {
2918
+ const r = t.contents.map((s) => s.kind === "text" ? "'" + s.srcModule.src.slice(s.start, s.end) + "'" : wt(s)).join(" ");
2919
+ e.add(" " + r);
2920
+ } else if (n === "type") {
2921
+ const { name: r } = t, s = typeof r == "string" ? r : r.originalName;
2922
+ if (e.add(" " + s), t.templateParams !== void 0) {
2923
+ const o = t.templateParams.map(An).join(", ");
2924
+ e.add("<" + o + ">");
2925
+ }
2926
+ } else if (n === "synthetic")
2927
+ e.add(` '${t.text}'`);
2928
+ else if (n === "import")
2929
+ e.add(" " + ei(t.imports));
2930
+ else if (n === "ref")
2931
+ e.add(" " + t.ident.originalName);
2932
+ else if (n === "typeDecl")
2933
+ $e(t, e);
2934
+ else if (n === "decl") {
2935
+ const { ident: r } = t;
2936
+ e.add(" %" + r.originalName);
2937
+ } else n === "assert" || n === "module" || n === "param" || n === "stuff" || (n === "directive" ? ai(t, e) : n === "statement" ? rt(t.attributes, e) : n === "switch-clause" || Tt(n));
2938
+ }
2939
+ function Mn(t, e) {
2940
+ const { kind: n } = t;
2941
+ if (n === "@attribute") {
2942
+ const { name: r, params: s } = t;
2943
+ e.add(" @" + r), s && s.length > 0 && (e.add("("), e.add(s.map(Cn).join(", ")), e.add(")"));
2944
+ } else n === "@builtin" ? e.add(` @builtin(${t.param.name})`) : n === "@diagnostic" ? e.add(
2945
+ ` @diagnostic${mt(t.severity, t.rule)}`
2946
+ ) : n === "@if" ? (e.add(" @if"), e.add("("), e.add(D(t.param.expression)), e.add(")")) : n === "@interpolate" ? e.add(` @interpolate(${t.params.map((r) => r.name).join(", ")})`) : Tt(n);
2947
+ }
2948
+ function si(t) {
2949
+ const e = new ee(0, Nn);
2950
+ return Mn(t, e), e.result;
2951
+ }
2952
+ function $e(t, e) {
2953
+ const { decl: n, typeRef: r } = t;
2954
+ e.add(" %" + n.ident.originalName), r && e.add(" : " + Q(r));
2955
+ }
2956
+ function oi(t, e) {
2957
+ const { name: n, params: r, returnType: s, attributes: o } = t;
2958
+ e.add(" " + n.ident.originalName), e.add("(");
2959
+ const i = r.map(
2960
+ (a) => {
2961
+ const { name: l } = a, { originalName: c } = l.decl.ident, d = Q(l.typeRef);
2962
+ return c + ": " + d;
2963
+ }
2964
+ ).join(", ");
2965
+ e.add(i), e.add(")"), rt(o, e), s && e.add(" -> " + Q(s));
2966
+ }
2967
+ function rt(t, e) {
2968
+ t == null || t.forEach((n) => e.add(" " + ii(n.attribute)));
2969
+ }
2970
+ function ii(t) {
2971
+ const { kind: e } = t;
2972
+ return e === "@attribute" ? "@" + t.name : e;
2973
+ }
2974
+ function ai(t, e) {
2975
+ const { directive: n, attributes: r } = t, { kind: s } = n;
2976
+ if (s === "diagnostic") {
2977
+ const { severity: o, rule: i } = n, a = mt(o, i);
2978
+ e.add(` diagnostic${a}`);
2979
+ } else s === "enable" || s === "requires" ? e.add(` ${s} ${n.extensions.map((o) => o.name).join(", ")}`) : Tt(s);
2980
+ rt(r, e);
2981
+ }
2982
+ function Cn(t) {
2983
+ return "contents" in t ? t.contents.map((n) => n.kind === "text" ? "'" + n.srcModule.src.slice(n.start, n.end) + "'" : wt(n)).join(" ") : wt(t);
2984
+ }
2985
+ function An(t) {
2986
+ return typeof t == "string" ? t : t.kind === "type" ? Q(t) : t.kind === "expression" ? Cn(t) : (console.log("unknown template parameter type", t), "??");
2987
+ }
2988
+ function Q(t) {
2989
+ if (!t) return "?type?";
2990
+ const { name: e } = t, n = typeof e == "string" ? e : e.originalName;
2991
+ let r = "";
2992
+ return t.templateParams !== void 0 && (r = "<" + t.templateParams.map(An).join(", ") + ">"), n + r;
2993
+ }
2994
+ function ci(t) {
2995
+ return t.contents.map((n) => {
2996
+ const { kind: r } = n;
2997
+ return r === "text" ? n.srcModule.src.slice(n.start, n.end) : r === "ref" ? n.ident.originalName : `?${n.kind}?`;
2998
+ }).join(" ");
2999
+ }
3000
+ class li {
3001
+ constructor(e) {
3002
+ this.sourceMap = e;
3003
+ }
3004
+ /**
3005
+ * Creates a {@link GPUShaderModule}.
3006
+ * When errors occur, they will point at the original WESL source code.
3007
+ *
3008
+ * The compilation info {@link GPUShaderModule.getCompilationInfo}
3009
+ * can be remapped with {@link mapGPUCompilationInfo}
3010
+ * @param device GPUDevice. Preferably a {@link WeslDevice} for better error reporting.
3011
+ * @param descriptor - Description of the {@link GPUShaderModule} to create.
3012
+ */
3013
+ createShaderModule(e, n) {
3014
+ if (!("injectError" in e))
3015
+ return e.createShaderModule({
3016
+ ...n,
3017
+ code: this.dest
3018
+ });
3019
+ e.pushErrorScope("validation");
3020
+ const r = e.createShaderModule({
3021
+ ...n,
3022
+ code: this.dest
3023
+ });
3024
+ e.popErrorScope();
3025
+ let { promise: s, resolve: o } = Promise.withResolvers();
3026
+ return e.injectError("validation", s), r.getCompilationInfo().then((i) => {
3027
+ if (i.messages.length === 0) {
3028
+ o(null);
3029
+ return;
3030
+ }
3031
+ const a = this.mapGPUCompilationInfo(i), l = ui(
3032
+ a,
3033
+ r
3034
+ );
3035
+ qn(l !== null);
3036
+ const c = new GPUValidationError(
3037
+ l
3038
+ );
3039
+ c.cause = new Error("createShaderModule failed"), c.compilationInfo = a, o(c);
3040
+ }), r;
3041
+ }
3042
+ /**
3043
+ * Use {@link LinkedWesl.createShaderModule} for a
3044
+ * better error reporting experience.
3045
+ */
3046
+ get dest() {
3047
+ return this.sourceMap.dest.text;
3048
+ }
3049
+ /** Turns raw compilation info into compilation info
3050
+ * that points at the WESL sources. */
3051
+ mapGPUCompilationInfo(e) {
3052
+ return {
3053
+ __brand: e.__brand,
3054
+ messages: e.messages.map(
3055
+ (n) => this.mapGPUCompilationMessage(n)
3056
+ )
3057
+ };
3058
+ }
3059
+ mapGPUCompilationMessage(e) {
3060
+ const n = this.sourceMap, r = n.destToSrc(e.offset), o = (e.length > 0 ? n.destToSrc(e.offset + e.length) : r).position - r.position;
3061
+ let [i, a] = Qt(
3062
+ r.position,
3063
+ r.src.text
3064
+ );
3065
+ return {
3066
+ __brand: e.__brand,
3067
+ type: e.type,
3068
+ message: e.message,
3069
+ offset: r.position,
3070
+ length: o,
3071
+ lineNum: i,
3072
+ linePos: a,
3073
+ module: {
3074
+ url: r.src.path ?? "",
3075
+ text: r.src.text
3076
+ }
3077
+ };
3078
+ }
3079
+ }
3080
+ function ui(t, e) {
3081
+ if (t.messages.length === 0) return null;
3082
+ let n = `Compilation log for [Invalid ShaderModule (${e.label || "unlabled"})]:
3083
+ `, r = t.messages.filter(
3084
+ (s) => s.type === "error"
3085
+ ).length;
3086
+ r > 0 && (n += `${r} error(s) generated while compiling the shader:
3087
+ `);
3088
+ for (const s of t.messages) {
3089
+ const { lineNum: o, linePos: i } = s;
3090
+ n += `${s.module.url}:${o}:${i}`, n += ` ${s.type}: ${s.message}
3091
+ `;
3092
+ const a = s.module.text;
3093
+ a && (n += De(a, [
3094
+ s.offset,
3095
+ s.offset + s.length
3096
+ ]).join(`
3097
+ `));
3098
+ }
3099
+ return n;
3100
+ }
3101
+ function di(t) {
3102
+ const n = t.split("/").filter((s) => s !== "."), r = [];
3103
+ return n.forEach((s) => {
3104
+ s !== "" && (s === ".." && r.length && r[r.length - 1] !== ".." ? r.pop() : r.push(s));
3105
+ }), r.join("/");
3106
+ }
3107
+ function fi(t) {
3108
+ const e = t.lastIndexOf("/"), n = e === -1 ? 0 : e + 1, r = t.indexOf(".", n), s = r === -1 ? t.length : r;
3109
+ return t.slice(0, s);
3110
+ }
3111
+ function pi() {
3112
+ return Tr(), { modules: {} };
3113
+ }
3114
+ function Gi(t) {
3115
+ return `modules: ${[...Object.keys(t.modules)]}`;
3116
+ }
3117
+ function Xi(t) {
3118
+ const e = Object.entries(t).map(([n, r]) => {
3119
+ const s = To(r);
3120
+ return [n, s];
3121
+ });
3122
+ return { modules: Object.fromEntries(e) };
3123
+ }
3124
+ function mi(t, e, n = "package") {
3125
+ let r;
3126
+ return e.includes("::") ? r = e : e.includes("/") || e.endsWith(".wesl") || e.endsWith(".wgsl") ? r = Bn(e, n) : r = n + "::" + e, t.modules[r];
3127
+ }
3128
+ function Rn(t, e, n = "package", r) {
3129
+ r === void 0 ? r = "" : r.endsWith("/") || (r += "/"), Object.entries(t).map(
3130
+ ([o, i]) => ({ modulePath: Bn(o, n), debugFilePath: r + o, src: i })
3131
+ ).forEach((o) => {
3132
+ const i = ce(o);
3133
+ if (e.modules[o.modulePath])
3134
+ throw new Error(`duplicate module path: '${o.modulePath}'`);
3135
+ e.modules[o.modulePath] = i;
3136
+ });
3137
+ }
3138
+ function hi(t, e) {
3139
+ t.forEach(
3140
+ ({ modules: n, name: r }) => Rn(n, e, r)
3141
+ );
3142
+ }
3143
+ const gi = /^lib\.w[eg]sl$/i;
3144
+ function Bn(t, e) {
3145
+ if (t.includes("::"))
3146
+ return t;
3147
+ if (e !== "package" && gi.test(t))
3148
+ return e;
3149
+ const r = fi(di(t)).replaceAll("/", "::");
3150
+ return e + "::" + r;
3151
+ }
3152
+ async function Ji(t) {
3153
+ const { weslSrc: e, debugWeslRoot: n, libs: r = [] } = t, s = pi();
3154
+ return Rn(e, s, "package", n), hi(r, s), new li(bi({ registry: s, ...t }));
3155
+ }
3156
+ function bi(t) {
3157
+ const e = xi(t), { transformedAst: n, newDecls: r, newStatements: s } = e;
3158
+ return ht.build(
3159
+ yi(
3160
+ n.moduleElem,
3161
+ n.srcModule,
3162
+ r,
3163
+ s,
3164
+ t.conditions
3165
+ )
3166
+ );
3167
+ }
3168
+ function xi(t) {
3169
+ const { registry: e, mangler: n } = t, { rootModuleName: r = "main", conditions: s = {} } = t, o = _i(e, r), { constants: i, config: a } = t;
3170
+ let { virtualLibs: l } = t;
3171
+ i && (l = { ...l, constants: ki(i) });
3172
+ let c = l && Sr(l, (U) => ({ fn: U }));
3173
+ const p = Ro({ rootAst: o, registry: e, conditions: s, virtuals: c, mangler: n }), { globalNames: h, decls: x, newStatements: P } = p;
3174
+ return { transformedAst: vi(o, h, a), newDecls: x, newStatements: P };
3175
+ }
3176
+ function ki(t) {
3177
+ return () => Object.entries(t).map(([e, n]) => `const ${e} = ${n};`).join(`
3178
+ `);
3179
+ }
3180
+ function _i(t, e) {
3181
+ const n = mi(t, e);
3182
+ if (!n)
3183
+ throw new Error(`Root module not found: ${e}`);
3184
+ return n;
3185
+ }
3186
+ function vi(t, e, n) {
3187
+ const { moduleElem: r, srcModule: s } = t, o = { moduleElem: r, srcModule: s, globalNames: e, notableElems: {} }, i = (n == null ? void 0 : n.plugins) ?? [];
3188
+ return Zt(i, (c) => c.transform).reduce(
3189
+ (c, d) => d(c),
3190
+ o
3191
+ );
3192
+ }
3193
+ function yi(t, e, n, r, s = {}) {
3194
+ const o = r.map((l) => {
3195
+ const { elem: c, srcModule: d } = l, { src: p, debugFilePath: h } = d, x = new ht({ text: p, path: h });
3196
+ return Lt(x, [c], s), x.addNl(), x;
3197
+ }), i = new ht({
3198
+ text: e.src,
3199
+ path: e.debugFilePath
3200
+ });
3201
+ Lt(i, [t], s, !1);
3202
+ const a = n.map((l) => {
3203
+ const c = new ht({
3204
+ text: l.srcModule.src,
3205
+ path: l.srcModule.debugFilePath
3206
+ });
3207
+ return Lt(c, [l.declElem], s), c;
3208
+ });
3209
+ return [...o, i, ...a];
3210
+ }
3211
+ function In(t, e) {
3212
+ e(t), t.contents && t.contents.forEach((r) => In(r, e));
3213
+ }
3214
+ function Ei(t) {
3215
+ const { kind: e } = t.attribute;
3216
+ if (e === "@attribute") {
3217
+ const { params: n } = t.attribute;
3218
+ return n === void 0 || n.length === 0 ? "@" + t.attribute.name : `@${t.attribute.name}(${n.map((r) => pe(r)).join(", ")})`;
3219
+ } else {
3220
+ if (e === "@builtin")
3221
+ return "@builtin(" + t.attribute.param.name + ")";
3222
+ if (e === "@diagnostic")
3223
+ return "@diagnostic" + mt(t.attribute.severity, t.attribute.rule);
3224
+ if (e === "@if")
3225
+ return `@if(${D(t.attribute.param.expression)})`;
3226
+ if (e === "@interpolate")
3227
+ return `@interpolate(${t.attribute.params.map((n) => n.name).join(", ")})`;
3228
+ j(e);
3229
+ }
3230
+ }
3231
+ function Bt(t) {
3232
+ return `<${t.map(Ln).join(", ")}>`;
3233
+ }
3234
+ function Ln(t) {
3235
+ if (t === void 0) return "?";
3236
+ if (typeof t == "string") return t;
3237
+ if (t.kind === "expression") return pe(t);
3238
+ if (t.kind === "type") return Si(t);
3239
+ j(t);
3240
+ }
3241
+ function Si(t) {
3242
+ if (!t) return "?";
3243
+ const { name: e, templateParams: n } = t, r = n ? Bt(n) : "";
3244
+ return `${jn(e)}${r}`;
3245
+ }
3246
+ function jn(t) {
3247
+ if (typeof t == "string") return t;
3248
+ if (t.std) return t.originalName;
3249
+ const e = St(t);
3250
+ return e.mangledName || e.originalName;
3251
+ }
3252
+ function pe(t) {
3253
+ if (t.kind === "translate-time-expression")
3254
+ throw new Error("Not supported");
3255
+ if (t.kind === "expression" || t.kind === "stuff")
3256
+ return t.contents.map((n) => {
3257
+ const { kind: r } = n;
3258
+ return r === "text" ? n.srcModule.src.slice(n.start, n.end) : r === "ref" ? jn(n.ident) : `?${n.kind}?`;
3259
+ }).join(" ");
3260
+ if (t.kind === "name")
3261
+ return t.name;
3262
+ j(t);
3263
+ }
3264
+ const wi = Mt(En);
3265
+ Mt(vn);
3266
+ Mt(yn);
3267
+ function Ki() {
3268
+ return {
3269
+ transform: Ti
3270
+ };
3271
+ }
3272
+ function Ti(t) {
3273
+ const e = structuredClone(t), { moduleElem: n, globalNames: r, notableElems: s } = e, o = Mi(n);
3274
+ Pi(n, o);
3275
+ const i = o.flatMap(
3276
+ (c) => Ri(c, r)
3277
+ ), a = ji(n);
3278
+ a.forEach(
3279
+ ({ memberRef: c, struct: d }) => Fi(c, d)
3280
+ ), a.forEach(
3281
+ ({ intermediates: c }) => c.forEach((d) => d.contents = [])
3282
+ );
3283
+ const l = Ni(n);
3284
+ return n.contents = [...i, ...l], s.bindingStructs = o, { ...e, moduleElem: n };
3285
+ }
3286
+ function Pi(t, e) {
3287
+ const n = t.contents.filter((s) => s.kind === "fn"), r = $i(n, e);
3288
+ if (r) {
3289
+ const { fn: s, struct: o } = r;
3290
+ o.entryFn = s;
3291
+ }
3292
+ }
3293
+ function $i(t, e) {
3294
+ var n, r, s;
3295
+ for (const o of t) {
3296
+ const { params: i } = o;
3297
+ for (const a of i) {
3298
+ const l = (r = (n = a.name) == null ? void 0 : n.typeRef) == null ? void 0 : r.name, c = (s = l == null ? void 0 : l.refersTo) == null ? void 0 : s.declElem, d = e.find((p) => p === c);
3299
+ if (d)
3300
+ return { fn: o, struct: d };
3301
+ }
3302
+ }
3303
+ }
3304
+ function Ni(t) {
3305
+ return t.contents.filter(
3306
+ (e) => e.kind !== "struct" || !e.bindingStruct
3307
+ );
3308
+ }
3309
+ function Mi(t) {
3310
+ const n = t.contents.filter((r) => r.kind === "struct").filter(Ci);
3311
+ return n.forEach((r) => r.bindingStruct = !0), n;
3312
+ }
3313
+ function Ci(t) {
3314
+ return t.members.some(({ attributes: e }) => Ai(e));
3315
+ }
3316
+ function Ai(t) {
3317
+ return t ? t.some(
3318
+ ({ attribute: e }) => e.kind === "@attribute" && (e.name === "binding" || e.name === "group")
3319
+ ) : !1;
3320
+ }
3321
+ function Ri(t, e) {
3322
+ return t.members.map((n) => {
3323
+ var h;
3324
+ const { typeRef: r, name: s } = n, { name: o } = r, i = r == null ? void 0 : r.templateParams, a = Je(s.name, e);
3325
+ n.mangledVarName = a, e.add(a);
3326
+ const l = ((h = n.attributes) == null ? void 0 : h.map(Ei).join(" ")) ?? "", c = Bi(n, o, i) ?? Ii(o, i) ?? Li(o, i);
3327
+ if (!c)
3328
+ return console.log("unhandled case transforming member", o), Ne(l, a, "", "??");
3329
+ const { storage: d, varType: p } = c;
3330
+ return Ne(l, a, d, p);
3331
+ });
3332
+ }
3333
+ function Bi(t, e, n, r) {
3334
+ if (e.originalName === "ptr") {
3335
+ const s = n ?? [], o = [s[0]];
3336
+ s[2] && o.push(s[2]);
3337
+ const i = Bt(o), a = Ln(s == null ? void 0 : s[1]);
3338
+ return { storage: i, varType: a };
3339
+ }
3340
+ }
3341
+ function Ii(t, e) {
3342
+ if (typeof t != "string") {
3343
+ const n = t.std ? t.originalName : "??", r = e ? Bt(e) : "";
3344
+ return { varType: n + r, storage: "" };
3345
+ }
3346
+ }
3347
+ function Li(t, e) {
3348
+ if (wi.test(t.originalName)) {
3349
+ const n = e ? Bt(e) : "";
3350
+ return { varType: t + n, storage: "" };
3351
+ }
3352
+ }
3353
+ function Ne(t, e, n, r) {
3354
+ return {
3355
+ kind: "synthetic",
3356
+ text: `${t} var${n} ${e} : ${r};
3357
+ `
3358
+ };
3359
+ }
3360
+ function ji(t) {
3361
+ const e = [];
3362
+ return In(t, (n) => {
3363
+ n.kind === "memberRef" && e.push(n);
3364
+ }), Zt(e, Di);
3365
+ }
3366
+ function Di(t) {
3367
+ const e = Oi(t.name.ident);
3368
+ if (e && e.struct.bindingStruct)
3369
+ return { memberRef: t, ...e };
3370
+ }
3371
+ function Oi(t) {
3372
+ const n = St(t).declElem;
3373
+ if (n && n.kind === "param") {
3374
+ const r = n.name.typeRef.name;
3375
+ if (typeof r != "string") {
3376
+ if (r.std)
3377
+ return;
3378
+ const o = St(r).declElem;
3379
+ return (o == null ? void 0 : o.kind) === "struct" ? { struct: o, intermediates: [n] } : void 0;
3380
+ }
3381
+ }
3382
+ }
3383
+ function Fi(t, e) {
3384
+ const n = t.member.name, r = e.members.find((l) => l.name.name === n);
3385
+ if (!r || !r.mangledVarName)
3386
+ return { kind: "synthetic", text: n };
3387
+ const { extraComponents: s } = t, o = s ? pe(s) : "", a = { kind: "synthetic", text: r.mangledVarName + o };
3388
+ return t.contents = [a], a;
3389
+ }
3390
+ export {
3391
+ li as LinkedWesl,
3392
+ wo as WeslParseError,
3393
+ hs as WeslStream,
3394
+ wt as astToString,
3395
+ si as attributeToString,
3396
+ xi as bindAndTransform,
3397
+ Ki as bindingStructsPlugin,
3398
+ _n as blankWeslParseState,
3399
+ ci as debugContentsToString,
3400
+ ji as findRefsToBindingStructs,
3401
+ Po as flatImports,
3402
+ Ct as identToString,
3403
+ Ji as link,
3404
+ bi as linkRegistry,
3405
+ Ti as lowerBindingStructs,
3406
+ Vi as makeWeslDevice,
3407
+ Mi as markBindingStructs,
3408
+ Pi as markEntryTypes,
3409
+ fi as noSuffix,
3410
+ di as normalize,
3411
+ Rn as parseIntoRegistry,
3412
+ hi as parseLibsIntoRegistry,
3413
+ ce as parseSrcModule,
3414
+ To as parseWESL,
3415
+ Xi as parseWeslSrc,
3416
+ pi as parsedRegistry,
3417
+ Gi as registryToString,
3418
+ Ge as scopeToString,
3419
+ Wi as scopeToStringLong,
3420
+ mi as selectModule,
3421
+ zi as syntheticWeslParseState,
3422
+ kn as throwClickableError,
3423
+ Fi as transformBindingReference,
3424
+ Ri as transformBindingStruct
3425
+ };
3426
+ //# sourceMappingURL=minified.js.map