@bino-bi/bn-template-engine 1.0.0-alpha.13 → 1.0.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/{p-637e3b8f.entry.js → p-19f49fbc.entry.js} +1 -1
  3. package/dist/bn-template-engine/p-209b3fd9.entry.js +1 -0
  4. package/dist/bn-template-engine/{p-67eae33e.entry.js → p-3465fcdc.entry.js} +1 -1
  5. package/dist/bn-template-engine/{p-82023539.entry.js → p-67746414.entry.js} +1 -1
  6. package/dist/bn-template-engine/p-BPDZcex5.js +1 -0
  7. package/dist/bn-template-engine/{p-DHheVOfP.js → p-Tx6omDWp.js} +1 -1
  8. package/dist/bn-template-engine/{p-52097456.entry.js → p-d724ab88.entry.js} +1 -1
  9. package/dist/bn-template-engine/p-efd3b67a.entry.js +1 -0
  10. package/dist/bn-template-engine/{p-46699464.entry.js → p-ff659485.entry.js} +1 -1
  11. package/dist/bn-template-engine/p-z9bPNFYF.js +1 -0
  12. package/dist/cjs/bn-asset_21.cjs.entry.js +348 -75
  13. package/dist/cjs/bn-grid.cjs.entry.js +2 -2
  14. package/dist/cjs/bn-image.cjs.entry.js +2 -2
  15. package/dist/cjs/bn-internationalization.cjs.entry.js +1 -1
  16. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  17. package/dist/cjs/bn-text.cjs.entry.js +3 -3
  18. package/dist/cjs/bn-tree.cjs.entry.js +2 -2
  19. package/dist/cjs/{context-protocol-Op7uUwN3.js → context-protocol-Cn5PL928.js} +14 -0
  20. package/dist/cjs/editor-companion.cjs.entry.js +1 -1
  21. package/dist/cjs/loader.cjs.js +1 -1
  22. package/dist/cjs/{scaling-57N4Cxb_.js → scaling-DM2UILdF.js} +58 -17
  23. package/dist/cjs/{withStyled-C2kmGAK3.js → withStyled-Dx3uRw9g.js} +72 -1
  24. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +28 -10
  25. package/dist/collection/components/bn-chart-structure/utils/helper/ElementPositions.js +46 -4
  26. package/dist/collection/components/bn-chart-time/bn-chart-time.js +39 -1
  27. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +40 -10
  28. package/dist/collection/components/bn-dataset/bn-dataset.js +25 -13
  29. package/dist/collection/components/bn-datasource/bn-datasource.js +23 -12
  30. package/dist/collection/components/bn-layout-card/bn-layout-card.css +5 -0
  31. package/dist/collection/components/bn-layout-card/bn-layout-card.js +6 -3
  32. package/dist/collection/components/bn-layout-page/bn-layout-page.css +5 -0
  33. package/dist/collection/components/bn-layout-page/bn-layout-page.js +6 -3
  34. package/dist/collection/components/bn-table/bn-table.js +75 -7
  35. package/dist/collection/components/bn-table/ibcs-table.js +27 -0
  36. package/dist/collection/components/bn-table/utils/Table.js +2 -2
  37. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +28 -5
  38. package/dist/collection/components/bn-table/utils/helper/DataQuery.js +46 -6
  39. package/dist/collection/components/bn-table/utils/model/TableAttribute.js +46 -0
  40. package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +5 -0
  41. package/dist/collection/context/scopedDb.js +14 -0
  42. package/dist/collection/utils/parentDimensions.js +57 -16
  43. package/dist/collection/utils/validate.js +23 -0
  44. package/dist/components/DateStringFactory.js +1 -1
  45. package/dist/components/Order.js +1 -1
  46. package/dist/components/bn-chart-structure.js +1 -1
  47. package/dist/components/bn-chart-time.js +1 -1
  48. package/dist/components/bn-dataset.js +1 -1
  49. package/dist/components/bn-datasource.js +1 -1
  50. package/dist/components/bn-layout-card.js +1 -1
  51. package/dist/components/bn-layout-page.js +1 -1
  52. package/dist/components/bn-table.js +1 -1
  53. package/dist/components/bn-title2.js +1 -1
  54. package/dist/components/context-protocol.js +1 -1
  55. package/dist/components/ibcs-chart-structure2.js +1 -1
  56. package/dist/components/ibcs-chart-time2.js +1 -1
  57. package/dist/components/ibcs-table2.js +1 -1
  58. package/dist/components/ibcs-title2.js +1 -1
  59. package/dist/components/scaling.js +1 -1
  60. package/dist/components/validate.js +1 -1
  61. package/dist/esm/bn-asset_21.entry.js +348 -75
  62. package/dist/esm/bn-grid.entry.js +2 -2
  63. package/dist/esm/bn-image.entry.js +2 -2
  64. package/dist/esm/bn-internationalization.entry.js +1 -1
  65. package/dist/esm/bn-template-engine.js +1 -1
  66. package/dist/esm/bn-text.entry.js +3 -3
  67. package/dist/esm/bn-tree.entry.js +2 -2
  68. package/dist/esm/{context-protocol-BDhzNbeD.js → context-protocol-BB-4Onmw.js} +14 -0
  69. package/dist/esm/editor-companion.entry.js +1 -1
  70. package/dist/esm/loader.js +1 -1
  71. package/dist/esm/{scaling-La1Ow72h.js → scaling-h4KcBet3.js} +58 -17
  72. package/dist/esm/{withStyled-Bl9cSoRW.js → withStyled-BBvU2f-A.js} +71 -2
  73. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +4 -0
  74. package/dist/types/components/bn-chart-structure/utils/helper/ElementPositions.d.ts +16 -1
  75. package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +13 -0
  76. package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +4 -0
  77. package/dist/types/components/bn-dataset/bn-dataset.d.ts +15 -7
  78. package/dist/types/components/bn-datasource/bn-datasource.d.ts +13 -6
  79. package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +1 -0
  80. package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +1 -0
  81. package/dist/types/components/bn-table/bn-table.d.ts +13 -0
  82. package/dist/types/components/bn-table/ibcs-table.d.ts +2 -0
  83. package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +3 -1
  84. package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +11 -0
  85. package/dist/types/components/bn-table/utils/model/TableAttribute.d.ts +22 -0
  86. package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +3 -0
  87. package/dist/types/components.d.ts +45 -20
  88. package/dist/types/utils/validate.d.ts +6 -0
  89. package/package.json +1 -1
  90. package/dist/bn-template-engine/p-3c827826.entry.js +0 -1
  91. package/dist/bn-template-engine/p-BVFHvEXF.js +0 -1
  92. package/dist/bn-template-engine/p-CQnZV3JG.js +0 -1
  93. package/dist/bn-template-engine/p-ab3ea8cf.entry.js +0 -1
@@ -1 +1 @@
1
- import{h as t,proxyCustomElement as e,HTMLElement as o,Host as s,transformTag as i}from"@stencil/core/internal/client";import{F as n,Q as r,V as a,I as l,S as c}from"./ibcsRuleSet.js";import{I as h,D as u,i as d,j as f,k as p,e as m,M as $}from"./Order.js";import{d as v,g}from"./context-protocol.js";import{D as R,S as w,a as b,b as S}from"./DataFormatDigits.js";import{w as E}from"./withComponentStyle.js";var O,y,M,U,G;!function(t){t[t.ALL=-1]="ALL"}(O||(O={})),function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(y||(y={})),function(t){t.LIST="list",t.SUM="sum",t.SUMNOTOTAL="sumnototal",t.OPT="opt",t.OPTNOTOTAL="optnototal"}(M||(M={})),function(t){t.ASC="asc",t.DESC="desc"}(U||(U={})),function(t){t.HEADER="HEADER",t.GROUPHEAD="GROUPHEAD",t.SEPERATORLINE="SEPERATORLINE",t.SUM="SUM",t.GROUPSUM="GROUP_SUM",t.DRILLELEMENT="DRILLELEMENT",t.STANDARD="STANDARD",t.PARTELEMENT="PARTELEMENT",t.ENTRY="ENTRY"}(G||(G={}));class T{constructor(t,e,o,s,i,n,r,a,l){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=e,this.value=o,this.prefix=n||"",this.cssStyle=s||"",this.prefixStyle=r||"prefix",this.type=i,this.mark=void 0,this.colSpan=a||1,this.measureScale=l||1}getAsHeaderList(){if(null==this.value)return[""];const t=[];for(const e of this.value.toString().split("<br/>"))t.push(e);return t}draw(t){let e=this.value;if("undefined"===e||void 0===e||null==e)return"";if(Number.isNaN(Number(e)))return e;if(""===this.type||void 0===this.type||null==this.type)return e;let o=t.percent,s=t.percent;return"decimal"===this.type&&(e=+e/this.measureScale,o=t.decimal,s=t.decimal),n.number(Number(e),this.type,o,s)}drawPrefix(){return null==this.prefix?"":this.prefix}}class _{constructor(t,e,o){this.index=t,this.groupindex=e,this.type=o,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case G.HEADER:return"groupheader";case G.SEPERATORLINE:return"";case G.DRILLELEMENT:return"ofit";case G.PARTELEMENT:return"partof";case G.STANDARD:return"";case G.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,e,o,s,i,n,r,a,l,c=!1,h){let u=n;"category"===e&&null!=a&&(u=`category-${a.toString()}`),this.type===G.HEADER?u="headerlabel":this.type===G.SEPERATORLINE&&(u=e),this.type===G.PARTELEMENT&&("percent"===s&&(t="-"),"category"!==e&&"operation"!==e&&(s="percent",u="")),"-"===t&&(u="");let d="prefix-first";r&&(d="prefix-second"),o&&(u=`${u} ${o}`);const f=new T(e,this.elements.length,t,u,s,i,d,1,l);f.isBarChart=c,f.columnStats=h,this.elements.push(f)}}const C={positive:{stroke:"#008f96",fill:"#008f96",fillpattern:"solid"},negative:{stroke:"#ff0000",fill:"#ff0000",fillpattern:"solid"},neutral:{stroke:"#808080",fill:"#808080",fillpattern:"outlined"},scenarios:{ac:{stroke:"#404040",fill:"#404040",fillpattern:"solid"},pp:{stroke:"#A6A6A6",fill:"#A6A6A6",fillpattern:"solid"},fc:{stroke:"#404040",fill:"#ffffff",fillpattern:"hatched"},pl:{stroke:"#404040",fill:"#ffffff",fillpattern:"outlined"}},fontColor:"#000000",fontSize:11,fontFamily:"'Noto Sans', sans-serif",unitScaling:.01,percentageScaling:.5,scaleFactor:1},N="#666666";function L(t,e){return`pattern-${t}-${e.replace("#","")}`}const P=({styles:e})=>{const o=e.scaleFactor,s=6*o,i=[{id:L("pos",e.positive.stroke),stroke:e.positive.stroke,fill:e.positive.fill},{id:L("neg",e.negative.stroke),stroke:e.negative.stroke,fill:e.negative.fill},{id:L("neu",e.neutral.stroke),stroke:e.neutral.stroke,fill:e.neutral.fill}];return t("defs",null,i.map((e=>t("pattern",{id:e.id,patternUnits:"userSpaceOnUse",width:s,height:s},t("rect",{width:s,height:s,fill:"#ffffff"}),t("line",{x1:"0",y1:s,x2:s,y2:"0",stroke:e.stroke,"stroke-width":1.5*o})))))};function x(t,e,o=1){let s,i;const n=t>=0?"+":"";if(e)return s=100*t,n+Math.round(s).toString()+"%";{let e;return s=t/o,i=Math.abs(s),e=i>=1e9?(s/1e9).toFixed(i>=1e10?0:1)+"B":i>=1e6?(s/1e6).toFixed(i>=1e7?0:1)+"M":i>=1e3?(s/1e3).toFixed(i>=1e4?0:1)+"K":s.toFixed(i>=10?0:1),e=e.replace(/\.0([KMB]?)$/,"$1"),n+e}}function k(t){const e=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(e)}function A(t){const e=t.slice(0,2).toLowerCase();return"pp"===e?"pp":"fc"===e?"fc":"pl"===e?"pl":"ac"}function D(t,e,o,s){return k(t)?function(t,e){const o=A(t);return e.scenarios[o]}(t,s):function(t,e,o){const s=t>=0;return e?s?o.positive:o.negative:s?o.negative:o.positive}(e,o,s)}const B=e=>{const{value:o,scenario:s,columnStats:i,height:n,isPositiveGood:r,formattedValue:a,measureScale:l,maxBarWidth:c=10,styles:h=C}=e,u=h.scaleFactor,d=h.fontSize,f=38*u,p=c*d,m=4*u,$=.15*p,v=p-m-$,g=Math.abs(o)*h.unitScaling*d,R=g>v,w=Math.max(0,i.absMax*h.unitScaling*d-v),b=Math.max(0,g-v),S=w>0?b/w*$:0,E=i.min<0,O=i.max>0,y=E?p:0,M=(E?f:0)+(y+(O?p:0))+(O?f:0),U=2*u,G=n-2*U,T=(E?f:0)+y,_=U,B=o>=0,F=D(s,o,r,h),Y=function(t,e){const o=t.fillpattern;return"hatched"===o?`url(#${L(e,t.stroke)})`:"outlined"===o?"transparent":t.fill}(F,k(s)?A(s):r?B?"pos":"neg":B?"neg":"pos"),{stroke:W,strokeWidth:H}="outlined"===(I=F).fillpattern?{stroke:I.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0};var I;const z=a||x(o,!1,l),j=R?v:g,Q=R?v+m+S:g,V=B?T+Q+4*u:T-Q-4*u,q=B?"start":"end";return t("svg",{width:M,height:n,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},t(P,{styles:h}),t("line",{x1:T,y1:0,x2:T,y2:n,stroke:N,"stroke-width":1*u}),j>0&&t("rect",{x:B?T:T-j,y:_,width:j,height:G,fill:Y,stroke:W,"stroke-width":H*u}),R&&S>0&&t("rect",{x:B?T+v+m:T-v-m-S,y:_,width:S,height:G,fill:Y,stroke:W,"stroke-width":H*u}),R&&function(e,o,s,i,n){const r=e+o/2,a=.35*o,l=i/3,c=.3*o;let h=`M ${r-a} ${s}`;for(let t=0;t<3;t++)h+=` L ${r-a-c} ${s+l*(t+.5)} L ${r-a} ${s+l*(t+1)}`;let u=`M ${r+a} ${s}`;for(let t=0;t<3;t++)u+=` L ${r+a+c} ${s+l*(t+.5)} L ${r+a} ${s+l*(t+1)}`;return[t("rect",{x:e,y:s-1,width:o,height:i+2,fill:"#ffffff"}),t("path",{d:h,fill:"none",stroke:"#000000","stroke-width":1*n}),t("path",{d:u,fill:"none",stroke:"#000000","stroke-width":1*n})]}(B?T+v:T-v-m,m,_,G,u),t("text",{x:V,y:n/2,dy:"0.35em","text-anchor":q,fill:h.fontColor,"font-size":d,"font-family":h.fontFamily},z))},F=e=>{const{value:o,scenario:s,columnStats:i,height:n,isPositiveGood:r,formattedValue:a,measureScale:l,maxBarWidth:c=10,styles:h=C}=e,u=h.scaleFactor,d=h.fontSize,f=Math.round(.67*c*d),p=5*u,m=i.min<0?f+p:0,$=m+(i.max>0?f+p:0),v=$+45*u,g=m,R=n/2,w=100*Math.abs(o)*h.percentageScaling*d,b=w>f,S=Math.min(w,f),E=o>=0,O=E?g+S:g-S,y=D(s,o,r,h),M=3*u,U=a||x(o,!0,l),G=$+4*u;return t("svg",{width:v,height:n,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},t("line",{x1:g,y1:0,x2:g,y2:n,stroke:N,"stroke-width":1*u}),!b&&t("circle",{cx:O,cy:R,r:M,fill:h.fontColor}),t("line",{x1:g,y1:R,x2:O,y2:R,stroke:y.fill,"stroke-width":2*u}),b&&E&&t("polygon",{points:`${g+f},${R} ${g+f-6*u},${R-3*u} ${g+f-6*u},${R+3*u}`,fill:y.fill}),b&&!E&&t("polygon",{points:`${g-f},${R} ${g-f+6*u},${R-3*u} ${g-f+6*u},${R+3*u}`,fill:y.fill}),t("text",{x:G,y:n/2,dy:"0.35em","text-anchor":"start",fill:h.fontColor,"font-size":d,"font-style":"italic","font-family":h.fontFamily},U))},Y=e=>{const{value:o,columnStats:s,isRelative:i,styles:n=C}=e;return null==o||isNaN(o)||!s||0===s.absMax?t("span",{class:"bar-chart-empty",style:{color:n.fontColor,fontStyle:"italic"}},"-"):t(i?F:B,Object.assign({},e))};class W{constructor(t){this.groups=[r.CATEGORY,r.CATEGORYINDEX],M.OPT!==t.type&&M.OPTNOTOTAL!==t.type||this.groups.unshift(r.OPERATION),t.grouped&&(this.groups.push(r.ROWGROUP),this.groups.push(r.ROWGROUPINDEX))}toString(){return this.groups.map((t=>`${t}`)).toString()}noCategory(){return this.groups.filter((t=>t!==r.CATEGORY))}toArray(){return this.groups}}class H{constructor(t,e){this.hasPartOf=!1,this.config=t,this.i18n=e}execute(t,e){var o;this.db=t,this.fromExpr=e;const s=[],i=[],n=[],a=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),l=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),c=this.getRelativeScenarios(),h=new W(this.config),u=this.config.grouped?[r.ROWGROUP,r.ROWGROUPINDEX]:[];let d,f=["",""];this.config.sortOrder.hierarchy.length>0&&(f=this.createOrderString(this.config.sortOrder)),this.hasPartOf=this.checkConfigForPartOf();try{d=t.exec(`SELECT COUNT(DISTINCT ${r.CATEGORY}) as ${r.TOTALROWCOUNT} ${u.length>0?","+u:""}\n FROM ${e} ${u.length>0?"GROUP BY "+u:""}\n ORDER BY ${f[0]}`)}catch(t){return console.error("DataQuery: meta query failed",t),[]}return 0===d.length||1===d.length&&0===(null!==(o=d[0][r.TOTALROWCOUNT])&&void 0!==o?o:0)&&0===u.length?[]:(d.forEach((t=>{const e=t.rowGroup&&t.rowGroup.length>0?`WHERE ${r.ROWGROUP} = '${t.rowGroup}'`:"";let o="";this.config.limit&&(o=`LIMIT ${this.config.limit}`),this.createGroupHeaderRow(t,s),this.createDataRow(s,t,h,a,e,f,o),this.createRestRow(t,s,h,a,e,f),this.createGroupSumRow(s,i,t,l,f)})),this.createTotalSumRow(s,i,l),s.forEach((e=>{try{n.push(t.exec(e))}catch(t){console.error("DataQuery: SQL query execution failed",e,t)}})),this.detectNaNCells(this.config.scenarios,n),this.createThereOfDrillRows(a,f,n),this.createPartOfDrillRows(a,f,i,n),this.createThereOfDrillColumns(this.config.categoryThereOf,n),this.calculateColumnGroupRest(n,this.config.categoryThereOf),this.calculateRelativeVariances(n,c),n)}detectNaNCells(t,e){e.forEach((e=>{e.map((e=>(t.forEach((t=>{const o=new a(t);!0===o.isValid?0!==e[o.base+"_cnt"]&&0!==e[o.delta+"_cnt"]||(e[t]=Number.NaN):0===e[t+"_cnt"]&&(e[t]=Number.NaN)})),e)))}))}createPartOfDrillRows(t,e,o,s){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===M.LIST)return;const i=this.createPartOfQuery(t,e);let n=[];const a=this.db;i.forEach((function(t){n.push(...a.exec(t))}));const l=this.exctractScenarioNames(t),c=[];o.forEach((function(t){c.push(...a.exec(t))}));const h=new Map;c.forEach((t=>h.set(t[r.ROWGROUP],t))),n=this.reduceResDrillByCategoryGroups(n,l),n.forEach((function(t){l.forEach((e=>{try{t[e]=t[e]/h.get(t[r.ROWGROUP])[e]}catch(o){console.error("DataQuery: partOf drill row calculation failed",e,o),t[e]=Number.NaN}}))})),this.injectDrillRowsToResultRows(n,s)}createRestRow(t,e,o,s,i,n){t.totalRowCnt-this.config.limit>0&&0!==this.config.limit&&e.push(`SELECT ${r.ROWNR}, 1 as ${r.ROWGROUPINDEX} , 'ENTRY' as ${r.TYPE}, 'NO_GROUP' as ${r.ROWGROUP}, 'REST' as ${r.CATEGORY} , SUM(ac1) as ac1, SUM(pp1) as pp1, SUM(dpp1_ac1_pos) as dpp1_ac1_pos, SUM(drpp1_ac1_pos) as drpp1_ac1_pos, SUM(dr_pp1) as dr_pp1 FROM (SELECT ROWNUM() AS ${r.ROWNR}, ${e.length} as ${r.ROWGROUPINDEX} , 'ENTRY' as ${r.TYPE}, '${t.rowGroup||"NO_GROUP"}' as ${r.ROWGROUP}, ${o} ${s.length>0?",".concat(s):""} FROM ${this.fromExpr} ${i} GROUP BY ${o} ORDER BY ${n[0]}) t WHERE t.rowNr > ${this.config.limit}`)}createDataRow(t,e,o,s,i,n,a){t.push(`SELECT ROWNUM() AS ${r.ROWNR},\n ${t.length} as ${r.ROWGROUPINDEX},\n 'ENTRY' as ${r.TYPE},\n '${e.rowGroup||"NO_GROUP"}' as ${r.ROWGROUP},\n '${r.CATEGORYINDEX}',\n ${o} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} ${i}\n GROUP BY ${o}\n ORDER BY ${n[0]} ${a}`)}createGroupHeaderRow(t,e){!0===this.config.grouped&&e.push(`SELECT ROWNUM() AS ${r.ROWNR},\n ${e.length} as ${r.ROWGROUPINDEX},\n 'GROUPHEAD' as ${r.TYPE},\n '${t.rowGroup}' as ${r.ROWGROUP} ${this.config.showGroupTitle?`,'${t.rowGroup}' as ${r.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}createGroupSumRow(t,e,o,s,i){!0!==this.config.grouped||M.SUM!==this.config.type&&M.SUMNOTOTAL!==this.config.type&&M.OPT!==this.config.type&&M.OPTNOTOTAL!==this.config.type||(t.push(`SELECT ${t.length} as ${r.ROWGROUPINDEX},\n '=' as ${r.OPERATION},\n '${o.rowGroup}' as ${r.ROWGROUP},\n ROWNUM() AS ${r.ROWNR},\n 'GROUP_SUM' as ${r.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr}\n WHERE ${r.ROWGROUP} = '${o.rowGroup}'\n ORDER BY ${i[0]} `),e.push(`SELECT ${t.length} as ${r.ROWGROUPINDEX},\n '=' as ${r.OPERATION},\n '${o.rowGroup}' as ${r.ROWGROUP},\n ROWNUM() AS ${r.ROWNR},\n 'GROUP_SUM' as ${r.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr}\n WHERE ${r.ROWGROUP} = '${o.rowGroup}'\n ORDER BY ${i[0]} `))}createTotalSumRow(t,e,o){if(M.SUM===this.config.type||M.OPT===this.config.type){const e=`${this.hasPartOf&&!1===this.config.grouped?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} `:""}${this.config.title}`;t.push(`SELECT ${t.length} as ${r.ROWGROUPINDEX},\n '${e}' as ${r.ROWGROUP},\n '=' as ${r.OPERATION},\n 'SUM' as ${r.TYPE} ${o.length>0?",".concat(o):""}\n FROM ${this.fromExpr} `)}e.push(`SELECT ${t.length} as ${r.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${r.ROWGROUP},\n '=' as ${r.OPERATION},\n 'SUM' as ${r.TYPE} ${o.length>0?",".concat(o):""}\n FROM ${this.fromExpr} `)}reduceResDrillByCategoryGroups(t,e){const o=new Map;return t.forEach((function(t){const s=t.rowNr+t.rowGroup+t.type+t.category;if(o.has(s)){const i=o.get(s);e.forEach((e=>{try{i[e]+=t[e]}catch(t){console.error("DataQuery: drill row aggregation failed",e,t)}}))}else o.set(s,t)})),[...o.values()]}injectDrillRowsToResultRows(t,e){const o=new Map;if(!0===this.config.grouped)t.forEach((function(t){e.forEach((function(e){const s=e.findIndex((e=>e.category===t.category&&e.rowGroup===t.rowGroup));if(s>=0){if(o.has(`${t.category}_${t.rowGroup}`)){const e=o.get(`${t.category}_${t.rowGroup}`)||0;o.set(`${t.category}_${t.rowGroup}`,e+1)}else o.set(`${t.category}_${t.rowGroup}`,1);t[r.ROWNR]=o.get(`${t.category}_${t.rowGroup}`),e.splice(s+t[r.ROWNR],0,t)}}))}));else{const s=this.findDuplicateSubCategories(t);t.forEach((function(t){e.forEach((function(e){const i=e.findIndex((e=>null!=e.category&&e.category===t.category));if(i>=0){if(o.has(`${t.category}`)){const e=o.get(`${t.category}`)||0;o.set(`${t.category}`,e+1)}else o.set(`${t.category}`,1);(1===t[r.ROWNR]||s.includes(t.subCategory))&&(t.subCategory=`${t.subCategory} (${t.rowGroup})`),e.splice(i+t[r.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,e,o){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const s=[],i=[];this.config.thereOf.forEach((o=>{let i=!0,n="1 <> 1 OR ( ";null!=o.category&&0!==o.category.length&&o.category.trim()&&(n+=` ${r.CATEGORY} = '${o.category}'`,i=!1),null!=o.rowGroup&&0!==o.rowGroup.length&&o.rowGroup.trim()&&(n+=` ${i?"":"AND"} ${r.ROWGROUP} = '${o.rowGroup}'`,i=!1),null!=o.subCategory&&0!==o.subCategory.length&&o.subCategory.trim()&&(n+=` ${i?"":"AND"} ${r.SUBCATEGORY} = '${o.subCategory}'`),n+=")",s.push(`SELECT ROWNUM() AS ${r.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${r.TYPE},\n ${r.CATEGORY},\n ${r.SUBCATEGORY},\n ${r.ROWGROUP} as ${r.ROWGROUP},\n ${t}\n FROM ${this.fromExpr}\n WHERE ${n}\n GROUP BY ${r.ROWGROUP}, ${r.CATEGORY}, ${r.SUBCATEGORY}\n ORDER BY ${e[1]}`)}));const n=this.db;s.forEach((function(t){i.push(...n.exec(t))})),this.injectDrillRowsToResultRows(i,o)}calculateRelativeVariances(t,e){t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[r.TYPE]&&e.forEach(((e,o)=>{t[o]=t[o]/t[e]}))}))}))}calculateColumnGroupRest(t,e){if(null==e||0===e.size)return;const o=new Map,s=new Map;e.forEach(((t,e)=>{const i=t,n=[];for(const t of i)n.push(`${e}##${t.name}`);o.set(e,n),s.set(`${e}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[r.TYPE]&&o.forEach(((e,o)=>{let i=0;e.forEach((e=>{void 0!==t[e]&&(i+=t[e])})),t[`${o}##REST`]=t[o]-i,0!==t[`${o}##REST`]&&s.set(`${o}##REST`,!0)}))}))}));const i=Array.from(s.entries()).filter((([t,e])=>!e)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const e of i)delete t[e]}))}))}getRelativeScenarios(){const t=new Map;return this.config.scenarios.forEach((e=>{const o=this.createRelativeScenario(e);null!=o&&t.set(o.key,o.value)})),t}translateScenarioSQL(t,e,o){const s=new a(t);return M.OPT===o||M.OPTNOTOTAL===o?s.isValid?"dr"===s.type?`SUM(${s.base} - ${s.delta}) as ${t}, SUM(${s.delta}) as dr_${s.delta}`:`SUM(${s.base} - ${s.delta}) as ${t}`:e?`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:`SUM(${t}) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:s.isValid?"dr"===s.type?`SUM((${s.base} * transformOperator(operation)) - (${s.delta} * transformOperator(operation))) as ${t}, SUM(${s.delta} * transformOperator(operation)) as dr_${s.delta}`:`SUM((${s.base} * transformOperator(operation))- (${s.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}createOrderString(t){return[`${t.hierarchy.toString()} ${t.direction}`,`${t.hierarchy.toString()} ${U.ASC===t.direction?U.DESC:U.ASC}`]}createRelativeScenario(t){const e=new a(t);return e.isValid&&"dr"===e.type?{key:`${t}`,value:`dr_${e.delta}`}:null}exctractScenarioNames(t){const e=[];return t.split(",").forEach((t=>t.length>=2?e.push(t.split("as")[1].trim()):null)),e}findDuplicateSubCategories(t){const e=t.map((t=>({count:1,subCategory:t.subCategory}))).reduce(((t,e)=>(t[e.subCategory]=(t[e.subCategory]||0)+e.count,t)),{});return Object.keys(e).filter((t=>e[t]>1))}createPartOfQuery(t,e){var o;const s=[];let i="1 <> 1 ",n=` ${r.ROWGROUP}`,a="ROWNUM()";return null===(o=this.config.partOf)||void 0===o||o.forEach((t=>{i+=`OR (${r.CATEGORY} = '${t.category}'`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=`and ${r.ROWGROUP} = '${t.rowGroup}'`),!1===this.config.grouped&&(n=` 'SUM_TOTAL' as ${r.ROWGROUP} `,a="1"),i+=")"})),s.push(`SELECT ${a} AS ${r.ROWNR},\n 'PARTELEMENT' as ${r.TYPE},\n ${r.CATEGORY},\n ${n},\n ${t}\n FROM ${this.fromExpr}\n WHERE ${i}\n GROUP BY ${r.ROWGROUP}, ${r.CATEGORY}, ${r.TYPE}\n ORDER BY ${e[1]}`),s}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,e){if(null==t||0===t.size)return;const o=[],s=[],i=this.fromExpr;t.forEach(((t,e)=>{let s="1 <> 1 ";t.forEach((t=>{s+=` or columnGroup = '${t.name}' `})),o.push(`SELECT 'ENTRY' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${s}\n GROUP BY rowlevel, rowGroup, category, columnGroup, scenario`),o.push(`SELECT 'ENTRY' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${s}\n GROUP BY rowlevel, rowGroup, category, columnGroup, columnSubGroup, scenario`),o.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${s}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, scenario`),o.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${s}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, columnSubGroup, scenario`),o.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${s}\n GROUP BY rowlevel, rowGroup, columnGroup, scenario`),o.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${s}\n GROUP BY rowlevel, rowGroup, columnGroup, columnSubGroup, scenario`),o.push(`SELECT 'SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${s}\n GROUP BY rowlevel, columnGroup, scenario`),o.push(`SELECT 'SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${s}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of o)s.push(...this.db.exec(t));this.injectDrillColumnsToResultRows(s,e)}injectDrillColumnsToResultRows(t,e){const o="##";for(const s of t)for(const t of e)for(const e of t)e.type===s.rowlevel&&("ENTRY"===s.rowlevel?"COLUMNGROUP"===s.columnlevel&&e.category===s.category?e[s.scenario+o+s.columnGroup]=s.val:"SUBGROUP"===s.columnlevel&&e.category===s.category&&(e[s.scenario+o+s.columnGroup+o+s.columnSubGroup]=s.val):"DRILLELEMENT"===s.rowlevel?"COLUMNGROUP"===s.columnlevel&&e.category===s.category&&e.subCategory===s.subCategory?e[s.scenario+o+s.columnGroup]=s.val:"SUBGROUP"===s.columnlevel&&e.category===s.category&&e.subCategory===s.subCategory?e[s.scenario+o+s.columnGroup+o+s.columnSubGroup]=s.val:"COLUMNGROUP"===s.columnlevel&&e.category===s.category&&e.subCategory===`${s.subCategory} (${s.rowGroup})`?e[s.scenario+o+s.columnGroup]=s.val:"SUBGROUP"===s.columnlevel&&e.category===s.category&&e.subCategory===`${s.subCategory} (${s.rowGroup})`&&(e[s.scenario+o+s.columnGroup+o+s.columnSubGroup]=s.val):("SUM"===s.rowlevel||"GROUP_SUM"===s.rowlevel)&&("COLUMNGROUP"===s.columnlevel&&e.category===s.category&&e.subCategory===s.subCategory&&(e[s.scenario+o+s.columnGroup]=s.val),"SUBGROUP"===s.columnlevel&&e.category===s.category&&e.subCategory===s.subCategory&&(e[s.scenario+o+s.columnGroup+o+s.columnSubGroup]=s.val)))}}class I{constructor(){this.normalizedHeader=[]}createHeader(t,e,o,s,i,r){const a=[];this.normalizedHeader=this.normalizeHeader(t,e);const l=new _(0,0,G.HEADER),c=new _(1,0,G.SEPERATORLINE);for(const t of this.normalizedHeader)l.createElement(n.translateScenarioLabel(t.name,o),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,o,s,i,r),null,null,null,null),c.createElement(null,t.type,this.createColumnType(t),null,null,null,null,null,null);return a.push(l),a.push(c),a}setHeaderPrefix(t,e,o,s,i){let r="";return"category"===t.name&&i&&(0===o.prefix.length&&0===s.length||(r=n.translateScenarioLabel("in",e)+" "+o.prefix+s)),t.order&&(r+=n.translateScenarioLabel("ORDER_"+t.order,e)),r}normalizeHeader(t,e){let o=[{name:r.CATEGORY,group:r.CATEGORY,type:r.CATEGORY,order:void 0}];return M.OPT!==t&&M.OPTNOTOTAL!==t||(o=[{name:r.OPERATION,group:r.OPERATION,type:r.OPERATION,order:void 0},{name:r.CATEGORY,group:r.CATEGORY,type:r.CATEGORY,order:void 0}]),[...o,...e]}createBodyRows(t,e,o,s){const i=[];let n=-1;const r=new H(t,e).execute(o,s),a=this.calculateColumnStatistics(r,t.barColumns);for(const o of r)n+=1,i.push(...this.createRow(t.i18n,e,t.scenariosUnitType,o,n,-1,t.categoryWidth,t.measureScale,t.barColumns,a));return i}calculateColumnStatistics(t,e){const o=new Map;if(!e||0===e.length)return o;const s=new Map;for(const t of e)o.set(t,{min:1/0,max:-1/0,absMax:0,median:0}),s.set(t,[]);for(const i of t)for(const t of i)for(const i of e){const e=this.extractColumnValue(t,i);if(null!==e&&!isNaN(e)){const t=o.get(i);t.min=Math.min(t.min,e),t.max=Math.max(t.max,e),s.get(i).push(Math.abs(e))}}for(const[t,e]of o){e.min!==1/0&&e.max!==-1/0||(e.min=0,e.max=0),e.absMax=Math.max(Math.abs(e.min),Math.abs(e.max));const i=s.get(t);if(i.length>0){i.sort(((t,e)=>t-e));const t=Math.floor(i.length/2);e.median=i.length%2==0?(i[t-1]+i[t])/2:i[t]}o.set(t,e)}return o}extractColumnValue(t,e){if(void 0!==t[e]){const o=Number(t[e]);return isNaN(o)?null:o}for(const o of Object.keys(t))if(o===e||o.endsWith("##"+e)||o===e+"##"+e){const e=Number(t[o]);if(!isNaN(e))return e}return null}createRow(t,e,o,s,i,n,a,l,c,h){var u;const d=[];for(const f of s){const p=f[r.ROWGROUP],m=f[r.SUBCATEGORY],$=f[r.TYPE],v=f[r.ROWNR]>=2,g=this.createDetailRow($,n+=1,i,s.length);for(const s of this.normalizedHeader){const i=this.getRawDataRowElement(f,s),n=null!==(u=null==c?void 0:c.includes(s.type))&&void 0!==u&&u,r=n?null==h?void 0:h.get(s.type):void 0;g.createElement(this.translateSumCellLabel(t,e,i,p,m,$,s.type),s.type,this.createColumnType(s),this.setCellType(s.type,o),this.translateCellPrefix(e,$,s.type),this.translateScenarioCSS(s.type,i),v,a,null==l?void 0:l.value,n,r)}d.push(g)}return d}getRawDataRowElement(t,e){return e.name===e.group&&e.name===e.type?t[e.name]:e.name===e.group&&e.name!==e.type?t[e.type+"##"+e.name]:t[e.type+"##"+e.group+"##"+e.name]}createDetailRow(t,e,o,s){switch(t){case G.GROUPHEAD:return new _(e,o,G.HEADER);case G.SUM:case G.GROUPSUM:return new _(s+2,o,G.SUM);case G.DRILLELEMENT:return new _(s+2,o,G.DRILLELEMENT);case G.PARTELEMENT:return new _(s+2,o,G.PARTELEMENT);default:return new _(e,o,G.STANDARD)}}translateSumCellLabel(t,e,o,s,i,n,r){return!1===Number.isNaN(Number(o))||this.isOperationColumn(r)?o:this.isGroupHeadCategory(n,r)||this.isEntryCategory(n,r)?t===h.ALL?`${e.get(o)||o}`:o:this.isDrillElementCategory(n,r)?t===h.ALL?`${e.get(i)||i}`:`${i}`:this.isPartElementCategory(n,r)?t===h.ALL||"SUM_TOTAL"===s?`${e.get(s)||s}`:`${s}`:this.isSumElementCategory(n,r)?t===h.ALL||"SUM_TOTAL"===s?`${e.get(s)||s}`:s:"GROUPHEAD"===n&&null==o?o:Number.isNaN(Number(o))?"-":Number(o)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,e){const o=new a(t);let s="pos";return e<0&&(s="neg"),o.isValid?s+"_"+o.direction+("dr"===o.type?" relative_variance":""):t}setCellType(t,e){if("category"===t)return"";let o;const s=new a(t);return e===u.PERCENT?(o="percent",s.isValid&&"d"===s.type&&(o="decimal")):(o="decimal",s.isValid&&"dr"===s.type&&(o="percent")),o}isDrillElementCategory(t,e){return"DRILLELEMENT"===t&&"category"===e}isPartElementCategory(t,e){return"PARTELEMENT"===t&&"category"===e}isSumElementCategory(t,e){return("GROUP_SUM"===t||"SUM"===t)&&"category"===e}isEntryCategory(t,e){return"ENTRY"===t&&"category"===e}isGroupHeadCategory(t,e){return"GROUPHEAD"===t&&"category"===e}translateCellPrefix(t,e,o){return this.isOperationColumn(o)||this.isGroupHeadCategory(e,o)||this.isEntryCategory(e,o)?null:this.isDrillElementCategory(e,o)?`${t.get("there_of")} `:this.isPartElementCategory(e,o)?`${t.get("part_of")} `:null}createColumnType(t){return t.name===t.group&&t.name===t.type?"base":t.name===t.group?"columnGroup":"columnSubGroup"}}class z{constructor(t,e,o,s){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.ruleSet=t||new l,this.db=e,this.dataSetFactory=new I,this.config=this.initConfig(s),this.i18n=this.initI18n(new Map),this.setSource(o,s.filter),this.state=y.DIRTY}setI18n(t){this.i18n=this.initI18n(t)}initI18n(t){const e=new Map([["",""],["SEPERATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pl3","PL3"],["ac4","AC4"],["pp4","PY4"],["fc4","FC4"],["pl4","PL4"],["in","in"],["category"," "],["operation"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return this.state=y.DIRTY,new Map([...e,...t||new Map])}initConfig(t){this.state=y.DIRTY;const e=t,o=this;return t.scenarios.sort(((t,e)=>o.ruleSet.getScenarioSorIndex(t)-o.ruleSet.getScenarioSorIndex(e))),e}setConfig(t){this.config=this.initConfig(t)}setSource(t,e){var o,s;if(!t)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=v(t,e);try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(s=null===(o=t[0])||void 0===o?void 0:o.cnt)&&void 0!==s?s:0}catch(t){this.rowCount=0}const i=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder);this.headerRows=this.dataSetFactory.createHeader(this.config.type,i,this.i18n,this.config.measureScale,this.config.measureUnit,this.config.showMeasureScale),this.bodyRows=0===this.rowCount?[]:this.dataSetFactory.createBodyRows(this.config,this.i18n,this.db,this.fromExpr),this.state=y.UP_TO_DATE}update(){const t=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder);this.headerRows=this.dataSetFactory.createHeader(this.config.type,t,this.i18n,this.config.measureScale,this.config.measureUnit,this.config.showMeasureScale),this.bodyRows=0!==this.rowCount&&this.fromExpr?this.dataSetFactory.createBodyRows(this.config,this.i18n,this.db,this.fromExpr):[],this.state=y.UP_TO_DATE}getHeader(){return this.state===y.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===y.DIRTY&&this.update(),this.bodyRows}normalizeScenarios(t,e,o){var s;const i=[];for(const n of t){if(null==e?void 0:e.has(n)){const t=e.get(n);for(const e of t){i.push({name:e.name,group:e.name,type:n,order:void 0});for(const t of e.subGroups)i.push({name:t,group:e.name,type:n,order:void 0})}i.push({name:"REST",group:"REST",type:n,order:void 0})}let t;(null===(s=null==o?void 0:o.hierarchy)||void 0===s?void 0:s.at(0))===n&&(t=o.direction),i.push({name:n,group:n,type:n,order:t})}return i}hasNoData(){return 0===this.rowCount}}class j{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=u.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.thereOf=[],this.categoryThereOf=new Map,this.partOf=[],this.sortOrder=new p(new c).default(),this.type=M.LIST,this.limit=0,this.i18n=h.ALL,this.categoryWidth=m.W25,this.measureScale=new w,this.measureUnit="",this.measureType=$.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[]}}class Q{constructor(t,e,o,s,i){this.tableDrillGroupAdapter=t,this.stringAdapter=e,this.orderAdapter=o,this.db=s,this.fromExpr=i}adapt(t){const e=new j;return d.isString(t.title)&&(e.title=t.title),d.isArray(t.scenarios)&&(e.scenarios=f.adaptArray(t.scenarios,this.stringAdapter)),d.isExisting(t.scenariosUnitType)&&(e.scenariosUnitType=t.scenariosUnitType),d.isBoolean(t.grouped)&&(e.grouped=t.grouped),d.isBoolean(t.showGroupTitle)&&(e.showGroupTitle=t.showGroupTitle),d.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),d.isArray(t.thereOf)&&(e.thereOf=f.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),d.isExisting(t.categoryThereOf)&&(e.categoryThereOf=t.categoryThereOf),d.isArray(t.partOf)&&(e.partOf=f.adaptArray(t.partOf,this.tableDrillGroupAdapter)),d.isExisting(t.order)&&(e.sortOrder=this.orderAdapter.adapt(t.order)),d.isExisting(t.type)&&(e.type=t.type),d.isNumber(t.limit)&&(e.limit=t.limit),d.isExisting(t.i18n)&&(e.i18n=t.i18n),d.isExisting(t.categoryWidth)&&(e.categoryWidth=t.categoryWidth),d.isExisting(t.measureScale)&&(e.measureScale=R.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale)),d.isExisting(t.measureType)&&(e.measureType=t.measureType),d.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),d.isString(t.filter)&&(e.filter=t.filter.trim()),d.isArray(t.barColumns)&&(e.barColumns=t.barColumns),e}default(){return new j}}class V{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class q{constructor(){}adapt(t){const e=new V;return d.isString(t.rowGroup)&&(e.rowGroup=t.rowGroup),d.isString(t.category)&&(e.category=t.category),d.isString(t.subCategory)&&(e.subCategory=t.subCategory),d.isString(t.partOf)&&(e.partOf=t.partOf),e}default(){return new V}}const K=e(class extends o{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.tableTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=u.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.thereof=[],this.partof=[],this.order={hierarchy:[],direction:U.ASC},this.categorythereof=new Map,this.type=M.LIST,this.categoryWidth=m.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=h.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=$.VOLUME,this.filter="",this.barColumns=[],this.barColumnMaxWidth=30,this.unitScaling=.01,this.percentageScaling=.5,this.scaleFactor=1,this.componentDataFormatDigits=new b,this.componentStyle=E(this)}render(){return t(s,null,(()=>{if(void 0!==this.table){if(this.table.hasNoData()){const e=this.i18n.get("NO_DATA")||"==No Data==";return t("p",{class:"warning"},e)}return t("table",null,t("thead",null,this.table.getHeader().map((e=>t("tr",{class:e.cssStyle},e.getCells().map((e=>t("th",{colSpan:e.colSpan,class:e.cssStyle},e.getAsHeaderList().map(((o,s,i)=>t("span",null,s===i.length-1?t("span",{class:" "===o?"table-footer":""},o,e.drawPrefix()," "):t("span",null,o,e.drawPrefix(),t("br",null)))))))))))),t("tbody",null,this.table.getBody().map((e=>t("tr",{class:e.cssStyle},null==e?void 0:e.getCells().map((o=>t("td",{colSpan:o.colSpan,class:o.type?`${o.cssStyle} ${o.type}`:o.cssStyle},null!=o.prefix?t("span",{class:o.cssStyle+" "+o.prefixStyle},o.drawPrefix()):"",o.isBarChart&&o.columnStats&&e.type!==G.SUM?t(Y,{value:o.value,scenario:o.key,columnStats:o.columnStats,height:18*this.scaleFactor,isRelative:o.key.startsWith("dr"),isPositiveGood:o.key.endsWith("_pos"),measureScale:o.measureScale,maxBarWidth:this.barColumnMaxWidth,styles:this.barChartStyles}):o.draw(this.componentDataFormatDigits)))))))))}})())}componentWillRender(){this.stores||(this.stores=g(this.element));const t=this.stores.db.db,e=this.prepareConfig(t);this.componentDataFormatDigits=(new S).adapt(this.dataFormatDigits),this.table=new z(new l,t,this.tableName,e),this.table.setI18n(this.i18n),this.barChartStyles=this.prepareBarChartStyles()}prepareConfig(t){const e=this.tableName?this.filter&&this.filter.length>0?`(SELECT * FROM \`${this.tableName}\` WHERE ${this.filter}) AS __src`:`\`${this.tableName}\``:"";return new Q(new q,new c,new p(new c),t,e).adapt({title:this.tableTitle,scenarios:this.scenarios,scenariosUnitType:this.scenariosDataFormat,grouped:this.grouped,showGroupTitle:this.showGroupTitle,thereOf:this.thereof,partOf:this.partof,categoryThereOf:this.categorythereof,order:this.order,type:this.type,limit:this.limit,i18n:this.i18nMode,categoryWidth:this.categoryWidth,measureScale:this.measureScale,measureUnit:this.measureUnit,measureType:this.measureType,showMeasureScale:this.showMeasureScale,filter:this.filter,barColumns:this.barColumns})}prepareBarChartStyles(){return this.componentStyle((t=>{var e,o,s,i,n,r,a,l,c,h,u,d,f,p,m,$,v,g,R,w,b,S,E,O,y,M;const U=null===(e=t["bn-chart-time"])||void 0===e?void 0:e.varianceStyles,G=null===(o=t["bn-chart-time"])||void 0===o?void 0:o.barStyles;return{positive:{stroke:(null===(s=null==U?void 0:U.pos)||void 0===s?void 0:s.stroke)||"#008f96",fill:(null===(i=null==U?void 0:U.pos)||void 0===i?void 0:i.fill)||"#008f96",fillpattern:(null===(n=null==U?void 0:U.pos)||void 0===n?void 0:n.fillpattern)||"solid"},negative:{stroke:(null===(r=null==U?void 0:U.neg)||void 0===r?void 0:r.stroke)||"#ff0000",fill:(null===(a=null==U?void 0:U.neg)||void 0===a?void 0:a.fill)||"#ff0000",fillpattern:(null===(l=null==U?void 0:U.neg)||void 0===l?void 0:l.fillpattern)||"solid"},neutral:{stroke:(null===(c=null==U?void 0:U.neu)||void 0===c?void 0:c.stroke)||"#808080",fill:(null===(h=null==U?void 0:U.neu)||void 0===h?void 0:h.fill)||"#808080",fillpattern:(null===(u=null==U?void 0:U.neu)||void 0===u?void 0:u.fillpattern)||"outlined"},scenarios:{ac:{stroke:(null===(d=null==G?void 0:G.ac)||void 0===d?void 0:d.stroke)||"#404040",fill:(null===(f=null==G?void 0:G.ac)||void 0===f?void 0:f.fill)||"#404040",fillpattern:(null===(p=null==G?void 0:G.ac)||void 0===p?void 0:p.fillpattern)||"solid"},pp:{stroke:(null===(m=null==G?void 0:G.pp)||void 0===m?void 0:m.stroke)||"#A6A6A6",fill:(null===($=null==G?void 0:G.pp)||void 0===$?void 0:$.fill)||"#A6A6A6",fillpattern:(null===(v=null==G?void 0:G.pp)||void 0===v?void 0:v.fillpattern)||"solid"},fc:{stroke:(null===(g=null==G?void 0:G.fc)||void 0===g?void 0:g.stroke)||"#404040",fill:(null===(R=null==G?void 0:G.fc)||void 0===R?void 0:R.fill)||"#ffffff",fillpattern:(null===(w=null==G?void 0:G.fc)||void 0===w?void 0:w.fillpattern)||"hatched"},pl:{stroke:(null===(b=null==G?void 0:G.pl)||void 0===b?void 0:b.stroke)||"#404040",fill:(null===(S=null==G?void 0:G.pl)||void 0===S?void 0:S.fill)||"#ffffff",fillpattern:(null===(E=null==G?void 0:G.pl)||void 0===E?void 0:E.fillpattern)||"outlined"}},fontColor:(null===(O=t.global)||void 0===O?void 0:O.fontColor)||"#000000",fontSize:.85*((null===(y=t.global)||void 0===y?void 0:y.fontSizePx)||13.3333)*this.scaleFactor,fontFamily:(null===(M=t.global)||void 0===M?void 0:M.fontFamily)||"'Noto Sans', sans-serif",unitScaling:this.unitScaling>0?this.unitScaling:this.autoUnitScaling(),percentageScaling:this.percentageScaling>0?this.percentageScaling:this.autoPercentageScaling(),scaleFactor:this.scaleFactor}}))}autoUnitScaling(){const t=this.componentStyle((t=>{var e;return.85*((null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333)*this.scaleFactor})),e=this.barColumnMaxWidth*t*.8,o=this.getMaxAbsValue();return o<=0||t<=0?.01:e/(o*t)}autoPercentageScaling(){const t=this.componentStyle((t=>{var e;return.85*((null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333)*this.scaleFactor})),e=.8*Math.round(.67*this.barColumnMaxWidth*t),o=this.getMaxRelativeValue();return o<=0||t<=0?.5:e/(o*t)}getMaxAbsValue(){if(!this.table)return 0;let t=0;for(const e of this.table.getBody())if(e.type!==G.SUM)for(const o of e.getCells())o.isBarChart&&o.columnStats&&!o.key.startsWith("dr")&&(t=Math.max(t,o.columnStats.absMax));return t}getMaxRelativeValue(){if(!this.table)return 0;let t=0;for(const e of this.table.getBody())if(e.type!==G.SUM)for(const o of e.getCells())o.isBarChart&&o.columnStats&&o.key.startsWith("dr")&&(t=Math.max(t,100*o.columnStats.absMax));return t}get element(){return this}static get style(){return':host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}'}},[1,"ibcs-table",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],tableTitle:[1,"table-title"],scenarios:[16],scenariosDataFormat:[1,"scenarios-data-format"],grouped:[4],limit:[2],showGroupTitle:[4,"show-group-title"],thereof:[16],partof:[16],order:[16],categorythereof:[16],type:[1],categoryWidth:[1,"category-width"],dataFormatDigits:[16],i18n:[1040],i18nMode:[1,"i18n-mode"],measureScale:[1,"measure-scale"],measureUnit:[1,"measure-unit"],showMeasureScale:[4,"show-measure-scale"],measureType:[1,"measure-type"],filter:[1],barColumns:[16],barColumnMaxWidth:[2,"bar-column-max-width"],unitScaling:[2,"unit-scaling"],percentageScaling:[2,"percentage-scaling"],scaleFactor:[2,"scale-factor"]}]);function J(){"undefined"!=typeof customElements&&["ibcs-table"].forEach((t=>{"ibcs-table"===t&&(customElements.get(i(t))||customElements.define(i(t),K))}))}export{K as I,M as T,J as d}
1
+ import{h as t,proxyCustomElement as e,HTMLElement as s,Host as o,transformTag as i}from"@stencil/core/internal/client";import{F as n,Q as r,V as a,I as l,S as c}from"./ibcsRuleSet.js";import{I as h,D as u,i as d,j as f,k as p,e as $,M as m}from"./Order.js";import{d as v,g}from"./context-protocol.js";import{D as R,S as w,a as b,b as S}from"./DataFormatDigits.js";import{w as E}from"./withComponentStyle.js";var O,y,M,U,G;!function(t){t[t.ALL=-1]="ALL"}(O||(O={})),function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(y||(y={})),function(t){t.LIST="list",t.SUM="sum",t.SUMNOTOTAL="sumnototal",t.OPT="opt",t.OPTNOTOTAL="optnototal"}(M||(M={})),function(t){t.ASC="asc",t.DESC="desc"}(U||(U={})),function(t){t.HEADER="HEADER",t.GROUPHEAD="GROUPHEAD",t.SEPERATORLINE="SEPERATORLINE",t.SUM="SUM",t.GROUPSUM="GROUP_SUM",t.DRILLELEMENT="DRILLELEMENT",t.STANDARD="STANDARD",t.PARTELEMENT="PARTELEMENT",t.ENTRY="ENTRY"}(G||(G={}));class T{constructor(t,e,s,o,i,n,r,a,l){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=e,this.value=s,this.prefix=n||"",this.cssStyle=o||"",this.prefixStyle=r||"prefix",this.type=i,this.mark=void 0,this.colSpan=a||1,this.measureScale=l||1}getAsHeaderList(){if(null==this.value)return[""];const t=[];for(const e of this.value.toString().split("<br/>"))t.push(e);return t}draw(t){let e=this.value;if("undefined"===e||void 0===e||null==e)return"";if(Number.isNaN(Number(e)))return e;if(""===this.type||void 0===this.type||null==this.type)return e;let s=t.percent,o=t.percent;return"decimal"===this.type&&(e=+e/this.measureScale,s=t.decimal,o=t.decimal),n.number(Number(e),this.type,s,o)}drawPrefix(){return null==this.prefix?"":this.prefix}}class _{constructor(t,e,s){this.index=t,this.groupindex=e,this.type=s,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case G.HEADER:return"groupheader";case G.SEPERATORLINE:return"";case G.DRILLELEMENT:return"ofit";case G.PARTELEMENT:return"partof";case G.STANDARD:return"";case G.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,e,s,o,i,n,r,a,l,c=!1,h){let u=n;"category"===e&&null!=a&&(u=`category-${a.toString()}`),this.type===G.HEADER?u="headerlabel":this.type===G.SEPERATORLINE&&(u=e),this.type===G.PARTELEMENT&&("percent"===o&&(t="-"),"category"!==e&&"operation"!==e&&(o="percent",u="")),"-"===t&&(u="");let d="prefix-first";r&&(d="prefix-second"),s&&(u=`${u} ${s}`);const f=new T(e,this.elements.length,t,u,o,i,d,1,l);f.isBarChart=c,f.columnStats=h,this.elements.push(f)}}const N={positive:{stroke:"#008f96",fill:"#008f96",fillpattern:"solid"},negative:{stroke:"#ff0000",fill:"#ff0000",fillpattern:"solid"},neutral:{stroke:"#808080",fill:"#808080",fillpattern:"outlined"},scenarios:{ac:{stroke:"#404040",fill:"#404040",fillpattern:"solid"},pp:{stroke:"#A6A6A6",fill:"#A6A6A6",fillpattern:"solid"},fc:{stroke:"#404040",fill:"#ffffff",fillpattern:"hatched"},pl:{stroke:"#404040",fill:"#ffffff",fillpattern:"outlined"}},fontColor:"#000000",fontSize:11,fontFamily:"'Noto Sans', sans-serif",unitScaling:.01,percentageScaling:.5,scaleFactor:1},L="#666666";function C(t,e){return`pattern-${t}-${e.replace("#","")}`}const P=({styles:e})=>{const s=e.scaleFactor,o=6*s,i=[{id:C("pos",e.positive.stroke),stroke:e.positive.stroke,fill:e.positive.fill},{id:C("neg",e.negative.stroke),stroke:e.negative.stroke,fill:e.negative.fill},{id:C("neu",e.neutral.stroke),stroke:e.neutral.stroke,fill:e.neutral.fill}];return t("defs",null,i.map((e=>t("pattern",{id:e.id,patternUnits:"userSpaceOnUse",width:o,height:o},t("rect",{width:o,height:o,fill:"#ffffff"}),t("line",{x1:"0",y1:o,x2:o,y2:"0",stroke:e.stroke,"stroke-width":1.5*s})))))};function x(t,e,s=1){let o,i;const n=t>=0?"+":"";if(e)return o=100*t,n+Math.round(o).toString()+"%";{let e;return o=t/s,i=Math.abs(o),e=i>=1e9?(o/1e9).toFixed(i>=1e10?0:1)+"B":i>=1e6?(o/1e6).toFixed(i>=1e7?0:1)+"M":i>=1e3?(o/1e3).toFixed(i>=1e4?0:1)+"K":o.toFixed(i>=10?0:1),e=e.replace(/\.0([KMB]?)$/,"$1"),n+e}}function A(t){const e=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(e)}function k(t){const e=t.slice(0,2).toLowerCase();return"pp"===e?"pp":"fc"===e?"fc":"pl"===e?"pl":"ac"}function D(t,e,s,o){return A(t)?function(t,e){const s=k(t);return e.scenarios[s]}(t,o):function(t,e,s){const o=t>=0;return e?o?s.positive:s.negative:o?s.negative:s.positive}(e,s,o)}const B=e=>{const{value:s,scenario:o,columnStats:i,height:n,isPositiveGood:r,formattedValue:a,measureScale:l,maxBarWidth:c=10,styles:h=N}=e,u=h.scaleFactor,d=h.fontSize,f=38*u,p=c*d,$=4*u,m=.15*p,v=p-$-m,g=Math.abs(s)*h.unitScaling*d,R=g>v,w=Math.max(0,i.absMax*h.unitScaling*d-v),b=Math.max(0,g-v),S=w>0?b/w*m:0,E=i.min<0,O=i.max>0,y=E?p:0,M=(E?f:0)+(y+(O?p:0))+(O?f:0),U=2*u,G=n-2*U,T=(E?f:0)+y,_=U,B=s>=0,F=D(o,s,r,h),Y=function(t,e){const s=t.fillpattern;return"hatched"===s?`url(#${C(e,t.stroke)})`:"outlined"===s?"transparent":t.fill}(F,A(o)?k(o):r?B?"pos":"neg":B?"neg":"pos"),{stroke:W,strokeWidth:H}="outlined"===(I=F).fillpattern?{stroke:I.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0};var I;const z=a||x(s,!1,l),j=R?v:g,V=R?v+$+S:g,Q=B?T+V+4*u:T-V-4*u,q=B?"start":"end";return t("svg",{width:M,height:n,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},t(P,{styles:h}),t("line",{x1:T,y1:0,x2:T,y2:n,stroke:L,"stroke-width":1*u}),j>0&&t("rect",{x:B?T:T-j,y:_,width:j,height:G,fill:Y,stroke:W,"stroke-width":H*u}),R&&S>0&&t("rect",{x:B?T+v+$:T-v-$-S,y:_,width:S,height:G,fill:Y,stroke:W,"stroke-width":H*u}),R&&function(e,s,o,i,n){const r=e+s/2,a=.35*s,l=i/3,c=.3*s;let h=`M ${r-a} ${o}`;for(let t=0;t<3;t++)h+=` L ${r-a-c} ${o+l*(t+.5)} L ${r-a} ${o+l*(t+1)}`;let u=`M ${r+a} ${o}`;for(let t=0;t<3;t++)u+=` L ${r+a+c} ${o+l*(t+.5)} L ${r+a} ${o+l*(t+1)}`;return[t("rect",{x:e,y:o-1,width:s,height:i+2,fill:"#ffffff"}),t("path",{d:h,fill:"none",stroke:"#000000","stroke-width":1*n}),t("path",{d:u,fill:"none",stroke:"#000000","stroke-width":1*n})]}(B?T+v:T-v-$,$,_,G,u),t("text",{x:Q,y:n/2,dy:"0.35em","text-anchor":q,fill:h.fontColor,"font-size":d,"font-family":h.fontFamily},z))},F=e=>{const{value:s,scenario:o,columnStats:i,height:n,isPositiveGood:r,formattedValue:a,measureScale:l,maxBarWidth:c=10,styles:h=N}=e,u=h.scaleFactor,d=h.fontSize,f=Math.round(.67*c*d),p=5*u,$=i.min<0?f+p:0,m=$+(i.max>0?f+p:0),v=m+45*u,g=$,R=n/2,w=100*Math.abs(s)*h.percentageScaling*d,b=w>f,S=Math.min(w,f),E=s>=0,O=E?g+S:g-S,y=D(o,s,r,h),M=3*u,U=a||x(s,!0,l),G=m+4*u;return t("svg",{width:v,height:n,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},t("line",{x1:g,y1:0,x2:g,y2:n,stroke:L,"stroke-width":1*u}),!b&&t("circle",{cx:O,cy:R,r:M,fill:h.fontColor}),t("line",{x1:g,y1:R,x2:O,y2:R,stroke:y.fill,"stroke-width":2*u}),b&&E&&t("polygon",{points:`${g+f},${R} ${g+f-6*u},${R-3*u} ${g+f-6*u},${R+3*u}`,fill:y.fill}),b&&!E&&t("polygon",{points:`${g-f},${R} ${g-f+6*u},${R-3*u} ${g-f+6*u},${R+3*u}`,fill:y.fill}),t("text",{x:G,y:n/2,dy:"0.35em","text-anchor":"start",fill:h.fontColor,"font-size":d,"font-style":"italic","font-family":h.fontFamily},U))},Y=e=>{const{value:s,columnStats:o,isRelative:i,styles:n=N}=e;return null==s||isNaN(s)||!o||0===o.absMax?t("span",{class:"bar-chart-empty",style:{color:n.fontColor,fontStyle:"italic"}},"-"):t(i?F:B,Object.assign({},e))};class W{constructor(t){this.groups=[r.CATEGORY,r.CATEGORYINDEX],M.OPT!==t.type&&M.OPTNOTOTAL!==t.type||this.groups.unshift(r.OPERATION),t.grouped&&(this.groups.push(r.ROWGROUP),this.groups.push(r.ROWGROUPINDEX))}toString(){return this.groups.map((t=>`${t}`)).toString()}noCategory(){return this.groups.filter((t=>t!==r.CATEGORY))}toArray(){return this.groups}}class H{constructor(t,e){this.hasPartOf=!1,this.config=t,this.i18n=e}execute(t,e){var s;this.db=t,this.fromExpr=e;const o=[],i=[],n=[],a=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),l=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),c=this.getRelativeScenarios(),h=this.config.attributes.map((t=>this.translateAttributeSQL(t))).toString(),u=new W(this.config),d=this.config.grouped?[r.ROWGROUP,r.ROWGROUPINDEX]:[];let f,p=["",""];this.config.sortOrder.hierarchy.length>0&&(p=this.createOrderString(this.config.sortOrder)),this.hasPartOf=this.checkConfigForPartOf();try{f=t.exec(`SELECT COUNT(DISTINCT ${r.CATEGORY}) as ${r.TOTALROWCOUNT} ${d.length>0?","+d:""}\n FROM ${e} ${d.length>0?"GROUP BY "+d:""}\n ORDER BY ${p[0]}`)}catch(t){return console.error("DataQuery: meta query failed",t),[]}return 0===f.length||1===f.length&&0===(null!==(s=f[0][r.TOTALROWCOUNT])&&void 0!==s?s:0)&&0===d.length?[]:(f.forEach((t=>{const e=t.rowGroup&&t.rowGroup.length>0?`WHERE ${r.ROWGROUP} = '${t.rowGroup}'`:"";let s="";this.config.limit&&(s=`LIMIT ${this.config.limit}`),this.createGroupHeaderRow(t,o),this.createDataRow(o,t,u,a,h,e,p,s),this.createRestRow(t,o,u,a,e,p),this.createGroupSumRow(o,i,t,l,p)})),this.createTotalSumRow(o,i,l),o.forEach((e=>{try{n.push(t.exec(e))}catch(t){console.error("DataQuery: SQL query execution failed",e,t)}})),this.detectNaNCells(this.config.scenarios,n),this.createThereOfDrillRows(a,h,p,n),this.createPartOfDrillRows(a,p,i,n),this.createThereOfDrillColumns(this.config.categoryThereOf,n),this.calculateColumnGroupRest(n,this.config.categoryThereOf),this.calculateRelativeVariances(n,c),n)}detectNaNCells(t,e){e.forEach((e=>{e.map((e=>(t.forEach((t=>{const s=new a(t);!0===s.isValid?0!==e[s.base+"_cnt"]&&0!==e[s.delta+"_cnt"]||(e[t]=Number.NaN):0===e[t+"_cnt"]&&(e[t]=Number.NaN)})),e)))}))}createPartOfDrillRows(t,e,s,o){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===M.LIST)return;const i=this.createPartOfQuery(t,e);let n=[];const a=this.db;i.forEach((function(t){n.push(...a.exec(t))}));const l=this.exctractScenarioNames(t),c=[];s.forEach((function(t){c.push(...a.exec(t))}));const h=new Map;c.forEach((t=>h.set(t[r.ROWGROUP],t))),n=this.reduceResDrillByCategoryGroups(n,l),n.forEach((function(t){l.forEach((e=>{try{t[e]=t[e]/h.get(t[r.ROWGROUP])[e]}catch(s){console.error("DataQuery: partOf drill row calculation failed",e,s),t[e]=Number.NaN}}))})),this.injectDrillRowsToResultRows(n,o)}createRestRow(t,e,s,o,i,n){t.totalRowCnt-this.config.limit>0&&0!==this.config.limit&&e.push(`SELECT ${r.ROWNR}, 1 as ${r.ROWGROUPINDEX} , 'ENTRY' as ${r.TYPE}, 'NO_GROUP' as ${r.ROWGROUP}, 'REST' as ${r.CATEGORY} , SUM(ac1) as ac1, SUM(pp1) as pp1, SUM(dpp1_ac1_pos) as dpp1_ac1_pos, SUM(drpp1_ac1_pos) as drpp1_ac1_pos, SUM(dr_pp1) as dr_pp1 FROM (SELECT ROWNUM() AS ${r.ROWNR}, ${e.length} as ${r.ROWGROUPINDEX} , 'ENTRY' as ${r.TYPE}, '${t.rowGroup||"NO_GROUP"}' as ${r.ROWGROUP}, ${s} ${o.length>0?",".concat(o):""} FROM ${this.fromExpr} ${i} GROUP BY ${s} ORDER BY ${n[0]}) t WHERE t.rowNr > ${this.config.limit}`)}createDataRow(t,e,s,o,i,n,a,l){t.push(`SELECT ROWNUM() AS ${r.ROWNR},\n ${t.length} as ${r.ROWGROUPINDEX},\n 'ENTRY' as ${r.TYPE},\n '${e.rowGroup||"NO_GROUP"}' as ${r.ROWGROUP},\n '${r.CATEGORYINDEX}',\n ${s} ${o.length>0?",".concat(o):""} ${i.length>0?",".concat(i):""}\n FROM ${this.fromExpr} ${n}\n GROUP BY ${s}\n ORDER BY ${a[0]} ${l}`)}createGroupHeaderRow(t,e){!0===this.config.grouped&&e.push(`SELECT ROWNUM() AS ${r.ROWNR},\n ${e.length} as ${r.ROWGROUPINDEX},\n 'GROUPHEAD' as ${r.TYPE},\n '${t.rowGroup}' as ${r.ROWGROUP} ${this.config.showGroupTitle?`,'${t.rowGroup}' as ${r.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}createGroupSumRow(t,e,s,o,i){!0!==this.config.grouped||M.SUM!==this.config.type&&M.SUMNOTOTAL!==this.config.type&&M.OPT!==this.config.type&&M.OPTNOTOTAL!==this.config.type||(t.push(`SELECT ${t.length} as ${r.ROWGROUPINDEX},\n '=' as ${r.OPERATION},\n '${s.rowGroup}' as ${r.ROWGROUP},\n ROWNUM() AS ${r.ROWNR},\n 'GROUP_SUM' as ${r.TYPE} ${o.length>0?",".concat(o):""}\n FROM ${this.fromExpr}\n WHERE ${r.ROWGROUP} = '${s.rowGroup}'\n ORDER BY ${i[0]} `),e.push(`SELECT ${t.length} as ${r.ROWGROUPINDEX},\n '=' as ${r.OPERATION},\n '${s.rowGroup}' as ${r.ROWGROUP},\n ROWNUM() AS ${r.ROWNR},\n 'GROUP_SUM' as ${r.TYPE} ${o.length>0?",".concat(o):""}\n FROM ${this.fromExpr}\n WHERE ${r.ROWGROUP} = '${s.rowGroup}'\n ORDER BY ${i[0]} `))}createTotalSumRow(t,e,s){if(M.SUM===this.config.type||M.OPT===this.config.type){const e=`${this.hasPartOf&&!1===this.config.grouped?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} `:""}${this.config.title}`;t.push(`SELECT ${t.length} as ${r.ROWGROUPINDEX},\n '${e}' as ${r.ROWGROUP},\n '=' as ${r.OPERATION},\n 'SUM' as ${r.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}e.push(`SELECT ${t.length} as ${r.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${r.ROWGROUP},\n '=' as ${r.OPERATION},\n 'SUM' as ${r.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}reduceResDrillByCategoryGroups(t,e){const s=new Map;return t.forEach((function(t){const o=t.rowNr+t.rowGroup+t.type+t.category;if(s.has(o)){const i=s.get(o);e.forEach((e=>{try{i[e]+=t[e]}catch(t){console.error("DataQuery: drill row aggregation failed",e,t)}}))}else s.set(o,t)})),[...s.values()]}injectDrillRowsToResultRows(t,e){const s=new Map;if(!0===this.config.grouped)t.forEach((function(t){e.forEach((function(e){const o=e.findIndex((e=>e.category===t.category&&e.rowGroup===t.rowGroup));if(o>=0){if(s.has(`${t.category}_${t.rowGroup}`)){const e=s.get(`${t.category}_${t.rowGroup}`)||0;s.set(`${t.category}_${t.rowGroup}`,e+1)}else s.set(`${t.category}_${t.rowGroup}`,1);t[r.ROWNR]=s.get(`${t.category}_${t.rowGroup}`),e.splice(o+t[r.ROWNR],0,t)}}))}));else{const o=this.findDuplicateSubCategories(t);t.forEach((function(t){e.forEach((function(e){const i=e.findIndex((e=>null!=e.category&&e.category===t.category));if(i>=0){if(s.has(`${t.category}`)){const e=s.get(`${t.category}`)||0;s.set(`${t.category}`,e+1)}else s.set(`${t.category}`,1);(1===t[r.ROWNR]||o.includes(t.subCategory))&&(t.subCategory=`${t.subCategory} (${t.rowGroup})`),e.splice(i+t[r.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,e,s,o){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const i=[],n=[];this.config.thereOf.forEach((o=>{let n=!0,a="1 <> 1 OR ( ";null!=o.category&&0!==o.category.length&&o.category.trim()&&(a+=` ${r.CATEGORY} = '${o.category}'`,n=!1),null!=o.rowGroup&&0!==o.rowGroup.length&&o.rowGroup.trim()&&(a+=` ${n?"":"AND"} ${r.ROWGROUP} = '${o.rowGroup}'`,n=!1),null!=o.subCategory&&0!==o.subCategory.length&&o.subCategory.trim()&&(a+=` ${n?"":"AND"} ${r.SUBCATEGORY} = '${o.subCategory}'`),a+=")",i.push(`SELECT ROWNUM() AS ${r.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${r.TYPE},\n ${r.CATEGORY},\n ${r.SUBCATEGORY},\n ${r.ROWGROUP} as ${r.ROWGROUP},\n ${t} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr}\n WHERE ${a}\n GROUP BY ${r.ROWGROUP}, ${r.CATEGORY}, ${r.SUBCATEGORY}\n ORDER BY ${s[1]}`)}));const a=this.db;i.forEach((function(t){n.push(...a.exec(t))})),this.injectDrillRowsToResultRows(n,o)}calculateRelativeVariances(t,e){t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[r.TYPE]&&e.forEach(((e,s)=>{t[s]=t[s]/t[e]}))}))}))}calculateColumnGroupRest(t,e){if(null==e||0===e.size)return;const s=new Map,o=new Map;e.forEach(((t,e)=>{const i=t,n=[];for(const t of i)n.push(`${e}##${t.name}`);s.set(e,n),o.set(`${e}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[r.TYPE]&&s.forEach(((e,s)=>{let i=0;e.forEach((e=>{void 0!==t[e]&&(i+=t[e])})),t[`${s}##REST`]=t[s]-i,0!==t[`${s}##REST`]&&o.set(`${s}##REST`,!0)}))}))}));const i=Array.from(o.entries()).filter((([t,e])=>!e)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const e of i)delete t[e]}))}))}getRelativeScenarios(){const t=new Map;return this.config.scenarios.forEach((e=>{const s=this.createRelativeScenario(e);null!=s&&t.set(s.key,s.value)})),t}translateScenarioSQL(t,e,s){const o=new a(t);return M.OPT===s||M.OPTNOTOTAL===s?o.isValid?"dr"===o.type?`SUM(${o.base} - ${o.delta}) as ${t}, SUM(${o.delta}) as dr_${o.delta}`:`SUM(${o.base} - ${o.delta}) as ${t}`:e?`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:`SUM(${t}) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:o.isValid?"dr"===o.type?`SUM((${o.base} * transformOperator(operation)) - (${o.delta} * transformOperator(operation))) as ${t}, SUM(${o.delta} * transformOperator(operation)) as dr_${o.delta}`:`SUM((${o.base} * transformOperator(operation))- (${o.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}translateAttributeSQL(t){const e=`[${t.arg}]`,s=/^(ac|pp|fc|pl)[1-4]$/.test(t.arg)&&this.config.type!==M.OPT&&this.config.type!==M.OPTNOTOTAL;switch(t.fn){case"set":return`SETAGG(${e}) as ${t.alias}`;case"first":return`FIRST(${e}) as ${t.alias}`;case"last":return`LAST(${e}) as ${t.alias}`;case"min":return`MIN(${e}) as ${t.alias}`;case"max":return`MAX(${e}) as ${t.alias}`;case"avg":return s?`AVG(${e} * transformOperator(operation)) as ${t.alias}`:`AVG(${e}) as ${t.alias}`;case"sum":return s?`SUM(${e} * transformOperator(operation)) as ${t.alias}`:`SUM(${e}) as ${t.alias}`;case"lit":return`${this.sqlLiteral(t.arg)} as ${t.alias}`}}sqlLiteral(t){return""===t||Number.isNaN(Number(t))?`'${t.replace(/'/g,"''")}'`:t}createOrderString(t){return[`${t.hierarchy.toString()} ${t.direction}`,`${t.hierarchy.toString()} ${U.ASC===t.direction?U.DESC:U.ASC}`]}createRelativeScenario(t){const e=new a(t);return e.isValid&&"dr"===e.type?{key:`${t}`,value:`dr_${e.delta}`}:null}exctractScenarioNames(t){const e=[];return t.split(",").forEach((t=>t.length>=2?e.push(t.split("as")[1].trim()):null)),e}findDuplicateSubCategories(t){const e=t.map((t=>({count:1,subCategory:t.subCategory}))).reduce(((t,e)=>(t[e.subCategory]=(t[e.subCategory]||0)+e.count,t)),{});return Object.keys(e).filter((t=>e[t]>1))}createPartOfQuery(t,e){var s;const o=[];let i="1 <> 1 ",n=` ${r.ROWGROUP}`,a="ROWNUM()";return null===(s=this.config.partOf)||void 0===s||s.forEach((t=>{i+=`OR (${r.CATEGORY} = '${t.category}'`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=`and ${r.ROWGROUP} = '${t.rowGroup}'`),!1===this.config.grouped&&(n=` 'SUM_TOTAL' as ${r.ROWGROUP} `,a="1"),i+=")"})),o.push(`SELECT ${a} AS ${r.ROWNR},\n 'PARTELEMENT' as ${r.TYPE},\n ${r.CATEGORY},\n ${n},\n ${t}\n FROM ${this.fromExpr}\n WHERE ${i}\n GROUP BY ${r.ROWGROUP}, ${r.CATEGORY}, ${r.TYPE}\n ORDER BY ${e[1]}`),o}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,e){if(null==t||0===t.size)return;const s=[],o=[],i=this.fromExpr;t.forEach(((t,e)=>{let o="1 <> 1 ";t.forEach((t=>{o+=` or columnGroup = '${t.name}' `})),s.push(`SELECT 'ENTRY' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${o}\n GROUP BY rowlevel, rowGroup, category, columnGroup, scenario`),s.push(`SELECT 'ENTRY' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${o}\n GROUP BY rowlevel, rowGroup, category, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${o}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${o}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${o}\n GROUP BY rowlevel, rowGroup, columnGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${o}\n GROUP BY rowlevel, rowGroup, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${o}\n GROUP BY rowlevel, columnGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${o}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of s)o.push(...this.db.exec(t));this.injectDrillColumnsToResultRows(o,e)}injectDrillColumnsToResultRows(t,e){const s="##";for(const o of t)for(const t of e)for(const e of t)e.type===o.rowlevel&&("ENTRY"===o.rowlevel?"COLUMNGROUP"===o.columnlevel&&e.category===o.category?e[o.scenario+s+o.columnGroup]=o.val:"SUBGROUP"===o.columnlevel&&e.category===o.category&&(e[o.scenario+s+o.columnGroup+s+o.columnSubGroup]=o.val):"DRILLELEMENT"===o.rowlevel?"COLUMNGROUP"===o.columnlevel&&e.category===o.category&&e.subCategory===o.subCategory?e[o.scenario+s+o.columnGroup]=o.val:"SUBGROUP"===o.columnlevel&&e.category===o.category&&e.subCategory===o.subCategory?e[o.scenario+s+o.columnGroup+s+o.columnSubGroup]=o.val:"COLUMNGROUP"===o.columnlevel&&e.category===o.category&&e.subCategory===`${o.subCategory} (${o.rowGroup})`?e[o.scenario+s+o.columnGroup]=o.val:"SUBGROUP"===o.columnlevel&&e.category===o.category&&e.subCategory===`${o.subCategory} (${o.rowGroup})`&&(e[o.scenario+s+o.columnGroup+s+o.columnSubGroup]=o.val):("SUM"===o.rowlevel||"GROUP_SUM"===o.rowlevel)&&("COLUMNGROUP"===o.columnlevel&&e.category===o.category&&e.subCategory===o.subCategory&&(e[o.scenario+s+o.columnGroup]=o.val),"SUBGROUP"===o.columnlevel&&e.category===o.category&&e.subCategory===o.subCategory&&(e[o.scenario+s+o.columnGroup+s+o.columnSubGroup]=o.val)))}}class I{constructor(){this.normalizedHeader=[],this.attributesByAlias=new Map}createHeader(t,e,s,o,i,r,a=[]){const l=[];this.attributesByAlias=new Map(a.map((t=>[t.alias,t]))),this.normalizedHeader=this.normalizeHeader(t,e,a);const c=new _(0,0,G.HEADER),h=new _(1,0,G.SEPERATORLINE);for(const t of this.normalizedHeader){const e=this.attributesByAlias.get(t.name);c.createElement(e?s.get(e.label)||e.label:n.translateScenarioLabel(t.name,s),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,s,o,i,r),null,null,null,null),h.createElement(null,t.type,this.createColumnType(t),null,null,null,null,null,null)}return l.push(c),l.push(h),l}setHeaderPrefix(t,e,s,o,i){let r="";return"category"===t.name&&i&&(0===s.prefix.length&&0===o.length||(r=n.translateScenarioLabel("in",e)+" "+s.prefix+o)),t.order&&(r+=n.translateScenarioLabel("ORDER_"+t.order,e)),r}normalizeHeader(t,e,s){let o=[{name:r.CATEGORY,group:r.CATEGORY,type:r.CATEGORY,order:void 0}];M.OPT!==t&&M.OPTNOTOTAL!==t||(o=[{name:r.OPERATION,group:r.OPERATION,type:r.OPERATION,order:void 0},{name:r.CATEGORY,group:r.CATEGORY,type:r.CATEGORY,order:void 0}]);const i=s.map((t=>({name:t.alias,group:t.alias,type:t.alias,order:void 0})));return[...o,...i,...e]}createBodyRows(t,e,s,o){const i=[];let n=-1;const r=new H(t,e).execute(s,o),a=this.calculateColumnStatistics(r,t.barColumns);for(const s of r)n+=1,i.push(...this.createRow(t.i18n,e,t.scenariosUnitType,s,n,-1,t.categoryWidth,t.measureScale,t.barColumns,a));return i}calculateColumnStatistics(t,e){const s=new Map;if(!e||0===e.length)return s;const o=new Map;for(const t of e)s.set(t,{min:1/0,max:-1/0,absMax:0,median:0}),o.set(t,[]);for(const i of t)for(const t of i)for(const i of e){const e=this.extractColumnValue(t,i);if(null!==e&&!isNaN(e)){const t=s.get(i);t.min=Math.min(t.min,e),t.max=Math.max(t.max,e),o.get(i).push(Math.abs(e))}}for(const[t,e]of s){e.min!==1/0&&e.max!==-1/0||(e.min=0,e.max=0),e.absMax=Math.max(Math.abs(e.min),Math.abs(e.max));const i=o.get(t);if(i.length>0){i.sort(((t,e)=>t-e));const t=Math.floor(i.length/2);e.median=i.length%2==0?(i[t-1]+i[t])/2:i[t]}s.set(t,e)}return s}extractColumnValue(t,e){if(void 0!==t[e]){const s=Number(t[e]);return isNaN(s)?null:s}for(const s of Object.keys(t))if(s===e||s.endsWith("##"+e)||s===e+"##"+e){const e=Number(t[s]);if(!isNaN(e))return e}return null}createRow(t,e,s,o,i,n,a,l,c,h){var u;const d=[];for(const f of o){const p=f[r.ROWGROUP],$=f[r.SUBCATEGORY],m=f[r.TYPE],v=f[r.ROWNR]>=2,g=this.createDetailRow(m,n+=1,i,o.length);for(const o of this.normalizedHeader){const i=this.getRawDataRowElement(f,o),n=null!==(u=null==c?void 0:c.includes(o.type))&&void 0!==u&&u,r=n?null==h?void 0:h.get(o.type):void 0;g.createElement(this.translateSumCellLabel(t,e,i,p,$,m,o.type),o.type,this.createColumnType(o),this.setCellType(o.type,s),this.translateCellPrefix(e,m,o.type),this.translateScenarioCSS(o.type,i),v,a,null==l?void 0:l.value,n,r)}d.push(g)}return d}getRawDataRowElement(t,e){return e.name===e.group&&e.name===e.type?t[e.name]:e.name===e.group&&e.name!==e.type?t[e.type+"##"+e.name]:t[e.type+"##"+e.group+"##"+e.name]}createDetailRow(t,e,s,o){switch(t){case G.GROUPHEAD:return new _(e,s,G.HEADER);case G.SUM:case G.GROUPSUM:return new _(o+2,s,G.SUM);case G.DRILLELEMENT:return new _(o+2,s,G.DRILLELEMENT);case G.PARTELEMENT:return new _(o+2,s,G.PARTELEMENT);default:return new _(e,s,G.STANDARD)}}translateSumCellLabel(t,e,s,o,i,n,r){return this.attributesByAlias.has(r)||!1===Number.isNaN(Number(s))||this.isOperationColumn(r)?s:this.isGroupHeadCategory(n,r)||this.isEntryCategory(n,r)?t===h.ALL?`${e.get(s)||s}`:s:this.isDrillElementCategory(n,r)?t===h.ALL?`${e.get(i)||i}`:`${i}`:this.isPartElementCategory(n,r)?t===h.ALL||"SUM_TOTAL"===o?`${e.get(o)||o}`:`${o}`:this.isSumElementCategory(n,r)?t===h.ALL||"SUM_TOTAL"===o?`${e.get(o)||o}`:o:"GROUPHEAD"===n&&null==s?s:Number.isNaN(Number(s))?"-":Number(s)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,e){if(this.attributesByAlias.has(t))return"attribute";const s=new a(t);let o="pos";return e<0&&(o="neg"),s.isValid?o+"_"+s.direction+("dr"===s.type?" relative_variance":""):t}setCellType(t,e){if("category"===t)return"";const s=this.attributesByAlias.get(t);if(s)return s.isNumeric?"decimal":"";let o;const i=new a(t);return e===u.PERCENT?(o="percent",i.isValid&&"d"===i.type&&(o="decimal")):(o="decimal",i.isValid&&"dr"===i.type&&(o="percent")),o}isDrillElementCategory(t,e){return"DRILLELEMENT"===t&&"category"===e}isPartElementCategory(t,e){return"PARTELEMENT"===t&&"category"===e}isSumElementCategory(t,e){return("GROUP_SUM"===t||"SUM"===t)&&"category"===e}isEntryCategory(t,e){return"ENTRY"===t&&"category"===e}isGroupHeadCategory(t,e){return"GROUPHEAD"===t&&"category"===e}translateCellPrefix(t,e,s){return this.isOperationColumn(s)||this.isGroupHeadCategory(e,s)||this.isEntryCategory(e,s)?null:this.isDrillElementCategory(e,s)?`${t.get("there_of")} `:this.isPartElementCategory(e,s)?`${t.get("part_of")} `:null}createColumnType(t){return t.name===t.group&&t.name===t.type?"base":t.name===t.group?"columnGroup":"columnSubGroup"}}class z{constructor(t,e,s,o){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.ruleSet=t||new l,this.db=e,this.dataSetFactory=new I,this.config=this.initConfig(o),this.i18n=this.initI18n(new Map),this.setSource(s,o.filter),this.state=y.DIRTY}setI18n(t){this.i18n=this.initI18n(t)}initI18n(t){const e=new Map([["",""],["SEPERATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pl3","PL3"],["ac4","AC4"],["pp4","PY4"],["fc4","FC4"],["pl4","PL4"],["in","in"],["category"," "],["operation"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return this.state=y.DIRTY,new Map([...e,...t||new Map])}initConfig(t){this.state=y.DIRTY;const e=t,s=this;return t.scenarios.sort(((t,e)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(e))),e}setConfig(t){this.config=this.initConfig(t)}setSource(t,e){var s,o;if(!t)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=v(t,e);try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(o=null===(s=t[0])||void 0===s?void 0:s.cnt)&&void 0!==o?o:0}catch(t){this.rowCount=0}const i=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder);this.headerRows=this.dataSetFactory.createHeader(this.config.type,i,this.i18n,this.config.measureScale,this.config.measureUnit,this.config.showMeasureScale,this.config.attributes),this.bodyRows=0===this.rowCount?[]:this.dataSetFactory.createBodyRows(this.config,this.i18n,this.db,this.fromExpr),this.state=y.UP_TO_DATE}update(){const t=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder);this.headerRows=this.dataSetFactory.createHeader(this.config.type,t,this.i18n,this.config.measureScale,this.config.measureUnit,this.config.showMeasureScale,this.config.attributes),this.bodyRows=0!==this.rowCount&&this.fromExpr?this.dataSetFactory.createBodyRows(this.config,this.i18n,this.db,this.fromExpr):[],this.state=y.UP_TO_DATE}getHeader(){return this.state===y.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===y.DIRTY&&this.update(),this.bodyRows}normalizeScenarios(t,e,s){var o;const i=[];for(const n of t){if(null==e?void 0:e.has(n)){const t=e.get(n);for(const e of t){i.push({name:e.name,group:e.name,type:n,order:void 0});for(const t of e.subGroups)i.push({name:t,group:e.name,type:n,order:void 0})}i.push({name:"REST",group:"REST",type:n,order:void 0})}let t;(null===(o=null==s?void 0:s.hierarchy)||void 0===o?void 0:o.at(0))===n&&(t=s.direction),i.push({name:n,group:n,type:n,order:t})}return i}hasNoData(){return 0===this.rowCount}}class j{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=u.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.thereOf=[],this.categoryThereOf=new Map,this.partOf=[],this.attributes=[],this.sortOrder=new p(new c).default(),this.type=M.LIST,this.limit=0,this.i18n=h.ALL,this.categoryWidth=$.W25,this.measureScale=new w,this.measureUnit="",this.measureType=m.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[]}}class V{constructor(t,e,s,o,i){this.tableDrillGroupAdapter=t,this.stringAdapter=e,this.orderAdapter=s,this.db=o,this.fromExpr=i}adapt(t){const e=new j;return d.isString(t.title)&&(e.title=t.title),d.isArray(t.scenarios)&&(e.scenarios=f.adaptArray(t.scenarios,this.stringAdapter)),d.isExisting(t.scenariosUnitType)&&(e.scenariosUnitType=t.scenariosUnitType),d.isBoolean(t.grouped)&&(e.grouped=t.grouped),d.isBoolean(t.showGroupTitle)&&(e.showGroupTitle=t.showGroupTitle),d.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),d.isArray(t.thereOf)&&(e.thereOf=f.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),d.isExisting(t.categoryThereOf)&&(e.categoryThereOf=t.categoryThereOf),d.isArray(t.partOf)&&(e.partOf=f.adaptArray(t.partOf,this.tableDrillGroupAdapter)),d.isArray(t.attributes)&&(e.attributes=t.attributes),d.isExisting(t.order)&&(e.sortOrder=this.orderAdapter.adapt(t.order)),d.isExisting(t.type)&&(e.type=t.type),d.isNumber(t.limit)&&(e.limit=t.limit),d.isExisting(t.i18n)&&(e.i18n=t.i18n),d.isExisting(t.categoryWidth)&&(e.categoryWidth=t.categoryWidth),d.isExisting(t.measureScale)&&(e.measureScale=R.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale)),d.isExisting(t.measureType)&&(e.measureType=t.measureType),d.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),d.isString(t.filter)&&(e.filter=t.filter.trim()),d.isArray(t.barColumns)&&(e.barColumns=t.barColumns),e}default(){return new j}}class Q{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class q{constructor(){}adapt(t){const e=new Q;return d.isString(t.rowGroup)&&(e.rowGroup=t.rowGroup),d.isString(t.category)&&(e.category=t.category),d.isString(t.subCategory)&&(e.subCategory=t.subCategory),d.isString(t.partOf)&&(e.partOf=t.partOf),e}default(){return new Q}}const K=e(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.tableTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=u.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.thereof=[],this.partof=[],this.order={hierarchy:[],direction:U.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=M.LIST,this.categoryWidth=$.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=h.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=m.VOLUME,this.filter="",this.barColumns=[],this.barColumnMaxWidth=30,this.unitScaling=.01,this.percentageScaling=.5,this.scaleFactor=1,this.componentDataFormatDigits=new b,this.componentStyle=E(this)}render(){return t(o,null,(()=>{if(void 0!==this.table){if(this.table.hasNoData()){const e=this.i18n.get("NO_DATA")||"==No Data==";return t("p",{class:"warning"},e)}return t("table",null,t("thead",null,this.table.getHeader().map((e=>t("tr",{class:e.cssStyle},e.getCells().map((e=>t("th",{colSpan:e.colSpan,class:e.cssStyle},e.getAsHeaderList().map(((s,o,i)=>t("span",null,o===i.length-1?t("span",{class:" "===s?"table-footer":""},s,e.drawPrefix()," "):t("span",null,s,e.drawPrefix(),t("br",null)))))))))))),t("tbody",null,this.table.getBody().map((e=>t("tr",{class:e.cssStyle},null==e?void 0:e.getCells().map((s=>t("td",{colSpan:s.colSpan,class:s.type?`${s.cssStyle} ${s.type}`:s.cssStyle},null!=s.prefix?t("span",{class:s.cssStyle+" "+s.prefixStyle},s.drawPrefix()):"",s.isBarChart&&s.columnStats&&e.type!==G.SUM?t(Y,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:s.key.startsWith("dr"),isPositiveGood:s.key.endsWith("_pos"),measureScale:s.measureScale,maxBarWidth:this.barColumnMaxWidth,styles:this.barChartStyles}):s.draw(this.componentDataFormatDigits)))))))))}})())}componentWillRender(){this.stores||(this.stores=g(this.element));const t=this.stores.db.db,e=this.prepareConfig(t);this.componentDataFormatDigits=(new S).adapt(this.dataFormatDigits),this.table=new z(new l,t,this.tableName,e),this.table.setI18n(this.i18n),this.barChartStyles=this.prepareBarChartStyles()}prepareConfig(t){const e=this.tableName?this.filter&&this.filter.length>0?`(SELECT * FROM \`${this.tableName}\` WHERE ${this.filter}) AS __src`:`\`${this.tableName}\``:"";return new V(new q,new c,new p(new c),t,e).adapt({title:this.tableTitle,scenarios:this.scenarios,scenariosUnitType:this.scenariosDataFormat,grouped:this.grouped,showGroupTitle:this.showGroupTitle,thereOf:this.thereof,partOf:this.partof,categoryThereOf:this.categorythereof,attributes:this.attributeColumns,order:this.order,type:this.type,limit:this.limit,i18n:this.i18nMode,categoryWidth:this.categoryWidth,measureScale:this.measureScale,measureUnit:this.measureUnit,measureType:this.measureType,showMeasureScale:this.showMeasureScale,filter:this.filter,barColumns:this.barColumns})}prepareBarChartStyles(){return this.componentStyle((t=>{var e,s,o,i,n,r,a,l,c,h,u,d,f,p,$,m,v,g,R,w,b,S,E,O,y,M;const U=null===(e=t["bn-chart-time"])||void 0===e?void 0:e.varianceStyles,G=null===(s=t["bn-chart-time"])||void 0===s?void 0:s.barStyles;return{positive:{stroke:(null===(o=null==U?void 0:U.pos)||void 0===o?void 0:o.stroke)||"#008f96",fill:(null===(i=null==U?void 0:U.pos)||void 0===i?void 0:i.fill)||"#008f96",fillpattern:(null===(n=null==U?void 0:U.pos)||void 0===n?void 0:n.fillpattern)||"solid"},negative:{stroke:(null===(r=null==U?void 0:U.neg)||void 0===r?void 0:r.stroke)||"#ff0000",fill:(null===(a=null==U?void 0:U.neg)||void 0===a?void 0:a.fill)||"#ff0000",fillpattern:(null===(l=null==U?void 0:U.neg)||void 0===l?void 0:l.fillpattern)||"solid"},neutral:{stroke:(null===(c=null==U?void 0:U.neu)||void 0===c?void 0:c.stroke)||"#808080",fill:(null===(h=null==U?void 0:U.neu)||void 0===h?void 0:h.fill)||"#808080",fillpattern:(null===(u=null==U?void 0:U.neu)||void 0===u?void 0:u.fillpattern)||"outlined"},scenarios:{ac:{stroke:(null===(d=null==G?void 0:G.ac)||void 0===d?void 0:d.stroke)||"#404040",fill:(null===(f=null==G?void 0:G.ac)||void 0===f?void 0:f.fill)||"#404040",fillpattern:(null===(p=null==G?void 0:G.ac)||void 0===p?void 0:p.fillpattern)||"solid"},pp:{stroke:(null===($=null==G?void 0:G.pp)||void 0===$?void 0:$.stroke)||"#A6A6A6",fill:(null===(m=null==G?void 0:G.pp)||void 0===m?void 0:m.fill)||"#A6A6A6",fillpattern:(null===(v=null==G?void 0:G.pp)||void 0===v?void 0:v.fillpattern)||"solid"},fc:{stroke:(null===(g=null==G?void 0:G.fc)||void 0===g?void 0:g.stroke)||"#404040",fill:(null===(R=null==G?void 0:G.fc)||void 0===R?void 0:R.fill)||"#ffffff",fillpattern:(null===(w=null==G?void 0:G.fc)||void 0===w?void 0:w.fillpattern)||"hatched"},pl:{stroke:(null===(b=null==G?void 0:G.pl)||void 0===b?void 0:b.stroke)||"#404040",fill:(null===(S=null==G?void 0:G.pl)||void 0===S?void 0:S.fill)||"#ffffff",fillpattern:(null===(E=null==G?void 0:G.pl)||void 0===E?void 0:E.fillpattern)||"outlined"}},fontColor:(null===(O=t.global)||void 0===O?void 0:O.fontColor)||"#000000",fontSize:.85*((null===(y=t.global)||void 0===y?void 0:y.fontSizePx)||13.3333)*this.scaleFactor,fontFamily:(null===(M=t.global)||void 0===M?void 0:M.fontFamily)||"'Noto Sans', sans-serif",unitScaling:this.unitScaling>0?this.unitScaling:this.autoUnitScaling(),percentageScaling:this.percentageScaling>0?this.percentageScaling:this.autoPercentageScaling(),scaleFactor:this.scaleFactor}}))}autoUnitScaling(){const t=this.componentStyle((t=>{var e;return.85*((null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333)*this.scaleFactor})),e=this.barColumnMaxWidth*t*.8,s=this.getMaxAbsValue();return s<=0||t<=0?.01:e/(s*t)}autoPercentageScaling(){const t=this.componentStyle((t=>{var e;return.85*((null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333)*this.scaleFactor})),e=.8*Math.round(.67*this.barColumnMaxWidth*t),s=this.getMaxRelativeValue();return s<=0||t<=0?.5:e/(s*t)}getMaxAbsValue(){if(!this.table)return 0;let t=0;for(const e of this.table.getBody())if(e.type!==G.SUM)for(const s of e.getCells())s.isBarChart&&s.columnStats&&!s.key.startsWith("dr")&&(t=Math.max(t,s.columnStats.absMax));return t}getMaxRelativeValue(){if(!this.table)return 0;let t=0;for(const e of this.table.getBody())if(e.type!==G.SUM)for(const s of e.getCells())s.isBarChart&&s.columnStats&&s.key.startsWith("dr")&&(t=Math.max(t,100*s.columnStats.absMax));return t}get element(){return this}static get style(){return':host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}'}},[1,"ibcs-table",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],tableTitle:[1,"table-title"],scenarios:[16],scenariosDataFormat:[1,"scenarios-data-format"],grouped:[4],limit:[2],showGroupTitle:[4,"show-group-title"],thereof:[16],partof:[16],order:[16],categorythereof:[16],attributeColumns:[16],type:[1],categoryWidth:[1,"category-width"],dataFormatDigits:[16],i18n:[1040],i18nMode:[1,"i18n-mode"],measureScale:[1,"measure-scale"],measureUnit:[1,"measure-unit"],showMeasureScale:[4,"show-measure-scale"],measureType:[1,"measure-type"],filter:[1],barColumns:[16],barColumnMaxWidth:[2,"bar-column-max-width"],unitScaling:[2,"unit-scaling"],percentageScaling:[2,"percentage-scaling"],scaleFactor:[2,"scale-factor"]}]);function X(){"undefined"!=typeof customElements&&["ibcs-table"].forEach((t=>{"ibcs-table"===t&&(customElements.get(i(t))||customElements.define(i(t),K))}))}export{K as I,M as T,X as d}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as s,h as i,transformTag as e}from"@stencil/core/internal/client";import{I as n,i as r,j as a,b as o,k as c}from"./Order.js";import{b as h,D as l,a as u}from"./DateStringFactory.js";import{F as d,I as p,S as f}from"./ibcsRuleSet.js";import{D as m}from"./luxon.js";class b{constructor(){}createMeasures(t,s,i){if(this.allMeasuresUseSameUnit(t)){const e=t.length;let r="",a="";for(let o=0;o<e;o++){let c="";o>0&&(c=s.get("SEPERATOR_WS")),e>1&&o===e-1&&(c=s.get("CONNECTOR_WS")),i===n.ALL?(r=(s.get(r)||r)+c+(s.get(t[o].name)||t[o].name),a=s.get(t[o].unit)||t[o].unit):(r=r+c+t[o].name,a=t[o].unit)}return[{name:r,unit:a}]}return t}createDimension(t,s,i,e,n){let r="";return void 0!==s&&(r=(new h).getDateLinkString(s.start,s.end,s.link,s.format,n)),r+t.map((t=>{let s="";return null!=i&&null!=i.hierarchy&&i.hierarchy.find((s=>s===t))&&(s=e.get("asc"===i.direction?"ORDER_asc":"ORDER_desc")),"".concat(" ",d.translateScenarioLabel(t,e),s)})).toString()}allMeasuresUseSameUnit(t){const s=new Map;return t.forEach((function(t){s.set(t.unit,!0)})),1===s.size}}class w{constructor(){this.businessunit="",this.measures=[],this.scenarios=[],this.i18nMode=n.ALL,this.intervalSpanLimit=32}}class _{constructor(t,s,i,e){this.measureEntryAdapter=t,this.timePeriodAdapter=s,this.orderAdapter=i,this.stringAdapter=e}adapt(t){const s=new w;return r.isString(t.businessunit)&&(s.businessunit=t.businessunit),r.isArray(t.measures)&&(s.measures=a.adaptArray(t.measures,this.measureEntryAdapter)),r.isArray(t.scenarios)&&(s.scenarios=a.adaptArray(t.scenarios,this.stringAdapter)),r.isExisting(t.timeperiod)&&(s.timeperiod=this.timePeriodAdapter.adapt(t.timeperiod)),r.isNumber(t.intervalSpanLimit)&&(s.intervalSpanLimit=t.intervalSpanLimit),r.isExisting(t.i18nMode)&&(s.i18nMode=t.i18nMode),r.isExisting(t.order)&&(s.order=this.orderAdapter.adapt(t.order)),s}default(){return new w}}var v;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(v||(v={}));class y{constructor(t){this.i18n=new Map,this.unit="",this.measures=[],this.dimension="",this.config=new w,this.state=v.DIRTY,this.ruleSet=t||new p,this.dataSetFactory=new b,this.state=v.DIRTY,this.setI18n(new Map)}setI18n(t){this.state=v.DIRTY;const s=new Map([["SEPERATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pp3","PL3"],["ac4","AC4"],["py4","PY4"],["fc4","FC4"],["pp4","PL4"],["category"," "],["operation"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"],["CONNECTOR_WS"," und "]]);this.i18n=new Map([...s,...t||new Map])}update(){return v.DIRTY===this.state&&(this.unit=this.config.businessunit,this.measures=this.dataSetFactory.createMeasures(this.config.measures,this.i18n,this.config.i18nMode),this.dimension=this.dataSetFactory.createDimension(this.config.scenarios,this.config.timeperiod,this.config.order,this.i18n,this.config.intervalSpanLimit),this.state=v.UP_TO_DATE),this}setConfig(t){this.config=this.initConfig(t)}initConfig(t){this.state=v.DIRTY;const s=t,i=this;return t.scenarios.sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))),s}}class R{constructor(t="",s=""){this.name=t,this.unit=s}}class E{construnctor(){}adapt(t){const s=new R;return r.isString(t.name)&&(s.name=t.name),r.isString(t.unit)&&(s.unit=t.unit),s}default(){return new R("","")}}class S{constructor(t=m.now(),s=m.now(),i=l.AUTO,e=u.AUTO){this.start=t,this.end=s,this.format=i,this.link=e}}class C{construnctor(){}adapt(t){const s=new S;return r.isDate(t.start)&&(s.start=t.start),r.isDate(t.end)&&(s.end=t.end),r.isExisting(t.format)&&(s.format=t.format),r.isExisting(t.link)&&(s.link=t.link),s}default(){return new S}}const O=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.businessUnit="",this.scenarios=[],this.measures=[],this.intervalSpanLimit=28,this.order={hierarchy:[],direction:o.ASC},this.i18n=new Map,this.i18nMode=n.ALL,this.title=new y(new p)}async setBusinessUnit(t){this.businessUnit=t}async setProps(t){Object.keys(t).forEach((s=>{this[s]=t[s]}))}render(){return i("div",{key:"314cf7dad025643a6cdc190312eb100a310f076b"},i("div",{key:"b2e5c89f5d9d08987d09d0ee46e63b5889ede87c"},this.title.unit),i("div",{key:"d9cb4aa0cc02d8b354eb61609d4e22f4641e10a1"},this.title.measures.map(((t,s)=>i("span",null,this.isFirstElement(s)?this.title.i18n.get("SEPERATOR_WS"):"",i("span",{class:"measure"},t.name)," ",t.unit?this.title.i18n.get("in"):""," ",t.unit)))),i("div",{key:"ccbfb094dd5fa097fe339b03958ea3854e87083e"},this.title.dimension))}componentWillLoad(){const t=this.prepareConfig();this.title=new y(new p),this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillUpdate(){const t=this.prepareConfig();this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillRender(){this.title.update()}isFirstElement(t){return 0!==t}prepareConfig(){return new _(new E,new C,new c(new f),new f).adapt({businessunit:this.businessUnit,measures:this.measures,scenarios:this.scenarios,timeperiod:this.timeperiod,intervalSpanLimit:this.intervalSpanLimit,i18nMode:this.i18nMode,order:this.order})}static get style(){return':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.measure{font-weight:bold}div{background-color:var(--bn-font-background, white);color:var(--bn-font-color, black)}'}},[1,"ibcs-title",{businessUnit:[1537,"business-unit"],scenarios:[16],measures:[16],timeperiod:[16],intervalSpanLimit:[2,"interval-span-limit"],order:[16],i18n:[1040],i18nMode:[1,"i18n-mode"],setBusinessUnit:[64],setProps:[64]}]);function P(){"undefined"!=typeof customElements&&["ibcs-title"].forEach((t=>{"ibcs-title"===t&&(customElements.get(e(t))||customElements.define(e(t),O))}))}export{O as I,P as d}
1
+ import{proxyCustomElement as t,HTMLElement as s,h as i,transformTag as e}from"@stencil/core/internal/client";import{I as n,i as r,j as a,O as o,k as c}from"./Order.js";import{b as h,a as l,D as u}from"./DateStringFactory.js";import{F as d,I as p,S as f}from"./ibcsRuleSet.js";import{D as m}from"./luxon.js";class b{constructor(){}createMeasures(t,s,i){if(this.allMeasuresUseSameUnit(t)){const e=t.length;let r="",a="";for(let o=0;o<e;o++){let c="";o>0&&(c=s.get("SEPERATOR_WS")),e>1&&o===e-1&&(c=s.get("CONNECTOR_WS")),i===n.ALL?(r=(s.get(r)||r)+c+(s.get(t[o].name)||t[o].name),a=s.get(t[o].unit)||t[o].unit):(r=r+c+t[o].name,a=t[o].unit)}return[{name:r,unit:a}]}return t}createDimension(t,s,i,e,n){let r="";return void 0!==s&&(r=(new h).getDateLinkString(s.start,s.end,s.link,s.format,n)),r+t.map((t=>{let s="";return null!=i&&null!=i.hierarchy&&i.hierarchy.find((s=>s===t))&&(s=e.get("asc"===i.direction?"ORDER_asc":"ORDER_desc")),"".concat(" ",d.translateScenarioLabel(t,e),s)})).toString()}allMeasuresUseSameUnit(t){const s=new Map;return t.forEach((function(t){s.set(t.unit,!0)})),1===s.size}}class w{constructor(){this.businessunit="",this.measures=[],this.scenarios=[],this.i18nMode=n.ALL,this.intervalSpanLimit=32}}class _{constructor(t,s,i,e){this.measureEntryAdapter=t,this.timePeriodAdapter=s,this.orderAdapter=i,this.stringAdapter=e}adapt(t){const s=new w;return r.isString(t.businessunit)&&(s.businessunit=t.businessunit),r.isArray(t.measures)&&(s.measures=a.adaptArray(t.measures,this.measureEntryAdapter)),r.isArray(t.scenarios)&&(s.scenarios=a.adaptArray(t.scenarios,this.stringAdapter)),r.isExisting(t.timeperiod)&&(s.timeperiod=this.timePeriodAdapter.adapt(t.timeperiod)),r.isNumber(t.intervalSpanLimit)&&(s.intervalSpanLimit=t.intervalSpanLimit),r.isExisting(t.i18nMode)&&(s.i18nMode=t.i18nMode),r.isExisting(t.order)&&(s.order=this.orderAdapter.adapt(t.order)),s}default(){return new w}}var v;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(v||(v={}));class y{constructor(t){this.i18n=new Map,this.unit="",this.measures=[],this.dimension="",this.config=new w,this.state=v.DIRTY,this.ruleSet=t||new p,this.dataSetFactory=new b,this.state=v.DIRTY,this.setI18n(new Map)}setI18n(t){this.state=v.DIRTY;const s=new Map([["SEPERATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pp3","PL3"],["ac4","AC4"],["py4","PY4"],["fc4","FC4"],["pp4","PL4"],["category"," "],["operation"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"],["CONNECTOR_WS"," und "]]);this.i18n=new Map([...s,...t||new Map])}update(){return v.DIRTY===this.state&&(this.unit=this.config.businessunit,this.measures=this.dataSetFactory.createMeasures(this.config.measures,this.i18n,this.config.i18nMode),this.dimension=this.dataSetFactory.createDimension(this.config.scenarios,this.config.timeperiod,this.config.order,this.i18n,this.config.intervalSpanLimit),this.state=v.UP_TO_DATE),this}setConfig(t){this.config=this.initConfig(t)}initConfig(t){this.state=v.DIRTY;const s=t,i=this;return t.scenarios.sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))),s}}class R{constructor(t="",s=""){this.name=t,this.unit=s}}class E{construnctor(){}adapt(t){const s=new R;return r.isString(t.name)&&(s.name=t.name),r.isString(t.unit)&&(s.unit=t.unit),s}default(){return new R("","")}}class O{constructor(t=m.now(),s=m.now(),i=l.AUTO,e=u.AUTO){this.start=t,this.end=s,this.format=i,this.link=e}}class S{construnctor(){}adapt(t){const s=new O;return r.isDate(t.start)&&(s.start=t.start),r.isDate(t.end)&&(s.end=t.end),r.isExisting(t.format)&&(s.format=t.format),r.isExisting(t.link)&&(s.link=t.link),s}default(){return new O}}const C=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.businessUnit="",this.scenarios=[],this.measures=[],this.intervalSpanLimit=28,this.order={hierarchy:[],direction:o.ASC},this.i18n=new Map,this.i18nMode=n.ALL,this.title=new y(new p)}async setBusinessUnit(t){this.businessUnit=t}async setProps(t){Object.keys(t).forEach((s=>{this[s]=t[s]}))}render(){return i("div",{key:"314cf7dad025643a6cdc190312eb100a310f076b"},i("div",{key:"b2e5c89f5d9d08987d09d0ee46e63b5889ede87c"},this.title.unit),i("div",{key:"d9cb4aa0cc02d8b354eb61609d4e22f4641e10a1"},this.title.measures.map(((t,s)=>i("span",null,this.isFirstElement(s)?this.title.i18n.get("SEPERATOR_WS"):"",i("span",{class:"measure"},t.name)," ",t.unit?this.title.i18n.get("in"):""," ",t.unit)))),i("div",{key:"ccbfb094dd5fa097fe339b03958ea3854e87083e"},this.title.dimension))}componentWillLoad(){const t=this.prepareConfig();this.title=new y(new p),this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillUpdate(){const t=this.prepareConfig();this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillRender(){this.title.update()}isFirstElement(t){return 0!==t}prepareConfig(){return new _(new E,new S,new c(new f),new f).adapt({businessunit:this.businessUnit,measures:this.measures,scenarios:this.scenarios,timeperiod:this.timeperiod,intervalSpanLimit:this.intervalSpanLimit,i18nMode:this.i18nMode,order:this.order})}static get style(){return':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.measure{font-weight:bold}div{background-color:var(--bn-font-background, white);color:var(--bn-font-color, black)}'}},[1,"ibcs-title",{businessUnit:[1537,"business-unit"],scenarios:[16],measures:[16],timeperiod:[16],intervalSpanLimit:[2,"interval-span-limit"],order:[16],i18n:[1040],i18nMode:[1,"i18n-mode"],setBusinessUnit:[64],setProps:[64]}]);function P(){"undefined"!=typeof customElements&&["ibcs-title"].forEach((t=>{"ibcs-title"===t&&(customElements.get(e(t))||customElements.define(e(t),C))}))}export{C as I,P as d}
@@ -1 +1 @@
1
- import{g as t,c as e}from"./context-protocol.js";import{r as o}from"./utils.js";import{getElement as n}from"@stencil/core/internal/client";const a=(t,e)=>{const o=[],n=[];for(const a of e)(t(a)?o:n).push(a);return[o,n]},r="WARN_use_dataset",s=(t,e)=>{const o=t.errors;if(o)if(e.length>0){const t=e.map((t=>t.substring(1))).join(", ");o.addOrReplace({id:r,type:"warning",message:`Using datasource(s) "${t}" directly. Prefer using a dataset (bn-dataset) for query support and metadata.`})}else o.remove(r)},i=(r,i,c)=>{let l,u,d=[],f=[],p=[];const h=(t,e)=>{const o=e?t.substring(1):t;let n;try{n=u.db.db.exec(`SELECT * FROM \`${o}\``)}catch(t){n=[]}i(t,n)},m=()=>{d.forEach((t=>t())),d=[],f.forEach((t=>{t&&(d.push(u.db.subscribe(t,(()=>h(t,!1)))),h(t,!1),(t=>{if(c){const e=u.datasetsMeta.get(t);e&&c(t,e)}})(t))})),p.forEach((t=>{t&&(d.push(u.db.subscribe(t.substring(1),(()=>h(t,!0)))),h(t,!0))}))},g=new MutationObserver((t=>{t.forEach((t=>{"datasets"===t.attributeName&&([p,f]=a((t=>t.startsWith("$")),n(r).getAttribute("datasets").split(",")),s(r,p),m())}))})),w=r.connectedCallback;r.connectedCallback=()=>{const e=n(r);u=t(e),[p,f]=a((t=>t.startsWith("$")),(e.getAttribute("datasets")||"").split(",")),s(r,p),m(),g.observe(e,{attributes:!0,attributeFilter:["datasets"]}),c&&(l=u.datasetsMeta.on("set",((t,e)=>{f.includes(t)&&c(t,e)}))),o(w,r)};const $=r.disconnectedCallback;return r.disconnectedCallback=()=>{g.disconnect(),d.forEach((t=>t())),d=[],o(l),e(n(r)),o($,r)},t=>{f=t,m()}};function c(t,e=!1){const o=l(t);if(!o)return e&&console.log("[parentDims] no layout parent found for",t.tagName),{width:0,height:0};const n=getComputedStyle(o),a=o.clientWidth-parseFloat(n.paddingLeft)-parseFloat(n.paddingRight),r=function(t,e=!1){let o=l(t),n=0;for(;o;){const t=getComputedStyle(o),a=t.overflowY;if(e&&console.log(`[height:${n}]`,o.tagName,o.className||"(no class)",`overflow=${a} clientH=${o.clientHeight} h=${t.height}`),"hidden"===a||"scroll"===a||"auto"===a){const a=o.clientHeight-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom);return e&&console.log(`[height] FOUND constrained at depth ${n}: ${Math.round(a)}px`),a}if("none"!==t.maxHeight){const e=parseFloat(t.maxHeight);if(!isNaN(e)&&e>0)return Math.min(e,o.clientHeight-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom))}o=u(o),n++}return e&&console.log("[height] NO constrained ancestor → viewport fallback"),"undefined"!=typeof window?window.innerHeight:0}(t,e);return e&&console.log("[parentDims]",t.tagName,"→ layoutParent:",o.tagName,o.className||"(no class)",`clientW=${o.clientWidth} → w=${Math.round(a)}, h=${Math.round(r)}`,"overflow:",n.overflow),{width:Math.max(0,a),height:Math.max(0,r)}}function l(t){var e;const o=t.parentElement;return(null===(e=null==o?void 0:o.assignedSlot)||void 0===e?void 0:e.parentElement)?o.assignedSlot.parentElement:o}function u(t){var e;return(null===(e=t.assignedSlot)||void 0===e?void 0:e.parentElement)?t.assignedSlot.parentElement:t.parentElement}function d(t){if(null==t||""===t)return{mode:"empty"};if("none"===t)return{mode:"none"};if("auto"===t)return{mode:"auto"};const e=Number(t);return!isNaN(e)&&e>0?{mode:"factor",factor:e}:{mode:"empty"}}export{c as g,d as p,i as w}
1
+ import{g as t,c as e}from"./context-protocol.js";import{r as n}from"./utils.js";import{getElement as o}from"@stencil/core/internal/client";const a=(t,e)=>{const n=[],o=[];for(const a of e)(t(a)?n:o).push(a);return[n,o]},r="WARN_use_dataset",s=(t,e)=>{const n=t.errors;if(n)if(e.length>0){const t=e.map((t=>t.substring(1))).join(", ");n.addOrReplace({id:r,type:"warning",message:`Using datasource(s) "${t}" directly. Prefer using a dataset (bn-dataset) for query support and metadata.`})}else n.remove(r)},i=(r,i,c)=>{let l,u,d=[],f=[],p=[];const h=(t,e)=>{const n=e?t.substring(1):t;let o;try{o=u.db.db.exec(`SELECT * FROM \`${n}\``)}catch(t){o=[]}i(t,o)},m=()=>{d.forEach((t=>t())),d=[],f.forEach((t=>{t&&(d.push(u.db.subscribe(t,(()=>h(t,!1)))),h(t,!1),(t=>{if(c){const e=u.datasetsMeta.get(t);e&&c(t,e)}})(t))})),p.forEach((t=>{t&&(d.push(u.db.subscribe(t.substring(1),(()=>h(t,!0)))),h(t,!0))}))},g=new MutationObserver((t=>{t.forEach((t=>{"datasets"===t.attributeName&&([p,f]=a((t=>t.startsWith("$")),o(r).getAttribute("datasets").split(",")),s(r,p),m())}))})),w=r.connectedCallback;r.connectedCallback=()=>{const e=o(r);u=t(e),[p,f]=a((t=>t.startsWith("$")),(e.getAttribute("datasets")||"").split(",")),s(r,p),m(),g.observe(e,{attributes:!0,attributeFilter:["datasets"]}),c&&(l=u.datasetsMeta.on("set",((t,e)=>{f.includes(t)&&c(t,e)}))),n(w,r)};const $=r.disconnectedCallback;return r.disconnectedCallback=()=>{g.disconnect(),d.forEach((t=>t())),d=[],n(l),e(o(r)),n($,r)},t=>{f=t,m()}};function c(t,e=!1){const n=l(t);if(!n)return e&&console.log("[parentDims] no layout parent found for",t.tagName),{width:0,height:0};const o=getComputedStyle(n),a=n.clientWidth-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight),r=function(t,e=!1){let n=l(t),o=0,a=null,r=1;for(;n;){if(n.hasAttribute("data-bn-fit-content")){e&&console.log(`[height:${o}]`,n.tagName,"fit-content region → discarding inner candidate"),a=null;const t=parseInt(n.getAttribute("data-bn-fit-content"),10);!isNaN(t)&&t>1&&(r*=t),n=u(n),o++;continue}const t=getComputedStyle(n),s=t.overflowY;if(e&&console.log(`[height:${o}]`,n.tagName,n.className||"(no class)",`overflow=${s} clientH=${n.clientHeight} h=${t.height}`),null===a)if("hidden"===s||"scroll"===s||"auto"===s)a=n.clientHeight-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom),e&&console.log(`[height] candidate at depth ${o}: ${Math.round(a)}px`);else if("none"!==t.maxHeight){const e=parseFloat(t.maxHeight);!isNaN(e)&&e>0&&(a=Math.min(e,n.clientHeight-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom)))}n=u(n),o++}return null!==a?a/r:(e&&console.log("[height] NO constrained ancestor → viewport fallback"),"undefined"!=typeof window?window.innerHeight/r:0)}(t,e);return e&&console.log("[parentDims]",t.tagName,"→ layoutParent:",n.tagName,n.className||"(no class)",`clientW=${n.clientWidth} → w=${Math.round(a)}, h=${Math.round(r)}`,"overflow:",o.overflow),{width:Math.max(0,a),height:Math.max(0,r)}}function l(t){var e;const n=t.parentElement;return(null===(e=null==n?void 0:n.assignedSlot)||void 0===e?void 0:e.parentElement)?n.assignedSlot.parentElement:n}function u(t){var e;if(null===(e=t.assignedSlot)||void 0===e?void 0:e.parentElement)return t.assignedSlot.parentElement;if(t.parentElement)return t.parentElement;const n=t.getRootNode();return n instanceof ShadowRoot?n.host:null}function d(t){if(null==t||""===t)return{mode:"empty"};if("none"===t)return{mode:"none"};if("auto"===t)return{mode:"auto"};const e=Number(t);return!isNaN(e)&&e>0?{mode:"factor",factor:e}:{mode:"empty"}}export{c as g,d as p,i as w}
@@ -1 +1 @@
1
- import{S as n,a as r,A as t,O as u,b as e,c as o,T as a,D as i,d as s,M as c,e as l}from"./Order.js";import{D as f,a as d}from"./DateStringFactory.js";function v(n){return null==n||""===n||"null"===n}function S(r){return v(r)||"auto"===r.trim().toLowerCase()?[]:m((null==r?void 0:r.split(",").filter((r=>!(r.toUpperCase().trim()in n)))).toString())}function m(t){return v(t)?[]:t.replace(";",",").split(",").filter((t=>{var u,e,o;const a=t.split("_"),i=null===(u=a[0])||void 0===u?void 0:u.replace(/^dr|^d/,"").toUpperCase().trim(),s=null===(e=a[1])||void 0===e?void 0:e.toUpperCase().trim(),c=null===(o=a[2])||void 0===o?void 0:o.toUpperCase().trim();return 3!==a.length||!(i in n)||!(s in n)||!(c in r)}))}function b(n){return v(n)||"auto"===n.trim().toLowerCase()?[]:m(n.split(",").filter((n=>!(n.toUpperCase()in u))).toString())}function N(n){return!v(n)&&Number.isInteger(Number(n))}function O(n){return!v(n)&&!Number.isNaN(Number(n))}function y(n){return!v(n)&&(null==n?void 0:n.toUpperCase())in e}function J(n){return"auto"===(null==n?void 0:n.toLowerCase())||(null==n?void 0:n.toUpperCase())in t}function p(n){if(v(n))return[];try{const r=JSON.parse(n);if(r instanceof Array)return r.filter((n=>!(n.hasOwnProperty("name")&&n.hasOwnProperty("unit"))))}catch(n){console.error("validateMeasureList: failed to parse JSON",n)}return["Invalid JSON structure"]}function h(n){const r=Date.parse(n);return Number.isInteger(r)}function k(n){return(null==n?void 0:n.toUpperCase())in d}function A(n){return(null==n?void 0:n.toUpperCase())in f}function T(n){return(null==n?void 0:n.toUpperCase())in o}function g(n){return!v(n)&&(null==n?void 0:n.toUpperCase())in i}function j(n){return!v(n)&&["true","false",!0,!1].some((r=>r===n))}function G(n){return!v(n)&&(null==n?void 0:n.toUpperCase())in s}function D(n){if(v(n))return[];try{const r=JSON.parse(n);if(r instanceof Array)return r.filter((n=>!(n.hasOwnProperty("rowGroup")&&n.hasOwnProperty("category")&&n.hasOwnProperty("subCategory"))))}catch(n){console.error("validateThereOfJsonStr: failed to parse JSON",n)}return["Invalid JSON structure"]}function E(n){if(v(n))return[];try{const r=JSON.parse(n);if(r instanceof Array)return r.filter((n=>!(n.hasOwnProperty("rowGroup")&&n.hasOwnProperty("category"))))}catch(n){console.error("validatePartOfJsonStr: failed to parse JSON",n)}return["Invalid JSON structure"]}function I(n){return(null==n?void 0:n.trim().toUpperCase())in c}function w(n){return["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(null==n?void 0:n.trim())||["GREATEST","LEAST"].includes(null==n?void 0:n.trim().toUpperCase())}function M(n){return(null==n?void 0:n.toUpperCase().trim())in l}function P(n){return(null==n?void 0:n.toUpperCase().trim())in a}function $(n){if(v(n))return[];try{return JSON.parse(n).filter((n=>!(n.hasOwnProperty("scenario")&&n.hasOwnProperty("name")&&n.hasOwnProperty("subGroups"))))}catch(n){console.error("validateColumnThereOfJsonStr: failed to parse JSON",n)}return["Invalid JSON structure"]}function q(n){if(v(n))return[];try{const r=JSON.parse(n);if("object"!=typeof r||null===r||Array.isArray(r))return["stack: must be a JSON object"];const t=[];if(r.hasOwnProperty("by")){const n=["scenarios","dimensions"];n.includes(r.by)||t.push(`stack: 'by' must be one of: ${n.join(", ")}`)}else t.push("stack: 'by' is required");if(r.hasOwnProperty("mode")){const n=["absolute","relative","absolute-relative"];n.includes(r.mode)||t.push(`stack: 'mode' must be one of: ${n.join(", ")}`)}if(r.hasOwnProperty("order")){const n=["asc","desc","dataset"];n.includes(r.order)||t.push(`stack: 'order' must be one of: ${n.join(", ")}`)}return t}catch(n){return["stack: invalid JSON"]}}export{m as a,b,y as c,p as d,h as e,A as f,k as g,O as h,v as i,J as j,N as k,j as l,w as m,q as n,T as o,P as p,g as q,G as r,D as s,E as t,I as u,S as v,M as w,$ as x}
1
+ import{S as n,a as t,A as r,b as e,O as u,c as i,T as s,D as o,d as a,M as c,e as l}from"./Order.js";import{a as f,D as d}from"./DateStringFactory.js";const v=/^\s*(set|first|last|min|max|avg|sum|lit)\(\s*(.*?)\s*\)\s*$/,m=/^[A-Za-z_][A-Za-z0-9_]*$/,S=["min","max","avg","sum"];class y{constructor(n,t,r,e){this.label=n,this.alias=t,this.fn=r,this.arg=e}get isNumeric(){return S.includes(this.fn)}}function N(n){if("string"!=typeof n)return!1;const t=v.exec(n);if(!t)return!1;const[,r,e]=t;return"lit"===r?e.length>0:m.test(e)}function O(n,t,r){if(!N(r))return null;const[,e,u]=v.exec(r);return new y(n,t,e,u)}function b(n){return null==n||""===n||"null"===n}function J(t){return b(t)||"auto"===t.trim().toLowerCase()?[]:p((null==t?void 0:t.split(",").filter((t=>!(t.toUpperCase().trim()in n)))).toString())}function p(r){return b(r)?[]:r.replace(";",",").split(",").filter((r=>{var e,u,i;const s=r.split("_"),o=null===(e=s[0])||void 0===e?void 0:e.replace(/^dr|^d/,"").toUpperCase().trim(),a=null===(u=s[1])||void 0===u?void 0:u.toUpperCase().trim(),c=null===(i=s[2])||void 0===i?void 0:i.toUpperCase().trim();return 3!==s.length||!(o in n)||!(a in n)||!(c in t)}))}function h(n){return b(n)||"auto"===n.trim().toLowerCase()?[]:p(n.split(",").filter((n=>!(n.toUpperCase()in e))).toString())}function A(n){return!b(n)&&Number.isInteger(Number(n))}function g(n){return!b(n)&&!Number.isNaN(Number(n))}function k(n){return!b(n)&&(null==n?void 0:n.toUpperCase())in u}function j(n){return"auto"===(null==n?void 0:n.toLowerCase())||(null==n?void 0:n.toUpperCase())in r}function T(n){if(b(n))return[];try{const t=JSON.parse(n);if(t instanceof Array)return t.filter((n=>!(n.hasOwnProperty("name")&&n.hasOwnProperty("unit"))))}catch(n){console.error("validateMeasureList: failed to parse JSON",n)}return["Invalid JSON structure"]}function $(n){const t=Date.parse(n);return Number.isInteger(t)}function G(n){return(null==n?void 0:n.toUpperCase())in d}function I(n){return(null==n?void 0:n.toUpperCase())in f}function w(n){return(null==n?void 0:n.toUpperCase())in i}function x(n){return!b(n)&&(null==n?void 0:n.toUpperCase())in o}function z(n){return!b(n)&&["true","false",!0,!1].some((t=>t===n))}function D(n){return!b(n)&&(null==n?void 0:n.toUpperCase())in a}function E(n){if(b(n))return[];try{const t=JSON.parse(n);if(t instanceof Array)return t.filter((n=>!(n.hasOwnProperty("rowGroup")&&n.hasOwnProperty("category")&&n.hasOwnProperty("subCategory"))))}catch(n){console.error("validateThereOfJsonStr: failed to parse JSON",n)}return["Invalid JSON structure"]}function _(n){if(b(n))return[];try{const t=JSON.parse(n);if(null!==t&&"object"==typeof t&&!(t instanceof Array))return Object.entries(t).filter((([,n])=>"string"!=typeof n||!N(n))).map((([n,t])=>`${n}: ${t}`))}catch(n){console.error("validateAttributesJsonStr: failed to parse JSON",n)}return["Invalid JSON structure"]}function M(n){if(b(n))return[];try{const t=JSON.parse(n);if(t instanceof Array)return t.filter((n=>!(n.hasOwnProperty("rowGroup")&&n.hasOwnProperty("category"))))}catch(n){console.error("validatePartOfJsonStr: failed to parse JSON",n)}return["Invalid JSON structure"]}function P(n){return(null==n?void 0:n.trim().toUpperCase())in c}function Z(n){return["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(null==n?void 0:n.trim())||["GREATEST","LEAST"].includes(null==n?void 0:n.trim().toUpperCase())}function q(n){return(null==n?void 0:n.toUpperCase().trim())in l}function C(n){return(null==n?void 0:n.toUpperCase().trim())in s}function L(n){if(b(n))return[];try{return JSON.parse(n).filter((n=>!(n.hasOwnProperty("scenario")&&n.hasOwnProperty("name")&&n.hasOwnProperty("subGroups"))))}catch(n){console.error("validateColumnThereOfJsonStr: failed to parse JSON",n)}return["Invalid JSON structure"]}function F(n){if(b(n))return[];try{const t=JSON.parse(n);if("object"!=typeof t||null===t||Array.isArray(t))return["stack: must be a JSON object"];const r=[];if(t.hasOwnProperty("by")){const n=["scenarios","dimensions"];n.includes(t.by)||r.push(`stack: 'by' must be one of: ${n.join(", ")}`)}else r.push("stack: 'by' is required");if(t.hasOwnProperty("mode")){const n=["absolute","relative","absolute-relative"];n.includes(t.mode)||r.push(`stack: 'mode' must be one of: ${n.join(", ")}`)}if(t.hasOwnProperty("order")){const n=["asc","desc","dataset"];n.includes(t.order)||r.push(`stack: 'order' must be one of: ${n.join(", ")}`)}return r}catch(n){return["stack: invalid JSON"]}}export{p as a,h as b,k as c,T as d,$ as e,I as f,G as g,g as h,b as i,j,A as k,z as l,Z as m,F as n,w as o,C as p,x as q,D as r,E as s,M as t,P as u,J as v,q as w,L as x,_ as y,O as z}