@bino-bi/bn-template-engine 1.0.0-next.37 → 1.0.0-next.39

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 (52) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/{p-f74760d7.entry.js → p-8c84d57e.entry.js} +1 -1
  3. package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +271 -57
  4. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +56 -6
  7. package/dist/collection/components/bn-table/bn-table.js +93 -5
  8. package/dist/collection/components/bn-table/utils/Table.js +33 -2
  9. package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +15 -7
  10. package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +2 -2
  11. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +15 -7
  12. package/dist/collection/components/bn-table/utils/helper/DataQuery.js +24 -10
  13. package/dist/collection/components/bn-table/utils/helper/IntervalColumns.js +30 -6
  14. package/dist/collection/components/bn-table/utils/helper/WaterfallCalculator.js +9 -3
  15. package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +31 -8
  16. package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +5 -0
  17. package/dist/collection/utils/layoutState/baseline.js +6 -5
  18. package/dist/components/bn-chart-bubble-renderer.js +1 -1
  19. package/dist/components/bn-chart-bubble.js +1 -1
  20. package/dist/components/bn-chart-bullet-renderer.js +1 -1
  21. package/dist/components/bn-chart-bullet.js +1 -1
  22. package/dist/components/bn-chart-scatter-renderer.js +1 -1
  23. package/dist/components/bn-chart-scatter.js +1 -1
  24. package/dist/components/bn-chart-structure.js +1 -1
  25. package/dist/components/bn-chart-time.js +1 -1
  26. package/dist/components/bn-table-renderer.js +1 -1
  27. package/dist/components/bn-table.js +1 -1
  28. package/dist/components/{p-CQVAHG6w.js → p-B4Cf0cVi.js} +1 -1
  29. package/dist/components/{p-C-KX1_tw.js → p-BsJOvfIg.js} +1 -1
  30. package/dist/components/p-ChaSU4fh.js +1 -0
  31. package/dist/components/{p-BhEdmPjm.js → p-Cyf5ZEXs.js} +1 -1
  32. package/dist/components/{p-t4xPltK2.js → p-XFZYX7DZ.js} +1 -1
  33. package/dist/components/{p-C_6KHDYv.js → p-chnyMHJT.js} +1 -1
  34. package/dist/components/p-dRPJiQB6.js +1 -0
  35. package/dist/esm/bn-annotation-layer_30.entry.js +271 -57
  36. package/dist/esm/bn-template-engine.js +1 -1
  37. package/dist/esm/loader.js +1 -1
  38. package/dist/types/components/bn-table/bn-table-renderer/bn-table-renderer.d.ts +2 -0
  39. package/dist/types/components/bn-table/bn-table.d.ts +26 -0
  40. package/dist/types/components/bn-table/utils/Table.d.ts +11 -1
  41. package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +5 -2
  42. package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +7 -4
  43. package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +1 -0
  44. package/dist/types/components/bn-table/utils/helper/IntervalColumns.d.ts +7 -0
  45. package/dist/types/components/bn-table/utils/helper/WaterfallCalculator.d.ts +5 -2
  46. package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +15 -6
  47. package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +2 -0
  48. package/dist/types/components.d.ts +19 -4
  49. package/dist/types/utils/layoutState/baseline.d.ts +4 -2
  50. package/package.json +1 -1
  51. package/dist/components/p-CHQ67u2G.js +0 -1
  52. package/dist/components/p-sar8m7th.js +0 -1
@@ -1681,6 +1681,11 @@ export namespace Components {
1681
1681
  * List of column names to render as bar charts instead of numbers. <br /><br /> Absolute variances (d_*) render as horizontal bar charts. Relative variances (dr_*) render as pin charts with a square head. Bars take the pattern of the minuend (FC hatched, PL outlined) in the colour of the sentiment; pin heads take the look of the minuend scenario (AC solid dark, PY solid grey, FC hatched, PL outlined); the axis takes the look of the reference scenario. Scenario columns (ac1..pl4) render as horizontal bar charts; when the table contains grouping structure (sum rows, thereof, or partof) they automatically render as an IBCS waterfall - data rows cascade from the running total and sum rows anchor at zero. Waterfall columns auto-scale to fit the bar column width (unit-scaling does not apply) and are not supported in combination with `interval` or `columnthereof`. <br /><br /> example:<br /> ```dac1_pp1_pos,drac1_pp1_pos,ac1```
1682
1682
  */
1683
1683
  "barColumns": string;
1684
+ /**
1685
+ * Number of interval groups that stand left of the category column. Needs an active `interval`. <br /><br /> ```0``` (default) keeps the category column first. ```1``` puts one interval group left of it and the rest right. The number of interval groups puts the category column last. A greater value raises a warning and is used as the number of groups. <br /><br /> The operation column and the `attributes` columns move with the category column.
1686
+ * @default 0
1687
+ */
1688
+ "categoryIntervalPosition": number;
1684
1689
  /**
1685
1690
  * Set width of category column, in em of the table font. <br /> If INF is selected the columns scaling to the min space they need seperatly. <br /><br /> The column is fixed at this width; a category label too long to fit is truncated with an ellipsis. <br /><br /> values:<br /> ``` w5 // w10 // w15 // w20 // w25 // w50 // inf ```
1686
1691
  * @default "w15"
@@ -1734,7 +1739,7 @@ export namespace Components {
1734
1739
  */
1735
1740
  "i18nNamespace"?: string;
1736
1741
  /**
1737
- * Repeats the entire scenario/variance column block once per interval group, rendered under a spanning header band (e.g. `2023 | 2024 | 2025`, each with the configured columns). <br /><br /> values:<br /> ```none // setname // year // quarter // month // week // day // hour // minute // second // millisecond // auto``` <br /><br /> ```none``` (default) deactivates the feature. ```setname``` groups by the dataset's `setname` column (non-date comparison); rows with a blank setname raise a warning and are grouped under `-`. Date values bucket rows by the `date` column; ```auto``` detects the granularity from the date span. Cannot be combined with `columnthereof`.
1742
+ * Repeats the entire scenario/variance column block once per interval group, rendered under a spanning header band (e.g. `2023 | 2024 | 2025`, each with the configured columns). <br /><br /> values:<br /> ```none // setname // year // quarter // month // week // day // hour // minute // second // millisecond // auto``` <br /><br /> ```none``` (default) deactivates the feature. ```setname``` groups by the dataset's `setname` column (non-date comparison); rows with a blank setname raise a warning and are grouped under `-`. Date values bucket rows by the `date` column; ```auto``` detects the granularity from the date span. Cannot be combined with `columnthereof`. <br /><br /> Date groups are shown in chronological order. Setname groups are shown in order of first appearance in the dataset. When the rows carry the optional numeric column `setnameIndex`, the setname groups are sorted ascending by it: the smallest index of a setname counts, groups without an index come last.
1738
1743
  * @default "none"
1739
1744
  */
1740
1745
  "interval": string;
@@ -1759,7 +1764,7 @@ export namespace Components {
1759
1764
  */
1760
1765
  "measureUnit": string;
1761
1766
  /**
1762
- * Comma list of the columns the rows are sorted by, left to right. `orderDirection` applies to all of them. <br /><br /> values: <br /> ```category // categoryindex // rowgroup // rowgroupindex // subcategory // subcategoryindex // ac[1-4] // fc[1-4] // pp[1-4] // pl[1-4] // auto``` <br /> or a variance, written like a scenario column, the sentiment is optional and ignored: ```dac1_pp1```, ```drfc1_pp1_pos``` <br /><br /> With `interval="setname"` a scenario or variance can name one bucket after `@`: ```dac1_pp1@_November``` sorts by that block only. Without a bucket the sum over all buckets is used. <br /><br /> The scenario or variance does not have to be a shown column; the sort arrow appears only on a shown one. A plain scenario also sorts the row groups by their sum. A variance or a token with `@` sorts only the rows inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data (and a relative variance with a zero reference) sort last. <br /><br /> When set to ```auto```, order is detected from the dataset silently.
1767
+ * Comma list of the columns the rows are sorted by, left to right. `orderDirection` applies to all of them. <br /><br /> values: <br /> ```category // categoryindex // rowgroup // rowgroupindex // subcategory // subcategoryindex // ac[1-4] // fc[1-4] // pp[1-4] // pl[1-4] // auto``` <br /> or a variance, written like a scenario column, the sentiment is optional and ignored: ```dac1_pp1```, ```drfc1_pp1_pos``` <br /><br /> With `interval="setname"` a scenario or variance can name one bucket after `@`: ```dac1_pp1@_November``` sorts by that block only. Without a bucket the sum over all buckets is used. <br /><br /> The scenario or variance does not have to be a shown column; the sort arrow appears only on a shown one. A plain scenario also sorts the row groups by their sum. A variance or a token with `@` sorts only the rows inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data (and a relative variance with a zero reference) sort last. <br /><br /> A data row with the category `REST` is the rest row of its group: sorted by a scenario or variance it stays the last row of the group. Its label comes from the `REST` translation. <br /><br /> When set to ```auto```, order is detected from the dataset silently.
1763
1768
  * @default "category"
1764
1769
  */
1765
1770
  "order": string;
@@ -1861,6 +1866,10 @@ export namespace Components {
1861
1866
  * @default []
1862
1867
  */
1863
1868
  "barColumns": string[];
1869
+ /**
1870
+ * @default 0
1871
+ */
1872
+ "categoryIntervalPosition": number;
1864
1873
  /**
1865
1874
  * @default TableCategoryWidth.INF
1866
1875
  */
@@ -3749,6 +3758,11 @@ declare namespace LocalJSX {
3749
3758
  * List of column names to render as bar charts instead of numbers. <br /><br /> Absolute variances (d_*) render as horizontal bar charts. Relative variances (dr_*) render as pin charts with a square head. Bars take the pattern of the minuend (FC hatched, PL outlined) in the colour of the sentiment; pin heads take the look of the minuend scenario (AC solid dark, PY solid grey, FC hatched, PL outlined); the axis takes the look of the reference scenario. Scenario columns (ac1..pl4) render as horizontal bar charts; when the table contains grouping structure (sum rows, thereof, or partof) they automatically render as an IBCS waterfall - data rows cascade from the running total and sum rows anchor at zero. Waterfall columns auto-scale to fit the bar column width (unit-scaling does not apply) and are not supported in combination with `interval` or `columnthereof`. <br /><br /> example:<br /> ```dac1_pp1_pos,drac1_pp1_pos,ac1```
3750
3759
  */
3751
3760
  "barColumns"?: string;
3761
+ /**
3762
+ * Number of interval groups that stand left of the category column. Needs an active `interval`. <br /><br /> ```0``` (default) keeps the category column first. ```1``` puts one interval group left of it and the rest right. The number of interval groups puts the category column last. A greater value raises a warning and is used as the number of groups. <br /><br /> The operation column and the `attributes` columns move with the category column.
3763
+ * @default 0
3764
+ */
3765
+ "categoryIntervalPosition"?: number;
3752
3766
  /**
3753
3767
  * Set width of category column, in em of the table font. <br /> If INF is selected the columns scaling to the min space they need seperatly. <br /><br /> The column is fixed at this width; a category label too long to fit is truncated with an ellipsis. <br /><br /> values:<br /> ``` w5 // w10 // w15 // w20 // w25 // w50 // inf ```
3754
3768
  * @default "w15"
@@ -3793,7 +3807,7 @@ declare namespace LocalJSX {
3793
3807
  */
3794
3808
  "i18nNamespace"?: string;
3795
3809
  /**
3796
- * Repeats the entire scenario/variance column block once per interval group, rendered under a spanning header band (e.g. `2023 | 2024 | 2025`, each with the configured columns). <br /><br /> values:<br /> ```none // setname // year // quarter // month // week // day // hour // minute // second // millisecond // auto``` <br /><br /> ```none``` (default) deactivates the feature. ```setname``` groups by the dataset's `setname` column (non-date comparison); rows with a blank setname raise a warning and are grouped under `-`. Date values bucket rows by the `date` column; ```auto``` detects the granularity from the date span. Cannot be combined with `columnthereof`.
3810
+ * Repeats the entire scenario/variance column block once per interval group, rendered under a spanning header band (e.g. `2023 | 2024 | 2025`, each with the configured columns). <br /><br /> values:<br /> ```none // setname // year // quarter // month // week // day // hour // minute // second // millisecond // auto``` <br /><br /> ```none``` (default) deactivates the feature. ```setname``` groups by the dataset's `setname` column (non-date comparison); rows with a blank setname raise a warning and are grouped under `-`. Date values bucket rows by the `date` column; ```auto``` detects the granularity from the date span. Cannot be combined with `columnthereof`. <br /><br /> Date groups are shown in chronological order. Setname groups are shown in order of first appearance in the dataset. When the rows carry the optional numeric column `setnameIndex`, the setname groups are sorted ascending by it: the smallest index of a setname counts, groups without an index come last.
3797
3811
  * @default "none"
3798
3812
  */
3799
3813
  "interval"?: string;
@@ -3818,7 +3832,7 @@ declare namespace LocalJSX {
3818
3832
  */
3819
3833
  "measureUnit"?: string;
3820
3834
  /**
3821
- * Comma list of the columns the rows are sorted by, left to right. `orderDirection` applies to all of them. <br /><br /> values: <br /> ```category // categoryindex // rowgroup // rowgroupindex // subcategory // subcategoryindex // ac[1-4] // fc[1-4] // pp[1-4] // pl[1-4] // auto``` <br /> or a variance, written like a scenario column, the sentiment is optional and ignored: ```dac1_pp1```, ```drfc1_pp1_pos``` <br /><br /> With `interval="setname"` a scenario or variance can name one bucket after `@`: ```dac1_pp1@_November``` sorts by that block only. Without a bucket the sum over all buckets is used. <br /><br /> The scenario or variance does not have to be a shown column; the sort arrow appears only on a shown one. A plain scenario also sorts the row groups by their sum. A variance or a token with `@` sorts only the rows inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data (and a relative variance with a zero reference) sort last. <br /><br /> When set to ```auto```, order is detected from the dataset silently.
3835
+ * Comma list of the columns the rows are sorted by, left to right. `orderDirection` applies to all of them. <br /><br /> values: <br /> ```category // categoryindex // rowgroup // rowgroupindex // subcategory // subcategoryindex // ac[1-4] // fc[1-4] // pp[1-4] // pl[1-4] // auto``` <br /> or a variance, written like a scenario column, the sentiment is optional and ignored: ```dac1_pp1```, ```drfc1_pp1_pos``` <br /><br /> With `interval="setname"` a scenario or variance can name one bucket after `@`: ```dac1_pp1@_November``` sorts by that block only. Without a bucket the sum over all buckets is used. <br /><br /> The scenario or variance does not have to be a shown column; the sort arrow appears only on a shown one. A plain scenario also sorts the row groups by their sum. A variance or a token with `@` sorts only the rows inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data (and a relative variance with a zero reference) sort last. <br /><br /> A data row with the category `REST` is the rest row of its group: sorted by a scenario or variance it stays the last row of the group. Its label comes from the `REST` translation. <br /><br /> When set to ```auto```, order is detected from the dataset silently.
3822
3836
  * @default "category"
3823
3837
  */
3824
3838
  "order"?: string;
@@ -4366,6 +4380,7 @@ declare namespace LocalJSX {
4366
4380
  "categoryWidth": string;
4367
4381
  "columnthereof": string | null;
4368
4382
  "interval": string;
4383
+ "categoryIntervalPosition": number;
4369
4384
  "tableAttributes": string;
4370
4385
  }
4371
4386
  interface BnTableRendererAttributes {
@@ -11,7 +11,9 @@ export declare function readSvgBaseline(svgRoot: ParentNode, host: Element): Bas
11
11
  export declare function readChartBaseline(host: HTMLElement, innerTag: string): Baseline;
12
12
  /**
13
13
  * Baseline of a rendered `<table>`, in the layout px of `host`: y is the
14
- * bottom of the header, x the left edge of the first value column (the cell
15
- * after the category column of the last header row, else of the first body row).
14
+ * bottom of the header, x the left edge of the first value column of the last
15
+ * header row, else of the first body row. That is the first cell that is not
16
+ * the operation or the category column. Interval groups can stand left of the
17
+ * category column, then it is the first cell of the row.
16
18
  */
17
19
  export declare function readTableBaseline(table: Element | null | undefined, host: Element): Baseline;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bino-bi/bn-template-engine",
3
- "version": "1.0.0-next.37",
3
+ "version": "1.0.0-next.39",
4
4
  "description": "IBCS-compliant web components for business intelligence tables and charts",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -1 +0,0 @@
1
- import{h as t,p as e,H as i,f as n,a as o,t as s}from"./p-D6YGOYV1.js";import{m as r,a as l,b as a}from"./p-DaOm9YwQ.js";import{p as h,n as c,r as u,d}from"./p-BzjGUtYh.js";import{F as f,V as p,Q as v,s as $,a as m,I as g,b}from"./p-CniN8ALm.js";import{S as w,I as E,D as S,C as R,d as y,M}from"./p-B5tixDPM.js";import{N as O,r as N}from"./p-fCjsrD7I.js";import{D as U,w as G}from"./p-Dq9dG0Kr.js";import{D as _,b as T}from"./p-sLbQ7yZ1.js";import{F as L}from"./p-DCPLGEs_.js";import{p as x,c as C}from"./p-16rjcQ0t.js";import{d as k,g as A}from"./p-DDvWTgk1.js";import{D as P,a as D,b as W}from"./p-7ieJFBUk.js";import{A as B}from"./p-BXg3v5AO.js";import{S as F}from"./p-BPGLOHUe.js";import{S as Y}from"./p-CeE4_3wQ.js";import{w as H}from"./p-DjPWZfry.js";var j,I,z,Q,V;!function(t){t[t.ALL=-1]="ALL"}(j||(j={})),function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(I||(I={})),function(t){t.LIST="list",t.SUM="sum",t.SUMNOTOTAL="sumnototal",t.OPT="opt",t.OPTNOTOTAL="optnototal"}(z||(z={})),function(t){t.ASC="asc",t.DESC="desc"}(Q||(Q={})),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"}(V||(V={}));const X="none",q="setname";function K(t){return t===q?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function Z(t){if(null==t)return"";if("string"==typeof t)return t.trim();const e=J(t);return e?e.toISO():String(t)}function J(t){if(null!=t){if("string"==typeof t){const e=U.fromISO(t,{zone:"utc"});return e.isValid?e:void 0}if("number"==typeof t){const e=U.fromMillis(t,{zone:"utc"});return e.isValid?e:void 0}if("boolean"==typeof t.isValid)return t.isValid?t:void 0}}const tt=/[\s\u200e\u200f\u061c]*[%\u066a][\s\u200e\u200f\u061c]*/;class et{constructor(t,e,i,n,o,s,r,l,a){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=e,this.value=i,this.prefix=s||"",this.cssStyle=n||"",this.prefixStyle=r||"prefix",this.type=o,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,e){let i=this.value;if("undefined"===i||void 0===i||null==i)return"";if(Number.isNaN(Number(i)))return i;if(""===this.type||void 0===this.type||null==this.type)return i;let n=t.percent,o=t.percent;return"percentpoint"===this.type?f.number(Number(i),"percent",n,o,1,e).replace(tt,""):("decimal"===this.type&&(i=+i/this.measureScale,n=t.decimal,o=t.decimal),f.number(Number(i),this.type,n,o,1,e))}drawPrefix(){return null==this.prefix?"":this.prefix}}class it{constructor(t,e,i){this.index=t,this.groupindex=e,this.type=i,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case V.HEADER:return"groupheader";case V.SEPERATORLINE:return"";case V.DRILLELEMENT:return"ofit";case V.PARTELEMENT:return"partof";case V.STANDARD:return"";case V.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,e,i,n,o,s,r,l,a,h=!1,c,u=1,d){let f=s;"category"===e&&null!=l&&(f=`category-${l.toString()}`),this.type===V.HEADER?f="headerlabel":this.type===V.SEPERATORLINE&&(f=null!=s?s:e),this.type===V.PARTELEMENT&&("percent"===n&&(t="-"),"category"!==e&&"operation"!==e&&(n="percent",f="")),("-"===t||t===O&&"percent"===n)&&(f="");let p="prefix-first";r&&(p="prefix-second"),i&&(f=`${f} ${i}`);const v=new et(e,this.elements.length,t,f,n,o,p,u,a);v.isBarChart=h,v.columnStats=c,v.waterfall=d,this.elements.push(v)}}const nt=.85,ot=.3,st=.25,rt={".":.28,",":.28,"-":.34,"%":.89," ":.28," ":.28," ":.28,M:.9};function lt(t,e){var i;let n=0;for(const e of t)n+=null!==(i=rt[e])&&void 0!==i?i:/[0-9+]/.test(e)?.59:.72;return n*e*1.1}let at;function ht(t,e,i,n){const o=function(){var t,e,i;if(void 0===at)try{at="undefined"==typeof document?null:null!==(i=null===(e=(t=document.createElement("canvas")).getContext)||void 0===e?void 0:e.call(t,"2d"))&&void 0!==i?i:null}catch(t){at=null}return at}();if(o){o.font="1px __bn_font_sentinel__";const s=o.font;if(o.font=`${n?"italic ":""}${e}px ${i}`,o.font===s)return lt(t,e);const r=o.measureText(t).width;if(Number.isFinite(r)&&(r>0||""===t))return r+.15*e}return lt(t,e)}function ct(t,e){return Math.max(0,(t-.5)*e)}function ut(t,e,i){const n=void 0!==t.neg,o=void 0!==t.pos||!n,s=(t,n)=>t?e+i+(null!=n?n:0):0;return{sides:(n?1:0)+(o?1:0),neg:s(n,t.neg),pos:s(o,t.pos)}}function dt(t,e,i,n){const{sides:o,neg:s,pos:r}=ut(e,i,n),l=s+r>0?Math.min(1,t/(s+r)):1,a=Math.max(0,(t-(s+r)*l)/o);return{extent:a,axisX:void 0!==e.neg?s*l+a:0}}function ft(t,e,i,n){const o=ct(t,e),{sides:s,neg:r,pos:l}=ut(i,n/2,ot*e);return r+l+s*function(t,e,i){return Math.min(1*e,t/(2*i))}(o,e,s)<=o+1e-6}function pt(t,e,i){const n=ct(t,e),o=ot*e,{extent:s,axisX:r}=dt(n,i,st*e/2,o),l=Math.min(.3*e,.2*s),a=.15*s;return{totalWidth:n,maxBarWidth:s,axisX:r,breakGap:l,overdriveZoneWidth:a,cutWidth:Math.max(0,s-l-a),labelGap:o}}function vt(t,e,i,n,o){var s,r;const l=ct(t,e),a=ot*e,{extent:h,axisX:c}=dt(l,i,n/2,a),u=void 0!==i.neg,d=void 0!==i.pos||!u;let f=u?h:0,p=d?h:0;if(o&&u&&d){const t=2*h,e=Math.max(0,null!==(s=o.neg)&&void 0!==s?s:0),i=Math.max(0,null!==(r=o.pos)&&void 0!==r?r:0);e+i<=t+1e-6?(f=e+(t-e-i)/2,p=t-f):e<h?(f=e,p=t-f):i<h&&(p=i,f=t-p)}return{totalWidth:l,maxPinLength:Math.max(f,p),negPinLength:f,posPinLength:p,axisX:u?c-h+f:0,labelGap:a}}const $t={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.333305,emPx:13.3333,fontFamily:"'Noto Sans', sans-serif",unitScaling:.01,percentageScaling:.5,scaleFactor:1},mt="#666666";function gt(t,e){return`pattern-${t}-${e.replace("#","")}`}const bt=({styles:e})=>{const i=e.scaleFactor,n=6*i,o=[{id:gt("pos",e.positive.stroke),stroke:e.positive.stroke,fill:e.positive.fill},{id:gt("neg",e.negative.stroke),stroke:e.negative.stroke,fill:e.negative.fill},{id:gt("neu",e.neutral.stroke),stroke:e.neutral.stroke,fill:e.neutral.fill},...["ac","pp","fc","pl"].map((t=>({id:gt(t,e.scenarios[t].stroke),stroke:e.scenarios[t].stroke,fill:e.scenarios[t].fill})))];return t("defs",null,o.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*i})))))};function wt(t,e,i=1,n,o=0,s=!0){const r=(e,i)=>(t>0&&e!==i?"+":"")+e;if(e){const e=(t,e)=>s?f.number(t,"percent",e,e,1,n):f.number(100*t,"decimal",e,e,1,n),i=i=>r(e(t,i),e(0,i));let l=Math.min(20,Math.max(0,Math.trunc(o)||0));for(;l>0&&i(l).length>7;)l--;return i(l)}const l=t/i,a=Math.abs(l);let h=1,c="";a>=9995e5?(h=1e9,c="B"):a>=999500?(h=1e6,c="M"):a>=999.5&&(h=1e3,c="K");const u=a>=10*h?0:1;return r(f.number(l/h,"decimal",u,0,1,n),f.number(0,"decimal",u,0,1,n))+c}function Et(t){const e=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(e)}function St(t){const e=t.slice(0,2).toLowerCase();return"pp"===e?"pp":"fc"===e?"fc":"pl"===e?"pl":"ac"}function Rt(t,e){if(Et(t))return null;const i=new p(t);if(!i.isValid)return null;const n=St(i.base),o=St(i.delta);return{minuend:e.scenarios[n],minuendSlot:n,reference:e.scenarios[o],referenceSlot:o}}const yt=({x:e,height:i,look:n,styles:o})=>{const s=o.scaleFactor,r=st*o.emPx,{reference:l,referenceSlot:a}=n;let h;if("outlined"===l.fillpattern){const n=r/2-.5*s;h=[e-n,e+n].map((e=>t("line",{x1:e,y1:0,x2:e,y2:i,stroke:l.stroke,"stroke-width":1*s})))}else h=t("line","hatched"===l.fillpattern?{x1:e,y1:0,x2:e,y2:i,stroke:l.stroke,"stroke-width":r,"stroke-dasharray":""+2*s}:{x1:e,y1:0,x2:e,y2:i,stroke:l.fill,"stroke-width":r});return t("g",{class:`variance-axis axis-${a}`},h)};function Mt(t){return void 0!==t.pos||void 0===t.neg}function Ot(t,e){return{neg:t.min<0?e:void 0,pos:t.max>0?e:void 0}}function Nt(t,e,i,n){return Et(t)?function(t,e){const i=St(t);return e.scenarios[i]}(t,n):function(t,e,i){const n=t>=0;return e?n?i.positive:i.negative:n?i.negative:i.positive}(e,i,n)}function Ut(t,e){const i=t.fillpattern;return"hatched"===i?`url(#${gt(e,t.stroke)})`:"outlined"===i?"transparent":t.fill}function Gt(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const _t=e=>{const{value:i,scenario:n,columnStats:o,height:s,isPositiveGood:r,formattedValue:l,measureScale:a,locale:h,columnWidthEm:c=10,labelWidths:u,styles:d=$t}=e,f=d.scaleFactor,p=d.fontSize,v=l||wt(i,!1,a,h),$=null!=u?u:Ot(o,ht(v,p,d.fontFamily,!1)),{totalWidth:m,axisX:g,breakGap:b,overdriveZoneWidth:w,cutWidth:E,labelGap:S}=pt(c,d.emPx,$),R=Math.abs(i)*d.unitScaling*p,y=R-E>1e-6,M=Math.max(0,o.absMax*d.unitScaling*p-E),O=Math.max(0,R-E),N=M>0?O/M*w:0,U=2*f,G=s-2*U,_=U,T=i>0||0===i&&Mt($),L=Rt(n,d),x=Nt(n,i,r,d),C=null==L?void 0:L.minuend.fillpattern,k="hatched"===C||"outlined"===C?Object.assign(Object.assign({},x),{fillpattern:C}):x,A=Ut(k,Et(n)?St(n):r?T?"pos":"neg":T?"neg":"pos"),{stroke:P,strokeWidth:D}=L&&"hatched"===k.fillpattern?{stroke:k.stroke,strokeWidth:1}:Gt(k),W=L?st*d.emPx/2:0,B=T?g+W:g-W,F=y?E:R,Y=y?E+b+N:R,H=T?B+Y+S:B-Y-S,j=T?"start":"end";return t("svg",{width:m,height:s,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},t(bt,{styles:d}),!L&&t("line",{x1:g,y1:0,x2:g,y2:s,stroke:mt,"stroke-width":1*f}),F>0&&t("rect",{x:T?B:B-F,y:_,width:F,height:G,fill:A,stroke:P,"stroke-width":D*f}),y&&N>0&&t("rect",{x:T?B+E+b:B-E-b-N,y:_,width:N,height:G,fill:A,stroke:P,"stroke-width":D*f}),y&&function(e,i,n,o,s){const r=e+i/2,l=.35*i,a=o/3,h=.3*i;let c=`M ${r-l} ${n}`;for(let t=0;t<3;t++)c+=` L ${r-l-h} ${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+h} ${n+a*(t+.5)} L ${r+l} ${n+a*(t+1)}`;return[t("rect",{x:e,y:n-1,width:i,height:o+2,fill:"#ffffff"}),t("path",{d:c,fill:"none",stroke:"#000000","stroke-width":1*s}),t("path",{d:u,fill:"none",stroke:"#000000","stroke-width":1*s})]}(T?B+E:B-E-b,b,_,G,f),L&&t(yt,{x:g,height:s,look:L,styles:d}),t("text",{x:H,y:s/2,dy:"0.35em","text-anchor":j,fill:d.fontColor,"font-size":p,"font-family":d.fontFamily},v))},Tt=e=>{var i,n;const{value:o,scenario:s,columnStats:r,height:l,isPositiveGood:a,formattedValue:h,measureScale:c,locale:u,percentDigits:d,percentSign:f,columnWidthEm:p=10,labelWidths:v,sideMax:$,styles:m=$t}=e,g=m.scaleFactor,b=m.fontSize,w=10*g,E=100*m.percentageScaling*b,S=h||wt(o,!0,c,u,d,f),R=null!=v?v:Ot(r,ht(S,b,m.fontFamily,!0)),{neg:y=Math.max(0,-r.min),pos:M=Math.max(0,r.max)}=null!=$?$:{},{totalWidth:O,negPinLength:N,posPinLength:U,axisX:G,labelGap:_}=vt(p,m.emPx,R,w,{neg:y*E,pos:M*E}),T=l/2,L=Math.abs(o)*E,x=o>0||0===o&&Mt(R),C=x?U:N,k=L-C>1e-6,A=x?1:-1,P=G+A*Math.min(L,C),D=Nt(s,o,a,m),W=Rt(s,m),B=null!==(i=null==W?void 0:W.minuend)&&void 0!==i?i:m.scenarios.ac,F=G+A*(C+w/2),Y=F-A*w,H=(k?F:P+A*(w/2))+A*_;return t("svg",{width:O,height:l,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},t(bt,{styles:m}),W?t(yt,{x:G,height:l,look:W,styles:m}):t("line",{x1:G,y1:0,x2:G,y2:l,stroke:mt,"stroke-width":1*g}),t("line",{x1:G,y1:T,x2:k?Y:P,y2:T,stroke:D.fill,"stroke-width":3*g}),k?t("polygon",{points:`${F},${T} ${Y},${T-w/2} ${Y},${T+w/2}`,fill:D.fill}):t("rect",{x:P-w/2,y:T-w/2,width:w,height:w,fill:"outlined"===B.fillpattern?"#ffffff":Ut(B,null!==(n=null==W?void 0:W.minuendSlot)&&void 0!==n?n:"ac"),stroke:B.stroke,"stroke-width":1*g}),t("text",{x:H,y:l/2,dy:"0.35em","text-anchor":x?"start":"end",fill:m.fontColor,"font-size":b,"font-style":"italic","font-family":m.fontFamily},S))},Lt=e=>{const{value:i,columnStats:n,isRelative:o,styles:s=$t}=e;return null==i||isNaN(i)||!n||0===n.absMax?t("span",{class:"bar-chart-empty",style:{color:s.fontColor,fontStyle:"italic"}},"-"):t(o?Tt:_t,Object.assign({},e))},xt=e=>{const{value:i,scenario:n,height:o,measureScale:s,locale:r,columnWidthEm:l=10,styles:a=$t,waterfall:h}=e,c=a.scaleFactor,u=a.fontSize,d=h.max-h.min;if(null==i||isNaN(i)||d<=0)return t("span",{class:"bar-chart-empty",style:{color:a.fontColor,fontStyle:"italic"}},"-");const{totalWidth:f,labelAreaWidth:p,barAreaWidth:v,labelGap:$}=function(t,e){const i=ct(t,e),n=Math.min(2.85*e,i/4);return{totalWidth:i,labelAreaWidth:n,barAreaWidth:i-2*n,labelGap:ot*e}}(l,a.emPx),m=v/d,g=t=>p+(t-h.min)*m,b=2*c,w=o-2*b,E=b,S=g(0),R=g(h.start),y=g(h.end),M=Math.min(R,y),O=Math.abs(y-R),N=Nt(n,i,!1,a),U=Ut(N,St(n)),{stroke:G,strokeWidth:_}=Gt(N),T=wt(i,"partof"===h.kind,s,r).replace(/^\+/,""),L=y<R,x=L?M-$:M+O+$,C=L?"end":"start";return t("svg",{width:f,height:o,class:"cell-bar-chart waterfall-bar",style:{overflow:"visible"}},t(bt,{styles:a}),t("line",{x1:S,y1:0,x2:S,y2:o,stroke:mt,"stroke-width":1*c}),void 0!==h.parentStart&&void 0!==h.parentEnd&&t("line",{x1:g(h.parentStart),y1:0,x2:g(h.parentStart),y2:o,stroke:mt,"stroke-width":1*c,"stroke-dasharray":`${2*c},${2*c}`}),void 0!==h.parentStart&&void 0!==h.parentEnd&&t("line",{x1:g(h.parentEnd),y1:0,x2:g(h.parentEnd),y2:o,stroke:mt,"stroke-width":1*c,"stroke-dasharray":`${2*c},${2*c}`}),O>0&&t("rect",{x:M,y:E,width:O,height:w,fill:U,stroke:G,"stroke-width":_*c}),t("text",{x,y:o/2,dy:"0.35em","text-anchor":C,fill:a.fontColor,"font-size":u,"font-family":a.fontFamily},T))},Ct=`IFNULL(${v.ROWGROUP}, '')`;class kt{constructor(t){this.groups=[v.CATEGORY,v.CATEGORYINDEX],z.OPT!==t.type&&z.OPTNOTOTAL!==t.type||this.groups.unshift(v.OPERATION),t.grouped&&(this.groups.push(v.ROWGROUP),this.groups.push(v.ROWGROUPINDEX))}toString(){return this.groups.map((t=>t===v.ROWGROUP?Ct:t)).toString()}select(){return this.groups.map((t=>t===v.ROWGROUP?`${Ct} as ${t}`:t)).toString()}noCategory(){return this.groups.filter((t=>t!==v.CATEGORY))}toArray(){return this.groups}}class At{constructor(t,e){this.hasPartOf=!1,this.params=[],this.sortSelect="",this.hasBlankRowGroup=!1,this.config=t,this.i18n=e}execute(t,e){var i;this.db=t,this.fromExpr=e;for(const t of[...this.config.scenarios,...this.config.categoryThereOf.keys()])if(!L.test(t))throw new Error(`invalid identifier "${t}"`);const n=[],o=[],s=[],r=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),l=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),a=this.getRelativeScenarios(),h=this.config.attributes.map((t=>this.translateAttributeSQL(t))).toString(),c=new kt(this.config),u=this.config.interval===q?this.config.sortOrder:{hierarchy:this.config.sortOrder.hierarchy.map((t=>{var e,i;return null!==(i=null===(e=x(t))||void 0===e?void 0:e.column)&&void 0!==i?i:t})),direction:this.config.sortOrder.direction};let d=["",""];u.hierarchy.length>0&&(d=this.createOrderString(u)),this.hasPartOf=this.checkConfigForPartOf();const{hierarchy:f,direction:p}=u,$=f.filter((t=>t===v.ROWGROUP||t===v.ROWGROUPINDEX||t.toUpperCase()in w)),m=$.filter((t=>t.toUpperCase()in w)).map((t=>`, SUM(${t} * transformOperator(operation)) as ${t}`)).join(""),g=$.length>0?$.map((t=>`${t} ${p}`)).toString():`${v.ROWGROUPINDEX} asc`,b=t.exec(`SELECT COUNT(DISTINCT ${v.CATEGORY}) as ${v.TOTALROWCOUNT} ${this.config.grouped?`, ${Ct} as ${v.ROWGROUP}, FIRST(${v.ROWGROUPINDEX}) as ${v.ROWGROUPINDEX}${m}`:""}\n FROM ${e} ${this.config.grouped?`GROUP BY ${Ct} ORDER BY ${g}`:""}`);return 0===b.length||1===b.length&&0===(null!==(i=b[0][v.TOTALROWCOUNT])&&void 0!==i?i:0)&&!this.config.grouped?[]:(this.hasBlankRowGroup=this.config.grouped&&b.some((t=>""===t.rowGroup)),b.forEach((t=>{const e=this.config.grouped?""===t.rowGroup?`WHERE (${v.ROWGROUP} IS NULL OR ${v.ROWGROUP} = '')`:`WHERE ${v.ROWGROUP} = ${this.bind(t.rowGroup)}`:"";let i="";this.config.limit&&(i=`LIMIT ${this.config.limit}`),this.createGroupHeaderRow(t,n),this.createDataRow(n,t,c,r,h,e,d,i),this.createRestRow(t,n,c,r,e,d),this.createGroupSumRow(n,o,t,l,e,d)})),this.createTotalSumRow(n,o,l),n.forEach((t=>s.push(this.exec(t)))),this.detectNaNCells(this.config.scenarios,s),this.createThereOfDrillRows(r,h,d,s),this.createPartOfDrillRows(r,d,o,s),this.createIntervalColumns(s),this.createThereOfDrillColumns(this.config.categoryThereOf,s),this.calculateColumnGroupRest(s,this.config.categoryThereOf),this.calculateRelativeVariances(s,a),s)}detectNaNCells(t,e){e.forEach((e=>{e.map((e=>(t.forEach((t=>{const i=new p(t);!0===i.isValid?0!==e[i.base+"_cnt"]&&0!==e[i.delta+"_cnt"]||(e[t]=Number.NaN):0===e[t+"_cnt"]&&(e[t]=Number.NaN)})),e)))}))}createPartOfDrillRows(t,e,i,n){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===z.LIST)return;const o=this.createPartOfQuery(t,e);let s=[];const r=this.db,l=this.params;o.forEach((t=>{s.push(...this.exec(t))}));const a=this.exctractScenarioNames(t),h=[];i.forEach((function(t){h.push(...r.exec(t,l))}));const c=new Map;h.forEach((t=>c.set(t[v.ROWGROUP],t))),s=this.reduceResDrillByCategoryGroups(s,a),s.forEach((function(t){a.forEach((e=>{try{t[e]=t[e]/c.get(t[v.ROWGROUP])[e]}catch(i){console.error("DataQuery: partOf drill row calculation failed",e,i),t[e]=Number.NaN}}))})),this.injectDrillRowsToResultRows(s,n)}createRestRow(t,e,i,n,o,s){var r;if(t.totalRowCnt-this.config.limit>0&&0!==this.config.limit){const l=this.exctractScenarioNames(n).map((t=>`SUM(${t}) as ${t}`)).join(", "),a=z.OPT===this.config.type||z.OPTNOTOTAL===this.config.type?", CASE WHEN MAX(transformOperator(operation)) = -1 THEN '-' ELSE '+' END as restOperation":"";e.push(`SELECT ${v.ROWNR}, 1 as ${v.ROWGROUPINDEX} , 'ENTRY' as ${v.TYPE}, 'NO_GROUP' as ${v.ROWGROUP}, ${this.bind(String(null!==(r=t.rowGroup)&&void 0!==r?r:""))} as restRowGroup, 'REST' as ${v.CATEGORY}${a} ${l.length>0?", "+l:""} FROM (SELECT ROWNUM() AS ${v.ROWNR}, ${e.length} as ${v.ROWGROUPINDEX} , 'ENTRY' as ${v.TYPE}, ${this.bind(String(t.rowGroup||"NO_GROUP"))} as ${v.ROWGROUP}, ${i.select()} ${n.length>0?",".concat(n):""}${this.sortSelect} FROM ${this.fromExpr} ${o} GROUP BY ${i} ORDER BY ${s[0]}) t WHERE t.rowNr > ${this.config.limit}`)}}createDataRow(t,e,i,n,o,s,r,l){t.push(`SELECT ROWNUM() AS ${v.ROWNR},\n ${t.length} as ${v.ROWGROUPINDEX},\n 'ENTRY' as ${v.TYPE},\n ${this.bind(String(e.rowGroup||"NO_GROUP"))} as ${v.ROWGROUP},\n '${v.CATEGORYINDEX}',\n ${i.select()} ${n.length>0?",".concat(n):""} ${o.length>0?",".concat(o):""}${this.sortSelect}\n FROM ${this.fromExpr} ${s}\n GROUP BY ${i}\n ORDER BY ${r[0]} ${l}`)}createGroupHeaderRow(t,e){if(!0===this.config.grouped){const i=this.bind(String(t.rowGroup)),n=""===t.rowGroup?this.bind("-"):i;e.push(`SELECT ROWNUM() AS ${v.ROWNR},\n ${e.length} as ${v.ROWGROUPINDEX},\n 'GROUPHEAD' as ${v.TYPE},\n ${i} as ${v.ROWGROUP} ${this.config.showGroupTitle?`,${n} as ${v.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}}createGroupSumRow(t,e,i,n,o,s){if(!0===this.config.grouped&&(z.SUM===this.config.type||z.SUMNOTOTAL===this.config.type||z.OPT===this.config.type||z.OPTNOTOTAL===this.config.type)){const r=this.bind(String(i.rowGroup));t.push(`SELECT ${t.length} as ${v.ROWGROUPINDEX},\n '=' as ${v.OPERATION},\n ${r} as ${v.ROWGROUP},\n ROWNUM() AS ${v.ROWNR},\n 'GROUP_SUM' as ${v.TYPE} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr} ${o}\n ORDER BY ${s[0]} `),e.push(`SELECT ${t.length} as ${v.ROWGROUPINDEX},\n '=' as ${v.OPERATION},\n ${r} as ${v.ROWGROUP},\n ROWNUM() AS ${v.ROWNR},\n 'GROUP_SUM' as ${v.TYPE} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr} ${o}\n ORDER BY ${s[0]} `)}}createTotalSumRow(t,e,i){var n;if(z.SUM===this.config.type||z.OPT===this.config.type){const e=(null===(n=this.config.title)||void 0===n?void 0:n.trim())||"SUM_TOTAL",o=this.hasPartOf&&!1===this.config.grouped&&"SUM_TOTAL"!==e?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} ${e}`:e;t.push(`SELECT ${t.length} as ${v.ROWGROUPINDEX},\n ${this.bind(o)} as ${v.ROWGROUP},\n '=' as ${v.OPERATION},\n 'SUM' as ${v.TYPE} ${i.length>0?",".concat(i):""}\n FROM ${this.fromExpr} `)}e.push(`SELECT ${t.length} as ${v.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${v.ROWGROUP},\n '=' as ${v.OPERATION},\n 'SUM' as ${v.TYPE} ${i.length>0?",".concat(i):""}\n FROM ${this.fromExpr} `)}reduceResDrillByCategoryGroups(t,e){const i=new Map;return t.forEach((function(t){const n=t.rowNr+t.rowGroup+t.type+t.category;if(i.has(n)){const o=i.get(n);e.forEach((e=>{try{o[e]+=t[e]}catch(t){console.error("DataQuery: drill row aggregation failed",e,t)}}))}else i.set(n,t)})),[...i.values()]}injectDrillRowsToResultRows(t,e){const i=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(i.has(`${t.category}_${t.rowGroup}`)){const e=i.get(`${t.category}_${t.rowGroup}`)||0;i.set(`${t.category}_${t.rowGroup}`,e+1)}else i.set(`${t.category}_${t.rowGroup}`,1);t[v.ROWNR]=i.get(`${t.category}_${t.rowGroup}`),e.splice(n+t[v.ROWNR],0,t)}}))}));else{const n=this.findDuplicateSubCategories(t);t.forEach((function(t){e.forEach((function(e){const o=e.findIndex((e=>null!=e.category&&e.category===t.category));if(o>=0){if(i.has(`${t.category}`)){const e=i.get(`${t.category}`)||0;i.set(`${t.category}`,e+1)}else i.set(`${t.category}`,1);null!=t.rowGroup&&""!==t.rowGroup&&n.includes(`${t.category}##${t.subCategory}`)&&(t.rawSubCategory=t.subCategory,t.subCategory=`${t.subCategory} (${t.rowGroup})`),e.splice(o+t[v.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,e,i,n){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const o=[],s=[];this.config.thereOf.forEach((n=>{let s=!0,r="1 <> 1 OR ( ";null!=n.category&&0!==n.category.length&&n.category.trim()&&(r+=` ${v.CATEGORY} = ${this.bind(n.category)}`,s=!1),null!=n.rowGroup&&0!==n.rowGroup.length&&n.rowGroup.trim()&&(r+=` ${s?"":"AND"} ${v.ROWGROUP} = ${this.bind(n.rowGroup)}`,s=!1),null!=n.subCategory&&0!==n.subCategory.length&&n.subCategory.trim()&&(r+=` ${s?"":"AND"} ${v.SUBCATEGORY} = ${this.bind(n.subCategory)}`),r+=")",o.push(`SELECT ROWNUM() AS ${v.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${v.TYPE},\n ${v.CATEGORY},\n ${v.SUBCATEGORY},\n ${this.drillRowGroup} as ${v.ROWGROUP},\n ${t} ${e.length>0?",".concat(e):""}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${r}\n GROUP BY ${this.drillRowGroup}, ${v.CATEGORY}, ${v.SUBCATEGORY}\n ORDER BY ${i[1]}`)})),o.forEach((t=>{s.push(...this.exec(t))})),this.injectDrillRowsToResultRows(s,n)}calculateRelativeVariances(t,e){t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[v.TYPE]&&e.forEach(((e,i)=>{var n;t[i]=null!==(n=N(t[i],t[e]))&&void 0!==n?n:O}))}))}))}calculateColumnGroupRest(t,e){if(null==e||0===e.size)return;const i=new Map,n=new Map;e.forEach(((t,e)=>{const o=t,s=[];for(const t of o)s.push(`${e}##${t.name}`);i.set(e,s),n.set(`${e}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[v.TYPE]&&i.forEach(((e,i)=>{let o=0;e.forEach((e=>{void 0!==t[e]&&(o+=t[e])})),t[`${i}##REST`]=t[i]-o,0!==t[`${i}##REST`]&&n.set(`${i}##REST`,!0)}))}))}));const o=Array.from(n.entries()).filter((([t,e])=>!e)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const e of o)delete t[e]}))}))}createIntervalColumns(t){var e,i,n,o,s;if(this.config.interval===X||this.config.categoryThereOf.size>0||0===this.config.scenarios.length)return;const r="##",l=`(SELECT *, ${K(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`,a=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),h=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),c=[...new Set(this.exctractScenarioNames(a))],u=this.getRelativeScenarios(),d=new kt(this.config),f=z.OPT===this.config.type||z.OPTNOTOTAL===this.config.type,$=this.config.grouped&&(z.SUM===this.config.type||z.SUMNOTOTAL===this.config.type||z.OPT===this.config.type||z.OPTNOTOTAL===this.config.type),m=this.checkConfigForPartOf()&&this.config.type!==z.LIST,g=t=>this.exec(t),b=t=>(this.config.scenarios.forEach((e=>{const i=new p(e);!0===i.isValid?0!==t[i.base+"_cnt"]&&0!==t[i.delta+"_cnt"]||(t[e]=Number.NaN):0===t[e+"_cnt"]&&(t[e]=Number.NaN)})),u.forEach(((e,i)=>{var n;t[i]=null!==(n=N(t[i],t[e]))&&void 0!==n?n:O})),t),w=(t,e,i)=>{for(const n of this.config.scenarios)t[n+r+i]=e[n]},E=g(`SELECT ${d.select()}, __interval ${a.length>0?",".concat(a):""}\n FROM ${l}\n GROUP BY ${d}, __interval`);if(this.config.limit>0)for(let n=0;n<t.length;n++){const o=t[n].find((t=>"ENTRY"===t.type&&"REST"===t.category));if(!o)continue;let s;for(let e=n-1;e>=0&&!s;e--){const i=t[e].filter((t=>"ENTRY"===t.type&&"REST"!==t.category));i.length>0&&(s=i)}if(!s)continue;const r=new Set(s.map((t=>t.category))),l=s[0].rowGroup,a=new Map;for(const t of E){if(this.config.grouped&&t.rowGroup!==l)continue;if(r.has(t.category))continue;const n=Z(t.__interval);let o=a.get(n);o||(o={},a.set(n,o));for(const n of c)o[n]=(null!==(e=o[n])&&void 0!==e?e:0)+(null!==(i=t[n])&&void 0!==i?i:0)}a.forEach(((t,e)=>{w(o,b(t),e)}))}for(const e of E){const i=Z(e.__interval);b(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||f&&t.operation!==e.operation||w(t,e,i))}const S=$||m&&this.config.grouped?g(`SELECT ${Ct} as ${v.ROWGROUP}, __interval ${h.length>0?",".concat(h):""}\n FROM ${l}\n GROUP BY ${Ct}, __interval`):[],R=new Map;if(S.forEach((t=>R.set(`${t.rowGroup}${r}${Z(t.__interval)}`,t))),$)for(const e of S){const i=Z(e.__interval),n=b(Object.assign({},e));for(const o of t)for(const t of o)"GROUP_SUM"===t.type&&t.rowGroup===e.rowGroup&&w(t,n,i)}const y=z.SUM===this.config.type||z.OPT===this.config.type,M=y||m&&!this.config.grouped?g(`SELECT __interval ${h.length>0?",".concat(h):""}\n FROM ${l}\n GROUP BY __interval`):[],U=new Map;if(M.forEach((t=>U.set(Z(t.__interval),t))),y)for(const e of M){const i=Z(e.__interval),n=b(Object.assign({},e));for(const e of t)for(const t of e)"SUM"===t.type&&w(t,n,i)}if(null!=this.config.thereOf&&this.config.thereOf.length>0){const e=[];this.config.thereOf.forEach((t=>{e.push(...g(`SELECT ${this.drillRowGroup} as ${v.ROWGROUP}, ${v.CATEGORY}, ${v.SUBCATEGORY}, __interval ${a.length>0?",".concat(a):""}\n FROM ${l}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${this.drillRowGroup}, ${v.CATEGORY}, ${v.SUBCATEGORY}, __interval`))}));for(const i of e){const e=Z(i.__interval);b(i);for(const n of t)for(const t of n)"DRILLELEMENT"===t.type&&t.category===i.category&&t.rowGroup===i.rowGroup&&(t.subCategory!==i.subCategory&&t.subCategory!==`${i.subCategory} (${i.rowGroup})`||w(t,i,e))}}if(m){let e="1 <> 1 ";null===(n=this.config.partOf)||void 0===n||n.forEach((t=>{e+=`OR (${v.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(e+=`and ${v.ROWGROUP} = ${this.bind(t.rowGroup)}`),e+=")"}));const i=g(`SELECT ${v.CATEGORY}, ${this.config.grouped?`${v.ROWGROUP}`:`'SUM_TOTAL' as ${v.ROWGROUP}`}, __interval ${a.length>0?",".concat(a):""}\n FROM ${l}\n WHERE ${e}\n GROUP BY ${v.ROWGROUP}, ${v.CATEGORY}, __interval`),h=new Map;for(const t of i){const e=`${t.rowGroup}${r}${t.category}${r}${Z(t.__interval)}`,i=h.get(e);if(i)for(const e of c)i[e]=(null!==(o=i[e])&&void 0!==o?o:0)+(null!==(s=t[e])&&void 0!==s?s:0);else h.set(e,t)}h.forEach((e=>{const i=Z(e.__interval),n=this.config.grouped?R.get(`${e.rowGroup}${r}${i}`):U.get(i);for(const t of c)e[t]=e[t]/(n?n[t]:Number.NaN);b(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,i)}))}}createThereOfWhereClause(t){let e=!0,i="1 <> 1 OR ( ";return null!=t.category&&0!==t.category.length&&t.category.trim()&&(i+=` ${v.CATEGORY} = ${this.bind(t.category)}`,e=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=` ${e?"":"AND"} ${v.ROWGROUP} = ${this.bind(t.rowGroup)}`,e=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(i+=` ${e?"":"AND"} ${v.SUBCATEGORY} = ${this.bind(t.subCategory)}`),i+")"}getRelativeScenarios(){const t=new Map;return this.config.scenarios.forEach((e=>{const i=this.createRelativeScenario(e);null!=i&&t.set(i.key,i.value)})),t}translateScenarioSQL(t,e,i){const n=new p(t);if(z.OPT===i||z.OPTNOTOTAL===i){if(n.isValid){const i=e?" * transformOperator(operation)":"",o=e?`SUM((${n.base} - ${n.delta})${i}) as ${t}`:`SUM(${n.base} - ${n.delta}) as ${t}`;return"dr"===n.type?`${o}, SUM(${n.delta}${i}) as dr_${n.delta}`:o}return e?`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:`SUM(${t}) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}return 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}]`,i=/^(ac|pp|fc|pl)[1-4]$/.test(t.arg)&&this.config.type!==z.OPT&&this.config.type!==z.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 i?`AVG(${e} * transformOperator(operation)) as ${t.alias}`:`AVG(${e}) as ${t.alias}`;case"sum":return i?`SUM(${e} * transformOperator(operation)) as ${t.alias}`:`SUM(${e}) as ${t.alias}`;case"lit":{const e=t.arg;return`${this.bind(""===e||Number.isNaN(Number(e))?e:Number(e))} as ${t.alias}`}}}get drillRowGroup(){return this.config.grouped?Ct:v.ROWGROUP}exec(t){const e=this.db.exec(t,this.params);return this.config.grouped&&e.forEach((t=>t.rowGroup=null==t.rowGroup?"":String(t.rowGroup))),e}bind(t){return`$${this.params.push(t)-1} `}createOrderString(t){const e=Q.ASC===t.direction?Q.DESC:Q.ASC,i=new Map;t.hierarchy.forEach(((t,e)=>{const n=x(t),o=null==n?void 0:n.bucket;("variance"===(null==n?void 0:n.kind)||"scenario"===(null==n?void 0:n.kind)&&void 0!==o)&&i.set(e,this.translateSortKeySQL(n,o,e))})),this.sortSelect=[...i.values()].map((t=>`, ${t}`)).join("");const n=(t,e,n)=>i.has(e)?`__sortnull${e} asc, __sort${e} ${n}`:`${t} ${n}`;return[t.hierarchy.map(((e,i)=>n(e,i,t.direction))).toString(),t.hierarchy.map(((t,i)=>n(t,i,e))).toString()]}translateSortKeySQL(t,e,i){const n=z.OPT===this.config.type||z.OPTNOTOTAL===this.config.type?"":" * transformOperator(operation)",o=void 0===e?"":`TRIM(CAST(${K(q)} AS STRING)) = ${this.bind(e)}`,s=t=>`SUM(${o?`(CASE WHEN ${o} THEN ${t} ELSE 0 END)`:t}${n})`,r=t=>`SUM(CASE WHEN ${o?`${o} AND `:""}${t} IS NOT NULL THEN 1 ELSE 0 END) = 0`;if("scenario"===t.kind)return`${s(t.column)} as __sort${i}, CASE WHEN ${r(t.column)} THEN 1 ELSE 0 END as __sortnull${i}`;const l=`(${s(t.base)} - ${s(t.delta)})`;let a=l,h=`${r(t.base)} OR ${r(t.delta)}`;if("dr"===t.type){const e=s(t.delta),i=`ABS(${e}) <= ABS(${l}) * 0.000000001`;a=`CASE WHEN ${i} THEN 0 ELSE ${l} / ABS(${e}) END`,h+=` OR ${i}`}return`${a} as __sort${i}, CASE WHEN ${h} THEN 1 ELSE 0 END as __sortnull${i}`}createRelativeScenario(t){const e=new p(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.category}##${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 i;const n=[];let o="1 <> 1 ",s=` ${this.drillRowGroup} as ${v.ROWGROUP}`,r="ROWNUM()";return null===(i=this.config.partOf)||void 0===i||i.forEach((t=>{o+=`OR (${v.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(o+=`and ${v.ROWGROUP} = ${this.bind(t.rowGroup)}`),!1===this.config.grouped&&(s=` 'SUM_TOTAL' as ${v.ROWGROUP} `,r="1"),o+=")"})),n.push(`SELECT ${r} AS ${v.ROWNR},\n 'PARTELEMENT' as ${v.TYPE},\n ${v.CATEGORY},\n ${s},\n ${t}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${o}\n GROUP BY ${this.drillRowGroup}, ${v.CATEGORY}, ${v.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 i=[],n=[],o=this.fromExpr;t.forEach(((t,e)=>{let n="1 <> 1 ";t.forEach((t=>{n+=` or columnGroup = ${this.bind(String(t.name))} `})),i.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 ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, columnGroup, scenario`),i.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 ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, columnGroup, columnSubGroup, scenario`),i.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 ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, scenario`),i.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 ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, columnSubGroup, scenario`),i.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 ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, columnGroup, scenario`),i.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 ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, columnGroup, columnSubGroup, scenario`),i.push(`SELECT 'SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, columnGroup, scenario`),i.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 ${o}\n WHERE ${n}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of i)n.push(...this.db.exec(t,this.params));this.injectDrillColumnsToResultRows(n,e)}injectDrillColumnsToResultRows(t,e){const i="##";for(const n of t)for(const t of e)for(const e of t)if(e.type===n.rowlevel)if("ENTRY"===n.rowlevel)"COLUMNGROUP"===n.columnlevel&&e.category===n.category?e[n.scenario+i+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&(e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val);else if("DRILLELEMENT"===n.rowlevel){if(!this.config.grouped&&e.rowGroup!==n.rowGroup)continue;"COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory?e[n.scenario+i+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory?e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val:"COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===`${n.subCategory} (${n.rowGroup})`?e[n.scenario+i+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===`${n.subCategory} (${n.rowGroup})`&&(e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val)}else("SUM"===n.rowlevel||"GROUP_SUM"===n.rowlevel)&&("COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory&&(e[n.scenario+i+n.columnGroup]=n.val),"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory&&(e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val))}}class Pt{constructor(){this.geometry=new Map}set(t,e,i){let n=this.geometry.get(t);n||(n=new Map,this.geometry.set(t,n)),n.set(e,i)}get(t,e){var i;return null===(i=this.geometry.get(t))||void 0===i?void 0:i.get(e)}}function Dt(t,e,i){const n=t[e];if(null==n)return null;const o=Number(n);return isNaN(o)?null:i!==z.OPT&&i!==z.OPTNOTOTAL||t[v.TYPE]!==V.ENTRY||"-"!==t[v.OPERATION]?o:-o}class Wt{constructor(t){this.ruleSet=t,this.normalizedHeader=[],this.attributesByAlias=new Map,this.hasBlankRowGroup=!1,this.dateBuckets=!1,this.unsignedEntries=!1}underlineClass(t){return this.ruleSet&&/^(ac|pp|fc|pl)[1-4]$/.test(t)?$(this.ruleSet.getScenarioColorIndex(t))+t.slice(2):null}getNormalizedHeader(){return this.normalizedHeader}createHeader(t,e,i,n,o,s,r=[]){const l=[];this.attributesByAlias=new Map(r.map((t=>[t.alias,t]))),this.normalizedHeader=this.normalizeHeader(t,e,r);const a=this.normalizedHeader.some((t=>void 0!==t.bucket));a&&l.push(this.createIntervalBandRow());const h=new it(a?1:0,0,V.HEADER),c=new it(a?2:1,0,V.SEPERATORLINE);for(const t of this.normalizedHeader){const e=this.attributesByAlias.get(t.name);h.createElement(e?i.get(e.label)||e.label:f.translateScenarioLabel(t.name,i),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,i,n,o,s),null,null,null,null),c.createElement(null,t.type,this.createColumnType(t),null,null,this.underlineClass(t.type),null,null,null)}return l.push(h),l.push(c),l}createIntervalBandRow(){const t=new it(0,0,V.HEADER);let e=0;for(;e<this.normalizedHeader.length;){const i=this.normalizedHeader[e];if(void 0===i.bucket){t.createElement(null,i.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===i.bucket;)n+=1;t.createElement(i.bucketLabel,i.type,"intervalGroup",null,null,null,null,null,null,!1,void 0,n),e+=n}return t}setHeaderPrefix(t,e,i,n,o){let s="";return"category"===t.name&&o&&(0===i.prefix.length&&0===n.length||(s=f.translateScenarioLabel("in",e)+" "+i.prefix+n)),t.order&&(s+=f.translateScenarioLabel("ORDER_"+t.order,e)),s}normalizeHeader(t,e,i){let n=[{name:v.CATEGORY,group:v.CATEGORY,type:v.CATEGORY,order:void 0}];z.OPT!==t&&z.OPTNOTOTAL!==t||(n=[{name:v.OPERATION,group:v.OPERATION,type:v.OPERATION,order:void 0},{name:v.CATEGORY,group:v.CATEGORY,type:v.CATEGORY,order:void 0}]);const o=i.map((t=>({name:t.alias,group:t.alias,type:t.alias,order:void 0})));return[...n,...o,...e]}createBodyRows(t,e,i,n){var o;const s=[];let r=-1;const l=new At(t,e);var a;this.dateBuckets=(a=t.interval)!==X&&a!==q,this.unsignedEntries=z.OPT===t.type||z.OPTNOTOTAL===t.type;const h=l.execute(i,n);this.hasBlankRowGroup=l.hasBlankRowGroup;const c=this.calculateColumnStatistics(h,t.barColumns,t.interval!==X),u=(null!==(o=t.barColumns)&&void 0!==o?o:[]).filter((t=>t.toUpperCase().trim()in w)),d=u.length>0&&t.interval===X&&0===t.categoryThereOf.size&&function(t){for(const e of t)for(const t of e){const e=t[v.TYPE];if(e===V.SUM||e===V.GROUPSUM||e===V.DRILLELEMENT||e===V.PARTELEMENT)return!0}return!1}(h)?function(t,e,i){const n=new Pt;for(const o of e){let e,s=0,r=0;const l=[],a=(t,e)=>{l.push(e),n.set(t,o,e)};for(const n of t)for(const t of n){const n=t[v.TYPE];if(n===V.GROUPHEAD){e=void 0;continue}const l=Dt(t,o,i);if(n===V.ENTRY){if(null===l){e=void 0;continue}a(t,{start:s,end:s+l,min:0,max:0,kind:"cascade"}),e={start:s,end:s+l},r=e.start,s+=l}else if(n===V.SUM||n===V.GROUPSUM){if(null===l){e=void 0;continue}a(t,{start:0,end:l,min:0,max:0,kind:"anchor"}),e={start:0,end:l},r=0,s=l}else if(n===V.DRILLELEMENT){if(null===l||void 0===e)continue;const i=r+(Math.sign(e.end-e.start)||1)*Math.abs(l);a(t,{start:r,end:i,min:0,max:0,kind:"thereof",parentStart:e.start,parentEnd:e.end}),r=i}else if(n===V.PARTELEMENT){if(null===l||void 0===e)continue;const i=r+l*(e.end-e.start);a(t,{start:r,end:i,min:0,max:0,kind:"partof",parentStart:e.start,parentEnd:e.end}),r=i}}let h=0,c=0;for(const t of l)h=Math.min(h,t.start,t.end),c=Math.max(c,t.start,t.end);for(const t of l)t.min=h,t.max=c}return n}(h,u,t.type):void 0;for(const i of h)r+=1,s.push(...this.createRow(t.i18n,e,t.scenariosUnitType,i,r,-1,t.categoryWidth,t.measureScale,t.barColumns,c,d));return s}calculateColumnStatistics(t,e,i=!1){const n=new Map;if(!e||0===e.length)return n;const o=new Map;for(const t of e)n.set(t,{min:1/0,max:-1/0,absMax:0,median:0}),o.set(t,[]);for(const s of t)for(const t of s){const s=t[v.TYPE];if(s!==V.SUM&&s!==V.GROUPSUM)for(const s of e){const e=i?this.extractIntervalColumnValues(t,s):[this.extractColumnValue(t,s)];for(const t of e)if(null!==t&&!isNaN(t)){const e=n.get(s);e.min=Math.min(e.min,t),e.max=Math.max(e.max,t),o.get(s).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 i=o.get(t);if(i.length>0){i.sort(((t,e)=>t-e));const t=Math.floor(i.length/2);e.median=i.length%2==0?(i[t-1]+i[t])/2:i[t]}n.set(t,e)}return n}extractIntervalColumnValues(t,e){const i=e+"##",n=[];for(const e of Object.keys(t))if(e.startsWith(i)){const i=Number(t[e]);n.push(isNaN(i)?null:i)}return n}extractColumnValue(t,e){if(void 0!==t[e]){const i=Number(t[e]);return isNaN(i)?null:i}for(const i of Object.keys(t))if(i===e||i.endsWith("##"+e)||i===e+"##"+e){const e=Number(t[i]);if(!isNaN(e))return e}return null}createRow(t,e,i,n,o,s,r,l,a,c,u){var d,f,$;const m=[];let g;for(const b of n){const w=b[v.ROWGROUP],E=""===w?"-":w,S=b[v.SUBCATEGORY],R=b[v.TYPE],y=b[v.ROWNR]>=2;g=null!==(f=null!==(d=b.operation)&&void 0!==d?d:b.restOperation)&&void 0!==f?f:g;const M=this.createDetailRow(R,s+=1,o,n.length);M.key=this.rowKey(b);for(const n of this.normalizedHeader){const o=this.getRawDataRowElement(b,n),s=null!==($=null==a?void 0:a.includes(n.type))&&void 0!==$&&$,d=s?null==c?void 0:c.get(n.type):void 0,f=s&&void 0===n.bucket&&n.name===n.group&&n.name===n.type?null==u?void 0:u.get(b,n.type):void 0;M.createElement(this.translateSumCellLabel(t,e,o,E,S,R,n.type),n.type,this.createColumnType(n),this.setCellType(n.type,i),this.translateCellPrefix(e,R,n.type),this.translateScenarioCSS(n.type,o,g),y,r,null==l?void 0:l.value,s,d,1,f);const v=M.elements[M.elements.length-1];this.dateBuckets&&void 0!==n.bucket&&(v.date=h(n.bucket));const m=new p(n.type);m.isValid&&(v.direction=this.resolveDirection(m,g))}m.push(M)}return m}rowKey(t){var e;const i=null!=t.restRowGroup?t.restRowGroup:"NO_GROUP"===t.rowGroup?void 0:t.rowGroup;switch(t.type){case V.ENTRY:return{rowGroup:i,category:t.category,subCategory:t.subCategory};case V.DRILLELEMENT:return{rowGroup:i,category:t.category,subCategory:null!==(e=t.rawSubCategory)&&void 0!==e?e:t.subCategory};case V.GROUPSUM:return{rowGroup:i,row:"subtotal"};case V.SUM:return{row:"total"};default:return}}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,i,n){switch(t){case V.GROUPHEAD:return new it(e,i,V.HEADER);case V.SUM:case V.GROUPSUM:return new it(n+2,i,V.SUM);case V.DRILLELEMENT:return new it(n+2,i,V.DRILLELEMENT);case V.PARTELEMENT:return new it(n+2,i,V.PARTELEMENT);default:return new it(e,i,V.STANDARD)}}translateSumCellLabel(t,e,i,n,o,s,r){return this.attributesByAlias.has(r)||!1===Number.isNaN(Number(i))||this.isOperationColumn(r)?i:this.isGroupHeadCategory(s,r)?t===E.ALL?`${e.get(i)||i}`:i:this.isEntryCategory(s,r)?t===E.ALL||"REST"===i?`${e.get(i)||i}`:i:this.isDrillElementCategory(s,r)?t===E.ALL?`${e.get(o)||o}`:`${o}`:this.isPartElementCategory(s,r)?t===E.ALL||"SUM_TOTAL"===n?`${e.get(n)||n}`:`${n}`:this.isSumElementCategory(s,r)?t===E.ALL||"SUM_TOTAL"===n?`${e.get(n)||n}`:n:"GROUPHEAD"===s&&null==i||i===O?i:Number.isNaN(Number(i))?"-":Number(i)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,e,i){if(this.attributesByAlias.has(t))return"attribute";const n=new p(t);let o="pos";return e<0&&(o="neg"),n.isValid?o+"_"+this.resolveDirection(n,i)+("dr"===n.type?" relative_variance":""):t}resolveDirection(t,e){return m(t.direction,e,!this.unsignedEntries)}setCellType(t,e){if("category"===t)return"";const i=this.attributesByAlias.get(t);if(i)return i.isNumeric?"decimal":"";let n;const o=new p(t);return e===S.PERCENT?(n="percent",o.isValid&&"d"===o.type&&(n="percentpoint")):(n="decimal",o.isValid&&"dr"===o.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,i){return this.isOperationColumn(i)||this.isGroupHeadCategory(e,i)||this.isEntryCategory(e,i)?null:this.isDrillElementCategory(e,i)?`${t.get("thereof")} `:this.isPartElementCategory(e,i)?`${t.get("part_of")} `:null}createColumnType(t){return t.name===t.group&&t.name===t.type?"base":t.name===t.group?"columnGroup":"columnSubGroup"}}class Bt{constructor(t,e,i,n){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new g,this.db=e,this.dataSetFactory=new Wt(this.ruleSet),this.config=this.initConfig(n),this.i18n=this.initI18n(new Map),this.setSource(i,n.filter)}setI18n(t){this.i18n=this.initI18n(t)}initI18n(t){const e=new Map([["",""],["SEPARATOR_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"," "],["thereof","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return this.state=I.DIRTY,new Map([...e,...t||new Map])}initConfig(t){this.state=I.DIRTY;const e=t,i=this;return t.scenarios.sort(((t,e)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(e))),e}setConfig(t){this.config=this.initConfig(t)}setSource(t,e){var i,n;if(this.state=I.DIRTY,this.fromExpr=k(this.db,t,e),!this.fromExpr)return void(this.rowCount=0);const o=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(n=null===(i=o[0])||void 0===i?void 0:i.cnt)&&void 0!==n?n:0}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=I.UP_TO_DATE}getHeader(){return this.state===I.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===I.DIRTY&&this.update(),this.bodyRows}getColumns(){return this.state===I.DIRTY&&this.update(),this.dataSetFactory.getNormalizedHeader()}prepareIntervalBuckets(){this.intervalBuckets=[],this.config.interval===X||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=X:(this.config.interval=function(t,e,i){var n;if(i!==_.AUTO)return i;const o=t.exec(`SELECT [date] as d FROM ${e}`);let s,r;for(const t of o){const e=null===(n=J(t.d))||void 0===n?void 0:n.toMillis();void 0!==e&&(s=void 0===s?e:Math.min(s,e),r=void 0===r?e:Math.max(r,e))}return void 0===s||void 0===r?_.DAY:(new T).calculateDistanceType(U.fromMillis(s),U.fromMillis(r))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,e,i,n){const o=t.exec(`SELECT ${K(i)} as __interval FROM ${e}`);if(i===q){const t=new Set,e=[];for(const i of o){const n=Z(i.__interval);t.has(n)||(t.add(n),e.push({key:n,label:0===n.length?"-":n}))}return e}const s=new Set,r=[];for(const t of o){const e=J(t.__interval);if(!e)continue;const i=e.toISO();s.has(i)||(s.add(i),r.push(e))}r.sort(((t,e)=>t.toMillis()-e.toMillis()));const l=new T;return l.setLocale(n),r.map((t=>({key:t.toISO(),label:l.getDateString(t,i)})))}(this.db,this.fromExpr,this.config.interval,this.config.locale),0===this.intervalBuckets.length&&(this.config.interval=X))}normalizeScenarios(t,e,i,n=[]){var o;const s=[],r=null===(o=null==i?void 0:i.hierarchy)||void 0===o?void 0:o.map((t=>x(t))).find((t=>"dim"!==(null==t?void 0:t.kind))),l=this.config.interval===q?null==r?void 0:r.bucket:void 0,a=(t,e)=>{var n;return null==r||(null===(n=x(t))||void 0===n?void 0:n.column)!==r.column||void 0!==l&&l!==e?void 0:i.direction};if(n.length>0){for(const e of n)for(const i of t)s.push({name:i,group:i,type:i,order:a(i,e.key),bucket:e.key,bucketLabel:e.label});return s}for(const i of t){if(null==e?void 0:e.has(i)){const t=e.get(i);for(const e of t){s.push({name:e.name,group:e.name,type:i,order:void 0});for(const t of e.subGroups)s.push({name:t,group:e.name,type:i,order:void 0})}s.push({name:"REST",group:"REST",type:i,order:void 0})}s.push({name:i,group:i,type:i,order:a(i)})}return s}hasNoData(){return 0===this.rowCount}orderBucketWarning(){var t,e;if(this.hasNoData()||this.state!==I.UP_TO_DATE)return;const i=(null!==(e=null===(t=this.config.sortOrder)||void 0===t?void 0:t.hierarchy)&&void 0!==e?e:[]).map((t=>{var e;return null===(e=x(t))||void 0===e?void 0:e.bucket})).filter((t=>void 0!==t));if(0===i.length)return;if(this.config.interval!==q)return`order: '@${i[0]}' needs interval setname, the bucket is ignored.`;const n=i.find((t=>!this.intervalBuckets.some((e=>e.key===t))));return void 0===n?void 0:`order: setname '${n}' not found, the rows are not sorted by it.`}hasBlankRowGroup(){return this.dataSetFactory.hasBlankRowGroup}}class Ft{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=S.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.thereOf=[],this.categoryThereOf=new Map,this.partOf=[],this.attributes=[],this.sortOrder=new C(new F).default(),this.type=z.LIST,this.limit=0,this.i18n=E.ALL,this.categoryWidth=y.W25,this.measureScale=new Y,this.measureUnit="",this.measureType=M.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.locale="de"}}class Yt{constructor(t,e,i,n,o,s){this.tableDrillGroupAdapter=t,this.stringAdapter=e,this.orderAdapter=i,this.db=n,this.fromExpr=o,this.onQueryError=s}adapt(t){const e=new Ft;return R.isString(t.title)&&(e.title=t.title),R.isArray(t.scenarios)&&(e.scenarios=B.adaptArray(t.scenarios,this.stringAdapter)),R.isExisting(t.scenariosUnitType)&&(e.scenariosUnitType=t.scenariosUnitType),R.isBoolean(t.grouped)&&(e.grouped=t.grouped),R.isBoolean(t.showGroupTitle)&&(e.showGroupTitle=t.showGroupTitle),R.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),R.isArray(t.thereOf)&&(e.thereOf=B.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),R.isExisting(t.categoryThereOf)&&(e.categoryThereOf=t.categoryThereOf),R.isArray(t.partOf)&&(e.partOf=B.adaptArray(t.partOf,this.tableDrillGroupAdapter)),R.isArray(t.attributes)&&(e.attributes=t.attributes),R.isExisting(t.order)&&(e.sortOrder=this.orderAdapter.adapt(t.order)),R.isExisting(t.type)&&(e.type=t.type),R.isNumber(t.limit)&&(e.limit=t.limit),R.isExisting(t.i18n)&&(e.i18n=t.i18n),R.isExisting(t.categoryWidth)&&(e.categoryWidth=t.categoryWidth),R.isExisting(t.measureScale)&&(e.measureScale=P.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale,this.onQueryError)),R.isExisting(t.measureType)&&(e.measureType=t.measureType),R.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),R.isString(t.filter)&&(e.filter=t.filter.trim()),R.isArray(t.barColumns)&&(e.barColumns=t.barColumns),R.isString(t.interval)&&(e.interval=t.interval),R.isString(t.locale)&&(e.locale=t.locale),e}default(){return new Ft}}class Ht{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class jt{constructor(){}adapt(t){const e=new Ht;return R.isString(t.rowGroup)&&(e.rowGroup=t.rowGroup),R.isString(t.category)&&(e.category=t.category),R.isString(t.subCategory)&&(e.subCategory=t.subCategory),R.isString(t.partOf)&&(e.partOf=t.partOf),e}default(){return new Ht}}const It=e(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.sumTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=S.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.thereof=[],this.partof=[],this.order={hierarchy:[],direction:Q.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=z.LIST,this.categoryWidth=y.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=E.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=M.VOLUME,this.filter="",this.barColumns=[],this.interval="none",this.barColumnMaxWidth=30,this.unitScaling=.01,this.percentageScaling=.5,this.scaleFactor=1,this.componentDataFormatDigits=new D,this.barColumnLayouts=new Map,this.relayout=()=>{this.barColumnLayouts.size>0&&n(this)},G(this),this.componentStyle=H(this)}connectedCallback(){var t;null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.relayout)}disconnectedCallback(){var t;null===(t=document.fonts)||void 0===t||t.removeEventListener("loadingdone",this.relayout)}async getLayoutDetail(t,e){var i,n,o;const s={regions:[],metadata:{},diagnostics:[]},h=null===(i=this.element.shadowRoot)||void 0===i?void 0:i.querySelector("table");if(s.metadata.hasNoData=null===(o=null===(n=this.table)||void 0===n?void 0:n.hasNoData())||void 0===o||o,!this.table||!h)return s;const c=h.querySelector("thead"),d=h.querySelector("tbody");c&&s.regions.push({id:"header",rect:r(c,t)}),d&&s.regions.push({id:"body",rect:r(d,t)});const f=this.table.getHeader(),p=this.table.getBody(),v=this.table.getColumns();if(s.metadata.headerRowCount=f.length,s.metadata.rowCount=p.length,s.metadata.columnCount=v.length,s.metadata.cellCount=p.reduce(((t,e)=>t+e.getCells().length),0),"full"!==e)return s;const $=[],m=[],g=(e,i,n)=>{const o=n?Array.from(n.children).filter((t=>"tr"===t.localName)):[];i.forEach(((i,n)=>{const h=o[n];if(!h)return;$.push({section:e,index:n,type:i.type,rect:r(h,t),point:u(h)});const c=i.getCells(),d=Array.from(h.children);c.length===d.length?c.forEach(((i,o)=>{var s,h;const c=d[o],f={kind:"header"===e?"headerCell":"cell",row:n,column:i.index,key:i.key||void 0,colSpan:i.colSpan,value:null!==(s=i.value)&&void 0!==s?s:void 0,text:(null===(h=c.textContent)||void 0===h?void 0:h.trim())||void 0,type:i.type||void 0,rect:r(c,t),point:u(c)};f.point&&(f.content=l(c,t),f.contentSign=a(c)||void 0);const p=c.querySelector("svg.cell-bar-chart");p&&(f.bar={variant:p.classList.contains("waterfall-bar")?"waterfall":p.classList.contains("relative-variance")?"relative":"absolute",rect:r(p,t)}),m.push(f)})):s.diagnostics.push({id:`WARN_layout_cell_pairing_${e}_${n}`,type:"warning",message:`layout-state: model/DOM cell count mismatch in ${e} row ${n} (${c.length} vs ${d.length}); cell details skipped for this row.`})}))};return g("header",f,c),g("body",p,d),s.elements=m,s.table={rows:$,columns:v.map(((t,e)=>({index:e,key:t.name,group:t.group,type:t.type,bucket:t.bucket})))},s}render(){var e;return t(o,{class:{"no-data":!0===(null===(e=this.table)||void 0===e?void 0:e.hasNoData())}},(()=>{var e,i,n,o;if(void 0===this.table)return;if(this.table.hasNoData()){const i=null!==(e=this.i18n.get("no-data"))&&void 0!==e?e:"No Data";return t("div",{class:"empty-state"},i)}const s=null===(o=null===(n=null===(i=this.stores)||void 0===i?void 0:i.context)||void 0===n?void 0:n.state)||void 0===o?void 0:o.locale;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(((i,n,o)=>t("span",null,n===o.length-1?t("span",{class:" "===i?"table-footer":""},i,e.drawPrefix()," "):t("span",null,i,e.drawPrefix(),t("br",null)))))))))))),t("tbody",null,this.table.getBody().map((e=>t("tr",Object.assign({class:e.cssStyle},d(e.key,"element")),null==e?void 0:e.getCells().map((i=>{var n,o,r,l,a;return t("td",Object.assign({colSpan:i.colSpan,class:i.type?`${i.cssStyle} ${i.type}`:i.cssStyle},e.key&&null!=i.value&&""!==i.value&&"-"!==i.value?d(Object.assign(Object.assign({},e.key),{date:i.date,scenario:i.key}),"element"):{}),null!=i.prefix?t("span",{class:i.cssStyle+" "+i.prefixStyle},i.drawPrefix()):"",i.isBarChart&&i.columnStats&&i.value!==O&&(void 0!==i.waterfall||e.type!==V.SUM)?void 0!==i.waterfall?t(xt,{value:i.value,scenario:i.key,columnStats:i.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:"pos"===i.direction,measureScale:i.measureScale,locale:s,columnWidthEm:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:i.waterfall}):t(Lt,{value:i.value,scenario:i.key,columnStats:i.columnStats,height:18*this.scaleFactor,isRelative:i.key.startsWith("dr"),isPositiveGood:"pos"===i.direction,measureScale:zt(i),locale:s,percentDigits:null!==(o=null===(n=this.barColumnLayouts.get(i.key))||void 0===n?void 0:n.percentDigits)&&void 0!==o?o:this.componentDataFormatDigits.percent,percentSign:null===(r=this.barColumnLayouts.get(i.key))||void 0===r?void 0:r.percentSign,columnWidthEm:this.barColumnMaxWidth,labelWidths:null===(l=this.barColumnLayouts.get(i.key))||void 0===l?void 0:l.labels,sideMax:null===(a=this.barColumnLayouts.get(i.key))||void 0===a?void 0:a.sideMax,styles:this.barChartStyles}):i.draw(this.componentDataFormatDigits,s))})))))))})())}componentWillRender(){var t,e,i,n,o,s,r,l;this.stores||(this.stores=A(this.element));const a=this.stores.db.db;this.componentDataFormatDigits=(new W).adapt(this.dataFormatDigits);try{const e=this.prepareConfig(a);this.table=new Bt(new g(this.ruleSetConfig),a,this.tableName,e),this.table.setI18n(this.i18n),this.table.hasNoData()||this.table.getBody(),null===(t=this.errors)||void 0===t||t.remove("ERR_sql")}catch(t){console.error("bn-table-renderer: query failed",t),this.table=void 0,null===(e=this.errors)||void 0===e||e.addOrReplace({id:"ERR_sql",type:"error",message:`Query failed: ${t instanceof Error?t.message:t}`})}(null===(i=this.table)||void 0===i?void 0:i.hasBlankRowGroup())?null===(n=this.errors)||void 0===n||n.addOrReplace({id:"WARN_blankRowGroup",type:"warning",message:"grouped: rows with blank rowGroup found, they are grouped under '-'."}):null===(o=this.errors)||void 0===o||o.remove("WARN_blankRowGroup");const h=null===(s=this.table)||void 0===s?void 0:s.orderBucketWarning();h?null===(r=this.errors)||void 0===r||r.addOrReplace({id:"WARN_orderBucket",type:"warning",message:h}):null===(l=this.errors)||void 0===l||l.remove("WARN_orderBucket"),this.barColumnLayouts=this.collectBarColumnLayouts(),this.barChartStyles=this.prepareBarChartStyles()}prepareConfig(t){var e,i,n;const o=k(t,this.tableName,this.filter);return new Yt(new jt,new F,new C(new F,!0),t,o,(t=>{throw t})).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===(i=null===(e=this.stores)||void 0===e?void 0:e.context)||void 0===i?void 0:i.state)||void 0===n?void 0:n.locale)||"de"})}prepareBarChartStyles(){var t;const e=!(this.unitScaling>0),i=!(this.percentageScaling>0),n=e?this.autoUnitScaling():this.unitScaling,o=i?this.autoPercentageScaling():this.percentageScaling;return(e||i)&&(null===(t=this.reportAutoScaling)||void 0===t||t.call(this,{unit:e?n:void 0,percentage:i?o:void 0})),this.componentStyle((t=>{var e,i,s,r,l,a,h,u,d,f,p,v,$,m,w,E,S,R,y,M,O,N,U,G,_,T;const L=null===(e=t["bn-chart-time"])||void 0===e?void 0:e.varianceStyles,x=null===(i=t["bn-chart-time"])||void 0===i?void 0:i.barStyles;return{positive:{stroke:(null===(s=null==L?void 0:L.pos)||void 0===s?void 0:s.stroke)||"#008f96",fill:(null===(r=null==L?void 0:L.pos)||void 0===r?void 0:r.fill)||"#008f96",fillpattern:c(null===(l=null==L?void 0:L.pos)||void 0===l?void 0:l.fillpattern)||"solid"},negative:{stroke:(null===(a=null==L?void 0:L.neg)||void 0===a?void 0:a.stroke)||"#ff0000",fill:(null===(h=null==L?void 0:L.neg)||void 0===h?void 0:h.fill)||"#ff0000",fillpattern:c(null===(u=null==L?void 0:L.neg)||void 0===u?void 0:u.fillpattern)||"solid"},neutral:{stroke:(null===(d=null==L?void 0:L.neu)||void 0===d?void 0:d.stroke)||"#808080",fill:(null===(f=null==L?void 0:L.neu)||void 0===f?void 0:f.fill)||"#808080",fillpattern:c(null===(p=null==L?void 0:L.neu)||void 0===p?void 0:p.fillpattern)||"outlined"},scenarios:b({ac:{stroke:(null===(v=null==x?void 0:x.ac)||void 0===v?void 0:v.stroke)||"#404040",fill:(null===($=null==x?void 0:x.ac)||void 0===$?void 0:$.fill)||"#404040",fillpattern:c(null===(m=null==x?void 0:x.ac)||void 0===m?void 0:m.fillpattern)||"solid"},pp:{stroke:(null===(w=null==x?void 0:x.pp)||void 0===w?void 0:w.stroke)||"#A6A6A6",fill:(null===(E=null==x?void 0:x.pp)||void 0===E?void 0:E.fill)||"#A6A6A6",fillpattern:c(null===(S=null==x?void 0:x.pp)||void 0===S?void 0:S.fillpattern)||"solid"},fc:{stroke:(null===(R=null==x?void 0:x.fc)||void 0===R?void 0:R.stroke)||"#404040",fill:(null===(y=null==x?void 0:x.fc)||void 0===y?void 0:y.fill)||"#ffffff",fillpattern:c(null===(M=null==x?void 0:x.fc)||void 0===M?void 0:M.fillpattern)||"hatched"},pl:{stroke:(null===(O=null==x?void 0:x.pl)||void 0===O?void 0:O.stroke)||"#404040",fill:(null===(N=null==x?void 0:x.pl)||void 0===N?void 0:N.fill)||"#ffffff",fillpattern:c(null===(U=null==x?void 0:x.pl)||void 0===U?void 0:U.fillpattern)||"outlined"}},new g(this.ruleSetConfig)),fontColor:(null===(G=t.global)||void 0===G?void 0:G.fontColor)||"#000000",fontSize:((null===(_=t.global)||void 0===_?void 0:_.fontSizePx)||13.3333)*nt*this.scaleFactor,emPx:((null===(T=t.global)||void 0===T?void 0:T.fontSizePx)||13.3333)*this.scaleFactor,fontFamily:this.labelFontFamily(),unitScaling:n,percentageScaling:o,scaleFactor:this.scaleFactor}}))}labelFontFamily(){return this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif"}))}emPx(){return this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*this.scaleFactor}autoUnitScaling(){const t=this.emPx(),e=t*nt;let i=1/0;for(const{isRelative:n,absMax:o,labels:s}of this.barColumnLayouts.values()){if(n||o<=0)continue;const{maxBarWidth:r,cutWidth:l}=pt(this.barColumnMaxWidth,t,s);i=Math.min(i,Math.min(.8*r,l)/(o*e))}return Number.isFinite(i)&&e>0?i:.01}autoPercentageScaling(){var t,e;const i=this.emPx(),n=i*nt;let o=1/0;for(const{isRelative:s,absMax:r,labels:l,sideMax:a}of this.barColumnLayouts.values()){if(!s||r<=0)continue;const h=10*this.scaleFactor,{negPinLength:c,posPinLength:u}=vt(this.barColumnMaxWidth,i,l,h),d=100*((null!==(t=a.neg)&&void 0!==t?t:0)+(null!==(e=a.pos)&&void 0!==e?e:0));o=Math.min(o,(c+u)/(d*n))}return Number.isFinite(o)&&n>0?o:.5}collectBarColumnLayouts(){var t,e,i,n;const o=new Map;if(!this.table||this.table.hasNoData())return o;const s=new Map;for(const e of this.table.getBody())if(e.type!==V.SUM)for(const i of e.getCells())i.isBarChart&&i.columnStats&&void 0===i.waterfall&&("number"!=typeof i.value||isNaN(i.value)||s.set(i.key,[...null!==(t=s.get(i.key))&&void 0!==t?t:[],i]));const r=this.emPx(),l=r*nt,a=10*this.scaleFactor,h=null===(n=null===(i=null===(e=this.stores)||void 0===e?void 0:e.context)||void 0===i?void 0:i.state)||void 0===n?void 0:n.locale,c=this.labelFontFamily();for(const[t,e]of s){const i=t.startsWith("dr"),n=e.map((t=>t.value)),s=(t,o)=>{var s;const r={neg:n.some((t=>t<0))?0:void 0,pos:n.some((t=>t>0))?0:void 0},a=Mt(r);for(const n of e){const e=n.value,u=e>0||0===e&&a?"pos":"neg",d=wt(e,i,zt(n),h,t,o);r[u]=Math.max(null!==(s=r[u])&&void 0!==s?s:0,ht(d,l,c,i))}return r};let u=Math.min(20,Math.max(0,Math.trunc(this.componentDataFormatDigits.percent)||0)),d=!0,f=s(u,d);for(;i&&(u>0||d)&&!ft(this.barColumnMaxWidth,r,f,a);)u>0?u--:d=!1,f=s(u,d);const p=Math.max(...n.map(Math.abs))*(i?100:1),v={neg:void 0===f.neg?void 0:Math.max(0,...n.map((t=>-t))),pos:void 0===f.pos?void 0:Math.max(0,...n)};o.set(t,{isRelative:i,absMax:p,labels:f,sideMax:v,percentDigits:u,percentSign:d})}return o}get element(){return this}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}: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,td.percentpoint{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,"bn-table-renderer",{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"],reportAutoScaling:[16],errors:[16],scaleFactor:[2,"scale-factor"],getLayoutDetail:[64]}]);function zt(t){return"percentpoint"===t.type?.01:t.measureScale}function Qt(){"undefined"!=typeof customElements&&["bn-table-renderer"].forEach((t=>{"bn-table-renderer"===t&&(customElements.get(s(t))||customElements.define(s(t),It))}))}export{It as B,X as I,z as T,q as a,Qt as d}
@@ -1 +0,0 @@
1
- import{r as n}from"./p-t4xPltK2.js";import{r as t}from"./p-BzjGUtYh.js";import{r as i,a as e}from"./p-CckAR27O.js";import{m as o}from"./p-DaOm9YwQ.js";import{LAYOUT_STATE_VERSION as r}from"./index.js";const l=/^Scenario([1-4])$/,d=/^stacked_(?:col|bar)_(\d+)_seg_\d+$/,a='g[id^="stacked_col_"], g[id^="stacked_bar_"]';function s(n,t){var i;let e=n.parentElement;for(;e&&e!==t;){const n=l.exec(null!==(i=e.id)&&void 0!==i?i:"");if(n)return`scenario${n[1]}`;e=e.parentElement}}function c(n){if(""===n)return;const t=Number(n.split("_")[0]);return Number.isFinite(t)?t:void 0}function u(n){const t=n.getAttribute("data-bn-index");return null===t?void 0:Number(t)}function v(n,t){var i;return(null!==(i=n.getAttribute("class"))&&void 0!==i?i:"").split(/\s+/).includes(t)}function f(i,e,r,l,f){var m,g;const b={regions:[],barCount:0,baseline:{}},p=[];return Array.from(null!==(g=null===(m=i.shadowRoot)||void 0===m?void 0:m.querySelectorAll(e))&&void 0!==g?g:[]).forEach(((e,m)=>{var g,x,k,_;const A=null!==(g=r[m])&&void 0!==g?g:`segment${m}`,$=null===(x=e.shadowRoot)||void 0===x?void 0:x.querySelector("svg#drawCanvas");if($&&(b.regions.push({id:`canvas:${A}`,rect:o($,l)}),0===m&&(b.barCount=function(n){const t=n.querySelector('g[id="Scenario1"]');if(t)return Array.from(t.children).filter((n=>{var t;return/^\d+$/.test(null!==(t=n.id)&&void 0!==t?t:"")})).length;const i=new Set;return n.querySelectorAll(a).forEach((n=>{const t=d.exec(n.id);t&&n.querySelector("rect")&&i.add(t[1])})),i.size}($),b.baseline=n($,i)),"full"===f&&p.push(...function(n,i,e){const r=[],l=new Set;return n.querySelectorAll('g[id$="_RECT"]').forEach(((d,a)=>{var u;l.add(d);const v={kind:"bar",id:d.id,segment:i,scenario:s(d,n),index:null!==(u=c(d.id))&&void 0!==u?u:a,rect:o(d,e),point:t(d)};r.push(v)})),n.querySelectorAll(a).forEach((n=>{var a,s,c;const u=d.exec(n.id);if(!u||!n.querySelector("rect"))return;l.add(n);const v=t(n),f={kind:"bar",id:n.id,segment:i,scenario:`stack:${null!==(c=null!==(s=null!==(a=null==v?void 0:v.scenario)&&void 0!==a?a:null==v?void 0:v.subCategory)&&void 0!==s?s:null==v?void 0:v.category)&&void 0!==c?c:""}`,index:Number(u[1]),rect:o(n,e),point:v};r.push(f)})),["DATA","SCENARIO"].forEach((d=>{n.querySelectorAll(`g[id$="_${d}_Label"]`).forEach(((n,a)=>{var s,u,f;if(v(n,"hide"))return;const m=null!==(u=null===(s=n.textContent)||void 0===s?void 0:s.trim())&&void 0!==u?u:"";if(!m)return;l.add(n);const g={kind:"label",id:n.id,role:"DATA"===d?"data":"scenario",text:m,segment:i,index:null!==(f=c(n.id))&&void 0!==f?f:a,rect:o(n,e),point:t(n)};r.push(g)}))})),n.querySelectorAll("[data-bn-part]").forEach(((d,a)=>{var s,v,f;if(l.has(d))return;const m=t(d),g=null!==(s=u(d))&&void 0!==s?s:function(n,t){var i;for(let e=n;e&&e!==t;e=e.parentElement){const n=c(null!==(i=e.id)&&void 0!==i?i:"");if(void 0!==n)return n}}(d,n);if("element"===m.part){const n={kind:"point",series:m.scenario,index:null!=g?g:a,rect:o(d,e),point:m};return void r.push(n)}const b={kind:"label",id:d.id||void 0,role:"data",text:null!==(f=null===(v=d.textContent)||void 0===v?void 0:v.trim())&&void 0!==f?f:"",segment:i,index:g,rect:o(d,e),point:m};r.push(b)})),n.querySelectorAll('g[id="axis"] line').forEach((n=>{var t;const l=(null!==(t=n.getAttribute("class"))&&void 0!==t?t:"").split(/\s+/).find((n=>n.startsWith("axis-"))),d=o(n,e),a={kind:"axis",style:null==l?void 0:l.slice(5),orientation:d.context.width>=d.context.height?"horizontal":"vertical",segment:i,rect:d};r.push(a)})),n.querySelectorAll('g[id="AxisAndDateLables"] text, g[id="AxisAndDateLabelsLine"] text').forEach((t=>{var l,d;if(v(t,"hide")||function(n,t){var i;let e=n.parentElement;for(;e&&e!==t;){if((null!==(i=e.id)&&void 0!==i?i:"").endsWith("_Label"))return!0;e=e.parentElement}return!1}(t,n))return;const a=null!==(d=null===(l=t.textContent)||void 0===l?void 0:l.trim())&&void 0!==d?d:"";if(!a)return;const s={kind:"label",role:v(t,"categories")?"title":"category",text:a,segment:i,rect:o(t,e)};r.push(s)})),r}($,A,l))),"full"===f){const n=null===(k=e.shadowRoot)||void 0===k?void 0:k.querySelector(".footer"),t=null===(_=null==n?void 0:n.textContent)||void 0===_?void 0:_.trim();t&&p.push({kind:"label",role:"footer",text:t,segment:A,rect:o(n,l)})}})),"full"===f&&(b.elements=p),b}function m(l,d,a,s,c,v){var f,m,g,b;const p={version:r,tag:l.localName,id:e(l),slot:null!==(f=l.getAttribute("slot"))&&void 0!==f?f:void 0,rect:o(l,c),em:s,regions:[],metadata:{title:a},diagnostics:i(l)},x=null===(b=null===(g=null===(m=l.shadowRoot)||void 0===m?void 0:m.querySelector(d))||void 0===g?void 0:g.shadowRoot)||void 0===b?void 0:b.querySelector("svg#drawCanvas");return x&&(p.regions.push({id:"canvas",rect:o(x,c)}),p.metadata.pointCount=x.querySelectorAll("circle, ellipse").length,p.baseline=n(x,l),"full"===v&&(p.elements=function(n,i){const e=[];return n.querySelectorAll("circle, ellipse").forEach(((n,r)=>{const l={kind:"point",index:r,rect:o(n,i),point:t(n)};e.push(l)})),n.querySelectorAll('rect[data-bn-part="element"]').forEach(((n,r)=>{var l;const d=t(n),a={kind:"bar",segment:"base",scenario:null==d?void 0:d.scenario,index:null!==(l=u(n))&&void 0!==l?l:r,rect:o(n,i),point:d};e.push(a)})),n.querySelectorAll("text").forEach((n=>{var r,l;const d=null!==(l=null===(r=n.textContent)||void 0===r?void 0:r.trim())&&void 0!==l?l:"";if(!d)return;const a={kind:"label",role:"data",text:d,rect:o(n,i),point:t(n)};e.push(a)})),e}(x,c))),p}export{f as a,m as c}