@toclocoinc/lattice-grid 1.28.0 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/docs/API.html +408 -14
- package/docs/api-detail.html +61 -4
- package/lattice-grid.d.ts +456 -8
- package/lattice-grid.esm.min.js +2593 -536
- package/lattice-grid.min.cjs +2593 -536
- package/lattice-grid.min.js +2593 -536
- package/modules/angular.esm.min.js +264 -0
- package/modules/angular.min.cjs +265 -0
- package/modules/angular.min.js +265 -0
- package/modules/charts.esm.min.js +366 -4
- package/modules/charts.min.cjs +365 -4
- package/modules/charts.min.js +365 -4
- package/modules/devtools.esm.min.js +2 -2
- package/modules/devtools.min.cjs +2 -2
- package/modules/devtools.min.js +2 -2
- package/modules/dhtmlx-compat.esm.min.js +4 -4
- package/modules/dhtmlx-compat.min.cjs +4 -4
- package/modules/dhtmlx-compat.min.js +4 -4
- package/modules/htmx.esm.min.js +2593 -536
- package/modules/htmx.min.cjs +2593 -536
- package/modules/htmx.min.js +2593 -536
- package/modules/react.esm.min.js +4 -3
- package/modules/react.min.cjs +4 -3
- package/modules/react.min.js +4 -3
- package/modules/svelte.esm.min.js +4 -3
- package/modules/svelte.min.cjs +4 -3
- package/modules/svelte.min.js +4 -3
- package/modules/vue.esm.min.js +4 -3
- package/modules/vue.min.cjs +4 -3
- package/modules/vue.min.js +4 -3
- package/modules/webcomponent.esm.min.js +2593 -536
- package/modules/webcomponent.min.cjs +2593 -536
- package/modules/webcomponent.min.js +2593 -536
- package/package.json +1 -1
package/lattice-grid.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.
|
|
2
|
+
* Lattice Grid 1.30.0, core + DOM renderer
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
@@ -54,7 +54,7 @@ Object.defineProperty(__exports,"frameBatched",{enumerable:true,get:function(){r
|
|
|
54
54
|
Object.defineProperty(__exports,"settleDebounce",{enumerable:true,get:function(){return settleDebounce;}});
|
|
55
55
|
Object.defineProperty(__exports,"whenIdle",{enumerable:true,get:function(){return whenIdle;}});
|
|
56
56
|
Object.defineProperty(__exports,"uid",{enumerable:true,get:function(){return uid;}});
|
|
57
|
-
const STAMPED_VERSION="1.
|
|
57
|
+
const STAMPED_VERSION="1.30.0";
|
|
58
58
|
async function resolveVersion(){
|
|
59
59
|
if(STAMPED_VERSION!=='0.0.0-source')return STAMPED_VERSION;
|
|
60
60
|
try{
|
|
@@ -71,7 +71,7 @@ return JSON.parse(text).version||STAMPED_VERSION;
|
|
|
71
71
|
return STAMPED_VERSION;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
const VERSION="1.
|
|
74
|
+
const VERSION="1.30.0";
|
|
75
75
|
const warned=new Set();
|
|
76
76
|
const WARNED_LIMIT=2000;
|
|
77
77
|
function rememberWarned(key){
|
|
@@ -1147,7 +1147,7 @@ const EVENT_NAMES=Object.freeze([
|
|
|
1147
1147
|
'facet:expanded','facet:failed',
|
|
1148
1148
|
'column:moved','column:resized','column:visible','column:pinned','column:grouped',
|
|
1149
1149
|
'column:pivoted','column:filter:open','column:menu:open','columns:changed',
|
|
1150
|
-
'columns:tagged','header:contextmenu','pivot:drill',
|
|
1150
|
+
'columns:tagged','columngroup:changed','header:contextmenu','pivot:drill',
|
|
1151
1151
|
'selection:changed','range:changed','clipboard:copy','page:changed','scroll',
|
|
1152
1152
|
'scroll:end','size:changed','detail:toggled','toolpanel:focus','highlight:changed',
|
|
1153
1153
|
'tree:loading','tree:loaded','tree:loadFailed','tree:loadAborted',
|
|
@@ -2774,11 +2774,18 @@ Object.defineProperty(__exports,"formatDateTime",{enumerable:true,get:function()
|
|
|
2774
2774
|
Object.defineProperty(__exports,"parseDuration",{enumerable:true,get:function(){return parseDuration;}});
|
|
2775
2775
|
Object.defineProperty(__exports,"toDurationMs",{enumerable:true,get:function(){return toDurationMs;}});
|
|
2776
2776
|
Object.defineProperty(__exports,"formatDuration",{enumerable:true,get:function(){return formatDuration;}});
|
|
2777
|
+
Object.defineProperty(__exports,"zoneAbbrev",{enumerable:true,get:function(){return zoneAbbrev;}});
|
|
2778
|
+
Object.defineProperty(__exports,"resolveZoneName",{enumerable:true,get:function(){return resolveZoneName;}});
|
|
2779
|
+
Object.defineProperty(__exports,"zoneLabel",{enumerable:true,get:function(){return zoneLabel;}});
|
|
2780
|
+
Object.defineProperty(__exports,"formatInstant",{enumerable:true,get:function(){return formatInstant;}});
|
|
2781
|
+
Object.defineProperty(__exports,"bucketInstant",{enumerable:true,get:function(){return bucketInstant;}});
|
|
2782
|
+
Object.defineProperty(__exports,"timestampGroupProjector",{enumerable:true,get:function(){return timestampGroupProjector;}});
|
|
2777
2783
|
Object.defineProperty(__exports,"TEMPORAL_TYPES",{enumerable:true,get:function(){return TEMPORAL_TYPES;}});
|
|
2778
2784
|
Object.defineProperty(__exports,"TEMPORAL_INFERENCE_ORDER",{enumerable:true,get:function(){return TEMPORAL_INFERENCE_ORDER;}});
|
|
2779
2785
|
Object.defineProperty(__exports,"default",{enumerable:true,get:function(){return __default;}});
|
|
2780
2786
|
const __m0=__req("packages/core/src/internal/util.js");
|
|
2781
2787
|
const isNil=__m0["isNil"];
|
|
2788
|
+
const isFunction=__m0["isFunction"];
|
|
2782
2789
|
const __m1=__req("packages/core/src/format/date.js");
|
|
2783
2790
|
const toDate=__m1["toDate"];
|
|
2784
2791
|
const compilePattern=__m1["compilePattern"];
|
|
@@ -3126,6 +3133,78 @@ if(s===''||DURATION_CLOCK.test(s))return false;
|
|
|
3126
3133
|
if(!/[a-z]/i.test(s))return false;
|
|
3127
3134
|
return parseDuration(s)!==null;
|
|
3128
3135
|
}
|
|
3136
|
+
const EXCEL_EPOCH_MS=Date.UTC(1899,11,30);
|
|
3137
|
+
const zoneNameFormatters=new Map();
|
|
3138
|
+
function zoneAbbrev(timeZone,ms){
|
|
3139
|
+
const key=timeZone||'';
|
|
3140
|
+
let fmt=zoneNameFormatters.get(key);
|
|
3141
|
+
if(!fmt){
|
|
3142
|
+
fmt=new Intl.DateTimeFormat('en-GB',{
|
|
3143
|
+
timeZone:timeZone||undefined,timeZoneName:'short',hour:'2-digit',hour12:false,
|
|
3144
|
+
});
|
|
3145
|
+
zoneNameFormatters.set(key,fmt);
|
|
3146
|
+
}
|
|
3147
|
+
const at=typeof ms==='number'?ms:Date.now();
|
|
3148
|
+
for(const part of fmt.formatToParts(new Date(at))){
|
|
3149
|
+
if(part.type==='timeZoneName')return part.value;
|
|
3150
|
+
}
|
|
3151
|
+
return'';
|
|
3152
|
+
}
|
|
3153
|
+
function resolveZoneName(timeZone){
|
|
3154
|
+
if(timeZone)return timeZone;
|
|
3155
|
+
try{
|
|
3156
|
+
return new Intl.DateTimeFormat().resolvedOptions().timeZone||'UTC';
|
|
3157
|
+
}catch{
|
|
3158
|
+
return'UTC';
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
function zoneLabel(timeZone,ms){
|
|
3162
|
+
const name=resolveZoneName(timeZone);
|
|
3163
|
+
const abbrev=zoneAbbrev(timeZone,ms);
|
|
3164
|
+
return abbrev?`${name} (${abbrev})`:name;
|
|
3165
|
+
}
|
|
3166
|
+
function displayZoneOf(o,p){
|
|
3167
|
+
if(o&&o.timeZone)return o.timeZone;
|
|
3168
|
+
const grid=p&&p.grid;
|
|
3169
|
+
const configured=grid&&isFunction(grid.get)?grid.get('timeZone'):undefined;
|
|
3170
|
+
return configured||undefined;
|
|
3171
|
+
}
|
|
3172
|
+
function formatInstant(value,o){
|
|
3173
|
+
const opts=o||EMPTY;
|
|
3174
|
+
const ms=toEpochMs(value);
|
|
3175
|
+
if(ms==null)return opts.nullDisplay??'';
|
|
3176
|
+
const text=dateTimeFormatter(opts)(ms);
|
|
3177
|
+
if(!opts.showOrigin)return text;
|
|
3178
|
+
const origin=opts.originZone;
|
|
3179
|
+
if(!origin)return`${text} (no origin recorded)`;
|
|
3180
|
+
if(origin===(opts.timeZone||resolveZoneName(opts.timeZone)))return text;
|
|
3181
|
+
return`${text} (${zoneLabel(origin,ms)})`;
|
|
3182
|
+
}
|
|
3183
|
+
function bucketInstant(ms,granularity,timeZone,weekStart){
|
|
3184
|
+
if(granularity==='instant'||!granularity)return ms;
|
|
3185
|
+
const p=zonedParts(ms,timeZone);
|
|
3186
|
+
if(granularity==='month'){
|
|
3187
|
+
return instantFromParts({year:p.year,month:p.month,day:1},timeZone);
|
|
3188
|
+
}
|
|
3189
|
+
if(granularity==='week'){
|
|
3190
|
+
const start=((weekStart>=1&&weekStart<=7)?weekStart:1);
|
|
3191
|
+
const dow=((new Date(Date.UTC(p.year,p.month-1,p.day)).getUTCDay()+6)%7)+1;
|
|
3192
|
+
const back=(dow-start+7)%7;
|
|
3193
|
+
const civil=new Date(Date.UTC(p.year,p.month-1,p.day-back));
|
|
3194
|
+
return instantFromParts(
|
|
3195
|
+
{year:civil.getUTCFullYear(),month:civil.getUTCMonth()+1,day:civil.getUTCDate()},
|
|
3196
|
+
timeZone,
|
|
3197
|
+
);
|
|
3198
|
+
}
|
|
3199
|
+
return instantFromParts({year:p.year,month:p.month,day:p.day},timeZone);
|
|
3200
|
+
}
|
|
3201
|
+
function timestampGroupProjector(column,timeZone){
|
|
3202
|
+
const group=column&&column.group;
|
|
3203
|
+
const granularity=(group&&group.granularity)||'day';
|
|
3204
|
+
if(granularity==='instant')return null;
|
|
3205
|
+
const weekStart=group&&group.weekStart;
|
|
3206
|
+
return(ms)=>(typeof ms==='number'?bucketInstant(ms,granularity,timeZone,weekStart):ms);
|
|
3207
|
+
}
|
|
3129
3208
|
const TEMPORAL_TYPES={
|
|
3130
3209
|
time:{
|
|
3131
3210
|
base:'number',
|
|
@@ -3176,6 +3255,36 @@ toStorage:(v)=>toDurationMs(v),
|
|
|
3176
3255
|
toClipboard:(v)=>formatDuration(toDurationMs(v),{style:'short',maxUnits:-1}),
|
|
3177
3256
|
fromClipboard:(s)=>parseDuration(s),
|
|
3178
3257
|
},
|
|
3258
|
+
timestamp:{
|
|
3259
|
+
base:'number',
|
|
3260
|
+
storage:'float64',
|
|
3261
|
+
format:(p)=>{
|
|
3262
|
+
const o=optionsFor(p,'timestamp');
|
|
3263
|
+
return formatInstant(p.value,{...o,timeZone:displayZoneOf(o,p)});
|
|
3264
|
+
},
|
|
3265
|
+
parse:(p)=>{
|
|
3266
|
+
const o=optionsFor(p,'timestamp');
|
|
3267
|
+
const d=parseDateTime(p.text,{timeZone:displayZoneOf(o,p)});
|
|
3268
|
+
return d?d.getTime():null;
|
|
3269
|
+
},
|
|
3270
|
+
compare:(a,b)=>compareNumeric(toEpochMs(a),toEpochMs(b)),
|
|
3271
|
+
groupProjector:(column,timeZone)=>timestampGroupProjector(column,timeZone),
|
|
3272
|
+
defaults:{filter:'date',editor:'datetime',align:'start'},
|
|
3273
|
+
excel:'yyyy-mm-dd hh:mm',
|
|
3274
|
+
excelKind:'number',
|
|
3275
|
+
toExcelValue:(v,p)=>{
|
|
3276
|
+
const ms=toEpochMs(v);
|
|
3277
|
+
if(ms==null)return null;
|
|
3278
|
+
const wall=zonedParts(ms,(p&&p.timeZone)||undefined);
|
|
3279
|
+
return(Date.UTC(wall.year,wall.month-1,wall.day,wall.hour,wall.minute,wall.second)-EXCEL_EPOCH_MS)/MS_PER_DAY;
|
|
3280
|
+
},
|
|
3281
|
+
toStorage:(v)=>toEpochMs(v),
|
|
3282
|
+
toClipboard:(v)=>{
|
|
3283
|
+
const ms=toEpochMs(v);
|
|
3284
|
+
return ms==null?'':new Date(ms).toISOString();
|
|
3285
|
+
},
|
|
3286
|
+
fromClipboard:(s)=>toEpochMs(s),
|
|
3287
|
+
},
|
|
3179
3288
|
};
|
|
3180
3289
|
const TEMPORAL_INFERENCE_ORDER=['datetime','time','duration'];
|
|
3181
3290
|
const __default=TEMPORAL_TYPES;
|
|
@@ -3542,6 +3651,19 @@ other:'{count} edits were refused and put back{reason}',
|
|
|
3542
3651
|
'a11y.column.alreadyLast':'{column} is already last in its group',
|
|
3543
3652
|
'a11y.column.cannotMoveThere':'{column} cannot be moved there',
|
|
3544
3653
|
'a11y.column.moved':'{column} moved to position {at} of {of}',
|
|
3654
|
+
'a11y.group.formed':'{column} grouped with {other} in a new band',
|
|
3655
|
+
'a11y.group.dissolved':'band {group} dissolved',
|
|
3656
|
+
'a11y.group.renamed':'band renamed to {group}',
|
|
3657
|
+
'a11y.group.moved':'band {group} moved to position {at} of {of}',
|
|
3658
|
+
'a11y.column.addedToGroup':'{column} added to band {group}',
|
|
3659
|
+
'a11y.column.removedFromGroup':'{column} removed from its band',
|
|
3660
|
+
'a11y.column.notInGroup':'{column} is not in a band',
|
|
3661
|
+
'a11y.column.cannotGroup':'{column} cannot be grouped',
|
|
3662
|
+
'a11y.group.cannotMove':'band {group} cannot be moved there',
|
|
3663
|
+
'columngroup.newGroup':'New group',
|
|
3664
|
+
'columngroup.rename':'Rename band',
|
|
3665
|
+
'columngroup.dissolve':'Dissolve band',
|
|
3666
|
+
'columngroup.group':'Group with adjacent column',
|
|
3545
3667
|
'a11y.panel.cannotMove':'{column} cannot be moved',
|
|
3546
3668
|
'a11y.panel.alreadyFirst':'{column} is already first',
|
|
3547
3669
|
'a11y.panel.alreadyLast':'{column} is already last',
|
|
@@ -3615,6 +3737,7 @@ other:'Paste preview: {changes} cell changes, {rejected} rejected. Review, then
|
|
|
3615
3737
|
'panel.quickFilter':'Quick filter',
|
|
3616
3738
|
'panel.formatting':'Formatting',
|
|
3617
3739
|
'panel.statistics':'Statistics',
|
|
3740
|
+
'panel.regression':'Regression',
|
|
3618
3741
|
'panel.compare':'Compare',
|
|
3619
3742
|
'panel.insights':'Insights',
|
|
3620
3743
|
'insights.subset':'Filtered subset vs whole',
|
|
@@ -3728,6 +3851,21 @@ other:'Paste preview: {changes} cell changes, {rejected} rejected. Review, then
|
|
|
3728
3851
|
'stats.ppk':'Ppk',
|
|
3729
3852
|
'stats.outOfSpec':'Out of specification',
|
|
3730
3853
|
'stats.filtered':'Over the {count} filtered rows',
|
|
3854
|
+
'regression.noModel':'No model configured. Set predictors and a response on the panel.',
|
|
3855
|
+
'regression.cannotFit':'The model cannot be fitted over the current rows.',
|
|
3856
|
+
'regression.observations':'Fitted over {count} rows',
|
|
3857
|
+
'regression.r2':'R²',
|
|
3858
|
+
'regression.adjR2':'Adjusted R²',
|
|
3859
|
+
'regression.coefficients':'Coefficients',
|
|
3860
|
+
'regression.term':'Term',
|
|
3861
|
+
'regression.estimate':'Estimate ± SE',
|
|
3862
|
+
'regression.stdError':'Std error',
|
|
3863
|
+
'regression.t':'t',
|
|
3864
|
+
'regression.p':'p',
|
|
3865
|
+
'regression.vif':'Variance inflation (VIF)',
|
|
3866
|
+
'regression.heteroscedasticity':'Heteroscedasticity (Breusch–Pagan)',
|
|
3867
|
+
'regression.heteroscedastic':'Heteroscedastic: BP {statistic}, p {p}',
|
|
3868
|
+
'regression.homoscedastic':'No heteroscedasticity detected: BP {statistic}, p {p}',
|
|
3731
3869
|
'menu.sortAscending':'Sort ascending',
|
|
3732
3870
|
'menu.sortDescending':'Sort descending',
|
|
3733
3871
|
'menu.clearSort':'Clear sort',
|
|
@@ -7116,6 +7254,392 @@ return String(data);
|
|
|
7116
7254
|
const identities=new WeakMap();
|
|
7117
7255
|
let identitySeq=0;
|
|
7118
7256
|
});
|
|
7257
|
+
__def("packages/core/src/model/shadow.js",function(__exports,__req){
|
|
7258
|
+
'use strict';
|
|
7259
|
+
Object.defineProperty(__exports,"MAX_TRACKED",{enumerable:true,get:function(){return MAX_TRACKED;}});
|
|
7260
|
+
Object.defineProperty(__exports,"DEFAULT_DEPTH",{enumerable:true,get:function(){return DEFAULT_DEPTH;}});
|
|
7261
|
+
Object.defineProperty(__exports,"SHADOW_KINDS",{enumerable:true,get:function(){return SHADOW_KINDS;}});
|
|
7262
|
+
Object.defineProperty(__exports,"ROLLING_KINDS",{enumerable:true,get:function(){return ROLLING_KINDS;}});
|
|
7263
|
+
Object.defineProperty(__exports,"FIT_SHADOW_KINDS",{enumerable:true,get:function(){return FIT_SHADOW_KINDS;}});
|
|
7264
|
+
Object.defineProperty(__exports,"MAD_SCALE",{enumerable:true,get:function(){return MAD_SCALE;}});
|
|
7265
|
+
Object.defineProperty(__exports,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:true,get:function(){return DEFAULT_ANOMALY_THRESHOLD;}});
|
|
7266
|
+
Object.defineProperty(__exports,"SPEC_STATUS",{enumerable:true,get:function(){return SPEC_STATUS;}});
|
|
7267
|
+
Object.defineProperty(__exports,"POSITIONAL_KINDS",{enumerable:true,get:function(){return POSITIONAL_KINDS;}});
|
|
7268
|
+
Object.defineProperty(__exports,"SHADOW_LABELS",{enumerable:true,get:function(){return SHADOW_LABELS;}});
|
|
7269
|
+
Object.defineProperty(__exports,"specStatusOf",{enumerable:true,get:function(){return specStatusOf;}});
|
|
7270
|
+
Object.defineProperty(__exports,"ShadowTracker",{enumerable:true,get:function(){return ShadowTracker;}});
|
|
7271
|
+
Object.defineProperty(__exports,"shadowsIn",{enumerable:true,get:function(){return shadowsIn;}});
|
|
7272
|
+
const MAX_TRACKED=200_000;
|
|
7273
|
+
const DEFAULT_DEPTH=20;
|
|
7274
|
+
const SHADOW_KINDS=Object.freeze([
|
|
7275
|
+
'updates','updatedAt','sinceUpdate','delta','deltaPercent',
|
|
7276
|
+
'rate','history','firstValue','streak',
|
|
7277
|
+
'rank','rankAsc','rankChange','percentile','quartile','zScore','shareOfTotal',
|
|
7278
|
+
'anomalyScore','anomalyFlag',
|
|
7279
|
+
'specStatus',
|
|
7280
|
+
'rollingSum','rollingAvg','rollingMin','rollingMax','windowCoverage',
|
|
7281
|
+
'cumulativeToDate','periodOverPeriod',
|
|
7282
|
+
'rollingQuantile','windowApproximate',
|
|
7283
|
+
'tsTrend','tsSeasonal','tsResidual','tsCoverage',
|
|
7284
|
+
'tsSmoothed','tsSmoothingAlpha','tsSmoothingBeta',
|
|
7285
|
+
'fitPredicted','fitResidual','fitInfluence',
|
|
7286
|
+
'fitStdResidual','fitLeverage','fitCooksD',
|
|
7287
|
+
]);
|
|
7288
|
+
const ROLLING_KINDS=Object.freeze([
|
|
7289
|
+
'rollingSum','rollingAvg','rollingMin','rollingMax','windowCoverage',
|
|
7290
|
+
'cumulativeToDate','periodOverPeriod',
|
|
7291
|
+
'rollingQuantile','windowApproximate',
|
|
7292
|
+
'tsTrend','tsSeasonal','tsResidual','tsCoverage',
|
|
7293
|
+
'tsSmoothed','tsSmoothingAlpha','tsSmoothingBeta',
|
|
7294
|
+
]);
|
|
7295
|
+
const FIT_SHADOW_KINDS=Object.freeze([
|
|
7296
|
+
'fitPredicted','fitResidual','fitInfluence',
|
|
7297
|
+
'fitStdResidual','fitLeverage','fitCooksD',
|
|
7298
|
+
]);
|
|
7299
|
+
const MAD_SCALE=0.6745;
|
|
7300
|
+
const DEFAULT_ANOMALY_THRESHOLD=3.5;
|
|
7301
|
+
const SPEC_STATUS=Object.freeze({PASS:'PASS',WARN:'WARN',FAIL:'FAIL'});
|
|
7302
|
+
const POSITIONAL_KINDS=Object.freeze([
|
|
7303
|
+
'rank','rankAsc','rankChange','percentile','quartile','zScore','shareOfTotal',
|
|
7304
|
+
'anomalyScore','anomalyFlag',
|
|
7305
|
+
]);
|
|
7306
|
+
const SHADOW_LABELS=Object.freeze({
|
|
7307
|
+
updates:'Updates',
|
|
7308
|
+
updatedAt:'Updated at',
|
|
7309
|
+
sinceUpdate:'Since update',
|
|
7310
|
+
delta:'Change',
|
|
7311
|
+
deltaPercent:'Change %',
|
|
7312
|
+
rate:'Rate of change',
|
|
7313
|
+
history:'History',
|
|
7314
|
+
firstValue:'Baseline',
|
|
7315
|
+
streak:'Streak',
|
|
7316
|
+
rank:'Rank',
|
|
7317
|
+
rankAsc:'Rank, ascending',
|
|
7318
|
+
rankChange:'Rank change',
|
|
7319
|
+
percentile:'Percentile',
|
|
7320
|
+
quartile:'Quartile',
|
|
7321
|
+
zScore:'Z-score',
|
|
7322
|
+
shareOfTotal:'Share of total',
|
|
7323
|
+
anomalyScore:'Anomaly score',
|
|
7324
|
+
anomalyFlag:'Anomaly',
|
|
7325
|
+
specStatus:'Spec status',
|
|
7326
|
+
rollingSum:'Rolling sum',
|
|
7327
|
+
rollingAvg:'Rolling average',
|
|
7328
|
+
rollingMin:'Rolling minimum',
|
|
7329
|
+
rollingMax:'Rolling maximum',
|
|
7330
|
+
windowCoverage:'Window coverage',
|
|
7331
|
+
cumulativeToDate:'Cumulative to date',
|
|
7332
|
+
periodOverPeriod:'Period over period',
|
|
7333
|
+
rollingQuantile:'Rolling quantile',
|
|
7334
|
+
windowApproximate:'Window approximate',
|
|
7335
|
+
tsTrend:'Trend',
|
|
7336
|
+
tsSeasonal:'Seasonal',
|
|
7337
|
+
tsResidual:'Seasonal residual',
|
|
7338
|
+
tsCoverage:'Decomposition coverage',
|
|
7339
|
+
tsSmoothed:'Smoothed',
|
|
7340
|
+
tsSmoothingAlpha:'Smoothing α',
|
|
7341
|
+
tsSmoothingBeta:'Smoothing β',
|
|
7342
|
+
fitPredicted:'Predicted',
|
|
7343
|
+
fitResidual:'Residual',
|
|
7344
|
+
fitInfluence:'Influence',
|
|
7345
|
+
fitStdResidual:'Std. residual',
|
|
7346
|
+
fitLeverage:'Leverage',
|
|
7347
|
+
fitCooksD:"Cook's D",
|
|
7348
|
+
});
|
|
7349
|
+
function specStatusOf(value,spec){
|
|
7350
|
+
if(!spec)return null;
|
|
7351
|
+
const lower=Number.isFinite(Number(spec.lower))?Number(spec.lower):null;
|
|
7352
|
+
const upper=Number.isFinite(Number(spec.upper))?Number(spec.upper):null;
|
|
7353
|
+
if(lower===null&&upper===null)return null;
|
|
7354
|
+
if(!Number.isFinite(value))return null;
|
|
7355
|
+
if(lower!==null&&value<lower)return SPEC_STATUS.FAIL;
|
|
7356
|
+
if(upper!==null&&value>upper)return SPEC_STATUS.FAIL;
|
|
7357
|
+
const warnLower=Number.isFinite(Number(spec.warnLower))?Number(spec.warnLower):null;
|
|
7358
|
+
const warnUpper=Number.isFinite(Number(spec.warnUpper))?Number(spec.warnUpper):null;
|
|
7359
|
+
if(warnLower!==null&&value<warnLower)return SPEC_STATUS.WARN;
|
|
7360
|
+
if(warnUpper!==null&&value>warnUpper)return SPEC_STATUS.WARN;
|
|
7361
|
+
return SPEC_STATUS.PASS;
|
|
7362
|
+
}
|
|
7363
|
+
class ShadowTracker{
|
|
7364
|
+
#colId;
|
|
7365
|
+
#baseline=new Map();
|
|
7366
|
+
#latest=new Map();
|
|
7367
|
+
#counts=new Map();
|
|
7368
|
+
#stamps=new Map();
|
|
7369
|
+
#history=new Map();
|
|
7370
|
+
#streaks=new Map();
|
|
7371
|
+
#forgotten=0;
|
|
7372
|
+
#depth;
|
|
7373
|
+
#max;
|
|
7374
|
+
#now;
|
|
7375
|
+
#summary=null;
|
|
7376
|
+
#filtered=null;
|
|
7377
|
+
constructor(opts){
|
|
7378
|
+
this.#colId=opts.colId;
|
|
7379
|
+
this.#depth=Math.max(2,opts.depth||DEFAULT_DEPTH);
|
|
7380
|
+
this.#max=Math.max(1,opts.max||MAX_TRACKED);
|
|
7381
|
+
this.#now=opts.now||(()=>Date.now());
|
|
7382
|
+
}
|
|
7383
|
+
get colId(){return this.#colId;}
|
|
7384
|
+
get forgotten(){return this.#forgotten;}
|
|
7385
|
+
get size(){return this.#latest.size;}
|
|
7386
|
+
observe(key,raw){
|
|
7387
|
+
const value=toNumber(raw);
|
|
7388
|
+
if(value===null)return;
|
|
7389
|
+
if(!this.#latest.has(key)){
|
|
7390
|
+
this.#summary=null;
|
|
7391
|
+
this.#filtered=null;
|
|
7392
|
+
this.#evictIfFull();
|
|
7393
|
+
this.#baseline.set(key,value);
|
|
7394
|
+
this.#latest.set(key,value);
|
|
7395
|
+
this.#counts.set(key,0);
|
|
7396
|
+
this.#stamps.set(key,this.#now());
|
|
7397
|
+
this.#history.set(key,[value]);
|
|
7398
|
+
this.#streaks.set(key,0);
|
|
7399
|
+
return;
|
|
7400
|
+
}
|
|
7401
|
+
const previous=this.#latest.get(key);
|
|
7402
|
+
if(previous===value)return;
|
|
7403
|
+
this.#summary=null;
|
|
7404
|
+
this.#filtered=null;
|
|
7405
|
+
this.#latest.set(key,value);
|
|
7406
|
+
this.#counts.set(key,(this.#counts.get(key)||0)+1);
|
|
7407
|
+
this.#stamps.set(key,this.#now());
|
|
7408
|
+
const readings=this.#history.get(key)||[];
|
|
7409
|
+
readings.push(value);
|
|
7410
|
+
if(readings.length>this.#depth)readings.splice(0,readings.length-this.#depth);
|
|
7411
|
+
this.#history.set(key,readings);
|
|
7412
|
+
const direction=Math.sign(value-previous);
|
|
7413
|
+
const streak=this.#streaks.get(key)||0;
|
|
7414
|
+
this.#streaks.set(key,Math.sign(streak)===direction?streak+direction:direction);
|
|
7415
|
+
}
|
|
7416
|
+
#evictIfFull(){
|
|
7417
|
+
if(this.#latest.size<this.#max)return;
|
|
7418
|
+
const oldest=this.#latest.keys().next().value;
|
|
7419
|
+
if(oldest===undefined)return;
|
|
7420
|
+
this.#baseline.delete(oldest);
|
|
7421
|
+
this.#latest.delete(oldest);
|
|
7422
|
+
this.#counts.delete(oldest);
|
|
7423
|
+
this.#stamps.delete(oldest);
|
|
7424
|
+
this.#history.delete(oldest);
|
|
7425
|
+
this.#streaks.delete(oldest);
|
|
7426
|
+
this.#forgotten++;
|
|
7427
|
+
}
|
|
7428
|
+
rebase(){
|
|
7429
|
+
for(const[key,value]of this.#latest)this.#baseline.set(key,value);
|
|
7430
|
+
this.#summary=null;
|
|
7431
|
+
this.#filtered=null;
|
|
7432
|
+
}
|
|
7433
|
+
reset(){
|
|
7434
|
+
this.#baseline.clear();
|
|
7435
|
+
this.#latest.clear();
|
|
7436
|
+
this.#counts.clear();
|
|
7437
|
+
this.#stamps.clear();
|
|
7438
|
+
this.#history.clear();
|
|
7439
|
+
this.#streaks.clear();
|
|
7440
|
+
this.#forgotten=0;
|
|
7441
|
+
this.#summary=null;
|
|
7442
|
+
this.#filtered=null;
|
|
7443
|
+
}
|
|
7444
|
+
retain(keys){
|
|
7445
|
+
const living=keys instanceof Set?keys:new Set(keys);
|
|
7446
|
+
let dropped=0;
|
|
7447
|
+
for(const key of[...this.#latest.keys()]){
|
|
7448
|
+
if(living.has(key))continue;
|
|
7449
|
+
this.#baseline.delete(key);
|
|
7450
|
+
this.#latest.delete(key);
|
|
7451
|
+
this.#counts.delete(key);
|
|
7452
|
+
this.#stamps.delete(key);
|
|
7453
|
+
this.#history.delete(key);
|
|
7454
|
+
this.#streaks.delete(key);
|
|
7455
|
+
dropped++;
|
|
7456
|
+
}
|
|
7457
|
+
if(dropped){this.#summary=null;this.#filtered=null;}
|
|
7458
|
+
return dropped;
|
|
7459
|
+
}
|
|
7460
|
+
read(kind,key,only,spec){
|
|
7461
|
+
switch(kind){
|
|
7462
|
+
case'updates':
|
|
7463
|
+
return this.#counts.has(key)?this.#counts.get(key):0;
|
|
7464
|
+
case'updatedAt':{
|
|
7465
|
+
const at=this.#stamps.get(key);
|
|
7466
|
+
return at===undefined?null:new Date(at);
|
|
7467
|
+
}
|
|
7468
|
+
case'sinceUpdate':{
|
|
7469
|
+
const at=this.#stamps.get(key);
|
|
7470
|
+
return at===undefined?null:this.#now()-at;
|
|
7471
|
+
}
|
|
7472
|
+
case'firstValue':
|
|
7473
|
+
return this.#baseline.has(key)?this.#baseline.get(key):null;
|
|
7474
|
+
case'delta':{
|
|
7475
|
+
if(!this.#latest.has(key))return null;
|
|
7476
|
+
return this.#latest.get(key)-this.#baseline.get(key);
|
|
7477
|
+
}
|
|
7478
|
+
case'deltaPercent':{
|
|
7479
|
+
if(!this.#latest.has(key))return null;
|
|
7480
|
+
const base=this.#baseline.get(key);
|
|
7481
|
+
if(!base)return null;
|
|
7482
|
+
return((this.#latest.get(key)-base)/Math.abs(base))*100;
|
|
7483
|
+
}
|
|
7484
|
+
case'rate':{
|
|
7485
|
+
const readings=this.#history.get(key);
|
|
7486
|
+
const at=this.#stamps.get(key);
|
|
7487
|
+
if(!readings||readings.length<2||at===undefined)return null;
|
|
7488
|
+
const elapsed=this.#now()-at;
|
|
7489
|
+
const change=readings[readings.length-1]-readings[readings.length-2];
|
|
7490
|
+
return elapsed>0?(change/elapsed)*1000:change;
|
|
7491
|
+
}
|
|
7492
|
+
case'history':
|
|
7493
|
+
return this.#history.has(key)?[...this.#history.get(key)]:null;
|
|
7494
|
+
case'streak':
|
|
7495
|
+
return this.#streaks.has(key)?this.#streaks.get(key):0;
|
|
7496
|
+
case'specStatus':{
|
|
7497
|
+
if(!this.#latest.has(key))return null;
|
|
7498
|
+
return specStatusOf(this.#latest.get(key),spec);
|
|
7499
|
+
}
|
|
7500
|
+
default:
|
|
7501
|
+
return POSITIONAL_KINDS.includes(kind)?this.#position(kind,key,only,spec):null;
|
|
7502
|
+
}
|
|
7503
|
+
}
|
|
7504
|
+
#view(only){
|
|
7505
|
+
if(only){
|
|
7506
|
+
if(this.#filtered&&this.#filtered.only===only)return this.#filtered.view;
|
|
7507
|
+
const view=this.#build(only);
|
|
7508
|
+
this.#filtered={only,view};
|
|
7509
|
+
return view;
|
|
7510
|
+
}
|
|
7511
|
+
if(this.#summary)return this.#summary;
|
|
7512
|
+
this.#summary=this.#build(null);
|
|
7513
|
+
return this.#summary;
|
|
7514
|
+
}
|
|
7515
|
+
#build(only){
|
|
7516
|
+
const values=[];
|
|
7517
|
+
for(const[key,value]of this.#latest){
|
|
7518
|
+
if(only&&!only.has(key))continue;
|
|
7519
|
+
values.push(value);
|
|
7520
|
+
}
|
|
7521
|
+
const sorted=values.sort((a,b)=>a-b);
|
|
7522
|
+
let n=0;
|
|
7523
|
+
let mean=0;
|
|
7524
|
+
let m2=0;
|
|
7525
|
+
let sum=0;
|
|
7526
|
+
for(const x of sorted){
|
|
7527
|
+
sum+=x;
|
|
7528
|
+
n++;
|
|
7529
|
+
const delta=x-mean;
|
|
7530
|
+
mean+=delta/n;
|
|
7531
|
+
m2+=delta*(x-mean);
|
|
7532
|
+
}
|
|
7533
|
+
const baseline=[];
|
|
7534
|
+
for(const[key,value]of this.#baseline){
|
|
7535
|
+
if(only&&!only.has(key))continue;
|
|
7536
|
+
baseline.push(value);
|
|
7537
|
+
}
|
|
7538
|
+
const median=n?medianSorted(sorted):0;
|
|
7539
|
+
const deviations=sorted.map((v)=>Math.abs(v-median)).sort((a,b)=>a-b);
|
|
7540
|
+
const mad=n?medianSorted(deviations):0;
|
|
7541
|
+
return{
|
|
7542
|
+
sorted,
|
|
7543
|
+
baseline:baseline.sort((a,b)=>a-b),
|
|
7544
|
+
sum,
|
|
7545
|
+
mean:n?mean:0,
|
|
7546
|
+
sd:n>1?Math.sqrt(m2/(n-1)):0,
|
|
7547
|
+
median,
|
|
7548
|
+
mad,
|
|
7549
|
+
};
|
|
7550
|
+
}
|
|
7551
|
+
#position(kind,key,only,spec){
|
|
7552
|
+
if(!this.#latest.has(key))return null;
|
|
7553
|
+
if(only&&!only.has(key))return null;
|
|
7554
|
+
const value=this.#latest.get(key);
|
|
7555
|
+
const view=this.#view(only);
|
|
7556
|
+
const n=view.sorted.length;
|
|
7557
|
+
if(!n)return null;
|
|
7558
|
+
switch(kind){
|
|
7559
|
+
case'rank':return n-upperBound(view.sorted,value)+1;
|
|
7560
|
+
case'rankAsc':return lowerBound(view.sorted,value)+1;
|
|
7561
|
+
case'rankChange':{
|
|
7562
|
+
if(!this.#baseline.has(key)||!view.baseline.length)return null;
|
|
7563
|
+
const was=view.baseline.length-upperBound(view.baseline,this.#baseline.get(key))+1;
|
|
7564
|
+
const now=n-upperBound(view.sorted,value)+1;
|
|
7565
|
+
return was-now;
|
|
7566
|
+
}
|
|
7567
|
+
case'percentile':return(upperBound(view.sorted,value)/n)*100;
|
|
7568
|
+
case'quartile':{
|
|
7569
|
+
const share=upperBound(view.sorted,value)/n;
|
|
7570
|
+
return Math.min(4,Math.max(1,Math.ceil(share*4)));
|
|
7571
|
+
}
|
|
7572
|
+
case'zScore':return view.sd?(value-view.mean)/view.sd:null;
|
|
7573
|
+
case'anomalyScore':
|
|
7574
|
+
return view.mad?(MAD_SCALE*(value-view.median))/view.mad:null;
|
|
7575
|
+
case'anomalyFlag':{
|
|
7576
|
+
if(!view.mad)return null;
|
|
7577
|
+
const threshold=spec&&Number.isFinite(Number(spec.threshold))
|
|
7578
|
+
?Number(spec.threshold):DEFAULT_ANOMALY_THRESHOLD;
|
|
7579
|
+
return Math.abs((MAD_SCALE*(value-view.median))/view.mad)>threshold;
|
|
7580
|
+
}
|
|
7581
|
+
case'shareOfTotal':return view.sum?(value/view.sum)*100:null;
|
|
7582
|
+
default:return null;
|
|
7583
|
+
}
|
|
7584
|
+
}
|
|
7585
|
+
}
|
|
7586
|
+
function medianSorted(sorted){
|
|
7587
|
+
const n=sorted.length;
|
|
7588
|
+
if(!n)return 0;
|
|
7589
|
+
const h=(n-1)*0.5;
|
|
7590
|
+
const lo=Math.floor(h);
|
|
7591
|
+
const hi=Math.ceil(h);
|
|
7592
|
+
return lo===hi?sorted[lo]:sorted[lo]+(h-lo)*(sorted[hi]-sorted[lo]);
|
|
7593
|
+
}
|
|
7594
|
+
function lowerBound(sorted,value){
|
|
7595
|
+
let lo=0;
|
|
7596
|
+
let hi=sorted.length;
|
|
7597
|
+
while(lo<hi){
|
|
7598
|
+
const mid=(lo+hi)>>1;
|
|
7599
|
+
if(sorted[mid]<value)lo=mid+1;
|
|
7600
|
+
else hi=mid;
|
|
7601
|
+
}
|
|
7602
|
+
return lo;
|
|
7603
|
+
}
|
|
7604
|
+
function upperBound(sorted,value){
|
|
7605
|
+
let lo=0;
|
|
7606
|
+
let hi=sorted.length;
|
|
7607
|
+
while(lo<hi){
|
|
7608
|
+
const mid=(lo+hi)>>1;
|
|
7609
|
+
if(sorted[mid]<=value)lo=mid+1;
|
|
7610
|
+
else hi=mid;
|
|
7611
|
+
}
|
|
7612
|
+
return lo;
|
|
7613
|
+
}
|
|
7614
|
+
function toNumber(raw){
|
|
7615
|
+
if(raw===null||raw===undefined||raw==='')return null;
|
|
7616
|
+
if(raw instanceof Date){
|
|
7617
|
+
const t=raw.getTime();
|
|
7618
|
+
return Number.isFinite(t)?t:null;
|
|
7619
|
+
}
|
|
7620
|
+
const n=typeof raw==='number'?raw:Number(raw);
|
|
7621
|
+
return Number.isFinite(n)?n:null;
|
|
7622
|
+
}
|
|
7623
|
+
function shadowsIn(columns){
|
|
7624
|
+
const out=[];
|
|
7625
|
+
for(const column of columns||[]){
|
|
7626
|
+
const declared=column.shadow;
|
|
7627
|
+
if(!declared)continue;
|
|
7628
|
+
const spec=typeof declared==='string'?{kind:declared}:declared;
|
|
7629
|
+
const kind=spec.kind;
|
|
7630
|
+
if(!SHADOW_KINDS.includes(kind))continue;
|
|
7631
|
+
if(ROLLING_KINDS.includes(kind))continue;
|
|
7632
|
+
if(FIT_SHADOW_KINDS.includes(kind))continue;
|
|
7633
|
+
out.push({
|
|
7634
|
+
colId:column.id||column.field,
|
|
7635
|
+
of:spec.of||column.field||column.id,
|
|
7636
|
+
kind,
|
|
7637
|
+
depth:spec.depth,
|
|
7638
|
+
});
|
|
7639
|
+
}
|
|
7640
|
+
return out;
|
|
7641
|
+
}
|
|
7642
|
+
});
|
|
7119
7643
|
__def("packages/core/src/columns/model.js",function(__exports,__req){
|
|
7120
7644
|
'use strict';
|
|
7121
7645
|
Object.defineProperty(__exports,"BUILTIN_DEFAULTS",{enumerable:true,get:function(){return BUILTIN_DEFAULTS;}});
|
|
@@ -7154,6 +7678,8 @@ const __m6=__req("packages/core/src/columns/value.js");
|
|
|
7154
7678
|
const compileDisplay=__m6["compileDisplay"];
|
|
7155
7679
|
const ValuePipeline=__m6["ValuePipeline"];
|
|
7156
7680
|
const warnImpureUse=__m6["warnImpureUse"];
|
|
7681
|
+
const __m7=__req("packages/core/src/model/shadow.js");
|
|
7682
|
+
const FIT_SHADOW_KINDS=__m7["FIT_SHADOW_KINDS"];
|
|
7157
7683
|
const BUILTIN_DEFAULTS={
|
|
7158
7684
|
value:{pure:true},
|
|
7159
7685
|
cell:{},
|
|
@@ -7339,15 +7865,29 @@ const id=def.id||def.field||uid('col');
|
|
|
7339
7865
|
if(def.shadow&&!isFunction(m.value&&m.value.compute)){
|
|
7340
7866
|
const spec=typeof def.shadow==='string'?{kind:def.shadow}:def.shadow;
|
|
7341
7867
|
const watched=spec.of||def.field||id;
|
|
7868
|
+
const isFit=FIT_SHADOW_KINDS.includes(spec.kind);
|
|
7869
|
+
const modelSpec=isFit?(spec.model||spec):null;
|
|
7870
|
+
const fitDeps=isFit&&modelSpec
|
|
7871
|
+
?[...(Array.isArray(modelSpec.predictors)?modelSpec.predictors:[]),
|
|
7872
|
+
modelSpec.response].filter(Boolean)
|
|
7873
|
+
:null;
|
|
7342
7874
|
m.value={
|
|
7343
7875
|
...(m.value||{}),
|
|
7344
|
-
deps:
|
|
7876
|
+
deps:(fitDeps&&fitDeps.length)
|
|
7877
|
+
?fitDeps
|
|
7878
|
+
:(spec.orderBy&&spec.orderBy!==watched?[watched,spec.orderBy]:[watched]),
|
|
7345
7879
|
pure:false,
|
|
7346
7880
|
compute:(deps,ctx)=>{
|
|
7347
7881
|
const api=ctx.grid&&ctx.grid.statistics;
|
|
7348
7882
|
if(!api)return null;
|
|
7349
7883
|
const key=(ctx.row&&ctx.row.key)||api.keyOf(ctx.data);
|
|
7350
|
-
|
|
7884
|
+
if(!key)return null;
|
|
7885
|
+
if(isFit){
|
|
7886
|
+
if(!isFunction(api.fitShadow))return null;
|
|
7887
|
+
const fitSpec=spec.model?{...spec.model,threshold:spec.threshold}:spec;
|
|
7888
|
+
return api.fitShadow(spec.kind,key,fitSpec);
|
|
7889
|
+
}
|
|
7890
|
+
return api.shadow(watched,spec.kind,key,spec.scope,spec);
|
|
7351
7891
|
},
|
|
7352
7892
|
};
|
|
7353
7893
|
}
|
|
@@ -7454,6 +7994,15 @@ if(own.type===false)return'text';
|
|
|
7454
7994
|
if(own.type)return own.type;
|
|
7455
7995
|
for(let i=presets.length-1;i>=0;i--)if(presets[i].type)return presets[i].type;
|
|
7456
7996
|
if(this.#defaults.type)return this.#defaults.type;
|
|
7997
|
+
if(own.shadow){
|
|
7998
|
+
const kind=typeof own.shadow==='string'?own.shadow:own.shadow.kind;
|
|
7999
|
+
if(kind==='fitInfluence')return'boolean';
|
|
8000
|
+
if(kind==='fitPredicted'||kind==='fitResidual'||kind==='fitStdResidual'
|
|
8001
|
+
||kind==='fitLeverage'||kind==='fitCooksD')return'number';
|
|
8002
|
+
if(kind==='tsTrend'||kind==='tsSeasonal'||kind==='tsResidual'
|
|
8003
|
+
||kind==='tsCoverage'||kind==='tsSmoothed'||kind==='tsSmoothingAlpha'
|
|
8004
|
+
||kind==='tsSmoothingBeta')return'number';
|
|
8005
|
+
}
|
|
7457
8006
|
if(inferredType)return inferredType;
|
|
7458
8007
|
if(own.lookup)return'lookup';
|
|
7459
8008
|
return'text';
|
|
@@ -7684,6 +8233,238 @@ for(const node of nodes)if(Array.isArray(node.columns))sort(node.columns);
|
|
|
7684
8233
|
};
|
|
7685
8234
|
sort(this.#groups);
|
|
7686
8235
|
}
|
|
8236
|
+
#detachLeaf(colId){
|
|
8237
|
+
const walk=(nodes)=>{
|
|
8238
|
+
for(let i=0;i<nodes.length;i++){
|
|
8239
|
+
const node=nodes[i];
|
|
8240
|
+
if(Array.isArray(node.columns)){
|
|
8241
|
+
const found=walk(node.columns);
|
|
8242
|
+
if(found)return found;
|
|
8243
|
+
}else if(node.column&&node.column.id===colId){
|
|
8244
|
+
return nodes.splice(i,1)[0];
|
|
8245
|
+
}
|
|
8246
|
+
}
|
|
8247
|
+
return null;
|
|
8248
|
+
};
|
|
8249
|
+
return walk(this.#groups);
|
|
8250
|
+
}
|
|
8251
|
+
#pruneEmptyGroups(nodes){
|
|
8252
|
+
const dissolved=[];
|
|
8253
|
+
for(let i=nodes.length-1;i>=0;i--){
|
|
8254
|
+
const node=nodes[i];
|
|
8255
|
+
if(Array.isArray(node.columns)){
|
|
8256
|
+
dissolved.push(...this.#pruneEmptyGroups(node.columns));
|
|
8257
|
+
if(node.columns.length===0){dissolved.push(node.id);nodes.splice(i,1);}
|
|
8258
|
+
}
|
|
8259
|
+
}
|
|
8260
|
+
return dissolved;
|
|
8261
|
+
}
|
|
8262
|
+
#rebuildGroupPaths(){
|
|
8263
|
+
const walk=(nodes,path)=>{
|
|
8264
|
+
for(const node of nodes){
|
|
8265
|
+
if(Array.isArray(node.columns))walk(node.columns,[...path,node.id]);
|
|
8266
|
+
else if(node.column)node.column.groupPath=path;
|
|
8267
|
+
}
|
|
8268
|
+
};
|
|
8269
|
+
walk(this.#groups,[]);
|
|
8270
|
+
}
|
|
8271
|
+
#makeContiguous(ids){
|
|
8272
|
+
const set=new Set(ids);
|
|
8273
|
+
const ordered=this.#order.filter((id)=>set.has(id));
|
|
8274
|
+
if(!ordered.length)return;
|
|
8275
|
+
const anchor=Math.min(...ordered.map((id)=>this.#order.indexOf(id)));
|
|
8276
|
+
const before=this.#order.slice(0,anchor).filter((id)=>!set.has(id));
|
|
8277
|
+
const after=this.#order.slice(anchor).filter((id)=>!set.has(id));
|
|
8278
|
+
this.#order=[...before,...ordered,...after];
|
|
8279
|
+
}
|
|
8280
|
+
#leafIdsUnder(node){
|
|
8281
|
+
const out=[];
|
|
8282
|
+
const walk=(n)=>{
|
|
8283
|
+
if(Array.isArray(n.columns)){for(const child of n.columns)walk(child);}
|
|
8284
|
+
else if(n.column)out.push(n.column.id);
|
|
8285
|
+
};
|
|
8286
|
+
walk(node);
|
|
8287
|
+
return out;
|
|
8288
|
+
}
|
|
8289
|
+
#findGroup(groupId){
|
|
8290
|
+
const walk=(nodes)=>{
|
|
8291
|
+
for(const node of nodes){
|
|
8292
|
+
if(!Array.isArray(node.columns))continue;
|
|
8293
|
+
if(node.id===groupId)return{node,parent:nodes};
|
|
8294
|
+
const found=walk(node.columns);
|
|
8295
|
+
if(found)return found;
|
|
8296
|
+
}
|
|
8297
|
+
return null;
|
|
8298
|
+
};
|
|
8299
|
+
return walk(this.#groups);
|
|
8300
|
+
}
|
|
8301
|
+
groupColumns(ids,opts={}){
|
|
8302
|
+
const list=toArray(ids).filter((id)=>this.#byId.has(id));
|
|
8303
|
+
if(!list.length){
|
|
8304
|
+
warnOnce('columns.group.empty','groupColumns was given no known column ids; nothing was grouped.');
|
|
8305
|
+
return null;
|
|
8306
|
+
}
|
|
8307
|
+
for(const id of list){
|
|
8308
|
+
const column=this.#byId.get(id);
|
|
8309
|
+
if(column.layout.lockPosition){
|
|
8310
|
+
warnOnce(`columns.group.locked:${id}`,`column "${id}" is position-locked and cannot be grouped.`);
|
|
8311
|
+
return null;
|
|
8312
|
+
}
|
|
8313
|
+
}
|
|
8314
|
+
const existing=opts.groupId?this.#findGroup(opts.groupId):null;
|
|
8315
|
+
if(opts.groupId&&!existing){
|
|
8316
|
+
warnOnce(`columns.group.unknown:${opts.groupId}`,`no band "${opts.groupId}" to add to; nothing was grouped.`);
|
|
8317
|
+
return null;
|
|
8318
|
+
}
|
|
8319
|
+
const leaves=list.map((id)=>this.#detachLeaf(id)).filter(Boolean);
|
|
8320
|
+
if(!leaves.length)return null;
|
|
8321
|
+
let groupId;
|
|
8322
|
+
if(existing){
|
|
8323
|
+
existing.node.columns.push(...leaves);
|
|
8324
|
+
groupId=existing.node.id;
|
|
8325
|
+
}else{
|
|
8326
|
+
const node={
|
|
8327
|
+
id:uid('grp'),
|
|
8328
|
+
title:opts.title||'',
|
|
8329
|
+
collapsible:false,
|
|
8330
|
+
openByDefault:true,
|
|
8331
|
+
showWhen:'always',
|
|
8332
|
+
marryChildren:false,
|
|
8333
|
+
header:{},
|
|
8334
|
+
def:{},
|
|
8335
|
+
columns:leaves,
|
|
8336
|
+
};
|
|
8337
|
+
const at=Number.isInteger(opts.at)
|
|
8338
|
+
?Math.max(0,Math.min(opts.at,this.#groups.length))
|
|
8339
|
+
:this.#groups.length;
|
|
8340
|
+
this.#groups.splice(at,0,node);
|
|
8341
|
+
groupId=node.id;
|
|
8342
|
+
}
|
|
8343
|
+
this.#pruneEmptyGroups(this.#groups);
|
|
8344
|
+
this.#makeContiguous(list);
|
|
8345
|
+
this.#rebuildGroupPaths();
|
|
8346
|
+
this.#reorderGroups();
|
|
8347
|
+
if(this.#onChange)this.#onChange('columngroup',{action:'formed',groupId,ids:list});
|
|
8348
|
+
return groupId;
|
|
8349
|
+
}
|
|
8350
|
+
ungroupColumn(id){
|
|
8351
|
+
const column=this.#byId.get(id);
|
|
8352
|
+
if(!column){warnOnce(`columns.ungroup.unknown:${id}`,`no column "${id}" to ungroup.`);return;}
|
|
8353
|
+
const path=column.groupPath||[];
|
|
8354
|
+
if(!path.length)return;
|
|
8355
|
+
const parentId=path[path.length-1];
|
|
8356
|
+
const found=this.#findGroup(parentId);
|
|
8357
|
+
if(!found)return;
|
|
8358
|
+
const leaf=this.#detachLeaf(id);
|
|
8359
|
+
if(!leaf)return;
|
|
8360
|
+
const at=found.parent.indexOf(found.node);
|
|
8361
|
+
found.parent.splice(at+1,0,leaf);
|
|
8362
|
+
const dissolved=this.#pruneEmptyGroups(this.#groups);
|
|
8363
|
+
const survivors=this.#leafIdsUnder(found.node);
|
|
8364
|
+
if(survivors.length){
|
|
8365
|
+
this.#makeContiguous(survivors);
|
|
8366
|
+
const last=Math.max(...survivors.map((sid)=>this.#order.indexOf(sid)));
|
|
8367
|
+
const rest=this.#order.filter((oid)=>oid!==id);
|
|
8368
|
+
rest.splice(last+1,0,id);
|
|
8369
|
+
this.#order=rest;
|
|
8370
|
+
}
|
|
8371
|
+
this.#rebuildGroupPaths();
|
|
8372
|
+
this.#reorderGroups();
|
|
8373
|
+
if(this.#onChange)this.#onChange('columngroup',{action:'removed',id,dissolved});
|
|
8374
|
+
}
|
|
8375
|
+
renameGroup(groupId,title){
|
|
8376
|
+
const found=this.#findGroup(groupId);
|
|
8377
|
+
if(!found){warnOnce(`columns.group.rename:${groupId}`,`no band "${groupId}" to rename.`);return;}
|
|
8378
|
+
found.node.title=String(title??'');
|
|
8379
|
+
if(this.#onChange)this.#onChange('columngroup',{action:'renamed',groupId,title:found.node.title});
|
|
8380
|
+
}
|
|
8381
|
+
dissolveGroup(groupId){
|
|
8382
|
+
const found=this.#findGroup(groupId);
|
|
8383
|
+
if(!found){warnOnce(`columns.group.dissolve:${groupId}`,`no band "${groupId}" to dissolve.`);return;}
|
|
8384
|
+
const at=found.parent.indexOf(found.node);
|
|
8385
|
+
found.parent.splice(at,1,...found.node.columns);
|
|
8386
|
+
this.#rebuildGroupPaths();
|
|
8387
|
+
this.#reorderGroups();
|
|
8388
|
+
if(this.#onChange)this.#onChange('columngroup',{action:'dissolved',groupId});
|
|
8389
|
+
}
|
|
8390
|
+
moveGroup(groupId,to){
|
|
8391
|
+
const found=this.#findGroup(groupId);
|
|
8392
|
+
if(!found){warnOnce(`columns.group.move:${groupId}`,`no band "${groupId}" to move.`);return;}
|
|
8393
|
+
const siblings=found.parent;
|
|
8394
|
+
const from=siblings.indexOf(found.node);
|
|
8395
|
+
if(from===-1)return;
|
|
8396
|
+
siblings.splice(from,1);
|
|
8397
|
+
siblings.splice(Math.max(0,Math.min(to,siblings.length)),0,found.node);
|
|
8398
|
+
this.#reflowGroupOrder();
|
|
8399
|
+
this.#rebuildGroupPaths();
|
|
8400
|
+
if(this.#onChange)this.#onChange('columngroup',{action:'moved',groupId,to});
|
|
8401
|
+
}
|
|
8402
|
+
#reflowGroupOrder(){
|
|
8403
|
+
const flat=[];
|
|
8404
|
+
const collect=(nodes)=>{
|
|
8405
|
+
for(const node of nodes){
|
|
8406
|
+
if(Array.isArray(node.columns))collect(node.columns);
|
|
8407
|
+
else if(node.column)flat.push(node.column.id);
|
|
8408
|
+
}
|
|
8409
|
+
};
|
|
8410
|
+
collect(this.#groups);
|
|
8411
|
+
const seen=new Set(flat);
|
|
8412
|
+
this.#order=[...flat,...this.#order.filter((id)=>!seen.has(id))];
|
|
8413
|
+
}
|
|
8414
|
+
groupTree(){
|
|
8415
|
+
const project=(nodes)=>nodes.map((node)=>{
|
|
8416
|
+
if(Array.isArray(node.columns)){
|
|
8417
|
+
return{
|
|
8418
|
+
id:node.id,
|
|
8419
|
+
title:node.title||'',
|
|
8420
|
+
collapsible:!!node.collapsible,
|
|
8421
|
+
openByDefault:node.openByDefault!==false,
|
|
8422
|
+
columns:project(node.columns),
|
|
8423
|
+
};
|
|
8424
|
+
}
|
|
8425
|
+
return node.column?node.column.id:null;
|
|
8426
|
+
}).filter((n)=>n!==null);
|
|
8427
|
+
const tree=project(this.#groups);
|
|
8428
|
+
return tree.some((n)=>n&&typeof n==='object')?tree:[];
|
|
8429
|
+
}
|
|
8430
|
+
applyGroupTree(tree){
|
|
8431
|
+
if(!Array.isArray(tree))return;
|
|
8432
|
+
const placed=new Set();
|
|
8433
|
+
const build=(nodes)=>{
|
|
8434
|
+
const out=[];
|
|
8435
|
+
for(const node of nodes){
|
|
8436
|
+
if(node&&typeof node==='object'&&Array.isArray(node.columns)){
|
|
8437
|
+
const children=build(node.columns);
|
|
8438
|
+
if(!children.length)continue;
|
|
8439
|
+
out.push({
|
|
8440
|
+
id:node.id||uid('grp'),
|
|
8441
|
+
title:node.title||'',
|
|
8442
|
+
collapsible:node.collapsible===true,
|
|
8443
|
+
openByDefault:node.openByDefault!==false,
|
|
8444
|
+
showWhen:'always',
|
|
8445
|
+
marryChildren:false,
|
|
8446
|
+
header:{},
|
|
8447
|
+
def:{},
|
|
8448
|
+
columns:children,
|
|
8449
|
+
});
|
|
8450
|
+
}else if(typeof node==='string'){
|
|
8451
|
+
const column=this.#byId.get(node);
|
|
8452
|
+
if(column&&!placed.has(node)){placed.add(node);out.push({column,path:[]});}
|
|
8453
|
+
}
|
|
8454
|
+
}
|
|
8455
|
+
return out;
|
|
8456
|
+
};
|
|
8457
|
+
const built=build(tree);
|
|
8458
|
+
for(const id of this.#order){
|
|
8459
|
+
if(placed.has(id))continue;
|
|
8460
|
+
const column=this.#byId.get(id);
|
|
8461
|
+
if(column)built.push({column,path:[]});
|
|
8462
|
+
}
|
|
8463
|
+
this.#groups=built;
|
|
8464
|
+
this.#rebuildGroupPaths();
|
|
8465
|
+
this.#reorderGroups();
|
|
8466
|
+
if(this.#onChange)this.#onChange('columngroup',{action:'applied'});
|
|
8467
|
+
}
|
|
7687
8468
|
show(ids){this.#setHidden(ids,false);}
|
|
7688
8469
|
hide(ids){this.#setHidden(ids,true);}
|
|
7689
8470
|
#setHidden(ids,hidden){
|
|
@@ -8024,348 +8805,6 @@ this.#onChange();
|
|
|
8024
8805
|
}
|
|
8025
8806
|
const __default=DetailModel;
|
|
8026
8807
|
});
|
|
8027
|
-
__def("packages/core/src/model/shadow.js",function(__exports,__req){
|
|
8028
|
-
'use strict';
|
|
8029
|
-
Object.defineProperty(__exports,"MAX_TRACKED",{enumerable:true,get:function(){return MAX_TRACKED;}});
|
|
8030
|
-
Object.defineProperty(__exports,"DEFAULT_DEPTH",{enumerable:true,get:function(){return DEFAULT_DEPTH;}});
|
|
8031
|
-
Object.defineProperty(__exports,"SHADOW_KINDS",{enumerable:true,get:function(){return SHADOW_KINDS;}});
|
|
8032
|
-
Object.defineProperty(__exports,"MAD_SCALE",{enumerable:true,get:function(){return MAD_SCALE;}});
|
|
8033
|
-
Object.defineProperty(__exports,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:true,get:function(){return DEFAULT_ANOMALY_THRESHOLD;}});
|
|
8034
|
-
Object.defineProperty(__exports,"SPEC_STATUS",{enumerable:true,get:function(){return SPEC_STATUS;}});
|
|
8035
|
-
Object.defineProperty(__exports,"POSITIONAL_KINDS",{enumerable:true,get:function(){return POSITIONAL_KINDS;}});
|
|
8036
|
-
Object.defineProperty(__exports,"SHADOW_LABELS",{enumerable:true,get:function(){return SHADOW_LABELS;}});
|
|
8037
|
-
Object.defineProperty(__exports,"specStatusOf",{enumerable:true,get:function(){return specStatusOf;}});
|
|
8038
|
-
Object.defineProperty(__exports,"ShadowTracker",{enumerable:true,get:function(){return ShadowTracker;}});
|
|
8039
|
-
Object.defineProperty(__exports,"shadowsIn",{enumerable:true,get:function(){return shadowsIn;}});
|
|
8040
|
-
const MAX_TRACKED=200_000;
|
|
8041
|
-
const DEFAULT_DEPTH=20;
|
|
8042
|
-
const SHADOW_KINDS=Object.freeze([
|
|
8043
|
-
'updates','updatedAt','sinceUpdate','delta','deltaPercent',
|
|
8044
|
-
'rate','history','firstValue','streak',
|
|
8045
|
-
'rank','rankAsc','rankChange','percentile','quartile','zScore','shareOfTotal',
|
|
8046
|
-
'anomalyScore','anomalyFlag',
|
|
8047
|
-
'specStatus',
|
|
8048
|
-
]);
|
|
8049
|
-
const MAD_SCALE=0.6745;
|
|
8050
|
-
const DEFAULT_ANOMALY_THRESHOLD=3.5;
|
|
8051
|
-
const SPEC_STATUS=Object.freeze({PASS:'PASS',WARN:'WARN',FAIL:'FAIL'});
|
|
8052
|
-
const POSITIONAL_KINDS=Object.freeze([
|
|
8053
|
-
'rank','rankAsc','rankChange','percentile','quartile','zScore','shareOfTotal',
|
|
8054
|
-
'anomalyScore','anomalyFlag',
|
|
8055
|
-
]);
|
|
8056
|
-
const SHADOW_LABELS=Object.freeze({
|
|
8057
|
-
updates:'Updates',
|
|
8058
|
-
updatedAt:'Updated at',
|
|
8059
|
-
sinceUpdate:'Since update',
|
|
8060
|
-
delta:'Change',
|
|
8061
|
-
deltaPercent:'Change %',
|
|
8062
|
-
rate:'Rate of change',
|
|
8063
|
-
history:'History',
|
|
8064
|
-
firstValue:'Baseline',
|
|
8065
|
-
streak:'Streak',
|
|
8066
|
-
rank:'Rank',
|
|
8067
|
-
rankAsc:'Rank, ascending',
|
|
8068
|
-
rankChange:'Rank change',
|
|
8069
|
-
percentile:'Percentile',
|
|
8070
|
-
quartile:'Quartile',
|
|
8071
|
-
zScore:'Z-score',
|
|
8072
|
-
shareOfTotal:'Share of total',
|
|
8073
|
-
anomalyScore:'Anomaly score',
|
|
8074
|
-
anomalyFlag:'Anomaly',
|
|
8075
|
-
specStatus:'Spec status',
|
|
8076
|
-
});
|
|
8077
|
-
function specStatusOf(value,spec){
|
|
8078
|
-
if(!spec)return null;
|
|
8079
|
-
const lower=Number.isFinite(Number(spec.lower))?Number(spec.lower):null;
|
|
8080
|
-
const upper=Number.isFinite(Number(spec.upper))?Number(spec.upper):null;
|
|
8081
|
-
if(lower===null&&upper===null)return null;
|
|
8082
|
-
if(!Number.isFinite(value))return null;
|
|
8083
|
-
if(lower!==null&&value<lower)return SPEC_STATUS.FAIL;
|
|
8084
|
-
if(upper!==null&&value>upper)return SPEC_STATUS.FAIL;
|
|
8085
|
-
const warnLower=Number.isFinite(Number(spec.warnLower))?Number(spec.warnLower):null;
|
|
8086
|
-
const warnUpper=Number.isFinite(Number(spec.warnUpper))?Number(spec.warnUpper):null;
|
|
8087
|
-
if(warnLower!==null&&value<warnLower)return SPEC_STATUS.WARN;
|
|
8088
|
-
if(warnUpper!==null&&value>warnUpper)return SPEC_STATUS.WARN;
|
|
8089
|
-
return SPEC_STATUS.PASS;
|
|
8090
|
-
}
|
|
8091
|
-
class ShadowTracker{
|
|
8092
|
-
#colId;
|
|
8093
|
-
#baseline=new Map();
|
|
8094
|
-
#latest=new Map();
|
|
8095
|
-
#counts=new Map();
|
|
8096
|
-
#stamps=new Map();
|
|
8097
|
-
#history=new Map();
|
|
8098
|
-
#streaks=new Map();
|
|
8099
|
-
#forgotten=0;
|
|
8100
|
-
#depth;
|
|
8101
|
-
#max;
|
|
8102
|
-
#now;
|
|
8103
|
-
#summary=null;
|
|
8104
|
-
#filtered=null;
|
|
8105
|
-
constructor(opts){
|
|
8106
|
-
this.#colId=opts.colId;
|
|
8107
|
-
this.#depth=Math.max(2,opts.depth||DEFAULT_DEPTH);
|
|
8108
|
-
this.#max=Math.max(1,opts.max||MAX_TRACKED);
|
|
8109
|
-
this.#now=opts.now||(()=>Date.now());
|
|
8110
|
-
}
|
|
8111
|
-
get colId(){return this.#colId;}
|
|
8112
|
-
get forgotten(){return this.#forgotten;}
|
|
8113
|
-
get size(){return this.#latest.size;}
|
|
8114
|
-
observe(key,raw){
|
|
8115
|
-
const value=toNumber(raw);
|
|
8116
|
-
if(value===null)return;
|
|
8117
|
-
if(!this.#latest.has(key)){
|
|
8118
|
-
this.#summary=null;
|
|
8119
|
-
this.#filtered=null;
|
|
8120
|
-
this.#evictIfFull();
|
|
8121
|
-
this.#baseline.set(key,value);
|
|
8122
|
-
this.#latest.set(key,value);
|
|
8123
|
-
this.#counts.set(key,0);
|
|
8124
|
-
this.#stamps.set(key,this.#now());
|
|
8125
|
-
this.#history.set(key,[value]);
|
|
8126
|
-
this.#streaks.set(key,0);
|
|
8127
|
-
return;
|
|
8128
|
-
}
|
|
8129
|
-
const previous=this.#latest.get(key);
|
|
8130
|
-
if(previous===value)return;
|
|
8131
|
-
this.#summary=null;
|
|
8132
|
-
this.#filtered=null;
|
|
8133
|
-
this.#latest.set(key,value);
|
|
8134
|
-
this.#counts.set(key,(this.#counts.get(key)||0)+1);
|
|
8135
|
-
this.#stamps.set(key,this.#now());
|
|
8136
|
-
const readings=this.#history.get(key)||[];
|
|
8137
|
-
readings.push(value);
|
|
8138
|
-
if(readings.length>this.#depth)readings.splice(0,readings.length-this.#depth);
|
|
8139
|
-
this.#history.set(key,readings);
|
|
8140
|
-
const direction=Math.sign(value-previous);
|
|
8141
|
-
const streak=this.#streaks.get(key)||0;
|
|
8142
|
-
this.#streaks.set(key,Math.sign(streak)===direction?streak+direction:direction);
|
|
8143
|
-
}
|
|
8144
|
-
#evictIfFull(){
|
|
8145
|
-
if(this.#latest.size<this.#max)return;
|
|
8146
|
-
const oldest=this.#latest.keys().next().value;
|
|
8147
|
-
if(oldest===undefined)return;
|
|
8148
|
-
this.#baseline.delete(oldest);
|
|
8149
|
-
this.#latest.delete(oldest);
|
|
8150
|
-
this.#counts.delete(oldest);
|
|
8151
|
-
this.#stamps.delete(oldest);
|
|
8152
|
-
this.#history.delete(oldest);
|
|
8153
|
-
this.#streaks.delete(oldest);
|
|
8154
|
-
this.#forgotten++;
|
|
8155
|
-
}
|
|
8156
|
-
rebase(){
|
|
8157
|
-
for(const[key,value]of this.#latest)this.#baseline.set(key,value);
|
|
8158
|
-
this.#summary=null;
|
|
8159
|
-
this.#filtered=null;
|
|
8160
|
-
}
|
|
8161
|
-
reset(){
|
|
8162
|
-
this.#baseline.clear();
|
|
8163
|
-
this.#latest.clear();
|
|
8164
|
-
this.#counts.clear();
|
|
8165
|
-
this.#stamps.clear();
|
|
8166
|
-
this.#history.clear();
|
|
8167
|
-
this.#streaks.clear();
|
|
8168
|
-
this.#forgotten=0;
|
|
8169
|
-
this.#summary=null;
|
|
8170
|
-
this.#filtered=null;
|
|
8171
|
-
}
|
|
8172
|
-
retain(keys){
|
|
8173
|
-
const living=keys instanceof Set?keys:new Set(keys);
|
|
8174
|
-
let dropped=0;
|
|
8175
|
-
for(const key of[...this.#latest.keys()]){
|
|
8176
|
-
if(living.has(key))continue;
|
|
8177
|
-
this.#baseline.delete(key);
|
|
8178
|
-
this.#latest.delete(key);
|
|
8179
|
-
this.#counts.delete(key);
|
|
8180
|
-
this.#stamps.delete(key);
|
|
8181
|
-
this.#history.delete(key);
|
|
8182
|
-
this.#streaks.delete(key);
|
|
8183
|
-
dropped++;
|
|
8184
|
-
}
|
|
8185
|
-
if(dropped){this.#summary=null;this.#filtered=null;}
|
|
8186
|
-
return dropped;
|
|
8187
|
-
}
|
|
8188
|
-
read(kind,key,only,spec){
|
|
8189
|
-
switch(kind){
|
|
8190
|
-
case'updates':
|
|
8191
|
-
return this.#counts.has(key)?this.#counts.get(key):0;
|
|
8192
|
-
case'updatedAt':{
|
|
8193
|
-
const at=this.#stamps.get(key);
|
|
8194
|
-
return at===undefined?null:new Date(at);
|
|
8195
|
-
}
|
|
8196
|
-
case'sinceUpdate':{
|
|
8197
|
-
const at=this.#stamps.get(key);
|
|
8198
|
-
return at===undefined?null:this.#now()-at;
|
|
8199
|
-
}
|
|
8200
|
-
case'firstValue':
|
|
8201
|
-
return this.#baseline.has(key)?this.#baseline.get(key):null;
|
|
8202
|
-
case'delta':{
|
|
8203
|
-
if(!this.#latest.has(key))return null;
|
|
8204
|
-
return this.#latest.get(key)-this.#baseline.get(key);
|
|
8205
|
-
}
|
|
8206
|
-
case'deltaPercent':{
|
|
8207
|
-
if(!this.#latest.has(key))return null;
|
|
8208
|
-
const base=this.#baseline.get(key);
|
|
8209
|
-
if(!base)return null;
|
|
8210
|
-
return((this.#latest.get(key)-base)/Math.abs(base))*100;
|
|
8211
|
-
}
|
|
8212
|
-
case'rate':{
|
|
8213
|
-
const readings=this.#history.get(key);
|
|
8214
|
-
const at=this.#stamps.get(key);
|
|
8215
|
-
if(!readings||readings.length<2||at===undefined)return null;
|
|
8216
|
-
const elapsed=this.#now()-at;
|
|
8217
|
-
const change=readings[readings.length-1]-readings[readings.length-2];
|
|
8218
|
-
return elapsed>0?(change/elapsed)*1000:change;
|
|
8219
|
-
}
|
|
8220
|
-
case'history':
|
|
8221
|
-
return this.#history.has(key)?[...this.#history.get(key)]:null;
|
|
8222
|
-
case'streak':
|
|
8223
|
-
return this.#streaks.has(key)?this.#streaks.get(key):0;
|
|
8224
|
-
case'specStatus':{
|
|
8225
|
-
if(!this.#latest.has(key))return null;
|
|
8226
|
-
return specStatusOf(this.#latest.get(key),spec);
|
|
8227
|
-
}
|
|
8228
|
-
default:
|
|
8229
|
-
return POSITIONAL_KINDS.includes(kind)?this.#position(kind,key,only,spec):null;
|
|
8230
|
-
}
|
|
8231
|
-
}
|
|
8232
|
-
#view(only){
|
|
8233
|
-
if(only){
|
|
8234
|
-
if(this.#filtered&&this.#filtered.only===only)return this.#filtered.view;
|
|
8235
|
-
const view=this.#build(only);
|
|
8236
|
-
this.#filtered={only,view};
|
|
8237
|
-
return view;
|
|
8238
|
-
}
|
|
8239
|
-
if(this.#summary)return this.#summary;
|
|
8240
|
-
this.#summary=this.#build(null);
|
|
8241
|
-
return this.#summary;
|
|
8242
|
-
}
|
|
8243
|
-
#build(only){
|
|
8244
|
-
const values=[];
|
|
8245
|
-
for(const[key,value]of this.#latest){
|
|
8246
|
-
if(only&&!only.has(key))continue;
|
|
8247
|
-
values.push(value);
|
|
8248
|
-
}
|
|
8249
|
-
const sorted=values.sort((a,b)=>a-b);
|
|
8250
|
-
let n=0;
|
|
8251
|
-
let mean=0;
|
|
8252
|
-
let m2=0;
|
|
8253
|
-
let sum=0;
|
|
8254
|
-
for(const x of sorted){
|
|
8255
|
-
sum+=x;
|
|
8256
|
-
n++;
|
|
8257
|
-
const delta=x-mean;
|
|
8258
|
-
mean+=delta/n;
|
|
8259
|
-
m2+=delta*(x-mean);
|
|
8260
|
-
}
|
|
8261
|
-
const baseline=[];
|
|
8262
|
-
for(const[key,value]of this.#baseline){
|
|
8263
|
-
if(only&&!only.has(key))continue;
|
|
8264
|
-
baseline.push(value);
|
|
8265
|
-
}
|
|
8266
|
-
const median=n?medianSorted(sorted):0;
|
|
8267
|
-
const deviations=sorted.map((v)=>Math.abs(v-median)).sort((a,b)=>a-b);
|
|
8268
|
-
const mad=n?medianSorted(deviations):0;
|
|
8269
|
-
return{
|
|
8270
|
-
sorted,
|
|
8271
|
-
baseline:baseline.sort((a,b)=>a-b),
|
|
8272
|
-
sum,
|
|
8273
|
-
mean:n?mean:0,
|
|
8274
|
-
sd:n>1?Math.sqrt(m2/(n-1)):0,
|
|
8275
|
-
median,
|
|
8276
|
-
mad,
|
|
8277
|
-
};
|
|
8278
|
-
}
|
|
8279
|
-
#position(kind,key,only,spec){
|
|
8280
|
-
if(!this.#latest.has(key))return null;
|
|
8281
|
-
if(only&&!only.has(key))return null;
|
|
8282
|
-
const value=this.#latest.get(key);
|
|
8283
|
-
const view=this.#view(only);
|
|
8284
|
-
const n=view.sorted.length;
|
|
8285
|
-
if(!n)return null;
|
|
8286
|
-
switch(kind){
|
|
8287
|
-
case'rank':return n-upperBound(view.sorted,value)+1;
|
|
8288
|
-
case'rankAsc':return lowerBound(view.sorted,value)+1;
|
|
8289
|
-
case'rankChange':{
|
|
8290
|
-
if(!this.#baseline.has(key)||!view.baseline.length)return null;
|
|
8291
|
-
const was=view.baseline.length-upperBound(view.baseline,this.#baseline.get(key))+1;
|
|
8292
|
-
const now=n-upperBound(view.sorted,value)+1;
|
|
8293
|
-
return was-now;
|
|
8294
|
-
}
|
|
8295
|
-
case'percentile':return(upperBound(view.sorted,value)/n)*100;
|
|
8296
|
-
case'quartile':{
|
|
8297
|
-
const share=upperBound(view.sorted,value)/n;
|
|
8298
|
-
return Math.min(4,Math.max(1,Math.ceil(share*4)));
|
|
8299
|
-
}
|
|
8300
|
-
case'zScore':return view.sd?(value-view.mean)/view.sd:null;
|
|
8301
|
-
case'anomalyScore':
|
|
8302
|
-
return view.mad?(MAD_SCALE*(value-view.median))/view.mad:null;
|
|
8303
|
-
case'anomalyFlag':{
|
|
8304
|
-
if(!view.mad)return null;
|
|
8305
|
-
const threshold=spec&&Number.isFinite(Number(spec.threshold))
|
|
8306
|
-
?Number(spec.threshold):DEFAULT_ANOMALY_THRESHOLD;
|
|
8307
|
-
return Math.abs((MAD_SCALE*(value-view.median))/view.mad)>threshold;
|
|
8308
|
-
}
|
|
8309
|
-
case'shareOfTotal':return view.sum?(value/view.sum)*100:null;
|
|
8310
|
-
default:return null;
|
|
8311
|
-
}
|
|
8312
|
-
}
|
|
8313
|
-
}
|
|
8314
|
-
function medianSorted(sorted){
|
|
8315
|
-
const n=sorted.length;
|
|
8316
|
-
if(!n)return 0;
|
|
8317
|
-
const h=(n-1)*0.5;
|
|
8318
|
-
const lo=Math.floor(h);
|
|
8319
|
-
const hi=Math.ceil(h);
|
|
8320
|
-
return lo===hi?sorted[lo]:sorted[lo]+(h-lo)*(sorted[hi]-sorted[lo]);
|
|
8321
|
-
}
|
|
8322
|
-
function lowerBound(sorted,value){
|
|
8323
|
-
let lo=0;
|
|
8324
|
-
let hi=sorted.length;
|
|
8325
|
-
while(lo<hi){
|
|
8326
|
-
const mid=(lo+hi)>>1;
|
|
8327
|
-
if(sorted[mid]<value)lo=mid+1;
|
|
8328
|
-
else hi=mid;
|
|
8329
|
-
}
|
|
8330
|
-
return lo;
|
|
8331
|
-
}
|
|
8332
|
-
function upperBound(sorted,value){
|
|
8333
|
-
let lo=0;
|
|
8334
|
-
let hi=sorted.length;
|
|
8335
|
-
while(lo<hi){
|
|
8336
|
-
const mid=(lo+hi)>>1;
|
|
8337
|
-
if(sorted[mid]<=value)lo=mid+1;
|
|
8338
|
-
else hi=mid;
|
|
8339
|
-
}
|
|
8340
|
-
return lo;
|
|
8341
|
-
}
|
|
8342
|
-
function toNumber(raw){
|
|
8343
|
-
if(raw===null||raw===undefined||raw==='')return null;
|
|
8344
|
-
if(raw instanceof Date){
|
|
8345
|
-
const t=raw.getTime();
|
|
8346
|
-
return Number.isFinite(t)?t:null;
|
|
8347
|
-
}
|
|
8348
|
-
const n=typeof raw==='number'?raw:Number(raw);
|
|
8349
|
-
return Number.isFinite(n)?n:null;
|
|
8350
|
-
}
|
|
8351
|
-
function shadowsIn(columns){
|
|
8352
|
-
const out=[];
|
|
8353
|
-
for(const column of columns||[]){
|
|
8354
|
-
const declared=column.shadow;
|
|
8355
|
-
if(!declared)continue;
|
|
8356
|
-
const spec=typeof declared==='string'?{kind:declared}:declared;
|
|
8357
|
-
const kind=spec.kind;
|
|
8358
|
-
if(!SHADOW_KINDS.includes(kind))continue;
|
|
8359
|
-
out.push({
|
|
8360
|
-
colId:column.id||column.field,
|
|
8361
|
-
of:spec.of||column.field||column.id,
|
|
8362
|
-
kind,
|
|
8363
|
-
depth:spec.depth,
|
|
8364
|
-
});
|
|
8365
|
-
}
|
|
8366
|
-
return out;
|
|
8367
|
-
}
|
|
8368
|
-
});
|
|
8369
8808
|
__def("packages/core/src/compute/handle.js",function(__exports,__req){
|
|
8370
8809
|
'use strict';
|
|
8371
8810
|
Object.defineProperty(__exports,"identity",{enumerable:true,get:function(){return identity;}});
|
|
@@ -8748,6 +9187,88 @@ const cdf=chiSquareCdf(x,df);
|
|
|
8748
9187
|
return Number.isNaN(cdf)?Number.NaN:Math.min(1,Math.max(0,1-cdf));
|
|
8749
9188
|
}
|
|
8750
9189
|
});
|
|
9190
|
+
__def("packages/core/src/compute/linalg.js",function(__exports,__req){
|
|
9191
|
+
'use strict';
|
|
9192
|
+
Object.defineProperty(__exports,"cholesky",{enumerable:true,get:function(){return cholesky;}});
|
|
9193
|
+
Object.defineProperty(__exports,"choleskySolve",{enumerable:true,get:function(){return choleskySolve;}});
|
|
9194
|
+
Object.defineProperty(__exports,"choleskyInverse",{enumerable:true,get:function(){return choleskyInverse;}});
|
|
9195
|
+
Object.defineProperty(__exports,"normalEquations",{enumerable:true,get:function(){return normalEquations;}});
|
|
9196
|
+
Object.defineProperty(__exports,"matVec",{enumerable:true,get:function(){return matVec;}});
|
|
9197
|
+
Object.defineProperty(__exports,"quadForm",{enumerable:true,get:function(){return quadForm;}});
|
|
9198
|
+
function cholesky(a){
|
|
9199
|
+
const n=a.length;
|
|
9200
|
+
const l=Array.from({length:n},()=>new Array(n).fill(0));
|
|
9201
|
+
for(let i=0;i<n;i++){
|
|
9202
|
+
for(let j=0;j<=i;j++){
|
|
9203
|
+
let sum=a[i][j];
|
|
9204
|
+
for(let k=0;k<j;k++)sum-=l[i][k]*l[j][k];
|
|
9205
|
+
if(i===j){
|
|
9206
|
+
if(!(sum>0))return null;
|
|
9207
|
+
l[i][j]=Math.sqrt(sum);
|
|
9208
|
+
}else{
|
|
9209
|
+
l[i][j]=sum/l[j][j];
|
|
9210
|
+
}
|
|
9211
|
+
}
|
|
9212
|
+
}
|
|
9213
|
+
return l;
|
|
9214
|
+
}
|
|
9215
|
+
function choleskySolve(l,b){
|
|
9216
|
+
const n=l.length;
|
|
9217
|
+
const y=new Array(n).fill(0);
|
|
9218
|
+
for(let i=0;i<n;i++){
|
|
9219
|
+
let sum=b[i];
|
|
9220
|
+
for(let k=0;k<i;k++)sum-=l[i][k]*y[k];
|
|
9221
|
+
y[i]=sum/l[i][i];
|
|
9222
|
+
}
|
|
9223
|
+
const x=new Array(n).fill(0);
|
|
9224
|
+
for(let i=n-1;i>=0;i--){
|
|
9225
|
+
let sum=y[i];
|
|
9226
|
+
for(let k=i+1;k<n;k++)sum-=l[k][i]*x[k];
|
|
9227
|
+
x[i]=sum/l[i][i];
|
|
9228
|
+
}
|
|
9229
|
+
return x;
|
|
9230
|
+
}
|
|
9231
|
+
function choleskyInverse(l){
|
|
9232
|
+
const n=l.length;
|
|
9233
|
+
const inv=Array.from({length:n},()=>new Array(n).fill(0));
|
|
9234
|
+
for(let c=0;c<n;c++){
|
|
9235
|
+
const e=new Array(n).fill(0);
|
|
9236
|
+
e[c]=1;
|
|
9237
|
+
const col=choleskySolve(l,e);
|
|
9238
|
+
for(let r=0;r<n;r++)inv[r][c]=col[r];
|
|
9239
|
+
}
|
|
9240
|
+
return inv;
|
|
9241
|
+
}
|
|
9242
|
+
function normalEquations(x,y,w){
|
|
9243
|
+
const n=x.length;
|
|
9244
|
+
const p=n?x[0].length:0;
|
|
9245
|
+
const xtwx=Array.from({length:p},()=>new Array(p).fill(0));
|
|
9246
|
+
const xtwy=new Array(p).fill(0);
|
|
9247
|
+
for(let i=0;i<n;i++){
|
|
9248
|
+
const wi=w?w[i]:1;
|
|
9249
|
+
const row=x[i];
|
|
9250
|
+
for(let a=0;a<p;a++){
|
|
9251
|
+
const wxa=wi*row[a];
|
|
9252
|
+
xtwy[a]+=wxa*y[i];
|
|
9253
|
+
for(let b=a;b<p;b++)xtwx[a][b]+=wxa*row[b];
|
|
9254
|
+
}
|
|
9255
|
+
}
|
|
9256
|
+
for(let a=0;a<p;a++)for(let b=0;b<a;b++)xtwx[a][b]=xtwx[b][a];
|
|
9257
|
+
return{xtwx,xtwy};
|
|
9258
|
+
}
|
|
9259
|
+
function matVec(m,v){
|
|
9260
|
+
return m.map((row)=>row.reduce((sum,cell,j)=>sum+cell*v[j],0));
|
|
9261
|
+
}
|
|
9262
|
+
function quadForm(x,m){
|
|
9263
|
+
let sum=0;
|
|
9264
|
+
for(let a=0;a<x.length;a++){
|
|
9265
|
+
let inner=0;
|
|
9266
|
+
for(let b=0;b<x.length;b++)inner+=m[a][b]*x[b];
|
|
9267
|
+
sum+=x[a]*inner;
|
|
9268
|
+
}
|
|
9269
|
+
return sum;
|
|
9270
|
+
}
|
|
9271
|
+
});
|
|
8751
9272
|
__def("packages/core/src/compute/sketch.js",function(__exports,__req){
|
|
8752
9273
|
'use strict';
|
|
8753
9274
|
Object.defineProperty(__exports,"Welford",{enumerable:true,get:function(){return Welford;}});
|
|
@@ -9088,6 +9609,10 @@ Object.defineProperty(__exports,"weightedQuantile",{enumerable:true,get:function
|
|
|
9088
9609
|
Object.defineProperty(__exports,"pairs",{enumerable:true,get:function(){return pairs;}});
|
|
9089
9610
|
Object.defineProperty(__exports,"covariance",{enumerable:true,get:function(){return covariance;}});
|
|
9090
9611
|
Object.defineProperty(__exports,"regression",{enumerable:true,get:function(){return regression;}});
|
|
9612
|
+
Object.defineProperty(__exports,"fitLinearModel",{enumerable:true,get:function(){return fitLinearModel;}});
|
|
9613
|
+
Object.defineProperty(__exports,"ADF_CT_CRITICAL",{enumerable:true,get:function(){return ADF_CT_CRITICAL;}});
|
|
9614
|
+
Object.defineProperty(__exports,"augmentedDickeyFuller",{enumerable:true,get:function(){return augmentedDickeyFuller;}});
|
|
9615
|
+
Object.defineProperty(__exports,"autocorrelations",{enumerable:true,get:function(){return autocorrelations;}});
|
|
9091
9616
|
Object.defineProperty(__exports,"spearman",{enumerable:true,get:function(){return spearman;}});
|
|
9092
9617
|
Object.defineProperty(__exports,"kendall",{enumerable:true,get:function(){return kendall;}});
|
|
9093
9618
|
Object.defineProperty(__exports,"seriesStats",{enumerable:true,get:function(){return seriesStats;}});
|
|
@@ -9121,10 +9646,18 @@ const presenceReader=__m0["presenceReader"];
|
|
|
9121
9646
|
const valueReader=__m0["valueReader"];
|
|
9122
9647
|
const __m1=__req("packages/core/src/compute/special.js");
|
|
9123
9648
|
const studentTQuantile=__m1["studentTQuantile"];
|
|
9649
|
+
const studentT=__m1["studentT"];
|
|
9124
9650
|
const normalQuantile=__m1["normalQuantile"];
|
|
9125
9651
|
const normalCdf=__m1["normalCdf"];
|
|
9126
|
-
const
|
|
9127
|
-
const
|
|
9652
|
+
const chiSquareUpperTail=__m1["chiSquareUpperTail"];
|
|
9653
|
+
const __m2=__req("packages/core/src/compute/linalg.js");
|
|
9654
|
+
const cholesky=__m2["cholesky"];
|
|
9655
|
+
const choleskySolve=__m2["choleskySolve"];
|
|
9656
|
+
const choleskyInverse=__m2["choleskyInverse"];
|
|
9657
|
+
const normalEquations=__m2["normalEquations"];
|
|
9658
|
+
const quadForm=__m2["quadForm"];
|
|
9659
|
+
const __m3=__req("packages/core/src/compute/sketch.js");
|
|
9660
|
+
const SKETCH_BOUNDS=__m3["SKETCH_BOUNDS"];
|
|
9128
9661
|
const KENDALL_LIMIT=5000;
|
|
9129
9662
|
const MAINTENANCE=Object.freeze({
|
|
9130
9663
|
variance:'rescan',
|
|
@@ -9708,6 +10241,196 @@ const residual=Math.max(0,syy-slope*sxy);
|
|
|
9708
10241
|
const stdError=n>2?Math.sqrt(residual/(n-2)/sxx):0;
|
|
9709
10242
|
return{slope,intercept,r2,stdError,n};
|
|
9710
10243
|
}
|
|
10244
|
+
const SUPPORTED_METHODS=new Set(['ols','wls','robust']);
|
|
10245
|
+
const DEFERRED_METHODS=new Set(['quantile']);
|
|
10246
|
+
const OUT_OF_SCOPE_METHODS=new Set(['ridge','lasso','elasticnet','mixed','gls']);
|
|
10247
|
+
const HUBER_C=1.345;
|
|
10248
|
+
function solveWls(design,y,w){
|
|
10249
|
+
const{xtwx,xtwy}=normalEquations(design,y,w);
|
|
10250
|
+
const l=cholesky(xtwx);
|
|
10251
|
+
if(!l)return null;
|
|
10252
|
+
const beta=choleskySolve(l,xtwy);
|
|
10253
|
+
const cov=choleskyInverse(l);
|
|
10254
|
+
const fitted=matVecRows(design,beta);
|
|
10255
|
+
const residuals=y.map((yi,i)=>yi-fitted[i]);
|
|
10256
|
+
return{beta,cov,fitted,residuals};
|
|
10257
|
+
}
|
|
10258
|
+
function matVecRows(rows,v){
|
|
10259
|
+
return rows.map((row)=>row.reduce((sum,cell,j)=>sum+cell*v[j],0));
|
|
10260
|
+
}
|
|
10261
|
+
function auxiliaryR2(predictors,j){
|
|
10262
|
+
const n=predictors.length;
|
|
10263
|
+
const y=predictors.map((row)=>row[j]);
|
|
10264
|
+
const design=predictors.map((row)=>[1,...row.filter((unused,c)=>c!==j)]);
|
|
10265
|
+
const fit=solveWls(design,y,null);
|
|
10266
|
+
if(!fit)return 1;
|
|
10267
|
+
const ybar=y.reduce((s,v)=>s+v,0)/n;
|
|
10268
|
+
let rss=0;
|
|
10269
|
+
let tss=0;
|
|
10270
|
+
for(let i=0;i<n;i++){rss+=fit.residuals[i]**2;tss+=(y[i]-ybar)**2;}
|
|
10271
|
+
if(tss===0)return 1;
|
|
10272
|
+
return Math.max(0,Math.min(1,1-rss/tss));
|
|
10273
|
+
}
|
|
10274
|
+
function madScale(values){
|
|
10275
|
+
const sorted=[...values].sort((a,b)=>a-b);
|
|
10276
|
+
const med=medianOfSorted(sorted);
|
|
10277
|
+
const dev=values.map((v)=>Math.abs(v-med)).sort((a,b)=>a-b);
|
|
10278
|
+
return medianOfSorted(dev)/0.6745;
|
|
10279
|
+
}
|
|
10280
|
+
function medianOfSorted(sorted){
|
|
10281
|
+
const n=sorted.length;
|
|
10282
|
+
if(!n)return 0;
|
|
10283
|
+
const mid=Math.floor(n/2);
|
|
10284
|
+
return n%2?sorted[mid]:(sorted[mid-1]+sorted[mid])/2;
|
|
10285
|
+
}
|
|
10286
|
+
function fitLinearModel(matrix,y,opts={}){
|
|
10287
|
+
const method=opts.method||'ols';
|
|
10288
|
+
if(OUT_OF_SCOPE_METHODS.has(method)){
|
|
10289
|
+
throw new Error(`[lattice] regression method "${method}" is out of scope; use ols, wls or robust.`);
|
|
10290
|
+
}
|
|
10291
|
+
if(DEFERRED_METHODS.has(method)){
|
|
10292
|
+
throw new Error(`[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.`);
|
|
10293
|
+
}
|
|
10294
|
+
if(!SUPPORTED_METHODS.has(method)){
|
|
10295
|
+
throw new Error(`[lattice] unknown regression method "${method}"; use ols, wls or robust.`);
|
|
10296
|
+
}
|
|
10297
|
+
const n=Array.isArray(y)?y.length:0;
|
|
10298
|
+
const k=n&&Array.isArray(matrix[0])?matrix[0].length:0;
|
|
10299
|
+
const p=k+1;
|
|
10300
|
+
if(!(n>p))return null;
|
|
10301
|
+
for(let i=0;i<n;i++){
|
|
10302
|
+
if(!Number.isFinite(y[i]))return null;
|
|
10303
|
+
if(!Array.isArray(matrix[i])||matrix[i].length!==k)return null;
|
|
10304
|
+
for(let j=0;j<k;j++)if(!Number.isFinite(matrix[i][j]))return null;
|
|
10305
|
+
}
|
|
10306
|
+
let weights=null;
|
|
10307
|
+
if(method==='wls'){
|
|
10308
|
+
weights=opts.weights;
|
|
10309
|
+
if(!Array.isArray(weights)||weights.length!==n)return null;
|
|
10310
|
+
for(let i=0;i<n;i++)if(!(weights[i]>0)||!Number.isFinite(weights[i]))return null;
|
|
10311
|
+
}
|
|
10312
|
+
const design=matrix.map((row)=>[1,...row]);
|
|
10313
|
+
let fit;
|
|
10314
|
+
let robustWeights=null;
|
|
10315
|
+
if(method==='robust'){
|
|
10316
|
+
fit=solveWls(design,y,null);
|
|
10317
|
+
if(!fit)return null;
|
|
10318
|
+
for(let iter=0;iter<50;iter++){
|
|
10319
|
+
const scale=madScale(fit.residuals);
|
|
10320
|
+
if(!(scale>0))break;
|
|
10321
|
+
const w=fit.residuals.map((r)=>{
|
|
10322
|
+
const u=Math.abs(r/scale);
|
|
10323
|
+
return u<=HUBER_C?1:HUBER_C/u;
|
|
10324
|
+
});
|
|
10325
|
+
const next=solveWls(design,y,w);
|
|
10326
|
+
if(!next)return null;
|
|
10327
|
+
const moved=next.beta.reduce((m,b,j)=>Math.max(m,Math.abs(b-fit.beta[j])),0);
|
|
10328
|
+
fit=next;
|
|
10329
|
+
robustWeights=w;
|
|
10330
|
+
if(moved<1e-10)break;
|
|
10331
|
+
}
|
|
10332
|
+
}else{
|
|
10333
|
+
fit=solveWls(design,y,weights);
|
|
10334
|
+
if(!fit)return null;
|
|
10335
|
+
}
|
|
10336
|
+
const w=method==='robust'?robustWeights:weights;
|
|
10337
|
+
const{beta,cov,fitted,residuals}=fit;
|
|
10338
|
+
let rss=0;
|
|
10339
|
+
let sw=0;
|
|
10340
|
+
let swy=0;
|
|
10341
|
+
for(let i=0;i<n;i++){
|
|
10342
|
+
const wi=w?w[i]:1;
|
|
10343
|
+
rss+=wi*residuals[i]**2;
|
|
10344
|
+
sw+=wi;
|
|
10345
|
+
swy+=wi*y[i];
|
|
10346
|
+
}
|
|
10347
|
+
const ybar=swy/sw;
|
|
10348
|
+
let tss=0;
|
|
10349
|
+
for(let i=0;i<n;i++){const wi=w?w[i]:1;tss+=wi*(y[i]-ybar)**2;}
|
|
10350
|
+
const df=n-p;
|
|
10351
|
+
const sigma2=rss/df;
|
|
10352
|
+
const r2=tss===0?1:Math.max(0,Math.min(1,1-rss/tss));
|
|
10353
|
+
const adjR2=1-(1-r2)*(n-1)/df;
|
|
10354
|
+
const names=Array.isArray(opts.names)&&opts.names.length===k
|
|
10355
|
+
?opts.names:matrix[0].map((unused,j)=>`x${j+1}`);
|
|
10356
|
+
const conf=level(opts.confidence);
|
|
10357
|
+
const tCrit=df>0?studentTQuantile(1-(1-conf)/2,df):Infinity;
|
|
10358
|
+
const coefficients=beta.map((estimate,j)=>{
|
|
10359
|
+
const stdError=Math.sqrt(Math.max(0,sigma2*cov[j][j]));
|
|
10360
|
+
const t=stdError>0?estimate/stdError:(estimate===0?0:Infinity);
|
|
10361
|
+
const pv=Number.isFinite(t)?2*(1-studentT(Math.abs(t),df)):0;
|
|
10362
|
+
const half=Number.isFinite(tCrit)?tCrit*stdError:null;
|
|
10363
|
+
return{
|
|
10364
|
+
name:j===0?'(intercept)':names[j-1],
|
|
10365
|
+
estimate,
|
|
10366
|
+
stdError,
|
|
10367
|
+
t,
|
|
10368
|
+
p:Math.max(0,Math.min(1,pv)),
|
|
10369
|
+
lower:half===null?null:estimate-half,
|
|
10370
|
+
upper:half===null?null:estimate+half,
|
|
10371
|
+
};
|
|
10372
|
+
});
|
|
10373
|
+
const leverage=new Array(n);
|
|
10374
|
+
const cooksD=new Array(n);
|
|
10375
|
+
for(let i=0;i<n;i++){
|
|
10376
|
+
const wi=w?w[i]:1;
|
|
10377
|
+
const h=Math.max(0,Math.min(1,wi*quadForm(design[i],cov)));
|
|
10378
|
+
leverage[i]=h;
|
|
10379
|
+
const denom=(1-h)**2;
|
|
10380
|
+
cooksD[i]=(denom>0&&sigma2>0)
|
|
10381
|
+
?(residuals[i]**2/(p*sigma2))*(h/denom)
|
|
10382
|
+
:null;
|
|
10383
|
+
}
|
|
10384
|
+
const vif=matrix[0].map((unused,j)=>{
|
|
10385
|
+
if(k<2)return 1;
|
|
10386
|
+
const rj=auxiliaryR2(matrix,j);
|
|
10387
|
+
return rj>=1?Infinity:1/(1-rj);
|
|
10388
|
+
});
|
|
10389
|
+
let hetero=null;
|
|
10390
|
+
{
|
|
10391
|
+
const e2=residuals.map((r)=>r*r);
|
|
10392
|
+
const aux=solveWls(design,e2,null);
|
|
10393
|
+
if(aux){
|
|
10394
|
+
const e2bar=e2.reduce((s,v)=>s+v,0)/n;
|
|
10395
|
+
let arss=0;
|
|
10396
|
+
let atss=0;
|
|
10397
|
+
for(let i=0;i<n;i++){arss+=aux.residuals[i]**2;atss+=(e2[i]-e2bar)**2;}
|
|
10398
|
+
const auxR2=atss===0?0:Math.max(0,Math.min(1,1-arss/atss));
|
|
10399
|
+
const statistic=n*auxR2;
|
|
10400
|
+
const pv=chiSquareUpperTail(statistic,k);
|
|
10401
|
+
hetero={statistic,df:k,p:pv,heteroscedastic:pv<0.05};
|
|
10402
|
+
}
|
|
10403
|
+
}
|
|
10404
|
+
let band=null;
|
|
10405
|
+
if(k===1){
|
|
10406
|
+
const order=matrix.map((row,i)=>i).sort((i,j)=>matrix[i][0]-matrix[j][0]);
|
|
10407
|
+
band={
|
|
10408
|
+
confidence:conf,
|
|
10409
|
+
points:order.map((i)=>{
|
|
10410
|
+
const xo=design[i];
|
|
10411
|
+
const se=Math.sqrt(Math.max(0,sigma2*quadForm(xo,cov)));
|
|
10412
|
+
return{x:matrix[i][0],yhat:fitted[i],lower:fitted[i]-tCrit*se,upper:fitted[i]+tCrit*se};
|
|
10413
|
+
}),
|
|
10414
|
+
};
|
|
10415
|
+
}
|
|
10416
|
+
return{
|
|
10417
|
+
method,
|
|
10418
|
+
coefficients,
|
|
10419
|
+
r2,
|
|
10420
|
+
adjR2,
|
|
10421
|
+
n,
|
|
10422
|
+
df,
|
|
10423
|
+
sigma2,
|
|
10424
|
+
fitted,
|
|
10425
|
+
residuals,
|
|
10426
|
+
leverage,
|
|
10427
|
+
cooksD,
|
|
10428
|
+
vif,
|
|
10429
|
+
heteroscedasticity:hetero,
|
|
10430
|
+
band,
|
|
10431
|
+
weights:w?[...w]:null,
|
|
10432
|
+
};
|
|
10433
|
+
}
|
|
9711
10434
|
function ranksOf(values){
|
|
9712
10435
|
const n=values.length;
|
|
9713
10436
|
const order=Array.from({length:n},(unused,i)=>i)
|
|
@@ -9723,6 +10446,119 @@ i=j+1;
|
|
|
9723
10446
|
}
|
|
9724
10447
|
return ranks;
|
|
9725
10448
|
}
|
|
10449
|
+
const ADF_CT_CRITICAL=Object.freeze({'1%':-3.9638,'5%':-3.4126,'10%':-3.1279});
|
|
10450
|
+
function adfInterpolatedP(stat){
|
|
10451
|
+
const levels=[0.01,0.05,0.10];
|
|
10452
|
+
const crit=[ADF_CT_CRITICAL['1%'],ADF_CT_CRITICAL['5%'],ADF_CT_CRITICAL['10%']];
|
|
10453
|
+
if(stat<=crit[0]){
|
|
10454
|
+
const slope=(Math.log(levels[1])-Math.log(levels[0]))/(crit[1]-crit[0]);
|
|
10455
|
+
return Math.max(1e-4,Math.min(0.01,Math.exp(Math.log(levels[0])+slope*(stat-crit[0]))));
|
|
10456
|
+
}
|
|
10457
|
+
if(stat>=crit[2]){
|
|
10458
|
+
const slope=(Math.log(levels[2])-Math.log(levels[1]))/(crit[2]-crit[1]);
|
|
10459
|
+
return Math.max(0.10,Math.min(0.999,Math.exp(Math.log(levels[2])+slope*(stat-crit[2]))));
|
|
10460
|
+
}
|
|
10461
|
+
const i=stat<crit[1]?0:1;
|
|
10462
|
+
const t=(stat-crit[i])/(crit[i+1]-crit[i]);
|
|
10463
|
+
return Math.exp(Math.log(levels[i])+t*(Math.log(levels[i+1])-Math.log(levels[i])));
|
|
10464
|
+
}
|
|
10465
|
+
function augmentedDickeyFuller(x,opts={}){
|
|
10466
|
+
const series=[];
|
|
10467
|
+
for(let i=0;i<x.length;i++){
|
|
10468
|
+
const v=Number(x[i]);
|
|
10469
|
+
if(Number.isFinite(v))series.push(v);
|
|
10470
|
+
}
|
|
10471
|
+
const n=series.length;
|
|
10472
|
+
const m=n-1;
|
|
10473
|
+
if(n<8||m<6)return null;
|
|
10474
|
+
const xdiff=new Array(m);
|
|
10475
|
+
for(let i=0;i<m;i++)xdiff[i]=series[i+1]-series[i];
|
|
10476
|
+
let maxlag=Number.isFinite(opts.maxlag)
|
|
10477
|
+
?Math.floor(opts.maxlag)
|
|
10478
|
+
:Math.ceil(12*(n/100)**0.25);
|
|
10479
|
+
maxlag=Math.max(0,Math.min(maxlag,Math.floor((m-5)/2)));
|
|
10480
|
+
const fit=(p,start)=>{
|
|
10481
|
+
const rows=[];
|
|
10482
|
+
const y=[];
|
|
10483
|
+
for(let j=start;j<m;j++){
|
|
10484
|
+
const row=[(j-start)+1,series[j]];
|
|
10485
|
+
for(let d=1;d<=p;d++)row.push(xdiff[j-d]);
|
|
10486
|
+
rows.push(row);
|
|
10487
|
+
y.push(xdiff[j]);
|
|
10488
|
+
}
|
|
10489
|
+
return fitLinearModel(rows,y,{method:'ols'});
|
|
10490
|
+
};
|
|
10491
|
+
const nFixed=m-maxlag;
|
|
10492
|
+
let bestLag=0;
|
|
10493
|
+
let bestAic=Infinity;
|
|
10494
|
+
for(let p=0;p<=maxlag;p++){
|
|
10495
|
+
const model=fit(p,maxlag);
|
|
10496
|
+
if(!model)continue;
|
|
10497
|
+
const params=p+3;
|
|
10498
|
+
const rss=model.sigma2*(nFixed-params);
|
|
10499
|
+
if(!(rss>0))continue;
|
|
10500
|
+
const aic=nFixed*Math.log(rss/nFixed)+2*params;
|
|
10501
|
+
if(aic<bestAic){bestAic=aic;bestLag=p;}
|
|
10502
|
+
}
|
|
10503
|
+
const finalModel=fit(bestLag,bestLag);
|
|
10504
|
+
if(!finalModel||!finalModel.coefficients[2])return null;
|
|
10505
|
+
const statistic=finalModel.coefficients[2].t;
|
|
10506
|
+
const pValue=adfInterpolatedP(statistic);
|
|
10507
|
+
const stationary=statistic<ADF_CT_CRITICAL['5%'];
|
|
10508
|
+
return{
|
|
10509
|
+
statistic,
|
|
10510
|
+
usedLag:bestLag,
|
|
10511
|
+
nobs:m-bestLag,
|
|
10512
|
+
criticalValues:{...ADF_CT_CRITICAL},
|
|
10513
|
+
pValue,
|
|
10514
|
+
pApproximate:true,
|
|
10515
|
+
stationary,
|
|
10516
|
+
verdict:stationary?'stationary':'non-stationary',
|
|
10517
|
+
regression:'ct',
|
|
10518
|
+
};
|
|
10519
|
+
}
|
|
10520
|
+
function autocorrelations(x,opts={}){
|
|
10521
|
+
const y=[];
|
|
10522
|
+
for(let i=0;i<x.length;i++){
|
|
10523
|
+
const v=Number(x[i]);
|
|
10524
|
+
if(Number.isFinite(v))y.push(v);
|
|
10525
|
+
}
|
|
10526
|
+
const n=y.length;
|
|
10527
|
+
if(n<3)return null;
|
|
10528
|
+
let maxlag=Number.isFinite(opts.maxlag)?Math.floor(opts.maxlag):Math.min(10,n-1);
|
|
10529
|
+
maxlag=Math.max(1,Math.min(maxlag,n-1));
|
|
10530
|
+
let mean=0;
|
|
10531
|
+
for(const v of y)mean+=v;
|
|
10532
|
+
mean/=n;
|
|
10533
|
+
const dev=y.map((v)=>v-mean);
|
|
10534
|
+
let c0=0;
|
|
10535
|
+
for(const d of dev)c0+=d*d;
|
|
10536
|
+
c0/=n;
|
|
10537
|
+
const acf=new Array(maxlag+1).fill(0);
|
|
10538
|
+
acf[0]=1;
|
|
10539
|
+
for(let k=1;k<=maxlag;k++){
|
|
10540
|
+
let s=0;
|
|
10541
|
+
for(let t=k;t<n;t++)s+=dev[t]*dev[t-k];
|
|
10542
|
+
acf[k]=c0>0?(s/n)/c0:0;
|
|
10543
|
+
}
|
|
10544
|
+
const pacf=new Array(maxlag+1).fill(0);
|
|
10545
|
+
pacf[0]=1;
|
|
10546
|
+
let prev=[];
|
|
10547
|
+
for(let k=1;k<=maxlag;k++){
|
|
10548
|
+
let num=acf[k];
|
|
10549
|
+
for(let j=1;j<k;j++)num-=prev[j-1]*acf[k-j];
|
|
10550
|
+
let den=1;
|
|
10551
|
+
for(let j=1;j<k;j++)den-=prev[j-1]*acf[j];
|
|
10552
|
+
const phikk=den!==0?num/den:0;
|
|
10553
|
+
const cur=new Array(k);
|
|
10554
|
+
for(let j=1;j<k;j++)cur[j-1]=prev[j-1]-phikk*prev[k-1-j];
|
|
10555
|
+
cur[k-1]=phikk;
|
|
10556
|
+
pacf[k]=phikk;
|
|
10557
|
+
prev=cur;
|
|
10558
|
+
}
|
|
10559
|
+
const bound=1.96/Math.sqrt(n);
|
|
10560
|
+
return{acf,pacf,bounds:{upper:bound,lower:-bound},n,nlags:maxlag,approximate:true};
|
|
10561
|
+
}
|
|
9726
10562
|
function spearman(a,b,indices){
|
|
9727
10563
|
const{xs,ys,n}=pairs(a,b,indices);
|
|
9728
10564
|
if(n<2)return null;
|
|
@@ -10519,6 +11355,350 @@ return new Window(opts.kind,span,now);
|
|
|
10519
11355
|
}
|
|
10520
11356
|
const __default={Window,WINDOW_KINDS,openWindow};
|
|
10521
11357
|
});
|
|
11358
|
+
__def("packages/core/src/compute/rolling.js",function(__exports,__req){
|
|
11359
|
+
'use strict';
|
|
11360
|
+
Object.defineProperty(__exports,"ROLLING_WINDOW_FIELDS",{enumerable:true,get:function(){return ROLLING_WINDOW_FIELDS;}});
|
|
11361
|
+
Object.defineProperty(__exports,"rollingWindow",{enumerable:true,get:function(){return rollingWindow;}});
|
|
11362
|
+
Object.defineProperty(__exports,"cumulativeToDate",{enumerable:true,get:function(){return cumulativeToDate;}});
|
|
11363
|
+
Object.defineProperty(__exports,"periodOverPeriod",{enumerable:true,get:function(){return periodOverPeriod;}});
|
|
11364
|
+
Object.defineProperty(__exports,"QUANTILE_SPAN_CAP",{enumerable:true,get:function(){return QUANTILE_SPAN_CAP;}});
|
|
11365
|
+
Object.defineProperty(__exports,"rollingQuantile",{enumerable:true,get:function(){return rollingQuantile;}});
|
|
11366
|
+
Object.defineProperty(__exports,"seasonalDecompose",{enumerable:true,get:function(){return seasonalDecompose;}});
|
|
11367
|
+
Object.defineProperty(__exports,"exponentialSmoothing",{enumerable:true,get:function(){return exponentialSmoothing;}});
|
|
11368
|
+
Object.defineProperty(__exports,"default",{enumerable:true,get:function(){return __default;}});
|
|
11369
|
+
const __m0=__req("packages/core/src/compute/windowed.js");
|
|
11370
|
+
const openWindow=__m0["openWindow"];
|
|
11371
|
+
const __m1=__req("packages/core/src/compute/sketch.js");
|
|
11372
|
+
const KLL=__m1["KLL"];
|
|
11373
|
+
const ROLLING_WINDOW_FIELDS=Object.freeze({
|
|
11374
|
+
rollingSum:'sum',
|
|
11375
|
+
rollingAvg:'avg',
|
|
11376
|
+
rollingMin:'min',
|
|
11377
|
+
rollingMax:'max',
|
|
11378
|
+
});
|
|
11379
|
+
function coverageOf(spec,size,at,firstAt){
|
|
11380
|
+
if(spec.kind==='count'){
|
|
11381
|
+
const span=Math.max(1,Math.floor(spec.span||0));
|
|
11382
|
+
return{coverage:Math.min(1,size/span),partial:size<span};
|
|
11383
|
+
}
|
|
11384
|
+
if(spec.kind==='time'){
|
|
11385
|
+
const span=spec.minutes!=null?spec.minutes*60_000:(spec.span||0);
|
|
11386
|
+
if(!(span>0))return{coverage:1,partial:false};
|
|
11387
|
+
const elapsed=at-firstAt;
|
|
11388
|
+
return{coverage:Math.min(1,elapsed/span),partial:elapsed<span};
|
|
11389
|
+
}
|
|
11390
|
+
return{coverage:null,partial:false};
|
|
11391
|
+
}
|
|
11392
|
+
function rollingWindow(seq,spec){
|
|
11393
|
+
const win=openWindow(spec);
|
|
11394
|
+
const out=new Map();
|
|
11395
|
+
const firstAt=seq.length?seq[0].at:0;
|
|
11396
|
+
for(let i=0;i<seq.length;i++){
|
|
11397
|
+
const{key,at,value}=seq[i];
|
|
11398
|
+
if(Number.isFinite(value))win.push(value,at);
|
|
11399
|
+
const agg=win.aggregate();
|
|
11400
|
+
const stamp=coverageOf(spec,agg.count,at,firstAt);
|
|
11401
|
+
if(key===null||key===undefined)continue;
|
|
11402
|
+
out.set(String(key),{
|
|
11403
|
+
sum:agg.sum,
|
|
11404
|
+
avg:agg.mean,
|
|
11405
|
+
min:agg.min,
|
|
11406
|
+
max:agg.max,
|
|
11407
|
+
count:agg.count,
|
|
11408
|
+
coverage:stamp.coverage,
|
|
11409
|
+
partial:stamp.partial,
|
|
11410
|
+
});
|
|
11411
|
+
}
|
|
11412
|
+
return out;
|
|
11413
|
+
}
|
|
11414
|
+
function cumulativeToDate(seq){
|
|
11415
|
+
const out=new Map();
|
|
11416
|
+
let total=0;
|
|
11417
|
+
for(const{key,value}of seq){
|
|
11418
|
+
if(Number.isFinite(value))total+=value;
|
|
11419
|
+
if(key===null||key===undefined)continue;
|
|
11420
|
+
out.set(String(key),total);
|
|
11421
|
+
}
|
|
11422
|
+
return out;
|
|
11423
|
+
}
|
|
11424
|
+
function periodOverPeriod(seq,lag=1){
|
|
11425
|
+
const out=new Map();
|
|
11426
|
+
const step=Math.max(1,Math.floor(lag));
|
|
11427
|
+
for(let i=0;i<seq.length;i++){
|
|
11428
|
+
const{key,value}=seq[i];
|
|
11429
|
+
if(key===null||key===undefined)continue;
|
|
11430
|
+
const prior=i>=step?seq[i-step].value:null;
|
|
11431
|
+
const now=Number.isFinite(value)?value:null;
|
|
11432
|
+
const was=Number.isFinite(prior)?prior:null;
|
|
11433
|
+
out.set(String(key),now!==null&&was!==null?now-was:null);
|
|
11434
|
+
}
|
|
11435
|
+
return out;
|
|
11436
|
+
}
|
|
11437
|
+
const QUANTILE_SPAN_CAP=4096;
|
|
11438
|
+
function seededRng(seed){
|
|
11439
|
+
let a=seed>>>0;
|
|
11440
|
+
return()=>{
|
|
11441
|
+
a+=0x6d2b79f5;
|
|
11442
|
+
let t=a;
|
|
11443
|
+
t=Math.imul(t^(t>>>15),t|1);
|
|
11444
|
+
t^=t+Math.imul(t^(t>>>7),t|61);
|
|
11445
|
+
return((t^(t>>>14))>>>0)/4294967296;
|
|
11446
|
+
};
|
|
11447
|
+
}
|
|
11448
|
+
function quantileSorted(sorted,p){
|
|
11449
|
+
const n=sorted.length;
|
|
11450
|
+
if(n===1)return sorted[0];
|
|
11451
|
+
const h=(n-1)*p;
|
|
11452
|
+
const lo=Math.floor(h);
|
|
11453
|
+
const hi=Math.ceil(h);
|
|
11454
|
+
return lo===hi?sorted[lo]:sorted[lo]+(h-lo)*(sorted[hi]-sorted[lo]);
|
|
11455
|
+
}
|
|
11456
|
+
function rollingQuantile(seq,spec,opts={}){
|
|
11457
|
+
const q=Math.min(1,Math.max(0,opts.q==null?0.5:opts.q));
|
|
11458
|
+
const cap=Math.max(1,Math.floor(opts.cap==null?QUANTILE_SPAN_CAP:opts.cap));
|
|
11459
|
+
const rng=seededRng(opts.seed==null?0x9e3779b9:opts.seed);
|
|
11460
|
+
const out=new Map();
|
|
11461
|
+
const firstAt=seq.length?seq[0].at:0;
|
|
11462
|
+
if(spec.kind==='session'){
|
|
11463
|
+
const sketch=new KLL(200,rng);
|
|
11464
|
+
let count=0;
|
|
11465
|
+
for(const{key,value}of seq){
|
|
11466
|
+
if(Number.isFinite(value)){sketch.add(value);count++;}
|
|
11467
|
+
if(key===null||key===undefined)continue;
|
|
11468
|
+
out.set(String(key),{
|
|
11469
|
+
value:count?sketch.quantile(q):null,
|
|
11470
|
+
approx:count>0,
|
|
11471
|
+
count,
|
|
11472
|
+
coverage:null,
|
|
11473
|
+
partial:false,
|
|
11474
|
+
});
|
|
11475
|
+
}
|
|
11476
|
+
return out;
|
|
11477
|
+
}
|
|
11478
|
+
const win=openWindow(spec);
|
|
11479
|
+
for(const{key,at,value}of seq){
|
|
11480
|
+
if(Number.isFinite(value))win.push(value,at);
|
|
11481
|
+
const values=win.values();
|
|
11482
|
+
const size=values.length;
|
|
11483
|
+
let value_=null;
|
|
11484
|
+
let approx=false;
|
|
11485
|
+
if(size){
|
|
11486
|
+
if(size<=cap){
|
|
11487
|
+
value_=quantileSorted([...values].sort((a,b)=>a-b),q);
|
|
11488
|
+
}else{
|
|
11489
|
+
const sketch=new KLL(200,rng);
|
|
11490
|
+
for(const v of values)sketch.add(v);
|
|
11491
|
+
value_=sketch.quantile(q);
|
|
11492
|
+
approx=true;
|
|
11493
|
+
}
|
|
11494
|
+
}
|
|
11495
|
+
const stamp=coverageOf(spec,size,at,firstAt);
|
|
11496
|
+
if(key===null||key===undefined)continue;
|
|
11497
|
+
out.set(String(key),{
|
|
11498
|
+
value:value_,approx,count:size,coverage:stamp.coverage,partial:stamp.partial,
|
|
11499
|
+
});
|
|
11500
|
+
}
|
|
11501
|
+
return out;
|
|
11502
|
+
}
|
|
11503
|
+
function centredTrend(y,m){
|
|
11504
|
+
const n=y.length;
|
|
11505
|
+
const trend=new Array(n).fill(null);
|
|
11506
|
+
const half=Math.floor(m/2);
|
|
11507
|
+
const even=m%2===0;
|
|
11508
|
+
for(let i=0;i<n;i++){
|
|
11509
|
+
if(i-half<0||i+half>=n)continue;
|
|
11510
|
+
let sum=0;
|
|
11511
|
+
let ok=true;
|
|
11512
|
+
if(even){
|
|
11513
|
+
for(let j=-half;j<=half;j++){
|
|
11514
|
+
const v=y[i+j];
|
|
11515
|
+
if(!Number.isFinite(v)){ok=false;break;}
|
|
11516
|
+
sum+=(j===-half||j===half)?v*0.5:v;
|
|
11517
|
+
}
|
|
11518
|
+
}else{
|
|
11519
|
+
for(let j=-half;j<=half;j++){
|
|
11520
|
+
const v=y[i+j];
|
|
11521
|
+
if(!Number.isFinite(v)){ok=false;break;}
|
|
11522
|
+
sum+=v;
|
|
11523
|
+
}
|
|
11524
|
+
}
|
|
11525
|
+
if(ok)trend[i]=sum/m;
|
|
11526
|
+
}
|
|
11527
|
+
return trend;
|
|
11528
|
+
}
|
|
11529
|
+
function seasonalDecompose(seq,opts){
|
|
11530
|
+
const out=new Map();
|
|
11531
|
+
const m=Math.floor(Number(opts&&opts.period));
|
|
11532
|
+
if(!(m>=2))return out;
|
|
11533
|
+
const multiplicative=opts&&opts.model==='multiplicative';
|
|
11534
|
+
const n=seq.length;
|
|
11535
|
+
const y=seq.map((row)=>(Number.isFinite(row.value)?row.value:null));
|
|
11536
|
+
const trend=centredTrend(y,m);
|
|
11537
|
+
const detrended=new Array(n).fill(null);
|
|
11538
|
+
for(let i=0;i<n;i++){
|
|
11539
|
+
const t=trend[i];
|
|
11540
|
+
const v=y[i];
|
|
11541
|
+
if(t===null||v===null)continue;
|
|
11542
|
+
if(multiplicative){if(t!==0)detrended[i]=v/t;}
|
|
11543
|
+
else detrended[i]=v-t;
|
|
11544
|
+
}
|
|
11545
|
+
const phaseSum=new Array(m).fill(0);
|
|
11546
|
+
const phaseCount=new Array(m).fill(0);
|
|
11547
|
+
for(let i=0;i<n;i++){
|
|
11548
|
+
if(detrended[i]===null)continue;
|
|
11549
|
+
const phase=i%m;
|
|
11550
|
+
phaseSum[phase]+=detrended[i];
|
|
11551
|
+
phaseCount[phase]+=1;
|
|
11552
|
+
}
|
|
11553
|
+
const identity=multiplicative?1:0;
|
|
11554
|
+
const phaseAvg=phaseSum.map((s,p)=>(phaseCount[p]?s/phaseCount[p]:identity));
|
|
11555
|
+
const mean=phaseAvg.reduce((a,b)=>a+b,0)/m;
|
|
11556
|
+
const seasonalIndex=multiplicative
|
|
11557
|
+
?phaseAvg.map((a)=>(mean!==0?a/mean:1))
|
|
11558
|
+
:phaseAvg.map((a)=>a-mean);
|
|
11559
|
+
for(let i=0;i<n;i++){
|
|
11560
|
+
const{key}=seq[i];
|
|
11561
|
+
if(key===null||key===undefined)continue;
|
|
11562
|
+
const t=trend[i];
|
|
11563
|
+
const s=seasonalIndex[i%m];
|
|
11564
|
+
const v=y[i];
|
|
11565
|
+
let residual=null;
|
|
11566
|
+
if(t!==null&&v!==null){
|
|
11567
|
+
residual=multiplicative
|
|
11568
|
+
?((t*s)!==0?v/(t*s):null)
|
|
11569
|
+
:v-t-s;
|
|
11570
|
+
}
|
|
11571
|
+
out.set(String(key),{
|
|
11572
|
+
trend:t,
|
|
11573
|
+
seasonal:v===null?null:s,
|
|
11574
|
+
residual,
|
|
11575
|
+
coverage:t===null?0:1,
|
|
11576
|
+
partial:t===null,
|
|
11577
|
+
});
|
|
11578
|
+
}
|
|
11579
|
+
return out;
|
|
11580
|
+
}
|
|
11581
|
+
function goldenMin(f,lo,hi,iters=80){
|
|
11582
|
+
const invphi=(Math.sqrt(5)-1)/2;
|
|
11583
|
+
let a=lo;
|
|
11584
|
+
let b=hi;
|
|
11585
|
+
let c=b-invphi*(b-a);
|
|
11586
|
+
let d=a+invphi*(b-a);
|
|
11587
|
+
let fc=f(c);
|
|
11588
|
+
let fd=f(d);
|
|
11589
|
+
for(let i=0;i<iters;i++){
|
|
11590
|
+
if(fc<fd){b=d;d=c;fd=fc;c=b-invphi*(b-a);fc=f(c);}
|
|
11591
|
+
else{a=c;c=d;fc=fd;d=a+invphi*(b-a);fd=f(d);}
|
|
11592
|
+
}
|
|
11593
|
+
return(a+b)/2;
|
|
11594
|
+
}
|
|
11595
|
+
const SMOOTH_LO=1e-4;
|
|
11596
|
+
const SMOOTH_HI=1-1e-4;
|
|
11597
|
+
function runSes(y,alpha){
|
|
11598
|
+
const n=y.length;
|
|
11599
|
+
const smoothed=new Array(n).fill(null);
|
|
11600
|
+
const fitted=new Array(n).fill(null);
|
|
11601
|
+
let level=null;
|
|
11602
|
+
let sse=0;
|
|
11603
|
+
for(let i=0;i<n;i++){
|
|
11604
|
+
const v=y[i];
|
|
11605
|
+
if(!Number.isFinite(v)){
|
|
11606
|
+
if(level!==null){fitted[i]=level;smoothed[i]=level;}
|
|
11607
|
+
continue;
|
|
11608
|
+
}
|
|
11609
|
+
if(level===null){level=v;fitted[i]=v;smoothed[i]=v;continue;}
|
|
11610
|
+
fitted[i]=level;
|
|
11611
|
+
sse+=(v-level)**2;
|
|
11612
|
+
level=alpha*v+(1-alpha)*level;
|
|
11613
|
+
smoothed[i]=level;
|
|
11614
|
+
}
|
|
11615
|
+
return{smoothed,fitted,sse};
|
|
11616
|
+
}
|
|
11617
|
+
function runHolt(y,alpha,beta){
|
|
11618
|
+
const n=y.length;
|
|
11619
|
+
const smoothed=new Array(n).fill(null);
|
|
11620
|
+
const fitted=new Array(n).fill(null);
|
|
11621
|
+
let level=null;
|
|
11622
|
+
let trend=null;
|
|
11623
|
+
let sse=0;
|
|
11624
|
+
for(let i=0;i<n;i++){
|
|
11625
|
+
const v=y[i];
|
|
11626
|
+
if(!Number.isFinite(v)){
|
|
11627
|
+
if(level!==null){level+=trend;smoothed[i]=level;}
|
|
11628
|
+
continue;
|
|
11629
|
+
}
|
|
11630
|
+
if(level===null){level=v;smoothed[i]=v;continue;}
|
|
11631
|
+
if(trend===null){
|
|
11632
|
+
trend=v-level;
|
|
11633
|
+
const forecast=level+trend;
|
|
11634
|
+
fitted[i]=forecast;
|
|
11635
|
+
sse+=(v-forecast)**2;
|
|
11636
|
+
const prev=level;
|
|
11637
|
+
level=alpha*v+(1-alpha)*(prev+trend);
|
|
11638
|
+
trend=beta*(level-prev)+(1-beta)*trend;
|
|
11639
|
+
smoothed[i]=level;
|
|
11640
|
+
continue;
|
|
11641
|
+
}
|
|
11642
|
+
const forecast=level+trend;
|
|
11643
|
+
fitted[i]=forecast;
|
|
11644
|
+
sse+=(v-forecast)**2;
|
|
11645
|
+
const prev=level;
|
|
11646
|
+
level=alpha*v+(1-alpha)*(prev+trend);
|
|
11647
|
+
trend=beta*(level-prev)+(1-beta)*trend;
|
|
11648
|
+
smoothed[i]=level;
|
|
11649
|
+
}
|
|
11650
|
+
return{smoothed,fitted,sse};
|
|
11651
|
+
}
|
|
11652
|
+
function exponentialSmoothing(seq,opts={}){
|
|
11653
|
+
const out=new Map();
|
|
11654
|
+
const holt=opts.method==='holt';
|
|
11655
|
+
const y=seq.map((row)=>(Number.isFinite(row.value)?row.value:null));
|
|
11656
|
+
const finite=y.filter((v)=>v!==null).length;
|
|
11657
|
+
const clamp=(x)=>Math.min(SMOOTH_HI,Math.max(SMOOTH_LO,x));
|
|
11658
|
+
const empty=()=>{
|
|
11659
|
+
for(const{key}of seq){
|
|
11660
|
+
if(key!==null&&key!==undefined){
|
|
11661
|
+
out.set(String(key),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});
|
|
11662
|
+
}
|
|
11663
|
+
}
|
|
11664
|
+
return out;
|
|
11665
|
+
};
|
|
11666
|
+
if(finite<(holt?2:1))return empty();
|
|
11667
|
+
let alpha=Number.isFinite(opts.alpha)?clamp(opts.alpha):null;
|
|
11668
|
+
let beta=holt&&Number.isFinite(opts.beta)?clamp(opts.beta):null;
|
|
11669
|
+
if(holt){
|
|
11670
|
+
if(alpha===null||beta===null){
|
|
11671
|
+
let a=alpha===null?0.5:alpha;
|
|
11672
|
+
let b=beta===null?0.5:beta;
|
|
11673
|
+
for(let round=0;round<6;round++){
|
|
11674
|
+
if(alpha===null)a=goldenMin((x)=>runHolt(y,x,b).sse,SMOOTH_LO,SMOOTH_HI);
|
|
11675
|
+
if(beta===null)b=goldenMin((x)=>runHolt(y,a,x).sse,SMOOTH_LO,SMOOTH_HI);
|
|
11676
|
+
}
|
|
11677
|
+
alpha=alpha===null?a:alpha;
|
|
11678
|
+
beta=beta===null?b:beta;
|
|
11679
|
+
}
|
|
11680
|
+
}else if(alpha===null){
|
|
11681
|
+
alpha=goldenMin((x)=>runSes(y,x).sse,SMOOTH_LO,SMOOTH_HI);
|
|
11682
|
+
}
|
|
11683
|
+
const run=holt?runHolt(y,alpha,beta):runSes(y,alpha);
|
|
11684
|
+
for(let i=0;i<seq.length;i++){
|
|
11685
|
+
const{key}=seq[i];
|
|
11686
|
+
if(key===null||key===undefined)continue;
|
|
11687
|
+
out.set(String(key),{
|
|
11688
|
+
smoothed:run.smoothed[i],
|
|
11689
|
+
fitted:run.fitted[i],
|
|
11690
|
+
alpha,
|
|
11691
|
+
beta:holt?beta:null,
|
|
11692
|
+
sse:run.sse,
|
|
11693
|
+
});
|
|
11694
|
+
}
|
|
11695
|
+
return out;
|
|
11696
|
+
}
|
|
11697
|
+
const __default={
|
|
11698
|
+
ROLLING_WINDOW_FIELDS,QUANTILE_SPAN_CAP,rollingWindow,rollingQuantile,
|
|
11699
|
+
cumulativeToDate,periodOverPeriod,seasonalDecompose,exponentialSmoothing,
|
|
11700
|
+
};
|
|
11701
|
+
});
|
|
10522
11702
|
__def("packages/core/src/compute/compare.js",function(__exports,__req){
|
|
10523
11703
|
'use strict';
|
|
10524
11704
|
Object.defineProperty(__exports,"COMPARE_MEASURES",{enumerable:true,get:function(){return COMPARE_MEASURES;}});
|
|
@@ -11497,10 +12677,14 @@ const valueReader=__m0["valueReader"];
|
|
|
11497
12677
|
const KEY_SEPARATOR='\u001F';
|
|
11498
12678
|
const NULL_MARKER='\u0000';
|
|
11499
12679
|
const MAX_DIRECT_COUNTS=1<<20;
|
|
11500
|
-
function packKeys(handles,idx,n){
|
|
12680
|
+
function packKeys(handles,idx,n,project){
|
|
11501
12681
|
const k=handles.length;
|
|
11502
|
-
const
|
|
11503
|
-
const
|
|
12682
|
+
const base=handles.map((h)=>valueReader(h));
|
|
12683
|
+
const projected=Array.isArray(project)&&project.some(Boolean);
|
|
12684
|
+
const readers=projected
|
|
12685
|
+
?base.map((r,j)=>(project[j]?(i)=>project[j](r(i)):r))
|
|
12686
|
+
:base;
|
|
12687
|
+
const allDictionary=!projected&&k>0&&handles.every((h)=>h&&h.kind==='dictionary'&&h.dict);
|
|
11504
12688
|
if(allDictionary){
|
|
11505
12689
|
const cards=handles.map((h)=>dictSize(h.dict)+1);
|
|
11506
12690
|
let product=1;
|
|
@@ -11550,7 +12734,7 @@ const list=handles||[];
|
|
|
11550
12734
|
const idx=order||identity(rowCount(list[0],opts));
|
|
11551
12735
|
const n=idx.length;
|
|
11552
12736
|
if(list.length===0||n===0)return{keys:[],buckets:[]};
|
|
11553
|
-
const{packed,strings,product,readers}=packKeys(list,idx,n);
|
|
12737
|
+
const{packed,strings,product,readers}=packKeys(list,idx,n,opts.project);
|
|
11554
12738
|
const ids=new Uint32Array(n);
|
|
11555
12739
|
let groups=0;
|
|
11556
12740
|
let packedKeys=null;
|
|
@@ -14513,13 +15697,16 @@ return node.op==='not'?!all:all;
|
|
|
14513
15697
|
if(node.col===undefined&&typeof opts.custom==='function')return!!opts.custom(node,row,index);
|
|
14514
15698
|
return testValue(referenceValue(row,node.col),node,opts.locale);
|
|
14515
15699
|
}
|
|
14516
|
-
function referenceGroup(rows,cols,order){
|
|
15700
|
+
function referenceGroup(rows,cols,order,project){
|
|
14517
15701
|
const source=order||rows.map((_,i)=>i);
|
|
14518
15702
|
const seen=new Map();
|
|
14519
15703
|
const keys=[];
|
|
14520
15704
|
const buckets=[];
|
|
14521
15705
|
for(const i of source){
|
|
14522
|
-
const tuple=cols.map((col)=>
|
|
15706
|
+
const tuple=cols.map((col,j)=>{
|
|
15707
|
+
const v=referenceValue(rows[i],col);
|
|
15708
|
+
return(project&&project[j])?project[j](v):v;
|
|
15709
|
+
});
|
|
14523
15710
|
const key=tuple
|
|
14524
15711
|
.map((v)=>(v===null||v===undefined?NULL_MARKER:String(v)))
|
|
14525
15712
|
.join(KEY_SEPARATOR);
|
|
@@ -15667,6 +16854,7 @@ mode='memory';
|
|
|
15667
16854
|
#factory;
|
|
15668
16855
|
#handles;
|
|
15669
16856
|
#stages=new Map();
|
|
16857
|
+
#pipelineActive=false;
|
|
15670
16858
|
#dataVersion=0;
|
|
15671
16859
|
#queryVersion=0;
|
|
15672
16860
|
#rowCache;
|
|
@@ -16152,6 +17340,16 @@ for(const colId of this.#queryColumns())if(touched.has(colId))return true;
|
|
|
16152
17340
|
return false;
|
|
16153
17341
|
}
|
|
16154
17342
|
#run(){
|
|
17343
|
+
if(this.#pipelineActive)return;
|
|
17344
|
+
this.#pipelineActive=true;
|
|
17345
|
+
try{
|
|
17346
|
+
this.#runStages();
|
|
17347
|
+
}finally{
|
|
17348
|
+
this.#pipelineActive=false;
|
|
17349
|
+
}
|
|
17350
|
+
}
|
|
17351
|
+
pipelineRunning(){return this.#pipelineActive;}
|
|
17352
|
+
#runStages(){
|
|
16155
17353
|
const filtered=this.#stage('filter',()=>this.#filterKey(),()=>this.#runFilter());
|
|
16156
17354
|
const sorted=this.#sortStage(filtered);
|
|
16157
17355
|
const grouped=this.#stage('group',()=>this.#groupKey(),()=>this.#runGroup(sorted));
|
|
@@ -16347,9 +17545,13 @@ unfilteredIndices(){
|
|
|
16347
17545
|
return this.#baseIndices();
|
|
16348
17546
|
}
|
|
16349
17547
|
filteredIndices(){
|
|
16350
|
-
this.#run();
|
|
16351
17548
|
const entry=this.#stages.get('filter');
|
|
16352
|
-
|
|
17549
|
+
if(entry&&entry.computed&&entry.key===this.#filterKey()){
|
|
17550
|
+
return entry.result||this.#baseIndices();
|
|
17551
|
+
}
|
|
17552
|
+
this.#run();
|
|
17553
|
+
const after=this.#stages.get('filter');
|
|
17554
|
+
const indices=after&&after.computed?after.result:null;
|
|
16353
17555
|
return indices||this.#baseIndices();
|
|
16354
17556
|
}
|
|
16355
17557
|
unfilteredRows(){
|
|
@@ -16461,15 +17663,29 @@ warnOnce(
|
|
|
16461
17663
|
);
|
|
16462
17664
|
}
|
|
16463
17665
|
if(!groupBy.length)return{roots:null,leaves:sorted,nodes:new Map()};
|
|
17666
|
+
const configZone=(this.#ctx.config||{}).timeZone;
|
|
16464
17667
|
const handles=[];
|
|
17668
|
+
const project=[];
|
|
17669
|
+
let anyProject=false;
|
|
16465
17670
|
for(const colId of groupBy){
|
|
16466
17671
|
const handle=this.#handles.handle(colId);
|
|
16467
17672
|
if(!handle){warnOnce(`source.group.${colId}`,`grouping ignores unknown column "${colId}".`);continue;}
|
|
16468
17673
|
handles.push(handle);
|
|
17674
|
+
const column=this.#column(colId);
|
|
17675
|
+
const dataType=column&&column.dataType;
|
|
17676
|
+
if(dataType&&isFunction(dataType.groupProjector)){
|
|
17677
|
+
const zone=(column.typeOptions&&column.typeOptions.timeZone)||column.timeZone||configZone||undefined;
|
|
17678
|
+
const proj=dataType.groupProjector(column,zone);
|
|
17679
|
+
project.push(proj||null);
|
|
17680
|
+
if(proj)anyProject=true;
|
|
17681
|
+
}else{
|
|
17682
|
+
project.push(null);
|
|
17683
|
+
}
|
|
16469
17684
|
}
|
|
16470
17685
|
if(!handles.length)return{roots:null,leaves:sorted,nodes:new Map()};
|
|
16471
17686
|
const{keys,buckets}=this.#kernel('groupByColumns')(handles,sorted,{
|
|
16472
17687
|
locale:(this.#ctx.config||{}).locale,
|
|
17688
|
+
project:anyProject?project:undefined,
|
|
16473
17689
|
});
|
|
16474
17690
|
const roots=[];
|
|
16475
17691
|
const nodes=new Map();
|
|
@@ -23802,11 +25018,11 @@ const isFunction=__m0["isFunction"];
|
|
|
23802
25018
|
const __m1=__req("packages/core/src/formatting/model.js");
|
|
23803
25019
|
const GRID_SCOPE=__m1["GRID_SCOPE"];
|
|
23804
25020
|
const isFormattingState=__m1["isFormattingState"];
|
|
23805
|
-
const STATE_VERSION=
|
|
25021
|
+
const STATE_VERSION=2;
|
|
23806
25022
|
const STATE_KEYS=([
|
|
23807
|
-
'columns','columnOrder','sort','filters','quick','quickMode','group','pivot',
|
|
25023
|
+
'columns','columnOrder','columnGroups','sort','filters','quick','quickMode','group','pivot',
|
|
23808
25024
|
'pivotView',
|
|
23809
|
-
'formatting','redaction','facets','expanded','selection','pagination','scroll',
|
|
25025
|
+
'formatting','redaction','annotations','facets','expanded','selection','pagination','scroll',
|
|
23810
25026
|
]);
|
|
23811
25027
|
function collector(){
|
|
23812
25028
|
const report={applied:[],skipped:[]};
|
|
@@ -23836,6 +25052,10 @@ if(t.columns&&isFunction(t.columns.state)){
|
|
|
23836
25052
|
const columns=t.columns.state();
|
|
23837
25053
|
state.columns=Array.isArray(columns)?columns.map((c)=>({...c})):[];
|
|
23838
25054
|
state.columnOrder=state.columns.map((c)=>c.id);
|
|
25055
|
+
if(isFunction(t.columns.groupTree)){
|
|
25056
|
+
const bands=t.columns.groupTree();
|
|
25057
|
+
if(Array.isArray(bands)&&bands.length)state.columnGroups=clone(bands);
|
|
25058
|
+
}
|
|
23839
25059
|
}
|
|
23840
25060
|
if(t.sort&&isFunction(t.sort.get))state.sort=clone(t.sort.get())||[];
|
|
23841
25061
|
if(t.filters&&isFunction(t.filters.get))state.filters=clone(t.filters.get())??null;
|
|
@@ -23858,6 +25078,10 @@ state.pivotView=clone(pv);
|
|
|
23858
25078
|
}
|
|
23859
25079
|
if(t.formatting&&isFunction(t.formatting.all))state.formatting=clone(t.formatting.all())||{};
|
|
23860
25080
|
if(t.redaction&&isFunction(t.redaction.list))state.redaction=t.redaction.list();
|
|
25081
|
+
if(t.annotations&&isFunction(t.annotations.list)){
|
|
25082
|
+
const marks=t.annotations.list();
|
|
25083
|
+
if(Array.isArray(marks)&&marks.length)state.annotations=marks;
|
|
25084
|
+
}
|
|
23861
25085
|
if(t.facets&&isFunction(t.facets.expanded))state.facets=t.facets.expanded();
|
|
23862
25086
|
if(t.expansion&&isFunction(t.expansion.expandedKeys))state.expanded=t.expansion.expandedKeys();
|
|
23863
25087
|
if(t.selection&&isFunction(t.selection.keys))state.selection=t.selection.keys();
|
|
@@ -23894,6 +25118,7 @@ return c.report;
|
|
|
23894
25118
|
switch(key){
|
|
23895
25119
|
case'columns':return this.#applyColumns(value,known,c,t);
|
|
23896
25120
|
case'columnOrder':return this.#applyOrder(value,known,c,t);
|
|
25121
|
+
case'columnGroups':return this.#applyColumnGroups(value,c,t);
|
|
23897
25122
|
case'sort':return this.#applySort(value,known,c,t);
|
|
23898
25123
|
case'filters':return this.#applyFilters(value,known,c,t);
|
|
23899
25124
|
case'quick':return this.#applySimple('quick',value,c,t.filters,'setQuick');
|
|
@@ -23903,6 +25128,7 @@ case'pivot':return this.#applyPivot(value,known,c,t);
|
|
|
23903
25128
|
case'pivotView':return this.#applySimple('pivotView',value,c,t.pivotView,'set');
|
|
23904
25129
|
case'formatting':return this.#applyFormatting(value,known,c,t);
|
|
23905
25130
|
case'redaction':return this.#applySimple('redaction',value,c,t.redaction,'set');
|
|
25131
|
+
case'annotations':return this.#applySimple('annotations',value,c,t.annotations,'set');
|
|
23906
25132
|
case'facets':return this.#applySimple('facets',value,c,t.facets,'setExpandedAll');
|
|
23907
25133
|
case'expanded':return this.#applySimple('expanded',value,c,t.expansion,'applyExpanded');
|
|
23908
25134
|
case'selection':return this.#applySimple('selection',value,c,t.selection,'set');
|
|
@@ -23946,6 +25172,12 @@ moved++;
|
|
|
23946
25172
|
}
|
|
23947
25173
|
return moved?c.applied('columnOrder'):c.skipped('columnOrder','no known columns in the saved order');
|
|
23948
25174
|
}
|
|
25175
|
+
#applyColumnGroups(value,c,t){
|
|
25176
|
+
if(!Array.isArray(value))return c.skipped('columnGroups','not an array');
|
|
25177
|
+
if(!t.columns||!isFunction(t.columns.applyGroupTree))return c.skipped('columnGroups','no column model');
|
|
25178
|
+
t.columns.applyGroupTree(value);
|
|
25179
|
+
return c.applied('columnGroups');
|
|
25180
|
+
}
|
|
23949
25181
|
#applySort(value,known,c,t){
|
|
23950
25182
|
if(!Array.isArray(value))return c.skipped('sort','not an array');
|
|
23951
25183
|
if(!t.sort||!isFunction(t.sort.set))return c.skipped('sort','no sort target');
|
|
@@ -24397,6 +25629,7 @@ const quick=diffScalar(String(a.quick||''),String(b.quick||''));
|
|
|
24397
25629
|
const group=diffIdList(a.group,b.group);
|
|
24398
25630
|
const pivot=diffPivot(a.pivot,b.pivot);
|
|
24399
25631
|
const pagination=diffScalar(a.pagination,b.pagination);
|
|
25632
|
+
const bands=diffBands(a.columnGroups,b.columnGroups);
|
|
24400
25633
|
const counts={
|
|
24401
25634
|
columnsMoved:columns.moved.length,
|
|
24402
25635
|
columnsHidden:columns.hidden.length,
|
|
@@ -24410,6 +25643,7 @@ columnsUnknown:columns.unknown.length,
|
|
|
24410
25643
|
sortChanges:sort.added.length+sort.removed.length+sort.redirected.length+(sort.reordered?1:0),
|
|
24411
25644
|
filterColumns:filters.added.length+filters.removed.length+filters.modified.length,
|
|
24412
25645
|
groupChanges:group.added.length+group.removed.length+(group.reordered?1:0),
|
|
25646
|
+
bandChanges:bands.added.length+bands.removed.length+bands.renamed.length+bands.restructured.length,
|
|
24413
25647
|
};
|
|
24414
25648
|
const sections=[];
|
|
24415
25649
|
if(columns.changed)sections.push('columns');
|
|
@@ -24419,6 +25653,7 @@ if(quick.changed)sections.push('quick');
|
|
|
24419
25653
|
if(group.changed)sections.push('group');
|
|
24420
25654
|
if(pivot.changed)sections.push('pivot');
|
|
24421
25655
|
if(pagination.changed)sections.push('pagination');
|
|
25656
|
+
if(bands.changed)sections.push('bands');
|
|
24422
25657
|
return{
|
|
24423
25658
|
changed:sections.length>0,
|
|
24424
25659
|
sections,
|
|
@@ -24430,9 +25665,48 @@ quick,
|
|
|
24430
25665
|
group,
|
|
24431
25666
|
pivot,
|
|
24432
25667
|
pagination,
|
|
25668
|
+
bands,
|
|
24433
25669
|
ignored:DIFF_IGNORED_KEYS,
|
|
24434
25670
|
};
|
|
24435
25671
|
}
|
|
25672
|
+
function diffBands(a,b){
|
|
25673
|
+
const from=bandMap(a);
|
|
25674
|
+
const to=bandMap(b);
|
|
25675
|
+
const added=[];
|
|
25676
|
+
const removed=[];
|
|
25677
|
+
const renamed=[];
|
|
25678
|
+
const restructured=[];
|
|
25679
|
+
for(const id of to.keys())if(!from.has(id))added.push(id);
|
|
25680
|
+
for(const id of from.keys()){
|
|
25681
|
+
if(!to.has(id)){removed.push(id);continue;}
|
|
25682
|
+
const x=from.get(id);
|
|
25683
|
+
const y=to.get(id);
|
|
25684
|
+
if(x.title!==y.title)renamed.push(id);
|
|
25685
|
+
if(x.members!==y.members)restructured.push(id);
|
|
25686
|
+
}
|
|
25687
|
+
return{
|
|
25688
|
+
changed:added.length>0||removed.length>0||renamed.length>0||restructured.length>0,
|
|
25689
|
+
added,
|
|
25690
|
+
removed,
|
|
25691
|
+
renamed,
|
|
25692
|
+
restructured,
|
|
25693
|
+
};
|
|
25694
|
+
}
|
|
25695
|
+
function bandMap(tree){
|
|
25696
|
+
const map=new Map();
|
|
25697
|
+
const walk=(nodes)=>{
|
|
25698
|
+
if(!Array.isArray(nodes))return;
|
|
25699
|
+
for(const node of nodes){
|
|
25700
|
+
if(isObject(node)&&Array.isArray(node.columns)){
|
|
25701
|
+
const members=node.columns.map((m)=>(isObject(m)?m.id:m)).join('\u0001');
|
|
25702
|
+
map.set(node.id,{title:String(node.title||''),members});
|
|
25703
|
+
walk(node.columns);
|
|
25704
|
+
}
|
|
25705
|
+
}
|
|
25706
|
+
};
|
|
25707
|
+
walk(tree);
|
|
25708
|
+
return map;
|
|
25709
|
+
}
|
|
24436
25710
|
function diffColumns(a,b,known){
|
|
24437
25711
|
const from=columnMap(a);
|
|
24438
25712
|
const to=columnMap(b);
|
|
@@ -32387,6 +33661,7 @@ const resolveDetail=__m7["resolveDetail"];
|
|
|
32387
33661
|
const __m8=__req("packages/core/src/model/shadow.js");
|
|
32388
33662
|
const ShadowTracker=__m8["ShadowTracker"];
|
|
32389
33663
|
const shadowsIn=__m8["shadowsIn"];
|
|
33664
|
+
const ROLLING_KINDS=__m8["ROLLING_KINDS"];
|
|
32390
33665
|
const __m9=__req("packages/core/src/compute/total.js");
|
|
32391
33666
|
const total=__m9["total"];
|
|
32392
33667
|
const aggregatesFor=__m9["aggregatesFor"];
|
|
@@ -32394,169 +33669,180 @@ const aggregateAllowed=__m9["aggregateAllowed"];
|
|
|
32394
33669
|
const __m10=__req("packages/core/src/compute/windowed.js");
|
|
32395
33670
|
const openWindow=__m10["openWindow"];
|
|
32396
33671
|
const WINDOW_KINDS=__m10["WINDOW_KINDS"];
|
|
32397
|
-
const __m11=__req("packages/core/src/compute/
|
|
32398
|
-
const
|
|
32399
|
-
const
|
|
32400
|
-
const
|
|
32401
|
-
const
|
|
32402
|
-
const
|
|
32403
|
-
const
|
|
32404
|
-
const
|
|
32405
|
-
const
|
|
32406
|
-
const
|
|
32407
|
-
const
|
|
32408
|
-
const
|
|
32409
|
-
const
|
|
32410
|
-
const
|
|
32411
|
-
const
|
|
32412
|
-
const
|
|
32413
|
-
const
|
|
32414
|
-
const
|
|
32415
|
-
const
|
|
32416
|
-
const
|
|
32417
|
-
const
|
|
32418
|
-
const
|
|
32419
|
-
const
|
|
32420
|
-
const
|
|
32421
|
-
const
|
|
32422
|
-
const
|
|
32423
|
-
const
|
|
32424
|
-
const
|
|
32425
|
-
const
|
|
32426
|
-
const
|
|
32427
|
-
const
|
|
32428
|
-
const __m13
|
|
32429
|
-
const
|
|
32430
|
-
const
|
|
32431
|
-
const
|
|
32432
|
-
const
|
|
32433
|
-
const
|
|
32434
|
-
const
|
|
32435
|
-
const
|
|
32436
|
-
const
|
|
32437
|
-
const
|
|
32438
|
-
const
|
|
32439
|
-
const
|
|
32440
|
-
const
|
|
32441
|
-
const
|
|
32442
|
-
const
|
|
32443
|
-
const
|
|
32444
|
-
const
|
|
32445
|
-
const
|
|
32446
|
-
const
|
|
32447
|
-
const
|
|
32448
|
-
const
|
|
32449
|
-
const
|
|
32450
|
-
const
|
|
32451
|
-
const
|
|
32452
|
-
const
|
|
32453
|
-
const
|
|
32454
|
-
const
|
|
32455
|
-
const
|
|
32456
|
-
const
|
|
32457
|
-
const
|
|
32458
|
-
const
|
|
32459
|
-
const
|
|
32460
|
-
const
|
|
32461
|
-
const
|
|
32462
|
-
const
|
|
32463
|
-
const
|
|
32464
|
-
const
|
|
32465
|
-
const
|
|
32466
|
-
const
|
|
32467
|
-
const
|
|
32468
|
-
const
|
|
32469
|
-
const
|
|
32470
|
-
const
|
|
32471
|
-
const
|
|
32472
|
-
const
|
|
32473
|
-
const
|
|
32474
|
-
const
|
|
32475
|
-
const
|
|
32476
|
-
const
|
|
32477
|
-
const
|
|
32478
|
-
const
|
|
32479
|
-
const
|
|
32480
|
-
const
|
|
32481
|
-
const
|
|
32482
|
-
const
|
|
32483
|
-
const
|
|
32484
|
-
const
|
|
32485
|
-
const
|
|
32486
|
-
const
|
|
32487
|
-
const
|
|
32488
|
-
const
|
|
32489
|
-
const
|
|
32490
|
-
const
|
|
32491
|
-
const
|
|
32492
|
-
const
|
|
32493
|
-
const
|
|
32494
|
-
const
|
|
32495
|
-
const
|
|
32496
|
-
const
|
|
32497
|
-
const
|
|
32498
|
-
const
|
|
32499
|
-
const
|
|
32500
|
-
const
|
|
32501
|
-
const
|
|
32502
|
-
const
|
|
32503
|
-
const
|
|
32504
|
-
const
|
|
32505
|
-
const
|
|
32506
|
-
const
|
|
32507
|
-
const
|
|
32508
|
-
const
|
|
32509
|
-
const
|
|
32510
|
-
const
|
|
32511
|
-
const
|
|
32512
|
-
const
|
|
32513
|
-
const
|
|
32514
|
-
const
|
|
32515
|
-
const
|
|
32516
|
-
const
|
|
32517
|
-
const
|
|
32518
|
-
const
|
|
32519
|
-
const
|
|
32520
|
-
const
|
|
32521
|
-
const
|
|
32522
|
-
const
|
|
32523
|
-
const
|
|
32524
|
-
const
|
|
32525
|
-
const
|
|
32526
|
-
const
|
|
32527
|
-
const
|
|
32528
|
-
const
|
|
32529
|
-
const
|
|
32530
|
-
const
|
|
32531
|
-
const
|
|
32532
|
-
const
|
|
32533
|
-
const
|
|
32534
|
-
const
|
|
32535
|
-
const
|
|
32536
|
-
const
|
|
32537
|
-
const
|
|
32538
|
-
const
|
|
32539
|
-
const
|
|
32540
|
-
const
|
|
32541
|
-
const
|
|
32542
|
-
const
|
|
32543
|
-
const
|
|
32544
|
-
const
|
|
32545
|
-
const
|
|
32546
|
-
const
|
|
32547
|
-
const
|
|
32548
|
-
const
|
|
32549
|
-
const
|
|
32550
|
-
const
|
|
32551
|
-
const
|
|
32552
|
-
const
|
|
32553
|
-
const
|
|
32554
|
-
const
|
|
32555
|
-
const
|
|
32556
|
-
const
|
|
32557
|
-
const
|
|
32558
|
-
const
|
|
32559
|
-
const
|
|
33672
|
+
const __m11=__req("packages/core/src/compute/rolling.js");
|
|
33673
|
+
const ROLLING_WINDOW_FIELDS=__m11["ROLLING_WINDOW_FIELDS"];
|
|
33674
|
+
const rollingWindow=__m11["rollingWindow"];
|
|
33675
|
+
const rollingQuantile=__m11["rollingQuantile"];
|
|
33676
|
+
const cumulativeToDate=__m11["cumulativeToDate"];
|
|
33677
|
+
const periodOverPeriod=__m11["periodOverPeriod"];
|
|
33678
|
+
const seasonalDecompose=__m11["seasonalDecompose"];
|
|
33679
|
+
const exponentialSmoothing=__m11["exponentialSmoothing"];
|
|
33680
|
+
const __m12=__req("packages/core/src/compute/handle.js");
|
|
33681
|
+
const statValueReader=__m12["valueReader"];
|
|
33682
|
+
const valueComparator=__m12["valueComparator"];
|
|
33683
|
+
const isMissing=__m12["isMissing"];
|
|
33684
|
+
const __m13=__req("packages/core/src/compute/statistics.js");
|
|
33685
|
+
const MAINTENANCE=__m13["MAINTENANCE"];
|
|
33686
|
+
const APPROXIMATE=__m13["APPROXIMATE"];
|
|
33687
|
+
const maintenanceOf=__m13["maintenanceOf"];
|
|
33688
|
+
const statCorrelation=__m13["correlation"];
|
|
33689
|
+
const statMoments=__m13["moments"];
|
|
33690
|
+
const countOutside=__m13["countOutside"];
|
|
33691
|
+
const statCapability=__m13["capability"];
|
|
33692
|
+
const statControlLimits=__m13["controlLimits"];
|
|
33693
|
+
const statControlViolations=__m13["controlViolations"];
|
|
33694
|
+
const statMeanInterval=__m13["meanInterval"];
|
|
33695
|
+
const statProportionInterval=__m13["proportionInterval"];
|
|
33696
|
+
const statSlopeInterval=__m13["slopeInterval"];
|
|
33697
|
+
const statCapabilityInterval=__m13["capabilityInterval"];
|
|
33698
|
+
const statCovariance=__m13["covariance"];
|
|
33699
|
+
const statHistogram=__m13["histogram"];
|
|
33700
|
+
const statKendall=__m13["kendall"];
|
|
33701
|
+
const statRegression=__m13["regression"];
|
|
33702
|
+
const statFitLinearModel=__m13["fitLinearModel"];
|
|
33703
|
+
const statSeries=__m13["seriesStats"];
|
|
33704
|
+
const statSpearman=__m13["spearman"];
|
|
33705
|
+
const statWeightedQuantile=__m13["weightedQuantile"];
|
|
33706
|
+
const statNumbers=__m13["numbers"];
|
|
33707
|
+
const statQuantileSorted=__m13["quantileSorted"];
|
|
33708
|
+
const statWeightedAverage=__m13["weightedAverage"];
|
|
33709
|
+
const statPopulationRead=__m13["populationRead"];
|
|
33710
|
+
const statCompareColumn=__m13["compareColumn"];
|
|
33711
|
+
const statIsNumericColumn=__m13["isNumericColumn"];
|
|
33712
|
+
const statAdf=__m13["augmentedDickeyFuller"];
|
|
33713
|
+
const statAcf=__m13["autocorrelations"];
|
|
33714
|
+
const __m14=__req("packages/core/src/compute/compare.js");
|
|
33715
|
+
const statCompareDatasets=__m14["compareDatasets"];
|
|
33716
|
+
const __m15=__req("packages/core/src/compute/anomaly.js");
|
|
33717
|
+
const anomalyModifiedZScores=__m15["modifiedZScores"];
|
|
33718
|
+
const anomalyIqrFences=__m15["iqrFences"];
|
|
33719
|
+
const anomalyMahalanobis=__m15["mahalanobis"];
|
|
33720
|
+
const ANOMALY_METHODS=__m15["ANOMALY_METHODS"];
|
|
33721
|
+
const __m16=__req("packages/core/src/compute/hypothesis.js");
|
|
33722
|
+
const statCompareGroups=__m16["compareGroups"];
|
|
33723
|
+
const __m17=__req("packages/core/src/columns/detailcolumn.js");
|
|
33724
|
+
const createDetailColumn=__m17["createDetailColumn"];
|
|
33725
|
+
const DETAIL_COLUMN_ID=__m17["DETAIL_COLUMN_ID"];
|
|
33726
|
+
const __m18=__req("packages/core/src/columns/treecolumn.js");
|
|
33727
|
+
const createTreeColumn=__m18["createTreeColumn"];
|
|
33728
|
+
const TREE_COLUMN_ID=__m18["TREE_COLUMN_ID"];
|
|
33729
|
+
const __m19=__req("packages/core/src/columns/pivotcolumns.js");
|
|
33730
|
+
const createPivotColumns=__m19["createPivotColumns"];
|
|
33731
|
+
const __m20=__req("packages/core/src/compute/pivot.js");
|
|
33732
|
+
const pivotKey=__m20["pivotKey"];
|
|
33733
|
+
const DEFAULT_PATH_SEPARATOR=__m20["DEFAULT_PATH_SEPARATOR"];
|
|
33734
|
+
const __m21=__req("packages/core/src/columns/value.js");
|
|
33735
|
+
const ValuePipeline=__m21["ValuePipeline"];
|
|
33736
|
+
const __m22=__req("packages/core/src/store/columnstore.js");
|
|
33737
|
+
const ColumnStore=__m22["ColumnStore"];
|
|
33738
|
+
const __m23=__req("packages/core/src/store/pool.js");
|
|
33739
|
+
const MaskPool=__m23["MaskPool"];
|
|
33740
|
+
const __m24=__req("packages/core/src/compute/index.js");
|
|
33741
|
+
const compute=__m24;
|
|
33742
|
+
const __m25=__req("packages/core/src/source/index.js");
|
|
33743
|
+
const createSource=__m25["createSource"];
|
|
33744
|
+
const DERIVED_ROW_KEY=__m25["DERIVED_ROW_KEY"];
|
|
33745
|
+
const __m26=__req("packages/core/src/source/rows.js");
|
|
33746
|
+
const pinnedRow=__m26["pinnedRow"];
|
|
33747
|
+
const DEFAULT_ROW_HEIGHT=__m26["DEFAULT_ROW_HEIGHT"];
|
|
33748
|
+
const __m27=__req("packages/core/src/model/rowkey.js");
|
|
33749
|
+
const createRowKey=__m27["createRowKey"];
|
|
33750
|
+
const __m28=__req("packages/core/src/model/rowmodel.js");
|
|
33751
|
+
const RowModel=__m28["RowModel"];
|
|
33752
|
+
const createRow=__m28["createRow"];
|
|
33753
|
+
const __m29=__req("packages/core/src/model/selection.js");
|
|
33754
|
+
const SelectionModel=__m29["SelectionModel"];
|
|
33755
|
+
const RangeModel=__m29["RangeModel"];
|
|
33756
|
+
const summarise=__m29["summarise"];
|
|
33757
|
+
const detectSeries=__m29["detectSeries"];
|
|
33758
|
+
const extendSeries=__m29["extendSeries"];
|
|
33759
|
+
const __m30=__req("packages/core/src/model/history.js");
|
|
33760
|
+
const HistoryModel=__m30["HistoryModel"];
|
|
33761
|
+
const __m31=__req("packages/core/src/model/diff.js");
|
|
33762
|
+
const DiffModel=__m31["DiffModel"];
|
|
33763
|
+
const readValue=__m31["readValue"];
|
|
33764
|
+
const __m32=__req("packages/core/src/model/views.js");
|
|
33765
|
+
const ViewStore=__m32["ViewStore"];
|
|
33766
|
+
const __m33=__req("packages/core/src/model/highlight.js");
|
|
33767
|
+
const HighlightModel=__m33["HighlightModel"];
|
|
33768
|
+
const __m34=__req("packages/core/src/model/redaction.js");
|
|
33769
|
+
const RedactionModel=__m34["RedactionModel"];
|
|
33770
|
+
const __m35=__req("packages/core/src/model/presentation.js");
|
|
33771
|
+
const PresentationModel=__m35["PresentationModel"];
|
|
33772
|
+
const __m36=__req("packages/core/src/model/timeline.js");
|
|
33773
|
+
const Timeline=__m36["Timeline"];
|
|
33774
|
+
const __m37=__req("packages/core/src/model/facets.js");
|
|
33775
|
+
const FacetModel=__m37["FacetModel"];
|
|
33776
|
+
const DEFAULT_DEBOUNCE=__m37["DEFAULT_DEBOUNCE"];
|
|
33777
|
+
const DEFAULT_ROW_CEILING=__m37["DEFAULT_ROW_CEILING"];
|
|
33778
|
+
const DEFAULT_FACET_HEIGHT=__m37["DEFAULT_FACET_HEIGHT"];
|
|
33779
|
+
const __m38=__req("packages/core/src/model/comments.js");
|
|
33780
|
+
const CommentModel=__m38["CommentModel"];
|
|
33781
|
+
const parseCommentKey=__m38["parseCellKey"];
|
|
33782
|
+
const DEFAULT_INDEX_DEBOUNCE=__m38["DEFAULT_INDEX_DEBOUNCE"];
|
|
33783
|
+
const DEFAULT_INDEX_LIMIT=__m38["DEFAULT_INDEX_LIMIT"];
|
|
33784
|
+
const __m39=__req("packages/core/src/model/diagnostics.js");
|
|
33785
|
+
const Diagnostics=__m39["Diagnostics"];
|
|
33786
|
+
const WARNING_IDS=__m39["WARNING_IDS"];
|
|
33787
|
+
const instrument=__m39["instrument"];
|
|
33788
|
+
const instrumentProvider=__m39["instrumentProvider"];
|
|
33789
|
+
const __m40=__req("packages/core/src/model/presence.js");
|
|
33790
|
+
const PresenceModel=__m40["PresenceModel"];
|
|
33791
|
+
const DEFAULT_THROTTLE_MS=__m40["DEFAULT_THROTTLE_MS"];
|
|
33792
|
+
const DEFAULT_IDLE_MS=__m40["DEFAULT_IDLE_MS"];
|
|
33793
|
+
const DEFAULT_REMOVE_MS=__m40["DEFAULT_REMOVE_MS"];
|
|
33794
|
+
const DEFAULT_LOCK_MS=__m40["DEFAULT_LOCK_MS"];
|
|
33795
|
+
const __m41=__req("packages/core/src/compute/facet.js");
|
|
33796
|
+
const facetKind=__m41["facetKind"];
|
|
33797
|
+
const DEFAULT_BUCKETS=__m41["DEFAULT_BUCKETS"];
|
|
33798
|
+
const DEFAULT_CARDINALITY_LIMIT=__m41["DEFAULT_CARDINALITY_LIMIT"];
|
|
33799
|
+
const __m42=__req("packages/worker/src/host.js");
|
|
33800
|
+
const createWorkerHost=__m42["createWorkerHost"];
|
|
33801
|
+
const __m43=__req("packages/core/src/i18n/index.js");
|
|
33802
|
+
const Messages=__m43["Messages"];
|
|
33803
|
+
const MESSAGE_KEYS=__m43["MESSAGE_KEYS"];
|
|
33804
|
+
const __m44=__req("packages/core/src/model/pending.js");
|
|
33805
|
+
const PendingWrites=__m44["PendingWrites"];
|
|
33806
|
+
const __m45=__req("packages/core/src/model/pending-rows.js");
|
|
33807
|
+
const PendingRows=__m45["PendingRows"];
|
|
33808
|
+
const isTempKey=__m45["isTempKey"];
|
|
33809
|
+
const __m46=__req("packages/core/src/registry/licence.js");
|
|
33810
|
+
const setSharedLicence=__m46["setLicence"];
|
|
33811
|
+
const licenceInfo=__m46["licenceInfo"];
|
|
33812
|
+
const licenceWatermark=__m46["watermark"];
|
|
33813
|
+
const licenceState=__m46["licenceState"];
|
|
33814
|
+
const sharedLicence=__m46["sharedLicence"];
|
|
33815
|
+
const __m47=__req("packages/core/src/columns/permissions.js");
|
|
33816
|
+
const PermissionModel=__m47["PermissionModel"];
|
|
33817
|
+
const __m48=__req("packages/core/src/ai/schema.js");
|
|
33818
|
+
const describeGrid=__m48["describeGrid"];
|
|
33819
|
+
const promptText=__m48["promptText"];
|
|
33820
|
+
const toolDefinition=__m48["toolDefinition"];
|
|
33821
|
+
const __m49=__req("packages/core/src/ai/intent.js");
|
|
33822
|
+
const planIntent=__m49["planIntent"];
|
|
33823
|
+
const applyPlan=__m49["applyPlan"];
|
|
33824
|
+
const buildPrompt=__m49["buildPrompt"];
|
|
33825
|
+
const __m50=__req("packages/core/src/model/edit.js");
|
|
33826
|
+
const EditModel=__m50["EditModel"];
|
|
33827
|
+
const __m51=__req("packages/core/src/model/changes.js");
|
|
33828
|
+
const ChangeModel=__m51["ChangeModel"];
|
|
33829
|
+
const __m52=__req("packages/core/src/model/state.js");
|
|
33830
|
+
const StateModel=__m52["StateModel"];
|
|
33831
|
+
const __m53=__req("packages/core/src/formatting/model.js");
|
|
33832
|
+
const FormattingModel=__m53["FormattingModel"];
|
|
33833
|
+
const GRID_SCOPE=__m53["GRID_SCOPE"];
|
|
33834
|
+
const __m54=__req("packages/core/src/formatting/rules.js");
|
|
33835
|
+
const summariseColumn=__m54["summariseColumn"];
|
|
33836
|
+
const __m55=__req("packages/core/src/export/index.js");
|
|
33837
|
+
const exportCsv=__m55["exportCsv"];
|
|
33838
|
+
const exportExcel=__m55["exportExcel"];
|
|
33839
|
+
const copyToClipboard=__m55["copyToClipboard"];
|
|
33840
|
+
const writeClipboardText=__m55["writeClipboardText"];
|
|
33841
|
+
const printGrid=__m55["printGrid"];
|
|
33842
|
+
const buildClipboardText=__m55["buildClipboardText"];
|
|
33843
|
+
const pasteIntoRange=__m55["pasteIntoRange"];
|
|
33844
|
+
const writeHookFor=__m55["writeHookFor"];
|
|
33845
|
+
const parseClipboardText=__m55["parseClipboardText"];
|
|
32560
33846
|
const QUICK_MODES=['contains','words','fuzzy','regex'];
|
|
32561
33847
|
function canonicalise(column,value){
|
|
32562
33848
|
const lookup=column&&column.lookup;
|
|
@@ -32785,6 +34071,7 @@ static#nextSourceId=1;
|
|
|
32785
34071
|
#pinnedBottomCache=null;
|
|
32786
34072
|
#diffSwapped=false;
|
|
32787
34073
|
#redaction;
|
|
34074
|
+
#annotationSeed=[];
|
|
32788
34075
|
#presentation;
|
|
32789
34076
|
#facets;
|
|
32790
34077
|
#comments;
|
|
@@ -32832,8 +34119,11 @@ pageSize:0,
|
|
|
32832
34119
|
#renderer=null;
|
|
32833
34120
|
#destroyed=false;
|
|
32834
34121
|
#shadows=new Map();
|
|
34122
|
+
#fitShadowCache=null;
|
|
34123
|
+
#fittingShadow=false;
|
|
32835
34124
|
#running=new Map();
|
|
32836
34125
|
#filteredKeyCache=null;
|
|
34126
|
+
#rollingCache=new Map();
|
|
32837
34127
|
#ready=false;
|
|
32838
34128
|
#teardown=new Set();
|
|
32839
34129
|
constructor(config={}){
|
|
@@ -33398,6 +34688,19 @@ set:(v)=>this.#renderer&&isFunction(this.#renderer.applyPivotState)
|
|
|
33398
34688
|
},
|
|
33399
34689
|
formatting:this.#formatting,
|
|
33400
34690
|
redaction:this.#redaction,
|
|
34691
|
+
annotations:{
|
|
34692
|
+
list:()=>(this.annotate&&isFunction(this.annotate.list)
|
|
34693
|
+
?this.annotate.list()
|
|
34694
|
+
:this.#annotationSeed.slice()),
|
|
34695
|
+
set:(marks)=>{
|
|
34696
|
+
const arr=Array.isArray(marks)?marks.slice():[];
|
|
34697
|
+
if(this.annotate&&isFunction(this.annotate.replaceAll)){
|
|
34698
|
+
this.annotate.replaceAll(arr);
|
|
34699
|
+
}else{
|
|
34700
|
+
this.#annotationSeed=arr;
|
|
34701
|
+
}
|
|
34702
|
+
},
|
|
34703
|
+
},
|
|
33401
34704
|
facets:this.#facets,
|
|
33402
34705
|
expansion:this.#rowModel,
|
|
33403
34706
|
selection:{keys:()=>this.#selection.keys(),set:(k)=>this.#selection.set(k)},
|
|
@@ -33771,6 +35074,7 @@ move:'column:moved',
|
|
|
33771
35074
|
visible:'column:visible',
|
|
33772
35075
|
pin:'column:pinned',
|
|
33773
35076
|
resize:'column:resized',
|
|
35077
|
+
columngroup:'columngroup:changed',
|
|
33774
35078
|
locale:'model:changed',
|
|
33775
35079
|
lookup:'model:changed',
|
|
33776
35080
|
state:'model:changed',
|
|
@@ -33788,6 +35092,7 @@ this.#refresh('rows');
|
|
|
33788
35092
|
}
|
|
33789
35093
|
#refresh(reason){
|
|
33790
35094
|
if(this.#destroyed)return;
|
|
35095
|
+
this.#rollingCache.clear();
|
|
33791
35096
|
this.#observeShadows();
|
|
33792
35097
|
this.#selection.sync?.();
|
|
33793
35098
|
this.#bus.emit('model:changed',{reason},'api');
|
|
@@ -33879,6 +35184,89 @@ out[i]=key===null||key===undefined?null:String(key);
|
|
|
33879
35184
|
}
|
|
33880
35185
|
return out;
|
|
33881
35186
|
}
|
|
35187
|
+
#fitModelOver(spec,indices){
|
|
35188
|
+
const s=spec||{};
|
|
35189
|
+
const predictors=Array.isArray(s.predictors)?s.predictors:[];
|
|
35190
|
+
if(!predictors.length||!s.response)return null;
|
|
35191
|
+
const predHandles=predictors.map((id)=>this.#handleFor(id));
|
|
35192
|
+
const respHandle=this.#handleFor(s.response);
|
|
35193
|
+
if(!respHandle||predHandles.some((h)=>!h))return null;
|
|
35194
|
+
const weightHandle=s.weights?this.#handleFor(s.weights):null;
|
|
35195
|
+
if(s.weights&&!weightHandle)return null;
|
|
35196
|
+
this.#warnWindowedStat('regressionModel',`${predictors.join(',')}~${s.response}`,indices.length);
|
|
35197
|
+
const readY=statValueReader(respHandle);
|
|
35198
|
+
const readP=predHandles.map((h)=>statValueReader(h));
|
|
35199
|
+
const readW=weightHandle?statValueReader(weightHandle):null;
|
|
35200
|
+
const matrix=[];
|
|
35201
|
+
const y=[];
|
|
35202
|
+
const weights=readW?[]:null;
|
|
35203
|
+
const rows=[];
|
|
35204
|
+
for(let i=0;i<indices.length;i++){
|
|
35205
|
+
const row=indices[i];
|
|
35206
|
+
const yv=Number(readY(row));
|
|
35207
|
+
const xs=readP.map((r)=>Number(r(row)));
|
|
35208
|
+
const wv=readW?Number(readW(row)):1;
|
|
35209
|
+
if(!Number.isFinite(yv)||xs.some((v)=>!Number.isFinite(v)))continue;
|
|
35210
|
+
if(readW&&!(wv>0))continue;
|
|
35211
|
+
matrix.push(xs);
|
|
35212
|
+
y.push(yv);
|
|
35213
|
+
if(weights)weights.push(wv);
|
|
35214
|
+
rows.push(row);
|
|
35215
|
+
}
|
|
35216
|
+
const model=statFitLinearModel(matrix,y,{
|
|
35217
|
+
method:s.method||'ols',
|
|
35218
|
+
weights:weights||undefined,
|
|
35219
|
+
confidence:s.confidence,
|
|
35220
|
+
names:predictors,
|
|
35221
|
+
});
|
|
35222
|
+
if(!model)return null;
|
|
35223
|
+
return{...model,predictors:[...predictors],response:s.response,rows};
|
|
35224
|
+
}
|
|
35225
|
+
#fitShadowMap(spec){
|
|
35226
|
+
const s=spec||{};
|
|
35227
|
+
if(!Array.isArray(s.predictors)||!s.predictors.length||!s.response)return null;
|
|
35228
|
+
const source=this.#source;
|
|
35229
|
+
const running=this.#fittingShadow
|
|
35230
|
+
||(source&&isFunction(source.pipelineRunning)&&source.pipelineRunning());
|
|
35231
|
+
this.#fittingShadow=true;
|
|
35232
|
+
let indices;
|
|
35233
|
+
let model;
|
|
35234
|
+
let sig;
|
|
35235
|
+
try{
|
|
35236
|
+
indices=running?this.#populationIndices():this.#statIndices();
|
|
35237
|
+
sig=JSON.stringify([s.predictors,s.response,s.method||'ols',s.weights||null,s.confidence??null,running]);
|
|
35238
|
+
if(this.#fitShadowCache&&this.#fitShadowCache.indices===indices&&this.#fitShadowCache.sig===sig){
|
|
35239
|
+
return this.#fitShadowCache.map;
|
|
35240
|
+
}
|
|
35241
|
+
model=this.#fitModelOver(s,indices);
|
|
35242
|
+
}finally{
|
|
35243
|
+
this.#fittingShadow=false;
|
|
35244
|
+
}
|
|
35245
|
+
let map=null;
|
|
35246
|
+
if(model&&Array.isArray(model.rows)){
|
|
35247
|
+
const keys=this.#indexKeys(model.rows);
|
|
35248
|
+
const byKey=new Map();
|
|
35249
|
+
const s=Number.isFinite(model.sigma2)&&model.sigma2>0?Math.sqrt(model.sigma2):null;
|
|
35250
|
+
for(let i=0;i<model.rows.length;i++){
|
|
35251
|
+
const key=keys[i];
|
|
35252
|
+
if(key==null)continue;
|
|
35253
|
+
const leverage=model.leverage?model.leverage[i]:null;
|
|
35254
|
+
const denom=(s!==null&&Number.isFinite(leverage)&&leverage<1)
|
|
35255
|
+
?s*Math.sqrt(1-leverage):null;
|
|
35256
|
+
const stdResidual=denom&&denom>0?model.residuals[i]/denom:null;
|
|
35257
|
+
byKey.set(key,{
|
|
35258
|
+
predicted:model.fitted[i],
|
|
35259
|
+
residual:model.residuals[i],
|
|
35260
|
+
cooksD:model.cooksD[i],
|
|
35261
|
+
leverage:Number.isFinite(leverage)?leverage:null,
|
|
35262
|
+
stdResidual,
|
|
35263
|
+
});
|
|
35264
|
+
}
|
|
35265
|
+
map={byKey,n:model.n};
|
|
35266
|
+
}
|
|
35267
|
+
this.#fitShadowCache={indices,sig,map};
|
|
35268
|
+
return map;
|
|
35269
|
+
}
|
|
33882
35270
|
#numericColumnsFor(ids,indices){
|
|
33883
35271
|
const columns=[];
|
|
33884
35272
|
const skipped=[];
|
|
@@ -34020,6 +35408,176 @@ values.set(key,kind==='percent'?(grand?(total/grand)*100:null):total);
|
|
|
34020
35408
|
this.#running.set(colId,{rows,kind,values});
|
|
34021
35409
|
return values;
|
|
34022
35410
|
}
|
|
35411
|
+
#rollingShadow(of,spec,rowKey){
|
|
35412
|
+
const map=this.#rollingMap(of,spec);
|
|
35413
|
+
if(!map)return null;
|
|
35414
|
+
const record=map.get(String(rowKey));
|
|
35415
|
+
if(!record)return null;
|
|
35416
|
+
const field=ROLLING_WINDOW_FIELDS[spec.kind];
|
|
35417
|
+
if(field)return record[field];
|
|
35418
|
+
if(spec.kind==='windowCoverage')return record.coverage;
|
|
35419
|
+
if(spec.kind==='windowApproximate')return record.approx===undefined?null:record.approx;
|
|
35420
|
+
if(spec.kind==='tsTrend')return record.trend;
|
|
35421
|
+
if(spec.kind==='tsSeasonal')return record.seasonal;
|
|
35422
|
+
if(spec.kind==='tsResidual')return record.residual;
|
|
35423
|
+
if(spec.kind==='tsCoverage')return record.coverage===undefined?null:record.coverage;
|
|
35424
|
+
if(spec.kind==='tsSmoothed')return record.smoothed;
|
|
35425
|
+
if(spec.kind==='tsSmoothingAlpha')return record.alpha===undefined?null:record.alpha;
|
|
35426
|
+
if(spec.kind==='tsSmoothingBeta')return record.beta===undefined?null:record.beta;
|
|
35427
|
+
return record.value;
|
|
35428
|
+
}
|
|
35429
|
+
#rollingMap(of,spec){
|
|
35430
|
+
const orderBy=spec&&spec.orderBy;
|
|
35431
|
+
if(!orderBy){
|
|
35432
|
+
warnOnce(
|
|
35433
|
+
`grid.rolling.orderBy:${of}:${spec&&spec.kind}`,
|
|
35434
|
+
`a '${spec&&spec.kind}' rolling column needs an 'orderBy' column to define its `
|
|
35435
|
+
+'order — the screen sort is never used, because a rolling figure would then '
|
|
35436
|
+
+'change on every header click. It reported null until an orderBy is set.',
|
|
35437
|
+
);
|
|
35438
|
+
return null;
|
|
35439
|
+
}
|
|
35440
|
+
const DECOMPOSE_KINDS=new Set(['tsTrend','tsSeasonal','tsResidual','tsCoverage']);
|
|
35441
|
+
const SMOOTH_KINDS=new Set(['tsSmoothed','tsSmoothingAlpha','tsSmoothingBeta']);
|
|
35442
|
+
let family=null;
|
|
35443
|
+
if(ROLLING_WINDOW_FIELDS[spec.kind]||spec.kind==='windowCoverage')family='window';
|
|
35444
|
+
else if(spec.kind==='rollingQuantile'||spec.kind==='windowApproximate')family='quantile';
|
|
35445
|
+
else if(DECOMPOSE_KINDS.has(spec.kind))family='decompose';
|
|
35446
|
+
else if(SMOOTH_KINDS.has(spec.kind))family='smooth';
|
|
35447
|
+
else if(spec.kind==='cumulativeToDate')family='cumulative';
|
|
35448
|
+
else if(spec.kind==='periodOverPeriod')family='pop';
|
|
35449
|
+
if(!family)return null;
|
|
35450
|
+
const within=spec.within==='all'?'all':'group';
|
|
35451
|
+
const groupBy=within==='group'?(this.#query.groupBy||[]):[];
|
|
35452
|
+
let windowSpec=null;
|
|
35453
|
+
if(family==='window'||family==='quantile'){
|
|
35454
|
+
windowSpec=this.#rollingWindowSpec(spec.window,of,spec.kind);
|
|
35455
|
+
if(!windowSpec)return null;
|
|
35456
|
+
}
|
|
35457
|
+
const q=family==='quantile'?this.#rollingQuantileOf(spec.q):null;
|
|
35458
|
+
const decompose=family==='decompose'?this.#rollingDecomposeSpec(spec,of):null;
|
|
35459
|
+
if(family==='decompose'&&!decompose)return null;
|
|
35460
|
+
const smooth=family==='smooth'?this.#rollingSmoothSpec(spec):null;
|
|
35461
|
+
const signature=JSON.stringify([family,of,orderBy,within,groupBy,windowSpec,q,decompose,smooth]);
|
|
35462
|
+
const cached=this.#rollingCache.get(signature);
|
|
35463
|
+
if(cached)return cached;
|
|
35464
|
+
const partitions=this.#rollingPartitions(of,orderBy,groupBy);
|
|
35465
|
+
if(!partitions)return null;
|
|
35466
|
+
const out=new Map();
|
|
35467
|
+
for(const seq of partitions.values()){
|
|
35468
|
+
if(family==='window'){
|
|
35469
|
+
for(const[key,record]of rollingWindow(seq,windowSpec))out.set(key,record);
|
|
35470
|
+
}else if(family==='quantile'){
|
|
35471
|
+
for(const[key,record]of rollingQuantile(seq,windowSpec,{q}))out.set(key,record);
|
|
35472
|
+
}else if(family==='decompose'){
|
|
35473
|
+
for(const[key,record]of seasonalDecompose(seq,decompose))out.set(key,record);
|
|
35474
|
+
}else if(family==='smooth'){
|
|
35475
|
+
for(const[key,record]of exponentialSmoothing(seq,smooth))out.set(key,record);
|
|
35476
|
+
}else if(family==='cumulative'){
|
|
35477
|
+
for(const[key,value]of cumulativeToDate(seq))out.set(key,{value});
|
|
35478
|
+
}else{
|
|
35479
|
+
for(const[key,value]of periodOverPeriod(seq,1))out.set(key,{value});
|
|
35480
|
+
}
|
|
35481
|
+
}
|
|
35482
|
+
this.#rollingCache.set(signature,out);
|
|
35483
|
+
return out;
|
|
35484
|
+
}
|
|
35485
|
+
#rollingWindowSpec(declared,of,kind){
|
|
35486
|
+
const w=declared&&typeof declared==='object'?declared:{kind:'count',span:declared};
|
|
35487
|
+
const wkind=WINDOW_KINDS.includes(w.kind)?w.kind:'count';
|
|
35488
|
+
if(wkind==='session')return{kind:'session'};
|
|
35489
|
+
const span=wkind==='time'&&w.minutes!=null?w.minutes*60_000:Number(w.span);
|
|
35490
|
+
if(!(span>0)){
|
|
35491
|
+
warnOnce(
|
|
35492
|
+
`grid.rolling.window:${of}:${kind}`,
|
|
35493
|
+
`a '${kind}' rolling column needs a positive window span (a count of rows, or a `
|
|
35494
|
+
+"time span in ms or 'minutes'); it had none, so the column reported null.",
|
|
35495
|
+
);
|
|
35496
|
+
return null;
|
|
35497
|
+
}
|
|
35498
|
+
return wkind==='time'?{kind:'time',span}:{kind:'count',span:Math.floor(span)};
|
|
35499
|
+
}
|
|
35500
|
+
#rollingQuantileOf(q){
|
|
35501
|
+
const n=Number(q);
|
|
35502
|
+
if(!Number.isFinite(n))return 0.5;
|
|
35503
|
+
return Math.min(1,Math.max(0,n));
|
|
35504
|
+
}
|
|
35505
|
+
#rollingDecomposeSpec(spec,of){
|
|
35506
|
+
const period=Math.floor(Number(spec.period));
|
|
35507
|
+
if(!(period>=2)){
|
|
35508
|
+
warnOnce(
|
|
35509
|
+
`grid.ts.period:${of}:${spec.kind}`,
|
|
35510
|
+
`a '${spec.kind}' decomposition column needs a declared integer 'period' of at least 2 `
|
|
35511
|
+
+'(the season length — 7 for a weekly cycle in daily data, say); there is no '
|
|
35512
|
+
+'auto-detection, so it reported null until a period is set.',
|
|
35513
|
+
);
|
|
35514
|
+
return null;
|
|
35515
|
+
}
|
|
35516
|
+
const model=spec.decomposition==='multiplicative'?'multiplicative':'additive';
|
|
35517
|
+
if(model==='multiplicative'){
|
|
35518
|
+
const handle=this.#handleFor(of);
|
|
35519
|
+
if(handle){
|
|
35520
|
+
const read=statValueReader(handle);
|
|
35521
|
+
const indices=this.#populationIndices();
|
|
35522
|
+
for(let i=0;i<indices.length;i++){
|
|
35523
|
+
const v=Number(read(indices[i]));
|
|
35524
|
+
if(Number.isFinite(v)&&v<=0){
|
|
35525
|
+
warnOnce(
|
|
35526
|
+
`grid.ts.multiplicative:${of}`,
|
|
35527
|
+
`a multiplicative decomposition of '${of}' meets a non-positive value, where the `
|
|
35528
|
+
+'ratio value ÷ trend is undefined; those rows report null. Use the additive model '
|
|
35529
|
+
+'for a series that crosses or sits at zero.',
|
|
35530
|
+
);
|
|
35531
|
+
break;
|
|
35532
|
+
}
|
|
35533
|
+
}
|
|
35534
|
+
}
|
|
35535
|
+
}
|
|
35536
|
+
return{period,model};
|
|
35537
|
+
}
|
|
35538
|
+
#rollingSmoothSpec(spec){
|
|
35539
|
+
const method=spec.smoothing==='holt'?'holt':'ses';
|
|
35540
|
+
const clamp=(x)=>Math.min(1,Math.max(0,Number(x)));
|
|
35541
|
+
const out={method};
|
|
35542
|
+
if(Number.isFinite(spec.alpha))out.alpha=clamp(spec.alpha);
|
|
35543
|
+
if(method==='holt'&&Number.isFinite(spec.beta))out.beta=clamp(spec.beta);
|
|
35544
|
+
return out;
|
|
35545
|
+
}
|
|
35546
|
+
#rollingPartitions(of,orderBy,groupBy){
|
|
35547
|
+
const ofHandle=this.#handleFor(of);
|
|
35548
|
+
const orderHandle=this.#handleFor(orderBy);
|
|
35549
|
+
if(!ofHandle||!orderHandle)return null;
|
|
35550
|
+
const indices=this.#populationIndices();
|
|
35551
|
+
const keys=this.#indexKeys(indices);
|
|
35552
|
+
const readValue=statValueReader(ofHandle);
|
|
35553
|
+
const readOrder=statValueReader(orderHandle);
|
|
35554
|
+
const groupReaders=groupBy
|
|
35555
|
+
.map((id)=>this.#handleFor(id))
|
|
35556
|
+
.filter(Boolean)
|
|
35557
|
+
.map((handle)=>statValueReader(handle));
|
|
35558
|
+
const partitions=new Map();
|
|
35559
|
+
for(let i=0;i<indices.length;i++){
|
|
35560
|
+
const key=keys[i];
|
|
35561
|
+
if(key===null||key===undefined)continue;
|
|
35562
|
+
const idx=indices[i];
|
|
35563
|
+
const raw=readOrder(idx);
|
|
35564
|
+
const at=raw instanceof Date?raw.getTime()
|
|
35565
|
+
:(typeof raw==='number'?raw:Date.parse(String(raw)));
|
|
35566
|
+
if(!Number.isFinite(at))continue;
|
|
35567
|
+
const v=Number(readValue(idx));
|
|
35568
|
+
const value=Number.isFinite(v)?v:null;
|
|
35569
|
+
const pkey=groupReaders.length
|
|
35570
|
+
?groupReaders.map((read)=>String(read(idx))).join('\u0001')
|
|
35571
|
+
:'';
|
|
35572
|
+
let seq=partitions.get(pkey);
|
|
35573
|
+
if(!seq){seq=[];partitions.set(pkey,seq);}
|
|
35574
|
+
seq.push({key,at,value});
|
|
35575
|
+
}
|
|
35576
|
+
for(const seq of partitions.values()){
|
|
35577
|
+
seq.sort((a,b)=>a.at-b.at);
|
|
35578
|
+
}
|
|
35579
|
+
return partitions;
|
|
35580
|
+
}
|
|
34023
35581
|
#orderedValues(colId,by){
|
|
34024
35582
|
const values=this.#handleFor(colId);
|
|
34025
35583
|
if(!values)return null;
|
|
@@ -35085,6 +36643,15 @@ apply(state){model.applyState(state);},
|
|
|
35085
36643
|
show(ids){grid.#tracked('column:visible','show columns',()=>model.show(ids),{target:String(ids)});},
|
|
35086
36644
|
hide(ids){grid.#tracked('column:visible','hide columns',()=>model.hide(ids),{target:String(ids)});},
|
|
35087
36645
|
move(id,to){grid.#tracked('column:move',`move ${grid.#columnTitle(id)}`,()=>model.move(id,to),{target:id});},
|
|
36646
|
+
groupColumns(ids,opts){
|
|
36647
|
+
let out=null;
|
|
36648
|
+
grid.#tracked('column:groupColumns','group columns',()=>{out=model.groupColumns(ids,opts);});
|
|
36649
|
+
return out;
|
|
36650
|
+
},
|
|
36651
|
+
ungroupColumn(id){grid.#tracked('column:ungroupColumn',`ungroup ${grid.#columnTitle(id)}`,()=>model.ungroupColumn(id),{target:id});},
|
|
36652
|
+
renameGroup(groupId,title){grid.#tracked('column:renameGroup','rename group',()=>model.renameGroup(groupId,title));},
|
|
36653
|
+
dissolveGroup(groupId){grid.#tracked('column:dissolveGroup','dissolve group',()=>model.dissolveGroup(groupId));},
|
|
36654
|
+
moveGroup(groupId,to){grid.#tracked('column:moveGroup','move group',()=>model.moveGroup(groupId,to));},
|
|
35088
36655
|
pin(id,side){grid.#tracked('column:pin',`pin ${grid.#columnTitle(id)}`,()=>model.pin(id,side),{target:id});},
|
|
35089
36656
|
resize(id,px){grid.#tracked('column:resize',`resize ${grid.#columnTitle(id)}`,()=>model.resize(id,px),{target:id});},
|
|
35090
36657
|
decorate(id,decoration,opts){
|
|
@@ -36295,6 +37862,9 @@ get statistics(){
|
|
|
36295
37862
|
const grid=this;
|
|
36296
37863
|
return{
|
|
36297
37864
|
shadow(colId,kind,rowKey,scope,spec){
|
|
37865
|
+
if(ROLLING_KINDS.includes(kind)){
|
|
37866
|
+
return grid.#rollingShadow(colId,spec||{kind},rowKey);
|
|
37867
|
+
}
|
|
36298
37868
|
const tracker=grid.#shadows.get(colId);
|
|
36299
37869
|
return tracker
|
|
36300
37870
|
?tracker.read(kind,rowKey,scope==='filtered'?grid.#filteredKeys():undefined,spec)
|
|
@@ -36475,6 +38045,42 @@ const indices=grid.#statIndices();
|
|
|
36475
38045
|
grid.#warnWindowedStat('regression',`${a},${b}`,indices.length);
|
|
36476
38046
|
return statRegression(first,second,indices);
|
|
36477
38047
|
},
|
|
38048
|
+
regressionModel(spec){
|
|
38049
|
+
return grid.#fitModelOver(spec,grid.#statIndices());
|
|
38050
|
+
},
|
|
38051
|
+
adf(spec){
|
|
38052
|
+
const s=spec||{};
|
|
38053
|
+
if(!s.of||!s.orderBy)return null;
|
|
38054
|
+
const partitions=grid.#rollingPartitions(s.of,s.orderBy,[]);
|
|
38055
|
+
if(!partitions)return null;
|
|
38056
|
+
const seq=partitions.get('')||[];
|
|
38057
|
+
return statAdf(seq.map((row)=>row.value),{maxlag:s.maxlag});
|
|
38058
|
+
},
|
|
38059
|
+
acf(spec){
|
|
38060
|
+
const s=spec||{};
|
|
38061
|
+
if(!s.of||!s.orderBy)return null;
|
|
38062
|
+
const partitions=grid.#rollingPartitions(s.of,s.orderBy,[]);
|
|
38063
|
+
if(!partitions)return null;
|
|
38064
|
+
const seq=partitions.get('')||[];
|
|
38065
|
+
return statAcf(seq.map((row)=>row.value),{maxlag:s.maxlag});
|
|
38066
|
+
},
|
|
38067
|
+
fitShadow(kind,rowKey,spec){
|
|
38068
|
+
const map=grid.#fitShadowMap(spec);
|
|
38069
|
+
if(!map)return null;
|
|
38070
|
+
const entry=map.byKey.get(String(rowKey));
|
|
38071
|
+
if(!entry)return null;
|
|
38072
|
+
if(kind==='fitPredicted')return entry.predicted;
|
|
38073
|
+
if(kind==='fitResidual')return entry.residual;
|
|
38074
|
+
if(kind==='fitStdResidual')return entry.stdResidual;
|
|
38075
|
+
if(kind==='fitLeverage')return entry.leverage;
|
|
38076
|
+
if(kind==='fitCooksD')return entry.cooksD;
|
|
38077
|
+
if(kind==='fitInfluence'){
|
|
38078
|
+
if(entry.cooksD==null)return null;
|
|
38079
|
+
const threshold=spec&&Number.isFinite(spec.threshold)?spec.threshold:4/map.n;
|
|
38080
|
+
return entry.cooksD>threshold;
|
|
38081
|
+
}
|
|
38082
|
+
return null;
|
|
38083
|
+
},
|
|
36478
38084
|
spearman(a,b){
|
|
36479
38085
|
const first=grid.#handleFor(a);
|
|
36480
38086
|
const second=grid.#handleFor(b);
|
|
@@ -49146,6 +50752,7 @@ filter:`${PREFIX}-header-filter`,
|
|
|
49146
50752
|
menu:`${PREFIX}-header-menu`,
|
|
49147
50753
|
resize:`${PREFIX}-header-resize`,
|
|
49148
50754
|
groupToggle:`${PREFIX}-header-group-toggle`,
|
|
50755
|
+
groupRename:`${PREFIX}-header-group-rename`,
|
|
49149
50756
|
guide:`${PREFIX}-resize-guide`,
|
|
49150
50757
|
};
|
|
49151
50758
|
function isGroup(node){
|
|
@@ -49339,6 +50946,16 @@ const label=document.createElement('span');
|
|
|
49339
50946
|
label.className=PART.label;
|
|
49340
50947
|
label.textContent=group.title||'';
|
|
49341
50948
|
el.appendChild(label);
|
|
50949
|
+
if(group.id){
|
|
50950
|
+
el.addEventListener('pointerdown',(e)=>{
|
|
50951
|
+
if(e.target&&e.target.className===PART.groupToggle)return;
|
|
50952
|
+
this.#startBandDrag(e,group);
|
|
50953
|
+
});
|
|
50954
|
+
label.addEventListener('dblclick',(e)=>{
|
|
50955
|
+
if(isFunction(e.stopPropagation))e.stopPropagation();
|
|
50956
|
+
this.#startBandRename(el,label,group);
|
|
50957
|
+
});
|
|
50958
|
+
}
|
|
49342
50959
|
if(group.collapsible){
|
|
49343
50960
|
const toggle=document.createElement('button');
|
|
49344
50961
|
toggle.className=PART.groupToggle;
|
|
@@ -49382,7 +50999,11 @@ return true;
|
|
|
49382
50999
|
}
|
|
49383
51000
|
const Ctor=(impl);
|
|
49384
51001
|
const instance=new Ctor();
|
|
49385
|
-
if(isFunction(instance.render))
|
|
51002
|
+
if(isFunction(instance.render)){
|
|
51003
|
+
const out=instance.render(label,params);
|
|
51004
|
+
if(out&&out.nodeType===1)label.appendChild(out);
|
|
51005
|
+
else if(typeof out==='string')label.textContent=out;
|
|
51006
|
+
}
|
|
49386
51007
|
return true;
|
|
49387
51008
|
}catch(err){
|
|
49388
51009
|
warnOnce(
|
|
@@ -49635,6 +51256,52 @@ ghost:null,
|
|
|
49635
51256
|
};
|
|
49636
51257
|
this.#capture(event);
|
|
49637
51258
|
}
|
|
51259
|
+
#startBandDrag(event,group){
|
|
51260
|
+
if(this.#drag)return;
|
|
51261
|
+
const ids=new Set();
|
|
51262
|
+
collectIds(group,ids);
|
|
51263
|
+
const first=this.#regionSlots('start').concat(this.#regionSlots('centre'),this.#regionSlots('end'))
|
|
51264
|
+
.find((s)=>ids.has(s.id));
|
|
51265
|
+
if(!first)return;
|
|
51266
|
+
this.#drag={
|
|
51267
|
+
kind:'band-press',
|
|
51268
|
+
groupId:group.id,
|
|
51269
|
+
region:first.region,
|
|
51270
|
+
startX:event.clientX??0,
|
|
51271
|
+
ghost:null,
|
|
51272
|
+
};
|
|
51273
|
+
this.#capture(event);
|
|
51274
|
+
}
|
|
51275
|
+
#startBandRename(cell,label,group){
|
|
51276
|
+
const document=this.#viewport.document;
|
|
51277
|
+
const input=document.createElement('input');
|
|
51278
|
+
input.className=PART.groupRename;
|
|
51279
|
+
input.value=group.title||'';
|
|
51280
|
+
input.setAttribute('aria-label',this.#t('columngroup.rename'));
|
|
51281
|
+
let done=false;
|
|
51282
|
+
const commit=(save)=>{
|
|
51283
|
+
if(done)return;
|
|
51284
|
+
done=true;
|
|
51285
|
+
if(save&&isFunction(this.#host.columns.renameGroup)){
|
|
51286
|
+
this.#host.columns.renameGroup(group.id,input.value);
|
|
51287
|
+
this.#on.layoutChanged();
|
|
51288
|
+
}else if(input.parentNode){
|
|
51289
|
+
const parent=input.parentNode;
|
|
51290
|
+
parent.insertBefore(label,input);
|
|
51291
|
+
parent.removeChild(input);
|
|
51292
|
+
}
|
|
51293
|
+
};
|
|
51294
|
+
input.addEventListener('keydown',(e)=>{
|
|
51295
|
+
if(e.key==='Enter'){if(isFunction(e.preventDefault))e.preventDefault();commit(true);}
|
|
51296
|
+
else if(e.key==='Escape'){if(isFunction(e.preventDefault))e.preventDefault();commit(false);}
|
|
51297
|
+
});
|
|
51298
|
+
input.addEventListener('blur',()=>commit(true));
|
|
51299
|
+
const parent=label.parentNode||cell;
|
|
51300
|
+
parent.insertBefore(input,label);
|
|
51301
|
+
parent.removeChild(label);
|
|
51302
|
+
if(isFunction(input.focus))input.focus();
|
|
51303
|
+
if(isFunction(input.select))input.select();
|
|
51304
|
+
}
|
|
49638
51305
|
#capture(event){
|
|
49639
51306
|
const doc=this.#viewport.document;
|
|
49640
51307
|
this.#drag.target=doc;
|
|
@@ -49675,6 +51342,16 @@ drag.ghost=this.#on.ghost(column?column.column.title??drag.colId:drag.colId);
|
|
|
49675
51342
|
if(drag.kind==='reorder'){
|
|
49676
51343
|
if(drag.ghost)drag.ghost.move(event.clientX??0,event.clientY??0);
|
|
49677
51344
|
drag.targetId=this.#dropIndex(drag,event.clientX??0);
|
|
51345
|
+
drag.lastX=event.clientX??0;
|
|
51346
|
+
}
|
|
51347
|
+
if(drag.kind==='band-move'){
|
|
51348
|
+
if(drag.ghost)drag.ghost.move(event.clientX??0,event.clientY??0);
|
|
51349
|
+
drag.lastX=event.clientX??0;
|
|
51350
|
+
}
|
|
51351
|
+
if(drag.kind==='band-press'&&Math.abs(dx)>=DRAG_THRESHOLD){
|
|
51352
|
+
drag.kind='band-move';
|
|
51353
|
+
drag.ghost=this.#on.ghost(this.#bandTitle(drag.groupId));
|
|
51354
|
+
drag.lastX=event.clientX??0;
|
|
49678
51355
|
}
|
|
49679
51356
|
}
|
|
49680
51357
|
handlePointerUp(event){
|
|
@@ -49698,8 +51375,14 @@ this.#on.layoutChanged();
|
|
|
49698
51375
|
}
|
|
49699
51376
|
return;
|
|
49700
51377
|
}
|
|
51378
|
+
if(drag.kind==='band-move'){
|
|
51379
|
+
if(drag.ghost)drag.ghost.release();
|
|
51380
|
+
this.#commitBandMove(drag);
|
|
51381
|
+
return;
|
|
51382
|
+
}
|
|
49701
51383
|
if(drag.kind==='reorder'){
|
|
49702
51384
|
if(drag.ghost)drag.ghost.release();
|
|
51385
|
+
if(this.#commitGroupDrop(drag)){this.#on.layoutChanged();return;}
|
|
49703
51386
|
const to=drag.targetId!=null&&drag.targetId!==drag.colId
|
|
49704
51387
|
?this.#modelIndex(drag.colId,drag.targetId,true)
|
|
49705
51388
|
:null;
|
|
@@ -49711,6 +51394,59 @@ this.#on.layoutChanged();
|
|
|
49711
51394
|
}
|
|
49712
51395
|
}
|
|
49713
51396
|
}
|
|
51397
|
+
#commitGroupDrop(drag){
|
|
51398
|
+
const columns=this.#host.columns;
|
|
51399
|
+
if(!columns||!isFunction(columns.groupColumns))return false;
|
|
51400
|
+
const hit=this.#slotAtPointer(drag.region,drag.lastX??drag.startX);
|
|
51401
|
+
if(!hit||hit.slot.id===drag.colId)return false;
|
|
51402
|
+
const dragCol=this.#layout.slot(drag.colId);
|
|
51403
|
+
if(!dragCol)return false;
|
|
51404
|
+
const dragBand=this.#innermostBand(dragCol.column);
|
|
51405
|
+
const overBand=this.#innermostBand(hit.slot.column);
|
|
51406
|
+
if(overBand&&overBand!==dragBand){
|
|
51407
|
+
columns.groupColumns([drag.colId],{groupId:overBand});
|
|
51408
|
+
return true;
|
|
51409
|
+
}
|
|
51410
|
+
if(dragBand&&!overBand){
|
|
51411
|
+
columns.ungroupColumn(drag.colId);
|
|
51412
|
+
return true;
|
|
51413
|
+
}
|
|
51414
|
+
if(!dragBand&&!overBand&&hit.frac>1/3&&hit.frac<2/3){
|
|
51415
|
+
columns.groupColumns([drag.colId,hit.slot.id],{title:this.#t('columngroup.newGroup')});
|
|
51416
|
+
return true;
|
|
51417
|
+
}
|
|
51418
|
+
return false;
|
|
51419
|
+
}
|
|
51420
|
+
#commitBandMove(drag){
|
|
51421
|
+
const columns=this.#host.columns;
|
|
51422
|
+
if(!columns||!isFunction(columns.moveGroup))return;
|
|
51423
|
+
const hit=this.#slotAtPointer(drag.region,drag.lastX??drag.startX);
|
|
51424
|
+
if(!hit)return;
|
|
51425
|
+
const pos=this.#bandPosition(drag.groupId);
|
|
51426
|
+
if(!pos)return;
|
|
51427
|
+
const targetIndex=pos.parent.findIndex((node)=>{
|
|
51428
|
+
const ids=new Set();
|
|
51429
|
+
collectIds(node,ids);
|
|
51430
|
+
return ids.has(hit.slot.id);
|
|
51431
|
+
});
|
|
51432
|
+
if(targetIndex<0||targetIndex===pos.index)return;
|
|
51433
|
+
columns.moveGroup(drag.groupId,targetIndex);
|
|
51434
|
+
this.#host.emit('columngroup:changed',{action:'moved',groupId:drag.groupId,origin:'user'});
|
|
51435
|
+
this.#on.layoutChanged();
|
|
51436
|
+
}
|
|
51437
|
+
#slotAtPointer(region,clientX){
|
|
51438
|
+
const slots=this.#regionSlots(region);
|
|
51439
|
+
if(!slots.length)return null;
|
|
51440
|
+
const bounds2=this.#regionBounds(region);
|
|
51441
|
+
const scroll=region==='centre'?this.#centreScrollLeft():0;
|
|
51442
|
+
const x=(this.#rtl?bounds2.right-clientX:clientX-bounds2.left)+scroll;
|
|
51443
|
+
for(const slot of slots){
|
|
51444
|
+
if(x>=slot.left&&x<slot.left+slot.width){
|
|
51445
|
+
return{slot,frac:slot.width>0?(x-slot.left)/slot.width:0};
|
|
51446
|
+
}
|
|
51447
|
+
}
|
|
51448
|
+
return null;
|
|
51449
|
+
}
|
|
49714
51450
|
#onHeaderKey(event,slot){
|
|
49715
51451
|
const key=event.key;
|
|
49716
51452
|
const ctrl=event.ctrlKey||event.metaKey;
|
|
@@ -49719,6 +51455,9 @@ const column=slot.column;
|
|
|
49719
51455
|
const title=column.title??slot.id;
|
|
49720
51456
|
const horizontal=key==='ArrowLeft'||key==='ArrowRight';
|
|
49721
51457
|
const back=key==='ArrowLeft';
|
|
51458
|
+
if(ctrl&&shift&&horizontal)return this.#keyGroup(slot,back);
|
|
51459
|
+
if(ctrl&&shift&&key==='ArrowUp')return this.#keyUngroup(slot);
|
|
51460
|
+
if(event.altKey&&shift&&horizontal)return this.#keyMoveBand(slot,back);
|
|
49722
51461
|
if(horizontal&&event.altKey){
|
|
49723
51462
|
if(column.layout?.resizable===false){
|
|
49724
51463
|
this.#announce(this.#t('a11y.column.cannotResize',{column:title}));
|
|
@@ -49791,6 +51530,110 @@ return true;
|
|
|
49791
51530
|
}
|
|
49792
51531
|
return false;
|
|
49793
51532
|
}
|
|
51533
|
+
#bandTitle(groupId){
|
|
51534
|
+
let title=null;
|
|
51535
|
+
const walk=(nodes)=>{
|
|
51536
|
+
for(const node of nodes){
|
|
51537
|
+
if(!isGroup(node))continue;
|
|
51538
|
+
if(node.id===groupId){title=node.title;return true;}
|
|
51539
|
+
if(walk(node.columns))return true;
|
|
51540
|
+
}
|
|
51541
|
+
return false;
|
|
51542
|
+
};
|
|
51543
|
+
walk(this.#tree());
|
|
51544
|
+
return title||this.#t('columngroup.newGroup');
|
|
51545
|
+
}
|
|
51546
|
+
#bandPosition(groupId){
|
|
51547
|
+
let found=null;
|
|
51548
|
+
const walk=(nodes)=>{
|
|
51549
|
+
for(let i=0;i<nodes.length;i++){
|
|
51550
|
+
const node=nodes[i];
|
|
51551
|
+
if(!isGroup(node))continue;
|
|
51552
|
+
if(node.id===groupId){found={parent:nodes,index:i};return true;}
|
|
51553
|
+
if(walk(node.columns))return true;
|
|
51554
|
+
}
|
|
51555
|
+
return false;
|
|
51556
|
+
};
|
|
51557
|
+
walk(this.#tree());
|
|
51558
|
+
return found;
|
|
51559
|
+
}
|
|
51560
|
+
#keyGroup(slot,back){
|
|
51561
|
+
const columns=this.#host.columns;
|
|
51562
|
+
const title=slot.column.title??slot.id;
|
|
51563
|
+
if(!columns||!isFunction(columns.groupColumns))return true;
|
|
51564
|
+
if(slot.column.layout?.lockPosition){
|
|
51565
|
+
this.#announce(this.#t('a11y.column.cannotGroup',{column:title}));
|
|
51566
|
+
return true;
|
|
51567
|
+
}
|
|
51568
|
+
const order=[...this.#cells.keys()];
|
|
51569
|
+
const at=order.indexOf(slot.id);
|
|
51570
|
+
const neighbourId=order[back?at-1:at+1];
|
|
51571
|
+
if(!neighbourId){
|
|
51572
|
+
this.#announce(this.#t(back?'a11y.column.alreadyFirst':'a11y.column.alreadyLast',{column:title}));
|
|
51573
|
+
return true;
|
|
51574
|
+
}
|
|
51575
|
+
const neighbour=columns.get(neighbourId);
|
|
51576
|
+
const myBand=this.#innermostBand(slot.column);
|
|
51577
|
+
const neighbourBand=this.#innermostBand(neighbour);
|
|
51578
|
+
if(neighbourBand&&neighbourBand===myBand){
|
|
51579
|
+
this.#announce(this.#t('a11y.column.addedToGroup',{column:title,group:this.#bandTitle(myBand)}));
|
|
51580
|
+
return true;
|
|
51581
|
+
}
|
|
51582
|
+
if(neighbourBand){
|
|
51583
|
+
columns.groupColumns([slot.id],{groupId:neighbourBand});
|
|
51584
|
+
this.#announce(this.#t('a11y.column.addedToGroup',{column:title,group:this.#bandTitle(neighbourBand)}));
|
|
51585
|
+
}else{
|
|
51586
|
+
columns.groupColumns([slot.id,neighbourId],{title:this.#t('columngroup.newGroup')});
|
|
51587
|
+
this.#announce(this.#t('a11y.group.formed',{column:title,other:neighbour?.title??neighbourId}));
|
|
51588
|
+
}
|
|
51589
|
+
this.#on.layoutChanged();
|
|
51590
|
+
this.focus(slot.id);
|
|
51591
|
+
return true;
|
|
51592
|
+
}
|
|
51593
|
+
#keyUngroup(slot){
|
|
51594
|
+
const columns=this.#host.columns;
|
|
51595
|
+
const title=slot.column.title??slot.id;
|
|
51596
|
+
if(!columns||!isFunction(columns.ungroupColumn))return true;
|
|
51597
|
+
if(!this.#innermostBand(slot.column)){
|
|
51598
|
+
this.#announce(this.#t('a11y.column.notInGroup',{column:title}));
|
|
51599
|
+
return true;
|
|
51600
|
+
}
|
|
51601
|
+
columns.ungroupColumn(slot.id);
|
|
51602
|
+
this.#announce(this.#t('a11y.column.removedFromGroup',{column:title}));
|
|
51603
|
+
this.#on.layoutChanged();
|
|
51604
|
+
this.focus(slot.id);
|
|
51605
|
+
return true;
|
|
51606
|
+
}
|
|
51607
|
+
#keyMoveBand(slot,back){
|
|
51608
|
+
const columns=this.#host.columns;
|
|
51609
|
+
const title=slot.column.title??slot.id;
|
|
51610
|
+
const bandId=this.#innermostBand(slot.column);
|
|
51611
|
+
if(!columns||!isFunction(columns.moveGroup)||!bandId){
|
|
51612
|
+
this.#announce(this.#t('a11y.column.notInGroup',{column:title}));
|
|
51613
|
+
return true;
|
|
51614
|
+
}
|
|
51615
|
+
const pos=this.#bandPosition(bandId);
|
|
51616
|
+
if(!pos)return true;
|
|
51617
|
+
const to=back?pos.index-1:pos.index+1;
|
|
51618
|
+
if(to<0||to>=pos.parent.length){
|
|
51619
|
+
this.#announce(this.#t('a11y.group.cannotMove',{group:this.#bandTitle(bandId)}));
|
|
51620
|
+
return true;
|
|
51621
|
+
}
|
|
51622
|
+
columns.moveGroup(bandId,to);
|
|
51623
|
+
this.#on.layoutChanged();
|
|
51624
|
+
this.focus(slot.id);
|
|
51625
|
+
const after=this.#bandPosition(bandId);
|
|
51626
|
+
this.#announce(this.#t('a11y.group.moved',{
|
|
51627
|
+
group:this.#bandTitle(bandId),
|
|
51628
|
+
at:(after?after.index:to)+1,
|
|
51629
|
+
of:pos.parent.length,
|
|
51630
|
+
}));
|
|
51631
|
+
return true;
|
|
51632
|
+
}
|
|
51633
|
+
#innermostBand(column){
|
|
51634
|
+
const path=column&&column.groupPath;
|
|
51635
|
+
return Array.isArray(path)&&path.length?path[path.length-1]:null;
|
|
51636
|
+
}
|
|
49794
51637
|
#stepTarget(slot,back){
|
|
49795
51638
|
const slots=this.#regionSlots(slot.region);
|
|
49796
51639
|
const bounds=this.#groupBounds(slot.id,slots);
|
|
@@ -66780,6 +68623,117 @@ return chart;
|
|
|
66780
68623
|
}
|
|
66781
68624
|
}
|
|
66782
68625
|
});
|
|
68626
|
+
__def("packages/dom/src/regressionpanel.js",function(__exports,__req){
|
|
68627
|
+
'use strict';
|
|
68628
|
+
Object.defineProperty(__exports,"RegressionPanel",{enumerable:true,get:function(){return RegressionPanel;}});
|
|
68629
|
+
Object.defineProperty(__exports,"default",{enumerable:true,get:function(){return __default;}});
|
|
68630
|
+
const __m0=__req("packages/dom/src/editors/common.js");
|
|
68631
|
+
const CLS=__m0["CLS"];
|
|
68632
|
+
const el=__m0["el"];
|
|
68633
|
+
const clear=__m0["clear"];
|
|
68634
|
+
const __m1=__req("packages/core/src/internal/util.js");
|
|
68635
|
+
const isFunction=__m1["isFunction"];
|
|
68636
|
+
const __m2=__req("packages/dom/src/ui/panelbase.js");
|
|
68637
|
+
const ToolPanelBase=__m2["ToolPanelBase"];
|
|
68638
|
+
function num(v,digits=4){
|
|
68639
|
+
const n=Number(v);
|
|
68640
|
+
if(!Number.isFinite(n))return n===Infinity?'∞':'—';
|
|
68641
|
+
return n.toFixed(digits);
|
|
68642
|
+
}
|
|
68643
|
+
class RegressionPanel extends ToolPanelBase{
|
|
68644
|
+
#spec(){
|
|
68645
|
+
const props=this.props||{};
|
|
68646
|
+
if(Array.isArray(props.predictors)&&props.predictors.length&&props.response)return props;
|
|
68647
|
+
const grid=this.ctx&&this.ctx.grid;
|
|
68648
|
+
const config=grid&&isFunction(grid.get)?grid.get('regression'):null;
|
|
68649
|
+
return config&&Array.isArray(config.predictors)&&config.response?config:null;
|
|
68650
|
+
}
|
|
68651
|
+
refresh(){
|
|
68652
|
+
const root=this.root;
|
|
68653
|
+
if(!root)return;
|
|
68654
|
+
clear(root);
|
|
68655
|
+
const spec=this.#spec();
|
|
68656
|
+
if(!spec){
|
|
68657
|
+
root.appendChild(el(this.doc,'p',{class:`${CLS.panel}__empty`,text:this.t('regression.noModel')}));
|
|
68658
|
+
return;
|
|
68659
|
+
}
|
|
68660
|
+
const model=isFunction(this.host.regressionModel)?this.host.regressionModel(spec):null;
|
|
68661
|
+
if(!model){
|
|
68662
|
+
root.appendChild(el(this.doc,'p',{class:`${CLS.panel}__empty`,text:this.t('regression.cannotFit')}));
|
|
68663
|
+
return;
|
|
68664
|
+
}
|
|
68665
|
+
root.appendChild(el(this.doc,'p',{
|
|
68666
|
+
class:`${CLS.panel}__count`,
|
|
68667
|
+
text:this.t('regression.observations',{count:model.n}),
|
|
68668
|
+
}));
|
|
68669
|
+
root.appendChild(this.#fitFigures(model));
|
|
68670
|
+
root.appendChild(this.#coefficients(model));
|
|
68671
|
+
const vif=this.#vif(model,spec);
|
|
68672
|
+
if(vif)root.appendChild(vif);
|
|
68673
|
+
root.appendChild(this.#hetero(model));
|
|
68674
|
+
}
|
|
68675
|
+
#fitFigures(model){
|
|
68676
|
+
const list=el(this.doc,'dl',{class:`${CLS.panel}__stats`});
|
|
68677
|
+
const add=(label,value)=>{
|
|
68678
|
+
list.appendChild(el(this.doc,'dt',{class:`${CLS.panel}__stat-label`,text:label}));
|
|
68679
|
+
list.appendChild(el(this.doc,'dd',{class:`${CLS.panel}__stat-value`,text:value}));
|
|
68680
|
+
};
|
|
68681
|
+
add(this.t('regression.r2'),num(model.r2,4));
|
|
68682
|
+
add(this.t('regression.adjR2'),num(model.adjR2,4));
|
|
68683
|
+
return list;
|
|
68684
|
+
}
|
|
68685
|
+
#coefficients(model){
|
|
68686
|
+
const wrapper=el(this.doc,'div',{class:`${CLS.panel}__section`});
|
|
68687
|
+
wrapper.appendChild(el(this.doc,'h4',{class:`${CLS.panel}__heading`,text:this.t('regression.coefficients')}));
|
|
68688
|
+
const table=el(this.doc,'table',{class:`${CLS.panel}__coef-table`});
|
|
68689
|
+
const head=el(this.doc,'tr');
|
|
68690
|
+
for(const key of['regression.term','regression.estimate','regression.stdError','regression.t','regression.p']){
|
|
68691
|
+
head.appendChild(el(this.doc,'th',{text:this.t(key)}));
|
|
68692
|
+
}
|
|
68693
|
+
table.appendChild(head);
|
|
68694
|
+
for(const c of model.coefficients){
|
|
68695
|
+
const row=el(this.doc,'tr');
|
|
68696
|
+
row.appendChild(el(this.doc,'td',{text:c.name}));
|
|
68697
|
+
row.appendChild(el(this.doc,'td',{text:`${num(c.estimate)} ± ${num(c.stdError)}`}));
|
|
68698
|
+
row.appendChild(el(this.doc,'td',{text:num(c.stdError)}));
|
|
68699
|
+
row.appendChild(el(this.doc,'td',{text:num(c.t,3)}));
|
|
68700
|
+
row.appendChild(el(this.doc,'td',{text:num(c.p,4)}));
|
|
68701
|
+
table.appendChild(row);
|
|
68702
|
+
}
|
|
68703
|
+
wrapper.appendChild(table);
|
|
68704
|
+
return wrapper;
|
|
68705
|
+
}
|
|
68706
|
+
#vif(model,spec){
|
|
68707
|
+
if(!Array.isArray(model.vif)||model.vif.length<2)return null;
|
|
68708
|
+
const wrapper=el(this.doc,'div',{class:`${CLS.panel}__section`});
|
|
68709
|
+
wrapper.appendChild(el(this.doc,'h4',{class:`${CLS.panel}__heading`,text:this.t('regression.vif')}));
|
|
68710
|
+
const list=el(this.doc,'dl',{class:`${CLS.panel}__stats`});
|
|
68711
|
+
model.vif.forEach((v,i)=>{
|
|
68712
|
+
list.appendChild(el(this.doc,'dt',{class:`${CLS.panel}__stat-label`,text:spec.predictors[i]}));
|
|
68713
|
+
list.appendChild(el(this.doc,'dd',{class:`${CLS.panel}__stat-value`,text:num(v,3)}));
|
|
68714
|
+
});
|
|
68715
|
+
wrapper.appendChild(list);
|
|
68716
|
+
return wrapper;
|
|
68717
|
+
}
|
|
68718
|
+
#hetero(model){
|
|
68719
|
+
const h=model.heteroscedasticity;
|
|
68720
|
+
const wrapper=el(this.doc,'div',{class:`${CLS.panel}__section`});
|
|
68721
|
+
wrapper.appendChild(el(this.doc,'h4',{class:`${CLS.panel}__heading`,text:this.t('regression.heteroscedasticity')}));
|
|
68722
|
+
if(!h){
|
|
68723
|
+
wrapper.appendChild(el(this.doc,'p',{class:`${CLS.panel}__empty`,text:this.t('regression.cannotFit')}));
|
|
68724
|
+
return wrapper;
|
|
68725
|
+
}
|
|
68726
|
+
wrapper.appendChild(el(this.doc,'p',{
|
|
68727
|
+
class:`${CLS.panel}__flag`,
|
|
68728
|
+
attrs:{'data-heteroscedastic':h.heteroscedastic?'true':'false'},
|
|
68729
|
+
text:this.t(h.heteroscedastic?'regression.heteroscedastic':'regression.homoscedastic',
|
|
68730
|
+
{statistic:num(h.statistic,3),p:num(h.p,4)}),
|
|
68731
|
+
}));
|
|
68732
|
+
return wrapper;
|
|
68733
|
+
}
|
|
68734
|
+
}
|
|
68735
|
+
const __default=RegressionPanel;
|
|
68736
|
+
});
|
|
66783
68737
|
__def("packages/dom/src/comparepanel.js",function(__exports,__req){
|
|
66784
68738
|
'use strict';
|
|
66785
68739
|
Object.defineProperty(__exports,"ComparePanel",{enumerable:true,get:function(){return ComparePanel;}});
|
|
@@ -67190,14 +69144,16 @@ const __m5=__req("packages/dom/src/formattingpanel.js");
|
|
|
67190
69144
|
const FormattingPanel=__m5["FormattingPanel"];
|
|
67191
69145
|
const __m6=__req("packages/dom/src/statisticspanel.js");
|
|
67192
69146
|
const StatisticsPanel=__m6["StatisticsPanel"];
|
|
67193
|
-
const __m7=__req("packages/dom/src/
|
|
67194
|
-
const
|
|
67195
|
-
const __m8=__req("packages/dom/src/
|
|
67196
|
-
const
|
|
67197
|
-
const __m9=__req("packages/dom/src/
|
|
67198
|
-
const
|
|
67199
|
-
const __m10=__req("packages/
|
|
67200
|
-
const
|
|
69147
|
+
const __m7=__req("packages/dom/src/regressionpanel.js");
|
|
69148
|
+
const RegressionPanel=__m7["RegressionPanel"];
|
|
69149
|
+
const __m8=__req("packages/dom/src/comparepanel.js");
|
|
69150
|
+
const ComparePanel=__m8["ComparePanel"];
|
|
69151
|
+
const __m9=__req("packages/dom/src/insightspanel.js");
|
|
69152
|
+
const InsightsPanel=__m9["InsightsPanel"];
|
|
69153
|
+
const __m10=__req("packages/dom/src/ui/panelbase.js");
|
|
69154
|
+
const ToolPanelBase=__m10["ToolPanelBase"];
|
|
69155
|
+
const __m11=__req("packages/core/src/compute/total.js");
|
|
69156
|
+
const TOTAL_LABELS=__m11["TOTAL_LABELS"];
|
|
67201
69157
|
class ColumnsPanel extends ToolPanelBase{
|
|
67202
69158
|
dragging=null;
|
|
67203
69159
|
refresh(){
|
|
@@ -67687,6 +69643,7 @@ views:ViewPicker,
|
|
|
67687
69643
|
quick:QuickFilterPanel,
|
|
67688
69644
|
formatting:FormattingPanel,
|
|
67689
69645
|
statistics:StatisticsPanel,
|
|
69646
|
+
regression:RegressionPanel,
|
|
67690
69647
|
compare:ComparePanel,
|
|
67691
69648
|
insights:InsightsPanel,
|
|
67692
69649
|
});
|
|
@@ -67697,6 +69654,7 @@ views:'panel.views',
|
|
|
67697
69654
|
quick:'panel.quickFilter',
|
|
67698
69655
|
formatting:'panel.formatting',
|
|
67699
69656
|
statistics:'panel.statistics',
|
|
69657
|
+
regression:'panel.regression',
|
|
67700
69658
|
compare:'panel.compare',
|
|
67701
69659
|
insights:'panel.insights',
|
|
67702
69660
|
});
|
|
@@ -67707,6 +69665,7 @@ views:'views',
|
|
|
67707
69665
|
quick:'search',
|
|
67708
69666
|
formatting:'palette',
|
|
67709
69667
|
statistics:'chart',
|
|
69668
|
+
regression:'chart',
|
|
67710
69669
|
compare:'link',
|
|
67711
69670
|
insights:'chart',
|
|
67712
69671
|
});
|
|
@@ -68884,6 +70843,28 @@ action:()=>grid.columns.group(grouped
|
|
|
68884
70843
|
:[...groupBy,colId]),
|
|
68885
70844
|
});
|
|
68886
70845
|
}
|
|
70846
|
+
if(isFunction(grid.columns.groupColumns)){
|
|
70847
|
+
const path=column.groupPath||[];
|
|
70848
|
+
const bandId=path.length?path[path.length-1]:null;
|
|
70849
|
+
const bandItems=[{
|
|
70850
|
+
name:t('columngroup.group'),
|
|
70851
|
+
disabled:order.length<2||at<0,
|
|
70852
|
+
action:()=>{
|
|
70853
|
+
const neighbour=order[at+1]??order[at-1];
|
|
70854
|
+
if(!neighbour)return;
|
|
70855
|
+
const nbrPath=(grid.columns.get(neighbour)||{}).groupPath||[];
|
|
70856
|
+
const nbrBand=nbrPath.length?nbrPath[nbrPath.length-1]:null;
|
|
70857
|
+
if(nbrBand)grid.columns.groupColumns([colId],{groupId:nbrBand});
|
|
70858
|
+
else grid.columns.groupColumns([colId,neighbour],{title:t('columngroup.newGroup')});
|
|
70859
|
+
},
|
|
70860
|
+
}];
|
|
70861
|
+
if(bandId){
|
|
70862
|
+
bandItems.push(
|
|
70863
|
+
{name:t('columngroup.dissolve'),action:()=>grid.columns.dissolveGroup(bandId)},
|
|
70864
|
+
);
|
|
70865
|
+
}
|
|
70866
|
+
items.push({separator:true},...bandItems);
|
|
70867
|
+
}
|
|
68887
70868
|
const pivotState=grid.state&&isFunction(grid.state.get)?grid.state.get().pivot:null;
|
|
68888
70869
|
const pivotBy=(pivotState&&pivotState.columns)||[];
|
|
68889
70870
|
const pivoted=pivotBy.includes(colId);
|
|
@@ -70797,6 +72778,8 @@ profilableColumns:()=>grid.columns.visible()
|
|
|
70797
72778
|
columnProfile:(colId)=>grid.statistics.profile(colId),
|
|
70798
72779
|
reduceColumn:(colId,kernel)=>grid.statistics.reduce(colId,kernel),
|
|
70799
72780
|
columnCapability:(colId)=>grid.statistics.capability(colId),
|
|
72781
|
+
regressionModel:(spec)=>(isFunction(grid.statistics.regressionModel)
|
|
72782
|
+
?grid.statistics.regressionModel(spec):null),
|
|
70800
72783
|
insightsColumns:()=>grid.columns.visible()
|
|
70801
72784
|
.filter((c)=>!c.generated)
|
|
70802
72785
|
.map((c)=>({id:c.id,title:String(c.title??c.id),type:c.type})),
|
|
@@ -72779,13 +74762,45 @@ const __default=captureElement;
|
|
|
72779
74762
|
__def("packages/dom/src/annotate.js",function(__exports,__req){
|
|
72780
74763
|
'use strict';
|
|
72781
74764
|
Object.defineProperty(__exports,"TOOLS",{enumerable:true,get:function(){return TOOLS;}});
|
|
74765
|
+
Object.defineProperty(__exports,"MARK_TYPES",{enumerable:true,get:function(){return MARK_TYPES;}});
|
|
72782
74766
|
Object.defineProperty(__exports,"AnnotationLayer",{enumerable:true,get:function(){return AnnotationLayer;}});
|
|
72783
74767
|
Object.defineProperty(__exports,"default",{enumerable:true,get:function(){return __default;}});
|
|
72784
74768
|
const __m0=__req("packages/core/src/internal/util.js");
|
|
72785
74769
|
const isFunction=__m0["isFunction"];
|
|
74770
|
+
const warnOnce=__m0["warnOnce"];
|
|
72786
74771
|
const __m1=__req("packages/dom/src/renderer/direction.js");
|
|
72787
74772
|
const signedX=__m1["signedX"];
|
|
72788
74773
|
const TOOLS=Object.freeze(['pen','arrow','rect','highlight']);
|
|
74774
|
+
const MARK_TYPES=Object.freeze(['freehand','arrow','rect','highlight']);
|
|
74775
|
+
const TYPE_TO_TOOL=Object.freeze({
|
|
74776
|
+
freehand:'pen',pen:'pen',arrow:'arrow',rect:'rect',highlight:'highlight',
|
|
74777
|
+
});
|
|
74778
|
+
const TOOL_TO_TYPE=Object.freeze({
|
|
74779
|
+
pen:'freehand',arrow:'arrow',rect:'rect',highlight:'highlight',
|
|
74780
|
+
});
|
|
74781
|
+
function markFromDescriptor(descriptor,fallbackColour){
|
|
74782
|
+
if(!descriptor||typeof descriptor!=='object')return null;
|
|
74783
|
+
const tool=TYPE_TO_TOOL[descriptor.type];
|
|
74784
|
+
if(!tool)return null;
|
|
74785
|
+
const raw=Array.isArray(descriptor.points)?descriptor.points:[];
|
|
74786
|
+
const points=[];
|
|
74787
|
+
for(const p of raw){
|
|
74788
|
+
const x=Number(p&&p.x);
|
|
74789
|
+
const y=Number(p&&p.y);
|
|
74790
|
+
if(Number.isFinite(x)&&Number.isFinite(y))points.push({x,y});
|
|
74791
|
+
}
|
|
74792
|
+
if(points.length<2)return null;
|
|
74793
|
+
const colour=typeof descriptor.colour==='string'&&descriptor.colour
|
|
74794
|
+
?descriptor.colour:fallbackColour;
|
|
74795
|
+
return{tool,colour,points};
|
|
74796
|
+
}
|
|
74797
|
+
function descriptorFromMark(mark){
|
|
74798
|
+
return{
|
|
74799
|
+
type:TOOL_TO_TYPE[mark.tool]||mark.tool,
|
|
74800
|
+
colour:mark.colour,
|
|
74801
|
+
points:mark.points.map((p)=>({x:p.x,y:p.y})),
|
|
74802
|
+
};
|
|
74803
|
+
}
|
|
72789
74804
|
const LAYER_CLASS='lat-annotate';
|
|
72790
74805
|
const WIDTHS=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});
|
|
72791
74806
|
function isDragShape(tool){return tool==='arrow'||tool==='rect';}
|
|
@@ -72799,18 +74814,48 @@ class AnnotationLayer{
|
|
|
72799
74814
|
#marks=[];
|
|
72800
74815
|
#drawing=null;
|
|
72801
74816
|
#off=[];
|
|
74817
|
+
#seed=null;
|
|
72802
74818
|
constructor(opts){
|
|
72803
74819
|
this.#grid=opts.grid;
|
|
72804
74820
|
this.#renderer=opts.renderer;
|
|
74821
|
+
this.#seed=Array.isArray(opts.seed)?opts.seed:null;
|
|
72805
74822
|
}
|
|
72806
74823
|
get tool(){return this.#tool;}
|
|
72807
74824
|
get count(){return this.#marks.length;}
|
|
72808
74825
|
mount(){
|
|
72809
74826
|
this.#off.push(this.#grid.on('scroll',()=>this.redraw()));
|
|
72810
74827
|
this.#off.push(this.#grid.on('render:done',()=>this.redraw()));
|
|
72811
|
-
this.#off.push(this.#grid.on('presentation:ended',()=>{this.use(null);this
|
|
74828
|
+
this.#off.push(this.#grid.on('presentation:ended',()=>{this.use(null);this.#clearTransient();}));
|
|
72812
74829
|
this.#bindEscape();
|
|
72813
74830
|
this.#watchRatio();
|
|
74831
|
+
if(this.#seed&&this.#seed.length)this.replaceAll(this.#seed);
|
|
74832
|
+
this.#seed=null;
|
|
74833
|
+
}
|
|
74834
|
+
add(mark){
|
|
74835
|
+
const built=markFromDescriptor(mark,this.#colour);
|
|
74836
|
+
if(!built){
|
|
74837
|
+
warnOnce('annotate.add.invalid',
|
|
74838
|
+
'annotate.add ignored a mark: it needs a known `type` '
|
|
74839
|
+
+`(${MARK_TYPES.join(', ')}) and at least two finite {x, y} points in content coordinates.`);
|
|
74840
|
+
return this.#marks.length;
|
|
74841
|
+
}
|
|
74842
|
+
built.durable=true;
|
|
74843
|
+
this.#marks.push(built);
|
|
74844
|
+
this.#ensure();
|
|
74845
|
+
this.redraw();
|
|
74846
|
+
this.#emit();
|
|
74847
|
+
return this.#marks.length;
|
|
74848
|
+
}
|
|
74849
|
+
list(){
|
|
74850
|
+
return this.#marks.map(descriptorFromMark);
|
|
74851
|
+
}
|
|
74852
|
+
replaceAll(marks){
|
|
74853
|
+
const arr=Array.isArray(marks)?marks:[];
|
|
74854
|
+
this.#marks=arr.map((m)=>markFromDescriptor(m,this.#colour)).filter(Boolean);
|
|
74855
|
+
for(const mark of this.#marks)mark.durable=true;
|
|
74856
|
+
if(this.#marks.length)this.#ensure();
|
|
74857
|
+
this.redraw();
|
|
74858
|
+
this.#emit();
|
|
72814
74859
|
}
|
|
72815
74860
|
#bindEscape(){
|
|
72816
74861
|
const root=this.#renderer.viewport?.root;
|
|
@@ -72872,7 +74917,15 @@ this.#marks=[];
|
|
|
72872
74917
|
this.redraw();
|
|
72873
74918
|
this.#emit();
|
|
72874
74919
|
}
|
|
74920
|
+
#clearTransient(){
|
|
74921
|
+
const kept=this.#marks.filter((mark)=>mark.durable);
|
|
74922
|
+
if(kept.length===this.#marks.length)return;
|
|
74923
|
+
this.#marks=kept;
|
|
74924
|
+
this.redraw();
|
|
74925
|
+
this.#emit();
|
|
74926
|
+
}
|
|
72875
74927
|
redraw(){
|
|
74928
|
+
if(!this.#canvas&&this.#marks.length)this.#ensure();
|
|
72876
74929
|
const canvas=this.#canvas;
|
|
72877
74930
|
const ctx=this.#ctx;
|
|
72878
74931
|
if(!canvas||!ctx)return;
|
|
@@ -75261,7 +77314,11 @@ announce(label
|
|
|
75261
77314
|
?t(redo?'a11y.history.redo':'a11y.history.undo',{label})
|
|
75262
77315
|
:t(redo?'a11y.history.redoLast':'a11y.history.undoLast'));
|
|
75263
77316
|
}));
|
|
75264
|
-
const annotations=new AnnotationLayer({
|
|
77317
|
+
const annotations=new AnnotationLayer({
|
|
77318
|
+
grid,
|
|
77319
|
+
renderer,
|
|
77320
|
+
seed:config.state&&Array.isArray(config.state.annotations)?config.state.annotations:null,
|
|
77321
|
+
});
|
|
75265
77322
|
annotations.mount();
|
|
75266
77323
|
teardown.push(()=>annotations.destroy());
|
|
75267
77324
|
grid.annotate=annotations;
|
|
@@ -75726,7 +77783,7 @@ createLocalViewStorage,
|
|
|
75726
77783
|
const __default=LatticeGrid;
|
|
75727
77784
|
});
|
|
75728
77785
|
try{
|
|
75729
|
-
__req("packages/worker/src/inline.js").setWorkerSource("(function(root){\n'use strict';\nvar __mods=Object.create(null);\nvar __cache=Object.create(null);\nfunction __def(id,fn){__mods[id]=fn;}\nfunction __req(id){\nvar hit=__cache[id];\nif(hit)return hit;\nvar exports=Object.create(null);\n__cache[id]=exports;\nvar fn=__mods[id];\nif(!fn)throw new Error('[lattice] missing module: '+id);\nfn(exports,__req);\nreturn exports;\n}\n__def(\"packages/core/src/internal/util.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"VERSION\",{enumerable:true,get:function(){return VERSION;}});\nObject.defineProperty(__exports,\"reportedWarnings\",{enumerable:true,get:function(){return reportedWarnings;}});\nObject.defineProperty(__exports,\"warnOnce\",{enumerable:true,get:function(){return warnOnce;}});\nObject.defineProperty(__exports,\"infoOnce\",{enumerable:true,get:function(){return infoOnce;}});\nObject.defineProperty(__exports,\"resetWarnings\",{enumerable:true,get:function(){return resetWarnings;}});\nObject.defineProperty(__exports,\"fail\",{enumerable:true,get:function(){return fail;}});\nObject.defineProperty(__exports,\"invariant\",{enumerable:true,get:function(){return invariant;}});\nObject.defineProperty(__exports,\"DEV\",{enumerable:true,get:function(){return DEV;}});\nObject.defineProperty(__exports,\"isObject\",{enumerable:true,get:function(){return isObject;}});\nObject.defineProperty(__exports,\"isFunction\",{enumerable:true,get:function(){return isFunction;}});\nObject.defineProperty(__exports,\"isNil\",{enumerable:true,get:function(){return isNil;}});\nObject.defineProperty(__exports,\"isBlank\",{enumerable:true,get:function(){return isBlank;}});\nObject.defineProperty(__exports,\"isCtor\",{enumerable:true,get:function(){return isCtor;}});\nObject.defineProperty(__exports,\"pathGetter\",{enumerable:true,get:function(){return pathGetter;}});\nObject.defineProperty(__exports,\"pathSetter\",{enumerable:true,get:function(){return pathSetter;}});\nObject.defineProperty(__exports,\"getPath\",{enumerable:true,get:function(){return getPath;}});\nObject.defineProperty(__exports,\"setPath\",{enumerable:true,get:function(){return setPath;}});\nObject.defineProperty(__exports,\"humanise\",{enumerable:true,get:function(){return humanise;}});\nObject.defineProperty(__exports,\"escapeHtml\",{enumerable:true,get:function(){return escapeHtml;}});\nObject.defineProperty(__exports,\"titleCase\",{enumerable:true,get:function(){return titleCase;}});\nObject.defineProperty(__exports,\"expand\",{enumerable:true,get:function(){return expand;}});\nObject.defineProperty(__exports,\"toArray\",{enumerable:true,get:function(){return toArray;}});\nObject.defineProperty(__exports,\"merge\",{enumerable:true,get:function(){return merge;}});\nObject.defineProperty(__exports,\"mergeRow\",{enumerable:true,get:function(){return mergeRow;}});\nObject.defineProperty(__exports,\"Lru\",{enumerable:true,get:function(){return Lru;}});\nObject.defineProperty(__exports,\"collator\",{enumerable:true,get:function(){return collator;}});\nObject.defineProperty(__exports,\"defaultCompare\",{enumerable:true,get:function(){return defaultCompare;}});\nObject.defineProperty(__exports,\"now\",{enumerable:true,get:function(){return now;}});\nObject.defineProperty(__exports,\"nextFrame\",{enumerable:true,get:function(){return nextFrame;}});\nObject.defineProperty(__exports,\"cancelFrame\",{enumerable:true,get:function(){return cancelFrame;}});\nObject.defineProperty(__exports,\"frameBatched\",{enumerable:true,get:function(){return frameBatched;}});\nObject.defineProperty(__exports,\"settleDebounce\",{enumerable:true,get:function(){return settleDebounce;}});\nObject.defineProperty(__exports,\"whenIdle\",{enumerable:true,get:function(){return whenIdle;}});\nObject.defineProperty(__exports,\"uid\",{enumerable:true,get:function(){return uid;}});\nconst STAMPED_VERSION=\"1.28.0\";\nasync function resolveVersion(){\nif(STAMPED_VERSION!=='0.0.0-source')return STAMPED_VERSION;\ntry{\nif(typeof process==='undefined'||!process.versions||!process.versions.node){\nreturn STAMPED_VERSION;\n}\nconst mod=await import('node:'+'module');\nconst req=mod.createRequire((typeof document!=='undefined'&&document.currentScript?document.currentScript.src:''));\nconst fs=req('node:'+'fs');\nconst url=new URL('../../../../package.json',(typeof document!=='undefined'&&document.currentScript?document.currentScript.src:''));\nconst text=fs.readFileSync(url,'utf8');\nreturn JSON.parse(text).version||STAMPED_VERSION;\n}catch{\nreturn STAMPED_VERSION;\n}\n}\nconst VERSION=\"1.28.0\";\nconst warned=new Set();\nconst WARNED_LIMIT=2000;\nfunction rememberWarned(key){\nwarned.add(key);\nif(warned.size>WARNED_LIMIT){\nconst oldest=warned.values().next().value;\nif(oldest!==undefined)warned.delete(oldest);\n}\n}\nconst reported=[];\nconst REPORT_LIMIT=500;\nfunction record(key,level,message){\nreported.push({\nkey,\nlevel,\nmessage:message.map((m)=>(typeof m==='string'?m:safeString(m))).join(' '),\nat:Date.now(),\n});\nif(reported.length>REPORT_LIMIT)reported.shift();\n}\nfunction safeString(value){\nif(value instanceof Error)return value.message;\ntry{return JSON.stringify(value);}catch{return String(value);}\n}\nfunction reportedWarnings(){return reported.map((r)=>({...r}));}\nfunction warnOnce(key,...message){\nif(warned.has(key))return;\nrememberWarned(key);\nrecord(key,'warn',message);\nconsole.warn('[lattice]',...message);\n}\nfunction infoOnce(key,...message){\nif(warned.has(key))return;\nrememberWarned(key);\nrecord(key,'info',message);\nconsole.info('[lattice]',...message);\n}\nfunction resetWarnings(){\nwarned.clear();\nreported.length=0;\n}\nfunction fail(message,extra){\nconst err=new Error(`[lattice] ${message}`);\nif(extra!==undefined)err.cause=extra;\nthrow err;\n}\nfunction invariant(condition,message){\nif(!condition)fail(message);\n}\nconst DEV=(()=>{\ntry{\nreturn!(typeof process!=='undefined'&&process.env\n&&process.env.NODE_ENV==='production');\n}catch{\nreturn true;\n}\n})();\nfunction isObject(v){\nreturn v!==null&&typeof v==='object'&&!Array.isArray(v);\n}\nfunction isFunction(v){\nreturn typeof v==='function';\n}\nfunction isNil(v){\nreturn v===null||v===undefined;\n}\nfunction isBlank(v){\nreturn v===null||v===undefined||v==='';\n}\nfunction isCtor(v){\nif(typeof v!=='function')return false;\nif(/^class[\\s{]/.test(Function.prototype.toString.call(v)))return true;\nreturn!!(v.prototype&&Object.getOwnPropertyNames(v.prototype).length>1);\n}\nconst pathCache=new Map();\nfunction pathGetter(path){\nlet fn=pathCache.get(path);\nif(fn)return fn;\nif(!path.includes('.')){\nfn=(o)=>(o==null?undefined:o[path]);\n}else{\nconst parts=path.split('.');\nconst n=parts.length;\nfn=(o)=>{\nlet cur=o;\nfor(let i=0;i<n;i++){\nif(cur==null)return undefined;\ncur=cur[parts[i]];\n}\nreturn cur;\n};\n}\npathCache.set(path,fn);\nreturn fn;\n}\nconst setterCache=new Map();\nfunction pathSetter(path){\nlet fn=setterCache.get(path);\nif(fn)return fn;\nif(!path.includes('.')){\nfn=(o,v)=>{if(o!=null)o[path]=v;};\n}else{\nconst parts=path.split('.');\nconst last=parts.length-1;\nfn=(o,v)=>{\nlet cur=o;\nfor(let i=0;i<last;i++){\nif(cur==null)return;\nconst k=parts[i];\nif(cur[k]==null)cur[k]={};\ncur=cur[k];\n}\nif(cur!=null)cur[parts[last]]=v;\n};\n}\nsetterCache.set(path,fn);\nreturn fn;\n}\nfunction getPath(obj,path){\nreturn pathGetter(path)(obj);\n}\nfunction setPath(obj,path,value){\npathSetter(path)(obj,value);\n}\nfunction humanise(field){\nif(!field)return'';\nconst leaf=field.includes('.')?field.slice(field.lastIndexOf('.')+1):field;\nreturn leaf\n.replace(/[_-]+/g,' ')\n.replace(/([a-z0-9])([A-Z])/g,'$1 $2')\n.replace(/([A-Z]+)([A-Z][a-z])/g,'$1 $2')\n.replace(/\\s+/g,' ')\n.trim()\n.replace(/^./,(c)=>c.toUpperCase());\n}\nconst ESCAPES={'&':'&','<':'<','>':'>','\"':'"',\"'\":'''};\nfunction escapeHtml(s){\nconst str=s==null?'':String(s);\nreturn/[&<>\"']/.test(str)?str.replace(/[&<>\"']/g,(c)=>ESCAPES[c]):str;\n}\nfunction titleCase(s){\nreturn String(s).replace(/\\w\\S*/g,(t)=>t[0].toUpperCase()+t.slice(1).toLowerCase());\n}\nfunction expand(value,key,whenTrue){\nif(value===undefined)return undefined;\nif(value===true)return{enabled:true,...whenTrue};\nif(value===false)return{enabled:false};\nif(isObject(value))return value;\nreturn{[key]:value,enabled:true};\n}\nfunction toArray(v){\nif(v===undefined||v===null)return[];\nreturn Array.isArray(v)?v:[v];\n}\nconst MERGE_FORBIDDEN_KEYS=Object.freeze(new Set(['__proto__','constructor','prototype']));\nfunction merge(a,b){\nif(!isObject(a))return isObject(b)?{...b}:b;\nif(!isObject(b))return b===undefined?a:b;\nconst out={...a};\nfor(const k of Object.keys(b)){\nif(MERGE_FORBIDDEN_KEYS.has(k))continue;\nconst bv=b[k];\nif(bv===undefined)continue;\nout[k]=isObject(bv)&&isObject(out[k])?merge(out[k],bv):bv;\n}\nreturn out;\n}\nfunction mergeRow(previous,patch){\nif(!isObject(previous)||!isObject(patch)||previous===patch)return patch;\nconst out=Object.create(Object.getPrototypeOf(previous));\nObject.assign(out,previous,patch);\nreturn out;\n}\nclass Lru{\n#max;\n#map=new Map();\n#onEvict;\nconstructor(max=256,onEvict=null){\nthis.#max=max;\nthis.#onEvict=onEvict;\n}\nget size(){\nreturn this.#map.size;\n}\nget max(){\nreturn this.#max;\n}\nset max(v){\nthis.#max=v;\nthis.#trim();\n}\nhas(k){\nreturn this.#map.has(k);\n}\nget(k){\nconst m=this.#map;\nif(!m.has(k))return undefined;\nconst v=m.get(k);\nm.delete(k);\nm.set(k,v);\nreturn v;\n}\npeek(k){\nreturn this.#map.get(k);\n}\nset(k,v){\nconst m=this.#map;\nif(m.has(k))m.delete(k);\nm.set(k,v);\nthis.#trim();\nreturn v;\n}\ndelete(k){\nconst v=this.#map.get(k);\nif(this.#map.delete(k)&&this.#onEvict)this.#onEvict(v,k);\nreturn v;\n}\nclear(){\nif(this.#onEvict)for(const[k,v]of this.#map)this.#onEvict(v,k);\nthis.#map.clear();\n}\nkeys(){\nreturn this.#map.keys();\n}\nvalues(){\nreturn this.#map.values();\n}\n#trim(){\nconst m=this.#map;\nwhile(m.size>this.#max){\nconst oldest=m.keys().next().value;\nconst v=m.get(oldest);\nm.delete(oldest);\nif(this.#onEvict)this.#onEvict(v,oldest);\n}\n}\n}\nconst collators=new Map();\nfunction collator(locale,opts){\nconst key=`${locale||''}|${opts?JSON.stringify(opts):''}`;\nlet c=collators.get(key);\nif(!c){\nc=new Intl.Collator(locale||undefined,{\nnumeric:true,sensitivity:'variant',...opts,\n});\ncollators.set(key,c);\n}\nreturn c;\n}\nfunction defaultCompare(a,b){\nif(a===b)return 0;\nif(a===null||a===undefined)return 1;\nif(b===null||b===undefined)return-1;\nif(typeof a==='number'&&typeof b==='number'){\nif(Number.isNaN(a))return Number.isNaN(b)?0:1;\nif(Number.isNaN(b))return-1;\nreturn a<b?-1:a>b?1:0;\n}\nconst sa=String(a);\nconst sb=String(b);\nreturn sa<sb?-1:sa>sb?1:0;\n}\nfunction now(){\nreturn typeof performance!=='undefined'&&performance.now\n?performance.now()\n:Date.now();\n}\nconst hasRaf=typeof requestAnimationFrame==='function';\nfunction nextFrame(fn){\nif(hasRaf)return requestAnimationFrame(fn);\nreturn setTimeout(()=>fn(now()),16);\n}\nfunction cancelFrame(handle){\nif(handle==null)return;\nif(hasRaf)cancelAnimationFrame(handle);\nelse clearTimeout(handle);\n}\nfunction frameBatched(fn){\nlet handle=null;\nlet lastArgs=null;\nconst run=()=>{\nhandle=null;\nconst a=lastArgs;\nlastArgs=null;\nfn(...(a||[]));\n};\nconst wrapped=(...args)=>{\nlastArgs=args;\nif(handle===null)handle=nextFrame(run);\n};\nwrapped.cancel=()=>{\ncancelFrame(handle);\nhandle=null;\nlastArgs=null;\n};\nwrapped.flush=()=>{\nif(handle!==null){\ncancelFrame(handle);\nrun();\n}\n};\nreturn wrapped;\n}\nfunction settleDebounce(fn,waitMs){\nlet timer=null;\nlet held=null;\nconst trailing=()=>{\ntimer=null;\nif(held===null)return;\nconst args=held;\nheld=null;\nfn(...args);\narm();\n};\nconst arm=()=>{\ntimer=setTimeout(trailing,waitMs);\nif(typeof timer?.unref==='function')timer.unref();\n};\nconst wrapped=(...args)=>{\nif(timer===null){\nfn(...args);\narm();\n}else{\nheld=args;\nclearTimeout(timer);\narm();\n}\n};\nwrapped.flush=()=>{\nif(timer!==null)clearTimeout(timer);\ntimer=null;\nif(held===null)return;\nconst args=held;\nheld=null;\nfn(...args);\n};\nwrapped.cancel=()=>{\nif(timer!==null)clearTimeout(timer);\ntimer=null;\nheld=null;\n};\nwrapped.pending=()=>timer!==null||held!==null;\nreturn wrapped;\n}\nfunction whenIdle(fn,timeout=50){\nif(typeof requestIdleCallback==='function'){\nreturn requestIdleCallback(fn,{timeout});\n}\nreturn setTimeout(()=>fn({timeRemaining:()=>0,didTimeout:true}),1);\n}\nlet idSeq=0;\nfunction uid(prefix='l'){\nreturn`${prefix}${(++idSeq).toString(36)}`;\n}\n});\n__def(\"packages/worker/src/transport.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"PROTOCOL\",{enumerable:true,get:function(){return PROTOCOL;}});\nObject.defineProperty(__exports,\"OPS\",{enumerable:true,get:function(){return OPS;}});\nObject.defineProperty(__exports,\"CONTROL\",{enumerable:true,get:function(){return CONTROL;}});\nObject.defineProperty(__exports,\"ERRORS\",{enumerable:true,get:function(){return ERRORS;}});\nObject.defineProperty(__exports,\"packHandle\",{enumerable:true,get:function(){return packHandle;}});\nObject.defineProperty(__exports,\"packHandles\",{enumerable:true,get:function(){return packHandles;}});\nObject.defineProperty(__exports,\"TransportedDictionary\",{enumerable:true,get:function(){return TransportedDictionary;}});\nObject.defineProperty(__exports,\"unpackHandle\",{enumerable:true,get:function(){return unpackHandle;}});\nObject.defineProperty(__exports,\"unpackHandles\",{enumerable:true,get:function(){return unpackHandles;}});\nObject.defineProperty(__exports,\"createMaskPool\",{enumerable:true,get:function(){return createMaskPool;}});\nObject.defineProperty(__exports,\"isTransferable\",{enumerable:true,get:function(){return isTransferable;}});\nObject.defineProperty(__exports,\"collectTransfers\",{enumerable:true,get:function(){return collectTransfers;}});\nObject.defineProperty(__exports,\"isPortable\",{enumerable:true,get:function(){return isPortable;}});\nObject.defineProperty(__exports,\"filterColumnIds\",{enumerable:true,get:function(){return filterColumnIds;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst collator=__m0[\"collator\"];\nconst isFunction=__m0[\"isFunction\"];\nconst PROTOCOL=1;\nconst OPS=Object.freeze({\nSORT_COLUMN:'sortColumn',\nSORT_MULTI:'sortMulti',\nEVALUATE_FILTERS:'evaluateFilters',\nCOMPACT:'compact',\nGROUP_BY_COLUMNS:'groupByColumns',\nTOTAL:'total',\nPIVOT:'pivot',\nFACET:'facet',\nCOLUMNIZE:'columnize',\nCOLLATE_STRING_RANKS:'collateStringRanks',\n});\nconst CONTROL=Object.freeze({\nREADY:'ready',\nCANCEL:'cancel',\nPING:'ping',\n});\nconst ERRORS=Object.freeze({\nNO_COMPUTE:'E_NO_COMPUTE',\nNO_KERNEL:'E_NO_KERNEL',\nABORTED:'E_ABORTED',\nKERNEL:'E_KERNEL',\nPROTOCOL:'E_PROTOCOL',\n});\nfunction packHandle(handle){\nif(handle==null)return null;\nconst presence=handle.presence;\nreturn{\nid:handle.id,\nkind:handle.kind,\nnullable:!!handle.nullable,\nvalues:handle.values??null,\npresence:presence?(presence.words??presence):null,\npresenceBits:presence?(presence.size??(presence.words??presence).length*8):0,\ndict:handle.dict?sliceDictionary(handle.dict):null,\noffsets:handle.offsets??null,\nversion:handle.version??0,\n};\n}\nfunction sliceDictionary(dict){\nif(Array.isArray(dict))return dict;\nif(isFunction(dict.values))return dict.values();\nreturn[];\n}\nfunction packHandles(handles){\nconst out=new Array(handles.length);\nfor(let i=0;i<handles.length;i++)out[i]=packHandle(handles[i]);\nreturn out;\n}\nclass TransportedBitset{\n#words;\n#bits;\nconstructor(words,bits){\nthis.#words=words;\nthis.#bits=bits;\n}\nget words(){return this.#words;}\nget size(){return this.#bits;}\nget(i){return(this.#words[i>>>3]&(1<<(i&7)))!==0;}\ncount(){\nconst w=this.#words;\nlet n=0;\nfor(let i=0;i<w.length;i++){\nlet v=w[i];\nwhile(v){v&=v-1;n++;}\n}\nreturn n;\n}\n}\nclass TransportedDictionary{\n#values;\n#index=null;\n#version=0;\n#ranks=new Map();\nconstructor(values){\nthis.#values=values||[];\n}\nget size(){return this.#values.length;}\nget version(){return this.#version;}\ncodeOf(value){\nif(this.#index===null){\nthis.#index=new Map();\nfor(let i=0;i<this.#values.length;i++)this.#index.set(this.#values[i],i);\n}\nconst found=this.#index.get(value);\nif(found!==undefined)return found;\nconst code=this.#values.length;\nthis.#values.push(value);\nthis.#index.set(value,code);\nthis.#version++;\nreturn code;\n}\nvalueOf(code){return this.#values[code];}\nvalues(){return this.#values;}\nranks(locale){\nconst key=locale||'';\nconst cached=this.#ranks.get(key);\nif(cached&&cached.version===this.#version)return cached.ranks;\nconst n=this.#values.length;\nconst order=new Uint32Array(n);\nfor(let i=0;i<n;i++)order[i]=i;\nconst cmp=collator(locale).compare;\nconst vals=this.#values;\nconst sorted=Array.from(order).sort((a,b)=>{\nconst av=vals[a];\nconst bv=vals[b];\nif(av===bv)return 0;\nif(av===null||av===undefined)return 1;\nif(bv===null||bv===undefined)return-1;\nreturn cmp(String(av),String(bv));\n});\nconst ranks=new Uint32Array(n);\nfor(let r=0;r<sorted.length;r++)ranks[sorted[r]]=r;\nthis.#ranks.set(key,{version:this.#version,ranks});\nreturn ranks;\n}\n}\nfunction unpackHandle(packed){\nif(packed==null)return null;\nconst presence=packed.presence\n?new TransportedBitset(packed.presence,packed.presenceBits||packed.presence.length*8)\n:null;\nconst dict=packed.dict?new TransportedDictionary(packed.dict):null;\nconst values=packed.values;\nconst offsets=packed.offsets??null;\nconst kind=packed.kind;\nconst get=(physical)=>{\nif(presence&&!presence.get(physical))return null;\nswitch(kind){\ncase'dictionary':\nreturn dict?dict.valueOf(values[physical]):values[physical];\ncase'bitset':\nreturn(values[physical>>>3]&(1<<(physical&7)))!==0;\ncase'multi':{\nif(!offsets)return null;\nconst from=offsets[physical];\nconst to=offsets[physical+1];\nconst out=new Array(to-from);\nfor(let i=from;i<to;i++)out[i-from]=dict?dict.valueOf(values[i]):values[i];\nreturn out;\n}\ndefault:\nreturn values[physical];\n}\n};\nreturn{\nid:packed.id,\nkind,\nnullable:packed.nullable,\nvalues,\npresence,\ndict,\noffsets,\nget,\nversion:packed.version,\n};\n}\nfunction unpackHandles(packed){\nconst out=new Array(packed.length);\nfor(let i=0;i<packed.length;i++)out[i]=unpackHandle(packed[i]);\nreturn out;\n}\nfunction createMaskPool(){\nconst masks=[];\nconst indices=[];\nreturn{\nmask(n){\nfor(let i=0;i<masks.length;i++){\nif(masks[i].length>=n){\nconst buf=masks.splice(i,1)[0].subarray(0,n);\nbuf.fill(0);\nreturn buf;\n}\n}\nreturn new Uint8Array(n);\n},\nindices(n){\nfor(let i=0;i<indices.length;i++){\nif(indices[i].length>=n)return indices.splice(i,1)[0].subarray(0,n);\n}\nreturn new Uint32Array(n);\n},\nrelease(buf){\nif(!buf)return;\nif(buf instanceof Uint8Array)masks.push(buf);\nelse if(buf instanceof Uint32Array)indices.push(buf);\n},\nclear(){masks.length=0;indices.length=0;},\n};\n}\nfunction isTransferable(v){\nif(!ArrayBuffer.isView(v))return false;\nconst buf=(v).buffer;\nif(!buf)return false;\nreturn typeof SharedArrayBuffer==='undefined'||!(buf instanceof SharedArrayBuffer);\n}\nfunction collectTransfers(value,out=[]){\nconst add=(v)=>{\nif(!isTransferable(v))return;\nconst buf=(v).buffer;\nif(!out.includes(buf))out.push(buf);\n};\nif(value==null)return out;\nif(ArrayBuffer.isView(value)){add(value);return out;}\nif(Array.isArray(value)){\nfor(const item of value)add(item);\nreturn out;\n}\nif(typeof value==='object'){\nfor(const key of Object.keys(value)){\nconst item=(value)[key];\nif(Array.isArray(item))for(const sub of item)add(sub);\nelse add(item);\n}\n}\nreturn out;\n}\nfunction isPortable(value,depth=0){\nif(value==null)return true;\nconst t=typeof value;\nif(t==='function'||t==='symbol')return false;\nif(t!=='object')return true;\nif(depth>4)return true;\nif(ArrayBuffer.isView(value)||value instanceof ArrayBuffer||value instanceof Date)return true;\nif(Array.isArray(value)){\nfor(const item of value)if(!isPortable(item,depth+1))return false;\nreturn true;\n}\nfor(const key of Object.keys(value)){\nif(!isPortable((value)[key],depth+1))return false;\n}\nreturn true;\n}\nfunction filterColumnIds(filters,out=new Set()){\nif(!filters||typeof filters!=='object')return out;\nconst node=(filters);\nif(typeof node.col==='string')out.add(node.col);\nconst conditions=node.conditions;\nif(Array.isArray(conditions))for(const child of conditions)filterColumnIds(child,out);\nreturn out;\n}\n});\n__def(\"packages/core/src/store/bitset.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"Bitset\",{enumerable:true,get:function(){return Bitset;}});\nconst WORD_BITS=8;\nclass Bitset{\nstatic#POP=new Uint8Array(256);\nstatic{\nfor(let i=1;i<256;i++)Bitset.#POP[i]=Bitset.#POP[i>>1]+(i&1);\n}\n#words;\n#bits;\nconstructor(bits=0){\nconst n=Math.max(0,bits|0);\nthis.#bits=n;\nthis.#words=new Uint8Array(Math.ceil(n/WORD_BITS));\n}\nget size(){return this.#bits;}\nget words(){return this.#words;}\nget bytes(){return this.#words?this.#words.byteLength:0;}\nget(i){\nif(i<0||i>=this.#bits)return 0;\nreturn(this.#words[i>>3]>>(i&7))&1;\n}\nset(i){\nif(i>=0&&i<this.#bits)this.#words[i>>3]|=1<<(i&7);\nreturn this;\n}\nclear(i){\nif(i>=0&&i<this.#bits)this.#words[i>>3]&=~(1<<(i&7));\nreturn this;\n}\nassign(i,bit){return bit?this.set(i):this.clear(i);}\nfill(bit=false){\nthis.#words.fill(bit?0xff:0);\nif(bit)this.#maskTail();\nreturn this;\n}\ngrow(bits){\nconst n=Math.max(0,bits|0);\nif(n<=this.#bits)return this;\nconst need=Math.ceil(n/WORD_BITS);\nif(need>this.#words.length){\nconst next=new Uint8Array(need);\nnext.set(this.#words);\nthis.#words=next;\n}\nthis.#bits=n;\nreturn this;\n}\ncount(){\nconst w=this.#words;\nconst pop=Bitset.#POP;\nlet total=0;\nfor(let i=0;i<w.length;i++)total+=pop[w[i]];\nreturn total;\n}\nand(other){\nconst b=other instanceof Bitset?other.words:other;\nconst w=this.#words;\nconst shared=Math.min(w.length,b.length);\nfor(let i=0;i<shared;i++)w[i]&=b[i];\nfor(let i=shared;i<w.length;i++)w[i]=0;\nreturn this;\n}\nor(other){\nconst b=other instanceof Bitset?other.words:other;\nconst w=this.#words;\nconst shared=Math.min(w.length,b.length);\nfor(let i=0;i<shared;i++)w[i]|=b[i];\nreturn this;\n}\nnot(){\nconst w=this.#words;\nfor(let i=0;i<w.length;i++)w[i]=~w[i]&0xff;\nthis.#maskTail();\nreturn this;\n}\nclone(){\nconst out=new Bitset(this.#bits);\nout.words.set(this.#words.subarray(0,out.words.length));\nreturn out;\n}\nrelease(){\nthis.#words=new Uint8Array(0);\nthis.#bits=0;\n}\n#maskTail(){\nconst used=this.#bits&7;\nif(used===0)return;\nconst last=(this.#bits>>3);\nif(last<this.#words.length)this.#words[last]&=(1<<used)-1;\n}\nstatic from(bools){\nconst arr=Array.isArray(bools)?bools:Array.from(bools);\nconst out=new Bitset(arr.length);\nfor(let i=0;i<arr.length;i++)if(arr[i])out.set(i);\nreturn out;\n}\n}\n});\n__def(\"packages/core/src/store/dictionary.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"Dictionary\",{enumerable:true,get:function(){return Dictionary;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst collator=__m0[\"collator\"];\nconst defaultCompare=__m0[\"defaultCompare\"];\nclass Dictionary{\n#values;\n#codes=new Map();\n#version=0;\n#ranks=null;\n#ranksVersion=-1;\n#ranksLocale='\\u0000';\nconstructor(values=[]){\nthis.#values=[];\nfor(let i=0;i<values.length;i++){\nconst v=values[i];\nif(this.#codes.has(v))continue;\nthis.#codes.set(v,this.#values.length);\nthis.#values.push(v);\n}\n}\nget size(){return this.#values.length;}\nget version(){return this.#version;}\nget bytes(){\nlet total=this.#values.length*8;\nfor(let i=0;i<this.#values.length;i++){\nconst v=this.#values[i];\nif(typeof v==='string')total+=v.length*2;\ntotal+=16;\n}\nreturn total;\n}\ncodeOf(value){\nconst existing=this.#codes.get(value);\nif(existing!==undefined)return existing;\nconst code=this.#values.length;\nthis.#values.push(value);\nthis.#codes.set(value,code);\nthis.#version++;\nreturn code;\n}\nlookup(value){\nconst code=this.#codes.get(value);\nreturn code===undefined?-1:code;\n}\nhas(value){return this.#codes.has(value);}\nvalueOf(code){return this.#values[code];}\nvalues(){return this.#values;}\nranks(locale){\nconst key=locale||'';\nif(this.#ranks&&this.#ranksVersion===this.#version&&this.#ranksLocale===key){\nreturn this.#ranks;\n}\nconst n=this.#values.length;\nconst order=new Array(n);\nfor(let i=0;i<n;i++)order[i]=i;\nconst cmp=collator(locale).compare;\nconst values=this.#values;\norder.sort((a,b)=>this.#compare(values[a],values[b],cmp));\nconst ranks=new Uint32Array(n);\nfor(let rank=0;rank<n;rank++)ranks[order[rank]]=rank;\nthis.#ranks=ranks;\nthis.#ranksVersion=this.#version;\nthis.#ranksLocale=key;\nreturn ranks;\n}\n#compare(a,b,compare){\nif(typeof a==='string'&&typeof b==='string')return compare(a,b);\nreturn defaultCompare(a,b);\n}\n}\n});\n__def(\"packages/core/src/store/multivalue.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"MultiValue\",{enumerable:true,get:function(){return MultiValue;}});\nclass MultiValue{\n#values;\n#offsets;\n#rows=0;\n#fill=0;\nconstructor(capacity={}){\nconst rows=Math.max(1,capacity.rows??16);\nconst values=Math.max(1,capacity.values??rows);\nthis.#values=new Int32Array(values);\nthis.#offsets=new Uint32Array(rows+1);\n}\nget values(){return this.#values;}\nget offsets(){return this.#offsets;}\nget rows(){return this.#rows;}\nget length(){return this.#fill;}\nget bytes(){return this.#values.byteLength+this.#offsets.byteLength;}\ncount(r){\nif(r<0||r>=this.#rows)return 0;\nreturn this.#offsets[r+1]-this.#offsets[r];\n}\nat(r){\nif(r<0||r>=this.#rows)return this.#values.subarray(0,0);\nreturn this.#values.subarray(this.#offsets[r],this.#offsets[r+1]);\n}\nhas(r,code){\nif(r<0||r>=this.#rows)return false;\nconst v=this.#values;\nconst end=this.#offsets[r+1];\nfor(let i=this.#offsets[r];i<end;i++)if(v[i]===code)return true;\nreturn false;\n}\nhasAny(r,codes){\nfor(let i=0;i<codes.length;i++)if(this.has(r,codes[i]))return true;\nreturn false;\n}\nhasAll(r,codes){\nfor(let i=0;i<codes.length;i++)if(!this.has(r,codes[i]))return false;\nreturn true;\n}\nhasNone(r,codes){return!this.hasAny(r,codes);}\npush(codes){\nconst r=this.#rows;\nconst n=codes.length;\nthis.#ensureRows(r+1);\nthis.#ensureValues(this.#fill+n);\nconst start=this.#fill;\nfor(let i=0;i<n;i++)this.#values[start+i]=codes[i]|0;\nthis.#fill+=n;\nthis.#rows=r+1;\nthis.#offsets[r]=start;\nthis.#offsets[r+1]=this.#fill;\nreturn r;\n}\nwrite(r,codes){\nif(r===this.#rows){this.push(codes);return;}\nif(r<0||r>this.#rows)return;\nconst start=this.#offsets[r];\nconst end=this.#offsets[r+1];\nconst n=codes.length;\nif(end-start===n){\nfor(let i=0;i<n;i++)this.#values[start+i]=codes[i]|0;\nreturn;\n}\nthis.#rebuild(r,codes);\n}\ncompact(remap,liveCount,dead){\nconst oldValues=this.#values;\nconst oldOffsets=this.#offsets;\nconst oldRows=this.#rows;\nconst values=new Int32Array(Math.max(1,this.#fill));\nconst offsets=new Uint32Array(liveCount+1);\nlet w=0;\nfor(let p=0;p<oldRows;p++){\nif(remap[p]===dead)continue;\nconst start=oldOffsets[p];\nconst end=oldOffsets[p+1];\noffsets[remap[p]]=w;\nfor(let i=start;i<end;i++)values[w++]=oldValues[i];\noffsets[remap[p]+1]=w;\n}\nthis.#values=values;\nthis.#offsets=offsets;\nthis.#rows=liveCount;\nthis.#fill=w;\n}\nrelease(){\nthis.#values=new Int32Array(0);\nthis.#offsets=new Uint32Array(1);\nthis.#rows=0;\nthis.#fill=0;\n}\n#ensureRows(rows){\nif(rows+1<=this.#offsets.length)return;\nlet cap=this.#offsets.length-1;\nwhile(cap<rows)cap=cap*2||16;\nconst next=new Uint32Array(cap+1);\nnext.set(this.#offsets);\nthis.#offsets=next;\n}\n#ensureValues(n){\nif(n<=this.#values.length)return;\nlet cap=this.#values.length;\nwhile(cap<n)cap=cap*2||16;\nconst next=new Int32Array(cap);\nnext.set(this.#values);\nthis.#values=next;\n}\n#rebuild(r,codes){\nconst oldValues=this.#values;\nconst oldOffsets=this.#offsets;\nconst rows=this.#rows;\nconst delta=codes.length-(oldOffsets[r+1]-oldOffsets[r]);\nconst values=new Int32Array(Math.max(1,this.#fill+delta));\nconst offsets=new Uint32Array(oldOffsets.length);\nlet w=0;\nfor(let p=0;p<rows;p++){\noffsets[p]=w;\nif(p===r){\nfor(let i=0;i<codes.length;i++)values[w++]=codes[i]|0;\n}else{\nfor(let i=oldOffsets[p];i<oldOffsets[p+1];i++)values[w++]=oldValues[i];\n}\noffsets[p+1]=w;\n}\nthis.#values=values;\nthis.#offsets=offsets;\nthis.#fill=w;\n}\n}\n});\n__def(\"packages/core/src/compute/handle.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"identity\",{enumerable:true,get:function(){return identity;}});\nObject.defineProperty(__exports,\"rowCount\",{enumerable:true,get:function(){return rowCount;}});\nObject.defineProperty(__exports,\"bitReader\",{enumerable:true,get:function(){return bitReader;}});\nObject.defineProperty(__exports,\"presenceReader\",{enumerable:true,get:function(){return presenceReader;}});\nObject.defineProperty(__exports,\"dictSize\",{enumerable:true,get:function(){return dictSize;}});\nObject.defineProperty(__exports,\"dictValue\",{enumerable:true,get:function(){return dictValue;}});\nObject.defineProperty(__exports,\"multiValue\",{enumerable:true,get:function(){return multiValue;}});\nObject.defineProperty(__exports,\"valueReader\",{enumerable:true,get:function(){return valueReader;}});\nObject.defineProperty(__exports,\"numericTotalOrder\",{enumerable:true,get:function(){return numericTotalOrder;}});\nObject.defineProperty(__exports,\"valueComparator\",{enumerable:true,get:function(){return valueComparator;}});\nObject.defineProperty(__exports,\"dictRanks\",{enumerable:true,get:function(){return dictRanks;}});\nObject.defineProperty(__exports,\"isMissing\",{enumerable:true,get:function(){return isMissing;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst collator=__m0[\"collator\"];\nconst defaultCompare=__m0[\"defaultCompare\"];\nconst warnOnce=__m0[\"warnOnce\"];\nfunction identity(n){\nconst out=new Uint32Array(n);\nfor(let i=0;i<n;i++)out[i]=i;\nreturn out;\n}\nfunction rowCount(handle,opts){\nif(opts&&typeof opts.count==='number')return opts.count;\nif(!handle)return 0;\nif(typeof handle.count==='number')return handle.count;\nif(typeof handle.length==='number')return handle.length;\nconst values=handle.values;\nif(handle.kind==='multi'&&handle.offsets)return Math.max(0,handle.offsets.length-1);\nif(!values)return handle.presence&&typeof handle.presence.size==='number'?handle.presence.size:0;\nif(handle.kind==='bitset'){\nif(typeof values.size==='number')return values.size;\nif(handle.presence&&typeof handle.presence.size==='number')return handle.presence.size;\nwarnOnce(`count:${handle.id}`,`column \"${handle.id}\" is bitset-backed with no declared row count; assuming ${values.length*8}`);\nreturn values.length*8;\n}\nreturn values.length;\n}\nconst bitOrders=new WeakMap();\nfunction bitOrderOf(bitset){\nconst ctor=bitset.constructor;\nif(!ctor)return'unknown';\nconst cached=bitOrders.get(ctor);\nif(cached)return cached;\nlet order='unknown';\ntry{\nlet probe=null;\nif(typeof ctor.from==='function')probe=ctor.from([false,true]);\nelse{\nprobe=new ctor(8);\nprobe.set(1);\n}\nconst words=probe&&probe.words;\nif(words&&words.length){\nif(words[0]===0x02)order='lsb';\nelse if(words[0]===0x40)order='msb';\n}\n}catch{\norder='unknown';\n}\nbitOrders.set(ctor,order);\nreturn order;\n}\nfunction bitReader(bits){\nif(!bits)return()=>0;\nconst raw=bits instanceof Uint8Array?bits:bits.words;\nif(raw instanceof Uint8Array){\nconst order=bits instanceof Uint8Array?'lsb':bitOrderOf(bits);\nif(order==='lsb')return(i)=>(raw[i>>>3]>>>(i&7))&1;\nif(order==='msb')return(i)=>(raw[i>>>3]>>>(7-(i&7)))&1;\n}\nif(typeof bits.get==='function')return(i)=>(bits.get(i)?1:0);\nreturn()=>0;\n}\nfunction presenceReader(handle){\nif(!handle||!handle.presence)return null;\nreturn bitReader(handle.presence);\n}\nfunction dictSize(dict){\nif(!dict)return 0;\nif(typeof dict.size==='number')return dict.size;\nif(typeof dict.values==='function')return dict.values().length;\nreturn 0;\n}\nfunction dictValue(dict,code){\nif(!dict)return null;\nif(typeof dict.valueOf==='function')return dict.valueOf(code);\nif(typeof dict.values==='function')return dict.values()[code];\nreturn null;\n}\nfunction multiValue(handle,i){\nconst offsets=handle.offsets;\nconst values=handle.values;\nif(!offsets||!values)return[];\nconst from=offsets[i];\nconst to=offsets[i+1];\nif(!(to>from))return[];\nconst dict=handle.dict;\nconst out=new Array(to-from);\nfor(let k=from;k<to;k++)out[k-from]=dict?dictValue(dict,values[k]):values[k];\nreturn out;\n}\nfunction valueReader(handle){\nif(!handle)return()=>undefined;\nconst values=handle.values;\nconst present=presenceReader(handle);\nconst kind=handle.kind;\nif(kind==='dictionary'){\nconst dict=handle.dict;\nif(present)return(i)=>(present(i)?dictValue(dict,values[i]):null);\nreturn(i)=>dictValue(dict,values[i]);\n}\nif(kind==='bitset'){\nconst bit=bitReader(values);\nif(present)return(i)=>(present(i)?bit(i)===1:null);\nreturn(i)=>bit(i)===1;\n}\nif(kind==='multi'){\nif(present)return(i)=>(present(i)?multiValue(handle,i):null);\nreturn(i)=>multiValue(handle,i);\n}\nif(!values&&typeof handle.get==='function'){\nconst get=handle.get.bind(handle);\nreturn(i)=>{\nconst v=get(i);\nreturn v===undefined?null:v;\n};\n}\nif(present){\nreturn(i)=>{\nif(!present(i))return null;\nconst v=values[i];\nreturn v===undefined?null:v;\n};\n}\nreturn(i)=>{\nconst v=values[i];\nreturn v===undefined?null:v;\n};\n}\nfunction numericTotalOrder(a,b){\nif(a<b)return-1;\nif(a>b)return 1;\nif(a===b){\nconst na=Object.is(a,-0);\nconst nb=Object.is(b,-0);\nif(na===nb)return 0;\nreturn na?-1:1;\n}\nconst an=Number.isNaN(a);\nconst bn=Number.isNaN(b);\nif(an&&bn)return 0;\nreturn an?1:-1;\n}\nfunction valueComparator(locale){\nconst coll=collator(locale);\nreturn(a,b)=>{\nif(a===b)return 0;\nconst ta=typeof a;\nconst tb=typeof b;\nif(ta==='string'&&tb==='string')return coll.compare(a,b);\nif(ta==='number'&&tb==='number')return numericTotalOrder(a,b);\nif(ta==='boolean'&&tb==='boolean')return a===b?0:a?1:-1;\nif(a instanceof Date||b instanceof Date){\nconst na=a instanceof Date?a.getTime():Number(a);\nconst nb=b instanceof Date?b.getTime():Number(b);\nreturn numericTotalOrder(na,nb);\n}\nreturn defaultCompare(a,b);\n};\n}\nfunction dictRanks(dict,locale){\nif(dict&&typeof dict.ranks==='function')return dict.ranks(locale);\nconst table=dict&&typeof dict.values==='function'?dict.values():[];\nconst n=table.length;\nconst cmp=valueComparator(locale);\nconst order=new Array(n);\nfor(let i=0;i<n;i++)order[i]=i;\norder.sort((a,b)=>cmp(table[a],table[b])||a-b);\nconst ranks=new Uint32Array(n);\nfor(let r=0;r<n;r++)ranks[order[r]]=r;\nreturn ranks;\n}\nfunction isMissing(v){\nreturn v===null||v===undefined||(typeof v==='number'&&Number.isNaN(v));\n}\n});\n__def(\"packages/core/src/compute/sort.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"radixSortFloat64\",{enumerable:true,get:function(){return radixSortFloat64;}});\nObject.defineProperty(__exports,\"radixSortInt32\",{enumerable:true,get:function(){return radixSortInt32;}});\nObject.defineProperty(__exports,\"rankSortDictionary\",{enumerable:true,get:function(){return rankSortDictionary;}});\nObject.defineProperty(__exports,\"mergeSortComparator\",{enumerable:true,get:function(){return mergeSortComparator;}});\nObject.defineProperty(__exports,\"rankSortStrings\",{enumerable:true,get:function(){return rankSortStrings;}});\nObject.defineProperty(__exports,\"collateStringRanks\",{enumerable:true,get:function(){return collateStringRanks;}});\nObject.defineProperty(__exports,\"sortColumn\",{enumerable:true,get:function(){return sortColumn;}});\nObject.defineProperty(__exports,\"sortMulti\",{enumerable:true,get:function(){return sortMulti;}});\nconst __m0=__req(\"packages/core/src/compute/handle.js\");\nconst bitReader=__m0[\"bitReader\"];\nconst dictRanks=__m0[\"dictRanks\"];\nconst dictSize=__m0[\"dictSize\"];\nconst identity=__m0[\"identity\"];\nconst isMissing=__m0[\"isMissing\"];\nconst presenceReader=__m0[\"presenceReader\"];\nconst rowCount=__m0[\"rowCount\"];\nconst valueComparator=__m0[\"valueComparator\"];\nconst valueReader=__m0[\"valueReader\"];\nconst EMPTY_INDICES=new Uint32Array(0);\nconst SCRATCH=new ArrayBuffer(8);\nconst SCRATCH_F64=new Float64Array(SCRATCH);\nconst SCRATCH_U32=new Uint32Array(SCRATCH);\nconst HI=(()=>{\nSCRATCH_F64[0]=-1;\nreturn(SCRATCH_U32[1]&0x80000000)!==0?1:0;\n})();\nconst LO=HI===1?0:1;\nfunction transformDouble(value,out){\nSCRATCH_F64[0]=value;\nlet hi=SCRATCH_U32[HI];\nlet lo=SCRATCH_U32[LO];\nif((hi&0x80000000)!==0){\nhi=~hi>>>0;\nlo=~lo>>>0;\n}else{\nhi=(hi^0x80000000)>>>0;\n}\nout[0]=lo;\nout[1]=hi;\n}\nfunction radixLsd64(idx,lo,hi,n){\nif(n<2)return idx;\nconst hist=new Uint32Array(256*8);\nfor(let i=0;i<n;i++){\nconst l=lo[i];\nconst h=hi[i];\nhist[l&0xff]++;\nhist[256+((l>>>8)&0xff)]++;\nhist[512+((l>>>16)&0xff)]++;\nhist[768+((l>>>24)&0xff)]++;\nhist[1024+(h&0xff)]++;\nhist[1280+((h>>>8)&0xff)]++;\nhist[1536+((h>>>16)&0xff)]++;\nhist[1792+((h>>>24)&0xff)]++;\n}\nlet srcIdx=idx;\nlet srcLo=lo;\nlet srcHi=hi;\nlet dstIdx=new Uint32Array(n);\nlet dstLo=new Uint32Array(n);\nlet dstHi=new Uint32Array(n);\nconst offset=new Uint32Array(256);\nfor(let pass=0;pass<8;pass++){\nconst base=pass<<8;\nconst shift=(pass&3)<<3;\nconst useHi=pass>=4;\nlet skip=false;\nfor(let b=0;b<256;b++){\nif(hist[base+b]===n){skip=true;break;}\n}\nif(skip)continue;\nlet sum=0;\nfor(let b=0;b<256;b++){\noffset[b]=sum;\nsum+=hist[base+b];\n}\nfor(let i=0;i<n;i++){\nconst l=srcLo[i];\nconst h=srcHi[i];\nconst digit=((useHi?h:l)>>>shift)&0xff;\nconst p=offset[digit]++;\ndstIdx[p]=srcIdx[i];\ndstLo[p]=l;\ndstHi[p]=h;\n}\nlet t=srcIdx;srcIdx=dstIdx;dstIdx=t;\nt=srcLo;srcLo=dstLo;dstLo=t;\nt=srcHi;srcHi=dstHi;dstHi=t;\n}\nreturn srcIdx;\n}\nfunction radixLsd32(idx,keys,n){\nif(n<2)return idx;\nconst hist=new Uint32Array(256*4);\nfor(let i=0;i<n;i++){\nconst k=keys[i];\nhist[k&0xff]++;\nhist[256+((k>>>8)&0xff)]++;\nhist[512+((k>>>16)&0xff)]++;\nhist[768+((k>>>24)&0xff)]++;\n}\nlet srcIdx=idx;\nlet srcKeys=keys;\nlet dstIdx=new Uint32Array(n);\nlet dstKeys=new Uint32Array(n);\nconst offset=new Uint32Array(256);\nfor(let pass=0;pass<4;pass++){\nconst base=pass<<8;\nconst shift=pass<<3;\nlet skip=false;\nfor(let b=0;b<256;b++){\nif(hist[base+b]===n){skip=true;break;}\n}\nif(skip)continue;\nlet sum=0;\nfor(let b=0;b<256;b++){\noffset[b]=sum;\nsum+=hist[base+b];\n}\nfor(let i=0;i<n;i++){\nconst k=srcKeys[i];\nconst p=offset[(k>>>shift)&0xff]++;\ndstIdx[p]=srcIdx[i];\ndstKeys[p]=k;\n}\nlet t=srcIdx;srcIdx=dstIdx;dstIdx=t;\nt=srcKeys;srcKeys=dstKeys;dstKeys=t;\n}\nreturn srcIdx;\n}\nfunction countingSort(idx,keys,n,radix){\nconst counts=new Uint32Array(radix+1);\nfor(let i=0;i<n;i++)counts[keys[i]]++;\nlet sum=0;\nfor(let k=0;k<=radix;k++){\nconst c=counts[k];\ncounts[k]=sum;\nsum+=c;\n}\nconst out=new Uint32Array(n);\nfor(let i=0;i<n;i++)out[counts[keys[i]]++]=idx[i];\nreturn out;\n}\nfunction sortUint32Keys(idx,keys,n,radix){\nif(n<2)return idx;\nif(radix<=65536||radix<=n*2)return countingSort(idx,keys,n,radix);\nreturn radixLsd32(idx,keys,n);\n}\nfunction exact(buffer,n){\nif(buffer.length===n&&buffer.byteOffset===0)return buffer;\nreturn Uint32Array.prototype.slice.call(buffer,0,n);\n}\nfunction radixSortFloat64(values,order,descending=false){\nconst src=order||identity(values.length);\nconst n=src.length;\nif(n<2)return Uint32Array.from(src);\nconst idx=new Uint32Array(n);\nconst lo=new Uint32Array(n);\nconst hi=new Uint32Array(n);\nconst nans=new Uint32Array(n);\nconst pair=new Uint32Array(2);\nlet m=0;\nlet nanCount=0;\nfor(let i=0;i<n;i++){\nconst row=src[i];\nconst v=values[row];\nif(Number.isNaN(v)){nans[nanCount++]=row;continue;}\ntransformDouble(v,pair);\nif(descending){\nlo[m]=~pair[0]>>>0;\nhi[m]=~pair[1]>>>0;\n}else{\nlo[m]=pair[0];\nhi[m]=pair[1];\n}\nidx[m++]=row;\n}\nconst sorted=radixLsd64(idx.subarray(0,m),lo.subarray(0,m),hi.subarray(0,m),m);\nif(nanCount===0)return exact(sorted,m);\nconst out=new Uint32Array(n);\nout.set(sorted.subarray(0,m),0);\nout.set(nans.subarray(0,nanCount),m);\nreturn out;\n}\nfunction radixSortInt32(values,order,descending=false){\nconst src=order||identity(values.length);\nconst n=src.length;\nif(n<2)return Uint32Array.from(src);\nconst idx=Uint32Array.from(src);\nconst keys=new Uint32Array(n);\nfor(let i=0;i<n;i++){\nconst k=(values[idx[i]]^0x80000000)>>>0;\nkeys[i]=descending?(~k>>>0):k;\n}\nreturn exact(radixLsd32(idx,keys,n),n);\n}\nfunction rankSortDictionary(handle,order,opts={}){\nconst src=order||identity(rowCount(handle,opts));\nconst n=src.length;\nif(n<2)return Uint32Array.from(src);\nconst ranks=dictRanks(handle.dict,opts.locale);\nconst codes=handle.values;\nconst present=presenceReader(handle);\nconst size=Math.max(dictSize(handle.dict),ranks.length);\nconst absentRank=size;\nconst idx=Uint32Array.from(src);\nconst keys=new Uint32Array(n);\nconst descending=!!opts.descending;\nfor(let i=0;i<n;i++){\nconst row=idx[i];\nlet rank=present&&present(row)===0?absentRank:ranks[codes[row]];\nif(rank===undefined)rank=absentRank;\nkeys[i]=descending?absentRank-rank:rank;\n}\nreturn exact(sortUint32Keys(idx,keys,n,size+1),n);\n}\nfunction mergeSortComparator(values,order,compare){\nconst n=order.length;\nlet src=Uint32Array.from(order);\nif(n<2)return src;\nlet dst=new Uint32Array(n);\nfor(let width=1;width<n;width<<=1){\nfor(let start=0;start<n;start+=width<<1){\nconst mid=Math.min(start+width,n);\nconst end=Math.min(start+(width<<1),n);\nlet i=start;\nlet j=mid;\nlet k=start;\nwhile(i<mid&&j<end){\ndst[k++]=compare(values[src[i]],values[src[j]])<=0?src[i++]:src[j++];\n}\nwhile(i<mid)dst[k++]=src[i++];\nwhile(j<end)dst[k++]=src[j++];\n}\nconst t=src;src=dst;dst=t;\n}\nreturn src;\n}\nfunction sortBitsetColumn(handle,idx,descending){\nconst bit=bitReader(handle.values);\nconst n=idx.length;\nconst out=new Uint32Array(n);\nconst first=descending?1:0;\nlet k=0;\nfor(let i=0;i<n;i++)if(bit(idx[i])===first)out[k++]=idx[i];\nfor(let i=0;i<n;i++)if(bit(idx[i])!==first)out[k++]=idx[i];\nreturn out;\n}\nfunction indexableValues(handle,idx){\nconst values=handle.values;\nconst kind=handle.kind;\nconst direct=(kind==='object'||kind===undefined)&&(Array.isArray(values)||ArrayBuffer.isView(values));\nif(direct&&!handle.presence)return values;\nconst reader=valueReader(handle);\nconst materialised=new Array(rowCount(handle)||0);\nfor(let i=0;i<idx.length;i++){\nconst row=idx[i];\nmaterialised[row]=reader(row);\n}\nreturn materialised;\n}\nfunction allStrings(values,idx){\nfor(let i=0;i<idx.length;i++){\nif(typeof values[idx[i]]!=='string')return false;\n}\nreturn true;\n}\nfunction rankSortStrings(idx,codes,ranks,d,descending){\nconst n=idx.length;\nconst idxOut=Uint32Array.from(idx);\nif(n<2||d<1)return idxOut;\nconst keys=new Uint32Array(n);\nconst top=d-1;\nfor(let i=0;i<n;i++){\nconst rank=ranks[codes[i]];\nkeys[i]=descending?top-rank:rank;\n}\nreturn exact(sortUint32Keys(idxOut,keys,n,d),n);\n}\nfunction collateStringRanks(table,d,locale){\nconst compare=valueComparator(locale);\nconst order=new Array(d);\nfor(let i=0;i<d;i++)order[i]=i;\norder.sort((a,b)=>compare(table[a],table[b])||a-b);\nconst ranks=new Uint32Array(d);\nfor(let r=0;r<d;r++)ranks[order[r]]=r;\nreturn ranks;\n}\nfunction keyedSortStrings(values,idx,opts){\nconst n=idx.length;\nconst codeOf=new Map();\nconst table=[];\nconst codes=new Uint32Array(n);\nfor(let i=0;i<n;i++){\nconst v=values[idx[i]];\nlet c=codeOf.get(v);\nif(c===undefined){c=table.length;codeOf.set(v,c);table.push(v);}\ncodes[i]=c;\n}\nconst d=table.length;\nconst ranks=collateStringRanks(table,d,opts.locale);\nreturn rankSortStrings(idx,codes,ranks,d,!!opts.descending);\n}\nfunction sortByComparator(handle,idx,opts){\nconst values=indexableValues(handle,idx);\nif(idx.length>=2&&allStrings(values,idx)){\nconst index=handle.stringRank;\nif(index&&index.version===handle.version&&index.usable(idx,values,opts.locale)){\nreturn index.sort(idx,opts);\n}\nreturn keyedSortStrings(values,idx,opts);\n}\nconst base=valueComparator(opts.locale);\nconst compare=opts.descending?(a,b)=>base(b,a):base;\nreturn mergeSortComparator(values,idx,compare);\n}\nfunction sortByCompare(handle,idx,opts){\nconst values=indexableValues(handle,idx);\nconst user=opts.compare;\nconst descending=!!opts.descending;\nconst compare=descending\n?(a,b)=>-user(a,b,undefined,undefined,true)\n:(a,b)=>user(a,b,undefined,undefined,false);\nreturn mergeSortComparator(values,idx,compare);\n}\nfunction partitionPresent(handle,idx){\nconst n=idx.length;\nconst present=presenceReader(handle);\nconst values=handle.values;\nconst checkNaN=handle.kind==='float64'&&!!values;\nconst looseKind=handle.kind==='object'||handle.kind==='multi'||handle.kind===undefined;\nif(!present&&!checkNaN&&!looseKind)return{present:idx,absent:EMPTY_INDICES};\nconst keep=new Uint32Array(n);\nconst drop=new Uint32Array(n);\nlet p=0;\nlet a=0;\nif(present&&checkNaN){\nfor(let i=0;i<n;i++){\nconst row=idx[i];\nif(present(row)===1&&!Number.isNaN(values[row]))keep[p++]=row;else drop[a++]=row;\n}\n}else if(checkNaN&&!present){\nfor(let i=0;i<n;i++){\nconst row=idx[i];\nif(!Number.isNaN(values[row]))keep[p++]=row;else drop[a++]=row;\n}\n}else if(present&&!looseKind){\nfor(let i=0;i<n;i++){\nconst row=idx[i];\nif(present(row)===1)keep[p++]=row;else drop[a++]=row;\n}\n}else{\nconst reader=valueReader(handle);\nfor(let i=0;i<n;i++){\nconst row=idx[i];\nif(!isMissing(reader(row)))keep[p++]=row;else drop[a++]=row;\n}\n}\nif(a===0)return{present:idx,absent:EMPTY_INDICES};\nreturn{present:keep.subarray(0,p),absent:drop.subarray(0,a)};\n}\nfunction joinRuns(sorted,absent,nullsFirst){\nif(absent.length===0)return sorted;\nconst out=new Uint32Array(sorted.length+absent.length);\nif(nullsFirst){\nout.set(absent,0);\nout.set(sorted,absent.length);\n}else{\nout.set(sorted,0);\nout.set(absent,sorted.length);\n}\nreturn out;\n}\nfunction sortColumn(handle,order,opts={}){\nconst src=order||identity(rowCount(handle,opts));\nif(!handle||src.length<2)return Uint32Array.from(src);\nconst{present,absent}=partitionPresent(handle,src);\nif(present.length===0)return Uint32Array.from(src);\nconst descending=!!opts.descending;\nlet sorted;\nif(typeof opts.compare==='function'){\nsorted=sortByCompare(handle,present,opts);\n}else{\nswitch(handle.kind){\ncase'float64':\nsorted=radixSortFloat64(handle.values,present,descending);\nbreak;\ncase'int32':\nsorted=radixSortInt32(handle.values,present,descending);\nbreak;\ncase'dictionary':\nsorted=rankSortDictionary(handle,present,opts);\nbreak;\ncase'bitset':\nsorted=sortBitsetColumn(handle,present,descending);\nbreak;\ndefault:\nsorted=sortByComparator(handle,present,opts);\nbreak;\n}\n}\nreturn joinRuns(sorted,absent,!!opts.nullsFirst);\n}\nfunction sortMulti(handles,entries,order,opts={}){\nconst list=entries||[];\nconst first=(list.length&&(list[0].handle||byId(handles,list[0].col)))||(handles&&handles[0]);\nlet current=order||identity(rowCount(first,opts));\nfor(let i=list.length-1;i>=0;i--){\nconst entry=list[i];\nconst handle=entry.handle||byId(handles,entry.col)||(handles&&handles[i]);\nif(!handle)continue;\ncurrent=sortColumn(handle,current,{\ndescending:entry.descending!==undefined?!!entry.descending:entry.dir==='desc',\nnullsFirst:!!entry.nullsFirst,\nlocale:entry.locale!==undefined?entry.locale:opts.locale,\ncompare:entry.compare,\n});\n}\nreturn current instanceof Uint32Array?current:Uint32Array.from(current);\n}\nfunction byId(handles,id){\nif(!handles||id===undefined)return undefined;\nfor(let i=0;i<handles.length;i++)if(handles[i]&&handles[i].id===id)return handles[i];\nreturn undefined;\n}\n});\n__def(\"packages/core/src/store/stringrank.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"DEFAULT_MAX_DISTINCT\",{enumerable:true,get:function(){return DEFAULT_MAX_DISTINCT;}});\nObject.defineProperty(__exports,\"StringRankIndex\",{enumerable:true,get:function(){return StringRankIndex;}});\nconst __m0=__req(\"packages/core/src/compute/sort.js\");\nconst collateStringRanks=__m0[\"collateStringRanks\"];\nconst rankSortStrings=__m0[\"rankSortStrings\"];\nconst DEFAULT_MAX_DISTINCT=100000;\nclass StringRankIndex{\n#table=[];\n#codeOf=new Map();\n#codeByRow;\n#length=0;\n#generation=0;\n#stamp=-1;\n#maxDistinct;\n#capped=false;\n#ranks=null;\n#ranksGeneration=-1;\n#ranksLocale='\\u0000';\nconstructor(maxDistinct=DEFAULT_MAX_DISTINCT){\nthis.#maxDistinct=maxDistinct>0?maxDistinct:DEFAULT_MAX_DISTINCT;\nthis.#codeByRow=new Uint32Array(0);\n}\nget version(){return this.#stamp;}\nset version(version){this.#stamp=version;}\nget generation(){return this.#generation;}\nget size(){return this.#table.length;}\nget capped(){return this.#capped;}\nget length(){return this.#length;}\nget bytes(){\nlet total=this.#codeByRow.byteLength;\nconst table=this.#table;\nfor(let i=0;i<table.length;i++)total+=table[i].length*2+24;\nreturn total;\n}\n#intern(value,capOnGrowth){\nconst existing=this.#codeOf.get(value);\nif(existing!==undefined)return existing;\nif(this.#capped)return-1;\nif(capOnGrowth&&this.#table.length>=this.#maxDistinct){\nthis.#capped=true;\nreturn-1;\n}\nconst code=this.#table.length;\nthis.#table.push(value);\nthis.#codeOf.set(value,code);\nthis.#generation++;\nreturn code;\n}\nbuild(values,count){\nconst n=count|0;\nthis.#table=[];\nthis.#codeOf=new Map();\nthis.#generation=0;\nthis.#capped=false;\nthis.#ranks=null;\nthis.#ranksGeneration=-1;\nthis.#codeByRow=new Uint32Array(n);\nfor(let row=0;row<n;row++){\nconst v=values[row];\nconst code=typeof v==='string'?this.#intern(v,false):-1;\nthis.#codeByRow[row]=code<0?0:code;\n}\nthis.#length=n;\n}\nappend(values,from,count){\nconst to=(from|0)+(count|0);\nif(to>this.#codeByRow.length){\nconst next=new Uint32Array(to);\nnext.set(this.#codeByRow.subarray(0,this.#length));\nthis.#codeByRow=next;\n}\nfor(let row=from|0;row<to;row++){\nconst v=values[row];\nconst code=typeof v==='string'?this.#intern(v,true):-1;\nthis.#codeByRow[row]=code<0?0:code;\n}\nthis.#length=Math.max(this.#length,to);\n}\nranks(locale){\nconst key=locale||'';\nif(this.#ranks&&this.#ranksGeneration===this.#generation&&this.#ranksLocale===key){\nreturn this.#ranks;\n}\nconst ranks=collateStringRanks(this.#table,this.#table.length,locale);\nthis.#ranks=ranks;\nthis.#ranksGeneration=this.#generation;\nthis.#ranksLocale=key;\nreturn ranks;\n}\nusable(idx,values,locale){\nif(this.#capped||this.#table.length===0)return false;\nconst codeByRow=this.#codeByRow;\nconst table=this.#table;\nconst covered=this.#length;\nfor(let i=0;i<idx.length;i++){\nconst row=idx[i];\nif(row>=covered)return false;\nif(table[codeByRow[row]]!==values[row])return false;\n}\nreturn true;\n}\nsort(idx,opts){\nconst ranks=this.ranks(opts.locale);\nconst d=this.#table.length;\nconst n=idx.length;\nconst codes=new Uint32Array(n);\nconst codeByRow=this.#codeByRow;\nfor(let i=0;i<n;i++)codes[i]=codeByRow[idx[i]];\nreturn rankSortStrings(idx,codes,ranks,d,!!opts.descending);\n}\n}\n});\n__def(\"packages/core/src/store/columnstore.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"REMOVED\",{enumerable:true,get:function(){return REMOVED;}});\nObject.defineProperty(__exports,\"toFloat\",{enumerable:true,get:function(){return toFloat;}});\nObject.defineProperty(__exports,\"ColumnHandle\",{enumerable:true,get:function(){return ColumnHandle;}});\nObject.defineProperty(__exports,\"ColumnStore\",{enumerable:true,get:function(){return ColumnStore;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst warnOnce=__m0[\"warnOnce\"];\nconst isFunction=__m0[\"isFunction\"];\nconst pathGetter=__m0[\"pathGetter\"];\nconst __m1=__req(\"packages/core/src/store/bitset.js\");\nconst Bitset=__m1[\"Bitset\"];\nconst __m2=__req(\"packages/core/src/store/dictionary.js\");\nconst Dictionary=__m2[\"Dictionary\"];\nconst __m3=__req(\"packages/core/src/store/multivalue.js\");\nconst MultiValue=__m3[\"MultiValue\"];\nconst __m4=__req(\"packages/core/src/store/stringrank.js\");\nconst StringRankIndex=__m4[\"StringRankIndex\"];\nconst REMOVED=0xFFFFFFFF;\nconst DEFAULT_CAPACITY=1024;\nconst DEFAULT_COLUMNAR_BELOW=5000;\nconst DEFAULT_COMPACT_RATIO=0.2;\nconst KINDS=new Set(['float64','int32','bitset','dictionary','object','multi']);\nfunction absent(v){return v===null||v===undefined;}\nfunction toFloat(v){\nif(typeof v==='number')return v;\nif(v instanceof Date)return v.getTime();\nif(typeof v==='boolean')return v?1:0;\nconst n=Number(v);\nreturn Number.isNaN(n)&&typeof v==='string'?Date.parse(v):n;\n}\nfunction toInt(v){\nconst n=toFloat(v);\nreturn Number.isFinite(n)?n|0:0;\n}\nfunction toMembers(v){\nif(absent(v))return[];\nreturn Array.isArray(v)?v:[v];\n}\nfunction decodeFrom(old,p){\nswitch(old.kind){\ncase'float64':\ncase'int32':return old.buf[p];\ncase'bitset':return old.bits.get(p)===1;\ncase'dictionary':return old.dict.valueOf(old.buf[p]);\ncase'multi':{\nconst codes=old.mv.at(p);\nconst out=new Array(codes.length);\nfor(let i=0;i<codes.length;i++)out[i]=old.dict.valueOf(codes[i]);\nreturn out;\n}\ndefault:return old.buf[p];\n}\n}\nfunction decodePacked(frag,i){\nswitch(frag.kind){\ncase'float64':\ncase'int32':return frag.values[i];\ncase'bitset':return(frag.values[i>>3]&(1<<(i&7)))!==0;\ncase'dictionary':return(frag.table||[])[frag.values[i]];\ncase'multi':{\nconst start=frag.offsets[i];\nconst end=frag.offsets[i+1];\nconst table=frag.table||[];\nconst out=new Array(end-start);\nfor(let k=start;k<end;k++)out[k-start]=table[frag.values[k]];\nreturn out;\n}\ndefault:return frag.values[i];\n}\n}\nclass ColumnHandle{\n#id;\n#kind;\n#target;\n#nullable;\n#read;\n#host;\n#seed;\n#columnar=false;\n#buf=null;\n#bits=null;\n#mv=null;\n#dict=null;\n#stringRank=null;\n#stringRankOn;\n#stringRankMax;\n#stringRankVersion=-1;\n#presence=null;\n#capacity=0;\n#version=0;\n#overlay=null;\n#cache=null;\n#released=false;\nconstructor(schema,host){\nthis.#id=schema.id;\nconst kind=KINDS.has(schema.kind)?schema.kind:'object';\nif(schema.kind&&!KINDS.has(schema.kind)){\nwarnOnce(`store.kind.${schema.id}`,\n`column \"${schema.id}\" declares unknown storage kind \"${schema.kind}\"; falling back to object`);\n}\nthis.#target=kind;\nthis.#kind=kind;\nthis.#nullable=schema.nullable!==false;\nthis.#seed=schema.dictionary??null;\nthis.#host=host;\nthis.#read=isFunction(schema.read)\n?schema.read\n:pathGetter(schema.field||schema.id);\nthis.#stringRankOn=schema.stringRankIndex!=='off';\nthis.#stringRankMax=typeof schema.stringRankMaxDistinct==='number'\n?schema.stringRankMaxDistinct\n:0;\nthis.#overlay=new Map();\n}\nget id(){return this.#id;}\nget kind(){return this.#columnar?this.#kind:'object';}\nget target(){return this.#target;}\nget nullable(){return this.#nullable;}\nget values(){\nif(this.#released)return null;\nif(!this.#columnar)return this.#lazy().values;\nif(this.#kind==='bitset')return this.#bits.words;\nif(this.#kind==='multi')return this.#mv.values;\nreturn this.#buf;\n}\nget presence(){\nif(this.#released||!this.#nullable)return null;\nreturn this.#columnar?this.#presence:this.#lazy().presence;\n}\nget dict(){\nif(this.#released||!this.#columnar)return null;\nreturn this.#kind==='dictionary'||this.#kind==='multi'?this.#dict:null;\n}\nget stringRank(){\nif(this.#released||!this.#stringRankOn)return null;\nif(this.kind!=='object')return null;\nconst values=this.values;\nconst n=this.#host.physical();\nif(!values||n===0)return null;\nif(this.#stringRank===null){\nif(typeof values[0]!=='string')return null;\nconst index=new StringRankIndex(this.#resolveStringRankMax());\nindex.build(values,n);\nindex.version=this.#version;\nthis.#stringRank=index;\nthis.#stringRankVersion=this.#version;\nreturn index.capped?null:index;\n}\nif(this.#stringRank.length<n){\nthis.#stringRank.append(values,this.#stringRank.length,n-this.#stringRank.length);\n}\nthis.#stringRank.version=this.#version;\nthis.#stringRankVersion=this.#version;\nreturn this.#stringRank.capped?null:this.#stringRank;\n}\n#resolveStringRankMax(){return this.#stringRankMax;}\n#dropStringRank(){\nthis.#stringRank=null;\nthis.#stringRankVersion=-1;\n}\nget offsets(){\nif(this.#released||!this.#columnar||this.#kind!=='multi')return null;\nreturn this.#mv.offsets;\n}\nget version(){return this.#version;}\nget bytes(){\nlet total=0;\nif(this.#buf)total+=this.#buf.byteLength??this.#buf.length*8;\nif(this.#bits)total+=this.#bits.bytes;\nif(this.#mv)total+=this.#mv.bytes;\nif(this.#presence)total+=this.#presence.bytes;\nif(this.#dict)total+=this.#dict.bytes;\nif(this.#overlay)total+=this.#overlay.size*24;\nreturn total;\n}\nget(physical){\nif(this.#released)return undefined;\nif(physical<0||physical>=this.#host.physical())return undefined;\nif(!this.#columnar)return this.#rowValue(physical);\nif(this.#nullable&&this.#presence.get(physical)===0)return null;\nswitch(this.#kind){\ncase'float64':\ncase'int32':return this.#buf[physical];\ncase'bitset':return this.#bits.get(physical)===1;\ncase'dictionary':return this.#dict.valueOf(this.#buf[physical]);\ncase'multi':{\nconst codes=this.#mv.at(physical);\nconst out=new Array(codes.length);\nfor(let i=0;i<codes.length;i++)out[i]=this.#dict.valueOf(codes[i]);\nreturn out;\n}\ndefault:return this.#buf[physical];\n}\n}\nset(physical,value){\nif(this.#released)return;\nif(this.#columnar)this.#writeValue(physical,value);\nelse this.#overlay.set(physical,value===undefined?null:value);\nif(this.#stringRank)this.#dropStringRank();\nthis.#version++;\n}\nread(row){return this.#read(row);}\nappendColumn(objects,from,n){\nif(this.#released||n<=0)return;\nif(!this.#columnar){this.#version++;return;}\nconst read=this.#read;\nconst nullable=this.#nullable;\nconst presence=this.#presence;\nlet sawAbsent=false;\nswitch(this.#kind){\ncase'float64':{\nconst buf=this.#buf;\nfor(let i=0;i<n;i++){\nconst v=read(objects[i]);\nif(typeof v==='number'){\nif(nullable)presence.set(from+i);\nbuf[from+i]=v;\ncontinue;\n}\nconst gone=v===null||v===undefined;\nif(nullable)presence.assign(from+i,!gone);\nelse if(gone)sawAbsent=true;\nbuf[from+i]=gone?NaN:toFloat(v);\n}\nbreak;\n}\ncase'int32':{\nconst buf=this.#buf;\nfor(let i=0;i<n;i++){\nconst v=read(objects[i]);\nconst gone=v===null||v===undefined;\nif(nullable)presence.assign(from+i,!gone);\nelse if(gone)sawAbsent=true;\nbuf[from+i]=gone?0:toInt(v);\n}\nbreak;\n}\ncase'bitset':{\nconst bits=this.#bits;\nfor(let i=0;i<n;i++){\nconst v=read(objects[i]);\nconst gone=v===null||v===undefined;\nif(nullable)presence.assign(from+i,!gone);\nelse if(gone)sawAbsent=true;\nbits.assign(from+i,!gone&&!!v);\n}\nbreak;\n}\ncase'dictionary':{\nconst buf=this.#buf;\nconst dict=this.#dict;\nfor(let i=0;i<n;i++){\nconst v=read(objects[i]);\nconst gone=v===null||v===undefined;\nif(nullable)presence.assign(from+i,!gone);\nelse if(gone)sawAbsent=true;\nbuf[from+i]=gone?0:dict.codeOf(v);\n}\nbreak;\n}\ncase'multi':{\nconst mv=this.#mv;\nconst dict=this.#dict;\nfor(let i=0;i<n;i++){\nconst v=read(objects[i]);\nconst gone=v===null||v===undefined;\nif(nullable)presence.assign(from+i,!gone);\nelse if(gone)sawAbsent=true;\nconst members=toMembers(v);\nconst codes=new Array(members.length);\nfor(let k=0;k<members.length;k++)codes[k]=dict.codeOf(members[k]);\nmv.write(from+i,codes);\n}\nbreak;\n}\ndefault:{\nconst buf=this.#buf;\nfor(let i=0;i<n;i++){\nconst v=read(objects[i]);\nconst gone=v===null||v===undefined;\nif(nullable)presence.assign(from+i,!gone);\nelse if(gone)sawAbsent=true;\nbuf[from+i]=gone?null:v;\n}\nbreak;\n}\n}\nif(sawAbsent){\nwarnOnce(`store.null.${this.#id}`,\n`column \"${this.#id}\" is declared non-nullable but received null; storing a filler value`);\n}\nif(this.#stringRank&&this.#kind==='object'){\nthis.#stringRank.append(this.#buf,from,n);\nthis.#stringRank.version=this.#version+1;\nthis.#stringRankVersion=this.#version+1;\n}\nthis.#version++;\n}\nappendPacked(frag,from,n){\nif(this.#released||n<=0||!frag)return;\nif(!this.#columnar){this.#version++;return;}\nconst presence=this.#presence;\nconst fragPresence=frag.presence;\nif(presence){\nif(fragPresence){\nfor(let i=0;i<n;i++)presence.assign(from+i,(fragPresence[i>>3]&(1<<(i&7)))!==0);\n}else{\nfor(let i=0;i<n;i++)presence.set(from+i);\n}\n}\nconst kindsAgree=frag.kind===this.#kind;\nif(kindsAgree&&(this.#kind==='float64'||this.#kind==='int32')){\nthis.#buf.set(frag.values,from);\nthis.#version++;\nreturn;\n}\nif(kindsAgree&&this.#kind==='bitset'){\nconst words=frag.values;\nfor(let i=0;i<n;i++)this.#bits.assign(from+i,(words[i>>3]&(1<<(i&7)))!==0);\nthis.#version++;\nreturn;\n}\nif(kindsAgree&&this.#kind==='dictionary'){\nconst table=frag.table||[];\nconst remap=new Uint32Array(table.length);\nfor(let t=0;t<table.length;t++)remap[t]=this.#dict.codeOf(table[t]);\nconst codes=frag.values;\nconst buf=this.#buf;\nconst pres=presence;\nfor(let i=0;i<n;i++){\nif(pres&&(fragPresence?(fragPresence[i>>3]&(1<<(i&7)))===0:false)){buf[from+i]=0;continue;}\nbuf[from+i]=remap[codes[i]]??0;\n}\nthis.#version++;\nreturn;\n}\nif(kindsAgree&&this.#kind==='multi'){\nconst table=frag.table||[];\nconst remap=new Uint32Array(table.length);\nfor(let t=0;t<table.length;t++)remap[t]=this.#dict.codeOf(table[t]);\nconst flat=frag.values;\nconst offsets=frag.offsets;\nfor(let i=0;i<n;i++){\nconst start=offsets[i];\nconst end=offsets[i+1];\nconst codes=new Array(end-start);\nfor(let k=start;k<end;k++)codes[k-start]=remap[flat[k]]??0;\nthis.#mv.write(from+i,codes);\n}\nthis.#version++;\nreturn;\n}\nfor(let i=0;i<n;i++){\nconst gone=fragPresence\n?(fragPresence[i>>3]&(1<<(i&7)))===0\n:(frag.kind==='object'?frag.values[i]===null:false);\nthis.#writeValue(from+i,gone?null:decodePacked(frag,i));\n}\nthis.#version++;\n}\ntouch(){this.#version++;}\ncolumnarise(capacity,fill){\nif(this.#columnar||this.#released)return;\nconst values=new Array(fill);\nfor(let p=0;p<fill;p++)values[p]=this.#rowValue(p);\nthis.#kind=this.#target;\nthis.#columnar=true;\nthis.#alloc(capacity);\nfor(let p=0;p<fill;p++)this.#writeValue(p,values[p]);\nthis.#overlay.clear();\nthis.#cache=null;\nthis.#dropStringRank();\nthis.#version++;\n}\ngrow(capacity){\nif(!this.#columnar||this.#released||capacity<=this.#capacity)return;\nswitch(this.#kind){\ncase'float64':case'int32':case'dictionary':{\nconst next=new this.#buf.constructor(capacity);\nnext.set(this.#buf);\nthis.#buf=next;\nbreak;\n}\ncase'bitset':this.#bits.grow(capacity);break;\ncase'multi':break;\ndefault:this.#buf.length=capacity;break;\n}\nif(this.#presence)this.#presence.grow(capacity);\nthis.#capacity=capacity;\nthis.#version++;\n}\nconvert(kind){\nif(this.#released||!KINDS.has(kind))return false;\nthis.#target=kind;\nif(!this.#columnar||kind===this.#kind)return false;\nconst old={kind:this.#kind,buf:this.#buf,bits:this.#bits,mv:this.#mv,dict:this.#dict};\nconst n=this.#host.physical();\nconst presence=this.#presence;\nthis.#kind=kind;\nthis.#alloc(this.#capacity);\nfor(let p=0;p<n;p++){\nconst gone=presence!==null&&presence.get(p)===0;\nif(gone&&kind!=='multi')continue;\nthis.#writeValue(p,gone?null:decodeFrom(old,p));\n}\nthis.#dropStringRank();\nthis.#version++;\nreturn true;\n}\ncompact(remap,oldFill,liveCount){\nif(this.#released)return;\nthis.#dropStringRank();\nif(!this.#columnar){\nconst overlay=this.#overlay;\nif(overlay.size){\nconst next=new Map();\nfor(const[p,v]of overlay)if(remap[p]!==REMOVED)next.set(remap[p],v);\nthis.#overlay=next;\n}\nthis.#cache=null;\nthis.#version++;\nreturn;\n}\nswitch(this.#kind){\ncase'float64':case'int32':case'dictionary':case'object':{\nconst buf=this.#buf;\nfor(let p=0;p<oldFill;p++)if(remap[p]!==REMOVED)buf[remap[p]]=buf[p];\nif(this.#kind==='object')for(let p=liveCount;p<oldFill;p++)buf[p]=undefined;\nbreak;\n}\ncase'bitset':{\nconst bits=this.#bits;\nfor(let p=0;p<oldFill;p++)if(remap[p]!==REMOVED)bits.assign(remap[p],bits.get(p)===1);\nfor(let p=liveCount;p<oldFill;p++)bits.clear(p);\nbreak;\n}\ncase'multi':this.#mv.compact(remap,liveCount,REMOVED);break;\ndefault:break;\n}\nif(this.#presence){\nconst pres=this.#presence;\nfor(let p=0;p<oldFill;p++)if(remap[p]!==REMOVED)pres.assign(remap[p],pres.get(p)===1);\nfor(let p=liveCount;p<oldFill;p++)pres.clear(p);\n}\nthis.#version++;\n}\nrelease(){\nif(this.#released)return;\nthis.#released=true;\nthis.#buf=null;\nif(this.#bits)this.#bits.release();\nthis.#bits=null;\nif(this.#mv)this.#mv.release();\nthis.#mv=null;\nif(this.#presence)this.#presence.release();\nthis.#presence=null;\nthis.#dict=null;\nthis.#stringRank=null;\nthis.#overlay=new Map();\nthis.#cache=null;\nthis.#capacity=0;\nthis.#version++;\n}\n#alloc(capacity){\nconst cap=Math.max(1,capacity);\nthis.#buf=null;\nthis.#bits=null;\nthis.#mv=null;\nswitch(this.#kind){\ncase'float64':this.#buf=new Float64Array(cap);break;\ncase'int32':this.#buf=new Int32Array(cap);break;\ncase'bitset':this.#bits=new Bitset(cap);break;\ncase'dictionary':\nthis.#buf=new Uint32Array(cap);\nthis.#dict=this.#dict??new Dictionary(this.#seed??[]);\nbreak;\ncase'multi':\nthis.#mv=new MultiValue({rows:cap,values:cap});\nthis.#dict=this.#dict??new Dictionary(this.#seed??[]);\nbreak;\ndefault:this.#buf=new Array(cap);break;\n}\nif(this.#kind!=='dictionary'&&this.#kind!=='multi')this.#dict=null;\nif(this.#nullable){\nif(this.#presence)this.#presence.grow(cap);\nelse this.#presence=new Bitset(cap);\n}\nthis.#capacity=cap;\n}\n#writeValue(p,value){\nconst gone=absent(value);\nif(this.#nullable)this.#presence.assign(p,!gone);\nelse if(gone){\nwarnOnce(`store.null.${this.#id}`,\n`column \"${this.#id}\" is declared non-nullable but received null; storing a filler value`);\n}\nswitch(this.#kind){\ncase'float64':this.#buf[p]=gone?NaN:toFloat(value);break;\ncase'int32':this.#buf[p]=gone?0:toInt(value);break;\ncase'bitset':this.#bits.assign(p,!gone&&!!value);break;\ncase'dictionary':this.#buf[p]=gone?0:this.#dict.codeOf(value);break;\ncase'multi':{\nconst members=toMembers(value);\nconst codes=new Array(members.length);\nfor(let i=0;i<members.length;i++)codes[i]=this.#dict.codeOf(members[i]);\nthis.#mv.write(p,codes);\nbreak;\n}\ndefault:this.#buf[p]=gone?null:value;break;\n}\n}\n#rowValue(p){\nif(this.#overlay.has(p))return this.#overlay.get(p);\nconst v=this.#read(this.#host.rowAt(p));\nreturn v===undefined?null:v;\n}\n#lazy(){\nif(this.#cache&&this.#cache.version===this.#version)return this.#cache;\nconst n=this.#host.physical();\nconst values=new Array(n);\nconst presence=this.#nullable?new Bitset(n):null;\nfor(let p=0;p<n;p++){\nconst v=this.#rowValue(p);\nvalues[p]=v;\nif(presence&&!absent(v))presence.set(p);\n}\nthis.#cache={version:this.#version,values,presence};\nreturn this.#cache;\n}\n}\nclass ColumnStore{\n#schema;\n#handles=new Map();\n#list=[];\n#rows=[];\n#fill=0;\n#capacity=0;\n#live=0;\n#dead=0;\n#tombs=new Bitset(0);\n#columnar=false;\n#retainSource=true;\n#columnarBelow;\n#initial;\n#ratio;\n#destroyed=false;\nconstructor(schema,opts={}){\nthis.#schema=Array.isArray(schema)?schema:[];\nthis.#initial=Math.max(1,opts.initialCapacity??DEFAULT_CAPACITY);\nthis.#retainSource=opts.retainSource!==false;\nthis.#columnarBelow=this.#retainSource?(opts.columnarBelow??DEFAULT_COLUMNAR_BELOW):0;\nthis.#ratio=opts.compactRatio??DEFAULT_COMPACT_RATIO;\nconst host={\nrowAt:(p)=>this.#rows[p],\nphysical:()=>this.#fill,\n};\nfor(const entry of this.#schema){\nif(!entry||!entry.id)continue;\nif(this.#handles.has(entry.id)){\nwarnOnce(`store.dup.${entry.id}`,`duplicate column id \"${entry.id}\" in the store schema; ignoring the second`);\ncontinue;\n}\nconst handle=new ColumnHandle(entry,host);\nthis.#handles.set(entry.id,handle);\nthis.#list.push(handle);\n}\nif(this.#columnarBelow<=0)this.#columnarise();\n}\nget count(){return this.#live;}\nget physical(){return this.#fill;}\nget capacity(){return this.#columnar?this.#capacity:this.#rows.length;}\nget tombstones(){return this.#dead;}\nget columnar(){return this.#columnar;}\nget destroyed(){return this.#destroyed;}\nget bytes(){\nlet total=this.#tombs.bytes+this.#rows.length*8;\nfor(const h of this.#list)total+=h.bytes;\nreturn total;\n}\nappend(objects){\nconst from=this.#fill;\nif(this.#destroyed||!objects)return{from,to:from};\nconst n=objects.length|0;\nif(n===0)return{from,to:from};\nif(this.#retainSource)for(let i=0;i<n;i++)this.#rows[from+i]=objects[i];\nthis.#fill=from+n;\nthis.#live+=n;\nthis.#tombs.grow(this.#fill);\nif(!this.#columnar){\nif(this.#fill>=this.#columnarBelow)this.#columnarise();\nelse for(const h of this.#list)h.touch();\nreturn{from,to:this.#fill};\n}\nthis.#ensure(this.#fill);\nconst cols=this.#list;\nfor(let c=0;c<cols.length;c++)cols[c].appendColumn(objects,from,n);\nreturn{from,to:this.#fill};\n}\nappendPacked(chunk,objects){\nconst from=this.#fill;\nif(this.#destroyed||!chunk)return{from,to:from};\nconst n=chunk.count|0;\nif(n===0)return{from,to:from};\nif(this.#retainSource&&objects){\nfor(let i=0;i<n;i++)this.#rows[from+i]=objects[i];\n}\nthis.#fill=from+n;\nthis.#live+=n;\nthis.#tombs.grow(this.#fill);\nif(!this.#columnar)this.#columnarise();\nthis.#ensure(this.#fill);\nconst byId=new Map();\nfor(const col of chunk.columns)byId.set(col.id,col);\nfor(const h of this.#list){\nconst frag=byId.get(h.id);\nif(frag)h.appendPacked(frag,from,n);\nelse{\nh.grow(this.#capacity);\n}\n}\nreturn{from,to:this.#fill};\n}\nsource(physical){\nif(this.#retainSource)return this.#rows[physical];\nif(physical<0||physical>=this.#fill)return undefined;\nreturn this.#reconstruct(physical);\n}\nsetSource(physical,object){\nif(this.#destroyed)return;\nif(physical<0||physical>=this.#fill)return;\nif(!this.#retainSource)return;\nthis.#rows[physical]=object;\n}\nget(colId,physical){\nconst h=this.#handles.get(colId);\nreturn h?h.get(physical):undefined;\n}\nset(colId,physical,value){\nif(this.#destroyed)return;\nif(physical<0||physical>=this.#fill)return;\nconst h=this.#handles.get(colId);\nif(!h){\nwarnOnce(`store.set.${colId}`,`set() on unknown column \"${colId}\"`);\nreturn;\n}\nh.set(physical,value);\n}\nremove(physical){\nif(this.#destroyed||physical<0||physical>=this.#fill)return false;\nif(this.#tombs.get(physical)===1)return false;\nthis.#tombs.set(physical);\nthis.#dead++;\nthis.#live--;\nreturn true;\n}\nlive(physical){\nif(physical<0||physical>=this.#fill)return false;\nreturn this.#tombs.get(physical)===0;\n}\ncompact(opts={}){\nif(this.#destroyed||this.#dead===0)return null;\nif(!opts.force&&this.#dead/this.#fill<this.#ratio)return null;\nconst oldFill=this.#fill;\nconst remap=new Uint32Array(oldFill);\nlet w=0;\nfor(let p=0;p<oldFill;p++)remap[p]=this.#tombs.get(p)===1?REMOVED:w++;\nfor(const h of this.#list)h.compact(remap,oldFill,w);\nif(this.#retainSource){\nconst rows=this.#rows;\nfor(let p=0;p<oldFill;p++)if(remap[p]!==REMOVED)rows[remap[p]]=rows[p];\nrows.length=w;\n}\nthis.#fill=w;\nthis.#live=w;\nthis.#dead=0;\nthis.#tombs=new Bitset(Math.max(this.#capacity,w));\nreturn remap;\n}\ncolumn(colId){return this.#handles.get(colId);}\ncolumns(){return this.#list.slice();}\nliveIndices(){\nconst out=new Uint32Array(this.#live);\nif(this.#dead===0){\nfor(let p=0;p<this.#fill;p++)out[p]=p;\nreturn out;\n}\nlet k=0;\nfor(let p=0;p<this.#fill;p++)if(this.#tombs.get(p)===0)out[k++]=p;\nreturn out;\n}\nconvert(colId,kind){\nconst h=this.#handles.get(colId);\nreturn h?h.convert(kind):false;\n}\ndestroy(){\nif(this.#destroyed)return;\nthis.#destroyed=true;\nfor(const h of this.#list)h.release();\nthis.#handles.clear();\nthis.#list.length=0;\nthis.#rows.length=0;\nthis.#tombs.release();\nthis.#fill=0;\nthis.#live=0;\nthis.#dead=0;\nthis.#capacity=0;\n}\n#ensure(n){\nif(n<=this.#capacity)return;\nlet cap=this.#capacity||this.#initial;\nwhile(cap<n)cap*=2;\nfor(const h of this.#list)h.grow(cap);\nthis.#tombs.grow(cap);\nthis.#capacity=cap;\n}\n#reconstruct(physical){\nconst out={};\nfor(const h of this.#list)out[h.id]=h.get(physical);\nreturn out;\n}\n#columnarise(){\nif(this.#columnar)return;\nlet cap=this.#initial;\nwhile(cap<this.#fill)cap*=2;\nthis.#columnar=true;\nthis.#capacity=cap;\nthis.#tombs.grow(cap);\nfor(const h of this.#list)h.columnarise(cap,this.#fill);\n}\n}\n});\n__def(\"packages/core/src/store/ingest.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"INGEST_DEFAULTS\",{enumerable:true,get:function(){return INGEST_DEFAULTS;}});\nObject.defineProperty(__exports,\"inferKind\",{enumerable:true,get:function(){return inferKind;}});\nObject.defineProperty(__exports,\"decideText\",{enumerable:true,get:function(){return decideText;}});\nObject.defineProperty(__exports,\"createReaders\",{enumerable:true,get:function(){return createReaders;}});\nObject.defineProperty(__exports,\"Ingest\",{enumerable:true,get:function(){return Ingest;}});\nObject.defineProperty(__exports,\"ingest\",{enumerable:true,get:function(){return ingest;}});\nObject.defineProperty(__exports,\"ingestSync\",{enumerable:true,get:function(){return ingestSync;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst now=__m0[\"now\"];\nconst nextFrame=__m0[\"nextFrame\"];\nconst infoOnce=__m0[\"infoOnce\"];\nconst warnOnce=__m0[\"warnOnce\"];\nconst isFunction=__m0[\"isFunction\"];\nconst pathGetter=__m0[\"pathGetter\"];\nconst __m1=__req(\"packages/core/src/store/columnstore.js\");\nconst ColumnStore=__m1[\"ColumnStore\"];\nconst INGEST_DEFAULTS=Object.freeze({\nchunkMs:8,\nchunkRows:512,\nsampleSize:100,\ndictionaryRatio:0.1,\ncolumnarBelow:5000,\ninitialCapacity:1024,\n});\nfunction inferKind(samples,hints={}){\nif(hints.multi)return'multi';\nif(samples.length===0)return'object';\nlet numbers=0;let booleans=0;let strings=0;let dates=0;let arrays=0;\nfor(let i=0;i<samples.length;i++){\nconst v=samples[i];\nif(typeof v==='number')numbers++;\nelse if(typeof v==='boolean')booleans++;\nelse if(typeof v==='string')strings++;\nelse if(v instanceof Date)dates++;\nelse if(Array.isArray(v))arrays++;\n}\nconst n=samples.length;\nif(numbers===n)return'float64';\nif(booleans===n)return'bitset';\nif(dates===n)return'float64';\nif(strings===n)return'text';\nif(arrays===n)return'multi';\nreturn'object';\n}\nfunction decideText(distinct,rows,ratio){\nif(rows<=0)return'dictionary';\nreturn distinct<ratio*rows?'dictionary':'object';\n}\nfunction createReaders(columns,computed,context){\nconst readers=new Map();\nconst base=new Map();\nfor(const col of columns){\nif(col.computed)continue;\nconst read=isFunction(col.read)?col.read:pathGetter(col.field||col.id);\nbase.set(col.id,read);\nreaders.set(col.id,read);\n}\nconst order=computed?.order??[];\nconst fns=computed?.fns??{};\nconst deps=computed?.deps??{};\nconst wrapDeps=computed?.wrapDeps??null;\nconst active=order.filter((id)=>isFunction(fns[id]));\nconst wildcard=active.some((id)=>deps[id]==='*');\nlet memo=new WeakMap();\nconst resolve=(data)=>{\nconst values={};\nif(wildcard)for(const[id,read]of base)values[id]=read(data);\nfor(const id of active){\nconst declared=deps[id];\nlet bag;\nif(declared==='*'){\nbag=values;\n}else{\nbag={};\nconst list=declared||[];\nfor(let i=0;i<list.length;i++){\nconst d=list[i];\nbag[d]=d in values?values[d]:base.get(d)?.(data);\n}\n}\nvalues[id]=fns[id](wrapDeps?wrapDeps(bag,id):bag,{\ndata,row:null,column:null,grid:null,context,\n});\n}\nreturn values;\n};\nconst valuesFor=(data)=>{\nif(data===null||(typeof data!=='object'&&typeof data!=='function'))return resolve(data);\nlet v=memo.get(data);\nif(v===undefined){v=resolve(data);memo.set(data,v);}\nreturn v;\n};\nfor(const id of active){\nreaders.set(id,\n(data)=>valuesFor(data)[id]);\n}\nreturn{\nreaders,\nreset(){memo=new WeakMap();},\n};\n}\nclass ColumnPlan{\nspec;\nread;\nkind;\ninferred;\nnullable;\ncandidate=false;\ndistinct=null;\nchange=null;\nreason='';\nconstructor(spec,read){\nthis.spec=spec;\nthis.read=read;\nthis.kind='object';\nthis.inferred=false;\nthis.nullable=spec.nullable!==false;\n}\n}\nclass Ingest{\n#rows;\n#plans=[];\n#store=null;\n#readers;\n#cursor=0;\n#opts;\n#done=false;\n#cancelled=false;\n#elapsed=0;\n#columnar;\nconstructor(rows,plan={},opts={}){\nthis.#rows=Array.isArray(rows)?rows:Array.from(rows||[]);\nthis.#opts={...INGEST_DEFAULTS,...opts};\nconst columns=plan.columns??[];\nthis.#readers=createReaders(columns,plan.computed??null,plan.context);\nthis.#columnar=this.#rows.length>=this.#opts.columnarBelow;\nthis.#planColumns(columns,plan.computed??null);\nthis.#store=new ColumnStore(this.#plans.map((p)=>({\nid:p.spec.id,\nkind:p.kind,\nnullable:p.nullable,\nread:p.read,\ndictionary:p.spec.dictionary,\n})),{\ninitialCapacity:this.#opts.initialCapacity,\ncolumnarBelow:this.#opts.columnarBelow,\n});\n}\nget store(){return this.#store;}\nget done(){return this.#done||this.#cancelled;}\nget progress(){return this.#cursor;}\nslice(){\nif(this.done)return false;\nif(this.#opts.signal?.aborted){this.#cancelled=true;return false;}\nconst started=now();\nconst{chunkMs,chunkRows}=this.#opts;\nconst total=this.#rows.length;\ndo{\nconst end=Math.min(this.#cursor+chunkRows,total);\nthis.#store.append(this.#rows.slice(this.#cursor,end));\nthis.#measure(this.#cursor,end);\nthis.#cursor=end;\nthis.#readers.reset();\nthis.#reviewCardinality(false);\n}while(this.#cursor<total&&now()-started<chunkMs);\nthis.#elapsed+=now()-started;\nthis.#opts.onProgress?.({loaded:this.#cursor,total});\nif(this.#cursor>=total){\nthis.#reviewCardinality(true);\nthis.#done=true;\nreturn false;\n}\nreturn true;\n}\ncancel(){this.#cancelled=true;}\nresult(){\nreturn{\nstore:this.#store,\nschema:this.#plans.map((p)=>({\nid:p.spec.id,kind:p.kind,nullable:p.nullable,read:p.read,\ndictionary:p.spec.dictionary,\n})),\ndecisions:this.#plans.map((p)=>({\nid:p.spec.id,\nkind:p.kind,\nnullable:p.nullable,\ninferred:p.inferred,\ndistinct:p.candidate||p.change?this.#distinctOf(p):null,\nchange:p.change,\nreason:p.reason,\n})),\ncount:this.#store.count,\nelapsed:this.#elapsed,\ncancelled:this.#cancelled,\n};\n}\n#planColumns(columns,computed){\nconst rows=this.#rows;\nconst sampleN=Math.min(this.#opts.sampleSize,rows.length);\nconst ratio=this.#opts.dictionaryRatio;\nconst pure=computed?.pure instanceof Set\n?computed.pure\n:new Set(computed?.pure??computed?.order??[]);\nfor(const spec of columns){\nif(!spec||!spec.id)continue;\nif(spec.computed&&(spec.pure===false||(computed&&!pure.has(spec.id)))){\nwarnOnce(`ingest.impure.${spec.id}`,\n`column \"${spec.id}\" is an impure computed column and is not materialised into the store`);\ncontinue;\n}\nconst read=this.#readers.readers.get(spec.id)\n??(isFunction(spec.read)?spec.read:pathGetter(spec.field||spec.id));\nconst plan=new ColumnPlan(spec,read);\nif(spec.kind){\nplan.kind=spec.kind;\nplan.reason='declared by the caller';\n}else if(spec.dictionary){\nplan.kind=spec.multi?'multi':'dictionary';\nplan.reason='value table supplied (lookup column)';\n}else{\nconst samples=[];\nfor(let i=0;i<sampleN&&samples.length<this.#opts.sampleSize;i++){\nconst v=read(rows[i]);\nif(v!==null&&v!==undefined)samples.push(v);\n}\nplan.inferred=true;\nconst kind=inferKind(samples,{multi:spec.multi});\nif(kind==='text'){\nconst distinct=new Set(samples).size;\nplan.kind=decideText(distinct,samples.length,ratio);\nplan.candidate=this.#columnar;\nplan.reason=`sampled ${distinct} distinct in ${samples.length}`;\n}else{\nplan.kind=kind;\nplan.reason=`inferred from ${samples.length} sampled values`;\nif(kind==='object'&&samples.length){\ninfoOnce(`ingest.mixed.${spec.id}`,\n`column \"${spec.id}\" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);\n}\n}\nif(plan.kind==='object'&&plan.candidate)plan.distinct=new Set(samples);\n}\nthis.#plans.push(plan);\n}\n}\n#measure(from,to){\nconst rows=this.#rows;\nfor(const plan of this.#plans){\nif(!plan.candidate||!plan.distinct)continue;\nconst set=plan.distinct;\nfor(let i=from;i<to;i++){\nconst v=plan.read(rows[i]);\nif(v!==null&&v!==undefined)set.add(v);\n}\n}\n}\n#distinctOf(plan){\nif(plan.distinct)return plan.distinct.size;\nconst handle=this.#store.column(plan.spec.id);\nreturn handle?.dict?handle.dict.size:0;\n}\n#reviewCardinality(final){\nconst ratio=this.#opts.dictionaryRatio;\nconst total=this.#rows.length;\nfor(const plan of this.#plans){\nif(!plan.candidate)continue;\nconst distinct=this.#distinctOf(plan);\nif(plan.kind==='dictionary'&&distinct>=ratio*total){\nconst handle=this.#store.column(plan.spec.id);\nplan.distinct=new Set(handle?.dict?handle.dict.values():[]);\nthis.#store.convert(plan.spec.id,'object');\nplan.kind='object';\nplan.change='demoted';\nplan.reason=`${distinct} distinct values is at or above ${ratio*100}% of ${total} rows`;\ncontinue;\n}\nif(plan.kind==='object'&&distinct>=ratio*total){\nplan.candidate=false;\nplan.distinct=null;\nplan.reason=`${distinct} distinct values is at or above ${ratio*100}% of ${total} rows`;\ncontinue;\n}\nif(final&&plan.kind==='object'&&distinct<ratio*total){\nthis.#store.convert(plan.spec.id,'dictionary');\nplan.kind='dictionary';\nplan.change=plan.change==='demoted'?null:'promoted';\nplan.reason=`${distinct} distinct values is below ${ratio*100}% of ${total} rows`;\nplan.distinct=null;\n}\nif(final)plan.candidate=false;\n}\n}\n}\nasync function ingest(rows,plan={},opts={}){\nconst run=new Ingest(rows,plan,opts);\nconst frame=opts.scheduler?.frame??nextFrame;\nwhile(run.slice()){\nawait new Promise((resolve)=>{frame(resolve);});\n}\nreturn run.result();\n}\nfunction ingestSync(rows,plan={},opts={}){\nconst run=new Ingest(rows,plan,{...opts,chunkMs:Infinity});\nwhile(run.slice());\nreturn run.result();\n}\n});\n__def(\"packages/core/src/store/columnpack.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"isPortableSchema\",{enumerable:true,get:function(){return isPortableSchema;}});\nObject.defineProperty(__exports,\"packChunk\",{enumerable:true,get:function(){return packChunk;}});\nObject.defineProperty(__exports,\"packedTransfers\",{enumerable:true,get:function(){return packedTransfers;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst pathGetter=__m0[\"pathGetter\"];\nconst __m1=__req(\"packages/core/src/store/ingest.js\");\nconst inferKind=__m1[\"inferKind\"];\nconst decideText=__m1[\"decideText\"];\nconst INGEST_DEFAULTS=__m1[\"INGEST_DEFAULTS\"];\nconst __m2=__req(\"packages/core/src/store/columnstore.js\");\nconst toFloat=__m2[\"toFloat\"];\nconst PORTABLE_KINDS=new Set(['float64','int32','bitset','dictionary','object','multi']);\nfunction isPortableSchema(schema){\nif(!Array.isArray(schema)||schema.length===0)return false;\nfor(const col of schema){\nif(!col||typeof col.id!=='string')return false;\nif(typeof col.field!=='string'||col.field==='')return false;\nif(col.kind&&!PORTABLE_KINDS.has(col.kind))return false;\n}\nreturn true;\n}\nfunction toInt(v){\nconst n=toFloat(v);\nreturn Number.isFinite(n)?n|0:0;\n}\nfunction toMembers(v){\nif(v===null||v===undefined)return[];\nreturn Array.isArray(v)?v:[v];\n}\nfunction resolveKind(col,values,rows,ratio){\nif(col.kind)return col.kind;\nconst samples=[];\nfor(let i=0;i<values.length&&samples.length<INGEST_DEFAULTS.sampleSize;i++){\nconst v=values[i];\nif(v!==null&&v!==undefined)samples.push(v);\n}\nconst kind=inferKind(samples,{multi:col.multi});\nif(kind!=='text')return kind;\nconst distinct=new Set(samples).size;\nreturn decideText(distinct,samples.length,ratio);\n}\nfunction packChunk(schema,rows,opts={}){\nconst n=rows.length|0;\nconst ratio=opts.dictionaryRatio??INGEST_DEFAULTS.dictionaryRatio;\nconst columns=[];\nfor(const col of schema){\nconst read=pathGetter(col.field||col.id);\nconst nullable=col.nullable!==false;\nconst raw=new Array(n);\nfor(let i=0;i<n;i++){\nconst v=read(rows[i]);\nraw[i]=v===undefined?null:v;\n}\nconst kind=resolveKind(col,raw,n,ratio);\nconst presence=nullable?new Uint8Array((n+7)>>3):null;\nconst present=(i)=>{if(presence)presence[i>>3]|=1<<(i&7);};\nlet packed;\nswitch(kind){\ncase'float64':{\nconst values=new Float64Array(n);\nfor(let i=0;i<n;i++){\nconst v=raw[i];\nconst gone=v===null;\nif(!gone)present(i);\nvalues[i]=gone?NaN:toFloat(v);\n}\npacked={id:col.id,kind,nullable,values,presence,offsets:null,table:null};\nbreak;\n}\ncase'int32':{\nconst values=new Int32Array(n);\nfor(let i=0;i<n;i++){\nconst v=raw[i];\nconst gone=v===null;\nif(!gone)present(i);\nvalues[i]=gone?0:toInt(v);\n}\npacked={id:col.id,kind,nullable,values,presence,offsets:null,table:null};\nbreak;\n}\ncase'bitset':{\nconst words=new Uint8Array((n+7)>>3);\nfor(let i=0;i<n;i++){\nconst v=raw[i];\nconst gone=v===null;\nif(!gone)present(i);\nif(!gone&&!!v)words[i>>3]|=1<<(i&7);\n}\npacked={id:col.id,kind,nullable,values:words,presence,offsets:null,table:null};\nbreak;\n}\ncase'dictionary':{\nconst codes=new Uint32Array(n);\nconst table=[];\nconst index=new Map();\nfor(let i=0;i<n;i++){\nconst v=raw[i];\nif(v===null){codes[i]=0;continue;}\npresent(i);\nlet code=index.get(v);\nif(code===undefined){code=table.length;table.push(v);index.set(v,code);}\ncodes[i]=code;\n}\npacked={id:col.id,kind,nullable,values:codes,presence,offsets:null,table};\nbreak;\n}\ncase'multi':{\nconst table=[];\nconst index=new Map();\nconst offsets=new Uint32Array(n+1);\nconst flat=[];\nfor(let i=0;i<n;i++){\nconst v=raw[i];\noffsets[i]=flat.length;\nconst gone=v===null;\nif(!gone)present(i);\nconst members=toMembers(v);\nfor(let k=0;k<members.length;k++){\nconst m=members[k];\nlet code=index.get(m);\nif(code===undefined){code=table.length;table.push(m);index.set(m,code);}\nflat.push(code);\n}\n}\noffsets[n]=flat.length;\npacked={id:col.id,kind,nullable,values:Int32Array.from(flat),presence,offsets,table};\nbreak;\n}\ndefault:{\nconst values=new Array(n);\nfor(let i=0;i<n;i++){\nconst v=raw[i];\nif(v!==null)present(i);\nvalues[i]=v;\n}\npacked={id:col.id,kind:'object',nullable,values,presence,offsets:null,table:null};\nbreak;\n}\n}\ncolumns.push(packed);\n}\nreturn{count:n,columns};\n}\nfunction packedTransfers(chunk){\nconst out=[];\nif(!chunk||!Array.isArray(chunk.columns))return out;\nconst add=(v)=>{\nif(ArrayBuffer.isView(v)&&v.buffer&&!out.includes(v.buffer))out.push(v.buffer);\n};\nfor(const col of chunk.columns){\nadd(col.values);\nadd(col.presence);\nadd(col.offsets);\n}\nreturn out;\n}\n});\n__def(\"packages/core/src/compute/sortspec.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"collationDescriptor\",{enumerable:true,get:function(){return collationDescriptor;}});\nObject.defineProperty(__exports,\"isPortableSort\",{enumerable:true,get:function(){return isPortableSort;}});\nObject.defineProperty(__exports,\"isPortableSortSet\",{enumerable:true,get:function(){return isPortableSortSet;}});\nObject.defineProperty(__exports,\"describeSortEntry\",{enumerable:true,get:function(){return describeSortEntry;}});\nObject.defineProperty(__exports,\"describeSort\",{enumerable:true,get:function(){return describeSort;}});\nfunction collationDescriptor(locale){\nreturn{locale:locale===undefined?undefined:String(locale),numeric:true,sensitivity:'variant'};\n}\nfunction isPortableSort(entry){\nreturn!!entry&&typeof entry.compare!=='function';\n}\nfunction isPortableSortSet(entries){\nif(!entries)return true;\nfor(let i=0;i<entries.length;i++)if(!isPortableSort(entries[i]))return false;\nreturn true;\n}\nfunction describeSortEntry(entry,locale){\nconst col=entry.col!==undefined?entry.col:(entry.handle&&entry.handle.id);\nconst chosen=entry.locale!==undefined?entry.locale:locale;\nreturn{\ncol,\ndescending:entry.descending!==undefined?!!entry.descending:entry.dir==='desc',\nnullsFirst:!!entry.nullsFirst,\ncollation:collationDescriptor(chosen),\n};\n}\nfunction describeSort(entries,locale){\nconst list=entries||[];\nconst out=new Array(list.length);\nfor(let i=0;i<list.length;i++)out[i]=describeSortEntry(list[i],locale);\nreturn out;\n}\n});\n__def(\"packages/core/src/format/date.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"scanPattern\",{enumerable:true,get:function(){return scanPattern;}});\nObject.defineProperty(__exports,\"toDate\",{enumerable:true,get:function(){return toDate;}});\nObject.defineProperty(__exports,\"compilePattern\",{enumerable:true,get:function(){return compilePattern;}});\nObject.defineProperty(__exports,\"compileDate\",{enumerable:true,get:function(){return compileDate;}});\nObject.defineProperty(__exports,\"toIsoDate\",{enumerable:true,get:function(){return toIsoDate;}});\nObject.defineProperty(__exports,\"toIsoDateTime\",{enumerable:true,get:function(){return toIsoDateTime;}});\nObject.defineProperty(__exports,\"compareIso\",{enumerable:true,get:function(){return compareIso;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst isNil=__m0[\"isNil\"];\nconst warnOnce=__m0[\"warnOnce\"];\nconst TOKENS=[\n'yyyy','yy','MMMM','MMM','MM','M','dd','d',\n'EEEE','EEE','HH','H','hh','h','mm','m','ss','s','SSS','a',\n];\nfunction scanPattern(pattern){\nconst out=[];\nlet i=0;\nlet literal='';\nconst flush=()=>{if(literal){out.push({token:null,text:literal});literal='';}};\nwhile(i<pattern.length){\nconst ch=pattern[i];\nif(ch===\"'\"){\nif(pattern[i+1]===\"'\"){literal+=\"'\";i+=2;continue;}\nconst end=pattern.indexOf(\"'\",i+1);\nif(end===-1){literal+=pattern.slice(i+1);i=pattern.length;continue;}\nliteral+=pattern.slice(i+1,end);\ni=end+1;\ncontinue;\n}\nconst token=TOKENS.find((t)=>pattern.startsWith(t,i));\nif(token){flush();out.push({token,text:token});i+=token.length;continue;}\nif(/[A-Za-z]/.test(ch)){\nwarnOnce(\n`date.pattern.token:${ch}`,\n`the date pattern \"${pattern}\" contains '${ch}', which is not a supported token, `\n+'so it is rendered as text. Quote it as a literal to silence this. '\n+`Supported: ${TOKENS.join(' ')}.`,\n);\n}\nliteral+=ch;\ni+=1;\n}\nflush();\nreturn out;\n}\nconst WALL_CLOCK=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;\nfunction toDate(value){\nif(isNil(value)||value==='')return null;\nif(value instanceof Date)return Number.isNaN(value.getTime())?null:value;\nif(typeof value==='number')return Number.isNaN(value)?null:new Date(value);\nif(typeof value==='string'){\nconst wall=WALL_CLOCK.exec(value.trim());\nif(wall){\nconst[,y,mo,d,h='0',mi='0',sec='0']=wall;\nreturn new Date(+y,+mo-1,+d,+h,+mi,+sec);\n}\nconst d=new Date(value);\nreturn Number.isNaN(d.getTime())?null:d;\n}\nreturn null;\n}\nfunction pad(n,w){return String(n).padStart(w,'0');}\nfunction fieldReader(timeZone){\nif(!timeZone){\nreturn(d)=>({\nyear:d.getFullYear(),month:d.getMonth()+1,day:d.getDate(),\nhour:d.getHours(),minute:d.getMinutes(),second:d.getSeconds(),\nms:d.getMilliseconds(),weekday:d.getDay(),\n});\n}\nconst zoned=new Intl.DateTimeFormat('en-US',{\ntimeZone,year:'numeric',month:'2-digit',day:'2-digit',\nhour:'2-digit',minute:'2-digit',second:'2-digit',hour12:false,weekday:'short',\n});\nconst days={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};\nreturn(d)=>{\nconst f={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:d.getMilliseconds(),weekday:0};\nfor(const part of zoned.formatToParts(d)){\nswitch(part.type){\ncase'year':f.year=Number(part.value);break;\ncase'month':f.month=Number(part.value);break;\ncase'day':f.day=Number(part.value);break;\ncase'hour':f.hour=Number(part.value)%24;break;\ncase'minute':f.minute=Number(part.value);break;\ncase'second':f.second=Number(part.value);break;\ncase'weekday':f.weekday=days[part.value]??0;break;\ndefault:break;\n}\n}\nreturn f;\n};\n}\nfunction compilePattern(pattern,locale,timeZone){\nconst segments=scanPattern(pattern);\nconst read=fieldReader(timeZone);\nconst used=new Set(segments.filter((s)=>s.token).map((s)=>s.token));\nconst monthShort=used.has('MMM')?new Intl.DateTimeFormat(locale,{month:'short',timeZone}):null;\nconst monthLong=used.has('MMMM')?new Intl.DateTimeFormat(locale,{month:'long',timeZone}):null;\nconst dayShort=used.has('EEE')?new Intl.DateTimeFormat(locale,{weekday:'short',timeZone}):null;\nconst dayLong=used.has('EEEE')?new Intl.DateTimeFormat(locale,{weekday:'long',timeZone}):null;\nreturn(d)=>{\nconst f=read(d);\nlet out='';\nfor(const seg of segments){\nif(!seg.token){out+=seg.text;continue;}\nswitch(seg.token){\ncase'yyyy':out+=pad(f.year,4);break;\ncase'yy':out+=pad(f.year%100,2);break;\ncase'MMMM':out+=monthLong.format(d);break;\ncase'MMM':out+=monthShort.format(d);break;\ncase'MM':out+=pad(f.month,2);break;\ncase'M':out+=String(f.month);break;\ncase'dd':out+=pad(f.day,2);break;\ncase'd':out+=String(f.day);break;\ncase'EEEE':out+=dayLong.format(d);break;\ncase'EEE':out+=dayShort.format(d);break;\ncase'HH':out+=pad(f.hour,2);break;\ncase'H':out+=String(f.hour);break;\ncase'hh':out+=pad(f.hour%12===0?12:f.hour%12,2);break;\ncase'h':out+=String(f.hour%12===0?12:f.hour%12);break;\ncase'mm':out+=pad(f.minute,2);break;\ncase'm':out+=String(f.minute);break;\ncase'ss':out+=pad(f.second,2);break;\ncase's':out+=String(f.second);break;\ncase'SSS':out+=pad(f.ms,3);break;\ncase'a':out+=f.hour<12?'AM':'PM';break;\ndefault:out+=seg.text;break;\n}\n}\nreturn out;\n};\n}\nconst UNITS=[\n['year',365*24*3600e3],\n['month',30*24*3600e3],\n['week',7*24*3600e3],\n['day',24*3600e3],\n['hour',3600e3],\n['minute',60e3],\n['second',1e3],\n];\nfunction compileDate(spec,locale){\nconst s=spec||{};\nconst loc=s.locale||locale||undefined;\nconst nullDisplay=s.nullDisplay??'';\nconst timeZone=s.timeZone;\nlet absolute;\nif(s.pattern){\nabsolute=compilePattern(s.pattern,loc,timeZone);\n}else if(s.dateStyle||s.timeStyle){\nconst opts={timeZone};\nif(s.dateStyle)opts.dateStyle=s.dateStyle;\nif(s.timeStyle)opts.timeStyle=s.timeStyle;\nconst dtf=new Intl.DateTimeFormat(loc,opts);\nabsolute=(d)=>dtf.format(d);\n}else{\nconst dtf=new Intl.DateTimeFormat(loc,{dateStyle:'medium',timeZone});\nabsolute=(d)=>dtf.format(d);\n}\nconst relative=s.relative?new Intl.RelativeTimeFormat(loc,{numeric:'auto'}):null;\nconst thresholdDays=typeof s.relative==='object'&&s.relative\n?(s.relative.threshold??7)\n:7;\nconst thresholdMs=thresholdDays*24*3600e3;\nconst format=(value,params)=>{\nconst d=toDate(value);\nif(!d)return nullDisplay;\nif(relative){\nconst now=params&&typeof params.now==='number'?params.now:Date.now();\nconst delta=d.getTime()-now;\nif(Math.abs(delta)<thresholdMs){\nfor(const[unit,ms]of UNITS){\nif(Math.abs(delta)>=ms||unit==='second'){\nreturn relative.format(Math.round(delta/ms),unit);\n}\n}\n}\n}\nreturn absolute(d);\n};\nformat.spec=s;\nreturn format;\n}\nfunction toIsoDate(value){\nif(isNil(value)||value==='')return null;\nif(typeof value==='string'){\nconst match=/^(\\d{4}-\\d{2}-\\d{2})/.exec(value.trim());\nif(match)return match[1];\nconst parsed=toDate(value);\nreturn parsed?toIsoDate(parsed):null;\n}\nconst date=toDate(value);\nif(!date)return null;\nconst pad=(n)=>String(n).padStart(2,'0');\nreturn`${date.getFullYear()}-${pad(date.getMonth()+1)}-${pad(date.getDate())}`;\n}\nfunction toIsoDateTime(value,timeZone){\nif(isNil(value)||value==='')return null;\nif(typeof value==='string'){\nconst text=value.trim();\nif(ZONE_SUFFIX.test(text)){\nconst instant=toDate(text);\nreturn instant?wallClockIn(instant,timeZone):null;\n}\nconst match=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(text);\nif(match){\nconst[,day,hour,minute,second]=match;\nreturn`${day}T${hour}:${minute}${second&&second!=='00'?`:${second}`:''}`;\n}\nif(/^\\d{4}-\\d{2}-\\d{2}$/.test(text))return`${text}T00:00`;\nconst parsed=toDate(text);\nreturn parsed?toIsoDateTime(parsed):null;\n}\nconst date=toDate(value);\nif(!date)return null;\nreturn wallClockIn(date,timeZone);\n}\nconst ZONE_SUFFIX=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;\nfunction wallClockIn(date,timeZone){\nconst pad=(n)=>String(n).padStart(2,'0');\nif(timeZone){\ntry{\nconst parts=new Intl.DateTimeFormat('en-CA',{\ntimeZone,\nyear:'numeric',month:'2-digit',day:'2-digit',\nhour:'2-digit',minute:'2-digit',second:'2-digit',\nhour12:false,\n}).formatToParts(date).reduce((out,part)=>{\nif(part.type!=='literal')out[part.type]=part.value;\nreturn out;\n},{});\nconst hour=parts.hour==='24'?'00':parts.hour;\nconst seconds=Number(parts.second);\nreturn`${parts.year}-${parts.month}-${parts.day}T${hour}:${parts.minute}`\n+(seconds?`:${parts.second}`:'');\n}catch{\n}\n}\nconst day=`${date.getFullYear()}-${pad(date.getMonth()+1)}-${pad(date.getDate())}`;\nconst seconds=date.getSeconds();\nconst clock=`${pad(date.getHours())}:${pad(date.getMinutes())}${seconds?`:${pad(seconds)}`:''}`;\nreturn`${day}T${clock}`;\n}\nfunction compareIso(a,b){\nconst left=isNil(a)||a===''?null:String(a);\nconst right=isNil(b)||b===''?null:String(b);\nif(left===null)return right===null?0:1;\nif(right===null)return-1;\nreturn left<right?-1:left>right?1:0;\n}\n});\n__def(\"packages/core/src/compute/filter.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"releaseMask\",{enumerable:true,get:function(){return releaseMask;}});\nObject.defineProperty(__exports,\"compilePredicate\",{enumerable:true,get:function(){return compilePredicate;}});\nObject.defineProperty(__exports,\"testValue\",{enumerable:true,get:function(){return testValue;}});\nObject.defineProperty(__exports,\"evaluateCondition\",{enumerable:true,get:function(){return evaluateCondition;}});\nObject.defineProperty(__exports,\"evaluateFilters\",{enumerable:true,get:function(){return evaluateFilters;}});\nObject.defineProperty(__exports,\"pruneColumn\",{enumerable:true,get:function(){return pruneColumn;}});\nObject.defineProperty(__exports,\"mentionsColumn\",{enumerable:true,get:function(){return mentionsColumn;}});\nObject.defineProperty(__exports,\"compact\",{enumerable:true,get:function(){return compact;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst isBlank=__m0[\"isBlank\"];\nconst toArray=__m0[\"toArray\"];\nconst warnOnce=__m0[\"warnOnce\"];\nconst __m1=__req(\"packages/core/src/format/date.js\");\nconst toIsoDate=__m1[\"toIsoDate\"];\nconst __m2=__req(\"packages/core/src/compute/handle.js\");\nconst bitReader=__m2[\"bitReader\"];\nconst dictSize=__m2[\"dictSize\"];\nconst dictValue=__m2[\"dictValue\"];\nconst presenceReader=__m2[\"presenceReader\"];\nconst valueComparator=__m2[\"valueComparator\"];\nconst valueReader=__m2[\"valueReader\"];\nconst ISO_DAY=/^\\d{4}-\\d{2}-\\d{2}$/;\nconst NULL_KEY='\\u0000null\\u0000';\nfunction acquireMask(ctx,n){\nconst pool=ctx&&ctx.pool;\nif(pool){\nconst take=pool.mask||pool.acquireMask||pool.acquire||pool.take;\nif(typeof take==='function'){\nconst mask=take.call(pool,n);\nif(mask&&mask.length>=n)return mask;\n}\n}\nreturn new Uint8Array(n);\n}\nfunction releaseMask(ctx,mask){\nconst pool=ctx&&ctx.pool;\nif(!pool||!mask)return;\nconst give=pool.release||pool.releaseMask||pool.free||pool.recycle;\nif(typeof give==='function')give.call(pool,mask);\n}\nfunction fillMask(mask,n,value){\nmask.fill(value,0,n);\nreturn mask;\n}\nfunction unorderable(v){\nreturn v===null||v===undefined||(typeof v==='number'&&Number.isNaN(v));\n}\nfunction coerceTarget(value,type){\nif(value===null||value===undefined)return value;\nif(type==='number')return typeof value==='number'?value:Number(value);\nif(type==='date'||type==='dateString'){\nconst iso=toIsoDate(value);\nreturn iso===null?toMillis(value):iso;\n}\nif(type==='boolean'){\nif(typeof value==='boolean')return value;\nif(value==='true'||value===1)return true;\nif(value==='false'||value===0)return false;\nreturn!!value;\n}\nreturn value;\n}\nfunction toMillis(value){\nif(value instanceof Date)return value.getTime();\nif(typeof value==='number')return value;\nreturn Date.parse(String(value));\n}\nfunction toNumber(value){\nif(typeof value==='number')return value;\nif(value instanceof Date)return value.getTime();\nif(value===null||value===undefined||value==='')return NaN;\nreturn Number(value);\n}\nfunction textOf(v,caseSensitive){\nconst s=typeof v==='string'?v:String(v);\nreturn caseSensitive?s:s.toLowerCase();\n}\nfunction setKey(v,caseSensitive){\nif(v===null||v===undefined)return NULL_KEY;\nif(typeof v==='string')return caseSensitive?v:v.toLowerCase();\nif(v instanceof Date)return v.getTime();\nreturn v;\n}\nfunction buildSet(value,caseSensitive,type){\nconst set=new Set();\nfor(const raw of toArray(value)){\nconst entry=coerceTarget(raw,type);\nset.add(setKey(entry,caseSensitive));\nif(typeof entry==='string'&&entry!==''&&Number.isFinite(Number(entry)))set.add(Number(entry));\nelse if(typeof entry==='number'&&Number.isFinite(entry))set.add(setKey(String(entry),caseSensitive));\n}\nreturn set;\n}\nfunction valueEquals(a,b,caseSensitive){\nif(a===null||a===undefined||b===null||b===undefined){\nreturn(a===null||a===undefined)&&(b===null||b===undefined);\n}\nconst ta=typeof a;\nconst tb=typeof b;\nif(ta==='string'&&tb==='string')return caseSensitive?a===b:a.toLowerCase()===b.toLowerCase();\nif(a instanceof Date||b instanceof Date)return toMillis(a)===toMillis(b);\nif(ta==='number'&&tb==='number')return a===b||(Number.isNaN(a)&&Number.isNaN(b));\nif(ta==='number'&&tb==='string')return a===Number(b);\nif(ta==='string'&&tb==='number')return Number(a)===b;\nif(ta==='boolean'||tb==='boolean')return a===b;\nif(Array.isArray(a)&&Array.isArray(b)){\nreturn a.length===b.length&&a.every((x,i)=>valueEquals(x,b[i],caseSensitive));\n}\nreturn a===b;\n}\nfunction compileRegExp(value,caseSensitive){\ntry{\nif(value instanceof RegExp){\nconst flags=value.flags.replace(/[gy]/g,'');\nreturn new RegExp(value.source,caseSensitive?flags:flags.includes('i')?flags:`${flags}i`);\n}\nreturn new RegExp(String(value),caseSensitive?'':'i');\n}catch(err){\nwarnOnce(`regex:${String(value)}`,`filter operator \"matches\" received an invalid pattern: ${String(value)}`,err);\nreturn null;\n}\n}\nfunction compilePredicate(condition,locale){\nconst predicate=compileValuePredicate(condition,locale);\nconst type=condition&&condition.type;\nif(type!=='date'&&type!=='dateString')return predicate;\nreturn(v)=>predicate(typeof v==='string'&&ISO_DAY.test(v)?v:(toIsoDate(v)??v));\n}\nfunction compileValuePredicate(condition,locale){\nconst op=condition&&condition.op;\nconst caseSensitive=!!(condition&&condition.caseSensitive);\nconst type=condition&&condition.type;\nconst cmp=valueComparator(locale);\nconst not=(p)=>(v)=>!p(v);\nswitch(op){\ncase'eq':{\nconst target=coerceTarget(condition.value,type);\nreturn(v)=>valueEquals(v,target,caseSensitive);\n}\ncase'ne':{\nconst target=coerceTarget(condition.value,type);\nreturn(v)=>!valueEquals(v,target,caseSensitive);\n}\ncase'lt':case'lte':case'gt':case'gte':{\nconst target=coerceTarget(condition.value,type);\nif(unorderable(target))return()=>false;\nconst want=op==='lt'?-1:op==='lte'?0:op==='gt'?1:2;\nreturn(v)=>{\nif(unorderable(v))return false;\nconst c=cmp(v,target);\nreturn want===-1?c<0:want===0?c<=0:want===1?c>0:c>=0;\n};\n}\ncase'between':case'notBetween':{\nconst pair=toArray(condition.value);\nconst lo=coerceTarget(pair[0],type);\nconst hi=coerceTarget(pair[1],type);\nconst bounds=condition.bounds||'[]';\nconst loInclusive=bounds.charAt(0)!=='(';\nconst hiInclusive=bounds.charAt(1)!==')';\nif(unorderable(lo)||unorderable(hi))return op==='between'?()=>false:()=>true;\nconst inRange=(v)=>{\nif(unorderable(v))return false;\nconst a=cmp(v,lo);\nconst b=cmp(v,hi);\nreturn(loInclusive?a>=0:a>0)&&(hiInclusive?b<=0:b<0);\n};\nreturn op==='between'?inRange:not(inRange);\n}\ncase'in':case'notIn':{\nconst set=buildSet(condition.value,caseSensitive,type);\nconst member=(v)=>set.has(setKey(v,caseSensitive));\nreturn op==='in'?member:not(member);\n}\ncase'contains':case'notContains':{\nconst needle=textOf(coerceTarget(condition.value,type),caseSensitive);\nconst has=(v)=>(v===null||v===undefined?false:textOf(v,caseSensitive).includes(needle));\nreturn op==='contains'?has:not(has);\n}\ncase'startsWith':{\nconst needle=textOf(coerceTarget(condition.value,type),caseSensitive);\nreturn(v)=>(v===null||v===undefined?false:textOf(v,caseSensitive).startsWith(needle));\n}\ncase'endsWith':{\nconst needle=textOf(coerceTarget(condition.value,type),caseSensitive);\nreturn(v)=>(v===null||v===undefined?false:textOf(v,caseSensitive).endsWith(needle));\n}\ncase'matches':{\nconst re=compileRegExp(condition.value,caseSensitive);\nif(!re)return()=>false;\nreturn(v)=>(v===null||v===undefined?false:re.test(String(v)));\n}\ncase'blank':\nreturn(v)=>isBlank(v)||(Array.isArray(v)&&v.length===0);\ncase'notBlank':\nreturn(v)=>!(isBlank(v)||(Array.isArray(v)&&v.length===0));\ncase'containsAny':case'containsNone':{\nconst set=buildSet(condition.value,caseSensitive,type);\nconst any=(v)=>{\nconst list=v===null||v===undefined?[]:toArray(v);\nfor(let i=0;i<list.length;i++)if(set.has(setKey(list[i],caseSensitive)))return true;\nreturn false;\n};\nreturn op==='containsAny'?any:not(any);\n}\ncase'containsAll':{\nconst wanted=toArray(condition.value).map((x)=>setKey(coerceTarget(x,type),caseSensitive));\nreturn(v)=>{\nconst list=v===null||v===undefined?[]:toArray(v);\nif(wanted.length===0)return true;\nconst have=new Set(list.map((x)=>setKey(x,caseSensitive)));\nfor(let i=0;i<wanted.length;i++)if(!have.has(wanted[i]))return false;\nreturn true;\n};\n}\ndefault:\nwarnOnce(`op:${String(op)}`,`unknown filter operator \"${String(op)}\"; the condition passes every row`);\nreturn()=>true;\n}\n}\nfunction testValue(value,condition,locale){\nreturn compilePredicate(condition,locale)(value);\n}\nfunction presenceCondition(handle,wantPresent,mask,count){\nconst present=presenceReader(handle);\nif(present){\nconst target=wantPresent?1:0;\nfor(let i=0;i<count;i++)mask[i]=present(i)===target?1:0;\nreturn mask;\n}\nconst kind=handle.kind;\nif(kind==='float64'||kind==='int32'||kind==='bitset'){\nreturn fillMask(mask,count,wantPresent?1:0);\n}\nconst read=valueReader(handle);\nfor(let i=0;i<count;i++){\nconst v=read(i);\nconst blank=isBlank(v)||(Array.isArray(v)&&v.length===0);\nmask[i]=blank===wantPresent?0:1;\n}\nreturn mask;\n}\nfunction dictionaryCondition(handle,pred,mask,count){\nconst dict=handle.dict;\nconst size=dictSize(dict);\nconst allowed=new Uint8Array(size);\nfor(let code=0;code<size;code++)allowed[code]=pred(dictValue(dict,code))?1:0;\nconst codes=handle.values;\nconst present=presenceReader(handle);\nif(!present){\nfor(let i=0;i<count;i++)mask[i]=allowed[codes[i]];\nreturn mask;\n}\nconst absentAnswer=pred(null)?1:0;\nfor(let i=0;i<count;i++)mask[i]=present(i)===1?allowed[codes[i]]:absentAnswer;\nreturn mask;\n}\nfunction booleanCondition(handle,pred,mask,count){\nconst bit=bitReader(handle.values);\nconst whenTrue=pred(true)?1:0;\nconst whenFalse=pred(false)?1:0;\nconst present=presenceReader(handle);\nif(!present){\nfor(let i=0;i<count;i++)mask[i]=bit(i)===1?whenTrue:whenFalse;\nreturn mask;\n}\nconst absentAnswer=pred(null)?1:0;\nfor(let i=0;i<count;i++){\nmask[i]=present(i)===0?absentAnswer:(bit(i)===1?whenTrue:whenFalse);\n}\nreturn mask;\n}\nfunction numericCondition(handle,condition,pred,mask,count){\nconst values=handle.values;\nconst type=condition.type;\nconst op=condition.op;\nlet handled=true;\nswitch(op){\ncase'eq':case'ne':{\nconst target=toNumber(coerceTarget(condition.value,type));\nconst wantNaN=typeof condition.value==='number'&&Number.isNaN(condition.value);\nconst invert=op==='ne'?1:0;\nif(wantNaN){\nfor(let i=0;i<count;i++)mask[i]=(Number.isNaN(values[i])?1:0)^invert;\n}else{\nfor(let i=0;i<count;i++)mask[i]=((values[i]===target)?1:0)^invert;\n}\nbreak;\n}\ncase'lt':{\nconst t=toNumber(coerceTarget(condition.value,type));\nfor(let i=0;i<count;i++)mask[i]=values[i]<t?1:0;\nbreak;\n}\ncase'lte':{\nconst t=toNumber(coerceTarget(condition.value,type));\nfor(let i=0;i<count;i++)mask[i]=values[i]<=t?1:0;\nbreak;\n}\ncase'gt':{\nconst t=toNumber(coerceTarget(condition.value,type));\nfor(let i=0;i<count;i++)mask[i]=values[i]>t?1:0;\nbreak;\n}\ncase'gte':{\nconst t=toNumber(coerceTarget(condition.value,type));\nfor(let i=0;i<count;i++)mask[i]=values[i]>=t?1:0;\nbreak;\n}\ncase'between':case'notBetween':{\nconst pair=toArray(condition.value);\nconst lo=toNumber(coerceTarget(pair[0],type));\nconst hi=toNumber(coerceTarget(pair[1],type));\nconst bounds=condition.bounds||'[]';\nconst loInclusive=bounds.charAt(0)!=='(';\nconst hiInclusive=bounds.charAt(1)!==')';\nconst invert=op==='notBetween'?1:0;\nif(loInclusive&&hiInclusive){\nfor(let i=0;i<count;i++)mask[i]=(((values[i]>=lo)&(values[i]<=hi))?1:0)^invert;\n}else if(loInclusive){\nfor(let i=0;i<count;i++)mask[i]=(((values[i]>=lo)&(values[i]<hi))?1:0)^invert;\n}else if(hiInclusive){\nfor(let i=0;i<count;i++)mask[i]=(((values[i]>lo)&(values[i]<=hi))?1:0)^invert;\n}else{\nfor(let i=0;i<count;i++)mask[i]=(((values[i]>lo)&(values[i]<hi))?1:0)^invert;\n}\nbreak;\n}\ncase'in':case'notIn':{\nconst set=new Set();\nfor(const raw of toArray(condition.value)){\nconst n=toNumber(coerceTarget(raw,type));\nif(!Number.isNaN(n))set.add(n);\n}\nconst invert=op==='notIn'?1:0;\nfor(let i=0;i<count;i++)mask[i]=(set.has(values[i])?1:0)^invert;\nbreak;\n}\ndefault:\nhandled=false;\nbreak;\n}\nif(!handled)return false;\nconst present=presenceReader(handle);\nif(present){\nconst absentAnswer=pred(null)?1:0;\nfor(let i=0;i<count;i++)if(present(i)===0)mask[i]=absentAnswer;\n}\nreturn true;\n}\nfunction genericCondition(handle,pred,mask,count){\nconst read=valueReader(handle);\nfor(let i=0;i<count;i++)mask[i]=pred(read(i))?1:0;\nreturn mask;\n}\nfunction evaluateCondition(condition,ctx,out){\nconst count=ctx.count|0;\nconst mask=out||acquireMask(ctx,count);\nif(!condition)return fillMask(mask,count,1);\nconst handle=typeof ctx.handle==='function'?ctx.handle(condition.col):undefined;\nconst custom=typeof ctx.custom==='function'?ctx.custom:null;\nif(!handle){\nif(custom){\nfor(let i=0;i<count;i++)mask[i]=custom(condition,i)?1:0;\nreturn mask;\n}\nwarnOnce(`filter:col:${String(condition.col)}`,\n`filter references unknown column \"${String(condition.col)}\"; the condition passes every row`);\nreturn fillMask(mask,count,1);\n}\nconst op=condition.op;\nif(op==='blank'||op==='notBlank')return presenceCondition(handle,op==='notBlank',mask,count);\nconst pred=compilePredicate(condition,ctx.locale);\nswitch(handle.kind){\ncase'dictionary':\nreturn dictionaryCondition(handle,pred,mask,count);\ncase'bitset':\nreturn booleanCondition(handle,pred,mask,count);\ncase'float64':case'int32':\nif(numericCondition(handle,condition,pred,mask,count))return mask;\nreturn genericCondition(handle,pred,mask,count);\ndefault:\nreturn genericCondition(handle,pred,mask,count);\n}\n}\nfunction evaluateNode(node,ctx,count){\nif(!node)return fillMask(acquireMask(ctx,count),count,1);\nif(Array.isArray(node.conditions)){\nconst children=node.conditions.filter((c)=>c!=null);\nconst op=node.op==='or'?'or':node.op==='not'?'not':'and';\nif(children.length===0)return fillMask(acquireMask(ctx,count),count,1);\nconst acc=evaluateNode(children[0],ctx,count);\nfor(let k=1;k<children.length;k++){\nconst rhs=evaluateNode(children[k],ctx,count);\nif(op==='or')for(let i=0;i<count;i++)acc[i]|=rhs[i];\nelse for(let i=0;i<count;i++)acc[i]&=rhs[i];\nreleaseMask(ctx,rhs);\n}\nif(op==='not')for(let i=0;i<count;i++)acc[i]^=1;\nreturn acc;\n}\nreturn evaluateCondition(node,ctx,acquireMask(ctx,count));\n}\nfunction evaluateFilters(filters,ctx){\nreturn evaluateNode(filters,ctx,ctx.count|0);\n}\nfunction pruneColumn(filters,colId){\nif(!filters||!colId)return filters||null;\nconst node=(filters);\nif(Array.isArray(node.conditions)){\nconst op=node.op==='or'?'or':node.op==='not'?'not':'and';\nif(op!=='and'){\nreturn mentionsColumn(node,colId)?null:filters;\n}\nconst kept=[];\nfor(const child of node.conditions){\nconst pruned=pruneColumn(child,colId);\nif(pruned)kept.push(pruned);\n}\nif(!kept.length)return null;\nreturn{...node,op:'and',conditions:kept};\n}\nreturn node.col===colId?null:filters;\n}\nfunction mentionsColumn(filters,colId){\nif(!filters||typeof filters!=='object')return false;\nconst node=(filters);\nif(node.col===colId)return true;\nif(Array.isArray(node.conditions)){\nfor(const child of node.conditions)if(mentionsColumn(child,colId))return true;\n}\nreturn false;\n}\nfunction compact(mask,count,out){\nif(out&&out.length>=count){\nlet k=0;\nfor(let i=0;i<count;i++)if(mask[i])out[k++]=i;\nreturn out.subarray(0,k);\n}\nlet survivors=0;\nfor(let i=0;i<count;i++)survivors+=mask[i]?1:0;\nconst result=new Uint32Array(survivors);\nlet k=0;\nfor(let i=0;i<count;i++)if(mask[i])result[k++]=i;\nreturn result;\n}\n});\n__def(\"packages/core/src/compute/group.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"packKeys\",{enumerable:true,get:function(){return packKeys;}});\nObject.defineProperty(__exports,\"groupByColumns\",{enumerable:true,get:function(){return groupByColumns;}});\nconst __m0=__req(\"packages/core/src/compute/handle.js\");\nconst dictSize=__m0[\"dictSize\"];\nconst identity=__m0[\"identity\"];\nconst presenceReader=__m0[\"presenceReader\"];\nconst rowCount=__m0[\"rowCount\"];\nconst valueReader=__m0[\"valueReader\"];\nconst KEY_SEPARATOR='\\u001F';\nconst NULL_MARKER='\\u0000';\nconst MAX_DIRECT_COUNTS=1<<20;\nfunction packKeys(handles,idx,n){\nconst k=handles.length;\nconst readers=handles.map((h)=>valueReader(h));\nconst allDictionary=k>0&&handles.every((h)=>h&&h.kind==='dictionary'&&h.dict);\nif(allDictionary){\nconst cards=handles.map((h)=>dictSize(h.dict)+1);\nlet product=1;\nfor(let j=0;j<k;j++)product*=cards[j];\nif(product<=Number.MAX_SAFE_INTEGER){\nconst codes=handles.map((h)=>h.values);\nconst presence=handles.map((h)=>presenceReader(h));\nconst keyOf=(row)=>{\nlet key=0;\nfor(let j=0;j<k;j++){\nconst present=presence[j];\nconst code=present&&present(row)===0?cards[j]-1:codes[j][row];\nkey=key*cards[j]+code;\n}\nreturn key;\n};\nconst packed=new Float64Array(n);\nfor(let i=0;i<n;i++)packed[i]=keyOf(idx[i]);\nreturn{packed,strings:null,product,readers,keyOf};\n}\n}\nconst keyOf=(row)=>{\nlet key='';\nfor(let j=0;j<k;j++){\nconst v=readers[j](row);\nkey+=(j===0?'':KEY_SEPARATOR)+(v===null||v===undefined?NULL_MARKER:String(v));\n}\nreturn key;\n};\nconst strings=new Array(n);\nfor(let i=0;i<n;i++)strings[i]=keyOf(idx[i]);\nreturn{packed:null,strings,product:Infinity,readers,keyOf};\n}\nfunction scatterBuckets(idx,ids,n,groups){\nconst offsets=new Uint32Array(groups+1);\nfor(let i=0;i<n;i++)offsets[ids[i]+1]++;\nfor(let g=0;g<groups;g++)offsets[g+1]+=offsets[g];\nconst scattered=new Uint32Array(n);\nconst cursor=offsets.slice(0,groups);\nfor(let i=0;i<n;i++)scattered[cursor[ids[i]]++]=idx[i];\nconst buckets=new Array(groups);\nfor(let g=0;g<groups;g++)buckets[g]=scattered.subarray(offsets[g],offsets[g+1]);\nreturn buckets;\n}\nfunction groupByColumns(handles,order,opts={}){\nconst list=handles||[];\nconst idx=order||identity(rowCount(list[0],opts));\nconst n=idx.length;\nif(list.length===0||n===0)return{keys:[],buckets:[]};\nconst{packed,strings,product,readers}=packKeys(list,idx,n);\nconst ids=new Uint32Array(n);\nlet groups=0;\nlet packedKeys=null;\nif(packed&&product<=Math.max(1024,Math.min(MAX_DIRECT_COUNTS,n*4))){\nconst size=product;\nconst seen=new Int32Array(size).fill(-1);\nfor(let i=0;i<n;i++)seen[packed[i]]=0;\nfor(let key=0;key<size;key++)if(seen[key]===0)seen[key]=groups++;\nfor(let i=0;i<n;i++)ids[i]=seen[packed[i]];\npackedKeys=new Float64Array(groups);\nfor(let key=0;key<size;key++)if(seen[key]>=0)packedKeys[seen[key]]=key;\n}else if(packed){\nconst seen=new Map();\nfor(let i=0;i<n;i++){\nconst key=packed[i];\nlet id=seen.get(key);\nif(id===undefined){id=groups++;seen.set(key,id);}\nids[i]=id;\n}\npackedKeys=new Float64Array(groups);\nfor(const[key,id]of seen)packedKeys[id]=key;\n}else{\nconst seen=new Map();\nfor(let i=0;i<n;i++){\nconst key=strings[i];\nlet id=seen.get(key);\nif(id===undefined){id=groups++;seen.set(key,id);}\nids[i]=id;\n}\n}\nconst buckets=scatterBuckets(idx,ids,n,groups);\nconst keys=new Array(groups);\nfor(let g=0;g<groups;g++){\nconst row=buckets[g][0];\nconst tuple=new Array(readers.length);\nfor(let j=0;j<readers.length;j++)tuple[j]=readers[j](row);\nkeys[g]=tuple;\n}\nconst result={keys,buckets};\nif(packedKeys)result.packed=packedKeys;\nreturn result;\n}\n});\n__def(\"packages/core/src/compute/facet.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"STRATEGIES\",{enumerable:true,get:function(){return STRATEGIES;}});\nObject.defineProperty(__exports,\"GRANULARITIES\",{enumerable:true,get:function(){return GRANULARITIES;}});\nObject.defineProperty(__exports,\"DEFAULT_BUCKETS\",{enumerable:true,get:function(){return DEFAULT_BUCKETS;}});\nObject.defineProperty(__exports,\"DEFAULT_CARDINALITY_LIMIT\",{enumerable:true,get:function(){return DEFAULT_CARDINALITY_LIMIT;}});\nObject.defineProperty(__exports,\"QUANTILE_SAMPLE\",{enumerable:true,get:function(){return QUANTILE_SAMPLE;}});\nObject.defineProperty(__exports,\"facetKind\",{enumerable:true,get:function(){return facetKind;}});\nObject.defineProperty(__exports,\"orderedReader\",{enumerable:true,get:function(){return orderedReader;}});\nObject.defineProperty(__exports,\"toNumeric\",{enumerable:true,get:function(){return toNumeric;}});\nObject.defineProperty(__exports,\"cardinalityOf\",{enumerable:true,get:function(){return cardinalityOf;}});\nObject.defineProperty(__exports,\"pickGranularity\",{enumerable:true,get:function(){return pickGranularity;}});\nObject.defineProperty(__exports,\"floorTo\",{enumerable:true,get:function(){return floorTo;}});\nObject.defineProperty(__exports,\"advance\",{enumerable:true,get:function(){return advance;}});\nObject.defineProperty(__exports,\"computeBounds\",{enumerable:true,get:function(){return computeBounds;}});\nObject.defineProperty(__exports,\"countInto\",{enumerable:true,get:function(){return countInto;}});\nObject.defineProperty(__exports,\"bucketOf\",{enumerable:true,get:function(){return bucketOf;}});\nObject.defineProperty(__exports,\"facet\",{enumerable:true,get:function(){return facet;}});\nObject.defineProperty(__exports,\"default\",{enumerable:true,get:function(){return __default;}});\nconst __m0=__req(\"packages/core/src/compute/handle.js\");\nconst presenceReader=__m0[\"presenceReader\"];\nconst valueReader=__m0[\"valueReader\"];\nconst dictSize=__m0[\"dictSize\"];\nconst dictValue=__m0[\"dictValue\"];\nconst STRATEGIES=Object.freeze(['equal','quantile','log']);\nconst GRANULARITIES=Object.freeze(['hour','day','week','month','quarter','year']);\nconst DEFAULT_BUCKETS=20;\nconst DEFAULT_CARDINALITY_LIMIT=50;\nconst QUANTILE_SAMPLE=10_000;\nfunction facetKind(handle,type){\nif(!handle)return'none';\nconst base=type&&type.base;\nif(base==='date'||base==='datetime'||base==='time'||base==='dateString')return'date';\nswitch(handle.kind){\ncase'bitset':return'boolean';\ncase'float64':case'int32':return'numeric';\ncase'dictionary':return'category';\ncase'multi':return'category';\ndefault:\nif(base==='number')return'numeric';\nif(base==='boolean')return'boolean';\nif(base==='text')return'category';\nreturn'none';\n}\n}\nfunction orderedReader(handle){\nconst values=handle.values;\nconst kind=handle.kind;\nif((kind==='float64'||kind==='int32')&&values)return(i)=>values[i];\nconst read=valueReader(handle);\nreturn(i)=>toNumeric(read(i));\n}\nfunction toNumeric(v){\nif(typeof v==='number')return v;\nif(v instanceof Date)return v.getTime();\nif(v===null||v===undefined||v==='')return NaN;\nif(typeof v==='boolean')return v?1:0;\nif(typeof v==='string'){\nconst n=Number(v);\nif(Number.isFinite(n))return n;\nconst t=Date.parse(v);\nreturn Number.isFinite(t)?t:NaN;\n}\nreturn NaN;\n}\nfunction cardinalityOf(handle,indices,count,limit=DEFAULT_CARDINALITY_LIMIT){\nif(!handle)return{cardinality:0,exact:true};\nif(handle.dict)return{cardinality:dictSize(handle.dict),exact:true};\nif(handle.kind==='bitset')return{cardinality:2,exact:true};\nconst read=valueReader(handle);\nconst n=indices?indices.length:count;\nconst seen=new Set();\nfor(let k=0;k<n;k++){\nconst v=read(indices?indices[k]:k);\nif(v===null||v===undefined)continue;\nseen.add(v);\nif(seen.size>limit)return{cardinality:seen.size,exact:false};\n}\nreturn{cardinality:seen.size,exact:true};\n}\nconst HOUR_MS=3600_000;\nconst DAY_MS=86_400_000;\nfunction pickGranularity(span,target=DEFAULT_BUCKETS){\nconst ms=Number.isFinite(span)&&span>0?span:0;\nconst wide=Math.max(1,target)*2;\nif(ms/HOUR_MS<=wide)return'hour';\nif(ms/DAY_MS<=wide)return'day';\nif(ms/(7*DAY_MS)<=wide)return'week';\nif(ms/(30*DAY_MS)<=wide)return'month';\nif(ms/(91*DAY_MS)<=wide)return'quarter';\nreturn'year';\n}\nfunction floorTo(ms,granularity){\nif(!Number.isFinite(ms))return NaN;\nconst d=new Date(ms);\nswitch(granularity){\ncase'hour':d.setMinutes(0,0,0);return d.getTime();\ncase'day':d.setHours(0,0,0,0);return d.getTime();\ncase'week':{\nd.setHours(0,0,0,0);\nconst back=(d.getDay()+6)%7;\nd.setDate(d.getDate()-back);\nreturn d.getTime();\n}\ncase'month':d.setDate(1);d.setHours(0,0,0,0);return d.getTime();\ncase'quarter':\nd.setMonth(Math.floor(d.getMonth()/3)*3,1);\nd.setHours(0,0,0,0);\nreturn d.getTime();\ndefault:d.setMonth(0,1);d.setHours(0,0,0,0);return d.getTime();\n}\n}\nfunction advance(ms,granularity){\nconst d=new Date(ms);\nswitch(granularity){\ncase'hour':d.setHours(d.getHours()+1);break;\ncase'day':d.setDate(d.getDate()+1);break;\ncase'week':d.setDate(d.getDate()+7);break;\ncase'month':d.setMonth(d.getMonth()+1);break;\ncase'quarter':d.setMonth(d.getMonth()+3);break;\ndefault:d.setFullYear(d.getFullYear()+1);break;\n}\nreturn d.getTime();\n}\nfunction numericExtent(handle,indices,count){\nconst read=orderedReader(handle);\nconst present=presenceReader(handle);\nconst n=indices?indices.length:count;\nlet min=Infinity;\nlet max=-Infinity;\nlet nulls=0;\nlet finite=0;\nfor(let k=0;k<n;k++){\nconst i=indices?indices[k]:k;\nif(present&&!present(i)){nulls++;continue;}\nconst v=read(i);\nif(!Number.isFinite(v)){nulls++;continue;}\nif(v<min)min=v;\nif(v>max)max=v;\nfinite++;\n}\nreturn{min,max,nulls,finite};\n}\nfunction sortedSample(handle,indices,count,cap){\nconst read=orderedReader(handle);\nconst present=presenceReader(handle);\nconst n=indices?indices.length:count;\nconst step=n>cap?n/cap:1;\nconst out=[];\nfor(let s=0;s<n;s+=step){\nconst i=indices?indices[Math.floor(s)]:Math.floor(s);\nif(present&&!present(i))continue;\nconst v=read(i);\nif(Number.isFinite(v))out.push(v);\n}\nconst arr=Float64Array.from(out);\narr.sort();\nreturn arr;\n}\nfunction computeBounds(handle,indices,count,opts={}){\nconst kind=opts.kind||facetKind(handle,opts.type);\nif(kind==='none'||!handle)return{kind:'none',buckets:[],suppressed:'type'};\nif(kind==='boolean')return boundsForBoolean(handle,indices,count);\nif(kind==='category')return boundsForCategory(handle,indices,count,opts);\nreturn boundsForOrdered(handle,indices,count,kind,opts);\n}\nfunction boundsForBoolean(handle,indices,count){\nconst present=presenceReader(handle);\nlet nulls=0;\nif(present){\nconst n=indices?indices.length:count;\nfor(let k=0;k<n;k++)if(!present(indices?indices[k]:k))nulls++;\n}\nconst buckets=[{value:false,label:'false'},{value:true,label:'true'}];\nif(nulls>0)buckets.push({null:true,label:'Empty'});\nreturn{kind:'boolean',buckets};\n}\nfunction boundsForCategory(handle,indices,count,opts){\nconst limit=opts.cardinalityLimit??DEFAULT_CARDINALITY_LIMIT;\nconst{cardinality}=cardinalityOf(handle,indices,count,limit);\nif(cardinality>limit&&(opts.aboveLimit||'suppress')==='suppress'){\nreturn{kind:'category',buckets:[],suppressed:'cardinality',cardinality};\n}\nconst read=valueReader(handle);\nconst n=indices?indices.length:count;\nconst tally=new Map();\nlet nulls=0;\nfor(let k=0;k<n;k++){\nconst v=read(indices?indices[k]:k);\nif(v===null||v===undefined||v===''){nulls++;continue;}\nif(Array.isArray(v)){\nif(!v.length){nulls++;continue;}\nfor(const m of v)tally.set(m,(tally.get(m)||0)+1);\ncontinue;\n}\ntally.set(v,(tally.get(v)||0)+1);\n}\nlet entries=[...tally.entries()];\nif(opts.order==='alpha'){\nentries.sort((a,b)=>String(a[0]).localeCompare(String(b[0])));\n}else{\nentries.sort((a,b)=>b[1]-a[1]);\n}\nlet remainder=0;\nlet dropped=0;\nif(entries.length>limit){\ndropped=entries.length-limit;\nfor(let i=limit;i<entries.length;i++)remainder+=entries[i][1];\nentries=entries.slice(0,limit);\n}\nconst buckets=entries.map(([value])=>({value,label:String(value)}));\nif(remainder>0)buckets.push({remainder:true,label:`Other (${dropped} values)`});\nif(nulls>0)buckets.push({null:true,label:'Empty'});\nreturn{kind:'category',buckets,cardinality};\n}\nfunction boundsForOrdered(handle,indices,count,kind,opts){\nconst{min,max,nulls,finite}=numericExtent(handle,indices,count);\nif(!finite){\nreturn{kind,buckets:nulls?[{null:true,label:'Empty'}]:[],empty:true};\n}\nconst wanted=Math.max(1,Math.floor(opts.buckets||DEFAULT_BUCKETS));\nlet buckets=[];\nif(kind==='date'){\nconst granularity=GRANULARITIES.includes(opts.granularity)\n?opts.granularity:pickGranularity(max-min,wanted);\nlet edge=floorTo(min,granularity);\nwhile(edge<=max&&buckets.length<4096){\nconst next=advance(edge,granularity);\nif(!(next>edge))break;\nbuckets.push({from:edge,to:next});\nedge=next;\n}\nreturn{kind,buckets:withNull(buckets,nulls),granularity};\n}\nconst strategy=STRATEGIES.includes(opts.strategy)?opts.strategy:'equal';\nif(strategy==='quantile'){\nconst sample=sortedSample(handle,indices,count,QUANTILE_SAMPLE);\nif(sample.length){\nconst edges=[sample[0]];\nfor(let b=1;b<wanted;b++){\nconst v=sample[Math.min(sample.length-1,Math.floor((b/wanted)*sample.length))];\nif(v>edges[edges.length-1])edges.push(v);\n}\nedges.push(max);\nfor(let b=0;b<edges.length-1;b++)buckets.push({from:edges[b],to:edges[b+1]});\n}\n}else if(strategy==='log'&&min>0){\nconst lo=Math.log10(min);\nconst hi=Math.log10(max);\nconst step=(hi-lo)/wanted||1;\nfor(let b=0;b<wanted;b++){\nbuckets.push({from:10**(lo+b*step),to:10**(lo+(b+1)*step)});\n}\n}\nif(!buckets.length){\nconst width=(max-min)/wanted||1;\nfor(let b=0;b<wanted;b++)buckets.push({from:min+b*width,to:min+(b+1)*width});\n}\nbuckets[buckets.length-1].to=max;\nreturn{kind,buckets:withNull(buckets,nulls),strategy,min,max};\n}\nfunction withNull(buckets,nulls){\nreturn nulls>0?[...buckets,{null:true,label:'Empty'}]:buckets;\n}\nfunction countInto(handle,indices,count,bounds,out){\nconst buckets=(bounds&&bounds.buckets)||[];\nconst counts=out&&out.length>=buckets.length?out.subarray(0,buckets.length)\n:new Uint32Array(buckets.length);\ncounts.fill(0);\nif(!handle||!buckets.length)return counts;\nconst nullBucket=buckets.length-1;\nconst hasNull=!!buckets[nullBucket]&&buckets[nullBucket].null===true;\nconst n=indices?indices.length:count;\nif(bounds.kind==='boolean'){\nconst read=valueReader(handle);\nfor(let k=0;k<n;k++){\nconst v=read(indices?indices[k]:k);\nif(v===null||v===undefined){if(hasNull)counts[nullBucket]++;continue;}\ncounts[v?1:0]++;\n}\nreturn counts;\n}\nif(bounds.kind==='category'){\nconst slot=new Map();\nfor(let b=0;b<buckets.length;b++){\nif(!buckets[b].null&&!buckets[b].remainder)slot.set(buckets[b].value,b);\n}\nconst remainderAt=buckets.findIndex((b)=>b.remainder);\nconst read=valueReader(handle);\nfor(let k=0;k<n;k++){\nconst v=read(indices?indices[k]:k);\nif(v===null||v===undefined||v===''){if(hasNull)counts[nullBucket]++;continue;}\nif(Array.isArray(v)){\nif(!v.length){if(hasNull)counts[nullBucket]++;continue;}\nfor(const m of v){\nconst at=slot.get(m);\nif(at!==undefined)counts[at]++;\nelse if(remainderAt>=0)counts[remainderAt]++;\n}\ncontinue;\n}\nconst at=slot.get(v);\nif(at!==undefined)counts[at]++;\nelse if(remainderAt>=0)counts[remainderAt]++;\n}\nreturn counts;\n}\nconst ordered=hasNull?buckets.length-1:buckets.length;\nconst edges=new Float64Array(ordered+1);\nfor(let b=0;b<ordered;b++)edges[b]=buckets[b].from;\nedges[ordered]=ordered?buckets[ordered-1].to:0;\nconst read=orderedReader(handle);\nconst present=presenceReader(handle);\nfor(let k=0;k<n;k++){\nconst i=indices?indices[k]:k;\nif(present&&!present(i)){if(hasNull)counts[nullBucket]++;continue;}\nconst v=read(i);\nif(!Number.isFinite(v)){if(hasNull)counts[nullBucket]++;continue;}\nconst at=bucketOf(edges,ordered,v);\nif(at>=0)counts[at]++;\n}\nreturn counts;\n}\nfunction bucketOf(edges,ordered,v){\nif(!ordered)return-1;\nif(v<edges[0])return-1;\nif(v>=edges[ordered])return v===edges[ordered]?ordered-1:-1;\nlet lo=0;\nlet hi=ordered-1;\nwhile(lo<hi){\nconst mid=(lo+hi+1)>>>1;\nif(v>=edges[mid])lo=mid;else hi=mid-1;\n}\nreturn lo;\n}\nfunction facet(handle,indices,count,opts={}){\nconst bounds=opts.bounds||computeBounds(handle,opts.boundsIndices??indices,count,opts);\nreturn{bounds,counts:countInto(handle,indices,count,bounds)};\n}\nconst __default=facet;\n});\n__def(\"packages/core/src/compute/special.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"logGamma\",{enumerable:true,get:function(){return logGamma;}});\nObject.defineProperty(__exports,\"incompleteBeta\",{enumerable:true,get:function(){return incompleteBeta;}});\nObject.defineProperty(__exports,\"normalQuantile\",{enumerable:true,get:function(){return normalQuantile;}});\nObject.defineProperty(__exports,\"normalCdf\",{enumerable:true,get:function(){return normalCdf;}});\nObject.defineProperty(__exports,\"studentT\",{enumerable:true,get:function(){return studentT;}});\nObject.defineProperty(__exports,\"studentTQuantile\",{enumerable:true,get:function(){return studentTQuantile;}});\nObject.defineProperty(__exports,\"regularizedGammaP\",{enumerable:true,get:function(){return regularizedGammaP;}});\nObject.defineProperty(__exports,\"chiSquareCdf\",{enumerable:true,get:function(){return chiSquareCdf;}});\nObject.defineProperty(__exports,\"chiSquareUpperTail\",{enumerable:true,get:function(){return chiSquareUpperTail;}});\nconst LANCZOS=Object.freeze([\n676.5203681218851,-1259.1392167224028,771.32342877765313,\n-176.61502916214059,12.507343278686905,-0.13857109526572012,\n9.9843695780195716e-6,1.5056327351493116e-7,\n]);\nconst EPS=3e-12;\nconst TINY=1e-300;\nfunction logGamma(x){\nif(x<0.5)return Math.log(Math.PI/Math.sin(Math.PI*x))-logGamma(1-x);\nconst z=x-1;\nlet a=0.99999999999980993;\nconst t=z+7.5;\nfor(let i=0;i<LANCZOS.length;i++)a+=LANCZOS[i]/(z+i+1);\nreturn 0.5*Math.log(2*Math.PI)+(z+0.5)*Math.log(t)-t+Math.log(a);\n}\nfunction betaContinuedFraction(a,b,x){\nconst qab=a+b;\nconst qap=a+1;\nconst qam=a-1;\nlet c=1;\nlet d=1-(qab*x)/qap;\nif(Math.abs(d)<TINY)d=TINY;\nd=1/d;\nlet h=d;\nfor(let m=1;m<=300;m++){\nconst m2=2*m;\nlet aa=(m*(b-m)*x)/((qam+m2)*(a+m2));\nd=1+aa*d;\nif(Math.abs(d)<TINY)d=TINY;\nc=1+aa/c;\nif(Math.abs(c)<TINY)c=TINY;\nd=1/d;\nh*=d*c;\naa=(-(a+m)*(qab+m)*x)/((a+m2)*(qap+m2));\nd=1+aa*d;\nif(Math.abs(d)<TINY)d=TINY;\nc=1+aa/c;\nif(Math.abs(c)<TINY)c=TINY;\nd=1/d;\nconst step=d*c;\nh*=step;\nif(Math.abs(step-1)<EPS)break;\n}\nreturn h;\n}\nfunction incompleteBeta(a,b,x){\nif(!(a>0)||!(b>0)||!Number.isFinite(x))return Number.NaN;\nif(x<=0)return 0;\nif(x>=1)return 1;\nconst front=Math.exp(\nlogGamma(a+b)-logGamma(a)-logGamma(b)+a*Math.log(x)+b*Math.log(1-x),\n);\nreturn x<(a+1)/(a+b+2)\n?(front*betaContinuedFraction(a,b,x))/a\n:1-(front*betaContinuedFraction(b,a,1-x))/b;\n}\nfunction normalQuantile(p){\nif(!(p>0)||!(p<1))return p===0?-Infinity:(p===1?Infinity:Number.NaN);\nconst a=[-3.969683028665376e+1,2.209460984245205e+2,-2.759285104469687e+2,\n1.383577518672690e+2,-3.066479806614716e+1,2.506628277459239];\nconst b=[-5.447609879822406e+1,1.615858368580409e+2,-1.556989798598866e+2,\n6.680131188771972e+1,-1.328068155288572e+1];\nconst c=[-7.784894002430293e-3,-3.223964580411365e-1,-2.400758277161838,\n-2.549732539343734,4.374664141464968,2.938163982698783];\nconst d=[7.784695709041462e-3,3.224671290700398e-1,2.445134137142996,\n3.754408661907416];\nconst low=0.02425;\nlet q;\nlet r;\nlet x;\nif(p<low){\nq=Math.sqrt(-2*Math.log(p));\nx=(((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5])\n/ ((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1);\n}else if(p<=1-low){\nq=p-0.5;\nr=q*q;\nx=((((((a[0]*r+a[1])*r+a[2])*r+a[3])*r+a[4])*r+a[5])*q)\n/ (((((b[0] * r + b[1]) * r + b[2]) * r + b[3]) * r + b[4]) * r + 1);\n}else{\nq=Math.sqrt(-2*Math.log(1-p));\nx=-(((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5])\n/ ((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1);\n}\nconst e=0.5*erfc(-x/Math.SQRT2)-p;\nconst u=e*Math.sqrt(2*Math.PI)*Math.exp((x*x)/2);\nreturn x-u/(1+(x*u)/2);\n}\nfunction erfc(x){\nconst z=Math.abs(x);\nconst t=2/(2+z);\nconst ty=4*t-2;\nconst cof=[-1.3026537197817094,6.4196979235649026e-1,1.9476473204185836e-2,\n-9.561514786808631e-3,-9.46595344482036e-4,3.66839497852761e-4,\n4.2523324806907e-5,-2.0278578112534e-5,-1.624290004647e-6,\n1.303655835580e-6,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,\n5.059343495e-9,-9.91364156e-10,-2.27365122e-10,9.6467911e-11,\n2.394038e-12,-6.886027e-12,8.94487e-13,3.13092e-13,-1.12708e-13,\n3.81e-16,7.106e-15];\nlet dd=0;\nlet dv=0;\nlet tmp;\nfor(let j=cof.length-1;j>0;j--){\ntmp=dv;\ndv=ty*dv-dd+cof[j];\ndd=tmp;\n}\nconst ans=t*Math.exp(-z*z+0.5*(cof[0]+ty*dv)-dd);\nreturn x>=0?ans:2-ans;\n}\nfunction normalCdf(x){\nreturn 0.5*erfc(-x/Math.SQRT2);\n}\nfunction studentT(t,df){\nif(!(df>0)||!Number.isFinite(t))return Number.NaN;\nconst tail=0.5*incompleteBeta(df/2,0.5,df/(df+t*t));\nreturn t>0?1-tail:tail;\n}\nfunction studentTQuantile(p,df){\nif(!(p>0)||!(p<1)||!(df>0))return Number.NaN;\nif(df>1e7)return normalQuantile(p);\nlet lo=-1e4;\nlet hi=1e4;\nlet x=normalQuantile(p);\nconst logBeta=logGamma(df/2)+logGamma(0.5)-logGamma((df+1)/2);\nfor(let i=0;i<60;i++){\nconst cdf=studentT(x,df);\nif(cdf<p)lo=x;else hi=x;\nconst pdf=Math.exp(-((df+1)/2)*Math.log(1+(x*x)/df)-logBeta)\n/ Math.sqrt(df);\nconst step=pdf>0?(cdf-p)/pdf:0;\nif(Math.abs(step)<1e-12)break;\nconst next=x-step;\nx=next>lo&&next<hi&&Number.isFinite(next)?next:(lo+hi)/2;\nif(hi-lo<1e-12)break;\n}\nreturn x;\n}\nfunction gammaSeries(a,x){\nlet ap=a;\nlet sum=1/a;\nlet del=sum;\nfor(let n=0;n<300;n++){\nap+=1;\ndel*=x/ap;\nsum+=del;\nif(Math.abs(del)<Math.abs(sum)*EPS)break;\n}\nreturn sum*Math.exp(-x+a*Math.log(x)-logGamma(a));\n}\nfunction gammaContinuedFraction(a,x){\nlet b=x+1-a;\nlet c=1/TINY;\nlet d=1/b;\nlet h=d;\nfor(let i=1;i<=300;i++){\nconst an=-i*(i-a);\nb+=2;\nd=an*d+b;\nif(Math.abs(d)<TINY)d=TINY;\nc=b+an/c;\nif(Math.abs(c)<TINY)c=TINY;\nd=1/d;\nconst del=d*c;\nh*=del;\nif(Math.abs(del-1)<EPS)break;\n}\nreturn Math.exp(-x+a*Math.log(x)-logGamma(a))*h;\n}\nfunction regularizedGammaP(a,x){\nif(!(a>0)||!(x>=0)||!Number.isFinite(x))return Number.NaN;\nif(x===0)return 0;\nreturn x<a+1?gammaSeries(a,x):1-gammaContinuedFraction(a,x);\n}\nfunction chiSquareCdf(x,df){\nif(!(df>0))return Number.NaN;\nreturn regularizedGammaP(df/2,x/2);\n}\nfunction chiSquareUpperTail(x,df){\nconst cdf=chiSquareCdf(x,df);\nreturn Number.isNaN(cdf)?Number.NaN:Math.min(1,Math.max(0,1-cdf));\n}\n});\n__def(\"packages/core/src/compute/sketch.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"Welford\",{enumerable:true,get:function(){return Welford;}});\nObject.defineProperty(__exports,\"Reservoir\",{enumerable:true,get:function(){return Reservoir;}});\nObject.defineProperty(__exports,\"hash32\",{enumerable:true,get:function(){return hash32;}});\nObject.defineProperty(__exports,\"HyperLogLog\",{enumerable:true,get:function(){return HyperLogLog;}});\nObject.defineProperty(__exports,\"SpaceSaving\",{enumerable:true,get:function(){return SpaceSaving;}});\nObject.defineProperty(__exports,\"KLL\",{enumerable:true,get:function(){return KLL;}});\nObject.defineProperty(__exports,\"SKETCH_BOUNDS\",{enumerable:true,get:function(){return SKETCH_BOUNDS;}});\nObject.defineProperty(__exports,\"default\",{enumerable:true,get:function(){return __default;}});\nclass Welford{\n#n=0;\n#mean=0;\n#m2=0;\nstatic get errorBound(){\nreturn Object.freeze({\nkind:'exact',metric:'none',value:0,\nstatement:'mean and variance match a full recompute to float rounding',\n});\n}\nget count(){return this.#n;}\nadd(x){\nif(!Number.isFinite(x))return;\nthis.#n++;\nconst delta=x-this.#mean;\nthis.#mean+=delta/this.#n;\nthis.#m2+=delta*(x-this.#mean);\n}\nmerge(other){\nif(other.#n===0)return;\nif(this.#n===0){this.#n=other.#n;this.#mean=other.#mean;this.#m2=other.#m2;return;}\nconst n=this.#n+other.#n;\nconst delta=other.#mean-this.#mean;\nthis.#mean+=delta*(other.#n/n);\nthis.#m2+=other.#m2+delta*delta*(this.#n*other.#n/n);\nthis.#n=n;\n}\nmean(){return this.#n?this.#mean:null;}\nvariance(){return this.#n>1?this.#m2/(this.#n-1):null;}\nvarianceP(){return this.#n?this.#m2/this.#n:null;}\nstddev(){const v=this.variance();return v===null?null:Math.sqrt(v);}\nstddevP(){const v=this.varianceP();return v===null?null:Math.sqrt(v);}\n}\nclass Reservoir{\n#items=[];\n#seen=0;\n#capacity;\n#rng;\nconstructor(capacity,rng=Math.random){\nif(!(capacity>0))throw new RangeError('reservoir capacity must be positive');\nthis.#capacity=Math.floor(capacity);\nthis.#rng=rng;\n}\nstatic get errorBound(){\nreturn Object.freeze({\nkind:'probabilistic',metric:'none',value:0,\nstatement:'uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators',\n});\n}\nget seen(){return this.#seen;}\nget size(){return this.#items.length;}\nadd(x){\nif(!Number.isFinite(x))return;\nthis.#seen++;\nif(this.#items.length<this.#capacity){\nthis.#items.push(x);\nreturn;\n}\nconst j=Math.floor(this.#rng()*this.#seen);\nif(j<this.#capacity)this.#items[j]=x;\n}\nsample(){return this.#items.slice();}\nmean(){\nif(!this.#items.length)return null;\nlet s=0;\nfor(const v of this.#items)s+=v;\nreturn s/this.#items.length;\n}\nquantile(p){\nconst n=this.#items.length;\nif(!n)return null;\nconst sorted=this.#items.slice().sort((a,b)=>a-b);\nif(n===1)return sorted[0];\nconst h=(n-1)*Math.min(1,Math.max(0,p));\nconst lo=Math.floor(h);\nconst hi=Math.ceil(h);\nreturn lo===hi?sorted[lo]:sorted[lo]+(h-lo)*(sorted[hi]-sorted[lo]);\n}\n}\nfunction fmix32(h){\nh^=h>>>16;\nh=Math.imul(h,0x85ebca6b);\nh^=h>>>13;\nh=Math.imul(h,0xc2b2ae35);\nh^=h>>>15;\nreturn h>>>0;\n}\nfunction hash32(v){\nif(typeof v==='number'){\nconst buf=new DataView(new ArrayBuffer(8));\nbuf.setFloat64(0,v===0?0:v);\nreturn fmix32(buf.getUint32(0)^buf.getUint32(4));\n}\nconst s=typeof v==='string'?v:String(v);\nlet h=0x811c9dc5;\nfor(let i=0;i<s.length;i++){\nh^=s.charCodeAt(i);\nh=Math.imul(h,0x01000193);\n}\nreturn fmix32(h);\n}\nclass HyperLogLog{\n#p;\n#m;\n#registers;\nconstructor(precision=14){\nconst p=Math.floor(precision);\nif(p<4||p>16)throw new RangeError('HLL precision must be 4..16');\nthis.#p=p;\nthis.#m=1<<p;\nthis.#registers=new Uint8Array(this.#m);\n}\nstatic errorBoundFor(precision=14){\nconst m=1<<Math.floor(precision);\nconst rse=1.04/Math.sqrt(m);\nreturn Object.freeze({\nkind:'probabilistic',metric:'relative',value:rse,\nstatement:`distinct count within ~${(rse*100).toFixed(2)}% relative standard error (m=${m} buckets)`,\n});\n}\nerrorBound(){return HyperLogLog.errorBoundFor(this.#p);}\nadd(v){\nconst h=hash32(v);\nconst idx=h&(this.#m-1);\nconst rest=(h>>>this.#p)|(1<<(32-this.#p));\nlet rank=1;\nlet x=rest;\nwhile((x&1)===0){rank++;x>>>=1;}\nif(rank>this.#registers[idx])this.#registers[idx]=rank;\n}\ncount(){\nconst m=this.#m;\nconst q=32-this.#p;\nconst hist=new Float64Array(q+2);\nfor(let i=0;i<m;i++)hist[this.#registers[i]]++;\nlet z=m*tau(1-hist[q+1]/m);\nfor(let k=q;k>=1;k--)z=0.5*(z+hist[k]);\nz+=m*sigma(hist[0]/m);\nconst estimate=(ERTL_ALPHA_INF*m*m)/z;\nreturn Math.round(estimate);\n}\n}\nconst ERTL_ALPHA_INF=0.5/Math.log(2);\nfunction sigma(x){\nif(x===1)return Infinity;\nlet y=1;\nlet z=x;\nlet prev;\ndo{\nx*=x;\nprev=z;\nz+=x*y;\ny+=y;\n}while(z!==prev);\nreturn z;\n}\nfunction tau(x){\nif(x===0||x===1)return 0;\nlet y=1;\nlet z=1-x;\nlet prev;\ndo{\nx=Math.sqrt(x);\nprev=z;\ny*=0.5;\nz-=(1-x)**2*y;\n}while(z!==prev);\nreturn z/3;\n}\nclass SpaceSaving{\n#counters=new Map();\n#capacity;\n#n=0;\nconstructor(capacity){\nif(!(capacity>0))throw new RangeError('Space-Saving capacity must be positive');\nthis.#capacity=Math.floor(capacity);\n}\nerrorBoundFor(n){\nconst value=n/this.#capacity;\nreturn Object.freeze({\nkind:'deterministic',metric:'absolute',value,\nstatement:`each count overestimates the truth by at most N/m = ${value.toFixed(2)} (N=${n}, m=${this.#capacity})`,\n});\n}\nget seen(){return this.#n;}\nadd(item){\nthis.#n++;\nconst existing=this.#counters.get(item);\nif(existing){existing.count++;return;}\nif(this.#counters.size<this.#capacity){\nthis.#counters.set(item,{count:1,error:0});\nreturn;\n}\nlet minItem;\nlet minCount=Infinity;\nfor(const[k,v]of this.#counters){\nif(v.count<minCount){minCount=v.count;minItem=k;}\n}\nthis.#counters.delete(minItem);\nthis.#counters.set(item,{count:minCount+1,error:minCount});\n}\ntop(k=this.#capacity){\nconst all=[...this.#counters.entries()]\n.map(([item,v])=>({item,count:v.count,error:v.error}))\n.sort((a,b)=>b.count-a.count);\nreturn all.slice(0,Math.max(0,Math.floor(k)));\n}\n}\nclass KLL{\n#k;\n#levels=[[]];\n#n=0;\n#rng;\n#capacityFactor;\nconstructor(k=200,rng=Math.random){\nthis.#k=Math.max(8,Math.floor(k));\nthis.#rng=rng;\nthis.#capacityFactor=2/3;\n}\nstatic errorBoundFor(k=200){\nconst eps=1/Math.max(8,Math.floor(k));\nreturn Object.freeze({\nkind:'probabilistic',metric:'rank',value:eps,\nstatement:`queried quantile's true rank within ~${(eps*100).toFixed(2)}% of N of the requested rank (k=${k})`,\n});\n}\nerrorBound(){return KLL.errorBoundFor(this.#k);}\nget count(){return this.#n;}\n#levelCapacity(height){\nconst top=this.#levels.length-1;\nconst depthFromTop=top-height;\nconst cap=Math.ceil(this.#k*this.#capacityFactor**depthFromTop);\nreturn Math.max(2,cap);\n}\nadd(x){\nif(!Number.isFinite(x))return;\nthis.#n++;\nthis.#levels[0].push(x);\nif(this.#levels[0].length>=this.#levelCapacity(0))this.#compact(0);\n}\n#compact(height){\nconst level=this.#levels[height];\nlevel.sort((a,b)=>a-b);\nif(height+1>=this.#levels.length)this.#levels.push([]);\nconst up=this.#levels[height+1];\nconst offset=this.#rng()<0.5?0:1;\nfor(let i=offset;i<level.length;i+=2)up.push(level[i]);\nthis.#levels[height]=[];\nfor(let h=0;h<this.#levels.length;h++){\nif(this.#levels[h].length>=this.#levelCapacity(h)){this.#compact(h);return;}\n}\n}\n#weighted(){\nconst out=[];\nfor(let h=0;h<this.#levels.length;h++){\nconst w=1<<h;\nfor(const v of this.#levels[h])out.push({v,w});\n}\nreturn out;\n}\nquantile(p){\nconst items=this.#weighted();\nif(!items.length)return null;\nitems.sort((a,b)=>a.v-b.v);\nlet totalW=0;\nfor(const it of items)totalW+=it.w;\nconst target=Math.min(1,Math.max(0,p))*totalW;\nlet cum=0;\nfor(const it of items){\ncum+=it.w;\nif(cum>=target)return it.v;\n}\nreturn items[items.length-1].v;\n}\nrank(x){\nlet cum=0;\nfor(let h=0;h<this.#levels.length;h++){\nconst w=1<<h;\nfor(const v of this.#levels[h])if(v<=x)cum+=w;\n}\nreturn cum;\n}\n}\nconst SKETCH_BOUNDS=Object.freeze({\ndistinct:HyperLogLog.errorBoundFor(14),\nmedian:KLL.errorBoundFor(200),\np25:KLL.errorBoundFor(200),\np75:KLL.errorBoundFor(200),\np90:KLL.errorBoundFor(200),\np95:KLL.errorBoundFor(200),\np99:KLL.errorBoundFor(200),\niqr:KLL.errorBoundFor(200),\ntopK:Object.freeze({\nkind:'deterministic',metric:'absolute',value:0,\nstatement:'each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m',\n}),\n});\nconst __default={\nWelford,Reservoir,HyperLogLog,SpaceSaving,KLL,hash32,SKETCH_BOUNDS,\n};\n});\n__def(\"packages/core/src/compute/statistics.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"KENDALL_LIMIT\",{enumerable:true,get:function(){return KENDALL_LIMIT;}});\nObject.defineProperty(__exports,\"MAINTENANCE\",{enumerable:true,get:function(){return MAINTENANCE;}});\nObject.defineProperty(__exports,\"APPROXIMATE\",{enumerable:true,get:function(){return APPROXIMATE;}});\nObject.defineProperty(__exports,\"maintenanceOf\",{enumerable:true,get:function(){return maintenanceOf;}});\nObject.defineProperty(__exports,\"numbers\",{enumerable:true,get:function(){return numbers;}});\nObject.defineProperty(__exports,\"frequencies\",{enumerable:true,get:function(){return frequencies;}});\nObject.defineProperty(__exports,\"herfindahl\",{enumerable:true,get:function(){return herfindahl;}});\nObject.defineProperty(__exports,\"entropy\",{enumerable:true,get:function(){return entropy;}});\nObject.defineProperty(__exports,\"evenness\",{enumerable:true,get:function(){return evenness;}});\nObject.defineProperty(__exports,\"topShare\",{enumerable:true,get:function(){return topShare;}});\nObject.defineProperty(__exports,\"gini\",{enumerable:true,get:function(){return gini;}});\nObject.defineProperty(__exports,\"moments\",{enumerable:true,get:function(){return moments;}});\nObject.defineProperty(__exports,\"quantileSorted\",{enumerable:true,get:function(){return quantileSorted;}});\nObject.defineProperty(__exports,\"quantile\",{enumerable:true,get:function(){return quantile;}});\nObject.defineProperty(__exports,\"STAT_FNS\",{enumerable:true,get:function(){return STAT_FNS;}});\nObject.defineProperty(__exports,\"STAT_LABELS\",{enumerable:true,get:function(){return STAT_LABELS;}});\nObject.defineProperty(__exports,\"weightedAverage\",{enumerable:true,get:function(){return weightedAverage;}});\nObject.defineProperty(__exports,\"extremeRow\",{enumerable:true,get:function(){return extremeRow;}});\nObject.defineProperty(__exports,\"correlation\",{enumerable:true,get:function(){return correlation;}});\nObject.defineProperty(__exports,\"trimmedMean\",{enumerable:true,get:function(){return trimmedMean;}});\nObject.defineProperty(__exports,\"winsorizedMean\",{enumerable:true,get:function(){return winsorizedMean;}});\nObject.defineProperty(__exports,\"modifiedZOutliers\",{enumerable:true,get:function(){return modifiedZOutliers;}});\nObject.defineProperty(__exports,\"jarqueBera\",{enumerable:true,get:function(){return jarqueBera;}});\nObject.defineProperty(__exports,\"weightedQuantile\",{enumerable:true,get:function(){return weightedQuantile;}});\nObject.defineProperty(__exports,\"pairs\",{enumerable:true,get:function(){return pairs;}});\nObject.defineProperty(__exports,\"covariance\",{enumerable:true,get:function(){return covariance;}});\nObject.defineProperty(__exports,\"regression\",{enumerable:true,get:function(){return regression;}});\nObject.defineProperty(__exports,\"spearman\",{enumerable:true,get:function(){return spearman;}});\nObject.defineProperty(__exports,\"kendall\",{enumerable:true,get:function(){return kendall;}});\nObject.defineProperty(__exports,\"seriesStats\",{enumerable:true,get:function(){return seriesStats;}});\nObject.defineProperty(__exports,\"D2_N2\",{enumerable:true,get:function(){return D2_N2;}});\nObject.defineProperty(__exports,\"D4_N2\",{enumerable:true,get:function(){return D4_N2;}});\nObject.defineProperty(__exports,\"movingRanges\",{enumerable:true,get:function(){return movingRanges;}});\nObject.defineProperty(__exports,\"withinSigma\",{enumerable:true,get:function(){return withinSigma;}});\nObject.defineProperty(__exports,\"capability\",{enumerable:true,get:function(){return capability;}});\nObject.defineProperty(__exports,\"controlLimits\",{enumerable:true,get:function(){return controlLimits;}});\nObject.defineProperty(__exports,\"westernElectricViolations\",{enumerable:true,get:function(){return westernElectricViolations;}});\nObject.defineProperty(__exports,\"nelsonViolations\",{enumerable:true,get:function(){return nelsonViolations;}});\nObject.defineProperty(__exports,\"CONTROL_RULE_SETS\",{enumerable:true,get:function(){return CONTROL_RULE_SETS;}});\nObject.defineProperty(__exports,\"controlViolations\",{enumerable:true,get:function(){return controlViolations;}});\nObject.defineProperty(__exports,\"countOutside\",{enumerable:true,get:function(){return countOutside;}});\nObject.defineProperty(__exports,\"histogram\",{enumerable:true,get:function(){return histogram;}});\nObject.defineProperty(__exports,\"DEFAULT_CONFIDENCE\",{enumerable:true,get:function(){return DEFAULT_CONFIDENCE;}});\nObject.defineProperty(__exports,\"meanInterval\",{enumerable:true,get:function(){return meanInterval;}});\nObject.defineProperty(__exports,\"proportionInterval\",{enumerable:true,get:function(){return proportionInterval;}});\nObject.defineProperty(__exports,\"slopeInterval\",{enumerable:true,get:function(){return slopeInterval;}});\nObject.defineProperty(__exports,\"capabilityInterval\",{enumerable:true,get:function(){return capabilityInterval;}});\nObject.defineProperty(__exports,\"standardizedMeanDifference\",{enumerable:true,get:function(){return standardizedMeanDifference;}});\nObject.defineProperty(__exports,\"normalTotalVariation\",{enumerable:true,get:function(){return normalTotalVariation;}});\nObject.defineProperty(__exports,\"frequencyMap\",{enumerable:true,get:function(){return frequencyMap;}});\nObject.defineProperty(__exports,\"categoricalDistance\",{enumerable:true,get:function(){return categoricalDistance;}});\nObject.defineProperty(__exports,\"SUBSET_RELIABILITY_FLOOR\",{enumerable:true,get:function(){return SUBSET_RELIABILITY_FLOOR;}});\nObject.defineProperty(__exports,\"compareColumn\",{enumerable:true,get:function(){return compareColumn;}});\nObject.defineProperty(__exports,\"isNumericColumn\",{enumerable:true,get:function(){return isNumericColumn;}});\nObject.defineProperty(__exports,\"populationRead\",{enumerable:true,get:function(){return populationRead;}});\nconst __m0=__req(\"packages/core/src/compute/handle.js\");\nconst presenceReader=__m0[\"presenceReader\"];\nconst valueReader=__m0[\"valueReader\"];\nconst __m1=__req(\"packages/core/src/compute/special.js\");\nconst studentTQuantile=__m1[\"studentTQuantile\"];\nconst normalQuantile=__m1[\"normalQuantile\"];\nconst normalCdf=__m1[\"normalCdf\"];\nconst __m2=__req(\"packages/core/src/compute/sketch.js\");\nconst SKETCH_BOUNDS=__m2[\"SKETCH_BOUNDS\"];\nconst KENDALL_LIMIT=5000;\nconst MAINTENANCE=Object.freeze({\nvariance:'rescan',\nvarianceP:'rescan',\nstddev:'rescan',\nstddevP:'rescan',\nsumSquares:'rescan',\nweightedAvg:'rescan',\nmedian:'rescan',\np25:'rescan',\np75:'rescan',\np90:'rescan',\np95:'rescan',\np99:'rescan',\niqr:'rescan',\nmode:'rescan',\ndistinct:'rescan',\nrange:'rescan',\nskewness:'rescan',\nkurtosis:'rescan',\ngeomean:'rescan',\nharmean:'rescan',\nmad:'rescan',\nargmin:'rescan',\nargmax:'rescan',\nhhi:'rescan',\nentropy:'rescan',\nevenness:'rescan',\ntop3Share:'rescan',\ntop10Share:'rescan',\ngini:'rescan',\ntrimmedMean:'rescan',\nwinsorizedMean:'rescan',\nrobustOutliers:'rescan',\njarqueBera:'rescan',\npassRate:'rescan',\nfailureCount:'rescan',\n});\nconst APPROXIMATE=Object.freeze({\ndistinct:Object.freeze({sketch:'HyperLogLog',bound:SKETCH_BOUNDS.distinct}),\nmedian:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.median}),\np25:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.p25}),\np75:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.p75}),\np90:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.p90}),\np95:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.p95}),\np99:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.p99}),\niqr:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.iqr}),\ntop3Share:Object.freeze({sketch:'SpaceSaving',bound:SKETCH_BOUNDS.topK}),\ntop10Share:Object.freeze({sketch:'SpaceSaving',bound:SKETCH_BOUNDS.topK}),\n});\nfunction maintenanceOf(fn){\nconst exact=fn==='sum'||fn==='avg'||fn==='countValues'||fn==='min'||fn==='max'\n?'maintained'\n:(Object.prototype.hasOwnProperty.call(MAINTENANCE,fn)?MAINTENANCE[fn]:null);\nconst approximate=Object.prototype.hasOwnProperty.call(APPROXIMATE,fn)?APPROXIMATE[fn]:null;\nreturn{stat:fn,exact,approximate};\n}\nfunction numbers(handle,indices){\nconst n=indices.length;\nconst out=new Float64Array(n);\nlet count=0;\nconst numeric=handle&&(handle.kind==='float64'||handle.kind==='int32');\nif(numeric){\nconst values=handle.values;\nconst present=presenceReader(handle);\nfor(let i=0;i<n;i++){\nconst row=indices[i];\nif(present&&present(row)!==1)continue;\nconst v=values[row];\nif(Number.isNaN(v))continue;\nout[count++]=v;\n}\nreturn out.subarray(0,count);\n}\nconst read=valueReader(handle);\nfor(let i=0;i<n;i++){\nconst raw=read(indices[i]);\nif(raw===null||raw===undefined||raw==='')continue;\nconst v=typeof raw==='number'?raw:Number(raw);\nif(!Number.isFinite(v))continue;\nout[count++]=v;\n}\nreturn out.subarray(0,count);\n}\nfunction frequencies(handle,indices){\nconst seen=new Map();\nconst read=valueReader(handle);\nlet total=0;\nfor(let i=0;i<indices.length;i++){\nconst raw=read(indices[i]);\nif(raw===null||raw===undefined||raw==='')continue;\nif(typeof raw==='number'&&Number.isNaN(raw))continue;\nconst key=typeof raw==='object'?String(raw):raw;\nseen.set(key,(seen.get(key)||0)+1);\ntotal++;\n}\nconst counts=[...seen.values()].sort((a,b)=>b-a);\nreturn{counts,total,distinct:counts.length};\n}\nfunction sharesOf(freq){\nreturn freq.total>0?freq.counts.map((c)=>c/freq.total):[];\n}\nfunction herfindahl(handle,indices){\nconst freq=frequencies(handle,indices);\nif(!freq.total)return null;\nlet sum=0;\nfor(const share of sharesOf(freq))sum+=share*share;\nreturn sum;\n}\nfunction entropy(handle,indices){\nconst freq=frequencies(handle,indices);\nif(!freq.total)return null;\nlet sum=0;\nfor(const share of sharesOf(freq))if(share>0)sum-=share*Math.log2(share);\nreturn sum;\n}\nfunction evenness(handle,indices){\nconst freq=frequencies(handle,indices);\nif(!freq.total||freq.distinct<2)return freq.total?1:null;\nlet sum=0;\nfor(const share of sharesOf(freq))if(share>0)sum-=share*Math.log2(share);\nreturn sum/Math.log2(freq.distinct);\n}\nfunction topShare(handle,indices,n=3){\nconst freq=frequencies(handle,indices);\nif(!freq.total)return null;\nconst take=Math.max(1,Math.floor(n));\nlet held=0;\nfor(let i=0;i<Math.min(take,freq.counts.length);i++)held+=freq.counts[i];\nreturn held/freq.total;\n}\nfunction gini(handle,indices){\nconst values=numbers(handle,indices);\nconst n=values.length;\nif(!n)return null;\nconst sorted=values.slice().sort();\nif(sorted[0]<0)return null;\nlet total=0;\nlet weighted=0;\nfor(let i=0;i<n;i++){\ntotal+=sorted[i];\nweighted+=(i+1)*sorted[i];\n}\nif(total===0)return 0;\nreturn(2*weighted)/(n*total)-(n+1)/n;\n}\nfunction moments(values){\nlet n=0;\nlet mean=0;\nlet m2=0;\nfor(let i=0;i<values.length;i++){\nconst x=values[i];\nn++;\nconst delta=x-mean;\nmean+=delta/n;\nm2+=delta*(x-mean);\n}\nreturn{n,mean,m2};\n}\nfunction quantileSorted(sorted,p){\nconst n=sorted.length;\nif(!n)return NaN;\nif(n===1)return sorted[0];\nconst h=(n-1)*Math.min(1,Math.max(0,p));\nconst lo=Math.floor(h);\nconst hi=Math.ceil(h);\nif(lo===hi)return sorted[lo];\nreturn sorted[lo]+(h-lo)*(sorted[hi]-sorted[lo]);\n}\nfunction quantile(values,p){\nif(!values.length)return NaN;\nconst sorted=values.slice().sort();\nreturn quantileSorted(sorted,p);\n}\nfunction specTally(handle,indices){\nconst read=valueReader(handle);\nlet pass=0;\nlet fail=0;\nlet warn=0;\nfor(let k=0;k<indices.length;k++){\nconst raw=read(indices[k]);\nif(raw===null||raw===undefined||raw==='')continue;\nconst token=String(raw).toUpperCase();\nif(token==='PASS')pass++;\nelse if(token==='FAIL')fail++;\nelse if(token==='WARN')warn++;\n}\nreturn{pass:pass+warn,fail,warn,judged:pass+warn+fail};\n}\nconst STAT_FNS=Object.freeze({\nhhi:(h,i)=>herfindahl(h,i),\nentropy:(h,i)=>entropy(h,i),\nevenness:(h,i)=>evenness(h,i),\ntop3Share:(h,i)=>topShare(h,i,3),\ntop10Share:(h,i)=>topShare(h,i,10),\ngini:(h,i)=>gini(h,i),\ntrimmedMean:(h,i)=>trimmedMean(numbers(h,i),0.1),\nwinsorizedMean:(h,i)=>winsorizedMean(numbers(h,i),0.1),\nrobustOutliers:(h,i)=>modifiedZOutliers(numbers(h,i),3.5),\njarqueBera:(h,i)=>jarqueBera(numbers(h,i)),\nvariance:(h,i)=>{\nconst{n,m2}=moments(numbers(h,i));\nreturn n>1?m2/(n-1):null;\n},\nvarianceP:(h,i)=>{\nconst{n,m2}=moments(numbers(h,i));\nreturn n>0?m2/n:null;\n},\nstddev:(h,i)=>{\nconst{n,m2}=moments(numbers(h,i));\nreturn n>1?Math.sqrt(m2/(n-1)):null;\n},\nstddevP:(h,i)=>{\nconst{n,m2}=moments(numbers(h,i));\nreturn n>0?Math.sqrt(m2/n):null;\n},\nmedian:(h,i)=>{\nconst values=numbers(h,i);\nreturn values.length?quantile(values,0.5):null;\n},\np25:(h,i)=>{\nconst values=numbers(h,i);\nreturn values.length?quantile(values,0.25):null;\n},\np75:(h,i)=>{\nconst values=numbers(h,i);\nreturn values.length?quantile(values,0.75):null;\n},\np90:(h,i)=>{\nconst values=numbers(h,i);\nreturn values.length?quantile(values,0.9):null;\n},\np95:(h,i)=>{\nconst values=numbers(h,i);\nreturn values.length?quantile(values,0.95):null;\n},\np99:(h,i)=>{\nconst values=numbers(h,i);\nreturn values.length?quantile(values,0.99):null;\n},\niqr:(h,i)=>{\nconst values=numbers(h,i);\nif(!values.length)return null;\nconst sorted=values.slice().sort();\nreturn quantileSorted(sorted,0.75)-quantileSorted(sorted,0.25);\n},\nmad:(h,i)=>{\nconst values=numbers(h,i);\nif(!values.length)return null;\nconst middle=quantile(values,0.5);\nconst deviations=new Float64Array(values.length);\nfor(let k=0;k<values.length;k++)deviations[k]=Math.abs(values[k]-middle);\nreturn quantile(deviations,0.5);\n},\nrange:(h,i)=>{\nconst values=numbers(h,i);\nif(!values.length)return null;\nlet lo=Infinity;\nlet hi=-Infinity;\nfor(let k=0;k<values.length;k++){\nif(values[k]<lo)lo=values[k];\nif(values[k]>hi)hi=values[k];\n}\nreturn hi-lo;\n},\ndistinct:(h,i)=>{\nconst read=valueReader(h);\nconst seen=new Set();\nfor(let k=0;k<i.length;k++){\nconst v=read(i[k]);\nif(v===null||v===undefined||v==='')continue;\nseen.add(v instanceof Date?v.getTime():v);\n}\nreturn seen.size;\n},\nmode:(h,i)=>{\nconst read=valueReader(h);\nconst counts=new Map();\nfor(let k=0;k<i.length;k++){\nconst v=read(i[k]);\nif(v===null||v===undefined||v==='')continue;\nconst id=v instanceof Date?v.getTime():v;\ncounts.set(id,(counts.get(id)||0)+1);\n}\nlet best=null;\nlet most=1;\nfor(const[value,times]of counts){\nif(times>most){\nmost=times;\nbest=value;\n}\n}\nreturn best;\n},\nskewness:(h,i)=>{\nconst values=numbers(h,i);\nconst{n,mean,m2}=moments(values);\nif(n<3||m2<=0)return null;\nconst sd=Math.sqrt(m2/(n-1));\nlet sum=0;\nfor(let k=0;k<values.length;k++)sum+=((values[k]-mean)/sd)**3;\nreturn(n/((n-1)*(n-2)))*sum;\n},\nkurtosis:(h,i)=>{\nconst values=numbers(h,i);\nconst{n,mean,m2}=moments(values);\nif(n<4||m2<=0)return null;\nconst sd=Math.sqrt(m2/(n-1));\nlet sum=0;\nfor(let k=0;k<values.length;k++)sum+=((values[k]-mean)/sd)**4;\nconst a=(n*(n+1))/((n-1)*(n-2)*(n-3));\nconst b=(3*(n-1)**2)/((n-2)*(n-3));\nreturn a*sum-b;\n},\ngeomean:(h,i)=>{\nconst values=numbers(h,i);\nif(!values.length)return null;\nlet sum=0;\nfor(let k=0;k<values.length;k++){\nif(values[k]<=0)return null;\nsum+=Math.log(values[k]);\n}\nreturn Math.exp(sum/values.length);\n},\nharmean:(h,i)=>{\nconst values=numbers(h,i);\nif(!values.length)return null;\nlet sum=0;\nfor(let k=0;k<values.length;k++){\nif(values[k]===0)return null;\nsum+=1/values[k];\n}\nreturn values.length/sum;\n},\nsumSquares:(h,i)=>{\nconst values=numbers(h,i);\nlet sum=0;\nfor(let k=0;k<values.length;k++)sum+=values[k]*values[k];\nreturn sum;\n},\npassRate:(h,i)=>{\nconst{pass,judged}=specTally(h,i);\nreturn judged?pass/judged:null;\n},\nfailureCount:(h,i)=>specTally(h,i).fail,\n});\nconst STAT_LABELS=Object.freeze({\nhhi:'Concentration (HHI)',\nentropy:'Entropy',\nevenness:'Evenness',\ntop3Share:'Top 3 share',\ntop10Share:'Top 10 share',\ngini:'Gini coefficient',\ntrimmedMean:'Trimmed mean',\nwinsorizedMean:'Winsorized mean',\nrobustOutliers:'Outliers (robust)',\njarqueBera:'Jarque–Bera',\nmedian:'Median',\np25:'25th percentile',\np75:'75th percentile',\np90:'90th percentile',\np95:'95th percentile',\np99:'99th percentile',\niqr:'Interquartile range',\nmad:'Median absolute deviation',\nvariance:'Variance',\nvarianceP:'Variance (population)',\nstddev:'Standard deviation',\nstddevP:'Standard deviation (population)',\nrange:'Range',\ndistinct:'Distinct',\nmode:'Mode',\nskewness:'Skewness',\nkurtosis:'Kurtosis',\ngeomean:'Geometric mean',\nharmean:'Harmonic mean',\nsumSquares:'Sum of squares',\nweightedAvg:'Weighted average',\nargmin:'Lowest by',\nargmax:'Highest by',\npassRate:'Pass rate',\nfailureCount:'Failures',\n});\nfunction weightedAverage(handle,weights,indices){\nconst readValue=valueReader(handle);\nconst readWeight=valueReader(weights);\nlet top=0;\nlet bottom=0;\nfor(let i=0;i<indices.length;i++){\nconst row=indices[i];\nconst value=Number(readValue(row));\nconst weight=Number(readWeight(row));\nif(!Number.isFinite(value)||!Number.isFinite(weight))continue;\ntop+=value*weight;\nbottom+=weight;\n}\nreturn bottom===0?null:top/bottom;\n}\nfunction extremeRow(handle,indices,largest){\nconst read=valueReader(handle);\nlet best=null;\nlet bestValue=largest?-Infinity:Infinity;\nfor(let i=0;i<indices.length;i++){\nconst row=indices[i];\nconst value=Number(read(row));\nif(!Number.isFinite(value))continue;\nif(largest?value>bestValue:value<bestValue){\nbestValue=value;\nbest=row;\n}\n}\nreturn best;\n}\nfunction correlation(a,b,indices){\nconst readA=valueReader(a);\nconst readB=valueReader(b);\nlet n=0;\nlet sx=0;\nlet sy=0;\nlet sxx=0;\nlet syy=0;\nlet sxy=0;\nfor(let i=0;i<indices.length;i++){\nconst row=indices[i];\nconst x=Number(readA(row));\nconst y=Number(readB(row));\nif(!Number.isFinite(x)||!Number.isFinite(y))continue;\nn++;\nsx+=x;\nsy+=y;\nsxx+=x*x;\nsyy+=y*y;\nsxy+=x*y;\n}\nif(n<2)return null;\nconst top=n*sxy-sx*sy;\nconst bottom=Math.sqrt((n*sxx-sx*sx)*(n*syy-sy*sy));\nif(bottom===0)return null;\nconst r=top/bottom;\nreturn Math.max(-1,Math.min(1,r));\n}\nfunction trimmedMean(values,share=0.1){\nconst n=values.length;\nif(!n)return null;\nconst sorted=Array.from(values).sort((a,b)=>a-b);\nconst cut=Math.floor(n*Math.min(0.49,Math.max(0,share)));\nconst kept=sorted.slice(cut,n-cut);\nif(!kept.length)return quantileSorted(sorted,0.5);\nlet sum=0;\nfor(const v of kept)sum+=v;\nreturn sum/kept.length;\n}\nfunction winsorizedMean(values,share=0.1){\nconst n=values.length;\nif(!n)return null;\nconst sorted=Array.from(values).sort((a,b)=>a-b);\nconst cut=Math.floor(n*Math.min(0.49,Math.max(0,share)));\nconst low=sorted[cut];\nconst high=sorted[n-1-cut];\nlet sum=0;\nfor(const v of sorted)sum+=Math.min(high,Math.max(low,v));\nreturn sum/n;\n}\nfunction modifiedZOutliers(values,threshold=3.5){\nconst n=values.length;\nif(!n)return null;\nconst sorted=Array.from(values).sort((a,b)=>a-b);\nconst middle=quantileSorted(sorted,0.5);\nconst deviations=sorted.map((v)=>Math.abs(v-middle)).sort((a,b)=>a-b);\nconst mad=quantileSorted(deviations,0.5);\nif(mad===0)return null;\nlet count=0;\nfor(const v of sorted)if(Math.abs((0.6745*(v-middle))/mad)>threshold)count++;\nreturn count;\n}\nfunction jarqueBera(values){\nconst n=values.length;\nif(n<8)return null;\nlet mean=0;\nfor(const v of values)mean+=v;\nmean/=n;\nlet m2=0;\nlet m3=0;\nlet m4=0;\nfor(const v of values){\nconst d=v-mean;\nm2+=d*d;\nm3+=d*d*d;\nm4+=d*d*d*d;\n}\nm2/=n;\nm3/=n;\nm4/=n;\nif(m2===0)return null;\nconst skew=m3/m2**1.5;\nconst excess=m4/(m2*m2)-3;\nreturn(n/6)*(skew*skew+(excess*excess)/4);\n}\nfunction weightedQuantile(values,weights,p){\nconst paired=[];\nlet total=0;\nfor(let i=0;i<values.length;i++){\nconst v=Number(values[i]);\nconst w=Number(weights[i]);\nif(!Number.isFinite(v)||!Number.isFinite(w)||w<=0)continue;\npaired.push([v,w]);\ntotal+=w;\n}\nif(!paired.length||total<=0)return null;\npaired.sort((a,b)=>a[0]-b[0]);\nif(paired.length===1)return paired[0][0];\nconst at=[];\nlet seen=0;\nfor(const[,w]of paired){\nat.push((seen+w/2)/total);\nseen+=w;\n}\nconst target=Math.max(0,Math.min(1,p));\nif(target<=at[0])return paired[0][0];\nif(target>=at[at.length-1])return paired[paired.length-1][0];\nfor(let i=1;i<at.length;i++){\nif(target>at[i])continue;\nconst span=at[i]-at[i-1];\nconst within=span>0?(target-at[i-1])/span:0;\nreturn paired[i-1][0]+(paired[i][0]-paired[i-1][0])*within;\n}\nreturn paired[paired.length-1][0];\n}\nfunction pairs(a,b,indices){\nconst readA=valueReader(a);\nconst readB=valueReader(b);\nconst xs=new Float64Array(indices.length);\nconst ys=new Float64Array(indices.length);\nlet n=0;\nfor(let i=0;i<indices.length;i++){\nconst row=indices[i];\nconst x=Number(readA(row));\nconst y=Number(readB(row));\nif(!Number.isFinite(x)||!Number.isFinite(y))continue;\nxs[n]=x;\nys[n]=y;\nn++;\n}\nreturn{xs:xs.subarray(0,n),ys:ys.subarray(0,n),n};\n}\nfunction covariance(a,b,indices,population=false){\nconst{xs,ys,n}=pairs(a,b,indices);\nif(n<2)return null;\nlet mx=0;\nlet my=0;\nfor(let i=0;i<n;i++){mx+=xs[i];my+=ys[i];}\nmx/=n;\nmy/=n;\nlet sum=0;\nfor(let i=0;i<n;i++)sum+=(xs[i]-mx)*(ys[i]-my);\nreturn sum/(population?n:n-1);\n}\nfunction regression(a,b,indices){\nconst{xs,ys,n}=pairs(a,b,indices);\nif(n<2)return null;\nlet mx=0;\nlet my=0;\nfor(let i=0;i<n;i++){mx+=xs[i];my+=ys[i];}\nmx/=n;\nmy/=n;\nlet sxx=0;\nlet sxy=0;\nlet syy=0;\nfor(let i=0;i<n;i++){\nconst dx=xs[i]-mx;\nconst dy=ys[i]-my;\nsxx+=dx*dx;\nsxy+=dx*dy;\nsyy+=dy*dy;\n}\nif(sxx===0)return null;\nconst slope=sxy/sxx;\nconst intercept=my-slope*mx;\nconst r2=syy===0?1:Math.max(0,Math.min(1,(sxy*sxy)/(sxx*syy)));\nconst residual=Math.max(0,syy-slope*sxy);\nconst stdError=n>2?Math.sqrt(residual/(n-2)/sxx):0;\nreturn{slope,intercept,r2,stdError,n};\n}\nfunction ranksOf(values){\nconst n=values.length;\nconst order=Array.from({length:n},(unused,i)=>i)\n.sort((i,j)=>values[i]-values[j]);\nconst ranks=new Float64Array(n);\nlet i=0;\nwhile(i<n){\nlet j=i;\nwhile(j+1<n&&values[order[j+1]]===values[order[i]])j++;\nconst shared=(i+j)/2+1;\nfor(let k=i;k<=j;k++)ranks[order[k]]=shared;\ni=j+1;\n}\nreturn ranks;\n}\nfunction spearman(a,b,indices){\nconst{xs,ys,n}=pairs(a,b,indices);\nif(n<2)return null;\nconst rx=ranksOf(xs);\nconst ry=ranksOf(ys);\nlet mx=0;\nlet my=0;\nfor(let i=0;i<n;i++){mx+=rx[i];my+=ry[i];}\nmx/=n;\nmy/=n;\nlet sxy=0;\nlet sxx=0;\nlet syy=0;\nfor(let i=0;i<n;i++){\nconst dx=rx[i]-mx;\nconst dy=ry[i]-my;\nsxy+=dx*dy;\nsxx+=dx*dx;\nsyy+=dy*dy;\n}\nif(sxx===0||syy===0)return null;\nreturn Math.max(-1,Math.min(1,sxy/Math.sqrt(sxx*syy)));\n}\nfunction kendall(a,b,indices){\nconst{xs,ys,n}=pairs(a,b,indices);\nif(n<2||n>KENDALL_LIMIT)return null;\nlet concordant=0;\nlet discordant=0;\nlet tiedXOnly=0;\nlet tiedYOnly=0;\nfor(let i=0;i<n;i++){\nfor(let j=i+1;j<n;j++){\nconst dx=Math.sign(xs[i]-xs[j]);\nconst dy=Math.sign(ys[i]-ys[j]);\nconst product=dx*dy;\nif(product>0)concordant++;\nelse if(product<0)discordant++;\nelse if(dx===0&&dy===0){}\nelse if(dx===0)tiedXOnly++;\nelse tiedYOnly++;\n}\n}\nconst orderedByX=concordant+discordant+tiedYOnly;\nconst orderedByY=concordant+discordant+tiedXOnly;\nif(orderedByX===0||orderedByY===0)return null;\nreturn(concordant-discordant)/Math.sqrt(orderedByX*orderedByY);\n}\nfunction seriesStats(ordered,opts={}){\nconst n=ordered.length;\nif(n<2)return null;\nconst first=ordered[0];\nconst last=ordered[n-1];\nconst returns=[];\nfor(let i=1;i<n;i++){\nconst previous=ordered[i-1];\nif(previous===0)continue;\nreturns.push((ordered[i]-previous)/Math.abs(previous));\n}\nlet volatility=null;\nif(returns.length>1){\nlet mean=0;\nfor(const r of returns)mean+=r;\nmean/=returns.length;\nlet m2=0;\nfor(const r of returns)m2+=(r-mean)**2;\nvolatility=Math.sqrt(m2/(returns.length-1));\n}\nconst periods=Number(opts.periodsPerYear)>0?Number(opts.periodsPerYear):null;\nlet peak=ordered[0];\nlet peakAt=0;\nlet worst=0;\nlet worstFrom=0;\nlet worstTo=0;\nfor(let i=1;i<n;i++){\nif(ordered[i]>peak){peak=ordered[i];peakAt=i;continue;}\nif(peak<=0)continue;\nconst fall=(peak-ordered[i])/peak;\nif(fall>worst){worst=fall;worstFrom=peakAt;worstTo=i;}\n}\nlet autocorrelation=null;\nif(n>2){\nlet mean=0;\nfor(let i=0;i<n;i++)mean+=ordered[i];\nmean/=n;\nlet top=0;\nlet bottom=0;\nfor(let i=0;i<n;i++){\nconst d=ordered[i]-mean;\nbottom+=d*d;\nif(i>0)top+=d*(ordered[i-1]-mean);\n}\nautocorrelation=bottom>0?top/bottom:null;\n}\nlet up=0;\nlet down=0;\nfor(const r of returns){if(r>0)up++;else if(r<0)down++;}\nlet growth=null;\nif(first>0&&last>0){\nconst perPeriod=(last/first)**(1/(n-1))-1;\ngrowth=periods?(1+perPeriod)**periods-1:perPeriod;\n}\nreturn{\nn,\nfirst,\nlast,\nchange:last-first,\nchangePercent:first===0?null:((last-first)/Math.abs(first))*100,\nvolatility,\nannualisedVolatility:volatility!==null&&periods?volatility*Math.sqrt(periods):null,\ngrowth,\nmaxDrawdown:worst,\nmaxDrawdownFrom:worstFrom,\nmaxDrawdownTo:worstTo,\nautocorrelation,\nupDays:up,\ndownDays:down,\n};\n}\nconst D2_N2=1.128;\nconst D4_N2=3.267;\nfunction movingRanges(ordered){\nconst n=ordered.length;\nif(n<2)return null;\nconst ranges=[];\nfor(let i=1;i<n;i++)ranges.push(Math.abs(ordered[i]-ordered[i-1]));\nconst centre=ranges.reduce((t,r)=>t+r,0)/ranges.length;\nreturn{ranges,centre,upper:D4_N2*centre,lower:0};\n}\nfunction withinSigma(ordered){\nconst n=ordered.length;\nif(n<2)return null;\nlet total=0;\nfor(let i=1;i<n;i++)total+=Math.abs(ordered[i]-ordered[i-1]);\nconst meanRange=total/(n-1);\nreturn{sigma:meanRange/D2_N2,meanRange};\n}\nfunction capability(ordered,spec){\nconst n=ordered.length;\nif(n<2||!spec)return null;\nconst lower=Number.isFinite(Number(spec.lower))?Number(spec.lower):null;\nconst upper=Number.isFinite(Number(spec.upper))?Number(spec.upper):null;\nif(lower===null&&upper===null)return null;\nlet mean=0;\nfor(let i=0;i<n;i++)mean+=ordered[i];\nmean/=n;\nlet m2=0;\nfor(let i=0;i<n;i++)m2+=(ordered[i]-mean)**2;\nconst overall=Math.sqrt(m2/(n-1));\nconst within=withinSigma(ordered);\nconst sigmaWithin=within?within.sigma:null;\nconst indices=(sigma)=>{\nif(!sigma||sigma<=0)return{index:null,k:null};\nconst both=lower!==null&&upper!==null;\nconst index=both?(upper-lower)/(6*sigma):null;\nconst upperSide=upper!==null?(upper-mean)/(3*sigma):Infinity;\nconst lowerSide=lower!==null?(mean-lower)/(3*sigma):Infinity;\nreturn{index,k:Math.min(upperSide,lowerSide)};\n};\nconst short=indices(sigmaWithin);\nconst long=indices(overall);\nlet outOfSpec=0;\nfor(let i=0;i<n;i++){\nif(lower!==null&&ordered[i]<lower){outOfSpec++;continue;}\nif(upper!==null&&ordered[i]>upper)outOfSpec++;\n}\nreturn{\nn,\nmean,\nlower,\nupper,\ntarget:Number.isFinite(Number(spec.target))?Number(spec.target):null,\nsigmaWithin,\nsigmaOverall:overall,\ncp:short.index,\ncpk:short.k,\npp:long.index,\nppk:long.k,\noutOfSpec,\ndefectRate:n?outOfSpec/n:null,\n};\n}\nfunction controlLimits(ordered){\nconst n=ordered.length;\nif(n<2)return null;\nconst within=withinSigma(ordered);\nif(!within||!(within.sigma>0))return null;\nlet centre=0;\nfor(let i=0;i<n;i++)centre+=ordered[i];\ncentre/=n;\nreturn{\ncentre,\nsigma:within.sigma,\nupper:centre+3*within.sigma,\nlower:centre-3*within.sigma,\n};\n}\nfunction westernElectricViolations(ordered,limits){\nif(!limits||!(limits.sigma>0))return[];\nconst n=ordered.length;\nconst{centre,sigma}=limits;\nconst z=(i)=>(ordered[i]-centre)/sigma;\nconst out=[];\nfor(let i=0;i<n;i++){\nif(Math.abs(z(i))>3){\nout.push({index:i,rule:1,description:'beyond three sigma'});\n}\nif(i>=2){\nfor(const side of[1,-1]){\nlet hits=0;\nfor(let k=i-2;k<=i;k++)if(z(k)*side>2)hits++;\nif(hits>=2){\nout.push({index:i,rule:2,description:'two of three past two sigma'});\nbreak;\n}\n}\n}\nif(i>=4){\nfor(const side of[1,-1]){\nlet hits=0;\nfor(let k=i-4;k<=i;k++)if(z(k)*side>1)hits++;\nif(hits>=4){\nout.push({index:i,rule:3,description:'four of five past one sigma'});\nbreak;\n}\n}\n}\nif(i>=7){\nfor(const side of[1,-1]){\nlet all=true;\nfor(let k=i-7;k<=i;k++)if(z(k)*side<=0){all=false;break;}\nif(all){\nout.push({index:i,rule:4,description:'eight in a row on one side'});\nbreak;\n}\n}\n}\n}\nreturn out;\n}\nfunction nelsonViolations(ordered,limits){\nif(!limits||!(limits.sigma>0))return[];\nconst n=ordered.length;\nconst{centre,sigma}=limits;\nconst z=(i)=>(ordered[i]-centre)/sigma;\nconst oneSide=(from,to,past,need)=>{\nfor(const side of[1,-1]){\nlet hits=0;\nfor(let k=from;k<=to;k++)if(z(k)*side>past)hits++;\nif(hits>=need)return true;\n}\nreturn false;\n};\nconst out=[];\nfor(let i=0;i<n;i++){\nif(Math.abs(z(i))>3)out.push({index:i,rule:1,description:'beyond three sigma'});\nif(i>=8){\nfor(const side of[1,-1]){\nlet all=true;\nfor(let k=i-8;k<=i;k++)if(z(k)*side<=0){all=false;break;}\nif(all){out.push({index:i,rule:2,description:'nine in a row on one side'});break;}\n}\n}\nif(i>=5){\nfor(const dir of[1,-1]){\nlet all=true;\nfor(let k=i-4;k<=i;k++){\nif((ordered[k]-ordered[k-1])*dir<=0){all=false;break;}\n}\nif(all){\nout.push({index:i,rule:3,description:dir>0?'six rising':'six falling'});\nbreak;\n}\n}\n}\nif(i>=13){\nlet alternating=true;\nfor(let k=i-12;k<=i;k++){\nconst a=ordered[k]-ordered[k-1];\nconst b=ordered[k+1<=i?k+1:k]-ordered[k];\nif(k+1>i)break;\nif(a===0||b===0||(a>0)===(b>0)){alternating=false;break;}\n}\nif(alternating)out.push({index:i,rule:4,description:'fourteen alternating'});\n}\nif(i>=2&&oneSide(i-2,i,2,2)){\nout.push({index:i,rule:5,description:'two of three past two sigma'});\n}\nif(i>=4&&oneSide(i-4,i,1,4)){\nout.push({index:i,rule:6,description:'four of five past one sigma'});\n}\nif(i>=14){\nlet inside=true;\nfor(let k=i-14;k<=i;k++)if(Math.abs(z(k))>=1){inside=false;break;}\nif(inside)out.push({index:i,rule:7,description:'fifteen within one sigma'});\n}\nif(i>=7){\nlet outside=true;\nfor(let k=i-7;k<=i;k++)if(Math.abs(z(k))<=1){outside=false;break;}\nif(outside)out.push({index:i,rule:8,description:'eight beyond one sigma'});\n}\n}\nreturn out;\n}\nconst CONTROL_RULE_SETS=Object.freeze(['westernElectric','nelson']);\nfunction controlViolations(ordered,limits,ruleSet='westernElectric'){\nreturn String(ruleSet)==='nelson'\n?nelsonViolations(ordered,limits)\n:westernElectricViolations(ordered,limits);\n}\nfunction countOutside(values,low,high){\nlet count=0;\nfor(let i=0;i<values.length;i++){\nif(values[i]<low||values[i]>high)count++;\n}\nreturn count;\n}\nfunction histogram(sorted,q1,q3,cap=20){\nconst n=sorted.length;\nif(!n)return[];\nconst min=sorted[0];\nconst max=sorted[n-1];\nif(max===min)return[{from:min,to:max,count:n}];\nconst iqr=q3-q1;\nconst fence=1.5*iqr;\nlet lo=iqr>0?Math.max(min,q1-fence):min;\nlet hi=iqr>0?Math.min(max,q3+fence):max;\nif(!(hi>lo)){lo=min;hi=max;}\nconst width=iqr>0?(2*iqr)/Math.cbrt(n):(hi-lo)/(Math.ceil(Math.log2(n))+1);\nconst count=width>0\n?Math.min(cap,Math.max(1,Math.ceil((hi-lo)/width)))\n:1;\nconst step=(hi-lo)/count;\nconst bins=[];\nfor(let i=0;i<count;i++){\nbins.push({from:lo+i*step,to:lo+(i+1)*step,count:0});\n}\nfor(let i=0;i<n;i++){\nconst at=Math.min(count-1,Math.max(0,Math.floor((sorted[i]-lo)/step)));\nbins[at].count++;\n}\nbins[0].from=min;\nbins[count-1].to=max;\nreturn bins;\n}\nconst DEFAULT_CONFIDENCE=0.95;\nfunction level(conf){\nconst c=Number(conf);\nreturn Number.isFinite(c)&&c>0&&c<1?c:DEFAULT_CONFIDENCE;\n}\nfunction meanInterval(values,conf=DEFAULT_CONFIDENCE){\nconst n=values.length;\nif(n<2)return null;\nlet sum=0;\nfor(let i=0;i<n;i++)sum+=values[i];\nconst mean=sum/n;\nlet ss=0;\nfor(let i=0;i<n;i++){const d=values[i]-mean;ss+=d*d;}\nconst sd=Math.sqrt(ss/(n-1));\nconst c=level(conf);\nconst t=studentTQuantile(1-(1-c)/2,n-1);\nconst margin=(t*sd)/Math.sqrt(n);\nreturn{mean,lower:mean-margin,upper:mean+margin,margin,n,confidence:c};\n}\nfunction proportionInterval(successes,n,conf=DEFAULT_CONFIDENCE){\nconst k=Number(successes);\nconst total=Number(n);\nif(!(total>0)||!(k>=0)||k>total)return null;\nconst c=level(conf);\nconst z=normalQuantile(1-(1-c)/2);\nconst p=k/total;\nconst z2=z*z;\nconst denominator=1+z2/total;\nconst centre=(p+z2/(2*total))/denominator;\nconst half=(z/denominator)\n*Math.sqrt((p*(1-p))/total+z2/(4*total*total));\nreturn{\nproportion:p,\nlower:Math.max(0,centre-half),\nupper:Math.min(1,centre+half),\nn:total,\nconfidence:c,\n};\n}\nfunction slopeInterval(fit,conf=DEFAULT_CONFIDENCE){\nif(!fit||!(fit.n>2)||!Number.isFinite(fit.stdError))return null;\nconst c=level(conf);\nconst t=studentTQuantile(1-(1-c)/2,fit.n-2);\nconst margin=t*fit.stdError;\nreturn{\nslope:fit.slope,\nlower:fit.slope-margin,\nupper:fit.slope+margin,\nmargin,\nconfidence:c,\n};\n}\nfunction capabilityInterval(index,n,conf=DEFAULT_CONFIDENCE){\nconst k=Number(index);\nconst count=Number(n);\nif(!Number.isFinite(k)||!(count>1))return null;\nconst c=level(conf);\nconst z=normalQuantile(1-(1-c)/2);\nconst margin=z*Math.sqrt(1/(9*count)+(k*k)/(2*(count-1)));\nreturn{index:k,lower:k-margin,upper:k+margin,margin,n:count,confidence:c};\n}\nfunction standardizedMeanDifference(population,subsetMean){\nif(!population||!(population.sd>0))return null;\nif(!Number.isFinite(subsetMean)||!Number.isFinite(population.mean))return null;\nreturn(subsetMean-population.mean)/population.sd;\n}\nfunction normalTotalVariation(d){\nif(!Number.isFinite(d))return 0;\nreturn Math.min(1,Math.max(0,2*normalCdf(Math.abs(d)/2)-1));\n}\nfunction frequencyMap(handle,indices){\nconst map=new Map();\nconst read=valueReader(handle);\nlet total=0;\nfor(let i=0;i<indices.length;i++){\nconst raw=read(indices[i]);\nif(raw===null||raw===undefined||raw==='')continue;\nif(typeof raw==='number'&&Number.isNaN(raw))continue;\nconst key=raw instanceof Date?raw.getTime()\n:(typeof raw==='object'?String(raw):raw);\nmap.set(key,(map.get(key)||0)+1);\ntotal++;\n}\nreturn{map,total};\n}\nfunction categoricalDistance(subset,subsetTotal,population,populationTotal){\nif(!(subsetTotal>0)||!(populationTotal>0))return null;\nlet sum=0;\nconst keys=new Set(subset.keys());\nfor(const k of population.keys())keys.add(k);\nfor(const k of keys){\nconst a=(subset.get(k)||0)/subsetTotal;\nconst b=(population.get(k)||0)/populationTotal;\nsum+=Math.abs(a-b);\n}\nreturn sum/2;\n}\nconst SUBSET_RELIABILITY_FLOOR=10;\nfunction compareColumn(handle,subsetIndices,populationStats){\nconst numeric=populationStats&&populationStats.numeric;\nif(numeric){\nconst values=numbers(handle,subsetIndices);\nconst{n,mean}=moments(values);\nconst d=n>0\n?standardizedMeanDifference(\n{mean:populationStats.mean,sd:populationStats.sd},mean,\n)\n:null;\nreturn{\nmeasure:'standardizedMeanDifference',\nmagnitude:d,\ndistance:d===null?0:normalTotalVariation(d),\ndirection:d===null?0:Math.sign(d),\nsubsetN:n,\npopulationN:populationStats.n||0,\nreliable:n>=SUBSET_RELIABILITY_FLOOR,\n};\n}\nconst{map,total}=frequencyMap(handle,subsetIndices);\nconst tvd=categoricalDistance(map,total,populationStats.map,populationStats.total);\nreturn{\nmeasure:'categoricalTotalVariation',\nmagnitude:tvd,\ndistance:tvd===null?0:tvd,\ndirection:0,\nsubsetN:total,\npopulationN:populationStats.total||0,\nreliable:total>=SUBSET_RELIABILITY_FLOOR,\n};\n}\nfunction isNumericColumn(handle,indices){\nif(handle&&(handle.kind==='float64'||handle.kind==='int32'))return true;\nconst read=valueReader(handle);\nlet seen=0;\nlet numeric=0;\nfor(let i=0;i<indices.length&&seen<200;i++){\nconst raw=read(indices[i]);\nif(raw===null||raw===undefined||raw==='')continue;\nif(raw instanceof Date)return false;\nseen++;\nconst v=typeof raw==='number'?raw:Number(raw);\nif(Number.isFinite(v))numeric++;\n}\nif(seen===0)return false;\nreturn numeric/seen>=0.9;\n}\nfunction populationRead(handle,populationIndices){\nif(isNumericColumn(handle,populationIndices)){\nconst values=numbers(handle,populationIndices);\nconst{n,mean,m2}=moments(values);\nreturn{numeric:true,mean,sd:n>0?Math.sqrt(m2/n):0,n};\n}\nconst{map,total}=frequencyMap(handle,populationIndices);\nreturn{numeric:false,map,total};\n}\n});\n__def(\"packages/core/src/compute/total.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"TOTAL_FNS\",{enumerable:true,get:function(){return TOTAL_FNS;}});\nObject.defineProperty(__exports,\"TOTAL_LABELS\",{enumerable:true,get:function(){return TOTAL_LABELS;}});\nObject.defineProperty(__exports,\"totalLabel\",{enumerable:true,get:function(){return totalLabel;}});\nObject.defineProperty(__exports,\"aggregatesFor\",{enumerable:true,get:function(){return aggregatesFor;}});\nObject.defineProperty(__exports,\"aggregateAllowed\",{enumerable:true,get:function(){return aggregateAllowed;}});\nObject.defineProperty(__exports,\"collectValues\",{enumerable:true,get:function(){return collectValues;}});\nObject.defineProperty(__exports,\"total\",{enumerable:true,get:function(){return total;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst isFunction=__m0[\"isFunction\"];\nconst warnOnce=__m0[\"warnOnce\"];\nconst __m1=__req(\"packages/core/src/compute/handle.js\");\nconst presenceReader=__m1[\"presenceReader\"];\nconst valueComparator=__m1[\"valueComparator\"];\nconst valueReader=__m1[\"valueReader\"];\nconst __m2=__req(\"packages/core/src/compute/statistics.js\");\nconst STAT_FNS=__m2[\"STAT_FNS\"];\nconst STAT_LABELS=__m2[\"STAT_LABELS\"];\nfunction isNumericBacking(handle){\nreturn!!handle&&(handle.kind==='float64'||handle.kind==='int32');\n}\nfunction sum(handle,indices){\nconst n=indices.length;\nlet acc=0;\nif(isNumericBacking(handle)){\nconst values=handle.values;\nconst present=presenceReader(handle);\nif(!present){\nfor(let i=0;i<n;i++){\nconst v=values[indices[i]];\nif(!Number.isNaN(v))acc+=v;\n}\nreturn acc;\n}\nfor(let i=0;i<n;i++){\nconst row=indices[i];\nif(present(row)===1){\nconst v=values[row];\nif(!Number.isNaN(v))acc+=v;\n}\n}\nreturn acc;\n}\nconst read=valueReader(handle);\nfor(let i=0;i<n;i++){\nconst v=numberOf(read(indices[i]));\nif(v!==null)acc+=v;\n}\nreturn acc;\n}\nsum.kernel=true;\nfunction countValues(handle,indices){\nconst n=indices.length;\nlet count=0;\nif(isNumericBacking(handle)){\nconst values=handle.values;\nconst present=presenceReader(handle);\nif(!present){\nfor(let i=0;i<n;i++)if(!Number.isNaN(values[indices[i]]))count++;\nreturn count;\n}\nfor(let i=0;i<n;i++){\nconst row=indices[i];\nif(present(row)===1&&!Number.isNaN(values[row]))count++;\n}\nreturn count;\n}\nconst read=valueReader(handle);\nfor(let i=0;i<n;i++){\nconst v=read(indices[i]);\nif(v!==null&&v!==undefined&&!(typeof v==='number'&&Number.isNaN(v)))count++;\n}\nreturn count;\n}\ncountValues.kernel=true;\nfunction count(handle,indices){\nreturn indices.length;\n}\ncount.kernel=true;\nfunction avg(handle,indices){\nconst values=countValues(handle,indices);\nif(values===0)return null;\nreturn sum(handle,indices)/values;\n}\navg.kernel=true;\nfunction extreme(handle,indices,direction,locale){\nconst n=indices.length;\nif(isNumericBacking(handle)){\nconst values=handle.values;\nconst present=presenceReader(handle);\nlet best=null;\nif(!present){\nfor(let i=0;i<n;i++){\nconst v=values[indices[i]];\nif(Number.isNaN(v))continue;\nif(best===null||(direction<0?v<best:v>best))best=v;\n}\nreturn best;\n}\nfor(let i=0;i<n;i++){\nconst row=indices[i];\nif(present(row)===0)continue;\nconst v=values[row];\nif(Number.isNaN(v))continue;\nif(best===null||(direction<0?v<best:v>best))best=v;\n}\nreturn best;\n}\nconst read=valueReader(handle);\nconst cmp=valueComparator(locale);\nlet best=null;\nfor(let i=0;i<n;i++){\nconst v=read(indices[i]);\nif(v===null||v===undefined||(typeof v==='number'&&Number.isNaN(v)))continue;\nif(best===null||(direction<0?cmp(v,best)<0:cmp(v,best)>0))best=v;\n}\nreturn best;\n}\nfunction min(handle,indices,ctx){\nreturn extreme(handle,indices,-1,ctx&&ctx.locale);\n}\nmin.kernel=true;\nfunction max(handle,indices,ctx){\nreturn extreme(handle,indices,1,ctx&&ctx.locale);\n}\nmax.kernel=true;\nfunction first(handle,indices){\nif(indices.length===0)return null;\nreturn valueReader(handle)(indices[0]);\n}\nfirst.kernel=true;\nfunction last(handle,indices){\nif(indices.length===0)return null;\nreturn valueReader(handle)(indices[indices.length-1]);\n}\nlast.kernel=true;\nfunction numberOf(v){\nif(typeof v==='number')return Number.isNaN(v)?null:v;\nif(v===null||v===undefined||v===''||typeof v==='boolean')return null;\nif(v instanceof Date)return v.getTime();\nconst n=Number(v);\nreturn Number.isNaN(n)?null:n;\n}\nconst TOTAL_FNS={\nsum,min,max,avg,count,first,last,countValues,\n...STAT_FNS,\n};\nconst TOTAL_LABELS=Object.freeze({\n...STAT_LABELS,\nsum:'Sum',\navg:'Average',\nmin:'Min',\nmax:'Max',\ncount:'Count',\ncountValues:'Count of values',\nfirst:'First',\nlast:'Last',\n});\nfunction totalLabel(fn){\nif(!fn)return'';\nif(typeof fn==='string')return TOTAL_LABELS[fn]||fn;\nreturn'Total';\n}\nconst CHOOSER_ORDER=Object.freeze([\n'sum','avg','min','max','count','countValues','first','last',\n]);\nfunction aggregatesFor(column){\nconst supported=column&&column.dataType\n&&column.dataType.totals&&column.dataType.totals.supported;\nif(Array.isArray(supported))return supported.slice();\nconst named=CHOOSER_ORDER.filter((name)=>name in TOTAL_FNS);\nfor(const name of Object.keys(TOTAL_FNS))if(!named.includes(name))named.push(name);\nreturn named;\n}\nfunction aggregateAllowed(column,name){\nif(typeof name!=='string')return true;\nreturn aggregatesFor(column).includes(name);\n}\nfunction collectValues(handle,indices){\nconst read=valueReader(handle);\nconst out=[];\nfor(let i=0;i<indices.length;i++){\nconst v=read(indices[i]);\nif(v===null||v===undefined)continue;\nout.push(v);\n}\nreturn out;\n}\nfunction total(handle,indices,fn,ctx){\nconst list=indices||[];\nif(typeof fn==='string'){\nconst kernel=TOTAL_FNS[fn];\nif(!kernel){\nwarnOnce(`total:${fn}`,`unknown total function \"${fn}\"; register it in config.totalFns`);\nreturn null;\n}\nreturn kernel(handle,list,ctx);\n}\nif(isFunction(fn)){\nif(fn.kernel===true)return fn(handle,list,ctx);\nreturn fn(collectValues(handle,list),ctx||{});\n}\nreturn null;\n}\n});\n__def(\"packages/core/src/compute/pivot.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"KEY_DELIMITER\",{enumerable:true,get:function(){return KEY_DELIMITER;}});\nObject.defineProperty(__exports,\"DEFAULT_PATH_SEPARATOR\",{enumerable:true,get:function(){return DEFAULT_PATH_SEPARATOR;}});\nObject.defineProperty(__exports,\"DEFAULT_MAX_COLUMNS\",{enumerable:true,get:function(){return DEFAULT_MAX_COLUMNS;}});\nObject.defineProperty(__exports,\"pivotKey\",{enumerable:true,get:function(){return pivotKey;}});\nObject.defineProperty(__exports,\"joinPath\",{enumerable:true,get:function(){return joinPath;}});\nObject.defineProperty(__exports,\"resolvePivotKeys\",{enumerable:true,get:function(){return resolvePivotKeys;}});\nObject.defineProperty(__exports,\"pivot\",{enumerable:true,get:function(){return pivot;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst warnOnce=__m0[\"warnOnce\"];\nconst __m1=__req(\"packages/core/src/compute/handle.js\");\nconst valueComparator=__m1[\"valueComparator\"];\nconst __m2=__req(\"packages/core/src/compute/group.js\");\nconst packKeys=__m2[\"packKeys\"];\nconst __m3=__req(\"packages/core/src/compute/total.js\");\nconst total=__m3[\"total\"];\nconst KEY_DELIMITER='|';\nconst DEFAULT_PATH_SEPARATOR='/';\nconst DEFAULT_MAX_COLUMNS=2000;\nfunction pivotKey(groupPath,pivotPath,colId){\nreturn`${groupPath}${KEY_DELIMITER}${pivotPath}${KEY_DELIMITER}${colId}`;\n}\nfunction joinPath(parts,separator){\nlet out='';\nfor(let i=0;i<parts.length;i++){\nconst v=parts[i];\nout+=(i===0?'':separator)+(v===null||v===undefined?'':String(v));\n}\nreturn out;\n}\nfunction resolvePivotKeys(handles,order,opts={}){\nconst separator=opts.separator||DEFAULT_PATH_SEPARATOR;\nconst n=order.length;\nconst{keyOf,readers}=packKeys(handles,order,0);\nconst seen=new Map();\nconst tuples=[];\nconst rawKeys=[];\nfor(let i=0;i<n;i++){\nconst row=order[i];\nconst key=keyOf(row);\nif(seen.has(key))continue;\nseen.set(key,tuples.length);\nrawKeys.push(key);\nconst tuple=new Array(readers.length);\nfor(let j=0;j<readers.length;j++)tuple[j]=readers[j](row);\ntuples.push(tuple);\n}\nconst cmp=valueComparator(opts.locale);\nconst rank=tuples.map((_,i)=>i);\nrank.sort((a,b)=>{\nconst ta=tuples[a];\nconst tb=tuples[b];\nfor(let j=0;j<ta.length;j++){\nconst c=compareNullable(ta[j],tb[j],cmp);\nif(c!==0)return c;\n}\nreturn a-b;\n});\nconst keys=new Array(rank.length);\nconst paths=new Array(rank.length);\nconst idByKey=new Map();\nfor(let position=0;position<rank.length;position++){\nconst from=rank[position];\nkeys[position]=tuples[from];\npaths[position]=joinPath(tuples[from],separator);\nidByKey.set(rawKeys[from],position);\n}\nconst idOf=(row)=>{\nconst id=idByKey.get(keyOf(row));\nreturn id===undefined?-1:id;\n};\nreturn{keys,paths,idOf};\n}\nfunction compareNullable(a,b,cmp){\nconst na=a===null||a===undefined;\nconst nb=b===null||b===undefined;\nif(na||nb)return na&&nb?0:na?1:-1;\nreturn cmp(a,b);\n}\nfunction resolveValueColumns(opts){\nconst declared=opts.values||opts.totals||[];\nif(declared.length&&typeof declared[0]==='object'&&declared[0]!==null){\nreturn declared.filter((entry)=>entry&&entry.handle);\n}\nconst resolve=typeof opts.handle==='function'?opts.handle:null;\nif(!resolve){\nif(declared.length){\nwarnOnce('pivot:handles',\n'pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle.');\n}\nreturn[];\n}\nconst totalOf=typeof opts.totalOf==='function'?opts.totalOf:null;\nconst out=[];\nfor(const colId of declared){\nconst handle=resolve(colId);\nif(!handle)continue;\nout.push({colId,handle,fn:totalOf?totalOf(colId):'sum'});\n}\nreturn out;\n}\nfunction normaliseArgs(a,b,c){\nif(Array.isArray(a)){\nconst opts=c||{};\nreturn{...opts,pivotHandles:a,order:b||null,groups:opts.groups||null};\n}\nreturn a||{};\n}\nfunction pivot(input,orderArg,optsArg){\nconst opts=normaliseArgs(input,orderArg,optsArg);\nconst separator=opts.separator||DEFAULT_PATH_SEPARATOR;\nconst valueColumns=resolveValueColumns(opts);\nconst maxColumns=opts.maxColumns===undefined?DEFAULT_MAX_COLUMNS:opts.maxColumns;\nconst groups=opts.groups&&opts.groups.buckets?opts.groups:null;\nconst buckets=groups?groups.buckets:[opts.order||new Uint32Array(0)];\nconst groupPaths=opts.groupPaths\n||(groups?groups.keys.map((tuple)=>joinPath(tuple,separator)):['']);\nconst scope=concatIndices(buckets);\nconst{keys,paths,idOf}=resolvePivotKeys(opts.pivotHandles||[],scope,opts);\nconst columns=paths.length*Math.max(1,valueColumns.length);\nconst fields=derivedFields(paths,valueColumns,separator);\nif(maxColumns&&columns>maxColumns){\nconst empty=new Map();\nreturn{\nkeys,\npaths,\nfields,\ngroupPaths,\ncolumns,\nvalues:empty,\ncells:empty,\nerror:{\ncode:'pivot-max-columns',\nmessage:`[lattice] pivot would generate ${columns} columns, above pivot.maxColumns of ${maxColumns}. Narrow the pivot columns or raise the limit.`,\ncolumns,\nmaxColumns,\n},\n};\n}\nconst cells=new Map();\nconst keyCount=paths.length;\nfor(let g=0;g<buckets.length;g++){\nconst bucket=buckets[g];\nconst groupPath=groupPaths[g]===undefined?'':groupPaths[g];\nconst n=bucket.length;\nif(n===0)continue;\nconst ids=new Int32Array(n);\nconst counts=new Uint32Array(keyCount+1);\nfor(let i=0;i<n;i++){\nconst id=idOf(bucket[i]);\nids[i]=id;\nif(id>=0)counts[id+1]++;\n}\nfor(let k=0;k<keyCount;k++)counts[k+1]+=counts[k];\nconst scattered=new Uint32Array(n);\nconst cursor=counts.slice(0,keyCount);\nfor(let i=0;i<n;i++){\nconst id=ids[i];\nif(id>=0)scattered[cursor[id]++]=bucket[i];\n}\nfor(let k=0;k<keyCount;k++){\nconst from=counts[k];\nconst to=counts[k+1];\nif(to===from)continue;\nconst slice=scattered.subarray(from,to);\nfor(let c=0;c<valueColumns.length;c++){\nconst column=valueColumns[c];\nconst result=total(column.handle,slice,column.fn,opts.totalContext||{locale:opts.locale});\ncells.set(pivotKey(groupPath,paths[k],column.colId),result);\n}\n}\n}\nreturn{keys,paths,fields,groupPaths,columns,values:cells,cells,error:null};\n}\nfunction derivedFields(paths,valueColumns,separator){\nif(valueColumns.length===0)return paths.slice();\nconst out=[];\nfor(const path of paths){\nfor(const column of valueColumns)out.push(`${path}${separator}${column.colId}`);\n}\nreturn out;\n}\nfunction concatIndices(buckets){\nif(buckets.length===1)return buckets[0]||new Uint32Array(0);\nlet n=0;\nfor(const b of buckets)n+=b?b.length:0;\nconst out=new Uint32Array(n);\nlet at=0;\nfor(const b of buckets){\nif(!b||b.length===0)continue;\nout.set(b,at);\nat+=b.length;\n}\nreturn out;\n}\n});\n__def(\"packages/core/src/compute/pivotmatrix.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"GRAND_PATH\",{enumerable:true,get:function(){return GRAND_PATH;}});\nObject.defineProperty(__exports,\"resolveAxis\",{enumerable:true,get:function(){return resolveAxis;}});\nObject.defineProperty(__exports,\"pivotMatrix\",{enumerable:true,get:function(){return pivotMatrix;}});\nObject.defineProperty(__exports,\"cellKey\",{enumerable:true,get:function(){return cellKey;}});\nObject.defineProperty(__exports,\"marginKey\",{enumerable:true,get:function(){return marginKey;}});\nconst __m0=__req(\"packages/core/src/compute/handle.js\");\nconst valueComparator=__m0[\"valueComparator\"];\nconst __m1=__req(\"packages/core/src/compute/total.js\");\nconst total=__m1[\"total\"];\nconst __m2=__req(\"packages/core/src/compute/group.js\");\nconst packKeys=__m2[\"packKeys\"];\nconst __m3=__req(\"packages/core/src/compute/pivot.js\");\nconst joinPath=__m3[\"joinPath\"];\nconst DEFAULT_PATH_SEPARATOR=__m3[\"DEFAULT_PATH_SEPARATOR\"];\nconst DEFAULT_MAX_COLUMNS=__m3[\"DEFAULT_MAX_COLUMNS\"];\nconst GRAND_PATH='';\nfunction resolveAxis(handles,leaves,opts={}){\nconst separator=opts.separator||DEFAULT_PATH_SEPARATOR;\nconst list=handles||[];\nconst order=leaves instanceof Uint32Array?leaves:Uint32Array.from(leaves||[]);\nconst n=order.length;\nif(list.length===0){\nreturn{tuples:[[]],paths:[GRAND_PATH],buckets:[order]};\n}\nconst{keyOf,readers}=packKeys(list,order,0);\nconst seen=new Map();\nconst tuples=[];\nconst rawKeys=[];\nconst rowsByKey=[];\nfor(let i=0;i<n;i++){\nconst row=order[i];\nconst key=keyOf(row);\nlet at=seen.get(key);\nif(at===undefined){\nat=tuples.length;\nseen.set(key,at);\nrawKeys.push(key);\nconst tuple=new Array(readers.length);\nfor(let j=0;j<readers.length;j++)tuple[j]=readers[j](row);\ntuples.push(tuple);\nrowsByKey.push([]);\n}\nrowsByKey[at].push(row);\n}\nconst cmp=valueComparator(opts.locale);\nconst rank=tuples.map((_,i)=>i);\nrank.sort((a,b)=>{\nconst ta=tuples[a];\nconst tb=tuples[b];\nfor(let j=0;j<ta.length;j++){\nconst c=compareNullable(ta[j],tb[j],cmp);\nif(c!==0)return c;\n}\nreturn a-b;\n});\nconst outTuples=new Array(rank.length);\nconst paths=new Array(rank.length);\nconst buckets=new Array(rank.length);\nfor(let position=0;position<rank.length;position++){\nconst from=rank[position];\noutTuples[position]=tuples[from];\npaths[position]=joinPath(tuples[from],separator);\nbuckets[position]=Uint32Array.from(rowsByKey[from]);\n}\nreturn{tuples:outTuples,paths,buckets};\n}\nfunction compareNullable(a,b,cmp){\nconst na=a===null||a===undefined;\nconst nb=b===null||b===undefined;\nif(na||nb)return na&&nb?0:na?1:-1;\nreturn cmp(a,b);\n}\nfunction intersect(a,b,bSet){\nconst out=[];\nfor(let i=0;i<a.length;i++){\nif(bSet.has(a[i]))out.push(a[i]);\n}\nreturn Uint32Array.from(out);\n}\nfunction reduceCell(handle,leaves,fn,ctx){\nconst value=leaves.length?total(handle,leaves,fn,ctx):null;\nreturn{value,leaves,count:leaves.length};\n}\nfunction pivotMatrix(input){\nconst opts=(input&&input.opts)||{};\nconst separator=opts.separator||DEFAULT_PATH_SEPARATOR;\nconst ctx=opts.totalContext||{locale:opts.locale};\nconst measures=(input.measures||[]).filter((m)=>m&&m.handle);\nconst leaves=input.leaves instanceof Uint32Array\n?input.leaves\n:Uint32Array.from(input.leaves||[]);\nconst rowAxis=resolveAxis(input.rowHandles||[],leaves,{...opts,separator});\nconst columnAxis=resolveAxis(input.columnHandles||[],leaves,{...opts,separator});\nconst maxColumns=opts.maxColumns===undefined?DEFAULT_MAX_COLUMNS:opts.maxColumns;\nconst columns=columnAxis.paths.length*Math.max(1,measures.length);\nconst empty=new Map();\nif(maxColumns&&columns>maxColumns){\nreturn{\nrowAxis,\ncolumnAxis,\nmeasures:measures.map((m)=>({colId:m.colId,fn:m.fn})),\nbody:empty,\nrowMargin:empty,\ncolumnMargin:empty,\ngrand:empty,\ncolumns,\nerror:{\ncode:'pivot-max-columns',\nmessage:`[lattice] pivot would generate ${columns} columns, above pivot.maxColumns of `\n+`${maxColumns}. Narrow the pivot columns or raise the limit.`,\ncolumns,\nmaxColumns,\n},\n};\n}\nconst body=new Map();\nconst rowMargin=new Map();\nconst columnMargin=new Map();\nconst grand=new Map();\nconst columnSets=columnAxis.buckets.map((b)=>new Set(b));\nfor(let c=0;c<columnAxis.paths.length;c++){\nconst columnLeaves=columnAxis.buckets[c];\nconst columnPath=columnAxis.paths[c];\nfor(const m of measures){\ncolumnMargin.set(marginKey(columnPath,m.colId),reduceCell(m.handle,columnLeaves,m.fn,ctx));\n}\n}\nfor(let r=0;r<rowAxis.paths.length;r++){\nconst rowLeaves=rowAxis.buckets[r];\nconst rowPath=rowAxis.paths[r];\nfor(const m of measures){\nrowMargin.set(marginKey(rowPath,m.colId),reduceCell(m.handle,rowLeaves,m.fn,ctx));\n}\nfor(let c=0;c<columnAxis.paths.length;c++){\nconst cellLeaves=intersect(rowLeaves,columnAxis.buckets[c],columnSets[c]);\nif(cellLeaves.length===0)continue;\nconst columnPath=columnAxis.paths[c];\nfor(const m of measures){\nbody.set(cellKey(rowPath,columnPath,m.colId),reduceCell(m.handle,cellLeaves,m.fn,ctx));\n}\n}\n}\nfor(const m of measures){\ngrand.set(m.colId,reduceCell(m.handle,leaves,m.fn,ctx));\n}\nreturn{\nrowAxis,\ncolumnAxis,\nmeasures:measures.map((m)=>({colId:m.colId,fn:m.fn})),\nbody,\nrowMargin,\ncolumnMargin,\ngrand,\ncolumns,\nerror:null,\n};\n}\nfunction cellKey(rowPath,columnPath,colId){\nreturn`${rowPath}\\u0000${columnPath}\\u0000${colId}`;\n}\nfunction marginKey(path,colId){\nreturn`${path}\\u0000${colId}`;\n}\n});\n__def(\"packages/core/src/compute/reference.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"referenceValue\",{enumerable:true,get:function(){return referenceValue;}});\nObject.defineProperty(__exports,\"referenceSort\",{enumerable:true,get:function(){return referenceSort;}});\nObject.defineProperty(__exports,\"referenceFilter\",{enumerable:true,get:function(){return referenceFilter;}});\nObject.defineProperty(__exports,\"referencePasses\",{enumerable:true,get:function(){return referencePasses;}});\nObject.defineProperty(__exports,\"referenceGroup\",{enumerable:true,get:function(){return referenceGroup;}});\nObject.defineProperty(__exports,\"referenceTotal\",{enumerable:true,get:function(){return referenceTotal;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst getPath=__m0[\"getPath\"];\nconst __m1=__req(\"packages/core/src/compute/handle.js\");\nconst isMissing=__m1[\"isMissing\"];\nconst valueComparator=__m1[\"valueComparator\"];\nconst __m2=__req(\"packages/core/src/compute/filter.js\");\nconst testValue=__m2[\"testValue\"];\nconst KEY_SEPARATOR=String.fromCharCode(0x1f);\nconst NULL_MARKER=String.fromCharCode(0x00);\nfunction referenceValue(row,col){\nconst v=col.includes('.')?getPath(row,col):(row==null?undefined:row[col]);\nreturn v===undefined?null:v;\n}\nfunction referenceSort(rows,entries,opts={}){\nconst list=entries||[];\nlet order=rows.map((_,i)=>i);\nif(list.length===0)return order;\nfor(let e=list.length-1;e>=0;e--){\norder=referenceSortOne(rows,order,list[e],opts);\n}\nreturn order;\n}\nfunction referenceSortOne(rows,order,entry,opts){\nconst locale=entry.locale!==undefined?entry.locale:opts.locale;\nconst base=valueComparator(locale);\nconst descending=entry.descending!==undefined?!!entry.descending:entry.dir==='desc';\nconst present=[];\nconst absent=[];\nfor(const i of order){\nconst v=referenceValue(rows[i],entry.col);\nif(isMissing(v))absent.push(i);else present.push(i);\n}\nconst position=new Map();\nfor(let p=0;p<present.length;p++)position.set(present[p],p);\nconst compare=(a,b)=>{\nconst va=referenceValue(rows[a],entry.col);\nconst vb=referenceValue(rows[b],entry.col);\nlet c;\nif(typeof entry.compare==='function'){\nc=entry.compare(va,vb,rows[a],rows[b],descending);\nif(descending)c=-c;\n}else{\nc=descending?base(vb,va):base(va,vb);\n}\nreturn c!==0?c:position.get(a)-position.get(b);\n};\npresent.sort(compare);\nreturn entry.nullsFirst?absent.concat(present):present.concat(absent);\n}\nfunction referenceFilter(rows,filters,opts={}){\nconst out=[];\nfor(let i=0;i<rows.length;i++){\nif(referencePasses(rows[i],filters,opts,i))out.push(i);\n}\nreturn out;\n}\nfunction referencePasses(row,node,opts,index){\nif(!node)return true;\nif(Array.isArray(node.conditions)){\nconst children=node.conditions.filter((c)=>c!=null);\nif(children.length===0)return true;\nif(node.op==='or')return children.some((c)=>referencePasses(row,c,opts,index));\nconst all=children.every((c)=>referencePasses(row,c,opts,index));\nreturn node.op==='not'?!all:all;\n}\nif(node.col===undefined&&typeof opts.custom==='function')return!!opts.custom(node,row,index);\nreturn testValue(referenceValue(row,node.col),node,opts.locale);\n}\nfunction referenceGroup(rows,cols,order){\nconst source=order||rows.map((_,i)=>i);\nconst seen=new Map();\nconst keys=[];\nconst buckets=[];\nfor(const i of source){\nconst tuple=cols.map((col)=>referenceValue(rows[i],col));\nconst key=tuple\n.map((v)=>(v===null||v===undefined?NULL_MARKER:String(v)))\n.join(KEY_SEPARATOR);\nlet at=seen.get(key);\nif(at===undefined){\nat=keys.length;\nseen.set(key,at);\nkeys.push(tuple);\nbuckets.push([]);\n}\nbuckets[at].push(i);\n}\nreturn{keys,buckets};\n}\nfunction referenceTotal(values,fn,opts={}){\nconst cmp=valueComparator(opts.locale);\nconst live=values.filter((v)=>!isMissing(v));\nconst numbers=live.map(toNumberOrNull).filter((v)=>v!==null);\nswitch(fn){\ncase'count':return values.length;\ncase'countValues':return live.length;\ncase'sum':return numbers.reduce((a,b)=>a+b,0);\ncase'avg':return live.length===0?null:numbers.reduce((a,b)=>a+b,0)/live.length;\ncase'min':return live.length===0?null:live.reduce((a,b)=>(cmp(b,a)<0?b:a));\ncase'max':return live.length===0?null:live.reduce((a,b)=>(cmp(b,a)>0?b:a));\ncase'first':return values.length===0?null:normaliseNull(values[0]);\ncase'last':return values.length===0?null:normaliseNull(values[values.length-1]);\ndefault:return null;\n}\n}\nfunction toNumberOrNull(v){\nif(typeof v==='number')return Number.isNaN(v)?null:v;\nif(v===null||v===undefined||v===''||typeof v==='boolean')return null;\nif(v instanceof Date)return v.getTime();\nconst n=Number(v);\nreturn Number.isNaN(n)?null:n;\n}\nfunction normaliseNull(v){\nreturn v===undefined?null:v;\n}\n});\n__def(\"packages/core/src/compute/windowed.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"Window\",{enumerable:true,get:function(){return Window;}});\nObject.defineProperty(__exports,\"WINDOW_KINDS\",{enumerable:true,get:function(){return WINDOW_KINDS;}});\nObject.defineProperty(__exports,\"openWindow\",{enumerable:true,get:function(){return openWindow;}});\nObject.defineProperty(__exports,\"default\",{enumerable:true,get:function(){return __default;}});\nconst __m0=__req(\"packages/core/src/compute/sketch.js\");\nconst Welford=__m0[\"Welford\"];\nclass Window{\n#kind;\n#span;\n#ticks=[];\n#now;\n#opened;\nconstructor(kind,span=0,now=Date.now){\nif(kind!=='count'&&kind!=='time'&&kind!=='session'){\nthrow new RangeError(`unknown window kind: ${kind}`);\n}\nif((kind==='count'||kind==='time')&&!(span>0)){\nthrow new RangeError(`a ${kind} window needs a positive span`);\n}\nthis.#kind=kind;\nthis.#span=Math.floor(span);\nthis.#now=now;\nthis.#opened=now();\n}\nget size(){return this.#ticks.length;}\npush(v,t=this.#now()){\nif(!Number.isFinite(v))return;\nthis.#ticks.push({t,v});\nthis.#evict(t);\n}\n#evict(nowT){\nif(this.#kind==='count'){\nwhile(this.#ticks.length>this.#span)this.#ticks.shift();\n}else if(this.#kind==='time'){\nconst cutoff=nowT-this.#span;\nwhile(this.#ticks.length&&this.#ticks[0].t<cutoff)this.#ticks.shift();\n}\n}\nspec(){\nconst span=this.#kind==='session'?this.#now()-this.#opened:this.#span;\nreturn{kind:this.#kind,span,size:this.#ticks.length};\n}\nvalues(){return this.#ticks.map((tk)=>tk.v);}\naggregate(){\nconst spec=this.spec();\nif(!this.#ticks.length){\nreturn{over:spec,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};\n}\nconst w=new Welford();\nlet sum=0;\nlet min=Infinity;\nlet max=-Infinity;\nfor(const{v}of this.#ticks){\nsum+=v;\nif(v<min)min=v;\nif(v>max)max=v;\nw.add(v);\n}\nreturn{\nover:spec,\ncount:this.#ticks.length,\nsum,\nmean:w.mean(),\nmin,\nmax,\nvariance:w.variance(),\nstddev:w.stddev(),\n};\n}\nreduce(fn){\nconst agg=this.aggregate();\nconst map={\nsum:agg.sum,avg:agg.mean,mean:agg.mean,min:agg.min,max:agg.max,\ncount:agg.count,variance:agg.variance,stddev:agg.stddev,\n};\nif(!(fn in map))throw new RangeError(`unknown windowed aggregate: ${fn}`);\nreturn{value:map[fn],over:agg.over};\n}\n}\nconst WINDOW_KINDS=Object.freeze(['count','time','session']);\nfunction openWindow(opts,now=Date.now){\nconst span=opts.kind==='time'&&opts.minutes!=null\n?opts.minutes*60_000\n:opts.span??0;\nreturn new Window(opts.kind,span,now);\n}\nconst __default={Window,WINDOW_KINDS,openWindow};\n});\n__def(\"packages/core/src/compute/anomaly.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"MAD_SCALE\",{enumerable:true,get:function(){return MAD_SCALE;}});\nObject.defineProperty(__exports,\"DEFAULT_MODIFIED_Z_THRESHOLD\",{enumerable:true,get:function(){return DEFAULT_MODIFIED_Z_THRESHOLD;}});\nObject.defineProperty(__exports,\"DEFAULT_IQR_K\",{enumerable:true,get:function(){return DEFAULT_IQR_K;}});\nObject.defineProperty(__exports,\"DEFAULT_CHI_SQUARE_P\",{enumerable:true,get:function(){return DEFAULT_CHI_SQUARE_P;}});\nObject.defineProperty(__exports,\"ANOMALY_METHODS\",{enumerable:true,get:function(){return ANOMALY_METHODS;}});\nObject.defineProperty(__exports,\"robustSpread\",{enumerable:true,get:function(){return robustSpread;}});\nObject.defineProperty(__exports,\"modifiedZScores\",{enumerable:true,get:function(){return modifiedZScores;}});\nObject.defineProperty(__exports,\"iqrFences\",{enumerable:true,get:function(){return iqrFences;}});\nObject.defineProperty(__exports,\"chiSquareCdf\",{enumerable:true,get:function(){return chiSquareCdf;}});\nObject.defineProperty(__exports,\"chiSquareQuantile\",{enumerable:true,get:function(){return chiSquareQuantile;}});\nObject.defineProperty(__exports,\"mahalanobis\",{enumerable:true,get:function(){return mahalanobis;}});\nconst __m0=__req(\"packages/core/src/compute/statistics.js\");\nconst quantileSorted=__m0[\"quantileSorted\"];\nconst __m1=__req(\"packages/core/src/compute/special.js\");\nconst logGamma=__m1[\"logGamma\"];\nconst MAD_SCALE=0.6745;\nconst DEFAULT_MODIFIED_Z_THRESHOLD=3.5;\nconst DEFAULT_IQR_K=1.5;\nconst DEFAULT_CHI_SQUARE_P=0.975;\nconst ANOMALY_METHODS=Object.freeze(['modifiedZScore','iqr','mahalanobis']);\nfunction robustSpread(values){\nconst n=values.length;\nif(!n)return null;\nconst sorted=Array.from(values,Number).sort((a,b)=>a-b);\nconst median=quantileSorted(sorted,0.5);\nconst deviations=sorted.map((v)=>Math.abs(v-median)).sort((a,b)=>a-b);\nconst mad=quantileSorted(deviations,0.5);\nreturn{median,mad};\n}\nfunction modifiedZScores(values,opts={}){\nconst threshold=Number.isFinite(opts.threshold)?opts.threshold:DEFAULT_MODIFIED_Z_THRESHOLD;\nconst n=values.length;\nconst scores=new Array(n).fill(null);\nconst flags=new Array(n).fill(false);\nconst finite=[];\nfor(let i=0;i<n;i++){\nconst v=Number(values[i]);\nif(Number.isFinite(v))finite.push(v);\n}\nif(!finite.length)return{median:null,mad:null,threshold,scores,flags,flagged:0};\nconst spread=robustSpread(finite);\nif(spread.mad===0)return{median:spread.median,mad:0,threshold,scores,flags,flagged:0};\nlet flagged=0;\nfor(let i=0;i<n;i++){\nconst v=Number(values[i]);\nif(!Number.isFinite(v))continue;\nconst score=(MAD_SCALE*(v-spread.median))/spread.mad;\nscores[i]=score;\nif(Math.abs(score)>threshold){flags[i]=true;flagged++;}\n}\nreturn{median:spread.median,mad:spread.mad,threshold,scores,flags,flagged};\n}\nfunction iqrFences(values,opts={}){\nconst k=Number.isFinite(opts.k)?opts.k:DEFAULT_IQR_K;\nconst finite=[];\nfor(let i=0;i<values.length;i++){\nconst v=Number(values[i]);\nif(Number.isFinite(v))finite.push(v);\n}\nif(!finite.length)return null;\nconst sorted=finite.sort((a,b)=>a-b);\nconst q1=quantileSorted(sorted,0.25);\nconst q3=quantileSorted(sorted,0.75);\nconst iqr=q3-q1;\nreturn{q1,q3,iqr,lower:q1-k*iqr,upper:q3+k*iqr,k};\n}\nfunction regularizedGammaP(a,x){\nif(x<=0)return 0;\nconst gln=logGamma(a);\nif(x<a+1){\nlet ap=a;\nlet sum=1/a;\nlet term=sum;\nfor(let i=0;i<1000;i++){\nap+=1;\nterm*=x/ap;\nsum+=term;\nif(Math.abs(term)<Math.abs(sum)*1e-15)break;\n}\nreturn sum*Math.exp(-x+a*Math.log(x)-gln);\n}\nconst tiny=1e-300;\nlet b=x+1-a;\nlet c=1/tiny;\nlet d=1/b;\nlet h=d;\nfor(let i=1;i<1000;i++){\nconst an=-i*(i-a);\nb+=2;\nd=an*d+b;\nif(Math.abs(d)<tiny)d=tiny;\nc=b+an/c;\nif(Math.abs(c)<tiny)c=tiny;\nd=1/d;\nconst delta=d*c;\nh*=delta;\nif(Math.abs(delta-1)<1e-15)break;\n}\nconst q=Math.exp(-x+a*Math.log(x)-gln)*h;\nreturn 1-q;\n}\nfunction chiSquareCdf(x,df){\nif(x<=0)return 0;\nreturn regularizedGammaP(df/2,x/2);\n}\nfunction chiSquareQuantile(df,p=DEFAULT_CHI_SQUARE_P){\nif(!(p>0)||!(p<1))return NaN;\nlet lo=0;\nlet hi=Math.max(1,df);\nwhile(chiSquareCdf(hi,df)<p)hi*=2;\nfor(let i=0;i<200;i++){\nconst mid=(lo+hi)/2;\nif(chiSquareCdf(mid,df)<p)lo=mid;else hi=mid;\nif(hi-lo<1e-10)break;\n}\nreturn(lo+hi)/2;\n}\nfunction invertMatrix(matrix){\nconst k=matrix.length;\nconst a=matrix.map((row,i)=>{\nconst copy=row.slice();\nfor(let j=0;j<k;j++)copy.push(i===j?1:0);\nreturn copy;\n});\nfor(let col=0;col<k;col++){\nlet pivot=col;\nfor(let r=col+1;r<k;r++){\nif(Math.abs(a[r][col])>Math.abs(a[pivot][col]))pivot=r;\n}\nif(Math.abs(a[pivot][col])<1e-12)return null;\nif(pivot!==col){const t=a[pivot];a[pivot]=a[col];a[col]=t;}\nconst div=a[col][col];\nfor(let j=0;j<2*k;j++)a[col][j]/=div;\nfor(let r=0;r<k;r++){\nif(r===col)continue;\nconst factor=a[r][col];\nif(factor===0)continue;\nfor(let j=0;j<2*k;j++)a[r][j]-=factor*a[col][j];\n}\n}\nreturn a.map((row)=>row.slice(k));\n}\nfunction meanAndCovariance(rows,k){\nconst n=rows.length;\nconst mean=new Array(k).fill(0);\nfor(const row of rows)for(let j=0;j<k;j++)mean[j]+=row[j];\nfor(let j=0;j<k;j++)mean[j]/=n;\nconst cov=Array.from({length:k},()=>new Array(k).fill(0));\nfor(const row of rows){\nfor(let a=0;a<k;a++){\nconst da=row[a]-mean[a];\nfor(let b=a;b<k;b++){\ncov[a][b]+=da*(row[b]-mean[b]);\n}\n}\n}\nconst denom=n>1?n-1:1;\nfor(let a=0;a<k;a++){\nfor(let b=a;b<k;b++){\ncov[a][b]/=denom;\ncov[b][a]=cov[a][b];\n}\n}\nreturn{mean,cov};\n}\nfunction mahalanobis(matrix,opts={}){\nconst p=Number.isFinite(opts.p)?opts.p:DEFAULT_CHI_SQUARE_P;\nconst ridgeFraction=Number.isFinite(opts.ridge)?opts.ridge:1e-6;\nconst n=matrix.length;\nif(!n)return null;\nconst k=matrix[0].length;\nif(!k)return null;\nconst distances=new Array(n).fill(null);\nconst squared=new Array(n).fill(null);\nconst flags=new Array(n).fill(false);\nconst completeIndex=[];\nconst complete=[];\nfor(let i=0;i<n;i++){\nconst row=matrix[i];\nlet ok=row.length===k;\nconst coords=new Array(k);\nfor(let j=0;ok&&j<k;j++){\nconst v=Number(row[j]);\nif(!Number.isFinite(v))ok=false;else coords[j]=v;\n}\nif(ok){completeIndex.push(i);complete.push(coords);}\n}\nconst df=k;\nconst cutoff=chiSquareQuantile(df,p);\nif(complete.length<=k){\nreturn{center:[],df,cutoff,singular:true,used:complete.length,distances,squared,flags,flagged:0};\n}\nconst{mean,cov}=meanAndCovariance(complete,k);\nlet inverse=invertMatrix(cov);\nlet singular=false;\nif(!inverse){\nsingular=true;\nlet trace=0;\nfor(let j=0;j<k;j++)trace+=cov[j][j];\nconst ridge=(trace/k)*ridgeFraction||ridgeFraction;\nconst nudged=cov.map((row,i)=>row.map((v,j)=>(i===j?v+ridge:v)));\ninverse=invertMatrix(nudged);\nif(!inverse){\nreturn{center:mean,df,cutoff,singular:true,used:complete.length,distances,squared,flags,flagged:0};\n}\n}\nlet flagged=0;\nfor(let c=0;c<complete.length;c++){\nconst row=complete[c];\nconst dev=new Array(k);\nfor(let j=0;j<k;j++)dev[j]=row[j]-mean[j];\nlet d2=0;\nfor(let a=0;a<k;a++){\nlet sa=0;\nfor(let b=0;b<k;b++)sa+=inverse[a][b]*dev[b];\nd2+=dev[a]*sa;\n}\nif(d2<0)d2=0;\nconst at=completeIndex[c];\nsquared[at]=d2;\ndistances[at]=Math.sqrt(d2);\nif(d2>cutoff){flags[at]=true;flagged++;}\n}\nreturn{\ncenter:mean,df,cutoff,singular,used:complete.length,distances,squared,flags,flagged,\n};\n}\n});\n__def(\"packages/core/src/compute/index.js\",function(__exports,__req){\n'use strict';\nconst __m0=__req(\"packages/core/src/compute/sort.js\");\nObject.defineProperty(__exports,\"sortColumn\",{enumerable:true,get:function(){return __m0[\"sortColumn\"];}});\nObject.defineProperty(__exports,\"sortMulti\",{enumerable:true,get:function(){return __m0[\"sortMulti\"];}});\nObject.defineProperty(__exports,\"radixSortFloat64\",{enumerable:true,get:function(){return __m0[\"radixSortFloat64\"];}});\nObject.defineProperty(__exports,\"radixSortInt32\",{enumerable:true,get:function(){return __m0[\"radixSortInt32\"];}});\nObject.defineProperty(__exports,\"rankSortDictionary\",{enumerable:true,get:function(){return __m0[\"rankSortDictionary\"];}});\nObject.defineProperty(__exports,\"mergeSortComparator\",{enumerable:true,get:function(){return __m0[\"mergeSortComparator\"];}});\nObject.defineProperty(__exports,\"collateStringRanks\",{enumerable:true,get:function(){return __m0[\"collateStringRanks\"];}});\nObject.defineProperty(__exports,\"rankSortStrings\",{enumerable:true,get:function(){return __m0[\"rankSortStrings\"];}});\nconst __m1=__req(\"packages/core/src/compute/sortspec.js\");\nObject.defineProperty(__exports,\"collationDescriptor\",{enumerable:true,get:function(){return __m1[\"collationDescriptor\"];}});\nObject.defineProperty(__exports,\"isPortableSort\",{enumerable:true,get:function(){return __m1[\"isPortableSort\"];}});\nObject.defineProperty(__exports,\"isPortableSortSet\",{enumerable:true,get:function(){return __m1[\"isPortableSortSet\"];}});\nObject.defineProperty(__exports,\"describeSortEntry\",{enumerable:true,get:function(){return __m1[\"describeSortEntry\"];}});\nObject.defineProperty(__exports,\"describeSort\",{enumerable:true,get:function(){return __m1[\"describeSort\"];}});\nconst __m2=__req(\"packages/core/src/compute/filter.js\");\nObject.defineProperty(__exports,\"evaluateFilters\",{enumerable:true,get:function(){return __m2[\"evaluateFilters\"];}});\nObject.defineProperty(__exports,\"evaluateCondition\",{enumerable:true,get:function(){return __m2[\"evaluateCondition\"];}});\nObject.defineProperty(__exports,\"compact\",{enumerable:true,get:function(){return __m2[\"compact\"];}});\nObject.defineProperty(__exports,\"testValue\",{enumerable:true,get:function(){return __m2[\"testValue\"];}});\nObject.defineProperty(__exports,\"compilePredicate\",{enumerable:true,get:function(){return __m2[\"compilePredicate\"];}});\nObject.defineProperty(__exports,\"releaseMask\",{enumerable:true,get:function(){return __m2[\"releaseMask\"];}});\nObject.defineProperty(__exports,\"pruneColumn\",{enumerable:true,get:function(){return __m2[\"pruneColumn\"];}});\nObject.defineProperty(__exports,\"mentionsColumn\",{enumerable:true,get:function(){return __m2[\"mentionsColumn\"];}});\nconst __m3=__req(\"packages/core/src/compute/group.js\");\nObject.defineProperty(__exports,\"groupByColumns\",{enumerable:true,get:function(){return __m3[\"groupByColumns\"];}});\nObject.defineProperty(__exports,\"packKeys\",{enumerable:true,get:function(){return __m3[\"packKeys\"];}});\nconst __m4=__req(\"packages/core/src/compute/facet.js\");\nObject.defineProperty(__exports,\"facet\",{enumerable:true,get:function(){return __m4[\"facet\"];}});\nObject.defineProperty(__exports,\"computeBounds\",{enumerable:true,get:function(){return __m4[\"computeBounds\"];}});\nObject.defineProperty(__exports,\"countInto\",{enumerable:true,get:function(){return __m4[\"countInto\"];}});\nObject.defineProperty(__exports,\"bucketOf\",{enumerable:true,get:function(){return __m4[\"bucketOf\"];}});\nObject.defineProperty(__exports,\"facetKind\",{enumerable:true,get:function(){return __m4[\"facetKind\"];}});\nObject.defineProperty(__exports,\"cardinalityOf\",{enumerable:true,get:function(){return __m4[\"cardinalityOf\"];}});\nObject.defineProperty(__exports,\"pickGranularity\",{enumerable:true,get:function(){return __m4[\"pickGranularity\"];}});\nObject.defineProperty(__exports,\"floorTo\",{enumerable:true,get:function(){return __m4[\"floorTo\"];}});\nObject.defineProperty(__exports,\"advance\",{enumerable:true,get:function(){return __m4[\"advance\"];}});\nObject.defineProperty(__exports,\"STRATEGIES\",{enumerable:true,get:function(){return __m4[\"STRATEGIES\"];}});\nObject.defineProperty(__exports,\"GRANULARITIES\",{enumerable:true,get:function(){return __m4[\"GRANULARITIES\"];}});\nObject.defineProperty(__exports,\"DEFAULT_BUCKETS\",{enumerable:true,get:function(){return __m4[\"DEFAULT_BUCKETS\"];}});\nObject.defineProperty(__exports,\"DEFAULT_CARDINALITY_LIMIT\",{enumerable:true,get:function(){return __m4[\"DEFAULT_CARDINALITY_LIMIT\"];}});\nObject.defineProperty(__exports,\"QUANTILE_SAMPLE\",{enumerable:true,get:function(){return __m4[\"QUANTILE_SAMPLE\"];}});\nconst __m5=__req(\"packages/core/src/compute/total.js\");\nObject.defineProperty(__exports,\"TOTAL_FNS\",{enumerable:true,get:function(){return __m5[\"TOTAL_FNS\"];}});\nObject.defineProperty(__exports,\"TOTAL_LABELS\",{enumerable:true,get:function(){return __m5[\"TOTAL_LABELS\"];}});\nObject.defineProperty(__exports,\"totalLabel\",{enumerable:true,get:function(){return __m5[\"totalLabel\"];}});\nObject.defineProperty(__exports,\"total\",{enumerable:true,get:function(){return __m5[\"total\"];}});\nObject.defineProperty(__exports,\"collectValues\",{enumerable:true,get:function(){return __m5[\"collectValues\"];}});\nconst __m6=__req(\"packages/core/src/compute/pivot.js\");\nObject.defineProperty(__exports,\"pivot\",{enumerable:true,get:function(){return __m6[\"pivot\"];}});\nObject.defineProperty(__exports,\"resolvePivotKeys\",{enumerable:true,get:function(){return __m6[\"resolvePivotKeys\"];}});\nObject.defineProperty(__exports,\"pivotKey\",{enumerable:true,get:function(){return __m6[\"pivotKey\"];}});\nObject.defineProperty(__exports,\"joinPath\",{enumerable:true,get:function(){return __m6[\"joinPath\"];}});\nObject.defineProperty(__exports,\"KEY_DELIMITER\",{enumerable:true,get:function(){return __m6[\"KEY_DELIMITER\"];}});\nObject.defineProperty(__exports,\"DEFAULT_PATH_SEPARATOR\",{enumerable:true,get:function(){return __m6[\"DEFAULT_PATH_SEPARATOR\"];}});\nObject.defineProperty(__exports,\"DEFAULT_MAX_COLUMNS\",{enumerable:true,get:function(){return __m6[\"DEFAULT_MAX_COLUMNS\"];}});\nconst __m7=__req(\"packages/core/src/compute/pivotmatrix.js\");\nObject.defineProperty(__exports,\"pivotMatrix\",{enumerable:true,get:function(){return __m7[\"pivotMatrix\"];}});\nObject.defineProperty(__exports,\"resolveAxis\",{enumerable:true,get:function(){return __m7[\"resolveAxis\"];}});\nObject.defineProperty(__exports,\"cellKey\",{enumerable:true,get:function(){return __m7[\"cellKey\"];}});\nObject.defineProperty(__exports,\"marginKey\",{enumerable:true,get:function(){return __m7[\"marginKey\"];}});\nObject.defineProperty(__exports,\"GRAND_PATH\",{enumerable:true,get:function(){return __m7[\"GRAND_PATH\"];}});\nconst __m8=__req(\"packages/core/src/compute/reference.js\");\nObject.defineProperty(__exports,\"referenceSort\",{enumerable:true,get:function(){return __m8[\"referenceSort\"];}});\nObject.defineProperty(__exports,\"referenceFilter\",{enumerable:true,get:function(){return __m8[\"referenceFilter\"];}});\nObject.defineProperty(__exports,\"referenceGroup\",{enumerable:true,get:function(){return __m8[\"referenceGroup\"];}});\nObject.defineProperty(__exports,\"referenceTotal\",{enumerable:true,get:function(){return __m8[\"referenceTotal\"];}});\nObject.defineProperty(__exports,\"referencePasses\",{enumerable:true,get:function(){return __m8[\"referencePasses\"];}});\nObject.defineProperty(__exports,\"referenceValue\",{enumerable:true,get:function(){return __m8[\"referenceValue\"];}});\nconst __m9=__req(\"packages/core/src/compute/handle.js\");\nObject.defineProperty(__exports,\"identity\",{enumerable:true,get:function(){return __m9[\"identity\"];}});\nObject.defineProperty(__exports,\"rowCount\",{enumerable:true,get:function(){return __m9[\"rowCount\"];}});\nObject.defineProperty(__exports,\"presenceReader\",{enumerable:true,get:function(){return __m9[\"presenceReader\"];}});\nObject.defineProperty(__exports,\"bitReader\",{enumerable:true,get:function(){return __m9[\"bitReader\"];}});\nObject.defineProperty(__exports,\"valueReader\",{enumerable:true,get:function(){return __m9[\"valueReader\"];}});\nObject.defineProperty(__exports,\"valueComparator\",{enumerable:true,get:function(){return __m9[\"valueComparator\"];}});\nObject.defineProperty(__exports,\"numericTotalOrder\",{enumerable:true,get:function(){return __m9[\"numericTotalOrder\"];}});\nObject.defineProperty(__exports,\"dictRanks\",{enumerable:true,get:function(){return __m9[\"dictRanks\"];}});\nObject.defineProperty(__exports,\"dictSize\",{enumerable:true,get:function(){return __m9[\"dictSize\"];}});\nObject.defineProperty(__exports,\"dictValue\",{enumerable:true,get:function(){return __m9[\"dictValue\"];}});\nObject.defineProperty(__exports,\"multiValue\",{enumerable:true,get:function(){return __m9[\"multiValue\"];}});\nObject.defineProperty(__exports,\"isMissing\",{enumerable:true,get:function(){return __m9[\"isMissing\"];}});\nconst __m10=__req(\"packages/core/src/compute/sketch.js\");\nObject.defineProperty(__exports,\"Welford\",{enumerable:true,get:function(){return __m10[\"Welford\"];}});\nObject.defineProperty(__exports,\"Reservoir\",{enumerable:true,get:function(){return __m10[\"Reservoir\"];}});\nObject.defineProperty(__exports,\"HyperLogLog\",{enumerable:true,get:function(){return __m10[\"HyperLogLog\"];}});\nObject.defineProperty(__exports,\"SpaceSaving\",{enumerable:true,get:function(){return __m10[\"SpaceSaving\"];}});\nObject.defineProperty(__exports,\"KLL\",{enumerable:true,get:function(){return __m10[\"KLL\"];}});\nObject.defineProperty(__exports,\"hash32\",{enumerable:true,get:function(){return __m10[\"hash32\"];}});\nObject.defineProperty(__exports,\"SKETCH_BOUNDS\",{enumerable:true,get:function(){return __m10[\"SKETCH_BOUNDS\"];}});\nconst __m11=__req(\"packages/core/src/compute/windowed.js\");\nObject.defineProperty(__exports,\"Window\",{enumerable:true,get:function(){return __m11[\"Window\"];}});\nObject.defineProperty(__exports,\"WINDOW_KINDS\",{enumerable:true,get:function(){return __m11[\"WINDOW_KINDS\"];}});\nObject.defineProperty(__exports,\"openWindow\",{enumerable:true,get:function(){return __m11[\"openWindow\"];}});\nconst __m12=__req(\"packages/core/src/compute/statistics.js\");\nObject.defineProperty(__exports,\"MAINTENANCE\",{enumerable:true,get:function(){return __m12[\"MAINTENANCE\"];}});\nObject.defineProperty(__exports,\"APPROXIMATE\",{enumerable:true,get:function(){return __m12[\"APPROXIMATE\"];}});\nObject.defineProperty(__exports,\"maintenanceOf\",{enumerable:true,get:function(){return __m12[\"maintenanceOf\"];}});\nconst __m13=__req(\"packages/core/src/compute/anomaly.js\");\nObject.defineProperty(__exports,\"ANOMALY_METHODS\",{enumerable:true,get:function(){return __m13[\"ANOMALY_METHODS\"];}});\nObject.defineProperty(__exports,\"modifiedZScores\",{enumerable:true,get:function(){return __m13[\"modifiedZScores\"];}});\nObject.defineProperty(__exports,\"iqrFences\",{enumerable:true,get:function(){return __m13[\"iqrFences\"];}});\nObject.defineProperty(__exports,\"mahalanobis\",{enumerable:true,get:function(){return __m13[\"mahalanobis\"];}});\n});\n__def(\"packages/worker/src/kernel.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"loadCompute\",{enumerable:true,get:function(){return loadCompute;}});\nObject.defineProperty(__exports,\"setCompute\",{enumerable:true,get:function(){return setCompute;}});\nObject.defineProperty(__exports,\"dispatch\",{enumerable:true,get:function(){return dispatch;}});\nObject.defineProperty(__exports,\"handleMessage\",{enumerable:true,get:function(){return handleMessage;}});\nObject.defineProperty(__exports,\"installKernel\",{enumerable:true,get:function(){return installKernel;}});\nconst __m0=__req(\"packages/worker/src/transport.js\");\nconst PROTOCOL=__m0[\"PROTOCOL\"];\nconst OPS=__m0[\"OPS\"];\nconst CONTROL=__m0[\"CONTROL\"];\nconst ERRORS=__m0[\"ERRORS\"];\nconst unpackHandle=__m0[\"unpackHandle\"];\nconst unpackHandles=__m0[\"unpackHandles\"];\nconst createMaskPool=__m0[\"createMaskPool\"];\nconst collectTransfers=__m0[\"collectTransfers\"];\nconst __m1=__req(\"packages/core/src/store/columnpack.js\");\nconst packChunk=__m1[\"packChunk\"];\nconst packedTransfers=__m1[\"packedTransfers\"];\nlet computeModule=null;\nlet computePromise=null;\nlet computeError=null;\nasync function loadCompute(loader){\nif(computeModule)return computeModule;\nif(!computePromise){\nconst load=loader||(()=>Promise.resolve(__req(\"packages/core/src/compute/index.js\")));\ncomputePromise=Promise.resolve()\n.then(load)\n.then((mod)=>{computeModule=mod;return mod;})\n.catch((err)=>{\ncomputeError=err;\ncomputeModule=null;\nreturn null;\n});\n}\nreturn computePromise;\n}\nfunction setCompute(mod){\ncomputeModule=mod;\ncomputePromise=mod?Promise.resolve(mod):null;\ncomputeError=mod?null:computeError;\n}\nfunction filterContext(handles,count,locale){\nconst byId=new Map();\nfor(const h of handles)if(h)byId.set(h.id,h);\nreturn{\nhandle(colId){return byId.get(colId);},\ncount,\npool:createMaskPool(),\nlocale,\n};\n}\nfunction dispatch(request,compute){\nconst{op,args}=request;\nif(op===OPS.COLUMNIZE){\nreturn packChunk(args.schema||[],args.rows||[],args.opts||{});\n}\nconst fn=compute[op];\nif(typeof fn!=='function'){\nconst err=new Error(`[lattice] compute kernel '${op}' is not exported`);\n(err).code=ERRORS.NO_KERNEL;\nthrow err;\n}\nswitch(op){\ncase OPS.COLLATE_STRING_RANKS:\nreturn fn(args.table||[],(args.table||[]).length,args.locale);\ncase OPS.SORT_COLUMN:\nreturn fn(unpackHandle(args.handle),args.order??null,args.opts||{});\ncase OPS.SORT_MULTI:{\nconst handles=unpackHandles(args.handles||[]);\nconst entries=(args.entries||[]).map((e)=>({\n...e,\nhandle:handles[e.index],\n}));\nreturn fn(handles,entries,args.order??null);\n}\ncase OPS.EVALUATE_FILTERS:\nreturn fn(args.filters,filterContext(unpackHandles(args.handles||[]),args.count,args.locale));\ncase OPS.COMPACT:\nreturn fn(args.mask,args.count,undefined);\ncase OPS.GROUP_BY_COLUMNS:\nreturn fn(unpackHandles(args.handles||[]),args.order??null,args.opts||{});\ncase OPS.TOTAL:\nreturn fn(unpackHandle(args.handle),args.indices??null,args.fn);\ncase OPS.PIVOT:\nreturn fn(unpackHandles(args.handles||[]),args.order??null,args.opts||{});\ncase OPS.FACET:\nreturn fn(unpackHandle(args.handle),args.indices??null,args.count,args.opts||{});\ndefault:{\nconst err=new Error(`[lattice] unknown worker op '${op}'`);\n(err).code=ERRORS.PROTOCOL;\nthrow err;\n}\n}\n}\nasync function handleMessage(message,opts={}){\nif(!message||message.lattice!==PROTOCOL)return null;\nconst{id,op}=message;\nif(op===CONTROL.CANCEL){\nopts.cancelled?.add(message.target);\nreturn null;\n}\nif(op===CONTROL.PING){\nreturn{reply:{lattice:PROTOCOL,id,ok:true,result:'pong'},transfer:[]};\n}\nif(op===OPS.COLUMNIZE){\nif(opts.cancelled?.has(id)){opts.cancelled.delete(id);return null;}\ntry{\nconst result=packChunk(message.args.schema||[],message.args.rows||[],message.args.opts||{});\nif(opts.cancelled?.has(id)){\nopts.cancelled.delete(id);\nreturn{reply:{lattice:PROTOCOL,id,ok:false,error:{code:ERRORS.ABORTED,message:'[lattice] request superseded'}},transfer:[]};\n}\nreturn{reply:{lattice:PROTOCOL,id,ok:true,result},transfer:packedTransfers(result)};\n}catch(err){\nconst e=(err);\nreturn{\nreply:{lattice:PROTOCOL,id,ok:false,error:{code:e.code||ERRORS.KERNEL,message:e.message||String(err),stack:e.stack}},\ntransfer:[],\n};\n}\n}\nconst compute=await loadCompute(opts.loader);\nif(!compute){\nreturn{\nreply:{\nlattice:PROTOCOL,\nid,\nok:false,\nerror:{\ncode:ERRORS.NO_COMPUTE,\nmessage:`[lattice] compute kernels unavailable in worker: ${computeError?computeError.message:'module not found'}`,\n},\n},\ntransfer:[],\n};\n}\nif(opts.cancelled?.has(id)){\nopts.cancelled.delete(id);\nreturn{reply:{lattice:PROTOCOL,id,ok:false,error:{code:ERRORS.ABORTED,message:'[lattice] request superseded'}},transfer:[]};\n}\ntry{\nconst result=dispatch(message,compute);\nif(opts.cancelled?.has(id)){\nopts.cancelled.delete(id);\nreturn{reply:{lattice:PROTOCOL,id,ok:false,error:{code:ERRORS.ABORTED,message:'[lattice] request superseded'}},transfer:[]};\n}\nreturn{reply:{lattice:PROTOCOL,id,ok:true,result},transfer:collectTransfers(result)};\n}catch(err){\nconst e=(err);\nreturn{\nreply:{\nlattice:PROTOCOL,\nid,\nok:false,\nerror:{code:e.code||ERRORS.KERNEL,message:e.message||String(err),stack:e.stack},\n},\ntransfer:[],\n};\n}\n}\nfunction installKernel(scope,opts={}){\nconst cancelled=new Set();\nconst onMessage=async(event)=>{\nconst outcome=await handleMessage(event.data,{loader:opts.loader,cancelled});\nif(!outcome)return;\nscope.postMessage(outcome.reply,outcome.transfer);\n};\nscope.addEventListener('message',onMessage);\nloadCompute(opts.loader).then((mod)=>{\nscope.postMessage({lattice:PROTOCOL,id:0,op:CONTROL.READY,compute:!!mod});\n});\nreturn()=>scope.removeEventListener('message',onMessage);\n}\n});\nvar __entry=__req(\"packages/worker/src/kernel.js\");\nroot[\"__latticeKernel\"]=__entry;\n})(typeof globalThis!=='undefined'?globalThis:this);\n__latticeKernel.installKernel(self);\n",{type:'classic'});
|
|
77786
|
+
__req("packages/worker/src/inline.js").setWorkerSource("(function(root){\n'use strict';\nvar __mods=Object.create(null);\nvar __cache=Object.create(null);\nfunction __def(id,fn){__mods[id]=fn;}\nfunction __req(id){\nvar hit=__cache[id];\nif(hit)return hit;\nvar exports=Object.create(null);\n__cache[id]=exports;\nvar fn=__mods[id];\nif(!fn)throw new Error('[lattice] missing module: '+id);\nfn(exports,__req);\nreturn exports;\n}\n__def(\"packages/core/src/internal/util.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"VERSION\",{enumerable:true,get:function(){return VERSION;}});\nObject.defineProperty(__exports,\"reportedWarnings\",{enumerable:true,get:function(){return reportedWarnings;}});\nObject.defineProperty(__exports,\"warnOnce\",{enumerable:true,get:function(){return warnOnce;}});\nObject.defineProperty(__exports,\"infoOnce\",{enumerable:true,get:function(){return infoOnce;}});\nObject.defineProperty(__exports,\"resetWarnings\",{enumerable:true,get:function(){return resetWarnings;}});\nObject.defineProperty(__exports,\"fail\",{enumerable:true,get:function(){return fail;}});\nObject.defineProperty(__exports,\"invariant\",{enumerable:true,get:function(){return invariant;}});\nObject.defineProperty(__exports,\"DEV\",{enumerable:true,get:function(){return DEV;}});\nObject.defineProperty(__exports,\"isObject\",{enumerable:true,get:function(){return isObject;}});\nObject.defineProperty(__exports,\"isFunction\",{enumerable:true,get:function(){return isFunction;}});\nObject.defineProperty(__exports,\"isNil\",{enumerable:true,get:function(){return isNil;}});\nObject.defineProperty(__exports,\"isBlank\",{enumerable:true,get:function(){return isBlank;}});\nObject.defineProperty(__exports,\"isCtor\",{enumerable:true,get:function(){return isCtor;}});\nObject.defineProperty(__exports,\"pathGetter\",{enumerable:true,get:function(){return pathGetter;}});\nObject.defineProperty(__exports,\"pathSetter\",{enumerable:true,get:function(){return pathSetter;}});\nObject.defineProperty(__exports,\"getPath\",{enumerable:true,get:function(){return getPath;}});\nObject.defineProperty(__exports,\"setPath\",{enumerable:true,get:function(){return setPath;}});\nObject.defineProperty(__exports,\"humanise\",{enumerable:true,get:function(){return humanise;}});\nObject.defineProperty(__exports,\"escapeHtml\",{enumerable:true,get:function(){return escapeHtml;}});\nObject.defineProperty(__exports,\"titleCase\",{enumerable:true,get:function(){return titleCase;}});\nObject.defineProperty(__exports,\"expand\",{enumerable:true,get:function(){return expand;}});\nObject.defineProperty(__exports,\"toArray\",{enumerable:true,get:function(){return toArray;}});\nObject.defineProperty(__exports,\"merge\",{enumerable:true,get:function(){return merge;}});\nObject.defineProperty(__exports,\"mergeRow\",{enumerable:true,get:function(){return mergeRow;}});\nObject.defineProperty(__exports,\"Lru\",{enumerable:true,get:function(){return Lru;}});\nObject.defineProperty(__exports,\"collator\",{enumerable:true,get:function(){return collator;}});\nObject.defineProperty(__exports,\"defaultCompare\",{enumerable:true,get:function(){return defaultCompare;}});\nObject.defineProperty(__exports,\"now\",{enumerable:true,get:function(){return now;}});\nObject.defineProperty(__exports,\"nextFrame\",{enumerable:true,get:function(){return nextFrame;}});\nObject.defineProperty(__exports,\"cancelFrame\",{enumerable:true,get:function(){return cancelFrame;}});\nObject.defineProperty(__exports,\"frameBatched\",{enumerable:true,get:function(){return frameBatched;}});\nObject.defineProperty(__exports,\"settleDebounce\",{enumerable:true,get:function(){return settleDebounce;}});\nObject.defineProperty(__exports,\"whenIdle\",{enumerable:true,get:function(){return whenIdle;}});\nObject.defineProperty(__exports,\"uid\",{enumerable:true,get:function(){return uid;}});\nconst STAMPED_VERSION=\"1.30.0\";\nasync function resolveVersion(){\nif(STAMPED_VERSION!=='0.0.0-source')return STAMPED_VERSION;\ntry{\nif(typeof process==='undefined'||!process.versions||!process.versions.node){\nreturn STAMPED_VERSION;\n}\nconst mod=await import('node:'+'module');\nconst req=mod.createRequire((typeof document!=='undefined'&&document.currentScript?document.currentScript.src:''));\nconst fs=req('node:'+'fs');\nconst url=new URL('../../../../package.json',(typeof document!=='undefined'&&document.currentScript?document.currentScript.src:''));\nconst text=fs.readFileSync(url,'utf8');\nreturn JSON.parse(text).version||STAMPED_VERSION;\n}catch{\nreturn STAMPED_VERSION;\n}\n}\nconst VERSION=\"1.30.0\";\nconst warned=new Set();\nconst WARNED_LIMIT=2000;\nfunction rememberWarned(key){\nwarned.add(key);\nif(warned.size>WARNED_LIMIT){\nconst oldest=warned.values().next().value;\nif(oldest!==undefined)warned.delete(oldest);\n}\n}\nconst reported=[];\nconst REPORT_LIMIT=500;\nfunction record(key,level,message){\nreported.push({\nkey,\nlevel,\nmessage:message.map((m)=>(typeof m==='string'?m:safeString(m))).join(' '),\nat:Date.now(),\n});\nif(reported.length>REPORT_LIMIT)reported.shift();\n}\nfunction safeString(value){\nif(value instanceof Error)return value.message;\ntry{return JSON.stringify(value);}catch{return String(value);}\n}\nfunction reportedWarnings(){return reported.map((r)=>({...r}));}\nfunction warnOnce(key,...message){\nif(warned.has(key))return;\nrememberWarned(key);\nrecord(key,'warn',message);\nconsole.warn('[lattice]',...message);\n}\nfunction infoOnce(key,...message){\nif(warned.has(key))return;\nrememberWarned(key);\nrecord(key,'info',message);\nconsole.info('[lattice]',...message);\n}\nfunction resetWarnings(){\nwarned.clear();\nreported.length=0;\n}\nfunction fail(message,extra){\nconst err=new Error(`[lattice] ${message}`);\nif(extra!==undefined)err.cause=extra;\nthrow err;\n}\nfunction invariant(condition,message){\nif(!condition)fail(message);\n}\nconst DEV=(()=>{\ntry{\nreturn!(typeof process!=='undefined'&&process.env\n&&process.env.NODE_ENV==='production');\n}catch{\nreturn true;\n}\n})();\nfunction isObject(v){\nreturn v!==null&&typeof v==='object'&&!Array.isArray(v);\n}\nfunction isFunction(v){\nreturn typeof v==='function';\n}\nfunction isNil(v){\nreturn v===null||v===undefined;\n}\nfunction isBlank(v){\nreturn v===null||v===undefined||v==='';\n}\nfunction isCtor(v){\nif(typeof v!=='function')return false;\nif(/^class[\\s{]/.test(Function.prototype.toString.call(v)))return true;\nreturn!!(v.prototype&&Object.getOwnPropertyNames(v.prototype).length>1);\n}\nconst pathCache=new Map();\nfunction pathGetter(path){\nlet fn=pathCache.get(path);\nif(fn)return fn;\nif(!path.includes('.')){\nfn=(o)=>(o==null?undefined:o[path]);\n}else{\nconst parts=path.split('.');\nconst n=parts.length;\nfn=(o)=>{\nlet cur=o;\nfor(let i=0;i<n;i++){\nif(cur==null)return undefined;\ncur=cur[parts[i]];\n}\nreturn cur;\n};\n}\npathCache.set(path,fn);\nreturn fn;\n}\nconst setterCache=new Map();\nfunction pathSetter(path){\nlet fn=setterCache.get(path);\nif(fn)return fn;\nif(!path.includes('.')){\nfn=(o,v)=>{if(o!=null)o[path]=v;};\n}else{\nconst parts=path.split('.');\nconst last=parts.length-1;\nfn=(o,v)=>{\nlet cur=o;\nfor(let i=0;i<last;i++){\nif(cur==null)return;\nconst k=parts[i];\nif(cur[k]==null)cur[k]={};\ncur=cur[k];\n}\nif(cur!=null)cur[parts[last]]=v;\n};\n}\nsetterCache.set(path,fn);\nreturn fn;\n}\nfunction getPath(obj,path){\nreturn pathGetter(path)(obj);\n}\nfunction setPath(obj,path,value){\npathSetter(path)(obj,value);\n}\nfunction humanise(field){\nif(!field)return'';\nconst leaf=field.includes('.')?field.slice(field.lastIndexOf('.')+1):field;\nreturn leaf\n.replace(/[_-]+/g,' ')\n.replace(/([a-z0-9])([A-Z])/g,'$1 $2')\n.replace(/([A-Z]+)([A-Z][a-z])/g,'$1 $2')\n.replace(/\\s+/g,' ')\n.trim()\n.replace(/^./,(c)=>c.toUpperCase());\n}\nconst ESCAPES={'&':'&','<':'<','>':'>','\"':'"',\"'\":'''};\nfunction escapeHtml(s){\nconst str=s==null?'':String(s);\nreturn/[&<>\"']/.test(str)?str.replace(/[&<>\"']/g,(c)=>ESCAPES[c]):str;\n}\nfunction titleCase(s){\nreturn String(s).replace(/\\w\\S*/g,(t)=>t[0].toUpperCase()+t.slice(1).toLowerCase());\n}\nfunction expand(value,key,whenTrue){\nif(value===undefined)return undefined;\nif(value===true)return{enabled:true,...whenTrue};\nif(value===false)return{enabled:false};\nif(isObject(value))return value;\nreturn{[key]:value,enabled:true};\n}\nfunction toArray(v){\nif(v===undefined||v===null)return[];\nreturn Array.isArray(v)?v:[v];\n}\nconst MERGE_FORBIDDEN_KEYS=Object.freeze(new Set(['__proto__','constructor','prototype']));\nfunction merge(a,b){\nif(!isObject(a))return isObject(b)?{...b}:b;\nif(!isObject(b))return b===undefined?a:b;\nconst out={...a};\nfor(const k of Object.keys(b)){\nif(MERGE_FORBIDDEN_KEYS.has(k))continue;\nconst bv=b[k];\nif(bv===undefined)continue;\nout[k]=isObject(bv)&&isObject(out[k])?merge(out[k],bv):bv;\n}\nreturn out;\n}\nfunction mergeRow(previous,patch){\nif(!isObject(previous)||!isObject(patch)||previous===patch)return patch;\nconst out=Object.create(Object.getPrototypeOf(previous));\nObject.assign(out,previous,patch);\nreturn out;\n}\nclass Lru{\n#max;\n#map=new Map();\n#onEvict;\nconstructor(max=256,onEvict=null){\nthis.#max=max;\nthis.#onEvict=onEvict;\n}\nget size(){\nreturn this.#map.size;\n}\nget max(){\nreturn this.#max;\n}\nset max(v){\nthis.#max=v;\nthis.#trim();\n}\nhas(k){\nreturn this.#map.has(k);\n}\nget(k){\nconst m=this.#map;\nif(!m.has(k))return undefined;\nconst v=m.get(k);\nm.delete(k);\nm.set(k,v);\nreturn v;\n}\npeek(k){\nreturn this.#map.get(k);\n}\nset(k,v){\nconst m=this.#map;\nif(m.has(k))m.delete(k);\nm.set(k,v);\nthis.#trim();\nreturn v;\n}\ndelete(k){\nconst v=this.#map.get(k);\nif(this.#map.delete(k)&&this.#onEvict)this.#onEvict(v,k);\nreturn v;\n}\nclear(){\nif(this.#onEvict)for(const[k,v]of this.#map)this.#onEvict(v,k);\nthis.#map.clear();\n}\nkeys(){\nreturn this.#map.keys();\n}\nvalues(){\nreturn this.#map.values();\n}\n#trim(){\nconst m=this.#map;\nwhile(m.size>this.#max){\nconst oldest=m.keys().next().value;\nconst v=m.get(oldest);\nm.delete(oldest);\nif(this.#onEvict)this.#onEvict(v,oldest);\n}\n}\n}\nconst collators=new Map();\nfunction collator(locale,opts){\nconst key=`${locale||''}|${opts?JSON.stringify(opts):''}`;\nlet c=collators.get(key);\nif(!c){\nc=new Intl.Collator(locale||undefined,{\nnumeric:true,sensitivity:'variant',...opts,\n});\ncollators.set(key,c);\n}\nreturn c;\n}\nfunction defaultCompare(a,b){\nif(a===b)return 0;\nif(a===null||a===undefined)return 1;\nif(b===null||b===undefined)return-1;\nif(typeof a==='number'&&typeof b==='number'){\nif(Number.isNaN(a))return Number.isNaN(b)?0:1;\nif(Number.isNaN(b))return-1;\nreturn a<b?-1:a>b?1:0;\n}\nconst sa=String(a);\nconst sb=String(b);\nreturn sa<sb?-1:sa>sb?1:0;\n}\nfunction now(){\nreturn typeof performance!=='undefined'&&performance.now\n?performance.now()\n:Date.now();\n}\nconst hasRaf=typeof requestAnimationFrame==='function';\nfunction nextFrame(fn){\nif(hasRaf)return requestAnimationFrame(fn);\nreturn setTimeout(()=>fn(now()),16);\n}\nfunction cancelFrame(handle){\nif(handle==null)return;\nif(hasRaf)cancelAnimationFrame(handle);\nelse clearTimeout(handle);\n}\nfunction frameBatched(fn){\nlet handle=null;\nlet lastArgs=null;\nconst run=()=>{\nhandle=null;\nconst a=lastArgs;\nlastArgs=null;\nfn(...(a||[]));\n};\nconst wrapped=(...args)=>{\nlastArgs=args;\nif(handle===null)handle=nextFrame(run);\n};\nwrapped.cancel=()=>{\ncancelFrame(handle);\nhandle=null;\nlastArgs=null;\n};\nwrapped.flush=()=>{\nif(handle!==null){\ncancelFrame(handle);\nrun();\n}\n};\nreturn wrapped;\n}\nfunction settleDebounce(fn,waitMs){\nlet timer=null;\nlet held=null;\nconst trailing=()=>{\ntimer=null;\nif(held===null)return;\nconst args=held;\nheld=null;\nfn(...args);\narm();\n};\nconst arm=()=>{\ntimer=setTimeout(trailing,waitMs);\nif(typeof timer?.unref==='function')timer.unref();\n};\nconst wrapped=(...args)=>{\nif(timer===null){\nfn(...args);\narm();\n}else{\nheld=args;\nclearTimeout(timer);\narm();\n}\n};\nwrapped.flush=()=>{\nif(timer!==null)clearTimeout(timer);\ntimer=null;\nif(held===null)return;\nconst args=held;\nheld=null;\nfn(...args);\n};\nwrapped.cancel=()=>{\nif(timer!==null)clearTimeout(timer);\ntimer=null;\nheld=null;\n};\nwrapped.pending=()=>timer!==null||held!==null;\nreturn wrapped;\n}\nfunction whenIdle(fn,timeout=50){\nif(typeof requestIdleCallback==='function'){\nreturn requestIdleCallback(fn,{timeout});\n}\nreturn setTimeout(()=>fn({timeRemaining:()=>0,didTimeout:true}),1);\n}\nlet idSeq=0;\nfunction uid(prefix='l'){\nreturn`${prefix}${(++idSeq).toString(36)}`;\n}\n});\n__def(\"packages/worker/src/transport.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"PROTOCOL\",{enumerable:true,get:function(){return PROTOCOL;}});\nObject.defineProperty(__exports,\"OPS\",{enumerable:true,get:function(){return OPS;}});\nObject.defineProperty(__exports,\"CONTROL\",{enumerable:true,get:function(){return CONTROL;}});\nObject.defineProperty(__exports,\"ERRORS\",{enumerable:true,get:function(){return ERRORS;}});\nObject.defineProperty(__exports,\"packHandle\",{enumerable:true,get:function(){return packHandle;}});\nObject.defineProperty(__exports,\"packHandles\",{enumerable:true,get:function(){return packHandles;}});\nObject.defineProperty(__exports,\"TransportedDictionary\",{enumerable:true,get:function(){return TransportedDictionary;}});\nObject.defineProperty(__exports,\"unpackHandle\",{enumerable:true,get:function(){return unpackHandle;}});\nObject.defineProperty(__exports,\"unpackHandles\",{enumerable:true,get:function(){return unpackHandles;}});\nObject.defineProperty(__exports,\"createMaskPool\",{enumerable:true,get:function(){return createMaskPool;}});\nObject.defineProperty(__exports,\"isTransferable\",{enumerable:true,get:function(){return isTransferable;}});\nObject.defineProperty(__exports,\"collectTransfers\",{enumerable:true,get:function(){return collectTransfers;}});\nObject.defineProperty(__exports,\"isPortable\",{enumerable:true,get:function(){return isPortable;}});\nObject.defineProperty(__exports,\"filterColumnIds\",{enumerable:true,get:function(){return filterColumnIds;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst collator=__m0[\"collator\"];\nconst isFunction=__m0[\"isFunction\"];\nconst PROTOCOL=1;\nconst OPS=Object.freeze({\nSORT_COLUMN:'sortColumn',\nSORT_MULTI:'sortMulti',\nEVALUATE_FILTERS:'evaluateFilters',\nCOMPACT:'compact',\nGROUP_BY_COLUMNS:'groupByColumns',\nTOTAL:'total',\nPIVOT:'pivot',\nFACET:'facet',\nCOLUMNIZE:'columnize',\nCOLLATE_STRING_RANKS:'collateStringRanks',\n});\nconst CONTROL=Object.freeze({\nREADY:'ready',\nCANCEL:'cancel',\nPING:'ping',\n});\nconst ERRORS=Object.freeze({\nNO_COMPUTE:'E_NO_COMPUTE',\nNO_KERNEL:'E_NO_KERNEL',\nABORTED:'E_ABORTED',\nKERNEL:'E_KERNEL',\nPROTOCOL:'E_PROTOCOL',\n});\nfunction packHandle(handle){\nif(handle==null)return null;\nconst presence=handle.presence;\nreturn{\nid:handle.id,\nkind:handle.kind,\nnullable:!!handle.nullable,\nvalues:handle.values??null,\npresence:presence?(presence.words??presence):null,\npresenceBits:presence?(presence.size??(presence.words??presence).length*8):0,\ndict:handle.dict?sliceDictionary(handle.dict):null,\noffsets:handle.offsets??null,\nversion:handle.version??0,\n};\n}\nfunction sliceDictionary(dict){\nif(Array.isArray(dict))return dict;\nif(isFunction(dict.values))return dict.values();\nreturn[];\n}\nfunction packHandles(handles){\nconst out=new Array(handles.length);\nfor(let i=0;i<handles.length;i++)out[i]=packHandle(handles[i]);\nreturn out;\n}\nclass TransportedBitset{\n#words;\n#bits;\nconstructor(words,bits){\nthis.#words=words;\nthis.#bits=bits;\n}\nget words(){return this.#words;}\nget size(){return this.#bits;}\nget(i){return(this.#words[i>>>3]&(1<<(i&7)))!==0;}\ncount(){\nconst w=this.#words;\nlet n=0;\nfor(let i=0;i<w.length;i++){\nlet v=w[i];\nwhile(v){v&=v-1;n++;}\n}\nreturn n;\n}\n}\nclass TransportedDictionary{\n#values;\n#index=null;\n#version=0;\n#ranks=new Map();\nconstructor(values){\nthis.#values=values||[];\n}\nget size(){return this.#values.length;}\nget version(){return this.#version;}\ncodeOf(value){\nif(this.#index===null){\nthis.#index=new Map();\nfor(let i=0;i<this.#values.length;i++)this.#index.set(this.#values[i],i);\n}\nconst found=this.#index.get(value);\nif(found!==undefined)return found;\nconst code=this.#values.length;\nthis.#values.push(value);\nthis.#index.set(value,code);\nthis.#version++;\nreturn code;\n}\nvalueOf(code){return this.#values[code];}\nvalues(){return this.#values;}\nranks(locale){\nconst key=locale||'';\nconst cached=this.#ranks.get(key);\nif(cached&&cached.version===this.#version)return cached.ranks;\nconst n=this.#values.length;\nconst order=new Uint32Array(n);\nfor(let i=0;i<n;i++)order[i]=i;\nconst cmp=collator(locale).compare;\nconst vals=this.#values;\nconst sorted=Array.from(order).sort((a,b)=>{\nconst av=vals[a];\nconst bv=vals[b];\nif(av===bv)return 0;\nif(av===null||av===undefined)return 1;\nif(bv===null||bv===undefined)return-1;\nreturn cmp(String(av),String(bv));\n});\nconst ranks=new Uint32Array(n);\nfor(let r=0;r<sorted.length;r++)ranks[sorted[r]]=r;\nthis.#ranks.set(key,{version:this.#version,ranks});\nreturn ranks;\n}\n}\nfunction unpackHandle(packed){\nif(packed==null)return null;\nconst presence=packed.presence\n?new TransportedBitset(packed.presence,packed.presenceBits||packed.presence.length*8)\n:null;\nconst dict=packed.dict?new TransportedDictionary(packed.dict):null;\nconst values=packed.values;\nconst offsets=packed.offsets??null;\nconst kind=packed.kind;\nconst get=(physical)=>{\nif(presence&&!presence.get(physical))return null;\nswitch(kind){\ncase'dictionary':\nreturn dict?dict.valueOf(values[physical]):values[physical];\ncase'bitset':\nreturn(values[physical>>>3]&(1<<(physical&7)))!==0;\ncase'multi':{\nif(!offsets)return null;\nconst from=offsets[physical];\nconst to=offsets[physical+1];\nconst out=new Array(to-from);\nfor(let i=from;i<to;i++)out[i-from]=dict?dict.valueOf(values[i]):values[i];\nreturn out;\n}\ndefault:\nreturn values[physical];\n}\n};\nreturn{\nid:packed.id,\nkind,\nnullable:packed.nullable,\nvalues,\npresence,\ndict,\noffsets,\nget,\nversion:packed.version,\n};\n}\nfunction unpackHandles(packed){\nconst out=new Array(packed.length);\nfor(let i=0;i<packed.length;i++)out[i]=unpackHandle(packed[i]);\nreturn out;\n}\nfunction createMaskPool(){\nconst masks=[];\nconst indices=[];\nreturn{\nmask(n){\nfor(let i=0;i<masks.length;i++){\nif(masks[i].length>=n){\nconst buf=masks.splice(i,1)[0].subarray(0,n);\nbuf.fill(0);\nreturn buf;\n}\n}\nreturn new Uint8Array(n);\n},\nindices(n){\nfor(let i=0;i<indices.length;i++){\nif(indices[i].length>=n)return indices.splice(i,1)[0].subarray(0,n);\n}\nreturn new Uint32Array(n);\n},\nrelease(buf){\nif(!buf)return;\nif(buf instanceof Uint8Array)masks.push(buf);\nelse if(buf instanceof Uint32Array)indices.push(buf);\n},\nclear(){masks.length=0;indices.length=0;},\n};\n}\nfunction isTransferable(v){\nif(!ArrayBuffer.isView(v))return false;\nconst buf=(v).buffer;\nif(!buf)return false;\nreturn typeof SharedArrayBuffer==='undefined'||!(buf instanceof SharedArrayBuffer);\n}\nfunction collectTransfers(value,out=[]){\nconst add=(v)=>{\nif(!isTransferable(v))return;\nconst buf=(v).buffer;\nif(!out.includes(buf))out.push(buf);\n};\nif(value==null)return out;\nif(ArrayBuffer.isView(value)){add(value);return out;}\nif(Array.isArray(value)){\nfor(const item of value)add(item);\nreturn out;\n}\nif(typeof value==='object'){\nfor(const key of Object.keys(value)){\nconst item=(value)[key];\nif(Array.isArray(item))for(const sub of item)add(sub);\nelse add(item);\n}\n}\nreturn out;\n}\nfunction isPortable(value,depth=0){\nif(value==null)return true;\nconst t=typeof value;\nif(t==='function'||t==='symbol')return false;\nif(t!=='object')return true;\nif(depth>4)return true;\nif(ArrayBuffer.isView(value)||value instanceof ArrayBuffer||value instanceof Date)return true;\nif(Array.isArray(value)){\nfor(const item of value)if(!isPortable(item,depth+1))return false;\nreturn true;\n}\nfor(const key of Object.keys(value)){\nif(!isPortable((value)[key],depth+1))return false;\n}\nreturn true;\n}\nfunction filterColumnIds(filters,out=new Set()){\nif(!filters||typeof filters!=='object')return out;\nconst node=(filters);\nif(typeof node.col==='string')out.add(node.col);\nconst conditions=node.conditions;\nif(Array.isArray(conditions))for(const child of conditions)filterColumnIds(child,out);\nreturn out;\n}\n});\n__def(\"packages/core/src/store/bitset.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"Bitset\",{enumerable:true,get:function(){return Bitset;}});\nconst WORD_BITS=8;\nclass Bitset{\nstatic#POP=new Uint8Array(256);\nstatic{\nfor(let i=1;i<256;i++)Bitset.#POP[i]=Bitset.#POP[i>>1]+(i&1);\n}\n#words;\n#bits;\nconstructor(bits=0){\nconst n=Math.max(0,bits|0);\nthis.#bits=n;\nthis.#words=new Uint8Array(Math.ceil(n/WORD_BITS));\n}\nget size(){return this.#bits;}\nget words(){return this.#words;}\nget bytes(){return this.#words?this.#words.byteLength:0;}\nget(i){\nif(i<0||i>=this.#bits)return 0;\nreturn(this.#words[i>>3]>>(i&7))&1;\n}\nset(i){\nif(i>=0&&i<this.#bits)this.#words[i>>3]|=1<<(i&7);\nreturn this;\n}\nclear(i){\nif(i>=0&&i<this.#bits)this.#words[i>>3]&=~(1<<(i&7));\nreturn this;\n}\nassign(i,bit){return bit?this.set(i):this.clear(i);}\nfill(bit=false){\nthis.#words.fill(bit?0xff:0);\nif(bit)this.#maskTail();\nreturn this;\n}\ngrow(bits){\nconst n=Math.max(0,bits|0);\nif(n<=this.#bits)return this;\nconst need=Math.ceil(n/WORD_BITS);\nif(need>this.#words.length){\nconst next=new Uint8Array(need);\nnext.set(this.#words);\nthis.#words=next;\n}\nthis.#bits=n;\nreturn this;\n}\ncount(){\nconst w=this.#words;\nconst pop=Bitset.#POP;\nlet total=0;\nfor(let i=0;i<w.length;i++)total+=pop[w[i]];\nreturn total;\n}\nand(other){\nconst b=other instanceof Bitset?other.words:other;\nconst w=this.#words;\nconst shared=Math.min(w.length,b.length);\nfor(let i=0;i<shared;i++)w[i]&=b[i];\nfor(let i=shared;i<w.length;i++)w[i]=0;\nreturn this;\n}\nor(other){\nconst b=other instanceof Bitset?other.words:other;\nconst w=this.#words;\nconst shared=Math.min(w.length,b.length);\nfor(let i=0;i<shared;i++)w[i]|=b[i];\nreturn this;\n}\nnot(){\nconst w=this.#words;\nfor(let i=0;i<w.length;i++)w[i]=~w[i]&0xff;\nthis.#maskTail();\nreturn this;\n}\nclone(){\nconst out=new Bitset(this.#bits);\nout.words.set(this.#words.subarray(0,out.words.length));\nreturn out;\n}\nrelease(){\nthis.#words=new Uint8Array(0);\nthis.#bits=0;\n}\n#maskTail(){\nconst used=this.#bits&7;\nif(used===0)return;\nconst last=(this.#bits>>3);\nif(last<this.#words.length)this.#words[last]&=(1<<used)-1;\n}\nstatic from(bools){\nconst arr=Array.isArray(bools)?bools:Array.from(bools);\nconst out=new Bitset(arr.length);\nfor(let i=0;i<arr.length;i++)if(arr[i])out.set(i);\nreturn out;\n}\n}\n});\n__def(\"packages/core/src/store/dictionary.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"Dictionary\",{enumerable:true,get:function(){return Dictionary;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst collator=__m0[\"collator\"];\nconst defaultCompare=__m0[\"defaultCompare\"];\nclass Dictionary{\n#values;\n#codes=new Map();\n#version=0;\n#ranks=null;\n#ranksVersion=-1;\n#ranksLocale='\\u0000';\nconstructor(values=[]){\nthis.#values=[];\nfor(let i=0;i<values.length;i++){\nconst v=values[i];\nif(this.#codes.has(v))continue;\nthis.#codes.set(v,this.#values.length);\nthis.#values.push(v);\n}\n}\nget size(){return this.#values.length;}\nget version(){return this.#version;}\nget bytes(){\nlet total=this.#values.length*8;\nfor(let i=0;i<this.#values.length;i++){\nconst v=this.#values[i];\nif(typeof v==='string')total+=v.length*2;\ntotal+=16;\n}\nreturn total;\n}\ncodeOf(value){\nconst existing=this.#codes.get(value);\nif(existing!==undefined)return existing;\nconst code=this.#values.length;\nthis.#values.push(value);\nthis.#codes.set(value,code);\nthis.#version++;\nreturn code;\n}\nlookup(value){\nconst code=this.#codes.get(value);\nreturn code===undefined?-1:code;\n}\nhas(value){return this.#codes.has(value);}\nvalueOf(code){return this.#values[code];}\nvalues(){return this.#values;}\nranks(locale){\nconst key=locale||'';\nif(this.#ranks&&this.#ranksVersion===this.#version&&this.#ranksLocale===key){\nreturn this.#ranks;\n}\nconst n=this.#values.length;\nconst order=new Array(n);\nfor(let i=0;i<n;i++)order[i]=i;\nconst cmp=collator(locale).compare;\nconst values=this.#values;\norder.sort((a,b)=>this.#compare(values[a],values[b],cmp));\nconst ranks=new Uint32Array(n);\nfor(let rank=0;rank<n;rank++)ranks[order[rank]]=rank;\nthis.#ranks=ranks;\nthis.#ranksVersion=this.#version;\nthis.#ranksLocale=key;\nreturn ranks;\n}\n#compare(a,b,compare){\nif(typeof a==='string'&&typeof b==='string')return compare(a,b);\nreturn defaultCompare(a,b);\n}\n}\n});\n__def(\"packages/core/src/store/multivalue.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"MultiValue\",{enumerable:true,get:function(){return MultiValue;}});\nclass MultiValue{\n#values;\n#offsets;\n#rows=0;\n#fill=0;\nconstructor(capacity={}){\nconst rows=Math.max(1,capacity.rows??16);\nconst values=Math.max(1,capacity.values??rows);\nthis.#values=new Int32Array(values);\nthis.#offsets=new Uint32Array(rows+1);\n}\nget values(){return this.#values;}\nget offsets(){return this.#offsets;}\nget rows(){return this.#rows;}\nget length(){return this.#fill;}\nget bytes(){return this.#values.byteLength+this.#offsets.byteLength;}\ncount(r){\nif(r<0||r>=this.#rows)return 0;\nreturn this.#offsets[r+1]-this.#offsets[r];\n}\nat(r){\nif(r<0||r>=this.#rows)return this.#values.subarray(0,0);\nreturn this.#values.subarray(this.#offsets[r],this.#offsets[r+1]);\n}\nhas(r,code){\nif(r<0||r>=this.#rows)return false;\nconst v=this.#values;\nconst end=this.#offsets[r+1];\nfor(let i=this.#offsets[r];i<end;i++)if(v[i]===code)return true;\nreturn false;\n}\nhasAny(r,codes){\nfor(let i=0;i<codes.length;i++)if(this.has(r,codes[i]))return true;\nreturn false;\n}\nhasAll(r,codes){\nfor(let i=0;i<codes.length;i++)if(!this.has(r,codes[i]))return false;\nreturn true;\n}\nhasNone(r,codes){return!this.hasAny(r,codes);}\npush(codes){\nconst r=this.#rows;\nconst n=codes.length;\nthis.#ensureRows(r+1);\nthis.#ensureValues(this.#fill+n);\nconst start=this.#fill;\nfor(let i=0;i<n;i++)this.#values[start+i]=codes[i]|0;\nthis.#fill+=n;\nthis.#rows=r+1;\nthis.#offsets[r]=start;\nthis.#offsets[r+1]=this.#fill;\nreturn r;\n}\nwrite(r,codes){\nif(r===this.#rows){this.push(codes);return;}\nif(r<0||r>this.#rows)return;\nconst start=this.#offsets[r];\nconst end=this.#offsets[r+1];\nconst n=codes.length;\nif(end-start===n){\nfor(let i=0;i<n;i++)this.#values[start+i]=codes[i]|0;\nreturn;\n}\nthis.#rebuild(r,codes);\n}\ncompact(remap,liveCount,dead){\nconst oldValues=this.#values;\nconst oldOffsets=this.#offsets;\nconst oldRows=this.#rows;\nconst values=new Int32Array(Math.max(1,this.#fill));\nconst offsets=new Uint32Array(liveCount+1);\nlet w=0;\nfor(let p=0;p<oldRows;p++){\nif(remap[p]===dead)continue;\nconst start=oldOffsets[p];\nconst end=oldOffsets[p+1];\noffsets[remap[p]]=w;\nfor(let i=start;i<end;i++)values[w++]=oldValues[i];\noffsets[remap[p]+1]=w;\n}\nthis.#values=values;\nthis.#offsets=offsets;\nthis.#rows=liveCount;\nthis.#fill=w;\n}\nrelease(){\nthis.#values=new Int32Array(0);\nthis.#offsets=new Uint32Array(1);\nthis.#rows=0;\nthis.#fill=0;\n}\n#ensureRows(rows){\nif(rows+1<=this.#offsets.length)return;\nlet cap=this.#offsets.length-1;\nwhile(cap<rows)cap=cap*2||16;\nconst next=new Uint32Array(cap+1);\nnext.set(this.#offsets);\nthis.#offsets=next;\n}\n#ensureValues(n){\nif(n<=this.#values.length)return;\nlet cap=this.#values.length;\nwhile(cap<n)cap=cap*2||16;\nconst next=new Int32Array(cap);\nnext.set(this.#values);\nthis.#values=next;\n}\n#rebuild(r,codes){\nconst oldValues=this.#values;\nconst oldOffsets=this.#offsets;\nconst rows=this.#rows;\nconst delta=codes.length-(oldOffsets[r+1]-oldOffsets[r]);\nconst values=new Int32Array(Math.max(1,this.#fill+delta));\nconst offsets=new Uint32Array(oldOffsets.length);\nlet w=0;\nfor(let p=0;p<rows;p++){\noffsets[p]=w;\nif(p===r){\nfor(let i=0;i<codes.length;i++)values[w++]=codes[i]|0;\n}else{\nfor(let i=oldOffsets[p];i<oldOffsets[p+1];i++)values[w++]=oldValues[i];\n}\noffsets[p+1]=w;\n}\nthis.#values=values;\nthis.#offsets=offsets;\nthis.#fill=w;\n}\n}\n});\n__def(\"packages/core/src/compute/handle.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"identity\",{enumerable:true,get:function(){return identity;}});\nObject.defineProperty(__exports,\"rowCount\",{enumerable:true,get:function(){return rowCount;}});\nObject.defineProperty(__exports,\"bitReader\",{enumerable:true,get:function(){return bitReader;}});\nObject.defineProperty(__exports,\"presenceReader\",{enumerable:true,get:function(){return presenceReader;}});\nObject.defineProperty(__exports,\"dictSize\",{enumerable:true,get:function(){return dictSize;}});\nObject.defineProperty(__exports,\"dictValue\",{enumerable:true,get:function(){return dictValue;}});\nObject.defineProperty(__exports,\"multiValue\",{enumerable:true,get:function(){return multiValue;}});\nObject.defineProperty(__exports,\"valueReader\",{enumerable:true,get:function(){return valueReader;}});\nObject.defineProperty(__exports,\"numericTotalOrder\",{enumerable:true,get:function(){return numericTotalOrder;}});\nObject.defineProperty(__exports,\"valueComparator\",{enumerable:true,get:function(){return valueComparator;}});\nObject.defineProperty(__exports,\"dictRanks\",{enumerable:true,get:function(){return dictRanks;}});\nObject.defineProperty(__exports,\"isMissing\",{enumerable:true,get:function(){return isMissing;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst collator=__m0[\"collator\"];\nconst defaultCompare=__m0[\"defaultCompare\"];\nconst warnOnce=__m0[\"warnOnce\"];\nfunction identity(n){\nconst out=new Uint32Array(n);\nfor(let i=0;i<n;i++)out[i]=i;\nreturn out;\n}\nfunction rowCount(handle,opts){\nif(opts&&typeof opts.count==='number')return opts.count;\nif(!handle)return 0;\nif(typeof handle.count==='number')return handle.count;\nif(typeof handle.length==='number')return handle.length;\nconst values=handle.values;\nif(handle.kind==='multi'&&handle.offsets)return Math.max(0,handle.offsets.length-1);\nif(!values)return handle.presence&&typeof handle.presence.size==='number'?handle.presence.size:0;\nif(handle.kind==='bitset'){\nif(typeof values.size==='number')return values.size;\nif(handle.presence&&typeof handle.presence.size==='number')return handle.presence.size;\nwarnOnce(`count:${handle.id}`,`column \"${handle.id}\" is bitset-backed with no declared row count; assuming ${values.length*8}`);\nreturn values.length*8;\n}\nreturn values.length;\n}\nconst bitOrders=new WeakMap();\nfunction bitOrderOf(bitset){\nconst ctor=bitset.constructor;\nif(!ctor)return'unknown';\nconst cached=bitOrders.get(ctor);\nif(cached)return cached;\nlet order='unknown';\ntry{\nlet probe=null;\nif(typeof ctor.from==='function')probe=ctor.from([false,true]);\nelse{\nprobe=new ctor(8);\nprobe.set(1);\n}\nconst words=probe&&probe.words;\nif(words&&words.length){\nif(words[0]===0x02)order='lsb';\nelse if(words[0]===0x40)order='msb';\n}\n}catch{\norder='unknown';\n}\nbitOrders.set(ctor,order);\nreturn order;\n}\nfunction bitReader(bits){\nif(!bits)return()=>0;\nconst raw=bits instanceof Uint8Array?bits:bits.words;\nif(raw instanceof Uint8Array){\nconst order=bits instanceof Uint8Array?'lsb':bitOrderOf(bits);\nif(order==='lsb')return(i)=>(raw[i>>>3]>>>(i&7))&1;\nif(order==='msb')return(i)=>(raw[i>>>3]>>>(7-(i&7)))&1;\n}\nif(typeof bits.get==='function')return(i)=>(bits.get(i)?1:0);\nreturn()=>0;\n}\nfunction presenceReader(handle){\nif(!handle||!handle.presence)return null;\nreturn bitReader(handle.presence);\n}\nfunction dictSize(dict){\nif(!dict)return 0;\nif(typeof dict.size==='number')return dict.size;\nif(typeof dict.values==='function')return dict.values().length;\nreturn 0;\n}\nfunction dictValue(dict,code){\nif(!dict)return null;\nif(typeof dict.valueOf==='function')return dict.valueOf(code);\nif(typeof dict.values==='function')return dict.values()[code];\nreturn null;\n}\nfunction multiValue(handle,i){\nconst offsets=handle.offsets;\nconst values=handle.values;\nif(!offsets||!values)return[];\nconst from=offsets[i];\nconst to=offsets[i+1];\nif(!(to>from))return[];\nconst dict=handle.dict;\nconst out=new Array(to-from);\nfor(let k=from;k<to;k++)out[k-from]=dict?dictValue(dict,values[k]):values[k];\nreturn out;\n}\nfunction valueReader(handle){\nif(!handle)return()=>undefined;\nconst values=handle.values;\nconst present=presenceReader(handle);\nconst kind=handle.kind;\nif(kind==='dictionary'){\nconst dict=handle.dict;\nif(present)return(i)=>(present(i)?dictValue(dict,values[i]):null);\nreturn(i)=>dictValue(dict,values[i]);\n}\nif(kind==='bitset'){\nconst bit=bitReader(values);\nif(present)return(i)=>(present(i)?bit(i)===1:null);\nreturn(i)=>bit(i)===1;\n}\nif(kind==='multi'){\nif(present)return(i)=>(present(i)?multiValue(handle,i):null);\nreturn(i)=>multiValue(handle,i);\n}\nif(!values&&typeof handle.get==='function'){\nconst get=handle.get.bind(handle);\nreturn(i)=>{\nconst v=get(i);\nreturn v===undefined?null:v;\n};\n}\nif(present){\nreturn(i)=>{\nif(!present(i))return null;\nconst v=values[i];\nreturn v===undefined?null:v;\n};\n}\nreturn(i)=>{\nconst v=values[i];\nreturn v===undefined?null:v;\n};\n}\nfunction numericTotalOrder(a,b){\nif(a<b)return-1;\nif(a>b)return 1;\nif(a===b){\nconst na=Object.is(a,-0);\nconst nb=Object.is(b,-0);\nif(na===nb)return 0;\nreturn na?-1:1;\n}\nconst an=Number.isNaN(a);\nconst bn=Number.isNaN(b);\nif(an&&bn)return 0;\nreturn an?1:-1;\n}\nfunction valueComparator(locale){\nconst coll=collator(locale);\nreturn(a,b)=>{\nif(a===b)return 0;\nconst ta=typeof a;\nconst tb=typeof b;\nif(ta==='string'&&tb==='string')return coll.compare(a,b);\nif(ta==='number'&&tb==='number')return numericTotalOrder(a,b);\nif(ta==='boolean'&&tb==='boolean')return a===b?0:a?1:-1;\nif(a instanceof Date||b instanceof Date){\nconst na=a instanceof Date?a.getTime():Number(a);\nconst nb=b instanceof Date?b.getTime():Number(b);\nreturn numericTotalOrder(na,nb);\n}\nreturn defaultCompare(a,b);\n};\n}\nfunction dictRanks(dict,locale){\nif(dict&&typeof dict.ranks==='function')return dict.ranks(locale);\nconst table=dict&&typeof dict.values==='function'?dict.values():[];\nconst n=table.length;\nconst cmp=valueComparator(locale);\nconst order=new Array(n);\nfor(let i=0;i<n;i++)order[i]=i;\norder.sort((a,b)=>cmp(table[a],table[b])||a-b);\nconst ranks=new Uint32Array(n);\nfor(let r=0;r<n;r++)ranks[order[r]]=r;\nreturn ranks;\n}\nfunction isMissing(v){\nreturn v===null||v===undefined||(typeof v==='number'&&Number.isNaN(v));\n}\n});\n__def(\"packages/core/src/compute/sort.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"radixSortFloat64\",{enumerable:true,get:function(){return radixSortFloat64;}});\nObject.defineProperty(__exports,\"radixSortInt32\",{enumerable:true,get:function(){return radixSortInt32;}});\nObject.defineProperty(__exports,\"rankSortDictionary\",{enumerable:true,get:function(){return rankSortDictionary;}});\nObject.defineProperty(__exports,\"mergeSortComparator\",{enumerable:true,get:function(){return mergeSortComparator;}});\nObject.defineProperty(__exports,\"rankSortStrings\",{enumerable:true,get:function(){return rankSortStrings;}});\nObject.defineProperty(__exports,\"collateStringRanks\",{enumerable:true,get:function(){return collateStringRanks;}});\nObject.defineProperty(__exports,\"sortColumn\",{enumerable:true,get:function(){return sortColumn;}});\nObject.defineProperty(__exports,\"sortMulti\",{enumerable:true,get:function(){return sortMulti;}});\nconst __m0=__req(\"packages/core/src/compute/handle.js\");\nconst bitReader=__m0[\"bitReader\"];\nconst dictRanks=__m0[\"dictRanks\"];\nconst dictSize=__m0[\"dictSize\"];\nconst identity=__m0[\"identity\"];\nconst isMissing=__m0[\"isMissing\"];\nconst presenceReader=__m0[\"presenceReader\"];\nconst rowCount=__m0[\"rowCount\"];\nconst valueComparator=__m0[\"valueComparator\"];\nconst valueReader=__m0[\"valueReader\"];\nconst EMPTY_INDICES=new Uint32Array(0);\nconst SCRATCH=new ArrayBuffer(8);\nconst SCRATCH_F64=new Float64Array(SCRATCH);\nconst SCRATCH_U32=new Uint32Array(SCRATCH);\nconst HI=(()=>{\nSCRATCH_F64[0]=-1;\nreturn(SCRATCH_U32[1]&0x80000000)!==0?1:0;\n})();\nconst LO=HI===1?0:1;\nfunction transformDouble(value,out){\nSCRATCH_F64[0]=value;\nlet hi=SCRATCH_U32[HI];\nlet lo=SCRATCH_U32[LO];\nif((hi&0x80000000)!==0){\nhi=~hi>>>0;\nlo=~lo>>>0;\n}else{\nhi=(hi^0x80000000)>>>0;\n}\nout[0]=lo;\nout[1]=hi;\n}\nfunction radixLsd64(idx,lo,hi,n){\nif(n<2)return idx;\nconst hist=new Uint32Array(256*8);\nfor(let i=0;i<n;i++){\nconst l=lo[i];\nconst h=hi[i];\nhist[l&0xff]++;\nhist[256+((l>>>8)&0xff)]++;\nhist[512+((l>>>16)&0xff)]++;\nhist[768+((l>>>24)&0xff)]++;\nhist[1024+(h&0xff)]++;\nhist[1280+((h>>>8)&0xff)]++;\nhist[1536+((h>>>16)&0xff)]++;\nhist[1792+((h>>>24)&0xff)]++;\n}\nlet srcIdx=idx;\nlet srcLo=lo;\nlet srcHi=hi;\nlet dstIdx=new Uint32Array(n);\nlet dstLo=new Uint32Array(n);\nlet dstHi=new Uint32Array(n);\nconst offset=new Uint32Array(256);\nfor(let pass=0;pass<8;pass++){\nconst base=pass<<8;\nconst shift=(pass&3)<<3;\nconst useHi=pass>=4;\nlet skip=false;\nfor(let b=0;b<256;b++){\nif(hist[base+b]===n){skip=true;break;}\n}\nif(skip)continue;\nlet sum=0;\nfor(let b=0;b<256;b++){\noffset[b]=sum;\nsum+=hist[base+b];\n}\nfor(let i=0;i<n;i++){\nconst l=srcLo[i];\nconst h=srcHi[i];\nconst digit=((useHi?h:l)>>>shift)&0xff;\nconst p=offset[digit]++;\ndstIdx[p]=srcIdx[i];\ndstLo[p]=l;\ndstHi[p]=h;\n}\nlet t=srcIdx;srcIdx=dstIdx;dstIdx=t;\nt=srcLo;srcLo=dstLo;dstLo=t;\nt=srcHi;srcHi=dstHi;dstHi=t;\n}\nreturn srcIdx;\n}\nfunction radixLsd32(idx,keys,n){\nif(n<2)return idx;\nconst hist=new Uint32Array(256*4);\nfor(let i=0;i<n;i++){\nconst k=keys[i];\nhist[k&0xff]++;\nhist[256+((k>>>8)&0xff)]++;\nhist[512+((k>>>16)&0xff)]++;\nhist[768+((k>>>24)&0xff)]++;\n}\nlet srcIdx=idx;\nlet srcKeys=keys;\nlet dstIdx=new Uint32Array(n);\nlet dstKeys=new Uint32Array(n);\nconst offset=new Uint32Array(256);\nfor(let pass=0;pass<4;pass++){\nconst base=pass<<8;\nconst shift=pass<<3;\nlet skip=false;\nfor(let b=0;b<256;b++){\nif(hist[base+b]===n){skip=true;break;}\n}\nif(skip)continue;\nlet sum=0;\nfor(let b=0;b<256;b++){\noffset[b]=sum;\nsum+=hist[base+b];\n}\nfor(let i=0;i<n;i++){\nconst k=srcKeys[i];\nconst p=offset[(k>>>shift)&0xff]++;\ndstIdx[p]=srcIdx[i];\ndstKeys[p]=k;\n}\nlet t=srcIdx;srcIdx=dstIdx;dstIdx=t;\nt=srcKeys;srcKeys=dstKeys;dstKeys=t;\n}\nreturn srcIdx;\n}\nfunction countingSort(idx,keys,n,radix){\nconst counts=new Uint32Array(radix+1);\nfor(let i=0;i<n;i++)counts[keys[i]]++;\nlet sum=0;\nfor(let k=0;k<=radix;k++){\nconst c=counts[k];\ncounts[k]=sum;\nsum+=c;\n}\nconst out=new Uint32Array(n);\nfor(let i=0;i<n;i++)out[counts[keys[i]]++]=idx[i];\nreturn out;\n}\nfunction sortUint32Keys(idx,keys,n,radix){\nif(n<2)return idx;\nif(radix<=65536||radix<=n*2)return countingSort(idx,keys,n,radix);\nreturn radixLsd32(idx,keys,n);\n}\nfunction exact(buffer,n){\nif(buffer.length===n&&buffer.byteOffset===0)return buffer;\nreturn Uint32Array.prototype.slice.call(buffer,0,n);\n}\nfunction radixSortFloat64(values,order,descending=false){\nconst src=order||identity(values.length);\nconst n=src.length;\nif(n<2)return Uint32Array.from(src);\nconst idx=new Uint32Array(n);\nconst lo=new Uint32Array(n);\nconst hi=new Uint32Array(n);\nconst nans=new Uint32Array(n);\nconst pair=new Uint32Array(2);\nlet m=0;\nlet nanCount=0;\nfor(let i=0;i<n;i++){\nconst row=src[i];\nconst v=values[row];\nif(Number.isNaN(v)){nans[nanCount++]=row;continue;}\ntransformDouble(v,pair);\nif(descending){\nlo[m]=~pair[0]>>>0;\nhi[m]=~pair[1]>>>0;\n}else{\nlo[m]=pair[0];\nhi[m]=pair[1];\n}\nidx[m++]=row;\n}\nconst sorted=radixLsd64(idx.subarray(0,m),lo.subarray(0,m),hi.subarray(0,m),m);\nif(nanCount===0)return exact(sorted,m);\nconst out=new Uint32Array(n);\nout.set(sorted.subarray(0,m),0);\nout.set(nans.subarray(0,nanCount),m);\nreturn out;\n}\nfunction radixSortInt32(values,order,descending=false){\nconst src=order||identity(values.length);\nconst n=src.length;\nif(n<2)return Uint32Array.from(src);\nconst idx=Uint32Array.from(src);\nconst keys=new Uint32Array(n);\nfor(let i=0;i<n;i++){\nconst k=(values[idx[i]]^0x80000000)>>>0;\nkeys[i]=descending?(~k>>>0):k;\n}\nreturn exact(radixLsd32(idx,keys,n),n);\n}\nfunction rankSortDictionary(handle,order,opts={}){\nconst src=order||identity(rowCount(handle,opts));\nconst n=src.length;\nif(n<2)return Uint32Array.from(src);\nconst ranks=dictRanks(handle.dict,opts.locale);\nconst codes=handle.values;\nconst present=presenceReader(handle);\nconst size=Math.max(dictSize(handle.dict),ranks.length);\nconst absentRank=size;\nconst idx=Uint32Array.from(src);\nconst keys=new Uint32Array(n);\nconst descending=!!opts.descending;\nfor(let i=0;i<n;i++){\nconst row=idx[i];\nlet rank=present&&present(row)===0?absentRank:ranks[codes[row]];\nif(rank===undefined)rank=absentRank;\nkeys[i]=descending?absentRank-rank:rank;\n}\nreturn exact(sortUint32Keys(idx,keys,n,size+1),n);\n}\nfunction mergeSortComparator(values,order,compare){\nconst n=order.length;\nlet src=Uint32Array.from(order);\nif(n<2)return src;\nlet dst=new Uint32Array(n);\nfor(let width=1;width<n;width<<=1){\nfor(let start=0;start<n;start+=width<<1){\nconst mid=Math.min(start+width,n);\nconst end=Math.min(start+(width<<1),n);\nlet i=start;\nlet j=mid;\nlet k=start;\nwhile(i<mid&&j<end){\ndst[k++]=compare(values[src[i]],values[src[j]])<=0?src[i++]:src[j++];\n}\nwhile(i<mid)dst[k++]=src[i++];\nwhile(j<end)dst[k++]=src[j++];\n}\nconst t=src;src=dst;dst=t;\n}\nreturn src;\n}\nfunction sortBitsetColumn(handle,idx,descending){\nconst bit=bitReader(handle.values);\nconst n=idx.length;\nconst out=new Uint32Array(n);\nconst first=descending?1:0;\nlet k=0;\nfor(let i=0;i<n;i++)if(bit(idx[i])===first)out[k++]=idx[i];\nfor(let i=0;i<n;i++)if(bit(idx[i])!==first)out[k++]=idx[i];\nreturn out;\n}\nfunction indexableValues(handle,idx){\nconst values=handle.values;\nconst kind=handle.kind;\nconst direct=(kind==='object'||kind===undefined)&&(Array.isArray(values)||ArrayBuffer.isView(values));\nif(direct&&!handle.presence)return values;\nconst reader=valueReader(handle);\nconst materialised=new Array(rowCount(handle)||0);\nfor(let i=0;i<idx.length;i++){\nconst row=idx[i];\nmaterialised[row]=reader(row);\n}\nreturn materialised;\n}\nfunction allStrings(values,idx){\nfor(let i=0;i<idx.length;i++){\nif(typeof values[idx[i]]!=='string')return false;\n}\nreturn true;\n}\nfunction rankSortStrings(idx,codes,ranks,d,descending){\nconst n=idx.length;\nconst idxOut=Uint32Array.from(idx);\nif(n<2||d<1)return idxOut;\nconst keys=new Uint32Array(n);\nconst top=d-1;\nfor(let i=0;i<n;i++){\nconst rank=ranks[codes[i]];\nkeys[i]=descending?top-rank:rank;\n}\nreturn exact(sortUint32Keys(idxOut,keys,n,d),n);\n}\nfunction collateStringRanks(table,d,locale){\nconst compare=valueComparator(locale);\nconst order=new Array(d);\nfor(let i=0;i<d;i++)order[i]=i;\norder.sort((a,b)=>compare(table[a],table[b])||a-b);\nconst ranks=new Uint32Array(d);\nfor(let r=0;r<d;r++)ranks[order[r]]=r;\nreturn ranks;\n}\nfunction keyedSortStrings(values,idx,opts){\nconst n=idx.length;\nconst codeOf=new Map();\nconst table=[];\nconst codes=new Uint32Array(n);\nfor(let i=0;i<n;i++){\nconst v=values[idx[i]];\nlet c=codeOf.get(v);\nif(c===undefined){c=table.length;codeOf.set(v,c);table.push(v);}\ncodes[i]=c;\n}\nconst d=table.length;\nconst ranks=collateStringRanks(table,d,opts.locale);\nreturn rankSortStrings(idx,codes,ranks,d,!!opts.descending);\n}\nfunction sortByComparator(handle,idx,opts){\nconst values=indexableValues(handle,idx);\nif(idx.length>=2&&allStrings(values,idx)){\nconst index=handle.stringRank;\nif(index&&index.version===handle.version&&index.usable(idx,values,opts.locale)){\nreturn index.sort(idx,opts);\n}\nreturn keyedSortStrings(values,idx,opts);\n}\nconst base=valueComparator(opts.locale);\nconst compare=opts.descending?(a,b)=>base(b,a):base;\nreturn mergeSortComparator(values,idx,compare);\n}\nfunction sortByCompare(handle,idx,opts){\nconst values=indexableValues(handle,idx);\nconst user=opts.compare;\nconst descending=!!opts.descending;\nconst compare=descending\n?(a,b)=>-user(a,b,undefined,undefined,true)\n:(a,b)=>user(a,b,undefined,undefined,false);\nreturn mergeSortComparator(values,idx,compare);\n}\nfunction partitionPresent(handle,idx){\nconst n=idx.length;\nconst present=presenceReader(handle);\nconst values=handle.values;\nconst checkNaN=handle.kind==='float64'&&!!values;\nconst looseKind=handle.kind==='object'||handle.kind==='multi'||handle.kind===undefined;\nif(!present&&!checkNaN&&!looseKind)return{present:idx,absent:EMPTY_INDICES};\nconst keep=new Uint32Array(n);\nconst drop=new Uint32Array(n);\nlet p=0;\nlet a=0;\nif(present&&checkNaN){\nfor(let i=0;i<n;i++){\nconst row=idx[i];\nif(present(row)===1&&!Number.isNaN(values[row]))keep[p++]=row;else drop[a++]=row;\n}\n}else if(checkNaN&&!present){\nfor(let i=0;i<n;i++){\nconst row=idx[i];\nif(!Number.isNaN(values[row]))keep[p++]=row;else drop[a++]=row;\n}\n}else if(present&&!looseKind){\nfor(let i=0;i<n;i++){\nconst row=idx[i];\nif(present(row)===1)keep[p++]=row;else drop[a++]=row;\n}\n}else{\nconst reader=valueReader(handle);\nfor(let i=0;i<n;i++){\nconst row=idx[i];\nif(!isMissing(reader(row)))keep[p++]=row;else drop[a++]=row;\n}\n}\nif(a===0)return{present:idx,absent:EMPTY_INDICES};\nreturn{present:keep.subarray(0,p),absent:drop.subarray(0,a)};\n}\nfunction joinRuns(sorted,absent,nullsFirst){\nif(absent.length===0)return sorted;\nconst out=new Uint32Array(sorted.length+absent.length);\nif(nullsFirst){\nout.set(absent,0);\nout.set(sorted,absent.length);\n}else{\nout.set(sorted,0);\nout.set(absent,sorted.length);\n}\nreturn out;\n}\nfunction sortColumn(handle,order,opts={}){\nconst src=order||identity(rowCount(handle,opts));\nif(!handle||src.length<2)return Uint32Array.from(src);\nconst{present,absent}=partitionPresent(handle,src);\nif(present.length===0)return Uint32Array.from(src);\nconst descending=!!opts.descending;\nlet sorted;\nif(typeof opts.compare==='function'){\nsorted=sortByCompare(handle,present,opts);\n}else{\nswitch(handle.kind){\ncase'float64':\nsorted=radixSortFloat64(handle.values,present,descending);\nbreak;\ncase'int32':\nsorted=radixSortInt32(handle.values,present,descending);\nbreak;\ncase'dictionary':\nsorted=rankSortDictionary(handle,present,opts);\nbreak;\ncase'bitset':\nsorted=sortBitsetColumn(handle,present,descending);\nbreak;\ndefault:\nsorted=sortByComparator(handle,present,opts);\nbreak;\n}\n}\nreturn joinRuns(sorted,absent,!!opts.nullsFirst);\n}\nfunction sortMulti(handles,entries,order,opts={}){\nconst list=entries||[];\nconst first=(list.length&&(list[0].handle||byId(handles,list[0].col)))||(handles&&handles[0]);\nlet current=order||identity(rowCount(first,opts));\nfor(let i=list.length-1;i>=0;i--){\nconst entry=list[i];\nconst handle=entry.handle||byId(handles,entry.col)||(handles&&handles[i]);\nif(!handle)continue;\ncurrent=sortColumn(handle,current,{\ndescending:entry.descending!==undefined?!!entry.descending:entry.dir==='desc',\nnullsFirst:!!entry.nullsFirst,\nlocale:entry.locale!==undefined?entry.locale:opts.locale,\ncompare:entry.compare,\n});\n}\nreturn current instanceof Uint32Array?current:Uint32Array.from(current);\n}\nfunction byId(handles,id){\nif(!handles||id===undefined)return undefined;\nfor(let i=0;i<handles.length;i++)if(handles[i]&&handles[i].id===id)return handles[i];\nreturn undefined;\n}\n});\n__def(\"packages/core/src/store/stringrank.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"DEFAULT_MAX_DISTINCT\",{enumerable:true,get:function(){return DEFAULT_MAX_DISTINCT;}});\nObject.defineProperty(__exports,\"StringRankIndex\",{enumerable:true,get:function(){return StringRankIndex;}});\nconst __m0=__req(\"packages/core/src/compute/sort.js\");\nconst collateStringRanks=__m0[\"collateStringRanks\"];\nconst rankSortStrings=__m0[\"rankSortStrings\"];\nconst DEFAULT_MAX_DISTINCT=100000;\nclass StringRankIndex{\n#table=[];\n#codeOf=new Map();\n#codeByRow;\n#length=0;\n#generation=0;\n#stamp=-1;\n#maxDistinct;\n#capped=false;\n#ranks=null;\n#ranksGeneration=-1;\n#ranksLocale='\\u0000';\nconstructor(maxDistinct=DEFAULT_MAX_DISTINCT){\nthis.#maxDistinct=maxDistinct>0?maxDistinct:DEFAULT_MAX_DISTINCT;\nthis.#codeByRow=new Uint32Array(0);\n}\nget version(){return this.#stamp;}\nset version(version){this.#stamp=version;}\nget generation(){return this.#generation;}\nget size(){return this.#table.length;}\nget capped(){return this.#capped;}\nget length(){return this.#length;}\nget bytes(){\nlet total=this.#codeByRow.byteLength;\nconst table=this.#table;\nfor(let i=0;i<table.length;i++)total+=table[i].length*2+24;\nreturn total;\n}\n#intern(value,capOnGrowth){\nconst existing=this.#codeOf.get(value);\nif(existing!==undefined)return existing;\nif(this.#capped)return-1;\nif(capOnGrowth&&this.#table.length>=this.#maxDistinct){\nthis.#capped=true;\nreturn-1;\n}\nconst code=this.#table.length;\nthis.#table.push(value);\nthis.#codeOf.set(value,code);\nthis.#generation++;\nreturn code;\n}\nbuild(values,count){\nconst n=count|0;\nthis.#table=[];\nthis.#codeOf=new Map();\nthis.#generation=0;\nthis.#capped=false;\nthis.#ranks=null;\nthis.#ranksGeneration=-1;\nthis.#codeByRow=new Uint32Array(n);\nfor(let row=0;row<n;row++){\nconst v=values[row];\nconst code=typeof v==='string'?this.#intern(v,false):-1;\nthis.#codeByRow[row]=code<0?0:code;\n}\nthis.#length=n;\n}\nappend(values,from,count){\nconst to=(from|0)+(count|0);\nif(to>this.#codeByRow.length){\nconst next=new Uint32Array(to);\nnext.set(this.#codeByRow.subarray(0,this.#length));\nthis.#codeByRow=next;\n}\nfor(let row=from|0;row<to;row++){\nconst v=values[row];\nconst code=typeof v==='string'?this.#intern(v,true):-1;\nthis.#codeByRow[row]=code<0?0:code;\n}\nthis.#length=Math.max(this.#length,to);\n}\nranks(locale){\nconst key=locale||'';\nif(this.#ranks&&this.#ranksGeneration===this.#generation&&this.#ranksLocale===key){\nreturn this.#ranks;\n}\nconst ranks=collateStringRanks(this.#table,this.#table.length,locale);\nthis.#ranks=ranks;\nthis.#ranksGeneration=this.#generation;\nthis.#ranksLocale=key;\nreturn ranks;\n}\nusable(idx,values,locale){\nif(this.#capped||this.#table.length===0)return false;\nconst codeByRow=this.#codeByRow;\nconst table=this.#table;\nconst covered=this.#length;\nfor(let i=0;i<idx.length;i++){\nconst row=idx[i];\nif(row>=covered)return false;\nif(table[codeByRow[row]]!==values[row])return false;\n}\nreturn true;\n}\nsort(idx,opts){\nconst ranks=this.ranks(opts.locale);\nconst d=this.#table.length;\nconst n=idx.length;\nconst codes=new Uint32Array(n);\nconst codeByRow=this.#codeByRow;\nfor(let i=0;i<n;i++)codes[i]=codeByRow[idx[i]];\nreturn rankSortStrings(idx,codes,ranks,d,!!opts.descending);\n}\n}\n});\n__def(\"packages/core/src/store/columnstore.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"REMOVED\",{enumerable:true,get:function(){return REMOVED;}});\nObject.defineProperty(__exports,\"toFloat\",{enumerable:true,get:function(){return toFloat;}});\nObject.defineProperty(__exports,\"ColumnHandle\",{enumerable:true,get:function(){return ColumnHandle;}});\nObject.defineProperty(__exports,\"ColumnStore\",{enumerable:true,get:function(){return ColumnStore;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst warnOnce=__m0[\"warnOnce\"];\nconst isFunction=__m0[\"isFunction\"];\nconst pathGetter=__m0[\"pathGetter\"];\nconst __m1=__req(\"packages/core/src/store/bitset.js\");\nconst Bitset=__m1[\"Bitset\"];\nconst __m2=__req(\"packages/core/src/store/dictionary.js\");\nconst Dictionary=__m2[\"Dictionary\"];\nconst __m3=__req(\"packages/core/src/store/multivalue.js\");\nconst MultiValue=__m3[\"MultiValue\"];\nconst __m4=__req(\"packages/core/src/store/stringrank.js\");\nconst StringRankIndex=__m4[\"StringRankIndex\"];\nconst REMOVED=0xFFFFFFFF;\nconst DEFAULT_CAPACITY=1024;\nconst DEFAULT_COLUMNAR_BELOW=5000;\nconst DEFAULT_COMPACT_RATIO=0.2;\nconst KINDS=new Set(['float64','int32','bitset','dictionary','object','multi']);\nfunction absent(v){return v===null||v===undefined;}\nfunction toFloat(v){\nif(typeof v==='number')return v;\nif(v instanceof Date)return v.getTime();\nif(typeof v==='boolean')return v?1:0;\nconst n=Number(v);\nreturn Number.isNaN(n)&&typeof v==='string'?Date.parse(v):n;\n}\nfunction toInt(v){\nconst n=toFloat(v);\nreturn Number.isFinite(n)?n|0:0;\n}\nfunction toMembers(v){\nif(absent(v))return[];\nreturn Array.isArray(v)?v:[v];\n}\nfunction decodeFrom(old,p){\nswitch(old.kind){\ncase'float64':\ncase'int32':return old.buf[p];\ncase'bitset':return old.bits.get(p)===1;\ncase'dictionary':return old.dict.valueOf(old.buf[p]);\ncase'multi':{\nconst codes=old.mv.at(p);\nconst out=new Array(codes.length);\nfor(let i=0;i<codes.length;i++)out[i]=old.dict.valueOf(codes[i]);\nreturn out;\n}\ndefault:return old.buf[p];\n}\n}\nfunction decodePacked(frag,i){\nswitch(frag.kind){\ncase'float64':\ncase'int32':return frag.values[i];\ncase'bitset':return(frag.values[i>>3]&(1<<(i&7)))!==0;\ncase'dictionary':return(frag.table||[])[frag.values[i]];\ncase'multi':{\nconst start=frag.offsets[i];\nconst end=frag.offsets[i+1];\nconst table=frag.table||[];\nconst out=new Array(end-start);\nfor(let k=start;k<end;k++)out[k-start]=table[frag.values[k]];\nreturn out;\n}\ndefault:return frag.values[i];\n}\n}\nclass ColumnHandle{\n#id;\n#kind;\n#target;\n#nullable;\n#read;\n#host;\n#seed;\n#columnar=false;\n#buf=null;\n#bits=null;\n#mv=null;\n#dict=null;\n#stringRank=null;\n#stringRankOn;\n#stringRankMax;\n#stringRankVersion=-1;\n#presence=null;\n#capacity=0;\n#version=0;\n#overlay=null;\n#cache=null;\n#released=false;\nconstructor(schema,host){\nthis.#id=schema.id;\nconst kind=KINDS.has(schema.kind)?schema.kind:'object';\nif(schema.kind&&!KINDS.has(schema.kind)){\nwarnOnce(`store.kind.${schema.id}`,\n`column \"${schema.id}\" declares unknown storage kind \"${schema.kind}\"; falling back to object`);\n}\nthis.#target=kind;\nthis.#kind=kind;\nthis.#nullable=schema.nullable!==false;\nthis.#seed=schema.dictionary??null;\nthis.#host=host;\nthis.#read=isFunction(schema.read)\n?schema.read\n:pathGetter(schema.field||schema.id);\nthis.#stringRankOn=schema.stringRankIndex!=='off';\nthis.#stringRankMax=typeof schema.stringRankMaxDistinct==='number'\n?schema.stringRankMaxDistinct\n:0;\nthis.#overlay=new Map();\n}\nget id(){return this.#id;}\nget kind(){return this.#columnar?this.#kind:'object';}\nget target(){return this.#target;}\nget nullable(){return this.#nullable;}\nget values(){\nif(this.#released)return null;\nif(!this.#columnar)return this.#lazy().values;\nif(this.#kind==='bitset')return this.#bits.words;\nif(this.#kind==='multi')return this.#mv.values;\nreturn this.#buf;\n}\nget presence(){\nif(this.#released||!this.#nullable)return null;\nreturn this.#columnar?this.#presence:this.#lazy().presence;\n}\nget dict(){\nif(this.#released||!this.#columnar)return null;\nreturn this.#kind==='dictionary'||this.#kind==='multi'?this.#dict:null;\n}\nget stringRank(){\nif(this.#released||!this.#stringRankOn)return null;\nif(this.kind!=='object')return null;\nconst values=this.values;\nconst n=this.#host.physical();\nif(!values||n===0)return null;\nif(this.#stringRank===null){\nif(typeof values[0]!=='string')return null;\nconst index=new StringRankIndex(this.#resolveStringRankMax());\nindex.build(values,n);\nindex.version=this.#version;\nthis.#stringRank=index;\nthis.#stringRankVersion=this.#version;\nreturn index.capped?null:index;\n}\nif(this.#stringRank.length<n){\nthis.#stringRank.append(values,this.#stringRank.length,n-this.#stringRank.length);\n}\nthis.#stringRank.version=this.#version;\nthis.#stringRankVersion=this.#version;\nreturn this.#stringRank.capped?null:this.#stringRank;\n}\n#resolveStringRankMax(){return this.#stringRankMax;}\n#dropStringRank(){\nthis.#stringRank=null;\nthis.#stringRankVersion=-1;\n}\nget offsets(){\nif(this.#released||!this.#columnar||this.#kind!=='multi')return null;\nreturn this.#mv.offsets;\n}\nget version(){return this.#version;}\nget bytes(){\nlet total=0;\nif(this.#buf)total+=this.#buf.byteLength??this.#buf.length*8;\nif(this.#bits)total+=this.#bits.bytes;\nif(this.#mv)total+=this.#mv.bytes;\nif(this.#presence)total+=this.#presence.bytes;\nif(this.#dict)total+=this.#dict.bytes;\nif(this.#overlay)total+=this.#overlay.size*24;\nreturn total;\n}\nget(physical){\nif(this.#released)return undefined;\nif(physical<0||physical>=this.#host.physical())return undefined;\nif(!this.#columnar)return this.#rowValue(physical);\nif(this.#nullable&&this.#presence.get(physical)===0)return null;\nswitch(this.#kind){\ncase'float64':\ncase'int32':return this.#buf[physical];\ncase'bitset':return this.#bits.get(physical)===1;\ncase'dictionary':return this.#dict.valueOf(this.#buf[physical]);\ncase'multi':{\nconst codes=this.#mv.at(physical);\nconst out=new Array(codes.length);\nfor(let i=0;i<codes.length;i++)out[i]=this.#dict.valueOf(codes[i]);\nreturn out;\n}\ndefault:return this.#buf[physical];\n}\n}\nset(physical,value){\nif(this.#released)return;\nif(this.#columnar)this.#writeValue(physical,value);\nelse this.#overlay.set(physical,value===undefined?null:value);\nif(this.#stringRank)this.#dropStringRank();\nthis.#version++;\n}\nread(row){return this.#read(row);}\nappendColumn(objects,from,n){\nif(this.#released||n<=0)return;\nif(!this.#columnar){this.#version++;return;}\nconst read=this.#read;\nconst nullable=this.#nullable;\nconst presence=this.#presence;\nlet sawAbsent=false;\nswitch(this.#kind){\ncase'float64':{\nconst buf=this.#buf;\nfor(let i=0;i<n;i++){\nconst v=read(objects[i]);\nif(typeof v==='number'){\nif(nullable)presence.set(from+i);\nbuf[from+i]=v;\ncontinue;\n}\nconst gone=v===null||v===undefined;\nif(nullable)presence.assign(from+i,!gone);\nelse if(gone)sawAbsent=true;\nbuf[from+i]=gone?NaN:toFloat(v);\n}\nbreak;\n}\ncase'int32':{\nconst buf=this.#buf;\nfor(let i=0;i<n;i++){\nconst v=read(objects[i]);\nconst gone=v===null||v===undefined;\nif(nullable)presence.assign(from+i,!gone);\nelse if(gone)sawAbsent=true;\nbuf[from+i]=gone?0:toInt(v);\n}\nbreak;\n}\ncase'bitset':{\nconst bits=this.#bits;\nfor(let i=0;i<n;i++){\nconst v=read(objects[i]);\nconst gone=v===null||v===undefined;\nif(nullable)presence.assign(from+i,!gone);\nelse if(gone)sawAbsent=true;\nbits.assign(from+i,!gone&&!!v);\n}\nbreak;\n}\ncase'dictionary':{\nconst buf=this.#buf;\nconst dict=this.#dict;\nfor(let i=0;i<n;i++){\nconst v=read(objects[i]);\nconst gone=v===null||v===undefined;\nif(nullable)presence.assign(from+i,!gone);\nelse if(gone)sawAbsent=true;\nbuf[from+i]=gone?0:dict.codeOf(v);\n}\nbreak;\n}\ncase'multi':{\nconst mv=this.#mv;\nconst dict=this.#dict;\nfor(let i=0;i<n;i++){\nconst v=read(objects[i]);\nconst gone=v===null||v===undefined;\nif(nullable)presence.assign(from+i,!gone);\nelse if(gone)sawAbsent=true;\nconst members=toMembers(v);\nconst codes=new Array(members.length);\nfor(let k=0;k<members.length;k++)codes[k]=dict.codeOf(members[k]);\nmv.write(from+i,codes);\n}\nbreak;\n}\ndefault:{\nconst buf=this.#buf;\nfor(let i=0;i<n;i++){\nconst v=read(objects[i]);\nconst gone=v===null||v===undefined;\nif(nullable)presence.assign(from+i,!gone);\nelse if(gone)sawAbsent=true;\nbuf[from+i]=gone?null:v;\n}\nbreak;\n}\n}\nif(sawAbsent){\nwarnOnce(`store.null.${this.#id}`,\n`column \"${this.#id}\" is declared non-nullable but received null; storing a filler value`);\n}\nif(this.#stringRank&&this.#kind==='object'){\nthis.#stringRank.append(this.#buf,from,n);\nthis.#stringRank.version=this.#version+1;\nthis.#stringRankVersion=this.#version+1;\n}\nthis.#version++;\n}\nappendPacked(frag,from,n){\nif(this.#released||n<=0||!frag)return;\nif(!this.#columnar){this.#version++;return;}\nconst presence=this.#presence;\nconst fragPresence=frag.presence;\nif(presence){\nif(fragPresence){\nfor(let i=0;i<n;i++)presence.assign(from+i,(fragPresence[i>>3]&(1<<(i&7)))!==0);\n}else{\nfor(let i=0;i<n;i++)presence.set(from+i);\n}\n}\nconst kindsAgree=frag.kind===this.#kind;\nif(kindsAgree&&(this.#kind==='float64'||this.#kind==='int32')){\nthis.#buf.set(frag.values,from);\nthis.#version++;\nreturn;\n}\nif(kindsAgree&&this.#kind==='bitset'){\nconst words=frag.values;\nfor(let i=0;i<n;i++)this.#bits.assign(from+i,(words[i>>3]&(1<<(i&7)))!==0);\nthis.#version++;\nreturn;\n}\nif(kindsAgree&&this.#kind==='dictionary'){\nconst table=frag.table||[];\nconst remap=new Uint32Array(table.length);\nfor(let t=0;t<table.length;t++)remap[t]=this.#dict.codeOf(table[t]);\nconst codes=frag.values;\nconst buf=this.#buf;\nconst pres=presence;\nfor(let i=0;i<n;i++){\nif(pres&&(fragPresence?(fragPresence[i>>3]&(1<<(i&7)))===0:false)){buf[from+i]=0;continue;}\nbuf[from+i]=remap[codes[i]]??0;\n}\nthis.#version++;\nreturn;\n}\nif(kindsAgree&&this.#kind==='multi'){\nconst table=frag.table||[];\nconst remap=new Uint32Array(table.length);\nfor(let t=0;t<table.length;t++)remap[t]=this.#dict.codeOf(table[t]);\nconst flat=frag.values;\nconst offsets=frag.offsets;\nfor(let i=0;i<n;i++){\nconst start=offsets[i];\nconst end=offsets[i+1];\nconst codes=new Array(end-start);\nfor(let k=start;k<end;k++)codes[k-start]=remap[flat[k]]??0;\nthis.#mv.write(from+i,codes);\n}\nthis.#version++;\nreturn;\n}\nfor(let i=0;i<n;i++){\nconst gone=fragPresence\n?(fragPresence[i>>3]&(1<<(i&7)))===0\n:(frag.kind==='object'?frag.values[i]===null:false);\nthis.#writeValue(from+i,gone?null:decodePacked(frag,i));\n}\nthis.#version++;\n}\ntouch(){this.#version++;}\ncolumnarise(capacity,fill){\nif(this.#columnar||this.#released)return;\nconst values=new Array(fill);\nfor(let p=0;p<fill;p++)values[p]=this.#rowValue(p);\nthis.#kind=this.#target;\nthis.#columnar=true;\nthis.#alloc(capacity);\nfor(let p=0;p<fill;p++)this.#writeValue(p,values[p]);\nthis.#overlay.clear();\nthis.#cache=null;\nthis.#dropStringRank();\nthis.#version++;\n}\ngrow(capacity){\nif(!this.#columnar||this.#released||capacity<=this.#capacity)return;\nswitch(this.#kind){\ncase'float64':case'int32':case'dictionary':{\nconst next=new this.#buf.constructor(capacity);\nnext.set(this.#buf);\nthis.#buf=next;\nbreak;\n}\ncase'bitset':this.#bits.grow(capacity);break;\ncase'multi':break;\ndefault:this.#buf.length=capacity;break;\n}\nif(this.#presence)this.#presence.grow(capacity);\nthis.#capacity=capacity;\nthis.#version++;\n}\nconvert(kind){\nif(this.#released||!KINDS.has(kind))return false;\nthis.#target=kind;\nif(!this.#columnar||kind===this.#kind)return false;\nconst old={kind:this.#kind,buf:this.#buf,bits:this.#bits,mv:this.#mv,dict:this.#dict};\nconst n=this.#host.physical();\nconst presence=this.#presence;\nthis.#kind=kind;\nthis.#alloc(this.#capacity);\nfor(let p=0;p<n;p++){\nconst gone=presence!==null&&presence.get(p)===0;\nif(gone&&kind!=='multi')continue;\nthis.#writeValue(p,gone?null:decodeFrom(old,p));\n}\nthis.#dropStringRank();\nthis.#version++;\nreturn true;\n}\ncompact(remap,oldFill,liveCount){\nif(this.#released)return;\nthis.#dropStringRank();\nif(!this.#columnar){\nconst overlay=this.#overlay;\nif(overlay.size){\nconst next=new Map();\nfor(const[p,v]of overlay)if(remap[p]!==REMOVED)next.set(remap[p],v);\nthis.#overlay=next;\n}\nthis.#cache=null;\nthis.#version++;\nreturn;\n}\nswitch(this.#kind){\ncase'float64':case'int32':case'dictionary':case'object':{\nconst buf=this.#buf;\nfor(let p=0;p<oldFill;p++)if(remap[p]!==REMOVED)buf[remap[p]]=buf[p];\nif(this.#kind==='object')for(let p=liveCount;p<oldFill;p++)buf[p]=undefined;\nbreak;\n}\ncase'bitset':{\nconst bits=this.#bits;\nfor(let p=0;p<oldFill;p++)if(remap[p]!==REMOVED)bits.assign(remap[p],bits.get(p)===1);\nfor(let p=liveCount;p<oldFill;p++)bits.clear(p);\nbreak;\n}\ncase'multi':this.#mv.compact(remap,liveCount,REMOVED);break;\ndefault:break;\n}\nif(this.#presence){\nconst pres=this.#presence;\nfor(let p=0;p<oldFill;p++)if(remap[p]!==REMOVED)pres.assign(remap[p],pres.get(p)===1);\nfor(let p=liveCount;p<oldFill;p++)pres.clear(p);\n}\nthis.#version++;\n}\nrelease(){\nif(this.#released)return;\nthis.#released=true;\nthis.#buf=null;\nif(this.#bits)this.#bits.release();\nthis.#bits=null;\nif(this.#mv)this.#mv.release();\nthis.#mv=null;\nif(this.#presence)this.#presence.release();\nthis.#presence=null;\nthis.#dict=null;\nthis.#stringRank=null;\nthis.#overlay=new Map();\nthis.#cache=null;\nthis.#capacity=0;\nthis.#version++;\n}\n#alloc(capacity){\nconst cap=Math.max(1,capacity);\nthis.#buf=null;\nthis.#bits=null;\nthis.#mv=null;\nswitch(this.#kind){\ncase'float64':this.#buf=new Float64Array(cap);break;\ncase'int32':this.#buf=new Int32Array(cap);break;\ncase'bitset':this.#bits=new Bitset(cap);break;\ncase'dictionary':\nthis.#buf=new Uint32Array(cap);\nthis.#dict=this.#dict??new Dictionary(this.#seed??[]);\nbreak;\ncase'multi':\nthis.#mv=new MultiValue({rows:cap,values:cap});\nthis.#dict=this.#dict??new Dictionary(this.#seed??[]);\nbreak;\ndefault:this.#buf=new Array(cap);break;\n}\nif(this.#kind!=='dictionary'&&this.#kind!=='multi')this.#dict=null;\nif(this.#nullable){\nif(this.#presence)this.#presence.grow(cap);\nelse this.#presence=new Bitset(cap);\n}\nthis.#capacity=cap;\n}\n#writeValue(p,value){\nconst gone=absent(value);\nif(this.#nullable)this.#presence.assign(p,!gone);\nelse if(gone){\nwarnOnce(`store.null.${this.#id}`,\n`column \"${this.#id}\" is declared non-nullable but received null; storing a filler value`);\n}\nswitch(this.#kind){\ncase'float64':this.#buf[p]=gone?NaN:toFloat(value);break;\ncase'int32':this.#buf[p]=gone?0:toInt(value);break;\ncase'bitset':this.#bits.assign(p,!gone&&!!value);break;\ncase'dictionary':this.#buf[p]=gone?0:this.#dict.codeOf(value);break;\ncase'multi':{\nconst members=toMembers(value);\nconst codes=new Array(members.length);\nfor(let i=0;i<members.length;i++)codes[i]=this.#dict.codeOf(members[i]);\nthis.#mv.write(p,codes);\nbreak;\n}\ndefault:this.#buf[p]=gone?null:value;break;\n}\n}\n#rowValue(p){\nif(this.#overlay.has(p))return this.#overlay.get(p);\nconst v=this.#read(this.#host.rowAt(p));\nreturn v===undefined?null:v;\n}\n#lazy(){\nif(this.#cache&&this.#cache.version===this.#version)return this.#cache;\nconst n=this.#host.physical();\nconst values=new Array(n);\nconst presence=this.#nullable?new Bitset(n):null;\nfor(let p=0;p<n;p++){\nconst v=this.#rowValue(p);\nvalues[p]=v;\nif(presence&&!absent(v))presence.set(p);\n}\nthis.#cache={version:this.#version,values,presence};\nreturn this.#cache;\n}\n}\nclass ColumnStore{\n#schema;\n#handles=new Map();\n#list=[];\n#rows=[];\n#fill=0;\n#capacity=0;\n#live=0;\n#dead=0;\n#tombs=new Bitset(0);\n#columnar=false;\n#retainSource=true;\n#columnarBelow;\n#initial;\n#ratio;\n#destroyed=false;\nconstructor(schema,opts={}){\nthis.#schema=Array.isArray(schema)?schema:[];\nthis.#initial=Math.max(1,opts.initialCapacity??DEFAULT_CAPACITY);\nthis.#retainSource=opts.retainSource!==false;\nthis.#columnarBelow=this.#retainSource?(opts.columnarBelow??DEFAULT_COLUMNAR_BELOW):0;\nthis.#ratio=opts.compactRatio??DEFAULT_COMPACT_RATIO;\nconst host={\nrowAt:(p)=>this.#rows[p],\nphysical:()=>this.#fill,\n};\nfor(const entry of this.#schema){\nif(!entry||!entry.id)continue;\nif(this.#handles.has(entry.id)){\nwarnOnce(`store.dup.${entry.id}`,`duplicate column id \"${entry.id}\" in the store schema; ignoring the second`);\ncontinue;\n}\nconst handle=new ColumnHandle(entry,host);\nthis.#handles.set(entry.id,handle);\nthis.#list.push(handle);\n}\nif(this.#columnarBelow<=0)this.#columnarise();\n}\nget count(){return this.#live;}\nget physical(){return this.#fill;}\nget capacity(){return this.#columnar?this.#capacity:this.#rows.length;}\nget tombstones(){return this.#dead;}\nget columnar(){return this.#columnar;}\nget destroyed(){return this.#destroyed;}\nget bytes(){\nlet total=this.#tombs.bytes+this.#rows.length*8;\nfor(const h of this.#list)total+=h.bytes;\nreturn total;\n}\nappend(objects){\nconst from=this.#fill;\nif(this.#destroyed||!objects)return{from,to:from};\nconst n=objects.length|0;\nif(n===0)return{from,to:from};\nif(this.#retainSource)for(let i=0;i<n;i++)this.#rows[from+i]=objects[i];\nthis.#fill=from+n;\nthis.#live+=n;\nthis.#tombs.grow(this.#fill);\nif(!this.#columnar){\nif(this.#fill>=this.#columnarBelow)this.#columnarise();\nelse for(const h of this.#list)h.touch();\nreturn{from,to:this.#fill};\n}\nthis.#ensure(this.#fill);\nconst cols=this.#list;\nfor(let c=0;c<cols.length;c++)cols[c].appendColumn(objects,from,n);\nreturn{from,to:this.#fill};\n}\nappendPacked(chunk,objects){\nconst from=this.#fill;\nif(this.#destroyed||!chunk)return{from,to:from};\nconst n=chunk.count|0;\nif(n===0)return{from,to:from};\nif(this.#retainSource&&objects){\nfor(let i=0;i<n;i++)this.#rows[from+i]=objects[i];\n}\nthis.#fill=from+n;\nthis.#live+=n;\nthis.#tombs.grow(this.#fill);\nif(!this.#columnar)this.#columnarise();\nthis.#ensure(this.#fill);\nconst byId=new Map();\nfor(const col of chunk.columns)byId.set(col.id,col);\nfor(const h of this.#list){\nconst frag=byId.get(h.id);\nif(frag)h.appendPacked(frag,from,n);\nelse{\nh.grow(this.#capacity);\n}\n}\nreturn{from,to:this.#fill};\n}\nsource(physical){\nif(this.#retainSource)return this.#rows[physical];\nif(physical<0||physical>=this.#fill)return undefined;\nreturn this.#reconstruct(physical);\n}\nsetSource(physical,object){\nif(this.#destroyed)return;\nif(physical<0||physical>=this.#fill)return;\nif(!this.#retainSource)return;\nthis.#rows[physical]=object;\n}\nget(colId,physical){\nconst h=this.#handles.get(colId);\nreturn h?h.get(physical):undefined;\n}\nset(colId,physical,value){\nif(this.#destroyed)return;\nif(physical<0||physical>=this.#fill)return;\nconst h=this.#handles.get(colId);\nif(!h){\nwarnOnce(`store.set.${colId}`,`set() on unknown column \"${colId}\"`);\nreturn;\n}\nh.set(physical,value);\n}\nremove(physical){\nif(this.#destroyed||physical<0||physical>=this.#fill)return false;\nif(this.#tombs.get(physical)===1)return false;\nthis.#tombs.set(physical);\nthis.#dead++;\nthis.#live--;\nreturn true;\n}\nlive(physical){\nif(physical<0||physical>=this.#fill)return false;\nreturn this.#tombs.get(physical)===0;\n}\ncompact(opts={}){\nif(this.#destroyed||this.#dead===0)return null;\nif(!opts.force&&this.#dead/this.#fill<this.#ratio)return null;\nconst oldFill=this.#fill;\nconst remap=new Uint32Array(oldFill);\nlet w=0;\nfor(let p=0;p<oldFill;p++)remap[p]=this.#tombs.get(p)===1?REMOVED:w++;\nfor(const h of this.#list)h.compact(remap,oldFill,w);\nif(this.#retainSource){\nconst rows=this.#rows;\nfor(let p=0;p<oldFill;p++)if(remap[p]!==REMOVED)rows[remap[p]]=rows[p];\nrows.length=w;\n}\nthis.#fill=w;\nthis.#live=w;\nthis.#dead=0;\nthis.#tombs=new Bitset(Math.max(this.#capacity,w));\nreturn remap;\n}\ncolumn(colId){return this.#handles.get(colId);}\ncolumns(){return this.#list.slice();}\nliveIndices(){\nconst out=new Uint32Array(this.#live);\nif(this.#dead===0){\nfor(let p=0;p<this.#fill;p++)out[p]=p;\nreturn out;\n}\nlet k=0;\nfor(let p=0;p<this.#fill;p++)if(this.#tombs.get(p)===0)out[k++]=p;\nreturn out;\n}\nconvert(colId,kind){\nconst h=this.#handles.get(colId);\nreturn h?h.convert(kind):false;\n}\ndestroy(){\nif(this.#destroyed)return;\nthis.#destroyed=true;\nfor(const h of this.#list)h.release();\nthis.#handles.clear();\nthis.#list.length=0;\nthis.#rows.length=0;\nthis.#tombs.release();\nthis.#fill=0;\nthis.#live=0;\nthis.#dead=0;\nthis.#capacity=0;\n}\n#ensure(n){\nif(n<=this.#capacity)return;\nlet cap=this.#capacity||this.#initial;\nwhile(cap<n)cap*=2;\nfor(const h of this.#list)h.grow(cap);\nthis.#tombs.grow(cap);\nthis.#capacity=cap;\n}\n#reconstruct(physical){\nconst out={};\nfor(const h of this.#list)out[h.id]=h.get(physical);\nreturn out;\n}\n#columnarise(){\nif(this.#columnar)return;\nlet cap=this.#initial;\nwhile(cap<this.#fill)cap*=2;\nthis.#columnar=true;\nthis.#capacity=cap;\nthis.#tombs.grow(cap);\nfor(const h of this.#list)h.columnarise(cap,this.#fill);\n}\n}\n});\n__def(\"packages/core/src/store/ingest.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"INGEST_DEFAULTS\",{enumerable:true,get:function(){return INGEST_DEFAULTS;}});\nObject.defineProperty(__exports,\"inferKind\",{enumerable:true,get:function(){return inferKind;}});\nObject.defineProperty(__exports,\"decideText\",{enumerable:true,get:function(){return decideText;}});\nObject.defineProperty(__exports,\"createReaders\",{enumerable:true,get:function(){return createReaders;}});\nObject.defineProperty(__exports,\"Ingest\",{enumerable:true,get:function(){return Ingest;}});\nObject.defineProperty(__exports,\"ingest\",{enumerable:true,get:function(){return ingest;}});\nObject.defineProperty(__exports,\"ingestSync\",{enumerable:true,get:function(){return ingestSync;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst now=__m0[\"now\"];\nconst nextFrame=__m0[\"nextFrame\"];\nconst infoOnce=__m0[\"infoOnce\"];\nconst warnOnce=__m0[\"warnOnce\"];\nconst isFunction=__m0[\"isFunction\"];\nconst pathGetter=__m0[\"pathGetter\"];\nconst __m1=__req(\"packages/core/src/store/columnstore.js\");\nconst ColumnStore=__m1[\"ColumnStore\"];\nconst INGEST_DEFAULTS=Object.freeze({\nchunkMs:8,\nchunkRows:512,\nsampleSize:100,\ndictionaryRatio:0.1,\ncolumnarBelow:5000,\ninitialCapacity:1024,\n});\nfunction inferKind(samples,hints={}){\nif(hints.multi)return'multi';\nif(samples.length===0)return'object';\nlet numbers=0;let booleans=0;let strings=0;let dates=0;let arrays=0;\nfor(let i=0;i<samples.length;i++){\nconst v=samples[i];\nif(typeof v==='number')numbers++;\nelse if(typeof v==='boolean')booleans++;\nelse if(typeof v==='string')strings++;\nelse if(v instanceof Date)dates++;\nelse if(Array.isArray(v))arrays++;\n}\nconst n=samples.length;\nif(numbers===n)return'float64';\nif(booleans===n)return'bitset';\nif(dates===n)return'float64';\nif(strings===n)return'text';\nif(arrays===n)return'multi';\nreturn'object';\n}\nfunction decideText(distinct,rows,ratio){\nif(rows<=0)return'dictionary';\nreturn distinct<ratio*rows?'dictionary':'object';\n}\nfunction createReaders(columns,computed,context){\nconst readers=new Map();\nconst base=new Map();\nfor(const col of columns){\nif(col.computed)continue;\nconst read=isFunction(col.read)?col.read:pathGetter(col.field||col.id);\nbase.set(col.id,read);\nreaders.set(col.id,read);\n}\nconst order=computed?.order??[];\nconst fns=computed?.fns??{};\nconst deps=computed?.deps??{};\nconst wrapDeps=computed?.wrapDeps??null;\nconst active=order.filter((id)=>isFunction(fns[id]));\nconst wildcard=active.some((id)=>deps[id]==='*');\nlet memo=new WeakMap();\nconst resolve=(data)=>{\nconst values={};\nif(wildcard)for(const[id,read]of base)values[id]=read(data);\nfor(const id of active){\nconst declared=deps[id];\nlet bag;\nif(declared==='*'){\nbag=values;\n}else{\nbag={};\nconst list=declared||[];\nfor(let i=0;i<list.length;i++){\nconst d=list[i];\nbag[d]=d in values?values[d]:base.get(d)?.(data);\n}\n}\nvalues[id]=fns[id](wrapDeps?wrapDeps(bag,id):bag,{\ndata,row:null,column:null,grid:null,context,\n});\n}\nreturn values;\n};\nconst valuesFor=(data)=>{\nif(data===null||(typeof data!=='object'&&typeof data!=='function'))return resolve(data);\nlet v=memo.get(data);\nif(v===undefined){v=resolve(data);memo.set(data,v);}\nreturn v;\n};\nfor(const id of active){\nreaders.set(id,\n(data)=>valuesFor(data)[id]);\n}\nreturn{\nreaders,\nreset(){memo=new WeakMap();},\n};\n}\nclass ColumnPlan{\nspec;\nread;\nkind;\ninferred;\nnullable;\ncandidate=false;\ndistinct=null;\nchange=null;\nreason='';\nconstructor(spec,read){\nthis.spec=spec;\nthis.read=read;\nthis.kind='object';\nthis.inferred=false;\nthis.nullable=spec.nullable!==false;\n}\n}\nclass Ingest{\n#rows;\n#plans=[];\n#store=null;\n#readers;\n#cursor=0;\n#opts;\n#done=false;\n#cancelled=false;\n#elapsed=0;\n#columnar;\nconstructor(rows,plan={},opts={}){\nthis.#rows=Array.isArray(rows)?rows:Array.from(rows||[]);\nthis.#opts={...INGEST_DEFAULTS,...opts};\nconst columns=plan.columns??[];\nthis.#readers=createReaders(columns,plan.computed??null,plan.context);\nthis.#columnar=this.#rows.length>=this.#opts.columnarBelow;\nthis.#planColumns(columns,plan.computed??null);\nthis.#store=new ColumnStore(this.#plans.map((p)=>({\nid:p.spec.id,\nkind:p.kind,\nnullable:p.nullable,\nread:p.read,\ndictionary:p.spec.dictionary,\n})),{\ninitialCapacity:this.#opts.initialCapacity,\ncolumnarBelow:this.#opts.columnarBelow,\n});\n}\nget store(){return this.#store;}\nget done(){return this.#done||this.#cancelled;}\nget progress(){return this.#cursor;}\nslice(){\nif(this.done)return false;\nif(this.#opts.signal?.aborted){this.#cancelled=true;return false;}\nconst started=now();\nconst{chunkMs,chunkRows}=this.#opts;\nconst total=this.#rows.length;\ndo{\nconst end=Math.min(this.#cursor+chunkRows,total);\nthis.#store.append(this.#rows.slice(this.#cursor,end));\nthis.#measure(this.#cursor,end);\nthis.#cursor=end;\nthis.#readers.reset();\nthis.#reviewCardinality(false);\n}while(this.#cursor<total&&now()-started<chunkMs);\nthis.#elapsed+=now()-started;\nthis.#opts.onProgress?.({loaded:this.#cursor,total});\nif(this.#cursor>=total){\nthis.#reviewCardinality(true);\nthis.#done=true;\nreturn false;\n}\nreturn true;\n}\ncancel(){this.#cancelled=true;}\nresult(){\nreturn{\nstore:this.#store,\nschema:this.#plans.map((p)=>({\nid:p.spec.id,kind:p.kind,nullable:p.nullable,read:p.read,\ndictionary:p.spec.dictionary,\n})),\ndecisions:this.#plans.map((p)=>({\nid:p.spec.id,\nkind:p.kind,\nnullable:p.nullable,\ninferred:p.inferred,\ndistinct:p.candidate||p.change?this.#distinctOf(p):null,\nchange:p.change,\nreason:p.reason,\n})),\ncount:this.#store.count,\nelapsed:this.#elapsed,\ncancelled:this.#cancelled,\n};\n}\n#planColumns(columns,computed){\nconst rows=this.#rows;\nconst sampleN=Math.min(this.#opts.sampleSize,rows.length);\nconst ratio=this.#opts.dictionaryRatio;\nconst pure=computed?.pure instanceof Set\n?computed.pure\n:new Set(computed?.pure??computed?.order??[]);\nfor(const spec of columns){\nif(!spec||!spec.id)continue;\nif(spec.computed&&(spec.pure===false||(computed&&!pure.has(spec.id)))){\nwarnOnce(`ingest.impure.${spec.id}`,\n`column \"${spec.id}\" is an impure computed column and is not materialised into the store`);\ncontinue;\n}\nconst read=this.#readers.readers.get(spec.id)\n??(isFunction(spec.read)?spec.read:pathGetter(spec.field||spec.id));\nconst plan=new ColumnPlan(spec,read);\nif(spec.kind){\nplan.kind=spec.kind;\nplan.reason='declared by the caller';\n}else if(spec.dictionary){\nplan.kind=spec.multi?'multi':'dictionary';\nplan.reason='value table supplied (lookup column)';\n}else{\nconst samples=[];\nfor(let i=0;i<sampleN&&samples.length<this.#opts.sampleSize;i++){\nconst v=read(rows[i]);\nif(v!==null&&v!==undefined)samples.push(v);\n}\nplan.inferred=true;\nconst kind=inferKind(samples,{multi:spec.multi});\nif(kind==='text'){\nconst distinct=new Set(samples).size;\nplan.kind=decideText(distinct,samples.length,ratio);\nplan.candidate=this.#columnar;\nplan.reason=`sampled ${distinct} distinct in ${samples.length}`;\n}else{\nplan.kind=kind;\nplan.reason=`inferred from ${samples.length} sampled values`;\nif(kind==='object'&&samples.length){\ninfoOnce(`ingest.mixed.${spec.id}`,\n`column \"${spec.id}\" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);\n}\n}\nif(plan.kind==='object'&&plan.candidate)plan.distinct=new Set(samples);\n}\nthis.#plans.push(plan);\n}\n}\n#measure(from,to){\nconst rows=this.#rows;\nfor(const plan of this.#plans){\nif(!plan.candidate||!plan.distinct)continue;\nconst set=plan.distinct;\nfor(let i=from;i<to;i++){\nconst v=plan.read(rows[i]);\nif(v!==null&&v!==undefined)set.add(v);\n}\n}\n}\n#distinctOf(plan){\nif(plan.distinct)return plan.distinct.size;\nconst handle=this.#store.column(plan.spec.id);\nreturn handle?.dict?handle.dict.size:0;\n}\n#reviewCardinality(final){\nconst ratio=this.#opts.dictionaryRatio;\nconst total=this.#rows.length;\nfor(const plan of this.#plans){\nif(!plan.candidate)continue;\nconst distinct=this.#distinctOf(plan);\nif(plan.kind==='dictionary'&&distinct>=ratio*total){\nconst handle=this.#store.column(plan.spec.id);\nplan.distinct=new Set(handle?.dict?handle.dict.values():[]);\nthis.#store.convert(plan.spec.id,'object');\nplan.kind='object';\nplan.change='demoted';\nplan.reason=`${distinct} distinct values is at or above ${ratio*100}% of ${total} rows`;\ncontinue;\n}\nif(plan.kind==='object'&&distinct>=ratio*total){\nplan.candidate=false;\nplan.distinct=null;\nplan.reason=`${distinct} distinct values is at or above ${ratio*100}% of ${total} rows`;\ncontinue;\n}\nif(final&&plan.kind==='object'&&distinct<ratio*total){\nthis.#store.convert(plan.spec.id,'dictionary');\nplan.kind='dictionary';\nplan.change=plan.change==='demoted'?null:'promoted';\nplan.reason=`${distinct} distinct values is below ${ratio*100}% of ${total} rows`;\nplan.distinct=null;\n}\nif(final)plan.candidate=false;\n}\n}\n}\nasync function ingest(rows,plan={},opts={}){\nconst run=new Ingest(rows,plan,opts);\nconst frame=opts.scheduler?.frame??nextFrame;\nwhile(run.slice()){\nawait new Promise((resolve)=>{frame(resolve);});\n}\nreturn run.result();\n}\nfunction ingestSync(rows,plan={},opts={}){\nconst run=new Ingest(rows,plan,{...opts,chunkMs:Infinity});\nwhile(run.slice());\nreturn run.result();\n}\n});\n__def(\"packages/core/src/store/columnpack.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"isPortableSchema\",{enumerable:true,get:function(){return isPortableSchema;}});\nObject.defineProperty(__exports,\"packChunk\",{enumerable:true,get:function(){return packChunk;}});\nObject.defineProperty(__exports,\"packedTransfers\",{enumerable:true,get:function(){return packedTransfers;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst pathGetter=__m0[\"pathGetter\"];\nconst __m1=__req(\"packages/core/src/store/ingest.js\");\nconst inferKind=__m1[\"inferKind\"];\nconst decideText=__m1[\"decideText\"];\nconst INGEST_DEFAULTS=__m1[\"INGEST_DEFAULTS\"];\nconst __m2=__req(\"packages/core/src/store/columnstore.js\");\nconst toFloat=__m2[\"toFloat\"];\nconst PORTABLE_KINDS=new Set(['float64','int32','bitset','dictionary','object','multi']);\nfunction isPortableSchema(schema){\nif(!Array.isArray(schema)||schema.length===0)return false;\nfor(const col of schema){\nif(!col||typeof col.id!=='string')return false;\nif(typeof col.field!=='string'||col.field==='')return false;\nif(col.kind&&!PORTABLE_KINDS.has(col.kind))return false;\n}\nreturn true;\n}\nfunction toInt(v){\nconst n=toFloat(v);\nreturn Number.isFinite(n)?n|0:0;\n}\nfunction toMembers(v){\nif(v===null||v===undefined)return[];\nreturn Array.isArray(v)?v:[v];\n}\nfunction resolveKind(col,values,rows,ratio){\nif(col.kind)return col.kind;\nconst samples=[];\nfor(let i=0;i<values.length&&samples.length<INGEST_DEFAULTS.sampleSize;i++){\nconst v=values[i];\nif(v!==null&&v!==undefined)samples.push(v);\n}\nconst kind=inferKind(samples,{multi:col.multi});\nif(kind!=='text')return kind;\nconst distinct=new Set(samples).size;\nreturn decideText(distinct,samples.length,ratio);\n}\nfunction packChunk(schema,rows,opts={}){\nconst n=rows.length|0;\nconst ratio=opts.dictionaryRatio??INGEST_DEFAULTS.dictionaryRatio;\nconst columns=[];\nfor(const col of schema){\nconst read=pathGetter(col.field||col.id);\nconst nullable=col.nullable!==false;\nconst raw=new Array(n);\nfor(let i=0;i<n;i++){\nconst v=read(rows[i]);\nraw[i]=v===undefined?null:v;\n}\nconst kind=resolveKind(col,raw,n,ratio);\nconst presence=nullable?new Uint8Array((n+7)>>3):null;\nconst present=(i)=>{if(presence)presence[i>>3]|=1<<(i&7);};\nlet packed;\nswitch(kind){\ncase'float64':{\nconst values=new Float64Array(n);\nfor(let i=0;i<n;i++){\nconst v=raw[i];\nconst gone=v===null;\nif(!gone)present(i);\nvalues[i]=gone?NaN:toFloat(v);\n}\npacked={id:col.id,kind,nullable,values,presence,offsets:null,table:null};\nbreak;\n}\ncase'int32':{\nconst values=new Int32Array(n);\nfor(let i=0;i<n;i++){\nconst v=raw[i];\nconst gone=v===null;\nif(!gone)present(i);\nvalues[i]=gone?0:toInt(v);\n}\npacked={id:col.id,kind,nullable,values,presence,offsets:null,table:null};\nbreak;\n}\ncase'bitset':{\nconst words=new Uint8Array((n+7)>>3);\nfor(let i=0;i<n;i++){\nconst v=raw[i];\nconst gone=v===null;\nif(!gone)present(i);\nif(!gone&&!!v)words[i>>3]|=1<<(i&7);\n}\npacked={id:col.id,kind,nullable,values:words,presence,offsets:null,table:null};\nbreak;\n}\ncase'dictionary':{\nconst codes=new Uint32Array(n);\nconst table=[];\nconst index=new Map();\nfor(let i=0;i<n;i++){\nconst v=raw[i];\nif(v===null){codes[i]=0;continue;}\npresent(i);\nlet code=index.get(v);\nif(code===undefined){code=table.length;table.push(v);index.set(v,code);}\ncodes[i]=code;\n}\npacked={id:col.id,kind,nullable,values:codes,presence,offsets:null,table};\nbreak;\n}\ncase'multi':{\nconst table=[];\nconst index=new Map();\nconst offsets=new Uint32Array(n+1);\nconst flat=[];\nfor(let i=0;i<n;i++){\nconst v=raw[i];\noffsets[i]=flat.length;\nconst gone=v===null;\nif(!gone)present(i);\nconst members=toMembers(v);\nfor(let k=0;k<members.length;k++){\nconst m=members[k];\nlet code=index.get(m);\nif(code===undefined){code=table.length;table.push(m);index.set(m,code);}\nflat.push(code);\n}\n}\noffsets[n]=flat.length;\npacked={id:col.id,kind,nullable,values:Int32Array.from(flat),presence,offsets,table};\nbreak;\n}\ndefault:{\nconst values=new Array(n);\nfor(let i=0;i<n;i++){\nconst v=raw[i];\nif(v!==null)present(i);\nvalues[i]=v;\n}\npacked={id:col.id,kind:'object',nullable,values,presence,offsets:null,table:null};\nbreak;\n}\n}\ncolumns.push(packed);\n}\nreturn{count:n,columns};\n}\nfunction packedTransfers(chunk){\nconst out=[];\nif(!chunk||!Array.isArray(chunk.columns))return out;\nconst add=(v)=>{\nif(ArrayBuffer.isView(v)&&v.buffer&&!out.includes(v.buffer))out.push(v.buffer);\n};\nfor(const col of chunk.columns){\nadd(col.values);\nadd(col.presence);\nadd(col.offsets);\n}\nreturn out;\n}\n});\n__def(\"packages/core/src/compute/sortspec.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"collationDescriptor\",{enumerable:true,get:function(){return collationDescriptor;}});\nObject.defineProperty(__exports,\"isPortableSort\",{enumerable:true,get:function(){return isPortableSort;}});\nObject.defineProperty(__exports,\"isPortableSortSet\",{enumerable:true,get:function(){return isPortableSortSet;}});\nObject.defineProperty(__exports,\"describeSortEntry\",{enumerable:true,get:function(){return describeSortEntry;}});\nObject.defineProperty(__exports,\"describeSort\",{enumerable:true,get:function(){return describeSort;}});\nfunction collationDescriptor(locale){\nreturn{locale:locale===undefined?undefined:String(locale),numeric:true,sensitivity:'variant'};\n}\nfunction isPortableSort(entry){\nreturn!!entry&&typeof entry.compare!=='function';\n}\nfunction isPortableSortSet(entries){\nif(!entries)return true;\nfor(let i=0;i<entries.length;i++)if(!isPortableSort(entries[i]))return false;\nreturn true;\n}\nfunction describeSortEntry(entry,locale){\nconst col=entry.col!==undefined?entry.col:(entry.handle&&entry.handle.id);\nconst chosen=entry.locale!==undefined?entry.locale:locale;\nreturn{\ncol,\ndescending:entry.descending!==undefined?!!entry.descending:entry.dir==='desc',\nnullsFirst:!!entry.nullsFirst,\ncollation:collationDescriptor(chosen),\n};\n}\nfunction describeSort(entries,locale){\nconst list=entries||[];\nconst out=new Array(list.length);\nfor(let i=0;i<list.length;i++)out[i]=describeSortEntry(list[i],locale);\nreturn out;\n}\n});\n__def(\"packages/core/src/format/date.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"scanPattern\",{enumerable:true,get:function(){return scanPattern;}});\nObject.defineProperty(__exports,\"toDate\",{enumerable:true,get:function(){return toDate;}});\nObject.defineProperty(__exports,\"compilePattern\",{enumerable:true,get:function(){return compilePattern;}});\nObject.defineProperty(__exports,\"compileDate\",{enumerable:true,get:function(){return compileDate;}});\nObject.defineProperty(__exports,\"toIsoDate\",{enumerable:true,get:function(){return toIsoDate;}});\nObject.defineProperty(__exports,\"toIsoDateTime\",{enumerable:true,get:function(){return toIsoDateTime;}});\nObject.defineProperty(__exports,\"compareIso\",{enumerable:true,get:function(){return compareIso;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst isNil=__m0[\"isNil\"];\nconst warnOnce=__m0[\"warnOnce\"];\nconst TOKENS=[\n'yyyy','yy','MMMM','MMM','MM','M','dd','d',\n'EEEE','EEE','HH','H','hh','h','mm','m','ss','s','SSS','a',\n];\nfunction scanPattern(pattern){\nconst out=[];\nlet i=0;\nlet literal='';\nconst flush=()=>{if(literal){out.push({token:null,text:literal});literal='';}};\nwhile(i<pattern.length){\nconst ch=pattern[i];\nif(ch===\"'\"){\nif(pattern[i+1]===\"'\"){literal+=\"'\";i+=2;continue;}\nconst end=pattern.indexOf(\"'\",i+1);\nif(end===-1){literal+=pattern.slice(i+1);i=pattern.length;continue;}\nliteral+=pattern.slice(i+1,end);\ni=end+1;\ncontinue;\n}\nconst token=TOKENS.find((t)=>pattern.startsWith(t,i));\nif(token){flush();out.push({token,text:token});i+=token.length;continue;}\nif(/[A-Za-z]/.test(ch)){\nwarnOnce(\n`date.pattern.token:${ch}`,\n`the date pattern \"${pattern}\" contains '${ch}', which is not a supported token, `\n+'so it is rendered as text. Quote it as a literal to silence this. '\n+`Supported: ${TOKENS.join(' ')}.`,\n);\n}\nliteral+=ch;\ni+=1;\n}\nflush();\nreturn out;\n}\nconst WALL_CLOCK=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;\nfunction toDate(value){\nif(isNil(value)||value==='')return null;\nif(value instanceof Date)return Number.isNaN(value.getTime())?null:value;\nif(typeof value==='number')return Number.isNaN(value)?null:new Date(value);\nif(typeof value==='string'){\nconst wall=WALL_CLOCK.exec(value.trim());\nif(wall){\nconst[,y,mo,d,h='0',mi='0',sec='0']=wall;\nreturn new Date(+y,+mo-1,+d,+h,+mi,+sec);\n}\nconst d=new Date(value);\nreturn Number.isNaN(d.getTime())?null:d;\n}\nreturn null;\n}\nfunction pad(n,w){return String(n).padStart(w,'0');}\nfunction fieldReader(timeZone){\nif(!timeZone){\nreturn(d)=>({\nyear:d.getFullYear(),month:d.getMonth()+1,day:d.getDate(),\nhour:d.getHours(),minute:d.getMinutes(),second:d.getSeconds(),\nms:d.getMilliseconds(),weekday:d.getDay(),\n});\n}\nconst zoned=new Intl.DateTimeFormat('en-US',{\ntimeZone,year:'numeric',month:'2-digit',day:'2-digit',\nhour:'2-digit',minute:'2-digit',second:'2-digit',hour12:false,weekday:'short',\n});\nconst days={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};\nreturn(d)=>{\nconst f={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:d.getMilliseconds(),weekday:0};\nfor(const part of zoned.formatToParts(d)){\nswitch(part.type){\ncase'year':f.year=Number(part.value);break;\ncase'month':f.month=Number(part.value);break;\ncase'day':f.day=Number(part.value);break;\ncase'hour':f.hour=Number(part.value)%24;break;\ncase'minute':f.minute=Number(part.value);break;\ncase'second':f.second=Number(part.value);break;\ncase'weekday':f.weekday=days[part.value]??0;break;\ndefault:break;\n}\n}\nreturn f;\n};\n}\nfunction compilePattern(pattern,locale,timeZone){\nconst segments=scanPattern(pattern);\nconst read=fieldReader(timeZone);\nconst used=new Set(segments.filter((s)=>s.token).map((s)=>s.token));\nconst monthShort=used.has('MMM')?new Intl.DateTimeFormat(locale,{month:'short',timeZone}):null;\nconst monthLong=used.has('MMMM')?new Intl.DateTimeFormat(locale,{month:'long',timeZone}):null;\nconst dayShort=used.has('EEE')?new Intl.DateTimeFormat(locale,{weekday:'short',timeZone}):null;\nconst dayLong=used.has('EEEE')?new Intl.DateTimeFormat(locale,{weekday:'long',timeZone}):null;\nreturn(d)=>{\nconst f=read(d);\nlet out='';\nfor(const seg of segments){\nif(!seg.token){out+=seg.text;continue;}\nswitch(seg.token){\ncase'yyyy':out+=pad(f.year,4);break;\ncase'yy':out+=pad(f.year%100,2);break;\ncase'MMMM':out+=monthLong.format(d);break;\ncase'MMM':out+=monthShort.format(d);break;\ncase'MM':out+=pad(f.month,2);break;\ncase'M':out+=String(f.month);break;\ncase'dd':out+=pad(f.day,2);break;\ncase'd':out+=String(f.day);break;\ncase'EEEE':out+=dayLong.format(d);break;\ncase'EEE':out+=dayShort.format(d);break;\ncase'HH':out+=pad(f.hour,2);break;\ncase'H':out+=String(f.hour);break;\ncase'hh':out+=pad(f.hour%12===0?12:f.hour%12,2);break;\ncase'h':out+=String(f.hour%12===0?12:f.hour%12);break;\ncase'mm':out+=pad(f.minute,2);break;\ncase'm':out+=String(f.minute);break;\ncase'ss':out+=pad(f.second,2);break;\ncase's':out+=String(f.second);break;\ncase'SSS':out+=pad(f.ms,3);break;\ncase'a':out+=f.hour<12?'AM':'PM';break;\ndefault:out+=seg.text;break;\n}\n}\nreturn out;\n};\n}\nconst UNITS=[\n['year',365*24*3600e3],\n['month',30*24*3600e3],\n['week',7*24*3600e3],\n['day',24*3600e3],\n['hour',3600e3],\n['minute',60e3],\n['second',1e3],\n];\nfunction compileDate(spec,locale){\nconst s=spec||{};\nconst loc=s.locale||locale||undefined;\nconst nullDisplay=s.nullDisplay??'';\nconst timeZone=s.timeZone;\nlet absolute;\nif(s.pattern){\nabsolute=compilePattern(s.pattern,loc,timeZone);\n}else if(s.dateStyle||s.timeStyle){\nconst opts={timeZone};\nif(s.dateStyle)opts.dateStyle=s.dateStyle;\nif(s.timeStyle)opts.timeStyle=s.timeStyle;\nconst dtf=new Intl.DateTimeFormat(loc,opts);\nabsolute=(d)=>dtf.format(d);\n}else{\nconst dtf=new Intl.DateTimeFormat(loc,{dateStyle:'medium',timeZone});\nabsolute=(d)=>dtf.format(d);\n}\nconst relative=s.relative?new Intl.RelativeTimeFormat(loc,{numeric:'auto'}):null;\nconst thresholdDays=typeof s.relative==='object'&&s.relative\n?(s.relative.threshold??7)\n:7;\nconst thresholdMs=thresholdDays*24*3600e3;\nconst format=(value,params)=>{\nconst d=toDate(value);\nif(!d)return nullDisplay;\nif(relative){\nconst now=params&&typeof params.now==='number'?params.now:Date.now();\nconst delta=d.getTime()-now;\nif(Math.abs(delta)<thresholdMs){\nfor(const[unit,ms]of UNITS){\nif(Math.abs(delta)>=ms||unit==='second'){\nreturn relative.format(Math.round(delta/ms),unit);\n}\n}\n}\n}\nreturn absolute(d);\n};\nformat.spec=s;\nreturn format;\n}\nfunction toIsoDate(value){\nif(isNil(value)||value==='')return null;\nif(typeof value==='string'){\nconst match=/^(\\d{4}-\\d{2}-\\d{2})/.exec(value.trim());\nif(match)return match[1];\nconst parsed=toDate(value);\nreturn parsed?toIsoDate(parsed):null;\n}\nconst date=toDate(value);\nif(!date)return null;\nconst pad=(n)=>String(n).padStart(2,'0');\nreturn`${date.getFullYear()}-${pad(date.getMonth()+1)}-${pad(date.getDate())}`;\n}\nfunction toIsoDateTime(value,timeZone){\nif(isNil(value)||value==='')return null;\nif(typeof value==='string'){\nconst text=value.trim();\nif(ZONE_SUFFIX.test(text)){\nconst instant=toDate(text);\nreturn instant?wallClockIn(instant,timeZone):null;\n}\nconst match=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(text);\nif(match){\nconst[,day,hour,minute,second]=match;\nreturn`${day}T${hour}:${minute}${second&&second!=='00'?`:${second}`:''}`;\n}\nif(/^\\d{4}-\\d{2}-\\d{2}$/.test(text))return`${text}T00:00`;\nconst parsed=toDate(text);\nreturn parsed?toIsoDateTime(parsed):null;\n}\nconst date=toDate(value);\nif(!date)return null;\nreturn wallClockIn(date,timeZone);\n}\nconst ZONE_SUFFIX=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;\nfunction wallClockIn(date,timeZone){\nconst pad=(n)=>String(n).padStart(2,'0');\nif(timeZone){\ntry{\nconst parts=new Intl.DateTimeFormat('en-CA',{\ntimeZone,\nyear:'numeric',month:'2-digit',day:'2-digit',\nhour:'2-digit',minute:'2-digit',second:'2-digit',\nhour12:false,\n}).formatToParts(date).reduce((out,part)=>{\nif(part.type!=='literal')out[part.type]=part.value;\nreturn out;\n},{});\nconst hour=parts.hour==='24'?'00':parts.hour;\nconst seconds=Number(parts.second);\nreturn`${parts.year}-${parts.month}-${parts.day}T${hour}:${parts.minute}`\n+(seconds?`:${parts.second}`:'');\n}catch{\n}\n}\nconst day=`${date.getFullYear()}-${pad(date.getMonth()+1)}-${pad(date.getDate())}`;\nconst seconds=date.getSeconds();\nconst clock=`${pad(date.getHours())}:${pad(date.getMinutes())}${seconds?`:${pad(seconds)}`:''}`;\nreturn`${day}T${clock}`;\n}\nfunction compareIso(a,b){\nconst left=isNil(a)||a===''?null:String(a);\nconst right=isNil(b)||b===''?null:String(b);\nif(left===null)return right===null?0:1;\nif(right===null)return-1;\nreturn left<right?-1:left>right?1:0;\n}\n});\n__def(\"packages/core/src/compute/filter.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"releaseMask\",{enumerable:true,get:function(){return releaseMask;}});\nObject.defineProperty(__exports,\"compilePredicate\",{enumerable:true,get:function(){return compilePredicate;}});\nObject.defineProperty(__exports,\"testValue\",{enumerable:true,get:function(){return testValue;}});\nObject.defineProperty(__exports,\"evaluateCondition\",{enumerable:true,get:function(){return evaluateCondition;}});\nObject.defineProperty(__exports,\"evaluateFilters\",{enumerable:true,get:function(){return evaluateFilters;}});\nObject.defineProperty(__exports,\"pruneColumn\",{enumerable:true,get:function(){return pruneColumn;}});\nObject.defineProperty(__exports,\"mentionsColumn\",{enumerable:true,get:function(){return mentionsColumn;}});\nObject.defineProperty(__exports,\"compact\",{enumerable:true,get:function(){return compact;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst isBlank=__m0[\"isBlank\"];\nconst toArray=__m0[\"toArray\"];\nconst warnOnce=__m0[\"warnOnce\"];\nconst __m1=__req(\"packages/core/src/format/date.js\");\nconst toIsoDate=__m1[\"toIsoDate\"];\nconst __m2=__req(\"packages/core/src/compute/handle.js\");\nconst bitReader=__m2[\"bitReader\"];\nconst dictSize=__m2[\"dictSize\"];\nconst dictValue=__m2[\"dictValue\"];\nconst presenceReader=__m2[\"presenceReader\"];\nconst valueComparator=__m2[\"valueComparator\"];\nconst valueReader=__m2[\"valueReader\"];\nconst ISO_DAY=/^\\d{4}-\\d{2}-\\d{2}$/;\nconst NULL_KEY='\\u0000null\\u0000';\nfunction acquireMask(ctx,n){\nconst pool=ctx&&ctx.pool;\nif(pool){\nconst take=pool.mask||pool.acquireMask||pool.acquire||pool.take;\nif(typeof take==='function'){\nconst mask=take.call(pool,n);\nif(mask&&mask.length>=n)return mask;\n}\n}\nreturn new Uint8Array(n);\n}\nfunction releaseMask(ctx,mask){\nconst pool=ctx&&ctx.pool;\nif(!pool||!mask)return;\nconst give=pool.release||pool.releaseMask||pool.free||pool.recycle;\nif(typeof give==='function')give.call(pool,mask);\n}\nfunction fillMask(mask,n,value){\nmask.fill(value,0,n);\nreturn mask;\n}\nfunction unorderable(v){\nreturn v===null||v===undefined||(typeof v==='number'&&Number.isNaN(v));\n}\nfunction coerceTarget(value,type){\nif(value===null||value===undefined)return value;\nif(type==='number')return typeof value==='number'?value:Number(value);\nif(type==='date'||type==='dateString'){\nconst iso=toIsoDate(value);\nreturn iso===null?toMillis(value):iso;\n}\nif(type==='boolean'){\nif(typeof value==='boolean')return value;\nif(value==='true'||value===1)return true;\nif(value==='false'||value===0)return false;\nreturn!!value;\n}\nreturn value;\n}\nfunction toMillis(value){\nif(value instanceof Date)return value.getTime();\nif(typeof value==='number')return value;\nreturn Date.parse(String(value));\n}\nfunction toNumber(value){\nif(typeof value==='number')return value;\nif(value instanceof Date)return value.getTime();\nif(value===null||value===undefined||value==='')return NaN;\nreturn Number(value);\n}\nfunction textOf(v,caseSensitive){\nconst s=typeof v==='string'?v:String(v);\nreturn caseSensitive?s:s.toLowerCase();\n}\nfunction setKey(v,caseSensitive){\nif(v===null||v===undefined)return NULL_KEY;\nif(typeof v==='string')return caseSensitive?v:v.toLowerCase();\nif(v instanceof Date)return v.getTime();\nreturn v;\n}\nfunction buildSet(value,caseSensitive,type){\nconst set=new Set();\nfor(const raw of toArray(value)){\nconst entry=coerceTarget(raw,type);\nset.add(setKey(entry,caseSensitive));\nif(typeof entry==='string'&&entry!==''&&Number.isFinite(Number(entry)))set.add(Number(entry));\nelse if(typeof entry==='number'&&Number.isFinite(entry))set.add(setKey(String(entry),caseSensitive));\n}\nreturn set;\n}\nfunction valueEquals(a,b,caseSensitive){\nif(a===null||a===undefined||b===null||b===undefined){\nreturn(a===null||a===undefined)&&(b===null||b===undefined);\n}\nconst ta=typeof a;\nconst tb=typeof b;\nif(ta==='string'&&tb==='string')return caseSensitive?a===b:a.toLowerCase()===b.toLowerCase();\nif(a instanceof Date||b instanceof Date)return toMillis(a)===toMillis(b);\nif(ta==='number'&&tb==='number')return a===b||(Number.isNaN(a)&&Number.isNaN(b));\nif(ta==='number'&&tb==='string')return a===Number(b);\nif(ta==='string'&&tb==='number')return Number(a)===b;\nif(ta==='boolean'||tb==='boolean')return a===b;\nif(Array.isArray(a)&&Array.isArray(b)){\nreturn a.length===b.length&&a.every((x,i)=>valueEquals(x,b[i],caseSensitive));\n}\nreturn a===b;\n}\nfunction compileRegExp(value,caseSensitive){\ntry{\nif(value instanceof RegExp){\nconst flags=value.flags.replace(/[gy]/g,'');\nreturn new RegExp(value.source,caseSensitive?flags:flags.includes('i')?flags:`${flags}i`);\n}\nreturn new RegExp(String(value),caseSensitive?'':'i');\n}catch(err){\nwarnOnce(`regex:${String(value)}`,`filter operator \"matches\" received an invalid pattern: ${String(value)}`,err);\nreturn null;\n}\n}\nfunction compilePredicate(condition,locale){\nconst predicate=compileValuePredicate(condition,locale);\nconst type=condition&&condition.type;\nif(type!=='date'&&type!=='dateString')return predicate;\nreturn(v)=>predicate(typeof v==='string'&&ISO_DAY.test(v)?v:(toIsoDate(v)??v));\n}\nfunction compileValuePredicate(condition,locale){\nconst op=condition&&condition.op;\nconst caseSensitive=!!(condition&&condition.caseSensitive);\nconst type=condition&&condition.type;\nconst cmp=valueComparator(locale);\nconst not=(p)=>(v)=>!p(v);\nswitch(op){\ncase'eq':{\nconst target=coerceTarget(condition.value,type);\nreturn(v)=>valueEquals(v,target,caseSensitive);\n}\ncase'ne':{\nconst target=coerceTarget(condition.value,type);\nreturn(v)=>!valueEquals(v,target,caseSensitive);\n}\ncase'lt':case'lte':case'gt':case'gte':{\nconst target=coerceTarget(condition.value,type);\nif(unorderable(target))return()=>false;\nconst want=op==='lt'?-1:op==='lte'?0:op==='gt'?1:2;\nreturn(v)=>{\nif(unorderable(v))return false;\nconst c=cmp(v,target);\nreturn want===-1?c<0:want===0?c<=0:want===1?c>0:c>=0;\n};\n}\ncase'between':case'notBetween':{\nconst pair=toArray(condition.value);\nconst lo=coerceTarget(pair[0],type);\nconst hi=coerceTarget(pair[1],type);\nconst bounds=condition.bounds||'[]';\nconst loInclusive=bounds.charAt(0)!=='(';\nconst hiInclusive=bounds.charAt(1)!==')';\nif(unorderable(lo)||unorderable(hi))return op==='between'?()=>false:()=>true;\nconst inRange=(v)=>{\nif(unorderable(v))return false;\nconst a=cmp(v,lo);\nconst b=cmp(v,hi);\nreturn(loInclusive?a>=0:a>0)&&(hiInclusive?b<=0:b<0);\n};\nreturn op==='between'?inRange:not(inRange);\n}\ncase'in':case'notIn':{\nconst set=buildSet(condition.value,caseSensitive,type);\nconst member=(v)=>set.has(setKey(v,caseSensitive));\nreturn op==='in'?member:not(member);\n}\ncase'contains':case'notContains':{\nconst needle=textOf(coerceTarget(condition.value,type),caseSensitive);\nconst has=(v)=>(v===null||v===undefined?false:textOf(v,caseSensitive).includes(needle));\nreturn op==='contains'?has:not(has);\n}\ncase'startsWith':{\nconst needle=textOf(coerceTarget(condition.value,type),caseSensitive);\nreturn(v)=>(v===null||v===undefined?false:textOf(v,caseSensitive).startsWith(needle));\n}\ncase'endsWith':{\nconst needle=textOf(coerceTarget(condition.value,type),caseSensitive);\nreturn(v)=>(v===null||v===undefined?false:textOf(v,caseSensitive).endsWith(needle));\n}\ncase'matches':{\nconst re=compileRegExp(condition.value,caseSensitive);\nif(!re)return()=>false;\nreturn(v)=>(v===null||v===undefined?false:re.test(String(v)));\n}\ncase'blank':\nreturn(v)=>isBlank(v)||(Array.isArray(v)&&v.length===0);\ncase'notBlank':\nreturn(v)=>!(isBlank(v)||(Array.isArray(v)&&v.length===0));\ncase'containsAny':case'containsNone':{\nconst set=buildSet(condition.value,caseSensitive,type);\nconst any=(v)=>{\nconst list=v===null||v===undefined?[]:toArray(v);\nfor(let i=0;i<list.length;i++)if(set.has(setKey(list[i],caseSensitive)))return true;\nreturn false;\n};\nreturn op==='containsAny'?any:not(any);\n}\ncase'containsAll':{\nconst wanted=toArray(condition.value).map((x)=>setKey(coerceTarget(x,type),caseSensitive));\nreturn(v)=>{\nconst list=v===null||v===undefined?[]:toArray(v);\nif(wanted.length===0)return true;\nconst have=new Set(list.map((x)=>setKey(x,caseSensitive)));\nfor(let i=0;i<wanted.length;i++)if(!have.has(wanted[i]))return false;\nreturn true;\n};\n}\ndefault:\nwarnOnce(`op:${String(op)}`,`unknown filter operator \"${String(op)}\"; the condition passes every row`);\nreturn()=>true;\n}\n}\nfunction testValue(value,condition,locale){\nreturn compilePredicate(condition,locale)(value);\n}\nfunction presenceCondition(handle,wantPresent,mask,count){\nconst present=presenceReader(handle);\nif(present){\nconst target=wantPresent?1:0;\nfor(let i=0;i<count;i++)mask[i]=present(i)===target?1:0;\nreturn mask;\n}\nconst kind=handle.kind;\nif(kind==='float64'||kind==='int32'||kind==='bitset'){\nreturn fillMask(mask,count,wantPresent?1:0);\n}\nconst read=valueReader(handle);\nfor(let i=0;i<count;i++){\nconst v=read(i);\nconst blank=isBlank(v)||(Array.isArray(v)&&v.length===0);\nmask[i]=blank===wantPresent?0:1;\n}\nreturn mask;\n}\nfunction dictionaryCondition(handle,pred,mask,count){\nconst dict=handle.dict;\nconst size=dictSize(dict);\nconst allowed=new Uint8Array(size);\nfor(let code=0;code<size;code++)allowed[code]=pred(dictValue(dict,code))?1:0;\nconst codes=handle.values;\nconst present=presenceReader(handle);\nif(!present){\nfor(let i=0;i<count;i++)mask[i]=allowed[codes[i]];\nreturn mask;\n}\nconst absentAnswer=pred(null)?1:0;\nfor(let i=0;i<count;i++)mask[i]=present(i)===1?allowed[codes[i]]:absentAnswer;\nreturn mask;\n}\nfunction booleanCondition(handle,pred,mask,count){\nconst bit=bitReader(handle.values);\nconst whenTrue=pred(true)?1:0;\nconst whenFalse=pred(false)?1:0;\nconst present=presenceReader(handle);\nif(!present){\nfor(let i=0;i<count;i++)mask[i]=bit(i)===1?whenTrue:whenFalse;\nreturn mask;\n}\nconst absentAnswer=pred(null)?1:0;\nfor(let i=0;i<count;i++){\nmask[i]=present(i)===0?absentAnswer:(bit(i)===1?whenTrue:whenFalse);\n}\nreturn mask;\n}\nfunction numericCondition(handle,condition,pred,mask,count){\nconst values=handle.values;\nconst type=condition.type;\nconst op=condition.op;\nlet handled=true;\nswitch(op){\ncase'eq':case'ne':{\nconst target=toNumber(coerceTarget(condition.value,type));\nconst wantNaN=typeof condition.value==='number'&&Number.isNaN(condition.value);\nconst invert=op==='ne'?1:0;\nif(wantNaN){\nfor(let i=0;i<count;i++)mask[i]=(Number.isNaN(values[i])?1:0)^invert;\n}else{\nfor(let i=0;i<count;i++)mask[i]=((values[i]===target)?1:0)^invert;\n}\nbreak;\n}\ncase'lt':{\nconst t=toNumber(coerceTarget(condition.value,type));\nfor(let i=0;i<count;i++)mask[i]=values[i]<t?1:0;\nbreak;\n}\ncase'lte':{\nconst t=toNumber(coerceTarget(condition.value,type));\nfor(let i=0;i<count;i++)mask[i]=values[i]<=t?1:0;\nbreak;\n}\ncase'gt':{\nconst t=toNumber(coerceTarget(condition.value,type));\nfor(let i=0;i<count;i++)mask[i]=values[i]>t?1:0;\nbreak;\n}\ncase'gte':{\nconst t=toNumber(coerceTarget(condition.value,type));\nfor(let i=0;i<count;i++)mask[i]=values[i]>=t?1:0;\nbreak;\n}\ncase'between':case'notBetween':{\nconst pair=toArray(condition.value);\nconst lo=toNumber(coerceTarget(pair[0],type));\nconst hi=toNumber(coerceTarget(pair[1],type));\nconst bounds=condition.bounds||'[]';\nconst loInclusive=bounds.charAt(0)!=='(';\nconst hiInclusive=bounds.charAt(1)!==')';\nconst invert=op==='notBetween'?1:0;\nif(loInclusive&&hiInclusive){\nfor(let i=0;i<count;i++)mask[i]=(((values[i]>=lo)&(values[i]<=hi))?1:0)^invert;\n}else if(loInclusive){\nfor(let i=0;i<count;i++)mask[i]=(((values[i]>=lo)&(values[i]<hi))?1:0)^invert;\n}else if(hiInclusive){\nfor(let i=0;i<count;i++)mask[i]=(((values[i]>lo)&(values[i]<=hi))?1:0)^invert;\n}else{\nfor(let i=0;i<count;i++)mask[i]=(((values[i]>lo)&(values[i]<hi))?1:0)^invert;\n}\nbreak;\n}\ncase'in':case'notIn':{\nconst set=new Set();\nfor(const raw of toArray(condition.value)){\nconst n=toNumber(coerceTarget(raw,type));\nif(!Number.isNaN(n))set.add(n);\n}\nconst invert=op==='notIn'?1:0;\nfor(let i=0;i<count;i++)mask[i]=(set.has(values[i])?1:0)^invert;\nbreak;\n}\ndefault:\nhandled=false;\nbreak;\n}\nif(!handled)return false;\nconst present=presenceReader(handle);\nif(present){\nconst absentAnswer=pred(null)?1:0;\nfor(let i=0;i<count;i++)if(present(i)===0)mask[i]=absentAnswer;\n}\nreturn true;\n}\nfunction genericCondition(handle,pred,mask,count){\nconst read=valueReader(handle);\nfor(let i=0;i<count;i++)mask[i]=pred(read(i))?1:0;\nreturn mask;\n}\nfunction evaluateCondition(condition,ctx,out){\nconst count=ctx.count|0;\nconst mask=out||acquireMask(ctx,count);\nif(!condition)return fillMask(mask,count,1);\nconst handle=typeof ctx.handle==='function'?ctx.handle(condition.col):undefined;\nconst custom=typeof ctx.custom==='function'?ctx.custom:null;\nif(!handle){\nif(custom){\nfor(let i=0;i<count;i++)mask[i]=custom(condition,i)?1:0;\nreturn mask;\n}\nwarnOnce(`filter:col:${String(condition.col)}`,\n`filter references unknown column \"${String(condition.col)}\"; the condition passes every row`);\nreturn fillMask(mask,count,1);\n}\nconst op=condition.op;\nif(op==='blank'||op==='notBlank')return presenceCondition(handle,op==='notBlank',mask,count);\nconst pred=compilePredicate(condition,ctx.locale);\nswitch(handle.kind){\ncase'dictionary':\nreturn dictionaryCondition(handle,pred,mask,count);\ncase'bitset':\nreturn booleanCondition(handle,pred,mask,count);\ncase'float64':case'int32':\nif(numericCondition(handle,condition,pred,mask,count))return mask;\nreturn genericCondition(handle,pred,mask,count);\ndefault:\nreturn genericCondition(handle,pred,mask,count);\n}\n}\nfunction evaluateNode(node,ctx,count){\nif(!node)return fillMask(acquireMask(ctx,count),count,1);\nif(Array.isArray(node.conditions)){\nconst children=node.conditions.filter((c)=>c!=null);\nconst op=node.op==='or'?'or':node.op==='not'?'not':'and';\nif(children.length===0)return fillMask(acquireMask(ctx,count),count,1);\nconst acc=evaluateNode(children[0],ctx,count);\nfor(let k=1;k<children.length;k++){\nconst rhs=evaluateNode(children[k],ctx,count);\nif(op==='or')for(let i=0;i<count;i++)acc[i]|=rhs[i];\nelse for(let i=0;i<count;i++)acc[i]&=rhs[i];\nreleaseMask(ctx,rhs);\n}\nif(op==='not')for(let i=0;i<count;i++)acc[i]^=1;\nreturn acc;\n}\nreturn evaluateCondition(node,ctx,acquireMask(ctx,count));\n}\nfunction evaluateFilters(filters,ctx){\nreturn evaluateNode(filters,ctx,ctx.count|0);\n}\nfunction pruneColumn(filters,colId){\nif(!filters||!colId)return filters||null;\nconst node=(filters);\nif(Array.isArray(node.conditions)){\nconst op=node.op==='or'?'or':node.op==='not'?'not':'and';\nif(op!=='and'){\nreturn mentionsColumn(node,colId)?null:filters;\n}\nconst kept=[];\nfor(const child of node.conditions){\nconst pruned=pruneColumn(child,colId);\nif(pruned)kept.push(pruned);\n}\nif(!kept.length)return null;\nreturn{...node,op:'and',conditions:kept};\n}\nreturn node.col===colId?null:filters;\n}\nfunction mentionsColumn(filters,colId){\nif(!filters||typeof filters!=='object')return false;\nconst node=(filters);\nif(node.col===colId)return true;\nif(Array.isArray(node.conditions)){\nfor(const child of node.conditions)if(mentionsColumn(child,colId))return true;\n}\nreturn false;\n}\nfunction compact(mask,count,out){\nif(out&&out.length>=count){\nlet k=0;\nfor(let i=0;i<count;i++)if(mask[i])out[k++]=i;\nreturn out.subarray(0,k);\n}\nlet survivors=0;\nfor(let i=0;i<count;i++)survivors+=mask[i]?1:0;\nconst result=new Uint32Array(survivors);\nlet k=0;\nfor(let i=0;i<count;i++)if(mask[i])result[k++]=i;\nreturn result;\n}\n});\n__def(\"packages/core/src/compute/group.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"packKeys\",{enumerable:true,get:function(){return packKeys;}});\nObject.defineProperty(__exports,\"groupByColumns\",{enumerable:true,get:function(){return groupByColumns;}});\nconst __m0=__req(\"packages/core/src/compute/handle.js\");\nconst dictSize=__m0[\"dictSize\"];\nconst identity=__m0[\"identity\"];\nconst presenceReader=__m0[\"presenceReader\"];\nconst rowCount=__m0[\"rowCount\"];\nconst valueReader=__m0[\"valueReader\"];\nconst KEY_SEPARATOR='\\u001F';\nconst NULL_MARKER='\\u0000';\nconst MAX_DIRECT_COUNTS=1<<20;\nfunction packKeys(handles,idx,n,project){\nconst k=handles.length;\nconst base=handles.map((h)=>valueReader(h));\nconst projected=Array.isArray(project)&&project.some(Boolean);\nconst readers=projected\n?base.map((r,j)=>(project[j]?(i)=>project[j](r(i)):r))\n:base;\nconst allDictionary=!projected&&k>0&&handles.every((h)=>h&&h.kind==='dictionary'&&h.dict);\nif(allDictionary){\nconst cards=handles.map((h)=>dictSize(h.dict)+1);\nlet product=1;\nfor(let j=0;j<k;j++)product*=cards[j];\nif(product<=Number.MAX_SAFE_INTEGER){\nconst codes=handles.map((h)=>h.values);\nconst presence=handles.map((h)=>presenceReader(h));\nconst keyOf=(row)=>{\nlet key=0;\nfor(let j=0;j<k;j++){\nconst present=presence[j];\nconst code=present&&present(row)===0?cards[j]-1:codes[j][row];\nkey=key*cards[j]+code;\n}\nreturn key;\n};\nconst packed=new Float64Array(n);\nfor(let i=0;i<n;i++)packed[i]=keyOf(idx[i]);\nreturn{packed,strings:null,product,readers,keyOf};\n}\n}\nconst keyOf=(row)=>{\nlet key='';\nfor(let j=0;j<k;j++){\nconst v=readers[j](row);\nkey+=(j===0?'':KEY_SEPARATOR)+(v===null||v===undefined?NULL_MARKER:String(v));\n}\nreturn key;\n};\nconst strings=new Array(n);\nfor(let i=0;i<n;i++)strings[i]=keyOf(idx[i]);\nreturn{packed:null,strings,product:Infinity,readers,keyOf};\n}\nfunction scatterBuckets(idx,ids,n,groups){\nconst offsets=new Uint32Array(groups+1);\nfor(let i=0;i<n;i++)offsets[ids[i]+1]++;\nfor(let g=0;g<groups;g++)offsets[g+1]+=offsets[g];\nconst scattered=new Uint32Array(n);\nconst cursor=offsets.slice(0,groups);\nfor(let i=0;i<n;i++)scattered[cursor[ids[i]]++]=idx[i];\nconst buckets=new Array(groups);\nfor(let g=0;g<groups;g++)buckets[g]=scattered.subarray(offsets[g],offsets[g+1]);\nreturn buckets;\n}\nfunction groupByColumns(handles,order,opts={}){\nconst list=handles||[];\nconst idx=order||identity(rowCount(list[0],opts));\nconst n=idx.length;\nif(list.length===0||n===0)return{keys:[],buckets:[]};\nconst{packed,strings,product,readers}=packKeys(list,idx,n,opts.project);\nconst ids=new Uint32Array(n);\nlet groups=0;\nlet packedKeys=null;\nif(packed&&product<=Math.max(1024,Math.min(MAX_DIRECT_COUNTS,n*4))){\nconst size=product;\nconst seen=new Int32Array(size).fill(-1);\nfor(let i=0;i<n;i++)seen[packed[i]]=0;\nfor(let key=0;key<size;key++)if(seen[key]===0)seen[key]=groups++;\nfor(let i=0;i<n;i++)ids[i]=seen[packed[i]];\npackedKeys=new Float64Array(groups);\nfor(let key=0;key<size;key++)if(seen[key]>=0)packedKeys[seen[key]]=key;\n}else if(packed){\nconst seen=new Map();\nfor(let i=0;i<n;i++){\nconst key=packed[i];\nlet id=seen.get(key);\nif(id===undefined){id=groups++;seen.set(key,id);}\nids[i]=id;\n}\npackedKeys=new Float64Array(groups);\nfor(const[key,id]of seen)packedKeys[id]=key;\n}else{\nconst seen=new Map();\nfor(let i=0;i<n;i++){\nconst key=strings[i];\nlet id=seen.get(key);\nif(id===undefined){id=groups++;seen.set(key,id);}\nids[i]=id;\n}\n}\nconst buckets=scatterBuckets(idx,ids,n,groups);\nconst keys=new Array(groups);\nfor(let g=0;g<groups;g++){\nconst row=buckets[g][0];\nconst tuple=new Array(readers.length);\nfor(let j=0;j<readers.length;j++)tuple[j]=readers[j](row);\nkeys[g]=tuple;\n}\nconst result={keys,buckets};\nif(packedKeys)result.packed=packedKeys;\nreturn result;\n}\n});\n__def(\"packages/core/src/compute/facet.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"STRATEGIES\",{enumerable:true,get:function(){return STRATEGIES;}});\nObject.defineProperty(__exports,\"GRANULARITIES\",{enumerable:true,get:function(){return GRANULARITIES;}});\nObject.defineProperty(__exports,\"DEFAULT_BUCKETS\",{enumerable:true,get:function(){return DEFAULT_BUCKETS;}});\nObject.defineProperty(__exports,\"DEFAULT_CARDINALITY_LIMIT\",{enumerable:true,get:function(){return DEFAULT_CARDINALITY_LIMIT;}});\nObject.defineProperty(__exports,\"QUANTILE_SAMPLE\",{enumerable:true,get:function(){return QUANTILE_SAMPLE;}});\nObject.defineProperty(__exports,\"facetKind\",{enumerable:true,get:function(){return facetKind;}});\nObject.defineProperty(__exports,\"orderedReader\",{enumerable:true,get:function(){return orderedReader;}});\nObject.defineProperty(__exports,\"toNumeric\",{enumerable:true,get:function(){return toNumeric;}});\nObject.defineProperty(__exports,\"cardinalityOf\",{enumerable:true,get:function(){return cardinalityOf;}});\nObject.defineProperty(__exports,\"pickGranularity\",{enumerable:true,get:function(){return pickGranularity;}});\nObject.defineProperty(__exports,\"floorTo\",{enumerable:true,get:function(){return floorTo;}});\nObject.defineProperty(__exports,\"advance\",{enumerable:true,get:function(){return advance;}});\nObject.defineProperty(__exports,\"computeBounds\",{enumerable:true,get:function(){return computeBounds;}});\nObject.defineProperty(__exports,\"countInto\",{enumerable:true,get:function(){return countInto;}});\nObject.defineProperty(__exports,\"bucketOf\",{enumerable:true,get:function(){return bucketOf;}});\nObject.defineProperty(__exports,\"facet\",{enumerable:true,get:function(){return facet;}});\nObject.defineProperty(__exports,\"default\",{enumerable:true,get:function(){return __default;}});\nconst __m0=__req(\"packages/core/src/compute/handle.js\");\nconst presenceReader=__m0[\"presenceReader\"];\nconst valueReader=__m0[\"valueReader\"];\nconst dictSize=__m0[\"dictSize\"];\nconst dictValue=__m0[\"dictValue\"];\nconst STRATEGIES=Object.freeze(['equal','quantile','log']);\nconst GRANULARITIES=Object.freeze(['hour','day','week','month','quarter','year']);\nconst DEFAULT_BUCKETS=20;\nconst DEFAULT_CARDINALITY_LIMIT=50;\nconst QUANTILE_SAMPLE=10_000;\nfunction facetKind(handle,type){\nif(!handle)return'none';\nconst base=type&&type.base;\nif(base==='date'||base==='datetime'||base==='time'||base==='dateString')return'date';\nswitch(handle.kind){\ncase'bitset':return'boolean';\ncase'float64':case'int32':return'numeric';\ncase'dictionary':return'category';\ncase'multi':return'category';\ndefault:\nif(base==='number')return'numeric';\nif(base==='boolean')return'boolean';\nif(base==='text')return'category';\nreturn'none';\n}\n}\nfunction orderedReader(handle){\nconst values=handle.values;\nconst kind=handle.kind;\nif((kind==='float64'||kind==='int32')&&values)return(i)=>values[i];\nconst read=valueReader(handle);\nreturn(i)=>toNumeric(read(i));\n}\nfunction toNumeric(v){\nif(typeof v==='number')return v;\nif(v instanceof Date)return v.getTime();\nif(v===null||v===undefined||v==='')return NaN;\nif(typeof v==='boolean')return v?1:0;\nif(typeof v==='string'){\nconst n=Number(v);\nif(Number.isFinite(n))return n;\nconst t=Date.parse(v);\nreturn Number.isFinite(t)?t:NaN;\n}\nreturn NaN;\n}\nfunction cardinalityOf(handle,indices,count,limit=DEFAULT_CARDINALITY_LIMIT){\nif(!handle)return{cardinality:0,exact:true};\nif(handle.dict)return{cardinality:dictSize(handle.dict),exact:true};\nif(handle.kind==='bitset')return{cardinality:2,exact:true};\nconst read=valueReader(handle);\nconst n=indices?indices.length:count;\nconst seen=new Set();\nfor(let k=0;k<n;k++){\nconst v=read(indices?indices[k]:k);\nif(v===null||v===undefined)continue;\nseen.add(v);\nif(seen.size>limit)return{cardinality:seen.size,exact:false};\n}\nreturn{cardinality:seen.size,exact:true};\n}\nconst HOUR_MS=3600_000;\nconst DAY_MS=86_400_000;\nfunction pickGranularity(span,target=DEFAULT_BUCKETS){\nconst ms=Number.isFinite(span)&&span>0?span:0;\nconst wide=Math.max(1,target)*2;\nif(ms/HOUR_MS<=wide)return'hour';\nif(ms/DAY_MS<=wide)return'day';\nif(ms/(7*DAY_MS)<=wide)return'week';\nif(ms/(30*DAY_MS)<=wide)return'month';\nif(ms/(91*DAY_MS)<=wide)return'quarter';\nreturn'year';\n}\nfunction floorTo(ms,granularity){\nif(!Number.isFinite(ms))return NaN;\nconst d=new Date(ms);\nswitch(granularity){\ncase'hour':d.setMinutes(0,0,0);return d.getTime();\ncase'day':d.setHours(0,0,0,0);return d.getTime();\ncase'week':{\nd.setHours(0,0,0,0);\nconst back=(d.getDay()+6)%7;\nd.setDate(d.getDate()-back);\nreturn d.getTime();\n}\ncase'month':d.setDate(1);d.setHours(0,0,0,0);return d.getTime();\ncase'quarter':\nd.setMonth(Math.floor(d.getMonth()/3)*3,1);\nd.setHours(0,0,0,0);\nreturn d.getTime();\ndefault:d.setMonth(0,1);d.setHours(0,0,0,0);return d.getTime();\n}\n}\nfunction advance(ms,granularity){\nconst d=new Date(ms);\nswitch(granularity){\ncase'hour':d.setHours(d.getHours()+1);break;\ncase'day':d.setDate(d.getDate()+1);break;\ncase'week':d.setDate(d.getDate()+7);break;\ncase'month':d.setMonth(d.getMonth()+1);break;\ncase'quarter':d.setMonth(d.getMonth()+3);break;\ndefault:d.setFullYear(d.getFullYear()+1);break;\n}\nreturn d.getTime();\n}\nfunction numericExtent(handle,indices,count){\nconst read=orderedReader(handle);\nconst present=presenceReader(handle);\nconst n=indices?indices.length:count;\nlet min=Infinity;\nlet max=-Infinity;\nlet nulls=0;\nlet finite=0;\nfor(let k=0;k<n;k++){\nconst i=indices?indices[k]:k;\nif(present&&!present(i)){nulls++;continue;}\nconst v=read(i);\nif(!Number.isFinite(v)){nulls++;continue;}\nif(v<min)min=v;\nif(v>max)max=v;\nfinite++;\n}\nreturn{min,max,nulls,finite};\n}\nfunction sortedSample(handle,indices,count,cap){\nconst read=orderedReader(handle);\nconst present=presenceReader(handle);\nconst n=indices?indices.length:count;\nconst step=n>cap?n/cap:1;\nconst out=[];\nfor(let s=0;s<n;s+=step){\nconst i=indices?indices[Math.floor(s)]:Math.floor(s);\nif(present&&!present(i))continue;\nconst v=read(i);\nif(Number.isFinite(v))out.push(v);\n}\nconst arr=Float64Array.from(out);\narr.sort();\nreturn arr;\n}\nfunction computeBounds(handle,indices,count,opts={}){\nconst kind=opts.kind||facetKind(handle,opts.type);\nif(kind==='none'||!handle)return{kind:'none',buckets:[],suppressed:'type'};\nif(kind==='boolean')return boundsForBoolean(handle,indices,count);\nif(kind==='category')return boundsForCategory(handle,indices,count,opts);\nreturn boundsForOrdered(handle,indices,count,kind,opts);\n}\nfunction boundsForBoolean(handle,indices,count){\nconst present=presenceReader(handle);\nlet nulls=0;\nif(present){\nconst n=indices?indices.length:count;\nfor(let k=0;k<n;k++)if(!present(indices?indices[k]:k))nulls++;\n}\nconst buckets=[{value:false,label:'false'},{value:true,label:'true'}];\nif(nulls>0)buckets.push({null:true,label:'Empty'});\nreturn{kind:'boolean',buckets};\n}\nfunction boundsForCategory(handle,indices,count,opts){\nconst limit=opts.cardinalityLimit??DEFAULT_CARDINALITY_LIMIT;\nconst{cardinality}=cardinalityOf(handle,indices,count,limit);\nif(cardinality>limit&&(opts.aboveLimit||'suppress')==='suppress'){\nreturn{kind:'category',buckets:[],suppressed:'cardinality',cardinality};\n}\nconst read=valueReader(handle);\nconst n=indices?indices.length:count;\nconst tally=new Map();\nlet nulls=0;\nfor(let k=0;k<n;k++){\nconst v=read(indices?indices[k]:k);\nif(v===null||v===undefined||v===''){nulls++;continue;}\nif(Array.isArray(v)){\nif(!v.length){nulls++;continue;}\nfor(const m of v)tally.set(m,(tally.get(m)||0)+1);\ncontinue;\n}\ntally.set(v,(tally.get(v)||0)+1);\n}\nlet entries=[...tally.entries()];\nif(opts.order==='alpha'){\nentries.sort((a,b)=>String(a[0]).localeCompare(String(b[0])));\n}else{\nentries.sort((a,b)=>b[1]-a[1]);\n}\nlet remainder=0;\nlet dropped=0;\nif(entries.length>limit){\ndropped=entries.length-limit;\nfor(let i=limit;i<entries.length;i++)remainder+=entries[i][1];\nentries=entries.slice(0,limit);\n}\nconst buckets=entries.map(([value])=>({value,label:String(value)}));\nif(remainder>0)buckets.push({remainder:true,label:`Other (${dropped} values)`});\nif(nulls>0)buckets.push({null:true,label:'Empty'});\nreturn{kind:'category',buckets,cardinality};\n}\nfunction boundsForOrdered(handle,indices,count,kind,opts){\nconst{min,max,nulls,finite}=numericExtent(handle,indices,count);\nif(!finite){\nreturn{kind,buckets:nulls?[{null:true,label:'Empty'}]:[],empty:true};\n}\nconst wanted=Math.max(1,Math.floor(opts.buckets||DEFAULT_BUCKETS));\nlet buckets=[];\nif(kind==='date'){\nconst granularity=GRANULARITIES.includes(opts.granularity)\n?opts.granularity:pickGranularity(max-min,wanted);\nlet edge=floorTo(min,granularity);\nwhile(edge<=max&&buckets.length<4096){\nconst next=advance(edge,granularity);\nif(!(next>edge))break;\nbuckets.push({from:edge,to:next});\nedge=next;\n}\nreturn{kind,buckets:withNull(buckets,nulls),granularity};\n}\nconst strategy=STRATEGIES.includes(opts.strategy)?opts.strategy:'equal';\nif(strategy==='quantile'){\nconst sample=sortedSample(handle,indices,count,QUANTILE_SAMPLE);\nif(sample.length){\nconst edges=[sample[0]];\nfor(let b=1;b<wanted;b++){\nconst v=sample[Math.min(sample.length-1,Math.floor((b/wanted)*sample.length))];\nif(v>edges[edges.length-1])edges.push(v);\n}\nedges.push(max);\nfor(let b=0;b<edges.length-1;b++)buckets.push({from:edges[b],to:edges[b+1]});\n}\n}else if(strategy==='log'&&min>0){\nconst lo=Math.log10(min);\nconst hi=Math.log10(max);\nconst step=(hi-lo)/wanted||1;\nfor(let b=0;b<wanted;b++){\nbuckets.push({from:10**(lo+b*step),to:10**(lo+(b+1)*step)});\n}\n}\nif(!buckets.length){\nconst width=(max-min)/wanted||1;\nfor(let b=0;b<wanted;b++)buckets.push({from:min+b*width,to:min+(b+1)*width});\n}\nbuckets[buckets.length-1].to=max;\nreturn{kind,buckets:withNull(buckets,nulls),strategy,min,max};\n}\nfunction withNull(buckets,nulls){\nreturn nulls>0?[...buckets,{null:true,label:'Empty'}]:buckets;\n}\nfunction countInto(handle,indices,count,bounds,out){\nconst buckets=(bounds&&bounds.buckets)||[];\nconst counts=out&&out.length>=buckets.length?out.subarray(0,buckets.length)\n:new Uint32Array(buckets.length);\ncounts.fill(0);\nif(!handle||!buckets.length)return counts;\nconst nullBucket=buckets.length-1;\nconst hasNull=!!buckets[nullBucket]&&buckets[nullBucket].null===true;\nconst n=indices?indices.length:count;\nif(bounds.kind==='boolean'){\nconst read=valueReader(handle);\nfor(let k=0;k<n;k++){\nconst v=read(indices?indices[k]:k);\nif(v===null||v===undefined){if(hasNull)counts[nullBucket]++;continue;}\ncounts[v?1:0]++;\n}\nreturn counts;\n}\nif(bounds.kind==='category'){\nconst slot=new Map();\nfor(let b=0;b<buckets.length;b++){\nif(!buckets[b].null&&!buckets[b].remainder)slot.set(buckets[b].value,b);\n}\nconst remainderAt=buckets.findIndex((b)=>b.remainder);\nconst read=valueReader(handle);\nfor(let k=0;k<n;k++){\nconst v=read(indices?indices[k]:k);\nif(v===null||v===undefined||v===''){if(hasNull)counts[nullBucket]++;continue;}\nif(Array.isArray(v)){\nif(!v.length){if(hasNull)counts[nullBucket]++;continue;}\nfor(const m of v){\nconst at=slot.get(m);\nif(at!==undefined)counts[at]++;\nelse if(remainderAt>=0)counts[remainderAt]++;\n}\ncontinue;\n}\nconst at=slot.get(v);\nif(at!==undefined)counts[at]++;\nelse if(remainderAt>=0)counts[remainderAt]++;\n}\nreturn counts;\n}\nconst ordered=hasNull?buckets.length-1:buckets.length;\nconst edges=new Float64Array(ordered+1);\nfor(let b=0;b<ordered;b++)edges[b]=buckets[b].from;\nedges[ordered]=ordered?buckets[ordered-1].to:0;\nconst read=orderedReader(handle);\nconst present=presenceReader(handle);\nfor(let k=0;k<n;k++){\nconst i=indices?indices[k]:k;\nif(present&&!present(i)){if(hasNull)counts[nullBucket]++;continue;}\nconst v=read(i);\nif(!Number.isFinite(v)){if(hasNull)counts[nullBucket]++;continue;}\nconst at=bucketOf(edges,ordered,v);\nif(at>=0)counts[at]++;\n}\nreturn counts;\n}\nfunction bucketOf(edges,ordered,v){\nif(!ordered)return-1;\nif(v<edges[0])return-1;\nif(v>=edges[ordered])return v===edges[ordered]?ordered-1:-1;\nlet lo=0;\nlet hi=ordered-1;\nwhile(lo<hi){\nconst mid=(lo+hi+1)>>>1;\nif(v>=edges[mid])lo=mid;else hi=mid-1;\n}\nreturn lo;\n}\nfunction facet(handle,indices,count,opts={}){\nconst bounds=opts.bounds||computeBounds(handle,opts.boundsIndices??indices,count,opts);\nreturn{bounds,counts:countInto(handle,indices,count,bounds)};\n}\nconst __default=facet;\n});\n__def(\"packages/core/src/compute/special.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"logGamma\",{enumerable:true,get:function(){return logGamma;}});\nObject.defineProperty(__exports,\"incompleteBeta\",{enumerable:true,get:function(){return incompleteBeta;}});\nObject.defineProperty(__exports,\"normalQuantile\",{enumerable:true,get:function(){return normalQuantile;}});\nObject.defineProperty(__exports,\"normalCdf\",{enumerable:true,get:function(){return normalCdf;}});\nObject.defineProperty(__exports,\"studentT\",{enumerable:true,get:function(){return studentT;}});\nObject.defineProperty(__exports,\"studentTQuantile\",{enumerable:true,get:function(){return studentTQuantile;}});\nObject.defineProperty(__exports,\"regularizedGammaP\",{enumerable:true,get:function(){return regularizedGammaP;}});\nObject.defineProperty(__exports,\"chiSquareCdf\",{enumerable:true,get:function(){return chiSquareCdf;}});\nObject.defineProperty(__exports,\"chiSquareUpperTail\",{enumerable:true,get:function(){return chiSquareUpperTail;}});\nconst LANCZOS=Object.freeze([\n676.5203681218851,-1259.1392167224028,771.32342877765313,\n-176.61502916214059,12.507343278686905,-0.13857109526572012,\n9.9843695780195716e-6,1.5056327351493116e-7,\n]);\nconst EPS=3e-12;\nconst TINY=1e-300;\nfunction logGamma(x){\nif(x<0.5)return Math.log(Math.PI/Math.sin(Math.PI*x))-logGamma(1-x);\nconst z=x-1;\nlet a=0.99999999999980993;\nconst t=z+7.5;\nfor(let i=0;i<LANCZOS.length;i++)a+=LANCZOS[i]/(z+i+1);\nreturn 0.5*Math.log(2*Math.PI)+(z+0.5)*Math.log(t)-t+Math.log(a);\n}\nfunction betaContinuedFraction(a,b,x){\nconst qab=a+b;\nconst qap=a+1;\nconst qam=a-1;\nlet c=1;\nlet d=1-(qab*x)/qap;\nif(Math.abs(d)<TINY)d=TINY;\nd=1/d;\nlet h=d;\nfor(let m=1;m<=300;m++){\nconst m2=2*m;\nlet aa=(m*(b-m)*x)/((qam+m2)*(a+m2));\nd=1+aa*d;\nif(Math.abs(d)<TINY)d=TINY;\nc=1+aa/c;\nif(Math.abs(c)<TINY)c=TINY;\nd=1/d;\nh*=d*c;\naa=(-(a+m)*(qab+m)*x)/((a+m2)*(qap+m2));\nd=1+aa*d;\nif(Math.abs(d)<TINY)d=TINY;\nc=1+aa/c;\nif(Math.abs(c)<TINY)c=TINY;\nd=1/d;\nconst step=d*c;\nh*=step;\nif(Math.abs(step-1)<EPS)break;\n}\nreturn h;\n}\nfunction incompleteBeta(a,b,x){\nif(!(a>0)||!(b>0)||!Number.isFinite(x))return Number.NaN;\nif(x<=0)return 0;\nif(x>=1)return 1;\nconst front=Math.exp(\nlogGamma(a+b)-logGamma(a)-logGamma(b)+a*Math.log(x)+b*Math.log(1-x),\n);\nreturn x<(a+1)/(a+b+2)\n?(front*betaContinuedFraction(a,b,x))/a\n:1-(front*betaContinuedFraction(b,a,1-x))/b;\n}\nfunction normalQuantile(p){\nif(!(p>0)||!(p<1))return p===0?-Infinity:(p===1?Infinity:Number.NaN);\nconst a=[-3.969683028665376e+1,2.209460984245205e+2,-2.759285104469687e+2,\n1.383577518672690e+2,-3.066479806614716e+1,2.506628277459239];\nconst b=[-5.447609879822406e+1,1.615858368580409e+2,-1.556989798598866e+2,\n6.680131188771972e+1,-1.328068155288572e+1];\nconst c=[-7.784894002430293e-3,-3.223964580411365e-1,-2.400758277161838,\n-2.549732539343734,4.374664141464968,2.938163982698783];\nconst d=[7.784695709041462e-3,3.224671290700398e-1,2.445134137142996,\n3.754408661907416];\nconst low=0.02425;\nlet q;\nlet r;\nlet x;\nif(p<low){\nq=Math.sqrt(-2*Math.log(p));\nx=(((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5])\n/ ((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1);\n}else if(p<=1-low){\nq=p-0.5;\nr=q*q;\nx=((((((a[0]*r+a[1])*r+a[2])*r+a[3])*r+a[4])*r+a[5])*q)\n/ (((((b[0] * r + b[1]) * r + b[2]) * r + b[3]) * r + b[4]) * r + 1);\n}else{\nq=Math.sqrt(-2*Math.log(1-p));\nx=-(((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5])\n/ ((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1);\n}\nconst e=0.5*erfc(-x/Math.SQRT2)-p;\nconst u=e*Math.sqrt(2*Math.PI)*Math.exp((x*x)/2);\nreturn x-u/(1+(x*u)/2);\n}\nfunction erfc(x){\nconst z=Math.abs(x);\nconst t=2/(2+z);\nconst ty=4*t-2;\nconst cof=[-1.3026537197817094,6.4196979235649026e-1,1.9476473204185836e-2,\n-9.561514786808631e-3,-9.46595344482036e-4,3.66839497852761e-4,\n4.2523324806907e-5,-2.0278578112534e-5,-1.624290004647e-6,\n1.303655835580e-6,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,\n5.059343495e-9,-9.91364156e-10,-2.27365122e-10,9.6467911e-11,\n2.394038e-12,-6.886027e-12,8.94487e-13,3.13092e-13,-1.12708e-13,\n3.81e-16,7.106e-15];\nlet dd=0;\nlet dv=0;\nlet tmp;\nfor(let j=cof.length-1;j>0;j--){\ntmp=dv;\ndv=ty*dv-dd+cof[j];\ndd=tmp;\n}\nconst ans=t*Math.exp(-z*z+0.5*(cof[0]+ty*dv)-dd);\nreturn x>=0?ans:2-ans;\n}\nfunction normalCdf(x){\nreturn 0.5*erfc(-x/Math.SQRT2);\n}\nfunction studentT(t,df){\nif(!(df>0)||!Number.isFinite(t))return Number.NaN;\nconst tail=0.5*incompleteBeta(df/2,0.5,df/(df+t*t));\nreturn t>0?1-tail:tail;\n}\nfunction studentTQuantile(p,df){\nif(!(p>0)||!(p<1)||!(df>0))return Number.NaN;\nif(df>1e7)return normalQuantile(p);\nlet lo=-1e4;\nlet hi=1e4;\nlet x=normalQuantile(p);\nconst logBeta=logGamma(df/2)+logGamma(0.5)-logGamma((df+1)/2);\nfor(let i=0;i<60;i++){\nconst cdf=studentT(x,df);\nif(cdf<p)lo=x;else hi=x;\nconst pdf=Math.exp(-((df+1)/2)*Math.log(1+(x*x)/df)-logBeta)\n/ Math.sqrt(df);\nconst step=pdf>0?(cdf-p)/pdf:0;\nif(Math.abs(step)<1e-12)break;\nconst next=x-step;\nx=next>lo&&next<hi&&Number.isFinite(next)?next:(lo+hi)/2;\nif(hi-lo<1e-12)break;\n}\nreturn x;\n}\nfunction gammaSeries(a,x){\nlet ap=a;\nlet sum=1/a;\nlet del=sum;\nfor(let n=0;n<300;n++){\nap+=1;\ndel*=x/ap;\nsum+=del;\nif(Math.abs(del)<Math.abs(sum)*EPS)break;\n}\nreturn sum*Math.exp(-x+a*Math.log(x)-logGamma(a));\n}\nfunction gammaContinuedFraction(a,x){\nlet b=x+1-a;\nlet c=1/TINY;\nlet d=1/b;\nlet h=d;\nfor(let i=1;i<=300;i++){\nconst an=-i*(i-a);\nb+=2;\nd=an*d+b;\nif(Math.abs(d)<TINY)d=TINY;\nc=b+an/c;\nif(Math.abs(c)<TINY)c=TINY;\nd=1/d;\nconst del=d*c;\nh*=del;\nif(Math.abs(del-1)<EPS)break;\n}\nreturn Math.exp(-x+a*Math.log(x)-logGamma(a))*h;\n}\nfunction regularizedGammaP(a,x){\nif(!(a>0)||!(x>=0)||!Number.isFinite(x))return Number.NaN;\nif(x===0)return 0;\nreturn x<a+1?gammaSeries(a,x):1-gammaContinuedFraction(a,x);\n}\nfunction chiSquareCdf(x,df){\nif(!(df>0))return Number.NaN;\nreturn regularizedGammaP(df/2,x/2);\n}\nfunction chiSquareUpperTail(x,df){\nconst cdf=chiSquareCdf(x,df);\nreturn Number.isNaN(cdf)?Number.NaN:Math.min(1,Math.max(0,1-cdf));\n}\n});\n__def(\"packages/core/src/compute/linalg.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"cholesky\",{enumerable:true,get:function(){return cholesky;}});\nObject.defineProperty(__exports,\"choleskySolve\",{enumerable:true,get:function(){return choleskySolve;}});\nObject.defineProperty(__exports,\"choleskyInverse\",{enumerable:true,get:function(){return choleskyInverse;}});\nObject.defineProperty(__exports,\"normalEquations\",{enumerable:true,get:function(){return normalEquations;}});\nObject.defineProperty(__exports,\"matVec\",{enumerable:true,get:function(){return matVec;}});\nObject.defineProperty(__exports,\"quadForm\",{enumerable:true,get:function(){return quadForm;}});\nfunction cholesky(a){\nconst n=a.length;\nconst l=Array.from({length:n},()=>new Array(n).fill(0));\nfor(let i=0;i<n;i++){\nfor(let j=0;j<=i;j++){\nlet sum=a[i][j];\nfor(let k=0;k<j;k++)sum-=l[i][k]*l[j][k];\nif(i===j){\nif(!(sum>0))return null;\nl[i][j]=Math.sqrt(sum);\n}else{\nl[i][j]=sum/l[j][j];\n}\n}\n}\nreturn l;\n}\nfunction choleskySolve(l,b){\nconst n=l.length;\nconst y=new Array(n).fill(0);\nfor(let i=0;i<n;i++){\nlet sum=b[i];\nfor(let k=0;k<i;k++)sum-=l[i][k]*y[k];\ny[i]=sum/l[i][i];\n}\nconst x=new Array(n).fill(0);\nfor(let i=n-1;i>=0;i--){\nlet sum=y[i];\nfor(let k=i+1;k<n;k++)sum-=l[k][i]*x[k];\nx[i]=sum/l[i][i];\n}\nreturn x;\n}\nfunction choleskyInverse(l){\nconst n=l.length;\nconst inv=Array.from({length:n},()=>new Array(n).fill(0));\nfor(let c=0;c<n;c++){\nconst e=new Array(n).fill(0);\ne[c]=1;\nconst col=choleskySolve(l,e);\nfor(let r=0;r<n;r++)inv[r][c]=col[r];\n}\nreturn inv;\n}\nfunction normalEquations(x,y,w){\nconst n=x.length;\nconst p=n?x[0].length:0;\nconst xtwx=Array.from({length:p},()=>new Array(p).fill(0));\nconst xtwy=new Array(p).fill(0);\nfor(let i=0;i<n;i++){\nconst wi=w?w[i]:1;\nconst row=x[i];\nfor(let a=0;a<p;a++){\nconst wxa=wi*row[a];\nxtwy[a]+=wxa*y[i];\nfor(let b=a;b<p;b++)xtwx[a][b]+=wxa*row[b];\n}\n}\nfor(let a=0;a<p;a++)for(let b=0;b<a;b++)xtwx[a][b]=xtwx[b][a];\nreturn{xtwx,xtwy};\n}\nfunction matVec(m,v){\nreturn m.map((row)=>row.reduce((sum,cell,j)=>sum+cell*v[j],0));\n}\nfunction quadForm(x,m){\nlet sum=0;\nfor(let a=0;a<x.length;a++){\nlet inner=0;\nfor(let b=0;b<x.length;b++)inner+=m[a][b]*x[b];\nsum+=x[a]*inner;\n}\nreturn sum;\n}\n});\n__def(\"packages/core/src/compute/sketch.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"Welford\",{enumerable:true,get:function(){return Welford;}});\nObject.defineProperty(__exports,\"Reservoir\",{enumerable:true,get:function(){return Reservoir;}});\nObject.defineProperty(__exports,\"hash32\",{enumerable:true,get:function(){return hash32;}});\nObject.defineProperty(__exports,\"HyperLogLog\",{enumerable:true,get:function(){return HyperLogLog;}});\nObject.defineProperty(__exports,\"SpaceSaving\",{enumerable:true,get:function(){return SpaceSaving;}});\nObject.defineProperty(__exports,\"KLL\",{enumerable:true,get:function(){return KLL;}});\nObject.defineProperty(__exports,\"SKETCH_BOUNDS\",{enumerable:true,get:function(){return SKETCH_BOUNDS;}});\nObject.defineProperty(__exports,\"default\",{enumerable:true,get:function(){return __default;}});\nclass Welford{\n#n=0;\n#mean=0;\n#m2=0;\nstatic get errorBound(){\nreturn Object.freeze({\nkind:'exact',metric:'none',value:0,\nstatement:'mean and variance match a full recompute to float rounding',\n});\n}\nget count(){return this.#n;}\nadd(x){\nif(!Number.isFinite(x))return;\nthis.#n++;\nconst delta=x-this.#mean;\nthis.#mean+=delta/this.#n;\nthis.#m2+=delta*(x-this.#mean);\n}\nmerge(other){\nif(other.#n===0)return;\nif(this.#n===0){this.#n=other.#n;this.#mean=other.#mean;this.#m2=other.#m2;return;}\nconst n=this.#n+other.#n;\nconst delta=other.#mean-this.#mean;\nthis.#mean+=delta*(other.#n/n);\nthis.#m2+=other.#m2+delta*delta*(this.#n*other.#n/n);\nthis.#n=n;\n}\nmean(){return this.#n?this.#mean:null;}\nvariance(){return this.#n>1?this.#m2/(this.#n-1):null;}\nvarianceP(){return this.#n?this.#m2/this.#n:null;}\nstddev(){const v=this.variance();return v===null?null:Math.sqrt(v);}\nstddevP(){const v=this.varianceP();return v===null?null:Math.sqrt(v);}\n}\nclass Reservoir{\n#items=[];\n#seen=0;\n#capacity;\n#rng;\nconstructor(capacity,rng=Math.random){\nif(!(capacity>0))throw new RangeError('reservoir capacity must be positive');\nthis.#capacity=Math.floor(capacity);\nthis.#rng=rng;\n}\nstatic get errorBound(){\nreturn Object.freeze({\nkind:'probabilistic',metric:'none',value:0,\nstatement:'uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators',\n});\n}\nget seen(){return this.#seen;}\nget size(){return this.#items.length;}\nadd(x){\nif(!Number.isFinite(x))return;\nthis.#seen++;\nif(this.#items.length<this.#capacity){\nthis.#items.push(x);\nreturn;\n}\nconst j=Math.floor(this.#rng()*this.#seen);\nif(j<this.#capacity)this.#items[j]=x;\n}\nsample(){return this.#items.slice();}\nmean(){\nif(!this.#items.length)return null;\nlet s=0;\nfor(const v of this.#items)s+=v;\nreturn s/this.#items.length;\n}\nquantile(p){\nconst n=this.#items.length;\nif(!n)return null;\nconst sorted=this.#items.slice().sort((a,b)=>a-b);\nif(n===1)return sorted[0];\nconst h=(n-1)*Math.min(1,Math.max(0,p));\nconst lo=Math.floor(h);\nconst hi=Math.ceil(h);\nreturn lo===hi?sorted[lo]:sorted[lo]+(h-lo)*(sorted[hi]-sorted[lo]);\n}\n}\nfunction fmix32(h){\nh^=h>>>16;\nh=Math.imul(h,0x85ebca6b);\nh^=h>>>13;\nh=Math.imul(h,0xc2b2ae35);\nh^=h>>>15;\nreturn h>>>0;\n}\nfunction hash32(v){\nif(typeof v==='number'){\nconst buf=new DataView(new ArrayBuffer(8));\nbuf.setFloat64(0,v===0?0:v);\nreturn fmix32(buf.getUint32(0)^buf.getUint32(4));\n}\nconst s=typeof v==='string'?v:String(v);\nlet h=0x811c9dc5;\nfor(let i=0;i<s.length;i++){\nh^=s.charCodeAt(i);\nh=Math.imul(h,0x01000193);\n}\nreturn fmix32(h);\n}\nclass HyperLogLog{\n#p;\n#m;\n#registers;\nconstructor(precision=14){\nconst p=Math.floor(precision);\nif(p<4||p>16)throw new RangeError('HLL precision must be 4..16');\nthis.#p=p;\nthis.#m=1<<p;\nthis.#registers=new Uint8Array(this.#m);\n}\nstatic errorBoundFor(precision=14){\nconst m=1<<Math.floor(precision);\nconst rse=1.04/Math.sqrt(m);\nreturn Object.freeze({\nkind:'probabilistic',metric:'relative',value:rse,\nstatement:`distinct count within ~${(rse*100).toFixed(2)}% relative standard error (m=${m} buckets)`,\n});\n}\nerrorBound(){return HyperLogLog.errorBoundFor(this.#p);}\nadd(v){\nconst h=hash32(v);\nconst idx=h&(this.#m-1);\nconst rest=(h>>>this.#p)|(1<<(32-this.#p));\nlet rank=1;\nlet x=rest;\nwhile((x&1)===0){rank++;x>>>=1;}\nif(rank>this.#registers[idx])this.#registers[idx]=rank;\n}\ncount(){\nconst m=this.#m;\nconst q=32-this.#p;\nconst hist=new Float64Array(q+2);\nfor(let i=0;i<m;i++)hist[this.#registers[i]]++;\nlet z=m*tau(1-hist[q+1]/m);\nfor(let k=q;k>=1;k--)z=0.5*(z+hist[k]);\nz+=m*sigma(hist[0]/m);\nconst estimate=(ERTL_ALPHA_INF*m*m)/z;\nreturn Math.round(estimate);\n}\n}\nconst ERTL_ALPHA_INF=0.5/Math.log(2);\nfunction sigma(x){\nif(x===1)return Infinity;\nlet y=1;\nlet z=x;\nlet prev;\ndo{\nx*=x;\nprev=z;\nz+=x*y;\ny+=y;\n}while(z!==prev);\nreturn z;\n}\nfunction tau(x){\nif(x===0||x===1)return 0;\nlet y=1;\nlet z=1-x;\nlet prev;\ndo{\nx=Math.sqrt(x);\nprev=z;\ny*=0.5;\nz-=(1-x)**2*y;\n}while(z!==prev);\nreturn z/3;\n}\nclass SpaceSaving{\n#counters=new Map();\n#capacity;\n#n=0;\nconstructor(capacity){\nif(!(capacity>0))throw new RangeError('Space-Saving capacity must be positive');\nthis.#capacity=Math.floor(capacity);\n}\nerrorBoundFor(n){\nconst value=n/this.#capacity;\nreturn Object.freeze({\nkind:'deterministic',metric:'absolute',value,\nstatement:`each count overestimates the truth by at most N/m = ${value.toFixed(2)} (N=${n}, m=${this.#capacity})`,\n});\n}\nget seen(){return this.#n;}\nadd(item){\nthis.#n++;\nconst existing=this.#counters.get(item);\nif(existing){existing.count++;return;}\nif(this.#counters.size<this.#capacity){\nthis.#counters.set(item,{count:1,error:0});\nreturn;\n}\nlet minItem;\nlet minCount=Infinity;\nfor(const[k,v]of this.#counters){\nif(v.count<minCount){minCount=v.count;minItem=k;}\n}\nthis.#counters.delete(minItem);\nthis.#counters.set(item,{count:minCount+1,error:minCount});\n}\ntop(k=this.#capacity){\nconst all=[...this.#counters.entries()]\n.map(([item,v])=>({item,count:v.count,error:v.error}))\n.sort((a,b)=>b.count-a.count);\nreturn all.slice(0,Math.max(0,Math.floor(k)));\n}\n}\nclass KLL{\n#k;\n#levels=[[]];\n#n=0;\n#rng;\n#capacityFactor;\nconstructor(k=200,rng=Math.random){\nthis.#k=Math.max(8,Math.floor(k));\nthis.#rng=rng;\nthis.#capacityFactor=2/3;\n}\nstatic errorBoundFor(k=200){\nconst eps=1/Math.max(8,Math.floor(k));\nreturn Object.freeze({\nkind:'probabilistic',metric:'rank',value:eps,\nstatement:`queried quantile's true rank within ~${(eps*100).toFixed(2)}% of N of the requested rank (k=${k})`,\n});\n}\nerrorBound(){return KLL.errorBoundFor(this.#k);}\nget count(){return this.#n;}\n#levelCapacity(height){\nconst top=this.#levels.length-1;\nconst depthFromTop=top-height;\nconst cap=Math.ceil(this.#k*this.#capacityFactor**depthFromTop);\nreturn Math.max(2,cap);\n}\nadd(x){\nif(!Number.isFinite(x))return;\nthis.#n++;\nthis.#levels[0].push(x);\nif(this.#levels[0].length>=this.#levelCapacity(0))this.#compact(0);\n}\n#compact(height){\nconst level=this.#levels[height];\nlevel.sort((a,b)=>a-b);\nif(height+1>=this.#levels.length)this.#levels.push([]);\nconst up=this.#levels[height+1];\nconst offset=this.#rng()<0.5?0:1;\nfor(let i=offset;i<level.length;i+=2)up.push(level[i]);\nthis.#levels[height]=[];\nfor(let h=0;h<this.#levels.length;h++){\nif(this.#levels[h].length>=this.#levelCapacity(h)){this.#compact(h);return;}\n}\n}\n#weighted(){\nconst out=[];\nfor(let h=0;h<this.#levels.length;h++){\nconst w=1<<h;\nfor(const v of this.#levels[h])out.push({v,w});\n}\nreturn out;\n}\nquantile(p){\nconst items=this.#weighted();\nif(!items.length)return null;\nitems.sort((a,b)=>a.v-b.v);\nlet totalW=0;\nfor(const it of items)totalW+=it.w;\nconst target=Math.min(1,Math.max(0,p))*totalW;\nlet cum=0;\nfor(const it of items){\ncum+=it.w;\nif(cum>=target)return it.v;\n}\nreturn items[items.length-1].v;\n}\nrank(x){\nlet cum=0;\nfor(let h=0;h<this.#levels.length;h++){\nconst w=1<<h;\nfor(const v of this.#levels[h])if(v<=x)cum+=w;\n}\nreturn cum;\n}\n}\nconst SKETCH_BOUNDS=Object.freeze({\ndistinct:HyperLogLog.errorBoundFor(14),\nmedian:KLL.errorBoundFor(200),\np25:KLL.errorBoundFor(200),\np75:KLL.errorBoundFor(200),\np90:KLL.errorBoundFor(200),\np95:KLL.errorBoundFor(200),\np99:KLL.errorBoundFor(200),\niqr:KLL.errorBoundFor(200),\ntopK:Object.freeze({\nkind:'deterministic',metric:'absolute',value:0,\nstatement:'each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m',\n}),\n});\nconst __default={\nWelford,Reservoir,HyperLogLog,SpaceSaving,KLL,hash32,SKETCH_BOUNDS,\n};\n});\n__def(\"packages/core/src/compute/statistics.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"KENDALL_LIMIT\",{enumerable:true,get:function(){return KENDALL_LIMIT;}});\nObject.defineProperty(__exports,\"MAINTENANCE\",{enumerable:true,get:function(){return MAINTENANCE;}});\nObject.defineProperty(__exports,\"APPROXIMATE\",{enumerable:true,get:function(){return APPROXIMATE;}});\nObject.defineProperty(__exports,\"maintenanceOf\",{enumerable:true,get:function(){return maintenanceOf;}});\nObject.defineProperty(__exports,\"numbers\",{enumerable:true,get:function(){return numbers;}});\nObject.defineProperty(__exports,\"frequencies\",{enumerable:true,get:function(){return frequencies;}});\nObject.defineProperty(__exports,\"herfindahl\",{enumerable:true,get:function(){return herfindahl;}});\nObject.defineProperty(__exports,\"entropy\",{enumerable:true,get:function(){return entropy;}});\nObject.defineProperty(__exports,\"evenness\",{enumerable:true,get:function(){return evenness;}});\nObject.defineProperty(__exports,\"topShare\",{enumerable:true,get:function(){return topShare;}});\nObject.defineProperty(__exports,\"gini\",{enumerable:true,get:function(){return gini;}});\nObject.defineProperty(__exports,\"moments\",{enumerable:true,get:function(){return moments;}});\nObject.defineProperty(__exports,\"quantileSorted\",{enumerable:true,get:function(){return quantileSorted;}});\nObject.defineProperty(__exports,\"quantile\",{enumerable:true,get:function(){return quantile;}});\nObject.defineProperty(__exports,\"STAT_FNS\",{enumerable:true,get:function(){return STAT_FNS;}});\nObject.defineProperty(__exports,\"STAT_LABELS\",{enumerable:true,get:function(){return STAT_LABELS;}});\nObject.defineProperty(__exports,\"weightedAverage\",{enumerable:true,get:function(){return weightedAverage;}});\nObject.defineProperty(__exports,\"extremeRow\",{enumerable:true,get:function(){return extremeRow;}});\nObject.defineProperty(__exports,\"correlation\",{enumerable:true,get:function(){return correlation;}});\nObject.defineProperty(__exports,\"trimmedMean\",{enumerable:true,get:function(){return trimmedMean;}});\nObject.defineProperty(__exports,\"winsorizedMean\",{enumerable:true,get:function(){return winsorizedMean;}});\nObject.defineProperty(__exports,\"modifiedZOutliers\",{enumerable:true,get:function(){return modifiedZOutliers;}});\nObject.defineProperty(__exports,\"jarqueBera\",{enumerable:true,get:function(){return jarqueBera;}});\nObject.defineProperty(__exports,\"weightedQuantile\",{enumerable:true,get:function(){return weightedQuantile;}});\nObject.defineProperty(__exports,\"pairs\",{enumerable:true,get:function(){return pairs;}});\nObject.defineProperty(__exports,\"covariance\",{enumerable:true,get:function(){return covariance;}});\nObject.defineProperty(__exports,\"regression\",{enumerable:true,get:function(){return regression;}});\nObject.defineProperty(__exports,\"fitLinearModel\",{enumerable:true,get:function(){return fitLinearModel;}});\nObject.defineProperty(__exports,\"ADF_CT_CRITICAL\",{enumerable:true,get:function(){return ADF_CT_CRITICAL;}});\nObject.defineProperty(__exports,\"augmentedDickeyFuller\",{enumerable:true,get:function(){return augmentedDickeyFuller;}});\nObject.defineProperty(__exports,\"autocorrelations\",{enumerable:true,get:function(){return autocorrelations;}});\nObject.defineProperty(__exports,\"spearman\",{enumerable:true,get:function(){return spearman;}});\nObject.defineProperty(__exports,\"kendall\",{enumerable:true,get:function(){return kendall;}});\nObject.defineProperty(__exports,\"seriesStats\",{enumerable:true,get:function(){return seriesStats;}});\nObject.defineProperty(__exports,\"D2_N2\",{enumerable:true,get:function(){return D2_N2;}});\nObject.defineProperty(__exports,\"D4_N2\",{enumerable:true,get:function(){return D4_N2;}});\nObject.defineProperty(__exports,\"movingRanges\",{enumerable:true,get:function(){return movingRanges;}});\nObject.defineProperty(__exports,\"withinSigma\",{enumerable:true,get:function(){return withinSigma;}});\nObject.defineProperty(__exports,\"capability\",{enumerable:true,get:function(){return capability;}});\nObject.defineProperty(__exports,\"controlLimits\",{enumerable:true,get:function(){return controlLimits;}});\nObject.defineProperty(__exports,\"westernElectricViolations\",{enumerable:true,get:function(){return westernElectricViolations;}});\nObject.defineProperty(__exports,\"nelsonViolations\",{enumerable:true,get:function(){return nelsonViolations;}});\nObject.defineProperty(__exports,\"CONTROL_RULE_SETS\",{enumerable:true,get:function(){return CONTROL_RULE_SETS;}});\nObject.defineProperty(__exports,\"controlViolations\",{enumerable:true,get:function(){return controlViolations;}});\nObject.defineProperty(__exports,\"countOutside\",{enumerable:true,get:function(){return countOutside;}});\nObject.defineProperty(__exports,\"histogram\",{enumerable:true,get:function(){return histogram;}});\nObject.defineProperty(__exports,\"DEFAULT_CONFIDENCE\",{enumerable:true,get:function(){return DEFAULT_CONFIDENCE;}});\nObject.defineProperty(__exports,\"meanInterval\",{enumerable:true,get:function(){return meanInterval;}});\nObject.defineProperty(__exports,\"proportionInterval\",{enumerable:true,get:function(){return proportionInterval;}});\nObject.defineProperty(__exports,\"slopeInterval\",{enumerable:true,get:function(){return slopeInterval;}});\nObject.defineProperty(__exports,\"capabilityInterval\",{enumerable:true,get:function(){return capabilityInterval;}});\nObject.defineProperty(__exports,\"standardizedMeanDifference\",{enumerable:true,get:function(){return standardizedMeanDifference;}});\nObject.defineProperty(__exports,\"normalTotalVariation\",{enumerable:true,get:function(){return normalTotalVariation;}});\nObject.defineProperty(__exports,\"frequencyMap\",{enumerable:true,get:function(){return frequencyMap;}});\nObject.defineProperty(__exports,\"categoricalDistance\",{enumerable:true,get:function(){return categoricalDistance;}});\nObject.defineProperty(__exports,\"SUBSET_RELIABILITY_FLOOR\",{enumerable:true,get:function(){return SUBSET_RELIABILITY_FLOOR;}});\nObject.defineProperty(__exports,\"compareColumn\",{enumerable:true,get:function(){return compareColumn;}});\nObject.defineProperty(__exports,\"isNumericColumn\",{enumerable:true,get:function(){return isNumericColumn;}});\nObject.defineProperty(__exports,\"populationRead\",{enumerable:true,get:function(){return populationRead;}});\nconst __m0=__req(\"packages/core/src/compute/handle.js\");\nconst presenceReader=__m0[\"presenceReader\"];\nconst valueReader=__m0[\"valueReader\"];\nconst __m1=__req(\"packages/core/src/compute/special.js\");\nconst studentTQuantile=__m1[\"studentTQuantile\"];\nconst studentT=__m1[\"studentT\"];\nconst normalQuantile=__m1[\"normalQuantile\"];\nconst normalCdf=__m1[\"normalCdf\"];\nconst chiSquareUpperTail=__m1[\"chiSquareUpperTail\"];\nconst __m2=__req(\"packages/core/src/compute/linalg.js\");\nconst cholesky=__m2[\"cholesky\"];\nconst choleskySolve=__m2[\"choleskySolve\"];\nconst choleskyInverse=__m2[\"choleskyInverse\"];\nconst normalEquations=__m2[\"normalEquations\"];\nconst quadForm=__m2[\"quadForm\"];\nconst __m3=__req(\"packages/core/src/compute/sketch.js\");\nconst SKETCH_BOUNDS=__m3[\"SKETCH_BOUNDS\"];\nconst KENDALL_LIMIT=5000;\nconst MAINTENANCE=Object.freeze({\nvariance:'rescan',\nvarianceP:'rescan',\nstddev:'rescan',\nstddevP:'rescan',\nsumSquares:'rescan',\nweightedAvg:'rescan',\nmedian:'rescan',\np25:'rescan',\np75:'rescan',\np90:'rescan',\np95:'rescan',\np99:'rescan',\niqr:'rescan',\nmode:'rescan',\ndistinct:'rescan',\nrange:'rescan',\nskewness:'rescan',\nkurtosis:'rescan',\ngeomean:'rescan',\nharmean:'rescan',\nmad:'rescan',\nargmin:'rescan',\nargmax:'rescan',\nhhi:'rescan',\nentropy:'rescan',\nevenness:'rescan',\ntop3Share:'rescan',\ntop10Share:'rescan',\ngini:'rescan',\ntrimmedMean:'rescan',\nwinsorizedMean:'rescan',\nrobustOutliers:'rescan',\njarqueBera:'rescan',\npassRate:'rescan',\nfailureCount:'rescan',\n});\nconst APPROXIMATE=Object.freeze({\ndistinct:Object.freeze({sketch:'HyperLogLog',bound:SKETCH_BOUNDS.distinct}),\nmedian:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.median}),\np25:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.p25}),\np75:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.p75}),\np90:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.p90}),\np95:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.p95}),\np99:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.p99}),\niqr:Object.freeze({sketch:'KLL',bound:SKETCH_BOUNDS.iqr}),\ntop3Share:Object.freeze({sketch:'SpaceSaving',bound:SKETCH_BOUNDS.topK}),\ntop10Share:Object.freeze({sketch:'SpaceSaving',bound:SKETCH_BOUNDS.topK}),\n});\nfunction maintenanceOf(fn){\nconst exact=fn==='sum'||fn==='avg'||fn==='countValues'||fn==='min'||fn==='max'\n?'maintained'\n:(Object.prototype.hasOwnProperty.call(MAINTENANCE,fn)?MAINTENANCE[fn]:null);\nconst approximate=Object.prototype.hasOwnProperty.call(APPROXIMATE,fn)?APPROXIMATE[fn]:null;\nreturn{stat:fn,exact,approximate};\n}\nfunction numbers(handle,indices){\nconst n=indices.length;\nconst out=new Float64Array(n);\nlet count=0;\nconst numeric=handle&&(handle.kind==='float64'||handle.kind==='int32');\nif(numeric){\nconst values=handle.values;\nconst present=presenceReader(handle);\nfor(let i=0;i<n;i++){\nconst row=indices[i];\nif(present&&present(row)!==1)continue;\nconst v=values[row];\nif(Number.isNaN(v))continue;\nout[count++]=v;\n}\nreturn out.subarray(0,count);\n}\nconst read=valueReader(handle);\nfor(let i=0;i<n;i++){\nconst raw=read(indices[i]);\nif(raw===null||raw===undefined||raw==='')continue;\nconst v=typeof raw==='number'?raw:Number(raw);\nif(!Number.isFinite(v))continue;\nout[count++]=v;\n}\nreturn out.subarray(0,count);\n}\nfunction frequencies(handle,indices){\nconst seen=new Map();\nconst read=valueReader(handle);\nlet total=0;\nfor(let i=0;i<indices.length;i++){\nconst raw=read(indices[i]);\nif(raw===null||raw===undefined||raw==='')continue;\nif(typeof raw==='number'&&Number.isNaN(raw))continue;\nconst key=typeof raw==='object'?String(raw):raw;\nseen.set(key,(seen.get(key)||0)+1);\ntotal++;\n}\nconst counts=[...seen.values()].sort((a,b)=>b-a);\nreturn{counts,total,distinct:counts.length};\n}\nfunction sharesOf(freq){\nreturn freq.total>0?freq.counts.map((c)=>c/freq.total):[];\n}\nfunction herfindahl(handle,indices){\nconst freq=frequencies(handle,indices);\nif(!freq.total)return null;\nlet sum=0;\nfor(const share of sharesOf(freq))sum+=share*share;\nreturn sum;\n}\nfunction entropy(handle,indices){\nconst freq=frequencies(handle,indices);\nif(!freq.total)return null;\nlet sum=0;\nfor(const share of sharesOf(freq))if(share>0)sum-=share*Math.log2(share);\nreturn sum;\n}\nfunction evenness(handle,indices){\nconst freq=frequencies(handle,indices);\nif(!freq.total||freq.distinct<2)return freq.total?1:null;\nlet sum=0;\nfor(const share of sharesOf(freq))if(share>0)sum-=share*Math.log2(share);\nreturn sum/Math.log2(freq.distinct);\n}\nfunction topShare(handle,indices,n=3){\nconst freq=frequencies(handle,indices);\nif(!freq.total)return null;\nconst take=Math.max(1,Math.floor(n));\nlet held=0;\nfor(let i=0;i<Math.min(take,freq.counts.length);i++)held+=freq.counts[i];\nreturn held/freq.total;\n}\nfunction gini(handle,indices){\nconst values=numbers(handle,indices);\nconst n=values.length;\nif(!n)return null;\nconst sorted=values.slice().sort();\nif(sorted[0]<0)return null;\nlet total=0;\nlet weighted=0;\nfor(let i=0;i<n;i++){\ntotal+=sorted[i];\nweighted+=(i+1)*sorted[i];\n}\nif(total===0)return 0;\nreturn(2*weighted)/(n*total)-(n+1)/n;\n}\nfunction moments(values){\nlet n=0;\nlet mean=0;\nlet m2=0;\nfor(let i=0;i<values.length;i++){\nconst x=values[i];\nn++;\nconst delta=x-mean;\nmean+=delta/n;\nm2+=delta*(x-mean);\n}\nreturn{n,mean,m2};\n}\nfunction quantileSorted(sorted,p){\nconst n=sorted.length;\nif(!n)return NaN;\nif(n===1)return sorted[0];\nconst h=(n-1)*Math.min(1,Math.max(0,p));\nconst lo=Math.floor(h);\nconst hi=Math.ceil(h);\nif(lo===hi)return sorted[lo];\nreturn sorted[lo]+(h-lo)*(sorted[hi]-sorted[lo]);\n}\nfunction quantile(values,p){\nif(!values.length)return NaN;\nconst sorted=values.slice().sort();\nreturn quantileSorted(sorted,p);\n}\nfunction specTally(handle,indices){\nconst read=valueReader(handle);\nlet pass=0;\nlet fail=0;\nlet warn=0;\nfor(let k=0;k<indices.length;k++){\nconst raw=read(indices[k]);\nif(raw===null||raw===undefined||raw==='')continue;\nconst token=String(raw).toUpperCase();\nif(token==='PASS')pass++;\nelse if(token==='FAIL')fail++;\nelse if(token==='WARN')warn++;\n}\nreturn{pass:pass+warn,fail,warn,judged:pass+warn+fail};\n}\nconst STAT_FNS=Object.freeze({\nhhi:(h,i)=>herfindahl(h,i),\nentropy:(h,i)=>entropy(h,i),\nevenness:(h,i)=>evenness(h,i),\ntop3Share:(h,i)=>topShare(h,i,3),\ntop10Share:(h,i)=>topShare(h,i,10),\ngini:(h,i)=>gini(h,i),\ntrimmedMean:(h,i)=>trimmedMean(numbers(h,i),0.1),\nwinsorizedMean:(h,i)=>winsorizedMean(numbers(h,i),0.1),\nrobustOutliers:(h,i)=>modifiedZOutliers(numbers(h,i),3.5),\njarqueBera:(h,i)=>jarqueBera(numbers(h,i)),\nvariance:(h,i)=>{\nconst{n,m2}=moments(numbers(h,i));\nreturn n>1?m2/(n-1):null;\n},\nvarianceP:(h,i)=>{\nconst{n,m2}=moments(numbers(h,i));\nreturn n>0?m2/n:null;\n},\nstddev:(h,i)=>{\nconst{n,m2}=moments(numbers(h,i));\nreturn n>1?Math.sqrt(m2/(n-1)):null;\n},\nstddevP:(h,i)=>{\nconst{n,m2}=moments(numbers(h,i));\nreturn n>0?Math.sqrt(m2/n):null;\n},\nmedian:(h,i)=>{\nconst values=numbers(h,i);\nreturn values.length?quantile(values,0.5):null;\n},\np25:(h,i)=>{\nconst values=numbers(h,i);\nreturn values.length?quantile(values,0.25):null;\n},\np75:(h,i)=>{\nconst values=numbers(h,i);\nreturn values.length?quantile(values,0.75):null;\n},\np90:(h,i)=>{\nconst values=numbers(h,i);\nreturn values.length?quantile(values,0.9):null;\n},\np95:(h,i)=>{\nconst values=numbers(h,i);\nreturn values.length?quantile(values,0.95):null;\n},\np99:(h,i)=>{\nconst values=numbers(h,i);\nreturn values.length?quantile(values,0.99):null;\n},\niqr:(h,i)=>{\nconst values=numbers(h,i);\nif(!values.length)return null;\nconst sorted=values.slice().sort();\nreturn quantileSorted(sorted,0.75)-quantileSorted(sorted,0.25);\n},\nmad:(h,i)=>{\nconst values=numbers(h,i);\nif(!values.length)return null;\nconst middle=quantile(values,0.5);\nconst deviations=new Float64Array(values.length);\nfor(let k=0;k<values.length;k++)deviations[k]=Math.abs(values[k]-middle);\nreturn quantile(deviations,0.5);\n},\nrange:(h,i)=>{\nconst values=numbers(h,i);\nif(!values.length)return null;\nlet lo=Infinity;\nlet hi=-Infinity;\nfor(let k=0;k<values.length;k++){\nif(values[k]<lo)lo=values[k];\nif(values[k]>hi)hi=values[k];\n}\nreturn hi-lo;\n},\ndistinct:(h,i)=>{\nconst read=valueReader(h);\nconst seen=new Set();\nfor(let k=0;k<i.length;k++){\nconst v=read(i[k]);\nif(v===null||v===undefined||v==='')continue;\nseen.add(v instanceof Date?v.getTime():v);\n}\nreturn seen.size;\n},\nmode:(h,i)=>{\nconst read=valueReader(h);\nconst counts=new Map();\nfor(let k=0;k<i.length;k++){\nconst v=read(i[k]);\nif(v===null||v===undefined||v==='')continue;\nconst id=v instanceof Date?v.getTime():v;\ncounts.set(id,(counts.get(id)||0)+1);\n}\nlet best=null;\nlet most=1;\nfor(const[value,times]of counts){\nif(times>most){\nmost=times;\nbest=value;\n}\n}\nreturn best;\n},\nskewness:(h,i)=>{\nconst values=numbers(h,i);\nconst{n,mean,m2}=moments(values);\nif(n<3||m2<=0)return null;\nconst sd=Math.sqrt(m2/(n-1));\nlet sum=0;\nfor(let k=0;k<values.length;k++)sum+=((values[k]-mean)/sd)**3;\nreturn(n/((n-1)*(n-2)))*sum;\n},\nkurtosis:(h,i)=>{\nconst values=numbers(h,i);\nconst{n,mean,m2}=moments(values);\nif(n<4||m2<=0)return null;\nconst sd=Math.sqrt(m2/(n-1));\nlet sum=0;\nfor(let k=0;k<values.length;k++)sum+=((values[k]-mean)/sd)**4;\nconst a=(n*(n+1))/((n-1)*(n-2)*(n-3));\nconst b=(3*(n-1)**2)/((n-2)*(n-3));\nreturn a*sum-b;\n},\ngeomean:(h,i)=>{\nconst values=numbers(h,i);\nif(!values.length)return null;\nlet sum=0;\nfor(let k=0;k<values.length;k++){\nif(values[k]<=0)return null;\nsum+=Math.log(values[k]);\n}\nreturn Math.exp(sum/values.length);\n},\nharmean:(h,i)=>{\nconst values=numbers(h,i);\nif(!values.length)return null;\nlet sum=0;\nfor(let k=0;k<values.length;k++){\nif(values[k]===0)return null;\nsum+=1/values[k];\n}\nreturn values.length/sum;\n},\nsumSquares:(h,i)=>{\nconst values=numbers(h,i);\nlet sum=0;\nfor(let k=0;k<values.length;k++)sum+=values[k]*values[k];\nreturn sum;\n},\npassRate:(h,i)=>{\nconst{pass,judged}=specTally(h,i);\nreturn judged?pass/judged:null;\n},\nfailureCount:(h,i)=>specTally(h,i).fail,\n});\nconst STAT_LABELS=Object.freeze({\nhhi:'Concentration (HHI)',\nentropy:'Entropy',\nevenness:'Evenness',\ntop3Share:'Top 3 share',\ntop10Share:'Top 10 share',\ngini:'Gini coefficient',\ntrimmedMean:'Trimmed mean',\nwinsorizedMean:'Winsorized mean',\nrobustOutliers:'Outliers (robust)',\njarqueBera:'Jarque–Bera',\nmedian:'Median',\np25:'25th percentile',\np75:'75th percentile',\np90:'90th percentile',\np95:'95th percentile',\np99:'99th percentile',\niqr:'Interquartile range',\nmad:'Median absolute deviation',\nvariance:'Variance',\nvarianceP:'Variance (population)',\nstddev:'Standard deviation',\nstddevP:'Standard deviation (population)',\nrange:'Range',\ndistinct:'Distinct',\nmode:'Mode',\nskewness:'Skewness',\nkurtosis:'Kurtosis',\ngeomean:'Geometric mean',\nharmean:'Harmonic mean',\nsumSquares:'Sum of squares',\nweightedAvg:'Weighted average',\nargmin:'Lowest by',\nargmax:'Highest by',\npassRate:'Pass rate',\nfailureCount:'Failures',\n});\nfunction weightedAverage(handle,weights,indices){\nconst readValue=valueReader(handle);\nconst readWeight=valueReader(weights);\nlet top=0;\nlet bottom=0;\nfor(let i=0;i<indices.length;i++){\nconst row=indices[i];\nconst value=Number(readValue(row));\nconst weight=Number(readWeight(row));\nif(!Number.isFinite(value)||!Number.isFinite(weight))continue;\ntop+=value*weight;\nbottom+=weight;\n}\nreturn bottom===0?null:top/bottom;\n}\nfunction extremeRow(handle,indices,largest){\nconst read=valueReader(handle);\nlet best=null;\nlet bestValue=largest?-Infinity:Infinity;\nfor(let i=0;i<indices.length;i++){\nconst row=indices[i];\nconst value=Number(read(row));\nif(!Number.isFinite(value))continue;\nif(largest?value>bestValue:value<bestValue){\nbestValue=value;\nbest=row;\n}\n}\nreturn best;\n}\nfunction correlation(a,b,indices){\nconst readA=valueReader(a);\nconst readB=valueReader(b);\nlet n=0;\nlet sx=0;\nlet sy=0;\nlet sxx=0;\nlet syy=0;\nlet sxy=0;\nfor(let i=0;i<indices.length;i++){\nconst row=indices[i];\nconst x=Number(readA(row));\nconst y=Number(readB(row));\nif(!Number.isFinite(x)||!Number.isFinite(y))continue;\nn++;\nsx+=x;\nsy+=y;\nsxx+=x*x;\nsyy+=y*y;\nsxy+=x*y;\n}\nif(n<2)return null;\nconst top=n*sxy-sx*sy;\nconst bottom=Math.sqrt((n*sxx-sx*sx)*(n*syy-sy*sy));\nif(bottom===0)return null;\nconst r=top/bottom;\nreturn Math.max(-1,Math.min(1,r));\n}\nfunction trimmedMean(values,share=0.1){\nconst n=values.length;\nif(!n)return null;\nconst sorted=Array.from(values).sort((a,b)=>a-b);\nconst cut=Math.floor(n*Math.min(0.49,Math.max(0,share)));\nconst kept=sorted.slice(cut,n-cut);\nif(!kept.length)return quantileSorted(sorted,0.5);\nlet sum=0;\nfor(const v of kept)sum+=v;\nreturn sum/kept.length;\n}\nfunction winsorizedMean(values,share=0.1){\nconst n=values.length;\nif(!n)return null;\nconst sorted=Array.from(values).sort((a,b)=>a-b);\nconst cut=Math.floor(n*Math.min(0.49,Math.max(0,share)));\nconst low=sorted[cut];\nconst high=sorted[n-1-cut];\nlet sum=0;\nfor(const v of sorted)sum+=Math.min(high,Math.max(low,v));\nreturn sum/n;\n}\nfunction modifiedZOutliers(values,threshold=3.5){\nconst n=values.length;\nif(!n)return null;\nconst sorted=Array.from(values).sort((a,b)=>a-b);\nconst middle=quantileSorted(sorted,0.5);\nconst deviations=sorted.map((v)=>Math.abs(v-middle)).sort((a,b)=>a-b);\nconst mad=quantileSorted(deviations,0.5);\nif(mad===0)return null;\nlet count=0;\nfor(const v of sorted)if(Math.abs((0.6745*(v-middle))/mad)>threshold)count++;\nreturn count;\n}\nfunction jarqueBera(values){\nconst n=values.length;\nif(n<8)return null;\nlet mean=0;\nfor(const v of values)mean+=v;\nmean/=n;\nlet m2=0;\nlet m3=0;\nlet m4=0;\nfor(const v of values){\nconst d=v-mean;\nm2+=d*d;\nm3+=d*d*d;\nm4+=d*d*d*d;\n}\nm2/=n;\nm3/=n;\nm4/=n;\nif(m2===0)return null;\nconst skew=m3/m2**1.5;\nconst excess=m4/(m2*m2)-3;\nreturn(n/6)*(skew*skew+(excess*excess)/4);\n}\nfunction weightedQuantile(values,weights,p){\nconst paired=[];\nlet total=0;\nfor(let i=0;i<values.length;i++){\nconst v=Number(values[i]);\nconst w=Number(weights[i]);\nif(!Number.isFinite(v)||!Number.isFinite(w)||w<=0)continue;\npaired.push([v,w]);\ntotal+=w;\n}\nif(!paired.length||total<=0)return null;\npaired.sort((a,b)=>a[0]-b[0]);\nif(paired.length===1)return paired[0][0];\nconst at=[];\nlet seen=0;\nfor(const[,w]of paired){\nat.push((seen+w/2)/total);\nseen+=w;\n}\nconst target=Math.max(0,Math.min(1,p));\nif(target<=at[0])return paired[0][0];\nif(target>=at[at.length-1])return paired[paired.length-1][0];\nfor(let i=1;i<at.length;i++){\nif(target>at[i])continue;\nconst span=at[i]-at[i-1];\nconst within=span>0?(target-at[i-1])/span:0;\nreturn paired[i-1][0]+(paired[i][0]-paired[i-1][0])*within;\n}\nreturn paired[paired.length-1][0];\n}\nfunction pairs(a,b,indices){\nconst readA=valueReader(a);\nconst readB=valueReader(b);\nconst xs=new Float64Array(indices.length);\nconst ys=new Float64Array(indices.length);\nlet n=0;\nfor(let i=0;i<indices.length;i++){\nconst row=indices[i];\nconst x=Number(readA(row));\nconst y=Number(readB(row));\nif(!Number.isFinite(x)||!Number.isFinite(y))continue;\nxs[n]=x;\nys[n]=y;\nn++;\n}\nreturn{xs:xs.subarray(0,n),ys:ys.subarray(0,n),n};\n}\nfunction covariance(a,b,indices,population=false){\nconst{xs,ys,n}=pairs(a,b,indices);\nif(n<2)return null;\nlet mx=0;\nlet my=0;\nfor(let i=0;i<n;i++){mx+=xs[i];my+=ys[i];}\nmx/=n;\nmy/=n;\nlet sum=0;\nfor(let i=0;i<n;i++)sum+=(xs[i]-mx)*(ys[i]-my);\nreturn sum/(population?n:n-1);\n}\nfunction regression(a,b,indices){\nconst{xs,ys,n}=pairs(a,b,indices);\nif(n<2)return null;\nlet mx=0;\nlet my=0;\nfor(let i=0;i<n;i++){mx+=xs[i];my+=ys[i];}\nmx/=n;\nmy/=n;\nlet sxx=0;\nlet sxy=0;\nlet syy=0;\nfor(let i=0;i<n;i++){\nconst dx=xs[i]-mx;\nconst dy=ys[i]-my;\nsxx+=dx*dx;\nsxy+=dx*dy;\nsyy+=dy*dy;\n}\nif(sxx===0)return null;\nconst slope=sxy/sxx;\nconst intercept=my-slope*mx;\nconst r2=syy===0?1:Math.max(0,Math.min(1,(sxy*sxy)/(sxx*syy)));\nconst residual=Math.max(0,syy-slope*sxy);\nconst stdError=n>2?Math.sqrt(residual/(n-2)/sxx):0;\nreturn{slope,intercept,r2,stdError,n};\n}\nconst SUPPORTED_METHODS=new Set(['ols','wls','robust']);\nconst DEFERRED_METHODS=new Set(['quantile']);\nconst OUT_OF_SCOPE_METHODS=new Set(['ridge','lasso','elasticnet','mixed','gls']);\nconst HUBER_C=1.345;\nfunction solveWls(design,y,w){\nconst{xtwx,xtwy}=normalEquations(design,y,w);\nconst l=cholesky(xtwx);\nif(!l)return null;\nconst beta=choleskySolve(l,xtwy);\nconst cov=choleskyInverse(l);\nconst fitted=matVecRows(design,beta);\nconst residuals=y.map((yi,i)=>yi-fitted[i]);\nreturn{beta,cov,fitted,residuals};\n}\nfunction matVecRows(rows,v){\nreturn rows.map((row)=>row.reduce((sum,cell,j)=>sum+cell*v[j],0));\n}\nfunction auxiliaryR2(predictors,j){\nconst n=predictors.length;\nconst y=predictors.map((row)=>row[j]);\nconst design=predictors.map((row)=>[1,...row.filter((unused,c)=>c!==j)]);\nconst fit=solveWls(design,y,null);\nif(!fit)return 1;\nconst ybar=y.reduce((s,v)=>s+v,0)/n;\nlet rss=0;\nlet tss=0;\nfor(let i=0;i<n;i++){rss+=fit.residuals[i]**2;tss+=(y[i]-ybar)**2;}\nif(tss===0)return 1;\nreturn Math.max(0,Math.min(1,1-rss/tss));\n}\nfunction madScale(values){\nconst sorted=[...values].sort((a,b)=>a-b);\nconst med=medianOfSorted(sorted);\nconst dev=values.map((v)=>Math.abs(v-med)).sort((a,b)=>a-b);\nreturn medianOfSorted(dev)/0.6745;\n}\nfunction medianOfSorted(sorted){\nconst n=sorted.length;\nif(!n)return 0;\nconst mid=Math.floor(n/2);\nreturn n%2?sorted[mid]:(sorted[mid-1]+sorted[mid])/2;\n}\nfunction fitLinearModel(matrix,y,opts={}){\nconst method=opts.method||'ols';\nif(OUT_OF_SCOPE_METHODS.has(method)){\nthrow new Error(`[lattice] regression method \"${method}\" is out of scope; use ols, wls or robust.`);\n}\nif(DEFERRED_METHODS.has(method)){\nthrow new Error(`[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.`);\n}\nif(!SUPPORTED_METHODS.has(method)){\nthrow new Error(`[lattice] unknown regression method \"${method}\"; use ols, wls or robust.`);\n}\nconst n=Array.isArray(y)?y.length:0;\nconst k=n&&Array.isArray(matrix[0])?matrix[0].length:0;\nconst p=k+1;\nif(!(n>p))return null;\nfor(let i=0;i<n;i++){\nif(!Number.isFinite(y[i]))return null;\nif(!Array.isArray(matrix[i])||matrix[i].length!==k)return null;\nfor(let j=0;j<k;j++)if(!Number.isFinite(matrix[i][j]))return null;\n}\nlet weights=null;\nif(method==='wls'){\nweights=opts.weights;\nif(!Array.isArray(weights)||weights.length!==n)return null;\nfor(let i=0;i<n;i++)if(!(weights[i]>0)||!Number.isFinite(weights[i]))return null;\n}\nconst design=matrix.map((row)=>[1,...row]);\nlet fit;\nlet robustWeights=null;\nif(method==='robust'){\nfit=solveWls(design,y,null);\nif(!fit)return null;\nfor(let iter=0;iter<50;iter++){\nconst scale=madScale(fit.residuals);\nif(!(scale>0))break;\nconst w=fit.residuals.map((r)=>{\nconst u=Math.abs(r/scale);\nreturn u<=HUBER_C?1:HUBER_C/u;\n});\nconst next=solveWls(design,y,w);\nif(!next)return null;\nconst moved=next.beta.reduce((m,b,j)=>Math.max(m,Math.abs(b-fit.beta[j])),0);\nfit=next;\nrobustWeights=w;\nif(moved<1e-10)break;\n}\n}else{\nfit=solveWls(design,y,weights);\nif(!fit)return null;\n}\nconst w=method==='robust'?robustWeights:weights;\nconst{beta,cov,fitted,residuals}=fit;\nlet rss=0;\nlet sw=0;\nlet swy=0;\nfor(let i=0;i<n;i++){\nconst wi=w?w[i]:1;\nrss+=wi*residuals[i]**2;\nsw+=wi;\nswy+=wi*y[i];\n}\nconst ybar=swy/sw;\nlet tss=0;\nfor(let i=0;i<n;i++){const wi=w?w[i]:1;tss+=wi*(y[i]-ybar)**2;}\nconst df=n-p;\nconst sigma2=rss/df;\nconst r2=tss===0?1:Math.max(0,Math.min(1,1-rss/tss));\nconst adjR2=1-(1-r2)*(n-1)/df;\nconst names=Array.isArray(opts.names)&&opts.names.length===k\n?opts.names:matrix[0].map((unused,j)=>`x${j+1}`);\nconst conf=level(opts.confidence);\nconst tCrit=df>0?studentTQuantile(1-(1-conf)/2,df):Infinity;\nconst coefficients=beta.map((estimate,j)=>{\nconst stdError=Math.sqrt(Math.max(0,sigma2*cov[j][j]));\nconst t=stdError>0?estimate/stdError:(estimate===0?0:Infinity);\nconst pv=Number.isFinite(t)?2*(1-studentT(Math.abs(t),df)):0;\nconst half=Number.isFinite(tCrit)?tCrit*stdError:null;\nreturn{\nname:j===0?'(intercept)':names[j-1],\nestimate,\nstdError,\nt,\np:Math.max(0,Math.min(1,pv)),\nlower:half===null?null:estimate-half,\nupper:half===null?null:estimate+half,\n};\n});\nconst leverage=new Array(n);\nconst cooksD=new Array(n);\nfor(let i=0;i<n;i++){\nconst wi=w?w[i]:1;\nconst h=Math.max(0,Math.min(1,wi*quadForm(design[i],cov)));\nleverage[i]=h;\nconst denom=(1-h)**2;\ncooksD[i]=(denom>0&&sigma2>0)\n?(residuals[i]**2/(p*sigma2))*(h/denom)\n:null;\n}\nconst vif=matrix[0].map((unused,j)=>{\nif(k<2)return 1;\nconst rj=auxiliaryR2(matrix,j);\nreturn rj>=1?Infinity:1/(1-rj);\n});\nlet hetero=null;\n{\nconst e2=residuals.map((r)=>r*r);\nconst aux=solveWls(design,e2,null);\nif(aux){\nconst e2bar=e2.reduce((s,v)=>s+v,0)/n;\nlet arss=0;\nlet atss=0;\nfor(let i=0;i<n;i++){arss+=aux.residuals[i]**2;atss+=(e2[i]-e2bar)**2;}\nconst auxR2=atss===0?0:Math.max(0,Math.min(1,1-arss/atss));\nconst statistic=n*auxR2;\nconst pv=chiSquareUpperTail(statistic,k);\nhetero={statistic,df:k,p:pv,heteroscedastic:pv<0.05};\n}\n}\nlet band=null;\nif(k===1){\nconst order=matrix.map((row,i)=>i).sort((i,j)=>matrix[i][0]-matrix[j][0]);\nband={\nconfidence:conf,\npoints:order.map((i)=>{\nconst xo=design[i];\nconst se=Math.sqrt(Math.max(0,sigma2*quadForm(xo,cov)));\nreturn{x:matrix[i][0],yhat:fitted[i],lower:fitted[i]-tCrit*se,upper:fitted[i]+tCrit*se};\n}),\n};\n}\nreturn{\nmethod,\ncoefficients,\nr2,\nadjR2,\nn,\ndf,\nsigma2,\nfitted,\nresiduals,\nleverage,\ncooksD,\nvif,\nheteroscedasticity:hetero,\nband,\nweights:w?[...w]:null,\n};\n}\nfunction ranksOf(values){\nconst n=values.length;\nconst order=Array.from({length:n},(unused,i)=>i)\n.sort((i,j)=>values[i]-values[j]);\nconst ranks=new Float64Array(n);\nlet i=0;\nwhile(i<n){\nlet j=i;\nwhile(j+1<n&&values[order[j+1]]===values[order[i]])j++;\nconst shared=(i+j)/2+1;\nfor(let k=i;k<=j;k++)ranks[order[k]]=shared;\ni=j+1;\n}\nreturn ranks;\n}\nconst ADF_CT_CRITICAL=Object.freeze({'1%':-3.9638,'5%':-3.4126,'10%':-3.1279});\nfunction adfInterpolatedP(stat){\nconst levels=[0.01,0.05,0.10];\nconst crit=[ADF_CT_CRITICAL['1%'],ADF_CT_CRITICAL['5%'],ADF_CT_CRITICAL['10%']];\nif(stat<=crit[0]){\nconst slope=(Math.log(levels[1])-Math.log(levels[0]))/(crit[1]-crit[0]);\nreturn Math.max(1e-4,Math.min(0.01,Math.exp(Math.log(levels[0])+slope*(stat-crit[0]))));\n}\nif(stat>=crit[2]){\nconst slope=(Math.log(levels[2])-Math.log(levels[1]))/(crit[2]-crit[1]);\nreturn Math.max(0.10,Math.min(0.999,Math.exp(Math.log(levels[2])+slope*(stat-crit[2]))));\n}\nconst i=stat<crit[1]?0:1;\nconst t=(stat-crit[i])/(crit[i+1]-crit[i]);\nreturn Math.exp(Math.log(levels[i])+t*(Math.log(levels[i+1])-Math.log(levels[i])));\n}\nfunction augmentedDickeyFuller(x,opts={}){\nconst series=[];\nfor(let i=0;i<x.length;i++){\nconst v=Number(x[i]);\nif(Number.isFinite(v))series.push(v);\n}\nconst n=series.length;\nconst m=n-1;\nif(n<8||m<6)return null;\nconst xdiff=new Array(m);\nfor(let i=0;i<m;i++)xdiff[i]=series[i+1]-series[i];\nlet maxlag=Number.isFinite(opts.maxlag)\n?Math.floor(opts.maxlag)\n:Math.ceil(12*(n/100)**0.25);\nmaxlag=Math.max(0,Math.min(maxlag,Math.floor((m-5)/2)));\nconst fit=(p,start)=>{\nconst rows=[];\nconst y=[];\nfor(let j=start;j<m;j++){\nconst row=[(j-start)+1,series[j]];\nfor(let d=1;d<=p;d++)row.push(xdiff[j-d]);\nrows.push(row);\ny.push(xdiff[j]);\n}\nreturn fitLinearModel(rows,y,{method:'ols'});\n};\nconst nFixed=m-maxlag;\nlet bestLag=0;\nlet bestAic=Infinity;\nfor(let p=0;p<=maxlag;p++){\nconst model=fit(p,maxlag);\nif(!model)continue;\nconst params=p+3;\nconst rss=model.sigma2*(nFixed-params);\nif(!(rss>0))continue;\nconst aic=nFixed*Math.log(rss/nFixed)+2*params;\nif(aic<bestAic){bestAic=aic;bestLag=p;}\n}\nconst finalModel=fit(bestLag,bestLag);\nif(!finalModel||!finalModel.coefficients[2])return null;\nconst statistic=finalModel.coefficients[2].t;\nconst pValue=adfInterpolatedP(statistic);\nconst stationary=statistic<ADF_CT_CRITICAL['5%'];\nreturn{\nstatistic,\nusedLag:bestLag,\nnobs:m-bestLag,\ncriticalValues:{...ADF_CT_CRITICAL},\npValue,\npApproximate:true,\nstationary,\nverdict:stationary?'stationary':'non-stationary',\nregression:'ct',\n};\n}\nfunction autocorrelations(x,opts={}){\nconst y=[];\nfor(let i=0;i<x.length;i++){\nconst v=Number(x[i]);\nif(Number.isFinite(v))y.push(v);\n}\nconst n=y.length;\nif(n<3)return null;\nlet maxlag=Number.isFinite(opts.maxlag)?Math.floor(opts.maxlag):Math.min(10,n-1);\nmaxlag=Math.max(1,Math.min(maxlag,n-1));\nlet mean=0;\nfor(const v of y)mean+=v;\nmean/=n;\nconst dev=y.map((v)=>v-mean);\nlet c0=0;\nfor(const d of dev)c0+=d*d;\nc0/=n;\nconst acf=new Array(maxlag+1).fill(0);\nacf[0]=1;\nfor(let k=1;k<=maxlag;k++){\nlet s=0;\nfor(let t=k;t<n;t++)s+=dev[t]*dev[t-k];\nacf[k]=c0>0?(s/n)/c0:0;\n}\nconst pacf=new Array(maxlag+1).fill(0);\npacf[0]=1;\nlet prev=[];\nfor(let k=1;k<=maxlag;k++){\nlet num=acf[k];\nfor(let j=1;j<k;j++)num-=prev[j-1]*acf[k-j];\nlet den=1;\nfor(let j=1;j<k;j++)den-=prev[j-1]*acf[j];\nconst phikk=den!==0?num/den:0;\nconst cur=new Array(k);\nfor(let j=1;j<k;j++)cur[j-1]=prev[j-1]-phikk*prev[k-1-j];\ncur[k-1]=phikk;\npacf[k]=phikk;\nprev=cur;\n}\nconst bound=1.96/Math.sqrt(n);\nreturn{acf,pacf,bounds:{upper:bound,lower:-bound},n,nlags:maxlag,approximate:true};\n}\nfunction spearman(a,b,indices){\nconst{xs,ys,n}=pairs(a,b,indices);\nif(n<2)return null;\nconst rx=ranksOf(xs);\nconst ry=ranksOf(ys);\nlet mx=0;\nlet my=0;\nfor(let i=0;i<n;i++){mx+=rx[i];my+=ry[i];}\nmx/=n;\nmy/=n;\nlet sxy=0;\nlet sxx=0;\nlet syy=0;\nfor(let i=0;i<n;i++){\nconst dx=rx[i]-mx;\nconst dy=ry[i]-my;\nsxy+=dx*dy;\nsxx+=dx*dx;\nsyy+=dy*dy;\n}\nif(sxx===0||syy===0)return null;\nreturn Math.max(-1,Math.min(1,sxy/Math.sqrt(sxx*syy)));\n}\nfunction kendall(a,b,indices){\nconst{xs,ys,n}=pairs(a,b,indices);\nif(n<2||n>KENDALL_LIMIT)return null;\nlet concordant=0;\nlet discordant=0;\nlet tiedXOnly=0;\nlet tiedYOnly=0;\nfor(let i=0;i<n;i++){\nfor(let j=i+1;j<n;j++){\nconst dx=Math.sign(xs[i]-xs[j]);\nconst dy=Math.sign(ys[i]-ys[j]);\nconst product=dx*dy;\nif(product>0)concordant++;\nelse if(product<0)discordant++;\nelse if(dx===0&&dy===0){}\nelse if(dx===0)tiedXOnly++;\nelse tiedYOnly++;\n}\n}\nconst orderedByX=concordant+discordant+tiedYOnly;\nconst orderedByY=concordant+discordant+tiedXOnly;\nif(orderedByX===0||orderedByY===0)return null;\nreturn(concordant-discordant)/Math.sqrt(orderedByX*orderedByY);\n}\nfunction seriesStats(ordered,opts={}){\nconst n=ordered.length;\nif(n<2)return null;\nconst first=ordered[0];\nconst last=ordered[n-1];\nconst returns=[];\nfor(let i=1;i<n;i++){\nconst previous=ordered[i-1];\nif(previous===0)continue;\nreturns.push((ordered[i]-previous)/Math.abs(previous));\n}\nlet volatility=null;\nif(returns.length>1){\nlet mean=0;\nfor(const r of returns)mean+=r;\nmean/=returns.length;\nlet m2=0;\nfor(const r of returns)m2+=(r-mean)**2;\nvolatility=Math.sqrt(m2/(returns.length-1));\n}\nconst periods=Number(opts.periodsPerYear)>0?Number(opts.periodsPerYear):null;\nlet peak=ordered[0];\nlet peakAt=0;\nlet worst=0;\nlet worstFrom=0;\nlet worstTo=0;\nfor(let i=1;i<n;i++){\nif(ordered[i]>peak){peak=ordered[i];peakAt=i;continue;}\nif(peak<=0)continue;\nconst fall=(peak-ordered[i])/peak;\nif(fall>worst){worst=fall;worstFrom=peakAt;worstTo=i;}\n}\nlet autocorrelation=null;\nif(n>2){\nlet mean=0;\nfor(let i=0;i<n;i++)mean+=ordered[i];\nmean/=n;\nlet top=0;\nlet bottom=0;\nfor(let i=0;i<n;i++){\nconst d=ordered[i]-mean;\nbottom+=d*d;\nif(i>0)top+=d*(ordered[i-1]-mean);\n}\nautocorrelation=bottom>0?top/bottom:null;\n}\nlet up=0;\nlet down=0;\nfor(const r of returns){if(r>0)up++;else if(r<0)down++;}\nlet growth=null;\nif(first>0&&last>0){\nconst perPeriod=(last/first)**(1/(n-1))-1;\ngrowth=periods?(1+perPeriod)**periods-1:perPeriod;\n}\nreturn{\nn,\nfirst,\nlast,\nchange:last-first,\nchangePercent:first===0?null:((last-first)/Math.abs(first))*100,\nvolatility,\nannualisedVolatility:volatility!==null&&periods?volatility*Math.sqrt(periods):null,\ngrowth,\nmaxDrawdown:worst,\nmaxDrawdownFrom:worstFrom,\nmaxDrawdownTo:worstTo,\nautocorrelation,\nupDays:up,\ndownDays:down,\n};\n}\nconst D2_N2=1.128;\nconst D4_N2=3.267;\nfunction movingRanges(ordered){\nconst n=ordered.length;\nif(n<2)return null;\nconst ranges=[];\nfor(let i=1;i<n;i++)ranges.push(Math.abs(ordered[i]-ordered[i-1]));\nconst centre=ranges.reduce((t,r)=>t+r,0)/ranges.length;\nreturn{ranges,centre,upper:D4_N2*centre,lower:0};\n}\nfunction withinSigma(ordered){\nconst n=ordered.length;\nif(n<2)return null;\nlet total=0;\nfor(let i=1;i<n;i++)total+=Math.abs(ordered[i]-ordered[i-1]);\nconst meanRange=total/(n-1);\nreturn{sigma:meanRange/D2_N2,meanRange};\n}\nfunction capability(ordered,spec){\nconst n=ordered.length;\nif(n<2||!spec)return null;\nconst lower=Number.isFinite(Number(spec.lower))?Number(spec.lower):null;\nconst upper=Number.isFinite(Number(spec.upper))?Number(spec.upper):null;\nif(lower===null&&upper===null)return null;\nlet mean=0;\nfor(let i=0;i<n;i++)mean+=ordered[i];\nmean/=n;\nlet m2=0;\nfor(let i=0;i<n;i++)m2+=(ordered[i]-mean)**2;\nconst overall=Math.sqrt(m2/(n-1));\nconst within=withinSigma(ordered);\nconst sigmaWithin=within?within.sigma:null;\nconst indices=(sigma)=>{\nif(!sigma||sigma<=0)return{index:null,k:null};\nconst both=lower!==null&&upper!==null;\nconst index=both?(upper-lower)/(6*sigma):null;\nconst upperSide=upper!==null?(upper-mean)/(3*sigma):Infinity;\nconst lowerSide=lower!==null?(mean-lower)/(3*sigma):Infinity;\nreturn{index,k:Math.min(upperSide,lowerSide)};\n};\nconst short=indices(sigmaWithin);\nconst long=indices(overall);\nlet outOfSpec=0;\nfor(let i=0;i<n;i++){\nif(lower!==null&&ordered[i]<lower){outOfSpec++;continue;}\nif(upper!==null&&ordered[i]>upper)outOfSpec++;\n}\nreturn{\nn,\nmean,\nlower,\nupper,\ntarget:Number.isFinite(Number(spec.target))?Number(spec.target):null,\nsigmaWithin,\nsigmaOverall:overall,\ncp:short.index,\ncpk:short.k,\npp:long.index,\nppk:long.k,\noutOfSpec,\ndefectRate:n?outOfSpec/n:null,\n};\n}\nfunction controlLimits(ordered){\nconst n=ordered.length;\nif(n<2)return null;\nconst within=withinSigma(ordered);\nif(!within||!(within.sigma>0))return null;\nlet centre=0;\nfor(let i=0;i<n;i++)centre+=ordered[i];\ncentre/=n;\nreturn{\ncentre,\nsigma:within.sigma,\nupper:centre+3*within.sigma,\nlower:centre-3*within.sigma,\n};\n}\nfunction westernElectricViolations(ordered,limits){\nif(!limits||!(limits.sigma>0))return[];\nconst n=ordered.length;\nconst{centre,sigma}=limits;\nconst z=(i)=>(ordered[i]-centre)/sigma;\nconst out=[];\nfor(let i=0;i<n;i++){\nif(Math.abs(z(i))>3){\nout.push({index:i,rule:1,description:'beyond three sigma'});\n}\nif(i>=2){\nfor(const side of[1,-1]){\nlet hits=0;\nfor(let k=i-2;k<=i;k++)if(z(k)*side>2)hits++;\nif(hits>=2){\nout.push({index:i,rule:2,description:'two of three past two sigma'});\nbreak;\n}\n}\n}\nif(i>=4){\nfor(const side of[1,-1]){\nlet hits=0;\nfor(let k=i-4;k<=i;k++)if(z(k)*side>1)hits++;\nif(hits>=4){\nout.push({index:i,rule:3,description:'four of five past one sigma'});\nbreak;\n}\n}\n}\nif(i>=7){\nfor(const side of[1,-1]){\nlet all=true;\nfor(let k=i-7;k<=i;k++)if(z(k)*side<=0){all=false;break;}\nif(all){\nout.push({index:i,rule:4,description:'eight in a row on one side'});\nbreak;\n}\n}\n}\n}\nreturn out;\n}\nfunction nelsonViolations(ordered,limits){\nif(!limits||!(limits.sigma>0))return[];\nconst n=ordered.length;\nconst{centre,sigma}=limits;\nconst z=(i)=>(ordered[i]-centre)/sigma;\nconst oneSide=(from,to,past,need)=>{\nfor(const side of[1,-1]){\nlet hits=0;\nfor(let k=from;k<=to;k++)if(z(k)*side>past)hits++;\nif(hits>=need)return true;\n}\nreturn false;\n};\nconst out=[];\nfor(let i=0;i<n;i++){\nif(Math.abs(z(i))>3)out.push({index:i,rule:1,description:'beyond three sigma'});\nif(i>=8){\nfor(const side of[1,-1]){\nlet all=true;\nfor(let k=i-8;k<=i;k++)if(z(k)*side<=0){all=false;break;}\nif(all){out.push({index:i,rule:2,description:'nine in a row on one side'});break;}\n}\n}\nif(i>=5){\nfor(const dir of[1,-1]){\nlet all=true;\nfor(let k=i-4;k<=i;k++){\nif((ordered[k]-ordered[k-1])*dir<=0){all=false;break;}\n}\nif(all){\nout.push({index:i,rule:3,description:dir>0?'six rising':'six falling'});\nbreak;\n}\n}\n}\nif(i>=13){\nlet alternating=true;\nfor(let k=i-12;k<=i;k++){\nconst a=ordered[k]-ordered[k-1];\nconst b=ordered[k+1<=i?k+1:k]-ordered[k];\nif(k+1>i)break;\nif(a===0||b===0||(a>0)===(b>0)){alternating=false;break;}\n}\nif(alternating)out.push({index:i,rule:4,description:'fourteen alternating'});\n}\nif(i>=2&&oneSide(i-2,i,2,2)){\nout.push({index:i,rule:5,description:'two of three past two sigma'});\n}\nif(i>=4&&oneSide(i-4,i,1,4)){\nout.push({index:i,rule:6,description:'four of five past one sigma'});\n}\nif(i>=14){\nlet inside=true;\nfor(let k=i-14;k<=i;k++)if(Math.abs(z(k))>=1){inside=false;break;}\nif(inside)out.push({index:i,rule:7,description:'fifteen within one sigma'});\n}\nif(i>=7){\nlet outside=true;\nfor(let k=i-7;k<=i;k++)if(Math.abs(z(k))<=1){outside=false;break;}\nif(outside)out.push({index:i,rule:8,description:'eight beyond one sigma'});\n}\n}\nreturn out;\n}\nconst CONTROL_RULE_SETS=Object.freeze(['westernElectric','nelson']);\nfunction controlViolations(ordered,limits,ruleSet='westernElectric'){\nreturn String(ruleSet)==='nelson'\n?nelsonViolations(ordered,limits)\n:westernElectricViolations(ordered,limits);\n}\nfunction countOutside(values,low,high){\nlet count=0;\nfor(let i=0;i<values.length;i++){\nif(values[i]<low||values[i]>high)count++;\n}\nreturn count;\n}\nfunction histogram(sorted,q1,q3,cap=20){\nconst n=sorted.length;\nif(!n)return[];\nconst min=sorted[0];\nconst max=sorted[n-1];\nif(max===min)return[{from:min,to:max,count:n}];\nconst iqr=q3-q1;\nconst fence=1.5*iqr;\nlet lo=iqr>0?Math.max(min,q1-fence):min;\nlet hi=iqr>0?Math.min(max,q3+fence):max;\nif(!(hi>lo)){lo=min;hi=max;}\nconst width=iqr>0?(2*iqr)/Math.cbrt(n):(hi-lo)/(Math.ceil(Math.log2(n))+1);\nconst count=width>0\n?Math.min(cap,Math.max(1,Math.ceil((hi-lo)/width)))\n:1;\nconst step=(hi-lo)/count;\nconst bins=[];\nfor(let i=0;i<count;i++){\nbins.push({from:lo+i*step,to:lo+(i+1)*step,count:0});\n}\nfor(let i=0;i<n;i++){\nconst at=Math.min(count-1,Math.max(0,Math.floor((sorted[i]-lo)/step)));\nbins[at].count++;\n}\nbins[0].from=min;\nbins[count-1].to=max;\nreturn bins;\n}\nconst DEFAULT_CONFIDENCE=0.95;\nfunction level(conf){\nconst c=Number(conf);\nreturn Number.isFinite(c)&&c>0&&c<1?c:DEFAULT_CONFIDENCE;\n}\nfunction meanInterval(values,conf=DEFAULT_CONFIDENCE){\nconst n=values.length;\nif(n<2)return null;\nlet sum=0;\nfor(let i=0;i<n;i++)sum+=values[i];\nconst mean=sum/n;\nlet ss=0;\nfor(let i=0;i<n;i++){const d=values[i]-mean;ss+=d*d;}\nconst sd=Math.sqrt(ss/(n-1));\nconst c=level(conf);\nconst t=studentTQuantile(1-(1-c)/2,n-1);\nconst margin=(t*sd)/Math.sqrt(n);\nreturn{mean,lower:mean-margin,upper:mean+margin,margin,n,confidence:c};\n}\nfunction proportionInterval(successes,n,conf=DEFAULT_CONFIDENCE){\nconst k=Number(successes);\nconst total=Number(n);\nif(!(total>0)||!(k>=0)||k>total)return null;\nconst c=level(conf);\nconst z=normalQuantile(1-(1-c)/2);\nconst p=k/total;\nconst z2=z*z;\nconst denominator=1+z2/total;\nconst centre=(p+z2/(2*total))/denominator;\nconst half=(z/denominator)\n*Math.sqrt((p*(1-p))/total+z2/(4*total*total));\nreturn{\nproportion:p,\nlower:Math.max(0,centre-half),\nupper:Math.min(1,centre+half),\nn:total,\nconfidence:c,\n};\n}\nfunction slopeInterval(fit,conf=DEFAULT_CONFIDENCE){\nif(!fit||!(fit.n>2)||!Number.isFinite(fit.stdError))return null;\nconst c=level(conf);\nconst t=studentTQuantile(1-(1-c)/2,fit.n-2);\nconst margin=t*fit.stdError;\nreturn{\nslope:fit.slope,\nlower:fit.slope-margin,\nupper:fit.slope+margin,\nmargin,\nconfidence:c,\n};\n}\nfunction capabilityInterval(index,n,conf=DEFAULT_CONFIDENCE){\nconst k=Number(index);\nconst count=Number(n);\nif(!Number.isFinite(k)||!(count>1))return null;\nconst c=level(conf);\nconst z=normalQuantile(1-(1-c)/2);\nconst margin=z*Math.sqrt(1/(9*count)+(k*k)/(2*(count-1)));\nreturn{index:k,lower:k-margin,upper:k+margin,margin,n:count,confidence:c};\n}\nfunction standardizedMeanDifference(population,subsetMean){\nif(!population||!(population.sd>0))return null;\nif(!Number.isFinite(subsetMean)||!Number.isFinite(population.mean))return null;\nreturn(subsetMean-population.mean)/population.sd;\n}\nfunction normalTotalVariation(d){\nif(!Number.isFinite(d))return 0;\nreturn Math.min(1,Math.max(0,2*normalCdf(Math.abs(d)/2)-1));\n}\nfunction frequencyMap(handle,indices){\nconst map=new Map();\nconst read=valueReader(handle);\nlet total=0;\nfor(let i=0;i<indices.length;i++){\nconst raw=read(indices[i]);\nif(raw===null||raw===undefined||raw==='')continue;\nif(typeof raw==='number'&&Number.isNaN(raw))continue;\nconst key=raw instanceof Date?raw.getTime()\n:(typeof raw==='object'?String(raw):raw);\nmap.set(key,(map.get(key)||0)+1);\ntotal++;\n}\nreturn{map,total};\n}\nfunction categoricalDistance(subset,subsetTotal,population,populationTotal){\nif(!(subsetTotal>0)||!(populationTotal>0))return null;\nlet sum=0;\nconst keys=new Set(subset.keys());\nfor(const k of population.keys())keys.add(k);\nfor(const k of keys){\nconst a=(subset.get(k)||0)/subsetTotal;\nconst b=(population.get(k)||0)/populationTotal;\nsum+=Math.abs(a-b);\n}\nreturn sum/2;\n}\nconst SUBSET_RELIABILITY_FLOOR=10;\nfunction compareColumn(handle,subsetIndices,populationStats){\nconst numeric=populationStats&&populationStats.numeric;\nif(numeric){\nconst values=numbers(handle,subsetIndices);\nconst{n,mean}=moments(values);\nconst d=n>0\n?standardizedMeanDifference(\n{mean:populationStats.mean,sd:populationStats.sd},mean,\n)\n:null;\nreturn{\nmeasure:'standardizedMeanDifference',\nmagnitude:d,\ndistance:d===null?0:normalTotalVariation(d),\ndirection:d===null?0:Math.sign(d),\nsubsetN:n,\npopulationN:populationStats.n||0,\nreliable:n>=SUBSET_RELIABILITY_FLOOR,\n};\n}\nconst{map,total}=frequencyMap(handle,subsetIndices);\nconst tvd=categoricalDistance(map,total,populationStats.map,populationStats.total);\nreturn{\nmeasure:'categoricalTotalVariation',\nmagnitude:tvd,\ndistance:tvd===null?0:tvd,\ndirection:0,\nsubsetN:total,\npopulationN:populationStats.total||0,\nreliable:total>=SUBSET_RELIABILITY_FLOOR,\n};\n}\nfunction isNumericColumn(handle,indices){\nif(handle&&(handle.kind==='float64'||handle.kind==='int32'))return true;\nconst read=valueReader(handle);\nlet seen=0;\nlet numeric=0;\nfor(let i=0;i<indices.length&&seen<200;i++){\nconst raw=read(indices[i]);\nif(raw===null||raw===undefined||raw==='')continue;\nif(raw instanceof Date)return false;\nseen++;\nconst v=typeof raw==='number'?raw:Number(raw);\nif(Number.isFinite(v))numeric++;\n}\nif(seen===0)return false;\nreturn numeric/seen>=0.9;\n}\nfunction populationRead(handle,populationIndices){\nif(isNumericColumn(handle,populationIndices)){\nconst values=numbers(handle,populationIndices);\nconst{n,mean,m2}=moments(values);\nreturn{numeric:true,mean,sd:n>0?Math.sqrt(m2/n):0,n};\n}\nconst{map,total}=frequencyMap(handle,populationIndices);\nreturn{numeric:false,map,total};\n}\n});\n__def(\"packages/core/src/compute/total.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"TOTAL_FNS\",{enumerable:true,get:function(){return TOTAL_FNS;}});\nObject.defineProperty(__exports,\"TOTAL_LABELS\",{enumerable:true,get:function(){return TOTAL_LABELS;}});\nObject.defineProperty(__exports,\"totalLabel\",{enumerable:true,get:function(){return totalLabel;}});\nObject.defineProperty(__exports,\"aggregatesFor\",{enumerable:true,get:function(){return aggregatesFor;}});\nObject.defineProperty(__exports,\"aggregateAllowed\",{enumerable:true,get:function(){return aggregateAllowed;}});\nObject.defineProperty(__exports,\"collectValues\",{enumerable:true,get:function(){return collectValues;}});\nObject.defineProperty(__exports,\"total\",{enumerable:true,get:function(){return total;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst isFunction=__m0[\"isFunction\"];\nconst warnOnce=__m0[\"warnOnce\"];\nconst __m1=__req(\"packages/core/src/compute/handle.js\");\nconst presenceReader=__m1[\"presenceReader\"];\nconst valueComparator=__m1[\"valueComparator\"];\nconst valueReader=__m1[\"valueReader\"];\nconst __m2=__req(\"packages/core/src/compute/statistics.js\");\nconst STAT_FNS=__m2[\"STAT_FNS\"];\nconst STAT_LABELS=__m2[\"STAT_LABELS\"];\nfunction isNumericBacking(handle){\nreturn!!handle&&(handle.kind==='float64'||handle.kind==='int32');\n}\nfunction sum(handle,indices){\nconst n=indices.length;\nlet acc=0;\nif(isNumericBacking(handle)){\nconst values=handle.values;\nconst present=presenceReader(handle);\nif(!present){\nfor(let i=0;i<n;i++){\nconst v=values[indices[i]];\nif(!Number.isNaN(v))acc+=v;\n}\nreturn acc;\n}\nfor(let i=0;i<n;i++){\nconst row=indices[i];\nif(present(row)===1){\nconst v=values[row];\nif(!Number.isNaN(v))acc+=v;\n}\n}\nreturn acc;\n}\nconst read=valueReader(handle);\nfor(let i=0;i<n;i++){\nconst v=numberOf(read(indices[i]));\nif(v!==null)acc+=v;\n}\nreturn acc;\n}\nsum.kernel=true;\nfunction countValues(handle,indices){\nconst n=indices.length;\nlet count=0;\nif(isNumericBacking(handle)){\nconst values=handle.values;\nconst present=presenceReader(handle);\nif(!present){\nfor(let i=0;i<n;i++)if(!Number.isNaN(values[indices[i]]))count++;\nreturn count;\n}\nfor(let i=0;i<n;i++){\nconst row=indices[i];\nif(present(row)===1&&!Number.isNaN(values[row]))count++;\n}\nreturn count;\n}\nconst read=valueReader(handle);\nfor(let i=0;i<n;i++){\nconst v=read(indices[i]);\nif(v!==null&&v!==undefined&&!(typeof v==='number'&&Number.isNaN(v)))count++;\n}\nreturn count;\n}\ncountValues.kernel=true;\nfunction count(handle,indices){\nreturn indices.length;\n}\ncount.kernel=true;\nfunction avg(handle,indices){\nconst values=countValues(handle,indices);\nif(values===0)return null;\nreturn sum(handle,indices)/values;\n}\navg.kernel=true;\nfunction extreme(handle,indices,direction,locale){\nconst n=indices.length;\nif(isNumericBacking(handle)){\nconst values=handle.values;\nconst present=presenceReader(handle);\nlet best=null;\nif(!present){\nfor(let i=0;i<n;i++){\nconst v=values[indices[i]];\nif(Number.isNaN(v))continue;\nif(best===null||(direction<0?v<best:v>best))best=v;\n}\nreturn best;\n}\nfor(let i=0;i<n;i++){\nconst row=indices[i];\nif(present(row)===0)continue;\nconst v=values[row];\nif(Number.isNaN(v))continue;\nif(best===null||(direction<0?v<best:v>best))best=v;\n}\nreturn best;\n}\nconst read=valueReader(handle);\nconst cmp=valueComparator(locale);\nlet best=null;\nfor(let i=0;i<n;i++){\nconst v=read(indices[i]);\nif(v===null||v===undefined||(typeof v==='number'&&Number.isNaN(v)))continue;\nif(best===null||(direction<0?cmp(v,best)<0:cmp(v,best)>0))best=v;\n}\nreturn best;\n}\nfunction min(handle,indices,ctx){\nreturn extreme(handle,indices,-1,ctx&&ctx.locale);\n}\nmin.kernel=true;\nfunction max(handle,indices,ctx){\nreturn extreme(handle,indices,1,ctx&&ctx.locale);\n}\nmax.kernel=true;\nfunction first(handle,indices){\nif(indices.length===0)return null;\nreturn valueReader(handle)(indices[0]);\n}\nfirst.kernel=true;\nfunction last(handle,indices){\nif(indices.length===0)return null;\nreturn valueReader(handle)(indices[indices.length-1]);\n}\nlast.kernel=true;\nfunction numberOf(v){\nif(typeof v==='number')return Number.isNaN(v)?null:v;\nif(v===null||v===undefined||v===''||typeof v==='boolean')return null;\nif(v instanceof Date)return v.getTime();\nconst n=Number(v);\nreturn Number.isNaN(n)?null:n;\n}\nconst TOTAL_FNS={\nsum,min,max,avg,count,first,last,countValues,\n...STAT_FNS,\n};\nconst TOTAL_LABELS=Object.freeze({\n...STAT_LABELS,\nsum:'Sum',\navg:'Average',\nmin:'Min',\nmax:'Max',\ncount:'Count',\ncountValues:'Count of values',\nfirst:'First',\nlast:'Last',\n});\nfunction totalLabel(fn){\nif(!fn)return'';\nif(typeof fn==='string')return TOTAL_LABELS[fn]||fn;\nreturn'Total';\n}\nconst CHOOSER_ORDER=Object.freeze([\n'sum','avg','min','max','count','countValues','first','last',\n]);\nfunction aggregatesFor(column){\nconst supported=column&&column.dataType\n&&column.dataType.totals&&column.dataType.totals.supported;\nif(Array.isArray(supported))return supported.slice();\nconst named=CHOOSER_ORDER.filter((name)=>name in TOTAL_FNS);\nfor(const name of Object.keys(TOTAL_FNS))if(!named.includes(name))named.push(name);\nreturn named;\n}\nfunction aggregateAllowed(column,name){\nif(typeof name!=='string')return true;\nreturn aggregatesFor(column).includes(name);\n}\nfunction collectValues(handle,indices){\nconst read=valueReader(handle);\nconst out=[];\nfor(let i=0;i<indices.length;i++){\nconst v=read(indices[i]);\nif(v===null||v===undefined)continue;\nout.push(v);\n}\nreturn out;\n}\nfunction total(handle,indices,fn,ctx){\nconst list=indices||[];\nif(typeof fn==='string'){\nconst kernel=TOTAL_FNS[fn];\nif(!kernel){\nwarnOnce(`total:${fn}`,`unknown total function \"${fn}\"; register it in config.totalFns`);\nreturn null;\n}\nreturn kernel(handle,list,ctx);\n}\nif(isFunction(fn)){\nif(fn.kernel===true)return fn(handle,list,ctx);\nreturn fn(collectValues(handle,list),ctx||{});\n}\nreturn null;\n}\n});\n__def(\"packages/core/src/compute/pivot.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"KEY_DELIMITER\",{enumerable:true,get:function(){return KEY_DELIMITER;}});\nObject.defineProperty(__exports,\"DEFAULT_PATH_SEPARATOR\",{enumerable:true,get:function(){return DEFAULT_PATH_SEPARATOR;}});\nObject.defineProperty(__exports,\"DEFAULT_MAX_COLUMNS\",{enumerable:true,get:function(){return DEFAULT_MAX_COLUMNS;}});\nObject.defineProperty(__exports,\"pivotKey\",{enumerable:true,get:function(){return pivotKey;}});\nObject.defineProperty(__exports,\"joinPath\",{enumerable:true,get:function(){return joinPath;}});\nObject.defineProperty(__exports,\"resolvePivotKeys\",{enumerable:true,get:function(){return resolvePivotKeys;}});\nObject.defineProperty(__exports,\"pivot\",{enumerable:true,get:function(){return pivot;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst warnOnce=__m0[\"warnOnce\"];\nconst __m1=__req(\"packages/core/src/compute/handle.js\");\nconst valueComparator=__m1[\"valueComparator\"];\nconst __m2=__req(\"packages/core/src/compute/group.js\");\nconst packKeys=__m2[\"packKeys\"];\nconst __m3=__req(\"packages/core/src/compute/total.js\");\nconst total=__m3[\"total\"];\nconst KEY_DELIMITER='|';\nconst DEFAULT_PATH_SEPARATOR='/';\nconst DEFAULT_MAX_COLUMNS=2000;\nfunction pivotKey(groupPath,pivotPath,colId){\nreturn`${groupPath}${KEY_DELIMITER}${pivotPath}${KEY_DELIMITER}${colId}`;\n}\nfunction joinPath(parts,separator){\nlet out='';\nfor(let i=0;i<parts.length;i++){\nconst v=parts[i];\nout+=(i===0?'':separator)+(v===null||v===undefined?'':String(v));\n}\nreturn out;\n}\nfunction resolvePivotKeys(handles,order,opts={}){\nconst separator=opts.separator||DEFAULT_PATH_SEPARATOR;\nconst n=order.length;\nconst{keyOf,readers}=packKeys(handles,order,0);\nconst seen=new Map();\nconst tuples=[];\nconst rawKeys=[];\nfor(let i=0;i<n;i++){\nconst row=order[i];\nconst key=keyOf(row);\nif(seen.has(key))continue;\nseen.set(key,tuples.length);\nrawKeys.push(key);\nconst tuple=new Array(readers.length);\nfor(let j=0;j<readers.length;j++)tuple[j]=readers[j](row);\ntuples.push(tuple);\n}\nconst cmp=valueComparator(opts.locale);\nconst rank=tuples.map((_,i)=>i);\nrank.sort((a,b)=>{\nconst ta=tuples[a];\nconst tb=tuples[b];\nfor(let j=0;j<ta.length;j++){\nconst c=compareNullable(ta[j],tb[j],cmp);\nif(c!==0)return c;\n}\nreturn a-b;\n});\nconst keys=new Array(rank.length);\nconst paths=new Array(rank.length);\nconst idByKey=new Map();\nfor(let position=0;position<rank.length;position++){\nconst from=rank[position];\nkeys[position]=tuples[from];\npaths[position]=joinPath(tuples[from],separator);\nidByKey.set(rawKeys[from],position);\n}\nconst idOf=(row)=>{\nconst id=idByKey.get(keyOf(row));\nreturn id===undefined?-1:id;\n};\nreturn{keys,paths,idOf};\n}\nfunction compareNullable(a,b,cmp){\nconst na=a===null||a===undefined;\nconst nb=b===null||b===undefined;\nif(na||nb)return na&&nb?0:na?1:-1;\nreturn cmp(a,b);\n}\nfunction resolveValueColumns(opts){\nconst declared=opts.values||opts.totals||[];\nif(declared.length&&typeof declared[0]==='object'&&declared[0]!==null){\nreturn declared.filter((entry)=>entry&&entry.handle);\n}\nconst resolve=typeof opts.handle==='function'?opts.handle:null;\nif(!resolve){\nif(declared.length){\nwarnOnce('pivot:handles',\n'pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle.');\n}\nreturn[];\n}\nconst totalOf=typeof opts.totalOf==='function'?opts.totalOf:null;\nconst out=[];\nfor(const colId of declared){\nconst handle=resolve(colId);\nif(!handle)continue;\nout.push({colId,handle,fn:totalOf?totalOf(colId):'sum'});\n}\nreturn out;\n}\nfunction normaliseArgs(a,b,c){\nif(Array.isArray(a)){\nconst opts=c||{};\nreturn{...opts,pivotHandles:a,order:b||null,groups:opts.groups||null};\n}\nreturn a||{};\n}\nfunction pivot(input,orderArg,optsArg){\nconst opts=normaliseArgs(input,orderArg,optsArg);\nconst separator=opts.separator||DEFAULT_PATH_SEPARATOR;\nconst valueColumns=resolveValueColumns(opts);\nconst maxColumns=opts.maxColumns===undefined?DEFAULT_MAX_COLUMNS:opts.maxColumns;\nconst groups=opts.groups&&opts.groups.buckets?opts.groups:null;\nconst buckets=groups?groups.buckets:[opts.order||new Uint32Array(0)];\nconst groupPaths=opts.groupPaths\n||(groups?groups.keys.map((tuple)=>joinPath(tuple,separator)):['']);\nconst scope=concatIndices(buckets);\nconst{keys,paths,idOf}=resolvePivotKeys(opts.pivotHandles||[],scope,opts);\nconst columns=paths.length*Math.max(1,valueColumns.length);\nconst fields=derivedFields(paths,valueColumns,separator);\nif(maxColumns&&columns>maxColumns){\nconst empty=new Map();\nreturn{\nkeys,\npaths,\nfields,\ngroupPaths,\ncolumns,\nvalues:empty,\ncells:empty,\nerror:{\ncode:'pivot-max-columns',\nmessage:`[lattice] pivot would generate ${columns} columns, above pivot.maxColumns of ${maxColumns}. Narrow the pivot columns or raise the limit.`,\ncolumns,\nmaxColumns,\n},\n};\n}\nconst cells=new Map();\nconst keyCount=paths.length;\nfor(let g=0;g<buckets.length;g++){\nconst bucket=buckets[g];\nconst groupPath=groupPaths[g]===undefined?'':groupPaths[g];\nconst n=bucket.length;\nif(n===0)continue;\nconst ids=new Int32Array(n);\nconst counts=new Uint32Array(keyCount+1);\nfor(let i=0;i<n;i++){\nconst id=idOf(bucket[i]);\nids[i]=id;\nif(id>=0)counts[id+1]++;\n}\nfor(let k=0;k<keyCount;k++)counts[k+1]+=counts[k];\nconst scattered=new Uint32Array(n);\nconst cursor=counts.slice(0,keyCount);\nfor(let i=0;i<n;i++){\nconst id=ids[i];\nif(id>=0)scattered[cursor[id]++]=bucket[i];\n}\nfor(let k=0;k<keyCount;k++){\nconst from=counts[k];\nconst to=counts[k+1];\nif(to===from)continue;\nconst slice=scattered.subarray(from,to);\nfor(let c=0;c<valueColumns.length;c++){\nconst column=valueColumns[c];\nconst result=total(column.handle,slice,column.fn,opts.totalContext||{locale:opts.locale});\ncells.set(pivotKey(groupPath,paths[k],column.colId),result);\n}\n}\n}\nreturn{keys,paths,fields,groupPaths,columns,values:cells,cells,error:null};\n}\nfunction derivedFields(paths,valueColumns,separator){\nif(valueColumns.length===0)return paths.slice();\nconst out=[];\nfor(const path of paths){\nfor(const column of valueColumns)out.push(`${path}${separator}${column.colId}`);\n}\nreturn out;\n}\nfunction concatIndices(buckets){\nif(buckets.length===1)return buckets[0]||new Uint32Array(0);\nlet n=0;\nfor(const b of buckets)n+=b?b.length:0;\nconst out=new Uint32Array(n);\nlet at=0;\nfor(const b of buckets){\nif(!b||b.length===0)continue;\nout.set(b,at);\nat+=b.length;\n}\nreturn out;\n}\n});\n__def(\"packages/core/src/compute/pivotmatrix.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"GRAND_PATH\",{enumerable:true,get:function(){return GRAND_PATH;}});\nObject.defineProperty(__exports,\"resolveAxis\",{enumerable:true,get:function(){return resolveAxis;}});\nObject.defineProperty(__exports,\"pivotMatrix\",{enumerable:true,get:function(){return pivotMatrix;}});\nObject.defineProperty(__exports,\"cellKey\",{enumerable:true,get:function(){return cellKey;}});\nObject.defineProperty(__exports,\"marginKey\",{enumerable:true,get:function(){return marginKey;}});\nconst __m0=__req(\"packages/core/src/compute/handle.js\");\nconst valueComparator=__m0[\"valueComparator\"];\nconst __m1=__req(\"packages/core/src/compute/total.js\");\nconst total=__m1[\"total\"];\nconst __m2=__req(\"packages/core/src/compute/group.js\");\nconst packKeys=__m2[\"packKeys\"];\nconst __m3=__req(\"packages/core/src/compute/pivot.js\");\nconst joinPath=__m3[\"joinPath\"];\nconst DEFAULT_PATH_SEPARATOR=__m3[\"DEFAULT_PATH_SEPARATOR\"];\nconst DEFAULT_MAX_COLUMNS=__m3[\"DEFAULT_MAX_COLUMNS\"];\nconst GRAND_PATH='';\nfunction resolveAxis(handles,leaves,opts={}){\nconst separator=opts.separator||DEFAULT_PATH_SEPARATOR;\nconst list=handles||[];\nconst order=leaves instanceof Uint32Array?leaves:Uint32Array.from(leaves||[]);\nconst n=order.length;\nif(list.length===0){\nreturn{tuples:[[]],paths:[GRAND_PATH],buckets:[order]};\n}\nconst{keyOf,readers}=packKeys(list,order,0);\nconst seen=new Map();\nconst tuples=[];\nconst rawKeys=[];\nconst rowsByKey=[];\nfor(let i=0;i<n;i++){\nconst row=order[i];\nconst key=keyOf(row);\nlet at=seen.get(key);\nif(at===undefined){\nat=tuples.length;\nseen.set(key,at);\nrawKeys.push(key);\nconst tuple=new Array(readers.length);\nfor(let j=0;j<readers.length;j++)tuple[j]=readers[j](row);\ntuples.push(tuple);\nrowsByKey.push([]);\n}\nrowsByKey[at].push(row);\n}\nconst cmp=valueComparator(opts.locale);\nconst rank=tuples.map((_,i)=>i);\nrank.sort((a,b)=>{\nconst ta=tuples[a];\nconst tb=tuples[b];\nfor(let j=0;j<ta.length;j++){\nconst c=compareNullable(ta[j],tb[j],cmp);\nif(c!==0)return c;\n}\nreturn a-b;\n});\nconst outTuples=new Array(rank.length);\nconst paths=new Array(rank.length);\nconst buckets=new Array(rank.length);\nfor(let position=0;position<rank.length;position++){\nconst from=rank[position];\noutTuples[position]=tuples[from];\npaths[position]=joinPath(tuples[from],separator);\nbuckets[position]=Uint32Array.from(rowsByKey[from]);\n}\nreturn{tuples:outTuples,paths,buckets};\n}\nfunction compareNullable(a,b,cmp){\nconst na=a===null||a===undefined;\nconst nb=b===null||b===undefined;\nif(na||nb)return na&&nb?0:na?1:-1;\nreturn cmp(a,b);\n}\nfunction intersect(a,b,bSet){\nconst out=[];\nfor(let i=0;i<a.length;i++){\nif(bSet.has(a[i]))out.push(a[i]);\n}\nreturn Uint32Array.from(out);\n}\nfunction reduceCell(handle,leaves,fn,ctx){\nconst value=leaves.length?total(handle,leaves,fn,ctx):null;\nreturn{value,leaves,count:leaves.length};\n}\nfunction pivotMatrix(input){\nconst opts=(input&&input.opts)||{};\nconst separator=opts.separator||DEFAULT_PATH_SEPARATOR;\nconst ctx=opts.totalContext||{locale:opts.locale};\nconst measures=(input.measures||[]).filter((m)=>m&&m.handle);\nconst leaves=input.leaves instanceof Uint32Array\n?input.leaves\n:Uint32Array.from(input.leaves||[]);\nconst rowAxis=resolveAxis(input.rowHandles||[],leaves,{...opts,separator});\nconst columnAxis=resolveAxis(input.columnHandles||[],leaves,{...opts,separator});\nconst maxColumns=opts.maxColumns===undefined?DEFAULT_MAX_COLUMNS:opts.maxColumns;\nconst columns=columnAxis.paths.length*Math.max(1,measures.length);\nconst empty=new Map();\nif(maxColumns&&columns>maxColumns){\nreturn{\nrowAxis,\ncolumnAxis,\nmeasures:measures.map((m)=>({colId:m.colId,fn:m.fn})),\nbody:empty,\nrowMargin:empty,\ncolumnMargin:empty,\ngrand:empty,\ncolumns,\nerror:{\ncode:'pivot-max-columns',\nmessage:`[lattice] pivot would generate ${columns} columns, above pivot.maxColumns of `\n+`${maxColumns}. Narrow the pivot columns or raise the limit.`,\ncolumns,\nmaxColumns,\n},\n};\n}\nconst body=new Map();\nconst rowMargin=new Map();\nconst columnMargin=new Map();\nconst grand=new Map();\nconst columnSets=columnAxis.buckets.map((b)=>new Set(b));\nfor(let c=0;c<columnAxis.paths.length;c++){\nconst columnLeaves=columnAxis.buckets[c];\nconst columnPath=columnAxis.paths[c];\nfor(const m of measures){\ncolumnMargin.set(marginKey(columnPath,m.colId),reduceCell(m.handle,columnLeaves,m.fn,ctx));\n}\n}\nfor(let r=0;r<rowAxis.paths.length;r++){\nconst rowLeaves=rowAxis.buckets[r];\nconst rowPath=rowAxis.paths[r];\nfor(const m of measures){\nrowMargin.set(marginKey(rowPath,m.colId),reduceCell(m.handle,rowLeaves,m.fn,ctx));\n}\nfor(let c=0;c<columnAxis.paths.length;c++){\nconst cellLeaves=intersect(rowLeaves,columnAxis.buckets[c],columnSets[c]);\nif(cellLeaves.length===0)continue;\nconst columnPath=columnAxis.paths[c];\nfor(const m of measures){\nbody.set(cellKey(rowPath,columnPath,m.colId),reduceCell(m.handle,cellLeaves,m.fn,ctx));\n}\n}\n}\nfor(const m of measures){\ngrand.set(m.colId,reduceCell(m.handle,leaves,m.fn,ctx));\n}\nreturn{\nrowAxis,\ncolumnAxis,\nmeasures:measures.map((m)=>({colId:m.colId,fn:m.fn})),\nbody,\nrowMargin,\ncolumnMargin,\ngrand,\ncolumns,\nerror:null,\n};\n}\nfunction cellKey(rowPath,columnPath,colId){\nreturn`${rowPath}\\u0000${columnPath}\\u0000${colId}`;\n}\nfunction marginKey(path,colId){\nreturn`${path}\\u0000${colId}`;\n}\n});\n__def(\"packages/core/src/compute/reference.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"referenceValue\",{enumerable:true,get:function(){return referenceValue;}});\nObject.defineProperty(__exports,\"referenceSort\",{enumerable:true,get:function(){return referenceSort;}});\nObject.defineProperty(__exports,\"referenceFilter\",{enumerable:true,get:function(){return referenceFilter;}});\nObject.defineProperty(__exports,\"referencePasses\",{enumerable:true,get:function(){return referencePasses;}});\nObject.defineProperty(__exports,\"referenceGroup\",{enumerable:true,get:function(){return referenceGroup;}});\nObject.defineProperty(__exports,\"referenceTotal\",{enumerable:true,get:function(){return referenceTotal;}});\nconst __m0=__req(\"packages/core/src/internal/util.js\");\nconst getPath=__m0[\"getPath\"];\nconst __m1=__req(\"packages/core/src/compute/handle.js\");\nconst isMissing=__m1[\"isMissing\"];\nconst valueComparator=__m1[\"valueComparator\"];\nconst __m2=__req(\"packages/core/src/compute/filter.js\");\nconst testValue=__m2[\"testValue\"];\nconst KEY_SEPARATOR=String.fromCharCode(0x1f);\nconst NULL_MARKER=String.fromCharCode(0x00);\nfunction referenceValue(row,col){\nconst v=col.includes('.')?getPath(row,col):(row==null?undefined:row[col]);\nreturn v===undefined?null:v;\n}\nfunction referenceSort(rows,entries,opts={}){\nconst list=entries||[];\nlet order=rows.map((_,i)=>i);\nif(list.length===0)return order;\nfor(let e=list.length-1;e>=0;e--){\norder=referenceSortOne(rows,order,list[e],opts);\n}\nreturn order;\n}\nfunction referenceSortOne(rows,order,entry,opts){\nconst locale=entry.locale!==undefined?entry.locale:opts.locale;\nconst base=valueComparator(locale);\nconst descending=entry.descending!==undefined?!!entry.descending:entry.dir==='desc';\nconst present=[];\nconst absent=[];\nfor(const i of order){\nconst v=referenceValue(rows[i],entry.col);\nif(isMissing(v))absent.push(i);else present.push(i);\n}\nconst position=new Map();\nfor(let p=0;p<present.length;p++)position.set(present[p],p);\nconst compare=(a,b)=>{\nconst va=referenceValue(rows[a],entry.col);\nconst vb=referenceValue(rows[b],entry.col);\nlet c;\nif(typeof entry.compare==='function'){\nc=entry.compare(va,vb,rows[a],rows[b],descending);\nif(descending)c=-c;\n}else{\nc=descending?base(vb,va):base(va,vb);\n}\nreturn c!==0?c:position.get(a)-position.get(b);\n};\npresent.sort(compare);\nreturn entry.nullsFirst?absent.concat(present):present.concat(absent);\n}\nfunction referenceFilter(rows,filters,opts={}){\nconst out=[];\nfor(let i=0;i<rows.length;i++){\nif(referencePasses(rows[i],filters,opts,i))out.push(i);\n}\nreturn out;\n}\nfunction referencePasses(row,node,opts,index){\nif(!node)return true;\nif(Array.isArray(node.conditions)){\nconst children=node.conditions.filter((c)=>c!=null);\nif(children.length===0)return true;\nif(node.op==='or')return children.some((c)=>referencePasses(row,c,opts,index));\nconst all=children.every((c)=>referencePasses(row,c,opts,index));\nreturn node.op==='not'?!all:all;\n}\nif(node.col===undefined&&typeof opts.custom==='function')return!!opts.custom(node,row,index);\nreturn testValue(referenceValue(row,node.col),node,opts.locale);\n}\nfunction referenceGroup(rows,cols,order,project){\nconst source=order||rows.map((_,i)=>i);\nconst seen=new Map();\nconst keys=[];\nconst buckets=[];\nfor(const i of source){\nconst tuple=cols.map((col,j)=>{\nconst v=referenceValue(rows[i],col);\nreturn(project&&project[j])?project[j](v):v;\n});\nconst key=tuple\n.map((v)=>(v===null||v===undefined?NULL_MARKER:String(v)))\n.join(KEY_SEPARATOR);\nlet at=seen.get(key);\nif(at===undefined){\nat=keys.length;\nseen.set(key,at);\nkeys.push(tuple);\nbuckets.push([]);\n}\nbuckets[at].push(i);\n}\nreturn{keys,buckets};\n}\nfunction referenceTotal(values,fn,opts={}){\nconst cmp=valueComparator(opts.locale);\nconst live=values.filter((v)=>!isMissing(v));\nconst numbers=live.map(toNumberOrNull).filter((v)=>v!==null);\nswitch(fn){\ncase'count':return values.length;\ncase'countValues':return live.length;\ncase'sum':return numbers.reduce((a,b)=>a+b,0);\ncase'avg':return live.length===0?null:numbers.reduce((a,b)=>a+b,0)/live.length;\ncase'min':return live.length===0?null:live.reduce((a,b)=>(cmp(b,a)<0?b:a));\ncase'max':return live.length===0?null:live.reduce((a,b)=>(cmp(b,a)>0?b:a));\ncase'first':return values.length===0?null:normaliseNull(values[0]);\ncase'last':return values.length===0?null:normaliseNull(values[values.length-1]);\ndefault:return null;\n}\n}\nfunction toNumberOrNull(v){\nif(typeof v==='number')return Number.isNaN(v)?null:v;\nif(v===null||v===undefined||v===''||typeof v==='boolean')return null;\nif(v instanceof Date)return v.getTime();\nconst n=Number(v);\nreturn Number.isNaN(n)?null:n;\n}\nfunction normaliseNull(v){\nreturn v===undefined?null:v;\n}\n});\n__def(\"packages/core/src/compute/windowed.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"Window\",{enumerable:true,get:function(){return Window;}});\nObject.defineProperty(__exports,\"WINDOW_KINDS\",{enumerable:true,get:function(){return WINDOW_KINDS;}});\nObject.defineProperty(__exports,\"openWindow\",{enumerable:true,get:function(){return openWindow;}});\nObject.defineProperty(__exports,\"default\",{enumerable:true,get:function(){return __default;}});\nconst __m0=__req(\"packages/core/src/compute/sketch.js\");\nconst Welford=__m0[\"Welford\"];\nclass Window{\n#kind;\n#span;\n#ticks=[];\n#now;\n#opened;\nconstructor(kind,span=0,now=Date.now){\nif(kind!=='count'&&kind!=='time'&&kind!=='session'){\nthrow new RangeError(`unknown window kind: ${kind}`);\n}\nif((kind==='count'||kind==='time')&&!(span>0)){\nthrow new RangeError(`a ${kind} window needs a positive span`);\n}\nthis.#kind=kind;\nthis.#span=Math.floor(span);\nthis.#now=now;\nthis.#opened=now();\n}\nget size(){return this.#ticks.length;}\npush(v,t=this.#now()){\nif(!Number.isFinite(v))return;\nthis.#ticks.push({t,v});\nthis.#evict(t);\n}\n#evict(nowT){\nif(this.#kind==='count'){\nwhile(this.#ticks.length>this.#span)this.#ticks.shift();\n}else if(this.#kind==='time'){\nconst cutoff=nowT-this.#span;\nwhile(this.#ticks.length&&this.#ticks[0].t<cutoff)this.#ticks.shift();\n}\n}\nspec(){\nconst span=this.#kind==='session'?this.#now()-this.#opened:this.#span;\nreturn{kind:this.#kind,span,size:this.#ticks.length};\n}\nvalues(){return this.#ticks.map((tk)=>tk.v);}\naggregate(){\nconst spec=this.spec();\nif(!this.#ticks.length){\nreturn{over:spec,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};\n}\nconst w=new Welford();\nlet sum=0;\nlet min=Infinity;\nlet max=-Infinity;\nfor(const{v}of this.#ticks){\nsum+=v;\nif(v<min)min=v;\nif(v>max)max=v;\nw.add(v);\n}\nreturn{\nover:spec,\ncount:this.#ticks.length,\nsum,\nmean:w.mean(),\nmin,\nmax,\nvariance:w.variance(),\nstddev:w.stddev(),\n};\n}\nreduce(fn){\nconst agg=this.aggregate();\nconst map={\nsum:agg.sum,avg:agg.mean,mean:agg.mean,min:agg.min,max:agg.max,\ncount:agg.count,variance:agg.variance,stddev:agg.stddev,\n};\nif(!(fn in map))throw new RangeError(`unknown windowed aggregate: ${fn}`);\nreturn{value:map[fn],over:agg.over};\n}\n}\nconst WINDOW_KINDS=Object.freeze(['count','time','session']);\nfunction openWindow(opts,now=Date.now){\nconst span=opts.kind==='time'&&opts.minutes!=null\n?opts.minutes*60_000\n:opts.span??0;\nreturn new Window(opts.kind,span,now);\n}\nconst __default={Window,WINDOW_KINDS,openWindow};\n});\n__def(\"packages/core/src/compute/anomaly.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"MAD_SCALE\",{enumerable:true,get:function(){return MAD_SCALE;}});\nObject.defineProperty(__exports,\"DEFAULT_MODIFIED_Z_THRESHOLD\",{enumerable:true,get:function(){return DEFAULT_MODIFIED_Z_THRESHOLD;}});\nObject.defineProperty(__exports,\"DEFAULT_IQR_K\",{enumerable:true,get:function(){return DEFAULT_IQR_K;}});\nObject.defineProperty(__exports,\"DEFAULT_CHI_SQUARE_P\",{enumerable:true,get:function(){return DEFAULT_CHI_SQUARE_P;}});\nObject.defineProperty(__exports,\"ANOMALY_METHODS\",{enumerable:true,get:function(){return ANOMALY_METHODS;}});\nObject.defineProperty(__exports,\"robustSpread\",{enumerable:true,get:function(){return robustSpread;}});\nObject.defineProperty(__exports,\"modifiedZScores\",{enumerable:true,get:function(){return modifiedZScores;}});\nObject.defineProperty(__exports,\"iqrFences\",{enumerable:true,get:function(){return iqrFences;}});\nObject.defineProperty(__exports,\"chiSquareCdf\",{enumerable:true,get:function(){return chiSquareCdf;}});\nObject.defineProperty(__exports,\"chiSquareQuantile\",{enumerable:true,get:function(){return chiSquareQuantile;}});\nObject.defineProperty(__exports,\"mahalanobis\",{enumerable:true,get:function(){return mahalanobis;}});\nconst __m0=__req(\"packages/core/src/compute/statistics.js\");\nconst quantileSorted=__m0[\"quantileSorted\"];\nconst __m1=__req(\"packages/core/src/compute/special.js\");\nconst logGamma=__m1[\"logGamma\"];\nconst MAD_SCALE=0.6745;\nconst DEFAULT_MODIFIED_Z_THRESHOLD=3.5;\nconst DEFAULT_IQR_K=1.5;\nconst DEFAULT_CHI_SQUARE_P=0.975;\nconst ANOMALY_METHODS=Object.freeze(['modifiedZScore','iqr','mahalanobis']);\nfunction robustSpread(values){\nconst n=values.length;\nif(!n)return null;\nconst sorted=Array.from(values,Number).sort((a,b)=>a-b);\nconst median=quantileSorted(sorted,0.5);\nconst deviations=sorted.map((v)=>Math.abs(v-median)).sort((a,b)=>a-b);\nconst mad=quantileSorted(deviations,0.5);\nreturn{median,mad};\n}\nfunction modifiedZScores(values,opts={}){\nconst threshold=Number.isFinite(opts.threshold)?opts.threshold:DEFAULT_MODIFIED_Z_THRESHOLD;\nconst n=values.length;\nconst scores=new Array(n).fill(null);\nconst flags=new Array(n).fill(false);\nconst finite=[];\nfor(let i=0;i<n;i++){\nconst v=Number(values[i]);\nif(Number.isFinite(v))finite.push(v);\n}\nif(!finite.length)return{median:null,mad:null,threshold,scores,flags,flagged:0};\nconst spread=robustSpread(finite);\nif(spread.mad===0)return{median:spread.median,mad:0,threshold,scores,flags,flagged:0};\nlet flagged=0;\nfor(let i=0;i<n;i++){\nconst v=Number(values[i]);\nif(!Number.isFinite(v))continue;\nconst score=(MAD_SCALE*(v-spread.median))/spread.mad;\nscores[i]=score;\nif(Math.abs(score)>threshold){flags[i]=true;flagged++;}\n}\nreturn{median:spread.median,mad:spread.mad,threshold,scores,flags,flagged};\n}\nfunction iqrFences(values,opts={}){\nconst k=Number.isFinite(opts.k)?opts.k:DEFAULT_IQR_K;\nconst finite=[];\nfor(let i=0;i<values.length;i++){\nconst v=Number(values[i]);\nif(Number.isFinite(v))finite.push(v);\n}\nif(!finite.length)return null;\nconst sorted=finite.sort((a,b)=>a-b);\nconst q1=quantileSorted(sorted,0.25);\nconst q3=quantileSorted(sorted,0.75);\nconst iqr=q3-q1;\nreturn{q1,q3,iqr,lower:q1-k*iqr,upper:q3+k*iqr,k};\n}\nfunction regularizedGammaP(a,x){\nif(x<=0)return 0;\nconst gln=logGamma(a);\nif(x<a+1){\nlet ap=a;\nlet sum=1/a;\nlet term=sum;\nfor(let i=0;i<1000;i++){\nap+=1;\nterm*=x/ap;\nsum+=term;\nif(Math.abs(term)<Math.abs(sum)*1e-15)break;\n}\nreturn sum*Math.exp(-x+a*Math.log(x)-gln);\n}\nconst tiny=1e-300;\nlet b=x+1-a;\nlet c=1/tiny;\nlet d=1/b;\nlet h=d;\nfor(let i=1;i<1000;i++){\nconst an=-i*(i-a);\nb+=2;\nd=an*d+b;\nif(Math.abs(d)<tiny)d=tiny;\nc=b+an/c;\nif(Math.abs(c)<tiny)c=tiny;\nd=1/d;\nconst delta=d*c;\nh*=delta;\nif(Math.abs(delta-1)<1e-15)break;\n}\nconst q=Math.exp(-x+a*Math.log(x)-gln)*h;\nreturn 1-q;\n}\nfunction chiSquareCdf(x,df){\nif(x<=0)return 0;\nreturn regularizedGammaP(df/2,x/2);\n}\nfunction chiSquareQuantile(df,p=DEFAULT_CHI_SQUARE_P){\nif(!(p>0)||!(p<1))return NaN;\nlet lo=0;\nlet hi=Math.max(1,df);\nwhile(chiSquareCdf(hi,df)<p)hi*=2;\nfor(let i=0;i<200;i++){\nconst mid=(lo+hi)/2;\nif(chiSquareCdf(mid,df)<p)lo=mid;else hi=mid;\nif(hi-lo<1e-10)break;\n}\nreturn(lo+hi)/2;\n}\nfunction invertMatrix(matrix){\nconst k=matrix.length;\nconst a=matrix.map((row,i)=>{\nconst copy=row.slice();\nfor(let j=0;j<k;j++)copy.push(i===j?1:0);\nreturn copy;\n});\nfor(let col=0;col<k;col++){\nlet pivot=col;\nfor(let r=col+1;r<k;r++){\nif(Math.abs(a[r][col])>Math.abs(a[pivot][col]))pivot=r;\n}\nif(Math.abs(a[pivot][col])<1e-12)return null;\nif(pivot!==col){const t=a[pivot];a[pivot]=a[col];a[col]=t;}\nconst div=a[col][col];\nfor(let j=0;j<2*k;j++)a[col][j]/=div;\nfor(let r=0;r<k;r++){\nif(r===col)continue;\nconst factor=a[r][col];\nif(factor===0)continue;\nfor(let j=0;j<2*k;j++)a[r][j]-=factor*a[col][j];\n}\n}\nreturn a.map((row)=>row.slice(k));\n}\nfunction meanAndCovariance(rows,k){\nconst n=rows.length;\nconst mean=new Array(k).fill(0);\nfor(const row of rows)for(let j=0;j<k;j++)mean[j]+=row[j];\nfor(let j=0;j<k;j++)mean[j]/=n;\nconst cov=Array.from({length:k},()=>new Array(k).fill(0));\nfor(const row of rows){\nfor(let a=0;a<k;a++){\nconst da=row[a]-mean[a];\nfor(let b=a;b<k;b++){\ncov[a][b]+=da*(row[b]-mean[b]);\n}\n}\n}\nconst denom=n>1?n-1:1;\nfor(let a=0;a<k;a++){\nfor(let b=a;b<k;b++){\ncov[a][b]/=denom;\ncov[b][a]=cov[a][b];\n}\n}\nreturn{mean,cov};\n}\nfunction mahalanobis(matrix,opts={}){\nconst p=Number.isFinite(opts.p)?opts.p:DEFAULT_CHI_SQUARE_P;\nconst ridgeFraction=Number.isFinite(opts.ridge)?opts.ridge:1e-6;\nconst n=matrix.length;\nif(!n)return null;\nconst k=matrix[0].length;\nif(!k)return null;\nconst distances=new Array(n).fill(null);\nconst squared=new Array(n).fill(null);\nconst flags=new Array(n).fill(false);\nconst completeIndex=[];\nconst complete=[];\nfor(let i=0;i<n;i++){\nconst row=matrix[i];\nlet ok=row.length===k;\nconst coords=new Array(k);\nfor(let j=0;ok&&j<k;j++){\nconst v=Number(row[j]);\nif(!Number.isFinite(v))ok=false;else coords[j]=v;\n}\nif(ok){completeIndex.push(i);complete.push(coords);}\n}\nconst df=k;\nconst cutoff=chiSquareQuantile(df,p);\nif(complete.length<=k){\nreturn{center:[],df,cutoff,singular:true,used:complete.length,distances,squared,flags,flagged:0};\n}\nconst{mean,cov}=meanAndCovariance(complete,k);\nlet inverse=invertMatrix(cov);\nlet singular=false;\nif(!inverse){\nsingular=true;\nlet trace=0;\nfor(let j=0;j<k;j++)trace+=cov[j][j];\nconst ridge=(trace/k)*ridgeFraction||ridgeFraction;\nconst nudged=cov.map((row,i)=>row.map((v,j)=>(i===j?v+ridge:v)));\ninverse=invertMatrix(nudged);\nif(!inverse){\nreturn{center:mean,df,cutoff,singular:true,used:complete.length,distances,squared,flags,flagged:0};\n}\n}\nlet flagged=0;\nfor(let c=0;c<complete.length;c++){\nconst row=complete[c];\nconst dev=new Array(k);\nfor(let j=0;j<k;j++)dev[j]=row[j]-mean[j];\nlet d2=0;\nfor(let a=0;a<k;a++){\nlet sa=0;\nfor(let b=0;b<k;b++)sa+=inverse[a][b]*dev[b];\nd2+=dev[a]*sa;\n}\nif(d2<0)d2=0;\nconst at=completeIndex[c];\nsquared[at]=d2;\ndistances[at]=Math.sqrt(d2);\nif(d2>cutoff){flags[at]=true;flagged++;}\n}\nreturn{\ncenter:mean,df,cutoff,singular,used:complete.length,distances,squared,flags,flagged,\n};\n}\n});\n__def(\"packages/core/src/compute/index.js\",function(__exports,__req){\n'use strict';\nconst __m0=__req(\"packages/core/src/compute/sort.js\");\nObject.defineProperty(__exports,\"sortColumn\",{enumerable:true,get:function(){return __m0[\"sortColumn\"];}});\nObject.defineProperty(__exports,\"sortMulti\",{enumerable:true,get:function(){return __m0[\"sortMulti\"];}});\nObject.defineProperty(__exports,\"radixSortFloat64\",{enumerable:true,get:function(){return __m0[\"radixSortFloat64\"];}});\nObject.defineProperty(__exports,\"radixSortInt32\",{enumerable:true,get:function(){return __m0[\"radixSortInt32\"];}});\nObject.defineProperty(__exports,\"rankSortDictionary\",{enumerable:true,get:function(){return __m0[\"rankSortDictionary\"];}});\nObject.defineProperty(__exports,\"mergeSortComparator\",{enumerable:true,get:function(){return __m0[\"mergeSortComparator\"];}});\nObject.defineProperty(__exports,\"collateStringRanks\",{enumerable:true,get:function(){return __m0[\"collateStringRanks\"];}});\nObject.defineProperty(__exports,\"rankSortStrings\",{enumerable:true,get:function(){return __m0[\"rankSortStrings\"];}});\nconst __m1=__req(\"packages/core/src/compute/sortspec.js\");\nObject.defineProperty(__exports,\"collationDescriptor\",{enumerable:true,get:function(){return __m1[\"collationDescriptor\"];}});\nObject.defineProperty(__exports,\"isPortableSort\",{enumerable:true,get:function(){return __m1[\"isPortableSort\"];}});\nObject.defineProperty(__exports,\"isPortableSortSet\",{enumerable:true,get:function(){return __m1[\"isPortableSortSet\"];}});\nObject.defineProperty(__exports,\"describeSortEntry\",{enumerable:true,get:function(){return __m1[\"describeSortEntry\"];}});\nObject.defineProperty(__exports,\"describeSort\",{enumerable:true,get:function(){return __m1[\"describeSort\"];}});\nconst __m2=__req(\"packages/core/src/compute/filter.js\");\nObject.defineProperty(__exports,\"evaluateFilters\",{enumerable:true,get:function(){return __m2[\"evaluateFilters\"];}});\nObject.defineProperty(__exports,\"evaluateCondition\",{enumerable:true,get:function(){return __m2[\"evaluateCondition\"];}});\nObject.defineProperty(__exports,\"compact\",{enumerable:true,get:function(){return __m2[\"compact\"];}});\nObject.defineProperty(__exports,\"testValue\",{enumerable:true,get:function(){return __m2[\"testValue\"];}});\nObject.defineProperty(__exports,\"compilePredicate\",{enumerable:true,get:function(){return __m2[\"compilePredicate\"];}});\nObject.defineProperty(__exports,\"releaseMask\",{enumerable:true,get:function(){return __m2[\"releaseMask\"];}});\nObject.defineProperty(__exports,\"pruneColumn\",{enumerable:true,get:function(){return __m2[\"pruneColumn\"];}});\nObject.defineProperty(__exports,\"mentionsColumn\",{enumerable:true,get:function(){return __m2[\"mentionsColumn\"];}});\nconst __m3=__req(\"packages/core/src/compute/group.js\");\nObject.defineProperty(__exports,\"groupByColumns\",{enumerable:true,get:function(){return __m3[\"groupByColumns\"];}});\nObject.defineProperty(__exports,\"packKeys\",{enumerable:true,get:function(){return __m3[\"packKeys\"];}});\nconst __m4=__req(\"packages/core/src/compute/facet.js\");\nObject.defineProperty(__exports,\"facet\",{enumerable:true,get:function(){return __m4[\"facet\"];}});\nObject.defineProperty(__exports,\"computeBounds\",{enumerable:true,get:function(){return __m4[\"computeBounds\"];}});\nObject.defineProperty(__exports,\"countInto\",{enumerable:true,get:function(){return __m4[\"countInto\"];}});\nObject.defineProperty(__exports,\"bucketOf\",{enumerable:true,get:function(){return __m4[\"bucketOf\"];}});\nObject.defineProperty(__exports,\"facetKind\",{enumerable:true,get:function(){return __m4[\"facetKind\"];}});\nObject.defineProperty(__exports,\"cardinalityOf\",{enumerable:true,get:function(){return __m4[\"cardinalityOf\"];}});\nObject.defineProperty(__exports,\"pickGranularity\",{enumerable:true,get:function(){return __m4[\"pickGranularity\"];}});\nObject.defineProperty(__exports,\"floorTo\",{enumerable:true,get:function(){return __m4[\"floorTo\"];}});\nObject.defineProperty(__exports,\"advance\",{enumerable:true,get:function(){return __m4[\"advance\"];}});\nObject.defineProperty(__exports,\"STRATEGIES\",{enumerable:true,get:function(){return __m4[\"STRATEGIES\"];}});\nObject.defineProperty(__exports,\"GRANULARITIES\",{enumerable:true,get:function(){return __m4[\"GRANULARITIES\"];}});\nObject.defineProperty(__exports,\"DEFAULT_BUCKETS\",{enumerable:true,get:function(){return __m4[\"DEFAULT_BUCKETS\"];}});\nObject.defineProperty(__exports,\"DEFAULT_CARDINALITY_LIMIT\",{enumerable:true,get:function(){return __m4[\"DEFAULT_CARDINALITY_LIMIT\"];}});\nObject.defineProperty(__exports,\"QUANTILE_SAMPLE\",{enumerable:true,get:function(){return __m4[\"QUANTILE_SAMPLE\"];}});\nconst __m5=__req(\"packages/core/src/compute/total.js\");\nObject.defineProperty(__exports,\"TOTAL_FNS\",{enumerable:true,get:function(){return __m5[\"TOTAL_FNS\"];}});\nObject.defineProperty(__exports,\"TOTAL_LABELS\",{enumerable:true,get:function(){return __m5[\"TOTAL_LABELS\"];}});\nObject.defineProperty(__exports,\"totalLabel\",{enumerable:true,get:function(){return __m5[\"totalLabel\"];}});\nObject.defineProperty(__exports,\"total\",{enumerable:true,get:function(){return __m5[\"total\"];}});\nObject.defineProperty(__exports,\"collectValues\",{enumerable:true,get:function(){return __m5[\"collectValues\"];}});\nconst __m6=__req(\"packages/core/src/compute/pivot.js\");\nObject.defineProperty(__exports,\"pivot\",{enumerable:true,get:function(){return __m6[\"pivot\"];}});\nObject.defineProperty(__exports,\"resolvePivotKeys\",{enumerable:true,get:function(){return __m6[\"resolvePivotKeys\"];}});\nObject.defineProperty(__exports,\"pivotKey\",{enumerable:true,get:function(){return __m6[\"pivotKey\"];}});\nObject.defineProperty(__exports,\"joinPath\",{enumerable:true,get:function(){return __m6[\"joinPath\"];}});\nObject.defineProperty(__exports,\"KEY_DELIMITER\",{enumerable:true,get:function(){return __m6[\"KEY_DELIMITER\"];}});\nObject.defineProperty(__exports,\"DEFAULT_PATH_SEPARATOR\",{enumerable:true,get:function(){return __m6[\"DEFAULT_PATH_SEPARATOR\"];}});\nObject.defineProperty(__exports,\"DEFAULT_MAX_COLUMNS\",{enumerable:true,get:function(){return __m6[\"DEFAULT_MAX_COLUMNS\"];}});\nconst __m7=__req(\"packages/core/src/compute/pivotmatrix.js\");\nObject.defineProperty(__exports,\"pivotMatrix\",{enumerable:true,get:function(){return __m7[\"pivotMatrix\"];}});\nObject.defineProperty(__exports,\"resolveAxis\",{enumerable:true,get:function(){return __m7[\"resolveAxis\"];}});\nObject.defineProperty(__exports,\"cellKey\",{enumerable:true,get:function(){return __m7[\"cellKey\"];}});\nObject.defineProperty(__exports,\"marginKey\",{enumerable:true,get:function(){return __m7[\"marginKey\"];}});\nObject.defineProperty(__exports,\"GRAND_PATH\",{enumerable:true,get:function(){return __m7[\"GRAND_PATH\"];}});\nconst __m8=__req(\"packages/core/src/compute/reference.js\");\nObject.defineProperty(__exports,\"referenceSort\",{enumerable:true,get:function(){return __m8[\"referenceSort\"];}});\nObject.defineProperty(__exports,\"referenceFilter\",{enumerable:true,get:function(){return __m8[\"referenceFilter\"];}});\nObject.defineProperty(__exports,\"referenceGroup\",{enumerable:true,get:function(){return __m8[\"referenceGroup\"];}});\nObject.defineProperty(__exports,\"referenceTotal\",{enumerable:true,get:function(){return __m8[\"referenceTotal\"];}});\nObject.defineProperty(__exports,\"referencePasses\",{enumerable:true,get:function(){return __m8[\"referencePasses\"];}});\nObject.defineProperty(__exports,\"referenceValue\",{enumerable:true,get:function(){return __m8[\"referenceValue\"];}});\nconst __m9=__req(\"packages/core/src/compute/handle.js\");\nObject.defineProperty(__exports,\"identity\",{enumerable:true,get:function(){return __m9[\"identity\"];}});\nObject.defineProperty(__exports,\"rowCount\",{enumerable:true,get:function(){return __m9[\"rowCount\"];}});\nObject.defineProperty(__exports,\"presenceReader\",{enumerable:true,get:function(){return __m9[\"presenceReader\"];}});\nObject.defineProperty(__exports,\"bitReader\",{enumerable:true,get:function(){return __m9[\"bitReader\"];}});\nObject.defineProperty(__exports,\"valueReader\",{enumerable:true,get:function(){return __m9[\"valueReader\"];}});\nObject.defineProperty(__exports,\"valueComparator\",{enumerable:true,get:function(){return __m9[\"valueComparator\"];}});\nObject.defineProperty(__exports,\"numericTotalOrder\",{enumerable:true,get:function(){return __m9[\"numericTotalOrder\"];}});\nObject.defineProperty(__exports,\"dictRanks\",{enumerable:true,get:function(){return __m9[\"dictRanks\"];}});\nObject.defineProperty(__exports,\"dictSize\",{enumerable:true,get:function(){return __m9[\"dictSize\"];}});\nObject.defineProperty(__exports,\"dictValue\",{enumerable:true,get:function(){return __m9[\"dictValue\"];}});\nObject.defineProperty(__exports,\"multiValue\",{enumerable:true,get:function(){return __m9[\"multiValue\"];}});\nObject.defineProperty(__exports,\"isMissing\",{enumerable:true,get:function(){return __m9[\"isMissing\"];}});\nconst __m10=__req(\"packages/core/src/compute/sketch.js\");\nObject.defineProperty(__exports,\"Welford\",{enumerable:true,get:function(){return __m10[\"Welford\"];}});\nObject.defineProperty(__exports,\"Reservoir\",{enumerable:true,get:function(){return __m10[\"Reservoir\"];}});\nObject.defineProperty(__exports,\"HyperLogLog\",{enumerable:true,get:function(){return __m10[\"HyperLogLog\"];}});\nObject.defineProperty(__exports,\"SpaceSaving\",{enumerable:true,get:function(){return __m10[\"SpaceSaving\"];}});\nObject.defineProperty(__exports,\"KLL\",{enumerable:true,get:function(){return __m10[\"KLL\"];}});\nObject.defineProperty(__exports,\"hash32\",{enumerable:true,get:function(){return __m10[\"hash32\"];}});\nObject.defineProperty(__exports,\"SKETCH_BOUNDS\",{enumerable:true,get:function(){return __m10[\"SKETCH_BOUNDS\"];}});\nconst __m11=__req(\"packages/core/src/compute/windowed.js\");\nObject.defineProperty(__exports,\"Window\",{enumerable:true,get:function(){return __m11[\"Window\"];}});\nObject.defineProperty(__exports,\"WINDOW_KINDS\",{enumerable:true,get:function(){return __m11[\"WINDOW_KINDS\"];}});\nObject.defineProperty(__exports,\"openWindow\",{enumerable:true,get:function(){return __m11[\"openWindow\"];}});\nconst __m12=__req(\"packages/core/src/compute/statistics.js\");\nObject.defineProperty(__exports,\"MAINTENANCE\",{enumerable:true,get:function(){return __m12[\"MAINTENANCE\"];}});\nObject.defineProperty(__exports,\"APPROXIMATE\",{enumerable:true,get:function(){return __m12[\"APPROXIMATE\"];}});\nObject.defineProperty(__exports,\"maintenanceOf\",{enumerable:true,get:function(){return __m12[\"maintenanceOf\"];}});\nconst __m13=__req(\"packages/core/src/compute/anomaly.js\");\nObject.defineProperty(__exports,\"ANOMALY_METHODS\",{enumerable:true,get:function(){return __m13[\"ANOMALY_METHODS\"];}});\nObject.defineProperty(__exports,\"modifiedZScores\",{enumerable:true,get:function(){return __m13[\"modifiedZScores\"];}});\nObject.defineProperty(__exports,\"iqrFences\",{enumerable:true,get:function(){return __m13[\"iqrFences\"];}});\nObject.defineProperty(__exports,\"mahalanobis\",{enumerable:true,get:function(){return __m13[\"mahalanobis\"];}});\n});\n__def(\"packages/worker/src/kernel.js\",function(__exports,__req){\n'use strict';\nObject.defineProperty(__exports,\"loadCompute\",{enumerable:true,get:function(){return loadCompute;}});\nObject.defineProperty(__exports,\"setCompute\",{enumerable:true,get:function(){return setCompute;}});\nObject.defineProperty(__exports,\"dispatch\",{enumerable:true,get:function(){return dispatch;}});\nObject.defineProperty(__exports,\"handleMessage\",{enumerable:true,get:function(){return handleMessage;}});\nObject.defineProperty(__exports,\"installKernel\",{enumerable:true,get:function(){return installKernel;}});\nconst __m0=__req(\"packages/worker/src/transport.js\");\nconst PROTOCOL=__m0[\"PROTOCOL\"];\nconst OPS=__m0[\"OPS\"];\nconst CONTROL=__m0[\"CONTROL\"];\nconst ERRORS=__m0[\"ERRORS\"];\nconst unpackHandle=__m0[\"unpackHandle\"];\nconst unpackHandles=__m0[\"unpackHandles\"];\nconst createMaskPool=__m0[\"createMaskPool\"];\nconst collectTransfers=__m0[\"collectTransfers\"];\nconst __m1=__req(\"packages/core/src/store/columnpack.js\");\nconst packChunk=__m1[\"packChunk\"];\nconst packedTransfers=__m1[\"packedTransfers\"];\nlet computeModule=null;\nlet computePromise=null;\nlet computeError=null;\nasync function loadCompute(loader){\nif(computeModule)return computeModule;\nif(!computePromise){\nconst load=loader||(()=>Promise.resolve(__req(\"packages/core/src/compute/index.js\")));\ncomputePromise=Promise.resolve()\n.then(load)\n.then((mod)=>{computeModule=mod;return mod;})\n.catch((err)=>{\ncomputeError=err;\ncomputeModule=null;\nreturn null;\n});\n}\nreturn computePromise;\n}\nfunction setCompute(mod){\ncomputeModule=mod;\ncomputePromise=mod?Promise.resolve(mod):null;\ncomputeError=mod?null:computeError;\n}\nfunction filterContext(handles,count,locale){\nconst byId=new Map();\nfor(const h of handles)if(h)byId.set(h.id,h);\nreturn{\nhandle(colId){return byId.get(colId);},\ncount,\npool:createMaskPool(),\nlocale,\n};\n}\nfunction dispatch(request,compute){\nconst{op,args}=request;\nif(op===OPS.COLUMNIZE){\nreturn packChunk(args.schema||[],args.rows||[],args.opts||{});\n}\nconst fn=compute[op];\nif(typeof fn!=='function'){\nconst err=new Error(`[lattice] compute kernel '${op}' is not exported`);\n(err).code=ERRORS.NO_KERNEL;\nthrow err;\n}\nswitch(op){\ncase OPS.COLLATE_STRING_RANKS:\nreturn fn(args.table||[],(args.table||[]).length,args.locale);\ncase OPS.SORT_COLUMN:\nreturn fn(unpackHandle(args.handle),args.order??null,args.opts||{});\ncase OPS.SORT_MULTI:{\nconst handles=unpackHandles(args.handles||[]);\nconst entries=(args.entries||[]).map((e)=>({\n...e,\nhandle:handles[e.index],\n}));\nreturn fn(handles,entries,args.order??null);\n}\ncase OPS.EVALUATE_FILTERS:\nreturn fn(args.filters,filterContext(unpackHandles(args.handles||[]),args.count,args.locale));\ncase OPS.COMPACT:\nreturn fn(args.mask,args.count,undefined);\ncase OPS.GROUP_BY_COLUMNS:\nreturn fn(unpackHandles(args.handles||[]),args.order??null,args.opts||{});\ncase OPS.TOTAL:\nreturn fn(unpackHandle(args.handle),args.indices??null,args.fn);\ncase OPS.PIVOT:\nreturn fn(unpackHandles(args.handles||[]),args.order??null,args.opts||{});\ncase OPS.FACET:\nreturn fn(unpackHandle(args.handle),args.indices??null,args.count,args.opts||{});\ndefault:{\nconst err=new Error(`[lattice] unknown worker op '${op}'`);\n(err).code=ERRORS.PROTOCOL;\nthrow err;\n}\n}\n}\nasync function handleMessage(message,opts={}){\nif(!message||message.lattice!==PROTOCOL)return null;\nconst{id,op}=message;\nif(op===CONTROL.CANCEL){\nopts.cancelled?.add(message.target);\nreturn null;\n}\nif(op===CONTROL.PING){\nreturn{reply:{lattice:PROTOCOL,id,ok:true,result:'pong'},transfer:[]};\n}\nif(op===OPS.COLUMNIZE){\nif(opts.cancelled?.has(id)){opts.cancelled.delete(id);return null;}\ntry{\nconst result=packChunk(message.args.schema||[],message.args.rows||[],message.args.opts||{});\nif(opts.cancelled?.has(id)){\nopts.cancelled.delete(id);\nreturn{reply:{lattice:PROTOCOL,id,ok:false,error:{code:ERRORS.ABORTED,message:'[lattice] request superseded'}},transfer:[]};\n}\nreturn{reply:{lattice:PROTOCOL,id,ok:true,result},transfer:packedTransfers(result)};\n}catch(err){\nconst e=(err);\nreturn{\nreply:{lattice:PROTOCOL,id,ok:false,error:{code:e.code||ERRORS.KERNEL,message:e.message||String(err),stack:e.stack}},\ntransfer:[],\n};\n}\n}\nconst compute=await loadCompute(opts.loader);\nif(!compute){\nreturn{\nreply:{\nlattice:PROTOCOL,\nid,\nok:false,\nerror:{\ncode:ERRORS.NO_COMPUTE,\nmessage:`[lattice] compute kernels unavailable in worker: ${computeError?computeError.message:'module not found'}`,\n},\n},\ntransfer:[],\n};\n}\nif(opts.cancelled?.has(id)){\nopts.cancelled.delete(id);\nreturn{reply:{lattice:PROTOCOL,id,ok:false,error:{code:ERRORS.ABORTED,message:'[lattice] request superseded'}},transfer:[]};\n}\ntry{\nconst result=dispatch(message,compute);\nif(opts.cancelled?.has(id)){\nopts.cancelled.delete(id);\nreturn{reply:{lattice:PROTOCOL,id,ok:false,error:{code:ERRORS.ABORTED,message:'[lattice] request superseded'}},transfer:[]};\n}\nreturn{reply:{lattice:PROTOCOL,id,ok:true,result},transfer:collectTransfers(result)};\n}catch(err){\nconst e=(err);\nreturn{\nreply:{\nlattice:PROTOCOL,\nid,\nok:false,\nerror:{code:e.code||ERRORS.KERNEL,message:e.message||String(err),stack:e.stack},\n},\ntransfer:[],\n};\n}\n}\nfunction installKernel(scope,opts={}){\nconst cancelled=new Set();\nconst onMessage=async(event)=>{\nconst outcome=await handleMessage(event.data,{loader:opts.loader,cancelled});\nif(!outcome)return;\nscope.postMessage(outcome.reply,outcome.transfer);\n};\nscope.addEventListener('message',onMessage);\nloadCompute(opts.loader).then((mod)=>{\nscope.postMessage({lattice:PROTOCOL,id:0,op:CONTROL.READY,compute:!!mod});\n});\nreturn()=>scope.removeEventListener('message',onMessage);\n}\n});\nvar __entry=__req(\"packages/worker/src/kernel.js\");\nroot[\"__latticeKernel\"]=__entry;\n})(typeof globalThis!=='undefined'?globalThis:this);\n__latticeKernel.installKernel(self);\n",{type:'classic'});
|
|
75730
77787
|
}catch(err){}
|
|
75731
77788
|
var __entry=__req("packages/dom/src/index.js");
|
|
75732
77789
|
if(typeof module==='object'&&module.exports){module.exports=__entry;}
|