@bino-bi/bn-template-engine 1.0.0-next.34 → 1.0.0-next.35

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 (145) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/p-4ef6683e.entry.js +1 -0
  3. package/dist/bn-template-engine/{p-7d475277.entry.js → p-5a64f90f.entry.js} +1 -1
  4. package/dist/bn-template-engine/{p-789bfd06.entry.js → p-93b8387f.entry.js} +1 -1
  5. package/dist/bn-template-engine/{p-66ed6259.entry.js → p-9a61f59d.entry.js} +1 -1
  6. package/dist/bn-template-engine/p-BVU4bIsi.js +1 -0
  7. package/dist/bn-template-engine/{p-CJfJQT0m.js → p-D0tNATZq.js} +1 -1
  8. package/dist/bn-template-engine/p-DF9sfwBN.js +1 -0
  9. package/dist/bn-template-engine/{p-CAvWZ3a5.js → p-DyupX-Z-.js} +1 -1
  10. package/dist/bn-template-engine/{p-14d021be.entry.js → p-b0dfc113.entry.js} +1 -1
  11. package/dist/bn-template-engine/{p-dec6837c.entry.js → p-eea538f1.entry.js} +1 -1
  12. package/dist/bn-template-engine/{p-CHZ50kEY.js → p-qpZjVnX5.js} +1 -1
  13. package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +206 -48
  14. package/dist/cjs/bn-grid.cjs.entry.js +3 -3
  15. package/dist/cjs/bn-image.cjs.entry.js +2 -2
  16. package/dist/cjs/bn-internationalization.cjs.entry.js +2 -2
  17. package/dist/cjs/bn-ruleset.cjs.entry.js +2 -2
  18. package/dist/cjs/bn-text.cjs.entry.js +3 -3
  19. package/dist/cjs/{localFrame-P5SDUOto.js → localFrame-U3Qs0psw.js} +1 -1
  20. package/dist/cjs/{withBodyObserver-B1_hmuUz.js → withBodyObserver-S-FGHpAX.js} +1 -1
  21. package/dist/cjs/{withHasError-3kR2tdhJ.js → withHasError-BkBrsCpI.js} +8 -7
  22. package/dist/cjs/{withStyled-eHD8Yt2K.js → withStyled-DfE0aW7D.js} +63 -3
  23. package/dist/cjs/{withTranslation-yJ-j0lsu.js → withTranslation-0gkn9xoC.js} +2 -2
  24. package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +9 -2
  25. package/dist/collection/components/bn-table/bn-table.js +19 -10
  26. package/dist/collection/components/bn-table/utils/Table.js +34 -8
  27. package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +84 -13
  28. package/dist/collection/components/bn-table/utils/helper/DataQuery.js +57 -10
  29. package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +5 -5
  30. package/dist/collection/stores/ruleSets.js +8 -7
  31. package/dist/collection/utils/ibcsRuleSet.js +2 -1
  32. package/dist/collection/utils/model/Order.js +49 -2
  33. package/dist/collection/utils/validate.js +11 -1
  34. package/dist/components/bn-annotation-layer.js +1 -1
  35. package/dist/components/bn-annotation-list.js +1 -1
  36. package/dist/components/bn-asset.js +1 -1
  37. package/dist/components/bn-body.js +1 -1
  38. package/dist/components/bn-card.js +1 -1
  39. package/dist/components/bn-chart-bubble-renderer.js +1 -1
  40. package/dist/components/bn-chart-bubble.js +1 -1
  41. package/dist/components/bn-chart-bullet-renderer.js +1 -1
  42. package/dist/components/bn-chart-bullet.js +1 -1
  43. package/dist/components/bn-chart-scatter-renderer.js +1 -1
  44. package/dist/components/bn-chart-scatter.js +1 -1
  45. package/dist/components/bn-chart-structure-renderer.js +1 -1
  46. package/dist/components/bn-chart-structure.js +1 -1
  47. package/dist/components/bn-chart-time-renderer.js +1 -1
  48. package/dist/components/bn-chart-time.js +1 -1
  49. package/dist/components/bn-component-style.js +1 -1
  50. package/dist/components/bn-context.js +1 -1
  51. package/dist/components/bn-dataset.js +1 -1
  52. package/dist/components/bn-datasource.js +1 -1
  53. package/dist/components/bn-footer.js +1 -1
  54. package/dist/components/bn-grid.js +1 -1
  55. package/dist/components/bn-image.js +1 -1
  56. package/dist/components/bn-internationalization.js +1 -1
  57. package/dist/components/bn-layout-card.js +1 -1
  58. package/dist/components/bn-layout-page.js +1 -1
  59. package/dist/components/bn-message.js +1 -1
  60. package/dist/components/bn-page.js +1 -1
  61. package/dist/components/bn-ruleset.js +1 -1
  62. package/dist/components/bn-scaling-group.js +1 -1
  63. package/dist/components/bn-table-renderer.js +1 -1
  64. package/dist/components/bn-table.js +1 -1
  65. package/dist/components/bn-text.js +1 -1
  66. package/dist/components/bn-title-renderer.js +1 -1
  67. package/dist/components/bn-title.js +1 -1
  68. package/dist/components/bn-tree.js +1 -1
  69. package/dist/components/p-16rjcQ0t.js +1 -0
  70. package/dist/components/{p-8a2-IS-y.js → p-2eicD9rF.js} +1 -1
  71. package/dist/components/p-4vVbchX2.js +1 -0
  72. package/dist/components/{p-VIw66ez1.js → p-7ieJFBUk.js} +1 -1
  73. package/dist/components/{p-Dn3DJxQQ.js → p-9mUU4itF.js} +1 -1
  74. package/dist/components/{p-D5LDmR4u.js → p-B5tixDPM.js} +1 -1
  75. package/dist/components/p-BPGLOHUe.js +1 -0
  76. package/dist/components/{p-B3F_c9GB.js → p-BU_53KVT.js} +1 -1
  77. package/dist/components/p-BW842XlW.js +1 -0
  78. package/dist/components/p-BXXjh6We.js +1 -0
  79. package/dist/components/{p-C-oNdJj9.js → p-BXg3v5AO.js} +1 -1
  80. package/dist/components/{p-B7UDMyar.js → p-BhEdmPjm.js} +1 -1
  81. package/dist/components/{p-nHZ8466v.js → p-BmOWXYHF.js} +1 -1
  82. package/dist/components/{p-DLLljAll.js → p-Bo_R7f_T.js} +1 -1
  83. package/dist/components/{p-DdG2Ylar.js → p-BqUB56k1.js} +1 -1
  84. package/dist/components/{p-DHAoxu6M.js → p-BzjGUtYh.js} +1 -1
  85. package/dist/components/{p-BtH2oezK.js → p-C-KX1_tw.js} +1 -1
  86. package/dist/components/{p-BldMZbAf.js → p-C3gYq-HU.js} +1 -1
  87. package/dist/components/{p-CPC9Vkmg.js → p-CQVAHG6w.js} +1 -1
  88. package/dist/components/{p-4BanAktr.js → p-C_6KHDYv.js} +1 -1
  89. package/dist/components/{p-ClGOhg6P.js → p-Cel0a6ma.js} +1 -1
  90. package/dist/components/{p-Ku08TQL1.js → p-Chuj-LpI.js} +1 -1
  91. package/dist/components/{p-M6hn0BuZ.js → p-CniN8ALm.js} +1 -1
  92. package/dist/components/{p-BcOud3dQ.js → p-DDvWTgk1.js} +1 -1
  93. package/dist/components/p-DJUffGeB.js +1 -0
  94. package/dist/components/p-DQl2K2Xl.js +1 -0
  95. package/dist/components/p-DT04Cka0.js +1 -0
  96. package/dist/components/{p-BVnYDfb8.js → p-DTmqMQpw.js} +1 -1
  97. package/dist/components/{p-DSkyHSIL.js → p-DaOm9YwQ.js} +1 -1
  98. package/dist/components/p-DjPWZfry.js +1 -0
  99. package/dist/components/{p-BXt0ers2.js → p-Dm6EAaJ9.js} +1 -1
  100. package/dist/components/p-Do4oPrkE.js +1 -0
  101. package/dist/components/{p-DEHnizot.js → p-Dq9dG0Kr.js} +1 -1
  102. package/dist/components/{p-D6cWoDk1.js → p-M2k_I8lv.js} +1 -1
  103. package/dist/components/{p-B4pmO5QQ.js → p-NBaq67dL.js} +1 -1
  104. package/dist/components/p-OquycEMA.js +1 -0
  105. package/dist/components/{p-CJtE8Pyr.js → p-eWxolPDU.js} +1 -1
  106. package/dist/components/{p-De82WP7z.js → p-fKJx8WtW.js} +1 -1
  107. package/dist/components/{p-xhiPDAZa.js → p-sLbQ7yZ1.js} +1 -1
  108. package/dist/components/{p-GrpYAVHb.js → p-sar8m7th.js} +1 -1
  109. package/dist/components/{p-CYqHwYgQ.js → p-tkB96Ena.js} +1 -1
  110. package/dist/esm/bn-annotation-layer_30.entry.js +206 -48
  111. package/dist/esm/bn-grid.entry.js +3 -3
  112. package/dist/esm/bn-image.entry.js +2 -2
  113. package/dist/esm/bn-internationalization.entry.js +2 -2
  114. package/dist/esm/bn-ruleset.entry.js +2 -2
  115. package/dist/esm/bn-text.entry.js +3 -3
  116. package/dist/esm/{localFrame-IW84cmdb.js → localFrame-BNWPPaQa.js} +1 -1
  117. package/dist/esm/{withBodyObserver-CAnnvrE_.js → withBodyObserver-AHQAUV85.js} +1 -1
  118. package/dist/esm/{withHasError-Cj_MzZ8Q.js → withHasError-B6Lvj9Cq.js} +8 -7
  119. package/dist/esm/{withStyled-Cxua0iTP.js → withStyled-CIoJ86RM.js} +61 -4
  120. package/dist/esm/{withTranslation-BeAbw2--.js → withTranslation-BX9T3dfm.js} +2 -2
  121. package/dist/types/components/bn-table/bn-table.d.ts +17 -4
  122. package/dist/types/components/bn-table/utils/Table.d.ts +2 -0
  123. package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +1 -1
  124. package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +8 -0
  125. package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +3 -2
  126. package/dist/types/components.d.ts +4 -4
  127. package/dist/types/stores/ruleSets.d.ts +2 -1
  128. package/dist/types/utils/ibcsRuleSet.d.ts +2 -1
  129. package/dist/types/utils/model/Order.d.ts +18 -1
  130. package/dist/types/utils/validate.d.ts +2 -0
  131. package/package.json +1 -1
  132. package/dist/bn-template-engine/p-BNCLKXjM.js +0 -1
  133. package/dist/bn-template-engine/p-_SKPuKfK.js +0 -1
  134. package/dist/bn-template-engine/p-dc12ff1b.entry.js +0 -1
  135. package/dist/components/p-BNWZoAip.js +0 -1
  136. package/dist/components/p-BT2WH_CP.js +0 -1
  137. package/dist/components/p-BVtD8O36.js +0 -1
  138. package/dist/components/p-BWRE5w0i.js +0 -1
  139. package/dist/components/p-C6XrNN2m.js +0 -1
  140. package/dist/components/p-CGI6XIaK.js +0 -1
  141. package/dist/components/p-CLkpoHdg.js +0 -1
  142. package/dist/components/p-CYv_8LrR.js +0 -1
  143. package/dist/components/p-Ckl1aEvn.js +0 -1
  144. package/dist/components/p-CurWSJkH.js +0 -1
  145. package/dist/components/p-D7X69xMg.js +0 -1
@@ -64,17 +64,17 @@ export function absoluteBarGeometry(widthEm, emPx, hasNeg, hasPos) {
64
64
  export function relativePinGeometry(widthEm, emPx, hasNeg, hasPos) {
65
65
  const totalWidth = contentWidth(widthEm, emPx);
66
66
  const sides = sideCount(hasNeg, hasPos);
67
- const labelAreaWidth = Math.min(PIN_LABEL_EM * emPx, totalWidth / 2);
68
- const pinAreaWidth = totalWidth - labelAreaWidth;
69
- const sideWidth = pinAreaWidth / sides;
67
+ const labelAreaWidth = Math.min(PIN_LABEL_EM * emPx, totalWidth / (2 * sides));
68
+ const sideWidth = (totalWidth - labelAreaWidth * sides) / sides;
69
+ // also leaves room for the outer half of the pin head
70
70
  const pinPadding = Math.min(PIN_PADDING_EM * emPx, sideWidth * 0.2);
71
71
  return {
72
72
  totalWidth,
73
73
  labelAreaWidth,
74
74
  maxPinLength: Math.max(0, sideWidth - pinPadding),
75
75
  pinPadding,
76
- axisX: hasNeg ? sideWidth : 0,
77
- labelX: pinAreaWidth + LABEL_GAP_EM * emPx,
76
+ axisX: hasNeg ? labelAreaWidth + sideWidth : 0,
77
+ labelGap: LABEL_GAP_EM * emPx,
78
78
  };
79
79
  }
80
80
  export function waterfallGeometry(widthEm, emPx) {
@@ -14,7 +14,8 @@
14
14
  /**
15
15
  * Built-in IBCS rule-set defaults per IBCS notation standard v1.2.
16
16
  * Sort order: PP(100s) < PL(200s) < FC(300s) < AC(400s); variance prefixes
17
- * add +1000 (absolute) or +2000 (relative).
17
+ * add +1000 (absolute) or +1005 (relative), so a relative variance sorts
18
+ * directly after the absolute variance with the same reference.
18
19
  */
19
20
  export const SYSTEM_RULESET_DEFAULTS = {
20
21
  scenarios: {
@@ -30,12 +31,12 @@ export const SYSTEM_RULESET_DEFAULTS = {
30
31
  dbu: { name: "dBU", colorIndex: 50, sortIndex: 1200 },
31
32
  dpp: { name: "dPP", colorIndex: 20, sortIndex: 1100 },
32
33
  dpy: { name: "dPY", colorIndex: 20, sortIndex: 1100 },
33
- drac: { name: "drAC", colorIndex: 10, sortIndex: 2400 },
34
- drfc: { name: "drFC", colorIndex: 30, sortIndex: 2300 },
35
- drpl: { name: "drPL", colorIndex: 50, sortIndex: 2200 },
36
- drbu: { name: "drBU", colorIndex: 50, sortIndex: 2200 },
37
- drpp: { name: "drPP", colorIndex: 20, sortIndex: 2100 },
38
- drpy: { name: "drPY", colorIndex: 20, sortIndex: 2100 },
34
+ drac: { name: "drAC", colorIndex: 10, sortIndex: 1405 },
35
+ drfc: { name: "drFC", colorIndex: 30, sortIndex: 1305 },
36
+ drpl: { name: "drPL", colorIndex: 50, sortIndex: 1205 },
37
+ drbu: { name: "drBU", colorIndex: 50, sortIndex: 1205 },
38
+ drpp: { name: "drPP", colorIndex: 20, sortIndex: 1105 },
39
+ drpy: { name: "drPY", colorIndex: 20, sortIndex: 1105 },
39
40
  },
40
41
  fallback: {
41
42
  name: "Series",
@@ -53,7 +53,8 @@ export function ruleSetLabels(config) {
53
53
  * - 50 = PL: outlined (no fill)
54
54
  *
55
55
  * Sort indices determine column display order: PP(100s) < PL(200s) < FC(300s) < AC(400s).
56
- * Variance columns add +1000 (absolute) or +2000 (relative) to the base sort index.
56
+ * Variance columns add +1000 (absolute) or +1005 (relative) to the base sort index,
57
+ * so a relative variance sorts directly after the absolute variance with the same reference.
57
58
  * Within each group, variant number (1-4) adds multiples of 10.
58
59
  *
59
60
  * The built-in rules live in `SYSTEM_RULESET_DEFAULTS` (stores/ruleSets); an
@@ -40,15 +40,62 @@ export class Order {
40
40
  this.direction = direction;
41
41
  }
42
42
  }
43
+ const DIM_COLUMNS = [
44
+ OrderColumn.ROWGROUP,
45
+ OrderColumn.ROWGROUPINDEX,
46
+ OrderColumn.CATEGORY,
47
+ OrderColumn.CATEGORYINDEX,
48
+ OrderColumn.SUBCATEGORY,
49
+ OrderColumn.SUBCATEGORYINDEX,
50
+ ];
51
+ const ORDER_SCENARIO_REGEX = /^(?:ac|fc|pp|pl)[1-4]$/;
52
+ const ORDER_VARIANCE_REGEX = /^(dr|d)((?:ac|fc|pp|pl)[1-4])_((?:ac|fc|pp|pl)[1-4])(?:_(?:pos|neg|neu|opinv|op))?$/;
53
+ /** Parses one bn-table order token, case-insensitive except for the bucket. undefined: not a valid token. */
54
+ export function parseOrderToken(token) {
55
+ if (token == null) {
56
+ return undefined;
57
+ }
58
+ const at = token.indexOf("@");
59
+ const head = (at < 0 ? token : token.slice(0, at)).trim().toLowerCase();
60
+ const bucket = at < 0 ? undefined : token.slice(at + 1).trim();
61
+ if (bucket === "") {
62
+ return undefined;
63
+ }
64
+ const dim = OrderColumn[head.toUpperCase()];
65
+ if (dim != null && DIM_COLUMNS.includes(dim)) {
66
+ return bucket === undefined ? { kind: "dim", column: dim } : undefined;
67
+ }
68
+ if (ORDER_SCENARIO_REGEX.test(head)) {
69
+ return { kind: "scenario", column: head, bucket };
70
+ }
71
+ const variance = ORDER_VARIANCE_REGEX.exec(head);
72
+ if (variance != null) {
73
+ const [, type, base, delta] = variance;
74
+ return { kind: "variance", column: `${type}${base}_${delta}`, type: type, base, delta, bucket };
75
+ }
76
+ return undefined;
77
+ }
78
+ /** Normalized form of a bn-table order token (`column[@bucket]`), undefined when it does not parse. */
79
+ export function normalizeOrderToken(token) {
80
+ const parsed = parseOrderToken(token);
81
+ if (parsed == null) {
82
+ return undefined;
83
+ }
84
+ return parsed.bucket === undefined ? parsed.column : `${parsed.column}@${parsed.bucket}`;
85
+ }
43
86
  export class OrderAdapter {
44
- constructor(stringAdapter) {
87
+ /** @param allowMeasures bn-table only: keep variance and `@bucket` tokens instead of mapping them to category. */
88
+ constructor(stringAdapter, allowMeasures = false) {
45
89
  this.stringAdapter = stringAdapter;
90
+ this.allowMeasures = allowMeasures;
46
91
  }
47
92
  adapt(data) {
48
93
  var _a;
49
94
  const hierarchy = AdapterUtils.adaptArray(data.hierarchy, this.stringAdapter);
50
95
  const order = OrderDirection[(_a = data.direction) === null || _a === void 0 ? void 0 : _a.toUpperCase()] || OrderDirection.ASC;
51
- return new Order(hierarchy.map((str) => OrderColumn[str.toUpperCase()] || OrderColumn.CATEGORY), order);
96
+ return new Order(hierarchy.map((str) => (this.allowMeasures
97
+ ? normalizeOrderToken(str)
98
+ : OrderColumn[str.toUpperCase()]) || OrderColumn.CATEGORY), order);
52
99
  }
53
100
  default() {
54
101
  return new Order(["category"], OrderDirection.ASC);
@@ -8,7 +8,7 @@
8
8
  import { AggregationLevel, AxisLabelsMode, DataFormat, I18nMode, MeasureType, Scenarios, Sentiments, TableBarColumnWidth, TableCategoryWidth, TableType, } from "./constants";
9
9
  import { isValidAttributeExpression } from "../components/bn-table/utils/model/TableAttribute";
10
10
  import { DateDistance, DateLink } from "./DateStringFactory";
11
- import { OrderColumn, OrderDirection } from "./model/Order";
11
+ import { OrderColumn, OrderDirection, parseOrderToken } from "./model/Order";
12
12
  import { resolveMeasure } from "./xy/VarianceMeasure";
13
13
  /**
14
14
  * Checks whether a value is blank, null, undefined, or the string `"null"`.
@@ -81,6 +81,16 @@ export function validateOrderList(value) {
81
81
  const invalidScenarios = value.split(",").filter((element) => !(element.toUpperCase() in OrderColumn));
82
82
  return validateVariancesList(invalidScenarios.toString());
83
83
  }
84
+ /** bn-table order: dims, scenarios and variances, the last two optionally with `@<setname>`. */
85
+ export function validateTableOrderList(value) {
86
+ if (isBlankInput(value)) {
87
+ return [];
88
+ }
89
+ if (value.trim().toLowerCase() === "auto") {
90
+ return [];
91
+ }
92
+ return value.split(",").filter((element) => parseOrderToken(element) === undefined);
93
+ }
84
94
  export function isValidInteger(value) {
85
95
  if (isBlankInput(value)) {
86
96
  return false;
@@ -1 +1 @@
1
- import{p as t,t as e,H as n,h as i,a as o}from"./p-D6YGOYV1.js";import{g as s}from"./p-BcOud3dQ.js";import{a as r,c as a,b as l}from"./p-D6cWoDk1.js";import{w as h,C as c}from"./p-DEHnizot.js";import{w as u}from"./p-C6XrNN2m.js";import{w as d}from"./p-CGI6XIaK.js";const b=t=>({x:t.x+t.width/2,y:t.y+t.height/2});function f(t,e){const n=b(t),i=e.x-n.x,o=e.y-n.y,s=Math.min(0===i?1/0:t.width/2/Math.abs(i),0===o?1/0:t.height/2/Math.abs(o));return Number.isFinite(s)?{x:n.x+i*s,y:n.y+o*s}:n}function m(t,e){return e?Object.assign(Object.assign({},t),{cx:Math.max(t.r,Math.min(t.cx,e.width-t.r)),cy:Math.max(t.r,Math.min(t.cy,e.height-t.r))}):t}const v=(t,e)=>t.x<e.x+e.width&&e.x<t.x+t.width&&t.y<e.y+e.height&&e.y<t.y+t.height;function y(t,e,n,i){var o,s,r;const a=.25*n,l=t.y+t.height/2,h=null!==(o=i.obstacles)&&void 0!==o?o:[],c=t=>{const n={x:t-e,y:l-e,width:2*e,height:2*e},o=i.area;return(!o||n.x>=0&&n.x+n.width<=o.width)&&!h.some((t=>v(n,t)))},u=t.x+t.width,d=t.x-a-e,b=u+a+e;if(c(d))return{x:d,y:l,r:e};if(c(b))return{x:b,y:l,r:e};const f=2*(e+a),m=h.filter((t=>t.y<l&&t.y+t.height>l)),y=Math.max(0,t.x-f,...m.filter((e=>e.x+e.width<=t.x)).map((t=>t.x+t.width))),p=Math.min(null!==(r=null===(s=i.area)||void 0===s?void 0:s.width)&&void 0!==r?r:1/0,u+f,...m.filter((t=>t.x>=u)).map((t=>t.x))),g=t.x-y,w=p-u;return{x:w>=g?u+w/2:t.x-g/2,y:l,r:Math.min(e,Math.max(Math.max(g,w)/2,.3*n))}}function p(t,e,n,i,o={}){var s;const{label:r,color:a}=t,{whole:l,area:h,text:c}=o,u=!l&&!c&&null!=o.obstacles,d=((t,e)=>t?Math.min(e,t.height/1.3):e)(null!=c?c:u?e:void 0,i);if("arrow"===t.mark){if(!n)return;const t=b(e),o=b(n);if(t.x===o.x&&t.y===o.y)return;let s=f(e,o),l=f(n,t);(l.x-s.x)*(o.x-t.x)+(l.y-s.y)*(o.y-t.y)<=0&&(s=t,l=o);const c=Math.hypot(l.x-s.x,l.y-s.y),u=Math.min(.8*i,c),d=(l.x-s.x)/c,v=(l.y-s.y)/c,y=l.x-d*u,p=l.y-v*u,g=.35*i;return{kind:"arrow",color:a,x1:s.x,y1:s.y,x2:y,y2:p,head:[`${l.x},${l.y}`,`${y-v*g},${p+d*g}`,`${y+v*g},${p-d*g}`].join(" "),badge:null!=r?m({cx:s.x,cy:s.y,r:.65*i,label:r},h):void 0}}if("frame"===t.mark){const n=null!=c?c:e,o=null===(s=t.point)||void 0===s?void 0:s.part,u=!l&&(null!=c||"label"===o||"total"===o),b=(u?.45:.2)*d,f=(u?.1:.2)*d,v=u?Math.max(n.width,n.height):n.width,y=n.x+n.width/2,p=1,g=Math.max(h?p:-1/0,y-v/2-b),w=Math.max(h?p:-1/0,n.y-f),x=Math.min(h?h.width-p:1/0,y+v/2+b),M=Math.min(h?h.height-p:1/0,n.y+n.height+f),k=Math.min(x-g,M-w)/2,S=l?.25*i:k,$=l?.25*i:u?Math.min((x-g)/2,1.6*k):k,O=1-Math.SQRT1_2,j=.65*d,C=u?.6*j:0;return{kind:"frame",color:a,x:g,y:w,width:x-g,height:M-w,rx:$,ry:S,badge:null!=r?m({cx:x-$*O+C,cy:w+S*O-C,r:j,label:r},h):void 0}}if(c&&!l){const t=y(c,(null==r?.4:.65)*d,d,o);return{kind:"marker",color:a,badge:m({cx:t.x,cy:t.y,r:t.r,label:r},h)}}const p=(null==r?.4:.75)*d,g=u?Math.min(p,e.height/2):p,w=l?{x:e.x+e.width-g,y:e.y+g}:b(e);if(u){const t={x:w.x-g,y:w.y-g,width:2*g,height:2*g},e=o.obstacles.find((e=>v(t,e)));if(e){const t=y(e,g,d,o);return{kind:"marker",color:a,badge:m({cx:t.x,cy:t.y,r:t.r,label:r},h)}}}return{kind:"marker",color:a,badge:m({cx:w.x,cy:w.y,r:g,label:r},h)}}const g=["rowGroup","category","subCategory","date","scenario","row"];function w(t,e){const n=e.getBoundingClientRect();if(0===n.width||0===n.height)return!0;const i=t.x+t.width/2,o=t.y+t.height/2;return i>=n.left&&i<=n.right&&o>=n.top&&o<=n.bottom}const x=new Set(["bn-asset","bn-component-style","bn-dataset","bn-datasource","bn-internationalization","bn-ruleset","bn-scaling-group"]);function M(t,e){const n=e.getBoundingClientRect();return 0===n.width||0===n.height||t.x<n.right&&t.x+t.width>n.left&&t.y<n.bottom&&t.y+t.height>n.top}const k=t(class extends n{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.marks=[],this.pageKey="",this.parsedItems=[],this.scheduled=!1,this.run=0,this.observed=new WeakSet,this.reported=new Set,this.schedule=()=>{this.scheduled||(this.scheduled=!0,this.holdStatus(new Promise((t=>{requestAnimationFrame((()=>{this.scheduled=!1,this.place().catch((t=>console.error("bn-annotation-layer: placing the marks failed",t))).finally(t)}))}))))},this.holdStatus=h(this),this.errors=d(this),this.componentStyle=u(this)}connectedCallback(){var t;this.stores=s(this.element),this.pageKey=r(this.element),this.observed=new WeakSet,this.resizeObserver=new ResizeObserver(this.schedule),this.mutationObserver=new MutationObserver(this.schedule),this.observeSize(this.element);const e=this.element.closest("bn-layout-page");e&&this.mutationObserver.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot","data-bino-annotation-target"]}),null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.schedule)}disconnectedCallback(){var t,e,n,i;null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(e=this.mutationObserver)||void 0===e||e.disconnect(),null===(n=document.fonts)||void 0===n||n.removeEventListener("loadingdone",this.schedule),this.run++,(null===(i=this.stores)||void 0===i?void 0:i.annotationsUnplaced.state[this.pageKey])&&this.stores.annotationsUnplaced.set(this.pageKey,void 0)}componentWillLoad(){this.parseItems()}componentDidLoad(){this.schedule()}onItemsChange(){this.parseItems(),this.schedule()}parseItems(){const t=a(this.items);t?this.errors.remove("ERR_items"):this.errors.addOrReplace({id:"ERR_items",type:"error",message:"items: not a JSON array of objects."}),this.parsedItems=null!=t?t:[]}async place(){var t;const e=++this.run;if(!this.element.isConnected||!this.svg)return;const n=this.element.closest("bn-layout-page"),i=new Map,o=new Map;null==n||n.querySelectorAll("[data-bino-annotation-target]").forEach((t=>{const e=Array.from(t.querySelectorAll("*")).find((t=>t.localName.startsWith("bn-")&&!x.has(t.localName))),n=null!=e?e:t;i.set(t.getAttribute("data-bino-annotation-target"),n),o.set(n,t)})),null==n||n.querySelectorAll("[slot]").forEach((t=>this.observeSize(t)));const s=new Set(this.parsedItems.flatMap((t=>[t.target,t.to]))),r=[...i].filter((([t])=>s.has(t))).map((([,t])=>t));if(await Promise.all(r.map((t=>{var e;return null===(e=t.componentOnReady)||void 0===e?void 0:e.call(t)}))),e!==this.run)return;r.forEach((t=>this.observe(t)));const a=new Map;if(await Promise.all(r.map((async t=>{var e;a.set(t,await(null===(e=t.getLayoutState)||void 0===e?void 0:e.call(t,{detail:"full"}).catch((()=>{}))))}))),e!==this.run)return;const l=(t,e)=>{var n;const s=null!=t?i.get(t):void 0;if(!s)return{problem:`no target "${t}" on this page`};const r=s.getBoundingClientRect();if(function(t){return!t||g.every((e=>null==t[e]))&&null==t.part}(e)){const e={x:r.left,y:r.top,width:r.width,height:r.height};return function(t,e,n){if(0===t.width||0===t.height||!M(t,n))return!0;for(let n=e;n&&"bn-layout-page"!==n.localName;n=n.parentElement)if(!M(t,n))return!0;return!1}(e,o.get(s),this.element)?{problem:`"${t}" cannot be seen`}:{box:e,whole:!0}}const l=a.get(s),h=l?function(t,e){var n;const i=t.table&&null==e.scenario?t.table.rows:null!==(n=t.elements)&&void 0!==n?n:[],o=null!=t.table&&null==e.subCategory;return i.filter((t=>function(t,e){var n;return!(!t||t.part!==(null!==(n=e.part)&&void 0!==n?n:"element"))&&g.every((n=>null==e[n]||e[n]+""===t[n]))}(t.point,e)&&!(o&&null!=t.point.subCategory))).map((({rect:t,content:e,contentSign:n})=>({rect:t,content:e,contentSign:n})))}(l,e):[];if(1!==h.length)return{problem:`${h.length} elements match the point ${JSON.stringify(e)} in "${t}"`};const c=({component:{x:t,y:e,width:n,height:i}})=>({x:r.left+t,y:r.top+e,width:n,height:i}),u=c(h[0].rect);if(function(t,e){for(let n=e;n&&"bn-layout-page"!==n.localName;n=n.parentElement)if(!w(t,n))return!0;return!1}(u,o.get(s))||!w(u,this.element))return{problem:`the point ${JSON.stringify(e)} in "${t}" is cut off`};const d=h[0].content;if(!l.table)return{box:u,whole:!1};const b=(null!==(n=l.elements)&&void 0!==n?n:[]).flatMap((t=>"cell"===t.kind&&t.content?[{box:c(t.content),sign:t.contentSign}]:[]));return{box:u,whole:!1,text:d&&{box:c(d),sign:h[0].contentSign},obstacles:b}},h=this.toLocalSpace(),c=({box:t,sign:e=0})=>{const n=h(t);return Object.assign(Object.assign({},n),{x:n.x-e,width:n.width+e})},u=parseFloat(getComputedStyle(this.svg).fontSize)||13.3333,d={width:this.element.clientWidth,height:this.element.clientHeight},b=[],f=[];for(const e of this.parsedItems){const n=l(e.target,e.point),i="arrow"===e.mark?l(e.to,e.toPoint):void 0,o="problem"in n?n:i&&"problem"in i?i:void 0;if(o){f.push({item:e,problem:o.problem});continue}const s=n,r=i,a=p(e,h(s.box),r&&h(r.box),u,{whole:s.whole,area:d,text:s.text&&c(s.text),obstacles:null===(t=s.obstacles)||void 0===t?void 0:t.map(c)});a?b.push(a):f.push({item:e,problem:"an arrow needs two ends at different places"})}this.marks=b,this.storeUnplaced(f.flatMap((({item:t})=>null!=t.label?[t.label]:[]))),f.length>0&&this.reportWhenQuiet(e,f)}async reportWhenQuiet(t,e){let n=0;for(let e=0;e<50&&n<2;e++){if(await new Promise((t=>window.setTimeout(t,200))),t!==this.run)return;n=0===c.componentRegisterStatus().running?n+1:0}this.report(e)}report(t){var e,n;for(const{item:i,problem:o}of t){const t=`bn-annotation-layer: ${null!==(e=i.mark)&&void 0!==e?e:"marker"} ${null!==(n=i.label)&&void 0!==n?n:"without a number"} is not drawn: ${o}.`;this.reported.has(t)||(this.reported.add(t),console.warn(t))}}toLocalSpace(){var t;const e=null===(t=this.svg.getScreenCTM())||void 0===t?void 0:t.inverse();return t=>{if(!e)return t;const n=[[t.x,t.y],[t.x+t.width,t.y+t.height]].map((([t,n])=>new DOMPoint(t,n).matrixTransform(e)));return{x:Math.min(n[0].x,n[1].x),y:Math.min(n[0].y,n[1].y),width:Math.abs(n[1].x-n[0].x),height:Math.abs(n[1].y-n[0].y)}}}storeUnplaced(t){var e,n;const i=null===(e=this.stores)||void 0===e?void 0:e.annotationsUnplaced,o=null!==(n=null==i?void 0:i.state[this.pageKey])&&void 0!==n?n:[];i&&JSON.stringify(o)!==JSON.stringify(t)&&i.set(this.pageKey,t)}observe(t){this.observeSize(t);const e=t=>{var n;t&&(this.observed.has(t)||(this.observed.add(t),null===(n=this.mutationObserver)||void 0===n||n.observe(t,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["x","y","width","height","transform","style","class"]})),t.querySelectorAll("*").forEach((t=>e(t.shadowRoot))))};e(t.shadowRoot)}observeSize(t){var e;this.observed.has(t)||(this.observed.add(t),null===(e=this.resizeObserver)||void 0===e||e.observe(t))}renderBadge(t,e){return t?i("g",null,i("circle",{cx:t.cx,cy:t.cy,r:t.r,style:{fill:e}}),null!=t.label?i("text",{class:"badge-text",x:t.cx,y:t.cy,style:{fontSize:1.1*t.r+"px"}},t.label):null):null}renderMark(t){var e,n;const o=l(t.color,this.componentStyle((t=>t["bn-annotation"])));return"marker"===t.kind?i("g",{class:"mark marker","data-label":t.badge.label},this.renderBadge(t.badge,o)):"frame"===t.kind?i("g",{class:"mark frame","data-label":null===(e=t.badge)||void 0===e?void 0:e.label},i("rect",{x:t.x,y:t.y,width:t.width,height:t.height,rx:t.rx,ry:t.ry,style:{fill:"none",stroke:o,strokeWidth:"1.5"}}),this.renderBadge(t.badge,o)):i("g",{class:"mark arrow","data-label":null===(n=t.badge)||void 0===n?void 0:n.label},i("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,style:{stroke:o,strokeWidth:"1.5"}}),i("polygon",{points:t.head,style:{fill:o}}),this.renderBadge(t.badge,o))}render(){return i(o,{key:"05ca564aeeaf190a45cd42020b307891990e04fe"},i("svg",{key:"995c55b16803107766bf2c394d8d799c0de5765d",ref:t=>this.svg=t},this.marks.map((t=>this.renderMark(t)))))}get element(){return this}static get watchers(){return{items:[{onItemsChange:0}]}}static get style(){return':host{position:absolute;inset:0;z-index:1;display:block;pointer-events:none;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px)}svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}.badge-text{fill:#ffffff;font-weight:bold;text-anchor:middle;dominant-baseline:central}'}},[1,"bn-annotation-layer",{items:[1],selectedStyle:[513,"selected-style"],marks:[32]},void 0,{items:[{onItemsChange:0}]}]),S=k,$=function(){"undefined"!=typeof customElements&&["bn-annotation-layer"].forEach((t=>{"bn-annotation-layer"===t&&(customElements.get(e(t))||customElements.define(e(t),k))}))};export{S as BnAnnotationLayer,$ as defineCustomElement}
1
+ import{p as t,t as e,H as n,h as i,a as o}from"./p-D6YGOYV1.js";import{g as s}from"./p-DDvWTgk1.js";import{a as r,c as a,b as l}from"./p-M2k_I8lv.js";import{w as h,C as c}from"./p-Dq9dG0Kr.js";import{w as u}from"./p-DjPWZfry.js";import{w as d}from"./p-4vVbchX2.js";const b=t=>({x:t.x+t.width/2,y:t.y+t.height/2});function f(t,e){const n=b(t),i=e.x-n.x,o=e.y-n.y,s=Math.min(0===i?1/0:t.width/2/Math.abs(i),0===o?1/0:t.height/2/Math.abs(o));return Number.isFinite(s)?{x:n.x+i*s,y:n.y+o*s}:n}function m(t,e){return e?Object.assign(Object.assign({},t),{cx:Math.max(t.r,Math.min(t.cx,e.width-t.r)),cy:Math.max(t.r,Math.min(t.cy,e.height-t.r))}):t}const v=(t,e)=>t.x<e.x+e.width&&e.x<t.x+t.width&&t.y<e.y+e.height&&e.y<t.y+t.height;function y(t,e,n,i){var o,s,r;const a=.25*n,l=t.y+t.height/2,h=null!==(o=i.obstacles)&&void 0!==o?o:[],c=t=>{const n={x:t-e,y:l-e,width:2*e,height:2*e},o=i.area;return(!o||n.x>=0&&n.x+n.width<=o.width)&&!h.some((t=>v(n,t)))},u=t.x+t.width,d=t.x-a-e,b=u+a+e;if(c(d))return{x:d,y:l,r:e};if(c(b))return{x:b,y:l,r:e};const f=2*(e+a),m=h.filter((t=>t.y<l&&t.y+t.height>l)),y=Math.max(0,t.x-f,...m.filter((e=>e.x+e.width<=t.x)).map((t=>t.x+t.width))),p=Math.min(null!==(r=null===(s=i.area)||void 0===s?void 0:s.width)&&void 0!==r?r:1/0,u+f,...m.filter((t=>t.x>=u)).map((t=>t.x))),g=t.x-y,w=p-u;return{x:w>=g?u+w/2:t.x-g/2,y:l,r:Math.min(e,Math.max(Math.max(g,w)/2,.3*n))}}function p(t,e,n,i,o={}){var s;const{label:r,color:a}=t,{whole:l,area:h,text:c}=o,u=!l&&!c&&null!=o.obstacles,d=((t,e)=>t?Math.min(e,t.height/1.3):e)(null!=c?c:u?e:void 0,i);if("arrow"===t.mark){if(!n)return;const t=b(e),o=b(n);if(t.x===o.x&&t.y===o.y)return;let s=f(e,o),l=f(n,t);(l.x-s.x)*(o.x-t.x)+(l.y-s.y)*(o.y-t.y)<=0&&(s=t,l=o);const c=Math.hypot(l.x-s.x,l.y-s.y),u=Math.min(.8*i,c),d=(l.x-s.x)/c,v=(l.y-s.y)/c,y=l.x-d*u,p=l.y-v*u,g=.35*i;return{kind:"arrow",color:a,x1:s.x,y1:s.y,x2:y,y2:p,head:[`${l.x},${l.y}`,`${y-v*g},${p+d*g}`,`${y+v*g},${p-d*g}`].join(" "),badge:null!=r?m({cx:s.x,cy:s.y,r:.65*i,label:r},h):void 0}}if("frame"===t.mark){const n=null!=c?c:e,o=null===(s=t.point)||void 0===s?void 0:s.part,u=!l&&(null!=c||"label"===o||"total"===o),b=(u?.45:.2)*d,f=(u?.1:.2)*d,v=u?Math.max(n.width,n.height):n.width,y=n.x+n.width/2,p=1,g=Math.max(h?p:-1/0,y-v/2-b),w=Math.max(h?p:-1/0,n.y-f),x=Math.min(h?h.width-p:1/0,y+v/2+b),M=Math.min(h?h.height-p:1/0,n.y+n.height+f),k=Math.min(x-g,M-w)/2,S=l?.25*i:k,$=l?.25*i:u?Math.min((x-g)/2,1.6*k):k,O=1-Math.SQRT1_2,j=.65*d,C=u?.6*j:0;return{kind:"frame",color:a,x:g,y:w,width:x-g,height:M-w,rx:$,ry:S,badge:null!=r?m({cx:x-$*O+C,cy:w+S*O-C,r:j,label:r},h):void 0}}if(c&&!l){const t=y(c,(null==r?.4:.65)*d,d,o);return{kind:"marker",color:a,badge:m({cx:t.x,cy:t.y,r:t.r,label:r},h)}}const p=(null==r?.4:.75)*d,g=u?Math.min(p,e.height/2):p,w=l?{x:e.x+e.width-g,y:e.y+g}:b(e);if(u){const t={x:w.x-g,y:w.y-g,width:2*g,height:2*g},e=o.obstacles.find((e=>v(t,e)));if(e){const t=y(e,g,d,o);return{kind:"marker",color:a,badge:m({cx:t.x,cy:t.y,r:t.r,label:r},h)}}}return{kind:"marker",color:a,badge:m({cx:w.x,cy:w.y,r:g,label:r},h)}}const g=["rowGroup","category","subCategory","date","scenario","row"];function w(t,e){const n=e.getBoundingClientRect();if(0===n.width||0===n.height)return!0;const i=t.x+t.width/2,o=t.y+t.height/2;return i>=n.left&&i<=n.right&&o>=n.top&&o<=n.bottom}const x=new Set(["bn-asset","bn-component-style","bn-dataset","bn-datasource","bn-internationalization","bn-ruleset","bn-scaling-group"]);function M(t,e){const n=e.getBoundingClientRect();return 0===n.width||0===n.height||t.x<n.right&&t.x+t.width>n.left&&t.y<n.bottom&&t.y+t.height>n.top}const k=t(class extends n{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.marks=[],this.pageKey="",this.parsedItems=[],this.scheduled=!1,this.run=0,this.observed=new WeakSet,this.reported=new Set,this.schedule=()=>{this.scheduled||(this.scheduled=!0,this.holdStatus(new Promise((t=>{requestAnimationFrame((()=>{this.scheduled=!1,this.place().catch((t=>console.error("bn-annotation-layer: placing the marks failed",t))).finally(t)}))}))))},this.holdStatus=h(this),this.errors=d(this),this.componentStyle=u(this)}connectedCallback(){var t;this.stores=s(this.element),this.pageKey=r(this.element),this.observed=new WeakSet,this.resizeObserver=new ResizeObserver(this.schedule),this.mutationObserver=new MutationObserver(this.schedule),this.observeSize(this.element);const e=this.element.closest("bn-layout-page");e&&this.mutationObserver.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot","data-bino-annotation-target"]}),null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.schedule)}disconnectedCallback(){var t,e,n,i;null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(e=this.mutationObserver)||void 0===e||e.disconnect(),null===(n=document.fonts)||void 0===n||n.removeEventListener("loadingdone",this.schedule),this.run++,(null===(i=this.stores)||void 0===i?void 0:i.annotationsUnplaced.state[this.pageKey])&&this.stores.annotationsUnplaced.set(this.pageKey,void 0)}componentWillLoad(){this.parseItems()}componentDidLoad(){this.schedule()}onItemsChange(){this.parseItems(),this.schedule()}parseItems(){const t=a(this.items);t?this.errors.remove("ERR_items"):this.errors.addOrReplace({id:"ERR_items",type:"error",message:"items: not a JSON array of objects."}),this.parsedItems=null!=t?t:[]}async place(){var t;const e=++this.run;if(!this.element.isConnected||!this.svg)return;const n=this.element.closest("bn-layout-page"),i=new Map,o=new Map;null==n||n.querySelectorAll("[data-bino-annotation-target]").forEach((t=>{const e=Array.from(t.querySelectorAll("*")).find((t=>t.localName.startsWith("bn-")&&!x.has(t.localName))),n=null!=e?e:t;i.set(t.getAttribute("data-bino-annotation-target"),n),o.set(n,t)})),null==n||n.querySelectorAll("[slot]").forEach((t=>this.observeSize(t)));const s=new Set(this.parsedItems.flatMap((t=>[t.target,t.to]))),r=[...i].filter((([t])=>s.has(t))).map((([,t])=>t));if(await Promise.all(r.map((t=>{var e;return null===(e=t.componentOnReady)||void 0===e?void 0:e.call(t)}))),e!==this.run)return;r.forEach((t=>this.observe(t)));const a=new Map;if(await Promise.all(r.map((async t=>{var e;a.set(t,await(null===(e=t.getLayoutState)||void 0===e?void 0:e.call(t,{detail:"full"}).catch((()=>{}))))}))),e!==this.run)return;const l=(t,e)=>{var n;const s=null!=t?i.get(t):void 0;if(!s)return{problem:`no target "${t}" on this page`};const r=s.getBoundingClientRect();if(function(t){return!t||g.every((e=>null==t[e]))&&null==t.part}(e)){const e={x:r.left,y:r.top,width:r.width,height:r.height};return function(t,e,n){if(0===t.width||0===t.height||!M(t,n))return!0;for(let n=e;n&&"bn-layout-page"!==n.localName;n=n.parentElement)if(!M(t,n))return!0;return!1}(e,o.get(s),this.element)?{problem:`"${t}" cannot be seen`}:{box:e,whole:!0}}const l=a.get(s),h=l?function(t,e){var n;const i=t.table&&null==e.scenario?t.table.rows:null!==(n=t.elements)&&void 0!==n?n:[],o=null!=t.table&&null==e.subCategory;return i.filter((t=>function(t,e){var n;return!(!t||t.part!==(null!==(n=e.part)&&void 0!==n?n:"element"))&&g.every((n=>null==e[n]||e[n]+""===t[n]))}(t.point,e)&&!(o&&null!=t.point.subCategory))).map((({rect:t,content:e,contentSign:n})=>({rect:t,content:e,contentSign:n})))}(l,e):[];if(1!==h.length)return{problem:`${h.length} elements match the point ${JSON.stringify(e)} in "${t}"`};const c=({component:{x:t,y:e,width:n,height:i}})=>({x:r.left+t,y:r.top+e,width:n,height:i}),u=c(h[0].rect);if(function(t,e){for(let n=e;n&&"bn-layout-page"!==n.localName;n=n.parentElement)if(!w(t,n))return!0;return!1}(u,o.get(s))||!w(u,this.element))return{problem:`the point ${JSON.stringify(e)} in "${t}" is cut off`};const d=h[0].content;if(!l.table)return{box:u,whole:!1};const b=(null!==(n=l.elements)&&void 0!==n?n:[]).flatMap((t=>"cell"===t.kind&&t.content?[{box:c(t.content),sign:t.contentSign}]:[]));return{box:u,whole:!1,text:d&&{box:c(d),sign:h[0].contentSign},obstacles:b}},h=this.toLocalSpace(),c=({box:t,sign:e=0})=>{const n=h(t);return Object.assign(Object.assign({},n),{x:n.x-e,width:n.width+e})},u=parseFloat(getComputedStyle(this.svg).fontSize)||13.3333,d={width:this.element.clientWidth,height:this.element.clientHeight},b=[],f=[];for(const e of this.parsedItems){const n=l(e.target,e.point),i="arrow"===e.mark?l(e.to,e.toPoint):void 0,o="problem"in n?n:i&&"problem"in i?i:void 0;if(o){f.push({item:e,problem:o.problem});continue}const s=n,r=i,a=p(e,h(s.box),r&&h(r.box),u,{whole:s.whole,area:d,text:s.text&&c(s.text),obstacles:null===(t=s.obstacles)||void 0===t?void 0:t.map(c)});a?b.push(a):f.push({item:e,problem:"an arrow needs two ends at different places"})}this.marks=b,this.storeUnplaced(f.flatMap((({item:t})=>null!=t.label?[t.label]:[]))),f.length>0&&this.reportWhenQuiet(e,f)}async reportWhenQuiet(t,e){let n=0;for(let e=0;e<50&&n<2;e++){if(await new Promise((t=>window.setTimeout(t,200))),t!==this.run)return;n=0===c.componentRegisterStatus().running?n+1:0}this.report(e)}report(t){var e,n;for(const{item:i,problem:o}of t){const t=`bn-annotation-layer: ${null!==(e=i.mark)&&void 0!==e?e:"marker"} ${null!==(n=i.label)&&void 0!==n?n:"without a number"} is not drawn: ${o}.`;this.reported.has(t)||(this.reported.add(t),console.warn(t))}}toLocalSpace(){var t;const e=null===(t=this.svg.getScreenCTM())||void 0===t?void 0:t.inverse();return t=>{if(!e)return t;const n=[[t.x,t.y],[t.x+t.width,t.y+t.height]].map((([t,n])=>new DOMPoint(t,n).matrixTransform(e)));return{x:Math.min(n[0].x,n[1].x),y:Math.min(n[0].y,n[1].y),width:Math.abs(n[1].x-n[0].x),height:Math.abs(n[1].y-n[0].y)}}}storeUnplaced(t){var e,n;const i=null===(e=this.stores)||void 0===e?void 0:e.annotationsUnplaced,o=null!==(n=null==i?void 0:i.state[this.pageKey])&&void 0!==n?n:[];i&&JSON.stringify(o)!==JSON.stringify(t)&&i.set(this.pageKey,t)}observe(t){this.observeSize(t);const e=t=>{var n;t&&(this.observed.has(t)||(this.observed.add(t),null===(n=this.mutationObserver)||void 0===n||n.observe(t,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["x","y","width","height","transform","style","class"]})),t.querySelectorAll("*").forEach((t=>e(t.shadowRoot))))};e(t.shadowRoot)}observeSize(t){var e;this.observed.has(t)||(this.observed.add(t),null===(e=this.resizeObserver)||void 0===e||e.observe(t))}renderBadge(t,e){return t?i("g",null,i("circle",{cx:t.cx,cy:t.cy,r:t.r,style:{fill:e}}),null!=t.label?i("text",{class:"badge-text",x:t.cx,y:t.cy,style:{fontSize:1.1*t.r+"px"}},t.label):null):null}renderMark(t){var e,n;const o=l(t.color,this.componentStyle((t=>t["bn-annotation"])));return"marker"===t.kind?i("g",{class:"mark marker","data-label":t.badge.label},this.renderBadge(t.badge,o)):"frame"===t.kind?i("g",{class:"mark frame","data-label":null===(e=t.badge)||void 0===e?void 0:e.label},i("rect",{x:t.x,y:t.y,width:t.width,height:t.height,rx:t.rx,ry:t.ry,style:{fill:"none",stroke:o,strokeWidth:"1.5"}}),this.renderBadge(t.badge,o)):i("g",{class:"mark arrow","data-label":null===(n=t.badge)||void 0===n?void 0:n.label},i("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,style:{stroke:o,strokeWidth:"1.5"}}),i("polygon",{points:t.head,style:{fill:o}}),this.renderBadge(t.badge,o))}render(){return i(o,{key:"05ca564aeeaf190a45cd42020b307891990e04fe"},i("svg",{key:"995c55b16803107766bf2c394d8d799c0de5765d",ref:t=>this.svg=t},this.marks.map((t=>this.renderMark(t)))))}get element(){return this}static get watchers(){return{items:[{onItemsChange:0}]}}static get style(){return':host{position:absolute;inset:0;z-index:1;display:block;pointer-events:none;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px)}svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}.badge-text{fill:#ffffff;font-weight:bold;text-anchor:middle;dominant-baseline:central}'}},[1,"bn-annotation-layer",{items:[1],selectedStyle:[513,"selected-style"],marks:[32]},void 0,{items:[{onItemsChange:0}]}]),S=k,$=function(){"undefined"!=typeof customElements&&["bn-annotation-layer"].forEach((t=>{"bn-annotation-layer"===t&&(customElements.get(e(t))||customElements.define(e(t),k))}))};export{S as BnAnnotationLayer,$ as defineCustomElement}
@@ -1 +1 @@
1
- import{p as t,H as s,f as e,h as i,a as n,t as o}from"./p-D6YGOYV1.js";import{g as a}from"./p-BcOud3dQ.js";import{a as l,p as r,b as c}from"./p-D6cWoDk1.js";import{s as d}from"./p-CyUmrWfW.js";import{w as m}from"./p-DEHnizot.js";import{w as f}from"./p-C6XrNN2m.js";import{w as h}from"./p-CGI6XIaK.js";const p=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.pageKey="",m(this),this.errors=h(this),this.componentStyle=f(this)}connectedCallback(){this.stores=a(this.element),this.pageKey=l(this.element),this.unsubscribe=this.stores.annotationsUnplaced.on("set",(t=>{t===this.pageKey&&e(this.element)})),e(this.element)}disconnectedCallback(){var t;null===(t=this.unsubscribe)||void 0===t||t.call(this)}render(){var t,s;const e=r(this.items);e?this.errors.remove("ERR_items"):this.errors.addOrReplace({id:"ERR_items",type:"error",message:"items: not a JSON array of objects."});const o=c(void 0,this.componentStyle((t=>t["bn-annotation"]))),a=null!==(s=null===(t=this.stores)||void 0===t?void 0:t.annotationsUnplaced.state[this.pageKey])&&void 0!==s?s:[];return i(n,{key:"69a1cb7ec4623dd722328638b93fa2ac05775dcf"},i("ol",{key:"cc7925db54a9015cd774242487967e25d0eb1dc0"},(null!=e?e:[]).map((t=>i("li",null,null==t.label||a.includes(t.label)?null!=t.label?i("div",{class:"badge-space"}):null:i("div",{class:"badge",style:{background:o}},i("span",null,t.label)),i("div",{class:"text"},t.title?i("span",{class:"title"},t.title," "):null,t.html?i("span",{innerHTML:d(t.html)}):null))))))}get element(){return this}static get style(){return':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}ol{margin:0;padding:0;list-style:none}li{display:flex;gap:0.5em;margin-bottom:0.6em;align-items:flex-start}.badge-space{flex:none;width:1.5em;height:1.5em}.badge{flex:none;display:flex;align-items:center;justify-content:center;width:1.5em;height:1.5em;border-radius:50%;color:#ffffff;font-weight:bold;line-height:1}.badge span{font-size:0.825em}.title{font-weight:bold}'}},[1,"bn-annotation-list",{items:[1],selectedStyle:[513,"selected-style"]}]),b=p,u=function(){"undefined"!=typeof customElements&&["bn-annotation-list"].forEach((t=>{"bn-annotation-list"===t&&(customElements.get(o(t))||customElements.define(o(t),p))}))};export{b as BnAnnotationList,u as defineCustomElement}
1
+ import{p as t,H as s,f as e,h as i,a as n,t as l}from"./p-D6YGOYV1.js";import{g as o}from"./p-DDvWTgk1.js";import{a,p as r,b as c}from"./p-M2k_I8lv.js";import{s as d}from"./p-CyUmrWfW.js";import{w as m}from"./p-Dq9dG0Kr.js";import{w as f}from"./p-DjPWZfry.js";import{w as h}from"./p-4vVbchX2.js";const p=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.pageKey="",m(this),this.errors=h(this),this.componentStyle=f(this)}connectedCallback(){this.stores=o(this.element),this.pageKey=a(this.element),this.unsubscribe=this.stores.annotationsUnplaced.on("set",(t=>{t===this.pageKey&&e(this.element)})),e(this.element)}disconnectedCallback(){var t;null===(t=this.unsubscribe)||void 0===t||t.call(this)}render(){var t,s;const e=r(this.items);e?this.errors.remove("ERR_items"):this.errors.addOrReplace({id:"ERR_items",type:"error",message:"items: not a JSON array of objects."});const l=c(void 0,this.componentStyle((t=>t["bn-annotation"]))),o=null!==(s=null===(t=this.stores)||void 0===t?void 0:t.annotationsUnplaced.state[this.pageKey])&&void 0!==s?s:[];return i(n,{key:"69a1cb7ec4623dd722328638b93fa2ac05775dcf"},i("ol",{key:"cc7925db54a9015cd774242487967e25d0eb1dc0"},(null!=e?e:[]).map((t=>i("li",null,null==t.label||o.includes(t.label)?null!=t.label?i("div",{class:"badge-space"}):null:i("div",{class:"badge",style:{background:l}},i("span",null,t.label)),i("div",{class:"text"},t.title?i("span",{class:"title"},t.title," "):null,t.html?i("span",{innerHTML:d(t.html)}):null))))))}get element(){return this}static get style(){return':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}ol{margin:0;padding:0;list-style:none}li{display:flex;gap:0.5em;margin-bottom:0.6em;align-items:flex-start}.badge-space{flex:none;width:1.5em;height:1.5em}.badge{flex:none;display:flex;align-items:center;justify-content:center;width:1.5em;height:1.5em;border-radius:50%;color:#ffffff;font-weight:bold;line-height:1}.badge span{font-size:0.825em}.title{font-weight:bold}'}},[1,"bn-annotation-list",{items:[1],selectedStyle:[513,"selected-style"]}]),b=p,u=function(){"undefined"!=typeof customElements&&["bn-annotation-list"].forEach((t=>{"bn-annotation-list"===t&&(customElements.get(l(t))||customElements.define(l(t),p))}))};export{b as BnAnnotationList,u as defineCustomElement}
@@ -1 +1 @@
1
- import{p as s,H as t,h as e,a as r,t as o}from"./p-D6YGOYV1.js";import{w as i}from"./p-DEHnizot.js";import{g as n}from"./p-BcOud3dQ.js";import{w as a}from"./p-CurWSJkH.js";import{w as m}from"./p-CGI6XIaK.js";const h=s(class extends t{constructor(s){super(),!1!==s&&this.__registerHost(),this.__attachShadow(),i(this),this.errors=m(this),a(this,(s=>{this.stores||(this.stores=n(this.element));try{const t=s.replace(/\s/g,"");this.stores.assets.set(this.name,t)}catch(t){console.error("Error parsing asset",t,s),this.stores.assets.set(this.name,void 0)}}))}render(){return e(r,{key:"9df81e3697e02833b8cb1fad7ea06a5f446852be"})}get element(){return this}static get style(){return":host{display:none}"}},[1,"bn-asset",{name:[1]}]),p=h,c=function(){"undefined"!=typeof customElements&&["bn-asset"].forEach((s=>{"bn-asset"===s&&(customElements.get(o(s))||customElements.define(o(s),h))}))};export{p as BnAsset,c as defineCustomElement}
1
+ import{p as s,H as t,h as e,a as r,t as o}from"./p-D6YGOYV1.js";import{w as i}from"./p-Dq9dG0Kr.js";import{g as n}from"./p-DDvWTgk1.js";import{w as a}from"./p-Do4oPrkE.js";import{w as m}from"./p-4vVbchX2.js";const h=s(class extends t{constructor(s){super(),!1!==s&&this.__registerHost(),this.__attachShadow(),i(this),this.errors=m(this),a(this,(s=>{this.stores||(this.stores=n(this.element));try{const t=s.replace(/\s/g,"");this.stores.assets.set(this.name,t)}catch(t){console.error("Error parsing asset",t,s),this.stores.assets.set(this.name,void 0)}}))}render(){return e(r,{key:"9df81e3697e02833b8cb1fad7ea06a5f446852be"})}get element(){return this}static get style(){return":host{display:none}"}},[1,"bn-asset",{name:[1]}]),p=h,c=function(){"undefined"!=typeof customElements&&["bn-asset"].forEach((s=>{"bn-asset"===s&&(customElements.get(o(s))||customElements.define(o(s),h))}))};export{p as BnAsset,c as defineCustomElement}
@@ -1 +1 @@
1
- import{B as o,d as s}from"./p-Ku08TQL1.js";const p=o,r=s;export{p as BnBody,r as defineCustomElement}
1
+ import{B as o,d as p}from"./p-Chuj-LpI.js";const s=o,r=p;export{s as BnBody,r as defineCustomElement}
@@ -1 +1 @@
1
- import{C as o,d as s}from"./p-8a2-IS-y.js";const a=o,p=s;export{a as BnCard,p as defineCustomElement}
1
+ import{C as o,d as r}from"./p-2eicD9rF.js";const s=o,p=r;export{s as BnCard,p as defineCustomElement}
@@ -1 +1 @@
1
- import{B as o,d as s}from"./p-CPC9Vkmg.js";const m=o,p=s;export{m as BnChartBubbleRenderer,p as defineCustomElement}
1
+ import{B as o,d as s}from"./p-CQVAHG6w.js";const p=o,r=s;export{p as BnChartBubbleRenderer,r as defineCustomElement}
@@ -1 +1 @@
1
- import{p as t,H as e,w as i,f as s,h as a,a as r,t as n}from"./p-D6YGOYV1.js";import{h as l,a as o}from"./p-BcOud3dQ.js";import{o as h}from"./p-DSkyHSIL.js";import{c}from"./p-GrpYAVHb.js";import{a as d}from"./p-t4xPltK2.js";import{g as u}from"./p-DD1zlev_.js";import{c as p}from"./p-D2Epww9R.js";import{o as v}from"./p-B6kka9sT.js";import{p as m}from"./p-Xb6Ilq8u.js";import{i as f,h as b,j as g}from"./p-CYv_8LrR.js";import{w as y}from"./p-DEHnizot.js";import{w as x}from"./p-C6XrNN2m.js";import{w}from"./p-BVtD8O36.js";import{w as _}from"./p-CGI6XIaK.js";import{w as S}from"./p-BWRE5w0i.js";import{w as L}from"./p-D7X69xMg.js";import{w as j}from"./p-B3F_c9GB.js";import{w as R}from"./p-DLLljAll.js";import{r as E,s as $}from"./p-CLkpoHdg.js";import{t as z,a as A,b as N,c as k,d as C,e as W,p as O}from"./p-Dn3DJxQQ.js";import{s as D}from"./p-DakXa7Dp.js";import{d as F}from"./p-CPC9Vkmg.js";const B={rowGroup:0,category:1,subCategory:2},G=["ac","pp","fc","pl"],M=t(class extends e{validateFilter(t){const e="ERR_filter";l(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateX(t){this.validateMeasureSpec("x",t,!0,(t=>z(t)))}validateY(t){this.validateMeasureSpec("y",t,!0,(t=>z(t)))}validateSize(t){this.validateMeasureSpec("size",t,!0,(t=>A(t))),this.validateSizeScaling()}validateShare(t){this.validateMeasureSpec("share",t,!1,(t=>N(t)))}validateCompareWith(t){const e="WARN_compareWith";f(t)||G.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`compare-with: invalid value '${t}' - expected ${G.join("/")}; ignored.`})}validateLevel(t){const e="WARN_level",i=["auto","category","subcategory"];f(t)||i.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`level: invalid value '${t}' - expected ${i.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const e="WARN_seriesLevel",i=["auto","rowgroup","category","none"];f(t)||i.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`series-level: invalid value '${t}' - expected ${i.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,(t=>k(t)))}validateLabels(t){this.validateObjectSpec("labels",t,(t=>C(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,(t=>W(t)))}validateAspect(t){const e="WARN_aspect";f(t)||null!==this.parseAspect(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`aspect: invalid value '${t}' - expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const e="WARN_limit";b(t)&&Number(t)>=0?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateScale(t){const e="WARN_scale";if(f(t))return void this.errors.remove(e);const{mode:i,factor:s}=m(t);"factor"===i&&(void 0===s||s<=0)?this.errors.addOrReplace({id:e,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(e)}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.pixelPerUnitGroupMap=new Map,this.chartTitle="",this.filter="",this.share="",this.compareWith="",this.level="auto",this.seriesLevel="auto",this.facet="",this.labels="",this.legend="",this.aspect="16:9",this.limit=0,this._autoScaleGuard=!1,this._lastObservedWidth=0,this.translateForInner=(t,e)=>this.t(t,e),R(this),y(this),w(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,e)=>{this.datasetMeta=e})),this.errors=_(this),L(this),this.componentStyle=x(this),this.ruleSetConfig=S(this),this.t=j(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateX(this.x),this.validateY(this.y),this.validateSize(this.size),this.validateShare(this.share),this.validateCompareWith(this.compareWith),this.validateLevel(this.level),this.validateSeriesLevel(this.seriesLevel),this.validateFacet(this.facet),this.validateLabels(this.labels),this.validateLegend(this.legend),this.validateAspect(this.aspect),this.validateLimit(this.limit),this.validateScale(this.scale)}componentDidRender(){D(this.element,"bn-chart-bubble-renderer");const{mode:t}=m(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const e=this.element,{width:s}=u(e);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const a=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),r=e.scrollWidth,n=this.appliedScaleFactor;if(!Number.isFinite(r)||r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const l=Math.max(.3,n*(s-1)/r);Math.abs(l-n)<.01||(e.style.setProperty("--bn-font-size",a*l+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+l.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,i((()=>{this.appliedScaleFactor=l}))),this.checkOverflow()}checkOverflow(){p(this.element,"bn-chart-bubble-renderer",this.errors)}componentDidLoad(){this.layoutObserver=v(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2?(this._lastObservedWidth=t,s(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);this._lastObservedWidth=t,s(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"all",values:!0,max:12}}setBlockingError(t,e){null===e?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:e}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateSizeScaling(){var t;const e=null===(t=this.prepareSize())||void 0===t?void 0:t.group;this.setBlockingError("ERR_xy_scale_group",void 0===e||this.pixelPerUnitGroupMap.has(e)?null:this.t(".bubble-scale-group-unknown",{group:e}))}validateMeasureSpec(t,e,i,s){var a;const r="ERR_xy_json_"+t,n="ERR_xy_measure_"+t,l="WARN_xy_fields_"+t,{data:o,parseError:h}=O(e,"measure");if(h)return this.setBlockingError(r,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(n,null),void this.errors.remove(l);if(this.setBlockingError(r,null),null===o)return this.setBlockingError(n,i?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(l);const c=null!==(a=o.measure)&&void 0!==a?a:"";g(c)?this.setBlockingError(n,null):this.setBlockingError(n,this.t(".xy-measure-invalid",{prop:t,measure:c})),this.reportSpecIssues(l,t,s(o))}validateObjectSpec(t,e,i){const s="ERR_xy_json_"+t,a="WARN_xy_fields_"+t,{data:r,parseError:n}=O(e,null);if(n)return this.setBlockingError(s,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(a);this.setBlockingError(s,null),null!==r?this.reportSpecIssues(a,t,i(r)):this.errors.remove(a)}reportSpecIssues(t,e,i){const s=[];null!==i&&i.invalidFields.length>0&&s.push("invalid: "+i.invalidFields.join(", ")),null!==i&&i.unknownKeys.length>0&&s.push("unknown: "+i.unknownKeys.join(", ")),s.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${s.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,e){const{data:i,parseError:s}=O(e,"measure");if(s||null===i)return null;const{config:a}=z(i);return null!==a&&g(a.measure)?(void 0!==a.min&&void 0!==a.max&&a.min>=a.max?(this.errors.addOrReplace({id:"WARN_xy_domain_"+t,type:"warning",message:t+": min must be smaller than max; the override is ignored."}),a.min=void 0,a.max=void 0):this.errors.remove("WARN_xy_domain_"+t),a):null}prepareSize(){const{data:t,parseError:e}=O(this.size,"measure");if(e||null===t)return null;const{config:i}=A(t);return null!==i&&g(i.measure)?i:null}prepareShare(){const{data:t,parseError:e}=O(this.share,"measure");if(e||null===t)return null;const{config:i}=N(t);return null!==i&&g(i.measure)?i:null}prepareCompareFamily(){var t;const e=null===(t=this.compareWith)||void 0===t?void 0:t.trim().toLowerCase();return G.includes(e)?e:null}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:i}=O(this.labels,null);return i||null===e?{points:t.points,values:t.values,max:t.max}:C(e,t).config}prepareLegend(){const{data:t,parseError:e}=O(this.legend,null);return e||null===t?{show:!0,position:"right"}:W(t).config}prepareFacet(){const{data:t,parseError:e}=O(this.facet,null);return e||null===t?null:k(t).config}preparePointLevel(){var t,e;const i=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===i)return"category";if("subcategory"===i)return"subCategory";const s=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;return"rowGroup"===s||"category"===s||"subCategory"===s?s:"category"}prepareSeriesLevel(t){var e;const i=null===(e=this.seriesLevel)||void 0===e?void 0:e.trim().toLowerCase();return"none"===i?null:"rowgroup"===i?"rowGroup":"category"===i||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,e){const i=new Set;let s=!1;for(const e of t){if(void 0===e)continue;const t=E(e);null!==t&&("scenario"===t.kind?i.add($(t.slot)):s=!0)}this.setBlockingError("ERR_xy_family",i.size>1?this.t(".xy-family-mixed",{families:[...i].join(", ")}):null);const a=this.prepareCompareFamily();this.setBlockingError("ERR_xy_compare_variance",null!==a&&s?this.t(".xy-compare-variance"):null),this.setBlockingError("ERR_xy_compare_family",null!==a&&1===i.size&&i.has(a)?`compare-with: '${a}' is already the primary scenario family.`:null);const r=this.preparePointLevel(),n=this.prepareSeriesLevel(r),l=null!==e?"rowgroup"===e.level?"rowGroup":"category":null;let o=null;if(null!==n&&B[n]>=B[r]&&(o=`series '${n}' vs point '${r}'`),null!==l){const t=null!=n?n:r;B[l]>=B[t]&&(o=`facet '${l}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==o?this.t(".xy-level-order",{detail:o}):null)}parseAspect(t){const e=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===e)return null;const i=Number(e[1]),s=Number(e[2]);return i<=0||s<=0?null:i/s}prepareAspect(){var t;return null!==(t=this.parseAspect(this.aspect))&&void 0!==t?t:16/9}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}prepareSizeAreaPerUnit(){var t;const e=null===(t=this.prepareSize())||void 0===t?void 0:t.group;if(void 0===e||!this.pixelPerUnitGroupMap.has(e))return 0;const i=this.pixelPerUnitGroupMap.get(e);if(!(i>0))return 0;const s=this.getEffectiveFontPx();return s*s/i}i18nLocalKeys(){return["no-data","axis.in","legend.title","legend.size","legend.compare"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),e=new Map(o.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{const i=e.global.fontSizePx*t;return{scaleFactors:e["bn-chart-bubble"].scaleFactors,fontStyles:{font:`${i}px ${e.global.fontFamily}`,size:i,color:e.global.fontColor,background:e.global.fontBackgroundColor,leading:1.8},axisStyles:e["bn-chart-bubble"].axisStyles,seriesColors:e["bn-chart-bubble"].seriesColors,padding:e["bn-chart-bubble"].padding}}))}async getBaseline(){return d(this.element,"bn-chart-bubble-renderer")}async getLayoutState(t){var e;const i=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",s=h(this.element),a=this.getEffectiveScaleFactor(),r=Number.isFinite(a)&&a>0?a:1,n=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*r;return c(this.element,"bn-chart-bubble-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:r},s,i)}getEffectiveScaleFactor(){const{mode:t,factor:e}=m(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var i,s,a,r;const n=(null===(i=e.global)||void 0===i?void 0:i.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=e.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=e.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=e.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const e of["ac","pp","fc","pl"])for(const i of[1,2,3,4])t[`${e}${i}`]={type:"number",isOptional:!0,description:""};const e={x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y),size:this.prepareSize(),share:this.prepareShare()};for(const[i,s]of Object.entries(e)){if(null===s)continue;const e=E(s.measure);null!==e&&("scenario"===e.kind?t[e.slot].description=`${i}: ${void 0!==s.label?s.label:s.measure}`:(t[e.measure.base].description=`${i}: ${s.measure} (base)`,t[e.measure.delta].description=`${i}: ${s.measure} (delta)`))}const i=this.prepareCompareFamily();if(null!==i)for(const[s,a]of Object.entries(e)){if(null===a||"share"===s)continue;const e=E(a.measure);if(null!==e&&"scenario"===e.kind){const a=i+e.slot.replace(/^[a-z]+/,"");""===t[a].description&&(t[a].description=s+": compareWith")}}return{IBubbleChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareAxis("x",this.x),e=this.prepareAxis("y",this.y),i=this.prepareSize(),s=this.prepareShare(),r=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==e?void 0:e.measure,null==i?void 0:i.measure,null==s?void 0:s.measure],r),this.validateSizeScaling(),this.hasBlockingErrors()||null===t||null===e||null===i)return null;const n=this.preparePointLevel(),l=this.prepareI18n(),o=this.prepareStyle(),h=u(this.element).width;return a("bn-chart-bubble-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:e,size:i,share:s,compareFamily:this.prepareCompareFamily(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:r,pointLevel:n,seriesLevel:this.prepareSeriesLevel(n),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,sizeAreaPerUnit:this.prepareSizeAreaPerUnit(),styles:o,i18n:l,containerWidth:h,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return a(r,{key:"2b15b5b4fc32db48b951e82ecc87f25b0afcc9f8",style:this.getFontStyles()},a("div",{key:"210d8622e1785b8c882f9c9a2fa2072af0e857b6",class:"container"},this.chartTemplate()))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],size:[{validateSize:0}],share:[{validateShare:0}],compareWith:[{validateCompareWith:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column}'}},[1,"bn-chart-bubble",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],x:[1],y:[1],size:[1],share:[1],compareWith:[1,"compare-with"],level:[1],seriesLevel:[1,"series-level"],facet:[1],labels:[1],legend:[1],aspect:[1],limit:[2],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],size:[{validateSize:0}],share:[{validateShare:0}],compareWith:[{validateCompareWith:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}]),I=M,P=function(){"undefined"!=typeof customElements&&["bn-chart-bubble","bn-chart-bubble-renderer"].forEach((t=>{switch(t){case"bn-chart-bubble":customElements.get(n(t))||customElements.define(n(t),M);break;case"bn-chart-bubble-renderer":customElements.get(n(t))||F()}}))};export{I as BnChartBubble,P as defineCustomElement}
1
+ import{p as t,H as e,w as i,f as s,h as a,a as r,t as n}from"./p-D6YGOYV1.js";import{h as l,a as o}from"./p-DDvWTgk1.js";import{o as h}from"./p-DaOm9YwQ.js";import{c}from"./p-sar8m7th.js";import{a as d}from"./p-t4xPltK2.js";import{g as u}from"./p-DD1zlev_.js";import{c as p}from"./p-D2Epww9R.js";import{o as v}from"./p-B6kka9sT.js";import{p as m}from"./p-Xb6Ilq8u.js";import{i as f,h as b,j as y}from"./p-DT04Cka0.js";import{w as g}from"./p-Dq9dG0Kr.js";import{w as x}from"./p-DjPWZfry.js";import{w}from"./p-DJUffGeB.js";import{w as _}from"./p-4vVbchX2.js";import{w as S}from"./p-OquycEMA.js";import{w as j}from"./p-DQl2K2Xl.js";import{w as R}from"./p-BU_53KVT.js";import{w as L}from"./p-Bo_R7f_T.js";import{r as $,s as E}from"./p-BXXjh6We.js";import{t as z,a as A,b as W,c as N,d as k,e as D,p as O}from"./p-9mUU4itF.js";import{s as F}from"./p-DakXa7Dp.js";import{d as C}from"./p-CQVAHG6w.js";const G={rowGroup:0,category:1,subCategory:2},M=["ac","pp","fc","pl"],T=t(class extends e{validateFilter(t){const e="ERR_filter";l(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateX(t){this.validateMeasureSpec("x",t,!0,(t=>z(t)))}validateY(t){this.validateMeasureSpec("y",t,!0,(t=>z(t)))}validateSize(t){this.validateMeasureSpec("size",t,!0,(t=>A(t))),this.validateSizeScaling()}validateShare(t){this.validateMeasureSpec("share",t,!1,(t=>W(t)))}validateCompareWith(t){const e="WARN_compareWith";f(t)||M.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`compare-with: invalid value '${t}' - expected ${M.join("/")}; ignored.`})}validateLevel(t){const e="WARN_level",i=["auto","category","subcategory"];f(t)||i.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`level: invalid value '${t}' - expected ${i.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const e="WARN_seriesLevel",i=["auto","rowgroup","category","none"];f(t)||i.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`series-level: invalid value '${t}' - expected ${i.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,(t=>N(t)))}validateLabels(t){this.validateObjectSpec("labels",t,(t=>k(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,(t=>D(t)))}validateAspect(t){const e="WARN_aspect";f(t)||null!==this.parseAspect(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`aspect: invalid value '${t}' - expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const e="WARN_limit";b(t)&&Number(t)>=0?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateScale(t){const e="WARN_scale";if(f(t))return void this.errors.remove(e);const{mode:i,factor:s}=m(t);"factor"===i&&(void 0===s||s<=0)?this.errors.addOrReplace({id:e,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(e)}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.pixelPerUnitGroupMap=new Map,this.chartTitle="",this.filter="",this.share="",this.compareWith="",this.level="auto",this.seriesLevel="auto",this.facet="",this.labels="",this.legend="",this.aspect="16:9",this.limit=0,this._autoScaleGuard=!1,this._lastObservedWidth=0,this.translateForInner=(t,e)=>this.t(t,e),L(this),g(this),w(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,e)=>{this.datasetMeta=e})),this.errors=_(this),j(this),this.componentStyle=x(this),this.ruleSetConfig=S(this),this.t=R(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateX(this.x),this.validateY(this.y),this.validateSize(this.size),this.validateShare(this.share),this.validateCompareWith(this.compareWith),this.validateLevel(this.level),this.validateSeriesLevel(this.seriesLevel),this.validateFacet(this.facet),this.validateLabels(this.labels),this.validateLegend(this.legend),this.validateAspect(this.aspect),this.validateLimit(this.limit),this.validateScale(this.scale)}componentDidRender(){F(this.element,"bn-chart-bubble-renderer");const{mode:t}=m(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const e=this.element,{width:s}=u(e);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const a=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),r=e.scrollWidth,n=this.appliedScaleFactor;if(!Number.isFinite(r)||r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const l=Math.max(.3,n*(s-1)/r);Math.abs(l-n)<.01||(e.style.setProperty("--bn-font-size",a*l+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+l.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,i((()=>{this.appliedScaleFactor=l}))),this.checkOverflow()}checkOverflow(){p(this.element,"bn-chart-bubble-renderer",this.errors)}componentDidLoad(){this.layoutObserver=v(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2?(this._lastObservedWidth=t,s(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);this._lastObservedWidth=t,s(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"all",values:!0,max:12}}setBlockingError(t,e){null===e?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:e}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateSizeScaling(){var t;const e=null===(t=this.prepareSize())||void 0===t?void 0:t.group;this.setBlockingError("ERR_xy_scale_group",void 0===e||this.pixelPerUnitGroupMap.has(e)?null:this.t(".bubble-scale-group-unknown",{group:e}))}validateMeasureSpec(t,e,i,s){var a;const r="ERR_xy_json_"+t,n="ERR_xy_measure_"+t,l="WARN_xy_fields_"+t,{data:o,parseError:h}=O(e,"measure");if(h)return this.setBlockingError(r,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(n,null),void this.errors.remove(l);if(this.setBlockingError(r,null),null===o)return this.setBlockingError(n,i?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(l);const c=null!==(a=o.measure)&&void 0!==a?a:"";y(c)?this.setBlockingError(n,null):this.setBlockingError(n,this.t(".xy-measure-invalid",{prop:t,measure:c})),this.reportSpecIssues(l,t,s(o))}validateObjectSpec(t,e,i){const s="ERR_xy_json_"+t,a="WARN_xy_fields_"+t,{data:r,parseError:n}=O(e,null);if(n)return this.setBlockingError(s,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(a);this.setBlockingError(s,null),null!==r?this.reportSpecIssues(a,t,i(r)):this.errors.remove(a)}reportSpecIssues(t,e,i){const s=[];null!==i&&i.invalidFields.length>0&&s.push("invalid: "+i.invalidFields.join(", ")),null!==i&&i.unknownKeys.length>0&&s.push("unknown: "+i.unknownKeys.join(", ")),s.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${s.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,e){const{data:i,parseError:s}=O(e,"measure");if(s||null===i)return null;const{config:a}=z(i);return null!==a&&y(a.measure)?(void 0!==a.min&&void 0!==a.max&&a.min>=a.max?(this.errors.addOrReplace({id:"WARN_xy_domain_"+t,type:"warning",message:t+": min must be smaller than max; the override is ignored."}),a.min=void 0,a.max=void 0):this.errors.remove("WARN_xy_domain_"+t),a):null}prepareSize(){const{data:t,parseError:e}=O(this.size,"measure");if(e||null===t)return null;const{config:i}=A(t);return null!==i&&y(i.measure)?i:null}prepareShare(){const{data:t,parseError:e}=O(this.share,"measure");if(e||null===t)return null;const{config:i}=W(t);return null!==i&&y(i.measure)?i:null}prepareCompareFamily(){var t;const e=null===(t=this.compareWith)||void 0===t?void 0:t.trim().toLowerCase();return M.includes(e)?e:null}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:i}=O(this.labels,null);return i||null===e?{points:t.points,values:t.values,max:t.max}:k(e,t).config}prepareLegend(){const{data:t,parseError:e}=O(this.legend,null);return e||null===t?{show:!0,position:"right"}:D(t).config}prepareFacet(){const{data:t,parseError:e}=O(this.facet,null);return e||null===t?null:N(t).config}preparePointLevel(){var t,e;const i=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===i)return"category";if("subcategory"===i)return"subCategory";const s=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;return"rowGroup"===s||"category"===s||"subCategory"===s?s:"category"}prepareSeriesLevel(t){var e;const i=null===(e=this.seriesLevel)||void 0===e?void 0:e.trim().toLowerCase();return"none"===i?null:"rowgroup"===i?"rowGroup":"category"===i||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,e){const i=new Set;let s=!1;for(const e of t){if(void 0===e)continue;const t=$(e);null!==t&&("scenario"===t.kind?i.add(E(t.slot)):s=!0)}this.setBlockingError("ERR_xy_family",i.size>1?this.t(".xy-family-mixed",{families:[...i].join(", ")}):null);const a=this.prepareCompareFamily();this.setBlockingError("ERR_xy_compare_variance",null!==a&&s?this.t(".xy-compare-variance"):null),this.setBlockingError("ERR_xy_compare_family",null!==a&&1===i.size&&i.has(a)?`compare-with: '${a}' is already the primary scenario family.`:null);const r=this.preparePointLevel(),n=this.prepareSeriesLevel(r),l=null!==e?"rowgroup"===e.level?"rowGroup":"category":null;let o=null;if(null!==n&&G[n]>=G[r]&&(o=`series '${n}' vs point '${r}'`),null!==l){const t=null!=n?n:r;G[l]>=G[t]&&(o=`facet '${l}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==o?this.t(".xy-level-order",{detail:o}):null)}parseAspect(t){const e=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===e)return null;const i=Number(e[1]),s=Number(e[2]);return i<=0||s<=0?null:i/s}prepareAspect(){var t;return null!==(t=this.parseAspect(this.aspect))&&void 0!==t?t:16/9}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}prepareSizeAreaPerUnit(){var t;const e=null===(t=this.prepareSize())||void 0===t?void 0:t.group;if(void 0===e||!this.pixelPerUnitGroupMap.has(e))return 0;const i=this.pixelPerUnitGroupMap.get(e);if(!(i>0))return 0;const s=this.getEffectiveFontPx();return s*s/i}i18nLocalKeys(){return["no-data","axis.in","legend.title","legend.size","legend.compare"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),e=new Map(o.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{const i=e.global.fontSizePx*t;return{scaleFactors:e["bn-chart-bubble"].scaleFactors,fontStyles:{font:`${i}px ${e.global.fontFamily}`,size:i,color:e.global.fontColor,background:e.global.fontBackgroundColor,leading:1.8},axisStyles:e["bn-chart-bubble"].axisStyles,seriesColors:e["bn-chart-bubble"].seriesColors,padding:e["bn-chart-bubble"].padding}}))}async getBaseline(){return d(this.element,"bn-chart-bubble-renderer")}async getLayoutState(t){var e;const i=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",s=h(this.element),a=this.getEffectiveScaleFactor(),r=Number.isFinite(a)&&a>0?a:1,n=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*r;return c(this.element,"bn-chart-bubble-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:r},s,i)}getEffectiveScaleFactor(){const{mode:t,factor:e}=m(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var i,s,a,r;const n=(null===(i=e.global)||void 0===i?void 0:i.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=e.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=e.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=e.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const e of["ac","pp","fc","pl"])for(const i of[1,2,3,4])t[`${e}${i}`]={type:"number",isOptional:!0,description:""};const e={x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y),size:this.prepareSize(),share:this.prepareShare()};for(const[i,s]of Object.entries(e)){if(null===s)continue;const e=$(s.measure);null!==e&&("scenario"===e.kind?t[e.slot].description=`${i}: ${void 0!==s.label?s.label:s.measure}`:(t[e.measure.base].description=`${i}: ${s.measure} (base)`,t[e.measure.delta].description=`${i}: ${s.measure} (delta)`))}const i=this.prepareCompareFamily();if(null!==i)for(const[s,a]of Object.entries(e)){if(null===a||"share"===s)continue;const e=$(a.measure);if(null!==e&&"scenario"===e.kind){const a=i+e.slot.replace(/^[a-z]+/,"");""===t[a].description&&(t[a].description=s+": compareWith")}}return{IBubbleChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareAxis("x",this.x),e=this.prepareAxis("y",this.y),i=this.prepareSize(),s=this.prepareShare(),r=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==e?void 0:e.measure,null==i?void 0:i.measure,null==s?void 0:s.measure],r),this.validateSizeScaling(),this.hasBlockingErrors()||null===t||null===e||null===i)return null;const n=this.preparePointLevel(),l=this.prepareI18n(),o=this.prepareStyle(),h=u(this.element).width;return a("bn-chart-bubble-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:e,size:i,share:s,compareFamily:this.prepareCompareFamily(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:r,pointLevel:n,seriesLevel:this.prepareSeriesLevel(n),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,sizeAreaPerUnit:this.prepareSizeAreaPerUnit(),styles:o,i18n:l,containerWidth:h,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return a(r,{key:"2b15b5b4fc32db48b951e82ecc87f25b0afcc9f8",style:this.getFontStyles()},a("div",{key:"210d8622e1785b8c882f9c9a2fa2072af0e857b6",class:"container"},this.chartTemplate()))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],size:[{validateSize:0}],share:[{validateShare:0}],compareWith:[{validateCompareWith:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column}'}},[1,"bn-chart-bubble",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],x:[1],y:[1],size:[1],share:[1],compareWith:[1,"compare-with"],level:[1],seriesLevel:[1,"series-level"],facet:[1],labels:[1],legend:[1],aspect:[1],limit:[2],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],size:[{validateSize:0}],share:[{validateShare:0}],compareWith:[{validateCompareWith:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}]),B=T,U=function(){"undefined"!=typeof customElements&&["bn-chart-bubble","bn-chart-bubble-renderer"].forEach((t=>{switch(t){case"bn-chart-bubble":customElements.get(n(t))||customElements.define(n(t),T);break;case"bn-chart-bubble-renderer":customElements.get(n(t))||C()}}))};export{B as BnChartBubble,U as defineCustomElement}
@@ -1 +1 @@
1
- import{B as o,d as r}from"./p-4BanAktr.js";const s=o,t=r;export{s as BnChartBulletRenderer,t as defineCustomElement}
1
+ import{B as o,d as s}from"./p-C_6KHDYv.js";const p=o,r=s;export{p as BnChartBulletRenderer,r as defineCustomElement}
@@ -1 +1 @@
1
- import{p as t,H as e,w as i,f as s,h as r,a,t as n}from"./p-D6YGOYV1.js";import{h as l,a as o}from"./p-BcOud3dQ.js";import{o as u}from"./p-DSkyHSIL.js";import{c as h}from"./p-GrpYAVHb.js";import{a as d}from"./p-t4xPltK2.js";import{C as c,A as p}from"./p-D5LDmR4u.js";import{o as v}from"./p-B6kka9sT.js";import{a as m,b as g,O as f}from"./p-BNWZoAip.js";import{g as b}from"./p-DD1zlev_.js";import{p as y}from"./p-Xb6Ilq8u.js";import{b as _,i as w,c as A,h as O}from"./p-CYv_8LrR.js";import{w as j}from"./p-DEHnizot.js";import{w as R}from"./p-C6XrNN2m.js";import{w as N}from"./p-BVtD8O36.js";import{w as S}from"./p-CGI6XIaK.js";import{r as x}from"./p-M6hn0BuZ.js";import{w as E}from"./p-BWRE5w0i.js";import{w as D}from"./p-B3F_c9GB.js";import{w as k}from"./p-DLLljAll.js";import{r as z}from"./p-CLkpoHdg.js";import{p as L}from"./p-Dn3DJxQQ.js";import{s as T}from"./p-DakXa7Dp.js";import{d as W}from"./p-4BanAktr.js";const $=["measure","label","unit"];function F(t){const e=[],i=I(t,"measure",e);if(void 0===i||""===i.trim())return e.push("measure"),{config:null,unknownKeys:C(t,$),invalidFields:e};const s={measure:i.trim()};return s.label=I(t,"label",e),s.unit=I(t,"unit",e),{config:s,unknownKeys:C(t,$),invalidFields:e}}const M=["show","decimals"];function B(t,e){const i=[],s={show:e.show,decimals:e.decimals};return c.isExisting(t.show)&&("auto"===t.show||"none"===t.show?s.show=t.show:i.push("show")),c.isExisting(t.decimals)&&(c.isNumber(t.decimals)&&t.decimals>=0&&t.decimals<=4?s.decimals=Math.floor(t.decimals):i.push("decimals")),{config:s,unknownKeys:C(t,M),invalidFields:i}}function U(t){var e;const i=null!==(e=null==t?void 0:t.trim())&&void 0!==e?e:"";if(""===i||"null"===i)return{ranges:[],parseError:!1,issues:[]};let s;try{s=JSON.parse(i)}catch(t){return{ranges:[],parseError:!0,issues:[]}}if(!Array.isArray(s)||0===s.length)return{ranges:[],parseError:!0,issues:[]};if(!s.every((t=>c.isNumber(t)&&isFinite(t)&&t>0)))return{ranges:[],parseError:!0,issues:[]};const r=[];let a=s;const n=[...a].sort(((t,e)=>t-e));return n.some(((t,e)=>t!==a[e]))&&r.push("not ascending, sorted"),a=n,a.length>2&&(r.push(a.length+" entries, first 2 kept"),a=a.slice(0,2)),{ranges:a,parseError:!1,issues:r}}function C(t,e){return Object.keys(t).filter((t=>!e.includes(t)))}function I(t,e,i){if(c.isExisting(t[e]))return c.isString(t[e])?t[e]:void i.push(e)}const V=["pl1","pp1","fc1"],G=t(class extends e{validateFilter(t){const e="ERR_filter";l(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateActual(t){this.validateMeasureSpec("actual",t)}validateTarget(t){this.validateMeasureSpec("target",t)}validateRanges(t){const e="ERR_bullet_json_ranges",i="WARN_bullet_ranges",s=U(t);if(s.parseError)return this.setBlockingError(e,this.t(".bullet-prop-json",{prop:"ranges"})),void this.errors.remove(i);this.setBlockingError(e,null),s.issues.length>0?this.errors.addOrReplace({id:i,type:"warning",message:this.t(".bullet-ranges-invalid",{detail:s.issues.join("; ")})}):this.errors.remove(i)}validateNormalize(t){this.validateEnum("normalize","WARN_normalize",t,["target","none"],"target")}validateVariances(t){this.validateEnum("variances","WARN_variances",t,["auto","none"],"auto")}validateLevel(t){this.validateEnum("level","WARN_level",t,["auto","rowgroup","category","subcategory"],"auto")}validateOrder(t){const e="WARN_order",i=_(t).filter((t=>""!==t));0===i.length?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`order: invalid value(s) '${i.join(", ")}'; using the dataset order.`})}validateOrderDirection(t){const e="WARN_orderDirection";w(t)||A(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`order-direction: invalid value '${t}' - expected asc/desc; using asc.`})}validateLimit(t){const e="WARN_limit";O(t)&&Number(t)>=0?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateLabels(t){const e="ERR_bullet_json_labels",i="WARN_bullet_fields_labels",{data:s,parseError:r}=L(t,null);if(r)return this.setBlockingError(e,this.t(".bullet-prop-json",{prop:"labels"})),void this.errors.remove(i);this.setBlockingError(e,null),null!==s?this.reportSpecIssues(i,"labels",B(s,this.labelDefaults())):this.errors.remove(i)}validateScale(t){const e="WARN_scale";if(w(t))return void this.errors.remove(e);const{mode:i,factor:s}=y(t);"factor"===i&&(void 0===s||s<=0)?this.errors.addOrReplace({id:e,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(e)}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.chartTitle="",this.filter="",this.actual="",this.target="",this.ranges="",this.normalizeMode="target",this.variances="auto",this.level="auto",this.order="",this.orderDirection="",this.limit=0,this.labels="",this._autoScaleGuard=!1,this._lastScaledParentHeight=0,this.translateForInner=(t,e)=>this.t(t,e),k(this),j(this),N(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,e)=>{this.datasetMeta=e})),this.errors=S(this),this.componentStyle=R(this),this.ruleSetConfig=E(this),this.t=D(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateActual(this.actual),this.validateTarget(this.target),this.validateRanges(this.ranges),this.validateNormalize(this.normalizeMode),this.validateVariances(this.variances),this.validateLevel(this.level),this.validateOrder(this.order),this.validateOrderDirection(this.orderDirection),this.validateLimit(this.limit),this.validateLabels(this.labels),this.validateScale(this.scale)}componentDidRender(){T(this.element,"bn-chart-bullet-renderer");const{mode:t}=y(this.scale);if("auto"!==t&&"empty"!==t)return void(this._autoScaleGuard=!1);if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const e=this.element,{height:s}=b(e);if(s<=0)return;this._lastScaledParentHeight=s;const r=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),a=e.scrollHeight,n=this.appliedScaleFactor;if(a<=s+1)return void this.errors.remove("AUTO_scale");const l=Math.max(.3,n*(s-1)/a);Math.abs(l-n)<.01||(e.style.setProperty("--bn-font-size",r*l+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+l.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,i((()=>{this.appliedScaleFactor=l})))}componentDidLoad(){this.layoutObserver=v(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=b(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=b(this.element);this._lastScaledParentHeight=t,s(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{show:"auto",decimals:1}}setBlockingError(t,e){null===e?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:e}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateMeasureSpec(t,e){var i;const s="ERR_bullet_json_"+t,r="ERR_bullet_measure_"+t,a="WARN_bullet_fields_"+t,{data:n,parseError:l}=L(e,"measure");if(l)return this.setBlockingError(s,this.t(".bullet-prop-json",{prop:t})),this.setBlockingError(r,null),void this.errors.remove(a);if(this.setBlockingError(s,null),null===n)return this.setBlockingError(r,null),void this.errors.remove(a);const o=(null!==(i=n.measure)&&void 0!==i?i:"").trim(),u=z(o);"auto"===o.toLowerCase()||null!==u&&"scenario"===u.kind?this.setBlockingError(r,null):this.setBlockingError(r,this.t(".bullet-measure-invalid",{prop:t,measure:o})),this.reportSpecIssues(a,t,F(n))}validateEnum(t,e,i,s,r){w(i)||s.includes(i.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`${t}: invalid value '${i}' - expected ${s.join("/")}; using '${r}'.`})}reportSpecIssues(t,e,i){const s=[];null!==i&&i.invalidFields.length>0&&s.push("invalid: "+i.invalidFields.join(", ")),null!==i&&i.unknownKeys.length>0&&s.push("unknown: "+i.unknownKeys.join(", ")),s.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${s.join("; ")}).`}):this.errors.remove(t)}prepareActual(){var t,e,i,s,r;const{data:a,parseError:n}=L(this.actual,"measure");if(n)return null;const l=null!==a?F(a).config:null;if(null===l||"auto"===l.measure.toLowerCase()){const r=null!==l,a=null!==(e=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==e?e:[],n=null!==(s=a.includes("ac1")?"ac1":null!==(i=a.find((t=>t.startsWith("ac"))))&&void 0!==i?i:a[0])&&void 0!==s?s:"ac1";return r||null===this.datasetMeta?this.errors.remove("AUTO_actual"):this.errors.addOrReplace({id:"AUTO_actual",type:"warning",message:"actual: not set, auto-detected: "+n}),null===l?{measure:n}:Object.assign(Object.assign({},l),{measure:n})}return this.errors.remove("AUTO_actual"),"scenario"===(null===(r=z(l.measure))||void 0===r?void 0:r.kind)?l:null}prepareTarget(){var t,e,i;const{data:s,parseError:r}=L(this.target,"measure");if(r)return null;const a=null!==s?F(s).config:null;if(null===a||"auto"===a.measure.toLowerCase()){const i=null!==a,s=null!==(e=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==e?e:[],r=V.find((t=>s.includes(t)));return void 0===r?(this.errors.remove("AUTO_target"),null!==this.datasetMeta?this.errors.addOrReplace({id:"WARN_bullet_target_unavailable",type:"warning",message:this.t(".bullet-target-none")}):this.errors.remove("WARN_bullet_target_unavailable"),null):(this.errors.remove("WARN_bullet_target_unavailable"),i||null===this.datasetMeta?this.errors.remove("AUTO_target"):this.errors.addOrReplace({id:"AUTO_target",type:"warning",message:"target: not set, auto-detected: "+r}),null===a?{measure:r}:Object.assign(Object.assign({},a),{measure:r}))}return this.errors.remove("AUTO_target"),this.errors.remove("WARN_bullet_target_unavailable"),"scenario"===(null===(i=z(a.measure))||void 0===i?void 0:i.kind)?a:null}prepareNormalize(){var t;return"none"===(null===(t=this.normalizeMode)||void 0===t?void 0:t.trim().toLowerCase())?"none":"target"}prepareShowVariances(){var t;return"none"!==(null===(t=this.variances)||void 0===t?void 0:t.trim().toLowerCase())}prepareLevel(){var t,e;const i=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("rowgroup"===i)return p.ROWGROUP;if("category"===i)return p.CATEGORY;if("subcategory"===i)return p.SUBCATEGORY;const s=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;if(void 0!==s&&""!==s){const t=p[s.toUpperCase()];if(void 0!==t)return t}return p.CATEGORY}prepareOrder(){var t,e,i,s;const r="auto"===(null===(t=this.order)||void 0===t?void 0:t.trim().toLowerCase());let a;w(this.order)||r?(null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedOrder)?(r?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+this.datasetMeta.suggestedOrder}),a=this.datasetMeta.suggestedOrder):(this.errors.remove("AUTO_order"),a=""):(this.errors.remove("AUTO_order"),a=this.order);const n=null!==(s=m[null===(i=this.orderDirection)||void 0===i?void 0:i.toUpperCase()])&&void 0!==s?s:m.ASC;if(w(a))return new g([f.CATEGORYINDEX],n);const l=a.split(",").map((t=>f[t.trim().toUpperCase()])).filter((t=>void 0!==t));return new g(l.length>0?l:[f.CATEGORYINDEX],n)}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:i}=L(this.labels,null);return i||null===e?{show:t.show,decimals:t.decimals}:B(e,t).config}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}i18nLocalKeys(){return["no-data","target","axis.in"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),e=new Map(o.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries(),...x(this.ruleSetConfig("user"))])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{const i=e.global.fontSizePx*t;return{scaleFactors:e["bn-chart-bullet"].scaleFactors,fontStyles:{font:`${i}px ${e.global.fontFamily}`,size:i,color:e.global.fontColor,background:e.global.fontBackgroundColor,leading:1.8},axisStyles:e["bn-chart-bullet"].axisStyles,barStyles:e["bn-chart-bullet"].barStyles,varianceStyles:e["bn-chart-bullet"].varianceStyles,rangeColors:e["bn-chart-bullet"].rangeColors,padding:e["bn-chart-bullet"].padding}}))}async getBaseline(){return d(this.element,"bn-chart-bullet-renderer")}async getLayoutState(t){var e;const i=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",s=u(this.element),r=this.getEffectiveScaleFactor(),a=Number.isFinite(r)&&r>0?r:1,n=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*a;return h(this.element,"bn-chart-bullet-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:a},s,i)}getEffectiveScaleFactor(){const{mode:t,factor:e}=y(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var i,s,r,a;const n=(null===(i=e.global)||void 0===i?void 0:i.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=e.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(r=e.global)||void 0===r?void 0:r.fontColor)||"#000000","--bn-font-background":(null===(a=e.global)||void 0===a?void 0:a.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const e of["ac","pp","fc","pl"])for(const i of[1,2,3,4])t[`${e}${i}`]={type:"number",isOptional:!0,description:""};const e={actual:this.prepareActual(),target:this.prepareTarget()};for(const[i,s]of Object.entries(e))null!==s&&void 0!==t[s.measure]&&(t[s.measure].description=`${i}: ${void 0!==s.label?s.label:s.measure}`);return{IBulletChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareActual(),e=this.prepareTarget(),i=U(this.ranges).ranges,s=this.prepareNormalize();return this.setBlockingError("ERR_bullet_measure_same",null!==t&&null!==e&&t.measure===e.measure?this.t(".bullet-measure-same",{measure:t.measure}):null),i.length>0&&"target"===s?this.errors.addOrReplace({id:"WARN_bullet_ranges_ignored",type:"warning",message:this.t(".bullet-ranges-ignored")}):this.errors.remove("WARN_bullet_ranges_ignored"),this.hasBlockingErrors()||null===t?null:r("bn-chart-bullet-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,actual:t,target:e,ranges:i,normalizeMode:s,showVariances:this.prepareShowVariances(),level:this.prepareLevel(),order:this.prepareOrder(),limit:this.prepareLimit(),labels:this.prepareLabels(),filter:this.filter,styles:this.prepareStyle(),i18n:this.prepareI18n(),containerWidth:b(this.element).width,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return r(a,{key:"cdd2404977255a330652806671d1bea76c796769",style:this.getFontStyles()},r("div",{key:"0b8cfeb6209083f9144c5824bceecb9b02578f02",class:"container"},this.chartTemplate()))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],actual:[{validateActual:0}],target:[{validateTarget:0}],ranges:[{validateRanges:0}],normalizeMode:[{validateNormalize:0}],variances:[{validateVariances:0}],level:[{validateLevel:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],labels:[{validateLabels:0}],scale:[{validateScale:0}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column}'}},[1,"bn-chart-bullet",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],actual:[1],target:[1],ranges:[1],normalizeMode:[1,"normalize"],variances:[1],level:[1],order:[1],orderDirection:[1,"order-direction"],limit:[2],labels:[1],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],actual:[{validateActual:0}],target:[{validateTarget:0}],ranges:[{validateRanges:0}],normalizeMode:[{validateNormalize:0}],variances:[{validateVariances:0}],level:[{validateLevel:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],labels:[{validateLabels:0}],scale:[{validateScale:0}]}]),K=G,H=function(){"undefined"!=typeof customElements&&["bn-chart-bullet","bn-chart-bullet-renderer"].forEach((t=>{switch(t){case"bn-chart-bullet":customElements.get(n(t))||customElements.define(n(t),G);break;case"bn-chart-bullet-renderer":customElements.get(n(t))||W()}}))};export{K as BnChartBullet,H as defineCustomElement}
1
+ import{p as t,H as e,w as i,f as s,h as r,a,t as n}from"./p-D6YGOYV1.js";import{h as l,a as o}from"./p-DDvWTgk1.js";import{o as u}from"./p-DaOm9YwQ.js";import{c as h}from"./p-sar8m7th.js";import{a as d}from"./p-t4xPltK2.js";import{C as c,A as p}from"./p-B5tixDPM.js";import{o as v}from"./p-B6kka9sT.js";import{a as m,b as f,O as g}from"./p-16rjcQ0t.js";import{g as b}from"./p-DD1zlev_.js";import{p as y}from"./p-Xb6Ilq8u.js";import{b as _,i as w,c as A,h as O}from"./p-DT04Cka0.js";import{w as j}from"./p-Dq9dG0Kr.js";import{w as R}from"./p-DjPWZfry.js";import{w as N}from"./p-DJUffGeB.js";import{w as x}from"./p-4vVbchX2.js";import{r as D}from"./p-CniN8ALm.js";import{w as S}from"./p-OquycEMA.js";import{w as T}from"./p-BU_53KVT.js";import{w as E}from"./p-Bo_R7f_T.js";import{r as k}from"./p-BXXjh6We.js";import{p as z}from"./p-9mUU4itF.js";import{s as W}from"./p-DakXa7Dp.js";import{d as L}from"./p-C_6KHDYv.js";const U=["measure","label","unit"];function $(t){const e=[],i=V(t,"measure",e);if(void 0===i||""===i.trim())return e.push("measure"),{config:null,unknownKeys:C(t,U),invalidFields:e};const s={measure:i.trim()};return s.label=V(t,"label",e),s.unit=V(t,"unit",e),{config:s,unknownKeys:C(t,U),invalidFields:e}}const M=["show","decimals"];function F(t,e){const i=[],s={show:e.show,decimals:e.decimals};return c.isExisting(t.show)&&("auto"===t.show||"none"===t.show?s.show=t.show:i.push("show")),c.isExisting(t.decimals)&&(c.isNumber(t.decimals)&&t.decimals>=0&&t.decimals<=4?s.decimals=Math.floor(t.decimals):i.push("decimals")),{config:s,unknownKeys:C(t,M),invalidFields:i}}function B(t){var e;const i=null!==(e=null==t?void 0:t.trim())&&void 0!==e?e:"";if(""===i||"null"===i)return{ranges:[],parseError:!1,issues:[]};let s;try{s=JSON.parse(i)}catch(t){return{ranges:[],parseError:!0,issues:[]}}if(!Array.isArray(s)||0===s.length)return{ranges:[],parseError:!0,issues:[]};if(!s.every((t=>c.isNumber(t)&&isFinite(t)&&t>0)))return{ranges:[],parseError:!0,issues:[]};const r=[];let a=s;const n=[...a].sort(((t,e)=>t-e));return n.some(((t,e)=>t!==a[e]))&&r.push("not ascending, sorted"),a=n,a.length>2&&(r.push(a.length+" entries, first 2 kept"),a=a.slice(0,2)),{ranges:a,parseError:!1,issues:r}}function C(t,e){return Object.keys(t).filter((t=>!e.includes(t)))}function V(t,e,i){if(c.isExisting(t[e]))return c.isString(t[e])?t[e]:void i.push(e)}const K=["pl1","pp1","fc1"],I=t(class extends e{validateFilter(t){const e="ERR_filter";l(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateActual(t){this.validateMeasureSpec("actual",t)}validateTarget(t){this.validateMeasureSpec("target",t)}validateRanges(t){const e="ERR_bullet_json_ranges",i="WARN_bullet_ranges",s=B(t);if(s.parseError)return this.setBlockingError(e,this.t(".bullet-prop-json",{prop:"ranges"})),void this.errors.remove(i);this.setBlockingError(e,null),s.issues.length>0?this.errors.addOrReplace({id:i,type:"warning",message:this.t(".bullet-ranges-invalid",{detail:s.issues.join("; ")})}):this.errors.remove(i)}validateNormalize(t){this.validateEnum("normalize","WARN_normalize",t,["target","none"],"target")}validateVariances(t){this.validateEnum("variances","WARN_variances",t,["auto","none"],"auto")}validateLevel(t){this.validateEnum("level","WARN_level",t,["auto","rowgroup","category","subcategory"],"auto")}validateOrder(t){const e="WARN_order",i=_(t).filter((t=>""!==t));0===i.length?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`order: invalid value(s) '${i.join(", ")}'; using the dataset order.`})}validateOrderDirection(t){const e="WARN_orderDirection";w(t)||A(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`order-direction: invalid value '${t}' - expected asc/desc; using asc.`})}validateLimit(t){const e="WARN_limit";O(t)&&Number(t)>=0?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateLabels(t){const e="ERR_bullet_json_labels",i="WARN_bullet_fields_labels",{data:s,parseError:r}=z(t,null);if(r)return this.setBlockingError(e,this.t(".bullet-prop-json",{prop:"labels"})),void this.errors.remove(i);this.setBlockingError(e,null),null!==s?this.reportSpecIssues(i,"labels",F(s,this.labelDefaults())):this.errors.remove(i)}validateScale(t){const e="WARN_scale";if(w(t))return void this.errors.remove(e);const{mode:i,factor:s}=y(t);"factor"===i&&(void 0===s||s<=0)?this.errors.addOrReplace({id:e,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(e)}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.chartTitle="",this.filter="",this.actual="",this.target="",this.ranges="",this.normalizeMode="target",this.variances="auto",this.level="auto",this.order="",this.orderDirection="",this.limit=0,this.labels="",this._autoScaleGuard=!1,this._lastScaledParentHeight=0,this.translateForInner=(t,e)=>this.t(t,e),E(this),j(this),N(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,e)=>{this.datasetMeta=e})),this.errors=x(this),this.componentStyle=R(this),this.ruleSetConfig=S(this),this.t=T(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateActual(this.actual),this.validateTarget(this.target),this.validateRanges(this.ranges),this.validateNormalize(this.normalizeMode),this.validateVariances(this.variances),this.validateLevel(this.level),this.validateOrder(this.order),this.validateOrderDirection(this.orderDirection),this.validateLimit(this.limit),this.validateLabels(this.labels),this.validateScale(this.scale)}componentDidRender(){W(this.element,"bn-chart-bullet-renderer");const{mode:t}=y(this.scale);if("auto"!==t&&"empty"!==t)return void(this._autoScaleGuard=!1);if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const e=this.element,{height:s}=b(e);if(s<=0)return;this._lastScaledParentHeight=s;const r=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),a=e.scrollHeight,n=this.appliedScaleFactor;if(a<=s+1)return void this.errors.remove("AUTO_scale");const l=Math.max(.3,n*(s-1)/a);Math.abs(l-n)<.01||(e.style.setProperty("--bn-font-size",r*l+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+l.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,i((()=>{this.appliedScaleFactor=l})))}componentDidLoad(){this.layoutObserver=v(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=b(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=b(this.element);this._lastScaledParentHeight=t,s(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{show:"auto",decimals:1}}setBlockingError(t,e){null===e?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:e}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateMeasureSpec(t,e){var i;const s="ERR_bullet_json_"+t,r="ERR_bullet_measure_"+t,a="WARN_bullet_fields_"+t,{data:n,parseError:l}=z(e,"measure");if(l)return this.setBlockingError(s,this.t(".bullet-prop-json",{prop:t})),this.setBlockingError(r,null),void this.errors.remove(a);if(this.setBlockingError(s,null),null===n)return this.setBlockingError(r,null),void this.errors.remove(a);const o=(null!==(i=n.measure)&&void 0!==i?i:"").trim(),u=k(o);"auto"===o.toLowerCase()||null!==u&&"scenario"===u.kind?this.setBlockingError(r,null):this.setBlockingError(r,this.t(".bullet-measure-invalid",{prop:t,measure:o})),this.reportSpecIssues(a,t,$(n))}validateEnum(t,e,i,s,r){w(i)||s.includes(i.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`${t}: invalid value '${i}' - expected ${s.join("/")}; using '${r}'.`})}reportSpecIssues(t,e,i){const s=[];null!==i&&i.invalidFields.length>0&&s.push("invalid: "+i.invalidFields.join(", ")),null!==i&&i.unknownKeys.length>0&&s.push("unknown: "+i.unknownKeys.join(", ")),s.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${s.join("; ")}).`}):this.errors.remove(t)}prepareActual(){var t,e,i,s,r;const{data:a,parseError:n}=z(this.actual,"measure");if(n)return null;const l=null!==a?$(a).config:null;if(null===l||"auto"===l.measure.toLowerCase()){const r=null!==l,a=null!==(e=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==e?e:[],n=null!==(s=a.includes("ac1")?"ac1":null!==(i=a.find((t=>t.startsWith("ac"))))&&void 0!==i?i:a[0])&&void 0!==s?s:"ac1";return r||null===this.datasetMeta?this.errors.remove("AUTO_actual"):this.errors.addOrReplace({id:"AUTO_actual",type:"warning",message:"actual: not set, auto-detected: "+n}),null===l?{measure:n}:Object.assign(Object.assign({},l),{measure:n})}return this.errors.remove("AUTO_actual"),"scenario"===(null===(r=k(l.measure))||void 0===r?void 0:r.kind)?l:null}prepareTarget(){var t,e,i;const{data:s,parseError:r}=z(this.target,"measure");if(r)return null;const a=null!==s?$(s).config:null;if(null===a||"auto"===a.measure.toLowerCase()){const i=null!==a,s=null!==(e=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==e?e:[],r=K.find((t=>s.includes(t)));return void 0===r?(this.errors.remove("AUTO_target"),null!==this.datasetMeta?this.errors.addOrReplace({id:"WARN_bullet_target_unavailable",type:"warning",message:this.t(".bullet-target-none")}):this.errors.remove("WARN_bullet_target_unavailable"),null):(this.errors.remove("WARN_bullet_target_unavailable"),i||null===this.datasetMeta?this.errors.remove("AUTO_target"):this.errors.addOrReplace({id:"AUTO_target",type:"warning",message:"target: not set, auto-detected: "+r}),null===a?{measure:r}:Object.assign(Object.assign({},a),{measure:r}))}return this.errors.remove("AUTO_target"),this.errors.remove("WARN_bullet_target_unavailable"),"scenario"===(null===(i=k(a.measure))||void 0===i?void 0:i.kind)?a:null}prepareNormalize(){var t;return"none"===(null===(t=this.normalizeMode)||void 0===t?void 0:t.trim().toLowerCase())?"none":"target"}prepareShowVariances(){var t;return"none"!==(null===(t=this.variances)||void 0===t?void 0:t.trim().toLowerCase())}prepareLevel(){var t,e;const i=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("rowgroup"===i)return p.ROWGROUP;if("category"===i)return p.CATEGORY;if("subcategory"===i)return p.SUBCATEGORY;const s=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;if(void 0!==s&&""!==s){const t=p[s.toUpperCase()];if(void 0!==t)return t}return p.CATEGORY}prepareOrder(){var t,e,i,s;const r="auto"===(null===(t=this.order)||void 0===t?void 0:t.trim().toLowerCase());let a;w(this.order)||r?(null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedOrder)?(r?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+this.datasetMeta.suggestedOrder}),a=this.datasetMeta.suggestedOrder):(this.errors.remove("AUTO_order"),a=""):(this.errors.remove("AUTO_order"),a=this.order);const n=null!==(s=m[null===(i=this.orderDirection)||void 0===i?void 0:i.toUpperCase()])&&void 0!==s?s:m.ASC;if(w(a))return new f([g.CATEGORYINDEX],n);const l=a.split(",").map((t=>g[t.trim().toUpperCase()])).filter((t=>void 0!==t));return new f(l.length>0?l:[g.CATEGORYINDEX],n)}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:i}=z(this.labels,null);return i||null===e?{show:t.show,decimals:t.decimals}:F(e,t).config}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}i18nLocalKeys(){return["no-data","target","axis.in"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),e=new Map(o.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries(),...D(this.ruleSetConfig("user"))])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{const i=e.global.fontSizePx*t;return{scaleFactors:e["bn-chart-bullet"].scaleFactors,fontStyles:{font:`${i}px ${e.global.fontFamily}`,size:i,color:e.global.fontColor,background:e.global.fontBackgroundColor,leading:1.8},axisStyles:e["bn-chart-bullet"].axisStyles,barStyles:e["bn-chart-bullet"].barStyles,varianceStyles:e["bn-chart-bullet"].varianceStyles,rangeColors:e["bn-chart-bullet"].rangeColors,padding:e["bn-chart-bullet"].padding}}))}async getBaseline(){return d(this.element,"bn-chart-bullet-renderer")}async getLayoutState(t){var e;const i=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",s=u(this.element),r=this.getEffectiveScaleFactor(),a=Number.isFinite(r)&&r>0?r:1,n=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*a;return h(this.element,"bn-chart-bullet-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:a},s,i)}getEffectiveScaleFactor(){const{mode:t,factor:e}=y(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var i,s,r,a;const n=(null===(i=e.global)||void 0===i?void 0:i.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=e.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(r=e.global)||void 0===r?void 0:r.fontColor)||"#000000","--bn-font-background":(null===(a=e.global)||void 0===a?void 0:a.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const e of["ac","pp","fc","pl"])for(const i of[1,2,3,4])t[`${e}${i}`]={type:"number",isOptional:!0,description:""};const e={actual:this.prepareActual(),target:this.prepareTarget()};for(const[i,s]of Object.entries(e))null!==s&&void 0!==t[s.measure]&&(t[s.measure].description=`${i}: ${void 0!==s.label?s.label:s.measure}`);return{IBulletChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareActual(),e=this.prepareTarget(),i=B(this.ranges).ranges,s=this.prepareNormalize();return this.setBlockingError("ERR_bullet_measure_same",null!==t&&null!==e&&t.measure===e.measure?this.t(".bullet-measure-same",{measure:t.measure}):null),i.length>0&&"target"===s?this.errors.addOrReplace({id:"WARN_bullet_ranges_ignored",type:"warning",message:this.t(".bullet-ranges-ignored")}):this.errors.remove("WARN_bullet_ranges_ignored"),this.hasBlockingErrors()||null===t?null:r("bn-chart-bullet-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,actual:t,target:e,ranges:i,normalizeMode:s,showVariances:this.prepareShowVariances(),level:this.prepareLevel(),order:this.prepareOrder(),limit:this.prepareLimit(),labels:this.prepareLabels(),filter:this.filter,styles:this.prepareStyle(),i18n:this.prepareI18n(),containerWidth:b(this.element).width,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return r(a,{key:"cdd2404977255a330652806671d1bea76c796769",style:this.getFontStyles()},r("div",{key:"0b8cfeb6209083f9144c5824bceecb9b02578f02",class:"container"},this.chartTemplate()))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],actual:[{validateActual:0}],target:[{validateTarget:0}],ranges:[{validateRanges:0}],normalizeMode:[{validateNormalize:0}],variances:[{validateVariances:0}],level:[{validateLevel:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],labels:[{validateLabels:0}],scale:[{validateScale:0}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column}'}},[1,"bn-chart-bullet",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],actual:[1],target:[1],ranges:[1],normalizeMode:[1,"normalize"],variances:[1],level:[1],order:[1],orderDirection:[1,"order-direction"],limit:[2],labels:[1],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],actual:[{validateActual:0}],target:[{validateTarget:0}],ranges:[{validateRanges:0}],normalizeMode:[{validateNormalize:0}],variances:[{validateVariances:0}],level:[{validateLevel:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],labels:[{validateLabels:0}],scale:[{validateScale:0}]}]),q=I,G=function(){"undefined"!=typeof customElements&&["bn-chart-bullet","bn-chart-bullet-renderer"].forEach((t=>{switch(t){case"bn-chart-bullet":customElements.get(n(t))||customElements.define(n(t),I);break;case"bn-chart-bullet-renderer":customElements.get(n(t))||L()}}))};export{q as BnChartBullet,G as defineCustomElement}
@@ -1 +1 @@
1
- import{B as o,d as s}from"./p-BtH2oezK.js";const t=o,p=s;export{t as BnChartScatterRenderer,p as defineCustomElement}
1
+ import{B as o,d as s}from"./p-C-KX1_tw.js";const t=o,p=s;export{t as BnChartScatterRenderer,p as defineCustomElement}
@@ -1 +1 @@
1
- import{p as t,H as e,w as s,f as i,h as a,a as r,t as n}from"./p-D6YGOYV1.js";import{h as o,a as l}from"./p-BcOud3dQ.js";import{o as h}from"./p-DSkyHSIL.js";import{c as d}from"./p-GrpYAVHb.js";import{a as c}from"./p-t4xPltK2.js";import{g as u}from"./p-DD1zlev_.js";import{c as p}from"./p-D2Epww9R.js";import{o as v}from"./p-B6kka9sT.js";import{p as m}from"./p-Xb6Ilq8u.js";import{i as f,h as y,j as g}from"./p-CYv_8LrR.js";import{w as b}from"./p-DEHnizot.js";import{w as x}from"./p-C6XrNN2m.js";import{w}from"./p-BVtD8O36.js";import{w as _}from"./p-CGI6XIaK.js";import{w as L}from"./p-BWRE5w0i.js";import{w as S}from"./p-B3F_c9GB.js";import{w as j}from"./p-DLLljAll.js";import{r as R,s as A}from"./p-CLkpoHdg.js";import{f as $,c as N,d as E,e as k,p as O,t as D}from"./p-Dn3DJxQQ.js";import{s as C}from"./p-DakXa7Dp.js";import{d as F}from"./p-BtH2oezK.js";const z={rowGroup:0,category:1,subCategory:2},I=t(class extends e{validateFilter(t){const e="ERR_filter";o(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateX(t){this.validateAxisSpec("x",t)}validateY(t){this.validateAxisSpec("y",t)}validateIso(t){this.validateObjectSpec("iso",t,null,(t=>$(t)))}validateLevel(t){const e="WARN_level",s=["auto","category","subcategory"];f(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const e="WARN_seriesLevel",s=["auto","rowgroup","category","none"];f(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`series-level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,null,(t=>N(t)))}validateLabels(t){this.validateObjectSpec("labels",t,null,(t=>E(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,null,(t=>k(t)))}validateAspect(t){const e="WARN_aspect";f(t)||null!==this.parseAspect(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`aspect: invalid value '${t}' - expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const e="WARN_limit";y(t)&&Number(t)>=0?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateScale(t){const e="WARN_scale";if(f(t))return void this.errors.remove(e);const{mode:s,factor:i}=m(t);"factor"===s&&(void 0===i||i<=0)?this.errors.addOrReplace({id:e,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(e)}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.chartTitle="",this.filter="",this.iso="",this.level="auto",this.seriesLevel="auto",this.facet="",this.labels="",this.legend="",this.aspect="16:9",this.limit=0,this._autoScaleGuard=!1,this._lastObservedWidth=0,this.translateForInner=(t,e)=>this.t(t,e),j(this),b(this),w(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,e)=>{this.datasetMeta=e})),this.errors=_(this),this.componentStyle=x(this),this.ruleSetConfig=L(this),this.t=S(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateX(this.x),this.validateY(this.y),this.validateIso(this.iso),this.validateLevel(this.level),this.validateSeriesLevel(this.seriesLevel),this.validateFacet(this.facet),this.validateLabels(this.labels),this.validateLegend(this.legend),this.validateAspect(this.aspect),this.validateLimit(this.limit),this.validateScale(this.scale)}componentDidRender(){C(this.element,"bn-chart-scatter-renderer");const{mode:t}=m(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const e=this.element,{width:i}=u(e);if(i<=0)return void this.checkOverflow();this._lastObservedWidth=i;const a=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),r=e.scrollWidth,n=this.appliedScaleFactor;if(!Number.isFinite(r)||r<=i+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(i-1)/r);Math.abs(o-n)<.01||(e.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,s((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}checkOverflow(){p(this.element,"bn-chart-scatter-renderer",this.errors)}componentDidLoad(){this.layoutObserver=v(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2?(this._lastObservedWidth=t,i(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);this._lastObservedWidth=t,i(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"auto",values:!1,max:12}}setBlockingError(t,e){null===e?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:e}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateAxisSpec(t,e){var s;const i="ERR_xy_json_"+t,a="ERR_xy_measure_"+t,r="WARN_xy_fields_"+t,n="x"===t||"y"===t||"size"===t,{data:o,parseError:l}=O(e,"measure");if(l)return this.setBlockingError(i,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(a,null),void this.errors.remove(r);if(this.setBlockingError(i,null),null===o)return this.setBlockingError(a,n?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(r);const h="share"===t?null:D(o),d=null!==(s=o.measure)&&void 0!==s?s:"";g(d)?this.setBlockingError(a,null):this.setBlockingError(a,this.t(".xy-measure-invalid",{prop:t,measure:d})),this.reportSpecIssues(r,t,h)}validateObjectSpec(t,e,s,i){const a="ERR_xy_json_"+t,r="WARN_xy_fields_"+t,{data:n,parseError:o}=O(e,s);if(o)return this.setBlockingError(a,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(r);this.setBlockingError(a,null),null!==n?this.reportSpecIssues(r,t,i(n)):this.errors.remove(r)}reportSpecIssues(t,e,s){const i=[];null!==s&&s.invalidFields.length>0&&i.push("invalid: "+s.invalidFields.join(", ")),null!==s&&s.unknownKeys.length>0&&i.push("unknown: "+s.unknownKeys.join(", ")),i.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${i.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,e){const{data:s,parseError:i}=O(e,"measure");if(i||null===s)return null;const{config:a}=D(s);return null!==a&&g(a.measure)?(void 0!==a.min&&void 0!==a.max&&a.min>=a.max?(this.errors.addOrReplace({id:"WARN_xy_domain_"+t,type:"warning",message:t+": min must be smaller than max; the override is ignored."}),a.min=void 0,a.max=void 0):this.errors.remove("WARN_xy_domain_"+t),a):null}prepareIso(){const{data:t,parseError:e}=O(this.iso,null);return e||null===t?null:$(t).config}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:s}=O(this.labels,null);return s||null===e?{points:t.points,values:t.values,max:t.max}:E(e,t).config}prepareLegend(){const{data:t,parseError:e}=O(this.legend,null);return e||null===t?{show:!0,position:"right"}:k(t).config}prepareFacet(){const{data:t,parseError:e}=O(this.facet,null);return e||null===t?null:N(t).config}preparePointLevel(){var t,e;const s=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===s)return"category";if("subcategory"===s)return"subCategory";const i=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;return"rowGroup"===i||"category"===i||"subCategory"===i?i:"category"}prepareSeriesLevel(t){var e;const s=null===(e=this.seriesLevel)||void 0===e?void 0:e.trim().toLowerCase();return"none"===s?null:"rowgroup"===s?"rowGroup":"category"===s||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,e){const s=new Set;for(const e of t){if(void 0===e)continue;const t=R(e);null!==t&&"scenario"===t.kind&&s.add(A(t.slot))}this.setBlockingError("ERR_xy_family",s.size>1?this.t(".xy-family-mixed",{families:[...s].join(", ")}):null);const i=this.preparePointLevel(),a=this.prepareSeriesLevel(i),r=null!==e?"rowgroup"===e.level?"rowGroup":"category":null;let n=null;if(null!==a&&z[a]>=z[i]&&(n=`series '${a}' vs point '${i}'`),null!==r){const t=null!=a?a:i;z[r]>=z[t]&&(n=`facet '${r}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==n?this.t(".xy-level-order",{detail:n}):null)}parseAspect(t){const e=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===e)return null;const s=Number(e[1]),i=Number(e[2]);return s<=0||i<=0?null:s/i}prepareAspect(){var t;return null!==(t=this.parseAspect(this.aspect))&&void 0!==t?t:16/9}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}i18nLocalKeys(){return["no-data","axis.in","legend.title"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),e=new Map(l.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor(),e=this.element.localName;return this.componentStyle((s=>{const i=s.global.fontSizePx*t;return{scaleFactors:s[e].scaleFactors,fontStyles:{font:`${i}px ${s.global.fontFamily}`,size:i,color:s.global.fontColor,background:s.global.fontBackgroundColor,leading:1.8},axisStyles:s[e].axisStyles,seriesColors:s[e].seriesColors,padding:s[e].padding}}))}async getBaseline(){return c(this.element,"bn-chart-scatter-renderer")}async getLayoutState(t){var e;const s=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",i=h(this.element),a=this.getEffectiveScaleFactor(),r=Number.isFinite(a)&&a>0?a:1,n=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*r;return d(this.element,"bn-chart-scatter-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:r},i,s)}getEffectiveScaleFactor(){const{mode:t,factor:e}=m(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var s,i,a,r;const n=(null===(s=e.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(i=e.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=e.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=e.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const e of["ac","pp","fc","pl"])for(const s of[1,2,3,4])t[`${e}${s}`]={type:"number",isOptional:!0,description:""};for(const[e,s]of Object.entries(this.mappedAxes())){if(null===s)continue;const i=R(s.measure);null!==i&&("scenario"===i.kind?t[i.slot].description=`${e}: ${"label"in s&&void 0!==s.label?s.label:s.measure}`:(t[i.measure.base].description=`${e}: ${s.measure} (base)`,t[i.measure.delta].description=`${e}: ${s.measure} (delta)`))}return{[this.dataStructureName()]:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}mappedAxes(){return{x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y)}}dataStructureName(){return"IScatterChartDataRow"}chartTemplate(){const t=this.prepareAxis("x",this.x),e=this.prepareAxis("y",this.y),s=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==e?void 0:e.measure],s),this.hasBlockingErrors()||null===t||null===e)return null;const i=this.preparePointLevel(),r=this.prepareI18n(),n=this.prepareStyle(),o=u(this.element).width;return a("bn-chart-scatter-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:e,iso:this.prepareIso(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:s,pointLevel:i,seriesLevel:this.prepareSeriesLevel(i),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,styles:n,i18n:r,containerWidth:o,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return a(r,{key:"4947af836a9c76b089bc07fb1f4df8c248aa4f62",style:this.getFontStyles()},a("div",{key:"16abbc30d255d224aefecf9e337d3b23d449828a",class:"container"},this.chartTemplate()))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],iso:[{validateIso:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column}'}},[1,"bn-chart-scatter",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],x:[1],y:[1],iso:[1],level:[1],seriesLevel:[1,"series-level"],facet:[1],labels:[1],legend:[1],aspect:[1],limit:[2],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],iso:[{validateIso:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}]),W=I,B=function(){"undefined"!=typeof customElements&&["bn-chart-scatter","bn-chart-scatter-renderer"].forEach((t=>{switch(t){case"bn-chart-scatter":customElements.get(n(t))||customElements.define(n(t),I);break;case"bn-chart-scatter-renderer":customElements.get(n(t))||F()}}))};export{W as BnChartScatter,B as defineCustomElement}
1
+ import{p as t,H as e,w as s,f as i,h as a,a as r,t as n}from"./p-D6YGOYV1.js";import{h as o,a as l}from"./p-DDvWTgk1.js";import{o as h}from"./p-DaOm9YwQ.js";import{c as d}from"./p-sar8m7th.js";import{a as c}from"./p-t4xPltK2.js";import{g as u}from"./p-DD1zlev_.js";import{c as p}from"./p-D2Epww9R.js";import{o as v}from"./p-B6kka9sT.js";import{p as m}from"./p-Xb6Ilq8u.js";import{i as f,h as y,j as g}from"./p-DT04Cka0.js";import{w as b}from"./p-Dq9dG0Kr.js";import{w as x}from"./p-DjPWZfry.js";import{w}from"./p-DJUffGeB.js";import{w as _}from"./p-4vVbchX2.js";import{w as j}from"./p-OquycEMA.js";import{w as L}from"./p-BU_53KVT.js";import{w as S}from"./p-Bo_R7f_T.js";import{r as R,s as $}from"./p-BXXjh6We.js";import{f as A,c as E,d as N,e as k,p as D,t as O}from"./p-9mUU4itF.js";import{s as F}from"./p-DakXa7Dp.js";import{d as W}from"./p-C-KX1_tw.js";const C={rowGroup:0,category:1,subCategory:2},z=t(class extends e{validateFilter(t){const e="ERR_filter";o(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateX(t){this.validateAxisSpec("x",t)}validateY(t){this.validateAxisSpec("y",t)}validateIso(t){this.validateObjectSpec("iso",t,null,(t=>A(t)))}validateLevel(t){const e="WARN_level",s=["auto","category","subcategory"];f(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const e="WARN_seriesLevel",s=["auto","rowgroup","category","none"];f(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`series-level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,null,(t=>E(t)))}validateLabels(t){this.validateObjectSpec("labels",t,null,(t=>N(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,null,(t=>k(t)))}validateAspect(t){const e="WARN_aspect";f(t)||null!==this.parseAspect(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`aspect: invalid value '${t}' - expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const e="WARN_limit";y(t)&&Number(t)>=0?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateScale(t){const e="WARN_scale";if(f(t))return void this.errors.remove(e);const{mode:s,factor:i}=m(t);"factor"===s&&(void 0===i||i<=0)?this.errors.addOrReplace({id:e,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(e)}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.chartTitle="",this.filter="",this.iso="",this.level="auto",this.seriesLevel="auto",this.facet="",this.labels="",this.legend="",this.aspect="16:9",this.limit=0,this._autoScaleGuard=!1,this._lastObservedWidth=0,this.translateForInner=(t,e)=>this.t(t,e),S(this),b(this),w(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,e)=>{this.datasetMeta=e})),this.errors=_(this),this.componentStyle=x(this),this.ruleSetConfig=j(this),this.t=L(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateX(this.x),this.validateY(this.y),this.validateIso(this.iso),this.validateLevel(this.level),this.validateSeriesLevel(this.seriesLevel),this.validateFacet(this.facet),this.validateLabels(this.labels),this.validateLegend(this.legend),this.validateAspect(this.aspect),this.validateLimit(this.limit),this.validateScale(this.scale)}componentDidRender(){F(this.element,"bn-chart-scatter-renderer");const{mode:t}=m(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const e=this.element,{width:i}=u(e);if(i<=0)return void this.checkOverflow();this._lastObservedWidth=i;const a=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),r=e.scrollWidth,n=this.appliedScaleFactor;if(!Number.isFinite(r)||r<=i+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(i-1)/r);Math.abs(o-n)<.01||(e.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,s((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}checkOverflow(){p(this.element,"bn-chart-scatter-renderer",this.errors)}componentDidLoad(){this.layoutObserver=v(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2?(this._lastObservedWidth=t,i(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);this._lastObservedWidth=t,i(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"auto",values:!1,max:12}}setBlockingError(t,e){null===e?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:e}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateAxisSpec(t,e){var s;const i="ERR_xy_json_"+t,a="ERR_xy_measure_"+t,r="WARN_xy_fields_"+t,n="x"===t||"y"===t||"size"===t,{data:o,parseError:l}=D(e,"measure");if(l)return this.setBlockingError(i,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(a,null),void this.errors.remove(r);if(this.setBlockingError(i,null),null===o)return this.setBlockingError(a,n?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(r);const h="share"===t?null:O(o),d=null!==(s=o.measure)&&void 0!==s?s:"";g(d)?this.setBlockingError(a,null):this.setBlockingError(a,this.t(".xy-measure-invalid",{prop:t,measure:d})),this.reportSpecIssues(r,t,h)}validateObjectSpec(t,e,s,i){const a="ERR_xy_json_"+t,r="WARN_xy_fields_"+t,{data:n,parseError:o}=D(e,s);if(o)return this.setBlockingError(a,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(r);this.setBlockingError(a,null),null!==n?this.reportSpecIssues(r,t,i(n)):this.errors.remove(r)}reportSpecIssues(t,e,s){const i=[];null!==s&&s.invalidFields.length>0&&i.push("invalid: "+s.invalidFields.join(", ")),null!==s&&s.unknownKeys.length>0&&i.push("unknown: "+s.unknownKeys.join(", ")),i.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${i.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,e){const{data:s,parseError:i}=D(e,"measure");if(i||null===s)return null;const{config:a}=O(s);return null!==a&&g(a.measure)?(void 0!==a.min&&void 0!==a.max&&a.min>=a.max?(this.errors.addOrReplace({id:"WARN_xy_domain_"+t,type:"warning",message:t+": min must be smaller than max; the override is ignored."}),a.min=void 0,a.max=void 0):this.errors.remove("WARN_xy_domain_"+t),a):null}prepareIso(){const{data:t,parseError:e}=D(this.iso,null);return e||null===t?null:A(t).config}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:s}=D(this.labels,null);return s||null===e?{points:t.points,values:t.values,max:t.max}:N(e,t).config}prepareLegend(){const{data:t,parseError:e}=D(this.legend,null);return e||null===t?{show:!0,position:"right"}:k(t).config}prepareFacet(){const{data:t,parseError:e}=D(this.facet,null);return e||null===t?null:E(t).config}preparePointLevel(){var t,e;const s=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===s)return"category";if("subcategory"===s)return"subCategory";const i=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;return"rowGroup"===i||"category"===i||"subCategory"===i?i:"category"}prepareSeriesLevel(t){var e;const s=null===(e=this.seriesLevel)||void 0===e?void 0:e.trim().toLowerCase();return"none"===s?null:"rowgroup"===s?"rowGroup":"category"===s||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,e){const s=new Set;for(const e of t){if(void 0===e)continue;const t=R(e);null!==t&&"scenario"===t.kind&&s.add($(t.slot))}this.setBlockingError("ERR_xy_family",s.size>1?this.t(".xy-family-mixed",{families:[...s].join(", ")}):null);const i=this.preparePointLevel(),a=this.prepareSeriesLevel(i),r=null!==e?"rowgroup"===e.level?"rowGroup":"category":null;let n=null;if(null!==a&&C[a]>=C[i]&&(n=`series '${a}' vs point '${i}'`),null!==r){const t=null!=a?a:i;C[r]>=C[t]&&(n=`facet '${r}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==n?this.t(".xy-level-order",{detail:n}):null)}parseAspect(t){const e=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===e)return null;const s=Number(e[1]),i=Number(e[2]);return s<=0||i<=0?null:s/i}prepareAspect(){var t;return null!==(t=this.parseAspect(this.aspect))&&void 0!==t?t:16/9}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}i18nLocalKeys(){return["no-data","axis.in","legend.title"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),e=new Map(l.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor(),e=this.element.localName;return this.componentStyle((s=>{const i=s.global.fontSizePx*t;return{scaleFactors:s[e].scaleFactors,fontStyles:{font:`${i}px ${s.global.fontFamily}`,size:i,color:s.global.fontColor,background:s.global.fontBackgroundColor,leading:1.8},axisStyles:s[e].axisStyles,seriesColors:s[e].seriesColors,padding:s[e].padding}}))}async getBaseline(){return c(this.element,"bn-chart-scatter-renderer")}async getLayoutState(t){var e;const s=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",i=h(this.element),a=this.getEffectiveScaleFactor(),r=Number.isFinite(a)&&a>0?a:1,n=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*r;return d(this.element,"bn-chart-scatter-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:r},i,s)}getEffectiveScaleFactor(){const{mode:t,factor:e}=m(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var s,i,a,r;const n=(null===(s=e.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(i=e.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=e.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=e.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const e of["ac","pp","fc","pl"])for(const s of[1,2,3,4])t[`${e}${s}`]={type:"number",isOptional:!0,description:""};for(const[e,s]of Object.entries(this.mappedAxes())){if(null===s)continue;const i=R(s.measure);null!==i&&("scenario"===i.kind?t[i.slot].description=`${e}: ${"label"in s&&void 0!==s.label?s.label:s.measure}`:(t[i.measure.base].description=`${e}: ${s.measure} (base)`,t[i.measure.delta].description=`${e}: ${s.measure} (delta)`))}return{[this.dataStructureName()]:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}mappedAxes(){return{x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y)}}dataStructureName(){return"IScatterChartDataRow"}chartTemplate(){const t=this.prepareAxis("x",this.x),e=this.prepareAxis("y",this.y),s=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==e?void 0:e.measure],s),this.hasBlockingErrors()||null===t||null===e)return null;const i=this.preparePointLevel(),r=this.prepareI18n(),n=this.prepareStyle(),o=u(this.element).width;return a("bn-chart-scatter-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:e,iso:this.prepareIso(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:s,pointLevel:i,seriesLevel:this.prepareSeriesLevel(i),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,styles:n,i18n:r,containerWidth:o,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return a(r,{key:"4947af836a9c76b089bc07fb1f4df8c248aa4f62",style:this.getFontStyles()},a("div",{key:"16abbc30d255d224aefecf9e337d3b23d449828a",class:"container"},this.chartTemplate()))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],iso:[{validateIso:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column}'}},[1,"bn-chart-scatter",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],x:[1],y:[1],iso:[1],level:[1],seriesLevel:[1,"series-level"],facet:[1],labels:[1],legend:[1],aspect:[1],limit:[2],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],iso:[{validateIso:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}]),I=z,T=function(){"undefined"!=typeof customElements&&["bn-chart-scatter","bn-chart-scatter-renderer"].forEach((t=>{switch(t){case"bn-chart-scatter":customElements.get(n(t))||customElements.define(n(t),z);break;case"bn-chart-scatter-renderer":customElements.get(n(t))||W()}}))};export{I as BnChartScatter,T as defineCustomElement}
@@ -1 +1 @@
1
- import{B as o,d as s}from"./p-CYqHwYgQ.js";const p=o,r=s;export{p as BnChartStructureRenderer,r as defineCustomElement}
1
+ import{B as o,d as s}from"./p-tkB96Ena.js";const t=o,a=s;export{t as BnChartStructureRenderer,a as defineCustomElement}