df-script 1.4.0 → 1.5.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/README.md +83 -34
- package/dist/api.d.ts +16 -8
- package/dist/api.js +11 -3
- package/dist/columnExpressions/ColumnExpr.d.ts +26 -364
- package/dist/columnExpressions/ColumnExpr.js +199 -3
- package/dist/columnExpressions/ExprBase.d.ts +8 -11
- package/dist/columnExpressions/ExprBase.js +20 -61
- package/dist/columnExpressions/constants.d.ts +2 -0
- package/dist/columnExpressions/constants.js +3 -1
- package/dist/columnExpressions/functions/coalesce.js +8 -4
- package/dist/columnExpressions/functions/element.d.ts +5 -0
- package/dist/columnExpressions/functions/element.js +11 -0
- package/dist/columnExpressions/functions/implode.d.ts +3 -0
- package/dist/columnExpressions/functions/implode.js +7 -0
- package/dist/columnExpressions/functions/lit.d.ts +3 -1
- package/dist/columnExpressions/functions/lit.js +8 -13
- package/dist/columnExpressions/functions/repeat.d.ts +47 -0
- package/dist/columnExpressions/functions/repeat.js +131 -0
- package/dist/columnExpressions/functions/seq_range.d.ts +31 -0
- package/dist/columnExpressions/functions/seq_range.js +91 -0
- package/dist/columnExpressions/functions/when.js +8 -4
- package/dist/columnExpressions/index.d.ts +5 -2
- package/dist/columnExpressions/index.js +5 -48
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +25 -50
- package/dist/columnExpressions/mixins/AggregationExpr.js +69 -165
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +41 -66
- package/dist/columnExpressions/mixins/ArithmeticExpr.js +126 -138
- package/dist/columnExpressions/mixins/BooleanExpr.d.ts +40 -0
- package/dist/columnExpressions/mixins/BooleanExpr.js +67 -0
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +31 -60
- package/dist/columnExpressions/mixins/ComparisonExpr.js +231 -370
- package/dist/columnExpressions/mixins/ListExpr.d.ts +15 -39
- package/dist/columnExpressions/mixins/ListExpr.js +124 -148
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +7 -33
- package/dist/columnExpressions/mixins/LogicalExpr.js +48 -49
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +6 -31
- package/dist/columnExpressions/mixins/ManipulationExpr.js +61 -25
- package/dist/columnExpressions/mixins/NumericExpr.d.ts +92 -0
- package/dist/columnExpressions/mixins/NumericExpr.js +259 -0
- package/dist/columnExpressions/mixins/StringExpr.d.ts +5 -30
- package/dist/columnExpressions/mixins/StringExpr.js +37 -49
- package/dist/columnExpressions/mixins/StructExpr.d.ts +16 -0
- package/dist/columnExpressions/mixins/StructExpr.js +139 -0
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +4 -30
- package/dist/columnExpressions/mixins/TemporalExpr.js +28 -29
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +27 -49
- package/dist/columnExpressions/mixins/WindowExpr.js +144 -274
- package/dist/columnExpressions/utils.d.ts +4 -0
- package/dist/columnExpressions/utils.js +45 -0
- package/dist/dataframe/constants.d.ts +3 -0
- package/dist/dataframe/constants.js +4 -1
- package/dist/dataframe/dataframe.d.ts +27 -10
- package/dist/dataframe/dataframe.js +461 -220
- package/dist/dataframe/grouped/grouped.d.ts +2 -3
- package/dist/dataframe/grouped/grouped.js +17 -16
- package/dist/dataframe/types.d.ts +65 -1
- package/dist/dataframe/utils.d.ts +11 -3
- package/dist/dataframe/utils.js +101 -9
- package/dist/datatypes/DataType.d.ts +2 -1
- package/dist/datatypes/DataType.js +29 -0
- package/dist/datatypes/index.d.ts +2 -2
- package/dist/datatypes/types.d.ts +37 -36
- package/dist/datatypes/types.js +15 -11
- package/dist/exceptions/index.d.ts +2 -0
- package/dist/exceptions/index.js +4 -1
- package/dist/exceptions/utils.d.ts +1 -0
- package/dist/exceptions/utils.js +19 -0
- package/dist/functions/concat.d.ts +1 -2
- package/dist/functions/concat.js +24 -12
- package/dist/functions/index.d.ts +3 -1
- package/dist/functions/index.js +7 -15
- package/dist/functions/read_csv.d.ts +8 -0
- package/dist/functions/read_csv.js +53 -0
- package/dist/functions/read_json.d.ts +10 -0
- package/dist/functions/read_json.js +21 -0
- package/dist/functions/transpose.d.ts +7 -0
- package/dist/functions/transpose.js +84 -0
- package/dist/index.js +6 -1
- package/dist/types.d.ts +31 -5
- package/dist/utils/csv.d.ts +77 -0
- package/dist/utils/csv.js +313 -0
- package/dist/utils/date.js +5 -6
- package/dist/utils/guards.d.ts +0 -2
- package/dist/utils/guards.js +0 -31
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/json.d.ts +120 -2
- package/dist/utils/json.js +204 -20
- package/dist/utils/list.d.ts +173 -1
- package/dist/utils/list.js +255 -22
- package/dist/utils/number.d.ts +61 -28
- package/dist/utils/number.js +248 -70
- package/dist/utils/string.d.ts +5 -0
- package/dist/utils/string.js +89 -0
- package/package.json +5 -1
package/dist/index.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
"use strict";var oe=Object.defineProperty;var bn=Object.getOwnPropertyDescriptor;var wn=Object.getOwnPropertyNames;var _n=Object.prototype.hasOwnProperty;var Tn=(s,t)=>{for(var e in t)oe(s,e,{get:t[e],enumerable:!0})},Dn=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of wn(t))!_n.call(s,r)&&r!==e&&oe(s,r,{get:()=>t[r],enumerable:!(n=bn(t,r))||n.enumerable});return s};var An=s=>Dn(oe({},"__esModule",{value:!0}),s);var Rn={};Tn(Rn,{$tbl:()=>On,ALL_COLUMNS_MARKER:()=>B,AggregationExpr:()=>pe,ArithmeticExpr:()=>fe,Binary:()=>Le,BinaryType:()=>Yt,Boolean:()=>Fe,BooleanType:()=>Gt,ColumnExpr:()=>k,ColumnNotFoundError:()=>wt,ComparisonExpr:()=>me,ComputeError:()=>et,DFScriptError:()=>ct,DataFrame:()=>F,DataFrameError:()=>V,DataType:()=>z,DataTypeRegistry:()=>L,Date:()=>Ve,DateTimeExprNamespace:()=>Ut,DateType:()=>Jt,Datetime:()=>Ke,DatetimeType:()=>Qt,DecimalType:()=>Dt,Duration:()=>Pe,DurationType:()=>ee,ExprBase:()=>bt,Float32:()=>Ue,Float32Type:()=>qt,Float64:()=>Me,Float64Type:()=>Ht,FloatDataType:()=>mt,GroupedData:()=>Ct,Int16:()=>Ie,Int16Type:()=>jt,Int32:()=>Se,Int32Type:()=>Bt,Int64:()=>ke,Int64Type:()=>Vt,Int8:()=>Ce,Int8Type:()=>Lt,IntegerDataType:()=>Tt,LITERAL_MARKER:()=>he,List:()=>We,ListExpr:()=>be,ListExprNamespace:()=>Mt,ListType:()=>ne,LogicalExpr:()=>de,NestedDataType:()=>pt,Null:()=>je,NullType:()=>Zt,NumericDataType:()=>lt,Object:()=>Be,ObjectType:()=>Xt,SchemaError:()=>ht,SignedIntegerType:()=>ot,StringExpr:()=>ye,StringExprNamespace:()=>Rt,Struct:()=>qe,StructType:()=>re,TemporalDataType:()=>at,TemporalExpr:()=>xe,Time:()=>$e,TimeType:()=>te,UInt16:()=>ve,UInt16Type:()=>$t,UInt32:()=>Oe,UInt32Type:()=>Pt,UInt64:()=>Re,UInt64Type:()=>Wt,UInt8:()=>Ee,UInt8Type:()=>Kt,UnsignedIntegerType:()=>it,Utf8:()=>Ne,Utf8Type:()=>zt,When:()=>Nt,WhenThen:()=>_t,WhenThenChain:()=>Ft,WindowExpr:()=>ge,all:()=>_e,assertColumnExists:()=>W,coalesce:()=>De,columnsToRows:()=>Ge,concat:()=>It,derive:()=>g,exclude:()=>Te,gatherColumnsByIndices:()=>At,getRowFromColumns:()=>vn,inferColumnType:()=>nt,kleeneBinary:()=>U,kleeneUnary:()=>w,lit:()=>we,normalizeToDataFrames:()=>xn,resolveColumnSelectors:()=>ft,resolveWindowExpr:()=>se,rowsToColumns:()=>He,when:()=>Ae});module.exports=An(Rn);var Xe=/[,\s_]/g,Cn=/^[+-]?\d+(?:\.\d+)?$/;function rt(s){return typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s)}function Q(s){if(s==null||typeof s=="symbol")return null;if(rt(s))return s;if(typeof s=="boolean")return s?1:0;if(typeof s=="bigint"){let t=Number(s);return rt(t)?t:null}if(s instanceof Date){let t=s.getTime();return rt(t)?t:null}if(typeof s=="string"){let t=s.trim().replace(Xe,"");if(t==="")return null;let e=Number(t);return rt(e)?e:null}return null}function yt(s){let{val:t,min:e,max:n}=s;return t<e?e:t>n?n:t}var Ze=34028234663852886e22,Mn={Float32:{min:-Ze,max:Ze},Float64:{min:-Number.MAX_VALUE,max:Number.MAX_VALUE}};function ie(s,t="Float64"){let e=Q(s);return e===null?null:t==="Float32"?Math.fround(e):e}var Je={Int8:{min:-128,max:127},Int16:{min:-32768,max:32767},Int32:{min:-2147483648,max:2147483647},UInt8:{min:0,max:255},UInt16:{min:0,max:65535},UInt32:{min:0,max:4294967295}},In={Int64:{min:-9223372036854775808n,max:9223372036854775807n},UInt64:{min:0n,max:18446744073709551615n}};function Qe(s,t){if(!rt(s)||!Number.isInteger(s))return!1;if(!t)return!0;let e=typeof t=="string"?Je[t]:t;return s>=e.min&&s<=e.max}function tt(s,t="Int32",e={}){let n=Q(s);if(n===null)return null;let r=n;switch(e.coerce||"truncate"){case"round":r=Math.round(r);break;case"floor":r=Math.floor(r);break;case"ceil":r=Math.ceil(r);break;case"truncate":r=Math.trunc(r);break}let i=typeof t=="string"?Je[t]:t;return yt({val:r,min:i.min,max:i.max})}function ae(s,t="Int64"){if(s==null||typeof s=="symbol")return null;let e=null;if(typeof s=="bigint")e=s;else if(typeof s=="boolean")e=s?1n:0n;else if(typeof s=="string"){let r=s.trim().replace(Xe,"");if(r==="")return null;if(Cn.test(r))e=BigInt(r.split(".")[0]);else{let o=Q(s);if(o===null)return null;e=BigInt(Math.trunc(o))}}else{let r=Q(s);if(r===null)return null;e=BigInt(Math.trunc(r))}let n=typeof t=="string"?In[t]:t;return yt({val:e,min:n.min,max:n.max})}function St(s,t={}){let e=Q(s);if(e===null)return null;let{precision:n,scale:r}=t,o=e;if(r!==void 0){let i=Math.pow(10,r);o=Math.round(o*i)/i}if(n!==void 0){let i=r||0,a=n-i;if(a>0){let l=Math.pow(10,a)-Math.pow(10,-i);o=yt({val:o,min:-l,max:l})}}return o}function tn(s){let t=s|0;return function(){let e=t=t+1831565813|0;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}var kt=/^\d{2}:\d{2}/,Et=/(?:Z|[+-]\d{2}(?::?\d{2})?)$/i;var le=1e3,nn=6e4,rn=36e5,dt=864e5,vt=1e3,Ot=1e6;function sn(s,t="ms"){let e=s.getTime();switch(t){case"s":return Math.floor(e/le);case"ms":return e;case"us":return e*vt;case"ns":return e*Ot}}function on(s){let t=s.getUTCFullYear();return Math.floor((t-1)/100)+1}function an(s){let t=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let n=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-n.getTime())/dt+1)/7)}function ln(s){let t=s.getUTCFullYear();return Math.floor((t-1)/1e3)+1}function ue(s,t,e=1){return new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth()+t,e,0,0,0,0))}function un(s){let t=new Date(Date.UTC(s.getUTCFullYear(),0,1)),e=s.getTime()-t.getTime();return Math.floor(e/dt)+1}function cn(s){return Math.floor(s.getUTCMonth()/3)+1}function hn(s){let t=s instanceof Date?s.getUTCFullYear():s;return t%4===0&&t%100!==0||t%400===0}function G(s){return s instanceof Date&&!Number.isNaN(s.getTime())}function en(s){let t=Math.abs(s);return t>=1e12?s:t<=1e10?s*1e3:s}var Sn=["%ms","%f","%Y","%y","%m","%d","%e","%H","%I","%p","%M","%S","%A","%a","%B","%b","%h","%j","%u","%w","%Z","%z"];function fn(s,t,e){let n=t;n=n.replace(/%%/g,"\0"),n=n.replace(/%F/g,"%Y-%m-%d"),n=n.replace(/%T/g,"%H:%M:%S"),n=n.replace(/%R/g,"%H:%M"),n=n.replace(/%D/g,"%m/%d/%y");let r={get"%Y"(){return String(s.getUTCFullYear())},get"%y"(){return String(s.getUTCFullYear()%100).padStart(2,"0")},get"%m"(){return String(s.getUTCMonth()+1).padStart(2,"0")},get"%d"(){return String(s.getUTCDate()).padStart(2,"0")},get"%e"(){return String(s.getUTCDate()).padStart(2," ")},get"%H"(){return String(s.getUTCHours()).padStart(2,"0")},get"%I"(){return String(s.getUTCHours()%12||12).padStart(2,"0")},get"%p"(){return s.getUTCHours()>=12?"PM":"AM"},get"%M"(){return String(s.getUTCMinutes()).padStart(2,"0")},get"%S"(){return String(s.getUTCSeconds()).padStart(2,"0")},get"%A"(){return s.toLocaleDateString(e,{weekday:"long",timeZone:"UTC"})},get"%a"(){return s.toLocaleDateString(e,{weekday:"short",timeZone:"UTC"})},get"%B"(){return s.toLocaleDateString(e,{month:"long",timeZone:"UTC"})},get"%b"(){return s.toLocaleDateString(e,{month:"short",timeZone:"UTC"})},get"%h"(){return s.toLocaleDateString(e,{month:"short",timeZone:"UTC"})},get"%j"(){let o=new Date(Date.UTC(s.getUTCFullYear(),0,1)),i=s.getTime()-o.getTime(),a=Math.floor(i/dt)+1;return String(a).padStart(3,"0")},get"%u"(){return String(s.getUTCDay()||7)},get"%w"(){return String(s.getUTCDay())},get"%Z"(){return"UTC"},get"%z"(){return"+0000"},get"%ms"(){return String(s.getUTCMilliseconds()).padStart(3,"0")},get"%f"(){return String(s.getUTCMilliseconds()*1e3).padStart(6,"0")}};for(let o of Sn)n.includes(o)&&(n=n.replaceAll(o,r[o]));return n.replace(/\0/g,"%")}function mn(s,t,e=!0){if(typeof s!="string"||typeof t!="string")return null;let n=[],r=1,o="",i=0;for(;i<t.length;){let b=t[i];if(b==="%")if(i+1<t.length){let T=t[i+1];if(T==="%")o+="%",i+=2;else if(t.slice(i,i+3)==="%ms")n.push({name:"ms",index:r++}),o+="(\\d{1,3})",i+=3;else{switch(T){case"Y":n.push({name:"year",index:r++}),o+="(\\d{4})";break;case"y":n.push({name:"year_short",index:r++}),o+="(\\d{2})";break;case"m":n.push({name:"month",index:r++}),o+="(\\d{1,2})";break;case"d":case"e":n.push({name:"day",index:r++}),o+="(\\d{1,2})";break;case"H":case"I":n.push({name:"hour",index:r++}),o+="(\\d{1,2})";break;case"M":n.push({name:"minute",index:r++}),o+="(\\d{1,2})";break;case"S":n.push({name:"second",index:r++}),o+="(\\d{1,2})";break;case"f":n.push({name:"fractional",index:r++}),o+="(\\d{1,6})";break;default:o+=b+T}i+=2}}else o+=b,i++;else"\\^$*+?.()|[]{}".indexOf(b)!==-1?o+="\\"+b:o+=b,i++}let a=new RegExp("^"+o+"$"),l=s.match(a);if(!l){if(e)return null;let b=new Date(s);return G(b)?b:null}let u=1970,c=1,h=1,f=0,m=0,p=0,y=0;for(let b of n){let T=l[b.index],A=parseInt(T,10);switch(b.name){case"year":u=A;break;case"year_short":u=A+(A>=69?1900:2e3);break;case"month":c=A;break;case"day":h=A;break;case"hour":f=A;break;case"minute":m=A;break;case"second":p=A;break;case"ms":y=parseInt(T.padEnd(3,"0").slice(0,3),10);break;case"fractional":y=parseInt(T.padEnd(6,"0").slice(0,3),10);break}}let x=new Date(Date.UTC(u,c-1,h,f,m,p,y));return G(x)?x:null}function X(s){if(s instanceof Date)return G(s)?s:null;if(typeof s=="number"){let t=new Date(en(s));return G(t)?t:null}if(typeof s=="bigint"){let t=new Date(en(Number(s)));return G(t)?t:null}if(typeof s=="string"){let t=s.trim();if(t==="")return null;let e=new Date(t);return G(e)?e:null}return null}function $(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function D(s){return Array.isArray(s)||$(s)}function Y(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function xt(s){if(!Y(s))return!1;let t=Object.getPrototypeOf(s);return t===null||t===Object.prototype}function pn(s){return typeof s!="function"?!1:/^class\s/.test(Function.prototype.toString.call(s))||s.prototype!==void 0&&s.prototype.constructor===s&&Object.getOwnPropertyDescriptor(s,"prototype")?.writable===!1}function kn(s){if(s==null)return!1;if(s instanceof Uint8Array||typeof s=="string")return!0;if(Array.isArray(s)){let t=s.length;for(let e=0;e<t;e++)if(!Qe(s[e],{min:-128,max:255}))return!1;return!0}return!!$(s)}function gn(s){return kn(s)?s instanceof Uint8Array?s:typeof s=="string"?new TextEncoder().encode(s):ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s):null}function st(s){return s==null?[]:Array.isArray(s)?s:$(s)?Array.from(s):[s]}function Z(s,t,{mode:e="every",allowNulls:n=!1,allowEmpty:r=!0}={}){if(!D(s))return!1;let o=s.length;if(o===0)return r?e==="every":!1;let i=a=>a==null?n:typeof t=="function"?pn(t)?a instanceof t:t(a):t==="date"?G(a):t==="object"?Y(a):t==="plainObject"?xt(a):t==="number"?rt(a):typeof a===t;if(e==="every"){for(let a=0;a<o;a++)if(!i(s[a]))return!1;return!0}else{for(let a=0;a<o;a++)if(i(s[a]))return!0;return!1}}function ce(s,t=!1){if(!D(s))return[];let e=Array.from(s);return e.sort((n,r)=>n==null&&r==null?0:n==null?1:r==null?-1:n<r?t?1:-1:n>r?t?-1:1:0),e}var yn={sum:null,count:0,min:null,max:null,mean:null,variance:0,std:0,nullCount:0,len:0,hasNulls:!1,isNumeric:!1};function j(s){if(!D(s))return{...yn};let t=s.length;if(t===0)return{...yn};let e=null,n=null,r=0,o=0,i=0,a=0,l=0;for(let c=0;c<t;c++){let h=s[c];if(h==null){o++;continue}(e==null||h<e)&&(e=h),(n==null||h>n)&&(n=h);let f=Q(h);if(f!==null){i+=f,r++;let m=f-a;a+=m/r;let p=f-a;l+=m*p}}let u=r>1?l/(r-1):0;return{sum:r>0?i:null,count:r,min:e,max:n,mean:r>0?i/r:null,variance:u,std:Math.sqrt(u),nullCount:o,len:t,hasNulls:o>0,isNumeric:r>0&&r===t-o}}function ut(s,t=null,{mode:e="both",returnStringOnNull:n=!1,maxScanStart:r=1,maxScanEnd:o=1,maxMatchesStart:i=1,maxMatchesEnd:a=1,trimFirst:l=!1,stringOptions:{literal:u=!1,caseInsensitive:c=!1}={}}={}){if(s==null)return n?"":null;let h=(d,I="both")=>I==="start"?d.trimStart():I==="end"?d.trimEnd():d.trim(),f=s;if(l&&t!=null&&(f=h(s,e)),t==null){let d=h(f,e);return n||d!==""?d:null}let m=t instanceof RegExp?d=>t.test(d):(()=>{let d=new Set(c?t.toLowerCase():t);return I=>d.has(c?I.toLowerCase():I)})(),p=f.length,y=new Uint8Array(p),A=u&&typeof t=="string"?({isStart:d,limit:I,maxMatches:R})=>{if(p===0||R===0)return;let E=t.length;if(E===0)return;let N=c?f.toLowerCase():f,K=c?t.toLowerCase():t,_=d?0:p-1,C=0,v=0;for(;_>=0&&_<p&&!(R!==null&&R>=0&&C>=R);){let M=d?_:_-E+1;if(!d&&M<0)break;let O=d?N.indexOf(K,M):N.lastIndexOf(K,M);if(O===-1)break;let q=d?O-_:_-(O+E-1);if(v+=q,I!==null&&I>=0&&v>=I)break;for(let H=0;H<E;H++)y[O+H]=1;C++,_=d?O+E:O-1}}:({isStart:d,limit:I,maxMatches:R})=>{if(p===0||R===0)return;let E=d?0:p-1,N=d?p:-1,K=d?1:-1,_=!1,C=0,v=0;for(let M=E;M!==N;M+=K)if(m(f[M])){if(!_){if(I!==null&&I>=0&&v>=I||R!==null&&R>=0&&C>=R)break;_=!0,C++}y[M]=1}else _=!1,v++};(e==="both"||e==="start")&&A({isStart:!0,limit:r,maxMatches:i}),(e==="both"||e==="end")&&A({isStart:!1,limit:o,maxMatches:a});let S="";for(let d=0;d<p;d++)y[d]===0&&(S+=f[d]);return n||S!==""?S:null}var B="*",he="*literal*";var w=s=>t=>{let e=t.length,n=new Array(e);for(let r=0;r<e;r++){let o=t[r];n[r]=o==null?null:s(o)}return n},U=(s,t,e)=>(n,r)=>{let o=n.length,i=s._resolve(t,r,o),a=new Array(o);if(D(i))for(let l=0;l<o;l++){let u=n[l],c=i[l];a[l]=u==null||c==null?null:e(u,c)}else for(let l=0;l<o;l++){let u=n[l];a[l]=u==null||i==null?null:e(u,i)}return a},g=(s,t)=>{let e=s.constructor,n=new e(s.colName||"");return Object.assign(n,s),n.ops=t?[...s.ops,t]:[...s.ops],n},bt=class{ops=[];outputName="";aggFn=null;groupingOpsIndex;partitionOpsIndex;partitionBy=null;_resolve(t,e,n){return t&&typeof t=="object"&&"evaluate"in t?t.isLiteral&&t.ops.length===1?t.literalValue:t.evaluate(e,n):t}alias(t){let e=this.constructor,n=new e(this.colName||"");return Object.assign(n,this),n.outputName=t,n}cast(t){return g(this,e=>{let n=e.length,r=new Array(n);for(let o=0;o<n;o++)r[o]=t.coerce(e[o]);return r})}debug(t){return g(this,e=>(console.log(`[DEBUG] ${t?t+": ":""}`,e),e))}evaluate(t,e){let n=this.colName,r=n&&n!=="*"?t[n]||new Array(e).fill(null):new Array(e).fill(null),o=this.ops,i=o.length;for(let a=0;a<i;a++)r=o[a](r,t);return r}_evaluatePre(t,e,n){let r=this.colName,o=r&&r!=="*"?e[r]||new Array(n).fill(null):new Array(n).fill(null),i=this.ops,a=t!==void 0?t:i.length;for(let l=0;l<a;l++)o=i[l](o,e);return o}_evaluatePost(t,e,n){let r=this.ops,o=t!==void 0?t:r.length,i=e;for(let a=o;a<r.length;a++)i=r[a](i,n);return i}evaluatePrePartition(t,e){return this._evaluatePre(this.partitionOpsIndex,t,e)}evaluatePostPartition(t,e){return this._evaluatePost(this.partitionOpsIndex,t,e)}evaluatePreGrouping(t,e){return this._evaluatePre(this.groupingOpsIndex,t,e)}evaluatePostGrouping(t,e){return this._evaluatePost(this.groupingOpsIndex,t,e)}};var fe=s=>class extends s{abs(){return g(this,w(t=>Math.abs(t)))}acos(){return g(this,w(t=>t<-1||t>1?null:Math.acos(t)))}acosh(){return g(this,w(t=>t<1?null:Math.acosh(t)))}add(t){return g(this,U(this,t,(e,n)=>e+n))}asin(){return g(this,w(t=>t<-1||t>1?null:Math.asin(t)))}asinh(){return g(this,w(Math.asinh))}atan(){return g(this,w(Math.atan))}atanh(){return g(this,w(t=>t<=-1||t>=1?null:Math.atanh(t)))}cbrt(){return g(this,w(Math.cbrt))}ceil(){return g(this,w(Math.ceil))}clip(t=null,e=null){return g(this,w(n=>t!==null&&e!==null?yt({val:n,min:t,max:e}):t!==null?Math.max(n,t):e!==null?Math.min(n,e):n))}cos(){return g(this,w(Math.cos))}cosh(){return g(this,w(Math.cosh))}degrees(){return g(this,w(t=>t*(180/Math.PI)))}div(t){return g(this,U(this,t,(e,n)=>n===0?null:e/n))}exp(){return g(this,w(Math.exp))}expm1(){return g(this,w(Math.expm1))}floor(){return g(this,w(Math.floor))}floordiv(t){return g(this,U(this,t,(e,n)=>n===0?null:Math.floor(e/n)))}hypot(t){return g(this,U(this,t,(e,n)=>Math.hypot(e,n)))}log(t=Math.E){return g(this,w(e=>e<=0?null:t===Math.E?Math.log(e):Math.log(e)/Math.log(t)))}log1p(){return g(this,w(t=>t<=-1?null:Math.log1p(t)))}mod(t){return g(this,U(this,t,(e,n)=>n===0?null:e%n))}mul(t){return g(this,U(this,t,(e,n)=>e*n))}negate(){return g(this,w(t=>-t))}pow(t){return g(this,U(this,t,(e,n)=>Math.pow(e,n)))}radians(){return g(this,w(t=>t*(Math.PI/180)))}rand(t,{min:e=0,max:n=1,integer:r=!1}={}){return g(this,o=>{let i=o.length,a=new Float64Array(i),l=t!==void 0?tn(t):Math.random,u=n-e;for(let c=0;c<i;c++){let h=l();a[c]=r?Math.floor(h*(u+1))+e:h*u+e}return a})}round(t=0){let e=Math.pow(10,t);return g(this,w(n=>Math.round(n*e)/e))}sign(){return g(this,w(Math.sign))}sin(){return g(this,w(Math.sin))}sinh(){return g(this,w(Math.sinh))}sqrt(){return g(this,w(t=>t<0?null:Math.sqrt(t)))}sub(t){return g(this,U(this,t,(e,n)=>e-n))}tan(){return g(this,w(Math.tan))}tanh(){return g(this,w(Math.tanh))}trunc(){return g(this,w(Math.trunc))}};function P(s){return s==null?s:s instanceof Date?`d:${s.getTime()}`:s instanceof Uint8Array?`u:${s.toString()}`:typeof s=="object"||typeof s=="function"?String(s):s}var me=s=>class extends s{between(t,e,n="both"){return g(this,(r,o)=>{let i=r.length,a=this._resolve(t,o,i),l=this._resolve(e,o,i),u=new Array(i),c=D(a),h=D(l);for(let f=0;f<i;f++){let m=r[f],p=c?a[f]:a,y=h?l[f]:l;if(m==null||p==null||y==null)u[f]=null;else{let x=n==="both"||n==="left"?m>=p:m>p,b=n==="both"||n==="right"?m<=y:m<y;u[f]=x&&b}}return u})}eq(t){return g(this,U(this,t,(e,n)=>e===n))}eq_missing(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=new Array(r);if(D(o))for(let a=0;a<r;a++){let l=e[a],u=o[a];l==null&&u==null?i[a]=!0:l==null||u==null?i[a]=!1:i[a]=l===u}else for(let a=0;a<r;a++){let l=e[a];l==null&&o==null?i[a]=!0:l==null||o==null?i[a]=!1:i[a]=l===o}return i})}ge(t){return g(this,U(this,t,(e,n)=>e>=n))}gt(t){return g(this,U(this,t,(e,n)=>e>n))}has_nulls(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e]==null)return!0;return!1})}is_close(t,e={}){let{abs_tol:n=1e-8,rel_tol:r=1e-8,nans_equal:o=!1}=e;return g(this,(i,a)=>{let l=i.length,u=this._resolve(t,a,l),c=D(u),h=new Array(l);for(let f=0;f<l;f++){let m=i[f],p=c?u[f]:u;if(m==null||p==null)h[f]=null;else if(Number.isNaN(m)||Number.isNaN(p))o&&Number.isNaN(m)&&Number.isNaN(p)?h[f]=!0:h[f]=!1;else if(!Number.isFinite(m)||!Number.isFinite(p))h[f]=m===p;else{let y=Math.abs(m-p),x=Math.max(r*Math.max(Math.abs(m),Math.abs(p)),n);h[f]=y<=x}}return h})}is_duplicated(){return g(this,t=>{let e=t.length,n=new Map,r=new Array(e);for(let i=0;i<e;i++){let a=P(t[i]);r[i]=a,n.set(a,(n.get(a)||0)+1)}let o=new Array(e);for(let i=0;i<e;i++)o[i]=(n.get(r[i])||0)>1;return o})}is_empty(t={}){let{ignoreNulls:e=!1}=t;return g(this,w(n=>{if(typeof n=="string")return n.length===0;if(D(n)){if(e){let r=n.length,o=0;for(let i=0;i<r;i++)n[i]!=null&&o++;return o===0}return n.length===0}return null}))}is_finite(){return g(this,w(Number.isFinite))}is_first_distinct(){return g(this,t=>{let e=t.length,n=new Set,r=new Array(e);for(let o=0;o<e;o++){let i=P(t[o]);n.has(i)?r[o]=!1:(n.add(i),r[o]=!0)}return r})}is_in(t){return g(this,(e,n)=>{let r=e.length,o=new Array(r);if(t&&typeof t=="object"&&"evaluate"in t){let i=t.evaluate(n,r);for(let a=0;a<r;a++){let l=e[a];if(l==null)o[a]=null;else{let u=i[a],c=new Set;if(D(u)){let h=u.length;for(let f=0;f<h;f++)c.add(P(u[f]))}else c.add(P(u));o[a]=c.has(P(l))}}}else{let i=D(t)?t:[],a=new Set,l=i.length;for(let u=0;u<l;u++)a.add(P(i[u]));for(let u=0;u<r;u++){let c=e[u];o[u]=c==null?null:a.has(P(c))}}return o})}is_infinite(){return g(this,w(t=>t===1/0||t===-1/0))}is_last_distinct(){return g(this,t=>{let e=t.length,n=new Set,r=new Array(e);for(let o=e-1;o>=0;o--){let i=P(t[o]);n.has(i)?r[o]=!1:(n.add(i),r[o]=!0)}return r})}is_n_distinct(t){return this._deriveAgg(e=>{let n=new Set,r=e.length;for(let o=0;o<r;o++)n.add(P(e[o]));return n.size===t})}is_nan(){return g(this,w(Number.isNaN))}is_not_nan(){return g(this,w(t=>!Number.isNaN(t)))}is_not_null(){return g(this,t=>{let e=t.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=t[r]!=null;return n})}is_null(){return g(this,t=>{let e=t.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=t[r]==null;return n})}is_unique(){return g(this,t=>{let e=t.length,n=new Map,r=new Array(e);for(let i=0;i<e;i++){let a=P(t[i]);r[i]=a,n.set(a,(n.get(a)||0)+1)}let o=new Array(e);for(let i=0;i<e;i++)o[i]=n.get(r[i])===1;return o})}le(t){return g(this,U(this,t,(e,n)=>e<=n))}lt(t){return g(this,U(this,t,(e,n)=>e<n))}ne(t){return g(this,U(this,t,(e,n)=>e!==n))}ne_missing(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=new Array(r);if(D(o))for(let a=0;a<r;a++){let l=e[a],u=o[a];l==null&&u==null?i[a]=!1:l==null||u==null?i[a]=!0:i[a]=l!==u}else for(let a=0;a<r;a++){let l=e[a];l==null&&o==null?i[a]=!1:l==null||o==null?i[a]=!0:i[a]=l!==o}return i})}not_in(t){return g(this,(e,n)=>{let r=e.length,o=new Array(r);if(t&&typeof t=="object"&&"evaluate"in t){let i=t.evaluate(n,r);for(let a=0;a<r;a++){let l=e[a];if(l==null)o[a]=null;else{let u=i[a],c=new Set;if(D(u)){let h=u.length;for(let f=0;f<h;f++)c.add(P(u[f]))}else c.add(P(u));o[a]=!c.has(P(l))}}}else{let i=D(t)?t:[],a=new Set,l=i.length;for(let u=0;u<l;u++)a.add(P(i[u]));for(let u=0;u<r;u++){let c=e[u];o[u]=c==null?null:!a.has(P(c))}}return o})}};function W(s,t,e,n=""){if(!(s in t))throw new wt(s,`${e} "${s}" does not exist${n}`)}var ct=class extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},V=class extends ct{},wt=class extends V{constructor(t,e){super(e||`Column "${t}" does not exist in the DataFrame.`)}},ht=class extends ct{},et=class extends ct{};var pe=s=>class extends s{aggFn=this.aggFn||null;_deriveAgg(t){let e=g(this);return e.aggFn=t,e.groupingOpsIndex=this.ops.length,e.partitionOpsIndex=this.ops.length,e}all(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(!t[e])return!1;return!0})}all_null(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e]!=null)return!1;return!0})}any(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e])return!0;return!1})}any_null(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e]==null)return!0;return!1})}avg(){return this._deriveAgg(t=>j(t).mean)}count(t={}){return t.includeNulls?this._deriveAgg(e=>e.length):this._deriveAgg(e=>j(e).count)}first(){return this._deriveAgg(t=>t[0]??null)}last(){return this._deriveAgg(t=>t[t.length-1]??null)}max(){return this._deriveAgg(t=>j(t).max)}mean(){return this.avg()}median(){return this._deriveAgg(t=>{if(!Z(t,"number",{allowNulls:!0}))return null;let e=t.length,n=[];for(let i=0;i<e;i++){let a=t[i];a!=null&&n.push(a)}let r=n.length;if(r===0)return null;n.sort((i,a)=>i-a);let o=Math.floor(r/2);return r%2!==0?n[o]:(n[o-1]+n[o])/2})}min(){return this._deriveAgg(t=>j(t).min)}mode(){return this._deriveAgg(t=>{if(!D(t))return null;let e=t.length,n=new Map,r=0;for(let i=0;i<e;i++){let a=t[i];if(a==null)continue;let l=(n.get(a)??0)+1;n.set(a,l),l>r&&(r=l)}if(r===0)return null;let o=[];for(let[i,a]of n.entries())a===r&&o.push(i);return o.length===0?null:(o.sort((i,a)=>i==null&&a==null?0:i==null?1:a==null||i<a?-1:i>a?1:0),o[0])})}n_unique(){return this._deriveAgg(t=>new Set(t).size)}quantile(t){if(t<0||t>1)throw new et("Quantile q must be between 0 and 1");return this._deriveAgg(e=>{let n=[];for(let l=0;l<e.length;l++)e[l]!=null&&n.push(e[l]);let r=n.length;if(!r)return null;n.sort((l,u)=>l-u);let o=(r-1)*t,i=Math.floor(o),a=Math.ceil(o);return i===a?n[i]:n[i]+(o-i)*(n[a]-n[i])})}std(){return this._deriveAgg(t=>j(t).std)}sum(){return this._deriveAgg(t=>j(t).sum)}};var ge=s=>class extends s{partitionBy=this.partitionBy||null;_rolling(t,e){let n=g(this);return n.partitionOpsIndex=this.ops.length,n.groupingOpsIndex=this.ops.length,n.evaluateWindow=function(r,o,i){let a=Math.max(0,i-t+1),l=i+1,u=r.slice(a,l);return e(u)},n}get isWindow(){return this.partitionBy!==null||this.evaluateWindow!==void 0||this.aggFn!==null}cum_count(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=0,a=t?o:0,l=t?n.length-1:o;for(let u=a;u<=l;u++)n[u]!=null&&i++;return i},e}cum_max(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=null,a=t?o:0,l=t?n.length-1:o;for(let u=a;u<=l;u++){let c=n[u];c!=null&&(i===null||c>i)&&(i=c)}return i},e}cum_min(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=null,a=t?o:0,l=t?n.length-1:o;for(let u=a;u<=l;u++){let c=n[u];c!=null&&(i===null||c<i)&&(i=c)}return i},e}cum_prod(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=1,a=!1,l=t?o:0,u=t?n.length-1:o;for(let c=l;c<=u;c++){let h=n[c];h!=null&&(i*=h,a=!0)}return a?i:null},e}cum_sum(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=0,a=t?o:0,l=t?n.length-1:o;for(let u=a;u<=l;u++){let c=n[u];c!=null&&(i+=c)}return i},e}dense_rank(){let t=g(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=function(e,n,r){let o=Array.from(new Set(e)).sort((l,u)=>l-u),i=new Map;for(let l=0;l<o.length;l++)i.set(o[l],l+1);let a=e[r];return i.get(a)??null},t}lag(t=1,e=null){let n=g(this);return n.partitionOpsIndex=this.ops.length,n.groupingOpsIndex=this.ops.length,n.evaluateWindow=function(r,o,i){let a=e;return i-t>=0&&(a=r[i-t]),a},n}lead(t=1,e=null){let n=g(this);return n.partitionOpsIndex=this.ops.length,n.groupingOpsIndex=this.ops.length,n.evaluateWindow=function(r,o,i){let a=e;return i+t<r.length&&(a=r[i+t]),a},n}over(t){let e=g(this),n=Array.isArray(t)?t:[t];return e.partitionBy=n,e}rank(){let t=g(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=function(e,n,r){let o=[...e].sort((l,u)=>l-u),i=new Map;for(let l=0;l<o.length;l++){let u=o[l];i.has(u)||i.set(u,l+1)}let a=e[r];return i.get(a)??null},t}rolling_max(t){return this._rolling(t,e=>j(e).max)}rolling_mean(t){return this._rolling(t,e=>j(e).mean)}rolling_median(t){return this._rolling(t,e=>{if(!Z(e,"number",{allowNulls:!0}))return null;let n=e.length,r=[];for(let a=0;a<n;a++){let l=e[a];l!=null&&r.push(l)}let o=r.length;if(o===0)return null;r.sort((a,l)=>a-l);let i=Math.floor(o/2);return o%2!==0?r[i]:(r[i-1]+r[i])/2})}rolling_min(t){return this._rolling(t,e=>j(e).min)}rolling_quantile(t,e){return this._rolling(e,n=>{let r=[];for(let u=0;u<n.length;u++)n[u]!=null&&r.push(n[u]);let o=r.length;if(o===0)return null;r.sort((u,c)=>u-c);let i=t*(o-1),a=Math.floor(i),l=Math.ceil(i);return a===l?r[a]:r[a]+(i-a)*(r[l]-r[a])})}rolling_rank(t){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=Math.max(0,o-t+1),a=o+1,l=n.slice(i,a),u=n[o];if(u==null)return null;let c=[];for(let m=0;m<l.length;m++)l[m]!=null&&c.push(l[m]);if(c.length===0)return null;let h=[...c].sort((m,p)=>m-p),f=new Map;for(let m=0;m<h.length;m++){let p=h[m];f.has(p)||f.set(p,m+1)}return f.get(u)??null},e}rolling_std(t){return this._rolling(t,e=>j(e).std)}rolling_sum(t){return this._rolling(t,e=>j(e).sum)}row_number(){let t=g(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=function(e,n,r){return r+1},t.outputName="row_number",t}};var Rt=class{constructor(t){this.expr=t}expr;_deriveString(t){return g(this.expr,w(e=>t(String(e))))}concat(t){return g(this.expr,U(this.expr,t,(e,n)=>String(e)+String(n)))}contains(t){return t==null?g(this.expr,e=>new Array(e.length).fill(null)):this._deriveString(e=>t instanceof RegExp?t.test(e):e.includes(t))}count_matches(t){return t==null?g(this.expr,e=>new Array(e.length).fill(null)):this._deriveString(e=>{if(t instanceof RegExp){let n=t.global?t:new RegExp(t.source,t.flags+"g"),r=e.match(n);return r?r.length:0}else{let n=0,r=e.indexOf(t);for(;r!==-1;)n++,r=e.indexOf(t,r+t.length);return n}})}decode_uri_component(){return this._deriveString(t=>{try{return decodeURIComponent(t)}catch{return t}})}encode_uri_component(){return this._deriveString(t=>{try{return encodeURIComponent(t)}catch{return t}})}ends_with(t){return this._deriveString(e=>e.endsWith(t))}explode(){return this._deriveString(t=>t.split(""))}extract(t,e=0){return t==null?g(this.expr,n=>new Array(n.length).fill(null)):this._deriveString(n=>{let r=n.match(t);return r&&r[e]!==void 0?r[e]:null})}len(){return this.len_chars()}len_bytes(){return this._deriveString(t=>new TextEncoder().encode(t).length)}len_chars(){return this._deriveString(t=>t.length)}lower(){return this._deriveString(t=>t.toLowerCase())}lpad(t,e=" "){return this._deriveString(n=>n.padStart(t,e))}pad_end(t,e=" "){return this.rpad(t,e)}pad_start(t,e=" "){return this.lpad(t,e)}replace(t,e){return t==null?g(this.expr,n=>new Array(n.length).fill(null)):this._deriveString(n=>n.replace(t,e))}replace_all(t,e){return t==null?g(this.expr,n=>new Array(n.length).fill(null)):this._deriveString(n=>{if(t instanceof RegExp){let r=t.global?t:new RegExp(t.source,t.flags+"g");return n.replace(r,e)}return n.replaceAll(t,e)})}reverse(){return this._deriveString(t=>t.split("").reverse().join(""))}rpad(t,e=" "){return this._deriveString(n=>n.padEnd(t,e))}slice(t,e){return this._deriveString(n=>{let r=t<0?n.length+t:t,o=e!==void 0?r+e:void 0;return n.slice(r,o)})}slice_str(t,e){return this.slice(t,e)}split(t){return this._deriveString(e=>e.split(t))}starts_with(t){return this._deriveString(e=>e.startsWith(t))}strip_chars(t,e){return this._deriveString(n=>ut(n,t,{mode:"both",...e}))}strip_chars_end(t,e){return this._deriveString(n=>ut(n,t,{mode:"end",...e}))}strip_chars_start(t,e){return this._deriveString(n=>ut(n,t,{mode:"start",...e}))}strip_prefix(t){return this._deriveString(e=>ut(e,t,{mode:"start",maxScanStart:1,maxMatchesStart:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strip_suffix(t){return this._deriveString(e=>ut(e,t,{mode:"end",maxScanEnd:1,maxMatchesEnd:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strptime(t,e=!0){return this._deriveString(n=>mn(n,t,e))}to_date(){return this._deriveString(t=>{let e=X(t);if(!e)return null;let n=new Date(e);return n.setUTCHours(0,0,0,0),n})}to_datetime(){return this._deriveString(X)}to_decimal(t,e){return this._deriveString(n=>St(n,{precision:t,scale:e}))}to_integer(){return this._deriveString(t=>tt(t))}to_lowercase(){return this.lower()}to_time(){return this._deriveString(t=>{let e=X(t);if(e)return e.toISOString().split("T")[1].slice(0,12);let n=t.trim();if(kt.test(n)){let r=new Date(`1970-01-01T${n}${Et.test(n)?"":"Z"}`);if(G(r))return r.toISOString().split("T")[1].slice(0,12)}return null})}to_titlecase(){return this._deriveString(t=>t.replace(/\b\w/g,e=>e.toUpperCase()))}to_uppercase(){return this.upper()}trim(){return this.strip_chars()}trim_end(){return this.strip_chars_end()}trim_start(){return this.strip_chars_start()}upper(){return this._deriveString(t=>t.toUpperCase())}zfill(t){return this._deriveString(e=>e.padStart(t,"0"))}},ye=s=>class extends s{get str(){return new Rt(this)}};var de=s=>class extends s{and(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=D(o),a=new Array(r);for(let l=0;l<r;l++){let u=e[l],c=i?o[l]:o;u===!1||c===!1?a[l]=!1:u==null||c==null?a[l]=null:a[l]=!0}return a})}not(){return g(this,w(t=>!t))}or(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=D(o),a=new Array(r);for(let l=0;l<r;l++){let u=e[l],c=i?o[l]:o;u===!0||c===!0?a[l]=!0:u==null||c==null?a[l]=null:a[l]=!1}return a})}xor(t){return g(this,U(this,t,(e,n)=>!!e!=!!n))}};var Ut=class{constructor(t){this.expr=t}expr;_deriveDate(t){return g(this.expr,w(e=>{let n=X(e);return n?t(n):null}))}_deriveDuration(t){return g(this.expr,w(e=>typeof e=="number"?t(e):null))}century(){return this._deriveDate(on)}date(){return this._deriveDate(t=>new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())))}datetime(){return this._deriveDate(t=>t)}day(){return this._deriveDate(t=>t.getUTCDate())}epoch(t="ms"){return this._deriveDate(e=>sn(e,t))}hour(){return this._deriveDate(t=>t.getUTCHours())}is_leap_year(){return this._deriveDate(hn)}microsecond(){return this._deriveDate(t=>t.getUTCMilliseconds()*vt)}millennium(){return this._deriveDate(ln)}millisecond(){return this._deriveDate(t=>t.getUTCMilliseconds())}minute(){return this._deriveDate(t=>t.getUTCMinutes())}month(){return this._deriveDate(t=>t.getUTCMonth()+1)}month_end(){return this._deriveDate(t=>ue(t,1,0))}month_start(){return this._deriveDate(t=>ue(t,0,1))}nanosecond(){return this._deriveDate(t=>t.getUTCMilliseconds()*Ot)}ordinal_day(){return this._deriveDate(un)}quarter(){return this._deriveDate(cn)}second(){return this._deriveDate(t=>t.getUTCSeconds())}strftime(t,e){return this._deriveDate(n=>fn(n,t,e))}time(){return this._deriveDate(t=>t.toISOString().split("T")[1].slice(0,12))}timestamp(t="ms"){return this.epoch(t)}to_string(t,e){return this.strftime(t,e)}total_days(){return this._deriveDuration(t=>t/dt)}total_hours(){return this._deriveDuration(t=>t/rn)}total_microseconds(){return this._deriveDuration(t=>t*vt)}total_milliseconds(){return this._deriveDuration(t=>t)}total_minutes(){return this._deriveDuration(t=>t/nn)}total_nanoseconds(){return this._deriveDuration(t=>t*Ot)}total_seconds(){return this._deriveDuration(t=>t/le)}week(){return this._deriveDate(an)}weekday(){return this._deriveDate(t=>t.getUTCDay()||7)}year(){return this._deriveDate(t=>t.getUTCFullYear())}},xe=s=>class extends s{get dt(){return new Ut(this)}};var Mt=class{constructor(t){this.expr=t}expr;_deriveList(t){return g(this.expr,w(e=>D(e)?t(e):null))}all(){return this._deriveList(t=>{let e=Array.from(t);for(let n=0;n<e.length;n++)if(!e[n])return!1;return!0})}any(){return this._deriveList(t=>{let e=Array.from(t);for(let n=0;n<e.length;n++)if(e[n])return!0;return!1})}contains(t){return this._deriveList(e=>Array.from(e).includes(t))}contains_all(t){return this._deriveList(e=>{let n=Array.from(e);for(let r=0;r<t.length;r++)if(!n.includes(t[r]))return!1;return!0})}contains_any(t){return this._deriveList(e=>{let n=Array.from(e);for(let r=0;r<t.length;r++)if(n.includes(t[r]))return!0;return!1})}count_matches(t){return this._deriveList(e=>{let n=Array.from(e),r=0;for(let o of n)o===t&&r++;return r})}drop_nulls(){return this._deriveList(t=>{let e=Array.from(t),n=[];for(let r=0;r<e.length;r++)e[r]!=null&&n.push(e[r]);return n})}first(t=!0){return this.get(0,t)}gather(t,e=!0){let n=Array.isArray(t)?t:[t];return this._deriveList(r=>{let o=r.length,i=new Array(n.length);for(let a=0;a<n.length;a++){let l=n[a],u=r.at(l);if(u===void 0&&!e)throw new et(`Index ${l} is out of bounds for list of length ${o}`);i[a]=u??null}return i})}gather_every(t,e=0){if(t<=0)throw new et("Step size n must be positive");return this._deriveList(n=>{let r=n.length,o=[];for(let i=e;i<r;i+=t)o.push(n[i]);return o})}get(t,e=!0){return this._deriveList(n=>{let r=n.at(t);if(r===void 0&&!e)throw new et(`Index ${t} is out of bounds for list of length ${n.length}`);return r??null})}join(t,{ignoreNulls:e=!1}={}){return this._deriveList(n=>{let r=Array.from(n),o=[];for(let i=0;i<r.length;i++){let a=r[i];a!=null?o.push(String(a)):e||o.push("")}return o.join(t)})}last(t=!0){return this.get(-1,t)}len(){return this.lengths()}lengths(){return this._deriveList(t=>t.length)}max(){return this._deriveList(t=>j(t).max)}mean(){return this._deriveList(t=>{let{sum:e,count:n}=j(t);return e!==null&&n>0?e/n:null})}median(){return this._deriveList(t=>{if(!Z(t,"number",{allowNulls:!0}))return null;let e=t.length,n=[];for(let i=0;i<e;i++){let a=t[i];a!=null&&n.push(a)}let r=n.length;if(r===0)return null;n.sort((i,a)=>i-a);let o=Math.floor(r/2);return r%2!==0?n[o]:(n[o-1]+n[o])/2})}min(){return this._deriveList(t=>j(t).min)}mode(){return this._deriveList(t=>{let e=t.length,n=new Map,r=0;for(let i=0;i<e;i++){let a=t[i];if(a==null)continue;let l=(n.get(a)??0)+1;n.set(a,l),l>r&&(r=l)}if(r===0)return[];let o=[];for(let[i,a]of n.entries())a===r&&o.push(i);return ce(o)})}n_unique(){return this._deriveList(t=>new Set(Array.from(t)).size)}reverse(){return this._deriveList(t=>Array.from(t).reverse())}slice(t,e){return this._deriveList(n=>{let r=Array.from(n),o=t<0?Math.max(0,r.length+t):t,i=e!==void 0?o+e:r.length;return r.slice(o,i)})}sort(t=!1){return this._deriveList(e=>ce(e,t))}sum(){return this._deriveList(t=>j(t).sum)}unique(){return this._deriveList(t=>Array.from(new Set(t)))}},be=s=>class extends s{get list(){return new Mt(this)}};var dn=s=>class extends s{fill_null(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=new Array(r);if(D(o))for(let a=0;a<r;a++){let l=e[a];i[a]=l??o[a]}else for(let a=0;a<r;a++){let l=e[a];i[a]=l??o}return i})}reverse(){return g(this,t=>t.slice().reverse())}};var k=class extends be(xe(de(ye(ge(pe(me(fe(dn(bt))))))))){colName;excludedCols=[];constructor(t){super(),this.colName=String(t),this.outputName=this.colName}};function we(s){let t=new k(he);return t.isLiteral=!0,t.literalValue=s,t.ops.push(e=>{let n=e.length,r=new Array(n);for(let o=0;o<n;o++)r[o]=s;return r}),t}function _e(){return new k("*")}function Te(s){let t=new k("*");return t.excludedCols=Array.isArray(s)?s:[s],t}function De(...s){let t=s.length===1&&Array.isArray(s[0])?s[0]:s,e=new k("*coalesce*");return e.ops.push((n,r)=>{let o=n.length,i=c=>c&&typeof c=="object"&&"evaluate"in c?c.evaluate(r,o):typeof c=="string"?r[c]||new Array(o).fill(null):c,a=t.map(i),l=new Array(o),u=a.length;for(let c=0;c<o;c++){let h=null;for(let f=0;f<u;f++){let m=a[f],p=D(m)?m[c]:m;if(p!=null){h=p;break}}l[c]=h}return l}),e}var Ft=class{predicates;values;constructor(t,e){this.predicates=t,this.values=e}then(t){return new _t(this.predicates,this.values.concat(t))}},Nt=class{predicates;constructor(t){this.predicates=[t]}then(t){return new _t(this.predicates,[t])}},_t=class s extends k{predicates;values;otherwiseValue;constructor(t,e,n=null){super(typeof t=="string"?t:"*when*"),this.predicates=Array.isArray(t)?t:[],this.values=e||[],this.otherwiseValue=n,this.ops.push((r,o)=>{let i=r.length,a=m=>m&&typeof m=="object"&&"evaluate"in m?m.evaluate(o,i):typeof m=="string"&&m in o?o[m]:m,l=this.predicates.map(a),u=this.values.map(a),c=a(this.otherwiseValue),h=new Array(i),f=l.length;for(let m=0;m<i;m++){let p=!1;for(let y=0;y<f;y++)if((D(l[y])?l[y][m]:l[y])===!0){h[m]=D(u[y])?u[y][m]:u[y],p=!0;break}p||(h[m]=D(c)?c[m]:c)}return h})}when(t){return new Ft(this.predicates.concat(t),this.values)}otherwise(t){return new s(this.predicates,this.values,t)}};function Ae(s){return new Nt(s)}function ft(s,t,e){let n=[],r=e?new Set(e):new Set;for(let o of s)if(typeof o=="string")n.push(new k(o));else if(o instanceof k&&o.colName==="*"){let i=new Set(o.excludedCols);for(let a of t)if(!r.has(a)&&!i.has(a)){let l=new k(a);l.ops=[...o.ops],l.aggFn=o.aggFn,l.partitionOpsIndex=o.partitionOpsIndex,l.groupingOpsIndex=o.groupingOpsIndex,l.partitionBy=o.partitionBy,o.evaluateWindow&&(l.evaluateWindow=o.evaluateWindow),o.outputName&&o.outputName!=="*"&&(l.outputName=o.outputName),n.push(l)}}else if(o&&typeof o=="object"&&"evaluate"in o&&!o.colName){for(let i of t)if(!r.has(i)){let a=new k(i);a.ops=[...o.ops],a.aggFn=o.aggFn,a.groupingOpsIndex=o.groupingOpsIndex,a.partitionOpsIndex=o.partitionOpsIndex,n.push(a)}}else n.push(o);return n}var z=class{get isNumeric(){return!1}get isInteger(){return!1}get isFloat(){return!1}get isSigned(){return!1}get isUnsigned(){return!1}get isTemporal(){return!1}get isNested(){return!1}get isBoolean(){return!1}get isString(){return!1}get isUtf8(){return!1}get isObject(){return!1}get isNull(){return!1}get isBinary(){return!1}},lt=class extends z{get isNumeric(){return!0}},Tt=class extends lt{get isInteger(){return!0}},ot=class extends Tt{get isSigned(){return!0}},it=class extends Tt{get isUnsigned(){return!0}},mt=class extends lt{get isFloat(){return!0}},at=class extends z{get isTemporal(){return!0}},pt=class extends z{get isNested(){return!0}};var Lt=class extends ot{name="Int8";coerce(t){return tt(t,"Int8")}equals(t){return t.name==="Int8"}allocate(t){return new Int8Array(t)}},Ce=new Lt,jt=class extends ot{name="Int16";coerce(t){return tt(t,"Int16")}equals(t){return t.name==="Int16"}allocate(t){return new Int16Array(t)}},Ie=new jt,Bt=class extends ot{name="Int32";coerce(t){return tt(t,"Int32")}equals(t){return t.name==="Int32"}allocate(t){return new Int32Array(t)}},Se=new Bt,Vt=class extends ot{name="Int64";coerce(t){return ae(t)}equals(t){return t.name==="Int64"}allocate(t){return new BigInt64Array(t)}},ke=new Vt,Kt=class extends it{name="UInt8";coerce(t){return tt(t,"UInt8")}equals(t){return t.name==="UInt8"}allocate(t){return new Uint8Array(t)}},Ee=new Kt,$t=class extends it{name="UInt16";coerce(t){return tt(t,"UInt16")}equals(t){return t.name==="UInt16"}allocate(t){return new Uint16Array(t)}},ve=new $t,Pt=class extends it{name="UInt32";coerce(t){return tt(t,"UInt32")}equals(t){return t.name==="UInt32"}allocate(t){return new Uint32Array(t)}},Oe=new Pt,Wt=class extends it{name="UInt64";coerce(t){return ae(t,"UInt64")}equals(t){return t.name==="UInt64"}allocate(t){return new BigUint64Array(t)}},Re=new Wt,qt=class extends mt{name="Float32";coerce(t){return ie(t,"Float32")}equals(t){return t.name==="Float32"}allocate(t){return new Float32Array(t)}},Ue=new qt,Ht=class extends mt{name="Float64";coerce(t){return ie(t,"Float64")}equals(t){return t.name==="Float64"}allocate(t){return new Float64Array(t)}},Me=new Ht,Dt=class s extends lt{constructor(e,n){super();this.precision=e;this.scale=n;this.name=e!==void 0&&n!==void 0?`Decimal(${e}, ${n})`:"Decimal"}precision;scale;name;coerce(e){return St(e,{precision:this.precision,scale:this.scale})}equals(e){return e instanceof s&&this.precision===e.precision&&this.scale===e.scale}allocate(e){return new Array(e).fill(null)}},Gt=class extends z{name="Boolean";get isBoolean(){return!0}coerce(t){return t==null?null:!!t}equals(t){return t.name==="Boolean"}allocate(t){return new Array(t).fill(null)}},Fe=new Gt,zt=class extends z{name="Utf8";get isString(){return!0}get isUtf8(){return!0}coerce(t){return t==null?null:String(t)}equals(t){return t.name==="Utf8"}allocate(t){return new Array(t).fill(null)}},Ne=new zt,Yt=class extends z{name="Binary";get isBinary(){return!0}coerce(t){return gn(t)}equals(t){return t.name==="Binary"}allocate(t){return new Array(t).fill(null)}},Le=new Yt,Zt=class extends z{name="Null";get isNull(){return!0}coerce(t){return null}equals(t){return t.name==="Null"}allocate(t){return new Array(t).fill(null)}},je=new Zt,Xt=class extends z{name="Object";get isObject(){return!0}coerce(t){return t===void 0?null:t}equals(t){return t.name==="Object"}allocate(t){return new Array(t).fill(null)}},Be=new Xt,Jt=class extends at{name="Date";coerce(t){let e=X(t);return e?(e.setUTCHours(0,0,0,0),e):null}equals(t){return t.name==="Date"}allocate(t){return new Array(t).fill(null)}},Ve=new Jt,Qt=class extends at{name="Datetime";coerce(t){return X(t)}equals(t){return t.name==="Datetime"}allocate(t){return new Array(t).fill(null)}},Ke=new Qt,te=class extends at{name="Time";coerce(t){if(t==null)return null;if(typeof t=="string"){let n=t.trim();if(kt.test(n)){let r=new globalThis.Date(`1970-01-01T${n}${Et.test(n)?"":"Z"}`);if(G(r))return r.toISOString().split("T")[1].slice(0,12)}}let e=X(t);return e?e.toISOString().split("T")[1].slice(0,12):null}equals(t){return t.name==="Time"}allocate(t){return new Array(t).fill(null)}},$e=new te,ee=class extends at{name="Duration";coerce(t){return Q(t)}equals(t){return t.name==="Duration"}allocate(t){return new Array(t).fill(null)}},Pe=new ee,ne=class s extends pt{constructor(e){super();this.innerType=e}innerType;name="List";coerce(e){if(e==null)return null;let n=D(e)?Array.from(e):[e],r=n.length,o=new Array(r);for(let i=0;i<r;i++)o[i]=this.innerType.coerce(n[i]);return o}equals(e){return e instanceof s&&this.innerType.equals(e.innerType)}allocate(e){return new Array(e).fill(null)}},We=s=>new ne(s),re=class s extends pt{constructor(e){super();this.fields=e}fields;name="Struct";coerce(e){if(!Y(e))return null;let n={};for(let[r,o]of globalThis.Object.entries(this.fields))n[r]=o.coerce(e[r]);return n}equals(e){if(!(e instanceof s))return!1;let n=globalThis.Object.keys(this.fields),r=globalThis.Object.keys(e.fields);if(n.length!==r.length)return!1;for(let o of n)if(!e.fields[o]||!this.fields[o].equals(e.fields[o]))return!1;return!0}allocate(e){return new Array(e).fill(null)}},qe=s=>new re(s);var L={Int8:Ce,Int16:Ie,Int32:Se,Int64:ke,UInt8:Ee,UInt16:ve,UInt32:Oe,UInt64:Re,Float32:Ue,Float64:Me,Decimal:(s,t)=>new Dt(s,t),Boolean:Fe,Utf8:Ne,Binary:Le,Date:Ve,Datetime:Ke,Time:$e,Duration:Pe,Object:Be,Null:je,List:We,Struct:qe};function En(s,t,e){let n=new Map,r=e.length,o=new Array(r);for(let i=0;i<r;i++){let a=e[i];typeof a=="string"?(W(a,s,"Partition key"," in the DataFrame."),o[i]=s[a]):o[i]=a.evaluate(s,t)}for(let i=0;i<t;i++){let a=new Array(o.length);for(let c=0;c<o.length;c++){let h=o[c][i];a[c]=h==null?"":String(h)}let l=a.join("\0"),u=n.get(l);u===void 0&&(u=[],n.set(l,u)),u.push(i)}return n}function se(s,t,e){let n=new Array(e);if(e===0)return n;let r=s.partitionBy||[],o=En(t,e,r),i=s.evaluatePrePartition(t,e);for(let a of o.values()){let l=a.length,u=new Array(l);for(let c=0;c<l;c++)u[c]=i[a[c]];if(s.evaluateWindow){for(let c=0;c<l;c++)n[a[c]]=s.evaluateWindow(u,a,c);continue}if(s.aggFn){let c=s.aggFn(u);for(let h=0;h<l;h++)n[a[h]]=c;continue}for(let c=0;c<l;c++)n[a[c]]=i[a[c]]}return s.evaluatePostPartition(n,t)}function He(s){if(!Array.isArray(s)||s.length===0)return{columns:{},height:0};let t=s.length,e=new Set;for(let o=0;o<t;o++){let i=s[o];if(Y(i)){let a=Object.keys(i);for(let l=0;l<a.length;l++)e.add(a[l])}}let n=Array.from(e),r={};for(let o=0;o<n.length;o++)r[n[o]]=new Array(t);for(let o=0;o<t;o++){let i=s[o]||{};for(let a=0;a<n.length;a++){let l=n[a],u=i[l];r[l][o]=u===void 0?null:u}}return{columns:r,height:t}}function Ge(s,t){let e=Object.keys(s),n=new Array(t);for(let r=0;r<t;r++){let o={};for(let i=0;i<e.length;i++){let a=e[i],l=s[a][r];o[a]=l===void 0?null:l}n[r]=o}return n}function vn(s,t,e){let n={};for(let r=0;r<e.length;r++){let o=e[r],i=s[o][t];n[o]=i===void 0?null:i}return n}function nt(s){if(s.length===0)return L.Utf8;let t=!0,e=!0,n=!0,r=!0,o=!0,i=!0,a=!1,l=!1,u=[];for(let c=0;c<s.length;c++){let h=s[c];if(h!=null){if(l=!0,!Array.isArray(h))i=!1;else for(let f=0;f<h.length;f++)u.push(h[f]);h instanceof Date&&(a=!0),typeof h!="boolean"&&(t=!1),typeof h!="bigint"&&(r=!1),typeof h!="number"?(n=!1,e=!1):Number.isInteger(h)||(e=!1),!(h instanceof Date)&&(typeof h!="string"||isNaN(Date.parse(h)))&&(o=!1)}}if(!l)return L.Utf8;if(i){let c=nt(u);return L.List(c)}if(t)return L.Boolean;if(r)return L.Int64;if(n&&!e)return L.Float64;if(n&&e){let c=!0;for(let h=0;h<s.length;h++){let f=s[h];if(f!=null&&(f<-2147483648||f>2147483647)){c=!1;break}}return c?L.Int32:L.Float64}return o&&a?L.Datetime:L.Utf8}function At(s,t){let e=Object.keys(s),n=e.length,r=t.length,o={};for(let i=0;i<n;i++){let a=e[i],l=s[a],u=new Array(r);for(let c=0;c<r;c++)u[c]=l[t[c]];o[a]=u}return o}var Ct=class{groups;keys;allKeys;parentColumns;parentHeight;parentSchema;constructor(t,e,n,r,o,i){this.groups=t,this.keys=e,this.allKeys=n,this.parentColumns=r,this.parentHeight=o,this.parentSchema=i}to_dataframe(){let t=this.keys.length,e=new Array(t);for(let a=0;a<t;a++)e[a]=String(this.keys[a]);let n=this.groups.size,r={};for(let a=0;a<e.length;a++)r[e[a]]=new Array(n);let o=0;for(let a of this.groups.values()){if(a.length===0)continue;let l=a[0];for(let u=0;u<e.length;u++){let c=e[u],h=this.parentColumns[c][l];r[c][o]=h===void 0?null:h}o++}let i={};for(let a of e)i[a]=this.parentSchema[a];return new F(r,i,o)}agg(...t){let e=this.allKeys.length,n=new Array(e);for(let h=0;h<e;h++)n[h]=String(this.allKeys[h]);let r=this.keys.length,o=new Array(r);for(let h=0;h<r;h++)o[h]=String(this.keys[h]);let i=ft(t.flat(),n,o),a=this.groups.size,l={};for(let h=0;h<o.length;h++)l[o[h]]=new Array(a);let u=0;for(let h of this.groups.values()){if(h.length===0)continue;let f=h[0];for(let m=0;m<o.length;m++){let p=o[m],y=this.parentColumns[p][f];l[p][u]=y===void 0?null:y}u++}for(let h=0;h<i.length;h++){let f=i[h],m=f.outputName||f.colName||"*";if(!f.aggFn){l[m]=f.evaluate(l,a);continue}let p=f.evaluatePreGrouping(this.parentColumns,this.parentHeight),y=new Array(a),x=0;for(let b of this.groups.values()){if(b.length===0)continue;let T=new Array(b.length);for(let A=0;A<b.length;A++)T[A]=p[b[A]];y[x]=f.aggFn(T),x++}l[m]=f.evaluatePostGrouping(y,l)}let c={};for(let h of o)c[h]=this.parentSchema[h];for(let h of i){let f=h.outputName||h.colName||"*";c[f]=nt(l[f])}return new F(l,c,u)}};function xn(s,t,e){if(s==null)throw new V(`Invalid input to ${t} at index ${e}: item cannot be null or undefined.`);if(s instanceof F)return[s];if(xt(s))return[new F(s)];if(D(s)){if(Z(s,F,{mode:"every"}))return s;if(Z(s,"plainObject",{mode:"every"}))return[new F(s)];let n=Z(s,F,{mode:"some"});for(let r=0;r<s.length;r++)if(n?!(s[r]instanceof F):!xt(s[r]))throw new V(n?`Invalid input to ${t} at index ${e}, sub-index ${r}: nested array must contain only DataFrame instances.`:`Invalid input to ${t} at index ${e}, row ${r}: rows must be plain objects.`)}throw new V(`Invalid input to ${t} at index ${e}: expected DataFrame, row array, or column dictionary.`)}function It(s,t={}){if(s==null)throw new V("Invalid input to concat: rawItems cannot be null or undefined.");let e=Array.isArray(s)?s:[s],n=[];for(let i=0;i<e.length;i++)n.push(...xn(e[i],"concat",i));let{how:r="vertical"}=t,o=t.horizontal?.strict??!0;if(n.length===0)return new F({},{},0);if(n.length===1&&r!=="horizontal")return n[0];switch(r){case"vertical":{let i=[];for(let m=0;m<n.length;m++)n[m].height>0&&i.push(n[m]);if(i.length===0)return new F({},{},0);let a=i[0],l=Object.keys(a._columns);for(let m=0;m<n.length;m++){let p=n[m];if(p.height===0)continue;let y=Object.keys(p._columns);if(l.length!==y.length)throw new V(`[Strict Vertical] Column count mismatch at index ${m}.`);for(let x=0;x<l.length;x++){if(l[x]!==y[x])throw new V(`[Strict Vertical] Schema mismatch at position ${x} in DF ${m}. Expected column "${l[x]}", but found "${y[x]}".`);let b=a.schema[l[x]],T=p.schema[l[x]];if(b&&T&&!b.equals(T))throw new ht(`[Strict Type Check] Schema type mismatch for column "${l[x]}": expected ${b.name}, found ${T.name}.`)}}let u=0;for(let m of n)u+=m.height;let c=n.find(m=>m.height>0)?.schema||n[0]?.schema||{},h={};for(let m of l){let p=c[m],y=!1;for(let b of n){let T=b._columns[m];if(!T){y=!0;break}if(!$(T)){for(let A=0;A<T.length;A++)if(T[A]==null){y=!0;break}}if(y)break}let x=p&&p.allocate?p.allocate(u):new Array(u).fill(null);y&&$(x)&&(x=new Array(u).fill(null)),h[m]=x}let f=0;for(let m of n){let p=m.height;if(p!==0){for(let y of l){let x=m._columns[y]||new Array(p).fill(null),b=h[y];if($(b)&&$(x))b.set(x,f);else{let T=b;for(let A=0;A<p;A++)T[f+A]=x[A]}}f+=p}}return new F(h,c,u)}case"horizontal":{let i=n[0].height;for(let c=1;c<n.length;c++)n[c].height>i&&(i=n[c].height);let a=new Set;for(let c=0;c<n.length;c++){let h=n[c];if(o&&h.height!==i)throw new V(`[Horizontal] Row count mismatch at index ${c}. Expected ${i}, got ${h.height}. Set strict=false to allow padding.`);for(let f of Object.keys(h._columns)){if(a.has(f))throw new V(`[Horizontal] Duplicate column name "${f}" detected. Horizontal concat requires unique names.`);a.add(f)}}let l={},u={};for(let c of n){let h=c.height;Object.assign(u,c.schema);for(let[f,m]of Object.entries(c._columns))if(h===i)l[f]=$(m)?Array.from(m):m;else{let p=new Array(i);for(let y=0;y<h;y++)p[y]=m[y];for(let y=h;y<i;y++)p[y]=null;l[f]=p}}return new F(l,u,i)}case"diagonal":{let i=new Set;for(let f of n)for(let m of Object.keys(f._columns))i.add(m);let a=Array.from(i),l=0;for(let f=0;f<n.length;f++)l+=n[f].height;let u={};for(let f of a){let m=null;for(let p of n){let y=p.schema[f];if(y){if(m===null)m=y;else if(!m.equals(y))throw new ht(`[Strict Type Check] Schema type mismatch for column "${f}": expected ${m.name}, found ${y.name}.`)}}u[f]=m||L.Utf8}let c={};for(let f=0;f<a.length;f++)c[a[f]]=new Array(l).fill(null);let h=0;for(let f=0;f<n.length;f++){let m=n[f],p=m.height;if(p!==0){for(let y=0;y<a.length;y++){let x=a[y],b=c[x],T=m._columns[x];if(T!==void 0)if($(T)&&$(b))b.set(T,h);else{let A=b;for(let S=0;S<p;S++)A[h+S]=T[S]}else{let A=b;for(let S=0;S<p;S++)A[h+S]=null}}h+=p}}return new F(c,u,l)}}}var F=class s{_columns;_height;_schema={};constructor(t,e,n){if(Array.isArray(t)){let{columns:r,height:o}=He(t);this._columns=r,this._height=o,e?this.applySchema(e):this.inferSchema();return}if(Y(t)){let r=-1;for(let[o,i]of Object.entries(t)){let a=D(i)?i.length:0;if(r===-1)r=a;else if(a!==r)throw new V(`Column height mismatch: Column "${o}" has length ${a}, but previous columns have length ${r}`)}this._columns=t,this._height=n!==void 0?n:r===-1?0:r,e?this.applySchema(e):this.inferSchema();return}this._columns={},this._height=0,e?this.applySchema(e):this._schema={}}inferSchema(){let t={},e=Object.keys(this._columns);for(let n of e)t[n]=nt(this._columns[n]);this._schema=t}applySchema(t){this._schema=t;let e=Object.keys(t),n={};for(let r of e){let o=t[r],i=this._columns[r],a=o.allocate?o.allocate(this._height):new Array(this._height).fill(null);if(!i){this._height>0&&$(a)&&(a=new Array(this._height).fill(null)),n[r]=a;continue}let l=!1,u=new Array(this._height);for(let c=0;c<this._height;c++){let h=o.coerce(i[c]);u[c]=h,h==null&&(l=!0)}l&&$(a)&&(a=new Array(this._height));for(let c=0;c<this._height;c++)a[c]=u[c];n[r]=a}this._columns=n}getSchema(){return this._schema}to_dicts(){return Ge(this._columns,this._height)}to_dict(){return{...this._columns}}get columns(){return Object.keys(this._columns)}concat(t,e={}){let n=Z(t,s,{mode:"every",allowEmpty:!1})?t:[t];return It([this,...n],e)}drop(...t){let e=new Set(t.flat()),n={},r={};for(let o of Object.keys(this._columns))e.has(o)||(n[o]=this._columns[o],r[o]=this._schema[o]);return new s(n,r,this._height)}get dtypes(){let t=Object.keys(this._columns),e=t.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=this._schema[t[r]];return n}filter(...t){if(this._height===0)return new s({},this._schema,0);let e=this._height,n=Object.keys(this._columns),r=n.length,o=[],i=[];for(let f of t)typeof f=="function"?i.push(f):o.push(f.evaluate(this._columns,e));let a=[],l=0,u=null;if(i.length>0){let f=this._columns;u={};for(let m=0;m<r;m++){let p=n[m],y=f[p];Object.defineProperty(u,p,{get(){let x=y[l];return x===void 0?null:x},enumerable:!0,configurable:!0})}}for(let f=0;f<e;f++){let m=!0;for(let p=0;p<o.length;p++)if(!o[p][f]){m=!1;break}if(m){if(u){l=f;for(let p=0;p<i.length;p++)if(!i[p](u)){m=!1;break}}m&&a.push(f)}}let c=At(this._columns,a),h=a.length;return new s(c,this._schema,h)}groupby(t){let e=st(t),n=new Map,r=this._height,o=e.length,i=new Array(o);for(let c=0;c<o;c++)i[c]=String(e[c]);for(let c=0;c<i.length;c++)W(i[c],this._columns,"Grouping key");let a=o===1?i[0]:null,l=a?this._columns[a]:null;for(let c=0;c<r;c++){let h;if(a){let m=l[c];h=m==null?"":String(m)}else{let m=new Array(o);for(let p=0;p<o;p++){let y=this._columns[i[p]][c];m[p]=y==null?"":String(y)}h=m.join("\0")}let f=n.get(h);f===void 0&&n.set(h,f=[]),f.push(c)}let u=Object.keys(this._columns);return new Ct(n,e,u,this._columns,this._height,this._schema)}head(t=10){return this.limit(t,{offset:0,from:"start"})}get height(){return this._height}hstack(t,e={}){return this.concat(t,{how:"horizontal",horizontal:e})}join(t){let{other:e,on:n,how:r="inner",suffixes:o=["","_right"]}=t,i=st(n);for(let _ of i){let C=String(_);W(C,this._columns,"Join key"," in the left DataFrame."),W(C,e._columns,"Join key"," in the right DataFrame.")}let[a,l]=o,u=Object.keys(this._columns),c=Object.keys(e._columns),h=new Set(i),f=u.length,m=c.length,p=(_,C)=>{let v=i.length;if(v===1){let O=_[i[0]][C];return O==null?null:String(O)}let M=new Array(v);for(let O=0;O<v;O++){let q=_[i[O]][C];if(q==null)return null;M[O]=String(q)}return M.join("\0")},y=new Map,x=e._height,b=e._columns;for(let _=0;_<x;_++){let C=p(b,_);if(C===null)continue;let v=y.get(C);v===void 0&&(v=[],y.set(C,v)),v.push(_)}let T=this._height,A=this._columns,S=[],d=[],I=r==="outer"||r==="right",R=I?new Set:null;for(let _=0;_<T;_++){let C=p(A,_),v=C===null?void 0:y.get(C);if(v===void 0)(r==="left"||r==="outer")&&(S.push(_),d.push(null));else for(let M=0;M<v.length;M++){let O=v[M];I&&R.add(O),S.push(_),d.push(O)}}if(I)for(let _=0;_<x;_++)R.has(_)||(S.push(-1),d.push(_));let E=S.length,N={},K={};for(let _=0;_<f;_++){let C=u[_],v=C in e._columns&&!h.has(C)?`${C}${a}`:C,M=this._columns[C],O=h.has(C),q=new Array(E);if(O){let H=e._columns[C];for(let J=0;J<E;J++){let ze=S[J];if(ze!==-1)q[J]=M[ze];else{let Ye=d[J];q[J]=Ye!==null?H[Ye]:null}}}else for(let H=0;H<E;H++){let J=S[H];q[H]=J!==-1?M[J]:null}N[v]=q,this._schema[C]&&(K[v]=this._schema[C])}for(let _=0;_<m;_++){let C=c[_];if(!h.has(C)){let v=C in this._columns?`${C}${l}`:C,M=e._columns[C],O=new Array(E);for(let q=0;q<E;q++){let H=d[q];O[q]=H!==null?M[H]:null}N[v]=O,e._schema[C]&&(K[v]=e._schema[C])}}return new s(N,K,E)}limit(t,e={}){let{offset:n=0,from:r="start"}=e,o=this._height,i=isNaN(t)?0:Math.max(Math.floor(t),0),a=isNaN(n)?0:Math.max(Math.floor(n),0);if(i===0||o===0||a>=o){let f={},m={};for(let p of Object.keys(this._columns))f[p]=[],m[p]=this._schema[p];return new s(f,m,0)}let l=0,u=0;r==="end"?(u=Math.max(o-a,0),l=Math.max(u-i,0)):(u=Math.min(a+i,o),l=a);let c=Math.max(u-l,0),h={};for(let f of Object.keys(this._columns))h[f]=this._columns[f].slice(l,u);return new s(h,this._schema,c)}pivot(t){if(this._height===0)return new s({},{},0);let{index:e,columns:n,values:r}=t,o=st(e),i=o.length,a=new Array(i);for(let d=0;d<i;d++)a[d]=String(o[d]);let l=String(n),u=String(r);for(let d of a)W(d,this._columns,"Pivot index key"," in the DataFrame.");W(l,this._columns,"Pivot column key"),W(u,this._columns,"Pivot values key"," in the DataFrame.");let c=new Map,h=new Set,f=this._height,m=this._columns[l],p=this._columns[u];for(let d=0;d<f;d++){let I=new Array(i);for(let K=0;K<i;K++){let _=this._columns[a[K]][d];I[K]=_==null?"":String(_)}let R=I.join("\0"),E=String(m[d]);h.add(E);let N=c.get(R);N===void 0&&(N={firstIdx:d,indices:[]},c.set(R,N)),N.indices.push(d)}let y=c.size,x={},b={};for(let d=0;d<i;d++){let I=a[d];x[I]=new Array(y),this._schema[I]&&(b[I]=this._schema[I])}let T=Array.from(h),A=this._schema[u]||L.Utf8;for(let d=0;d<T.length;d++){let I=T[d];x[I]=new Array(y).fill(null),b[I]=A}let S=0;for(let d of c.values()){let I=d.firstIdx;for(let E=0;E<i;E++){let N=a[E];x[N][S]=this._columns[N][I]}let R=d.indices;for(let E=0;E<R.length;E++){let N=R[E],K=String(m[N]);x[K][S]=p[N]}S++}return new s(x,b,y)}rename(t){let e=t||{},n={},r={},o=Object.keys(this._columns);for(let a of o){let l=e[a]||a;n[l]=this._columns[a],r[l]=this._schema[a]}if(Object.keys(n).length<o.length)throw new V("Rename collision: Multiple columns mapped to the same output name.");return new s(n,r,this._height)}reverse(){if(this._height===0)return this;let t={},e=Object.keys(this._columns),n=e.length;for(let r=0;r<n;r++){let o=e[r];t[o]=this._columns[o].slice().reverse()}return new s(t,this._schema,this._height)}get schema(){return this._schema}select(...t){let e=this._normalizeArgs(t),n=Object.keys(this._columns),r=ft(e,n),o={},i={};for(let a of r){let l=a.outputName||a.colName||"*";if(l in o)throw new V(`Duplicate column selection: "${l}" is selected multiple times.`);o[l]=a.isWindow?se(a,this._columns,this._height):a.evaluate(this._columns,this._height);let u=a.colName||l,c=a instanceof k&&a.ops.length===0&&!a.isWindow&&!a.aggFn;i[l]=c&&this._schema[u]?this._schema[u]:nt(o[l])}return new s(o,i,this._height)}get shape(){return[this.height,this.width]}slice(t,e){let n=this._height,r=t<0?Math.max(n+t,0):Math.min(t,n),o=e===void 0?n:e<0?Math.max(n+e,0):Math.min(e,n),i=Math.max(o-r,0);return this.limit(i,{offset:r})}sort(t){if(!t||!t.by||this._height===0)return this;let{by:e,descending:n=!1,nullsLast:r=!0,custom:o}=t,i=st(e);for(let p=0;p<i.length;p++){let y=i[p];typeof y=="string"&&W(y,this._columns,"Sort key")}let a=Array.isArray(n)?n:new Array(i.length).fill(n),l=i.length,u=new Array(l);for(let p=0;p<l;p++){let y=i[p],x=a[p]?-1:1,b=o&&typeof y=="string"?o[y]:null,T=y?.evaluate?y.evaluate(this._columns,this._height):this._columns[y]||new Array(this._height).fill(null);u[p]={values:T,isDesc:x,customComp:b}}let c=u.length,h=r?1:-1,f=new Array(this._height);for(let p=0;p<this._height;p++)f[p]=p;f.sort((p,y)=>{for(let x=0;x<c;x++){let{values:b,isDesc:T,customComp:A}=u[x],S=b[p],d=b[y];if(A){let R=A(S,d);if(R!==0)return R*T;continue}if(S==null||d==null){if(S===d)continue;return(S==null?1:-1)*h}if(S===d)continue;return(S<d?-1:1)*T}return 0});let m=At(this._columns,f);return new s(m,this._schema,this._height)}tail(t=10){return this.limit(t,{offset:0,from:"end"})}to_list(t){if(this._height===0)return[];let e=t&&typeof t!="string"&&"evaluate"in t,n;if(e)n=t.evaluate(this._columns,this._height);else{let r=t;if(r==null)return new Array(this._height).fill(null);W(r,this._columns,"Column"),n=this._columns[r]}return Array.isArray(n)?n:Array.from(n)}unique(t){if(this._height===0)return new s({},this._schema,0);let e=st(t),n=e.length===0?Object.keys(this._columns):e.map(String);for(let h of n)W(h,this._columns,"Unique column key");let r=new Set,o=[],i=n.length,a=this._height,l=i===1?this._columns[n[0]]:null;for(let h=0;h<a;h++){let f;if(l){let m=l[h];f=m==null?"":String(m)}else{let m=new Array(i);for(let p=0;p<i;p++){let y=this._columns[n[p]][h];m[p]=y==null?"":String(y)}f=m.join("\0")}r.has(f)||(r.add(f),o.push(h))}let u=At(this._columns,o),c=o.length;return new s(u,this._schema,c)}unpivot(t){let{idVars:e,valueVars:n,varName:r="variable",valueName:o="value"}=t,i=st(e).map(String),a=st(n).map(String),l=i.length,u=a.length;for(let p of i)W(p,this._columns,"Unpivot id variable key");for(let p of a)W(p,this._columns,"Unpivot value variable key");let c=this._height*u,h={};for(let p=0;p<l;p++)h[i[p]]=new Array(c);h[r]=new Array(c),h[o]=new Array(c);let f=0;for(let p=0;p<this._height;p++)for(let y=0;y<u;y++){let x=a[y];for(let b=0;b<l;b++){let T=i[b];h[T][f]=this._columns[T][p]}h[r][f]=x,h[o][f]=this._columns[x][p],f++}let m={};for(let p of i)m[p]=this._schema[p];return m[r]=L.Utf8,m[o]=nt(h[o]),new s(h,m,c)}vstack(t){return this.concat(t,{how:"vertical"})}get width(){return Object.keys(this._columns).length}_normalizeArgs(t){let e=t.flat(),n=[];for(let r of e)if(typeof r=="string")n.push(new k(r));else if(Y(r)&&"evaluate"in r)n.push(r);else if(Y(r))for(let[o,i]of Object.entries(r))if(Y(i)&&"evaluate"in i)n.push(i.alias(o));else{let a=new k(o);a.evaluate=(l,u)=>new Array(u).fill(i),n.push(a)}return n}with_columns(...t){let e=this._normalizeArgs(t),n=Object.keys(this._columns),r=ft(e,n),o=r.length,i={...this._columns},a={...this._schema};for(let l=0;l<o;l++){let u=r[l],c=u.outputName||u.colName||"*";u.isWindow?i[c]=se(u,this._columns,this._height):i[c]=u.evaluate(this._columns,this._height);let h=u.colName||c;u instanceof k&&u.ops.length===0&&!u.isWindow&&!u.aggFn&&this._schema[h]?a[c]=this._schema[h]:a[c]=nt(i[c])}return new s(i,a,this._height)}};var On={data:(s,t)=>new F(s,t),col:s=>new k(s),all:_e,exclude:Te,coalesce:De,concat:It,lit:we,when:Ae,DataType:L};0&&(module.exports={$tbl,ALL_COLUMNS_MARKER,AggregationExpr,ArithmeticExpr,Binary,BinaryType,Boolean,BooleanType,ColumnExpr,ColumnNotFoundError,ComparisonExpr,ComputeError,DFScriptError,DataFrame,DataFrameError,DataType,DataTypeRegistry,Date,DateTimeExprNamespace,DateType,Datetime,DatetimeType,DecimalType,Duration,DurationType,ExprBase,Float32,Float32Type,Float64,Float64Type,FloatDataType,GroupedData,Int16,Int16Type,Int32,Int32Type,Int64,Int64Type,Int8,Int8Type,IntegerDataType,LITERAL_MARKER,List,ListExpr,ListExprNamespace,ListType,LogicalExpr,NestedDataType,Null,NullType,NumericDataType,Object,ObjectType,SchemaError,SignedIntegerType,StringExpr,StringExprNamespace,Struct,StructType,TemporalDataType,TemporalExpr,Time,TimeType,UInt16,UInt16Type,UInt32,UInt32Type,UInt64,UInt64Type,UInt8,UInt8Type,UnsignedIntegerType,Utf8,Utf8Type,When,WhenThen,WhenThenChain,WindowExpr,all,assertColumnExists,coalesce,columnsToRows,concat,derive,exclude,gatherColumnsByIndices,getRowFromColumns,inferColumnType,kleeneBinary,kleeneUnary,lit,normalizeToDataFrames,resolveColumnSelectors,resolveWindowExpr,rowsToColumns,when});
|
|
1
|
+
"use strict";var an=Object.defineProperty;var jr=Object.getOwnPropertyDescriptor;var Vr=Object.getOwnPropertyNames;var Br=Object.prototype.hasOwnProperty;var O=(r,e)=>()=>(r&&(e=r(r=0)),e);var er=(r,e)=>{for(var t in e)an(r,t,{get:e[t],enumerable:!0})},$r=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Vr(e))!Br.call(r,o)&&o!==t&&an(r,o,{get:()=>e[o],enumerable:!(n=jr(e,o))||n.enumerable});return r};var tr=r=>$r(an({},"__esModule",{value:!0}),r);var q,ln,un,Pe,oe=O(()=>{"use strict";q="*",ln="*literal*",un="*coalesce*",Pe="*element*"});function Ee(r,e=null,{mode:t="both",returnStringOnNull:n=!1,maxScanStart:o=1,maxScanEnd:s=1,maxMatchesStart:i=1,maxMatchesEnd:a=1,trimFirst:u=!1,stringOptions:{literal:c=!1,caseInsensitive:l=!1}={}}={}){if(r==null)return n?"":null;let f=(w,D="both")=>D==="start"?w.trimStart():D==="end"?w.trimEnd():w.trim(),m=r;if(u&&e!=null&&(m=f(r,t)),e==null){let w=f(m,t);return n||w!==""?w:null}let p=e instanceof RegExp?w=>e.test(w):(()=>{let w=new Set(l?e.toLowerCase():e);return D=>w.has(l?D.toLowerCase():D)})(),h=m.length,y=new Uint8Array(h),S=c&&typeof e=="string"?({isStart:w,limit:D,maxMatches:k})=>{if(h===0||k===0)return;let W=e.length;if(W===0)return;let ce=l?m.toLowerCase():m,fe=l?e.toLowerCase():e,A=w?0:h-1,E=0,v=0;for(;A>=0&&A<h&&!(k!==null&&k>=0&&E>=k);){let M=w?A:A-W+1;if(!w&&M<0)break;let Y=w?ce.indexOf(fe,M):ce.lastIndexOf(fe,M);if(Y===-1)break;let ne=w?Y-A:A-(Y+W-1);if(v+=ne,D!==null&&D>=0&&v>=D)break;for(let Z=0;Z<W;Z++)y[Y+Z]=1;E++,A=w?Y+W:Y-1}}:({isStart:w,limit:D,maxMatches:k})=>{if(h===0||k===0)return;let W=w?0:h-1,ce=w?h:-1,fe=w?1:-1,A=!1,E=0,v=0;for(let M=W;M!==ce;M+=fe)if(p(m[M])){if(!A){if(D!==null&&D>=0&&v>=D||k!==null&&k>=0&&E>=k)break;A=!0,E++}y[M]=1}else A=!1,v++};(t==="both"||t==="start")&&S({isStart:!0,limit:o,maxMatches:i}),(t==="both"||t==="end")&&S({isStart:!1,limit:s,maxMatches:a});let _="";for(let w=0;w<h;w++)y[w]===0&&(_+=m[w]);return n||_!==""?_:null}function nr(r){return typeof r=="string"?r.trim().length===0:r instanceof String?r.valueOf().trim().length===0:!1}function $(r,{depth:e=0,maxDepth:t=50}={}){if(e>t)return"v:circular";if(r===null)return"v:null";if(r===void 0)return"v:undefined";if(r instanceof Date)return P(r)?`d:${r.getTime()}`:"d:invalid";if(L(r))return`u:${r.constructor.name}:${r.toString()}`;if(Array.isArray(r)){let n=r.length,o=new Array(n),s={depth:e+1,maxDepth:t};for(let i=0;i<n;i++)o[i]=$(r[i],s);return`a:[${o.join(",")}]`}if(r instanceof Set){let n=Array.from(r),o=n.length,s=new Array(o),i={depth:e+1,maxDepth:t};for(let a=0;a<o;a++)s[a]=$(n[a],i);return s.sort(),`set:[${s.join(",")}]`}if(r instanceof Map){let n=Array.from(r.keys()),o=n.length,s=new Array(o),i={depth:e+1,maxDepth:t};for(let a=0;a<o;a++){let u=n[a];s[a]=`${$(u,i)}:${$(r.get(u),i)}`}return s.sort(),`map:{${s.join(",")}}`}if(typeof r=="object"&&typeof r.toJSON=="function")return`j:${$(r.toJSON(),{depth:e+1,maxDepth:t})}`;if(_e(r)){let n=Object.keys(r).sort(),o=n.length,s=new Array(o),i={depth:e+1,maxDepth:t};for(let a=0;a<o;a++){let u=n[a];s[a]=`${u}:${$(r[u],i)}`}return`o:{${s.join(",")}}`}return r instanceof RegExp?`r:${r.toString()}`:typeof r=="function"?`f:${r.toString()}`:typeof r=="string"?`s:${r}`:typeof r=="symbol"?`y:${r.toString()}`:`${typeof r}:${r}`}var ht=O(()=>{"use strict";Oe();we()});function We(r){return r==null?[]:Array.isArray(r)?[...r]:L(r)?Array.from(r):[r]}function Re(r){let e=We(r),t=e.length,n=new Array(t);for(let o=0;o<t;o++)n[o]=String(e[o]);return n}function K(r,e,{mode:t="every",allowNulls:n=!1,allowEmpty:o=!0}={}){if(!T(r))return!1;let s=r.length;if(s===0)return o?t==="every":!1;let i=r,a;if(typeof e=="function")a=ir(e)?c=>c instanceof e:e;else switch(e){case"null":a=u=>u===null;break;case"undefined":a=u=>u===void 0;break;case"nullish":a=u=>u==null;break;case"any":a=()=>!0;break;case"date":a=P;break;case"object":a=G;break;case"plainObject":a=_e;break;case"number":a=te;break;default:a=u=>typeof u===e;break}if(n){let u=a;a=c=>c==null||u(c)}if(t==="every"){for(let u=0;u<s;u++)if(!a(i[u]))return!1;return!0}else{for(let u=0;u<s;u++)if(a(i[u]))return!0;return!1}}function yt(r,e=!1){if(!T(r))return[];let t=Array.from(r);return t.sort((n,o)=>n==null&&o==null?0:n==null?1:o==null?-1:n<o?e?1:-1:n>o?e?-1:1:0),t}function B(r){if(!T(r))return{...rr};let e=r.length;if(e===0)return{...rr};let t=null,n=null,o=0,s=0,i=0,a=0,u=0,c=0;for(let f=0;f<e;f++){let m=r[f];if(m==null){s++;continue}(t==null||m<t)&&(t=m),(n==null||m>n)&&(n=m);let p=X(m);if(p!==null){let h=i+p;Math.abs(i)>=Math.abs(p)?a+=i-h+p:a+=p-h+i,i=h,o++;let y=p-u;u+=y/o;let d=p-u;c+=y*d}}let l=o>1?c/(o-1):0;return{sum:o>0?i+a:null,count:o,min:t,max:n,mean:o>0?(i+a)/o:null,variance:l,std:Math.sqrt(l),nullCount:s,len:e,hasNulls:s>0,isNumeric:o>0&&o===e-s}}function Se(r,{strict:e=!1,keySelector:t}={}){let n=Array.from(r),o=new Map;if(e){let i=t??$,a=new Map,u=n.length;for(let l=0;l<u;l++){let f=n[l],m=i(f),p=a.get(m);p===void 0?a.set(m,{val:f,count:1}):p.count++}let c=[];for(let l of a.values())c.push(l.val);for(let l=0;l<u;l++){let f=n[l],m=i(f),p=a.get(m);o.set(f,p.count)}return{values:c,count:c.length,frequencies:o}}let s=n.length;for(let i=0;i<s;i++){let a=n[i];o.set(a,(o.get(a)??0)+1)}return{values:Array.from(o.keys()),count:o.size,frequencies:o}}function or(r,{step:e=1,offsetStart:t=0,offsetEnd:n,maxItemsGathered:o,null_on_oob:s=!0}={}){if(r==null)return null;if(o!==void 0&&o<=0)return[];if(e===0)throw new Error("Step size step cannot be zero");let i=r.length;if(i===0?t!==0:t>=i||t<-i){if(!s)throw new Error(`Start offset ${t} is out of bounds for list of length ${i}`);return null}let u=t<0?i+t:t,c=n!==void 0?n<0?i+n:n:e>0?i:-1,l=[];if(e>0)for(let f=u;f<c&&f<i&&!(f>=0&&(l.push(r[f]),o!==void 0&&l.length>=o));f+=e);else for(let f=u;f>c&&f>=0&&!(f<i&&(l.push(r[f]),o!==void 0&&l.length>=o));f+=e);return l}function sr(r,e=",",{ignoreNulls:t=!1,nullValue:n="",prefix:o="",suffix:s="",limit:i,truncationMarker:a="...",valueFormatter:u}={}){let c=r.length,l=[],f=i!==void 0?Math.max(0,i):c,m=!1;for(let p=0;p<c;p++){if(l.length>=f){m=!0;break}let h=r[p];h!=null?l.push(u?u(h,p):String(h)):t||l.push(n)}return o+l.join(e)+(m?a:"")+s}function De(r,e,t={}){let n=r.length,{mode:o="cumulative",step:s=1,coerce:i=y=>y,condition:a,reverse:u=!1,startIndex:c=u?n-1:0,endIndex:l=u?-1:n}=t,f=u?-1:1,m=c,p=l,h=(y,d)=>{(!a||a(r[y],y,r))&&(r[y]=i(d))};if(o==="constant"){let y=i(e);for(let d=m;u?d>p:d<p;d+=f)h(d,y)}else if(o==="independent")if(typeof s=="function"){let y=0;for(let d=m;u?d>p:d<p;d+=f)h(d,s({index:y,initialValue:e,originalValue:r[d],absoluteIndex:d,targetArray:r})),y++}else for(let y=m;u?y>p:y<p;y+=f)h(y,e+y*s);else{let y=e,d=!0,g=0;for(let b=m;u?b>p:b<p;b+=f)d?(h(b,y),d=!1):(typeof s=="function"?y=s({prev:y,index:g,originalValue:r[b],absoluteIndex:b,targetArray:r}):y=y+s,h(b,y)),g++}}var rr,cn=O(()=>{"use strict";Oe();we();Fe();ht();rr={sum:null,count:0,min:null,max:null,mean:null,variance:0,std:0,nullCount:0,len:0,hasNulls:!1,isNumeric:!1}});function te(r,e){return typeof r!="number"?!1:e&&e.allowNonFiniteNumbers?!0:!Number.isNaN(r)&&Number.isFinite(r)}function X(r,e){if(r==null||typeof r=="symbol")return null;if(te(r,e))return r;if(typeof r=="boolean")return r?1:0;if(typeof r=="bigint"){let t=Number(r);return te(t,e)?t:null}if(r instanceof Date){let t=r.getTime();return te(t,e)?t:null}if(typeof r=="string"){let t=r.trim().replace(ar,"");if(t==="")return null;let n=Number(t);return Number.isNaN(n)?e?.allowNonFiniteNumbers&&t.toLowerCase()==="nan"?NaN:null:te(n,e)?n:null}return null}function lr({locale:r="en-US",accountingNegatives:e=!1,fallback:t="NaN",...n}={}){n.useGrouping===void 0&&(n.useGrouping=!1),n.maximumFractionDigits===void 0&&n.maximumSignificantDigits===void 0&&(n.maximumFractionDigits=20);let o=new Intl.NumberFormat(r,n);return s=>{if(typeof s=="bigint")return e&&s<0n?`(${o.format(-s)})`:o.format(s);let i=X(s,{allowNonFiniteNumbers:!0});return i===null||Number.isNaN(i)?t:Number.isFinite(i)?e&&i<0?`(${o.format(Math.abs(i))})`:o.format(i):e&&i===-1/0?"(Infinity)":String(i)}}function fn(r,{floatPrecision:e="Float64",allowNonFiniteNumbers:t=!0,floatScientific:n=!1}={}){let o=X(r,{allowNonFiniteNumbers:t});if(o===null&&n&&typeof r=="string"){let s=parseFloat(r);te(s,{allowNonFiniteNumbers:t})&&(o=s)}return o===null||(e==="Float32"&&(o=Math.fround(o)),!t&&!Number.isFinite(o))?null:o}function cr(r,e){if(!te(r)||!Number.isInteger(r))return!1;if(!e)return!0;let t=typeof e=="string"?ur[e]:e;return r>=t.min&&r<=t.max}function le(r,{range:e="Int32",coerce:t="truncate"}={}){let n=X(r);if(n===null)return null;let o=n;switch(t){case"round":o=Math.round(o);break;case"floor":o=Math.floor(o);break;case"ceil":o=Math.ceil(o);break;case"truncate":o=Math.trunc(o);break}let s=typeof e=="string"?ur[e]:e;return se(o,{min:s.min,max:s.max})}function Ne(r,{range:e="Int64",truncate:t=!1}={}){if(r==null||typeof r=="symbol")return null;let n=null;if(typeof r=="bigint")n=r;else if(typeof r=="boolean")n=r?1n:0n;else if(typeof r=="string"){let s=r.trim().replace(ar,"");if(s==="")return null;if(Kr.test(s)){if(!t&&s.includes("."))return null;let i=s.indexOf(".");n=BigInt(i!==-1?s.slice(0,i):s)}else{let i=X(s);if(i===null||!t&&!Number.isInteger(i))return null;n=BigInt(Math.trunc(i))}}else{let s=X(r);if(s===null||!t&&!Number.isInteger(s))return null;n=BigInt(Math.trunc(s))}let o=typeof e=="string"?qr[e]:e;return se(n,{min:o.min,max:o.max})}function Pr(r,e){let t=r-e,n=Math.pow(10,t)-Math.pow(10,-e);return n>0?n:null}function Wr(r,e){let t=r.toString();if(t.includes("e")){let n=Math.pow(10,e);return Math.round(r*n)/n}return+(Math.round(+(t+"e"+e))+"e-"+e)}function dt(r,{precision:e,scale:t}={}){let n=X(r);if(n===null)return null;let o=n;if(t!==void 0&&(o=Wr(o,t)),e!==void 0){let i=Pr(e,t??0);i!==null&&(o=se(o,{min:-i,max:i}))}return o}function se(r,{min:e=null,max:t=null,safe:n=!0}={}){if(e!==null&&t!==null&&e>t)return e;let o=r;return n&&typeof o=="number"&&(Number.isNaN(o)?o=e!==null?e:t!==null?t:r:o===1/0?o=t!==null?t:r:o===-1/0&&(o=e!==null?e:r)),e!==null&&o<e?e:t!==null&&o>t?t:o}function fr(r){let e=r|0;return function(){let t=e=e+1831565813|0;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function mr(r){let e=r.length,t=0,n=new Float64Array(e);for(let s=0;s<e;s++){let i=r[s];typeof i=="number"&&!Number.isNaN(i)&&(n[t++]=i)}if(t===0)return null;let o=n.subarray(0,t);return o.sort(),o}function ve(r){let e=mr(r);if(!e)return null;let t=e.length,n=Math.floor(t/2);return t%2!==0?e[n]:(e[n-1]+e[n])/2}function gt(r,e){if(e<0||e>1)return null;let t=mr(r);if(!t)return null;let n=t.length,o=e*(n-1),s=Math.floor(o),i=Math.ceil(o);return s===i?t[s]:t[s]+(o-s)*(t[i]-t[s])}function bt(r){if(!T(r)||r.length===0)return null;let e=new Map,t=r.length,n=0,o=[];for(let s=0;s<t;s++){let i=r[s];if(i==null)continue;let a=(e.get(i)??0)+1;e.set(i,a),a>n?(n=a,o=[i]):a===n&&o.push(i)}return o.length===0?null:yt(o)}var ar,Kr,ur,qr,Fe=O(()=>{"use strict";Oe();cn();ar=/[,\s_]/g,Kr=/^[+-]?\d+(?:\.\d+)?$/;ur={Int8:{min:-128,max:127},Int16:{min:-32768,max:32767},Int32:{min:-2147483648,max:2147483647},UInt8:{min:0,max:255},UInt16:{min:0,max:65535},UInt32:{min:0,max:4294967295}};qr={Int64:{min:-9223372036854775808n,max:9223372036854775807n},UInt64:{min:0n,max:18446744073709551615n}}});function dr(r,e="ms"){let t=r.getTime();switch(e){case"s":return Math.floor(t/mn);case"ms":return t;case"us":return t*_t;case"ns":return t*St}}function gr(r){let e=r.getUTCFullYear();return Math.floor((e-1)/100)+1}function br(r){let e=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate())),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let n=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-n.getTime())/He+1)/7)}function xr(r){let e=r.getUTCFullYear();return Math.floor((e-1)/1e3)+1}function pn(r,e,t=1){return new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()+e,t,0,0,0,0))}function wr(r){let e=new Date(Date.UTC(r.getUTCFullYear(),0,1)),t=r.getTime()-e.getTime();return Math.floor(t/He)+1}function _r(r){return Math.floor(r.getUTCMonth()/3)+1}function Sr(r){let e=r instanceof Date?r.getUTCFullYear():r;return e%4===0&&e%100!==0||e%400===0}function P(r){return r instanceof Date&&!Number.isNaN(r.getTime())}function pr(r){let e=Math.abs(r);return e>=1e12?r:e<=1e10?r*1e3:r}function Ue(r,e,t){let n=e;n=n.replace(/%%/g,"\0"),n=n.replace(/%F/g,"%Y-%m-%d"),n=n.replace(/%T/g,"%H:%M:%S"),n=n.replace(/%R/g,"%H:%M"),n=n.replace(/%D/g,"%m/%d/%y");let o={get"%Y"(){return String(r.getUTCFullYear())},get"%y"(){return String(r.getUTCFullYear()%100).padStart(2,"0")},get"%m"(){return String(r.getUTCMonth()+1).padStart(2,"0")},get"%d"(){return String(r.getUTCDate()).padStart(2,"0")},get"%e"(){return String(r.getUTCDate()).padStart(2," ")},get"%H"(){return String(r.getUTCHours()).padStart(2,"0")},get"%I"(){return String(r.getUTCHours()%12||12).padStart(2,"0")},get"%p"(){return r.getUTCHours()>=12?"PM":"AM"},get"%M"(){return String(r.getUTCMinutes()).padStart(2,"0")},get"%S"(){return String(r.getUTCSeconds()).padStart(2,"0")},get"%A"(){return r.toLocaleDateString(t,{weekday:"long",timeZone:"UTC"})},get"%a"(){return r.toLocaleDateString(t,{weekday:"short",timeZone:"UTC"})},get"%B"(){return r.toLocaleDateString(t,{month:"long",timeZone:"UTC"})},get"%b"(){return r.toLocaleDateString(t,{month:"short",timeZone:"UTC"})},get"%h"(){return r.toLocaleDateString(t,{month:"short",timeZone:"UTC"})},get"%j"(){let s=new Date(Date.UTC(r.getUTCFullYear(),0,1)),i=r.getTime()-s.getTime(),a=Math.floor(i/He)+1;return String(a).padStart(3,"0")},get"%u"(){return String(r.getUTCDay()||7)},get"%w"(){return String(r.getUTCDay())},get"%Z"(){return"UTC"},get"%z"(){return"+0000"},get"%ms"(){return String(r.getUTCMilliseconds()).padStart(3,"0")},get"%f"(){return String(r.getUTCMilliseconds()*1e3).padStart(6,"0")}};for(let s of Hr)n.includes(s)&&(n=n.replaceAll(s,o[s]));return n.replace(/\0/g,"%")}function Dr(r,e,t=!0){if(typeof r!="string"||typeof e!="string")return null;let n=[],o=1,s="",i=0;for(;i<e.length;){let g=e[i];if(g==="%")if(i+1<e.length){let b=e[i+1];if(b==="%")s+="%",i+=2;else if(e.slice(i,i+3)==="%ms")n.push({name:"ms",index:o++}),s+="(\\d{1,3})",i+=3;else{switch(b){case"Y":n.push({name:"year",index:o++}),s+="(\\d{4})";break;case"y":n.push({name:"year_short",index:o++}),s+="(\\d{2})";break;case"m":n.push({name:"month",index:o++}),s+="(\\d{1,2})";break;case"d":case"e":n.push({name:"day",index:o++}),s+="(\\d{1,2})";break;case"H":case"I":n.push({name:"hour",index:o++}),s+="(\\d{1,2})";break;case"M":n.push({name:"minute",index:o++}),s+="(\\d{1,2})";break;case"S":n.push({name:"second",index:o++}),s+="(\\d{1,2})";break;case"f":n.push({name:"fractional",index:o++}),s+="(\\d{1,6})";break;default:s+=g+b}i+=2}}else s+=g,i++;else"\\^$*+?.()|[]{}".indexOf(g)!==-1?s+="\\"+g:s+=g,i++}let a=new RegExp("^"+s+"$"),u=r.match(a);if(!u){if(t)return null;let g=new Date(r);return P(g)?g:null}let c=1970,l=1,f=1,m=0,p=0,h=0,y=0;for(let g of n){let b=u[g.index],S=parseInt(b,10);switch(g.name){case"year":c=S;break;case"year_short":c=S+(S>=69?1900:2e3);break;case"month":l=S;break;case"day":f=S;break;case"hour":m=S;break;case"minute":p=S;break;case"second":h=S;break;case"ms":y=parseInt(b.padEnd(3,"0").slice(0,3),10);break;case"fractional":y=parseInt(b.padEnd(6,"0").slice(0,3),10);break}}let d=new Date(Date.UTC(c,l-1,f,m,p,h,y));return P(d)?d:null}function Q(r){if(r instanceof Date)return P(r)?r:null;if(typeof r=="number"){let e=new Date(pr(r));return P(e)?e:null}if(typeof r=="bigint"){let e=new Date(pr(Number(r)));return P(e)?e:null}if(typeof r=="string"){if(nr(r))return null;let e=new Date(r);return P(e)?e:null}return null}var xt,wt,mn,hr,yr,He,_t,St,Hr,we=O(()=>{"use strict";Fe();ht();xt=/^\d{2}:\d{2}/,wt=/(?:Z|[+-]\d{2}(?::?\d{2})?)$/i,mn=1e3,hr=6e4,yr=36e5,He=864e5,_t=1e3,St=1e6;Hr=["%ms","%f","%Y","%y","%m","%d","%e","%H","%I","%p","%M","%S","%A","%a","%B","%b","%h","%j","%u","%w","%Z","%z"]});function L(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function T(r){return Array.isArray(r)||L(r)}function G(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function _e(r){if(!G(r))return!1;let e=Object.getPrototypeOf(r);return e===null||e===Object.prototype}function ir(r){return typeof r!="function"?!1:/^class\s/.test(Function.prototype.toString.call(r))||r.prototype!==void 0&&r.prototype.constructor===r&&Object.getOwnPropertyDescriptor(r,"prototype")?.writable===!1}function Jr(r){if(r==null)return!1;if(r instanceof Uint8Array||typeof r=="string")return!0;if(Array.isArray(r)){let e=r.length;for(let t=0;t<e;t++)if(!cr(r[t],{min:-128,max:255}))return!1;return!0}return!!L(r)}function Cr(r){return Jr(r)?r instanceof Uint8Array?r:typeof r=="string"?new TextEncoder().encode(r):ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r):null}var Oe=O(()=>{"use strict";we();Fe()});function Tr(r,{format:e="json",allowPrimitives:t=!1,trimBeforeParse:n=!1,reviver:o,ndjson:{skipInvalidLines:s=!1,maxLines:i,skipLines:a}={},guard:u,onError:c,fallback:l=Je}={}){if(typeof r!="string")return l!==Je?l:r;let f=n?r.trim():r;if(f==="")return l!==Je?l:r;let m;try{if(e==="ndjson"){let p=[],h=0,y=0,d=0;hn.lastIndex=0;let g;for(;;){g=hn.exec(f);let b=g?f.substring(d,g.index):f.substring(d);g&&(d=hn.lastIndex);let S=b.trim();if(S!==""&&(h++,a===void 0||h>a))if(!t&&!Gr(S)){if(!s)throw new Error("NDJSON line is not wrapped and primitives are disallowed")}else try{if(p.push(JSON.parse(S,o)),y++,i!==void 0&&y>=i)break}catch(_){if(!s)throw _}if(!g)break}if(p.length===0)throw new Error("No valid NDJSON lines processed");m=p}else{if(!t&&!zr(f))throw new Error("JSON string is not wrapped and primitives are disallowed");m=JSON.parse(f,o)}}catch(p){return c?.(p),l!==Je?l:r}return u&&!u(m)?(c?.(new Error("Parsed value failed guard validation")),l!==Je?l:r):m}function Ge(r={}){let e=r.bigintStrategy??"string",t=r.handleCircular?new WeakSet:null,o=Array.isArray(r.replacer)?r.replacer.map(String):null,s=i=>e==="number"&&i<=BigInt(Number.MAX_SAFE_INTEGER)&&i>=BigInt(Number.MIN_SAFE_INTEGER)?Number(i):i.toString();return function(a,u){let c=u;if(typeof r.replacer=="function")c=r.replacer.call(this,a,u);else if(o&&a!==""&&!Array.isArray(this)&&!o.includes(a))return;if(c===void 0)return;let l=c===u&&this!=null?this[a]:c;if(typeof r.onCustom=="function"){let f=r.onCustom.call(this,a,l);if(f!==l||f===void 0&&l!==void 0)return f}if(l!==null&&typeof l!="object"&&typeof l!="bigint")return c;if(t&&l!==null&&typeof l=="object"){if(a===""&&(t=new WeakSet),t.has(l))return r.onCircular?r.onCircular.call(this,a,l):"[Circular]";t.add(l)}return typeof l=="bigint"?r.voidBigIntReplacement?c:r.onBigInt?r.onBigInt(l):s(l):L(l)?r.voidTypedArrayReplacement?c:r.onTypedArray?r.onTypedArray(l):Array.from(l):l instanceof Set?r.voidSetReplacement?c:r.onSet?r.onSet(l):Array.from(l):l instanceof Map?r.voidMapReplacement?c:r.onMap?r.onMap(l):Array.from(l.entries()):l instanceof RegExp?r.voidRegExpReplacement?c:r.onRegExp?r.onRegExp(l):l.toString():P(l)?r.voidDateReplacement?c:r.onDate?r.onDate(l):r.formatDate?r.formatDate(l):l.toISOString():l instanceof Error?r.onError?r.onError(l):{name:l.name,message:l.message,stack:l.stack}:l instanceof URLSearchParams?r.onURLSearchParams?r.onURLSearchParams(l):l.toString():c}}var hn,Je,Gr,zr,Dt=O(()=>{"use strict";Oe();we();hn=/\r\n|\n|\r/g,Je=Symbol("no_fallback"),Gr=r=>{let e=r.length;if(e<2)return!1;let t=r[0],n=r[e-1];return t==="{"&&n==="}"||t==="["&&n==="]"},zr=r=>{let e=0,t=r.length;for(;e<t&&/\s/.test(r[e]);)e++;let n=t-1;for(;n>=e&&/\s/.test(r[n]);)n--;if(e>=n)return!1;let o=r[e],s=r[n];return o==="{"&&s==="}"||o==="["&&s==="]"}});var Ct=O(()=>{"use strict"});var H,Ce,ze,me,pe,Me,he,Le,Tt=O(()=>{"use strict";H=class r{matches(e){if(e==null)return!1;if(e instanceof r)return!!(this.equals(e)||this.name.startsWith("Decimal")&&e.name.startsWith("Decimal")&&e.precision===void 0&&e.scale===void 0);if(typeof e=="function"){if(e.prototype instanceof r)return this instanceof e;try{let t=e();if(t instanceof r)return this.constructor===t.constructor}catch{}}return!1}get isNumeric(){return!1}get isInteger(){return!1}get isFloat(){return!1}get isSigned(){return!1}get isUnsigned(){return!1}get isTemporal(){return!1}get isNested(){return!1}get isBoolean(){return!1}get isString(){return!1}get isUtf8(){return!1}get isObject(){return!1}get isNull(){return!1}get isBinary(){return!1}},Ce=class extends H{get isNumeric(){return!0}},ze=class extends Ce{get isInteger(){return!0}},me=class extends ze{get isSigned(){return!0}},pe=class extends ze{get isUnsigned(){return!0}},Me=class extends Ce{get isFloat(){return!0}},he=class extends H{get isTemporal(){return!0}},Le=class extends H{get isNested(){return!0}}});var At,yn,It,dn,kt,gn,Et,Ze,Ot,bn,Rt,xn,Ft,wn,Nt,_n,vt,Sn,Ut,Xe,Ye,Mt,Qe,Lt,je,jt,Dn,Vt,Cn,Bt,Tn,$t,An,Kt,et,qt,In,Pt,kn,Wt,En,Ht,On,Rn=O(()=>{"use strict";Tt();U();At=class extends me{name="Int8";coerce(e){return le(e,{range:"Int8"})}equals(e){return e.name==="Int8"}allocate(e){return new Int8Array(e)}},yn=new At,It=class extends me{name="Int16";coerce(e){return le(e,{range:"Int16"})}equals(e){return e.name==="Int16"}allocate(e){return new Int16Array(e)}},dn=new It,kt=class extends me{name="Int32";coerce(e){return le(e,{range:"Int32"})}equals(e){return e.name==="Int32"}allocate(e){return new Int32Array(e)}},gn=new kt,Et=class extends me{name="Int64";coerce(e){return Ne(e,{truncate:!0})}equals(e){return e.name==="Int64"}allocate(e){return new BigInt64Array(e)}},Ze=new Et,Ot=class extends pe{name="UInt8";coerce(e){return le(e,{range:"UInt8"})}equals(e){return e.name==="UInt8"}allocate(e){return new Uint8Array(e)}},bn=new Ot,Rt=class extends pe{name="UInt16";coerce(e){return le(e,{range:"UInt16"})}equals(e){return e.name==="UInt16"}allocate(e){return new Uint16Array(e)}},xn=new Rt,Ft=class extends pe{name="UInt32";coerce(e){return le(e,{range:"UInt32"})}equals(e){return e.name==="UInt32"}allocate(e){return new Uint32Array(e)}},wn=new Ft,Nt=class extends pe{name="UInt64";coerce(e){return Ne(e,{range:"UInt64"})}equals(e){return e.name==="UInt64"}allocate(e){return new BigUint64Array(e)}},_n=new Nt,vt=class extends Me{name="Float32";coerce(e){return fn(e,{floatPrecision:"Float32"})}equals(e){return e.name==="Float32"}allocate(e){return new Float32Array(e)}},Sn=new vt,Ut=class extends Me{name="Float64";coerce(e){return fn(e,{floatPrecision:"Float64"})}equals(e){return e.name==="Float64"}allocate(e){return new Float64Array(e)}},Xe=new Ut,Ye=class r extends Ce{constructor(t,n){super();this.precision=t;this.scale=n;this.name=t!==void 0&&n!==void 0?`Decimal(${t}, ${n})`:"Decimal"}precision;scale;name;coerce(t){return dt(t,{precision:this.precision,scale:this.scale})}equals(t){return t instanceof r&&this.precision===t.precision&&this.scale===t.scale}allocate(t){return new Array(t).fill(null)}},Mt=class extends H{name="Boolean";get isBoolean(){return!0}coerce(e){return e==null?null:!!e}equals(e){return e.name==="Boolean"}allocate(e){return new Array(e).fill(null)}},Qe=new Mt,Lt=class extends H{name="Utf8";get isString(){return!0}get isUtf8(){return!0}coerce(e){return e==null?null:String(e)}equals(e){return e.name==="Utf8"}allocate(e){return new Array(e).fill(null)}},je=new Lt,jt=class extends H{name="Binary";get isBinary(){return!0}coerce(e){return Cr(e)}equals(e){return e.name==="Binary"}allocate(e){return new Array(e).fill(null)}},Dn=new jt,Vt=class extends H{name="Null";get isNull(){return!0}coerce(e){return null}equals(e){return e.name==="Null"}allocate(e){return new Array(e).fill(null)}},Cn=new Vt,Bt=class extends H{name="Object";get isObject(){return!0}coerce(e){return e===void 0?null:e}equals(e){return e.name==="Object"}allocate(e){return new Array(e).fill(null)}},Tn=new Bt,$t=class extends he{name="Date";coerce(e){let t=Q(e);return t?(t.setUTCHours(0,0,0,0),t):null}equals(e){return e.name==="Date"}allocate(e){return new Array(e).fill(null)}},An=new $t,Kt=class extends he{name="Datetime";coerce(e){return Q(e)}equals(e){return e.name==="Datetime"}allocate(e){return new Array(e).fill(null)}},et=new Kt,qt=class extends he{name="Time";coerce(e){if(e==null)return null;if(typeof e=="string"){let n=e.trim();if(xt.test(n)){let o=new globalThis.Date(`1970-01-01T${n}${wt.test(n)?"":"Z"}`);if(P(o))return o.toISOString().split("T")[1].slice(0,12)}}let t=Q(e);return t?t.toISOString().split("T")[1].slice(0,12):null}equals(e){return e.name==="Time"}allocate(e){return new Array(e).fill(null)}},In=new qt,Pt=class extends he{name="Duration";coerce(e){return X(e)}equals(e){return e.name==="Duration"}allocate(e){return new Array(e).fill(null)}},kn=new Pt,Wt=class r extends Le{constructor(t){super();this.innerType=t}innerType;name="List";coerce(t){if(t==null)return null;let n=T(t)?Array.from(t):[t],o=n.length,s=new Array(o);for(let i=0;i<o;i++)s[i]=this.innerType.coerce(n[i]);return s}equals(t){return t instanceof r&&this.innerType.equals(t.innerType)}allocate(t){return new Array(t).fill(null)}},En=r=>new Wt(r),Ht=class r extends Le{constructor(t){super();this.fields=t}fields;name="Struct";coerce(t){if(!G(t))return null;let n={},o=globalThis.Object.keys(this.fields),s=o.length;for(let i=0;i<s;i++){let a=o[i],u=this.fields[a];n[a]=u.coerce(t[a])}return n}equals(t){if(!(t instanceof r))return!1;let n=globalThis.Object.keys(this.fields),o=globalThis.Object.keys(t.fields);if(n.length!==o.length)return!1;for(let s of n)if(!t.fields[s]||!this.fields[s].equals(t.fields[s]))return!1;return!0}allocate(t){return new Array(t).fill(null)}},On=r=>new Ht(r)});var R,ye=O(()=>{"use strict";Tt();Rn();Rn();Tt();R={Int8:yn,Int16:dn,Int32:gn,Int64:Ze,UInt8:bn,UInt16:xn,UInt32:wn,UInt64:_n,Float32:Sn,Float64:Xe,Decimal:(r,e)=>new Ye(r,e),Boolean:Qe,Utf8:je,Binary:Dn,Date:An,Datetime:et,Time:In,Duration:kn,Object:Tn,Null:Cn,List:En,Struct:On}});function Yr(r={}){let e=r.nullValue!==void 0?r.nullValue:"",t=lr(r.numericFormatOptions),n=r.replacerOptions||{},o=a=>r.datetimeFormat?Ue(a,r.datetimeFormat):r.dateFormat?Ue(a,r.dateFormat):r.timeFormat?Ue(a,r.timeFormat):a.toISOString(),s=Ge({formatDate:o,...n}),i=typeof n.onBigInt=="function";return a=>{if(a==null||typeof a=="symbol"||typeof a=="function")return{str:e,isNumeric:!1};if(typeof a=="bigint"&&!i&&!n.voidBigIntReplacement)return{str:t(a),isNumeric:!0};let u=s.call(null,"",a);return u==null||typeof u=="symbol"||typeof u=="function"?{str:e,isNumeric:!1}:typeof u=="string"?{str:u,isNumeric:!1}:typeof u=="number"||typeof u=="bigint"?{str:t(u),isNumeric:!0}:typeof u=="boolean"?{str:u?"true":"false",isNumeric:!1}:u instanceof Number?{str:t(u.valueOf()),isNumeric:!0}:u instanceof String?{str:u.valueOf(),isNumeric:!1}:u instanceof Boolean?{str:u.valueOf()?"true":"false",isNumeric:!1}:typeof u=="object"?{str:JSON.stringify(u,Ge({formatDate:o,...n})),isNumeric:!1}:{str:String(u),isNumeric:!1}}}function Gt(r,e,t={}){let{separator:n=",",quoteChar:o='"',includeHeader:s=!0,lineTerminator:i=`
|
|
2
|
+
`,quoteStyle:a="necessary",includeBom:u=!1,onRow:c,...l}=t,f=Object.keys(r),m=f.length,p=[],h=!0,y=Yr(l),d=(b,S=!1)=>{let _,w=!1;if(S)_=String(b);else{let k=y(b);_=k.str,w=k.isNumeric}if(a==="never")return _;if(a==="always"){let k=_.split(o).join(o+o);return o+k+o}if(a==="non_numeric"&&!w&&b!=null){let k=_.split(o).join(o+o);return o+k+o}if(_.includes(n)||_.includes(o)||_.includes(`
|
|
3
|
+
`)||_.includes("\r")){let k=_.split(o).join(o+o);return o+k+o}return _},g=b=>{if(h){let S=u?"\uFEFF"+b:b;c?c(S):p.push(S),h=!1}else c?c(i+b):p.push(b)};if(s){let b=new Array(m);for(let S=0;S<m;S++)b[S]=d(f[S],!0);g(b.join(n))}for(let b=0;b<e;b++){let S=new Array(m);for(let _=0;_<m;_++)S[_]=d(r[f[_]][b],!1);g(S.join(n))}return c?u?"\uFEFF":"":p.join(i)}function Ir(r,e={}){let t=e.separator||",",n=e.quoteChar||'"',o=r;o.startsWith("\uFEFF")&&(o=o.substring("\uFEFF".length));let s=[],i=[],a="",u=!1,c=!1,l=!1,f=o.length;for(let m=0;m<f;m++){let p=o[m];if(u)c=!0,l=!1,p===n?m+1<f&&o[m+1]===n?(a+=n,m++):u=!1:a+=p;else if(p===n)c=!0,l=!1,u=!0;else if(p===t)i.push(a),a="",l=!0;else{let h=!1;p==="\r"?(h=!0,m+1<f&&o[m+1]===`
|
|
4
|
+
`&&m++):p===`
|
|
5
|
+
`&&(h=!0),h?(c||i.length>0||a!==""||l)&&(i.push(a),s.push(i),i=[],a="",c=!1,l=!1):(c=!0,l=!1,a+=p)}}return(c||i.length>0||a!==""||l)&&(i.push(a),s.push(i)),s}function kr(r,e={}){let t=new Set(e.nullValues??["","NA","null","NaN"]),n=r.length,o=!0,s=!0,i=!0,a=!0,u=!1;for(let l=0;l<n;l++){let f=r[l].trim();if(!t.has(f)){if(u=!0,o){let m=f.toLowerCase();m!=="true"&&m!=="false"&&m!=="1"&&m!=="0"&&(o=!1)}if(i&&Ne(f,{truncate:!1})===null&&(i=!1),s&&X(f,{allowNonFiniteNumbers:!0})===null&&(s=!1),a&&Q(f)===null&&(a=!1),!o&&!s&&!i&&!a)break}}let c=new Array(n);if(!u||!o&&!s&&!i&&!a){for(let l=0;l<n;l++){let f=r[l];c[l]=t.has(f.trim())?null:f}return{type:je,values:c}}if(o){for(let l=0;l<n;l++){let f=r[l].trim();if(t.has(f))c[l]=null;else{let m=f.toLowerCase();c[l]=m==="true"||m==="1"}}return{type:Qe,values:c}}if(i){for(let l=0;l<n;l++){let f=r[l].trim();c[l]=t.has(f)?null:Ne(f,{truncate:!1})}return{type:Ze,values:c}}if(s){for(let l=0;l<n;l++){let f=r[l].trim();c[l]=t.has(f)?null:X(f,{allowNonFiniteNumbers:!0})}return{type:Xe,values:c}}if(a){for(let l=0;l<n;l++){let f=r[l].trim();c[l]=t.has(f)?null:Q(f)}return{type:et,values:c}}return{type:je,values:c}}var Er=O(()=>{"use strict";we();Dt();Fe();Ct();ye()});var U=O(()=>{"use strict";Oe();Fe();we();cn();ht();Dt();Er()});function J(r,e,t,n=""){if(!(r in e))throw new Te(r,`${t} "${r}" does not exist${n}`)}function zt(r,e){let t=Object.keys(r),n=t.length,o=e;for(let s=0;s<n;s++){let i=t[s],a=r[i],u=T(a)?a.length:0;if(o===void 0)o=u;else if(u!==o)throw new z(`Column height mismatch: Column "${i}" has length ${u}, but DataFrame height is ${o}`)}return o===void 0?0:o}var Or=O(()=>{"use strict";re();U()});var Ae,j,Te,Be,de,z,re=O(()=>{"use strict";Or();Ae=class extends Error{constructor(e){super(e),this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},j=class extends Ae{},Te=class extends j{constructor(e,t){super(t||`Column "${e}" does not exist in the DataFrame.`)}},Be=class extends Ae{},de=class extends Ae{},z=class extends Ae{}});var x,F,ee=O(()=>{"use strict";oe();re();x=(r,e)=>{let t=r.constructor,n=r.colNames||r.colName||"",o=new t(n);return Object.assign(o,r),o.ops=e?[...r.ops,e]:[...r.ops],o},F=class r{ops=[];outputName="";isLiteral;literalValue;aggFn=null;groupingOpsIndex;partitionOpsIndex;partitionBy=null;evaluateWindow;_resolve(e,t,n){return e instanceof r?e.isLiteral&&e.ops.length===1?e.literalValue:e.evaluate(t,n):e}alias(e){let t=x(this);return t.outputName=e,t}cast(e){return x(this,t=>{let n=t.length,o=new Array(n);for(let s=0;s<n;s++)o[s]=e.coerce(t[s]);return o})}debug(e){return x(this,t=>(console.log(`[DEBUG] ${e?e+": ":""}`,t),t))}_getInitialValue(e,t){let n=this.colName;if(n&&n!=="*"&&!n.startsWith("*")&&!(n in e))throw new Te(n);return n&&n!=="*"?e[n]||new Array(t).fill(null):new Array(t).fill(null)}evaluate(e,t){let n=this._getInitialValue(e,t),o=this.ops,s=o.length;for(let i=0;i<s;i++)n=o[i](n,e);return n}evaluatePre(e,t,n){let o=this._getInitialValue(t,n),s=this.ops,i=e!==void 0?e:s.length;for(let a=0;a<i;a++)o=s[a](o,t);return o}evaluatePost(e,t,n){let o=this.ops,s=e!==void 0?e:o.length,i=t;for(let a=s;a<o.length;a++)i=o[a](i,n);return i}}});function Zr(r,e,t){let n=new Map,o=t.length,s=new Array(o);for(let i=0;i<o;i++){let a=t[i];typeof a=="string"?(J(a,r,"Partition key"," in the DataFrame."),s[i]=r[a]):s[i]=a.evaluate(r,e)}if(o===1){let i=s[0];for(let a=0;a<e;a++){let u=i[a],c=u==null?"":$(u),l=n.get(c);l===void 0&&(l=[],n.set(c,l)),l.push(a)}return n}for(let i=0;i<e;i++){let a=new Array(o);for(let l=0;l<o;l++){let f=s[l][i];a[l]=f==null?"":$(f)}let u=a.join("\0"),c=n.get(u);c===void 0&&(c=[],n.set(u,c)),c.push(i)}return n}function Fn(r,e,t){let n=new Array(t);if(t===0)return n;let o=r.partitionBy||[],s=Zr(e,t,o),i=r.evaluatePre(r.partitionOpsIndex,e,t);for(let a of s.values()){let u=a.length,c=new Array(u);for(let l=0;l<u;l++)c[l]=i[a[l]];if(r.evaluateWindow){for(let l=0;l<u;l++)n[a[l]]=r.evaluateWindow(c,a,l);continue}if(r.aggFn){let l=r.aggFn(c);for(let f=0;f<u;f++)n[a[f]]=l;continue}for(let l=0;l<u;l++)n[a[l]]=i[a[l]]}return r.evaluatePost(r.partitionOpsIndex,n,e)}function Nn(r){if(!Array.isArray(r)||r.length===0)return{columns:{},height:0};let e=r.length,t=new Set;for(let s=0;s<e;s++){let i=r[s];if(G(i)){let a=Object.keys(i);for(let u=0;u<a.length;u++)t.add(a[u])}}let n=Array.from(t),o={};for(let s=0;s<n.length;s++)o[n[s]]=new Array(e);for(let s=0;s<e;s++){let i=r[s]||{};for(let a=0;a<n.length;a++){let u=n[a],c=i[u];o[u][s]=c===void 0?null:c}}return{columns:o,height:e}}function vn(r,e){let t=Object.keys(r),n=new Array(e);for(let o=0;o<e;o++){let s={};for(let i=0;i<t.length;i++){let a=t[i],u=r[a][o];s[a]=u===void 0?null:u}n[o]=s}return n}function Xr(r,e,t){let n={};for(let o=0;o<t.length;o++){let s=t[o],i=r[s][e];n[s]=i===void 0?null:i}return n}function ue(r){if(r.length===0)return R.Utf8;let e=!0,t=!0,n=!0,o=!0,s=!0,i=!0,a=!0,u=!0,c=!1,l=!1,f=[];for(let m=0;m<r.length;m++){let p=r[m];if(p!=null){if(l=!0,p instanceof Uint8Array||(a=!1),!T(p)||p instanceof Uint8Array)i=!1;else{let h=p,y=h.length;for(let d=0;d<y;d++)f.push(h[d])}p instanceof Date&&(c=!0),typeof p!="boolean"&&(e=!1),typeof p!="bigint"&&(o=!1),typeof p!="number"?(n=!1,t=!1):Number.isInteger(p)||(t=!1),!(p instanceof Date)&&(typeof p!="string"||isNaN(Date.parse(p)))&&(s=!1),(!G(p)||p instanceof Date||p instanceof Uint8Array||Array.isArray(p))&&(u=!1)}}if(!l)return R.Utf8;if(a)return R.Binary;if(i){let m=ue(f);return R.List(m)}if(e)return R.Boolean;if(o)return R.Int64;if(n&&!t)return R.Float64;if(n&&t){let m=!0;for(let p=0;p<r.length;p++){let h=r[p];if(h!=null&&(h<-2147483648||h>2147483647)){m=!1;break}}return m?R.Int32:R.Float64}return s&&c?R.Datetime:u?R.Object:R.Utf8}function $e(r,e){let t=Object.keys(r),n=t.length,o=e.length,s={};for(let i=0;i<n;i++){let a=t[i],u=r[a],c=L(u)?new u.constructor(o):new Array(o);for(let l=0;l<o;l++)c[l]=u[e[l]];s[a]=c}return s}function Ie(r,e,t){let n=e.length;if(n===1){let s=r[e[0]][t];return s==null?"":$(s)}let o=new Array(n);for(let s=0;s<n;s++){let i=r[e[s]][t];o[s]=i==null?"":$(i)}return o.join("\0")}function ge(r,e,t){let n=e.allocate?e.allocate(t):new Array(t);if(L(n)){let s=n;for(let i=0;i<t;i++){let a=e.coerce(r[i]);if(a==null){let u=new Array(t);for(let c=0;c<i;c++)u[c]=s[c];u[i]=null;for(let c=i+1;c<t;c++)u[c]=e.coerce(r[c]);return u}s[i]=a}}else for(let s=0;s<t;s++)n[s]=e.coerce(r[s]);return n}function Un(r,e){if(r)if(typeof r=="string")require("fs").writeFileSync(r,e,"utf8");else if(typeof r=="object"&&typeof r.write=="function")r.write(e);else throw new TypeError("Invalid file argument. Expected a file path string or a writable stream/object with a write method.")}var tt=O(()=>{"use strict";ye();Ct();U();re()});function nt(r,e,t){return r.isWindow?Fn(r,e,t):r.evaluate(e,t)}var C,V,be=O(()=>{"use strict";U();tt();C=r=>e=>{let t=e.length,n=new Array(t);for(let o=0;o<t;o++){let s=e[o];n[o]=s==null?null:r(s)}return n},V=(r,e,t)=>(n,o)=>{let s=n.length,i=r._resolve(e,o,s),a=new Array(s);if(T(i))for(let u=0;u<s;u++){let c=n[u],l=i[u];a[u]=c==null||l==null?null:t(c,l)}else for(let u=0;u<s;u++){let c=n[u];a[u]=c==null||i==null?null:t(c,i)}return a}});var rt,Mn=O(()=>{"use strict";ee();be();U();rt=class extends F{abs(){return x(this,C(e=>Math.abs(e)))}acos(){return x(this,C(e=>e<-1||e>1?null:Math.acos(e)))}acosh(){return x(this,C(e=>e<1?null:Math.acosh(e)))}add(e){return x(this,V(this,e,(t,n)=>t+n))}asin(){return x(this,C(e=>e<-1||e>1?null:Math.asin(e)))}asinh(){return x(this,C(Math.asinh))}atan(){return x(this,C(Math.atan))}atanh(){return x(this,C(e=>e<=-1||e>=1?null:Math.atanh(e)))}cbrt(){return x(this,C(Math.cbrt))}ceil(){return x(this,C(Math.ceil))}clip(e=null,t=null){return x(this,C(n=>se(n,{min:e,max:t})))}cos(){return x(this,C(Math.cos))}cosh(){return x(this,C(Math.cosh))}degrees(){return x(this,C(e=>e*(180/Math.PI)))}div(e){return x(this,V(this,e,(t,n)=>n===0?null:t/n))}exp(){return x(this,C(Math.exp))}expm1(){return x(this,C(Math.expm1))}floor(){return x(this,C(Math.floor))}floordiv(e){return x(this,V(this,e,(t,n)=>n===0?null:Math.floor(t/n)))}hypot(e){return x(this,V(this,e,(t,n)=>Math.hypot(t,n)))}log(e=Math.E){return x(this,C(t=>t<=0?null:e===Math.E?Math.log(t):Math.log(t)/Math.log(e)))}log1p(){return x(this,C(e=>e<=-1?null:Math.log1p(e)))}mod(e){return x(this,V(this,e,(t,n)=>n===0?null:t%n))}mul(e){return x(this,V(this,e,(t,n)=>t*n))}negate(){return x(this,C(e=>-e))}pow(e){return x(this,V(this,e,(t,n)=>Math.pow(t,n)))}radians(){return x(this,C(e=>e*(Math.PI/180)))}rand(e,{min:t=0,max:n=1,integer:o=!1}={}){return x(this,s=>{let i=s.length,a=new Float64Array(i),u=e!==void 0?fr(e):Math.random,c=n-t;for(let l=0;l<i;l++){let f=u();a[l]=o?Math.floor(f*(c+1))+t:f*c+t}return a})}round(e=0){let t=Math.pow(10,e);return x(this,C(n=>Math.round(n*t)/t))}sign(){return x(this,C(Math.sign))}sin(){return x(this,C(Math.sin))}sinh(){return x(this,C(Math.sinh))}sqrt(){return x(this,C(e=>e<0?null:Math.sqrt(e)))}sub(e){return x(this,V(this,e,(t,n)=>t-n))}tan(){return x(this,C(Math.tan))}tanh(){return x(this,C(Math.tanh))}trunc(){return x(this,C(Math.trunc))}}});var ot,Ln=O(()=>{"use strict";ee();be();U();ot=class extends F{and(e){return x(this,(t,n)=>{let o=t.length,s=this._resolve(e,n,o),i=T(s),a=new Array(o);for(let u=0;u<o;u++){let c=t[u],l=i?s[u]:s;c===!1||l===!1?a[u]=!1:c==null||l==null?a[u]=null:a[u]=!0}return a})}not(){return x(this,C(e=>!e))}or(e){return x(this,(t,n)=>{let o=t.length,s=this._resolve(e,n,o),i=T(s),a=new Array(o);for(let u=0;u<o;u++){let c=t[u],l=i?s[u]:s;c===!0||l===!0?a[u]=!0:c==null||l==null?a[u]=null:a[u]=!1}return a})}xor(e){return x(this,V(this,e,(t,n)=>!!t!=!!n))}}});function Fr(r,e,t,n){let o=r.length,s=new Array(o);if(t&&typeof t=="object"&&"evaluate"in t){let i=t.evaluate(e,o);for(let a=0;a<o;a++){let u=r[a];if(u==null)s[a]=null;else{let c=i[a],l=new Set;if(T(c)){let m=c.length;for(let p=0;p<m;p++)l.add($(c[p]))}else l.add($(c));let f=l.has($(u));s[a]=n?!f:f}}}else{let i=T(t)?t:[],a=new Set,u=i.length;for(let c=0;c<u;c++)a.add($(i[c]));for(let c=0;c<o;c++){let l=r[c];if(l==null)s[c]=null;else{let f=a.has($(l));s[c]=n?!f:f}}}return s}function Nr(r,e){let{frequencies:t}=Se(r,{strict:!0}),n=r.length,o=new Array(n);for(let s=0;s<n;s++){let i=t.get(r[s])||0;o[s]=e?i>1:i===1}return o}function vr(r,e,t){let n=r.length,o=new Array(n);if(T(e))for(let s=0;s<n;s++){let i=r[s],a=e[s];i==null&&a==null?o[s]=!t:i==null||a==null?o[s]=t:o[s]=t?i!==a:i===a}else for(let s=0;s<n;s++){let i=r[s];i==null&&e==null?o[s]=!t:i==null||e==null?o[s]=t:o[s]=t?i!==e:i===e}return o}var st,jn=O(()=>{"use strict";ee();be();U();st=class extends F{between(e,t,n="both"){return x(this,(o,s)=>{let i=o.length,a=this._resolve(e,s,i),u=this._resolve(t,s,i),c=new Array(i),l=T(a),f=T(u);for(let m=0;m<i;m++){let p=o[m],h=l?a[m]:a,y=f?u[m]:u;if(p==null||h==null||y==null)c[m]=null;else{let d=n==="both"||n==="left"?p>=h:p>h,g=n==="both"||n==="right"?p<=y:p<y;c[m]=d&&g}}return c})}eq(e){return x(this,V(this,e,(t,n)=>t===n))}eq_missing(e){return x(this,(t,n)=>{let o=this._resolve(e,n,t.length);return vr(t,o,!1)})}ge(e){return x(this,V(this,e,(t,n)=>t>=n))}gt(e){return x(this,V(this,e,(t,n)=>t>n))}has_nulls(){return this._deriveAgg(e=>{for(let t=0;t<e.length;t++)if(e[t]==null)return!0;return!1})}is_close(e,{abs_tol:t=1e-8,rel_tol:n=1e-8,nans_equal:o=!1}={}){return x(this,(s,i)=>{let a=s.length,u=this._resolve(e,i,a),c=T(u),l=new Array(a);for(let f=0;f<a;f++){let m=s[f],p=c?u[f]:u;if(m==null||p==null)l[f]=null;else if(te(m)&&te(p)){let h=Math.abs(m-p),y=Math.max(n*Math.max(Math.abs(m),Math.abs(p)),t);l[f]=h<=y}else Number.isNaN(m)&&Number.isNaN(p)?l[f]=o:l[f]=m===p}return l})}is_duplicated(){return x(this,e=>Nr(e,!0))}is_empty({ignoreNulls:e=!1}={}){return x(this,C(t=>typeof t=="string"?t.length===0:T(t)?e?K(t,"nullish",{mode:"every"}):t.length===0:null))}is_finite(){return x(this,C(Number.isFinite))}is_in(e){return x(this,(t,n)=>Fr(t,n,e,!1))}is_infinite(){return x(this,C(e=>e===1/0||e===-1/0))}is_nan(){return x(this,C(Number.isNaN))}is_not_nan(){return x(this,C(e=>!Number.isNaN(e)))}is_not_null(){return x(this,e=>{let t=e.length,n=new Array(t);for(let o=0;o<t;o++)n[o]=e[o]!=null;return n})}is_null(){return x(this,e=>{let t=e.length,n=new Array(t);for(let o=0;o<t;o++)n[o]=e[o]==null;return n})}is_unique(){return x(this,e=>Nr(e,!1))}le(e){return x(this,V(this,e,(t,n)=>t<=n))}lt(e){return x(this,V(this,e,(t,n)=>t<n))}ne(e){return x(this,V(this,e,(t,n)=>t!==n))}ne_missing(e){return x(this,(t,n)=>{let o=this._resolve(e,n,t.length);return vr(t,o,!0)})}not_in(e){return x(this,(t,n)=>Fr(t,n,e,!0))}}});var Yt,it,Vn=O(()=>{"use strict";ee();be();U();Yt=class{constructor(e){this.expr=e}expr;_deriveString(e){return x(this.expr,C(t=>e(String(t))))}_patternGuard(e,t){return e==null?x(this.expr,n=>new Array(n.length).fill(null)):t()}concat(e){return x(this.expr,V(this.expr,e,(t,n)=>String(t)+String(n)))}contains(e){return this._patternGuard(e,()=>this._deriveString(t=>e instanceof RegExp?e.test(t):t.includes(e)))}count_matches(e){return this._patternGuard(e,()=>this._deriveString(t=>{if(e instanceof RegExp){let n=e.global?e:new RegExp(e.source,e.flags+"g"),o=t.match(n);return o?o.length:0}else{let n=0,o=t.indexOf(e);for(;o!==-1;)n++,o=t.indexOf(e,o+e.length);return n}}))}decode_uri_component(){return this._deriveString(e=>{try{return decodeURIComponent(e)}catch{return e}})}encode_uri_component(){return this._deriveString(e=>{try{return encodeURIComponent(e)}catch{return e}})}ends_with(e){return this._deriveString(t=>t.endsWith(e))}explode(){return this._deriveString(e=>e.split(""))}extract(e,t=0){return this._patternGuard(e,()=>this._deriveString(n=>{let o=n.match(e);return o&&o[t]!==void 0?o[t]:null}))}len(){return this.len_chars()}len_bytes(){return this._deriveString(e=>new TextEncoder().encode(e).length)}len_chars(){return this._deriveString(e=>e.length)}lower(){return this._deriveString(e=>e.toLowerCase())}lpad(e,t=" "){return this._deriveString(n=>n.padStart(e,t))}pad_end(e,t=" "){return this.rpad(e,t)}pad_start(e,t=" "){return this.lpad(e,t)}replace(e,t){return this._patternGuard(e,()=>this._deriveString(n=>n.replace(e,t)))}replace_all(e,t){return this._patternGuard(e,()=>this._deriveString(n=>{if(e instanceof RegExp){let o=e.global?e:new RegExp(e.source,e.flags+"g");return n.replace(o,t)}return n.replaceAll(e,t)}))}reverse(){return this._deriveString(e=>e.split("").reverse().join(""))}rpad(e,t=" "){return this._deriveString(n=>n.padEnd(e,t))}slice(e,t){return this._deriveString(n=>{let o=e<0?n.length+e:e,s=t!==void 0?o+t:void 0;return n.slice(o,s)})}slice_str(e,t){return this.slice(e,t)}split(e){return this._deriveString(t=>t.split(e))}starts_with(e){return this._deriveString(t=>t.startsWith(e))}strip_chars(e,t){return this._deriveString(n=>Ee(n,e,{mode:"both",...t}))}strip_chars_end(e,t){return this._deriveString(n=>Ee(n,e,{mode:"end",...t}))}strip_chars_start(e,t){return this._deriveString(n=>Ee(n,e,{mode:"start",...t}))}strip_prefix(e){return this._deriveString(t=>Ee(t,e,{mode:"start",maxScanStart:1,maxMatchesStart:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strip_suffix(e){return this._deriveString(t=>Ee(t,e,{mode:"end",maxScanEnd:1,maxMatchesEnd:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strptime(e,t=!0){return this._deriveString(n=>Dr(n,e,t))}to_date(){return this._deriveString(e=>{let t=Q(e);if(!t)return null;let n=new Date(t);return n.setUTCHours(0,0,0,0),n})}to_datetime(){return this._deriveString(Q)}to_decimal(e,t){return this._deriveString(n=>dt(n,{precision:e,scale:t}))}to_integer(){return this._deriveString(e=>le(e))}to_lowercase(){return this.lower()}to_time(){return this._deriveString(e=>{let t=Q(e);if(t)return t.toISOString().split("T")[1].slice(0,12);let n=e.trim();if(xt.test(n)){let o=new Date(`1970-01-01T${n}${wt.test(n)?"":"Z"}`);if(P(o))return o.toISOString().split("T")[1].slice(0,12)}return null})}to_titlecase(){return this._deriveString(e=>e.replace(/\b\w/g,t=>t.toUpperCase()))}to_uppercase(){return this.upper()}trim(){return this.strip_chars()}trim_end(){return this.strip_chars_end()}trim_start(){return this.strip_chars_start()}upper(){return this._deriveString(e=>e.toUpperCase())}zfill(e){return this._deriveString(t=>t.padStart(e,"0"))}},it=class extends F{get str(){return new Yt(this)}}});var at,Bn=O(()=>{"use strict";ee();re();U();at=class extends F{_deriveAgg(e){let t=x(this);return t.aggFn=e,t.groupingOpsIndex=this.ops.length,t.partitionOpsIndex=this.ops.length,t}all(){return this._deriveAgg(e=>K(e,t=>!!t,{mode:"every"}))}all_null(){return this._deriveAgg(e=>K(e,"nullish",{mode:"every"}))}any(){return this._deriveAgg(e=>K(e,t=>!!t,{mode:"some"}))}any_null(){return this._deriveAgg(e=>K(e,"nullish",{mode:"some"}))}avg(){return this._deriveAgg(e=>B(e).mean)}count(e={}){return e.includeNulls?this._deriveAgg(t=>t.length):this._deriveAgg(t=>B(t).count)}first(){return this._deriveAgg(e=>e[0]??null)}implode(){return this._deriveAgg(e=>e)}last(){return this._deriveAgg(e=>e[e.length-1]??null)}max(){return this._deriveAgg(e=>B(e).max)}mean(){return this.avg()}median(){return this._deriveAgg(e=>ve(e))}min(){return this._deriveAgg(e=>B(e).min)}mode(){return this._deriveAgg(e=>bt(e))}n_unique(e={}){return this._deriveAgg(t=>Se(t,e).count)}quantile(e){if(e<0||e>1)throw new de("Quantile q must be between 0 and 1");return this._deriveAgg(t=>gt(t,e))}std(){return this._deriveAgg(e=>B(e).std)}sum(){return this._deriveAgg(e=>B(e).sum)}}});function $n(r,e,t={}){if(e==null)return null;let n=r;if(t.ignoreNulls){n=[];let a=r.length;for(let u=0;u<a;u++)r[u]!=null&&n.push(r[u])}t.dense&&(n=Array.from(new Set(n)));let o=[...n].sort((a,u)=>a-u),s=new Map,i=o.length;for(let a=0;a<i;a++){let u=o[a];s.has(u)||s.set(u,a+1)}return s.get(e)??null}var lt,Kn=O(()=>{"use strict";ee();U();lt=class extends F{partitionBy=this.partitionBy||null;_window(e){let t=x(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=e,t}_rolling(e,t){return this._window(function(n,o,s){let i=Math.max(0,s-e+1),a=s+1,u=n.slice(i,a);return t(u)})}_cum(e,t,n,o){return this._window(function(s,i,a){let u=t,c=!1,l=e?a:0,f=e?s.length-1:a;for(let m=l;m<=f;m++){let p=s[m];p!=null&&(u=n(u,p),c=!0)}return o?o(u,c):u})}get isWindow(){return this.partitionBy!==null||this.evaluateWindow!==void 0||this.aggFn!==null}cum_count(e=!1){return this._cum(e,0,t=>t+1)}cum_max(e=!1){return this._cum(e,null,(t,n)=>t===null||n>t?n:t)}cum_min(e=!1){return this._cum(e,null,(t,n)=>t===null||n<t?n:t)}cum_prod(e=!1){return this._cum(e,1,(t,n)=>t*n,(t,n)=>n?t:null)}cum_sum(e=!1){return this._cum(e,0,(t,n)=>t+n)}dense_rank(){return this._window(function(e,t,n){return $n(e,e[n],{dense:!0})})}lag(e=1,t=null){return this._window(function(n,o,s){let i=t;return s-e>=0&&(i=n[s-e]),i})}lead(e=1,t=null){return this._window(function(n,o,s){let i=t;return s+e<n.length&&(i=n[s+e]),i})}over(e){let t=x(this),n=Array.isArray(e)?e:[e];return t.partitionBy=n,t}rank(){return this._window(function(e,t,n){return $n(e,e[n])})}rolling_max(e){return this._rolling(e,t=>B(t).max)}rolling_mean(e){return this._rolling(e,t=>B(t).mean)}rolling_median(e){return this._rolling(e,t=>ve(t))}rolling_min(e){return this._rolling(e,t=>B(t).min)}rolling_quantile(e,t){return this._rolling(t,n=>gt(n,e))}rolling_rank(e){return this._rolling(e,t=>$n(t,t[t.length-1],{ignoreNulls:!0}))}rolling_std(e){return this._rolling(e,t=>B(t).std)}rolling_sum(e){return this._rolling(e,t=>B(t).sum)}row_number(){let e=this._window(function(t,n,o){return o+1});return e.outputName="row_number",e}}});var Zt,ut,qn=O(()=>{"use strict";ee();be();U();Zt=class{constructor(e){this.expr=e}expr;_deriveDate(e){return x(this.expr,C(t=>{let n=Q(t);return n?e(n):null}))}_deriveDuration(e){return x(this.expr,C(t=>typeof t=="number"?e(t):null))}century(){return this._deriveDate(gr)}date(){return this._deriveDate(e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())))}datetime(){return this._deriveDate(e=>e)}day(){return this._deriveDate(e=>e.getUTCDate())}epoch(e="ms"){return this._deriveDate(t=>dr(t,e))}hour(){return this._deriveDate(e=>e.getUTCHours())}is_leap_year(){return this._deriveDate(Sr)}microsecond(){return this._deriveDate(e=>e.getUTCMilliseconds()*_t)}millennium(){return this._deriveDate(xr)}millisecond(){return this._deriveDate(e=>e.getUTCMilliseconds())}minute(){return this._deriveDate(e=>e.getUTCMinutes())}month(){return this._deriveDate(e=>e.getUTCMonth()+1)}month_end(){return this._deriveDate(e=>pn(e,1,0))}month_start(){return this._deriveDate(e=>pn(e,0,1))}nanosecond(){return this._deriveDate(e=>e.getUTCMilliseconds()*St)}ordinal_day(){return this._deriveDate(wr)}quarter(){return this._deriveDate(_r)}second(){return this._deriveDate(e=>e.getUTCSeconds())}strftime(e,t){return this._deriveDate(n=>Ue(n,e,t))}time(){return this._deriveDate(e=>e.toISOString().split("T")[1].slice(0,12))}timestamp(e="ms"){return this.epoch(e)}to_string(e,t){return this.strftime(e,t)}total_days(){return this._deriveDuration(e=>e/He)}total_hours(){return this._deriveDuration(e=>e/yr)}total_microseconds(){return this._deriveDuration(e=>e*_t)}total_milliseconds(){return this._deriveDuration(e=>e)}total_minutes(){return this._deriveDuration(e=>e/hr)}total_nanoseconds(){return this._deriveDuration(e=>e*St)}total_seconds(){return this._deriveDuration(e=>e/mn)}week(){return this._deriveDate(br)}weekday(){return this._deriveDate(e=>e.getUTCDay()||7)}year(){return this._deriveDate(e=>e.getUTCFullYear())}},ut=class extends F{get dt(){return new Zt(this)}}});var Xt,ct,Pn=O(()=>{"use strict";ee();be();U();re();oe();Xt=class{constructor(e){this.expr=e}expr;_deriveList(e){return x(this.expr,C(t=>T(t)?e(t):null))}all(){return this._deriveList(e=>K(e,t=>!!t,{mode:"every"}))}any(){return this._deriveList(e=>K(e,t=>!!t,{mode:"some"}))}contains(e){return this._deriveList(t=>t.includes(e))}contains_all(e){return this._deriveList(t=>K(e,n=>t.includes(n),{mode:"every"}))}contains_any(e){return this._deriveList(t=>K(e,n=>t.includes(n),{mode:"some"}))}count_matches(e){return this._deriveList(t=>{let n=0,o=t.length;for(let s=0;s<o;s++)t[s]===e&&n++;return n})}drop_nulls(){return this._deriveList(e=>{let t=e.length,n=[];for(let o=0;o<t;o++)e[o]!=null&&n.push(e[o]);return n})}explode({empty_as_null:e=!0,keep_nulls:t=!0}={}){return x(this.expr,n=>{let o=n.length,s=0;for(let c=0;c<o;c++){let l=n[c];if(T(l)){s+=l.length||(e?1:0);continue}if(l!=null){s+=1;continue}t&&(s+=1)}let i=new Array(s),a=new Int32Array(s),u=0;for(let c=0;c<o;c++){let l=n[c];if(T(l)){let f=l.length;if(f>0){for(let m=0;m<f;m++)a[u]=c,i[u++]=l[m];continue}e&&(a[u]=c,i[u++]=null);continue}if(l!=null){a[u]=c,i[u++]=l;continue}t&&(a[u]=c,i[u++]=null)}return i.rowMap=a,i})}first(e=!0){return this.get(0,e)}gather(e,t=!0){return this._deriveList(n=>{let o=n.length,s=T(e)?e:[e],i=s.length,a=new Array(i);for(let u=0;u<i;u++){let c=s[u],l=n.at(c);if(l===void 0&&!t)throw new de(`Index ${c} is out of bounds for list of length ${o}`);a[u]=l??null}return a})}gather_every(e={}){return this._deriveList(t=>or(t,e))}get(e,t=!0){return this._deriveList(n=>{let o=n.at(e);if(o===void 0&&!t)throw new de(`Index ${e} is out of bounds for list of length ${n.length}`);return o??null})}join(e=",",t={}){return this._deriveList(n=>sr(n,e,t))}last(e=!0){return this.get(-1,e)}len(){return this.lengths()}lengths(){return this._deriveList(e=>e.length)}max(){return this._deriveList(e=>B(e).max)}mean(){return this._deriveList(e=>B(e).mean)}median(){return this._deriveList(e=>ve(e))}min(){return this._deriveList(e=>B(e).min)}mode(){return this._deriveList(e=>bt(e))}n_unique(e={}){return this._deriveList(t=>Se(t,e).count)}reverse(){return this._deriveList(e=>e.slice().reverse())}slice(e,t){return this._deriveList(n=>{let o=n.length,s=e<0?Math.max(0,o+e):e,i=t!==void 0?s+t:o;return n.slice(s,i)})}sort(e=!1){return this._deriveList(t=>yt(t,e))}sum(){return this._deriveList(e=>B(e).sum)}unique(e={}){return this._deriveList(t=>Se(t,e).values)}eval(e){return x(this.expr,(t,n)=>{let o=t.length,s=new Array(o);for(let i=0;i<o;i++){let a=t[i];if(!T(a)){s[i]=null;continue}let u=a.length,c={...n,[Pe]:a};if(e.aggFn!=null&&(e.partitionBy==null||e.partitionBy.length===0)){let f=e.groupingOpsIndex!==void 0?e.groupingOpsIndex:e.ops.length,m=e.evaluatePre(f,c,u),p=e.aggFn(Array.from(m));s[i]=e.evaluatePost(f,[p],c)}else s[i]=nt(e,c,u)}return s})}},ct=class extends F{get list(){return new Xt(this)}}});var Qt,Ur=O(()=>{"use strict";ee();U();Qt=class extends F{fill_null({value:e=void 0,strategy:t=void 0,limit:n=void 0}={}){return x(this,(o,s)=>{let i=o.length,a=Array.from(o);if(t!==void 0)if(t==="zero"||t==="one"||t==="min"||t==="max"||t==="mean"){let u;t==="zero"?u=0:t==="one"?u=1:u=B(o)[t],De(a,u,{mode:"constant",condition:c=>c==null})}else if(t==="forward"||t==="backward"){let u=t==="forward",c=null,l=0;De(a,null,{mode:"independent",reverse:!u,step:({originalValue:f})=>f!=null?(c=f,l=0,f):c!==null&&(n===void 0||l<n)?(l++,c):null})}else throw new Error(`Unsupported fill_null strategy: "${t}"`);else{let u=this._resolve(e,s,i),c=T(u);De(a,null,{mode:"independent",step:({index:l,originalValue:f})=>f??(c?u[l]:u)})}return a})}reverse(){return x(this,e=>e.slice().reverse())}}});var Mr={};er(Mr,{ColumnExpr:()=>I,resolveColumnSelectors:()=>xe});function Qr(r,e){for(let t of e)for(let n of Object.getOwnPropertyNames(t.prototype))n!=="constructor"&&Object.defineProperty(r.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n)||Object.create(null))}function eo(r,e,t,n){if(!(r instanceof I)){if(r&&typeof r=="object"&&"evaluate"in r&&!r.colName){let o=[];for(let s=0;s<e.length;s++)t.has(e[s])||o.push(e[s]);return o}return null}if(r.colNames&&r.colNames.length>0)return r.colNames;if(r.colName==="*"){let o=new Set(r.excludedCols),s=[];for(let i=0;i<e.length;i++){let a=e[i];!o.has(a)&&!t.has(a)&&s.push(a)}return s}if(r.targetType||r.targetTypes&&r.targetTypes.length>0){if(!n)throw new Error("Cannot resolve DataType column selector without DataFrame schema.");let o=[];for(let s=0;s<e.length;s++){let i=e[s];if(t.has(i))continue;let a=n[i];if(a){if(r.targetType)a.matches(r.targetType)&&o.push(i);else if(r.targetTypes){for(let u=0;u<r.targetTypes.length;u++)if(a.matches(r.targetTypes[u])){o.push(i);break}}}}return o}return null}function xe(r,e,t,n,o){let s=[],i=t?new Set(t):new Set;for(let a=0;a<r.length;a++){let u=r[a];if(typeof u=="string"){s.push(new I(u));continue}if(u&&typeof u=="object"&&u.isUnnest){let l=[],f=u.colName;if(n&&f&&n[f]&&n[f].name==="Struct"&&(l=Object.keys(n[f].fields)),l.length===0&&o){let h=Object.keys(o)[0],y=h?o[h].length:0,d=u.baseExpr.evaluate(o,y),g=d.length;for(let b=0;b<g;b++){let S=d[b];if(S!=null&&typeof S=="object"){l=Object.keys(S);break}}}let m=l.length;if(m>0){for(let p=0;p<m;p++){let h=l[p],y=u.baseExpr.struct.field(h);s.push(y)}continue}}let c=eo(u,e,i,n);if(c!==null)for(let l=0;l<c.length;l++){let f=new I(c[l]);f.ops=[...u.ops||[]],f.aggFn=u.aggFn,f.partitionOpsIndex=u.partitionOpsIndex,f.groupingOpsIndex=u.groupingOpsIndex,f.partitionBy=u.partitionBy,u.evaluateWindow&&(f.evaluateWindow=u.evaluateWindow),u.outputName&&u.outputName!=="*"&&(f.outputName=u.outputName),s.push(f)}else s.push(u)}return s}var I,ie=O(()=>{"use strict";ee();Mn();jn();Bn();Kn();Vn();Ln();qn();Pn();Wn();Ur();U();ye();oe();I=class r extends F{colName;colNames;excludedCols=[];targetType;targetTypes;static isColExpr(e){if(!G(e))return!1;try{return"evaluate"in e&&typeof e.evaluate=="function"}catch{return!1}}static toColExpr(e){if(e==null)throw new Error("Column reference cannot be null or undefined.");return r.isColExpr(e)?e:new r(e)}constructor(e){super(),Array.isArray(e)?e.some(n=>n instanceof H||typeof n=="function")?(this.targetTypes=e,this.colName="",this.outputName=""):(this.colNames=e.map(String),this.colName="",this.outputName=""):e instanceof H||typeof e=="function"?(this.targetType=e,this.colName="",this.outputName=""):(this.colName=String(e),this.outputName=this.colName)}};Qr(I,[rt,st,at,lt,it,ot,ut,ct,ft,Qt])});function Lr(r){if(r==null)throw new Error("Column reference cannot be null or undefined.");return en||(en=(ie(),tr(Mr)).ColumnExpr),en.isColExpr(r)?r:new en(r)}var en,tn,ft,Wn=O(()=>{"use strict";ee();en=null;tn=class{constructor(e){this.expr=e;return new Proxy(this,{get(t,n,o){return n in t?Reflect.get(t,n,o):typeof n=="string"?t.field(n):Reflect.get(t,n,o)}})}expr;field(e){return x(this.expr,t=>{let n=t.length,o=new Array(n);for(let s=0;s<n;s++){let i=t[s];o[s]=i!=null&&typeof i=="object"?i[e]:null}return o}).alias(e)}rename_fields(e){return x(this.expr,t=>{let n=t.length,o=new Array(n),s=Object.keys(e),i=s.length;for(let a=0;a<n;a++){let u=t[a];if(u==null||typeof u!="object"){o[a]=null;continue}let c={},l=Object.keys(u),f=l.length;for(let m=0;m<f;m++){let p=l[m];c[p]=u[p]}for(let m=0;m<i;m++){let p=s[m];if(p in c){let h=e[p];c[h]=c[p],delete c[p]}}o[a]=c}return o})}with_fields(e){return x(this.expr,(t,n)=>{let o=t.length,s=new Array(o),i=[];if(Array.isArray(e)){let c=e.length;for(let l=0;l<c;l++){let f=e[l],m=Lr(f),p=m.outputName||m.colName;if(!p)throw new Error("Expressions passed to struct.with_fields must have a name/alias.");i.push({name:p,expr:m})}}else if(e&&typeof e=="object"){let c=Object.keys(e),l=c.length;for(let f=0;f<l;f++){let m=c[f],p=Lr(e[m]);i.push({name:m,expr:p})}}let a=i.length,u=new Array(a);for(let c=0;c<a;c++)u[c]=i[c].expr.evaluate(n,o);for(let c=0;c<o;c++){let l=t[c];if(l==null||typeof l!="object"){s[c]=null;continue}let f={},m=Object.keys(l),p=m.length;for(let h=0;h<p;h++){let y=m[h];f[y]=l[y]}for(let h=0;h<a;h++)f[i[h].name]=u[h][c];s[c]=f}return s})}unnest(){let e=x(this.expr);return e.isUnnest=!0,e.baseExpr=this.expr,e}},ft=class extends F{get struct(){return new tn(this)}}});var oo={};er(oo,{$df:()=>ro,ALL_COLUMNS_MARKER:()=>q,AggregationExpr:()=>at,ArithmeticExpr:()=>rt,Binary:()=>Dn,BinaryType:()=>jt,Boolean:()=>Qe,BooleanType:()=>Mt,COALESCE_MARKER:()=>un,ColumnExpr:()=>I,ColumnNotFoundError:()=>Te,ComparisonExpr:()=>st,ComputeError:()=>de,DFScriptError:()=>Ae,DataFrame:()=>N,DataFrameError:()=>j,DataType:()=>H,DataTypeRegistry:()=>R,Date:()=>An,DateTimeExprNamespace:()=>Zt,DateType:()=>$t,Datetime:()=>et,DatetimeType:()=>Kt,DecimalType:()=>Ye,Duration:()=>kn,DurationType:()=>Pt,ELEMENT_MARKER:()=>Pe,ExprBase:()=>F,Float32:()=>Sn,Float32Type:()=>vt,Float64:()=>Xe,Float64Type:()=>Ut,FloatDataType:()=>Me,GroupedData:()=>pt,Int16:()=>dn,Int16Type:()=>It,Int32:()=>gn,Int32Type:()=>kt,Int64:()=>Ze,Int64Type:()=>Et,Int8:()=>yn,Int8Type:()=>At,IntegerDataType:()=>ze,LITERAL_MARKER:()=>ln,List:()=>En,ListExpr:()=>ct,ListExprNamespace:()=>Xt,ListType:()=>Wt,LogicalExpr:()=>ot,NestedDataType:()=>Le,Null:()=>Cn,NullType:()=>Vt,NumericDataType:()=>Ce,Object:()=>Tn,ObjectType:()=>Bt,SchemaError:()=>Be,ShapeError:()=>z,SignedIntegerType:()=>me,StringExpr:()=>it,StringExprNamespace:()=>Yt,Struct:()=>On,StructExpr:()=>ft,StructExprNamespace:()=>tn,StructType:()=>Ht,TemporalDataType:()=>he,TemporalExpr:()=>ut,Time:()=>In,TimeType:()=>qt,UInt16:()=>xn,UInt16Type:()=>Rt,UInt32:()=>wn,UInt32Type:()=>Ft,UInt64:()=>_n,UInt64Type:()=>Nt,UInt8:()=>bn,UInt8Type:()=>Ot,UnsignedIntegerType:()=>pe,Utf8:()=>je,Utf8Type:()=>Lt,When:()=>rn,WhenThen:()=>mt,WhenThenChain:()=>nn,WindowExpr:()=>lt,all:()=>Ke,assertColumnExists:()=>J,assertHeight:()=>zt,coalesce:()=>Gn,coerceColumn:()=>ge,columnsToRows:()=>vn,computeRowHash:()=>Ie,concat:()=>qe,derive:()=>x,element:()=>Zn,evaluateExpression:()=>nt,exclude:()=>Jn,gatherColumnsByIndices:()=>$e,getRowFromColumns:()=>Xr,implode:()=>Yn,inferColumnType:()=>ue,kleeneBinary:()=>V,kleeneUnary:()=>C,lit:()=>Hn,read_csv:()=>sn,read_json:()=>on,resolveColumnSelectors:()=>xe,resolveWindowExpr:()=>Fn,rowsToColumns:()=>Nn,seq_range:()=>ke,when:()=>zn,writeStringToFileOrStream:()=>Un});module.exports=tr(oo);oe();ee();Mn();Ln();jn();Vn();Bn();Kn();qn();Pn();Wn();ie();ie();oe();re();U();function ke(r,e={strict:!0}){let t=e,n=new I(ln);return n.literalValue=r,t.name&&(n.outputName=t.name),n.ops.push(o=>{let s=o.length,i=(w,D)=>w===void 0?D:se(w<0?s+w:w,{min:0,max:s}),a=i(t.startIndex,0),u=i(t.endIndex,s),c=Math.max(0,u-a),l=t.n!==void 0?t.n:c,f=t.strict!==!1;if(f){if(l!==s)throw new z(`Column height mismatch: seq_range length ${l} does not match DataFrame height ${s}`)}else{let w=t.pad??!1,D=t.truncate??!1;if(w&&!D&&l>c)throw new z(`Cannot pad seq_range output: specified length ${l} starting at index ${a} exceeds slice width ${c} (requires truncation).`);if(D&&!w&&l<c)throw new z(`Cannot truncate seq_range output: specified length ${l} starting at index ${a} is less than slice width ${c} (requires padding).`)}let m=s,p=!!t.dtype,h=t.mode||"cumulative",y=t.step!==void 0?t.step:1,d=p?w=>t.dtype.coerce(w):w=>w;if(f){let w=t.dtype?.allocate?t.dtype.allocate(m):new Array(m);return De(w,r,{mode:h,step:y,coerce:d,startIndex:0,endIndex:m}),w}let g=Math.min(a+l,u),b=t.padValue!==void 0?t.padValue:null,S=d(b);if(h==="constant"&&a===0&&g===m&&!t.dtype){let w=new Array(m);for(let D=0;D<m;D++)w[D]=r;return w}let _=new Array(m);return _.fill(S),De(_,r,{mode:h,step:y,coerce:d,startIndex:a,endIndex:g}),_}),n}function Hn(r,e){let t=ke(r,{strict:!0,mode:"constant",dtype:e?.dtype,name:e?.name});return t.isLiteral=!0,t}ie();oe();function Ke(){return new I("*")}ie();oe();function Jn(r){let e=new I("*");return e.excludedCols=Array.isArray(r)?r:[r],e}ie();U();oe();function Gn(...r){let e=r.length===1&&Array.isArray(r[0])?r[0]:r,t=new I(un);return t.ops.push((n,o)=>{let s=n.length,i=l=>I.isColExpr(l)?l.evaluate(o,s):typeof l=="string"?o[l]||new Array(s).fill(null):l,a=e.length,u=new Array(a);for(let l=0;l<a;l++)u[l]=i(e[l]);let c=new Array(s);for(let l=0;l<s;l++){let f=null;for(let m=0;m<a;m++){let p=u[m],h=T(p)?p[l]:p;if(h!=null){f=h;break}}c[l]=f}return c}),t}ie();U();var nn=class{predicates;values;constructor(e,t){this.predicates=e,this.values=t}then(e){return new mt(this.predicates,this.values.concat(e))}},rn=class{predicates;constructor(e){this.predicates=[e]}then(e){return new mt(this.predicates,[e])}},mt=class r extends I{predicates;values;otherwiseValue;constructor(e,t,n=null){super(typeof e=="string"?e:"*when*"),this.predicates=Array.isArray(e)?e:[],this.values=t||[],this.otherwiseValue=n,this.ops.push((o,s)=>{let i=o.length,a=p=>I.isColExpr(p)?p.evaluate(s,i):typeof p=="string"&&p in s?s[p]:p,u=this.predicates.length,c=new Array(u),l=new Array(u);for(let p=0;p<u;p++)c[p]=a(this.predicates[p]),l[p]=a(this.values[p]);let f=a(this.otherwiseValue),m=new Array(i);for(let p=0;p<i;p++){let h=!1;for(let y=0;y<u;y++)if((T(c[y])?c[y][p]:c[y])===!0){m[p]=T(l[y])?l[y][p]:l[y],h=!0;break}h||(m[p]=T(f)?f[p]:f)}return m})}when(e){return new nn(this.predicates.concat(e),this.values)}otherwise(e){return new r(this.predicates,this.values,e)}};function zn(r){return new rn(r)}ie();function Yn(r){return I.toColExpr(r).implode()}ie();oe();function Zn(){return new I(Pe)}be();tt();var pt=class{groups;keys;allKeys;parentColumns;parentHeight;parentSchema;constructor(e,t,n,o,s,i){this.groups=e,this.keys=t,this.allKeys=n,this.parentColumns=o,this.parentHeight=s,this.parentSchema=i}to_dataframe(){let e=this.keys.length,t=new Array(e);for(let a=0;a<e;a++)t[a]=String(this.keys[a]);let n=this.groups.size,o={};for(let a=0;a<t.length;a++)o[t[a]]=new Array(n);let s=0;for(let a of this.groups.values()){if(a.length===0)continue;let u=a[0];for(let c=0;c<t.length;c++){let l=t[c],f=this.parentColumns[l][u];o[l][s]=f===void 0?null:f}s++}let i={};for(let a of t)i[a]=this.parentSchema[a];return N._createDirect(o,i,s)}agg(...e){let t=this.allKeys.length,n=new Array(t);for(let f=0;f<t;f++)n[f]=String(this.allKeys[f]);let o=this.keys.length,s=new Array(o);for(let f=0;f<o;f++)s[f]=String(this.keys[f]);let i=xe(e.flat(),n,s,this.parentSchema,this.parentColumns),a=this.groups.size,u={};for(let f=0;f<s.length;f++)u[s[f]]=new Array(a);let c=0;for(let f of this.groups.values()){if(f.length===0)continue;let m=f[0];for(let p=0;p<s.length;p++){let h=s[p],y=this.parentColumns[h][m];u[h][c]=y===void 0?null:y}c++}for(let f=0;f<i.length;f++){let m=i[f],p=m.outputName||m.colName||"*";if(!m.aggFn)u[p]=m.evaluate(u,a);else{let h=m.evaluatePre(m.groupingOpsIndex,this.parentColumns,this.parentHeight),y=new Array(a),d=0;for(let g of this.groups.values()){if(g.length===0)continue;let b=new Array(g.length);for(let S=0;S<g.length;S++)b[S]=h[g[S]];y[d]=m.aggFn(b),d++}u[p]=m.evaluatePost(m.groupingOpsIndex,y,u)}}let l={};for(let f of s)l[f]=this.parentSchema[f];for(let f of i){let m=f.outputName||f.colName||"*";l[m]=ue(u[m])}return N._createDirect(u,l,c)}};Ct();Dt();ye();U();re();ye();U();re();function to(r,e,t){if(r==null)throw new j(`Invalid input to ${e} at index ${t}: item cannot be null or undefined.`);if(r instanceof N)return[r];if(_e(r))return[new N(r)];if(T(r)){if(K(r,N,{mode:"every"}))return r;if(K(r,"plainObject",{mode:"every"}))return[new N(r)];let n=K(r,N,{mode:"some"});for(let o=0;o<r.length;o++)if(n?!(r[o]instanceof N):!_e(r[o]))throw new j(n?`Invalid input to ${e} at index ${t}, sub-index ${o}: nested array must contain only DataFrame instances.`:`Invalid input to ${e} at index ${t}, row ${o}: rows must be plain objects.`)}throw new j(`Invalid input to ${e} at index ${t}: expected DataFrame, row array, or column dictionary.`)}function qe(r,{how:e="vertical",horizontal:t}={}){if(r==null)throw new j("Invalid input to concat: rawItems cannot be null or undefined.");let n=Array.isArray(r)?r:[r],o=[];for(let i=0;i<n.length;i++)o.push(...to(n[i],"concat",i));let s=t?.strict??!0;if(o.length===0)return N._createDirect({},{},0);if(o.length===1&&e!=="horizontal")return o[0];switch(e){case"vertical":{let i=[];for(let h=0;h<o.length;h++)o[h].height>0&&i.push(o[h]);if(i.length===0)return N._createDirect({},{},0);let a=i[0],u=Object.keys(a._columns);for(let h=0;h<o.length;h++){let y=o[h];if(y.height===0)continue;let d=Object.keys(y._columns);if(u.length!==d.length)throw new j(`[Strict Vertical] Column count mismatch at index ${h}.`);for(let g=0;g<u.length;g++){if(u[g]!==d[g])throw new j(`[Strict Vertical] Schema mismatch at position ${g} in DF ${h}. Expected column "${u[g]}", but found "${d[g]}".`);let b=a.schema[u[g]],S=y.schema[u[g]];if(b&&S&&!b.equals(S))throw new Be(`[Strict Type Check] Schema type mismatch for column "${u[g]}": expected ${b.name}, found ${S.name}.`)}}let c=0;for(let h of o)c+=h.height;let l={},f=o.length;for(let h=0;h<f;h++)if(o[h].height>0){l=o[h].schema;break}Object.keys(l).length===0&&f>0&&(l=o[0].schema);let m={};for(let h of u){let y=l[h],d=!1;for(let b of o){let S=b._columns[h];if(!S){d=!0;break}if(!L(S)){for(let _=0;_<S.length;_++)if(S[_]==null){d=!0;break}}if(d)break}let g=y&&y.allocate?y.allocate(c):new Array(c).fill(null);d&&L(g)&&(g=new Array(c).fill(null)),m[h]=g}let p=0;for(let h of o){let y=h.height;if(y!==0){for(let d of u){let g=h._columns[d]||new Array(y).fill(null),b=m[d];if(L(b)&&L(g))b.set(g,p);else{let S=b;for(let _=0;_<y;_++)S[p+_]=g[_]}}p+=y}}return N._createDirect(m,l,c)}case"horizontal":{let i=o[0].height;for(let l=1;l<o.length;l++)o[l].height>i&&(i=o[l].height);let a=new Set;for(let l=0;l<o.length;l++){let f=o[l];if(s&&f.height!==i)throw new z(`[Horizontal] Row count mismatch at index ${l}. Expected ${i}, got ${f.height}. Set strict=false to allow padding.`);for(let m of Object.keys(f._columns)){if(a.has(m))throw new j(`[Horizontal] Duplicate column name "${m}" detected. Horizontal concat requires unique names.`);a.add(m)}}let u={},c={};for(let l of o){let f=l.height;Object.assign(c,l.schema);let m=Object.keys(l._columns),p=m.length;for(let h=0;h<p;h++){let y=m[h],d=l._columns[y];if(f===i)u[y]=L(d)?Array.from(d):d;else{let g=new Array(i);for(let b=0;b<f;b++)g[b]=d[b];for(let b=f;b<i;b++)g[b]=null;u[y]=g}}}return N._createDirect(u,c,i)}case"diagonal":{let i=new Set;for(let m of o)for(let p of Object.keys(m._columns))i.add(p);let a=Array.from(i),u=0;for(let m=0;m<o.length;m++)u+=o[m].height;let c={};for(let m of a){let p=null;for(let h of o){let y=h.schema[m];if(y){if(p===null)p=y;else if(!p.equals(y))throw new Be(`[Strict Type Check] Schema type mismatch for column "${m}": expected ${p.name}, found ${y.name}.`)}}c[m]=p||R.Utf8}let l={};for(let m=0;m<a.length;m++)l[a[m]]=new Array(u).fill(null);let f=0;for(let m=0;m<o.length;m++){let p=o[m],h=p.height;if(h!==0){for(let y=0;y<a.length;y++){let d=a[y],g=l[d],b=p._columns[d];if(b!==void 0)if(L(b)&&L(g))g.set(b,f);else{let S=g;for(let _=0;_<h;_++)S[f+_]=b[_]}else{let S=g;for(let _=0;_<h;_++)S[f+_]=null}}f+=h}}return N._createDirect(l,c,u)}}}tt();var N=class r{_columns;_height;_schema={};static _createDirect(e,t,n){zt(e,n);let o=Object.create(r.prototype);return o._columns=e,o._schema=t,o._height=n,o}constructor(e,t,n){if(Array.isArray(e)){let{columns:o,height:s}=Nn(e);this._columns=o,this._height=s,t?this.applySchema(t):this.inferSchema();return}if(G(e)){this._columns=e,this._height=zt(e,n),t?this.applySchema(t):this.inferSchema();return}this._columns={},this._height=0,t?this.applySchema(t):this._schema={}}inferSchema(){let e={},t=Object.keys(this._columns),n=t.length;for(let o=0;o<n;o++){let s=t[o];e[s]=ue(this._columns[s])}this.applySchema(e)}applySchema(e){this._schema=e;let t=Object.keys(e),n={};for(let o of t){let s=e[o],i=this._columns[o];n[o]=i?ge(i,s,this._height):ge(new Array(this._height).fill(null),s,this._height)}this._columns=n}get columns(){return Object.keys(this._columns)}concat(e,t={}){let n=K(e,r,{mode:"every",allowEmpty:!1})?e:[e];return qe([this,...n],t)}drop(...e){let t=new Set(e.flat()),n={},o={};for(let s of Object.keys(this._columns))t.has(s)||(n[s]=this._columns[s],o[s]=this._schema[s]);return r._createDirect(n,o,this._height)}drop_nulls(e){return this._height===0?this:this.filter(e?new I(e).is_not_null():Ke().is_not_null())}get dtypes(){let e=Object.keys(this._columns),t=e.length,n=new Array(t);for(let o=0;o<t;o++)n[o]=this._schema[e[o]];return n}explode(e,t){let n=I.toColExpr(e),o=n.colNames||[n.colName||n.outputName],s=new Set,i=o.length;for(let l=0;l<i;l++){let f=o[l];if(!f)throw new j("Expression passed to explode must have a column name.");J(f,this._columns,"Explode column"),s.add(f)}let a=Object.keys(this._columns),u=[],c=a.length;for(let l=0;l<c;l++){let f=a[l];u.push(s.has(f)?new I(f).list.explode(t):new I(f))}return this.select(...u)}fill_null(e={}){return this._height===0?this:this.with_columns(Ke().fill_null(e))}filter(...e){if(this._height===0)return r._createDirect({},this._schema,0);let t=this._height,n=Object.keys(this._columns),o=n.length,s=[],i=[],a=[],u=e.length;for(let d=0;d<u;d++){let g=e[d];typeof g=="function"?i.push(g):a.push(g)}let c=xe(a,n,void 0,this._schema,this._columns),l=c.length;for(let d=0;d<l;d++)s.push(c[d].evaluate(this._columns,t));let f=[],m=0,p=null;if(i.length>0){let d=this._columns;p={};for(let g=0;g<o;g++){let b=n[g],S=d[b];Object.defineProperty(p,b,{get(){let _=S[m];return _===void 0?null:_},enumerable:!0,configurable:!0})}}for(let d=0;d<t;d++){let g=!0;for(let b=0;b<s.length;b++)if(!s[b][d]){g=!1;break}if(g){if(p){m=d;for(let b=0;b<i.length;b++)if(!i[b](p)){g=!1;break}}g&&f.push(d)}}let h=$e(this._columns,f),y=f.length;return r._createDirect(h,this._schema,y)}get_schema(){return this._schema}groupby(e){let t=We(e),n=new Map,o=this._height,s=Re(e);for(let a=0;a<s.length;a++)J(s[a],this._columns,"Grouping key");for(let a=0;a<o;a++){let u=Ie(this._columns,s,a),c=n.get(u);c===void 0&&n.set(u,c=[]),c.push(a)}let i=Object.keys(this._columns);return new pt(n,t,i,this._columns,this._height,this._schema)}head(e=10){return this.limit(e,{offset:0,from:"start"})}get height(){return this._height}hstack(e,t={}){return this.concat(e,{how:"horizontal",horizontal:t})}insert_column(e,t,n){let o=I.toColExpr(n).alias(t),s=Object.keys(this._columns),i=s.length,a=[];for(let c=0;c<i;c++){let l=s[c];l!==t&&a.push(l)}let u=Math.max(0,Math.min(e,a.length));return a.splice(u,0,o),this.select(...a)}item(e,t){let n=this._height,o=Object.keys(this._columns),s=o.length;if(e===void 0&&t===void 0){if(n!==1||s!==1)throw new Error("DataFrame.item() can only be called without arguments if the shape is (1, 1).");return this._columns[o[0]][0]}if(e===void 0||t===void 0)throw new Error("DataFrame.item() requires both row and column to be specified if not empty.");if(e<0||e>=n)throw new Error(`Row index ${e} is out of bounds for DataFrame height ${n}.`);let i;if(typeof t=="number"){if(t<0||t>=s)throw new Error(`Column index ${t} is out of bounds for DataFrame width ${s}.`);i=o[t]}else if(i=t,this._columns[i]===void 0)throw new Error(`Column "${i}" does not exist.`);return this._columns[i][e]}*iter_columns(){let e=Object.keys(this._columns),t=e.length,n=this._columns;for(let o=0;o<t;o++)yield n[e[o]]}*iter_rows({named:e=!1}={}){let t=Object.keys(this._columns),n=t.length,o=this._columns,s=this._height,i=new Array(n);for(let a=0;a<n;a++)i[a]=o[t[a]];if(e)for(let a=0;a<s;a++){let u={};for(let c=0;c<n;c++)u[t[c]]=i[c][a];yield u}else for(let a=0;a<s;a++){let u=new Array(n);for(let c=0;c<n;c++)u[c]=i[c][a];yield u}}join(e){let{other:t,on:n,how:o="inner",suffixes:s=["","_right"]}=e,i=Re(n);for(let A=0;A<i.length;A++){let E=i[A];J(E,this._columns,"Join key"," in the left DataFrame."),J(E,t._columns,"Join key"," in the right DataFrame.")}let[a,u]=s,c=Object.keys(this._columns),l=Object.keys(t._columns),f=new Set(i),m=c.length,p=l.length,h=(A,E)=>{let v=i.length;for(let M=0;M<v;M++)if(A[i[M]][E]==null)return null;return Ie(A,i,E)},y=new Map,d=t._height,g=t._columns;for(let A=0;A<d;A++){let E=h(g,A);if(E===null)continue;let v=y.get(E);v===void 0&&(v=[],y.set(E,v)),v.push(A)}let b=this._height,S=this._columns,_=[],w=[],D=o==="outer"||o==="right",k=D?new Set:null;for(let A=0;A<b;A++){let E=h(S,A),v=E===null?void 0:y.get(E);if(v===void 0)(o==="left"||o==="outer")&&(_.push(A),w.push(null));else for(let M=0;M<v.length;M++){let Y=v[M];D&&k.add(Y),_.push(A),w.push(Y)}}if(D)for(let A=0;A<d;A++)k.has(A)||(_.push(-1),w.push(A));let W=_.length,ce={},fe={};for(let A=0;A<m;A++){let E=c[A],v=E in t._columns&&!f.has(E)?`${E}${a}`:E,M=this._columns[E],Y=f.has(E),ne=new Array(W);if(Y){let Z=t._columns[E];for(let ae=0;ae<W;ae++){let Xn=_[ae];if(Xn!==-1)ne[ae]=M[Xn];else{let Qn=w[ae];ne[ae]=Qn!==null?Z[Qn]:null}}}else for(let Z=0;Z<W;Z++){let ae=_[Z];ne[Z]=ae!==-1?M[ae]:null}ce[v]=ne,this._schema[E]&&(fe[v]=this._schema[E])}for(let A=0;A<p;A++){let E=l[A];if(!f.has(E)){let v=E in this._columns?`${E}${u}`:E,M=t._columns[E],Y=new Array(W);for(let ne=0;ne<W;ne++){let Z=w[ne];Y[ne]=Z!==null?M[Z]:null}ce[v]=Y,t._schema[E]&&(fe[v]=t._schema[E])}}return r._createDirect(ce,fe,W)}limit(e,{offset:t=0,from:n="start"}={}){let o=this._height,s=se(Math.floor(e),{min:0,max:o}),i=se(Math.floor(t),{min:0,max:o}),a=i,u=Math.min(i+s,o);n==="end"&&(u=o-i,a=Math.max(u-s,0));let c=u-a,l={},f=Object.keys(this._columns),m=f.length;for(let p=0;p<m;p++){let h=f[p];l[h]=this._columns[h].slice(a,u)}return r._createDirect(l,this._schema,c)}pivot(e){if(this._height===0)return r._createDirect({},{},0);let{index:t,columns:n,values:o}=e,s=Re(t),i=s.length;for(let w=0;w<i;w++)J(s[w],this._columns,"Pivot index key");let a=String(n),u=String(o);J(a,this._columns,"Pivot column key"),J(u,this._columns,"Pivot values key");let c=new Map,l=[],f=new Set,m=this._height,p=this._columns[a],h=this._columns[u];for(let w=0;w<m;w++){let D=Ie(this._columns,s,w);f.add(String(p[w])),c.get(D)===void 0&&(c.set(D,c.size),l.push(w))}let y=c.size,d={},g={};for(let w=0;w<i;w++){let D=s[w];d[D]=this._columns[D],this._schema[D]&&(g[D]=this._schema[D])}let b=$e(d,l),S=Array.from(f),_=this._schema[u]||R.Utf8;for(let w=0;w<S.length;w++){let D=S[w];b[D]=new Array(y).fill(null),g[D]=_}for(let w=0;w<m;w++){let D=Ie(this._columns,s,w),k=c.get(D),W=String(p[w]);b[W][k]=h[w]}return r._createDirect(b,g,y)}rename(e){let t=e||{},n={},o={},s=Object.keys(this._columns);for(let a of s){let u=t[a]||a;n[u]=this._columns[a],o[u]=this._schema[a]}if(Object.keys(n).length<s.length)throw new j("Rename collision: Multiple columns mapped to the same output name.");return r._createDirect(n,o,this._height)}reverse(){if(this._height===0)return this;let e={},t=Object.keys(this._columns),n=t.length;for(let o=0;o<n;o++){let s=t[o];e[s]=this._columns[s].slice().reverse()}return r._createDirect(e,this._schema,this._height)}get schema(){return this._schema}select(...e){let t=this._normalizeArgs(e),n=Object.keys(this._columns),o=xe(t,n,void 0,this._schema,this._columns),s=o.length;if(s===0)return r._createDirect({},{},this._height);let i={},a={},u=new Array(s),c=new Array(s),l=new Set,f=null;for(let h=0;h<s;h++){let y=o[h],d=y.outputName||y.colName||"*";if(l.has(d))throw new j(`Duplicate column selection: "${d}" is selected multiple times.`);l.add(d);let g=nt(y,this._columns,this._height);u[h]=g,c[h]=d;let b=g&&g.rowMap;if(b)if(f){let S=b.length;if(S!==f.length)throw new z(`Mismatched explode heights: Column "${d}" has length ${S}, but another exploded column has length ${f.length}`);for(let _=0;_<S;_++)if(b[_]!==f[_])throw new z(`Mismatched explode heights: Column "${d}" has mismatched row lengths compared to another exploded column.`)}else f=b}let m=f?f.length:this._height,p=s>0;for(let h=0;h<s;h++){let y=o[h],d=y.aggFn!=null&&(y.partitionBy==null||y.partitionBy.length===0),g=!!y.isLiteral;if(!d&&!g){p=!1;break}}for(let h=0;h<s;h++){let y=c[h],d=u[h],g=d,b=g&&g.rowMap,S=T(d)?d.length:0,_=f&&!b?this._height:m;if(S!==_)throw new z(`Column height mismatch: Column "${y}" has length ${S}, but expected ${_}`);if(f&&!b){let w=f.length;if(L(d)){let D=new g.constructor(w);for(let k=0;k<w;k++)D[k]=g[f[k]];d=D}else{let D=new Array(w);for(let k=0;k<w;k++)D[k]=g[f[k]];d=D}}u[h]=d}p&&(m=1);for(let h=0;h<s;h++){let y=o[h],d=c[h],g=u[h],b=y.colName||d,_=y instanceof I&&y.ops.length===0&&!y.isWindow&&!y.aggFn&&this._schema[b]||ue(g);a[d]=_,i[d]=ge(g,_,m)}return r._createDirect(i,a,m)}get shape(){return[this.height,this.width]}slice(e,t){let n=this._height,o=e<0?Math.max(n+e,0):Math.min(e,n),s=t===void 0?n:t<0?Math.max(n+t,0):Math.min(t,n),i=Math.max(s-o,0);return this.limit(i,{offset:o})}sort(e){if(!e||!e.by||this._height===0)return this;let{by:t,descending:n=!1,nullsLast:o=!0,custom:s}=e,i=We(t);for(let h=0;h<i.length;h++){let y=I.toColExpr(i[h]);y.colName&&J(y.colName,this._columns,"Sort key")}let a=Array.isArray(n)?n:new Array(i.length).fill(n),u=i.length,c=new Array(u);for(let h=0;h<u;h++){let y=i[h],d=a[h]?-1:1,g=s&&typeof y=="string"?s[y]:null,b=I.toColExpr(y).evaluate(this._columns,this._height);c[h]={values:b,isDesc:d,customComp:g}}let l=c.length,f=o?1:-1,m=new Array(this._height);for(let h=0;h<this._height;h++)m[h]=h;m.sort((h,y)=>{for(let d=0;d<l;d++){let{values:g,isDesc:b,customComp:S}=c[d],_=g[h],w=g[y];if(S){let k=S(_,w);if(k!==0)return k*b;continue}if(_==null||w==null){if(_===w)continue;return(_==null?1:-1)*f}if(_===w)continue;return(_<w?-1:1)*b}return 0});let p=$e(this._columns,m);return r._createDirect(p,this._schema,this._height)}tail(e=10){return this.limit(e,{offset:0,from:"end"})}to_dict(){return{...this._columns}}to_dicts(){return vn(this._columns,this._height)}to_list(e){if(this._height===0)return[];if(e==null)return new Array(this._height).fill(null);let n=I.toColExpr(e).evaluate(this._columns,this._height);return Array.isArray(n)?n:Array.from(n)}transpose({include_header:e=!1,header_name:t="column",column_names:n}={}){if(this._height===0){let l={},f={};return e&&(l[t]=ge([],R.Utf8,0),f[t]=R.Utf8),r._createDirect(l,f,0)}let o=this.columns;typeof n=="string"&&(J(n,this._columns,"column_names"),o=o.filter(l=>l!==n));let s=[];if(typeof n=="string"){let l=this._columns[n];s=new Array(this._height);for(let f=0;f<this._height;f++){let m=l[f];if(m==null)throw new j(`Transpose column_names column "${n}" contains null/undefined at index ${f}`);s[f]=String(m)}}else if(n!=null&&typeof n!="string"&&Symbol.iterator in Object(n)){let l=Array.from(n);if(l.length!==this._height)throw new j(`column_names length (${l.length}) must match the height of the DataFrame (${this._height})`);s=new Array(this._height);for(let f=0;f<this._height;f++)s[f]=String(l[f])}else{s=new Array(this._height);for(let l=0;l<this._height;l++)s[l]=`column_${l}`}let i=new Set;e&&i.add(t);for(let l=0;l<s.length;l++){let f=s[l];if(i.has(f))throw new j(`Duplicate column name in transposed DataFrame: "${f}"`);i.add(f)}let a=o.length,u={},c={};e&&(u[t]=ge(o,R.Utf8,a),c[t]=R.Utf8);for(let l=0;l<this._height;l++){let f=s[l],m=new Array(a);for(let h=0;h<a;h++)m[h]=this._columns[o[h]][l];let p=ue(m);u[f]=ge(m,p,a),c[f]=p}return r._createDirect(u,c,a)}unique(e){if(this._height===0)return r._createDirect({},this._schema,0);let t=We(e),n=t.length===0?Object.keys(this._columns):t.map(String);for(let c of n)J(c,this._columns,"Unique column key");let o=new Set,s=[],i=this._height;for(let c=0;c<i;c++){let l=Ie(this._columns,n,c);o.has(l)||(o.add(l),s.push(c))}let a=$e(this._columns,s),u=s.length;return r._createDirect(a,this._schema,u)}unpivot(e){let{idVars:t,valueVars:n,varName:o="variable",valueName:s="value"}=e,i=Re(t),a=Re(n),u=i.length,c=a.length;for(let h of i)J(h,this._columns,"Unpivot id variable key");for(let h of a)J(h,this._columns,"Unpivot value variable key");let l=this._height*c,f={};for(let h=0;h<u;h++)f[i[h]]=new Array(l);f[o]=new Array(l),f[s]=new Array(l);let m=0;for(let h=0;h<this._height;h++)for(let y=0;y<c;y++){let d=a[y];for(let g=0;g<u;g++){let b=i[g];f[b][m]=this._columns[b][h]}f[o][m]=d,f[s][m]=this._columns[d][h],m++}let p={};for(let h of i)p[h]=this._schema[h];return p[o]=R.Utf8,p[s]=ue(f[s]),r._createDirect(f,p,l)}vstack(e){return this.concat(e,{how:"vertical"})}get width(){return Object.keys(this._columns).length}_normalizeArgs(e){let t=e.flat(),n=[];for(let o of t)if(typeof o=="string")n.push(new I(o));else if(I.isColExpr(o))n.push(o);else if(G(o)){let s=Object.keys(o),i=s.length;for(let a=0;a<i;a++){let u=s[a],c=o[u];if(I.isColExpr(c))n.push(c.alias(u));else{let l=new I(u);l.evaluate=(f,m)=>new Array(m).fill(c),n.push(l)}}}return n}with_columns(...e){if(e.length===0)return this;let t=this._normalizeArgs(e),n=Object.keys(this._columns),o=xe(t,n,void 0,this._schema,this._columns),s=o.length;if(s===0)return this;let i=new Map;for(let c=0;c<s;c++){let l=o[c],f=l.outputName||l.colName||"*";i.set(f,l)}let a=[],u=n.length;for(let c=0;c<u;c++){let l=n[c];a.push(i.get(l)||new I(l)),i.delete(l)}for(let c of i.values())a.push(c);return this.select(...a)}with_row_index(e="index",t=0){let n=ke(t,{mode:"independent",dtype:R.UInt32,step:1}),o=this.insert_column(0,e,n);return o._schema[e]=R.UInt32,o}write_json(e,{format:t="json",replacerOptions:n}={}){if(t!=="json"&&t!=="ndjson")throw new TypeError(`Unsupported JSON format: "${t}". Expected "json" or "ndjson".`);let o=n?.replacer===null?void 0:Ge(n),s;if(t==="ndjson"){let i=this.to_dicts(),a=i.length,u=new Array(a);for(let c=0;c<a;c++)u[c]=JSON.stringify(i[c],o);s=u.join(`
|
|
6
|
+
`)}else s=JSON.stringify(this.to_dicts(),o);return Un(e,s),s}write_csv(e,t={}){if(e){if(typeof e=="string"){let n=require("fs"),o=n.openSync(e,"w");try{Gt(this._columns,this._height,{...t,onRow:s=>{n.writeSync(o,s,null,"utf8")}})}finally{n.closeSync(o)}}else if(typeof e=="object"&&typeof e.write=="function")Gt(this._columns,this._height,{...t,onRow:n=>{e.write(n)}});else throw new TypeError("Invalid file argument. Expected a file path string or a writable stream/object with a write method.");return""}return Gt(this._columns,this._height,t)}};tt();ye();U();re();function on(r,{format:e="json",trimBeforeParse:t=!0,schema:n,...o}={}){let s=Tr(r,{format:e,trimBeforeParse:t,...o});if(s===r)throw new j(`Invalid JSON input: must be a valid, non-empty JSON ${e} string.`);let i=Array.isArray(s)?s:G(s)?[s]:[];return new N(i,n)}U();function sn(r,e={}){let{hasHeader:t=!0,schema:n,inferSchema:o=!0}=e,s=Ir(r,e);if(s.length===0)return new N({});let i,a;t?(i=s[0],a=s.slice(1)):(i=s[0].map((m,p)=>`column_${p}`),a=s);let u=i.length,c=a.length,l={};for(let m=0;m<u;m++){let p=i[m],h=new Array(c);for(let y=0;y<c;y++)h[y]=a[y][m]!==void 0?a[y][m]:"";l[p]=h}let f={};for(let m=0;m<u;m++){let p=i[m],h=l[p];if(n&&n[p])f[p]=h;else if(o){let{values:y}=kr(h,e);f[p]=y}else f[p]=h}return new N(f,n)}function no(r,e){return new N(r,e)}var ro={data:no,col:r=>new I(r),all:Ke,exclude:Jn,coalesce:Gn,concat:qe,read_json:on,read_csv:sn,lit:Hn,when:zn,implode:Yn,seq_range:ke,element:Zn,DataType:R};ye();re();0&&(module.exports={$df,ALL_COLUMNS_MARKER,AggregationExpr,ArithmeticExpr,Binary,BinaryType,Boolean,BooleanType,COALESCE_MARKER,ColumnExpr,ColumnNotFoundError,ComparisonExpr,ComputeError,DFScriptError,DataFrame,DataFrameError,DataType,DataTypeRegistry,Date,DateTimeExprNamespace,DateType,Datetime,DatetimeType,DecimalType,Duration,DurationType,ELEMENT_MARKER,ExprBase,Float32,Float32Type,Float64,Float64Type,FloatDataType,GroupedData,Int16,Int16Type,Int32,Int32Type,Int64,Int64Type,Int8,Int8Type,IntegerDataType,LITERAL_MARKER,List,ListExpr,ListExprNamespace,ListType,LogicalExpr,NestedDataType,Null,NullType,NumericDataType,Object,ObjectType,SchemaError,ShapeError,SignedIntegerType,StringExpr,StringExprNamespace,Struct,StructExpr,StructExprNamespace,StructType,TemporalDataType,TemporalExpr,Time,TimeType,UInt16,UInt16Type,UInt32,UInt32Type,UInt64,UInt64Type,UInt8,UInt8Type,UnsignedIntegerType,Utf8,Utf8Type,When,WhenThen,WhenThenChain,WindowExpr,all,assertColumnExists,assertHeight,coalesce,coerceColumn,columnsToRows,computeRowHash,concat,derive,element,evaluateExpression,exclude,gatherColumnsByIndices,getRowFromColumns,implode,inferColumnType,kleeneBinary,kleeneUnary,lit,read_csv,read_json,resolveColumnSelectors,resolveWindowExpr,rowsToColumns,seq_range,when,writeStringToFileOrStream});
|
package/dist/types.d.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import type { DataFrame } from "./dataframe/dataframe";
|
|
2
|
+
import type { RegisteredDataType } from "./datatypes";
|
|
3
|
+
export type { RegisteredDataType };
|
|
2
4
|
export type RowRecord = Record<string, any>;
|
|
5
|
+
export type JSONFormat =
|
|
6
|
+
/** Standard JSON format. */
|
|
7
|
+
"json"
|
|
8
|
+
/** Newline Delimited JSON format. */
|
|
9
|
+
| "ndjson";
|
|
3
10
|
export type ColumnData<T = any> = ArrayLike<T> & Iterable<T>;
|
|
4
11
|
export type ColumnDict = Record<string, ColumnData>;
|
|
12
|
+
export type DataFrameSchema = Record<string, RegisteredDataType>;
|
|
5
13
|
export type DataFrameColumns<T extends RowRecord> = {
|
|
6
14
|
[K in keyof T]: ColumnData<T[K]>;
|
|
7
15
|
};
|
|
8
16
|
export type Scalar = string | number | boolean | bigint | Date | null | undefined;
|
|
9
17
|
export type AggFn<V, R = any> = (values: V[]) => R;
|
|
10
18
|
export type OpFn = (vals: ColumnData, columns: ColumnDict) => ColumnData;
|
|
19
|
+
export type IntoExpr = string | IExpr;
|
|
11
20
|
export interface IExpr {
|
|
12
21
|
ops: OpFn[];
|
|
13
22
|
colName?: string;
|
|
@@ -24,13 +33,11 @@ export interface IExpr {
|
|
|
24
33
|
} | null;
|
|
25
34
|
isWindow?: boolean;
|
|
26
35
|
alias(name: string): this;
|
|
27
|
-
cast(dataType:
|
|
36
|
+
cast(dataType: RegisteredDataType): this;
|
|
28
37
|
_resolve(val: any, columns: ColumnDict, height: number): ColumnData | any;
|
|
29
38
|
evaluate(columns: ColumnDict, height: number): ColumnData;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
evaluatePrePartition(columns: ColumnDict, height: number): ColumnData;
|
|
33
|
-
evaluatePostPartition(aggregatedArray: any[], columns: ColumnDict): ColumnData;
|
|
39
|
+
evaluatePre(opsIndex: number | undefined, columns: ColumnDict, height: number): ColumnData;
|
|
40
|
+
evaluatePost(opsIndex: number | undefined, aggregatedArray: any[], columns: ColumnDict): ColumnData;
|
|
34
41
|
evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
|
|
35
42
|
debug(label?: string): this;
|
|
36
43
|
}
|
|
@@ -45,3 +52,22 @@ export interface ConcatOptions {
|
|
|
45
52
|
horizontal?: HorizontalConcatOptions;
|
|
46
53
|
}
|
|
47
54
|
export type ConcatItem = DataFrame<any> | ColumnDict | RowRecord[];
|
|
55
|
+
export type { UniqueListStatsOptions, JoinListOptions } from "./utils/list";
|
|
56
|
+
export interface ExplodeOptions {
|
|
57
|
+
empty_as_null?: boolean;
|
|
58
|
+
keep_nulls?: boolean;
|
|
59
|
+
}
|
|
60
|
+
import type { DataType } from "./datatypes/DataType";
|
|
61
|
+
export type InferDataType<T> = T extends DataType<infer U> ? U : any;
|
|
62
|
+
export type InferSchema<S extends DataFrameSchema> = {
|
|
63
|
+
[K in keyof S]: InferDataType<S[K]>;
|
|
64
|
+
};
|
|
65
|
+
export type FlattenUnion<T> = {
|
|
66
|
+
[K in (T extends any ? keyof T : never)]?: T extends any ? (K extends keyof T ? T[K] : never) : never;
|
|
67
|
+
};
|
|
68
|
+
export type FillNullStrategy = "forward" | "backward" | "min" | "max" | "mean" | "zero" | "one";
|
|
69
|
+
export interface FillNullOptions {
|
|
70
|
+
value?: any;
|
|
71
|
+
strategy?: FillNullStrategy;
|
|
72
|
+
limit?: number;
|
|
73
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ColumnDict } from "../types";
|
|
2
|
+
import { type SafeJsonReplacerOptions } from "./json";
|
|
3
|
+
import { type NumericFormatOptions } from "./number";
|
|
4
|
+
import { DataType } from "../datatypes";
|
|
5
|
+
import type { ReadCSVOptions } from "../dataframe/types";
|
|
6
|
+
export interface FormatCSVValueOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The string representation to use for null/missing values.
|
|
9
|
+
* @default ""
|
|
10
|
+
*/
|
|
11
|
+
nullValue?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Custom format string for Date values (e.g. "%Y-%m-%d").
|
|
14
|
+
*/
|
|
15
|
+
dateFormat?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Custom format string for Time values (e.g. "%H:%M:%S").
|
|
18
|
+
*/
|
|
19
|
+
timeFormat?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Custom format string for Datetime values (e.g. "%Y-%m-%d %H:%M:%S").
|
|
22
|
+
*/
|
|
23
|
+
datetimeFormat?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Options for numeric formatting (floats, ints, bigints).
|
|
26
|
+
*/
|
|
27
|
+
numericFormatOptions?: NumericFormatOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Options for the safe JSON replacer used when formatting objects/arrays.
|
|
30
|
+
*/
|
|
31
|
+
replacerOptions?: SafeJsonReplacerOptions;
|
|
32
|
+
}
|
|
33
|
+
export interface WriteCSVOptions extends FormatCSVValueOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Whether to write the header row.
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
includeHeader?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Character that separates fields.
|
|
41
|
+
* @default ","
|
|
42
|
+
*/
|
|
43
|
+
separator?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The string used to end each row.
|
|
46
|
+
* @default "\n"
|
|
47
|
+
*/
|
|
48
|
+
lineTerminator?: string;
|
|
49
|
+
/**
|
|
50
|
+
* The character used for quoting fields.
|
|
51
|
+
* @default '"'
|
|
52
|
+
*/
|
|
53
|
+
quoteChar?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Defines when to use quotes.
|
|
56
|
+
* - "necessary": Quotes only when required (e.g., value contains separator, quote_char, or newlines).
|
|
57
|
+
* - "always": Quotes every field.
|
|
58
|
+
* - "never": Never quotes fields.
|
|
59
|
+
* - "non_numeric": Quotes all fields that are non-numeric.
|
|
60
|
+
* @default "necessary"
|
|
61
|
+
*/
|
|
62
|
+
quoteStyle?: "necessary" | "always" | "never" | "non_numeric";
|
|
63
|
+
/**
|
|
64
|
+
* Whether to include a Byte Order Mark (BOM) at the start of the file.
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
includeBom?: boolean;
|
|
68
|
+
}
|
|
69
|
+
export declare function formatCsvValue(options?: FormatCSVValueOptions): (val: any) => string;
|
|
70
|
+
export declare function stringifyCSV(columns: ColumnDict, height: number, options?: WriteCSVOptions & {
|
|
71
|
+
onRow?: (rowStr: string) => void;
|
|
72
|
+
}): string;
|
|
73
|
+
export declare function parseCSV(content: string, options?: ReadCSVOptions): string[][];
|
|
74
|
+
export declare function inferAndCoerceCSVColumn(values: string[], options?: ReadCSVOptions): {
|
|
75
|
+
type: DataType;
|
|
76
|
+
values: any[];
|
|
77
|
+
};
|