@bino-bi/bn-template-engine 1.0.0-alpha.17 → 1.0.0-alpha.18

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 (186) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/p-0107f0cc.entry.js +1 -0
  3. package/dist/bn-template-engine/p-209351c9.entry.js +1 -0
  4. package/dist/bn-template-engine/p-22d0fb7a.entry.js +1 -0
  5. package/dist/bn-template-engine/p-2e6dc267.entry.js +1 -0
  6. package/dist/bn-template-engine/p-485d23d7.entry.js +1 -0
  7. package/dist/bn-template-engine/p-5651417d.entry.js +1 -0
  8. package/dist/bn-template-engine/p-5bfdc1e5.entry.js +1 -0
  9. package/dist/bn-template-engine/p-6b75762d.entry.js +1 -0
  10. package/dist/bn-template-engine/{p-1a1fd8eb.entry.js → p-7bdc0e28.entry.js} +1 -1
  11. package/dist/bn-template-engine/p-9879c9b2.entry.js +1 -0
  12. package/dist/bn-template-engine/p-BWKdb9ym.js +1 -0
  13. package/dist/bn-template-engine/{p-CIXlJoMr.js → p-BZV1b5VH.js} +1 -1
  14. package/dist/bn-template-engine/p-Bdfxd_Ke.js +1 -0
  15. package/dist/bn-template-engine/p-BqhIhYr1.js +1 -0
  16. package/dist/bn-template-engine/p-C0Pwqx-O.js +1 -0
  17. package/dist/bn-template-engine/{p-44L8rZSd.js → p-CBqUr7I8.js} +1 -1
  18. package/dist/bn-template-engine/{p-COXiPUfj.js → p-CPzF3Q2m.js} +1 -1
  19. package/dist/bn-template-engine/{p-DHibUOw5.js → p-CiudZRQr.js} +1 -1
  20. package/dist/bn-template-engine/{p-B2KOyHRY.js → p-Dg9OcXAO.js} +1 -1
  21. package/dist/bn-template-engine/p-DsTzlzxQ.js +1 -0
  22. package/dist/bn-template-engine/p-X6CxL6W-.js +1 -0
  23. package/dist/bn-template-engine/p-a130cb43.entry.js +1 -0
  24. package/dist/bn-template-engine/p-aakBGfzL.js +1 -0
  25. package/dist/bn-template-engine/p-dc745c32.entry.js +1 -0
  26. package/dist/bn-template-engine/p-e96da91f.entry.js +1 -0
  27. package/dist/bn-template-engine/{p-d3fc17ee.entry.js → p-f3d1fa06.entry.js} +1 -1
  28. package/dist/bn-template-engine/p-fcb43f2c.entry.js +1 -0
  29. package/dist/bn-template-engine/p-rdqTC0_5.js +1 -0
  30. package/dist/cjs/{AxisConfig-B_GMRfX_.js → AxisConfig-VnVelfSV.js} +1 -1
  31. package/dist/cjs/LabelCollisionManager-nfD5P__k.js +412 -0
  32. package/dist/cjs/NumericScale-BAyYXpKL.js +107 -0
  33. package/dist/cjs/Order-DobBozQC.js +87 -0
  34. package/dist/cjs/{LabelCollisionManager-8HGn9W0V.js → SVGStyle-BQOmGWLX.js} +2 -409
  35. package/dist/cjs/SVGVariancesStyleGroup-DCGfHrqh.js +50 -0
  36. package/dist/cjs/{VarianceMeasure-DEOzP-XZ.js → VarianceMeasure-NY9yhiNV.js} +1 -1
  37. package/dist/cjs/{XYChartDataRow-CDl1Ofnv.js → XYChartDataRow-B7OKrAcC.js} +7 -111
  38. package/dist/cjs/bn-asset_21.cjs.entry.js +221 -263
  39. package/dist/cjs/bn-chart-bubble.cjs.entry.js +8 -7
  40. package/dist/cjs/bn-chart-bullet.cjs.entry.js +785 -0
  41. package/dist/cjs/bn-chart-scatter.cjs.entry.js +8 -7
  42. package/dist/cjs/bn-grid.cjs.entry.js +5 -4
  43. package/dist/cjs/bn-image.cjs.entry.js +5 -4
  44. package/dist/cjs/bn-internationalization.cjs.entry.js +2 -2
  45. package/dist/cjs/bn-ruleset.cjs.entry.js +2 -2
  46. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  47. package/dist/cjs/bn-template.cjs.entry.js +1 -1
  48. package/dist/cjs/bn-text.cjs.entry.js +6 -5
  49. package/dist/cjs/bn-tree.cjs.entry.js +4 -3
  50. package/dist/cjs/{context-protocol-CIuyJKkK.js → context-protocol-BDrMkhc4.js} +66 -0
  51. package/dist/cjs/editor-companion.cjs.entry.js +2 -2
  52. package/dist/cjs/ibcs-chart-bubble.cjs.entry.js +20 -18
  53. package/dist/cjs/ibcs-chart-bullet.cjs.entry.js +673 -0
  54. package/dist/cjs/ibcs-chart-scatter.cjs.entry.js +19 -17
  55. package/dist/cjs/{layoutObserver-CJWRV_y6.js → layoutObserver-p0wXIWFg.js} +2 -2
  56. package/dist/cjs/loader.cjs.js +1 -1
  57. package/dist/cjs/{scaling-B4UPXivZ.js → scaling-BmqxcNOf.js} +1 -1
  58. package/dist/cjs/{withScalingGroup-D832DQKp.js → withScalingGroup-BmcRlWBs.js} +1 -1
  59. package/dist/cjs/{withStyled-COxuhL-N.js → withStyled-CRiC9fzc.js} +5 -86
  60. package/dist/collection/collection-manifest.json +2 -0
  61. package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.css +10 -0
  62. package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.js +1014 -0
  63. package/dist/collection/components/bn-chart-bullet/ibcs-chart-bullet.css +9 -0
  64. package/dist/collection/components/bn-chart-bullet/ibcs-chart-bullet.js +538 -0
  65. package/dist/collection/components/bn-chart-bullet/utils/BulletChart.js +440 -0
  66. package/dist/collection/components/bn-chart-bullet/utils/model/BulletChartStyle.js +132 -0
  67. package/dist/collection/components/bn-chart-bullet/utils/model/BulletConfig.js +89 -0
  68. package/dist/collection/components/bn-chart-bullet/utils/model/index.js +2 -0
  69. package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.js +1 -1
  70. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +1 -1
  71. package/dist/collection/components/bn-chart-time/bn-chart-time.js +1 -1
  72. package/dist/collection/components/bn-component-style/bn-component-style.js +1 -1
  73. package/dist/collection/components/bn-context/bn-context.js +1 -1
  74. package/dist/collection/components/bn-dataset/bn-dataset.js +1 -1
  75. package/dist/collection/components/bn-datasource/bn-datasource.js +1 -1
  76. package/dist/collection/components/bn-footer/bn-footer.js +1 -1
  77. package/dist/collection/components/bn-grid/bn-grid.js +1 -1
  78. package/dist/collection/components/bn-image/bn-image.js +1 -1
  79. package/dist/collection/components/bn-internationalization/bn-internationalization.js +1 -1
  80. package/dist/collection/components/bn-layout-card/bn-layout-card.js +1 -1
  81. package/dist/collection/components/bn-layout-page/bn-layout-page.js +1 -1
  82. package/dist/collection/components/bn-message/bn-message.js +1 -1
  83. package/dist/collection/components/bn-page/bn-page.js +1 -1
  84. package/dist/collection/components/bn-ruleset/bn-ruleset.js +1 -1
  85. package/dist/collection/components/bn-scaling-group/bn-scaling-group.js +1 -1
  86. package/dist/collection/components/bn-table/bn-table.js +1 -1
  87. package/dist/collection/components/bn-template/bn-template.js +1 -1
  88. package/dist/collection/components/bn-text/bn-text.js +1 -1
  89. package/dist/collection/components/bn-title/bn-title.js +1 -1
  90. package/dist/collection/components/bn-title/ibcs-title/ibcs-title.js +1 -1
  91. package/dist/collection/components/editor-companion/editor-companion.js +1 -1
  92. package/dist/collection/stores/componentStyles.js +38 -0
  93. package/dist/collection/stores/internationalization.js +28 -0
  94. package/dist/components/NumericScale.js +1 -0
  95. package/dist/components/Order.js +1 -1
  96. package/dist/components/XYChartDataRow.js +1 -1
  97. package/dist/components/bn-chart-bullet.d.ts +11 -0
  98. package/dist/components/bn-chart-bullet.js +1 -0
  99. package/dist/components/bn-chart-scatter.js +1 -1
  100. package/dist/components/bn-chart-structure.js +1 -1
  101. package/dist/components/bn-chart-time.js +1 -1
  102. package/dist/components/bn-component-style.js +1 -1
  103. package/dist/components/bn-context.js +1 -1
  104. package/dist/components/bn-dataset.js +1 -1
  105. package/dist/components/bn-datasource.js +1 -1
  106. package/dist/components/bn-footer2.js +1 -1
  107. package/dist/components/bn-grid.js +1 -1
  108. package/dist/components/bn-image.js +1 -1
  109. package/dist/components/bn-internationalization.js +1 -1
  110. package/dist/components/bn-layout-card.js +1 -1
  111. package/dist/components/bn-layout-page.js +1 -1
  112. package/dist/components/bn-message2.js +1 -1
  113. package/dist/components/bn-page2.js +1 -1
  114. package/dist/components/bn-ruleset.js +1 -1
  115. package/dist/components/bn-scaling-group.js +1 -1
  116. package/dist/components/bn-table.js +1 -1
  117. package/dist/components/bn-template.js +1 -1
  118. package/dist/components/bn-text.js +1 -1
  119. package/dist/components/bn-title2.js +1 -1
  120. package/dist/components/context-protocol.js +1 -1
  121. package/dist/components/editor-companion.js +1 -1
  122. package/dist/components/ibcs-chart-bubble2.js +1 -1
  123. package/dist/components/ibcs-chart-bullet.d.ts +11 -0
  124. package/dist/components/ibcs-chart-bullet.js +1 -0
  125. package/dist/components/ibcs-chart-bullet2.js +1 -0
  126. package/dist/components/ibcs-chart-scatter2.js +1 -1
  127. package/dist/components/ibcs-chart-structure2.js +1 -1
  128. package/dist/components/ibcs-chart-time2.js +1 -1
  129. package/dist/components/ibcs-table2.js +1 -1
  130. package/dist/components/ibcs-title2.js +1 -1
  131. package/dist/components/main.js +1 -0
  132. package/dist/components/stackColors.js +1 -1
  133. package/dist/esm/{AxisConfig-BwUQrme0.js → AxisConfig-C_zWCKlL.js} +1 -1
  134. package/dist/esm/LabelCollisionManager-8swVQHKA.js +404 -0
  135. package/dist/esm/NumericScale-DsTzlzxQ.js +105 -0
  136. package/dist/esm/Order-BPeWfygb.js +83 -0
  137. package/dist/esm/{LabelCollisionManager-DZP5Vl8T.js → SVGStyle-BxEDw9zh.js} +3 -403
  138. package/dist/esm/SVGVariancesStyleGroup-DRQYvSDD.js +48 -0
  139. package/dist/esm/{VarianceMeasure-Cxshx01h.js → VarianceMeasure-DnwNKspZ.js} +1 -1
  140. package/dist/esm/{XYChartDataRow-FF_VxRnF.js → XYChartDataRow-DeV4r-Wm.js} +5 -108
  141. package/dist/esm/bn-asset_21.entry.js +25 -67
  142. package/dist/esm/bn-chart-bubble.entry.js +8 -7
  143. package/dist/esm/bn-chart-bullet.entry.js +783 -0
  144. package/dist/esm/bn-chart-scatter.entry.js +8 -7
  145. package/dist/esm/bn-grid.entry.js +5 -4
  146. package/dist/esm/bn-image.entry.js +5 -4
  147. package/dist/esm/bn-internationalization.entry.js +2 -2
  148. package/dist/esm/bn-ruleset.entry.js +2 -2
  149. package/dist/esm/bn-template-engine.js +1 -1
  150. package/dist/esm/bn-template.entry.js +1 -1
  151. package/dist/esm/bn-text.entry.js +6 -5
  152. package/dist/esm/bn-tree.entry.js +4 -3
  153. package/dist/esm/{context-protocol-BNHTlllP.js → context-protocol-1Yj1uKvh.js} +66 -0
  154. package/dist/esm/editor-companion.entry.js +2 -2
  155. package/dist/esm/ibcs-chart-bubble.entry.js +6 -4
  156. package/dist/esm/ibcs-chart-bullet.entry.js +671 -0
  157. package/dist/esm/ibcs-chart-scatter.entry.js +6 -4
  158. package/dist/esm/{layoutObserver-D5FY_lQa.js → layoutObserver-DCbmpGrz.js} +2 -2
  159. package/dist/esm/loader.js +1 -1
  160. package/dist/esm/{scaling-B7Pa0d_s.js → scaling-B_k50v9z.js} +1 -1
  161. package/dist/esm/{withScalingGroup-DBheBsP4.js → withScalingGroup-Br70pAv9.js} +1 -1
  162. package/dist/esm/{withStyled-DTvj2nar.js → withStyled-Br2DGTPs.js} +4 -83
  163. package/dist/types/components/bn-chart-bullet/bn-chart-bullet.d.ts +172 -0
  164. package/dist/types/components/bn-chart-bullet/ibcs-chart-bullet.d.ts +52 -0
  165. package/dist/types/components/bn-chart-bullet/utils/BulletChart.d.ts +91 -0
  166. package/dist/types/components/bn-chart-bullet/utils/model/BulletChartStyle.d.ts +70 -0
  167. package/dist/types/components/bn-chart-bullet/utils/model/BulletConfig.d.ts +43 -0
  168. package/dist/types/components/bn-chart-bullet/utils/model/index.d.ts +2 -0
  169. package/dist/types/components.d.ts +399 -4
  170. package/dist/types/stores/componentStyles.d.ts +20 -0
  171. package/package.json +1 -1
  172. package/dist/bn-template-engine/p-172499ac.entry.js +0 -1
  173. package/dist/bn-template-engine/p-19e65c04.entry.js +0 -1
  174. package/dist/bn-template-engine/p-2849c367.entry.js +0 -1
  175. package/dist/bn-template-engine/p-5dd11fcc.entry.js +0 -1
  176. package/dist/bn-template-engine/p-63f891d9.entry.js +0 -1
  177. package/dist/bn-template-engine/p-72f63181.entry.js +0 -1
  178. package/dist/bn-template-engine/p-836ad6f3.entry.js +0 -1
  179. package/dist/bn-template-engine/p-BnOTt2YD.js +0 -1
  180. package/dist/bn-template-engine/p-CDPTCKVx.js +0 -1
  181. package/dist/bn-template-engine/p-CPZIJpxn.js +0 -1
  182. package/dist/bn-template-engine/p-a50da0f0.entry.js +0 -1
  183. package/dist/bn-template-engine/p-a9a34fb2.entry.js +0 -1
  184. package/dist/bn-template-engine/p-b0369558.entry.js +0 -1
  185. package/dist/bn-template-engine/p-f8c46905.entry.js +0 -1
  186. package/dist/bn-template-engine/p-lIy3SJs2.js +0 -1
@@ -1 +0,0 @@
1
- import{r as t,h as i,H as s,g as e,d as n,f as r,e as a,F as h}from"./p-B_d-jp99.js";import{w as o,a as l,r as c}from"./p-B4JfKvVT.js";import{g as d,a as u,e as p,c as f,D as v,b as g}from"./p-BnOTt2YD.js";import{w as m}from"./p-BjBz5cSL.js";import{b,v as w,f as y,e as S,g as O,h as $,j as R,a as M,d as x,k as _,l as k,w as E,i as L,O as T,m as P,n as A,o as C,D as N,p as U,q as D,r as G,s as W,t as F,u as Y,x as I,y as B,z,A as H,B as V,C as j,E as X,F as J,G as q,H as K,I as Z,J as Q,K as tt}from"./p-lIy3SJs2.js";import{w as it,a as st,g as et,p as nt}from"./p-COXiPUfj.js";import{w as rt}from"./p-DHibUOw5.js";import{i as at,w as ht,a as ot,o as lt}from"./p-44L8rZSd.js";import{A as ct,f as dt,g as ut,h as pt,c as ft,i as vt,D as gt,I as mt,e as bt,M as wt,B as yt,T as St,C as Ot,R as $t,S as Rt}from"./p-CIXlJoMr.js";import{F as Mt,S as xt,d as _t,g as kt,I as Et,C as Lt,V as Tt,e as Pt,f as At,a as Ct,b as Nt,c as Ut,P as Dt,h as Gt,H as Wt,i as Ft,L as Yt,j as It,Q as Bt}from"./p-CDPTCKVx.js";import{s as zt}from"./p-BA48JiHe.js";const Ht=class{constructor(i){t(this,i),o(this),this.errors=l(this),m(this,(t=>{this.stores||(this.stores=d(this.element));try{const i=t.replace(/\s/g,"");this.stores.assets.set(this.name,i)}catch(i){console.error("Error parsing asset",i,t),this.stores.assets.set(this.name,void 0)}}))}render(){return i(s,{key:"dfec9f90136278bddab194479301aa3fa5bc1e72"})}get element(){return e(this)}};Ht.style=":host{display:none}";const Vt=class{constructor(i){t(this,i),o(this),this.errors=l(this),this.componentStyle=b(this)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){return i(s,{key:"f43978af1c6658c6fa165093c3ada6b5f3b5986d",style:this.getFontStyles()},i("slot",{key:"b9c97432089676fc373b1d5ee59573ef5681a5c5"}))}get element(){return e(this)}};Vt.style=':host{flex:1;min-height:0;position:relative;overflow:hidden;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}';const jt=class{constructor(i){t(this,i),o(this),this.errors=l(this),this.componentStyle=b(this)}render(){return i(s,{key:"92bcbc010336d3a542c86e182831bbfddda2aa9b",style:this.prepareStyle()},i("slot",{key:"d836aa5443283df158dcb50345aee0df97f74a6e"}))}prepareStyle(){return{"font-family":this.componentStyle((t=>t.global.fontFamily)),"font-size":`${this.componentStyle((t=>t.global.fontSizePx))}px`,"--bn-font-family":this.componentStyle((t=>t.global.fontFamily))||"'Noto Sans', sans-serif","--bn-font-size":`${this.componentStyle((t=>t.global.fontSizePx))||13.3333}px`,"--bn-font-color":this.componentStyle((t=>t.global.fontColor))||"#000000","--bn-font-background":this.componentStyle((t=>t.global.fontBackgroundColor))||"#ffffff"}}get element(){return e(this)}};jt.style=':host{display:flex;flex-direction:column;justify-content:space-between;flex:1;min-height:0;padding:0.25em;margin:0.5em;background-origin:content-box;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(.border){box-sizing:border-box;-webkit-box-sizing:border-box;border:0.1em solid #ddd}div{color:var(--bn-font-color, black)}';const Xt=class{validateScenario(t){const i="ERR_scenarios";if(at(t))return void this.errors.remove(i);const s=w(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(at(t))return void this.errors.remove(i);const s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateUnitScaling(t){const i="ERR_unitScaling";"auto"===(null==t?void 0:t.toString().trim().toLowerCase())||S(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."})}validatePercentageScaling(t){const i="ERR_percentageScaling";"auto"===(null==t?void 0:t.toString().trim().toLowerCase())||S(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."})}validateLevel(t){const i="ERR_level";O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="ERR_order";if(at(t))return void this.errors.remove(i);const s=$(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";at(t)||R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateLimit(t){const i="ERR_limit";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateShowCategories(t){const i="ERR_showCategories";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showCategories: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateMeasureScale(t){const i="ERR_measureScale";_(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateStack(t){const i="ERR_stack",s=k(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:s.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this._lastScaledParentHeight=0,this.chartTitle="",this.filter="",this.limit=0,this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.measureUnit="",this.stack="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,E(this),o(this),it(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=l(this),rt(this),this.componentStyle=b(this),this.ruleSetConfig=ht(this),this.t=st(this).t,this.resolveInherited=ot(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){const{mode:t}=nt(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkWidthOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkWidthOverflow();const i=this.element,{height:s}=et(i);if(s<=0)return void this.checkWidthOverflow();this._lastScaledParentHeight=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollHeight,a=this.appliedScaleFactor;if(r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkWidthOverflow();const h=Math.max(.3,a*(s-1)/r);Math.abs(h-a)<.01||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,n((()=>{this.appliedScaleFactor=h}))),this.checkWidthOverflow()}componentDidLoad(){this.layoutObserver=lt(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=et(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,r(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=et(this.element);this._lastScaledParentHeight=t,r(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}checkWidthOverflow(){var t;const i="WARN_overflow",s=String(null!==(t=this.unitScaling)&&void 0!==t?t:"").trim().toLowerCase();if(""===s||"auto"===s)return void this.errors.remove(i);const e=et(this.element);e.width>0&&this.element.scrollWidth>e.width+1?this.errors.addOrReplace({id:i,type:"error",message:`Chart exceeds available width (${this.element.scrollWidth}px > ${Math.round(e.width)}px). Reduce unit-scaling or set to "auto".`}):this.errors.remove(i)}prepareDimension(){const t=et(this.element),i=this.prepareVariances();return this.canvasWidthSegmented=t.width/(1+i.length),{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,s,e;const n=this.resolveInherited("scenarios",this.scenarios);if(void 0!==n)return this.errors.remove("AUTO_scenarios"),n.split(",").map((t=>t.trim()));const r="auto"===(null===(t=this.scenarios)||void 0===t?void 0:t.trim().toLowerCase());return L(this.scenarios)||r?(null===(s=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===s?void 0:s.length)>0?(r?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(e=this.scenarios)||void 0===e?void 0:e.split(",").map((t=>t.trim())))}prepareVariances(){var t;const i=this.resolveInherited("variances",this.variances);return void 0!==i?i.split(",").map((t=>t.trim())):L(this.variances)?[]:null===(t=this.variances)||void 0===t?void 0:t.split(",").map((t=>t.trim()))}prepareHideCategories(t){return t>=1||"true"!==this.showCategories}prepareI18n(){const t=u,i=new Map([].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}preparePixelPerUnit(){var t;if(this.pixelPerUnitGroupMap.has(this.unitScaling))return this.errors.remove("AUTO_unitScaling"),this.pixelPerUnitGroupMap.get(this.unitScaling);if("auto"===(null===(t=this.unitScaling)||void 0===t?void 0:t.toString().trim().toLowerCase()))return this.errors.remove("AUTO_unitScaling"),0;const i=Number(this.unitScaling);return!isNaN(i)&&i>0?(this.errors.remove("AUTO_unitScaling"),i):(this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:"unit-scaling: not set, auto-calculated to fit available space."}),0)}preparePixelPerPercentage(){var t;if(this.pixelPerUnitGroupMap.has(this.percentageScaling))return this.pixelPerUnitGroupMap.get(this.percentageScaling);if("auto"===(null===(t=this.percentageScaling)||void 0===t?void 0:t.toString().trim().toLowerCase()))return this.errors.remove("AUTO_percentageScaling"),0;const i=Number(this.percentageScaling);return!isNaN(i)&&i>0?(this.errors.remove("AUTO_percentageScaling"),100*i):(this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:"percentage-scaling: not set, auto-calculated to fit available space."}),0)}prepareLevel(){var t,i,s;const e="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return L(this.level)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(e?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:`level: not set, auto-detected: ${this.datasetMeta.suggestedLevel}`}),ct[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),ct[null===(s=this.level)||void 0===s?void 0:s.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),s=this.resolveInherited("orderDirection",this.orderDirection),e=null!=i?i:this.order,n=null!=s?s:this.orderDirection,r="auto"===(null==e?void 0:e.trim().toLowerCase());let a;return L(e)||r?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(r?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${this.datasetMeta.suggestedOrder}`}),a=this.datasetMeta.suggestedOrder):a=e:(this.errors.remove("AUTO_order"),a=e),{hierarchy:null==a?void 0:a.split(",").map((t=>P[null==t?void 0:t.toUpperCase()])),direction:T[null==n?void 0:n.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-structure"].scaleFactors.scenarioOffset,scenarioLabelToBar:i["bn-chart-structure"].scaleFactors.scenarioLabelToBar,labelToBar:i["bn-chart-structure"].scaleFactors.labelToBar,labelToAxis:i["bn-chart-structure"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-structure"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-structure"].scaleFactors.needleHeadWidth,barWidth:i["bn-chart-structure"].scaleFactors.barWidth,varianceAxisLineWidth:i["bn-chart-structure"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-structure"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-structure"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-structure"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-structure"].scaleFactors.markerWidth,markerOffset:i["bn-chart-structure"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-structure"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-structure"].scaleFactors.axisTickLength},fontStyles:{font:`${s}px ${i.global.fontFamily}`,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-structure"].axisStyles,barStyles:i["bn-chart-structure"].barStyles,varianceStyles:i["bn-chart-structure"].varianceStyles,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareStackConfig(){if(L(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios";if(i===dt.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s)}else this.errors.remove(s);return{by:i,mode:t.mode||pt.ABSOLUTE,order:t.order||ut.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareLimit(){return Math.floor(Number(this.limit)||0)}getDataStructure(){return{IStructureChartDataRow:{operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return L(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,s){const e=this.getEffectiveScaleFactor(),n=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),a=this.prepareStackConfig(),h=this.prepareScenarios(),o=(null==a?void 0:a.by)===dt.DIMENSIONS?h.slice(0,1):h;return i("ibcs-chart-structure",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:o,variances:[t],hideCategories:this.prepareHideCategories(s),pixelPerUnit:n>0?n*e:0,pixelPerPercentage:r>0?r*e:0,limit:this.prepareLimit(),styles:this.prepareStyle(),i18n:this.prepareI18n(),order:this.prepareOrder(),level:this.prepareLevel(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(s),stackConfig:a,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}getEffectiveScaleFactor(){const{mode:t,factor:i}=nt(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const a=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":a*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const e=this.prepareVariances();e.length>0&&(t=[...t,...e]);const n=this.getFontStyles();return i(s,{key:"47c720a82d86db4bbae43818b1ff8a32e6f38bf8",style:n},i("div",{key:"82ece19acfee49d6bdbd74f18126a178ef0667c9",class:"container"},t.map(this.chartTemplate)))}get element(){return e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}};var Jt;Xt.style=':host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}',function(t){t.ROWGROUP="rowGroup",t.ROWGROUPINDEX="rowGroupIndex",t.CATEGORY="category",t.CATEGORYINDEX="categoryIndex",t.SUBCATEGORY="subCategory",t.SUBCATEGORYINDEX="subCategoryIndex"}(Jt||(Jt={}));const qt=class{validateScenario(t){const i="ERR_scenarios";if(at(t))return void this.errors.remove(i);const s=w(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(at(t))return void this.errors.remove(i);const s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateLeftSync(t){const i="ERR_syncSpaceLeft";S(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"syncSpaceLeft: invalid value(s) '"+t+"' are not supported."})}validateLimit(t){const i="ERR_limit";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateUnitScaling(t){const i="ERR_unitScaling";"auto"===(null==t?void 0:t.toString().trim().toLowerCase())||S(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."})}validatePercentageScaling(t){const i="ERR_percentageScaling";"auto"===(null==t?void 0:t.toString().trim().toLowerCase())||S(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."})}validateLevel(t){const i="ERR_level";O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="ERR_order";if(at(t))return void this.errors.remove(i);const s=$(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";at(t)||R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateInterval(t){const i="ERR_dateInterval";A(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateInterval: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateChartMode(t){const i="ERR_chartMode";["bar","line","auto"].includes(null==t?void 0:t.toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"chartMode: invalid value '"+(null==t?void 0:t.toString())+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(t){const i="ERR_maxBars";!M(t)||t<1?this.errors.addOrReplace({id:i,type:"warning",message:"maxBars: invalid value '"+(null==t?void 0:t.toString())+"' is not supported. Must be a positive integer."}):this.errors.remove(i)}validateStack(t){const i="ERR_stack",s=k(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:s.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}validateAxisLabelsMode(t){const i="ERR_axisLabelsMode";C(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsMode: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateLineFullWidth(t){const i="ERR_lineFullWidth";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"lineFullWidth: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowCategories(t){const i="ERR_showCategories";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showCategories: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateMeasureScale(t){const i="ERR_measureScale";_(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowOverlayAvg(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showOverlayAvg: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowOverlayMedian(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showOverlayMedian: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.chartTitle="",this.filter="",this.syncSpaceLeft=-1,this.limit=0,this.chartMode="bar",this.maxBars=28,this.stack="",this.intervalSpanLimit=28,this.lineFullWidth="true",this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.showOverlayAvg="true",this.showOverlayMedian="false",this.measureUnit="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,this._settleTimer=null,this._lastAppliedHeight=0,E(this),o(this),it(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=l(this),rt(this),this.componentStyle=b(this),this.ruleSetConfig=ht(this),this.t=st(this).t,this.resolveInherited=ot(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLimit(this.limit),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateLeftSync(this.syncSpaceLeft),this.validateDateInterval(this.dateInterval),this.validateAxisLabelsMode(this.axisLabelsMode),this.validateLineFullWidth(this.lineFullWidth),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateShowOverlayAvg(this.showOverlayAvg),this.validateShowOverlayMedian(this.showOverlayMedian),this.validateChartMode(this.chartMode),this.validateMaxBars(this.maxBars),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){const{mode:t}=nt(this.scale);if("auto"!==t&&"empty"!==t){this._autoScaleGuard=!1;const t=et(this.element),i="WARN_overflow";return void(t.width>0&&this.element.scrollWidth>t.width+1?this.errors.addOrReplace({id:i,type:"warning",message:"Chart exceeds available space and will be cut off. Check unit-scaling value."}):this.errors.remove(i))}if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const i=this.element,{width:s}=et(i);if(s<=0)return;this._lastObservedWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,a=this.appliedScaleFactor;if(r<=s+1)return void this.errors.remove("AUTO_scale");const h=Math.max(.3,a*(s-1)/r);Math.abs(h-a)<.01||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,n((()=>{this.appliedScaleFactor=h})))}componentDidLoad(){this.layoutObserver=lt(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=et(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,r(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=et(this.element);this._lastObservedWidth=t,r(this)}))})),this.settleParentHeight()}settleParentHeight(){const t=[150,400,1e3,2500],i=()=>{if(this._settleTimer=null,!this.element.isConnected)return;const{height:s}=et(this.element);s>0&&Math.abs(s-this._lastAppliedHeight)>8&&!this._autoScaleGuard&&r(this);const e=t.shift();void 0!==e&&(this._settleTimer=setTimeout(i,e))};this._settleTimer=setTimeout(i,t.shift())}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null,null!=this._settleTimer&&(clearTimeout(this._settleTimer),this._settleTimer=null)}prepareDimension(){const t=et(this.element),i=this.prepareScenarios(),s=this.prepareVariances();return this.canvasWidthSegmented=t.width/(i.length+s.length||1),this._lastAppliedHeight=t.height,{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,s,e;const n=this.resolveInherited("scenarios",this.scenarios);if(void 0!==n)return this.errors.remove("AUTO_scenarios"),n.split(",").map((t=>t.trim()));const r="auto"===(null===(t=this.scenarios)||void 0===t?void 0:t.trim().toLowerCase());return L(this.scenarios)||r?(null===(s=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===s?void 0:s.length)>0?(r?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(e=this.scenarios)||void 0===e?void 0:e.split(",").map((t=>t.trim())))}prepareAvg(){return"true"===this.showOverlayAvg}prepareMedian(){return"true"===this.showOverlayMedian}prepareVariances(){var t;const i=this.resolveInherited("variances",this.variances);return void 0!==i?i.split(",").map((t=>t.trim())):L(this.variances)?[]:null===(t=this.variances)||void 0===t?void 0:t.split(",").map((t=>t.trim()))}prepareHideAxisLabels(t){return t>=1||"true"!==this.showCategories}prepareI18n(){const t=u,i=new Map([].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}preparePixelPerUnit(){var t;if(this.pixelPerUnitGroupMap.has(this.unitScaling))return this.errors.remove("AUTO_unitScaling"),this.pixelPerUnitGroupMap.get(this.unitScaling);if("auto"===(null===(t=this.unitScaling)||void 0===t?void 0:t.toString().trim().toLowerCase()))return this.errors.remove("AUTO_unitScaling"),0;const i=Number(this.unitScaling);return!isNaN(i)&&i>0?(this.errors.remove("AUTO_unitScaling"),i):(this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:"unit-scaling: not set, auto-calculated to fit available space."}),0)}preparePixelPerPercentage(){var t;if(this.pixelPerUnitGroupMap.has(this.percentageScaling))return this.pixelPerUnitGroupMap.get(this.percentageScaling);if("auto"===(null===(t=this.percentageScaling)||void 0===t?void 0:t.toString().trim().toLowerCase()))return this.errors.remove("AUTO_percentageScaling"),0;const i=Number(this.percentageScaling);return!isNaN(i)&&i>0?(this.errors.remove("AUTO_percentageScaling"),100*i):(this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:"percentage-scaling: not set, auto-calculated to fit available space."}),0)}prepareLevel(){var t,i,s;const e="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return L(this.level)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(e?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:`level: not set, auto-detected: ${this.datasetMeta.suggestedLevel}`}),Jt[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),Jt[null===(s=this.level)||void 0===s?void 0:s.toUpperCase()])}prepareOrder(){var t,i,s;const e=this.resolveInherited("order",this.order),n=this.resolveInherited("orderDirection",this.orderDirection),r=null!=e?e:this.order,a=null!=n?n:this.orderDirection;let h=(L(this.level)||"auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase()))&&(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?this.datasetMeta.suggestedLevel:this.level;const o="auto"===(null==r?void 0:r.trim().toLowerCase());return L(r)||o?(null===(s=this.datasetMeta)||void 0===s?void 0:s.suggestedLevel)&&(o?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${h}`})):(this.errors.remove("AUTO_order"),"levelindex"===(null==r?void 0:r.toLocaleLowerCase())&&(h+="Index")),{hierarchy:[P[null==h?void 0:h.toUpperCase()]],direction:T[null==a?void 0:a.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-time"].scaleFactors.scenarioOffset,scenarioLabelToColumn:i["bn-chart-time"].scaleFactors.scenarioLabelToColumn,labelToColumn:.3,labelToColum:i["bn-chart-time"].scaleFactors.labelToColum,labelToAxis:i["bn-chart-time"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-time"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-time"].scaleFactors.needleHeadWidth,columnWidth:i["bn-chart-time"].scaleFactors.columnWidth,varianceAxisLineWidth:i["bn-chart-time"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-time"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-time"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-time"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-time"].scaleFactors.markerWidth,markerOffset:i["bn-chart-time"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-time"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-time"].scaleFactors.axisTickLength},fontStyles:{font:`${s}px ${i.global.fontFamily}`,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-time"].axisStyles,barStyles:i["bn-chart-time"].barStyles,varianceStyles:i["bn-chart-time"].varianceStyles,stackColors:i["bn-chart-time"].stackColors,padding:i["bn-chart-time"].padding,pattern:null}}))}prepareLeftSideOffset(t,i){return this.syncSpaceLeft>-1?this.syncSpaceLeft:Mt.getMaxWidthOfArrayItems([...this.prepareVariances(),...this.prepareScenarios(),this.chartTitle],t,i)}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareDateInterval(){var t,i,s;const e="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return L(this.dateInterval)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedDateInterval)?(e?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:`dateInterval: not set, auto-detected: ${this.datasetMeta.suggestedDateInterval}`}),N[this.datasetMeta.suggestedDateInterval.toUpperCase()]):e?N.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),N[null===(s=this.dateInterval)||void 0===s?void 0:s.toUpperCase()])}prepareIntervalSpanLimit(){return this.intervalSpanLimit}prepareAxisLabelsMode(){var t;return ft[null===(t=this.axisLabelsMode)||void 0===t?void 0:t.toUpperCase()]}prepareFilter(){return 0===this.filter.length?"":this.filter}getDataStructure(){return{ITimeChartDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return L(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareStackConfig(){if(L(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios";if(i===dt.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s)}else this.errors.remove(s);return{by:i,mode:t.mode||pt.ABSOLUTE,order:t.order||ut.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareLineFullWidth(){return"true"===this.lineFullWidth}prepareChartMode(){var t;const i=null===(t=this.chartMode)||void 0===t?void 0:t.toLowerCase();return"line"===i?vt.LINE:"auto"===i?vt.AUTO:vt.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,s){const e=this.prepareI18n(),n=this.prepareStyle(),r=et(this.element).width,a=this.getEffectiveScaleFactor(),h=this.preparePixelPerUnit(),o=this.preparePixelPerPercentage(),l=this.prepareStackConfig(),c=this.prepareScenarios(),d=(null==l?void 0:l.by)===dt.DIMENSIONS?c.slice(0,1):c;return i("ibcs-chart-time",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:d,variances:[t],hideAxisLabels:this.prepareHideAxisLabels(s),pixelPerUnit:h>0?h*a:0,pixelPerPercentage:o>0?o*a:0,limit:this.prepareLimit(),leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(e,n),styles:n,i18n:e,order:this.prepareOrder(),level:this.prepareLevel(),dateInterval:this.prepareDateInterval(),intervalSpanLimit:this.prepareIntervalSpanLimit(),axisLabelsMode:this.prepareAxisLabelsMode(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showOverlayAvg:this.prepareAvg(),showOverlayMedian:this.prepareMedian(),showMeasureScale:this.prepareShowMeasureScale(s),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:l,lineFullWidth:this.prepareLineFullWidth(),containerWidth:r,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}getEffectiveScaleFactor(){const{mode:t,factor:i}=nt(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const a=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":a*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const e=this.prepareVariances();e.length>0&&(t=[...t,...e]);const n=this.getFontStyles();return i(s,{key:"24ae704ef08048b28578c9616b07d84d0ac7b13c",style:n},i("div",{key:"79c4a900b6689993d8283e4e05f9a91069491b1c",class:"container"},t.map(this.chartTemplate)))}get element(){return e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],limit:[{validateLimit:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],lineFullWidth:[{validateLineFullWidth:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],showOverlayAvg:[{validateShowOverlayAvg:0}],showOverlayMedian:[{validateShowOverlayMedian:0}]}}};qt.style=":host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}";const Kt=class{constructor(i){t(this,i),this.name="_default",o(this),this.errors=l(this),m(this,(t=>{this.stores||(this.stores=d(this.element));try{const i=JSON.parse(t);this.stores.componentStyles.set(this.name,i),this.errors.remove("JSON_PARSE")}catch(t){this.errors.addOrReplace({id:"JSON_PARSE",type:"error",message:`bn-component-style: Failed to parse JSON body — ${t.message}`}),console.error(t)}}))}render(){return i(s,{key:"b920e4a086d748a1d9ec921e6bf92fa26a7e6c7d"})}get element(){return e(this)}};Kt.style="bn-component-style{display:none}";const Zt=class{constructor(i){t(this,i),this.currentPageUpdate=void 0,o(this),this.errors=l(this)}setLocale(t){this.stores.context.state.locale=t}connectedCallback(){this.stores=p(this.element),this.locale&&(this.stores.context.state.locale=this.locale),this.currentPageUpdate=setTimeout((()=>{this.element.querySelectorAll("bn-page, bn-layout-page").forEach(((t,i)=>{if("bn-layout-page"===t.localName)t.setAttribute("page-number",(i+1).toString());else{const s=t.querySelector("bn-footer");s&&s.setAttribute("page-number",(i+1).toString())}}))}),250)}disconnectedCallback(){this.currentPageUpdate&&clearTimeout(this.currentPageUpdate)}componentWillLoad(){}componentDidLoad(){}componentShouldUpdate(){}componentWillRender(){}componentDidRender(){}componentWillUpdate(){}componentDidUpdate(){}render(){return i(s,{key:"951ae1073a4b43e9b5382e17c6afb0faab120a01"},i("slot",{key:"4337496bfb68b431c90855b81d05f3f469e7f259"}))}get element(){return e(this)}static get watchers(){return{locale:[{setLocale:0}]}}};Zt.style=":host{display:block}";const Qt=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],ti=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function ii(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function si(t){const i=Array.from(t);return{distinctValues:i,count:i.length,hasData:i.length>0}}var ei=Uint8Array,ni=Uint16Array,ri=Int32Array,ai=new ei([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),hi=new ei([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),oi=new ei([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),li=function(t,i){for(var s=new ni(31),e=0;e<31;++e)s[e]=i+=1<<t[e-1];var n=new ri(s[30]);for(e=1;e<30;++e)for(var r=s[e];r<s[e+1];++r)n[r]=r-s[e]<<5|e;return{b:s,r:n}},ci=li(ai,2),di=ci.b,ui=ci.r;di[28]=258,ui[258]=28;for(var pi=li(hi,0).b,fi=new ni(32768),vi=0;vi<32768;++vi){var gi=(43690&vi)>>1|(21845&vi)<<1;fi[vi]=((65280&(gi=(61680&(gi=(52428&gi)>>2|(13107&gi)<<2))>>4|(3855&gi)<<4))>>8|(255&gi)<<8)>>1}var mi=function(t,i,s){for(var e=t.length,n=0,r=new ni(i);n<e;++n)t[n]&&++r[t[n]-1];var a,h=new ni(i);for(n=1;n<i;++n)h[n]=h[n-1]+r[n-1]<<1;if(s){a=new ni(1<<i);var o=15-i;for(n=0;n<e;++n)if(t[n])for(var l=n<<4|t[n],c=i-t[n],d=h[t[n]-1]++<<c,u=d|(1<<c)-1;d<=u;++d)a[fi[d]>>o]=l}else for(a=new ni(e),n=0;n<e;++n)t[n]&&(a[n]=fi[h[t[n]-1]++]>>15-t[n]);return a},bi=new ei(288);for(vi=0;vi<144;++vi)bi[vi]=8;for(vi=144;vi<256;++vi)bi[vi]=9;for(vi=256;vi<280;++vi)bi[vi]=7;for(vi=280;vi<288;++vi)bi[vi]=8;var wi=new ei(32);for(vi=0;vi<32;++vi)wi[vi]=5;var yi=mi(bi,9,1),Si=mi(wi,5,1),Oi=function(t){for(var i=t[0],s=1;s<t.length;++s)t[s]>i&&(i=t[s]);return i},$i=function(t,i,s){var e=i/8|0;return(t[e]|t[e+1]<<8)>>(7&i)&s},Ri=function(t,i){var s=i/8|0;return(t[s]|t[s+1]<<8|t[s+2]<<16)>>(7&i)},Mi=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],xi=function(t,i,s){var e=new Error(i||Mi[t]);if(e.code=t,Error.captureStackTrace&&Error.captureStackTrace(e,xi),!s)throw e;return e},_i=new ei(0);function ki(t,i){var s,e,n=function(t){31==t[0]&&139==t[1]&&8==t[2]||xi(6,"invalid gzip data");var i=t[3],s=10;4&i&&(s+=2+(t[10]|t[11]<<8));for(var e=(i>>3&1)+(i>>4&1);e>0;e-=!t[s++]);return s+(2&i)}(t);return n+8>t.length&&xi(6,"invalid gzip data"),function(t,i,s,e){var n=t.length;if(!n||i.f&&!i.l)return s||new ei(0);var r=!s,a=r||2!=i.i;r&&(s=new ei(3*n));var h,o,l=function(t){var i=s.length;if(t>i){var e=new ei(Math.max(2*i,t));e.set(s),s=e}},c=i.f||0,d=i.p||0,u=i.b||0,p=i.l,f=i.d,v=i.m,g=i.n,m=8*n;do{if(!p){c=$i(t,d,1);var b=$i(t,d+1,3);if(d+=3,!b){var w=t[(L=4+((d+7)/8|0))-4]|t[L-3]<<8,y=L+w;if(y>n){xi(0);break}a&&l(u+w),s.set(t.subarray(L,y),u),i.b=u+=w,i.p=d=8*y,i.f=c;continue}if(1==b)p=yi,f=Si,v=9,g=5;else if(2==b){var S=$i(t,d,31)+257,O=$i(t,d+10,15)+4,$=S+$i(t,d+5,31)+1;d+=14;for(var R=new ei($),M=new ei(19),x=0;x<O;++x)M[oi[x]]=$i(t,d+3*x,7);d+=3*O;var _=Oi(M),k=(1<<_)-1,E=mi(M,_,1);for(x=0;x<$;){var L,T=E[$i(t,d,k)];if(d+=15&T,(L=T>>4)<16)R[x++]=L;else{var P=0,A=0;for(16==L?(A=3+$i(t,d,3),d+=2,P=R[x-1]):17==L?(A=3+$i(t,d,7),d+=3):18==L&&(A=11+$i(t,d,127),d+=7);A--;)R[x++]=P}}var C=R.subarray(0,S),N=R.subarray(S);v=Oi(C),g=Oi(N),p=mi(C,v,1),f=mi(N,g,1)}else xi(1);if(d>m){xi(0);break}}a&&l(u+131072);for(var U=(1<<v)-1,D=(1<<g)-1,G=d;;G=d){var W=(P=p[Ri(t,d)&U])>>4;if((d+=15&P)>m){xi(0);break}if(P||xi(2),W<256)s[u++]=W;else{if(256==W){G=d,p=null;break}var F=W-254;W>264&&(F=$i(t,d,(1<<(B=ai[x=W-257]))-1)+di[x],d+=B);var Y=f[Ri(t,d)&D],I=Y>>4;if(Y||xi(3),d+=15&Y,N=pi[I],I>3){var B=hi[I];N+=Ri(t,d)&(1<<B)-1,d+=B}if(d>m){xi(0);break}a&&l(u+131072);var z=u+F;if(u<N){var H=0-N,V=Math.min(N,z);for(H+u<0&&xi(3);u<V;++u)s[u]=e[H+u]}for(;u<z;++u)s[u]=s[u-N]}}i.l=p,i.p=G,i.b=u,i.f=c,p&&(c=1,i.m=v,i.d=f,i.n=g)}while(!c);return u!=s.length&&r?(h=s,(null==(o=u)||o>h.length)&&(o=h.length),new ei(h.subarray(0,o))):s.subarray(0,u)}(t.subarray(n,-8),{i:2},new ei(((s=t)[(e=s.length)-4]|s[e-3]<<8|s[e-2]<<16|s[e-1]<<24)>>>0),i)}var Ei="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ei.decode(_i,{stream:!0})}catch(t){}function Li(t){return U(t)}function Ti(t){const i=t.indexOf(":");if(-1===i)throw new Error("Invalid compressed format: missing ':' separator");const s=t.slice(0,i),e=t.slice(i+1),n=atob(e),r=new Uint8Array(n.length);for(let t=0;t<n.length;t++)r[t]=n.charCodeAt(t);const a=ki(r);return{hash:s,json:(new TextDecoder).decode(a)}}const Pi=class{constructor(i){t(this,i),this.datasources="",this.static=!1,this.raw=!0,this.interval=0,this.lastBodyHash=null,this.lastViewQuery=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,o(this),this.errors=l(this),((t,i)=>{let s,n=[],r=[];const a=t=>{let e;try{e=s.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){e=[]}i()},h=()=>{n.forEach((t=>t())),n=[],r.forEach((t=>{t&&(n.push(s.db.subscribe(t,(()=>a(t)))),a(t))}))},o=new MutationObserver((i=>{i.forEach((i=>{"datasources"===i.attributeName&&(r=(e(t).getAttribute("datasources")||"").split(","),h())}))})),l=t.connectedCallback;t.connectedCallback=()=>{const i=e(t);s=d(i),r=(i.getAttribute("datasources")||"").split(","),h(),o.observe(i,{attributes:!0,attributeFilter:["datasources"]}),c(l,t)};const u=t.disconnectedCallback;t.disconnectedCallback=()=>{o.disconnect(),n.forEach((t=>t())),n=[],f(e(t)),c(u,t)}})(this,(()=>{this.executeQuery()})),m(this,(t=>{const i=t.trim();if(this.isUrl(i)){if(i===this.currentUrl)return;return this.currentUrl=i,this.lastBodyHash=null,this.fetchAndStore(i),void this.startPolling()}let s,e;if(null!==this.currentUrl&&(this.cancelInFlight(),this.currentUrl=null),!this.raw&&this.static)try{const i=Ti(t);s=i.hash,e=i.json}catch(i){return void console.error("Error decoding compressed dataset",i,String(t).slice(0,200))}else s=Li(t),e=t;s!==this.lastBodyHash&&(this.lastBodyHash=s,this.query=e,this.executeQuery())}))}executeQuery(){if(this.stores||(this.stores=d(this.element)),!this.query||!this.name)return;const t=this.stores.db.db;let i;if(this.static){try{i=JSON.parse(this.query)}catch(t){console.error("Failed to parse static dataset",t),i=[]}t.tables[this.name]={data:Array.isArray(i)?i:[]},this.lastViewQuery=null}else{if(this.lastViewQuery!==this.query){try{t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],t.views&&null!=t.views[this.name]&&delete t.views[this.name];try{t.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`),this.lastViewQuery=this.query}catch(t){return console.error("bn-dataset: failed to register SQL view",t,this.query),this.lastViewQuery=null,i=[],void this.publish(i)}}try{i=t.exec(`SELECT * FROM \`${this.name}\``)}catch(t){return}}this.publish(i)}publish(t){this.latestResult!==t?(this.latestResult=t,this.stores.db.notify(this.name),this.stores.datasetsMeta.set(this.name,function(t){const i={};for(const t of ti)i[t]=new Set;const s={};for(const t of Qt)s[t]={hasData:!1,min:null,max:null};const e=new Set;let n=null,r=null;const a=Array.isArray(t)?t:[];for(let t=0;t<a.length;t++){const h=a[t];if(null==h)continue;for(const t of ti){const s=h[t];null!=s&&""!==s&&i[t].add(String(s))}for(const t of Qt){const i=h[t];if(ii(i)){const e=s[t];e.hasData=!0,(null===e.min||i<e.min)&&(e.min=i),(null===e.max||i>e.max)&&(e.max=i)}}const o=h.date;if(null!=o&&""!==o){const t=String(o);e.add(t),(null===n||t<n)&&(n=t),(null===r||t>r)&&(r=t)}}const h=Qt.map((t=>({key:t,hasData:s[t].hasData,min:s[t].min,max:s[t].max}))),o=h.filter((t=>t.hasData)).map((t=>t.key)),l=si(i.rowGroup),c=si(i.category),d=si(i.subCategory),u=si(i.columnGroup),p=si(i.columnSubGroup),f={min:n,max:r,hasData:e.size>0,distinctCount:e.size};let v="category";return d.hasData?v="subCategory":c.hasData?v="category":l.hasData&&(v="rowGroup"),{rowCount:a.length,scenarios:h,availableScenarios:o,rowGroup:l,category:c,subCategory:d,columnGroup:u,columnSubGroup:p,dateRange:f,suggestedLevel:v,suggestedOrder:v,suggestedDateInterval:f.hasData?"auto":null,calculatedAt:Date.now()}}(t))):this.stores.db.notify(this.name)}nameUpdated(){this.executeQuery()}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,i;if(this.cancelInFlight(),(null===(i=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===i?void 0:i.db)&&this.name){const t=this.stores.db.db;try{t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],t.views&&null!=t.views[this.name]&&delete t.views[this.name],this.stores.db.notify(this.name)}}isUrl(t){return!(!t.startsWith("http://")&&!t.startsWith("https://"))||t.startsWith("/")&&!t.startsWith("//")}async fetchAndStore(t){var i;null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=new AbortController,this.stores||(this.stores=d(this.element));try{const i=await fetch(t,{signal:this.abortController.signal}),s=await i.json();this.stores.db.db.tables[this.name]={data:Array.isArray(s)?s:[]},this.lastViewQuery=null,this.publish(s)}catch(i){if(i instanceof DOMException&&"AbortError"===i.name)return;console.error("bn-dataset: error fetching URL",i,t),this.stores.db.db.tables[this.name]={data:[]},this.lastViewQuery=null,this.publish([])}}clearPollTimer(){null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null)}cancelInFlight(){var t;this.clearPollTimer(),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPollTimer(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return i(s,{key:"483ee52a7ad5547dd8f3cf8117963bad39222f82"})}get element(){return e(this)}static get watchers(){return{name:[{nameUpdated:0}],interval:[{onIntervalChange:0}]}}};Pi.style="bn-dataset{display:none}";const Ai=class{constructor(i){t(this,i),this.raw=!0,this.interval=0,this.lastHash=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,o(this),this.errors=l(this),m(this,(t=>{this.stores||(this.stores=d(this.element));const i=t.trim();if(this.isUrl(i)){if(i===this.currentUrl)return;return this.currentUrl=i,this.lastHash=null,this.fetchAndStore(i),void this.startPolling()}null!==this.currentUrl&&(this.cancelInFlight(),this.currentUrl=null);try{let i,s;if(this.raw)i=Li(t),s=t;else{const e=Ti(t);i=e.hash,s=e.json}if(i===this.lastHash)return;this.lastHash=i;const e=JSON.parse(s);this.publish(e)}catch(i){console.error("Error parsing datasource",i,String(t).slice(0,200)),this.publish([])}}))}publish(t){this.stores.db.db.tables[this.name]={data:Array.isArray(t)?t:[]},this.stores.db.notify(this.name)}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,i;this.cancelInFlight();const s=null===(i=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===i?void 0:i.db;s&&this.name&&(null!=s.tables[this.name]&&delete s.tables[this.name],s.views&&null!=s.views[this.name]&&delete s.views[this.name],this.stores.db.notify(this.name))}isUrl(t){return!(!t.startsWith("http://")&&!t.startsWith("https://"))||t.startsWith("/")&&!t.startsWith("//")}async fetchAndStore(t){var i;null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=new AbortController,this.stores||(this.stores=d(this.element));try{const i=await fetch(t,{signal:this.abortController.signal}),s=await i.json();this.publish(s)}catch(i){if(i instanceof DOMException&&"AbortError"===i.name)return;console.error("bn-datasource: error fetching URL",i,t),this.publish([])}}clearPollTimer(){null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null)}cancelInFlight(){var t;this.clearPollTimer(),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPollTimer(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return i(s,{key:"f78ba1b36a4fccb5016a08845e838814ccc8bb6c"})}get element(){return e(this)}static get watchers(){return{interval:[{onIntervalChange:0}]}}};Ai.style="bn-datasource{display:none}";const Ci=class{constructor(i){t(this,i),this.pageNumber=null,this.displayPageNumber=!0,o(this),this.errors=l(this),this.componentStyle=b(this)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}isValidHttpUrl(t){let i;try{i=new URL(t)}catch(t){return!1}return"http:"===i.protocol||"https:"===i.protocol}prepareAssetUrl(t){return this.isValidHttpUrl(t)?t:`./assets/${t}.png`}render(){return i(s,{key:"07c01136b8130b2fc121eb5f4f6a9d999b863e76",id:this.displayPageNumber||this.text||this.code?"container-page-footer":"container",style:this.getFontStyles()},i("div",{key:"2277a4f74c64e2ddb2e2248f3e92c79fa9134368",id:"footer-text"},null!=this.text?i("span",{class:"note"},this.text):""),i("div",{key:"88676f2510a345fe376302c30f9e8a5679cacbbc",id:"code"},null!=this.code?i("img",{class:"image",src:a(`${this.prepareAssetUrl(this.code)}`)}):""),i("div",{key:"76cf057f846ce92d7d20a213c3fcf08a41250a07",id:"page-number"},this.displayPageNumber?i("span",{class:"page"},this.pageNumber):""))}static get assetsDirs(){return["assets"]}get element(){return e(this)}};Ci.style=':host{padding:0.2em 0.5em;display:flex;flex-direction:row;justify-content:space-between;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(#container-page-footer){box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em solid #ddd}div#footer-text{font-size:0.6em;display:inline}div#code{flex:1;display:inline;text-align:right;padding-right:1em}div#page-number{font-size:0.6em;display:inline}.image{z-index:2;background-color:transparent;border:transparent;height:1.2em;width:auto}';const Ni=class{constructor(i){t(this,i),this.titleImage="",this.titleBusinessUnit="",this.titleOrder="category",this.titleOrderDirection="asc",this.titleDateFormat="none",this.titleDateLink="none",this.titleNamespace="_system",this.footerText="",this.cardLayout="full",this.cardCustomTemplate='"a b" "c d"',this.cardGridGap="0",this.cardFitToContent=!1,this.cardShowBorder=!0,this.templateMap=new Map([["split-vertical",'"a b"'],["split-horizontal",'"a" "b"'],["2x2",'"a b" "c d"'],["3x3",'"a b c" "d e f" "g h i"'],["4x4",'"a b c d" "e f g h" "i j k l" "m n o p"'],["1-over-2",'"a a" "b c"'],["2-over-1",'"a b" "c c"'],["1-over-3",'"a a a " "b c d"'],["3-over-1",'"a b c" "d d d"'],["custom-template",'"a b" "c c c"'],["gold3",'"a c" "b c"'],["gold4",'"a b c c" "d d c c"']]),this.errors=l(this),this.resolveInherited=ot(this,[{propName:"titleScenarios",ancestorAttr:"title-scenarios"},{propName:"titleVariances",ancestorAttr:"title-variances"},{propName:"titleOrder",ancestorAttr:"title-order"},{propName:"titleOrderDirection",ancestorAttr:"title-order-direction"},{propName:"ruleset",ancestorAttr:"ruleset"}])}connectedCallback(){this.stores=d(this.element),this.reflectInheritedAttrs()}getCommonStyles(){let t="100%";return!0===this.cardFitToContent&&(t="fit-content"),{display:"grid",height:t,width:"100%",gap:this.cardGridGap+"px"}}calculateFractions(t){const i=t.trim().split(/\s+/).length;return 0===i?"minmax(0, 1fr)":Array(i).fill("minmax(0, 1fr)").join(" ")}getGridTemplateColumns(t){const i=this.getTemplatePattern(t).match(/"[\w\d\s.]+"/g);return i&&0!==i.length?this.calculateFractions(i[0]):"minmax(0, 1fr)"}getRowCount(t){const i=this.getTemplatePattern(t).match(/"[\w\d\s.]+"/g);return i?i.length:1}getGridTemplateRows(t){const i=this.getRowCount(t);return this.cardFitToContent?Array(i).fill("auto").join(" "):Array(i).fill("minmax(0, 1fr)").join(" ")}getLayoutStyle(){return Object.assign(Object.assign({},this.getCommonStyles()),{"grid-template-areas":this.getTemplatePattern(this.cardLayout),"grid-template-columns":this.getGridTemplateColumns(this.cardLayout),"grid-template-rows":this.getGridTemplateRows(this.cardLayout)})}createDivAreaStyles(t){return t.map((t=>({display:"flex",overflow:"hidden","grid-area":t})))}getSlots(t){const s=this.createDivAreaStyles(t);return i(h,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"card-slot-"+s})))))}extractSlotNames(t){if(null==t)return[];const i=t.match(/\b\w+\b/g);return i?Array.from(new Set(i)):[]}getTemplatePattern(t){return!1===this.templateMap.has(t)&&"custom-template"!==t?'"a"':"custom-template"===t?this.cardCustomTemplate:this.templateMap.get(t)}async getNumberOfSlot(t){const i=this.getTemplatePattern(t);return this.extractSlotNames(i).length}componentDidUpdate(){}setCardClass(){return!0===this.cardShowBorder?"card_box border":"card_box"}reflectInheritedAttrs(){const t=[{prop:"titleScenarios",attr:"title-scenarios"},{prop:"titleVariances",attr:"title-variances"},{prop:"titleOrder",attr:"title-order"},{prop:"titleOrderDirection",attr:"title-order-direction"},{prop:"ruleset",attr:"ruleset"}];for(const{prop:i,attr:s}of t){const t=this.resolveInherited(i,this[i]);void 0!==t&&this.element.setAttribute(s,t)}}prepareTitleImage(t){if(null==t||""===t)return"";const i=this.stores.assets.state;return t.startsWith("asset:")?i[t.substring(6)]:i[t]||t}render(){var t,s,e,n,r;const a=this.getLayoutStyle(),h=this.extractSlotNames(a["grid-template-areas"]);return i("bn-card",{key:"fd78ac2ccd6742b6be6e726f90aa64ede009cc6f",styles:this.styles,"selected-style":this.selectedStyle,class:this.setCardClass()},i("div",{key:"7089fae2d8cb7f4cc193ded4ab371af706971476",class:"cardtitle"},i("bn-title",{key:"ddafc110dfc6c41995c88e671401c92d6a281beb",namespace:this.titleNamespace,ruleset:null!==(t=this.resolveInherited("ruleset",this.ruleset))&&void 0!==t?t:this.ruleset,"business-unit":this.titleBusinessUnit,scenarios:null!==(s=this.resolveInherited("titleScenarios",this.titleScenarios))&&void 0!==s?s:this.titleScenarios,variances:null!==(e=this.resolveInherited("titleVariances",this.titleVariances))&&void 0!==e?e:this.titleVariances,order:null!==(n=this.resolveInherited("titleOrder",this.titleOrder))&&void 0!==n?n:this.titleOrder,"order-direction":null!==(r=this.resolveInherited("titleOrderDirection",this.titleOrderDirection))&&void 0!==r?r:this.titleOrderDirection,measures:this.titleMeasures,"date-start":this.titleDateStart,"date-end":this.titleDateEnd,"date-format":this.titleDateFormat,"date-link":this.titleDateLink}),null!=this.titleImage&&""!==this.titleImage?i("img",{class:"image",src:this.prepareTitleImage(this.titleImage)}):""),i("bn-body",{key:"472abe3e7640d7735d0b15b88ec0c3036d1862a1"},i("div",{key:"e9e1970e093f3f9a00707a5b8bf5e6624b53974a",style:a,"data-bn-fit-content":this.cardFitToContent?String(this.getRowCount(this.cardLayout)):null},this.getSlots(h))),i("bn-footer",{key:"2562532b8916d6316c019d93e2eab6e27fdca031",text:this.footerText,"page-number":0,"display-page-number":"false"}))}get element(){return e(this)}};Ni.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden}.cardtitle{display:inline-flex}::slotted(*){flex:1 1 auto;min-width:0}.image{margin-right:0.5em;margin-top:0.5em;z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}';const Ui=class{constructor(i){t(this,i),this.messageText="",this.messageImage="",this.titleBusinessUnit="",this.titleOrder="category",this.titleOrderDirection="asc",this.titleDateFormat="none",this.titleDateLink="none",this.titleNamespace="_system",this.footerDisplayPageNumber=!0,this.pageLayout="full",this.pageCustomTemplate='"a b" "c d"',this.pageGridGap="0",this.pageFitToContent=!1,this.templateMap=new Map([["split-vertical",'"a b"'],["split-horizontal",'"a" "b"'],["2x2",'"a b" "c d"'],["3x3",'"a b c" "d e f" "g h i"'],["4x4",'"a b c d" "e f g h" "i j k l" "m n o p"'],["1-over-2",'"a a" "b c"'],["2-over-1",'"a b" "c c"'],["1-over-3",'"a a a " "b c d"'],["3-over-1",'"a b c" "d d d"'],["custom-template",'"a b" "c c c"'],["gold3",'"a c" "b c"'],["gold4",'"a b c c" "d d c c"']]),this.errors=l(this)}getCommonStyles(){let t="100%";return!0===this.pageFitToContent&&(t="fit-content"),{display:"grid",height:t,width:"100%",gap:this.pageGridGap+"px"}}getRowCount(t){const i=this.getTemplateAreas(t).match(/"[\w\d\s.]+"/g);return i?i.length:1}getGridTemplateRows(t){const i=this.getRowCount(t);return this.pageFitToContent?Array(i).fill("auto").join(" "):Array(i).fill("minmax(0, 1fr)").join(" ")}getLayoutStyle(){return Object.assign(Object.assign({},this.getCommonStyles()),{"grid-template-areas":this.getTemplateAreas(this.pageLayout),"grid-template-columns":this.getGridTemplateColumns(this.pageLayout),"grid-template-rows":this.getGridTemplateRows(this.pageLayout)})}createDivAreaStyles(t){return t.map((t=>({display:"flex",overflow:"hidden","grid-area":t})))}getSlots(t){const s=this.createDivAreaStyles(t);return i(h,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"slot-"+s})))))}extractSlotNames(t){if(null==t)return[];const i=t.match(/\b\w+\b/g);return i?Array.from(new Set(i)):[]}getTemplateAreas(t){return!1===this.templateMap.has(t)&&"custom-template"!==t?'"a"':"custom-template"===t?this.pageCustomTemplate:this.templateMap.get(t)}calculateFractions(t){const i=t.trim().split(/\s+/).length;return 0===i?"minmax(0, 1fr)":Array(i).fill("minmax(0, 1fr)").join(" ")}getGridTemplateColumns(t){if(!1===this.templateMap.has(t)&&"custom-template"!==t)return"1fr";let i;i="custom-template"===t?this.pageCustomTemplate:this.templateMap.get(t);const s=i.match(/"[\w\d\s.]+"/g);return this.calculateFractions(s[0])}async getNumberOfSlot(t){const i=this.getTemplateAreas(t);return this.extractSlotNames(i).length}componentDidUpdate(){const t=this.element.closest("bn-context").getAttribute("render-orientation");if(t&&t!==this.pageOrientation){const t=this.element.shadowRoot.querySelector("bn-page"),i=this.element.closest("bn-layout-page");i&&t&&(t.style.transform="rotate(-90deg) translate(-100%)",t.style.transformOrigin="top left",i.style.width=`${t.clientHeight}px`,i.style.height=`${t.clientWidth}px`)}}render(){const t=this.getLayoutStyle(),s=this.extractSlotNames(t["grid-template-areas"]);return i("bn-page",{key:"c07ff4c3b0d39b1afa36b6bdd015ee4c88c22404",styles:this.styles,"selected-style":this.selectedStyle,format:this.pageFormat,orientation:this.pageOrientation},i("bn-message",{key:"e65c9d9f97f1ce63ebcf5c255b7b1c9457fb72c4",text:this.messageText,image:this.messageImage}),i("bn-title",{key:"c69cf9dce72afe3f23c5642d80287926e443e7e1",namespace:this.titleNamespace,ruleset:this.ruleset,"business-unit":this.titleBusinessUnit,scenarios:this.titleScenarios,variances:this.titleVariances,order:this.titleOrder,"order-direction":this.titleOrderDirection,measures:this.titleMeasures,"date-start":this.titleDateStart,"date-end":this.titleDateEnd,"date-format":this.titleDateFormat,"date-link":this.titleDateLink}),i("bn-body",{key:"c5ef984f19253a42464e81eb5c70037f3b1ed111"},i("div",{key:"5a54ccdc4d8e221f45cee1a4e43cf0b388818ce3",style:t,"data-bn-fit-content":this.pageFitToContent?String(this.getRowCount(this.pageLayout)):null},this.getSlots(s))),i("bn-footer",{key:"41ad417476586a1f40aa838d96d08a8336d04a93",text:this.footerText,"page-number":this.pageNumber,"display-page-number":this.footerDisplayPageNumber}))}get element(){return e(this)}};Ui.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:block;overflow:hidden}::slotted(*){flex:1 1 auto;min-width:0}';const Di=class{constructor(i){t(this,i),o(this),this.errors=l(this),this.componentStyle=b(this)}connectedCallback(){this.stores=d(this.element)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}prepareAssetUrl(t){if(null==t||""===t)return"";const i=this.stores.assets.state;return t.startsWith("asset:")?i[t.substring(6)]:i[t]||t}render(){return i(s,{key:"83f39ae717c41c0861dc593bf732a81a82635ac1",id:this.text||this.image?"container-page-message":"container",style:this.getFontStyles()},i("div",{key:"bd76f6bb557d9312092f116ab0aaaa950e505acf",id:"message-text"},null!=this.text&&""!==this.text?i("span",{class:"note",innerHTML:zt(this.text)}):""),i("div",{key:"de1e14e4115f76a00b64994e7b6dbec7c75b4ea5",id:"page-image"},null!=this.image&&""!==this.image?i("img",{class:"image",src:this.prepareAssetUrl(this.image)}):""))}static get assetsDirs(){return["assets"]}get element(){return e(this)}};Di.style=':host{padding:0.2em 0.5em;display:flex;flex-direction:row;justify-content:space-between;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(#container-page-message){min-height:4.55em;box-sizing:border-box;-webkit-box-sizing:border-box;border-bottom:0.1em solid #ddd}div#message-text{font-size:1.4em;overflow:clip;display:inline}span.note p{margin:0}.image{z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:block}';const Gi=["xga","hd","full-hd","4k","4k2k","a4","a3","a2","a1","a0","letter","legal"],Wi=["landscape","portrait"],Fi=class{constructor(i){t(this,i),o(this),this.errors=l(this),this.componentStyle=b(this)}validateFormat(t){const i="ERR_format";L(t)||Gi.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`format: invalid value '${t}' is not supported. Valid values: ${Gi.join(", ")}`})}validateOrientation(t){const i="ERR_orientation";L(t)||Wi.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`orientation: invalid value '${t}' is not supported. Valid values: ${Wi.join(", ")}`})}render(){return i(s,{key:"7623fe9a67534d467f10d7ad25afb201e895110f",format:this.format,orientation:this.orientation,style:this.prepareStyle()},i("slot",{key:"8a2e3cce4449d2ce5ce898aff45ca8b4b903ab6c"}))}prepareStyle(){return{"font-family":this.componentStyle((t=>t.global.fontFamily)),"font-size":`${this.componentStyle((t=>t.global.fontSizePx))}px`,"--bn-font-family":this.componentStyle((t=>t.global.fontFamily))||"'Noto Sans', sans-serif","--bn-font-size":`${this.componentStyle((t=>t.global.fontSizePx))||13.3333}px`,"--bn-font-color":this.componentStyle((t=>t.global.fontColor))||"#000000","--bn-font-background":this.componentStyle((t=>t.global.fontBackgroundColor))||"#ffffff"}}get element(){return e(this)}static get watchers(){return{format:[{validateFormat:0}],orientation:[{validateOrientation:0}]}}};Fi.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);height:768px;width:1024px;display:flex;flex-direction:column;page-break-after:always;overflow:hidden}:host([format=xga]){height:768px;width:1024px}:host([format=xga][orientation=portrait]){height:1024px;width:768px}:host([format=xga][orientation=landscape]){height:768px;width:1024px}:host([format=hd]){height:720px;width:1280px}:host([format=hd][orientation=portrait]){height:1280px;width:720px}:host([format=hd][orientation=landscape]){height:720px;width:1280px}:host([format=full_hd]){height:1080px;width:1920px}:host([format=full_hd][orientation=portrait]){height:1920px;width:1080px}:host([format=full_hd][orientation=landscape]){height:1080px;width:1920px}:host([format="4k"]){height:2160px;width:3840px}:host([format="4k"][orientation=portrait]){height:3840px;width:2160px}:host([format="4k"][orientation=landscape]){height:2160px;width:3840px}:host([format="4k2k"]){height:2160px;width:4096px}:host([format="4k2k"][orientation=portrait]){height:4096px;width:2160px}:host([format="4k2k"][orientation=landscape]){height:2160px;width:4096px}:host([format=a6]){height:5.83in;width:4.13in}:host([format=a6][orientation=portrait]){height:5.83in;width:4.13in}:host([format=a6][orientation=landscape]){height:4.13in;width:5.83in}:host([format=a5]){height:8.27in;width:5.83in}:host([format=a5][orientation=portrait]){height:8.27in;width:5.83in}:host([format=a5][orientation=landscape]){height:5.83in;width:8.27in}:host([format=a4]){height:11.6in;width:8.17in}:host([format=a4][orientation=portrait]){height:11.6in;width:8.17in}:host([format=a4][orientation=landscape]){height:8.17in;width:11.6in}:host([format=a3]){height:16.54in;width:11.7in}:host([format=a3][orientation=portrait]){height:16.54in;width:11.7in}:host([format=a3][orientation=landscape]){height:11.7in;width:16.54in}:host([format=a2]){height:23.4in;width:16.54in}:host([format=a2][orientation=portrait]){height:23.4in;width:16.54in}:host([format=a2][orientation=landscape]){height:16.54in;width:23.4in}:host([format=a1]){height:33.1in;width:23.4in}:host([format=a1][orientation=portrait]){height:33.1in;width:23.4in}:host([format=a1][orientation=landscape]){height:23.4in;width:33.1in}:host([format=a0]){height:46.8in;width:33.1in}:host([format=a0][orientation=portrait]){height:46.8in;width:33.1in}:host([format=a0][orientation=landscape]){height:33.1in;width:46.8in}:host([format=letter]){height:11in;width:8.5in}:host([format=letter][orientation=portrait]){height:11in;width:8.5in}:host([format=letter][orientation=landscape]){height:8.5in;width:11in}:host([format=legal]){height:14in;width:8.5in}:host([format=legal][orientation=portrait]){height:14in;width:8.5in}:host([format=legal][orientation=landscape]){height:8.5in;width:14in}:host([format=tabloid]){height:17in;width:11in}:host([format=tabloid][orientation=portrait]){height:17in;width:11in}:host([format=tabloid][orientation=landscape]){height:11in;width:17in}:host([format=ledger]){height:11in;width:17in}:host([format=ledger][orientation=portrait]){height:17in;width:11in}:host([format=ledger][orientation=landscape]){height:11in;width:17in}';const Yi=class{constructor(i){t(this,i),o(this),this.errors=l(this)}connectedCallback(){this.stores=d(this.element),this.pushToStore()}onNameChange(t,i){i&&i!==t&&this.stores&&this.stores.scalingGroups.state[i]===this.value&&this.stores.scalingGroups.set(i,void 0),this.pushToStore()}onValueChange(){this.pushToStore()}pushToStore(){var t;if(!this.stores)return;const i=null===(t=this.name)||void 0===t?void 0:t.toString().trim();"auto"!==(null==i?void 0:i.toLowerCase())?(this.errors.remove("ERR_reserved_name"),i?(this.errors.remove("ERR_empty_name"),this.stores.scalingGroups.set(i,this.value)):this.errors.addOrReplace({id:"ERR_empty_name",type:"warning",message:"bn-scaling-group: name is required."})):this.errors.addOrReplace({id:"ERR_reserved_name",type:"warning",message:'bn-scaling-group: name "auto" is reserved and cannot be used.'})}render(){return i(s,{key:"fe1325e81399fceb3ec75c1289d3479f88045baa"})}get element(){return e(this)}static get watchers(){return{name:[{onNameChange:0}],value:[{onValueChange:0}]}}};var Ii,Bi,zi,Hi,Vi;Yi.style="bn-scaling-group{display:none}",function(t){t[t.ALL=-1]="ALL"}(Ii||(Ii={})),function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Bi||(Bi={})),function(t){t.LIST="list",t.SUM="sum",t.SUMNOTOTAL="sumnototal",t.OPT="opt",t.OPTNOTOTAL="optnototal"}(zi||(zi={})),function(t){t.ASC="asc",t.DESC="desc"}(Hi||(Hi={})),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"}(Vi||(Vi={}));const ji="none",Xi="setname";function Ji(t){return t===Xi?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function qi(t){if(null==t)return"";if("string"==typeof t)return t.trim();const i=Ki(t);return i?i.toISO():String(t)}function Ki(t){if(null!=t){if("string"==typeof t){const i=v.fromISO(t);return i.isValid?i:void 0}if("number"==typeof t){const i=v.fromMillis(t);return i.isValid?i:void 0}if("boolean"==typeof t.isValid)return t.isValid?t:void 0}}const Zi=class{validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}constructor(i){t(this,i),this.layoutObserver=null,this._lastScaledParentWidth=0,this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.hasBlankSetnames=!1,this.sumTitle="",this.filter="",this.measureUnit="",this.barColumnWidth="w10",this.unitScaling=.01,this.percentageScaling=.5,this.pixelPerUnitGroupMap=new Map,this.dataFormat="decimal",this.grouped="false",this.showMeasureScale="false",this.showGroupTitle="true",this.type="list",this.limit=0,this.thereof="[]",this.partof="[]",this.order="category",this.orderDirection="asc",this.measureType="volume",this.measureScale="greatest",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.categoryWidth="w15",this.columnthereof=null,this.interval="none",this.tableAttributes="",this._autoScaleGuard=!1,E(this),o(this),this.errors=l(this),rt(this),this.componentStyle=b(this),this.ruleSetConfig=ht(this),it(this,((t,i)=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1,this.hasBlankSetnames=Array.isArray(i)&&i.some((t=>{var i;return L(null!==(i=null==t?void 0:t.setname)&&void 0!==i?i:null==t?void 0:t.setName)}))}),((t,i)=>{this.datasetMeta=i})),this.t=st(this).t,this.resolveInherited=ot(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}validateScenario(t){const i="ERR_scenarios";if(at(t))return void this.errors.remove(i);const s=w(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(at(t))return void this.errors.remove(i);const s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateBarColumns(t){const i="ERR_barColumns";if(L(t))return void this.errors.remove(i);const s=G(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="ERR_barColumnWidth";W(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"barColumnWidth: invalid value '"+t+"' is not supported."})}validateUnitScaling(t){const i="ERR_unitScaling";"auto"===(null==t?void 0:t.toString().trim().toLowerCase())||S(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value '"+t+"' is not supported."})}validatePercentageScaling(t){const i="ERR_percentageScaling";"auto"===(null==t?void 0:t.toString().trim().toLowerCase())||S(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value '"+t+"' is not supported."})}validateDataFormat(t){const i="ERR_dataFormat";F(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateGrouped(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"grouped: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowGroupTitle(t){const i="ERR_showGroupTitle";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showGroupTitle: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateType(t){const i="ERR_type";Y(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateLimit(t){const i="ERR_limit";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateThereOf(t){const i="ERR_thereof",s=I(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validatePartOf(t){const i="ERR_partof",s=B(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="ERR_order";if(at(t))return void this.errors.remove(i);const s=$(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";at(t)||R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureType(t){const i="ERR_measureType";z(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureScale(t){const i="ERR_measureScale";_(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDataFormatDigitsDecimal(t){const i="ERR_dataFormatDigitsDecimal";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsDecimal: invalid value(s) '"+t+"' are not supported."})}validateDateFormatDigitsPercent(t){const i="ERR_dataFormatDigitsPercent";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsPercent: invalid value(s) '"+t+"' are not supported."})}validateCategoryWidth(t){const i="ERR_categoryWidth";H(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryWidth: invalid value(s) '"+t+"' are not supported."})}validateColumnThereOf(t){const i=V(t),s="ERR_categorythereof";i.length>0?this.errors.addOrReplace({id:s,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(s)}validateInterval(t){const i="ERR_interval",s=null==t?void 0:t.trim().toLowerCase();L(t)||s===ji||s===Xi||A(s)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"interval: invalid value '"+t+"' is not supported."})}validateTableAttributes(t){const i="ERR_attributes",s=j(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"attributes: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateDataFormat(this.dataFormat),this.validateGrouped(this.grouped),this.validateShowGroupTitle(this.showGroupTitle),this.validateType(this.type),this.validateLimit(this.limit),this.validateThereOf(this.thereof),this.validatePartOf(this.partof),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDateFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateCategoryWidth(this.categoryWidth),this.validateMeasureType(this.measureType),this.validateMeasureScale(this.measureScale),this.validateColumnThereOf(this.columnthereof),this.validateInterval(this.interval),this.validateTableAttributes(this.tableAttributes),this.validateShowMeasureScale(this.showMeasureScale),this.validateBarColumns(this.barColumns),this.validateBarColumnWidth(this.barColumnWidth),this.validateUnitScaling(this.unitScaling),this.validatePercentageScaling(this.percentageScaling),this.validateScaling(this.scale)}componentDidLoad(){this.layoutObserver=lt(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=et(this.element);t>0&&Math.abs(t-this._lastScaledParentWidth)>2&&(this._lastScaledParentWidth=t,r(this))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}componentDidRender(){const{mode:t}=nt(this.scale);if("auto"!==t&&"empty"!==t)return void(this._autoScaleGuard=!1);if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const i=this.element,{width:s}=et(i);if(s<=0)return;this._lastScaledParentWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,a=this.appliedScaleFactor;if(r<=s+1)return void this.errors.remove("AUTO_scale");const h=Math.max(.3,a*(s-1)/r);Math.abs(h-a)<.001||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled table by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,n((()=>{this.appliedScaleFactor=h})))}prepareDataFormat(){var t;return gt[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return"true"===this.grouped}prepareShowGroupTitle(){return"true"===this.showGroupTitle}prepareTableType(){var t;return zi[null===(t=this.type)||void 0===t?void 0:t.toUpperCase()]}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareThereOf(){return null==this.thereof||""===this.thereof.trim()?[]:JSON.parse(this.thereof)}preparePartOf(){return null==this.partof||""===this.partof.trim()?[]:JSON.parse(this.partof)}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),s=this.resolveInherited("orderDirection",this.orderDirection),e=null!=i?i:this.order,n=null!=s?s:this.orderDirection,r="auto"===(null==e?void 0:e.trim().toLowerCase());let a=e;return r&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(a=this.datasetMeta.suggestedOrder),{hierarchy:a.split(",").map((t=>P[null==t?void 0:t.toUpperCase()])),direction:T[null==n?void 0:n.toUpperCase()]}}prepareI18nMode(){return mt.META}prepareI18n(){const t=u,i=new Map(["in","category","operation","there_of","part_of","SUM_TOTAL"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,s,e,n,r,a,h,o;const l=this.resolveInherited("scenarios",this.scenarios),c=this.resolveInherited("variances",this.variances);if(void 0!==l||void 0!==c){this.errors.remove("AUTO_scenarios");let i=[];return void 0!==l?i=i.concat(l.split(",")):L(this.scenarios)||(i=i.concat(this.scenarios.split(","))),void 0!==c?i=i.concat(c.split(",")):(null===(t=this.variances)||void 0===t?void 0:t.trim().length)>0&&(i=i.concat(this.variances.split(","))),i.map((t=>t.trim()))}const d="auto"===(null===(i=this.scenarios)||void 0===i?void 0:i.trim().toLowerCase());if((L(this.scenarios)||d)&&L(this.variances))return(null===(e=null===(s=this.datasetMeta)||void 0===s?void 0:s.availableScenarios)||void 0===e?void 0:e.length)>0?(d?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[];let u=[];return d||L(this.scenarios)?(null===(r=null===(n=this.datasetMeta)||void 0===n?void 0:n.availableScenarios)||void 0===r?void 0:r.length)>0&&(d?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),u=u.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),u=u.concat(null===(a=this.scenarios)||void 0===a?void 0:a.split(","))),(null===(h=this.variances)||void 0===h?void 0:h.trim().length)>0&&(u=u.concat(null===(o=this.variances)||void 0===o?void 0:o.split(","))),u.map((t=>t.trim()))}prepareCategoryWidth(){var t;return L(this.categoryWidth)?bt.INF:bt[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}prepareMeasureScale(){return L(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareMeasureType(){var t;return L(this.measureType)?wt.VOLUME:wt[null===(t=this.measureType)||void 0===t?void 0:t.toUpperCase()]}prepareColumnThereOf(){if(null==this.columnthereof||""===this.columnthereof.trim())return new Map;const t=JSON.parse(this.columnthereof),i=new Map;for(const[s,e]of Object.entries(t))!1===i.has(e.scenario)&&i.set(e.scenario,[]),i.get(e.scenario).push(e);return i}prepareInterval(){var t;const i="ERR_intervalConflict",s="ERR_intervalNoDate",e="ERR_intervalSetname",n=L(this.interval)?ji:this.interval.trim().toLowerCase();return n!==ji&&n!==Xi&&!A(n)||n===ji?(this.errors.remove(i),this.errors.remove(s),this.errors.remove(e),ji):null!=this.columnthereof&&""!==this.columnthereof.trim()?(this.errors.addOrReplace({id:i,type:"warning",message:"interval: cannot be combined with columnthereof, interval is ignored."}),this.errors.remove(s),this.errors.remove(e),ji):(this.errors.remove(i),n===Xi?(this.hasBlankSetnames?this.errors.addOrReplace({id:e,type:"warning",message:"interval: rows with blank setname found, they are grouped under '—'."}):this.errors.remove(e),this.errors.remove(s),Xi):(this.errors.remove(e),this.datasetMeta&&!(null===(t=this.datasetMeta.dateRange)||void 0===t?void 0:t.hasData)?(this.errors.addOrReplace({id:s,type:"warning",message:"interval: dataset has no date values, interval is ignored."}),ji):(this.errors.remove(s),n)))}prepareAttributes(){if(null==this.tableAttributes||""===this.tableAttributes.trim())return[];try{const t=JSON.parse(this.tableAttributes);return null===t||"object"!=typeof t||t instanceof Array?[]:Object.entries(t).map((([t,i],s)=>"string"==typeof i?X(t,`attr_${s}`,i):null)).filter((t=>null!==t))}catch(t){return[]}}prepareSumTitle(){return""===this.sumTitle||null==this.sumTitle?"SUM_TOTAL":this.sumTitle}prepareShowMeasureScale(){return"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareBarColumnWidth(){var t;const i=null===(t=this.barColumnWidth)||void 0===t?void 0:t.toUpperCase(),s=St[i];return s?yt[s]:yt[St.W10]}prepareBarColumns(){return L(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){var t;return this.pixelPerUnitGroupMap.has(this.unitScaling)?this.pixelPerUnitGroupMap.get(this.unitScaling):"auto"===(null===(t=this.unitScaling)||void 0===t?void 0:t.toString().trim().toLowerCase())?0:Number(this.unitScaling)}preparePercentageScaling(){var t;return this.pixelPerUnitGroupMap.has(this.percentageScaling)?this.pixelPerUnitGroupMap.get(this.percentageScaling):"auto"===(null===(t=this.percentageScaling)||void 0===t?void 0:t.toString().trim().toLowerCase())?0:Number(this.percentageScaling)}getDataStructure(){return{ITableDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}getEffectiveScaleFactor(){const{mode:t,factor:i}=nt(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const a=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":a*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),e=this.getEffectiveScaleFactor();return i(s,{key:"c17878caebdbc1921880dfb1f784f553b9522108",style:t},i("div",{key:"58babcce2a4fc3892609e86b8c7ce3b44286311f"},i("ibcs-table",{key:"27cc8a7bef5b641943311af29d819dc7e10089cf",tableName:this.datasetName,dataVersion:this.dataVersion,sumTitle:this.prepareSumTitle(),scenarios:this.prepareScenarios(),scenariosDataFormat:this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),thereof:this.prepareThereOf(),partof:this.preparePartOf(),order:this.prepareOrder(),categorythereof:this.prepareColumnThereOf(),attributeColumns:this.prepareAttributes(),type:this.prepareTableType(),categoryWidth:this.prepareCategoryWidth(),dataFormatDigits:this.prepareDataFormatDigits(),i18n:this.prepareI18n(),i18nMode:this.prepareI18nMode(),measureScale:this.prepareMeasureScale(),measureType:this.prepareMeasureType(),measureUnit:this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(),filter:this.prepareFilter(),barColumns:this.prepareBarColumns(),interval:this.prepareInterval(),barColumnMaxWidth:this.prepareBarColumnWidth(),unitScaling:this.prepareUnitScaling(),percentageScaling:this.preparePercentageScaling(),scaleFactor:e,ruleSetConfig:this.ruleSetConfig()})))}get element(){return e(this)}static get watchers(){return{scale:[{validateScaling:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],grouped:[{validateGrouped:0}],showMeasureScale:[{validateShowMeasureScale:0}],showGroupTitle:[{validateShowGroupTitle:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],tableAttributes:[{validateTableAttributes:0}]}}};Zi.style=":host{display:inline-block;position:relative;overflow:hidden}";const Qi=class{constructor(i){t(this,i),this.businessUnit="",this.order="category",this.orderDirection="asc",this.dateFormat="none",this.dateLink="none",E(this),o(this),this.t=st(this).t,this.errors=l(this),this.componentStyle=b(this),this.ruleSetConfig=ht(this)}validateScenario(t){const i="ERR_scenarios",s=w(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances",s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateOrder(t){const i=$(t),s="ERR_order";i.length>0?this.errors.addOrReplace({id:s,type:"warning",message:"order: invalid value(s) '"+(null==i?void 0:i.toString())+"' are not supported."}):this.errors.remove(s)}validateOrderDirection(t){const i="ERR_orderDirection";R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasures(t){const i="ERR_measures",s=J(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"measures: invalid value(s) '"+(null==s?void 0:s.toString())+'\' are not supported. Valid format example: [{"name": "Bruttoumsatz", "unit": "mEUR"}]'}):this.errors.remove(i)}validateDateStart(t){const i="ERR_dateStart";q(t)||L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateEnd(t){const i="ERR_dateEnd";q(t)||L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateFormat(t){const i="ERR_dateFormat";A(t)||L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateFormat: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateLink(t){const i="ERR_dateLink";K(t)||L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateLink: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateMeasures(this.measures),this.validateDateStart(this.dateStart),this.validateDateEnd(this.dateEnd),this.validateDateFormat(this.dateFormat),this.validateDateLink(this.dateLink),this.validateOrderDirection(this.orderDirection),this.validateOrder(this.order)}prepareI18n(){const t=u,i=new Map(["SEPERATOR_WS","in","CONNECTOR_WS"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}prepareI18nMode(){return mt.META}prepareTitleOrder(){var t;return L(this.order)||L(this.orderDirection)?null:{hierarchy:this.order.split(",").map((t=>t.trim())),direction:T[null===(t=this.orderDirection)||void 0===t?void 0:t.toUpperCase()]}}prepareTitleTimePeriod(){var t,i;return L(this.dateStart)&&L(this.dateEnd)||L(this.dateLink)?null:{start:v.fromISO(this.dateStart),end:v.fromISO(this.dateEnd),format:N[null===(t=this.dateFormat)||void 0===t?void 0:t.toUpperCase()],link:Z[null===(i=this.dateLink)||void 0===i?void 0:i.toUpperCase()]}}prepareMeasures(){return L(this.measures)?[]:JSON.parse(this.measures)}prepareScenarios(){var t,i,s,e;if(L(this.scenarios)&&L(this.variances))return[];let n=[];return(null===(t=this.scenarios)||void 0===t?void 0:t.trim().length)>0&&(n=n.concat(null===(i=this.scenarios)||void 0===i?void 0:i.split(","))),(null===(s=this.variances)||void 0===s?void 0:s.trim().length)>0&&(n=n.concat(null===(e=this.variances)||void 0===e?void 0:e.split(","))),n.map((t=>t.trim()))}prepareBusinessUnit(){return L(this.businessUnit)||"null"===this.businessUnit?null:this.businessUnit}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return i(s,{key:"4f64c957500d566f6ff3d3abe88e77d956f997de",style:t},i("ibcs-title",{key:"ee6c785ae9f0d9a703a4a05c063ff02f1595da64",businessUnit:this.prepareBusinessUnit(),scenarios:this.prepareScenarios(),measures:this.prepareMeasures(),timeperiod:this.prepareTitleTimePeriod(),order:this.prepareTitleOrder(),i18n:this.prepareI18n(),"i18n-mode":this.prepareI18nMode(),ruleSetConfig:this.ruleSetConfig()}))}get element(){return e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],measures:[{validateMeasures:0}],dateStart:[{validateDateStart:0}],dateEnd:[{validateDateEnd:0}],dateFormat:[{validateDateFormat:0}],dateLink:[{validateDateLink:0}]}}};Qi.style=':host{padding:0.5em;margin-bottom:0.5em;box-sizing:border-box;-webkit-box-sizing:border-box;width:100%;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}';let ts=class{constructor(t,i,s,e,n,r,a,h,o=!1){this.categoryPosition={x:0,y:0},this.spacings={scenarioOffset:0,markerOffset:0,scenarioLabelToBar:0,labelToBar:0,labelToAxis:0,needleWidth:0,needleHeadWidth:0,barWidth:0,varianceAxisLineWidth:0,axisLineWidth:0,auxiliaryLineWidth:0,scenarioLineWidth:0,markerWidth:0,categoryWidth:0,axisTickLength:0},this.categoriesBoxOffset={width:0,height:0},this.padding=t,this.scaleFactors=i,this.fontSize=s,this.axisPosition={x:0,y:0},this.numberOfColumns=e,this.leftSideLengthSync=n,this.topSideLabelHeight=r>0?this.fontSize:0,this.hasStackedHeaders=o,this.leftSideLabelLength=this.calculateSideLabelLength(r,a,h),this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}getBarPositionX(){return this.axisPosition.x}getBarCenterPositionY(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth}getBarPositionY(t,i){return i?this.getBarCenterPositionY(t):this.getBarCenterPositionY(t)-this.spacings.scenarioOffset}getCategoryPositionX(t){let i=this.spacings.labelToAxis;return t&&(i=-this.spacings.labelToAxis),this.getAxisPositionX()+i}getAxisTitlePositionX(){return this.axisPosition.x}getAxisTitlePositionY(){return this.axisPosition.y-this.spacings.labelToAxis-this.getTopLabelOverhang()}getStackedHeaderPositionY(){return this.getBarCenterPositionY(0)-.5*this.spacings.barWidth-this.spacings.scenarioLabelToBar}getNeedleWidth(){return this.spacings.needleWidth}getAxisPositionX(){return this.leftSideLabelLength+this.padding.left+this.spacings.labelToAxis}getAxisPositionY(){return this.padding.top+this.getAxisTitleOffset()}loadCategoriesBox(t){this.categoriesBoxOffset=t,this.calculateAxisPosition()}addOffsetByNegativeDataPoints(t,i,s,e){null!=t&&null!=t.value&&t.value<0&&(s&&t.isClipped()?this.axisPosition.x+=Math.abs(t.getClippedValue()*t.pixelPerUnit):this.axisPosition.x+=Math.abs(t.value*t.pixelPerUnit),this.axisPosition.x+=i,this.axisPosition.x+=this.spacings.labelToBar),this.axisPosition.x<e/2&&(this.axisPosition.x=e/2+this.spacings.labelToBar)}getLabelPositionX(t){let i=this.spacings.labelToBar;return t<0&&(i*=-1),this.axisPosition.x+t+i}getLabelPositionY(t){return this.axisPosition.y+t+this.spacings.labelToBar}getCategoryToAxisSpaceing(){return this.spacings.labelToAxis}getCategoryToTopSpaceing(){return this.spacings.scenarioOffset}getCategoryToBottomSpaceing(){return this.spacings.scenarioOffset}getAxisEndPositionY(){return this.getAxisPositionY()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getScenarioLabelPositionOffsetY(t){if(t){const t=.5*this.getBarWidth()+this.spacings.scenarioLabelToBar;return Math.max(t,this.spacings.categoryWidth-this.spacings.scenarioOffset+this.spacings.labelToAxis)}return-(.5*this.getBarWidth()+this.spacings.scenarioLabelToBar)}getBarWidth(){return this.spacings.barWidth}getMarkerPositionY(t,i){return i?this.getBarCenterPositionY(t)-this.spacings.markerOffset-.5*this.getBarWidth():this.getBarCenterPositionY(t)+this.spacings.markerOffset+.5*this.getBarWidth()}getMarkerPositionX(){return this.getBarPositionX()}getMarkerScenarioLabelPositionOffsetY(t){return t?-(.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar):this.spacings.scenarioLabelToBar+.5*this.spacings.markerWidth}getAxisEndPositionX(){return this.getAxisPositionX()}calculateSpacings(){this.spacings={scenarioOffset:this.fontSize*this.scaleFactors.scenarioOffset,markerOffset:this.fontSize*this.scaleFactors.markerOffset,scenarioLabelToBar:this.fontSize*this.scaleFactors.scenarioLabelToBar,labelToBar:this.fontSize*this.scaleFactors.labelToBar,labelToAxis:this.fontSize*this.scaleFactors.labelToAxis,needleWidth:this.fontSize*this.scaleFactors.needleWidth,needleHeadWidth:this.fontSize*this.scaleFactors.needleHeadWidth,barWidth:this.fontSize*this.scaleFactors.barWidth,varianceAxisLineWidth:this.fontSize*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontSize*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontSize*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontSize*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontSize*this.scaleFactors.markerWidth,categoryWidth:this.fontSize*this.scaleFactors.categoryWidth,axisTickLength:this.fontSize*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left,y:this.getAxisPositionY()+.5*this.spacings.categoryWidth}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY()}}recalculatePositions(){this.calculateCategoryPosition(),this.calculateAxisPosition()}getAxisTitleOffset(){return this.topSideLabelHeight+this.spacings.labelToAxis+this.getTopLabelOverhang()}getTopLabelOverhang(){return this.hasStackedHeaders?this.getStackedHeaderOverhang():this.getTopScenarioLabelOverhang()}getStackedHeaderOverhang(){return Math.max(0,this.fontSize+this.spacings.scenarioLabelToBar+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}getTopScenarioLabelOverhang(){return Math.max(0,this.fontSize+.5*this.spacings.barWidth+this.spacings.scenarioLabelToBar-.5*this.spacings.categoryWidth,this.fontSize+.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar+this.spacings.markerOffset+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}calculateSideLabelLength(t,i,s){if(this.leftSideLengthSync)return this.leftSideLengthSync;const e=t/2;let n=i;return e>n&&(n=e),s>n&&(n=s),n}},is=class{constructor(t){this.top=t.top,this.bottom=t.bottom,this.left=t.left,this.right=t.right}addBoxTopLeft(t){return this.top+=t.height|this.top,this.left+=t.width|this.top,this}},ss=class{constructor(t){const i=1*t,s=.7*t;this.bgOffset=(i-s)/2,this.markerUp={top:s/2+",0",left:"0,"+s,right:s+","+s},this.markerUpBackground={top:i/2+",0",left:"0,"+i,right:i+","+i},this.markerDown={bottom:s/2+","+s,left:"0,0",right:s+",0"},this.markerDownBackground={bottom:i/2+","+i,left:"0,0",right:i+",0"}}upMarkerPatternStrings(){return{background:this.markerUpBackground.left+" "+this.markerUpBackground.right+" "+this.markerUpBackground.top+" "+this.markerUpBackground.left,foreground:this.markerUp.left+" "+this.markerUp.right+" "+this.markerUp.top+" "+this.markerUp.left,bgOffset:this.bgOffset}}downMarkerPatternStrings(){return{background:this.markerDownBackground.left+" "+this.markerDownBackground.right+" "+this.markerDownBackground.bottom+" "+this.markerDownBackground.left,foreground:this.markerDown.left+" "+this.markerDown.right+" "+this.markerDown.bottom+" "+this.markerDown.left,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t}},es=class{constructor(t){this.container=new xt,this.pattern=this.createFCPattern(this.container.group(),t),this.styles=t;let i=10;null!=t&&null!=t.fontStyles&&t.fontStyles.size&&(i=t.fontStyles.size),this.bgOffset=(1*i-.7*i)/2}createFCPattern(t,i){const s=i;return t.pattern(10,10,(function(t){t.rect(10,10).fill(s.barStyles.fc.fill),t.line(0,5,5,0).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"}),t.line(5,10,10,5).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"})})).id("pattern-structure-fc")}getFCPolygonPattern(){return{background:"",foreground:"",bgOffset:0,pattern:this.pattern}}toString(){return this.container.svg()}};var ns,rs,as;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(ns||(ns={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(rs||(rs={})),function(t){t[t.Y=1e24]="Y",t[t.Z=1e21]="Z",t[t.E=1e18]="E",t[t.P=1e15]="P",t[t.T=1e12]="T",t[t.G=1e9]="G",t[t.M=1e6]="M",t[t.k=1e3]="k",t[t.h=100]="h",t[t.da=10]="da",t[t.d=.1]="d",t[t.c=.01]="c",t[t.m=.001]="m",t[t.my=1e-6]="my",t[t.n=1e-9]="n",t[t.p=1e-12]="p",t[t.f=1e-15]="f",t[t.a=1e-18]="a",t[t.z=1e-21]="z",t[t.y=1e-24]="y"}(as||(as={}));class hs{static calculateMeasureScale(t,i,s,e){var n,r;if("_"===e)return new _t;if(null!=e&&[...this.unitsLeast,...this.unitsGreat].includes(e))return this.lookupPrefix(e);if(0===s.length||!i)return new _t;const a=`SELECT MAX(GREATEST(${s.filter((t=>3===t.length)).map((t=>"ABS("+t+")")).toString()})) as prefixvalue\n FROM ${i}`,h=`SELECT MIN(LEAST(${s.filter((t=>3===t.length)).map((t=>"ABS("+t+")")).toString()})) as prefixvalue\n FROM ${i}`;let o,l=a;"LEAST"===(null==e?void 0:e.toUpperCase())&&(l=h);try{o=null!==(r=null===(n=t.exec(l)[0])||void 0===n?void 0:n.prefixvalue)&&void 0!==r?r:0}catch(t){return console.error("DataAnalyzer: measure-scale query failed",l,t),new _t}return this.determinePrefix(Math.abs(o))}static determinePrefix(t){if(t>=1e3){const i=Math.floor(Math.floor(Math.abs(t)).toString().length/3),s=+Math.pow(1e3,i);return new _t(this.unitsGreat[i-1],s)}if(t<=.001){const i=Math.floor(Math.abs(t).toString().length/3),s=1/Math.pow(1e3,i);return new _t(this.unitsLeast[i-1],s)}return new _t}static lookupPrefix(t){return new _t(t,as[t])}}hs.unitsGreat=["k","M","G","T","P","E","Z","Y"],hs.unitsLeast=["m","my","n","p","P","f","a","z","y"];class os{adapt(t){return Q.adaptDefaultString(t)}default(){return""}}class ls{constructor(t,i){this.data=t,this.scenarios=i,this.variances=[],this.title="",this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.sortOrder=new tt(new os).default(),this.level=ct.CATEGORY,this.filter="",this.measureScale=new _t,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null}}class cs{constructor(t,i,s,e,n,r){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=e,this.db=n,this.fromExpr=r}adapt(t){const i=Q.adaptArray(t.data,this.dataRowAdapter),s=Q.adaptArray(t.scenarios,this.stringAdapter),e=new ls(i,s);return Ot.isArray(t.variances)&&(e.variances=Q.adaptArray(t.variances,this.stringAdapter)),Ot.isString(t.title)&&(e.title=t.title),Ot.isBoolean(t.hideCategories)&&(e.hideCategories=t.hideCategories),Ot.isNumber(t.pixelPerUnit)&&(e.pixelPerUnit=t.pixelPerUnit),Ot.isNumber(t.pixelPerPercentage)&&(e.pixelPerPercentage=t.pixelPerPercentage),Ot.isNumber(t.limit)&&(e.limit=t.limit),Ot.isExisting(t.sortOrder)&&(e.sortOrder=this.orderAdapter.adapt(t.sortOrder)),Ot.isExisting(t.level)&&(e.level=t.level),Ot.isString(t.filter)&&(e.filter=t.filter.trim()),Ot.isExisting(t.measureScale)&&(e.measureScale=hs.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale)),Ot.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),Ot.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),Ot.isExisting(t.dataFormatDigits)&&(e.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),Ot.isExisting(t.stackConfig)&&(e.stackConfig=t.stackConfig),e}default(){return new ls([],[])}}let ds=class{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1,this.variance="neg"===e||e===bs.NEG?bs.NEG:"pos"===e||e===bs.POS?bs.POS:bs.NEU}isEmpty(){return null==this.value||null==this.scenario}getScaledUnit(){return null==this.value?0:this.value*this.pixelPerUnit}getScaledPercentUnit(){return null==this.value?0:Math.abs(this.value)>1.45?this.value>=0?1.45*this.pixelPerUnit:-1.45*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:bs.NEU===this.variance?bs.NEU:bs.POS===this.variance?bs.NEG:bs.POS}isClipped(){return null!=this.value&&Math.abs(this.value)>1.45}getClippedValue(){return 145}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}};class us{constructor(){this.operation="+"}addRowGroup(t,i){this.rowGroup=t,this.rowGroupIndex=i}addCategory(t,i){this.category=t,this.categoryIndex=i}addSubCategory(t,i){this.subCategory=t,this.subCategoryIndex=i}addColumnGroup(t,i){this.columnGroup=t,this.columnGroupIndex=i}addSubColumnGroup(t,i){this.columnSubGroup=t,this.columnSubGroupIndex=i}}class ps{constructor(){}adapt(t){const i=new us;return Ot.isOperator(t.operation)&&(i.operation=t.operation),Ot.isNumber(t.rowGroupIndex)&&Ot.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),Ot.isNumber(t.categoryIndex)&&Ot.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),Ot.isNumber(t.subCategoryIndex)&&Ot.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),Ot.isNumber(t.columnGroupIndex)&&Ot.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),Ot.isNumber(t.columnSubGroupIndex)&&Ot.isString(t.columnSubGroup)&&i.addSubColumnGroup(t.columnSubGroup,t.columnSubGroupIndex),this.setActualValues(t,i),this.setPlanValues(t,i),this.setPreviousPeriodValues(t,i),this.setForecastValues(t,i),i}default(){return new us}setActualValues(t,i){Ot.isNumber(t.ac1)&&(i.ac1=t.ac1),Ot.isNumber(t.ac2)&&(i.ac2=t.ac2),Ot.isNumber(t.ac3)&&(i.ac3=t.ac3),Ot.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){Ot.isNumber(t.pl1)&&(i.pl1=t.pl1),Ot.isNumber(t.pl2)&&(i.pl2=t.pl2),Ot.isNumber(t.pl3)&&(i.pl3=t.pl3),Ot.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){Ot.isNumber(t.pp1)&&(i.pp1=t.pp1),Ot.isNumber(t.pp2)&&(i.pp2=t.pp2),Ot.isNumber(t.pp3)&&(i.pp3=t.pp3),Ot.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){Ot.isNumber(t.fc1)&&(i.fc1=t.fc1),Ot.isNumber(t.fc2)&&(i.fc2=t.fc2),Ot.isNumber(t.fc3)&&(i.fc3=t.fc3),Ot.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class fs{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"]}}class vs{constructor(t,i,s,e,n){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingadapter=n}adapt(t){const i=new fs(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return Ot.isExisting(t)&&(Ot.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),Ot.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),Ot.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),Ot.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),Ot.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),Ot.isExisting(t.padding)&&(i.padding=this.paddingadapter.adapt(t.padding)),Array.isArray(t.stackColors)&&t.stackColors.length>0&&(i.stackColors=t.stackColors),i.pattern=new ss(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new fs(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class gs{constructor(){this.scenarioOffset=.3,this.scenarioLabelToBar=.1,this.labelToBar=.3,this.labelToAxis=.3,this.needleWidth=.3,this.needleHeadWidth=.6,this.barWidth=1.2,this.varianceAxisLineWidth=.3,this.axisLineWidth=.1,this.auxiliaryLineWidth=.1,this.scenarioLineWidth=.2,this.markerWidth=.7,this.markerOffset=0,this.categoryWidth=1.9,this.axisTickLength=.3}}class ms{adapt(t){const i=new gs;return Ot.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),Ot.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),Ot.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),Ot.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),Ot.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),Ot.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),Ot.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),Ot.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),Ot.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),Ot.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),Ot.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),Ot.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),Ot.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),Ot.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),Ot.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new gs}}var bs,ws,ys;!function(t){t.AC1="ac1",t.PP1="pp1",t.FC1="fc1",t.PL1="pl1",t.AC2="ac2",t.PP2="pp2",t.FC2="fc2",t.PL2="pl2",t.AC3="ac3",t.PP3="pp3",t.FC3="fc3",t.PL3="pl3",t.AC4="ac4",t.PP4="pp4",t.FC4="fc4",t.PL4="pl4",t.POS="pos",t.NEG="neg",t.NEU="neu"}(bs||(bs={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(ws||(ws={})),function(t){t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right",t[t.Top=3]="Top",t[t.Bottom=4]="Bottom"}(ys||(ys={}));class Ss{constructor(t,i,s,e,n,r,a,h){this.group=null,this.segmentFillColor=null,this.maxWidth=null,this.ID_SCENARIOLABEL="Label",this.CSS_CATEGORIES="categories",this.x=i,this.y=s,this.value=n,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),e))),this.styles=r,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=a||ys.Top,this.horizontalHookLocation=h||ys.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}setMaxWidth(t){return this.maxWidth=t,this}updateGroup(t){return this.group=t,this}createElementID(t,i){return t+"_"+i+"_"+this.ID_SCENARIOLABEL}draw(t={percent:2,decimal:1},i=new _t){var s;if(this.isEmpty())return this;const e=this.group;let n;const r=this.styles.fontStyles.background||"#ffffff";let a="",h="start";if(!1===Number.isNaN(Number(this.value))){let s=t.percent,e=t.percent,r=1,o="percent";!1===this.isRelativeLabel&&(s=t.decimal,e=t.decimal,r=i.value,o="decimal"),n=Mt.number(Number(this.value),o,s,e,r),Number(this.value)<0&&(h="end"),this.isVarianceLabel&&Number(this.value)>=0&&(a="+")}else n=""+this.value,h="start";const o=e.text(a+n);o.move(this.x,this.y);const l=o.bbox().w,c=o.bbox().h;return null!=this.maxWidth&&l>this.maxWidth?(null===(s=this.group)||void 0===s||s.remove(),this.group=null,this):(this.horizontalHookLocation===ys.Right?(h="end",o.move(o.x()-o.length(),o.y())):this.horizontalHookLocation===ys.Center&&(h="middle",o.move(o.x()-o.length()/2,o.y())),this.verticalHookLocation===ys.Center?o.move(o.x(),o.y()-c/2):this.verticalHookLocation===ys.Bottom&&o.move(o.x(),o.y()-c),o.font({anchor:h}),null!=this.segmentFillColor?o.fill(kt(this.segmentFillColor)):null==e||e.rect(l,.9*c).stroke(r).fill(r).opacity(.7).move(o.x(),o.y()+.1*c).insertBefore(o),this)}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}let Os=class{constructor(t,i,s,e){this.height=0,this.ID_AXIS="axis",this.ID_AXIS_TITLE="axis-title",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.position=i,this.style=e,this.label=new Ss(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,ys.Bottom,ys.Center),this.svgGroup=s.group().id(this.ID_AXIS)}draw(){return this.labelText&&this.label.draw(),this.svgGroup.line(this.position.getAxisPositionX(),this.position.getAxisPositionY(),this.position.getAxisEndPositionX(),this.position.getAxisEndPositionY()).addClass(this.ID_AXIS+"-"+this.convertScenarioType()),this.height=this.svgGroup.height(),this}convertScenarioType(){return void 0===this.scenarioType||null==this.scenarioType?"default":`${this.scenarioType}`.slice(0,2)}};class $s{constructor(t,i,s,e,n,r,a,h=null){if(this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.barGroup=null,this.isVarianceBar=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveWidth=0,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.isPrimaryBar=n,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=h,this.scenarioGroup=r,this.styles=i,null!=r&&(this.barGroup=r.group().id(r.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=ys.Left;s.value<0&&(i=ys.Right),this.dimensions=this.createDimensions(t,s,e,n),this.label=new Ss(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,ys.Center,i),this.scenarioLabel=this.getScenarioLabel(a)}}setAsVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}isRelativeVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToRelativeVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new _t){if(this.isEmpty()||null==this.dataPoint.getScenario())return this;let s=this.barStyles.getSVGStyle(this.dataPoint.getScenario());this.isVarianceBar&&(s=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()));const e=this.convertToSVGStyle(s,"stroke");let n=this.convertToSVGStyle(s,"fill");const r=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=r){const t=this.styles.pattern.get(r);null!=t&&(n=t.pattern)}null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(n,e):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(n).stroke(e).cy(this.dimensions.yPos).x(this.dimensions.xPos)),this.drawBarDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.barGroup||!this.overflowConfig)return;const s=this.position.getBarPositionX(),e=this.position.getBarWidth(),n=this.dimensions.barLength,{breakGap:r}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(n,e).fill(t).stroke(i).x(s-n).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,e).fill(t).stroke(i).x(s-n-r-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-n-r,r)):(this.barGroup.rect(n,e).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,e).fill(t).stroke(i).x(s+n+r).cy(this.dimensions.yPos),this.drawBreakIndicator(s+n,r))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),e=this.dimensions.yPos-s/2,n=t+i/2,r=.35*i,a=s/3;let h=`M ${n-r} ${e}`;for(let t=0;t<3;t++)h+=` L ${n-r-.3*i} ${e+a*(t+.5)} L ${n-r} ${e+a*(t+1)}`;let o=`M ${n+r} ${e}`;for(let t=0;t<3;t++)o+=` L ${n+r+.3*i} ${e+a*(t+.5)} L ${n+r} ${e+a*(t+1)}`;this.barGroup.rect(i,s+2).fill("#ffffff").stroke("none").x(t).cy(this.dimensions.yPos),this.barGroup.path(h).fill("none").stroke({color:"#000000",width:1}),this.barGroup.path(o).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s,e){const n=i.getScaledUnit(),r=Math.abs(n);if(this.overflowConfig&&r>0){const a="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(r>a){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:h,maxOverflow:o}=this.overflowConfig;this.overdriveWidth=o>0?(r-a)/o*h:0;const l=a+i+this.overdriveWidth;return n<0?{clipped:!1,barLength:a,xPos:t.getBarPositionX()-a,yPos:t.getBarPositionY(s,e),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*a,scenarioLabelYPos:t.getBarPositionY(s,e)+t.getScenarioLabelPositionOffsetY(e)}:{clipped:!1,barLength:a,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,e),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*a,scenarioLabelYPos:t.getBarPositionY(s,e)+t.getScenarioLabelPositionOffsetY(e)}}}return n<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()+n,yPos:t.getBarPositionY(s,e),labelXPos:this.position.getLabelPositionX(n),scenarioLabelXPos:this.position.getBarPositionX()-.5*r,scenarioLabelYPos:this.position.getBarPositionY(s,e)+this.position.getScenarioLabelPositionOffsetY(e)}:{clipped:!1,barLength:n,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,e),labelXPos:this.position.getLabelPositionX(n),scenarioLabelXPos:this.position.getBarPositionX()+.5*r,scenarioLabelYPos:this.position.getBarPositionY(s,e)+this.position.getScenarioLabelPositionOffsetY(e)}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceBar||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw()}drawBarDataLabel(t,i=new _t){var s;this.isPrimaryBar&&(null===(s=this.label)||void 0===s||s.draw(t,i))}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getScenarioLabel(t){return new Ss(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,this.isPrimaryBar?ys.Top:ys.Bottom,ys.Center)}}let Rs=class{constructor(t,i,s,e,n,r,a,h,o){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.FALLBACK_COLOUR="#000000",this.scenarioLabel=null,this._defaultMarkerPattern=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.position=t,this.markerGroup=i||null,this.markerPattern=s||this._defaultMarkerPattern,this.styles=n,this.barStyles=n?n.barStyles:null,this.scenario=e,!0!==(null==r?void 0:r.isEmpty())&&(this.hasData=!0,this.dimensions=this.createMarkerDimensions(r,a,o),this.scenarioLabel=this.getScenarioLabel(h,n,o))}createMarkerDimensions(t,i,s){return t.getScaledUnit()<0?{clipped:!1,labelXPos:0,barLength:Math.abs(t.getScaledUnit()),xPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}:{clipped:!1,labelXPos:0,barLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX()+t.getScaledUnit(),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()+t.getScaledUnit(),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}}getScenarioLabel(t,i,s){return null==this.markerGroup?null:new Ss(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?ys.Bottom:ys.Top,ys.Center)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}draw(){if(this.isEmpty())return this;const t=this.convertToSVGStyle(this.barStyles[this.getScenario()],"stroke");let i=this.convertToSVGStyle(this.barStyles[this.getScenario()],"fill");const s=this.barStyles[this.getScenario()];if(null!=s&&s.fillpattern){const t=this.styles.pattern.get(s.fillpattern);null!=t&&(i=t.pattern)}return this.markerGroup.polygon(this.markerPattern.background).fill("#ffffff").cy(this.dimensions.yPos).cx(this.dimensions.xPos),this.markerGroup.polygon(this.markerPattern.foreground).fill(i).stroke(t).cy(this.dimensions.yPos).cx(this.dimensions.xPos),null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(),this}isEmpty(){return!1===this.hasData}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}},Ms=class{constructor(t,i,s,e,n){if(this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=n,this.styles=i,this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0,this.dimensions=this.createDimensions(t,s,e);let i=ys.Left;s.value<0&&(i=ys.Right),this.label=new Ss(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,ys.Center,i),this.label.setToRelativeVarianceLabel()}}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(){var t;if(this.isEmpty())return this;if(null==this.dimensions)return this;const i=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),s=i.stroke;let e=i.fill;const n=this.barStyles[this.dataPoint.getScenario()];if(null!=n&&n.fillpattern){const t=this.styles.pattern.get(n.fillpattern);null!=t&&null!=t.pattern&&(e=t.pattern)}this.drawNeedleHead(e,s),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(e).stroke(s).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(t=this.label)||void 0===t||t.draw()}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{barLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getBarPositionX()+i.getScaledPercentUnit(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()-this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}:{barLength:i.getScaledPercentUnit(),xPos:t.getBarPositionX(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()+this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}}drawNeedleHead(t,i){if(null===this.dimensions)return;const s=this.styles.varianceStyles.needleHeadColour,e=this.styles.varianceStyles.needleHeadColour;if(this.dimensions.clipped){let s="13,0 4,-5 4,5 13,0 8,0 0,-5 0,5 8,0";null!=this.dataPoint.value&&this.dataPoint.value<0&&(s="0,0 9,-5 9,5 0,0 5,0 13,-5 13,5 5,0"),this.barGroup.polygon(s).fill(t).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(t).stroke(i)}else this.barGroup.rect(2*this.position.getNeedleWidth(),2*this.position.getNeedleWidth()).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(s).stroke(e)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadXPosition(){let t=this.dimensions.xPos;return null!=this.dataPoint.value&&this.dataPoint.value>0&&(t+=this.dimensions.barLength),t}};class xs{constructor(t,i,s,e,n,r,a,h,o,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=e,this.baselineValue=n,this.segmentIndex=a,this.stackMode=h,this.totalValue=o,this.group=c,this.barGroup=c.group().id(`stacked_bar_${e}_seg_${a}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new _t){if(!this.hasData||null==this.dataPoint.value)return;const s=this.dataPoint.value,e=this.dataPoint.pixelPerUnit,n=this.position.getBarPositionX(),r=this.position.getBarWidth();let a,h;if(this.stackMode===pt.RELATIVE){const t=e;a=(0!==this.totalValue?Math.abs(s)/Math.abs(this.totalValue):0)*t,h=n+this.baselineValue/Math.abs(this.totalValue)*t}else a=Math.abs(s*e),h=n+this.baselineValue*e;const o=this.position.getBarPositionY(this.index,!0),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],d={color:c},u={color:c,width:.5};this.barGroup.rect(Math.max(a,.5),r).fill(d).stroke(u).cy(o).x(h);const p=a-6;if(p>0){const e=h+a/2;if(this.stackMode===pt.RELATIVE||this.stackMode===pt.ABSOLUTE_RELATIVE){const i=(0!==this.totalValue?s/this.totalValue*100:0).toFixed(t.percent)+"%";new Ss(this.group,e,o,"STACK_SEG",i,this.styles,ys.Center,ys.Center).setSegmentFill(c).setMaxWidth(p).draw()}else new Ss(this.group,e,o,"STACK_SEG",s,this.styles,ys.Center,ys.Center).setSegmentFill(c).setMaxWidth(p).draw(t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new _t){if(this.stackMode===pt.RELATIVE)return;const s=this.position.getBarPositionX()+this.totalValue*this.dataPoint.pixelPerUnit+this.position.spacings.labelToBar,e=this.position.getBarPositionY(this.index,!0);new Ss(this.group,s,e,"STACK_TOTAL",this.totalValue,this.styles,ys.Center,ys.Left).draw(t,i)}}let _s=class{constructor(t,i,s,e,n){this.overflowConfig=null,this.i18n=n;const r=i.group().id("Scenario1"),a=i.group().id("Scenario2").insertBefore(r);this.svgGroups={parent:i,scenario1:r,scenario2:a,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=e}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,e,n,r;const a=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),h=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);let o=null;return this.isLastDataPoint(i)&&(o=`${this.i18n.get(t.scenario)||t.scenario}`),new $s(this.position,this.styles,t,i,!0,a,o,this.overflowConfig).updateLabelGroup(h)}createVarianceBar(t,i){var s,e,n,r;const a=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),h=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);let o=null;return this.isLastDataPoint(i)&&(o=`${this.i18n.get(t.scenario)||t.scenario}`),new $s(this.position,this.styles,t,i,!0,a,o,this.overflowConfig).updateLabelGroup(h).setAsVariance()}createRelativeVarianceBar(t,i){var s,e,n,r;const a=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),h=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);return new Ms(this.position,this.styles,t,i,a).updateLabelGroup(h)}createSecondaryBar(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===e?void 0:e.group().id(""+i);let r=null;return this.isFirsttDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new $s(this.position,this.styles,t,i,!1,n,r,this.overflowConfig)}createPrimaryMarker(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===e?void 0:e.group().id(""+i),r=this.styles.pattern.get("marker-down")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let a=null;return this.isFirstDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new Rs(this.position,n,r,t.scenario,this.styles,t,i,a,!0)}createSecondaryMarker(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===e?void 0:e.group().id(""+i),r=this.styles.pattern.get("marker-up")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new Rs(this.position,n,r,t.scenario,this.styles,t,i,a,!1)}isFirstDataPoint(t){return 0===t}};class ks{constructor(t,i,s,e,n){this.dataModel=[],this.variancesDataModel=[],this.title="",this.smallestDataPointValue=new ds(0,bs.AC1,1,bs.NEU),this.highestDataPointValue=new ds(0,bs.AC1,1,bs.NEU),this.smallestVarianceDataPointValue=new ds(0,bs.AC1,1,bs.NEU),this.highestVarianceDataPointValue=new ds(0,bs.AC1,1,bs.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideCategories=!1,this.axisScenario=bs.AC1,this.CSS_CATEGORIES="categories",this.state=ns.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new _t,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.scenarioPropOrder=[],this.overflowConfig=null,this.highestStackedTotal=0,this.fromExpr="",this.rowCount=0,this.db=i,this.tableName=s,this.ruleSet=t||new Et,this.i18n=this.createI18n(new Map),this.styles=n,this.setConfig(e),this.position=this.createElementPosition()}updatePosition(){this.position=this.createElementPosition()}createElementPosition(){this.titleLength=this.calculateTitleLength(0);let t=this.calculateLeftSideWidth(this.getVarianceType());const i=this.calculateCategoryWidth();return this.titleLength>t&&(t=this.titleLength),new ts(new is(this.styles.padding),this.styles.scaleFactors,this.styles.fontStyles.size,this.dataModel.length,this.leftSideOffsetForHorizontalSync,this.titleLength,t,i,!!this.stackConfig&&0===this.variancesDataModel.length)}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new Et}setConfig(t){var i;this.state=ns.DIRTY,this.scenarioPropOrder=[...t.scenarios];const s=this.sortScenariosbyVisualisationRules(t.scenarios);this.hideCategories=t.hideCategories||!1,this.limit=t.limit,this.pixelPerUnit=t.pixelPerUnit||1,this.pixelPerPercentage=t.pixelPerPercentage||100,this.setSource(t.filter),this.dataModel=this.populateModel(s,t.level,t.sortOrder),t.stackConfig&&t.stackConfig.by!==dt.SCENARIOS&&this.populateDimensionStackSegments(s,t.stackConfig,t.level),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.title=t.title||Mt.translateScenarioLabel(null===(i=null==t?void 0:t.variances)||void 0===i?void 0:i.toString(),this.i18n),this.smallestDataPointValue=this.findSmallestDataPointValue(this.dataModel),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(this.dataModel),this.highestVarianceDataPointValue=this.findHighestDataPointValue(this.variancesDataModel),this.axisScenario=this.setAxisScenario(t.variances),this.measureScale=t.measureScale,this.measureUnit=t.measureUnit,this.dataFormatDigits=t.dataFormatDigits,this.stackConfig=t.stackConfig,this.highestStackedTotal=this.findHighestStackedRowTotal(this.dataModel),this.updatePosition()}sortScenariosbyVisualisationRules(t){const i=this;return[...t].sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))).reverse()}setI18n(t){this.i18n=this.createI18n(t)}createI18n(t){this.state=ns.DIRTY;const i=new Map([["SEPERATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pl3","PL3"],["ac4","AC4"],["pp4","PY4"],["fc4","FC4"],["pl4","PL4"],["category"," "],["operation"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return new Map([...i,...t])}setSource(t){var i,s;if(this.state=ns.DIRTY,!this.tableName)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=g(this.tableName,t);try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(s=null===(i=t[0])||void 0===i?void 0:i.cnt)&&void 0!==s?s:0}catch(t){this.rowCount=0}}getMaxBarValue(){var t,i;if(null!=this.stackConfig&&this.highestStackedTotal>0)return this.stackConfig.mode===pt.RELATIVE?1:this.highestStackedTotal;const s=this.getVarianceType();return s===rs.NONE&&null!=(null===(t=this.highestDataPointValue)||void 0===t?void 0:t.value)?Math.abs(this.highestDataPointValue.value):s===rs.ABSOLUTE&&null!=(null===(i=this.highestVarianceDataPointValue)||void 0===i?void 0:i.value)?Math.abs(this.highestVarianceDataPointValue.value):0}getAllocatedCanvasWidth(){const t=this.position.getAxisPositionX(),i=this.calculateRightSideWidth(this.getVarianceType());let s=t+i+ +this.styles.padding.left+this.styles.padding.right;return i<this.titleLength/2&&(s+=this.titleLength/2),t<this.titleLength/2&&(s+=this.titleLength/2),s}getAllocatedCanvasHeight(){return this.position.getAxisEndPositionY()+this.position.spacings.labelToAxis+this.position.fontSize+this.styles.padding.bottom}patternToString(){return"<svg></svg>"}toString(){const t=new xt;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.svg()}draw(t){this.cleanSVGforRedraw(t),this.state===ns.DIRTY&&(this.state=ns.UP_TO_DATE),this.variancesDataModel&&this.variancesDataModel.length>0?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?(this.drawStackedScenarios(this.dataModel,t),this.drawStackedHeaders(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)):(this.drawScenarios(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t))}setPattern(t,i){this.styles.pattern.set(t,i)}calculateTitleLength(t){const i=Lt(this.title.length>7?this.title:"_______",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;return i<t?t:i/2}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":Mt.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}setAxisScenario(t){let i=bs.AC1;if(null!=t&&t.length>0){const s=new Tt(t.toString());s.isValid&&(i=s.delta)}return null===i&&(i=bs.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const e=[],n=this.createOrderStr(i,s),r=this.createSelectString(i,s),a=this.createGroupByStr(i,s);let h;try{h=this.db.exec(`SELECT ${r} ${t.length>0?","+t.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(","):""}\n FROM ${this.fromExpr}\n GROUP BY ${a}\n ORDER BY ${n}`)}catch(t){return console.error("StructureChart: populateModel query failed",t),[]}return this.detectNaNCells(t,h),this.createDataRows(h,e,t),this.crateRESTRow(h,t,e),e}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new Tt(t);!0===s.isValid?0!==i[s.base+"_cnt"]&&0!==i[s.delta+"_cnt"]||(i[t]=Number.NaN):0===i[t+"_cnt"]&&(i[t]=Number.NaN)})),i)))}crateRESTRow(t,i,s){if(0===this.limit||this.limit>t.length)return;const e=[],n=t.slice(this.limit,t.length);this.createDataRows(n,e,i);const r=e.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new ds(t.scenario1.value+s.scenario1.value,i[0],t.scenario1.pixelPerUnit,bs.NEU),scenario2:new ds(t.scenario2.value+s.scenario2.value,i[1],t.scenario2.pixelPerUnit,bs.NEU),scenario3:new ds(t.scenario3.value+s.scenario3.value,i[2],t.scenario3.pixelPerUnit,bs.NEU),scenario4:new ds(t.scenario4.value+s.scenario4.value,i[3],t.scenario4.pixelPerUnit,bs.NEU)}}),{id:9999,category:"REST",type:rs.NONE,scenario1:new ds(0,i[0],this.pixelPerUnit,bs.NEU),scenario2:new ds(0,i[1],this.pixelPerUnit,bs.NEU),scenario3:new ds(0,i[2],this.pixelPerUnit,bs.NEU),scenario4:new ds(0,i[3],this.pixelPerUnit,bs.NEU)});s.push(r)}createDataRows(t,i,s){let e=t;this.limit>0&&(e=t.slice(0,this.limit)),e.forEach(((t,e)=>{i.push({id:e,category:t.category,type:rs.NONE,scenario1:new ds(t[s[0]],s[0],this.pixelPerUnit,bs.NEU),scenario2:new ds(t[s[1]],s[1],this.pixelPerUnit,bs.NEU),scenario3:new ds(t[s[2]],s[2],this.pixelPerUnit,bs.NEU),scenario4:new ds(t[s[3]],s[3],this.pixelPerUnit,bs.NEU)})}))}createOrderStr(t,i){let s=`${t.toLowerCase()}`;return i.hierarchy.length>=1&&(s=`${i.hierarchy.toString()} ${null==i?void 0:i.direction}`),s}createSelectString(t,i){return t===ct.CATEGORY&&i.hierarchy.includes(P.CATEGORYINDEX)?`${P.CATEGORYINDEX}, ${ct.CATEGORY} as category`:t===ct.ROWGROUP&&i.hierarchy.includes(P.ROWGROUPINDEX)?`${P.ROWGROUPINDEX}, ${ct.ROWGROUP} as category`:t===ct.SUBCATEGORY&&i.hierarchy.includes(P.SUBCATEGORYINDEX)?`${P.SUBCATEGORYINDEX}, ${ct.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===ct.CATEGORY&&i.hierarchy.includes(P.CATEGORYINDEX)?`${P.CATEGORYINDEX}, ${ct.CATEGORY}`:t===ct.ROWGROUP&&i.hierarchy.includes(P.ROWGROUPINDEX)?`${P.ROWGROUPINDEX}, ${ct.ROWGROUP}`:t===ct.SUBCATEGORY&&i.hierarchy.includes(P.SUBCATEGORYINDEX)?`${P.SUBCATEGORYINDEX}, ${ct.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=Lt(i.category,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"});s.width>t&&(t=s.width)}return 1.1125*t}findSmallestDataPointValue(t){let i=new ds(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value<i.value&&(i=t);return i}findHighestDataPointValue(t){let i=new ds(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value>i.value&&(i=t);return i}findHighestStackedRowTotal(t){if(!this.stackConfig||0===t.length)return 0;const i=this.stackConfig.by===dt.SCENARIOS;let s=0;for(const e of t){let t=0;if(i){const i=["scenario1","scenario2","scenario3","scenario4"],s=[];for(const t of i){const i=e[t];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario})}if(new Set(s.map((t=>Pt(t.scenario)))).size>1){const i=new Map;for(const t of s){const s=Pt(t.scenario);i.set(s,(i.get(s)||0)+Math.abs(t.value))}t=Math.max(...i.values())}else t=s.reduce(((t,i)=>t+Math.abs(i.value)),0)}else e.stackSegments&&e.stackSegments.length>0&&(t=e.stackSegments.reduce(((t,i)=>t+Math.abs(i.value)),0));t>s&&(s=t)}return s}populateVarianceModel(t,i){const s=[];if(0===t.length)return s;let e=null;null!=i&&i.length>0&&(e=i[0]);for(const n in t){const r=new Tt(t[n]);if(r.isValid){const t=this.mapScenarios(r,e),n=r.direction;let a=this.pixelPerUnit;"dr"===r.type&&(a=this.pixelPerPercentage);for(const e in i)s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?rs.RELATIVE:rs.ABSOLUTE,scenario1:new ds(this.calculateVariance(r,i[e],t),r.base,a,n),scenario2:new ds(null,null,null,null),scenario3:new ds(null,null,null,null),scenario4:new ds(null,null,null,null)})}}return s}calculateVariance(t,i,s){const e=s.get(t.base),n=s.get(t.delta);return null==e||null==n?null:t.type===rs.RELATIVE?(i[e].value-i[n].value)/i[n].value:i[e].value-i[n].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((e=>{i[e].scenario===t.delta?s.set(t.delta,e):i[e].scenario===t.base&&s.set(t.base,e)})),s}calculateTextBoxWidth(t){return Lt(Mt.number(t,"decimal",1,0),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}calculatePercentageTextBoxWidth(t){let i=0;return t>=0&&(i+=Lt("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=Lt(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,Lt(Mt.number(t,"decimal",1,1),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width+i+i}cleanSVGforRedraw(t){t.clear()}drawAxisAndLabels(t,i){const s=i.group().id("AxisAndDateLables");let e=!1;this.hideCategories||t.forEach(((t,i)=>{t.type===rs.RELATIVE&&(e=!0);let n=ys.Right,r=!0;t.scenario1.value<0&&(n=ys.Left,r=!1),new Ss(s,this.position.getCategoryPositionX(r),this.position.getBarCenterPositionY(i),"",t.category,this.styles,ys.Center,n).draw()})),new Os({scenarioType:this.axisScenario,labelText:this.title,isRelative:e},this.position,s,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new _s(this.position,s,this.styles,t.length,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{e.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),e.createSecondaryBar(t.scenario2,i).draw(),e.createPrimaryMarker(t.scenario3,i).draw(),e.createSecondaryMarker(t.scenario4,i).draw()}))}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new _s(this.position,s,this.styles,t.length,this.i18n);return e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===rs.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw():e.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)})),s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const e=i.indexOf(t.scenario),n=i.indexOf(s.scenario);return(-1===e?i.length:e)-(-1===n?i.length:n)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),e=this.stackConfig.by===dt.SCENARIOS;t.forEach(((t,i)=>{const n=["scenario1","scenario2","scenario3","scenario4"],r=[];if(e){for(const i of n){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&r.push({value:s.value,scenario:s.scenario,dataPoint:s})}this.sortSegmentsByPropOrder(r)}else{const i=t.scenario1;i&&!i.isEmpty()&&null!=i.value&&r.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0!==r.length)if((e?new Set(r.map((t=>Pt(t.scenario)))):new Set).size>1){const t=new Map;for(const i of r){const s=Pt(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const e=[];for(const i of At)t.has(i)&&(e.push({prefix:i,segments:t.get(i)}),t.delete(i));for(const[i,s]of t)e.push({prefix:i,segments:s});e.forEach(((t,n)=>{const r=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),a=e.length-1-n;let h=0,o=null;t.segments.forEach((t=>{const e=new xs(this.position,this.styles,t.dataPoint,i,h,t.scenario,a,this.stackConfig.mode,r,!0,s);e.draw(this.dataFormatDigits,this.measureScale),h+=Math.abs(t.value),o=e})),o&&o.drawTotalLabel(this.dataFormatDigits,this.measureScale)}))}else{let n=r;!e&&t.stackSegments&&t.stackSegments.length>0&&(n=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint})))),"asc"===this.stackConfig.order?n.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&n.sort(((t,i)=>i.value-t.value));const a=n.reduce(((t,i)=>t+Math.abs(i.value)),0);let h=0,o=null;n.forEach(((t,n)=>{const r=new xs(this.position,this.styles,t.dataPoint,i,h,t.scenario,n,this.stackConfig.mode,a,e,s);r.draw(this.dataFormatDigits,this.measureScale),h+=Math.abs(t.value),o=r})),o&&o.drawTotalLabel(this.dataFormatDigits,this.measureScale)}}))}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;const s=this.stackConfig.by===dt.SCENARIOS,e=i.group().id("StackedHeaders"),n=t[0];if(!s){const t=n.stackSegments;if(!t||0===t.length)return;const i=[...t];"asc"===this.stackConfig.order?i.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&i.sort(((t,i)=>i.value-t.value));const s=i.reduce(((t,i)=>t+Math.abs(i.value)),0),r=this.position.getBarPositionX(),a=this.position.getStackedHeaderPositionY();let h=0;return void i.forEach((t=>{const i=t.dataPoint.pixelPerUnit;let n;n=this.stackConfig.mode===pt.RELATIVE?(0!==s?Math.abs(t.value)/s:0)*i:Math.abs(t.value*i);const o=r+h+n/2,l=this.i18n.get(t.label)||t.label;new Ss(e,o,a,"STACK_HEADER",l,this.styles,ys.Bottom,ys.Center).draw(),h+=n}))}const r=["scenario1","scenario2","scenario3","scenario4"],a=[];for(const t of r){const i=n[t];i&&!i.isEmpty()&&null!=i.value&&a.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===a.length)return;this.sortSegmentsByPropOrder(a);const h=new Set(a.map((t=>Pt(t.scenario)))),o=this.position.getBarPositionX(),l=this.position.getStackedHeaderPositionY();if(h.size>1){const t=new Map;for(const i of a){const s=Pt(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const i=[];for(const s of At)t.has(s)&&(i.push({prefix:s,segments:t.get(s)}),t.delete(s));for(const[s,e]of t)i.push({prefix:s,segments:e});i.forEach((t=>{const i=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),s=t.segments[0].dataPoint.pixelPerUnit,n=o+(this.stackConfig.mode===pt.RELATIVE?s:i*s)/2,r=this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase();new Ss(e,n,l,"STACK_HEADER",r,this.styles,ys.Bottom,ys.Center).draw()}))}else{"asc"===this.stackConfig.order?a.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&a.sort(((t,i)=>i.value-t.value));const t=a.reduce(((t,i)=>t+Math.abs(i.value)),0);let i=0;a.forEach((s=>{const n=s.dataPoint.pixelPerUnit;let r;r=this.stackConfig.mode===pt.RELATIVE?(0!==t?Math.abs(s.value)/t:0)*n:Math.abs(s.value*n);const a=o+i+r/2,h=this.i18n.get(s.scenario)||s.scenario;new Ss(e,a,l,"STACK_HEADER",h,this.styles,ys.Bottom,ys.Center).draw(),i+=r}))}}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:rs.NONE}calculateLeftSideWidth(t){var i,s,e;let n=0;const r=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(rs.NONE===t&&null!=(null===(i=this.smallestDataPointValue)||void 0===i?void 0:i.value)&&this.smallestDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestDataPointValue.value);n=Math.abs(this.smallestDataPointValue.getScaledUnit())+r+t}else if(rs.RELATIVE===t&&null!=(null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);n=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+r+t}else if(rs.ABSOLUTE===t&&null!=(null===(e=this.smallestVarianceDataPointValue)||void 0===e?void 0:e.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value);n=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+r+t}return n<=this.titleLength?this.titleLength:n}calculateRightSideWidth(t){var i,s,e;if(null!=this.stackConfig&&this.highestStackedTotal>0){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;let i;i=this.stackConfig.mode===pt.RELATIVE?this.pixelPerUnit:this.highestStackedTotal*this.pixelPerUnit;const s=this.calculateTextBoxWidth(this.highestStackedTotal);return Math.max(i+t+s,this.titleLength)}let n=0;const r=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(rs.NONE===t&&null!=(null===(i=this.highestDataPointValue)||void 0===i?void 0:i.value)&&this.highestDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestDataPointValue.value);n=Math.abs(this.highestDataPointValue.getScaledUnit())+r+t}else if(rs.RELATIVE===t&&null!=(null===(s=this.highestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);n=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+r+t}else if(rs.ABSOLUTE===t&&null!=(null===(e=this.highestVarianceDataPointValue)||void 0===e?void 0:e.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);n=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+r+t}return n<=this.titleLength?this.titleLength:n}populateDimensionStackSegments(t,i,s){if(0===this.rowCount||!this.fromExpr||0===t.length)return;const e={[ct.ROWGROUP]:"category",[ct.ROWGROUPINDEX]:"category",[ct.CATEGORY]:"subCategory",[ct.CATEGORYINDEX]:"subCategory"}[s];if(!e)return;const n=s.toString(),r=t[0];let a;try{a=this.db.exec(`SELECT [${n}] as displayGroup, [${e}] as stackLabel, SUM([${r}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${n}], [${e}]`)}catch(t){return void console.error("StructureChart: dimension-stack query failed",t)}const h=new Map;for(const t of a){const i=t.displayGroup;h.has(i)||h.set(i,[]),null!=t.stackValue&&null!=t.stackLabel&&h.get(i).push({label:t.stackLabel,value:t.stackValue})}for(const t of this.dataModel){const i=h.get(t.category);t.stackSegments=i&&i.length>0?i.map((t=>({label:t.label,value:t.value,dataPoint:new ds(t.value,r,this.pixelPerUnit,bs.NEU)}))):[]}}hasNoData(){return 0===this.dataModel.length}setAvailableWidth(t){if(this.pixelPerUnit<=0||t<=0)this.overflowConfig=null;else if(null==this.stackConfig){if(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig){const{cutWidth:t,overdriveZoneWidth:i,breakGap:s}=this.overflowConfig,e=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new ds(e,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new ds(-e,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new ds(e,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new ds(-e,this.smallestDataPointValue.scenario,1,this.smallestDataPointValue.variance))),this.updatePosition()}}else this.overflowConfig=null}calculateOverflowConfig(t){const i=this.variancesDataModel&&this.variancesDataModel.length>0;if(this.getVarianceType()===rs.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,e=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,n=s.getScaledUnit(),r=null!=e.value?Math.abs(e.getScaledUnit()):0,a=Math.max(n,r);if(a<=0)return null;const h=this.styles.fontStyles.size,o=h*this.styles.scaleFactors.labelToBar,l=1.5*h,c=.3*h,d=.8*h,u=t-this.position.getAxisPositionX()-this.styles.padding.left-this.styles.padding.right-o-this.calculateTextBoxWidth(s.value||0)-l-c;if(u<=d)return null;const p=u-d;return a<=p?null:{cutWidth:u,overdriveZoneWidth:l,breakGap:c,maxOverflow:a-p,scenarioCutOffset:d}}}class Es{constructor(t=2,i=1){this.percent=t,this.decimal=i}}class Ls{adapt(t){const i=new Es;return Ot.isNumber(t.percent)&&(i.percent=t.percent),Ot.isNumber(t.decimal)&&(i.decimal=t.decimal),i}default(){return new Es}}class Ts{constructor(t,i,s){this.pos=t,this.neg=i,this.neu=s,this.needleHeadColour="#000000"}getSVGStyle(t){return"pos"===t?this.pos:"neg"===t?this.neg:this.neu}}class Ps{constructor(t){this.svgStyleAdapter=t}adapt(t){const i=new Ts(this.svgStyleAdapter.defaultPos(),this.svgStyleAdapter.defaultNeg(),this.svgStyleAdapter.defaultNeu());return Ot.isExisting(t.pos)&&(i.pos=this.svgStyleAdapter.adapt(t.pos)),Ot.isExisting(t.neg)&&(i.neg=this.svgStyleAdapter.adapt(t.neg)),Ot.isExisting(t.pp)&&(i.neu=this.svgStyleAdapter.adapt(t.neu)),Ot.isString(t.needleHeadColour)&&(i.needleHeadColour=t.needleHeadColour),i}default(){return new Ts(this.svgStyleAdapter.defaultPos(),this.svgStyleAdapter.defaultNeg(),this.svgStyleAdapter.defaultNeu())}}const As=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.chartTitle="",this.scenarios=[],this.variances=[],this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.i18n=new Map,this.order={hierarchy:[],direction:T.ASC},this.level=ct.CATEGORY,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.parentDimensions={width:0,height:0}}getDb(){return this.stores||(this.stores=d(this.element)),this.stores.db.db}render(){var t,e,n;if(void 0===this.chart)return i(s,null);if(this.chart.hasNoData()){const t=this.i18n.get("NO_DATA")||"==No Data==";return i(s,null,i("p",{class:"warning"},t))}return i(s,null,i("div",{innerHTML:null===(t=this.pattern)||void 0===t?void 0:t.toString(),class:"hidePatternContainer"}),i("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(e=this.chart)||void 0===e?void 0:e.getFooter()),i("div",{innerHTML:null===(n=this.chart)||void 0===n?void 0:n.toString()}))}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),e=this.prepareStyle();this.chart=new ks(new Et(this.ruleSetConfig),i,this.tableName,s,e),this.chart.setI18n(this.i18n),this.autoFitScaling(s,e),this.chart.setAvailableWidth((null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new es(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}async componentWillUpdate(){var t;if(null==this.chart)return;const i=this.prepareConfig(),s=this.prepareStyle();this.chart.setI18n(this.i18n),this.chart.setStyles(s),this.chart.setRuleSet(new Et(this.ruleSetConfig)),this.chart.setConfig(i),this.autoFitScaling(i,s),this.chart.setAvailableWidth((null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new es(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}autoFitScaling(t,i){var s;const e=t.pixelPerUnit<=0,n=t.pixelPerPercentage<=0;if(!e&&!n)return;const r=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,a=this.getDb();if(!r||r<=0)return e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=50),this.chart=new ks(new Et(this.ruleSetConfig),a,this.tableName,t,i),void this.chart.setI18n(this.i18n);e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=1),this.chart=new ks(new Et(this.ruleSetConfig),a,this.tableName,t,i),this.chart.setI18n(this.i18n),this.chart.toString();const h=this.chart.getAllocatedCanvasWidth();if(h<=0)return;const o=this.chart.getMaxBarValue();e&&(t.pixelPerUnit=o>0?Math.max(.001,(r-(h-o))/o):.9*r/h),n&&(t.pixelPerPercentage=.9*r/h),this.chart=new ks(new Et(this.ruleSetConfig),a,this.tableName,t,i),this.chart.setI18n(this.i18n)}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=this.tableName?g(this.tableName,this.filter):"";return new cs(new ps,new tt(new os),new os,new Ls,t,i).adapt({scenarios:this.scenarios,variances:this.variances,title:this.chartTitle,hideCategories:this.hideCategories,pixelPerUnit:this.pixelPerUnit,pixelPerPercentage:this.pixelPerPercentage,level:this.level,limit:this.limit,sortOrder:this.order,filter:this.filter,measureScale:this.measureScale,measureUnit:this.measureUnit,showMeasureScale:this.showMeasureScale,dataFormatDigits:this.dataFormatDigits,stackConfig:this.stackConfig})}prepareStyle(){return new vs(new ms,new Ct,new Nt(new Ut),new Ps(new Ut),new Dt).adapt(this.styles)}get element(){return e(this)}};As.style=':host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}';class Cs{constructor(){this.scenarioOffset=.3,this.scenarioLabelToColumn=.3,this.labelToColumn=.3,this.labelToAxis=.3,this.needleWidth=.3,this.needleHeadWidth=.6,this.columnWidth=2,this.varianceAxisLineWidth=.3,this.axisLineWidth=.1,this.auxiliaryLineWidth=.1,this.scenarioLineWidth=.2,this.markerWidth=.7,this.markerOffset=0,this.categoryWidth=3,this.axisTickLength=.3}}class Ns{adapt(t){const i=new Cs;return Ot.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),Ot.isNumber(t.scenarioLabelToColumn)&&(i.scenarioLabelToColumn=t.scenarioLabelToColumn),Ot.isNumber(t.labelToColumn)&&(i.labelToColumn=t.labelToColumn),Ot.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),Ot.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),Ot.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),Ot.isNumber(t.columnWidth)&&(i.columnWidth=t.columnWidth),Ot.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),Ot.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),Ot.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),Ot.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),Ot.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),Ot.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),Ot.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),Ot.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new Cs}}class Us{constructor(t,i,s,e,n,r,a){this.categoryPosition={x:0,y:0},this.spacings=new Cs,this.categoriesBoxOffset={width:0,height:0},this.padding=t,this.scaleFactors=i,this.fontStlye=s,this.dataLabelHeight=this.caluculateDataLabelHeight(),this.axisPosition={x:0,y:0},this.columnValue={min:e,max:n},this.numberOfColumns=r,this.leftSideLabelLength=a,this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}caluculateDataLabelHeight(){return 1.1*Lt("123456789",{font:this.fontStlye.font,fontSize:this.fontStlye.size+"px"}).height}getColumnCenterPositionX(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth+this.leftSideLabelLength+.5*this.spacings.columnWidth}getAxisPositionY(t){let i=this.columnValue.max.getScaledUnit();return t&&(i=this.columnValue.max.getScaledPercentUnit()+this.getNeedleWidth()),i+this.dataLabelHeight+this.spacings.labelToAxis+this.padding.top}getAxisPositionX(){return this.padding.left+this.leftSideLabelLength}getColumnPositionX(t,i){return i?this.getColumnCenterPositionX(t):this.getColumnCenterPositionX(t)-this.spacings.scenarioOffset}getColumnPositionY(){return this.columnValue.max.getScaledUnit()+this.dataLabelHeight+this.spacings.labelToColumn+this.padding.top}getNeedlePositionY(){return this.columnValue.max.getScaledPercentUnit()+this.dataLabelHeight+this.spacings.labelToColumn+this.getNeedleWidth()+this.padding.top}getMarkerPositionX(t,i){return i?this.getColumnCenterPositionX(t)-this.spacings.markerOffset-.5*this.getColumnWidth():this.getColumnCenterPositionX(t)+this.spacings.markerOffset+.5*this.getColumnWidth()}getMarkerPositionY(){return this.getColumnPositionY()}getAxisTitlePositionX(t){const i=t.width();return this.axisPosition.x-i}getAxisTitlePositionY(t,i){let s=this.columnValue.max.getScaledUnit();return i&&(s=this.columnValue.max.getScaledPercentUnit()),t?s+this.dataLabelHeight+this.spacings.labelToAxis:s}getColumnDataLabelPositionY(t){const i=this.spacings.labelToColumn;return t<0?this.getColumnPositionY()+Math.abs(t)+i:this.getColumnPositionY()-t-i}getNeedleDataLabelPositionY(t){const i=this.spacings.labelToColumn;return t<0?this.getNeedlePositionY()+Math.abs(t)+i+2*this.getNeedleWidth():this.getNeedlePositionY()-t-i-2*this.getNeedleWidth()}getAxisEndPositionX(){return this.getAxisPositionX()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getColumnWidth(){return this.spacings.columnWidth}getNeedleWidth(){return this.spacings.needleWidth}getNeedleHeadWidth(){return this.spacings.needleHeadWidth}getScenarioLabelPositionOffsetX(t){return t?.5*this.getColumnWidth()+this.spacings.scenarioLabelToColumn:-(.5*this.getColumnWidth()+this.spacings.scenarioLabelToColumn)}calculateSpacings(){this.spacings={scenarioOffset:this.fontStlye.size*this.scaleFactors.scenarioOffset,scenarioLabelToColumn:this.fontStlye.size*this.scaleFactors.scenarioLabelToColumn,markerOffset:this.fontStlye.size*this.scaleFactors.markerOffset,labelToColumn:this.fontStlye.size*this.scaleFactors.labelToColumn,labelToAxis:this.fontStlye.size*this.scaleFactors.labelToAxis,needleWidth:this.fontStlye.size*this.scaleFactors.needleWidth,needleHeadWidth:this.fontStlye.size*this.scaleFactors.needleHeadWidth,columnWidth:this.fontStlye.size*this.scaleFactors.columnWidth,varianceAxisLineWidth:this.fontStlye.size*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontStlye.size*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontStlye.size*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontStlye.size*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontStlye.size*this.scaleFactors.markerWidth,categoryWidth:this.fontStlye.size*this.scaleFactors.categoryWidth,axisTickLength:this.fontStlye.size*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left+.5*this.spacings.columnWidth,y:this.padding.top}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY(!1)}}getMarkerScenarioLabelPositionOffsetX(t){return t?this.spacings.labelToColumn-this.fontStlye.size:this.spacings.labelToColumn+.5*this.spacings.markerWidth}}class Ds{constructor(t){this.top=t.top,this.bottom=t.bottom,this.left=t.left,this.right=t.right}addBoxTopLeft(t){return this.top+=t.height|this.top,this.left+=t.width|this.top,this}}class Gs{constructor(t){const i=1*t,s=.7*t;this.bgOffset=(i-s)/2,this.markerUp={top:s/2+",0",left:"0,"+s,right:s+","+s},this.markerUpBackground={top:i/2+",0",left:"0,"+i,right:i+","+i},this.markerDown={bottom:s/2+","+s,left:"0,0",right:s+",0"},this.markerDownBackground={bottom:i/2+","+i,left:"0,0",right:i+",0"},this.markerRight={bottom:"0,"+s,top:"0,0",right:s+","+s/2},this.markerRightBackground={bottom:"0,"+i,top:"0,0",right:i+","+i/2},this.markerLeft={bottom:s+","+s,top:s+",0",left:"0,"+s/2},this.markerLeftBackground={bottom:i+","+i,top:i+",0",Left:"0,"+i/2}}upMarkerPatternStrings(){return{background:this.markerUpBackground.left+" "+this.markerUpBackground.right+" "+this.markerUpBackground.top+" "+this.markerUpBackground.left,foreground:this.markerUp.left+" "+this.markerUp.right+" "+this.markerUp.top+" "+this.markerUp.left,bgOffset:this.bgOffset}}downMarkerPatternStrings(){return{background:this.markerDownBackground.left+" "+this.markerDownBackground.right+" "+this.markerDownBackground.bottom+" "+this.markerDownBackground.left,foreground:this.markerDown.left+" "+this.markerDown.right+" "+this.markerDown.bottom+" "+this.markerDown.left,bgOffset:this.bgOffset}}rightMarkerPatternStrings(){return{background:this.markerRightBackground.top+" "+this.markerRightBackground.right+" "+this.markerRightBackground.bottom+" "+this.markerRightBackground.top,foreground:this.markerRight.top+" "+this.markerRight.right+" "+this.markerRight.bottom+" "+this.markerRight.top,bgOffset:this.bgOffset}}leftMarkerPatternStrings(){return{background:this.markerLeftBackground.top+" "+this.markerLeftBackground.Left+" "+this.markerLeftBackground.bottom+" "+this.markerLeftBackground.top,foreground:this.markerLeft.top+" "+this.markerLeft.left+" "+this.markerLeft.bottom+" "+this.markerLeft.top,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t.set("marker-right",this.rightMarkerPatternStrings()),t.set("marker-left",this.leftMarkerPatternStrings()),t}}class Ws{constructor(t){this.container=new xt,this.pattern=this.createFCPattern(this.container.group(),t),this.styles=t;let i=10;null!=t&&null!=t.fontStyles&&t.fontStyles.size&&(i=t.fontStyles.size),this.bgOffset=(1*i-.7*i)/2}createFCPattern(t,i){const s=i;return t.pattern(10,10,(function(t){t.rect(10,10).fill(s.barStyles.fc.fill),t.line(0,5,5,0).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"}),t.line(5,10,10,5).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"})})).id("pattern-time-fc")}getFCPolygonPattern(){return{background:"",foreground:"",bgOffset:0,pattern:this.pattern}}toString(){return this.container.svg()}}class Fs{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1,this.variance="neg"===e||e===Hs.NEG?Hs.NEG:"pos"===e||e===Hs.POS?Hs.POS:Hs.NEU}isEmpty(){return void 0===this.value||null==this.scenario}getScaledUnit(){return null==this.value?0:this.value*this.pixelPerUnit}getScaledPercentUnit(){return null==this.value?0:this.value>1.45?1.45*this.pixelPerUnit:this.value<-1.45?-1.45*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:Hs.NEU===this.variance?Hs.NEU:Hs.POS===this.variance?Hs.NEG:Hs.POS}isClipped(){return null!=this.value&&Math.abs(this.value)>1.45}getClippedValue(){return 145}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class Ys{constructor(){this.operation="+"}addRowGroup(t,i){this.rowGroup=t,this.rowGroupIndex=i}addCategory(t,i){this.category=t,this.categoryIndex=i}addSubCategory(t,i){this.subCategory=t,this.subCategoryIndex=i}addColumnGroup(t,i){this.columnGroup=t,this.columnGroupIndex=i}addSubColumnGroup(t,i){this.columnSubGroup=t,this.columnSubGroupIndex=i}}class Is{constructor(){}adapt(t){const i=new Ys;return Ot.isString(t.date)&&(i.date=this.parseDateString(t.date)),Ot.isOperator(t.operation)&&(i.operation=t.operation),Ot.isNumber(t.rowGroupIndex)&&Ot.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),Ot.isNumber(t.categoryIndex)&&Ot.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),Ot.isNumber(t.subCategoryIndex)&&Ot.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),Ot.isNumber(t.columnGroupIndex)&&Ot.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),Ot.isNumber(t.columnSubGroupIndex)&&Ot.isString(t.columnSubGroup)&&i.addSubColumnGroup(t.columnSubGroup,t.columnSubGroupIndex),this.setActualValues(t,i),this.setPlanValues(t,i),this.setPreviousPeriodValues(t,i),this.setForecastValues(t,i),i}parseDateString(t){if("string"!=typeof t)return;const i=v.fromISO(t);if(i.isValid)return i;console.warn(`TimeChartDataRow: invalid date value '${t}' — skipping row`)}default(){return new Ys}setActualValues(t,i){Ot.isNumber(t.ac1)&&(i.ac1=t.ac1),Ot.isNumber(t.ac2)&&(i.ac2=t.ac2),Ot.isNumber(t.ac3)&&(i.ac3=t.ac3),Ot.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){Ot.isNumber(t.pl1)&&(i.pl1=t.pl1),Ot.isNumber(t.pl2)&&(i.pl2=t.pl2),Ot.isNumber(t.pl3)&&(i.pl3=t.pl3),Ot.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){Ot.isNumber(t.pp1)&&(i.pp1=t.pp1),Ot.isNumber(t.pp2)&&(i.pp2=t.pp2),Ot.isNumber(t.pp3)&&(i.pp3=t.pp3),Ot.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){Ot.isNumber(t.fc1)&&(i.fc1=t.fc1),Ot.isNumber(t.fc2)&&(i.fc2=t.fc2),Ot.isNumber(t.fc3)&&(i.fc3=t.fc3),Ot.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class Bs{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"]}}class zs{constructor(t,i,s,e,n){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingadapter=n}adapt(t){const i=new Bs(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return Ot.isExisting(t)&&(Ot.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),Ot.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),Ot.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),Ot.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),Ot.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),Ot.isExisting(t.padding)&&(i.padding=this.paddingadapter.adapt(t.padding)),Array.isArray(t.stackColors)&&t.stackColors.length>0&&(i.stackColors=t.stackColors),i.pattern=new Gs(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new Bs(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}var Hs,Vs;!function(t){t.AC1="ac1",t.PP1="pp1",t.FC1="fc1",t.PL1="pl1",t.AC2="ac2",t.PP2="pp2",t.FC2="fc2",t.PL2="pl2",t.AC3="ac3",t.PP3="pp3",t.FC3="fc3",t.PL3="pl3",t.AC4="ac4",t.PP4="pp4",t.FC4="fc4",t.PL4="pl4",t.POS="pos",t.NEG="neg",t.NEU="neu"}(Hs||(Hs={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(Vs||(Vs={}));class js{constructor(t,i,s){this.ID_AXIS="axis",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.isRelative=t.isRelative||!1,this.position=i,this.svgGroup=s.group().id(this.ID_AXIS)}drawAxisTitle(t,i){null==i&&(i=""),t.text(i).addClass(this.CSS_AXIS_TITLE).attr("text-anchor","middle").move(this.position.getAxisTitlePositionX(t),this.position.getAxisTitlePositionY(!0,this.isRelative))}draw(){return this.labelText&&this.drawAxisTitle(this.svgGroup,this.labelText),this.svgGroup.line(this.position.getAxisPositionX(),this.position.getAxisPositionY(this.isRelative),this.position.getAxisEndPositionX(),this.position.getAxisPositionY(this.isRelative)).addClass(this.ID_AXIS+"-"+this.convertScenarioType()),this}convertScenarioType(){return void 0===this.scenarioType||null==this.scenarioType?"default":`${this.scenarioType}`.slice(0,2)}}class Xs{constructor(t,i,s,e,n,r,a,h=null){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.isVarianceColumn=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveHeight=0,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.isPrimaryColumn=n,this.position=t,this.columnBarStyles=i.barStyles,this.overflowConfig=h,this.scenarioGroup=r,this.styles=i,this.columnGroup=r.group().id(r.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(s,e,n),this.label=this.getDataLabel(s),this.scenarioLabel=this.getScenarioLabel(a))}setAsVariance(){var t;return this.isVarianceColumn=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new _t){if(this.isEmpty())return this;const s=this.getScenarioStyle(),e=this.convertToSVGStyle(s,"stroke"),n=this.getFillStyle(s);null!=this.columnGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(n,e):this.columnGroup.rect(this.position.getColumnWidth(),this.dimensions.columnLength).fill(n).stroke(e).y(this.dimensions.yPos).cx(this.dimensions.xPos)),this.drawColumnDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.columnGroup||!this.overflowConfig)return;const s=this.position.getColumnPositionY(),e=this.position.getColumnWidth(),n=this.dimensions.columnLength,{breakGap:r}=this.overflowConfig,a=s-n;this.columnGroup.rect(e,n).fill(t).stroke(i).y(a).cx(this.dimensions.xPos);const h=a-r-this.overdriveHeight;this.columnGroup.rect(e,this.overdriveHeight).fill(t).stroke(i).y(h).cx(this.dimensions.xPos),this.drawBreakIndicator(a,r)}drawBreakIndicator(t,i){if(!this.columnGroup)return;const s=this.position.getColumnWidth(),e=this.dimensions.xPos-s/2,n=t-i/2,r=.35*i,a=s/3;let h=`M ${e} ${n-r}`;for(let t=0;t<3;t++)h+=` L ${e+a*(t+.5)} ${n-r-.3*i} L ${e+a*(t+1)} ${n-r}`;let o=`M ${e} ${n+r}`;for(let t=0;t<3;t++)o+=` L ${e+a*(t+.5)} ${n+r+.3*i} L ${e+a*(t+1)} ${n+r}`;this.columnGroup.rect(s+2,i).fill("#ffffff").stroke("none").y(t-i).cx(this.dimensions.xPos),this.columnGroup.path(h).fill("none").stroke({color:"#000000",width:1}),this.columnGroup.path(o).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s){const e=t.getScaledUnit();if(this.overflowConfig&&e>0){const n="ac"===t.getScenario()?this.overflowConfig.cutHeight:this.overflowConfig.cutHeight-this.overflowConfig.scenarioCutOffset;if(e>n){this.isOverflowing=!0;const{breakGap:t,overdriveZoneHeight:r,maxOverflow:a}=this.overflowConfig;this.overdriveHeight=a>0?(e-n)/a*r:0;const h=n+t+this.overdriveHeight,o=this.position.getColumnPositionY();return{clipped:!1,columnLength:n,xPos:this.position.getColumnPositionX(i,s),yPos:o-n,labelYPos:o-h-this.position.spacings.labelToColumn,scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:o-.5*n}}}return e<0?{clipped:!1,columnLength:Math.abs(e),xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY(),labelYPos:this.position.getColumnDataLabelPositionY(e),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()+.5*Math.abs(e)}:{clipped:!1,columnLength:e,xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY()-e,labelYPos:this.position.getColumnDataLabelPositionY(e),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()-.5*Math.abs(e)}}getDataLabel(t){let i=Wt.Bottom;null!=t.value&&t.value<0&&(i=Wt.Top);const s=this.isOverflowing?this.dimensions.labelYPos:this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit());return new Gt(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),s,this.ID_DATA_PREFIX,t.value,this.styles,i,Wt.Center)}getScenarioLabel(t){return new Gt(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,Wt.Center,this.isPrimaryColumn?Wt.Left:Wt.Right)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceColumn||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(!0)}drawColumnDataLabel(t,i=new _t){var s;null===(s=this.label)||void 0===s||s.draw(this.isPrimaryColumn,t,i)}getFillStyle(t){var i,s,e,n;const r=this.columnBarStyles[this.dataPoint.getScenario()];return(null==r?void 0:r.fillpattern)&&(null===(i=this.styles.pattern.get(r.fillpattern))||void 0===i?void 0:i.pattern)?null===(n=null===(e=null===(s=this.styles)||void 0===s?void 0:s.pattern)||void 0===e?void 0:e.get(r.fillpattern))||void 0===n?void 0:n.pattern:this.convertToSVGStyle(t,"fill")}getScenarioStyle(){var t;return this.isVarianceColumn?null===(t=this.styles)||void 0===t?void 0:t.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()):this.columnBarStyles[this.dataPoint.getScenario()]}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}}class Js{constructor(t,i,s,e,n,r,a,h,o){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.FALLBACK_COLOUR="#000000",this.scenarioLabel=null,this._defaultMarkerPattern=null,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.position=t,this.markerGroup=i||null,this.markerPattern=s||this._defaultMarkerPattern,this.styles=n,this.barStyles=n?n.barStyles:null,this.scenario=e,!0!==(null==r?void 0:r.isEmpty())&&(this.hasData=!0,this.dimensions=this.createMarkerDimensions(r,a,o),this.scenarioLabel=this.getScenarioLabel(h,n,o))}draw(){if(this.isEmpty())return this;const t=this.convertToSVGStyle(this.barStyles[this.getScenario()],"stroke");let i=this.convertToSVGStyle(this.barStyles[this.getScenario()],"fill");const s=this.barStyles[this.getScenario()];if(null!=s&&s.fillpattern){const t=this.styles.pattern.get(s.fillpattern);null!=t&&(i=t.pattern)}return this.markerGroup.polygon(this.markerPattern.background).fill("#ffffff").cy(this.dimensions.yPos-this.dimensions.columnLength).cx(this.dimensions.xPos),this.markerGroup.polygon(this.markerPattern.foreground).fill(i).stroke(t).cy(this.dimensions.yPos-this.dimensions.columnLength).cx(this.dimensions.xPos),null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(),this}createMarkerDimensions(t,i,s){return t.getScaledUnit()<0?{clipped:!1,labelYPos:0,columnLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX(i,s),yPos:this.position.getMarkerPositionY(),scenarioLabelXPos:this.position.getMarkerPositionX(i,s)+this.position.getMarkerScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getMarkerPositionY()+Math.abs(t.getScaledUnit())}:{clipped:!1,labelYPos:0,columnLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX(i,s),yPos:this.position.getMarkerPositionY(),scenarioLabelXPos:this.position.getMarkerPositionX(i,s)+this.position.getMarkerScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getMarkerPositionY()-Math.abs(t.getScaledUnit())}}getScenarioLabel(t,i,s){return null==this.markerGroup?null:new Gt(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,Wt.Center,s?Wt.Right:Wt.Left)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}isEmpty(){return!1===this.hasData}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class qs{constructor(t,i,s,e,n){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.dataLabel=null,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=n,this.styles=i,this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(t,s,e),this.dataLabel=new Gt(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getNeedleDataLabelPositionY(this.dataPoint.getScaledPercentUnit()),this.ID_DATA_PREFIX,s.value,this.styles,Wt.Center,Wt.Center),this.dataLabel.setToRelativeVarianceLabel())}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.dataLabel)||void 0===i||i.updateGroup(t),this}draw(){var t;if(this.isEmpty())return this;const i=this.styles.varianceStyles[this.dataPoint.getVarianceStyle()],s=this.convertToSVGStyle(i,"stroke");let e=this.convertToSVGStyle(i,"fill");const n=this.convertToSVGStyle(this.styles.varianceStyles.ac,"stroke"),r=this.convertToSVGStyle(this.styles.varianceStyles.ac,"fill"),a=this.barStyles[this.dataPoint.getScenario()];if(null!=a&&a.fillpattern){const t=this.styles.pattern.get(a.fillpattern);null!=t&&(e=t.pattern)}this.dimensions.clipped?this.createClippedNeedleHead(e,s):this.createNeedleHead(n,r),this.barGroup.rect(this.position.getNeedleWidth(),this.dimensions.columnLength).cx(this.dimensions.xPos).y(this.dimensions.yPos).fill(e).stroke(s),null===(t=this.dataLabel)||void 0===t||t.draw()}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,columnLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getColumnCenterPositionX(s),yPos:t.getNeedlePositionY(),clipped:i.isClipped()}:{columnLength:i.getScaledPercentUnit(),xPos:t.getColumnCenterPositionX(s),yPos:t.getNeedlePositionY()-i.getScaledPercentUnit(),labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:i.isClipped()}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}createClippedNeedleHead(t,i){const s=this.barGroup.polygon("0,0 5,9 -5,9 0,0 0,5 5,13 -5,13 0,5").fill(t).cx(this.dimensions.xPos).cy(this.getHeadYPosition()).fill(t).stroke(i);null!=this.dataPoint.value&&this.dataPoint.value<0&&s.flip("y")}createNeedleHead(t,i){this.barGroup.rect(2*this.position.getNeedleWidth(),this.position.getNeedleHeadWidth()).cx(this.dimensions.xPos).cy(this.getHeadYPosition()).fill(t).stroke(i)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadYPosition(){let t=this.dimensions.yPos;return null!=this.dataPoint.value&&this.dataPoint.value<0&&(t+=this.dimensions.columnLength),t}}const Ks={ac:{markerFill:"#000000",markerStroke:"#000000",lineColor:"#000000"},pp:{markerFill:"#999999",markerStroke:"#999999",lineColor:"#999999"},fc:{markerFill:"#ffffff",markerStroke:"#000000",lineColor:"#000000",lineDashArray:"4,4"},pl:{markerFill:"#ffffff",markerStroke:"#000000",lineColor:"#000000"}};class Zs{constructor(t,i,s,e,n,r,a,h,o=null){this.MARKER_SIZE=8,this.LINE_WIDTH=2,this.ID_LINE_PREFIX="LINE",this.ID_MARKER_PREFIX="MARKER",this.ID_LABEL_PREFIX="LABEL",this.ESTIMATED_LABEL_WIDTH=56,this.ESTIMATED_LABEL_HEIGHT=24,this.position=t,this.styles=i,this.dataPoints=s,this.scenarioGroup=e,this.labelGroup=n,this.scenarioName=r,this.scenarioLabel=a,this.collisionManager=o}draw(t={percent:2,decimal:1},i=new _t){return this.drawGeometry(),this.drawLabels(t,i),this}drawGeometry(){if(0===this.dataPoints.length)return this;const t=this.getLineStyle();return this.drawLines(t),this.drawMarkers(t),this}drawLabels(t={percent:2,decimal:1},i=new _t){return 0===this.dataPoints.length||(this.drawScenarioLabel(),this.drawValueLabels(t,i)),this}getLineStyle(){var t,i;const s=(null===(i=null===(t=this.scenarioName)||void 0===t?void 0:t.slice(0,2))||void 0===i?void 0:i.toLowerCase())||"ac";return Ks[s]||Ks.ac}getScenarioVariant(){var t;const i=parseInt((null===(t=this.scenarioName)||void 0===t?void 0:t.slice(-1))||"1",10);return isNaN(i)?1:Math.min(Math.max(i,1),4)}drawSquareMarker(t,i,s,e){const n=this.MARKER_SIZE/2;t.rect(this.MARKER_SIZE,this.MARKER_SIZE).fill(e.markerFill).stroke({color:e.markerStroke,width:1}).move(i-n,s-n)}drawCircleMarker(t,i,s,e){t.circle(this.MARKER_SIZE).fill(e.markerFill).stroke({color:e.markerStroke,width:1}).center(i,s)}drawTriangleMarker(t,i,s,e){const n=this.MARKER_SIZE/2;t.polygon(`${i},${s-n} ${i-n},${s+n} ${i+n},${s+n}`).fill(e.markerFill).stroke({color:e.markerStroke,width:1})}drawDiamondMarker(t,i,s,e){const n=this.MARKER_SIZE/2;t.polygon(`${i},${s-n} ${i+n},${s} ${i},${s+n} ${i-n},${s}`).fill(e.markerFill).stroke({color:e.markerStroke,width:1})}drawLines(t){const i=this.scenarioGroup.group().id(this.ID_LINE_PREFIX);for(let s=1;s<this.dataPoints.length;s++){const e=this.dataPoints[s-1],n=this.dataPoints[s];if(e.dataPoint.isEmpty()||n.dataPoint.isEmpty())continue;const r=this.position.getColumnCenterPositionX(e.index),a=this.position.getColumnPositionY()-e.dataPoint.getScaledUnit(),h=this.position.getColumnCenterPositionX(n.index),o=this.position.getColumnPositionY()-n.dataPoint.getScaledUnit(),l=i.line([[r,a],[h,o]]).stroke({color:t.lineColor,width:this.LINE_WIDTH,linecap:"round"}).fill("none");t.lineDashArray&&l.attr("stroke-dasharray",t.lineDashArray)}}drawMarkers(t){const i=this.scenarioGroup.group().id(this.ID_MARKER_PREFIX),s=this.getScenarioVariant();for(const e of this.dataPoints){if(e.dataPoint.isEmpty())continue;const n=this.position.getColumnCenterPositionX(e.index),r=this.position.getColumnPositionY()-e.dataPoint.getScaledUnit();switch(s){case 2:this.drawCircleMarker(i,n,r,t);break;case 3:this.drawTriangleMarker(i,n,r,t);break;case 4:this.drawDiamondMarker(i,n,r,t);break;default:this.drawSquareMarker(i,n,r,t)}}}getLabelPositionPriority(t){const i=this.dataPoints[t];let s=null;for(let i=t+1;i<this.dataPoints.length;i++)if(!this.dataPoints[i].dataPoint.isEmpty()){s=this.dataPoints[i];break}let e=null;for(let i=t-1;i>=0;i--)if(!this.dataPoints[i].dataPoint.isEmpty()){e=this.dataPoints[i];break}const n=i.dataPoint.getScaledUnit();return e&&s&&e.dataPoint.getScaledUnit()>n&&s.dataPoint.getScaledUnit()>n?[Ft.Below,Ft.Left,Ft.Right,Ft.Above]:[Ft.Above,Ft.Left,Ft.Right,Ft.Below]}getScenarioType(){var t,i;return(null===(i=null===(t=this.scenarioName)||void 0===t?void 0:t.slice(0,2))||void 0===i?void 0:i.toLowerCase())||"ac"}drawValueLabels(t,i){const s=this.getScenarioType();for(let e=0;e<this.dataPoints.length;e++){const n=this.dataPoints[e];if(n.dataPoint.isEmpty()||null===n.dataPoint.value)continue;const r=this.position.getColumnCenterPositionX(n.index),a=this.position.getColumnPositionY()-n.dataPoint.getScaledUnit();let h=r,o=a-this.MARKER_SIZE/2-2,l=Wt.Bottom,c=Wt.Center;if(this.collisionManager){const t=this.getLabelPositionPriority(e),i=this.collisionManager.getOptimalPlacement(r,a,this.ESTIMATED_LABEL_WIDTH,this.ESTIMATED_LABEL_HEIGHT,n.index,this.MARKER_SIZE,s,t);if(null===i)continue;h=i.labelX,o=i.labelY,l=i.verticalHook,c=i.horizontalHook;const d=Object.assign(Object.assign({},i.bounds),{scenarioType:s});this.collisionManager.register(d)}new Gt(this.labelGroup,h,o,this.ID_LABEL_PREFIX,n.dataPoint.value,this.styles,l,c).draw(!0,t,i)}}drawScenarioLabel(){if(!this.scenarioLabel)return;let t=null;for(let i=this.dataPoints.length-1;i>=0;i--)if(!this.dataPoints[i].dataPoint.isEmpty()){t=this.dataPoints[i];break}if(!t)return;const i=this.position.getColumnCenterPositionX(t.index)+this.MARKER_SIZE+4,s=this.position.getColumnPositionY()-t.dataPoint.getScaledUnit(),e=this.getScenarioType();if(this.collisionManager){if(this.collisionManager.shouldHideScenarioLabel(i,s,e))return;this.collisionManager.registerScenarioLabel(i,s,e)}new Gt(this.labelGroup,i,s,"SCENARIO_LABEL",this.scenarioLabel,this.styles,Wt.Center,Wt.Left).forceStringTypeDraw()}}class Qs{constructor(t,i,s,e,n,r,a,h,o,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=e,this.baselineValue=n,this.segmentIndex=a,this.stackMode=h,this.totalValue=o,this.group=c,this.columnGroup=c.group().id(`stacked_col_${e}_seg_${a}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new _t){if(!this.hasData||null==this.dataPoint.value)return;const s=this.dataPoint.value,e=this.dataPoint.pixelPerUnit;let n,r;const a=this.position.getColumnPositionY();if(this.stackMode===pt.RELATIVE){const t=0!==this.totalValue?Math.abs(s)/Math.abs(this.totalValue):0,i=$t*e;n=t*i,r=a-this.baselineValue/Math.abs(this.totalValue)*i-n}else n=Math.abs(s*e),r=a-this.baselineValue*e-n;const h=this.position.getColumnCenterPositionX(this.index),o=this.position.getColumnWidth(),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],d={color:c},u={color:c,width:.5};if(this.columnGroup.rect(o,Math.max(n,.5)).fill(d).stroke(u).y(r).cx(h),n>=18){const e=r+n/2;if(this.stackMode===pt.RELATIVE||this.stackMode===pt.ABSOLUTE_RELATIVE){const i=(0!==this.totalValue?s/this.totalValue*100:0).toFixed(t.percent)+"%";new Gt(this.group,h,e,"STACK_SEG",i,this.styles,Wt.Center,Wt.Center).setSegmentFill(c).forceStringTypeDraw()}else new Gt(this.group,h,e,"STACK_SEG",s,this.styles,Wt.Center,Wt.Center).setSegmentFill(c).draw(!0,t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new _t){if(this.stackMode===pt.RELATIVE)return;const s=this.position.getColumnCenterPositionX(this.index),e=this.position.getColumnPositionY();new Gt(this.group,s,e-this.totalValue*this.dataPoint.pixelPerUnit-this.position.spacings.labelToColumn,"STACK_TOTAL",this.totalValue,this.styles,Wt.Bottom,Wt.Center).draw(!0,t,i)}}const te={ac:{fill:"#000000",opacity:.3,lineColor:"#000000"},pp:{fill:"#999999",opacity:.3,lineColor:"#999999"},fc:{fill:"#000000",opacity:.2,lineColor:"#000000",dashArray:"4,4"},pl:{fill:"#000000",opacity:.1,lineColor:"#000000"}},ie=[{fill:"#000000",opacity:.3},{fill:"#555555",opacity:.25},{fill:"#999999",opacity:.2},{fill:"#bbbbbb",opacity:.15},{fill:"#dddddd",opacity:.1}];class se{constructor(t,i,s,e,n,r){this.group=t.group().id(`area_fill_${n}`),this.upperPoints=i,this.lowerPoints=s,this.scenarioType=e,this.segmentIndex=n,this.isScenarioStack=r}draw(){if(this.upperPoints.length<2||this.lowerPoints.length<2)return;let t,i,s=`M ${this.upperPoints[0].x},${this.upperPoints[0].y}`;for(let t=1;t<this.upperPoints.length;t++)s+=` L ${this.upperPoints[t].x},${this.upperPoints[t].y}`;for(let t=this.lowerPoints.length-1;t>=0;t--)s+=` L ${this.lowerPoints[t].x},${this.lowerPoints[t].y}`;if(s+=" Z",this.isScenarioStack&&this.scenarioType){const s=this.scenarioType.slice(0,2).toLowerCase(),e=te[s]||te.ac;t=e.fill,i=e.opacity}else{const s=Math.min(this.segmentIndex,ie.length-1);t=ie[s].fill,i=ie[s].opacity}this.group.path(s).fill(t).opacity(i).stroke("none")}drawBoundaryLine(){if(this.upperPoints.length<2)return;let t,i="#000000";if(this.isScenarioStack&&this.scenarioType){const s=this.scenarioType.slice(0,2).toLowerCase(),e=te[s]||te.ac;i=e.lineColor,t=e.dashArray}const s=this.group.polyline(this.upperPoints.map((t=>[t.x,t.y]))).fill("none").stroke({color:i,width:1.5});t&&s.attr("stroke-dasharray",t)}}class ee{constructor(t,i,s,e,n,r,a,h){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.isVarianceLine=!1,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.previousDimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=n,this.isPrimaryLine=r,this.position=t,this.LineBarStyles=i.barStyles,this.scenarioGroup=a,this.styles=i,this.LineGroup=a.group().id(a.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(s,n,r),this.label=this.getDataLabel(s),this.scenarioLabel=this.getScenarioLabel(h)),this.previousDimensions=this.createDimensions(e,n-1,r)}setAsVariance(){var t;return this.isVarianceLine=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new _t){if(this.isEmpty())return this;const s=this.getScenarioStyle(),e=this.getFillStyle(s);null!=this.LineGroup&&this.LineGroup.line([[this.previousDimensions.xPos,this.previousDimensions.yPos],[this.dimensions.xPos,this.dimensions.yPos]]).fill(e).stroke({color:"#f06",width:3,linecap:"round"}),this.drawLineDataLabel(t,i),this.drawScenarioLabel()}createDimensions(t,i,s){return{clipped:!1,columnLength:t.getScaledUnit(),xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY()-t.getScaledUnit(),labelYPos:this.position.getColumnDataLabelPositionY(t.getScaledUnit()),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()-t.getScaledUnit()}}getDataLabel(t){let i=Wt.Bottom;return null!=t.value&&t.value<0&&(i=Wt.Top),new Gt(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit()),this.ID_DATA_PREFIX,t.value,this.styles,i,Wt.Center)}getScenarioLabel(t){return new Gt(this.scenarioGroup,0,0,this.ID_SCENARIO_PREFIX,t,this.styles,Wt.Bottom,Wt.Left)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceLine||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(!0)}drawLineDataLabel(t,i=new _t){var s;null===(s=this.label)||void 0===s||s.draw(this.isPrimaryLine,t,i)}getFillStyle(t){var i,s,e,n;const r=this.LineBarStyles[this.dataPoint.getScenario()];return(null==r?void 0:r.fillpattern)&&(null===(i=this.styles.pattern.get(r.fillpattern))||void 0===i?void 0:i.pattern)?null===(n=null===(e=null===(s=this.styles)||void 0===s?void 0:s.pattern)||void 0===e?void 0:e.get(r.fillpattern))||void 0===n?void 0:n.pattern:this.convertToSVGStyle(t,"fill")}getScenarioStyle(){var t;return this.isVarianceLine?null===(t=this.styles)||void 0===t?void 0:t.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()):this.LineBarStyles[this.dataPoint.getScenario()]}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}}class ne{constructor(t,i,s,e,n){this.pixelPerUnit=1,this.collisionManager=null,this.overflowConfig=null,this.i18n=n;const r=i.group().id("Scenario1"),a=i.group().id("Scenario2").insertBefore(r);this.svgGroups={parent:i,scenario1:r,scenario2:a,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=e}setOverflowConfig(t){this.overflowConfig=t}createLine(t,i,s,e){const n=this.svgGroups.scenario1.group().id(""+e),r=this.svgGroups.scenario1Label.group().id(""+e);let a=null;return this.isLastDataPoint(e-1)&&(a=t),new ee(this.position,this.styles,i,s,e,!1,n,a).updateLabelGroup(r)}createPrimaryBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new Xs(this.position,this.styles,t,i,!0,s,n,this.overflowConfig).updateLabelGroup(e)}createVarianceBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new Xs(this.position,this.styles,t,i,!0,s,n,this.overflowConfig).updateLabelGroup(e).setAsVariance()}createRelativeVarianceBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);return new qs(this.position,this.styles,t,i,s).updateLabelGroup(e)}createSecondaryBar(t,i){const s=this.svgGroups.scenario2.group().id(""+i);let e=null;return this.isFirstDataPoint(i)&&(e=`${this.i18n.get(t.scenario)||t.scenario}`),new Xs(this.position,this.styles,t,i,!1,s,e,this.overflowConfig)}createPrimaryMarker(t,i){const s=this.svgGroups.scenario3.group().id(""+i),e=this.styles.pattern.get("marker-right")||{foreground:"#000000",background:"#ffffff",bgOffset:0};let n=null;return this.isFirstDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new Js(this.position,s,e,t.scenario,this.styles,t,i,n,!0)}createSecondaryMarker(t,i){const s=this.svgGroups.scenario4.group().id(""+i),e=this.styles.pattern.get("marker-left")||{foreground:"#000000",background:"#ffffff",bgOffset:0};let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new Js(this.position,s,e,t.scenario,this.styles,t,i,n,!1)}isLastDataPoint(t){return this.elementCnt-1===t}isFirstDataPoint(t){return 0===t}setCollisionManager(t){this.collisionManager=t}moveLabelsToFront(){this.svgGroups.scenario1Label.front()}createLineSeries(t,i){const s=this.svgGroups.parent.group().id("LineSeries_"+i),e=this.svgGroups.scenario1Label.group().id("LineSeries_Label_"+i),n=`${this.i18n.get(i)||i}`;return new Zs(this.position,this.styles,t,s,e,i,n,this.i18n,this.collisionManager)}}var re,ae;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(re||(re={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(ae||(ae={}));class he{constructor(t,i,s,e,n,r=0){this.CSS_CATEGORIES="categories",this.dataModel=[],this.variancesDataModel=[],this.title="",this.smallestDataPointValue=new Fs(0,Hs.AC1,1,Hs.NEU),this.highestDataPointValue=new Fs(0,Hs.AC1,1,Hs.NEU),this.smallestVarianceDataPointValue=new Fs(0,Hs.AC1,1,Hs.NEU),this.highestVarianceDataPointValue=new Fs(0,Hs.AC1,1,Hs.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideAxisLabels=!1,this.axisScenario=Hs.AC1,this.fromExpr="",this.rowCount=0,this.axisCategoryArea={width:0,height:0},this.scenariosArea={width:0,height:0},this.state=re.DIRTY,this.i18n=new Map,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=N.DAY,this.locale="de",this.axisLabelsMode=ft.SMART,this.intervalSpanLimit=32,this.measureScale=new _t,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=vt.BAR,this.maxBars=28,this.stackConfig=null,this.scenarioPropOrder=[],this.lineFullWidth=!0,this.availableWidth=0,this.overflowConfig=null,this.lastScenarios=[],this.db=i,this.tableName=s,this.ruleSet=t||new Et,this.i18n=this.createI18n(new Map),this.styles=n,this.availableWidth=r,this.setConfig(e),this.position=this.createElementPosition(this.lastScenarios)}updatePosition(t){this.position=this.createElementPosition(t)}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new Et}setAvailableWidth(t){this.availableWidth=t}setAvailableHeight(t){this.pixelPerUnit<=0||t<=0?this.overflowConfig=null:null==this.stackConfig&&this.determineEffectiveChartMode()===vt.BAR?(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig&&this.updatePosition(this.lastScenarios)):this.overflowConfig=null}calculateOverflowConfig(t){const i=(this.isVarianceChart()?this.highestVarianceDataPointValue:this.highestDataPointValue).getScaledUnit();if(i<=0)return null;const s=this.styles.fontStyles.size,e=1.5*s,n=.3*s,r=t-(this.position.dataLabelHeight+this.position.spacings.labelToColumn+this.position.padding.top+this.position.padding.bottom+this.position.spacings.labelToAxis+s)-e-n,a=.8*s;if(r<=a)return null;const h=r-a;return i<=h?null:{cutHeight:r,overdriveZoneHeight:e,breakGap:n,maxOverflow:i-h,scenarioCutOffset:a}}setConfig(t){var i;this.state=re.DIRTY,this.scenarioPropOrder=[...t.scenarios];const s=this.sortScenariosbyVisualisationRules(t.scenarios);this.setSource(t.filter),this.hideAxisLabels=t.hideAxisLabels||!1,this.pixelPerUnit=t.pixelPerUnit,this.pixelPerPercentage=t.pixelPerPercentage,this.axisLabelsMode=t.axisLabelsMode,this.intervalSpanLimit=t.intervalSpanLimit,this.dateInterval=this.findDateInterval(t.dateInterval),this.dataModel=this.populateModel(s,this.dateInterval,t.level,t.sortOrder),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.title=t.title||Mt.translateScenarioLabel(null===(i=null==t?void 0:t.variances)||void 0===i?void 0:i.toString(),this.i18n),this.smallestDataPointValue=this.findSmallestDataPointValue(this.dataModel),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(this.dataModel),this.highestVarianceDataPointValue=this.findHighestDataPointValue(this.variancesDataModel),this.axisScenario=this.setAxisScenario(t.variances),this.leftSideOffsetForHorizontalSync=t.leftSideOffsetForHorizontalSync,this.measureScale=t.measureScale,this.measureUnit=t.measureUnit,this.dataFormatDigits=t.dataFormatDigits,this.showOverlayMedian=t.showOverlayMedian,this.showOverlayAvg=t.showOverlayAvg,this.chartMode=t.chartMode,this.maxBars=t.maxBars,this.stackConfig=t.stackConfig,this.lineFullWidth=t.lineFullWidth,this.lastScenarios=s,this.updatePosition(s)}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":Mt.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}sortScenariosbyVisualisationRules(t){const i=this;return[...t].sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))).reverse()}setI18n(t){this.i18n=this.createI18n(t)}setSource(t){var i,s;if(this.state=re.DIRTY,!this.tableName)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=g(this.tableName,t);try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(s=null===(i=t[0])||void 0===i?void 0:i.cnt)&&void 0!==s?s:0}catch(t){this.rowCount=0}}getAllocatedCanvasWidth(){const t=this.position.getAxisEndPositionX(),i=3*this.styles.fontStyles.size,s=Math.max(this.axisCategoryArea.width,this.scenariosArea.width);return Math.max(t+i,s>0?s+this.position.leftSideLabelLength:0)}getAllocatedCanvasHeight(){if(null==this.smallestVarianceDataPointValue.value||null==this.highestVarianceDataPointValue.value||null==this.smallestDataPointValue.value||null==this.highestDataPointValue.value)return 0;const t=this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===ae.RELATIVE)),i=this.position.getAxisPositionY(t),s=this.position.spacings.labelToAxis+this.position.dataLabelHeight+this.styles.padding.bottom;let e;if(this.isOnSameAxisSide())e=i+s;else{const t=this.isVarianceChart()?this.smallestVarianceDataPointValue:this.smallestDataPointValue;e=i+Math.abs(t.getScaledUnit())+this.position.spacings.labelToColumn+this.position.dataLabelHeight+s}const n=this.isOnSameAxisSide();return Math.max(e,n?this.axisCategoryArea.height+this.scenariosArea.height:this.scenariosArea.height)}toString(){const t=new xt;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}draw(t){this.cleanSVGforRedraw(t),this.state===re.DIRTY&&(this.state=re.UP_TO_DATE),this.isVarianceChart()?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?this.determineEffectiveChartMode()===vt.LINE?(this.drawStackedAreaScenarios(this.dataModel,t),this.drawAxisAndLabelsForLineChart(this.dataModel,t)):(this.drawStackedScenarios(this.dataModel,t),this.drawStackedHeaders(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)):this.determineEffectiveChartMode()===vt.LINE?(this.drawLineScenarios(this.dataModel,t),this.drawAxisAndLabelsForLineChart(this.dataModel,t)):(this.drawScenarios(this.dataModel,t),this.drawOverlayLayer(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t))}determineEffectiveChartMode(){return this.chartMode===vt.LINE||this.chartMode===vt.AUTO&&this.dataModel.length>this.maxBars?vt.LINE:vt.BAR}setPattern(t,i){this.styles.pattern.set(t,i)}hasNoData(){return 0===this.dataModel.length}isOnSameAxisSide(){return null!=this.smallestVarianceDataPointValue.value&&null!=this.highestVarianceDataPointValue.value&&null!=this.smallestDataPointValue.value&&null!=this.highestDataPointValue.value&&(this.isVarianceChart()?Math.sign(this.smallestVarianceDataPointValue.value)===Math.sign(this.highestVarianceDataPointValue.value)||0===this.smallestDataPointValue.value&&1===Math.sign(this.highestDataPointValue.value):Math.sign(this.smallestDataPointValue.value)===Math.sign(this.highestDataPointValue.value)||0===this.smallestDataPointValue.value&&1===Math.sign(this.highestDataPointValue.value))}createI18n(t){this.state=re.DIRTY;const i=new Map([["SEPERATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pl3","PL3"],["ac4","AC4"],["pp4","PY4"],["fc4","FC4"],["pl4","PL4"],["category"," "],["operation"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return new Map([...i,...t])}createElementPosition(t){var i;let s;const e=Lt(t.filter(((t,i)=>1===i||2===i)).map((t=>Mt.translateScenarioLabel(t,this.i18n))).reduce(((t,i)=>t.length<i.length?i:t),""),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,n=this.calculateTitleLength(this.leftSideOffsetForHorizontalSync);let r,a;if(s=e>n?e:n,null!=this.position&&(s+=this.position.spacings.labelToColumn),this.leftSideOffsetForHorizontalSync>-1&&(s=this.leftSideOffsetForHorizontalSync),this.isVarianceChart()?(r=this.smallestVarianceDataPointValue,a=this.highestVarianceDataPointValue):(r=this.smallestDataPointValue,a=this.highestDataPointValue),(null===(i=this.stackConfig)||void 0===i?void 0:i.mode)===pt.RELATIVE&&(a=new Fs($t,a.scenario,this.pixelPerUnit,a.variance)),this.overflowConfig){const{cutHeight:t,overdriveZoneHeight:i,breakGap:s}=this.overflowConfig;a=new Fs(t+i+s,a.scenario,1,a.variance)}let h=this.styles.scaleFactors;const o=this.determineEffectiveChartMode();if(this.lineFullWidth&&this.availableWidth>0&&this.dataModel.length>0&&!this.isVarianceChart()&&o===vt.LINE){const t=this.styles.fontStyles.size,i=this.styles.padding,e=this.styles.scaleFactors,n=this.availableWidth-(i.left+i.right+t*e.scenarioOffset+s+t*e.columnWidth);if(n>0){const i=Math.max(n/this.dataModel.length/t,1.2*e.columnWidth),s=new Cs;Object.assign(s,e),s.categoryWidth=i,h=s}}return new Us(new Ds(this.styles.padding),h,this.styles.fontStyles,r,a,this.dataModel.length,s)}calculateTitleLength(t){let i="_______";i.length<this.title.length&&(i=this.title);const s=Lt(i,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;return s<t?t:s}setAxisScenario(t){let i=Hs.AC1;if(null!=t&&t.length>0){const s=new Tt(t.toString());s.isValid&&(i=s.delta)}return null===i&&(i=Hs.AC1),i}populateModel(t,i,s,e){if(0===this.rowCount||!this.fromExpr)return[];let n=this.queryDataSet(i,"","");return this.detectNaNCells(t,n),n=this.leftOuterJoinDates(n,i),this.createDataRows(n,t)}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new Tt(t);!0===s.isValid?0!==i[s.base+"_cnt"]&&0!==i[s.delta+"_cnt"]||(i[t]=Number.NaN):0===i[t+"_cnt"]&&(i[t]=Number.NaN)})),i)))}findDateInterval(t){var i,s,e;if(t!==N.AUTO)return t;const n=this.queryMinMaxDates();let r=N.DAY;return null!=(null===(i=n[0])||void 0===i?void 0:i.mindate)&&(r=(new D).calculateDistanceType(null===(s=n[0])||void 0===s?void 0:s.mindate,null===(e=n[0])||void 0===e?void 0:e.maxdate,this.intervalSpanLimit)),r}queryMinMaxDates(){var t,i;let s;try{s=this.db.exec(`SELECT MAX(date) as maxdate, MIN(date) as mindate FROM ${this.fromExpr}`)}catch(t){return console.error("TimeChart: min/max date query failed",t),[{}]}return null!=(null===(t=s[0])||void 0===t?void 0:t.mindate)&&(s[0].mindate=he.coerceDateTime(s[0].mindate)),null!=(null===(i=s[0])||void 0===i?void 0:i.maxdate)&&(s[0].maxdate=he.coerceDateTime(s[0].maxdate)),s}static coerceDateTime(t){if(null!=t){if("string"==typeof t){const i=v.fromISO(t);return i.isValid?i:void 0}if("number"==typeof t){const i=v.fromMillis(t);return i.isValid?i:void 0}return"boolean"==typeof t.isValid?t:void 0}}queryDataSet(t,i,s){const e=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],n=`normalizeDate([date], '${t}' , '${this.locale}') as calcdate`;let r;try{r=this.db.exec(`SELECT p.calcdate ${i},\n ${e.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(",")}\n\n FROM (SELECT ${n} ${i},\n ac1,\n ac2,\n ac3,\n ac4,\n pp1,\n pp2,\n pp3,\n pp4,\n fc1,\n fc2,\n fc3,\n fc4,\n pl1,\n pl2,\n pl3,\n pl4\n FROM ${this.fromExpr}) as p\n GROUP BY calcdate ${s}\n ORDER BY calcdate asc`)}catch(t){return console.error("TimeChart: queryDataSet failed",t),[]}return r}createDataRows(t,i){const s=[];return t.forEach(((t,e)=>{s.push({id:e,category:t.category,type:ae.NONE,date:t.calcdate,scenario1:new Fs(t[i[0]],i[0],this.pixelPerUnit,Hs.NEU),scenario2:new Fs(t[i[1]],i[1],this.pixelPerUnit,Hs.NEU),scenario3:new Fs(t[i[2]],i[2],this.pixelPerUnit,Hs.NEU),scenario4:new Fs(t[i[3]],i[3],this.pixelPerUnit,Hs.NEU)})})),s}findSmallestDataPointValue(t){const i=this.isVarianceChart()?this.pixelPerPercentage:this.pixelPerUnit;let s=new Fs(0,"default",i,Hs.NEU);for(const i of t)for(const t of[i.scenario1,i.scenario2,i.scenario3,i.scenario4])t&&null!=t.value&&t.value<Number(s.value)&&(s=t);return s}findHighestDataPointValue(t){const i=this.isVarianceChart()?this.pixelPerPercentage:this.pixelPerUnit;let s=new Fs(0,"default",i,Hs.NEU);for(const i of t)for(const t of[i.scenario1,i.scenario2,i.scenario3,i.scenario4])null!=t&&t.value>Number(s.value)&&(s=t);return s}populateVarianceModel(t,i){const s=[];if(null==t||0===t.length)return s;let e=null;null!=i&&i.length>0&&(e=i[0]);for(const n in t){const r=new Tt(t[n]);if(r.isValid){const t=this.mapScenarios(r,e),n=r.direction,a="dr"===r.type?this.pixelPerPercentage:this.pixelPerUnit;for(const e in i)s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?ae.RELATIVE:ae.ABSOLUTE,date:i[e].date,scenario1:new Fs(this.calculateVariance(r,i[e],t),r.delta,a,n),scenario2:new Fs(null,null,null,null),scenario3:new Fs(null,null,null,null),scenario4:new Fs(null,null,null,null)})}}return s}calculateVariance(t,i,s){const e=s.get(t.base),n=s.get(t.delta);return null==e||null==n||null==i[e].value||null==i[n].value?null:t.type===ae.RELATIVE?(i[e].value-i[n].value)/i[n].value:i[e].value-i[n].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((e=>{i[e].scenario===t.delta?s.set(t.delta,e):i[e].scenario===t.base&&s.set(t.base,e)})),s}cleanSVGforRedraw(t){t.clear()}isVarianceChart(){return this.variancesDataModel&&this.variancesDataModel.length>0}createDateFactory(){return new D}drawAxisAndLabels(t,i){const s=this.createDateFactory(),e=i.group().id("AxisAndDateLables");let n=!1;if(!1===this.hideAxisLabels)t.forEach(((t,i)=>{let r=Wt.Top,a=this.position.spacings.labelToAxis;t.scenario1.value<0&&(r=Wt.Bottom,a*=-1),t.type===ae.RELATIVE&&(n=!0);let h=s.getDateString(t.date,this.dateInterval);this.axisLabelsMode===ft.SMART?(h=s.getSmartDateString(t.date,this.dateInterval),0===i&&this.dateInterval!==N.YEAR&&(h=s.getShortDateString(t.date,this.dateInterval))):this.axisLabelsMode===ft.SHORT&&(h=s.getShortDateString(t.date,this.dateInterval)),new Gt(e,this.position.getColumnCenterPositionX(i),this.position.getAxisPositionY(n)+a,"",h,this.styles,r,Wt.Center).forceStringTypeDraw()}));else{const i=null==t?void 0:t[0];i&&i.type===ae.RELATIVE&&(n=!0)}new js({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e).draw(),this.axisCategoryArea={height:e.height(),width:e.width()}}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new ne(this.position,s,this.styles,t.length,this.i18n);e.setOverflowConfig(this.overflowConfig);let n=!1;t.forEach(((t,i)=>{e.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),e.createSecondaryBar(t.scenario2,i).draw(),e.createPrimaryMarker(t.scenario3,i).draw(),e.createSecondaryMarker(t.scenario4,i).draw(),!1===t.scenario1.isEmpty()&&(n=!0)}));let r=0;!1===n&&(r=this.isOnSameAxisSide()?this.position.dataLabelHeight:2*this.position.dataLabelHeight),this.scenariosArea={height:s.height()+this.styles.padding.top+this.styles.padding.bottom+r,width:s.width()+this.position.spacings.columnWidth}}drawLineScenarios(t,i){var s,e;const n=i.group().id("LineScenarios"),r=new Yt,a=new ne(this.position,n,this.styles,t.length,this.i18n);a.setCollisionManager(r);const h=["ac1","pp1","fc1","pl1"],o=[[],[],[],[]];t.forEach(((t,i)=>{["scenario1","scenario2","scenario3","scenario4"].forEach(((s,e)=>{t[s]&&o[e].push({dataPoint:t[s],index:i})}))}));const l=[];for(let t=0;t<o.length;t++){const i=o[t];if(i.length>0&&i.some((t=>!t.dataPoint.isEmpty()))){const n=(null===(e=null===(s=i[0])||void 0===s?void 0:s.dataPoint)||void 0===e?void 0:e.scenario)||h[t],r=n.slice(0,2).toLowerCase();l.push({points:i,scenarioName:n,scenarioType:r})}}l.sort(((t,i)=>(It[i.scenarioType]||99)-(It[t.scenarioType]||99)));const c=[];for(const t of l){const i=a.createLineSeries(t.points,t.scenarioName);c.push({series:i,scenarioType:t.scenarioType})}for(const t of c)t.series.drawGeometry();a.moveLabelsToFront();const d=[...c].sort(((t,i)=>(It[t.scenarioType]||99)-(It[i.scenarioType]||99)));for(const t of d)t.series.drawLabels(this.dataFormatDigits,this.measureScale);const u=this.position.getColumnPositionY();this.scenariosArea={height:Math.max(n.height()+this.styles.padding.top,u)+this.styles.padding.bottom,width:n.width()+this.position.spacings.columnWidth}}drawAxisAndLabelsForLineChart(t,i){const s=this.createDateFactory(),e=i.group().id("AxisAndDateLabelsLine"),n=!1,r=t.length-1;!1===this.hideAxisLabels&&t.forEach(((i,a)=>{if(!this.shouldShowLineChartAxisLabel(t,a))return;let h,o=Wt.Top,l=this.position.spacings.labelToAxis;i.scenario1.value<0&&(o=Wt.Bottom,l*=-1),this.lineFullWidth&&this.availableWidth>0?this.axisLabelsMode===ft.SMART?(h=s.getSmartDateString(i.date,this.dateInterval),0===a&&this.dateInterval!==N.YEAR&&(h=s.getShortDateString(i.date,this.dateInterval))):h=this.axisLabelsMode===ft.SHORT?s.getShortDateString(i.date,this.dateInterval):s.getDateString(i.date,this.dateInterval):h=s.getShortDateString(i.date,this.dateInterval),new Gt(e,this.position.getColumnCenterPositionX(a),this.position.getAxisPositionY(n)+l,"",h,this.styles,o,Wt.Center).forceStringTypeDraw(),a>0&&a<r&&this.isYearChange(t,a)&&this.drawYearSeparatorLine(e,a,n)})),new js({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e).draw(),this.axisCategoryArea={height:e.height(),width:e.width()}}shouldShowLineChartAxisLabel(t,i){return!!(this.lineFullWidth&&this.availableWidth>0)||(0===i||i===t.length-1||this.isYearChange(t,i))}isYearChange(t,i){var s,e;if(0===i)return!1;const n=null===(s=t[i])||void 0===s?void 0:s.date,r=null===(e=t[i-1])||void 0===e?void 0:e.date;return!(!n||!r)&&n.year!==r.year}drawYearSeparatorLine(t,i,s){const e=this.position.getColumnCenterPositionX(i)-this.position.spacings.columnWidth/2,n=this.position.columnValue.max.getScaledUnit()+this.position.dataLabelHeight,r=this.position.getAxisPositionY(s)-n,a=this.position.getAxisPositionY(s);t.line([[e,r],[e,a]]).stroke({color:"#999999",width:1,dasharray:"4,4"}).attr("stroke-dasharray","4,4")}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new ne(this.position,s,this.styles,t.length,this.i18n);return e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===ae.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw():e.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)})),this.scenariosArea={height:s.height()+this.styles.padding.top+this.styles.padding.bottom,width:s.width()+this.position.spacings.columnWidth},s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const e=i.indexOf(t.scenario),n=i.indexOf(s.scenario);return(-1===e?i.length:e)-(-1===n?i.length:n)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),e=this.stackConfig.by===dt.SCENARIOS;t.forEach(((t,i)=>{const n=["scenario1","scenario2","scenario3","scenario4"],r=[];if(e){for(const i of n){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&r.push({value:s.value,scenario:s.scenario,dataPoint:s})}this.sortSegmentsByPropOrder(r)}else{const i=t.scenario1;i&&!i.isEmpty()&&null!=i.value&&r.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0!==r.length)if((e?new Set(r.map((t=>Pt(t.scenario)))):new Set).size>1){const t=new Map;for(const i of r){const s=Pt(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const e=[];for(const i of At)t.has(i)&&(e.push({prefix:i,segments:t.get(i)}),t.delete(i));for(const[i,s]of t)e.push({prefix:i,segments:s});e.forEach(((t,n)=>{const r=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),a=e.length-1-n;let h=0,o=null;t.segments.forEach((t=>{const e=new Qs(this.position,this.styles,t.dataPoint,i,h,t.scenario,a,this.stackConfig.mode,r,!0,s);e.draw(this.dataFormatDigits,this.measureScale),h+=Math.abs(t.value),o=e})),o&&o.drawTotalLabel(this.dataFormatDigits,this.measureScale)}))}else{"asc"===this.stackConfig.order?r.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&r.sort(((t,i)=>i.value-t.value));const t=r.reduce(((t,i)=>t+Math.abs(i.value)),0);let n=0,a=null;r.forEach(((r,h)=>{const o=new Qs(this.position,this.styles,r.dataPoint,i,n,r.scenario,h,this.stackConfig.mode,t,e,s);o.draw(this.dataFormatDigits,this.measureScale),n+=Math.abs(r.value),a=o})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}})),this.scenariosArea={height:s.height()+this.styles.padding.top+this.styles.padding.bottom,width:s.width()+this.position.spacings.columnWidth}}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;if(this.stackConfig.by!==dt.SCENARIOS)return;const s=i.group().id("StackedHeaders"),e=t[0],n=["scenario1","scenario2","scenario3","scenario4"],r=[];for(const t of n){const i=e[t];i&&!i.isEmpty()&&null!=i.value&&r.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===r.length)return;this.sortSegmentsByPropOrder(r);const a=new Set(r.map((t=>Pt(t.scenario)))),h=this.position.getColumnPositionY(),o=this.position.getColumnCenterPositionX(0)-this.position.getColumnWidth()/2-this.position.spacings.labelToColumn;if(a.size>1){const t=new Map;for(const i of r){const s=Pt(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const i=[];for(const s of At)t.has(s)&&(i.push({prefix:s,segments:t.get(s)}),t.delete(s));for(const[s,e]of t)i.push({prefix:s,segments:e});i.forEach(((t,e)=>{const n=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),r=t.segments[0].dataPoint.pixelPerUnit,a=this.stackConfig.mode===pt.RELATIVE?$t*r:n*r,l=e===i.length-1?h-a/2:h-a,c=this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase();new Gt(s,o,l,"STACK_HEADER",c,this.styles,Wt.Center,Wt.Right).forceStringTypeDraw()}))}else{"asc"===this.stackConfig.order?r.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&r.sort(((t,i)=>i.value-t.value));const t=r.reduce(((t,i)=>t+Math.abs(i.value)),0),i=r[0].dataPoint.pixelPerUnit;let e=0;r.forEach((n=>{let r;r=this.stackConfig.mode===pt.RELATIVE?(0!==t?Math.abs(n.value)/t:0)*$t*i:Math.abs(n.value*i);const a=h-e-r/2,l=this.i18n.get(n.scenario)||n.scenario;new Gt(s,o,a,"STACK_HEADER",l,this.styles,Wt.Center,Wt.Right).forceStringTypeDraw(),e+=r}))}}drawStackedAreaScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedAreaScenarios"),e=this.stackConfig.by===dt.SCENARIOS,n=this.stackConfig.mode,r=["scenario1","scenario2","scenario3","scenario4"];if(0===(e?r.filter((i=>t.some((t=>t[i]&&!t[i].isEmpty())))).length:1))return;const a=[],h=[],o=[];for(const i of r)t.some((t=>t[i]&&!t[i].isEmpty()))&&o.push(i);if(e&&this.scenarioPropOrder.length>0){const i=this.scenarioPropOrder;o.sort(((s,e)=>{var n,r,a,h;const o=i.indexOf(null!==(r=null===(n=t[0][s])||void 0===n?void 0:n.scenario)&&void 0!==r?r:""),l=i.indexOf(null!==(h=null===(a=t[0][e])||void 0===a?void 0:a.scenario)&&void 0!==h?h:"");return(-1===o?i.length:o)-(-1===l?i.length:l)}))}for(let i=0;i<o.length;i++){const s=o[i],e=[];for(let r=0;r<t.length;r++){const h=t[r][s],l=h&&!h.isEmpty()&&null!=h.value?h.value:0,c=i>0?a[i-1][r]:0;if(n===pt.RELATIVE){const i=o.reduce(((i,s)=>{const e=t[r][s];return i+(e&&!e.isEmpty()&&null!=e.value?Math.abs(e.value):0)}),0),s=0!==i?Math.abs(l)/i:0;e.push(c+s)}else e.push(c+l)}a.push(e);const r=t[0][s];h.push((null==r?void 0:r.scenario)||"ac1")}const l=this.position.getColumnPositionY(),c=this.pixelPerUnit,d=t=>t.map(((t,i)=>({x:this.position.getColumnCenterPositionX(i),y:l-(n===pt.RELATIVE?t*$t*c:t*c)}))),u=t.map(((t,i)=>({x:this.position.getColumnCenterPositionX(i),y:l})));for(let t=0;t<a.length;t++){const i=d(a[t]),n=0===t?u:d(a[t-1]),r=new se(s,i,n,e?h[t]:null,t,e);r.draw(),r.drawBoundaryLine()}this.scenariosArea={height:s.height()+this.styles.padding.top+this.styles.padding.bottom,width:s.width()+this.position.spacings.columnWidth}}drawOverlayLayer(t,i){const s=i.group().id("Overlay"),e=new ne(this.position,s,this.styles,t.length,this.i18n);if(!0===this.showOverlayAvg){let i=null;const s=function(t){const i=t.reduce(((t,i)=>{var s;return t+((null===(s=i.scenario1)||void 0===s?void 0:s.value)||0)}),0),s=t.filter((t=>{var i;return void 0!==(null===(i=t.scenario1)||void 0===i?void 0:i.value)})).length,e=s>0?i/s:0,n=Object.assign(Object.assign({},t[0]),{scenario1:new Fs(e,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),r=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new Fs(e,t[t.length-1].scenario1.scenario,t[t.length-1].scenario1.pixelPerUnit,t[t.length-1].scenario1.variance)});return[n,...t.map((t=>Object.assign(Object.assign({},t),{scenario1:new Fs(e,t.scenario1.scenario,t.scenario1.pixelPerUnit,t.scenario1.variance)}))),r]}(t);s.forEach(((t,s)=>{null!=i&&e.createLine(`Ø ${this.i18n.get(t.scenario1.scenario)||t.scenario1.scenario}`,t.scenario1,i,s-1).draw(this.dataFormatDigits,this.measureScale),i=t.scenario1}))}if(!0===this.showOverlayMedian){let i=null;const s=function(t){const i=t.map((t=>{var i;return null===(i=t.scenario1)||void 0===i?void 0:i.value})).filter((t=>void 0!==t)).sort(((t,i)=>t-i)),s=i.length%2==0?(i[i.length/2-1]+i[i.length/2])/2:i[Math.floor(i.length/2)],e=Object.assign(Object.assign({},t[0]),{scenario1:new Fs(s,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),n=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new Fs(s,t[t.length-1].scenario1.scenario,t[t.length-1].scenario1.pixelPerUnit,t[t.length-1].scenario1.variance)});return[e,...t.map((t=>Object.assign(Object.assign({},t),{scenario1:new Fs(s,t.scenario1.scenario,t.scenario1.pixelPerUnit,t.scenario1.variance)}))),n]}(t);s.forEach(((t,s)=>{null!=i&&e.createLine(`Mdn ${this.i18n.get(t.scenario1.scenario)||t.scenario1.scenario}`,t.scenario1,i,s-1).draw(this.dataFormatDigits,this.measureScale),i=t.scenario1}))}}leftOuterJoinDates(t,i){const s=t.map((t=>t.calcdate)).filter((t=>null!=t&&"boolean"==typeof t.isValid&&t.isValid));if(0===s.length)return t;const e=v.max(...s),n=v.min(...s),r=(new D).datesBetween(n,e,i,this.intervalSpanLimit),a=new Map;return r.forEach(((t,i)=>{a.set(t.toISO(),{id:i,calcdate:t,category:null,ac1:null,ac2:null,ac3:null,ac4:null,pp1:null,pp2:null,pp3:null,pp4:null,fc1:null,fc2:null,fc3:null,fc4:null,pl1:null,pl2:null,pl3:null,pl4:null,isEmpty:!0})})),t.forEach((t=>{const i=t.calcdate.toISO(),s=a.get(i);s&&s.isEmpty&&a.set(i,{id:s.id,calcdate:t.calcdate,category:t.category,ac1:t.ac1,ac2:t.ac2,ac3:t.ac3,ac4:t.ac4,pp1:t.pp1,pp2:t.pp2,pp3:t.pp3,pp4:t.pp4,fc1:t.fc1,fc2:t.fc2,fc3:t.fc3,fc4:t.fc4,pl1:t.pl1,pl2:t.pl2,pl3:t.pl3,pl4:t.pl4,isEmpty:!1})})),Array.from(a.values())}}class oe{constructor(t,i){this.data=t,this.scenarios=i,this.variances=[],this.title="",this.hideAxisLabels=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.sortOrder=new tt(new os).default(),this.level=ct.CATEGORY,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=N.AUTO,this.axisLabelsMode=ft.SMART,this.intervalSpanLimit=28,this.filter="",this.measureScale=new _t,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.showOverlayMedian=!0,this.showOverlayAvg=!0,this.chartMode=vt.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0}}class le{constructor(t,i,s,e,n,r){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=e,this.db=n,this.fromExpr=r}adapt(t){const i=Q.adaptArray(t.data,this.dataRowAdapter),s=Q.adaptArray(t.scenarios,this.stringAdapter),e=new oe(i,s);return Ot.isArray(t.variances)&&(e.variances=Q.adaptArray(t.variances,this.stringAdapter)),Ot.isString(t.title)&&(e.title=t.title),Ot.isBoolean(t.hideAxisLabels)&&(e.hideAxisLabels=t.hideAxisLabels),Ot.isNumber(t.pixelPerUnit)&&(e.pixelPerUnit=t.pixelPerUnit),Ot.isNumber(t.pixelPerPercentage)&&(e.pixelPerPercentage=t.pixelPerPercentage),Ot.isNumber(t.limit)&&(e.limit=t.limit),Ot.isExisting(t.sortOrder)&&(e.sortOrder=this.orderAdapter.adapt(t.sortOrder)),Ot.isExisting(t.level)&&(e.level=t.level),Ot.isExisting(t.dateInterval)&&(e.dateInterval=t.dateInterval),Ot.isExisting(t.axisLabelsMode)&&(e.axisLabelsMode=t.axisLabelsMode),Ot.isNumber(t.leftSideOffsetForHorizontalSync)&&(e.leftSideOffsetForHorizontalSync=t.leftSideOffsetForHorizontalSync),Ot.isNumber(t.intervalSpanLimit)&&(e.intervalSpanLimit=t.intervalSpanLimit),Ot.isString(t.filter)&&(e.filter=t.filter),Ot.isExisting(t.measureScale)&&(e.measureScale=hs.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale)),Ot.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),Ot.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),Ot.isExisting(t.dataFormatDigits)&&(e.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),Ot.isBoolean(t.showOverlayAvg)&&(e.showOverlayAvg=t.showOverlayAvg),Ot.isBoolean(t.showOverlayMedian)&&(e.showOverlayMedian=t.showOverlayMedian),Ot.isExisting(t.chartMode)&&(e.chartMode=t.chartMode),Ot.isNumber(t.maxBars)&&(e.maxBars=t.maxBars),Ot.isExisting(t.stackConfig)&&(e.stackConfig=t.stackConfig),Ot.isBoolean(t.lineFullWidth)&&(e.lineFullWidth=t.lineFullWidth),e}default(){return new oe([],[])}}const ce=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.scenarios=[],this.variances=[],this.hideAxisLabels=!1,this.pixelPerUnit=2,this.pixelPerPercentage=50,this.limit=0,this.leftSideOffsetForHorizontalSync=-1,this.i18n=new Map,this.order={hierarchy:[],direction:T.ASC},this.level=ct.CATEGORY,this.dateInterval=N.AUTO,this.intervalSpanLimit=28,this.axisLabelsMode=ft.SMART,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=vt.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.containerWidth=0,this.dataFormatDigits={percent:2,decimal:1},this.parentDimensions={width:0,height:0}}getDb(){return this.stores||(this.stores=d(this.element)),this.stores.db.db}render(){var t,e,n;if(void 0===this.chart)return i(s,null);if(this.chart.hasNoData()){const t=this.i18n.get("NO_DATA")||"==No Data==";return i(s,null,i("p",{class:"warning"},t))}return i(s,null,i("div",{innerHTML:null===(t=this.pattern)||void 0===t?void 0:t.toString(),class:"hidePatternContainer"}),i("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(e=this.chart)||void 0===e?void 0:e.getFooter()),i("div",{innerHTML:null===(n=this.chart)||void 0===n?void 0:n.toString()}))}async componentWillLoad(){var t;const i=this.prepareConfig(),s=this.prepareStyle(),e=this.containerWidth||0;this.chart=new he(new Et(this.ruleSetConfig),this.getDb(),this.tableName,i,s,e),this.chart.setI18n(this.i18n),this.autoFitScaling(i,s),this.chart.setAvailableHeight((null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),this.pattern=new Ws(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}async componentWillUpdate(){var t;if(null==this.chart)return;const i=this.prepareConfig(),s=this.prepareStyle();this.chart.setI18n(this.i18n),this.chart.setStyles(s),this.chart.setAvailableWidth(this.containerWidth||0),this.chart.setRuleSet(new Et(this.ruleSetConfig)),this.chart.setConfig(i),this.autoFitScaling(i,s),this.chart.setAvailableHeight((null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),this.pattern=new Ws(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}autoFitScaling(t,i){var s;const e=t.pixelPerUnit<=0,n=t.pixelPerPercentage<=0;if(!e&&!n)return;const r=null===(s=this.parentDimensions)||void 0===s?void 0:s.height,a=this.containerWidth||0;if(!r||r<=0)return e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=50),this.chart=new he(new Et(this.ruleSetConfig),this.getDb(),this.tableName,t,i,a),void this.chart.setI18n(this.i18n);e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=1),this.chart=new he(new Et(this.ruleSetConfig),this.getDb(),this.tableName,t,i,a),this.chart.setI18n(this.i18n),this.chart.toString();const h=this.chart.getAllocatedCanvasHeight();if(h<=0)return;const o=.9*r/h;e&&(t.pixelPerUnit=o),n&&(t.pixelPerPercentage=o),this.chart=new he(new Et(this.ruleSetConfig),this.getDb(),this.tableName,t,i,a),this.chart.setI18n(this.i18n)}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=this.tableName?g(this.tableName,this.filter):"";return new le(new Is,new tt(new os),new os,new Ls,t,i).adapt({scenarios:this.scenarios,variances:this.variances,title:this.chartTitle,hideAxisLabels:this.hideAxisLabels,pixelPerUnit:this.pixelPerUnit,pixelPerPercentage:this.pixelPerPercentage,level:this.level,dateInterval:this.dateInterval,axisLabelsMode:this.axisLabelsMode,limit:this.limit,sortOrder:this.order,leftSideOffsetForHorizontalSync:this.leftSideOffsetForHorizontalSync,intervalSpanLimit:this.intervalSpanLimit,filter:this.filter,measureScale:this.measureScale,measureUnit:this.measureUnit,showMeasureScale:this.showMeasureScale,dataFormatDigits:this.dataFormatDigits,showOverlayMedian:this.showOverlayMedian,showOverlayAvg:this.showOverlayAvg,chartMode:this.chartMode,maxBars:this.maxBars,stackConfig:this.stackConfig,lineFullWidth:this.lineFullWidth})}prepareStyle(){return new zs(new Ns,new Ct,new Nt(new Ut),new Ps(new Ut),new Dt).adapt(this.styles)}get element(){return e(this)}};ce.style=':host{position:relative;display:inline-block}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-default{stroke:black;stroke-width:0.1em}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.hide{opacity:0}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}';class de{constructor(t,i,s,e,n,r,a,h,o){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=i,this.value=s,this.prefix=r||"",this.cssStyle=e||"",this.prefixStyle=a||"prefix",this.type=n,this.mark=void 0,this.colSpan=h||1,this.measureScale=o||1}getAsHeaderList(){if(null==this.value)return[""];const t=[];for(const i of this.value.toString().split("<br/>"))t.push(i);return t}draw(t){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 s=t.percent,e=t.percent;return"decimal"===this.type&&(i=+i/this.measureScale,s=t.decimal,e=t.decimal),Mt.number(Number(i),this.type,s,e)}drawPrefix(){return null==this.prefix?"":this.prefix}}class ue{constructor(t,i,s){this.index=t,this.groupindex=i,this.type=s,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case Vi.HEADER:return"groupheader";case Vi.SEPERATORLINE:return"";case Vi.DRILLELEMENT:return"ofit";case Vi.PARTELEMENT:return"partof";case Vi.STANDARD:return"";case Vi.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,i,s,e,n,r,a,h,o,l=!1,c,d=1,u){let p=r;"category"===i&&null!=h&&(p=`category-${h.toString()}`),this.type===Vi.HEADER?p="headerlabel":this.type===Vi.SEPERATORLINE&&(p=i),this.type===Vi.PARTELEMENT&&("percent"===e&&(t="-"),"category"!==i&&"operation"!==i&&(e="percent",p="")),"-"===t&&(p="");let f="prefix-first";a&&(f="prefix-second"),s&&(p=`${p} ${s}`);const v=new de(i,this.elements.length,t,p,e,n,f,d,o);v.isBarChart=l,v.columnStats=c,v.waterfall=u,this.elements.push(v)}}const pe={positive:{stroke:"#008f96",fill:"#008f96",fillpattern:"solid"},negative:{stroke:"#ff0000",fill:"#ff0000",fillpattern:"solid"},neutral:{stroke:"#808080",fill:"#808080",fillpattern:"outlined"},scenarios:{ac:{stroke:"#404040",fill:"#404040",fillpattern:"solid"},pp:{stroke:"#A6A6A6",fill:"#A6A6A6",fillpattern:"solid"},fc:{stroke:"#404040",fill:"#ffffff",fillpattern:"hatched"},pl:{stroke:"#404040",fill:"#ffffff",fillpattern:"outlined"}},fontColor:"#000000",fontSize:11,fontFamily:"'Noto Sans', sans-serif",unitScaling:.01,percentageScaling:.5,scaleFactor:1},fe="#666666";function ve(t,i){return`pattern-${t}-${i.replace("#","")}`}const ge=({styles:t})=>{const s=t.scaleFactor,e=6*s,n=[{id:ve("pos",t.positive.stroke),stroke:t.positive.stroke,fill:t.positive.fill},{id:ve("neg",t.negative.stroke),stroke:t.negative.stroke,fill:t.negative.fill},{id:ve("neu",t.neutral.stroke),stroke:t.neutral.stroke,fill:t.neutral.fill},...["ac","pp","fc","pl"].map((i=>({id:ve(i,t.scenarios[i].stroke),stroke:t.scenarios[i].stroke,fill:t.scenarios[i].fill})))];return i("defs",null,n.map((t=>i("pattern",{id:t.id,patternUnits:"userSpaceOnUse",width:e,height:e},i("rect",{width:e,height:e,fill:"#ffffff"}),i("line",{x1:"0",y1:e,x2:e,y2:"0",stroke:t.stroke,"stroke-width":1.5*s})))))};function me(t,i,s=1){let e,n;const r=t>=0?"+":"";if(i)return e=100*t,r+Math.round(e).toString()+"%";{let i;return e=t/s,n=Math.abs(e),i=n>=1e9?(e/1e9).toFixed(n>=1e10?0:1)+"B":n>=1e6?(e/1e6).toFixed(n>=1e7?0:1)+"M":n>=1e3?(e/1e3).toFixed(n>=1e4?0:1)+"K":e.toFixed(n>=10?0:1),i=i.replace(/\.0([KMB]?)$/,"$1"),r+i}}function be(t){const i=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(i)}function we(t){const i=t.slice(0,2).toLowerCase();return"pp"===i?"pp":"fc"===i?"fc":"pl"===i?"pl":"ac"}function ye(t,i,s,e){return be(t)?function(t,i){const s=we(t);return i.scenarios[s]}(t,e):function(t,i,s){const e=t>=0;return i?e?s.positive:s.negative:e?s.negative:s.positive}(i,s,e)}function Se(t,i){const s=t.fillpattern;return"hatched"===s?`url(#${ve(i,t.stroke)})`:"outlined"===s?"transparent":t.fill}function Oe(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const $e=t=>{const{value:s,scenario:e,columnStats:n,height:r,isPositiveGood:a,formattedValue:h,measureScale:o,maxBarWidth:l=10,styles:c=pe}=t,d=c.scaleFactor,u=c.fontSize,p=38*d,f=l*u,v=4*d,g=.15*f,m=f-v-g,b=Math.abs(s)*c.unitScaling*u,w=b>m,y=Math.max(0,n.absMax*c.unitScaling*u-m),S=Math.max(0,b-m),O=y>0?S/y*g:0,$=n.min<0,R=n.max>0,M=$?f:0,x=($?p:0)+(M+(R?f:0))+(R?p:0),_=2*d,k=r-2*_,E=($?p:0)+M,L=_,T=s>=0,P=ye(e,s,a,c),A=Se(P,be(e)?we(e):a?T?"pos":"neg":T?"neg":"pos"),{stroke:C,strokeWidth:N}=Oe(P),U=h||me(s,!1,o),D=w?m:b,G=w?m+v+O:b,W=T?E+G+4*d:E-G-4*d,F=T?"start":"end";return i("svg",{width:x,height:r,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},i(ge,{styles:c}),i("line",{x1:E,y1:0,x2:E,y2:r,stroke:fe,"stroke-width":1*d}),D>0&&i("rect",{x:T?E:E-D,y:L,width:D,height:k,fill:A,stroke:C,"stroke-width":N*d}),w&&O>0&&i("rect",{x:T?E+m+v:E-m-v-O,y:L,width:O,height:k,fill:A,stroke:C,"stroke-width":N*d}),w&&function(t,s,e,n,r){const a=t+s/2,h=.35*s,o=n/3,l=.3*s;let c=`M ${a-h} ${e}`;for(let t=0;t<3;t++)c+=` L ${a-h-l} ${e+o*(t+.5)} L ${a-h} ${e+o*(t+1)}`;let d=`M ${a+h} ${e}`;for(let t=0;t<3;t++)d+=` L ${a+h+l} ${e+o*(t+.5)} L ${a+h} ${e+o*(t+1)}`;return[i("rect",{x:t,y:e-1,width:s,height:n+2,fill:"#ffffff"}),i("path",{d:c,fill:"none",stroke:"#000000","stroke-width":1*r}),i("path",{d,fill:"none",stroke:"#000000","stroke-width":1*r})]}(T?E+m:E-m-v,v,L,k,d),i("text",{x:W,y:r/2,dy:"0.35em","text-anchor":F,fill:c.fontColor,"font-size":u,"font-family":c.fontFamily},U))},Re=t=>{const{value:s,scenario:e,columnStats:n,height:r,isPositiveGood:a,formattedValue:h,measureScale:o,maxBarWidth:l=10,styles:c=pe}=t,d=c.scaleFactor,u=c.fontSize,p=Math.round(.67*l*u),f=5*d,v=n.min<0?p+f:0,g=v+(n.max>0?p+f:0),m=g+45*d,b=v,w=r/2,y=100*Math.abs(s)*c.percentageScaling*u,S=y>p,O=Math.min(y,p),$=s>=0,R=$?b+O:b-O,M=ye(e,s,a,c),x=3*d,_=h||me(s,!0,o),k=g+4*d;return i("svg",{width:m,height:r,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},i("line",{x1:b,y1:0,x2:b,y2:r,stroke:fe,"stroke-width":1*d}),!S&&i("circle",{cx:R,cy:w,r:x,fill:c.fontColor}),i("line",{x1:b,y1:w,x2:R,y2:w,stroke:M.fill,"stroke-width":2*d}),S&&$&&i("polygon",{points:`${b+p},${w} ${b+p-6*d},${w-3*d} ${b+p-6*d},${w+3*d}`,fill:M.fill}),S&&!$&&i("polygon",{points:`${b-p},${w} ${b-p+6*d},${w-3*d} ${b-p+6*d},${w+3*d}`,fill:M.fill}),i("text",{x:k,y:r/2,dy:"0.35em","text-anchor":"start",fill:c.fontColor,"font-size":u,"font-style":"italic","font-family":c.fontFamily},_))},Me=t=>{const{value:s,columnStats:e,isRelative:n,styles:r=pe}=t;return null==s||isNaN(s)||!e||0===e.absMax?i("span",{class:"bar-chart-empty",style:{color:r.fontColor,fontStyle:"italic"}},"-"):i(n?Re:$e,Object.assign({},t))},xe=t=>{const{value:s,scenario:e,height:n,measureScale:r,maxBarWidth:a=10,styles:h=pe,waterfall:o}=t,l=h.scaleFactor,c=h.fontSize,d=o.max-o.min;if(null==s||isNaN(s)||d<=0)return i("span",{class:"bar-chart-empty",style:{color:h.fontColor,fontStyle:"italic"}},"-");const u=38*l,p=a*c,f=u+p+u,v=p/d,g=t=>u+(t-o.min)*v,m=2*l,b=n-2*m,w=m,y=g(0),S=g(o.start),O=g(o.end),$=Math.min(S,O),R=Math.abs(O-S),M=ye(e,s,!1,h),x=Se(M,we(e)),{stroke:_,strokeWidth:k}=Oe(M),E=me(s,"partof"===o.kind,r).replace(/^\+/,""),L=O<S,T=L?$-4*l:$+R+4*l,P=L?"end":"start";return i("svg",{width:f,height:n,class:"cell-bar-chart waterfall-bar",style:{overflow:"visible"}},i(ge,{styles:h}),i("line",{x1:y,y1:0,x2:y,y2:n,stroke:fe,"stroke-width":1*l}),void 0!==o.parentStart&&void 0!==o.parentEnd&&i("line",{x1:g(o.parentStart),y1:0,x2:g(o.parentStart),y2:n,stroke:fe,"stroke-width":1*l,"stroke-dasharray":`${2*l},${2*l}`}),void 0!==o.parentStart&&void 0!==o.parentEnd&&i("line",{x1:g(o.parentEnd),y1:0,x2:g(o.parentEnd),y2:n,stroke:fe,"stroke-width":1*l,"stroke-dasharray":`${2*l},${2*l}`}),R>0&&i("rect",{x:$,y:w,width:R,height:b,fill:x,stroke:_,"stroke-width":k*l}),i("text",{x:T,y:n/2,dy:"0.35em","text-anchor":P,fill:h.fontColor,"font-size":c,"font-family":h.fontFamily},E))};class _e{constructor(t){this.groups=[Bt.CATEGORY,Bt.CATEGORYINDEX],zi.OPT!==t.type&&zi.OPTNOTOTAL!==t.type||this.groups.unshift(Bt.OPERATION),t.grouped&&(this.groups.push(Bt.ROWGROUP),this.groups.push(Bt.ROWGROUPINDEX))}toString(){return this.groups.map((t=>`${t}`)).toString()}noCategory(){return this.groups.filter((t=>t!==Bt.CATEGORY))}toArray(){return this.groups}}class ke{constructor(t,i){this.hasPartOf=!1,this.config=t,this.i18n=i}execute(t,i){var s;this.db=t,this.fromExpr=i;const e=[],n=[],r=[],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(),o=this.getRelativeScenarios(),l=this.config.attributes.map((t=>this.translateAttributeSQL(t))).toString(),c=new _e(this.config),d=this.config.grouped?[Bt.ROWGROUP,Bt.ROWGROUPINDEX]:[];let u,p=["",""];this.config.sortOrder.hierarchy.length>0&&(p=this.createOrderString(this.config.sortOrder)),this.hasPartOf=this.checkConfigForPartOf();try{u=t.exec(`SELECT COUNT(DISTINCT ${Bt.CATEGORY}) as ${Bt.TOTALROWCOUNT} ${d.length>0?","+d:""}\n FROM ${i} ${d.length>0?"GROUP BY "+d:""}\n ORDER BY ${p[0]}`)}catch(t){return console.error("DataQuery: meta query failed",t),[]}return 0===u.length||1===u.length&&0===(null!==(s=u[0][Bt.TOTALROWCOUNT])&&void 0!==s?s:0)&&0===d.length?[]:(u.forEach((t=>{const i=t.rowGroup&&t.rowGroup.length>0?`WHERE ${Bt.ROWGROUP} = '${t.rowGroup}'`:"";let s="";this.config.limit&&(s=`LIMIT ${this.config.limit}`),this.createGroupHeaderRow(t,e),this.createDataRow(e,t,c,a,l,i,p,s),this.createRestRow(t,e,c,a,i,p),this.createGroupSumRow(e,n,t,h,p)})),this.createTotalSumRow(e,n,h),e.forEach((i=>{try{r.push(t.exec(i))}catch(t){console.error("DataQuery: SQL query execution failed",i,t)}})),this.detectNaNCells(this.config.scenarios,r),this.createThereOfDrillRows(a,l,p,r),this.createPartOfDrillRows(a,p,n,r),this.createIntervalColumns(r),this.createThereOfDrillColumns(this.config.categoryThereOf,r),this.calculateColumnGroupRest(r,this.config.categoryThereOf),this.calculateRelativeVariances(r,o),r)}detectNaNCells(t,i){i.forEach((i=>{i.map((i=>(t.forEach((t=>{const s=new Tt(t);!0===s.isValid?0!==i[s.base+"_cnt"]&&0!==i[s.delta+"_cnt"]||(i[t]=Number.NaN):0===i[t+"_cnt"]&&(i[t]=Number.NaN)})),i)))}))}createPartOfDrillRows(t,i,s,e){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===zi.LIST)return;const n=this.createPartOfQuery(t,i);let r=[];const a=this.db;n.forEach((function(t){r.push(...a.exec(t))}));const h=this.exctractScenarioNames(t),o=[];s.forEach((function(t){o.push(...a.exec(t))}));const l=new Map;o.forEach((t=>l.set(t[Bt.ROWGROUP],t))),r=this.reduceResDrillByCategoryGroups(r,h),r.forEach((function(t){h.forEach((i=>{try{t[i]=t[i]/l.get(t[Bt.ROWGROUP])[i]}catch(s){console.error("DataQuery: partOf drill row calculation failed",i,s),t[i]=Number.NaN}}))})),this.injectDrillRowsToResultRows(r,e)}createRestRow(t,i,s,e,n,r){if(t.totalRowCnt-this.config.limit>0&&0!==this.config.limit){const a=this.exctractScenarioNames(e).map((t=>`SUM(${t}) as ${t}`)).join(", ");i.push(`SELECT ${Bt.ROWNR}, 1 as ${Bt.ROWGROUPINDEX} , 'ENTRY' as ${Bt.TYPE}, 'NO_GROUP' as ${Bt.ROWGROUP}, 'REST' as ${Bt.CATEGORY} ${a.length>0?", "+a:""} FROM (SELECT ROWNUM() AS ${Bt.ROWNR}, ${i.length} as ${Bt.ROWGROUPINDEX} , 'ENTRY' as ${Bt.TYPE}, '${t.rowGroup||"NO_GROUP"}' as ${Bt.ROWGROUP}, ${s} ${e.length>0?",".concat(e):""} FROM ${this.fromExpr} ${n} GROUP BY ${s} ORDER BY ${r[0]}) t WHERE t.rowNr > ${this.config.limit}`)}}createDataRow(t,i,s,e,n,r,a,h){t.push(`SELECT ROWNUM() AS ${Bt.ROWNR},\n ${t.length} as ${Bt.ROWGROUPINDEX},\n 'ENTRY' as ${Bt.TYPE},\n '${i.rowGroup||"NO_GROUP"}' as ${Bt.ROWGROUP},\n '${Bt.CATEGORYINDEX}',\n ${s} ${e.length>0?",".concat(e):""} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr} ${r}\n GROUP BY ${s}\n ORDER BY ${a[0]} ${h}`)}createGroupHeaderRow(t,i){!0===this.config.grouped&&i.push(`SELECT ROWNUM() AS ${Bt.ROWNR},\n ${i.length} as ${Bt.ROWGROUPINDEX},\n 'GROUPHEAD' as ${Bt.TYPE},\n '${t.rowGroup}' as ${Bt.ROWGROUP} ${this.config.showGroupTitle?`,'${t.rowGroup}' as ${Bt.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}createGroupSumRow(t,i,s,e,n){!0!==this.config.grouped||zi.SUM!==this.config.type&&zi.SUMNOTOTAL!==this.config.type&&zi.OPT!==this.config.type&&zi.OPTNOTOTAL!==this.config.type||(t.push(`SELECT ${t.length} as ${Bt.ROWGROUPINDEX},\n '=' as ${Bt.OPERATION},\n '${s.rowGroup}' as ${Bt.ROWGROUP},\n ROWNUM() AS ${Bt.ROWNR},\n 'GROUP_SUM' as ${Bt.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr}\n WHERE ${Bt.ROWGROUP} = '${s.rowGroup}'\n ORDER BY ${n[0]} `),i.push(`SELECT ${t.length} as ${Bt.ROWGROUPINDEX},\n '=' as ${Bt.OPERATION},\n '${s.rowGroup}' as ${Bt.ROWGROUP},\n ROWNUM() AS ${Bt.ROWNR},\n 'GROUP_SUM' as ${Bt.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr}\n WHERE ${Bt.ROWGROUP} = '${s.rowGroup}'\n ORDER BY ${n[0]} `))}createTotalSumRow(t,i,s){var e;if(zi.SUM===this.config.type||zi.OPT===this.config.type){const i=(null===(e=this.config.title)||void 0===e?void 0:e.trim())||"SUM_TOTAL",n=this.hasPartOf&&!1===this.config.grouped&&"SUM_TOTAL"!==i?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} ${i}`:i;t.push(`SELECT ${t.length} as ${Bt.ROWGROUPINDEX},\n '${n}' as ${Bt.ROWGROUP},\n '=' as ${Bt.OPERATION},\n 'SUM' as ${Bt.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}i.push(`SELECT ${t.length} as ${Bt.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${Bt.ROWGROUP},\n '=' as ${Bt.OPERATION},\n 'SUM' as ${Bt.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}reduceResDrillByCategoryGroups(t,i){const s=new Map;return t.forEach((function(t){const e=t.rowNr+t.rowGroup+t.type+t.category;if(s.has(e)){const n=s.get(e);i.forEach((i=>{try{n[i]+=t[i]}catch(t){console.error("DataQuery: drill row aggregation failed",i,t)}}))}else s.set(e,t)})),[...s.values()]}injectDrillRowsToResultRows(t,i){const s=new Map;if(!0===this.config.grouped)t.forEach((function(t){i.forEach((function(i){const e=i.findIndex((i=>i.category===t.category&&i.rowGroup===t.rowGroup));if(e>=0){if(s.has(`${t.category}_${t.rowGroup}`)){const i=s.get(`${t.category}_${t.rowGroup}`)||0;s.set(`${t.category}_${t.rowGroup}`,i+1)}else s.set(`${t.category}_${t.rowGroup}`,1);t[Bt.ROWNR]=s.get(`${t.category}_${t.rowGroup}`),i.splice(e+t[Bt.ROWNR],0,t)}}))}));else{const e=this.findDuplicateSubCategories(t);t.forEach((function(t){i.forEach((function(i){const n=i.findIndex((i=>null!=i.category&&i.category===t.category));if(n>=0){if(s.has(`${t.category}`)){const i=s.get(`${t.category}`)||0;s.set(`${t.category}`,i+1)}else s.set(`${t.category}`,1);(1===t[Bt.ROWNR]||e.includes(t.subCategory))&&(t.subCategory=`${t.subCategory} (${t.rowGroup})`),i.splice(n+t[Bt.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,i,s,e){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const n=[],r=[];this.config.thereOf.forEach((e=>{let r=!0,a="1 <> 1 OR ( ";null!=e.category&&0!==e.category.length&&e.category.trim()&&(a+=` ${Bt.CATEGORY} = '${e.category}'`,r=!1),null!=e.rowGroup&&0!==e.rowGroup.length&&e.rowGroup.trim()&&(a+=` ${r?"":"AND"} ${Bt.ROWGROUP} = '${e.rowGroup}'`,r=!1),null!=e.subCategory&&0!==e.subCategory.length&&e.subCategory.trim()&&(a+=` ${r?"":"AND"} ${Bt.SUBCATEGORY} = '${e.subCategory}'`),a+=")",n.push(`SELECT ROWNUM() AS ${Bt.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${Bt.TYPE},\n ${Bt.CATEGORY},\n ${Bt.SUBCATEGORY},\n ${Bt.ROWGROUP} as ${Bt.ROWGROUP},\n ${t} ${i.length>0?",".concat(i):""}\n FROM ${this.fromExpr}\n WHERE ${a}\n GROUP BY ${Bt.ROWGROUP}, ${Bt.CATEGORY}, ${Bt.SUBCATEGORY}\n ORDER BY ${s[1]}`)}));const a=this.db;n.forEach((function(t){r.push(...a.exec(t))})),this.injectDrillRowsToResultRows(r,e)}calculateRelativeVariances(t,i){t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[Bt.TYPE]&&i.forEach(((i,s)=>{t[s]=t[s]/t[i]}))}))}))}calculateColumnGroupRest(t,i){if(null==i||0===i.size)return;const s=new Map,e=new Map;i.forEach(((t,i)=>{const n=t,r=[];for(const t of n)r.push(`${i}##${t.name}`);s.set(i,r),e.set(`${i}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[Bt.TYPE]&&s.forEach(((i,s)=>{let n=0;i.forEach((i=>{void 0!==t[i]&&(n+=t[i])})),t[`${s}##REST`]=t[s]-n,0!==t[`${s}##REST`]&&e.set(`${s}##REST`,!0)}))}))}));const n=Array.from(e.entries()).filter((([t,i])=>!i)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const i of n)delete t[i]}))}))}createIntervalColumns(t){var i,s,e,n,r;if(this.config.interval===ji||this.config.categoryThereOf.size>0||0===this.config.scenarios.length)return;const a="##",h=`(SELECT *, ${Ji(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`,o=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),l=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),c=this.exctractScenarioNames(o),d=this.getRelativeScenarios(),u=new _e(this.config),p=zi.OPT===this.config.type||zi.OPTNOTOTAL===this.config.type,f=this.config.grouped&&(zi.SUM===this.config.type||zi.SUMNOTOTAL===this.config.type||zi.OPT===this.config.type||zi.OPTNOTOTAL===this.config.type),v=this.checkConfigForPartOf()&&this.config.type!==zi.LIST,g=t=>{try{return this.db.exec(t)}catch(i){return console.error("DataQuery: interval query failed",t,i),[]}},m=t=>(this.config.scenarios.forEach((i=>{const s=new Tt(i);!0===s.isValid?0!==t[s.base+"_cnt"]&&0!==t[s.delta+"_cnt"]||(t[i]=Number.NaN):0===t[i+"_cnt"]&&(t[i]=Number.NaN)})),d.forEach(((i,s)=>{t[s]=t[s]/t[i]})),t),b=(t,i,s)=>{for(const e of this.config.scenarios)t[e+a+s]=i[e]},w=g(`SELECT ${u}, __interval ${o.length>0?",".concat(o):""}\n FROM ${h}\n GROUP BY ${u}, __interval`);if(this.config.limit>0)for(let e=0;e<t.length;e++){const n=t[e].find((t=>"ENTRY"===t.type&&"REST"===t.category));if(!n)continue;let r;for(let i=e-1;i>=0&&!r;i--){const s=t[i].filter((t=>"ENTRY"===t.type&&"REST"!==t.category));s.length>0&&(r=s)}if(!r)continue;const a=new Set(r.map((t=>t.category))),h=r[0].rowGroup,o=new Map;for(const t of w){if(this.config.grouped&&t.rowGroup!==h)continue;if(a.has(t.category))continue;const e=qi(t.__interval);let n=o.get(e);n||(n={},o.set(e,n));for(const e of c)n[e]=(null!==(i=n[e])&&void 0!==i?i:0)+(null!==(s=t[e])&&void 0!==s?s:0)}o.forEach(((t,i)=>{b(n,m(t),i)}))}for(const i of w){const s=qi(i.__interval);m(i);for(const e of t)for(const t of e)"ENTRY"===t.type&&"REST"!==t.category&&t.category===i.category&&(this.config.grouped&&t.rowGroup!==i.rowGroup||p&&t.operation!==i.operation||b(t,i,s))}const y=f||v&&this.config.grouped?g(`SELECT ${Bt.ROWGROUP}, __interval ${l.length>0?",".concat(l):""}\n FROM ${h}\n GROUP BY ${Bt.ROWGROUP}, __interval`):[],S=new Map;if(y.forEach((t=>S.set(`${t.rowGroup}${a}${qi(t.__interval)}`,t))),f)for(const i of y){const s=qi(i.__interval),e=m(Object.assign({},i));for(const n of t)for(const t of n)"GROUP_SUM"===t.type&&t.rowGroup===i.rowGroup&&b(t,e,s)}const O=zi.SUM===this.config.type||zi.OPT===this.config.type,$=O||v&&!this.config.grouped?g(`SELECT __interval ${l.length>0?",".concat(l):""}\n FROM ${h}\n GROUP BY __interval`):[],R=new Map;if($.forEach((t=>R.set(qi(t.__interval),t))),O)for(const i of $){const s=qi(i.__interval),e=m(Object.assign({},i));for(const i of t)for(const t of i)"SUM"===t.type&&b(t,e,s)}if(null!=this.config.thereOf&&this.config.thereOf.length>0){const i=[];this.config.thereOf.forEach((t=>{i.push(...g(`SELECT ${Bt.ROWGROUP}, ${Bt.CATEGORY}, ${Bt.SUBCATEGORY}, __interval ${o.length>0?",".concat(o):""}\n FROM ${h}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${Bt.ROWGROUP}, ${Bt.CATEGORY}, ${Bt.SUBCATEGORY}, __interval`))}));for(const s of i){const i=qi(s.__interval);m(s);for(const e of t)for(const t of e)"DRILLELEMENT"===t.type&&t.category===s.category&&(t.subCategory!==s.subCategory&&t.subCategory!==`${s.subCategory} (${s.rowGroup})`||b(t,s,i))}}if(v){let i="1 <> 1 ";null===(e=this.config.partOf)||void 0===e||e.forEach((t=>{i+=`OR (${Bt.CATEGORY} = '${t.category}'`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=`and ${Bt.ROWGROUP} = '${t.rowGroup}'`),i+=")"}));const s=g(`SELECT ${Bt.CATEGORY}, ${this.config.grouped?`${Bt.ROWGROUP}`:`'SUM_TOTAL' as ${Bt.ROWGROUP}`}, __interval ${o.length>0?",".concat(o):""}\n FROM ${h}\n WHERE ${i}\n GROUP BY ${Bt.ROWGROUP}, ${Bt.CATEGORY}, __interval`),l=new Map;for(const t of s){const i=`${t.rowGroup}${a}${t.category}${a}${qi(t.__interval)}`,s=l.get(i);if(s)for(const i of c)s[i]=(null!==(n=s[i])&&void 0!==n?n:0)+(null!==(r=t[i])&&void 0!==r?r:0);else l.set(i,t)}l.forEach((i=>{const s=qi(i.__interval),e=this.config.grouped?S.get(`${i.rowGroup}${a}${s}`):R.get(s);for(const t of c)i[t]=i[t]/(e?e[t]:Number.NaN);m(i);for(const e of t)for(const t of e)"PARTELEMENT"===t.type&&t.category===i.category&&t.rowGroup===i.rowGroup&&b(t,i,s)}))}}createThereOfWhereClause(t){let i=!0,s="1 <> 1 OR ( ";return null!=t.category&&0!==t.category.length&&t.category.trim()&&(s+=` ${Bt.CATEGORY} = '${t.category}'`,i=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(s+=` ${i?"":"AND"} ${Bt.ROWGROUP} = '${t.rowGroup}'`,i=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(s+=` ${i?"":"AND"} ${Bt.SUBCATEGORY} = '${t.subCategory}'`),s+")"}getRelativeScenarios(){const t=new Map;return this.config.scenarios.forEach((i=>{const s=this.createRelativeScenario(i);null!=s&&t.set(s.key,s.value)})),t}translateScenarioSQL(t,i,s){const e=new Tt(t);return zi.OPT===s||zi.OPTNOTOTAL===s?e.isValid?"dr"===e.type?`SUM(${e.base} - ${e.delta}) as ${t}, SUM(${e.delta}) as dr_${e.delta}`:`SUM(${e.base} - ${e.delta}) as ${t}`:i?`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:`SUM(${t}) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:e.isValid?"dr"===e.type?`SUM((${e.base} * transformOperator(operation)) - (${e.delta} * transformOperator(operation))) as ${t}, SUM(${e.delta} * transformOperator(operation)) as dr_${e.delta}`:`SUM((${e.base} * transformOperator(operation))- (${e.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}translateAttributeSQL(t){const i=`[${t.arg}]`,s=/^(ac|pp|fc|pl)[1-4]$/.test(t.arg)&&this.config.type!==zi.OPT&&this.config.type!==zi.OPTNOTOTAL;switch(t.fn){case"set":return`SETAGG(${i}) as ${t.alias}`;case"first":return`FIRST(${i}) as ${t.alias}`;case"last":return`LAST(${i}) as ${t.alias}`;case"min":return`MIN(${i}) as ${t.alias}`;case"max":return`MAX(${i}) as ${t.alias}`;case"avg":return s?`AVG(${i} * transformOperator(operation)) as ${t.alias}`:`AVG(${i}) as ${t.alias}`;case"sum":return s?`SUM(${i} * transformOperator(operation)) as ${t.alias}`:`SUM(${i}) as ${t.alias}`;case"lit":return`${this.sqlLiteral(t.arg)} as ${t.alias}`}}sqlLiteral(t){return""===t||Number.isNaN(Number(t))?`'${t.replace(/'/g,"''")}'`:t}createOrderString(t){return[`${t.hierarchy.toString()} ${t.direction}`,`${t.hierarchy.toString()} ${Hi.ASC===t.direction?Hi.DESC:Hi.ASC}`]}createRelativeScenario(t){const i=new Tt(t);return i.isValid&&"dr"===i.type?{key:`${t}`,value:`dr_${i.delta}`}:null}exctractScenarioNames(t){const i=[];return t.split(",").forEach((t=>t.length>=2?i.push(t.split("as")[1].trim()):null)),i}findDuplicateSubCategories(t){const i=t.map((t=>({count:1,subCategory:t.subCategory}))).reduce(((t,i)=>(t[i.subCategory]=(t[i.subCategory]||0)+i.count,t)),{});return Object.keys(i).filter((t=>i[t]>1))}createPartOfQuery(t,i){var s;const e=[];let n="1 <> 1 ",r=` ${Bt.ROWGROUP}`,a="ROWNUM()";return null===(s=this.config.partOf)||void 0===s||s.forEach((t=>{n+=`OR (${Bt.CATEGORY} = '${t.category}'`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(n+=`and ${Bt.ROWGROUP} = '${t.rowGroup}'`),!1===this.config.grouped&&(r=` 'SUM_TOTAL' as ${Bt.ROWGROUP} `,a="1"),n+=")"})),e.push(`SELECT ${a} AS ${Bt.ROWNR},\n 'PARTELEMENT' as ${Bt.TYPE},\n ${Bt.CATEGORY},\n ${r},\n ${t}\n FROM ${this.fromExpr}\n WHERE ${n}\n GROUP BY ${Bt.ROWGROUP}, ${Bt.CATEGORY}, ${Bt.TYPE}\n ORDER BY ${i[1]}`),e}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,i){if(null==t||0===t.size)return;const s=[],e=[],n=this.fromExpr;t.forEach(((t,i)=>{let e="1 <> 1 ";t.forEach((t=>{e+=` or columnGroup = '${t.name}' `})),s.push(`SELECT 'ENTRY' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, columnGroup, scenario`),s.push(`SELECT 'ENTRY' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, columnGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, columnGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of s)e.push(...this.db.exec(t));this.injectDrillColumnsToResultRows(e,i)}injectDrillColumnsToResultRows(t,i){const s="##";for(const e of t)for(const t of i)for(const i of t)i.type===e.rowlevel&&("ENTRY"===e.rowlevel?"COLUMNGROUP"===e.columnlevel&&i.category===e.category?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val):"DRILLELEMENT"===e.rowlevel?"COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory?i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val:"COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===`${e.subCategory} (${e.rowGroup})`?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===`${e.subCategory} (${e.rowGroup})`&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val):("SUM"===e.rowlevel||"GROUP_SUM"===e.rowlevel)&&("COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory&&(i[e.scenario+s+e.columnGroup]=e.val),"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val)))}}class Ee{constructor(){this.geometry=new Map}set(t,i,s){let e=this.geometry.get(t);e||(e=new Map,this.geometry.set(t,e)),e.set(i,s)}get(t,i){var s;return null===(s=this.geometry.get(t))||void 0===s?void 0:s.get(i)}}function Le(t,i,s){const e=t[i];if(null==e)return null;const n=Number(e);return isNaN(n)?null:s!==zi.OPT&&s!==zi.OPTNOTOTAL||t[Bt.TYPE]!==Vi.ENTRY||"-"!==t[Bt.OPERATION]?n:-n}class Te{constructor(){this.normalizedHeader=[],this.attributesByAlias=new Map}createHeader(t,i,s,e,n,r,a=[]){const h=[];this.attributesByAlias=new Map(a.map((t=>[t.alias,t]))),this.normalizedHeader=this.normalizeHeader(t,i,a);const o=this.normalizedHeader.some((t=>void 0!==t.bucket));o&&h.push(this.createIntervalBandRow());const l=new ue(o?1:0,0,Vi.HEADER),c=new ue(o?2:1,0,Vi.SEPERATORLINE);for(const t of this.normalizedHeader){const i=this.attributesByAlias.get(t.name);l.createElement(i?s.get(i.label)||i.label:Mt.translateScenarioLabel(t.name,s),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,s,e,n,r),null,null,null,null),c.createElement(null,t.type,this.createColumnType(t),null,null,null,null,null,null)}return h.push(l),h.push(c),h}createIntervalBandRow(){const t=new ue(0,0,Vi.HEADER);let i=0;for(;i<this.normalizedHeader.length;){const s=this.normalizedHeader[i];if(void 0===s.bucket){t.createElement(null,s.type,"filler",null,null,null,null,null,null),i+=1;continue}let e=1;for(;i+e<this.normalizedHeader.length&&this.normalizedHeader[i+e].bucket===s.bucket;)e+=1;t.createElement(s.bucketLabel,s.type,"intervalGroup",null,null,null,null,null,null,!1,void 0,e),i+=e}return t}setHeaderPrefix(t,i,s,e,n){let r="";return"category"===t.name&&n&&(0===s.prefix.length&&0===e.length||(r=Mt.translateScenarioLabel("in",i)+" "+s.prefix+e)),t.order&&(r+=Mt.translateScenarioLabel("ORDER_"+t.order,i)),r}normalizeHeader(t,i,s){let e=[{name:Bt.CATEGORY,group:Bt.CATEGORY,type:Bt.CATEGORY,order:void 0}];zi.OPT!==t&&zi.OPTNOTOTAL!==t||(e=[{name:Bt.OPERATION,group:Bt.OPERATION,type:Bt.OPERATION,order:void 0},{name:Bt.CATEGORY,group:Bt.CATEGORY,type:Bt.CATEGORY,order:void 0}]);const n=s.map((t=>({name:t.alias,group:t.alias,type:t.alias,order:void 0})));return[...e,...n,...i]}createBodyRows(t,i,s,e){var n;const r=[];let a=-1;const h=new ke(t,i).execute(s,e),o=this.calculateColumnStatistics(h,t.barColumns,t.interval!==ji),l=(null!==(n=t.barColumns)&&void 0!==n?n:[]).filter((t=>t.toUpperCase().trim()in Rt)),c=l.length>0&&t.interval===ji&&0===t.categoryThereOf.size&&function(t){for(const i of t)for(const t of i){const i=t[Bt.TYPE];if(i===Vi.SUM||i===Vi.GROUPSUM||i===Vi.DRILLELEMENT||i===Vi.PARTELEMENT)return!0}return!1}(h)?function(t,i,s){const e=new Ee;for(const n of i){let i,r=0,a=0;const h=[],o=(t,i)=>{h.push(i),e.set(t,n,i)};for(const e of t)for(const t of e){const e=t[Bt.TYPE];if(e===Vi.GROUPHEAD){i=void 0;continue}const h=Le(t,n,s);if(e===Vi.ENTRY){if(null===h){i=void 0;continue}o(t,{start:r,end:r+h,min:0,max:0,kind:"cascade"}),i={start:r,end:r+h},a=i.start,r+=h}else if(e===Vi.SUM||e===Vi.GROUPSUM){if(null===h){i=void 0;continue}o(t,{start:0,end:h,min:0,max:0,kind:"anchor"}),i={start:0,end:h},a=0,r=h}else if(e===Vi.DRILLELEMENT){if(null===h||void 0===i)continue;const s=a+(Math.sign(i.end-i.start)||1)*Math.abs(h);o(t,{start:a,end:s,min:0,max:0,kind:"thereof",parentStart:i.start,parentEnd:i.end}),a=s}else if(e===Vi.PARTELEMENT){if(null===h||void 0===i)continue;const s=a+h*(i.end-i.start);o(t,{start:a,end:s,min:0,max:0,kind:"partof",parentStart:i.start,parentEnd:i.end}),a=s}}let l=0,c=0;for(const t of h)l=Math.min(l,t.start,t.end),c=Math.max(c,t.start,t.end);for(const t of h)t.min=l,t.max=c}return e}(h,l,t.type):void 0;for(const s of h)a+=1,r.push(...this.createRow(t.i18n,i,t.scenariosUnitType,s,a,-1,t.categoryWidth,t.measureScale,t.barColumns,o,c));return r}calculateColumnStatistics(t,i,s=!1){const e=new Map;if(!i||0===i.length)return e;const n=new Map;for(const t of i)e.set(t,{min:1/0,max:-1/0,absMax:0,median:0}),n.set(t,[]);for(const r of t)for(const t of r)for(const r of i){const i=s?this.extractIntervalColumnValues(t,r):[this.extractColumnValue(t,r)];for(const t of i)if(null!==t&&!isNaN(t)){const i=e.get(r);i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),n.get(r).push(Math.abs(t))}}for(const[t,i]of e){i.min!==1/0&&i.max!==-1/0||(i.min=0,i.max=0),i.absMax=Math.max(Math.abs(i.min),Math.abs(i.max));const s=n.get(t);if(s.length>0){s.sort(((t,i)=>t-i));const t=Math.floor(s.length/2);i.median=s.length%2==0?(s[t-1]+s[t])/2:s[t]}e.set(t,i)}return e}extractIntervalColumnValues(t,i){const s=i+"##",e=[];for(const i of Object.keys(t))if(i.startsWith(s)){const s=Number(t[i]);e.push(isNaN(s)?null:s)}return e}extractColumnValue(t,i){if(void 0!==t[i]){const s=Number(t[i]);return isNaN(s)?null:s}for(const s of Object.keys(t))if(s===i||s.endsWith("##"+i)||s===i+"##"+i){const i=Number(t[s]);if(!isNaN(i))return i}return null}createRow(t,i,s,e,n,r,a,h,o,l,c){var d;const u=[];for(const p of e){const f=p[Bt.ROWGROUP],v=p[Bt.SUBCATEGORY],g=p[Bt.TYPE],m=p[Bt.ROWNR]>=2,b=this.createDetailRow(g,r+=1,n,e.length);for(const e of this.normalizedHeader){const n=this.getRawDataRowElement(p,e),r=null!==(d=null==o?void 0:o.includes(e.type))&&void 0!==d&&d,u=r?null==l?void 0:l.get(e.type):void 0,w=r&&void 0===e.bucket&&e.name===e.group&&e.name===e.type?null==c?void 0:c.get(p,e.type):void 0;b.createElement(this.translateSumCellLabel(t,i,n,f,v,g,e.type),e.type,this.createColumnType(e),this.setCellType(e.type,s),this.translateCellPrefix(i,g,e.type),this.translateScenarioCSS(e.type,n),m,a,null==h?void 0:h.value,r,u,1,w)}u.push(b)}return u}getRawDataRowElement(t,i){return void 0!==i.bucket?t[i.type+"##"+i.bucket]:i.name===i.group&&i.name===i.type?t[i.name]:i.name===i.group&&i.name!==i.type?t[i.type+"##"+i.name]:t[i.type+"##"+i.group+"##"+i.name]}createDetailRow(t,i,s,e){switch(t){case Vi.GROUPHEAD:return new ue(i,s,Vi.HEADER);case Vi.SUM:case Vi.GROUPSUM:return new ue(e+2,s,Vi.SUM);case Vi.DRILLELEMENT:return new ue(e+2,s,Vi.DRILLELEMENT);case Vi.PARTELEMENT:return new ue(e+2,s,Vi.PARTELEMENT);default:return new ue(i,s,Vi.STANDARD)}}translateSumCellLabel(t,i,s,e,n,r,a){return this.attributesByAlias.has(a)||!1===Number.isNaN(Number(s))||this.isOperationColumn(a)?s:this.isGroupHeadCategory(r,a)||this.isEntryCategory(r,a)?t===mt.ALL?`${i.get(s)||s}`:s:this.isDrillElementCategory(r,a)?t===mt.ALL?`${i.get(n)||n}`:`${n}`:this.isPartElementCategory(r,a)?t===mt.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:`${e}`:this.isSumElementCategory(r,a)?t===mt.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:e:"GROUPHEAD"===r&&null==s?s:Number.isNaN(Number(s))?"-":Number(s)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,i){if(this.attributesByAlias.has(t))return"attribute";const s=new Tt(t);let e="pos";return i<0&&(e="neg"),s.isValid?e+"_"+s.direction+("dr"===s.type?" relative_variance":""):t}setCellType(t,i){if("category"===t)return"";const s=this.attributesByAlias.get(t);if(s)return s.isNumeric?"decimal":"";let e;const n=new Tt(t);return i===gt.PERCENT?(e="percent",n.isValid&&"d"===n.type&&(e="decimal")):(e="decimal",n.isValid&&"dr"===n.type&&(e="percent")),e}isDrillElementCategory(t,i){return"DRILLELEMENT"===t&&"category"===i}isPartElementCategory(t,i){return"PARTELEMENT"===t&&"category"===i}isSumElementCategory(t,i){return("GROUP_SUM"===t||"SUM"===t)&&"category"===i}isEntryCategory(t,i){return"ENTRY"===t&&"category"===i}isGroupHeadCategory(t,i){return"GROUPHEAD"===t&&"category"===i}translateCellPrefix(t,i,s){return this.isOperationColumn(s)||this.isGroupHeadCategory(i,s)||this.isEntryCategory(i,s)?null:this.isDrillElementCategory(i,s)?`${t.get("there_of")} `:this.isPartElementCategory(i,s)?`${t.get("part_of")} `:null}createColumnType(t){return t.name===t.group&&t.name===t.type?"base":t.name===t.group?"columnGroup":"columnSubGroup"}}class Pe{constructor(t,i,s,e){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new Et,this.db=i,this.dataSetFactory=new Te,this.config=this.initConfig(e),this.i18n=this.initI18n(new Map),this.setSource(s,e.filter),this.state=Bi.DIRTY}setI18n(t){this.i18n=this.initI18n(t)}initI18n(t){const i=new Map([["",""],["SEPERATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pl3","PL3"],["ac4","AC4"],["pp4","PY4"],["fc4","FC4"],["pl4","PL4"],["in","in"],["category"," "],["operation"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return this.state=Bi.DIRTY,new Map([...i,...t||new Map])}initConfig(t){this.state=Bi.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}setConfig(t){this.config=this.initConfig(t)}setSource(t,i){var s,e;if(!t)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=g(t,i);try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(e=null===(s=t[0])||void 0===s?void 0:s.cnt)&&void 0!==e?e:0}catch(t){this.rowCount=0}this.prepareIntervalBuckets();const n=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder,this.intervalBuckets);this.headerRows=this.dataSetFactory.createHeader(this.config.type,n,this.i18n,this.config.measureScale,this.config.measureUnit,this.config.showMeasureScale,this.config.attributes),this.bodyRows=0===this.rowCount?[]:this.dataSetFactory.createBodyRows(this.config,this.i18n,this.db,this.fromExpr),this.state=Bi.UP_TO_DATE}update(){this.prepareIntervalBuckets();const t=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder,this.intervalBuckets);this.headerRows=this.dataSetFactory.createHeader(this.config.type,t,this.i18n,this.config.measureScale,this.config.measureUnit,this.config.showMeasureScale,this.config.attributes),this.bodyRows=0!==this.rowCount&&this.fromExpr?this.dataSetFactory.createBodyRows(this.config,this.i18n,this.db,this.fromExpr):[],this.state=Bi.UP_TO_DATE}getHeader(){return this.state===Bi.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===Bi.DIRTY&&this.update(),this.bodyRows}prepareIntervalBuckets(){this.intervalBuckets=[],this.config.interval===ji||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=ji:(this.config.interval=function(t,i,s){var e;if(s!==N.AUTO)return s;let n,r,a;try{n=t.exec(`SELECT [date] as d FROM ${i}`)}catch(t){return console.error("IntervalColumns: date query failed",t),N.DAY}for(const t of n){const i=null===(e=Ki(t.d))||void 0===e?void 0:e.toMillis();void 0!==i&&(r=void 0===r?i:Math.min(r,i),a=void 0===a?i:Math.max(a,i))}return void 0===r||void 0===a?N.DAY:(new D).calculateDistanceType(v.fromMillis(r),v.fromMillis(a))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,i,s,e){let n;try{n=t.exec(`SELECT ${Ji(s)} as __interval FROM ${i}`)}catch(t){return console.error("IntervalColumns: bucket query failed",t),[]}if(s===Xi){const t=new Set,i=[];for(const s of n){const e=qi(s.__interval);t.has(e)||(t.add(e),i.push({key:e,label:0===e.length?"—":e}))}return i}const r=new Set,a=[];for(const t of n){const i=Ki(t.__interval);if(!i)continue;const s=i.toISO();r.has(s)||(r.add(s),a.push(i))}a.sort(((t,i)=>t.toMillis()-i.toMillis()));const h=new D;return h.setLocale(e),a.map((t=>({key:t.toISO(),label:h.getDateString(t,s)})))}(this.db,this.fromExpr,this.config.interval,this.config.locale),0===this.intervalBuckets.length&&(this.config.interval=ji))}normalizeScenarios(t,i,s,e=[]){var n,r;const a=[];if(e.length>0){for(const i of e)for(const e of t)a.push({name:e,group:e,type:e,order:(null===(n=null==s?void 0:s.hierarchy)||void 0===n?void 0:n.at(0))===e?s.direction:void 0,bucket:i.key,bucketLabel:i.label});return a}for(const e of t){if(null==i?void 0:i.has(e)){const t=i.get(e);for(const i of t){a.push({name:i.name,group:i.name,type:e,order:void 0});for(const t of i.subGroups)a.push({name:t,group:i.name,type:e,order:void 0})}a.push({name:"REST",group:"REST",type:e,order:void 0})}let t;(null===(r=null==s?void 0:s.hierarchy)||void 0===r?void 0:r.at(0))===e&&(t=s.direction),a.push({name:e,group:e,type:e,order:t})}return a}hasNoData(){return 0===this.rowCount}}class Ae{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=gt.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.thereOf=[],this.categoryThereOf=new Map,this.partOf=[],this.attributes=[],this.sortOrder=new tt(new os).default(),this.type=zi.LIST,this.limit=0,this.i18n=mt.ALL,this.categoryWidth=bt.W25,this.measureScale=new _t,this.measureUnit="",this.measureType=wt.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.locale="de"}}class Ce{constructor(t,i,s,e,n){this.tableDrillGroupAdapter=t,this.stringAdapter=i,this.orderAdapter=s,this.db=e,this.fromExpr=n}adapt(t){const i=new Ae;return Ot.isString(t.title)&&(i.title=t.title),Ot.isArray(t.scenarios)&&(i.scenarios=Q.adaptArray(t.scenarios,this.stringAdapter)),Ot.isExisting(t.scenariosUnitType)&&(i.scenariosUnitType=t.scenariosUnitType),Ot.isBoolean(t.grouped)&&(i.grouped=t.grouped),Ot.isBoolean(t.showGroupTitle)&&(i.showGroupTitle=t.showGroupTitle),Ot.isBoolean(t.showMeasureScale)&&(i.showMeasureScale=t.showMeasureScale),Ot.isArray(t.thereOf)&&(i.thereOf=Q.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),Ot.isExisting(t.categoryThereOf)&&(i.categoryThereOf=t.categoryThereOf),Ot.isArray(t.partOf)&&(i.partOf=Q.adaptArray(t.partOf,this.tableDrillGroupAdapter)),Ot.isArray(t.attributes)&&(i.attributes=t.attributes),Ot.isExisting(t.order)&&(i.sortOrder=this.orderAdapter.adapt(t.order)),Ot.isExisting(t.type)&&(i.type=t.type),Ot.isNumber(t.limit)&&(i.limit=t.limit),Ot.isExisting(t.i18n)&&(i.i18n=t.i18n),Ot.isExisting(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),Ot.isExisting(t.measureScale)&&(i.measureScale=hs.calculateMeasureScale(this.db,this.fromExpr,i.scenarios,t.measureScale)),Ot.isExisting(t.measureType)&&(i.measureType=t.measureType),Ot.isString(t.measureUnit)&&(i.measureUnit=t.measureUnit),Ot.isString(t.filter)&&(i.filter=t.filter.trim()),Ot.isArray(t.barColumns)&&(i.barColumns=t.barColumns),Ot.isString(t.interval)&&(i.interval=t.interval),Ot.isString(t.locale)&&(i.locale=t.locale),i}default(){return new Ae}}class Ne{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class Ue{constructor(){}adapt(t){const i=new Ne;return Ot.isString(t.rowGroup)&&(i.rowGroup=t.rowGroup),Ot.isString(t.category)&&(i.category=t.category),Ot.isString(t.subCategory)&&(i.subCategory=t.subCategory),Ot.isString(t.partOf)&&(i.partOf=t.partOf),i}default(){return new Ne}}const De=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.sumTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=gt.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.thereof=[],this.partof=[],this.order={hierarchy:[],direction:Hi.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=zi.LIST,this.categoryWidth=bt.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=mt.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=wt.VOLUME,this.filter="",this.barColumns=[],this.interval="none",this.barColumnMaxWidth=30,this.unitScaling=.01,this.percentageScaling=.5,this.scaleFactor=1,this.componentDataFormatDigits=new Es,this.componentStyle=b(this)}render(){return i(s,null,(()=>{if(void 0!==this.table){if(this.table.hasNoData()){const t=this.i18n.get("NO_DATA")||"==No Data==";return i("p",{class:"warning"},t)}return i("table",null,i("thead",null,this.table.getHeader().map((t=>i("tr",{class:t.cssStyle},t.getCells().map((t=>i("th",{colSpan:t.colSpan,class:t.cssStyle},t.getAsHeaderList().map(((s,e,n)=>i("span",null,e===n.length-1?i("span",{class:" "===s?"table-footer":""},s,t.drawPrefix()," "):i("span",null,s,t.drawPrefix(),i("br",null)))))))))))),i("tbody",null,this.table.getBody().map((t=>i("tr",{class:t.cssStyle},null==t?void 0:t.getCells().map((s=>i("td",{colSpan:s.colSpan,class:s.type?`${s.cssStyle} ${s.type}`:s.cssStyle},null!=s.prefix?i("span",{class:s.cssStyle+" "+s.prefixStyle},s.drawPrefix()):"",s.isBarChart&&s.columnStats&&(void 0!==s.waterfall||t.type!==Vi.SUM)?void 0!==s.waterfall?i(xe,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:s.key.endsWith("_pos"),measureScale:s.measureScale,maxBarWidth:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:s.waterfall}):i(Me,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:s.key.startsWith("dr"),isPositiveGood:s.key.endsWith("_pos"),measureScale:s.measureScale,maxBarWidth:this.barColumnMaxWidth,styles:this.barChartStyles}):s.draw(this.componentDataFormatDigits)))))))))}})())}componentWillRender(){this.stores||(this.stores=d(this.element));const t=this.stores.db.db,i=this.prepareConfig(t);this.componentDataFormatDigits=(new Ls).adapt(this.dataFormatDigits),this.table=new Pe(new Et(this.ruleSetConfig),t,this.tableName,i),this.table.setI18n(this.i18n),this.barChartStyles=this.prepareBarChartStyles()}prepareConfig(t){var i,s,e;const n=this.tableName?this.filter&&this.filter.length>0?`(SELECT * FROM \`${this.tableName}\` WHERE ${this.filter}) AS __src`:`\`${this.tableName}\``:"";return new Ce(new Ue,new os,new tt(new os),t,n).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===(e=null===(s=null===(i=this.stores)||void 0===i?void 0:i.context)||void 0===s?void 0:s.state)||void 0===e?void 0:e.locale)||"de"})}prepareBarChartStyles(){return this.componentStyle((t=>{var i,s,e,n,r,a,h,o,l,c,d,u,p,f,v,g,m,b,w,y,S,O,$,R,M,x;const _=null===(i=t["bn-chart-time"])||void 0===i?void 0:i.varianceStyles,k=null===(s=t["bn-chart-time"])||void 0===s?void 0:s.barStyles;return{positive:{stroke:(null===(e=null==_?void 0:_.pos)||void 0===e?void 0:e.stroke)||"#008f96",fill:(null===(n=null==_?void 0:_.pos)||void 0===n?void 0:n.fill)||"#008f96",fillpattern:(null===(r=null==_?void 0:_.pos)||void 0===r?void 0:r.fillpattern)||"solid"},negative:{stroke:(null===(a=null==_?void 0:_.neg)||void 0===a?void 0:a.stroke)||"#ff0000",fill:(null===(h=null==_?void 0:_.neg)||void 0===h?void 0:h.fill)||"#ff0000",fillpattern:(null===(o=null==_?void 0:_.neg)||void 0===o?void 0:o.fillpattern)||"solid"},neutral:{stroke:(null===(l=null==_?void 0:_.neu)||void 0===l?void 0:l.stroke)||"#808080",fill:(null===(c=null==_?void 0:_.neu)||void 0===c?void 0:c.fill)||"#808080",fillpattern:(null===(d=null==_?void 0:_.neu)||void 0===d?void 0:d.fillpattern)||"outlined"},scenarios:{ac:{stroke:(null===(u=null==k?void 0:k.ac)||void 0===u?void 0:u.stroke)||"#404040",fill:(null===(p=null==k?void 0:k.ac)||void 0===p?void 0:p.fill)||"#404040",fillpattern:(null===(f=null==k?void 0:k.ac)||void 0===f?void 0:f.fillpattern)||"solid"},pp:{stroke:(null===(v=null==k?void 0:k.pp)||void 0===v?void 0:v.stroke)||"#A6A6A6",fill:(null===(g=null==k?void 0:k.pp)||void 0===g?void 0:g.fill)||"#A6A6A6",fillpattern:(null===(m=null==k?void 0:k.pp)||void 0===m?void 0:m.fillpattern)||"solid"},fc:{stroke:(null===(b=null==k?void 0:k.fc)||void 0===b?void 0:b.stroke)||"#404040",fill:(null===(w=null==k?void 0:k.fc)||void 0===w?void 0:w.fill)||"#ffffff",fillpattern:(null===(y=null==k?void 0:k.fc)||void 0===y?void 0:y.fillpattern)||"hatched"},pl:{stroke:(null===(S=null==k?void 0:k.pl)||void 0===S?void 0:S.stroke)||"#404040",fill:(null===(O=null==k?void 0:k.pl)||void 0===O?void 0:O.fill)||"#ffffff",fillpattern:(null===($=null==k?void 0:k.pl)||void 0===$?void 0:$.fillpattern)||"outlined"}},fontColor:(null===(R=t.global)||void 0===R?void 0:R.fontColor)||"#000000",fontSize:.85*((null===(M=t.global)||void 0===M?void 0:M.fontSizePx)||13.3333)*this.scaleFactor,fontFamily:(null===(x=t.global)||void 0===x?void 0:x.fontFamily)||"'Noto Sans', sans-serif",unitScaling:this.unitScaling>0?this.unitScaling:this.autoUnitScaling(),percentageScaling:this.percentageScaling>0?this.percentageScaling:this.autoPercentageScaling(),scaleFactor:this.scaleFactor}}))}autoUnitScaling(){const t=this.componentStyle((t=>{var i;return.85*((null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333)*this.scaleFactor})),i=this.barColumnMaxWidth*t*.8,s=this.getMaxAbsValue();return s<=0||t<=0?.01:i/(s*t)}autoPercentageScaling(){const t=this.componentStyle((t=>{var i;return.85*((null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333)*this.scaleFactor})),i=.8*Math.round(.67*this.barColumnMaxWidth*t),s=this.getMaxRelativeValue();return s<=0||t<=0?.5:i/(s*t)}getMaxAbsValue(){if(!this.table)return 0;let t=0;for(const i of this.table.getBody())if(i.type!==Vi.SUM)for(const s of i.getCells())s.isBarChart&&s.columnStats&&!s.key.startsWith("dr")&&!s.waterfall&&(t=Math.max(t,s.columnStats.absMax));return t}getMaxRelativeValue(){if(!this.table)return 0;let t=0;for(const i of this.table.getBody())if(i.type!==Vi.SUM)for(const s of i.getCells())s.isBarChart&&s.columnStats&&s.key.startsWith("dr")&&(t=Math.max(t,100*s.columnStats.absMax));return t}get element(){return e(this)}};De.style=':host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}th.intervalGroup{border-bottom:0.1em solid black;text-align:center;font-weight:bold}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}';class Ge{constructor(){}createMeasures(t,i,s){if(this.allMeasuresUseSameUnit(t)){const e=t.length;let n="",r="";for(let a=0;a<e;a++){let h="";a>0&&(h=i.get("SEPERATOR_WS")),e>1&&a===e-1&&(h=i.get("CONNECTOR_WS")),s===mt.ALL?(n=(i.get(n)||n)+h+(i.get(t[a].name)||t[a].name),r=i.get(t[a].unit)||t[a].unit):(n=n+h+t[a].name,r=t[a].unit)}return[{name:n,unit:r}]}return t}createDimension(t,i,s,e,n){let r="";void 0!==i&&(r=(new D).getDateLinkString(i.start,i.end,i.link,i.format,n));const a=t.map((t=>{let i="";return null!=s&&null!=s.hierarchy&&s.hierarchy.find((i=>i===t))&&(i=e.get("asc"===s.direction?"ORDER_asc":"ORDER_desc")),"".concat(" ",Mt.translateScenarioLabel(t,e),i)})).toString();return r+a}allMeasuresUseSameUnit(t){const i=new Map;return t.forEach((function(t){i.set(t.unit,!0)})),1===i.size}}class We{constructor(){this.businessunit="",this.measures=[],this.scenarios=[],this.i18nMode=mt.ALL,this.intervalSpanLimit=32}}class Fe{constructor(t,i,s,e){this.measureEntryAdapter=t,this.timePeriodAdapter=i,this.orderAdapter=s,this.stringAdapter=e}adapt(t){const i=new We;return Ot.isString(t.businessunit)&&(i.businessunit=t.businessunit),Ot.isArray(t.measures)&&(i.measures=Q.adaptArray(t.measures,this.measureEntryAdapter)),Ot.isArray(t.scenarios)&&(i.scenarios=Q.adaptArray(t.scenarios,this.stringAdapter)),Ot.isExisting(t.timeperiod)&&(i.timeperiod=this.timePeriodAdapter.adapt(t.timeperiod)),Ot.isNumber(t.intervalSpanLimit)&&(i.intervalSpanLimit=t.intervalSpanLimit),Ot.isExisting(t.i18nMode)&&(i.i18nMode=t.i18nMode),Ot.isExisting(t.order)&&(i.order=this.orderAdapter.adapt(t.order)),i}default(){return new We}}var Ye;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Ye||(Ye={}));class Ie{constructor(t){this.i18n=new Map,this.unit="",this.measures=[],this.dimension="",this.config=new We,this.state=Ye.DIRTY,this.ruleSet=t||new Et,this.dataSetFactory=new Ge,this.state=Ye.DIRTY,this.setI18n(new Map)}setRuleSet(t){this.ruleSet=t||new Et}setI18n(t){this.state=Ye.DIRTY;const i=new Map([["SEPERATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pp3","PL3"],["ac4","AC4"],["py4","PY4"],["fc4","FC4"],["pp4","PL4"],["category"," "],["operation"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"],["CONNECTOR_WS"," und "]]);this.i18n=new Map([...i,...t||new Map])}update(){return Ye.DIRTY===this.state&&(this.unit=this.config.businessunit,this.measures=this.dataSetFactory.createMeasures(this.config.measures,this.i18n,this.config.i18nMode),this.dimension=this.dataSetFactory.createDimension(this.config.scenarios,this.config.timeperiod,this.config.order,this.i18n,this.config.intervalSpanLimit),this.state=Ye.UP_TO_DATE),this}setConfig(t){this.config=this.initConfig(t)}initConfig(t){this.state=Ye.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}}class Be{constructor(t="",i=""){this.name=t,this.unit=i}}class ze{construnctor(){}adapt(t){const i=new Be;return Ot.isString(t.name)&&(i.name=t.name),Ot.isString(t.unit)&&(i.unit=t.unit),i}default(){return new Be("","")}}class He{constructor(t=v.now(),i=v.now(),s=N.AUTO,e=Z.AUTO){this.start=t,this.end=i,this.format=s,this.link=e}}class Ve{construnctor(){}adapt(t){const i=new He;return Ot.isDate(t.start)&&(i.start=t.start),Ot.isDate(t.end)&&(i.end=t.end),Ot.isExisting(t.format)&&(i.format=t.format),Ot.isExisting(t.link)&&(i.link=t.link),i}default(){return new He}}const je=class{constructor(i){t(this,i),this.businessUnit="",this.scenarios=[],this.measures=[],this.intervalSpanLimit=28,this.order={hierarchy:[],direction:T.ASC},this.i18n=new Map,this.i18nMode=mt.ALL,this.title=new Ie(new Et)}async setBusinessUnit(t){this.businessUnit=t}async setProps(t){Object.keys(t).forEach((i=>{this[i]=t[i]}))}render(){return i("div",{key:"48c386989821f8893046247277c018f08fefa557"},i("div",{key:"21561f606551d3413ce6f1b3157eb0f1d2f532a3",innerHTML:zt(this.title.unit)}),i("div",{key:"8882fa69e8baf3d7004370c2c8ea055d9f7e188e"},this.title.measures.map(((t,s)=>i("span",null,this.isFirstElement(s)?this.title.i18n.get("SEPERATOR_WS"):"",i("span",{class:"measure"},t.name)," ",t.unit?this.title.i18n.get("in"):""," ",t.unit)))),i("div",{key:"75a24b0f8fb46ae2fee2dbd1c54bf82d90320d3d"},this.title.dimension))}componentWillLoad(){const t=this.prepareConfig();this.title=new Ie(new Et(this.ruleSetConfig)),this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillUpdate(){const t=this.prepareConfig();this.title.setI18n(this.i18n),this.title.setRuleSet(new Et(this.ruleSetConfig)),this.title.setConfig(t)}componentWillRender(){this.title.update()}isFirstElement(t){return 0!==t}prepareConfig(){return new Fe(new ze,new Ve,new tt(new os),new os).adapt({businessunit:this.businessUnit,measures:this.measures,scenarios:this.scenarios,timeperiod:this.timeperiod,intervalSpanLimit:this.intervalSpanLimit,i18nMode:this.i18nMode,order:this.order})}};je.style=':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.measure{font-weight:bold}div{background-color:var(--bn-font-background, white);color:var(--bn-font-color, black)}p{margin:0}';export{Ht as bn_asset,Vt as bn_body,jt as bn_card,Xt as bn_chart_structure,qt as bn_chart_time,Kt as bn_component_style,Zt as bn_context,Pi as bn_dataset,Ai as bn_datasource,Ci as bn_footer,Ni as bn_layout_card,Ui as bn_layout_page,Di as bn_message,Fi as bn_page,Yi as bn_scaling_group,Zi as bn_table,Qi as bn_title,As as ibcs_chart_structure,ce as ibcs_chart_time,De as ibcs_table,je as ibcs_title}