watr 4.7.2 → 5.0.0

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.
package/dist/watr.min.js CHANGED
@@ -1,6 +1,6 @@
1
- var $r=Object.defineProperty;var vr=(t,e)=>{for(var r in e)$r(t,r,{get:e[r],enumerable:!0})};var qt={};vr(qt,{f32:()=>dt,f64:()=>mt,i16:()=>Br,i32:()=>X,i64:()=>xt,i8:()=>Mr,uleb:()=>S,uleb5:()=>Sr,v128:()=>ee});var E=(t,e=E.loc)=>{if(e!=null&&E.src){let r=1,i=1;for(let s=0;s<e&&s<E.src.length;s++)E.src[s]===`
2
- `?(r++,i=1):i++;t+=` at ${r}:${i}`}throw Error(t)},Be=/^_|_$|[^\da-f]_|_[^\da-f]/i,ze=/^[+-]?(?:0x[\da-f]+|\d+)$/i,Ir=new TextEncoder,kr=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),Me={n:10,r:13,t:9,'"':34,"'":39,"\\":92},Et=t=>{let e=[],r=1,i,s,n="",l=()=>(n&&e.push(...Ir.encode(n)),n="");for(;r<t.length-1;)s=t[r++],i=null,s==="\\"&&(t[r]==="u"?(r++,r++,s=String.fromCodePoint(parseInt(t.slice(r,r=t.indexOf("}",r)),16)),r++):Me[t[r]]?i=Me[t[r++]]:isNaN(i=parseInt(t[r]+t[r+1],16))?s+=t[r]:(r++,r++)),i!=null?(l(),e.push(i)):n+=s;return l(),e.valueOf=()=>t,e},Ne=t=>kr.decode(new Uint8Array(Et(t))),Jt=t=>Array.isArray(t)?t.map(Jt):t,V=(t,e,r,i)=>{if(e(t,r,i),Array.isArray(t))for(let s=0;s<t.length;s++)V(t[s],e,t,s)},J=(t,e,r,i)=>{if(Array.isArray(t))for(let n=0;n<t.length;n++)J(t[n],e,t,n);let s=e(t,r,i);return s!==void 0&&r&&(r[i]=s),s!==void 0?s:t};var S=(t,e=[])=>{if(t==null)return e;if(typeof t=="string"&&(t=/[_x]/i.test(t)?BigInt(t.replaceAll("_","")):X.parse(t)),typeof t=="bigint"){for(;;){let i=Number(t&0x7Fn);if(t>>=7n,t===0n){e.push(i);break}e.push(i|128)}return e}let r=t&127;return t>>>=7,t===0?(e.push(r),e):(e.push(r|128),S(t,e))};function Sr(t){let e=[];for(let r=0;r<5;r++){let i=t&127;t>>>=7,r<4&&(i|=128),e.push(i)}return e}function X(t,e=[]){for(typeof t=="string"&&(t=X.parse(t));;){let r=Number(t&127);if(t>>=7,t===0&&!(r&64)||t===-1&&r&64){e.push(r);break}e.push(r|128)}return e}var qe=t=>!Be.test(t)&&ze.test(t=t.replaceAll("_",""))?t:E(`Bad int ${t}`),Mr=X,Br=X;X.parse=t=>(t=parseInt(qe(t)),(t<-2147483648||t>4294967295)&&E("i32 constant out of range"),t);function xt(t,e=[]){for(typeof t=="string"?t=xt.parse(t):typeof t=="number"&&(t=BigInt(t)),typeof t=="bigint"&&t>0x7fffffffffffffffn&&(t=t-0x10000000000000000n);;){let r=Number(t&0x7Fn);if(t>>=7n,t===0n&&!(r&64)||t===-1n&&r&64){e.push(r);break}e.push(r|128)}return e}var Mt=new ArrayBuffer(8),tt=new Uint8Array(Mt),zr=new Int32Array(Mt),Nr=new Float32Array(Mt),Tr=new Float64Array(Mt),te=new BigInt64Array(Mt);xt.parse=t=>{t=qe(t);let e=t[0]==="-",r=e||t[0]==="+"?t.slice(1):t,i;if(r[0]==="0"&&(r[1]==="x"||r[1]==="X")){let n=r.slice(2).replace(/^0+/,"")||"0";i=e?"8000000000000000":"ffffffffffffffff",(n.length>16||n.length===16&&n.toLowerCase()>i)&&E("i64 constant out of range")}else{let n=r.replace(/^0+/,"")||"0";i=e?"9223372036854775808":"18446744073709551615",(n.length>i.length||n.length===i.length&&n>i)&&E("i64 constant out of range")}let s=BigInt(r);return e&&(s=0n-s),te[0]=s,te[0]};var Er=2147483648,qr=2139095040,Te=4194304;function dt(t,e,r){if(typeof t=="string"&&(r=t.indexOf("nan"))>=0){if(t[r+3]===":"){let i=t.slice(r+4);e=i==="canonical"||i==="arithmetic"?Te:X.parse(i)}else e=Te;e=(e|qr)>>>0,t[0]==="-"&&(e=(e|Er)>>>0),zr[0]=e|0}else e=typeof t=="string"?dt.parse(t):t,Nr[0]=e;return[tt[0],tt[1],tt[2],tt[3]]}var Or=0x8000000000000000n,Fr=0x7ff0000000000000n,Ee=0x8000000000000n;function mt(t,e,r){if(typeof t=="string"&&(r=t.indexOf("nan"))>=0){if(t[r+3]===":"){let i=t.slice(r+4);e=i==="canonical"||i==="arithmetic"?Ee:xt.parse(i)}else e=Ee;e|=Fr,t[0]==="-"&&(e|=Or),te[0]=e}else e=typeof t=="string"?mt.parse(t):t,Tr[0]=e;return[tt[0],tt[1],tt[2],tt[3],tt[4],tt[5],tt[6],tt[7]]}mt.parse=(t,e=Number.MAX_VALUE)=>{t=t.replaceAll("_","");let r=1;if(t[0]==="-"?(r=-1,t=t.slice(1)):t[0]==="+"&&(t=t.slice(1)),t[1]==="x"){let[i,s="0"]=t.split(/p/i),[n,l=""]=i.split("."),f=l.length??0,c=0;for(let g=n.length-1;g>=2;g--){let h=parseInt(n[g],16);c+=h*16**(n.length-1-g)}let a=l?parseInt("0x"+l)/16**f:0;s=parseInt(s,10);let u=r*(c+a)*2**s;return u=Math.max(-e,Math.min(e,u)),u}return t.includes("nan")?r<0?NaN:NaN:t.includes("inf")?r*(1/0):r*parseFloat(t)};dt.parse=t=>mt.parse(t,34028234663852886e22);var ee=t=>{let e=BigInt(typeof t=="string"?t.replaceAll("_",""):t),r=new Uint8Array(16);for(let i=0;i<16;i++)r[i]=Number(e&0xffn),e>>=8n;return[...r]};var At=["unreachable","nop","block block","loop block","if block","else null","then null",,"throw tagidx",,"throw_ref","end end","br labelidx","br_if labelidx","br_table br_table","return","call funcidx","call_indirect call_indirect","return_call funcidx","return_call_indirect call_indirect","call_ref typeidx","return_call_ref typeidx",,,,,"drop","select select","",,,"try_table try_table","local.get localidx","local.set localidx","local.tee localidx","global.get globalidx","global.set globalidx","table.get tableidx","table.set tableidx",,"i32.load memarg","i64.load memarg","f32.load memarg","f64.load memarg","i32.load8_s memarg","i32.load8_u memarg","i32.load16_s memarg","i32.load16_u memarg","i64.load8_s memarg","i64.load8_u memarg","i64.load16_s memarg","i64.load16_u memarg","i64.load32_s memarg","i64.load32_u memarg","i32.store memarg","i64.store memarg","f32.store memarg","f64.store memarg","i32.store8 memarg","i32.store16 memarg","i64.store8 memarg","i64.store16 memarg","i64.store32 memarg","memory.size opt_memory","memory.grow opt_memory","i32.const i32","i64.const i64","f32.const f32","f64.const f64","i32.eqz","i32.eq","i32.ne","i32.lt_s","i32.lt_u","i32.gt_s","i32.gt_u","i32.le_s","i32.le_u","i32.ge_s","i32.ge_u","i64.eqz","i64.eq","i64.ne","i64.lt_s","i64.lt_u","i64.gt_s","i64.gt_u","i64.le_s","i64.le_u","i64.ge_s","i64.ge_u","f32.eq","f32.ne","f32.lt","f32.gt","f32.le","f32.ge","f64.eq","f64.ne","f64.lt","f64.gt","f64.le","f64.ge","i32.clz","i32.ctz","i32.popcnt","i32.add","i32.sub","i32.mul","i32.div_s","i32.div_u","i32.rem_s","i32.rem_u","i32.and","i32.or","i32.xor","i32.shl","i32.shr_s","i32.shr_u","i32.rotl","i32.rotr","i64.clz","i64.ctz","i64.popcnt","i64.add","i64.sub","i64.mul","i64.div_s","i64.div_u","i64.rem_s","i64.rem_u","i64.and","i64.or","i64.xor","i64.shl","i64.shr_s","i64.shr_u","i64.rotl","i64.rotr","f32.abs","f32.neg","f32.ceil","f32.floor","f32.trunc","f32.nearest","f32.sqrt","f32.add","f32.sub","f32.mul","f32.div","f32.min","f32.max","f32.copysign","f64.abs","f64.neg","f64.ceil","f64.floor","f64.trunc","f64.nearest","f64.sqrt","f64.add","f64.sub","f64.mul","f64.div","f64.min","f64.max","f64.copysign","i32.wrap_i64","i32.trunc_f32_s","i32.trunc_f32_u","i32.trunc_f64_s","i32.trunc_f64_u","i64.extend_i32_s","i64.extend_i32_u","i64.trunc_f32_s","i64.trunc_f32_u","i64.trunc_f64_s","i64.trunc_f64_u","f32.convert_i32_s","f32.convert_i32_u","f32.convert_i64_s","f32.convert_i64_u","f32.demote_f64","f64.convert_i32_s","f64.convert_i32_u","f64.convert_i64_s","f64.convert_i64_u","f64.promote_f32","i32.reinterpret_f32","i64.reinterpret_f64","f32.reinterpret_i32","f64.reinterpret_i64","i32.extend8_s","i32.extend16_s","i64.extend8_s","i64.extend16_s","i64.extend32_s",,,,,,,,,,,,"ref.null ref_null","ref.is_null","ref.func funcidx","ref.eq","ref.as_non_null","br_on_null labelidx","br_on_non_null labelidx",,,,,,,,,,"cont.new typeidx","cont.bind cont_bind","suspend tagidx","resume resume","resume_throw resume_throw","resume_throw_ref resume_throw_ref","switch switch_cont",,,,,,,,,,,,,,,,,,,,,["struct.new typeidx","struct.new_default typeidx","struct.get typeidx_field","struct.get_s typeidx_field","struct.get_u typeidx_field","struct.set typeidx_field","array.new typeidx","array.new_default typeidx","array.new_fixed typeidx_multi","array.new_data typeidx_dataidx","array.new_elem typeidx_elemidx","array.get typeidx","array.get_s typeidx","array.get_u typeidx","array.set typeidx","array.len","array.fill typeidx","array.copy typeidx_typeidx","array.init_data typeidx_dataidx","array.init_elem typeidx_elemidx","ref.test reftype","ref.test_null reftype","ref.cast reftype","ref.cast_null reftype","br_on_cast reftype2","br_on_cast_fail reftype2","any.convert_extern","extern.convert_any","ref.i31","i31.get_s","i31.get_u",,"struct.new_desc typeidx","struct.new_default_desc typeidx","ref.get_desc typeidx","ref.cast_desc_eq reftype",,"br_on_cast_desc_eq reftype2","br_on_cast_desc_eq_fail reftype2",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"string.new_utf8 memoryidx?","string.new_wtf16 memoryidx?","string.const stringidx","string.measure_utf8","string.measure_wtf8","string.measure_wtf16","string.encode_utf8 memoryidx?","string.encode_wtf16 memoryidx?","string.concat","string.eq","string.is_usv_sequence","string.new_lossy_utf8 memoryidx?","string.new_wtf8 memoryidx?","string.encode_lossy_utf8 memoryidx?","string.encode_wtf8 memoryidx?",,"string.as_wtf8","stringview_wtf8.advance","stringview_wtf8.encode_utf8 memoryidx?","stringview_wtf8.slice","stringview_wtf8.encode_lossy_utf8 memoryidx?","stringview_wtf8.encode_wtf8 memoryidx?",,,"string.as_wtf16","stringview_wtf16.length","stringview_wtf16.get_codeunit","stringview_wtf16.encode memoryidx?","stringview_wtf16.slice",,,,"string.as_iter","stringview_iter.next","stringview_iter.advance","stringview_iter.rewind","stringview_iter.slice",,,,,,,,,,,,"string.new_utf8_array","string.new_wtf16_array","string.encode_utf8_array","string.encode_wtf16_array","string.new_lossy_utf8_array","string.new_wtf8_array","string.encode_lossy_utf8_array","string.encode_wtf8_array"],["i32.trunc_sat_f32_s","i32.trunc_sat_f32_u","i32.trunc_sat_f64_s","i32.trunc_sat_f64_u","i64.trunc_sat_f32_s","i64.trunc_sat_f32_u","i64.trunc_sat_f64_s","i64.trunc_sat_f64_u","memory.init dataidx_memoryidx","data.drop dataidx","memory.copy memoryidx_memoryidx","memory.fill memoryidx?","table.init reversed","elem.drop elemidx","table.copy tableidx_tableidx","table.grow tableidx","table.size tableidx","table.fill tableidx",,"i64.add128","i64.sub128","i64.mul_wide_s","i64.mul_wide_u",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"f32.sqrt_ceil","f32.add_ceil","f32.sub_ceil","f32.mul_ceil","f32.div_ceil","f64.sqrt_ceil","f64.add_ceil","f64.sub_ceil","f64.mul_ceil","f64.div_ceil","f32.convert_ceil_i32_s","f32.convert_ceil_i32_u","f32.convert_ceil_i64_s","f32.convert_ceil_i64_u","f32.demote_ceil_f64","f64.convert_ceil_i32_s","f64.convert_ceil_i32_u","f64.convert_ceil_i64_s","f64.convert_ceil_i64_u","f64.promote_ceil_f32","f32.sqrt_floor","f32.add_floor","f32.sub_floor","f32.mul_floor","f32.div_floor","f64.sqrt_floor","f64.add_floor","f64.sub_floor","f64.mul_floor","f64.div_floor","f32.convert_floor_i32_s","f32.convert_floor_i32_u","f32.convert_floor_i64_s","f32.convert_floor_i64_u","f32.demote_floor_f64","f64.convert_floor_i32_s","f64.convert_floor_i32_u","f64.convert_floor_i64_s","f64.convert_floor_i64_u","f64.promote_floor_f32","f32.sqrt_trunc","f32.add_trunc","f32.sub_trunc","f32.mul_trunc","f32.div_trunc","f64.sqrt_trunc","f64.add_trunc","f64.sub_trunc","f64.mul_trunc","f64.div_trunc","f32.convert_trunc_i32_s","f32.convert_trunc_i32_u","f32.convert_trunc_i64_s","f32.convert_trunc_i64_u","f32.demote_trunc_f64","f64.convert_trunc_i32_s","f64.convert_trunc_i32_u","f64.convert_trunc_i64_s","f64.convert_trunc_i64_u","f64.promote_trunc_f32"],["v128.load memarg","v128.load8x8_s memarg","v128.load8x8_u memarg","v128.load16x4_s memarg","v128.load16x4_u memarg","v128.load32x2_s memarg","v128.load32x2_u memarg","v128.load8_splat memarg","v128.load16_splat memarg","v128.load32_splat memarg","v128.load64_splat memarg","v128.store memarg","v128.const v128const","i8x16.shuffle shuffle","i8x16.swizzle","i8x16.splat","i16x8.splat","i32x4.splat","i64x2.splat","f32x4.splat","f64x2.splat","i8x16.extract_lane_s laneidx","i8x16.extract_lane_u laneidx","i8x16.replace_lane laneidx","i16x8.extract_lane_s laneidx","i16x8.extract_lane_u laneidx","i16x8.replace_lane laneidx","i32x4.extract_lane laneidx","i32x4.replace_lane laneidx","i64x2.extract_lane laneidx","i64x2.replace_lane laneidx","f32x4.extract_lane laneidx","f32x4.replace_lane laneidx","f64x2.extract_lane laneidx","f64x2.replace_lane laneidx","i8x16.eq","i8x16.ne","i8x16.lt_s","i8x16.lt_u","i8x16.gt_s","i8x16.gt_u","i8x16.le_s","i8x16.le_u","i8x16.ge_s","i8x16.ge_u","i16x8.eq","i16x8.ne","i16x8.lt_s","i16x8.lt_u","i16x8.gt_s","i16x8.gt_u","i16x8.le_s","i16x8.le_u","i16x8.ge_s","i16x8.ge_u","i32x4.eq","i32x4.ne","i32x4.lt_s","i32x4.lt_u","i32x4.gt_s","i32x4.gt_u","i32x4.le_s","i32x4.le_u","i32x4.ge_s","i32x4.ge_u","f32x4.eq","f32x4.ne","f32x4.lt","f32x4.gt","f32x4.le","f32x4.ge","f64x2.eq","f64x2.ne","f64x2.lt","f64x2.gt","f64x2.le","f64x2.ge","v128.not","v128.and","v128.andnot","v128.or","v128.xor","v128.bitselect","v128.any_true","v128.load8_lane memlane","v128.load16_lane memlane","v128.load32_lane memlane","v128.load64_lane memlane","v128.store8_lane memlane","v128.store16_lane memlane","v128.store32_lane memlane","v128.store64_lane memlane","v128.load32_zero memarg","v128.load64_zero memarg","f32x4.demote_f64x2_zero","f64x2.promote_low_f32x4","i8x16.abs","i8x16.neg","i8x16.popcnt","i8x16.all_true","i8x16.bitmask","i8x16.narrow_i16x8_s","i8x16.narrow_i16x8_u","f32x4.ceil","f32x4.floor","f32x4.trunc","f32x4.nearest","i8x16.shl","i8x16.shr_s","i8x16.shr_u","i8x16.add","i8x16.add_sat_s","i8x16.add_sat_u","i8x16.sub","i8x16.sub_sat_s","i8x16.sub_sat_u","f64x2.ceil","f64x2.floor","i8x16.min_s","i8x16.min_u","i8x16.max_s","i8x16.max_u","f64x2.trunc","i8x16.avgr_u","i16x8.extadd_pairwise_i8x16_s","i16x8.extadd_pairwise_i8x16_u","i32x4.extadd_pairwise_i16x8_s","i32x4.extadd_pairwise_i16x8_u","i16x8.abs","i16x8.neg","i16x8.q15mulr_sat_s","i16x8.all_true","i16x8.bitmask","i16x8.narrow_i32x4_s","i16x8.narrow_i32x4_u","i16x8.extend_low_i8x16_s","i16x8.extend_high_i8x16_s","i16x8.extend_low_i8x16_u","i16x8.extend_high_i8x16_u","i16x8.shl","i16x8.shr_s","i16x8.shr_u","i16x8.add","i16x8.add_sat_s","i16x8.add_sat_u","i16x8.sub","i16x8.sub_sat_s","i16x8.sub_sat_u","f64x2.nearest","i16x8.mul","i16x8.min_s","i16x8.min_u","i16x8.max_s","i16x8.max_u",,"i16x8.avgr_u","i16x8.extmul_low_i8x16_s","i16x8.extmul_high_i8x16_s","i16x8.extmul_low_i8x16_u","i16x8.extmul_high_i8x16_u","i32x4.abs","i32x4.neg",,"i32x4.all_true","i32x4.bitmask",,,"i32x4.extend_low_i16x8_s","i32x4.extend_high_i16x8_s","i32x4.extend_low_i16x8_u","i32x4.extend_high_i16x8_u","i32x4.shl","i32x4.shr_s","i32x4.shr_u","i32x4.add",,,"i32x4.sub",,,,"i32x4.mul","i32x4.min_s","i32x4.min_u","i32x4.max_s","i32x4.max_u","i32x4.dot_i16x8_s",,"i32x4.extmul_low_i16x8_s","i32x4.extmul_high_i16x8_s","i32x4.extmul_low_i16x8_u","i32x4.extmul_high_i16x8_u","i64x2.abs","i64x2.neg",,"i64x2.all_true","i64x2.bitmask",,,"i64x2.extend_low_i32x4_s","i64x2.extend_high_i32x4_s","i64x2.extend_low_i32x4_u","i64x2.extend_high_i32x4_u","i64x2.shl","i64x2.shr_s","i64x2.shr_u","i64x2.add",,,"i64x2.sub",,,,"i64x2.mul","i64x2.eq","i64x2.ne","i64x2.lt_s","i64x2.gt_s","i64x2.le_s","i64x2.ge_s","i64x2.extmul_low_i32x4_s","i64x2.extmul_high_i32x4_s","i64x2.extmul_low_i32x4_u","i64x2.extmul_high_i32x4_u","f32x4.abs","f32x4.neg",,"f32x4.sqrt","f32x4.add","f32x4.sub","f32x4.mul","f32x4.div","f32x4.min","f32x4.max","f32x4.pmin","f32x4.pmax","f64x2.abs","f64x2.neg",,"f64x2.sqrt","f64x2.add","f64x2.sub","f64x2.mul","f64x2.div","f64x2.min","f64x2.max","f64x2.pmin","f64x2.pmax","i32x4.trunc_sat_f32x4_s","i32x4.trunc_sat_f32x4_u","f32x4.convert_i32x4_s","f32x4.convert_i32x4_u","i32x4.trunc_sat_f64x2_s_zero","i32x4.trunc_sat_f64x2_u_zero","f64x2.convert_low_i32x4_s","f64x2.convert_low_i32x4_u","i8x16.relaxed_swizzle","i32x4.relaxed_trunc_f32x4_s","i32x4.relaxed_trunc_f32x4_u","i32x4.relaxed_trunc_f64x2_s_zero","i32x4.relaxed_trunc_f64x2_u_zero","f32x4.relaxed_madd","f32x4.relaxed_nmadd","f64x2.relaxed_madd","f64x2.relaxed_nmadd","i8x16.relaxed_laneselect","i16x8.relaxed_laneselect","i32x4.relaxed_laneselect","i64x2.relaxed_laneselect","f32x4.relaxed_min","f32x4.relaxed_max","f64x2.relaxed_min","f64x2.relaxed_max","i16x8.relaxed_q15mulr_s","i16x8.relaxed_dot_i8x16_i7x16_s","i32x4.relaxed_dot_i8x16_i7x16_add_s"],["memory.atomic.notify memarg","memory.atomic.wait32 memarg","memory.atomic.wait64 memarg","atomic.fence opt_memory",,,,,,,,,,,,,"i32.atomic.load memarg","i64.atomic.load memarg","i32.atomic.load8_u memarg","i32.atomic.load16_u memarg","i64.atomic.load8_u memarg","i64.atomic.load16_u memarg","i64.atomic.load32_u memarg","i32.atomic.store memarg","i64.atomic.store memarg","i32.atomic.store8 memarg","i32.atomic.store16 memarg","i64.atomic.store8 memarg","i64.atomic.store16 memarg","i64.atomic.store32 memarg","i32.atomic.rmw.add memarg","i64.atomic.rmw.add memarg","i32.atomic.rmw8.add_u memarg","i32.atomic.rmw16.add_u memarg","i64.atomic.rmw8.add_u memarg","i64.atomic.rmw16.add_u memarg","i64.atomic.rmw32.add_u memarg","i32.atomic.rmw.sub memarg","i64.atomic.rmw.sub memarg","i32.atomic.rmw8.sub_u memarg","i32.atomic.rmw16.sub_u memarg","i64.atomic.rmw8.sub_u memarg","i64.atomic.rmw16.sub_u memarg","i64.atomic.rmw32.sub_u memarg","i32.atomic.rmw.and memarg","i64.atomic.rmw.and memarg","i32.atomic.rmw8.and_u memarg","i32.atomic.rmw16.and_u memarg","i64.atomic.rmw8.and_u memarg","i64.atomic.rmw16.and_u memarg","i64.atomic.rmw32.and_u memarg","i32.atomic.rmw.or memarg","i64.atomic.rmw.or memarg","i32.atomic.rmw8.or_u memarg","i32.atomic.rmw16.or_u memarg","i64.atomic.rmw8.or_u memarg","i64.atomic.rmw16.or_u memarg","i64.atomic.rmw32.or_u memarg","i32.atomic.rmw.xor memarg","i64.atomic.rmw.xor memarg","i32.atomic.rmw8.xor_u memarg","i32.atomic.rmw16.xor_u memarg","i64.atomic.rmw8.xor_u memarg","i64.atomic.rmw16.xor_u memarg","i64.atomic.rmw32.xor_u memarg","i32.atomic.rmw.xchg memarg","i64.atomic.rmw.xchg memarg","i32.atomic.rmw8.xchg_u memarg","i32.atomic.rmw16.xchg_u memarg","i64.atomic.rmw8.xchg_u memarg","i64.atomic.rmw16.xchg_u memarg","i64.atomic.rmw32.xchg_u memarg","i32.atomic.rmw.cmpxchg memarg","i64.atomic.rmw.cmpxchg memarg","i32.atomic.rmw8.cmpxchg_u memarg","i32.atomic.rmw16.cmpxchg_u memarg","i64.atomic.rmw8.cmpxchg_u memarg","i64.atomic.rmw16.cmpxchg_u memarg","i64.atomic.rmw32.cmpxchg_u memarg"]],Oe=t=>{if(typeof t!="string")return null;let e=t.indexOf(".");if(e<0)return null;let r=t.slice(0,e),i=r==="i32"||r==="i64"||r==="f32"||r==="f64";return i&&/^(eqz?|ne|[lg][te])(_[su])?$/.test(t.slice(e+1))?"i32":i||r==="v128"?r:t==="memory.size"||t==="memory.grow"?"i32":null},F={custom:0,type:1,import:2,func:3,table:4,memory:5,tag:13,strings:14,global:6,export:7,start:8,elem:9,datacount:12,code:10,data:11},j={i8:120,i16:119,i32:127,i64:126,f32:125,f64:124,void:64,v128:123,exn:105,noexn:116,nofunc:115,noextern:114,none:113,func:112,extern:111,any:110,eq:109,i31:108,struct:107,array:106,data:107,cont:104,nocont:117,string:103,stringview_wtf8:102,stringview_wtf16:96,stringview_iter:97,nullfuncref:115,nullexternref:114,nullexnref:116,nullref:113,funcref:112,externref:111,exnref:105,anyref:110,eqref:109,i31ref:108,structref:107,arrayref:106,contref:104,nocontref:117,stringref:103,ref:100,refnull:99,sub:80,subfinal:79,rec:78},yt={func:96,struct:95,array:94,cont:93,sub:80,subfinal:79,rec:78},re={func:0,table:1,memory:2,global:3,tag:4};var lt=t=>{let e=0,r=[],i="",s=0,n=0,l=()=>i&&(r.push(i),i=""),f=c=>{r.loc=c;for(let a,u,g;e<t.length;)if(a=t.charCodeAt(e),s===34)i+=t[e++],a===92?i+=t[e++]:a===34&&(l(),s=0);else if(s>59)a===40&&t.charCodeAt(e+1)===59?(s++,i+=t[e++]+t[e++]):a===59&&t.charCodeAt(e+1)===41?(i+=t[e++]+t[e++],--s===59&&(l(),s=0)):i+=t[e++];else if(s<0)a===10||a===13?(i+=t[e++],l(),s=0):s===-2&&a===41?(l(),s=0):i+=t[e++];else if(a===34)i!=="$"&&l(),s=34,i+=t[e++];else if(a===40&&t.charCodeAt(e+1)===59)l(),s=60,i=t[e++]+t[e++];else if(a===59&&t.charCodeAt(e+1)===59)l(),s=t.indexOf(`
3
- `,e)<0?-2:-1,i=t[e++]+t[e++];else if(a===40&&t.charCodeAt(e+1)===64)l(),g=e,e+=2,i="@",n++,(u=r).push(r=[]),f(g),r=u;else if(a===40)l(),g=e++,n++,(u=r).push(r=[]),f(g),r=u;else{if(a===41)return l(),e++,n--;a<=32?(l(),e++):i+=t[e++]}s<0&&l(),l()};return f(0),s===34&&E("Unclosed quote",e),s>59&&E("Unclosed block comment",e),n>0&&E("Unclosed parenthesis",e),e<t.length&&E("Unexpected closing parenthesis",e),r.length>1?r:r[0]||[]};var Ce=t=>typeof t=="string"&&(t[0]===";"||t[1]===";")||Array.isArray(t)&&t[0]?.[0]==="@"&&t[0]!=="@custom"&&!t[0]?.startsWith?.("@metadata.code."),Re=(t,e)=>typeof t=="string"?t[0]==="$"&&t[1]==='"'?t.includes("\\")?"$"+Ne(t.slice(1)):"$"+t.slice(2,-1):t[0]==='"'?Et(t):t:Array.isArray(t)?(e=t.filter(r=>!Ce(r)).map(Re),e.loc=t.loc,e.length===1&&e[0]?.[0]==="module"?e[0]:e):t;function fe(t,e){typeof t=="string"?(E.src=t,t=lt(t)||[]):E.src="",E.loc=0,t=Ce(t)?[]:Re(t)??[];let r=0;if(t[0]==="module"?(r++,Y(t[r])&&r++):typeof t[0]=="string"&&(t=[t]),t[r]==="binary"){let b=Uint8Array.from(t.slice(++r).flat());return e?b.length:b}if(t[r]==="quote")return fe(t.slice(++r).map(b=>b.valueOf().slice(1,-1)).flat().join(""),e);t=t.flatMap((b,o)=>{if(o<r||!Array.isArray(b)||b[0]!=="import")return[b];let[,y,...p]=b;if(!p.some(_=>Array.isArray(_)&&_[0]==="item"))return[b];if(Array.isArray(p.at(-1))&&p.at(-1)[0]!=="item"){let _=p.at(-1);return p.slice(0,-1).filter(d=>d[0]==="item").map(([,d])=>["import",y,d,_])}return p.filter(_=>_[0]==="item").map(([,_,d])=>["import",y,_,d])});let i=[];for(let b in F)(i[F[b]]=i[b]=[]).name=b;i.metadata={},t.slice(r).filter(b=>{if(!Array.isArray(b)){let p=E.loc,m=E.src,_;for(;(p=m.indexOf(b,p))>=0;){if(_=m.charCodeAt(p-1),p>0&&(_>47&&_<58||_>64&&_<91||_>96&&_<123||_===95||_===36)){p++;continue}if(_=m.charCodeAt(p+b.length),_>47&&_<58||_>64&&_<91||_>96&&_<123||_===95){p++;continue}break}p>=0&&(E.loc=p),E(`Unexpected token ${b}`)}let[o,...y]=b;if(E.loc=b.loc,o==="@custom")i.custom.push(y);else if(o==="rec")for(let p=0;p<y.length;p++){let[,...m]=y[p];ie(m,i.type);let _=[];for(;m[0]?.[0]==="descriptor"||m[0]?.[0]==="describes";)_.push(m.shift());(m=Fe(m,i)).push(p?!0:[i.type.length,y.length]),_.length&&(m.desc=m.desc?[..._,...m.desc]:_),i.type.push(m)}else if(o==="type"){ie(y,i.type);let p=[];for(;y[0]?.[0]==="descriptor"||y[0]?.[0]==="describes";)p.push(y.shift());let m=Fe(y,i);p.length&&(m.desc=m.desc?[...p,...m.desc]:p),i.type.push(m)}else if(o==="start"||o==="export")i[o].push(y);else return!0}).forEach(b=>{let[o,...y]=b;E.loc=b.loc;let p;o==="import"&&([o,...y]=(p=y).pop());let m=i[o];for(m||E(`Unknown section ${o}`),ie(y,m);y[0]?.[0]==="export";)i.export.push([y.shift()[1],[o,m?.length]]);if(y[0]?.[0]==="import"&&([,...p]=y.shift()),o==="table"){let _=y[0]==="i64",d=_?1:0;if(y[d+1]?.[0]==="elem"){let[$,[,...z]]=[y[d],y[d+1]];y=_?["i64",z.length,z.length,$]:[z.length,z.length,$],i.elem.push([["table",m.length],["offset",[_?"i64.const":"i32.const",_?0n:0]],$,...z])}}else if(o==="memory"){let _=y[0]==="i64",d=_?1:0;if(y[d]?.[0]==="data"){let $=y.find(k=>Array.isArray(k)&&k[0]==="pagesize")?.[1]??65536,[,...z]=y.splice(d,1)[0],I=""+Math.ceil(z.reduce((k,N)=>k+N.length,0)/$);i.data.push([["memory",m.length],[_?"i64.const":"i32.const",_?0n:0],...z]),y=_?["i64",I,I]:[I,I]}}else if(o==="func"){let[_,d,$]=Dt(y,i);_??=Rt(d,$,i),!p&&i.code.push([[_,d,$],...ut(y,i)]),y=[["type",_]]}else if(o==="tag"){let[_,d]=Dt(y,i);_??=Rt(d,[],i),y=[["type",_]]}p&&(i.import.push([...p,[o,...y]]),y=null),m.push(y)});let s=(b,o=!0)=>{let y=i[b].filter(Boolean).map(p=>le[b](p,i)).filter(Boolean);return b===F.custom?y.flatMap(p=>[b,...L(p)]):y.length?[b,...L(o?L(y):y.flat())]:[]},n=()=>{let b=[];for(let o in i.metadata){let y=L(Et(`"metadata.code.${o}"`)),p=L(i.metadata[o].map(([m,_])=>[...S(m),...L(_.map(([d,$])=>[...S(d),...L($)]))]));b.push(0,...L([...y,...p]))}return b},l=s(F.global),f=s(F.elem);if(e){let b=i.code.filter(Boolean).map($=>Cr($,i)),o=b.length?Pt(b.length)+b.reduce(($,z)=>$+z,0):0,y=b.length?1+Pt(o)+o:0,p=n(),m=s(F.data),_=i.strings.length?[F.strings,...L([0,...L(i.strings.map($=>L($)))])]:[],d=[s(F.custom),s(F.type),s(F.import),s(F.func),s(F.table),s(F.memory),s(F.tag),_,l,s(F.export),s(F.start,!1),f,s(F.datacount,!1),p,m];return 8+y+d.reduce(($,z)=>$+z.length,0)}let c=i.code.filter(Boolean).map(b=>le[F.code](b,i)).filter(Boolean),a=c.length?[F.code,...L(L(c))]:[],u=n(),g=s(F.data),h=i.strings.length?[F.strings,...L([0,...L(i.strings.map(b=>L(b)))])]:[],x=[s(F.custom),s(F.type),s(F.import),s(F.func),s(F.table),s(F.memory),s(F.tag),h,l,s(F.export),s(F.start,!1),f,s(F.datacount,!1),a,u,g],M=Uint8Array.from([0,97,115,109,1,0,0,0,...x.flat()]),A=w();return A&&(M.metadata=A),M;function w(){let b=!1;for(let d in i.metadata)b=!0;if(!b)return;let o={},p=8+x.slice(0,x.indexOf(a)).reduce((d,$)=>d+$.length,0)+a.length-c.reduce((d,$)=>d+$.length,0),m=[];for(let d=0,$=p;d<c.length;d++)m[d]=$+(i.codeSizePrefix?.[d]??0),$+=c[d].length;let _=i.import.filter(d=>d[2][0]==="func").length;for(let d in i.metadata){let $=[];for(let[z,I]of i.metadata[d]){let k=m[z-_];for(let[N,v]of I)$.push([k+N,v])}o[d]=$.sort((z,I)=>z[0]-I[0])}return o}}function oe(t){return fe(t)}function Ue(t){return fe(t,!0)}var et=t=>t?.[0]==="$"||!isNaN(t),Y=t=>t?.[0]==="$",se=t=>t?.[0]==="a"||t?.[0]==="o";function ut(t,e){let r=[];for(t=[...t];t.length;){let i=t.shift();if(typeof i=="string")if(r.push(i),i==="block"||i==="if"||i==="loop")Y(t[0])&&r.push(t.shift()),r.push(Ot(t,e));else if(i==="else"||i==="end")Y(t[0])&&t.shift();else if(i==="select")r.push(Ut(t)[1]);else if(i.endsWith("call_indirect")){let s=et(t[0])?t.shift():0,[n,l,f]=Dt(t,e);r.push(s,["type",n??Rt(l,f,e)])}else i==="table.init"?r.push(et(t[1])?t.shift():0,t.shift()):i==="table.copy"||i==="memory.copy"?r.push(et(t[0])?t.shift():0,et(t[0])?t.shift():0):i.startsWith("table.")?r.push(et(t[0])?t.shift():0):i==="memory.init"?(r.push(...et(t[1])?[t.shift(),t.shift()].reverse():[t.shift(),0]),e.datacount&&(e.datacount[0]=!0)):i==="data.drop"||i==="array.new_data"||i==="array.init_data"?(i==="data.drop"&&r.push(t.shift()),e.datacount&&(e.datacount[0]=!0)):(i.startsWith("memory.")||i.endsWith("load")||i.endsWith("store"))&&et(t[0])&&r.push(t.shift());else if(Array.isArray(i)){let s=i[0];if(i.loc!=null&&(E.loc=i.loc),s?.startsWith?.("@metadata.code.")){let l=s.slice(15);r.push(["@metadata",l,i[1]]);continue}if(typeof s!="string"||!Array.isArray(At[s])){r.push(i);continue}let n=i.slice(1);if(s==="block"||s==="loop")r.push(s),Y(n[0])&&r.push(n.shift()),r.push(Ot(n,e),...ut(n,e),"end");else if(s==="if"){let l=[],f=[];n.at(-1)?.[0]==="else"&&(f=ut(n.pop().slice(1),e)),n.at(-1)?.[0]==="then"&&(l=ut(n.pop().slice(1),e));let c=[s];Y(n[0])&&c.push(n.shift()),c.push(Ot(n,e)),r.push(...ut(n,e),...c,...l),f.length&&r.push("else",...f),r.push("end")}else if(s==="try_table"){for(r.push(s),Y(n[0])&&r.push(n.shift()),r.push(Ot(n,e));n[0]?.[0]==="catch"||n[0]?.[0]==="catch_ref"||n[0]?.[0]==="catch_all"||n[0]?.[0]==="catch_all_ref";)r.push(n.shift());r.push(...ut(n,e),"end")}else if(s==="ref.test"||s==="ref.cast"){let l=n[0];(!Array.isArray(l)||l[1]==="null"||l[0]!=="ref")&&(s+="_null"),r.push(...ut(n.slice(1),e),s,l),t.unshift(...r.splice(r.length-2))}else{let l=[];for(;n.length&&(!Array.isArray(n[0])||n[0].valueOf!==Array.prototype.valueOf||"type,param,result,ref,exact,on".includes(n[0][0]));)l.push(n.shift());r.push(...ut(n,e),s,...l),t.unshift(...r.splice(r.length-1-l.length))}}else r.push(i)}return r}var Rt=(t,e,r,i="$"+t+">"+e)=>(r.type[i]??=r.type.push(["func",[t,e]])-1,i),ne=(t,e)=>{let r=[];for(;t[0]?.[0]===e;){let[,...i]=t.shift(),s=Y(i[0])&&i.shift();s&&(s in r?(()=>{throw Error(`Duplicate ${e} ${s}`)})():r[s]=r.length),r.push(...i)}return r},Ut=t=>{let e=ne(t,"param"),r=ne(t,"result");if(t[0]?.[0]==="param")throw Error("Unexpected param");return[e,r]},Dt=(t,e)=>{if(t[0]?.[0]!=="type")return[,...Ut(t)];let[,r]=t.shift(),[i,s]=Ut(t),n=e.type[typeof r=="string"&&isNaN(r)?e.type[r]:+r];if(!n)throw Error(`Unknown type ${r}`);if((i.length||s.length)&&n[1].join(">")!==i+">"+s)throw Error(`Type ${r} mismatch`);return[r,...n[1]]},Ot=(t,e)=>{let[r,i,s]=Dt(t,e);if(!(!i.length&&!s.length))return!i.length&&s.length===1?["result",...s]:["type",r??Rt(i,s,e)]},ie=(t,e)=>{let r=Y(t[0])&&t.shift();return r&&(r in e?E(`Duplicate ${e.name} ${r}`):e[r]=e.length),r},Fe=([t],e)=>{let r="subfinal",i=[],s,n=[];t[0]==="sub"&&(r=t.shift(),t[0]==="final"&&(r+=t.shift()),t=(i=t).pop(),i=i.filter(f=>Array.isArray(f)&&(f[0]==="descriptor"||f[0]==="describes")?(n.push(f),!1):!0)),[s,...t]=t,s==="func"?(t=Ut(t),e.type["$"+t.join(">")]??=e.type.length):s==="struct"?t=ne(t,"field"):s==="array"&&([t]=t);let l=[s,t,r,i];return n.length&&(l.desc=n),l},le=[([t,...e],r)=>{let i=e;return(e[0]?.[0]==="before"||e[0]?.[0]==="after")&&(i=e.slice(1)),[...L(t),...i.flat()]},(t,e)=>{let[r,i,s,n,l]=t;if(l===!0)return;let f=(t.desc??[]).flatMap(([a,u])=>[a==="descriptor"?77:76,...S(B(u,e.type))]),c=(a,u)=>a==="func"?[yt.func,...L(u[0].map(g=>Z(g,e))),...L(u[1].map(g=>Z(g,e)))]:a==="array"?[yt.array,...Ft(u,e)]:a==="struct"?[yt.struct,...L(u.map(g=>Ft(g,e)))]:a==="cont"?[yt.cont,...S(B(u[0]??u,e.type))]:[yt[a]];if(l){let[a,u]=l,g=Array.from({length:u},(h,x)=>{let M=e.type[a+x],A=M.slice(0,4);return M.desc&&(A.desc=M.desc),le[F.type](A,e)});return[yt.rec,...L(g)]}else if(s==="sub"||n?.length)return[yt[s],...L(n.map(a=>B(a,e.type))),...f,...c(r,i)];return[...f,...c(r,i)]},([t,e,[r,...i]],s)=>{let n,l=re[r];if(r==="func"){i[0]==="exact"&&i.shift()&&(l=32);let[[,c]]=i;n=S(B(c,s.type))}else if(r==="tag"){let[[,f]]=i;n=[0,...S(B(f,s.type))]}else r==="memory"?n=Lt(i):r==="global"?n=Ft(i[0],s):r==="table"?n=[...Z(i.pop(),s),...Lt(i)]:E(`Unknown kind ${r}`);return[...L(t),...L(e),l,...n]},([[,t]],e)=>S(B(t,e.type)),(t,e)=>{let r=Lt(t),i=Z(t.shift(),e),[s]=t;return s?[64,0,...i,...r,...bt(s,e)]:[...i,...r]},(t,e)=>Lt(t),([t,e],r)=>[...Ft(t,r),...bt(e,r)],([t,[e,r]],i)=>[...L(t),re[e],...S(B(r,i[e]))],([t],e)=>S(B(t,e.func)),(t,e)=>{let r=0,i=0,s=0,n=0,l,f,c;t[0]==="declare"&&(t.shift(),i=1),t[0]?.[0]==="table"?([,l]=t.shift(),l=B(l,e.table)):(typeof t[0]=="string"||typeof t[0]=="number")&&(t[1]?.[0]==="offset"||Array.isArray(t[1])&&t[1][0]!=="item"&&!t[1][0]?.startsWith("ref"))&&(l=B(t.shift(),e.table)),t[0]?.[0]==="offset"||Array.isArray(t[0])&&t[0][0]!=="item"&&!t[0][0].startsWith("ref")?(f=t.shift(),f[0]==="offset"&&([,f]=f),f=bt(f,e)):i||(r=1),j[t[0]]||t[0]?.[0]==="ref"?c=Z(t.shift(),e):t[0]==="func"?c=[j[t.shift()]]:c=[j.func],t=t.map(u=>(u[0]==="item"&&(u=u.length===3&&u[1]==="ref.func"?u[2]:u[1]),u[0]==="ref.func"&&([,u]=u),typeof u!="string"&&(s=1),u)),c[0]!==j.funcref&&(n=1,s=1);let a=s<<2|(r||i?i:!!l||n)<<1|(r||i);return[a,...a===0?f:a===1?[0]:a===2?[...S(l||0),...f,0]:a===3?[0]:a===4?f:a===5?c:a===6?[...S(l||0),...f,...c]:c,...L(t.map(s?u=>bt(typeof u=="string"?["ref.func",u]:u,e):u=>S(B(u,e.func))))]},(t,e)=>{let[r,i]=t.shift();i||([,[i]]=e.type[B(r,e.type)]),e.local=Object.create(i),e.block=[],e.local.name="local",e.block.name="block",e._codeIdx===void 0&&(e._codeIdx=0);let s=e._codeIdx++;for(;t[0]?.[0]==="local";){let[,...u]=t.shift();if(Y(u[0])){let g=u.shift();g in e.local?E(`Duplicate local ${g}`):e.local[g]=e.local.length}e.local.push(...u)}e.meta={};let n=Pe(t,e),l=e.local.slice(i.length).reduce((u,g)=>(g==u[u.length-1]?.[1]?u[u.length-1][0]++:u.push([1,g]),u),[]),f=L(l.map(([u,g])=>[...S(u),...Z(g,e)])),c=e.import.filter(u=>u[2][0]==="func").length+s;for(let u in e.meta){for(let g of e.meta[u])g[0]+=f.length;((e.metadata??={})[u]??=[]).push([c,e.meta[u]])}e.local=e.block=e.meta=null;let a=L([...f,...n]);return(e.codeSizePrefix??=[])[s]=a.length-f.length-n.length,a},(t,e)=>{let r,i=0;return t[0]?.[0]==="memory"?([,i]=t.shift(),i=B(i,e.memory)):(typeof t[0]=="string"||typeof t[0]=="number")&&(t[1]?.[0]==="offset"||Array.isArray(t[1])&&typeof t[1][0]=="string")&&(i=B(t.shift(),e.memory)),Array.isArray(t[0])&&typeof t[0]?.[0]=="string"&&(r=t.shift(),r[0]==="offset"&&([,r]=r),r??E("Bad offset",r)),[...i?[2,...S(i),...bt(r,e)]:r?[0,...bt(r,e)]:[1],...L(t.flatMap(s=>Dr(s)??[...s]))]},(t,e)=>S(e.data.length),([[,t]],e)=>[0,...S(B(t,e.type))]],Z=(t,e)=>t[0]==="ref"?t[1]=="null"?Array.isArray(t[2])&&t[2][0]==="exact"?[j.refnull,98,...S(B(t[2][1],e.type))]:j[t[2]]?[j[t[2]]]:[j.refnull,...S(B(t[t.length-1],e.type))]:Array.isArray(t[1])&&t[1][0]==="exact"?[j.ref,98,...S(B(t[1][1],e.type))]:[j.ref,...S(j[t[t.length-1]]||B(t[t.length-1],e.type))]:[j[t]??E(`Unknown type ${t}`)],Ft=(t,e,r=t[0]==="mut"?1:0)=>[...Z(r?t[1]:t,e),r],De={null:()=>[],reversed:(t,e)=>{let r=t.shift(),i=t.shift();return[...S(B(i,e.elem)),...S(B(r,e.table))]},block:(t,e)=>{e.block.push(1),Y(t[0])&&(e.block[t.shift()]=e.block.length);let r=t.shift();return r?r[0]==="result"?Z(r[1],e):S(B(r[1],e.type)):[j.void]},try_table:(t,e)=>{Y(t[0])&&(e.block[t.shift()]=e.block.length+1);let r=t.shift(),i=r?r[0]==="result"?Z(r[1],e):S(B(r[1],e.type)):[j.void],s=[],n=0;for(;t[0]?.[0]==="catch"||t[0]?.[0]==="catch_ref"||t[0]?.[0]==="catch_all"||t[0]?.[0]==="catch_all_ref";){let l=t.shift(),f=l[0]==="catch"?0:l[0]==="catch_ref"?1:l[0]==="catch_all"?2:3;f<=1?s.push(f,...S(B(l[1],e.tag)),...S(pt(l[2],e.block))):s.push(f,...S(pt(l[1],e.block))),n++}return e.block.push(1),[...i,...S(n),...s]},end:(t,e)=>(e.block.pop(),[]),call_indirect:(t,e)=>{let r=t.shift(),[,i]=t.shift();return[...S(B(i,e.type)),...S(B(r,e.table))]},br_table:(t,e)=>{let r=[],i=0;for(;t[0]&&(!isNaN(t[0])||Y(t[0]));)r.push(...S(pt(t.shift(),e.block))),i++;return[...S(i-1),...r]},select:(t,e)=>{let r=t.shift()||[];return r.length?L(r.map(i=>Z(i,e))):[]},ref_null:(t,e)=>{let r=t.shift();return Array.isArray(r)&&r[0]==="exact"?[98,...S(B(r[1],e.type))]:j[r]?[j[r]]:S(B(r,e.type))},memarg:(t,e,r)=>Le(t,r,et(t[0])&&!se(t[0])?B(t.shift(),e.memory):0),opt_memory:(t,e)=>S(B(et(t[0])?t.shift():0,e.memory)),reftype:(t,e)=>{let r=Z(t.shift(),e);return r.length>1?r.slice(1):r},reftype2:(t,e)=>{let r=pt(t.shift(),e.block),i=Z(t.shift(),e),s=Z(t.shift(),e),n=l=>l.length>1?l.slice(1):l;return[(s[0]!==j.ref)<<1|i[0]!==j.ref,...S(r),...n(i),...n(s)]},v128const:t=>{let[e,r]=t.shift().split("x"),i=+e.slice(1),s=i>>>3;if(r=+r,e[0]==="i"){let l=r===16?new Uint8Array(16):r===8?new Uint16Array(8):r===4?new Uint32Array(4):new BigUint64Array(2);for(let f=0;f<r;f++)l[f]=qt[e].parse(t.shift());return[...new Uint8Array(l.buffer)]}let n=new Uint8Array(16);for(let l=0;l<r;l++)n.set(qt[e](t.shift()),l*s);return[...n]},shuffle:t=>{let e=[];for(let r=0;r<16;r++)e.push(Ct(t.shift(),32));return typeof t[0]=="string"&&!isNaN(t[0])&&E("invalid lane length"),e},memlane:(t,e,r)=>{let i=Y(t[0])||et(t[0])&&(se(t[1])||et(t[1]))?B(t.shift(),e.memory):0;return[...Le(t,r,i),...S(Ct(t.shift()))]},"*":t=>S(t.shift()),labelidx:(t,e)=>S(pt(t.shift(),e.block)),laneidx:t=>[Ct(t.shift(),255)],funcidx:(t,e)=>S(B(t.shift(),e.func)),typeidx:(t,e)=>S(B(t.shift(),e.type)),tableidx:(t,e)=>S(B(t.shift(),e.table)),memoryidx:(t,e)=>S(B(t.shift(),e.memory)),globalidx:(t,e)=>S(B(t.shift(),e.global)),localidx:(t,e)=>S(B(t.shift(),e.local)),dataidx:(t,e)=>S(B(t.shift(),e.data)),elemidx:(t,e)=>S(B(t.shift(),e.elem)),tagidx:(t,e)=>S(B(t.shift(),e.tag)),"memoryidx?":(t,e)=>S(B(et(t[0])?t.shift():0,e.memory)),stringidx:(t,e)=>{let r=t.shift(),i=r.valueOf(),s=e.strings.findIndex(n=>n.valueOf()===i);return s<0&&(s=e.strings.push(r)-1),S(s)},i32:t=>X(t.shift()),i64:t=>xt(t.shift()),f32:t=>dt(t.shift()),f64:t=>mt(t.shift()),v128:t=>ee(t.shift()),typeidx_field:(t,e)=>{let r=B(t.shift(),e.type);return[...S(r),...S(B(t.shift(),e.type[r][1]))]},typeidx_multi:(t,e)=>[...S(B(t.shift(),e.type)),...S(t.shift())],typeidx_dataidx:(t,e)=>[...S(B(t.shift(),e.type)),...S(B(t.shift(),e.data))],typeidx_elemidx:(t,e)=>[...S(B(t.shift(),e.type)),...S(B(t.shift(),e.elem))],typeidx_typeidx:(t,e)=>[...S(B(t.shift(),e.type)),...S(B(t.shift(),e.type))],dataidx_memoryidx:(t,e)=>[...S(B(t.shift(),e.data)),...S(B(t.shift(),e.memory))],memoryidx_memoryidx:(t,e)=>[...S(B(t.shift(),e.memory)),...S(B(t.shift(),e.memory))],tableidx_tableidx:(t,e)=>[...S(B(t.shift(),e.table)),...S(B(t.shift(),e.table))],cont_bind:(t,e)=>[...S(B(t.shift(),e.type)),...S(B(t.shift(),e.type))],switch_cont:(t,e)=>[...S(B(t.shift(),e.type)),...S(B(t.shift(),e.tag))],resume:(t,e)=>{let r=S(B(t.shift(),e.type)),i=[],s=0;for(;t[0]?.[0]==="on";){let[,n,l]=t.shift();l==="switch"?i.push(1,...S(B(n,e.tag))):i.push(0,...S(B(n,e.tag)),...S(pt(l,e.block))),s++}return[...r,...S(s),...i]},resume_throw:(t,e)=>{let r=S(B(t.shift(),e.type)),i=S(B(t.shift(),e.tag)),s=[],n=0;for(;t[0]?.[0]==="on";){let[,l,f]=t.shift();f==="switch"?s.push(1,...S(B(l,e.tag))):s.push(0,...S(B(l,e.tag)),...S(pt(f,e.block))),n++}return[...r,...i,...S(n),...s]},resume_throw_ref:(t,e)=>{let r=S(B(t.shift(),e.type)),i=[],s=0;for(;t[0]?.[0]==="on";){let[,n,l]=t.shift();l==="switch"?i.push(1,...S(B(n,e.tag))):i.push(0,...S(B(n,e.tag)),...S(pt(l,e.block))),s++}return[...r,...S(s),...i]}},wt={};(function t(e,r){for(let i=0,s,n,l;i<e.length;i++)(s=e[i])&&(Array.isArray(s)?t(s,i):([n,l]=s.split(" "),At[n]=r?[r,...S(i)]:[i],l&&(wt[n]=De[l])))})(At);var Pe=(t,e)=>{let r=[],i=[];for(;t?.length;){let s=t.shift();if(s?.[0]==="@metadata"){i.push(s.slice(1));continue}Array.isArray(s)&&(s.loc!=null&&(E.loc=s.loc),E(`Unknown instruction ${s[0]}`));let[...n]=At[s]||E(`Unknown instruction ${s}`);if(wt[s]&&(s==="select"&&t[0]?.length?n[0]++:wt[s]===De.reftype&&!s.endsWith("_null")&&(t[0][1]==="null"||t[0][0]!=="ref")&&n[n.length-1]++,n.push(...wt[s](t,e,s))),i.length){for(let[l,f]of i)(e.meta[l]??=[]).push([r.length,f]);i=[]}r.push(...n)}return r.push(11),r},Pt=t=>S(t).length,Lr=(t,e)=>{let r=0,i=[];for(;t?.length;){let s=t.shift();if(s?.[0]==="@metadata"){i.push(s.slice(1));continue}Array.isArray(s)&&(s.loc!=null&&(E.loc=s.loc),E(`Unknown instruction ${s[0]}`));let l=(At[s]||E(`Unknown instruction ${s}`)).length;if(wt[s]&&(l+=wt[s](t,e,s).length),i.length){for(let[f,c]of i)(e.meta[f]??=[]).push([r,c]);i=[]}r+=l}return r+1},Cr=(t,e)=>{let[r,i]=t.shift();i||([,[i]]=e.type[B(r,e.type)]),e.local=Object.create(i),e.block=[],e.local.name="local",e.block.name="block",e._codeIdx===void 0&&(e._codeIdx=0);let s=e._codeIdx++;for(;t[0]?.[0]==="local";){let[,...u]=t.shift();if(Y(u[0])){let g=u.shift();g in e.local?E(`Duplicate local ${g}`):e.local[g]=e.local.length}e.local.push(...u)}e.meta={};let n=Lr(t,e),l=e.local.slice(i.length).reduce((u,g)=>(g==u[u.length-1]?.[1]?u[u.length-1][0]++:u.push([1,g]),u),[]),f=L(l.map(([u,g])=>[...S(u),...Z(g,e)])),c=e.import.filter(u=>u[2][0]==="func").length+s;for(let u in e.meta){for(let g of e.meta[u])g[0]+=f.length;((e.metadata??={})[u]??=[]).push([c,e.meta[u]])}e.local=e.block=e.meta=null;let a=f.length+n;return(e.codeSizePrefix??=[])[s]=Pt(a),Pt(a)+a},bt=(t,e)=>Pe(ut([t],e),e),B=(t,e,r)=>(r=Y(t)?e[t]:+t,r in e?r:E(`Unknown ${e.name} ${t}`)),pt=(t,e,r)=>(r=Y(t)?e.length-e[t]:+t,isNaN(r)||r>e.length?E(`Bad label ${t}`):r),Rr=t=>{let e,r,i,s;for(;se(t[0]);)[i,s]=t.shift().split("="),i==="offset"?r=+s:i==="align"?e=+s:E(`Unknown param ${i}=${s}`);return(r<0||r>4294967295)&&E(`Bad offset ${r}`),(e<=0||e>4294967295)&&E(`Bad align ${e}`),e&&(e=Math.log2(e))%1&&E(`Bad align ${e}`),[e,r]},Le=(t,e,r=0)=>{let[i,s]=Rr(t),n=(i??Ur(e))|(r&&64);return r?[...S(n),...S(r),...S(s??0)]:[...S(n),...S(s??0)]},Ur=t=>{let e=t.indexOf(".",3)+1,r=t.slice(1,t[0]==="v"?4:3);if(t[e]==="a"&&(e=t.indexOf(".",e)+1),t[0]==="m")return t.includes("64")?3:2;if(t[e]==="r"){let n=t.slice(e,e+6).match(/\d+/);return Math.log2(n?n[0]/8:+r/8)}let i=t[e]==="l"?e+4:e+5,s=t.slice(i).match(/(\d+)(x|_|$)/);return Math.log2(s?s[2]==="x"?8:s[1]/8:+r/8)},Dr=t=>{if(!Array.isArray(t))return null;let[e,...r]=t;if(e!=="i8"&&e!=="i16"&&e!=="i32"&&e!=="i64"&&e!=="f32"&&e!=="f64")return null;let i=[],s=new DataView(new ArrayBuffer(8));for(let n of r)e==="i8"?i.push(X.parse(n)&511&255):e==="i16"?(s.setInt16(0,X.parse(n),!0),i.push(...new Uint8Array(s.buffer,0,2))):e==="i32"?(s.setInt32(0,X.parse(n),!0),i.push(...new Uint8Array(s.buffer,0,4))):e==="i64"?(s.setBigInt64(0,BigInt(n),!0),i.push(...new Uint8Array(s.buffer,0,8))):e==="f32"?i.push(...dt(n)):e==="f64"&&i.push(...mt(n));return i},Lt=t=>{let e=t[0]==="i64"&&t.shift(),r=t[t.length-1]==="shared"&&t.pop(),i=t.findIndex(a=>Array.isArray(a)&&a[0]==="pagesize"),s=-1;i>=0&&(s=Math.log2(+t.splice(i,1)[0][1]));let n=!isNaN(parseInt(t[1])),l=(s>=0?8:0)|(e?4:0)|(r?2:0)|(n?1:0),f=e?a=>{if(typeof a=="bigint")return a;let u=typeof a=="string"?a.replaceAll("_",""):String(a);return BigInt(u)}:Ct,c=s>=0?S(s):[];return n?[l,...S(f(t.shift())),...S(f(t.shift())),...c]:[l,...S(f(t.shift())),...c]},Ct=(t,e=4294967295)=>{let r=typeof t=="string"&&t[0]!=="+"?X.parse(t):typeof t=="number"?t:E(`Bad int ${t}`);return r>e?E(`Value out of range ${t}`):r},L=t=>[...S(t.length),...t.flat()];function We(t,e={}){typeof t=="string"&&(t=lt(t));let{indent:r=" ",newline:i=`
4
- `,comments:s=!0}=e;if(r||="",i||="",typeof t[0]=="string"&&t[0][0]!==";")return l(t);return t.filter(f=>s||!n(f)).map(f=>l(f)).join(i);function n(f){return typeof f=="string"&&f[1]===";"}function l(f,c=0){if(!Array.isArray(f))return f;let a=f[0];if(!a)return"";let u=!1;if(a==="try_table"){let x=1;for(typeof f[x]=="string"&&f[x][0]==="$"&&(a+=" "+f[x++]),Array.isArray(f[x])&&(f[x][0]==="result"||f[x][0]==="type")&&(a+=" "+l(f[x++],c));Array.isArray(f[x])&&/^catch/.test(f[x][0]);)a+=" "+l(f[x++],c).trim();for(;x<f.length;x++)a+=Array.isArray(f[x])?i+r.repeat(c+1)+l(f[x],c+1):" "+f[x];return`(${a+i+r.repeat(c)})`}let g=!!i&&f.length<4&&!f.some(x=>typeof x=="string"&&x[0]===";"&&x[1]===";"),h=r.repeat(c+1);for(let x=1;x<f.length;x++){let M=f[x]?.valueOf?.()??f[x];if(typeof M=="string"&&M[1]===";"){if(!s)continue;if(M[0]===";")if(i)a+=i+h+M.trimEnd(),u=!0;else{let A=a[a.length-1];A&&A!==" "&&A!=="("&&(a+=" "),a+=M.trimEnd()+`
5
- `}else{let A=a[a.length-1];A&&A!==" "&&A!=="("&&(a+=" "),a+=M.trimEnd()}}else if(Array.isArray(M))g&&(g=M.every(A=>!Array.isArray(A))),a+=i+h+l(M,c+1),u=!1;else if(f[0]==="data")g=!1,(i||a[a.length-1]!==")")&&(a+=i||" "),a+=h+M,u=!1;else{let A=a[a.length-1];u&&i?a+=i+h:A===`
6
- `?a+="":(A&&A!==")"&&A!==" "||i||A===")")&&(a+=" "),a+=M,u=!1}}return g?`(${a.replaceAll(i+h+"("," (")})`:`(${a+i+r.repeat(c)})`}}var Ge=(t,e)=>{let r=[],i=t[0]==="module"?1:0;for(let s=i;s<t.length;s++)Array.isArray(t[s])&&t[s][0]===e&&r.push({node:t[s],idx:s});return r},Wt=(t,e,r)=>t.splice(e,0,r),Pr=0,ft=t=>`$__${t}${Pr++}`,Wr=(t,e)=>{let r=new Set;if(V(t,a=>{Array.isArray(a)&&a[0]==="ref.func"&&r.add(a[1])}),!r.size)return t;let i=ft("fntbl"),s=[...r],n=Object.fromEntries(s.map((a,u)=>[a,u])),l=Ge(t,"func"),f=l.length?l[0].idx:t[0]==="module"?1:0;Wt(t,f,["table",i,"funcref",["elem",...s]]);let c={};return V(t,a=>{if(!Array.isArray(a)||a[0]!=="func")return;let u=typeof a[1]=="string"&&a[1][0]==="$"?a[1]:null;if(!u)return;let g=[],h=[];for(let x of a){if(Array.isArray(x)&&x[0]==="param")for(let M=1;M<x.length;M++)x[M][0]!=="$"&&g.push(x[M]);if(Array.isArray(x)&&x[0]==="result")for(let M=1;M<x.length;M++)h.push(x[M])}c[u]={params:g,results:h}}),J(t,(a,u,g)=>{if(!(!Array.isArray(a)||!u)){if(a[0]==="ref.func"&&n[a[1]]!==void 0&&(u[g]=["i32.const",n[a[1]]]),a[0]==="call_ref"){let h=a[1],x=a.slice(2);u[g]=["call_indirect",i,["type",h],...x]}if(a[0]==="return_call_ref"){let h=a[1],x=a.slice(2);u[g]=["return_call_indirect",i,["type",h],...x]}}}),t},jr={"i32.extend8_s":["i32",24],"i32.extend16_s":["i32",16],"i64.extend8_s":["i64",56n],"i64.extend16_s":["i64",48n],"i64.extend32_s":["i64",32n]},Gr=(t,e)=>(J(t,(r,i,s)=>{if(!Array.isArray(r)||!i)return;let n=jr[r[0]];if(!n)return;let[l,f]=n,c=r.slice(1);i[s]=[`${l}.shr_s`,[`${l}.shl`,...c,[`${l}.const`,f]],[`${l}.const`,f]]}),t),je={"i32.trunc_sat_f32_s":{itype:"i32",ftype:"f32",signed:!0,min:-2147483648,max:2147483647},"i32.trunc_sat_f32_u":{itype:"i32",ftype:"f32",signed:!1,min:0,max:4294967295},"i32.trunc_sat_f64_s":{itype:"i32",ftype:"f64",signed:!0,min:-2147483648,max:2147483647},"i32.trunc_sat_f64_u":{itype:"i32",ftype:"f64",signed:!1,min:0,max:4294967295},"i64.trunc_sat_f32_s":{itype:"i64",ftype:"f32",signed:!0,min:-9223372036854775808n,max:9223372036854775807n},"i64.trunc_sat_f32_u":{itype:"i64",ftype:"f32",signed:!1,min:0n,max:18446744073709551615n},"i64.trunc_sat_f64_s":{itype:"i64",ftype:"f64",signed:!0,min:-9223372036854775808n,max:9223372036854775807n},"i64.trunc_sat_f64_u":{itype:"i64",ftype:"f64",signed:!1,min:0n,max:18446744073709551615n}},Hr=(t,e)=>{let r=new Set;if(V(t,s=>{Array.isArray(s)&&je[s[0]]&&r.add(s[0])}),!r.size)return t;let i={};for(let s of r){let{itype:n,ftype:l,signed:f,min:c,max:a}=je[s],u=ft(`trunc_${n}_${l}_${f?"s":"u"}`);i[s]=u;let g=`${n}.trunc_${l}_${f?"s":"u"}`,h=n==="i64"?0n:0,x=["func",u,["param","$v",l],["result",n],["if",["result",n],[`${l}.ne`,["local.get","$v"],["local.get","$v"]],["then",[`${n}.const`,h]],["else",["if",["result",n],[`${l}.lt`,["local.get","$v"],[`${l}.const`,typeof c=="bigint"?Number(c):c]],["then",[`${n}.const`,c]],["else",["if",["result",n],[`${l}.gt`,["local.get","$v"],[`${l}.const`,typeof a=="bigint"?Number(a):a]],["then",[`${n}.const`,a]],["else",[g,["local.get","$v"]]]]]]]]];t.push(x)}return J(t,(s,n,l)=>{!Array.isArray(s)||!n||i[s[0]]&&(n[l]=["call",i[s[0]],...s.slice(1)])}),t},Vr=(t,e)=>{let r=new Set,i=new Set;V(t,l=>{if(Array.isArray(l)){if(l[0]==="memory.copy"){let f=typeof l[1]=="number"?l[1]:0,c=typeof l[2]=="number"?l[2]:0;r.add(`${f}_${c}`)}if(l[0]==="memory.fill"){let f=typeof l[1]=="number"?l[1]:0;i.add(f)}}});let s={},n={};for(let l of r){let[f,c]=l.split("_").map(Number),a=ft(`memcpy${l==="0_0"?"":"_"+l}`);s[l]=a;let u=f?["i32.store8",f]:["i32.store8"],g=c?["i32.load8_u",c]:["i32.load8_u"];t.push(["func",a,["param","$dst","i32"],["param","$src","i32"],["param","$len","i32"],["local","$i","i32"],["block","$done",["loop","$loop",["br_if","$done",["i32.ge_u",["local.get","$i"],["local.get","$len"]]],[...u,["i32.add",["local.get","$dst"],["local.get","$i"]],[...g,["i32.add",["local.get","$src"],["local.get","$i"]]]],["local.set","$i",["i32.add",["local.get","$i"],["i32.const",1]]],["br","$loop"]]]])}for(let l of i){let f=ft(`memset${l===0?"":"_"+l}`);n[l]=f;let c=l?["i32.store8",l]:["i32.store8"];t.push(["func",f,["param","$dst","i32"],["param","$val","i32"],["param","$len","i32"],["local","$i","i32"],["block","$done",["loop","$loop",["br_if","$done",["i32.ge_u",["local.get","$i"],["local.get","$len"]]],[...c,["i32.add",["local.get","$dst"],["local.get","$i"]],["local.get","$val"]],["local.set","$i",["i32.add",["local.get","$i"],["i32.const",1]]],["br","$loop"]]]])}return J(t,(l,f,c)=>{if(!(!Array.isArray(l)||!f)){if(l[0]==="memory.copy"){let a=typeof l[1]=="number"?l[1]:0,u=typeof l[2]=="number"?l[2]:0,g=l.filter(h=>Array.isArray(h)||typeof h=="string"&&h[0]==="$");f[c]=["call",s[`${a}_${u}`],...g]}if(l[0]==="memory.fill"){let a=typeof l[1]=="number"?l[1]:0,u=l.filter(g=>Array.isArray(g)||typeof g=="string"&&g[0]==="$");f[c]=["call",n[a],...u]}}}),t},Yr=(t,e)=>{let r=!1;return V(t,i=>{Array.isArray(i)&&(i[0]==="return_call"||i[0]==="return_call_indirect")&&(r=!0)}),r&&J(t,(i,s,n)=>{!Array.isArray(i)||!s||(i[0]==="return_call"&&(s[n]=["return",["call",...i.slice(1)]]),i[0]==="return_call_indirect"&&(s[n]=["return",["call_indirect",...i.slice(1)]]))}),t},Xr=(t,e)=>(J(t,(r,i,s)=>{if(!(!Array.isArray(r)||!i)&&(r[0]==="ref.i31"&&(i[s]=["i32.and",...r.slice(1),["i32.const",2147483647]]),r[0]==="i31.get_u"&&(i[s]=r.length>1?r[1]:["drop"]),r[0]==="i31.get_s")){let n=r.slice(1);i[s]=["i32.shr_s",["i32.shl",...n,["i32.const",1]],["i32.const",1]]}}),t),Zr=(t,e)=>{let r={};V(t,s=>{if(!Array.isArray(s)||s[0]!=="global")return;let n=typeof s[1]=="string"&&s[1][0]==="$"?s[1]:null;if(n)for(let l=s.length-1;l>=0;l--){let f=s[l];if(Array.isArray(f)&&(f[0]==="i32.const"||f[0]==="i64.const"||f[0]==="f32.const"||f[0]==="f64.const")){r[n]={type:f[0].split(".")[0],value:f[1]};break}}});let i=s=>{if(!Array.isArray(s))return s;let n=s[0];if(n==="global.get"&&r[s[1]]){let l=r[s[1]];return[`${l.type}.const`,l.value]}if(n==="i32.add"||n==="i64.add"){let l=i(s[1]),f=i(s[2]);if(l&&f&&l[0]?.endsWith(".const")&&f[0]?.endsWith(".const")){let c=n.split(".")[0],a=c==="i64"?BigInt(l[1]):Number(l[1]),u=c==="i64"?BigInt(f[1]):Number(f[1]);return[`${c}.const`,a+u]}}if(n==="i32.sub"||n==="i64.sub"){let l=i(s[1]),f=i(s[2]);if(l&&f&&l[0]?.endsWith(".const")&&f[0]?.endsWith(".const")){let c=n.split(".")[0],a=c==="i64"?BigInt(l[1]):Number(l[1]),u=c==="i64"?BigInt(f[1]):Number(f[1]);return[`${c}.const`,a-u]}}if(n==="i32.mul"||n==="i64.mul"){let l=i(s[1]),f=i(s[2]);if(l&&f&&l[0]?.endsWith(".const")&&f[0]?.endsWith(".const")){let c=n.split(".")[0],a=c==="i64"?BigInt(l[1]):Number(l[1]),u=c==="i64"?BigInt(f[1]):Number(f[1]);return[`${c}.const`,a*u]}}return s};return J(t,(s,n,l)=>{if(!(!Array.isArray(s)||s[0]!=="global"||!n)){for(let f=2;f<s.length;f++)if(Array.isArray(s[f])){let c=i(s[f]);c!==s[f]&&(s[f]=c)}}}),t},Kr=(t,e)=>{let r=new Map,i=[];if(V(t,f=>{if(!Array.isArray(f)||f[0]!=="func")return;let c=typeof f[1]=="string"&&f[1][0]==="$"?f[1]:null,a=[];for(let u of f)if(Array.isArray(u)&&u[0]==="result")for(let g=1;g<u.length;g++)a.push(u[g]);a.length>1&&c&&r.set(c,a)}),!r.size)return t;let s=Math.max(...[...r.values()].map(f=>f.length)),n={};for(let[f,c]of r)for(let a=1;a<c.length;a++){let u=c[a];if(n[u]||(n[u]=[]),n[u].length<a){let g=ft(`ret_${u}_${n[u].length}`);n[u].push(g),i.push(["global",g,["mut",u],[`${u}.const`,u==="i64"?0n:0]])}}let l=t[0]==="module"?1:0;for(let f of i.reverse())Wt(t,l,f);return J(t,(f,c,a)=>{if(!Array.isArray(f)||f[0]!=="func")return;let u=typeof f[1]=="string"&&f[1][0]==="$"?f[1]:null;if(!u||!r.has(u))return;let g=r.get(u);for(let h=0;h<f.length;h++)if(Array.isArray(f[h])&&f[h][0]==="result"){f[h]=["result",g[0]];break}}),t},Bt={i32:4,i64:8,f32:4,f64:8},Qr=(t,e)=>{let r=new Map,i=new Map,s=1;if(V(t,A=>{if(!Array.isArray(A)||A[0]!=="type")return;let w=typeof A[1]=="string"&&A[1][0]==="$"?A[1]:null;if(w){for(let b of A)if(Array.isArray(b)){if(b[0]==="struct"){let o=[];for(let y of b)if(Array.isArray(y)&&y[0]==="field"){let p=typeof y[1]=="string"&&y[1][0]==="$"?y[1]:null,m=p?y[2]:y[1],_=Array.isArray(m)&&m[0]==="mut"?m[1]:m;o.push({name:p,type:_})}r.set(w,{kind:"struct",fields:o}),i.set(w,s++)}if(b[0]==="array"){let o=b[1],y=Array.isArray(o)&&o[0]==="mut"?o[1]:o;r.set(w,{kind:"array",elemType:y}),i.set(w,s++)}}}}),!r.size)return t;let n=Ge(t,"memory").length>0,l=ft("alloc"),f=ft("heap_ptr"),c=t[0]==="module"?1:0;n||Wt(t,c,["memory",1]),Wt(t,c+1,["global",f,["mut","i32"],["i32.const",1024]]);let a=["func",l,["param","$size","i32"],["result","i32"],["local","$ptr","i32"],["local.set","$ptr",["global.get",f]],["global.set",f,["i32.add",["global.get",f],["local.get","$size"]]],["local.get","$ptr"]];t.push(a);let u=A=>{let w=4;for(let b of A.fields)w+=Bt[b.type]||4;return w},g=(A,w)=>{let b=4;for(let o=0;o<w;o++)b+=Bt[A.fields[o].type]||4;return b},h=(A,w)=>{for(let b=0;b<A.fields.length;b++)if(A.fields[b].name===w)return b;return-1},x=0,M=()=>`$__gc_tmp${x++}`;return V(t,A=>{if(!Array.isArray(A)||A[0]!=="func")return;let w=!1,b=!1,o=!1,y=!1;if(V(A,m=>{Array.isArray(m)&&((m[0]==="struct.new"||m[0]==="struct.new_default")&&(w=!0),(m[0]==="array.new"||m[0]==="array.new_default")&&(b=!0,o=!0,y=!0))}),!w&&!b)return;let p=1;for(let m=1;m<A.length;m++){let _=A[m];if(Array.isArray(_)&&(_[0]==="param"||_[0]==="result"||_[0]==="local"||_[0]==="export"||_[0]==="type"))p=m+1;else if(typeof _=="string"&&_[0]==="$")p=m+1;else if(!Array.isArray(_))p=m+1;else break}w&&A.splice(p++,0,["local","$__gc_ptr","i32"]),b&&A.splice(p++,0,["local","$__gc_aptr","i32"]),o&&A.splice(p++,0,["local","$__gc_alen","i32"]),y&&A.splice(p++,0,["local","$__gc_aidx","i32"])}),J(t,(A,w,b)=>{if(!(!Array.isArray(A)||!w)){if(A[0]==="struct.new"||A[0]==="struct.new_default"){let o=A[1],y=r.get(o);if(!y||y.kind!=="struct")return;let p=u(y),m=i.get(o),_=A.slice(2),d="$__gc_ptr",$=[["local.set",d,["call",l,["i32.const",p]]],["i32.store",["local.get",d],["i32.const",m]]];if(A[0]==="struct.new")for(let z=0;z<y.fields.length;z++){let I=y.fields[z],k=g(y,z),N=I.type==="i64"?"i64.store":I.type==="f32"?"f32.store":I.type==="f64"?"f64.store":"i32.store";$.push([N,["i32.add",["local.get",d],["i32.const",k]],_[z]||[`${I.type}.const`,0]])}else for(let z=0;z<y.fields.length;z++){let I=y.fields[z],k=g(y,z),N=I.type==="i64"?"i64.store":I.type==="f32"?"f32.store":I.type==="f64"?"f64.store":"i32.store",v=I.type==="i64"?["i64.const",0n]:I.type==="f32"?["f32.const",0]:I.type==="f64"?["f64.const",0]:["i32.const",0];$.push([N,["i32.add",["local.get",d],["i32.const",k]],v])}$.push(["local.get",d]),w[b]=["block",["result","i32"],...$]}if(A[0]==="struct.get"){let o=A[1],y=A[2],p=A[3],m=r.get(o);if(!m||m.kind!=="struct")return;let _=typeof y=="string"&&y[0]==="$"?h(m,y):parseInt(y);if(_<0)return;let d=m.fields[_],$=g(m,_),z=d.type==="i64"?"i64.load":d.type==="f32"?"f32.load":d.type==="f64"?"f64.load":"i32.load";w[b]=[z,["i32.add",p,["i32.const",$]]]}if(A[0]==="struct.set"){let o=A[1],y=A[2],p=A[3],m=A[4],_=r.get(o);if(!_||_.kind!=="struct")return;let d=typeof y=="string"&&y[0]==="$"?h(_,y):parseInt(y);if(d<0)return;let $=_.fields[d],z=g(_,d),I=$.type==="i64"?"i64.store":$.type==="f32"?"f32.store":$.type==="f64"?"f64.store":"i32.store";w[b]=[I,["i32.add",p,["i32.const",z]],m]}if(A[0]==="array.new"||A[0]==="array.new_default"){let o=A[1],y=r.get(o);if(!y||y.kind!=="array")return;let p=i.get(o),m=Bt[y.elemType]||4,_=A[0]==="array.new"?A[2]:null,d=A[0]==="array.new"?A[3]:A[2],$="$__gc_aptr",z="$__gc_alen",I="$__gc_aidx",k=y.elemType==="i64"?"i64.store":y.elemType==="f32"?"f32.store":y.elemType==="f64"?"f64.store":"i32.store",N=[["local.set",z,d],["local.set",$,["call",l,["i32.add",["i32.const",8],["i32.mul",["local.get",z],["i32.const",m]]]]],["i32.store",["local.get",$],["i32.const",p]],["i32.store",["i32.add",["local.get",$],["i32.const",4]],["local.get",z]]];_&&N.push(["local.set",I,["i32.const",0]],["block","$done",["loop","$loop",["br_if","$done",["i32.ge_u",["local.get",I],["local.get",z]]],[k,["i32.add",["i32.add",["local.get",$],["i32.const",8]],["i32.mul",["local.get",I],["i32.const",m]]],_],["local.set",I,["i32.add",["local.get",I],["i32.const",1]]],["br","$loop"]]]),N.push(["local.get",$]),w[b]=["block",["result","i32"],...N]}if(A[0]==="array.get"){let o=A[1],y=A[2],p=A[3],m=r.get(o);if(!m||m.kind!=="array")return;let _=Bt[m.elemType]||4,d=m.elemType==="i64"?"i64.load":m.elemType==="f32"?"f32.load":m.elemType==="f64"?"f64.load":"i32.load";w[b]=[d,["i32.add",["i32.add",y,["i32.const",8]],["i32.mul",p,["i32.const",_]]]]}if(A[0]==="array.set"){let o=A[1],y=A[2],p=A[3],m=A[4],_=r.get(o);if(!_||_.kind!=="array")return;let d=Bt[_.elemType]||4,$=_.elemType==="i64"?"i64.store":_.elemType==="f32"?"f32.store":_.elemType==="f64"?"f64.store":"i32.store";w[b]=[$,["i32.add",["i32.add",y,["i32.const",8]],["i32.mul",p,["i32.const",d]]],m]}if(A[0]==="array.len"){let o=A[1];w[b]=["i32.load",["i32.add",o,["i32.const",4]]]}}}),t},Jr=(t,e)=>{let r=new Map,i=1;return V(t,s=>{if(!Array.isArray(s)||s[0]!=="type")return;let n=typeof s[1]=="string"&&s[1][0]==="$"?s[1]:null;if(n)for(let l of s)Array.isArray(l)&&(l[0]==="struct"||l[0]==="array")&&r.set(n,i++)}),r.size&&J(t,(s,n,l)=>{if(!(!Array.isArray(s)||!n)){if(s[0]==="ref.test"){let f=s[1],c=null;Array.isArray(f)&&f[0]==="ref"&&(c=f[1]==="null"?f[2]:f[1]);let a=s[2],u=r.get(c);u!==void 0&&(n[l]=["if",["result","i32"],["i32.eqz",a],["then",["i32.const",0]],["else",["i32.eq",["i32.load",a],["i32.const",u]]]])}if(s[0]==="ref.cast"){let f=s[1],c=null,a=!1;Array.isArray(f)&&f[0]==="ref"&&(f[1]==="null"?(a=!0,c=f[2]):c=f[1]);let u=s[2],g=r.get(c);if(g!==void 0){let h=ft("cast");a?n[l]=["block",["result","i32"],["local",h,"i32"],["local.set",h,u],["if",["i32.and",["i32.ne",["local.get",h],["i32.const",0]],["i32.ne",["i32.load",["local.get",h]],["i32.const",g]]],["then",["unreachable"]]],["local.get",h]]:n[l]=["block",["result","i32"],["local",h,"i32"],["local.set",h,u],["if",["i32.or",["i32.eqz",["local.get",h]],["i32.ne",["i32.load",["local.get",h]],["i32.const",g]]],["then",["unreachable"]]],["local.get",h]]}}if(s[0]==="br_on_cast"){let f=s[1],c=s[2],a=s[3],u=s[4],g=null;Array.isArray(a)&&a[0]==="ref"&&(g=a[1]==="null"?a[2]:a[1]);let h=r.get(g);if(h!==void 0){let x=ft("brcast");n[l]=["block",["result","i32"],["local",x,"i32"],["local.set",x,u],["br_if",f,["i32.and",["i32.ne",["local.get",x],["i32.const",0]],["i32.eq",["i32.load",["local.get",x]],["i32.const",h]]]],["local.get",x]]}}if(s[0]==="br_on_cast_fail"){let f=s[1],c=s[2],a=s[3],u=s[4],g=null;Array.isArray(a)&&a[0]==="ref"&&(g=a[1]==="null"?a[2]:a[1]);let h=r.get(g);if(h!==void 0){let x=ft("brfail");n[l]=["block",["result","i32"],["local",x,"i32"],["local.set",x,u],["br_if",f,["i32.or",["i32.eqz",["local.get",x]],["i32.ne",["i32.load",["local.get",x]],["i32.const",h]]]],["local.get",x]]}}}}),t},jt=[["funcref",["ref.func","call_ref","return_call_ref"],Wr],["sign_ext",["i32.extend8_s","i32.extend16_s","i64.extend8_s","i64.extend16_s","i64.extend32_s"],Gr],["nontrapping",["i32.trunc_sat_f32_s","i32.trunc_sat_f32_u","i32.trunc_sat_f64_s","i32.trunc_sat_f64_u","i64.trunc_sat_f32_s","i64.trunc_sat_f32_u","i64.trunc_sat_f64_s","i64.trunc_sat_f64_u"],Hr],["bulk_memory",["memory.copy","memory.fill"],Vr],["return_call",["return_call","return_call_indirect"],Yr],["i31ref",["ref.i31","i31.get_s","i31.get_u"],Xr],["extended_const",["global.get"],Zr],["multi_value",[],Kr],["gc",["struct.new","struct.get","struct.set","array.new","array.get","array.set","array.len","struct.new_default","array.new_default","array.new_fixed","array.copy"],Qr],["ref_cast",["ref.test","ref.cast","br_on_cast","br_on_cast_fail"],Jr]],Ns=Object.fromEntries(jt.map(t=>[t[0],t[1]])),ti=t=>{if(t===!1)return{};if(t!==!0&&typeof t!="string")return{...t};let e=typeof t=="string"?new Set(t.split(/\s+/).filter(Boolean)):null,r={};for(let i of jt)r[i[0]]=e?e.has("all")||e.has(i[0]):!0;return r},ei=t=>{let e=new Set;return V(t,r=>{if(typeof r=="string")for(let i of jt)i[1].some(n=>r===n||r.startsWith(n+" "))&&e.add(i[0])}),V(t,r=>{if(!(!Array.isArray(r)||r[0]!=="global"))for(let i of r)Array.isArray(i)&&(i[0]==="i32.add"||i[0]==="i32.sub"||i[0]==="i32.mul"||i[0]==="i64.add"||i[0]==="i64.sub"||i[0]==="i64.mul")&&V(i,s=>{Array.isArray(s)&&s[0]==="global.get"&&e.add("extended_const")})}),V(t,r=>{if(!Array.isArray(r)||r[0]!=="func")return;let i=0;for(let s of r)Array.isArray(s)&&s[0]==="result"&&(i+=s.length-1);i>1&&e.add("multi_value")}),e};function ae(t,e=!0){typeof t=="string"&&(t=lt(t)),t=Jt(t),e=ti(e);let r=ei(t),i={uid:0};for(let s of jt){let n=s[2];r.has(s[0])&&e[s[0]]!==!1&&(t=n(t,i))}return t}var ri=6,er=16,Q=t=>Array.isArray(t)?t.map(Q):t,R=(t,e,r,i)=>{if(e(t,r,i),Array.isArray(t))for(let s=0;s<t.length;s++)R(t[s],e,t,s)},H=(t,e,r,i)=>{if(Array.isArray(t))for(let n=0;n<t.length;n++)H(t[n],e,t,n);let s=e(t,r,i);return s!==void 0&&r&&(r[i]=s),s!==void 0?s:t},He=t=>{if(typeof t!="string")return null;let e=t.indexOf(".");if(e<0)return null;let r=t.slice(0,e),i=r==="i32"||r==="i64"||r==="f32"||r==="f64";return i&&/^(eqz?|ne|[lg][te])(_[su])?$/.test(t.slice(e+1))?"i32":i||r==="v128"?r:t==="memory.size"||t==="memory.grow"?"i32":null};var Ve=t=>{try{return Ue(t)}catch{return 1/0}},nt=(t,e)=>{if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="bigint")return t===e;if(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!nt(t[r],e[r]))return!1;return!0},It=t=>{let e=1;for(;e<t.length;){let s=t[e];if(Array.isArray(s)&&(s[0]==="then"||s[0]==="else"||s[0]==="result"||s[0]==="param")){e++;continue}break}let r=null,i=null;for(let s=e+1;s<t.length;s++){let n=t[s];Array.isArray(n)&&(n[0]==="then"?r=n:n[0]==="else"&&(i=n))}return{condIdx:e,cond:t[e],thenBranch:r,elseBranch:i}},ii=t=>{if(!Array.isArray(t)||t[0]!=="module")return t;let e=new Map,r=new Map,i=new Map,s=new Map,n=new Map,l=new Map,f=(I,k,N,v=!1)=>{let T=typeof k[1]=="string"&&k[1][0]==="$",C=T?k[1]:N,st=!v&&k.some(O=>Array.isArray(O)&&O[0]==="export"),W={node:k,idx:N,used:st,isImport:v};return I.set(C,W),T&&I.set(N,W),l.set(k,W),W},c=0,a=0,u=0,g=0,h=0,x=[],M=[],A=[],w=[];for(let I of t.slice(1)){if(!Array.isArray(I))continue;let k=I[0];if(k==="type")f(i,I,u++);else if(k==="func")f(e,I,c++);else if(k==="global")f(r,I,a++);else if(k==="table")f(s,I,g++);else if(k==="memory")f(n,I,h++);else if(k==="import")for(let N of I)Array.isArray(N)&&(N[0]==="func"?f(e,N,c++,!0):N[0]==="global"?f(r,N,a++,!0):N[0]==="table"?f(s,N,g++,!0):N[0]==="memory"&&f(n,N,h++,!0));else k==="export"?A.push(I):k==="start"?w.push(I):k==="elem"?x.push(I):k==="data"&&M.push(I)}let b=[],o=I=>{I&&!I.scanned&&b.push(I)},y=I=>{let k=e.get(I);k&&(k.used||(k.used=!0),o(k))},p=I=>{let k=r.get(I);k&&(k.used=!0)},m=I=>{let k=s.get(I);k&&(k.used=!0)},_=I=>{typeof I=="string"&&I[0]!=="$"&&(I=+I);let k=n.get(I);k&&(k.used=!0)},d=I=>{let k=i.get(I);k&&(k.used=!0)};for(let I of A)for(let k of I){if(!Array.isArray(k))continue;let[N,v]=k;N==="func"?y(v):N==="global"?p(v):N==="table"?m(v):N==="memory"&&_(v)}for(let I of w){let k=I[1];typeof k=="string"&&k[0]!=="$"&&(k=+k),y(k)}for(let I of x)R(I,k=>{Array.isArray(k)&&k[0]==="ref.func"?y(k[1]):typeof k=="string"&&k[0]==="$"&&y(k)});for(let I of M){let k=I[1];Array.isArray(k)&&k[0]==="memory"?_(k[1]):typeof k=="string"&&k[0]==="$"?_(k):Array.isArray(k)&&_(0)}for(let I of[e,r,s,n])for(let k of I.values())k.used&&o(k);if(!(A.length>0||w.length>0||x.length>0||b.length>0)){for(let I of[e,r,s,n])for(let k of I.values())k.used=!0;return t}for(;b.length;){let I=b.pop();I.scanned||(I.scanned=!0,!I.isImport&&R(I.node,k=>{if(!Array.isArray(k)){typeof k=="string"&&k[0]==="$"&&y(k);return}let[N,v]=k;if(N==="call"||N==="return_call"||N==="ref.func")y(v);else if(N==="global.get"||N==="global.set")p(v);else if(N==="type")d(v);else if(N==="call_indirect"||N==="return_call_indirect")for(let T of k)typeof T=="string"&&T[0]==="$"&&m(T);typeof N=="string"&&(N.startsWith("memory.")||N.includes(".load")||N.includes(".store"))&&_(0)}))}let z=["module"];for(let I of t.slice(1)){if(!Array.isArray(I)){z.push(I);continue}let k=I[0];if(k==="func"||k==="global"||k==="type")l.get(I)?.used&&z.push(I);else if(k==="import"){let N=!1;for(let v of I){if(!Array.isArray(v))continue;if(l.get(v)?.used){N=!0;break}}N&&z.push(I)}else z.push(I)}return z},Ye=t=>t-Math.floor(t)!==.5?Math.round(t):2*Math.round(t/2),rr=new ArrayBuffer(8),me=new Float64Array(rr),kt=new Uint32Array(rr),ir=new ArrayBuffer(4),_e=new Float32Array(ir),he=new Int32Array(ir),K=t=>(t>>>0).toString(16).padStart(8,"0"),si=t=>{let e="",r=1;for(let i=15;i>=0;i--){let s=15-parseInt(t[i],16)+r;e=(s&15).toString(16)+e,r=s>>4}return e},Nt=t=>{let e=t.toString(16);return e[0]==="-"?si(e.slice(1).padStart(16,"0")):e.padStart(16,"0")},G="0x0000000000000000",ce="0x0000000000000001",Kt="0xffffffffffffffff",gt=t=>{if(typeof t=="string"){let e=t.replaceAll("_","");if(e.length===18&&e[1]==="x")return"0x"+e.slice(2).toLowerCase();let r=e[0]==="-",i=e[0]==="-"||e[0]==="+"?e.slice(1):e;return"0x"+Nt(r?-BigInt(i):BigInt(i))}return typeof t=="bigint"?"0x"+Nt(BigInt(String(t))):"0x"+Nt(BigInt(Math.trunc(t)||0))},Xe=t=>(parseInt(t[2],16)^8).toString(16)+t.slice(3),Gt=t=>parseInt(t.slice(10),16)|0,at=t=>parseInt(t.slice(2,10),16)>>>0,rt=t=>t==null?null:"0x"+Nt(t),zt=t=>{let e=BigInt(t);return e>0x7fffffffffffffffn&&(e=e-0x8000000000000000n-0x8000000000000000n),e},ni=t=>(me[0]=t,"0x"+K(kt[1])+K(kt[0])),li=t=>(kt[1]=parseInt(t.slice(2,10),16),kt[0]=parseInt(t.slice(10),16),me[0]),fi=t=>(_e[0]=t,he[0]),oi=t=>(he[0]=t|0,_e[0]),$t=t=>(e,r)=>t(e,r)?1:0,Ht=t=>(e,r)=>t(e>>>0,r>>>0)?1:0,Vt=t=>(e,r)=>t(Xe(e),Xe(r))?1:0,Yt=t=>(e,r)=>t(e,r)?1:0,ai={"i32.add":(t,e)=>t+e|0,"i32.sub":(t,e)=>t-e|0,"i32.mul":(t,e)=>Math.imul(t,e),"i32.div_s":(t,e)=>e!==0?t/e|0:null,"i32.div_u":(t,e)=>e!==0?(t>>>0)/(e>>>0)|0:null,"i32.rem_s":(t,e)=>e!==0?t%e|0:null,"i32.rem_u":(t,e)=>e!==0?(t>>>0)%(e>>>0)|0:null,"i32.and":(t,e)=>t&e,"i32.or":(t,e)=>t|e,"i32.xor":(t,e)=>t^e,"i32.shl":(t,e)=>t<<(e&31),"i32.shr_s":(t,e)=>t>>(e&31),"i32.shr_u":(t,e)=>t>>>(e&31),"i32.rotl":(t,e)=>(e&=31,t<<e|t>>>32-e|0),"i32.rotr":(t,e)=>(e&=31,t>>>e|t<<32-e|0),"i32.eq":$t((t,e)=>t===e),"i32.ne":$t((t,e)=>t!==e),"i32.lt_s":$t((t,e)=>t<e),"i32.lt_u":Ht((t,e)=>t<e),"i32.gt_s":$t((t,e)=>t>e),"i32.gt_u":Ht((t,e)=>t>e),"i32.le_s":$t((t,e)=>t<=e),"i32.le_u":Ht((t,e)=>t<=e),"i32.ge_s":$t((t,e)=>t>=e),"i32.ge_u":Ht((t,e)=>t>=e),"i32.eqz":t=>t===0?1:0,"i32.clz":t=>Math.clz32(t),"i32.ctz":t=>t===0?32:31-Math.clz32(t&-t),"i32.popcnt":t=>{let e=0;for(;t;)e+=t&1,t>>>=1;return e},"i32.wrap_i64":t=>Gt(t),"i32.extend8_s":t=>t<<24>>24,"i32.extend16_s":t=>t<<16>>16,"i64.add":(t,e)=>rt(BigInt(t)+BigInt(e)&0xffffffffffffffffn),"i64.sub":(t,e)=>rt(BigInt(t)-BigInt(e)&0xffffffffffffffffn),"i64.mul":(t,e)=>rt(BigInt(t)*BigInt(e)&0xffffffffffffffffn),"i64.div_s":(t,e)=>e!==G&&!(t==="0x8000000000000000"&&e===Kt)?rt(zt(t)/zt(e)&0xffffffffffffffffn):null,"i64.div_u":(t,e)=>e!==G&&!(at(t)>>>31)&&!(at(e)>>>31)?rt(BigInt(t)/BigInt(e)):null,"i64.rem_s":(t,e)=>e!==G?rt(zt(t)%zt(e)&0xffffffffffffffffn):null,"i64.rem_u":(t,e)=>e!==G&&!(at(t)>>>31)&&!(at(e)>>>31)?rt(BigInt(t)%BigInt(e)):null,"i64.and":(t,e)=>rt(BigInt(t)&BigInt(e)&0xffffffffffffffffn),"i64.or":(t,e)=>rt((BigInt(t)|BigInt(e))&0xffffffffffffffffn),"i64.xor":(t,e)=>rt((BigInt(t)^BigInt(e))&0xffffffffffffffffn),"i64.shl":(t,e)=>rt(BigInt(t)<<(BigInt(e)&63n)&0xffffffffffffffffn),"i64.shr_s":(t,e)=>rt(zt(t)>>(BigInt(e)&63n)&0xffffffffffffffffn),"i64.shr_u":(t,e)=>{let r=parseInt(e.slice(10),16)&63,i=at(t),s=parseInt(t.slice(10),16)>>>0,n=r>=32?0:i>>>r,l=r===0?s:r>=32?i>>>r-32:(s>>>r|i<<32-r)>>>0;return"0x"+K(n)+K(l)},"i64.eq":(t,e)=>t===e?1:0,"i64.ne":(t,e)=>t!==e?1:0,"i64.lt_s":Vt((t,e)=>t<e),"i64.lt_u":Yt((t,e)=>t<e),"i64.gt_s":Vt((t,e)=>t>e),"i64.gt_u":Yt((t,e)=>t>e),"i64.le_s":Vt((t,e)=>t<=e),"i64.le_u":Yt((t,e)=>t<=e),"i64.ge_s":Vt((t,e)=>t>=e),"i64.ge_u":Yt((t,e)=>t>=e),"i64.eqz":t=>t===G?1:0,"i64.extend_i32_s":t=>"0x"+K(t>>31)+K(t),"i64.extend_i32_u":t=>"0x00000000"+K(t),"i64.extend8_s":t=>{let e=Gt(t)<<24>>24;return"0x"+K(e>>31)+K(e)},"i64.extend16_s":t=>{let e=Gt(t)<<16>>16;return"0x"+K(e>>31)+K(e)},"i64.extend32_s":t=>{let e=Gt(t);return"0x"+K(e>>31)+K(e)},"f32.add":(t,e)=>Math.fround(t+e),"f32.sub":(t,e)=>Math.fround(t-e),"f32.mul":(t,e)=>Math.fround(t*e),"f32.div":(t,e)=>Math.fround(t/e),"f32.neg":t=>Math.fround(-t),"f32.abs":t=>Math.fround(Math.abs(t)),"f32.sqrt":t=>Math.fround(Math.sqrt(t)),"f32.ceil":t=>Math.fround(Math.ceil(t)),"f32.floor":t=>Math.fround(Math.floor(t)),"f32.trunc":t=>Math.fround(Math.trunc(t)),"f32.nearest":t=>Math.fround(Ye(t)),"f64.add":(t,e)=>t+e,"f64.sub":(t,e)=>t-e,"f64.mul":(t,e)=>t*e,"f64.div":(t,e)=>t/e,"f64.neg":t=>-t,"f64.abs":Math.abs,"f64.sqrt":Math.sqrt,"f64.ceil":Math.ceil,"f64.floor":Math.floor,"f64.trunc":Math.trunc,"f64.nearest":Ye,"i32.reinterpret_f32":fi,"f32.reinterpret_i32":oi,"i64.reinterpret_f64":ni,"f64.reinterpret_i64":li,"f32.convert_i32_s":t=>Math.fround(t|0),"f32.convert_i32_u":t=>Math.fround(t>>>0),"f32.convert_i64_s":t=>Math.fround((at(t)|0)*4294967296+parseInt(t.slice(10),16)),"f32.convert_i64_u":t=>Math.fround(at(t)*4294967296+parseInt(t.slice(10),16)),"f64.convert_i32_s":t=>t|0,"f64.convert_i32_u":t=>t>>>0,"f64.convert_i64_s":t=>(at(t)|0)*4294967296+parseInt(t.slice(10),16),"f64.convert_i64_u":t=>at(t)*4294967296+parseInt(t.slice(10),16),"f32.demote_f64":t=>Math.fround(t),"f64.promote_f32":t=>Math.fround(t)},ci=t=>{let e=t?.indexOf?.("nan");if(e<0||e==null)return null;let r=t.slice(e+4).replaceAll("_",""),s=(t[e+3]===":"&&r!=="canonical"&&r!=="arithmetic"?BigInt(r):0x8000000000000n).toString(16).padStart(16,"0"),n=(parseInt(s.slice(0,8),16)|2146435072|(t[0]==="-"?2147483648:0))>>>0;return"0x"+K(n)+s.slice(8)},ui=(t,e=t?.indexOf?.("nan"))=>{if(e<0||e==null)return null;let r=t.slice(e+4).replaceAll("_",""),s=(t[e+3]===":"&&r!=="canonical"&&r!=="arithmetic"?BigInt(r):0x8000000000000n).toString(16).padStart(16,"0");return kt[1]=(parseInt(s.slice(0,8),16)|2146435072|(t[0]==="-"?2147483648:0))>>>0,kt[0]=parseInt(s.slice(8),16),me[0]},yi=(t,e=t?.indexOf?.("nan"))=>{if(e<0||e==null)return null;let r=t.slice(e+4).replaceAll("_",""),i=t[e+3]===":"&&r!=="canonical"&&r!=="arithmetic"?parseInt(r):4194304;return he[0]=i|2139095040|(t[0]==="-"?2147483648:0)|0,_e[0]},q=t=>{if(!Array.isArray(t)||t.length!==2)return null;let[e,r]=t;if(e==="i32.const")return{type:"i32",value:(typeof r=="string"?parseInt(r.replaceAll("_","")):r)|0};if(e==="i64.const")return{type:"i64",value:gt(r)};if(e==="f32.const"){let i=yi(r);return{type:"f32",value:i!==null?i:Math.fround(Number(r))}}if(e==="f64.const"){let i=ui(r),s=i!==null?i:Number(r);return{type:"f64",value:Number.isNaN(s)?NaN:s}}return null},Ze=(t,e)=>{if(t==="i32")return["i32.const",e|0];if(t==="i64")return["i64.const",typeof e=="number"?e:gt(e)];if(t==="f32"){let r=Math.fround(e);return["f32.const",Number.isNaN(r)?"nan":r]}return t==="f64"?["f64.const",Number.isNaN(e)?"nan":e]:null},pi=t=>H(t,e=>{if(!Array.isArray(e))return;let r=ai[e[0]];if(r){if(e.length===2){if(e[0]==="i64.reinterpret_f64"){let n=e[1];if(Array.isArray(n)&&n.length===2&&n[0]==="f64.const"&&typeof n[1]=="string"){let l=ci(n[1]);if(l)return["i64.const",l]}}if(e[0]==="f64.reinterpret_i64"){let n=q(e[1]);if(n&&n.type==="i64"){let l=n.value.slice(2),f=parseInt(l.slice(0,8),16)>>>0,c=parseInt(l.slice(8),16)>>>0;if((f&2146435072)===2146435072&&((f&1048575)!==0||c!==0))return["f64.const",(f&2147483648?"-":"")+"nan:0x"+(f&1048575).toString(16).padStart(5,"0")+l.slice(8)]}}let i=q(e[1]);if(!i)return;let s=r(i.value);return s==null?void 0:Ze(He(e[0]),s)}if(e.length===3){let i=q(e[1]),s=q(e[2]);if(!i||!s)return;let n=r(i.value,s.value);return n==null?void 0:Ze(He(e[0]),n)}}}),ot=t=>(e,r)=>{let i=q(e),s=q(r);return i?.value===t?r:s?.value===t?e:null},it=t=>(e,r)=>q(r)?.value===t?e:null,gi={"i32.add":ot(0),"i64.add":ot(G),"i32.sub":it(0),"i64.sub":it(G),"i32.mul":ot(1),"i64.mul":ot(ce),"i32.div_s":it(1),"i32.div_u":it(1),"i64.div_s":it(ce),"i64.div_u":it(ce),"i32.and":ot(-1),"i64.and":ot(Kt),"i32.or":ot(0),"i64.or":ot(G),"i32.xor":ot(0),"i64.xor":ot(G),"i32.shl":it(0),"i32.shr_s":it(0),"i32.shr_u":it(0),"i64.shl":it(G),"i64.shr_s":it(G),"i64.shr_u":it(G)},mi=t=>H(t,e=>{if(!Array.isArray(e)||e.length!==3)return;let r=gi[e[0]];if(!r)return;let i=r(e[1],e[2]);if(i!==null)return i}),_i=t=>H(t,e=>{if(!Array.isArray(e)||e.length!==3)return;let[r,i,s]=e;if(r==="i32.mul"){let n=q(s);if(n&&n.value>0&&!(n.value&n.value-1)){let f=Math.log2(n.value);if(Number.isInteger(f))return["i32.shl",i,["i32.const",f]]}let l=q(i);if(l&&l.value>0&&!(l.value&l.value-1)){let f=Math.log2(l.value);if(Number.isInteger(f))return["i32.shl",s,["i32.const",f]]}}if(r==="i64.mul"){let n=q(s),l=n?BigInt(n.value):null;if(l!=null&&l>0n&&(l&l-1n)===0n)return["i64.shl",i,["i64.const",l.toString(2).length-1]];let f=q(i),c=f?BigInt(f.value):null;if(c!=null&&c>0n&&(c&c-1n)===0n)return["i64.shl",s,["i64.const",c.toString(2).length-1]]}if(r==="i32.div_u"){let n=q(s);if(n&&n.value>0&&!(n.value&n.value-1)){let l=Math.log2(n.value);if(Number.isInteger(l))return["i32.shr_u",i,["i32.const",l]]}}if(r==="i64.div_u"){let n=q(s),l=n?BigInt(n.value):null;if(l!=null&&l>0n&&(l&l-1n)===0n)return["i64.shr_u",i,["i64.const",l.toString(2).length-1]]}if(r==="i32.rem_u"){let n=q(s);if(n&&n.value>0&&!(n.value&n.value-1))return["i32.and",i,["i32.const",n.value-1]]}if(r==="i64.rem_u"){let n=q(s),l=n?BigInt(n.value):null;if(l!=null&&l>0n&&(l&l-1n)===0n)return["i64.and",i,["i64.const","0x"+Nt(l-1n)]]}}),hi=t=>H(t,e=>{if(!Array.isArray(e))return;let r=e[0];if(r==="if"){let{condIdx:i,cond:s,thenBranch:n,elseBranch:l}=It(e),f=q(s);if(!f)return;let c=f.value!==0&&f.value!==G?n:l;if(c&&c.length>1){let a=c.slice(1),u=e.slice(1,i).filter(g=>Array.isArray(g)&&(g[0]==="result"||g[0]==="param"));return u.length?["block",...u,...a]:a.length===1?a[0]:["block",...a]}return["nop"]}if(r==="br_if"&&e.length>=3){let i=e[e.length-1],s=q(i);return s?s.value===0||s.value===G?["nop"]:["br",e[1]]:void 0}if(r==="select"&&e.length>=4){let i=e[e.length-1],s=q(i);return s?s.value===0||s.value===G?e[2]:e[1]:void 0}}),xi=t=>{if(Array.isArray(t))for(let e of t)Array.isArray(e)&&e[0]==="func"&&di(e);return t},xe=new Set,di=t=>{let e=new Map,r=new Map,i=new Map,s=new Map,n=o=>{if(!Array.isArray(o)||o.length!==2||o[0]!=="i32.const"&&o[0]!=="i64.const")return null;let y=typeof o[1]=="string"?Number(o[1].replaceAll("_","")):Number(o[1]);return Number.isFinite(y)?y:null},l=o=>Array.isArray(o)&&o[0]==="i32.const"?n(o):null,f=o=>Array.isArray(o)?o[0]==="i64.reinterpret_f64"&&Array.isArray(o[1])&&o[1][0]==="local.get"&&typeof o[1][1]=="string"?o[1][1]:o[0]==="local.get"&&typeof o[1]=="string"?e.get(o[1])??null:null:null,c=o=>{if(!Array.isArray(o))return null;let y=o[0];if(y==="local.get"&&typeof o[1]=="string")return r.get(o[1])??null;if(y==="call"&&o[1]==="$__ptr_type"&&o.length===3)return f(o[2]);let p=m=>Array.isArray(m)&&m[0]==="i64.shr_u"&&n(m[2])===47?f(m[1]):null;if(y==="i32.and"&&o.length===3){let[m,_]=l(o[2])===15?[o[1],null]:l(o[1])===15?[o[2],null]:[null,null];if(m&&Array.isArray(m)&&m[0]==="i32.wrap_i64")return p(m[1])}if(y==="i32.wrap_i64"&&Array.isArray(o[1])&&o[1][0]==="i64.and"){let m=o[1];if(n(m[2])===15)return p(m[1]);if(n(m[1])===15)return p(m[2])}return null},a=o=>{e.delete(o),r.delete(o),i.delete(o),s.delete(o);for(let[y,p]of e)p===o&&e.delete(y);for(let[y,p]of r)p===o&&r.delete(y)},u=new Map,g=o=>{if(!Array.isArray(o))return xe;let y=u.get(o);if(y)return y;y=new Set,(o[0]==="local.set"||o[0]==="local.tee")&&typeof o[1]=="string"&&y.add(o[1]);for(let p=1;p<o.length;p++)for(let m of g(o[p]))y.add(m);return u.set(o,y),y},h=()=>[new Map(i),new Map([...s].map(([o,y])=>[o,new Set(y)])),new Map(e),new Map(r)],x=(o,y)=>{o.clear();for(let[p,m]of y)o.set(p,m)},M=([o,y,p,m])=>{x(i,o),x(s,y),x(e,p),x(r,m)},A=(o,y,p)=>{if(!Array.isArray(o))return p;let m=o[0];if(m==="i32.eqz")return A(o[1],!y,p);if(m==="i32.and"&&y&&o.length===3)return A(o[1],!0,p),A(o[2],!0,p),p;if(m==="i32.or"&&!y&&o.length===3)return A(o[1],!1,p),A(o[2],!1,p),p;if((m==="i32.eq"||m==="i32.ne")&&o.length===3){let d=c(o[1]),$=l(o[2]);return(d==null||$==null)&&(d=c(o[2]),$=l(o[1])),d!=null&&$!=null&&p.push({x:d,k:$,eq:m==="i32.eq"===y}),p}let _=c(o);return _!=null&&p.push({x:_,k:0,eq:!y}),p},w=o=>{for(let{x:y,k:p,eq:m}of o)if(m)i.set(y,p);else{let _=s.get(y);_||s.set(y,_=new Set),_.add(p)}},b=(o,y,p)=>{if(!Array.isArray(o))return;let m=o[0];if(m==="local.set"||m==="local.tee"){Array.isArray(o[2])&&b(o[2],o,2);let d=o[1];if(typeof d!="string")return;a(d);let $=o[2];if(Array.isArray($))if($[0]==="i64.reinterpret_f64"&&Array.isArray($[1])&&$[1][0]==="local.get"&&typeof $[1][1]=="string")e.set(d,$[1][1]);else if($[0]==="local.get"&&typeof $[1]=="string"&&e.has($[1]))e.set(d,e.get($[1]));else{let z=c($);z!=null&&r.set(d,z)}return}if(m==="if"){let{condIdx:d}=It(o);Array.isArray(o[d])&&b(o[d],o,d);let $=o[d],{thenBranch:z,elseBranch:I}=It(o),k=g(o),N=h();if(w(A($,!0,[])),z)for(let v=1;v<z.length;v++)b(z[v],z,v);if(M(N),w(A($,!1,[])),I)for(let v=1;v<I.length;v++)b(I[v],I,v);M(N);for(let v of k)a(v);return}if(m==="loop"){let d=g(o);for(let $ of d)a($);for(let $=1;$<o.length;$++)b(o[$],o,$);for(let $ of d)a($);return}if(m==="block"){for(let d=1;d<o.length;d++)b(o[d],o,d);for(let d of g(o))a(d);return}let _=c(o);if(_!=null&&i.has(_)&&y){y[p]=["i32.const",i.get(_)];return}if((m==="i32.eq"||m==="i32.ne")&&o.length===3){let d=c(o[1]),$=l(o[2]);if((d==null||$==null)&&(d=c(o[2]),$=l(o[1])),d!=null&&$!=null&&s.get(d)?.has($)&&y){y[p]=["i32.const",m==="i32.eq"?0:1];return}}for(let d=1;d<o.length;d++)b(o[d],o,d)};for(let o=1;o<t.length;o++)b(t[o],t,o)},Ke=new Set(["unreachable","return","br","br_table"]),Ai=t=>(R(t,e=>{if(!Array.isArray(e))return;let r=e[0];if((r==="func"||r==="block"||r==="loop")&&Qe(e),r==="if")for(let i=1;i<e.length;i++)Array.isArray(e[i])&&(e[i][0]==="then"||e[i][0]==="else")&&Qe(e[i])}),t),Qe=t=>{let e=!1,r=-1;for(let i=1;i<t.length;i++){let s=t[i];if(Array.isArray(s)){let n=s[0];if(n==="param"||n==="result"||n==="local"||n==="type"||n==="export")continue;e&&r===-1&&(r=i),Ke.has(n)&&(e=!0,r=i+1)}else typeof s=="string"&&(e&&r===-1&&(r=i),Ke.has(s)&&(e=!0,r=i+1))}r>0&&r<t.length&&t.splice(r)},bi=t=>(R(t,e=>{if(!Array.isArray(e)||e[0]!=="func")return;let r=[],i=new Map,s=new Set;for(let n=1;n<e.length;n++){let l=e[n];Array.isArray(l)&&(l[0]==="local"&&(r.push({node:l,idx:n}),typeof l[1]=="string"&&l[1][0]==="$"&&i.set(l[1],l[2])),l[0]==="param"&&typeof l[1]=="string"&&l[1][0]==="$"&&(i.set(l[1],l[2]),s.add(l[1])))}R(e,n=>{if(!Array.isArray(n))return;let l=n[0];if(l==="local.get"||l==="local.set"||l==="local.tee"){let f=n[1];typeof f=="string"&&s.add(f)}});for(let n=r.length-1;n>=0;n--){let{idx:l,node:f}=r[n],c=typeof f[1]=="string"&&f[1][0]==="$"?f[1]:null;c&&!s.has(c)&&e.splice(l,1)}}),t),sr=new Set(["call","call_indirect","return_call","return_call_indirect","table.set","table.grow","table.fill","table.copy","table.init","struct.set","struct.new","array.set","array.new","array.new_fixed","array.new_data","array.new_elem","array.init_data","array.init_elem","ref.i31","global.set","local.set","local.tee","unreachable","return","br","br_if","br_table","br_on_null","br_on_non_null","br_on_cast","br_on_cast_fail","throw","rethrow","throw_ref","try_table","data.drop","elem.drop"]),nr=[".store","memory.",".atomic."],D=t=>{if(!Array.isArray(t))return!0;let e=t[0];if(typeof e!="string"||sr.has(e))return!1;for(let r of nr)if(e.includes(r))return!1;for(let r=1;r<t.length;r++)if(Array.isArray(t[r])&&!D(t[r]))return!1;return!0},wi=new Set(["if","then","else","block","loop","try"]),$i=t=>typeof t=="string"&&!sr.has(t)&&!wi.has(t)&&!nr.some(e=>t.includes(e)),lr=t=>{if(!Array.isArray(t)||D(t))return[];let e=t[0];if(e==="local.tee"&&t.length===3)return[["local.set",t[1],t[2]]];if($i(e)){let r=[];for(let i=1;i<t.length;i++)r.push(...lr(t[i]));return r}return[["drop",t]]},vi=t=>{let e=new Map,r=i=>(e.has(i)||e.set(i,{gets:0,sets:0,tees:0}),e.get(i));return R(t,i=>{!Array.isArray(i)||i.length<2||typeof i[1]!="string"||(i[0]==="local.get"?r(i[1]).gets++:i[0]==="local.set"?r(i[1]).sets++:i[0]==="local.tee"&&r(i[1]).tees++)}),e},Ii=t=>{let e=q(t);if(!e)return!1;if(e.type==="i32"){let r=e.value|0;return r>=-64&&r<=63}if(e.type==="i64"){let r=BigInt(e.value);return r<=63n||r>=0xffffffffffffffc0n}return!1},ki=(t,e)=>Array.isArray(t)&&t[0]==="local.get"&&t.length===2&&typeof t[1]=="string"&&t[1]!==e,fr=t=>t.pure&&t.singleUse||Ii(t.val)||t.copy,Xt=(t,e)=>{for(let[r,i]of t){let s=!1;R(i.val,n=>{Array.isArray(n)&&(n[0]==="local.get"||n[0]==="local.tee")&&n[1]===e&&(s=!0)}),s&&t.delete(r)}},ue=(t,e)=>{for(let[r,i]of t){let s=!1;R(i.val,n=>{Array.isArray(n)&&n[0]==="global.get"&&n[1]===e&&(s=!0)}),s&&t.delete(r)}},or=t=>{if(!Array.isArray(t))return!1;let e=t[0];if(typeof e=="string"&&(e.includes(".load")||e==="memory.copy"||e==="memory.size"))return!0;for(let r=1;r<t.length;r++)if(or(t[r]))return!0;return!1},ar=t=>{if(!Array.isArray(t))return!1;let e=t[0];if(typeof e=="string"&&(e==="global.get"||e==="table.get"||e==="table.size"||e==="call"||e==="call_indirect"||e==="return_call"||e==="return_call_indirect"||e.includes(".load")||e==="memory.copy"||e==="memory.size"))return!0;for(let r=1;r<t.length;r++)if(ar(t[r]))return!0;return!1},ye=t=>{if(!Array.isArray(t))return!1;let e=t[0];if(typeof e=="string"&&(e.endsWith(".store")||e==="memory.copy"||e==="memory.fill"||e==="memory.init"||e.includes(".atomic.")&&!e.endsWith(".load")))return!0;for(let r=1;r<t.length;r++)if(ye(t[r]))return!0;return!1},pe=(t,e)=>{if(!Array.isArray(t))return t;let r=t[0];if(r==="local.get"&&t.length===2){let s=typeof t[1]=="string"&&e.get(t[1]);return s&&fr(s)?Q(s.val):t}let i=e;if(_t(r)){let s=null;R(t,n=>{Array.isArray(n)&&(n[0]==="local.set"||n[0]==="local.tee")&&typeof n[1]=="string"&&e.has(n[1])&&(s||(s=new Map(e)),s.delete(n[1]))}),s&&(i=s)}for(let s=1;s<t.length;s++){let n=pe(t[s],i);n!==t[s]&&(t[s]=n),s+1<t.length&&Array.isArray(t[s])&&R(t[s],l=>{Array.isArray(l)&&((l[0]==="local.set"||l[0]==="local.tee")&&typeof l[1]=="string"?(i===e&&(i=new Map(e)),i.delete(l[1]),Xt(i,l[1])):l[0]==="global.set"&&typeof l[1]=="string"&&(i===e&&(i=new Map(e)),ue(i,l[1])))})}return t},Si=(t,e,r)=>{let i=!1,s=l=>r.get(l)||{gets:0,sets:0,tees:0},n=new Map;for(let l=1;l<t.length;l++){let f=t[l];if(!Array.isArray(f))continue;let c=f[0];if(!(c==="param"||c==="result"||c==="local"||c==="type"||c==="export")){if((c==="local.set"||c==="local.tee")&&f.length===3&&typeof f[1]=="string"){let a=pe(f[2],n);a!==f[2]&&(f[2]=a,i=!0),R(f[2],g=>{Array.isArray(g)&&((g[0]==="local.set"||g[0]==="local.tee")&&typeof g[1]=="string"?(n.delete(g[1]),Xt(n,g[1])):g[0]==="global.set"&&typeof g[1]=="string"&&ue(n,g[1]))});let u=s(f[1]);if(Xt(n,f[1]),ye(f[2]))for(let[g,h]of n)h.readsMem&&n.delete(g);n.set(f[1],{val:f[2],pure:D(f[2]),readsMem:or(f[2]),singleUse:u.gets<=1&&u.sets<=1&&u.tees===0,copy:ki(f[2],f[1])});continue}if(_t(c)&&n.clear(),c==="call"||c==="call_indirect"||c==="return_call"||c==="return_call_indirect")for(let[a,u]of n)ar(u.val)&&n.delete(a);if(c==="local.get"&&f.length===2&&typeof f[1]=="string"){let a=n.get(f[1]);if(a&&fr(a)){let u=Q(a.val);f.length=0,f.push(...Array.isArray(u)?u:[u]),i=!0;continue}}if(c!=="block"&&c!=="loop"&&c!=="if"){let a=Q(f);if(pe(f,n),nt(a,f)||(i=!0),R(f,u=>{Array.isArray(u)&&((u[0]==="local.set"||u[0]==="local.tee")&&typeof u[1]=="string"?(n.delete(u[1]),Xt(n,u[1])):u[0]==="global.set"&&typeof u[1]=="string"&&ue(n,u[1]))}),ye(f))for(let[u,g]of n)g.readsMem&&n.delete(u)}}}return i},Mi=(t,e,r)=>{let i=!1;for(let s=1;s<t.length-1;s++){let n=t[s],l=t[s+1];if(!Array.isArray(n)||n[0]!=="local.set"||n.length!==3||!Array.isArray(l)||l[0]!=="local.get"||l.length!==2)continue;let f=n[1];if(l[1]!==f||e.has(f))continue;let c=r.get(f)||{gets:0,sets:0,tees:0};if(c.sets!==1||c.gets!==1||c.tees!==0)continue;let a=Q(n[2]);t.splice(s,2,...Array.isArray(a)?[a]:[a]),i=!0,s--}return i},Bi=(t,e,r)=>{let i=!1;for(let s=1;s<t.length-1;s++){let n=t[s],l=t[s+1];if(!Array.isArray(n)||n[0]!=="local.set"||n.length!==3||!Array.isArray(l)||l[0]!=="local.get"||l.length!==2)continue;let f=n[1];if(l[1]!==f||e.has(f))continue;let c=r.get(f)||{gets:0,sets:0,tees:0};c.sets+c.gets+c.tees<=2||(t.splice(s,2,["local.tee",f,Q(n[2])]),i=!0)}return i},zi=(t,e,r)=>{let i=!1,s=n=>r.get(n)||{gets:0,sets:0,tees:0};for(let n=t.length-1;n>=1;n--){let l=t[n];if(!Array.isArray(l))continue;let f=typeof l[1]=="string"?l[1]:null;if(!f||e.has(f))continue;let c=s(f);l[0]==="local.set"&&c.gets===0&&c.tees===0?l.length===3?D(l[2])&&(t.splice(n,1),i=!0):l.length===2&&(t[n]=["drop"],i=!0):l[0]==="local"&&f[0]==="$"&&c.gets===0&&c.sets===0&&c.tees===0&&(t.splice(n,1),i=!0)}return i},Ni=(t,e)=>{let r=!1;for(let i=1;i<t.length-1;i++){let s=t[i],n=t[i+1];if(!Array.isArray(s)||s[0]!=="local.set"||s.length!==3||!Array.isArray(n)||n[0]!=="local.set"&&n[0]!=="local.tee"||n.length!==3||n[1]!==s[1]||e.has(s[1])||!D(s[2]))continue;let l=!1;R(n[2],f=>{Array.isArray(f)&&(f[0]==="local.get"||f[0]==="local.tee")&&f[1]===s[1]&&(l=!0)}),!l&&(t.splice(i,1),r=!0,i--)}return r},de=t=>Array.isArray(t)&&(t[0]==="func"||t[0]==="block"||t[0]==="loop"||t[0]==="then"||t[0]==="else"),_t=t=>t==="block"||t==="loop"||t==="if",ge=t=>(R(t,e=>{if(!Array.isArray(e)||e[0]!=="func")return;let r=new Set;for(let s of e)Array.isArray(s)&&s[0]==="param"&&typeof s[1]=="string"&&r.add(s[1]);let i=[];H(e,s=>{de(s)&&i.push(s)});for(let s=0;s<ri;s++){let n=vi(e),l=!1;for(let f of i)Si(f,r,n)&&(l=!0),Mi(f,r,n)&&(l=!0),Bi(f,r,n)&&(l=!0),zi(f,r,n)&&(l=!0),Ni(f,r)&&(l=!0);if(!l)break}}),t),cr=0,Ti=new Set(["export","type","param","result","local"]),vt=t=>{let e=2;for(;e<t.length&&(typeof t[e]=="string"||Array.isArray(t[e])&&Ti.has(t[e][0]));)e++;return e},Ae=t=>t==="br"||t==="br_if"||t==="br_table",be=t=>{if(!Array.isArray(t))return!1;let e=t[0];if(e==="return_call"||e==="return_call_indirect"||e==="return_call_ref"||e==="try"||e==="try_table"||e==="delegate"||e==="rethrow")return!0;if(Ae(e)){for(let r=1;r<t.length;r++)if(typeof t[r]=="number"||typeof t[r]=="string"&&/^\d+$/.test(t[r]))return!0}for(let r=1;r<t.length;r++)if(be(t[r]))return!0;return!1},we=(t,e)=>{if(!Array.isArray(t))return!1;if((t[0]==="call"||t[0]==="return_call")&&t[1]===e)return!0;for(let r=1;r<t.length;r++)if(we(t[r],e))return!0;return!1},$e=t=>t==="i32"?["i32.const",0]:t==="i64"?["i64.const",0]:t==="f32"?["f32.const",0]:t==="f64"?["f64.const",0]:t==="v128"?["v128.const","i64x2","0","0"]:null,ur=(t,e)=>{let r=!1,i=!1,s=0,n=l=>{if(r||!Array.isArray(l))return;let f=l[0],c=f==="local.set"||f==="local.tee";if((c||f==="local.get")&&l[1]===e){if(c)for(let u=2;u<l.length&&!r;u++)n(l[u]);if(r)return;r=!0,(f==="local.get"||s>0)&&(i=!0);return}let a=f==="if";for(let u=1;u<l.length&&!r;u++){let g=l[u],h=a&&Array.isArray(g)&&(g[0]==="then"||g[0]==="else");h&&s++,n(g),h&&s--}};for(let l of t){if(r)break;n(l)}return r?i:!1},ve=(t,e)=>{if(!Array.isArray(t))return;let r=t[0];if(r==="export"&&Array.isArray(t[2])&&t[2][0]==="func"&&typeof t[2][1]=="string")e.add(t[2][1]);else if(r==="start"&&typeof t[1]=="string")e.add(t[1]);else if(r==="ref.func"&&typeof t[1]=="string")e.add(t[1]);else if(r==="elem")for(let i of t)typeof i=="string"&&i[0]==="$"&&e.add(i);for(let i of t)ve(i,e)},Ei=t=>{let e=new Set;for(let r of t)(!Array.isArray(r)||r[0]!=="func")&&ve(r,e);return e},qi=t=>{let e=[],r=[],i=null,s=!0,n=0;for(let l=2;l<t.length;l++){let f=t[l];if(typeof f!="string"){if(!Array.isArray(f)){s=!1;break}if(f[0]==="param"){if(typeof f[1]!="string"||f[1][0]!=="$"){s=!1;break}e.push({name:f[1],type:f[2]})}else if(f[0]==="local"){if(typeof f[1]!="string"||f[1][0]!=="$"||!$e(f[2])){s=!1;break}r.push({name:f[1],type:f[2]})}else if(f[0]==="result")n+=f.length-1,f.length>1&&(i=f[1]);else if(f[0]==="export"){s=!1;break}else{if(f[0]==="type")continue;break}}}return n>1&&(s=!1),s?{params:e,locals:r,inlResult:i}:null},Oi=t=>{let e=0,r=i=>{if(Array.isArray(i)){e++;for(let s=1;s<i.length;s++)r(i[s])}};for(let i=vt(t);i<t.length;i++)r(t[i]);return e},Fi=(t,e,r,i,s)=>{let n=++cr,l=`$__inl${n}`,f=new Map;for(let w of t)f.set(w.name,`$__inl${n}_${w.name.slice(1)}`);for(let w of e)f.set(w.name,`$__inl${n}_${w.name.slice(1)}`);let c=new Map,a=w=>{if(Array.isArray(w)){_t(w[0])&&typeof w[1]=="string"&&w[1][0]==="$"&&!c.has(w[1])&&c.set(w[1],`$__inl${n}L_${w[1].slice(1)}`);for(let b=1;b<w.length;b++)a(w[b])}};for(let w of i)a(w);let u=w=>{if(!Array.isArray(w))return w;let b=w[0];return(b==="local.get"||b==="local.set"||b==="local.tee")&&typeof w[1]=="string"&&f.has(w[1])?[b,f.get(w[1]),...w.slice(2).map(u)]:b==="return"?["br",l,...w.slice(1).map(u)]:_t(b)&&typeof w[1]=="string"&&c.has(w[1])?[b,c.get(w[1]),...w.slice(2).map(u)]:Ae(b)?[b,...w.slice(1).map(o=>typeof o=="string"&&c.has(o)?c.get(o):u(o))]:w.map((o,y)=>y===0?o:u(o))},g=t.map((w,b)=>["local.set",f.get(w.name),s[b]]),h=e.filter(w=>ur(i,w.name)).map(w=>["local.set",f.get(w.name),$e(w.type)]),x=i.map(u),M=r?["block",l,["result",r],...g,...h,...x]:["block",l,...g,...h,...x],A=[...t,...e].map(w=>["local",f.get(w.name),w.type]);return{block:M,decls:A}},Li=90,Ci=(t,e)=>e==="v128"&&t.length>0&&t.every(r=>r.type==="v128"),yr=(t,{simdOnly:e=!1,pin:r=xe}={})=>{if(!Array.isArray(t)||t[0]!=="module")return t;let i=new Set;for(let s=0;s<er;s++){let n=t.filter(p=>Array.isArray(p)&&p[0]==="func"),l=new Map;for(let p of n)typeof p[1]=="string"&&l.set(p[1],p);let f=new Map,c=new Set,a=p=>{if(!Array.isArray(p))return;let m=p[0];m==="call"&&typeof p[1]=="string"?f.set(p[1],(f.get(p[1])||0)+1):m==="return_call"&&typeof p[1]=="string"&&c.add(p[1]);for(let _=1;_<p.length;_++)a(p[_])};a(t);let u=new Set;for(let p of t)(!Array.isArray(p)||p[0]!=="func")&&ve(p,u);let g=null,h=null;for(let[p,m]of l){if(i.has(p)||u.has(p)||c.has(p)||r.has(p)||!(f.get(p)>=1)||Oi(m)>Li||we(m,p))continue;let _=qi(m);if(!_||e&&!Ci(_.params,_.inlResult))continue;let d=!1;for(let $=vt(m);$<m.length;$++)if(be(m[$])){d=!0;break}if(!d){g=p,h=_;break}}if(!g)break;let x=l.get(g),{params:M,locals:A,inlResult:w}=h,b=x.slice(vt(x)),o=f.get(g)||0,y=0;for(let p of n){if(p===x)continue;let m=[];for(let _=vt(p);_<p.length;_++)p[_]=H(p[_],d=>{if(!Array.isArray(d)||d[0]!=="call"||d[1]!==g)return;let $=d.slice(2);if($.length!==M.length)return;let{block:z,decls:I}=Fi(M,A,w,b,$);return m.push(...I),y++,z});m.length&&p.splice(vt(p),0,...m)}if(y===o){let p=t.indexOf(x);p>=0&&t.splice(p,1)}else i.add(g)}return t},pr=t=>{if(!Array.isArray(t)||t[0]!=="module")return t;let e=new Map,r=new Map,i=new Map,s=[],n=!1;if(R(t,o=>{Array.isArray(o)&&typeof o[0]=="string"&&(o[0]==="table.set"||o[0]==="table.grow"||o[0]==="table.init"||o[0]==="table.copy"||o[0]==="table.fill")&&(n=!0)}),n)return t;for(let o of t.slice(1))if(Array.isArray(o))if(o[0]==="elem"){let y=o[1];if(!Array.isArray(y)||y[0]!=="i32.const")return t;let p=Number(y[1]);for(let m=2;m<o.length;m++)typeof o[m]=="string"&&o[m][0]==="$"&&e.set(p++,o[m])}else o[0]==="type"&&typeof o[1]=="string"?r.set(o[1],o[2]):o[0]==="func"&&(s.push(o),typeof o[1]=="string"&&i.set(o[1],o));if(!e.size)return t;let l=new Map,f=(o,y)=>Array.isArray(o)&&o[0]==="i64.const"&&gt(o[1])===y,c="0x0000000000007fff",a="0x0000000000000020",u=(o,y)=>Array.isArray(o)?o[0]==="i64.const"?(y.push(o),!0):o[0]==="f64.const"&&typeof o[1]=="string"&&o[1].startsWith("nan:")?(y.push(["i64.const",gt(o[1].slice(4))]),!0):o[0]==="f64.reinterpret_i64"&&o.length===2?u(o[1],y):o[0]==="select"&&o.length===4?u(o[1],y)&&u(o[2],y):!1:!1,g=new Map;R(t,o=>{!Array.isArray(o)||o[0]!=="global.set"||typeof o[1]!="string"||(g.has(o[1])||g.set(o[1],[]),g.get(o[1]).push(o[2]))});let h=(o,y,p)=>{if(!Array.isArray(o))return!1;if(o[0]==="i64.const")return y.push(o),!0;if(o[0]==="f64.const"&&typeof o[1]=="string"&&o[1].startsWith("nan:"))return y.push(["i64.const",gt(o[1].slice(4))]),!0;if((o[0]==="f64.reinterpret_i64"||o[0]==="i64.reinterpret_f64")&&o.length===2)return h(o[1],y,p);if(o[0]==="global.get"&&typeof o[1]=="string")return p.push(o[1]),!0;if(o[0]==="local.get"||o[0]==="local.tee")return o[0]==="local.tee"&&o.length===3?h(o[2],y,p):!1;if(o[0]==="select"&&o.length===4)return h(o[1],y,p)&&h(o[2],y,p);if(o[0]==="if"){let m=!0,_=!1;for(let d=1;d<o.length;d++){let $=o[d];Array.isArray($)&&($[0]==="then"||$[0]==="else")&&(_=!0,($.length!==2||!h($[1],y,p))&&(m=!1))}return m&&_}return!1},x=new Map;for(let[o,y]of g){let p=[],m=[],_=!0;for(let d of y)if(!h(d,p,m)){_=!1;break}x.set(o,_?{consts:p,reads:m}:null)}let M=!0,A=new Map;for(;M;){M=!1;for(let[o,y]of x){if(A.get(o)===null)continue;if(y===null){A.get(o)!==null&&(A.set(o,null),M=!0);continue}let p=A.get(o)||new Map,m=p.size,_=!1;for(let d of y.consts)p.set(gt(d[1]),d);for(let d of y.reads){if(x.get(d)===null||A.get(d)===null){_=!0;break}let $=A.get(d);if($)for(let[z,I]of $)p.set(z,I)}if(_){A.set(o,null),M=!0;continue}(!A.has(o)||p.size!==m)&&(A.set(o,p),M=!0)}}for(let[o,y]of A)l.set(o,y);let w=o=>{if(!Array.isArray(o)||o[0]!=="i32.wrap_i64")return null;let y=o[1];if(!Array.isArray(y)||y[0]!=="i64.and")return null;let p=y[1],m=y[2];if(f(m,c)||(p=y[2],m=y[1]),!f(m,c)||!Array.isArray(p)||p[0]!=="i64.shr_u"||!f(p[2],a))return null;let _=p[1];if(!Array.isArray(_)||_[0]!=="i64.reinterpret_f64")return null;let d=_[1];return Array.isArray(d)&&d[0]==="local.get"&&typeof d[1]=="string"?{local:d[1]}:Array.isArray(d)&&d[0]==="global.get"&&typeof d[1]=="string"?{global:d[1]}:null},b=o=>{let y=[],p=[];for(let m of o)if(Array.isArray(m))if(m[0]==="param")for(let _ of m.slice(1))typeof _=="string"&&_[0]!=="$"&&y.push(_);else m[0]==="result"&&p.push(...m.slice(1));return y.join(",")+"->"+p.join(",")};for(let o of s){let y=new Map;for(let p of o)Array.isArray(p)&&p[0]==="param"&&typeof p[1]=="string"&&y.set(p[1],null);R(o,p=>{if(!Array.isArray(p)||p[0]!=="local.set"&&p[0]!=="local.tee"||typeof p[1]!="string"||y.get(p[1])===null)return;let m=[];if(u(p[2],m)){let _=y.get(p[1])||new Map;for(let d of m)_.set(gt(d[1]),d);y.set(p[1],_)}else if(Array.isArray(p[2])&&p[2][0]==="global.get"&&typeof p[2][1]=="string"&&l.get(p[2][1])){let _=l.get(p[2][1]),d=y.get(p[1])||new Map;for(let[$,z]of _)d.set($,z);y.set(p[1],d)}else y.set(p[1],null)}),H(o,(p,m)=>{if(!Array.isArray(p)||p[0]!=="call_indirect"||m&&m[0]==="else")return;let _=Array.isArray(p[1])&&p[1][0]==="type"?p[1]:null;if(!_)return;let d=r.get(_[1]),$=Array.isArray(d)?b(d.slice(1)):null;if($==null)return;let z=[];for(let O of d.slice(1))Array.isArray(O)&&O[0]==="result"&&z.push(...O.slice(1));let I=p.slice(2,-1),k=p[p.length-1],N=O=>{let U=i.get(O);if(!U)return!1;let ct=U.find(St=>Array.isArray(St)&&St[0]==="type");return ct?ct[1]===_[1]||r.get(ct[1])&&b(r.get(ct[1]).slice(1))===$:b(U.slice(2))===$};if(Array.isArray(k)&&k[0]==="i32.const"){let O=e.get(Number(k[1]));return O&&N(O)?["call",O,...I]:void 0}let v=w(k);if(!v)return;let T=v.local!=null?y.get(v.local):l.get(v.global);if(!T||T.size===0||T.size>4)return;let C=[];for(let O of T.values()){let U=e.get(at(gt(O[1]))&32767);if(!U||!N(U))return;C.push([O,U])}let st=v.local!=null?["local.get",v.local]:["global.get",v.global],W=p;for(let O=C.length-1;O>=0;O--){let[U,ct]=C[O];W=["if",...z.length?[["result",...z]]:[],["i64.eq",["i64.reinterpret_f64",Q(st)],Q(U)],["then",["call",ct,...I.map(Q)]],["else",W]]}return W})}return t},Ri=(t,{pin:e=xe}={})=>{if(!Array.isArray(t)||t[0]!=="module")return t;let r=vt,i=we,s=be,n=Ae,l=$e,f=ur;for(let c=0;c<er;c++){let a=t.filter(v=>Array.isArray(v)&&v[0]==="func"),u=new Map;for(let v of a)typeof v[1]=="string"&&u.set(v[1],v);let g=new Map,h=new Set,x=v=>{if(!Array.isArray(v))return;let T=v[0];T==="call"&&typeof v[1]=="string"?g.set(v[1],(g.get(v[1])||0)+1):T==="return_call"&&typeof v[1]=="string"&&h.add(v[1]);for(let C=1;C<v.length;C++)x(v[C])};x(t);let M=Ei(t),A=null;for(let[v,T]of u){if(M.has(v)||h.has(v)||g.get(v)!==1||e.has(v)||i(T,v))continue;let C=!0,st=0;for(let O=2;O<T.length;O++){let U=T[O];if(typeof U!="string"){if(!Array.isArray(U)){C=!1;break}if(U[0]==="param"||U[0]==="local"){if(typeof U[1]!="string"||U[1][0]!=="$"){C=!1;break}if(U[0]==="local"&&!l(U[2])){C=!1;break}}else if(U[0]==="result")st+=U.length-1;else if(U[0]==="export"){C=!1;break}else{if(U[0]==="type")continue;break}}}if(!C||st>1)continue;let W=!1;for(let O=r(T);O<T.length;O++)if(s(T[O])){W=!0;break}if(!W){A=v;break}}if(!A)break;let w=u.get(A),b=[],o=[],y=null;for(let v=2;v<w.length;v++){let T=w[v];if(!(typeof T=="string"||!Array.isArray(T)))if(T[0]==="param")b.push({name:T[1],type:T[2]});else if(T[0]==="result")T.length>1&&(y=T[1]);else if(T[0]==="local")o.push({name:T[1],type:T[2]});else{if(T[0]==="export"||T[0]==="type")continue;break}}let p=w.slice(r(w)),m=++cr,_=`$__inl${m}`,d=new Map;for(let v of b)d.set(v.name,`$__inl${m}_${v.name.slice(1)}`);for(let v of o)d.set(v.name,`$__inl${m}_${v.name.slice(1)}`);let $=new Map,z=v=>{if(Array.isArray(v)){_t(v[0])&&typeof v[1]=="string"&&v[1][0]==="$"&&!$.has(v[1])&&$.set(v[1],`$__inl${m}L_${v[1].slice(1)}`);for(let T=1;T<v.length;T++)z(v[T])}};for(let v of p)z(v);let I=v=>{if(!Array.isArray(v))return v;let T=v[0];return(T==="local.get"||T==="local.set"||T==="local.tee")&&typeof v[1]=="string"&&d.has(v[1])?[T,d.get(v[1]),...v.slice(2).map(I)]:T==="return"?["br",_,...v.slice(1).map(I)]:_t(T)&&typeof v[1]=="string"&&$.has(v[1])?[T,$.get(v[1]),...v.slice(2).map(I)]:n(T)?[T,...v.slice(1).map(C=>typeof C=="string"&&$.has(C)?$.get(C):I(C))]:v.map((C,st)=>st===0?C:I(C))},k=!1;for(let v of a){if(v===w||k)continue;let T=r(v);for(let C=T;C<v.length;C++){let st=H(v[C],W=>{if(k||!Array.isArray(W)||W[0]!=="call"||W[1]!==A)return;let O=W.slice(2);if(O.length!==b.length)return;let U=b.map((ht,wr)=>["local.set",d.get(ht.name),O[wr]]),ct=o.filter(ht=>f(p,ht.name)).map(ht=>["local.set",d.get(ht.name),l(ht.type)]),St=p.map(I);return k=!0,y?["block",_,["result",y],...U,...ct,...St]:["block",_,...U,...ct,...St]});if(st!==v[C]&&(v[C]=st),k){let W=[...b,...o].map(O=>["local",d.get(O.name),O.type]);W.length&&v.splice(r(v),0,...W);break}}if(k)break}if(!k)break;let N=t.indexOf(w);N>=0&&t.splice(N,1)}return t},Zt=(t,e)=>{let r=!1,i=(s,n)=>{if(r||!Array.isArray(s))return;let l=s[0],f=n;if((l==="block"||l==="loop")&&typeof s[1]=="string"&&s[1]===e&&(f=!0),!n){if(l==="br"||l==="br_if"||l==="br_on_null"||l==="br_on_non_null"||l==="br_on_cast"||l==="br_on_cast_fail"){if(s[1]===e){r=!0;return}}else if(l==="br_table"){for(let c=1;c<s.length&&typeof s[c]=="string";c++)if(s[c]===e){r=!0;return}}else if(l==="catch"||l==="catch_ref"){if(s[2]===e){r=!0;return}}else if((l==="catch_all"||l==="catch_all_ref")&&s[1]===e){r=!0;return}}for(let c=1;c<s.length;c++)i(s[c],f)};for(let s of t)i(s,!1);return r},gr=t=>(H(t,e=>{if(!Array.isArray(e)||e[0]!=="block")return;let r=1,i=null;typeof e[1]=="string"&&e[1][0]==="$"&&(i=e[1],r=2);let s=!1;for(;r<e.length;){let f=e[r];if(Array.isArray(f)&&(f[0]==="param"||f[0]==="type")){r++;continue}if(Array.isArray(f)&&f[0]==="result"){s=!0,r++;continue}break}let n=e.slice(r);if(!s||n.length!==1)return;let l=n[0];if(Array.isArray(l)&&!(i&&Zt(n,i))){e.length=0;for(let f of l)e.push(f)}}),R(t,e=>{if(!de(e))return;let r=1;for(;r<e.length;){let i=e[r];if(!Array.isArray(i)){r++;continue}{let f=i[0],c=f==="local.set"||f==="global.set"?2:f==="drop"?1:-1;if(c>=0&&i.length===c+1){let a=i[c];if(Array.isArray(a)&&a[0]==="block"){let u=1,g=null;typeof a[1]=="string"&&a[1][0]==="$"&&(g=a[1],u=2);let h=!1;for(;u<a.length;){let M=a[u];if(Array.isArray(M)&&(M[0]==="param"||M[0]==="type")){u++;continue}if(Array.isArray(M)&&M[0]==="result"){h=!0,u++;continue}break}let x=h?a.slice(u):null;if(x&&x.length>=2&&!(g&&Zt(x,g))){let M=x[x.length-1],A=x.slice(0,-1);i[c]=M,e.splice(r,1,...A,i);continue}}}}if(i[0]!=="block"){r++;continue}let s=1,n=null;for(typeof i[1]=="string"&&i[1][0]==="$"&&(n=i[1],s=2);s<i.length;){let f=i[s];if(Array.isArray(f)&&(f[0]==="param"||f[0]==="result"||f[0]==="type")){s++;continue}break}let l=i.slice(s);if(n&&Zt(l,n)){r++;continue}e.splice(r,1,...l),r+=l.length}}),t),mr=t=>(R(t,e=>{if(!Array.isArray(e)||e[0]!=="func")return;let r=new Map;for(let h of e)Array.isArray(h)&&h[0]==="local"&&typeof h[1]=="string"&&h[1][0]==="$"&&typeof h[2]=="string"&&r.set(h[1],h[2]);if(r.size<2)return;let i=new Map,s=[],n=0,l=!1,f=0,c=h=>{if(l||!Array.isArray(h))return;let x=h[0],M=x==="loop";M&&s.push({start:n,end:n});let A=x==="local.set"||x==="local.tee";if(A||x==="local.get"){let w=h[1];if(typeof w!="string"||w[0]!=="$"){l=!0;return}if(A)for(let o=2;o<h.length;o++)c(h[o]);let b=n++;if(r.has(w)){let o=i.get(w);o||(o={start:b,end:b,firstOp:x,firstCond:f>0,loops:new Set},i.set(w,o)),b>o.end&&(o.end=b);for(let y of s)o.loops.add(y)}}else{n++;let w=x==="if";for(let b=1;b<h.length;b++){let o=h[b],y=w&&Array.isArray(o)&&(o[0]==="then"||o[0]==="else");y&&f++,c(o),y&&f--}}if(M){let w=s.pop();w.end=n}};if(c(e),l)return;for(let h of i.values())for(let x of h.loops)x.start<h.start&&(h.start=x.start),x.end>h.end&&(h.end=x.end);let a=[...i.entries()].sort((h,x)=>h[1].start-x[1].start),u=new Map,g=[];for(let[h,x]of a){let M=x.firstOp==="local.get"||x.firstCond,A=r.get(h),w=M?null:g.find(b=>b.type===A&&b.end<x.start);w?(u.set(h,w.primary),x.end>w.end&&(w.end=x.end)):g.push({primary:h,type:A,end:x.end})}u.size!==0&&R(e,h=>{Array.isArray(h)&&(h[0]==="local.get"||h[0]==="local.set"||h[0]==="local.tee")&&u.has(h[1])&&(h[1]=u.get(h[1]))})}),t),_r=t=>H(t,e=>{if(!Array.isArray(e))return;let r=e[0];if(r==="nop")return["nop"];if(r==="drop"&&e.length===2){let i=lr(e[1]);return i.length===0?["nop"]:i.length===1?i[0]:["block",...i]}if(r==="select"&&e.length>=4&&nt(e[1],e[2])&&D(e[3]))return e[1];if(r==="if"){let{cond:i,thenBranch:s,elseBranch:n}=It(e),l=!s||s.length<=1,f=!n||n.length<=1;if(l&&f)return D(i)?["nop"]:["drop",i];if(n&&f&&!l)return e.filter(c=>c!==n)}if(de(e)){let i=[r];for(let s=1;s<e.length;s++){let n=e[s];if(n==="nop"||Array.isArray(n)&&n[0]==="nop")continue;let l=e[s+1],f=l==="drop"||Array.isArray(l)&&l[0]==="drop"&&l.length===1;if(Array.isArray(n)&&f&&D(n)){s++;continue}if(Array.isArray(n)&&f&&n[0]==="local.tee"&&n.length===3){i.push(["local.set",n[1],n[2]]),s++;continue}i.push(n)}if(i.length!==e.length)return i}}),P=t=>(e,r)=>nt(e,r)&&D(e)?t:null,Ui={"i32.sub":P(["i32.const",0]),"i64.sub":P(["i64.const",0]),"i32.xor":P(["i32.const",0]),"i64.xor":P(["i64.const",0]),"i32.eq":P(["i32.const",1]),"i64.eq":P(["i32.const",1]),"i32.ne":P(["i32.const",0]),"i64.ne":P(["i32.const",0]),"i32.lt_s":P(["i32.const",0]),"i32.lt_u":P(["i32.const",0]),"i32.gt_s":P(["i32.const",0]),"i32.gt_u":P(["i32.const",0]),"i32.le_s":P(["i32.const",1]),"i32.le_u":P(["i32.const",1]),"i32.ge_s":P(["i32.const",1]),"i32.ge_u":P(["i32.const",1]),"i64.lt_s":P(["i32.const",0]),"i64.lt_u":P(["i32.const",0]),"i64.gt_s":P(["i32.const",0]),"i64.gt_u":P(["i32.const",0]),"i64.le_s":P(["i32.const",1]),"i64.le_u":P(["i32.const",1]),"i64.ge_s":P(["i32.const",1]),"i64.ge_u":P(["i32.const",1]),"i32.mul":(t,e)=>q(e)?.value===0&&D(t)?["i32.const",0]:q(t)?.value===0&&D(e)?["i32.const",0]:null,"i64.mul":(t,e)=>q(e)?.value===G&&D(t)?["i64.const",0]:q(t)?.value===G&&D(e)?["i64.const",0]:null,"i32.and":(t,e)=>nt(t,e)&&D(e)?t:q(e)?.value===0&&D(t)?["i32.const",0]:q(t)?.value===0&&D(e)?["i32.const",0]:null,"i64.and":(t,e)=>nt(t,e)&&D(e)?t:q(e)?.value===G&&D(t)?["i64.const",0]:q(t)?.value===G&&D(e)?["i64.const",0]:null,"i32.or":(t,e)=>nt(t,e)&&D(e)?t:q(e)?.value===-1&&D(t)?["i32.const",-1]:q(t)?.value===-1&&D(e)?["i32.const",-1]:null,"i64.or":(t,e)=>nt(t,e)&&D(e)?t:q(e)?.value===Kt&&D(t)?["i64.const",-1]:q(t)?.value===Kt&&D(e)?["i64.const",-1]:null,"local.set":(t,e)=>Array.isArray(e)&&e[0]==="local.get"&&e[1]===t?["nop"]:null},Di=t=>H(t,e=>{if(!Array.isArray(e)||e.length!==3)return;let r=Ui[e[0]];if(!r)return;let i=r(e[1],e[2]);if(i!==null)return i}),Pi=t=>{let e=typeof t=="bigint"?t:BigInt(typeof t=="string"?t.replaceAll("_",""):Math.trunc(Number(t)||0));e>0x7fffffffffffffffn&&(e=e-0x8000000000000000n-0x8000000000000000n);let r=1;for(;;){let i=e&0x7fn;if(e>>=7n,e===0n&&(i&0x40n)===0n||e===-1n&&(i&0x40n)!==0n)return r;r++}},Wi=t=>{if(!Array.isArray(t))return 4;switch(t[0]){case"i32.const":case"i64.const":return 1+Pi(t[1]);case"f32.const":return 5;case"f64.const":return 9;case"v128.const":return 18;default:return 4}},ji=2,Gi=t=>{if(!Array.isArray(t)||t[0]!=="module")return t;let e=new Map,r=new Set;for(let n of t.slice(1)){if(!Array.isArray(n))continue;if(n[0]==="export"&&Array.isArray(n[2])&&n[2][0]==="global"&&typeof n[2][1]=="string"){r.add(n[2][1]);continue}if(n[0]!=="global")continue;let l=typeof n[1]=="string"&&n[1][0]==="$"?n[1]:null;if(!l)continue;n.some(a=>Array.isArray(a)&&a[0]==="export")&&r.add(l);let f=n[2];if(Array.isArray(f)&&f[0]==="mut"||Array.isArray(f)&&f[0]==="import")continue;let c=n[3];q(c)&&e.set(l,c)}if(e.size===0)return t;let i=new Map;R(t,n=>{if(!Array.isArray(n))return;let l=n[1];typeof l!="string"||l[0]!=="$"||(n[0]==="global.set"?e.delete(l):n[0]==="global.get"&&i.set(l,(i.get(l)||0)+1))});let s=new Set;for(let[n,l]of e){let f=i.get(n)||0;if(f===0)continue;let c=Wi(l),a=c+2,u=f*ji+a;f*c+(r.has(n)?a:0)<=u&&s.add(n)}if(s.size===0)return t;H(t,n=>{if(!(!Array.isArray(n)||n[0]!=="global.get"||n.length!==2)&&s.has(n[1]))return Q(e.get(n[1]))});for(let n=t.length-1;n>=1;n--){let l=t[n];Array.isArray(l)&&l[0]==="global"&&typeof l[1]=="string"&&s.has(l[1])&&!r.has(l[1])&&t.splice(n,1)}return t},Hi=t=>H(t,e=>{if(!Array.isArray(e))return;let r=e[0];if(typeof r!="string"||!r.endsWith("load")&&!r.endsWith("store"))return;let i=r.endsWith("store"),s=0,n=null,l=1;for(typeof e[1]=="string"&&(e[1][0]==="$"||!isNaN(e[1]))&&(n=e[1],l=2);l<e.length&&typeof e[l]=="string"&&(e[l].startsWith("offset=")||e[l].startsWith("align="));)e[l].startsWith("offset=")&&(s=+e[l].slice(7)),l++;let f=i?e.length-2:e.length-1,c=i?e.length-1:-1;if(f<l)return;let a=e[f];if(!Array.isArray(a)||a[0]!=="i32.add"||a.length!==3)return;let u=a[1],g=a[2],h=q(u),x=q(g),M=null,A=null;if(h&&h.type==="i32"?(A=h.value,M=g):x&&x.type==="i32"&&(A=x.value,M=u),M===null||A===null)return;let w=s+A,b=[r];n!==null&&b.push(n),b.push(`offset=${w}`);let o=null;for(let y=l;y<f;y++)typeof e[y]=="string"&&e[y].startsWith("align=")&&(o=e[y]);return o&&b.push(o),b.push(M),i&&b.push(e[c]),b}),Vi=t=>(R(t,e=>{if(!Array.isArray(e)||e[0]!=="block")return;let i=1,s=null;if(typeof e[1]=="string"&&e[1][0]==="$"&&(s=e[1],i=2),!s)return;let n=-1;for(let f=e.length-1;f>=i;f--){let c=e[f];if(!Array.isArray(c)){c!=="nop"&&c!=="end"&&(n=f);continue}let a=c[0];if(!(a==="param"||a==="result"||a==="local"||a==="type"||a==="export")){n=f;break}}if(n<0)return;let l=e[n];Array.isArray(l)&&l[0]==="br"&&l[1]===s&&e.splice(n,1,...l.slice(2))}),t),Yi=t=>(R(t,e=>{if(!Array.isArray(e)||e[0]!=="block")return;let r=1,i=null;if(typeof e[1]=="string"&&e[1][0]==="$"&&(i=e[1],r=2),!i)return;for(;r<e.length;){let M=e[r];if(Array.isArray(M)&&M[0]==="type"){r++;continue}if(Array.isArray(M)&&(M[0]==="param"||M[0]==="result"))return;break}if(e.length-r!==1)return;let s=e[r];if(!Array.isArray(s)||s[0]!=="loop")return;let n=1,l=null;typeof s[1]=="string"&&s[1][0]==="$"&&(l=s[1],n=2);let f=[];for(;n<s.length;){let M=s[n];if(Array.isArray(M)&&M[0]==="type"){f.push(M),n++;continue}if(Array.isArray(M)&&(M[0]==="param"||M[0]==="result"))return;break}let c=s.slice(n);if(c.length<2)return;let a=c[0],u=c[c.length-1];if(!Array.isArray(a)||a[0]!=="br_if"||a[1]!==i||a.length!==3||!Array.isArray(u)||u[0]!=="br"||u[1]!==l||u.length!==2)return;let g=c.slice(1,-1);if(Zt(g,i))return;let h=a[2];Array.isArray(h)&&h[0]==="i32.eqz"&&h.length===2?h=h[1]:h=["i32.eqz",h];let x=["loop"];l&&x.push(l);for(let M of f)x.push(M);x.push(["if",h,["then",...g,u]]),e.length=0;for(let M of x)e.push(M)}),t),Xi=t=>{if(!Array.isArray(t)||t[0]!=="module")return t;let e=new Set;return R(t,r=>{Array.isArray(r)&&r[0]==="global.set"&&typeof r[1]=="string"&&e.add(r[1])}),H(t,r=>{if(!Array.isArray(r)||r[0]!=="global")return;let i=typeof r[1]=="string"&&r[1][0]==="$"?r[1]:null;if(!i||e.has(i))return;let s=typeof r[1]=="string"&&r[1][0]==="$",n=s?r[2]:r[1];if(Array.isArray(n)&&n[0]==="mut"){let l=[...r];return l[s?2:1]=n[1],l}})},Zi=t=>H(t,e=>{if(!Array.isArray(e)||e[0]!=="if")return;let{cond:r,thenBranch:i,elseBranch:s}=It(e),n=!i||i.length<=1,l=!s||s.length<=1;if(!n&&l&&i.length===2){let f=i[1];if(Array.isArray(f)&&f[0]==="br"&&f.length===2)return["br_if",f[1],r]}if(n&&!l&&s.length===2){let f=s[1];if(Array.isArray(f)&&f[0]==="br"&&f.length===2)return["br_if",f[1],["i32.eqz",r]]}}),Ki=t=>H(t,e=>{if(!Array.isArray(e)||e[0]!=="if")return;let{thenBranch:r,elseBranch:i}=It(e);if(!r||!i||r.length<=1||i.length<=1||!e.some(h=>Array.isArray(h)&&h[0]==="result"))return;let n=0,l=Math.min(r.length,i.length);for(let h=1;h<l&&nt(r[r.length-h],i[i.length-h]);h++)n++;if(n===0)return;let f=r.slice(r.length-n),c=r.slice(0,r.length-n),a=i.slice(0,i.length-n),u=["block"];for(let h=1;h<e.length;h++){let x=e[h];if(Array.isArray(x)&&(x[0]==="then"||x[0]==="else"))break;Array.isArray(x)&&(x[0]==="result"||x[0]==="type")&&u.push(x)}let g=["if"];for(let h=1;h<e.length;h++){let x=e[h];if(Array.isArray(x)&&(x[0]==="then"||x[0]==="else"))break;Array.isArray(x)&&(x[0]==="result"||x[0]==="type")||g.push(x)}return g.push(c.length>1?c:["then"]),g.push(a.length>1?a:["else"]),u.push(g,...f),u}),hr=(t,e)=>{let r=[],i=[t];for(;i.length;){let s=i.pop();if(Array.isArray(s)){i.push("|");for(let n=s.length-1;n>=0;n--)i.push(s[n]);i.push("[")}else typeof s=="string"?r.push(e.has(s)?"$__L":s):typeof s=="bigint"?r.push(s.toString()+"n"):typeof s=="number"?r.push(s.toString()):s===null?r.push("null"):s===!0?r.push("t"):s===!1?r.push("f"):r.push(String(s))}return r.join(",")},Qi=t=>{if(!Array.isArray(t)||t[0]!=="module")return t;let e=new Map,r=new Map;for(let i of t.slice(1)){if(!Array.isArray(i)||i[0]!=="func")continue;let s=typeof i[1]=="string"&&i[1][0]==="$"?i[1]:null;if(!s)continue;let n=new Set;typeof i[1]=="string"&&i[1][0]==="$"&&n.add(i[1]),R(i,f=>{if(!Array.isArray(f)||typeof f[1]!="string"||f[1][0]!=="$")return;let c=f[0];(c==="param"||c==="local"||_t(c))&&n.add(f[1])});let l=hr(i,n);e.has(l)?r.set(s,e.get(l)):e.set(l,s)}return r.size===0||H(t,i=>{if(!Array.isArray(i))return;let s=i[0];if((s==="call"||s==="return_call")&&r.has(i[1]))return[s,r.get(i[1]),...i.slice(2)];if(s==="ref.func"&&r.has(i[1]))return["ref.func",r.get(i[1])];if(s==="elem"){let n=i[i.length-1];if(Array.isArray(n))return[...i.slice(0,-1),n.map(l=>r.get(l)||l)]}if(s==="call_indirect"&&i.length>=3){let n=i[1];if(typeof n=="string"&&r.has(n))return["call_indirect",r.get(n),...i.slice(2)]}}),t},Ji=t=>{if(!Array.isArray(t)||t[0]!=="module")return t;let e=new Map,r=new Map;for(let i of t.slice(1)){if(!Array.isArray(i)||i[0]!=="type")continue;let s=typeof i[1]=="string"&&i[1][0]==="$"?i[1]:null;if(!s)continue;let n=hr(i,new Set([s]));e.has(n)?r.set(s,e.get(n)):e.set(n,s)}if(r.size===0)return t;for(let i=t.length-1;i>=0;i--){let s=t[i];if(Array.isArray(s)&&s[0]==="type"){let n=typeof s[1]=="string"&&s[1][0]==="$"?s[1]:null;n&&r.has(n)&&t.splice(i,1)}}return H(t,i=>{if(!Array.isArray(i))return;let s=i[0];if(s==="func")for(let n=1;n<i.length;n++){let l=i[n];Array.isArray(l)&&l[0]==="type"&&typeof l[1]=="string"&&r.has(l[1])&&(i[n]=["type",r.get(l[1])])}if(s==="import")for(let n=1;n<i.length;n++){let l=i[n];if(Array.isArray(l))for(let f=1;f<l.length;f++){let c=l[f];Array.isArray(c)&&c[0]==="type"&&typeof c[1]=="string"&&r.has(c[1])&&(l[f]=["type",r.get(c[1])])}}if(s==="call_indirect"||s==="return_call_indirect"){if(typeof i[1]=="string"&&r.has(i[1]))return[s,r.get(i[1]),...i.slice(2)];if(Array.isArray(i[1])&&i[1][0]==="type"&&typeof i[1][1]=="string"&&r.has(i[1][1]))return[s,["type",r.get(i[1][1])],...i.slice(2)]}}),t},Qt=t=>{if(typeof t!="string"||t.length<2||t[0]!=='"')return[];let e=[],r=s=>s>=48&&s<=57?s-48:s>=97&&s<=102?s-87:s>=65&&s<=70?s-55:-1,i=t.length-1;for(let s=1;s<i;s++){let n=t.charCodeAt(s);if(n!==92){e.push(n);continue}let l=t.charCodeAt(++s);if(l===120||l===88)e.push(r(t.charCodeAt(s+1))<<4|r(t.charCodeAt(s+2))),s+=2;else{let f=r(l),c=s+1<i?r(t.charCodeAt(s+1)):-1;f>=0&&c>=0?(e.push(f<<4|c),s++):l===110?e.push(10):l===116?e.push(9):l===114?e.push(13):e.push(l)}}return e},xr=(t,e)=>{let r='"';for(let i=0;i<e;i++){let s=t[i];s>=32&&s<127&&s!==34&&s!==92?r+=String.fromCharCode(s):r+="\\"+s.toString(16).padStart(2,"0")}return r+'"'},ts=t=>{let e=[];for(let i of t)if(typeof i=="string"){let s=Qt(i);for(let n=0;n<s.length;n++)e.push(s[n])}else if(Array.isArray(i)&&i[0]==="i8")for(let s=1;s<i.length;s++)e.push(Number(i[s])&255);else return t;let r=e.length;for(;r>0&&e[r-1]===0;)r--;return r===e.length?t:r===0?[]:[xr(e,r)]},es=t=>{let e=1;if(typeof t[e]=="string"&&t[e][0]==="$"&&e++,Array.isArray(t[e])&&t[e][0]==="memory"){let i=t[e][1];e++;let s=t[e];return Array.isArray(s)&&(s[0]==="i32.const"||s[0]==="i64.const")?{memidx:i,offset:Number(s[1])}:null}let r=t[e];return Array.isArray(r)&&(r[0]==="i32.const"||r[0]==="i64.const")?{memidx:0,offset:Number(r[1])}:null},Je=t=>{let e=1;typeof t[e]=="string"&&t[e][0]==="$"&&e++,Array.isArray(t[e])&&t[e][0]==="memory"&&e++,Array.isArray(t[e])&&typeof t[e][0]=="string"&&!t[e][0].startsWith('"')&&e++;let r=0;for(let i=e;i<t.length;i++){let s=t[i];if(typeof s=="string")r+=Qt(s).length;else if(Array.isArray(s)&&s[0]==="i8")r+=s.length-1;else return null}return r},rs=(t,e)=>{let r=1;typeof t[r]=="string"&&t[r][0]==="$"&&r++,Array.isArray(t[r])&&t[r][0]==="memory"&&r++,Array.isArray(t[r])&&typeof t[r][0]=="string"&&!t[r][0].startsWith('"')&&r++;let i=1;typeof e[i]=="string"&&e[i][0]==="$"&&i++,Array.isArray(e[i])&&e[i][0]==="memory"&&i++,Array.isArray(e[i])&&typeof e[i][0]=="string"&&!e[i][0].startsWith('"')&&i++;let s=t.slice(r),n=e.slice(i);if(s.length===1&&n.length===1&&typeof s[0]=="string"&&typeof n[0]=="string"){let l=Qt(s[0]),f=Qt(n[0]);for(let c=0;c<f.length;c++)l.push(f[c]);return t.length=r,t.push(xr(l,l.length)),!0}return t.length=r,t.push(...s,...n),!0},is=t=>{if(!Array.isArray(t)||t[0]!=="module")return t;for(let i of t){if(!Array.isArray(i)||i[0]!=="data")continue;let s=1;typeof i[1]=="string"&&i[1][0]==="$"&&(s=2),s<i.length&&Array.isArray(i[s])&&typeof i[s][0]=="string"&&!i[s][0].startsWith('"')&&s++;let n=i.slice(s);if(n.length===0)continue;let l=ts(n);(l.length!==n.length||l.length>0&&l[0]!==n[0])&&(i.length=s,i.push(...l))}let e=[];for(let i=0;i<t.length;i++){let s=t[i];if(Array.isArray(s)&&s[0]==="data"){let n=es(s);if(n){let l=Je(s);l!==null&&e.push({...n,node:s,index:i,len:l})}}}e.sort((i,s)=>{let n=String(i.memidx),l=String(s.memidx);return n!==l?n.localeCompare(l):i.offset-s.offset});let r=new Set;for(let i=0;i<e.length-1;i++){let s=e[i],n=e[i+1];r.has(s.index)||String(s.memidx)!==String(n.memidx)||s.offset+s.len===n.offset&&rs(s.node,n.node)&&(r.add(n.index),s.len=Je(s.node))}return r.size>0&&(t=t.filter((i,s)=>!r.has(s))),t},tr=()=>{let t=new Map,e=0;return r=>{if(!t.has(r)){let i="",s=e++;do i=String.fromCharCode(97+s%26)+i,s=Math.floor(s/26)-1;while(s>=0);t.set(r,i||"a")}return t.get(r)}},ss=t=>{if(!Array.isArray(t)||t[0]!=="module")return t;let e=tr(),r=tr();for(let i of t)!Array.isArray(i)||i[0]!=="import"||(typeof i[1]=="string"&&i[1][0]==='"'&&(i[1]='"'+e(i[1].slice(1,-1))+'"'),typeof i[2]=="string"&&i[2][0]==='"'&&(i[2]='"'+r(i[2].slice(1,-1))+'"'));return t},ns=t=>{let e=!0;return R(t,r=>{if(!e||!Array.isArray(r))return;let i=r[0];if(i==="func"&&(typeof r[1]!="string"||r[1][0]!=="$"))e=!1;else if((i==="call"||i==="return_call"||i==="ref.func")&&(typeof r[1]!="string"||r[1][0]!=="$"))e=!1;else if(i==="start"&&(typeof r[1]!="string"||r[1][0]!=="$"))e=!1;else if(i==="elem")for(let s of r){if(typeof s=="string"&&s[0]!=="$"&&/^\d/.test(s)){e=!1;break}if(Array.isArray(s)&&s[0]==="ref.func"&&(typeof s[1]!="string"||s[1][0]!=="$")){e=!1;break}}}),e},ls=t=>{if(!Array.isArray(t)||t[0]!=="module"||!ns(t))return t;let e=new Map;R(t,n=>{Array.isArray(n)&&(n[0]==="call"||n[0]==="return_call")&&e.set(n[1],(e.get(n[1])||0)+1)});let r=[],i=[],s=[];for(let n of t.slice(1)){if(!Array.isArray(n)){s.push(n);continue}n[0]==="import"?r.push(n):n[0]==="func"?i.push(n):s.push(n)}return i.sort((n,l)=>(e.get(l[1])||0)-(e.get(n[1])||0)),["module",...r,...i,...s]},Tt=[["stripmut",Xi,!0,"strip mut from never-written globals"],["globals",Gi,!0,"propagate immutable global constants"],["guardRefine",xi,!1,"fold NaN-box tag reads under dominating tag guards (jz NaN-box-specific; opt-in)"],["fold",pi,!0,"constant folding"],["identity",mi,!0,"remove identity ops (x + 0 \u2192 x)"],["peephole",Di,!0,"x-x\u21920, x&0\u21920, etc."],["strength",_i,!0,"strength reduction (x * 2 \u2192 x << 1)"],["branch",hi,!0,"simplify constant branches"],["propagate",ge,!0,"forward-propagate single-use locals & tiny consts (never inflates)"],["devirt",pr,!1,"call_indirect with a constant or known closure-const index \u2192 direct/guarded calls \u2014 grows bytes for speed"],["inlineOnce",Ri,!0,"inline single-call functions into their lone caller (never duplicates)"],["inline",yr,!1,"inline tiny functions \u2014 can duplicate bodies"],["offset",Hi,!0,"fold add+const into load/store offset"],["unbranch",Vi,!0,"remove redundant br at end of own block"],["loopify",Yi,!0,"collapse block+loop+brif while-idiom into loop+if"],["brif",Zi,!0,"if-then-br \u2192 br_if"],["foldarms",Ki,!1,"merge identical trailing if arms \u2014 can add block wrapper"],["deadcode",Ai,!0,"eliminate dead code after unreachable/br/return"],["vacuum",_r,!0,"remove nops, drop-of-pure, empty branches"],["mergeBlocks",gr,!0,"unwrap `(block $L \u2026)` whose label is never targeted"],["coalesce",mr,!0,"share local slots between same-type non-overlapping locals"],["locals",bi,!0,"remove unused locals"],["dedupe",Qi,!0,"eliminate duplicate functions"],["dedupTypes",Ji,!0,"merge identical type definitions"],["packData",is,!0,"trim trailing zeros, merge adjacent data segments"],["reorder",ls,!1,"put hot functions first \u2014 no AST reduction"],["treeshake",ii,!0,"remove unused funcs/globals/types/tables"],["minifyImports",ss,!1,"shorten import names \u2014 enable only when you control the host"]],Fs=Object.fromEntries(Tt.map(t=>[t[0],t[2]])),fs=t=>{if(t===!1)return{};if(t!==!0&&typeof t!="string"){let i={...t};for(let s of Tt)i[s[0]]===void 0&&(i[s[0]]=s[2]);return i}let e=typeof t=="string"?new Set(t.split(/\s+/).filter(Boolean)):null,r={};for(let i of Tt)r[i[0]]=e?e.has("all")||e.has(i[0]):i[2];return r},os=t=>{if(!Array.isArray(t))return!1;let e=new Map,r=new Set,i=new Set,s=n=>{if(!Array.isArray(n))return;let l=n[0];if(l==="call"&&typeof n[1]=="string")e.set(n[1],(e.get(n[1])||0)+1);else if(l==="return_call"&&typeof n[1]=="string")i.add(n[1]);else if(l==="ref.func"&&typeof n[1]=="string")r.add(n[1]);else if(l==="export"&&Array.isArray(n[2])&&n[2][0]==="func"&&typeof n[2][1]=="string")r.add(n[2][1]);else if(l==="start"&&typeof n[1]=="string")r.add(n[1]);else if(l==="elem")for(let f of n)typeof f=="string"&&f[0]==="$"&&r.add(f);for(let f=1;f<n.length;f++)s(n[f])};s(t);for(let n of t){if(!Array.isArray(n)||n[0]!=="func"||typeof n[1]!="string")continue;let l=n[1];if(!(e.get(l)!==1||r.has(l)||i.has(l))&&!n.some(f=>Array.isArray(f)&&f[0]==="export"))return!0}return!1},as=new Set(["export","type","param","result","local"]);function cs(t){if(!Array.isArray(t)||t[0]!=="module")return t;let e=t.find(i=>Array.isArray(i)&&i[0]==="func"&&i[1]==="$__start");if(!e)return t;let r=2;for(;r<e.length&&Array.isArray(e[r])&&as.has(e[r][0]);)r++;return r<e.length?t:t.filter(i=>!(Array.isArray(i)&&(i[0]==="func"&&i[1]==="$__start"||i[0]==="start"&&i[1]==="$__start")))}function Ie(t,e=!0){typeof t=="string"&&(t=lt(t));let r=e===!0;e=fs(e),e.pin=e.pin instanceof Set?e.pin:new Set(e.pin||[]);let i=e.log?(a,u)=>e.log(a,u):()=>{},s=e.verbose||e.log;t=Q(t);let n=a=>(e.inline&&(a=yr(a,{simdOnly:e.inline==="simd",pin:e.pin}),e.propagate&&(a=ge(a)),e.mergeBlocks&&(a=gr(a)),e.vacuum&&(a=_r(a)),e.coalesceLocals&&(a=mr(a))),a),l=a=>(a=n(a),cs(e.devirt?pr(a):a));if(!((e.inlineOnce||e.inline)&&os(t))){for(let a=0;a<3;a++){let u=Q(t);for(let[g,h]of Tt)e[g]&&g!=="inlineOnce"&&g!=="inline"&&g!=="devirt"&&(t=h(t,e));if(nt(u,t))break;s&&i(` round ${a+1} applied`)}return l(t)}let f=null,c=Ve(t);for(let a=0;a<3;a++){f=Q(t);for(let[x,M]of Tt)e[x]&&x!=="devirt"&&x!=="inline"&&(t=M(t,e));if(e.propagate&&(e.inlineOnce||e.inline)&&(t=ge(t)),nt(f,t))break;let u=Ve(t),g=u-c;if((s||g!==0)&&i(` round ${a+1}: ${g>0?"+":""}${g} bytes`,g),g>(r?0:16)){s&&i(` \u26A0 round ${a+1} inflated by ${g} bytes, reverting`,g),t=f;break}c=u}return l(t)}var dr="\uE000",us=(t,e={})=>{if(!Array.isArray(t))return typeof t=="string"&&t[0]==="$"&&e.locals?.[t]?e.locals[t]:null;let[r,...i]=t,s=Oe(r);return s||(r==="local.get"&&e.locals?.[i[0]]?e.locals[i[0]]:r==="call"&&e.funcs?.[i[0]]?e.funcs[i[0]].result?.[0]:null)};function ke(t,e){if(t=e(t),Array.isArray(t))for(let r=0;r<t.length;r++){let i=ke(t[r],e);i?._splice?(t.splice(r,1,...i),r+=i.length-1):t[r]=i}return t}function ys(t,e){let r=[],i=new Map;return ke(t,s=>{if(!Array.isArray(s))return s;if(s[0]==="call"&&typeof s[1]=="function"){let n=s[1];if(!i.has(n)){let f=[];for(let u=2;u<s.length;u++){let g=us(s[u]);g&&f.push(g)}let c=r.length,a=n.name||`$fn${c}`;i.set(n,{idx:c,name:a.startsWith("$")?a:"$"+a,params:f,fn:n}),r.push(i.get(n))}let l=i.get(n);s[1]=l.name}return s}),r}function ps(t){return t.map(({name:e,params:r})=>["import",'"env"',`"${e.slice(1)}"`,["func",e,...r.map(i=>["param",i])]])}function Se(t,e,r){let{parse:i,compile:s,optimize:n,polyfill:l}=t,f={};if(!Array.isArray(e)&&r.length&&typeof r[r.length-1]=="object"&&r[r.length-1]!==null&&!r[r.length-1].byteLength&&(f=r.pop()),Array.isArray(e)&&e.raw){let c=e[0];for(let M=0;M<r.length;M++)c+=dr+e[M+1];let a=i(c),u=[],g=0;a=ke(a,M=>{if(M===dr){let A=r[g++];if(typeof A=="function")return u.push(A),A;if(typeof A=="string"&&(A[0]==="("||/^\s*\(/.test(A))){let w=i(A);return Array.isArray(w)&&Array.isArray(w[0])&&(w._splice=!0),w}return A?.byteLength!==void 0?[...A]:typeof A=="bigint"?A.toString():A}return M});let h=null;if(u.length){let M=ys(a,u);if(M.length){let A=ps(M);a[0]==="module"?a.splice(1,0,...A):typeof a[0]=="string"?a=[...A,a]:a.unshift(...A),h={env:{}};for(let w of M)h.env[w.name.slice(1)]=w.fn}}f.polyfill&&(a=l(a,f.polyfill)),f.optimize&&(a=n(a,f.optimize));let x=s(a);return h&&(x._imports=h),x}if(f.polyfill||f.optimize){let c=typeof e=="string"?i(e):e;return f.polyfill&&(c=l(c,f.polyfill)),f.optimize&&(c=n(c,f.optimize)),s(c)}return s(e)}function Ar(t,e,r){let i=Se(t,e,r),s=new WebAssembly.Module(i);return new WebAssembly.Instance(s,i._imports).exports}var br={parse:lt,compile:oe,optimize:Ie,polyfill:ae};function Hs(t,...e){return Se(br,t,e)}function gs(t,...e){return Ar(br,t,e)}var Vs=gs;export{Hs as compile,Vs as default,Ie as optimize,lt as parse,ae as polyfill,We as print,gs as watr};
1
+ var Ce=Object.defineProperty;var De=(e,t)=>{for(var i in t)Ce(e,i,{get:t[i],enumerable:!0})};var H={};De(H,{f32:()=>R,f64:()=>L,i16:()=>Re,i32:()=>B,i64:()=>j,i8:()=>je,uleb:()=>o,uleb5:()=>Pe,v128:()=>oe});var h=(e,t=h.loc)=>{if(t!=null&&h.src){let i=1,r=1;for(let s=0;s<t&&s<h.src.length;s++)h.src[s]===`
2
+ `?(i++,r=1):r++;e+=` at ${i}:${r}`}throw Error(e)},ye=/^_|_$|[^\da-f]_|_[^\da-f]/i,we=/^[+-]?(?:0x[\da-f]+|\d+)$/i,We=new TextEncoder,Le=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),de={n:10,r:13,t:9,'"':34,"'":39,"\\":92},X=e=>{let t=[],i=1,r,s,l="",a=()=>(l&&t.push(...We.encode(l)),l="");for(;i<e.length-1;)s=e[i++],r=null,s==="\\"&&(e[i]==="u"?(i++,i++,s=String.fromCodePoint(parseInt(e.slice(i,i=e.indexOf("}",i)),16)),i++):de[e[i]]?r=de[e[i++]]:isNaN(r=parseInt(e[i]+e[i+1],16))?s+=e[i]:(i++,i++)),r!=null?(a(),t.push(r)):l+=s;return a(),t.valueOf=()=>e,t},be=e=>Le.decode(new Uint8Array(X(e)));var o=(e,t=[])=>{if(e==null)return t;if(typeof e=="string"&&(e=/[_x]/i.test(e)?BigInt(e.replaceAll("_","")):B.parse(e)),typeof e=="bigint"){for(;;){let r=Number(e&0x7Fn);if(e>>=7n,e===0n){t.push(r);break}t.push(r|128)}return t}let i=e&127;return e>>>=7,e===0?(t.push(i),t):(t.push(i|128),o(e,t))};function Pe(e){let t=[];for(let i=0;i<5;i++){let r=e&127;e>>>=7,i<4&&(r|=128),t.push(r)}return t}function B(e,t=[]){for(typeof e=="string"&&(e=B.parse(e));;){let i=Number(e&127);if(e>>=7,e===0&&!(i&64)||e===-1&&i&64){t.push(i);break}t.push(i|128)}return t}var Ie=e=>!ye.test(e)&&we.test(e=e.replaceAll("_",""))?e:h(`Bad int ${e}`),je=B,Re=B;B.parse=e=>(e=parseInt(Ie(e)),(e<-2147483648||e>4294967295)&&h("i32 constant out of range"),e);function j(e,t=[]){for(typeof e=="string"?e=j.parse(e):typeof e=="number"&&(e=BigInt(e)),typeof e=="bigint"&&e>0x7fffffffffffffffn&&(e=e-0x10000000000000000n);;){let i=Number(e&0x7Fn);if(e>>=7n,e===0n&&!(i&64)||e===-1n&&i&64){t.push(i);break}t.push(i|128)}return t}var Q=new ArrayBuffer(8),S=new Uint8Array(Q),Ve=new Int32Array(Q),Ye=new Float32Array(Q),Ge=new Float64Array(Q),ne=new BigInt64Array(Q);j.parse=e=>{e=Ie(e);let t=e[0]==="-",i=t||e[0]==="+"?e.slice(1):e,r;if(i[0]==="0"&&(i[1]==="x"||i[1]==="X")){let l=i.slice(2).replace(/^0+/,"")||"0";r=t?"8000000000000000":"ffffffffffffffff",(l.length>16||l.length===16&&l.toLowerCase()>r)&&h("i64 constant out of range")}else{let l=i.replace(/^0+/,"")||"0";r=t?"9223372036854775808":"18446744073709551615",(l.length>r.length||l.length===r.length&&l>r)&&h("i64 constant out of range")}let s=BigInt(i);return t&&(s=0n-s),ne[0]=s,ne[0]};var Ke=2147483648,Qe=2139095040,Ae=4194304;function R(e,t,i){if(typeof e=="string"&&(i=e.indexOf("nan"))>=0){if(e[i+3]===":"){let r=e.slice(i+4);t=r==="canonical"||r==="arithmetic"?Ae:B.parse(r)}else t=Ae;t=(t|Qe)>>>0,e[0]==="-"&&(t=(t|Ke)>>>0),Ve[0]=t|0}else t=typeof e=="string"?R.parse(e):e,Ye[0]=t;return[S[0],S[1],S[2],S[3]]}var Xe=0x8000000000000000n,He=0x7ff0000000000000n,ve=0x8000000000000n;function L(e,t,i){if(typeof e=="string"&&(i=e.indexOf("nan"))>=0){if(e[i+3]===":"){let r=e.slice(i+4);t=r==="canonical"||r==="arithmetic"?ve:j.parse(r)}else t=ve;t|=He,e[0]==="-"&&(t|=Xe),ne[0]=t}else t=typeof e=="string"?L.parse(e):e,Ge[0]=t;return[S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7]]}L.parse=(e,t=Number.MAX_VALUE)=>{e=e.replaceAll("_","");let i=1;if(e[0]==="-"?(i=-1,e=e.slice(1)):e[0]==="+"&&(e=e.slice(1)),e[1]==="x"){let[r,s="0"]=e.split(/p/i),[l,a=""]=r.split("."),f=a.length??0,_=0;for(let x=l.length-1;x>=2;x--){let U=parseInt(l[x],16);_+=U*16**(l.length-1-x)}let n=a?parseInt("0x"+a)/16**f:0;s=parseInt(s,10);let c=i*(_+n)*2**s;return c=Math.max(-t,Math.min(t,c)),c}return e.includes("nan")?i<0?NaN:NaN:e.includes("inf")?i*(1/0):i*parseFloat(e)};R.parse=e=>L.parse(e,34028234663852886e22);var oe=e=>{let t=BigInt(typeof e=="string"?e.replaceAll("_",""):e),i=new Uint8Array(16);for(let r=0;r<16;r++)i[r]=Number(t&0xffn),t>>=8n;return[...i]};var V=["unreachable","nop","block block","loop block","if block","else null","then null",,"throw tagidx",,"throw_ref","end end","br labelidx","br_if labelidx","br_table br_table","return","call funcidx","call_indirect call_indirect","return_call funcidx","return_call_indirect call_indirect","call_ref typeidx","return_call_ref typeidx",,,,,"drop","select select","",,,"try_table try_table","local.get localidx","local.set localidx","local.tee localidx","global.get globalidx","global.set globalidx","table.get tableidx","table.set tableidx",,"i32.load memarg","i64.load memarg","f32.load memarg","f64.load memarg","i32.load8_s memarg","i32.load8_u memarg","i32.load16_s memarg","i32.load16_u memarg","i64.load8_s memarg","i64.load8_u memarg","i64.load16_s memarg","i64.load16_u memarg","i64.load32_s memarg","i64.load32_u memarg","i32.store memarg","i64.store memarg","f32.store memarg","f64.store memarg","i32.store8 memarg","i32.store16 memarg","i64.store8 memarg","i64.store16 memarg","i64.store32 memarg","memory.size opt_memory","memory.grow opt_memory","i32.const i32","i64.const i64","f32.const f32","f64.const f64","i32.eqz","i32.eq","i32.ne","i32.lt_s","i32.lt_u","i32.gt_s","i32.gt_u","i32.le_s","i32.le_u","i32.ge_s","i32.ge_u","i64.eqz","i64.eq","i64.ne","i64.lt_s","i64.lt_u","i64.gt_s","i64.gt_u","i64.le_s","i64.le_u","i64.ge_s","i64.ge_u","f32.eq","f32.ne","f32.lt","f32.gt","f32.le","f32.ge","f64.eq","f64.ne","f64.lt","f64.gt","f64.le","f64.ge","i32.clz","i32.ctz","i32.popcnt","i32.add","i32.sub","i32.mul","i32.div_s","i32.div_u","i32.rem_s","i32.rem_u","i32.and","i32.or","i32.xor","i32.shl","i32.shr_s","i32.shr_u","i32.rotl","i32.rotr","i64.clz","i64.ctz","i64.popcnt","i64.add","i64.sub","i64.mul","i64.div_s","i64.div_u","i64.rem_s","i64.rem_u","i64.and","i64.or","i64.xor","i64.shl","i64.shr_s","i64.shr_u","i64.rotl","i64.rotr","f32.abs","f32.neg","f32.ceil","f32.floor","f32.trunc","f32.nearest","f32.sqrt","f32.add","f32.sub","f32.mul","f32.div","f32.min","f32.max","f32.copysign","f64.abs","f64.neg","f64.ceil","f64.floor","f64.trunc","f64.nearest","f64.sqrt","f64.add","f64.sub","f64.mul","f64.div","f64.min","f64.max","f64.copysign","i32.wrap_i64","i32.trunc_f32_s","i32.trunc_f32_u","i32.trunc_f64_s","i32.trunc_f64_u","i64.extend_i32_s","i64.extend_i32_u","i64.trunc_f32_s","i64.trunc_f32_u","i64.trunc_f64_s","i64.trunc_f64_u","f32.convert_i32_s","f32.convert_i32_u","f32.convert_i64_s","f32.convert_i64_u","f32.demote_f64","f64.convert_i32_s","f64.convert_i32_u","f64.convert_i64_s","f64.convert_i64_u","f64.promote_f32","i32.reinterpret_f32","i64.reinterpret_f64","f32.reinterpret_i32","f64.reinterpret_i64","i32.extend8_s","i32.extend16_s","i64.extend8_s","i64.extend16_s","i64.extend32_s",,,,,,,,,,,,"ref.null ref_null","ref.is_null","ref.func funcidx","ref.eq","ref.as_non_null","br_on_null labelidx","br_on_non_null labelidx",,,,,,,,,,"cont.new typeidx","cont.bind cont_bind","suspend tagidx","resume resume","resume_throw resume_throw","resume_throw_ref resume_throw_ref","switch switch_cont",,,,,,,,,,,,,,,,,,,,,["struct.new typeidx","struct.new_default typeidx","struct.get typeidx_field","struct.get_s typeidx_field","struct.get_u typeidx_field","struct.set typeidx_field","array.new typeidx","array.new_default typeidx","array.new_fixed typeidx_multi","array.new_data typeidx_dataidx","array.new_elem typeidx_elemidx","array.get typeidx","array.get_s typeidx","array.get_u typeidx","array.set typeidx","array.len","array.fill typeidx","array.copy typeidx_typeidx","array.init_data typeidx_dataidx","array.init_elem typeidx_elemidx","ref.test reftype","ref.test_null reftype","ref.cast reftype","ref.cast_null reftype","br_on_cast reftype2","br_on_cast_fail reftype2","any.convert_extern","extern.convert_any","ref.i31","i31.get_s","i31.get_u",,"struct.new_desc typeidx","struct.new_default_desc typeidx","ref.get_desc typeidx","ref.cast_desc_eq reftype",,"br_on_cast_desc_eq reftype2","br_on_cast_desc_eq_fail reftype2",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"string.new_utf8 memoryidx?","string.new_wtf16 memoryidx?","string.const stringidx","string.measure_utf8","string.measure_wtf8","string.measure_wtf16","string.encode_utf8 memoryidx?","string.encode_wtf16 memoryidx?","string.concat","string.eq","string.is_usv_sequence","string.new_lossy_utf8 memoryidx?","string.new_wtf8 memoryidx?","string.encode_lossy_utf8 memoryidx?","string.encode_wtf8 memoryidx?",,"string.as_wtf8","stringview_wtf8.advance","stringview_wtf8.encode_utf8 memoryidx?","stringview_wtf8.slice","stringview_wtf8.encode_lossy_utf8 memoryidx?","stringview_wtf8.encode_wtf8 memoryidx?",,,"string.as_wtf16","stringview_wtf16.length","stringview_wtf16.get_codeunit","stringview_wtf16.encode memoryidx?","stringview_wtf16.slice",,,,"string.as_iter","stringview_iter.next","stringview_iter.advance","stringview_iter.rewind","stringview_iter.slice",,,,,,,,,,,,"string.new_utf8_array","string.new_wtf16_array","string.encode_utf8_array","string.encode_wtf16_array","string.new_lossy_utf8_array","string.new_wtf8_array","string.encode_lossy_utf8_array","string.encode_wtf8_array"],["i32.trunc_sat_f32_s","i32.trunc_sat_f32_u","i32.trunc_sat_f64_s","i32.trunc_sat_f64_u","i64.trunc_sat_f32_s","i64.trunc_sat_f32_u","i64.trunc_sat_f64_s","i64.trunc_sat_f64_u","memory.init dataidx_memoryidx","data.drop dataidx","memory.copy memoryidx_memoryidx","memory.fill memoryidx?","table.init reversed","elem.drop elemidx","table.copy tableidx_tableidx","table.grow tableidx","table.size tableidx","table.fill tableidx",,"i64.add128","i64.sub128","i64.mul_wide_s","i64.mul_wide_u",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"f32.sqrt_ceil","f32.add_ceil","f32.sub_ceil","f32.mul_ceil","f32.div_ceil","f64.sqrt_ceil","f64.add_ceil","f64.sub_ceil","f64.mul_ceil","f64.div_ceil","f32.convert_ceil_i32_s","f32.convert_ceil_i32_u","f32.convert_ceil_i64_s","f32.convert_ceil_i64_u","f32.demote_ceil_f64","f64.convert_ceil_i32_s","f64.convert_ceil_i32_u","f64.convert_ceil_i64_s","f64.convert_ceil_i64_u","f64.promote_ceil_f32","f32.sqrt_floor","f32.add_floor","f32.sub_floor","f32.mul_floor","f32.div_floor","f64.sqrt_floor","f64.add_floor","f64.sub_floor","f64.mul_floor","f64.div_floor","f32.convert_floor_i32_s","f32.convert_floor_i32_u","f32.convert_floor_i64_s","f32.convert_floor_i64_u","f32.demote_floor_f64","f64.convert_floor_i32_s","f64.convert_floor_i32_u","f64.convert_floor_i64_s","f64.convert_floor_i64_u","f64.promote_floor_f32","f32.sqrt_trunc","f32.add_trunc","f32.sub_trunc","f32.mul_trunc","f32.div_trunc","f64.sqrt_trunc","f64.add_trunc","f64.sub_trunc","f64.mul_trunc","f64.div_trunc","f32.convert_trunc_i32_s","f32.convert_trunc_i32_u","f32.convert_trunc_i64_s","f32.convert_trunc_i64_u","f32.demote_trunc_f64","f64.convert_trunc_i32_s","f64.convert_trunc_i32_u","f64.convert_trunc_i64_s","f64.convert_trunc_i64_u","f64.promote_trunc_f32"],["v128.load memarg","v128.load8x8_s memarg","v128.load8x8_u memarg","v128.load16x4_s memarg","v128.load16x4_u memarg","v128.load32x2_s memarg","v128.load32x2_u memarg","v128.load8_splat memarg","v128.load16_splat memarg","v128.load32_splat memarg","v128.load64_splat memarg","v128.store memarg","v128.const v128const","i8x16.shuffle shuffle","i8x16.swizzle","i8x16.splat","i16x8.splat","i32x4.splat","i64x2.splat","f32x4.splat","f64x2.splat","i8x16.extract_lane_s laneidx","i8x16.extract_lane_u laneidx","i8x16.replace_lane laneidx","i16x8.extract_lane_s laneidx","i16x8.extract_lane_u laneidx","i16x8.replace_lane laneidx","i32x4.extract_lane laneidx","i32x4.replace_lane laneidx","i64x2.extract_lane laneidx","i64x2.replace_lane laneidx","f32x4.extract_lane laneidx","f32x4.replace_lane laneidx","f64x2.extract_lane laneidx","f64x2.replace_lane laneidx","i8x16.eq","i8x16.ne","i8x16.lt_s","i8x16.lt_u","i8x16.gt_s","i8x16.gt_u","i8x16.le_s","i8x16.le_u","i8x16.ge_s","i8x16.ge_u","i16x8.eq","i16x8.ne","i16x8.lt_s","i16x8.lt_u","i16x8.gt_s","i16x8.gt_u","i16x8.le_s","i16x8.le_u","i16x8.ge_s","i16x8.ge_u","i32x4.eq","i32x4.ne","i32x4.lt_s","i32x4.lt_u","i32x4.gt_s","i32x4.gt_u","i32x4.le_s","i32x4.le_u","i32x4.ge_s","i32x4.ge_u","f32x4.eq","f32x4.ne","f32x4.lt","f32x4.gt","f32x4.le","f32x4.ge","f64x2.eq","f64x2.ne","f64x2.lt","f64x2.gt","f64x2.le","f64x2.ge","v128.not","v128.and","v128.andnot","v128.or","v128.xor","v128.bitselect","v128.any_true","v128.load8_lane memlane","v128.load16_lane memlane","v128.load32_lane memlane","v128.load64_lane memlane","v128.store8_lane memlane","v128.store16_lane memlane","v128.store32_lane memlane","v128.store64_lane memlane","v128.load32_zero memarg","v128.load64_zero memarg","f32x4.demote_f64x2_zero","f64x2.promote_low_f32x4","i8x16.abs","i8x16.neg","i8x16.popcnt","i8x16.all_true","i8x16.bitmask","i8x16.narrow_i16x8_s","i8x16.narrow_i16x8_u","f32x4.ceil","f32x4.floor","f32x4.trunc","f32x4.nearest","i8x16.shl","i8x16.shr_s","i8x16.shr_u","i8x16.add","i8x16.add_sat_s","i8x16.add_sat_u","i8x16.sub","i8x16.sub_sat_s","i8x16.sub_sat_u","f64x2.ceil","f64x2.floor","i8x16.min_s","i8x16.min_u","i8x16.max_s","i8x16.max_u","f64x2.trunc","i8x16.avgr_u","i16x8.extadd_pairwise_i8x16_s","i16x8.extadd_pairwise_i8x16_u","i32x4.extadd_pairwise_i16x8_s","i32x4.extadd_pairwise_i16x8_u","i16x8.abs","i16x8.neg","i16x8.q15mulr_sat_s","i16x8.all_true","i16x8.bitmask","i16x8.narrow_i32x4_s","i16x8.narrow_i32x4_u","i16x8.extend_low_i8x16_s","i16x8.extend_high_i8x16_s","i16x8.extend_low_i8x16_u","i16x8.extend_high_i8x16_u","i16x8.shl","i16x8.shr_s","i16x8.shr_u","i16x8.add","i16x8.add_sat_s","i16x8.add_sat_u","i16x8.sub","i16x8.sub_sat_s","i16x8.sub_sat_u","f64x2.nearest","i16x8.mul","i16x8.min_s","i16x8.min_u","i16x8.max_s","i16x8.max_u",,"i16x8.avgr_u","i16x8.extmul_low_i8x16_s","i16x8.extmul_high_i8x16_s","i16x8.extmul_low_i8x16_u","i16x8.extmul_high_i8x16_u","i32x4.abs","i32x4.neg",,"i32x4.all_true","i32x4.bitmask",,,"i32x4.extend_low_i16x8_s","i32x4.extend_high_i16x8_s","i32x4.extend_low_i16x8_u","i32x4.extend_high_i16x8_u","i32x4.shl","i32x4.shr_s","i32x4.shr_u","i32x4.add",,,"i32x4.sub",,,,"i32x4.mul","i32x4.min_s","i32x4.min_u","i32x4.max_s","i32x4.max_u","i32x4.dot_i16x8_s",,"i32x4.extmul_low_i16x8_s","i32x4.extmul_high_i16x8_s","i32x4.extmul_low_i16x8_u","i32x4.extmul_high_i16x8_u","i64x2.abs","i64x2.neg",,"i64x2.all_true","i64x2.bitmask",,,"i64x2.extend_low_i32x4_s","i64x2.extend_high_i32x4_s","i64x2.extend_low_i32x4_u","i64x2.extend_high_i32x4_u","i64x2.shl","i64x2.shr_s","i64x2.shr_u","i64x2.add",,,"i64x2.sub",,,,"i64x2.mul","i64x2.eq","i64x2.ne","i64x2.lt_s","i64x2.gt_s","i64x2.le_s","i64x2.ge_s","i64x2.extmul_low_i32x4_s","i64x2.extmul_high_i32x4_s","i64x2.extmul_low_i32x4_u","i64x2.extmul_high_i32x4_u","f32x4.abs","f32x4.neg",,"f32x4.sqrt","f32x4.add","f32x4.sub","f32x4.mul","f32x4.div","f32x4.min","f32x4.max","f32x4.pmin","f32x4.pmax","f64x2.abs","f64x2.neg",,"f64x2.sqrt","f64x2.add","f64x2.sub","f64x2.mul","f64x2.div","f64x2.min","f64x2.max","f64x2.pmin","f64x2.pmax","i32x4.trunc_sat_f32x4_s","i32x4.trunc_sat_f32x4_u","f32x4.convert_i32x4_s","f32x4.convert_i32x4_u","i32x4.trunc_sat_f64x2_s_zero","i32x4.trunc_sat_f64x2_u_zero","f64x2.convert_low_i32x4_s","f64x2.convert_low_i32x4_u","i8x16.relaxed_swizzle","i32x4.relaxed_trunc_f32x4_s","i32x4.relaxed_trunc_f32x4_u","i32x4.relaxed_trunc_f64x2_s_zero","i32x4.relaxed_trunc_f64x2_u_zero","f32x4.relaxed_madd","f32x4.relaxed_nmadd","f64x2.relaxed_madd","f64x2.relaxed_nmadd","i8x16.relaxed_laneselect","i16x8.relaxed_laneselect","i32x4.relaxed_laneselect","i64x2.relaxed_laneselect","f32x4.relaxed_min","f32x4.relaxed_max","f64x2.relaxed_min","f64x2.relaxed_max","i16x8.relaxed_q15mulr_s","i16x8.relaxed_dot_i8x16_i7x16_s","i32x4.relaxed_dot_i8x16_i7x16_add_s"],["memory.atomic.notify memarg","memory.atomic.wait32 memarg","memory.atomic.wait64 memarg","atomic.fence opt_memory",,,,,,,,,,,,,"i32.atomic.load memarg","i64.atomic.load memarg","i32.atomic.load8_u memarg","i32.atomic.load16_u memarg","i64.atomic.load8_u memarg","i64.atomic.load16_u memarg","i64.atomic.load32_u memarg","i32.atomic.store memarg","i64.atomic.store memarg","i32.atomic.store8 memarg","i32.atomic.store16 memarg","i64.atomic.store8 memarg","i64.atomic.store16 memarg","i64.atomic.store32 memarg","i32.atomic.rmw.add memarg","i64.atomic.rmw.add memarg","i32.atomic.rmw8.add_u memarg","i32.atomic.rmw16.add_u memarg","i64.atomic.rmw8.add_u memarg","i64.atomic.rmw16.add_u memarg","i64.atomic.rmw32.add_u memarg","i32.atomic.rmw.sub memarg","i64.atomic.rmw.sub memarg","i32.atomic.rmw8.sub_u memarg","i32.atomic.rmw16.sub_u memarg","i64.atomic.rmw8.sub_u memarg","i64.atomic.rmw16.sub_u memarg","i64.atomic.rmw32.sub_u memarg","i32.atomic.rmw.and memarg","i64.atomic.rmw.and memarg","i32.atomic.rmw8.and_u memarg","i32.atomic.rmw16.and_u memarg","i64.atomic.rmw8.and_u memarg","i64.atomic.rmw16.and_u memarg","i64.atomic.rmw32.and_u memarg","i32.atomic.rmw.or memarg","i64.atomic.rmw.or memarg","i32.atomic.rmw8.or_u memarg","i32.atomic.rmw16.or_u memarg","i64.atomic.rmw8.or_u memarg","i64.atomic.rmw16.or_u memarg","i64.atomic.rmw32.or_u memarg","i32.atomic.rmw.xor memarg","i64.atomic.rmw.xor memarg","i32.atomic.rmw8.xor_u memarg","i32.atomic.rmw16.xor_u memarg","i64.atomic.rmw8.xor_u memarg","i64.atomic.rmw16.xor_u memarg","i64.atomic.rmw32.xor_u memarg","i32.atomic.rmw.xchg memarg","i64.atomic.rmw.xchg memarg","i32.atomic.rmw8.xchg_u memarg","i32.atomic.rmw16.xchg_u memarg","i64.atomic.rmw8.xchg_u memarg","i64.atomic.rmw16.xchg_u memarg","i64.atomic.rmw32.xchg_u memarg","i32.atomic.rmw.cmpxchg memarg","i64.atomic.rmw.cmpxchg memarg","i32.atomic.rmw8.cmpxchg_u memarg","i32.atomic.rmw16.cmpxchg_u memarg","i64.atomic.rmw8.cmpxchg_u memarg","i64.atomic.rmw16.cmpxchg_u memarg","i64.atomic.rmw32.cmpxchg_u memarg"]],$e=e=>{if(typeof e!="string")return null;let t=e.indexOf(".");if(t<0)return null;let i=e.slice(0,t),r=i==="i32"||i==="i64"||i==="f32"||i==="f64";return r&&/^(eqz?|ne|[lg][te])(_[su])?$/.test(e.slice(t+1))?"i32":r||i==="v128"?i:e==="memory.size"||e==="memory.grow"?"i32":null},v={custom:0,type:1,import:2,func:3,table:4,memory:5,tag:13,strings:14,global:6,export:7,start:8,elem:9,datacount:12,code:10,data:11},N={i8:120,i16:119,i32:127,i64:126,f32:125,f64:124,void:64,v128:123,exn:105,noexn:116,nofunc:115,noextern:114,none:113,func:112,extern:111,any:110,eq:109,i31:108,struct:107,array:106,data:107,cont:104,nocont:117,string:103,stringview_wtf8:102,stringview_wtf16:96,stringview_iter:97,nullfuncref:115,nullexternref:114,nullexnref:116,nullref:113,funcref:112,externref:111,exnref:105,anyref:110,eqref:109,i31ref:108,structref:107,arrayref:106,contref:104,nocontref:117,stringref:103,ref:100,refnull:99,sub:80,subfinal:79,rec:78},D={func:96,struct:95,array:94,cont:93,sub:80,subfinal:79,rec:78},ce={func:0,table:1,memory:2,global:3,tag:4};var Y=e=>{let t=0,i=[],r="",s=0,l=0,a=()=>r&&(i.push(r),r=""),f=_=>{i.loc=_;for(let n,c,x;t<e.length;)if(n=e.charCodeAt(t),s===34)r+=e[t++],n===92?r+=e[t++]:n===34&&(a(),s=0);else if(s>59)n===40&&e.charCodeAt(t+1)===59?(s++,r+=e[t++]+e[t++]):n===59&&e.charCodeAt(t+1)===41?(r+=e[t++]+e[t++],--s===59&&(a(),s=0)):r+=e[t++];else if(s<0)n===10||n===13?(r+=e[t++],a(),s=0):s===-2&&n===41?(a(),s=0):r+=e[t++];else if(n===34)r!=="$"&&a(),s=34,r+=e[t++];else if(n===40&&e.charCodeAt(t+1)===59)a(),s=60,r=e[t++]+e[t++];else if(n===59&&e.charCodeAt(t+1)===59)a(),s=e.indexOf(`
3
+ `,t)<0?-2:-1,r=e[t++]+e[t++];else if(n===40&&e.charCodeAt(t+1)===64)a(),x=t,t+=2,r="@",l++,(c=i).push(i=[]),f(x),i=c;else if(n===40)a(),x=t++,l++,(c=i).push(i=[]),f(x),i=c;else{if(n===41)return a(),t++,l--;n<=32?(a(),t++):r+=e[t++]}s<0&&a(),a()};return f(0),s===34&&h("Unclosed quote",t),s>59&&h("Unclosed block comment",t),l>0&&h("Unclosed parenthesis",t),t<e.length&&h("Unexpected closing parenthesis",t),i.length>1?i:i[0]||[]};var Ne=e=>typeof e=="string"&&(e[0]===";"||e[1]===";")||Array.isArray(e)&&e[0]?.[0]==="@"&&e[0]!=="@custom"&&!e[0]?.startsWith?.("@metadata.code."),qe=(e,t)=>typeof e=="string"?e[0]==="$"&&e[1]==='"'?e.includes("\\")?"$"+be(e.slice(1)):"$"+e.slice(2,-1):e[0]==='"'?X(e):e:Array.isArray(e)?(t=e.filter(i=>!Ne(i)).map(qe),t.loc=e.loc,t.length===1&&t[0]?.[0]==="module"?t[0]:t):e;function Ee(e,t){typeof e=="string"?(h.src=e,e=Y(e)||[]):h.src="",h.loc=0,e=Ne(e)?[]:qe(e)??[];let i=0;if(e[0]==="module"?(i++,E(e[i])&&i++):typeof e[0]=="string"&&(e=[e]),e[i]==="binary"){let g=Uint8Array.from(e.slice(++i).flat());return t?g.length:g}if(e[i]==="quote")return Ee(e.slice(++i).map(g=>g.valueOf().slice(1,-1)).flat().join(""),t);e=e.flatMap((g,$)=>{if($<i||!Array.isArray(g)||g[0]!=="import")return[g];let[,p,...d]=g;if(!d.some(u=>Array.isArray(u)&&u[0]==="item"))return[g];if(Array.isArray(d.at(-1))&&d.at(-1)[0]!=="item"){let u=d.at(-1);return d.slice(0,-1).filter(w=>w[0]==="item").map(([,w])=>["import",p,w,u])}return d.filter(u=>u[0]==="item").map(([,u,w])=>["import",p,u,w])});let r=[];for(let g in v)(r[v[g]]=r[g]=[]).name=g;r.metadata={},e.slice(i).filter(g=>{if(!Array.isArray(g)){let d=h.loc,b=h.src,u;for(;(d=b.indexOf(g,d))>=0;){if(u=b.charCodeAt(d-1),d>0&&(u>47&&u<58||u>64&&u<91||u>96&&u<123||u===95||u===36)){d++;continue}if(u=b.charCodeAt(d+g.length),u>47&&u<58||u>64&&u<91||u>96&&u<123||u===95){d++;continue}break}d>=0&&(h.loc=d),h(`Unexpected token ${g}`)}let[$,...p]=g;if(h.loc=g.loc,$==="@custom")r.custom.push(p);else if($==="rec")for(let d=0;d<p.length;d++){let[,...b]=p[d];me(b,r.type);let u=[];for(;b[0]?.[0]==="descriptor"||b[0]?.[0]==="describes";)u.push(b.shift());(b=ke(b,r)).push(d?!0:[r.type.length,p.length]),u.length&&(b.desc=b.desc?[...u,...b.desc]:u),r.type.push(b)}else if($==="type"){me(p,r.type);let d=[];for(;p[0]?.[0]==="descriptor"||p[0]?.[0]==="describes";)d.push(p.shift());let b=ke(p,r);d.length&&(b.desc=b.desc?[...d,...b.desc]:d),r.type.push(b)}else if($==="start"||$==="export")r[$].push(p);else return!0}).forEach(g=>{let[$,...p]=g;h.loc=g.loc;let d;$==="import"&&([$,...p]=(d=p).pop());let b=r[$];for(b||h(`Unknown section ${$}`),me(p,b);p[0]?.[0]==="export";)r.export.push([p.shift()[1],[$,b?.length]]);if(p[0]?.[0]==="import"&&([,...d]=p.shift()),$==="table"){let u=p[0]==="i64",w=u?1:0;if(p[w+1]?.[0]==="elem"){let[z,[,...q]]=[p[w],p[w+1]];p=u?["i64",q.length,q.length,z]:[q.length,q.length,z],r.elem.push([["table",b.length],["offset",[u?"i64.const":"i32.const",u?0n:0]],z,...q])}}else if($==="memory"){let u=p[0]==="i64",w=u?1:0;if(p[w]?.[0]==="data"){let z=p.find(P=>Array.isArray(P)&&P[0]==="pagesize")?.[1]??65536,[,...q]=p.splice(w,1)[0],C=""+Math.ceil(q.reduce((P,fe)=>P+fe.length,0)/z);r.data.push([["memory",b.length],[u?"i64.const":"i32.const",u?0n:0],...q]),p=u?["i64",C,C]:[C,C]}}else if($==="func"){let[u,w,z]=se(p,r);u??=ie(w,z,r),!d&&r.code.push([[u,w,z],...T(p,r)]),p=[["type",u]]}else if($==="tag"){let[u,w]=se(p,r);u??=ie(w,[],r),p=[["type",u]]}d&&(r.import.push([...d,[$,...p]]),p=null),b.push(p)});let s=(g,$=!0)=>{let p=r[g].filter(Boolean).map(d=>xe[g](d,r)).filter(Boolean);return g===v.custom?p.flatMap(d=>[g,...I(d)]):p.length?[g,...I($?I(p):p.flat())]:[]},l=()=>{let g=[];for(let $ in r.metadata){let p=I(X(`"metadata.code.${$}"`)),d=I(r.metadata[$].map(([b,u])=>[...o(b),...I(u.map(([w,z])=>[...o(w),...I(z)]))]));g.push(0,...I([...p,...d]))}return g},a=s(v.global),f=s(v.elem);if(t){let g=r.code.filter(Boolean).map(z=>Ze(z,r)),$=g.length?le(g.length)+g.reduce((z,q)=>z+q,0):0,p=g.length?1+le($)+$:0,d=l(),b=s(v.data),u=r.strings.length?[v.strings,...I([0,...I(r.strings.map(z=>I(z)))])]:[],w=[s(v.custom),s(v.type),s(v.import),s(v.func),s(v.table),s(v.memory),s(v.tag),u,a,s(v.export),s(v.start,!1),f,s(v.datacount,!1),d,b];return 8+p+w.reduce((z,q)=>z+q.length,0)}let _=r.code.filter(Boolean).map(g=>xe[v.code](g,r)).filter(Boolean),n=_.length?[v.code,...I(I(_))]:[],c=l(),x=s(v.data),U=r.strings.length?[v.strings,...I([0,...I(r.strings.map(g=>I(g)))])]:[],A=[s(v.custom),s(v.type),s(v.import),s(v.func),s(v.table),s(v.memory),s(v.tag),U,a,s(v.export),s(v.start,!1),f,s(v.datacount,!1),n,c,x],k=Uint8Array.from([0,97,115,109,1,0,0,0,...A.flat()]),y=O();return y&&(k.metadata=y),k;function O(){let g=!1;for(let w in r.metadata)g=!0;if(!g)return;let $={},d=8+A.slice(0,A.indexOf(n)).reduce((w,z)=>w+z.length,0)+n.length-_.reduce((w,z)=>w+z.length,0),b=[];for(let w=0,z=d;w<_.length;w++)b[w]=z+(r.codeSizePrefix?.[w]??0),z+=_[w].length;let u=r.import.filter(w=>w[2][0]==="func").length;for(let w in r.metadata){let z=[];for(let[q,C]of r.metadata[w]){let P=b[q-u];for(let[fe,Te]of C)z.push([P+fe,Te])}$[w]=z.sort((q,C)=>q[0]-C[0])}return $}}function pe(e){return Ee(e)}var M=e=>e?.[0]==="$"||!isNaN(e),E=e=>e?.[0]==="$",_e=e=>e?.[0]==="a"||e?.[0]==="o";function T(e,t){let i=[];for(e=[...e];e.length;){let r=e.shift();if(typeof r=="string")if(i.push(r),r==="block"||r==="if"||r==="loop")E(e[0])&&i.push(e.shift()),i.push(J(e,t));else if(r==="else"||r==="end")E(e[0])&&e.shift();else if(r==="select")i.push(re(e)[1]);else if(r.endsWith("call_indirect")){let s=M(e[0])?e.shift():0,[l,a,f]=se(e,t);i.push(s,["type",l??ie(a,f,t)])}else r==="table.init"?i.push(M(e[1])?e.shift():0,e.shift()):r==="table.copy"||r==="memory.copy"?i.push(M(e[0])?e.shift():0,M(e[0])?e.shift():0):r.startsWith("table.")?i.push(M(e[0])?e.shift():0):r==="memory.init"?(i.push(...M(e[1])?[e.shift(),e.shift()].reverse():[e.shift(),0]),t.datacount&&(t.datacount[0]=!0)):r==="data.drop"||r==="array.new_data"||r==="array.init_data"?(r==="data.drop"&&i.push(e.shift()),t.datacount&&(t.datacount[0]=!0)):(r.startsWith("memory.")||r.endsWith("load")||r.endsWith("store"))&&M(e[0])&&i.push(e.shift());else if(Array.isArray(r)){let s=r[0];if(r.loc!=null&&(h.loc=r.loc),s?.startsWith?.("@metadata.code.")){let a=s.slice(15);i.push(["@metadata",a,r[1]]);continue}if(typeof s!="string"||!Array.isArray(V[s])){i.push(r);continue}let l=r.slice(1);if(s==="block"||s==="loop")i.push(s),E(l[0])&&i.push(l.shift()),i.push(J(l,t),...T(l,t),"end");else if(s==="if"){let a=[],f=[];l.at(-1)?.[0]==="else"&&(f=T(l.pop().slice(1),t)),l.at(-1)?.[0]==="then"&&(a=T(l.pop().slice(1),t));let _=[s];E(l[0])&&_.push(l.shift()),_.push(J(l,t)),i.push(...T(l,t),..._,...a),f.length&&i.push("else",...f),i.push("end")}else if(s==="try_table"){for(i.push(s),E(l[0])&&i.push(l.shift()),i.push(J(l,t));l[0]?.[0]==="catch"||l[0]?.[0]==="catch_ref"||l[0]?.[0]==="catch_all"||l[0]?.[0]==="catch_all_ref";)i.push(l.shift());i.push(...T(l,t),"end")}else if(s==="ref.test"||s==="ref.cast"){let a=l[0];(!Array.isArray(a)||a[1]==="null"||a[0]!=="ref")&&(s+="_null"),i.push(...T(l.slice(1),t),s,a),e.unshift(...i.splice(i.length-2))}else{let a=[];for(;l.length&&(!Array.isArray(l[0])||l[0].valueOf!==Array.prototype.valueOf||"type,param,result,ref,exact,on".includes(l[0][0]));)a.push(l.shift());i.push(...T(l,t),s,...a),e.unshift(...i.splice(i.length-1-a.length))}}else i.push(r)}return i}var ie=(e,t,i,r="$"+e+">"+t)=>(i.type[r]??=i.type.push(["func",[e,t]])-1,r),ue=(e,t)=>{let i=[];for(;e[0]?.[0]===t;){let[,...r]=e.shift(),s=E(r[0])&&r.shift();s&&(s in i?(()=>{throw Error(`Duplicate ${t} ${s}`)})():i[s]=i.length),i.push(...r)}return i},re=e=>{let t=ue(e,"param"),i=ue(e,"result");if(e[0]?.[0]==="param")throw Error("Unexpected param");return[t,i]},se=(e,t)=>{if(e[0]?.[0]!=="type")return[,...re(e)];let[,i]=e.shift(),[r,s]=re(e),l=t.type[typeof i=="string"&&isNaN(i)?t.type[i]:+i];if(!l)throw Error(`Unknown type ${i}`);if((r.length||s.length)&&l[1].join(">")!==r+">"+s)throw Error(`Type ${i} mismatch`);return[i,...l[1]]},J=(e,t)=>{let[i,r,s]=se(e,t);if(!(!r.length&&!s.length))return!r.length&&s.length===1?["result",...s]:["type",i??ie(r,s,t)]},me=(e,t)=>{let i=E(e[0])&&e.shift();return i&&(i in t?h(`Duplicate ${t.name} ${i}`):t[i]=t.length),i},ke=([e],t)=>{let i="subfinal",r=[],s,l=[];e[0]==="sub"&&(i=e.shift(),e[0]==="final"&&(i+=e.shift()),e=(r=e).pop(),r=r.filter(f=>Array.isArray(f)&&(f[0]==="descriptor"||f[0]==="describes")?(l.push(f),!1):!0)),[s,...e]=e,s==="func"?(e=re(e),t.type["$"+e.join(">")]??=t.type.length):s==="struct"?e=ue(e,"field"):s==="array"&&([e]=e);let a=[s,e,i,r];return l.length&&(a.desc=l),a},xe=[([e,...t],i)=>{let r=t;return(t[0]?.[0]==="before"||t[0]?.[0]==="after")&&(r=t.slice(1)),[...I(e),...r.flat()]},(e,t)=>{let[i,r,s,l,a]=e;if(a===!0)return;let f=(e.desc??[]).flatMap(([n,c])=>[n==="descriptor"?77:76,...o(m(c,t.type))]),_=(n,c)=>n==="func"?[D.func,...I(c[0].map(x=>F(x,t))),...I(c[1].map(x=>F(x,t)))]:n==="array"?[D.array,...Z(c,t)]:n==="struct"?[D.struct,...I(c.map(x=>Z(x,t)))]:n==="cont"?[D.cont,...o(m(c[0]??c,t.type))]:[D[n]];if(a){let[n,c]=a,x=Array.from({length:c},(U,A)=>{let k=t.type[n+A],y=k.slice(0,4);return k.desc&&(y.desc=k.desc),xe[v.type](y,t)});return[D.rec,...I(x)]}else if(s==="sub"||l?.length)return[D[s],...I(l.map(n=>m(n,t.type))),...f,..._(i,r)];return[...f,..._(i,r)]},([e,t,[i,...r]],s)=>{let l,a=ce[i];if(i==="func"){r[0]==="exact"&&r.shift()&&(a=32);let[[,_]]=r;l=o(m(_,s.type))}else if(i==="tag"){let[[,f]]=r;l=[0,...o(m(f,s.type))]}else i==="memory"?l=ee(r):i==="global"?l=Z(r[0],s):i==="table"?l=[...F(r.pop(),s),...ee(r)]:h(`Unknown kind ${i}`);return[...I(e),...I(t),a,...l]},([[,e]],t)=>o(m(e,t.type)),(e,t)=>{let i=ee(e),r=F(e.shift(),t),[s]=e;return s?[64,0,...r,...i,...G(s,t)]:[...r,...i]},(e,t)=>ee(e),([e,t],i)=>[...Z(e,i),...G(t,i)],([e,[t,i]],r)=>[...I(e),ce[t],...o(m(i,r[t]))],([e],t)=>o(m(e,t.func)),(e,t)=>{let i=0,r=0,s=0,l=0,a,f,_;e[0]==="declare"&&(e.shift(),r=1),e[0]?.[0]==="table"?([,a]=e.shift(),a=m(a,t.table)):(typeof e[0]=="string"||typeof e[0]=="number")&&(e[1]?.[0]==="offset"||Array.isArray(e[1])&&e[1][0]!=="item"&&!e[1][0]?.startsWith("ref"))&&(a=m(e.shift(),t.table)),e[0]?.[0]==="offset"||Array.isArray(e[0])&&e[0][0]!=="item"&&!e[0][0].startsWith("ref")?(f=e.shift(),f[0]==="offset"&&([,f]=f),f=G(f,t)):r||(i=1),N[e[0]]||e[0]?.[0]==="ref"?_=F(e.shift(),t):e[0]==="func"?_=[N[e.shift()]]:_=[N.func],e=e.map(c=>(c[0]==="item"&&(c=c.length===3&&c[1]==="ref.func"?c[2]:c[1]),c[0]==="ref.func"&&([,c]=c),typeof c!="string"&&(s=1),c)),_[0]!==N.funcref&&(l=1,s=1);let n=s<<2|(i||r?r:!!a||l)<<1|(i||r);return[n,...n===0?f:n===1?[0]:n===2?[...o(a||0),...f,0]:n===3?[0]:n===4?f:n===5?_:n===6?[...o(a||0),...f,..._]:_,...I(e.map(s?c=>G(typeof c=="string"?["ref.func",c]:c,t):c=>o(m(c,t.func))))]},(e,t)=>{let[i,r]=e.shift();r||([,[r]]=t.type[m(i,t.type)]),t.local=Object.create(r),t.block=[],t.local.name="local",t.block.name="block",t._codeIdx===void 0&&(t._codeIdx=0);let s=t._codeIdx++;for(;e[0]?.[0]==="local";){let[,...c]=e.shift();if(E(c[0])){let x=c.shift();x in t.local?h(`Duplicate local ${x}`):t.local[x]=t.local.length}t.local.push(...c)}t.meta={};let l=Be(e,t),a=t.local.slice(r.length).reduce((c,x)=>(x==c[c.length-1]?.[1]?c[c.length-1][0]++:c.push([1,x]),c),[]),f=I(a.map(([c,x])=>[...o(c),...F(x,t)])),_=t.import.filter(c=>c[2][0]==="func").length+s;for(let c in t.meta){for(let x of t.meta[c])x[0]+=f.length;((t.metadata??={})[c]??=[]).push([_,t.meta[c]])}t.local=t.block=t.meta=null;let n=I([...f,...l]);return(t.codeSizePrefix??=[])[s]=n.length-f.length-l.length,n},(e,t)=>{let i,r=0;return e[0]?.[0]==="memory"?([,r]=e.shift(),r=m(r,t.memory)):(typeof e[0]=="string"||typeof e[0]=="number")&&(e[1]?.[0]==="offset"||Array.isArray(e[1])&&typeof e[1][0]=="string")&&(r=m(e.shift(),t.memory)),Array.isArray(e[0])&&typeof e[0]?.[0]=="string"&&(i=e.shift(),i[0]==="offset"&&([,i]=i),i??h("Bad offset",i)),[...r?[2,...o(r),...G(i,t)]:i?[0,...G(i,t)]:[1],...I(e.flatMap(s=>it(s)??[...s]))]},(e,t)=>o(t.data.length),([[,e]],t)=>[0,...o(m(e,t.type))]],F=(e,t)=>e[0]==="ref"?e[1]=="null"?Array.isArray(e[2])&&e[2][0]==="exact"?[N.refnull,98,...o(m(e[2][1],t.type))]:N[e[2]]?[N[e[2]]]:[N.refnull,...o(m(e[e.length-1],t.type))]:Array.isArray(e[1])&&e[1][0]==="exact"?[N.ref,98,...o(m(e[1][1],t.type))]:[N.ref,...o(N[e[e.length-1]]||m(e[e.length-1],t.type))]:[N[e]??h(`Unknown type ${e}`)],Z=(e,t,i=e[0]==="mut"?1:0)=>[...F(i?e[1]:e,t),i],Ue={null:()=>[],reversed:(e,t)=>{let i=e.shift(),r=e.shift();return[...o(m(r,t.elem)),...o(m(i,t.table))]},block:(e,t)=>{t.block.push(1),E(e[0])&&(t.block[e.shift()]=t.block.length);let i=e.shift();return i?i[0]==="result"?F(i[1],t):o(m(i[1],t.type)):[N.void]},try_table:(e,t)=>{E(e[0])&&(t.block[e.shift()]=t.block.length+1);let i=e.shift(),r=i?i[0]==="result"?F(i[1],t):o(m(i[1],t.type)):[N.void],s=[],l=0;for(;e[0]?.[0]==="catch"||e[0]?.[0]==="catch_ref"||e[0]?.[0]==="catch_all"||e[0]?.[0]==="catch_all_ref";){let a=e.shift(),f=a[0]==="catch"?0:a[0]==="catch_ref"?1:a[0]==="catch_all"?2:3;f<=1?s.push(f,...o(m(a[1],t.tag)),...o(W(a[2],t.block))):s.push(f,...o(W(a[1],t.block))),l++}return t.block.push(1),[...r,...o(l),...s]},end:(e,t)=>(t.block.pop(),[]),call_indirect:(e,t)=>{let i=e.shift(),[,r]=e.shift();return[...o(m(r,t.type)),...o(m(i,t.table))]},br_table:(e,t)=>{let i=[],r=0;for(;e[0]&&(!isNaN(e[0])||E(e[0]));)i.push(...o(W(e.shift(),t.block))),r++;return[...o(r-1),...i]},select:(e,t)=>{let i=e.shift()||[];return i.length?I(i.map(r=>F(r,t))):[]},ref_null:(e,t)=>{let i=e.shift();return Array.isArray(i)&&i[0]==="exact"?[98,...o(m(i[1],t.type))]:N[i]?[N[i]]:o(m(i,t.type))},memarg:(e,t,i)=>ze(e,i,M(e[0])&&!_e(e[0])?m(e.shift(),t.memory):0),opt_memory:(e,t)=>o(m(M(e[0])?e.shift():0,t.memory)),reftype:(e,t)=>{let i=F(e.shift(),t);return i.length>1?i.slice(1):i},reftype2:(e,t)=>{let i=W(e.shift(),t.block),r=F(e.shift(),t),s=F(e.shift(),t),l=a=>a.length>1?a.slice(1):a;return[(s[0]!==N.ref)<<1|r[0]!==N.ref,...o(i),...l(r),...l(s)]},v128const:e=>{let[t,i]=e.shift().split("x"),r=+t.slice(1),s=r>>>3;if(i=+i,t[0]==="i"){let a=i===16?new Uint8Array(16):i===8?new Uint16Array(8):i===4?new Uint32Array(4):new BigUint64Array(2);for(let f=0;f<i;f++)a[f]=H[t].parse(e.shift());return[...new Uint8Array(a.buffer)]}let l=new Uint8Array(16);for(let a=0;a<i;a++)l.set(H[t](e.shift()),a*s);return[...l]},shuffle:e=>{let t=[];for(let i=0;i<16;i++)t.push(te(e.shift(),32));return typeof e[0]=="string"&&!isNaN(e[0])&&h("invalid lane length"),t},memlane:(e,t,i)=>{let r=E(e[0])||M(e[0])&&(_e(e[1])||M(e[1]))?m(e.shift(),t.memory):0;return[...ze(e,i,r),...o(te(e.shift()))]},"*":e=>o(e.shift()),labelidx:(e,t)=>o(W(e.shift(),t.block)),laneidx:e=>[te(e.shift(),255)],funcidx:(e,t)=>o(m(e.shift(),t.func)),typeidx:(e,t)=>o(m(e.shift(),t.type)),tableidx:(e,t)=>o(m(e.shift(),t.table)),memoryidx:(e,t)=>o(m(e.shift(),t.memory)),globalidx:(e,t)=>o(m(e.shift(),t.global)),localidx:(e,t)=>o(m(e.shift(),t.local)),dataidx:(e,t)=>o(m(e.shift(),t.data)),elemidx:(e,t)=>o(m(e.shift(),t.elem)),tagidx:(e,t)=>o(m(e.shift(),t.tag)),"memoryidx?":(e,t)=>o(m(M(e[0])?e.shift():0,t.memory)),stringidx:(e,t)=>{let i=e.shift(),r=i.valueOf(),s=t.strings.findIndex(l=>l.valueOf()===r);return s<0&&(s=t.strings.push(i)-1),o(s)},i32:e=>B(e.shift()),i64:e=>j(e.shift()),f32:e=>R(e.shift()),f64:e=>L(e.shift()),v128:e=>oe(e.shift()),typeidx_field:(e,t)=>{let i=m(e.shift(),t.type);return[...o(i),...o(m(e.shift(),t.type[i][1]))]},typeidx_multi:(e,t)=>[...o(m(e.shift(),t.type)),...o(e.shift())],typeidx_dataidx:(e,t)=>[...o(m(e.shift(),t.type)),...o(m(e.shift(),t.data))],typeidx_elemidx:(e,t)=>[...o(m(e.shift(),t.type)),...o(m(e.shift(),t.elem))],typeidx_typeidx:(e,t)=>[...o(m(e.shift(),t.type)),...o(m(e.shift(),t.type))],dataidx_memoryidx:(e,t)=>[...o(m(e.shift(),t.data)),...o(m(e.shift(),t.memory))],memoryidx_memoryidx:(e,t)=>[...o(m(e.shift(),t.memory)),...o(m(e.shift(),t.memory))],tableidx_tableidx:(e,t)=>[...o(m(e.shift(),t.table)),...o(m(e.shift(),t.table))],cont_bind:(e,t)=>[...o(m(e.shift(),t.type)),...o(m(e.shift(),t.type))],switch_cont:(e,t)=>[...o(m(e.shift(),t.type)),...o(m(e.shift(),t.tag))],resume:(e,t)=>{let i=o(m(e.shift(),t.type)),r=[],s=0;for(;e[0]?.[0]==="on";){let[,l,a]=e.shift();a==="switch"?r.push(1,...o(m(l,t.tag))):r.push(0,...o(m(l,t.tag)),...o(W(a,t.block))),s++}return[...i,...o(s),...r]},resume_throw:(e,t)=>{let i=o(m(e.shift(),t.type)),r=o(m(e.shift(),t.tag)),s=[],l=0;for(;e[0]?.[0]==="on";){let[,a,f]=e.shift();f==="switch"?s.push(1,...o(m(a,t.tag))):s.push(0,...o(m(a,t.tag)),...o(W(f,t.block))),l++}return[...i,...r,...o(l),...s]},resume_throw_ref:(e,t)=>{let i=o(m(e.shift(),t.type)),r=[],s=0;for(;e[0]?.[0]==="on";){let[,l,a]=e.shift();a==="switch"?r.push(1,...o(m(l,t.tag))):r.push(0,...o(m(l,t.tag)),...o(W(a,t.block))),s++}return[...i,...o(s),...r]}},K={};(function e(t,i){for(let r=0,s,l,a;r<t.length;r++)(s=t[r])&&(Array.isArray(s)?e(s,r):([l,a]=s.split(" "),V[l]=i?[i,...o(r)]:[r],a&&(K[l]=Ue[a])))})(V);var Be=(e,t)=>{let i=[],r=[];for(;e?.length;){let s=e.shift();if(s?.[0]==="@metadata"){r.push(s.slice(1));continue}Array.isArray(s)&&(s.loc!=null&&(h.loc=s.loc),h(`Unknown instruction ${s[0]}`));let[...l]=V[s]||h(`Unknown instruction ${s}`);if(K[s]&&(s==="select"&&e[0]?.length?l[0]++:K[s]===Ue.reftype&&!s.endsWith("_null")&&(e[0][1]==="null"||e[0][0]!=="ref")&&l[l.length-1]++,l.push(...K[s](e,t,s))),r.length){for(let[a,f]of r)(t.meta[a]??=[]).push([i.length,f]);r=[]}i.push(...l)}return i.push(11),i},le=e=>o(e).length,Je=(e,t)=>{let i=0,r=[];for(;e?.length;){let s=e.shift();if(s?.[0]==="@metadata"){r.push(s.slice(1));continue}Array.isArray(s)&&(s.loc!=null&&(h.loc=s.loc),h(`Unknown instruction ${s[0]}`));let a=(V[s]||h(`Unknown instruction ${s}`)).length;if(K[s]&&(a+=K[s](e,t,s).length),r.length){for(let[f,_]of r)(t.meta[f]??=[]).push([i,_]);r=[]}i+=a}return i+1},Ze=(e,t)=>{let[i,r]=e.shift();r||([,[r]]=t.type[m(i,t.type)]),t.local=Object.create(r),t.block=[],t.local.name="local",t.block.name="block",t._codeIdx===void 0&&(t._codeIdx=0);let s=t._codeIdx++;for(;e[0]?.[0]==="local";){let[,...c]=e.shift();if(E(c[0])){let x=c.shift();x in t.local?h(`Duplicate local ${x}`):t.local[x]=t.local.length}t.local.push(...c)}t.meta={};let l=Je(e,t),a=t.local.slice(r.length).reduce((c,x)=>(x==c[c.length-1]?.[1]?c[c.length-1][0]++:c.push([1,x]),c),[]),f=I(a.map(([c,x])=>[...o(c),...F(x,t)])),_=t.import.filter(c=>c[2][0]==="func").length+s;for(let c in t.meta){for(let x of t.meta[c])x[0]+=f.length;((t.metadata??={})[c]??=[]).push([_,t.meta[c]])}t.local=t.block=t.meta=null;let n=f.length+l;return(t.codeSizePrefix??=[])[s]=le(n),le(n)+n},G=(e,t)=>Be(T([e],t),t),m=(e,t,i)=>(i=E(e)?t[e]:+e,i in t?i:h(`Unknown ${t.name} ${e}`)),W=(e,t,i)=>(i=E(e)?t.length-t[e]:+e,isNaN(i)||i>t.length?h(`Bad label ${e}`):i),et=e=>{let t,i,r,s;for(;_e(e[0]);)[r,s]=e.shift().split("="),r==="offset"?i=+s:r==="align"?t=+s:h(`Unknown param ${r}=${s}`);return(i<0||i>4294967295)&&h(`Bad offset ${i}`),(t<=0||t>4294967295)&&h(`Bad align ${t}`),t&&(t=Math.log2(t))%1&&h(`Bad align ${t}`),[t,i]},ze=(e,t,i=0)=>{let[r,s]=et(e),l=(r??tt(t))|(i&&64);return i?[...o(l),...o(i),...o(s??0)]:[...o(l),...o(s??0)]},tt=e=>{let t=e.indexOf(".",3)+1,i=e.slice(1,e[0]==="v"?4:3);if(e[t]==="a"&&(t=e.indexOf(".",t)+1),e[0]==="m")return e.includes("64")?3:2;if(e[t]==="r"){let l=e.slice(t,t+6).match(/\d+/);return Math.log2(l?l[0]/8:+i/8)}let r=e[t]==="l"?t+4:t+5,s=e.slice(r).match(/(\d+)(x|_|$)/);return Math.log2(s?s[2]==="x"?8:s[1]/8:+i/8)},it=e=>{if(!Array.isArray(e))return null;let[t,...i]=e;if(t!=="i8"&&t!=="i16"&&t!=="i32"&&t!=="i64"&&t!=="f32"&&t!=="f64")return null;let r=[],s=new DataView(new ArrayBuffer(8));for(let l of i)t==="i8"?r.push(B.parse(l)&511&255):t==="i16"?(s.setInt16(0,B.parse(l),!0),r.push(...new Uint8Array(s.buffer,0,2))):t==="i32"?(s.setInt32(0,B.parse(l),!0),r.push(...new Uint8Array(s.buffer,0,4))):t==="i64"?(s.setBigInt64(0,BigInt(l),!0),r.push(...new Uint8Array(s.buffer,0,8))):t==="f32"?r.push(...R(l)):t==="f64"&&r.push(...L(l));return r},ee=e=>{let t=e[0]==="i64"&&e.shift(),i=e[e.length-1]==="shared"&&e.pop(),r=e.findIndex(n=>Array.isArray(n)&&n[0]==="pagesize"),s=-1;r>=0&&(s=Math.log2(+e.splice(r,1)[0][1]));let l=!isNaN(parseInt(e[1])),a=(s>=0?8:0)|(t?4:0)|(i?2:0)|(l?1:0),f=t?n=>{if(typeof n=="bigint")return n;let c=typeof n=="string"?n.replaceAll("_",""):String(n);return BigInt(c)}:te,_=s>=0?o(s):[];return l?[a,...o(f(e.shift())),...o(f(e.shift())),..._]:[a,...o(f(e.shift())),..._]},te=(e,t=4294967295)=>{let i=typeof e=="string"&&e[0]!=="+"?B.parse(e):typeof e=="number"?e:h(`Bad int ${e}`);return i>t?h(`Value out of range ${e}`):i},I=e=>[...o(e.length),...e.flat()];function Fe(e,t={}){typeof e=="string"&&(e=Y(e));let{indent:i=" ",newline:r=`
4
+ `,comments:s=!0}=t;if(i||="",r||="",typeof e[0]=="string"&&e[0][0]!==";")return a(e);return e.filter(f=>s||!l(f)).map(f=>a(f)).join(r);function l(f){return typeof f=="string"&&f[1]===";"}function a(f,_=0){if(!Array.isArray(f))return f;let n=f[0];if(!n)return"";let c=!1;if(n==="try_table"){let A=1;for(typeof f[A]=="string"&&f[A][0]==="$"&&(n+=" "+f[A++]),Array.isArray(f[A])&&(f[A][0]==="result"||f[A][0]==="type")&&(n+=" "+a(f[A++],_));Array.isArray(f[A])&&/^catch/.test(f[A][0]);)n+=" "+a(f[A++],_).trim();for(;A<f.length;A++)n+=Array.isArray(f[A])?r+i.repeat(_+1)+a(f[A],_+1):" "+f[A];return`(${n+r+i.repeat(_)})`}let x=!!r&&f.length<4&&!f.some(A=>typeof A=="string"&&A[0]===";"&&A[1]===";"),U=i.repeat(_+1);for(let A=1;A<f.length;A++){let k=f[A]?.valueOf?.()??f[A];if(typeof k=="string"&&k[1]===";"){if(!s)continue;if(k[0]===";")if(r)n+=r+U+k.trimEnd(),c=!0;else{let y=n[n.length-1];y&&y!==" "&&y!=="("&&(n+=" "),n+=k.trimEnd()+`
5
+ `}else{let y=n[n.length-1];y&&y!==" "&&y!=="("&&(n+=" "),n+=k.trimEnd()}}else if(Array.isArray(k))x&&(x=k.every(y=>!Array.isArray(y))),n+=r+U+a(k,_+1),c=!1;else if(f[0]==="data")x=!1,(r||n[n.length-1]!==")")&&(n+=r||" "),n+=U+k,c=!1;else{let y=n[n.length-1];c&&r?n+=r+U:y===`
6
+ `?n+="":(y&&y!==")"&&y!==" "||r||y===")")&&(n+=" "),n+=k,c=!1}}return x?`(${n.replaceAll(r+U+"("," (")})`:`(${n+r+i.repeat(_)})`}}var Se="\uE000";function ae(e,t,i,r){if(typeof e!="function")throw Error(`watr: '${t}' is not bundled in this entry \u2014 import it from 'watr/${t}' and compose: compile(${t}(src))`);return e(i,r)}var rt=(e,t={})=>{if(!Array.isArray(e))return typeof e=="string"&&e[0]==="$"&&t.locals?.[e]?t.locals[e]:null;let[i,...r]=e,s=$e(i);return s||(i==="local.get"&&t.locals?.[r[0]]?t.locals[r[0]]:i==="call"&&t.funcs?.[r[0]]?t.funcs[r[0]].result?.[0]:null)};function he(e,t){if(e=t(e),Array.isArray(e))for(let i=0;i<e.length;i++){let r=he(e[i],t);r?._splice?(e.splice(i,1,...r),i+=r.length-1):e[i]=r}return e}function st(e,t){let i=[],r=new Map;return he(e,s=>{if(!Array.isArray(s))return s;if(s[0]==="call"&&typeof s[1]=="function"){let l=s[1];if(!r.has(l)){let f=[];for(let c=2;c<s.length;c++){let x=rt(s[c]);x&&f.push(x)}let _=i.length,n=l.name||`$fn${_}`;r.set(l,{idx:_,name:n.startsWith("$")?n:"$"+n,params:f,fn:l}),i.push(r.get(l))}let a=r.get(l);s[1]=a.name}return s}),i}function lt(e){return e.map(({name:t,params:i})=>["import",'"env"',`"${t.slice(1)}"`,["func",t,...i.map(r=>["param",r])]])}function ge(e,t,i){let{parse:r,compile:s,optimize:l,polyfill:a}=e,f={};if(!Array.isArray(t)&&i.length&&typeof i[i.length-1]=="object"&&i[i.length-1]!==null&&!i[i.length-1].byteLength&&(f=i.pop()),Array.isArray(t)&&t.raw){let _=t[0];for(let k=0;k<i.length;k++)_+=Se+t[k+1];let n=r(_),c=[],x=0;n=he(n,k=>{if(k===Se){let y=i[x++];if(typeof y=="function")return c.push(y),y;if(typeof y=="string"&&(y[0]==="("||/^\s*\(/.test(y))){let O=r(y);return Array.isArray(O)&&Array.isArray(O[0])&&(O._splice=!0),O}return y?.byteLength!==void 0?[...y]:typeof y=="bigint"?y.toString():y}return k});let U=null;if(c.length){let k=st(n,c);if(k.length){let y=lt(k);n[0]==="module"?n.splice(1,0,...y):typeof n[0]=="string"?n=[...y,n]:n.unshift(...y),U={env:{}};for(let O of k)U.env[O.name.slice(1)]=O.fn}}f.polyfill&&(n=ae(a,"polyfill",n,f.polyfill)),f.optimize&&(n=ae(l,"optimize",n,f.optimize));let A=s(n);return U&&(A._imports=U),A}if(f.polyfill||f.optimize){let _=typeof t=="string"?r(t):t;return f.polyfill&&(_=ae(a,"polyfill",_,f.polyfill)),f.optimize&&(_=ae(l,"optimize",_,f.optimize)),s(_)}return s(t)}function Me(e,t,i){let r=ge(e,t,i),s=new WebAssembly.Module(r);return new WebAssembly.Instance(s,r._imports).exports}var Oe={parse:Y,compile:pe};function zt(e,...t){return ge(Oe,e,t)}function at(e,...t){return Me(Oe,e,t)}var Nt=at;export{zt as compile,Nt as default,Y as parse,Fe as print,at as watr};
package/dist/watr.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "watr",
3
- "version": "4.7.2",
3
+ "version": "5.0.0",
4
4
  "description": "Light & fast WAT compiler – WebAssembly Text to binary, parse, print, transform",
5
5
  "main": "watr.js",
6
6
  "bin": {
@@ -27,6 +27,10 @@
27
27
  "types": "./types/src/compile.d.ts",
28
28
  "default": "./src/compile.js"
29
29
  },
30
+ "./polyfill": {
31
+ "types": "./types/src/polyfill.d.ts",
32
+ "default": "./src/polyfill.js"
33
+ },
30
34
  "./optimize": {
31
35
  "types": "./types/src/optimize.d.ts",
32
36
  "default": "./src/optimize.js"
@@ -42,6 +46,12 @@
42
46
  ],
43
47
  "compile": [
44
48
  "./types/src/compile.d.ts"
49
+ ],
50
+ "polyfill": [
51
+ "./types/src/polyfill.d.ts"
52
+ ],
53
+ "optimize": [
54
+ "./types/src/optimize.d.ts"
45
55
  ]
46
56
  }
47
57
  },
package/readme.md CHANGED
@@ -4,7 +4,7 @@
4
4
  _Light & fast WAT compiler_
5
5
 
6
6
  * [feature](https://webassembly.org/features/?categories=browsers%2Cstandalones%2Ctools) & [spec](https://webassembly.github.io/spec/core/text/index.html)-complete, zero deps
7
- * [compile](./docs.md#compilesource-options) · [polyfill](./docs.md#polyfillast-options) · [optimize](./docs.md#optimizeast-options) · [parse](./docs.md#parsesource-options) · [prettify](./docs.md#printtree-options) · [minify](./docs.md#printtree-options)
7
+ * [compile](./docs.md#compilesource) · [polyfill](./docs.md#polyfillast-options) · [optimize](./docs.md#optimizeast-options) · [parse](./docs.md#parsesource-options) · [prettify](./docs.md#printtree-options) · [minify](./docs.md#printtree-options)
8
8
  * instant wasm, JS interop, CLI, clear errors
9
9
 
10
10
  **[docs](./docs.md)**  **·**  **[demo](https://dy.github.io/watr/play/)**
@@ -19,13 +19,16 @@ _Light & fast WAT compiler_
19
19
  import watr, { compile, parse, print } from 'watr'
20
20
 
21
21
  // compile to binary
22
- const binary = compile('(func (export "f") (result f64) (f64.const 1))', {
23
- polyfill: false, // transform newer features to MVP
24
- optimize: true // fold constants, treeshake, eliminate dead code ...
25
- })
22
+ const src = '(func (export "f") (result f64) (f64.const 1))'
23
+ const binary = compile(src)
26
24
  const module = new WebAssembly.Module(binary)
27
25
  const { f } = new WebAssembly.Instance(module).exports
28
26
 
27
+ // optional, heavy transforms ship as separate entries — compose them
28
+ import optimize from 'watr/optimize' // fold constants, treeshake, eliminate dead code …
29
+ import polyfill from 'watr/polyfill' // newer features → MVP
30
+ compile(optimize(polyfill(src)))
31
+
29
32
  // parse
30
33
  parse('(i32.const 42)') // ['i32.const', 42]
31
34
 
@@ -56,7 +59,7 @@ npx watr input.wat --polyfill # newer features → MVP
56
59
 
57
60
  ## Metrics
58
61
 
59
- * **watr** — ~84 KB minified (~24 KB gzipped), 4,460 op/s
62
+ * **watr** — ~43 KB minified (~14 KB gzipped), 4,460 op/s
60
63
  * [spec/wast.js](https://github.com/WebAssembly/spec) — 216 KB, 2,185 op/s
61
64
  * [wabt](https://github.com/WebAssembly/wabt) — 282 KB, 1,273 op/s
62
65
  * [binaryen](https://github.com/WebAssembly/binaryen) — 1,100 KB, 718 op/s