@kanunilabs/pivotgrid-core 1.6.0 → 1.7.1

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.
@@ -1 +1 @@
1
- 'use strict';var J=class{size=1;nodeToParent;nodeToVal;nodeToDepth;nodeChildCount;childrenMap;constructor(e){this.nodeToParent=new Int32Array(e).fill(-1),this.nodeToVal=new Int32Array(e).fill(-1),this.nodeToDepth=new Int32Array(e).fill(0),this.nodeChildCount=new Int32Array(e).fill(0),this.childrenMap=new Map;}expandCapacity(){let e=this.nodeToParent.length*2,n=new Int32Array(e).fill(-1);n.set(this.nodeToParent),this.nodeToParent=n;let t=new Int32Array(e).fill(-1);t.set(this.nodeToVal),this.nodeToVal=t;let r=new Int32Array(e).fill(0);r.set(this.nodeToDepth),this.nodeToDepth=r;let i=new Int32Array(e).fill(0);i.set(this.nodeChildCount),this.nodeChildCount=i;}insert(e,n){let t=0;for(let r=0;r<n;r++){let i=e[r],a=this.childrenMap.get(t);a||(a=new Map,this.childrenMap.set(t,a));let u=a.get(i);u===void 0&&(this.size>=this.nodeToParent.length&&this.expandCapacity(),u=this.size++,this.nodeToParent[u]=t,this.nodeToVal[u]=i,this.nodeToDepth[u]=r+1,this.nodeChildCount[t]++,a.set(i,u)),t=u;}return t}};var ee=class{dictionary=[];rowFields=[];colFields=[];dataFields=[];storedColumns={};storedRowCount=0;lastMask=null;isBuilt=false;buildState=null;incrementalFilters=null;incrementalPrefilter=null;rowTrie;colTrie;cardinalityMap={};rowPathStrs=[];colPathStrs=[];rowIndexMapCache={};columnIndexMapCache={};buildVersion=0;groupCount=0;leafGroupRowIds;leafGroupColIds;leafGroupMeasures;leafGroupCounts;leafGroupMins;leafGroupMaxes;leafGroupDistinctSets=new Map;init(e){this.dictionary=e.dictionary,this.rowFields=e.rowFields,this.colFields=e.colFields,this.dataFields=e.dataFields,e.workerBootstrap&&e.workerBootstrap.length>0&&console.warn("[PivotGrid Worker] workerBootstrap is deprecated for security reasons. All calculations are executed on the main thread."),this.storedRowCount=e.rowCount,this.storedColumns={};for(let[n,t]of Object.entries(e.columnarData))t.type==="int32"&&(this.storedColumns[n]={type:"int32",array:new Int32Array(t.buffer)}),t.type==="float64"&&(this.storedColumns[n]={type:"float64",array:new Float64Array(t.buffer)});this.lastMask=null,e.deferBuild?this.isBuilt=false:this.buildFromMask(null);}reconfigure(e){if(this.rowFields=e.rowFields,this.colFields=e.colFields,this.dataFields=e.dataFields,e.dictionaryAppend&&e.dictionaryAppend.length>0)for(let n of e.dictionaryAppend)this.dictionary.push(n);if(e.newColumns)for(let[n,t]of Object.entries(e.newColumns))t.type==="int32"&&(this.storedColumns[n]={type:"int32",array:new Int32Array(t.buffer)}),t.type==="float64"&&(this.storedColumns[n]={type:"float64",array:new Float64Array(t.buffer)});this.buildFromMask(this.lastMask);}initStart(e){this.dictionary=e.dictionary,this.rowFields=e.rowFields,this.colFields=e.colFields,this.dataFields=e.dataFields,e.workerBootstrap&&e.workerBootstrap.length>0&&console.warn("[PivotGrid Worker] workerBootstrap is deprecated for security reasons. All calculations are executed on the main thread."),this.storedRowCount=e.rowCountTotal,this.storedColumns={};for(let[n,t]of Object.entries(e.columnTypes))t==="int32"?this.storedColumns[n]={type:"int32",array:new Int32Array(e.rowCountTotal)}:this.storedColumns[n]={type:"float64",array:new Float64Array(e.rowCountTotal)};this.incrementalFilters=e.filters&&e.filters.length>0?e.filters.map(n=>({fieldId:n.fieldId,filterType:n.filterType,ids:new Set,pending:new Set(n.valueStrings)})):null,this.incrementalPrefilter=e.prefilter&&e.prefilter.conditions.length>0?e.prefilter:null,this.lastMask=this.incrementalFilters||this.incrementalPrefilter?new Uint8Array(e.rowCountTotal):null,this.resolveIncrementalFilterStrings(0),this.isBuilt=false,this.beginBuild();}initChunk(e){if(e.dictionaryAppend&&e.dictionaryAppend.length>0){let n=this.dictionary.length;for(let t of e.dictionaryAppend)this.dictionary.push(t);this.resolveIncrementalFilterStrings(n),this.ensureCardCapacity();}for(let[n,t]of Object.entries(e.columns)){let r=this.storedColumns[n];r&&(r.type==="int32"?r.array.set(new Int32Array(t),e.start):r.array.set(new Float64Array(t),e.start));}this.lastMask&&this.computeMaskRange(e.start,e.end),this.processRange(e.start,e.end,this.lastMask);}initEnd(){this.incrementalFilters=null,this.incrementalPrefilter=null,this.finalizeBuild();}resolveIncrementalFilterStrings(e){let n=this.incrementalFilters;if(!n)return;let t=0;for(let r of n)t+=r.pending.size;if(t!==0)for(let r=e;r<this.dictionary.length;r++){let i=this.dictionary[r];for(let a of n)a.pending.delete(i)&&a.ids.add(r);}}computeMaskRange(e,n){let t=this.lastMask;if(t.fill(1,e,n),this.incrementalFilters)for(let r of this.incrementalFilters){let i=this.storedColumns[r.fieldId];if(!i||i.type!=="int32")continue;let a=i.array,u=r.ids;if(r.filterType==="exclude")for(let o=e;o<n;o++)t[o]&&u.has(a[o])&&(t[o]=0);else for(let o=e;o<n;o++)t[o]&&!u.has(a[o])&&(t[o]=0);}if(this.incrementalPrefilter)for(let r=e;r<n;r++)t[r]&&!this.evaluatePrefilterGroup(this.incrementalPrefilter,r)&&(t[r]=0);}applyFilter(e){if(e.filters.length===0&&!e.prefilter){this.lastMask=null,this.buildFromMask(null);return}let n=this.storedRowCount,t=new Uint8Array(n);t.fill(1);for(let r of e.filters){let i=this.storedColumns[r.fieldId];if(!i||i.type!=="int32")continue;let a=i.array,u=new Set(r.dictIds);if(r.filterType==="exclude")for(let o=0;o<n;o++)t[o]&&u.has(a[o])&&(t[o]=0);else for(let o=0;o<n;o++)t[o]&&!u.has(a[o])&&(t[o]=0);}if(e.prefilter&&e.prefilter.conditions.length>0)for(let r=0;r<n;r++)t[r]&&!this.evaluatePrefilterGroup(e.prefilter,r)&&(t[r]=0);this.lastMask=t,this.buildFromMask(t);}evaluatePrefilterGroup(e,n){if(!e.conditions||e.conditions.length===0)return true;if(e.logicalOperator==="and"){for(let t of e.conditions)if("logicalOperator"in t){if(!this.evaluatePrefilterGroup(t,n))return false}else if(!this.evaluatePrefilterCondition(t,n))return false;return true}else {for(let t of e.conditions)if("logicalOperator"in t){if(this.evaluatePrefilterGroup(t,n))return true}else if(this.evaluatePrefilterCondition(t,n))return true;return false}}evaluatePrefilterCondition(e,n){let t=this.storedColumns[e.fieldId];if(!t)return true;if(t.type==="float64"){let u=t.array[n],o=Number(e.value);switch(e.operator){case "=":return u===o;case "<>":return u!==o;case ">":return u>o;case ">=":return u>=o;case "<":return u<o;case "<=":return u<=o;case "isnull":return isNaN(u)||u===0;case "isnotnull":return !isNaN(u)&&u!==0;default:return true}}let r=t.array[n],i=this.dictionary[r]||"",a=String(e.value??"");switch(e.operator){case "=":return i===a;case "<>":return i!==a;case ">":return i>a;case ">=":return i>=a;case "<":return i<a;case "<=":return i<=a;case "contains":return i.toLowerCase().includes(a.toLowerCase());case "notcontains":return !i.toLowerCase().includes(a.toLowerCase());case "startswith":return i.toLowerCase().startsWith(a.toLowerCase());case "endswith":return i.toLowerCase().endsWith(a.toLowerCase());case "isnull":return i===""||i==="(Blank)";case "isnotnull":return i!==""&&i!=="(Blank)";case "in":return Array.isArray(e.value)?e.value.map(String).includes(i):true;case "notin":return Array.isArray(e.value)?!e.value.map(String).includes(i):true;default:return true}}buildFromMask(e){this.beginBuild(),this.processRange(0,this.storedRowCount,e),this.finalizeBuild();}beginBuild(){let e=this.storedRowCount,n=this.storedColumns,t=this.rowFields.length,r=this.colFields.length,i=new Array(t);for(let l=0;l<t;l++)i[l]=n[this.rowFields[l].id].array;let a=new Array(r);for(let l=0;l<r;l++)a[l]=n[this.colFields[l].id].array;let u=this.dictionary.length,o=this.rowFields.map(l=>{let M=n[l.id];return M&&M.type==="int32"?new Uint8Array(u):null}),w=this.colFields.map(l=>{let M=n[l.id];return M&&M.type==="int32"?new Uint8Array(u):null});this.rowTrie=new J(2e5),this.colTrie=new J(2e5);let v=this.dataFields.length,S=this.dataFields.map(l=>l.summaryType||"sum"),h=S.some(l=>l==="count"||l==="avg"),D=S.some(l=>l==="min"),L=S.some(l=>l==="max"),K=S.some(l=>l==="distinct"),_=new Array(v);for(let l=0;l<v;l++)_[l]=n[this.dataFields[l].id].array;let R=Math.min(e,2e5),N=D?new Float64Array(R*v):new Float64Array(0),x=L?new Float64Array(R*v):new Float64Array(0);this.leafGroupDistinctSets=K?new Map:new Map,D&&N.fill(1/0),L&&x.fill(-1/0),this.buildState={rPath:new Int32Array(t),cPath:new Int32Array(r),rowColArrays:i,colColArrays:a,dataColArrays:_,rowCardSeen:o,colCardSeen:w,rowCardCounts:new Int32Array(t),colCardCounts:new Int32Array(r),summaryTypes:S,allSums:S.every(l=>l==="sum"),needsCounts:h,needsMins:D,needsMaxes:L,groupMap:new Map,leafRowIds:new Int32Array(R),leafColIds:new Int32Array(R),leafMeasures:new Float64Array(R*v),leafCounts:h?new Float64Array(R*v):new Float64Array(0),leafMins:N,leafMaxes:x,gCount:0};}ensureCardCapacity(){let e=this.buildState;if(!e)return;let n=this.dictionary.length,t=r=>{if(r===null||r.length>=n)return r;let i=new Uint8Array(Math.max(n,r.length*2));return i.set(r),i};for(let r=0;r<e.rowCardSeen.length;r++)e.rowCardSeen[r]=t(e.rowCardSeen[r]);for(let r=0;r<e.colCardSeen.length;r++)e.colCardSeen[r]=t(e.colCardSeen[r]);}processRange(e,n,t){let r=this.buildState,{rPath:i,cPath:a,rowColArrays:u,colColArrays:o,dataColArrays:w,rowCardSeen:v,colCardSeen:S,rowCardCounts:h,colCardCounts:D,summaryTypes:L,allSums:K,needsCounts:_,needsMins:R,needsMaxes:N,groupMap:x}=r,l=u.length,M=o.length,y=w.length,X=this.rowTrie,V=this.colTrie,C=r.leafRowIds,b=r.leafColIds,k=r.leafMeasures,z=r.leafCounts,U=r.leafMins,E=r.leafMaxes,Q=r.gCount;for(let W=e;W<n;W++){if(t&&!t[W])continue;for(let s=0;s<l;s++){let d=u[s][W];i[s]=d;let f=v[s];f!==null&&f[d]===0&&(f[d]=1,h[s]++);}let Y=X.insert(i,l);for(let s=0;s<M;s++){let d=o[s][W];a[s]=d;let f=S[s];f!==null&&f[d]===0&&(f[d]=1,D[s]++);}let H=V.insert(a,M),Z=Y*67108864+H,G=x.get(Z);if(G===void 0){if(G=Q++,x.set(Z,G),G>=C.length){let s=G*2,d=new Int32Array(s);d.set(C),C=d;let f=new Int32Array(s);f.set(b),b=f;let I=new Float64Array(s*y);if(I.set(k),k=I,_){let p=new Float64Array(s*y);p.set(z),z=p;}if(R){let p=new Float64Array(s*y);p.fill(1/0),p.set(U),U=p;}if(N){let p=new Float64Array(s*y);p.fill(-1/0),p.set(E),E=p;}}C[G]=Y,b[G]=H;}let c=G*y;if(K)for(let s=0;s<y;s++)k[c+s]+=w[s][W];else for(let s=0;s<y;s++){let d=w[s][W],f=c+s;switch(L[s]){case "sum":k[f]+=d;break;case "count":z[f]+=1;break;case "avg":k[f]+=d,z[f]+=1;break;case "min":d<U[f]&&(U[f]=d);break;case "max":d>E[f]&&(E[f]=d);break;case "distinct":{let I=this.leafGroupDistinctSets.get(f);I||(I=new Set,this.leafGroupDistinctSets.set(f,I)),I.add(d);break}default:k[f]+=d;break}}}r.leafRowIds=C,r.leafColIds=b,r.leafMeasures=k,r.leafCounts=z,r.leafMins=U,r.leafMaxes=E,r.gCount=Q;}finalizeBuild(){let e=this.buildState,{needsCounts:n,needsMins:t,needsMaxes:r,gCount:i}=e,a=e.dataColArrays.length,u=e.rowColArrays.length,o=e.colColArrays.length;this.groupCount=i,this.leafGroupRowIds=e.leafRowIds.slice(0,i),this.leafGroupColIds=e.leafColIds.slice(0,i),this.leafGroupMeasures=e.leafMeasures.slice(0,i*a),this.leafGroupCounts=n?e.leafCounts.slice(0,i*a):e.leafCounts,this.leafGroupMins=t?e.leafMins.slice(0,i*a):e.leafMins,this.leafGroupMaxes=r?e.leafMaxes.slice(0,i*a):e.leafMaxes,this.cardinalityMap={};for(let w=0;w<u;w++)e.rowCardSeen[w]!==null&&(this.cardinalityMap[this.rowFields[w].id]=e.rowCardCounts[w]);for(let w=0;w<o;w++)e.colCardSeen[w]!==null&&(this.cardinalityMap[this.colFields[w].id]=e.colCardCounts[w]);this.buildState=null,this.buildVersion++,this.isBuilt=true,this.rowPathStrs=this.buildPathStrs(this.rowTrie),this.colPathStrs=this.buildPathStrs(this.colTrie),this.rowIndexMapCache=this.buildIndexMap(this.rowPathStrs),this.columnIndexMapCache=this.buildIndexMap(this.colPathStrs);}buildPathStrs(e){let n=new Array(e.size);n[0]="";for(let t=1;t<e.size;t++){let r=e.nodeToParent[t],i=this.dictionary[e.nodeToVal[t]],a=n[r];n[t]=a?a+"|"+i:i;}return n}buildIndexMap(e){let n={};for(let t=0;t<e.length;t++)n[e[t]]=t;return n}compute(e){this.isBuilt||this.buildFromMask(this.lastMask);let n=this.rowPathStrs,t=this.colPathStrs,r=new Uint8Array(this.rowTrie.size),i=new Set(e.expandedPaths),a=i.has(".*")||i.has("*");for(let c=0;c<this.rowTrie.size;c++)r[c]=a||i.has(n[c])?1:0;let u=new Uint8Array(this.colTrie.size),o=new Set(e.expandedColPaths),w=o.has(".*")||o.has("*");for(let c=0;c<this.colTrie.size;c++)u[c]=w||o.has(t[c])?1:0;let v=new Uint8Array(this.rowTrie.size);v[0]=1;for(let c=1;c<this.rowTrie.size;c++){let s=this.rowTrie.nodeToParent[c];(s===0||r[s])&&(v[c]=1);}let S=new Uint8Array(this.colTrie.size);S[0]=1;for(let c=1;c<this.colTrie.size;c++){let s=this.colTrie.nodeToParent[c];(s===0||u[s])&&(S[c]=1);}let h=this.dataFields.length,D=this.dataFields.map(c=>c.summaryType||"sum"),L=this.leafGroupMins.length>0,K=this.leafGroupMaxes.length>0,_=this.leafGroupCounts.length>0,R=this.leafGroupDistinctSets.size>0,N=new Map,x=0,l=1e4,M=new Float64Array(l),y=new Float64Array(l*h),X=new Int32Array(l*h),V=_?new Float64Array(l*h):null,C=L?new Float64Array(l*h):null,b=K?new Float64Array(l*h):null,k=R?new Map:new Map;C&&C.fill(1/0),b&&b.fill(-1/0);let z=new Int32Array(this.rowFields.length+1),U=new Int32Array(this.colFields.length+1),E=(c,s,d,f)=>{let I=0,p=c;for(;p!==-1;)d[p]&&(f[I++]=p),p=s.nodeToParent[p];return I};for(let c=0;c<this.groupCount;c++){let s=this.leafGroupRowIds[c],d=this.leafGroupColIds[c],f=E(s,this.rowTrie,v,z),I=E(d,this.colTrie,S,U);for(let p=0;p<f;p++){let $=z[p];for(let B=0;B<I;B++){let q=U[B],j=$*67108864+q,g=N.get(j);if(g===void 0){if(g=x++,N.set(j,g),g>=M.length){let A=g*2,m=new Float64Array(A);m.set(M),M=m;let P=new Float64Array(A*h);P.set(y),y=P;let T=new Int32Array(A*h);if(T.set(X),X=T,V){let F=new Float64Array(A*h);F.set(V),V=F;}if(C){let F=new Float64Array(A*h);F.fill(1/0),F.set(C),C=F;}if(b){let F=new Float64Array(A*h);F.fill(-1/0),F.set(b),b=F;}}M[g]=j;}for(let A=0;A<h;A++){let m=g*h+A,P=c*h+A;switch(D[A]){case "sum":y[m]+=this.leafGroupMeasures[P];break;case "count":y[m]+=this.leafGroupCounts[P];break;case "avg":y[m]+=this.leafGroupMeasures[P],V[m]+=this.leafGroupCounts[P];break;case "min":{let T=this.leafGroupMins[P];T<C[m]&&(C[m]=T);break}case "max":{let T=this.leafGroupMaxes[P];T>b[m]&&(b[m]=T);break}case "distinct":{let T=this.leafGroupDistinctSets.get(P);if(T){let F=k.get(m);F||(F=new Set,k.set(m,F));for(let ie of T)F.add(ie);}break}default:y[m]+=this.leafGroupMeasures[P];break}X[m]+=1;}}}}for(let c=0;c<x;c++)for(let s=0;s<h;s++){let d=c*h+s;switch(D[s]){case "avg":y[d]=V[d]>0?y[d]/V[d]:0;break;case "min":y[d]=C[d]!==1/0?C[d]:0;break;case "max":y[d]=b[d]!==-1/0?b[d]:0;break;case "distinct":{let f=k.get(d);y[d]=f?f.size:0;break}}}let Q=M.slice(0,x),W=y.slice(0,x*h),Y=X.slice(0,x*h),H=(c,s,d,f,I)=>{let p=[];for(let B=0;B<f.length;B++)p[B]=f[B]?.id||"";let $=B=>{let q=c.childrenMap.get(B);if(!q)return [];let j=[];for(let g of q.values())if(s[g]){let A=c.nodeToDepth[g]-1,m=d[g]===1;j.push({key:I[g],value:this.dictionary[c.nodeToVal[g]],fieldId:p[A]||"",children:m?$(g):[],isExpanded:m,isTotal:false,depth:A,hasChildren:c.nodeChildCount[g]>0});}return j};return $(0)},Z=H(this.rowTrie,v,r,this.rowFields,n),G=H(this.colTrie,S,u,this.colFields,t);return {id:e.id,rowTree:Z,colTree:G,cellMatrix:{keys:Q,sums:W,counts:Y},rowIndexMap:this.rowIndexMapCache,columnIndexMap:this.columnIndexMapCache,cardinalityMap:this.cardinalityMap,indexMapsVersion:this.buildVersion}}};var O=new ee,ne=-1;self.onmessage=te=>{let e=te.data;try{if(e.action==="init")O.init(e),self.postMessage({id:e.id,isInitComplete:!0});else if(e.action==="initStart")O.initStart(e);else if(e.action==="initChunk")O.initChunk(e);else if(e.action==="initEnd")O.initEnd(),self.postMessage({id:e.id,isInitComplete:!0});else if(e.action==="filter")O.applyFilter(e),self.postMessage({id:e.id,isFilterComplete:!0});else if(e.action==="reconfigure")O.reconfigure(e),self.postMessage({id:e.id,isReconfigureComplete:!0});else if(e.action==="compute"){let n=O.compute(e),t=[n.cellMatrix.keys.buffer,n.cellMatrix.sums.buffer,n.cellMatrix.counts.buffer];if(n.indexMapsVersion!==void 0&&n.indexMapsVersion===ne){let r={...n,rowIndexMap:void 0,columnIndexMap:void 0,cardinalityMap:void 0,indexMapsOmitted:!0};postMessage(r,t);}else n.indexMapsVersion!==void 0&&(ne=n.indexMapsVersion),postMessage(n,t);}}catch(n){self.postMessage({id:e.id,error:n instanceof Error?n.message:String(n)});}};
1
+ 'use strict';var nt=class{size=1;nodeToParent;nodeToVal;nodeToDepth;nodeChildCount;childrenMap;constructor(t){this.nodeToParent=new Int32Array(t).fill(-1),this.nodeToVal=new Int32Array(t).fill(-1),this.nodeToDepth=new Int32Array(t).fill(0),this.nodeChildCount=new Int32Array(t).fill(0),this.childrenMap=new Map;}expandCapacity(){let t=this.nodeToParent.length*2,e=new Int32Array(t).fill(-1);e.set(this.nodeToParent),this.nodeToParent=e;let n=new Int32Array(t).fill(-1);n.set(this.nodeToVal),this.nodeToVal=n;let r=new Int32Array(t).fill(0);r.set(this.nodeToDepth),this.nodeToDepth=r;let i=new Int32Array(t).fill(0);i.set(this.nodeChildCount),this.nodeChildCount=i;}insert(t,e){let n=0;for(let r=0;r<e;r++){let i=t[r],s=this.childrenMap.get(n);s||(s=new Map,this.childrenMap.set(n,s));let l=s.get(i);l===void 0&&(this.size>=this.nodeToParent.length&&this.expandCapacity(),l=this.size++,this.nodeToParent[l]=n,this.nodeToVal[l]=i,this.nodeToDepth[l]=r+1,this.nodeChildCount[n]++,s.set(i,l)),n=l;}return n}};function X(z,t){if(z.length>=t)return z;let e=new z.constructor(Math.max(t,Math.ceil(z.length*1.5)));return e.set(z),e}function ct(z,t,e){let n=t[0];for(let r=0;r<t.length;r++){let i=t[r]+1,s=r+1<t.length?t[r+1]:e;z.copyWithin(n,i,s),n+=s-i;}}var lt=class{dictionary=[];rowFields=[];colFields=[];dataFields=[];storedColumns={};storedRowCount=0;lastMask=null;isBuilt=false;buildState=null;activeFilters=null;activePrefilter=null;tracking=false;groupRows=new Int32Array(0);groupMap=new Map;rowLive=null;colLive=null;rowTrie;colTrie;cardinalityMap={};rowPathStrs=[];colPathStrs=[];rowIndexMapCache={};columnIndexMapCache={};buildVersion=0;groupCount=0;leafGroupRowIds;leafGroupColIds;leafGroupMeasures;leafGroupCounts;leafGroupMins;leafGroupMaxes;leafGroupDistinctSets=new Map;rowGroupOf=null;init(t){this.dictionary=t.dictionary,this.rowFields=t.rowFields,this.colFields=t.colFields,this.dataFields=t.dataFields,t.workerBootstrap&&t.workerBootstrap.length>0&&console.warn("[PivotGrid Worker] workerBootstrap is deprecated for security reasons. All calculations are executed on the main thread."),this.storedRowCount=t.rowCount,this.storedColumns={};for(let[e,n]of Object.entries(t.columnarData))n.type==="int32"&&(this.storedColumns[e]={type:"int32",array:new Int32Array(n.buffer)}),n.type==="float64"&&(this.storedColumns[e]={type:"float64",array:new Float64Array(n.buffer)});this.lastMask=null,this.activeFilters=this.activePrefilter=null,t.deferBuild?this.isBuilt=false:this.buildFromMask(null);}reconfigure(t){if(this.rowFields=t.rowFields,this.colFields=t.colFields,this.dataFields=t.dataFields,this.appendDictionary(t.dictionaryAppend),t.newColumns)for(let[e,n]of Object.entries(t.newColumns))n.type==="int32"&&(this.storedColumns[e]={type:"int32",array:new Int32Array(n.buffer)}),n.type==="float64"&&(this.storedColumns[e]={type:"float64",array:new Float64Array(n.buffer)});this.buildFromMask(this.lastMask);}initStart(t){this.dictionary=t.dictionary,this.rowFields=t.rowFields,this.colFields=t.colFields,this.dataFields=t.dataFields,t.workerBootstrap&&t.workerBootstrap.length>0&&console.warn("[PivotGrid Worker] workerBootstrap is deprecated for security reasons. All calculations are executed on the main thread."),this.storedRowCount=t.rowCountTotal,this.storedColumns={};for(let[e,n]of Object.entries(t.columnTypes))n==="int32"?this.storedColumns[e]={type:"int32",array:new Int32Array(t.rowCountTotal)}:this.storedColumns[e]={type:"float64",array:new Float64Array(t.rowCountTotal)};this.setFilters((t.filters||[]).map(e=>({fieldId:e.fieldId,filterType:e.filterType,ids:new Set,pending:new Set(e.valueStrings)})),t.prefilter),this.resolveIncrementalFilterStrings(0),this.isBuilt=false,this.beginBuild();}initChunk(t){this.appendDictionary(t.dictionaryAppend)&&this.ensureCardCapacity();for(let[e,n]of Object.entries(t.columns)){let r=this.storedColumns[e];r&&(r.type==="int32"?r.array.set(new Int32Array(n),t.start):r.array.set(new Float64Array(n),t.start));}this.lastMask&&this.computeMaskRange(t.start,t.end),this.processRange(t.start,t.end,this.lastMask);}initEnd(){this.finalizeBuild();}appendDictionary(t){if(!t||t.length===0)return false;let e=this.dictionary.length;for(let n of t)this.dictionary.push(n);return this.resolveIncrementalFilterStrings(e),true}setFilters(t,e){this.activeFilters=t.length>0?t:null,this.activePrefilter=e&&e.conditions.length>0?e:null,this.lastMask=this.activeFilters||this.activePrefilter?new Uint8Array(this.storedRowCount):null;}resolveIncrementalFilterStrings(t){let e=this.activeFilters;if(!e)return;let n=0;for(let r of e)n+=r.pending.size;if(n!==0)for(let r=t;r<this.dictionary.length;r++){let i=this.dictionary[r];for(let s of e)s.pending.delete(i)&&s.ids.add(r);}}computeMaskRange(t,e){let n=this.lastMask;if(n.fill(1,t,e),this.activeFilters)for(let r of this.activeFilters){let i=this.storedColumns[r.fieldId];if(!i||i.type!=="int32")continue;let s=i.array,l=r.ids;if(r.filterType==="exclude")for(let a=t;a<e;a++)n[a]&&l.has(s[a])&&(n[a]=0);else for(let a=t;a<e;a++)n[a]&&!l.has(s[a])&&(n[a]=0);}if(this.activePrefilter)for(let r=t;r<e;r++)n[r]&&!this.evaluatePrefilterGroup(this.activePrefilter,r)&&(n[r]=0);}applyFilter(t){this.setFilters(t.filters.map(e=>({fieldId:e.fieldId,filterType:e.filterType,ids:new Set(e.dictIds),pending:new Set(e.valueStrings)})),t.prefilter),this.lastMask&&this.computeMaskRange(0,this.storedRowCount),this.buildFromMask(this.lastMask);}evaluatePrefilterGroup(t,e){if(!t.conditions||t.conditions.length===0)return true;if(t.logicalOperator==="and"){for(let n of t.conditions)if("logicalOperator"in n){if(!this.evaluatePrefilterGroup(n,e))return false}else if(!this.evaluatePrefilterCondition(n,e))return false;return true}else {for(let n of t.conditions)if("logicalOperator"in n){if(this.evaluatePrefilterGroup(n,e))return true}else if(this.evaluatePrefilterCondition(n,e))return true;return false}}evaluatePrefilterCondition(t,e){let n=this.storedColumns[t.fieldId];if(!n)return true;if(n.type==="float64"){let l=n.array[e],a=Number(t.value);switch(t.operator){case "=":return l===a;case "<>":return l!==a;case ">":return l>a;case ">=":return l>=a;case "<":return l<a;case "<=":return l<=a;case "isnull":return isNaN(l)||l===0;case "isnotnull":return !isNaN(l)&&l!==0;default:return true}}let r=n.array[e],i=this.dictionary[r]||"",s=String(t.value??"");switch(t.operator){case "=":return i===s;case "<>":return i!==s;case ">":return i>s;case ">=":return i>=s;case "<":return i<s;case "<=":return i<=s;case "contains":return i.toLowerCase().includes(s.toLowerCase());case "notcontains":return !i.toLowerCase().includes(s.toLowerCase());case "startswith":return i.toLowerCase().startsWith(s.toLowerCase());case "endswith":return i.toLowerCase().endsWith(s.toLowerCase());case "isnull":return i===""||i==="(Blank)";case "isnotnull":return i!==""&&i!=="(Blank)";case "in":return Array.isArray(t.value)?t.value.map(String).includes(i):true;case "notin":return Array.isArray(t.value)?!t.value.map(String).includes(i):true;default:return true}}buildFromMask(t){this.beginBuild(),this.processRange(0,this.storedRowCount,t),this.finalizeBuild();}beginBuild(){let t=this.storedRowCount,e=this.storedColumns,n=this.rowFields.length,r=this.colFields.length,i=new Array(n);for(let c=0;c<n;c++)i[c]=e[this.rowFields[c].id].array;let s=new Array(r);for(let c=0;c<r;c++)s[c]=e[this.colFields[c].id].array;let l=this.dictionary.length,a=this.rowFields.map(c=>{let v=e[c.id];return v&&v.type==="int32"?new Uint8Array(l):null}),d=this.colFields.map(c=>{let v=e[c.id];return v&&v.type==="int32"?new Uint8Array(l):null});this.rowTrie=new nt(2e5),this.colTrie=new nt(2e5);let w=this.dataFields.length,C=this.dataFields.map(c=>c.summaryType||"sum"),h=C.some(c=>c==="count"||c==="avg"),G=C.some(c=>c==="min"),m=C.some(c=>c==="max"),M=C.some(c=>c==="distinct"),R=new Array(w);for(let c=0;c<w;c++)R[c]=e[this.dataFields[c].id].array;let I=Math.min(t,2e5),u=G?new Float64Array(I*w):new Float64Array(0),p=m?new Float64Array(I*w):new Float64Array(0);this.leafGroupDistinctSets=M?new Map:new Map,G&&u.fill(1/0),m&&p.fill(-1/0),this.buildState={rPath:new Int32Array(n),cPath:new Int32Array(r),rowColArrays:i,colColArrays:s,dataColArrays:R,rowCardSeen:a,colCardSeen:d,rowCardCounts:new Int32Array(n),colCardCounts:new Int32Array(r),summaryTypes:C,allSums:C.every(c=>c==="sum"),needsCounts:h,needsMins:G,needsMaxes:m,groupMap:new Map,leafRowIds:new Int32Array(I),leafColIds:new Int32Array(I),leafMeasures:new Float64Array(I*w),leafCounts:h?new Float64Array(I*w):new Float64Array(0),leafMins:u,leafMaxes:p,rowGroupOf:this.tracking||C.includes("custom")?new Int32Array(t).fill(-1):null,gCount:0};}ensureCardCapacity(){let t=this.buildState;if(!t)return;let e=this.dictionary.length,n=r=>{if(r===null||r.length>=e)return r;let i=new Uint8Array(Math.max(e,r.length*2));return i.set(r),i};for(let r=0;r<t.rowCardSeen.length;r++)t.rowCardSeen[r]=n(t.rowCardSeen[r]);for(let r=0;r<t.colCardSeen.length;r++)t.colCardSeen[r]=n(t.colCardSeen[r]);}processRange(t,e,n){let r=this.buildState,{rPath:i,cPath:s,rowColArrays:l,colColArrays:a,dataColArrays:d,rowCardSeen:w,colCardSeen:C,rowCardCounts:h,colCardCounts:G,summaryTypes:m,allSums:M,needsCounts:R,needsMins:I,needsMaxes:u,groupMap:p,rowGroupOf:c}=r,v=l.length,y=a.length,b=d.length,D=this.rowTrie,E=this.colTrie,W=r.leafRowIds,J=r.leafColIds,_=r.leafMeasures,Q=r.leafCounts,Y=r.leafMins,Z=r.leafMaxes,K=r.gCount;for(let T=t;T<e;T++){if(n&&!n[T])continue;for(let f=0;f<v;f++){let F=l[f][T];i[f]=F;let g=w[f];g!==null&&g[F]===0&&(g[F]=1,h[f]++);}let $=D.insert(i,v);for(let f=0;f<y;f++){let F=a[f][T];s[f]=F;let g=C[f];g!==null&&g[F]===0&&(g[F]=1,G[f]++);}let rt=E.insert(s,y),it=$*67108864+rt,L=p.get(it);if(L===void 0){if(L=K++,p.set(it,L),L>=W.length){let f=L*2,F=new Int32Array(f);F.set(W),W=F;let g=new Int32Array(f);g.set(J),J=g;let H=new Float64Array(f*b);if(H.set(_),_=H,R){let o=new Float64Array(f*b);o.set(Q),Q=o;}if(I){let o=new Float64Array(f*b);o.fill(1/0),o.set(Y),Y=o;}if(u){let o=new Float64Array(f*b);o.fill(-1/0),o.set(Z),Z=o;}}W[L]=$,J[L]=rt;}c!==null&&(c[T]=L);let st=L*b;if(M)for(let f=0;f<b;f++)_[st+f]+=d[f][T];else for(let f=0;f<b;f++){let F=d[f][T],g=st+f;switch(m[f]){case "sum":_[g]+=F;break;case "count":Q[g]+=1;break;case "avg":_[g]+=F,Q[g]+=1;break;case "min":F<Y[g]&&(Y[g]=F);break;case "max":F>Z[g]&&(Z[g]=F);break;case "distinct":{let H=this.leafGroupDistinctSets.get(g);H||(H=new Set,this.leafGroupDistinctSets.set(g,H)),H.add(F);break}default:_[g]+=F;break}}}r.leafRowIds=W,r.leafColIds=J,r.leafMeasures=_,r.leafCounts=Q,r.leafMins=Y,r.leafMaxes=Z,r.gCount=K;}finalizeBuild(){let t=this.buildState,{needsCounts:e,needsMins:n,needsMaxes:r,gCount:i}=t,s=t.dataColArrays.length,l=t.rowColArrays.length,a=t.colColArrays.length;this.groupCount=i,this.leafGroupRowIds=t.leafRowIds.slice(0,i),this.leafGroupColIds=t.leafColIds.slice(0,i),this.leafGroupMeasures=t.leafMeasures.slice(0,i*s),this.leafGroupCounts=e?t.leafCounts.slice(0,i*s):t.leafCounts,this.leafGroupMins=n?t.leafMins.slice(0,i*s):t.leafMins,this.leafGroupMaxes=r?t.leafMaxes.slice(0,i*s):t.leafMaxes,this.rowGroupOf=t.rowGroupOf,this.cardinalityMap={};for(let d=0;d<l;d++)t.rowCardSeen[d]!==null&&(this.cardinalityMap[this.rowFields[d].id]=t.rowCardCounts[d]);for(let d=0;d<a;d++)t.colCardSeen[d]!==null&&(this.cardinalityMap[this.colFields[d].id]=t.colCardCounts[d]);if(this.buildState=null,this.rowLive=this.colLive=null,this.tracking){this.groupMap=t.groupMap;let d=this.groupRows=new Int32Array(i),w=t.rowGroupOf;for(let C=0;C<this.storedRowCount;C++)w[C]>=0&&d[w[C]]++;}this.buildVersion++,this.isBuilt=true,this.rowPathStrs=this.buildPathStrs(this.rowTrie),this.colPathStrs=this.buildPathStrs(this.colTrie),this.rowIndexMapCache=this.buildIndexMap(this.rowPathStrs,null),this.columnIndexMapCache=this.buildIndexMap(this.colPathStrs,null);}buildPathStrs(t,e=[""]){let n=e;for(let r=e.length;r<t.size;r++){let i=t.nodeToParent[r],s=this.dictionary[t.nodeToVal[r]],l=n[i];n[r]=l?l+"|"+s:s;}return n}buildIndexMap(t,e){let n={};for(let r=0;r<t.length;r++)(!e||e[r])&&(n[t[r]]=r);return n}applyTransaction(t){this.tracking||(this.tracking=true,this.buildFromMask(this.lastMask)),this.appendDictionary(t.dictionaryAppend);let{update:e,remove:n}=t,r=e.length,i=this.storedRowCount,s=i+t.addCount,l=this.storedColumns,a=new Set,d=false,w=this.rowGroupOf,C=u=>{let p=w[u];p<0||(w[u]=-1,--this.groupRows[p]===0&&(d=true),a.add(p));};e.forEach(C),n.forEach(C);for(let u in l){let p=l[u],c=t.columns[u];if(!c)throw new Error("transaction: no values for column "+u);let v=p.type==="int32"?new Int32Array(c):new Float64Array(c),y=p.array=X(p.array,s);for(let b=0;b<r;b++)y[e[b]]=v[b];y.set(v.subarray(r),i);}w=this.rowGroupOf=X(w,s),w.fill(-1,i,s);let h=this.lastMask&&(this.lastMask=X(this.lastMask,s));h&&(e.forEach(u=>this.computeMaskRange(u,u+1)),this.computeMaskRange(i,s));let G=this.rowFields.map(u=>l[u.id].array),m=this.colFields.map(u=>l[u.id].array),M=new Int32Array(G.length),R=new Int32Array(m.length),I=u=>{if(h&&!h[u])return;G.forEach((b,D)=>{M[D]=b[u];}),m.forEach((b,D)=>{R[D]=b[u];});let p=this.rowTrie.insert(M,M.length),c=this.colTrie.insert(R,R.length),v=p*67108864+c,y=this.groupMap.get(v);y===void 0&&(this.groupMap.set(v,y=this.groupCount++),(this.leafGroupRowIds=X(this.leafGroupRowIds,y+1))[y]=p,(this.leafGroupColIds=X(this.leafGroupColIds,y+1))[y]=c,this.groupRows=X(this.groupRows,y+1)),this.groupRows[y]++===0&&(d=true),w[u]=y,a.add(y);};e.forEach(I);for(let u=i;u<s;u++)I(u);if(this.storedRowCount=s-n.length,n.length>0){for(let u in l)ct(l[u].array,n,s);ct(w,n,s),h&&ct(h,n,s);}if(this.resumGroups(a),d){let u=0;for(let p=0;p<this.groupCount;p++)this.groupRows[p]===0&&u++;u>4096&&u>this.groupCount-u?this.buildFromMask(this.lastMask):(this.cardinalityMap={},[this.rowLive,this.rowPathStrs,this.rowIndexMapCache]=this.relive(this.rowTrie,this.leafGroupRowIds,this.rowFields,this.rowPathStrs),[this.colLive,this.colPathStrs,this.columnIndexMapCache]=this.relive(this.colTrie,this.leafGroupColIds,this.colFields,this.colPathStrs),this.buildVersion++);}return this.storedRowCount}resumGroups(t){if(t.size===0)return;let e=this.dataFields.length,n=this.dataFields.map(m=>m.summaryType||"sum"),r=this.dataFields.map(m=>this.storedColumns[m.id].array),i=this.groupCount*e,s=this.leafGroupMeasures=X(this.leafGroupMeasures,i),l=n.some(m=>m==="count"||m==="avg")?this.leafGroupCounts=X(this.leafGroupCounts,i):null,a=n.includes("min")?this.leafGroupMins=X(this.leafGroupMins,i):null,d=n.includes("max")?this.leafGroupMaxes=X(this.leafGroupMaxes,i):null,w=this.leafGroupDistinctSets,C=new Uint8Array(this.groupCount),h=0;for(let m of t){C[m]=1,h+=this.groupRows[m];for(let M=m*e;M<(m+1)*e;M++)s[M]=0,l&&(l[M]=0),a&&(a[M]=1/0),d&&(d[M]=-1/0),w.delete(M);}let G=this.rowGroupOf;for(let m=0;h>0&&m<this.storedRowCount;m++){let M=G[m];if(!(M<0||!C[M])){h--;for(let R=0;R<e;R++){let I=r[R][m],u=M*e+R;switch(n[R]){case "count":l[u]++;break;case "avg":s[u]+=I,l[u]++;break;case "min":I<a[u]&&(a[u]=I);break;case "max":I>d[u]&&(d[u]=I);break;case "distinct":{let p=w.get(u);p||w.set(u,p=new Set),p.add(I);break}default:s[u]+=I;}}}}}relive(t,e,n,r){let i=new Uint8Array(t.size);i[0]=1;for(let a=0;a<this.groupCount;a++)if(this.groupRows[a]!==0)for(let d=e[a];!i[d];d=t.nodeToParent[d])i[d]=1;let s=n.map(()=>new Set);t.nodeChildCount.fill(0,0,t.size);for(let a=1;a<t.size;a++)i[a]&&(t.nodeChildCount[t.nodeToParent[a]]++,s[t.nodeToDepth[a]-1]?.add(t.nodeToVal[a]));n.forEach((a,d)=>{this.cardinalityMap[a.id]=s[d].size;});let l=this.buildPathStrs(t,r);return [i,l,this.buildIndexMap(l,i)]}compute(t){this.isBuilt||this.buildFromMask(this.lastMask);let e=this.rowPathStrs,n=this.colPathStrs,r=new Uint8Array(this.rowTrie.size),i=new Set(t.expandedPaths),s=i.has(".*")||i.has("*");for(let o=0;o<this.rowTrie.size;o++)r[o]=s||i.has(e[o])?1:0;let l=new Uint8Array(this.colTrie.size),a=new Set(t.expandedColPaths),d=a.has(".*")||a.has("*");for(let o=0;o<this.colTrie.size;o++)l[o]=d||a.has(n[o])?1:0;let w=new Uint8Array(this.rowTrie.size);w[0]=1;for(let o=1;o<this.rowTrie.size;o++){let S=this.rowTrie.nodeToParent[o];(S===0||r[S])&&(!this.rowLive||this.rowLive[o])&&(w[o]=1);}let C=new Uint8Array(this.colTrie.size);C[0]=1;for(let o=1;o<this.colTrie.size;o++){let S=this.colTrie.nodeToParent[o];(S===0||l[S])&&(!this.colLive||this.colLive[o])&&(C[o]=1);}let h=this.dataFields.length,G=this.dataFields.map(o=>o.summaryType||"sum"),m=this.leafGroupMins.length>0,M=this.leafGroupMaxes.length>0,R=this.leafGroupCounts.length>0,I=this.leafGroupDistinctSets.size>0,u=new Map,p=0,c=1e4,v=new Float64Array(c),y=new Float64Array(c*h),b=new Int32Array(c*h),D=R?new Float64Array(c*h):null,E=m?new Float64Array(c*h):null,W=M?new Float64Array(c*h):null,J=I?new Map:new Map;E&&E.fill(1/0),W&&W.fill(-1/0);let _=new Int32Array(this.rowFields.length+1),Q=new Int32Array(this.colFields.length+1),Y=(o,S,A,O)=>{let tt=0,U=o;for(;U!==-1;)A[U]&&(O[tt++]=U),U=S.nodeToParent[U];return tt},Z=this.rowGroupOf!==null&&G.includes("custom"),K=Z?new Int32Array(this.groupCount+1):null,T=Z?new Int32Array(Math.max(16,this.groupCount*4)):null,$=0,rt=this.tracking?this.groupRows:null;for(let o=0;o<this.groupCount;o++){if(rt!==null&&rt[o]===0){K!==null&&(K[o+1]=$);continue}let S=this.leafGroupRowIds[o],A=this.leafGroupColIds[o],O=Y(S,this.rowTrie,w,_),tt=Y(A,this.colTrie,C,Q);for(let U=0;U<O;U++){let ot=_[U];for(let j=0;j<tt;j++){let at=Q[j],et=ot*67108864+at,P=u.get(et);if(P===void 0){if(P=p++,u.set(et,P),P>=v.length){let k=P*2,x=new Float64Array(k);x.set(v),v=x;let V=new Float64Array(k*h);V.set(y),y=V;let N=new Int32Array(k*h);if(N.set(b),b=N,D){let B=new Float64Array(k*h);B.set(D),D=B;}if(E){let B=new Float64Array(k*h);B.fill(1/0),B.set(E),E=B;}if(W){let B=new Float64Array(k*h);B.fill(-1/0),B.set(W),W=B;}}v[P]=et;}if(T!==null){if($>=T.length){let k=new Int32Array(T.length*2);k.set(T),T=k;}T[$++]=P;}for(let k=0;k<h;k++){let x=P*h+k,V=o*h+k;switch(G[k]){case "sum":y[x]+=this.leafGroupMeasures[V];break;case "count":y[x]+=this.leafGroupCounts[V];break;case "avg":y[x]+=this.leafGroupMeasures[V],D[x]+=this.leafGroupCounts[V];break;case "min":{let N=this.leafGroupMins[V];N<E[x]&&(E[x]=N);break}case "max":{let N=this.leafGroupMaxes[V];N>W[x]&&(W[x]=N);break}case "distinct":{let N=this.leafGroupDistinctSets.get(V);if(N){let B=J.get(x);B||(B=new Set,J.set(x,B));for(let ft of N)B.add(ft);}break}default:y[x]+=this.leafGroupMeasures[V];break}b[x]+=1;}}}K!==null&&(K[o+1]=$);}for(let o=0;o<p;o++)for(let S=0;S<h;S++){let A=o*h+S;switch(G[S]){case "avg":y[A]=D[A]>0?y[A]/D[A]:0;break;case "min":y[A]=E[A]!==1/0?E[A]:0;break;case "max":y[A]=W[A]!==-1/0?W[A]:0;break;case "distinct":{let O=J.get(A);y[A]=O?O.size:0;break}}}let it=v.slice(0,p),L=y.slice(0,p*h),st=b.slice(0,p*h),f=(o,S,A,O,tt)=>{let U=[];for(let j=0;j<O.length;j++)U[j]=O[j]?.id||"";let ot=j=>{let at=o.childrenMap.get(j);if(!at)return [];let et=[];for(let P of at.values())if(S[P]){let k=o.nodeToDepth[P]-1,x=A[P]===1;et.push({key:tt[P],value:this.dictionary[o.nodeToVal[P]],fieldId:U[k]||"",children:x?ot(P):[],isExpanded:x,isTotal:false,depth:k,hasChildren:o.nodeChildCount[P]>0});}return et};return ot(0)},F;if(this.rowGroupOf!==null&&K!==null&&T!==null){let o=this.storedRowCount,S={};for(let A=0;A<h;A++){if(G[A]!=="custom")continue;let O=this.dataFields[A].id;S[O]=this.storedColumns[O].array.slice(0,o);}F={rowGroupOf:this.rowGroupOf.slice(0,o),groupCellOffsets:K,groupCells:T.slice(0,$),values:S};}let g=f(this.rowTrie,w,r,this.rowFields,e),H=f(this.colTrie,C,l,this.colFields,n);return {id:t.id,rowTree:g,colTree:H,cellMatrix:{keys:it,sums:L,counts:st},customSummary:F,rowIndexMap:this.rowIndexMapCache,columnIndexMap:this.columnIndexMapCache,cardinalityMap:this.cardinalityMap,indexMapsVersion:this.buildVersion}}};var q=new lt,dt=-1;self.onmessage=z=>{let t=z.data;try{if(t.action==="init")q.init(t),self.postMessage({id:t.id,isInitComplete:!0});else if(t.action==="initStart")q.initStart(t);else if(t.action==="initChunk")q.initChunk(t);else if(t.action==="initEnd")q.initEnd(),self.postMessage({id:t.id,isInitComplete:!0});else if(t.action==="filter")q.applyFilter(t),self.postMessage({id:t.id,isFilterComplete:!0});else if(t.action==="reconfigure")q.reconfigure(t),self.postMessage({id:t.id,isReconfigureComplete:!0});else if(t.action==="transaction")self.postMessage({id:t.id,isTransactionComplete:!0,rowCount:q.applyTransaction(t)});else if(t.action==="compute"){let e=q.compute(t),n=[e.cellMatrix.keys.buffer,e.cellMatrix.sums.buffer,e.cellMatrix.counts.buffer];if(e.indexMapsVersion!==void 0&&e.indexMapsVersion===dt){let r={...e,rowIndexMap:void 0,columnIndexMap:void 0,cardinalityMap:void 0,indexMapsOmitted:!0};postMessage(r,n);}else e.indexMapsVersion!==void 0&&(dt=e.indexMapsVersion),postMessage(e,n);}}catch(e){self.postMessage({id:t.id,error:e instanceof Error?e.message:String(e)});}};
@@ -1 +1 @@
1
- var J=class{size=1;nodeToParent;nodeToVal;nodeToDepth;nodeChildCount;childrenMap;constructor(e){this.nodeToParent=new Int32Array(e).fill(-1),this.nodeToVal=new Int32Array(e).fill(-1),this.nodeToDepth=new Int32Array(e).fill(0),this.nodeChildCount=new Int32Array(e).fill(0),this.childrenMap=new Map;}expandCapacity(){let e=this.nodeToParent.length*2,n=new Int32Array(e).fill(-1);n.set(this.nodeToParent),this.nodeToParent=n;let t=new Int32Array(e).fill(-1);t.set(this.nodeToVal),this.nodeToVal=t;let r=new Int32Array(e).fill(0);r.set(this.nodeToDepth),this.nodeToDepth=r;let i=new Int32Array(e).fill(0);i.set(this.nodeChildCount),this.nodeChildCount=i;}insert(e,n){let t=0;for(let r=0;r<n;r++){let i=e[r],a=this.childrenMap.get(t);a||(a=new Map,this.childrenMap.set(t,a));let u=a.get(i);u===void 0&&(this.size>=this.nodeToParent.length&&this.expandCapacity(),u=this.size++,this.nodeToParent[u]=t,this.nodeToVal[u]=i,this.nodeToDepth[u]=r+1,this.nodeChildCount[t]++,a.set(i,u)),t=u;}return t}};var ee=class{dictionary=[];rowFields=[];colFields=[];dataFields=[];storedColumns={};storedRowCount=0;lastMask=null;isBuilt=false;buildState=null;incrementalFilters=null;incrementalPrefilter=null;rowTrie;colTrie;cardinalityMap={};rowPathStrs=[];colPathStrs=[];rowIndexMapCache={};columnIndexMapCache={};buildVersion=0;groupCount=0;leafGroupRowIds;leafGroupColIds;leafGroupMeasures;leafGroupCounts;leafGroupMins;leafGroupMaxes;leafGroupDistinctSets=new Map;init(e){this.dictionary=e.dictionary,this.rowFields=e.rowFields,this.colFields=e.colFields,this.dataFields=e.dataFields,e.workerBootstrap&&e.workerBootstrap.length>0&&console.warn("[PivotGrid Worker] workerBootstrap is deprecated for security reasons. All calculations are executed on the main thread."),this.storedRowCount=e.rowCount,this.storedColumns={};for(let[n,t]of Object.entries(e.columnarData))t.type==="int32"&&(this.storedColumns[n]={type:"int32",array:new Int32Array(t.buffer)}),t.type==="float64"&&(this.storedColumns[n]={type:"float64",array:new Float64Array(t.buffer)});this.lastMask=null,e.deferBuild?this.isBuilt=false:this.buildFromMask(null);}reconfigure(e){if(this.rowFields=e.rowFields,this.colFields=e.colFields,this.dataFields=e.dataFields,e.dictionaryAppend&&e.dictionaryAppend.length>0)for(let n of e.dictionaryAppend)this.dictionary.push(n);if(e.newColumns)for(let[n,t]of Object.entries(e.newColumns))t.type==="int32"&&(this.storedColumns[n]={type:"int32",array:new Int32Array(t.buffer)}),t.type==="float64"&&(this.storedColumns[n]={type:"float64",array:new Float64Array(t.buffer)});this.buildFromMask(this.lastMask);}initStart(e){this.dictionary=e.dictionary,this.rowFields=e.rowFields,this.colFields=e.colFields,this.dataFields=e.dataFields,e.workerBootstrap&&e.workerBootstrap.length>0&&console.warn("[PivotGrid Worker] workerBootstrap is deprecated for security reasons. All calculations are executed on the main thread."),this.storedRowCount=e.rowCountTotal,this.storedColumns={};for(let[n,t]of Object.entries(e.columnTypes))t==="int32"?this.storedColumns[n]={type:"int32",array:new Int32Array(e.rowCountTotal)}:this.storedColumns[n]={type:"float64",array:new Float64Array(e.rowCountTotal)};this.incrementalFilters=e.filters&&e.filters.length>0?e.filters.map(n=>({fieldId:n.fieldId,filterType:n.filterType,ids:new Set,pending:new Set(n.valueStrings)})):null,this.incrementalPrefilter=e.prefilter&&e.prefilter.conditions.length>0?e.prefilter:null,this.lastMask=this.incrementalFilters||this.incrementalPrefilter?new Uint8Array(e.rowCountTotal):null,this.resolveIncrementalFilterStrings(0),this.isBuilt=false,this.beginBuild();}initChunk(e){if(e.dictionaryAppend&&e.dictionaryAppend.length>0){let n=this.dictionary.length;for(let t of e.dictionaryAppend)this.dictionary.push(t);this.resolveIncrementalFilterStrings(n),this.ensureCardCapacity();}for(let[n,t]of Object.entries(e.columns)){let r=this.storedColumns[n];r&&(r.type==="int32"?r.array.set(new Int32Array(t),e.start):r.array.set(new Float64Array(t),e.start));}this.lastMask&&this.computeMaskRange(e.start,e.end),this.processRange(e.start,e.end,this.lastMask);}initEnd(){this.incrementalFilters=null,this.incrementalPrefilter=null,this.finalizeBuild();}resolveIncrementalFilterStrings(e){let n=this.incrementalFilters;if(!n)return;let t=0;for(let r of n)t+=r.pending.size;if(t!==0)for(let r=e;r<this.dictionary.length;r++){let i=this.dictionary[r];for(let a of n)a.pending.delete(i)&&a.ids.add(r);}}computeMaskRange(e,n){let t=this.lastMask;if(t.fill(1,e,n),this.incrementalFilters)for(let r of this.incrementalFilters){let i=this.storedColumns[r.fieldId];if(!i||i.type!=="int32")continue;let a=i.array,u=r.ids;if(r.filterType==="exclude")for(let o=e;o<n;o++)t[o]&&u.has(a[o])&&(t[o]=0);else for(let o=e;o<n;o++)t[o]&&!u.has(a[o])&&(t[o]=0);}if(this.incrementalPrefilter)for(let r=e;r<n;r++)t[r]&&!this.evaluatePrefilterGroup(this.incrementalPrefilter,r)&&(t[r]=0);}applyFilter(e){if(e.filters.length===0&&!e.prefilter){this.lastMask=null,this.buildFromMask(null);return}let n=this.storedRowCount,t=new Uint8Array(n);t.fill(1);for(let r of e.filters){let i=this.storedColumns[r.fieldId];if(!i||i.type!=="int32")continue;let a=i.array,u=new Set(r.dictIds);if(r.filterType==="exclude")for(let o=0;o<n;o++)t[o]&&u.has(a[o])&&(t[o]=0);else for(let o=0;o<n;o++)t[o]&&!u.has(a[o])&&(t[o]=0);}if(e.prefilter&&e.prefilter.conditions.length>0)for(let r=0;r<n;r++)t[r]&&!this.evaluatePrefilterGroup(e.prefilter,r)&&(t[r]=0);this.lastMask=t,this.buildFromMask(t);}evaluatePrefilterGroup(e,n){if(!e.conditions||e.conditions.length===0)return true;if(e.logicalOperator==="and"){for(let t of e.conditions)if("logicalOperator"in t){if(!this.evaluatePrefilterGroup(t,n))return false}else if(!this.evaluatePrefilterCondition(t,n))return false;return true}else {for(let t of e.conditions)if("logicalOperator"in t){if(this.evaluatePrefilterGroup(t,n))return true}else if(this.evaluatePrefilterCondition(t,n))return true;return false}}evaluatePrefilterCondition(e,n){let t=this.storedColumns[e.fieldId];if(!t)return true;if(t.type==="float64"){let u=t.array[n],o=Number(e.value);switch(e.operator){case "=":return u===o;case "<>":return u!==o;case ">":return u>o;case ">=":return u>=o;case "<":return u<o;case "<=":return u<=o;case "isnull":return isNaN(u)||u===0;case "isnotnull":return !isNaN(u)&&u!==0;default:return true}}let r=t.array[n],i=this.dictionary[r]||"",a=String(e.value??"");switch(e.operator){case "=":return i===a;case "<>":return i!==a;case ">":return i>a;case ">=":return i>=a;case "<":return i<a;case "<=":return i<=a;case "contains":return i.toLowerCase().includes(a.toLowerCase());case "notcontains":return !i.toLowerCase().includes(a.toLowerCase());case "startswith":return i.toLowerCase().startsWith(a.toLowerCase());case "endswith":return i.toLowerCase().endsWith(a.toLowerCase());case "isnull":return i===""||i==="(Blank)";case "isnotnull":return i!==""&&i!=="(Blank)";case "in":return Array.isArray(e.value)?e.value.map(String).includes(i):true;case "notin":return Array.isArray(e.value)?!e.value.map(String).includes(i):true;default:return true}}buildFromMask(e){this.beginBuild(),this.processRange(0,this.storedRowCount,e),this.finalizeBuild();}beginBuild(){let e=this.storedRowCount,n=this.storedColumns,t=this.rowFields.length,r=this.colFields.length,i=new Array(t);for(let l=0;l<t;l++)i[l]=n[this.rowFields[l].id].array;let a=new Array(r);for(let l=0;l<r;l++)a[l]=n[this.colFields[l].id].array;let u=this.dictionary.length,o=this.rowFields.map(l=>{let M=n[l.id];return M&&M.type==="int32"?new Uint8Array(u):null}),w=this.colFields.map(l=>{let M=n[l.id];return M&&M.type==="int32"?new Uint8Array(u):null});this.rowTrie=new J(2e5),this.colTrie=new J(2e5);let v=this.dataFields.length,S=this.dataFields.map(l=>l.summaryType||"sum"),h=S.some(l=>l==="count"||l==="avg"),D=S.some(l=>l==="min"),L=S.some(l=>l==="max"),K=S.some(l=>l==="distinct"),_=new Array(v);for(let l=0;l<v;l++)_[l]=n[this.dataFields[l].id].array;let R=Math.min(e,2e5),N=D?new Float64Array(R*v):new Float64Array(0),x=L?new Float64Array(R*v):new Float64Array(0);this.leafGroupDistinctSets=K?new Map:new Map,D&&N.fill(1/0),L&&x.fill(-1/0),this.buildState={rPath:new Int32Array(t),cPath:new Int32Array(r),rowColArrays:i,colColArrays:a,dataColArrays:_,rowCardSeen:o,colCardSeen:w,rowCardCounts:new Int32Array(t),colCardCounts:new Int32Array(r),summaryTypes:S,allSums:S.every(l=>l==="sum"),needsCounts:h,needsMins:D,needsMaxes:L,groupMap:new Map,leafRowIds:new Int32Array(R),leafColIds:new Int32Array(R),leafMeasures:new Float64Array(R*v),leafCounts:h?new Float64Array(R*v):new Float64Array(0),leafMins:N,leafMaxes:x,gCount:0};}ensureCardCapacity(){let e=this.buildState;if(!e)return;let n=this.dictionary.length,t=r=>{if(r===null||r.length>=n)return r;let i=new Uint8Array(Math.max(n,r.length*2));return i.set(r),i};for(let r=0;r<e.rowCardSeen.length;r++)e.rowCardSeen[r]=t(e.rowCardSeen[r]);for(let r=0;r<e.colCardSeen.length;r++)e.colCardSeen[r]=t(e.colCardSeen[r]);}processRange(e,n,t){let r=this.buildState,{rPath:i,cPath:a,rowColArrays:u,colColArrays:o,dataColArrays:w,rowCardSeen:v,colCardSeen:S,rowCardCounts:h,colCardCounts:D,summaryTypes:L,allSums:K,needsCounts:_,needsMins:R,needsMaxes:N,groupMap:x}=r,l=u.length,M=o.length,y=w.length,X=this.rowTrie,V=this.colTrie,C=r.leafRowIds,b=r.leafColIds,k=r.leafMeasures,z=r.leafCounts,U=r.leafMins,E=r.leafMaxes,Q=r.gCount;for(let W=e;W<n;W++){if(t&&!t[W])continue;for(let s=0;s<l;s++){let d=u[s][W];i[s]=d;let f=v[s];f!==null&&f[d]===0&&(f[d]=1,h[s]++);}let Y=X.insert(i,l);for(let s=0;s<M;s++){let d=o[s][W];a[s]=d;let f=S[s];f!==null&&f[d]===0&&(f[d]=1,D[s]++);}let H=V.insert(a,M),Z=Y*67108864+H,G=x.get(Z);if(G===void 0){if(G=Q++,x.set(Z,G),G>=C.length){let s=G*2,d=new Int32Array(s);d.set(C),C=d;let f=new Int32Array(s);f.set(b),b=f;let I=new Float64Array(s*y);if(I.set(k),k=I,_){let p=new Float64Array(s*y);p.set(z),z=p;}if(R){let p=new Float64Array(s*y);p.fill(1/0),p.set(U),U=p;}if(N){let p=new Float64Array(s*y);p.fill(-1/0),p.set(E),E=p;}}C[G]=Y,b[G]=H;}let c=G*y;if(K)for(let s=0;s<y;s++)k[c+s]+=w[s][W];else for(let s=0;s<y;s++){let d=w[s][W],f=c+s;switch(L[s]){case "sum":k[f]+=d;break;case "count":z[f]+=1;break;case "avg":k[f]+=d,z[f]+=1;break;case "min":d<U[f]&&(U[f]=d);break;case "max":d>E[f]&&(E[f]=d);break;case "distinct":{let I=this.leafGroupDistinctSets.get(f);I||(I=new Set,this.leafGroupDistinctSets.set(f,I)),I.add(d);break}default:k[f]+=d;break}}}r.leafRowIds=C,r.leafColIds=b,r.leafMeasures=k,r.leafCounts=z,r.leafMins=U,r.leafMaxes=E,r.gCount=Q;}finalizeBuild(){let e=this.buildState,{needsCounts:n,needsMins:t,needsMaxes:r,gCount:i}=e,a=e.dataColArrays.length,u=e.rowColArrays.length,o=e.colColArrays.length;this.groupCount=i,this.leafGroupRowIds=e.leafRowIds.slice(0,i),this.leafGroupColIds=e.leafColIds.slice(0,i),this.leafGroupMeasures=e.leafMeasures.slice(0,i*a),this.leafGroupCounts=n?e.leafCounts.slice(0,i*a):e.leafCounts,this.leafGroupMins=t?e.leafMins.slice(0,i*a):e.leafMins,this.leafGroupMaxes=r?e.leafMaxes.slice(0,i*a):e.leafMaxes,this.cardinalityMap={};for(let w=0;w<u;w++)e.rowCardSeen[w]!==null&&(this.cardinalityMap[this.rowFields[w].id]=e.rowCardCounts[w]);for(let w=0;w<o;w++)e.colCardSeen[w]!==null&&(this.cardinalityMap[this.colFields[w].id]=e.colCardCounts[w]);this.buildState=null,this.buildVersion++,this.isBuilt=true,this.rowPathStrs=this.buildPathStrs(this.rowTrie),this.colPathStrs=this.buildPathStrs(this.colTrie),this.rowIndexMapCache=this.buildIndexMap(this.rowPathStrs),this.columnIndexMapCache=this.buildIndexMap(this.colPathStrs);}buildPathStrs(e){let n=new Array(e.size);n[0]="";for(let t=1;t<e.size;t++){let r=e.nodeToParent[t],i=this.dictionary[e.nodeToVal[t]],a=n[r];n[t]=a?a+"|"+i:i;}return n}buildIndexMap(e){let n={};for(let t=0;t<e.length;t++)n[e[t]]=t;return n}compute(e){this.isBuilt||this.buildFromMask(this.lastMask);let n=this.rowPathStrs,t=this.colPathStrs,r=new Uint8Array(this.rowTrie.size),i=new Set(e.expandedPaths),a=i.has(".*")||i.has("*");for(let c=0;c<this.rowTrie.size;c++)r[c]=a||i.has(n[c])?1:0;let u=new Uint8Array(this.colTrie.size),o=new Set(e.expandedColPaths),w=o.has(".*")||o.has("*");for(let c=0;c<this.colTrie.size;c++)u[c]=w||o.has(t[c])?1:0;let v=new Uint8Array(this.rowTrie.size);v[0]=1;for(let c=1;c<this.rowTrie.size;c++){let s=this.rowTrie.nodeToParent[c];(s===0||r[s])&&(v[c]=1);}let S=new Uint8Array(this.colTrie.size);S[0]=1;for(let c=1;c<this.colTrie.size;c++){let s=this.colTrie.nodeToParent[c];(s===0||u[s])&&(S[c]=1);}let h=this.dataFields.length,D=this.dataFields.map(c=>c.summaryType||"sum"),L=this.leafGroupMins.length>0,K=this.leafGroupMaxes.length>0,_=this.leafGroupCounts.length>0,R=this.leafGroupDistinctSets.size>0,N=new Map,x=0,l=1e4,M=new Float64Array(l),y=new Float64Array(l*h),X=new Int32Array(l*h),V=_?new Float64Array(l*h):null,C=L?new Float64Array(l*h):null,b=K?new Float64Array(l*h):null,k=R?new Map:new Map;C&&C.fill(1/0),b&&b.fill(-1/0);let z=new Int32Array(this.rowFields.length+1),U=new Int32Array(this.colFields.length+1),E=(c,s,d,f)=>{let I=0,p=c;for(;p!==-1;)d[p]&&(f[I++]=p),p=s.nodeToParent[p];return I};for(let c=0;c<this.groupCount;c++){let s=this.leafGroupRowIds[c],d=this.leafGroupColIds[c],f=E(s,this.rowTrie,v,z),I=E(d,this.colTrie,S,U);for(let p=0;p<f;p++){let $=z[p];for(let B=0;B<I;B++){let q=U[B],j=$*67108864+q,g=N.get(j);if(g===void 0){if(g=x++,N.set(j,g),g>=M.length){let A=g*2,m=new Float64Array(A);m.set(M),M=m;let P=new Float64Array(A*h);P.set(y),y=P;let T=new Int32Array(A*h);if(T.set(X),X=T,V){let F=new Float64Array(A*h);F.set(V),V=F;}if(C){let F=new Float64Array(A*h);F.fill(1/0),F.set(C),C=F;}if(b){let F=new Float64Array(A*h);F.fill(-1/0),F.set(b),b=F;}}M[g]=j;}for(let A=0;A<h;A++){let m=g*h+A,P=c*h+A;switch(D[A]){case "sum":y[m]+=this.leafGroupMeasures[P];break;case "count":y[m]+=this.leafGroupCounts[P];break;case "avg":y[m]+=this.leafGroupMeasures[P],V[m]+=this.leafGroupCounts[P];break;case "min":{let T=this.leafGroupMins[P];T<C[m]&&(C[m]=T);break}case "max":{let T=this.leafGroupMaxes[P];T>b[m]&&(b[m]=T);break}case "distinct":{let T=this.leafGroupDistinctSets.get(P);if(T){let F=k.get(m);F||(F=new Set,k.set(m,F));for(let ie of T)F.add(ie);}break}default:y[m]+=this.leafGroupMeasures[P];break}X[m]+=1;}}}}for(let c=0;c<x;c++)for(let s=0;s<h;s++){let d=c*h+s;switch(D[s]){case "avg":y[d]=V[d]>0?y[d]/V[d]:0;break;case "min":y[d]=C[d]!==1/0?C[d]:0;break;case "max":y[d]=b[d]!==-1/0?b[d]:0;break;case "distinct":{let f=k.get(d);y[d]=f?f.size:0;break}}}let Q=M.slice(0,x),W=y.slice(0,x*h),Y=X.slice(0,x*h),H=(c,s,d,f,I)=>{let p=[];for(let B=0;B<f.length;B++)p[B]=f[B]?.id||"";let $=B=>{let q=c.childrenMap.get(B);if(!q)return [];let j=[];for(let g of q.values())if(s[g]){let A=c.nodeToDepth[g]-1,m=d[g]===1;j.push({key:I[g],value:this.dictionary[c.nodeToVal[g]],fieldId:p[A]||"",children:m?$(g):[],isExpanded:m,isTotal:false,depth:A,hasChildren:c.nodeChildCount[g]>0});}return j};return $(0)},Z=H(this.rowTrie,v,r,this.rowFields,n),G=H(this.colTrie,S,u,this.colFields,t);return {id:e.id,rowTree:Z,colTree:G,cellMatrix:{keys:Q,sums:W,counts:Y},rowIndexMap:this.rowIndexMapCache,columnIndexMap:this.columnIndexMapCache,cardinalityMap:this.cardinalityMap,indexMapsVersion:this.buildVersion}}};var O=new ee,ne=-1;self.onmessage=te=>{let e=te.data;try{if(e.action==="init")O.init(e),self.postMessage({id:e.id,isInitComplete:!0});else if(e.action==="initStart")O.initStart(e);else if(e.action==="initChunk")O.initChunk(e);else if(e.action==="initEnd")O.initEnd(),self.postMessage({id:e.id,isInitComplete:!0});else if(e.action==="filter")O.applyFilter(e),self.postMessage({id:e.id,isFilterComplete:!0});else if(e.action==="reconfigure")O.reconfigure(e),self.postMessage({id:e.id,isReconfigureComplete:!0});else if(e.action==="compute"){let n=O.compute(e),t=[n.cellMatrix.keys.buffer,n.cellMatrix.sums.buffer,n.cellMatrix.counts.buffer];if(n.indexMapsVersion!==void 0&&n.indexMapsVersion===ne){let r={...n,rowIndexMap:void 0,columnIndexMap:void 0,cardinalityMap:void 0,indexMapsOmitted:!0};postMessage(r,t);}else n.indexMapsVersion!==void 0&&(ne=n.indexMapsVersion),postMessage(n,t);}}catch(n){self.postMessage({id:e.id,error:n instanceof Error?n.message:String(n)});}};
1
+ var nt=class{size=1;nodeToParent;nodeToVal;nodeToDepth;nodeChildCount;childrenMap;constructor(t){this.nodeToParent=new Int32Array(t).fill(-1),this.nodeToVal=new Int32Array(t).fill(-1),this.nodeToDepth=new Int32Array(t).fill(0),this.nodeChildCount=new Int32Array(t).fill(0),this.childrenMap=new Map;}expandCapacity(){let t=this.nodeToParent.length*2,e=new Int32Array(t).fill(-1);e.set(this.nodeToParent),this.nodeToParent=e;let n=new Int32Array(t).fill(-1);n.set(this.nodeToVal),this.nodeToVal=n;let r=new Int32Array(t).fill(0);r.set(this.nodeToDepth),this.nodeToDepth=r;let i=new Int32Array(t).fill(0);i.set(this.nodeChildCount),this.nodeChildCount=i;}insert(t,e){let n=0;for(let r=0;r<e;r++){let i=t[r],s=this.childrenMap.get(n);s||(s=new Map,this.childrenMap.set(n,s));let l=s.get(i);l===void 0&&(this.size>=this.nodeToParent.length&&this.expandCapacity(),l=this.size++,this.nodeToParent[l]=n,this.nodeToVal[l]=i,this.nodeToDepth[l]=r+1,this.nodeChildCount[n]++,s.set(i,l)),n=l;}return n}};function X(z,t){if(z.length>=t)return z;let e=new z.constructor(Math.max(t,Math.ceil(z.length*1.5)));return e.set(z),e}function ct(z,t,e){let n=t[0];for(let r=0;r<t.length;r++){let i=t[r]+1,s=r+1<t.length?t[r+1]:e;z.copyWithin(n,i,s),n+=s-i;}}var lt=class{dictionary=[];rowFields=[];colFields=[];dataFields=[];storedColumns={};storedRowCount=0;lastMask=null;isBuilt=false;buildState=null;activeFilters=null;activePrefilter=null;tracking=false;groupRows=new Int32Array(0);groupMap=new Map;rowLive=null;colLive=null;rowTrie;colTrie;cardinalityMap={};rowPathStrs=[];colPathStrs=[];rowIndexMapCache={};columnIndexMapCache={};buildVersion=0;groupCount=0;leafGroupRowIds;leafGroupColIds;leafGroupMeasures;leafGroupCounts;leafGroupMins;leafGroupMaxes;leafGroupDistinctSets=new Map;rowGroupOf=null;init(t){this.dictionary=t.dictionary,this.rowFields=t.rowFields,this.colFields=t.colFields,this.dataFields=t.dataFields,t.workerBootstrap&&t.workerBootstrap.length>0&&console.warn("[PivotGrid Worker] workerBootstrap is deprecated for security reasons. All calculations are executed on the main thread."),this.storedRowCount=t.rowCount,this.storedColumns={};for(let[e,n]of Object.entries(t.columnarData))n.type==="int32"&&(this.storedColumns[e]={type:"int32",array:new Int32Array(n.buffer)}),n.type==="float64"&&(this.storedColumns[e]={type:"float64",array:new Float64Array(n.buffer)});this.lastMask=null,this.activeFilters=this.activePrefilter=null,t.deferBuild?this.isBuilt=false:this.buildFromMask(null);}reconfigure(t){if(this.rowFields=t.rowFields,this.colFields=t.colFields,this.dataFields=t.dataFields,this.appendDictionary(t.dictionaryAppend),t.newColumns)for(let[e,n]of Object.entries(t.newColumns))n.type==="int32"&&(this.storedColumns[e]={type:"int32",array:new Int32Array(n.buffer)}),n.type==="float64"&&(this.storedColumns[e]={type:"float64",array:new Float64Array(n.buffer)});this.buildFromMask(this.lastMask);}initStart(t){this.dictionary=t.dictionary,this.rowFields=t.rowFields,this.colFields=t.colFields,this.dataFields=t.dataFields,t.workerBootstrap&&t.workerBootstrap.length>0&&console.warn("[PivotGrid Worker] workerBootstrap is deprecated for security reasons. All calculations are executed on the main thread."),this.storedRowCount=t.rowCountTotal,this.storedColumns={};for(let[e,n]of Object.entries(t.columnTypes))n==="int32"?this.storedColumns[e]={type:"int32",array:new Int32Array(t.rowCountTotal)}:this.storedColumns[e]={type:"float64",array:new Float64Array(t.rowCountTotal)};this.setFilters((t.filters||[]).map(e=>({fieldId:e.fieldId,filterType:e.filterType,ids:new Set,pending:new Set(e.valueStrings)})),t.prefilter),this.resolveIncrementalFilterStrings(0),this.isBuilt=false,this.beginBuild();}initChunk(t){this.appendDictionary(t.dictionaryAppend)&&this.ensureCardCapacity();for(let[e,n]of Object.entries(t.columns)){let r=this.storedColumns[e];r&&(r.type==="int32"?r.array.set(new Int32Array(n),t.start):r.array.set(new Float64Array(n),t.start));}this.lastMask&&this.computeMaskRange(t.start,t.end),this.processRange(t.start,t.end,this.lastMask);}initEnd(){this.finalizeBuild();}appendDictionary(t){if(!t||t.length===0)return false;let e=this.dictionary.length;for(let n of t)this.dictionary.push(n);return this.resolveIncrementalFilterStrings(e),true}setFilters(t,e){this.activeFilters=t.length>0?t:null,this.activePrefilter=e&&e.conditions.length>0?e:null,this.lastMask=this.activeFilters||this.activePrefilter?new Uint8Array(this.storedRowCount):null;}resolveIncrementalFilterStrings(t){let e=this.activeFilters;if(!e)return;let n=0;for(let r of e)n+=r.pending.size;if(n!==0)for(let r=t;r<this.dictionary.length;r++){let i=this.dictionary[r];for(let s of e)s.pending.delete(i)&&s.ids.add(r);}}computeMaskRange(t,e){let n=this.lastMask;if(n.fill(1,t,e),this.activeFilters)for(let r of this.activeFilters){let i=this.storedColumns[r.fieldId];if(!i||i.type!=="int32")continue;let s=i.array,l=r.ids;if(r.filterType==="exclude")for(let a=t;a<e;a++)n[a]&&l.has(s[a])&&(n[a]=0);else for(let a=t;a<e;a++)n[a]&&!l.has(s[a])&&(n[a]=0);}if(this.activePrefilter)for(let r=t;r<e;r++)n[r]&&!this.evaluatePrefilterGroup(this.activePrefilter,r)&&(n[r]=0);}applyFilter(t){this.setFilters(t.filters.map(e=>({fieldId:e.fieldId,filterType:e.filterType,ids:new Set(e.dictIds),pending:new Set(e.valueStrings)})),t.prefilter),this.lastMask&&this.computeMaskRange(0,this.storedRowCount),this.buildFromMask(this.lastMask);}evaluatePrefilterGroup(t,e){if(!t.conditions||t.conditions.length===0)return true;if(t.logicalOperator==="and"){for(let n of t.conditions)if("logicalOperator"in n){if(!this.evaluatePrefilterGroup(n,e))return false}else if(!this.evaluatePrefilterCondition(n,e))return false;return true}else {for(let n of t.conditions)if("logicalOperator"in n){if(this.evaluatePrefilterGroup(n,e))return true}else if(this.evaluatePrefilterCondition(n,e))return true;return false}}evaluatePrefilterCondition(t,e){let n=this.storedColumns[t.fieldId];if(!n)return true;if(n.type==="float64"){let l=n.array[e],a=Number(t.value);switch(t.operator){case "=":return l===a;case "<>":return l!==a;case ">":return l>a;case ">=":return l>=a;case "<":return l<a;case "<=":return l<=a;case "isnull":return isNaN(l)||l===0;case "isnotnull":return !isNaN(l)&&l!==0;default:return true}}let r=n.array[e],i=this.dictionary[r]||"",s=String(t.value??"");switch(t.operator){case "=":return i===s;case "<>":return i!==s;case ">":return i>s;case ">=":return i>=s;case "<":return i<s;case "<=":return i<=s;case "contains":return i.toLowerCase().includes(s.toLowerCase());case "notcontains":return !i.toLowerCase().includes(s.toLowerCase());case "startswith":return i.toLowerCase().startsWith(s.toLowerCase());case "endswith":return i.toLowerCase().endsWith(s.toLowerCase());case "isnull":return i===""||i==="(Blank)";case "isnotnull":return i!==""&&i!=="(Blank)";case "in":return Array.isArray(t.value)?t.value.map(String).includes(i):true;case "notin":return Array.isArray(t.value)?!t.value.map(String).includes(i):true;default:return true}}buildFromMask(t){this.beginBuild(),this.processRange(0,this.storedRowCount,t),this.finalizeBuild();}beginBuild(){let t=this.storedRowCount,e=this.storedColumns,n=this.rowFields.length,r=this.colFields.length,i=new Array(n);for(let c=0;c<n;c++)i[c]=e[this.rowFields[c].id].array;let s=new Array(r);for(let c=0;c<r;c++)s[c]=e[this.colFields[c].id].array;let l=this.dictionary.length,a=this.rowFields.map(c=>{let v=e[c.id];return v&&v.type==="int32"?new Uint8Array(l):null}),d=this.colFields.map(c=>{let v=e[c.id];return v&&v.type==="int32"?new Uint8Array(l):null});this.rowTrie=new nt(2e5),this.colTrie=new nt(2e5);let w=this.dataFields.length,C=this.dataFields.map(c=>c.summaryType||"sum"),h=C.some(c=>c==="count"||c==="avg"),G=C.some(c=>c==="min"),m=C.some(c=>c==="max"),M=C.some(c=>c==="distinct"),R=new Array(w);for(let c=0;c<w;c++)R[c]=e[this.dataFields[c].id].array;let I=Math.min(t,2e5),u=G?new Float64Array(I*w):new Float64Array(0),p=m?new Float64Array(I*w):new Float64Array(0);this.leafGroupDistinctSets=M?new Map:new Map,G&&u.fill(1/0),m&&p.fill(-1/0),this.buildState={rPath:new Int32Array(n),cPath:new Int32Array(r),rowColArrays:i,colColArrays:s,dataColArrays:R,rowCardSeen:a,colCardSeen:d,rowCardCounts:new Int32Array(n),colCardCounts:new Int32Array(r),summaryTypes:C,allSums:C.every(c=>c==="sum"),needsCounts:h,needsMins:G,needsMaxes:m,groupMap:new Map,leafRowIds:new Int32Array(I),leafColIds:new Int32Array(I),leafMeasures:new Float64Array(I*w),leafCounts:h?new Float64Array(I*w):new Float64Array(0),leafMins:u,leafMaxes:p,rowGroupOf:this.tracking||C.includes("custom")?new Int32Array(t).fill(-1):null,gCount:0};}ensureCardCapacity(){let t=this.buildState;if(!t)return;let e=this.dictionary.length,n=r=>{if(r===null||r.length>=e)return r;let i=new Uint8Array(Math.max(e,r.length*2));return i.set(r),i};for(let r=0;r<t.rowCardSeen.length;r++)t.rowCardSeen[r]=n(t.rowCardSeen[r]);for(let r=0;r<t.colCardSeen.length;r++)t.colCardSeen[r]=n(t.colCardSeen[r]);}processRange(t,e,n){let r=this.buildState,{rPath:i,cPath:s,rowColArrays:l,colColArrays:a,dataColArrays:d,rowCardSeen:w,colCardSeen:C,rowCardCounts:h,colCardCounts:G,summaryTypes:m,allSums:M,needsCounts:R,needsMins:I,needsMaxes:u,groupMap:p,rowGroupOf:c}=r,v=l.length,y=a.length,b=d.length,D=this.rowTrie,E=this.colTrie,W=r.leafRowIds,J=r.leafColIds,_=r.leafMeasures,Q=r.leafCounts,Y=r.leafMins,Z=r.leafMaxes,K=r.gCount;for(let T=t;T<e;T++){if(n&&!n[T])continue;for(let f=0;f<v;f++){let F=l[f][T];i[f]=F;let g=w[f];g!==null&&g[F]===0&&(g[F]=1,h[f]++);}let $=D.insert(i,v);for(let f=0;f<y;f++){let F=a[f][T];s[f]=F;let g=C[f];g!==null&&g[F]===0&&(g[F]=1,G[f]++);}let rt=E.insert(s,y),it=$*67108864+rt,L=p.get(it);if(L===void 0){if(L=K++,p.set(it,L),L>=W.length){let f=L*2,F=new Int32Array(f);F.set(W),W=F;let g=new Int32Array(f);g.set(J),J=g;let H=new Float64Array(f*b);if(H.set(_),_=H,R){let o=new Float64Array(f*b);o.set(Q),Q=o;}if(I){let o=new Float64Array(f*b);o.fill(1/0),o.set(Y),Y=o;}if(u){let o=new Float64Array(f*b);o.fill(-1/0),o.set(Z),Z=o;}}W[L]=$,J[L]=rt;}c!==null&&(c[T]=L);let st=L*b;if(M)for(let f=0;f<b;f++)_[st+f]+=d[f][T];else for(let f=0;f<b;f++){let F=d[f][T],g=st+f;switch(m[f]){case "sum":_[g]+=F;break;case "count":Q[g]+=1;break;case "avg":_[g]+=F,Q[g]+=1;break;case "min":F<Y[g]&&(Y[g]=F);break;case "max":F>Z[g]&&(Z[g]=F);break;case "distinct":{let H=this.leafGroupDistinctSets.get(g);H||(H=new Set,this.leafGroupDistinctSets.set(g,H)),H.add(F);break}default:_[g]+=F;break}}}r.leafRowIds=W,r.leafColIds=J,r.leafMeasures=_,r.leafCounts=Q,r.leafMins=Y,r.leafMaxes=Z,r.gCount=K;}finalizeBuild(){let t=this.buildState,{needsCounts:e,needsMins:n,needsMaxes:r,gCount:i}=t,s=t.dataColArrays.length,l=t.rowColArrays.length,a=t.colColArrays.length;this.groupCount=i,this.leafGroupRowIds=t.leafRowIds.slice(0,i),this.leafGroupColIds=t.leafColIds.slice(0,i),this.leafGroupMeasures=t.leafMeasures.slice(0,i*s),this.leafGroupCounts=e?t.leafCounts.slice(0,i*s):t.leafCounts,this.leafGroupMins=n?t.leafMins.slice(0,i*s):t.leafMins,this.leafGroupMaxes=r?t.leafMaxes.slice(0,i*s):t.leafMaxes,this.rowGroupOf=t.rowGroupOf,this.cardinalityMap={};for(let d=0;d<l;d++)t.rowCardSeen[d]!==null&&(this.cardinalityMap[this.rowFields[d].id]=t.rowCardCounts[d]);for(let d=0;d<a;d++)t.colCardSeen[d]!==null&&(this.cardinalityMap[this.colFields[d].id]=t.colCardCounts[d]);if(this.buildState=null,this.rowLive=this.colLive=null,this.tracking){this.groupMap=t.groupMap;let d=this.groupRows=new Int32Array(i),w=t.rowGroupOf;for(let C=0;C<this.storedRowCount;C++)w[C]>=0&&d[w[C]]++;}this.buildVersion++,this.isBuilt=true,this.rowPathStrs=this.buildPathStrs(this.rowTrie),this.colPathStrs=this.buildPathStrs(this.colTrie),this.rowIndexMapCache=this.buildIndexMap(this.rowPathStrs,null),this.columnIndexMapCache=this.buildIndexMap(this.colPathStrs,null);}buildPathStrs(t,e=[""]){let n=e;for(let r=e.length;r<t.size;r++){let i=t.nodeToParent[r],s=this.dictionary[t.nodeToVal[r]],l=n[i];n[r]=l?l+"|"+s:s;}return n}buildIndexMap(t,e){let n={};for(let r=0;r<t.length;r++)(!e||e[r])&&(n[t[r]]=r);return n}applyTransaction(t){this.tracking||(this.tracking=true,this.buildFromMask(this.lastMask)),this.appendDictionary(t.dictionaryAppend);let{update:e,remove:n}=t,r=e.length,i=this.storedRowCount,s=i+t.addCount,l=this.storedColumns,a=new Set,d=false,w=this.rowGroupOf,C=u=>{let p=w[u];p<0||(w[u]=-1,--this.groupRows[p]===0&&(d=true),a.add(p));};e.forEach(C),n.forEach(C);for(let u in l){let p=l[u],c=t.columns[u];if(!c)throw new Error("transaction: no values for column "+u);let v=p.type==="int32"?new Int32Array(c):new Float64Array(c),y=p.array=X(p.array,s);for(let b=0;b<r;b++)y[e[b]]=v[b];y.set(v.subarray(r),i);}w=this.rowGroupOf=X(w,s),w.fill(-1,i,s);let h=this.lastMask&&(this.lastMask=X(this.lastMask,s));h&&(e.forEach(u=>this.computeMaskRange(u,u+1)),this.computeMaskRange(i,s));let G=this.rowFields.map(u=>l[u.id].array),m=this.colFields.map(u=>l[u.id].array),M=new Int32Array(G.length),R=new Int32Array(m.length),I=u=>{if(h&&!h[u])return;G.forEach((b,D)=>{M[D]=b[u];}),m.forEach((b,D)=>{R[D]=b[u];});let p=this.rowTrie.insert(M,M.length),c=this.colTrie.insert(R,R.length),v=p*67108864+c,y=this.groupMap.get(v);y===void 0&&(this.groupMap.set(v,y=this.groupCount++),(this.leafGroupRowIds=X(this.leafGroupRowIds,y+1))[y]=p,(this.leafGroupColIds=X(this.leafGroupColIds,y+1))[y]=c,this.groupRows=X(this.groupRows,y+1)),this.groupRows[y]++===0&&(d=true),w[u]=y,a.add(y);};e.forEach(I);for(let u=i;u<s;u++)I(u);if(this.storedRowCount=s-n.length,n.length>0){for(let u in l)ct(l[u].array,n,s);ct(w,n,s),h&&ct(h,n,s);}if(this.resumGroups(a),d){let u=0;for(let p=0;p<this.groupCount;p++)this.groupRows[p]===0&&u++;u>4096&&u>this.groupCount-u?this.buildFromMask(this.lastMask):(this.cardinalityMap={},[this.rowLive,this.rowPathStrs,this.rowIndexMapCache]=this.relive(this.rowTrie,this.leafGroupRowIds,this.rowFields,this.rowPathStrs),[this.colLive,this.colPathStrs,this.columnIndexMapCache]=this.relive(this.colTrie,this.leafGroupColIds,this.colFields,this.colPathStrs),this.buildVersion++);}return this.storedRowCount}resumGroups(t){if(t.size===0)return;let e=this.dataFields.length,n=this.dataFields.map(m=>m.summaryType||"sum"),r=this.dataFields.map(m=>this.storedColumns[m.id].array),i=this.groupCount*e,s=this.leafGroupMeasures=X(this.leafGroupMeasures,i),l=n.some(m=>m==="count"||m==="avg")?this.leafGroupCounts=X(this.leafGroupCounts,i):null,a=n.includes("min")?this.leafGroupMins=X(this.leafGroupMins,i):null,d=n.includes("max")?this.leafGroupMaxes=X(this.leafGroupMaxes,i):null,w=this.leafGroupDistinctSets,C=new Uint8Array(this.groupCount),h=0;for(let m of t){C[m]=1,h+=this.groupRows[m];for(let M=m*e;M<(m+1)*e;M++)s[M]=0,l&&(l[M]=0),a&&(a[M]=1/0),d&&(d[M]=-1/0),w.delete(M);}let G=this.rowGroupOf;for(let m=0;h>0&&m<this.storedRowCount;m++){let M=G[m];if(!(M<0||!C[M])){h--;for(let R=0;R<e;R++){let I=r[R][m],u=M*e+R;switch(n[R]){case "count":l[u]++;break;case "avg":s[u]+=I,l[u]++;break;case "min":I<a[u]&&(a[u]=I);break;case "max":I>d[u]&&(d[u]=I);break;case "distinct":{let p=w.get(u);p||w.set(u,p=new Set),p.add(I);break}default:s[u]+=I;}}}}}relive(t,e,n,r){let i=new Uint8Array(t.size);i[0]=1;for(let a=0;a<this.groupCount;a++)if(this.groupRows[a]!==0)for(let d=e[a];!i[d];d=t.nodeToParent[d])i[d]=1;let s=n.map(()=>new Set);t.nodeChildCount.fill(0,0,t.size);for(let a=1;a<t.size;a++)i[a]&&(t.nodeChildCount[t.nodeToParent[a]]++,s[t.nodeToDepth[a]-1]?.add(t.nodeToVal[a]));n.forEach((a,d)=>{this.cardinalityMap[a.id]=s[d].size;});let l=this.buildPathStrs(t,r);return [i,l,this.buildIndexMap(l,i)]}compute(t){this.isBuilt||this.buildFromMask(this.lastMask);let e=this.rowPathStrs,n=this.colPathStrs,r=new Uint8Array(this.rowTrie.size),i=new Set(t.expandedPaths),s=i.has(".*")||i.has("*");for(let o=0;o<this.rowTrie.size;o++)r[o]=s||i.has(e[o])?1:0;let l=new Uint8Array(this.colTrie.size),a=new Set(t.expandedColPaths),d=a.has(".*")||a.has("*");for(let o=0;o<this.colTrie.size;o++)l[o]=d||a.has(n[o])?1:0;let w=new Uint8Array(this.rowTrie.size);w[0]=1;for(let o=1;o<this.rowTrie.size;o++){let S=this.rowTrie.nodeToParent[o];(S===0||r[S])&&(!this.rowLive||this.rowLive[o])&&(w[o]=1);}let C=new Uint8Array(this.colTrie.size);C[0]=1;for(let o=1;o<this.colTrie.size;o++){let S=this.colTrie.nodeToParent[o];(S===0||l[S])&&(!this.colLive||this.colLive[o])&&(C[o]=1);}let h=this.dataFields.length,G=this.dataFields.map(o=>o.summaryType||"sum"),m=this.leafGroupMins.length>0,M=this.leafGroupMaxes.length>0,R=this.leafGroupCounts.length>0,I=this.leafGroupDistinctSets.size>0,u=new Map,p=0,c=1e4,v=new Float64Array(c),y=new Float64Array(c*h),b=new Int32Array(c*h),D=R?new Float64Array(c*h):null,E=m?new Float64Array(c*h):null,W=M?new Float64Array(c*h):null,J=I?new Map:new Map;E&&E.fill(1/0),W&&W.fill(-1/0);let _=new Int32Array(this.rowFields.length+1),Q=new Int32Array(this.colFields.length+1),Y=(o,S,A,O)=>{let tt=0,U=o;for(;U!==-1;)A[U]&&(O[tt++]=U),U=S.nodeToParent[U];return tt},Z=this.rowGroupOf!==null&&G.includes("custom"),K=Z?new Int32Array(this.groupCount+1):null,T=Z?new Int32Array(Math.max(16,this.groupCount*4)):null,$=0,rt=this.tracking?this.groupRows:null;for(let o=0;o<this.groupCount;o++){if(rt!==null&&rt[o]===0){K!==null&&(K[o+1]=$);continue}let S=this.leafGroupRowIds[o],A=this.leafGroupColIds[o],O=Y(S,this.rowTrie,w,_),tt=Y(A,this.colTrie,C,Q);for(let U=0;U<O;U++){let ot=_[U];for(let j=0;j<tt;j++){let at=Q[j],et=ot*67108864+at,P=u.get(et);if(P===void 0){if(P=p++,u.set(et,P),P>=v.length){let k=P*2,x=new Float64Array(k);x.set(v),v=x;let V=new Float64Array(k*h);V.set(y),y=V;let N=new Int32Array(k*h);if(N.set(b),b=N,D){let B=new Float64Array(k*h);B.set(D),D=B;}if(E){let B=new Float64Array(k*h);B.fill(1/0),B.set(E),E=B;}if(W){let B=new Float64Array(k*h);B.fill(-1/0),B.set(W),W=B;}}v[P]=et;}if(T!==null){if($>=T.length){let k=new Int32Array(T.length*2);k.set(T),T=k;}T[$++]=P;}for(let k=0;k<h;k++){let x=P*h+k,V=o*h+k;switch(G[k]){case "sum":y[x]+=this.leafGroupMeasures[V];break;case "count":y[x]+=this.leafGroupCounts[V];break;case "avg":y[x]+=this.leafGroupMeasures[V],D[x]+=this.leafGroupCounts[V];break;case "min":{let N=this.leafGroupMins[V];N<E[x]&&(E[x]=N);break}case "max":{let N=this.leafGroupMaxes[V];N>W[x]&&(W[x]=N);break}case "distinct":{let N=this.leafGroupDistinctSets.get(V);if(N){let B=J.get(x);B||(B=new Set,J.set(x,B));for(let ft of N)B.add(ft);}break}default:y[x]+=this.leafGroupMeasures[V];break}b[x]+=1;}}}K!==null&&(K[o+1]=$);}for(let o=0;o<p;o++)for(let S=0;S<h;S++){let A=o*h+S;switch(G[S]){case "avg":y[A]=D[A]>0?y[A]/D[A]:0;break;case "min":y[A]=E[A]!==1/0?E[A]:0;break;case "max":y[A]=W[A]!==-1/0?W[A]:0;break;case "distinct":{let O=J.get(A);y[A]=O?O.size:0;break}}}let it=v.slice(0,p),L=y.slice(0,p*h),st=b.slice(0,p*h),f=(o,S,A,O,tt)=>{let U=[];for(let j=0;j<O.length;j++)U[j]=O[j]?.id||"";let ot=j=>{let at=o.childrenMap.get(j);if(!at)return [];let et=[];for(let P of at.values())if(S[P]){let k=o.nodeToDepth[P]-1,x=A[P]===1;et.push({key:tt[P],value:this.dictionary[o.nodeToVal[P]],fieldId:U[k]||"",children:x?ot(P):[],isExpanded:x,isTotal:false,depth:k,hasChildren:o.nodeChildCount[P]>0});}return et};return ot(0)},F;if(this.rowGroupOf!==null&&K!==null&&T!==null){let o=this.storedRowCount,S={};for(let A=0;A<h;A++){if(G[A]!=="custom")continue;let O=this.dataFields[A].id;S[O]=this.storedColumns[O].array.slice(0,o);}F={rowGroupOf:this.rowGroupOf.slice(0,o),groupCellOffsets:K,groupCells:T.slice(0,$),values:S};}let g=f(this.rowTrie,w,r,this.rowFields,e),H=f(this.colTrie,C,l,this.colFields,n);return {id:t.id,rowTree:g,colTree:H,cellMatrix:{keys:it,sums:L,counts:st},customSummary:F,rowIndexMap:this.rowIndexMapCache,columnIndexMap:this.columnIndexMapCache,cardinalityMap:this.cardinalityMap,indexMapsVersion:this.buildVersion}}};var q=new lt,dt=-1;self.onmessage=z=>{let t=z.data;try{if(t.action==="init")q.init(t),self.postMessage({id:t.id,isInitComplete:!0});else if(t.action==="initStart")q.initStart(t);else if(t.action==="initChunk")q.initChunk(t);else if(t.action==="initEnd")q.initEnd(),self.postMessage({id:t.id,isInitComplete:!0});else if(t.action==="filter")q.applyFilter(t),self.postMessage({id:t.id,isFilterComplete:!0});else if(t.action==="reconfigure")q.reconfigure(t),self.postMessage({id:t.id,isReconfigureComplete:!0});else if(t.action==="transaction")self.postMessage({id:t.id,isTransactionComplete:!0,rowCount:q.applyTransaction(t)});else if(t.action==="compute"){let e=q.compute(t),n=[e.cellMatrix.keys.buffer,e.cellMatrix.sums.buffer,e.cellMatrix.counts.buffer];if(e.indexMapsVersion!==void 0&&e.indexMapsVersion===dt){let r={...e,rowIndexMap:void 0,columnIndexMap:void 0,cardinalityMap:void 0,indexMapsOmitted:!0};postMessage(r,n);}else e.indexMapsVersion!==void 0&&(dt=e.indexMapsVersion),postMessage(e,n);}}catch(e){self.postMessage({id:t.id,error:e instanceof Error?e.message:String(e)});}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanunilabs/pivotgrid-core",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "description": "Framework-agnostic PivotGrid engine with Web Worker, columnar storage, trie-based grouping, and headless controller",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "KanuniLabs <hello@kanunilabs.com> (https://www.kanunilabs.com)",
@@ -54,6 +54,7 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/file-saver": "^2.0.7",
57
+ "ajv": "^8.20.0",
57
58
  "@kanunilabs/foundation": "1.0.4"
58
59
  },
59
60
  "keywords": [
@@ -78,7 +79,7 @@
78
79
  ],
79
80
  "scripts": {
80
81
  "lint": "tsc --noEmit",
81
- "build": "pnpm run build:worker && pnpm run build:embed && tsup",
82
+ "build": "pnpm run build:worker && pnpm run build:embed && tsup && node ../../scripts/check-esm-load.mjs",
82
83
  "build:worker": "tsup --config tsup.worker.config.ts",
83
84
  "build:embed": "node scripts/embed-workers.mjs",
84
85
  "build:check": "tsc --noEmit",