df-script 1.5.0 → 1.6.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.
Files changed (133) hide show
  1. package/README.md +124 -8
  2. package/dist/api.d.ts +1 -1
  3. package/dist/columnExpressions/ColumnExpr.d.ts +2 -2
  4. package/dist/columnExpressions/functions/coalesce.d.ts +2 -2
  5. package/dist/columnExpressions/functions/element.d.ts +1 -1
  6. package/dist/columnExpressions/functions/when.d.ts +2 -2
  7. package/dist/columnExpressions/index.d.ts +1 -1
  8. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +2 -2
  9. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +11 -10
  10. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +39 -0
  11. package/dist/columnExpressions/mixins/ListExpr.d.ts +2 -2
  12. package/dist/columnExpressions/mixins/StringExpr.d.ts +2 -2
  13. package/dist/columnExpressions/types.d.ts +1 -0
  14. package/dist/constants.d.ts +11 -0
  15. package/dist/dataframe/dataframe.d.ts +1 -1
  16. package/dist/datatypes/index.d.ts +3 -2
  17. package/dist/datatypes/types.d.ts +7 -7
  18. package/dist/index.js +6 -6
  19. package/dist/types.d.ts +4 -2
  20. package/dist/utils/array.d.ts +217 -0
  21. package/dist/utils/binary.d.ts +3 -0
  22. package/dist/utils/date.d.ts +21 -35
  23. package/dist/utils/guards.d.ts +11 -10
  24. package/dist/utils/index.d.ts +3 -2
  25. package/dist/utils/list.d.ts +23 -1
  26. package/dist/utils/number.d.ts +14 -29
  27. package/dist/utils/object.d.ts +26 -0
  28. package/dist/utils/string.d.ts +3 -5
  29. package/package.json +2 -2
  30. package/dist/api.js +0 -26
  31. package/dist/bundle.min.js +0 -1
  32. package/dist/columnExpressions/ColumnExpr.js +0 -219
  33. package/dist/columnExpressions/ExprBase.js +0 -92
  34. package/dist/columnExpressions/constants.js +0 -7
  35. package/dist/columnExpressions/functions/all.js +0 -11
  36. package/dist/columnExpressions/functions/coalesce.js +0 -44
  37. package/dist/columnExpressions/functions/element.js +0 -11
  38. package/dist/columnExpressions/functions/exclude.js +0 -13
  39. package/dist/columnExpressions/functions/implode.js +0 -7
  40. package/dist/columnExpressions/functions/lit.js +0 -17
  41. package/dist/columnExpressions/functions/repeat.d.ts +0 -47
  42. package/dist/columnExpressions/functions/repeat.js +0 -131
  43. package/dist/columnExpressions/functions/seq_range.js +0 -91
  44. package/dist/columnExpressions/functions/when.js +0 -85
  45. package/dist/columnExpressions/index.js +0 -38
  46. package/dist/columnExpressions/mixins/AggregationExpr.js +0 -76
  47. package/dist/columnExpressions/mixins/ArithmeticExpr.js +0 -131
  48. package/dist/columnExpressions/mixins/BooleanExpr.d.ts +0 -40
  49. package/dist/columnExpressions/mixins/BooleanExpr.js +0 -67
  50. package/dist/columnExpressions/mixins/ComparisonExpr.js +0 -250
  51. package/dist/columnExpressions/mixins/ListExpr.js +0 -224
  52. package/dist/columnExpressions/mixins/LogicalExpr.js +0 -53
  53. package/dist/columnExpressions/mixins/ManipulationExpr.js +0 -71
  54. package/dist/columnExpressions/mixins/NumericExpr.d.ts +0 -92
  55. package/dist/columnExpressions/mixins/NumericExpr.js +0 -259
  56. package/dist/columnExpressions/mixins/StringExpr.js +0 -237
  57. package/dist/columnExpressions/mixins/StructExpr.js +0 -139
  58. package/dist/columnExpressions/mixins/TemporalExpr.js +0 -126
  59. package/dist/columnExpressions/mixins/WindowExpr.js +0 -151
  60. package/dist/columnExpressions/types.js +0 -2
  61. package/dist/columnExpressions/utils.js +0 -45
  62. package/dist/dataframe/constants.js +0 -7
  63. package/dist/dataframe/dataframe.js +0 -990
  64. package/dist/dataframe/grouped/grouped.js +0 -114
  65. package/dist/dataframe/index.js +0 -20
  66. package/dist/dataframe/types.js +0 -2
  67. package/dist/dataframe/utils.js +0 -307
  68. package/dist/datatypes/DataType.js +0 -76
  69. package/dist/datatypes/index.js +0 -46
  70. package/dist/datatypes/types/Binary.d.ts +0 -9
  71. package/dist/datatypes/types/Binary.js +0 -18
  72. package/dist/datatypes/types/Boolean.d.ts +0 -9
  73. package/dist/datatypes/types/Boolean.js +0 -19
  74. package/dist/datatypes/types/Date.d.ts +0 -8
  75. package/dist/datatypes/types/Date.js +0 -21
  76. package/dist/datatypes/types/Datetime.d.ts +0 -8
  77. package/dist/datatypes/types/Datetime.js +0 -17
  78. package/dist/datatypes/types/Decimal.d.ts +0 -10
  79. package/dist/datatypes/types/Decimal.js +0 -28
  80. package/dist/datatypes/types/Duration.d.ts +0 -8
  81. package/dist/datatypes/types/Duration.js +0 -17
  82. package/dist/datatypes/types/Float32.d.ts +0 -8
  83. package/dist/datatypes/types/Float32.js +0 -17
  84. package/dist/datatypes/types/Float64.d.ts +0 -8
  85. package/dist/datatypes/types/Float64.js +0 -17
  86. package/dist/datatypes/types/Int16.d.ts +0 -8
  87. package/dist/datatypes/types/Int16.js +0 -17
  88. package/dist/datatypes/types/Int32.d.ts +0 -8
  89. package/dist/datatypes/types/Int32.js +0 -17
  90. package/dist/datatypes/types/Int64.d.ts +0 -8
  91. package/dist/datatypes/types/Int64.js +0 -17
  92. package/dist/datatypes/types/Int8.d.ts +0 -8
  93. package/dist/datatypes/types/Int8.js +0 -17
  94. package/dist/datatypes/types/List.d.ts +0 -10
  95. package/dist/datatypes/types/List.js +0 -31
  96. package/dist/datatypes/types/Null.d.ts +0 -9
  97. package/dist/datatypes/types/Null.js +0 -17
  98. package/dist/datatypes/types/Object.d.ts +0 -9
  99. package/dist/datatypes/types/Object.js +0 -17
  100. package/dist/datatypes/types/Struct.d.ts +0 -14
  101. package/dist/datatypes/types/Struct.js +0 -39
  102. package/dist/datatypes/types/Time.d.ts +0 -8
  103. package/dist/datatypes/types/Time.js +0 -29
  104. package/dist/datatypes/types/UInt16.d.ts +0 -8
  105. package/dist/datatypes/types/UInt16.js +0 -17
  106. package/dist/datatypes/types/UInt32.d.ts +0 -8
  107. package/dist/datatypes/types/UInt32.js +0 -17
  108. package/dist/datatypes/types/UInt64.d.ts +0 -8
  109. package/dist/datatypes/types/UInt64.js +0 -17
  110. package/dist/datatypes/types/UInt8.d.ts +0 -8
  111. package/dist/datatypes/types/UInt8.js +0 -17
  112. package/dist/datatypes/types/Utf8.d.ts +0 -10
  113. package/dist/datatypes/types/Utf8.js +0 -20
  114. package/dist/datatypes/types.js +0 -290
  115. package/dist/exceptions/index.js +0 -46
  116. package/dist/exceptions/utils.js +0 -28
  117. package/dist/functions/concat.js +0 -260
  118. package/dist/functions/index.js +0 -9
  119. package/dist/functions/read_csv.js +0 -53
  120. package/dist/functions/read_json.js +0 -21
  121. package/dist/functions/transpose.d.ts +0 -7
  122. package/dist/functions/transpose.js +0 -84
  123. package/dist/types.js +0 -2
  124. package/dist/utils/boolean.d.ts +0 -1
  125. package/dist/utils/boolean.js +0 -18
  126. package/dist/utils/csv.js +0 -313
  127. package/dist/utils/date.js +0 -348
  128. package/dist/utils/guards.js +0 -112
  129. package/dist/utils/index.js +0 -23
  130. package/dist/utils/json.js +0 -217
  131. package/dist/utils/list.js +0 -361
  132. package/dist/utils/number.js +0 -401
  133. package/dist/utils/string.js +0 -209
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
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});
1
+ "use strict";var bn=Object.defineProperty;var Eo=Object.getOwnPropertyDescriptor;var Ro=Object.getOwnPropertyNames;var No=Object.prototype.hasOwnProperty;var E=(n,e)=>()=>(n&&(e=n(n=0)),e);var Ar=(n,e)=>{for(var t in e)bn(n,t,{get:e[t],enumerable:!0})},vo=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ro(e))!No.call(n,o)&&o!==t&&bn(n,o,{get:()=>e[o],enumerable:!(r=Eo(e,o))||r.enumerable});return n};var Tr=n=>vo(bn({},"__esModule",{value:!0}),n);var G,xn,_n,ze,ae=E(()=>{"use strict";G="*",xn="*literal*",_n="*coalesce*",ze="*element*"});function P(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function Ce(n){if(!P(n))return!1;let e=Object.getPrototypeOf(n);if(e===null)return!0;let t=Object.prototype.hasOwnProperty.call(e,"constructor")&&e.constructor;return typeof t!="function"?!1:Function.prototype.toString.call(t)===Zo}function Vr(n){if(typeof n!="function")return!1;let e="";try{e=Function.prototype.toString.call(n)}catch{return!1}if(/^class[\s{]/.test(e))return!0;if(n===Symbol||n===BigInt)return!1;let t=Object.getOwnPropertyDescriptor(n,"prototype");return t&&!t.writable?e.includes("[native code]"):!1}function le(n,e,t,r){if(!P(n))return!1;if(!(Symbol.toStringTag in n))return Object.prototype.toString.call(n)===e;if(!t)return!1;try{return t.call(n,r),!0}catch{return!1}}function F(n){return le(n,Fo,wn)&&wn?!Number.isNaN(wn.call(n)):!1}function de(n){return le(n,Mo,Ho)}function wt(n){return le(n,Uo,Jo)}function St(n){return le(n,jo,Yo)}function Lr(n){return le(n,Lo,Xo,"key")}function Pr(n){return P(n)?Symbol.toStringTag in n?n instanceof Error:Object.prototype.toString.call(n)===Vo:!1}function Ir(n){return le(n,vr,Sn)}function kr(n){return le(n,Fr,Dn)}function Er(n){return le(n,Mr,An)}function Rr(n){return le(n,Ur,He)}function Nr(n){return le(n,jr,Je)}function oe(n){if(!P(n))return n;switch(Object.prototype.toString.call(n)){case Fr:if(kr(n))try{return Dn.call(n)}catch{}break;case vr:if(Ir(n))try{return Sn.call(n)}catch{}break;case Mr:if(Er(n))try{return An.call(n)}catch{}break;case Ur:if(Rr(n)&&He)try{return He.call(n)}catch{}break;case jr:if(Nr(n)&&Je)try{return Je.call(n)}catch{}break}if(Symbol.toStringTag in n){if(kr(n))try{return Dn.call(n)}catch{}else if(Ir(n))try{return Sn.call(n)}catch{}else if(Er(n))try{return An.call(n)}catch{}else if(Rr(n)&&He)try{return He.call(n)}catch{}else if(Nr(n)&&Je)try{return Je.call(n)}catch{}}if(typeof n.valueOf=="function"&&n.valueOf!==Object.prototype.valueOf)try{let t=n.valueOf();if(typeof t!="object"||t===null)return t}catch{}return n}var Fo,Mo,Uo,jo,Vo,Lo,vr,Fr,Mr,Ur,jr,Po,Bo,Cr,Or,$o,Ko,qo,Wo,Go,zo,Ho,Jo,Yo,wn,Xo,Sn,Dn,An,He,Je,Zo,ge=E(()=>{"use strict";Fo="[object Date]",Mo="[object RegExp]",Uo="[object Set]",jo="[object Map]",Vo="[object Error]",Lo="[object URLSearchParams]",vr="[object String]",Fr="[object Number]",Mr="[object Boolean]",Ur="[object BigInt]",jr="[object Symbol]",Po=typeof Date=="function"?Date.prototype:void 0,Bo=Object.getPrototypeOf(/./),Cr=typeof Set=="function"?Set.prototype:void 0,Or=typeof Map=="function"?Map.prototype:void 0,$o=typeof URLSearchParams=="function"?URLSearchParams.prototype:void 0,Ko=Object.getPrototypeOf(""),qo=Object.getPrototypeOf(0),Wo=Object.getPrototypeOf(!0),Go=typeof BigInt=="function"?BigInt.prototype:void 0,zo=typeof Symbol=="function"?Symbol.prototype:void 0,Ho=Object.getOwnPropertyDescriptor(Bo,"source")?.get,Jo=Cr?Object.getOwnPropertyDescriptor(Cr,"size")?.get:void 0,Yo=Or?Object.getOwnPropertyDescriptor(Or,"size")?.get:void 0,wn=Po?.valueOf,Xo=$o?.has,Sn=Ko.valueOf,Dn=qo.valueOf,An=Wo.valueOf,He=Go?.valueOf,Je=zo?.valueOf,Zo=Function.prototype.toString.call(Object)});function Z(n,e){return typeof n!="number"?!1:Number.isNaN(n)?e?.allowNaN??e?.allowNonFiniteNumbers??!1:Number.isFinite(n)?!0:e?.allowNonFiniteNumbers??!1}function Br(n){for(let e=1;e<n.length;e++)if(n[e].length!==3)return!1;return!0}function Gr(n,e){if(Qo.test(n))return null;let t=n.trim();if(t==="")return null;t.startsWith("(")&&t.endsWith(")")&&(t="-"+t.slice(1,-1).trim());let r=t[t.length-1];(r==="-"||r==="+")&&t.length>1&&(t=r+t.slice(0,-1).trim()),e||(t=t.replace(es,""));let o=t.includes("."),s=t.includes(",");if(o&&s){let i=t.lastIndexOf("."),a=t.lastIndexOf(","),u=a>i,c=u?".":",",l=u?a:i,f=t.slice(0,l).split(c);return f.length>1&&!Br(f)||f[0].replace($r,"").length>3?null:u?t.replace(Kr,"").replace(Dt,"."):t.replace(Dt,"")}if(s||o){let i=s?",":".",a=t.split(i);if(a.length>2||i===","&&a.length===2&&a[1].length===3){let u=a[0].replace($r,"").length;if(u===0){if(i===","||a.length>2)return null}else return u>3?null:Br(a)?t.replace(s?Dt:Kr,""):null}if(s)return t.replace(Dt,".")}return t}function te(n,{allowNonFiniteNumbers:e=!1,strictNumericString:t=!1,floatScientific:r=!0}={}){if(n==null||typeof n=="symbol")return null;switch(n=oe(n),typeof n){case"number":return Z(n,{allowNonFiniteNumbers:e})?n:null;case"boolean":return n?1:0;case"bigint":{let o=Number(n);return Z(o,{allowNonFiniteNumbers:e})?o:null}case"object":{if(F(n)){let o=n.getTime();return Z(o,{allowNonFiniteNumbers:e})?o:null}return null}case"string":{let o=Gr(n,t);if(o===null)return null;if(e){let a=o.toLowerCase();if(a==="nan"||a==="-nan"||a==="+nan")return NaN;if(a==="infinity"||a==="+infinity")return 1/0;if(a==="-infinity")return-1/0}if(Wr.test(o)&&!r||!qr.test(o))return null;let i=Number(o);return Z(i,{allowNonFiniteNumbers:e})?i:null}default:return null}}function zr({locale:n="en-US",accountingNegatives:e=!1,fallback:t="NaN",formatNonFinite:r=!1,...o}={}){o.useGrouping===void 0&&(o.useGrouping=!1),o.maximumFractionDigits===void 0&&o.maximumSignificantDigits===void 0&&(o.maximumFractionDigits=20),e&&(o.currencySign="accounting",o.style===void 0&&(o.style="decimal"));let s=new Intl.NumberFormat(n,o);return i=>{if(typeof i=="bigint")return e&&i<0n?`(${s.format(-i)})`:s.format(i);let a=te(i,{allowNonFiniteNumbers:!0});return a===null||Number.isNaN(a)?t:Number.isFinite(a)?e&&a<0?`(${s.format(Math.abs(a))})`:s.format(a):r?t:e&&a===-1/0?`(${s.format(1/0)})`:String(a)}}function Tn(n,{floatPrecision:e="Float64",allowNonFiniteNumbers:t=!0,floatScientific:r=!0,strictNumericString:o=!1}={}){let s=te(n,{allowNonFiniteNumbers:t,floatScientific:r,strictNumericString:o});return s===null||(e==="Float32"&&(s=Math.fround(s)),!Z(s,{allowNonFiniteNumbers:t}))?null:s}function me(n,{range:e="Int32",coerce:t="truncate"}={}){let r=te(n);if(r===null)return null;switch(t){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 o=typeof e=="string"?ts[e]:e;return ue(r,{min:o.min,max:o.max})}function Me(n,{range:e="Int64",truncate:t=!1}={}){if(n==null||typeof n=="symbol")return null;n=oe(n);let r=null;if(typeof n=="bigint")r=n;else if(typeof n=="string"){let s=Gr(n,!1);if(s===null||!qr.test(s))return null;if(Wr.test(s)){let i=Number(s);if(!Number.isFinite(i)||!t&&!Number.isInteger(i))return null;r=BigInt(Math.trunc(i))}else{let i=s.indexOf(".");if(i!==-1){if(!t&&/[^0]/.test(s.slice(i+1)))return null;s=s.slice(0,i)}try{r=BigInt(s)}catch{return null}}}else{let s=te(n);if(s===null||!t&&!Number.isInteger(s))return null;r=BigInt(Math.trunc(s))}let o=typeof e=="string"?ns[e]:e;return ue(r,{min:o.min,max:o.max})}function rs(n,e){let t=n-e;if(t<0||e<0)return null;if(t>15)return Number.MAX_SAFE_INTEGER;let r=Math.min(e,16),o=Math.pow(10,t)-Math.pow(10,-r);return o>0?o:null}function Cn(n,e){let t=n.toString();if(t.includes("e")){let r=Math.pow(10,e);return Math.round(n*r)/r}return+(Math.round(+(t+"e"+e))+"e"+-e)}function At(n,{precision:e,scale:t}={}){let r=te(n);if(r===null)return null;let o=r;if(t!==void 0&&(o=Cn(o,t)),e!==void 0){let i=rs(e,t??0);i!==null&&(o=ue(o,{min:-i,max:i}))}return o}function ue(n,e){if(!e)return n;let{min:t=null,max:r=null,safe:o=!0}=e;if(t!==null&&r!==null&&t>r)return t;let s=n;if(o&&typeof s=="number"){if(Number.isNaN(s))return t!==null?t:r!==null?r:n;if(s===1/0)return r!==null?r:n;if(s===-1/0)return t!==null?t:n}return t!==null&&s<t?t:r!==null&&s>r?r:s}function Hr(n){let e=n|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}}var qr,Qo,es,Wr,$r,Kr,Dt,ts,ns,Ye=E(()=>{"use strict";ge();qr=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,Qo=/0[xobXOB]/,es=/[\s_]/g,Wr=/[eE]/;$r=/^[+-]/,Kr=/\./g,Dt=/,/g;ts={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}};ns={Int64:{min:-9223372036854775808n,max:9223372036854775807n},UInt64:{min:0n,max:18446744073709551615n}}});function U(n){if(!ArrayBuffer.isView(n))return!1;if(Jr)return Jr.call(n)!==void 0;let e=Object.prototype.toString.call(n);return e!=="[object DataView]"&&e.endsWith("Array]")}function C(n){return Array.isArray(n)||U(n)}function Xe(n){return n==null?[]:Array.isArray(n)?[...n]:U(n)?Array.from(n):[n]}function Ue(n){let e=Xe(n),t=e.length,r=new Array(t);for(let o=0;o<t;o++)r[o]=String(e[o]);return r}function W(n,e,{mode:t="every",allowNulls:r=!1,allowEmpty:o=!0}={}){if(!C(n))return!1;let s=n.length;if(s===0)return o?t==="every":!1;let i=n,a;if(typeof e=="function")a=Vr(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=F;break;case"object":a=P;break;case"plainObject":a=Ce;break;case"number":a=Z;break;default:a=u=>typeof u===e;break}if(r){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 Ze(n,{descending:e=!1,nullsLast:t=!0}={}){if(!C(n))return[];let r=n,o=r.length;if(o===0)return[];if(U(n)){let f=r.slice().sort();return e&&f.reverse(),Array.from(f)}let s=[],i=[],a=!0,u=!0,c=!0;for(let f=0;f<o;f++){let m=r[f];if(m==null)i.push(m);else if(s.push(m),c){let h=typeof m;h!=="number"&&(a=!1),h!=="string"&&(u=!1),!a&&!u&&(c=!1)}}return s.length>1&&(a?s.sort(e?(f,m)=>m-f:(f,m)=>f-m):u?s.sort(e?(f,m)=>m.localeCompare(f):(f,m)=>f.localeCompare(m)):s.sort((f,m)=>{let h=typeof f,p=typeof m;if(h!==p){let y=h<p?-1:1;return e?-y:y}return f<m?e?1:-1:f>m?e?-1:1:0})),i.length===0?s:t?s.concat(i):i.concat(s)}function $(n){if(!C(n))return{...Yr};let e=n.length;if(e===0)return{...Yr};let t=null,r=null,o=0,s=0,i=0,a=0,u=0,c=0;for(let f=0;f<e;f++){let m=n[f];if(m==null||typeof m=="number"&&!Z(m,{allowNonFiniteNumbers:!0,allowNaN:!1})){s++;continue}(t==null||m<t)&&(t=m),(r==null||m>r)&&(r=m);let h=te(m);if(h!==null){let p=i+h;Math.abs(i)>=Math.abs(h)?a+=i-p+h:a+=h-p+i,i=p,o++;let y=h-u;u+=y/o;let d=h-u;c+=y*d}}let l=o>1?c/(o-1):0;return{sum:o>0?i+a:null,count:o,min:t,max:r,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 Oe(n,{strict:e=!1,keySelector:t}={}){let r=Array.from(n),o=new Map;if(e){let i=t??q,a=new Map,u=r.length;for(let l=0;l<u;l++){let f=r[l],m=i(f),h=a.get(m);h===void 0?a.set(m,{val:f,count:1}):h.count++}let c=[];for(let l of a.values())c.push(l.val);for(let l=0;l<u;l++){let f=r[l],m=i(f),h=a.get(m);o.set(f,h.count)}return{values:c,count:c.length,frequencies:o}}let s=r.length;for(let i=0;i<s;i++){let a=r[i];o.set(a,(o.get(a)??0)+1)}return{values:Array.from(o.keys()),count:o.size,frequencies:o}}function Xr(n,{step:e=1,offsetStart:t=0,offsetEnd:r,maxItemsGathered:o,null_on_oob:s=!0}={}){if(n==null)return null;if(o!==void 0&&o<=0)return[];if(e===0)throw new Error("Step size step cannot be zero");let i=n.length;if(i===0?t!==0:t>=i||t<-i){if(!s)throw new Error(`Start offset ${t} is out of bounds for array of length ${i}`);return null}let u=t<0?i+t:t,c=r!==void 0?r<0?i+r:r:e>0?i:-1,l=[];if(e>0)for(let f=u;f<c&&f<i&&!(f>=0&&(l.push(n[f]),o!==void 0&&l.length>=o));f+=e);else for(let f=u;f>c&&f>=0&&!(f<i&&(l.push(n[f]),o!==void 0&&l.length>=o));f+=e);return l}function Zr(n,e=",",{ignoreNulls:t=!1,nullValue:r="",prefix:o="",suffix:s="",limit:i,truncationMarker:a="...",valueFormatter:u}={}){let c=n.length,l=[],f=i!==void 0?Math.max(0,i):c,m=!1;for(let h=0;h<c;h++){if(l.length>=f){m=!0;break}let p=n[h];p!=null?l.push(u?u(p,h):String(p)):t||l.push(r)}return o+l.join(e)+(m?a:"")+s}function Ie(n,e,t={}){let r=n.length,{mode:o="cumulative",step:s=1,coerce:i=y=>y,condition:a,reverse:u=!1,startIndex:c=u?r-1:0,endIndex:l=u?-1:r}=t,f=u?-1:1,m=c,h=l,p=(y,d)=>{(!a||a(n[y],y,n))&&(n[y]=i(d))};if(o==="constant"){let y=i(e);for(let d=m;u?d>h:d<h;d+=f)p(d,y)}else if(o==="independent")if(typeof s=="function"){let y=0;for(let d=m;u?d>h:d<h;d+=f)p(d,s({index:y,initialValue:e,originalValue:n[d],absoluteIndex:d,targetArray:n})),y++}else for(let y=m;u?y>h:y<h;y+=f)p(y,e+y*s);else{let y=e,d=!0,g=0;for(let b=m;u?b>h:b<h;b+=f)d?(p(b,y),d=!1):(typeof s=="function"?y=s({prev:y,index:g,originalValue:n[b],absoluteIndex:b,targetArray:n}):y=y+s,p(b,y)),g++}}function Qr(n){let e=n.length,t=0,r=new Float64Array(e);for(let s=0;s<e;s++){let i=n[s],a=te(i,{allowNonFiniteNumbers:!0});a!==null&&Z(a,{allowNonFiniteNumbers:!0,allowNaN:!1})&&(r[t++]=a)}if(t===0)return null;let o=r.subarray(0,t);return o.sort(),o}function je(n){let e=Qr(n);if(!e)return null;let t=e.length,r=Math.floor(t/2);return t%2!==0?e[r]:(e[r-1]+e[r])/2}function Tt(n,e){if(e<0||e>1)return null;let t=Qr(n);if(!t)return null;let r=t.length,o=e*(r-1),s=Math.floor(o),i=Math.ceil(o);return s===i?t[s]:t[s]+(o-s)*(t[i]-t[s])}function Ct(n){if(!C(n)||n.length===0)return null;let e=new Map,t=n.length,r=0,o=[];for(let s=0;s<t;s++){let i=n[s];if(i==null||typeof i=="number"&&!Z(i,{allowNonFiniteNumbers:!0,allowNaN:!1}))continue;let a=(e.get(i)??0)+1;e.set(i,a),a>r?(r=a,o=[i]):a===r&&o.push(i)}return o.length===0?null:Ze(o)}var Jr,Yr,Qe=E(()=>{"use strict";ge();Ye();Ot();Jr=(()=>{try{let n=new Uint8Array(0),e=Object.getPrototypeOf(n),t=Object.getPrototypeOf(e),r=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag)?.get;return r&&r.call(n)==="Uint8Array"?r:void 0}catch{return}})();Yr={sum:null,count:0,min:null,max:null,mean:null,variance:0,std:0,nullCount:0,len:0,hasNulls:!1,isNumeric:!1}});function eo(n){let e=oe(n);return typeof e=="string"?e.trim().length===0:!1}function It(n){let e=oe(n);if(e==null)return"";let t=String(e);return typeof RegExp.escape=="function"?RegExp.escape(t):t.replace(os,"\\$&")}function Ve(n,e=null,t={}){if(n==null)return t.returnStringOnNull?"":null;let{mode:r="both",returnStringOnNull:o=!1,maxScanStart:s=1,maxScanEnd:i=1,maxMatchesStart:a=1,maxMatchesEnd:u=1,trimFirst:c=!1,stringOptions:l}=t,{literal:f=!1,caseInsensitive:m=!1}=l??{},h=(w,A="both")=>A==="start"?w.trimStart():A==="end"?w.trimEnd():w.trim(),p=n;if(c&&e!=null&&(p=h(n,r)),e==null){let w=h(p,r);return o||w!==""?w:null}let y=de(e)?w=>{try{e.lastIndex=0}catch{}return e.test(w)}:(()=>{let w=new Set(m?e.toLowerCase():e);return A=>w.has(m?A.toLowerCase():A)})(),d=p.length;if(s===1&&a===1&&i===1&&u===1&&!f){let w=0,A=d;if(r==="both"||r==="start")for(;w<d&&y(p[w]);)w++;if(r==="both"||r==="end")for(;A>w&&y(p[A-1]);)A--;let M=w===0&&A===d?p:p.substring(w,A);return o||M!==""?M:null}let b=new Uint8Array(d),D=(w,A,M)=>{if(d===0||M===0)return;let fe=w?0:d-1,ie=w?d:-1,I=w?1:-1,k=!1,L=0,K=0;for(let H=fe;H!==ie;H+=I)if(y(p[H])){if(!k){if(A!==null&&A>=0&&K>=A||M!==null&&M>=0&&L>=M)break;k=!0,L++}b[H]=1}else if(k=!1,K++,A!==null&&A>=0&&K>=A)break},_=(w,A,M,fe,ie)=>{if(d===0||ie===0||A===0)return;let I=M?0:d-1,k=0,L=0,K=m?p.toLowerCase():p;for(;I>=0&&I<d&&!(ie!==null&&ie>=0&&k>=ie);){let H=M?I:I-A+1;if(!M&&H<0)break;let J=M?K.indexOf(w,H):K.lastIndexOf(w,H);if(J===-1)break;let re=M?J-I:I-(J+A-1);if(L+=re,fe!==null&&fe>=0&&L>=fe)break;for(let ee=0;ee<A;ee++)b[J+ee]=1;k++,I=M?J+A:J-1}};if(r==="both"||r==="start")if(f&&typeof e=="string"){let w=m?e.toLowerCase():e;_(w,e.length,!0,s,a)}else D(!0,s,a);if(r==="both"||r==="end")if(f&&typeof e=="string"){let w=m?e.toLowerCase():e;_(w,e.length,!1,i,u)}else D(!1,i,u);let S="";for(let w=0;w<d;w++)b[w]===0&&(S+=p[w]);return o||S!==""?S:null}function q(n,{depth:e=0,maxDepth:t=50}={}){if(e>t)return"v:circular";if(n===null)return"v:null";if(n===void 0)return"v:undefined";if(F(n))return`d:${n.getTime()}`;if(U(n))return`u:${n.constructor.name}:${n.toString()}`;if(Array.isArray(n)){let r=n.length,o=new Array(r),s={depth:e+1,maxDepth:t};for(let i=0;i<r;i++)o[i]=q(n[i],s);return`a:[${o.join(",")}]`}if(wt(n)){let r=Array.from(n),o=r.length,s=new Array(o),i={depth:e+1,maxDepth:t};for(let a=0;a<o;a++)s[a]=q(r[a],i);return s.sort(),`set:[${s.join(",")}]`}if(St(n)){let r=Array.from(n.keys()),o=r.length,s=new Array(o),i={depth:e+1,maxDepth:t};for(let a=0;a<o;a++){let u=r[a];s[a]=`${q(u,i)}:${q(n.get(u),i)}`}return s.sort(),`map:{${s.join(",")}}`}if(typeof n=="object"&&typeof n.toJSON=="function"){let r=n.toJSON();if(r!==n)return`j:${q(r,{depth:e+1,maxDepth:t})}`}if(Ce(n)){let r=Object.keys(n).sort(),o=r.length,s=new Array(o),i={depth:e+1,maxDepth:t};for(let a=0;a<o;a++){let u=r[a];s[a]=`${u}:${q(n[u],i)}`}return`o:{${s.join(",")}}`}return de(n)?`r:${n.toString()}`:typeof n=="function"?`f:${n.toString()}`:typeof n=="string"?`s:${n}`:typeof n=="symbol"?`y:${n.toString()}`:`${typeof n}:${n}`}var os,Ot=E(()=>{"use strict";ge();Qe();os=/[-\/\\^$*+?.()|\[\]{}]/g});var On,In,kn=E(()=>{"use strict";On=1000n,In=1000000n});function as(n){let e=to.get(n);return e||(e=new Intl.DateTimeFormat("en-US",{timeZone:n,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),to.set(n,e)),e}function ls(n,e){let t=`${n}_${e}`,r=no.get(t);return r||(r=new Intl.DateTimeFormat(n,{timeZoneName:"short",timeZone:e}),no.set(t,r)),r}function us(n){let e=ro.get(n);if(e===void 0){try{Intl.DateTimeFormat(void 0,{timeZone:n}),e=!0}catch{e=!1}ro.set(n,e)}return e}function pe(n){let e=!n||n==="local"?Intl.DateTimeFormat().resolvedOptions().timeZone:n;return us(e)?e:"UTC"}function ke(n,e=0,t=1,r=0,o=0,s=0,i=0){let a=new Date(0);return a.setUTCFullYear(n,e,t),a.setUTCHours(r,o,s,i),a}function Et(n,e=0,t=1,r=0,o=0,s=0,i=0){if(n>=100||n<0)return Date.UTC(n,e,t,r,o,s,i);let a=new Date(0);return a.setUTCFullYear(n,e,t),a.setUTCHours(r,o,s,i),a.getTime()}function cs(n,e,t){let r=[0,3,2,5,0,3,5,1,4,6,2,4],o=n;return e<3&&(o-=1),(o+Math.floor(o/4)-Math.floor(o/100)+Math.floor(o/400)+r[e-1]+t)%7}function Rt(n,e){let t=pe(e);if(t.toUpperCase()==="UTC")return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),ms:n.getUTCMilliseconds(),dayOfWeek:n.getUTCDay()};let o=as(t).formatToParts(n),s="0",i="0",a="0",u="0",c="0",l="0",f="0";for(let d=0,g=o.length;d<g;d++){let b=o[d];switch(b.type){case"year":s=b.value;break;case"month":i=b.value;break;case"day":a=b.value;break;case"hour":u=b.value;break;case"minute":c=b.value;break;case"second":l=b.value;break;case"fractionalSecond":f=b.value;break}}let m=parseInt(s,10),h=parseInt(i,10),p=parseInt(a,10),y=cs(m,h,p);return{year:m,month:h,day:p,hour:parseInt(u,10),minute:parseInt(c,10),second:parseInt(l,10),ms:parseInt(f,10),dayOfWeek:y}}function Rn(n,e){if(e.toUpperCase()==="UTC")return 0;let t=Rt(n,"UTC"),r=Rt(n,e),o=Et(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.ms),s=Et(r.year,r.month-1,r.day,r.hour,r.minute,r.second,r.ms);return Math.round((s-o)/6e4)}function fs(n,e){let t=pe(e),r=Rn(n,t),o=r>=0?"+":"-",s=Math.abs(r),i=String(Math.floor(s/60)).padStart(2,"0"),a=String(s%60).padStart(2,"0");return`${o}${i}${a}`}function Q(n,e){let t=oe(n);if(t==null)return null;let r=null;if(F(t))r=t;else if(typeof t=="number"||typeof t=="bigint")r=new Date(ms(t));else if(typeof t=="string"){if(eo(t))return null;r=new Date(t)}if(!r||!F(r))return null;if(e?.dateOnly){let o=typeof t=="string",s=o&&is.test(t),i=o&&!s&&!oo.test(t)?"local":"UTC",a=Rt(r,i);return ke(a.year,a.month-1,a.day)}return r}function vt(n){let e=oe(n);if(e==null)return null;let t=null;if(typeof e=="string"){let o=e.trim();if(ss.test(o)){let s=oo.test(o);t=Q(`1970-01-01T${o}${s?"":"Z"}`)}}let r=t||Q(e);return r?Ee(r,"%H:%M:%S.%ms"):null}function so(n,e="ms"){let t=n.getTime();switch(e){case"s":return Math.floor(t/1e3);case"ms":return t;case"us":return BigInt(t)*On;case"ns":return BigInt(t)*In}}function ms(n){if(typeof n=="bigint"){let t=n<0n?-n:n;return t<=30000000000n?Number(n)*1e3:t<=30000000000000n?Number(n):t<=30000000000000000n?Number(n/On):Number(n/In)}let e=Math.abs(n);return e<=3e10?n*1e3:e<=3e13?n:e<=3e16?Math.floor(n/1e3):Math.floor(n/1e6)}function io(n){if(!F(n))return null;let e=n.getUTCFullYear();return Math.floor((e-1)/100)+1}function ao(n){if(!F(n))return null;let e=ke(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let r=ke(e.getUTCFullYear(),0,1),o=Math.round((e.getTime()-r.getTime())/864e5);return Math.floor(o/7)+1}function lo(n){if(!F(n))return null;let e=n.getUTCFullYear();return Math.floor((e-1)/1e3)+1}function vn(n,e,t=1){return F(n)?ke(n.getUTCFullYear(),n.getUTCMonth()+e,t):null}function Fn(n){if(!F(n))return null;let e=Et(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()),t=Et(n.getUTCFullYear(),0,1);return Math.floor((e-t)/864e5)+1}function uo(n){return F(n)?Math.floor(n.getUTCMonth()/3)+1:null}function Mn(n){let e;if(F(n))e=n.getUTCFullYear();else if(Z(n))e=n;else return!1;return e%4===0&&e%100!==0||e%400===0}function co(n){return n.replace(/%[FTRD]/g,e=>hs[e]||e)}function En(n,e){return new Date(n.getTime()-e*60*1e3)}function ys(n){let e=n[0]==="+"?1:-1,t=parseInt(n.slice(1,3),10)||0,r=parseInt(n.slice(3,5),10)||0;return e*(t*60+r)}function Ee(n,e,t,r="UTC"){if(!F(n)||typeof e!="string")return"";let o=t&&t.trim()||Intl.DateTimeFormat().resolvedOptions().locale||"en-US",s=co(e),i=null,a=()=>i??=Rt(n,r);return s.replace(kt,(u,c)=>{if(c==="%")return"%";let l=Un[c];return l?l.format(n,o,r,a()):u})}function fo(n,e,t=!0,r="UTC"){if(typeof n!="string"||typeof e!="string")return null;let o=co(e),s=[],i="",a=0;kt.lastIndex=0;let u;for(;(u=kt.exec(o))!==null;){let y=o.slice(a,u.index);i+=It(y);let d=u[1];if(d==="%")i+="\\%";else{let g=Un[d];g&&g.parseRegex?(s.push(g),i+=`(${g.parseRegex})`):i+=It(u[0])}a=kt.lastIndex}i+=It(o.slice(a));let c=new RegExp("^\\s*"+i+"\\s*$"),l=n.match(c);if(!l)return t?null:Q(n);let f={year:1970,month:1,day:1,hour:0,minute:0,second:0,ms:0,offset:null},m=null,h=!1;for(let y=0;y<s.length;y++){let d=l[y+1],g=s[y],b=g.parseNormalize?g.parseNormalize(d):parseInt(d,10);g.key==="j"&&(h=!0),g.parseField==="ampm"?m=b:g.parseField==="offset"?f.offset=b:g.parseField&&(f[g.parseField]=b)}if(m&&(m==="PM"&&f.hour<12&&(f.hour+=12),m==="AM"&&f.hour===12&&(f.hour=0)),h){let y=Mn(f.year)?366:365;if(f.day<1||f.day>y)return null;let d=ke(f.year,0,1);d.setUTCDate(f.day),f.month=d.getUTCMonth()+1,f.day=d.getUTCDate()}let p=ke(f.year,f.month-1,f.day,f.hour,f.minute,f.second,f.ms);if(!F(p)||p.getUTCFullYear()!==f.year||p.getUTCMonth()+1!==f.month||p.getUTCDate()!==f.day||p.getUTCHours()!==f.hour||p.getUTCMinutes()!==f.minute||p.getUTCSeconds()!==f.second||p.getUTCMilliseconds()!==f.ms)return null;if(f.offset)p=En(p,ys(f.offset));else if(r.toUpperCase()!=="UTC"){let y=pe(r),d=Rn(p,y);p=En(p,d);let g=Rn(p,y);g!==d&&(p=En(p,g-d))}return F(p)?p:null}var ss,oo,is,to,no,ro,Un,ps,kt,hs,jn=E(()=>{"use strict";Ot();ge();Ye();kn();ss=/^\d{2}:\d{2}/,oo=/(?:Z|[+-]\d{2}(?::?\d{2})?)$/i,is=/^\d{4}-\d{2}-\d{2}$/,to=new Map;no=new Map;ro=new Map;Un={Y:{key:"Y",format:(n,e,t,r)=>{let o=r.year;return o>=0?String(o).padStart(4,"0"):"-"+String(Math.abs(o)).padStart(4,"0")},parseRegex:"\\d{4}",parseField:"year"},y:{key:"y",format:(n,e,t,r)=>String(Math.abs(r.year)%100).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"year",parseNormalize:n=>{let e=parseInt(n,10);return e+(e>=69?1900:2e3)}},m:{key:"m",format:(n,e,t,r)=>String(r.month).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"month"},d:{key:"d",format:(n,e,t,r)=>String(r.day).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"day"},e:{key:"e",format:(n,e,t,r)=>String(r.day).padStart(2," "),parseRegex:"\\s?\\d{1,2}",parseField:"day"},H:{key:"H",format:(n,e,t,r)=>String(r.hour).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"hour"},I:{key:"I",format:(n,e,t,r)=>String(r.hour%12||12).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"hour"},p:{key:"p",format:(n,e,t,r)=>r.hour>=12?"PM":"AM",parseRegex:"AM|PM|am|pm",parseField:"ampm",parseNormalize:n=>n.toUpperCase()},M:{key:"M",format:(n,e,t,r)=>String(r.minute).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"minute"},S:{key:"S",format:(n,e,t,r)=>String(r.second).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"second"},A:{key:"A",format:(n,e,t)=>n.toLocaleDateString(e,{weekday:"long",timeZone:pe(t)})},a:{key:"a",format:(n,e,t)=>n.toLocaleDateString(e,{weekday:"short",timeZone:pe(t)})},B:{key:"B",format:(n,e,t)=>n.toLocaleDateString(e,{month:"long",timeZone:pe(t)})},b:{key:"b",format:(n,e,t)=>n.toLocaleDateString(e,{month:"short",timeZone:pe(t)})},h:{key:"h",format:(n,e,t)=>n.toLocaleDateString(e,{month:"short",timeZone:pe(t)})},j:{key:"j",format:(n,e,t,r)=>String(Fn(ke(r.year,r.month-1,r.day))??1).padStart(3,"0"),parseRegex:"\\d{3}",parseField:"day",parseNormalize:n=>parseInt(n,10)},u:{key:"u",format:(n,e,t,r)=>String(r.dayOfWeek||7)},w:{key:"w",format:(n,e,t,r)=>String(r.dayOfWeek)},Z:{key:"Z",format:(n,e,t)=>{let r=pe(t);if(r.toUpperCase()==="UTC")return"UTC";let o=ls(e,r).formatToParts(n);for(let s=0,i=o.length;s<i;s++)if(o[s].type==="timeZoneName")return o[s].value;return"UTC"}},z:{key:"z",format:(n,e,t)=>fs(n,t),parseRegex:"[+-]\\d{2}(?::?\\d{2})?",parseField:"offset",parseNormalize:n=>n.replace(":","")},ms:{key:"ms",format:(n,e,t,r)=>String(r.ms).padStart(3,"0"),parseRegex:"\\d{3}",parseField:"ms",parseNormalize:n=>parseInt(n,10)},f:{key:"f",format:(n,e,t,r)=>String(r.ms).padStart(3,"0").padEnd(6,"0"),parseRegex:"\\d{1,9}",parseField:"ms",parseNormalize:n=>parseInt(n.padEnd(6,"0").slice(0,3),10)}},ps=Object.keys(Un).concat("%").sort((n,e)=>e.length-n.length),kt=new RegExp("%("+ps.join("|")+")","g"),hs={"%F":"%Y-%m-%d","%T":"%H:%M:%S","%R":"%H:%M","%D":"%m/%d/%y"}});function mo(n,{format:e="json",allowPrimitives:t=!1,trimBeforeParse:r=!1,reviver:o,ndjson:{skipInvalidLines:s=!1,maxLines:i,skipLines:a}={},guard:u,onError:c,fallback:l=et}={}){if(typeof n!="string")return l!==et?l:n;let f=r?n.trim():n;if(f==="")return l!==et?l:n;let m;try{if(e==="ndjson"){let h=[],p=0,y=0,d=0;Vn.lastIndex=0;let g;for(;;){g=Vn.exec(f);let b=g?f.substring(d,g.index):f.substring(d);g&&(d=Vn.lastIndex);let D=b.trim();if(D!==""&&(p++,a===void 0||p>a))if(!t&&!ds(D)){if(!s)throw new Error("NDJSON line is not wrapped and primitives are disallowed")}else try{if(h.push(JSON.parse(D,o)),y++,i!==void 0&&y>=i)break}catch(_){if(!s)throw _}if(!g)break}if(h.length===0)throw new Error("No valid NDJSON lines processed");m=h}else{if(!t&&!gs(f))throw new Error("JSON string is not wrapped and primitives are disallowed");m=JSON.parse(f,o)}}catch(h){return c?.(h),l!==et?l:n}return u&&!u(m)?(c?.(new Error("Parsed value failed guard validation")),l!==et?l:n):m}function tt(n={}){let e=n.bigintStrategy??"string",t=n.handleCircular?new WeakSet:null,o=Array.isArray(n.replacer)?n.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 n.replacer=="function")c=n.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 n.onCustom=="function"){let f=n.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 n.onCircular?n.onCircular.call(this,a,l):"[Circular]";t.add(l)}return typeof l=="bigint"?n.voidBigIntReplacement?c:n.onBigInt?n.onBigInt(l):s(l):U(l)?n.voidTypedArrayReplacement?c:n.onTypedArray?n.onTypedArray(l):Array.from(l):wt(l)?n.voidSetReplacement?c:n.onSet?n.onSet(l):Array.from(l):St(l)?n.voidMapReplacement?c:n.onMap?n.onMap(l):Array.from(l.entries()):de(l)?n.voidRegExpReplacement?c:n.onRegExp?n.onRegExp(l):l.toString():F(l)?n.voidDateReplacement?c:n.onDate?n.onDate(l):n.formatDate?n.formatDate(l):l.toISOString():Pr(l)?n.onError?n.onError(l):{name:l.name,message:l.message,stack:l.stack}:Lr(l)?n.onURLSearchParams?n.onURLSearchParams(l):l.toString():c}}var Vn,et,ds,gs,Ft=E(()=>{"use strict";Qe();ge();Vn=/\r\n|\n|\r/g,et=Symbol("no_fallback"),ds=n=>{let e=n.length;if(e<2)return!1;let t=n[0],r=n[e-1];return t==="{"&&r==="}"||t==="["&&r==="]"},gs=n=>{let e=0,t=n.length;for(;e<t&&/\s/.test(n[e]);)e++;let r=t-1;for(;r>=e&&/\s/.test(n[r]);)r--;if(e>=r)return!1;let o=n[e],s=n[r];return o==="{"&&s==="}"||o==="["&&s==="]"}});var Mt=E(()=>{"use strict"});var Y,Re,nt,be,xe,Le,_e,Pe,Ut=E(()=>{"use strict";Y=class n{matches(e){if(e==null)return!1;if(e instanceof n)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 n)return this instanceof e;try{let t=e();if(t instanceof n)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}},Re=class extends Y{get isNumeric(){return!0}},nt=class extends Re{get isInteger(){return!0}},be=class extends nt{get isSigned(){return!0}},xe=class extends nt{get isUnsigned(){return!0}},Le=class extends Re{get isFloat(){return!0}},_e=class extends Y{get isTemporal(){return!0}},Pe=class extends Y{get isNested(){return!0}}});var jt,Ln,Vt,Pn,Lt,Bn,Pt,ot,Bt,$n,$t,Kn,Kt,qn,qt,Wn,Wt,Gn,Gt,st,rt,zt,it,Ht,Be,Jt,zn,Yt,Hn,Xt,Jn,Zt,Yn,Qt,at,en,Xn,tn,Zn,nn,Qn,rn,er,tr=E(()=>{"use strict";Ut();B();jt=class extends be{name="Int8";coerce(e){return me(e,{range:"Int8"})}equals(e){return e.name==="Int8"}allocate(e){return new Int8Array(e)}},Ln=new jt,Vt=class extends be{name="Int16";coerce(e){return me(e,{range:"Int16"})}equals(e){return e.name==="Int16"}allocate(e){return new Int16Array(e)}},Pn=new Vt,Lt=class extends be{name="Int32";coerce(e){return me(e,{range:"Int32"})}equals(e){return e.name==="Int32"}allocate(e){return new Int32Array(e)}},Bn=new Lt,Pt=class extends be{name="Int64";coerce(e){return Me(e,{truncate:!0})}equals(e){return e.name==="Int64"}allocate(e){return new BigInt64Array(e)}},ot=new Pt,Bt=class extends xe{name="UInt8";coerce(e){return me(e,{range:"UInt8"})}equals(e){return e.name==="UInt8"}allocate(e){return new Uint8Array(e)}},$n=new Bt,$t=class extends xe{name="UInt16";coerce(e){return me(e,{range:"UInt16"})}equals(e){return e.name==="UInt16"}allocate(e){return new Uint16Array(e)}},Kn=new $t,Kt=class extends xe{name="UInt32";coerce(e){return me(e,{range:"UInt32"})}equals(e){return e.name==="UInt32"}allocate(e){return new Uint32Array(e)}},qn=new Kt,qt=class extends xe{name="UInt64";coerce(e){return Me(e,{range:"UInt64"})}equals(e){return e.name==="UInt64"}allocate(e){return new BigUint64Array(e)}},Wn=new qt,Wt=class extends Le{name="Float32";coerce(e){return Tn(e,{floatPrecision:"Float32"})}equals(e){return e.name==="Float32"}allocate(e){return new Float32Array(e)}},Gn=new Wt,Gt=class extends Le{name="Float64";coerce(e){return Tn(e,{floatPrecision:"Float64"})}equals(e){return e.name==="Float64"}allocate(e){return new Float64Array(e)}},st=new Gt,rt=class n extends Re{constructor(t,r){super();this.precision=t;this.scale=r;this.name=t!==void 0&&r!==void 0?`Decimal(${t}, ${r})`:"Decimal"}precision;scale;name;coerce(t){return At(t,{precision:this.precision,scale:this.scale})}equals(t){return t instanceof n&&this.precision===t.precision&&this.scale===t.scale}allocate(t){return new Array(t).fill(null)}},zt=class extends Y{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)}},it=new zt,Ht=class extends Y{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)}},Be=new Ht,Jt=class extends Y{name="Binary";get isBinary(){return!0}coerce(e){return po(e)}equals(e){return e.name==="Binary"}allocate(e){return new Array(e).fill(null)}},zn=new Jt,Yt=class extends Y{name="Null";get isNull(){return!0}coerce(e){return null}equals(e){return e.name==="Null"}allocate(e){return new Array(e).fill(null)}},Hn=new Yt,Xt=class extends Y{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)}},Jn=new Xt,Zt=class extends _e{name="Date";coerce(e){return Q(e,{dateOnly:!0})}equals(e){return e.name==="Date"}allocate(e){return new Array(e).fill(null)}},Yn=new Zt,Qt=class extends _e{name="Datetime";coerce(e){return Q(e)}equals(e){return e.name==="Datetime"}allocate(e){return new Array(e).fill(null)}},at=new Qt,en=class extends _e{name="Time";coerce(e){return vt(e)}equals(e){return e.name==="Time"}allocate(e){return new Array(e).fill(null)}},Xn=new en,tn=class extends _e{name="Duration";coerce(e){return te(e)}equals(e){return e.name==="Duration"}allocate(e){return new Array(e).fill(null)}},Zn=new tn,nn=class n extends Pe{constructor(t){super();this.innerType=t}innerType;name="Array";coerce(t){if(t==null)return null;let r=C(t)?Array.from(t):[t],o=r.length,s=new Array(o);for(let i=0;i<o;i++)s[i]=this.innerType.coerce(r[i]);return s}equals(t){return t instanceof n&&this.innerType.equals(t.innerType)}allocate(t){return new Array(t).fill(null)}},Qn=n=>new nn(n),rn=class n extends Pe{constructor(t){super();this.fields=t}fields;name="Struct";coerce(t){if(!P(t))return null;let r={},o=Object.keys(this.fields),s=o.length;for(let i=0;i<s;i++){let a=o[i],u=this.fields[a];r[a]=u.coerce(t[a])}return r}equals(t){if(!(t instanceof n))return!1;let r=Object.keys(this.fields),o=Object.keys(t.fields);if(r.length!==o.length)return!1;for(let s=0;s<r.length;s++){let i=r[s];if(!this.fields[i].equals(t.fields[i]))return!1}return!0}allocate(t){return new Array(t).fill(null)}},er=n=>new rn(n)});var R,we=E(()=>{"use strict";Ut();tr();tr();Ut();R={Int8:Ln,Int16:Pn,Int32:Bn,Int64:ot,UInt8:$n,UInt16:Kn,UInt32:qn,UInt64:Wn,Float32:Gn,Float64:st,Decimal:(n,e)=>new rt(n,e),Boolean:it,Utf8:Be,Binary:zn,Date:Yn,Datetime:at,Time:Xn,Duration:Zn,Object:Jn,Null:Hn,Array:Qn,Struct:er}});function bs(n={}){let e=n.nullValue!==void 0?n.nullValue:"",t=zr(n.numericFormatOptions),r=n.replacerOptions||{},o=a=>n.datetimeFormat?Ee(a,n.datetimeFormat):n.dateFormat?Ee(a,n.dateFormat):n.timeFormat?Ee(a,n.timeFormat):a.toISOString(),s=tt({formatDate:o,...r}),i=typeof r.onBigInt=="function";return a=>{if(a==null||typeof a=="symbol"||typeof a=="function")return{str:e,isNumeric:!1};if(typeof a=="bigint"&&!i&&!r.voidBigIntReplacement)return{str:t(a),isNumeric:!0};let u=s.call(null,"",a),c=oe(u);return c==null||typeof c=="symbol"||typeof c=="function"?{str:e,isNumeric:!1}:typeof c=="string"?{str:c,isNumeric:!1}:typeof c=="number"||typeof c=="bigint"?{str:t(c),isNumeric:!0}:typeof c=="boolean"?{str:c?"true":"false",isNumeric:!1}:typeof c=="object"?{str:JSON.stringify(c,tt({formatDate:o,...r})),isNumeric:!1}:{str:String(c),isNumeric:!1}}}function sn(n,e,t={}){let{separator:r=",",quoteChar:o='"',includeHeader:s=!0,lineTerminator:i=`
2
+ `,quoteStyle:a="necessary",includeBom:u=!1,onRow:c,...l}=t,f=Object.keys(n),m=f.length,h=[],p=!0,y=bs(l),d=(b,D=!1)=>{let _,S=!1;if(D)_=String(b);else{let A=y(b);_=A.str,S=A.isNumeric}if(a==="never")return _;if(a==="always"){let A=_.split(o).join(o+o);return o+A+o}if(a==="non_numeric"&&!S&&b!=null){let A=_.split(o).join(o+o);return o+A+o}if(_.includes(r)||_.includes(o)||_.includes(`
3
+ `)||_.includes("\r")){let A=_.split(o).join(o+o);return o+A+o}return _},g=b=>{if(p){let D=u?"\uFEFF"+b:b;c?c(D):h.push(D),p=!1}else c?c(i+b):h.push(b)};if(s){let b=new Array(m);for(let D=0;D<m;D++)b[D]=d(f[D],!0);g(b.join(r))}for(let b=0;b<e;b++){let D=new Array(m);for(let _=0;_<m;_++)D[_]=d(n[f[_]][b],!1);g(D.join(r))}return c?u?"\uFEFF":"":h.join(i)}function yo(n,e={}){let t=e.separator||",",r=e.quoteChar||'"',o=n;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 h=o[m];if(u)c=!0,l=!1,h===r?m+1<f&&o[m+1]===r?(a+=r,m++):u=!1:a+=h;else if(h===r)c=!0,l=!1,u=!0;else if(h===t)i.push(a),a="",l=!0;else{let p=!1;h==="\r"?(p=!0,m+1<f&&o[m+1]===`
4
+ `&&m++):h===`
5
+ `&&(p=!0),p?(c||i.length>0||a!==""||l)&&(i.push(a),s.push(i),i=[],a="",c=!1,l=!1):(c=!0,l=!1,a+=h)}}return(c||i.length>0||a!==""||l)&&(i.push(a),s.push(i)),s}function go(n,e={}){let t=new Set(e.nullValues??["","NA","null","NaN"]),r=n.length,o=!0,s=!0,i=!0,a=!0,u=!1;for(let l=0;l<r;l++){let f=n[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&&Me(f,{truncate:!1})===null&&(i=!1),s&&te(f,{allowNonFiniteNumbers:!0})===null&&(s=!1),a&&Q(f)===null&&(a=!1),!o&&!s&&!i&&!a)break}}let c=new Array(r);if(!u||!o&&!s&&!i&&!a){for(let l=0;l<r;l++){let f=n[l];c[l]=t.has(f.trim())?null:f}return{type:Be,values:c}}if(o){for(let l=0;l<r;l++){let f=n[l].trim();if(t.has(f))c[l]=null;else{let m=f.toLowerCase();c[l]=m==="true"||m==="1"}}return{type:it,values:c}}if(i){for(let l=0;l<r;l++){let f=n[l].trim();c[l]=t.has(f)?null:Me(f,{truncate:!1})}return{type:ot,values:c}}if(s){for(let l=0;l<r;l++){let f=n[l].trim();c[l]=t.has(f)?null:te(f,{allowNonFiniteNumbers:!0})}return{type:st,values:c}}if(a){for(let l=0;l<r;l++){let f=n[l].trim();c[l]=t.has(f)?null:Q(f)}return{type:at,values:c}}return{type:Be,values:c}}var bo=E(()=>{"use strict";jn();Ft();Ye();Mt();we();ge()});function xs(n){return n==null?!1:typeof n=="string"||U(n)?!0:Array.isArray(n)}function po(n){return xs(n)?Object.prototype.toString.call(n)==="[object Uint8Array]"?n:typeof n=="string"?new TextEncoder().encode(n):U(n)?new Uint8Array(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)):new Uint8Array(n):null}var xo=E(()=>{"use strict";Qe()});var B=E(()=>{"use strict";ge();Ye();jn();Qe();Ot();Ft();bo();xo()});function X(n,e,t,r=""){if(!(n in e))throw new he(n,`${t} "${n}" does not exist${r}`)}function an(n,e){let t=Object.keys(n),r=t.length,o=e;for(let s=0;s<r;s++){let i=t[s],a=n[i],u=C(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 _o=E(()=>{"use strict";se();B()});var Ne,j,he,Ke,Se,z,se=E(()=>{"use strict";_o();Ne=class extends Error{constructor(e){super(e),this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},j=class extends Ne{},he=class extends j{constructor(e,t){super(t||`Column "${e}" does not exist in the DataFrame.`)}},Ke=class extends Ne{},Se=class extends Ne{},z=class extends Ne{}});var x,N,ne=E(()=>{"use strict";ae();se();x=(n,e)=>{let t=n.constructor,r=n.colNames||n.colName||"",o=new t(r);return Object.assign(o,n),o.ops=e?[...n.ops,e]:[...n.ops],o},N=class n{ops=[];outputName="";isLiteral;literalValue;aggFn=null;groupingOpsIndex;partitionOpsIndex;partitionBy=null;evaluateWindow;_resolve(e,t,r){return e instanceof n?e.isLiteral&&e.ops.length===1?e.literalValue:e.evaluate(t,r):e}alias(e){let t=x(this);return t.outputName=e,t}cast(e){return x(this,t=>{let r=t.length,o=new Array(r);for(let s=0;s<r;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 r=this.colName;if(r&&r!=="*"&&!r.startsWith("*")&&!(r in e))throw new he(r);return r&&r!=="*"?e[r]||new Array(t).fill(null):new Array(t).fill(null)}evaluate(e,t){let r=this._getInitialValue(e,t),o=this.ops,s=o.length;for(let i=0;i<s;i++)r=o[i](r,e);return r}evaluatePre(e,t,r){let o=this._getInitialValue(t,r),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,r){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,r);return i}}});function _s(n,e,t){let r=new Map,o=t.length,s=new Array(o);for(let i=0;i<o;i++){let a=t[i];typeof a=="string"?(X(a,n,"Partition key"," in the DataFrame."),s[i]=n[a]):s[i]=a.evaluate(n,e)}if(o===1){let i=s[0];for(let a=0;a<e;a++){let u=i[a],c=u==null?"":q(u),l=r.get(c);l===void 0&&(l=[],r.set(c,l)),l.push(a)}return r}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?"":q(f)}let u=a.join("\0"),c=r.get(u);c===void 0&&(c=[],r.set(u,c)),c.push(i)}return r}function nr(n,e,t){let r=new Array(t);if(t===0)return r;let o=n.partitionBy||[],s=_s(e,t,o),i=n.evaluatePre(n.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(n.evaluateWindow){for(let l=0;l<u;l++)r[a[l]]=n.evaluateWindow(c,a,l);continue}if(n.aggFn){let l=n.aggFn(c);for(let f=0;f<u;f++)r[a[f]]=l;continue}for(let l=0;l<u;l++)r[a[l]]=i[a[l]]}return n.evaluatePost(n.partitionOpsIndex,r,e)}function rr(n){if(!Array.isArray(n)||n.length===0)return{columns:{},height:0};let e=n.length,t=new Set;for(let s=0;s<e;s++){let i=n[s];if(P(i)){let a=Object.keys(i);for(let u=0;u<a.length;u++)t.add(a[u])}}let r=Array.from(t),o={};for(let s=0;s<r.length;s++)o[r[s]]=new Array(e);for(let s=0;s<e;s++){let i=n[s]||{};for(let a=0;a<r.length;a++){let u=r[a],c=i[u];o[u][s]=c===void 0?null:c}}return{columns:o,height:e}}function or(n,e){let t=Object.keys(n),r=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=n[a][o];s[a]=u===void 0?null:u}r[o]=s}return r}function ws(n,e,t){let r={};for(let o=0;o<t.length;o++){let s=t[o],i=n[s][e];r[s]=i===void 0?null:i}return r}function ye(n){if(n.length===0)return R.Utf8;let e=!0,t=!0,r=!0,o=!0,s=!0,i=!0,a=!0,u=!0,c=!1,l=!1,f=[];for(let m=0;m<n.length;m++){let h=n[m];if(h!=null){if(l=!0,h instanceof Uint8Array||(a=!1),!C(h)||h instanceof Uint8Array)i=!1;else{let p=h,y=p.length;for(let d=0;d<y;d++)f.push(p[d])}F(h)&&(c=!0),typeof h!="boolean"&&(e=!1),typeof h!="bigint"&&(o=!1),typeof h!="number"?(r=!1,t=!1):Number.isInteger(h)||(t=!1),!F(h)&&(typeof h!="string"||isNaN(Date.parse(h)))&&(s=!1),(!P(h)||h instanceof Uint8Array)&&(u=!1)}}if(!l)return R.Utf8;if(a)return R.Binary;if(i){let m=ye(f);return R.Array(m)}if(e)return R.Boolean;if(o)return R.Int64;if(r&&!t)return R.Float64;if(r&&t){let m=!0;for(let h=0;h<n.length;h++){let p=n[h];if(p!=null&&(p<-2147483648||p>2147483647)){m=!1;break}}return m?R.Int32:R.Float64}return s&&c?R.Datetime:u?R.Object:R.Utf8}function qe(n,e){let t=Object.keys(n),r=t.length,o=e.length,s={};for(let i=0;i<r;i++){let a=t[i],u=n[a],c=U(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 ve(n,e,t){let r=e.length;if(r===1){let s=n[e[0]][t];return s==null?"":q(s)}let o=new Array(r);for(let s=0;s<r;s++){let i=n[e[s]][t];o[s]=i==null?"":q(i)}return o.join("\0")}function De(n,e,t){let r=e.allocate?e.allocate(t):new Array(t);if(U(r)){let s=r;for(let i=0;i<t;i++){let a=e.coerce(n[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(n[c]);return u}s[i]=a}}else for(let s=0;s<t;s++)r[s]=e.coerce(n[s]);return r}function sr(n,e){if(n)if(typeof n=="string"){if(typeof require!="function")throw new Error("File writing is not supported in this environment (missing require('fs')).");require("fs").writeFileSync(n,e,"utf8")}else if(P(n)&&typeof n.write=="function")n.write(e);else throw new TypeError("Invalid file argument. Expected a file path string or a writable stream/object with a write method.")}var lt=E(()=>{"use strict";we();Mt();B();se()});function ut(n,e,t){return n.isWindow?nr(n,e,t):n.evaluate(e,t)}var T,V,Ae=E(()=>{"use strict";B();lt();T=n=>e=>{let t=e.length,r=new Array(t);for(let o=0;o<t;o++){let s=e[o];r[o]=s==null?null:n(s)}return r},V=(n,e,t)=>(r,o)=>{let s=r.length,i=n._resolve(e,o,s),a=new Array(s);if(C(i))for(let u=0;u<s;u++){let c=r[u],l=i[u];a[u]=c==null||l==null?null:t(c,l)}else for(let u=0;u<s;u++){let c=r[u];a[u]=c==null||i==null?null:t(c,i)}return a}});var ct,ir=E(()=>{"use strict";ne();Ae();B();ct=class extends N{abs(){return x(this,T(Math.abs))}acos(){return x(this,T(e=>e<-1||e>1?null:Math.acos(e)))}acosh(){return x(this,T(e=>e<1?null:Math.acosh(e)))}add(e){return x(this,V(this,e,(t,r)=>t+r))}asin(){return x(this,T(e=>e<-1||e>1?null:Math.asin(e)))}asinh(){return x(this,T(Math.asinh))}atan(){return x(this,T(Math.atan))}atan2(e){return x(this,V(this,e,Math.atan2))}atanh(){return x(this,T(e=>e<=-1||e>=1?null:Math.atanh(e)))}cbrt(){return x(this,T(Math.cbrt))}ceil(){return x(this,T(Math.ceil))}clip(e=null,t=null){return x(this,T(r=>ue(r,{min:e,max:t})))}copysign(e){return x(this,V(this,e,(t,r)=>Math.abs(t)*(r>=0?1:-1)))}cos(){return x(this,T(Math.cos))}cosh(){return x(this,T(Math.cosh))}degrees(){return x(this,T(e=>e*(180/Math.PI)))}div(e){return x(this,V(this,e,(t,r)=>r===0?null:t/r))}exp(){return x(this,T(Math.exp))}expm1(){return x(this,T(Math.expm1))}floor(){return x(this,T(Math.floor))}floordiv(e){return x(this,V(this,e,(t,r)=>r===0?null:Math.floor(t/r)))}hypot(e){return x(this,V(this,e,Math.hypot))}log(e=Math.E){return x(this,T(t=>t<=0?null:e===Math.E?Math.log(t):Math.log(t)/Math.log(e)))}log1p(){return x(this,T(e=>e<=-1?null:Math.log1p(e)))}mod(e){return x(this,V(this,e,(t,r)=>r===0?null:t%r))}mul(e){return x(this,V(this,e,(t,r)=>t*r))}negate(){return x(this,T(e=>-e))}pow(e){return x(this,V(this,e,Math.pow))}radians(){return x(this,T(e=>e*(Math.PI/180)))}rand(e,{min:t=0,max:r=1,integer:o=!1}={}){return x(this,s=>{let i=s.length,a=new Float64Array(i),u=e!==void 0?Hr(e):Math.random,c=r-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){return x(this,T(t=>Cn(t,e)))}sign(){return x(this,T(Math.sign))}sin(){return x(this,T(Math.sin))}sinh(){return x(this,T(Math.sinh))}sqrt(){return x(this,T(e=>e<0?null:Math.sqrt(e)))}sub(e){return x(this,V(this,e,(t,r)=>t-r))}tan(){return x(this,T(Math.tan))}tanh(){return x(this,T(Math.tanh))}trunc(){return x(this,T(Math.trunc))}}});var ft,ar=E(()=>{"use strict";ne();Ae();B();ft=class extends N{and(e){return x(this,(t,r)=>{let o=t.length,s=this._resolve(e,r,o),i=C(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,T(e=>!e))}or(e){return x(this,(t,r)=>{let o=t.length,s=this._resolve(e,r,o),i=C(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,r)=>!!t!=!!r))}}});function So(n,e,t,r){let o=n.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=n[a];if(u==null)s[a]=null;else{let c=i[a],l=new Set;if(C(c)){let m=c.length;for(let h=0;h<m;h++)l.add(q(c[h]))}else l.add(q(c));let f=l.has(q(u));s[a]=r?!f:f}}}else{let i=C(t)?t:[],a=new Set,u=i.length;for(let c=0;c<u;c++)a.add(q(i[c]));for(let c=0;c<o;c++){let l=n[c];if(l==null)s[c]=null;else{let f=a.has(q(l));s[c]=r?!f:f}}}return s}function Do(n,e){let{frequencies:t}=Oe(n,{strict:!0}),r=n.length,o=new Array(r);for(let s=0;s<r;s++){let i=t.get(n[s])||0;o[s]=e?i>1:i===1}return o}function Ao(n,e,t){let r=n.length,o=new Array(r);if(C(e))for(let s=0;s<r;s++){let i=n[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<r;s++){let i=n[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 mt,lr=E(()=>{"use strict";ne();Ae();B();mt=class extends N{between(e,t,r="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=C(a),f=C(u);for(let m=0;m<i;m++){let h=o[m],p=l?a[m]:a,y=f?u[m]:u;if(h==null||p==null||y==null)c[m]=null;else{let d=r==="both"||r==="left"?h>=p:h>p,g=r==="both"||r==="right"?h<=y:h<y;c[m]=d&&g}}return c})}eq(e){return x(this,V(this,e,(t,r)=>t===r))}eq_missing(e){return x(this,(t,r)=>{let o=this._resolve(e,r,t.length);return Ao(t,o,!1)})}ge(e){return x(this,V(this,e,(t,r)=>t>=r))}gt(e){return x(this,V(this,e,(t,r)=>t>r))}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:r=1e-8,nans_equal:o=!1}={}){return x(this,(s,i)=>{let a=s.length,u=this._resolve(e,i,a),c=C(u),l=new Array(a);for(let f=0;f<a;f++){let m=s[f],h=c?u[f]:u;if(m==null||h==null)l[f]=null;else if(Z(m)&&Z(h)){let p=Math.abs(m-h),y=Math.max(r*Math.max(Math.abs(m),Math.abs(h)),t);l[f]=p<=y}else Number.isNaN(m)&&Number.isNaN(h)?l[f]=o:l[f]=m===h}return l})}is_duplicated(){return x(this,e=>Do(e,!0))}is_empty({ignoreNulls:e=!1}={}){return x(this,T(t=>typeof t=="string"?t.length===0:C(t)?e?W(t,"nullish",{mode:"every"}):t.length===0:null))}is_finite(){return x(this,T(Number.isFinite))}is_in(e){return x(this,(t,r)=>So(t,r,e,!1))}is_infinite(){return x(this,T(e=>e===1/0||e===-1/0))}is_nan(){return x(this,T(Number.isNaN))}is_not_nan(){return x(this,T(e=>!Number.isNaN(e)))}is_not_null(){return x(this,e=>{let t=e.length,r=new Array(t);for(let o=0;o<t;o++)r[o]=e[o]!=null;return r})}is_null(){return x(this,e=>{let t=e.length,r=new Array(t);for(let o=0;o<t;o++)r[o]=e[o]==null;return r})}is_unique(){return x(this,e=>Do(e,!1))}le(e){return x(this,V(this,e,(t,r)=>t<=r))}lt(e){return x(this,V(this,e,(t,r)=>t<r))}ne(e){return x(this,V(this,e,(t,r)=>t!==r))}ne_missing(e){return x(this,(t,r)=>{let o=this._resolve(e,r,t.length);return Ao(t,o,!0)})}not_in(e){return x(this,(t,r)=>So(t,r,e,!0))}}});var ln,pt,ur=E(()=>{"use strict";ne();Ae();B();ln=class{constructor(e){this.expr=e}expr;_deriveString(e){return x(this.expr,T(t=>e(String(t))))}_patternGuard(e,t){return e==null?x(this.expr,r=>new Array(r.length).fill(null)):t()}concat(e){return x(this.expr,V(this.expr,e,(t,r)=>String(t)+String(r)))}contains(e){return this._patternGuard(e,()=>this._deriveString(t=>de(e)?e.test(t):t.includes(e)))}count_matches(e){return this._patternGuard(e,()=>this._deriveString(t=>{if(de(e)){let r=e.global?e:new RegExp(e.source,e.flags+"g"),o=t.match(r);return o?o.length:0}else{let r=0,o=t.indexOf(e);for(;o!==-1;)r++,o=t.indexOf(e,o+e.length);return r}}))}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(r=>{let o=r.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(r=>r.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(r=>r.replace(e,t)))}replace_all(e,t){return this._patternGuard(e,()=>this._deriveString(r=>r.replaceAll(e,t)))}reverse(){return this._deriveString(e=>e.split("").reverse().join(""))}rpad(e,t=" "){return this._deriveString(r=>r.padEnd(e,t))}slice(e,t){return this._deriveString(r=>{let o=e<0?r.length+e:e,s=t!==void 0?o+t:void 0;return r.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(r=>Ve(r,e,{mode:"both",...t}))}strip_chars_end(e,t){return this._deriveString(r=>Ve(r,e,{mode:"end",...t}))}strip_chars_start(e,t){return this._deriveString(r=>Ve(r,e,{mode:"start",...t}))}strip_prefix(e){return this._deriveString(t=>Ve(t,e,{mode:"start",maxScanStart:1,maxMatchesStart:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strip_suffix(e){return this._deriveString(t=>Ve(t,e,{mode:"end",maxScanEnd:1,maxMatchesEnd:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strptime(e,t=!0){return this._deriveString(r=>fo(r,e,t))}to_date(){return this._deriveString(e=>Q(e,{dateOnly:!0}))}to_datetime(){return this._deriveString(Q)}to_decimal(e,t){return this._deriveString(r=>At(r,{precision:e,scale:t}))}to_integer(){return this._deriveString(e=>me(e))}to_lowercase(){return this.lower()}to_time(){return this._deriveString(vt)}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"))}},pt=class extends N{get str(){return new ln(this)}}});var ht,cr=E(()=>{"use strict";ne();se();B();ht=class extends N{_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=>W(e,t=>!!t,{mode:"every"}))}all_null(){return this._deriveAgg(e=>W(e,"nullish",{mode:"every"}))}any(){return this._deriveAgg(e=>W(e,t=>!!t,{mode:"some"}))}any_null(){return this._deriveAgg(e=>W(e,"nullish",{mode:"some"}))}avg(){return this._deriveAgg(e=>$(e).mean)}count(e={}){return e.includeNulls?this._deriveAgg(t=>t.length):this._deriveAgg(t=>$(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=>$(e).max)}mean(){return this.avg()}median(){return this._deriveAgg(e=>je(e))}min(){return this._deriveAgg(e=>$(e).min)}mode(){return this._deriveAgg(e=>Ct(e))}n_unique(e={}){return this._deriveAgg(t=>Oe(t,e).count)}quantile(e){if(e<0||e>1)throw new Se("Quantile q must be between 0 and 1");return this._deriveAgg(t=>Tt(t,e))}std(){return this._deriveAgg(e=>$(e).std)}sum(){return this._deriveAgg(e=>$(e).sum)}}});function fr(n,e,t={}){if(e==null)return null;let r=t.dense?"_denseRankCache":"_rankCache",o=n[r];if(!o){let s=n;if(t.ignoreNulls){s=[];let u=n.length;for(let c=0;c<u;c++)n[c]!=null&&s.push(n[c])}t.dense&&(s=Array.from(new Set(s)));let i=Ze(s);o=new Map;let a=i.length;for(let u=0;u<a;u++){let c=i[u];o.has(c)||o.set(c,u+1)}n[r]=o}return o.get(e)??null}var yt,mr=E(()=>{"use strict";ne();B();yt=class extends N{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(r,o,s){let i=Math.max(0,s-e+1),a=s+1,u=r.slice(i,a);return t(u)})}_cum(e,t,r,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 h=s[m];h!=null&&(u=r(u,h),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,r)=>t===null||r>t?r:t)}cum_min(e=!1){return this._cum(e,null,(t,r)=>t===null||r<t?r:t)}cum_prod(e=!1){return this._cum(e,1,(t,r)=>t*r,(t,r)=>r?t:null)}cum_sum(e=!1){return this._cum(e,0,(t,r)=>t+r)}dense_rank(){return this._window(function(e,t,r){return fr(e,e[r],{dense:!0})})}lag(e=1,t=null){return this._window(function(r,o,s){let i=t;return s-e>=0&&(i=r[s-e]),i})}lead(e=1,t=null){return this._window(function(r,o,s){let i=t;return s+e<r.length&&(i=r[s+e]),i})}over(e){let t=x(this),r=Array.isArray(e)?e:[e];return t.partitionBy=r,t}rank(){return this._window(function(e,t,r){return fr(e,e[r])})}rolling_max(e){return this._rolling(e,t=>$(t).max)}rolling_mean(e){return this._rolling(e,t=>$(t).mean)}rolling_median(e){return this._rolling(e,t=>je(t))}rolling_min(e){return this._rolling(e,t=>$(t).min)}rolling_quantile(e,t){return this._rolling(t,r=>Tt(r,e))}rolling_rank(e){return this._rolling(e,t=>fr(t,t[t.length-1],{ignoreNulls:!0}))}rolling_std(e){return this._rolling(e,t=>$(t).std)}rolling_sum(e){return this._rolling(e,t=>$(t).sum)}row_number(){let e=this._window(function(t,r,o){return o+1});return e.outputName="row_number",e}}});var un,dt,pr=E(()=>{"use strict";ne();Ae();B();kn();un=class{constructor(e){this.expr=e}expr;_deriveDate(e){return x(this.expr,T(t=>{let r=Q(t);return r?e(r):null}))}_deriveDuration(e){return x(this.expr,T(t=>typeof t=="number"?e(t):null))}century(){return this._deriveDate(io)}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=>so(t,e))}hour(){return this._deriveDate(e=>e.getUTCHours())}is_leap_year(){return this._deriveDate(Mn)}microsecond(){return this._deriveDate(e=>e.getUTCMilliseconds()*1e3)}millennium(){return this._deriveDate(lo)}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=>vn(e,1,0))}month_start(){return this._deriveDate(e=>vn(e,0,1))}nanosecond(){return this._deriveDate(e=>e.getUTCMilliseconds()*1e6)}ordinal_day(){return this._deriveDate(Fn)}quarter(){return this._deriveDate(uo)}second(){return this._deriveDate(e=>e.getUTCSeconds())}strftime(e,t){return this._deriveDate(r=>Ee(r,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/864e5)}total_hours(){return this._deriveDuration(e=>e/36e5)}total_microseconds(){return this._deriveDuration(e=>e*1e3)}total_milliseconds(){return this._deriveDuration(e=>e)}total_minutes(){return this._deriveDuration(e=>e/6e4)}total_nanoseconds(){return this._deriveDuration(e=>e*1e6)}total_seconds(){return this._deriveDuration(e=>e/1e3)}week(){return this._deriveDate(ao)}weekday(){return this._deriveDate(e=>e.getUTCDay()||7)}year(){return this._deriveDate(e=>e.getUTCFullYear())}},dt=class extends N{get dt(){return new un(this)}}});var cn,gt,hr=E(()=>{"use strict";ne();Ae();B();se();ae();cn=class{constructor(e){this.expr=e}expr;_deriveArray(e){return x(this.expr,T(t=>C(t)?e(t):null))}all(){return this._deriveArray(e=>W(e,t=>!!t,{mode:"every"}))}any(){return this._deriveArray(e=>W(e,t=>!!t,{mode:"some"}))}contains(e){return this._deriveArray(t=>t.includes(e))}contains_all(e){return this._deriveArray(t=>W(e,r=>t.includes(r),{mode:"every"}))}contains_any(e){return this._deriveArray(t=>W(e,r=>t.includes(r),{mode:"some"}))}count_matches(e){return this._deriveArray(t=>{let r=0,o=t.length;for(let s=0;s<o;s++)t[s]===e&&r++;return r})}drop_nulls(){return this._deriveArray(e=>{let t=e.length,r=[];for(let o=0;o<t;o++)e[o]!=null&&r.push(e[o]);return r})}explode({empty_as_null:e=!0,keep_nulls:t=!0}={}){return x(this.expr,r=>{let o=r.length,s=0;for(let c=0;c<o;c++){let l=r[c];if(C(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=r[c];if(C(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._deriveArray(r=>{let o=r.length,s=C(e)?e:[e],i=s.length,a=new Array(i);for(let u=0;u<i;u++){let c=s[u],l=r.at(c);if(l===void 0&&!t)throw new Se(`Index ${c} is out of bounds for array of length ${o}`);a[u]=l??null}return a})}gather_every(e={}){return this._deriveArray(t=>Xr(t,e))}get(e,t=!0){return this._deriveArray(r=>{let o=r.at(e);if(o===void 0&&!t)throw new Se(`Index ${e} is out of bounds for array of length ${r.length}`);return o??null})}join(e=",",t={}){return this._deriveArray(r=>Zr(r,e,t))}last(e=!0){return this.get(-1,e)}len(){return this.lengths()}lengths(){return this._deriveArray(e=>e.length)}max(){return this._deriveArray(e=>$(e).max)}mean(){return this._deriveArray(e=>$(e).mean)}median(){return this._deriveArray(e=>je(e))}min(){return this._deriveArray(e=>$(e).min)}mode(){return this._deriveArray(e=>Ct(e))}n_unique(e={}){return this._deriveArray(t=>Oe(t,e).count)}reverse(){return this._deriveArray(e=>e.slice().reverse())}slice(e,t){return this._deriveArray(r=>{let o=r.length,s=e<0?Math.max(0,o+e):e,i=t!==void 0?s+t:o;return r.slice(s,i)})}sort(e){return this._deriveArray(t=>Ze(t,e))}sum(){return this._deriveArray(e=>$(e).sum)}unique(e={}){return this._deriveArray(t=>Oe(t,e).values)}eval(e){return x(this.expr,(t,r)=>{let o=t.length,s=new Array(o);for(let i=0;i<o;i++){let a=t[i];if(!C(a)){s[i]=null;continue}let u=a.length,c={...r,[ze]: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),h=e.aggFn(Array.from(m));s[i]=e.evaluatePost(f,[h],c)}else s[i]=ut(e,c,u)}return s})}},gt=class extends N{get arr(){return new cn(this)}}});var fn,Oo=E(()=>{"use strict";ne();B();fn=class extends N{fill_null({value:e=void 0,strategy:t=void 0,limit:r=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=$(o)[t],Ie(a,u,{mode:"constant",condition:c=>c==null})}else if(t==="forward"||t==="backward"){let u=t==="forward",c=null,l=0;Ie(a,null,{mode:"independent",reverse:!u,step:({originalValue:f})=>f!=null?(c=f,l=0,f):c!==null&&(r===void 0||l<r)?(l++,c):null})}else throw new Error(`Unsupported fill_null strategy: "${t}"`);else{let u=this._resolve(e,s,i),c=C(u);Ie(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 Io={};Ar(Io,{ColumnExpr:()=>O,resolveColumnSelectors:()=>Te});function As(n,e){for(let t of e)for(let r of Object.getOwnPropertyNames(t.prototype))r!=="constructor"&&Object.defineProperty(n.prototype,r,Object.getOwnPropertyDescriptor(t.prototype,r)||Object.create(null))}function Ts(n,e,t,r){if(!(n instanceof O)){if(P(n)&&"evaluate"in n&&!n.colName){let o=[];for(let s=0;s<e.length;s++)t.has(e[s])||o.push(e[s]);return o}return null}if(n.colNames&&n.colNames.length>0)return n.colNames;if(n.colName==="*"){let o=new Set(n.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(n.targetType||n.targetTypes&&n.targetTypes.length>0){if(!r)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=r[i];if(a){if(n.targetType)a.matches(n.targetType)&&o.push(i);else if(n.targetTypes){for(let u=0;u<n.targetTypes.length;u++)if(a.matches(n.targetTypes[u])){o.push(i);break}}}}return o}return null}function Te(n,e,t,r,o){let s=[],i=t?new Set(t):new Set;for(let a=0;a<n.length;a++){let u=n[a];if(typeof u=="string"){s.push(new O(u));continue}if(P(u)&&u.isUnnest){let l=[],f=u.colName;if(typeof f=="string"&&r&&r[f]&&r[f].name==="Struct"&&(l=Object.keys(r[f].fields)),l.length===0&&o){let p=Object.keys(o)[0],y=p?o[p].length:0,d=u.baseExpr.evaluate(o,y),g=d.length;for(let b=0;b<g;b++){let D=d[b];if(D!=null&&typeof D=="object"){l=Object.keys(D);break}}}let m=l.length;if(m>0){for(let h=0;h<m;h++){let p=l[h],y=u.baseExpr.struct.field(p);s.push(y)}continue}}let c=Ts(u,e,i,r);if(c!==null)for(let l=0;l<c.length;l++){let f=new O(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 O,ce=E(()=>{"use strict";ne();ir();lr();cr();mr();ur();ar();pr();hr();yr();Oo();B();we();ae();O=class n extends N{colName;colNames;excludedCols=[];targetType;targetTypes;static isColExpr(e){if(!P(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 n.isColExpr(e)?e:new n(e)}constructor(e){super(),Array.isArray(e)?e.some(r=>r instanceof Y||typeof r=="function")?(this.targetTypes=e,this.colName="",this.outputName=""):(this.colNames=e.map(String),this.colName="",this.outputName=""):e instanceof Y||typeof e=="function"?(this.targetType=e,this.colName="",this.outputName=""):(this.colName=String(e),this.outputName=this.colName)}};As(O,[ct,mt,ht,yt,pt,ft,dt,gt,bt,fn])});function ko(n){if(n==null)throw new Error("Column reference cannot be null or undefined.");return mn||(mn=(ce(),Tr(Io)).ColumnExpr),mn.isColExpr(n)?n:new mn(n)}var mn,pn,bt,yr=E(()=>{"use strict";ne();mn=null;pn=class{constructor(e){this.expr=e;return new Proxy(this,{get(t,r,o){return r in t?Reflect.get(t,r,o):typeof r=="string"?t.field(r):Reflect.get(t,r,o)}})}expr;field(e){return x(this.expr,t=>{let r=t.length,o=new Array(r);for(let s=0;s<r;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 r=t.length,o=new Array(r),s=Object.keys(e),i=s.length;for(let a=0;a<r;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 h=l[m];c[h]=u[h]}for(let m=0;m<i;m++){let h=s[m];if(h in c){let p=e[h];c[p]=c[h],delete c[h]}}o[a]=c}return o})}with_fields(e){return x(this.expr,(t,r)=>{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=ko(f),h=m.outputName||m.colName;if(!h)throw new Error("Expressions passed to struct.with_fields must have a name/alias.");i.push({name:h,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],h=ko(e[m]);i.push({name:m,expr:h})}}let a=i.length,u=new Array(a);for(let c=0;c<a;c++)u[c]=i[c].expr.evaluate(r,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),h=m.length;for(let p=0;p<h;p++){let y=m[p];f[y]=l[y]}for(let p=0;p<a;p++)f[i[p].name]=u[p][c];s[c]=f}return s})}unnest(){let e=x(this.expr);return e.isUnnest=!0,e.baseExpr=this.expr,e}},bt=class extends N{get struct(){return new pn(this)}}});var ks={};Ar(ks,{$df:()=>Is,ALL_COLUMNS_MARKER:()=>G,AggregationExpr:()=>ht,ArithmeticExpr:()=>ct,Array:()=>Qn,ArrayDataType:()=>Qn,ArrayExpr:()=>gt,ArrayExprNamespace:()=>cn,ArrayType:()=>nn,Binary:()=>zn,BinaryType:()=>Jt,Boolean:()=>it,BooleanDataType:()=>it,BooleanType:()=>zt,COALESCE_MARKER:()=>_n,ColumnExpr:()=>O,ColumnNotFoundError:()=>he,ComparisonExpr:()=>mt,ComputeError:()=>Se,DFScriptError:()=>Ne,DataFrame:()=>v,DataFrameError:()=>j,DataType:()=>Y,DataTypeRegistry:()=>R,Date:()=>Yn,DateDataType:()=>Yn,DateTimeExprNamespace:()=>un,DateType:()=>Zt,Datetime:()=>at,DatetimeType:()=>Qt,DecimalType:()=>rt,Duration:()=>Zn,DurationType:()=>tn,ELEMENT_MARKER:()=>ze,ExprBase:()=>N,Float32:()=>Gn,Float32Type:()=>Wt,Float64:()=>st,Float64Type:()=>Gt,FloatDataType:()=>Le,GroupedData:()=>_t,Int16:()=>Pn,Int16Type:()=>Vt,Int32:()=>Bn,Int32Type:()=>Lt,Int64:()=>ot,Int64Type:()=>Pt,Int8:()=>Ln,Int8Type:()=>jt,IntegerDataType:()=>nt,LITERAL_MARKER:()=>xn,LogicalExpr:()=>ft,NestedDataType:()=>Pe,Null:()=>Hn,NullType:()=>Yt,NumericDataType:()=>Re,Object:()=>Jn,ObjectDataType:()=>Jn,ObjectType:()=>Xt,SchemaError:()=>Ke,ShapeError:()=>z,SignedIntegerType:()=>be,StringExpr:()=>pt,StringExprNamespace:()=>ln,Struct:()=>er,StructExpr:()=>bt,StructExprNamespace:()=>pn,StructType:()=>rn,TemporalDataType:()=>_e,TemporalExpr:()=>dt,Time:()=>Xn,TimeType:()=>en,UInt16:()=>Kn,UInt16Type:()=>$t,UInt32:()=>qn,UInt32Type:()=>Kt,UInt64:()=>Wn,UInt64Type:()=>qt,UInt8:()=>$n,UInt8Type:()=>Bt,UnsignedIntegerType:()=>xe,Utf8:()=>Be,Utf8Type:()=>Ht,When:()=>yn,WhenThen:()=>xt,WhenThenChain:()=>hn,WindowExpr:()=>yt,all:()=>We,assertColumnExists:()=>X,assertHeight:()=>an,coalesce:()=>br,coerceColumn:()=>De,columnsToRows:()=>or,computeRowHash:()=>ve,concat:()=>Ge,derive:()=>x,element:()=>wr,evaluateExpression:()=>ut,exclude:()=>gr,gatherColumnsByIndices:()=>qe,getRowFromColumns:()=>ws,implode:()=>_r,inferColumnType:()=>ye,kleeneBinary:()=>V,kleeneUnary:()=>T,lit:()=>dr,read_csv:()=>gn,read_json:()=>dn,resolveColumnSelectors:()=>Te,resolveWindowExpr:()=>nr,rowsToColumns:()=>rr,seq_range:()=>Fe,when:()=>xr,writeStringToFileOrStream:()=>sr});module.exports=Tr(ks);ae();ne();ir();ar();lr();ur();cr();mr();pr();hr();yr();ce();ce();ae();se();B();function Fe(n,e={strict:!0}){let t=e,r=new O(xn);return r.literalValue=n,t.name&&(r.outputName=t.name),r.ops.push(o=>{let s=o.length,i=(S,w)=>S===void 0?w:ue(S<0?s+S:S,{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 S=t.pad??!1,w=t.truncate??!1;if(S&&!w&&l>c)throw new z(`Cannot pad seq_range output: specified length ${l} starting at index ${a} exceeds slice width ${c} (requires truncation).`);if(w&&!S&&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,h=!!t.dtype,p=t.mode||"cumulative",y=t.step!==void 0?t.step:1,d=h?S=>t.dtype.coerce(S):S=>S;if(f){let S=t.dtype?.allocate?t.dtype.allocate(m):new Array(m);return Ie(S,n,{mode:p,step:y,coerce:d,startIndex:0,endIndex:m}),S}let g=Math.min(a+l,u),b=t.padValue!==void 0?t.padValue:null,D=d(b);if(p==="constant"&&a===0&&g===m&&!t.dtype){let S=new Array(m);for(let w=0;w<m;w++)S[w]=n;return S}let _=new Array(m);return _.fill(D),Ie(_,n,{mode:p,step:y,coerce:d,startIndex:a,endIndex:g}),_}),r}function dr(n,e){let t=Fe(n,{strict:!0,mode:"constant",dtype:e?.dtype,name:e?.name});return t.isLiteral=!0,t}ce();ae();function We(){return new O("*")}ce();ae();function gr(n){let e=new O("*");return e.excludedCols=Array.isArray(n)?n:[n],e}ce();B();ae();function br(...n){let e=n.length===1&&Array.isArray(n[0])?n[0]:n,t=new O(_n);return t.ops.push((r,o)=>{let s=r.length,i=l=>O.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 h=u[m],p=C(h)?h[l]:h;if(p!=null){f=p;break}}c[l]=f}return c}),t}ce();B();var hn=class{predicates;values;constructor(e,t){this.predicates=e,this.values=t}then(e){return new xt(this.predicates,this.values.concat(e))}},yn=class{predicates;constructor(e){this.predicates=[e]}then(e){return new xt(this.predicates,[e])}},xt=class n extends O{predicates;values;otherwiseValue;constructor(e,t,r=null){super(typeof e=="string"?e:"*when*"),this.predicates=Array.isArray(e)?e:[],this.values=t||[],this.otherwiseValue=r,this.ops.push((o,s)=>{let i=o.length,a=h=>O.isColExpr(h)?h.evaluate(s,i):typeof h=="string"&&h in s?s[h]:h,u=this.predicates.length,c=new Array(u),l=new Array(u);for(let h=0;h<u;h++)c[h]=a(this.predicates[h]),l[h]=a(this.values[h]);let f=a(this.otherwiseValue),m=new Array(i);for(let h=0;h<i;h++){let p=!1;for(let y=0;y<u;y++)if((C(c[y])?c[y][h]:c[y])===!0){m[h]=C(l[y])?l[y][h]:l[y],p=!0;break}p||(m[h]=C(f)?f[h]:f)}return m})}when(e){return new hn(this.predicates.concat(e),this.values)}otherwise(e){return new n(this.predicates,this.values,e)}};function xr(n){return new yn(n)}ce();function _r(n){return O.toColExpr(n).implode()}ce();ae();function wr(){return new O(ze)}Ae();lt();var _t=class{groups;keys;allKeys;parentColumns;parentHeight;parentSchema;constructor(e,t,r,o,s,i){this.groups=e,this.keys=t,this.allKeys=r,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 r=this.groups.size,o={};for(let a=0;a<t.length;a++)o[t[a]]=new Array(r);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 v._createDirect(o,i,s)}agg(...e){let t=this.allKeys.length,r=new Array(t);for(let f=0;f<t;f++)r[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=Te(e.flat(),r,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 h=0;h<s.length;h++){let p=s[h],y=this.parentColumns[p][m];u[p][c]=y===void 0?null:y}c++}for(let f=0;f<i.length;f++){let m=i[f],h=m.outputName||m.colName||"*";if(!m.aggFn)u[h]=m.evaluate(u,a);else{let p=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 D=0;D<g.length;D++)b[D]=p[g[D]];y[d]=m.aggFn(b),d++}u[h]=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]=ye(u[m])}return v._createDirect(u,l,c)}};Mt();Ft();we();B();se();we();B();se();function Cs(n,e,t){if(n==null)throw new j(`Invalid input to ${e} at index ${t}: item cannot be null or undefined.`);if(n instanceof v)return[n];if(Ce(n))return[new v(n)];if(C(n)){if(W(n,v,{mode:"every"}))return n;if(W(n,"plainObject",{mode:"every"}))return[new v(n)];let r=W(n,v,{mode:"some"});for(let o=0;o<n.length;o++)if(r?!(n[o]instanceof v):!Ce(n[o]))throw new j(r?`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 Ge(n,{how:e="vertical",horizontal:t}={}){if(n==null)throw new j("Invalid input to concat: rawItems cannot be null or undefined.");let r=Array.isArray(n)?n:[n],o=[];for(let i=0;i<r.length;i++)o.push(...Cs(r[i],"concat",i));let s=t?.strict??!0;if(o.length===0)return v._createDirect({},{},0);if(o.length===1&&e!=="horizontal")return o[0];switch(e){case"vertical":{let i=[];for(let p=0;p<o.length;p++)o[p].height>0&&i.push(o[p]);if(i.length===0)return v._createDirect({},{},0);let a=i[0],u=Object.keys(a._columns);for(let p=0;p<o.length;p++){let y=o[p];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 ${p}.`);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 ${p}. Expected column "${u[g]}", but found "${d[g]}".`);let b=a.schema[u[g]],D=y.schema[u[g]];if(b&&D&&!b.equals(D))throw new Ke(`[Strict Type Check] Schema type mismatch for column "${u[g]}": expected ${b.name}, found ${D.name}.`)}}let c=0;for(let p of o)c+=p.height;let l={},f=o.length;for(let p=0;p<f;p++)if(o[p].height>0){l=o[p].schema;break}Object.keys(l).length===0&&f>0&&(l=o[0].schema);let m={};for(let p of u){let y=l[p],d=!1;for(let b of o){let D=b._columns[p];if(!D){d=!0;break}if(!U(D)){for(let _=0;_<D.length;_++)if(D[_]==null){d=!0;break}}if(d)break}let g=y&&y.allocate?y.allocate(c):new Array(c).fill(null);d&&U(g)&&(g=new Array(c).fill(null)),m[p]=g}let h=0;for(let p of o){let y=p.height;if(y!==0){for(let d of u){let g=p._columns[d]||new Array(y).fill(null),b=m[d];if(U(b)&&U(g))b.set(g,h);else{let D=b;for(let _=0;_<y;_++)D[h+_]=g[_]}}h+=y}}return v._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),h=m.length;for(let p=0;p<h;p++){let y=m[p],d=l._columns[y];if(f===i)u[y]=U(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 v._createDirect(u,c,i)}case"diagonal":{let i=new Set;for(let m of o)for(let h of Object.keys(m._columns))i.add(h);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 h=null;for(let p of o){let y=p.schema[m];if(y){if(h===null)h=y;else if(!h.equals(y))throw new Ke(`[Strict Type Check] Schema type mismatch for column "${m}": expected ${h.name}, found ${y.name}.`)}}c[m]=h||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 h=o[m],p=h.height;if(p!==0){for(let y=0;y<a.length;y++){let d=a[y],g=l[d],b=h._columns[d];if(b!==void 0)if(U(b)&&U(g))g.set(b,f);else{let D=g;for(let _=0;_<p;_++)D[f+_]=b[_]}else{let D=g;for(let _=0;_<p;_++)D[f+_]=null}}f+=p}}return v._createDirect(l,c,u)}}}lt();var v=class n{_columns;_height;_schema={};static _createDirect(e,t,r){an(e,r);let o=Object.create(n.prototype);return o._columns=e,o._schema=t,o._height=r,o}constructor(e,t,r){if(Array.isArray(e)){let{columns:o,height:s}=rr(e);this._columns=o,this._height=s,t?this.applySchema(t):this.inferSchema();return}if(P(e)){this._columns=e,this._height=an(e,r),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),r=t.length;for(let o=0;o<r;o++){let s=t[o];e[s]=ye(this._columns[s])}this.applySchema(e)}applySchema(e){this._schema=e;let t=Object.keys(e),r={};for(let o of t){let s=e[o],i=this._columns[o];r[o]=i?De(i,s,this._height):De(new Array(this._height).fill(null),s,this._height)}this._columns=r}get columns(){return Object.keys(this._columns)}concat(e,t={}){let r=W(e,n,{mode:"every",allowEmpty:!1})?e:[e];return Ge([this,...r],t)}drop(...e){let t=new Set(e.flat()),r={},o={};for(let s of Object.keys(this._columns))t.has(s)||(r[s]=this._columns[s],o[s]=this._schema[s]);return n._createDirect(r,o,this._height)}drop_nulls(e){return this._height===0?this:this.filter(e?new O(e).is_not_null():We().is_not_null())}get dtypes(){let e=Object.keys(this._columns),t=e.length,r=new Array(t);for(let o=0;o<t;o++)r[o]=this._schema[e[o]];return r}explode(e,t){let r=O.toColExpr(e),o=r.colNames||[r.colName||r.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.");X(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 O(f).arr.explode(t):new O(f))}return this.select(...u)}fill_null(e={}){return this._height===0?this:this.with_columns(We().fill_null(e))}filter(...e){if(this._height===0)return n._createDirect({},this._schema,0);let t=this._height,r=Object.keys(this._columns),o=r.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=Te(a,r,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,h=null;if(i.length>0){let d=this._columns;h={};for(let g=0;g<o;g++){let b=r[g],D=d[b];Object.defineProperty(h,b,{get(){let _=D[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(h){m=d;for(let b=0;b<i.length;b++)if(!i[b](h)){g=!1;break}}g&&f.push(d)}}let p=qe(this._columns,f),y=f.length;return n._createDirect(p,this._schema,y)}get_schema(){return this._schema}groupby(e){let t=Xe(e),r=new Map,o=this._height,s=Ue(e);for(let a=0;a<s.length;a++)X(s[a],this._columns,"Grouping key");for(let a=0;a<o;a++){let u=ve(this._columns,s,a),c=r.get(u);c===void 0&&r.set(u,c=[]),c.push(a)}let i=Object.keys(this._columns);return new _t(r,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,r){let o=O.toColExpr(r).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 r=this._height,o=Object.keys(this._columns),s=o.length;if(e===void 0&&t===void 0){if(r!==1||s!==1)throw new j("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 j("DataFrame.item() requires both row and column to be specified if not empty.");if(e<0||e>=r)throw new z(`Row index ${e} is out of bounds for DataFrame height ${r}.`);let i;if(typeof t=="number"){if(t<0||t>=s)throw new z(`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 he(i);return this._columns[i][e]}*iter_columns(){let e=Object.keys(this._columns),t=e.length,r=this._columns;for(let o=0;o<t;o++)yield r[e[o]]}*iter_rows({named:e=!1}={}){let t=Object.keys(this._columns),r=t.length,o=this._columns,s=this._height,i=new Array(r);for(let a=0;a<r;a++)i[a]=o[t[a]];if(e)for(let a=0;a<s;a++){let u={};for(let c=0;c<r;c++)u[t[c]]=i[c][a];yield u}else for(let a=0;a<s;a++){let u=new Array(r);for(let c=0;c<r;c++)u[c]=i[c][a];yield u}}join(e){let{other:t,on:r,how:o="inner",suffixes:s=["","_right"]}=e,i=Ue(r);for(let I=0;I<i.length;I++){let k=i[I];X(k,this._columns,"Join key"," in the left DataFrame."),X(k,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,h=l.length,p=(I,k)=>{let L=i.length;for(let K=0;K<L;K++)if(I[i[K]][k]==null)return null;return ve(I,i,k)},y=new Map,d=t._height,g=t._columns;for(let I=0;I<d;I++){let k=p(g,I);if(k===null)continue;let L=y.get(k);L===void 0&&(L=[],y.set(k,L)),L.push(I)}let b=this._height,D=this._columns,_=[],S=[],w=o==="outer"||o==="right",A=w?new Set:null;for(let I=0;I<b;I++){let k=p(D,I),L=k===null?void 0:y.get(k);if(L===void 0)(o==="left"||o==="outer")&&(_.push(I),S.push(null));else for(let K=0;K<L.length;K++){let H=L[K];w&&A.add(H),_.push(I),S.push(H)}}if(w)for(let I=0;I<d;I++)A.has(I)||(_.push(-1),S.push(I));let M=_.length,fe={},ie={};for(let I=0;I<m;I++){let k=c[I],L=k in t._columns&&!f.has(k)?`${k}${a}`:k,K=this._columns[k],H=f.has(k),J=new Array(M);if(H){let re=t._columns[k];for(let ee=0;ee<M;ee++){let Sr=_[ee];if(Sr!==-1)J[ee]=K[Sr];else{let Dr=S[ee];J[ee]=Dr!==null?re[Dr]:null}}}else for(let re=0;re<M;re++){let ee=_[re];J[re]=ee!==-1?K[ee]:null}fe[L]=J,this._schema[k]&&(ie[L]=this._schema[k])}for(let I=0;I<h;I++){let k=l[I];if(!f.has(k)){let L=k in this._columns?`${k}${u}`:k,K=t._columns[k],H=new Array(M);for(let J=0;J<M;J++){let re=S[J];H[J]=re!==null?K[re]:null}fe[L]=H,t._schema[k]&&(ie[L]=t._schema[k])}}return n._createDirect(fe,ie,M)}limit(e,{offset:t=0,from:r="start"}={}){let o=this._height,s=ue(Math.floor(e),{min:0,max:o}),i=ue(Math.floor(t),{min:0,max:o}),a=i,u=Math.min(i+s,o);r==="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 h=0;h<m;h++){let p=f[h];l[p]=this._columns[p].slice(a,u)}return n._createDirect(l,this._schema,c)}pivot(e){if(this._height===0)return n._createDirect({},{},0);let{index:t,columns:r,values:o}=e,s=Ue(t),i=s.length;for(let S=0;S<i;S++)X(s[S],this._columns,"Pivot index key");let a=String(r),u=String(o);X(a,this._columns,"Pivot column key"),X(u,this._columns,"Pivot values key");let c=new Map,l=[],f=new Set,m=this._height,h=this._columns[a],p=this._columns[u];for(let S=0;S<m;S++){let w=ve(this._columns,s,S);f.add(String(h[S])),c.get(w)===void 0&&(c.set(w,c.size),l.push(S))}let y=c.size,d={},g={};for(let S=0;S<i;S++){let w=s[S];d[w]=this._columns[w],this._schema[w]&&(g[w]=this._schema[w])}let b=qe(d,l),D=Array.from(f),_=this._schema[u]||R.Utf8;for(let S=0;S<D.length;S++){let w=D[S];b[w]=new Array(y).fill(null),g[w]=_}for(let S=0;S<m;S++){let w=ve(this._columns,s,S),A=c.get(w),M=String(h[S]);b[M][A]=p[S]}return n._createDirect(b,g,y)}rename(e){let t=e||{},r={},o={},s=Object.keys(this._columns);for(let a of s){let u=t[a]||a;r[u]=this._columns[a],o[u]=this._schema[a]}if(Object.keys(r).length<s.length)throw new j("Rename collision: Multiple columns mapped to the same output name.");return n._createDirect(r,o,this._height)}reverse(){if(this._height===0)return this;let e={},t=Object.keys(this._columns),r=t.length;for(let o=0;o<r;o++){let s=t[o];e[s]=this._columns[s].slice().reverse()}return n._createDirect(e,this._schema,this._height)}get schema(){return this._schema}select(...e){let t=this._normalizeArgs(e),r=Object.keys(this._columns),o=Te(t,r,void 0,this._schema,this._columns),s=o.length;if(s===0)return n._createDirect({},{},this._height);let i={},a={},u=new Array(s),c=new Array(s),l=new Set,f=null;for(let p=0;p<s;p++){let y=o[p],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=ut(y,this._columns,this._height);u[p]=g,c[p]=d;let b=g&&g.rowMap;if(b)if(f){let D=b.length;if(D!==f.length)throw new z(`Mismatched explode heights: Column "${d}" has length ${D}, but another exploded column has length ${f.length}`);for(let _=0;_<D;_++)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,h=s>0;for(let p=0;p<s;p++){let y=o[p],d=y.aggFn!=null&&(y.partitionBy==null||y.partitionBy.length===0),g=!!y.isLiteral;if(!d&&!g){h=!1;break}}for(let p=0;p<s;p++){let y=c[p],d=u[p],g=d,b=g&&g.rowMap,D=C(d)?d.length:0,_=f&&!b?this._height:m;if(D!==_)throw new z(`Column height mismatch: Column "${y}" has length ${D}, but expected ${_}`);if(f&&!b){let S=f.length;if(U(d)){let w=new g.constructor(S);for(let A=0;A<S;A++)w[A]=g[f[A]];d=w}else{let w=new Array(S);for(let A=0;A<S;A++)w[A]=g[f[A]];d=w}}u[p]=d}h&&(m=1);for(let p=0;p<s;p++){let y=o[p],d=c[p],g=u[p],b=y.colName||d,_=y instanceof O&&y.ops.length===0&&!y.isWindow&&!y.aggFn&&this._schema[b]||ye(g);a[d]=_,i[d]=De(g,_,m)}return n._createDirect(i,a,m)}get shape(){return[this.height,this.width]}slice(e,t){let r=this._height,o=e<0?Math.max(r+e,0):Math.min(e,r),s=t===void 0?r:t<0?Math.max(r+t,0):Math.min(t,r),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:r=!1,nullsLast:o=!0,custom:s}=e,i=Xe(t);for(let p=0;p<i.length;p++){let y=O.toColExpr(i[p]);y.colName&&X(y.colName,this._columns,"Sort key")}let a=Array.isArray(r)?r:new Array(i.length).fill(r),u=i.length,c=new Array(u);for(let p=0;p<u;p++){let y=i[p],d=a[p]?-1:1,g=s&&typeof y=="string"?s[y]:null,b=O.toColExpr(y).evaluate(this._columns,this._height);c[p]={values:b,isDesc:d,customComp:g}}let l=c.length,f=o?1:-1,m=new Array(this._height);for(let p=0;p<this._height;p++)m[p]=p;m.sort((p,y)=>{for(let d=0;d<l;d++){let{values:g,isDesc:b,customComp:D}=c[d],_=g[p],S=g[y];if(D){let A=D(_,S);if(A!==0)return A*b;continue}if(_==null||S==null){if(_===S)continue;return(_==null?1:-1)*f}if(_===S)continue;return(_<S?-1:1)*b}return 0});let h=qe(this._columns,m);return n._createDirect(h,this._schema,this._height)}tail(e=10){return this.limit(e,{offset:0,from:"end"})}to_dict(){return{...this._columns}}to_dicts(){return or(this._columns,this._height)}to_array(e){if(this._height===0)return[];if(e==null)return new Array(this._height).fill(null);let r=O.toColExpr(e).evaluate(this._columns,this._height);return Array.isArray(r)?r:Array.from(r)}transpose({include_header:e=!1,header_name:t="column",column_names:r}={}){if(this._height===0){let l={},f={};return e&&(l[t]=De([],R.Utf8,0),f[t]=R.Utf8),n._createDirect(l,f,0)}let o=this.columns;typeof r=="string"&&(X(r,this._columns,"column_names"),o=o.filter(l=>l!==r));let s=[];if(typeof r=="string"){let l=this._columns[r];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 "${r}" contains null/undefined at index ${f}`);s[f]=String(m)}}else if(r!=null&&typeof r!="string"&&Symbol.iterator in Object(r)){let l=Array.from(r);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]=De(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 p=0;p<a;p++)m[p]=this._columns[o[p]][l];let h=ye(m);u[f]=De(m,h,a),c[f]=h}return n._createDirect(u,c,a)}unique(e){if(this._height===0)return n._createDirect({},this._schema,0);let t=Xe(e),r=t.length===0?Object.keys(this._columns):t.map(String);for(let c of r)X(c,this._columns,"Unique column key");let o=new Set,s=[],i=this._height;for(let c=0;c<i;c++){let l=ve(this._columns,r,c);o.has(l)||(o.add(l),s.push(c))}let a=qe(this._columns,s),u=s.length;return n._createDirect(a,this._schema,u)}unpivot(e){let{idVars:t,valueVars:r,varName:o="variable",valueName:s="value"}=e,i=Ue(t),a=Ue(r),u=i.length,c=a.length;for(let p of i)X(p,this._columns,"Unpivot id variable key");for(let p of a)X(p,this._columns,"Unpivot value variable key");let l=this._height*c,f={};for(let p=0;p<u;p++)f[i[p]]=new Array(l);f[o]=new Array(l),f[s]=new Array(l);let m=0;for(let p=0;p<this._height;p++)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][p]}f[o][m]=d,f[s][m]=this._columns[d][p],m++}let h={};for(let p of i)h[p]=this._schema[p];return h[o]=R.Utf8,h[s]=ye(f[s]),n._createDirect(f,h,l)}vstack(e){return this.concat(e,{how:"vertical"})}get width(){return Object.keys(this._columns).length}_normalizeArgs(e){let t=e.flat(),r=[];for(let o of t)if(typeof o=="string")r.push(new O(o));else if(O.isColExpr(o))r.push(o);else if(P(o)){let s=Object.keys(o),i=s.length;for(let a=0;a<i;a++){let u=s[a],c=o[u];if(O.isColExpr(c))r.push(c.alias(u));else{let l=new O(u);l.evaluate=(f,m)=>new Array(m).fill(c),r.push(l)}}}return r}with_columns(...e){if(e.length===0)return this;let t=this._normalizeArgs(e),r=Object.keys(this._columns),o=Te(t,r,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=r.length;for(let c=0;c<u;c++){let l=r[c];a.push(i.get(l)||new O(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 r=Fe(t,{mode:"independent",dtype:R.UInt32,step:1}),o=this.insert_column(0,e,r);return o._schema[e]=R.UInt32,o}write_json(e,{format:t="json",replacerOptions:r}={}){if(t!=="json"&&t!=="ndjson")throw new TypeError(`Unsupported JSON format: "${t}". Expected "json" or "ndjson".`);let o=r?.replacer===null?void 0:tt(r),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 sr(e,s),s}write_csv(e,t={}){if(e){if(typeof e=="string"){if(typeof require!="function")throw new Error("File writing is not supported in this environment (missing require('fs')).");let r=require("fs"),o=r.openSync(e,"w");try{sn(this._columns,this._height,{...t,onRow:s=>{r.writeSync(o,s,null,"utf8")}})}finally{r.closeSync(o)}}else if(P(e)&&typeof e.write=="function")sn(this._columns,this._height,{...t,onRow:r=>{e.write(r)}});else throw new TypeError("Invalid file argument. Expected a file path string or a writable stream/object with a write method.");return""}return sn(this._columns,this._height,t)}};lt();we();B();se();function dn(n,{format:e="json",trimBeforeParse:t=!0,schema:r,...o}={}){let s=mo(n,{format:e,trimBeforeParse:t,...o});if(s===n)throw new j(`Invalid JSON input: must be a valid, non-empty JSON ${e} string.`);let i=Array.isArray(s)?s:P(s)?[s]:[];return new v(i,r)}B();function gn(n,e={}){let{hasHeader:t=!0,schema:r,inferSchema:o=!0}=e,s=yo(n,e);if(s.length===0)return new v({});let i,a;t?(i=s[0],a=s.slice(1)):(i=s[0].map((m,h)=>`column_${h}`),a=s);let u=i.length,c=a.length,l={};for(let m=0;m<u;m++){let h=i[m],p=new Array(c);for(let y=0;y<c;y++)p[y]=a[y][m]!==void 0?a[y][m]:"";l[h]=p}let f={};for(let m=0;m<u;m++){let h=i[m],p=l[h];if(r&&r[h])f[h]=p;else if(o){let{values:y}=go(p,e);f[h]=y}else f[h]=p}return new v(f,r)}function Os(n,e){return new v(n,e)}var Is={data:Os,col:n=>new O(n),all:We,exclude:gr,coalesce:br,concat:Ge,read_json:dn,read_csv:gn,lit:dr,when:xr,implode:_r,seq_range:Fe,element:wr,DataType:R};we();se();0&&(module.exports={$df,ALL_COLUMNS_MARKER,AggregationExpr,ArithmeticExpr,Array,ArrayDataType,ArrayExpr,ArrayExprNamespace,ArrayType,Binary,BinaryType,Boolean,BooleanDataType,BooleanType,COALESCE_MARKER,ColumnExpr,ColumnNotFoundError,ComparisonExpr,ComputeError,DFScriptError,DataFrame,DataFrameError,DataType,DataTypeRegistry,Date,DateDataType,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,LogicalExpr,NestedDataType,Null,NullType,NumericDataType,Object,ObjectDataType,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
@@ -13,7 +13,9 @@ export type DataFrameSchema = Record<string, RegisteredDataType>;
13
13
  export type DataFrameColumns<T extends RowRecord> = {
14
14
  [K in keyof T]: ColumnData<T[K]>;
15
15
  };
16
- export type Scalar = string | number | boolean | bigint | Date | null | undefined;
16
+ export type AnyTypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
17
+ export type ValidPrimitiveTypes = string | number | boolean | bigint | symbol | null | undefined;
18
+ export type ValidScalarTypes = Exclude<ValidPrimitiveTypes, symbol> | Date | AnyTypedArray;
17
19
  export type AggFn<V, R = any> = (values: V[]) => R;
18
20
  export type OpFn = (vals: ColumnData, columns: ColumnDict) => ColumnData;
19
21
  export type IntoExpr = string | IExpr;
@@ -52,7 +54,7 @@ export interface ConcatOptions {
52
54
  horizontal?: HorizontalConcatOptions;
53
55
  }
54
56
  export type ConcatItem = DataFrame<any> | ColumnDict | RowRecord[];
55
- export type { UniqueListStatsOptions, JoinListOptions } from "./utils/list";
57
+ export type { UniqueArrayStatsOptions, JoinArrayOptions } from "./utils/array";
56
58
  export interface ExplodeOptions {
57
59
  empty_as_null?: boolean;
58
60
  keep_nulls?: boolean;