spatialscape 0.3.0__py3-none-any.whl

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 (58) hide show
  1. spatialscape/__init__.py +13 -0
  2. spatialscape/_app/assets/array-utils-flat-BL8Cekj1.js +13 -0
  3. spatialscape/_app/assets/blosc-DEOJs6D5.js +18 -0
  4. spatialscape/_app/assets/blosc-Df7TknHH.js +18 -0
  5. spatialscape/_app/assets/chunk-INHXZS53-DAOLzMPX.js +2 -0
  6. spatialscape/_app/assets/chunk-INHXZS53-DfBSTIxr.js +2 -0
  7. spatialscape/_app/assets/deflate-B2AbjNo_.js +2 -0
  8. spatialscape/_app/assets/expression-E359vKZW.js +368 -0
  9. spatialscape/_app/assets/get-attribute-from-layouts-Dd2gixpo.js +2 -0
  10. spatialscape/_app/assets/index-BKPnXJSt.css +1 -0
  11. spatialscape/_app/assets/index-Gxpj1e1n.js +8454 -0
  12. spatialscape/_app/assets/jpeg-b0MwBR_9.js +2 -0
  13. spatialscape/_app/assets/lerc-ujbbHc0C.js +2 -0
  14. spatialscape/_app/assets/lz4-BFJkNc3o.js +16 -0
  15. spatialscape/_app/assets/lz4-DNE3IovK.js +16 -0
  16. spatialscape/_app/assets/lzw-DfRkoFB0.js +2 -0
  17. spatialscape/_app/assets/packbits-BDCGuk_Z.js +2 -0
  18. spatialscape/_app/assets/pako.esm-Ch1S5qKo.js +2 -0
  19. spatialscape/_app/assets/raw-vNZ-QFXZ.js +2 -0
  20. spatialscape/_app/assets/webgl-D2Fkccwd.js +345 -0
  21. spatialscape/_app/assets/webimage-DDU0IC05.js +2 -0
  22. spatialscape/_app/assets/worker-CUy87eWB.js +8 -0
  23. spatialscape/_app/assets/zstd-CGD_7wnU.js +16 -0
  24. spatialscape/_app/assets/zstd-qXhZ_1DN.js +16 -0
  25. spatialscape/_app/favicon.svg +161 -0
  26. spatialscape/_app/index.html +23 -0
  27. spatialscape/build.py +630 -0
  28. spatialscape/cli.py +399 -0
  29. spatialscape/config.py +570 -0
  30. spatialscape/convert.py +321 -0
  31. spatialscape/discover.py +98 -0
  32. spatialscape/expression.py +300 -0
  33. spatialscape/fingerprint.py +152 -0
  34. spatialscape/genes.py +251 -0
  35. spatialscape/geometry.py +132 -0
  36. spatialscape/images.py +240 -0
  37. spatialscape/init.py +578 -0
  38. spatialscape/manifest.py +162 -0
  39. spatialscape/obs.py +48 -0
  40. spatialscape/outlines.py +145 -0
  41. spatialscape/polygons.py +85 -0
  42. spatialscape/rds.py +609 -0
  43. spatialscape/rdsread.py +556 -0
  44. spatialscape/readers.py +195 -0
  45. spatialscape/registry.py +83 -0
  46. spatialscape/serve.py +262 -0
  47. spatialscape/session.py +474 -0
  48. spatialscape/site.py +274 -0
  49. spatialscape/synthetic.py +142 -0
  50. spatialscape/thumbnail.py +95 -0
  51. spatialscape/tracks.py +551 -0
  52. spatialscape/validate.py +193 -0
  53. spatialscape/vocab.py +188 -0
  54. spatialscape-0.3.0.dist-info/METADATA +68 -0
  55. spatialscape-0.3.0.dist-info/RECORD +58 -0
  56. spatialscape-0.3.0.dist-info/WHEEL +4 -0
  57. spatialscape-0.3.0.dist-info/entry_points.txt +3 -0
  58. spatialscape-0.3.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,345 @@
1
+ import{_ as e,a as t,n,r,t as i,v as a}from"./expression-E359vKZW.js";import{l as o}from"./get-attribute-from-layouts-Dd2gixpo.js";import{n as s,r as c}from"./index-Gxpj1e1n.js";function l(e,t,n=!1){if(n)return t===1?`float`:`vec${t}`;switch(e){case`uint8`:case`uint16`:case`uint32`:return t===1?`uint`:`uvec${t}`;case`sint8`:case`sint16`:case`sint32`:return t===1?`int`:`ivec${t}`;default:return t===1?`float`:`vec${t}`}}function u(e,t,n=!1){let r;if(n)switch(e){case`uint8`:r=`unorm8`;break;case`sint8`:r=`snorm8`;break;case`uint16`:r=`unorm16`;break;case`sint16`:r=`snorm16`;break;case`float32`:r=`float32`;break;default:throw Error(`Unsupported normalized vertex format for ${e}`)}else r=e;return t===1?r:t===3&&!r.startsWith(`float32`)&&!r.endsWith(`32`)?`${r}x3-webgl`:`${r}x${t}`}function d(e){switch(e[0]){case`u`:return`0u`;case`s`:return`0`;default:return`0.`}}function f(e,t){switch(e){case`uint8`:case`uint16`:case`uint32`:return`${Math.trunc(t)}u`;case`sint8`:case`sint16`:case`sint32`:return`${Math.trunc(t)}`;default:return Number.isInteger(t)?`${t}.0`:`${t}`}}function p(e){switch(e){case`uint8`:return`r8uint`;case`sint8`:return`r8sint`;case`uint16`:return`r16uint`;case`sint16`:return`r16sint`;case`uint32`:return`r32uint`;case`sint32`:return`r32sint`;case`float32`:return`r32float`;default:throw Error(`Unsupported WebGL gather texture format for ${e}`)}}function m(e){return e}function h(e){switch(e){case`uint32`:return`usampler2D`;case`sint32`:return`isampler2D`;case`float32`:return`sampler2D`;default:throw Error(`Unsupported WebGL gather sampler type for ${e}`)}}var g=`GPGPU Operation Counts`,_=`Transform Runs`,v=new a;function y({module:e,elementWise:n=!1,expression:i,inputs:a,output:o,operationType:c=o.type,outputBuffer:u}){let f=u.device,p=C(`result`,o.type,o.size,o.normalized),m=[e,p],h=[],y={},w=l(o.type,1,o.normalized),T=l(c,1,o.normalized),E=``,D=null,O={TYPE:T,RESULT_LEN:o.size.toString()},k=b(a);for(let[e,n]of k)m.push(x(e,n.type,n.size,n.normalized,c)),h.push(S(e,n)),n instanceof r?y[e]=n.buffer:(D||=t.createOrReuse(f,u.byteLength),y[e]=D),E+=`TYPE ${e}[${n.size}]; get_${e}(${e});\n`,O[`${e.toUpperCase()}_LEN`]=n.size.toString();let A=``;if(i)for(let e=0;e<o.size;e++)A+=`result[${e}]=${i(e)};\n`;else if(n)for(let t=0;t<o.size;t++){let n=d(T),r=k.map(([e,r])=>t<r.size?`${e}[${t}]`:n);A+=`result[${t}]=${e.name}(${r.join(`, `)});\n`}else A=`${e.name}(${k.map(([e])=>e).join(`, `)}, result);`;let j=`\
2
+ #version 300 es
3
+
4
+ void main() {
5
+ ${E}
6
+ ${w} result[${o.size}];
7
+ ${A}
8
+ set_result(result);
9
+ }
10
+ `,M=new s(f,{vs:j,shaderAssembler:v,defines:O,modules:m,bufferLayout:h,vertexCount:1,instanceCount:o.length,attributes:y,feedbackBufferMode:`interleaved`,outputs:p.varyings});f.statsManager.getStats(g).get(_).incrementCount(),M.run({inputBuffers:y,outputBuffers:{[p.varyings[0]]:o.offset===0?u:{buffer:u,byteOffset:o.offset,byteLength:o.byteLength}}}),D&&t.recycle(D)}function b(e){return Array.isArray(e)?e.map((e,t)=>[`x${t}`,e]):Object.entries(e)}function x(e,t,n,r=!1,i=t){let a=``,o=``;for(let s=0;s<n;s+=4){let c=Math.min(n-s,4),u=l(t,c,r);a+=`in ${u} a${e}_${s};\n`;for(let n=0;n<c;n++){let a=`a${e}_${s}`;c>1&&(a=`${a}[${n}]`),(r||t!==i)&&(a=`TYPE(${a})`),o+=`v[${s+n}]=${a};\n`}}return{name:e,vs:`
11
+ ${a}
12
+ void get_${e}(out TYPE v[${n}]) {
13
+ ${o}
14
+ }
15
+ `}}function S(e,t){let n={name:e,stepMode:t.isConstant?`vertex`:`instance`,byteStride:t.stride,attributes:[]};for(let r=0;r<t.size;r+=4){let i=Math.min(t.size-r,4);n.attributes.push({attribute:`a${e}_${r}`,format:u(t.type,i,t.normalized),byteOffset:t.offset+t.ValueType.BYTES_PER_ELEMENT*r})}return n}function C(e,t,n,r=!1){let i=[],a=l(t,1,r),o=``,s=``;for(let a=0;a<n;a+=4){let c=Math.min(n-a,4),u=l(t,c,r);i.push(`${e}_${a}`),o+=`flat out ${u} ${e}_${a};\n`;let d=Array.from({length:c},(e,t)=>a+t);s+=`${e}_${a} = ${u}(${d.map(e=>`v[${e}]`).join(`,`)});\n`}return{name:e,varyings:i,vs:`
16
+ ${o}
17
+ void set_${e}(in ${a} v[${n}]) {
18
+ ${s}
19
+ }
20
+ `}}var w=`TYPE arithmetic_add(TYPE x, TYPE y) {
21
+ return x + y;
22
+ }
23
+
24
+ TYPE arithmetic_subtract(TYPE x, TYPE y) {
25
+ return x - y;
26
+ }
27
+
28
+ TYPE arithmetic_multiply(TYPE x, TYPE y) {
29
+ return x * y;
30
+ }
31
+
32
+ TYPE arithmetic_divide(TYPE x, TYPE y) {
33
+ return x / y;
34
+ }
35
+
36
+ float arithmetic_tan(float x) {
37
+ return tan_fp32(x);
38
+ }
39
+ `,T=({inputs:t,output:r,target:a})=>{let o=r.type,s=l(o,1,r.normalized),c=d(s),u=t.namedInputs;return y({module:{name:`arithmetic`,dependencies:[e],vs:w},inputs:u,output:r,operationType:o,outputBuffer:a,expression:e=>i(t.expression,{operations:n,inputs:u,laneIndex:e,formatInput:t=>`${t}[${e}]`,formatOutOfBoundsInput:e=>u[e].size===1?`${e}[0]`:c,formatLiteral:t=>{let n=Array.isArray(t)?t[e]??0:t;return`${s}(${f(o,n)})`},formatCall:(e,t)=>`${e}(${t.join(`, `)})`})}),{success:!0}},E=`GPGPU Operation Counts`,D=`Transform Runs`,O=({inputs:e,output:n,target:i})=>{let{sourceValues:a}=e,s=i.device;if(a.length===0){let e=new n.ValueType(n.length*n.size);return i.write(e),{success:!0,value:e}}if(a.isConstant){let e=a.value,t=new n.ValueType(n.length*n.size);for(let r=0;r<n.length;r++){let n=e[r];t[r*2]=n,t[r*2+1]=n}return i.write(t),{success:!0,value:t}}let l=s.createTexture({width:1,height:n.length,format:`rg32float`,usage:o.RENDER|o.COPY_SRC|o.COPY_DST}),u=s.createFramebuffer({colorAttachments:[l]}),d=new c(s,{vs:`#version 300 es
40
+
41
+ flat out float extent_value;
42
+
43
+ void main() {
44
+ float sourceValues[SOURCE_VALUES_LEN];
45
+ get_sourceValues(sourceValues);
46
+ extent_value = sourceValues[gl_VertexID];
47
+
48
+ float y = (float(gl_VertexID) + 0.5) / float(CHANNEL_COUNT) * 2.0 - 1.0;
49
+ gl_Position = vec4(0.0, y, 0.0, 1.0);
50
+ gl_PointSize = 1.0;
51
+ }
52
+ `,fs:`#version 300 es
53
+
54
+ precision highp float;
55
+
56
+ flat in float extent_value;
57
+ out vec2 fragColor;
58
+
59
+ void main() {
60
+ fragColor = vec2(-extent_value, extent_value);
61
+ }
62
+ `,topology:`point-list`,parameters:{depthCompare:`always`,blend:!0,blendColorSrcFactor:`one`,blendColorDstFactor:`one`,blendColorOperation:`max`,blendAlphaSrcFactor:`one`,blendAlphaDstFactor:`one`,blendAlphaOperation:`max`},modules:[x(`sourceValues`,a.type,a.size,a.normalized)],defines:{TYPE:`float`,SOURCE_VALUES_LEN:a.size.toString(),CHANNEL_COUNT:n.length.toString()},attributes:{sourceValues:a.buffer},bufferLayout:[S(`sourceValues`,a)],instanceCount:a.length,vertexCount:n.length,disableWarnings:!0}),f=t.createOrReuse(s,n.byteLength);try{let e=s.beginRenderPass({framebuffer:u,parameters:{viewport:[0,0,1,n.length]},clearColor:[-k,-k,0,0],clearDepth:!1,clearStencil:!1});s.statsManager.getStats(E).get(D).incrementCount(),d.draw(e),e.end();let t=s.createCommandEncoder();return t.copyTextureToBuffer({sourceTexture:l,width:1,height:n.length,destinationBuffer:f,byteOffset:0,bytesPerRow:8}),s.submit(t.finish()),T({device:s,inputs:{expression:{kind:`call`,op:`multiply`,args:[{kind:`input`,name:`x`},{kind:`literal`,value:[-1,1]}]},namedInputs:{x:new r({buffer:f,size:2,type:`float32`,length:n.length})}},output:n,target:i})}finally{d.destroy(),t.recycle(f),u.destroy(),l.destroy()}},k=3e38,A=({inputs:e,output:t,target:n})=>{let r=e.map((e,t)=>[`x${t}`,e]);j(n.device.limits.maxVertexAttributes,r),M(n.device.limits.maxInterStageShaderVariables,t);let i=r.map(([e,t])=>`in TYPE ${e}[${t.size}]`).join(`, `),a=0;return y({module:{name:`interleave`,vs:`\
63
+ void interleave(${i}, out TYPE result[RESULT_LEN]) {
64
+ ${r.map(([e,t])=>{let n=Array.from({length:t.size},(t,n)=>` result[${a+n}] = ${e}[${n}];`).join(`
65
+ `);return a+=t.size,n}).join(`
66
+ `)}
67
+ }
68
+ `},inputs:e,output:t,outputBuffer:n}),{success:!0}};function j(e,t){let n=t.reduce((e,[,t])=>e+Math.ceil(t.size/4),0);if(n>e)throw Error(`interleave() requires ${n} vertex attributes, exceeding device limit ${e}`)}function M(e,t){if(t.size>e)throw Error(`interleave() output size ${t.size} exceeds device inter-stage component limit ${e}`)}function N(){let e=new Uint16Array([255]);return new Uint8Array(e.buffer)[0]>0}var P=`\
69
+ #define LE ${+!!N()}
70
+ const uint F32_NAN = 0xffffffffu;
71
+ const uint F32_INF = 0x7f800000u;
72
+
73
+ // Find first set bit using binary search
74
+ // https://en.wikipedia.org/wiki/Find_first_set#CLZ
75
+ int countLeadingZeros(uint a) {
76
+ if (a == 0u) return 32;
77
+ int n = 0;
78
+ if ((a & 0xffff0000u) == 0u) { n += 16; a = a << 16; }
79
+ if ((a & 0xff000000u) == 0u) { n += 8; a = a << 8; }
80
+ if ((a & 0xf0000000u) == 0u) { n += 4; a = a << 4; }
81
+ if ((a & 0xc0000000u) == 0u) { n += 2; a = a << 2; }
82
+ if ((a & 0x80000000u) == 0u) return n + 1;
83
+ return n;
84
+ }
85
+
86
+ uint roundShiftRight(uint value, int shift) {
87
+ if (shift <= 0) {
88
+ return value << (-shift);
89
+ }
90
+
91
+ if (shift >= 32) {
92
+ if (shift == 32 && value > 0x80000000u) {
93
+ return 1u;
94
+ }
95
+ return 0u;
96
+ }
97
+
98
+ uint truncated = value >> shift;
99
+ uint halfShift = 1u << (shift - 1);
100
+ uint remainder = value & ((1u << shift) - 1u);
101
+ if (remainder > halfShift || (remainder == halfShift && (truncated & 1u) == 1u)) {
102
+ return truncated + 1u;
103
+ }
104
+ return truncated;
105
+ }
106
+
107
+ uint makeFloat_(uint sign, int exponent, uint mantissa) {
108
+ return (sign << 31) | (uint(exponent + 127) << 23) | (mantissa & 0x7fffffu);
109
+ }
110
+
111
+ /**
112
+ * Assemble a float32 in bit representation according to IEEE 754
113
+ * https://en.wikipedia.org/wiki/Single-precision_floating-point_format
114
+ */
115
+ uint makeFloat(uint sign, int exponent, uint significand) {
116
+ if (significand == 0u) {
117
+ return sign << 31;
118
+ }
119
+
120
+ // Remove any extra leading zeros for better precision
121
+ int lead_zeros = countLeadingZeros(significand);
122
+ // Significand is encoded as 1.fraction
123
+ int normalizedExponent = exponent + 31 - lead_zeros;
124
+
125
+ if (normalizedExponent > 127) {
126
+ return (sign << 31) | F32_INF;
127
+ }
128
+
129
+ uint mantissa;
130
+ if (normalizedExponent >= -126) {
131
+ mantissa = roundShiftRight(significand, 8 - lead_zeros);
132
+ if (mantissa >= 0x1000000u) {
133
+ mantissa >>= 1;
134
+ normalizedExponent++;
135
+ if (normalizedExponent > 127) {
136
+ return (sign << 31) | F32_INF;
137
+ }
138
+ }
139
+ return makeFloat_(sign, normalizedExponent, mantissa);
140
+ }
141
+
142
+ int subnormalShift = -149 - exponent;
143
+ mantissa = roundShiftRight(significand, subnormalShift);
144
+ if (mantissa >= 0x800000u) {
145
+ return (sign << 31) | (1u << 23);
146
+ }
147
+ return (sign << 31) | mantissa;
148
+ }
149
+
150
+ /**
151
+ * Parse 8-byte memory as a float64 number according to IEEE 754
152
+ * https://en.wikipedia.org/wiki/Double-precision_floating-point_format
153
+ * Returns 8-byte memory as 2 float32 numbers, consisting of
154
+ * high part: fround(d)
155
+ * low part: d - fround(d)
156
+ */
157
+ uvec2 parseAsDouble(uvec2 d) {
158
+ #if LE
159
+ d = d.yx; // to big endian
160
+ #endif
161
+
162
+ uint sign = (d[0] >> 31) & 1u; // first bit
163
+ uint exponentBits = (d[0] >> 20) & 0x7ffu;
164
+ int exponent = int(exponentBits) - 1023; // next 11 bits
165
+ uint fractionHigh = d[0] & 0xfffffu;
166
+ uint fractionLow = d[1];
167
+
168
+ if (exponentBits == 0x7ffu) {
169
+ if (fractionHigh == 0u && fractionLow == 0u) {
170
+ return uvec2((sign << 31) | F32_INF, F32_NAN);
171
+ }
172
+ return uvec2(F32_NAN);
173
+ }
174
+
175
+ if (exponentBits == 0u) {
176
+ // All float64 subnormals are too small to survive a float32 split.
177
+ return uvec2(sign << 31);
178
+ }
179
+
180
+ if (exponent > 127) {
181
+ return uvec2((sign << 31) | F32_INF, ((1u - sign) << 31) | F32_INF);
182
+ }
183
+
184
+ uint hi_part;
185
+ uint low_part;
186
+
187
+ // float64 significand has 52 bits
188
+ // float32 significand has 23 bits
189
+ // The significand of the high part is the significand of the double, trimmed
190
+ uint f_hi = 0x800000u | (fractionHigh << 3) | (fractionLow >> 29);
191
+ uint f_low = fractionLow & 0x1fffffffu;
192
+
193
+ if (exponent < -126) {
194
+ // For tiny normals, the top 24 significand bits still contribute to the float32
195
+ // high part, but they land in the float32 subnormal range.
196
+ hi_part = makeFloat(sign, exponent - 23, f_hi);
197
+
198
+ // The residual keeps the remaining 29 significand bits at the original double scale.
199
+ low_part = makeFloat(sign, exponent - 52, f_low);
200
+ return uvec2(hi_part, low_part);
201
+ }
202
+
203
+ bool roundUp = f_low > 0x10000000u || (f_low == 0x10000000u && (f_hi & 1u) == 1u);
204
+
205
+ uint f_rounded = f_hi + (roundUp ? 1u : 0u);
206
+ int exponent_hi = exponent;
207
+ if (f_rounded == 0x1000000u) {
208
+ f_rounded = 0x800000u;
209
+ exponent_hi++;
210
+ }
211
+
212
+ if (exponent_hi > 127) {
213
+ // Overflows float32 limit
214
+ hi_part = (sign << 31) | F32_INF;
215
+ low_part = ((1u - sign) << 31) | F32_INF;
216
+ return uvec2(hi_part, low_part);
217
+ }
218
+
219
+ hi_part = makeFloat_(sign, exponent_hi, f_rounded);
220
+
221
+ int remainder = int(f_low);
222
+ uint sign_low = sign;
223
+ if (roundUp) {
224
+ remainder -= 0x20000000;
225
+ }
226
+ if (remainder < 0) {
227
+ sign_low = 1u - sign;
228
+ remainder = -remainder;
229
+ }
230
+ low_part = makeFloat(sign_low, exponent - 52, uint(remainder));
231
+
232
+ return uvec2(hi_part, low_part);
233
+ }
234
+
235
+ void fround(in uint x[X_LEN], out float result[X_LEN]) {
236
+ int n = X_LEN / 2;
237
+ for (int i = 0; i < n; i++) {
238
+ uvec2 f = parseAsDouble(uvec2(x[i * 2], x[i * 2 + 1]));
239
+ result[i] = uintBitsToFloat(f.x);
240
+ result[i + n] = uintBitsToFloat(f.y);
241
+ }
242
+ }
243
+ `,F=({inputs:e,output:t,target:n})=>(y({module:{name:`fround`,vs:P},inputs:e,output:t,operationType:`uint32`,outputBuffer:n}),{success:!0});function I(e,t,n){let r=h(n),i=l(t,1),a=Array.from({length:e.size},(e,t)=>` v[${t}] = ${i}(texelFetch(source_values_texture, ivec2(${t}, rowIndex), 0).r);`).join(`
244
+ `);return{name:`source_values_texture`,vs:`
245
+ uniform highp ${r} source_values_texture;
246
+ void read_source_values(int rowIndex, out TYPE v[${e.size}]) {
247
+ ${a}
248
+ }
249
+ `}}function L(e,t,n){let r=n.createTexture({width:Math.max(e.size,1),height:e.length,format:p(t),usage:o.SAMPLE|o.COPY_DST});if(e.length===0)return r;let i=n.createCommandEncoder();return i.copyBufferToTexture({sourceBuffer:e.buffer,destinationTexture:r,byteOffset:e.offset,bytesPerRow:e.stride,rowsPerImage:e.length,size:[e.size,e.length,1]}),n.submit(i.finish()),r}var R=async({inputs:e,output:t,target:n})=>{let{ids:r,sourceValues:i}=e,a=n.device,o=C(`result`,t.type,t.size),c=l(r.type,1),u=l(t.type,1),d=m(t.type),f=L(i,d,a),p=`\
250
+ #version 300 es
251
+
252
+ void main() {
253
+ INDEX_TYPE ids[1];
254
+ get_ids(ids);
255
+ TYPE result[${t.size}];
256
+ gather(ids, result);
257
+ set_result(result);
258
+ }
259
+ `,h=new s(a,{vs:p,defines:{INDEX_TYPE:c,TYPE:u,RESULT_LEN:t.size.toString(),SOURCE_VALUES_ROWS:i.length.toString()},modules:[z(r,c),I(i,t.type,d),V(t.type),o],bindings:{source_values_texture:f},bufferLayout:[B(r)],vertexCount:1,instanceCount:t.length,feedbackBufferMode:`interleaved`,outputs:o.varyings});try{return h.run({inputBuffers:{ids:r.buffer},outputBuffers:{[o.varyings[0]]:n}}),{success:!0}}finally{h.destroy(),f.destroy()}};function z(e,t){let n=l(e.type,1),r=`aids_0`;return e.type!==H(t)&&(r=`${t}(${r})`),{name:`ids`,vs:`
260
+ in ${n} aids_0;
261
+ void get_ids(out INDEX_TYPE v[1]) {
262
+ v[0] = ${r};
263
+ }
264
+ `}}function B(e){return{name:`ids`,stepMode:e.isConstant?`vertex`:`instance`,byteStride:e.stride,attributes:[{attribute:`aids_0`,format:u(e.type,1,e.normalized),byteOffset:e.offset}]}}function V(e){return{name:`gather`,vs:`
265
+ void zero_result(out TYPE result[RESULT_LEN]) {
266
+ for (int i = 0; i < RESULT_LEN; i++) {
267
+ result[i] = ${d(e)};
268
+ }
269
+ }
270
+
271
+ void gather(in INDEX_TYPE ids[1], out TYPE result[RESULT_LEN]) {
272
+ int sourceIndex = int(ids[0]);
273
+ if (sourceIndex < 0 || sourceIndex >= SOURCE_VALUES_ROWS) {
274
+ zero_result(result);
275
+ return;
276
+ }
277
+ read_source_values(sourceIndex, result);
278
+ }
279
+ `}}function H(e){switch(e){case`uint`:return`uint32`;case`int`:return`sint32`;default:return`float32`}}var U=`void row_dot(in TYPE x[X_LEN], in TYPE y[Y_LEN], out float result[1]) {
280
+ float sum = 0.0;
281
+ for (int i = 0; i < X_LEN; i++) {
282
+ sum += float(x[i]) * float(y[i]);
283
+ }
284
+ result[0] = sum;
285
+ }
286
+ `,W=({inputs:e,output:t,target:n})=>(y({module:{name:`row_dot`,vs:U},inputs:e,output:t,operationType:`float32`,outputBuffer:n}),{success:!0}),G=`void equalAll(in TYPE x[X_LEN], in TYPE y[Y_LEN], out uint result[1]) {
287
+ uint allEqual = uint(1);
288
+ for (int i = 0; i < X_LEN; i++) {
289
+ if (x[i] != y[i]) {
290
+ allEqual = uint(0);
291
+ break;
292
+ }
293
+ }
294
+ result[0] = allEqual;
295
+ }
296
+ `,K=({inputs:e,output:t,target:n})=>(y({module:{name:`equalAll`,vs:G},inputs:e,output:t,operationType:t.type===`uint32`?e.x.type:t.type,outputBuffer:n}),{success:!0}),q=`void row_length(in TYPE x[X_LEN], out float result[1]) {
297
+ float sum = 0.0;
298
+ for (int i = 0; i < X_LEN; i++) {
299
+ sum += float(x[i]) * float(x[i]);
300
+ }
301
+ result[0] = sqrt(sum);
302
+ }
303
+ `,J=({inputs:e,output:t,target:n})=>(y({module:{name:`row_length`,vs:q},inputs:e,output:t,operationType:`float32`,outputBuffer:n}),{success:!0}),Y=async({inputs:e,output:t,target:n})=>{let{segments:r}=e,i=n.device,a=C(`result`,t.type,t.size),o=m(r.type),c=L(r,o,i),l=new s(i,{vs:`#version 300 es
304
+
305
+ void main() {
306
+ TYPE result[RESULT_LEN];
307
+ segmentedMap(result);
308
+ set_result(result);
309
+ }
310
+ `,defines:{TYPE:`uint`,RESULT_LEN:t.size.toString(),SEGMENTS_LENGTH:r.length.toString()},modules:[I(r,t.type,o),X(),a],bindings:{source_values_texture:c},vertexCount:1,instanceCount:t.length,feedbackBufferMode:`interleaved`,outputs:a.varyings});try{return l.run({outputBuffers:{[a.varyings[0]]:n}}),{success:!0}}finally{l.destroy(),c.destroy()}};function X(){return{name:`segmentedMap`,vs:`
311
+ uint read_segment_start(int segmentIndex) {
312
+ TYPE value[1];
313
+ read_source_values(segmentIndex, value);
314
+ return uint(value[0]);
315
+ }
316
+
317
+ void segmentedMap(out TYPE result[RESULT_LEN]) {
318
+ uint vertexIndex = uint(gl_InstanceID);
319
+ int low = 0;
320
+ int high = SEGMENTS_LENGTH;
321
+
322
+ while (low < high) {
323
+ int mid = low + (high - low) / 2;
324
+ uint midStart = read_segment_start(mid);
325
+ if (midStart <= vertexIndex) {
326
+ low = mid + 1;
327
+ } else {
328
+ high = mid;
329
+ }
330
+ }
331
+
332
+ uint segmentIndex = uint(max(low - 1, 0));
333
+ uint segmentStart = read_segment_start(int(segmentIndex));
334
+ result[0] = segmentIndex;
335
+ result[1] = vertexIndex - segmentStart;
336
+ }
337
+ `}}var Z=async({inputs:e,output:t,target:n})=>{let r=d(l(t.type,1,t.normalized));return y({module:{name:`select`,vs:``},inputs:e,output:t,operationType:t.type,outputBuffer:n,expression:t=>{let n=Q(`condition`,e.condition,t,r),i=Q(`whenTrue`,e.whenTrue,t,r),a=Q(`whenFalse`,e.whenFalse,t,r);return`(${n} != ${r} ? ${i} : ${a})`}}),{success:!0}};function Q(e,t,n,r){return n<t.size?`${e}[${n}]`:t.size===1?`${e}[0]`:r}var $=({inputs:e,output:t,target:n})=>{let r=C(`result`,t.type,t.size),i=new s(n.device,{vs:`#version 300 es
338
+
339
+ void main() {
340
+ int result[1];
341
+ result[0] = START + gl_InstanceID * STEP;
342
+ set_result(result);
343
+ }
344
+ `,defines:{START:e.start.toString(),STEP:e.step.toString()},modules:[r],vertexCount:1,instanceCount:t.length,feedbackBufferMode:`interleaved`,outputs:r.varyings});try{return i.run({outputBuffers:{[r.varyings[0]]:n}}),{success:!0}}finally{i.destroy()}},ee=({inputs:e,output:t,target:n})=>{let{columns:r}=e;return y({module:{name:`swizzle`,vs:`// swizzle expression handled inline`},expression:e=>`x[${r[e]}]`,inputs:{x:e.x},output:t,outputBuffer:n}),{success:!0}};export{T as arithmetic,W as dot,K as equalAll,O as extent,F as fround,R as gather,A as interleave,J as length,Y as segmentedMap,Z as select,$ as sequence,ee as swizzle};
345
+ //# sourceMappingURL=webgl-D2Fkccwd.js.map
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./index-Gxpj1e1n.js";var t=class extends e{constructor(){if(super(),typeof createImageBitmap>`u`)throw Error("Cannot decode WebImage as `createImageBitmap` is not available");if(typeof document>`u`&&typeof OffscreenCanvas>`u`)throw Error("Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available")}async decode(e,t){let n=new Blob([t]),r=await createImageBitmap(n),i;typeof document<`u`?(i=document.createElement(`canvas`),i.width=r.width,i.height=r.height):i=new OffscreenCanvas(r.width,r.height);let a=i.getContext(`2d`);return a.drawImage(r,0,0),a.getImageData(0,0,r.width,r.height).data.buffer}};export{t as default};
2
+ //# sourceMappingURL=webimage-DDU0IC05.js.map