@kanunilabs/pivotgrid 1.6.7 → 1.6.9

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/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var pivotgridCore=require('@kanunilabs/pivotgrid-core');var pn={tr:pivotgridCore.tr,en:pivotgridCore.en,ar:pivotgridCore.ar,de:pivotgridCore.de,fr:pivotgridCore.fr,es:pivotgridCore.es,it:pivotgridCore.it,pt:pivotgridCore.pt,ru:pivotgridCore.ru,"zh-CN":pivotgridCore.zhCN,ja:pivotgridCore.ja,ko:pivotgridCore.ko};function Be(e,t,n){let a=e??"en",l={...pivotgridCore.en,...pn[a]??{},...t??{}};return {locale:a,rtl:n!==void 0?n:a==="ar",dictionary:l,t:i=>l[i]||i}}var un={renderCalculatedFieldModal:"render props do not exist here; pass onAddCalculatedField/onEditCalculatedField, or use @kanunilabs/pivotgrid-enterprise which fills the socket",renderPrefilterBuilder:"render props do not exist here; pass onOpenPrefilter, or use @kanunilabs/pivotgrid-enterprise which fills the socket",renderNodeContextMenu:"render props do not exist here; the node menu is built in (Community since #192)",onOpenFullScreenChart:"dead even in React (never fires); use chartIntegrationOptions",children:"this is not a React component",ref:"the object returned by createPivotGrid IS the imperative handle",touchChipTap:"a tap on a field chip sorts it here, as a click does; a long press does not open its menu (B.35)",fieldChooserMode:"the field list here always opens over the pivot; the side panel is React only (B.37)"},st=new Set;function ct(e){for(let t of Object.keys(e)){let n=un[t];!n||st.has(t)||(st.add(t),console.warn(`[pivotgrid] config key "${t}" is React-only and ignored \u2014 ${n}`));}}var fn=[["background","--pivot-bg"],["surface","--pivot-surface"],["surfaceHover","--pivot-surface-hover"],["surfaceHeader","--pivot-surface-header"],[e=>e.headerBackground||e.surfaceHeader,"--pivot-header-bg"],["headerText","--pivot-header-text"],["border","--pivot-border"],["text","--pivot-text"],["textMuted","--pivot-text-muted"],["textHeader","--pivot-text-header"],["primary","--pivot-primary"],["primaryForeground","--pivot-primary-foreground"],["success","--pivot-success"],["danger","--pivot-danger"],["warning","--pivot-warning"],["info","--pivot-info"],["totalBackground","--pivot-total-bg"],["stripeBackground","--pivot-stripe-bg"],["groupBorder","--pivot-group-border"],["iconActive","--pivot-icon-active"]];function pt(e,t){for(let[n,a]of fn){let l=t?typeof n=="function"?n(t):t[n]:void 0;typeof l=="string"&&l?e.style.setProperty(a,l):e.style.removeProperty(a);}t?.id?e.setAttribute("data-theme",t.id):e.removeAttribute("data-theme");}var Ue=(e,t)=>(e.areaIndex||0)-(t.areaIndex||0);function vt(e,t){let n=pivotgridCore.shownFields(e.fields),a=e.layout,l=n.filter(r=>r.area==="row").sort(Ue),i=n.filter(r=>r.area==="column").sort(Ue),d=n.filter(r=>r.area==="data").sort(Ue),b=e.engineResult,M=e.expandedPaths.has("*"),T=e.expandedColPaths.has("*"),F=a.rowHeaderLayout==="tree"?1:l.length||1,m=a.dataFieldPosition==="rows"&&d.length>1,f=m?1:d.length;if(!b)return {rowFields:l,colFields:i,dataFields:d,colHeaders:[],virtualRows:[],leafColHashes:[],cellLookup:new Map,fieldRanges:{},engineResult:null,layout:a,maxRowDepth:F,showDataInRows:m,dfsPerLeaf:f,totalDataCols:0,dataColOffset:F+(m?1:0)};let[g,h]=a.hideEmptySummaryCells?pivotgridCore.filterEmptySummaryTree(b):[b.rowTree,b.colTree],p=pivotgridCore.buildColumnHeaders(h,d,a,e.expandedColPaths,T,t,i.length),w=a.rowHeaderLayout==="tree"?pivotgridCore.flattenRowTreeTree(g,e.expandedPaths,M,l.length||1,a.showRowTotals??true,a.totalsPosition??"bottom",a.showTotalsForSingleValues!==false):pivotgridCore.flattenRowTreeTabular(g,e.expandedPaths,M,F,a.showRowTotals??true,a.totalsPosition??"bottom",a.showTotalsForSingleValues!==false),s=[];for(let r of w)if(m&&!r.isSubtotal&&!r.hasChildren)for(let x=0;x<d.length;x++)s.push({flatRow:r,dfIndex:x,isDataRow:true,isGrandTotal:false});else s.push({flatRow:r,dfIndex:0,isDataRow:false,isGrandTotal:false});if(pivotgridCore.grandTotalShown(a,"row",g))if(m)for(let r=0;r<d.length;r++)s.push({flatRow:null,dfIndex:r,isDataRow:true,isGrandTotal:true});else s.push({flatRow:null,dfIndex:0,isDataRow:false,isGrandTotal:true});let k=pivotgridCore.columnSlotOptions(a),y=[];for(let r of pivotgridCore.getVisibleColSlots(h,e.expandedColPaths,T,k))y.push({hash:r.node.key,isGrandTotal:!!r.node.isTotal,isSubtotal:r.isSubtotal});(pivotgridCore.grandTotalShown(a,"column",h)||y.length===0)&&y.push({hash:"",isGrandTotal:true});let C=new Map,o=b.cellMatrix.keys;for(let r=0;r<o.length;r++)C.set(o[r],r);let c=d.some(pivotgridCore.fieldNeedsRange)?pivotgridCore.computeFieldRanges(b,d):{};return {rowFields:l,colFields:i,dataFields:d,colHeaders:p,virtualRows:s,leafColHashes:y,cellLookup:C,fieldRanges:c,engineResult:b,layout:a,maxRowDepth:F,showDataInRows:m,dfsPerLeaf:f,totalDataCols:y.length*f,dataColOffset:F+(m?1:0)}}function Ye(e,t,n,a,l){let i=e.engineResult,d=i.rowIndexMap[t]??-1,b=i.columnIndexMap[n]??-1;if(d===-1||b===-1)return null;let M=e.cellLookup.get(d*pivotgridCore.MAX_C+b);if(M===void 0)return null;let T=e.dataFields.length,F=i.cellMatrix.sums,m=i.cellMatrix.displaySums,f={};for(let g=0;g<T;g++)f[e.dataFields[g].id]=F[M*T+g],m&&(f[`${e.dataFields[g].id}_display`]=m[M*T+g]);return {values:f,rowPath:pivotgridCore.pathParts(t),colPath:pivotgridCore.pathParts(n),isTotalCell:d===0||b===0||a||l}}function mt(e,t,n){if(!e.engineResult||n<e.dataColOffset)return null;let a=n-e.dataColOffset,l=Math.floor(a/e.dfsPerLeaf),i=a%e.dfsPerLeaf;if(l>=e.leafColHashes.length)return null;let d=e.virtualRows[t];if(!d)return null;let b=d.isGrandTotal?"":d.flatRow?.key;if(b===void 0)return null;let M=e.leafColHashes[l]?.hash;if(M===void 0)return null;let T=e.engineResult.rowIndexMap[b],F=e.engineResult.columnIndexMap[M];if(T===void 0||F===void 0)return null;let m=e.cellLookup.get(T*pivotgridCore.MAX_C+F);if(m===void 0)return null;let f=e.showDataInRows?d.dfIndex:i,h=e.engineResult.cellMatrix.sums[m*e.dataFields.length+f];return typeof h=="number"?h:null}function Ze(e,t,n){let a=e.virtualRows[t];if(!a||a.isGrandTotal||!a.flatRow)return null;let l=a.flatRow,i=e.layout.rowHeaderLayout==="tree",d=n,b=i?l.depth:d,M=b===l.depth,T=b<l.depth,F=M?l.hasChildren:T,m=M?l.isExpanded:T,f=i?l.key:pivotgridCore.pathKey(l.pathValues.slice(0,d+1));return {hasChildren:F,isExpanded:m,cellHashStr:f,depth:b,dIdx:d,flatRow:l}}function gt(e,t,n){if(n<e.dataColOffset||!e.engineResult)return null;let a=n-e.dataColOffset,l=Math.floor(a/e.dfsPerLeaf),i=a%e.dfsPerLeaf;if(l>=e.leafColHashes.length)return null;let d=e.virtualRows[t];if(!d)return null;let b=d.isGrandTotal?"":d.flatRow?.key;if(b===void 0)return null;let M=e.leafColHashes[l],T=Ye(e,b,M.hash,!!d.flatRow?.isSubtotal,M.isGrandTotal);if(!T)return null;let F=e.showDataInRows?d.dfIndex:i,m=e.dataFields[F],f=T.values[`${m?.id}_display`]??T.values[m?.id],g=!!d.flatRow?.isSubtotal||M.isGrandTotal||T.isTotalCell;return {cell:{isTotalCell:T.isTotalCell,rowPath:T.rowPath,colPath:T.colPath,values:T.values},val:f,isTotal:g}}function Ne(e){let t=new Map;return (n,a)=>{if(n==null||Number.isNaN(n))return "";if(a.format&&typeof n=="number"){if(typeof a.format=="function")return a.format(n);try{let l=a.format,i=t.get(l);i||(i=new Intl.NumberFormat(e,l),t.set(l,i));let d=i.format(n);return l.isCustom&&(l.prefix||l.suffix)?`${l.prefix||""}${d}${l.suffix||""}`:d}catch{return String(n)}}return typeof n=="number"&&pivotgridCore.percentModeText(n,a,e)||String(n)}}var Ie=null;function We(e,t,n){if(!e)return false;let a=Math.min(e.startR,e.endR),l=Math.max(e.startR,e.endR),i=Math.min(e.startC,e.endC),d=Math.max(e.startC,e.endC);return t>=a&&t<=l&&n>=i&&n<=d}function bt(e){let{scroller:t,shared:n}=e,a={},l="",i=null,d=false;function b(){for(let g of t.querySelectorAll("td[data-r][data-c]")){let h=Number(g.getAttribute("data-r")),p=Number(g.getAttribute("data-c"));g.classList.toggle("kanuni-pivot-cell-selected",We(n.selection,h,p));}}function M(){let g=n.selection;if(e.onStats){if(!g||g.mode!=="data"){i&&(clearTimeout(i),i=null),d&&(d=false,e.onStats(null));return}i&&clearTimeout(i),i=setTimeout(()=>{i=null;let h=n.selection;if(!h||h.mode!=="data")return;let p=Math.min(h.startR,h.endR),w=Math.max(h.startR,h.endR),s=Math.min(h.startC,h.endC),k=Math.max(h.startC,h.endC),y=0,C=0,o=1/0,c=-1/0,r=e.getVM();if(r){for(let x=p;x<=w;x++)for(let u=s;u<=k;u++){let E=mt(r,x,u);E===null||isNaN(E)||(y+=E,C++,E<o&&(o=E),E>c&&(c=E));}d=C>0,e.onStats(C>0?{sum:y,count:C,avg:y/C,min:o,max:c}:null);}},10);}}n.selectByKey=(g,h,p,w)=>{let s=e.getVM();if(!s)return;let k=h<s.dataColOffset?"row":"data",y=n.selection;if(Ie=a,l="",p&&y&&y.mode===k){if(y.endR===g&&y.endC===h&&!y.isSelecting)return;n.selection={...y,endR:g,endC:h,isSelecting:false};}else if(p){let o=(w.c<s.dataColOffset?"row":"data")===k?w:{r:g,c:h};n.selection={startR:o.r,startC:o.c,endR:g,endC:h,isSelecting:false,mode:k};}else {if(y&&y.mode===k&&!y.isSelecting&&y.startR===g&&y.startC===h&&y.endR===g&&y.endC===h)return;n.selection={startR:g,startC:h,endR:g,endC:h,isSelecting:false,mode:k};}b(),M();};let T=g=>{if(g.button!==0||n.isResizing||g.target.closest?.(".kanuni-pivot-resize-handle"))return;let h=g.target.closest?.("td[data-r][data-c]");if(!h)return;let p=e.getVM();if(!p)return;let w=Number(h.getAttribute("data-r")),s=Number(h.getAttribute("data-c")),k=s<p.dataColOffset?"row":"data";Ie=a,l="",n.selection={startR:w,startC:s,endR:w,endC:s,isSelecting:true,mode:k},b(),M();},F=g=>{let h=n.selection;if(!h||!h.isSelecting)return;let p=g.target.closest?.("td[data-r][data-c]");if(!p)return;let w=Number(p.getAttribute("data-r")),s=Number(p.getAttribute("data-c")),k=`${w},${s}`;if(k===l)return;l=k;let y=e.getVM();!y||(s<y.dataColOffset?"row":"data")!==h.mode||w===h.endR&&s===h.endC||(h.endR=w,h.endC=s,b(),M());},m=()=>{n.selection&&(n.selection.isSelecting=false);},f=g=>{if(!(g.ctrlKey||g.metaKey)||g.key!=="c"||Ie!==null&&Ie!==a)return;let h=n.selection;if(!h)return;let p=Math.min(h.startR,h.endR),w=Math.max(h.startR,h.endR),s=Math.min(h.startC,h.endC),k=Math.max(h.startC,h.endC),y="";for(let C=p;C<=w;C++){let o=[];for(let c=s;c<=k;c++){let r=t.querySelector(`[data-r="${C}"][data-c="${c}"]`);o.push(r?(r.innerText??r.textContent??"").trim().replace(/\n/g," "):"");}y+=o.join(" ")+`
2
- `;}y&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(y).catch(()=>{});};return t.addEventListener("mousedown",T),t.addEventListener("mouseover",F),document.addEventListener("mouseup",m),document.addEventListener("keydown",f),{destroy(){t.removeEventListener("mousedown",T),t.removeEventListener("mouseover",F),document.removeEventListener("mouseup",m),document.removeEventListener("keydown",f),i&&clearTimeout(i),Ie===a&&(Ie=null),n.selectByKey=void 0;}}}var yt={settings:[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]],"settings-2":[["path",{d:"M14 17H5"}],["path",{d:"M19 7h-9"}],["circle",{cx:"17",cy:"17",r:"3"}],["circle",{cx:"7",cy:"7",r:"3"}]],download:[["path",{d:"M12 15V3"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}],["path",{d:"m7 10 5 5 5-5"}]],"refresh-cw":[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}],["path",{d:"M8 16H3v5"}]],maximize2:[["path",{d:"M15 3h6v6"}],["path",{d:"m21 3-7 7"}],["path",{d:"m3 21 7-7"}],["path",{d:"M9 21H3v-6"}]],minimize2:[["path",{d:"m14 10 7-7"}],["path",{d:"M20 10h-6V4"}],["path",{d:"m3 21 7-7"}],["path",{d:"M4 14h6v6"}]],fullscreen:[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1"}]],shrink:[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3"}]],"file-spreadsheet":[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M8 13h2"}],["path",{d:"M14 13h2"}],["path",{d:"M8 17h2"}],["path",{d:"M14 17h2"}]],"file-text":[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]],"file-json":[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1"}]],file:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}]],database:[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5"}],["path",{d:"M3 12A9 3 0 0 0 21 12"}]],calculator:[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18"}],["path",{d:"M16 10h.01"}],["path",{d:"M12 10h.01"}],["path",{d:"M8 10h.01"}],["path",{d:"M12 14h.01"}],["path",{d:"M8 14h.01"}],["path",{d:"M12 18h.01"}],["path",{d:"M8 18h.01"}]],filter:[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"}]],"bar-chart":[["path",{d:"M5 21v-6"}],["path",{d:"M12 21V9"}],["path",{d:"M19 21V3"}]],"bar-chart-3":[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}],["path",{d:"M18 17V9"}],["path",{d:"M13 17V5"}],["path",{d:"M8 17v-3"}]],"line-chart":[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}],["path",{d:"m19 9-5 5-4-4-3 3"}]],"area-chart":[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z"}]],"pie-chart":[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83"}]],"scatter-chart":[["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor"}],["circle",{cx:"18.5",cy:"5.5",r:".5",fill:"currentColor"}],["circle",{cx:"11.5",cy:"11.5",r:".5",fill:"currentColor"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor"}],["circle",{cx:"17.5",cy:"14.5",r:".5",fill:"currentColor"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}]],"dot-plot":[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"19",cy:"12",r:"1"}],["circle",{cx:"5",cy:"12",r:"1"}]],"bubble-chart":[["circle",{cx:"12",cy:"12",r:"10"}],["circle",{cx:"12",cy:"12",r:"1"}]],"donut-chart":[["path",{d:"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3"}],["circle",{cx:"12",cy:"12",r:"3"}]],"waterfall-chart":[["path",{d:"M13 17V9"}],["path",{d:"M18 17v-3"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}],["path",{d:"M8 17V5"}]],"funnel-chart":[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"}]],"treemap-chart":[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1"}]],"heatmap-chart":[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"M3 9h18"}],["path",{d:"M3 15h18"}],["path",{d:"M9 3v18"}],["path",{d:"M15 3v18"}]],"range-chart":[["path",{d:"M9 5v4"}],["rect",{width:"4",height:"6",x:"7",y:"9",rx:"1"}],["path",{d:"M9 15v2"}],["path",{d:"M17 3v2"}],["rect",{width:"4",height:"8",x:"15",y:"5",rx:"1"}],["path",{d:"M17 13v3"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}]],"sunburst-chart":[["circle",{cx:"12",cy:"12",r:"4"}],["path",{d:"M12 2v2"}],["path",{d:"M12 20v2"}],["path",{d:"m4.93 4.93 1.41 1.41"}],["path",{d:"m17.66 17.66 1.41 1.41"}],["path",{d:"M2 12h2"}],["path",{d:"M20 12h2"}],["path",{d:"m6.34 17.66-1.41 1.41"}],["path",{d:"m19.07 4.93-1.41 1.41"}]],"histogram-chart":[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1"}]],radar:[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34"}],["path",{d:"M4 6h.01"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67"}],["path",{d:"M12 18h.01"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67"}],["circle",{cx:"12",cy:"12",r:"2"}],["path",{d:"m13.41 10.59 5.66-5.66"}]],printer:[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1"}]],copy:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"}]],save:[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7"}]],"save-all":[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z"}]],bookmark:[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z"}]],"folder-open":[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}]],check:[["path",{d:"M20 6 9 17l-5-5"}]],"check-circle":[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335"}],["path",{d:"m9 11 3 3L22 4"}]],star:[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"}]],trash:[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]],x:[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]],search:[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]],"grip-vertical":[["circle",{cx:"9",cy:"12",r:"1"}],["circle",{cx:"9",cy:"5",r:"1"}],["circle",{cx:"9",cy:"19",r:"1"}],["circle",{cx:"15",cy:"12",r:"1"}],["circle",{cx:"15",cy:"5",r:"1"}],["circle",{cx:"15",cy:"19",r:"1"}]],"grip-horizontal":[["circle",{cx:"12",cy:"9",r:"1"}],["circle",{cx:"19",cy:"9",r:"1"}],["circle",{cx:"5",cy:"9",r:"1"}],["circle",{cx:"12",cy:"15",r:"1"}],["circle",{cx:"19",cy:"15",r:"1"}],["circle",{cx:"5",cy:"15",r:"1"}]],"chevron-down":[["path",{d:"m6 9 6 6 6-6"}]],"chevron-left":[["path",{d:"m15 18-6-6 6-6"}]],"chevron-right":[["path",{d:"m9 18 6-6-6-6"}]],"chevrons-left":[["path",{d:"m11 17-5-5 5-5"}],["path",{d:"m18 17-5-5 5-5"}]],"chevrons-right":[["path",{d:"m6 17 5-5-5-5"}],["path",{d:"m13 17 5-5-5-5"}]],"arrow-up":[["path",{d:"m5 12 7-7 7 7"}],["path",{d:"M12 19V5"}]],"arrow-down":[["path",{d:"M12 5v14"}],["path",{d:"m19 12-7 7-7-7"}]],"arrow-down-a-z":[["path",{d:"m3 16 4 4 4-4"}],["path",{d:"M7 20V4"}],["path",{d:"M20 8h-5"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10"}],["path",{d:"M15 14h5l-5 6h5"}]],"arrow-up-z-a":[["path",{d:"m3 8 4-4 4 4"}],["path",{d:"M7 4v16"}],["path",{d:"M15 4h5l-5 6h5"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20"}],["path",{d:"M20 18h-5"}]],"eye-off":[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}],["path",{d:"m2 2 20 20"}]],list:[["path",{d:"M3 5h.01"}],["path",{d:"M3 12h.01"}],["path",{d:"M3 19h.01"}],["path",{d:"M8 5h13"}],["path",{d:"M8 12h13"}],["path",{d:"M8 19h13"}]],columns3:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"M9 3v18"}],["path",{d:"M15 3v18"}]],hash:[["line",{x1:"4",x2:"20",y1:"9",y2:"9"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21"}]],calendar:[["path",{d:"M8 2v4"}],["path",{d:"M16 2v4"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}],["path",{d:"M3 10h18"}]],type:[["path",{d:"M12 4v16"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}],["path",{d:"M9 20h6"}]],plus:[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]],"alert-circle":[["circle",{cx:"12",cy:"12",r:"10"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16"}]],move:[["path",{d:"M12 2v20"}],["path",{d:"m15 19-3 3-3-3"}],["path",{d:"m19 9 3 3-3 3"}],["path",{d:"M2 12h20"}],["path",{d:"m5 9-3 3 3 3"}],["path",{d:"m9 5 3-3 3 3"}]]};var xt="http://www.w3.org/2000/svg";function X(e,t=15,n){let a=document.createElementNS(xt,"svg");a.setAttribute("width",String(t)),a.setAttribute("height",String(t)),a.setAttribute("viewBox","0 0 24 24"),a.setAttribute("fill","none"),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","2"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),a.setAttribute("aria-hidden","true"),a.setAttribute("focusable","false"),n&&(a.style.color=n);for(let[l,i]of yt[e]??[]){let d=document.createElementNS(xt,l);for(let[b,M]of Object.entries(i))d.setAttribute(b,String(M));a.appendChild(d);}return a}function Ve(e,t=15,n){let a=X(e,t,n);return a.setAttribute("fill","currentColor"),a}function he(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Je(e){let t=document.activeElement;return !t||!e.contains(t)?null:t.closest(".kanuni-pivot-field-chip")?.getAttribute("data-drop-id")??null}function Qe(e,t){if(!t)return;let n=e.querySelector(`.kanuni-pivot-field-chip[data-drop-id="${t}"]`);n&&n!==document.activeElement&&n.focus({preventScroll:true});}function Pn(e,t,n){let a=e.filter(l=>l.area===t);return t==="filter"?Ct(a,n):a.sort((l,i)=>(l.areaIndex||0)-(i.areaIndex||0))}var Rn={row:"rowArea",column:"columnArea",data:"dataArea",filter:"filterArea"};function Ge(e,t){let{t:n,locale:a,rtl:l}=t.getI18n(),i=he("kanuni-pivot-field-chip");i.setAttribute("data-drop-id",e.id),i.setAttribute("data-touch-hold",""),i.style.position="relative",i.style.cursor="pointer",i.setAttribute("role","button"),i.tabIndex=0;let d=t.getFields?Pn(t.getFields(),e.area,a):[e],b=Math.max(0,d.findIndex(s=>s.id===e.id)),M=n(Rn[e.area??""]??"rowArea");i.setAttribute("aria-label",n("fieldChipLabel").replace("{0}",e.caption||e.id).replace("{1}",M).replace("{2}",String(b+1)).replace("{3}",String(d.length))),i.setAttribute("aria-keyshortcuts","Control+ArrowLeft Control+ArrowRight Control+Home Control+End Delete Alt+ArrowDown Shift+F10"),i.setAttribute("aria-description",n("fieldChipKeys"));let T=()=>{if(!t.onSort)return;let s=e.sortOrder==="asc"?"desc":e.sortOrder==="desc"?void 0:"asc";t.onSort(e.id,s);},F=s=>{if(!s)return;(i.closest(".kanuni-pivot-root")??document.body).querySelector(`.kanuni-pivot-field-chip[data-drop-id="${s}"]`)?.focus({preventScroll:true});};i.addEventListener("keydown",s=>{let k=s.ctrlKey||s.metaKey,y=l?"ArrowRight":"ArrowLeft",C=l?"ArrowLeft":"ArrowRight",o=!!t.onMove&&e.area!=="filter",c=true;if(s.key==="Enter"||s.key===" ")T();else if(k&&o&&(s.key===y||s.key==="ArrowUp"))b>0&&t.onMove(e.id,"left");else if(k&&o&&(s.key===C||s.key==="ArrowDown"))b<d.length-1&&t.onMove(e.id,"right");else if(k&&o&&s.key==="Home")b>0&&t.onMove(e.id,"start");else if(k&&o&&s.key==="End")b<d.length-1&&t.onMove(e.id,"end");else if(!k&&(s.key===y||s.key===C)){let r=s.key===y?-1:1;F(d[b+r]?.id);}else if(s.key==="Delete"||s.key==="Backspace"){let r=d[b+1]??d[b-1];t.requestFocus?.(r?.id??null),t.onRemove(e.id);}else if(s.altKey&&s.key==="ArrowDown"){let r=i.getBoundingClientRect();t.onFilterClick(l?r.right:r.left,r.bottom,e.id);}else if(s.key==="F10"&&s.shiftKey||s.key==="ContextMenu"){if(!t.onContextMenu)return;let r=i.getBoundingClientRect();t.onContextMenu(l?r.right:r.left,r.bottom,e.id,void 0,true);}else c=false;c&&(s.preventDefault(),s.stopPropagation());});let m=he("pivot-truncate","span");Object.assign(m.style,{maxWidth:"var(--pivot-chip-max-width, 120px)",userSelect:"none"}),m.title=e.caption||e.id,m.textContent=e.caption||e.id,i.appendChild(m),e.sortOrder==="asc"&&i.appendChild(X("arrow-up",12,"var(--pivot-primary)")),e.sortOrder==="desc"&&i.appendChild(X("arrow-down",12,"var(--pivot-primary)"));let f=e.area==="data"&&e.summaryType?pivotgridCore.summaryTypeLabel(String(e.summaryType),n):"";if(f){let s=he("kanuni-pivot-chip-badge","span");Object.assign(s.style,{fontSize:"10px",backgroundColor:"color-mix(in srgb, var(--pivot-primary) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--pivot-primary) 45%, transparent)",color:"var(--pivot-text)",padding:"0 4px",borderRadius:"4px",fontWeight:"700"}),s.textContent=f,i.appendChild(s);}let g=!!e.filterValues&&e.filterValues.size>0||!!e.valueFilter||!!e.labelFilter,h=he(`kanuni-pivot-field-chip-actions${g?" is-filtered":""}`);h.setAttribute("aria-hidden","true");let p=he("kanuni-pivot-chip-btn","span");p.title=n("filterField"),p.style.color=g?"var(--pivot-danger)":"inherit",p.appendChild(X("filter",12)),p.addEventListener("pointerdown",s=>s.stopPropagation()),p.addEventListener("click",s=>{s.stopPropagation(),t.onFilterClick(s.clientX,s.clientY,e.id);});let w=he("kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger kanuni-pivot-chip-remove","span");if(w.title=n("removeField"),w.appendChild(X("x",12)),w.addEventListener("pointerdown",s=>s.stopPropagation()),w.addEventListener("click",s=>{s.stopPropagation(),t.onRemove(e.id);}),h.append(p,w),i.appendChild(h),t.onContextMenu){i.setAttribute("data-chip-menu","");let s=he(`kanuni-pivot-chip-more${g?" is-filtered":""}`,"span");if(s.setAttribute("aria-hidden","true"),s.addEventListener("pointerdown",k=>k.stopPropagation()),s.addEventListener("click",k=>{k.stopPropagation();let y=s.getBoundingClientRect();t.onContextMenu(l?y.right:y.left,y.bottom,e.id,void 0);}),i.appendChild(s),g){let k=X("filter",10);k.classList.add("kanuni-pivot-chip-filtered-mark"),k.setAttribute("aria-hidden","true"),i.appendChild(k);}}return i.addEventListener("click",s=>{s.stopPropagation(),T();}),i.addEventListener("contextmenu",s=>{if(s.stopPropagation(),t.onContextMenu){s.preventDefault();let k=i.getBoundingClientRect(),y=Number.isFinite(s.clientX)?s.clientX:l?k.right:k.left,C=Number.isFinite(s.clientY)?s.clientY:k.bottom;t.onContextMenu(y,C,e.id,void 0);}}),i}function je(e,t,n,a,l){let{t:i}=l.getI18n(),d=he("kanuni-pivot-area-dropzone");d.setAttribute("data-drop-id",e),d.tabIndex=-1;let b=he("kanuni-pivot-area-header");b.appendChild(X(n,13)),b.appendChild(document.createTextNode(t)),d.appendChild(b);let M=he("kanuni-pivot-area-content");if(a.length===0){let F=he("pivot-text-xs pivot-text-muted","span");Object.assign(F.style,{fontStyle:"italic",padding:"0 8px"}),F.textContent=i("dropHere"),M.appendChild(F);}for(let F of a)M.appendChild(Ge(F,l));let T=he("kanuni-pivot-ghost-end");return T.setAttribute("data-drop-id",`${e}-ghost-end`),T.setAttribute("data-ghost-populated",a.length>0?"1":"0"),Object.assign(T.style,{flex:"1",minWidth:"40px",minHeight:"24px",borderRadius:"var(--pivot-border-radius-sm)",transition:"background-color 0.2s"}),M.appendChild(T),d.appendChild(M),d}function Ct(e,t){let n=new Map;return e.map(l=>{let i=l.caption||l.id||"";if(n.has(i)){let d=n.get(i)+1;return n.set(i,d),{...l,caption:`${i} (${d})`}}return n.set(i,1),l}).sort((l,i)=>(l.caption||"").toLowerCase().localeCompare((i.caption||"").toLowerCase(),t||"en"))}function wt(e){let t=he("kanuni-pivot-filter-strip pivot-flex pivot-flex-col");Object.assign(t.style,{padding:"8px",borderBottom:"1px solid var(--pivot-border)",backgroundColor:"color-mix(in srgb, var(--pivot-surface-header) 30%, transparent)",flex:"0 0 auto"});let n=l=>{e.onGlobalContextMenu&&(l.target.closest(".kanuni-pivot-field-chip")||(l.preventDefault(),e.onGlobalContextMenu(l.clientX,l.clientY)));};t.addEventListener("contextmenu",n),e.host.appendChild(t);function a(l,i,d){let{t:b}=e.getI18n(),M=l.querySelector(".kanuni-pivot-area-header"),T=l.querySelector(".kanuni-pivot-area-content"),F=d.collapsed===true;if(F&&l.setAttribute("data-collapsed",""),M&&F){let g=pivotgridCore.countFilteredFields(i);if(g>0){let h=he("kanuni-pivot-area-filtered-count","span");h.textContent=b("filteredFieldCount").replace("{0}",String(g)),M.appendChild(h);}}if(M&&e.onToggleCollapsed&&i.length>0){let g=he("kanuni-pivot-area-collapse","button");g.type="button";let h=b(F?"expandFilterArea":"collapseFilterArea");g.setAttribute("aria-expanded",String(!F)),g.setAttribute("aria-label",h),g.title=h;let p=X("chevron-down",14);F||(p.style.transform="rotate(180deg)"),g.appendChild(p),g.addEventListener("click",w=>{w.stopPropagation(),e.onToggleCollapsed();}),M.appendChild(g);}let m=pivotgridCore.filterAreaRows({filterAreaMaxRows:d.maxRows,filterAreaCollapsed:F,filterAreaCollapsedRows:d.collapsedRows});if(!T||m===null)return;if(m===0){T.style.display="none";return}let f=T.querySelector(".kanuni-pivot-field-chip");T.style.maxHeight=`${pivotgridCore.filterAreaMaxHeight(m,f?.offsetHeight||28)}px`,T.style.overflowY=F?"hidden":"auto";}return {element:t,paint(l,i,d={}){t.style.display=i?"":"none";let b=Je(t);if(t.textContent="",!i)return;let M=he("pivot-flex");M.style.width="100%";let{t:T,locale:F}=e.getI18n(),m=je("filter",T("filterArea"),"filter",Ct(l,F),e);M.appendChild(m),t.appendChild(M),a(m,l,d),Qe(t,b);},destroy(){t.removeEventListener("contextmenu",n),t.remove();}}}var Et="kanuni-pivot-drop-indicator";function An(e){let t=he(Et);Object.assign(t.style,{position:"absolute",zIndex:"100",pointerEvents:"none",top:"-4px",bottom:"-4px",width:"0"}),t.style.setProperty(e==="before"?"inset-inline-start":"inset-inline-end","-4px");let n=he("");Object.assign(n.style,{position:"absolute",top:"0",width:"0",height:"0",borderTop:"5px solid var(--pivot-primary)"}),n.style.setProperty("inset-inline-start","-4px"),n.style.setProperty("border-inline-start","4px solid transparent"),n.style.setProperty("border-inline-end","4px solid transparent");let a=he("");Object.assign(a.style,{position:"absolute",bottom:"0",width:"0",height:"0",borderBottom:"5px solid var(--pivot-primary)"}),a.style.setProperty("inset-inline-start","-4px"),a.style.setProperty("border-inline-start","4px solid transparent"),a.style.setProperty("border-inline-end","4px solid transparent");let l=he("");return Object.assign(l.style,{position:"absolute",top:"0",bottom:"0",width:"2px",backgroundColor:"var(--pivot-primary)"}),l.style.setProperty("inset-inline-start","-1px"),t.append(n,a,l),t}function kt(e,t){for(let n of e){for(let a of n.querySelectorAll(`.${Et}`))a.remove();for(let a of n.querySelectorAll('[data-drop-id$="-ghost-end"]'))a.style.backgroundColor="transparent",a.style.boxShadow="none",a.textContent="";for(let a of n.querySelectorAll(".pivot-area-strip--over"))a.classList.remove("pivot-area-strip--over");for(let a of n.querySelectorAll('[data-drop-kind="list"]'))a.style.backgroundColor="transparent",a.style.boxShadow="none";}if(t.intent==="before"||t.intent==="after"){if(!t.targetId)return;for(let n of e){let a=n.querySelector(`.kanuni-pivot-field-chip[data-drop-id="${t.targetId}"]`)??n.querySelector(`[data-drop-id="${t.targetId}"]`)??n.querySelector(`[data-drop-id="chooser-${t.targetId}"]`);if(a){a.appendChild(An(t.intent));return}}}else if(t.intent==="append"&&t.targetArea)for(let n of e){let a=n.querySelector(`[data-drop-id="${t.targetArea}-ghost-end"]`)??n.querySelector(`[data-drop-id="chooser-${t.targetArea}-ghost-end"]`);if(a&&(a.style.backgroundColor="color-mix(in srgb, var(--pivot-primary) 10%, transparent)",a.style.boxShadow="inset 0 0 0 1px color-mix(in srgb, var(--pivot-primary) 50%, transparent)",a.getAttribute("data-ghost-populated")==="1")){let d=he("");Object.assign(d.style,{width:"4px",height:"100%",backgroundColor:"var(--pivot-primary)",borderRadius:"2px",marginLeft:"4px"}),a.appendChild(d);}n.querySelector(`[data-drop-id="${t.targetArea}"]`)?.classList.add("pivot-area-strip--over");let i=n.querySelector(`[data-drop-id="chooser-${t.targetArea}"][data-drop-kind="list"]`);i&&(i.style.backgroundColor="color-mix(in srgb, var(--pivot-primary) 5%, transparent)",i.style.boxShadow="inset 0 0 0 1px color-mix(in srgb, var(--pivot-primary) 50%, transparent)");}}var Vn={style:{}},zn=28,Mt=5,$n=10,Lt=40,St=8,et=100;function Y(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function ee(e,t){for(let[n,a]of Object.entries(t)){if(a==null)continue;let l=n.replace(/[A-Z]/g,i=>"-"+i.toLowerCase());e.style.setProperty(l,typeof a=="number"&&a!==0&&!/z-?index|font-?weight|opacity/i.test(n)?`${a}px`:String(a));}}function Ke(e,t,n,a){let l=Y("kanuni-pivot-resize-handle");return l.setAttribute("data-resize-id",e),l.setAttribute("data-resize-default",String(t)),n>1&&l.setAttribute("data-resize-span",String(n)),l.style.setProperty(a,"-3px"),l}function ze(e,t){e.textContent="",t!=null&&(typeof t=="string"||typeof t=="number"?e.textContent=String(t):e.appendChild(t));}function Te(e,t){e.classList.add("kanuni-pivot-rh-sticky"),e.style.setProperty("inset-inline-start",t);}function Pt(e){let{host:t,getI18n:n}=e,a=e.columnWidthDefaults??pivotgridCore.resolveColumnWidthDefaults(),l=e.rowHeight??(()=>zn),i=e.shared?.cellId??((S,A)=>`pivot-cell-${S}-${A}`),d=Y("datagrid-table-wrapper custom-scrollbar pivot-right-pane");ee(d,{overflow:"auto",flex:"1 1 auto",minHeight:0,position:"relative",outline:"none"}),d.tabIndex=0,d.setAttribute("role","grid");let b=Y("");ee(b,{width:"max-content",position:"relative",minWidth:"100%"});let M=Y("kanuni-pivot-table","table");M.setAttribute("role","presentation"),ee(M,{borderCollapse:"separate",borderSpacing:0,width:0,minWidth:"100%",tableLayout:"fixed"});let T=document.createElement("colgroup"),F=Y("","thead");F.setAttribute("role","rowgroup"),ee(F,{position:"sticky",top:0,zIndex:50,backgroundColor:"var(--pivot-surface-header)"});let m=Y("","tbody");m.setAttribute("role","rowgroup"),M.append(T,F,m),b.appendChild(M),d.appendChild(b),t.appendChild(d);let f=null,g=Ne(n().locale),h=n().locale,p={start:-1,end:-1},w={start:0,end:Number.MAX_SAFE_INTEGER},s={},k=new Set,y=false,C=()=>f?Math.max(f.colHeaders.length,1)*l()+(e.chipDeps?42:0):0,o=S=>s[`row-${S}`]??a.rowHeader,c=()=>s[`row-${f.maxRowDepth}`]??et,r=S=>s[`leaf-${S}`]??a.data;function x(){if(!f||f.totalDataCols<=Lt){w={start:0,end:Number.MAX_SAFE_INTEGER};return}let S=Math.abs(d.scrollLeft),A=E().total,B=S-A,W=0,U=0;for(;W<f.totalDataCols&&U+r(W)<=B;)U+=r(W),W++;W=Math.max(0,W-St);let de=d.clientWidth||0,ge=W,Z=0;for(;ge<f.totalDataCols&&Z<=de;)Z+=r(ge),ge++;w={start:W,end:Math.min(f.totalDataCols,ge+St)};}function u(){if(!f)return {start:0,end:0};let S=Math.max(0,d.scrollTop-C()),A=Math.max(0,Math.floor(S/l())-Mt),B=Math.ceil((d.clientHeight||600)/l())+$n;return {start:A,end:Math.min(f.virtualRows.length,A+B+Mt)}}function E(){let S=[];for(let A=0;A<f.maxRowDepth;A++)S.push(o(A));return f.showDataInRows&&S.push(c()),pivotgridCore.computeRowHeaderWidths(S,R(S.length)?0:d.clientWidth)}function R(S){let A=f.layout.rowHeaderOverflow;return A==="scroll"||pivotgridCore.rowHeadersUnpinned(S,d.clientWidth,A)}function P(){d.classList.toggle("kanuni-pivot-rowheaders-scroll",R(f.maxRowDepth+(f.showDataInRows?1:0)));let{widths:S,total:A}=E(),B=0;for(let W=0;W<S.length;W++)d.style.setProperty(`--row-header-left-${W}`,`${B}px`),d.style.setProperty(`--col-width-row-${W}`,`${S[W]}px`),k.add(`--col-width-row-${W}`),B+=S[W];d.style.setProperty("--row-header-total-width",`${A}px`);}function D(){T.textContent="";for(let S=0;S<f.maxRowDepth;S++){let A=document.createElement("col");A.style.width=`var(--col-width-row-${S}, ${a.rowHeader}px)`,T.appendChild(A);}if(f.showDataInRows){let S=document.createElement("col");S.style.width=`var(--col-width-row-${f.maxRowDepth}, ${et}px)`,T.appendChild(S);}for(let S=0;S<Math.max(f.totalDataCols,1);S++){let A=document.createElement("col");A.style.width=`var(--col-width-data-${S}, ${a.data}px)`,T.appendChild(A);}}function I(){let{colHeaders:S,rowFields:A,colFields:B,dataFields:W,maxRowDepth:U,showDataInRows:de,layout:ge,dataColOffset:Z}=f,{t:ue,locale:L}=n(),$=Je(F);F.textContent="";let K=Math.max(S.length,1),v=e.chipDeps;if(v){let z=Y("","tr");z.setAttribute("role","row"),ee(z,{height:42});let O=Y("","th");O.setAttribute("role","columnheader"),O.colSpan=Math.max(Z,1),ee(O,{position:"sticky",zIndex:61,borderBottom:"1px solid var(--pivot-border)",borderInlineEnd:"1px solid var(--pivot-border)",padding:0,verticalAlign:"top",minWidth:50,backgroundColor:"var(--pivot-surface-header)"}),O.style.setProperty("inset-inline-start","0px"),O.appendChild(je("data",ue("dataArea"),"bar-chart-3",W,v)),z.appendChild(O);let G=Y("","th");G.setAttribute("role","columnheader"),G.colSpan=Math.max(f.totalDataCols,1),ee(G,{borderBottom:"1px solid var(--pivot-border)",padding:0,verticalAlign:"top",zIndex:1,backgroundColor:"var(--pivot-surface-header)"});let N=Y("");ee(N,{position:"sticky",width:"max-content",maxWidth:"100%"}),N.style.setProperty("inset-inline-start","var(--row-header-total-width, 0px)"),N.appendChild(je("column",ue("columnArea"),"columns3",B,v)),G.appendChild(N),z.appendChild(G),F.appendChild(z);}for(let z=0;z<K;z++){let O=Y("","tr");if(O.setAttribute("role","row"),ee(O,{height:l()}),z===0){let N=j=>({position:"sticky",top:0,zIndex:60,backgroundColor:"var(--pivot-surface-header)",borderBottom:"1px solid var(--pivot-border)",borderInlineEnd:j?"1px solid var(--pivot-border)":"none",verticalAlign:"bottom",padding:"4px 8px",color:"var(--pivot-text-header)"});if(A.length===0){let j=Y("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");j.setAttribute("data-drop-id","row"),j.setAttribute("data-row-header-idx","0"),j.rowSpan=K,j.colSpan=Math.max(Z,1),ee(j,{...N(true),padding:"8px",color:"color-mix(in srgb, var(--pivot-text-header, var(--pivot-text)) 70%, transparent)"}),Te(j,"var(--row-header-left-0, 0px)"),j.textContent=ue("dropHere"),O.appendChild(j);}else if(ge.rowHeaderLayout==="tree"){let j=Y("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");if(j.setAttribute("data-row-header-idx","0"),j.rowSpan=K,ee(j,N(!de)),Te(j,"var(--row-header-left-0, 0px)"),v){let _=Y("");ee(_,{display:"flex",flexWrap:"wrap",gap:4});for(let oe of A)_.appendChild(Ge(oe,v));j.appendChild(_);}else ze(j,A.map(_=>_.caption).join(", "));O.appendChild(j);}else for(let j=0;j<U;j++){let _=Y("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");_.setAttribute("data-row-header-idx",String(j)),_.rowSpan=K,ee(_,N(j===U-1&&!de)),Te(_,`var(--row-header-left-${j}, 0px)`);let oe=A[j];oe&&v&&_.setAttribute("data-drop-id",oe.id),oe&&v?_.appendChild(Ge(oe,v)):ze(_,oe?.caption??""),O.appendChild(_);}if(de&&A.length>0){let j=Y("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");j.setAttribute("data-row-header-idx",String(U)),j.rowSpan=K,ee(j,N(true)),Te(j,`var(--row-header-left-${U}, 0px)`);let _=Y("");ee(_,{fontSize:10,fontWeight:600,textTransform:"uppercase",textAlign:"center",color:"color-mix(in srgb, var(--pivot-text-header, var(--pivot-text)) 80%, transparent)"}),_.style.letterSpacing="0.05em",_.textContent=ue("dataArea"),j.appendChild(_),O.appendChild(j);}}let G=S[z]??[];for(let N of G){let j=N.fieldId?B.find(se=>se.id===N.fieldId):void 0,_=!!j?.filterValues&&j.filterValues.size>0,oe=N.leafStart,xe=j&&!N.isTotal?pivotgridCore.formatDimensionValue(N.caption,j,"grid",L):N.caption,ae={text:typeof j?.cellTemplate=="function"?j.cellTemplate({value:N.caption,displayValue:xe,field:j})??null:String(xe??""),style:{textAlign:"left",fontWeight:N.isTotal?600:500,borderBottom:"1px solid var(--pivot-border)",borderRight:"1px solid var(--pivot-border)",color:"var(--pivot-text-header, inherit)",backgroundColor:"var(--pivot-surface-header)",cursor:j?"pointer":"context-menu",position:"relative",zIndex:1,padding:"4px 6px"},className:`kanuni-pivot-header-cell group ${N.isTotal?"kanuni-pivot-header-total":""}`};e.onCellPrepared?.({area:"column",cell:null,rowIndex:z,columnIndex:oe,cellConfig:ae}),ae.style.fontWeight=N.isTotal?pivotgridCore.paintedFontWeight(ae.style.fontWeight,600,"--pivot-font-weight-header-total"):pivotgridCore.paintedFontWeight(ae.style.fontWeight,500,"--pivot-font-weight-header");let Q=Y(ae.className,"th");Q.setAttribute("role","columnheader"),N.hasChildren&&Q.setAttribute("aria-expanded",String(!!N.isExpanded)),Q.colSpan=N.colSpan,Q.rowSpan=N.rowSpan,ee(Q,ae.style);let ve=Y("pivot-flex pivot-items-center");if(ee(ve,{gap:4}),N.hasChildren){let se=Y("kanuni-pivot-expand-icon","span");se.textContent=N.isExpanded?"\u2212":"+",se.setAttribute("aria-hidden","true"),se.setAttribute("data-col-expand",N.colPath??""),ee(se,{cursor:"pointer",marginRight:4,flexShrink:0}),ve.appendChild(se);}let ce=Y("select-none","span");ze(ce,ae.text),ve.appendChild(ce);let le=f.rowFields.find(se=>se.sortBySummaryField===N.fieldId&&(se.sortBySummaryPath||"")===(N.colPath||""));if(le){let se=Y("pivot-text-primary kanuni-pivot-sort-arrow","span");se.appendChild(X(le.sortOrder==="asc"?"arrow-up":"arrow-down",12)),ve.appendChild(se);}if(N.fieldId){let se=Y(`kanuni-pivot-head-filter cursor-pointer transition-opacity ${_?"opacity-100 pivot-text-danger":"opacity-0 group-hover:opacity-70"}`,"span");se.setAttribute("data-filter-field",N.fieldId),se.appendChild(_?Ve("filter",10):X("filter",10)),ve.appendChild(se);}Q.appendChild(ve),N.fieldId&&Q.setAttribute("data-header-field",N.fieldId),N.colPath!==void 0&&Q.setAttribute("data-header-col-path",N.colPath),Q.setAttribute("data-header-depth",String(z)),Q.appendChild(Ke(`leaf-${oe}-${N.colSpan}`,a.data,N.colSpan,"right")),O.appendChild(Q);}F.appendChild(O);}Qe(F,$);}function H(S,A,B,W){let U=A.flatRow,{rowFields:de,layout:ge,maxRowDepth:Z,virtualRows:ue}=f,{locale:L}=n(),$=ge.rowHeaderLayout==="tree",K=$?U.depth:W,v=U.pathValues[K],z=U.rowSpans[W]>0&&A.dfIndex===0,O=de[K],G=O&&v!==null&&v!==void 0?pivotgridCore.formatDimensionValue(v,O,"grid",L):v,N=K===U.depth,j=K<U.depth,_=N?U.hasChildren:j,oe=N?U.isExpanded:j,xe=ue[B+1],Me=!$&&xe&&!xe.isGrandTotal&&xe.flatRow&&!xe.flatRow.isSubtotal&&(xe.flatRow.rowSpans[W]===0||xe.dfIndex>0)&&xe.flatRow.pathValues[W]===v,ae=pivotgridCore.rowHeaderGroupEnd(ue,B,W,$),Q=ge.rowHeaderGroupLines===true,ve=G!=null?String(G):null;typeof O?.cellTemplate=="function"&&ve!==null&&(ve=O.cellTemplate({value:G,displayValue:G,field:O})??ve);let ce={text:ve,style:{position:"sticky",backgroundColor:"var(--pivot-surface)",zIndex:40,cursor:_?"pointer":"default",fontWeight:G&&K<U.depth?600:400,verticalAlign:"middle",padding:0,borderBottom:Q?ae?"1px solid var(--pivot-border)":"none":Me?"none":"1px solid var(--pivot-border)",height:l()},className:`kanuni-pivot-cell kanuni-pivot-row-header ${_?"kanuni-pivot-row-expandable":""}${e.shared?.focused?.r===B&&e.shared?.focused?.c===W?" kanuni-pivot-cell-focused":""}${We(e.shared?.selection??null,B,W)?" kanuni-pivot-cell-selected":""}`};e.onCellPrepared?.({area:"row",cell:null,rowIndex:B,columnIndex:W,cellConfig:ce}),G&&K<U.depth&&(ce.style.fontWeight=pivotgridCore.paintedFontWeight(ce.style.fontWeight,600,"--pivot-font-weight-group"));let le=Y(ce.className,"td");if(le.id=i(B,W),le.setAttribute("role","rowheader"),_&&le.setAttribute("aria-expanded",String(oe)),le.setAttribute("data-r",String(B)),le.setAttribute("data-c",String(W)),ae&&le.setAttribute("data-group-end",""),ee(le,ce.style),Te(le,`var(--row-header-left-${W}, 0px)`),!$&&W>=U.depth&&W<Z-1&&le.style.setProperty("border-inline-end","none"),!z&&!$){Q||(le.style.borderBottom="none"),le.appendChild(Ke(`row-${W}`,a.rowHeader,1,n().rtl?"left":"right")),S.appendChild(le);return}le.setAttribute("data-group-start","");let se=$?U.depth*20:0,Se=Y("");if(ee(Se,{display:"flex",alignItems:"center",gap:4,padding:"0 8px",height:"100%",position:"relative"}),Se.style.setProperty("padding-inline-start",`${8+se}px`),$&&U.depth>0){let Le=Y("kanuni-pivot-tree-line");ee(Le,{position:"absolute",left:se,top:-l()/2,width:12,height:l(),borderLeft:"1px dotted var(--pivot-border)",borderBottom:"1px dotted var(--pivot-border)"}),Se.appendChild(Le);}if(ce.text!==null&&ce.text!==void 0){if(_){let ke=Y("kanuni-pivot-expand-icon","span");ke.textContent=oe?"\u2212":"+",ke.setAttribute("aria-hidden","true"),ee(ke,{flexShrink:0,position:"relative",zIndex:2}),Se.appendChild(ke);}else {let ke=Y("","span");ee(ke,{width:14,flexShrink:0}),Se.appendChild(ke);}let Le=Y("truncate","span");ze(Le,ce.text),ge.textOverflow==="clip"&&(typeof ce.text=="string"||typeof ce.text=="number")&&(Le.title=String(ce.text)),Se.appendChild(Le);}le.appendChild(Se),le.appendChild(Ke(`row-${W}`,a.rowHeader,1,n().rtl?"left":"right")),S.appendChild(le);}function V(S,A,B,W,U){let{dataFields:de,leafColHashes:ge,dfsPerLeaf:Z,dataColOffset:ue,showDataInRows:L,totalDataCols:$}=f,K=$>Lt,v=e.registry?e.registry.getPluginsByType("cellRender"):null;ge.forEach((z,O)=>{let G=O*Z,N=L?[de[B]]:de,j=K&&(G+Z<=w.start||G>=w.end),_=j?null:Ye(f,A,z.hash,W,z.isGrandTotal);N.forEach((oe,xe)=>{let Me=G+xe,ae=ue+Me,Q=Y("kanuni-pivot-cell","td");if(Q.id=i(U,ae),Q.setAttribute("role","gridcell"),Q.setAttribute("data-r",String(U)),Q.setAttribute("data-c",String(ae)),j||K&&(Me<w.start||Me>=w.end)){S.appendChild(Q);return}let ve=_?.values[`${oe.id}_display`]??_?.values[oe.id],ce=g(ve,oe),le=W||z.isGrandTotal||!!_?.isTotalCell,se=oe.conditionalFormatting?pivotgridCore.resolveConditionalVisual(_?.values[oe.id],oe,_??null,f.fieldRanges[oe.id]):Vn,Se=se.style,Le=ce;if(typeof oe.cellTemplate=="function")Le=oe.cellTemplate({value:ve,displayValue:ce,cell:_,field:oe})??null;else if(v){for(let Pe of v)if(Pe.renderCell){let Xe=Pe.renderCell(ve,ce,_,oe);if(Xe!=null){Le=Xe;break}}}let ke={text:Le,style:{textAlign:oe.dataType==="number"?"right":"left",fontWeight:le?600:400,backgroundColor:le?"var(--pivot-bg)":"transparent",cursor:e.hasCellClick?.()&&_?"pointer":"default",...Se},className:`kanuni-pivot-cell ${le?"kanuni-pivot-cell-total":""}${e.shared?.focused?.r===U&&e.shared?.focused?.c===ae?" kanuni-pivot-cell-focused":""}${We(e.shared?.selection??null,U,ae)?" kanuni-pivot-cell-selected":""}`};if(e.onCellPrepared?.({area:"data",cell:_,rowIndex:U,columnIndex:ae,cellConfig:ke}),le&&(ke.style.fontWeight=pivotgridCore.paintedFontWeight(ke.style.fontWeight,600,"--pivot-font-weight-total")),Q.className=ke.className,ee(Q,ke.style),Q.setAttribute("data-val",typeof ve=="number"?String(ve):""),ze(Q,ke.text),se.dataBar){let Pe=Math.round(se.dataBar.ratio*100);Q.style.setProperty("background-image",`linear-gradient(to ${n().rtl?"left":"right"}, ${se.dataBar.color} ${Pe}%, transparent ${Pe}%)`),Q.style.setProperty("background-repeat","no-repeat");}if(se.icon){let Pe=X(se.icon,12);Pe.style.setProperty("margin-inline-end","4px"),Pe.style.setProperty("vertical-align","middle"),Q.insertBefore(Pe,Q.firstChild);}S.appendChild(Q);});});}let q=(S,A)=>e.shared?.focused?.r===S&&e.shared?.focused?.c===A?" kanuni-pivot-cell-focused":"";function ie(S){let A=S.flatRow;return S.isGrandTotal||!A?{level:1}:A.isSubtotal||!A.hasChildren?{level:A.depth+1}:{level:A.depth+1,expanded:!!A.isExpanded}}function pe(S,A){let{t:B}=n(),{maxRowDepth:W,showDataInRows:U,dataFields:de,layout:ge}=f,Z=Y("kanuni-pivot-row","tr");if(Z.setAttribute("role","row"),Z.setAttribute("aria-rowindex",String(A+1)),ee(Z,{height:l()}),ge.rowHeaderLayout==="tree"){let L=ie(S);Z.setAttribute("aria-level",String(L.level)),L.expanded!==void 0&&Z.setAttribute("aria-expanded",String(L.expanded));}if(S.isGrandTotal){Z.classList.add("kanuni-pivot-grand-total-row");for(let L=0;L<W;L++){let $=L===0,K=Y("kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total"+q(A,L),"td");K.id=i(A,L),K.setAttribute("role",$?"rowheader":"presentation"),ee(K,{position:"sticky",zIndex:40,fontWeight:"var(--pivot-font-weight-grand-total, 700)",backgroundColor:"var(--pivot-surface)",paddingLeft:$?8:0,paddingRight:0,borderRight:L===W-1?"1px solid var(--pivot-border)":"none",whiteSpace:$?"nowrap":"normal",overflow:$?"visible":"hidden"}),Te(K,`var(--row-header-left-${L}, 0px)`),$&&(K.textContent=`${B("grandTotal")}${U?` \u2014 ${de[S.dfIndex]?.caption??""}`:""}`),Z.appendChild(K);}if(U){let L=Y("kanuni-pivot-cell kanuni-pivot-cell-total"+q(A,W),"td");L.id=i(A,W),L.setAttribute("role","gridcell"),ee(L,{position:"sticky",zIndex:40,backgroundColor:"var(--pivot-surface)"}),Te(L,`var(--row-header-left-${W}, 0px)`),L.textContent=String(de[S.dfIndex]?.caption??""),Z.appendChild(L);}return V(Z,"",S.dfIndex,true,A),Z}let ue=S.flatRow;if(ue.isSubtotal){Z.classList.add("kanuni-pivot-subtotal-row");let L=`${B("subTotal")}: ${ue.pathValues[ue.depth]}`;if(ge.rowHeaderLayout==="tree"){let $=Y("kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total"+q(A,0),"td");$.id=i(A,0),$.setAttribute("role","rowheader"),ee($,{position:"sticky",zIndex:40,fontWeight:"var(--pivot-font-weight-total, 600)",backgroundColor:"var(--pivot-surface)",paddingLeft:8+ue.depth*20}),Te($,"var(--row-header-left-0, 0px)"),$.textContent=L,Z.appendChild($);}else for(let $=0;$<W;$++){if($<ue.depth){H(Z,S,A,$);continue}let K=$===ue.depth,v=Y("kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total"+q(A,$),"td");v.id=i(A,$),v.setAttribute("role",K?"rowheader":"presentation"),ee(v,{position:"sticky",zIndex:40,fontWeight:"var(--pivot-font-weight-total, 600)",backgroundColor:"var(--pivot-surface)",paddingLeft:K?8:0,paddingRight:0,borderRight:$===W-1?"1px solid var(--pivot-border)":"none",whiteSpace:K?"nowrap":"normal",overflow:K?"visible":"hidden"}),Te(v,`var(--row-header-left-${$}, 0px)`),K&&(v.textContent=L),Z.appendChild(v);}if(U){let $=Y("kanuni-pivot-cell kanuni-pivot-cell-total"+q(A,W),"td");$.id=i(A,W),$.setAttribute("role","gridcell"),ee($,{position:"sticky",zIndex:40,backgroundColor:"var(--pivot-surface)"}),Te($,`var(--row-header-left-${W}, 0px)`),$.textContent=String(de[S.dfIndex]?.caption??""),Z.appendChild($);}return V(Z,ue.key,S.dfIndex,true,A),Z}for(let L=0;L<W;L++)H(Z,S,A,L);if(U){let L=Y("kanuni-pivot-cell kanuni-pivot-row-header"+q(A,W),"td");if(L.id=i(A,W),L.setAttribute("role","rowheader"),ee(L,{position:"sticky",zIndex:40,backgroundColor:"var(--pivot-surface)"}),Te(L,`var(--row-header-left-${W}, 0px)`),S.isDataRow){let $=Y("","span");ee($,{color:"var(--pivot-text-muted)",paddingLeft:8}),$.textContent=String(de[S.dfIndex]?.caption??""),L.appendChild($);}L.appendChild(Ke(`row-${W}`,et,1,n().rtl?"left":"right")),Z.appendChild(L);}return V(Z,ue.key,S.dfIndex,false,A),Z}function re(){if(y||!f)return;let S=u();if(x(),p=S,m.textContent="",S.start>0){let A=Y("","tr");ee(A,{height:S.start*l()});let B=Y("","td");B.colSpan=f.dataColOffset+Math.max(f.totalDataCols,1),ee(B,{padding:0,border:"none"}),A.appendChild(B),m.appendChild(A);}for(let A=S.start;A<S.end;A++)m.appendChild(pe(f.virtualRows[A],A));ee(b,{height:C()+f.virtualRows.length*l()});}function fe(S){if(y)return;let A=n();A.locale!==h&&(h=A.locale,g=Ne(A.locale)),s=S.columnWidths??{},f=vt(S,{grandTotal:A.t("grandTotal"),subTotal:A.t("subTotal")}),d.setAttribute("role",f.layout.rowHeaderLayout==="tree"?"treegrid":"grid"),d.setAttribute("aria-rowcount",String(f.virtualRows.length+f.colHeaders.length+(e.chipDeps?1:0))),d.setAttribute("aria-colcount",String(f.dataColOffset+f.totalDataCols)),d.setAttribute("aria-label",A.t("pivotView"));let B=e.shared?.focused;B?d.setAttribute("aria-activedescendant",i(B.r,B.c)):d.removeAttribute("aria-activedescendant");for(let W of k)d.style.removeProperty(W);k.clear(),P();for(let[W,U]of Object.entries(s)){if(!W.startsWith("leaf-"))continue;let de=`--col-width-data-${W.slice(5)}`;d.style.setProperty(de,`${U}px`),k.add(de);}D(),I(),p={start:-1,end:-1},re();}let ye=()=>{if(y||!f)return;let S=u(),A=w.start;x(),(S.start!==p.start||S.end!==p.end||w.start!==A)&&re();};d.addEventListener("scroll",ye,{passive:true});let Ee=()=>{if(y||!f)return;P();let S=u(),A=w.start,B=w.end;x(),(S.start!==p.start||S.end!==p.end||w.start!==A||w.end!==B)&&re();},J=typeof ResizeObserver<"u"?new ResizeObserver(()=>Ee()):null;return J?.observe(d),{getVM:()=>f,getTheadHeight:C,paintStructural:fe,paintWindow:re,refreshWindow:Ee,rowHeaderLayout(){let S=[];if(f){for(let A=0;A<f.maxRowDepth;A++)S.push(o(A));f.showDataInRows&&S.push(c());}return {configured:S,viewport:f&&R(S.length)?0:d.clientWidth}},scroller:d,destroy(){y=true,J?.disconnect(),d.removeEventListener("scroll",ye),d.remove();}}}var Nn=0;function Rt(){let e=`kp${++Nn}-`;return {lastResizeTime:0,isResizing:false,focused:null,selection:null,cellId:(t,n)=>`${e}pivot-cell-${t}-${n}`}}function At(e){let{scroller:t,controller:n,getVM:a,shared:l}=e,i=o=>o?.closest?.("td[data-r][data-c]")??null;function d(o,c){let r=l.focused;l.focused={r:o,c},r&&t.querySelector(`td[id="${l.cellId(r.r,r.c)}"]`)?.classList.remove("kanuni-pivot-cell-focused"),t.querySelector(`td[id="${l.cellId(o,c)}"]`)?.classList.add("kanuni-pivot-cell-focused"),t.setAttribute("aria-activedescendant",l.cellId(o,c));}function b(o,c,r){if(!e.onCellClick)return;let x=a();if(!x)return;let u=gt(x,c,r);if(!u)return;let E={event:o,cellType:u.isTotal?"grandTotal":"data",value:u.val,rowPath:u.cell.rowPath,colPath:u.cell.colPath};e.onCellClick(e.resolveCellClick?e.resolveCellClick(E):E);}let M=o=>{let c=o.target,r=c.closest("[data-col-expand]");if(r){n.toggleColExpanded(r.getAttribute("data-col-expand")??"");return}if(c.closest(".kanuni-pivot-resize-handle"))return;let x=c.closest("[data-filter-field]");if(x){e.onFilterClick?.(o.clientX,o.clientY,x.getAttribute("data-filter-field")??"");return}let u=c.closest("th[data-header-field]");if(u){if(Date.now()-l.lastResizeTime<100)return;let I=a();if(!I)return;let H=u.getAttribute("data-header-field")??"",V=u.getAttribute("data-header-col-path")??"",q=I.rowFields.find(ie=>ie.sortBySummaryField===H&&(ie.sortBySummaryPath||"")===V);q&&n.sortField(q.id,q.sortOrder==="asc"?"desc":"asc");return}let E=i(c);if(!E)return;let R=Number(E.getAttribute("data-r")),P=Number(E.getAttribute("data-c")),D=a();if(D){if(t.focus({preventScroll:true}),d(R,P),P<D.dataColOffset){if(Date.now()-l.lastResizeTime<100)return;let I=Ze(D,R,P);I?.hasChildren&&n.toggleExpanded(I.cellHashStr);return}b(o,R,P);}},T=o=>{if(o.target.closest?.(".kanuni-pivot-resize-handle"))return;let c=i(o.target);if(!c)return;let r=Number(c.getAttribute("data-r")),x=Number(c.getAttribute("data-c")),u=a();!u||x<u.dataColOffset||b(o,r,x);},F=o=>{let c=o.target.closest?.("th[data-header-field]");if(c){o.preventDefault(),c.hasAttribute("aria-expanded")?e.onNodeContextMenu?.({x:o.clientX,y:o.clientY,path:c.getAttribute("data-header-col-path")??"",isExpanded:c.getAttribute("aria-expanded")==="true",depth:Number(c.getAttribute("data-header-depth")??0),type:"col"}):e.onHeaderContextMenu&&e.onHeaderContextMenu(o.clientX,o.clientY,c.getAttribute("data-header-field")??"",c.getAttribute("data-header-col-path")??void 0);return}let r=i(o.target);if(!r)return;let x=Number(r.getAttribute("data-r")),u=Number(r.getAttribute("data-c")),E=a();if(E){if(u<E.dataColOffset){let R=Ze(E,x,u);if(R){let{flatRow:P,hasChildren:D,cellHashStr:I,isExpanded:H,depth:V,dIdx:q}=R,ie=E.layout.rowHeaderLayout==="tree",pe=q>P.depth,re=pe?P.hasChildren:D;if(re&&e.onNodeContextMenu){o.preventDefault(),e.onNodeContextMenu({x:o.clientX,y:o.clientY,path:pe?ie?P.key:pivotgridCore.pathKey(P.pathValues.slice(0,P.depth+1)):I,isExpanded:pe?P.isExpanded:H,depth:pe?P.depth:V,type:"row"});return}if(re)return}}e.onGlobalContextMenu&&(o.preventDefault(),e.onGlobalContextMenu(o.clientX,o.clientY));}},m=e.keyboardEnabled!==false;function f(){let o=l.focused;l.focused=null,o&&t.querySelector(`td[id="${l.cellId(o.r,o.c)}"]`)?.classList.remove("kanuni-pivot-cell-focused"),t.removeAttribute("aria-activedescendant");}let g=new Set(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),h=o=>{if(o.target!==t)return;let c=a();if(!c)return;if(!l.focused){if(!g.has(o.key)||c.virtualRows.length===0)return;o.preventDefault(),d(0,0),(o.shiftKey||!(o.ctrlKey||o.metaKey))&&l.selectByKey?.(0,0,false,{r:0,c:0});return}let{r,c:x}=l.focused,u={r,c:x},E=o.ctrlKey||o.metaKey,R=c.dataColOffset+c.totalDataCols,P=e.rowHeight?.()??28,D=e.getTheadHeight?.()??c.colHeaders.length*P,I=Math.max(1,Math.ceil(((t.clientHeight||600)-D)/P));switch(o.key){case "ArrowDown":o.preventDefault(),r=Math.min(c.virtualRows.length-1,r+1);break;case "ArrowUp":o.preventDefault(),r=Math.max(0,r-1);break;case "ArrowRight":o.preventDefault(),x=Math.min(R-1,x+1);break;case "ArrowLeft":o.preventDefault(),x=Math.max(0,x-1);break;case "Home":o.preventDefault(),(o.ctrlKey||o.metaKey)&&(r=0),x=0;break;case "End":o.preventDefault(),(o.ctrlKey||o.metaKey)&&(r=c.virtualRows.length-1),x=R-1;break;case "PageDown":o.preventDefault(),r=Math.min(c.virtualRows.length-1,r+I-1);break;case "PageUp":o.preventDefault(),r=Math.max(0,r-I+1);break;case "Escape":o.preventDefault(),f();return;case " ":case "Enter":{o.preventDefault(),o.key===" "&&l.selectByKey?.(r,x,o.shiftKey,u);let q=t.querySelector(`td[id="${l.cellId(r,x)}"]`);q&&(o.key===" "?q.click():q.dispatchEvent(new MouseEvent("dblclick",{bubbles:true})));return}default:return}let H=D+r*P,V=t.clientHeight||600;H<t.scrollTop+D?(t.scrollTop=H-D,t.dispatchEvent(new Event("scroll"))):H+P>t.scrollTop+V&&(t.scrollTop=H+P-V,t.dispatchEvent(new Event("scroll"))),d(r,x),(o.shiftKey||!E)&&l.selectByKey?.(r,x,o.shiftKey,u),x>=c.dataColOffset&&p(r,x,c.dataColOffset);};function p(o,c,r){let x=t.querySelector(`td[id="${l.cellId(o,c)}"]`)??t.querySelector(`td[data-c="${c}"]`);if(!x)return;let u=t.getBoundingClientRect(),E=getComputedStyle(t).direction==="rtl",R=t.querySelector(`td[data-c="${r-1}"]`)?.getBoundingClientRect(),P=x.getBoundingClientRect(),D=E?u.right-t.clientWidth:u.left,I=E?D:R?R.right:D,H=E&&R?R.left:D+t.clientWidth,V=0;P.left<I?V=P.left-I:P.right>H&&(V=Math.min(P.right-H,P.left-I)),V!==0&&(t.scrollLeft+=V,t.dispatchEvent(new Event("scroll")));}let w=o=>{if(o.button!==0)return;let c=i(o.target);if(!c)return;let r=Number(c.getAttribute("data-r")),x=Number(c.getAttribute("data-c"));l.focused?.r===r&&l.focused.c===x||d(r,x);},s=false,k=()=>{s=true,setTimeout(()=>{s=false;},0);},y=o=>{let c=a();c&&!l.focused&&!s&&o.target===t&&c.virtualRows.length>0&&d(0,0);},C=o=>{o.relatedTarget&&t.contains(o.relatedTarget)||f();};return t.addEventListener("mousedown",k,true),t.addEventListener("pointerdown",k,true),t.addEventListener("click",M),m&&t.addEventListener("mouseup",w),t.addEventListener("dblclick",T),t.addEventListener("contextmenu",F),m?(t.addEventListener("keydown",h),t.addEventListener("focus",y),t.addEventListener("blur",C)):t.removeAttribute("tabindex"),{destroy(){t.removeEventListener("click",M),t.removeEventListener("mouseup",w),t.removeEventListener("dblclick",T),t.removeEventListener("contextmenu",F),t.removeEventListener("mousedown",k,true),t.removeEventListener("pointerdown",k,true),m&&(t.removeEventListener("keydown",h),t.removeEventListener("focus",y),t.removeEventListener("blur",C));}}}function Ht(e){let{host:t,scroller:n,shared:a}=e,l=document.createElement("div");l.className="kanuni-pivot-drag-line",Object.assign(l.style,{position:"absolute",top:"0",bottom:"0",left:"0",width:"2px",backgroundColor:"var(--pivot-primary)",zIndex:"100",display:"none",pointerEvents:"none"}),t.appendChild(l);let i=null,d=1,b=0,M=1,T=0,F=[],m={},f=null,g=-1,h=y=>{l.style.display="block",l.style.transform=`translateX(${pivotgridCore.resizeLineX(y,t)}px)`;},p=y=>{a.isResizing&&h(y.clientX);},w=y=>{if(!a.isResizing||!i)return;l.style.display="none";let C=(y.clientX-b)/M,o=e.isRtl()?-C:C;if(i.startsWith("row-")){let c=Math.max(20,T+o);m[i]=f?pivotgridCore.invertRowHeaderWidth(f.configured,g,c,f.viewport):c;}else if(i.startsWith("leaf-")){let c=i.split("-"),r=parseInt(c[1],10),u=Math.max(d*20,T+o)/T;for(let E=0;E<d;E++)m[`leaf-${r+E}`]=Math.max(20,F[E]*u);}a.isResizing=false,a.lastResizeTime=Date.now(),i=null,document.body.style.cursor="",document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",w),e.commit({...m});},s=y=>{let C=y.target.closest?.(".kanuni-pivot-resize-handle");if(!C||(y.preventDefault(),y.stopPropagation(),i=C.getAttribute("data-resize-id"),!i))return;let o=Number(C.getAttribute("data-resize-default")||150);if(d=Number(C.getAttribute("data-resize-span")||1),b=y.clientX,M=pivotgridCore.cssZoomOf(t),m={...e.getWidths()},i.startsWith("row-"))g=parseInt(i.slice(4),10),f=e.rowHeaderLayout(),T=pivotgridCore.computeRowHeaderWidths(f.configured,f.viewport).widths[g]??m[i]??o;else if(i.startsWith("leaf-")){let c=parseInt(i.split("-")[1],10);F=[],T=0;for(let r=0;r<d;r++){let x=m[`leaf-${c+r}`]||o;F.push(x),T+=x;}}a.isResizing=true,h(y.clientX),document.body.style.cursor="col-resize",document.addEventListener("mousemove",p),document.addEventListener("mouseup",w);},k=y=>{let C=y.target.closest?.(".kanuni-pivot-resize-handle"),o=C?.getAttribute("data-resize-id");if(!C||!o||a.isResizing)return;y.preventDefault(),y.stopPropagation();let c={...e.getWidths()},r=C.closest("th,td");if(o.startsWith("row-")){let x=o.slice(4),u=pivotgridCore.measureFitWidth(Array.from(n.querySelectorAll(`td[data-c="${x}"], th[data-row-header-idx="${x}"]`)),t);if(!u)return;let E=e.rowHeaderLayout();c[o]=pivotgridCore.invertRowHeaderWidth(E.configured,parseInt(x,10),Math.max(pivotgridCore.ROW_HEADER_MIN_COL_WIDTH,u),E.viewport);}else if(o.startsWith("leaf-")){let x=Number(C.getAttribute("data-resize-span")||1),u=parseInt(o.split("-")[1],10),E=e.dataColOffset?.()??0,R=[];for(let I=0;I<x;I++){let H=Array.from(n.querySelectorAll(`td[data-c="${E+u+I}"]`));x===1&&r&&H.unshift(r);let V=pivotgridCore.measureFitWidth(H,t);R.push(V?Math.max(20,V):c[`leaf-${u+I}`]||Number(C.getAttribute("data-resize-default")||95));}let P=R.reduce((I,H)=>I+H,0),D=x>1&&r?pivotgridCore.measureFitWidth([r],t):0;D>P&&(R=R.map(I=>I*D/P)),R.forEach((I,H)=>{c[`leaf-${u+H}`]=I;});}else return;a.lastResizeTime=Date.now(),e.commit(c);};return n.addEventListener("mousedown",s),n.addEventListener("dblclick",k),{destroy(){n.removeEventListener("mousedown",s),n.removeEventListener("dblclick",k),a.isResizing&&(a.isResizing=false,document.body.style.cursor=""),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",w),l.remove();}}}function Dt(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function De(e){let t=Dt("kanuni-pivot-root kanuni-pivot-portal-container");Ot(t,e);let n=nt.get(e);return n||nt.set(e,n=new Set),n.add(t),t}var nt=new WeakMap,It=new WeakMap;function Ot(e,t){for(let i of It.get(e)??[])e.classList.remove(i);let n=Array.from(t.classList).filter(i=>i.startsWith("kanuni-pivot-")&&i!=="kanuni-pivot-root");for(let i of n)e.classList.add(i);It.set(e,n);let a=e.style.getPropertyValue("zoom");e.setAttribute("style",t.getAttribute("style")??"");for(let i of ["position","inset","z-index","width","height"])e.style.removeProperty(i);a&&e.style.setProperty("zoom",a);let l=t.getAttribute("data-theme");l?e.setAttribute("data-theme",l):e.removeAttribute("data-theme"),e.setAttribute("dir",t.getAttribute("dir")??"ltr");}function Vt(e){let t=nt.get(e);if(t)for(let n of Array.from(t)){if(!n.isConnected){t.delete(n);continue}Ot(n,e);}}function Oe(e){e.style.removeProperty("zoom");let t=pivotgridCore.cssZoomOf(e);Math.abs(t-1)>.01&&e.style.setProperty("zoom",String(1/t));}function $e(){let e=document,t=e.fullscreenElement??e.webkitFullscreenElement??null;return t||(document.querySelector(".pivot-is-fullscreen")??document.body)}function ot(e){let t=null,n=null;function a(){n?.(),n=null,t?.remove(),t=null;}function l(i){a(),t=De(e);let d=Dt("kanuni-pivot-portal-root");t.appendChild(d),$e().appendChild(t),Oe(t);let b=i(d),M=t,T=m=>{M.contains(m.target)||a();},F=m=>{m.key==="Escape"&&a();};return document.addEventListener("pointerdown",T,true),document.addEventListener("keydown",F,true),n=()=>{document.removeEventListener("pointerdown",T,true),document.removeEventListener("keydown",F,true),b?.();},d}return {openPopup:l,closePopup:a,isOpen:()=>t!==null,destroy:a}}var $t=new Map;function Bt(e,t,n,a="(Blanks)"){return pivotgridCore.formatHeaderFilterLabel(e,t,n,a)}var Re=28;function be(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}var ro="M11 11l3.5 3.5M12.5 7a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z";function io(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("class","kanuni-pivot-popup-search-icon"),e.setAttribute("width","14"),e.setAttribute("height","14"),e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("fill","none");let t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d",ro),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.5"),t.setAttribute("stroke-linecap","round"),e.appendChild(t),e}function Nt(e){let{portal:t}=e;function n(a,l,i){let d=e.getField(i);if(!d)return;let{t:b,rtl:M,locale:T}=e.getI18n(),F=true,m=[],f=[],g="",h=new Set,p=0,w=220,s=false,k=[];t.openPopup(y=>{let C=be("kanuni-pivot-popup pivot-animate-zoom-in"),o=pivotgridCore.popupViewport(),c=pivotgridCore.placePopup({x:a,y:l},{width:250,height:350},{margin:10,viewport:o});C.setAttribute("role","dialog"),C.setAttribute("aria-label",b("columnFilter")),C.setAttribute("data-datagrid-keyboard-scope","modal"),C.tabIndex=-1,Object.assign(C.style,{left:`${c.left}px`,top:`${c.top}px`,width:"250px",height:`${Math.min(350,c.maxHeight)}px`,minWidth:"200px",minHeight:`${Math.min(250,c.maxHeight)}px`,maxWidth:`${Math.min(600,o.width-20)}px`,maxHeight:`${Math.min(350,c.maxHeight)}px`,resize:"both",direction:M?"rtl":"ltr"});let r=be("kanuni-pivot-popup-header"),x=be("kanuni-pivot-popup-search");x.appendChild(io());let u=be("kanuni-pivot-popup-search-input","input");u.type="text",u.placeholder=b("search"),u.setAttribute("aria-controls","pivot-filter-options"),x.appendChild(u),r.appendChild(x);let E=be("kanuni-pivot-popup-actions"),R=be("kanuni-pivot-popup-action-btn kanuni-pivot-popup-action-btn--primary","button");R.textContent=b("selectAll");let P=be("kanuni-pivot-popup-action-btn kanuni-pivot-popup-action-btn--danger","button");P.textContent=b("clearAll"),E.append(R,P),r.appendChild(E);let D=be("kanuni-pivot-popup-list pivot-custom-scrollbar");D.id="pivot-filter-options";let I=be("");I.style.position="relative",D.appendChild(I);let H=be("kanuni-pivot-popup-footer"),V=be("kanuni-pivot-btn kanuni-pivot-btn--outline","button");V.textContent=b("cancel");let q=be("kanuni-pivot-btn kanuni-pivot-btn--primary","button");q.textContent=b("ok");for(let L of [V,q])Object.assign(L.style,{height:"28px",padding:"0 12px",fontSize:"12px"});if(H.append(V,q),e.openCondition&&(d.area==="row"||d.area==="column")){let L=be("kanuni-pivot-btn kanuni-pivot-btn--outline","button");L.type="button",L.setAttribute("data-condition-filter",""),L.title=b("conditionFilter")+"\u2026",L.setAttribute("aria-label",L.title),Object.assign(L.style,{height:"28px",padding:"0 7px",marginInlineEnd:"auto"}),(d.valueFilter||d.labelFilter)&&(L.style.color="var(--pivot-danger)"),L.appendChild(X("settings-2",14)),L.addEventListener("click",()=>{t.closePopup(),e.openCondition(d.id);}),H.prepend(L);}C.append(r,D,H),y.appendChild(C);let ie=()=>{if(!g)return f;let L=g.toLowerCase(),$=L.replace(/,/g,"."),K=L.replace(/\./g,","),v=L.replace(/[.,\s]/g,"");return f.filter(z=>{let O=z.label.toLowerCase(),G=O.replace(/[.,\s]/g,"");return O.includes(L)||O.includes($)||O.includes(K)||!!v&&G.includes(v)})},pe=()=>h.size===m.length,re=()=>!g,fe=()=>ie().length+(re()?1:0),ye=()=>fe()===0?-1:Math.min(p,fe()-1),Ee=L=>{if(re()&&L===0)return "select-all";let $=re()?L-1:L;return `value:${ie()[$]?.key}`},J=new Map;function S(){if(s)return;let L=document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains("kanuni-pivot-popup-item");if(q.disabled=!F&&m.length>0&&h.size===0,I.textContent="",J.clear(),F){I.style.height="";let G=be("pivot-flex pivot-items-center pivot-justify-center pivot-h-full"),N=be("");Object.assign(N.style,{width:"24px",height:"24px",border:"2px solid var(--pivot-border)",borderTopColor:"var(--pivot-primary)",borderRadius:"50%",animation:"spin 1s linear infinite"}),G.appendChild(N),I.appendChild(G);return}let $=ie(),K=fe();I.style.height=`${K*Re}px`;let v=Math.max(0,Math.floor(D.scrollTop/Re)-2),z=Math.min(K,v+Math.ceil(w/Re)+4),O=ye();for(let G=v;G<z;G++){let N,j,_,oe,xe,Me=false;if(re()&&G===0)N="select-all",j=`(${b("selectAll")})`,_=pe(),oe=true,xe=B;else {let ce=$[re()?G-1:G];if(!ce)continue;let le=pivotgridCore.headerFilterGroupTick(ce,h);N=`value:${ce.key}`,j=ce.label,_=le==="all",Me=le==="some",oe=false,xe=()=>W(ce);}let ae=be(`kanuni-pivot-popup-item${_?" kanuni-pivot-popup-item--checked":""}${G===O?" kanuni-pivot-popup-item--active":""}`);ae.id=N,ae.setAttribute("role","checkbox"),ae.setAttribute("aria-checked",Me?"mixed":String(_)),ae.tabIndex=0,Object.assign(ae.style,{position:"absolute",top:`${G*Re}px`,insetInlineStart:"0",insetInlineEnd:"0",height:`${Re}px`,fontWeight:oe?"600":"400"});let Q=be("kanuni-pivot-checkbox","input");Q.type="checkbox",Q.checked=_,Q.indeterminate=Me,Q.readOnly=true,Q.tabIndex=-1;let ve=be("pivot-truncate","span");ve.textContent=j,ae.append(Q,ve),ae.addEventListener("click",xe),ae.addEventListener("focus",()=>{p=G;}),I.appendChild(ae),J.set(G,ae);}if($.length===0){let G=be("");Object.assign(G.style,{padding:"12px",textAlign:"center",fontSize:"12px",color:"var(--pivot-text-muted)"}),G.textContent=b("noItems"),I.appendChild(G);}u.setAttribute("aria-activedescendant",O>=0?Ee(O):""),L&&J.get(O)?.focus();}function A(L){h=pivotgridCore.setHeaderFilterGroups(h,ie(),L),S();}function B(){A(!ie().every(L=>pivotgridCore.headerFilterGroupTick(L,h)==="all"));}function W(L){h=pivotgridCore.toggleHeaderFilterGroup(h,L),S();}function U(){if(q.disabled)return;let L=pivotgridCore.headerFilterWrite(m,h,d);L.kind==="clear"?e.clear(d.id):L.kind==="apply"&&e.apply(d.id,L.values,L.filterType),t.closePopup();}function de(L){p=Math.max(0,Math.min(fe()-1,L));let $=p*Re;$<D.scrollTop?D.scrollTop=$:$+Re>D.scrollTop+w&&(D.scrollTop=$+Re-w),S(),J.get(p)?.focus();}let ge=L=>{if(L.key==="ArrowDown"||L.key==="ArrowUp"){if(L.preventDefault(),fe()===0)return;de(ye()+(L.key==="ArrowDown"?1:-1));return}if(L.key==="Home"&&fe()>0){L.preventDefault(),de(0);return}if(L.key==="End"&&fe()>0){L.preventDefault(),de(fe()-1);return}if(L.key==="Backspace"&&L.target!==u){L.preventDefault(),u.focus(),g=g.slice(0,-1),u.value=g,p=0,S();return}if(L.key===" "||L.code==="Space"){if(L.target===u)return;L.preventDefault();let $=ye();if(fe()>0&&$>=0)if(re()&&$===0)B();else {let K=ie()[re()?$-1:$];K&&W(K);}return}if(L.key==="Enter"){L.preventDefault(),U();return}if(L.key==="Escape"){L.stopPropagation(),t.closePopup();return}L.key.length===1&&!L.ctrlKey&&!L.metaKey&&!L.altKey&&L.target!==u&&(L.preventDefault(),u.focus(),g+=L.key,u.value=g,p=0,S());},Z=L=>{ge(L),L.defaultPrevented&&L.stopPropagation();};document.addEventListener("keydown",Z,true),C.addEventListener("click",L=>L.stopPropagation()),u.addEventListener("input",()=>{g=u.value,p=0,S();}),R.addEventListener("click",B),P.addEventListener("click",()=>A(false)),V.addEventListener("click",()=>t.closePopup()),q.addEventListener("click",U),D.addEventListener("scroll",()=>{$t.set(d.id,D.scrollTop),S();});let ue=typeof ResizeObserver<"u"?new ResizeObserver(L=>{for(let $ of L)w=$.contentRect.height;}):null;return ue?.observe(D),S(),u.focus(),k.push(setTimeout(()=>{if(s)return;if(!d.dataField&&!d.isCalculated){m=[],F=false,S();return}let L=pivotgridCore.getFieldDistinctValues(d.id,e.gridId);if(L)m=L.map(K=>({rawStr:K.rawStr==="null"||K.rawStr==="undefined"?b("blanks"):K.rawStr,rawVal:K.rawVal,label:Bt(K.rawVal,d,T,b("blanks"))}));else {let K=new Map,v=e.getData();for(let O=0;O<v.length;O++){let G=pivotgridCore.extractGroupValue(v[O],d);if(G==="(Blank)"&&d.calculateSummaryExpression)continue;let N=G==null?b("blanks"):String(G);K.has(N)||K.set(N,G);}let z=Array.from(K.values());if(d.dataType==="number")z.sort((O,G)=>Number(O)-Number(G));else {let O=pivotgridCore.collatorFor().compare;z.sort((G,N)=>O(String(G),String(N)));}m=z.map(O=>({rawStr:O==null?b("blanks"):String(O),rawVal:O,label:Bt(O,d,T,b("blanks"))}));}f=pivotgridCore.groupHeaderFilterOptions(m),h=pivotgridCore.headerFilterShown(m,d),F=false,S();let $=$t.get(d.id)||0;$>0&&k.push(setTimeout(()=>{s||(D.scrollTop=$,S());},50)),k.push(setTimeout(()=>{s||u.focus();},50));},10)),()=>{s=true,document.removeEventListener("keydown",Z,true);for(let L of k)clearTimeout(L);ue?.disconnect();}});}return {open:n,close:()=>t.closePopup()}}function Ce(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Wt(e){let t=Ce("kanuni-pivot-footer pivot-flex pivot-items-center pivot-justify-start");Object.assign(t.style,{padding:"4px 8px",backgroundColor:"color-mix(in srgb, var(--pivot-surface-header) 50%, var(--pivot-surface))",borderTop:"1px solid var(--pivot-border)",gap:"4px",flex:"0 0 auto"}),e.host.appendChild(t);let n=null,a=null,l=null,i=null;function d(){n=null,a?.remove(),a=null,l?.classList.remove("kanuni-pivot-footer-btn--active"),l=null;}let b=y=>{e.onGlobalContextMenu&&(y.preventDefault(),e.onGlobalContextMenu(y.clientX,y.clientY));};t.addEventListener("contextmenu",b);let M=y=>{!n||y.target?.closest?.("[data-footer-menu]")?.getAttribute("data-footer-menu")===n||d();};document.addEventListener("mousedown",M);let T=Ce("kanuni-pivot-search","input");T.type="search";let F,m=()=>{clearTimeout(F),e.onSearch?.(T.value);};T.addEventListener("input",()=>{clearTimeout(F),F=setTimeout(m,250);}),T.addEventListener("keydown",y=>{y.stopPropagation(),y.key==="Enter"?m():y.key==="Escape"&&(T.value="",m());});function f(y,C,o=false){let c=Ce(`kanuni-pivot-footer-btn${o?" kanuni-pivot-footer-btn--active":""}`,"button");return c.title=C,c.setAttribute("aria-label",C),c.type="button",c.appendChild(X(y,15)),c}let g=()=>Ce("kanuni-pivot-footer-divider");function h(y,C,o,c,r,x={}){let u=Ce("kanuni-pivot-dropdown-item pivot-flex","button");u.type="button",u.style.gap="12px",x.locked&&(u.style.opacity="0.6",u.style.cursor=x.canUpgrade?"pointer":"not-allowed",x.canUpgrade||(u.disabled=true),x.hint&&(u.title=x.hint)),u.appendChild(X(y,16,C));let E=Ce(""),R=Ce("pivot-font-medium pivot-flex pivot-items-center");if(R.style.gap="6px",R.appendChild(document.createTextNode(o)),x.locked&&x.badge){let P=Ce("","span");Object.assign(P.style,{fontSize:"9px",fontWeight:"700",textTransform:"uppercase",letterSpacing:"0.04em",padding:"1px 5px",borderRadius:"9999px",backgroundColor:"color-mix(in srgb, var(--pivot-warning) 18%, transparent)",color:"var(--pivot-warning)"}),P.textContent=x.badge,R.appendChild(P);}if(E.appendChild(R),c!==null){let P=Ce("pivot-text-xs pivot-text-muted");P.textContent=c,E.appendChild(P);}return u.appendChild(E),r&&u.addEventListener("click",r),u}function p(y,C=false){let o=Ce("kanuni-pivot-report-section-title");return C&&(o.style.marginTop="4px",o.style.borderTop="1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"),o.textContent=y,o}function w(){let y=Ce("kanuni-pivot-dropdown-menu pivot-animate-slide-up pivot-custom-scrollbar");return Object.assign(y.style,{bottom:"100%",left:"0",marginBottom:"4px",width:"256px",maxHeight:"384px",overflowY:"auto"}),y}function s(y){n=null,i&&k(i),e.onExport(y);}function k(y){i=y;let{t:C,locale:o}=e.getI18n(),c=e.toolbar??{},r=document.activeElement===T;if(t.textContent="",a=null,l=null,c.showSaveReport!==false&&e.mountReportMenu){let u=Ce("pivot-relative");e.mountReportMenu(u),u.childNodes.length>0&&(t.appendChild(u),t.appendChild(g()));}if(c.showFieldChooserToggle!==false){let u=f("settings",C("showFieldList"),e.fieldChooserOpen());u.addEventListener("click",e.onToggleFieldChooser),t.appendChild(u);}if(e.onOpenPrefilter){let u=f("filter",C("filterBuilder"));u.addEventListener("click",e.onOpenPrefilter),t.appendChild(u);}if(e.onToggleChart){let u=f("bar-chart",C("chartToggle"));u.addEventListener("click",e.onToggleChart),t.appendChild(u);}if(c.showCalculatedFields!==false&&e.onAddCalculatedField){let u=f("calculator",C("calculatedMeasureDesigner"));u.addEventListener("click",e.onAddCalculatedField),t.appendChild(u);}if(t.appendChild(g()),c.showExpandCollapseAll!==false){let u=f("maximize2",C("expandAll"));u.addEventListener("click",e.onExpandAll);let E=f("minimize2",C("collapseAll"));E.addEventListener("click",e.onCollapseAll),t.append(u,E);}if(c.showRefreshButton!==false&&e.onRefresh){t.appendChild(g());let u=f("refresh-cw",C("refreshData"));u.addEventListener("click",e.onRefresh),t.appendChild(u);}if(c.showFullscreenToggle!==false&&e.onToggleFullscreen){t.appendChild(g());let u=e.isFullscreen(),E=f(u?"shrink":"fullscreen",C(u?"exitFullscreen":"enterFullscreen"),u);u&&Object.assign(E.style,{backgroundColor:"color-mix(in srgb, var(--pivot-primary) 10%, transparent)",color:"var(--pivot-primary)",border:"1px solid color-mix(in srgb, var(--pivot-primary) 30%, transparent)"}),E.addEventListener("click",e.onToggleFullscreen),t.appendChild(E);}if(t.appendChild(g()),c.showExportButton!==false){let u=Ce("pivot-relative");u.setAttribute("data-footer-menu","export");let E=f("download",C("export"),n==="export");if(E.addEventListener("click",()=>{n=n==="export"?null:"export",k(y);}),u.appendChild(E),n==="export"){let R=w(),P=H=>{let V=!e.advancedExport;return {locked:V,canUpgrade:V&&!!e.upgradeUrl,badge:C("enterpriseBadge"),hint:V&&e.upgradeUrl?C("enterpriseUpgradeHint"):void 0}},D=(H,V)=>{if(!(!e.advancedExport))return ()=>s(H);if(e.upgradeUrl)return ()=>{n=null,k(y),window.open(e.upgradeUrl,"_blank","noopener,noreferrer");}},I=e.registry?.getPluginsByType("exporter")??[];if(I.length>0){R.appendChild(p(C("customExports")));for(let H of I)R.appendChild(h("database","var(--pivot-primary)",`${H.id.replace("exporter-","").toUpperCase()} ${C("export")}`,C("customPlugin"),()=>s(H.id)));R.appendChild(Ce("kanuni-pivot-dropdown-divider"));}R.appendChild(p(C("excelExport"))),R.appendChild(h("file-spreadsheet","var(--pivot-success)",C("pivotView"),C("preservesGridLayout"),D("excel-pivot"),P())),R.appendChild(h("file-spreadsheet","var(--pivot-success)",C("listView"),C("rawFlatData"),D("excel-list"),P())),R.appendChild(p(C("document"),true)),R.appendChild(h("file-text","var(--pivot-danger)",C("pdfDocument"),C("printReadyLayout"),D("pdf"),P())),R.appendChild(h("printer","var(--pivot-info)",C("print"),C("sendToPrinter"),()=>s("print"))),R.appendChild(h("copy","var(--pivot-primary)",C("copyToClipboard"),C("tabSeparatedValues"),()=>s("clipboard"))),R.appendChild(h("file-json","var(--pivot-success)",C("fullSnapshot"),C("saveSessionState"),()=>s("json-snapshot"))),R.appendChild(p(C("rawDataFormats"),true)),R.appendChild(h("file","var(--pivot-info)","CSV",null,()=>s("csv"))),R.appendChild(h("file-json","var(--pivot-warning)","JSON (Tree)",null,()=>s("json-pivot"))),R.appendChild(h("file-json","var(--pivot-warning)","JSON (List)",null,()=>s("json"))),R.appendChild(h("database","var(--pivot-text-muted)","XML",null,()=>s("xml"))),u.appendChild(R),a=R,l=E;}t.appendChild(u);}if(e.onSearch){let u=C("search").replace(/[.\u2026]+$/,"");T.placeholder=C("search"),T.setAttribute("aria-label",u),t.appendChild(g()),t.appendChild(T),r&&T.focus();}let x=y.selectionStats;if(x){let u=new Intl.NumberFormat(o,{minimumFractionDigits:2,maximumFractionDigits:2}),E=Ce("kanuni-pivot-selection-stats pivot-text-muted pivot-font-medium pivot-flex pivot-items-center");Object.assign(E.style,{marginLeft:"auto",fontSize:"11px",gap:"8px",paddingRight:"8px",userSelect:"none"});let R=[[C("count"),String(x.count)],[C("sum"),u.format(x.sum)],[C("avg"),u.format(x.avg)],[C("min"),u.format(x.min)],[C("max"),u.format(x.max)]];for(let[P,D]of R){let I=Ce("","span");I.textContent=`(${P}: ${D})`,E.appendChild(I);}t.appendChild(E);}}return {element:t,paint:k,syncSearch(y){document.activeElement!==T&&(T.value=y);},destroy(){clearTimeout(F),t.removeEventListener("contextmenu",b),document.removeEventListener("mousedown",M),t.remove();}}}var Gt=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];function jt(e,t){let n=false,a=()=>{let M=document;return M.fullscreenElement??M.webkitFullscreenElement??M.mozFullScreenElement??M.msFullscreenElement??null},l=()=>n||a()===e;function i(M){if(n=M,e.classList.toggle("pivot-is-fullscreen",M),M)Object.assign(e.style,{position:"fixed",inset:"0",zIndex:"9990",width:"auto",height:"auto"});else for(let T of ["position","inset","z-index","width","height"])e.style.removeProperty(T);}let d=()=>{let M=l();e.classList.toggle("pivot-is-fullscreen",a()===e||n),t(M);};for(let M of Gt)document.addEventListener(M,d);function b(){let M=document;if(l()){if(n){i(false),t(false);return}M.exitFullscreen?M.exitFullscreen():M.webkitExitFullscreen?M.webkitExitFullscreen():M.mozCancelFullScreen?M.mozCancelFullScreen():M.msExitFullscreen?M.msExitFullscreen():t(false);return}let T=e;T.requestFullscreen?T.requestFullscreen().then(()=>{e.classList.add("pivot-is-fullscreen");},()=>{i(true),t(true);}):T.webkitRequestFullscreen?T.webkitRequestFullscreen():T.mozRequestFullScreen?T.mozRequestFullScreen():T.msRequestFullscreen?T.msRequestFullscreen():(i(true),t(true));}return {isFullscreen:l,toggle:b,destroy(){for(let M of Gt)document.removeEventListener(M,d);n&&i(false);}}}var rt=["row","column","data","filter","chooser"];function qt(e){let t={activeId:null,targetId:null,targetArea:null,intent:null};function n(r,x,u){t.targetId===r&&t.targetArea===x&&t.intent===u||(t.targetId=r,t.targetArea=x,t.intent=u,e.controller.setDragIntent(r,x,u),e.onIntentChange({...t}));}let a=null,l=null,i=null,d=null;function b(r,x,u){i=De(e.gridRoot),i.style.pointerEvents="none",d=document.createElement("div"),d.className="kanuni-pivot-drag-overlay pivot-flex pivot-items-center pivot-gap-2 pivot-font-semibold pivot-truncate",Object.assign(d.style,{position:"fixed",left:"0",top:"0",padding:"8px 12px",backgroundColor:"var(--pivot-surface)",border:"2px solid var(--pivot-primary)",boxShadow:"var(--pivot-shadow-xl)",borderRadius:"var(--pivot-border-radius)",fontSize:"14px",opacity:"0.9",cursor:"grabbing",transformOrigin:"0 0",pointerEvents:"none",zIndex:"100000"});let E=document.createElement("span");E.className="pivot-truncate",Object.assign(E.style,{maxWidth:"150px",color:"var(--pivot-text)"});let R=e.getFields().find(P=>P.id===r);E.textContent=R?.caption||R?.id||"Field",d.appendChild(E),i.appendChild(d),document.body.appendChild(i),Oe(i),M(x,u);}function M(r,x){d&&(d.style.transform=`translate3d(${r+6}px, ${x+6}px, 0) scale(1.05)`);}function T(){i?.remove(),i=null,d=null,l&&(l.el.classList.remove("is-dragging"),l.el.style.removeProperty("pointer-events"),l.el.style.removeProperty("cursor"),document.body.style.removeProperty("user-select"));}function F(r){let x=l;if(T(),l=null,a?.holdTimer&&clearTimeout(a.holdTimer),a=null,document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",w),document.removeEventListener("pointercancel",k),document.removeEventListener("keydown",y,true),!x)return;let u=t.activeId??x.dropId.replace("chooser-","");t.activeId=null,t.targetId=null,t.targetArea=null,t.intent=null,e.onIntentChange({...t}),r===null?e.controller.resetDrag():e.controller.commitDrag(u,r);}function m(){if(!a)return;let{el:r,dropId:x,pointerId:u,startX:E,startY:R}=a;l={el:r,dropId:x,pointerId:u,startX:E,startY:R},a=null;let P=x.replace("chooser-","");t.activeId=P,e.controller.setDragActive(P),r.classList.add("is-dragging"),r.style.pointerEvents="none",r.style.cursor="grabbing",b(P,E,R),window.getSelection?.()?.removeAllRanges?.(),document.body.style.userSelect="none",e.onIntentChange({...t});}function f(r,x){let u=null,E=null,R=null,P=typeof document.elementFromPoint=="function"?document.elementFromPoint(r,x):null;for(let D of e.roots())for(let I of D.querySelectorAll("[data-drop-id]")){if(l&&I===l.el||P&&!I.contains(P)||I.classList.contains("kanuni-pivot-field-chip")&&I.closest('[data-drop-id="chooser-chooser"]'))continue;let H=I.getBoundingClientRect();if(H.width===0&&H.height===0||r<H.left||r>H.right||x<H.top||x>H.bottom)continue;let V=I.getAttribute("data-drop-id"),q=V.replace("chooser-","");if(q.endsWith("-ghost-end"))E={id:V,el:I};else if(rt.includes(q))R=R??{id:V,el:I};else {let ie=H.width*H.height;(!u||ie<u.size)&&(u={id:V,el:I,size:ie});}}return u??E??R}function g(r,x){let u=f(r,x);if(!u)return n(null,null,null),{overId:null};let E=u.id.replace("chooser-",""),R=e.getFields().find(I=>I.id===E),P=rt.includes(E)||E.endsWith("-ghost-end")?E.replace("-ghost-end",""):R?.area,D=!!(t.activeId&&P&&e.controller.canMoveFieldTo&&!e.controller.canMoveFieldTo(t.activeId,P));if(d?.classList.toggle("is-drop-denied",D),d&&(d.style.borderColor=D?"var(--pivot-danger)":"var(--pivot-primary)"),D)return n(null,null,null),{overId:null};if(rt.includes(E)||E.endsWith("-ghost-end"))return n(null,P,"append"),{overId:u.id};if(R){let I=R.area==="chooser"?"vertical":"horizontal",H=u.el.getBoundingClientRect(),V=e.controller.calculateDropIntent(r,x,{top:H.top,left:H.left,width:H.width,height:H.height},t.intent,false,I);return n(E,R.area??null,V),{overId:u.id}}return {overId:u.id}}let h=null,p=r=>{if(!(a&&r.pointerId!==a.pointerId)&&!(l&&r.pointerId!==l.pointerId)){if(a){let x=r.clientX-a.startX,u=r.clientY-a.startY,E=Math.hypot(x,u);if(a.isTouch){if(!a.held&&E>8){a.holdTimer&&clearTimeout(a.holdTimer),a=null;return}if(!a.held)return}else if(E<8)return;m();}l&&(r.preventDefault(),M(r.clientX,r.clientY),h=g(r.clientX,r.clientY).overId);}},w=r=>{if(!(a&&r.pointerId!==a.pointerId)&&!(l&&r.pointerId!==l.pointerId)){if(a){a.holdTimer&&clearTimeout(a.holdTimer),a=null,document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",w),document.removeEventListener("pointercancel",k),document.removeEventListener("keydown",y,true);return}l&&F(g(r.clientX,r.clientY).overId??h);}},s=r=>{(l||a?.held)&&r.cancelable&&r.preventDefault();},k=()=>F(null),y=r=>{r.key==="Escape"&&l&&(r.stopPropagation(),F(null));},C=r=>{if(e.disabled?.()||a||l||r.button!==0&&r.pointerType==="mouse")return;let x=r.target;if(x.closest("button, input, .kanuni-pivot-chip-btn"))return;let u=x.closest(".kanuni-pivot-field-chip[data-drop-id]");if(!u||u.getAttribute("data-drag-scope")==="grip"&&!x.closest("[data-drag-grip]"))return;let E=u.getAttribute("data-drop-id"),R=r.pointerType==="touch";a={el:u,dropId:E,pointerId:r.pointerId,startX:r.clientX,startY:r.clientY,isTouch:R,held:false,holdTimer:R?setTimeout(()=>{a&&(a.held=true,m());},Math.max(0,e.touchDragDelay?.()??200)):null},document.addEventListener("pointermove",p),document.addEventListener("pointerup",w),document.addEventListener("pointercancel",k),document.addEventListener("keydown",y,true);},o=new Set;function c(){for(let r of o)r.isConnected||(r.removeEventListener("pointerdown",C),o.delete(r));for(let r of e.roots())o.has(r)||(o.add(r),r.addEventListener("pointerdown",C));}return c(),document.addEventListener("touchmove",s,{passive:false}),{getState:()=>({...t}),refreshRoots:c,rootCount:()=>o.size,destroy(){l&&F(null),a?.holdTimer&&clearTimeout(a.holdTimer),a=null;for(let r of o)r.removeEventListener("pointerdown",C);o.clear(),document.removeEventListener("touchmove",s),document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",w),document.removeEventListener("pointercancel",k),document.removeEventListener("keydown",y,true);}}}function me(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Kt(e){let{portal:t}=e;function n(m,f,g,h=false){let p=me(`${h?"kanuni-pivot-dropdown-item-danger":"kanuni-pivot-dropdown-item"} pivot-flex pivot-items-center`,"button");return p.type="button",m&&p.appendChild(X(m,16)),p.appendChild(document.createTextNode(" "+f)),p.addEventListener("click",()=>{t.closePopup(),g();}),p}function a(m,f,g){let h=()=>window.visualViewport?.removeEventListener("resize",p),p=()=>{if(!m.isConnected){h();return}let w=m.offsetWidth,s=m.scrollHeight||m.offsetHeight;if(w===0&&s===0)return;let k=pivotgridCore.placePopup({x:f,y:g},{width:w,height:s});m.style.top=`${k.top}px`,m.style.left=`${k.left}px`,m.style.maxHeight=`${k.maxHeight}px`;};return p(),window.visualViewport?.addEventListener("resize",p),h}let l=null;function i(m,f,g){let h=null,p=null,w=()=>{h?.remove(),h=null,l===w&&(l=null);},s=()=>{if(h)return;l&&l(),l=w,h=me("kanuni-pivot-dropdown-menu pivot-animate-zoom-in");let o=m.getBoundingClientRect(),c=pivotgridCore.placePopup({x:o.right+4,y:o.top},{width:160,height:0},{altX:o.left-4});if(Object.assign(h.style,{position:"fixed",top:`${c.top}px`,left:`${c.left}px`,minWidth:"160px",zIndex:"10000"}),h.addEventListener("contextmenu",r=>r.preventDefault()),h.addEventListener("mouseenter",()=>{p&&clearTimeout(p);}),h.addEventListener("mouseleave",()=>{p=setTimeout(w,200);}),g(h),f.appendChild(h),h.offsetHeight){let r=pivotgridCore.placePopup({x:o.right+4,y:o.top},{width:h.offsetWidth,height:h.scrollHeight},{altX:o.left-4});Object.assign(h.style,{top:`${r.top}px`,left:`${r.left}px`,maxHeight:`${r.maxHeight}px`,overflowY:"auto"});}},k=0,y=false,C=()=>Date.now()-k<1e3;m.addEventListener("pointerdown",o=>{o.pointerType!=="mouse"&&(k=Date.now());}),m.addEventListener("mouseenter",()=>{p&&clearTimeout(p),!C()&&(h||(y=true),s());}),m.addEventListener("mouseleave",()=>{C()||(p=setTimeout(w,200));}),m.addEventListener("click",o=>{if(o.detail>0&&y&&h){y=false;return}y=false,h?w():s();});}function d(m,f,g){let h=me("kanuni-pivot-dropdown-item pivot-flex pivot-items-center pivot-justify-between","button");h.type="button";let p=me("pivot-flex pivot-items-center pivot-gap-2","span");return p.appendChild(X(m,16)),p.appendChild(document.createTextNode(" "+f)),h.appendChild(p),h.appendChild(X(g?"chevron-left":"chevron-right",14)),h}function b(m){m.addEventListener("keydown",f=>{let g=[...m.querySelectorAll("button:not([disabled])")];if(g.length===0)return;let h=g.indexOf(document.activeElement),p=-1;f.key==="ArrowDown"?p=h<0?0:(h+1)%g.length:f.key==="ArrowUp"?p=h<0?g.length-1:(h-1+g.length)%g.length:f.key==="Home"?p=0:f.key==="End"&&(p=g.length-1),!(p<0)&&(f.preventDefault(),g[p].focus());});}function M(m,f,g,h,p){let w=e.getFields().find(o=>o.id===g);if(!w)return;let{t:s,rtl:k}=e.getI18n(),y=e.getFields().filter(o=>o.area==="row").sort((o,c)=>(o.areaIndex||0)-(c.areaIndex||0)),C=h!==void 0&&y.length>0&&w.area==="data";t.openPopup(o=>{let c=me("kanuni-pivot-dropdown-menu pivot-animate-zoom-in pivot-flex-col");Object.assign(c.style,{position:"fixed",top:`${f}px`,left:`${m}px`,maxHeight:`${Math.max(0,pivotgridCore.popupViewport().height-16)}px`,overflowY:"auto",overflowX:"hidden",width:"220px",zIndex:"9999"}),c.addEventListener("contextmenu",u=>u.preventDefault());let r=me("kanuni-pivot-report-section-title");if(Object.assign(r.style,{position:"sticky",top:"0",zIndex:"10"}),r.textContent=w.caption??w.id,c.appendChild(r),C){let u=me("kanuni-pivot-report-section-title");u.style.marginTop="4px",u.textContent=s("sortByThisColumn"),c.appendChild(u);for(let E of y)c.appendChild(n("arrow-down-a-z",s("sortFieldByThisColumn").replace("{0}",E.caption||E.id),()=>e.controller.sortFieldBySummary(E.id,w.id,h)));c.appendChild(me("kanuni-pivot-divider")),c.appendChild(n("x",s("removeAllSorting"),()=>e.controller.clearAllSorting(),true));}else {c.appendChild(n("arrow-down-a-z",s("sortAsc"),()=>e.controller.sortField(w.id,"asc"))),c.appendChild(n("arrow-up-z-a",s("sortDesc"),()=>e.controller.sortField(w.id,"desc"))),w.sortOrder&&c.appendChild(n("x",s("clearSort"),()=>e.controller.sortField(w.id,void 0),true)),e.openFilter&&w.area!=="data"&&c.appendChild(n("filter",s("filterField"),()=>e.openFilter(w.id,m,f))),e.openCondition&&(w.area==="row"||w.area==="column")&&c.appendChild(n("filter",s("conditionFilter")+"\u2026",()=>e.openCondition(w.id))),c.appendChild(me("kanuni-pivot-divider"));let u=d("list",s("order"),k);c.appendChild(u),i(u,o,P=>{let D=[["start",s("moveToStart"),"chevrons-left"],["left",s("moveToLeft"),"chevron-left"],["right",s("moveToRight"),"chevron-right"],["end",s("moveToEnd"),"chevrons-right"]];for(let[I,H,V]of D)P.appendChild(n(V,H,()=>e.controller.moveField(w.id,I)));});let E=[["row",s("rowArea"),"rows-3"],["column",s("columnArea"),"columns-3"],["data",s("dataArea"),"bar-chart-3"],["filter",s("filterArea"),"filter"]].filter(([P])=>P!==w.area);if(E.length>0){let P=d("move",s("moveToArea"),k);c.appendChild(P),i(P,o,D=>{for(let[I,H,V]of E){let q=n(V,H,()=>e.controller.changeFieldArea(w.id,I));e.controller.canMoveFieldTo(w.id,I)||(q.disabled=true),D.appendChild(q);}});}e.openFieldChooser&&c.appendChild(n("list",s("showFieldList"),e.openFieldChooser)),c.appendChild(n("eye-off",s("hide"),()=>e.controller.removeField(w.id)));let R=e.customContextMenuItems?.(w);if(R&&R.length>0){c.appendChild(me("kanuni-pivot-divider"));for(let P of R){let D=n(null,P.label,P.action);P.icon&&D.insertBefore(P.icon(),D.firstChild),c.appendChild(D);}}c.appendChild(me("kanuni-pivot-divider")),w.isCalculated&&e.onEditCalculatedField&&c.appendChild(n("calculator",s("editCalculation"),()=>e.onEditCalculatedField(w))),c.appendChild(n("settings",s("fieldSettings"),()=>e.openSettings(w.id)));}o.appendChild(c);let x=a(c,m,f);return p?(b(o),c.querySelector("button")?.focus(),()=>{x(),e.gridRoot?.querySelector(`.kanuni-pivot-field-chip[data-drop-id="${g}"]`)?.focus({preventScroll:true});}):x});}function T(m,f){let{t:g}=e.getI18n();t.openPopup(h=>{let p=me("kanuni-pivot-dropdown-menu pivot-animate-zoom-in");Object.assign(p.style,{position:"fixed",zIndex:"301",width:"224px",fontSize:"14px",left:`${m}px`,top:`${f}px`}),p.addEventListener("contextmenu",y=>y.preventDefault());let w=me("kanuni-pivot-report-section-title");w.textContent=g("viewOptions"),p.appendChild(w);let s=e.getLayout(),k=(y,C,o)=>{let c=me("pivot-w-full pivot-flex pivot-items-center pivot-justify-between","button");c.type="button",Object.assign(c.style,{padding:"6px 12px",textAlign:"left"}),c.addEventListener("mouseenter",()=>{c.style.backgroundColor="var(--pivot-surface-hover)";}),c.addEventListener("mouseleave",()=>{c.style.backgroundColor="transparent";});let r=me("","span");r.textContent=y;let x=me("pivot-text-xs pivot-text-muted pivot-font-medium","span");return x.textContent=g(C?"show":"hide"),c.append(r,x),c.addEventListener("click",()=>{o(),t.closePopup();}),c};return p.appendChild(k(g("filterArea"),s.showFilterArea===false,()=>e.controller.setLayout({showFilterArea:s.showFilterArea===false}))),p.appendChild(k(g("footerArea"),s.showFooter===false,()=>e.controller.setLayout({showFooter:s.showFooter===false}))),h.appendChild(p),a(p,m,f)});}function F(m){let{t:f}=e.getI18n(),g=()=>{let h=e.getEngineTrees();if(!h)return [];let p=[],w=(s,k)=>{if(s)for(let y of s)k>=m.depth&&p.push(y.key),y.children&&w(y.children,k+1);};return w(m.type==="row"?h.rowTree:h.colTree,0),p};t.openPopup(h=>{let p=me("");Object.assign(p.style,{position:"fixed",inset:"0",zIndex:"9998"}),p.addEventListener("click",()=>t.closePopup()),p.addEventListener("contextmenu",k=>{k.preventDefault(),t.closePopup();});let w=me("kanuni-pivot-dropdown-menu pivot-animate-zoom-in");Object.assign(w.style,{position:"fixed",left:`${m.x}px`,top:`${m.y}px`,zIndex:"9999",minWidth:"160px"}),w.addEventListener("contextmenu",k=>k.preventDefault());let s=(k,y)=>{let C=me("kanuni-pivot-dropdown-item pivot-state-hover","button");return C.type="button",Object.assign(C.style,{paddingLeft:"32px",paddingRight:"24px"}),C.textContent=k,C.addEventListener("click",o=>{o.stopPropagation(),t.closePopup(),y();}),C};return w.appendChild(s(m.isExpanded?f("collapse"):f("expand"),()=>{m.type==="row"?e.controller.toggleExpanded(m.path):e.controller.toggleColExpanded(m.path);})),w.appendChild(me("kanuni-pivot-dropdown-divider")),w.appendChild(s(f("expandAll"),()=>{let k=g();m.type==="row"?e.controller.expandPaths(k):e.controller.expandColPaths(k);})),w.appendChild(s(f("collapseAll"),()=>{let k=g();m.type==="row"?e.controller.collapsePaths(k):e.controller.collapseColPaths(k);})),h.append(p,w),a(w,m.x,m.y)});}return {openFieldMenu:M,openGlobalMenu:T,openNodeMenu:F,close:()=>t.closePopup()}}function we(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}var Ae=(e,...t)=>{let n=we("kanuni-pivot-form-group"),a=we("kanuni-pivot-form-label","label");return a.textContent=e,n.append(a,...t),n},Fe=(e,t)=>{let n=we("kanuni-pivot-select","select");for(let[a,l]of e){let i=document.createElement("option");i.value=a,i.textContent=l,n.appendChild(i);}return n.value=t,n},_e=(e,t)=>{let n=we("kanuni-pivot-input","input");return n.type=e,n.value=t,n},_t=(...e)=>{let t=we("");Object.assign(t.style,{display:"flex",gap:"8px",marginTop:"6px"});for(let n of e)Object.assign(n.style,{flex:"1 1 0",minWidth:"0"});return t.append(...e),t},lo=[["equals","opEquals"],["notEquals","opNotEquals"],["contains","opContains"],["notContains","opNotContains"],["startsWith","opStartsWith"],["endsWith","opEndsWith"]],so=[[">","opGreater"],[">=","opGreaterOrEqual"],["<","opLess"],["<=","opLessOrEqual"],["=","opEquals"],["!=","opNotEquals"],["between","opBetween"],["notBetween","opNotBetween"]];function Xt(e){function t(l,i,d,b){let{t:M}=e.getI18n();e.portal.openPopup(T=>{let F=we("kanuni-pivot-modal-overlay pivot-animate-fade-in");F.addEventListener("click",()=>e.portal.closePopup());let m=we("kanuni-pivot-modal pivot-animate-zoom-in");m.style.width="400px",m.setAttribute("role","dialog"),m.setAttribute("aria-modal","true"),m.setAttribute("aria-label",l);let f=we("kanuni-pivot-modal-header"),g=we("kanuni-pivot-modal-title","h2");g.textContent=l;let h=we("kanuni-pivot-modal-close","button");h.type="button",h.setAttribute("aria-label",M("cancel")),h.appendChild(X("x",20)),h.addEventListener("click",()=>e.portal.closePopup()),f.append(g,h);let p=we("kanuni-pivot-modal-footer"),w=we("kanuni-pivot-btn kanuni-pivot-btn--outline","button");w.type="button",w.textContent=M("cancel"),w.addEventListener("click",()=>e.portal.closePopup());let s=we("kanuni-pivot-btn kanuni-pivot-btn--primary","button");s.type="button",s.appendChild(X("check",16)),s.appendChild(document.createTextNode(" "+M("ok"))),s.addEventListener("click",()=>{d()!==false&&e.portal.closePopup();}),p.append(w,s),m.append(f,i,p),T.append(F,m),b.focus();});}function n(l){let i=e.getFields().find(w=>w.id===l);if(!i)return;let{t:d}=e.getI18n(),b=we("kanuni-pivot-modal-body pivot-custom-scrollbar"),M=_e("text",i.caption??"");b.appendChild(Ae(d("caption"),M));let T=i.area==="data"||i.area==="chooser",F=i.area==="row"||i.area==="column"||i.area==="filter"||i.area==="chooser",m=null,f=null,g=null,h=(...w)=>w.map(s=>[s,d(s)]),p=(...w)=>{let s=i.summaryType;return h(...s&&!w.includes(s)?[s,...w]:w)};T&&i.dataType&&i.dataType!=="number"&&(m=Fe(p("count","distinct"),String(i.summaryType||"count")),b.appendChild(Ae(d("summaryType"),m))),T&&i.dataType==="number"&&(m=Fe(p("sum","count","avg","min","max","distinct"),String(i.summaryType||"sum")),b.appendChild(Ae(d("summaryType"),m)),f=Fe([["absolute",d("absoluteValue")],...h("percentOfTotal","percentOfColumnTotal","percentOfRowTotal","percentOfParentRowTotal","percentOfParentColumnTotal","runningTotal","difference","percentDifference")],String(i.summaryDisplayMode||"absolute")),b.appendChild(Ae(d("displayMode"),f))),F&&i.dataType==="date"&&(g=Fe([["",d("none")],...h("year","quarter","month","week","day")],String(i.groupInterval||"")),b.appendChild(Ae(d("groupInterval"),g))),t(d("fieldSettings"),b,()=>{e.save({...i,caption:M.value,summaryType:m?.value||i.summaryType,summaryDisplayMode:f?.value??i.summaryDisplayMode,groupInterval:g?g.value||void 0:i.groupInterval});},M);}function a(l){let i=e.getFields(),d=i.find(o=>o.id===l);if(!d)return;let{t:b}=e.getI18n(),M=we("kanuni-pivot-modal-body pivot-custom-scrollbar"),T=o=>[["",b("none")],...o.map(([c,r])=>[c,b(r)])],F=d.labelFilter,m=Fe(T(lo),F?.operator??"");m.setAttribute("data-condition-label-op",""),m.setAttribute("aria-label",b("caption"));let f=_e("text",F?.value??"");f.setAttribute("data-condition-label-value",""),f.placeholder=b("builderValuePlaceholder"),f.setAttribute("aria-label",b("builderValuePlaceholder")),M.appendChild(Ae(b("caption"),_t(m,f)));let g=i.filter(o=>o.area==="data").sort((o,c)=>(o.areaIndex||0)-(c.areaIndex||0)),h=d.valueFilter,p=Fe(g.map(o=>[o.id,o.caption||o.id]),g.some(o=>o.id===h?.dataField)?h.dataField:g[0]?.id??"");p.setAttribute("data-condition-value-field",""),p.setAttribute("aria-label",b("dataArea"));let w=Fe(T(so),h?.operator??"");w.setAttribute("data-condition-value-op",""),w.setAttribute("aria-label",b("dataArea"));let s=_e("number",h?String(h.value):"");s.setAttribute("data-condition-value","");let k=_e("number",h?.value2!==void 0?String(h.value2):"");k.setAttribute("data-condition-value2","");for(let o of [s,k])o.setAttribute("aria-label",b("builderValuePlaceholder"));g.length>0&&M.appendChild(Ae(b("dataArea"),p,_t(w,s,k)));let y=()=>{f.disabled=m.value==="",s.disabled=w.value==="",k.style.display=w.value==="between"||w.value==="notBetween"?"":"none";};m.addEventListener("change",y),w.addEventListener("change",y),y();let C=o=>(o.setAttribute("aria-invalid","true"),o.focus(),false);t(`${b("conditionFilter")}: ${d.caption||d.id}`,M,()=>{for(let r of [f,s,k])r.removeAttribute("aria-invalid");let o;if(m.value){if(f.value==="")return C(f);o={operator:m.value,value:f.value,...F?.caseSensitive?{caseSensitive:true}:{}};}let c=g.length>0?void 0:h;if(w.value&&g.length>0){let r=k.style.display!=="none",x=s.value===""?NaN:Number(s.value),u=k.value===""?NaN:Number(k.value);if(!Number.isFinite(x))return C(s);if(r&&!Number.isFinite(u))return C(k);c={dataField:p.value,operator:w.value,value:x,...r?{value2:u}:{}};}e.save({...d,labelFilter:o,valueFilter:c});},m);}return {open:n,openCondition:a}}function te(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function po(e){let t=e.isCalculated?"settings-2":e.dataType==="number"?"hash":e.dataType==="date"?"calendar":e.dataType==="boolean"?"filter":"type";return X(t,12,"var(--pivot-primary)")}function Ut(e){let t=null,n=null,a=null,l="",i={x:0,y:0},d={width:700,height:550},b=()=>window.innerWidth<=768,M=["fullscreenchange","webkitfullscreenchange"],T=()=>{if(!t)return;let o=$e();t.parentElement!==o&&o.appendChild(t);},F=()=>{n&&(m(),b()||(i={x:Math.min(i.x,Math.max(0,window.innerWidth-d.width)),y:Math.min(i.y,Math.max(0,window.innerHeight-d.height))},m()));};function m(){n&&(b()?Object.assign(n.style,{position:"fixed",inset:"0",width:"100%",height:"100%",left:"",top:"",borderRadius:"0",zIndex:"100",transform:"none",padding:"0"}):Object.assign(n.style,{position:"fixed",inset:"",left:`${i.x}px`,top:`${i.y}px`,width:`${d.width}px`,height:`${d.height}px`,maxWidth:"95vw",maxHeight:"95vh",transform:"none",padding:"0",zIndex:"100",boxShadow:"var(--pivot-shadow-lg)",borderRadius:""}));}function f(o,c){let{t:r}=e.getI18n(),x=te("kanuni-pivot-field-chip");x.setAttribute("data-drop-id",`chooser-${o.id}`),x.setAttribute("data-drag-scope","grip"),x.style.position="relative";let u=te("");if(u.setAttribute("data-drag-grip",""),Object.assign(u.style,{color:"var(--pivot-text-muted)",cursor:"grab",flexShrink:"0",opacity:"0.5"}),u.appendChild(X("grip-vertical",14)),x.appendChild(u),c){let H=te("kanuni-pivot-checkbox","input");H.type="checkbox",H.checked=o.area!=="chooser",H.style.flexShrink="0",H.addEventListener("change",()=>{H.checked?e.controller.showFields([o.id]):e.controller.removeField(o.id);}),x.appendChild(H);}x.appendChild(po(o));let E=te("pivot-truncate","span");Object.assign(E.style,{flex:"1",color:"var(--pivot-text)",textAlign:"left"}),E.textContent=o.caption??o.id;let R=o.area==="data"&&o.summaryType?pivotgridCore.summaryTypeLabel(String(o.summaryType),r):"";if(R){let H=te("","span");Object.assign(H.style,{fontSize:"10px",marginLeft:"4px",backgroundColor:"color-mix(in srgb, var(--pivot-primary) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--pivot-primary) 45%, transparent)",color:"var(--pivot-text)",padding:"0 4px",borderRadius:"4px",fontWeight:"700"}),H.textContent=R,E.appendChild(H);}x.appendChild(E);let P=!!o.filterValues&&o.filterValues.size>0,D=te(`kanuni-pivot-field-chip-actions${P?" is-filtered":""}`);if(o.area!=="data"){let H=te("kanuni-pivot-chip-btn","button");H.type="button",H.title=r("filterField"),P&&Object.assign(H.style,{color:"var(--pivot-danger)",backgroundColor:"color-mix(in srgb, var(--pivot-danger) 10%, transparent)"}),H.appendChild(X("filter",12)),H.addEventListener("click",V=>{V.stopPropagation(),e.onFilterClick(V.clientX,V.clientY,o.id);}),D.appendChild(H);}if(o.isCalculated){let H=te("kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger","button");H.type="button",H.title=r("deletePermanently"),H.appendChild(X("trash",12)),H.addEventListener("click",V=>{V.stopPropagation(),e.controller.deleteField(o.id);}),D.appendChild(H);}let I=te("kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger","button");return I.type="button",I.title=r("removeFromArea"),I.appendChild(X("x",12)),I.addEventListener("click",H=>{H.stopPropagation(),e.controller.removeField(o.id);}),D.appendChild(I),x.appendChild(D),x}function g(o,c,r,x,u){let E=te("");if(Object.assign(E.style,{height:"100%",display:"flex",flexDirection:"column",transition:"background-color 0.2s"}),r!==null){let D=te("");Object.assign(D.style,{fontSize:"12px",fontWeight:"600",textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--pivot-text-muted)",backgroundColor:"color-mix(in srgb, var(--pivot-surface-header) 30%, transparent)",padding:"8px 12px",borderBottom:"1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"}),D.textContent=r,E.appendChild(D);}let R=te("pivot-custom-scrollbar");if(R.setAttribute("data-drop-id",`chooser-${o}`),R.setAttribute("data-drop-kind","list"),Object.assign(R.style,{maxHeight:b()?"none":"100%",flex:"1",padding:"8px",minHeight:"80px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"6px",alignItems:c.length===0?"center":"stretch",justifyContent:c.length===0?"center":"flex-start"}),c.length===0){let D=te("");Object.assign(D.style,{fontSize:"12px",color:"color-mix(in srgb, var(--pivot-text-muted) 70%, transparent)",fontStyle:"italic",textAlign:"center",width:"100%"}),D.textContent=x,R.appendChild(D);}for(let D of c)R.appendChild(f(D,u));let P=te("");return P.setAttribute("data-drop-id",`chooser-${o}-ghost-end`),P.setAttribute("data-ghost-populated",c.length>0?"1":"0"),Object.assign(P.style,{width:"100%",minHeight:"24px",transition:"background-color 0.2s",borderRadius:"var(--pivot-border-radius-sm)"}),R.appendChild(P),E.appendChild(R),E}function h(){let o=new Map;return e.getFields().map(c=>{let r=c.caption||c.id||"";if(o.has(r)){let x=o.get(r)+1;return o.set(r,x),{...c,caption:`${r} (${x})`}}return o.set(r,1),c})}function p(){let{locale:o}=e.getI18n(),c=[...h()].sort((x,u)=>(x.caption||"").toLowerCase().localeCompare((u.caption||"").toLowerCase(),o||"en"));if(!l)return c;let r=l.toLowerCase();return c.filter(x=>(x.caption||"").toLowerCase().includes(r))}function w(){let o=p().filter(c=>c.area==="chooser").map(c=>c.id);o.length!==0&&e.controller.showFields(o);}function s(){if(!a)return;let{t:o,locale:c}=e.getI18n(),r=new Map;for(let J of a.querySelectorAll('[data-drop-kind="list"]')){let S=J.getAttribute("data-drop-id");S&&J.scrollTop>0&&r.set(S,J.scrollTop);}let x=h(),u=p(),E=J=>x.filter(S=>S.area===J).sort((S,A)=>(S.areaIndex||0)-(A.areaIndex||0));a.textContent="";let R=b(),P=te(R?"w-full flex flex-col border-b border-border bg-surface":"w-full md:w-[40%] flex flex-col border-b md:border-b-0 md:border-r border-border bg-surface");R&&(P.style.flexShrink="0");let D=te("p-3 border-b border-border/60 bg-surface/80"),I=te("relative"),H=X("search",16);H.setAttribute("class","text-muted-fg opacity-60"),Object.assign(H.style,{position:"absolute",top:"50%",transform:"translateY(-50%)",pointerEvents:"none"}),H.style.setProperty("inset-inline-start","10px");let V=te("w-full bg-surface-hover/50 border-border rounded-md text-[13px] kanuni-pivot-input","input");V.type="text",V.placeholder=o("search"),V.value=l,V.style.setProperty("padding-inline-start","34px"),V.addEventListener("input",()=>{l=V.value,s();let J=a?.querySelector('input[type="text"]');J?.focus(),J?.setSelectionRange(J.value.length,J.value.length);}),I.append(H,V),D.appendChild(I),P.appendChild(D);let q=te(R?"p-2":"flex-1 overflow-hidden p-2"),ie=te("");Object.assign(ie.style,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"});let pe=te("text-[11px] font-bold uppercase tracking-wider text-muted-fg/80 mb-2 px-1");pe.textContent=o("allFields");let re=te("kanuni-pivot-popup-action-btn kanuni-pivot-chooser-select-all","button");re.type="button",re.textContent=o("selectAll"),re.style.color="var(--pivot-primary)",re.disabled=u.every(J=>J.area!=="chooser"),re.addEventListener("click",w),ie.append(pe,re),q.appendChild(ie),q.appendChild(g("chooser",u,null,o("noItems"),true)),P.appendChild(q);let fe=te(R?"w-full p-3 bg-surface-sunken/30":"w-full md:w-[60%] flex-1 overflow-y-auto custom-scrollbar p-3 bg-surface-sunken/30");R&&(fe.style.flexShrink="0");let ye=te(R?"grid grid-cols-1 sm:grid-cols-2 gap-3":"grid grid-cols-1 sm:grid-cols-2 gap-3 h-full auto-rows-fr"),Ee=[["filter",o("filterArea")],["column",o("columnArea")],["row",o("rowArea")],["data",o("dataArea")]];for(let[J,S]of Ee){let A=te("border border-border/80 rounded-md shadow-sm bg-surface overflow-hidden flex flex-col transition-colors");R&&(A.style.minHeight="140px"),A.appendChild(g(J,E(J),S,o("dropHere"),false)),ye.appendChild(A);}fe.appendChild(ye),a.append(P,fe);for(let[J,S]of r){let A=a.querySelector(`[data-drop-id="${J}"][data-drop-kind="list"]`);A&&(A.scrollTop=S);}}function k(){if(t)return;let{t:o}=e.getI18n();t=De(e.gridRoot);let c=te("fixed inset-0 z-[100] kanuni-pivot-chooser-backdrop overflow-auto pointer-events-auto");c.addEventListener("click",y),n=te("flex flex-col bg-surface shadow-2xl border border-border overflow-hidden rounded-lg kanuni-pivot-field-chooser"),n.addEventListener("click",P=>P.stopPropagation()),b()||(d={width:Math.min(700,window.innerWidth-32),height:Math.min(550,window.innerHeight-32)},i={x:Math.max(0,(window.innerWidth-d.width)/2),y:Math.max(0,(window.innerHeight-d.height)/2)}),m();let r=te("pivot-field-chooser__header flex items-center justify-between p-3 border-b border-border bg-surface-header/90");b()||(r.style.cursor="move");let x=te("text-[15px] font-semibold m-0 flex items-center gap-2 select-none","h3");x.appendChild(X("grip-horizontal",18,"var(--pivot-text-muted)")),x.appendChild(document.createTextNode(o("allFields")));let u=te("btn-icon rounded-full p-1.5 kanuni-pivot-chip-btn","button");u.type="button",u.setAttribute("aria-label",o("cancel")),u.appendChild(X("x",18)),u.addEventListener("pointerdown",P=>P.stopPropagation()),u.addEventListener("click",y),r.append(x,u);let E=null;r.addEventListener("pointerdown",P=>{b()||P.target.closest(".kanuni-pivot-field-chip, button, input")||(E={px:P.clientX,py:P.clientY,x:i.x,y:i.y},r.setPointerCapture?.(P.pointerId));}),r.addEventListener("pointermove",P=>{E&&(i={x:Math.max(0,E.x+P.clientX-E.px),y:Math.max(0,E.y+P.clientY-E.py)},m());});let R=P=>{E=null,r.releasePointerCapture?.(P.pointerId);};if(r.addEventListener("pointerup",R),r.addEventListener("pointercancel",R),a=te(b()?"flex flex-1 flex-col bg-surface-sunken/30":"flex flex-1 overflow-hidden flex-col md:flex-row bg-surface-sunken/30"),b()&&(a.setAttribute("data-chooser-scroll",""),Object.assign(a.style,{minHeight:"0",overflowY:"auto",touchAction:"pan-y",overscrollBehavior:"contain"})),s(),n.append(r,a),!b()){let P=[["n","n-resize",{top:"0",left:"0",right:"0",height:"6px"}],["s","s-resize",{bottom:"0",left:"0",right:"0",height:"6px"}],["w","w-resize",{top:"0",bottom:"0",left:"0",width:"6px"}],["e","e-resize",{top:"0",bottom:"0",right:"0",width:"6px"}],["nw","nw-resize",{top:"0",left:"0",width:"12px",height:"12px"}],["ne","ne-resize",{top:"0",right:"0",width:"12px",height:"12px"}],["sw","sw-resize",{bottom:"0",left:"0",width:"12px",height:"12px"}],["se","se-resize",{bottom:"0",right:"0",width:"12px",height:"12px"}]];for(let[D,I,H]of P){let V=te("kanuni-pivot-chooser-resize");V.setAttribute("data-resize-dir",D),Object.assign(V.style,{position:"absolute",zIndex:D.length===2?"51":"50",cursor:I},H);let q=null;V.addEventListener("pointerdown",pe=>{pe.stopPropagation(),q={px:pe.clientX,py:pe.clientY,w:d.width,h:d.height,x:i.x,y:i.y},V.setPointerCapture?.(pe.pointerId);}),V.addEventListener("pointermove",pe=>{if(!q)return;let re=pe.clientX-q.px,fe=pe.clientY-q.py,ye=q.w,Ee=q.h,J=q.x,S=q.y;D.includes("e")&&(ye=q.w+re),D.includes("s")&&(Ee=q.h+fe),D.includes("w")&&(ye=q.w-re,ye>=400&&(J=q.x+re)),D.includes("n")&&(Ee=q.h-fe,Ee>=400&&(S=q.y+fe)),d={width:Math.max(400,ye),height:Math.max(400,Ee)},i={x:Math.max(0,J),y:Math.max(0,S)},m();});let ie=pe=>{q=null,V.releasePointerCapture?.(pe.pointerId);};V.addEventListener("pointerup",ie),V.addEventListener("pointercancel",ie),n.appendChild(V);}}c.appendChild(n),t.appendChild(c),$e().appendChild(t),Oe(t),window.addEventListener("resize",F);for(let P of M)document.addEventListener(P,T);e.onOpenChanged?.(true);}function y(){if(t){window.removeEventListener("resize",F);for(let o of M)document.removeEventListener(o,T);t.remove(),t=null,n=null,a=null,l="",e.onOpenChanged?.(false);}}function C(){if(!t)return;let o={...i},c={...d};y(),k(),i=o,d=c,m();}return {open:k,close:y,toggle:()=>t?y():k(),isOpen:()=>t!==null,repaint:s,relocalize:C,getHost:()=>t,destroy:y}}function ne(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Yt(e){let t=false,n=null,a=d=>{t&&n&&!n.contains(d.target)&&(t=false,e.requestRepaint());};document.addEventListener("mousedown",a);function l(d,b){let{t:M}=e.getI18n();e.portal.openPopup(T=>{let F=ne("kanuni-pivot-modal-overlay");F.addEventListener("click",()=>e.portal.closePopup());let m=ne("kanuni-pivot-modal pivot-animate-zoom-in");Object.assign(m.style,{display:"flex",flexDirection:"column",gap:"16px",padding:"24px"});let f=ne("pivot-flex pivot-flex-col");f.style.gap="6px";let g=ne("pivot-flex pivot-items-center pivot-justify-between"),h=ne("kanuni-pivot-modal-title","h3");h.textContent=d;let p=ne("kanuni-pivot-modal-close","button");p.type="button",p.setAttribute("aria-label",M("close")),p.style.padding="6px",p.appendChild(X("x",16)),p.addEventListener("click",()=>e.portal.closePopup()),g.append(h,p);let w=ne("kanuni-pivot-modal-description","p");w.textContent=M("saveReportDescription"),f.append(g,w);let s=ne("pivot-flex pivot-flex-col pivot-gap-4","form"),k=ne("pivot-flex pivot-flex-col pivot-gap-2"),y=ne("kanuni-pivot-form-label","label");y.textContent=M("reportName");let C=ne("kanuni-pivot-input","input");C.type="text",C.placeholder=M("reportNamePlaceholder"),C.required=true,C.value=b,k.append(y,C);let o=ne("pivot-flex pivot-items-center pivot-gap-2"),c=ne("kanuni-pivot-input","input");c.type="checkbox",Object.assign(c.style,{width:"16px",height:"16px"});let r=ne("kanuni-pivot-form-label","label");Object.assign(r.style,{margin:"0",cursor:"pointer"}),r.textContent=M("setAsDefault"),r.addEventListener("click",()=>{c.checked=!c.checked;}),o.append(c,r);let x=ne("kanuni-pivot-modal-footer");Object.assign(x.style,{marginTop:"8px",paddingTop:"16px",borderTop:"1px solid var(--pivot-border)",display:"flex",justifyContent:"flex-end",gap:"8px"});let u=ne("kanuni-pivot-btn kanuni-pivot-btn--outline","button");u.type="button",u.textContent=M("cancel"),u.addEventListener("click",()=>e.portal.closePopup());let E=ne("kanuni-pivot-btn kanuni-pivot-btn--primary","button");E.type="submit",E.disabled=!b.trim(),E.appendChild(X("save",16)),E.appendChild(document.createTextNode(" "+M("save"))),C.addEventListener("input",()=>{E.disabled=!C.value.trim();}),x.append(u,E),s.addEventListener("submit",R=>{R.preventDefault();let P=C.value.trim();P&&(e.controller.saveReport(P,c.checked),e.portal.closePopup());}),s.append(k,o,x),m.append(f,s),T.append(F,m),C.focus();});}function i(d){let{t:b}=e.getI18n();n=d;let M=e.getReports(),T=e.getActiveReportId(),F=M.find(w=>w.id===T),m=ne(`kanuni-pivot-report-btn ${t?"kanuni-pivot-report-btn--open":T?"kanuni-pivot-report-btn--active":"kanuni-pivot-report-btn--default"}`,"button");m.type="button",m.title=b("viewsAndReports"),m.appendChild(X("bookmark",15));let f=ne("pivot-truncate","span");if(f.style.maxWidth="120px",f.textContent=F?F.name:b("views"),m.appendChild(f),m.addEventListener("click",()=>{t=!t,e.requestRepaint();}),d.appendChild(m),!t)return;let g=ne("kanuni-pivot-report-dropdown pivot-animate-slide-up"),h=(w,s=false)=>{let k=ne("kanuni-pivot-report-section-title");return s&&(k.style.marginTop="8px",k.style.borderTop="1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"),k.textContent=w,k},p=(w,s,k,y)=>{let C=ne("kanuni-pivot-report-item","button");C.type="button",C.appendChild(X(w,16,s));let o=ne(""),c=ne("pivot-font-medium");return c.textContent=k,o.appendChild(c),C.appendChild(o),C.addEventListener("click",()=>{t=false,e.requestRepaint(),y();}),C};if(g.appendChild(h(b("actions"))),g.appendChild(p("save","var(--pivot-success)",b("saveNewView"),()=>l(b("saveNewView"),""))),T&&(g.appendChild(p("save-all","var(--pivot-warning)",b("saveChangesOverwrite"),()=>e.controller.updateCurrentReport())),g.appendChild(p("copy","var(--pivot-info)",b("saveAsCopy"),()=>l(b("saveAsView"),`${F?.name??""} (Copy)`)))),M.length>0){g.appendChild(h(b("savedViews"),true));let w=ne("kanuni-pivot-report-list pivot-custom-scrollbar");for(let s of M){let k=ne(`kanuni-pivot-report-list-item${s.id===T?" kanuni-pivot-report-list-item--active":""}`),y=ne("kanuni-pivot-report-list-btn","button");y.type="button",y.appendChild(X(s.id===T?"check":"folder-open",14,s.id===T?"var(--pivot-primary)":"var(--pivot-text-muted)"));let C=ne("pivot-text-sm pivot-truncate","span");C.style.color=s.id===T?"var(--pivot-primary)":"var(--pivot-text)",s.id===T&&C.classList.add("pivot-font-medium"),C.textContent=s.name,y.appendChild(C),s.isDefault&&y.appendChild(Ve("star",12,"var(--pivot-warning)")),y.addEventListener("click",()=>{t=false,e.requestRepaint(),e.controller.loadReport(s.id);}),k.appendChild(y);let o=ne("kanuni-pivot-report-actions");if(!s.isDefault){let r=ne("kanuni-pivot-action-btn kanuni-pivot-action-btn--warning","button");r.type="button",r.title=b("makeDefault"),r.setAttribute("aria-label",r.title),r.appendChild(X("star",14)),r.addEventListener("click",x=>{x.stopPropagation(),e.controller.setDefaultReport(s.id);}),o.appendChild(r);}let c=ne("kanuni-pivot-action-btn kanuni-pivot-action-btn--danger","button");c.type="button",c.title=b("deleteReport"),c.setAttribute("aria-label",c.title),c.appendChild(X("trash",14)),c.addEventListener("click",r=>{r.stopPropagation(),window.confirm(b("deleteReportConfirm").replace("{0}",s.name))&&(e.controller.deleteReport(s.id),s.id===T&&(t=false,e.requestRepaint()));}),o.appendChild(c),k.appendChild(o),w.appendChild(k);}g.appendChild(w);}d.appendChild(g);}return {mount:i,destroy(){document.removeEventListener("mousedown",a);}}}var fo={chartData:[],chartSeries:[]};function at(e,t,n,a){let l=null,i,d,b,M=false;function T(){if(M)return;let f=e.getState();if(!f.engineResult||!f.engineResult.cellMatrix||!n.transformer){a(fo);return}a(n.transformer(f.engineResult,pivotgridCore.shownFields(f.fields),f.expandedPaths,t(),n));}function F(){let f=e.getState(),g=t();f.engineResult===i&&f.expandedPaths===d&&g===b||(i=f.engineResult,d=f.expandedPaths,b=g,l&&clearTimeout(l),l=setTimeout(T,150));}let m=e.subscribe(F);return F(),{refresh:F,stop(){M=true,l&&clearTimeout(l),m();}}}function He(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}var lt=new Set;function ko(){let e="default-pivot-grid";for(let t=2;lt.has(e);t++)e=`default-pivot-grid-${t}`;return lt.add(e),e}function To(e,t){if(!e||!(e instanceof HTMLElement))throw new Error("[pivotgrid] createPivotGrid needs a container HTMLElement");ct(t);let n=Be(t.locale,t.dictionary,t.rtl),a=t.gridId||t.stateStoring?.storageKey,l=a||ko();!a&&l!=="default-pivot-grid"&&console.warn(`[pivotgrid] multiple grids without gridId on this page \u2014 this one got '${l}'. Give each grid an explicit gridId for stable state persistence.`);let i=He("kanuni-pivot-root"+(t.className?" "+t.className:""));i.style.width="100%",i.style.height="100%",pt(i,pivotgridCore.pivotSchemeTheme(t.theme,t.palette,t.dark)),i.setAttribute("dir",n.rtl?"rtl":"ltr");let d=He("kanuni-pivot-wrapper pivot-flex pivot-flex-col");d.style.width="100%",d.style.height="100%";let b=He("pivot-grid pivot-flex-1 pivot-flex pivot-flex-col pivot-relative");b.style.minHeight="0",b.style.overflow="hidden",b.style.backgroundColor="var(--pivot-bg)",b.style.border="1px solid var(--pivot-border)",b.style.borderRadius="var(--pivot-radius-md)",b.style.userSelect="none",t.striped&&i.classList.add("kanuni-pivot-striped");let M=t.density,T=()=>pivotgridCore.pivotDensityClass(M),F=()=>pivotgridCore.pivotRowHeight(M);T()&&i.classList.add(T());let m=He("pivot-flex-1 pivot-flex pivot-flex-col pivot-relative");m.style.minHeight="0";let f=He("pivot-text-muted pivot-text-sm");f.style.padding="8px",f.style.position="absolute",f.style.inset="0",f.style.display="none",f.style.zIndex="70",f.style.backgroundColor="var(--pivot-bg)",f.setAttribute("data-pivot-status",""),b.appendChild(m),b.appendChild(f),d.appendChild(b),i.appendChild(d);let g=He("kanuni-pivot-live");g.setAttribute("role","status"),g.setAttribute("aria-live","polite"),g.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap",i.appendChild(g),e.appendChild(i);let h={gridId:l,data:t.data??[],rowKey:t.rowKey,asyncTransactionWait:t.asyncTransactionWait,loading:t.loading,maxColumns:t.maxColumns,initialFields:t.initialFields??t.fields??[],controlledFields:t.fields,controlledLayout:t.layout,stateStoring:t.stateStoring,workerUrl:t.workerUrl,registry:t.registry,serverSource:t.serverSource,locale:n.locale,dictionary:n.dictionary,enterpriseEdition:t.advancedExport===true,onRefresh:t.onRefresh,onFieldsChange:t.onFieldsChange,onLayoutChange:t.onLayoutChange,onFieldMove:t.onFieldMove,onBeforePivotCalculate:t.onBeforePivotCalculate,onAfterPivotCalculate:t.onAfterPivotCalculate,onExporting:t.onExporting,onLargeExport:t.onLargeExport,onComputingChange:t.onComputingChange,onError:t.onError,onChartStateLoaded:t.onChartStateLoaded},p=new pivotgridCore.PivotController(h),w=pivotgridCore.bindPivotScrollMemory(i,p),s=pivotgridCore.watchShortPivot(d),k=()=>pivotgridCore.shownFields(p.getState().fields),y=ot(i),C=Nt({portal:y,getI18n:()=>n,gridId:l,getField:v=>k().find(z=>z.id===v),getData:()=>p.getRawData(),apply:(v,z,O)=>p.applyFilter(v,z,O),clear:v=>p.clearFilter(v),openCondition:v=>o.openCondition(v)}),o=Xt({portal:y,getI18n:()=>n,getFields:k,save:v=>p.updateField(v)}),c=Kt({portal:y,gridRoot:i,getI18n:()=>n,getFields:k,getLayout:()=>p.getState().layout,controller:p,getEngineTrees:()=>{let v=p.getState().engineResult;return v?{rowTree:v.rowTree,colTree:v.colTree}:null},openSettings:v=>o.open(v),openCondition:v=>o.openCondition(v),openFilter:(v,z,O)=>{E()||C.open(z,O,v);},openFieldChooser:()=>r.open(),onEditCalculatedField:t.onEditCalculatedField?v=>{E()||t.onEditCalculatedField(v);}:void 0,customContextMenuItems:t.customContextMenuItems}),r=Ut({gridRoot:i,getI18n:()=>n,getFields:k,controller:p,onFilterClick:(v,z,O)=>C.open(v,z,O),onOpenChanged:()=>{S||(ie.refreshRoots(),J.paint(p.getState()));}}),x=(v,z)=>{t.onGlobalContextMenu?t.onGlobalContextMenu(v,z):c.openGlobalMenu(v,z);},u=Rt(),E=()=>t.disabled===true,R,P,D={getI18n:()=>n,onRemove:v=>{E()||p.removeField(v);},onFilterClick:(v,z,O)=>{E()||C.open(v,z,O);},onSort:(v,z)=>{E()||p.sortField(v,z);},onContextMenu:(v,z,O,G,N)=>{E()||c.openFieldMenu(v,z,O,G,N);},getFields:k,onMove:(v,z)=>{E()||p.moveField(v,z);},requestFocus:v=>{R=v;let O=document.activeElement?.closest?.("[data-drop-id]")?.getAttribute("data-drop-id");P=O?k().find(G=>G.id===O)?.area:void 0;}},I=Pt({host:m,getI18n:()=>n,onCellPrepared:t.onCellPrepared,registry:t.registry,shared:u,chipDeps:D,hasCellClick:()=>!!t.onCellClick&&!E(),columnWidthDefaults:pivotgridCore.resolveColumnWidthDefaults(t.defaultColumnWidths),rowHeight:F}),H=wt({...D,host:b,onGlobalContextMenu:x,onToggleCollapsed:()=>{E()||p.setLayout({filterAreaCollapsed:p.getState().layout.filterAreaCollapsed!==true});}});b.insertBefore(H.element,m);let V=He("kanuni-pivot-notice");V.setAttribute("role","status"),V.style.display="none",b.insertBefore(V,m);let q=()=>{let v=r.getHost();return v?[i,v]:[i]},ie=qt({gridRoot:i,roots:q,controller:p,getFields:k,onIntentChange:v=>kt(q(),v),disabled:E,touchDragDelay:()=>t.touchDragDelay}),pe=At({scroller:I.scroller,controller:{toggleExpanded:v=>{E()||p.toggleExpanded(v);},toggleColExpanded:v=>{E()||p.toggleColExpanded(v);},sortField:(v,z)=>{E()||p.sortField(v,z);}},getVM:I.getVM,getTheadHeight:I.getTheadHeight,rowHeight:F,shared:u,onCellClick:t.disabled===true?void 0:t.onCellClick,resolveCellClick:v=>p.resolveCellClick(v),onGlobalContextMenu:(v,z)=>{E()||x(v,z);},onFilterClick:(v,z,O)=>{E()||C.open(v,z,O);},onHeaderContextMenu:(v,z,O,G)=>{E()||c.openFieldMenu(v,z,O,G);},onNodeContextMenu:v=>{E()||c.openNodeMenu(v);},keyboardEnabled:t.keyboardNavigation?.enabled!==false}),re=bt({scroller:I.scroller,shared:u,getVM:I.getVM,onStats:v=>p.setSelectionStats(v)}),fe=Ht({host:m,scroller:I.scroller,shared:u,isRtl:()=>n.rtl,getWidths:()=>p.getState().columnWidths??{},rowHeaderLayout:()=>I.rowHeaderLayout(),dataColOffset:()=>I.getVM()?.dataColOffset??0,commit:v=>{E()||p.setColumnWidths(v);}}),ye=jt(i,()=>{J.paint(p.getState()),I.refreshWindow();}),Ee=Yt({portal:y,getI18n:()=>n,controller:p,getReports:()=>p.getState().reports??[],getActiveReportId:()=>p.getState().activeReportId??null,requestRepaint:()=>J.paint(p.getState())}),J=Wt({host:d,getI18n:()=>n,toolbar:t.toolbar,advancedExport:t.advancedExport===true,upgradeUrl:t.upgradeUrl,registry:t.registry,onToggleFieldChooser:()=>r.toggle(),fieldChooserOpen:()=>r.isOpen(),onRefresh:t.onRefresh,onExport:v=>{p.exportData(v,{applyFilters:true}).catch(z=>{let O=z instanceof Error?z:new Error(String(z));O.name!=="AbortError"&&(t.onError?t.onError(O):console.error(O));});},onExpandAll:()=>p.expandAll({allLevels:true}),onCollapseAll:()=>p.collapseAll(),onAddCalculatedField:t.onAddCalculatedField?()=>{E()||t.onAddCalculatedField();}:void 0,onOpenPrefilter:t.onOpenPrefilter?()=>{E()||t.onOpenPrefilter();}:void 0,onToggleChart:t.onToggleChart?()=>{E()||t.onToggleChart();}:void 0,onToggleFullscreen:()=>ye.toggle(),isFullscreen:()=>ye.isFullscreen(),onGlobalContextMenu:x,mountReportMenu:v=>Ee.mount(v),onSearch:t.search?v=>p.setSearchText(v):void 0}),S=false,A=false,B=null,W=0;function U(){S||A||(A=true,queueMicrotask(Z));}let de="";function ge(v){let z=pivotgridCore.pivotChipView(v);if(de!==z.className){for(let G of de.split(" "))G&&i.classList.remove(G);for(let G of z.className.split(" "))G&&i.classList.add(G);de=z.className;}let O=z.style["--pivot-chip-max-width"];O?i.style.setProperty("--pivot-chip-max-width",O):i.style.removeProperty("--pivot-chip-max-width"),Vt(i);}function Z(){if(A=false,S)return;let v=p.getState(),z=!B||B.engineResult!==v.engineResult||B.fields!==v.fields||B.layout!==v.layout||B.expandedPaths!==v.expandedPaths||B.expandedColPaths!==v.expandedColPaths||B.columnWidths!==v.columnWidths;(!B||B.layout!==v.layout)&&ge(v.layout);let O=!B||B.isBuilding!==v.isBuilding||B.buildProgress!==v.buildProgress||B.engineError!==v.engineError||B.engineResult!==v.engineResult||B.noData!==v.noData,G=!B||B.selectionStats!==v.selectionStats||B.reports!==v.reports||B.activeReportId!==v.activeReportId||B.layout!==v.layout;if(z&&(H.paint(pivotgridCore.shownFields(v.fields).filter(N=>N.area==="filter"),v.layout.showFilterArea!==false,{maxRows:v.layout.filterAreaMaxRows,collapsed:v.layout.filterAreaCollapsed===true,collapsedRows:v.layout.filterAreaCollapsedRows}),r.isOpen()&&r.repaint()),z&&v.engineResult&&I.paintStructural(v),R!==void 0&&(((R?i.querySelector(`.kanuni-pivot-field-chip[data-drop-id="${R}"]`):P?i.querySelector(`[data-drop-id="${P}"]`):null)??I.scroller).focus({preventScroll:true}),R=void 0,P=void 0),O&&ue(v),!B||B.engineResult!==v.engineResult){let N=v.engineResult?.columnsTruncated;V.style.display=N?"":"none";let j=new Intl.NumberFormat(n.locale);V.textContent=N?n.t("columnsTruncated").replace("{shown}",j.format(N.shown)).replace("{total}",j.format(N.total)):"";}if(B&&B.searchText!==v.searchText&&J.syncSearch(v.searchText??""),B&&B.fields!==v.fields){let N=pivotgridCore.pivotChangeAnnouncement(B.fields,v.fields,n.t);N&&(g.textContent=pivotgridCore.nextLiveText(g.textContent??"",N));}G&&(J.element.style.display=v.layout.showFooter===false?"none":"",J.paint(v)),B=v,W++;}function ue(v){if(v.engineError){f.style.display="block",f.textContent=`${n.t("error")}: ${v.engineError.message}`;return}if(v.isBuilding&&!v.engineResult){f.style.display="block",f.textContent=`${n.t("initializing")} ${Math.round(v.buildProgress??0)}%`;return}if(!v.engineResult){f.style.display="block",f.textContent=n.t(v.noData?"emptyData":"loading");return}f.style.display="none",f.textContent="";}let L=t.onChartSync?at(p,()=>n.locale,t.chartIntegrationOptions??{},t.onChartSync):null,$=p.subscribe(U);Z();let K={controller:p,element:i,setData(v){S||p.setData(v);},applyTransaction(v){return p.applyTransaction(v)},applyTransactionAsync(v,z){p.applyTransactionAsync(v,z);},flushAsyncTransactions(){p.flushAsyncTransactions();},setLoading(v){p.setLoading(v);},undoLayout:()=>pivotgridCore.keepFocusAcross(i,p,()=>p.undoLayout()),redoLayout:()=>pivotgridCore.keepFocusAcross(i,p,()=>p.redoLayout()),canUndoLayout:()=>p.canUndoLayout(),canRedoLayout:()=>p.canRedoLayout(),clearLayoutHistory:()=>p.clearLayoutHistory(),setFields(v){S||p.setFields(v);},setSearchText(v){p.setSearchText(v);},setLocale(v,z,O){S||(n=Be(v,z??t.dictionary,O??t.rtl),i.setAttribute("dir",n.rtl?"rtl":"ltr"),p.updateOptions({locale:n.locale,dictionary:n.dictionary}),B=null,U(),r.relocalize(),L?.refresh());},openFieldChooser:()=>r.open(),closeFieldChooser:()=>r.close(),clearAllFilters:()=>p.clearAllFilters(),setDensity(v){S||(T()&&i.classList.remove(T()),M=v,T()&&i.classList.add(T()),B=null,U());},destroy(){S||(S=true,$(),w(),s(),L?.stop(),r.destroy(),ie.destroy(),pe.destroy(),re.destroy(),fe.destroy(),H.destroy(),Ee.destroy(),J.destroy(),ye.destroy(),y.destroy(),I.destroy(),p.dispose(),i.remove(),a||lt.delete(l));}};return Object.defineProperty(K,"__flushCount",{get:()=>W}),Object.defineProperty(K,"__shared",{get:()=>u}),Object.defineProperty(K,"__dragRootCount",{get:()=>ie.rootCount()}),K}
3
- Object.defineProperty(exports,"PivotController",{enumerable:true,get:function(){return pivotgridCore.PivotController}});Object.defineProperty(exports,"defaultPivotLayout",{enumerable:true,get:function(){return pivotgridCore.defaultPivotLayout}});Object.defineProperty(exports,"getAdvancedExporter",{enumerable:true,get:function(){return pivotgridCore.getAdvancedExporter}});Object.defineProperty(exports,"registerAdvancedExporter",{enumerable:true,get:function(){return pivotgridCore.registerAdvancedExporter}});exports.createChartSync=at;exports.createPivotGrid=To;exports.createPortalLayer=ot;exports.createThemedHost=De;exports.createValueFormatter=Ne;exports.filledIcon=Ve;exports.fitPortalZoom=Oe;exports.icon=X;exports.portalParent=$e;exports.resolveI18n=Be;
1
+ 'use strict';var pivotgridCore=require('@kanunilabs/pivotgrid-core');var pt={tr:pivotgridCore.tr,en:pivotgridCore.en,ar:pivotgridCore.ar,de:pivotgridCore.de,fr:pivotgridCore.fr,es:pivotgridCore.es,it:pivotgridCore.it,pt:pivotgridCore.pt,ru:pivotgridCore.ru,"zh-CN":pivotgridCore.zhCN,ja:pivotgridCore.ja,ko:pivotgridCore.ko};function Ne(e,t,n){let a=e??"en",d={...pivotgridCore.en,...pt[a]??{},...t??{}};return {locale:a,rtl:n!==void 0?n:a==="ar",dictionary:d,t:i=>d[i]||i,defaultBlanks:pt[a]?.blanks||pivotgridCore.en.blanks}}var hn={renderCalculatedFieldModal:"render props do not exist here; pass onAddCalculatedField/onEditCalculatedField, or use @kanunilabs/pivotgrid-enterprise which fills the socket",renderPrefilterBuilder:"render props do not exist here; pass onOpenPrefilter, or use @kanunilabs/pivotgrid-enterprise which fills the socket",renderNodeContextMenu:"render props do not exist here; the node menu is built in (Community since #192)",onOpenFullScreenChart:"dead even in React (never fires); use chartIntegrationOptions",children:"this is not a React component",ref:"the object returned by createPivotGrid IS the imperative handle",touchChipTap:"a tap on a field chip sorts it here, as a click does; a long press does not open its menu (B.35)",fieldChooserMode:"the field list here always opens over the pivot; the side panel is React only (B.37)"},ut=new Set;function ft(e){for(let t of Object.keys(e)){let n=hn[t];!n||ut.has(t)||(ut.add(t),console.warn(`[pivotgrid] config key "${t}" is React-only and ignored \u2014 ${n}`));}}var vn=[["background","--pivot-bg"],["surface","--pivot-surface"],["surfaceHover","--pivot-surface-hover"],["surfaceHeader","--pivot-surface-header"],[e=>e.headerBackground||e.surfaceHeader,"--pivot-header-bg"],["headerText","--pivot-header-text"],["border","--pivot-border"],["text","--pivot-text"],["textMuted","--pivot-text-muted"],["textHeader","--pivot-text-header"],["primary","--pivot-primary"],["primaryForeground","--pivot-primary-foreground"],["success","--pivot-success"],["danger","--pivot-danger"],["warning","--pivot-warning"],["info","--pivot-info"],["totalBackground","--pivot-total-bg"],["stripeBackground","--pivot-stripe-bg"],["groupBorder","--pivot-group-border"],["iconActive","--pivot-icon-active"]];function ht(e,t){for(let[n,a]of vn){let d=t?typeof n=="function"?n(t):t[n]:void 0;typeof d=="string"&&d?e.style.setProperty(a,d):e.style.removeProperty(a);}t?.id?e.setAttribute("data-theme",t.id):e.removeAttribute("data-theme");}var Ze=(e,t)=>(e.areaIndex||0)-(t.areaIndex||0);function bt(e,t){let n=pivotgridCore.shownFields(e.fields),a=e.layout,d=n.filter(o=>o.area==="row").sort(Ze),i=n.filter(o=>o.area==="column").sort(Ze),s=n.filter(o=>o.area==="data").sort(Ze),w=e.engineResult,M=e.expandedPaths.has("*"),T=e.expandedColPaths.has("*"),F=a.rowHeaderLayout==="tree"?1:d.length||1,m=a.dataFieldPosition==="rows"&&s.length>1,u=m?1:s.length;if(!w)return {rowFields:d,colFields:i,dataFields:s,colHeaders:[],virtualRows:[],leafColHashes:[],cellLookup:new Map,fieldRanges:{},engineResult:null,layout:a,maxRowDepth:F,showDataInRows:m,dfsPerLeaf:u,totalDataCols:0,dataColOffset:F+(m?1:0)};let[y,h]=a.hideEmptySummaryCells?pivotgridCore.filterEmptySummaryTree(w):[w.rowTree,w.colTree],p=pivotgridCore.buildColumnHeaders(h,s,a,e.expandedColPaths,T,t,i.length),g=a.rowHeaderLayout==="tree"?pivotgridCore.flattenRowTreeTree(y,e.expandedPaths,M,d.length||1,a.showRowTotals??true,a.totalsPosition??"bottom",a.showTotalsForSingleValues!==false):pivotgridCore.flattenRowTreeTabular(y,e.expandedPaths,M,F,a.showRowTotals??true,a.totalsPosition??"bottom",a.showTotalsForSingleValues!==false),l=[];for(let o of g)if(m&&!o.isSubtotal&&!o.hasChildren)for(let x=0;x<s.length;x++)l.push({flatRow:o,dfIndex:x,isDataRow:true,isGrandTotal:false});else l.push({flatRow:o,dfIndex:0,isDataRow:false,isGrandTotal:false});if(pivotgridCore.grandTotalShown(a,"row",y))if(m)for(let o=0;o<s.length;o++)l.push({flatRow:null,dfIndex:o,isDataRow:true,isGrandTotal:true});else l.push({flatRow:null,dfIndex:0,isDataRow:false,isGrandTotal:true});let k=pivotgridCore.columnSlotOptions(a),b=[];for(let o of pivotgridCore.getVisibleColSlots(h,e.expandedColPaths,T,k))b.push({hash:o.node.key,isGrandTotal:!!o.node.isTotal,isSubtotal:o.isSubtotal});(pivotgridCore.grandTotalShown(a,"column",h)||b.length===0)&&b.push({hash:"",isGrandTotal:true});let C=new Map,r=w.cellMatrix.keys;for(let o=0;o<r.length;o++)C.set(r[o],o);let c=s.some(pivotgridCore.fieldNeedsRange)?pivotgridCore.computeFieldRanges(w,s):{};return {rowFields:d,colFields:i,dataFields:s,colHeaders:p,virtualRows:l,leafColHashes:b,cellLookup:C,fieldRanges:c,engineResult:w,layout:a,maxRowDepth:F,showDataInRows:m,dfsPerLeaf:u,totalDataCols:b.length*u,dataColOffset:F+(m?1:0)}}function Je(e,t,n,a,d){let i=e.engineResult,s=i.rowIndexMap[t]??-1,w=i.columnIndexMap[n]??-1;if(s===-1||w===-1)return null;let M=e.cellLookup.get(s*pivotgridCore.MAX_C+w);if(M===void 0)return null;let T=e.dataFields.length,F=i.cellMatrix.sums,m=i.cellMatrix.displaySums,u={};for(let y=0;y<T;y++)u[e.dataFields[y].id]=F[M*T+y],m&&(u[`${e.dataFields[y].id}_display`]=m[M*T+y]);return {values:u,rowPath:pivotgridCore.pathParts(t),colPath:pivotgridCore.pathParts(n),isTotalCell:s===0||w===0||a||d}}function yt(e,t,n){if(!e.engineResult||n<e.dataColOffset)return null;let a=n-e.dataColOffset,d=Math.floor(a/e.dfsPerLeaf),i=a%e.dfsPerLeaf;if(d>=e.leafColHashes.length)return null;let s=e.virtualRows[t];if(!s)return null;let w=s.isGrandTotal?"":s.flatRow?.key;if(w===void 0)return null;let M=e.leafColHashes[d]?.hash;if(M===void 0)return null;let T=e.engineResult.rowIndexMap[w],F=e.engineResult.columnIndexMap[M];if(T===void 0||F===void 0)return null;let m=e.cellLookup.get(T*pivotgridCore.MAX_C+F);if(m===void 0)return null;let u=e.showDataInRows?s.dfIndex:i,h=e.engineResult.cellMatrix.sums[m*e.dataFields.length+u];return typeof h=="number"?h:null}function Qe(e,t,n){let a=e.virtualRows[t];if(!a||a.isGrandTotal||!a.flatRow)return null;let d=a.flatRow,i=e.layout.rowHeaderLayout==="tree",s=n,w=i?d.depth:s,M=w===d.depth,T=w<d.depth,F=M?d.hasChildren:T,m=M?d.isExpanded:T,u=i?d.key:pivotgridCore.pathKey(d.pathValues.slice(0,s+1));return {hasChildren:F,isExpanded:m,cellHashStr:u,depth:w,dIdx:s,flatRow:d}}function xt(e,t,n){if(n<e.dataColOffset||!e.engineResult)return null;let a=n-e.dataColOffset,d=Math.floor(a/e.dfsPerLeaf),i=a%e.dfsPerLeaf;if(d>=e.leafColHashes.length)return null;let s=e.virtualRows[t];if(!s)return null;let w=s.isGrandTotal?"":s.flatRow?.key;if(w===void 0)return null;let M=e.leafColHashes[d],T=Je(e,w,M.hash,!!s.flatRow?.isSubtotal,M.isGrandTotal);if(!T)return null;let F=e.showDataInRows?s.dfIndex:i,m=e.dataFields[F],u=T.values[`${m?.id}_display`]??T.values[m?.id],y=!!s.flatRow?.isSubtotal||M.isGrandTotal||T.isTotalCell;return {cell:{isTotalCell:T.isTotalCell,rowPath:T.rowPath,colPath:T.colPath,values:T.values},val:u,isTotal:y}}function We(e){let t=new Map;return (n,a)=>{if(n==null||Number.isNaN(n))return "";if(a.format&&typeof n=="number"){if(typeof a.format=="function")return a.format(n);try{let d=a.format,i=t.get(d);i||(i=new Intl.NumberFormat(e,d),t.set(d,i));let s=i.format(n);return d.isCustom&&(d.prefix||d.suffix)?`${d.prefix||""}${s}${d.suffix||""}`:s}catch{return String(n)}}return typeof n=="number"&&pivotgridCore.percentModeText(n,a,e)||String(n)}}var De=null;function Ge(e,t,n){if(!e)return false;let a=Math.min(e.startR,e.endR),d=Math.max(e.startR,e.endR),i=Math.min(e.startC,e.endC),s=Math.max(e.startC,e.endC);return t>=a&&t<=d&&n>=i&&n<=s}function Ct(e){let{scroller:t,shared:n}=e,a={},d="",i=null,s=false;function w(){for(let y of t.querySelectorAll("td[data-r][data-c]")){let h=Number(y.getAttribute("data-r")),p=Number(y.getAttribute("data-c"));y.classList.toggle("kanuni-pivot-cell-selected",Ge(n.selection,h,p));}}function M(){let y=n.selection;if(e.onStats){if(!y||y.mode!=="data"){i&&(clearTimeout(i),i=null),s&&(s=false,e.onStats(null));return}i&&clearTimeout(i),i=setTimeout(()=>{i=null;let h=n.selection;if(!h||h.mode!=="data")return;let p=Math.min(h.startR,h.endR),g=Math.max(h.startR,h.endR),l=Math.min(h.startC,h.endC),k=Math.max(h.startC,h.endC),b=0,C=0,r=1/0,c=-1/0,o=e.getVM();if(o){for(let x=p;x<=g;x++)for(let f=l;f<=k;f++){let E=yt(o,x,f);E===null||isNaN(E)||(b+=E,C++,E<r&&(r=E),E>c&&(c=E));}s=C>0,e.onStats(C>0?{sum:b,count:C,avg:b/C,min:r,max:c}:null);}},10);}}n.selectByKey=(y,h,p,g)=>{let l=e.getVM();if(!l)return;let k=h<l.dataColOffset?"row":"data",b=n.selection;if(De=a,d="",p&&b&&b.mode===k){if(b.endR===y&&b.endC===h&&!b.isSelecting)return;n.selection={...b,endR:y,endC:h,isSelecting:false};}else if(p){let r=(g.c<l.dataColOffset?"row":"data")===k?g:{r:y,c:h};n.selection={startR:r.r,startC:r.c,endR:y,endC:h,isSelecting:false,mode:k};}else {if(b&&b.mode===k&&!b.isSelecting&&b.startR===y&&b.startC===h&&b.endR===y&&b.endC===h)return;n.selection={startR:y,startC:h,endR:y,endC:h,isSelecting:false,mode:k};}w(),M();};let T=y=>{if(y.button!==0||n.isResizing||y.target.closest?.(".kanuni-pivot-resize-handle"))return;let h=y.target.closest?.("td[data-r][data-c]");if(!h)return;let p=e.getVM();if(!p)return;let g=Number(h.getAttribute("data-r")),l=Number(h.getAttribute("data-c")),k=l<p.dataColOffset?"row":"data";De=a,d="",n.selection={startR:g,startC:l,endR:g,endC:l,isSelecting:true,mode:k},w(),M();},F=y=>{let h=n.selection;if(!h||!h.isSelecting)return;let p=y.target.closest?.("td[data-r][data-c]");if(!p)return;let g=Number(p.getAttribute("data-r")),l=Number(p.getAttribute("data-c")),k=`${g},${l}`;if(k===d)return;d=k;let b=e.getVM();!b||(l<b.dataColOffset?"row":"data")!==h.mode||g===h.endR&&l===h.endC||(h.endR=g,h.endC=l,w(),M());},m=()=>{n.selection&&(n.selection.isSelecting=false);},u=y=>{if(!(y.ctrlKey||y.metaKey)||y.key!=="c"||De!==null&&De!==a)return;let h=n.selection;if(!h)return;let p=Math.min(h.startR,h.endR),g=Math.max(h.startR,h.endR),l=Math.min(h.startC,h.endC),k=Math.max(h.startC,h.endC),b="";for(let C=p;C<=g;C++){let r=[];for(let c=l;c<=k;c++){let o=t.querySelector(`[data-r="${C}"][data-c="${c}"]`);r.push(o?(o.innerText??o.textContent??"").trim().replace(/\n/g," "):"");}b+=r.join(" ")+`
2
+ `;}b&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(b).catch(()=>{});};return t.addEventListener("mousedown",T),t.addEventListener("mouseover",F),document.addEventListener("mouseup",m),document.addEventListener("keydown",u),{destroy(){t.removeEventListener("mousedown",T),t.removeEventListener("mouseover",F),document.removeEventListener("mouseup",m),document.removeEventListener("keydown",u),i&&clearTimeout(i),De===a&&(De=null),n.selectByKey=void 0;}}}var wt={settings:[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]],"settings-2":[["path",{d:"M14 17H5"}],["path",{d:"M19 7h-9"}],["circle",{cx:"17",cy:"17",r:"3"}],["circle",{cx:"7",cy:"7",r:"3"}]],download:[["path",{d:"M12 15V3"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}],["path",{d:"m7 10 5 5 5-5"}]],"refresh-cw":[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}],["path",{d:"M8 16H3v5"}]],maximize2:[["path",{d:"M15 3h6v6"}],["path",{d:"m21 3-7 7"}],["path",{d:"m3 21 7-7"}],["path",{d:"M9 21H3v-6"}]],minimize2:[["path",{d:"m14 10 7-7"}],["path",{d:"M20 10h-6V4"}],["path",{d:"m3 21 7-7"}],["path",{d:"M4 14h6v6"}]],fullscreen:[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1"}]],shrink:[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3"}]],"file-spreadsheet":[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M8 13h2"}],["path",{d:"M14 13h2"}],["path",{d:"M8 17h2"}],["path",{d:"M14 17h2"}]],"file-text":[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]],"file-json":[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1"}]],file:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}]],database:[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5"}],["path",{d:"M3 12A9 3 0 0 0 21 12"}]],calculator:[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18"}],["path",{d:"M16 10h.01"}],["path",{d:"M12 10h.01"}],["path",{d:"M8 10h.01"}],["path",{d:"M12 14h.01"}],["path",{d:"M8 14h.01"}],["path",{d:"M12 18h.01"}],["path",{d:"M8 18h.01"}]],filter:[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"}]],"bar-chart":[["path",{d:"M5 21v-6"}],["path",{d:"M12 21V9"}],["path",{d:"M19 21V3"}]],"bar-chart-3":[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}],["path",{d:"M18 17V9"}],["path",{d:"M13 17V5"}],["path",{d:"M8 17v-3"}]],"line-chart":[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}],["path",{d:"m19 9-5 5-4-4-3 3"}]],"area-chart":[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z"}]],"pie-chart":[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83"}]],"scatter-chart":[["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor"}],["circle",{cx:"18.5",cy:"5.5",r:".5",fill:"currentColor"}],["circle",{cx:"11.5",cy:"11.5",r:".5",fill:"currentColor"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor"}],["circle",{cx:"17.5",cy:"14.5",r:".5",fill:"currentColor"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}]],"dot-plot":[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"19",cy:"12",r:"1"}],["circle",{cx:"5",cy:"12",r:"1"}]],"bubble-chart":[["circle",{cx:"12",cy:"12",r:"10"}],["circle",{cx:"12",cy:"12",r:"1"}]],"donut-chart":[["path",{d:"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3"}],["circle",{cx:"12",cy:"12",r:"3"}]],"waterfall-chart":[["path",{d:"M13 17V9"}],["path",{d:"M18 17v-3"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}],["path",{d:"M8 17V5"}]],"funnel-chart":[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"}]],"treemap-chart":[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1"}]],"heatmap-chart":[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"M3 9h18"}],["path",{d:"M3 15h18"}],["path",{d:"M9 3v18"}],["path",{d:"M15 3v18"}]],"range-chart":[["path",{d:"M9 5v4"}],["rect",{width:"4",height:"6",x:"7",y:"9",rx:"1"}],["path",{d:"M9 15v2"}],["path",{d:"M17 3v2"}],["rect",{width:"4",height:"8",x:"15",y:"5",rx:"1"}],["path",{d:"M17 13v3"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}]],"sunburst-chart":[["circle",{cx:"12",cy:"12",r:"4"}],["path",{d:"M12 2v2"}],["path",{d:"M12 20v2"}],["path",{d:"m4.93 4.93 1.41 1.41"}],["path",{d:"m17.66 17.66 1.41 1.41"}],["path",{d:"M2 12h2"}],["path",{d:"M20 12h2"}],["path",{d:"m6.34 17.66-1.41 1.41"}],["path",{d:"m19.07 4.93-1.41 1.41"}]],"histogram-chart":[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1"}]],radar:[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34"}],["path",{d:"M4 6h.01"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67"}],["path",{d:"M12 18h.01"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67"}],["circle",{cx:"12",cy:"12",r:"2"}],["path",{d:"m13.41 10.59 5.66-5.66"}]],printer:[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1"}]],copy:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"}]],save:[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7"}]],"save-all":[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z"}]],bookmark:[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z"}]],"folder-open":[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}]],check:[["path",{d:"M20 6 9 17l-5-5"}]],"check-circle":[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335"}],["path",{d:"m9 11 3 3L22 4"}]],star:[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"}]],trash:[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]],x:[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]],search:[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]],"grip-vertical":[["circle",{cx:"9",cy:"12",r:"1"}],["circle",{cx:"9",cy:"5",r:"1"}],["circle",{cx:"9",cy:"19",r:"1"}],["circle",{cx:"15",cy:"12",r:"1"}],["circle",{cx:"15",cy:"5",r:"1"}],["circle",{cx:"15",cy:"19",r:"1"}]],"grip-horizontal":[["circle",{cx:"12",cy:"9",r:"1"}],["circle",{cx:"19",cy:"9",r:"1"}],["circle",{cx:"5",cy:"9",r:"1"}],["circle",{cx:"12",cy:"15",r:"1"}],["circle",{cx:"19",cy:"15",r:"1"}],["circle",{cx:"5",cy:"15",r:"1"}]],"chevron-down":[["path",{d:"m6 9 6 6 6-6"}]],"chevron-left":[["path",{d:"m15 18-6-6 6-6"}]],"chevron-right":[["path",{d:"m9 18 6-6-6-6"}]],"chevrons-left":[["path",{d:"m11 17-5-5 5-5"}],["path",{d:"m18 17-5-5 5-5"}]],"chevrons-right":[["path",{d:"m6 17 5-5-5-5"}],["path",{d:"m13 17 5-5-5-5"}]],"arrow-up":[["path",{d:"m5 12 7-7 7 7"}],["path",{d:"M12 19V5"}]],"arrow-down":[["path",{d:"M12 5v14"}],["path",{d:"m19 12-7 7-7-7"}]],"arrow-down-a-z":[["path",{d:"m3 16 4 4 4-4"}],["path",{d:"M7 20V4"}],["path",{d:"M20 8h-5"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10"}],["path",{d:"M15 14h5l-5 6h5"}]],"arrow-up-z-a":[["path",{d:"m3 8 4-4 4 4"}],["path",{d:"M7 4v16"}],["path",{d:"M15 4h5l-5 6h5"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20"}],["path",{d:"M20 18h-5"}]],"eye-off":[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}],["path",{d:"m2 2 20 20"}]],list:[["path",{d:"M3 5h.01"}],["path",{d:"M3 12h.01"}],["path",{d:"M3 19h.01"}],["path",{d:"M8 5h13"}],["path",{d:"M8 12h13"}],["path",{d:"M8 19h13"}]],columns3:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"M9 3v18"}],["path",{d:"M15 3v18"}]],hash:[["line",{x1:"4",x2:"20",y1:"9",y2:"9"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21"}]],calendar:[["path",{d:"M8 2v4"}],["path",{d:"M16 2v4"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}],["path",{d:"M3 10h18"}]],type:[["path",{d:"M12 4v16"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}],["path",{d:"M9 20h6"}]],plus:[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]],"alert-circle":[["circle",{cx:"12",cy:"12",r:"10"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16"}]],move:[["path",{d:"M12 2v20"}],["path",{d:"m15 19-3 3-3-3"}],["path",{d:"m19 9 3 3-3 3"}],["path",{d:"M2 12h20"}],["path",{d:"m5 9-3 3 3 3"}],["path",{d:"m9 5 3-3 3 3"}]]};var Et="http://www.w3.org/2000/svg";function _(e,t=15,n){let a=document.createElementNS(Et,"svg");a.setAttribute("width",String(t)),a.setAttribute("height",String(t)),a.setAttribute("viewBox","0 0 24 24"),a.setAttribute("fill","none"),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","2"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),a.setAttribute("aria-hidden","true"),a.setAttribute("focusable","false"),n&&(a.style.color=n);for(let[d,i]of wt[e]??[]){let s=document.createElementNS(Et,d);for(let[w,M]of Object.entries(i))s.setAttribute(w,String(M));a.appendChild(s);}return a}function ze(e,t=15,n){let a=_(e,t,n);return a.setAttribute("fill","currentColor"),a}function be(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function et(e){let t=document.activeElement;return !t||!e.contains(t)?null:t.closest(".kanuni-pivot-field-chip")?.getAttribute("data-drop-id")??null}function tt(e,t){if(!t)return;let n=e.querySelector(`.kanuni-pivot-field-chip[data-drop-id="${t}"]`);n&&n!==document.activeElement&&n.focus({preventScroll:true});}function An(e,t,n){let a=e.filter(d=>d.area===t);return t==="filter"?kt(a,n):a.sort((d,i)=>(d.areaIndex||0)-(i.areaIndex||0))}var Fn={row:"rowArea",column:"columnArea",data:"dataArea",filter:"filterArea"};function je(e,t){let{t:n,locale:a,rtl:d}=t.getI18n(),i=be("kanuni-pivot-field-chip");i.setAttribute("data-drop-id",e.id),i.setAttribute("data-touch-hold",""),i.style.position="relative",i.style.cursor="pointer",i.setAttribute("role","button"),i.tabIndex=0;let s=t.getFields?An(t.getFields(),e.area,a):[e],w=Math.max(0,s.findIndex(l=>l.id===e.id)),M=n(Fn[e.area??""]??"rowArea");i.setAttribute("aria-label",n("fieldChipLabel").replace("{0}",e.caption||e.id).replace("{1}",M).replace("{2}",String(w+1)).replace("{3}",String(s.length))),i.setAttribute("aria-keyshortcuts","Control+ArrowLeft Control+ArrowRight Control+Home Control+End Delete Alt+ArrowDown Shift+F10"),i.setAttribute("aria-description",n("fieldChipKeys"));let T=()=>{if(!t.onSort)return;let l=e.sortOrder==="asc"?"desc":e.sortOrder==="desc"?void 0:"asc";t.onSort(e.id,l);},F=l=>{if(!l)return;(i.closest(".kanuni-pivot-root")??document.body).querySelector(`.kanuni-pivot-field-chip[data-drop-id="${l}"]`)?.focus({preventScroll:true});};i.addEventListener("keydown",l=>{let k=l.ctrlKey||l.metaKey,b=d?"ArrowRight":"ArrowLeft",C=d?"ArrowLeft":"ArrowRight",r=!!t.onMove&&e.area!=="filter",c=true;if(l.key==="Enter"||l.key===" ")T();else if(k&&r&&(l.key===b||l.key==="ArrowUp"))w>0&&t.onMove(e.id,"left");else if(k&&r&&(l.key===C||l.key==="ArrowDown"))w<s.length-1&&t.onMove(e.id,"right");else if(k&&r&&l.key==="Home")w>0&&t.onMove(e.id,"start");else if(k&&r&&l.key==="End")w<s.length-1&&t.onMove(e.id,"end");else if(!k&&(l.key===b||l.key===C)){let o=l.key===b?-1:1;F(s[w+o]?.id);}else if(l.key==="Delete"||l.key==="Backspace"){let o=s[w+1]??s[w-1];t.requestFocus?.(o?.id??null),t.onRemove(e.id);}else if(l.altKey&&l.key==="ArrowDown"){let o=i.getBoundingClientRect();t.onFilterClick(d?o.right:o.left,o.bottom,e.id);}else if(l.key==="F10"&&l.shiftKey||l.key==="ContextMenu"){if(!t.onContextMenu)return;let o=i.getBoundingClientRect();t.onContextMenu(d?o.right:o.left,o.bottom,e.id,void 0,true);}else c=false;c&&(l.preventDefault(),l.stopPropagation());});let m=be("pivot-truncate","span");Object.assign(m.style,{maxWidth:"var(--pivot-chip-max-width, 120px)",userSelect:"none"}),m.title=e.caption||e.id,m.textContent=e.caption||e.id,i.appendChild(m),e.sortOrder==="asc"&&i.appendChild(_("arrow-up",12,"var(--pivot-primary)")),e.sortOrder==="desc"&&i.appendChild(_("arrow-down",12,"var(--pivot-primary)"));let u=e.area==="data"&&e.summaryType?pivotgridCore.summaryTypeLabel(String(e.summaryType),n):"";if(u){let l=be("kanuni-pivot-chip-badge","span");Object.assign(l.style,{fontSize:"10px",backgroundColor:"color-mix(in srgb, var(--pivot-primary) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--pivot-primary) 45%, transparent)",color:"var(--pivot-text)",padding:"0 4px",borderRadius:"4px",fontWeight:"700"}),l.textContent=u,i.appendChild(l);}let y=!!e.filterValues&&e.filterValues.size>0||!!e.valueFilter||!!e.labelFilter,h=be(`kanuni-pivot-field-chip-actions${y?" is-filtered":""}`);h.setAttribute("aria-hidden","true");let p=be("kanuni-pivot-chip-btn","span");p.title=n("filterField"),p.style.color=y?"var(--pivot-danger)":"inherit",p.appendChild(_("filter",12)),p.addEventListener("pointerdown",l=>l.stopPropagation()),p.addEventListener("click",l=>{l.stopPropagation(),t.onFilterClick(l.clientX,l.clientY,e.id);});let g=be("kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger kanuni-pivot-chip-remove","span");if(g.title=n("removeField"),g.appendChild(_("x",12)),g.addEventListener("pointerdown",l=>l.stopPropagation()),g.addEventListener("click",l=>{l.stopPropagation(),t.onRemove(e.id);}),h.append(p,g),i.appendChild(h),t.onContextMenu){i.setAttribute("data-chip-menu","");let l=be(`kanuni-pivot-chip-more${y?" is-filtered":""}`,"span");if(l.setAttribute("aria-hidden","true"),l.addEventListener("pointerdown",k=>k.stopPropagation()),l.addEventListener("click",k=>{k.stopPropagation();let b=l.getBoundingClientRect();t.onContextMenu(d?b.right:b.left,b.bottom,e.id,void 0);}),i.appendChild(l),y){let k=_("filter",10);k.classList.add("kanuni-pivot-chip-filtered-mark"),k.setAttribute("aria-hidden","true"),i.appendChild(k);}}return i.addEventListener("click",l=>{l.stopPropagation(),T();}),i.addEventListener("contextmenu",l=>{if(l.stopPropagation(),t.onContextMenu){l.preventDefault();let k=i.getBoundingClientRect(),b=Number.isFinite(l.clientX)?l.clientX:d?k.right:k.left,C=Number.isFinite(l.clientY)?l.clientY:k.bottom;t.onContextMenu(b,C,e.id,void 0);}}),i}function qe(e,t,n,a,d){let{t:i}=d.getI18n(),s=be("kanuni-pivot-area-dropzone");s.setAttribute("data-drop-id",e),s.tabIndex=-1;let w=be("kanuni-pivot-area-header");w.appendChild(_(n,13)),w.appendChild(document.createTextNode(t)),s.appendChild(w);let M=be("kanuni-pivot-area-content");if(a.length===0){let F=be("pivot-text-xs pivot-text-muted","span");Object.assign(F.style,{fontStyle:"italic",padding:"0 8px"}),F.textContent=i("dropHere"),M.appendChild(F);}for(let F of a)M.appendChild(je(F,d));let T=be("kanuni-pivot-ghost-end");return T.setAttribute("data-drop-id",`${e}-ghost-end`),T.setAttribute("data-ghost-populated",a.length>0?"1":"0"),Object.assign(T.style,{flex:"1",minWidth:"40px",minHeight:"24px",borderRadius:"var(--pivot-border-radius-sm)",transition:"background-color 0.2s"}),M.appendChild(T),s.appendChild(M),s}function kt(e,t){let n=new Map;return e.map(d=>{let i=d.caption||d.id||"";if(n.has(i)){let s=n.get(i)+1;return n.set(i,s),{...d,caption:`${i} (${s})`}}return n.set(i,1),d}).sort((d,i)=>(d.caption||"").toLowerCase().localeCompare((i.caption||"").toLowerCase(),t||"en"))}function Tt(e){let t=be("kanuni-pivot-filter-strip pivot-flex pivot-flex-col");Object.assign(t.style,{padding:"8px",borderBottom:"1px solid var(--pivot-border)",backgroundColor:"var(--pivot-area-bg, color-mix(in srgb, var(--pivot-surface-header) 30%, transparent))",flex:"0 0 auto"});let n=d=>{e.onGlobalContextMenu&&(d.target.closest(".kanuni-pivot-field-chip")||(d.preventDefault(),e.onGlobalContextMenu(d.clientX,d.clientY)));};t.addEventListener("contextmenu",n),e.host.appendChild(t);function a(d,i,s){let{t:w}=e.getI18n(),M=d.querySelector(".kanuni-pivot-area-header"),T=d.querySelector(".kanuni-pivot-area-content"),F=s.collapsed===true;if(F&&d.setAttribute("data-collapsed",""),M&&F){let y=pivotgridCore.countFilteredFields(i);if(y>0){let h=be("kanuni-pivot-area-filtered-count","span");h.textContent=w("filteredFieldCount").replace("{0}",String(y)),M.appendChild(h);}}if(M&&e.onToggleCollapsed&&i.length>0){let y=be("kanuni-pivot-area-collapse","button");y.type="button";let h=w(F?"expandFilterArea":"collapseFilterArea");y.setAttribute("aria-expanded",String(!F)),y.setAttribute("aria-label",h),y.title=h;let p=_("chevron-down",14);F||(p.style.transform="rotate(180deg)"),y.appendChild(p),y.addEventListener("click",g=>{g.stopPropagation(),e.onToggleCollapsed();}),M.appendChild(y);}let m=pivotgridCore.filterAreaRows({filterAreaMaxRows:s.maxRows,filterAreaCollapsed:F,filterAreaCollapsedRows:s.collapsedRows});if(!T||m===null)return;if(m===0){T.style.display="none";return}let u=T.querySelector(".kanuni-pivot-field-chip");T.style.maxHeight=`${pivotgridCore.filterAreaMaxHeight(m,u?.offsetHeight||28)}px`,T.style.overflowY=F?"hidden":"auto";}return {element:t,paint(d,i,s={}){t.style.display=i?"":"none";let w=et(t);if(t.textContent="",!i)return;let M=be("pivot-flex");M.style.width="100%";let{t:T,locale:F}=e.getI18n(),m=qe("filter",T("filterArea"),"filter",kt(d,F),e);M.appendChild(m),t.appendChild(M),a(m,d,s),tt(t,w);},destroy(){t.removeEventListener("contextmenu",n),t.remove();}}}var Mt="kanuni-pivot-drop-indicator";function Hn(e){let t=be(Mt);Object.assign(t.style,{position:"absolute",zIndex:"100",pointerEvents:"none",top:"-4px",bottom:"-4px",width:"0"}),t.style.setProperty(e==="before"?"inset-inline-start":"inset-inline-end","-4px");let n=be("");Object.assign(n.style,{position:"absolute",top:"0",width:"0",height:"0",borderTop:"5px solid var(--pivot-primary)"}),n.style.setProperty("inset-inline-start","-4px"),n.style.setProperty("border-inline-start","4px solid transparent"),n.style.setProperty("border-inline-end","4px solid transparent");let a=be("");Object.assign(a.style,{position:"absolute",bottom:"0",width:"0",height:"0",borderBottom:"5px solid var(--pivot-primary)"}),a.style.setProperty("inset-inline-start","-4px"),a.style.setProperty("border-inline-start","4px solid transparent"),a.style.setProperty("border-inline-end","4px solid transparent");let d=be("");return Object.assign(d.style,{position:"absolute",top:"0",bottom:"0",width:"2px",backgroundColor:"var(--pivot-primary)"}),d.style.setProperty("inset-inline-start","-1px"),t.append(n,a,d),t}function Lt(e,t){for(let n of e){for(let a of n.querySelectorAll(`.${Mt}`))a.remove();for(let a of n.querySelectorAll('[data-drop-id$="-ghost-end"]'))a.style.backgroundColor="transparent",a.style.boxShadow="none",a.textContent="";for(let a of n.querySelectorAll(".pivot-area-strip--over"))a.classList.remove("pivot-area-strip--over");for(let a of n.querySelectorAll(".kanuni-pivot-column-strip"))t.targetArea==="column"&&t.intent!==null?a.setAttribute("data-drop-over",""):a.removeAttribute("data-drop-over");for(let a of n.querySelectorAll('[data-drop-kind="list"]'))a.style.backgroundColor="transparent",a.style.boxShadow="none";}if(t.intent==="before"||t.intent==="after"){if(!t.targetId)return;for(let n of e){let a=n.querySelector(`.kanuni-pivot-field-chip[data-drop-id="${t.targetId}"]`)??n.querySelector(`[data-drop-id="${t.targetId}"]`)??n.querySelector(`[data-drop-id="chooser-${t.targetId}"]`);if(a){a.appendChild(Hn(t.intent));return}}}else if(t.intent==="append"&&t.targetArea)for(let n of e){let a=n.querySelector(`[data-drop-id="${t.targetArea}-ghost-end"]`)??n.querySelector(`[data-drop-id="chooser-${t.targetArea}-ghost-end"]`);if(a&&(a.style.backgroundColor="color-mix(in srgb, var(--pivot-primary) 10%, transparent)",a.style.boxShadow="inset 0 0 0 1px color-mix(in srgb, var(--pivot-primary) 50%, transparent)",a.getAttribute("data-ghost-populated")==="1")){let s=be("");Object.assign(s.style,{width:"4px",height:"100%",backgroundColor:"var(--pivot-primary)",borderRadius:"2px",marginLeft:"4px"}),a.appendChild(s);}n.querySelector(`[data-drop-id="${t.targetArea}"]`)?.classList.add("pivot-area-strip--over");let i=n.querySelector(`[data-drop-id="chooser-${t.targetArea}"][data-drop-kind="list"]`);i&&(i.style.backgroundColor="color-mix(in srgb, var(--pivot-primary) 5%, transparent)",i.style.boxShadow="inset 0 0 0 1px color-mix(in srgb, var(--pivot-primary) 50%, transparent)");}}var $n={style:{}},Nn=28,Pt=5,Wn=10,Rt=40,At=8,nt=100;function U(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function ee(e,t){for(let[n,a]of Object.entries(t)){if(a==null)continue;let d=n.replace(/[A-Z]/g,i=>"-"+i.toLowerCase());e.style.setProperty(d,typeof a=="number"&&a!==0&&!/z-?index|font-?weight|opacity/i.test(n)?`${a}px`:String(a));}}function Xe(e,t,n,a){let d=U("kanuni-pivot-resize-handle");return d.setAttribute("data-resize-id",e),d.setAttribute("data-resize-default",String(t)),n>1&&d.setAttribute("data-resize-span",String(n)),d.style.setProperty(a,"-3px"),d}function Be(e,t){e.textContent="",t!=null&&(typeof t=="string"||typeof t=="number"?e.textContent=String(t):e.appendChild(t));}function Pe(e,t){e.classList.add("kanuni-pivot-rh-sticky"),e.style.setProperty("inset-inline-start",t);}function Ft(e){let{host:t,getI18n:n}=e,a=e.columnWidthDefaults??pivotgridCore.resolveColumnWidthDefaults(),d=e.rowHeight??(()=>Nn),i=e.shared?.cellId??((P,A)=>`pivot-cell-${P}-${A}`),s=U("datagrid-table-wrapper custom-scrollbar pivot-right-pane");ee(s,{overflow:"auto",flex:"1 1 auto",minHeight:0,position:"relative",outline:"none"}),s.tabIndex=0,s.setAttribute("role","grid");let w=U("");ee(w,{width:"max-content",position:"relative",minWidth:"100%"});let M=U("kanuni-pivot-table","table");M.setAttribute("role","presentation"),ee(M,{borderCollapse:"separate",borderSpacing:0,width:0,minWidth:"100%",tableLayout:"fixed"});let T=document.createElement("colgroup"),F=U("","thead");F.setAttribute("role","rowgroup"),ee(F,{position:"sticky",top:0,zIndex:50,backgroundColor:"var(--pivot-surface-header)"});let m=U("","tbody");m.setAttribute("role","rowgroup"),M.append(T,F,m),w.appendChild(M),s.appendChild(w),t.appendChild(s);let u=null,y=We(n().locale),h=n().locale,p={start:-1,end:-1},g={start:0,end:Number.MAX_SAFE_INTEGER},l={},k=new Set,b=false,C=()=>u?Math.max(u.colHeaders.length,1)*d()+(e.chipDeps?42:0):0,r=P=>l[`row-${P}`]??a.rowHeader,c=()=>l[`row-${u.maxRowDepth}`]??nt,o=P=>l[`leaf-${P}`]??a.data;function x(){if(!u||u.totalDataCols<=Rt){g={start:0,end:Number.MAX_SAFE_INTEGER};return}let P=Math.abs(s.scrollLeft),A=E().total,$=P-A,N=0,X=0;for(;N<u.totalDataCols&&X+o(N)<=$;)X+=o(N),N++;N=Math.max(0,N-At);let J=s.clientWidth||0,ye=N,Y=0;for(;ye<u.totalDataCols&&Y<=J;)Y+=o(ye),ye++;g={start:N,end:Math.min(u.totalDataCols,ye+At)};}function f(){if(!u)return {start:0,end:0};let P=Math.max(0,s.scrollTop-C()),A=Math.max(0,Math.floor(P/d())-Pt),$=Math.ceil((s.clientHeight||600)/d())+Wn;return {start:A,end:Math.min(u.virtualRows.length,A+$+Pt)}}function E(){let P=[];for(let A=0;A<u.maxRowDepth;A++)P.push(r(A));return u.showDataInRows&&P.push(c()),pivotgridCore.computeRowHeaderWidths(P,R(P.length)?0:s.clientWidth)}function R(P){let A=u.layout.rowHeaderOverflow;return A==="scroll"||pivotgridCore.rowHeadersUnpinned(P,s.clientWidth,A)}function L(){s.classList.toggle("kanuni-pivot-rowheaders-scroll",R(u.maxRowDepth+(u.showDataInRows?1:0)));let{widths:P,total:A}=E(),$=0;for(let N=0;N<P.length;N++)s.style.setProperty(`--row-header-left-${N}`,`${$}px`),s.style.setProperty(`--col-width-row-${N}`,`${P[N]}px`),k.add(`--col-width-row-${N}`),$+=P[N];s.style.setProperty("--row-header-total-width",`${A}px`);}function O(){T.textContent="";for(let P=0;P<u.maxRowDepth;P++){let A=document.createElement("col");A.style.width=`var(--col-width-row-${P}, ${a.rowHeader}px)`,T.appendChild(A);}if(u.showDataInRows){let P=document.createElement("col");P.style.width=`var(--col-width-row-${u.maxRowDepth}, ${nt}px)`,T.appendChild(P);}for(let P=0;P<Math.max(u.totalDataCols,1);P++){let A=document.createElement("col");A.style.width=`var(--col-width-data-${P}, ${a.data}px)`,T.appendChild(A);}}function I(){let{colHeaders:P,rowFields:A,colFields:$,dataFields:N,maxRowDepth:X,showDataInRows:J,layout:ye,dataColOffset:Y}=u,{t:fe,locale:K}=n(),de=et(F);F.textContent="";let j=Math.max(P.length,1),v=e.chipDeps;if(v){let z=U("","tr");z.setAttribute("role","row"),ee(z,{height:42});let W=U("","th");W.setAttribute("role","columnheader"),W.colSpan=Math.max(Y,1),ee(W,{position:"sticky",zIndex:61,borderBottom:"1px solid var(--pivot-border)",borderInlineEnd:"1px solid var(--pivot-border)",padding:0,verticalAlign:"top",minWidth:50,backgroundColor:"var(--pivot-area-bg, var(--pivot-surface-header))"}),W.style.setProperty("inset-inline-start","0px"),W.appendChild(qe("data",fe("dataArea"),"bar-chart-3",N,v)),z.appendChild(W);let S=U("kanuni-pivot-column-strip","th");S.setAttribute("role","columnheader"),S.setAttribute("data-drop-id","column-strip"),S.colSpan=Math.max(u.totalDataCols,1),ee(S,{borderBottom:"1px solid var(--pivot-border)",padding:0,verticalAlign:"top",zIndex:1,backgroundColor:"var(--pivot-area-bg, var(--pivot-surface-header))"});let D=U("");ee(D,{position:"sticky",width:"max-content",maxWidth:"100%"}),D.style.setProperty("inset-inline-start","var(--row-header-total-width, 0px)"),D.appendChild(qe("column",fe("columnArea"),"columns3",$,v)),S.appendChild(D),z.appendChild(S),F.appendChild(z);}for(let z=0;z<j;z++){let W=U("","tr");if(W.setAttribute("role","row"),ee(W,{height:d()}),z===0){let D=B=>({position:"sticky",top:0,zIndex:60,backgroundColor:"var(--pivot-surface-header)",borderBottom:"1px solid var(--pivot-border)",borderInlineEnd:B?"1px solid var(--pivot-border)":"none",verticalAlign:"bottom",padding:"4px 8px",color:"var(--pivot-text-header)"});if(A.length===0){let B=U("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");B.setAttribute("data-drop-id","row"),B.setAttribute("data-row-header-idx","0"),B.rowSpan=j,B.colSpan=Math.max(Y,1),ee(B,{...D(true),padding:"8px",color:"color-mix(in srgb, var(--pivot-text-header, var(--pivot-text)) 70%, transparent)"}),Pe(B,"var(--row-header-left-0, 0px)"),B.textContent=fe("dropHere"),W.appendChild(B);}else if(ye.rowHeaderLayout==="tree"){let B=U("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");if(B.setAttribute("data-row-header-idx","0"),B.rowSpan=j,ee(B,D(!J)),Pe(B,"var(--row-header-left-0, 0px)"),v){let q=U("");ee(q,{display:"flex",flexWrap:"wrap",gap:4});for(let te of A)q.appendChild(je(te,v));B.appendChild(q);}else Be(B,A.map(q=>q.caption).join(", "));W.appendChild(B);}else for(let B=0;B<X;B++){let q=U("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");q.setAttribute("data-row-header-idx",String(B)),q.rowSpan=j,ee(q,D(B===X-1&&!J)),Pe(q,`var(--row-header-left-${B}, 0px)`);let te=A[B];te&&v&&q.setAttribute("data-drop-id",te.id),te&&v?q.appendChild(je(te,v)):Be(q,te?.caption??""),W.appendChild(q);}if(J&&A.length>0){let B=U("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");B.setAttribute("data-row-header-idx",String(X)),B.rowSpan=j,ee(B,D(true)),Pe(B,`var(--row-header-left-${X}, 0px)`);let q=U("");ee(q,{fontSize:10,fontWeight:600,textTransform:"uppercase",textAlign:"center",color:"color-mix(in srgb, var(--pivot-text-header, var(--pivot-text)) 80%, transparent)"}),q.style.letterSpacing="0.05em",q.textContent=fe("dataArea"),B.appendChild(q),W.appendChild(B);}}let S=P[z]??[];for(let D of S){let B=D.fieldId?$.find(le=>le.id===D.fieldId):void 0,q=!!B?.filterValues&&B.filterValues.size>0,te=D.leafStart,Z=B&&!D.isTotal?pivotgridCore.formatDimensionValue(D.caption,B,"grid",K,pivotgridCore.blanksTextOf(n().dictionary)):D.caption,ce={text:typeof B?.cellTemplate=="function"?B.cellTemplate({value:D.caption,displayValue:Z,field:B})??null:String(Z??""),style:{textAlign:"left",fontWeight:D.isTotal?600:500,borderBottom:"1px solid var(--pivot-border)",borderRight:"1px solid var(--pivot-border)",color:"var(--pivot-text-header, inherit)",backgroundColor:"var(--pivot-surface-header)",cursor:B?"pointer":"context-menu",position:"relative",zIndex:1,padding:"4px 6px"},className:`kanuni-pivot-header-cell group ${D.isTotal?"kanuni-pivot-header-total":""}`};e.onCellPrepared?.({area:"column",cell:null,rowIndex:z,columnIndex:te,cellConfig:ce}),ce.style.fontWeight=D.isTotal?pivotgridCore.paintedFontWeight(ce.style.fontWeight,600,"--pivot-font-weight-header-total"):pivotgridCore.paintedFontWeight(ce.style.fontWeight,500,"--pivot-font-weight-header");let ne=U(ce.className,"th");ne.setAttribute("role","columnheader"),D.hasChildren&&ne.setAttribute("aria-expanded",String(!!D.isExpanded)),ne.colSpan=D.colSpan,ne.rowSpan=D.rowSpan,ee(ne,ce.style);let he=U("pivot-flex pivot-items-center");if(ee(he,{gap:4}),D.hasChildren){let le=U("kanuni-pivot-expand-icon","span");le.textContent=D.isExpanded?"\u2212":"+",le.setAttribute("aria-hidden","true"),le.setAttribute("data-col-expand",D.colPath??""),ee(le,{cursor:"pointer",marginRight:4,flexShrink:0}),he.appendChild(le);}let ve=U("select-none","span");Be(ve,ce.text),he.appendChild(ve);let pe=u.rowFields.find(le=>le.sortBySummaryField===D.fieldId&&(le.sortBySummaryPath||"")===(D.colPath||""));if(pe){let le=U("pivot-text-primary kanuni-pivot-sort-arrow","span");le.appendChild(_(pe.sortOrder==="asc"?"arrow-up":"arrow-down",12)),he.appendChild(le);}if(D.fieldId){let le=U(`kanuni-pivot-head-filter cursor-pointer transition-opacity ${q?"opacity-100 pivot-text-danger":"opacity-0 group-hover:opacity-70"}`,"span");le.setAttribute("data-filter-field",D.fieldId),le.appendChild(q?ze("filter",10):_("filter",10)),he.appendChild(le);}ne.appendChild(he),D.fieldId&&ne.setAttribute("data-header-field",D.fieldId),D.colPath!==void 0&&ne.setAttribute("data-header-col-path",D.colPath),ne.setAttribute("data-header-depth",String(z)),ne.appendChild(Xe(`leaf-${te}-${D.colSpan}`,a.data,D.colSpan,"right")),W.appendChild(ne);}F.appendChild(W);}tt(F,de);}function H(P,A,$,N){let X=A.flatRow,{rowFields:J,layout:ye,maxRowDepth:Y,virtualRows:fe}=u,{locale:K}=n(),de=ye.rowHeaderLayout==="tree",j=de?X.depth:N,v=X.pathValues[j],z=X.rowSpans[N]>0&&A.dfIndex===0,W=J[j],S=W&&v!==null&&v!==void 0?pivotgridCore.formatDimensionValue(v,W,"grid",K,pivotgridCore.blanksTextOf(n().dictionary)):v,D=j===X.depth,B=j<X.depth,q=D?X.hasChildren:B,te=D?X.isExpanded:B,Z=fe[$+1],Q=!de&&Z&&!Z.isGrandTotal&&Z.flatRow&&!Z.flatRow.isSubtotal&&(Z.flatRow.rowSpans[N]===0||Z.dfIndex>0)&&Z.flatRow.pathValues[N]===v,ce=pivotgridCore.rowHeaderGroupEnd(fe,$,N,de),ne=ye.rowHeaderGroupLines===true,he=S!=null?String(S):null;typeof W?.cellTemplate=="function"&&he!==null&&(he=W.cellTemplate({value:S,displayValue:S,field:W})??he);let ve={text:he,style:{position:"sticky",backgroundColor:"var(--pivot-surface)",zIndex:40,cursor:q?"pointer":"default",fontWeight:S&&j<X.depth?600:400,verticalAlign:"middle",padding:0,borderBottom:ne?ce?"1px solid var(--pivot-border)":"none":Q?"none":"1px solid var(--pivot-border)",height:d()},className:`kanuni-pivot-cell kanuni-pivot-row-header ${q?"kanuni-pivot-row-expandable":""}${e.shared?.focused?.r===$&&e.shared?.focused?.c===N?" kanuni-pivot-cell-focused":""}${Ge(e.shared?.selection??null,$,N)?" kanuni-pivot-cell-selected":""}`};e.onCellPrepared?.({area:"row",cell:null,rowIndex:$,columnIndex:N,cellConfig:ve}),S&&j<X.depth&&(ve.style.fontWeight=pivotgridCore.paintedFontWeight(ve.style.fontWeight,600,"--pivot-font-weight-group"));let pe=U(ve.className,"td");if(pe.id=i($,N),pe.setAttribute("role","rowheader"),q&&pe.setAttribute("aria-expanded",String(te)),pe.setAttribute("data-r",String($)),pe.setAttribute("data-c",String(N)),ce&&pe.setAttribute("data-group-end",""),ee(pe,ve.style),Pe(pe,`var(--row-header-left-${N}, 0px)`),!de&&N>=X.depth&&N<Y-1&&pe.style.setProperty("border-inline-end","none"),!z&&!de){ne||(pe.style.borderBottom="none"),pe.appendChild(Xe(`row-${N}`,a.rowHeader,1,n().rtl?"left":"right")),P.appendChild(pe);return}pe.setAttribute("data-group-start","");let le=de?X.depth*20:0,ge=U("");if(ee(ge,{display:"flex",alignItems:"center",gap:4,padding:"0 8px",height:"100%",position:"relative"}),ge.style.setProperty("padding-inline-start",`${8+le}px`),de&&X.depth>0){let ke=U("kanuni-pivot-tree-line");ee(ke,{position:"absolute",left:le,top:-d()/2,width:12,height:d(),borderLeft:"1px dotted var(--pivot-border)",borderBottom:"1px dotted var(--pivot-border)"}),ge.appendChild(ke);}if(ve.text!==null&&ve.text!==void 0){if(q){let we=U("kanuni-pivot-expand-icon","span");we.textContent=te?"\u2212":"+",we.setAttribute("aria-hidden","true"),ee(we,{flexShrink:0,position:"relative",zIndex:2}),ge.appendChild(we);}else {let we=U("","span");ee(we,{width:14,flexShrink:0}),ge.appendChild(we);}let ke=U("truncate","span");Be(ke,ve.text),ye.textOverflow==="clip"&&(typeof ve.text=="string"||typeof ve.text=="number")&&(ke.title=String(ve.text)),ge.appendChild(ke);}pe.appendChild(ge),pe.appendChild(Xe(`row-${N}`,a.rowHeader,1,n().rtl?"left":"right")),P.appendChild(pe);}function V(P,A,$,N,X){let{dataFields:J,leafColHashes:ye,dfsPerLeaf:Y,dataColOffset:fe,showDataInRows:K,totalDataCols:de}=u,j=de>Rt,v=e.registry?e.registry.getPluginsByType("cellRender"):null;ye.forEach((z,W)=>{let S=W*Y,D=K?[J[$]]:J,B=j&&(S+Y<=g.start||S>=g.end),q=B?null:Je(u,A,z.hash,N,z.isGrandTotal);D.forEach((te,Z)=>{let Q=S+Z,ce=fe+Q,ne=U("kanuni-pivot-cell","td");if(ne.id=i(X,ce),ne.setAttribute("role","gridcell"),ne.setAttribute("data-r",String(X)),ne.setAttribute("data-c",String(ce)),B||j&&(Q<g.start||Q>=g.end)){P.appendChild(ne);return}let he=q?.values[`${te.id}_display`]??q?.values[te.id],ve=y(he,te),pe=N||z.isGrandTotal||!!q?.isTotalCell,le=te.conditionalFormatting?pivotgridCore.resolveConditionalVisual(q?.values[te.id],te,q??null,u.fieldRanges[te.id]):$n,ge=le.style,ke=ve;if(typeof te.cellTemplate=="function")ke=te.cellTemplate({value:he,displayValue:ve,cell:q,field:te})??null;else if(v){for(let Le of v)if(Le.renderCell){let Ie=Le.renderCell(he,ve,q,te);if(Ie!=null){ke=Ie;break}}}let we={text:ke,style:{textAlign:te.dataType==="number"?"right":"left",fontWeight:pe?600:400,backgroundColor:pe?"var(--pivot-bg)":"transparent",cursor:e.hasCellClick?.()&&q?"pointer":"default",...ge},className:`kanuni-pivot-cell ${pe?"kanuni-pivot-cell-total":""}${e.shared?.focused?.r===X&&e.shared?.focused?.c===ce?" kanuni-pivot-cell-focused":""}${Ge(e.shared?.selection??null,X,ce)?" kanuni-pivot-cell-selected":""}`};if(e.onCellPrepared?.({area:"data",cell:q,rowIndex:X,columnIndex:ce,cellConfig:we}),pe&&(we.style.fontWeight=pivotgridCore.paintedFontWeight(we.style.fontWeight,600,"--pivot-font-weight-total")),we.style.backgroundColor==="transparent"&&(we.style.backgroundColor="var(--pivot-cell-bg, transparent)"),ne.className=we.className,ee(ne,we.style),ne.setAttribute("data-val",typeof he=="number"?String(he):""),Be(ne,we.text),le.dataBar){let Le=Math.round(le.dataBar.ratio*100);ne.style.setProperty("background-image",`linear-gradient(to ${n().rtl?"left":"right"}, ${le.dataBar.color} ${Le}%, transparent ${Le}%)`),ne.style.setProperty("background-repeat","no-repeat");}if(le.icon){let Le=_(le.icon,12);Le.style.setProperty("margin-inline-end","4px"),Le.style.setProperty("vertical-align","middle"),ne.insertBefore(Le,ne.firstChild);}P.appendChild(ne);});});}let G=(P,A)=>e.shared?.focused?.r===P&&e.shared?.focused?.c===A?" kanuni-pivot-cell-focused":"";function oe(P){let A=P.flatRow;return P.isGrandTotal||!A?{level:1}:A.isSubtotal||!A.hasChildren?{level:A.depth+1}:{level:A.depth+1,expanded:!!A.isExpanded}}function re(P,A){let{t:$}=n(),{maxRowDepth:N,showDataInRows:X,dataFields:J,layout:ye}=u,Y=U("kanuni-pivot-row","tr");if(Y.setAttribute("role","row"),Y.setAttribute("aria-rowindex",String(A+1)),ee(Y,{height:d()}),ye.rowHeaderLayout==="tree"){let K=oe(P);Y.setAttribute("aria-level",String(K.level)),K.expanded!==void 0&&Y.setAttribute("aria-expanded",String(K.expanded));}if(P.isGrandTotal){Y.classList.add("kanuni-pivot-grand-total-row");for(let K=0;K<N;K++){let de=K===0,j=U("kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total"+G(A,K),"td");j.id=i(A,K),j.setAttribute("role",de?"rowheader":"presentation"),ee(j,{position:"sticky",zIndex:40,fontWeight:"var(--pivot-font-weight-grand-total, 700)",backgroundColor:"var(--pivot-surface)",paddingLeft:de?8:0,paddingRight:0,borderRight:K===N-1?"1px solid var(--pivot-border)":"none",whiteSpace:de?"nowrap":"normal",overflow:de?"visible":"hidden"}),Pe(j,`var(--row-header-left-${K}, 0px)`),de&&(j.textContent=`${$("grandTotal")}${X?` \u2014 ${J[P.dfIndex]?.caption??""}`:""}`),Y.appendChild(j);}if(X){let K=U("kanuni-pivot-cell kanuni-pivot-cell-total"+G(A,N),"td");K.id=i(A,N),K.setAttribute("role","gridcell"),ee(K,{position:"sticky",zIndex:40,backgroundColor:"var(--pivot-surface)"}),Pe(K,`var(--row-header-left-${N}, 0px)`),K.textContent=String(J[P.dfIndex]?.caption??""),Y.appendChild(K);}return V(Y,"",P.dfIndex,true,A),Y}let fe=P.flatRow;if(fe.isSubtotal){Y.classList.add("kanuni-pivot-subtotal-row");let K=fe.pathValues[fe.depth],de=`${$("subTotal")}: ${pivotgridCore.isBlankMember(K)?pivotgridCore.blanksTextOf(n().dictionary):K}`;if(ye.rowHeaderLayout==="tree"){let j=U("kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total"+G(A,0),"td");j.id=i(A,0),j.setAttribute("role","rowheader"),ee(j,{position:"sticky",zIndex:40,fontWeight:"var(--pivot-font-weight-total, 600)",backgroundColor:"var(--pivot-surface)",paddingLeft:8+fe.depth*20}),Pe(j,"var(--row-header-left-0, 0px)"),j.textContent=de,Y.appendChild(j);}else for(let j=0;j<N;j++){if(j<fe.depth){H(Y,P,A,j);continue}let v=j===fe.depth,z=U("kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total"+G(A,j),"td");z.id=i(A,j),z.setAttribute("role",v?"rowheader":"presentation"),ee(z,{position:"sticky",zIndex:40,fontWeight:"var(--pivot-font-weight-total, 600)",backgroundColor:"var(--pivot-surface)",paddingLeft:v?8:0,paddingRight:0,borderRight:j===N-1?"1px solid var(--pivot-border)":"none",whiteSpace:v?"nowrap":"normal",overflow:v?"visible":"hidden"}),Pe(z,`var(--row-header-left-${j}, 0px)`),v&&(z.textContent=de),Y.appendChild(z);}if(X){let j=U("kanuni-pivot-cell kanuni-pivot-cell-total"+G(A,N),"td");j.id=i(A,N),j.setAttribute("role","gridcell"),ee(j,{position:"sticky",zIndex:40,backgroundColor:"var(--pivot-surface)"}),Pe(j,`var(--row-header-left-${N}, 0px)`),j.textContent=String(J[P.dfIndex]?.caption??""),Y.appendChild(j);}return V(Y,fe.key,P.dfIndex,true,A),Y}for(let K=0;K<N;K++)H(Y,P,A,K);if(X){let K=U("kanuni-pivot-cell kanuni-pivot-row-header"+G(A,N),"td");if(K.id=i(A,N),K.setAttribute("role","rowheader"),ee(K,{position:"sticky",zIndex:40,backgroundColor:"var(--pivot-surface)"}),Pe(K,`var(--row-header-left-${N}, 0px)`),P.isDataRow){let de=U("","span");ee(de,{color:"var(--pivot-text-muted)",paddingLeft:8}),de.textContent=String(J[P.dfIndex]?.caption??""),K.appendChild(de);}K.appendChild(Xe(`row-${N}`,nt,1,n().rtl?"left":"right")),Y.appendChild(K);}return V(Y,fe.key,P.dfIndex,false,A),Y}function ue(){if(b||!u)return;let P=f();if(x(),p=P,m.textContent="",P.start>0){let A=U("","tr");ee(A,{height:P.start*d()});let $=U("","td");$.colSpan=u.dataColOffset+Math.max(u.totalDataCols,1),ee($,{padding:0,border:"none"}),A.appendChild($),m.appendChild(A);}for(let A=P.start;A<P.end;A++)m.appendChild(re(u.virtualRows[A],A));ee(w,{height:C()+u.virtualRows.length*d()});}function Te(P){if(b)return;let A=n();A.locale!==h&&(h=A.locale,y=We(A.locale)),l=P.columnWidths??{},u=bt(P,{grandTotal:A.t("grandTotal"),subTotal:A.t("subTotal"),blanks:pivotgridCore.blanksTextOf(A.dictionary)}),s.setAttribute("role",u.layout.rowHeaderLayout==="tree"?"treegrid":"grid"),s.setAttribute("aria-rowcount",String(u.virtualRows.length+u.colHeaders.length+(e.chipDeps?1:0))),s.setAttribute("aria-colcount",String(u.dataColOffset+u.totalDataCols)),s.setAttribute("aria-label",A.t("pivotView"));let $=e.shared?.focused;$?s.setAttribute("aria-activedescendant",i($.r,$.c)):s.removeAttribute("aria-activedescendant");for(let N of k)s.style.removeProperty(N);k.clear(),L();for(let[N,X]of Object.entries(l)){if(!N.startsWith("leaf-"))continue;let J=`--col-width-data-${N.slice(5)}`;s.style.setProperty(J,`${X}px`),k.add(J);}O(),I(),p={start:-1,end:-1},ue();}let me=()=>{if(b||!u)return;let P=f(),A=g.start;x(),(P.start!==p.start||P.end!==p.end||g.start!==A)&&ue();};s.addEventListener("scroll",me,{passive:true});let Ce=()=>{if(b||!u)return;L();let P=f(),A=g.start,$=g.end;x(),(P.start!==p.start||P.end!==p.end||g.start!==A||g.end!==$)&&ue();},ie=typeof ResizeObserver<"u"?new ResizeObserver(()=>Ce()):null;return ie?.observe(s),{getVM:()=>u,getTheadHeight:C,paintStructural:Te,paintWindow:ue,refreshWindow:Ce,rowHeaderLayout(){let P=[];if(u){for(let A=0;A<u.maxRowDepth;A++)P.push(r(A));u.showDataInRows&&P.push(c());}return {configured:P,viewport:u&&R(P.length)?0:s.clientWidth}},scroller:s,destroy(){b=true,ie?.disconnect(),s.removeEventListener("scroll",me),s.remove();}}}var jn=0;function Ht(){let e=`kp${++jn}-`;return {lastResizeTime:0,isResizing:false,focused:null,selection:null,cellId:(t,n)=>`${e}pivot-cell-${t}-${n}`}}function It(e){let{scroller:t,controller:n,getVM:a,shared:d}=e,i=r=>r?.closest?.("td[data-r][data-c]")??null;function s(r,c){let o=d.focused;d.focused={r,c},o&&t.querySelector(`td[id="${d.cellId(o.r,o.c)}"]`)?.classList.remove("kanuni-pivot-cell-focused"),t.querySelector(`td[id="${d.cellId(r,c)}"]`)?.classList.add("kanuni-pivot-cell-focused"),t.setAttribute("aria-activedescendant",d.cellId(r,c));}function w(r,c,o){if(!e.onCellClick)return;let x=a();if(!x)return;let f=xt(x,c,o);if(!f)return;let E={event:r,cellType:f.isTotal?"grandTotal":"data",value:f.val,rowPath:f.cell.rowPath,colPath:f.cell.colPath};e.onCellClick(e.resolveCellClick?e.resolveCellClick(E):E);}let M=r=>{let c=r.target,o=c.closest("[data-col-expand]");if(o){n.toggleColExpanded(o.getAttribute("data-col-expand")??"");return}if(c.closest(".kanuni-pivot-resize-handle"))return;let x=c.closest("[data-filter-field]");if(x){e.onFilterClick?.(r.clientX,r.clientY,x.getAttribute("data-filter-field")??"");return}let f=c.closest("th[data-header-field]");if(f){if(Date.now()-d.lastResizeTime<100)return;let I=a();if(!I)return;let H=f.getAttribute("data-header-field")??"",V=f.getAttribute("data-header-col-path")??"",G=I.rowFields.find(oe=>oe.sortBySummaryField===H&&(oe.sortBySummaryPath||"")===V);G&&n.sortField(G.id,G.sortOrder==="asc"?"desc":"asc");return}let E=i(c);if(!E)return;let R=Number(E.getAttribute("data-r")),L=Number(E.getAttribute("data-c")),O=a();if(O){if(t.focus({preventScroll:true}),s(R,L),L<O.dataColOffset){if(Date.now()-d.lastResizeTime<100)return;let I=Qe(O,R,L);I?.hasChildren&&n.toggleExpanded(I.cellHashStr);return}w(r,R,L);}},T=r=>{if(r.target.closest?.(".kanuni-pivot-resize-handle"))return;let c=i(r.target);if(!c)return;let o=Number(c.getAttribute("data-r")),x=Number(c.getAttribute("data-c")),f=a();!f||x<f.dataColOffset||w(r,o,x);},F=r=>{let c=r.target.closest?.("th[data-header-field]");if(c){r.preventDefault(),c.hasAttribute("aria-expanded")?e.onNodeContextMenu?.({x:r.clientX,y:r.clientY,path:c.getAttribute("data-header-col-path")??"",isExpanded:c.getAttribute("aria-expanded")==="true",depth:Number(c.getAttribute("data-header-depth")??0),type:"col"}):e.onHeaderContextMenu&&e.onHeaderContextMenu(r.clientX,r.clientY,c.getAttribute("data-header-field")??"",c.getAttribute("data-header-col-path")??void 0);return}let o=i(r.target);if(!o)return;let x=Number(o.getAttribute("data-r")),f=Number(o.getAttribute("data-c")),E=a();if(E){if(f<E.dataColOffset){let R=Qe(E,x,f);if(R){let{flatRow:L,hasChildren:O,cellHashStr:I,isExpanded:H,depth:V,dIdx:G}=R,oe=E.layout.rowHeaderLayout==="tree",re=G>L.depth,ue=re?L.hasChildren:O;if(ue&&e.onNodeContextMenu){r.preventDefault(),e.onNodeContextMenu({x:r.clientX,y:r.clientY,path:re?oe?L.key:pivotgridCore.pathKey(L.pathValues.slice(0,L.depth+1)):I,isExpanded:re?L.isExpanded:H,depth:re?L.depth:V,type:"row"});return}if(ue)return}}e.onGlobalContextMenu&&(r.preventDefault(),e.onGlobalContextMenu(r.clientX,r.clientY));}},m=e.keyboardEnabled!==false;function u(){let r=d.focused;d.focused=null,r&&t.querySelector(`td[id="${d.cellId(r.r,r.c)}"]`)?.classList.remove("kanuni-pivot-cell-focused"),t.removeAttribute("aria-activedescendant");}let y=new Set(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),h=r=>{if(r.target!==t)return;let c=a();if(!c)return;if(!d.focused){if(!y.has(r.key)||c.virtualRows.length===0)return;r.preventDefault(),s(0,0),(r.shiftKey||!(r.ctrlKey||r.metaKey))&&d.selectByKey?.(0,0,false,{r:0,c:0});return}let{r:o,c:x}=d.focused,f={r:o,c:x},E=r.ctrlKey||r.metaKey,R=c.dataColOffset+c.totalDataCols,L=e.rowHeight?.()??28,O=e.getTheadHeight?.()??c.colHeaders.length*L,I=Math.max(1,Math.ceil(((t.clientHeight||600)-O)/L));switch(r.key){case "ArrowDown":r.preventDefault(),o=Math.min(c.virtualRows.length-1,o+1);break;case "ArrowUp":r.preventDefault(),o=Math.max(0,o-1);break;case "ArrowRight":r.preventDefault(),x=Math.min(R-1,x+1);break;case "ArrowLeft":r.preventDefault(),x=Math.max(0,x-1);break;case "Home":r.preventDefault(),(r.ctrlKey||r.metaKey)&&(o=0),x=0;break;case "End":r.preventDefault(),(r.ctrlKey||r.metaKey)&&(o=c.virtualRows.length-1),x=R-1;break;case "PageDown":r.preventDefault(),o=Math.min(c.virtualRows.length-1,o+I-1);break;case "PageUp":r.preventDefault(),o=Math.max(0,o-I+1);break;case "Escape":r.preventDefault(),u();return;case " ":case "Enter":{r.preventDefault(),r.key===" "&&d.selectByKey?.(o,x,r.shiftKey,f);let G=t.querySelector(`td[id="${d.cellId(o,x)}"]`);G&&(r.key===" "?G.click():G.dispatchEvent(new MouseEvent("dblclick",{bubbles:true})));return}default:return}let H=O+o*L,V=t.clientHeight||600;H<t.scrollTop+O?(t.scrollTop=H-O,t.dispatchEvent(new Event("scroll"))):H+L>t.scrollTop+V&&(t.scrollTop=H+L-V,t.dispatchEvent(new Event("scroll"))),s(o,x),(r.shiftKey||!E)&&d.selectByKey?.(o,x,r.shiftKey,f),x>=c.dataColOffset&&p(o,x,c.dataColOffset);};function p(r,c,o){let x=t.querySelector(`td[id="${d.cellId(r,c)}"]`)??t.querySelector(`td[data-c="${c}"]`);if(!x)return;let f=t.getBoundingClientRect(),E=getComputedStyle(t).direction==="rtl",R=t.querySelector(`td[data-c="${o-1}"]`)?.getBoundingClientRect(),L=x.getBoundingClientRect(),O=E?f.right-t.clientWidth:f.left,I=E?O:R?R.right:O,H=E&&R?R.left:O+t.clientWidth,V=0;L.left<I?V=L.left-I:L.right>H&&(V=Math.min(L.right-H,L.left-I)),V!==0&&(t.scrollLeft+=V,t.dispatchEvent(new Event("scroll")));}let g=r=>{if(r.button!==0)return;let c=i(r.target);if(!c)return;let o=Number(c.getAttribute("data-r")),x=Number(c.getAttribute("data-c"));d.focused?.r===o&&d.focused.c===x||s(o,x);},l=false,k=()=>{l=true,setTimeout(()=>{l=false;},0);},b=r=>{let c=a();c&&!d.focused&&!l&&r.target===t&&c.virtualRows.length>0&&s(0,0);},C=r=>{r.relatedTarget&&t.contains(r.relatedTarget)||u();};return t.addEventListener("mousedown",k,true),t.addEventListener("pointerdown",k,true),t.addEventListener("click",M),m&&t.addEventListener("mouseup",g),t.addEventListener("dblclick",T),t.addEventListener("contextmenu",F),m?(t.addEventListener("keydown",h),t.addEventListener("focus",b),t.addEventListener("blur",C)):t.removeAttribute("tabindex"),{destroy(){t.removeEventListener("click",M),t.removeEventListener("mouseup",g),t.removeEventListener("dblclick",T),t.removeEventListener("contextmenu",F),t.removeEventListener("mousedown",k,true),t.removeEventListener("pointerdown",k,true),m&&(t.removeEventListener("keydown",h),t.removeEventListener("focus",b),t.removeEventListener("blur",C));}}}function Ot(e){let{host:t,scroller:n,shared:a}=e,d=document.createElement("div");d.className="kanuni-pivot-drag-line",Object.assign(d.style,{position:"absolute",top:"0",bottom:"0",left:"0",width:"2px",backgroundColor:"var(--pivot-primary)",zIndex:"100",display:"none",pointerEvents:"none"}),t.appendChild(d);let i=null,s=1,w=0,M=1,T=0,F=[],m={},u=null,y=-1,h=b=>{d.style.display="block",d.style.transform=`translateX(${pivotgridCore.resizeLineX(b,t)}px)`;},p=b=>{a.isResizing&&h(b.clientX);},g=b=>{if(!a.isResizing||!i)return;d.style.display="none";let C=(b.clientX-w)/M,r=e.isRtl()?-C:C;if(i.startsWith("row-")){let c=Math.max(20,T+r);m[i]=u?pivotgridCore.invertRowHeaderWidth(u.configured,y,c,u.viewport):c;}else if(i.startsWith("leaf-")){let c=i.split("-"),o=parseInt(c[1],10),f=Math.max(s*20,T+r)/T;for(let E=0;E<s;E++)m[`leaf-${o+E}`]=Math.max(20,F[E]*f);}a.isResizing=false,a.lastResizeTime=Date.now(),i=null,document.body.style.cursor="",document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",g),e.commit({...m});},l=b=>{let C=b.target.closest?.(".kanuni-pivot-resize-handle");if(!C||(b.preventDefault(),b.stopPropagation(),i=C.getAttribute("data-resize-id"),!i))return;let r=Number(C.getAttribute("data-resize-default")||150);if(s=Number(C.getAttribute("data-resize-span")||1),w=b.clientX,M=pivotgridCore.cssZoomOf(t),m={...e.getWidths()},i.startsWith("row-"))y=parseInt(i.slice(4),10),u=e.rowHeaderLayout(),T=pivotgridCore.computeRowHeaderWidths(u.configured,u.viewport).widths[y]??m[i]??r;else if(i.startsWith("leaf-")){let c=parseInt(i.split("-")[1],10);F=[],T=0;for(let o=0;o<s;o++){let x=m[`leaf-${c+o}`]||r;F.push(x),T+=x;}}a.isResizing=true,h(b.clientX),document.body.style.cursor="col-resize",document.addEventListener("mousemove",p),document.addEventListener("mouseup",g);},k=b=>{let C=b.target.closest?.(".kanuni-pivot-resize-handle"),r=C?.getAttribute("data-resize-id");if(!C||!r||a.isResizing)return;b.preventDefault(),b.stopPropagation();let c={...e.getWidths()},o=C.closest("th,td");if(r.startsWith("row-")){let x=r.slice(4),f=pivotgridCore.measureFitWidth(Array.from(n.querySelectorAll(`td[data-c="${x}"], th[data-row-header-idx="${x}"]`)),t);if(!f)return;let E=e.rowHeaderLayout();c[r]=pivotgridCore.invertRowHeaderWidth(E.configured,parseInt(x,10),Math.max(pivotgridCore.ROW_HEADER_MIN_COL_WIDTH,f),E.viewport);}else if(r.startsWith("leaf-")){let x=Number(C.getAttribute("data-resize-span")||1),f=parseInt(r.split("-")[1],10),E=e.dataColOffset?.()??0,R=[];for(let I=0;I<x;I++){let H=Array.from(n.querySelectorAll(`td[data-c="${E+f+I}"]`));x===1&&o&&H.unshift(o);let V=pivotgridCore.measureFitWidth(H,t);R.push(V?Math.max(20,V):c[`leaf-${f+I}`]||Number(C.getAttribute("data-resize-default")||95));}let L=R.reduce((I,H)=>I+H,0),O=x>1&&o?pivotgridCore.measureFitWidth([o],t):0;O>L&&(R=R.map(I=>I*O/L)),R.forEach((I,H)=>{c[`leaf-${f+H}`]=I;});}else return;a.lastResizeTime=Date.now(),e.commit(c);};return n.addEventListener("mousedown",l),n.addEventListener("dblclick",k),{destroy(){n.removeEventListener("mousedown",l),n.removeEventListener("dblclick",k),a.isResizing&&(a.isResizing=false,document.body.style.cursor=""),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",g),d.remove();}}}function zt(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Oe(e){let t=zt("kanuni-pivot-root kanuni-pivot-portal-container");Bt(t,e);let n=rt.get(e);return n||rt.set(e,n=new Set),n.add(t),t}var rt=new WeakMap,Vt=new WeakMap;function Bt(e,t){for(let i of Vt.get(e)??[])e.classList.remove(i);let n=Array.from(t.classList).filter(i=>i.startsWith("kanuni-pivot-")&&i!=="kanuni-pivot-root");for(let i of n)e.classList.add(i);Vt.set(e,n);let a=e.style.getPropertyValue("zoom");e.setAttribute("style",t.getAttribute("style")??"");for(let i of ["position","inset","z-index","width","height"])e.style.removeProperty(i);a&&e.style.setProperty("zoom",a);let d=t.getAttribute("data-theme");d?e.setAttribute("data-theme",d):e.removeAttribute("data-theme"),e.setAttribute("dir",t.getAttribute("dir")??"ltr");}function $t(e){let t=rt.get(e);if(t)for(let n of Array.from(t)){if(!n.isConnected){t.delete(n);continue}Bt(n,e);}}function Ve(e){e.style.removeProperty("zoom");let t=pivotgridCore.cssZoomOf(e);Math.abs(t-1)>.01&&e.style.setProperty("zoom",String(1/t));}function $e(){let e=document,t=e.fullscreenElement??e.webkitFullscreenElement??null;return t||(document.querySelector(".pivot-is-fullscreen")??document.body)}function it(e){let t=null,n=null;function a(){n?.(),n=null,t?.remove(),t=null;}function d(i){a(),t=Oe(e);let s=zt("kanuni-pivot-portal-root");t.appendChild(s),$e().appendChild(t),Ve(t);let w=i(s),M=t,T=m=>{M.contains(m.target)||a();},F=m=>{m.key==="Escape"&&a();};return document.addEventListener("pointerdown",T,true),document.addEventListener("keydown",F,true),n=()=>{document.removeEventListener("pointerdown",T,true),document.removeEventListener("keydown",F,true),w?.();},s}return {openPopup:d,closePopup:a,isOpen:()=>t!==null,destroy:a}}var Wt=new Map;function Gt(e,t,n,a){return pivotgridCore.formatHeaderFilterLabel(e,t,n,a)}var Re=28;function Ee(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}var po="M11 11l3.5 3.5M12.5 7a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z";function uo(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("class","kanuni-pivot-popup-search-icon"),e.setAttribute("width","14"),e.setAttribute("height","14"),e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("fill","none");let t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d",po),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.5"),t.setAttribute("stroke-linecap","round"),e.appendChild(t),e}function jt(e){let{portal:t}=e;function n(a,d,i){let s=e.getField(i);if(!s)return;let{t:w,rtl:M,locale:T,dictionary:F,defaultBlanks:m}=e.getI18n(),u=pivotgridCore.blanksTextOf(F),y=true,h=[],p=[],g="",l=new Set,k=0,b=220,C=false,r=[];t.openPopup(c=>{let o=Ee("kanuni-pivot-popup pivot-animate-zoom-in"),x=pivotgridCore.popupViewport(),f=pivotgridCore.filterPopupBox({x:a,y:d},e.gridId,s.id,x),E=pivotgridCore.filterPopupLimits(f);o.setAttribute("role","dialog"),o.setAttribute("aria-label",w("columnFilter")),o.setAttribute("data-datagrid-keyboard-scope","modal"),o.tabIndex=-1,Object.assign(o.style,{left:`${f.left}px`,top:`${f.top}px`,width:`${f.width}px`,height:`${f.height}px`,minWidth:"200px",minHeight:`${f.minHeight}px`,maxWidth:E.maxWidth,maxHeight:E.maxHeight,resize:"both",direction:M?"rtl":"ltr"});let R=Ee("kanuni-pivot-popup-header"),L=Ee("kanuni-pivot-popup-search"),O=e.showSearch?e.showSearch()!==false:true;L.appendChild(uo());let I=Ee("kanuni-pivot-popup-search-input","input");I.type="text",I.placeholder=w("search"),I.setAttribute("aria-controls","pivot-filter-options"),L.appendChild(I),O&&R.appendChild(L);let H=Ee("kanuni-pivot-popup-actions"),V=Ee("kanuni-pivot-popup-action-btn kanuni-pivot-popup-action-btn--primary","button");V.textContent=w("selectAll");let G=Ee("kanuni-pivot-popup-action-btn kanuni-pivot-popup-action-btn--danger","button");G.textContent=w("clearAll"),H.append(V,G),R.appendChild(H);let oe=Ee("kanuni-pivot-popup-list pivot-custom-scrollbar");oe.id="pivot-filter-options";let re=Ee("");re.style.position="relative",oe.appendChild(re);let ue=Ee("kanuni-pivot-popup-footer"),Te=Ee("kanuni-pivot-btn kanuni-pivot-btn--outline","button");Te.textContent=w("cancel");let me=Ee("kanuni-pivot-btn kanuni-pivot-btn--primary","button");me.textContent=w("ok");for(let S of [Te,me])Object.assign(S.style,{height:"28px",padding:"0 12px",fontSize:"12px"});if(ue.append(Te,me),e.openCondition&&(s.area==="row"||s.area==="column")){let S=Ee("kanuni-pivot-btn kanuni-pivot-btn--outline","button");S.type="button",S.setAttribute("data-condition-filter",""),S.title=w("conditionFilter")+"\u2026",S.setAttribute("aria-label",S.title),Object.assign(S.style,{height:"28px",padding:"0 7px",marginInlineEnd:"auto"}),(s.valueFilter||s.labelFilter)&&(S.style.color="var(--pivot-danger)"),S.appendChild(_("settings-2",14)),S.addEventListener("click",()=>{t.closePopup(),e.openCondition(s.id);}),ue.prepend(S);}o.append(R,oe,ue),c.appendChild(o);let Ce=()=>{if(!g)return p;let S=g.toLowerCase(),D=S.replace(/,/g,"."),B=S.replace(/\./g,","),q=S.replace(/[.,\s]/g,"");return p.filter(te=>{let Z=te.label.toLowerCase(),Q=Z.replace(/[.,\s]/g,"");return Z.includes(S)||Z.includes(D)||Z.includes(B)||!!q&&Q.includes(q)})},ie=()=>l.size===h.length,P=()=>!g,A=()=>Ce().length+(P()?1:0),$=()=>A()===0?-1:Math.min(k,A()-1),N=S=>{if(P()&&S===0)return "select-all";let D=P()?S-1:S;return `value:${Ce()[D]?.key}`},X=new Map;function J(){if(C)return;let S=document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains("kanuni-pivot-popup-item");if(me.disabled=!y&&h.length>0&&l.size===0,re.textContent="",X.clear(),y){re.style.height="";let Q=Ee("pivot-flex pivot-items-center pivot-justify-center pivot-h-full"),ce=Ee("");Object.assign(ce.style,{width:"24px",height:"24px",border:"2px solid var(--pivot-border)",borderTopColor:"var(--pivot-primary)",borderRadius:"50%",animation:"spin 1s linear infinite"}),Q.appendChild(ce),re.appendChild(Q);return}let D=Ce(),B=A();re.style.height=`${B*Re}px`;let q=Math.max(0,Math.floor(oe.scrollTop/Re)-2),te=Math.min(B,q+Math.ceil(b/Re)+4),Z=$();for(let Q=q;Q<te;Q++){let ce,ne,he,ve,pe,le=false;if(P()&&Q===0)ce="select-all",ne=`(${w("selectAll")})`,he=ie(),ve=true,pe=Y;else {let Le=D[P()?Q-1:Q];if(!Le)continue;let Ie=pivotgridCore.headerFilterGroupTick(Le,l);ce=`value:${Le.key}`,ne=Le.label,he=Ie==="all",le=Ie==="some",ve=false,pe=()=>fe(Le);}let ge=Ee(`kanuni-pivot-popup-item${he?" kanuni-pivot-popup-item--checked":""}${Q===Z?" kanuni-pivot-popup-item--active":""}`);ge.id=ce,ge.setAttribute("role","checkbox"),ge.setAttribute("aria-checked",le?"mixed":String(he)),ne===""&&ge.setAttribute("aria-label",m),ge.tabIndex=0,Object.assign(ge.style,{position:"absolute",top:`${Q*Re}px`,insetInlineStart:"0",insetInlineEnd:"0",height:`${Re}px`,fontWeight:ve?"600":"400"});let ke=Ee("kanuni-pivot-checkbox","input");ke.type="checkbox",ke.checked=he,ke.indeterminate=le,ke.readOnly=true,ke.tabIndex=-1;let we=Ee("pivot-truncate","span");we.textContent=ne,ge.append(ke,we),ge.addEventListener("click",pe),ge.addEventListener("focus",()=>{k=Q;}),re.appendChild(ge),X.set(Q,ge);}if(D.length===0){let Q=Ee("");Object.assign(Q.style,{padding:"12px",textAlign:"center",fontSize:"12px",color:"var(--pivot-text-muted)"}),Q.textContent=w("noItems"),re.appendChild(Q);}O&&I.setAttribute("aria-activedescendant",Z>=0?N(Z):""),S&&X.get(Z)?.focus();}function ye(S){l=pivotgridCore.setHeaderFilterGroups(l,Ce(),S),J();}function Y(){ye(!Ce().every(S=>pivotgridCore.headerFilterGroupTick(S,l)==="all"));}function fe(S){l=pivotgridCore.toggleHeaderFilterGroup(l,S),J();}function K(){if(me.disabled)return;let S=pivotgridCore.headerFilterWrite(h,l,s);S.kind==="clear"?e.clear(s.id):S.kind==="apply"&&e.apply(s.id,S.values,S.filterType),t.closePopup();}function de(S){k=Math.max(0,Math.min(A()-1,S));let D=k*Re;D<oe.scrollTop?oe.scrollTop=D:D+Re>oe.scrollTop+b&&(oe.scrollTop=D+Re-b),J(),X.get(k)?.focus();}let j=S=>{if(S.key==="ArrowDown"||S.key==="ArrowUp"){if(S.preventDefault(),A()===0)return;de($()+(S.key==="ArrowDown"?1:-1));return}if(S.key==="Home"&&A()>0){S.preventDefault(),de(0);return}if(S.key==="End"&&A()>0){S.preventDefault(),de(A()-1);return}if(O&&S.key==="Backspace"&&S.target!==I){S.preventDefault(),I.focus(),g=g.slice(0,-1),I.value=g,k=0,J();return}if(S.key===" "||S.code==="Space"){if(S.target===I)return;S.preventDefault();let D=$();if(A()>0&&D>=0)if(P()&&D===0)Y();else {let B=Ce()[P()?D-1:D];B&&fe(B);}return}if(S.key==="Enter"){S.preventDefault(),K();return}if(S.key==="Escape"){S.stopPropagation(),t.closePopup();return}O&&S.key.length===1&&!S.ctrlKey&&!S.metaKey&&!S.altKey&&S.target!==I&&(S.preventDefault(),I.focus(),g+=S.key,I.value=g,k=0,J());},v=S=>{j(S),S.defaultPrevented&&S.stopPropagation();};document.addEventListener("keydown",v,true),o.addEventListener("click",S=>S.stopPropagation()),I.addEventListener("input",()=>{g=I.value,k=0,J();}),V.addEventListener("click",Y),G.addEventListener("click",()=>ye(false)),Te.addEventListener("click",()=>t.closePopup()),me.addEventListener("click",K),oe.addEventListener("scroll",()=>{Wt.set(s.id,oe.scrollTop),J();});let z=typeof ResizeObserver<"u"?new ResizeObserver(S=>{for(let D of S)b=D.contentRect.height;J();}):null;z?.observe(oe);let W=typeof ResizeObserver<"u"?new ResizeObserver(()=>{let S=parseFloat(o.style.width),D=parseFloat(o.style.height);S===f.width&&D===f.height||pivotgridCore.rememberFilterPopupSize(e.gridId,s.id,S,D);}):null;return W?.observe(o),J(),O?I.focus():o.focus(),r.push(setTimeout(()=>{if(C)return;if(!s.dataField&&!s.isCalculated){h=[],y=false,J();return}let S=pivotgridCore.getFieldDistinctValues(s.id,e.gridId);if(S)h=S.map(B=>({rawStr:B.rawStr==="null"||B.rawStr==="undefined"?pivotgridCore.BLANK_MEMBER:B.rawStr,rawVal:B.rawVal,label:Gt(B.rawVal,s,T,u)}));else {let B=new Map,q=e.getData();for(let Z=0;Z<q.length;Z++){let Q=pivotgridCore.extractGroupValue(q[Z],s);if(Q==="(Blank)"&&s.calculateSummaryExpression)continue;let ce=Q==null?pivotgridCore.BLANK_MEMBER:String(Q);B.has(ce)||B.set(ce,Q);}let te=Array.from(B.values());if(s.dataType==="number")te.sort((Z,Q)=>Number(Z)-Number(Q));else {let Z=pivotgridCore.collatorFor().compare;te.sort((Q,ce)=>Z(String(Q),String(ce)));}h=te.map(Z=>({rawStr:Z==null?pivotgridCore.BLANK_MEMBER:String(Z),rawVal:Z,label:Gt(Z,s,T,u)}));}p=pivotgridCore.groupHeaderFilterOptions(h),l=pivotgridCore.headerFilterShown(h,s),y=false,J();let D=Wt.get(s.id)||0;D>0&&r.push(setTimeout(()=>{C||(oe.scrollTop=D,J());},50)),r.push(setTimeout(()=>{C||I.focus();},50));},10)),()=>{C=true,document.removeEventListener("keydown",v,true);for(let S of r)clearTimeout(S);z?.disconnect(),W?.disconnect();}});}return {open:n,close:()=>t.closePopup()}}function Me(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function qt(e){let t=Me("kanuni-pivot-footer pivot-flex pivot-items-center pivot-justify-start");Object.assign(t.style,{padding:"4px 8px",backgroundColor:"color-mix(in srgb, var(--pivot-surface-header) 50%, var(--pivot-surface))",borderTop:"1px solid var(--pivot-border)",gap:"4px",flex:"0 0 auto"}),e.host.appendChild(t);let n=null,a=null,d=null,i=null;function s(){n=null,a?.remove(),a=null,d?.classList.remove("kanuni-pivot-footer-btn--active"),d=null;}let w=b=>{e.onGlobalContextMenu&&(b.preventDefault(),e.onGlobalContextMenu(b.clientX,b.clientY));};t.addEventListener("contextmenu",w);let M=b=>{!n||b.target?.closest?.("[data-footer-menu]")?.getAttribute("data-footer-menu")===n||s();};document.addEventListener("mousedown",M);let T=Me("kanuni-pivot-search","input");T.type="search";let F,m=()=>{clearTimeout(F),e.onSearch?.(T.value);};T.addEventListener("input",()=>{clearTimeout(F),F=setTimeout(m,250);}),T.addEventListener("keydown",b=>{b.stopPropagation(),b.key==="Enter"?m():b.key==="Escape"&&(T.value="",m());});function u(b,C,r=false){let c=Me(`kanuni-pivot-footer-btn${r?" kanuni-pivot-footer-btn--active":""}`,"button");return c.title=C,c.setAttribute("aria-label",C),c.type="button",c.appendChild(_(b,15)),c}let y=()=>Me("kanuni-pivot-footer-divider");function h(b,C,r,c,o,x={}){let f=Me("kanuni-pivot-dropdown-item pivot-flex","button");f.type="button",f.style.gap="12px",x.locked&&(f.style.opacity="0.6",f.style.cursor=x.canUpgrade?"pointer":"not-allowed",x.canUpgrade||(f.disabled=true),x.hint&&(f.title=x.hint)),f.appendChild(_(b,16,C));let E=Me(""),R=Me("pivot-font-medium pivot-flex pivot-items-center");if(R.style.gap="6px",R.appendChild(document.createTextNode(r)),x.locked&&x.badge){let L=Me("","span");Object.assign(L.style,{fontSize:"9px",fontWeight:"700",textTransform:"uppercase",letterSpacing:"0.04em",padding:"1px 5px",borderRadius:"9999px",backgroundColor:"color-mix(in srgb, var(--pivot-warning) 18%, transparent)",color:"var(--pivot-warning)"}),L.textContent=x.badge,R.appendChild(L);}if(E.appendChild(R),c!==null){let L=Me("pivot-text-xs pivot-text-muted");L.textContent=c,E.appendChild(L);}return f.appendChild(E),o&&f.addEventListener("click",o),f}function p(b,C=false){let r=Me("kanuni-pivot-report-section-title");return C&&(r.style.marginTop="4px",r.style.borderTop="1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"),r.textContent=b,r}function g(){let b=Me("kanuni-pivot-dropdown-menu pivot-animate-slide-up pivot-custom-scrollbar");return Object.assign(b.style,{bottom:"100%",left:"0",marginBottom:"4px",width:"256px",maxHeight:"384px",overflowY:"auto"}),b}function l(b){n=null,i&&k(i),e.onExport(b);}function k(b){i=b;let{t:C,locale:r}=e.getI18n(),c=e.toolbar??{},o=document.activeElement===T;if(t.textContent="",a=null,d=null,c.showSaveReport!==false&&e.mountReportMenu){let f=Me("pivot-relative");e.mountReportMenu(f),f.childNodes.length>0&&(t.appendChild(f),t.appendChild(y()));}if(c.showFieldChooserToggle!==false){let f=u("settings",C("showFieldList"),e.fieldChooserOpen());f.addEventListener("click",e.onToggleFieldChooser),t.appendChild(f);}if(e.onOpenPrefilter){let f=u("filter",C("filterBuilder"));f.addEventListener("click",e.onOpenPrefilter),t.appendChild(f);}if(e.onToggleChart){let f=u("bar-chart",C("chartToggle"));f.addEventListener("click",e.onToggleChart),t.appendChild(f);}if(c.showCalculatedFields!==false&&e.onAddCalculatedField){let f=u("calculator",C("calculatedMeasureDesigner"));f.addEventListener("click",e.onAddCalculatedField),t.appendChild(f);}if(t.appendChild(y()),c.showExpandCollapseAll!==false){let f=u("maximize2",C("expandAll"));f.addEventListener("click",e.onExpandAll);let E=u("minimize2",C("collapseAll"));E.addEventListener("click",e.onCollapseAll),t.append(f,E);}if(c.showRefreshButton!==false&&e.onRefresh){t.appendChild(y());let f=u("refresh-cw",C("refreshData"));f.addEventListener("click",e.onRefresh),t.appendChild(f);}if(c.showFullscreenToggle!==false&&e.onToggleFullscreen){t.appendChild(y());let f=e.isFullscreen(),E=u(f?"shrink":"fullscreen",C(f?"exitFullscreen":"enterFullscreen"),f);f&&Object.assign(E.style,{backgroundColor:"color-mix(in srgb, var(--pivot-primary) 10%, transparent)",color:"var(--pivot-primary)",border:"1px solid color-mix(in srgb, var(--pivot-primary) 30%, transparent)"}),E.addEventListener("click",e.onToggleFullscreen),t.appendChild(E);}if(t.appendChild(y()),c.showExportButton!==false){let f=Me("pivot-relative");f.setAttribute("data-footer-menu","export");let E=u("download",C("export"),n==="export");if(E.addEventListener("click",()=>{n=n==="export"?null:"export",k(b);}),f.appendChild(E),n==="export"){let R=g(),L=H=>{let V=!e.advancedExport;return {locked:V,canUpgrade:V&&!!e.upgradeUrl,badge:C("enterpriseBadge"),hint:V&&e.upgradeUrl?C("enterpriseUpgradeHint"):void 0}},O=(H,V)=>{if(!(!e.advancedExport))return ()=>l(H);if(e.upgradeUrl)return ()=>{n=null,k(b),window.open(e.upgradeUrl,"_blank","noopener,noreferrer");}},I=e.registry?.getPluginsByType("exporter")??[];if(I.length>0){R.appendChild(p(C("customExports")));for(let H of I)R.appendChild(h("database","var(--pivot-primary)",`${H.id.replace("exporter-","").toUpperCase()} ${C("export")}`,C("customPlugin"),()=>l(H.id)));R.appendChild(Me("kanuni-pivot-dropdown-divider"));}R.appendChild(p(C("excelExport"))),R.appendChild(h("file-spreadsheet","var(--pivot-success)",C("pivotView"),C("preservesGridLayout"),O("excel-pivot"),L())),R.appendChild(h("file-spreadsheet","var(--pivot-success)",C("listView"),C("rawFlatData"),O("excel-list"),L())),R.appendChild(p(C("document"),true)),R.appendChild(h("file-text","var(--pivot-danger)",C("pdfDocument"),C("printReadyLayout"),O("pdf"),L())),R.appendChild(h("printer","var(--pivot-info)",C("print"),C("sendToPrinter"),()=>l("print"))),R.appendChild(h("copy","var(--pivot-primary)",C("copyToClipboard"),C("tabSeparatedValues"),()=>l("clipboard"))),R.appendChild(h("file-json","var(--pivot-success)",C("fullSnapshot"),C("saveSessionState"),()=>l("json-snapshot"))),R.appendChild(p(C("rawDataFormats"),true)),R.appendChild(h("file","var(--pivot-info)","CSV",null,()=>l("csv"))),R.appendChild(h("file-json","var(--pivot-warning)","JSON (Tree)",null,()=>l("json-pivot"))),R.appendChild(h("file-json","var(--pivot-warning)","JSON (List)",null,()=>l("json"))),R.appendChild(h("database","var(--pivot-text-muted)","XML",null,()=>l("xml"))),f.appendChild(R),a=R,d=E;}t.appendChild(f);}if(e.onSearch){let f=C("search").replace(/[.\u2026]+$/,"");T.placeholder=C("search"),T.setAttribute("aria-label",f),t.appendChild(y()),t.appendChild(T),o&&T.focus();}let x=b.selectionStats;if(x){let f=new Intl.NumberFormat(r,{minimumFractionDigits:2,maximumFractionDigits:2}),E=Me("kanuni-pivot-selection-stats pivot-text-muted pivot-font-medium pivot-flex pivot-items-center");Object.assign(E.style,{marginLeft:"auto",fontSize:"11px",gap:"8px",paddingRight:"8px",userSelect:"none"});let R=[[C("count"),String(x.count)],[C("sum"),f.format(x.sum)],[C("avg"),f.format(x.avg)],[C("min"),f.format(x.min)],[C("max"),f.format(x.max)]];for(let[L,O]of R){let I=Me("","span");I.textContent=`(${L}: ${O})`,E.appendChild(I);}t.appendChild(E);}}return {element:t,paint:k,syncSearch(b){document.activeElement!==T&&(T.value=b);},destroy(){clearTimeout(F),t.removeEventListener("contextmenu",w),document.removeEventListener("mousedown",M),t.remove();}}}var Kt=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];function _t(e,t){let n=false,a=()=>{let M=document;return M.fullscreenElement??M.webkitFullscreenElement??M.mozFullScreenElement??M.msFullscreenElement??null},d=()=>n||a()===e;function i(M){if(n=M,e.classList.toggle("pivot-is-fullscreen",M),M)Object.assign(e.style,{position:"fixed",inset:"0",zIndex:"9990",width:"auto",height:"auto"});else for(let T of ["position","inset","z-index","width","height"])e.style.removeProperty(T);}let s=()=>{let M=d();e.classList.toggle("pivot-is-fullscreen",a()===e||n),t(M);};for(let M of Kt)document.addEventListener(M,s);function w(){let M=document;if(d()){if(n){i(false),t(false);return}M.exitFullscreen?M.exitFullscreen():M.webkitExitFullscreen?M.webkitExitFullscreen():M.mozCancelFullScreen?M.mozCancelFullScreen():M.msExitFullscreen?M.msExitFullscreen():t(false);return}let T=e;T.requestFullscreen?T.requestFullscreen().then(()=>{e.classList.add("pivot-is-fullscreen");},()=>{i(true),t(true);}):T.webkitRequestFullscreen?T.webkitRequestFullscreen():T.mozRequestFullScreen?T.mozRequestFullScreen():T.msRequestFullscreen?T.msRequestFullscreen():(i(true),t(true));}return {isFullscreen:d,toggle:w,destroy(){for(let M of Kt)document.removeEventListener(M,s);n&&i(false);}}}var lt=["row","column","data","filter","chooser"];function Xt(e){let t={activeId:null,targetId:null,targetArea:null,intent:null};function n(o,x,f){t.targetId===o&&t.targetArea===x&&t.intent===f||(t.targetId=o,t.targetArea=x,t.intent=f,e.controller.setDragIntent(o,x,f),e.onIntentChange({...t}));}let a=null,d=null,i=null,s=null;function w(o,x,f){i=Oe(e.gridRoot),i.style.pointerEvents="none",s=document.createElement("div"),s.className="kanuni-pivot-drag-overlay pivot-flex pivot-items-center pivot-gap-2 pivot-font-semibold pivot-truncate",Object.assign(s.style,{position:"fixed",left:"0",top:"0",padding:"8px 12px",backgroundColor:"var(--pivot-surface)",border:"2px solid var(--pivot-primary)",boxShadow:"var(--pivot-shadow-xl)",borderRadius:"var(--pivot-border-radius)",fontSize:"var(--pivot-chip-font-size, 14px)",opacity:"0.9",cursor:"grabbing",transformOrigin:"0 0",pointerEvents:"none",zIndex:"100000"});let E=document.createElement("span");E.className="pivot-truncate",Object.assign(E.style,{maxWidth:"150px",color:"var(--pivot-text)"});let R=e.getFields().find(L=>L.id===o);E.textContent=R?.caption||R?.id||"Field",s.appendChild(E),i.appendChild(s),document.body.appendChild(i),Ve(i),M(x,f);}function M(o,x){s&&(s.style.transform=`translate3d(${o+6}px, ${x+6}px, 0) scale(1.05)`);}function T(){i?.remove(),i=null,s=null,d&&(d.el.classList.remove("is-dragging"),d.el.style.removeProperty("pointer-events"),d.el.style.removeProperty("cursor"),document.body.style.removeProperty("user-select"));}function F(o){let x=d;if(T(),d=null,a?.holdTimer&&clearTimeout(a.holdTimer),a=null,document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",g),document.removeEventListener("pointercancel",k),document.removeEventListener("keydown",b,true),!x)return;let f=t.activeId??x.dropId.replace("chooser-","");t.activeId=null,t.targetId=null,t.targetArea=null,t.intent=null,e.onIntentChange({...t}),o===null?e.controller.resetDrag():e.controller.commitDrag(f,o);}function m(){if(!a)return;let{el:o,dropId:x,pointerId:f,startX:E,startY:R}=a;d={el:o,dropId:x,pointerId:f,startX:E,startY:R},a=null;let L=x.replace("chooser-","");t.activeId=L,e.controller.setDragActive(L),o.classList.add("is-dragging"),o.style.pointerEvents="none",o.style.cursor="grabbing",w(L,E,R),window.getSelection?.()?.removeAllRanges?.(),document.body.style.userSelect="none",e.onIntentChange({...t});}function u(o,x){let f=null,E=null,R=null,L=null,O=typeof document.elementFromPoint=="function"?document.elementFromPoint(o,x):null;for(let I of e.roots())for(let H of I.querySelectorAll("[data-drop-id]")){if(d&&H===d.el||O&&!H.contains(O)||H.classList.contains("kanuni-pivot-field-chip")&&H.closest('[data-drop-id="chooser-chooser"]'))continue;let V=H.getBoundingClientRect();if(V.width===0&&V.height===0||o<V.left||o>V.right||x<V.top||x>V.bottom)continue;let G=H.getAttribute("data-drop-id"),oe=G.replace("chooser-","");if(H.classList.contains("kanuni-pivot-column-strip"))L=L??{id:G,el:H};else if(oe.endsWith("-ghost-end"))E={id:G,el:H};else if(lt.includes(oe))R=R??{id:G,el:H};else {let re=V.width*V.height;(!f||re<f.size)&&(f={id:G,el:H,size:re});}}return !f&&!E&&!R&&L?{id:L.id.replace(/-strip$/,"-ghost-end"),el:L.el}:f??E??R}function y(o,x){let f=u(o,x);if(!f)return n(null,null,null),{overId:null};let E=f.id.replace("chooser-",""),R=e.getFields().find(I=>I.id===E),L=lt.includes(E)||E.endsWith("-ghost-end")?E.replace("-ghost-end",""):R?.area,O=!!(t.activeId&&L&&e.controller.canMoveFieldTo&&!e.controller.canMoveFieldTo(t.activeId,L));if(s?.classList.toggle("is-drop-denied",O),s&&(s.style.borderColor=O?"var(--pivot-danger)":"var(--pivot-primary)"),O)return n(null,null,null),{overId:null};if(lt.includes(E)||E.endsWith("-ghost-end"))return n(null,L,"append"),{overId:f.id};if(R){let I=R.area==="chooser"?"vertical":"horizontal",H=f.el.getBoundingClientRect(),V=e.controller.calculateDropIntent(o,x,{top:H.top,left:H.left,width:H.width,height:H.height},t.intent,false,I);return n(E,R.area??null,V),{overId:f.id}}return {overId:f.id}}let h=null,p=o=>{if(!(a&&o.pointerId!==a.pointerId)&&!(d&&o.pointerId!==d.pointerId)){if(a){let x=o.clientX-a.startX,f=o.clientY-a.startY,E=Math.hypot(x,f);if(a.isTouch){if(!a.held&&E>8){a.holdTimer&&clearTimeout(a.holdTimer),a=null;return}if(!a.held)return}else if(E<8)return;m();}d&&(o.preventDefault(),M(o.clientX,o.clientY),h=y(o.clientX,o.clientY).overId);}},g=o=>{if(!(a&&o.pointerId!==a.pointerId)&&!(d&&o.pointerId!==d.pointerId)){if(a){a.holdTimer&&clearTimeout(a.holdTimer),a=null,document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",g),document.removeEventListener("pointercancel",k),document.removeEventListener("keydown",b,true);return}d&&F(y(o.clientX,o.clientY).overId??h);}},l=o=>{(d||a?.held)&&o.cancelable&&o.preventDefault();},k=()=>F(null),b=o=>{o.key==="Escape"&&d&&(o.stopPropagation(),F(null));},C=o=>{if(e.disabled?.()||a||d||o.button!==0&&o.pointerType==="mouse")return;let x=o.target;if(x.closest("button, input, .kanuni-pivot-chip-btn"))return;let f=x.closest(".kanuni-pivot-field-chip[data-drop-id]");if(!f||f.getAttribute("data-drag-scope")==="grip"&&!x.closest("[data-drag-grip]"))return;let E=f.getAttribute("data-drop-id"),R=o.pointerType==="touch";a={el:f,dropId:E,pointerId:o.pointerId,startX:o.clientX,startY:o.clientY,isTouch:R,held:false,holdTimer:R?setTimeout(()=>{a&&(a.held=true,m());},Math.max(0,e.touchDragDelay?.()??200)):null},document.addEventListener("pointermove",p),document.addEventListener("pointerup",g),document.addEventListener("pointercancel",k),document.addEventListener("keydown",b,true);},r=new Set;function c(){for(let o of r)o.isConnected||(o.removeEventListener("pointerdown",C),r.delete(o));for(let o of e.roots())r.has(o)||(r.add(o),o.addEventListener("pointerdown",C));}return c(),document.addEventListener("touchmove",l,{passive:false}),{getState:()=>({...t}),refreshRoots:c,rootCount:()=>r.size,destroy(){d&&F(null),a?.holdTimer&&clearTimeout(a.holdTimer),a=null;for(let o of r)o.removeEventListener("pointerdown",C);r.clear(),document.removeEventListener("touchmove",l),document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",g),document.removeEventListener("pointercancel",k),document.removeEventListener("keydown",b,true);}}}function xe(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Ut(e){let{portal:t}=e;function n(m,u,y,h=false){let p=xe(`${h?"kanuni-pivot-dropdown-item-danger":"kanuni-pivot-dropdown-item"} pivot-flex pivot-items-center`,"button");return p.type="button",m&&p.appendChild(_(m,16)),p.appendChild(document.createTextNode(" "+u)),p.addEventListener("click",()=>{t.closePopup(),y();}),p}function a(m,u,y){let h=()=>window.visualViewport?.removeEventListener("resize",p),p=()=>{if(!m.isConnected){h();return}let g=m.offsetWidth,l=m.scrollHeight||m.offsetHeight;if(g===0&&l===0)return;let k=pivotgridCore.placePopup({x:u,y},{width:g,height:l});m.style.top=`${k.top}px`,m.style.left=`${k.left}px`,m.style.maxHeight=`${k.maxHeight}px`;};return p(),window.visualViewport?.addEventListener("resize",p),h}let d=null;function i(m,u,y){let h=null,p=null,g=()=>{h?.remove(),h=null,d===g&&(d=null);},l=()=>{if(h)return;d&&d(),d=g,h=xe("kanuni-pivot-dropdown-menu pivot-animate-zoom-in");let r=m.getBoundingClientRect(),c=pivotgridCore.placePopup({x:r.right+4,y:r.top},{width:160,height:0},{altX:r.left-4});if(Object.assign(h.style,{position:"fixed",top:`${c.top}px`,left:`${c.left}px`,minWidth:"160px",zIndex:"10000"}),h.addEventListener("contextmenu",o=>o.preventDefault()),h.addEventListener("mouseenter",()=>{p&&clearTimeout(p);}),h.addEventListener("mouseleave",()=>{p=setTimeout(g,200);}),y(h),u.appendChild(h),h.offsetHeight){let o=pivotgridCore.placePopup({x:r.right+4,y:r.top},{width:h.offsetWidth,height:h.scrollHeight},{altX:r.left-4});Object.assign(h.style,{top:`${o.top}px`,left:`${o.left}px`,maxHeight:`${o.maxHeight}px`,overflowY:"auto"});}},k=0,b=false,C=()=>Date.now()-k<1e3;m.addEventListener("pointerdown",r=>{r.pointerType!=="mouse"&&(k=Date.now());}),m.addEventListener("mouseenter",()=>{p&&clearTimeout(p),!C()&&(h||(b=true),l());}),m.addEventListener("mouseleave",()=>{C()||(p=setTimeout(g,200));}),m.addEventListener("click",r=>{if(r.detail>0&&b&&h){b=false;return}b=false,h?g():l();});}function s(m,u,y){let h=xe("kanuni-pivot-dropdown-item pivot-flex pivot-items-center pivot-justify-between","button");h.type="button";let p=xe("pivot-flex pivot-items-center pivot-gap-2","span");return p.appendChild(_(m,16)),p.appendChild(document.createTextNode(" "+u)),h.appendChild(p),h.appendChild(_(y?"chevron-left":"chevron-right",14)),h}function w(m){m.addEventListener("keydown",u=>{let y=[...m.querySelectorAll("button:not([disabled])")];if(y.length===0)return;let h=y.indexOf(document.activeElement),p=-1;u.key==="ArrowDown"?p=h<0?0:(h+1)%y.length:u.key==="ArrowUp"?p=h<0?y.length-1:(h-1+y.length)%y.length:u.key==="Home"?p=0:u.key==="End"&&(p=y.length-1),!(p<0)&&(u.preventDefault(),y[p].focus());});}function M(m,u,y,h,p){let g=e.getFields().find(r=>r.id===y);if(!g)return;let{t:l,rtl:k}=e.getI18n(),b=e.getFields().filter(r=>r.area==="row").sort((r,c)=>(r.areaIndex||0)-(c.areaIndex||0)),C=h!==void 0&&b.length>0&&g.area==="data";t.openPopup(r=>{let c=xe("kanuni-pivot-dropdown-menu pivot-animate-zoom-in pivot-flex-col");Object.assign(c.style,{position:"fixed",top:`${u}px`,left:`${m}px`,maxHeight:`${Math.max(0,pivotgridCore.popupViewport().height-16)}px`,overflowY:"auto",overflowX:"hidden",width:"220px",zIndex:"9999"}),c.addEventListener("contextmenu",f=>f.preventDefault());let o=xe("kanuni-pivot-report-section-title");if(Object.assign(o.style,{position:"sticky",top:"0",zIndex:"10"}),o.textContent=g.caption??g.id,c.appendChild(o),C){let f=xe("kanuni-pivot-report-section-title");f.style.marginTop="4px",f.textContent=l("sortByThisColumn"),c.appendChild(f);for(let E of b)c.appendChild(n("arrow-down-a-z",l("sortFieldByThisColumn").replace("{0}",E.caption||E.id),()=>e.controller.sortFieldBySummary(E.id,g.id,h)));c.appendChild(xe("kanuni-pivot-divider")),c.appendChild(n("x",l("removeAllSorting"),()=>e.controller.clearAllSorting(),true));}else {c.appendChild(n("arrow-down-a-z",l("sortAsc"),()=>e.controller.sortField(g.id,"asc"))),c.appendChild(n("arrow-up-z-a",l("sortDesc"),()=>e.controller.sortField(g.id,"desc"))),g.sortOrder&&c.appendChild(n("x",l("clearSort"),()=>e.controller.sortField(g.id,void 0),true)),e.openFilter&&g.area!=="data"&&c.appendChild(n("filter",l("filterField"),()=>e.openFilter(g.id,m,u))),e.openCondition&&(g.area==="row"||g.area==="column")&&c.appendChild(n("filter",l("conditionFilter")+"\u2026",()=>e.openCondition(g.id))),c.appendChild(xe("kanuni-pivot-divider"));let f=s("list",l("order"),k);c.appendChild(f),i(f,r,L=>{let O=[["start",l("moveToStart"),"chevrons-left"],["left",l("moveToLeft"),"chevron-left"],["right",l("moveToRight"),"chevron-right"],["end",l("moveToEnd"),"chevrons-right"]];for(let[I,H,V]of O)L.appendChild(n(V,H,()=>e.controller.moveField(g.id,I)));});let E=[["row",l("rowArea"),"rows-3"],["column",l("columnArea"),"columns-3"],["data",l("dataArea"),"bar-chart-3"],["filter",l("filterArea"),"filter"]].filter(([L])=>L!==g.area);if(E.length>0){let L=s("move",l("moveToArea"),k);c.appendChild(L),i(L,r,O=>{for(let[I,H,V]of E){let G=n(V,H,()=>e.controller.changeFieldArea(g.id,I));e.controller.canMoveFieldTo(g.id,I)||(G.disabled=true),O.appendChild(G);}});}e.openFieldChooser&&c.appendChild(n("list",l("showFieldList"),e.openFieldChooser)),c.appendChild(n("eye-off",l("hide"),()=>e.controller.removeField(g.id)));let R=e.customContextMenuItems?.(g);if(R&&R.length>0){c.appendChild(xe("kanuni-pivot-divider"));for(let L of R){let O=n(null,L.label,L.action);L.icon&&O.insertBefore(L.icon(),O.firstChild),c.appendChild(O);}}c.appendChild(xe("kanuni-pivot-divider")),g.isCalculated&&e.onEditCalculatedField&&c.appendChild(n("calculator",l("editCalculation"),()=>e.onEditCalculatedField(g))),c.appendChild(n("settings",l("fieldSettings"),()=>e.openSettings(g.id)));}r.appendChild(c);let x=a(c,m,u);return p?(w(r),c.querySelector("button")?.focus(),()=>{x(),e.gridRoot?.querySelector(`.kanuni-pivot-field-chip[data-drop-id="${y}"]`)?.focus({preventScroll:true});}):x});}function T(m,u){let{t:y}=e.getI18n(),h=pivotgridCore.viewOptionsMenuItems(e.getLayout());h.any&&t.openPopup(p=>{let g=xe("kanuni-pivot-dropdown-menu pivot-animate-zoom-in");Object.assign(g.style,{position:"fixed",zIndex:"301",width:"224px",fontSize:"14px",left:`${m}px`,top:`${u}px`}),g.addEventListener("contextmenu",C=>C.preventDefault());let l=xe("kanuni-pivot-report-section-title");l.textContent=y("viewOptions"),g.appendChild(l);let k=e.getLayout(),b=(C,r,c)=>{let o=xe("pivot-w-full pivot-flex pivot-items-center pivot-justify-between","button");o.type="button",Object.assign(o.style,{padding:"6px 12px",textAlign:"left"}),o.addEventListener("mouseenter",()=>{o.style.backgroundColor="var(--pivot-surface-hover)";}),o.addEventListener("mouseleave",()=>{o.style.backgroundColor="transparent";});let x=xe("","span");x.textContent=C;let f=xe("pivot-text-xs pivot-text-muted pivot-font-medium","span");return f.textContent=y(r?"show":"hide"),o.append(x,f),o.addEventListener("click",()=>{c(),t.closePopup();}),o};return h.filterArea&&g.appendChild(b(y("filterArea"),k.showFilterArea===false,()=>e.controller.setLayout({showFilterArea:k.showFilterArea===false}))),h.footer&&g.appendChild(b(y("footerArea"),k.showFooter===false,()=>e.controller.setLayout({showFooter:k.showFooter===false}))),p.appendChild(g),a(g,m,u)});}function F(m){let{t:u}=e.getI18n(),y=()=>{let h=e.getEngineTrees();if(!h)return [];let p=[],g=(l,k)=>{if(l)for(let b of l)k>=m.depth&&p.push(b.key),b.children&&g(b.children,k+1);};return g(m.type==="row"?h.rowTree:h.colTree,0),p};t.openPopup(h=>{let p=xe("");Object.assign(p.style,{position:"fixed",inset:"0",zIndex:"9998"}),p.addEventListener("click",()=>t.closePopup()),p.addEventListener("contextmenu",k=>{k.preventDefault(),t.closePopup();});let g=xe("kanuni-pivot-dropdown-menu pivot-animate-zoom-in");Object.assign(g.style,{position:"fixed",left:`${m.x}px`,top:`${m.y}px`,zIndex:"9999",minWidth:"160px"}),g.addEventListener("contextmenu",k=>k.preventDefault());let l=(k,b)=>{let C=xe("kanuni-pivot-dropdown-item pivot-state-hover","button");return C.type="button",Object.assign(C.style,{paddingLeft:"32px",paddingRight:"24px"}),C.textContent=k,C.addEventListener("click",r=>{r.stopPropagation(),t.closePopup(),b();}),C};return g.appendChild(l(m.isExpanded?u("collapse"):u("expand"),()=>{m.type==="row"?e.controller.toggleExpanded(m.path):e.controller.toggleColExpanded(m.path);})),g.appendChild(xe("kanuni-pivot-dropdown-divider")),g.appendChild(l(u("expandAll"),()=>{let k=y();m.type==="row"?e.controller.expandPaths(k):e.controller.expandColPaths(k);})),g.appendChild(l(u("collapseAll"),()=>{let k=y();m.type==="row"?e.controller.collapsePaths(k):e.controller.collapseColPaths(k);})),h.append(p,g),a(g,m.x,m.y)});}return {openFieldMenu:M,openGlobalMenu:T,openNodeMenu:F,close:()=>t.closePopup()}}function Se(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}var Ae=(e,...t)=>{let n=Se("kanuni-pivot-form-group"),a=Se("kanuni-pivot-form-label","label");return a.textContent=e,n.append(a,...t),n},Fe=(e,t)=>{let n=Se("kanuni-pivot-select","select");for(let[a,d]of e){let i=document.createElement("option");i.value=a,i.textContent=d,n.appendChild(i);}return n.value=t,n},Ue=(e,t)=>{let n=Se("kanuni-pivot-input","input");return n.type=e,n.value=t,n},Yt=(...e)=>{let t=Se("");Object.assign(t.style,{display:"flex",gap:"8px",marginTop:"6px"});for(let n of e)Object.assign(n.style,{flex:"1 1 0",minWidth:"0"});return t.append(...e),t},vo=[["equals","opEquals"],["notEquals","opNotEquals"],["contains","opContains"],["notContains","opNotContains"],["startsWith","opStartsWith"],["endsWith","opEndsWith"]],mo=[[">","opGreater"],[">=","opGreaterOrEqual"],["<","opLess"],["<=","opLessOrEqual"],["=","opEquals"],["!=","opNotEquals"],["between","opBetween"],["notBetween","opNotBetween"]];function Zt(e){function t(d,i,s,w){let{t:M}=e.getI18n();e.portal.openPopup(T=>{let F=Se("kanuni-pivot-modal-overlay pivot-animate-fade-in");F.addEventListener("click",()=>e.portal.closePopup());let m=Se("kanuni-pivot-modal pivot-animate-zoom-in");m.style.width="400px",m.setAttribute("role","dialog"),m.setAttribute("aria-modal","true"),m.setAttribute("aria-label",d);let u=Se("kanuni-pivot-modal-header"),y=Se("kanuni-pivot-modal-title","h2");y.textContent=d;let h=Se("kanuni-pivot-modal-close","button");h.type="button",h.setAttribute("aria-label",M("cancel")),h.appendChild(_("x",20)),h.addEventListener("click",()=>e.portal.closePopup()),u.append(y,h);let p=Se("kanuni-pivot-modal-footer"),g=Se("kanuni-pivot-btn kanuni-pivot-btn--outline","button");g.type="button",g.textContent=M("cancel"),g.addEventListener("click",()=>e.portal.closePopup());let l=Se("kanuni-pivot-btn kanuni-pivot-btn--primary","button");l.type="button",l.appendChild(_("check",16)),l.appendChild(document.createTextNode(" "+M("ok"))),l.addEventListener("click",()=>{s()!==false&&e.portal.closePopup();}),p.append(g,l),m.append(u,i,p),T.append(F,m),w.focus();});}function n(d){let i=e.getFields().find(g=>g.id===d);if(!i)return;let{t:s}=e.getI18n(),w=Se("kanuni-pivot-modal-body pivot-custom-scrollbar"),M=Ue("text",i.caption??"");w.appendChild(Ae(s("caption"),M));let T=i.area==="data"||i.area==="chooser",F=i.area==="row"||i.area==="column"||i.area==="filter"||i.area==="chooser",m=null,u=null,y=null,h=(...g)=>g.map(l=>[l,s(l)]),p=(...g)=>{let l=i.summaryType;return h(...l&&!g.includes(l)?[l,...g]:g)};T&&i.dataType&&i.dataType!=="number"&&(m=Fe(p("count","distinct"),String(i.summaryType||"count")),w.appendChild(Ae(s("summaryType"),m))),T&&i.dataType==="number"&&(m=Fe(p("sum","count","avg","min","max","distinct"),String(i.summaryType||"sum")),w.appendChild(Ae(s("summaryType"),m)),u=Fe([["absolute",s("absoluteValue")],...h("percentOfTotal","percentOfColumnTotal","percentOfRowTotal","percentOfParentRowTotal","percentOfParentColumnTotal","runningTotal","difference","percentDifference")],String(i.summaryDisplayMode||"absolute")),w.appendChild(Ae(s("displayMode"),u))),F&&i.dataType==="date"&&(y=Fe([["",s("none")],...h("year","quarter","month","week","day")],String(i.groupInterval||"")),w.appendChild(Ae(s("groupInterval"),y))),t(s("fieldSettings"),w,()=>{e.save({...i,caption:M.value,summaryType:m?.value||i.summaryType,summaryDisplayMode:u?.value??i.summaryDisplayMode,groupInterval:y?y.value||void 0:i.groupInterval});},M);}function a(d){let i=e.getFields(),s=i.find(r=>r.id===d);if(!s)return;let{t:w}=e.getI18n(),M=Se("kanuni-pivot-modal-body pivot-custom-scrollbar"),T=r=>[["",w("none")],...r.map(([c,o])=>[c,w(o)])],F=s.labelFilter,m=Fe(T(vo),F?.operator??"");m.setAttribute("data-condition-label-op",""),m.setAttribute("aria-label",w("caption"));let u=Ue("text",F?.value??"");u.setAttribute("data-condition-label-value",""),u.placeholder=w("builderValuePlaceholder"),u.setAttribute("aria-label",w("builderValuePlaceholder")),M.appendChild(Ae(w("caption"),Yt(m,u)));let y=i.filter(r=>r.area==="data").sort((r,c)=>(r.areaIndex||0)-(c.areaIndex||0)),h=s.valueFilter,p=Fe(y.map(r=>[r.id,r.caption||r.id]),y.some(r=>r.id===h?.dataField)?h.dataField:y[0]?.id??"");p.setAttribute("data-condition-value-field",""),p.setAttribute("aria-label",w("dataArea"));let g=Fe(T(mo),h?.operator??"");g.setAttribute("data-condition-value-op",""),g.setAttribute("aria-label",w("dataArea"));let l=Ue("number",h?String(h.value):"");l.setAttribute("data-condition-value","");let k=Ue("number",h?.value2!==void 0?String(h.value2):"");k.setAttribute("data-condition-value2","");for(let r of [l,k])r.setAttribute("aria-label",w("builderValuePlaceholder"));y.length>0&&M.appendChild(Ae(w("dataArea"),p,Yt(g,l,k)));let b=()=>{u.disabled=m.value==="",l.disabled=g.value==="",k.style.display=g.value==="between"||g.value==="notBetween"?"":"none";};m.addEventListener("change",b),g.addEventListener("change",b),b();let C=r=>(r.setAttribute("aria-invalid","true"),r.focus(),false);t(`${w("conditionFilter")}: ${s.caption||s.id}`,M,()=>{for(let o of [u,l,k])o.removeAttribute("aria-invalid");let r;if(m.value){if(u.value==="")return C(u);r={operator:m.value,value:u.value,...F?.caseSensitive?{caseSensitive:true}:{}};}let c=y.length>0?void 0:h;if(g.value&&y.length>0){let o=k.style.display!=="none",x=l.value===""?NaN:Number(l.value),f=k.value===""?NaN:Number(k.value);if(!Number.isFinite(x))return C(l);if(o&&!Number.isFinite(f))return C(k);c={dataField:p.value,operator:g.value,value:x,...o?{value2:f}:{}};}e.save({...s,labelFilter:r,valueFilter:c});},m);}return {open:n,openCondition:a}}function ae(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function bo(e){let t=e.isCalculated?"settings-2":e.dataType==="number"?"hash":e.dataType==="date"?"calendar":e.dataType==="boolean"?"filter":"type";return _(t,12,"var(--pivot-primary)")}function Jt(e){let t=null,n=null,a=null,d="",i={x:0,y:0},s={width:700,height:550},w=()=>window.innerWidth<=768,M=["fullscreenchange","webkitfullscreenchange"],T=()=>{if(!t)return;let r=$e();t.parentElement!==r&&r.appendChild(t);},F=()=>{n&&(m(),w()||(i={x:Math.min(i.x,Math.max(0,window.innerWidth-s.width)),y:Math.min(i.y,Math.max(0,window.innerHeight-s.height))},m()));};function m(){n&&(w()?Object.assign(n.style,{position:"fixed",inset:"0",width:"100%",height:"100%",left:"",top:"",borderRadius:"0",zIndex:"100",transform:"none",padding:"0"}):Object.assign(n.style,{position:"fixed",inset:"",left:`${i.x}px`,top:`${i.y}px`,width:`${s.width}px`,height:`${s.height}px`,maxWidth:"95vw",maxHeight:"95vh",transform:"none",padding:"0",zIndex:"100",boxShadow:"var(--pivot-shadow-lg)",borderRadius:""}));}function u(r,c){let{t:o}=e.getI18n(),x=ae("kanuni-pivot-field-chip");x.setAttribute("data-drop-id",`chooser-${r.id}`),x.setAttribute("data-drag-scope","grip"),x.style.position="relative";let f=ae("");if(f.setAttribute("data-drag-grip",""),Object.assign(f.style,{color:"var(--pivot-text-muted)",cursor:"grab",flexShrink:"0",opacity:"0.5"}),f.appendChild(_("grip-vertical",14)),x.appendChild(f),c){let H=ae("kanuni-pivot-checkbox","input");H.type="checkbox",H.checked=r.area!=="chooser",H.style.flexShrink="0",H.addEventListener("change",()=>{H.checked?e.controller.showFields([r.id]):e.controller.removeField(r.id);}),x.appendChild(H);}x.appendChild(bo(r));let E=ae("pivot-truncate","span");Object.assign(E.style,{flex:"1",color:"var(--pivot-text)",textAlign:"left"}),E.textContent=r.caption??r.id;let R=r.area==="data"&&r.summaryType?pivotgridCore.summaryTypeLabel(String(r.summaryType),o):"";if(R){let H=ae("","span");Object.assign(H.style,{fontSize:"10px",marginLeft:"4px",backgroundColor:"color-mix(in srgb, var(--pivot-primary) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--pivot-primary) 45%, transparent)",color:"var(--pivot-text)",padding:"0 4px",borderRadius:"4px",fontWeight:"700"}),H.textContent=R,E.appendChild(H);}x.appendChild(E);let L=!!r.filterValues&&r.filterValues.size>0,O=ae(`kanuni-pivot-field-chip-actions${L?" is-filtered":""}`);if(r.area!=="data"){let H=ae("kanuni-pivot-chip-btn","button");H.type="button",H.title=o("filterField"),L&&Object.assign(H.style,{color:"var(--pivot-danger)",backgroundColor:"color-mix(in srgb, var(--pivot-danger) 10%, transparent)"}),H.appendChild(_("filter",12)),H.addEventListener("click",V=>{V.stopPropagation(),e.onFilterClick(V.clientX,V.clientY,r.id);}),O.appendChild(H);}if(r.isCalculated){let H=ae("kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger","button");H.type="button",H.title=o("deletePermanently"),H.appendChild(_("trash",12)),H.addEventListener("click",V=>{V.stopPropagation(),e.controller.deleteField(r.id);}),O.appendChild(H);}let I=ae("kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger","button");return I.type="button",I.title=o("removeFromArea"),I.appendChild(_("x",12)),I.addEventListener("click",H=>{H.stopPropagation(),e.controller.removeField(r.id);}),O.appendChild(I),x.appendChild(O),x}function y(r,c,o,x,f){let E=ae("");if(Object.assign(E.style,{height:"100%",display:"flex",flexDirection:"column",transition:"background-color 0.2s"}),o!==null){let O=ae("");Object.assign(O.style,{fontSize:"12px",fontWeight:"600",textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--pivot-text-muted)",backgroundColor:"color-mix(in srgb, var(--pivot-surface-header) 30%, transparent)",padding:"8px 12px",borderBottom:"1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"}),O.textContent=o,E.appendChild(O);}let R=ae("pivot-custom-scrollbar");if(R.setAttribute("data-drop-id",`chooser-${r}`),R.setAttribute("data-drop-kind","list"),Object.assign(R.style,{maxHeight:w()?"none":"100%",flex:"1",padding:"8px",minHeight:"80px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"6px",alignItems:c.length===0?"center":"stretch",justifyContent:c.length===0?"center":"flex-start"}),c.length===0){let O=ae("");Object.assign(O.style,{fontSize:"12px",color:"color-mix(in srgb, var(--pivot-text-muted) 70%, transparent)",fontStyle:"italic",textAlign:"center",width:"100%"}),O.textContent=x,R.appendChild(O);}for(let O of c)R.appendChild(u(O,f));let L=ae("");return L.setAttribute("data-drop-id",`chooser-${r}-ghost-end`),L.setAttribute("data-ghost-populated",c.length>0?"1":"0"),Object.assign(L.style,{width:"100%",minHeight:"24px",transition:"background-color 0.2s",borderRadius:"var(--pivot-border-radius-sm)"}),R.appendChild(L),E.appendChild(R),E}function h(){let r=new Map;return e.getFields().map(c=>{let o=c.caption||c.id||"";if(r.has(o)){let x=r.get(o)+1;return r.set(o,x),{...c,caption:`${o} (${x})`}}return r.set(o,1),c})}function p(){let{locale:r}=e.getI18n(),c=[...h()].sort((x,f)=>(x.caption||"").toLowerCase().localeCompare((f.caption||"").toLowerCase(),r||"en"));if(!d)return c;let o=d.toLowerCase();return c.filter(x=>(x.caption||"").toLowerCase().includes(o))}function g(){let r=p().filter(c=>c.area==="chooser").map(c=>c.id);r.length!==0&&e.controller.showFields(r);}function l(){if(!a)return;let{t:r,locale:c}=e.getI18n(),o=new Map;for(let ie of a.querySelectorAll('[data-drop-kind="list"]')){let P=ie.getAttribute("data-drop-id");P&&ie.scrollTop>0&&o.set(P,ie.scrollTop);}let x=h(),f=p(),E=ie=>x.filter(P=>P.area===ie).sort((P,A)=>(P.areaIndex||0)-(A.areaIndex||0));a.textContent="";let R=w(),L=ae(R?"w-full flex flex-col border-b border-border bg-surface":"w-full md:w-[40%] flex flex-col border-b md:border-b-0 md:border-r border-border bg-surface");R&&(L.style.flexShrink="0");let O=ae("p-3 border-b border-border/60 bg-surface/80"),I=ae("relative"),H=_("search",16);H.setAttribute("class","text-muted-fg opacity-60"),Object.assign(H.style,{position:"absolute",top:"50%",transform:"translateY(-50%)",pointerEvents:"none"}),H.style.setProperty("inset-inline-start","10px");let V=ae("w-full bg-surface-hover/50 border-border rounded-md text-[13px] kanuni-pivot-input","input");V.type="text",V.placeholder=r("search"),V.value=d,V.style.setProperty("padding-inline-start","34px"),V.addEventListener("input",()=>{d=V.value,l();let ie=a?.querySelector('input[type="text"]');ie?.focus(),ie?.setSelectionRange(ie.value.length,ie.value.length);}),I.append(H,V),O.appendChild(I),L.appendChild(O);let G=ae(R?"p-2":"flex-1 overflow-hidden p-2"),oe=ae("");Object.assign(oe.style,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"});let re=ae("text-[11px] font-bold uppercase tracking-wider text-muted-fg/80 mb-2 px-1");re.textContent=r("allFields");let ue=ae("kanuni-pivot-popup-action-btn kanuni-pivot-chooser-select-all","button");ue.type="button",ue.textContent=r("selectAll"),ue.style.color="var(--pivot-primary)",ue.disabled=f.every(ie=>ie.area!=="chooser"),ue.addEventListener("click",g),oe.append(re,ue),G.appendChild(oe),G.appendChild(y("chooser",f,null,r("noItems"),true)),L.appendChild(G);let Te=ae(R?"w-full p-3 bg-surface-sunken/30":"w-full md:w-[60%] flex-1 overflow-y-auto custom-scrollbar p-3 bg-surface-sunken/30");R&&(Te.style.flexShrink="0");let me=ae(R?"grid grid-cols-1 sm:grid-cols-2 gap-3":"grid grid-cols-1 sm:grid-cols-2 gap-3 h-full auto-rows-fr"),Ce=[["filter",r("filterArea")],["column",r("columnArea")],["row",r("rowArea")],["data",r("dataArea")]];for(let[ie,P]of Ce){let A=ae("border border-border/80 rounded-md shadow-sm bg-surface overflow-hidden flex flex-col transition-colors");R&&(A.style.minHeight="140px"),A.appendChild(y(ie,E(ie),P,r("dropHere"),false)),me.appendChild(A);}Te.appendChild(me),a.append(L,Te);for(let[ie,P]of o){let A=a.querySelector(`[data-drop-id="${ie}"][data-drop-kind="list"]`);A&&(A.scrollTop=P);}}function k(){if(t)return;let{t:r}=e.getI18n();t=Oe(e.gridRoot);let c=ae("fixed inset-0 z-[100] kanuni-pivot-chooser-backdrop overflow-auto pointer-events-auto");c.addEventListener("click",b),n=ae("flex flex-col bg-surface shadow-2xl border border-border overflow-hidden rounded-lg kanuni-pivot-field-chooser"),n.addEventListener("click",L=>L.stopPropagation()),w()||(s={width:Math.min(700,window.innerWidth-32),height:Math.min(550,window.innerHeight-32)},i={x:Math.max(0,(window.innerWidth-s.width)/2),y:Math.max(0,(window.innerHeight-s.height)/2)}),m();let o=ae("pivot-field-chooser__header flex items-center justify-between p-3 border-b border-border bg-surface-header/90");w()||(o.style.cursor="move");let x=ae("text-[15px] font-semibold m-0 flex items-center gap-2 select-none","h3");x.appendChild(_("grip-horizontal",18,"var(--pivot-text-muted)")),x.appendChild(document.createTextNode(r("allFields")));let f=ae("btn-icon rounded-full p-1.5 kanuni-pivot-chip-btn","button");f.type="button",f.setAttribute("aria-label",r("cancel")),f.appendChild(_("x",18)),f.addEventListener("pointerdown",L=>L.stopPropagation()),f.addEventListener("click",b),o.append(x,f);let E=null;o.addEventListener("pointerdown",L=>{w()||L.target.closest(".kanuni-pivot-field-chip, button, input")||(E={px:L.clientX,py:L.clientY,x:i.x,y:i.y},o.setPointerCapture?.(L.pointerId));}),o.addEventListener("pointermove",L=>{E&&(i={x:Math.max(0,E.x+L.clientX-E.px),y:Math.max(0,E.y+L.clientY-E.py)},m());});let R=L=>{E=null,o.releasePointerCapture?.(L.pointerId);};if(o.addEventListener("pointerup",R),o.addEventListener("pointercancel",R),a=ae(w()?"flex flex-1 flex-col bg-surface-sunken/30":"flex flex-1 overflow-hidden flex-col md:flex-row bg-surface-sunken/30"),w()&&(a.setAttribute("data-chooser-scroll",""),Object.assign(a.style,{minHeight:"0",overflowY:"auto",touchAction:"pan-y",overscrollBehavior:"contain"})),l(),n.append(o,a),!w()){let L=[["n","n-resize",{top:"0",left:"0",right:"0",height:"6px"}],["s","s-resize",{bottom:"0",left:"0",right:"0",height:"6px"}],["w","w-resize",{top:"0",bottom:"0",left:"0",width:"6px"}],["e","e-resize",{top:"0",bottom:"0",right:"0",width:"6px"}],["nw","nw-resize",{top:"0",left:"0",width:"12px",height:"12px"}],["ne","ne-resize",{top:"0",right:"0",width:"12px",height:"12px"}],["sw","sw-resize",{bottom:"0",left:"0",width:"12px",height:"12px"}],["se","se-resize",{bottom:"0",right:"0",width:"12px",height:"12px"}]];for(let[O,I,H]of L){let V=ae("kanuni-pivot-chooser-resize");V.setAttribute("data-resize-dir",O),Object.assign(V.style,{position:"absolute",zIndex:O.length===2?"51":"50",cursor:I},H);let G=null;V.addEventListener("pointerdown",re=>{re.stopPropagation(),G={px:re.clientX,py:re.clientY,w:s.width,h:s.height,x:i.x,y:i.y},V.setPointerCapture?.(re.pointerId);}),V.addEventListener("pointermove",re=>{if(!G)return;let ue=re.clientX-G.px,Te=re.clientY-G.py,me=G.w,Ce=G.h,ie=G.x,P=G.y;O.includes("e")&&(me=G.w+ue),O.includes("s")&&(Ce=G.h+Te),O.includes("w")&&(me=G.w-ue,me>=400&&(ie=G.x+ue)),O.includes("n")&&(Ce=G.h-Te,Ce>=400&&(P=G.y+Te)),s={width:Math.max(400,me),height:Math.max(400,Ce)},i={x:Math.max(0,ie),y:Math.max(0,P)},m();});let oe=re=>{G=null,V.releasePointerCapture?.(re.pointerId);};V.addEventListener("pointerup",oe),V.addEventListener("pointercancel",oe),n.appendChild(V);}}c.appendChild(n),t.appendChild(c),$e().appendChild(t),Ve(t),window.addEventListener("resize",F);for(let L of M)document.addEventListener(L,T);e.onOpenChanged?.(true);}function b(){if(t){window.removeEventListener("resize",F);for(let r of M)document.removeEventListener(r,T);t.remove(),t=null,n=null,a=null,d="",e.onOpenChanged?.(false);}}function C(){if(!t)return;let r={...i},c={...s};b(),k(),i=r,s=c,m();}return {open:k,close:b,toggle:()=>t?b():k(),isOpen:()=>t!==null,repaint:l,relocalize:C,getHost:()=>t,destroy:b}}function se(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Qt(e){let t=false,n=null,a=s=>{t&&n&&!n.contains(s.target)&&(t=false,e.requestRepaint());};document.addEventListener("mousedown",a);function d(s,w){let{t:M}=e.getI18n();e.portal.openPopup(T=>{let F=se("kanuni-pivot-modal-overlay");F.addEventListener("click",()=>e.portal.closePopup());let m=se("kanuni-pivot-modal pivot-animate-zoom-in");Object.assign(m.style,{display:"flex",flexDirection:"column",gap:"16px",padding:"24px"});let u=se("pivot-flex pivot-flex-col");u.style.gap="6px";let y=se("pivot-flex pivot-items-center pivot-justify-between"),h=se("kanuni-pivot-modal-title","h3");h.textContent=s;let p=se("kanuni-pivot-modal-close","button");p.type="button",p.setAttribute("aria-label",M("close")),p.style.padding="6px",p.appendChild(_("x",16)),p.addEventListener("click",()=>e.portal.closePopup()),y.append(h,p);let g=se("kanuni-pivot-modal-description","p");g.textContent=M("saveReportDescription"),u.append(y,g);let l=se("pivot-flex pivot-flex-col pivot-gap-4","form"),k=se("pivot-flex pivot-flex-col pivot-gap-2"),b=se("kanuni-pivot-form-label","label");b.textContent=M("reportName");let C=se("kanuni-pivot-input","input");C.type="text",C.placeholder=M("reportNamePlaceholder"),C.required=true,C.value=w,k.append(b,C);let r=se("pivot-flex pivot-items-center pivot-gap-2"),c=se("kanuni-pivot-input","input");c.type="checkbox",Object.assign(c.style,{width:"16px",height:"16px"});let o=se("kanuni-pivot-form-label","label");Object.assign(o.style,{margin:"0",cursor:"pointer"}),o.textContent=M("setAsDefault"),o.addEventListener("click",()=>{c.checked=!c.checked;}),r.append(c,o);let x=se("kanuni-pivot-modal-footer");Object.assign(x.style,{marginTop:"8px",paddingTop:"16px",borderTop:"1px solid var(--pivot-border)",display:"flex",justifyContent:"flex-end",gap:"8px"});let f=se("kanuni-pivot-btn kanuni-pivot-btn--outline","button");f.type="button",f.textContent=M("cancel"),f.addEventListener("click",()=>e.portal.closePopup());let E=se("kanuni-pivot-btn kanuni-pivot-btn--primary","button");E.type="submit",E.disabled=!w.trim(),E.appendChild(_("save",16)),E.appendChild(document.createTextNode(" "+M("save"))),C.addEventListener("input",()=>{E.disabled=!C.value.trim();}),x.append(f,E),l.addEventListener("submit",R=>{R.preventDefault();let L=C.value.trim();L&&(e.controller.saveReport(L,c.checked),e.portal.closePopup());}),l.append(k,r,x),m.append(u,l),T.append(F,m),C.focus();});}function i(s){let{t:w}=e.getI18n();n=s;let M=e.getReports(),T=e.getActiveReportId(),F=M.find(g=>g.id===T),m=se(`kanuni-pivot-report-btn ${t?"kanuni-pivot-report-btn--open":T?"kanuni-pivot-report-btn--active":"kanuni-pivot-report-btn--default"}`,"button");m.type="button",m.title=w("viewsAndReports"),m.appendChild(_("bookmark",15));let u=se("pivot-truncate","span");if(u.style.maxWidth="120px",u.textContent=F?F.name:w("views"),m.appendChild(u),m.addEventListener("click",()=>{t=!t,e.requestRepaint();}),s.appendChild(m),!t)return;let y=se("kanuni-pivot-report-dropdown pivot-animate-slide-up"),h=(g,l=false)=>{let k=se("kanuni-pivot-report-section-title");return l&&(k.style.marginTop="8px",k.style.borderTop="1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"),k.textContent=g,k},p=(g,l,k,b)=>{let C=se("kanuni-pivot-report-item","button");C.type="button",C.appendChild(_(g,16,l));let r=se(""),c=se("pivot-font-medium");return c.textContent=k,r.appendChild(c),C.appendChild(r),C.addEventListener("click",()=>{t=false,e.requestRepaint(),b();}),C};if(y.appendChild(h(w("actions"))),y.appendChild(p("save","var(--pivot-success)",w("saveNewView"),()=>d(w("saveNewView"),""))),T&&(y.appendChild(p("save-all","var(--pivot-warning)",w("saveChangesOverwrite"),()=>e.controller.updateCurrentReport())),y.appendChild(p("copy","var(--pivot-info)",w("saveAsCopy"),()=>d(w("saveAsView"),`${F?.name??""} (Copy)`)))),M.length>0){y.appendChild(h(w("savedViews"),true));let g=se("kanuni-pivot-report-list pivot-custom-scrollbar");for(let l of M){let k=se(`kanuni-pivot-report-list-item${l.id===T?" kanuni-pivot-report-list-item--active":""}`),b=se("kanuni-pivot-report-list-btn","button");b.type="button",b.appendChild(_(l.id===T?"check":"folder-open",14,l.id===T?"var(--pivot-primary)":"var(--pivot-text-muted)"));let C=se("pivot-text-sm pivot-truncate","span");C.style.color=l.id===T?"var(--pivot-primary)":"var(--pivot-text)",l.id===T&&C.classList.add("pivot-font-medium"),C.textContent=l.name,b.appendChild(C),l.isDefault&&b.appendChild(ze("star",12,"var(--pivot-warning)")),b.addEventListener("click",()=>{t=false,e.requestRepaint(),e.controller.loadReport(l.id);}),k.appendChild(b);let r=se("kanuni-pivot-report-actions");if(!l.isDefault){let o=se("kanuni-pivot-action-btn kanuni-pivot-action-btn--warning","button");o.type="button",o.title=w("makeDefault"),o.setAttribute("aria-label",o.title),o.appendChild(_("star",14)),o.addEventListener("click",x=>{x.stopPropagation(),e.controller.setDefaultReport(l.id);}),r.appendChild(o);}let c=se("kanuni-pivot-action-btn kanuni-pivot-action-btn--danger","button");c.type="button",c.title=w("deleteReport"),c.setAttribute("aria-label",c.title),c.appendChild(_("trash",14)),c.addEventListener("click",o=>{o.stopPropagation(),window.confirm(w("deleteReportConfirm").replace("{0}",l.name))&&(e.controller.deleteReport(l.id),l.id===T&&(t=false,e.requestRepaint()));}),r.appendChild(c),k.appendChild(r),g.appendChild(k);}y.appendChild(g);}s.appendChild(y);}return {mount:i,destroy(){document.removeEventListener("mousedown",a);}}}var xo={chartData:[],chartSeries:[]};function dt(e,t,n,a){let d=null,i,s,w,M=false;function T(){if(M)return;let u=e.getState();if(!u.engineResult||!u.engineResult.cellMatrix||!n.transformer){a(xo);return}a(n.transformer(u.engineResult,pivotgridCore.shownFields(u.fields),u.expandedPaths,t(),n));}function F(){let u=e.getState(),y=t();u.engineResult===i&&u.expandedPaths===s&&y===w||(i=u.engineResult,s=u.expandedPaths,w=y,d&&clearTimeout(d),d=setTimeout(T,150));}let m=e.subscribe(F);return F(),{refresh:F,stop(){M=true,d&&clearTimeout(d),m();}}}function He(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}var ct=new Set;function Ao(){let e="default-pivot-grid";for(let t=2;ct.has(e);t++)e=`default-pivot-grid-${t}`;return ct.add(e),e}function Fo(e,t){if(!e||!(e instanceof HTMLElement))throw new Error("[pivotgrid] createPivotGrid needs a container HTMLElement");ft(t);let n=Ne(t.locale,t.dictionary,t.rtl),a=t.gridId||t.stateStoring?.storageKey,d=a||Ao();!a&&d!=="default-pivot-grid"&&console.warn(`[pivotgrid] multiple grids without gridId on this page \u2014 this one got '${d}'. Give each grid an explicit gridId for stable state persistence.`);let i=He("kanuni-pivot-root"+(t.className?" "+t.className:""));i.style.width="100%",i.style.height="100%",ht(i,pivotgridCore.pivotSchemeTheme(t.theme,t.palette,t.dark)),i.setAttribute("dir",n.rtl?"rtl":"ltr");let s=He("kanuni-pivot-wrapper pivot-flex pivot-flex-col");s.style.width="100%",s.style.height="100%";let w=He("pivot-grid pivot-flex-1 pivot-flex pivot-flex-col pivot-relative");w.style.minHeight="0",w.style.overflow="hidden",w.style.backgroundColor="var(--pivot-bg)",w.style.border="1px solid var(--pivot-border)",w.style.borderRadius="var(--pivot-radius-md)",w.style.userSelect="none",t.striped&&i.classList.add("kanuni-pivot-striped");let M=t.density,T=()=>pivotgridCore.pivotDensityClass(M),F=()=>pivotgridCore.pivotRowHeight(M);T()&&i.classList.add(T());let m=He("pivot-flex-1 pivot-flex pivot-flex-col pivot-relative");m.style.minHeight="0";let u=He("pivot-text-muted pivot-text-sm");u.style.padding="8px",u.style.position="absolute",u.style.inset="0",u.style.display="none",u.style.zIndex="70",u.style.backgroundColor="var(--pivot-bg)",u.setAttribute("data-pivot-status",""),w.appendChild(m),w.appendChild(u),s.appendChild(w),i.appendChild(s);let y=He("kanuni-pivot-live");y.setAttribute("role","status"),y.setAttribute("aria-live","polite"),y.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap",i.appendChild(y),e.appendChild(i);let h={gridId:d,data:t.data??[],rowKey:t.rowKey,asyncTransactionWait:t.asyncTransactionWait,loading:t.loading,maxColumns:t.maxColumns,initialFields:t.initialFields??t.fields??[],controlledFields:t.fields,controlledLayout:t.layout,stateStoring:t.stateStoring,workerUrl:t.workerUrl,registry:t.registry,serverSource:t.serverSource,locale:n.locale,dictionary:n.dictionary,enterpriseEdition:t.advancedExport===true,onRefresh:t.onRefresh,onFieldsChange:t.onFieldsChange,onLayoutChange:t.onLayoutChange,onFieldMove:t.onFieldMove,onBeforePivotCalculate:t.onBeforePivotCalculate,onAfterPivotCalculate:t.onAfterPivotCalculate,onExporting:t.onExporting,onLargeExport:t.onLargeExport,onComputingChange:t.onComputingChange,onError:t.onError,onChartStateLoaded:t.onChartStateLoaded},p=new pivotgridCore.PivotController(h),g=pivotgridCore.bindPivotScrollMemory(i,p),l=pivotgridCore.watchShortPivot(s),k=()=>pivotgridCore.shownFields(p.getState().fields),b=it(i),C=jt({portal:b,getI18n:()=>n,gridId:d,getField:v=>k().find(z=>z.id===v),getData:()=>p.getRawData(),apply:(v,z,W)=>p.applyFilter(v,z,W),clear:v=>p.clearFilter(v),openCondition:v=>r.openCondition(v),showSearch:()=>p.getState().layout.filterPopupSearch!==false}),r=Zt({portal:b,getI18n:()=>n,getFields:k,save:v=>p.updateField(v)}),c=Ut({portal:b,gridRoot:i,getI18n:()=>n,getFields:k,getLayout:()=>p.getState().layout,controller:p,getEngineTrees:()=>{let v=p.getState().engineResult;return v?{rowTree:v.rowTree,colTree:v.colTree}:null},openSettings:v=>r.open(v),openCondition:v=>r.openCondition(v),openFilter:(v,z,W)=>{E()||C.open(z,W,v);},openFieldChooser:()=>o.open(),onEditCalculatedField:t.onEditCalculatedField?v=>{E()||t.onEditCalculatedField(v);}:void 0,customContextMenuItems:t.customContextMenuItems}),o=Jt({gridRoot:i,getI18n:()=>n,getFields:k,controller:p,onFilterClick:(v,z,W)=>C.open(v,z,W),onOpenChanged:()=>{P||(oe.refreshRoots(),ie.paint(p.getState()));}}),x=(v,z)=>{t.onGlobalContextMenu?t.onGlobalContextMenu(v,z):c.openGlobalMenu(v,z);},f=Ht(),E=()=>t.disabled===true,R,L,O={getI18n:()=>n,onRemove:v=>{E()||p.removeField(v);},onFilterClick:(v,z,W)=>{E()||C.open(v,z,W);},onSort:(v,z)=>{E()||p.sortField(v,z);},onContextMenu:(v,z,W,S,D)=>{E()||c.openFieldMenu(v,z,W,S,D);},getFields:k,onMove:(v,z)=>{E()||p.moveField(v,z);},requestFocus:v=>{R=v;let W=document.activeElement?.closest?.("[data-drop-id]")?.getAttribute("data-drop-id");L=W?k().find(S=>S.id===W)?.area:void 0;}},I=Ft({host:m,getI18n:()=>n,onCellPrepared:t.onCellPrepared,registry:t.registry,shared:f,chipDeps:O,hasCellClick:()=>!!t.onCellClick&&!E(),columnWidthDefaults:pivotgridCore.resolveColumnWidthDefaults(t.defaultColumnWidths),rowHeight:F}),H=Tt({...O,host:w,onGlobalContextMenu:x,onToggleCollapsed:()=>{E()||p.setLayout({filterAreaCollapsed:p.getState().layout.filterAreaCollapsed!==true});}});w.insertBefore(H.element,m);let V=He("kanuni-pivot-notice");V.setAttribute("role","status"),V.style.display="none",w.insertBefore(V,m);let G=()=>{let v=o.getHost();return v?[i,v]:[i]},oe=Xt({gridRoot:i,roots:G,controller:p,getFields:k,onIntentChange:v=>Lt(G(),v),disabled:E,touchDragDelay:()=>t.touchDragDelay}),re=It({scroller:I.scroller,controller:{toggleExpanded:v=>{E()||p.toggleExpanded(v);},toggleColExpanded:v=>{E()||p.toggleColExpanded(v);},sortField:(v,z)=>{E()||p.sortField(v,z);}},getVM:I.getVM,getTheadHeight:I.getTheadHeight,rowHeight:F,shared:f,onCellClick:t.disabled===true?void 0:t.onCellClick,resolveCellClick:v=>p.resolveCellClick(v),onGlobalContextMenu:(v,z)=>{E()||x(v,z);},onFilterClick:(v,z,W)=>{E()||C.open(v,z,W);},onHeaderContextMenu:(v,z,W,S)=>{E()||c.openFieldMenu(v,z,W,S);},onNodeContextMenu:v=>{E()||c.openNodeMenu(v);},keyboardEnabled:t.keyboardNavigation?.enabled!==false}),ue=Ct({scroller:I.scroller,shared:f,getVM:I.getVM,onStats:v=>p.setSelectionStats(v)}),Te=Ot({host:m,scroller:I.scroller,shared:f,isRtl:()=>n.rtl,getWidths:()=>p.getState().columnWidths??{},rowHeaderLayout:()=>I.rowHeaderLayout(),dataColOffset:()=>I.getVM()?.dataColOffset??0,commit:v=>{E()||p.setColumnWidths(v);}}),me=_t(i,()=>{ie.paint(p.getState()),I.refreshWindow();}),Ce=Qt({portal:b,getI18n:()=>n,controller:p,getReports:()=>p.getState().reports??[],getActiveReportId:()=>p.getState().activeReportId??null,requestRepaint:()=>ie.paint(p.getState())}),ie=qt({host:s,getI18n:()=>n,toolbar:t.toolbar,advancedExport:t.advancedExport===true,upgradeUrl:t.upgradeUrl,registry:t.registry,onToggleFieldChooser:()=>o.toggle(),fieldChooserOpen:()=>o.isOpen(),onRefresh:t.onRefresh,onExport:v=>{p.exportData(v,{applyFilters:true}).catch(z=>{let W=z instanceof Error?z:new Error(String(z));W.name!=="AbortError"&&(t.onError?t.onError(W):console.error(W));});},onExpandAll:()=>p.expandAll({allLevels:true}),onCollapseAll:()=>p.collapseAll(),onAddCalculatedField:t.onAddCalculatedField?()=>{E()||t.onAddCalculatedField();}:void 0,onOpenPrefilter:t.onOpenPrefilter?()=>{E()||t.onOpenPrefilter();}:void 0,onToggleChart:t.onToggleChart?()=>{E()||t.onToggleChart();}:void 0,onToggleFullscreen:()=>me.toggle(),isFullscreen:()=>me.isFullscreen(),onGlobalContextMenu:x,mountReportMenu:v=>Ce.mount(v),onSearch:t.search?v=>p.setSearchText(v):void 0}),P=false,A=false,$=null,N=0;function X(){P||A||(A=true,queueMicrotask(Y));}let J="";function ye(v){let z=pivotgridCore.pivotChipView(v);if(J!==z.className){for(let S of J.split(" "))S&&i.classList.remove(S);for(let S of z.className.split(" "))S&&i.classList.add(S);J=z.className;}let W=z.style["--pivot-chip-max-width"];W?i.style.setProperty("--pivot-chip-max-width",W):i.style.removeProperty("--pivot-chip-max-width"),$t(i);}function Y(){if(A=false,P)return;let v=p.getState(),z=!$||$.engineResult!==v.engineResult||$.fields!==v.fields||$.layout!==v.layout||$.expandedPaths!==v.expandedPaths||$.expandedColPaths!==v.expandedColPaths||$.columnWidths!==v.columnWidths;(!$||$.layout!==v.layout)&&ye(v.layout);let W=!$||$.isBuilding!==v.isBuilding||$.buildProgress!==v.buildProgress||$.engineError!==v.engineError||$.engineResult!==v.engineResult||$.noData!==v.noData,S=!$||$.selectionStats!==v.selectionStats||$.reports!==v.reports||$.activeReportId!==v.activeReportId||$.layout!==v.layout;if(z&&(H.paint(pivotgridCore.shownFields(v.fields).filter(D=>D.area==="filter"),v.layout.showFilterArea!==false,{maxRows:v.layout.filterAreaMaxRows,collapsed:v.layout.filterAreaCollapsed===true,collapsedRows:v.layout.filterAreaCollapsedRows}),o.isOpen()&&o.repaint()),z&&v.engineResult&&I.paintStructural(v),R!==void 0&&(((R?i.querySelector(`.kanuni-pivot-field-chip[data-drop-id="${R}"]`):L?i.querySelector(`[data-drop-id="${L}"]`):null)??I.scroller).focus({preventScroll:true}),R=void 0,L=void 0),W&&fe(v),!$||$.engineResult!==v.engineResult){let D=v.engineResult?.columnsTruncated;V.style.display=D?"":"none";let B=new Intl.NumberFormat(n.locale);V.textContent=D?n.t("columnsTruncated").replace("{shown}",B.format(D.shown)).replace("{total}",B.format(D.total)):"";}if($&&$.searchText!==v.searchText&&ie.syncSearch(v.searchText??""),$&&$.fields!==v.fields){let D=pivotgridCore.pivotChangeAnnouncement($.fields,v.fields,n.t);D&&(y.textContent=pivotgridCore.nextLiveText(y.textContent??"",D));}S&&(ie.element.style.display=v.layout.showFooter===false?"none":"",ie.paint(v)),$=v,N++;}function fe(v){if(v.engineError){u.style.display="block",u.textContent=`${n.t("error")}: ${v.engineError.message}`;return}if(v.isBuilding&&!v.engineResult){u.style.display="block",u.textContent=`${n.t("initializing")} ${Math.round(v.buildProgress??0)}%`;return}if(!v.engineResult){u.style.display="block",u.textContent=n.t(v.noData?"emptyData":"loading");return}u.style.display="none",u.textContent="";}let K=t.onChartSync?dt(p,()=>n.locale,t.chartIntegrationOptions??{},t.onChartSync):null,de=p.subscribe(X);Y();let j={controller:p,element:i,setData(v){P||p.setData(v);},applyTransaction(v){return p.applyTransaction(v)},applyTransactionAsync(v,z){p.applyTransactionAsync(v,z);},flushAsyncTransactions(){p.flushAsyncTransactions();},setLoading(v){p.setLoading(v);},undoLayout:()=>pivotgridCore.keepFocusAcross(i,p,()=>p.undoLayout()),redoLayout:()=>pivotgridCore.keepFocusAcross(i,p,()=>p.redoLayout()),canUndoLayout:()=>p.canUndoLayout(),canRedoLayout:()=>p.canRedoLayout(),clearLayoutHistory:()=>p.clearLayoutHistory(),setFields(v){P||p.setFields(v);},setSearchText(v){p.setSearchText(v);},setLocale(v,z,W){P||(n=Ne(v,z??t.dictionary,W??t.rtl),i.setAttribute("dir",n.rtl?"rtl":"ltr"),p.updateOptions({locale:n.locale,dictionary:n.dictionary}),$=null,X(),o.relocalize(),K?.refresh());},openFieldChooser:()=>o.open(),closeFieldChooser:()=>o.close(),clearAllFilters:()=>p.clearAllFilters(),setDensity(v){P||(T()&&i.classList.remove(T()),M=v,T()&&i.classList.add(T()),$=null,X());},destroy(){P||(P=true,de(),g(),l(),K?.stop(),o.destroy(),oe.destroy(),re.destroy(),ue.destroy(),Te.destroy(),H.destroy(),Ce.destroy(),ie.destroy(),me.destroy(),b.destroy(),I.destroy(),p.dispose(),i.remove(),a||ct.delete(d));}};return Object.defineProperty(j,"__flushCount",{get:()=>N}),Object.defineProperty(j,"__shared",{get:()=>f}),Object.defineProperty(j,"__dragRootCount",{get:()=>oe.rootCount()}),j}
3
+ Object.defineProperty(exports,"PivotController",{enumerable:true,get:function(){return pivotgridCore.PivotController}});Object.defineProperty(exports,"defaultPivotLayout",{enumerable:true,get:function(){return pivotgridCore.defaultPivotLayout}});Object.defineProperty(exports,"getAdvancedExporter",{enumerable:true,get:function(){return pivotgridCore.getAdvancedExporter}});Object.defineProperty(exports,"registerAdvancedExporter",{enumerable:true,get:function(){return pivotgridCore.registerAdvancedExporter}});exports.createChartSync=dt;exports.createPivotGrid=Fo;exports.createPortalLayer=it;exports.createThemedHost=Oe;exports.createValueFormatter=We;exports.filledIcon=ze;exports.fitPortalZoom=Ve;exports.icon=_;exports.portalParent=$e;exports.resolveI18n=Ne;