@bino-bi/bn-template-engine 1.0.0-alpha.16 → 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 (326) 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-ff659485.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-BA48JiHe.js +1 -0
  13. package/dist/bn-template-engine/p-BWKdb9ym.js +1 -0
  14. package/dist/bn-template-engine/p-BZV1b5VH.js +1 -0
  15. package/dist/bn-template-engine/p-Bdfxd_Ke.js +1 -0
  16. package/dist/bn-template-engine/p-BqhIhYr1.js +1 -0
  17. package/dist/bn-template-engine/p-C0Pwqx-O.js +1 -0
  18. package/dist/bn-template-engine/p-CBqUr7I8.js +1 -0
  19. package/dist/bn-template-engine/{p-BPDZcex5.js → p-CPzF3Q2m.js} +1 -1
  20. package/dist/bn-template-engine/p-CiudZRQr.js +1 -0
  21. package/dist/bn-template-engine/p-Dg9OcXAO.js +1 -0
  22. package/dist/bn-template-engine/p-DsTzlzxQ.js +1 -0
  23. package/dist/bn-template-engine/p-X6CxL6W-.js +1 -0
  24. package/dist/bn-template-engine/p-a130cb43.entry.js +1 -0
  25. package/dist/bn-template-engine/p-aakBGfzL.js +1 -0
  26. package/dist/bn-template-engine/p-dc745c32.entry.js +1 -0
  27. package/dist/bn-template-engine/p-e96da91f.entry.js +1 -0
  28. package/dist/bn-template-engine/p-f3d1fa06.entry.js +1 -0
  29. package/dist/bn-template-engine/p-fcb43f2c.entry.js +1 -0
  30. package/dist/bn-template-engine/p-rdqTC0_5.js +1 -0
  31. package/dist/cjs/AxisConfig-VnVelfSV.js +233 -0
  32. package/dist/cjs/LabelCollisionManager-nfD5P__k.js +412 -0
  33. package/dist/cjs/NumericScale-BAyYXpKL.js +107 -0
  34. package/dist/cjs/Order-DobBozQC.js +87 -0
  35. package/dist/cjs/SVGStyle-BQOmGWLX.js +8209 -0
  36. package/dist/cjs/SVGVariancesStyleGroup-DCGfHrqh.js +50 -0
  37. package/dist/cjs/VarianceMeasure-NY9yhiNV.js +372 -0
  38. package/dist/cjs/XYChartDataRow-B7OKrAcC.js +829 -0
  39. package/dist/cjs/bn-asset_21.cjs.entry.js +1614 -9670
  40. package/dist/cjs/bn-chart-bubble.cjs.entry.js +762 -0
  41. package/dist/cjs/bn-chart-bullet.cjs.entry.js +785 -0
  42. package/dist/cjs/bn-chart-scatter.cjs.entry.js +658 -0
  43. package/dist/cjs/bn-grid.cjs.entry.js +5 -3
  44. package/dist/cjs/bn-image.cjs.entry.js +5 -3
  45. package/dist/cjs/bn-internationalization.cjs.entry.js +2 -2
  46. package/dist/cjs/bn-ruleset.cjs.entry.js +41 -0
  47. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  48. package/dist/cjs/bn-template.cjs.entry.js +1 -1
  49. package/dist/cjs/bn-text.cjs.entry.js +8 -79
  50. package/dist/cjs/bn-tree.cjs.entry.js +4 -2
  51. package/dist/cjs/{context-protocol-Cn5PL928.js → context-protocol-BDrMkhc4.js} +272 -1
  52. package/dist/cjs/editor-companion.cjs.entry.js +2 -2
  53. package/dist/cjs/ibcs-chart-bubble.cjs.entry.js +624 -0
  54. package/dist/cjs/ibcs-chart-bullet.cjs.entry.js +673 -0
  55. package/dist/cjs/ibcs-chart-scatter.cjs.entry.js +667 -0
  56. package/dist/cjs/layoutObserver-p0wXIWFg.js +350 -0
  57. package/dist/cjs/loader.cjs.js +1 -1
  58. package/dist/cjs/sanitizeHtml-LuZr1IMd.js +85 -0
  59. package/dist/cjs/{scaling-DM2UILdF.js → scaling-BmqxcNOf.js} +1 -1
  60. package/dist/cjs/withScalingGroup-BmcRlWBs.js +73 -0
  61. package/dist/cjs/{withStyled-Dx3uRw9g.js → withStyled-CRiC9fzc.js} +44 -383
  62. package/dist/collection/collection-manifest.json +7 -0
  63. package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.css +10 -0
  64. package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.js +1110 -0
  65. package/dist/collection/components/bn-chart-bubble/ibcs-chart-bubble.css +9 -0
  66. package/dist/collection/components/bn-chart-bubble/ibcs-chart-bubble.js +653 -0
  67. package/dist/collection/components/bn-chart-bubble/utils/BubbleChart.js +472 -0
  68. package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.css +10 -0
  69. package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.js +1014 -0
  70. package/dist/collection/components/bn-chart-bullet/ibcs-chart-bullet.css +9 -0
  71. package/dist/collection/components/bn-chart-bullet/ibcs-chart-bullet.js +538 -0
  72. package/dist/collection/components/bn-chart-bullet/utils/BulletChart.js +440 -0
  73. package/dist/collection/components/bn-chart-bullet/utils/model/BulletChartStyle.js +132 -0
  74. package/dist/collection/components/bn-chart-bullet/utils/model/BulletConfig.js +89 -0
  75. package/dist/collection/components/bn-chart-bullet/utils/model/index.js +2 -0
  76. package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.css +10 -0
  77. package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.js +965 -0
  78. package/dist/collection/components/bn-chart-scatter/ibcs-chart-scatter.css +9 -0
  79. package/dist/collection/components/bn-chart-scatter/ibcs-chart-scatter.js +580 -0
  80. package/dist/collection/components/bn-chart-scatter/utils/ScatterChart.js +409 -0
  81. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +23 -2
  82. package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +29 -4
  83. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +3 -0
  84. package/dist/collection/components/bn-chart-time/bn-chart-time.js +27 -4
  85. package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +29 -4
  86. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +16 -4
  87. package/dist/collection/components/bn-chart-time/utils/elements/StackedColumn.js +3 -3
  88. package/dist/collection/components/bn-component-style/bn-component-style.js +1 -1
  89. package/dist/collection/components/bn-context/bn-context.js +1 -1
  90. package/dist/collection/components/bn-dataset/bn-dataset.js +1 -1
  91. package/dist/collection/components/bn-datasource/bn-datasource.js +1 -1
  92. package/dist/collection/components/bn-footer/bn-footer.js +1 -1
  93. package/dist/collection/components/bn-grid/bn-grid.js +1 -1
  94. package/dist/collection/components/bn-image/bn-image.js +1 -1
  95. package/dist/collection/components/bn-internationalization/bn-internationalization.js +1 -1
  96. package/dist/collection/components/bn-layout-card/bn-layout-card.js +26 -3
  97. package/dist/collection/components/bn-layout-page/bn-layout-page.js +33 -4
  98. package/dist/collection/components/bn-message/bn-message.css +6 -2
  99. package/dist/collection/components/bn-message/bn-message.js +3 -2
  100. package/dist/collection/components/bn-page/bn-page.js +1 -1
  101. package/dist/collection/components/bn-ruleset/bn-ruleset.css +3 -0
  102. package/dist/collection/components/bn-ruleset/bn-ruleset.js +68 -0
  103. package/dist/collection/components/bn-scaling-group/bn-scaling-group.js +1 -1
  104. package/dist/collection/components/bn-table/bn-table.js +146 -14
  105. package/dist/collection/components/bn-table/ibcs-table.css +8 -0
  106. package/dist/collection/components/bn-table/ibcs-table.js +64 -8
  107. package/dist/collection/components/bn-table/utils/Table.js +43 -5
  108. package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +13 -8
  109. package/dist/collection/components/bn-table/utils/elements/TableRow.js +3 -2
  110. package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +47 -0
  111. package/dist/collection/components/bn-table/utils/elements/index.js +1 -0
  112. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +87 -15
  113. package/dist/collection/components/bn-table/utils/helper/DataQuery.js +284 -3
  114. package/dist/collection/components/bn-table/utils/helper/IntervalColumns.js +140 -0
  115. package/dist/collection/components/bn-table/utils/helper/WaterfallCalculator.js +166 -0
  116. package/dist/collection/components/bn-table/utils/helper/index.js +2 -0
  117. package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +10 -0
  118. package/dist/collection/components/bn-template/bn-template.js +1 -1
  119. package/dist/collection/components/bn-text/bn-text.js +2 -75
  120. package/dist/collection/components/bn-title/bn-title.js +27 -3
  121. package/dist/collection/components/bn-title/ibcs-title/ibcs-title.css +4 -0
  122. package/dist/collection/components/bn-title/ibcs-title/ibcs-title.js +29 -3
  123. package/dist/collection/components/bn-title/ibcs-title/utils/Title.js +3 -0
  124. package/dist/collection/components/editor-companion/editor-companion.js +1 -1
  125. package/dist/collection/stores/componentStyles.js +67 -0
  126. package/dist/collection/stores/createScopedStores.js +6 -1
  127. package/dist/collection/stores/internationalization.js +68 -0
  128. package/dist/collection/stores/ruleSets.js +46 -0
  129. package/dist/collection/utils/constants.js +5 -0
  130. package/dist/collection/utils/ibcsRuleSet.js +14 -26
  131. package/dist/collection/utils/sanitizeHtml.js +81 -0
  132. package/dist/collection/utils/validate.js +24 -0
  133. package/dist/collection/utils/withComponentStyle.js +3 -5
  134. package/dist/collection/utils/withInheritedProps.js +1 -1
  135. package/dist/collection/utils/withRuleSet.js +105 -0
  136. package/dist/collection/utils/withScalingGroup.js +3 -0
  137. package/dist/collection/utils/xy/FacetGrid.js +36 -0
  138. package/dist/collection/utils/xy/IsoCurves.js +156 -0
  139. package/dist/collection/utils/xy/NumericScale.js +103 -0
  140. package/dist/collection/utils/xy/PointLabeler.js +96 -0
  141. package/dist/collection/utils/xy/RadiusScale.js +42 -0
  142. package/dist/collection/utils/xy/SeriesPalette.js +80 -0
  143. package/dist/collection/utils/xy/VarianceMeasure.js +76 -0
  144. package/dist/collection/utils/xy/XYFrame.js +120 -0
  145. package/dist/collection/utils/xy/XYLegend.js +107 -0
  146. package/dist/collection/utils/xy/model/AxisConfig.js +221 -0
  147. package/dist/collection/utils/xy/model/ScaleFactorsXYChart.js +69 -0
  148. package/dist/collection/utils/xy/model/XYChartDataRow.js +0 -0
  149. package/dist/collection/utils/xy/model/XYChartStyle.js +52 -0
  150. package/dist/components/AxisConfig.js +1 -0
  151. package/dist/components/CompareUtil.js +1 -0
  152. package/dist/components/DataFormatDigits.js +1 -1
  153. package/dist/components/LabelCollisionManager.js +1 -0
  154. package/dist/components/NumericScale.js +1 -0
  155. package/dist/components/Order.js +1 -1
  156. package/dist/components/SVGVariancesStyleGroup.js +1 -1
  157. package/dist/components/SiPrefix.js +1 -0
  158. package/dist/components/StringAdapter.js +1 -0
  159. package/dist/components/VarianceMeasure.js +1 -0
  160. package/dist/components/XYChartDataRow.js +1 -0
  161. package/dist/components/bn-chart-bubble.d.ts +11 -0
  162. package/dist/components/bn-chart-bubble.js +1 -0
  163. package/dist/components/bn-chart-bullet.d.ts +11 -0
  164. package/dist/components/bn-chart-bullet.js +1 -0
  165. package/dist/components/bn-chart-scatter.d.ts +11 -0
  166. package/dist/components/bn-chart-scatter.js +1 -0
  167. package/dist/components/bn-chart-structure.js +1 -1
  168. package/dist/components/bn-chart-time.js +1 -1
  169. package/dist/components/bn-component-style.js +1 -1
  170. package/dist/components/bn-context.js +1 -1
  171. package/dist/components/bn-dataset.js +1 -1
  172. package/dist/components/bn-datasource.js +1 -1
  173. package/dist/components/bn-footer2.js +1 -1
  174. package/dist/components/bn-grid.js +1 -1
  175. package/dist/components/bn-image.js +1 -1
  176. package/dist/components/bn-internationalization.js +1 -1
  177. package/dist/components/bn-layout-card.js +1 -1
  178. package/dist/components/bn-layout-page.js +1 -1
  179. package/dist/components/bn-message2.js +1 -1
  180. package/dist/components/bn-page2.js +1 -1
  181. package/dist/components/bn-ruleset.d.ts +11 -0
  182. package/dist/components/bn-ruleset.js +1 -0
  183. package/dist/components/bn-scaling-group.js +1 -1
  184. package/dist/components/bn-table.js +1 -1
  185. package/dist/components/bn-template.js +1 -1
  186. package/dist/components/bn-text.js +1 -1
  187. package/dist/components/bn-title2.js +1 -1
  188. package/dist/components/bn-tree.js +1 -1
  189. package/dist/components/context-protocol.js +1 -1
  190. package/dist/components/editor-companion.js +1 -1
  191. package/dist/components/formatter.js +1 -0
  192. package/dist/components/ibcs-chart-bubble.d.ts +11 -0
  193. package/dist/components/ibcs-chart-bubble.js +1 -0
  194. package/dist/components/ibcs-chart-bubble2.js +1 -0
  195. package/dist/components/ibcs-chart-bullet.d.ts +11 -0
  196. package/dist/components/ibcs-chart-bullet.js +1 -0
  197. package/dist/components/ibcs-chart-bullet2.js +1 -0
  198. package/dist/components/ibcs-chart-scatter.d.ts +11 -0
  199. package/dist/components/ibcs-chart-scatter.js +1 -0
  200. package/dist/components/ibcs-chart-scatter2.js +1 -0
  201. package/dist/components/ibcs-chart-structure2.js +1 -1
  202. package/dist/components/ibcs-chart-time2.js +1 -1
  203. package/dist/components/ibcs-table2.js +1 -1
  204. package/dist/components/ibcs-title2.js +1 -1
  205. package/dist/components/layoutObserver.js +1 -1
  206. package/dist/components/luxon.js +1 -1
  207. package/dist/components/main.js +1 -0
  208. package/dist/components/merge.js +1 -0
  209. package/dist/components/sanitizeHtml.js +1 -0
  210. package/dist/components/stackColors.js +1 -0
  211. package/dist/components/validate.js +1 -1
  212. package/dist/components/withComponentStyle.js +1 -1
  213. package/dist/components/withDataset.js +1 -0
  214. package/dist/components/withRuleSet.js +1 -0
  215. package/dist/components/withScalingGroup.js +1 -0
  216. package/dist/components/withStyled.js +1 -1
  217. package/dist/esm/AxisConfig-C_zWCKlL.js +224 -0
  218. package/dist/esm/LabelCollisionManager-8swVQHKA.js +404 -0
  219. package/dist/esm/NumericScale-DsTzlzxQ.js +105 -0
  220. package/dist/esm/Order-BPeWfygb.js +83 -0
  221. package/dist/esm/SVGStyle-BxEDw9zh.js +8199 -0
  222. package/dist/esm/SVGVariancesStyleGroup-DRQYvSDD.js +48 -0
  223. package/dist/esm/VarianceMeasure-DnwNKspZ.js +364 -0
  224. package/dist/esm/XYChartDataRow-DeV4r-Wm.js +820 -0
  225. package/dist/esm/bn-asset_21.entry.js +1127 -9183
  226. package/dist/esm/bn-chart-bubble.entry.js +760 -0
  227. package/dist/esm/bn-chart-bullet.entry.js +783 -0
  228. package/dist/esm/bn-chart-scatter.entry.js +656 -0
  229. package/dist/esm/bn-grid.entry.js +5 -3
  230. package/dist/esm/bn-image.entry.js +5 -3
  231. package/dist/esm/bn-internationalization.entry.js +2 -2
  232. package/dist/esm/bn-ruleset.entry.js +39 -0
  233. package/dist/esm/bn-template-engine.js +1 -1
  234. package/dist/esm/bn-template.entry.js +1 -1
  235. package/dist/esm/bn-text.entry.js +7 -78
  236. package/dist/esm/bn-tree.entry.js +4 -2
  237. package/dist/esm/{context-protocol-BB-4Onmw.js → context-protocol-1Yj1uKvh.js} +268 -2
  238. package/dist/esm/editor-companion.entry.js +2 -2
  239. package/dist/esm/ibcs-chart-bubble.entry.js +622 -0
  240. package/dist/esm/ibcs-chart-bullet.entry.js +671 -0
  241. package/dist/esm/ibcs-chart-scatter.entry.js +665 -0
  242. package/dist/esm/layoutObserver-DCbmpGrz.js +345 -0
  243. package/dist/esm/loader.js +1 -1
  244. package/dist/esm/sanitizeHtml-BA48JiHe.js +83 -0
  245. package/dist/esm/{scaling-h4KcBet3.js → scaling-B_k50v9z.js} +2 -2
  246. package/dist/esm/withScalingGroup-Br70pAv9.js +71 -0
  247. package/dist/esm/{withStyled-BBvU2f-A.js → withStyled-Br2DGTPs.js} +30 -367
  248. package/dist/types/components/bn-chart-bubble/bn-chart-bubble.d.ts +193 -0
  249. package/dist/types/components/bn-chart-bubble/ibcs-chart-bubble.d.ts +58 -0
  250. package/dist/types/components/bn-chart-bubble/utils/BubbleChart.d.ts +91 -0
  251. package/dist/types/components/bn-chart-bullet/bn-chart-bullet.d.ts +172 -0
  252. package/dist/types/components/bn-chart-bullet/ibcs-chart-bullet.d.ts +52 -0
  253. package/dist/types/components/bn-chart-bullet/utils/BulletChart.d.ts +91 -0
  254. package/dist/types/components/bn-chart-bullet/utils/model/BulletChartStyle.d.ts +70 -0
  255. package/dist/types/components/bn-chart-bullet/utils/model/BulletConfig.d.ts +43 -0
  256. package/dist/types/components/bn-chart-bullet/utils/model/index.d.ts +2 -0
  257. package/dist/types/components/bn-chart-scatter/bn-chart-scatter.d.ts +172 -0
  258. package/dist/types/components/bn-chart-scatter/ibcs-chart-scatter.d.ts +53 -0
  259. package/dist/types/components/bn-chart-scatter/utils/ScatterChart.d.ts +66 -0
  260. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +7 -0
  261. package/dist/types/components/bn-chart-structure/ibcs-chart-structure.d.ts +2 -0
  262. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +1 -0
  263. package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +10 -1
  264. package/dist/types/components/bn-chart-time/ibcs-chart-time.d.ts +2 -0
  265. package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +1 -0
  266. package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +10 -0
  267. package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +14 -0
  268. package/dist/types/components/bn-message/bn-message.d.ts +5 -2
  269. package/dist/types/components/bn-ruleset/bn-ruleset.d.ts +8 -0
  270. package/dist/types/components/bn-table/bn-table.d.ts +38 -5
  271. package/dist/types/components/bn-table/ibcs-table.d.ts +8 -1
  272. package/dist/types/components/bn-table/utils/Table.d.ts +8 -0
  273. package/dist/types/components/bn-table/utils/elements/Cell.d.ts +2 -0
  274. package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +33 -0
  275. package/dist/types/components/bn-table/utils/elements/TableRow.d.ts +2 -1
  276. package/dist/types/components/bn-table/utils/elements/WaterfallBar.d.ts +21 -0
  277. package/dist/types/components/bn-table/utils/elements/index.d.ts +1 -0
  278. package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +13 -7
  279. package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +17 -0
  280. package/dist/types/components/bn-table/utils/helper/IntervalColumns.d.ts +37 -0
  281. package/dist/types/components/bn-table/utils/helper/WaterfallCalculator.d.ts +55 -0
  282. package/dist/types/components/bn-table/utils/helper/index.d.ts +2 -0
  283. package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +4 -0
  284. package/dist/types/components/bn-table/utils/model/index.d.ts +21 -0
  285. package/dist/types/components/bn-title/bn-title.d.ts +11 -1
  286. package/dist/types/components/bn-title/ibcs-title/ibcs-title.d.ts +2 -0
  287. package/dist/types/components/bn-title/ibcs-title/utils/Title.d.ts +1 -0
  288. package/dist/types/components.d.ts +1383 -82
  289. package/dist/types/context/context-protocol.d.ts +2 -0
  290. package/dist/types/stores/componentStyles.d.ts +41 -0
  291. package/dist/types/stores/createScopedStores.d.ts +2 -0
  292. package/dist/types/stores/ruleSets.d.ts +40 -0
  293. package/dist/types/utils/constants.d.ts +5 -0
  294. package/dist/types/utils/ibcsRuleSet.d.ts +6 -1
  295. package/dist/types/utils/model/ChartStyles.d.ts +2 -1
  296. package/dist/types/utils/sanitizeHtml.d.ts +6 -0
  297. package/dist/types/utils/validate.d.ts +12 -0
  298. package/dist/types/utils/withInheritedProps.d.ts +11 -0
  299. package/dist/types/utils/withRuleSet.d.ts +24 -0
  300. package/dist/types/utils/xy/FacetGrid.d.ts +27 -0
  301. package/dist/types/utils/xy/IsoCurves.d.ts +46 -0
  302. package/dist/types/utils/xy/NumericScale.d.ts +41 -0
  303. package/dist/types/utils/xy/PointLabeler.d.ts +58 -0
  304. package/dist/types/utils/xy/RadiusScale.d.ts +26 -0
  305. package/dist/types/utils/xy/SeriesPalette.d.ts +59 -0
  306. package/dist/types/utils/xy/VarianceMeasure.d.ts +37 -0
  307. package/dist/types/utils/xy/XYFrame.d.ts +44 -0
  308. package/dist/types/utils/xy/XYLegend.d.ts +43 -0
  309. package/dist/types/utils/xy/model/AxisConfig.d.ts +96 -0
  310. package/dist/types/utils/xy/model/ScaleFactorsXYChart.d.ts +36 -0
  311. package/dist/types/utils/xy/model/XYChartDataRow.d.ts +157 -0
  312. package/dist/types/utils/xy/model/XYChartStyle.d.ts +31 -0
  313. package/package.json +1 -1
  314. package/readme.md +7 -3
  315. package/dist/bn-template-engine/p-19f49fbc.entry.js +0 -1
  316. package/dist/bn-template-engine/p-3465fcdc.entry.js +0 -1
  317. package/dist/bn-template-engine/p-67746414.entry.js +0 -1
  318. package/dist/bn-template-engine/p-6b469808.entry.js +0 -1
  319. package/dist/bn-template-engine/p-86ca2d5e.entry.js +0 -1
  320. package/dist/bn-template-engine/p-Tx6omDWp.js +0 -1
  321. package/dist/bn-template-engine/p-d724ab88.entry.js +0 -1
  322. package/dist/bn-template-engine/p-efd3b67a.entry.js +0 -1
  323. package/dist/bn-template-engine/p-z9bPNFYF.js +0 -1
  324. package/dist/components/ibcsRuleSet.js +0 -1
  325. package/dist/components/scaling.js +0 -1
  326. package/dist/components/withInheritedProps.js +0 -1
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as e,h as n,Fragment as i,transformTag as s}from"@stencil/core/internal/client";import{g as r,B as o}from"./context-protocol.js";const c=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.distinctCache=new Map}connectedCallback(){this.stores=r(this.element)}internationalizationKeys(){return Promise.resolve(o)}getDistinctFromDataSource(t,e){const n=`datasource:${t}:${e}`;if(this.distinctCache.has(n))return Promise.resolve(this.distinctCache.get(n));const i=this.distinct(this.queryRows(t),e);return this.distinctCache.set(n,i),Promise.resolve(i)}getDistinctFromDataset(t,e){const n=`dataset:${t}:${e}`;if(this.distinctCache.has(n))return Promise.resolve(this.distinctCache.get(n));const i=this.distinct(this.queryRows(t),e);return this.distinctCache.set(n,i),Promise.resolve(i)}render(){return n(i,{key:"d6eb8ea68a4d507142547f4014f1dd3db58dcfd4"})}queryRows(t){try{return this.stores.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){return[]}}distinct(t,e){return[...new Set(t.map((t=>t[e])))].filter((t=>null!=t))}get element(){return this}static get style(){return"editor-companion{display:none}"}},[0,"editor-companion",{internationalizationKeys:[64],getDistinctFromDataSource:[64],getDistinctFromDataset:[64]}]),a=c,m=function(){"undefined"!=typeof customElements&&["editor-companion"].forEach((t=>{"editor-companion"===t&&(customElements.get(s(t))||customElements.define(s(t),c))}))};export{a as EditorCompanion,m as defineCustomElement}
1
+ import{proxyCustomElement as t,HTMLElement as e,h as n,Fragment as i,transformTag as s}from"@stencil/core/internal/client";import{g as r,B as o}from"./context-protocol.js";const a=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.distinctCache=new Map}connectedCallback(){this.stores=r(this.element)}internationalizationKeys(){return Promise.resolve(o)}getDistinctFromDataSource(t,e){const n=`datasource:${t}:${e}`;if(this.distinctCache.has(n))return Promise.resolve(this.distinctCache.get(n));const i=this.distinct(this.queryRows(t),e);return this.distinctCache.set(n,i),Promise.resolve(i)}getDistinctFromDataset(t,e){const n=`dataset:${t}:${e}`;if(this.distinctCache.has(n))return Promise.resolve(this.distinctCache.get(n));const i=this.distinct(this.queryRows(t),e);return this.distinctCache.set(n,i),Promise.resolve(i)}render(){return n(i,{key:"35a8fdaa36fb5f9b042d1fad904f9b54a58ba79c"})}queryRows(t){try{return this.stores.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){return[]}}distinct(t,e){return[...new Set(t.map((t=>t[e])))].filter((t=>null!=t))}get element(){return this}static get style(){return"editor-companion{display:none}"}},[0,"editor-companion",{internationalizationKeys:[64],getDistinctFromDataSource:[64],getDistinctFromDataset:[64]}]),c=a,m=function(){"undefined"!=typeof customElements&&["editor-companion"].forEach((t=>{"editor-companion"===t&&(customElements.get(s(t))||customElements.define(s(t),a))}))};export{c as EditorCompanion,m as defineCustomElement}
@@ -0,0 +1 @@
1
+ import{S as t,g as r}from"./luxon.js";import{m as n}from"./merge.js";class e{constructor(t){this.type="",this.base="",this.delta="",this.direction="",this.isValid=!1;const r=/(d|dr)(pl\d|ac\d|fc\d|pp\d)_(pl\d|ac\d|fc\d|pp\d)_(pos|neg|neu)/;if(r.test(t)){const n=r.exec(t);null!=n&&(this.type=String(n[1]),this.base=String(n[2]),this.delta=String(n[3]),this.direction=String(n[4]),this.isValid=!0)}}}class i{constructor(r){this._dateFormat={year:"YYYY",quarter:"Q[Q] YYYY",month:"MMM YYYY",locale:"[KW]WW YYYY",day:"DD.MM.YYYY"},this._dateLinkFormat={avg:"Ø[DATE]",interval:"[DATE]..[DATE]",start:".[DATE]",end:"[DATE].",ytd:"_[DATE]",ytg:"[DATE]_",cum:"[DATE]_[DATE]",mat:"~[DATE]",none:"[DATE]"},this._scenarioMap=new Map;const e=n([t,null!=r?r:{}]);Object.entries(e.scenarios).forEach((([t,r])=>{var n,e,i;this.createScenarioMapEntry(t,null!==(n=r.name)&&void 0!==n?n:t,null!==(e=r.colorIndex)&&void 0!==e?e:10,null!==(i=r.sortIndex)&&void 0!==i?i:0)})),this._fallBackScenario=e.fallback}createScenarioMapEntry(t,r,n,e){const i=r,o=n;[1,2,3,4].forEach((n=>{this._scenarioMap.set(t+n,{name:r+n,group:i,colorIndex:o,sortIndex:e+10*n})}))}getScenario(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t):this._fallBackScenario}getScenarioGroup(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t).name:this._fallBackScenario.name}getScenarioColorIndex(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t).colorIndex:this._fallBackScenario.colorIndex}getScenarioSorIndex(t){const r=this.normalizeVarianceScenario(t);return this._scenarioMap.has(r)?this._scenarioMap.get(r).sortIndex:this._fallBackScenario.sortIndex}normalizeVarianceScenario(t){if(null==t)return"";const r=new e(t);return r.isValid?r.type+r.delta:t}}var o,s,a={},c=r(function(){if(o)return a;o=1;var t={};return Object.defineProperty(a,"__esModule",{value:!0}),a.default=function(r,n){void 0===n&&(n={});var e=JSON.stringify({text:r,options:n});if(t[e])return t[e];n.font=n.font||"Times",n.fontSize=n.fontSize||"16px",n.fontWeight=n.fontWeight||"normal",n.width=n.width||"auto";var i=function(t,r){var n=document.createElement("div"),e=document.createTextNode(t);return n.appendChild(e),n.style.fontFamily=r.font,n.style.fontSize=r.fontSize,n.style.fontWeight=r.fontWeight,n.style.position="absolute",n.style.visibility="hidden",n.style.left="-999px",n.style.top="-999px",n.style.width=r.width,n.style.height="auto",document.body.appendChild(n),n}(r,n),o={width:i.offsetWidth,height:i.offsetHeight};return function(t){t.parentNode.removeChild(t)}(i),t[e]=o,o},a}());!function(t){t.OPERATION="operation",t.ROWGROUP="rowGroup",t.ROWGROUPINDEX="rowGroupIndex",t.CURRENTROW="currentRow",t.CATEGORY="category",t.CATEGORYINDEX="categoryIndex",t.SUBCATEGORY="subCategory",t.SUBCATEGORYINDEX="subCategoryIndex",t.COLUMNGROUP="columnGroup",t.COLUMNGROUPINDEX="columnIndex",t.COLUMNSUBGROUP="columnSubGroup",t.COLUMNSUBGROUPINDEX="columnSubGroupIndex",t.AC1="ac1",t.AC2="ac2",t.AC3="ac3",t.AC4="ac4",t.PP1="pp1",t.PP2="pp2",t.PP3="pp3",t.PP4="pp4",t.FC1="fc1",t.FC2="fc2",t.FC3="fc3",t.FC4="fc4",t.PL1="pl1",t.PL2="pl2",t.PL3="pl3",t.PL4="pl4",t.TOTALROWCOUNT="totalRowCnt",t.ROWNR="rowNr",t.TYPE="type"}(s||(s={}));class u{static number(t,r="decimal",n=1,e=0,i=1){return(t/i).toLocaleString("de-DE",{style:r,useGrouping:!0,maximumFractionDigits:n,minimumFractionDigits:e}).replace(/\s+(%)/g,"$1").replace(/\s/g,this.postfixSeperator).replace(/\./g,this.tsdDelimiter)}static translateScenarioLabel(t,r){if(null==t)return"";const n=new e(t);if(!n.isValid)return`${r.get(t)||t}`;let i,o;return s.AC1===n.base?(i=r.get("dr"===n.type?"ibcssymbol_delta_ac_relative":"ibcssymbol_delta_ac"),o=r.get(n.delta)||n.delta):(i=r.get("dr"===n.type?"ibcssymbol_delta_generic_relative":"ibcssymbol_delta_generic"),o=`${r.get(n.base)||n.base} - ${r.get(n.delta)||n.delta}`),void 0===i&&(i="{%}"),`${i.replace("{%}",o)}`}static getMaxWidthOfArrayItems(t,r,n){return c(t.map((t=>u.translateScenarioLabel(t,r))).reduce(((t,r)=>t.length<r.length?r:t),""),{font:n.fontStyles.font,fontSize:n.fontStyles.size+"px"}).width}}u.tsdDelimiter=".",u.postfixSeperator=",";export{c as C,u as F,i as I,s as Q,e as V}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface IbcsChartBubble extends Components.IbcsChartBubble, HTMLElement {}
4
+ export const IbcsChartBubble: {
5
+ prototype: IbcsChartBubble;
6
+ new (): IbcsChartBubble;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1 @@
1
+ import{I as s,d as b}from"./ibcs-chart-bubble2.js";const o=s,r=b;export{o as IbcsChartBubble,r as defineCustomElement}
@@ -0,0 +1 @@
1
+ import{proxyCustomElement as t,HTMLElement as i,h as s,Host as e,transformTag as h}from"@stencil/core/internal/client";import{r as n,m as l,s as o,g as r,d as a}from"./context-protocol.js";import{C as c,F as d,I as u}from"./formatter.js";import{S as v,F as m,a as b,b as f,P as w}from"./main.js";import{X as p,r as y,a as g,b as x,P as M,F as $,c as S,S as L}from"./XYChartDataRow.js";import{g as k}from"./stackColors.js";import{N as z}from"./NumericScale.js";import{r as N}from"./VarianceMeasure.js";class C{constructor(t,i,s,e,h){this.mode=t,this.vMax=i,this.rMaxPx=s,this.rMinPx=e,this.areaPerUnitPx2=h}static local(t,i,s){return new C("local",t,i,s,0)}static grouped(t){return new C("grouped",0,0,0,t)}radius(t){return"grouped"===this.mode?t<=0?0:Math.sqrt(this.areaPerUnitPx2*t/Math.PI):this.vMax<=0||t<=0?this.rMinPx:Math.max(this.rMinPx,this.rMaxPx*Math.sqrt(t/this.vMax))}}class W{constructor(t,i,s,e,h,n){var l,o,r,a;this.ruleSet=t,this.config=e,this.styles=h,this.availableWidth=n,this.warnings=[],this.canvasHeight=0,this.i18nMap=new Map,this.hatchPatterns=new Set,this.scaleOverflowCount=0,this.svgRoot=null;const c=new p,d=""!==s?i.exec(`SELECT * FROM ${s}`):[],u=(null!=d?d:[]).map((t=>c.adapt(t)));this.data=y(u,{pointLevel:e.pointLevel,seriesLevel:e.seriesLevel,facetLevel:null!==e.facet?"rowgroup"===e.facet.level?"rowGroup":"category":null,measures:{x:null!==(l=N(e.x.measure))&&void 0!==l?l:{kind:"scenario",slot:"ac1"},y:null!==(o=N(e.y.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac2"},size:null!==(r=N(e.size.measure))&&void 0!==r?r:{kind:"scenario",slot:"ac3"},share:null!==e.share&&null!==(a=N(e.share.measure))&&void 0!==a?a:void 0},compareFamily:e.compareFamily,domains:{x:{min:e.x.min,max:e.x.max},y:{min:e.y.min,max:e.y.max}},limit:e.limit,limitBy:"size"}),this.warnings.push(...this.data.warnings)}get em(){return this.styles.fontStyles.size}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=c(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,e,h={}){var n,l;t.text(i).font({size:this.styles.fontStyles.size,weight:h.bold?"bold":"normal",anchor:null!==(n=h.anchor)&&void 0!==n?n:"start"}).fill(null!==(l=h.color)&&void 0!==l?l:this.styles.fontStyles.color).attr({x:s,y:e,"font-family":this.fontFamily()})}hasNoData(){return 0===this.data.totalPoints}getWarnings(){return this.warnings}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.canvasHeight}setI18n(t){this.i18nMap=t}addWarningOnce(t,i){this.warnings.some((i=>i.code===t))||this.warnings.push({code:t,data:i})}primaryColorIndex(){const t=N(this.config.size.measure);return null===t||"variance"===t.kind?10:this.ruleSet.getScenarioColorIndex(t.slot)}compareColorIndex(){return this.ruleSet.getScenarioColorIndex(`${this.config.compareFamily}1`)}seriesHue(t){const{color:i,overflowed:s}=n(t,this.styles.seriesColors);return s&&this.addWarningOnce("xy-series-overflow",{}),i}familyDisplayName(t){return this.ruleSet.getScenario(`${t}1`).group}legendModel(){var t,i;const s=[],e=null!==(i=null!==(t=this.config.size.label)&&void 0!==t?t:this.i18nMap.get("legend.size"))&&void 0!==i?i:"";""!==e&&(s.push(e),void 0!==this.config.size.unit&&""!==this.config.size.unit&&s.push(`${this.i18nMap.get("axis.in")||"in"} ${this.config.size.unit}`));const h=this.seriesHue(0),n=[];if(null!==this.config.compareFamily){const t=N(this.config.size.measure),i=null!==t&&"scenario"===t.kind?t.slot.replace(/\d+$/,""):"ac";n.push({label:this.familyDisplayName(this.config.compareFamily),treatment:l(this.compareColorIndex(),h,"bubble")}),n.push({label:this.familyDisplayName(i),treatment:l(this.primaryColorIndex(),h,"bubble")})}const o=this.data.series.map((t=>{var i;return{label:""===t.key?null!==(i=this.ruleSet.getScenario("").name)&&void 0!==i?i:"Series":t.key,treatment:l(this.primaryColorIndex(),this.seriesHue(t.index),"bubble")}}));return{sizeCaption:s,title:this.i18nMap.get("legend.title")||null,compareEntries:n,entries:o}}toString(){const t=new v;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}axisTitle(t,i){var s;const e=null!==(s=t.label)&&void 0!==s?s:"";return""===e?"":void 0===t.unit||""===t.unit?e:`${e} ${i} ${t.unit}`}draw(t){var i,s,e,h,n,l,o,r,a,c,d;this.warnings=this.data.warnings.slice(),this.hatchPatterns.clear(),this.scaleOverflowCount=0,this.svgRoot=t;const u=this.em,v=this.styles.padding,m=this.i18nMap.get("axis.in")||"in",b=t.group(),f=new g(this.styles),w=this.legendModel(),p=this.config.legend.show&&(w.entries.length>0||w.sizeCaption.length>0),y=p?f.measure(w,this.config.legend.position):{width:0,height:0},x="right"===this.config.legend.position&&p?y.width+u:0,M=""!==this.config.chartTitle?1.6*u:0,S=this.axisTitle(this.config.y,m),L=this.axisTitle(this.config.x,m),k=""!==S?1.4*u:.4*u,N=1.4*u+(""!==L?1.3*u:0);let W,F=3*u,T={x:0,y:0,width:0,height:0},P=[];const j=Math.max(1,this.data.facets.length),A=null===(i=this.config.facet)||void 0===i?void 0:i.columns,D=z.domain(null!==(e=null===(s=this.data.extents)||void 0===s?void 0:s.xMin)&&void 0!==e?e:0,null!==(n=null===(h=this.data.extents)||void 0===h?void 0:h.xMax)&&void 0!==n?n:1,{min:this.config.x.min,max:this.config.x.max}),E=z.domain(null!==(o=null===(l=this.data.extents)||void 0===l?void 0:l.yMin)&&void 0!==o?o:0,null!==(a=null===(r=this.data.extents)||void 0===r?void 0:r.yMax)&&void 0!==a?a:1,{min:this.config.y.min,max:this.config.y.max});for(let t=0;t<2;t++){const t=Math.max(10,this.availableWidth-v.left-v.right-F-x);T={x:v.left+F,y:v.top+M+k,width:t,height:t/this.config.aspect},W=new $(j,A,T,this.styles.scaleFactors.panelGap*u);const i=W.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*u)))),e=new z(E[0],E[1],i,0);P=e.ticks(s);const h=z.tickDecimals(P);F=Math.max(...P.map((t=>this.textWidth(this.formatTick(t,h)))),u)+this.styles.scaleFactors.axisTickLength*u+.4*u}this.canvasHeight=T.y+T.height+N+("bottom"===this.config.legend.position&&p?y.height+u:0)+v.bottom,""!==this.config.chartTitle&&this.drawText(b,this.config.chartTitle,v.left,v.top+u,{bold:!0}),""!==S&&this.drawAxisTitleText(b,this.config.y,m,v.left,T.y-.6*u,"start");const H=this.buildPanels(W,D,E),I=H[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(H[0].rect.width/(7*u))))),X=z.tickDecimals(I),R=z.tickDecimals(P),U=this.config.sizeAreaPerUnit>0?C.grouped(this.config.sizeAreaPerUnit):C.local(null!==(d=null===(c=this.data.extents)||void 0===c?void 0:c.sizeMax)&&void 0!==d?d:0,this.styles.scaleFactors.bubbleMaxRadius*u,this.styles.scaleFactors.bubbleMinRadius*u);0===this.data.facets.length?this.drawPanel(b,H[0],{key:"",points:[]},U,I,P,X,R,!0,!0):this.data.facets.forEach(((t,i)=>{this.drawPanel(b,H[i],t,U,I,P,X,R,W.isOuterLeft(i),W.isOuterBottom(i),this.data.facets.length>1?t.key:"")})),""!==L&&this.drawAxisTitleText(b,this.config.x,m,T.x+T.width,T.y+T.height+2.6*u,"end"),p&&("right"===this.config.legend.position?f.draw(b,w,T.x+T.width+u,T.y,"right"):f.draw(b,w,T.x,T.y+T.height+N,"bottom")),this.scaleOverflowCount>0&&this.addWarningOnce("bubble-scale-overflow",{count:String(this.scaleOverflowCount)}),t.group().addClass("annotations")}drawAxisTitleText(t,i,s,e,h,n){var l;const o=null!==(l=i.label)&&void 0!==l?l:"",r=void 0!==i.unit&&""!==i.unit?`${s} ${i.unit}`:"",a=.3*this.em;"start"===n?(this.drawText(t,o,e,h,{bold:!0}),""!==r&&this.drawText(t,r,e+this.textWidth(o,!0)+a,h,{})):""!==r?(this.drawText(t,r,e,h,{anchor:"end"}),this.drawText(t,o,e-this.textWidth(r)-a,h,{anchor:"end",bold:!0})):this.drawText(t,o,e,h,{anchor:"end",bold:!0})}buildPanels(t,i,s){const e=[];for(let h=0;h<t.count;h++){const n=t.panelRect(h),l=new z(i[0],i[1],n.x,n.x+n.width),o=new z(s[0],s[1],n.y+n.height,n.y);e.push({rect:n,xScale:l,yScale:o,frame:new x(l,o,n,this.styles)})}return e}treatmentFill(t,i,s){return!0!==t.hatch?t.fill:(this.ensureHatchPattern(i,s),`url(#xy-fc-${i})`)}ensureHatchPattern(t,i){this.hatchPatterns.has(t)||null===this.svgRoot||(this.hatchPatterns.add(t),this.svgRoot.defs().pattern(10,10,(t=>{t.rect(10,10).fill("#ffffff"),t.line(0,10,10,0).stroke({color:i,width:2}),t.line(-2.5,2.5,2.5,-2.5).stroke({color:i,width:2}),t.line(7.5,12.5,12.5,7.5).stroke({color:i,width:2})})).id(`xy-fc-${t}`))}drawPanel(t,i,s,e,h,n,r,a,c,d,u=""){var v,m,b,f;const w=t.group(),p=this.em;i.frame.drawBands(w,this.config.x.highlight,this.config.y.highlight),i.frame.drawGrid(w,n,void 0===this.config.x.refLine&&void 0===this.config.y.refLine&&i.rect.width>30*p?h:void 0),i.frame.drawRefLines(w,this.config.x.refLine,this.config.y.refLine),i.frame.drawFrame(w);const y=w.group().id("compare"),g=w.group().id("primary"),x=new M(i.rect,this.styles.scaleFactors.labelToMark*p),$=[...s.points].sort(((t,i)=>{var s,e;return(null!==(s=i.size)&&void 0!==s?s:0)-(null!==(e=t.size)&&void 0!==e?e:0)})),S=[];for(const t of $){const s=null!==(m=null===(v=this.data.series.find((i=>i.key===t.seriesKey)))||void 0===v?void 0:v.index)&&void 0!==m?m:0,h=this.seriesHue(s),n=l(this.primaryColorIndex(),h,"bubble"),r=i.xScale.scale(t.x),a=i.yScale.scale(t.y),c=e.radius(null!==(b=t.size)&&void 0!==b?b:0);if(this.config.sizeAreaPerUnit>0&&this.bubbleExceedsPanel(i.rect,r,a,c)&&this.scaleOverflowCount++,null!=t.compare){const n=l(this.compareColorIndex(),h,"bubble"),o=i.xScale.scale(t.compare.x),r=i.yScale.scale(t.compare.y),a=e.radius(null!==(f=t.compare.size)&&void 0!==f?f:0);this.drawBubble(y,o,r,a,n,s,h),x.registerMark(o,r,a),this.config.labels.values&&void 0!==t.compare.size&&a>=1.2*p&&this.drawValueLabel(y,o,r,a,t.compare.size,n.fill)}this.drawBubble(g,r,a,c,n,s,h),x.registerMark(r,a,c),void 0!==t.share&&c>0&&this.drawShareSlice(g,r,a,c,t.share,o(h)),this.config.labels.values&&void 0!==t.size&&this.drawValueLabel(g,r,a,c,t.size,!0===n.hatch?"#ffffff":n.fill),S.push({point:t,cx:r,cy:a,r:c,seriesIndex:s,hue:h,treatment:n})}this.drawNameLabels(w,x,S),i.frame.drawTickLabels(w,{ticksX:h,ticksY:n,xDecimals:r,yDecimals:a,showXLabels:d,showYLabels:c}),""!==u&&i.frame.drawPanelTitle(w,u)}bubbleExceedsPanel(t,i,s,e){return i-e<t.x||i+e>t.x+t.width||s-e<t.y||s+e>t.y+t.height}drawBubble(t,i,s,e,h,n,l){e<=0||t.circle(2*e).center(i,s).fill(this.treatmentFill(h,n,l)).stroke({color:h.stroke,width:h.strokeWidth})}drawShareSlice(t,i,s,e,h,n){if(h<=0)return;if(h>=1)return void t.circle(2*e).center(i,s).fill(n);const l=2*h*Math.PI,o=i+e*Math.sin(l),r=s-e*Math.cos(l),a=l>Math.PI?1:0;t.path(`M ${i} ${s} L ${i} ${s-e} A ${e} ${e} 0 ${a} 1 ${o} ${r} Z`).fill(n).stroke("none")}drawValueLabel(t,i,s,e,h,n){const l=d.number(h,"decimal",1,1);this.textWidth(l)+.4*this.em>2*e||this.drawText(t,l,i,s+.35*this.em,{anchor:"middle",color:k(n.startsWith("#")?n:"#ffffff")})}drawNameLabels(t,i,s){const e=[...s].sort(((t,i)=>{var s,e;return(null!==(s=i.point.size)&&void 0!==s?s:0)-(null!==(e=t.point.size)&&void 0!==e?e:0)})),{selected:h,unknownNames:n}=i.selectCandidates(e,this.config.labels.points,this.config.labels.max,(t=>t.point.name));n.length>0&&this.addWarningOnce("xy-label-unknown",{names:n.join(", ")});const l=h.map((t=>({name:t.point.name,cx:t.cx,cy:t.cy,r:t.r,width:this.textWidth(t.point.name),height:1.1*this.em})));for(const s of i.place(l))this.drawText(t,s.candidate.name,s.x,s.y+.9*s.candidate.height,{})}formatTick(t,i){return d.number(t,"decimal",i,i)}}const F=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-label-unknown","xy-series-overflow","xy-point-budget","bubble-size-negative","bubble-share-range","bubble-scale-overflow"],T=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.share=null,this.compareFamily=null,this.facet=null,this.pointLevel="category",this.seriesLevel=null,this.aspect=16/9,this.limit=0,this.filter="",this.sizeAreaPerUnit=0,this.i18n=new Map,this.containerWidth=0,this.svgMarkup=""}getDb(){return this.stores||(this.stores=r(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=this.tableName?a(this.tableName,this.filter):"";this.chart=new W(new u(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,x:this.x,y:this.y,size:this.size,share:this.share,compareFamily:this.compareFamily,labels:this.labels,legend:this.legend,facet:this.facet,pointLevel:this.pointLevel,seriesLevel:this.seriesLevel,aspect:this.aspect,limit:this.limit,sizeAreaPerUnit:this.sizeAreaPerUnit},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of F){const s=`WARN_${t}`;if(i.has(t)){const e=void 0!==this.translate?this.translate(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:e})}else this.errors.remove(s)}}prepareStyle(){return new S(new L,new m,new b(new f),new w).adapt(this.styles)}render(){if(void 0===this.chart)return s(e,null);if(this.chart.hasNoData()){const t=this.i18n.get("no-data")||"==No Data==";return s(e,null,s("p",{class:"warning"},t))}return s(e,null,s("div",{innerHTML:this.svgMarkup}))}get element(){return this}static get style(){return':host{position:relative;display:inline-block}.warning{font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}'}},[1,"ibcs-chart-bubble",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],x:[16],y:[16],size:[16],share:[16],compareFamily:[1,"compare-family"],labels:[16],legend:[16],facet:[16],pointLevel:[1,"point-level"],seriesLevel:[1,"series-level"],aspect:[2],limit:[2],filter:[1],sizeAreaPerUnit:[2,"size-area-per-unit"],styles:[16],i18n:[16],containerWidth:[2,"container-width"],ruleSetConfig:[16],errors:[16],translate:[16]}]);function P(){"undefined"!=typeof customElements&&["ibcs-chart-bubble"].forEach((t=>{"ibcs-chart-bubble"===t&&(customElements.get(h(t))||customElements.define(h(t),T))}))}export{T as I,P as d}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface IbcsChartBullet extends Components.IbcsChartBullet, HTMLElement {}
4
+ export const IbcsChartBullet: {
5
+ prototype: IbcsChartBullet;
6
+ new (): IbcsChartBullet;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1 @@
1
+ import{I as s,d as t}from"./ibcs-chart-bullet2.js";const o=s,r=t;export{o as IbcsChartBullet,r as defineCustomElement}
@@ -0,0 +1 @@
1
+ import{proxyCustomElement as t,HTMLElement as i,h as s,Host as h,transformTag as e}from"@stencil/core/internal/client";import{g as n,d as r}from"./context-protocol.js";import{A as a,C as o}from"./CompareUtil.js";import{C as l,F as c,I as u}from"./formatter.js";import{S as d,F as m,a as f,b as v,P as g}from"./main.js";import{S as p}from"./SVGVariancesStyleGroup.js";import{a as w}from"./Order.js";import{N as b}from"./NumericScale.js";import{s as $}from"./VarianceMeasure.js";class y{constructor(t,i,s,h,e,n){this.ruleSet=t,this.config=h,this.styles=e,this.availableWidth=n,this.rows=[],this.warnings=[],this.i18nMap=new Map,this.populateModel(i,s),this.normalized="target"===this.config.normalize&&this.rows.some((t=>null!==t.fraction)),null!==this.config.target&&this.rows.length>0&&!this.rows.some((t=>null!==t.target))&&this.warnings.push({code:"bullet-target-none",data:{}})}populateModel(t,i){var s,h,e;if(""===i)return;const n=this.config.level,r=this.config.order,a=this.config.actual.measure,o=null!==(h=null===(s=this.config.target)||void 0===s?void 0:s.measure)&&void 0!==h?h:null,l=[a,...null!==o?[o]:[]].map((t=>`SUM(${t}) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(", ");let c;try{c=t.exec(`SELECT ${this.createSelectString(n,r)}, ${l},\n MIN(transformOperator(operation)) as opMin, MAX(transformOperator(operation)) as opMax\n FROM ${i}\n GROUP BY ${this.createGroupByStr(n,r)}\n ORDER BY ${this.createOrderStr(n,r)}`)}catch(t){return void console.error("BulletChart: populateModel query failed",t)}let u=null!=c?c:[];this.config.limit>0&&(u=u.slice(0,this.config.limit));let d=0,m=0,f=0;for(const t of u){const i=this.readValue(t,a),s=null!==o?this.readValue(t,o):null,h="number"==typeof t.opMin?t.opMin:1,n="number"==typeof t.opMax?t.opMax:1;let r=-1===h&&-1===n?"-":"+";h!==n&&(r="+",d++);let l=null;"target"===this.config.normalize&&(null===s?null!==o&&m++:s<=0?f++:null!==i&&(i<0?f++:l=i/s)),this.rows.push({category:String(null!==(e=t.category)&&void 0!==e?e:""),actual:i,target:s,operation:r,sentiment:this.sentiment(i,s,r),fraction:l})}d>0&&this.warnings.push({code:"bullet-mixed-operation",data:{count:String(d)}}),m>0&&this.warnings.push({code:"bullet-target-missing",data:{count:String(m)}}),f>0&&this.warnings.push({code:"bullet-target-invalid",data:{count:String(f)}})}readValue(t,i){if(0===t[`${i}_cnt`])return null;const s=t[i];return"number"==typeof s&&isFinite(s)?s:null}sentiment(t,i,s){return null===t||null===i||t===i?"neu":t>i!=("-"===s)?"pos":"neg"}createSelectString(t,i){return t===a.CATEGORY&&i.hierarchy.includes(w.CATEGORYINDEX)?`${w.CATEGORYINDEX}, ${a.CATEGORY} as category`:t===a.ROWGROUP&&i.hierarchy.includes(w.ROWGROUPINDEX)?`${w.ROWGROUPINDEX}, ${a.ROWGROUP} as category`:t===a.SUBCATEGORY&&i.hierarchy.includes(w.SUBCATEGORYINDEX)?`${w.SUBCATEGORYINDEX}, ${a.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===a.CATEGORY&&i.hierarchy.includes(w.CATEGORYINDEX)?`${w.CATEGORYINDEX}, ${a.CATEGORY}`:t===a.ROWGROUP&&i.hierarchy.includes(w.ROWGROUPINDEX)?`${w.ROWGROUPINDEX}, ${a.ROWGROUP}`:t===a.SUBCATEGORY&&i.hierarchy.includes(w.SUBCATEGORYINDEX)?`${w.SUBCATEGORYINDEX}, ${a.SUBCATEGORY}`:`${t.toString()}`}createOrderStr(t,i){let s=`${t.toLowerCase()}`;return i.hierarchy.length>=1&&(s=`${i.hierarchy.toString()} ${null==i?void 0:i.direction}`),s}get em(){return this.styles.fontStyles.size}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=l(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,h,e={}){var n,r,a;t.text(i).font({size:null!==(n=e.size)&&void 0!==n?n:this.styles.fontStyles.size,weight:e.bold?"bold":"normal",anchor:null!==(r=e.anchor)&&void 0!==r?r:"start"}).fill(null!==(a=e.color)&&void 0!==a?a:this.styles.fontStyles.color).attr({x:s,y:h,"font-family":this.fontFamily()})}setI18n(t){this.i18nMap=t}hasNoData(){return 0===this.rows.length}getWarnings(){return this.warnings}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.styles.padding.top+this.titleHeight()+this.headerHeight()+this.rows.length*this.rowBlockHeight()+this.styles.padding.bottom}titleHeight(){return""!==this.config.chartTitle?1.6*this.em:0}headerHeight(){return this.rows.length>0?1.2*this.em:0}rowBlockHeight(){const t=this.em,i=this.styles.scaleFactors.rowHeight*t;return this.normalized?i:i+this.styles.scaleFactors.tickStripHeight*t}valueLabel(t){return null===t||"none"===this.config.labels.show?"":c.number(t,"decimal",this.config.labels.decimals,0)}targetFamily(){var t,i,s;const h=null!==(i=null===(t=this.config.target)||void 0===t?void 0:t.measure)&&void 0!==i?i:"pl1";return null!==(s={10:"ac",20:"pp",30:"fc",50:"pl"}[this.ruleSet.getScenarioColorIndex(h)])&&void 0!==s?s:$(h)}actualLabel(){var t;return null!==(t=this.config.actual.label)&&void 0!==t?t:c.translateScenarioLabel(this.config.actual.measure,this.i18nMap)}targetLabel(){return null===this.config.target?"":void 0!==this.config.target.label?this.config.target.label:this.normalized?this.i18nMap.get("target")||"Target":c.translateScenarioLabel(this.config.target.measure,this.i18nMap)}toString(){const t=new d;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}draw(t){var i,s;const h=this.em,e=this.styles.scaleFactors,n=this.styles.padding,r=t.group();if(""!==this.config.chartTitle&&this.drawText(r,this.config.chartTitle,n.left,n.top+h,{bold:!0}),0===this.rows.length)return void t.group().addClass("annotations");const a=e.rowHeight*h,o=this.rowBlockHeight(),l=n.top+this.titleHeight()+this.headerHeight(),c=l+(this.rows.length-1)*o+a,u=Math.max(...this.rows.map((t=>this.textWidth(t.category,!0))),h),d=this.rows.map((t=>this.valueLabel(t.actual))),m="none"===this.config.labels.show?0:Math.max(...d.map((t=>this.textWidth(t))),0),f=n.left+u+e.labelToAxis*h,v=Math.max(10,this.availableWidth-f-n.right-m-(m>0?e.labelToBar*h:0)),g=null!==(i=this.config.actual.unit)&&void 0!==i?i:null===(s=this.config.target)||void 0===s?void 0:s.unit,p=this.i18nMap.get("axis.in")||"in",w=l-.35*h;void 0!==g&&""!==g&&this.drawText(r,`${p} ${g}`,n.left,w,{}),this.drawText(r,this.actualLabel(),f+.2*h,w,{}),this.normalized?this.drawNormalized(r,f,v,l,c,a,o,d):this.drawClassic(r,f,v,l,a,o,d),this.rows.forEach(((t,i)=>{this.drawText(r,t.category,f-e.labelToAxis*h,l+i*o+a/2+.35*h,{anchor:"end",bold:!0})})),r.line(f,l-.2*h,f,c+.2*h).stroke({color:this.styles.axisStyles.ac.stroke,width:e.axisLineWidth}),t.group().addClass("annotations")}drawNormalized(t,i,s,h,e,n,r,a){const o=this.em,l=this.styles.scaleFactors,c=1.05*Math.max(1,...this.rows.map((t=>{var i;return null!==(i=t.fraction)&&void 0!==i?i:0}))),u=t=>i+t/c*s,d=u(1),m=this.styles.barStyles.getSVGStyle(this.targetFamily()),f=t.line(d,h-.3*o,d,e+.3*o).stroke({color:m.stroke,width:l.targetLineWidth});void 0!==m.dasharray&&f.attr("stroke-dasharray",m.dasharray),this.drawText(t,this.targetLabel(),d,h-.35*o,{anchor:"middle",bold:!0}),this.rows.forEach(((s,e)=>{const c=h+e*r+n/2;if(null===s.fraction)return void this.drawValueText(t,a[e],i+l.labelToBar*o,c);const m=l.barHeight*o,f=u(s.fraction);if(t.rect(Math.max(0,f-i),m).move(i,c-m/2).fill(this.styles.barStyles.ac.fill).stroke({color:this.styles.barStyles.ac.stroke,width:this.styles.barStyles.ac.width}),this.config.showVariances&&"neu"!==s.sentiment){const i=l.varianceHeight*o,h=this.styles.varianceStyles.getSVGStyle(s.sentiment);t.rect(Math.abs(f-d),i).move(Math.min(f,d),c-i/2).fill(h.fill).stroke({color:h.stroke,width:h.width})}this.drawValueText(t,a[e],Math.max(f,d)+l.labelToBar*o,c)}))}drawClassic(t,i,s,h,e,n,r){const a=this.em,o=this.styles.scaleFactors,l=o.barHeight*a,u=this.config.ranges.length>0;this.rows.forEach(((d,m)=>{var f,v;const g=h+m*n,p=g+e/2,w=u&&null!==d.target?this.config.ranges.map((t=>t*d.target)):[],$=Math.max(null!==(f=d.actual)&&void 0!==f?f:0,null!==(v=d.target)&&void 0!==v?v:0,...w);if($<=0)return void this.drawValueText(t,r[m],i+o.labelToBar*a,p);const y=b.niceStep($,4),M=Math.ceil($/y-1e-9*y)*y,S=new b(0,M,i,i+s);let x=i;w.forEach(((i,s)=>{const h=.8*e;t.rect(Math.max(0,S.scale(i)-x),h).move(x,p-h/2).fill(this.styles.rangeColors[Math.min(s,this.styles.rangeColors.length-1)]).stroke("none"),x=S.scale(i)}));let N=i;if(null!==d.actual&&d.actual>0){const s=S.scale(d.actual);t.rect(s-i,l).move(i,p-l/2).fill(this.styles.barStyles.ac.fill).stroke({color:this.styles.barStyles.ac.stroke,width:this.styles.barStyles.ac.width}),N=s}if(null!==d.target&&d.target>0){const i=S.scale(d.target),s=o.targetTickHeight*a,e=this.styles.barStyles.getSVGStyle(this.targetFamily()),n=t.line(i,p-s/2,i,p+s/2).stroke({color:e.stroke,width:o.targetLineWidth});void 0!==e.dasharray&&n.attr("stroke-dasharray",e.dasharray),0===m&&this.drawText(t,this.targetLabel(),i,h-.35*a,{anchor:"middle"}),N=Math.max(N,i)}N=Math.max(N,x),this.drawValueText(t,r[m],N+o.labelToBar*a,p);const C=S.ticks(4),E=b.tickDecimals(C),F=g+e;for(const i of C){const s=S.scale(i);t.line(s,F,s,F+o.axisTickLength*a).stroke({color:this.styles.axisStyles.ac.stroke,width:o.axisLineWidth}),this.drawText(t,c.number(i,"decimal",E,E),s,F+o.tickStripHeight*a-.2*a,{anchor:"middle"})}}))}drawValueText(t,i,s,h){""!==i&&this.drawText(t,i,s,h+.35*this.em,{})}}class M{constructor(){this.rowHeight=1.9,this.barHeight=.66,this.varianceHeight=.4,this.targetTickHeight=1.1,this.targetLineWidth=2,this.axisLineWidth=1,this.labelToBar=.3,this.labelToAxis=.3,this.axisTickLength=.35,this.tickStripHeight=1.2}}class S{adapt(t){const i=new M;return o.isNumber(t.rowHeight)&&(i.rowHeight=t.rowHeight),o.isNumber(t.barHeight)&&(i.barHeight=t.barHeight),o.isNumber(t.varianceHeight)&&(i.varianceHeight=t.varianceHeight),o.isNumber(t.targetTickHeight)&&(i.targetTickHeight=t.targetTickHeight),o.isNumber(t.targetLineWidth)&&(i.targetLineWidth=t.targetLineWidth),o.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),o.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),o.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),o.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),o.isNumber(t.tickStripHeight)&&(i.tickStripHeight=t.tickStripHeight),i}default(){return new M}}class x{constructor(t,i,s,h,e,n){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=h,this.varianceStyles=e,this.padding=n,this.rangeColors=["#D9D9D9","#EFEFEF"]}}class N{constructor(t,i,s,h,e){this.scaleFactorsBulletChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=h,this.paddingAdapter=e}adapt(t){const i=this.default();return o.isExisting(t)&&(o.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsBulletChartAdapter.adapt(t.scaleFactors)),o.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),o.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),o.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),o.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),o.isExisting(t.padding)&&(i.padding=this.paddingAdapter.adapt(t.padding)),Array.isArray(t.rangeColors)&&t.rangeColors.length>0&&(i.rangeColors=t.rangeColors)),i}default(){return new x(this.scaleFactorsBulletChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingAdapter.default())}}const C=["bullet-target-missing","bullet-target-invalid","bullet-mixed-operation","bullet-target-none"],E=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.target=null,this.ranges=[],this.normalize="target",this.showVariances=!0,this.level=a.CATEGORY,this.limit=0,this.filter="",this.i18n=new Map,this.containerWidth=0,this.svgMarkup=""}getDb(){return this.stores||(this.stores=n(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=this.tableName?r(this.tableName,this.filter):"";this.chart=new y(new u(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,actual:this.actual,target:this.target,ranges:this.ranges,normalize:this.normalize,showVariances:this.showVariances,level:this.level,order:this.order,limit:this.limit,labels:this.labels},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of C){const s=`WARN_${t}`;if(i.has(t)){const h=void 0!==this.translate?this.translate(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:h})}else this.errors.remove(s)}}prepareStyle(){return new N(new S,new m,new f(new v),new p(new v),new g).adapt(this.styles)}render(){if(void 0===this.chart)return s(h,null);if(this.chart.hasNoData()){const t=this.i18n.get("no-data")||"==No Data==";return s(h,null,s("p",{class:"warning"},t))}return s(h,null,s("div",{innerHTML:this.svgMarkup}))}get element(){return this}static get style(){return':host{position:relative;display:inline-block}.warning{font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}'}},[1,"ibcs-chart-bullet",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],actual:[16],target:[16],ranges:[16],normalize:[1],showVariances:[4,"show-variances"],level:[1],order:[16],limit:[2],labels:[16],filter:[1],styles:[16],i18n:[16],containerWidth:[2,"container-width"],ruleSetConfig:[16],errors:[16],translate:[16]}]);function F(){"undefined"!=typeof customElements&&["ibcs-chart-bullet"].forEach((t=>{"ibcs-chart-bullet"===t&&(customElements.get(e(t))||customElements.define(e(t),E))}))}export{E as I,F as d}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface IbcsChartScatter extends Components.IbcsChartScatter, HTMLElement {}
4
+ export const IbcsChartScatter: {
5
+ prototype: IbcsChartScatter;
6
+ new (): IbcsChartScatter;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1 @@
1
+ import{I as s,d as t}from"./ibcs-chart-scatter2.js";const r=s,a=t;export{r as IbcsChartScatter,a as defineCustomElement}
@@ -0,0 +1 @@
1
+ import{proxyCustomElement as t,HTMLElement as i,h as s,Host as n,transformTag as e}from"@stencil/core/internal/client";import{r as h,m as o,g as r,d as a}from"./context-protocol.js";import{C as l,F as c,I as u}from"./formatter.js";import{S as d,F as v,a as m,b as f,P as w}from"./main.js";import{X as p,r as x,a as g,b as y,P as M,F as b,c as $,S as L}from"./XYChartDataRow.js";import{N as S}from"./NumericScale.js";import{r as k}from"./VarianceMeasure.js";class N{constructor(t,i){this.xScale=t,this.yScale=i}isPositiveDomain(){return this.xScale.domainMin>0&&this.yScale.domainMin>0}static autoK(t){const i=t.filter((t=>t>0)).sort(((t,i)=>t-i));if(0===i.length)return[];const s=t=>i[Math.min(i.length-1,Math.floor(t*i.length))];let n=N.ladderValues(s(.25),s(.75));if(n.length<2&&(n=N.ladderValues(i[0],i[i.length-1])),0===n.length)return[];if(1===n.length)return n;if(n.length<=4)return n;const e=[];for(let t=0;t<4;t++)e.push(n[Math.round(t*(n.length-1)/3)]);return[...new Set(e)]}static ladderValues(t,i){if(t<=0||i<t)return[];const s=[];for(let n=Math.floor(Math.log10(t))-1;n<=Math.ceil(Math.log10(i));n++)for(const e of[1,2,5]){const h=e*Math.pow(10,n);h>=t&&h<=i&&s.push(h)}return s}visibleRange(t){if(!this.isPositiveDomain()||t<=0)return null;const i=Math.max(this.xScale.domainMin,t/this.yScale.domainMax),s=Math.min(this.xScale.domainMax,t/this.yScale.domainMin);return i>=s?null:[i,s]}samples(t){const i=this.visibleRange(t);if(null===i)return null;const[s,n]=i,e=[];for(let i=0;i<64;i++){const h=s*Math.pow(n/s,i/63);e.push({x:this.xScale.scale(h),y:this.yScale.scale(t/h)})}return e}path(t){const i=this.samples(t);return null===i?null:i.map(((t,i)=>`${0===i?"M":"L"} ${t.x} ${t.y}`)).join(" ")}exitPoint(t){const i=this.visibleRange(t);if(null===i)return null;const s=i[1],n=s>=this.xScale.domainMax-1e-9*Math.abs(this.xScale.domainMax);return{x:this.xScale.scale(s),y:this.yScale.scale(t/s),edge:n?"right":"bottom"}}regionPath(t){if(!this.isPositiveDomain()||t<=0)return null;const i=this.xScale.domainMin,s=this.xScale.domainMax,n=this.yScale.domainMin,e=this.yScale.domainMax,h=this.xScale.scale(i),o=this.xScale.scale(s),r=this.yScale.scale(e),a=this.yScale.scale(n);if(t>=s*e)return null;if(t<=i*n)return`M ${h} ${r} L ${o} ${r} L ${o} ${a} L ${h} ${a} Z`;const l=this.samples(t),[c,u]=this.visibleRange(t),d=c>i,v=u>=s-1e-9*Math.abs(s),m=l.map(((t,i)=>`${0===i?"M":"L"} ${t.x} ${t.y}`));return v||m.push(`L ${o} ${a}`),m.push(`L ${o} ${r}`),d||m.push(`L ${h} ${r}`),m.push("Z"),m.join(" ")}}class T{constructor(t,i,s,n,e,h){var o,r;this.ruleSet=t,this.config=n,this.styles=e,this.availableWidth=h,this.warnings=[],this.canvasHeight=0,this.i18nMap=new Map;const a=new p,l=""!==s?i.exec(`SELECT * FROM ${s}`):[],c=(null!=l?l:[]).map((t=>a.adapt(t)));this.data=x(c,{pointLevel:n.pointLevel,seriesLevel:n.seriesLevel,facetLevel:null!==n.facet?"rowgroup"===n.facet.level?"rowGroup":"category":null,measures:{x:null!==(o=k(n.x.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac1"},y:null!==(r=k(n.y.measure))&&void 0!==r?r:{kind:"scenario",slot:"ac2"}},domains:{x:{min:n.x.min,max:n.x.max},y:{min:n.y.min,max:n.y.max}},limit:n.limit,limitBy:"order"}),this.warnings.push(...this.data.warnings)}get em(){return this.styles.fontStyles.size}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=l(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,n,e={}){var h,o,r;t.text(i).font({size:null!==(h=e.size)&&void 0!==h?h:this.styles.fontStyles.size,weight:e.bold?"bold":"normal",anchor:null!==(o=e.anchor)&&void 0!==o?o:"start"}).fill(null!==(r=e.color)&&void 0!==r?r:this.styles.fontStyles.color).attr({x:s,y:n,"font-family":this.fontFamily()})}hasNoData(){return 0===this.data.totalPoints}getWarnings(){return this.warnings}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.canvasHeight}axisTitle(t,i){var s;const n=null!==(s=t.label)&&void 0!==s?s:"";return""===n?"":void 0===t.unit||""===t.unit?n:`${n} ${i} ${t.unit}`}setI18n(t){this.i18nMap=t}legendModel(){const t=this.data.series.map((t=>{var i;return{label:""===t.key?null!==(i=this.ruleSet.getScenario("").name)&&void 0!==i?i:"Series":t.key,treatment:this.seriesTreatment(t.index)}}));return{sizeCaption:[],title:this.i18nMap.get("legend.title")||null,compareEntries:[],entries:t}}primaryColorIndex(){const t=k(this.config.x.measure);return null===t||"variance"===t.kind?10:this.ruleSet.getScenarioColorIndex(t.slot)}seriesTreatment(t){const{color:i,overflowed:s}=h(t,this.styles.seriesColors);return s&&this.addWarningOnce("xy-series-overflow",{}),o(this.primaryColorIndex(),i,"dot")}addWarningOnce(t,i){this.warnings.some((i=>i.code===t))||this.warnings.push({code:t,data:i})}toString(){const t=new d;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}draw(t){var i,s,n,e,h,o,r,a,l,c;this.warnings=this.data.warnings.slice();const u=this.em,d=this.styles.padding,v=this.i18nMap.get("axis.in")||"in",m=t.group(),f=new g(this.styles),w=this.legendModel(),p=this.config.legend.show&&w.entries.length>0,x=p?f.measure(w,this.config.legend.position):{width:0,height:0},y=null!==this.config.iso,M=y?Math.max(3*u,this.textWidth(null!==(i=this.config.iso.label)&&void 0!==i?i:"",!0)+u,this.textWidth(void 0!==this.config.iso.unit&&""!==this.config.iso.unit?`${v} ${this.config.iso.unit}`:"")+u):0,$="right"===this.config.legend.position?Math.max(p?x.width+u:0,M):M,L=""!==this.config.chartTitle?1.6*u:0,k=this.axisTitle(this.config.y,v),N=this.axisTitle(this.config.x,v),T=""!==k?1.4*u:.4*u,W=1.4*u+(""!==N?1.3*u:0);let C,P=3*u,D={x:0,y:0,width:0,height:0},j=[];const E=Math.max(1,this.data.facets.length),F=null===(s=this.config.facet)||void 0===s?void 0:s.columns,I=S.domain(null!==(e=null===(n=this.data.extents)||void 0===n?void 0:n.xMin)&&void 0!==e?e:0,null!==(o=null===(h=this.data.extents)||void 0===h?void 0:h.xMax)&&void 0!==o?o:1,{min:this.config.x.min,max:this.config.x.max}),A=S.domain(null!==(a=null===(r=this.data.extents)||void 0===r?void 0:r.yMin)&&void 0!==a?a:0,null!==(c=null===(l=this.data.extents)||void 0===l?void 0:l.yMax)&&void 0!==c?c:1,{min:this.config.y.min,max:this.config.y.max});for(let t=0;t<2;t++){const t=Math.max(10,this.availableWidth-d.left-d.right-P-$);D={x:d.left+P,y:d.top+L+T,width:t,height:t/this.config.aspect},C=new b(E,F,D,this.styles.scaleFactors.panelGap*u);const i=C.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*u)))),n=new S(A[0],A[1],i,0);j=n.ticks(s);const e=S.tickDecimals(j);P=Math.max(...j.map((t=>this.textWidth(this.formatTick(t,e)))),u)+this.styles.scaleFactors.axisTickLength*u+.4*u}this.canvasHeight=D.y+D.height+W+("bottom"===this.config.legend.position&&p?x.height+u:0)+d.bottom,""!==this.config.chartTitle&&this.drawText(m,this.config.chartTitle,d.left,d.top+u,{bold:!0}),""!==k&&this.drawAxisTitleText(m,this.config.y,v,d.left,D.y-.6*u,"start");const H=this.buildPanels(C,I,A),R=H[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(H[0].rect.width/(7*u))))),X=S.tickDecimals(R),z=S.tickDecimals(j);let V=!1;y&&(I[0]>0&&A[0]>0?V=!0:this.addWarningOnce("xy-iso-domain",{})),0===this.data.facets.length?this.drawPanel(m,H[0],{key:"",points:[]},R,j,X,z,!0,!0,V):this.data.facets.forEach(((t,i)=>{this.drawPanel(m,H[i],t,R,j,X,z,C.isOuterLeft(i),C.isOuterBottom(i),V,this.data.facets.length>1?t.key:"")})),""!==N&&this.drawAxisTitleText(m,this.config.x,v,D.x+D.width,D.y+D.height+2.6*u,"end"),p&&("right"===this.config.legend.position?f.draw(m,w,D.x+D.width+u,D.y,"right"):f.draw(m,w,D.x,D.y+D.height+W,"bottom")),t.group().addClass("annotations")}drawAxisTitleText(t,i,s,n,e,h){var o;const r=null!==(o=i.label)&&void 0!==o?o:"",a=void 0!==i.unit&&""!==i.unit?`${s} ${i.unit}`:"",l=.3*this.em;"start"===h?(this.drawText(t,r,n,e,{bold:!0}),""!==a&&this.drawText(t,a,n+this.textWidth(r,!0)+l,e,{})):""!==a?(this.drawText(t,a,n,e,{anchor:"end"}),this.drawText(t,r,n-this.textWidth(a)-l,e,{anchor:"end",bold:!0})):this.drawText(t,r,n,e,{anchor:"end",bold:!0})}buildPanels(t,i,s){const n=[];for(let e=0;e<t.count;e++){const h=t.panelRect(e),o=new S(i[0],i[1],h.x,h.x+h.width),r=new S(s[0],s[1],h.y+h.height,h.y);n.push({rect:h,xScale:o,yScale:r,frame:new y(o,r,h,this.styles)})}return n}drawPanel(t,i,s,n,e,h,o,r,a,l,c=""){var u,d;const v=t.group(),m=this.em;i.frame.drawBands(v,this.config.x.highlight,this.config.y.highlight),i.frame.drawGrid(v,e,void 0===this.config.x.refLine&&void 0===this.config.y.refLine&&i.rect.width>30*m?n:void 0),l&&null!==this.config.iso&&this.drawIso(v,i),i.frame.drawRefLines(v,this.config.x.refLine,this.config.y.refLine),i.frame.drawFrame(v);const f=this.styles.scaleFactors.pointRadius*m,w=new M(i.rect,this.styles.scaleFactors.labelToMark*m),p=[];for(const t of s.points){const s=null!==(d=null===(u=this.data.series.find((i=>i.key===t.seriesKey)))||void 0===u?void 0:u.index)&&void 0!==d?d:0,n=this.seriesTreatment(s),e=i.xScale.scale(t.x),h=i.yScale.scale(t.y);p.push({point:t,cx:e,cy:h,treatment:n});const o=v.circle(2*f).center(e,h).fill(n.fill).stroke({color:n.stroke,width:n.strokeWidth});void 0!==n.dasharray&&o.attr("stroke-dasharray",n.dasharray),w.registerMark(e,h,f)}this.drawPointLabels(v,w,p,f),i.frame.drawTickLabels(v,{ticksX:n,ticksY:e,xDecimals:h,yDecimals:o,showXLabels:a,showYLabels:r}),""!==c&&i.frame.drawPanelTitle(v,c)}drawPointLabels(t,i,s,n){const e=s.reduce(((t,i)=>t+i.cx),0)/Math.max(1,s.length),h=s.reduce(((t,i)=>t+i.cy),0)/Math.max(1,s.length),o=[...s].sort(((t,i)=>Math.hypot(i.cx-e,i.cy-h)-Math.hypot(t.cx-e,t.cy-h))),{selected:r,unknownNames:a}=i.selectCandidates(o,this.config.labels.points,this.config.labels.max,(t=>t.point.name));a.length>0&&this.addWarningOnce("xy-label-unknown",{names:a.join(", ")});const l=r.map((t=>({name:t.point.name,cx:t.cx,cy:t.cy,r:n,width:this.textWidth(t.point.name),height:1.1*this.em})));for(const s of i.place(l))this.drawText(t,s.candidate.name,s.x,s.y+.9*s.candidate.height,{})}drawIso(t,i){const s=this.config.iso,n=new N(i.xScale,i.yScale),e=this.i18nMap.get("axis.in")||"in",h=this.data.facets.flatMap((t=>t.points.map((t=>t.x*t.y)))),o="auto"===s.values?N.autoK(h):s.values;if(void 0!==s.highlight){const i=n.regionPath(s.highlight.from);null!==i&&t.path(i).fill(this.styles.axisStyles.pl.fill).stroke("none")}const r={color:this.styles.axisStyles.fc.stroke,width:this.styles.scaleFactors.gridLineWidth};let a=null;for(const i of o){const s=n.path(i);if(null===s)continue;t.path(s).fill("none").stroke(r);const e=n.exitPoint(i);null!==e&&(this.drawText(t,this.formatTick(i,0),e.x+.4*this.em,"right"===e.edge?e.y+.35*this.em:e.y-.5*this.em,{}),(null===a||e.y<a.y)&&(a=e))}if(null!==a&&void 0!==s.label&&""!==s.label){const i=void 0!==s.unit&&""!==s.unit?`${e} ${s.unit}`:"";this.drawText(t,s.label,a.x+.4*this.em,a.y-1.6*this.em,{bold:!0}),""!==i&&this.drawText(t,i,a.x+.4*this.em,a.y-.5*this.em,{})}}formatTick(t,i){return c.number(t,"decimal",i,i)}}const W=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-iso-domain","xy-label-unknown","xy-series-overflow","xy-point-budget"],C=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.iso=null,this.facet=null,this.pointLevel="category",this.seriesLevel=null,this.aspect=16/9,this.limit=0,this.filter="",this.i18n=new Map,this.containerWidth=0,this.svgMarkup=""}getDb(){return this.stores||(this.stores=r(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=this.tableName?a(this.tableName,this.filter):"";this.chart=new T(new u(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,x:this.x,y:this.y,iso:this.iso,labels:this.labels,legend:this.legend,facet:this.facet,pointLevel:this.pointLevel,seriesLevel:this.seriesLevel,aspect:this.aspect,limit:this.limit},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of W){const s=`WARN_${t}`;if(i.has(t)){const n=void 0!==this.translate?this.translate(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:n})}else this.errors.remove(s)}}prepareStyle(){return new $(new L,new v,new m(new f),new w).adapt(this.styles)}render(){if(void 0===this.chart)return s(n,null);if(this.chart.hasNoData()){const t=this.i18n.get("no-data")||"==No Data==";return s(n,null,s("p",{class:"warning"},t))}return s(n,null,s("div",{innerHTML:this.svgMarkup}))}get element(){return this}static get style(){return':host{position:relative;display:inline-block}.warning{font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}'}},[1,"ibcs-chart-scatter",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],x:[16],y:[16],iso:[16],labels:[16],legend:[16],facet:[16],pointLevel:[1,"point-level"],seriesLevel:[1,"series-level"],aspect:[2],limit:[2],filter:[1],styles:[16],i18n:[16],containerWidth:[2,"container-width"],ruleSetConfig:[16],errors:[16],translate:[16]}]);function P(){"undefined"!=typeof customElements&&["ibcs-chart-scatter"].forEach((t=>{"ibcs-chart-scatter"===t&&(customElements.get(e(t))||customElements.define(e(t),C))}))}export{C as I,P as d}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as i,h as s,Host as h,transformTag as e}from"@stencil/core/internal/client";import{S as n,g as r,a as o,I as a,F as l,b as c,c as u,d,P as f}from"./SVGVariancesStyleGroup.js";import{j as p,i as g,k as v,A as w,h as b,f as m,b as P,O as S}from"./Order.js";import{D as y,S as L,b as x}from"./DataFormatDigits.js";import{S as M,F as k,I as T,C,V as A}from"./ibcsRuleSet.js";import{d as $,g as O}from"./context-protocol.js";class _{constructor(t,i,s,h,e,n,r,o,a=!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=h,this.leftSideLengthSync=e,this.topSideLabelHeight=n>0?this.fontSize:0,this.hasStackedHeaders=a,this.leftSideLabelLength=this.calculateSideLabelLength(n,r,o),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,h){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<h/2&&(this.axisPosition.x=h/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 h=t/2;let e=i;return h>e&&(e=h),s>e&&(e=s),e}}class E{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 R{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}}class D{constructor(t){this.container=new n,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 W,N,X,B,Y;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(W||(W={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(N||(N={}));class V{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 v(new M).default(),this.level=w.CATEGORY,this.filter="",this.measureScale=new L,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null}}class H{constructor(t,i,s,h,e,n){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=h,this.db=e,this.fromExpr=n}adapt(t){const i=p.adaptArray(t.data,this.dataRowAdapter),s=p.adaptArray(t.scenarios,this.stringAdapter),h=new V(i,s);return g.isArray(t.variances)&&(h.variances=p.adaptArray(t.variances,this.stringAdapter)),g.isString(t.title)&&(h.title=t.title),g.isBoolean(t.hideCategories)&&(h.hideCategories=t.hideCategories),g.isNumber(t.pixelPerUnit)&&(h.pixelPerUnit=t.pixelPerUnit),g.isNumber(t.pixelPerPercentage)&&(h.pixelPerPercentage=t.pixelPerPercentage),g.isNumber(t.limit)&&(h.limit=t.limit),g.isExisting(t.sortOrder)&&(h.sortOrder=this.orderAdapter.adapt(t.sortOrder)),g.isExisting(t.level)&&(h.level=t.level),g.isString(t.filter)&&(h.filter=t.filter.trim()),g.isExisting(t.measureScale)&&(h.measureScale=y.calculateMeasureScale(this.db,this.fromExpr,h.scenarios,t.measureScale)),g.isString(t.measureUnit)&&(h.measureUnit=t.measureUnit),g.isBoolean(t.showMeasureScale)&&(h.showMeasureScale=t.showMeasureScale),g.isExisting(t.dataFormatDigits)&&(h.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),g.isExisting(t.stackConfig)&&(h.stackConfig=t.stackConfig),h}default(){return new V([],[])}}class F{constructor(t,i,s,h){this.value=t,this.scenario=i,this.pixelPerUnit=s||1,this.variance="neg"===h||h===X.NEG?X.NEG:"pos"===h||h===X.POS?X.POS:X.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:X.NEU===this.variance?X.NEU:X.POS===this.variance?X.NEG:X.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 G{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 U{constructor(){}adapt(t){const i=new G;return g.isOperator(t.operation)&&(i.operation=t.operation),g.isNumber(t.rowGroupIndex)&&g.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),g.isNumber(t.categoryIndex)&&g.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),g.isNumber(t.subCategoryIndex)&&g.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),g.isNumber(t.columnGroupIndex)&&g.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),g.isNumber(t.columnSubGroupIndex)&&g.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 G}setActualValues(t,i){g.isNumber(t.ac1)&&(i.ac1=t.ac1),g.isNumber(t.ac2)&&(i.ac2=t.ac2),g.isNumber(t.ac3)&&(i.ac3=t.ac3),g.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){g.isNumber(t.pl1)&&(i.pl1=t.pl1),g.isNumber(t.pl2)&&(i.pl2=t.pl2),g.isNumber(t.pl3)&&(i.pl3=t.pl3),g.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){g.isNumber(t.pp1)&&(i.pp1=t.pp1),g.isNumber(t.pp2)&&(i.pp2=t.pp2),g.isNumber(t.pp3)&&(i.pp3=t.pp3),g.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){g.isNumber(t.fc1)&&(i.fc1=t.fc1),g.isNumber(t.fc2)&&(i.fc2=t.fc2),g.isNumber(t.fc3)&&(i.fc3=t.fc3),g.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class z{constructor(t,i,s,h,e,n){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=h,this.varianceStyles=e,this.padding=n,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"]}}class I{constructor(t,i,s,h,e){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=h,this.paddingadapter=e}adapt(t){const i=new z(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return g.isExisting(t)&&(g.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),g.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),g.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),g.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),g.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),g.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 R(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new z(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class j{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 K{adapt(t){const i=new j;return g.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),g.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),g.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),g.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),g.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),g.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),g.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),g.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),g.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),g.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),g.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),g.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),g.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),g.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),g.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new j}}!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"}(X||(X={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(B||(B={})),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"}(Y||(Y={}));class q{constructor(t,i,s,h,e,n,r,o){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=e,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),h))),this.styles=n,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=r||Y.Top,this.horizontalHookLocation=o||Y.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 L){var s;if(this.isEmpty())return this;const h=this.group;let e;const n=this.styles.fontStyles.background||"#ffffff";let o="",a="start";if(!1===Number.isNaN(Number(this.value))){let s=t.percent,h=t.percent,n=1,r="percent";!1===this.isRelativeLabel&&(s=t.decimal,h=t.decimal,n=i.value,r="decimal"),e=k.number(Number(this.value),r,s,h,n),Number(this.value)<0&&(a="end"),this.isVarianceLabel&&Number(this.value)>=0&&(o="+")}else e=""+this.value,a="start";const l=h.text(o+e);l.move(this.x,this.y);const c=l.bbox().w,u=l.bbox().h;return null!=this.maxWidth&&c>this.maxWidth?(null===(s=this.group)||void 0===s||s.remove(),this.group=null,this):(this.horizontalHookLocation===Y.Right?(a="end",l.move(l.x()-l.length(),l.y())):this.horizontalHookLocation===Y.Center&&(a="middle",l.move(l.x()-l.length()/2,l.y())),this.verticalHookLocation===Y.Center?l.move(l.x(),l.y()-u/2):this.verticalHookLocation===Y.Bottom&&l.move(l.x(),l.y()-u),l.font({anchor:a}),null!=this.segmentFillColor?l.fill(r(this.segmentFillColor)):null==h||h.rect(c,.9*u).stroke(n).fill(n).opacity(.7).move(l.x(),l.y()+.1*u).insertBefore(l),this)}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}class Z{constructor(t,i,s,h){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=h,this.label=new q(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,Y.Bottom,Y.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 J{constructor(t,i,s,h,e,n,r,o=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=h,this.isPrimaryBar=e,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=n,this.styles=i,null!=n&&(this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=Y.Left;s.value<0&&(i=Y.Right),this.dimensions=this.createDimensions(t,s,h,e),this.label=new q(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Y.Center,i),this.scenarioLabel=this.getScenarioLabel(r)}}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 L){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 h=this.convertToSVGStyle(s,"stroke");let e=this.convertToSVGStyle(s,"fill");const n=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=n){const t=this.styles.pattern.get(n);null!=t&&(e=t.pattern)}null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(e,h):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(e).stroke(h).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(),h=this.position.getBarWidth(),e=this.dimensions.barLength,{breakGap:n}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(e,h).fill(t).stroke(i).x(s-e).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s-e-n-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-e-n,n)):(this.barGroup.rect(e,h).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s+e+n).cy(this.dimensions.yPos),this.drawBreakIndicator(s+e,n))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),h=this.dimensions.yPos-s/2,e=t+i/2,n=.35*i,r=s/3;let o=`M ${e-n} ${h}`;for(let t=0;t<3;t++)o+=` L ${e-n-.3*i} ${h+r*(t+.5)} L ${e-n} ${h+r*(t+1)}`;let a=`M ${e+n} ${h}`;for(let t=0;t<3;t++)a+=` L ${e+n+.3*i} ${h+r*(t+.5)} L ${e+n} ${h+r*(t+1)}`;this.barGroup.rect(i,s+2).fill("#ffffff").stroke("none").x(t).cy(this.dimensions.yPos),this.barGroup.path(o).fill("none").stroke({color:"#000000",width:1}),this.barGroup.path(a).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s,h){const e=i.getScaledUnit(),n=Math.abs(e);if(this.overflowConfig&&n>0){const r="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(n>r){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:o,maxOverflow:a}=this.overflowConfig;this.overdriveWidth=a>0?(n-r)/a*o:0;const l=r+i+this.overdriveWidth;return e<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()-r,yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:r,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}}}return e<0?{clipped:!1,barLength:n,xPos:t.getBarPositionX()+e,yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()-.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:e,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()+.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}}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 L){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 q(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,this.isPrimaryBar?Y.Top:Y.Bottom,Y.Center)}}class Q{constructor(t,i,s,h,e,n,r,o,a){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=e,this.barStyles=e?e.barStyles:null,this.scenario=h,!0!==(null==n?void 0:n.isEmpty())&&(this.hasData=!0,this.dimensions=this.createMarkerDimensions(n,r,a),this.scenarioLabel=this.getScenarioLabel(o,e,a))}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 q(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?Y.Bottom:Y.Top,Y.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)}}class tt{constructor(t,i,s,h,e){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=h,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=e,this.styles=i,this.barGroup=e.group().id(e.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0,this.dimensions=this.createDimensions(t,s,h);let i=Y.Left;s.value<0&&(i=Y.Right),this.label=new q(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Y.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 h=i.fill;const e=this.barStyles[this.dataPoint.getScenario()];if(null!=e&&e.fillpattern){const t=this.styles.pattern.get(e.fillpattern);null!=t&&null!=t.pattern&&(h=t.pattern)}this.drawNeedleHead(h,s),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(h).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,h=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(h)}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 it{constructor(t,i,s,h,e,n,r,o,a,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=h,this.baselineValue=e,this.segmentIndex=r,this.stackMode=o,this.totalValue=a,this.group=c,this.barGroup=c.group().id(`stacked_bar_${h}_seg_${r}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new L){if(!this.hasData||null==this.dataPoint.value)return;const s=this.dataPoint.value,h=this.dataPoint.pixelPerUnit,e=this.position.getBarPositionX(),n=this.position.getBarWidth();let r,o;if(this.stackMode===b.RELATIVE){const t=h;r=(0!==this.totalValue?Math.abs(s)/Math.abs(this.totalValue):0)*t,o=e+this.baselineValue/Math.abs(this.totalValue)*t}else r=Math.abs(s*h),o=e+this.baselineValue*h;const a=this.position.getBarPositionY(this.index,!0),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],u={color:c},d={color:c,width:.5};this.barGroup.rect(Math.max(r,.5),n).fill(u).stroke(d).cy(a).x(o);const f=r-6;if(f>0){const h=o+r/2;if(this.stackMode===b.RELATIVE||this.stackMode===b.ABSOLUTE_RELATIVE){const i=(0!==this.totalValue?s/this.totalValue*100:0).toFixed(t.percent)+"%";new q(this.group,h,a,"STACK_SEG",i,this.styles,Y.Center,Y.Center).setSegmentFill(c).setMaxWidth(f).draw()}else new q(this.group,h,a,"STACK_SEG",s,this.styles,Y.Center,Y.Center).setSegmentFill(c).setMaxWidth(f).draw(t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new L){if(this.stackMode===b.RELATIVE)return;const s=this.position.getBarPositionX()+this.totalValue*this.dataPoint.pixelPerUnit+this.position.spacings.labelToBar,h=this.position.getBarPositionY(this.index,!0);new q(this.group,s,h,"STACK_TOTAL",this.totalValue,this.styles,Y.Center,Y.Left).draw(t,i)}}class st{constructor(t,i,s,h,e){this.overflowConfig=null,this.i18n=e;const n=i.group().id("Scenario1"),r=i.group().id("Scenario2").insertBefore(n);this.svgGroups={parent:i,scenario1:n,scenario2:r,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=h}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new J(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o)}createVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new J(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o).setAsVariance()}createRelativeVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);return new tt(this.position,this.styles,t,i,r).updateLabelGroup(o)}createSecondaryBar(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===h?void 0:h.group().id(""+i);let n=null;return this.isFirsttDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new J(this.position,this.styles,t,i,!1,e,n,this.overflowConfig)}createPrimaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===h?void 0:h.group().id(""+i),n=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 r=null;return this.isFirstDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new Q(this.position,e,n,t.scenario,this.styles,t,i,r,!0)}createSecondaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===h?void 0:h.group().id(""+i),n=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 r=null;return this.isLastDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new Q(this.position,e,n,t.scenario,this.styles,t,i,r,!1)}isFirstDataPoint(t){return 0===t}}class ht{constructor(t,i,s,h,e){this.dataModel=[],this.variancesDataModel=[],this.title="",this.smallestDataPointValue=new F(0,X.AC1,1,X.NEU),this.highestDataPointValue=new F(0,X.AC1,1,X.NEU),this.smallestVarianceDataPointValue=new F(0,X.AC1,1,X.NEU),this.highestVarianceDataPointValue=new F(0,X.AC1,1,X.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideCategories=!1,this.axisScenario=X.AC1,this.CSS_CATEGORIES="categories",this.state=W.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new L,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 T,this.i18n=this.createI18n(new Map),this.styles=e,this.setConfig(h),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 _(new E(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}setConfig(t){var i;this.state=W.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!==m.SCENARIOS&&this.populateDimensionStackSegments(s,t.stackConfig,t.level),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.title=t.title||k.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=W.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=W.DIRTY,!this.tableName)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=$(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===b.RELATIVE?1:this.highestStackedTotal;const s=this.getVarianceType();return s===N.NONE&&null!=(null===(t=this.highestDataPointValue)||void 0===t?void 0:t.value)?Math.abs(this.highestDataPointValue.value):s===N.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 n;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.svg()}draw(t){this.cleanSVGforRedraw(t),this.state===W.DIRTY&&(this.state=W.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=C(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?" ":k.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}setAxisScenario(t){let i=X.AC1;if(null!=t&&t.length>0){const s=new A(t.toString());s.isValid&&(i=s.delta)}return null===i&&(i=X.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const h=[],e=this.createOrderStr(i,s),n=this.createSelectString(i,s),r=this.createGroupByStr(i,s);let o;try{o=this.db.exec(`SELECT ${n} ${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 ${r}\n ORDER BY ${e}`)}catch(t){return console.error("StructureChart: populateModel query failed",t),[]}return this.detectNaNCells(t,o),this.createDataRows(o,h,t),this.crateRESTRow(o,t,h),h}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new A(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 h=[],e=t.slice(this.limit,t.length);this.createDataRows(e,h,i);const n=h.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new F(t.scenario1.value+s.scenario1.value,i[0],t.scenario1.pixelPerUnit,X.NEU),scenario2:new F(t.scenario2.value+s.scenario2.value,i[1],t.scenario2.pixelPerUnit,X.NEU),scenario3:new F(t.scenario3.value+s.scenario3.value,i[2],t.scenario3.pixelPerUnit,X.NEU),scenario4:new F(t.scenario4.value+s.scenario4.value,i[3],t.scenario4.pixelPerUnit,X.NEU)}}),{id:9999,category:"REST",type:N.NONE,scenario1:new F(0,i[0],this.pixelPerUnit,X.NEU),scenario2:new F(0,i[1],this.pixelPerUnit,X.NEU),scenario3:new F(0,i[2],this.pixelPerUnit,X.NEU),scenario4:new F(0,i[3],this.pixelPerUnit,X.NEU)});s.push(n)}createDataRows(t,i,s){let h=t;this.limit>0&&(h=t.slice(0,this.limit)),h.forEach(((t,h)=>{i.push({id:h,category:t.category,type:N.NONE,scenario1:new F(t[s[0]],s[0],this.pixelPerUnit,X.NEU),scenario2:new F(t[s[1]],s[1],this.pixelPerUnit,X.NEU),scenario3:new F(t[s[2]],s[2],this.pixelPerUnit,X.NEU),scenario4:new F(t[s[3]],s[3],this.pixelPerUnit,X.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===w.CATEGORY&&i.hierarchy.includes(P.CATEGORYINDEX)?`${P.CATEGORYINDEX}, ${w.CATEGORY} as category`:t===w.ROWGROUP&&i.hierarchy.includes(P.ROWGROUPINDEX)?`${P.ROWGROUPINDEX}, ${w.ROWGROUP} as category`:t===w.SUBCATEGORY&&i.hierarchy.includes(P.SUBCATEGORYINDEX)?`${P.SUBCATEGORYINDEX}, ${w.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===w.CATEGORY&&i.hierarchy.includes(P.CATEGORYINDEX)?`${P.CATEGORYINDEX}, ${w.CATEGORY}`:t===w.ROWGROUP&&i.hierarchy.includes(P.ROWGROUPINDEX)?`${P.ROWGROUPINDEX}, ${w.ROWGROUP}`:t===w.SUBCATEGORY&&i.hierarchy.includes(P.SUBCATEGORYINDEX)?`${P.SUBCATEGORYINDEX}, ${w.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=C(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 F(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 F(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===m.SCENARIOS;let s=0;for(const h of t){let t=0;if(i){const i=["scenario1","scenario2","scenario3","scenario4"],s=[];for(const t of i){const i=h[t];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario})}if(new Set(s.map((t=>o(t.scenario)))).size>1){const i=new Map;for(const t of s){const s=o(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 h.stackSegments&&h.stackSegments.length>0&&(t=h.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 h=null;null!=i&&i.length>0&&(h=i[0]);for(const e in t){const n=new A(t[e]);if(n.isValid){const t=this.mapScenarios(n,h),e=n.direction;let r=this.pixelPerUnit;"dr"===n.type&&(r=this.pixelPerPercentage);for(const h in i)s.push({id:Number(h),category:i[h].category,type:"dr"===n.type?N.RELATIVE:N.ABSOLUTE,scenario1:new F(this.calculateVariance(n,i[h],t),n.base,r,e),scenario2:new F(null,null,null,null),scenario3:new F(null,null,null,null),scenario4:new F(null,null,null,null)})}}return s}calculateVariance(t,i,s){const h=s.get(t.base),e=s.get(t.delta);return null==h||null==e?null:t.type===N.RELATIVE?(i[h].value-i[e].value)/i[e].value:i[h].value-i[e].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((h=>{i[h].scenario===t.delta?s.set(t.delta,h):i[h].scenario===t.base&&s.set(t.base,h)})),s}calculateTextBoxWidth(t){return C(k.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+=C("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=C(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,C(k.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 h=!1;this.hideCategories||t.forEach(((t,i)=>{t.type===N.RELATIVE&&(h=!0);let e=Y.Right,n=!0;t.scenario1.value<0&&(e=Y.Left,n=!1),new q(s,this.position.getCategoryPositionX(n),this.position.getBarCenterPositionY(i),"",t.category,this.styles,Y.Center,e).draw()})),new Z({scenarioType:this.axisScenario,labelText:this.title,isRelative:h},this.position,s,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios"),h=new st(this.position,s,this.styles,t.length,this.i18n);h.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{h.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),h.createSecondaryBar(t.scenario2,i).draw(),h.createPrimaryMarker(t.scenario3,i).draw(),h.createSecondaryMarker(t.scenario4,i).draw()}))}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),h=new st(this.position,s,this.styles,t.length,this.i18n);return h.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===N.RELATIVE?h.createRelativeVarianceBar(t.scenario1,i).draw():h.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 h=i.indexOf(t.scenario),e=i.indexOf(s.scenario);return(-1===h?i.length:h)-(-1===e?i.length:e)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),h=this.stackConfig.by===m.SCENARIOS;t.forEach(((t,i)=>{const e=["scenario1","scenario2","scenario3","scenario4"],n=[];if(h){for(const i of e){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&n.push({value:s.value,scenario:s.scenario,dataPoint:s})}this.sortSegmentsByPropOrder(n)}else{const i=t.scenario1;i&&!i.isEmpty()&&null!=i.value&&n.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0!==n.length)if((h?new Set(n.map((t=>o(t.scenario)))):new Set).size>1){const t=new Map;for(const i of n){const s=o(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const h=[];for(const i of a)t.has(i)&&(h.push({prefix:i,segments:t.get(i)}),t.delete(i));for(const[i,s]of t)h.push({prefix:i,segments:s});h.forEach(((t,e)=>{const n=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),r=h.length-1-e;let o=0,a=null;t.segments.forEach((t=>{const h=new it(this.position,this.styles,t.dataPoint,i,o,t.scenario,r,this.stackConfig.mode,n,!0,s);h.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),a=h})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}))}else{let e=n;!h&&t.stackSegments&&t.stackSegments.length>0&&(e=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint})))),"asc"===this.stackConfig.order?e.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&e.sort(((t,i)=>i.value-t.value));const r=e.reduce(((t,i)=>t+Math.abs(i.value)),0);let o=0,a=null;e.forEach(((t,e)=>{const n=new it(this.position,this.styles,t.dataPoint,i,o,t.scenario,e,this.stackConfig.mode,r,h,s);n.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),a=n})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}}))}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;const s=this.stackConfig.by===m.SCENARIOS,h=i.group().id("StackedHeaders"),e=t[0];if(!s){const t=e.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),n=this.position.getBarPositionX(),r=this.position.getStackedHeaderPositionY();let o=0;return void i.forEach((t=>{const i=t.dataPoint.pixelPerUnit;let e;e=this.stackConfig.mode===b.RELATIVE?(0!==s?Math.abs(t.value)/s:0)*i:Math.abs(t.value*i);const a=n+o+e/2,l=this.i18n.get(t.label)||t.label;new q(h,a,r,"STACK_HEADER",l,this.styles,Y.Bottom,Y.Center).draw(),o+=e}))}const 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 l=new Set(r.map((t=>o(t.scenario)))),c=this.position.getBarPositionX(),u=this.position.getStackedHeaderPositionY();if(l.size>1){const t=new Map;for(const i of r){const s=o(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const i=[];for(const s of a)t.has(s)&&(i.push({prefix:s,segments:t.get(s)}),t.delete(s));for(const[s,h]of t)i.push({prefix:s,segments:h});i.forEach((t=>{const i=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),s=t.segments[0].dataPoint.pixelPerUnit,e=c+(this.stackConfig.mode===b.RELATIVE?s:i*s)/2,n=this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase();new q(h,e,u,"STACK_HEADER",n,this.styles,Y.Bottom,Y.Center).draw()}))}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 i=0;r.forEach((s=>{const e=s.dataPoint.pixelPerUnit;let n;n=this.stackConfig.mode===b.RELATIVE?(0!==t?Math.abs(s.value)/t:0)*e:Math.abs(s.value*e);const r=c+i+n/2,o=this.i18n.get(s.scenario)||s.scenario;new q(h,r,u,"STACK_HEADER",o,this.styles,Y.Bottom,Y.Center).draw(),i+=n}))}}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:N.NONE}calculateLeftSideWidth(t){var i,s,h;let e=0;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(N.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);e=Math.abs(this.smallestDataPointValue.getScaledUnit())+n+t}else if(N.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);e=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+n+t}else if(N.ABSOLUTE===t&&null!=(null===(h=this.smallestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value);e=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+n+t}return e<=this.titleLength?this.titleLength:e}calculateRightSideWidth(t){var i,s,h;if(null!=this.stackConfig&&this.highestStackedTotal>0){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;let i;i=this.stackConfig.mode===b.RELATIVE?this.pixelPerUnit:this.highestStackedTotal*this.pixelPerUnit;const s=this.calculateTextBoxWidth(this.highestStackedTotal);return Math.max(i+t+s,this.titleLength)}let e=0;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(N.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);e=Math.abs(this.highestDataPointValue.getScaledUnit())+n+t}else if(N.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);e=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+n+t}else if(N.ABSOLUTE===t&&null!=(null===(h=this.highestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);e=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+n+t}return e<=this.titleLength?this.titleLength:e}populateDimensionStackSegments(t,i,s){if(0===this.rowCount||!this.fromExpr||0===t.length)return;const h={[w.ROWGROUP]:"category",[w.ROWGROUPINDEX]:"category",[w.CATEGORY]:"subCategory",[w.CATEGORYINDEX]:"subCategory"}[s];if(!h)return;const e=s.toString(),n=t[0];let r;try{r=this.db.exec(`SELECT [${e}] as displayGroup, [${h}] as stackLabel, SUM([${n}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${e}], [${h}]`)}catch(t){return void console.error("StructureChart: dimension-stack query failed",t)}const o=new Map;for(const t of r){const i=t.displayGroup;o.has(i)||o.set(i,[]),null!=t.stackValue&&null!=t.stackLabel&&o.get(i).push({label:t.stackLabel,value:t.stackValue})}for(const t of this.dataModel){const i=o.get(t.category);t.stackSegments=i&&i.length>0?i.map((t=>({label:t.label,value:t.value,dataPoint:new F(t.value,n,this.pixelPerUnit,X.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,h=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new F(h,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new F(-h,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new F(h,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new F(-h,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()===N.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,h=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,e=s.getScaledUnit(),n=null!=h.value?Math.abs(h.getScaledUnit()):0,r=Math.max(e,n);if(r<=0)return null;const o=this.styles.fontStyles.size,a=o*this.styles.scaleFactors.labelToBar,l=1.5*o,c=.3*o,u=.8*o,d=t-this.position.getAxisPositionX()-this.styles.padding.left-this.styles.padding.right-a-this.calculateTextBoxWidth(s.value||0)-l-c;if(d<=u)return null;const f=d-u;return r<=f?null:{cutWidth:d,overdriveZoneWidth:l,breakGap:c,maxOverflow:r-f,scenarioCutOffset:u}}}const et=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),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:S.ASC},this.level=w.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=O(this.element)),this.stores.db.db}render(){var t,i,e;if(void 0===this.chart)return s(h,null);if(this.chart.hasNoData()){const t=this.i18n.get("NO_DATA")||"==No Data==";return s(h,null,s("p",{class:"warning"},t))}return s(h,null,s("div",{innerHTML:null===(t=this.pattern)||void 0===t?void 0:t.toString(),class:"hidePatternContainer"}),s("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(i=this.chart)||void 0===i?void 0:i.getFooter()),s("div",{innerHTML:null===(e=this.chart)||void 0===e?void 0:e.toString()}))}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),h=this.prepareStyle();this.chart=new ht(new T,i,this.tableName,s,h),this.chart.setI18n(this.i18n),this.autoFitScaling(s,h),this.chart.setAvailableWidth((null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new D(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.setConfig(i),this.autoFitScaling(i,s),this.chart.setAvailableWidth((null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new D(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}autoFitScaling(t,i){var s;const h=t.pixelPerUnit<=0,e=t.pixelPerPercentage<=0;if(!h&&!e)return;const n=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,r=this.getDb();if(!n||n<=0)return h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=50),this.chart=new ht(new T,r,this.tableName,t,i),void this.chart.setI18n(this.i18n);h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=1),this.chart=new ht(new T,r,this.tableName,t,i),this.chart.setI18n(this.i18n),this.chart.toString();const o=this.chart.getAllocatedCanvasWidth();if(o<=0)return;const a=this.chart.getMaxBarValue();h&&(t.pixelPerUnit=a>0?Math.max(.001,(n-(o-a))/a):.9*n/o),e&&(t.pixelPerPercentage=.9*n/o),this.chart=new ht(new T,r,this.tableName,t,i),this.chart.setI18n(this.i18n)}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=this.tableName?$(this.tableName,this.filter):"";return new H(new U,new v(new M),new M,new x,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 I(new K,new l,new c(new u),new d(new u),new f).adapt(this.styles)}get element(){return this}static get style(){return':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}'}},[1,"ibcs-chart-structure",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],scenarios:[16],variances:[16],hideCategories:[4,"hide-categories"],pixelPerUnit:[2,"pixel-per-unit"],pixelPerPercentage:[2,"pixel-per-percentage"],limit:[2],styles:[1040],i18n:[1040],order:[16],level:[1],filter:[1],measureScale:[1,"measure-scale"],measureUnit:[1,"measure-unit"],showMeasureScale:[4,"show-measure-scale"],dataFormatDigits:[16],stackConfig:[16],parentDimensions:[16]}]);function nt(){"undefined"!=typeof customElements&&["ibcs-chart-structure"].forEach((t=>{"ibcs-chart-structure"===t&&(customElements.get(e(t))||customElements.define(e(t),et))}))}export{et as I,nt as d}
1
+ import{proxyCustomElement as t,HTMLElement as i,h as s,Host as h,transformTag as e}from"@stencil/core/internal/client";import{S as n,F as r,a as o,b as a,P as l}from"./main.js";import{C as c,A as u,g as d,e as f}from"./CompareUtil.js";import{D as p,b as g}from"./DataFormatDigits.js";import{A as v,c as w,a as b,O as m}from"./Order.js";import{S as P}from"./SiPrefix.js";import{F as S,I as y,C as L,V as x}from"./formatter.js";import{g as M,a as k,I as C}from"./stackColors.js";import{d as T,g as A}from"./context-protocol.js";import{S as $}from"./StringAdapter.js";import{S as O}from"./SVGVariancesStyleGroup.js";class _{constructor(t,i,s,h,e,n,r,o,a=!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=h,this.leftSideLengthSync=e,this.topSideLabelHeight=n>0?this.fontSize:0,this.hasStackedHeaders=a,this.leftSideLabelLength=this.calculateSideLabelLength(n,r,o),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,h){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<h/2&&(this.axisPosition.x=h/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 h=t/2;let e=i;return h>e&&(e=h),s>e&&(e=s),e}}class E{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 R{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}}class D{constructor(t){this.container=new n,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 W,N,X,B,Y;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(W||(W={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(N||(N={}));class V{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 w(new $).default(),this.level=u.CATEGORY,this.filter="",this.measureScale=new P,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null}}class H{constructor(t,i,s,h,e,n){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=h,this.db=e,this.fromExpr=n}adapt(t){const i=v.adaptArray(t.data,this.dataRowAdapter),s=v.adaptArray(t.scenarios,this.stringAdapter),h=new V(i,s);return c.isArray(t.variances)&&(h.variances=v.adaptArray(t.variances,this.stringAdapter)),c.isString(t.title)&&(h.title=t.title),c.isBoolean(t.hideCategories)&&(h.hideCategories=t.hideCategories),c.isNumber(t.pixelPerUnit)&&(h.pixelPerUnit=t.pixelPerUnit),c.isNumber(t.pixelPerPercentage)&&(h.pixelPerPercentage=t.pixelPerPercentage),c.isNumber(t.limit)&&(h.limit=t.limit),c.isExisting(t.sortOrder)&&(h.sortOrder=this.orderAdapter.adapt(t.sortOrder)),c.isExisting(t.level)&&(h.level=t.level),c.isString(t.filter)&&(h.filter=t.filter.trim()),c.isExisting(t.measureScale)&&(h.measureScale=p.calculateMeasureScale(this.db,this.fromExpr,h.scenarios,t.measureScale)),c.isString(t.measureUnit)&&(h.measureUnit=t.measureUnit),c.isBoolean(t.showMeasureScale)&&(h.showMeasureScale=t.showMeasureScale),c.isExisting(t.dataFormatDigits)&&(h.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),c.isExisting(t.stackConfig)&&(h.stackConfig=t.stackConfig),h}default(){return new V([],[])}}class F{constructor(t,i,s,h){this.value=t,this.scenario=i,this.pixelPerUnit=s||1,this.variance="neg"===h||h===X.NEG?X.NEG:"pos"===h||h===X.POS?X.POS:X.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:X.NEU===this.variance?X.NEU:X.POS===this.variance?X.NEG:X.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 G{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 U{constructor(){}adapt(t){const i=new G;return c.isOperator(t.operation)&&(i.operation=t.operation),c.isNumber(t.rowGroupIndex)&&c.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),c.isNumber(t.categoryIndex)&&c.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),c.isNumber(t.subCategoryIndex)&&c.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),c.isNumber(t.columnGroupIndex)&&c.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),c.isNumber(t.columnSubGroupIndex)&&c.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 G}setActualValues(t,i){c.isNumber(t.ac1)&&(i.ac1=t.ac1),c.isNumber(t.ac2)&&(i.ac2=t.ac2),c.isNumber(t.ac3)&&(i.ac3=t.ac3),c.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){c.isNumber(t.pl1)&&(i.pl1=t.pl1),c.isNumber(t.pl2)&&(i.pl2=t.pl2),c.isNumber(t.pl3)&&(i.pl3=t.pl3),c.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){c.isNumber(t.pp1)&&(i.pp1=t.pp1),c.isNumber(t.pp2)&&(i.pp2=t.pp2),c.isNumber(t.pp3)&&(i.pp3=t.pp3),c.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){c.isNumber(t.fc1)&&(i.fc1=t.fc1),c.isNumber(t.fc2)&&(i.fc2=t.fc2),c.isNumber(t.fc3)&&(i.fc3=t.fc3),c.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class z{constructor(t,i,s,h,e,n){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=h,this.varianceStyles=e,this.padding=n,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"]}}class j{constructor(t,i,s,h,e){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=h,this.paddingadapter=e}adapt(t){const i=new z(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return c.isExisting(t)&&(c.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),c.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),c.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),c.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),c.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),c.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 R(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new z(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class I{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 K{adapt(t){const i=new I;return c.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),c.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),c.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),c.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),c.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),c.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),c.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),c.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),c.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),c.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),c.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),c.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),c.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),c.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),c.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new I}}!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"}(X||(X={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(B||(B={})),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"}(Y||(Y={}));class q{constructor(t,i,s,h,e,n,r,o){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=e,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),h))),this.styles=n,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=r||Y.Top,this.horizontalHookLocation=o||Y.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 P){var s;if(this.isEmpty())return this;const h=this.group;let e;const n=this.styles.fontStyles.background||"#ffffff";let r="",o="start";if(!1===Number.isNaN(Number(this.value))){let s=t.percent,h=t.percent,n=1,a="percent";!1===this.isRelativeLabel&&(s=t.decimal,h=t.decimal,n=i.value,a="decimal"),e=S.number(Number(this.value),a,s,h,n),Number(this.value)<0&&(o="end"),this.isVarianceLabel&&Number(this.value)>=0&&(r="+")}else e=""+this.value,o="start";const a=h.text(r+e);a.move(this.x,this.y);const l=a.bbox().w,c=a.bbox().h;return null!=this.maxWidth&&l>this.maxWidth?(null===(s=this.group)||void 0===s||s.remove(),this.group=null,this):(this.horizontalHookLocation===Y.Right?(o="end",a.move(a.x()-a.length(),a.y())):this.horizontalHookLocation===Y.Center&&(o="middle",a.move(a.x()-a.length()/2,a.y())),this.verticalHookLocation===Y.Center?a.move(a.x(),a.y()-c/2):this.verticalHookLocation===Y.Bottom&&a.move(a.x(),a.y()-c),a.font({anchor:o}),null!=this.segmentFillColor?a.fill(M(this.segmentFillColor)):null==h||h.rect(l,.9*c).stroke(n).fill(n).opacity(.7).move(a.x(),a.y()+.1*c).insertBefore(a),this)}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}class Z{constructor(t,i,s,h){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=h,this.label=new q(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,Y.Bottom,Y.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 J{constructor(t,i,s,h,e,n,r,o=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=h,this.isPrimaryBar=e,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=n,this.styles=i,null!=n&&(this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=Y.Left;s.value<0&&(i=Y.Right),this.dimensions=this.createDimensions(t,s,h,e),this.label=new q(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Y.Center,i),this.scenarioLabel=this.getScenarioLabel(r)}}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 P){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 h=this.convertToSVGStyle(s,"stroke");let e=this.convertToSVGStyle(s,"fill");const n=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=n){const t=this.styles.pattern.get(n);null!=t&&(e=t.pattern)}null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(e,h):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(e).stroke(h).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(),h=this.position.getBarWidth(),e=this.dimensions.barLength,{breakGap:n}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(e,h).fill(t).stroke(i).x(s-e).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s-e-n-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-e-n,n)):(this.barGroup.rect(e,h).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s+e+n).cy(this.dimensions.yPos),this.drawBreakIndicator(s+e,n))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),h=this.dimensions.yPos-s/2,e=t+i/2,n=.35*i,r=s/3;let o=`M ${e-n} ${h}`;for(let t=0;t<3;t++)o+=` L ${e-n-.3*i} ${h+r*(t+.5)} L ${e-n} ${h+r*(t+1)}`;let a=`M ${e+n} ${h}`;for(let t=0;t<3;t++)a+=` L ${e+n+.3*i} ${h+r*(t+.5)} L ${e+n} ${h+r*(t+1)}`;this.barGroup.rect(i,s+2).fill("#ffffff").stroke("none").x(t).cy(this.dimensions.yPos),this.barGroup.path(o).fill("none").stroke({color:"#000000",width:1}),this.barGroup.path(a).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s,h){const e=i.getScaledUnit(),n=Math.abs(e);if(this.overflowConfig&&n>0){const r="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(n>r){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:o,maxOverflow:a}=this.overflowConfig;this.overdriveWidth=a>0?(n-r)/a*o:0;const l=r+i+this.overdriveWidth;return e<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()-r,yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:r,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}}}return e<0?{clipped:!1,barLength:n,xPos:t.getBarPositionX()+e,yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()-.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:e,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()+.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}}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 P){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 q(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,this.isPrimaryBar?Y.Top:Y.Bottom,Y.Center)}}class Q{constructor(t,i,s,h,e,n,r,o,a){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=e,this.barStyles=e?e.barStyles:null,this.scenario=h,!0!==(null==n?void 0:n.isEmpty())&&(this.hasData=!0,this.dimensions=this.createMarkerDimensions(n,r,a),this.scenarioLabel=this.getScenarioLabel(o,e,a))}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 q(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?Y.Bottom:Y.Top,Y.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)}}class tt{constructor(t,i,s,h,e){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=h,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=e,this.styles=i,this.barGroup=e.group().id(e.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0,this.dimensions=this.createDimensions(t,s,h);let i=Y.Left;s.value<0&&(i=Y.Right),this.label=new q(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Y.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 h=i.fill;const e=this.barStyles[this.dataPoint.getScenario()];if(null!=e&&e.fillpattern){const t=this.styles.pattern.get(e.fillpattern);null!=t&&null!=t.pattern&&(h=t.pattern)}this.drawNeedleHead(h,s),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(h).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,h=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(h)}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 it{constructor(t,i,s,h,e,n,r,o,a,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=h,this.baselineValue=e,this.segmentIndex=r,this.stackMode=o,this.totalValue=a,this.group=c,this.barGroup=c.group().id(`stacked_bar_${h}_seg_${r}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new P){if(!this.hasData||null==this.dataPoint.value)return;const s=this.dataPoint.value,h=this.dataPoint.pixelPerUnit,e=this.position.getBarPositionX(),n=this.position.getBarWidth();let r,o;if(this.stackMode===d.RELATIVE){const t=h;r=(0!==this.totalValue?Math.abs(s)/Math.abs(this.totalValue):0)*t,o=e+this.baselineValue/Math.abs(this.totalValue)*t}else r=Math.abs(s*h),o=e+this.baselineValue*h;const a=this.position.getBarPositionY(this.index,!0),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],u={color:c},f={color:c,width:.5};this.barGroup.rect(Math.max(r,.5),n).fill(u).stroke(f).cy(a).x(o);const p=r-6;if(p>0){const h=o+r/2;if(this.stackMode===d.RELATIVE||this.stackMode===d.ABSOLUTE_RELATIVE){const i=(0!==this.totalValue?s/this.totalValue*100:0).toFixed(t.percent)+"%";new q(this.group,h,a,"STACK_SEG",i,this.styles,Y.Center,Y.Center).setSegmentFill(c).setMaxWidth(p).draw()}else new q(this.group,h,a,"STACK_SEG",s,this.styles,Y.Center,Y.Center).setSegmentFill(c).setMaxWidth(p).draw(t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new P){if(this.stackMode===d.RELATIVE)return;const s=this.position.getBarPositionX()+this.totalValue*this.dataPoint.pixelPerUnit+this.position.spacings.labelToBar,h=this.position.getBarPositionY(this.index,!0);new q(this.group,s,h,"STACK_TOTAL",this.totalValue,this.styles,Y.Center,Y.Left).draw(t,i)}}class st{constructor(t,i,s,h,e){this.overflowConfig=null,this.i18n=e;const n=i.group().id("Scenario1"),r=i.group().id("Scenario2").insertBefore(n);this.svgGroups={parent:i,scenario1:n,scenario2:r,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=h}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new J(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o)}createVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new J(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o).setAsVariance()}createRelativeVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);return new tt(this.position,this.styles,t,i,r).updateLabelGroup(o)}createSecondaryBar(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===h?void 0:h.group().id(""+i);let n=null;return this.isFirsttDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new J(this.position,this.styles,t,i,!1,e,n,this.overflowConfig)}createPrimaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===h?void 0:h.group().id(""+i),n=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 r=null;return this.isFirstDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new Q(this.position,e,n,t.scenario,this.styles,t,i,r,!0)}createSecondaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===h?void 0:h.group().id(""+i),n=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 r=null;return this.isLastDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new Q(this.position,e,n,t.scenario,this.styles,t,i,r,!1)}isFirstDataPoint(t){return 0===t}}class ht{constructor(t,i,s,h,e){this.dataModel=[],this.variancesDataModel=[],this.title="",this.smallestDataPointValue=new F(0,X.AC1,1,X.NEU),this.highestDataPointValue=new F(0,X.AC1,1,X.NEU),this.smallestVarianceDataPointValue=new F(0,X.AC1,1,X.NEU),this.highestVarianceDataPointValue=new F(0,X.AC1,1,X.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideCategories=!1,this.axisScenario=X.AC1,this.CSS_CATEGORIES="categories",this.state=W.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new P,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 y,this.i18n=this.createI18n(new Map),this.styles=e,this.setConfig(h),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 _(new E(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 y}setConfig(t){var i;this.state=W.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!==f.SCENARIOS&&this.populateDimensionStackSegments(s,t.stackConfig,t.level),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.title=t.title||S.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=W.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=W.DIRTY,!this.tableName)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=T(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===d.RELATIVE?1:this.highestStackedTotal;const s=this.getVarianceType();return s===N.NONE&&null!=(null===(t=this.highestDataPointValue)||void 0===t?void 0:t.value)?Math.abs(this.highestDataPointValue.value):s===N.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 n;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.svg()}draw(t){this.cleanSVGforRedraw(t),this.state===W.DIRTY&&(this.state=W.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=L(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?" ":S.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}setAxisScenario(t){let i=X.AC1;if(null!=t&&t.length>0){const s=new x(t.toString());s.isValid&&(i=s.delta)}return null===i&&(i=X.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const h=[],e=this.createOrderStr(i,s),n=this.createSelectString(i,s),r=this.createGroupByStr(i,s);let o;try{o=this.db.exec(`SELECT ${n} ${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 ${r}\n ORDER BY ${e}`)}catch(t){return console.error("StructureChart: populateModel query failed",t),[]}return this.detectNaNCells(t,o),this.createDataRows(o,h,t),this.crateRESTRow(o,t,h),h}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new x(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 h=[],e=t.slice(this.limit,t.length);this.createDataRows(e,h,i);const n=h.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new F(t.scenario1.value+s.scenario1.value,i[0],t.scenario1.pixelPerUnit,X.NEU),scenario2:new F(t.scenario2.value+s.scenario2.value,i[1],t.scenario2.pixelPerUnit,X.NEU),scenario3:new F(t.scenario3.value+s.scenario3.value,i[2],t.scenario3.pixelPerUnit,X.NEU),scenario4:new F(t.scenario4.value+s.scenario4.value,i[3],t.scenario4.pixelPerUnit,X.NEU)}}),{id:9999,category:"REST",type:N.NONE,scenario1:new F(0,i[0],this.pixelPerUnit,X.NEU),scenario2:new F(0,i[1],this.pixelPerUnit,X.NEU),scenario3:new F(0,i[2],this.pixelPerUnit,X.NEU),scenario4:new F(0,i[3],this.pixelPerUnit,X.NEU)});s.push(n)}createDataRows(t,i,s){let h=t;this.limit>0&&(h=t.slice(0,this.limit)),h.forEach(((t,h)=>{i.push({id:h,category:t.category,type:N.NONE,scenario1:new F(t[s[0]],s[0],this.pixelPerUnit,X.NEU),scenario2:new F(t[s[1]],s[1],this.pixelPerUnit,X.NEU),scenario3:new F(t[s[2]],s[2],this.pixelPerUnit,X.NEU),scenario4:new F(t[s[3]],s[3],this.pixelPerUnit,X.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===u.CATEGORY&&i.hierarchy.includes(b.CATEGORYINDEX)?`${b.CATEGORYINDEX}, ${u.CATEGORY} as category`:t===u.ROWGROUP&&i.hierarchy.includes(b.ROWGROUPINDEX)?`${b.ROWGROUPINDEX}, ${u.ROWGROUP} as category`:t===u.SUBCATEGORY&&i.hierarchy.includes(b.SUBCATEGORYINDEX)?`${b.SUBCATEGORYINDEX}, ${u.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===u.CATEGORY&&i.hierarchy.includes(b.CATEGORYINDEX)?`${b.CATEGORYINDEX}, ${u.CATEGORY}`:t===u.ROWGROUP&&i.hierarchy.includes(b.ROWGROUPINDEX)?`${b.ROWGROUPINDEX}, ${u.ROWGROUP}`:t===u.SUBCATEGORY&&i.hierarchy.includes(b.SUBCATEGORYINDEX)?`${b.SUBCATEGORYINDEX}, ${u.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=L(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 F(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 F(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===f.SCENARIOS;let s=0;for(const h of t){let t=0;if(i){const i=["scenario1","scenario2","scenario3","scenario4"],s=[];for(const t of i){const i=h[t];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario})}if(new Set(s.map((t=>k(t.scenario)))).size>1){const i=new Map;for(const t of s){const s=k(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 h.stackSegments&&h.stackSegments.length>0&&(t=h.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 h=null;null!=i&&i.length>0&&(h=i[0]);for(const e in t){const n=new x(t[e]);if(n.isValid){const t=this.mapScenarios(n,h),e=n.direction;let r=this.pixelPerUnit;"dr"===n.type&&(r=this.pixelPerPercentage);for(const h in i)s.push({id:Number(h),category:i[h].category,type:"dr"===n.type?N.RELATIVE:N.ABSOLUTE,scenario1:new F(this.calculateVariance(n,i[h],t),n.base,r,e),scenario2:new F(null,null,null,null),scenario3:new F(null,null,null,null),scenario4:new F(null,null,null,null)})}}return s}calculateVariance(t,i,s){const h=s.get(t.base),e=s.get(t.delta);return null==h||null==e?null:t.type===N.RELATIVE?(i[h].value-i[e].value)/i[e].value:i[h].value-i[e].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((h=>{i[h].scenario===t.delta?s.set(t.delta,h):i[h].scenario===t.base&&s.set(t.base,h)})),s}calculateTextBoxWidth(t){return L(S.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+=L("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=L(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,L(S.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 h=!1;this.hideCategories||t.forEach(((t,i)=>{t.type===N.RELATIVE&&(h=!0);let e=Y.Right,n=!0;t.scenario1.value<0&&(e=Y.Left,n=!1),new q(s,this.position.getCategoryPositionX(n),this.position.getBarCenterPositionY(i),"",t.category,this.styles,Y.Center,e).draw()})),new Z({scenarioType:this.axisScenario,labelText:this.title,isRelative:h},this.position,s,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios"),h=new st(this.position,s,this.styles,t.length,this.i18n);h.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{h.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),h.createSecondaryBar(t.scenario2,i).draw(),h.createPrimaryMarker(t.scenario3,i).draw(),h.createSecondaryMarker(t.scenario4,i).draw()}))}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),h=new st(this.position,s,this.styles,t.length,this.i18n);return h.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===N.RELATIVE?h.createRelativeVarianceBar(t.scenario1,i).draw():h.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 h=i.indexOf(t.scenario),e=i.indexOf(s.scenario);return(-1===h?i.length:h)-(-1===e?i.length:e)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),h=this.stackConfig.by===f.SCENARIOS;t.forEach(((t,i)=>{const e=["scenario1","scenario2","scenario3","scenario4"],n=[];if(h){for(const i of e){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&n.push({value:s.value,scenario:s.scenario,dataPoint:s})}this.sortSegmentsByPropOrder(n)}else{const i=t.scenario1;i&&!i.isEmpty()&&null!=i.value&&n.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0!==n.length)if((h?new Set(n.map((t=>k(t.scenario)))):new Set).size>1){const t=new Map;for(const i of n){const s=k(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const h=[];for(const i of C)t.has(i)&&(h.push({prefix:i,segments:t.get(i)}),t.delete(i));for(const[i,s]of t)h.push({prefix:i,segments:s});h.forEach(((t,e)=>{const n=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),r=h.length-1-e;let o=0,a=null;t.segments.forEach((t=>{const h=new it(this.position,this.styles,t.dataPoint,i,o,t.scenario,r,this.stackConfig.mode,n,!0,s);h.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),a=h})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}))}else{let e=n;!h&&t.stackSegments&&t.stackSegments.length>0&&(e=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint})))),"asc"===this.stackConfig.order?e.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&e.sort(((t,i)=>i.value-t.value));const r=e.reduce(((t,i)=>t+Math.abs(i.value)),0);let o=0,a=null;e.forEach(((t,e)=>{const n=new it(this.position,this.styles,t.dataPoint,i,o,t.scenario,e,this.stackConfig.mode,r,h,s);n.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),a=n})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}}))}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;const s=this.stackConfig.by===f.SCENARIOS,h=i.group().id("StackedHeaders"),e=t[0];if(!s){const t=e.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),n=this.position.getBarPositionX(),r=this.position.getStackedHeaderPositionY();let o=0;return void i.forEach((t=>{const i=t.dataPoint.pixelPerUnit;let e;e=this.stackConfig.mode===d.RELATIVE?(0!==s?Math.abs(t.value)/s:0)*i:Math.abs(t.value*i);const a=n+o+e/2,l=this.i18n.get(t.label)||t.label;new q(h,a,r,"STACK_HEADER",l,this.styles,Y.Bottom,Y.Center).draw(),o+=e}))}const 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 o=new Set(r.map((t=>k(t.scenario)))),a=this.position.getBarPositionX(),l=this.position.getStackedHeaderPositionY();if(o.size>1){const t=new Map;for(const i of r){const s=k(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const i=[];for(const s of C)t.has(s)&&(i.push({prefix:s,segments:t.get(s)}),t.delete(s));for(const[s,h]of t)i.push({prefix:s,segments:h});i.forEach((t=>{const i=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),s=t.segments[0].dataPoint.pixelPerUnit,e=a+(this.stackConfig.mode===d.RELATIVE?s:i*s)/2,n=this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase();new q(h,e,l,"STACK_HEADER",n,this.styles,Y.Bottom,Y.Center).draw()}))}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 i=0;r.forEach((s=>{const e=s.dataPoint.pixelPerUnit;let n;n=this.stackConfig.mode===d.RELATIVE?(0!==t?Math.abs(s.value)/t:0)*e:Math.abs(s.value*e);const r=a+i+n/2,o=this.i18n.get(s.scenario)||s.scenario;new q(h,r,l,"STACK_HEADER",o,this.styles,Y.Bottom,Y.Center).draw(),i+=n}))}}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:N.NONE}calculateLeftSideWidth(t){var i,s,h;let e=0;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(N.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);e=Math.abs(this.smallestDataPointValue.getScaledUnit())+n+t}else if(N.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);e=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+n+t}else if(N.ABSOLUTE===t&&null!=(null===(h=this.smallestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value);e=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+n+t}return e<=this.titleLength?this.titleLength:e}calculateRightSideWidth(t){var i,s,h;if(null!=this.stackConfig&&this.highestStackedTotal>0){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;let i;i=this.stackConfig.mode===d.RELATIVE?this.pixelPerUnit:this.highestStackedTotal*this.pixelPerUnit;const s=this.calculateTextBoxWidth(this.highestStackedTotal);return Math.max(i+t+s,this.titleLength)}let e=0;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(N.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);e=Math.abs(this.highestDataPointValue.getScaledUnit())+n+t}else if(N.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);e=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+n+t}else if(N.ABSOLUTE===t&&null!=(null===(h=this.highestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);e=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+n+t}return e<=this.titleLength?this.titleLength:e}populateDimensionStackSegments(t,i,s){if(0===this.rowCount||!this.fromExpr||0===t.length)return;const h={[u.ROWGROUP]:"category",[u.ROWGROUPINDEX]:"category",[u.CATEGORY]:"subCategory",[u.CATEGORYINDEX]:"subCategory"}[s];if(!h)return;const e=s.toString(),n=t[0];let r;try{r=this.db.exec(`SELECT [${e}] as displayGroup, [${h}] as stackLabel, SUM([${n}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${e}], [${h}]`)}catch(t){return void console.error("StructureChart: dimension-stack query failed",t)}const o=new Map;for(const t of r){const i=t.displayGroup;o.has(i)||o.set(i,[]),null!=t.stackValue&&null!=t.stackLabel&&o.get(i).push({label:t.stackLabel,value:t.stackValue})}for(const t of this.dataModel){const i=o.get(t.category);t.stackSegments=i&&i.length>0?i.map((t=>({label:t.label,value:t.value,dataPoint:new F(t.value,n,this.pixelPerUnit,X.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,h=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new F(h,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new F(-h,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new F(h,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new F(-h,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()===N.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,h=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,e=s.getScaledUnit(),n=null!=h.value?Math.abs(h.getScaledUnit()):0,r=Math.max(e,n);if(r<=0)return null;const o=this.styles.fontStyles.size,a=o*this.styles.scaleFactors.labelToBar,l=1.5*o,c=.3*o,u=.8*o,d=t-this.position.getAxisPositionX()-this.styles.padding.left-this.styles.padding.right-a-this.calculateTextBoxWidth(s.value||0)-l-c;if(d<=u)return null;const f=d-u;return r<=f?null:{cutWidth:d,overdriveZoneWidth:l,breakGap:c,maxOverflow:r-f,scenarioCutOffset:u}}}const et=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),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:m.ASC},this.level=u.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=A(this.element)),this.stores.db.db}render(){var t,i,e;if(void 0===this.chart)return s(h,null);if(this.chart.hasNoData()){const t=this.i18n.get("NO_DATA")||"==No Data==";return s(h,null,s("p",{class:"warning"},t))}return s(h,null,s("div",{innerHTML:null===(t=this.pattern)||void 0===t?void 0:t.toString(),class:"hidePatternContainer"}),s("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(i=this.chart)||void 0===i?void 0:i.getFooter()),s("div",{innerHTML:null===(e=this.chart)||void 0===e?void 0:e.toString()}))}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),h=this.prepareStyle();this.chart=new ht(new y(this.ruleSetConfig),i,this.tableName,s,h),this.chart.setI18n(this.i18n),this.autoFitScaling(s,h),this.chart.setAvailableWidth((null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new D(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 y(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 D(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}autoFitScaling(t,i){var s;const h=t.pixelPerUnit<=0,e=t.pixelPerPercentage<=0;if(!h&&!e)return;const n=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,r=this.getDb();if(!n||n<=0)return h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=50),this.chart=new ht(new y(this.ruleSetConfig),r,this.tableName,t,i),void this.chart.setI18n(this.i18n);h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=1),this.chart=new ht(new y(this.ruleSetConfig),r,this.tableName,t,i),this.chart.setI18n(this.i18n),this.chart.toString();const o=this.chart.getAllocatedCanvasWidth();if(o<=0)return;const a=this.chart.getMaxBarValue();h&&(t.pixelPerUnit=a>0?Math.max(.001,(n-(o-a))/a):.9*n/o),e&&(t.pixelPerPercentage=.9*n/o),this.chart=new ht(new y(this.ruleSetConfig),r,this.tableName,t,i),this.chart.setI18n(this.i18n)}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=this.tableName?T(this.tableName,this.filter):"";return new H(new U,new w(new $),new $,new g,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 j(new K,new r,new o(new a),new O(new a),new l).adapt(this.styles)}get element(){return this}static get style(){return':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}'}},[1,"ibcs-chart-structure",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],scenarios:[16],variances:[16],hideCategories:[4,"hide-categories"],pixelPerUnit:[2,"pixel-per-unit"],pixelPerPercentage:[2,"pixel-per-percentage"],limit:[2],styles:[1040],i18n:[1040],order:[16],level:[1],filter:[1],measureScale:[1,"measure-scale"],measureUnit:[1,"measure-unit"],showMeasureScale:[4,"show-measure-scale"],dataFormatDigits:[16],stackConfig:[16],parentDimensions:[16],ruleSetConfig:[16]}]);function nt(){"undefined"!=typeof customElements&&["ibcs-chart-structure"].forEach((t=>{"ibcs-chart-structure"===t&&(customElements.get(e(t))||customElements.define(e(t),et))}))}export{et as I,nt as d}