@kanunilabs/pivotgrid 1.6.3 → 1.6.4
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 +3 -3
- package/dist/index.js +3 -3
- package/dist/pivotgrid.umd.js +7 -7
- package/dist/styles.css +27 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {ko,ja,zhCN,ru,pt as pt$1,it as it$1,es,fr,de,ar,en as en$1,tr,percentModeText,pivotSchemeTheme,PivotController,bindPivotScrollMemory,resolveColumnWidthDefaults,pivotDensityClass,shownFields,pivotChangeAnnouncement,nextLiveText,placePopup,popupViewport,countFilteredFields,filterAreaRows,filterAreaMaxHeight,pathKey,filterEmptySummaryTree,buildColumnHeaders,flattenRowTreeTree,flattenRowTreeTabular,grandTotalShown,columnSlotOptions,getVisibleColSlots,fieldNeedsRange,computeFieldRanges,formatDimensionValue,summaryTypeLabel,computeRowHeaderWidths,MAX_C,getFieldDistinctValues,extractGroupValue,collatorFor,headerFilterShown,pathParts,headerFilterWrite,pivotRowHeight,resolveConditionalVisual,invertRowHeaderWidth}from'@kanunilabs/pivotgrid-core';export{PivotController,defaultPivotLayout,getAdvancedExporter,registerAdvancedExporter}from'@kanunilabs/pivotgrid-core';var Qt={tr:tr,en:en$1,ar:ar,de:de,fr:fr,es:es,it:it$1,pt:pt$1,ru:ru,"zh-CN":zhCN,ja:ja,ko:ko};function Ve(e,t,n){let r=e??"en",l={...en$1,...Qt[r]??{},...t??{}};return {locale:r,rtl:n!==void 0?n:r==="ar",dictionary:l,t:i=>l[i]||i}}var en={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)"},nt=new Set;function rt(e){for(let t of Object.keys(e)){let n=en[t];!n||nt.has(t)||(nt.add(t),console.warn(`[pivotgrid] config key "${t}" is React-only and ignored \u2014 ${n}`));}}var tn=[["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 it(e,t){for(let[n,r]of tn){let l=t?typeof n=="function"?n(t):t[n]:void 0;typeof l=="string"&&l?e.style.setProperty(r,l):e.style.removeProperty(r);}t?.id?e.setAttribute("data-theme",t.id):e.removeAttribute("data-theme");}var Ke=(e,t)=>(e.areaIndex||0)-(t.areaIndex||0);function dt(e,t){let n=shownFields(e.fields),r=e.layout,l=n.filter(f=>f.area==="row").sort(Ke),i=n.filter(f=>f.area==="column").sort(Ke),a=n.filter(f=>f.area==="data").sort(Ke),g=e.engineResult,M=e.expandedPaths.has("*"),L=e.expandedColPaths.has("*"),E=r.rowHeaderLayout==="tree"?1:l.length||1,x=r.dataFieldPosition==="rows"&&a.length>1,d=x?1:a.length;if(!g)return {rowFields:l,colFields:i,dataFields:a,colHeaders:[],virtualRows:[],leafColHashes:[],cellLookup:new Map,fieldRanges:{},engineResult:null,layout:r,maxRowDepth:E,showDataInRows:x,dfsPerLeaf:d,totalDataCols:0,dataColOffset:E+(x?1:0)};let[h,w]=r.hideEmptySummaryCells?filterEmptySummaryTree(g):[g.rowTree,g.colTree],v=buildColumnHeaders(w,a,r,e.expandedColPaths,L,t),c=r.rowHeaderLayout==="tree"?flattenRowTreeTree(h,e.expandedPaths,M,l.length||1,r.showRowTotals??true,r.totalsPosition??"bottom",r.showTotalsForSingleValues!==false):flattenRowTreeTabular(h,e.expandedPaths,M,E,r.showRowTotals??true,r.totalsPosition??"bottom",r.showTotalsForSingleValues!==false),o=[];for(let f of c)if(x&&!f.isSubtotal&&!f.hasChildren)for(let C=0;C<a.length;C++)o.push({flatRow:f,dfIndex:C,isDataRow:true,isGrandTotal:false});else o.push({flatRow:f,dfIndex:0,isDataRow:false,isGrandTotal:false});if(grandTotalShown(r,"row",h))if(x)for(let f=0;f<a.length;f++)o.push({flatRow:null,dfIndex:f,isDataRow:true,isGrandTotal:true});else o.push({flatRow:null,dfIndex:0,isDataRow:false,isGrandTotal:true});let k=columnSlotOptions(r),y=[];for(let f of getVisibleColSlots(w,e.expandedColPaths,L,k))y.push({hash:f.node.key,isGrandTotal:!!f.node.isTotal,isSubtotal:f.isSubtotal});(grandTotalShown(r,"column",w)||y.length===0)&&y.push({hash:"",isGrandTotal:true});let b=new Map,p=g.cellMatrix.keys;for(let f=0;f<p.length;f++)b.set(p[f],f);let u=a.some(fieldNeedsRange)?computeFieldRanges(g,a):{};return {rowFields:l,colFields:i,dataFields:a,colHeaders:v,virtualRows:o,leafColHashes:y,cellLookup:b,fieldRanges:u,engineResult:g,layout:r,maxRowDepth:E,showDataInRows:x,dfsPerLeaf:d,totalDataCols:y.length*d,dataColOffset:E+(x?1:0)}}function _e(e,t,n,r,l){let i=e.engineResult,a=i.rowIndexMap[t]??-1,g=i.columnIndexMap[n]??-1;if(a===-1||g===-1)return null;let M=e.cellLookup.get(a*MAX_C+g);if(M===void 0)return null;let L=e.dataFields.length,E=i.cellMatrix.sums,x=i.cellMatrix.displaySums,d={};for(let h=0;h<L;h++)d[e.dataFields[h].id]=E[M*L+h],x&&(d[`${e.dataFields[h].id}_display`]=x[M*L+h]);return {values:d,rowPath:pathParts(t),colPath:pathParts(n),isTotalCell:a===0||g===0||r||l}}function ct(e,t,n){if(!e.engineResult||n<e.dataColOffset)return null;let r=n-e.dataColOffset,l=Math.floor(r/e.dfsPerLeaf),i=r%e.dfsPerLeaf;if(l>=e.leafColHashes.length)return null;let a=e.virtualRows[t];if(!a)return null;let g=a.isGrandTotal?"":a.flatRow?.key;if(g===void 0)return null;let M=e.leafColHashes[l]?.hash;if(M===void 0)return null;let L=e.engineResult.rowIndexMap[g],E=e.engineResult.columnIndexMap[M];if(L===void 0||E===void 0)return null;let x=e.cellLookup.get(L*MAX_C+E);if(x===void 0)return null;let d=e.showDataInRows?a.dfIndex:i,w=e.engineResult.cellMatrix.sums[x*e.dataFields.length+d];return typeof w=="number"?w:null}function Xe(e,t,n){let r=e.virtualRows[t];if(!r||r.isGrandTotal||!r.flatRow)return null;let l=r.flatRow,i=e.layout.rowHeaderLayout==="tree",a=n,g=i?l.depth:a,M=g===l.depth,L=g<l.depth,E=M?l.hasChildren:L,x=M?l.isExpanded:L,d=i?l.key:pathKey(l.pathValues.slice(0,a+1));return {hasChildren:E,isExpanded:x,cellHashStr:d,depth:g,dIdx:a,flatRow:l}}function pt(e,t,n){if(n<e.dataColOffset||!e.engineResult)return null;let r=n-e.dataColOffset,l=Math.floor(r/e.dfsPerLeaf),i=r%e.dfsPerLeaf;if(l>=e.leafColHashes.length)return null;let a=e.virtualRows[t];if(!a)return null;let g=a.isGrandTotal?"":a.flatRow?.key;if(g===void 0)return null;let M=e.leafColHashes[l],L=_e(e,g,M.hash,!!a.flatRow?.isSubtotal,M.isGrandTotal);if(!L)return null;let E=e.showDataInRows?a.dfIndex:i,x=e.dataFields[E],d=L.values[`${x?.id}_display`]??L.values[x?.id],h=!!a.flatRow?.isSubtotal||M.isGrandTotal||L.isTotalCell;return {cell:{isTotalCell:L.isTotalCell,rowPath:L.rowPath,colPath:L.colPath,values:L.values},val:d,isTotal:h}}function ze(e){let t=new Map;return (n,r)=>{if(n==null||Number.isNaN(n))return "";if(r.format&&typeof n=="number"){if(typeof r.format=="function")return r.format(n);try{let l=r.format,i=t.get(l);i||(i=new Intl.NumberFormat(e,l),t.set(l,i));let a=i.format(n);return l.isCustom&&(l.prefix||l.suffix)?`${l.prefix||""}${a}${l.suffix||""}`:a}catch{return String(n)}}return typeof n=="number"&&percentModeText(n,r,e)||String(n)}}var Ae=null;function $e(e,t,n){if(!e)return false;let r=Math.min(e.startR,e.endR),l=Math.max(e.startR,e.endR),i=Math.min(e.startC,e.endC),a=Math.max(e.startC,e.endC);return t>=r&&t<=l&&n>=i&&n<=a}function ut(e){let{scroller:t,shared:n}=e,r={},l="",i=null;function a(){for(let d of t.querySelectorAll("td[data-r][data-c]")){let h=Number(d.getAttribute("data-r")),w=Number(d.getAttribute("data-c"));d.classList.toggle("kanuni-pivot-cell-selected",$e(n.selection,h,w));}}function g(){let d=n.selection;!d||d.mode!=="data"||!e.onStats||(i&&clearTimeout(i),i=setTimeout(()=>{i=null;let h=n.selection;if(!h||h.mode!=="data")return;let w=Math.min(h.startR,h.endR),v=Math.max(h.startR,h.endR),c=Math.min(h.startC,h.endC),o=Math.max(h.startC,h.endC),k=0,y=0,b=1/0,p=-1/0,u=e.getVM();if(u){for(let f=w;f<=v;f++)for(let C=c;C<=o;C++){let m=ct(u,f,C);m===null||isNaN(m)||(k+=m,y++,m<b&&(b=m),m>p&&(p=m));}e.onStats(y>0?{sum:k,count:y,avg:k/y,min:b,max:p}:null);}},10));}let M=d=>{if(d.button!==0||n.isResizing||d.target.closest?.(".kanuni-pivot-resize-handle"))return;let h=d.target.closest?.("td[data-r][data-c]");if(!h)return;let w=e.getVM();if(!w)return;let v=Number(h.getAttribute("data-r")),c=Number(h.getAttribute("data-c")),o=c<w.dataColOffset?"row":"data";Ae=r,l="",n.selection={startR:v,startC:c,endR:v,endC:c,isSelecting:true,mode:o},a(),g();},L=d=>{let h=n.selection;if(!h||!h.isSelecting)return;let w=d.target.closest?.("td[data-r][data-c]");if(!w)return;let v=Number(w.getAttribute("data-r")),c=Number(w.getAttribute("data-c")),o=`${v},${c}`;if(o===l)return;l=o;let k=e.getVM();!k||(c<k.dataColOffset?"row":"data")!==h.mode||v===h.endR&&c===h.endC||(h.endR=v,h.endC=c,a(),g());},E=()=>{n.selection&&(n.selection.isSelecting=false);},x=d=>{if(!(d.ctrlKey||d.metaKey)||d.key!=="c"||Ae!==null&&Ae!==r)return;let h=n.selection;if(!h)return;let w=Math.min(h.startR,h.endR),v=Math.max(h.startR,h.endR),c=Math.min(h.startC,h.endC),o=Math.max(h.startC,h.endC),k="";for(let y=w;y<=v;y++){let b=[];for(let p=c;p<=o;p++){let u=t.querySelector(`[data-r="${y}"][data-c="${p}"]`);b.push(u?(u.innerText??u.textContent??"").trim().replace(/\n/g," "):"");}k+=b.join(" ")+`
|
|
2
|
-
`;}k&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(k).catch(()=>{});};return t.addEventListener("mousedown",M),t.addEventListener("mouseover",L),document.addEventListener("mouseup",E),document.addEventListener("keydown",x),{destroy(){t.removeEventListener("mousedown",M),t.removeEventListener("mouseover",L),document.removeEventListener("mouseup",E),document.removeEventListener("keydown",x),i&&clearTimeout(i),Ae===r&&(Ae=null);}}}var ht={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 vt="http://www.w3.org/2000/svg";function q(e,t=15,n){let r=document.createElementNS(vt,"svg");r.setAttribute("width",String(t)),r.setAttribute("height",String(t)),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("fill","none"),r.setAttribute("stroke","currentColor"),r.setAttribute("stroke-width","2"),r.setAttribute("stroke-linecap","round"),r.setAttribute("stroke-linejoin","round"),r.setAttribute("aria-hidden","true"),r.setAttribute("focusable","false"),n&&(r.style.color=n);for(let[l,i]of ht[e]??[]){let a=document.createElementNS(vt,l);for(let[g,M]of Object.entries(i))a.setAttribute(g,String(M));r.appendChild(a);}return r}function Fe(e,t=15,n){let r=q(e,t,n);return r.setAttribute("fill","currentColor"),r}function pe(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Ye(e){let t=document.activeElement;return !t||!e.contains(t)?null:t.closest(".kanuni-pivot-field-chip")?.getAttribute("data-drop-id")??null}function Ue(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 bn(e,t,n){let r=e.filter(l=>l.area===t);return t==="filter"?ft(r,n):r.sort((l,i)=>(l.areaIndex||0)-(i.areaIndex||0))}var yn={row:"rowArea",column:"columnArea",data:"dataArea",filter:"filterArea"};function Be(e,t){let{t:n,locale:r,rtl:l}=t.getI18n(),i=pe("kanuni-pivot-field-chip");i.setAttribute("data-drop-id",e.id),i.style.position="relative",i.style.cursor="pointer",i.setAttribute("role","button"),i.tabIndex=0;let a=t.getFields?bn(t.getFields(),e.area,r):[e],g=Math.max(0,a.findIndex(o=>o.id===e.id)),M=n(yn[e.area??""]??"rowArea");i.setAttribute("aria-label",n("fieldChipLabel").replace("{0}",e.caption||e.id).replace("{1}",M).replace("{2}",String(g+1)).replace("{3}",String(a.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 L=()=>{if(!t.onSort)return;let o=e.sortOrder==="asc"?"desc":e.sortOrder==="desc"?void 0:"asc";t.onSort(e.id,o);},E=o=>{if(!o)return;(i.closest(".kanuni-pivot-root")??document.body).querySelector(`.kanuni-pivot-field-chip[data-drop-id="${o}"]`)?.focus({preventScroll:true});};i.addEventListener("keydown",o=>{let k=o.ctrlKey||o.metaKey,y=l?"ArrowRight":"ArrowLeft",b=l?"ArrowLeft":"ArrowRight",p=!!t.onMove&&e.area!=="filter",u=true;if(o.key==="Enter"||o.key===" ")L();else if(k&&p&&(o.key===y||o.key==="ArrowUp"))g>0&&t.onMove(e.id,"left");else if(k&&p&&(o.key===b||o.key==="ArrowDown"))g<a.length-1&&t.onMove(e.id,"right");else if(k&&p&&o.key==="Home")g>0&&t.onMove(e.id,"start");else if(k&&p&&o.key==="End")g<a.length-1&&t.onMove(e.id,"end");else if(!k&&(o.key===y||o.key===b)){let f=o.key===y?-1:1;E(a[g+f]?.id);}else if(o.key==="Delete"||o.key==="Backspace"){let f=a[g+1]??a[g-1];t.requestFocus?.(f?.id??null),t.onRemove(e.id);}else if(o.altKey&&o.key==="ArrowDown"){let f=i.getBoundingClientRect();t.onFilterClick(l?f.right:f.left,f.bottom,e.id);}else if(o.key==="F10"&&o.shiftKey||o.key==="ContextMenu"){if(!t.onContextMenu)return;let f=i.getBoundingClientRect();t.onContextMenu(l?f.right:f.left,f.bottom,e.id,void 0,true);}else u=false;u&&(o.preventDefault(),o.stopPropagation());});let x=pe("pivot-truncate","span");Object.assign(x.style,{maxWidth:"120px",userSelect:"none"}),x.textContent=e.caption||e.id,i.appendChild(x),e.sortOrder==="asc"&&i.appendChild(q("arrow-up",12,"var(--pivot-primary)")),e.sortOrder==="desc"&&i.appendChild(q("arrow-down",12,"var(--pivot-primary)"));let d=e.area==="data"&&e.summaryType?summaryTypeLabel(String(e.summaryType),n):"";if(d){let o=pe("","span");Object.assign(o.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"}),o.textContent=d,i.appendChild(o);}let h=!!e.filterValues&&e.filterValues.size>0||!!e.valueFilter||!!e.labelFilter,w=pe(`kanuni-pivot-field-chip-actions${h?" is-filtered":""}`);w.setAttribute("aria-hidden","true");let v=pe("kanuni-pivot-chip-btn","span");v.title=n("filterField"),v.style.color=h?"var(--pivot-danger)":"inherit",v.appendChild(q("filter",12)),v.addEventListener("pointerdown",o=>o.stopPropagation()),v.addEventListener("click",o=>{o.stopPropagation(),t.onFilterClick(o.clientX,o.clientY,e.id);});let c=pe("kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger","span");if(c.title=n("removeField"),c.appendChild(q("x",12)),c.addEventListener("pointerdown",o=>o.stopPropagation()),c.addEventListener("click",o=>{o.stopPropagation(),t.onRemove(e.id);}),w.append(v,c),i.appendChild(w),t.onContextMenu){i.setAttribute("data-chip-menu","");let o=pe(`kanuni-pivot-chip-more${h?" is-filtered":""}`,"span");if(o.setAttribute("aria-hidden","true"),o.addEventListener("pointerdown",k=>k.stopPropagation()),o.addEventListener("click",k=>{k.stopPropagation();let y=o.getBoundingClientRect();t.onContextMenu(l?y.right:y.left,y.bottom,e.id,void 0);}),i.appendChild(o),h){let k=q("filter",10);k.classList.add("kanuni-pivot-chip-filtered-mark"),k.setAttribute("aria-hidden","true"),i.appendChild(k);}}return i.addEventListener("click",o=>{o.stopPropagation(),L();}),i.addEventListener("contextmenu",o=>{if(o.stopPropagation(),t.onContextMenu){o.preventDefault();let k=i.getBoundingClientRect(),y=Number.isFinite(o.clientX)?o.clientX:l?k.right:k.left,b=Number.isFinite(o.clientY)?o.clientY:k.bottom;t.onContextMenu(y,b,e.id,void 0);}}),i}function Ne(e,t,n,r,l){let{t:i}=l.getI18n(),a=pe("kanuni-pivot-area-dropzone");a.setAttribute("data-drop-id",e),a.tabIndex=-1;let g=pe("kanuni-pivot-area-header");g.appendChild(q(n,13)),g.appendChild(document.createTextNode(t)),a.appendChild(g);let M=pe("kanuni-pivot-area-content");if(r.length===0){let E=pe("pivot-text-xs pivot-text-muted","span");Object.assign(E.style,{fontStyle:"italic",padding:"0 8px"}),E.textContent=i("dropHere"),M.appendChild(E);}for(let E of r)M.appendChild(Be(E,l));let L=pe("kanuni-pivot-ghost-end");return L.setAttribute("data-drop-id",`${e}-ghost-end`),L.setAttribute("data-ghost-populated",r.length>0?"1":"0"),Object.assign(L.style,{flex:"1",minWidth:"40px",minHeight:"24px",borderRadius:"var(--pivot-border-radius-sm)",transition:"background-color 0.2s"}),M.appendChild(L),a.appendChild(M),a}function ft(e,t){let n=new Map;return e.map(l=>{let i=l.caption||l.id||"";if(n.has(i)){let a=n.get(i)+1;return n.set(i,a),{...l,caption:`${i} (${a})`}}return n.set(i,1),l}).sort((l,i)=>(l.caption||"").toLowerCase().localeCompare((i.caption||"").toLowerCase(),t||"en"))}function mt(e){let t=pe("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 r(l,i,a){let{t:g}=e.getI18n(),M=l.querySelector(".kanuni-pivot-area-header"),L=l.querySelector(".kanuni-pivot-area-content"),E=a.collapsed===true;if(E&&l.setAttribute("data-collapsed",""),M&&E){let h=countFilteredFields(i);if(h>0){let w=pe("kanuni-pivot-area-filtered-count","span");w.textContent=g("filteredFieldCount").replace("{0}",String(h)),M.appendChild(w);}}if(M&&e.onToggleCollapsed&&i.length>0){let h=pe("kanuni-pivot-area-collapse","button");h.type="button";let w=g(E?"expandFilterArea":"collapseFilterArea");h.setAttribute("aria-expanded",String(!E)),h.setAttribute("aria-label",w),h.title=w;let v=q("chevron-down",14);E||(v.style.transform="rotate(180deg)"),h.appendChild(v),h.addEventListener("click",c=>{c.stopPropagation(),e.onToggleCollapsed();}),M.appendChild(h);}let x=filterAreaRows({filterAreaMaxRows:a.maxRows,filterAreaCollapsed:E});if(!L||x===null)return;let d=L.querySelector(".kanuni-pivot-field-chip");L.style.maxHeight=`${filterAreaMaxHeight(x,d?.offsetHeight||28)}px`,L.style.overflowY=E?"hidden":"auto";}return {element:t,paint(l,i,a={}){t.style.display=i?"":"none";let g=Ye(t);if(t.textContent="",!i)return;let M=pe("pivot-flex");M.style.width="100%";let{t:L,locale:E}=e.getI18n(),x=Ne("filter",L("filterArea"),"filter",ft(l,E),e);M.appendChild(x),t.appendChild(M),r(x,l,a),Ue(t,g);},destroy(){t.removeEventListener("contextmenu",n),t.remove();}}}var gt="kanuni-pivot-drop-indicator";function xn(e){let t=pe(gt);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=pe("");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 r=pe("");Object.assign(r.style,{position:"absolute",bottom:"0",width:"0",height:"0",borderBottom:"5px solid var(--pivot-primary)"}),r.style.setProperty("inset-inline-start","-4px"),r.style.setProperty("border-inline-start","4px solid transparent"),r.style.setProperty("border-inline-end","4px solid transparent");let l=pe("");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,r,l),t}function bt(e,t){for(let n of e){for(let r of n.querySelectorAll(`.${gt}`))r.remove();for(let r of n.querySelectorAll('[data-drop-id$="-ghost-end"]'))r.style.backgroundColor="transparent",r.style.boxShadow="none",r.textContent="";for(let r of n.querySelectorAll(".pivot-area-strip--over"))r.classList.remove("pivot-area-strip--over");for(let r of n.querySelectorAll('[data-drop-kind="list"]'))r.style.backgroundColor="transparent",r.style.boxShadow="none";}if(t.intent==="before"||t.intent==="after"){if(!t.targetId)return;for(let n of e){let r=n.querySelector(`[data-drop-id="${t.targetId}"]`)??n.querySelector(`[data-drop-id="chooser-${t.targetId}"]`);if(r){r.appendChild(xn(t.intent));return}}}else if(t.intent==="append"&&t.targetArea)for(let n of e){let r=n.querySelector(`[data-drop-id="${t.targetArea}-ghost-end"]`)??n.querySelector(`[data-drop-id="chooser-${t.targetArea}-ghost-end"]`);if(r&&(r.style.backgroundColor="color-mix(in srgb, var(--pivot-primary) 10%, transparent)",r.style.boxShadow="inset 0 0 0 1px color-mix(in srgb, var(--pivot-primary) 50%, transparent)",r.getAttribute("data-ghost-populated")==="1")){let a=pe("");Object.assign(a.style,{width:"4px",height:"100%",backgroundColor:"var(--pivot-primary)",borderRadius:"2px",marginLeft:"4px"}),r.appendChild(a);}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 kn={style:{}},Tn=28,xt=5,Mn=10,Ct=40,wt=8,Ze=100;function _(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function J(e,t){for(let[n,r]of Object.entries(t)){if(r==null)continue;let l=n.replace(/[A-Z]/g,i=>"-"+i.toLowerCase());e.style.setProperty(l,typeof r=="number"&&r!==0&&!/z-?index|font-?weight|opacity/i.test(n)?`${r}px`:String(r));}}function We(e,t,n,r){let l=_("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(r,"-3px"),l}function Ie(e,t){e.textContent="",t!=null&&(typeof t=="string"||typeof t=="number"?e.textContent=String(t):e.appendChild(t));}function Et(e){let{host:t,getI18n:n}=e,r=e.columnWidthDefaults??resolveColumnWidthDefaults(),l=e.rowHeight??(()=>Tn),i=e.shared?.cellId??((S,P)=>`pivot-cell-${S}-${P}`),a=_("datagrid-table-wrapper custom-scrollbar pivot-right-pane");J(a,{overflow:"auto",flex:"1 1 auto",minHeight:0,position:"relative",outline:"none"}),a.tabIndex=0,a.setAttribute("role","grid");let g=_("");J(g,{width:"max-content",position:"relative",minWidth:"100%"});let M=_("kanuni-pivot-table","table");M.setAttribute("role","presentation"),J(M,{borderCollapse:"separate",borderSpacing:0,width:0,minWidth:"100%",tableLayout:"fixed"});let L=document.createElement("colgroup"),E=_("","thead");E.setAttribute("role","rowgroup"),J(E,{position:"sticky",top:0,zIndex:50,backgroundColor:"var(--pivot-surface-header)"});let x=_("","tbody");x.setAttribute("role","rowgroup"),M.append(L,E,x),g.appendChild(M),a.appendChild(g),t.appendChild(a);let d=null,h=ze(n().locale),w=n().locale,v={start:-1,end:-1},c={start:0,end:Number.MAX_SAFE_INTEGER},o={},k=new Set,y=false,b=()=>d?Math.max(d.colHeaders.length,1)*l()+(e.chipDeps?42:0):0,p=S=>o[`row-${S}`]??r.rowHeader,u=()=>o[`row-${d.maxRowDepth}`]??Ze,f=S=>o[`leaf-${S}`]??r.data;function C(){if(!d||d.totalDataCols<=Ct){c={start:0,end:Number.MAX_SAFE_INTEGER};return}let S=Math.abs(a.scrollLeft),P=A().total,D=S-P,V=0,X=0;for(;V<d.totalDataCols&&X+f(V)<=D;)X+=f(V),V++;V=Math.max(0,V-wt);let ae=a.clientWidth||0,fe=V,Y=0;for(;fe<d.totalDataCols&&Y<=ae;)Y+=f(fe),fe++;c={start:V,end:Math.min(d.totalDataCols,fe+wt)};}function m(){if(!d)return {start:0,end:0};let S=Math.max(0,a.scrollTop-b()),P=Math.max(0,Math.floor(S/l())-xt),D=Math.ceil((a.clientHeight||600)/l())+Mn;return {start:P,end:Math.min(d.virtualRows.length,P+D+xt)}}function A(){let S=[];for(let P=0;P<d.maxRowDepth;P++)S.push(p(P));return d.showDataInRows&&S.push(u()),computeRowHeaderWidths(S,a.clientWidth)}function R(){let{widths:S,total:P}=A(),D=0;for(let V=0;V<S.length;V++)a.style.setProperty(`--row-header-left-${V}`,`${D}px`),a.style.setProperty(`--col-width-row-${V}`,`${S[V]}px`),k.add(`--col-width-row-${V}`),D+=S[V];a.style.setProperty("--row-header-total-width",`${P}px`);}function F(){L.textContent="";for(let S=0;S<d.maxRowDepth;S++){let P=document.createElement("col");P.style.width=`var(--col-width-row-${S}, ${r.rowHeader}px)`,L.appendChild(P);}if(d.showDataInRows){let S=document.createElement("col");S.style.width=`var(--col-width-row-${d.maxRowDepth}, ${Ze}px)`,L.appendChild(S);}for(let S=0;S<Math.max(d.totalDataCols,1);S++){let P=document.createElement("col");P.style.width=`var(--col-width-data-${S}, ${r.data}px)`,L.appendChild(P);}}function H(){let{colHeaders:S,rowFields:P,colFields:D,dataFields:V,maxRowDepth:X,showDataInRows:ae,layout:fe,dataColOffset:Y}=d,{t:de,locale:T}=n(),s=Ye(E);E.textContent="";let I=Math.max(S.length,1),$=e.chipDeps;if($){let Q=_("","tr");Q.setAttribute("role","row"),J(Q,{height:42});let z=_("","th");z.setAttribute("role","columnheader"),z.colSpan=Math.max(Y,1),J(z,{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)"}),z.style.setProperty("inset-inline-start","0px"),z.appendChild(Ne("data",de("dataArea"),"bar-chart-3",V,$)),Q.appendChild(z);let j=_("","th");j.setAttribute("role","columnheader"),j.colSpan=Math.max(d.totalDataCols,1),J(j,{borderBottom:"1px solid var(--pivot-border)",padding:0,verticalAlign:"top",zIndex:1,backgroundColor:"var(--pivot-surface-header)"});let B=_("");J(B,{position:"sticky",width:"max-content",maxWidth:"100%"}),B.style.setProperty("inset-inline-start","var(--row-header-total-width, 0px)"),B.appendChild(Ne("column",de("columnArea"),"columns3",D,$)),j.appendChild(B),Q.appendChild(j),E.appendChild(Q);}for(let Q=0;Q<I;Q++){let z=_("","tr");if(z.setAttribute("role","row"),J(z,{height:l()}),Q===0){let B=W=>({position:"sticky",top:0,zIndex:60,backgroundColor:"var(--pivot-surface-header)",borderBottom:"1px solid var(--pivot-border)",borderInlineEnd:W?"1px solid var(--pivot-border)":"none",verticalAlign:"bottom",padding:"4px 8px",color:"var(--pivot-text-header)"});if(P.length===0){let W=_("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");W.setAttribute("data-drop-id","row"),W.setAttribute("data-row-header-idx","0"),W.rowSpan=I,W.colSpan=Math.max(Y,1),J(W,{...B(true),padding:"8px",color:"color-mix(in srgb, var(--pivot-text-header, var(--pivot-text)) 70%, transparent)"}),W.style.setProperty("inset-inline-start","var(--row-header-left-0, 0px)"),W.textContent=de("dropHere"),z.appendChild(W);}else if(fe.rowHeaderLayout==="tree"){let W=_("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");if(W.setAttribute("data-row-header-idx","0"),W.rowSpan=I,J(W,B(!ae)),W.style.setProperty("inset-inline-start","var(--row-header-left-0, 0px)"),$){let K=_("");J(K,{display:"flex",flexWrap:"wrap",gap:4});for(let re of P)K.appendChild(Be(re,$));W.appendChild(K);}else Ie(W,P.map(K=>K.caption).join(", "));z.appendChild(W);}else for(let W=0;W<X;W++){let K=_("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");K.setAttribute("data-row-header-idx",String(W)),K.rowSpan=I,J(K,B(W===X-1&&!ae)),K.style.setProperty("inset-inline-start",`var(--row-header-left-${W}, 0px)`);let re=P[W];re&&$?K.appendChild(Be(re,$)):Ie(K,re?.caption??""),z.appendChild(K);}if(ae&&P.length>0){let W=_("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");W.setAttribute("data-row-header-idx",String(X)),W.rowSpan=I,J(W,B(true)),W.style.setProperty("inset-inline-start",`var(--row-header-left-${X}, 0px)`);let K=_("");J(K,{fontSize:10,fontWeight:600,textTransform:"uppercase",textAlign:"center",color:"color-mix(in srgb, var(--pivot-text-header, var(--pivot-text)) 80%, transparent)"}),K.style.letterSpacing="0.05em",K.textContent=de("dataArea"),W.appendChild(K),z.appendChild(W);}}let j=S[Q]??[];for(let B of j){let W=B.fieldId?D.find(oe=>oe.id===B.fieldId):void 0,K=!!W?.filterValues&&W.filterValues.size>0,re=B.leafStart,ge=W&&!B.isTotal?formatDimensionValue(B.caption,W,"grid",T):B.caption,ce={text:typeof W?.cellTemplate=="function"?W.cellTemplate({value:B.caption,displayValue:ge,field:W})??null:String(ge??""),style:{textAlign:"left",fontWeight:B.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:W?"pointer":"context-menu",position:"relative",zIndex:1,padding:"4px 6px"},className:`kanuni-pivot-header-cell group ${B.isTotal?"kanuni-pivot-header-total":""}`};e.onCellPrepared?.({area:"column",cell:null,rowIndex:Q,columnIndex:re,cellConfig:ce});let Z=_(ce.className,"th");Z.setAttribute("role","columnheader"),B.hasChildren&&Z.setAttribute("aria-expanded",String(!!B.isExpanded)),Z.colSpan=B.colSpan,Z.rowSpan=B.rowSpan,J(Z,ce.style);let ee=_("pivot-flex pivot-items-center");if(J(ee,{gap:4}),B.hasChildren){let oe=_("kanuni-pivot-expand-icon","span");oe.textContent=B.isExpanded?"\u2212":"+",oe.setAttribute("aria-hidden","true"),oe.setAttribute("data-col-expand",B.colPath??""),J(oe,{cursor:"pointer",marginRight:4,flexShrink:0}),ee.appendChild(oe);}let Ee=_("select-none","span");Ie(Ee,ce.text),ee.appendChild(Ee);let Ce=d.rowFields.find(oe=>oe.sortBySummaryField===B.fieldId&&(oe.sortBySummaryPath||"")===(B.colPath||""));if(Ce){let oe=_("pivot-text-primary kanuni-pivot-sort-arrow","span");oe.appendChild(q(Ce.sortOrder==="asc"?"arrow-up":"arrow-down",12)),ee.appendChild(oe);}if(B.fieldId){let oe=_(`kanuni-pivot-head-filter cursor-pointer transition-opacity ${K?"opacity-100 pivot-text-danger":"opacity-0 group-hover:opacity-70"}`,"span");oe.setAttribute("data-filter-field",B.fieldId),oe.appendChild(K?Fe("filter",10):q("filter",10)),ee.appendChild(oe);}Z.appendChild(ee),B.fieldId&&Z.setAttribute("data-header-field",B.fieldId),B.colPath!==void 0&&Z.setAttribute("data-header-col-path",B.colPath),Z.setAttribute("data-header-depth",String(Q)),Z.appendChild(We(`leaf-${re}-${B.colSpan}`,r.data,B.colSpan,"right")),z.appendChild(Z);}E.appendChild(z);}Ue(E,s);}function G(S,P,D,V){let X=P.flatRow,{rowFields:ae,layout:fe,maxRowDepth:Y,virtualRows:de}=d,{locale:T}=n(),s=fe.rowHeaderLayout==="tree",I=s?X.depth:V,$=X.pathValues[I],Q=X.rowSpans[V]>0&&P.dfIndex===0,z=ae[I],j=z&&$!==null&&$!==void 0?formatDimensionValue($,z,"grid",T):$,B=I===X.depth,W=I<X.depth,K=B?X.hasChildren:W,re=B?X.isExpanded:W,ge=de[D+1],me=!s&&ge&&!ge.isGrandTotal&&ge.flatRow&&!ge.flatRow.isSubtotal&&(ge.flatRow.rowSpans[V]===0||ge.dfIndex>0)&&ge.flatRow.pathValues[V]===$,ce=j!=null?String(j):null;typeof z?.cellTemplate=="function"&&ce!==null&&(ce=z.cellTemplate({value:j,displayValue:j,field:z})??ce);let Z={text:ce,style:{position:"sticky",backgroundColor:"var(--pivot-surface)",zIndex:40,cursor:K?"pointer":"default",fontWeight:j&&I<X.depth?600:400,verticalAlign:"middle",padding:0,borderBottom:me?"none":"1px solid var(--pivot-border)",height:l()},className:`kanuni-pivot-cell kanuni-pivot-row-header ${K?"kanuni-pivot-row-expandable":""}${e.shared?.focused?.r===D&&e.shared?.focused?.c===V?" kanuni-pivot-cell-focused":""}${$e(e.shared?.selection??null,D,V)?" kanuni-pivot-cell-selected":""}`};e.onCellPrepared?.({area:"row",cell:null,rowIndex:D,columnIndex:V,cellConfig:Z});let ee=_(Z.className,"td");if(ee.id=i(D,V),ee.setAttribute("role","rowheader"),K&&ee.setAttribute("aria-expanded",String(re)),ee.setAttribute("data-r",String(D)),ee.setAttribute("data-c",String(V)),J(ee,Z.style),ee.style.setProperty("inset-inline-start",`var(--row-header-left-${V}, 0px)`),!s&&V>=X.depth&&V<Y-1&&ee.style.setProperty("border-inline-end","none"),!Q&&!s){ee.style.borderBottom="none",ee.appendChild(We(`row-${V}`,r.rowHeader,1,n().rtl?"left":"right")),S.appendChild(ee);return}let Ee=s?X.depth*20:0,Ce=_("");if(J(Ce,{display:"flex",alignItems:"center",gap:4,padding:"0 8px",height:"100%",position:"relative"}),Ce.style.setProperty("padding-inline-start",`${8+Ee}px`),s&&X.depth>0){let oe=_("kanuni-pivot-tree-line");J(oe,{position:"absolute",left:Ee,top:-l()/2,width:12,height:l(),borderLeft:"1px dotted var(--pivot-border)",borderBottom:"1px dotted var(--pivot-border)"}),Ce.appendChild(oe);}if(Z.text!==null&&Z.text!==void 0){if(K){let ke=_("kanuni-pivot-expand-icon","span");ke.textContent=re?"\u2212":"+",ke.setAttribute("aria-hidden","true"),J(ke,{flexShrink:0,position:"relative",zIndex:2}),Ce.appendChild(ke);}else {let ke=_("","span");J(ke,{width:14,flexShrink:0}),Ce.appendChild(ke);}let oe=_("truncate","span");Ie(oe,Z.text),Ce.appendChild(oe);}ee.appendChild(Ce),ee.appendChild(We(`row-${V}`,r.rowHeader,1,n().rtl?"left":"right")),S.appendChild(ee);}function O(S,P,D,V,X){let{dataFields:ae,leafColHashes:fe,dfsPerLeaf:Y,dataColOffset:de,showDataInRows:T,totalDataCols:s}=d,I=s>Ct,$=e.registry?e.registry.getPluginsByType("cellRender"):null;fe.forEach((Q,z)=>{let j=z*Y,B=T?[ae[D]]:ae,W=I&&(j+Y<=c.start||j>=c.end),K=W?null:_e(d,P,Q.hash,V,Q.isGrandTotal);B.forEach((re,ge)=>{let me=j+ge,ce=de+me,Z=_("kanuni-pivot-cell","td");if(Z.id=i(X,ce),Z.setAttribute("role","gridcell"),Z.setAttribute("data-r",String(X)),Z.setAttribute("data-c",String(ce)),W||I&&(me<c.start||me>=c.end)){S.appendChild(Z);return}let ee=K?.values[`${re.id}_display`]??K?.values[re.id],Ee=h(ee,re),Ce=V||Q.isGrandTotal||!!K?.isTotalCell,oe=re.conditionalFormatting?resolveConditionalVisual(K?.values[re.id],re,K??null,d.fieldRanges[re.id]):kn,ke=oe.style,je=Ee;if(typeof re.cellTemplate=="function")je=re.cellTemplate({value:ee,displayValue:Ee,cell:K,field:re})??null;else if($){for(let Te of $)if(Te.renderCell){let qe=Te.renderCell(ee,Ee,K,re);if(qe!=null){je=qe;break}}}let Oe={text:je,style:{textAlign:re.dataType==="number"?"right":"left",fontWeight:Ce?600:400,backgroundColor:Ce?"var(--pivot-bg)":"transparent",cursor:e.hasCellClick?.()&&K?"pointer":"default",...ke},className:`kanuni-pivot-cell ${Ce?"kanuni-pivot-cell-total":""}${e.shared?.focused?.r===X&&e.shared?.focused?.c===ce?" kanuni-pivot-cell-focused":""}${$e(e.shared?.selection??null,X,ce)?" kanuni-pivot-cell-selected":""}`};if(e.onCellPrepared?.({area:"data",cell:K,rowIndex:X,columnIndex:ce,cellConfig:Oe}),Z.className=Oe.className,J(Z,Oe.style),Z.setAttribute("data-val",typeof ee=="number"?String(ee):""),Ie(Z,Oe.text),oe.dataBar){let Te=Math.round(oe.dataBar.ratio*100);Z.style.setProperty("background-image",`linear-gradient(to ${n().rtl?"left":"right"}, ${oe.dataBar.color} ${Te}%, transparent ${Te}%)`),Z.style.setProperty("background-repeat","no-repeat");}if(oe.icon){let Te=q(oe.icon,12);Te.style.setProperty("margin-inline-end","4px"),Te.style.setProperty("vertical-align","middle"),Z.insertBefore(Te,Z.firstChild);}S.appendChild(Z);});});}let N=(S,P)=>e.shared?.focused?.r===S&&e.shared?.focused?.c===P?" kanuni-pivot-cell-focused":"";function U(S){let P=S.flatRow;return S.isGrandTotal||!P?{level:1}:P.isSubtotal||!P.hasChildren?{level:P.depth+1}:{level:P.depth+1,expanded:!!P.isExpanded}}function we(S,P){let{t:D}=n(),{maxRowDepth:V,showDataInRows:X,dataFields:ae,layout:fe}=d,Y=_("kanuni-pivot-row","tr");if(Y.setAttribute("role","row"),Y.setAttribute("aria-rowindex",String(P+1)),J(Y,{height:l()}),fe.rowHeaderLayout==="tree"){let T=U(S);Y.setAttribute("aria-level",String(T.level)),T.expanded!==void 0&&Y.setAttribute("aria-expanded",String(T.expanded));}if(S.isGrandTotal){Y.classList.add("kanuni-pivot-grand-total-row");for(let T=0;T<V;T++){let s=T===0,I=_("kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total"+N(P,T),"td");I.id=i(P,T),I.setAttribute("role",s?"rowheader":"presentation"),J(I,{position:"sticky",zIndex:40,fontWeight:700,backgroundColor:"var(--pivot-surface)",paddingLeft:s?8:0,paddingRight:0,borderRight:T===V-1?"1px solid var(--pivot-border)":"none",whiteSpace:s?"nowrap":"normal",overflow:s?"visible":"hidden"}),I.style.setProperty("inset-inline-start",`var(--row-header-left-${T}, 0px)`),s&&(I.textContent=`${D("grandTotal")}${X?` \u2014 ${ae[S.dfIndex]?.caption??""}`:""}`),Y.appendChild(I);}if(X){let T=_("kanuni-pivot-cell kanuni-pivot-cell-total"+N(P,V),"td");T.id=i(P,V),T.setAttribute("role","gridcell"),J(T,{position:"sticky",zIndex:40,backgroundColor:"var(--pivot-surface)"}),T.style.setProperty("inset-inline-start",`var(--row-header-left-${V}, 0px)`),T.textContent=String(ae[S.dfIndex]?.caption??""),Y.appendChild(T);}return O(Y,"",S.dfIndex,true,P),Y}let de=S.flatRow;if(de.isSubtotal){Y.classList.add("kanuni-pivot-subtotal-row");let T=`${D("subTotal")}: ${de.pathValues[de.depth]}`;if(fe.rowHeaderLayout==="tree"){let s=_("kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total"+N(P,0),"td");s.id=i(P,0),s.setAttribute("role","rowheader"),J(s,{position:"sticky",zIndex:40,fontWeight:600,backgroundColor:"var(--pivot-surface)",paddingLeft:8+de.depth*20}),s.style.setProperty("inset-inline-start","var(--row-header-left-0, 0px)"),s.textContent=T,Y.appendChild(s);}else for(let s=0;s<V;s++){if(s<de.depth){G(Y,S,P,s);continue}let I=s===de.depth,$=_("kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total"+N(P,s),"td");$.id=i(P,s),$.setAttribute("role",I?"rowheader":"presentation"),J($,{position:"sticky",zIndex:40,fontWeight:600,backgroundColor:"var(--pivot-surface)",paddingLeft:I?8:0,paddingRight:0,borderRight:s===V-1?"1px solid var(--pivot-border)":"none",whiteSpace:I?"nowrap":"normal",overflow:I?"visible":"hidden"}),$.style.setProperty("inset-inline-start",`var(--row-header-left-${s}, 0px)`),I&&($.textContent=T),Y.appendChild($);}if(X){let s=_("kanuni-pivot-cell kanuni-pivot-cell-total"+N(P,V),"td");s.id=i(P,V),s.setAttribute("role","gridcell"),J(s,{position:"sticky",zIndex:40,backgroundColor:"var(--pivot-surface)"}),s.style.setProperty("inset-inline-start",`var(--row-header-left-${V}, 0px)`),s.textContent=String(ae[S.dfIndex]?.caption??""),Y.appendChild(s);}return O(Y,de.key,S.dfIndex,true,P),Y}for(let T=0;T<V;T++)G(Y,S,P,T);if(X){let T=_("kanuni-pivot-cell kanuni-pivot-row-header"+N(P,V),"td");if(T.id=i(P,V),T.setAttribute("role","rowheader"),J(T,{position:"sticky",zIndex:40,backgroundColor:"var(--pivot-surface)"}),T.style.setProperty("inset-inline-start",`var(--row-header-left-${V}, 0px)`),S.isDataRow){let s=_("","span");J(s,{color:"var(--pivot-text-muted)",paddingLeft:8}),s.textContent=String(ae[S.dfIndex]?.caption??""),T.appendChild(s);}T.appendChild(We(`row-${V}`,Ze,1,n().rtl?"left":"right")),Y.appendChild(T);}return O(Y,de.key,S.dfIndex,false,P),Y}function ie(){if(y||!d)return;let S=m();if(C(),v=S,x.textContent="",S.start>0){let P=_("","tr");J(P,{height:S.start*l()});let D=_("","td");D.colSpan=d.dataColOffset+Math.max(d.totalDataCols,1),J(D,{padding:0,border:"none"}),P.appendChild(D),x.appendChild(P);}for(let P=S.start;P<S.end;P++)x.appendChild(we(d.virtualRows[P],P));J(g,{height:b()+d.virtualRows.length*l()});}function le(S){if(y)return;let P=n();P.locale!==w&&(w=P.locale,h=ze(P.locale)),o=S.columnWidths??{},d=dt(S,{grandTotal:P.t("grandTotal"),subTotal:P.t("subTotal")}),a.setAttribute("role",d.layout.rowHeaderLayout==="tree"?"treegrid":"grid"),a.setAttribute("aria-rowcount",String(d.virtualRows.length+d.colHeaders.length+(e.chipDeps?1:0))),a.setAttribute("aria-colcount",String(d.dataColOffset+d.totalDataCols)),a.setAttribute("aria-label",P.t("pivotView"));let D=e.shared?.focused;D?a.setAttribute("aria-activedescendant",i(D.r,D.c)):a.removeAttribute("aria-activedescendant");for(let V of k)a.style.removeProperty(V);k.clear(),R();for(let[V,X]of Object.entries(o)){if(!V.startsWith("leaf-"))continue;let ae=`--col-width-data-${V.slice(5)}`;a.style.setProperty(ae,`${X}px`),k.add(ae);}F(),H(),v={start:-1,end:-1},ie();}let ve=()=>{if(y||!d)return;let S=m(),P=c.start;C(),(S.start!==v.start||S.end!==v.end||c.start!==P)&&ie();};a.addEventListener("scroll",ve,{passive:true});let ye=()=>{if(y||!d)return;R();let S=m(),P=c.start,D=c.end;C(),(S.start!==v.start||S.end!==v.end||c.start!==P||c.end!==D)&&ie();},se=typeof ResizeObserver<"u"?new ResizeObserver(()=>ye()):null;return se?.observe(a),{getVM:()=>d,getTheadHeight:b,paintStructural:le,paintWindow:ie,refreshWindow:ye,rowHeaderLayout(){let S=[];if(d){for(let P=0;P<d.maxRowDepth;P++)S.push(p(P));d.showDataInRows&&S.push(u());}return {configured:S,viewport:a.clientWidth}},scroller:a,destroy(){y=true,se?.disconnect(),a.removeEventListener("scroll",ve),a.remove();}}}var Sn=0;function kt(){let e=`kp${++Sn}-`;return {lastResizeTime:0,isResizing:false,focused:null,selection:null,cellId:(t,n)=>`${e}pivot-cell-${t}-${n}`}}function Tt(e){let{scroller:t,controller:n,getVM:r,shared:l}=e,i=c=>c?.closest?.("td[data-r][data-c]")??null;function a(c,o){let k=l.focused;l.focused={r:c,c:o},k&&t.querySelector(`td[id="${l.cellId(k.r,k.c)}"]`)?.classList.remove("kanuni-pivot-cell-focused"),t.querySelector(`td[id="${l.cellId(c,o)}"]`)?.classList.add("kanuni-pivot-cell-focused"),t.setAttribute("aria-activedescendant",l.cellId(c,o));}function g(c,o,k){if(!e.onCellClick)return;let y=r();if(!y)return;let b=pt(y,o,k);if(!b)return;let p={event:c,cellType:b.isTotal?"grandTotal":"data",value:b.val,rowPath:b.cell.rowPath,colPath:b.cell.colPath};e.onCellClick(e.resolveCellClick?e.resolveCellClick(p):p);}let M=c=>{let o=c.target,k=o.closest("[data-col-expand]");if(k){n.toggleColExpanded(k.getAttribute("data-col-expand")??"");return}if(o.closest(".kanuni-pivot-resize-handle"))return;let y=o.closest("[data-filter-field]");if(y){e.onFilterClick?.(c.clientX,c.clientY,y.getAttribute("data-filter-field")??"");return}let b=o.closest("th[data-header-field]");if(b){if(Date.now()-l.lastResizeTime<100)return;let m=r();if(!m)return;let A=b.getAttribute("data-header-field")??"",R=b.getAttribute("data-header-col-path")??"",F=m.rowFields.find(H=>H.sortBySummaryField===A&&(H.sortBySummaryPath||"")===R);F&&n.sortField(F.id,F.sortOrder==="asc"?"desc":"asc");return}let p=i(o);if(!p)return;let u=Number(p.getAttribute("data-r")),f=Number(p.getAttribute("data-c")),C=r();if(C){if(t.focus({preventScroll:true}),a(u,f),f<C.dataColOffset){if(Date.now()-l.lastResizeTime<100)return;let m=Xe(C,u,f);m?.hasChildren&&n.toggleExpanded(m.cellHashStr);return}g(c,u,f);}},L=c=>{let o=i(c.target);if(!o)return;let k=Number(o.getAttribute("data-r")),y=Number(o.getAttribute("data-c")),b=r();!b||y<b.dataColOffset||g(c,k,y);},E=c=>{let o=c.target.closest?.("th[data-header-field]");if(o){c.preventDefault(),o.hasAttribute("aria-expanded")?e.onNodeContextMenu?.({x:c.clientX,y:c.clientY,path:o.getAttribute("data-header-col-path")??"",isExpanded:o.getAttribute("aria-expanded")==="true",depth:Number(o.getAttribute("data-header-depth")??0),type:"col"}):e.onHeaderContextMenu&&e.onHeaderContextMenu(c.clientX,c.clientY,o.getAttribute("data-header-field")??"",o.getAttribute("data-header-col-path")??void 0);return}let k=i(c.target);if(!k)return;let y=Number(k.getAttribute("data-r")),b=Number(k.getAttribute("data-c")),p=r();if(p){if(b<p.dataColOffset){let u=Xe(p,y,b);if(u){let{flatRow:f,hasChildren:C,cellHashStr:m,isExpanded:A,depth:R,dIdx:F}=u,H=p.layout.rowHeaderLayout==="tree",G=F>f.depth,O=G?f.hasChildren:C;if(O&&e.onNodeContextMenu){c.preventDefault(),e.onNodeContextMenu({x:c.clientX,y:c.clientY,path:G?H?f.key:pathKey(f.pathValues.slice(0,f.depth+1)):m,isExpanded:G?f.isExpanded:A,depth:G?f.depth:R,type:"row"});return}if(O)return}}e.onGlobalContextMenu&&(c.preventDefault(),e.onGlobalContextMenu(c.clientX,c.clientY));}},x=e.keyboardEnabled!==false;function d(){let c=l.focused;l.focused=null,c&&t.querySelector(`td[id="${l.cellId(c.r,c.c)}"]`)?.classList.remove("kanuni-pivot-cell-focused"),t.removeAttribute("aria-activedescendant");}let h=c=>{if(c.target!==t||!l.focused)return;let o=r();if(!o)return;let{r:k,c:y}=l.focused,b=o.dataColOffset+o.totalDataCols,p=e.rowHeight?.()??28,u=e.getTheadHeight?.()??o.colHeaders.length*p,f=Math.max(1,Math.ceil(((t.clientHeight||600)-u)/p));switch(c.key){case "ArrowDown":c.preventDefault(),k=Math.min(o.virtualRows.length-1,k+1);break;case "ArrowUp":c.preventDefault(),k=Math.max(0,k-1);break;case "ArrowRight":c.preventDefault(),y=Math.min(b-1,y+1);break;case "ArrowLeft":c.preventDefault(),y=Math.max(0,y-1);break;case "Home":c.preventDefault(),(c.ctrlKey||c.metaKey)&&(k=0),y=0;break;case "End":c.preventDefault(),(c.ctrlKey||c.metaKey)&&(k=o.virtualRows.length-1),y=b-1;break;case "PageDown":c.preventDefault(),k=Math.min(o.virtualRows.length-1,k+f-1);break;case "PageUp":c.preventDefault(),k=Math.max(0,k-f+1);break;case "Escape":c.preventDefault(),d();return;case " ":case "Enter":{c.preventDefault();let A=t.querySelector(`td[id="${l.cellId(k,y)}"]`);A&&(c.key===" "?A.click():A.dispatchEvent(new MouseEvent("dblclick",{bubbles:true})));return}default:return}let C=u+k*p,m=t.clientHeight||600;C<t.scrollTop+u?(t.scrollTop=C-u,t.dispatchEvent(new Event("scroll"))):C+p>t.scrollTop+m&&(t.scrollTop=C+p-m,t.dispatchEvent(new Event("scroll"))),a(k,y);},w=c=>{let o=r();o&&!l.focused&&c.target===t&&o.virtualRows.length>0&&a(0,0);},v=c=>{c.relatedTarget&&t.contains(c.relatedTarget)||d();};return t.addEventListener("click",M),t.addEventListener("dblclick",L),t.addEventListener("contextmenu",E),x?(t.addEventListener("keydown",h),t.addEventListener("focus",w),t.addEventListener("blur",v)):t.removeAttribute("tabindex"),{destroy(){t.removeEventListener("click",M),t.removeEventListener("dblclick",L),t.removeEventListener("contextmenu",E),x&&(t.removeEventListener("keydown",h),t.removeEventListener("focus",w),t.removeEventListener("blur",v));}}}function Mt(e){let{host:t,scroller:n,shared:r}=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,a=1,g=0,M=0,L=[],E={},x=null,d=-1,h=o=>{let k=t.getBoundingClientRect();l.style.display="block",l.style.transform=`translateX(${o-k.left}px)`;},w=o=>{r.isResizing&&h(o.clientX);},v=o=>{if(!r.isResizing||!i)return;l.style.display="none";let k=o.clientX-g,y=e.isRtl()?-k:k;if(i.startsWith("row-")){let b=Math.max(20,M+y);E[i]=x?invertRowHeaderWidth(x.configured,d,b,x.viewport):b;}else if(i.startsWith("leaf-")){let b=i.split("-"),p=parseInt(b[1],10),f=Math.max(a*20,M+y)/M;for(let C=0;C<a;C++)E[`leaf-${p+C}`]=Math.max(20,L[C]*f);}r.isResizing=false,r.lastResizeTime=Date.now(),i=null,document.body.style.cursor="",document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",v),e.commit({...E});},c=o=>{let k=o.target.closest?.(".kanuni-pivot-resize-handle");if(!k||(o.preventDefault(),o.stopPropagation(),i=k.getAttribute("data-resize-id"),!i))return;let y=Number(k.getAttribute("data-resize-default")||150);if(a=Number(k.getAttribute("data-resize-span")||1),g=o.clientX,E={...e.getWidths()},i.startsWith("row-"))d=parseInt(i.slice(4),10),x=e.rowHeaderLayout(),M=computeRowHeaderWidths(x.configured,x.viewport).widths[d]??E[i]??y;else if(i.startsWith("leaf-")){let b=parseInt(i.split("-")[1],10);L=[],M=0;for(let p=0;p<a;p++){let u=E[`leaf-${b+p}`]||y;L.push(u),M+=u;}}r.isResizing=true,h(o.clientX),document.body.style.cursor="col-resize",document.addEventListener("mousemove",w),document.addEventListener("mouseup",v);};return n.addEventListener("mousedown",c),{destroy(){n.removeEventListener("mousedown",c),r.isResizing&&(r.isResizing=false,document.body.style.cursor=""),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",v),l.remove();}}}function Lt(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Re(e){let t=Lt("kanuni-pivot-root kanuni-pivot-portal-container");e.classList.contains("kanuni-pivot-striped")&&t.classList.add("kanuni-pivot-striped"),t.setAttribute("style",e.getAttribute("style")??"");for(let r of ["position","inset","z-index","width","height"])t.style.removeProperty(r);let n=e.getAttribute("data-theme");return n&&t.setAttribute("data-theme",n),t.setAttribute("dir",e.getAttribute("dir")??"ltr"),t}function He(){let e=document,t=e.fullscreenElement??e.webkitFullscreenElement??null;return t||(document.querySelector(".pivot-is-fullscreen")??document.body)}function Je(e){let t=null,n=null;function r(){n?.(),n=null,t?.remove(),t=null;}function l(i){r(),t=Re(e);let a=Lt("kanuni-pivot-portal-root");t.appendChild(a),He().appendChild(t);let g=i(a),M=t,L=x=>{M.contains(x.target)||r();},E=x=>{x.key==="Escape"&&r();};return document.addEventListener("pointerdown",L,true),document.addEventListener("keydown",E,true),n=()=>{document.removeEventListener("pointerdown",L,true),document.removeEventListener("keydown",E,true),g?.();},a}return {openPopup:l,closePopup:r,isOpen:()=>t!==null,destroy:r}}var St=new Map,Pt=new Map;function Rt(e,t,n,r="(Blanks)"){if(e==null)return r;if(t.format&&typeof e=="number")try{let l=t.format,i=JSON.stringify(l)+"_"+n,a=Pt.get(i);a||(a=new Intl.NumberFormat(n,l),Pt.set(i,a));let g=a.format(e);return l.isCustom&&(l.prefix||l.suffix)?`${l.prefix||""}${g}${l.suffix||""}`:g}catch{return String(e)}return String(e)}var Me=28;function he(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}var zn="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 $n(){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",zn),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.5"),t.setAttribute("stroke-linecap","round"),e.appendChild(t),e}function At(e){let{portal:t}=e;function n(r,l,i){let a=e.getField(i);if(!a)return;let{t:g,rtl:M,locale:L}=e.getI18n(),E=true,x=[],d="",h=new Set,w=0,v=220,c=false,o=[];t.openPopup(k=>{let y=he("kanuni-pivot-popup pivot-animate-zoom-in"),b=popupViewport(),p=placePopup({x:r,y:l},{width:250,height:350},{margin:10,viewport:b});y.setAttribute("role","dialog"),y.setAttribute("aria-label",g("columnFilter")),y.setAttribute("data-datagrid-keyboard-scope","modal"),y.tabIndex=-1,Object.assign(y.style,{left:`${p.left}px`,top:`${p.top}px`,width:"250px",height:`${Math.min(350,p.maxHeight)}px`,minWidth:"200px",minHeight:`${Math.min(250,p.maxHeight)}px`,maxWidth:`${Math.min(600,b.width-20)}px`,maxHeight:`${Math.min(350,p.maxHeight)}px`,resize:"both",direction:M?"rtl":"ltr"});let u=he("kanuni-pivot-popup-header"),f=he("kanuni-pivot-popup-search");f.appendChild($n());let C=he("kanuni-pivot-popup-search-input","input");C.type="text",C.placeholder=g("search"),C.setAttribute("aria-controls","pivot-filter-options"),f.appendChild(C),u.appendChild(f);let m=he("kanuni-pivot-popup-actions"),A=he("kanuni-pivot-popup-action-btn kanuni-pivot-popup-action-btn--primary","button");A.textContent=g("selectAll");let R=he("kanuni-pivot-popup-action-btn kanuni-pivot-popup-action-btn--danger","button");R.textContent=g("clearAll"),m.append(A,R),u.appendChild(m);let F=he("kanuni-pivot-popup-list pivot-custom-scrollbar");F.id="pivot-filter-options";let H=he("");H.style.position="relative",F.appendChild(H);let G=he("kanuni-pivot-popup-footer"),O=he("kanuni-pivot-btn kanuni-pivot-btn--outline","button");O.textContent=g("cancel");let N=he("kanuni-pivot-btn kanuni-pivot-btn--primary","button");N.textContent=g("ok");for(let T of [O,N])Object.assign(T.style,{height:"28px",padding:"0 12px",fontSize:"12px"});if(G.append(O,N),e.openCondition&&(a.area==="row"||a.area==="column")){let T=he("kanuni-pivot-btn kanuni-pivot-btn--outline","button");T.type="button",T.setAttribute("data-condition-filter",""),T.title=g("conditionFilter")+"\u2026",T.setAttribute("aria-label",T.title),Object.assign(T.style,{height:"28px",padding:"0 7px",marginInlineEnd:"auto"}),(a.valueFilter||a.labelFilter)&&(T.style.color="var(--pivot-danger)"),T.appendChild(q("settings-2",14)),T.addEventListener("click",()=>{t.closePopup(),e.openCondition(a.id);}),G.prepend(T);}y.append(u,F,G),k.appendChild(y);let U=()=>{if(!d)return x;let T=d.toLowerCase(),s=T.replace(/,/g,"."),I=T.replace(/\./g,","),$=T.replace(/[.,\s]/g,"");return x.filter(Q=>{let z=Q.label.toLowerCase(),j=z.replace(/[.,\s]/g,"");return z.includes(T)||z.includes(s)||z.includes(I)||!!$&&j.includes($)})},we=()=>h.size===x.length,ie=()=>!d,le=()=>U().length+(ie()?1:0),ve=()=>le()===0?-1:Math.min(w,le()-1),ye=T=>{if(ie()&&T===0)return "select-all";let s=ie()?T-1:T;return `value:${U()[s]?.rawStr}`},se=new Map;function S(){if(c)return;let T=document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains("kanuni-pivot-popup-item");if(N.disabled=!E&&x.length>0&&h.size===0,H.textContent="",se.clear(),E){H.style.height="";let j=he("pivot-flex pivot-items-center pivot-justify-center pivot-h-full"),B=he("");Object.assign(B.style,{width:"24px",height:"24px",border:"2px solid var(--pivot-border)",borderTopColor:"var(--pivot-primary)",borderRadius:"50%",animation:"spin 1s linear infinite"}),j.appendChild(B),H.appendChild(j);return}let s=U(),I=le();H.style.height=`${I*Me}px`;let $=Math.max(0,Math.floor(F.scrollTop/Me)-2),Q=Math.min(I,$+Math.ceil(v/Me)+4),z=ve();for(let j=$;j<Q;j++){let B,W,K,re,ge;if(ie()&&j===0)B="select-all",W=`(${g("selectAll")})`,K=we(),re=true,ge=D;else {let ee=s[ie()?j-1:j];if(!ee)continue;B=`value:${ee.rawStr}`,W=ee.label,K=h.has(ee.rawStr),re=false,ge=()=>V(ee.rawStr);}let me=he(`kanuni-pivot-popup-item${K?" kanuni-pivot-popup-item--checked":""}${j===z?" kanuni-pivot-popup-item--active":""}`);me.id=B,me.setAttribute("role","checkbox"),me.setAttribute("aria-checked",String(K)),me.tabIndex=0,Object.assign(me.style,{position:"absolute",top:`${j*Me}px`,insetInlineStart:"0",insetInlineEnd:"0",height:`${Me}px`,fontWeight:re?"600":"400"});let ce=he("kanuni-pivot-checkbox","input");ce.type="checkbox",ce.checked=K,ce.readOnly=true,ce.tabIndex=-1;let Z=he("pivot-truncate","span");Z.textContent=W,me.append(ce,Z),me.addEventListener("click",ge),me.addEventListener("focus",()=>{w=j;}),H.appendChild(me),se.set(j,me);}if(s.length===0){let j=he("");Object.assign(j.style,{padding:"12px",textAlign:"center",fontSize:"12px",color:"var(--pivot-text-muted)"}),j.textContent=g("noItems"),H.appendChild(j);}C.setAttribute("aria-activedescendant",z>=0?ye(z):""),T&&se.get(z)?.focus();}function P(T){h=new Set(h);for(let s of U())T?h.add(s.rawStr):h.delete(s.rawStr);S();}function D(){P(!U().every(T=>h.has(T.rawStr)));}function V(T){h.has(T)?h.delete(T):h.add(T),S();}function X(){if(N.disabled)return;let T=headerFilterWrite(x,h,a);T.kind==="clear"?e.clear(a.id):T.kind==="apply"&&e.apply(a.id,T.values,T.filterType),t.closePopup();}function ae(T){w=Math.max(0,Math.min(le()-1,T));let s=w*Me;s<F.scrollTop?F.scrollTop=s:s+Me>F.scrollTop+v&&(F.scrollTop=s+Me-v),S(),se.get(w)?.focus();}let fe=T=>{if(T.key==="ArrowDown"||T.key==="ArrowUp"){if(T.preventDefault(),le()===0)return;ae(ve()+(T.key==="ArrowDown"?1:-1));return}if(T.key==="Home"&&le()>0){T.preventDefault(),ae(0);return}if(T.key==="End"&&le()>0){T.preventDefault(),ae(le()-1);return}if(T.key==="Backspace"&&T.target!==C){T.preventDefault(),C.focus(),d=d.slice(0,-1),C.value=d,w=0,S();return}if(T.key===" "||T.code==="Space"){if(T.target===C)return;T.preventDefault();let s=ve();if(le()>0&&s>=0)if(ie()&&s===0)D();else {let I=U()[ie()?s-1:s];I&&V(I.rawStr);}return}if(T.key==="Enter"){T.preventDefault(),X();return}if(T.key==="Escape"){T.stopPropagation(),t.closePopup();return}T.key.length===1&&!T.ctrlKey&&!T.metaKey&&!T.altKey&&T.target!==C&&(T.preventDefault(),C.focus(),d+=T.key,C.value=d,w=0,S());},Y=T=>{fe(T),T.defaultPrevented&&T.stopPropagation();};document.addEventListener("keydown",Y,true),y.addEventListener("click",T=>T.stopPropagation()),C.addEventListener("input",()=>{d=C.value,w=0,S();}),A.addEventListener("click",D),R.addEventListener("click",()=>P(false)),O.addEventListener("click",()=>t.closePopup()),N.addEventListener("click",X),F.addEventListener("scroll",()=>{St.set(a.id,F.scrollTop),S();});let de=typeof ResizeObserver<"u"?new ResizeObserver(T=>{for(let s of T)v=s.contentRect.height;}):null;return de?.observe(F),S(),C.focus(),o.push(setTimeout(()=>{if(c)return;if(!a.dataField&&!a.isCalculated){x=[],E=false,S();return}let T=getFieldDistinctValues(a.id,e.gridId);if(T)x=T.map(I=>({rawStr:I.rawStr==="null"||I.rawStr==="undefined"?g("blanks"):I.rawStr,rawVal:I.rawVal,label:Rt(I.rawVal,a,L,g("blanks"))}));else {let I=new Map,$=e.getData();for(let z=0;z<$.length;z++){let j=extractGroupValue($[z],a);if(j==="(Blank)"&&a.calculateSummaryExpression)continue;let B=j==null?g("blanks"):String(j);I.has(B)||I.set(B,j);}let Q=Array.from(I.values());if(a.dataType==="number")Q.sort((z,j)=>Number(z)-Number(j));else {let z=collatorFor().compare;Q.sort((j,B)=>z(String(j),String(B)));}x=Q.map(z=>({rawStr:z==null?g("blanks"):String(z),rawVal:z,label:Rt(z,a,L,g("blanks"))}));}h=headerFilterShown(x,a),E=false,S();let s=St.get(a.id)||0;s>0&&o.push(setTimeout(()=>{c||(F.scrollTop=s,S());},50)),o.push(setTimeout(()=>{c||C.focus();},50));},10)),()=>{c=true,document.removeEventListener("keydown",Y,true);for(let T of o)clearTimeout(T);de?.disconnect();}});}return {open:n,close:()=>t.closePopup()}}function be(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Ft(e){let t=be("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,r=null,l=null,i=null;function a(){n=null,r?.remove(),r=null,l?.classList.remove("kanuni-pivot-footer-btn--active"),l=null;}let g=y=>{e.onGlobalContextMenu&&(y.preventDefault(),e.onGlobalContextMenu(y.clientX,y.clientY));};t.addEventListener("contextmenu",g);let M=y=>{!n||y.target?.closest?.("[data-footer-menu]")?.getAttribute("data-footer-menu")===n||a();};document.addEventListener("mousedown",M);let L=be("kanuni-pivot-search","input");L.type="search";let E,x=()=>{clearTimeout(E),e.onSearch?.(L.value);};L.addEventListener("input",()=>{clearTimeout(E),E=setTimeout(x,250);}),L.addEventListener("keydown",y=>{y.stopPropagation(),y.key==="Enter"?x():y.key==="Escape"&&(L.value="",x());});function d(y,b,p=false){let u=be(`kanuni-pivot-footer-btn${p?" kanuni-pivot-footer-btn--active":""}`,"button");return u.title=b,u.setAttribute("aria-label",b),u.type="button",u.appendChild(q(y,15)),u}let h=()=>be("kanuni-pivot-footer-divider");function w(y,b,p,u,f,C={}){let m=be("kanuni-pivot-dropdown-item pivot-flex","button");m.type="button",m.style.gap="12px",C.locked&&(m.style.opacity="0.6",m.style.cursor=C.canUpgrade?"pointer":"not-allowed",C.canUpgrade||(m.disabled=true),C.hint&&(m.title=C.hint)),m.appendChild(q(y,16,b));let A=be(""),R=be("pivot-font-medium pivot-flex pivot-items-center");if(R.style.gap="6px",R.appendChild(document.createTextNode(p)),C.locked&&C.badge){let F=be("","span");Object.assign(F.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)"}),F.textContent=C.badge,R.appendChild(F);}if(A.appendChild(R),u!==null){let F=be("pivot-text-xs pivot-text-muted");F.textContent=u,A.appendChild(F);}return m.appendChild(A),f&&m.addEventListener("click",f),m}function v(y,b=false){let p=be("kanuni-pivot-report-section-title");return b&&(p.style.marginTop="4px",p.style.borderTop="1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"),p.textContent=y,p}function c(){let y=be("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 o(y){n=null,i&&k(i),e.onExport(y);}function k(y){i=y;let{t:b,locale:p}=e.getI18n(),u=e.toolbar??{},f=document.activeElement===L;if(t.textContent="",r=null,l=null,u.showSaveReport!==false&&e.mountReportMenu){let m=be("pivot-relative");e.mountReportMenu(m),m.childNodes.length>0&&(t.appendChild(m),t.appendChild(h()));}if(u.showFieldChooserToggle!==false){let m=d("settings",b("showFieldList"),e.fieldChooserOpen());m.addEventListener("click",e.onToggleFieldChooser),t.appendChild(m);}if(e.onOpenPrefilter){let m=d("filter",b("filterBuilder"));m.addEventListener("click",e.onOpenPrefilter),t.appendChild(m);}if(e.onToggleChart){let m=d("bar-chart",b("chartToggle"));m.addEventListener("click",e.onToggleChart),t.appendChild(m);}if(u.showCalculatedFields!==false&&e.onAddCalculatedField){let m=d("calculator",b("calculatedMeasureDesigner"));m.addEventListener("click",e.onAddCalculatedField),t.appendChild(m);}if(t.appendChild(h()),u.showExpandCollapseAll!==false){let m=d("maximize2",b("expandAll"));m.addEventListener("click",e.onExpandAll);let A=d("minimize2",b("collapseAll"));A.addEventListener("click",e.onCollapseAll),t.append(m,A);}if(u.showRefreshButton!==false&&e.onRefresh){t.appendChild(h());let m=d("refresh-cw",b("refreshData"));m.addEventListener("click",e.onRefresh),t.appendChild(m);}if(u.showFullscreenToggle!==false&&e.onToggleFullscreen){t.appendChild(h());let m=e.isFullscreen(),A=d(m?"shrink":"fullscreen",b(m?"exitFullscreen":"enterFullscreen"),m);m&&Object.assign(A.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)"}),A.addEventListener("click",e.onToggleFullscreen),t.appendChild(A);}if(t.appendChild(h()),u.showExportButton!==false){let m=be("pivot-relative");m.setAttribute("data-footer-menu","export");let A=d("download",b("export"),n==="export");if(A.addEventListener("click",()=>{n=n==="export"?null:"export",k(y);}),m.appendChild(A),n==="export"){let R=c(),F=O=>{let N=!e.advancedExport;return {locked:N,canUpgrade:N&&!!e.upgradeUrl,badge:b("enterpriseBadge"),hint:N&&e.upgradeUrl?b("enterpriseUpgradeHint"):void 0}},H=(O,N)=>{if(!(!e.advancedExport))return ()=>o(O);if(e.upgradeUrl)return ()=>{n=null,k(y),window.open(e.upgradeUrl,"_blank","noopener,noreferrer");}},G=e.registry?.getPluginsByType("exporter")??[];if(G.length>0){R.appendChild(v(b("customExports")));for(let O of G)R.appendChild(w("database","var(--pivot-primary)",`${O.id.replace("exporter-","").toUpperCase()} ${b("export")}`,b("customPlugin"),()=>o(O.id)));R.appendChild(be("kanuni-pivot-dropdown-divider"));}R.appendChild(v(b("excelExport"))),R.appendChild(w("file-spreadsheet","var(--pivot-success)",b("pivotView"),b("preservesGridLayout"),H("excel-pivot"),F())),R.appendChild(w("file-spreadsheet","var(--pivot-success)",b("listView"),b("rawFlatData"),H("excel-list"),F())),R.appendChild(v(b("document"),true)),R.appendChild(w("file-text","var(--pivot-danger)",b("pdfDocument"),b("printReadyLayout"),H("pdf"),F())),R.appendChild(w("printer","var(--pivot-info)",b("print"),b("sendToPrinter"),()=>o("print"))),R.appendChild(w("copy","var(--pivot-primary)",b("copyToClipboard"),b("tabSeparatedValues"),()=>o("clipboard"))),R.appendChild(w("file-json","var(--pivot-success)",b("fullSnapshot"),b("saveSessionState"),()=>o("json-snapshot"))),R.appendChild(v(b("rawDataFormats"),true)),R.appendChild(w("file","var(--pivot-info)","CSV",null,()=>o("csv"))),R.appendChild(w("file-json","var(--pivot-warning)","JSON (Tree)",null,()=>o("json-pivot"))),R.appendChild(w("file-json","var(--pivot-warning)","JSON (List)",null,()=>o("json"))),R.appendChild(w("database","var(--pivot-text-muted)","XML",null,()=>o("xml"))),m.appendChild(R),r=R,l=A;}t.appendChild(m);}if(e.onSearch){let m=b("search").replace(/[.\u2026]+$/,"");L.placeholder=b("search"),L.setAttribute("aria-label",m),t.appendChild(h()),t.appendChild(L),f&&L.focus();}let C=y.selectionStats;if(C){let m=new Intl.NumberFormat(p,{minimumFractionDigits:2,maximumFractionDigits:2}),A=be("kanuni-pivot-selection-stats pivot-text-muted pivot-font-medium pivot-flex pivot-items-center");Object.assign(A.style,{marginLeft:"auto",fontSize:"11px",gap:"8px",paddingRight:"8px",userSelect:"none"});let R=[[b("count"),String(C.count)],[b("sum"),m.format(C.sum)],[b("avg"),m.format(C.avg)],[b("min"),m.format(C.min)],[b("max"),m.format(C.max)]];for(let[F,H]of R){let G=be("","span");G.textContent=`(${F}: ${H})`,A.appendChild(G);}t.appendChild(A);}}return {element:t,paint:k,syncSearch(y){document.activeElement!==L&&(L.value=y);},destroy(){clearTimeout(E),t.removeEventListener("contextmenu",g),document.removeEventListener("mousedown",M),t.remove();}}}var It=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];function Ht(e,t){let n=false,r=()=>{let M=document;return M.fullscreenElement??M.webkitFullscreenElement??M.mozFullScreenElement??M.msFullscreenElement??null},l=()=>n||r()===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 L of ["position","inset","z-index","width","height"])e.style.removeProperty(L);}let a=()=>{let M=l();e.classList.toggle("pivot-is-fullscreen",r()===e||n),t(M);};for(let M of It)document.addEventListener(M,a);function g(){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 L=e;L.requestFullscreen?L.requestFullscreen().then(()=>{e.classList.add("pivot-is-fullscreen");},()=>{i(true),t(true);}):L.webkitRequestFullscreen?L.webkitRequestFullscreen():L.mozRequestFullScreen?L.mozRequestFullScreen():L.msRequestFullscreen?L.msRequestFullscreen():(i(true),t(true));}return {isFullscreen:l,toggle:g,destroy(){for(let M of It)document.removeEventListener(M,a);n&&i(false);}}}var Qe=["row","column","data","filter","chooser"];function Dt(e){let t={activeId:null,targetId:null,targetArea:null,intent:null};function n(u,f,C){t.targetId===u&&t.targetArea===f&&t.intent===C||(t.targetId=u,t.targetArea=f,t.intent=C,e.controller.setDragIntent(u,f,C),e.onIntentChange({...t}));}let r=null,l=null,i=null,a=null;function g(u,f,C){i=Re(e.gridRoot),i.style.pointerEvents="none",a=document.createElement("div"),a.className="kanuni-pivot-drag-overlay pivot-flex pivot-items-center pivot-gap-2 pivot-font-semibold pivot-truncate",Object.assign(a.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 m=document.createElement("span");m.className="pivot-truncate",Object.assign(m.style,{maxWidth:"150px",color:"var(--pivot-text)"});let A=e.getFields().find(R=>R.id===u);m.textContent=A?.caption||A?.id||"Field",a.appendChild(m),i.appendChild(a),document.body.appendChild(i),M(f,C);}function M(u,f){a&&(a.style.transform=`translate3d(${u+6}px, ${f+6}px, 0) scale(1.05)`);}function L(){i?.remove(),i=null,a=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 E(u){let f=l;if(L(),l=null,r?.holdTimer&&clearTimeout(r.holdTimer),r=null,document.removeEventListener("pointermove",v),document.removeEventListener("pointerup",c),document.removeEventListener("pointercancel",o),document.removeEventListener("keydown",k,true),!f)return;let C=t.activeId??f.dropId.replace("chooser-","");t.activeId=null,t.targetId=null,t.targetArea=null,t.intent=null,e.onIntentChange({...t}),u===null?e.controller.resetDrag():e.controller.commitDrag(C,u);}function x(){if(!r)return;let{el:u,dropId:f,pointerId:C,startX:m,startY:A}=r;l={el:u,dropId:f,pointerId:C,startX:m,startY:A},r=null;let R=f.replace("chooser-","");t.activeId=R,e.controller.setDragActive(R),u.classList.add("is-dragging"),u.style.pointerEvents="none",u.style.cursor="grabbing",g(R,m,A),window.getSelection?.()?.removeAllRanges?.(),document.body.style.userSelect="none",e.onIntentChange({...t});}function d(u,f){let C=null,m=null,A=null,R=typeof document.elementFromPoint=="function"?document.elementFromPoint(u,f):null;for(let F of e.roots())for(let H of F.querySelectorAll("[data-drop-id]")){if(l&&H===l.el||R&&!H.contains(R)||H.classList.contains("kanuni-pivot-field-chip")&&H.closest('[data-drop-id="chooser-chooser"]'))continue;let G=H.getBoundingClientRect();if(G.width===0&&G.height===0||u<G.left||u>G.right||f<G.top||f>G.bottom)continue;let O=H.getAttribute("data-drop-id"),N=O.replace("chooser-","");if(N.endsWith("-ghost-end"))m={id:O,el:H};else if(Qe.includes(N))A=A??{id:O,el:H};else {let U=G.width*G.height;(!C||U<C.size)&&(C={id:O,el:H,size:U});}}return C??m??A}function h(u,f){let C=d(u,f);if(!C)return n(null,null,null),{overId:null};let m=C.id.replace("chooser-",""),A=e.getFields().find(H=>H.id===m),R=Qe.includes(m)||m.endsWith("-ghost-end")?m.replace("-ghost-end",""):A?.area,F=!!(t.activeId&&R&&e.controller.canMoveFieldTo&&!e.controller.canMoveFieldTo(t.activeId,R));if(a?.classList.toggle("is-drop-denied",F),a&&(a.style.borderColor=F?"var(--pivot-danger)":"var(--pivot-primary)"),F)return n(null,null,null),{overId:null};if(Qe.includes(m)||m.endsWith("-ghost-end"))return n(null,R,"append"),{overId:C.id};if(A){let H=A.area==="chooser"?"vertical":"horizontal",G=C.el.getBoundingClientRect(),O=e.controller.calculateDropIntent(u,f,{top:G.top,left:G.left,width:G.width,height:G.height},t.intent,false,H);return n(m,A.area??null,O),{overId:C.id}}return {overId:C.id}}let w=null,v=u=>{if(!(r&&u.pointerId!==r.pointerId)&&!(l&&u.pointerId!==l.pointerId)){if(r){let f=u.clientX-r.startX,C=u.clientY-r.startY,m=Math.hypot(f,C);if(r.isTouch){if(!r.held&&m>8){r.holdTimer&&clearTimeout(r.holdTimer),r=null;return}if(!r.held)return}else if(m<8)return;x();}l&&(u.preventDefault(),M(u.clientX,u.clientY),w=h(u.clientX,u.clientY).overId);}},c=u=>{if(!(r&&u.pointerId!==r.pointerId)&&!(l&&u.pointerId!==l.pointerId)){if(r){r.holdTimer&&clearTimeout(r.holdTimer),r=null,document.removeEventListener("pointermove",v),document.removeEventListener("pointerup",c),document.removeEventListener("pointercancel",o),document.removeEventListener("keydown",k,true);return}l&&E(h(u.clientX,u.clientY).overId??w);}},o=()=>E(null),k=u=>{u.key==="Escape"&&l&&(u.stopPropagation(),E(null));},y=u=>{if(e.disabled?.()||r||l||u.button!==0&&u.pointerType==="mouse")return;let f=u.target;if(f.closest("button, input, .kanuni-pivot-chip-btn"))return;let C=f.closest(".kanuni-pivot-field-chip[data-drop-id]");if(!C||C.getAttribute("data-drag-scope")==="grip"&&!f.closest("[data-drag-grip]"))return;let m=C.getAttribute("data-drop-id"),A=u.pointerType==="touch";r={el:C,dropId:m,pointerId:u.pointerId,startX:u.clientX,startY:u.clientY,isTouch:A,held:false,holdTimer:A?setTimeout(()=>{r&&(r.held=true,x());},Math.max(0,e.touchDragDelay?.()??200)):null},document.addEventListener("pointermove",v),document.addEventListener("pointerup",c),document.addEventListener("pointercancel",o),document.addEventListener("keydown",k,true);},b=new Set;function p(){for(let u of b)u.isConnected||(u.removeEventListener("pointerdown",y),b.delete(u));for(let u of e.roots())b.has(u)||(b.add(u),u.addEventListener("pointerdown",y));}return p(),{getState:()=>({...t}),refreshRoots:p,rootCount:()=>b.size,destroy(){l&&E(null),r?.holdTimer&&clearTimeout(r.holdTimer),r=null;for(let u of b)u.removeEventListener("pointerdown",y);b.clear(),document.removeEventListener("pointermove",v),document.removeEventListener("pointerup",c),document.removeEventListener("pointercancel",o),document.removeEventListener("keydown",k,true);}}}function ue(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Ot(e){let{portal:t}=e;function n(E,x,d,h=false){let w=ue(`${h?"kanuni-pivot-dropdown-item-danger":"kanuni-pivot-dropdown-item"} pivot-flex pivot-items-center`,"button");return w.type="button",E&&w.appendChild(q(E,16)),w.appendChild(document.createTextNode(" "+x)),w.addEventListener("click",()=>{t.closePopup(),d();}),w}function r(E,x,d){let h=()=>window.visualViewport?.removeEventListener("resize",w),w=()=>{if(!E.isConnected){h();return}let v=E.offsetWidth,c=E.scrollHeight||E.offsetHeight;if(v===0&&c===0)return;let o=placePopup({x,y:d},{width:v,height:c});E.style.top=`${o.top}px`,E.style.left=`${o.left}px`,E.style.maxHeight=`${o.maxHeight}px`;};return w(),window.visualViewport?.addEventListener("resize",w),h}function l(E,x,d){let h=null,w=null,v=()=>{h?.remove(),h=null;},c=()=>{if(h)return;h=ue("kanuni-pivot-dropdown-menu pivot-animate-zoom-in");let o=E.getBoundingClientRect(),k=placePopup({x:o.right+4,y:o.top},{width:160,height:0},{altX:o.left-4});if(Object.assign(h.style,{position:"fixed",top:`${k.top}px`,left:`${k.left}px`,minWidth:"160px",zIndex:"10000"}),h.addEventListener("contextmenu",y=>y.preventDefault()),h.addEventListener("mouseenter",()=>{w&&clearTimeout(w);}),h.addEventListener("mouseleave",()=>{w=setTimeout(v,200);}),d(h),x.appendChild(h),h.offsetHeight){let y=placePopup({x:o.right+4,y:o.top},{width:h.offsetWidth,height:h.scrollHeight},{altX:o.left-4});Object.assign(h.style,{top:`${y.top}px`,left:`${y.left}px`,maxHeight:`${y.maxHeight}px`,overflowY:"auto"});}};E.addEventListener("mouseenter",()=>{w&&clearTimeout(w),c();}),E.addEventListener("mouseleave",()=>{w=setTimeout(v,200);}),E.addEventListener("click",()=>h?v():c());}function i(E,x,d){let h=ue("kanuni-pivot-dropdown-item pivot-flex pivot-items-center pivot-justify-between","button");h.type="button";let w=ue("pivot-flex pivot-items-center pivot-gap-2","span");return w.appendChild(q(E,16)),w.appendChild(document.createTextNode(" "+x)),h.appendChild(w),h.appendChild(q(d?"chevron-left":"chevron-right",14)),h}function a(E){E.addEventListener("keydown",x=>{let d=[...E.querySelectorAll("button:not([disabled])")];if(d.length===0)return;let h=d.indexOf(document.activeElement),w=-1;x.key==="ArrowDown"?w=h<0?0:(h+1)%d.length:x.key==="ArrowUp"?w=h<0?d.length-1:(h-1+d.length)%d.length:x.key==="Home"?w=0:x.key==="End"&&(w=d.length-1),!(w<0)&&(x.preventDefault(),d[w].focus());});}function g(E,x,d,h,w){let v=e.getFields().find(b=>b.id===d);if(!v)return;let{t:c,rtl:o}=e.getI18n(),k=e.getFields().filter(b=>b.area==="row").sort((b,p)=>(b.areaIndex||0)-(p.areaIndex||0)),y=h!==void 0&&k.length>0&&v.area==="data";t.openPopup(b=>{let p=ue("kanuni-pivot-dropdown-menu pivot-animate-zoom-in pivot-flex-col");Object.assign(p.style,{position:"fixed",top:`${x}px`,left:`${E}px`,maxHeight:`${Math.max(0,popupViewport().height-16)}px`,overflowY:"auto",overflowX:"hidden",width:"220px",zIndex:"9999"}),p.addEventListener("contextmenu",C=>C.preventDefault());let u=ue("kanuni-pivot-report-section-title");if(Object.assign(u.style,{position:"sticky",top:"0",zIndex:"10"}),u.textContent=v.caption??v.id,p.appendChild(u),y){let C=ue("kanuni-pivot-report-section-title");C.style.marginTop="4px",C.textContent=c("sortByThisColumn"),p.appendChild(C);for(let m of k)p.appendChild(n("arrow-down-a-z",c("sortFieldByThisColumn").replace("{0}",m.caption||m.id),()=>e.controller.sortFieldBySummary(m.id,v.id,h)));p.appendChild(ue("kanuni-pivot-divider")),p.appendChild(n("x",c("removeAllSorting"),()=>e.controller.clearAllSorting(),true));}else {p.appendChild(n("arrow-down-a-z",c("sortAsc"),()=>e.controller.sortField(v.id,"asc"))),p.appendChild(n("arrow-up-z-a",c("sortDesc"),()=>e.controller.sortField(v.id,"desc"))),v.sortOrder&&p.appendChild(n("x",c("clearSort"),()=>e.controller.sortField(v.id,void 0),true)),e.openFilter&&v.area!=="data"&&p.appendChild(n("filter",c("filterField"),()=>e.openFilter(v.id,E,x))),e.openCondition&&(v.area==="row"||v.area==="column")&&p.appendChild(n("filter",c("conditionFilter")+"\u2026",()=>e.openCondition(v.id))),p.appendChild(ue("kanuni-pivot-divider"));let C=i("list",c("order"),o);p.appendChild(C),l(C,b,R=>{let F=[["start",c("moveToStart"),"chevrons-left"],["left",c("moveToLeft"),"chevron-left"],["right",c("moveToRight"),"chevron-right"],["end",c("moveToEnd"),"chevrons-right"]];for(let[H,G,O]of F)R.appendChild(n(O,G,()=>e.controller.moveField(v.id,H)));});let m=[["row",c("rowArea"),"rows-3"],["column",c("columnArea"),"columns-3"],["data",c("dataArea"),"bar-chart-3"],["filter",c("filterArea"),"filter"]].filter(([R])=>R!==v.area);if(m.length>0){let R=i("move",c("moveToArea"),o);p.appendChild(R),l(R,b,F=>{for(let[H,G,O]of m){let N=n(O,G,()=>e.controller.changeFieldArea(v.id,H));e.controller.canMoveFieldTo(v.id,H)||(N.disabled=true),F.appendChild(N);}});}e.openFieldChooser&&p.appendChild(n("list",c("showFieldList"),e.openFieldChooser)),p.appendChild(n("eye-off",c("hide"),()=>e.controller.removeField(v.id)));let A=e.customContextMenuItems?.(v);if(A&&A.length>0){p.appendChild(ue("kanuni-pivot-divider"));for(let R of A){let F=n(null,R.label,R.action);R.icon&&F.insertBefore(R.icon(),F.firstChild),p.appendChild(F);}}p.appendChild(ue("kanuni-pivot-divider")),v.isCalculated&&e.onEditCalculatedField&&p.appendChild(n("calculator",c("editCalculation"),()=>e.onEditCalculatedField(v))),p.appendChild(n("settings",c("fieldSettings"),()=>e.openSettings(v.id)));}b.appendChild(p);let f=r(p,E,x);return w?(a(b),p.querySelector("button")?.focus(),()=>{f(),e.gridRoot?.querySelector(`.kanuni-pivot-field-chip[data-drop-id="${d}"]`)?.focus({preventScroll:true});}):f});}function M(E,x){let{t:d}=e.getI18n();t.openPopup(h=>{let w=ue("kanuni-pivot-dropdown-menu pivot-animate-zoom-in");Object.assign(w.style,{position:"fixed",zIndex:"301",width:"224px",fontSize:"14px",left:`${placePopup({x:E,y:x},{width:224,height:120}).left}px`,top:`${placePopup({x:E,y:x},{width:224,height:120}).top}px`}),w.addEventListener("contextmenu",k=>k.preventDefault());let v=ue("kanuni-pivot-report-section-title");v.textContent=d("viewOptions"),w.appendChild(v);let c=e.getLayout(),o=(k,y,b)=>{let p=ue("pivot-w-full pivot-flex pivot-items-center pivot-justify-between","button");p.type="button",Object.assign(p.style,{padding:"6px 12px",textAlign:"left"}),p.addEventListener("mouseenter",()=>{p.style.backgroundColor="var(--pivot-surface-hover)";}),p.addEventListener("mouseleave",()=>{p.style.backgroundColor="transparent";});let u=ue("","span");u.textContent=k;let f=ue("pivot-text-xs pivot-text-muted pivot-font-medium","span");return f.textContent=d(y?"show":"hide"),p.append(u,f),p.addEventListener("click",()=>{b(),t.closePopup();}),p};w.appendChild(o(d("filterArea"),c.showFilterArea===false,()=>e.controller.setLayout({showFilterArea:c.showFilterArea===false}))),w.appendChild(o(d("footerArea"),c.showFooter===false,()=>e.controller.setLayout({showFooter:c.showFooter===false}))),h.appendChild(w);});}function L(E){let{t:x}=e.getI18n(),d=()=>{let h=e.getEngineTrees();if(!h)return [];let w=[],v=(c,o)=>{if(c)for(let k of c)o>=E.depth&&w.push(k.key),k.children&&v(k.children,o+1);};return v(E.type==="row"?h.rowTree:h.colTree,0),w};t.openPopup(h=>{let w=ue("");Object.assign(w.style,{position:"fixed",inset:"0",zIndex:"9998"}),w.addEventListener("click",()=>t.closePopup()),w.addEventListener("contextmenu",o=>{o.preventDefault(),t.closePopup();});let v=ue("kanuni-pivot-dropdown-menu pivot-animate-zoom-in");Object.assign(v.style,{position:"fixed",left:`${Math.min(E.x,window.innerWidth-180)}px`,top:`${Math.min(E.y,window.innerHeight-200)}px`,zIndex:"9999",minWidth:"160px"}),v.addEventListener("contextmenu",o=>o.preventDefault());let c=(o,k)=>{let y=ue("kanuni-pivot-dropdown-item pivot-state-hover","button");return y.type="button",Object.assign(y.style,{paddingLeft:"32px",paddingRight:"24px"}),y.textContent=o,y.addEventListener("click",b=>{b.stopPropagation(),t.closePopup(),k();}),y};v.appendChild(c(E.isExpanded?x("collapse"):x("expand"),()=>{E.type==="row"?e.controller.toggleExpanded(E.path):e.controller.toggleColExpanded(E.path);})),v.appendChild(ue("kanuni-pivot-dropdown-divider")),v.appendChild(c(x("expandAll"),()=>{let o=d();E.type==="row"?e.controller.expandPaths(o):e.controller.expandColPaths(o);})),v.appendChild(c(x("collapseAll"),()=>{let o=d();E.type==="row"?e.controller.collapsePaths(o):e.controller.collapseColPaths(o);})),h.append(w,v);});}return {openFieldMenu:g,openGlobalMenu:M,openNodeMenu:L,close:()=>t.closePopup()}}function xe(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}var Le=(e,...t)=>{let n=xe("kanuni-pivot-form-group"),r=xe("kanuni-pivot-form-label","label");return r.textContent=e,n.append(r,...t),n},Se=(e,t)=>{let n=xe("kanuni-pivot-select","select");for(let[r,l]of e){let i=document.createElement("option");i.value=r,i.textContent=l,n.appendChild(i);}return n.value=t,n},Ge=(e,t)=>{let n=xe("kanuni-pivot-input","input");return n.type=e,n.value=t,n},Vt=(...e)=>{let t=xe("");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},Nn=[["equals","opEquals"],["notEquals","opNotEquals"],["contains","opContains"],["notContains","opNotContains"],["startsWith","opStartsWith"],["endsWith","opEndsWith"]],Wn=[[">","opGreater"],[">=","opGreaterOrEqual"],["<","opLess"],["<=","opLessOrEqual"],["=","opEquals"],["!=","opNotEquals"],["between","opBetween"],["notBetween","opNotBetween"]];function zt(e){function t(l,i,a,g){let{t:M}=e.getI18n();e.portal.openPopup(L=>{let E=xe("kanuni-pivot-modal-overlay pivot-animate-fade-in");E.addEventListener("click",()=>e.portal.closePopup());let x=xe("kanuni-pivot-modal pivot-animate-zoom-in");x.style.width="400px",x.setAttribute("role","dialog"),x.setAttribute("aria-modal","true"),x.setAttribute("aria-label",l);let d=xe("kanuni-pivot-modal-header"),h=xe("kanuni-pivot-modal-title","h2");h.textContent=l;let w=xe("kanuni-pivot-modal-close","button");w.type="button",w.setAttribute("aria-label",M("cancel")),w.appendChild(q("x",20)),w.addEventListener("click",()=>e.portal.closePopup()),d.append(h,w);let v=xe("kanuni-pivot-modal-footer"),c=xe("kanuni-pivot-btn kanuni-pivot-btn--outline","button");c.type="button",c.textContent=M("cancel"),c.addEventListener("click",()=>e.portal.closePopup());let o=xe("kanuni-pivot-btn kanuni-pivot-btn--primary","button");o.type="button",o.appendChild(q("check",16)),o.appendChild(document.createTextNode(" "+M("ok"))),o.addEventListener("click",()=>{a()!==false&&e.portal.closePopup();}),v.append(c,o),x.append(d,i,v),L.append(E,x),g.focus();});}function n(l){let i=e.getFields().find(c=>c.id===l);if(!i)return;let{t:a}=e.getI18n(),g=xe("kanuni-pivot-modal-body pivot-custom-scrollbar"),M=Ge("text",i.caption??"");g.appendChild(Le(a("caption"),M));let L=i.area==="data"||i.area==="chooser",E=i.area==="row"||i.area==="column"||i.area==="filter"||i.area==="chooser",x=null,d=null,h=null,w=(...c)=>c.map(o=>[o,a(o)]),v=(...c)=>{let o=i.summaryType;return w(...o&&!c.includes(o)?[o,...c]:c)};L&&i.dataType&&i.dataType!=="number"&&(x=Se(v("count","distinct"),String(i.summaryType||"count")),g.appendChild(Le(a("summaryType"),x))),L&&i.dataType==="number"&&(x=Se(v("sum","count","avg","min","max","distinct"),String(i.summaryType||"sum")),g.appendChild(Le(a("summaryType"),x)),d=Se([["absolute",a("absoluteValue")],...w("percentOfTotal","percentOfColumnTotal","percentOfRowTotal","percentOfParentRowTotal","percentOfParentColumnTotal","runningTotal","difference","percentDifference")],String(i.summaryDisplayMode||"absolute")),g.appendChild(Le(a("displayMode"),d))),E&&i.dataType==="date"&&(h=Se([["",a("none")],...w("year","quarter","month","week","day")],String(i.groupInterval||"")),g.appendChild(Le(a("groupInterval"),h))),t(a("fieldSettings"),g,()=>{e.save({...i,caption:M.value,summaryType:x?.value||i.summaryType,summaryDisplayMode:d?.value??i.summaryDisplayMode,groupInterval:h?h.value||void 0:i.groupInterval});},M);}function r(l){let i=e.getFields(),a=i.find(p=>p.id===l);if(!a)return;let{t:g}=e.getI18n(),M=xe("kanuni-pivot-modal-body pivot-custom-scrollbar"),L=p=>[["",g("none")],...p.map(([u,f])=>[u,g(f)])],E=a.labelFilter,x=Se(L(Nn),E?.operator??"");x.setAttribute("data-condition-label-op",""),x.setAttribute("aria-label",g("caption"));let d=Ge("text",E?.value??"");d.setAttribute("data-condition-label-value",""),d.placeholder=g("builderValuePlaceholder"),d.setAttribute("aria-label",g("builderValuePlaceholder")),M.appendChild(Le(g("caption"),Vt(x,d)));let h=i.filter(p=>p.area==="data").sort((p,u)=>(p.areaIndex||0)-(u.areaIndex||0)),w=a.valueFilter,v=Se(h.map(p=>[p.id,p.caption||p.id]),h.some(p=>p.id===w?.dataField)?w.dataField:h[0]?.id??"");v.setAttribute("data-condition-value-field",""),v.setAttribute("aria-label",g("dataArea"));let c=Se(L(Wn),w?.operator??"");c.setAttribute("data-condition-value-op",""),c.setAttribute("aria-label",g("dataArea"));let o=Ge("number",w?String(w.value):"");o.setAttribute("data-condition-value","");let k=Ge("number",w?.value2!==void 0?String(w.value2):"");k.setAttribute("data-condition-value2","");for(let p of [o,k])p.setAttribute("aria-label",g("builderValuePlaceholder"));h.length>0&&M.appendChild(Le(g("dataArea"),v,Vt(c,o,k)));let y=()=>{d.disabled=x.value==="",o.disabled=c.value==="",k.style.display=c.value==="between"||c.value==="notBetween"?"":"none";};x.addEventListener("change",y),c.addEventListener("change",y),y();let b=p=>(p.setAttribute("aria-invalid","true"),p.focus(),false);t(`${g("conditionFilter")}: ${a.caption||a.id}`,M,()=>{for(let f of [d,o,k])f.removeAttribute("aria-invalid");let p;if(x.value){if(d.value==="")return b(d);p={operator:x.value,value:d.value,...E?.caseSensitive?{caseSensitive:true}:{}};}let u=h.length>0?void 0:w;if(c.value&&h.length>0){let f=k.style.display!=="none",C=o.value===""?NaN:Number(o.value),m=k.value===""?NaN:Number(k.value);if(!Number.isFinite(C))return b(o);if(f&&!Number.isFinite(m))return b(k);u={dataField:v.value,operator:c.value,value:C,...f?{value2:m}:{}};}e.save({...a,labelFilter:p,valueFilter:u});},x);}return {open:n,openCondition:r}}function te(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function jn(e){let t=e.isCalculated?"settings-2":e.dataType==="number"?"hash":e.dataType==="date"?"calendar":e.dataType==="boolean"?"filter":"type";return q(t,12,"var(--pivot-primary)")}function $t(e){let t=null,n=null,r=null,l="",i={x:0,y:0},a={width:700,height:550},g=()=>window.innerWidth<=768,M=["fullscreenchange","webkitfullscreenchange"],L=()=>{if(!t)return;let p=He();t.parentElement!==p&&p.appendChild(t);},E=()=>{n&&(x(),g()||(i={x:Math.min(i.x,Math.max(0,window.innerWidth-a.width)),y:Math.min(i.y,Math.max(0,window.innerHeight-a.height))},x()));};function x(){n&&(g()?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:`${a.width}px`,height:`${a.height}px`,maxWidth:"95vw",maxHeight:"95vh",transform:"none",padding:"0",zIndex:"100",boxShadow:"var(--pivot-shadow-lg)",borderRadius:""}));}function d(p,u){let{t:f}=e.getI18n(),C=te("kanuni-pivot-field-chip");C.setAttribute("data-drop-id",`chooser-${p.id}`),C.setAttribute("data-drag-scope","grip"),C.style.position="relative";let m=te("");if(m.setAttribute("data-drag-grip",""),Object.assign(m.style,{color:"var(--pivot-text-muted)",cursor:"grab",flexShrink:"0",opacity:"0.5"}),m.appendChild(q("grip-vertical",14)),C.appendChild(m),u){let O=te("kanuni-pivot-checkbox","input");O.type="checkbox",O.checked=p.area!=="chooser",O.style.flexShrink="0",O.addEventListener("change",()=>{O.checked?e.controller.showFields([p.id]):e.controller.removeField(p.id);}),C.appendChild(O);}C.appendChild(jn(p));let A=te("pivot-truncate","span");Object.assign(A.style,{flex:"1",color:"var(--pivot-text)",textAlign:"left"}),A.textContent=p.caption??p.id;let R=p.area==="data"&&p.summaryType?summaryTypeLabel(String(p.summaryType),f):"";if(R){let O=te("","span");Object.assign(O.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"}),O.textContent=R,A.appendChild(O);}C.appendChild(A);let F=!!p.filterValues&&p.filterValues.size>0,H=te(`kanuni-pivot-field-chip-actions${F?" is-filtered":""}`);if(p.area!=="data"){let O=te("kanuni-pivot-chip-btn","button");O.type="button",O.title=f("filterField"),F&&Object.assign(O.style,{color:"var(--pivot-danger)",backgroundColor:"color-mix(in srgb, var(--pivot-danger) 10%, transparent)"}),O.appendChild(q("filter",12)),O.addEventListener("click",N=>{N.stopPropagation(),e.onFilterClick(N.clientX,N.clientY,p.id);}),H.appendChild(O);}if(p.isCalculated){let O=te("kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger","button");O.type="button",O.title=f("deletePermanently"),O.appendChild(q("trash",12)),O.addEventListener("click",N=>{N.stopPropagation(),e.controller.deleteField(p.id);}),H.appendChild(O);}let G=te("kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger","button");return G.type="button",G.title=f("removeFromArea"),G.appendChild(q("x",12)),G.addEventListener("click",O=>{O.stopPropagation(),e.controller.removeField(p.id);}),H.appendChild(G),C.appendChild(H),C}function h(p,u,f,C,m){let A=te("");if(Object.assign(A.style,{height:"100%",display:"flex",flexDirection:"column",transition:"background-color 0.2s"}),f!==null){let H=te("");Object.assign(H.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)"}),H.textContent=f,A.appendChild(H);}let R=te("pivot-custom-scrollbar");if(R.setAttribute("data-drop-id",`chooser-${p}`),R.setAttribute("data-drop-kind","list"),Object.assign(R.style,{maxHeight:g()?"none":"100%",flex:"1",padding:"8px",minHeight:"80px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"6px",alignItems:u.length===0?"center":"stretch",justifyContent:u.length===0?"center":"flex-start"}),u.length===0){let H=te("");Object.assign(H.style,{fontSize:"12px",color:"color-mix(in srgb, var(--pivot-text-muted) 70%, transparent)",fontStyle:"italic",textAlign:"center",width:"100%"}),H.textContent=C,R.appendChild(H);}for(let H of u)R.appendChild(d(H,m));let F=te("");return F.setAttribute("data-drop-id",`chooser-${p}-ghost-end`),F.setAttribute("data-ghost-populated",u.length>0?"1":"0"),Object.assign(F.style,{width:"100%",minHeight:"24px",transition:"background-color 0.2s",borderRadius:"var(--pivot-border-radius-sm)"}),R.appendChild(F),A.appendChild(R),A}function w(){let p=new Map;return e.getFields().map(u=>{let f=u.caption||u.id||"";if(p.has(f)){let C=p.get(f)+1;return p.set(f,C),{...u,caption:`${f} (${C})`}}return p.set(f,1),u})}function v(){let{locale:p}=e.getI18n(),u=[...w()].sort((C,m)=>(C.caption||"").toLowerCase().localeCompare((m.caption||"").toLowerCase(),p||"en"));if(!l)return u;let f=l.toLowerCase();return u.filter(C=>(C.caption||"").toLowerCase().includes(f))}function c(){let p=v().filter(u=>u.area==="chooser").map(u=>u.id);p.length!==0&&e.controller.showFields(p);}function o(){if(!r)return;let{t:p,locale:u}=e.getI18n(),f=new Map;for(let S of r.querySelectorAll('[data-drop-kind="list"]')){let P=S.getAttribute("data-drop-id");P&&S.scrollTop>0&&f.set(P,S.scrollTop);}let C=w(),m=v(),A=S=>C.filter(P=>P.area===S).sort((P,D)=>(P.areaIndex||0)-(D.areaIndex||0));r.textContent="";let R=g(),F=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&&(F.style.flexShrink="0");let H=te("p-3 border-b border-border/60 bg-surface/80"),G=te("relative"),O=q("search",16);O.setAttribute("class","text-muted-fg opacity-60"),Object.assign(O.style,{position:"absolute",top:"50%",transform:"translateY(-50%)",pointerEvents:"none"}),O.style.setProperty("inset-inline-start","10px");let N=te("w-full bg-surface-hover/50 border-border rounded-md text-[13px] kanuni-pivot-input","input");N.type="text",N.placeholder=p("search"),N.value=l,N.style.setProperty("padding-inline-start","34px"),N.addEventListener("input",()=>{l=N.value,o();let S=r?.querySelector('input[type="text"]');S?.focus(),S?.setSelectionRange(S.value.length,S.value.length);}),G.append(O,N),H.appendChild(G),F.appendChild(H);let U=te(R?"p-2":"flex-1 overflow-hidden p-2"),we=te("");Object.assign(we.style,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"});let ie=te("text-[11px] font-bold uppercase tracking-wider text-muted-fg/80 mb-2 px-1");ie.textContent=p("allFields");let le=te("kanuni-pivot-popup-action-btn kanuni-pivot-chooser-select-all","button");le.type="button",le.textContent=p("selectAll"),le.style.color="var(--pivot-primary)",le.disabled=m.every(S=>S.area!=="chooser"),le.addEventListener("click",c),we.append(ie,le),U.appendChild(we),U.appendChild(h("chooser",m,null,p("noItems"),true)),F.appendChild(U);let ve=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&&(ve.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"),se=[["filter",p("filterArea")],["column",p("columnArea")],["row",p("rowArea")],["data",p("dataArea")]];for(let[S,P]of se){let D=te("border border-border/80 rounded-md shadow-sm bg-surface overflow-hidden flex flex-col transition-colors");R&&(D.style.minHeight="140px"),D.appendChild(h(S,A(S),P,p("dropHere"),false)),ye.appendChild(D);}ve.appendChild(ye),r.append(F,ve);for(let[S,P]of f){let D=r.querySelector(`[data-drop-id="${S}"][data-drop-kind="list"]`);D&&(D.scrollTop=P);}}function k(){if(t)return;let{t:p}=e.getI18n();t=Re(e.gridRoot);let u=te("fixed inset-0 z-[100] kanuni-pivot-chooser-backdrop overflow-auto pointer-events-auto");u.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",F=>F.stopPropagation()),g()||(a={width:Math.min(700,window.innerWidth-32),height:Math.min(550,window.innerHeight-32)},i={x:Math.max(0,(window.innerWidth-a.width)/2),y:Math.max(0,(window.innerHeight-a.height)/2)}),x();let f=te("pivot-field-chooser__header flex items-center justify-between p-3 border-b border-border bg-surface-header/90");g()||(f.style.cursor="move");let C=te("text-[15px] font-semibold m-0 flex items-center gap-2 select-none","h3");C.appendChild(q("grip-horizontal",18,"var(--pivot-text-muted)")),C.appendChild(document.createTextNode(p("allFields")));let m=te("btn-icon rounded-full p-1.5 kanuni-pivot-chip-btn","button");m.type="button",m.setAttribute("aria-label",p("cancel")),m.appendChild(q("x",18)),m.addEventListener("pointerdown",F=>F.stopPropagation()),m.addEventListener("click",y),f.append(C,m);let A=null;f.addEventListener("pointerdown",F=>{g()||F.target.closest(".kanuni-pivot-field-chip, button, input")||(A={px:F.clientX,py:F.clientY,x:i.x,y:i.y},f.setPointerCapture?.(F.pointerId));}),f.addEventListener("pointermove",F=>{A&&(i={x:Math.max(0,A.x+F.clientX-A.px),y:Math.max(0,A.y+F.clientY-A.py)},x());});let R=F=>{A=null,f.releasePointerCapture?.(F.pointerId);};if(f.addEventListener("pointerup",R),f.addEventListener("pointercancel",R),r=te(g()?"flex flex-1 flex-col bg-surface-sunken/30":"flex flex-1 overflow-hidden flex-col md:flex-row bg-surface-sunken/30"),g()&&(r.setAttribute("data-chooser-scroll",""),Object.assign(r.style,{minHeight:"0",overflowY:"auto",touchAction:"pan-y",overscrollBehavior:"contain"})),o(),n.append(f,r),!g()){let F=[["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[H,G,O]of F){let N=te("kanuni-pivot-chooser-resize");N.setAttribute("data-resize-dir",H),Object.assign(N.style,{position:"absolute",zIndex:H.length===2?"51":"50",cursor:G},O);let U=null;N.addEventListener("pointerdown",ie=>{ie.stopPropagation(),U={px:ie.clientX,py:ie.clientY,w:a.width,h:a.height,x:i.x,y:i.y},N.setPointerCapture?.(ie.pointerId);}),N.addEventListener("pointermove",ie=>{if(!U)return;let le=ie.clientX-U.px,ve=ie.clientY-U.py,ye=U.w,se=U.h,S=U.x,P=U.y;H.includes("e")&&(ye=U.w+le),H.includes("s")&&(se=U.h+ve),H.includes("w")&&(ye=U.w-le,ye>=400&&(S=U.x+le)),H.includes("n")&&(se=U.h-ve,se>=400&&(P=U.y+ve)),a={width:Math.max(400,ye),height:Math.max(400,se)},i={x:Math.max(0,S),y:Math.max(0,P)},x();});let we=ie=>{U=null,N.releasePointerCapture?.(ie.pointerId);};N.addEventListener("pointerup",we),N.addEventListener("pointercancel",we),n.appendChild(N);}}u.appendChild(n),t.appendChild(u),He().appendChild(t),window.addEventListener("resize",E);for(let F of M)document.addEventListener(F,L);e.onOpenChanged?.(true);}function y(){if(t){window.removeEventListener("resize",E);for(let p of M)document.removeEventListener(p,L);t.remove(),t=null,n=null,r=null,l="",e.onOpenChanged?.(false);}}function b(){if(!t)return;let p={...i},u={...a};y(),k(),i=p,a=u,x();}return {open:k,close:y,toggle:()=>t?y():k(),isOpen:()=>t!==null,repaint:o,relocalize:b,getHost:()=>t,destroy:y}}function ne(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Bt(e){let t=false,n=null,r=a=>{t&&n&&!n.contains(a.target)&&(t=false,e.requestRepaint());};document.addEventListener("mousedown",r);function l(a,g){let{t:M}=e.getI18n();e.portal.openPopup(L=>{let E=ne("kanuni-pivot-modal-overlay");E.addEventListener("click",()=>e.portal.closePopup());let x=ne("kanuni-pivot-modal pivot-animate-zoom-in");Object.assign(x.style,{display:"flex",flexDirection:"column",gap:"16px",padding:"24px"});let d=ne("pivot-flex pivot-flex-col");d.style.gap="6px";let h=ne("pivot-flex pivot-items-center pivot-justify-between"),w=ne("kanuni-pivot-modal-title","h3");w.textContent=a;let v=ne("kanuni-pivot-modal-close","button");v.type="button",v.setAttribute("aria-label",M("close")),v.style.padding="6px",v.appendChild(q("x",16)),v.addEventListener("click",()=>e.portal.closePopup()),h.append(w,v);let c=ne("kanuni-pivot-modal-description","p");c.textContent=M("saveReportDescription"),d.append(h,c);let o=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 b=ne("kanuni-pivot-input","input");b.type="text",b.placeholder=M("reportNamePlaceholder"),b.required=true,b.value=g,k.append(y,b);let p=ne("pivot-flex pivot-items-center pivot-gap-2"),u=ne("kanuni-pivot-input","input");u.type="checkbox",Object.assign(u.style,{width:"16px",height:"16px"});let f=ne("kanuni-pivot-form-label","label");Object.assign(f.style,{margin:"0",cursor:"pointer"}),f.textContent=M("setAsDefault"),f.addEventListener("click",()=>{u.checked=!u.checked;}),p.append(u,f);let C=ne("kanuni-pivot-modal-footer");Object.assign(C.style,{marginTop:"8px",paddingTop:"16px",borderTop:"1px solid var(--pivot-border)",display:"flex",justifyContent:"flex-end",gap:"8px"});let m=ne("kanuni-pivot-btn kanuni-pivot-btn--outline","button");m.type="button",m.textContent=M("cancel"),m.addEventListener("click",()=>e.portal.closePopup());let A=ne("kanuni-pivot-btn kanuni-pivot-btn--primary","button");A.type="submit",A.disabled=!g.trim(),A.appendChild(q("save",16)),A.appendChild(document.createTextNode(" "+M("save"))),b.addEventListener("input",()=>{A.disabled=!b.value.trim();}),C.append(m,A),o.addEventListener("submit",R=>{R.preventDefault();let F=b.value.trim();F&&(e.controller.saveReport(F,u.checked),e.portal.closePopup());}),o.append(k,p,C),x.append(d,o),L.append(E,x),b.focus();});}function i(a){let{t:g}=e.getI18n();n=a;let M=e.getReports(),L=e.getActiveReportId(),E=M.find(c=>c.id===L),x=ne(`kanuni-pivot-report-btn ${t?"kanuni-pivot-report-btn--open":L?"kanuni-pivot-report-btn--active":"kanuni-pivot-report-btn--default"}`,"button");x.type="button",x.title=g("viewsAndReports"),x.appendChild(q("bookmark",15));let d=ne("pivot-truncate","span");if(d.style.maxWidth="120px",d.textContent=E?E.name:g("views"),x.appendChild(d),x.addEventListener("click",()=>{t=!t,e.requestRepaint();}),a.appendChild(x),!t)return;let h=ne("kanuni-pivot-report-dropdown pivot-animate-slide-up"),w=(c,o=false)=>{let k=ne("kanuni-pivot-report-section-title");return o&&(k.style.marginTop="8px",k.style.borderTop="1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"),k.textContent=c,k},v=(c,o,k,y)=>{let b=ne("kanuni-pivot-report-item","button");b.type="button",b.appendChild(q(c,16,o));let p=ne(""),u=ne("pivot-font-medium");return u.textContent=k,p.appendChild(u),b.appendChild(p),b.addEventListener("click",()=>{t=false,e.requestRepaint(),y();}),b};if(h.appendChild(w(g("actions"))),h.appendChild(v("save","var(--pivot-success)",g("saveNewView"),()=>l(g("saveNewView"),""))),L&&(h.appendChild(v("save-all","var(--pivot-warning)",g("saveChangesOverwrite"),()=>e.controller.updateCurrentReport())),h.appendChild(v("copy","var(--pivot-info)",g("saveAsCopy"),()=>l(g("saveAsView"),`${E?.name??""} (Copy)`)))),M.length>0){h.appendChild(w(g("savedViews"),true));let c=ne("kanuni-pivot-report-list pivot-custom-scrollbar");for(let o of M){let k=ne(`kanuni-pivot-report-list-item${o.id===L?" kanuni-pivot-report-list-item--active":""}`),y=ne("kanuni-pivot-report-list-btn","button");y.type="button",y.appendChild(q(o.id===L?"check":"folder-open",14,o.id===L?"var(--pivot-primary)":"var(--pivot-text-muted)"));let b=ne("pivot-text-sm pivot-truncate","span");b.style.color=o.id===L?"var(--pivot-primary)":"var(--pivot-text)",o.id===L&&b.classList.add("pivot-font-medium"),b.textContent=o.name,y.appendChild(b),o.isDefault&&y.appendChild(Fe("star",12,"var(--pivot-warning)")),y.addEventListener("click",()=>{t=false,e.requestRepaint(),e.controller.loadReport(o.id);}),k.appendChild(y);let p=ne("kanuni-pivot-report-actions");if(!o.isDefault){let f=ne("kanuni-pivot-action-btn kanuni-pivot-action-btn--warning","button");f.type="button",f.title=g("makeDefault"),f.setAttribute("aria-label",f.title),f.appendChild(q("star",14)),f.addEventListener("click",C=>{C.stopPropagation(),e.controller.setDefaultReport(o.id);}),p.appendChild(f);}let u=ne("kanuni-pivot-action-btn kanuni-pivot-action-btn--danger","button");u.type="button",u.title=g("deleteReport"),u.setAttribute("aria-label",u.title),u.appendChild(q("trash",14)),u.addEventListener("click",f=>{f.stopPropagation(),window.confirm(g("deleteReportConfirm").replace("{0}",o.name))&&(e.controller.deleteReport(o.id),o.id===L&&(t=false,e.requestRepaint()));}),p.appendChild(u),k.appendChild(p),c.appendChild(k);}h.appendChild(c);}a.appendChild(h);}return {mount:i,destroy(){document.removeEventListener("mousedown",r);}}}var Kn={chartData:[],chartSeries:[]};function et(e,t,n,r){let l=null,i,a,g,M=false;function L(){if(M)return;let d=e.getState();if(!d.engineResult||!d.engineResult.cellMatrix||!n.transformer){r(Kn);return}r(n.transformer(d.engineResult,shownFields(d.fields),d.expandedPaths,t(),n));}function E(){let d=e.getState(),h=t();d.engineResult===i&&d.expandedPaths===a&&h===g||(i=d.engineResult,a=d.expandedPaths,g=h,l&&clearTimeout(l),l=setTimeout(L,150));}let x=e.subscribe(E);return E(),{refresh:E,stop(){M=true,l&&clearTimeout(l),x();}}}function Pe(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}var tt=new Set;function to(){let e="default-pivot-grid";for(let t=2;tt.has(e);t++)e=`default-pivot-grid-${t}`;return tt.add(e),e}function no(e,t){if(!e||!(e instanceof HTMLElement))throw new Error("[pivotgrid] createPivotGrid needs a container HTMLElement");rt(t);let n=Ve(t.locale,t.dictionary,t.rtl),r=t.gridId||t.stateStoring?.storageKey,l=r||to();!r&&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=Pe("kanuni-pivot-root"+(t.className?" "+t.className:""));i.style.width="100%",i.style.height="100%",it(i,pivotSchemeTheme(t.theme,t.palette,t.dark)),i.setAttribute("dir",n.rtl?"rtl":"ltr");let a=Pe("kanuni-pivot-wrapper pivot-flex pivot-flex-col");a.style.width="100%",a.style.height="100%";let g=Pe("pivot-grid pivot-flex-1 pivot-flex pivot-flex-col pivot-relative");g.style.minHeight="0",g.style.overflow="hidden",g.style.backgroundColor="var(--pivot-bg)",g.style.border="1px solid var(--pivot-border)",g.style.borderRadius="var(--pivot-radius-md)",g.style.userSelect="none",t.striped&&i.classList.add("kanuni-pivot-striped");let M=t.density,L=()=>pivotDensityClass(M),E=()=>pivotRowHeight(M);L()&&i.classList.add(L());let x=Pe("pivot-flex-1 pivot-flex pivot-flex-col pivot-relative");x.style.minHeight="0";let d=Pe("pivot-text-muted pivot-text-sm");d.style.padding="8px",d.style.position="absolute",d.style.inset="0",d.style.display="none",d.style.zIndex="70",d.style.backgroundColor="var(--pivot-bg)",d.setAttribute("data-pivot-status",""),g.appendChild(x),g.appendChild(d),a.appendChild(g),i.appendChild(a);let h=Pe("kanuni-pivot-live");h.setAttribute("role","status"),h.setAttribute("aria-live","polite"),h.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap",i.appendChild(h),e.appendChild(i);let w={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,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},v=new PivotController(w),c=bindPivotScrollMemory(i,v),o=()=>shownFields(v.getState().fields),k=Je(i),y=At({portal:k,getI18n:()=>n,gridId:l,getField:s=>o().find(I=>I.id===s),getData:()=>v.getRawData(),apply:(s,I,$)=>v.applyFilter(s,I,$),clear:s=>v.clearFilter(s),openCondition:s=>b.openCondition(s)}),b=zt({portal:k,getI18n:()=>n,getFields:o,save:s=>v.updateField(s)}),p=Ot({portal:k,gridRoot:i,getI18n:()=>n,getFields:o,getLayout:()=>v.getState().layout,controller:v,getEngineTrees:()=>{let s=v.getState().engineResult;return s?{rowTree:s.rowTree,colTree:s.colTree}:null},openSettings:s=>b.open(s),openCondition:s=>b.openCondition(s),openFilter:(s,I,$)=>{m()||y.open(I,$,s);},openFieldChooser:()=>u.open(),onEditCalculatedField:t.onEditCalculatedField?s=>{m()||t.onEditCalculatedField(s);}:void 0,customContextMenuItems:t.customContextMenuItems}),u=$t({gridRoot:i,getI18n:()=>n,getFields:o,controller:v,onFilterClick:(s,I,$)=>y.open(s,I,$),onOpenChanged:()=>{S||(U.refreshRoots(),se.paint(v.getState()));}}),f=(s,I)=>{t.onGlobalContextMenu?t.onGlobalContextMenu(s,I):p.openGlobalMenu(s,I);},C=kt(),m=()=>t.disabled===true,A,R,F={getI18n:()=>n,onRemove:s=>{m()||v.removeField(s);},onFilterClick:(s,I,$)=>{m()||y.open(s,I,$);},onSort:(s,I)=>{m()||v.sortField(s,I);},onContextMenu:(s,I,$,Q,z)=>{m()||p.openFieldMenu(s,I,$,Q,z);},getFields:o,onMove:(s,I)=>{m()||v.moveField(s,I);},requestFocus:s=>{A=s;let $=document.activeElement?.closest?.("[data-drop-id]")?.getAttribute("data-drop-id");R=$?o().find(Q=>Q.id===$)?.area:void 0;}},H=Et({host:x,getI18n:()=>n,onCellPrepared:t.onCellPrepared,registry:t.registry,shared:C,chipDeps:F,hasCellClick:()=>!!t.onCellClick&&!m(),columnWidthDefaults:resolveColumnWidthDefaults(t.defaultColumnWidths),rowHeight:E}),G=mt({...F,host:g,onGlobalContextMenu:f,onToggleCollapsed:()=>{m()||v.setLayout({filterAreaCollapsed:v.getState().layout.filterAreaCollapsed!==true});}});g.insertBefore(G.element,x);let O=Pe("kanuni-pivot-notice");O.setAttribute("role","status"),O.style.display="none",g.insertBefore(O,x);let N=()=>{let s=u.getHost();return s?[i,s]:[i]},U=Dt({gridRoot:i,roots:N,controller:v,getFields:o,onIntentChange:s=>bt(N(),s),disabled:m,touchDragDelay:()=>t.touchDragDelay}),we=Tt({scroller:H.scroller,controller:{toggleExpanded:s=>{m()||v.toggleExpanded(s);},toggleColExpanded:s=>{m()||v.toggleColExpanded(s);},sortField:(s,I)=>{m()||v.sortField(s,I);}},getVM:H.getVM,getTheadHeight:H.getTheadHeight,rowHeight:E,shared:C,onCellClick:t.disabled===true?void 0:t.onCellClick,resolveCellClick:s=>v.resolveCellClick(s),onGlobalContextMenu:(s,I)=>{m()||f(s,I);},onFilterClick:(s,I,$)=>{m()||y.open(s,I,$);},onHeaderContextMenu:(s,I,$,Q)=>{m()||p.openFieldMenu(s,I,$,Q);},onNodeContextMenu:s=>{m()||p.openNodeMenu(s);},keyboardEnabled:t.keyboardNavigation?.enabled!==false}),ie=ut({scroller:H.scroller,shared:C,getVM:H.getVM,onStats:s=>v.setSelectionStats(s)}),le=Mt({host:x,scroller:H.scroller,shared:C,isRtl:()=>n.rtl,getWidths:()=>v.getState().columnWidths??{},rowHeaderLayout:()=>H.rowHeaderLayout(),commit:s=>{m()||v.setColumnWidths(s);}}),ve=Ht(i,()=>{se.paint(v.getState()),H.refreshWindow();}),ye=Bt({portal:k,getI18n:()=>n,controller:v,getReports:()=>v.getState().reports??[],getActiveReportId:()=>v.getState().activeReportId??null,requestRepaint:()=>se.paint(v.getState())}),se=Ft({host:a,getI18n:()=>n,toolbar:t.toolbar,advancedExport:t.advancedExport===true,upgradeUrl:t.upgradeUrl,registry:t.registry,onToggleFieldChooser:()=>u.toggle(),fieldChooserOpen:()=>u.isOpen(),onRefresh:t.onRefresh,onExport:s=>{v.exportData(s,{applyFilters:true}).catch(I=>{let $=I instanceof Error?I:new Error(String(I));$.name!=="AbortError"&&(t.onError?t.onError($):console.error($));});},onExpandAll:()=>v.expandAll({allLevels:true}),onCollapseAll:()=>v.collapseAll(),onAddCalculatedField:t.onAddCalculatedField?()=>{m()||t.onAddCalculatedField();}:void 0,onOpenPrefilter:t.onOpenPrefilter?()=>{m()||t.onOpenPrefilter();}:void 0,onToggleChart:t.onToggleChart?()=>{m()||t.onToggleChart();}:void 0,onToggleFullscreen:()=>ve.toggle(),isFullscreen:()=>ve.isFullscreen(),onGlobalContextMenu:f,mountReportMenu:s=>ye.mount(s),onSearch:t.search?s=>v.setSearchText(s):void 0}),S=false,P=false,D=null,V=0;function X(){S||P||(P=true,queueMicrotask(ae));}function ae(){if(P=false,S)return;let s=v.getState(),I=!D||D.engineResult!==s.engineResult||D.fields!==s.fields||D.layout!==s.layout||D.expandedPaths!==s.expandedPaths||D.expandedColPaths!==s.expandedColPaths||D.columnWidths!==s.columnWidths,$=!D||D.isBuilding!==s.isBuilding||D.buildProgress!==s.buildProgress||D.engineError!==s.engineError||D.engineResult!==s.engineResult||D.noData!==s.noData,Q=!D||D.selectionStats!==s.selectionStats||D.reports!==s.reports||D.activeReportId!==s.activeReportId||D.layout!==s.layout;if(I&&(G.paint(shownFields(s.fields).filter(z=>z.area==="filter"),s.layout.showFilterArea!==false,{maxRows:s.layout.filterAreaMaxRows,collapsed:s.layout.filterAreaCollapsed===true}),u.isOpen()&&u.repaint()),I&&s.engineResult&&H.paintStructural(s),A!==void 0&&(((A?i.querySelector(`.kanuni-pivot-field-chip[data-drop-id="${A}"]`):R?i.querySelector(`[data-drop-id="${R}"]`):null)??H.scroller).focus({preventScroll:true}),A=void 0,R=void 0),$&&fe(s),!D||D.engineResult!==s.engineResult){let z=s.engineResult?.columnsTruncated;O.style.display=z?"":"none";let j=new Intl.NumberFormat(n.locale);O.textContent=z?n.t("columnsTruncated").replace("{shown}",j.format(z.shown)).replace("{total}",j.format(z.total)):"";}if(D&&D.searchText!==s.searchText&&se.syncSearch(s.searchText??""),D&&D.fields!==s.fields){let z=pivotChangeAnnouncement(D.fields,s.fields,n.t);z&&(h.textContent=nextLiveText(h.textContent??"",z));}Q&&(se.element.style.display=s.layout.showFooter===false?"none":"",se.paint(s)),D=s,V++;}function fe(s){if(s.engineError){d.style.display="block",d.textContent=`${n.t("error")}: ${s.engineError.message}`;return}if(s.isBuilding&&!s.engineResult){d.style.display="block",d.textContent=`${n.t("initializing")} ${Math.round(s.buildProgress??0)}%`;return}if(!s.engineResult){d.style.display="block",d.textContent=n.t(s.noData?"emptyData":"loading");return}d.style.display="none",d.textContent="";}let Y=t.onChartSync?et(v,()=>n.locale,t.chartIntegrationOptions??{},t.onChartSync):null,de=v.subscribe(X);ae();let T={controller:v,element:i,setData(s){S||v.setData(s);},applyTransaction(s){return v.applyTransaction(s)},applyTransactionAsync(s,I){v.applyTransactionAsync(s,I);},flushAsyncTransactions(){v.flushAsyncTransactions();},setLoading(s){v.setLoading(s);},undoLayout:()=>v.undoLayout(),redoLayout:()=>v.redoLayout(),canUndoLayout:()=>v.canUndoLayout(),canRedoLayout:()=>v.canRedoLayout(),clearLayoutHistory:()=>v.clearLayoutHistory(),setFields(s){S||v.setFields(s);},setSearchText(s){v.setSearchText(s);},setLocale(s,I,$){S||(n=Ve(s,I??t.dictionary,$??t.rtl),i.setAttribute("dir",n.rtl?"rtl":"ltr"),v.updateOptions({locale:n.locale}),D=null,X(),u.relocalize(),Y?.refresh());},openFieldChooser:()=>u.open(),closeFieldChooser:()=>u.close(),clearAllFilters:()=>v.clearAllFilters(),setDensity(s){S||(L()&&i.classList.remove(L()),M=s,L()&&i.classList.add(L()),D=null,X());},destroy(){S||(S=true,de(),c(),Y?.stop(),u.destroy(),U.destroy(),we.destroy(),ie.destroy(),le.destroy(),G.destroy(),ye.destroy(),se.destroy(),ve.destroy(),k.destroy(),H.destroy(),v.dispose(),i.remove(),r||tt.delete(l));}};return Object.defineProperty(T,"__flushCount",{get:()=>V}),Object.defineProperty(T,"__shared",{get:()=>C}),Object.defineProperty(T,"__dragRootCount",{get:()=>U.rootCount()}),T}
|
|
3
|
-
export{et as createChartSync,
|
|
1
|
+
import {ko,ja,zhCN,ru,pt as pt$1,it as it$1,es,fr,de,ar,en as en$1,tr,percentModeText,pivotSchemeTheme,PivotController,bindPivotScrollMemory,resolveColumnWidthDefaults,pivotDensityClass,shownFields,keepFocusAcross,pivotChangeAnnouncement,nextLiveText,placePopup,popupViewport,countFilteredFields,filterAreaRows,filterAreaMaxHeight,pathKey,filterEmptySummaryTree,buildColumnHeaders,flattenRowTreeTree,flattenRowTreeTabular,grandTotalShown,columnSlotOptions,getVisibleColSlots,fieldNeedsRange,computeFieldRanges,formatDimensionValue,summaryTypeLabel,MAX_C,computeRowHeaderWidths,getFieldDistinctValues,extractGroupValue,collatorFor,headerFilterShown,pathParts,headerFilterWrite,pivotRowHeight,resolveConditionalVisual,invertRowHeaderWidth}from'@kanunilabs/pivotgrid-core';export{PivotController,defaultPivotLayout,getAdvancedExporter,registerAdvancedExporter}from'@kanunilabs/pivotgrid-core';var en={tr:tr,en:en$1,ar:ar,de:de,fr:fr,es:es,it:it$1,pt:pt$1,ru:ru,"zh-CN":zhCN,ja:ja,ko:ko};function Ve(e,t,n){let r=e??"en",l={...en$1,...en[r]??{},...t??{}};return {locale:r,rtl:n!==void 0?n:r==="ar",dictionary:l,t:a=>l[a]||a}}var tn={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)"},nt=new Set;function rt(e){for(let t of Object.keys(e)){let n=tn[t];!n||nt.has(t)||(nt.add(t),console.warn(`[pivotgrid] config key "${t}" is React-only and ignored \u2014 ${n}`));}}var nn=[["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 it(e,t){for(let[n,r]of nn){let l=t?typeof n=="function"?n(t):t[n]:void 0;typeof l=="string"&&l?e.style.setProperty(r,l):e.style.removeProperty(r);}t?.id?e.setAttribute("data-theme",t.id):e.removeAttribute("data-theme");}var Ke=(e,t)=>(e.areaIndex||0)-(t.areaIndex||0);function dt(e,t){let n=shownFields(e.fields),r=e.layout,l=n.filter(m=>m.area==="row").sort(Ke),a=n.filter(m=>m.area==="column").sort(Ke),s=n.filter(m=>m.area==="data").sort(Ke),C=e.engineResult,k=e.expandedPaths.has("*"),M=e.expandedColPaths.has("*"),R=r.rowHeaderLayout==="tree"?1:l.length||1,y=r.dataFieldPosition==="rows"&&s.length>1,f=y?1:s.length;if(!C)return {rowFields:l,colFields:a,dataFields:s,colHeaders:[],virtualRows:[],leafColHashes:[],cellLookup:new Map,fieldRanges:{},engineResult:null,layout:r,maxRowDepth:R,showDataInRows:y,dfsPerLeaf:f,totalDataCols:0,dataColOffset:R+(y?1:0)};let[x,g]=r.hideEmptySummaryCells?filterEmptySummaryTree(C):[C.rowTree,C.colTree],h=buildColumnHeaders(g,s,r,e.expandedColPaths,M,t),w=r.rowHeaderLayout==="tree"?flattenRowTreeTree(x,e.expandedPaths,k,l.length||1,r.showRowTotals??true,r.totalsPosition??"bottom",r.showTotalsForSingleValues!==false):flattenRowTreeTabular(x,e.expandedPaths,k,R,r.showRowTotals??true,r.totalsPosition??"bottom",r.showTotalsForSingleValues!==false),i=[];for(let m of w)if(y&&!m.isSubtotal&&!m.hasChildren)for(let E=0;E<s.length;E++)i.push({flatRow:m,dfIndex:E,isDataRow:true,isGrandTotal:false});else i.push({flatRow:m,dfIndex:0,isDataRow:false,isGrandTotal:false});if(grandTotalShown(r,"row",x))if(y)for(let m=0;m<s.length;m++)i.push({flatRow:null,dfIndex:m,isDataRow:true,isGrandTotal:true});else i.push({flatRow:null,dfIndex:0,isDataRow:false,isGrandTotal:true});let p=columnSlotOptions(r),u=[];for(let m of getVisibleColSlots(g,e.expandedColPaths,M,p))u.push({hash:m.node.key,isGrandTotal:!!m.node.isTotal,isSubtotal:m.isSubtotal});(grandTotalShown(r,"column",g)||u.length===0)&&u.push({hash:"",isGrandTotal:true});let v=new Map,c=C.cellMatrix.keys;for(let m=0;m<c.length;m++)v.set(c[m],m);let o=s.some(fieldNeedsRange)?computeFieldRanges(C,s):{};return {rowFields:l,colFields:a,dataFields:s,colHeaders:h,virtualRows:i,leafColHashes:u,cellLookup:v,fieldRanges:o,engineResult:C,layout:r,maxRowDepth:R,showDataInRows:y,dfsPerLeaf:f,totalDataCols:u.length*f,dataColOffset:R+(y?1:0)}}function _e(e,t,n,r,l){let a=e.engineResult,s=a.rowIndexMap[t]??-1,C=a.columnIndexMap[n]??-1;if(s===-1||C===-1)return null;let k=e.cellLookup.get(s*MAX_C+C);if(k===void 0)return null;let M=e.dataFields.length,R=a.cellMatrix.sums,y=a.cellMatrix.displaySums,f={};for(let x=0;x<M;x++)f[e.dataFields[x].id]=R[k*M+x],y&&(f[`${e.dataFields[x].id}_display`]=y[k*M+x]);return {values:f,rowPath:pathParts(t),colPath:pathParts(n),isTotalCell:s===0||C===0||r||l}}function ct(e,t,n){if(!e.engineResult||n<e.dataColOffset)return null;let r=n-e.dataColOffset,l=Math.floor(r/e.dfsPerLeaf),a=r%e.dfsPerLeaf;if(l>=e.leafColHashes.length)return null;let s=e.virtualRows[t];if(!s)return null;let C=s.isGrandTotal?"":s.flatRow?.key;if(C===void 0)return null;let k=e.leafColHashes[l]?.hash;if(k===void 0)return null;let M=e.engineResult.rowIndexMap[C],R=e.engineResult.columnIndexMap[k];if(M===void 0||R===void 0)return null;let y=e.cellLookup.get(M*MAX_C+R);if(y===void 0)return null;let f=e.showDataInRows?s.dfIndex:a,g=e.engineResult.cellMatrix.sums[y*e.dataFields.length+f];return typeof g=="number"?g:null}function Xe(e,t,n){let r=e.virtualRows[t];if(!r||r.isGrandTotal||!r.flatRow)return null;let l=r.flatRow,a=e.layout.rowHeaderLayout==="tree",s=n,C=a?l.depth:s,k=C===l.depth,M=C<l.depth,R=k?l.hasChildren:M,y=k?l.isExpanded:M,f=a?l.key:pathKey(l.pathValues.slice(0,s+1));return {hasChildren:R,isExpanded:y,cellHashStr:f,depth:C,dIdx:s,flatRow:l}}function pt(e,t,n){if(n<e.dataColOffset||!e.engineResult)return null;let r=n-e.dataColOffset,l=Math.floor(r/e.dfsPerLeaf),a=r%e.dfsPerLeaf;if(l>=e.leafColHashes.length)return null;let s=e.virtualRows[t];if(!s)return null;let C=s.isGrandTotal?"":s.flatRow?.key;if(C===void 0)return null;let k=e.leafColHashes[l],M=_e(e,C,k.hash,!!s.flatRow?.isSubtotal,k.isGrandTotal);if(!M)return null;let R=e.showDataInRows?s.dfIndex:a,y=e.dataFields[R],f=M.values[`${y?.id}_display`]??M.values[y?.id],x=!!s.flatRow?.isSubtotal||k.isGrandTotal||M.isTotalCell;return {cell:{isTotalCell:M.isTotalCell,rowPath:M.rowPath,colPath:M.colPath,values:M.values},val:f,isTotal:x}}function ze(e){let t=new Map;return (n,r)=>{if(n==null||Number.isNaN(n))return "";if(r.format&&typeof n=="number"){if(typeof r.format=="function")return r.format(n);try{let l=r.format,a=t.get(l);a||(a=new Intl.NumberFormat(e,l),t.set(l,a));let s=a.format(n);return l.isCustom&&(l.prefix||l.suffix)?`${l.prefix||""}${s}${l.suffix||""}`:s}catch{return String(n)}}return typeof n=="number"&&percentModeText(n,r,e)||String(n)}}var Re=null;function $e(e,t,n){if(!e)return false;let r=Math.min(e.startR,e.endR),l=Math.max(e.startR,e.endR),a=Math.min(e.startC,e.endC),s=Math.max(e.startC,e.endC);return t>=r&&t<=l&&n>=a&&n<=s}function ut(e){let{scroller:t,shared:n}=e,r={},l="",a=null,s=false;function C(){for(let x of t.querySelectorAll("td[data-r][data-c]")){let g=Number(x.getAttribute("data-r")),h=Number(x.getAttribute("data-c"));x.classList.toggle("kanuni-pivot-cell-selected",$e(n.selection,g,h));}}function k(){let x=n.selection;if(e.onStats){if(!x||x.mode!=="data"){a&&(clearTimeout(a),a=null),s&&(s=false,e.onStats(null));return}a&&clearTimeout(a),a=setTimeout(()=>{a=null;let g=n.selection;if(!g||g.mode!=="data")return;let h=Math.min(g.startR,g.endR),w=Math.max(g.startR,g.endR),i=Math.min(g.startC,g.endC),p=Math.max(g.startC,g.endC),u=0,v=0,c=1/0,o=-1/0,m=e.getVM();if(m){for(let E=h;E<=w;E++)for(let b=i;b<=p;b++){let S=ct(m,E,b);S===null||isNaN(S)||(u+=S,v++,S<c&&(c=S),S>o&&(o=S));}s=v>0,e.onStats(v>0?{sum:u,count:v,avg:u/v,min:c,max:o}:null);}},10);}}n.selectByKey=(x,g,h,w)=>{let i=e.getVM();if(!i)return;let p=g<i.dataColOffset?"row":"data",u=n.selection;if(Re=r,l="",h&&u&&u.mode===p){if(u.endR===x&&u.endC===g&&!u.isSelecting)return;n.selection={...u,endR:x,endC:g,isSelecting:false};}else if(h){let c=(w.c<i.dataColOffset?"row":"data")===p?w:{r:x,c:g};n.selection={startR:c.r,startC:c.c,endR:x,endC:g,isSelecting:false,mode:p};}else {if(u&&u.mode===p&&!u.isSelecting&&u.startR===x&&u.startC===g&&u.endR===x&&u.endC===g)return;n.selection={startR:x,startC:g,endR:x,endC:g,isSelecting:false,mode:p};}C(),k();};let M=x=>{if(x.button!==0||n.isResizing||x.target.closest?.(".kanuni-pivot-resize-handle"))return;let g=x.target.closest?.("td[data-r][data-c]");if(!g)return;let h=e.getVM();if(!h)return;let w=Number(g.getAttribute("data-r")),i=Number(g.getAttribute("data-c")),p=i<h.dataColOffset?"row":"data";Re=r,l="",n.selection={startR:w,startC:i,endR:w,endC:i,isSelecting:true,mode:p},C(),k();},R=x=>{let g=n.selection;if(!g||!g.isSelecting)return;let h=x.target.closest?.("td[data-r][data-c]");if(!h)return;let w=Number(h.getAttribute("data-r")),i=Number(h.getAttribute("data-c")),p=`${w},${i}`;if(p===l)return;l=p;let u=e.getVM();!u||(i<u.dataColOffset?"row":"data")!==g.mode||w===g.endR&&i===g.endC||(g.endR=w,g.endC=i,C(),k());},y=()=>{n.selection&&(n.selection.isSelecting=false);},f=x=>{if(!(x.ctrlKey||x.metaKey)||x.key!=="c"||Re!==null&&Re!==r)return;let g=n.selection;if(!g)return;let h=Math.min(g.startR,g.endR),w=Math.max(g.startR,g.endR),i=Math.min(g.startC,g.endC),p=Math.max(g.startC,g.endC),u="";for(let v=h;v<=w;v++){let c=[];for(let o=i;o<=p;o++){let m=t.querySelector(`[data-r="${v}"][data-c="${o}"]`);c.push(m?(m.innerText??m.textContent??"").trim().replace(/\n/g," "):"");}u+=c.join(" ")+`
|
|
2
|
+
`;}u&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(u).catch(()=>{});};return t.addEventListener("mousedown",M),t.addEventListener("mouseover",R),document.addEventListener("mouseup",y),document.addEventListener("keydown",f),{destroy(){t.removeEventListener("mousedown",M),t.removeEventListener("mouseover",R),document.removeEventListener("mouseup",y),document.removeEventListener("keydown",f),a&&clearTimeout(a),Re===r&&(Re=null),n.selectByKey=void 0;}}}var ht={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 ft="http://www.w3.org/2000/svg";function q(e,t=15,n){let r=document.createElementNS(ft,"svg");r.setAttribute("width",String(t)),r.setAttribute("height",String(t)),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("fill","none"),r.setAttribute("stroke","currentColor"),r.setAttribute("stroke-width","2"),r.setAttribute("stroke-linecap","round"),r.setAttribute("stroke-linejoin","round"),r.setAttribute("aria-hidden","true"),r.setAttribute("focusable","false"),n&&(r.style.color=n);for(let[l,a]of ht[e]??[]){let s=document.createElementNS(ft,l);for(let[C,k]of Object.entries(a))s.setAttribute(C,String(k));r.appendChild(s);}return r}function Fe(e,t=15,n){let r=q(e,t,n);return r.setAttribute("fill","currentColor"),r}function pe(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Ye(e){let t=document.activeElement;return !t||!e.contains(t)?null:t.closest(".kanuni-pivot-field-chip")?.getAttribute("data-drop-id")??null}function Ue(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 yn(e,t,n){let r=e.filter(l=>l.area===t);return t==="filter"?vt(r,n):r.sort((l,a)=>(l.areaIndex||0)-(a.areaIndex||0))}var xn={row:"rowArea",column:"columnArea",data:"dataArea",filter:"filterArea"};function Be(e,t){let{t:n,locale:r,rtl:l}=t.getI18n(),a=pe("kanuni-pivot-field-chip");a.setAttribute("data-drop-id",e.id),a.style.position="relative",a.style.cursor="pointer",a.setAttribute("role","button"),a.tabIndex=0;let s=t.getFields?yn(t.getFields(),e.area,r):[e],C=Math.max(0,s.findIndex(i=>i.id===e.id)),k=n(xn[e.area??""]??"rowArea");a.setAttribute("aria-label",n("fieldChipLabel").replace("{0}",e.caption||e.id).replace("{1}",k).replace("{2}",String(C+1)).replace("{3}",String(s.length))),a.setAttribute("aria-keyshortcuts","Control+ArrowLeft Control+ArrowRight Control+Home Control+End Delete Alt+ArrowDown Shift+F10"),a.setAttribute("aria-description",n("fieldChipKeys"));let M=()=>{if(!t.onSort)return;let i=e.sortOrder==="asc"?"desc":e.sortOrder==="desc"?void 0:"asc";t.onSort(e.id,i);},R=i=>{if(!i)return;(a.closest(".kanuni-pivot-root")??document.body).querySelector(`.kanuni-pivot-field-chip[data-drop-id="${i}"]`)?.focus({preventScroll:true});};a.addEventListener("keydown",i=>{let p=i.ctrlKey||i.metaKey,u=l?"ArrowRight":"ArrowLeft",v=l?"ArrowLeft":"ArrowRight",c=!!t.onMove&&e.area!=="filter",o=true;if(i.key==="Enter"||i.key===" ")M();else if(p&&c&&(i.key===u||i.key==="ArrowUp"))C>0&&t.onMove(e.id,"left");else if(p&&c&&(i.key===v||i.key==="ArrowDown"))C<s.length-1&&t.onMove(e.id,"right");else if(p&&c&&i.key==="Home")C>0&&t.onMove(e.id,"start");else if(p&&c&&i.key==="End")C<s.length-1&&t.onMove(e.id,"end");else if(!p&&(i.key===u||i.key===v)){let m=i.key===u?-1:1;R(s[C+m]?.id);}else if(i.key==="Delete"||i.key==="Backspace"){let m=s[C+1]??s[C-1];t.requestFocus?.(m?.id??null),t.onRemove(e.id);}else if(i.altKey&&i.key==="ArrowDown"){let m=a.getBoundingClientRect();t.onFilterClick(l?m.right:m.left,m.bottom,e.id);}else if(i.key==="F10"&&i.shiftKey||i.key==="ContextMenu"){if(!t.onContextMenu)return;let m=a.getBoundingClientRect();t.onContextMenu(l?m.right:m.left,m.bottom,e.id,void 0,true);}else o=false;o&&(i.preventDefault(),i.stopPropagation());});let y=pe("pivot-truncate","span");Object.assign(y.style,{maxWidth:"120px",userSelect:"none"}),y.textContent=e.caption||e.id,a.appendChild(y),e.sortOrder==="asc"&&a.appendChild(q("arrow-up",12,"var(--pivot-primary)")),e.sortOrder==="desc"&&a.appendChild(q("arrow-down",12,"var(--pivot-primary)"));let f=e.area==="data"&&e.summaryType?summaryTypeLabel(String(e.summaryType),n):"";if(f){let i=pe("","span");Object.assign(i.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"}),i.textContent=f,a.appendChild(i);}let x=!!e.filterValues&&e.filterValues.size>0||!!e.valueFilter||!!e.labelFilter,g=pe(`kanuni-pivot-field-chip-actions${x?" is-filtered":""}`);g.setAttribute("aria-hidden","true");let h=pe("kanuni-pivot-chip-btn","span");h.title=n("filterField"),h.style.color=x?"var(--pivot-danger)":"inherit",h.appendChild(q("filter",12)),h.addEventListener("pointerdown",i=>i.stopPropagation()),h.addEventListener("click",i=>{i.stopPropagation(),t.onFilterClick(i.clientX,i.clientY,e.id);});let w=pe("kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger","span");if(w.title=n("removeField"),w.appendChild(q("x",12)),w.addEventListener("pointerdown",i=>i.stopPropagation()),w.addEventListener("click",i=>{i.stopPropagation(),t.onRemove(e.id);}),g.append(h,w),a.appendChild(g),t.onContextMenu){a.setAttribute("data-chip-menu","");let i=pe(`kanuni-pivot-chip-more${x?" is-filtered":""}`,"span");if(i.setAttribute("aria-hidden","true"),i.addEventListener("pointerdown",p=>p.stopPropagation()),i.addEventListener("click",p=>{p.stopPropagation();let u=i.getBoundingClientRect();t.onContextMenu(l?u.right:u.left,u.bottom,e.id,void 0);}),a.appendChild(i),x){let p=q("filter",10);p.classList.add("kanuni-pivot-chip-filtered-mark"),p.setAttribute("aria-hidden","true"),a.appendChild(p);}}return a.addEventListener("click",i=>{i.stopPropagation(),M();}),a.addEventListener("contextmenu",i=>{if(i.stopPropagation(),t.onContextMenu){i.preventDefault();let p=a.getBoundingClientRect(),u=Number.isFinite(i.clientX)?i.clientX:l?p.right:p.left,v=Number.isFinite(i.clientY)?i.clientY:p.bottom;t.onContextMenu(u,v,e.id,void 0);}}),a}function Ne(e,t,n,r,l){let{t:a}=l.getI18n(),s=pe("kanuni-pivot-area-dropzone");s.setAttribute("data-drop-id",e),s.tabIndex=-1;let C=pe("kanuni-pivot-area-header");C.appendChild(q(n,13)),C.appendChild(document.createTextNode(t)),s.appendChild(C);let k=pe("kanuni-pivot-area-content");if(r.length===0){let R=pe("pivot-text-xs pivot-text-muted","span");Object.assign(R.style,{fontStyle:"italic",padding:"0 8px"}),R.textContent=a("dropHere"),k.appendChild(R);}for(let R of r)k.appendChild(Be(R,l));let M=pe("kanuni-pivot-ghost-end");return M.setAttribute("data-drop-id",`${e}-ghost-end`),M.setAttribute("data-ghost-populated",r.length>0?"1":"0"),Object.assign(M.style,{flex:"1",minWidth:"40px",minHeight:"24px",borderRadius:"var(--pivot-border-radius-sm)",transition:"background-color 0.2s"}),k.appendChild(M),s.appendChild(k),s}function vt(e,t){let n=new Map;return e.map(l=>{let a=l.caption||l.id||"";if(n.has(a)){let s=n.get(a)+1;return n.set(a,s),{...l,caption:`${a} (${s})`}}return n.set(a,1),l}).sort((l,a)=>(l.caption||"").toLowerCase().localeCompare((a.caption||"").toLowerCase(),t||"en"))}function mt(e){let t=pe("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 r(l,a,s){let{t:C}=e.getI18n(),k=l.querySelector(".kanuni-pivot-area-header"),M=l.querySelector(".kanuni-pivot-area-content"),R=s.collapsed===true;if(R&&l.setAttribute("data-collapsed",""),k&&R){let x=countFilteredFields(a);if(x>0){let g=pe("kanuni-pivot-area-filtered-count","span");g.textContent=C("filteredFieldCount").replace("{0}",String(x)),k.appendChild(g);}}if(k&&e.onToggleCollapsed&&a.length>0){let x=pe("kanuni-pivot-area-collapse","button");x.type="button";let g=C(R?"expandFilterArea":"collapseFilterArea");x.setAttribute("aria-expanded",String(!R)),x.setAttribute("aria-label",g),x.title=g;let h=q("chevron-down",14);R||(h.style.transform="rotate(180deg)"),x.appendChild(h),x.addEventListener("click",w=>{w.stopPropagation(),e.onToggleCollapsed();}),k.appendChild(x);}let y=filterAreaRows({filterAreaMaxRows:s.maxRows,filterAreaCollapsed:R});if(!M||y===null)return;let f=M.querySelector(".kanuni-pivot-field-chip");M.style.maxHeight=`${filterAreaMaxHeight(y,f?.offsetHeight||28)}px`,M.style.overflowY=R?"hidden":"auto";}return {element:t,paint(l,a,s={}){t.style.display=a?"":"none";let C=Ye(t);if(t.textContent="",!a)return;let k=pe("pivot-flex");k.style.width="100%";let{t:M,locale:R}=e.getI18n(),y=Ne("filter",M("filterArea"),"filter",vt(l,R),e);k.appendChild(y),t.appendChild(k),r(y,l,s),Ue(t,C);},destroy(){t.removeEventListener("contextmenu",n),t.remove();}}}var gt="kanuni-pivot-drop-indicator";function Cn(e){let t=pe(gt);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=pe("");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 r=pe("");Object.assign(r.style,{position:"absolute",bottom:"0",width:"0",height:"0",borderBottom:"5px solid var(--pivot-primary)"}),r.style.setProperty("inset-inline-start","-4px"),r.style.setProperty("border-inline-start","4px solid transparent"),r.style.setProperty("border-inline-end","4px solid transparent");let l=pe("");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,r,l),t}function bt(e,t){for(let n of e){for(let r of n.querySelectorAll(`.${gt}`))r.remove();for(let r of n.querySelectorAll('[data-drop-id$="-ghost-end"]'))r.style.backgroundColor="transparent",r.style.boxShadow="none",r.textContent="";for(let r of n.querySelectorAll(".pivot-area-strip--over"))r.classList.remove("pivot-area-strip--over");for(let r of n.querySelectorAll('[data-drop-kind="list"]'))r.style.backgroundColor="transparent",r.style.boxShadow="none";}if(t.intent==="before"||t.intent==="after"){if(!t.targetId)return;for(let n of e){let r=n.querySelector(`[data-drop-id="${t.targetId}"]`)??n.querySelector(`[data-drop-id="chooser-${t.targetId}"]`);if(r){r.appendChild(Cn(t.intent));return}}}else if(t.intent==="append"&&t.targetArea)for(let n of e){let r=n.querySelector(`[data-drop-id="${t.targetArea}-ghost-end"]`)??n.querySelector(`[data-drop-id="chooser-${t.targetArea}-ghost-end"]`);if(r&&(r.style.backgroundColor="color-mix(in srgb, var(--pivot-primary) 10%, transparent)",r.style.boxShadow="inset 0 0 0 1px color-mix(in srgb, var(--pivot-primary) 50%, transparent)",r.getAttribute("data-ghost-populated")==="1")){let s=pe("");Object.assign(s.style,{width:"4px",height:"100%",backgroundColor:"var(--pivot-primary)",borderRadius:"2px",marginLeft:"4px"}),r.appendChild(s);}n.querySelector(`[data-drop-id="${t.targetArea}"]`)?.classList.add("pivot-area-strip--over");let a=n.querySelector(`[data-drop-id="chooser-${t.targetArea}"][data-drop-kind="list"]`);a&&(a.style.backgroundColor="color-mix(in srgb, var(--pivot-primary) 5%, transparent)",a.style.boxShadow="inset 0 0 0 1px color-mix(in srgb, var(--pivot-primary) 50%, transparent)");}}var Tn={style:{}},Mn=28,xt=5,Ln=10,Ct=40,wt=8,Ze=100;function X(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function J(e,t){for(let[n,r]of Object.entries(t)){if(r==null)continue;let l=n.replace(/[A-Z]/g,a=>"-"+a.toLowerCase());e.style.setProperty(l,typeof r=="number"&&r!==0&&!/z-?index|font-?weight|opacity/i.test(n)?`${r}px`:String(r));}}function We(e,t,n,r){let l=X("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(r,"-3px"),l}function He(e,t){e.textContent="",t!=null&&(typeof t=="string"||typeof t=="number"?e.textContent=String(t):e.appendChild(t));}function Et(e){let{host:t,getI18n:n}=e,r=e.columnWidthDefaults??resolveColumnWidthDefaults(),l=e.rowHeight??(()=>Mn),a=e.shared?.cellId??((L,P)=>`pivot-cell-${L}-${P}`),s=X("datagrid-table-wrapper custom-scrollbar pivot-right-pane");J(s,{overflow:"auto",flex:"1 1 auto",minHeight:0,position:"relative",outline:"none"}),s.tabIndex=0,s.setAttribute("role","grid");let C=X("");J(C,{width:"max-content",position:"relative",minWidth:"100%"});let k=X("kanuni-pivot-table","table");k.setAttribute("role","presentation"),J(k,{borderCollapse:"separate",borderSpacing:0,width:0,minWidth:"100%",tableLayout:"fixed"});let M=document.createElement("colgroup"),R=X("","thead");R.setAttribute("role","rowgroup"),J(R,{position:"sticky",top:0,zIndex:50,backgroundColor:"var(--pivot-surface-header)"});let y=X("","tbody");y.setAttribute("role","rowgroup"),k.append(M,R,y),C.appendChild(k),s.appendChild(C),t.appendChild(s);let f=null,x=ze(n().locale),g=n().locale,h={start:-1,end:-1},w={start:0,end:Number.MAX_SAFE_INTEGER},i={},p=new Set,u=false,v=()=>f?Math.max(f.colHeaders.length,1)*l()+(e.chipDeps?42:0):0,c=L=>i[`row-${L}`]??r.rowHeader,o=()=>i[`row-${f.maxRowDepth}`]??Ze,m=L=>i[`leaf-${L}`]??r.data;function E(){if(!f||f.totalDataCols<=Ct){w={start:0,end:Number.MAX_SAFE_INTEGER};return}let L=Math.abs(s.scrollLeft),P=S().total,D=L-P,V=0,Y=0;for(;V<f.totalDataCols&&Y+m(V)<=D;)Y+=m(V),V++;V=Math.max(0,V-wt);let ae=s.clientWidth||0,ve=V,U=0;for(;ve<f.totalDataCols&&U<=ae;)U+=m(ve),ve++;w={start:V,end:Math.min(f.totalDataCols,ve+wt)};}function b(){if(!f)return {start:0,end:0};let L=Math.max(0,s.scrollTop-v()),P=Math.max(0,Math.floor(L/l())-xt),D=Math.ceil((s.clientHeight||600)/l())+Ln;return {start:P,end:Math.min(f.virtualRows.length,P+D+xt)}}function S(){let L=[];for(let P=0;P<f.maxRowDepth;P++)L.push(c(P));return f.showDataInRows&&L.push(o()),computeRowHeaderWidths(L,s.clientWidth)}function F(){let{widths:L,total:P}=S(),D=0;for(let V=0;V<L.length;V++)s.style.setProperty(`--row-header-left-${V}`,`${D}px`),s.style.setProperty(`--col-width-row-${V}`,`${L[V]}px`),p.add(`--col-width-row-${V}`),D+=L[V];s.style.setProperty("--row-header-total-width",`${P}px`);}function A(){M.textContent="";for(let L=0;L<f.maxRowDepth;L++){let P=document.createElement("col");P.style.width=`var(--col-width-row-${L}, ${r.rowHeader}px)`,M.appendChild(P);}if(f.showDataInRows){let L=document.createElement("col");L.style.width=`var(--col-width-row-${f.maxRowDepth}, ${Ze}px)`,M.appendChild(L);}for(let L=0;L<Math.max(f.totalDataCols,1);L++){let P=document.createElement("col");P.style.width=`var(--col-width-data-${L}, ${r.data}px)`,M.appendChild(P);}}function H(){let{colHeaders:L,rowFields:P,colFields:D,dataFields:V,maxRowDepth:Y,showDataInRows:ae,layout:ve,dataColOffset:U}=f,{t:de,locale:T}=n(),d=Ye(R);R.textContent="";let I=Math.max(L.length,1),B=e.chipDeps;if(B){let Q=X("","tr");Q.setAttribute("role","row"),J(Q,{height:42});let z=X("","th");z.setAttribute("role","columnheader"),z.colSpan=Math.max(U,1),J(z,{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)"}),z.style.setProperty("inset-inline-start","0px"),z.appendChild(Ne("data",de("dataArea"),"bar-chart-3",V,B)),Q.appendChild(z);let j=X("","th");j.setAttribute("role","columnheader"),j.colSpan=Math.max(f.totalDataCols,1),J(j,{borderBottom:"1px solid var(--pivot-border)",padding:0,verticalAlign:"top",zIndex:1,backgroundColor:"var(--pivot-surface-header)"});let W=X("");J(W,{position:"sticky",width:"max-content",maxWidth:"100%"}),W.style.setProperty("inset-inline-start","var(--row-header-total-width, 0px)"),W.appendChild(Ne("column",de("columnArea"),"columns3",D,B)),j.appendChild(W),Q.appendChild(j),R.appendChild(Q);}for(let Q=0;Q<I;Q++){let z=X("","tr");if(z.setAttribute("role","row"),J(z,{height:l()}),Q===0){let W=G=>({position:"sticky",top:0,zIndex:60,backgroundColor:"var(--pivot-surface-header)",borderBottom:"1px solid var(--pivot-border)",borderInlineEnd:G?"1px solid var(--pivot-border)":"none",verticalAlign:"bottom",padding:"4px 8px",color:"var(--pivot-text-header)"});if(P.length===0){let G=X("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");G.setAttribute("data-drop-id","row"),G.setAttribute("data-row-header-idx","0"),G.rowSpan=I,G.colSpan=Math.max(U,1),J(G,{...W(true),padding:"8px",color:"color-mix(in srgb, var(--pivot-text-header, var(--pivot-text)) 70%, transparent)"}),G.style.setProperty("inset-inline-start","var(--row-header-left-0, 0px)"),G.textContent=de("dropHere"),z.appendChild(G);}else if(ve.rowHeaderLayout==="tree"){let G=X("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");if(G.setAttribute("data-row-header-idx","0"),G.rowSpan=I,J(G,W(!ae)),G.style.setProperty("inset-inline-start","var(--row-header-left-0, 0px)"),B){let _=X("");J(_,{display:"flex",flexWrap:"wrap",gap:4});for(let re of P)_.appendChild(Be(re,B));G.appendChild(_);}else He(G,P.map(_=>_.caption).join(", "));z.appendChild(G);}else for(let G=0;G<Y;G++){let _=X("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");_.setAttribute("data-row-header-idx",String(G)),_.rowSpan=I,J(_,W(G===Y-1&&!ae)),_.style.setProperty("inset-inline-start",`var(--row-header-left-${G}, 0px)`);let re=P[G];re&&B?_.appendChild(Be(re,B)):He(_,re?.caption??""),z.appendChild(_);}if(ae&&P.length>0){let G=X("kanuni-pivot-header-cell kanuni-pivot-header-corner","th");G.setAttribute("data-row-header-idx",String(Y)),G.rowSpan=I,J(G,W(true)),G.style.setProperty("inset-inline-start",`var(--row-header-left-${Y}, 0px)`);let _=X("");J(_,{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=de("dataArea"),G.appendChild(_),z.appendChild(G);}}let j=L[Q]??[];for(let W of j){let G=W.fieldId?D.find(oe=>oe.id===W.fieldId):void 0,_=!!G?.filterValues&&G.filterValues.size>0,re=W.leafStart,ge=G&&!W.isTotal?formatDimensionValue(W.caption,G,"grid",T):W.caption,ce={text:typeof G?.cellTemplate=="function"?G.cellTemplate({value:W.caption,displayValue:ge,field:G})??null:String(ge??""),style:{textAlign:"left",fontWeight:W.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:G?"pointer":"context-menu",position:"relative",zIndex:1,padding:"4px 6px"},className:`kanuni-pivot-header-cell group ${W.isTotal?"kanuni-pivot-header-total":""}`};e.onCellPrepared?.({area:"column",cell:null,rowIndex:Q,columnIndex:re,cellConfig:ce});let Z=X(ce.className,"th");Z.setAttribute("role","columnheader"),W.hasChildren&&Z.setAttribute("aria-expanded",String(!!W.isExpanded)),Z.colSpan=W.colSpan,Z.rowSpan=W.rowSpan,J(Z,ce.style);let ee=X("pivot-flex pivot-items-center");if(J(ee,{gap:4}),W.hasChildren){let oe=X("kanuni-pivot-expand-icon","span");oe.textContent=W.isExpanded?"\u2212":"+",oe.setAttribute("aria-hidden","true"),oe.setAttribute("data-col-expand",W.colPath??""),J(oe,{cursor:"pointer",marginRight:4,flexShrink:0}),ee.appendChild(oe);}let Ee=X("select-none","span");He(Ee,ce.text),ee.appendChild(Ee);let Ce=f.rowFields.find(oe=>oe.sortBySummaryField===W.fieldId&&(oe.sortBySummaryPath||"")===(W.colPath||""));if(Ce){let oe=X("pivot-text-primary kanuni-pivot-sort-arrow","span");oe.appendChild(q(Ce.sortOrder==="asc"?"arrow-up":"arrow-down",12)),ee.appendChild(oe);}if(W.fieldId){let oe=X(`kanuni-pivot-head-filter cursor-pointer transition-opacity ${_?"opacity-100 pivot-text-danger":"opacity-0 group-hover:opacity-70"}`,"span");oe.setAttribute("data-filter-field",W.fieldId),oe.appendChild(_?Fe("filter",10):q("filter",10)),ee.appendChild(oe);}Z.appendChild(ee),W.fieldId&&Z.setAttribute("data-header-field",W.fieldId),W.colPath!==void 0&&Z.setAttribute("data-header-col-path",W.colPath),Z.setAttribute("data-header-depth",String(Q)),Z.appendChild(We(`leaf-${re}-${W.colSpan}`,r.data,W.colSpan,"right")),z.appendChild(Z);}R.appendChild(z);}Ue(R,d);}function N(L,P,D,V){let Y=P.flatRow,{rowFields:ae,layout:ve,maxRowDepth:U,virtualRows:de}=f,{locale:T}=n(),d=ve.rowHeaderLayout==="tree",I=d?Y.depth:V,B=Y.pathValues[I],Q=Y.rowSpans[V]>0&&P.dfIndex===0,z=ae[I],j=z&&B!==null&&B!==void 0?formatDimensionValue(B,z,"grid",T):B,W=I===Y.depth,G=I<Y.depth,_=W?Y.hasChildren:G,re=W?Y.isExpanded:G,ge=de[D+1],me=!d&&ge&&!ge.isGrandTotal&&ge.flatRow&&!ge.flatRow.isSubtotal&&(ge.flatRow.rowSpans[V]===0||ge.dfIndex>0)&&ge.flatRow.pathValues[V]===B,ce=j!=null?String(j):null;typeof z?.cellTemplate=="function"&&ce!==null&&(ce=z.cellTemplate({value:j,displayValue:j,field:z})??ce);let Z={text:ce,style:{position:"sticky",backgroundColor:"var(--pivot-surface)",zIndex:40,cursor:_?"pointer":"default",fontWeight:j&&I<Y.depth?600:400,verticalAlign:"middle",padding:0,borderBottom: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===D&&e.shared?.focused?.c===V?" kanuni-pivot-cell-focused":""}${$e(e.shared?.selection??null,D,V)?" kanuni-pivot-cell-selected":""}`};e.onCellPrepared?.({area:"row",cell:null,rowIndex:D,columnIndex:V,cellConfig:Z});let ee=X(Z.className,"td");if(ee.id=a(D,V),ee.setAttribute("role","rowheader"),_&&ee.setAttribute("aria-expanded",String(re)),ee.setAttribute("data-r",String(D)),ee.setAttribute("data-c",String(V)),J(ee,Z.style),ee.style.setProperty("inset-inline-start",`var(--row-header-left-${V}, 0px)`),!d&&V>=Y.depth&&V<U-1&&ee.style.setProperty("border-inline-end","none"),!Q&&!d){ee.style.borderBottom="none",ee.appendChild(We(`row-${V}`,r.rowHeader,1,n().rtl?"left":"right")),L.appendChild(ee);return}let Ee=d?Y.depth*20:0,Ce=X("");if(J(Ce,{display:"flex",alignItems:"center",gap:4,padding:"0 8px",height:"100%",position:"relative"}),Ce.style.setProperty("padding-inline-start",`${8+Ee}px`),d&&Y.depth>0){let oe=X("kanuni-pivot-tree-line");J(oe,{position:"absolute",left:Ee,top:-l()/2,width:12,height:l(),borderLeft:"1px dotted var(--pivot-border)",borderBottom:"1px dotted var(--pivot-border)"}),Ce.appendChild(oe);}if(Z.text!==null&&Z.text!==void 0){if(_){let ke=X("kanuni-pivot-expand-icon","span");ke.textContent=re?"\u2212":"+",ke.setAttribute("aria-hidden","true"),J(ke,{flexShrink:0,position:"relative",zIndex:2}),Ce.appendChild(ke);}else {let ke=X("","span");J(ke,{width:14,flexShrink:0}),Ce.appendChild(ke);}let oe=X("truncate","span");He(oe,Z.text),Ce.appendChild(oe);}ee.appendChild(Ce),ee.appendChild(We(`row-${V}`,r.rowHeader,1,n().rtl?"left":"right")),L.appendChild(ee);}function O(L,P,D,V,Y){let{dataFields:ae,leafColHashes:ve,dfsPerLeaf:U,dataColOffset:de,showDataInRows:T,totalDataCols:d}=f,I=d>Ct,B=e.registry?e.registry.getPluginsByType("cellRender"):null;ve.forEach((Q,z)=>{let j=z*U,W=T?[ae[D]]:ae,G=I&&(j+U<=w.start||j>=w.end),_=G?null:_e(f,P,Q.hash,V,Q.isGrandTotal);W.forEach((re,ge)=>{let me=j+ge,ce=de+me,Z=X("kanuni-pivot-cell","td");if(Z.id=a(Y,ce),Z.setAttribute("role","gridcell"),Z.setAttribute("data-r",String(Y)),Z.setAttribute("data-c",String(ce)),G||I&&(me<w.start||me>=w.end)){L.appendChild(Z);return}let ee=_?.values[`${re.id}_display`]??_?.values[re.id],Ee=x(ee,re),Ce=V||Q.isGrandTotal||!!_?.isTotalCell,oe=re.conditionalFormatting?resolveConditionalVisual(_?.values[re.id],re,_??null,f.fieldRanges[re.id]):Tn,ke=oe.style,je=Ee;if(typeof re.cellTemplate=="function")je=re.cellTemplate({value:ee,displayValue:Ee,cell:_,field:re})??null;else if(B){for(let Te of B)if(Te.renderCell){let qe=Te.renderCell(ee,Ee,_,re);if(qe!=null){je=qe;break}}}let Oe={text:je,style:{textAlign:re.dataType==="number"?"right":"left",fontWeight:Ce?600:400,backgroundColor:Ce?"var(--pivot-bg)":"transparent",cursor:e.hasCellClick?.()&&_?"pointer":"default",...ke},className:`kanuni-pivot-cell ${Ce?"kanuni-pivot-cell-total":""}${e.shared?.focused?.r===Y&&e.shared?.focused?.c===ce?" kanuni-pivot-cell-focused":""}${$e(e.shared?.selection??null,Y,ce)?" kanuni-pivot-cell-selected":""}`};if(e.onCellPrepared?.({area:"data",cell:_,rowIndex:Y,columnIndex:ce,cellConfig:Oe}),Z.className=Oe.className,J(Z,Oe.style),Z.setAttribute("data-val",typeof ee=="number"?String(ee):""),He(Z,Oe.text),oe.dataBar){let Te=Math.round(oe.dataBar.ratio*100);Z.style.setProperty("background-image",`linear-gradient(to ${n().rtl?"left":"right"}, ${oe.dataBar.color} ${Te}%, transparent ${Te}%)`),Z.style.setProperty("background-repeat","no-repeat");}if(oe.icon){let Te=q(oe.icon,12);Te.style.setProperty("margin-inline-end","4px"),Te.style.setProperty("vertical-align","middle"),Z.insertBefore(Te,Z.firstChild);}L.appendChild(Z);});});}let $=(L,P)=>e.shared?.focused?.r===L&&e.shared?.focused?.c===P?" kanuni-pivot-cell-focused":"";function K(L){let P=L.flatRow;return L.isGrandTotal||!P?{level:1}:P.isSubtotal||!P.hasChildren?{level:P.depth+1}:{level:P.depth+1,expanded:!!P.isExpanded}}function we(L,P){let{t:D}=n(),{maxRowDepth:V,showDataInRows:Y,dataFields:ae,layout:ve}=f,U=X("kanuni-pivot-row","tr");if(U.setAttribute("role","row"),U.setAttribute("aria-rowindex",String(P+1)),J(U,{height:l()}),ve.rowHeaderLayout==="tree"){let T=K(L);U.setAttribute("aria-level",String(T.level)),T.expanded!==void 0&&U.setAttribute("aria-expanded",String(T.expanded));}if(L.isGrandTotal){U.classList.add("kanuni-pivot-grand-total-row");for(let T=0;T<V;T++){let d=T===0,I=X("kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total"+$(P,T),"td");I.id=a(P,T),I.setAttribute("role",d?"rowheader":"presentation"),J(I,{position:"sticky",zIndex:40,fontWeight:700,backgroundColor:"var(--pivot-surface)",paddingLeft:d?8:0,paddingRight:0,borderRight:T===V-1?"1px solid var(--pivot-border)":"none",whiteSpace:d?"nowrap":"normal",overflow:d?"visible":"hidden"}),I.style.setProperty("inset-inline-start",`var(--row-header-left-${T}, 0px)`),d&&(I.textContent=`${D("grandTotal")}${Y?` \u2014 ${ae[L.dfIndex]?.caption??""}`:""}`),U.appendChild(I);}if(Y){let T=X("kanuni-pivot-cell kanuni-pivot-cell-total"+$(P,V),"td");T.id=a(P,V),T.setAttribute("role","gridcell"),J(T,{position:"sticky",zIndex:40,backgroundColor:"var(--pivot-surface)"}),T.style.setProperty("inset-inline-start",`var(--row-header-left-${V}, 0px)`),T.textContent=String(ae[L.dfIndex]?.caption??""),U.appendChild(T);}return O(U,"",L.dfIndex,true,P),U}let de=L.flatRow;if(de.isSubtotal){U.classList.add("kanuni-pivot-subtotal-row");let T=`${D("subTotal")}: ${de.pathValues[de.depth]}`;if(ve.rowHeaderLayout==="tree"){let d=X("kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total"+$(P,0),"td");d.id=a(P,0),d.setAttribute("role","rowheader"),J(d,{position:"sticky",zIndex:40,fontWeight:600,backgroundColor:"var(--pivot-surface)",paddingLeft:8+de.depth*20}),d.style.setProperty("inset-inline-start","var(--row-header-left-0, 0px)"),d.textContent=T,U.appendChild(d);}else for(let d=0;d<V;d++){if(d<de.depth){N(U,L,P,d);continue}let I=d===de.depth,B=X("kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total"+$(P,d),"td");B.id=a(P,d),B.setAttribute("role",I?"rowheader":"presentation"),J(B,{position:"sticky",zIndex:40,fontWeight:600,backgroundColor:"var(--pivot-surface)",paddingLeft:I?8:0,paddingRight:0,borderRight:d===V-1?"1px solid var(--pivot-border)":"none",whiteSpace:I?"nowrap":"normal",overflow:I?"visible":"hidden"}),B.style.setProperty("inset-inline-start",`var(--row-header-left-${d}, 0px)`),I&&(B.textContent=T),U.appendChild(B);}if(Y){let d=X("kanuni-pivot-cell kanuni-pivot-cell-total"+$(P,V),"td");d.id=a(P,V),d.setAttribute("role","gridcell"),J(d,{position:"sticky",zIndex:40,backgroundColor:"var(--pivot-surface)"}),d.style.setProperty("inset-inline-start",`var(--row-header-left-${V}, 0px)`),d.textContent=String(ae[L.dfIndex]?.caption??""),U.appendChild(d);}return O(U,de.key,L.dfIndex,true,P),U}for(let T=0;T<V;T++)N(U,L,P,T);if(Y){let T=X("kanuni-pivot-cell kanuni-pivot-row-header"+$(P,V),"td");if(T.id=a(P,V),T.setAttribute("role","rowheader"),J(T,{position:"sticky",zIndex:40,backgroundColor:"var(--pivot-surface)"}),T.style.setProperty("inset-inline-start",`var(--row-header-left-${V}, 0px)`),L.isDataRow){let d=X("","span");J(d,{color:"var(--pivot-text-muted)",paddingLeft:8}),d.textContent=String(ae[L.dfIndex]?.caption??""),T.appendChild(d);}T.appendChild(We(`row-${V}`,Ze,1,n().rtl?"left":"right")),U.appendChild(T);}return O(U,de.key,L.dfIndex,false,P),U}function ie(){if(u||!f)return;let L=b();if(E(),h=L,y.textContent="",L.start>0){let P=X("","tr");J(P,{height:L.start*l()});let D=X("","td");D.colSpan=f.dataColOffset+Math.max(f.totalDataCols,1),J(D,{padding:0,border:"none"}),P.appendChild(D),y.appendChild(P);}for(let P=L.start;P<L.end;P++)y.appendChild(we(f.virtualRows[P],P));J(C,{height:v()+f.virtualRows.length*l()});}function le(L){if(u)return;let P=n();P.locale!==g&&(g=P.locale,x=ze(P.locale)),i=L.columnWidths??{},f=dt(L,{grandTotal:P.t("grandTotal"),subTotal:P.t("subTotal")}),s.setAttribute("role",f.layout.rowHeaderLayout==="tree"?"treegrid":"grid"),s.setAttribute("aria-rowcount",String(f.virtualRows.length+f.colHeaders.length+(e.chipDeps?1:0))),s.setAttribute("aria-colcount",String(f.dataColOffset+f.totalDataCols)),s.setAttribute("aria-label",P.t("pivotView"));let D=e.shared?.focused;D?s.setAttribute("aria-activedescendant",a(D.r,D.c)):s.removeAttribute("aria-activedescendant");for(let V of p)s.style.removeProperty(V);p.clear(),F();for(let[V,Y]of Object.entries(i)){if(!V.startsWith("leaf-"))continue;let ae=`--col-width-data-${V.slice(5)}`;s.style.setProperty(ae,`${Y}px`),p.add(ae);}A(),H(),h={start:-1,end:-1},ie();}let fe=()=>{if(u||!f)return;let L=b(),P=w.start;E(),(L.start!==h.start||L.end!==h.end||w.start!==P)&&ie();};s.addEventListener("scroll",fe,{passive:true});let ye=()=>{if(u||!f)return;F();let L=b(),P=w.start,D=w.end;E(),(L.start!==h.start||L.end!==h.end||w.start!==P||w.end!==D)&&ie();},se=typeof ResizeObserver<"u"?new ResizeObserver(()=>ye()):null;return se?.observe(s),{getVM:()=>f,getTheadHeight:v,paintStructural:le,paintWindow:ie,refreshWindow:ye,rowHeaderLayout(){let L=[];if(f){for(let P=0;P<f.maxRowDepth;P++)L.push(c(P));f.showDataInRows&&L.push(o());}return {configured:L,viewport:s.clientWidth}},scroller:s,destroy(){u=true,se?.disconnect(),s.removeEventListener("scroll",fe),s.remove();}}}var Pn=0;function kt(){let e=`kp${++Pn}-`;return {lastResizeTime:0,isResizing:false,focused:null,selection:null,cellId:(t,n)=>`${e}pivot-cell-${t}-${n}`}}function Tt(e){let{scroller:t,controller:n,getVM:r,shared:l}=e,a=p=>p?.closest?.("td[data-r][data-c]")??null;function s(p,u){let v=l.focused;l.focused={r:p,c:u},v&&t.querySelector(`td[id="${l.cellId(v.r,v.c)}"]`)?.classList.remove("kanuni-pivot-cell-focused"),t.querySelector(`td[id="${l.cellId(p,u)}"]`)?.classList.add("kanuni-pivot-cell-focused"),t.setAttribute("aria-activedescendant",l.cellId(p,u));}function C(p,u,v){if(!e.onCellClick)return;let c=r();if(!c)return;let o=pt(c,u,v);if(!o)return;let m={event:p,cellType:o.isTotal?"grandTotal":"data",value:o.val,rowPath:o.cell.rowPath,colPath:o.cell.colPath};e.onCellClick(e.resolveCellClick?e.resolveCellClick(m):m);}let k=p=>{let u=p.target,v=u.closest("[data-col-expand]");if(v){n.toggleColExpanded(v.getAttribute("data-col-expand")??"");return}if(u.closest(".kanuni-pivot-resize-handle"))return;let c=u.closest("[data-filter-field]");if(c){e.onFilterClick?.(p.clientX,p.clientY,c.getAttribute("data-filter-field")??"");return}let o=u.closest("th[data-header-field]");if(o){if(Date.now()-l.lastResizeTime<100)return;let F=r();if(!F)return;let A=o.getAttribute("data-header-field")??"",H=o.getAttribute("data-header-col-path")??"",N=F.rowFields.find(O=>O.sortBySummaryField===A&&(O.sortBySummaryPath||"")===H);N&&n.sortField(N.id,N.sortOrder==="asc"?"desc":"asc");return}let m=a(u);if(!m)return;let E=Number(m.getAttribute("data-r")),b=Number(m.getAttribute("data-c")),S=r();if(S){if(t.focus({preventScroll:true}),s(E,b),b<S.dataColOffset){if(Date.now()-l.lastResizeTime<100)return;let F=Xe(S,E,b);F?.hasChildren&&n.toggleExpanded(F.cellHashStr);return}C(p,E,b);}},M=p=>{let u=a(p.target);if(!u)return;let v=Number(u.getAttribute("data-r")),c=Number(u.getAttribute("data-c")),o=r();!o||c<o.dataColOffset||C(p,v,c);},R=p=>{let u=p.target.closest?.("th[data-header-field]");if(u){p.preventDefault(),u.hasAttribute("aria-expanded")?e.onNodeContextMenu?.({x:p.clientX,y:p.clientY,path:u.getAttribute("data-header-col-path")??"",isExpanded:u.getAttribute("aria-expanded")==="true",depth:Number(u.getAttribute("data-header-depth")??0),type:"col"}):e.onHeaderContextMenu&&e.onHeaderContextMenu(p.clientX,p.clientY,u.getAttribute("data-header-field")??"",u.getAttribute("data-header-col-path")??void 0);return}let v=a(p.target);if(!v)return;let c=Number(v.getAttribute("data-r")),o=Number(v.getAttribute("data-c")),m=r();if(m){if(o<m.dataColOffset){let E=Xe(m,c,o);if(E){let{flatRow:b,hasChildren:S,cellHashStr:F,isExpanded:A,depth:H,dIdx:N}=E,O=m.layout.rowHeaderLayout==="tree",$=N>b.depth,K=$?b.hasChildren:S;if(K&&e.onNodeContextMenu){p.preventDefault(),e.onNodeContextMenu({x:p.clientX,y:p.clientY,path:$?O?b.key:pathKey(b.pathValues.slice(0,b.depth+1)):F,isExpanded:$?b.isExpanded:A,depth:$?b.depth:H,type:"row"});return}if(K)return}}e.onGlobalContextMenu&&(p.preventDefault(),e.onGlobalContextMenu(p.clientX,p.clientY));}},y=e.keyboardEnabled!==false;function f(){let p=l.focused;l.focused=null,p&&t.querySelector(`td[id="${l.cellId(p.r,p.c)}"]`)?.classList.remove("kanuni-pivot-cell-focused"),t.removeAttribute("aria-activedescendant");}let x=p=>{if(p.target!==t||!l.focused)return;let u=r();if(!u)return;let{r:v,c}=l.focused,o={r:v,c},m=p.ctrlKey||p.metaKey,E=u.dataColOffset+u.totalDataCols,b=e.rowHeight?.()??28,S=e.getTheadHeight?.()??u.colHeaders.length*b,F=Math.max(1,Math.ceil(((t.clientHeight||600)-S)/b));switch(p.key){case "ArrowDown":p.preventDefault(),v=Math.min(u.virtualRows.length-1,v+1);break;case "ArrowUp":p.preventDefault(),v=Math.max(0,v-1);break;case "ArrowRight":p.preventDefault(),c=Math.min(E-1,c+1);break;case "ArrowLeft":p.preventDefault(),c=Math.max(0,c-1);break;case "Home":p.preventDefault(),(p.ctrlKey||p.metaKey)&&(v=0),c=0;break;case "End":p.preventDefault(),(p.ctrlKey||p.metaKey)&&(v=u.virtualRows.length-1),c=E-1;break;case "PageDown":p.preventDefault(),v=Math.min(u.virtualRows.length-1,v+F-1);break;case "PageUp":p.preventDefault(),v=Math.max(0,v-F+1);break;case "Escape":p.preventDefault(),f();return;case " ":case "Enter":{p.preventDefault(),p.key===" "&&l.selectByKey?.(v,c,p.shiftKey,o);let N=t.querySelector(`td[id="${l.cellId(v,c)}"]`);N&&(p.key===" "?N.click():N.dispatchEvent(new MouseEvent("dblclick",{bubbles:true})));return}default:return}let A=S+v*b,H=t.clientHeight||600;A<t.scrollTop+S?(t.scrollTop=A-S,t.dispatchEvent(new Event("scroll"))):A+b>t.scrollTop+H&&(t.scrollTop=A+b-H,t.dispatchEvent(new Event("scroll"))),s(v,c),(p.shiftKey||!m)&&l.selectByKey?.(v,c,p.shiftKey,o),c>=u.dataColOffset&&g(v,c,u.dataColOffset);};function g(p,u,v){let c=t.querySelector(`td[id="${l.cellId(p,u)}"]`)??t.querySelector(`td[data-c="${u}"]`);if(!c)return;let o=t.getBoundingClientRect(),m=getComputedStyle(t).direction==="rtl",E=t.querySelector(`td[data-c="${v-1}"]`)?.getBoundingClientRect(),b=c.getBoundingClientRect(),S=m?o.right-t.clientWidth:o.left,F=m?S:E?E.right:S,A=m&&E?E.left:S+t.clientWidth,H=0;b.left<F?H=b.left-F:b.right>A&&(H=Math.min(b.right-A,b.left-F)),H!==0&&(t.scrollLeft+=H,t.dispatchEvent(new Event("scroll")));}let h=p=>{if(p.button!==0)return;let u=a(p.target);if(!u)return;let v=Number(u.getAttribute("data-r")),c=Number(u.getAttribute("data-c"));l.focused?.r===v&&l.focused.c===c||s(v,c);},w=p=>{let u=r();u&&!l.focused&&p.target===t&&u.virtualRows.length>0&&s(0,0);},i=p=>{p.relatedTarget&&t.contains(p.relatedTarget)||f();};return t.addEventListener("click",k),y&&t.addEventListener("mouseup",h),t.addEventListener("dblclick",M),t.addEventListener("contextmenu",R),y?(t.addEventListener("keydown",x),t.addEventListener("focus",w),t.addEventListener("blur",i)):t.removeAttribute("tabindex"),{destroy(){t.removeEventListener("click",k),t.removeEventListener("mouseup",h),t.removeEventListener("dblclick",M),t.removeEventListener("contextmenu",R),y&&(t.removeEventListener("keydown",x),t.removeEventListener("focus",w),t.removeEventListener("blur",i));}}}function Mt(e){let{host:t,scroller:n,shared:r}=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 a=null,s=1,C=0,k=0,M=[],R={},y=null,f=-1,x=i=>{let p=t.getBoundingClientRect();l.style.display="block",l.style.transform=`translateX(${i-p.left}px)`;},g=i=>{r.isResizing&&x(i.clientX);},h=i=>{if(!r.isResizing||!a)return;l.style.display="none";let p=i.clientX-C,u=e.isRtl()?-p:p;if(a.startsWith("row-")){let v=Math.max(20,k+u);R[a]=y?invertRowHeaderWidth(y.configured,f,v,y.viewport):v;}else if(a.startsWith("leaf-")){let v=a.split("-"),c=parseInt(v[1],10),m=Math.max(s*20,k+u)/k;for(let E=0;E<s;E++)R[`leaf-${c+E}`]=Math.max(20,M[E]*m);}r.isResizing=false,r.lastResizeTime=Date.now(),a=null,document.body.style.cursor="",document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",h),e.commit({...R});},w=i=>{let p=i.target.closest?.(".kanuni-pivot-resize-handle");if(!p||(i.preventDefault(),i.stopPropagation(),a=p.getAttribute("data-resize-id"),!a))return;let u=Number(p.getAttribute("data-resize-default")||150);if(s=Number(p.getAttribute("data-resize-span")||1),C=i.clientX,R={...e.getWidths()},a.startsWith("row-"))f=parseInt(a.slice(4),10),y=e.rowHeaderLayout(),k=computeRowHeaderWidths(y.configured,y.viewport).widths[f]??R[a]??u;else if(a.startsWith("leaf-")){let v=parseInt(a.split("-")[1],10);M=[],k=0;for(let c=0;c<s;c++){let o=R[`leaf-${v+c}`]||u;M.push(o),k+=o;}}r.isResizing=true,x(i.clientX),document.body.style.cursor="col-resize",document.addEventListener("mousemove",g),document.addEventListener("mouseup",h);};return n.addEventListener("mousedown",w),{destroy(){n.removeEventListener("mousedown",w),r.isResizing&&(r.isResizing=false,document.body.style.cursor=""),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",h),l.remove();}}}function Lt(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Ae(e){let t=Lt("kanuni-pivot-root kanuni-pivot-portal-container");e.classList.contains("kanuni-pivot-striped")&&t.classList.add("kanuni-pivot-striped"),t.setAttribute("style",e.getAttribute("style")??"");for(let r of ["position","inset","z-index","width","height"])t.style.removeProperty(r);let n=e.getAttribute("data-theme");return n&&t.setAttribute("data-theme",n),t.setAttribute("dir",e.getAttribute("dir")??"ltr"),t}function Ie(){let e=document,t=e.fullscreenElement??e.webkitFullscreenElement??null;return t||(document.querySelector(".pivot-is-fullscreen")??document.body)}function Je(e){let t=null,n=null;function r(){n?.(),n=null,t?.remove(),t=null;}function l(a){r(),t=Ae(e);let s=Lt("kanuni-pivot-portal-root");t.appendChild(s),Ie().appendChild(t);let C=a(s),k=t,M=y=>{k.contains(y.target)||r();},R=y=>{y.key==="Escape"&&r();};return document.addEventListener("pointerdown",M,true),document.addEventListener("keydown",R,true),n=()=>{document.removeEventListener("pointerdown",M,true),document.removeEventListener("keydown",R,true),C?.();},s}return {openPopup:l,closePopup:r,isOpen:()=>t!==null,destroy:r}}var St=new Map,Pt=new Map;function Rt(e,t,n,r="(Blanks)"){if(e==null)return r;if(t.format&&typeof e=="number")try{let l=t.format,a=JSON.stringify(l)+"_"+n,s=Pt.get(a);s||(s=new Intl.NumberFormat(n,l),Pt.set(a,s));let C=s.format(e);return l.isCustom&&(l.prefix||l.suffix)?`${l.prefix||""}${C}${l.suffix||""}`:C}catch{return String(e)}return String(e)}var Me=28;function he(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}var $n="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 Bn(){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",$n),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.5"),t.setAttribute("stroke-linecap","round"),e.appendChild(t),e}function At(e){let{portal:t}=e;function n(r,l,a){let s=e.getField(a);if(!s)return;let{t:C,rtl:k,locale:M}=e.getI18n(),R=true,y=[],f="",x=new Set,g=0,h=220,w=false,i=[];t.openPopup(p=>{let u=he("kanuni-pivot-popup pivot-animate-zoom-in"),v=popupViewport(),c=placePopup({x:r,y:l},{width:250,height:350},{margin:10,viewport:v});u.setAttribute("role","dialog"),u.setAttribute("aria-label",C("columnFilter")),u.setAttribute("data-datagrid-keyboard-scope","modal"),u.tabIndex=-1,Object.assign(u.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,v.width-20)}px`,maxHeight:`${Math.min(350,c.maxHeight)}px`,resize:"both",direction:k?"rtl":"ltr"});let o=he("kanuni-pivot-popup-header"),m=he("kanuni-pivot-popup-search");m.appendChild(Bn());let E=he("kanuni-pivot-popup-search-input","input");E.type="text",E.placeholder=C("search"),E.setAttribute("aria-controls","pivot-filter-options"),m.appendChild(E),o.appendChild(m);let b=he("kanuni-pivot-popup-actions"),S=he("kanuni-pivot-popup-action-btn kanuni-pivot-popup-action-btn--primary","button");S.textContent=C("selectAll");let F=he("kanuni-pivot-popup-action-btn kanuni-pivot-popup-action-btn--danger","button");F.textContent=C("clearAll"),b.append(S,F),o.appendChild(b);let A=he("kanuni-pivot-popup-list pivot-custom-scrollbar");A.id="pivot-filter-options";let H=he("");H.style.position="relative",A.appendChild(H);let N=he("kanuni-pivot-popup-footer"),O=he("kanuni-pivot-btn kanuni-pivot-btn--outline","button");O.textContent=C("cancel");let $=he("kanuni-pivot-btn kanuni-pivot-btn--primary","button");$.textContent=C("ok");for(let T of [O,$])Object.assign(T.style,{height:"28px",padding:"0 12px",fontSize:"12px"});if(N.append(O,$),e.openCondition&&(s.area==="row"||s.area==="column")){let T=he("kanuni-pivot-btn kanuni-pivot-btn--outline","button");T.type="button",T.setAttribute("data-condition-filter",""),T.title=C("conditionFilter")+"\u2026",T.setAttribute("aria-label",T.title),Object.assign(T.style,{height:"28px",padding:"0 7px",marginInlineEnd:"auto"}),(s.valueFilter||s.labelFilter)&&(T.style.color="var(--pivot-danger)"),T.appendChild(q("settings-2",14)),T.addEventListener("click",()=>{t.closePopup(),e.openCondition(s.id);}),N.prepend(T);}u.append(o,A,N),p.appendChild(u);let K=()=>{if(!f)return y;let T=f.toLowerCase(),d=T.replace(/,/g,"."),I=T.replace(/\./g,","),B=T.replace(/[.,\s]/g,"");return y.filter(Q=>{let z=Q.label.toLowerCase(),j=z.replace(/[.,\s]/g,"");return z.includes(T)||z.includes(d)||z.includes(I)||!!B&&j.includes(B)})},we=()=>x.size===y.length,ie=()=>!f,le=()=>K().length+(ie()?1:0),fe=()=>le()===0?-1:Math.min(g,le()-1),ye=T=>{if(ie()&&T===0)return "select-all";let d=ie()?T-1:T;return `value:${K()[d]?.rawStr}`},se=new Map;function L(){if(w)return;let T=document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains("kanuni-pivot-popup-item");if($.disabled=!R&&y.length>0&&x.size===0,H.textContent="",se.clear(),R){H.style.height="";let j=he("pivot-flex pivot-items-center pivot-justify-center pivot-h-full"),W=he("");Object.assign(W.style,{width:"24px",height:"24px",border:"2px solid var(--pivot-border)",borderTopColor:"var(--pivot-primary)",borderRadius:"50%",animation:"spin 1s linear infinite"}),j.appendChild(W),H.appendChild(j);return}let d=K(),I=le();H.style.height=`${I*Me}px`;let B=Math.max(0,Math.floor(A.scrollTop/Me)-2),Q=Math.min(I,B+Math.ceil(h/Me)+4),z=fe();for(let j=B;j<Q;j++){let W,G,_,re,ge;if(ie()&&j===0)W="select-all",G=`(${C("selectAll")})`,_=we(),re=true,ge=D;else {let ee=d[ie()?j-1:j];if(!ee)continue;W=`value:${ee.rawStr}`,G=ee.label,_=x.has(ee.rawStr),re=false,ge=()=>V(ee.rawStr);}let me=he(`kanuni-pivot-popup-item${_?" kanuni-pivot-popup-item--checked":""}${j===z?" kanuni-pivot-popup-item--active":""}`);me.id=W,me.setAttribute("role","checkbox"),me.setAttribute("aria-checked",String(_)),me.tabIndex=0,Object.assign(me.style,{position:"absolute",top:`${j*Me}px`,insetInlineStart:"0",insetInlineEnd:"0",height:`${Me}px`,fontWeight:re?"600":"400"});let ce=he("kanuni-pivot-checkbox","input");ce.type="checkbox",ce.checked=_,ce.readOnly=true,ce.tabIndex=-1;let Z=he("pivot-truncate","span");Z.textContent=G,me.append(ce,Z),me.addEventListener("click",ge),me.addEventListener("focus",()=>{g=j;}),H.appendChild(me),se.set(j,me);}if(d.length===0){let j=he("");Object.assign(j.style,{padding:"12px",textAlign:"center",fontSize:"12px",color:"var(--pivot-text-muted)"}),j.textContent=C("noItems"),H.appendChild(j);}E.setAttribute("aria-activedescendant",z>=0?ye(z):""),T&&se.get(z)?.focus();}function P(T){x=new Set(x);for(let d of K())T?x.add(d.rawStr):x.delete(d.rawStr);L();}function D(){P(!K().every(T=>x.has(T.rawStr)));}function V(T){x.has(T)?x.delete(T):x.add(T),L();}function Y(){if($.disabled)return;let T=headerFilterWrite(y,x,s);T.kind==="clear"?e.clear(s.id):T.kind==="apply"&&e.apply(s.id,T.values,T.filterType),t.closePopup();}function ae(T){g=Math.max(0,Math.min(le()-1,T));let d=g*Me;d<A.scrollTop?A.scrollTop=d:d+Me>A.scrollTop+h&&(A.scrollTop=d+Me-h),L(),se.get(g)?.focus();}let ve=T=>{if(T.key==="ArrowDown"||T.key==="ArrowUp"){if(T.preventDefault(),le()===0)return;ae(fe()+(T.key==="ArrowDown"?1:-1));return}if(T.key==="Home"&&le()>0){T.preventDefault(),ae(0);return}if(T.key==="End"&&le()>0){T.preventDefault(),ae(le()-1);return}if(T.key==="Backspace"&&T.target!==E){T.preventDefault(),E.focus(),f=f.slice(0,-1),E.value=f,g=0,L();return}if(T.key===" "||T.code==="Space"){if(T.target===E)return;T.preventDefault();let d=fe();if(le()>0&&d>=0)if(ie()&&d===0)D();else {let I=K()[ie()?d-1:d];I&&V(I.rawStr);}return}if(T.key==="Enter"){T.preventDefault(),Y();return}if(T.key==="Escape"){T.stopPropagation(),t.closePopup();return}T.key.length===1&&!T.ctrlKey&&!T.metaKey&&!T.altKey&&T.target!==E&&(T.preventDefault(),E.focus(),f+=T.key,E.value=f,g=0,L());},U=T=>{ve(T),T.defaultPrevented&&T.stopPropagation();};document.addEventListener("keydown",U,true),u.addEventListener("click",T=>T.stopPropagation()),E.addEventListener("input",()=>{f=E.value,g=0,L();}),S.addEventListener("click",D),F.addEventListener("click",()=>P(false)),O.addEventListener("click",()=>t.closePopup()),$.addEventListener("click",Y),A.addEventListener("scroll",()=>{St.set(s.id,A.scrollTop),L();});let de=typeof ResizeObserver<"u"?new ResizeObserver(T=>{for(let d of T)h=d.contentRect.height;}):null;return de?.observe(A),L(),E.focus(),i.push(setTimeout(()=>{if(w)return;if(!s.dataField&&!s.isCalculated){y=[],R=false,L();return}let T=getFieldDistinctValues(s.id,e.gridId);if(T)y=T.map(I=>({rawStr:I.rawStr==="null"||I.rawStr==="undefined"?C("blanks"):I.rawStr,rawVal:I.rawVal,label:Rt(I.rawVal,s,M,C("blanks"))}));else {let I=new Map,B=e.getData();for(let z=0;z<B.length;z++){let j=extractGroupValue(B[z],s);if(j==="(Blank)"&&s.calculateSummaryExpression)continue;let W=j==null?C("blanks"):String(j);I.has(W)||I.set(W,j);}let Q=Array.from(I.values());if(s.dataType==="number")Q.sort((z,j)=>Number(z)-Number(j));else {let z=collatorFor().compare;Q.sort((j,W)=>z(String(j),String(W)));}y=Q.map(z=>({rawStr:z==null?C("blanks"):String(z),rawVal:z,label:Rt(z,s,M,C("blanks"))}));}x=headerFilterShown(y,s),R=false,L();let d=St.get(s.id)||0;d>0&&i.push(setTimeout(()=>{w||(A.scrollTop=d,L());},50)),i.push(setTimeout(()=>{w||E.focus();},50));},10)),()=>{w=true,document.removeEventListener("keydown",U,true);for(let T of i)clearTimeout(T);de?.disconnect();}});}return {open:n,close:()=>t.closePopup()}}function be(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Ft(e){let t=be("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,r=null,l=null,a=null;function s(){n=null,r?.remove(),r=null,l?.classList.remove("kanuni-pivot-footer-btn--active"),l=null;}let C=u=>{e.onGlobalContextMenu&&(u.preventDefault(),e.onGlobalContextMenu(u.clientX,u.clientY));};t.addEventListener("contextmenu",C);let k=u=>{!n||u.target?.closest?.("[data-footer-menu]")?.getAttribute("data-footer-menu")===n||s();};document.addEventListener("mousedown",k);let M=be("kanuni-pivot-search","input");M.type="search";let R,y=()=>{clearTimeout(R),e.onSearch?.(M.value);};M.addEventListener("input",()=>{clearTimeout(R),R=setTimeout(y,250);}),M.addEventListener("keydown",u=>{u.stopPropagation(),u.key==="Enter"?y():u.key==="Escape"&&(M.value="",y());});function f(u,v,c=false){let o=be(`kanuni-pivot-footer-btn${c?" kanuni-pivot-footer-btn--active":""}`,"button");return o.title=v,o.setAttribute("aria-label",v),o.type="button",o.appendChild(q(u,15)),o}let x=()=>be("kanuni-pivot-footer-divider");function g(u,v,c,o,m,E={}){let b=be("kanuni-pivot-dropdown-item pivot-flex","button");b.type="button",b.style.gap="12px",E.locked&&(b.style.opacity="0.6",b.style.cursor=E.canUpgrade?"pointer":"not-allowed",E.canUpgrade||(b.disabled=true),E.hint&&(b.title=E.hint)),b.appendChild(q(u,16,v));let S=be(""),F=be("pivot-font-medium pivot-flex pivot-items-center");if(F.style.gap="6px",F.appendChild(document.createTextNode(c)),E.locked&&E.badge){let A=be("","span");Object.assign(A.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)"}),A.textContent=E.badge,F.appendChild(A);}if(S.appendChild(F),o!==null){let A=be("pivot-text-xs pivot-text-muted");A.textContent=o,S.appendChild(A);}return b.appendChild(S),m&&b.addEventListener("click",m),b}function h(u,v=false){let c=be("kanuni-pivot-report-section-title");return v&&(c.style.marginTop="4px",c.style.borderTop="1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"),c.textContent=u,c}function w(){let u=be("kanuni-pivot-dropdown-menu pivot-animate-slide-up pivot-custom-scrollbar");return Object.assign(u.style,{bottom:"100%",left:"0",marginBottom:"4px",width:"256px",maxHeight:"384px",overflowY:"auto"}),u}function i(u){n=null,a&&p(a),e.onExport(u);}function p(u){a=u;let{t:v,locale:c}=e.getI18n(),o=e.toolbar??{},m=document.activeElement===M;if(t.textContent="",r=null,l=null,o.showSaveReport!==false&&e.mountReportMenu){let b=be("pivot-relative");e.mountReportMenu(b),b.childNodes.length>0&&(t.appendChild(b),t.appendChild(x()));}if(o.showFieldChooserToggle!==false){let b=f("settings",v("showFieldList"),e.fieldChooserOpen());b.addEventListener("click",e.onToggleFieldChooser),t.appendChild(b);}if(e.onOpenPrefilter){let b=f("filter",v("filterBuilder"));b.addEventListener("click",e.onOpenPrefilter),t.appendChild(b);}if(e.onToggleChart){let b=f("bar-chart",v("chartToggle"));b.addEventListener("click",e.onToggleChart),t.appendChild(b);}if(o.showCalculatedFields!==false&&e.onAddCalculatedField){let b=f("calculator",v("calculatedMeasureDesigner"));b.addEventListener("click",e.onAddCalculatedField),t.appendChild(b);}if(t.appendChild(x()),o.showExpandCollapseAll!==false){let b=f("maximize2",v("expandAll"));b.addEventListener("click",e.onExpandAll);let S=f("minimize2",v("collapseAll"));S.addEventListener("click",e.onCollapseAll),t.append(b,S);}if(o.showRefreshButton!==false&&e.onRefresh){t.appendChild(x());let b=f("refresh-cw",v("refreshData"));b.addEventListener("click",e.onRefresh),t.appendChild(b);}if(o.showFullscreenToggle!==false&&e.onToggleFullscreen){t.appendChild(x());let b=e.isFullscreen(),S=f(b?"shrink":"fullscreen",v(b?"exitFullscreen":"enterFullscreen"),b);b&&Object.assign(S.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)"}),S.addEventListener("click",e.onToggleFullscreen),t.appendChild(S);}if(t.appendChild(x()),o.showExportButton!==false){let b=be("pivot-relative");b.setAttribute("data-footer-menu","export");let S=f("download",v("export"),n==="export");if(S.addEventListener("click",()=>{n=n==="export"?null:"export",p(u);}),b.appendChild(S),n==="export"){let F=w(),A=O=>{let $=!e.advancedExport;return {locked:$,canUpgrade:$&&!!e.upgradeUrl,badge:v("enterpriseBadge"),hint:$&&e.upgradeUrl?v("enterpriseUpgradeHint"):void 0}},H=(O,$)=>{if(!(!e.advancedExport))return ()=>i(O);if(e.upgradeUrl)return ()=>{n=null,p(u),window.open(e.upgradeUrl,"_blank","noopener,noreferrer");}},N=e.registry?.getPluginsByType("exporter")??[];if(N.length>0){F.appendChild(h(v("customExports")));for(let O of N)F.appendChild(g("database","var(--pivot-primary)",`${O.id.replace("exporter-","").toUpperCase()} ${v("export")}`,v("customPlugin"),()=>i(O.id)));F.appendChild(be("kanuni-pivot-dropdown-divider"));}F.appendChild(h(v("excelExport"))),F.appendChild(g("file-spreadsheet","var(--pivot-success)",v("pivotView"),v("preservesGridLayout"),H("excel-pivot"),A())),F.appendChild(g("file-spreadsheet","var(--pivot-success)",v("listView"),v("rawFlatData"),H("excel-list"),A())),F.appendChild(h(v("document"),true)),F.appendChild(g("file-text","var(--pivot-danger)",v("pdfDocument"),v("printReadyLayout"),H("pdf"),A())),F.appendChild(g("printer","var(--pivot-info)",v("print"),v("sendToPrinter"),()=>i("print"))),F.appendChild(g("copy","var(--pivot-primary)",v("copyToClipboard"),v("tabSeparatedValues"),()=>i("clipboard"))),F.appendChild(g("file-json","var(--pivot-success)",v("fullSnapshot"),v("saveSessionState"),()=>i("json-snapshot"))),F.appendChild(h(v("rawDataFormats"),true)),F.appendChild(g("file","var(--pivot-info)","CSV",null,()=>i("csv"))),F.appendChild(g("file-json","var(--pivot-warning)","JSON (Tree)",null,()=>i("json-pivot"))),F.appendChild(g("file-json","var(--pivot-warning)","JSON (List)",null,()=>i("json"))),F.appendChild(g("database","var(--pivot-text-muted)","XML",null,()=>i("xml"))),b.appendChild(F),r=F,l=S;}t.appendChild(b);}if(e.onSearch){let b=v("search").replace(/[.\u2026]+$/,"");M.placeholder=v("search"),M.setAttribute("aria-label",b),t.appendChild(x()),t.appendChild(M),m&&M.focus();}let E=u.selectionStats;if(E){let b=new Intl.NumberFormat(c,{minimumFractionDigits:2,maximumFractionDigits:2}),S=be("kanuni-pivot-selection-stats pivot-text-muted pivot-font-medium pivot-flex pivot-items-center");Object.assign(S.style,{marginLeft:"auto",fontSize:"11px",gap:"8px",paddingRight:"8px",userSelect:"none"});let F=[[v("count"),String(E.count)],[v("sum"),b.format(E.sum)],[v("avg"),b.format(E.avg)],[v("min"),b.format(E.min)],[v("max"),b.format(E.max)]];for(let[A,H]of F){let N=be("","span");N.textContent=`(${A}: ${H})`,S.appendChild(N);}t.appendChild(S);}}return {element:t,paint:p,syncSearch(u){document.activeElement!==M&&(M.value=u);},destroy(){clearTimeout(R),t.removeEventListener("contextmenu",C),document.removeEventListener("mousedown",k),t.remove();}}}var Ht=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];function It(e,t){let n=false,r=()=>{let k=document;return k.fullscreenElement??k.webkitFullscreenElement??k.mozFullScreenElement??k.msFullscreenElement??null},l=()=>n||r()===e;function a(k){if(n=k,e.classList.toggle("pivot-is-fullscreen",k),k)Object.assign(e.style,{position:"fixed",inset:"0",zIndex:"9990",width:"auto",height:"auto"});else for(let M of ["position","inset","z-index","width","height"])e.style.removeProperty(M);}let s=()=>{let k=l();e.classList.toggle("pivot-is-fullscreen",r()===e||n),t(k);};for(let k of Ht)document.addEventListener(k,s);function C(){let k=document;if(l()){if(n){a(false),t(false);return}k.exitFullscreen?k.exitFullscreen():k.webkitExitFullscreen?k.webkitExitFullscreen():k.mozCancelFullScreen?k.mozCancelFullScreen():k.msExitFullscreen?k.msExitFullscreen():t(false);return}let M=e;M.requestFullscreen?M.requestFullscreen().then(()=>{e.classList.add("pivot-is-fullscreen");},()=>{a(true),t(true);}):M.webkitRequestFullscreen?M.webkitRequestFullscreen():M.mozRequestFullScreen?M.mozRequestFullScreen():M.msRequestFullscreen?M.msRequestFullscreen():(a(true),t(true));}return {isFullscreen:l,toggle:C,destroy(){for(let k of Ht)document.removeEventListener(k,s);n&&a(false);}}}var Qe=["row","column","data","filter","chooser"];function Dt(e){let t={activeId:null,targetId:null,targetArea:null,intent:null};function n(o,m,E){t.targetId===o&&t.targetArea===m&&t.intent===E||(t.targetId=o,t.targetArea=m,t.intent=E,e.controller.setDragIntent(o,m,E),e.onIntentChange({...t}));}let r=null,l=null,a=null,s=null;function C(o,m,E){a=Ae(e.gridRoot),a.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:"14px",opacity:"0.9",cursor:"grabbing",transformOrigin:"0 0",pointerEvents:"none",zIndex:"100000"});let b=document.createElement("span");b.className="pivot-truncate",Object.assign(b.style,{maxWidth:"150px",color:"var(--pivot-text)"});let S=e.getFields().find(F=>F.id===o);b.textContent=S?.caption||S?.id||"Field",s.appendChild(b),a.appendChild(s),document.body.appendChild(a),k(m,E);}function k(o,m){s&&(s.style.transform=`translate3d(${o+6}px, ${m+6}px, 0) scale(1.05)`);}function M(){a?.remove(),a=null,s=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 R(o){let m=l;if(M(),l=null,r?.holdTimer&&clearTimeout(r.holdTimer),r=null,document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",w),document.removeEventListener("pointercancel",i),document.removeEventListener("keydown",p,true),!m)return;let E=t.activeId??m.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(E,o);}function y(){if(!r)return;let{el:o,dropId:m,pointerId:E,startX:b,startY:S}=r;l={el:o,dropId:m,pointerId:E,startX:b,startY:S},r=null;let F=m.replace("chooser-","");t.activeId=F,e.controller.setDragActive(F),o.classList.add("is-dragging"),o.style.pointerEvents="none",o.style.cursor="grabbing",C(F,b,S),window.getSelection?.()?.removeAllRanges?.(),document.body.style.userSelect="none",e.onIntentChange({...t});}function f(o,m){let E=null,b=null,S=null,F=typeof document.elementFromPoint=="function"?document.elementFromPoint(o,m):null;for(let A of e.roots())for(let H of A.querySelectorAll("[data-drop-id]")){if(l&&H===l.el||F&&!H.contains(F)||H.classList.contains("kanuni-pivot-field-chip")&&H.closest('[data-drop-id="chooser-chooser"]'))continue;let N=H.getBoundingClientRect();if(N.width===0&&N.height===0||o<N.left||o>N.right||m<N.top||m>N.bottom)continue;let O=H.getAttribute("data-drop-id"),$=O.replace("chooser-","");if($.endsWith("-ghost-end"))b={id:O,el:H};else if(Qe.includes($))S=S??{id:O,el:H};else {let K=N.width*N.height;(!E||K<E.size)&&(E={id:O,el:H,size:K});}}return E??b??S}function x(o,m){let E=f(o,m);if(!E)return n(null,null,null),{overId:null};let b=E.id.replace("chooser-",""),S=e.getFields().find(H=>H.id===b),F=Qe.includes(b)||b.endsWith("-ghost-end")?b.replace("-ghost-end",""):S?.area,A=!!(t.activeId&&F&&e.controller.canMoveFieldTo&&!e.controller.canMoveFieldTo(t.activeId,F));if(s?.classList.toggle("is-drop-denied",A),s&&(s.style.borderColor=A?"var(--pivot-danger)":"var(--pivot-primary)"),A)return n(null,null,null),{overId:null};if(Qe.includes(b)||b.endsWith("-ghost-end"))return n(null,F,"append"),{overId:E.id};if(S){let H=S.area==="chooser"?"vertical":"horizontal",N=E.el.getBoundingClientRect(),O=e.controller.calculateDropIntent(o,m,{top:N.top,left:N.left,width:N.width,height:N.height},t.intent,false,H);return n(b,S.area??null,O),{overId:E.id}}return {overId:E.id}}let g=null,h=o=>{if(!(r&&o.pointerId!==r.pointerId)&&!(l&&o.pointerId!==l.pointerId)){if(r){let m=o.clientX-r.startX,E=o.clientY-r.startY,b=Math.hypot(m,E);if(r.isTouch){if(!r.held&&b>8){r.holdTimer&&clearTimeout(r.holdTimer),r=null;return}if(!r.held)return}else if(b<8)return;y();}l&&(o.preventDefault(),k(o.clientX,o.clientY),g=x(o.clientX,o.clientY).overId);}},w=o=>{if(!(r&&o.pointerId!==r.pointerId)&&!(l&&o.pointerId!==l.pointerId)){if(r){r.holdTimer&&clearTimeout(r.holdTimer),r=null,document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",w),document.removeEventListener("pointercancel",i),document.removeEventListener("keydown",p,true);return}l&&R(x(o.clientX,o.clientY).overId??g);}},i=()=>R(null),p=o=>{o.key==="Escape"&&l&&(o.stopPropagation(),R(null));},u=o=>{if(e.disabled?.()||r||l||o.button!==0&&o.pointerType==="mouse")return;let m=o.target;if(m.closest("button, input, .kanuni-pivot-chip-btn"))return;let E=m.closest(".kanuni-pivot-field-chip[data-drop-id]");if(!E||E.getAttribute("data-drag-scope")==="grip"&&!m.closest("[data-drag-grip]"))return;let b=E.getAttribute("data-drop-id"),S=o.pointerType==="touch";r={el:E,dropId:b,pointerId:o.pointerId,startX:o.clientX,startY:o.clientY,isTouch:S,held:false,holdTimer:S?setTimeout(()=>{r&&(r.held=true,y());},Math.max(0,e.touchDragDelay?.()??200)):null},document.addEventListener("pointermove",h),document.addEventListener("pointerup",w),document.addEventListener("pointercancel",i),document.addEventListener("keydown",p,true);},v=new Set;function c(){for(let o of v)o.isConnected||(o.removeEventListener("pointerdown",u),v.delete(o));for(let o of e.roots())v.has(o)||(v.add(o),o.addEventListener("pointerdown",u));}return c(),{getState:()=>({...t}),refreshRoots:c,rootCount:()=>v.size,destroy(){l&&R(null),r?.holdTimer&&clearTimeout(r.holdTimer),r=null;for(let o of v)o.removeEventListener("pointerdown",u);v.clear(),document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",w),document.removeEventListener("pointercancel",i),document.removeEventListener("keydown",p,true);}}}function ue(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Ot(e){let{portal:t}=e;function n(y,f,x,g=false){let h=ue(`${g?"kanuni-pivot-dropdown-item-danger":"kanuni-pivot-dropdown-item"} pivot-flex pivot-items-center`,"button");return h.type="button",y&&h.appendChild(q(y,16)),h.appendChild(document.createTextNode(" "+f)),h.addEventListener("click",()=>{t.closePopup(),x();}),h}function r(y,f,x){let g=()=>window.visualViewport?.removeEventListener("resize",h),h=()=>{if(!y.isConnected){g();return}let w=y.offsetWidth,i=y.scrollHeight||y.offsetHeight;if(w===0&&i===0)return;let p=placePopup({x:f,y:x},{width:w,height:i});y.style.top=`${p.top}px`,y.style.left=`${p.left}px`,y.style.maxHeight=`${p.maxHeight}px`;};return h(),window.visualViewport?.addEventListener("resize",h),g}let l=null;function a(y,f,x){let g=null,h=null,w=()=>{g?.remove(),g=null,l===w&&(l=null);},i=()=>{if(g)return;l&&l(),l=w,g=ue("kanuni-pivot-dropdown-menu pivot-animate-zoom-in");let c=y.getBoundingClientRect(),o=placePopup({x:c.right+4,y:c.top},{width:160,height:0},{altX:c.left-4});if(Object.assign(g.style,{position:"fixed",top:`${o.top}px`,left:`${o.left}px`,minWidth:"160px",zIndex:"10000"}),g.addEventListener("contextmenu",m=>m.preventDefault()),g.addEventListener("mouseenter",()=>{h&&clearTimeout(h);}),g.addEventListener("mouseleave",()=>{h=setTimeout(w,200);}),x(g),f.appendChild(g),g.offsetHeight){let m=placePopup({x:c.right+4,y:c.top},{width:g.offsetWidth,height:g.scrollHeight},{altX:c.left-4});Object.assign(g.style,{top:`${m.top}px`,left:`${m.left}px`,maxHeight:`${m.maxHeight}px`,overflowY:"auto"});}},p=0,u=false,v=()=>Date.now()-p<1e3;y.addEventListener("pointerdown",c=>{c.pointerType!=="mouse"&&(p=Date.now());}),y.addEventListener("mouseenter",()=>{h&&clearTimeout(h),!v()&&(g||(u=true),i());}),y.addEventListener("mouseleave",()=>{v()||(h=setTimeout(w,200));}),y.addEventListener("click",c=>{if(c.detail>0&&u&&g){u=false;return}u=false,g?w():i();});}function s(y,f,x){let g=ue("kanuni-pivot-dropdown-item pivot-flex pivot-items-center pivot-justify-between","button");g.type="button";let h=ue("pivot-flex pivot-items-center pivot-gap-2","span");return h.appendChild(q(y,16)),h.appendChild(document.createTextNode(" "+f)),g.appendChild(h),g.appendChild(q(x?"chevron-left":"chevron-right",14)),g}function C(y){y.addEventListener("keydown",f=>{let x=[...y.querySelectorAll("button:not([disabled])")];if(x.length===0)return;let g=x.indexOf(document.activeElement),h=-1;f.key==="ArrowDown"?h=g<0?0:(g+1)%x.length:f.key==="ArrowUp"?h=g<0?x.length-1:(g-1+x.length)%x.length:f.key==="Home"?h=0:f.key==="End"&&(h=x.length-1),!(h<0)&&(f.preventDefault(),x[h].focus());});}function k(y,f,x,g,h){let w=e.getFields().find(c=>c.id===x);if(!w)return;let{t:i,rtl:p}=e.getI18n(),u=e.getFields().filter(c=>c.area==="row").sort((c,o)=>(c.areaIndex||0)-(o.areaIndex||0)),v=g!==void 0&&u.length>0&&w.area==="data";t.openPopup(c=>{let o=ue("kanuni-pivot-dropdown-menu pivot-animate-zoom-in pivot-flex-col");Object.assign(o.style,{position:"fixed",top:`${f}px`,left:`${y}px`,maxHeight:`${Math.max(0,popupViewport().height-16)}px`,overflowY:"auto",overflowX:"hidden",width:"220px",zIndex:"9999"}),o.addEventListener("contextmenu",b=>b.preventDefault());let m=ue("kanuni-pivot-report-section-title");if(Object.assign(m.style,{position:"sticky",top:"0",zIndex:"10"}),m.textContent=w.caption??w.id,o.appendChild(m),v){let b=ue("kanuni-pivot-report-section-title");b.style.marginTop="4px",b.textContent=i("sortByThisColumn"),o.appendChild(b);for(let S of u)o.appendChild(n("arrow-down-a-z",i("sortFieldByThisColumn").replace("{0}",S.caption||S.id),()=>e.controller.sortFieldBySummary(S.id,w.id,g)));o.appendChild(ue("kanuni-pivot-divider")),o.appendChild(n("x",i("removeAllSorting"),()=>e.controller.clearAllSorting(),true));}else {o.appendChild(n("arrow-down-a-z",i("sortAsc"),()=>e.controller.sortField(w.id,"asc"))),o.appendChild(n("arrow-up-z-a",i("sortDesc"),()=>e.controller.sortField(w.id,"desc"))),w.sortOrder&&o.appendChild(n("x",i("clearSort"),()=>e.controller.sortField(w.id,void 0),true)),e.openFilter&&w.area!=="data"&&o.appendChild(n("filter",i("filterField"),()=>e.openFilter(w.id,y,f))),e.openCondition&&(w.area==="row"||w.area==="column")&&o.appendChild(n("filter",i("conditionFilter")+"\u2026",()=>e.openCondition(w.id))),o.appendChild(ue("kanuni-pivot-divider"));let b=s("list",i("order"),p);o.appendChild(b),a(b,c,A=>{let H=[["start",i("moveToStart"),"chevrons-left"],["left",i("moveToLeft"),"chevron-left"],["right",i("moveToRight"),"chevron-right"],["end",i("moveToEnd"),"chevrons-right"]];for(let[N,O,$]of H)A.appendChild(n($,O,()=>e.controller.moveField(w.id,N)));});let S=[["row",i("rowArea"),"rows-3"],["column",i("columnArea"),"columns-3"],["data",i("dataArea"),"bar-chart-3"],["filter",i("filterArea"),"filter"]].filter(([A])=>A!==w.area);if(S.length>0){let A=s("move",i("moveToArea"),p);o.appendChild(A),a(A,c,H=>{for(let[N,O,$]of S){let K=n($,O,()=>e.controller.changeFieldArea(w.id,N));e.controller.canMoveFieldTo(w.id,N)||(K.disabled=true),H.appendChild(K);}});}e.openFieldChooser&&o.appendChild(n("list",i("showFieldList"),e.openFieldChooser)),o.appendChild(n("eye-off",i("hide"),()=>e.controller.removeField(w.id)));let F=e.customContextMenuItems?.(w);if(F&&F.length>0){o.appendChild(ue("kanuni-pivot-divider"));for(let A of F){let H=n(null,A.label,A.action);A.icon&&H.insertBefore(A.icon(),H.firstChild),o.appendChild(H);}}o.appendChild(ue("kanuni-pivot-divider")),w.isCalculated&&e.onEditCalculatedField&&o.appendChild(n("calculator",i("editCalculation"),()=>e.onEditCalculatedField(w))),o.appendChild(n("settings",i("fieldSettings"),()=>e.openSettings(w.id)));}c.appendChild(o);let E=r(o,y,f);return h?(C(c),o.querySelector("button")?.focus(),()=>{E(),e.gridRoot?.querySelector(`.kanuni-pivot-field-chip[data-drop-id="${x}"]`)?.focus({preventScroll:true});}):E});}function M(y,f){let{t:x}=e.getI18n();t.openPopup(g=>{let h=ue("kanuni-pivot-dropdown-menu pivot-animate-zoom-in");Object.assign(h.style,{position:"fixed",zIndex:"301",width:"224px",fontSize:"14px",left:`${placePopup({x:y,y:f},{width:224,height:120}).left}px`,top:`${placePopup({x:y,y:f},{width:224,height:120}).top}px`}),h.addEventListener("contextmenu",u=>u.preventDefault());let w=ue("kanuni-pivot-report-section-title");w.textContent=x("viewOptions"),h.appendChild(w);let i=e.getLayout(),p=(u,v,c)=>{let o=ue("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 m=ue("","span");m.textContent=u;let E=ue("pivot-text-xs pivot-text-muted pivot-font-medium","span");return E.textContent=x(v?"show":"hide"),o.append(m,E),o.addEventListener("click",()=>{c(),t.closePopup();}),o};h.appendChild(p(x("filterArea"),i.showFilterArea===false,()=>e.controller.setLayout({showFilterArea:i.showFilterArea===false}))),h.appendChild(p(x("footerArea"),i.showFooter===false,()=>e.controller.setLayout({showFooter:i.showFooter===false}))),g.appendChild(h);});}function R(y){let{t:f}=e.getI18n(),x=()=>{let g=e.getEngineTrees();if(!g)return [];let h=[],w=(i,p)=>{if(i)for(let u of i)p>=y.depth&&h.push(u.key),u.children&&w(u.children,p+1);};return w(y.type==="row"?g.rowTree:g.colTree,0),h};t.openPopup(g=>{let h=ue("");Object.assign(h.style,{position:"fixed",inset:"0",zIndex:"9998"}),h.addEventListener("click",()=>t.closePopup()),h.addEventListener("contextmenu",p=>{p.preventDefault(),t.closePopup();});let w=ue("kanuni-pivot-dropdown-menu pivot-animate-zoom-in");Object.assign(w.style,{position:"fixed",left:`${Math.min(y.x,window.innerWidth-180)}px`,top:`${Math.min(y.y,window.innerHeight-200)}px`,zIndex:"9999",minWidth:"160px"}),w.addEventListener("contextmenu",p=>p.preventDefault());let i=(p,u)=>{let v=ue("kanuni-pivot-dropdown-item pivot-state-hover","button");return v.type="button",Object.assign(v.style,{paddingLeft:"32px",paddingRight:"24px"}),v.textContent=p,v.addEventListener("click",c=>{c.stopPropagation(),t.closePopup(),u();}),v};w.appendChild(i(y.isExpanded?f("collapse"):f("expand"),()=>{y.type==="row"?e.controller.toggleExpanded(y.path):e.controller.toggleColExpanded(y.path);})),w.appendChild(ue("kanuni-pivot-dropdown-divider")),w.appendChild(i(f("expandAll"),()=>{let p=x();y.type==="row"?e.controller.expandPaths(p):e.controller.expandColPaths(p);})),w.appendChild(i(f("collapseAll"),()=>{let p=x();y.type==="row"?e.controller.collapsePaths(p):e.controller.collapseColPaths(p);})),g.append(h,w);});}return {openFieldMenu:k,openGlobalMenu:M,openNodeMenu:R,close:()=>t.closePopup()}}function xe(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}var Le=(e,...t)=>{let n=xe("kanuni-pivot-form-group"),r=xe("kanuni-pivot-form-label","label");return r.textContent=e,n.append(r,...t),n},Se=(e,t)=>{let n=xe("kanuni-pivot-select","select");for(let[r,l]of e){let a=document.createElement("option");a.value=r,a.textContent=l,n.appendChild(a);}return n.value=t,n},Ge=(e,t)=>{let n=xe("kanuni-pivot-input","input");return n.type=e,n.value=t,n},Vt=(...e)=>{let t=xe("");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},Wn=[["equals","opEquals"],["notEquals","opNotEquals"],["contains","opContains"],["notContains","opNotContains"],["startsWith","opStartsWith"],["endsWith","opEndsWith"]],Gn=[[">","opGreater"],[">=","opGreaterOrEqual"],["<","opLess"],["<=","opLessOrEqual"],["=","opEquals"],["!=","opNotEquals"],["between","opBetween"],["notBetween","opNotBetween"]];function zt(e){function t(l,a,s,C){let{t:k}=e.getI18n();e.portal.openPopup(M=>{let R=xe("kanuni-pivot-modal-overlay pivot-animate-fade-in");R.addEventListener("click",()=>e.portal.closePopup());let y=xe("kanuni-pivot-modal pivot-animate-zoom-in");y.style.width="400px",y.setAttribute("role","dialog"),y.setAttribute("aria-modal","true"),y.setAttribute("aria-label",l);let f=xe("kanuni-pivot-modal-header"),x=xe("kanuni-pivot-modal-title","h2");x.textContent=l;let g=xe("kanuni-pivot-modal-close","button");g.type="button",g.setAttribute("aria-label",k("cancel")),g.appendChild(q("x",20)),g.addEventListener("click",()=>e.portal.closePopup()),f.append(x,g);let h=xe("kanuni-pivot-modal-footer"),w=xe("kanuni-pivot-btn kanuni-pivot-btn--outline","button");w.type="button",w.textContent=k("cancel"),w.addEventListener("click",()=>e.portal.closePopup());let i=xe("kanuni-pivot-btn kanuni-pivot-btn--primary","button");i.type="button",i.appendChild(q("check",16)),i.appendChild(document.createTextNode(" "+k("ok"))),i.addEventListener("click",()=>{s()!==false&&e.portal.closePopup();}),h.append(w,i),y.append(f,a,h),M.append(R,y),C.focus();});}function n(l){let a=e.getFields().find(w=>w.id===l);if(!a)return;let{t:s}=e.getI18n(),C=xe("kanuni-pivot-modal-body pivot-custom-scrollbar"),k=Ge("text",a.caption??"");C.appendChild(Le(s("caption"),k));let M=a.area==="data"||a.area==="chooser",R=a.area==="row"||a.area==="column"||a.area==="filter"||a.area==="chooser",y=null,f=null,x=null,g=(...w)=>w.map(i=>[i,s(i)]),h=(...w)=>{let i=a.summaryType;return g(...i&&!w.includes(i)?[i,...w]:w)};M&&a.dataType&&a.dataType!=="number"&&(y=Se(h("count","distinct"),String(a.summaryType||"count")),C.appendChild(Le(s("summaryType"),y))),M&&a.dataType==="number"&&(y=Se(h("sum","count","avg","min","max","distinct"),String(a.summaryType||"sum")),C.appendChild(Le(s("summaryType"),y)),f=Se([["absolute",s("absoluteValue")],...g("percentOfTotal","percentOfColumnTotal","percentOfRowTotal","percentOfParentRowTotal","percentOfParentColumnTotal","runningTotal","difference","percentDifference")],String(a.summaryDisplayMode||"absolute")),C.appendChild(Le(s("displayMode"),f))),R&&a.dataType==="date"&&(x=Se([["",s("none")],...g("year","quarter","month","week","day")],String(a.groupInterval||"")),C.appendChild(Le(s("groupInterval"),x))),t(s("fieldSettings"),C,()=>{e.save({...a,caption:k.value,summaryType:y?.value||a.summaryType,summaryDisplayMode:f?.value??a.summaryDisplayMode,groupInterval:x?x.value||void 0:a.groupInterval});},k);}function r(l){let a=e.getFields(),s=a.find(c=>c.id===l);if(!s)return;let{t:C}=e.getI18n(),k=xe("kanuni-pivot-modal-body pivot-custom-scrollbar"),M=c=>[["",C("none")],...c.map(([o,m])=>[o,C(m)])],R=s.labelFilter,y=Se(M(Wn),R?.operator??"");y.setAttribute("data-condition-label-op",""),y.setAttribute("aria-label",C("caption"));let f=Ge("text",R?.value??"");f.setAttribute("data-condition-label-value",""),f.placeholder=C("builderValuePlaceholder"),f.setAttribute("aria-label",C("builderValuePlaceholder")),k.appendChild(Le(C("caption"),Vt(y,f)));let x=a.filter(c=>c.area==="data").sort((c,o)=>(c.areaIndex||0)-(o.areaIndex||0)),g=s.valueFilter,h=Se(x.map(c=>[c.id,c.caption||c.id]),x.some(c=>c.id===g?.dataField)?g.dataField:x[0]?.id??"");h.setAttribute("data-condition-value-field",""),h.setAttribute("aria-label",C("dataArea"));let w=Se(M(Gn),g?.operator??"");w.setAttribute("data-condition-value-op",""),w.setAttribute("aria-label",C("dataArea"));let i=Ge("number",g?String(g.value):"");i.setAttribute("data-condition-value","");let p=Ge("number",g?.value2!==void 0?String(g.value2):"");p.setAttribute("data-condition-value2","");for(let c of [i,p])c.setAttribute("aria-label",C("builderValuePlaceholder"));x.length>0&&k.appendChild(Le(C("dataArea"),h,Vt(w,i,p)));let u=()=>{f.disabled=y.value==="",i.disabled=w.value==="",p.style.display=w.value==="between"||w.value==="notBetween"?"":"none";};y.addEventListener("change",u),w.addEventListener("change",u),u();let v=c=>(c.setAttribute("aria-invalid","true"),c.focus(),false);t(`${C("conditionFilter")}: ${s.caption||s.id}`,k,()=>{for(let m of [f,i,p])m.removeAttribute("aria-invalid");let c;if(y.value){if(f.value==="")return v(f);c={operator:y.value,value:f.value,...R?.caseSensitive?{caseSensitive:true}:{}};}let o=x.length>0?void 0:g;if(w.value&&x.length>0){let m=p.style.display!=="none",E=i.value===""?NaN:Number(i.value),b=p.value===""?NaN:Number(p.value);if(!Number.isFinite(E))return v(i);if(m&&!Number.isFinite(b))return v(p);o={dataField:h.value,operator:w.value,value:E,...m?{value2:b}:{}};}e.save({...s,labelFilter:c,valueFilter:o});},y);}return {open:n,openCondition:r}}function te(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function qn(e){let t=e.isCalculated?"settings-2":e.dataType==="number"?"hash":e.dataType==="date"?"calendar":e.dataType==="boolean"?"filter":"type";return q(t,12,"var(--pivot-primary)")}function $t(e){let t=null,n=null,r=null,l="",a={x:0,y:0},s={width:700,height:550},C=()=>window.innerWidth<=768,k=["fullscreenchange","webkitfullscreenchange"],M=()=>{if(!t)return;let c=Ie();t.parentElement!==c&&c.appendChild(t);},R=()=>{n&&(y(),C()||(a={x:Math.min(a.x,Math.max(0,window.innerWidth-s.width)),y:Math.min(a.y,Math.max(0,window.innerHeight-s.height))},y()));};function y(){n&&(C()?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:`${a.x}px`,top:`${a.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 f(c,o){let{t:m}=e.getI18n(),E=te("kanuni-pivot-field-chip");E.setAttribute("data-drop-id",`chooser-${c.id}`),E.setAttribute("data-drag-scope","grip"),E.style.position="relative";let b=te("");if(b.setAttribute("data-drag-grip",""),Object.assign(b.style,{color:"var(--pivot-text-muted)",cursor:"grab",flexShrink:"0",opacity:"0.5"}),b.appendChild(q("grip-vertical",14)),E.appendChild(b),o){let O=te("kanuni-pivot-checkbox","input");O.type="checkbox",O.checked=c.area!=="chooser",O.style.flexShrink="0",O.addEventListener("change",()=>{O.checked?e.controller.showFields([c.id]):e.controller.removeField(c.id);}),E.appendChild(O);}E.appendChild(qn(c));let S=te("pivot-truncate","span");Object.assign(S.style,{flex:"1",color:"var(--pivot-text)",textAlign:"left"}),S.textContent=c.caption??c.id;let F=c.area==="data"&&c.summaryType?summaryTypeLabel(String(c.summaryType),m):"";if(F){let O=te("","span");Object.assign(O.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"}),O.textContent=F,S.appendChild(O);}E.appendChild(S);let A=!!c.filterValues&&c.filterValues.size>0,H=te(`kanuni-pivot-field-chip-actions${A?" is-filtered":""}`);if(c.area!=="data"){let O=te("kanuni-pivot-chip-btn","button");O.type="button",O.title=m("filterField"),A&&Object.assign(O.style,{color:"var(--pivot-danger)",backgroundColor:"color-mix(in srgb, var(--pivot-danger) 10%, transparent)"}),O.appendChild(q("filter",12)),O.addEventListener("click",$=>{$.stopPropagation(),e.onFilterClick($.clientX,$.clientY,c.id);}),H.appendChild(O);}if(c.isCalculated){let O=te("kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger","button");O.type="button",O.title=m("deletePermanently"),O.appendChild(q("trash",12)),O.addEventListener("click",$=>{$.stopPropagation(),e.controller.deleteField(c.id);}),H.appendChild(O);}let N=te("kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger","button");return N.type="button",N.title=m("removeFromArea"),N.appendChild(q("x",12)),N.addEventListener("click",O=>{O.stopPropagation(),e.controller.removeField(c.id);}),H.appendChild(N),E.appendChild(H),E}function x(c,o,m,E,b){let S=te("");if(Object.assign(S.style,{height:"100%",display:"flex",flexDirection:"column",transition:"background-color 0.2s"}),m!==null){let H=te("");Object.assign(H.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)"}),H.textContent=m,S.appendChild(H);}let F=te("pivot-custom-scrollbar");if(F.setAttribute("data-drop-id",`chooser-${c}`),F.setAttribute("data-drop-kind","list"),Object.assign(F.style,{maxHeight:C()?"none":"100%",flex:"1",padding:"8px",minHeight:"80px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"6px",alignItems:o.length===0?"center":"stretch",justifyContent:o.length===0?"center":"flex-start"}),o.length===0){let H=te("");Object.assign(H.style,{fontSize:"12px",color:"color-mix(in srgb, var(--pivot-text-muted) 70%, transparent)",fontStyle:"italic",textAlign:"center",width:"100%"}),H.textContent=E,F.appendChild(H);}for(let H of o)F.appendChild(f(H,b));let A=te("");return A.setAttribute("data-drop-id",`chooser-${c}-ghost-end`),A.setAttribute("data-ghost-populated",o.length>0?"1":"0"),Object.assign(A.style,{width:"100%",minHeight:"24px",transition:"background-color 0.2s",borderRadius:"var(--pivot-border-radius-sm)"}),F.appendChild(A),S.appendChild(F),S}function g(){let c=new Map;return e.getFields().map(o=>{let m=o.caption||o.id||"";if(c.has(m)){let E=c.get(m)+1;return c.set(m,E),{...o,caption:`${m} (${E})`}}return c.set(m,1),o})}function h(){let{locale:c}=e.getI18n(),o=[...g()].sort((E,b)=>(E.caption||"").toLowerCase().localeCompare((b.caption||"").toLowerCase(),c||"en"));if(!l)return o;let m=l.toLowerCase();return o.filter(E=>(E.caption||"").toLowerCase().includes(m))}function w(){let c=h().filter(o=>o.area==="chooser").map(o=>o.id);c.length!==0&&e.controller.showFields(c);}function i(){if(!r)return;let{t:c,locale:o}=e.getI18n(),m=new Map;for(let L of r.querySelectorAll('[data-drop-kind="list"]')){let P=L.getAttribute("data-drop-id");P&&L.scrollTop>0&&m.set(P,L.scrollTop);}let E=g(),b=h(),S=L=>E.filter(P=>P.area===L).sort((P,D)=>(P.areaIndex||0)-(D.areaIndex||0));r.textContent="";let F=C(),A=te(F?"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");F&&(A.style.flexShrink="0");let H=te("p-3 border-b border-border/60 bg-surface/80"),N=te("relative"),O=q("search",16);O.setAttribute("class","text-muted-fg opacity-60"),Object.assign(O.style,{position:"absolute",top:"50%",transform:"translateY(-50%)",pointerEvents:"none"}),O.style.setProperty("inset-inline-start","10px");let $=te("w-full bg-surface-hover/50 border-border rounded-md text-[13px] kanuni-pivot-input","input");$.type="text",$.placeholder=c("search"),$.value=l,$.style.setProperty("padding-inline-start","34px"),$.addEventListener("input",()=>{l=$.value,i();let L=r?.querySelector('input[type="text"]');L?.focus(),L?.setSelectionRange(L.value.length,L.value.length);}),N.append(O,$),H.appendChild(N),A.appendChild(H);let K=te(F?"p-2":"flex-1 overflow-hidden p-2"),we=te("");Object.assign(we.style,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"});let ie=te("text-[11px] font-bold uppercase tracking-wider text-muted-fg/80 mb-2 px-1");ie.textContent=c("allFields");let le=te("kanuni-pivot-popup-action-btn kanuni-pivot-chooser-select-all","button");le.type="button",le.textContent=c("selectAll"),le.style.color="var(--pivot-primary)",le.disabled=b.every(L=>L.area!=="chooser"),le.addEventListener("click",w),we.append(ie,le),K.appendChild(we),K.appendChild(x("chooser",b,null,c("noItems"),true)),A.appendChild(K);let fe=te(F?"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");F&&(fe.style.flexShrink="0");let ye=te(F?"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"),se=[["filter",c("filterArea")],["column",c("columnArea")],["row",c("rowArea")],["data",c("dataArea")]];for(let[L,P]of se){let D=te("border border-border/80 rounded-md shadow-sm bg-surface overflow-hidden flex flex-col transition-colors");F&&(D.style.minHeight="140px"),D.appendChild(x(L,S(L),P,c("dropHere"),false)),ye.appendChild(D);}fe.appendChild(ye),r.append(A,fe);for(let[L,P]of m){let D=r.querySelector(`[data-drop-id="${L}"][data-drop-kind="list"]`);D&&(D.scrollTop=P);}}function p(){if(t)return;let{t:c}=e.getI18n();t=Ae(e.gridRoot);let o=te("fixed inset-0 z-[100] kanuni-pivot-chooser-backdrop overflow-auto pointer-events-auto");o.addEventListener("click",u),n=te("flex flex-col bg-surface shadow-2xl border border-border overflow-hidden rounded-lg kanuni-pivot-field-chooser"),n.addEventListener("click",A=>A.stopPropagation()),C()||(s={width:Math.min(700,window.innerWidth-32),height:Math.min(550,window.innerHeight-32)},a={x:Math.max(0,(window.innerWidth-s.width)/2),y:Math.max(0,(window.innerHeight-s.height)/2)}),y();let m=te("pivot-field-chooser__header flex items-center justify-between p-3 border-b border-border bg-surface-header/90");C()||(m.style.cursor="move");let E=te("text-[15px] font-semibold m-0 flex items-center gap-2 select-none","h3");E.appendChild(q("grip-horizontal",18,"var(--pivot-text-muted)")),E.appendChild(document.createTextNode(c("allFields")));let b=te("btn-icon rounded-full p-1.5 kanuni-pivot-chip-btn","button");b.type="button",b.setAttribute("aria-label",c("cancel")),b.appendChild(q("x",18)),b.addEventListener("pointerdown",A=>A.stopPropagation()),b.addEventListener("click",u),m.append(E,b);let S=null;m.addEventListener("pointerdown",A=>{C()||A.target.closest(".kanuni-pivot-field-chip, button, input")||(S={px:A.clientX,py:A.clientY,x:a.x,y:a.y},m.setPointerCapture?.(A.pointerId));}),m.addEventListener("pointermove",A=>{S&&(a={x:Math.max(0,S.x+A.clientX-S.px),y:Math.max(0,S.y+A.clientY-S.py)},y());});let F=A=>{S=null,m.releasePointerCapture?.(A.pointerId);};if(m.addEventListener("pointerup",F),m.addEventListener("pointercancel",F),r=te(C()?"flex flex-1 flex-col bg-surface-sunken/30":"flex flex-1 overflow-hidden flex-col md:flex-row bg-surface-sunken/30"),C()&&(r.setAttribute("data-chooser-scroll",""),Object.assign(r.style,{minHeight:"0",overflowY:"auto",touchAction:"pan-y",overscrollBehavior:"contain"})),i(),n.append(m,r),!C()){let A=[["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[H,N,O]of A){let $=te("kanuni-pivot-chooser-resize");$.setAttribute("data-resize-dir",H),Object.assign($.style,{position:"absolute",zIndex:H.length===2?"51":"50",cursor:N},O);let K=null;$.addEventListener("pointerdown",ie=>{ie.stopPropagation(),K={px:ie.clientX,py:ie.clientY,w:s.width,h:s.height,x:a.x,y:a.y},$.setPointerCapture?.(ie.pointerId);}),$.addEventListener("pointermove",ie=>{if(!K)return;let le=ie.clientX-K.px,fe=ie.clientY-K.py,ye=K.w,se=K.h,L=K.x,P=K.y;H.includes("e")&&(ye=K.w+le),H.includes("s")&&(se=K.h+fe),H.includes("w")&&(ye=K.w-le,ye>=400&&(L=K.x+le)),H.includes("n")&&(se=K.h-fe,se>=400&&(P=K.y+fe)),s={width:Math.max(400,ye),height:Math.max(400,se)},a={x:Math.max(0,L),y:Math.max(0,P)},y();});let we=ie=>{K=null,$.releasePointerCapture?.(ie.pointerId);};$.addEventListener("pointerup",we),$.addEventListener("pointercancel",we),n.appendChild($);}}o.appendChild(n),t.appendChild(o),Ie().appendChild(t),window.addEventListener("resize",R);for(let A of k)document.addEventListener(A,M);e.onOpenChanged?.(true);}function u(){if(t){window.removeEventListener("resize",R);for(let c of k)document.removeEventListener(c,M);t.remove(),t=null,n=null,r=null,l="",e.onOpenChanged?.(false);}}function v(){if(!t)return;let c={...a},o={...s};u(),p(),a=c,s=o,y();}return {open:p,close:u,toggle:()=>t?u():p(),isOpen:()=>t!==null,repaint:i,relocalize:v,getHost:()=>t,destroy:u}}function ne(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}function Bt(e){let t=false,n=null,r=s=>{t&&n&&!n.contains(s.target)&&(t=false,e.requestRepaint());};document.addEventListener("mousedown",r);function l(s,C){let{t:k}=e.getI18n();e.portal.openPopup(M=>{let R=ne("kanuni-pivot-modal-overlay");R.addEventListener("click",()=>e.portal.closePopup());let y=ne("kanuni-pivot-modal pivot-animate-zoom-in");Object.assign(y.style,{display:"flex",flexDirection:"column",gap:"16px",padding:"24px"});let f=ne("pivot-flex pivot-flex-col");f.style.gap="6px";let x=ne("pivot-flex pivot-items-center pivot-justify-between"),g=ne("kanuni-pivot-modal-title","h3");g.textContent=s;let h=ne("kanuni-pivot-modal-close","button");h.type="button",h.setAttribute("aria-label",k("close")),h.style.padding="6px",h.appendChild(q("x",16)),h.addEventListener("click",()=>e.portal.closePopup()),x.append(g,h);let w=ne("kanuni-pivot-modal-description","p");w.textContent=k("saveReportDescription"),f.append(x,w);let i=ne("pivot-flex pivot-flex-col pivot-gap-4","form"),p=ne("pivot-flex pivot-flex-col pivot-gap-2"),u=ne("kanuni-pivot-form-label","label");u.textContent=k("reportName");let v=ne("kanuni-pivot-input","input");v.type="text",v.placeholder=k("reportNamePlaceholder"),v.required=true,v.value=C,p.append(u,v);let c=ne("pivot-flex pivot-items-center pivot-gap-2"),o=ne("kanuni-pivot-input","input");o.type="checkbox",Object.assign(o.style,{width:"16px",height:"16px"});let m=ne("kanuni-pivot-form-label","label");Object.assign(m.style,{margin:"0",cursor:"pointer"}),m.textContent=k("setAsDefault"),m.addEventListener("click",()=>{o.checked=!o.checked;}),c.append(o,m);let E=ne("kanuni-pivot-modal-footer");Object.assign(E.style,{marginTop:"8px",paddingTop:"16px",borderTop:"1px solid var(--pivot-border)",display:"flex",justifyContent:"flex-end",gap:"8px"});let b=ne("kanuni-pivot-btn kanuni-pivot-btn--outline","button");b.type="button",b.textContent=k("cancel"),b.addEventListener("click",()=>e.portal.closePopup());let S=ne("kanuni-pivot-btn kanuni-pivot-btn--primary","button");S.type="submit",S.disabled=!C.trim(),S.appendChild(q("save",16)),S.appendChild(document.createTextNode(" "+k("save"))),v.addEventListener("input",()=>{S.disabled=!v.value.trim();}),E.append(b,S),i.addEventListener("submit",F=>{F.preventDefault();let A=v.value.trim();A&&(e.controller.saveReport(A,o.checked),e.portal.closePopup());}),i.append(p,c,E),y.append(f,i),M.append(R,y),v.focus();});}function a(s){let{t:C}=e.getI18n();n=s;let k=e.getReports(),M=e.getActiveReportId(),R=k.find(w=>w.id===M),y=ne(`kanuni-pivot-report-btn ${t?"kanuni-pivot-report-btn--open":M?"kanuni-pivot-report-btn--active":"kanuni-pivot-report-btn--default"}`,"button");y.type="button",y.title=C("viewsAndReports"),y.appendChild(q("bookmark",15));let f=ne("pivot-truncate","span");if(f.style.maxWidth="120px",f.textContent=R?R.name:C("views"),y.appendChild(f),y.addEventListener("click",()=>{t=!t,e.requestRepaint();}),s.appendChild(y),!t)return;let x=ne("kanuni-pivot-report-dropdown pivot-animate-slide-up"),g=(w,i=false)=>{let p=ne("kanuni-pivot-report-section-title");return i&&(p.style.marginTop="8px",p.style.borderTop="1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"),p.textContent=w,p},h=(w,i,p,u)=>{let v=ne("kanuni-pivot-report-item","button");v.type="button",v.appendChild(q(w,16,i));let c=ne(""),o=ne("pivot-font-medium");return o.textContent=p,c.appendChild(o),v.appendChild(c),v.addEventListener("click",()=>{t=false,e.requestRepaint(),u();}),v};if(x.appendChild(g(C("actions"))),x.appendChild(h("save","var(--pivot-success)",C("saveNewView"),()=>l(C("saveNewView"),""))),M&&(x.appendChild(h("save-all","var(--pivot-warning)",C("saveChangesOverwrite"),()=>e.controller.updateCurrentReport())),x.appendChild(h("copy","var(--pivot-info)",C("saveAsCopy"),()=>l(C("saveAsView"),`${R?.name??""} (Copy)`)))),k.length>0){x.appendChild(g(C("savedViews"),true));let w=ne("kanuni-pivot-report-list pivot-custom-scrollbar");for(let i of k){let p=ne(`kanuni-pivot-report-list-item${i.id===M?" kanuni-pivot-report-list-item--active":""}`),u=ne("kanuni-pivot-report-list-btn","button");u.type="button",u.appendChild(q(i.id===M?"check":"folder-open",14,i.id===M?"var(--pivot-primary)":"var(--pivot-text-muted)"));let v=ne("pivot-text-sm pivot-truncate","span");v.style.color=i.id===M?"var(--pivot-primary)":"var(--pivot-text)",i.id===M&&v.classList.add("pivot-font-medium"),v.textContent=i.name,u.appendChild(v),i.isDefault&&u.appendChild(Fe("star",12,"var(--pivot-warning)")),u.addEventListener("click",()=>{t=false,e.requestRepaint(),e.controller.loadReport(i.id);}),p.appendChild(u);let c=ne("kanuni-pivot-report-actions");if(!i.isDefault){let m=ne("kanuni-pivot-action-btn kanuni-pivot-action-btn--warning","button");m.type="button",m.title=C("makeDefault"),m.setAttribute("aria-label",m.title),m.appendChild(q("star",14)),m.addEventListener("click",E=>{E.stopPropagation(),e.controller.setDefaultReport(i.id);}),c.appendChild(m);}let o=ne("kanuni-pivot-action-btn kanuni-pivot-action-btn--danger","button");o.type="button",o.title=C("deleteReport"),o.setAttribute("aria-label",o.title),o.appendChild(q("trash",14)),o.addEventListener("click",m=>{m.stopPropagation(),window.confirm(C("deleteReportConfirm").replace("{0}",i.name))&&(e.controller.deleteReport(i.id),i.id===M&&(t=false,e.requestRepaint()));}),c.appendChild(o),p.appendChild(c),w.appendChild(p);}x.appendChild(w);}s.appendChild(x);}return {mount:a,destroy(){document.removeEventListener("mousedown",r);}}}var _n={chartData:[],chartSeries:[]};function et(e,t,n,r){let l=null,a,s,C,k=false;function M(){if(k)return;let f=e.getState();if(!f.engineResult||!f.engineResult.cellMatrix||!n.transformer){r(_n);return}r(n.transformer(f.engineResult,shownFields(f.fields),f.expandedPaths,t(),n));}function R(){let f=e.getState(),x=t();f.engineResult===a&&f.expandedPaths===s&&x===C||(a=f.engineResult,s=f.expandedPaths,C=x,l&&clearTimeout(l),l=setTimeout(M,150));}let y=e.subscribe(R);return R(),{refresh:R,stop(){k=true,l&&clearTimeout(l),y();}}}function Pe(e,t="div"){let n=document.createElement(t);return e&&(n.className=e),n}var tt=new Set;function no(){let e="default-pivot-grid";for(let t=2;tt.has(e);t++)e=`default-pivot-grid-${t}`;return tt.add(e),e}function oo(e,t){if(!e||!(e instanceof HTMLElement))throw new Error("[pivotgrid] createPivotGrid needs a container HTMLElement");rt(t);let n=Ve(t.locale,t.dictionary,t.rtl),r=t.gridId||t.stateStoring?.storageKey,l=r||no();!r&&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 a=Pe("kanuni-pivot-root"+(t.className?" "+t.className:""));a.style.width="100%",a.style.height="100%",it(a,pivotSchemeTheme(t.theme,t.palette,t.dark)),a.setAttribute("dir",n.rtl?"rtl":"ltr");let s=Pe("kanuni-pivot-wrapper pivot-flex pivot-flex-col");s.style.width="100%",s.style.height="100%";let C=Pe("pivot-grid pivot-flex-1 pivot-flex pivot-flex-col pivot-relative");C.style.minHeight="0",C.style.overflow="hidden",C.style.backgroundColor="var(--pivot-bg)",C.style.border="1px solid var(--pivot-border)",C.style.borderRadius="var(--pivot-radius-md)",C.style.userSelect="none",t.striped&&a.classList.add("kanuni-pivot-striped");let k=t.density,M=()=>pivotDensityClass(k),R=()=>pivotRowHeight(k);M()&&a.classList.add(M());let y=Pe("pivot-flex-1 pivot-flex pivot-flex-col pivot-relative");y.style.minHeight="0";let f=Pe("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",""),C.appendChild(y),C.appendChild(f),s.appendChild(C),a.appendChild(s);let x=Pe("kanuni-pivot-live");x.setAttribute("role","status"),x.setAttribute("aria-live","polite"),x.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap",a.appendChild(x),e.appendChild(a);let g={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,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},h=new PivotController(g),w=bindPivotScrollMemory(a,h),i=()=>shownFields(h.getState().fields),p=Je(a),u=At({portal:p,getI18n:()=>n,gridId:l,getField:d=>i().find(I=>I.id===d),getData:()=>h.getRawData(),apply:(d,I,B)=>h.applyFilter(d,I,B),clear:d=>h.clearFilter(d),openCondition:d=>v.openCondition(d)}),v=zt({portal:p,getI18n:()=>n,getFields:i,save:d=>h.updateField(d)}),c=Ot({portal:p,gridRoot:a,getI18n:()=>n,getFields:i,getLayout:()=>h.getState().layout,controller:h,getEngineTrees:()=>{let d=h.getState().engineResult;return d?{rowTree:d.rowTree,colTree:d.colTree}:null},openSettings:d=>v.open(d),openCondition:d=>v.openCondition(d),openFilter:(d,I,B)=>{b()||u.open(I,B,d);},openFieldChooser:()=>o.open(),onEditCalculatedField:t.onEditCalculatedField?d=>{b()||t.onEditCalculatedField(d);}:void 0,customContextMenuItems:t.customContextMenuItems}),o=$t({gridRoot:a,getI18n:()=>n,getFields:i,controller:h,onFilterClick:(d,I,B)=>u.open(d,I,B),onOpenChanged:()=>{L||(K.refreshRoots(),se.paint(h.getState()));}}),m=(d,I)=>{t.onGlobalContextMenu?t.onGlobalContextMenu(d,I):c.openGlobalMenu(d,I);},E=kt(),b=()=>t.disabled===true,S,F,A={getI18n:()=>n,onRemove:d=>{b()||h.removeField(d);},onFilterClick:(d,I,B)=>{b()||u.open(d,I,B);},onSort:(d,I)=>{b()||h.sortField(d,I);},onContextMenu:(d,I,B,Q,z)=>{b()||c.openFieldMenu(d,I,B,Q,z);},getFields:i,onMove:(d,I)=>{b()||h.moveField(d,I);},requestFocus:d=>{S=d;let B=document.activeElement?.closest?.("[data-drop-id]")?.getAttribute("data-drop-id");F=B?i().find(Q=>Q.id===B)?.area:void 0;}},H=Et({host:y,getI18n:()=>n,onCellPrepared:t.onCellPrepared,registry:t.registry,shared:E,chipDeps:A,hasCellClick:()=>!!t.onCellClick&&!b(),columnWidthDefaults:resolveColumnWidthDefaults(t.defaultColumnWidths),rowHeight:R}),N=mt({...A,host:C,onGlobalContextMenu:m,onToggleCollapsed:()=>{b()||h.setLayout({filterAreaCollapsed:h.getState().layout.filterAreaCollapsed!==true});}});C.insertBefore(N.element,y);let O=Pe("kanuni-pivot-notice");O.setAttribute("role","status"),O.style.display="none",C.insertBefore(O,y);let $=()=>{let d=o.getHost();return d?[a,d]:[a]},K=Dt({gridRoot:a,roots:$,controller:h,getFields:i,onIntentChange:d=>bt($(),d),disabled:b,touchDragDelay:()=>t.touchDragDelay}),we=Tt({scroller:H.scroller,controller:{toggleExpanded:d=>{b()||h.toggleExpanded(d);},toggleColExpanded:d=>{b()||h.toggleColExpanded(d);},sortField:(d,I)=>{b()||h.sortField(d,I);}},getVM:H.getVM,getTheadHeight:H.getTheadHeight,rowHeight:R,shared:E,onCellClick:t.disabled===true?void 0:t.onCellClick,resolveCellClick:d=>h.resolveCellClick(d),onGlobalContextMenu:(d,I)=>{b()||m(d,I);},onFilterClick:(d,I,B)=>{b()||u.open(d,I,B);},onHeaderContextMenu:(d,I,B,Q)=>{b()||c.openFieldMenu(d,I,B,Q);},onNodeContextMenu:d=>{b()||c.openNodeMenu(d);},keyboardEnabled:t.keyboardNavigation?.enabled!==false}),ie=ut({scroller:H.scroller,shared:E,getVM:H.getVM,onStats:d=>h.setSelectionStats(d)}),le=Mt({host:y,scroller:H.scroller,shared:E,isRtl:()=>n.rtl,getWidths:()=>h.getState().columnWidths??{},rowHeaderLayout:()=>H.rowHeaderLayout(),commit:d=>{b()||h.setColumnWidths(d);}}),fe=It(a,()=>{se.paint(h.getState()),H.refreshWindow();}),ye=Bt({portal:p,getI18n:()=>n,controller:h,getReports:()=>h.getState().reports??[],getActiveReportId:()=>h.getState().activeReportId??null,requestRepaint:()=>se.paint(h.getState())}),se=Ft({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:d=>{h.exportData(d,{applyFilters:true}).catch(I=>{let B=I instanceof Error?I:new Error(String(I));B.name!=="AbortError"&&(t.onError?t.onError(B):console.error(B));});},onExpandAll:()=>h.expandAll({allLevels:true}),onCollapseAll:()=>h.collapseAll(),onAddCalculatedField:t.onAddCalculatedField?()=>{b()||t.onAddCalculatedField();}:void 0,onOpenPrefilter:t.onOpenPrefilter?()=>{b()||t.onOpenPrefilter();}:void 0,onToggleChart:t.onToggleChart?()=>{b()||t.onToggleChart();}:void 0,onToggleFullscreen:()=>fe.toggle(),isFullscreen:()=>fe.isFullscreen(),onGlobalContextMenu:m,mountReportMenu:d=>ye.mount(d),onSearch:t.search?d=>h.setSearchText(d):void 0}),L=false,P=false,D=null,V=0;function Y(){L||P||(P=true,queueMicrotask(ae));}function ae(){if(P=false,L)return;let d=h.getState(),I=!D||D.engineResult!==d.engineResult||D.fields!==d.fields||D.layout!==d.layout||D.expandedPaths!==d.expandedPaths||D.expandedColPaths!==d.expandedColPaths||D.columnWidths!==d.columnWidths,B=!D||D.isBuilding!==d.isBuilding||D.buildProgress!==d.buildProgress||D.engineError!==d.engineError||D.engineResult!==d.engineResult||D.noData!==d.noData,Q=!D||D.selectionStats!==d.selectionStats||D.reports!==d.reports||D.activeReportId!==d.activeReportId||D.layout!==d.layout;if(I&&(N.paint(shownFields(d.fields).filter(z=>z.area==="filter"),d.layout.showFilterArea!==false,{maxRows:d.layout.filterAreaMaxRows,collapsed:d.layout.filterAreaCollapsed===true}),o.isOpen()&&o.repaint()),I&&d.engineResult&&H.paintStructural(d),S!==void 0&&(((S?a.querySelector(`.kanuni-pivot-field-chip[data-drop-id="${S}"]`):F?a.querySelector(`[data-drop-id="${F}"]`):null)??H.scroller).focus({preventScroll:true}),S=void 0,F=void 0),B&&ve(d),!D||D.engineResult!==d.engineResult){let z=d.engineResult?.columnsTruncated;O.style.display=z?"":"none";let j=new Intl.NumberFormat(n.locale);O.textContent=z?n.t("columnsTruncated").replace("{shown}",j.format(z.shown)).replace("{total}",j.format(z.total)):"";}if(D&&D.searchText!==d.searchText&&se.syncSearch(d.searchText??""),D&&D.fields!==d.fields){let z=pivotChangeAnnouncement(D.fields,d.fields,n.t);z&&(x.textContent=nextLiveText(x.textContent??"",z));}Q&&(se.element.style.display=d.layout.showFooter===false?"none":"",se.paint(d)),D=d,V++;}function ve(d){if(d.engineError){f.style.display="block",f.textContent=`${n.t("error")}: ${d.engineError.message}`;return}if(d.isBuilding&&!d.engineResult){f.style.display="block",f.textContent=`${n.t("initializing")} ${Math.round(d.buildProgress??0)}%`;return}if(!d.engineResult){f.style.display="block",f.textContent=n.t(d.noData?"emptyData":"loading");return}f.style.display="none",f.textContent="";}let U=t.onChartSync?et(h,()=>n.locale,t.chartIntegrationOptions??{},t.onChartSync):null,de=h.subscribe(Y);ae();let T={controller:h,element:a,setData(d){L||h.setData(d);},applyTransaction(d){return h.applyTransaction(d)},applyTransactionAsync(d,I){h.applyTransactionAsync(d,I);},flushAsyncTransactions(){h.flushAsyncTransactions();},setLoading(d){h.setLoading(d);},undoLayout:()=>keepFocusAcross(a,h,()=>h.undoLayout()),redoLayout:()=>keepFocusAcross(a,h,()=>h.redoLayout()),canUndoLayout:()=>h.canUndoLayout(),canRedoLayout:()=>h.canRedoLayout(),clearLayoutHistory:()=>h.clearLayoutHistory(),setFields(d){L||h.setFields(d);},setSearchText(d){h.setSearchText(d);},setLocale(d,I,B){L||(n=Ve(d,I??t.dictionary,B??t.rtl),a.setAttribute("dir",n.rtl?"rtl":"ltr"),h.updateOptions({locale:n.locale}),D=null,Y(),o.relocalize(),U?.refresh());},openFieldChooser:()=>o.open(),closeFieldChooser:()=>o.close(),clearAllFilters:()=>h.clearAllFilters(),setDensity(d){L||(M()&&a.classList.remove(M()),k=d,M()&&a.classList.add(M()),D=null,Y());},destroy(){L||(L=true,de(),w(),U?.stop(),o.destroy(),K.destroy(),we.destroy(),ie.destroy(),le.destroy(),N.destroy(),ye.destroy(),se.destroy(),fe.destroy(),p.destroy(),H.destroy(),h.dispose(),a.remove(),r||tt.delete(l));}};return Object.defineProperty(T,"__flushCount",{get:()=>V}),Object.defineProperty(T,"__shared",{get:()=>E}),Object.defineProperty(T,"__dragRootCount",{get:()=>K.rootCount()}),T}
|
|
3
|
+
export{et as createChartSync,oo as createPivotGrid,Je as createPortalLayer,Ae as createThemedHost,ze as createValueFormatter,Fe as filledIcon,q as icon,Ie as portalParent,Ve as resolveI18n};
|