@bino-bi/bn-template-engine 1.0.0-next.19 → 1.0.0-next.21

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 (144) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/{p-7bdc0e28.entry.js → p-28d5c266.entry.js} +1 -1
  3. package/dist/bn-template-engine/{p-2e6dc267.entry.js → p-2d3ea756.entry.js} +1 -1
  4. package/dist/bn-template-engine/{p-9879c9b2.entry.js → p-2fba7c99.entry.js} +1 -1
  5. package/dist/bn-template-engine/{p-eca8e2e2.entry.js → p-6077155f.entry.js} +1 -1
  6. package/dist/bn-template-engine/{p-74c5a95d.entry.js → p-687032d5.entry.js} +1 -1
  7. package/dist/bn-template-engine/{p-22d0fb7a.entry.js → p-6c7f0076.entry.js} +1 -1
  8. package/dist/bn-template-engine/{p-Dg9OcXAO.js → p-6lOdN-fB.js} +1 -1
  9. package/dist/bn-template-engine/{p-83c71b16.entry.js → p-7e9dbc93.entry.js} +1 -1
  10. package/dist/bn-template-engine/{p-b25455a7.entry.js → p-99477a27.entry.js} +1 -1
  11. package/dist/bn-template-engine/p-A8xyE4b1.js +1 -0
  12. package/dist/bn-template-engine/p-BgIpdpfH.js +1 -0
  13. package/dist/bn-template-engine/p-BpWWgN6k.js +1 -0
  14. package/dist/bn-template-engine/{p-Bdfxd_Ke.js → p-C5uvAEKI.js} +1 -1
  15. package/dist/bn-template-engine/p-C8Q0lsaU.js +1 -0
  16. package/dist/bn-template-engine/{p-DY7YYmpa.js → p-C9i1Xsib.js} +1 -1
  17. package/dist/bn-template-engine/{p-BWKdb9ym.js → p-CJThzFZm.js} +1 -1
  18. package/dist/bn-template-engine/{p-rdqTC0_5.js → p-CYE0I1Mx.js} +1 -1
  19. package/dist/bn-template-engine/{p-X6CxL6W-.js → p-DwYUTvvI.js} +1 -1
  20. package/dist/bn-template-engine/{p-19bbac66.entry.js → p-a1380d7c.entry.js} +1 -1
  21. package/dist/bn-template-engine/{p-485d23d7.entry.js → p-a4ea9a79.entry.js} +1 -1
  22. package/dist/bn-template-engine/p-b5274369.entry.js +1 -0
  23. package/dist/bn-template-engine/{p-e96da91f.entry.js → p-b9e94127.entry.js} +1 -1
  24. package/dist/bn-template-engine/p-ba912130.entry.js +1 -0
  25. package/dist/bn-template-engine/{p-f9dfd120.entry.js → p-de29986f.entry.js} +1 -1
  26. package/dist/bn-template-engine/{p-BZV1b5VH.js → p-eEfqksk-.js} +1 -1
  27. package/dist/bn-template-engine/{p-aakBGfzL.js → p-fFtEvsY-.js} +1 -1
  28. package/dist/cjs/{AxisConfig-VnVelfSV.js → AxisConfig-D7CAyPLO.js} +1 -1
  29. package/dist/cjs/{LabelCollisionManager-nfD5P__k.js → LabelCollisionManager-DkdQ9Xdg.js} +2 -2
  30. package/dist/cjs/{Order-DobBozQC.js → Order-IPfAP0q8.js} +1 -1
  31. package/dist/cjs/{SVGStyle-BQOmGWLX.js → SVGStyle-BD8jApd4.js} +2 -2
  32. package/dist/cjs/{SVGVariancesStyleGroup-DCGfHrqh.js → SVGVariancesStyleGroup-BaWzR951.js} +1 -1
  33. package/dist/cjs/{VarianceMeasure-NY9yhiNV.js → VarianceMeasure-BBWTgv2e.js} +1 -1
  34. package/dist/cjs/{XYChartDataRow-B7OKrAcC.js → XYChartDataRow-BoR0CTfl.js} +4 -4
  35. package/dist/cjs/bn-asset_21.cjs.entry.js +93 -35
  36. package/dist/cjs/bn-chart-bubble.cjs.entry.js +8 -8
  37. package/dist/cjs/bn-chart-bullet.cjs.entry.js +7 -7
  38. package/dist/cjs/bn-chart-scatter.cjs.entry.js +7 -7
  39. package/dist/cjs/bn-grid.cjs.entry.js +5 -5
  40. package/dist/cjs/bn-image.cjs.entry.js +4 -4
  41. package/dist/cjs/bn-internationalization.cjs.entry.js +1 -1
  42. package/dist/cjs/bn-ruleset.cjs.entry.js +1 -1
  43. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  44. package/dist/cjs/bn-text.cjs.entry.js +5 -5
  45. package/dist/cjs/bn-tree.cjs.entry.js +4 -4
  46. package/dist/cjs/{context-protocol-BDrMkhc4.js → context-protocol-BBhT9B52.js} +9 -3
  47. package/dist/cjs/editor-companion.cjs.entry.js +1 -1
  48. package/dist/cjs/ibcs-chart-bubble.cjs.entry.js +5 -5
  49. package/dist/cjs/ibcs-chart-bullet.cjs.entry.js +5 -5
  50. package/dist/cjs/ibcs-chart-scatter.cjs.entry.js +5 -5
  51. package/dist/cjs/{layoutObserver-o03YUfn_.js → layoutObserver-DUYYkDMQ.js} +3 -3
  52. package/dist/cjs/loader.cjs.js +1 -1
  53. package/dist/cjs/{scaling-DKZyjWj5.js → scaling-BIJQ2NV1.js} +4 -2
  54. package/dist/cjs/{withScalingGroup-BmcRlWBs.js → withScalingGroup-D5clRvRe.js} +1 -1
  55. package/dist/cjs/{withStyled-CRiC9fzc.js → withStyled-Cm9dWQhu.js} +34 -3
  56. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +2 -2
  57. package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +1 -1
  58. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +19 -2
  59. package/dist/collection/components/bn-chart-time/bn-chart-time.js +2 -2
  60. package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +3 -1
  61. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +19 -1
  62. package/dist/collection/components/bn-chart-time/utils/model/TimeChartComponentConfig.js +5 -0
  63. package/dist/collection/components/bn-context/bn-context.js +20 -1
  64. package/dist/collection/components/bn-grid/bn-grid.js +20 -1
  65. package/dist/collection/components/bn-layout-card/bn-layout-card.js +3 -3
  66. package/dist/collection/components/bn-layout-page/bn-layout-page.js +3 -3
  67. package/dist/collection/components/bn-table/bn-table.js +2 -2
  68. package/dist/collection/components/bn-table/ibcs-table.js +1 -1
  69. package/dist/collection/components/bn-table/utils/Table.js +0 -1
  70. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +3 -1
  71. package/dist/collection/components/bn-title/bn-title.js +5 -1
  72. package/dist/collection/components/bn-title/ibcs-title/ibcs-title.js +25 -2
  73. package/dist/collection/components/bn-title/ibcs-title/utils/Title.js +4 -4
  74. package/dist/collection/components/bn-title/ibcs-title/utils/factories/TitleDataSetFactory.js +6 -2
  75. package/dist/collection/components/bn-title/ibcs-title/utils/model/TitleConfig.js +5 -0
  76. package/dist/collection/components/bn-tree/bn-tree.js +19 -0
  77. package/dist/collection/stores/internationalization.js +9 -3
  78. package/dist/collection/utils/DateStringFactory.js +31 -0
  79. package/dist/collection/utils/withTranslation.js +3 -1
  80. package/dist/components/DateStringFactory.js +1 -1
  81. package/dist/components/bn-chart-structure.js +1 -1
  82. package/dist/components/bn-chart-time.js +1 -1
  83. package/dist/components/bn-context.js +1 -1
  84. package/dist/components/bn-grid.js +1 -1
  85. package/dist/components/bn-layout-card.js +1 -1
  86. package/dist/components/bn-layout-page.js +1 -1
  87. package/dist/components/bn-table.js +1 -1
  88. package/dist/components/bn-title2.js +1 -1
  89. package/dist/components/bn-tree.js +1 -1
  90. package/dist/components/context-protocol.js +1 -1
  91. package/dist/components/ibcs-chart-structure2.js +1 -1
  92. package/dist/components/ibcs-chart-time2.js +1 -1
  93. package/dist/components/ibcs-table2.js +1 -1
  94. package/dist/components/ibcs-title2.js +1 -1
  95. package/dist/esm/{AxisConfig-C_zWCKlL.js → AxisConfig-ByIP5J-9.js} +1 -1
  96. package/dist/esm/{LabelCollisionManager-8swVQHKA.js → LabelCollisionManager-DaNiDiM9.js} +2 -2
  97. package/dist/esm/{Order-BPeWfygb.js → Order-BQeJE_yi.js} +1 -1
  98. package/dist/esm/{SVGStyle-BxEDw9zh.js → SVGStyle-BwBlY3Km.js} +2 -2
  99. package/dist/esm/{SVGVariancesStyleGroup-DRQYvSDD.js → SVGVariancesStyleGroup-BpGW4CvN.js} +1 -1
  100. package/dist/esm/{VarianceMeasure-DnwNKspZ.js → VarianceMeasure-CE3N8Bea.js} +1 -1
  101. package/dist/esm/{XYChartDataRow-DeV4r-Wm.js → XYChartDataRow-DeMI1JKU.js} +4 -4
  102. package/dist/esm/bn-asset_21.entry.js +93 -35
  103. package/dist/esm/bn-chart-bubble.entry.js +8 -8
  104. package/dist/esm/bn-chart-bullet.entry.js +7 -7
  105. package/dist/esm/bn-chart-scatter.entry.js +7 -7
  106. package/dist/esm/bn-grid.entry.js +5 -5
  107. package/dist/esm/bn-image.entry.js +4 -4
  108. package/dist/esm/bn-internationalization.entry.js +1 -1
  109. package/dist/esm/bn-ruleset.entry.js +1 -1
  110. package/dist/esm/bn-template-engine.js +1 -1
  111. package/dist/esm/bn-text.entry.js +5 -5
  112. package/dist/esm/bn-tree.entry.js +4 -4
  113. package/dist/esm/{context-protocol-1Yj1uKvh.js → context-protocol-d8MHrEo8.js} +9 -3
  114. package/dist/esm/editor-companion.entry.js +1 -1
  115. package/dist/esm/ibcs-chart-bubble.entry.js +5 -5
  116. package/dist/esm/ibcs-chart-bullet.entry.js +5 -5
  117. package/dist/esm/ibcs-chart-scatter.entry.js +5 -5
  118. package/dist/esm/{layoutObserver-BG5dOBYH.js → layoutObserver-BJBEyhNf.js} +3 -3
  119. package/dist/esm/loader.js +1 -1
  120. package/dist/esm/{scaling-CeSRcRl1.js → scaling-BGnpSN1j.js} +4 -2
  121. package/dist/esm/{withScalingGroup-Br70pAv9.js → withScalingGroup-CC3UcvC5.js} +1 -1
  122. package/dist/esm/{withStyled-Br2DGTPs.js → withStyled-2l5Tx3cf.js} +34 -3
  123. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +5 -0
  124. package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +5 -0
  125. package/dist/types/components/bn-chart-time/utils/model/TimeChartComponentConfig.d.ts +2 -0
  126. package/dist/types/components/bn-context/bn-context.d.ts +8 -0
  127. package/dist/types/components/bn-grid/bn-grid.d.ts +8 -0
  128. package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +4 -0
  129. package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +4 -0
  130. package/dist/types/components/bn-title/bn-title.d.ts +1 -0
  131. package/dist/types/components/bn-title/ibcs-title/ibcs-title.d.ts +2 -0
  132. package/dist/types/components/bn-title/ibcs-title/utils/factories/TitleDataSetFactory.d.ts +3 -1
  133. package/dist/types/components/bn-title/ibcs-title/utils/model/TitleConfig.d.ts +2 -0
  134. package/dist/types/components/bn-tree/bn-tree.d.ts +8 -0
  135. package/dist/types/components.d.ts +42 -4
  136. package/dist/types/utils/DateStringFactory.d.ts +19 -0
  137. package/dist/types/utils/withTranslation.d.ts +3 -1
  138. package/package.json +1 -1
  139. package/dist/bn-template-engine/p-209351c9.entry.js +0 -1
  140. package/dist/bn-template-engine/p-90806e7a.entry.js +0 -1
  141. package/dist/bn-template-engine/p-BqhIhYr1.js +0 -1
  142. package/dist/bn-template-engine/p-C0Pwqx-O.js +0 -1
  143. package/dist/bn-template-engine/p-CiudZRQr.js +0 -1
  144. package/dist/bn-template-engine/p-DTuaq8Pj.js +0 -1
@@ -1 +1 @@
1
- import{h as t,proxyCustomElement as e,HTMLElement as o,Host as n,transformTag as s}from"@stencil/core/internal/client";import{F as i,Q as r,V as l,I as a}from"./formatter.js";import{S as c,I as h,D as u,C as f,d,M as p}from"./CompareUtil.js";import{D as $}from"./luxon.js";import{a as m,b as v}from"./DateStringFactory.js";import{d as g,g as R}from"./context-protocol.js";import{D as w,a as S,b as E}from"./DataFormatDigits.js";import{A as b,c as y}from"./Order.js";import{S as O}from"./StringAdapter.js";import{S as M}from"./SiPrefix.js";import{w as U}from"./withComponentStyle.js";var T,G,_,N,C;!function(t){t[t.ALL=-1]="ALL"}(T||(T={})),function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(G||(G={})),function(t){t.LIST="list",t.SUM="sum",t.SUMNOTOTAL="sumnototal",t.OPT="opt",t.OPTNOTOTAL="optnototal"}(_||(_={})),function(t){t.ASC="asc",t.DESC="desc"}(N||(N={})),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"}(C||(C={}));const L="none",x="setname";function k(t){return t===x?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function P(t){if(null==t)return"";if("string"==typeof t)return t.trim();const e=A(t);return e?e.toISO():String(t)}function A(t){if(null!=t){if("string"==typeof t){const e=$.fromISO(t);return e.isValid?e:void 0}if("number"==typeof t){const e=$.fromMillis(t);return e.isValid?e:void 0}if("boolean"==typeof t.isValid)return t.isValid?t:void 0}}class D{constructor(t,e,o,n,s,i,r,l,a){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=e,this.value=o,this.prefix=i||"",this.cssStyle=n||"",this.prefixStyle=r||"prefix",this.type=s,this.mark=void 0,this.colSpan=l||1,this.measureScale=a||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,n=t.percent;return"decimal"===this.type&&(e=+e/this.measureScale,o=t.decimal,n=t.decimal),i.number(Number(e),this.type,o,n)}drawPrefix(){return null==this.prefix?"":this.prefix}}class B{constructor(t,e,o){this.index=t,this.groupindex=e,this.type=o,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case C.HEADER:return"groupheader";case C.SEPERATORLINE:return"";case C.DRILLELEMENT:return"ofit";case C.PARTELEMENT:return"partof";case C.STANDARD:return"";case C.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,e,o,n,s,i,r,l,a,c=!1,h,u=1,f){let d=i;"category"===e&&null!=l&&(d=`category-${l.toString()}`),this.type===C.HEADER?d="headerlabel":this.type===C.SEPERATORLINE&&(d=e),this.type===C.PARTELEMENT&&("percent"===n&&(t="-"),"category"!==e&&"operation"!==e&&(n="percent",d="")),"-"===t&&(d="");let p="prefix-first";r&&(p="prefix-second"),o&&(d=`${d} ${o}`);const $=new D(e,this.elements.length,t,d,n,s,p,u,a);$.isBarChart=c,$.columnStats=h,$.waterfall=f,this.elements.push($)}}const F={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},Y="#666666";function W(t,e){return`pattern-${t}-${e.replace("#","")}`}const H=({styles:e})=>{const o=e.scaleFactor,n=6*o,s=[{id:W("pos",e.positive.stroke),stroke:e.positive.stroke,fill:e.positive.fill},{id:W("neg",e.negative.stroke),stroke:e.negative.stroke,fill:e.negative.fill},{id:W("neu",e.neutral.stroke),stroke:e.neutral.stroke,fill:e.neutral.fill},...["ac","pp","fc","pl"].map((t=>({id:W(t,e.scenarios[t].stroke),stroke:e.scenarios[t].stroke,fill:e.scenarios[t].fill})))];return t("defs",null,s.map((e=>t("pattern",{id:e.id,patternUnits:"userSpaceOnUse",width:n,height:n},t("rect",{width:n,height:n,fill:"#ffffff"}),t("line",{x1:"0",y1:n,x2:n,y2:"0",stroke:e.stroke,"stroke-width":1.5*o})))))};function I(t,e,o=1){let n,s;const i=t>=0?"+":"";if(e)return n=100*t,i+Math.round(n).toString()+"%";{let e;return n=t/o,s=Math.abs(n),e=s>=1e9?(n/1e9).toFixed(s>=1e10?0:1)+"B":s>=1e6?(n/1e6).toFixed(s>=1e7?0:1)+"M":s>=1e3?(n/1e3).toFixed(s>=1e4?0:1)+"K":n.toFixed(s>=10?0:1),e=e.replace(/\.0([KMB]?)$/,"$1"),i+e}}function j(t){const e=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(e)}function z(t){const e=t.slice(0,2).toLowerCase();return"pp"===e?"pp":"fc"===e?"fc":"pl"===e?"pl":"ac"}function V(t,e,o,n){return j(t)?function(t,e){const o=z(t);return e.scenarios[o]}(t,n):function(t,e,o){const n=t>=0;return e?n?o.positive:o.negative:n?o.negative:o.positive}(e,o,n)}function Q(t,e){const o=t.fillpattern;return"hatched"===o?`url(#${W(e,t.stroke)})`:"outlined"===o?"transparent":t.fill}function q(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const K=e=>{const{value:o,scenario:n,columnStats:s,height:i,isPositiveGood:r,formattedValue:l,measureScale:a,maxBarWidth:c=10,styles:h=F}=e,u=h.scaleFactor,f=h.fontSize,d=38*u,p=c*f,$=4*u,m=.15*p,v=p-$-m,g=Math.abs(o)*h.unitScaling*f,R=g>v,w=Math.max(0,s.absMax*h.unitScaling*f-v),S=Math.max(0,g-v),E=w>0?S/w*m:0,b=s.min<0,y=s.max>0,O=b?p:0,M=(b?d:0)+(O+(y?p:0))+(y?d:0),U=2*u,T=i-2*U,G=(b?d:0)+O,_=U,N=o>=0,C=V(n,o,r,h),L=Q(C,j(n)?z(n):r?N?"pos":"neg":N?"neg":"pos"),{stroke:x,strokeWidth:k}=q(C),P=l||I(o,!1,a),A=R?v:g,D=R?v+$+E:g,B=N?G+D+4*u:G-D-4*u,W=N?"start":"end";return t("svg",{width:M,height:i,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},t(H,{styles:h}),t("line",{x1:G,y1:0,x2:G,y2:i,stroke:Y,"stroke-width":1*u}),A>0&&t("rect",{x:N?G:G-A,y:_,width:A,height:T,fill:L,stroke:x,"stroke-width":k*u}),R&&E>0&&t("rect",{x:N?G+v+$:G-v-$-E,y:_,width:E,height:T,fill:L,stroke:x,"stroke-width":k*u}),R&&function(e,o,n,s,i){const r=e+o/2,l=.35*o,a=s/3,c=.3*o;let h=`M ${r-l} ${n}`;for(let t=0;t<3;t++)h+=` L ${r-l-c} ${n+a*(t+.5)} L ${r-l} ${n+a*(t+1)}`;let u=`M ${r+l} ${n}`;for(let t=0;t<3;t++)u+=` L ${r+l+c} ${n+a*(t+.5)} L ${r+l} ${n+a*(t+1)}`;return[t("rect",{x:e,y:n-1,width:o,height:s+2,fill:"#ffffff"}),t("path",{d:h,fill:"none",stroke:"#000000","stroke-width":1*i}),t("path",{d:u,fill:"none",stroke:"#000000","stroke-width":1*i})]}(N?G+v:G-v-$,$,_,T,u),t("text",{x:B,y:i/2,dy:"0.35em","text-anchor":W,fill:h.fontColor,"font-size":f,"font-family":h.fontFamily},P))},X=e=>{const{value:o,scenario:n,columnStats:s,height:i,isPositiveGood:r,formattedValue:l,measureScale:a,maxBarWidth:c=10,styles:h=F}=e,u=h.scaleFactor,f=h.fontSize,d=Math.round(.67*c*f),p=5*u,$=s.min<0?d+p:0,m=$+(s.max>0?d+p:0),v=m+45*u,g=$,R=i/2,w=100*Math.abs(o)*h.percentageScaling*f,S=w>d,E=Math.min(w,d),b=o>=0,y=b?g+E:g-E,O=V(n,o,r,h),M=3*u,U=l||I(o,!0,a),T=m+4*u;return t("svg",{width:v,height:i,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},t("line",{x1:g,y1:0,x2:g,y2:i,stroke:Y,"stroke-width":1*u}),!S&&t("circle",{cx:y,cy:R,r:M,fill:h.fontColor}),t("line",{x1:g,y1:R,x2:y,y2:R,stroke:O.fill,"stroke-width":2*u}),S&&b&&t("polygon",{points:`${g+d},${R} ${g+d-6*u},${R-3*u} ${g+d-6*u},${R+3*u}`,fill:O.fill}),S&&!b&&t("polygon",{points:`${g-d},${R} ${g-d+6*u},${R-3*u} ${g-d+6*u},${R+3*u}`,fill:O.fill}),t("text",{x:T,y:i/2,dy:"0.35em","text-anchor":"start",fill:h.fontColor,"font-size":f,"font-style":"italic","font-family":h.fontFamily},U))},J=e=>{const{value:o,columnStats:n,isRelative:s,styles:i=F}=e;return null==o||isNaN(o)||!n||0===n.absMax?t("span",{class:"bar-chart-empty",style:{color:i.fontColor,fontStyle:"italic"}},"-"):t(s?X:K,Object.assign({},e))},Z=e=>{const{value:o,scenario:n,height:s,measureScale:i,maxBarWidth:r=10,styles:l=F,waterfall:a}=e,c=l.scaleFactor,h=l.fontSize,u=a.max-a.min;if(null==o||isNaN(o)||u<=0)return t("span",{class:"bar-chart-empty",style:{color:l.fontColor,fontStyle:"italic"}},"-");const f=38*c,d=r*h,p=f+d+f,$=d/u,m=t=>f+(t-a.min)*$,v=2*c,g=s-2*v,R=v,w=m(0),S=m(a.start),E=m(a.end),b=Math.min(S,E),y=Math.abs(E-S),O=V(n,o,!1,l),M=Q(O,z(n)),{stroke:U,strokeWidth:T}=q(O),G=I(o,"partof"===a.kind,i).replace(/^\+/,""),_=E<S,N=_?b-4*c:b+y+4*c,C=_?"end":"start";return t("svg",{width:p,height:s,class:"cell-bar-chart waterfall-bar",style:{overflow:"visible"}},t(H,{styles:l}),t("line",{x1:w,y1:0,x2:w,y2:s,stroke:Y,"stroke-width":1*c}),void 0!==a.parentStart&&void 0!==a.parentEnd&&t("line",{x1:m(a.parentStart),y1:0,x2:m(a.parentStart),y2:s,stroke:Y,"stroke-width":1*c,"stroke-dasharray":`${2*c},${2*c}`}),void 0!==a.parentStart&&void 0!==a.parentEnd&&t("line",{x1:m(a.parentEnd),y1:0,x2:m(a.parentEnd),y2:s,stroke:Y,"stroke-width":1*c,"stroke-dasharray":`${2*c},${2*c}`}),y>0&&t("rect",{x:b,y:R,width:y,height:g,fill:M,stroke:U,"stroke-width":T*c}),t("text",{x:N,y:s/2,dy:"0.35em","text-anchor":C,fill:l.fontColor,"font-size":h,"font-family":l.fontFamily},G))};class tt{constructor(t){this.groups=[r.CATEGORY,r.CATEGORYINDEX],_.OPT!==t.type&&_.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 et{constructor(t,e){this.hasPartOf=!1,this.config=t,this.i18n=e}execute(t,e){var o;this.db=t,this.fromExpr=e;const n=[],s=[],i=[],l=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),a=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 tt(this.config),f=this.config.grouped?[r.ROWGROUP,r.ROWGROUPINDEX]:[];let d,p=["",""];this.config.sortOrder.hierarchy.length>0&&(p=this.createOrderString(this.config.sortOrder)),this.hasPartOf=this.checkConfigForPartOf();try{d=t.exec(`SELECT COUNT(DISTINCT ${r.CATEGORY}) as ${r.TOTALROWCOUNT} ${f.length>0?","+f:""}\n FROM ${e} ${f.length>0?"GROUP BY "+f:""}\n ORDER BY ${p[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===f.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,n),this.createDataRow(n,t,u,l,h,e,p,o),this.createRestRow(t,n,u,l,e,p),this.createGroupSumRow(n,s,t,a,p)})),this.createTotalSumRow(n,s,a),n.forEach((e=>{try{i.push(t.exec(e))}catch(t){console.error("DataQuery: SQL query execution failed",e,t)}})),this.detectNaNCells(this.config.scenarios,i),this.createThereOfDrillRows(l,h,p,i),this.createPartOfDrillRows(l,p,s,i),this.createIntervalColumns(i),this.createThereOfDrillColumns(this.config.categoryThereOf,i),this.calculateColumnGroupRest(i,this.config.categoryThereOf),this.calculateRelativeVariances(i,c),i)}detectNaNCells(t,e){e.forEach((e=>{e.map((e=>(t.forEach((t=>{const o=new l(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,n){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===_.LIST)return;const s=this.createPartOfQuery(t,e);let i=[];const l=this.db;s.forEach((function(t){i.push(...l.exec(t))}));const a=this.exctractScenarioNames(t),c=[];o.forEach((function(t){c.push(...l.exec(t))}));const h=new Map;c.forEach((t=>h.set(t[r.ROWGROUP],t))),i=this.reduceResDrillByCategoryGroups(i,a),i.forEach((function(t){a.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(i,n)}createRestRow(t,e,o,n,s,i){if(t.totalRowCnt-this.config.limit>0&&0!==this.config.limit){const l=this.exctractScenarioNames(n).map((t=>`SUM(${t}) as ${t}`)).join(", ");e.push(`SELECT ${r.ROWNR}, 1 as ${r.ROWGROUPINDEX} , 'ENTRY' as ${r.TYPE}, 'NO_GROUP' as ${r.ROWGROUP}, 'REST' as ${r.CATEGORY} ${l.length>0?", "+l:""} FROM (SELECT ROWNUM() AS ${r.ROWNR}, ${e.length} as ${r.ROWGROUPINDEX} , 'ENTRY' as ${r.TYPE}, '${t.rowGroup||"NO_GROUP"}' as ${r.ROWGROUP}, ${o} ${n.length>0?",".concat(n):""} FROM ${this.fromExpr} ${s} GROUP BY ${o} ORDER BY ${i[0]}) t WHERE t.rowNr > ${this.config.limit}`)}}createDataRow(t,e,o,n,s,i,l,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} ${n.length>0?",".concat(n):""} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} ${i}\n GROUP BY ${o}\n ORDER BY ${l[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,n,s){!0!==this.config.grouped||_.SUM!==this.config.type&&_.SUMNOTOTAL!==this.config.type&&_.OPT!==this.config.type&&_.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} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr}\n WHERE ${r.ROWGROUP} = '${o.rowGroup}'\n ORDER BY ${s[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} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr}\n WHERE ${r.ROWGROUP} = '${o.rowGroup}'\n ORDER BY ${s[0]} `))}createTotalSumRow(t,e,o){var n;if(_.SUM===this.config.type||_.OPT===this.config.type){const e=(null===(n=this.config.title)||void 0===n?void 0:n.trim())||"SUM_TOTAL",s=this.hasPartOf&&!1===this.config.grouped&&"SUM_TOTAL"!==e?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} ${e}`:e;t.push(`SELECT ${t.length} as ${r.ROWGROUPINDEX},\n '${s}' 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 n=t.rowNr+t.rowGroup+t.type+t.category;if(o.has(n)){const s=o.get(n);e.forEach((e=>{try{s[e]+=t[e]}catch(t){console.error("DataQuery: drill row aggregation failed",e,t)}}))}else o.set(n,t)})),[...o.values()]}injectDrillRowsToResultRows(t,e){const o=new Map;if(!0===this.config.grouped)t.forEach((function(t){e.forEach((function(e){const n=e.findIndex((e=>e.category===t.category&&e.rowGroup===t.rowGroup));if(n>=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(n+t[r.ROWNR],0,t)}}))}));else{const n=this.findDuplicateSubCategories(t);t.forEach((function(t){e.forEach((function(e){const s=e.findIndex((e=>null!=e.category&&e.category===t.category));if(s>=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]||n.includes(t.subCategory))&&(t.subCategory=`${t.subCategory} (${t.rowGroup})`),e.splice(s+t[r.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,e,o,n){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const s=[],i=[];this.config.thereOf.forEach((n=>{let i=!0,l="1 <> 1 OR ( ";null!=n.category&&0!==n.category.length&&n.category.trim()&&(l+=` ${r.CATEGORY} = '${n.category}'`,i=!1),null!=n.rowGroup&&0!==n.rowGroup.length&&n.rowGroup.trim()&&(l+=` ${i?"":"AND"} ${r.ROWGROUP} = '${n.rowGroup}'`,i=!1),null!=n.subCategory&&0!==n.subCategory.length&&n.subCategory.trim()&&(l+=` ${i?"":"AND"} ${r.SUBCATEGORY} = '${n.subCategory}'`),l+=")",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} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr}\n WHERE ${l}\n GROUP BY ${r.ROWGROUP}, ${r.CATEGORY}, ${r.SUBCATEGORY}\n ORDER BY ${o[1]}`)}));const l=this.db;s.forEach((function(t){i.push(...l.exec(t))})),this.injectDrillRowsToResultRows(i,n)}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,n=new Map;e.forEach(((t,e)=>{const s=t,i=[];for(const t of s)i.push(`${e}##${t.name}`);o.set(e,i),n.set(`${e}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[r.TYPE]&&o.forEach(((e,o)=>{let s=0;e.forEach((e=>{void 0!==t[e]&&(s+=t[e])})),t[`${o}##REST`]=t[o]-s,0!==t[`${o}##REST`]&&n.set(`${o}##REST`,!0)}))}))}));const s=Array.from(n.entries()).filter((([t,e])=>!e)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const e of s)delete t[e]}))}))}createIntervalColumns(t){var e,o,n,s,i;if(this.config.interval===L||this.config.categoryThereOf.size>0||0===this.config.scenarios.length)return;const a="##",c=`(SELECT *, ${k(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`,h=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),u=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),f=this.exctractScenarioNames(h),d=this.getRelativeScenarios(),p=new tt(this.config),$=_.OPT===this.config.type||_.OPTNOTOTAL===this.config.type,m=this.config.grouped&&(_.SUM===this.config.type||_.SUMNOTOTAL===this.config.type||_.OPT===this.config.type||_.OPTNOTOTAL===this.config.type),v=this.checkConfigForPartOf()&&this.config.type!==_.LIST,g=t=>{try{return this.db.exec(t)}catch(e){return console.error("DataQuery: interval query failed",t,e),[]}},R=t=>(this.config.scenarios.forEach((e=>{const o=new l(e);!0===o.isValid?0!==t[o.base+"_cnt"]&&0!==t[o.delta+"_cnt"]||(t[e]=Number.NaN):0===t[e+"_cnt"]&&(t[e]=Number.NaN)})),d.forEach(((e,o)=>{t[o]=t[o]/t[e]})),t),w=(t,e,o)=>{for(const n of this.config.scenarios)t[n+a+o]=e[n]},S=g(`SELECT ${p}, __interval ${h.length>0?",".concat(h):""}\n FROM ${c}\n GROUP BY ${p}, __interval`);if(this.config.limit>0)for(let n=0;n<t.length;n++){const s=t[n].find((t=>"ENTRY"===t.type&&"REST"===t.category));if(!s)continue;let i;for(let e=n-1;e>=0&&!i;e--){const o=t[e].filter((t=>"ENTRY"===t.type&&"REST"!==t.category));o.length>0&&(i=o)}if(!i)continue;const r=new Set(i.map((t=>t.category))),l=i[0].rowGroup,a=new Map;for(const t of S){if(this.config.grouped&&t.rowGroup!==l)continue;if(r.has(t.category))continue;const n=P(t.__interval);let s=a.get(n);s||(s={},a.set(n,s));for(const n of f)s[n]=(null!==(e=s[n])&&void 0!==e?e:0)+(null!==(o=t[n])&&void 0!==o?o:0)}a.forEach(((t,e)=>{w(s,R(t),e)}))}for(const e of S){const o=P(e.__interval);R(e);for(const n of t)for(const t of n)"ENTRY"===t.type&&"REST"!==t.category&&t.category===e.category&&(this.config.grouped&&t.rowGroup!==e.rowGroup||$&&t.operation!==e.operation||w(t,e,o))}const E=m||v&&this.config.grouped?g(`SELECT ${r.ROWGROUP}, __interval ${u.length>0?",".concat(u):""}\n FROM ${c}\n GROUP BY ${r.ROWGROUP}, __interval`):[],b=new Map;if(E.forEach((t=>b.set(`${t.rowGroup}${a}${P(t.__interval)}`,t))),m)for(const e of E){const o=P(e.__interval),n=R(Object.assign({},e));for(const s of t)for(const t of s)"GROUP_SUM"===t.type&&t.rowGroup===e.rowGroup&&w(t,n,o)}const y=_.SUM===this.config.type||_.OPT===this.config.type,O=y||v&&!this.config.grouped?g(`SELECT __interval ${u.length>0?",".concat(u):""}\n FROM ${c}\n GROUP BY __interval`):[],M=new Map;if(O.forEach((t=>M.set(P(t.__interval),t))),y)for(const e of O){const o=P(e.__interval),n=R(Object.assign({},e));for(const e of t)for(const t of e)"SUM"===t.type&&w(t,n,o)}if(null!=this.config.thereOf&&this.config.thereOf.length>0){const e=[];this.config.thereOf.forEach((t=>{e.push(...g(`SELECT ${r.ROWGROUP}, ${r.CATEGORY}, ${r.SUBCATEGORY}, __interval ${h.length>0?",".concat(h):""}\n FROM ${c}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${r.ROWGROUP}, ${r.CATEGORY}, ${r.SUBCATEGORY}, __interval`))}));for(const o of e){const e=P(o.__interval);R(o);for(const n of t)for(const t of n)"DRILLELEMENT"===t.type&&t.category===o.category&&(t.subCategory!==o.subCategory&&t.subCategory!==`${o.subCategory} (${o.rowGroup})`||w(t,o,e))}}if(v){let e="1 <> 1 ";null===(n=this.config.partOf)||void 0===n||n.forEach((t=>{e+=`OR (${r.CATEGORY} = '${t.category}'`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(e+=`and ${r.ROWGROUP} = '${t.rowGroup}'`),e+=")"}));const o=g(`SELECT ${r.CATEGORY}, ${this.config.grouped?`${r.ROWGROUP}`:`'SUM_TOTAL' as ${r.ROWGROUP}`}, __interval ${h.length>0?",".concat(h):""}\n FROM ${c}\n WHERE ${e}\n GROUP BY ${r.ROWGROUP}, ${r.CATEGORY}, __interval`),l=new Map;for(const t of o){const e=`${t.rowGroup}${a}${t.category}${a}${P(t.__interval)}`,o=l.get(e);if(o)for(const e of f)o[e]=(null!==(s=o[e])&&void 0!==s?s:0)+(null!==(i=t[e])&&void 0!==i?i:0);else l.set(e,t)}l.forEach((e=>{const o=P(e.__interval),n=this.config.grouped?b.get(`${e.rowGroup}${a}${o}`):M.get(o);for(const t of f)e[t]=e[t]/(n?n[t]:Number.NaN);R(e);for(const n of t)for(const t of n)"PARTELEMENT"===t.type&&t.category===e.category&&t.rowGroup===e.rowGroup&&w(t,e,o)}))}}createThereOfWhereClause(t){let e=!0,o="1 <> 1 OR ( ";return null!=t.category&&0!==t.category.length&&t.category.trim()&&(o+=` ${r.CATEGORY} = '${t.category}'`,e=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(o+=` ${e?"":"AND"} ${r.ROWGROUP} = '${t.rowGroup}'`,e=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(o+=` ${e?"":"AND"} ${r.SUBCATEGORY} = '${t.subCategory}'`),o+")"}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 n=new l(t);return _.OPT===o||_.OPTNOTOTAL===o?n.isValid?"dr"===n.type?`SUM(${n.base} - ${n.delta}) as ${t}, SUM(${n.delta}) as dr_${n.delta}`:`SUM(${n.base} - ${n.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`:n.isValid?"dr"===n.type?`SUM((${n.base} * transformOperator(operation)) - (${n.delta} * transformOperator(operation))) as ${t}, SUM(${n.delta} * transformOperator(operation)) as dr_${n.delta}`:`SUM((${n.base} * transformOperator(operation))- (${n.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}translateAttributeSQL(t){const e=`[${t.arg}]`,o=/^(ac|pp|fc|pl)[1-4]$/.test(t.arg)&&this.config.type!==_.OPT&&this.config.type!==_.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 o?`AVG(${e} * transformOperator(operation)) as ${t.alias}`:`AVG(${e}) as ${t.alias}`;case"sum":return o?`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()} ${N.ASC===t.direction?N.DESC:N.ASC}`]}createRelativeScenario(t){const e=new l(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 n=[];let s="1 <> 1 ",i=` ${r.ROWGROUP}`,l="ROWNUM()";return null===(o=this.config.partOf)||void 0===o||o.forEach((t=>{s+=`OR (${r.CATEGORY} = '${t.category}'`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(s+=`and ${r.ROWGROUP} = '${t.rowGroup}'`),!1===this.config.grouped&&(i=` 'SUM_TOTAL' as ${r.ROWGROUP} `,l="1"),s+=")"})),n.push(`SELECT ${l} AS ${r.ROWNR},\n 'PARTELEMENT' as ${r.TYPE},\n ${r.CATEGORY},\n ${i},\n ${t}\n FROM ${this.fromExpr}\n WHERE ${s}\n GROUP BY ${r.ROWGROUP}, ${r.CATEGORY}, ${r.TYPE}\n ORDER BY ${e[1]}`),n}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,e){if(null==t||0===t.size)return;const o=[],n=[],s=this.fromExpr;t.forEach(((t,e)=>{let n="1 <> 1 ";t.forEach((t=>{n+=` 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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of o)n.push(...this.db.exec(t));this.injectDrillColumnsToResultRows(n,e)}injectDrillColumnsToResultRows(t,e){const o="##";for(const n of t)for(const t of e)for(const e of t)e.type===n.rowlevel&&("ENTRY"===n.rowlevel?"COLUMNGROUP"===n.columnlevel&&e.category===n.category?e[n.scenario+o+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&(e[n.scenario+o+n.columnGroup+o+n.columnSubGroup]=n.val):"DRILLELEMENT"===n.rowlevel?"COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory?e[n.scenario+o+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory?e[n.scenario+o+n.columnGroup+o+n.columnSubGroup]=n.val:"COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===`${n.subCategory} (${n.rowGroup})`?e[n.scenario+o+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===`${n.subCategory} (${n.rowGroup})`&&(e[n.scenario+o+n.columnGroup+o+n.columnSubGroup]=n.val):("SUM"===n.rowlevel||"GROUP_SUM"===n.rowlevel)&&("COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory&&(e[n.scenario+o+n.columnGroup]=n.val),"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory&&(e[n.scenario+o+n.columnGroup+o+n.columnSubGroup]=n.val)))}}class ot{constructor(){this.geometry=new Map}set(t,e,o){let n=this.geometry.get(t);n||(n=new Map,this.geometry.set(t,n)),n.set(e,o)}get(t,e){var o;return null===(o=this.geometry.get(t))||void 0===o?void 0:o.get(e)}}function nt(t,e,o){const n=t[e];if(null==n)return null;const s=Number(n);return isNaN(s)?null:o!==_.OPT&&o!==_.OPTNOTOTAL||t[r.TYPE]!==C.ENTRY||"-"!==t[r.OPERATION]?s:-s}class st{constructor(){this.normalizedHeader=[],this.attributesByAlias=new Map}createHeader(t,e,o,n,s,r,l=[]){const a=[];this.attributesByAlias=new Map(l.map((t=>[t.alias,t]))),this.normalizedHeader=this.normalizeHeader(t,e,l);const c=this.normalizedHeader.some((t=>void 0!==t.bucket));c&&a.push(this.createIntervalBandRow());const h=new B(c?1:0,0,C.HEADER),u=new B(c?2:1,0,C.SEPERATORLINE);for(const t of this.normalizedHeader){const e=this.attributesByAlias.get(t.name);h.createElement(e?o.get(e.label)||e.label:i.translateScenarioLabel(t.name,o),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,o,n,s,r),null,null,null,null),u.createElement(null,t.type,this.createColumnType(t),null,null,null,null,null,null)}return a.push(h),a.push(u),a}createIntervalBandRow(){const t=new B(0,0,C.HEADER);let e=0;for(;e<this.normalizedHeader.length;){const o=this.normalizedHeader[e];if(void 0===o.bucket){t.createElement(null,o.type,"filler",null,null,null,null,null,null),e+=1;continue}let n=1;for(;e+n<this.normalizedHeader.length&&this.normalizedHeader[e+n].bucket===o.bucket;)n+=1;t.createElement(o.bucketLabel,o.type,"intervalGroup",null,null,null,null,null,null,!1,void 0,n),e+=n}return t}setHeaderPrefix(t,e,o,n,s){let r="";return"category"===t.name&&s&&(0===o.prefix.length&&0===n.length||(r=i.translateScenarioLabel("in",e)+" "+o.prefix+n)),t.order&&(r+=i.translateScenarioLabel("ORDER_"+t.order,e)),r}normalizeHeader(t,e,o){let n=[{name:r.CATEGORY,group:r.CATEGORY,type:r.CATEGORY,order:void 0}];_.OPT!==t&&_.OPTNOTOTAL!==t||(n=[{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 s=o.map((t=>({name:t.alias,group:t.alias,type:t.alias,order:void 0})));return[...n,...s,...e]}createBodyRows(t,e,o,n){var s;const i=[];let l=-1;const a=new et(t,e).execute(o,n),h=this.calculateColumnStatistics(a,t.barColumns,t.interval!==L),u=(null!==(s=t.barColumns)&&void 0!==s?s:[]).filter((t=>t.toUpperCase().trim()in c)),f=u.length>0&&t.interval===L&&0===t.categoryThereOf.size&&function(t){for(const e of t)for(const t of e){const e=t[r.TYPE];if(e===C.SUM||e===C.GROUPSUM||e===C.DRILLELEMENT||e===C.PARTELEMENT)return!0}return!1}(a)?function(t,e,o){const n=new ot;for(const s of e){let e,i=0,l=0;const a=[],c=(t,e)=>{a.push(e),n.set(t,s,e)};for(const n of t)for(const t of n){const n=t[r.TYPE];if(n===C.GROUPHEAD){e=void 0;continue}const a=nt(t,s,o);if(n===C.ENTRY){if(null===a){e=void 0;continue}c(t,{start:i,end:i+a,min:0,max:0,kind:"cascade"}),e={start:i,end:i+a},l=e.start,i+=a}else if(n===C.SUM||n===C.GROUPSUM){if(null===a){e=void 0;continue}c(t,{start:0,end:a,min:0,max:0,kind:"anchor"}),e={start:0,end:a},l=0,i=a}else if(n===C.DRILLELEMENT){if(null===a||void 0===e)continue;const o=l+(Math.sign(e.end-e.start)||1)*Math.abs(a);c(t,{start:l,end:o,min:0,max:0,kind:"thereof",parentStart:e.start,parentEnd:e.end}),l=o}else if(n===C.PARTELEMENT){if(null===a||void 0===e)continue;const o=l+a*(e.end-e.start);c(t,{start:l,end:o,min:0,max:0,kind:"partof",parentStart:e.start,parentEnd:e.end}),l=o}}let h=0,u=0;for(const t of a)h=Math.min(h,t.start,t.end),u=Math.max(u,t.start,t.end);for(const t of a)t.min=h,t.max=u}return n}(a,u,t.type):void 0;for(const o of a)l+=1,i.push(...this.createRow(t.i18n,e,t.scenariosUnitType,o,l,-1,t.categoryWidth,t.measureScale,t.barColumns,h,f));return i}calculateColumnStatistics(t,e,o=!1){const n=new Map;if(!e||0===e.length)return n;const s=new Map;for(const t of e)n.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=o?this.extractIntervalColumnValues(t,i):[this.extractColumnValue(t,i)];for(const t of e)if(null!==t&&!isNaN(t)){const e=n.get(i);e.min=Math.min(e.min,t),e.max=Math.max(e.max,t),s.get(i).push(Math.abs(t))}}for(const[t,e]of n){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 o=s.get(t);if(o.length>0){o.sort(((t,e)=>t-e));const t=Math.floor(o.length/2);e.median=o.length%2==0?(o[t-1]+o[t])/2:o[t]}n.set(t,e)}return n}extractIntervalColumnValues(t,e){const o=e+"##",n=[];for(const e of Object.keys(t))if(e.startsWith(o)){const o=Number(t[e]);n.push(isNaN(o)?null:o)}return n}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,n,s,i,l,a,c,h,u){var f;const d=[];for(const p of n){const $=p[r.ROWGROUP],m=p[r.SUBCATEGORY],v=p[r.TYPE],g=p[r.ROWNR]>=2,R=this.createDetailRow(v,i+=1,s,n.length);for(const n of this.normalizedHeader){const s=this.getRawDataRowElement(p,n),i=null!==(f=null==c?void 0:c.includes(n.type))&&void 0!==f&&f,r=i?null==h?void 0:h.get(n.type):void 0,d=i&&void 0===n.bucket&&n.name===n.group&&n.name===n.type?null==u?void 0:u.get(p,n.type):void 0;R.createElement(this.translateSumCellLabel(t,e,s,$,m,v,n.type),n.type,this.createColumnType(n),this.setCellType(n.type,o),this.translateCellPrefix(e,v,n.type),this.translateScenarioCSS(n.type,s),g,l,null==a?void 0:a.value,i,r,1,d)}d.push(R)}return d}getRawDataRowElement(t,e){return void 0!==e.bucket?t[e.type+"##"+e.bucket]: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,n){switch(t){case C.GROUPHEAD:return new B(e,o,C.HEADER);case C.SUM:case C.GROUPSUM:return new B(n+2,o,C.SUM);case C.DRILLELEMENT:return new B(n+2,o,C.DRILLELEMENT);case C.PARTELEMENT:return new B(n+2,o,C.PARTELEMENT);default:return new B(e,o,C.STANDARD)}}translateSumCellLabel(t,e,o,n,s,i,r){return this.attributesByAlias.has(r)||!1===Number.isNaN(Number(o))||this.isOperationColumn(r)?o:this.isGroupHeadCategory(i,r)||this.isEntryCategory(i,r)?t===h.ALL?`${e.get(o)||o}`:o:this.isDrillElementCategory(i,r)?t===h.ALL?`${e.get(s)||s}`:`${s}`:this.isPartElementCategory(i,r)?t===h.ALL||"SUM_TOTAL"===n?`${e.get(n)||n}`:`${n}`:this.isSumElementCategory(i,r)?t===h.ALL||"SUM_TOTAL"===n?`${e.get(n)||n}`:n:"GROUPHEAD"===i&&null==o?o:Number.isNaN(Number(o))?"-":Number(o)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,e){if(this.attributesByAlias.has(t))return"attribute";const o=new l(t);let n="pos";return e<0&&(n="neg"),o.isValid?n+"_"+o.direction+("dr"===o.type?" relative_variance":""):t}setCellType(t,e){if("category"===t)return"";const o=this.attributesByAlias.get(t);if(o)return o.isNumeric?"decimal":"";let n;const s=new l(t);return e===u.PERCENT?(n="percent",s.isValid&&"d"===s.type&&(n="decimal")):(n="decimal",s.isValid&&"dr"===s.type&&(n="percent")),n}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 it{constructor(t,e,o,n){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new a,this.db=e,this.dataSetFactory=new st,this.config=this.initConfig(n),this.i18n=this.initI18n(new Map),this.setSource(o,n.filter),this.state=G.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=G.DIRTY,new Map([...e,...t||new Map])}initConfig(t){this.state=G.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,n;if(!t)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=g(t,e);try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(n=null===(o=t[0])||void 0===o?void 0:o.cnt)&&void 0!==n?n:0}catch(t){this.rowCount=0}this.prepareIntervalBuckets();const s=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder,this.intervalBuckets);this.headerRows=this.dataSetFactory.createHeader(this.config.type,s,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=G.UP_TO_DATE}update(){this.prepareIntervalBuckets();const t=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder,this.intervalBuckets);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=G.UP_TO_DATE}getHeader(){return this.state===G.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===G.DIRTY&&this.update(),this.bodyRows}prepareIntervalBuckets(){this.intervalBuckets=[],this.config.interval===L||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=L:(this.config.interval=function(t,e,o){var n;if(o!==m.AUTO)return o;let s,i,r;try{s=t.exec(`SELECT [date] as d FROM ${e}`)}catch(t){return console.error("IntervalColumns: date query failed",t),m.DAY}for(const t of s){const e=null===(n=A(t.d))||void 0===n?void 0:n.toMillis();void 0!==e&&(i=void 0===i?e:Math.min(i,e),r=void 0===r?e:Math.max(r,e))}return void 0===i||void 0===r?m.DAY:(new v).calculateDistanceType($.fromMillis(i),$.fromMillis(r))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,e,o,n){let s;try{s=t.exec(`SELECT ${k(o)} as __interval FROM ${e}`)}catch(t){return console.error("IntervalColumns: bucket query failed",t),[]}if(o===x){const t=new Set,e=[];for(const o of s){const n=P(o.__interval);t.has(n)||(t.add(n),e.push({key:n,label:0===n.length?"—":n}))}return e}const i=new Set,r=[];for(const t of s){const e=A(t.__interval);if(!e)continue;const o=e.toISO();i.has(o)||(i.add(o),r.push(e))}r.sort(((t,e)=>t.toMillis()-e.toMillis()));const l=new v;return l.setLocale(n),r.map((t=>({key:t.toISO(),label:l.getDateString(t,o)})))}(this.db,this.fromExpr,this.config.interval,this.config.locale),0===this.intervalBuckets.length&&(this.config.interval=L))}normalizeScenarios(t,e,o,n=[]){var s,i;const r=[];if(n.length>0){for(const e of n)for(const n of t)r.push({name:n,group:n,type:n,order:(null===(s=null==o?void 0:o.hierarchy)||void 0===s?void 0:s.at(0))===n?o.direction:void 0,bucket:e.key,bucketLabel:e.label});return r}for(const n of t){if(null==e?void 0:e.has(n)){const t=e.get(n);for(const e of t){r.push({name:e.name,group:e.name,type:n,order:void 0});for(const t of e.subGroups)r.push({name:t,group:e.name,type:n,order:void 0})}r.push({name:"REST",group:"REST",type:n,order:void 0})}let t;(null===(i=null==o?void 0:o.hierarchy)||void 0===i?void 0:i.at(0))===n&&(t=o.direction),r.push({name:n,group:n,type:n,order:t})}return r}hasNoData(){return 0===this.rowCount}}class rt{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 y(new O).default(),this.type=_.LIST,this.limit=0,this.i18n=h.ALL,this.categoryWidth=d.W25,this.measureScale=new M,this.measureUnit="",this.measureType=p.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.locale="de"}}class lt{constructor(t,e,o,n,s){this.tableDrillGroupAdapter=t,this.stringAdapter=e,this.orderAdapter=o,this.db=n,this.fromExpr=s}adapt(t){const e=new rt;return f.isString(t.title)&&(e.title=t.title),f.isArray(t.scenarios)&&(e.scenarios=b.adaptArray(t.scenarios,this.stringAdapter)),f.isExisting(t.scenariosUnitType)&&(e.scenariosUnitType=t.scenariosUnitType),f.isBoolean(t.grouped)&&(e.grouped=t.grouped),f.isBoolean(t.showGroupTitle)&&(e.showGroupTitle=t.showGroupTitle),f.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),f.isArray(t.thereOf)&&(e.thereOf=b.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),f.isExisting(t.categoryThereOf)&&(e.categoryThereOf=t.categoryThereOf),f.isArray(t.partOf)&&(e.partOf=b.adaptArray(t.partOf,this.tableDrillGroupAdapter)),f.isArray(t.attributes)&&(e.attributes=t.attributes),f.isExisting(t.order)&&(e.sortOrder=this.orderAdapter.adapt(t.order)),f.isExisting(t.type)&&(e.type=t.type),f.isNumber(t.limit)&&(e.limit=t.limit),f.isExisting(t.i18n)&&(e.i18n=t.i18n),f.isExisting(t.categoryWidth)&&(e.categoryWidth=t.categoryWidth),f.isExisting(t.measureScale)&&(e.measureScale=w.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale)),f.isExisting(t.measureType)&&(e.measureType=t.measureType),f.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),f.isString(t.filter)&&(e.filter=t.filter.trim()),f.isArray(t.barColumns)&&(e.barColumns=t.barColumns),f.isString(t.interval)&&(e.interval=t.interval),f.isString(t.locale)&&(e.locale=t.locale),e}default(){return new rt}}class at{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class ct{constructor(){}adapt(t){const e=new at;return f.isString(t.rowGroup)&&(e.rowGroup=t.rowGroup),f.isString(t.category)&&(e.category=t.category),f.isString(t.subCategory)&&(e.subCategory=t.subCategory),f.isString(t.partOf)&&(e.partOf=t.partOf),e}default(){return new at}}const ht=e(class extends o{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.sumTitle="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:N.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=_.LIST,this.categoryWidth=d.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=h.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=p.VOLUME,this.filter="",this.barColumns=[],this.interval="none",this.barColumnMaxWidth=30,this.unitScaling=.01,this.percentageScaling=.5,this.scaleFactor=1,this.componentDataFormatDigits=new S,this.componentStyle=U(this)}render(){return t(n,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,n,s)=>t("span",null,n===s.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&&(void 0!==o.waterfall||e.type!==C.SUM)?void 0!==o.waterfall?t(Z,{value:o.value,scenario:o.key,columnStats:o.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:o.key.endsWith("_pos"),measureScale:o.measureScale,maxBarWidth:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:o.waterfall}):t(J,{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=R(this.element));const t=this.stores.db.db,e=this.prepareConfig(t);this.componentDataFormatDigits=(new E).adapt(this.dataFormatDigits),this.table=new it(new a(this.ruleSetConfig),t,this.tableName,e),this.table.setI18n(this.i18n),this.barChartStyles=this.prepareBarChartStyles()}prepareConfig(t){var e,o,n;const s=this.tableName?this.filter&&this.filter.length>0?`(SELECT * FROM \`${this.tableName}\` WHERE ${this.filter}) AS __src`:`\`${this.tableName}\``:"";return new lt(new ct,new O,new y(new O),t,s).adapt({title:this.sumTitle,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,interval:this.interval,locale:(null===(n=null===(o=null===(e=this.stores)||void 0===e?void 0:e.context)||void 0===o?void 0:o.state)||void 0===n?void 0:n.locale)||"de"})}prepareBarChartStyles(){return this.componentStyle((t=>{var e,o,n,s,i,r,l,a,c,h,u,f,d,p,$,m,v,g,R,w,S,E,b,y,O,M;const U=null===(e=t["bn-chart-time"])||void 0===e?void 0:e.varianceStyles,T=null===(o=t["bn-chart-time"])||void 0===o?void 0:o.barStyles;return{positive:{stroke:(null===(n=null==U?void 0:U.pos)||void 0===n?void 0:n.stroke)||"#008f96",fill:(null===(s=null==U?void 0:U.pos)||void 0===s?void 0:s.fill)||"#008f96",fillpattern:(null===(i=null==U?void 0:U.pos)||void 0===i?void 0:i.fillpattern)||"solid"},negative:{stroke:(null===(r=null==U?void 0:U.neg)||void 0===r?void 0:r.stroke)||"#ff0000",fill:(null===(l=null==U?void 0:U.neg)||void 0===l?void 0:l.fill)||"#ff0000",fillpattern:(null===(a=null==U?void 0:U.neg)||void 0===a?void 0:a.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===(f=null==T?void 0:T.ac)||void 0===f?void 0:f.stroke)||"#404040",fill:(null===(d=null==T?void 0:T.ac)||void 0===d?void 0:d.fill)||"#404040",fillpattern:(null===(p=null==T?void 0:T.ac)||void 0===p?void 0:p.fillpattern)||"solid"},pp:{stroke:(null===($=null==T?void 0:T.pp)||void 0===$?void 0:$.stroke)||"#A6A6A6",fill:(null===(m=null==T?void 0:T.pp)||void 0===m?void 0:m.fill)||"#A6A6A6",fillpattern:(null===(v=null==T?void 0:T.pp)||void 0===v?void 0:v.fillpattern)||"solid"},fc:{stroke:(null===(g=null==T?void 0:T.fc)||void 0===g?void 0:g.stroke)||"#404040",fill:(null===(R=null==T?void 0:T.fc)||void 0===R?void 0:R.fill)||"#ffffff",fillpattern:(null===(w=null==T?void 0:T.fc)||void 0===w?void 0:w.fillpattern)||"hatched"},pl:{stroke:(null===(S=null==T?void 0:T.pl)||void 0===S?void 0:S.stroke)||"#404040",fill:(null===(E=null==T?void 0:T.pl)||void 0===E?void 0:E.fill)||"#ffffff",fillpattern:(null===(b=null==T?void 0:T.pl)||void 0===b?void 0:b.fillpattern)||"outlined"}},fontColor:(null===(y=t.global)||void 0===y?void 0:y.fontColor)||"#000000",fontSize:.85*((null===(O=t.global)||void 0===O?void 0:O.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!==C.SUM)for(const o of e.getCells())o.isBarChart&&o.columnStats&&!o.key.startsWith("dr")&&!o.waterfall&&(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!==C.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}th.intervalGroup{border-bottom:0.1em solid black;text-align:center;font-weight:bold}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"],selectedStyle:[513,"selected-style"],sumTitle:[1,"sum-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],ruleSetConfig:[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],interval:[1],barColumnMaxWidth:[2,"bar-column-max-width"],unitScaling:[2,"unit-scaling"],percentageScaling:[2,"percentage-scaling"],scaleFactor:[2,"scale-factor"]}]);function ut(){"undefined"!=typeof customElements&&["ibcs-table"].forEach((t=>{"ibcs-table"===t&&(customElements.get(s(t))||customElements.define(s(t),ht))}))}export{ht as I,_ as T,L as a,x as b,ut as d}
1
+ import{h as t,proxyCustomElement as e,HTMLElement as o,Host as n,transformTag as s}from"@stencil/core/internal/client";import{F as i,Q as r,V as l,I as a}from"./formatter.js";import{S as c,I as h,D as u,C as f,d,M as p}from"./CompareUtil.js";import{D as $}from"./luxon.js";import{a as m,b as v}from"./DateStringFactory.js";import{d as R,g}from"./context-protocol.js";import{D as w,a as S,b as E}from"./DataFormatDigits.js";import{A as b,c as y}from"./Order.js";import{S as O}from"./StringAdapter.js";import{S as M}from"./SiPrefix.js";import{w as U}from"./withComponentStyle.js";var T,G,_,N,C;!function(t){t[t.ALL=-1]="ALL"}(T||(T={})),function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(G||(G={})),function(t){t.LIST="list",t.SUM="sum",t.SUMNOTOTAL="sumnototal",t.OPT="opt",t.OPTNOTOTAL="optnototal"}(_||(_={})),function(t){t.ASC="asc",t.DESC="desc"}(N||(N={})),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"}(C||(C={}));const L="none",x="setname";function k(t){return t===x?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function P(t){if(null==t)return"";if("string"==typeof t)return t.trim();const e=A(t);return e?e.toISO():String(t)}function A(t){if(null!=t){if("string"==typeof t){const e=$.fromISO(t);return e.isValid?e:void 0}if("number"==typeof t){const e=$.fromMillis(t);return e.isValid?e:void 0}if("boolean"==typeof t.isValid)return t.isValid?t:void 0}}class D{constructor(t,e,o,n,s,i,r,l,a){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=e,this.value=o,this.prefix=i||"",this.cssStyle=n||"",this.prefixStyle=r||"prefix",this.type=s,this.mark=void 0,this.colSpan=l||1,this.measureScale=a||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,n=t.percent;return"decimal"===this.type&&(e=+e/this.measureScale,o=t.decimal,n=t.decimal),i.number(Number(e),this.type,o,n)}drawPrefix(){return null==this.prefix?"":this.prefix}}class B{constructor(t,e,o){this.index=t,this.groupindex=e,this.type=o,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case C.HEADER:return"groupheader";case C.SEPERATORLINE:return"";case C.DRILLELEMENT:return"ofit";case C.PARTELEMENT:return"partof";case C.STANDARD:return"";case C.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,e,o,n,s,i,r,l,a,c=!1,h,u=1,f){let d=i;"category"===e&&null!=l&&(d=`category-${l.toString()}`),this.type===C.HEADER?d="headerlabel":this.type===C.SEPERATORLINE&&(d=e),this.type===C.PARTELEMENT&&("percent"===n&&(t="-"),"category"!==e&&"operation"!==e&&(n="percent",d="")),"-"===t&&(d="");let p="prefix-first";r&&(p="prefix-second"),o&&(d=`${d} ${o}`);const $=new D(e,this.elements.length,t,d,n,s,p,u,a);$.isBarChart=c,$.columnStats=h,$.waterfall=f,this.elements.push($)}}const F={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},Y="#666666";function W(t,e){return`pattern-${t}-${e.replace("#","")}`}const H=({styles:e})=>{const o=e.scaleFactor,n=6*o,s=[{id:W("pos",e.positive.stroke),stroke:e.positive.stroke,fill:e.positive.fill},{id:W("neg",e.negative.stroke),stroke:e.negative.stroke,fill:e.negative.fill},{id:W("neu",e.neutral.stroke),stroke:e.neutral.stroke,fill:e.neutral.fill},...["ac","pp","fc","pl"].map((t=>({id:W(t,e.scenarios[t].stroke),stroke:e.scenarios[t].stroke,fill:e.scenarios[t].fill})))];return t("defs",null,s.map((e=>t("pattern",{id:e.id,patternUnits:"userSpaceOnUse",width:n,height:n},t("rect",{width:n,height:n,fill:"#ffffff"}),t("line",{x1:"0",y1:n,x2:n,y2:"0",stroke:e.stroke,"stroke-width":1.5*o})))))};function I(t,e,o=1){let n,s;const i=t>=0?"+":"";if(e)return n=100*t,i+Math.round(n).toString()+"%";{let e;return n=t/o,s=Math.abs(n),e=s>=1e9?(n/1e9).toFixed(s>=1e10?0:1)+"B":s>=1e6?(n/1e6).toFixed(s>=1e7?0:1)+"M":s>=1e3?(n/1e3).toFixed(s>=1e4?0:1)+"K":n.toFixed(s>=10?0:1),e=e.replace(/\.0([KMB]?)$/,"$1"),i+e}}function j(t){const e=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(e)}function z(t){const e=t.slice(0,2).toLowerCase();return"pp"===e?"pp":"fc"===e?"fc":"pl"===e?"pl":"ac"}function V(t,e,o,n){return j(t)?function(t,e){const o=z(t);return e.scenarios[o]}(t,n):function(t,e,o){const n=t>=0;return e?n?o.positive:o.negative:n?o.negative:o.positive}(e,o,n)}function Q(t,e){const o=t.fillpattern;return"hatched"===o?`url(#${W(e,t.stroke)})`:"outlined"===o?"transparent":t.fill}function q(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const K=e=>{const{value:o,scenario:n,columnStats:s,height:i,isPositiveGood:r,formattedValue:l,measureScale:a,maxBarWidth:c=10,styles:h=F}=e,u=h.scaleFactor,f=h.fontSize,d=38*u,p=c*f,$=4*u,m=.15*p,v=p-$-m,R=Math.abs(o)*h.unitScaling*f,g=R>v,w=Math.max(0,s.absMax*h.unitScaling*f-v),S=Math.max(0,R-v),E=w>0?S/w*m:0,b=s.min<0,y=s.max>0,O=b?p:0,M=(b?d:0)+(O+(y?p:0))+(y?d:0),U=2*u,T=i-2*U,G=(b?d:0)+O,_=U,N=o>=0,C=V(n,o,r,h),L=Q(C,j(n)?z(n):r?N?"pos":"neg":N?"neg":"pos"),{stroke:x,strokeWidth:k}=q(C),P=l||I(o,!1,a),A=g?v:R,D=g?v+$+E:R,B=N?G+D+4*u:G-D-4*u,W=N?"start":"end";return t("svg",{width:M,height:i,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},t(H,{styles:h}),t("line",{x1:G,y1:0,x2:G,y2:i,stroke:Y,"stroke-width":1*u}),A>0&&t("rect",{x:N?G:G-A,y:_,width:A,height:T,fill:L,stroke:x,"stroke-width":k*u}),g&&E>0&&t("rect",{x:N?G+v+$:G-v-$-E,y:_,width:E,height:T,fill:L,stroke:x,"stroke-width":k*u}),g&&function(e,o,n,s,i){const r=e+o/2,l=.35*o,a=s/3,c=.3*o;let h=`M ${r-l} ${n}`;for(let t=0;t<3;t++)h+=` L ${r-l-c} ${n+a*(t+.5)} L ${r-l} ${n+a*(t+1)}`;let u=`M ${r+l} ${n}`;for(let t=0;t<3;t++)u+=` L ${r+l+c} ${n+a*(t+.5)} L ${r+l} ${n+a*(t+1)}`;return[t("rect",{x:e,y:n-1,width:o,height:s+2,fill:"#ffffff"}),t("path",{d:h,fill:"none",stroke:"#000000","stroke-width":1*i}),t("path",{d:u,fill:"none",stroke:"#000000","stroke-width":1*i})]}(N?G+v:G-v-$,$,_,T,u),t("text",{x:B,y:i/2,dy:"0.35em","text-anchor":W,fill:h.fontColor,"font-size":f,"font-family":h.fontFamily},P))},X=e=>{const{value:o,scenario:n,columnStats:s,height:i,isPositiveGood:r,formattedValue:l,measureScale:a,maxBarWidth:c=10,styles:h=F}=e,u=h.scaleFactor,f=h.fontSize,d=Math.round(.67*c*f),p=5*u,$=s.min<0?d+p:0,m=$+(s.max>0?d+p:0),v=m+45*u,R=$,g=i/2,w=100*Math.abs(o)*h.percentageScaling*f,S=w>d,E=Math.min(w,d),b=o>=0,y=b?R+E:R-E,O=V(n,o,r,h),M=3*u,U=l||I(o,!0,a),T=m+4*u;return t("svg",{width:v,height:i,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},t("line",{x1:R,y1:0,x2:R,y2:i,stroke:Y,"stroke-width":1*u}),!S&&t("circle",{cx:y,cy:g,r:M,fill:h.fontColor}),t("line",{x1:R,y1:g,x2:y,y2:g,stroke:O.fill,"stroke-width":2*u}),S&&b&&t("polygon",{points:`${R+d},${g} ${R+d-6*u},${g-3*u} ${R+d-6*u},${g+3*u}`,fill:O.fill}),S&&!b&&t("polygon",{points:`${R-d},${g} ${R-d+6*u},${g-3*u} ${R-d+6*u},${g+3*u}`,fill:O.fill}),t("text",{x:T,y:i/2,dy:"0.35em","text-anchor":"start",fill:h.fontColor,"font-size":f,"font-style":"italic","font-family":h.fontFamily},U))},J=e=>{const{value:o,columnStats:n,isRelative:s,styles:i=F}=e;return null==o||isNaN(o)||!n||0===n.absMax?t("span",{class:"bar-chart-empty",style:{color:i.fontColor,fontStyle:"italic"}},"-"):t(s?X:K,Object.assign({},e))},Z=e=>{const{value:o,scenario:n,height:s,measureScale:i,maxBarWidth:r=10,styles:l=F,waterfall:a}=e,c=l.scaleFactor,h=l.fontSize,u=a.max-a.min;if(null==o||isNaN(o)||u<=0)return t("span",{class:"bar-chart-empty",style:{color:l.fontColor,fontStyle:"italic"}},"-");const f=38*c,d=r*h,p=f+d+f,$=d/u,m=t=>f+(t-a.min)*$,v=2*c,R=s-2*v,g=v,w=m(0),S=m(a.start),E=m(a.end),b=Math.min(S,E),y=Math.abs(E-S),O=V(n,o,!1,l),M=Q(O,z(n)),{stroke:U,strokeWidth:T}=q(O),G=I(o,"partof"===a.kind,i).replace(/^\+/,""),_=E<S,N=_?b-4*c:b+y+4*c,C=_?"end":"start";return t("svg",{width:p,height:s,class:"cell-bar-chart waterfall-bar",style:{overflow:"visible"}},t(H,{styles:l}),t("line",{x1:w,y1:0,x2:w,y2:s,stroke:Y,"stroke-width":1*c}),void 0!==a.parentStart&&void 0!==a.parentEnd&&t("line",{x1:m(a.parentStart),y1:0,x2:m(a.parentStart),y2:s,stroke:Y,"stroke-width":1*c,"stroke-dasharray":`${2*c},${2*c}`}),void 0!==a.parentStart&&void 0!==a.parentEnd&&t("line",{x1:m(a.parentEnd),y1:0,x2:m(a.parentEnd),y2:s,stroke:Y,"stroke-width":1*c,"stroke-dasharray":`${2*c},${2*c}`}),y>0&&t("rect",{x:b,y:g,width:y,height:R,fill:M,stroke:U,"stroke-width":T*c}),t("text",{x:N,y:s/2,dy:"0.35em","text-anchor":C,fill:l.fontColor,"font-size":h,"font-family":l.fontFamily},G))};class tt{constructor(t){this.groups=[r.CATEGORY,r.CATEGORYINDEX],_.OPT!==t.type&&_.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 et{constructor(t,e){this.hasPartOf=!1,this.config=t,this.i18n=e}execute(t,e){var o;this.db=t,this.fromExpr=e;const n=[],s=[],i=[],l=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),a=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 tt(this.config),f=this.config.grouped?[r.ROWGROUP,r.ROWGROUPINDEX]:[];let d,p=["",""];this.config.sortOrder.hierarchy.length>0&&(p=this.createOrderString(this.config.sortOrder)),this.hasPartOf=this.checkConfigForPartOf();try{d=t.exec(`SELECT COUNT(DISTINCT ${r.CATEGORY}) as ${r.TOTALROWCOUNT} ${f.length>0?","+f:""}\n FROM ${e} ${f.length>0?"GROUP BY "+f:""}\n ORDER BY ${p[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===f.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,n),this.createDataRow(n,t,u,l,h,e,p,o),this.createRestRow(t,n,u,l,e,p),this.createGroupSumRow(n,s,t,a,p)})),this.createTotalSumRow(n,s,a),n.forEach((e=>{try{i.push(t.exec(e))}catch(t){console.error("DataQuery: SQL query execution failed",e,t)}})),this.detectNaNCells(this.config.scenarios,i),this.createThereOfDrillRows(l,h,p,i),this.createPartOfDrillRows(l,p,s,i),this.createIntervalColumns(i),this.createThereOfDrillColumns(this.config.categoryThereOf,i),this.calculateColumnGroupRest(i,this.config.categoryThereOf),this.calculateRelativeVariances(i,c),i)}detectNaNCells(t,e){e.forEach((e=>{e.map((e=>(t.forEach((t=>{const o=new l(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,n){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===_.LIST)return;const s=this.createPartOfQuery(t,e);let i=[];const l=this.db;s.forEach((function(t){i.push(...l.exec(t))}));const a=this.exctractScenarioNames(t),c=[];o.forEach((function(t){c.push(...l.exec(t))}));const h=new Map;c.forEach((t=>h.set(t[r.ROWGROUP],t))),i=this.reduceResDrillByCategoryGroups(i,a),i.forEach((function(t){a.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(i,n)}createRestRow(t,e,o,n,s,i){if(t.totalRowCnt-this.config.limit>0&&0!==this.config.limit){const l=this.exctractScenarioNames(n).map((t=>`SUM(${t}) as ${t}`)).join(", ");e.push(`SELECT ${r.ROWNR}, 1 as ${r.ROWGROUPINDEX} , 'ENTRY' as ${r.TYPE}, 'NO_GROUP' as ${r.ROWGROUP}, 'REST' as ${r.CATEGORY} ${l.length>0?", "+l:""} FROM (SELECT ROWNUM() AS ${r.ROWNR}, ${e.length} as ${r.ROWGROUPINDEX} , 'ENTRY' as ${r.TYPE}, '${t.rowGroup||"NO_GROUP"}' as ${r.ROWGROUP}, ${o} ${n.length>0?",".concat(n):""} FROM ${this.fromExpr} ${s} GROUP BY ${o} ORDER BY ${i[0]}) t WHERE t.rowNr > ${this.config.limit}`)}}createDataRow(t,e,o,n,s,i,l,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} ${n.length>0?",".concat(n):""} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} ${i}\n GROUP BY ${o}\n ORDER BY ${l[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,n,s){!0!==this.config.grouped||_.SUM!==this.config.type&&_.SUMNOTOTAL!==this.config.type&&_.OPT!==this.config.type&&_.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} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr}\n WHERE ${r.ROWGROUP} = '${o.rowGroup}'\n ORDER BY ${s[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} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr}\n WHERE ${r.ROWGROUP} = '${o.rowGroup}'\n ORDER BY ${s[0]} `))}createTotalSumRow(t,e,o){var n;if(_.SUM===this.config.type||_.OPT===this.config.type){const e=(null===(n=this.config.title)||void 0===n?void 0:n.trim())||"SUM_TOTAL",s=this.hasPartOf&&!1===this.config.grouped&&"SUM_TOTAL"!==e?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} ${e}`:e;t.push(`SELECT ${t.length} as ${r.ROWGROUPINDEX},\n '${s}' 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 n=t.rowNr+t.rowGroup+t.type+t.category;if(o.has(n)){const s=o.get(n);e.forEach((e=>{try{s[e]+=t[e]}catch(t){console.error("DataQuery: drill row aggregation failed",e,t)}}))}else o.set(n,t)})),[...o.values()]}injectDrillRowsToResultRows(t,e){const o=new Map;if(!0===this.config.grouped)t.forEach((function(t){e.forEach((function(e){const n=e.findIndex((e=>e.category===t.category&&e.rowGroup===t.rowGroup));if(n>=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(n+t[r.ROWNR],0,t)}}))}));else{const n=this.findDuplicateSubCategories(t);t.forEach((function(t){e.forEach((function(e){const s=e.findIndex((e=>null!=e.category&&e.category===t.category));if(s>=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]||n.includes(t.subCategory))&&(t.subCategory=`${t.subCategory} (${t.rowGroup})`),e.splice(s+t[r.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,e,o,n){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const s=[],i=[];this.config.thereOf.forEach((n=>{let i=!0,l="1 <> 1 OR ( ";null!=n.category&&0!==n.category.length&&n.category.trim()&&(l+=` ${r.CATEGORY} = '${n.category}'`,i=!1),null!=n.rowGroup&&0!==n.rowGroup.length&&n.rowGroup.trim()&&(l+=` ${i?"":"AND"} ${r.ROWGROUP} = '${n.rowGroup}'`,i=!1),null!=n.subCategory&&0!==n.subCategory.length&&n.subCategory.trim()&&(l+=` ${i?"":"AND"} ${r.SUBCATEGORY} = '${n.subCategory}'`),l+=")",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} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr}\n WHERE ${l}\n GROUP BY ${r.ROWGROUP}, ${r.CATEGORY}, ${r.SUBCATEGORY}\n ORDER BY ${o[1]}`)}));const l=this.db;s.forEach((function(t){i.push(...l.exec(t))})),this.injectDrillRowsToResultRows(i,n)}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,n=new Map;e.forEach(((t,e)=>{const s=t,i=[];for(const t of s)i.push(`${e}##${t.name}`);o.set(e,i),n.set(`${e}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[r.TYPE]&&o.forEach(((e,o)=>{let s=0;e.forEach((e=>{void 0!==t[e]&&(s+=t[e])})),t[`${o}##REST`]=t[o]-s,0!==t[`${o}##REST`]&&n.set(`${o}##REST`,!0)}))}))}));const s=Array.from(n.entries()).filter((([t,e])=>!e)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const e of s)delete t[e]}))}))}createIntervalColumns(t){var e,o,n,s,i;if(this.config.interval===L||this.config.categoryThereOf.size>0||0===this.config.scenarios.length)return;const a="##",c=`(SELECT *, ${k(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`,h=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),u=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),f=this.exctractScenarioNames(h),d=this.getRelativeScenarios(),p=new tt(this.config),$=_.OPT===this.config.type||_.OPTNOTOTAL===this.config.type,m=this.config.grouped&&(_.SUM===this.config.type||_.SUMNOTOTAL===this.config.type||_.OPT===this.config.type||_.OPTNOTOTAL===this.config.type),v=this.checkConfigForPartOf()&&this.config.type!==_.LIST,R=t=>{try{return this.db.exec(t)}catch(e){return console.error("DataQuery: interval query failed",t,e),[]}},g=t=>(this.config.scenarios.forEach((e=>{const o=new l(e);!0===o.isValid?0!==t[o.base+"_cnt"]&&0!==t[o.delta+"_cnt"]||(t[e]=Number.NaN):0===t[e+"_cnt"]&&(t[e]=Number.NaN)})),d.forEach(((e,o)=>{t[o]=t[o]/t[e]})),t),w=(t,e,o)=>{for(const n of this.config.scenarios)t[n+a+o]=e[n]},S=R(`SELECT ${p}, __interval ${h.length>0?",".concat(h):""}\n FROM ${c}\n GROUP BY ${p}, __interval`);if(this.config.limit>0)for(let n=0;n<t.length;n++){const s=t[n].find((t=>"ENTRY"===t.type&&"REST"===t.category));if(!s)continue;let i;for(let e=n-1;e>=0&&!i;e--){const o=t[e].filter((t=>"ENTRY"===t.type&&"REST"!==t.category));o.length>0&&(i=o)}if(!i)continue;const r=new Set(i.map((t=>t.category))),l=i[0].rowGroup,a=new Map;for(const t of S){if(this.config.grouped&&t.rowGroup!==l)continue;if(r.has(t.category))continue;const n=P(t.__interval);let s=a.get(n);s||(s={},a.set(n,s));for(const n of f)s[n]=(null!==(e=s[n])&&void 0!==e?e:0)+(null!==(o=t[n])&&void 0!==o?o:0)}a.forEach(((t,e)=>{w(s,g(t),e)}))}for(const e of S){const o=P(e.__interval);g(e);for(const n of t)for(const t of n)"ENTRY"===t.type&&"REST"!==t.category&&t.category===e.category&&(this.config.grouped&&t.rowGroup!==e.rowGroup||$&&t.operation!==e.operation||w(t,e,o))}const E=m||v&&this.config.grouped?R(`SELECT ${r.ROWGROUP}, __interval ${u.length>0?",".concat(u):""}\n FROM ${c}\n GROUP BY ${r.ROWGROUP}, __interval`):[],b=new Map;if(E.forEach((t=>b.set(`${t.rowGroup}${a}${P(t.__interval)}`,t))),m)for(const e of E){const o=P(e.__interval),n=g(Object.assign({},e));for(const s of t)for(const t of s)"GROUP_SUM"===t.type&&t.rowGroup===e.rowGroup&&w(t,n,o)}const y=_.SUM===this.config.type||_.OPT===this.config.type,O=y||v&&!this.config.grouped?R(`SELECT __interval ${u.length>0?",".concat(u):""}\n FROM ${c}\n GROUP BY __interval`):[],M=new Map;if(O.forEach((t=>M.set(P(t.__interval),t))),y)for(const e of O){const o=P(e.__interval),n=g(Object.assign({},e));for(const e of t)for(const t of e)"SUM"===t.type&&w(t,n,o)}if(null!=this.config.thereOf&&this.config.thereOf.length>0){const e=[];this.config.thereOf.forEach((t=>{e.push(...R(`SELECT ${r.ROWGROUP}, ${r.CATEGORY}, ${r.SUBCATEGORY}, __interval ${h.length>0?",".concat(h):""}\n FROM ${c}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${r.ROWGROUP}, ${r.CATEGORY}, ${r.SUBCATEGORY}, __interval`))}));for(const o of e){const e=P(o.__interval);g(o);for(const n of t)for(const t of n)"DRILLELEMENT"===t.type&&t.category===o.category&&(t.subCategory!==o.subCategory&&t.subCategory!==`${o.subCategory} (${o.rowGroup})`||w(t,o,e))}}if(v){let e="1 <> 1 ";null===(n=this.config.partOf)||void 0===n||n.forEach((t=>{e+=`OR (${r.CATEGORY} = '${t.category}'`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(e+=`and ${r.ROWGROUP} = '${t.rowGroup}'`),e+=")"}));const o=R(`SELECT ${r.CATEGORY}, ${this.config.grouped?`${r.ROWGROUP}`:`'SUM_TOTAL' as ${r.ROWGROUP}`}, __interval ${h.length>0?",".concat(h):""}\n FROM ${c}\n WHERE ${e}\n GROUP BY ${r.ROWGROUP}, ${r.CATEGORY}, __interval`),l=new Map;for(const t of o){const e=`${t.rowGroup}${a}${t.category}${a}${P(t.__interval)}`,o=l.get(e);if(o)for(const e of f)o[e]=(null!==(s=o[e])&&void 0!==s?s:0)+(null!==(i=t[e])&&void 0!==i?i:0);else l.set(e,t)}l.forEach((e=>{const o=P(e.__interval),n=this.config.grouped?b.get(`${e.rowGroup}${a}${o}`):M.get(o);for(const t of f)e[t]=e[t]/(n?n[t]:Number.NaN);g(e);for(const n of t)for(const t of n)"PARTELEMENT"===t.type&&t.category===e.category&&t.rowGroup===e.rowGroup&&w(t,e,o)}))}}createThereOfWhereClause(t){let e=!0,o="1 <> 1 OR ( ";return null!=t.category&&0!==t.category.length&&t.category.trim()&&(o+=` ${r.CATEGORY} = '${t.category}'`,e=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(o+=` ${e?"":"AND"} ${r.ROWGROUP} = '${t.rowGroup}'`,e=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(o+=` ${e?"":"AND"} ${r.SUBCATEGORY} = '${t.subCategory}'`),o+")"}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 n=new l(t);return _.OPT===o||_.OPTNOTOTAL===o?n.isValid?"dr"===n.type?`SUM(${n.base} - ${n.delta}) as ${t}, SUM(${n.delta}) as dr_${n.delta}`:`SUM(${n.base} - ${n.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`:n.isValid?"dr"===n.type?`SUM((${n.base} * transformOperator(operation)) - (${n.delta} * transformOperator(operation))) as ${t}, SUM(${n.delta} * transformOperator(operation)) as dr_${n.delta}`:`SUM((${n.base} * transformOperator(operation))- (${n.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}translateAttributeSQL(t){const e=`[${t.arg}]`,o=/^(ac|pp|fc|pl)[1-4]$/.test(t.arg)&&this.config.type!==_.OPT&&this.config.type!==_.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 o?`AVG(${e} * transformOperator(operation)) as ${t.alias}`:`AVG(${e}) as ${t.alias}`;case"sum":return o?`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()} ${N.ASC===t.direction?N.DESC:N.ASC}`]}createRelativeScenario(t){const e=new l(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 n=[];let s="1 <> 1 ",i=` ${r.ROWGROUP}`,l="ROWNUM()";return null===(o=this.config.partOf)||void 0===o||o.forEach((t=>{s+=`OR (${r.CATEGORY} = '${t.category}'`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(s+=`and ${r.ROWGROUP} = '${t.rowGroup}'`),!1===this.config.grouped&&(i=` 'SUM_TOTAL' as ${r.ROWGROUP} `,l="1"),s+=")"})),n.push(`SELECT ${l} AS ${r.ROWNR},\n 'PARTELEMENT' as ${r.TYPE},\n ${r.CATEGORY},\n ${i},\n ${t}\n FROM ${this.fromExpr}\n WHERE ${s}\n GROUP BY ${r.ROWGROUP}, ${r.CATEGORY}, ${r.TYPE}\n ORDER BY ${e[1]}`),n}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,e){if(null==t||0===t.size)return;const o=[],n=[],s=this.fromExpr;t.forEach(((t,e)=>{let n="1 <> 1 ";t.forEach((t=>{n+=` 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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\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 ${s}\n WHERE ${n}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of o)n.push(...this.db.exec(t));this.injectDrillColumnsToResultRows(n,e)}injectDrillColumnsToResultRows(t,e){const o="##";for(const n of t)for(const t of e)for(const e of t)e.type===n.rowlevel&&("ENTRY"===n.rowlevel?"COLUMNGROUP"===n.columnlevel&&e.category===n.category?e[n.scenario+o+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&(e[n.scenario+o+n.columnGroup+o+n.columnSubGroup]=n.val):"DRILLELEMENT"===n.rowlevel?"COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory?e[n.scenario+o+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory?e[n.scenario+o+n.columnGroup+o+n.columnSubGroup]=n.val:"COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===`${n.subCategory} (${n.rowGroup})`?e[n.scenario+o+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===`${n.subCategory} (${n.rowGroup})`&&(e[n.scenario+o+n.columnGroup+o+n.columnSubGroup]=n.val):("SUM"===n.rowlevel||"GROUP_SUM"===n.rowlevel)&&("COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory&&(e[n.scenario+o+n.columnGroup]=n.val),"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory&&(e[n.scenario+o+n.columnGroup+o+n.columnSubGroup]=n.val)))}}class ot{constructor(){this.geometry=new Map}set(t,e,o){let n=this.geometry.get(t);n||(n=new Map,this.geometry.set(t,n)),n.set(e,o)}get(t,e){var o;return null===(o=this.geometry.get(t))||void 0===o?void 0:o.get(e)}}function nt(t,e,o){const n=t[e];if(null==n)return null;const s=Number(n);return isNaN(s)?null:o!==_.OPT&&o!==_.OPTNOTOTAL||t[r.TYPE]!==C.ENTRY||"-"!==t[r.OPERATION]?s:-s}class st{constructor(){this.normalizedHeader=[],this.attributesByAlias=new Map}createHeader(t,e,o,n,s,r,l=[]){const a=[];this.attributesByAlias=new Map(l.map((t=>[t.alias,t]))),this.normalizedHeader=this.normalizeHeader(t,e,l);const c=this.normalizedHeader.some((t=>void 0!==t.bucket));c&&a.push(this.createIntervalBandRow());const h=new B(c?1:0,0,C.HEADER),u=new B(c?2:1,0,C.SEPERATORLINE);for(const t of this.normalizedHeader){const e=this.attributesByAlias.get(t.name);h.createElement(e?o.get(e.label)||e.label:i.translateScenarioLabel(t.name,o),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,o,n,s,r),null,null,null,null),u.createElement(null,t.type,this.createColumnType(t),null,null,null,null,null,null)}return a.push(h),a.push(u),a}createIntervalBandRow(){const t=new B(0,0,C.HEADER);let e=0;for(;e<this.normalizedHeader.length;){const o=this.normalizedHeader[e];if(void 0===o.bucket){t.createElement(null,o.type,"filler",null,null,null,null,null,null),e+=1;continue}let n=1;for(;e+n<this.normalizedHeader.length&&this.normalizedHeader[e+n].bucket===o.bucket;)n+=1;t.createElement(o.bucketLabel,o.type,"intervalGroup",null,null,null,null,null,null,!1,void 0,n),e+=n}return t}setHeaderPrefix(t,e,o,n,s){let r="";return"category"===t.name&&s&&(0===o.prefix.length&&0===n.length||(r=i.translateScenarioLabel("in",e)+" "+o.prefix+n)),t.order&&(r+=i.translateScenarioLabel("ORDER_"+t.order,e)),r}normalizeHeader(t,e,o){let n=[{name:r.CATEGORY,group:r.CATEGORY,type:r.CATEGORY,order:void 0}];_.OPT!==t&&_.OPTNOTOTAL!==t||(n=[{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 s=o.map((t=>({name:t.alias,group:t.alias,type:t.alias,order:void 0})));return[...n,...s,...e]}createBodyRows(t,e,o,n){var s;const i=[];let l=-1;const a=new et(t,e).execute(o,n),h=this.calculateColumnStatistics(a,t.barColumns,t.interval!==L),u=(null!==(s=t.barColumns)&&void 0!==s?s:[]).filter((t=>t.toUpperCase().trim()in c)),f=u.length>0&&t.interval===L&&0===t.categoryThereOf.size&&function(t){for(const e of t)for(const t of e){const e=t[r.TYPE];if(e===C.SUM||e===C.GROUPSUM||e===C.DRILLELEMENT||e===C.PARTELEMENT)return!0}return!1}(a)?function(t,e,o){const n=new ot;for(const s of e){let e,i=0,l=0;const a=[],c=(t,e)=>{a.push(e),n.set(t,s,e)};for(const n of t)for(const t of n){const n=t[r.TYPE];if(n===C.GROUPHEAD){e=void 0;continue}const a=nt(t,s,o);if(n===C.ENTRY){if(null===a){e=void 0;continue}c(t,{start:i,end:i+a,min:0,max:0,kind:"cascade"}),e={start:i,end:i+a},l=e.start,i+=a}else if(n===C.SUM||n===C.GROUPSUM){if(null===a){e=void 0;continue}c(t,{start:0,end:a,min:0,max:0,kind:"anchor"}),e={start:0,end:a},l=0,i=a}else if(n===C.DRILLELEMENT){if(null===a||void 0===e)continue;const o=l+(Math.sign(e.end-e.start)||1)*Math.abs(a);c(t,{start:l,end:o,min:0,max:0,kind:"thereof",parentStart:e.start,parentEnd:e.end}),l=o}else if(n===C.PARTELEMENT){if(null===a||void 0===e)continue;const o=l+a*(e.end-e.start);c(t,{start:l,end:o,min:0,max:0,kind:"partof",parentStart:e.start,parentEnd:e.end}),l=o}}let h=0,u=0;for(const t of a)h=Math.min(h,t.start,t.end),u=Math.max(u,t.start,t.end);for(const t of a)t.min=h,t.max=u}return n}(a,u,t.type):void 0;for(const o of a)l+=1,i.push(...this.createRow(t.i18n,e,t.scenariosUnitType,o,l,-1,t.categoryWidth,t.measureScale,t.barColumns,h,f));return i}calculateColumnStatistics(t,e,o=!1){const n=new Map;if(!e||0===e.length)return n;const s=new Map;for(const t of e)n.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=o?this.extractIntervalColumnValues(t,i):[this.extractColumnValue(t,i)];for(const t of e)if(null!==t&&!isNaN(t)){const e=n.get(i);e.min=Math.min(e.min,t),e.max=Math.max(e.max,t),s.get(i).push(Math.abs(t))}}for(const[t,e]of n){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 o=s.get(t);if(o.length>0){o.sort(((t,e)=>t-e));const t=Math.floor(o.length/2);e.median=o.length%2==0?(o[t-1]+o[t])/2:o[t]}n.set(t,e)}return n}extractIntervalColumnValues(t,e){const o=e+"##",n=[];for(const e of Object.keys(t))if(e.startsWith(o)){const o=Number(t[e]);n.push(isNaN(o)?null:o)}return n}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,n,s,i,l,a,c,h,u){var f;const d=[];for(const p of n){const $=p[r.ROWGROUP],m=p[r.SUBCATEGORY],v=p[r.TYPE],R=p[r.ROWNR]>=2,g=this.createDetailRow(v,i+=1,s,n.length);for(const n of this.normalizedHeader){const s=this.getRawDataRowElement(p,n),i=null!==(f=null==c?void 0:c.includes(n.type))&&void 0!==f&&f,r=i?null==h?void 0:h.get(n.type):void 0,d=i&&void 0===n.bucket&&n.name===n.group&&n.name===n.type?null==u?void 0:u.get(p,n.type):void 0;g.createElement(this.translateSumCellLabel(t,e,s,$,m,v,n.type),n.type,this.createColumnType(n),this.setCellType(n.type,o),this.translateCellPrefix(e,v,n.type),this.translateScenarioCSS(n.type,s),R,l,null==a?void 0:a.value,i,r,1,d)}d.push(g)}return d}getRawDataRowElement(t,e){return void 0!==e.bucket?t[e.type+"##"+e.bucket]: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,n){switch(t){case C.GROUPHEAD:return new B(e,o,C.HEADER);case C.SUM:case C.GROUPSUM:return new B(n+2,o,C.SUM);case C.DRILLELEMENT:return new B(n+2,o,C.DRILLELEMENT);case C.PARTELEMENT:return new B(n+2,o,C.PARTELEMENT);default:return new B(e,o,C.STANDARD)}}translateSumCellLabel(t,e,o,n,s,i,r){return this.attributesByAlias.has(r)||!1===Number.isNaN(Number(o))||this.isOperationColumn(r)?o:this.isGroupHeadCategory(i,r)?t===h.ALL?`${e.get(o)||o}`:o:this.isEntryCategory(i,r)?t===h.ALL||"REST"===o?`${e.get(o)||o}`:o:this.isDrillElementCategory(i,r)?t===h.ALL?`${e.get(s)||s}`:`${s}`:this.isPartElementCategory(i,r)?t===h.ALL||"SUM_TOTAL"===n?`${e.get(n)||n}`:`${n}`:this.isSumElementCategory(i,r)?t===h.ALL||"SUM_TOTAL"===n?`${e.get(n)||n}`:n:"GROUPHEAD"===i&&null==o?o:Number.isNaN(Number(o))?"-":Number(o)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,e){if(this.attributesByAlias.has(t))return"attribute";const o=new l(t);let n="pos";return e<0&&(n="neg"),o.isValid?n+"_"+o.direction+("dr"===o.type?" relative_variance":""):t}setCellType(t,e){if("category"===t)return"";const o=this.attributesByAlias.get(t);if(o)return o.isNumeric?"decimal":"";let n;const s=new l(t);return e===u.PERCENT?(n="percent",s.isValid&&"d"===s.type&&(n="decimal")):(n="decimal",s.isValid&&"dr"===s.type&&(n="percent")),n}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 it{constructor(t,e,o,n){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new a,this.db=e,this.dataSetFactory=new st,this.config=this.initConfig(n),this.i18n=this.initI18n(new Map),this.setSource(o,n.filter),this.state=G.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"],["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=G.DIRTY,new Map([...e,...t||new Map])}initConfig(t){this.state=G.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,n;if(!t)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=R(t,e);try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(n=null===(o=t[0])||void 0===o?void 0:o.cnt)&&void 0!==n?n:0}catch(t){this.rowCount=0}this.prepareIntervalBuckets();const s=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder,this.intervalBuckets);this.headerRows=this.dataSetFactory.createHeader(this.config.type,s,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=G.UP_TO_DATE}update(){this.prepareIntervalBuckets();const t=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder,this.intervalBuckets);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=G.UP_TO_DATE}getHeader(){return this.state===G.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===G.DIRTY&&this.update(),this.bodyRows}prepareIntervalBuckets(){this.intervalBuckets=[],this.config.interval===L||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=L:(this.config.interval=function(t,e,o){var n;if(o!==m.AUTO)return o;let s,i,r;try{s=t.exec(`SELECT [date] as d FROM ${e}`)}catch(t){return console.error("IntervalColumns: date query failed",t),m.DAY}for(const t of s){const e=null===(n=A(t.d))||void 0===n?void 0:n.toMillis();void 0!==e&&(i=void 0===i?e:Math.min(i,e),r=void 0===r?e:Math.max(r,e))}return void 0===i||void 0===r?m.DAY:(new v).calculateDistanceType($.fromMillis(i),$.fromMillis(r))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,e,o,n){let s;try{s=t.exec(`SELECT ${k(o)} as __interval FROM ${e}`)}catch(t){return console.error("IntervalColumns: bucket query failed",t),[]}if(o===x){const t=new Set,e=[];for(const o of s){const n=P(o.__interval);t.has(n)||(t.add(n),e.push({key:n,label:0===n.length?"—":n}))}return e}const i=new Set,r=[];for(const t of s){const e=A(t.__interval);if(!e)continue;const o=e.toISO();i.has(o)||(i.add(o),r.push(e))}r.sort(((t,e)=>t.toMillis()-e.toMillis()));const l=new v;return l.setLocale(n),r.map((t=>({key:t.toISO(),label:l.getDateString(t,o)})))}(this.db,this.fromExpr,this.config.interval,this.config.locale),0===this.intervalBuckets.length&&(this.config.interval=L))}normalizeScenarios(t,e,o,n=[]){var s,i;const r=[];if(n.length>0){for(const e of n)for(const n of t)r.push({name:n,group:n,type:n,order:(null===(s=null==o?void 0:o.hierarchy)||void 0===s?void 0:s.at(0))===n?o.direction:void 0,bucket:e.key,bucketLabel:e.label});return r}for(const n of t){if(null==e?void 0:e.has(n)){const t=e.get(n);for(const e of t){r.push({name:e.name,group:e.name,type:n,order:void 0});for(const t of e.subGroups)r.push({name:t,group:e.name,type:n,order:void 0})}r.push({name:"REST",group:"REST",type:n,order:void 0})}let t;(null===(i=null==o?void 0:o.hierarchy)||void 0===i?void 0:i.at(0))===n&&(t=o.direction),r.push({name:n,group:n,type:n,order:t})}return r}hasNoData(){return 0===this.rowCount}}class rt{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 y(new O).default(),this.type=_.LIST,this.limit=0,this.i18n=h.ALL,this.categoryWidth=d.W25,this.measureScale=new M,this.measureUnit="",this.measureType=p.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.locale="de"}}class lt{constructor(t,e,o,n,s){this.tableDrillGroupAdapter=t,this.stringAdapter=e,this.orderAdapter=o,this.db=n,this.fromExpr=s}adapt(t){const e=new rt;return f.isString(t.title)&&(e.title=t.title),f.isArray(t.scenarios)&&(e.scenarios=b.adaptArray(t.scenarios,this.stringAdapter)),f.isExisting(t.scenariosUnitType)&&(e.scenariosUnitType=t.scenariosUnitType),f.isBoolean(t.grouped)&&(e.grouped=t.grouped),f.isBoolean(t.showGroupTitle)&&(e.showGroupTitle=t.showGroupTitle),f.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),f.isArray(t.thereOf)&&(e.thereOf=b.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),f.isExisting(t.categoryThereOf)&&(e.categoryThereOf=t.categoryThereOf),f.isArray(t.partOf)&&(e.partOf=b.adaptArray(t.partOf,this.tableDrillGroupAdapter)),f.isArray(t.attributes)&&(e.attributes=t.attributes),f.isExisting(t.order)&&(e.sortOrder=this.orderAdapter.adapt(t.order)),f.isExisting(t.type)&&(e.type=t.type),f.isNumber(t.limit)&&(e.limit=t.limit),f.isExisting(t.i18n)&&(e.i18n=t.i18n),f.isExisting(t.categoryWidth)&&(e.categoryWidth=t.categoryWidth),f.isExisting(t.measureScale)&&(e.measureScale=w.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale)),f.isExisting(t.measureType)&&(e.measureType=t.measureType),f.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),f.isString(t.filter)&&(e.filter=t.filter.trim()),f.isArray(t.barColumns)&&(e.barColumns=t.barColumns),f.isString(t.interval)&&(e.interval=t.interval),f.isString(t.locale)&&(e.locale=t.locale),e}default(){return new rt}}class at{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class ct{constructor(){}adapt(t){const e=new at;return f.isString(t.rowGroup)&&(e.rowGroup=t.rowGroup),f.isString(t.category)&&(e.category=t.category),f.isString(t.subCategory)&&(e.subCategory=t.subCategory),f.isString(t.partOf)&&(e.partOf=t.partOf),e}default(){return new at}}const ht=e(class extends o{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.sumTitle="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:N.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=_.LIST,this.categoryWidth=d.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=h.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=p.VOLUME,this.filter="",this.barColumns=[],this.interval="none",this.barColumnMaxWidth=30,this.unitScaling=.01,this.percentageScaling=.5,this.scaleFactor=1,this.componentDataFormatDigits=new S,this.componentStyle=U(this)}render(){return t(n,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,n,s)=>t("span",null,n===s.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&&(void 0!==o.waterfall||e.type!==C.SUM)?void 0!==o.waterfall?t(Z,{value:o.value,scenario:o.key,columnStats:o.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:o.key.endsWith("_pos"),measureScale:o.measureScale,maxBarWidth:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:o.waterfall}):t(J,{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 E).adapt(this.dataFormatDigits),this.table=new it(new a(this.ruleSetConfig),t,this.tableName,e),this.table.setI18n(this.i18n),this.barChartStyles=this.prepareBarChartStyles()}prepareConfig(t){var e,o,n;const s=this.tableName?this.filter&&this.filter.length>0?`(SELECT * FROM \`${this.tableName}\` WHERE ${this.filter}) AS __src`:`\`${this.tableName}\``:"";return new lt(new ct,new O,new y(new O),t,s).adapt({title:this.sumTitle,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,interval:this.interval,locale:(null===(n=null===(o=null===(e=this.stores)||void 0===e?void 0:e.context)||void 0===o?void 0:o.state)||void 0===n?void 0:n.locale)||"de"})}prepareBarChartStyles(){return this.componentStyle((t=>{var e,o,n,s,i,r,l,a,c,h,u,f,d,p,$,m,v,R,g,w,S,E,b,y,O,M;const U=null===(e=t["bn-chart-time"])||void 0===e?void 0:e.varianceStyles,T=null===(o=t["bn-chart-time"])||void 0===o?void 0:o.barStyles;return{positive:{stroke:(null===(n=null==U?void 0:U.pos)||void 0===n?void 0:n.stroke)||"#008f96",fill:(null===(s=null==U?void 0:U.pos)||void 0===s?void 0:s.fill)||"#008f96",fillpattern:(null===(i=null==U?void 0:U.pos)||void 0===i?void 0:i.fillpattern)||"solid"},negative:{stroke:(null===(r=null==U?void 0:U.neg)||void 0===r?void 0:r.stroke)||"#ff0000",fill:(null===(l=null==U?void 0:U.neg)||void 0===l?void 0:l.fill)||"#ff0000",fillpattern:(null===(a=null==U?void 0:U.neg)||void 0===a?void 0:a.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===(f=null==T?void 0:T.ac)||void 0===f?void 0:f.stroke)||"#404040",fill:(null===(d=null==T?void 0:T.ac)||void 0===d?void 0:d.fill)||"#404040",fillpattern:(null===(p=null==T?void 0:T.ac)||void 0===p?void 0:p.fillpattern)||"solid"},pp:{stroke:(null===($=null==T?void 0:T.pp)||void 0===$?void 0:$.stroke)||"#A6A6A6",fill:(null===(m=null==T?void 0:T.pp)||void 0===m?void 0:m.fill)||"#A6A6A6",fillpattern:(null===(v=null==T?void 0:T.pp)||void 0===v?void 0:v.fillpattern)||"solid"},fc:{stroke:(null===(R=null==T?void 0:T.fc)||void 0===R?void 0:R.stroke)||"#404040",fill:(null===(g=null==T?void 0:T.fc)||void 0===g?void 0:g.fill)||"#ffffff",fillpattern:(null===(w=null==T?void 0:T.fc)||void 0===w?void 0:w.fillpattern)||"hatched"},pl:{stroke:(null===(S=null==T?void 0:T.pl)||void 0===S?void 0:S.stroke)||"#404040",fill:(null===(E=null==T?void 0:T.pl)||void 0===E?void 0:E.fill)||"#ffffff",fillpattern:(null===(b=null==T?void 0:T.pl)||void 0===b?void 0:b.fillpattern)||"outlined"}},fontColor:(null===(y=t.global)||void 0===y?void 0:y.fontColor)||"#000000",fontSize:.85*((null===(O=t.global)||void 0===O?void 0:O.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!==C.SUM)for(const o of e.getCells())o.isBarChart&&o.columnStats&&!o.key.startsWith("dr")&&!o.waterfall&&(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!==C.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}th.intervalGroup{border-bottom:0.1em solid black;text-align:center;font-weight:bold}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"],selectedStyle:[513,"selected-style"],sumTitle:[1,"sum-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],ruleSetConfig:[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],interval:[1],barColumnMaxWidth:[2,"bar-column-max-width"],unitScaling:[2,"unit-scaling"],percentageScaling:[2,"percentage-scaling"],scaleFactor:[2,"scale-factor"]}]);function ut(){"undefined"!=typeof customElements&&["ibcs-table"].forEach((t=>{"ibcs-table"===t&&(customElements.get(s(t))||customElements.define(s(t),ht))}))}export{ht as I,_ as T,L as a,x as b,ut 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,C as r}from"./CompareUtil.js";import{b as a,a as o,D as c}from"./DateStringFactory.js";import{F as h,I as l}from"./formatter.js";import{A as u,O as p,c as d}from"./Order.js";import{D as m}from"./luxon.js";import{S as f}from"./StringAdapter.js";import{s as b}from"./sanitizeHtml.js";class w{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 a).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(" ",h.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 _{constructor(){this.businessunit="",this.measures=[],this.scenarios=[],this.i18nMode=n.ALL,this.intervalSpanLimit=32}}class v{constructor(t,s,i,e){this.measureEntryAdapter=t,this.timePeriodAdapter=s,this.orderAdapter=i,this.stringAdapter=e}adapt(t){const s=new _;return r.isString(t.businessunit)&&(s.businessunit=t.businessunit),r.isArray(t.measures)&&(s.measures=u.adaptArray(t.measures,this.measureEntryAdapter)),r.isArray(t.scenarios)&&(s.scenarios=u.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 _}}var y;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(y||(y={}));class R{constructor(t){this.i18n=new Map,this.unit="",this.measures=[],this.dimension="",this.config=new _,this.state=y.DIRTY,this.ruleSet=t||new l,this.dataSetFactory=new w,this.state=y.DIRTY,this.setI18n(new Map)}setRuleSet(t){this.ruleSet=t||new l}setI18n(t){this.state=y.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 y.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=y.UP_TO_DATE),this}setConfig(t){this.config=this.initConfig(t)}initConfig(t){this.state=y.DIRTY;const s=t,i=this;return t.scenarios.sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))),s}}class C{constructor(t="",s=""){this.name=t,this.unit=s}}class S{construnctor(){}adapt(t){const s=new C;return r.isString(t.name)&&(s.name=t.name),r.isString(t.unit)&&(s.unit=t.unit),s}default(){return new C("","")}}class E{constructor(t=m.now(),s=m.now(),i=o.AUTO,e=c.AUTO){this.start=t,this.end=s,this.format=i,this.link=e}}class O{construnctor(){}adapt(t){const s=new E;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 E}}const g=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:p.ASC},this.i18n=new Map,this.i18nMode=n.ALL,this.title=new R(new l)}async setBusinessUnit(t){this.businessUnit=t}async setProps(t){Object.keys(t).forEach((s=>{this[s]=t[s]}))}render(){return i("div",{key:"7a95748a4576c654c9066efb2bfd7531238d2ed0"},i("div",{key:"6a34ba1043660dc75b57cd029f6438d1178c34e4",innerHTML:b(this.title.unit)}),i("div",{key:"6ec241e7cd6ac8a2061aab1b822973e77e2fb7cd"},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:"d6bc97cd78ec8734d4d42b2537cf61dfcac28ae4"},this.title.dimension))}componentWillLoad(){const t=this.prepareConfig();this.title=new R(new l(this.ruleSetConfig)),this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillUpdate(){const t=this.prepareConfig();this.title.setI18n(this.i18n),this.title.setRuleSet(new l(this.ruleSetConfig)),this.title.setConfig(t)}componentWillRender(){this.title.update()}isFirstElement(t){return 0!==t}prepareConfig(){return new v(new S,new O,new d(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)}p{margin:0}'}},[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"],ruleSetConfig:[16],setBusinessUnit:[64],setProps:[64]}]);function P(){"undefined"!=typeof customElements&&["ibcs-title"].forEach((t=>{"ibcs-title"===t&&(customElements.get(e(t))||customElements.define(e(t),g))}))}export{g 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,C as r}from"./CompareUtil.js";import{b as a,a as o,D as c}from"./DateStringFactory.js";import{F as h,I as l}from"./formatter.js";import{A as u,O as p,c as d}from"./Order.js";import{D as m}from"./luxon.js";import{S as f}from"./StringAdapter.js";import{s as b}from"./sanitizeHtml.js";class w{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,r="de"){let o="";if(void 0!==s){const t=new a;t.setLocale(r),o=t.getDateLinkString(s.start,s.end,s.link,s.format,n)}return o+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(" ",h.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 _{constructor(){this.businessunit="",this.measures=[],this.scenarios=[],this.i18nMode=n.ALL,this.intervalSpanLimit=32,this.locale="de"}}class v{constructor(t,s,i,e){this.measureEntryAdapter=t,this.timePeriodAdapter=s,this.orderAdapter=i,this.stringAdapter=e}adapt(t){const s=new _;return r.isString(t.businessunit)&&(s.businessunit=t.businessunit),r.isArray(t.measures)&&(s.measures=u.adaptArray(t.measures,this.measureEntryAdapter)),r.isArray(t.scenarios)&&(s.scenarios=u.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)),r.isString(t.locale)&&(s.locale=t.locale),s}default(){return new _}}var R;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(R||(R={}));class y{constructor(t){this.i18n=new Map,this.unit="",this.measures=[],this.dimension="",this.config=new _,this.state=R.DIRTY,this.ruleSet=t||new l,this.dataSetFactory=new w,this.state=R.DIRTY,this.setI18n(new Map)}setRuleSet(t){this.ruleSet=t||new l}setI18n(t){this.state=R.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"],["pl3","PL3"],["ac4","AC4"],["pp4","PY4"],["fc4","FC4"],["pl4","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 R.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.config.locale),this.state=R.UP_TO_DATE),this}setConfig(t){this.config=this.initConfig(t)}initConfig(t){this.state=R.DIRTY;const s=t,i=this;return t.scenarios.sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))),s}}class C{constructor(t="",s=""){this.name=t,this.unit=s}}class S{construnctor(){}adapt(t){const s=new C;return r.isString(t.name)&&(s.name=t.name),r.isString(t.unit)&&(s.unit=t.unit),s}default(){return new C("","")}}class E{constructor(t=m.now(),s=m.now(),i=o.AUTO,e=c.AUTO){this.start=t,this.end=s,this.format=i,this.link=e}}class O{construnctor(){}adapt(t){const s=new E;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 E}}const g=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:p.ASC},this.i18n=new Map,this.i18nMode=n.ALL,this.locale="de",this.title=new y(new l)}async setBusinessUnit(t){this.businessUnit=t}async setProps(t){Object.keys(t).forEach((s=>{this[s]=t[s]}))}render(){return i("div",{key:"4a675a92695130e13bd690587098cf70d81028c9"},i("div",{key:"54c98ac466109f4ea1306aa57379f5cb25cf654f",innerHTML:b(this.title.unit)}),i("div",{key:"35e8592454c45c06db9e3b6db5525165a3ee4a00"},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:"29c93306567a592ac956d5c97501dc5e7acf90ec"},this.title.dimension))}componentWillLoad(){const t=this.prepareConfig();this.title=new y(new l(this.ruleSetConfig)),this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillUpdate(){const t=this.prepareConfig();this.title.setI18n(this.i18n),this.title.setRuleSet(new l(this.ruleSetConfig)),this.title.setConfig(t)}componentWillRender(){this.title.update()}isFirstElement(t){return 0!==t}prepareConfig(){return new v(new S,new O,new d(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,locale:this.locale})}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)}p{margin:0}'}},[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"],locale:[1],ruleSetConfig:[16],setBusinessUnit:[64],setProps:[64]}]);function P(){"undefined"!=typeof customElements&&["ibcs-title"].forEach((t=>{"ibcs-title"===t&&(customElements.get(e(t))||customElements.define(e(t),g))}))}export{g as I,P as d}
@@ -1,4 +1,4 @@
1
- import { C as CompareUtil } from './VarianceMeasure-DnwNKspZ.js';
1
+ import { C as CompareUtil } from './VarianceMeasure-CE3N8Bea.js';
2
2
 
3
3
  /**
4
4
  * Parses a raw object-prop attribute value. A blank value yields `data: null`
@@ -1,5 +1,5 @@
1
- import { F as Formatter } from './SVGStyle-BxEDw9zh.js';
2
- import './VarianceMeasure-DnwNKspZ.js';
1
+ import { F as Formatter } from './SVGStyle-BwBlY3Km.js';
2
+ import './VarianceMeasure-CE3N8Bea.js';
3
3
 
4
4
  /** SI metric prefix for number scaling (e.g. prefix="M", value=1000000 divides displayed values by one million). */
5
5
  class SiPrefix {
@@ -1,4 +1,4 @@
1
- import { C as CompareUtil } from './VarianceMeasure-DnwNKspZ.js';
1
+ import { C as CompareUtil } from './VarianceMeasure-CE3N8Bea.js';
2
2
 
3
3
  /** Shared utilities for the adapter layer, used by all component config adapters. */
4
4
  class AdapterUtils {
@@ -1,5 +1,5 @@
1
- import { d as getDefaultExportFromCjs, S as SYSTEM_RULESET_DEFAULTS } from './context-protocol-1Yj1uKvh.js';
2
- import { m as merge, C as CompareUtil } from './VarianceMeasure-DnwNKspZ.js';
1
+ import { d as getDefaultExportFromCjs, S as SYSTEM_RULESET_DEFAULTS } from './context-protocol-d8MHrEo8.js';
2
+ import { m as merge, C as CompareUtil } from './VarianceMeasure-CE3N8Bea.js';
3
3
 
4
4
  /**
5
5
  * Parses an IBCS variance column name into its constituent parts.
@@ -1,4 +1,4 @@
1
- import { C as CompareUtil } from './VarianceMeasure-DnwNKspZ.js';
1
+ import { C as CompareUtil } from './VarianceMeasure-CE3N8Bea.js';
2
2
 
3
3
  class SVGVariancesStyleGroup {
4
4
  constructor(pos, neg, neu) {
@@ -1,4 +1,4 @@
1
- import { D as DateTime } from './context-protocol-1Yj1uKvh.js';
1
+ import { D as DateTime } from './context-protocol-d8MHrEo8.js';
2
2
 
3
3
  const isObject = (obj) => {
4
4
  if (typeof obj === 'object' && obj !== null) {
@@ -1,7 +1,7 @@
1
- import { C as CompareUtil, a as scenarioSlotNumber } from './VarianceMeasure-DnwNKspZ.js';
2
- import { X as XY_SERIES_PALETTE, D as DateTime } from './context-protocol-1Yj1uKvh.js';
3
- import { L as LabelCollisionManager, H as HookLocation } from './LabelCollisionManager-8swVQHKA.js';
4
- import { F as Formatter, C as CalculateSize } from './SVGStyle-BxEDw9zh.js';
1
+ import { C as CompareUtil, a as scenarioSlotNumber } from './VarianceMeasure-CE3N8Bea.js';
2
+ import { X as XY_SERIES_PALETTE, D as DateTime } from './context-protocol-d8MHrEo8.js';
3
+ import { L as LabelCollisionManager, H as HookLocation } from './LabelCollisionManager-DaNiDiM9.js';
4
+ import { F as Formatter, C as CalculateSize } from './SVGStyle-BwBlY3Km.js';
5
5
 
6
6
  /**
7
7
  * Aggregates all style configuration for an XY chart (scatter/bubble):