webr
Version:
The statistical programming language R compiled into WASM for use in a web browser and node.
2 lines • 133 kB
JavaScript
"use strict";(()=>{var ki=Object.create;var ts=Object.defineProperty;var Ti=Object.getOwnPropertyDescriptor;var Ai=Object.getOwnPropertyNames;var Di=Object.getPrototypeOf,Pi=Object.prototype.hasOwnProperty;var Q=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(r,t)=>(typeof require<"u"?require:r)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var H=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var Mi=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Ai(r))!Pi.call(e,s)&&s!==t&&ts(e,s,{get:()=>r[s],enumerable:!(n=Ti(r,s))||n.enumerable});return e};var rs=(e,r,t)=>(t=e!=null?ki(Di(e)):{},Mi(r||!e||!e.__esModule?ts(t,"default",{value:e,enumerable:!0}):t,e));var Ot=H(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.getUint64=ne.getInt64=ne.setInt64=ne.setUint64=ne.UINT32_MAX=void 0;ne.UINT32_MAX=4294967295;function Wi(e,r,t){let n=t/4294967296,s=t;e.setUint32(r,n),e.setUint32(r+4,s)}ne.setUint64=Wi;function Ci(e,r,t){let n=Math.floor(t/4294967296),s=t;e.setUint32(r,n),e.setUint32(r+4,s)}ne.setInt64=Ci;function Fi(e,r){let t=e.getInt32(r),n=e.getUint32(r+4);return t*4294967296+n}ne.getInt64=Fi;function Li(e,r){let t=e.getUint32(r),n=e.getUint32(r+4);return t*4294967296+n}ne.getUint64=Li});var lr=H(V=>{"use strict";var Zr,Jr,Xr;Object.defineProperty(V,"__esModule",{value:!0});V.utf8DecodeTD=V.TEXT_DECODER_THRESHOLD=V.utf8DecodeJs=V.utf8EncodeTE=V.TEXT_ENCODER_THRESHOLD=V.utf8EncodeJs=V.utf8Count=void 0;var fs=Ot(),or=(typeof process>"u"||((Zr=process==null?void 0:process.env)===null||Zr===void 0?void 0:Zr.TEXT_ENCODING)!=="never")&&typeof TextEncoder<"u"&&typeof TextDecoder<"u";function Bi(e){let r=e.length,t=0,n=0;for(;n<r;){let s=e.charCodeAt(n++);if((s&4294967168)===0){t++;continue}else if((s&4294965248)===0)t+=2;else{if(s>=55296&&s<=56319&&n<r){let a=e.charCodeAt(n);(a&64512)===56320&&(++n,s=((s&1023)<<10)+(a&1023)+65536)}(s&4294901760)===0?t+=3:t+=4}}return t}V.utf8Count=Bi;function zi(e,r,t){let n=e.length,s=t,a=0;for(;a<n;){let i=e.charCodeAt(a++);if((i&4294967168)===0){r[s++]=i;continue}else if((i&4294965248)===0)r[s++]=i>>6&31|192;else{if(i>=55296&&i<=56319&&a<n){let o=e.charCodeAt(a);(o&64512)===56320&&(++a,i=((i&1023)<<10)+(o&1023)+65536)}(i&4294901760)===0?(r[s++]=i>>12&15|224,r[s++]=i>>6&63|128):(r[s++]=i>>18&7|240,r[s++]=i>>12&63|128,r[s++]=i>>6&63|128)}r[s++]=i&63|128}}V.utf8EncodeJs=zi;var It=or?new TextEncoder:void 0;V.TEXT_ENCODER_THRESHOLD=or?typeof process<"u"&&((Jr=process==null?void 0:process.env)===null||Jr===void 0?void 0:Jr.TEXT_ENCODING)!=="force"?200:0:fs.UINT32_MAX;function ji(e,r,t){r.set(It.encode(e),t)}function Hi(e,r,t){It.encodeInto(e,r.subarray(t))}V.utf8EncodeTE=It?.encodeInto?Hi:ji;var qi=4096;function $i(e,r,t){let n=r,s=n+t,a=[],i="";for(;n<s;){let o=e[n++];if((o&128)===0)a.push(o);else if((o&224)===192){let d=e[n++]&63;a.push((o&31)<<6|d)}else if((o&240)===224){let d=e[n++]&63,l=e[n++]&63;a.push((o&31)<<12|d<<6|l)}else if((o&248)===240){let d=e[n++]&63,l=e[n++]&63,u=e[n++]&63,_=(o&7)<<18|d<<12|l<<6|u;_>65535&&(_-=65536,a.push(_>>>10&1023|55296),_=56320|_&1023),a.push(_)}else a.push(o);a.length>=qi&&(i+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(i+=String.fromCharCode(...a)),i}V.utf8DecodeJs=$i;var Vi=or?new TextDecoder:null;V.TEXT_DECODER_THRESHOLD=or?typeof process<"u"&&((Xr=process==null?void 0:process.env)===null||Xr===void 0?void 0:Xr.TEXT_DECODER)!=="force"?200:0:fs.UINT32_MAX;function Zi(e,r,t){let n=e.subarray(r,r+t);return Vi.decode(n)}V.utf8DecodeTD=Zi});var Kr=H(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.ExtData=void 0;var Gr=class{constructor(r,t){this.type=r,this.data=t}};cr.ExtData=Gr});var dr=H(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.DecodeError=void 0;var Yr=class e extends Error{constructor(r){super(r);let t=Object.create(e.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:e.name})}};ur.DecodeError=Yr});var Qr=H(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.timestampExtension=q.decodeTimestampExtension=q.decodeTimestampToTimeSpec=q.encodeTimestampExtension=q.encodeDateToTimeSpec=q.encodeTimeSpecToTimestamp=q.EXT_TIMESTAMP=void 0;var Ji=dr(),hs=Ot();q.EXT_TIMESTAMP=-1;var Xi=4294967296-1,Gi=17179869184-1;function ps({sec:e,nsec:r}){if(e>=0&&r>=0&&e<=Gi)if(r===0&&e<=Xi){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t}else{let t=e/4294967296,n=e&4294967295,s=new Uint8Array(8),a=new DataView(s.buffer);return a.setUint32(0,r<<2|t&3),a.setUint32(4,n),s}else{let t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,r),(0,hs.setInt64)(n,4,e),t}}q.encodeTimeSpecToTimestamp=ps;function gs(e){let r=e.getTime(),t=Math.floor(r/1e3),n=(r-t*1e3)*1e6,s=Math.floor(n/1e9);return{sec:t+s,nsec:n-s*1e9}}q.encodeDateToTimeSpec=gs;function ms(e){if(e instanceof Date){let r=gs(e);return ps(r)}else return null}q.encodeTimestampExtension=ms;function ys(e){let r=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:r.getUint32(0),nsec:0};case 8:{let t=r.getUint32(0),n=r.getUint32(4),s=(t&3)*4294967296+n,a=t>>>2;return{sec:s,nsec:a}}case 12:{let t=(0,hs.getInt64)(r,4),n=r.getUint32(0);return{sec:t,nsec:n}}default:throw new Ji.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}q.decodeTimestampToTimeSpec=ys;function _s(e){let r=ys(e);return new Date(r.sec*1e3+r.nsec/1e6)}q.decodeTimestampExtension=_s;q.timestampExtension={type:q.EXT_TIMESTAMP,encode:ms,decode:_s}});var pr=H(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.ExtensionCodec=void 0;var fr=Kr(),Ki=Qr(),Nt=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Ki.timestampExtension)}register({type:r,encode:t,decode:n}){if(r>=0)this.encoders[r]=t,this.decoders[r]=n;else{let s=1+r;this.builtInEncoders[s]=t,this.builtInDecoders[s]=n}}tryToEncode(r,t){for(let n=0;n<this.builtInEncoders.length;n++){let s=this.builtInEncoders[n];if(s!=null){let a=s(r,t);if(a!=null){let i=-1-n;return new fr.ExtData(i,a)}}}for(let n=0;n<this.encoders.length;n++){let s=this.encoders[n];if(s!=null){let a=s(r,t);if(a!=null){let i=n;return new fr.ExtData(i,a)}}}return r instanceof fr.ExtData?r:null}decode(r,t,n){let s=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return s?s(r,t,n):new fr.ExtData(t,r)}};hr.ExtensionCodec=Nt;Nt.defaultCodec=new Nt});var en=H(ct=>{"use strict";Object.defineProperty(ct,"__esModule",{value:!0});ct.createDataView=ct.ensureUint8Array=void 0;function bs(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?new Uint8Array(e):Uint8Array.from(e)}ct.ensureUint8Array=bs;function Yi(e){if(e instanceof ArrayBuffer)return new DataView(e);let r=bs(e);return new DataView(r.buffer,r.byteOffset,r.byteLength)}ct.createDataView=Yi});var rn=H(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});ue.Encoder=ue.DEFAULT_INITIAL_BUFFER_SIZE=ue.DEFAULT_MAX_DEPTH=void 0;var Ut=lr(),Qi=pr(),ws=Ot(),eo=en();ue.DEFAULT_MAX_DEPTH=100;ue.DEFAULT_INITIAL_BUFFER_SIZE=2048;var tn=class{constructor(r=Qi.ExtensionCodec.defaultCodec,t=void 0,n=ue.DEFAULT_MAX_DEPTH,s=ue.DEFAULT_INITIAL_BUFFER_SIZE,a=!1,i=!1,o=!1,d=!1){this.extensionCodec=r,this.context=t,this.maxDepth=n,this.initialBufferSize=s,this.sortKeys=a,this.forceFloat32=i,this.ignoreUndefined=o,this.forceIntegerToFloat=d,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}reinitializeState(){this.pos=0}encodeSharedRef(r){return this.reinitializeState(),this.doEncode(r,1),this.bytes.subarray(0,this.pos)}encode(r){return this.reinitializeState(),this.doEncode(r,1),this.bytes.slice(0,this.pos)}doEncode(r,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);r==null?this.encodeNil():typeof r=="boolean"?this.encodeBoolean(r):typeof r=="number"?this.encodeNumber(r):typeof r=="string"?this.encodeString(r):this.encodeObject(r,t)}ensureBufferSizeToWrite(r){let t=this.pos+r;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(r){let t=new ArrayBuffer(r),n=new Uint8Array(t),s=new DataView(t);n.set(this.bytes),this.view=s,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(r){r===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(r){Number.isSafeInteger(r)&&!this.forceIntegerToFloat?r>=0?r<128?this.writeU8(r):r<256?(this.writeU8(204),this.writeU8(r)):r<65536?(this.writeU8(205),this.writeU16(r)):r<4294967296?(this.writeU8(206),this.writeU32(r)):(this.writeU8(207),this.writeU64(r)):r>=-32?this.writeU8(224|r+32):r>=-128?(this.writeU8(208),this.writeI8(r)):r>=-32768?(this.writeU8(209),this.writeI16(r)):r>=-2147483648?(this.writeU8(210),this.writeI32(r)):(this.writeU8(211),this.writeI64(r)):this.forceFloat32?(this.writeU8(202),this.writeF32(r)):(this.writeU8(203),this.writeF64(r))}writeStringHeader(r){if(r<32)this.writeU8(160+r);else if(r<256)this.writeU8(217),this.writeU8(r);else if(r<65536)this.writeU8(218),this.writeU16(r);else if(r<4294967296)this.writeU8(219),this.writeU32(r);else throw new Error(`Too long string: ${r} bytes in UTF-8`)}encodeString(r){if(r.length>Ut.TEXT_ENCODER_THRESHOLD){let s=(0,Ut.utf8Count)(r);this.ensureBufferSizeToWrite(5+s),this.writeStringHeader(s),(0,Ut.utf8EncodeTE)(r,this.bytes,this.pos),this.pos+=s}else{let s=(0,Ut.utf8Count)(r);this.ensureBufferSizeToWrite(5+s),this.writeStringHeader(s),(0,Ut.utf8EncodeJs)(r,this.bytes,this.pos),this.pos+=s}}encodeObject(r,t){let n=this.extensionCodec.tryToEncode(r,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(r))this.encodeArray(r,t);else if(ArrayBuffer.isView(r))this.encodeBinary(r);else if(typeof r=="object")this.encodeMap(r,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(r)}`)}encodeBinary(r){let t=r.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let n=(0,eo.ensureUint8Array)(r);this.writeU8a(n)}encodeArray(r,t){let n=r.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let s of r)this.doEncode(s,t+1)}countWithoutUndefined(r,t){let n=0;for(let s of t)r[s]!==void 0&&n++;return n}encodeMap(r,t){let n=Object.keys(r);this.sortKeys&&n.sort();let s=this.ignoreUndefined?this.countWithoutUndefined(r,n):n.length;if(s<16)this.writeU8(128+s);else if(s<65536)this.writeU8(222),this.writeU16(s);else if(s<4294967296)this.writeU8(223),this.writeU32(s);else throw new Error(`Too large map object: ${s}`);for(let a of n){let i=r[a];this.ignoreUndefined&&i===void 0||(this.encodeString(a),this.doEncode(i,t+1))}}encodeExtension(r){let t=r.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(r.type),this.writeU8a(r.data)}writeU8(r){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,r),this.pos++}writeU8a(r){let t=r.length;this.ensureBufferSizeToWrite(t),this.bytes.set(r,this.pos),this.pos+=t}writeI8(r){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,r),this.pos++}writeU16(r){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,r),this.pos+=2}writeI16(r){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,r),this.pos+=2}writeU32(r){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,r),this.pos+=4}writeI32(r){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,r),this.pos+=4}writeF32(r){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,r),this.pos+=4}writeF64(r){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,r),this.pos+=8}writeU64(r){this.ensureBufferSizeToWrite(8),(0,ws.setUint64)(this.view,this.pos,r),this.pos+=8}writeI64(r){this.ensureBufferSizeToWrite(8),(0,ws.setInt64)(this.view,this.pos,r),this.pos+=8}};ue.Encoder=tn});var Rs=H(gr=>{"use strict";Object.defineProperty(gr,"__esModule",{value:!0});gr.encode=void 0;var to=rn(),ro={};function no(e,r=ro){return new to.Encoder(r.extensionCodec,r.context,r.maxDepth,r.initialBufferSize,r.sortKeys,r.forceFloat32,r.ignoreUndefined,r.forceIntegerToFloat).encodeSharedRef(e)}gr.encode=no});var xs=H(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.prettyByte=void 0;function so(e){return`${e<0?"-":""}0x${Math.abs(e).toString(16).padStart(2,"0")}`}mr.prettyByte=so});var Es=H(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});yr.CachedKeyDecoder=void 0;var ao=lr(),io=16,oo=16,nn=class{constructor(r=io,t=oo){this.maxKeyLength=r,this.maxLengthPerKey=t,this.hit=0,this.miss=0,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(r){return r>0&&r<=this.maxKeyLength}find(r,t,n){let s=this.caches[n-1];e:for(let a of s){let i=a.bytes;for(let o=0;o<n;o++)if(i[o]!==r[t+o])continue e;return a.str}return null}store(r,t){let n=this.caches[r.length-1],s={bytes:r,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=s:n.push(s)}decode(r,t,n){let s=this.find(r,t,n);if(s!=null)return this.hit++,s;this.miss++;let a=(0,ao.utf8DecodeJs)(r,t,n),i=Uint8Array.prototype.slice.call(r,t,t+n);return this.store(i,a),a}};yr.CachedKeyDecoder=nn});var _r=H(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.Decoder=we.DataViewIndexOutOfBoundsError=void 0;var sn=xs(),lo=pr(),Xe=Ot(),an=lr(),on=en(),co=Es(),be=dr(),uo=e=>{let r=typeof e;return r==="string"||r==="number"},Wt=-1,cn=new DataView(new ArrayBuffer(0)),fo=new Uint8Array(cn.buffer);we.DataViewIndexOutOfBoundsError=(()=>{try{cn.getInt8(0)}catch(e){return e.constructor}throw new Error("never reached")})();var vs=new we.DataViewIndexOutOfBoundsError("Insufficient data"),ho=new co.CachedKeyDecoder,ln=class{constructor(r=lo.ExtensionCodec.defaultCodec,t=void 0,n=Xe.UINT32_MAX,s=Xe.UINT32_MAX,a=Xe.UINT32_MAX,i=Xe.UINT32_MAX,o=Xe.UINT32_MAX,d=ho){this.extensionCodec=r,this.context=t,this.maxStrLength=n,this.maxBinLength=s,this.maxArrayLength=a,this.maxMapLength=i,this.maxExtLength=o,this.keyDecoder=d,this.totalPos=0,this.pos=0,this.view=cn,this.bytes=fo,this.headByte=Wt,this.stack=[]}reinitializeState(){this.totalPos=0,this.headByte=Wt,this.stack.length=0}setBuffer(r){this.bytes=(0,on.ensureUint8Array)(r),this.view=(0,on.createDataView)(this.bytes),this.pos=0}appendBuffer(r){if(this.headByte===Wt&&!this.hasRemaining(1))this.setBuffer(r);else{let t=this.bytes.subarray(this.pos),n=(0,on.ensureUint8Array)(r),s=new Uint8Array(t.length+n.length);s.set(t),s.set(n,t.length),this.setBuffer(s)}}hasRemaining(r){return this.view.byteLength-this.pos>=r}createExtraByteError(r){let{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${r}]`)}decode(r){this.reinitializeState(),this.setBuffer(r);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}*decodeMulti(r){for(this.reinitializeState(),this.setBuffer(r);this.hasRemaining(1);)yield this.doDecodeSync()}async decodeAsync(r){let t=!1,n;for await(let o of r){if(t)throw this.createExtraByteError(this.totalPos);this.appendBuffer(o);try{n=this.doDecodeSync(),t=!0}catch(d){if(!(d instanceof we.DataViewIndexOutOfBoundsError))throw d}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:s,pos:a,totalPos:i}=this;throw new RangeError(`Insufficient data in parsing ${(0,sn.prettyByte)(s)} at ${i} (${a} in the current buffer)`)}decodeArrayStream(r){return this.decodeMultiAsync(r,!0)}decodeStream(r){return this.decodeMultiAsync(r,!1)}async*decodeMultiAsync(r,t){let n=t,s=-1;for await(let a of r){if(t&&s===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a),n&&(s=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--s!==0;);}catch(i){if(!(i instanceof we.DataViewIndexOutOfBoundsError))throw i}this.totalPos+=this.pos}}doDecodeSync(){e:for(;;){let r=this.readHeadByte(),t;if(r>=224)t=r-256;else if(r<192)if(r<128)t=r;else if(r<144){let s=r-128;if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(r<160){let s=r-144;if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else{let s=r-160;t=this.decodeUtf8String(s,0)}else if(r===192)t=null;else if(r===194)t=!1;else if(r===195)t=!0;else if(r===202)t=this.readF32();else if(r===203)t=this.readF64();else if(r===204)t=this.readU8();else if(r===205)t=this.readU16();else if(r===206)t=this.readU32();else if(r===207)t=this.readU64();else if(r===208)t=this.readI8();else if(r===209)t=this.readI16();else if(r===210)t=this.readI32();else if(r===211)t=this.readI64();else if(r===217){let s=this.lookU8();t=this.decodeUtf8String(s,1)}else if(r===218){let s=this.lookU16();t=this.decodeUtf8String(s,2)}else if(r===219){let s=this.lookU32();t=this.decodeUtf8String(s,4)}else if(r===220){let s=this.readU16();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(r===221){let s=this.readU32();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(r===222){let s=this.readU16();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(r===223){let s=this.readU32();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(r===196){let s=this.lookU8();t=this.decodeBinary(s,1)}else if(r===197){let s=this.lookU16();t=this.decodeBinary(s,2)}else if(r===198){let s=this.lookU32();t=this.decodeBinary(s,4)}else if(r===212)t=this.decodeExtension(1,0);else if(r===213)t=this.decodeExtension(2,0);else if(r===214)t=this.decodeExtension(4,0);else if(r===215)t=this.decodeExtension(8,0);else if(r===216)t=this.decodeExtension(16,0);else if(r===199){let s=this.lookU8();t=this.decodeExtension(s,1)}else if(r===200){let s=this.lookU16();t=this.decodeExtension(s,2)}else if(r===201){let s=this.lookU32();t=this.decodeExtension(s,4)}else throw new be.DecodeError(`Unrecognized type byte: ${(0,sn.prettyByte)(r)}`);this.complete();let n=this.stack;for(;n.length>0;){let s=n[n.length-1];if(s.type===0)if(s.array[s.position]=t,s.position++,s.position===s.size)n.pop(),t=s.array;else continue e;else if(s.type===1){if(!uo(t))throw new be.DecodeError("The type of key must be string or number but "+typeof t);if(t==="__proto__")throw new be.DecodeError("The key __proto__ is not allowed");s.key=t,s.type=2;continue e}else if(s.map[s.key]=t,s.readCount++,s.readCount===s.size)n.pop(),t=s.map;else{s.key=null,s.type=1;continue e}}return t}}readHeadByte(){return this.headByte===Wt&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Wt}readArraySize(){let r=this.readHeadByte();switch(r){case 220:return this.readU16();case 221:return this.readU32();default:{if(r<160)return r-144;throw new be.DecodeError(`Unrecognized array type byte: ${(0,sn.prettyByte)(r)}`)}}}pushMapState(r){if(r>this.maxMapLength)throw new be.DecodeError(`Max length exceeded: map length (${r}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.push({type:1,size:r,key:null,readCount:0,map:{}})}pushArrayState(r){if(r>this.maxArrayLength)throw new be.DecodeError(`Max length exceeded: array length (${r}) > maxArrayLength (${this.maxArrayLength})`);this.stack.push({type:0,size:r,array:new Array(r),position:0})}decodeUtf8String(r,t){var n;if(r>this.maxStrLength)throw new be.DecodeError(`Max length exceeded: UTF-8 byte length (${r}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+r)throw vs;let s=this.pos+t,a;return this.stateIsMapKey()&&(!((n=this.keyDecoder)===null||n===void 0)&&n.canBeCached(r))?a=this.keyDecoder.decode(this.bytes,s,r):r>an.TEXT_DECODER_THRESHOLD?a=(0,an.utf8DecodeTD)(this.bytes,s,r):a=(0,an.utf8DecodeJs)(this.bytes,s,r),this.pos+=t+r,a}stateIsMapKey(){return this.stack.length>0?this.stack[this.stack.length-1].type===1:!1}decodeBinary(r,t){if(r>this.maxBinLength)throw new be.DecodeError(`Max length exceeded: bin length (${r}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(r+t))throw vs;let n=this.pos+t,s=this.bytes.subarray(n,n+r);return this.pos+=t+r,s}decodeExtension(r,t){if(r>this.maxExtLength)throw new be.DecodeError(`Max length exceeded: ext length (${r}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),s=this.decodeBinary(r,t+1);return this.extensionCodec.decode(s,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let r=this.view.getUint8(this.pos);return this.pos++,r}readI8(){let r=this.view.getInt8(this.pos);return this.pos++,r}readU16(){let r=this.view.getUint16(this.pos);return this.pos+=2,r}readI16(){let r=this.view.getInt16(this.pos);return this.pos+=2,r}readU32(){let r=this.view.getUint32(this.pos);return this.pos+=4,r}readI32(){let r=this.view.getInt32(this.pos);return this.pos+=4,r}readU64(){let r=(0,Xe.getUint64)(this.view,this.pos);return this.pos+=8,r}readI64(){let r=(0,Xe.getInt64)(this.view,this.pos);return this.pos+=8,r}readF32(){let r=this.view.getFloat32(this.pos);return this.pos+=4,r}readF64(){let r=this.view.getFloat64(this.pos);return this.pos+=8,r}};we.Decoder=ln});var un=H(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});de.decodeMulti=de.decode=de.defaultDecodeOptions=void 0;var Ss=_r();de.defaultDecodeOptions={};function po(e,r=de.defaultDecodeOptions){return new Ss.Decoder(r.extensionCodec,r.context,r.maxStrLength,r.maxBinLength,r.maxArrayLength,r.maxMapLength,r.maxExtLength).decode(e)}de.decode=po;function go(e,r=de.defaultDecodeOptions){return new Ss.Decoder(r.extensionCodec,r.context,r.maxStrLength,r.maxBinLength,r.maxArrayLength,r.maxMapLength,r.maxExtLength).decodeMulti(e)}de.decodeMulti=go});var As=H(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Ae.ensureAsyncIterable=Ae.asyncIterableFromStream=Ae.isAsyncIterable=void 0;function ks(e){return e[Symbol.asyncIterator]!=null}Ae.isAsyncIterable=ks;function mo(e){if(e==null)throw new Error("Assertion Failure: value must not be null nor undefined")}async function*Ts(e){let r=e.getReader();try{for(;;){let{done:t,value:n}=await r.read();if(t)return;mo(n),yield n}}finally{r.releaseLock()}}Ae.asyncIterableFromStream=Ts;function yo(e){return ks(e)?e:Ts(e)}Ae.ensureAsyncIterable=yo});var Ps=H(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});fe.decodeStream=fe.decodeMultiStream=fe.decodeArrayStream=fe.decodeAsync=void 0;var dn=_r(),fn=As(),br=un();async function _o(e,r=br.defaultDecodeOptions){let t=(0,fn.ensureAsyncIterable)(e);return new dn.Decoder(r.extensionCodec,r.context,r.maxStrLength,r.maxBinLength,r.maxArrayLength,r.maxMapLength,r.maxExtLength).decodeAsync(t)}fe.decodeAsync=_o;function bo(e,r=br.defaultDecodeOptions){let t=(0,fn.ensureAsyncIterable)(e);return new dn.Decoder(r.extensionCodec,r.context,r.maxStrLength,r.maxBinLength,r.maxArrayLength,r.maxMapLength,r.maxExtLength).decodeArrayStream(t)}fe.decodeArrayStream=bo;function Ds(e,r=br.defaultDecodeOptions){let t=(0,fn.ensureAsyncIterable)(e);return new dn.Decoder(r.extensionCodec,r.context,r.maxStrLength,r.maxBinLength,r.maxArrayLength,r.maxMapLength,r.maxExtLength).decodeStream(t)}fe.decodeMultiStream=Ds;function wo(e,r=br.defaultDecodeOptions){return Ds(e,r)}fe.decodeStream=wo});var Is=H(k=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});k.decodeTimestampExtension=k.encodeTimestampExtension=k.decodeTimestampToTimeSpec=k.encodeTimeSpecToTimestamp=k.encodeDateToTimeSpec=k.EXT_TIMESTAMP=k.ExtData=k.ExtensionCodec=k.Encoder=k.DataViewIndexOutOfBoundsError=k.DecodeError=k.Decoder=k.decodeStream=k.decodeMultiStream=k.decodeArrayStream=k.decodeAsync=k.decodeMulti=k.decode=k.encode=void 0;var Ro=Rs();Object.defineProperty(k,"encode",{enumerable:!0,get:function(){return Ro.encode}});var Ms=un();Object.defineProperty(k,"decode",{enumerable:!0,get:function(){return Ms.decode}});Object.defineProperty(k,"decodeMulti",{enumerable:!0,get:function(){return Ms.decodeMulti}});var wr=Ps();Object.defineProperty(k,"decodeAsync",{enumerable:!0,get:function(){return wr.decodeAsync}});Object.defineProperty(k,"decodeArrayStream",{enumerable:!0,get:function(){return wr.decodeArrayStream}});Object.defineProperty(k,"decodeMultiStream",{enumerable:!0,get:function(){return wr.decodeMultiStream}});Object.defineProperty(k,"decodeStream",{enumerable:!0,get:function(){return wr.decodeStream}});var Os=_r();Object.defineProperty(k,"Decoder",{enumerable:!0,get:function(){return Os.Decoder}});Object.defineProperty(k,"DataViewIndexOutOfBoundsError",{enumerable:!0,get:function(){return Os.DataViewIndexOutOfBoundsError}});var xo=dr();Object.defineProperty(k,"DecodeError",{enumerable:!0,get:function(){return xo.DecodeError}});var Eo=rn();Object.defineProperty(k,"Encoder",{enumerable:!0,get:function(){return Eo.Encoder}});var vo=pr();Object.defineProperty(k,"ExtensionCodec",{enumerable:!0,get:function(){return vo.ExtensionCodec}});var So=Kr();Object.defineProperty(k,"ExtData",{enumerable:!0,get:function(){return So.ExtData}});var ut=Qr();Object.defineProperty(k,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return ut.EXT_TIMESTAMP}});Object.defineProperty(k,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return ut.encodeDateToTimeSpec}});Object.defineProperty(k,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return ut.encodeTimeSpecToTimestamp}});Object.defineProperty(k,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return ut.decodeTimestampToTimeSpec}});Object.defineProperty(k,"encodeTimestampExtension",{enumerable:!0,get:function(){return ut.encodeTimestampExtension}});Object.defineProperty(k,"decodeTimestampExtension",{enumerable:!0,get:function(){return ut.decodeTimestampExtension}})});var _i=H((mh,yi)=>{var xt=Q("fs"),mi=Q("url"),bu=Q("child_process").spawn;yi.exports=Qn;Qn.XMLHttpRequest=Qn;function Qn(e){"use strict";e=e||{};var r=this,t=Q("http"),n=Q("https"),s,a,i={},o=!1,d={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},l=Object.assign({},d),u=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],_=["TRACE","TRACK","CONNECT"],g=!1,f=!1,m=!1,x={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.response=Buffer.alloc(0),this.status=null,this.statusText=null;var b=function(p){return o||p&&u.indexOf(p.toLowerCase())===-1},w=function(p){return p&&_.indexOf(p)===-1};this.open=function(p,h,S,I,y){if(this.abort(),f=!1,m=!1,!w(p))throw new Error("SecurityError: Request method not allowed");i={method:p,url:h.toString(),async:typeof S!="boolean"?!0:S,user:I||null,password:y||null},v(this.OPENED)},this.setDisableHeaderCheck=function(p){o=p},this.setRequestHeader=function(p,h){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!b(p))return console.warn('Refused to set unsafe header "'+p+'"'),!1;if(g)throw new Error("INVALID_STATE_ERR: send flag is true");return l[p]=h,!0},this.getResponseHeader=function(p){return typeof p=="string"&&this.readyState>this.OPENED&&a.headers[p.toLowerCase()]&&!f?a.headers[p.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||f)return"";var p="";for(var h in a.headers)h!=="set-cookie"&&h!=="set-cookie2"&&(p+=h+": "+a.headers[h]+`\r
`);return p.substr(0,p.length-2)},this.getRequestHeader=function(p){return typeof p=="string"&&l[p]?l[p]:""},this.send=function(p){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(g)throw new Error("INVALID_STATE_ERR: send has already been called");var h=!1,S=!1,I=mi.parse(i.url),y;switch(I.protocol){case"https:":h=!0;case"http:":y=I.hostname;break;case"file:":S=!0;break;case void 0:case"":y="localhost";break;default:throw new Error("Protocol not supported.")}if(S){if(i.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(i.async)xt.readFile(unescape(I.pathname),function(Y,We){Y?r.handleError(Y,Y.errno||-1):(r.status=200,r.responseText=We.toString("utf8"),r.response=We,v(r.DONE))});else try{this.response=xt.readFileSync(unescape(I.pathname)),this.responseText=this.response.toString("utf8"),this.status=200,v(r.DONE)}catch(Y){this.handleError(Y,Y.errno||-1)}return}var M=I.port||(h?443:80),A=I.pathname+(I.search?I.search:"");if(l.Host=y,h&&M===443||M===80||(l.Host+=":"+I.port),i.user){typeof i.password>"u"&&(i.password="");var E=new Buffer(i.user+":"+i.password);l.Authorization="Basic "+E.toString("base64")}i.method==="GET"||i.method==="HEAD"?p=null:p?(l["Content-Length"]=Buffer.isBuffer(p)?p.length:Buffer.byteLength(p),l["Content-Type"]||(l["Content-Type"]="text/plain;charset=UTF-8")):i.method==="POST"&&(l["Content-Length"]=0);var T=e.agent||!1,j={host:y,port:M,path:A,method:i.method,headers:l,agent:T};if(h&&(j.pfx=e.pfx,j.key=e.key,j.passphrase=e.passphrase,j.cert=e.cert,j.ca=e.ca,j.ciphers=e.ciphers,j.rejectUnauthorized=e.rejectUnauthorized!==!1),f=!1,i.async){var vt=h?n.request:t.request;g=!0,r.dispatchEvent("readystatechange");var Ne=function(Y){if(a=Y,a.statusCode===302||a.statusCode===303||a.statusCode===307){i.url=a.headers.location;var We=mi.parse(i.url);y=We.hostname;var ve={hostname:We.hostname,port:We.port,path:We.path,method:a.statusCode===303?"GET":i.method,headers:l};h&&(ve.pfx=e.pfx,ve.key=e.key,ve.passphrase=e.passphrase,ve.cert=e.cert,ve.ca=e.ca,ve.ciphers=e.ciphers,ve.rejectUnauthorized=e.rejectUnauthorized!==!1),s=vt(ve,Ne).on("error",Ue),s.end();return}v(r.HEADERS_RECEIVED),r.status=a.statusCode,a.on("data",function(sr){if(sr){var Si=Buffer.from(sr);r.response=Buffer.concat([r.response,Si])}g&&v(r.LOADING)}),a.on("end",function(){g&&(g=!1,v(r.DONE),r.responseText=r.response.toString("utf8"))}),a.on("error",function(sr){r.handleError(sr)})},Ue=function(Y){r.handleError(Y)};s=vt(j,Ne).on("error",Ue),e.autoUnref&&s.on("socket",Y=>{Y.unref()}),p&&s.write(p),s.end(),r.dispatchEvent("loadstart")}else{var St=".node-xmlhttprequest-content-"+process.pid,kt=".node-xmlhttprequest-sync-"+process.pid;xt.writeFileSync(kt,"","utf8");for(var xi="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(h?"s":"")+".request;var options = "+JSON.stringify(j)+";var responseText = '';var responseData = Buffer.alloc(0);var req = doRequest(options, function(response) {response.on('data', function(chunk) { var data = Buffer.from(chunk); responseText += data.toString('utf8'); responseData = Buffer.concat([responseData, data]);});response.on('end', function() {fs.writeFileSync('"+St+"', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText, data: responseData.toString('base64')}}), 'utf8');fs.unlinkSync('"+kt+"');});response.on('error', function(error) {fs.writeFileSync('"+St+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+kt+"');});}).on('error', function(error) {fs.writeFileSync('"+St+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+kt+"');});"+(p?"req.write('"+JSON.stringify(p).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",Ei=bu(process.argv[0],["-e",xi]),Su;xt.existsSync(kt););if(r.responseText=xt.readFileSync(St,"utf8"),Ei.stdin.end(),xt.unlinkSync(St),r.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var vi=JSON.parse(r.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,""));r.handleError(vi,503)}else{r.status=r.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1");var zr=JSON.parse(r.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"));a={statusCode:r.status,headers:zr.data.headers},r.responseText=zr.data.text,r.response=Buffer.from(zr.data.data,"base64"),v(r.DONE,!0)}}},this.handleError=function(p,h){this.status=h||0,this.statusText=p,this.responseText=p.stack,f=!0,v(this.DONE)},this.abort=function(){s&&(s.abort(),s=null),l=Object.assign({},d),this.responseText="",this.responseXML="",this.response=Buffer.alloc(0),f=m=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||g)&&this.readyState!==this.DONE&&(g=!1,v(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(p,h){p in x||(x[p]=[]),x[p].push(h)},this.removeEventListener=function(p,h){p in x&&(x[p]=x[p].filter(function(S){return S!==h}))},this.dispatchEvent=function(p){if(typeof r["on"+p]=="function"&&(this.readyState===this.DONE&&i.async?setTimeout(function(){r["on"+p]()},0):r["on"+p]()),p in x)for(let h=0,S=x[p].length;h<S;h++)this.readyState===this.DONE?setTimeout(function(){x[p][h].call(r)},0):x[p][h].call(r)};var v=function(p){if(!(r.readyState===p||r.readyState===r.UNSENT&&m)&&(r.readyState=p,(i.async||r.readyState<r.OPENED||r.readyState===r.DONE)&&r.dispatchEvent("readystatechange"),r.readyState===r.DONE)){let h;m?h="abort":f?h="error":h="load",r.dispatchEvent(h),r.dispatchEvent("loadend")}}}});var Ce=class extends Error{constructor(r){super(r),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};var Se=class extends Ce{};var L=typeof process<"u"&&process.release&&process.release.name==="node",Tt;if(globalThis.document)Tt=e=>new Promise((r,t)=>{let n=document.createElement("script");n.src=e,n.onload=()=>r(),n.onerror=t,document.head.appendChild(n)});else if(globalThis.importScripts)Tt=async e=>{try{globalThis.importScripts(e)}catch(r){if(r instanceof TypeError)await import(e);else throw r}};else if(L)Tt=async e=>{await import((await import("path")).default.resolve(e))};else throw new Ce("Cannot determine runtime environment");var ie={null:0,symbol:1,pairlist:2,closure:3,environment:4,promise:5,call:6,special:7,builtin:8,string:9,logical:10,integer:13,double:14,complex:15,character:16,dots:17,any:18,list:19,expression:20,bytecode:21,pointer:22,weakref:23,raw:24,s4:25,new:30,free:31,function:99};function At(e){return!!e&&typeof e=="object"&&Object.keys(ie).includes(e.type)}function Fe(e){return!!e&&typeof e=="object"&&"re"in e&&"im"in e}var c={};function ns(e){Object.keys(e).forEach(r=>c._free(e[r]))}function Le(e){return c._Rf_protect(ee(e)),e}function D(e,r){return c._Rf_protect(ee(e)),++r.n,e}function ss(e){let r=c._malloc(4);return c._R_ProtectWithIndex(ee(e),r),{loc:c.getValue(r,"i32"),ptr:r}}function as(e){c._Rf_unprotect(1),c._free(e.ptr)}function is(e,r){return c._R_Reprotect(ee(e),r.loc),e}function U(e){c._Rf_unprotect(e)}function jr(e,r,t){c._Rf_defineVar(ee(r),ee(t),ee(e))}function ye(e,r){let t={},n={n:0};try{let s=new te(r);D(s,n),t.code=c.allocateUTF8(e);let a=c._R_ParseEvalString(t.code,s.ptr);return R.wrap(a)}finally{ns(t),U(n.n)}}var nt=class extends Error{constructor(r,t){super(r),this.name="UnwindProtectException",this.cont=t}};function Be(e,r){return c.getWasmTableEntry(c.GOT.ffi_safe_eval.value)(ee(e),ee(r))}var Oi=new WeakMap;function os(e,r){return Oi.set(e,r),e}function Hr(e){return typeof e=="string"&&e.length===Dt}var Dt=63;function _e(){let e=Array.from({length:4},Ii).join("-");if(e.length!==Dt)throw new Error("comlink internal error: UUID has the wrong length");return e}function Ii(){let e=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16),r=15-e.length;return r>0&&(e=Array.from({length:r},()=>0).join("")+e),e}function ee(e){return $e(e)?e.ptr:e}function Ve(e,r){if(c._TYPEOF(e.ptr)!==ie[r])throw new Error(`Unexpected object type "${e.type()}" when expecting type "${r}"`)}var ke=new Map;function Ze(e,r){let t=ee(r);if(c._R_PreserveObject(t),e!==void 0){if(Hr(e)){ke.get(e).push(t);return}throw new Error("Unexpected shelter type "+typeof e)}}function qr(e,r){let t=ee(r);c._R_ReleaseObject(t);let n=ke.get(e),s=n.indexOf(t);if(s<0)throw new Error("Can't find object in shelter.");n.splice(s,1)}function $r(e){let r=ke.get(e);for(let t of r)try{c._R_ReleaseObject(t)}catch(n){console.error(n)}ke.set(e,[])}function ls(e){if(At(e))return new(Mt(e.type))(e);if(typeof e>"u")return new at;if(e&&typeof e=="object"&&"type"in e&&e.type==="null")return new at;if(e===null)return new re({type:"logical",names:null,values:[null]});if(typeof e=="boolean")return new re(e);if(typeof e=="number")return new qe(e);if(typeof e=="string")return new oe(e);if(Fe(e))return new it(e);if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return new ot(e);if(Array.isArray(e))return Ni(e);if(typeof e=="object")return je.fromObject(e);throw new Error("R object construction for this JS object is not yet supported.")}function Ni(e){let r={n:0};if(e.every(n=>n&&typeof n=="object"&&!$e(n)&&!Fe(n))){let n=e,s=n.every(i=>Object.keys(i).filter(o=>!Object.keys(n[0]).includes(o)).length===0&&Object.keys(n[0]).filter(o=>!Object.keys(i).includes(o)).length===0),a=n.every(i=>Object.values(i).every(o=>us(o)||cs(o)));if(s&&a)return je.fromD3(n)}if(e.every(n=>typeof n=="boolean"||n===null))return new re(e);if(e.every(n=>typeof n=="number"||n===null))return new qe(e);if(e.every(n=>typeof n=="string"||n===null))return new oe(e);try{let n=new le([new B("c"),...e]);return D(n,r),n.eval()}finally{U(r.n)}}var F=class{constructor(r){this.ptr=r}type(){let r=c._TYPEOF(this.ptr);return Object.keys(ie).find(n=>ie[n]===r)}},R=class e extends F{constructor(r){if(!(r instanceof F))return ls(r);super(r.ptr)}static wrap(r){let t=c._TYPEOF(r),n=Object.keys(ie)[Object.values(ie).indexOf(t)];return new(Mt(n))(new F(r))}get[Symbol.toStringTag](){return`RObject:${this.type()}`}static getPersistentObject(r){return W[r]}getPropertyValue(r){return this[r]}inspect(){ye(".Internal(inspect(x))",{x:this})}isNull(){return c._TYPEOF(this.ptr)===ie.null}isNa(){try{let r=ye("is.na(x)",{x:this});return Le(r),r.toBoolean()}finally{U(1)}}isUnbound(){return this.ptr===W.unboundValue.ptr}attrs(){return ze.wrap(c._ATTRIB(this.ptr))}class(){let r={n:0},t=new le([new B("class"),this]);D(t,r);try{return t.eval()}finally{U(r.n)}}setNames(r){let t;if(r===null)t=W.null;else if(Array.isArray(r)&&r.every(n=>typeof n=="string"||n===null))t=new oe(r);else throw new Error("Argument to setNames must be null or an Array of strings or null");return c._Rf_setAttrib(this.ptr,W.namesSymbol.ptr,t.ptr),this}names(){let r=oe.wrap(c._Rf_getAttrib(this.ptr,W.namesSymbol.ptr));return r.isNull()?null:r.toArray()}includes(r){let t=this.names();return t&&t.includes(r)}toJs(r={depth:0},t=1){throw new Error("This R object cannot be converted to JS")}subset(r){return this.#e(r,W.bracketSymbol.ptr)}get(r){return this.#e(r,W.bracket2Symbol.ptr)}getDollar(r){return this.#e(r,W.dollarSymbol.ptr)}#e(r,t){let n={n:0};try{let s=new e(r);D(s,n);let a=c._Rf_lang3(t,this.ptr,s.ptr);return D(a,n),e.wrap(Be(a,W.baseEnv))}finally{U(n.n)}}pluck(...r){let t=ss(W.null);try{let n=(a,i)=>{let o=a.get(i);return is(o,t)},s=r.reduce(n,this);return s.isNull()?void 0:s}finally{as(t)}}set(r,t){let n={n:0};try{let s=new e(r);D(s,n);let a=new e(t);D(a,n);let i=new B("[[<-"),o=c._Rf_lang4(i.ptr,this.ptr,s.ptr,a.ptr);return D(o,n),e.wrap(Be(o,W.baseEnv))}finally{U(n.n)}}static getMethods(r){let t=new Set,n=r;do Object.getOwnPropertyNames(n).map(s=>t.add(s));while(n=Object.getPrototypeOf(n));return[...t.keys()].filter(s=>typeof r[s]=="function")}},at=class extends R{constructor(){return super(new F(c.getValue(c._R_NilValue,"*"))),this}toJs(){return{type:"null"}}},B=class extends R{constructor(r){if(r instanceof F){Ve(r,"symbol"),super(r);return}let t=c.allocateUTF8(r);try{super(new F(c._Rf_install(t)))}finally{c._free(t)}}toJs(){let r=this.toObject();return{type:"symbol",printname:r.printname,symvalue:r.symvalue,internal:r.internal}}toObject(){return{printname:this.printname().isUnbound()?null:this.printname().toString(),symvalue:this.symvalue().isUnbound()?null:this.symvalue().ptr,internal:this.internal().isNull()?null:this.internal().ptr}}toString(){return this.printname().toString()}printname(){return He.wrap(c._PRINTNAME(this.ptr))}symvalue(){return R.wrap(c._SYMVALUE(this.ptr))}internal(){return R.wrap(c._INTERNAL(this.ptr))}},ze=class e extends R{constructor(r){if(r instanceof F)return Ve(r,"pairlist"),super(r),this;let t={n:0};try{let{names:n,values:s}=lt(r),a=e.wrap(c._Rf_allocList(s.length));D(a,t);for(let[i,o]=[0,a];!o.isNull();[i,o]=[i+1,o.cdr()])o.setcar(new R(s[i]));a.setNames(n),super(a)}finally{U(t.n)}}get length(){return this.toArray().length}toArray(r={depth:1}){return this.toJs(r).values}toObject({allowDuplicateKey:r=!0,allowEmptyKey:t=!1,depth:n=-1}={}){let s=this.entries({depth:n}),a=s.map(([i])=>i);if(!r&&new Set(a).size!==a.length)throw new Error("Duplicate key when converting pairlist without allowDuplicateKey enabled");if(!t&&a.some(i=>!i))throw new Error("Empty or null key when converting pairlist without allowEmptyKey enabled");return Object.fromEntries(s.filter((i,o)=>s.findIndex(d=>d[0]===i[0])===o))}entries(r={depth:1}){let t=this.toJs(r);return t.values.map((n,s)=>[t.names?t.names[s]:null,n])}toJs(r={depth:0},t=1){let n=[],s=!1,a=[];for(let o=this;!o.isNull();o=o.cdr()){let d=o.tag();d.isNull()?n.push(""):(s=!0,n.push(d.toString())),r.depth&&t>=r.depth?a.push(o.car()):a.push(o.car().toJs(r,t+1))}return{type:"pairlist",names:s?n:null,values:a}}includes(r){return r in this.toObject()}setcar(r){c._SETCAR(this.ptr,r.ptr)}car(){return R.wrap(c._CAR(this.ptr))}cdr(){return R.wrap(c._CDR(this.ptr))}tag(){return R.wrap(c._TAG(this.ptr))}},le=class e extends R{constructor(r){if(r instanceof F)return Ve(r,"call"),super(r),this;let t={n:0};try{let{values:n}=lt(r),s=n.map(i=>D(new R(i),t)),a=e.wrap(c._Rf_allocVector(ie.call,n.length));D(a,t);for(let[i,o]=[0,a];!o.isNull();[i,o]=[i+1,o.cdr()])o.setcar(s[i]);super(a)}finally{U(t.n)}}setcar(r){c._SETCAR(this.ptr,r.ptr)}car(){return R.wrap(c._CAR(this.ptr))}cdr(){return R.wrap(c._CDR(this.ptr))}eval(){return c.webr.evalR(this,{env:W.baseEnv})}capture(r={}){return c.webr.captureR(this,r)}deparse(){let r={n:0};try{let t=c._Rf_lang2(new B("deparse1").ptr,c._Rf_lang2(new B("quote").ptr,this.ptr));D(t,r);let n=oe.wrap(Be(t,W.baseEnv));return D(n,r),n.toString()}finally{U(r.n)}}},ce=class e extends R{constructor(r,t=null){if(r instanceof F){if(Ve(r,"list"),super(r),t){if(t.length!==this.length)throw new Error("Can't construct named `RList`. Supplied `names` must be the same length as the list.");this.setNames(t)}return this}let n={n:0};try{let s=lt(r),a=c._Rf_allocVector(ie.list,s.values.length);D(a,n),s.values.forEach((o,d)=>{ds(o)?c._SET_VECTOR_ELT(a,d,new e(o).ptr):c._SET_VECTOR_ELT(a,d,new R(o).ptr)});let i=t||s.names;if(i&&i.length!==s.values.length)throw new Error("Can't construct named `RList`. Supplied `names` must be the same length as the list.");R.wrap(a).setNames(i),super(new F(a))}finally{U(n.n)}}get length(){return c._LENGTH(this.ptr)}isDataFrame(){let r=ze.wrap(c._ATTRIB(this.ptr)).get("class");return!r.isNull()&&r.toArray().includes("data.frame")}toArray(r={depth:1}){return this.toJs(r).values}toObject({allowDuplicateKey:r=!0,allowEmptyKey:t=!1,depth:n=-1}={}){let s=this.entries({depth:n}),a=s.map(([i])=>i);if(!r&&new Set(a).size!==a.length)throw new Error("Duplicate key when converting list without allowDuplicateKey enabled");if(!t&&a.some(i=>!i))throw new Error("Empty or null key when converting list without allowEmptyKey enabled");return Object.fromEntries(s.filter((i,o)=>s.findIndex(d=>d[0]===i[0])===o))}toD3(){if(!this.isDataFrame())throw new Error("Can't convert R list object to D3 format. Object must be of class 'data.frame'.");return this.entries().reduce((t,n)=>(n[1].forEach((s,a)=>t[a]=Object.assign(t[a]||{},{[n[0]]:s})),t),[])}entries(r={depth:-1}){let t=this.toJs(r);return this.isDataFrame()&&r.depth<0&&(t.values=t.values.map(n=>n.toArray())),t.values.map((n,s)=>[t.names?t.names[s]:null,n])}toJs(r={depth:0},t=1){return{type:"list",names:this.names(),values:[...Array(this.length).keys()].map(n=>r.depth&&t>=r.depth?this.get(n+1):this.get(n+1).toJs(r,t+1))}}},je=class e extends ce{constructor(r){if(r instanceof F){if(super(r),!this.isDataFrame())throw new Error("Can't construct `RDataFrame`. Supplied R object is not a `data.frame`.");return this}return e.fromObject(r)}static fromObject(r){let{names:t,values:n}=lt(r),s={n:0};try{let a=!!t&&t.length>0&&t.every(o=>o),i=n.length>0&&n.every(o=>Array.isArray(o)||ArrayBuffer.isView(o)||o instanceof ArrayBuffer);if(a&&i){let o=n,d=o.every(u=>u.length===o[0].length),l=o.every(u=>us(u[0])||cs(u[0]));if(d&&l){let u=new ce({type:"list",names:t,values:o.map(g=>ls(g))});D(u,s);let _=new le([new B("as.data.frame"),u]);return D(_,s),new e(_.eval())}}}finally{U(s.n)}throw new Error("Can't construct `data.frame`. Source object is not eligible.")}static fromD3(r){return this.fromObject(Object.fromEntries(Object.keys(r[0]).map(t=>[t,r.map(n=>n[t])])))}},st=class extends R{exec(...r){let t={n:0};try{let n=new le([this,...r]);return D(n,t),n.eval()}finally{U(t.n)}}capture(r={},...t){let n={n:0};try{let s=new le([this,...t]);return D(s,n),s.capture(r)}finally{U(n.n)}}},He=class e extends R{static{this.CEType={CE_NATIVE:0,CE_UTF8:1,CE_LATIN1:2,CE_BYTES:3,CE_SYMBOL:5,CE_ANY:99}}constructor(r){if(r instanceof F){Ve(r,"string"),super(r);return}let t=c.allocateUTF8(r);try{super(new F(c._Rf_mkCharCE(t,e.CEType.CE_UTF8)))}finally{c._free(t)}}toString(){let r=c._vmaxget();try{return c.UTF8ToString(c._Rf_translateCharUTF8(this.ptr))}finally{c._vmaxset(r)}}toJs(){return{type:"string",value:this.toString()}}},te=class extends R{constructor(r={}){if(r instanceof F)return Ve(r,"environment"),super(r),this;let t=0;try{let{names:n,values:s}=lt(r),a=Le(c._R_NewEnv(W.globalEnv.ptr,0,0));++t,s.forEach((i,o)=>{let d=n?n[o]:null;if(!d)throw new Error("Can't create object in new environment with empty symbol name");let l=new B(d),u=Le(new R(i));try{jr(a,l,u)}finally{U(1)}}),super(new F(a))}finally{U(t)}}ls(r=!1,t=!0){return oe.wrap(c._R_lsInternal3(this.ptr,Number(r),Number(t))).toArray()}bind(r,t){let n=new B(r),s=Le(new R(t));try{jr(this,n,s)}finally{U(1)}}names(){return this.ls(!0,!0)}frame(){return R.wrap(c._FRAME(this.ptr))}subset(r){if(typeof r=="number")throw new Error("Object of type environment is not subsettable");return this.getDollar(r)}toObject({depth:r=-1}={}){let t=this.names();return Object.fromEntries([...Array(t.length).keys()].map(n=>{let s=this.getDollar(t[n]);return[t[n],r<0?s:s.toJs({depth:r})]}))}toJs(r={depth:0},t=1){let n=this.names(),s=[...Array(n.length).keys()].map(a=>r.depth&&t>=r.depth?this.getDollar(n[a]):this.getDollar(n[a]).toJs(r,t+1));return{type:"environment",names:n,values:s}}},Te=class extends R{constructor(r,t,n){if(r instanceof F)return Ve(r,t),super(r),this;let s={n:0};try{let{names:a,values:i}=lt(r),o=c._Rf_allocVector(ie[t],i.length);D(o,s),i.forEach(n(o)),R.wrap(o).setNames(a),super(new F(o))}finally{U(s.n)}}get length(){return c._LENGTH(this.ptr)}get(r){return super.get(r)}subset(r){return super.subset(r)}getDollar(){throw new Error("$ operator is invalid for atomic vectors")}detectMissing(){let r={n:0};try{let t=c._Rf_lang2(new B("is.na").ptr,this.ptr);D(t,r);let n=re.wrap(Be(t,W.baseEnv));D(n,r);let s=n.toTypedArray();return Array.from(s).map(a=>!!a)}finally{U(r.n)}}toArray(){let r=this.toTypedArray();return this.detectMissing().map((t,n)=>t?null:r[n])}toObject({allowDuplicateKey:r=!0,allowEmptyKey:t=!1}={}){let n=this.entries(),s=n.map(([a])=>a);if(!r&&new Set(s).size!==s.length)throw new Error("Duplicate key when converting atomic vector without allowDuplicateKey enabled");if(!t&&s.some(a=>!a))throw new Error("Empty or null key when converting atomic vector without allowEmptyKey enabled");return Object.fromEntries(n.filter((a,i)=>n.findIndex(o=>o[0]===a[0])===i))}entries(){let r=this.toArray(),t=this.names();return r.map((n,s)=>[t?t[s]:null,n])}toJs(){return{type:this.type(),names:this.names(),values:this.toArray()}}},re=class e extends Te{constructor(r){super(r,"logical",e.#e)}static#e=r=>{let t=c._LOGICAL(r),n=c.getValue(c._R_NaInt,"i32");return(s,a)=>{c.setValue(t+4*a,s===null?n:!!s,"i32")}};getBoolean(r){return this.get(r).toArray()[0]}toBoolean(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let r=this.getBoolean(1);if(r===null)throw new Error("Can't convert missing value `NA` to a JS boolean");return r}toTypedArray(){return new Int32Array(c.HEAP32.subarray(c._LOGICAL(this.ptr)/4,c._LOGICAL(this.ptr)/4+this.length))}toArray(){let r=this.toTypedArray();return this.detectMissing().map((t,n)=>t?null:!!r[n])}},Pt=class e extends Te{constructor(r){super(r,"integer",e.#e)}static#e=r=>{let t=c._INTEGER(r),n=c.getValue(c._R_NaInt,"i32");return(s,a)=>{c.setValue(t+4*a,s===null?n:Math.round(Number(s)),"i32")}};getNumber(r){return this.get(r).toArray()[0]}toNumber(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let r=this.getNumber(1);if(r===null)throw new Error("Can't convert missing value `NA` to a JS number");return r}toTypedArray(){return new Int32Array(c.HEAP32.subarray(c._INTEGER(this.ptr)/4,c._INTEGER(this.ptr)/4+this.length))}},qe=class e extends Te{constructor(r){super(r,"dou