@bino-bi/bn-template-engine 1.0.0-next.63 → 1.0.0-next.65

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.
@@ -20743,6 +20743,7 @@ const Chart = class {
20743
20743
  * when a forecast is in its value and outlined for a plan.
20744
20744
  * - `dataset` - name of a dataset with one row per total (`date` and the
20745
20745
  * scenario columns). The chart takes the values from it and computes none.
20746
+ * With `average` or `last` the values of a row are one column.
20746
20747
  * - `label` - text under the column of `by: all`. The other columns take the name of their period.
20747
20748
  * - `width` - width in widths of a period column, default 1.
20748
20749
  *
@@ -21665,7 +21666,7 @@ const Chart = class {
21665
21666
  this.errors.remove("WARN_scenarios_none");
21666
21667
  }
21667
21668
  const fontStyles = this.getFontStyles();
21668
- return (index.h(index.Host, { key: '1b6a2c72252e0f0c437815ea71652bc6ca7bb90c', style: fontStyles }, index.h("div", { key: '1df2b96475b83b11c197a00efed98b2e60a05ed9', class: "container" }, segments.map(this.chartTemplate))));
21669
+ return (index.h(index.Host, { key: 'baa11d12a8dc2e01a487b02bcd68902890ceb85a', style: fontStyles }, index.h("div", { key: '40a33368366a59709c8a6c0354a6aca50445778f', class: "container" }, segments.map(this.chartTemplate))));
21669
21670
  }
21670
21671
  get element() { return index.getElement(this); }
21671
21672
  static get watchers() { return {
@@ -24911,13 +24912,15 @@ class TimeChart {
24911
24912
  return runs;
24912
24913
  }
24913
24914
  /** The start of the group of a date, null for one group over all periods. */
24914
- totalGroupStart(date) {
24915
+ totalGroupStart(date, period = false) {
24915
24916
  var _a, _b;
24916
24917
  const by = (_b = (_a = this.totals) === null || _a === void 0 ? void 0 : _a.by) !== null && _b !== void 0 ? _b : "all";
24917
24918
  if (by === "all" || date == null || !date.isValid) {
24918
24919
  return null;
24919
24920
  }
24920
- return date.startOf(by);
24921
+ // a week belongs to the year, quarter or month of its Thursday, as its number does
24922
+ const day = period && this.dateInterval === withStyled.DateDistance.WEEK && by !== "week" ? date.plus({ days: 3 }) : date;
24923
+ return day.startOf(by);
24921
24924
  }
24922
24925
  /** The name of a total column under the axis: the text of the config at the end, else the name of its period. */
24923
24926
  totalLabel(start) {
@@ -24956,7 +24959,7 @@ class TimeChart {
24956
24959
  }
24957
24960
  /** The rows of the totals dataset, one per group, with the scenario columns added up. */
24958
24961
  totalDatasetRows() {
24959
- var _a, _b, _c, _d;
24962
+ var _a, _b, _c, _d, _e;
24960
24963
  const name = (_a = this.totals) === null || _a === void 0 ? void 0 : _a.dataset;
24961
24964
  if (!name) {
24962
24965
  return null;
@@ -24974,18 +24977,22 @@ class TimeChart {
24974
24977
  this.failQuery(e);
24975
24978
  return rows;
24976
24979
  }
24980
+ const periods = new Set(this.dataModel.map((row) => { var _a, _b, _c; return (_c = (_b = (_a = row.date) === null || _a === void 0 ? void 0 : _a.toISODate) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : ""; }));
24977
24981
  for (const row of result) {
24978
24982
  const date = TimeChart.parseDate(row.date);
24979
- const start = date ? this.totalGroupStart(date) : null;
24980
- const key = start ? ((_b = start.toISODate()) !== null && _b !== void 0 ? _b : "") : "";
24983
+ // a row with the date of a period of the chart belongs to the total of that period: a week can
24984
+ // count into another year than its first day
24985
+ const isPeriod = date != null && periods.has((_b = date.toISODate()) !== null && _b !== void 0 ? _b : "");
24986
+ const start = date ? this.totalGroupStart(date, isPeriod) : null;
24987
+ const key = start ? ((_c = start.toISODate()) !== null && _c !== void 0 ? _c : "") : "";
24981
24988
  if (this.totals.by !== "all" && key === "")
24982
24989
  continue;
24983
- const sums = (_c = rows.get(key)) !== null && _c !== void 0 ? _c : {};
24990
+ const sums = (_d = rows.get(key)) !== null && _d !== void 0 ? _d : {};
24984
24991
  for (const [column, raw] of Object.entries(row)) {
24985
24992
  // a value can come as a text, like in the dataset of the chart
24986
24993
  const value = typeof raw === "string" && raw.trim() !== "" ? Number(raw) : raw;
24987
24994
  if (column !== "date" && typeof value === "number" && Number.isFinite(value)) {
24988
- sums[column] = ((_d = sums[column]) !== null && _d !== void 0 ? _d : 0) + value;
24995
+ sums[column] = ((_e = sums[column]) !== null && _e !== void 0 ? _e : 0) + value;
24989
24996
  }
24990
24997
  }
24991
24998
  rows.set(key, sums);
@@ -25032,7 +25039,7 @@ class TimeChart {
25032
25039
  // the groups: runs of periods with the same start
25033
25040
  const groups = [];
25034
25041
  this.dataModel.forEach((row, index) => {
25035
- const start = this.totalGroupStart(row.date);
25042
+ const start = this.totalGroupStart(row.date, true);
25036
25043
  const last = groups[groups.length - 1];
25037
25044
  if (last != null && (start == null || (last.start != null && +last.start === +start))) {
25038
25045
  last.to = index;
@@ -25051,6 +25058,7 @@ class TimeChart {
25051
25058
  let parts = [];
25052
25059
  let reference = null;
25053
25060
  let counted = [];
25061
+ let scenarios;
25054
25062
  if (fromData != null) {
25055
25063
  // the values as the dataset gives them: one part per scenario of the series
25056
25064
  const data = (_c = fromData.get(group.start ? ((_b = group.start.toISODate()) !== null && _b !== void 0 ? _b : "") : "")) !== null && _c !== void 0 ? _c : {};
@@ -25064,6 +25072,13 @@ class TimeChart {
25064
25072
  if (referenceScenario != null && Number.isFinite(data[referenceScenario])) {
25065
25073
  reference = { scenario: referenceScenario, value: data[referenceScenario] };
25066
25074
  }
25075
+ scenarios = parts.map((part) => part.scenario);
25076
+ if (this.totals.aggregation !== "sum" && parts.length > 1 && parts.every((part) => part.value > 0)) {
25077
+ // an average or a last value is one column: the dataset gives the value, not its parts
25078
+ parts = [
25079
+ { scenario: this.mixedScenario(scenarios), value: parts.reduce((sum, part) => sum + part.value, 0) },
25080
+ ];
25081
+ }
25067
25082
  }
25068
25083
  else {
25069
25084
  // the periods where the series has a value. The reference counts in the same periods only,
@@ -25074,6 +25089,7 @@ class TimeChart {
25074
25089
  return slot != null && Number.isFinite((_a = row[slot]) === null || _a === void 0 ? void 0 : _a.value);
25075
25090
  });
25076
25091
  counted = used.map((row) => this.dataModel.indexOf(row));
25092
+ scenarios = [...new Set(used.map((row) => row[this.visibleSlot(row, followers)].scenario))];
25077
25093
  const visible = used.map((row) => row[this.visibleSlot(row, followers)]);
25078
25094
  // with `last` the one period that gives the value counts. A reference with a gap in
25079
25095
  // the counted periods is no reference: half a sum would stand against a full one.
@@ -25119,7 +25135,7 @@ class TimeChart {
25119
25135
  return [];
25120
25136
  }
25121
25137
  const total = parts.reduce((sum, part) => sum + part.value, 0);
25122
- columns.push(Object.assign(Object.assign({}, group), { label: this.totalLabel(group.start), parts, total, reference, counted }));
25138
+ columns.push(Object.assign(Object.assign({}, group), { label: this.totalLabel(group.start), parts, total, reference, counted, scenarios }));
25123
25139
  }
25124
25140
  return columns;
25125
25141
  }
@@ -25160,20 +25176,31 @@ class TimeChart {
25160
25176
  let delta;
25161
25177
  const notations = new Set();
25162
25178
  if (fromData != null) {
25163
- base = 0;
25164
25179
  const data = (_b = fromData.get(column.start ? ((_a = column.start.toISODate()) !== null && _a !== void 0 ? _a : "") : "")) !== null && _b !== void 0 ? _b : {};
25165
- // the bases of the row are the scenarios of the series, each counts once
25166
- for (const name of new Set(candidates.map((entry) => entry.variance.base))) {
25167
- // a 0 is a scenario without a value in this total, as for the parts
25168
- if (Number.isFinite(data[name]) && data[name] !== 0) {
25169
- base += data[name];
25170
- notations.add(name.slice(0, 2));
25171
- }
25180
+ // the scenarios of the series can stand on either side of a variance: that side is
25181
+ // added up, each scenario once, the other side is the one reference of the row
25182
+ const series = new Set(column.scenarios);
25183
+ const bases = [...new Set(candidates.map((entry) => entry.variance.base))];
25184
+ const deltas = [...new Set(candidates.map((entry) => entry.variance.delta))];
25185
+ // a row for a part of the series only has no total: the reference of the dataset is the one of the whole total
25186
+ const covered = new Set([...bases, ...deltas].filter((name) => series.has(name))).size;
25187
+ if (covered > 0 && covered < series.size) {
25188
+ return null;
25172
25189
  }
25173
- if (notations.size === 0 || !Number.isFinite(data[first.delta])) {
25190
+ // a 0 is a scenario without a value in this total, as for the parts
25191
+ const has = (name) => Number.isFinite(data[name]) && data[name] !== 0;
25192
+ const side = (names) => {
25193
+ const used = names.some((name) => series.has(name)) ? names.filter(has) : names.slice(0, 1).filter(has);
25194
+ return used.length > 0 ? used.reduce((sum, name) => sum + data[name], 0) : null;
25195
+ };
25196
+ const baseSide = side(bases);
25197
+ const deltaSide = side(deltas);
25198
+ if (baseSide == null || deltaSide == null) {
25174
25199
  return null;
25175
25200
  }
25176
- delta = data[first.delta];
25201
+ base = baseSide;
25202
+ delta = deltaSide;
25203
+ bases.filter(has).forEach((name) => notations.add(name.slice(0, 2)));
25177
25204
  }
25178
25205
  else {
25179
25206
  // the same periods as the column, so the two tell the same: with `last` the one
@@ -581,6 +581,7 @@ export class Chart {
581
581
  * when a forecast is in its value and outlined for a plan.
582
582
  * - `dataset` - name of a dataset with one row per total (`date` and the
583
583
  * scenario columns). The chart takes the values from it and computes none.
584
+ * With `average` or `last` the values of a row are one column.
584
585
  * - `label` - text under the column of `by: all`. The other columns take the name of their period.
585
586
  * - `width` - width in widths of a period column, default 1.
586
587
  *
@@ -1503,7 +1504,7 @@ export class Chart {
1503
1504
  this.errors.remove("WARN_scenarios_none");
1504
1505
  }
1505
1506
  const fontStyles = this.getFontStyles();
1506
- return (h(Host, { key: '1b6a2c72252e0f0c437815ea71652bc6ca7bb90c', style: fontStyles }, h("div", { key: '1df2b96475b83b11c197a00efed98b2e60a05ed9', class: "container" }, segments.map(this.chartTemplate))));
1507
+ return (h(Host, { key: 'baa11d12a8dc2e01a487b02bcd68902890ceb85a', style: fontStyles }, h("div", { key: '40a33368366a59709c8a6c0354a6aca50445778f', class: "container" }, segments.map(this.chartTemplate))));
1507
1508
  }
1508
1509
  static get is() { return "bn-chart-time"; }
1509
1510
  static get encapsulation() { return "shadow"; }
@@ -2143,7 +2144,7 @@ export class Chart {
2143
2144
  "optional": false,
2144
2145
  "docs": {
2145
2146
  "tags": [],
2146
- "text": "Total columns at their own scale, as JSON:\n`{\"by\":\"all\",\"aggregation\":\"sum\",\"unitScaling\":280,\"label\":\"2025\",\"width\":1.6}`.\n\n- `unitScaling` - data units per em of column height, like `unit-scaling`. Required.\n- `by` - what a total covers. `all` (default): one column right of the last\n period for all periods. `year`, `quarter`, `month`, `week`: one column\n behind the periods of each of them, on the axis.\n- `aggregation` - `sum` (default), `average` or `last`. With `sum` a column\n stacks one part per scenario of the series: the first scenario, and with\n `scenario-switch` the ones that follow it. Else it is one column, hatched\n when a forecast is in its value and outlined for a plan.\n- `dataset` - name of a dataset with one row per total (`date` and the\n scenario columns). The chart takes the values from it and computes none.\n- `label` - text under the column of `by: all`. The other columns take the name of their period.\n- `width` - width in widths of a period column, default 1.\n\nThe first other scenario is the reference behind a column. Each variance\nrow gets the variance of each total at the scale of the row. With\n`scaling-indicator` a column has its own band, and with `by: all` a line\nlinks it to the band of the periods. Plain columns only: not with `stack`\nand not in line mode. The chart needs a fixed `unit-scaling`, and every\npart of a total must be positive."
2147
+ "text": "Total columns at their own scale, as JSON:\n`{\"by\":\"all\",\"aggregation\":\"sum\",\"unitScaling\":280,\"label\":\"2025\",\"width\":1.6}`.\n\n- `unitScaling` - data units per em of column height, like `unit-scaling`. Required.\n- `by` - what a total covers. `all` (default): one column right of the last\n period for all periods. `year`, `quarter`, `month`, `week`: one column\n behind the periods of each of them, on the axis.\n- `aggregation` - `sum` (default), `average` or `last`. With `sum` a column\n stacks one part per scenario of the series: the first scenario, and with\n `scenario-switch` the ones that follow it. Else it is one column, hatched\n when a forecast is in its value and outlined for a plan.\n- `dataset` - name of a dataset with one row per total (`date` and the\n scenario columns). The chart takes the values from it and computes none.\n With `average` or `last` the values of a row are one column.\n- `label` - text under the column of `by: all`. The other columns take the name of their period.\n- `width` - width in widths of a period column, default 1.\n\nThe first other scenario is the reference behind a column. Each variance\nrow gets the variance of each total at the scale of the row. With\n`scaling-indicator` a column has its own band, and with `by: all` a line\nlinks it to the band of the periods. Plain columns only: not with `stack`\nand not in line mode. The chart needs a fixed `unit-scaling`, and every\npart of a total must be positive."
2147
2148
  },
2148
2149
  "getter": false,
2149
2150
  "setter": false,
@@ -946,13 +946,15 @@ export class TimeChart {
946
946
  return runs;
947
947
  }
948
948
  /** The start of the group of a date, null for one group over all periods. */
949
- totalGroupStart(date) {
949
+ totalGroupStart(date, period = false) {
950
950
  var _a, _b;
951
951
  const by = (_b = (_a = this.totals) === null || _a === void 0 ? void 0 : _a.by) !== null && _b !== void 0 ? _b : "all";
952
952
  if (by === "all" || date == null || !date.isValid) {
953
953
  return null;
954
954
  }
955
- return date.startOf(by);
955
+ // a week belongs to the year, quarter or month of its Thursday, as its number does
956
+ const day = period && this.dateInterval === DateDistance.WEEK && by !== "week" ? date.plus({ days: 3 }) : date;
957
+ return day.startOf(by);
956
958
  }
957
959
  /** The name of a total column under the axis: the text of the config at the end, else the name of its period. */
958
960
  totalLabel(start) {
@@ -991,7 +993,7 @@ export class TimeChart {
991
993
  }
992
994
  /** The rows of the totals dataset, one per group, with the scenario columns added up. */
993
995
  totalDatasetRows() {
994
- var _a, _b, _c, _d;
996
+ var _a, _b, _c, _d, _e;
995
997
  const name = (_a = this.totals) === null || _a === void 0 ? void 0 : _a.dataset;
996
998
  if (!name) {
997
999
  return null;
@@ -1009,18 +1011,22 @@ export class TimeChart {
1009
1011
  this.failQuery(e);
1010
1012
  return rows;
1011
1013
  }
1014
+ const periods = new Set(this.dataModel.map((row) => { var _a, _b, _c; return (_c = (_b = (_a = row.date) === null || _a === void 0 ? void 0 : _a.toISODate) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : ""; }));
1012
1015
  for (const row of result) {
1013
1016
  const date = TimeChart.parseDate(row.date);
1014
- const start = date ? this.totalGroupStart(date) : null;
1015
- const key = start ? ((_b = start.toISODate()) !== null && _b !== void 0 ? _b : "") : "";
1017
+ // a row with the date of a period of the chart belongs to the total of that period: a week can
1018
+ // count into another year than its first day
1019
+ const isPeriod = date != null && periods.has((_b = date.toISODate()) !== null && _b !== void 0 ? _b : "");
1020
+ const start = date ? this.totalGroupStart(date, isPeriod) : null;
1021
+ const key = start ? ((_c = start.toISODate()) !== null && _c !== void 0 ? _c : "") : "";
1016
1022
  if (this.totals.by !== "all" && key === "")
1017
1023
  continue;
1018
- const sums = (_c = rows.get(key)) !== null && _c !== void 0 ? _c : {};
1024
+ const sums = (_d = rows.get(key)) !== null && _d !== void 0 ? _d : {};
1019
1025
  for (const [column, raw] of Object.entries(row)) {
1020
1026
  // a value can come as a text, like in the dataset of the chart
1021
1027
  const value = typeof raw === "string" && raw.trim() !== "" ? Number(raw) : raw;
1022
1028
  if (column !== "date" && typeof value === "number" && Number.isFinite(value)) {
1023
- sums[column] = ((_d = sums[column]) !== null && _d !== void 0 ? _d : 0) + value;
1029
+ sums[column] = ((_e = sums[column]) !== null && _e !== void 0 ? _e : 0) + value;
1024
1030
  }
1025
1031
  }
1026
1032
  rows.set(key, sums);
@@ -1067,7 +1073,7 @@ export class TimeChart {
1067
1073
  // the groups: runs of periods with the same start
1068
1074
  const groups = [];
1069
1075
  this.dataModel.forEach((row, index) => {
1070
- const start = this.totalGroupStart(row.date);
1076
+ const start = this.totalGroupStart(row.date, true);
1071
1077
  const last = groups[groups.length - 1];
1072
1078
  if (last != null && (start == null || (last.start != null && +last.start === +start))) {
1073
1079
  last.to = index;
@@ -1086,6 +1092,7 @@ export class TimeChart {
1086
1092
  let parts = [];
1087
1093
  let reference = null;
1088
1094
  let counted = [];
1095
+ let scenarios;
1089
1096
  if (fromData != null) {
1090
1097
  // the values as the dataset gives them: one part per scenario of the series
1091
1098
  const data = (_c = fromData.get(group.start ? ((_b = group.start.toISODate()) !== null && _b !== void 0 ? _b : "") : "")) !== null && _c !== void 0 ? _c : {};
@@ -1099,6 +1106,13 @@ export class TimeChart {
1099
1106
  if (referenceScenario != null && Number.isFinite(data[referenceScenario])) {
1100
1107
  reference = { scenario: referenceScenario, value: data[referenceScenario] };
1101
1108
  }
1109
+ scenarios = parts.map((part) => part.scenario);
1110
+ if (this.totals.aggregation !== "sum" && parts.length > 1 && parts.every((part) => part.value > 0)) {
1111
+ // an average or a last value is one column: the dataset gives the value, not its parts
1112
+ parts = [
1113
+ { scenario: this.mixedScenario(scenarios), value: parts.reduce((sum, part) => sum + part.value, 0) },
1114
+ ];
1115
+ }
1102
1116
  }
1103
1117
  else {
1104
1118
  // the periods where the series has a value. The reference counts in the same periods only,
@@ -1109,6 +1123,7 @@ export class TimeChart {
1109
1123
  return slot != null && Number.isFinite((_a = row[slot]) === null || _a === void 0 ? void 0 : _a.value);
1110
1124
  });
1111
1125
  counted = used.map((row) => this.dataModel.indexOf(row));
1126
+ scenarios = [...new Set(used.map((row) => row[this.visibleSlot(row, followers)].scenario))];
1112
1127
  const visible = used.map((row) => row[this.visibleSlot(row, followers)]);
1113
1128
  // with `last` the one period that gives the value counts. A reference with a gap in
1114
1129
  // the counted periods is no reference: half a sum would stand against a full one.
@@ -1154,7 +1169,7 @@ export class TimeChart {
1154
1169
  return [];
1155
1170
  }
1156
1171
  const total = parts.reduce((sum, part) => sum + part.value, 0);
1157
- columns.push(Object.assign(Object.assign({}, group), { label: this.totalLabel(group.start), parts, total, reference, counted }));
1172
+ columns.push(Object.assign(Object.assign({}, group), { label: this.totalLabel(group.start), parts, total, reference, counted, scenarios }));
1158
1173
  }
1159
1174
  return columns;
1160
1175
  }
@@ -1195,20 +1210,31 @@ export class TimeChart {
1195
1210
  let delta;
1196
1211
  const notations = new Set();
1197
1212
  if (fromData != null) {
1198
- base = 0;
1199
1213
  const data = (_b = fromData.get(column.start ? ((_a = column.start.toISODate()) !== null && _a !== void 0 ? _a : "") : "")) !== null && _b !== void 0 ? _b : {};
1200
- // the bases of the row are the scenarios of the series, each counts once
1201
- for (const name of new Set(candidates.map((entry) => entry.variance.base))) {
1202
- // a 0 is a scenario without a value in this total, as for the parts
1203
- if (Number.isFinite(data[name]) && data[name] !== 0) {
1204
- base += data[name];
1205
- notations.add(name.slice(0, 2));
1206
- }
1214
+ // the scenarios of the series can stand on either side of a variance: that side is
1215
+ // added up, each scenario once, the other side is the one reference of the row
1216
+ const series = new Set(column.scenarios);
1217
+ const bases = [...new Set(candidates.map((entry) => entry.variance.base))];
1218
+ const deltas = [...new Set(candidates.map((entry) => entry.variance.delta))];
1219
+ // a row for a part of the series only has no total: the reference of the dataset is the one of the whole total
1220
+ const covered = new Set([...bases, ...deltas].filter((name) => series.has(name))).size;
1221
+ if (covered > 0 && covered < series.size) {
1222
+ return null;
1207
1223
  }
1208
- if (notations.size === 0 || !Number.isFinite(data[first.delta])) {
1224
+ // a 0 is a scenario without a value in this total, as for the parts
1225
+ const has = (name) => Number.isFinite(data[name]) && data[name] !== 0;
1226
+ const side = (names) => {
1227
+ const used = names.some((name) => series.has(name)) ? names.filter(has) : names.slice(0, 1).filter(has);
1228
+ return used.length > 0 ? used.reduce((sum, name) => sum + data[name], 0) : null;
1229
+ };
1230
+ const baseSide = side(bases);
1231
+ const deltaSide = side(deltas);
1232
+ if (baseSide == null || deltaSide == null) {
1209
1233
  return null;
1210
1234
  }
1211
- delta = data[first.delta];
1235
+ base = baseSide;
1236
+ delta = deltaSide;
1237
+ bases.filter(has).forEach((name) => notations.add(name.slice(0, 2)));
1212
1238
  }
1213
1239
  else {
1214
1240
  // the same periods as the column, so the two tell the same: with `last` the one
@@ -1 +1 @@
1
- import{B as o,d as s}from"./p-C3-kXJUZ.js";const p=o,r=s;export{p as BnChartTimeRenderer,r as defineCustomElement}
1
+ import{B as o,d as s}from"./p-CWhnUC41.js";const p=o,r=s;export{p as BnChartTimeRenderer,r as defineCustomElement}
@@ -1 +1 @@
1
- import{p as t,H as i,f as e,w as s,h as a,d as n,t as r}from"./p-BnmylmXF.js";import{h as o,g as l,a as h}from"./p-5LbdDgZ5.js";import{k as c,v as d,a as u,B as p,i as v,f as m,h as g,n as f,C as b,m as y}from"./p-DG0UTzyc.js";import{w as S}from"./p-ClFDt6Bk.js";import{w as x}from"./p-BrQCbmG0.js";import{i as w,w as A,a as O}from"./p-BcTq1zVT.js";import{w as M}from"./p-BPvwrhvq.js";import{w as _}from"./p-CpUADUdN.js";import{w as N}from"./p-NkLVO7n9.js";import{r as T}from"./p-D0v9GMIf.js";import{w as D}from"./p-CFW5n3j6.js";import{w as k,r as L}from"./p-D32TsLzd.js";import{g as W}from"./p-Dsvjkuy3.js";import{r as F,f as j,p as P}from"./p-Xb6Ilq8u.js";import{o as R}from"./p-B6kka9sT.js";import{V as U,F as C,v as I}from"./p-Zz3fAPcH.js";import{b as $,e as B,f as z,g as E,h as G}from"./p-DguYWLBj.js";import{D as V}from"./p-ja0FCkHB.js";import{L as H}from"./p-DY5fMUX8.js";import{o as J,m as q}from"./p-Bmb0YBzz.js";import{r as X,a as Y}from"./p-CckAR27O.js";import{a as Z}from"./p-CFY-zEXs.js";import{a as Q}from"./p-JofGXz75.js";import{s as K}from"./p-DakXa7Dp.js";import{d as tt}from"./p-C3-kXJUZ.js";const it=t(class t extends i{validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(w(t)||c(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(w(t))return void this.errors.remove(i);const e=u(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateLeftSync(t){const i="WARN_syncSpaceLeft";p(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"syncSpaceLeft: invalid value(s) '"+t+"' are not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";v(t)?this.errors.remove(i):"invalid"===F(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";v(t)?this.errors.remove(i):"invalid"===F(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateDateInterval(t){const i="WARN_dateInterval";v(t)||m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateInterval: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateChartMode(t){const i="WARN_chartMode";["bar","line","auto"].includes(null==t?void 0:t.toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"chartMode: invalid value '"+(null==t?void 0:""+t)+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(t){const i="WARN_maxBars";!g(t)||t<1?this.errors.addOrReplace({id:i,type:"warning",message:"maxBars: invalid value '"+(null==t?void 0:""+t)+"' is not supported. Must be a positive integer."}):this.errors.remove(i)}validateStack(t){const i="WARN_stack",e=f(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:e.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}validateAxisLabelsMode(t){const i="WARN_axisLabelsMode";v(t)||b(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsMode: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";y(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const e="WARN_"+t;!g(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:e,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(e)}validateTotals(t){const i="WARN_totals";v(t)||null!=this.parseTotals(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:'totals: needs JSON with a unitScaling greater than 0, by one of all, year, quarter, month, week, and aggregation one of sum, average, last. For example {"unitScaling":280}.'}),this.bindTotalsDataset()}parseTotals(t){var i,e;try{const s=JSON.parse(t),a=F(null==s?void 0:s.unitScaling,this.pixelPerUnitGroupMap);if("value"!==a.kind||!(a.value>0))return null;const n=null!==(i=s.by)&&void 0!==i?i:"all",r=null!==(e=s.aggregation)&&void 0!==e?e:"sum";if(!["all","year","quarter","month","week"].includes(n))return null;if(!["sum","average","last"].includes(r))return null;const o=Number(s.width);return{unitScaling:a.value,by:n,aggregation:r,label:"string"==typeof s.label||"number"==typeof s.label?s.label+"":"",width:o>0?o:1,dataset:"string"==typeof s.dataset?s.dataset.trim():""}}catch(t){return null}}bindTotalsDataset(){var t,i;let e;try{const i=v(this.totals)?"":null===(t=JSON.parse(this.totals))||void 0===t?void 0:t.dataset;e="string"==typeof i?i.trim():""}catch(t){e=""}this.element.isConnected&&e!==this.totalsDatasetName&&(null===(i=this.totalsDatasetUnsubscribe)||void 0===i||i.call(this),this.totalsDatasetUnsubscribe=null,this.totalsDatasetName=e,e&&(this.totalsDatasetUnsubscribe=l(this.element).db.subscribe(e,(()=>{this.dataVersion++}))))}prepareTotals(){const t=v(this.totals)?null:this.parseTotals(this.totals),i="WARN_totals_unitScaling";if(null==t)return this.errors.remove(i),null;if("value"!==F(this.unitScaling,this.pixelPerUnitGroupMap).kind)return this.errors.addOrReplace({id:i,type:"warning",message:"totals: needs a fixed unitScaling of the chart, the total columns are not drawn."}),null;if(this.hidesScenarios())return this.errors.addOrReplace({id:i,type:"warning",message:"totals: needs the columns of the chart, a chart with scenarios none draws no total columns."}),null;this.errors.remove(i);const{unitScaling:e}=t,s=function(t,i){var e={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&i.indexOf(s)<0&&(e[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(s=Object.getOwnPropertySymbols(t);a<s.length;a++)i.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(t,s[a])&&(e[s[a]]=t[s[a]])}return e}(t,["unitScaling"]);return Object.assign(Object.assign({},s),{pixelPerUnit:this.getEffectiveFontPx()/e})}validateAxisLabelsStep(t){const i="WARN_axisLabelsStep";!g(t)||Number(t)<1?this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsStep: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validateAxisTitlePosition(t){const i="WARN_axisTitlePosition";v(t)||["left","right","none"].includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisTitlePosition: invalid value '"+t+"' is not supported."})}constructor(i){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.chartTitle="",this.filter="",this.syncSpaceLeft=-1,this.chartMode="bar",this.maxBars=28,this.stack="",this.intervalSpanLimit=28,this.lineFullWidth=!0,this.showCategories=!0,this.measureScale="greatest",this.showMeasureScale=!1,this.showOverlayAvg=!0,this.showOverlayMedian=!1,this.measureUnit="",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.dataFormatPercentSign=!0,this.axisLabelsStep=1,this.totals="",this.totalsDatasetUnsubscribe=null,this.totalsDatasetName="",this.scenarioSwitch=!1,this.axisTitlePosition="left",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,this._settleTimer=null,this._lastAppliedHeight=0,this._baseHeightBonus=0,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=i=>{var e,s,a,n,r,o;this.lastAutoScalingReport={unit:null!==(e=i.unit)&&void 0!==e?e:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(a=i.percentage)&&void 0!==a?a:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const l=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),h=this.getEffectiveFontPx();if(void 0!==i.unit&&i.unit>0&&this.autoUnitWarningActive){const e=h/i.unit;l(e,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=e,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(((null!==(r=this.unitScaling)&&void 0!==r?r:"")+"").trim())}, auto-fitted to 1 em ≈ ${j(e)} units.`}))}if(void 0!==i.percentage&&i.percentage>0&&this.autoPctWarningActive){const e=100*h/i.percentage;l(e,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=e,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(((null!==(o=this.percentageScaling)&&void 0!==o?o:"")+"").trim())}, auto-fitted to 1 em ≈ ${j(e)} percentage points.`}))}},_(this),x(this),S(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=k(this),M(this),this.componentStyle=N(this),this.ruleSetConfig=D(this),this.t=A(this).t,this.resolveInherited=O(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"}],this.errors)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLeftSync(this.syncSpaceLeft),this.validateDateInterval(this.dateInterval),this.validateAxisLabelsMode(this.axisLabelsMode),this.validateMeasureScale(this.measureScale),this.validateChartMode(this.chartMode),this.validateMaxBars(this.maxBars),this.validateStack(this.stack),this.validateScaling(this.scale),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDataFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateAxisLabelsStep(this.axisLabelsStep),this.validateTotals(this.totals),this.validateAxisTitlePosition(this.axisTitlePosition)}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer");let e=0,s=!1;return null==i||i.forEach((t=>{var i,a,n;const r=parseFloat(null!==(n=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("width"))&&void 0!==n?n:"");Number.isNaN(r)||(e=Math.max(e,r),s=!0)})),s?Math.max(Math.floor(e),this.element.scrollWidth):this.element.scrollWidth}measureContentHeight(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer");let e=0,s=!1;return null==i||i.forEach((t=>{var i,a,n;const r=parseFloat(null!==(n=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("height"))&&void 0!==n?n:"");Number.isNaN(r)||(e+=r,s=!0)})),s?Math.max(Math.floor(e),this.element.scrollHeight):this.element.scrollHeight}checkOverflow(){const t=W(this.element),i=this.measureContentWidth(),e=this.measureContentHeight(),s=t.width>0&&i>t.width+1,a=t.height>0&&e>t.height+1;if(!s&&!a)return void L(this.errors,null);const n=this.prepareVariances().some((t=>t.startsWith("dr"))),r="value"===F(this.unitScaling,this.pixelPerUnitGroupMap).kind,o=n&&"value"===F(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=P(this.scale),h="auto"!==l&&"empty"!==l,c=[];a&&r&&c.push("unit-scaling"),a&&o&&c.push("percentage-scaling"),s&&h&&c.push("scale");const d=[];s&&d.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),a&&d.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),L(this.errors,`Chart exceeds available ${d.join(" and ")}. `+(c.length>0?`Adjust ${c.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),c.length>0)}componentDidRender(){K(this.element,"bn-chart-time-renderer");const t=this.updateBaseHeightBonus();t&&!this._autoScaleGuard&&e(this);const{mode:i}=P(this.scale);if("auto"!==i&&"empty"!==i)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,this.checkOverflow(),void(t&&e(this));const a=this.element,{width:n}=W(a);if(n<=0)return void this.checkOverflow();this._lastObservedWidth=n;const r=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),o=a.scrollWidth,l=this.appliedScaleFactor;if(o<=n+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const h=Math.max(.3,l*(n-1)/o);Math.abs(h-l)<.01||(a.style.setProperty("--bn-font-size",r*h+"px"),"empty"===i?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+h.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,s((()=>{this.appliedScaleFactor=h}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=R(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=W(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,e(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=W(this.element);this._lastObservedWidth=t,e(this)}))})),this.settleParentHeight()}settleParentHeight(){const t=[150,400,1e3,2500],i=()=>{if(this._settleTimer=null,!this.element.isConnected)return;const{height:s}=W(this.element);s>0&&Math.abs(s-this._lastAppliedHeight)>8&&!this._autoScaleGuard&&e(this);const a=t.shift();void 0!==a&&(this._settleTimer=setTimeout(i,a))};this._settleTimer=setTimeout(i,t.shift())}connectedCallback(){this.bindTotalsDataset()}disconnectedCallback(){var t,i;null===(t=this.totalsDatasetUnsubscribe)||void 0===t||t.call(this),this.totalsDatasetUnsubscribe=null,this.totalsDatasetName="",null===(i=this.layoutObserver)||void 0===i||i.disconnect(),this.layoutObserver=null,null!=this._settleTimer&&(clearTimeout(this._settleTimer),this._settleTimer=null)}updateBaseHeightBonus(){var t,i;const e=this.prepareSegments();let s=0;if("value"===F(this.unitScaling,this.pixelPerUnitGroupMap).kind&&e.length>1&&0===e[0].length){const a=Array.from(null!==(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer"))&&void 0!==i?i:[]);s=function(t,i){let e=0;for(const s of i)s>0&&(e+=t-s);return Math.max(0,e)}(this.segmentShare(this._lastAppliedHeight,e.length),a.slice(1).map((t=>t.offsetHeight)))}const a=function(t,i){const e=i-t;return e<-1||e>8?i:t}(this._baseHeightBonus,s);return a!==this._baseHeightBonus&&(this._baseHeightBonus=a,!0)}segmentShare(t,i){const e=this.showMeasureScale?this.getEffectiveFontPx():0;return Math.max(0,t-e)/Math.max(1,i)}prepareDimension(t=!1){const i=W(this.element),e=this.prepareScenarios(),s=this.prepareSegments();this.canvasWidthSegmented=i.width/(e.length+this.prepareVariances().length||1),this._lastAppliedHeight=i.height;const a=this.segmentShare(i.height,s.length);return{width:this.canvasWidthSegmented,height:a+(t?this._baseHeightBonus:0)}}prepareScenarios(){var t,i,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(a.inherited)return this.errors.remove("AUTO_scenarios"),a.value.split(",").map((t=>t.trim()));if(c(a.value))return this.errors.remove("AUTO_scenarios"),[];const n="auto"===(null===(t=a.value)||void 0===t?void 0:t.trim().toLowerCase());return v(a.value)||n?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(n||a.unresolved?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(s=a.value)||void 0===s?void 0:s.split(",").map((t=>t.trim())))}hidesScenarios(){const t=this.resolveInherited("scenarios",this.scenarios);return!t.inherited&&c(t.value)}prepareSegments(){const t=this.hidesScenarios()?[]:[[]],i=new Map;for(const e of this.prepareVariances()){const s=new U(e),a=`${s.type}:${s.delta}`,n=this.scenarioSwitch&&s.isValid?i.get(a):void 0;if(n){n.push(e);continue}const r=[e];t.push(r),s.isValid&&i.set(a,r)}return t}prepareAxisTitlePosition(){var t;const i=null===(t=this.axisTitlePosition)||void 0===t?void 0:t.trim().toLowerCase();return"right"===i||"none"===i?i:"left"}prepareAvg(){return this.showOverlayAvg}prepareMedian(){return this.showOverlayMedian}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return v(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}checkVarianceScenarios(t){const i="WARN_variances_scenario",e=this.prepareScenarios(),s=[];for(const i of t){const t=new U(i);if(t.isValid)for(const a of[t.base,t.delta])e.includes(a)||s.push(`'${i}' needs '${a}'`)}!this.hidesScenarios()&&e.length>0&&s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:`variances: ${s.join(", ")}, which is not in scenarios (${e.join(", ")}). The variance has no values.`}):this.errors.remove(i)}prepareHideAxisLabels(t){return t>=1||!this.showCategories}prepareI18n(){const t=h,i=new Map(["no-data","date-format-short-year"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...T(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const i=F(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const i=F(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-time"].scaleFactors.scenarioOffset,scenarioLabelToColumn:i["bn-chart-time"].scaleFactors.scenarioLabelToColumn,labelToColumn:i["bn-chart-time"].scaleFactors.labelToColumn,labelToAxis:i["bn-chart-time"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-time"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-time"].scaleFactors.needleHeadWidth,columnWidth:i["bn-chart-time"].scaleFactors.columnWidth,varianceAxisLineWidth:i["bn-chart-time"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-time"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-time"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-time"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-time"].scaleFactors.markerWidth,markerOffset:i["bn-chart-time"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-time"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-time"].scaleFactors.axisTickLength},fontStyles:{font:`${e}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:e,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-time"].axisStyles,barStyles:i["bn-chart-time"].barStyles,varianceStyles:i["bn-chart-time"].varianceStyles,stackColors:i["bn-chart-time"].stackColors,padding:i["bn-chart-time"].padding,pattern:null,locale:"de"}}))}prepareLeftSideOffset(t,i){if(this.syncSpaceLeft>-1)return this.syncSpaceLeft;const e="left"===this.prepareAxisTitlePosition()?[...this.prepareVariances(),this.chartTitle]:[];return C.getMaxWidthOfArrayItems([...e,...this.prepareScenarios()],t,i)}prepareChartTitle(t){return t>=1||this.hidesScenarios()?"":this.chartTitle}prepareDateInterval(){var t,i,e;const s="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return v(this.dateInterval)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedDateInterval)?(s?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:"dateInterval: not set, auto-detected: "+this.datasetMeta.suggestedDateInterval}),V[this.datasetMeta.suggestedDateInterval.toUpperCase()]):s?V.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),V[null===(e=this.dateInterval)||void 0===e?void 0:e.toUpperCase()])}prepareIntervalSpanLimit(){const t=Number(this.intervalSpanLimit);return t>0?t:28}prepareAxisLabelsMode(){var t;return $[null===(t=this.axisLabelsMode)||void 0===t?void 0:t.toUpperCase().replace("-","_")]}prepareFilter(){return 0===this.filter.length?"":this.filter}getDataStructure(){return{ITimeChartDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return v(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareStackConfig(){if(v(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_scenarios_max"),null;try{const t=JSON.parse(this.stack),i=t.by,e="WARN_stack_dimensions_scenarios",s="WARN_stack_scenarios_max",a=this.prepareScenarios();return i===B.DIMENSIONS&&a.length>1&&!this.scenarioSwitch?this.errors.addOrReplace({id:e,type:"warning",message:`stack by dimensions: only the first scenario "${a[0]}" is used, the rest (${a.slice(1).join(", ")}) are discarded.`}):this.errors.remove(e),i===B.SCENARIOS&&a.length>4?this.errors.addOrReplace({id:s,type:"warning",message:`stack by scenarios: at most four scenarios are stacked, the rest (${a.slice(4).join(", ")}) are discarded. Use stack by dimensions for more series.`}):this.errors.remove(s),{by:i,mode:t.mode||E.ABSOLUTE,order:t.order||z.DATASET,notation:"scenario"===t.notation?"scenario":"none",legend:["right","both","none"].includes(t.legend)?t.legend:"left",percentMark:!0===t.percentMark}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_scenarios_max"),null}}prepareLineFullWidth(){return this.lineFullWidth}prepareChartMode(){var t;const i=null===(t=this.chartMode)||void 0===t?void 0:t.toLowerCase();return"line"===i?G.LINE:"auto"===i?G.AUTO:G.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,i){const e=this.prepareI18n(),s=this.prepareStyle(),n=W(this.element).width,r=this.preparePixelPerUnit(),o=this.preparePixelPerPercentage(),l=this.prepareStackConfig(),h=0===t.length,c=this.hidesScenarios()?I(t):this.prepareScenarios(),d=h&&(null==l?void 0:l.by)===B.DIMENSIONS&&!this.scenarioSwitch?c.slice(0,1):c;return a("bn-chart-time-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(i),scenarios:d,variances:t.length>0?t:[""],hideAxisLabels:this.prepareHideAxisLabels(i),pixelPerUnit:r,pixelPerPercentage:o,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(e,s),styles:s,i18n:e,dateInterval:this.prepareDateInterval(),intervalSpanLimit:this.prepareIntervalSpanLimit(),axisLabelsMode:this.prepareAxisLabelsMode(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showOverlayAvg:this.prepareAvg(),showOverlayMedian:this.prepareMedian(),showMeasureScale:this.prepareShowMeasureScale(i),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:l,lineFullWidth:this.prepareLineFullWidth(),dataFormatDigits:{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal,percentSign:!1!==this.dataFormatPercentSign},axisLabelsStep:Math.max(1,Math.floor(Number(this.axisLabelsStep)||1)),scalingIndicator:Number(this.scalingIndicator)||0,totals:this.prepareTotals(),scenarioSwitch:this.scenarioSwitch,axisTitlePosition:this.prepareAxisTitlePosition(),containerWidth:n,parentDimensions:this.prepareDimension(h),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return Q(this.element,"bn-chart-time-renderer")}async getLayoutState(t){var i,e,s,a;const n=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",r=J(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,h=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,c=this.prepareVariances(),d=Z(this.element,"bn-chart-time-renderer",this.prepareSegments().map((t=>t.length>0?t.join(","):"base")),r,n),u=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-chart-time-renderer"),p={version:H,tag:this.element.localName,id:Y(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:q(this.element,r),em:{fontSizePx:h,appliedScaleFactor:l},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(a=null==u?void 0:u.scenarios)&&void 0!==a?a:[],variances:c,barCount:d.barCount,chartMode:this.chartMode||void 0,hasNoData:0===d.barCount},diagnostics:X(this.element),scaling:this.resolveScalingInfo(h),baseline:d.baseline};return d.elements&&(p.elements=d.elements),p}resolveScalingInfo(t){var i,e;const s={},a=F(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===a.kind)s.unitMode="fixed",s.unitsPerEm=a.value,s.unitPxPerUnit=t/a.value;else{s.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(s.unitPxPerUnit=e,s.unitsPerEm=t/e)}const n=F(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)s.percentageMode="fixed",s.percentagePointsPerEm=n.value,s.percentagePxPerPoint=t/n.value;else{s.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(s.percentagePxPerPoint=i/100,s.percentagePointsPerEm=100*t/i)}return s}getEffectiveScaleFactor(){const{mode:t,factor:i}=P(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,a,n;const r=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":r*t+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(n=i.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){this.checkVarianceScenarios(this.prepareVariances());const t=this.prepareSegments();0===t.length?this.errors.addOrReplace({id:"WARN_scenarios_none",type:"warning",message:"scenarios: none needs at least one variance, the chart is empty."}):this.errors.remove("WARN_scenarios_none");const i=this.getFontStyles();return a(n,{key:"1b6a2c72252e0f0c437815ea71652bc6ca7bb90c",style:i},a("div",{key:"1df2b96475b83b11c197a00efed98b2e60a05ed9",class:"container"},t.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],totals:[{validateTotals:0}],axisLabelsStep:[{validateAxisLabelsStep:0}],axisTitlePosition:[{validateAxisTitlePosition: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-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}'}},[1,"bn-chart-time",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],scenarios:[1],variances:[1],syncSpaceLeft:[2,"sync-space-left"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dateInterval:[1,"date-interval"],chartMode:[1,"chart-mode"],maxBars:[2,"max-bars"],stack:[1],scale:[1],intervalSpanLimit:[2,"interval-span-limit"],axisLabelsMode:[1,"axis-labels-mode"],lineFullWidth:[4,"line-full-width"],showCategories:[4,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[4,"show-measure-scale"],showOverlayAvg:[4,"show-overlay-avg"],showOverlayMedian:[4,"show-overlay-median"],measureUnit:[1,"measure-unit"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],dataFormatPercentSign:[4,"data-format-percent-sign"],axisLabelsStep:[2,"axis-labels-step"],scalingIndicator:[2,"scaling-indicator"],totals:[1],scenarioSwitch:[4,"scenario-switch"],axisTitlePosition:[1,"axis-title-position"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],totals:[{validateTotals:0}],axisLabelsStep:[{validateAxisLabelsStep:0}],axisTitlePosition:[{validateAxisTitlePosition:0}]}]),et=it,st=function(){"undefined"!=typeof customElements&&["bn-chart-time","bn-chart-time-renderer"].forEach((t=>{switch(t){case"bn-chart-time":customElements.get(r(t))||customElements.define(r(t),it);break;case"bn-chart-time-renderer":customElements.get(r(t))||tt()}}))};export{et as BnChartTime,st as defineCustomElement}
1
+ import{p as t,H as i,f as e,w as s,h as a,d as n,t as r}from"./p-BnmylmXF.js";import{h as o,g as l,a as h}from"./p-5LbdDgZ5.js";import{k as c,v as d,a as u,B as p,i as v,f as m,h as g,n as f,C as b,m as y}from"./p-DG0UTzyc.js";import{w as S}from"./p-ClFDt6Bk.js";import{w as x}from"./p-BrQCbmG0.js";import{i as w,w as A,a as O}from"./p-BcTq1zVT.js";import{w as M}from"./p-BPvwrhvq.js";import{w as _}from"./p-CpUADUdN.js";import{w as N}from"./p-NkLVO7n9.js";import{r as T}from"./p-D0v9GMIf.js";import{w as D}from"./p-CFW5n3j6.js";import{w as k,r as L}from"./p-D32TsLzd.js";import{g as W}from"./p-Dsvjkuy3.js";import{r as F,f as j,p as P}from"./p-Xb6Ilq8u.js";import{o as R}from"./p-B6kka9sT.js";import{V as C,F as U,v as I}from"./p-Zz3fAPcH.js";import{b as $,e as B,f as z,g as E,h as G}from"./p-DguYWLBj.js";import{D as V}from"./p-ja0FCkHB.js";import{L as H}from"./p-DY5fMUX8.js";import{o as q,m as J}from"./p-Bmb0YBzz.js";import{r as X,a as Y}from"./p-CckAR27O.js";import{a as Z}from"./p-CFY-zEXs.js";import{a as Q}from"./p-JofGXz75.js";import{s as K}from"./p-DakXa7Dp.js";import{d as tt}from"./p-CWhnUC41.js";const it=t(class t extends i{validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(w(t)||c(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(w(t))return void this.errors.remove(i);const e=u(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateLeftSync(t){const i="WARN_syncSpaceLeft";p(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"syncSpaceLeft: invalid value(s) '"+t+"' are not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";v(t)?this.errors.remove(i):"invalid"===F(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";v(t)?this.errors.remove(i):"invalid"===F(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateDateInterval(t){const i="WARN_dateInterval";v(t)||m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateInterval: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateChartMode(t){const i="WARN_chartMode";["bar","line","auto"].includes(null==t?void 0:t.toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"chartMode: invalid value '"+(null==t?void 0:""+t)+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(t){const i="WARN_maxBars";!g(t)||t<1?this.errors.addOrReplace({id:i,type:"warning",message:"maxBars: invalid value '"+(null==t?void 0:""+t)+"' is not supported. Must be a positive integer."}):this.errors.remove(i)}validateStack(t){const i="WARN_stack",e=f(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:e.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}validateAxisLabelsMode(t){const i="WARN_axisLabelsMode";v(t)||b(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsMode: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";y(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const e="WARN_"+t;!g(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:e,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(e)}validateTotals(t){const i="WARN_totals";v(t)||null!=this.parseTotals(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:'totals: needs JSON with a unitScaling greater than 0, by one of all, year, quarter, month, week, and aggregation one of sum, average, last. For example {"unitScaling":280}.'}),this.bindTotalsDataset()}parseTotals(t){var i,e;try{const s=JSON.parse(t),a=F(null==s?void 0:s.unitScaling,this.pixelPerUnitGroupMap);if("value"!==a.kind||!(a.value>0))return null;const n=null!==(i=s.by)&&void 0!==i?i:"all",r=null!==(e=s.aggregation)&&void 0!==e?e:"sum";if(!["all","year","quarter","month","week"].includes(n))return null;if(!["sum","average","last"].includes(r))return null;const o=Number(s.width);return{unitScaling:a.value,by:n,aggregation:r,label:"string"==typeof s.label||"number"==typeof s.label?s.label+"":"",width:o>0?o:1,dataset:"string"==typeof s.dataset?s.dataset.trim():""}}catch(t){return null}}bindTotalsDataset(){var t,i;let e;try{const i=v(this.totals)?"":null===(t=JSON.parse(this.totals))||void 0===t?void 0:t.dataset;e="string"==typeof i?i.trim():""}catch(t){e=""}this.element.isConnected&&e!==this.totalsDatasetName&&(null===(i=this.totalsDatasetUnsubscribe)||void 0===i||i.call(this),this.totalsDatasetUnsubscribe=null,this.totalsDatasetName=e,e&&(this.totalsDatasetUnsubscribe=l(this.element).db.subscribe(e,(()=>{this.dataVersion++}))))}prepareTotals(){const t=v(this.totals)?null:this.parseTotals(this.totals),i="WARN_totals_unitScaling";if(null==t)return this.errors.remove(i),null;if("value"!==F(this.unitScaling,this.pixelPerUnitGroupMap).kind)return this.errors.addOrReplace({id:i,type:"warning",message:"totals: needs a fixed unitScaling of the chart, the total columns are not drawn."}),null;if(this.hidesScenarios())return this.errors.addOrReplace({id:i,type:"warning",message:"totals: needs the columns of the chart, a chart with scenarios none draws no total columns."}),null;this.errors.remove(i);const{unitScaling:e}=t,s=function(t,i){var e={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&i.indexOf(s)<0&&(e[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(s=Object.getOwnPropertySymbols(t);a<s.length;a++)i.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(t,s[a])&&(e[s[a]]=t[s[a]])}return e}(t,["unitScaling"]);return Object.assign(Object.assign({},s),{pixelPerUnit:this.getEffectiveFontPx()/e})}validateAxisLabelsStep(t){const i="WARN_axisLabelsStep";!g(t)||Number(t)<1?this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsStep: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validateAxisTitlePosition(t){const i="WARN_axisTitlePosition";v(t)||["left","right","none"].includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisTitlePosition: invalid value '"+t+"' is not supported."})}constructor(i){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.chartTitle="",this.filter="",this.syncSpaceLeft=-1,this.chartMode="bar",this.maxBars=28,this.stack="",this.intervalSpanLimit=28,this.lineFullWidth=!0,this.showCategories=!0,this.measureScale="greatest",this.showMeasureScale=!1,this.showOverlayAvg=!0,this.showOverlayMedian=!1,this.measureUnit="",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.dataFormatPercentSign=!0,this.axisLabelsStep=1,this.totals="",this.totalsDatasetUnsubscribe=null,this.totalsDatasetName="",this.scenarioSwitch=!1,this.axisTitlePosition="left",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,this._settleTimer=null,this._lastAppliedHeight=0,this._baseHeightBonus=0,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=i=>{var e,s,a,n,r,o;this.lastAutoScalingReport={unit:null!==(e=i.unit)&&void 0!==e?e:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(a=i.percentage)&&void 0!==a?a:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const l=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),h=this.getEffectiveFontPx();if(void 0!==i.unit&&i.unit>0&&this.autoUnitWarningActive){const e=h/i.unit;l(e,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=e,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(((null!==(r=this.unitScaling)&&void 0!==r?r:"")+"").trim())}, auto-fitted to 1 em ≈ ${j(e)} units.`}))}if(void 0!==i.percentage&&i.percentage>0&&this.autoPctWarningActive){const e=100*h/i.percentage;l(e,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=e,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(((null!==(o=this.percentageScaling)&&void 0!==o?o:"")+"").trim())}, auto-fitted to 1 em ≈ ${j(e)} percentage points.`}))}},_(this),x(this),S(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=k(this),M(this),this.componentStyle=N(this),this.ruleSetConfig=D(this),this.t=A(this).t,this.resolveInherited=O(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"}],this.errors)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLeftSync(this.syncSpaceLeft),this.validateDateInterval(this.dateInterval),this.validateAxisLabelsMode(this.axisLabelsMode),this.validateMeasureScale(this.measureScale),this.validateChartMode(this.chartMode),this.validateMaxBars(this.maxBars),this.validateStack(this.stack),this.validateScaling(this.scale),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDataFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateAxisLabelsStep(this.axisLabelsStep),this.validateTotals(this.totals),this.validateAxisTitlePosition(this.axisTitlePosition)}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer");let e=0,s=!1;return null==i||i.forEach((t=>{var i,a,n;const r=parseFloat(null!==(n=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("width"))&&void 0!==n?n:"");Number.isNaN(r)||(e=Math.max(e,r),s=!0)})),s?Math.max(Math.floor(e),this.element.scrollWidth):this.element.scrollWidth}measureContentHeight(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer");let e=0,s=!1;return null==i||i.forEach((t=>{var i,a,n;const r=parseFloat(null!==(n=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("height"))&&void 0!==n?n:"");Number.isNaN(r)||(e+=r,s=!0)})),s?Math.max(Math.floor(e),this.element.scrollHeight):this.element.scrollHeight}checkOverflow(){const t=W(this.element),i=this.measureContentWidth(),e=this.measureContentHeight(),s=t.width>0&&i>t.width+1,a=t.height>0&&e>t.height+1;if(!s&&!a)return void L(this.errors,null);const n=this.prepareVariances().some((t=>t.startsWith("dr"))),r="value"===F(this.unitScaling,this.pixelPerUnitGroupMap).kind,o=n&&"value"===F(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=P(this.scale),h="auto"!==l&&"empty"!==l,c=[];a&&r&&c.push("unit-scaling"),a&&o&&c.push("percentage-scaling"),s&&h&&c.push("scale");const d=[];s&&d.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),a&&d.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),L(this.errors,`Chart exceeds available ${d.join(" and ")}. `+(c.length>0?`Adjust ${c.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),c.length>0)}componentDidRender(){K(this.element,"bn-chart-time-renderer");const t=this.updateBaseHeightBonus();t&&!this._autoScaleGuard&&e(this);const{mode:i}=P(this.scale);if("auto"!==i&&"empty"!==i)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,this.checkOverflow(),void(t&&e(this));const a=this.element,{width:n}=W(a);if(n<=0)return void this.checkOverflow();this._lastObservedWidth=n;const r=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),o=a.scrollWidth,l=this.appliedScaleFactor;if(o<=n+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const h=Math.max(.3,l*(n-1)/o);Math.abs(h-l)<.01||(a.style.setProperty("--bn-font-size",r*h+"px"),"empty"===i?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+h.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,s((()=>{this.appliedScaleFactor=h}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=R(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=W(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,e(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=W(this.element);this._lastObservedWidth=t,e(this)}))})),this.settleParentHeight()}settleParentHeight(){const t=[150,400,1e3,2500],i=()=>{if(this._settleTimer=null,!this.element.isConnected)return;const{height:s}=W(this.element);s>0&&Math.abs(s-this._lastAppliedHeight)>8&&!this._autoScaleGuard&&e(this);const a=t.shift();void 0!==a&&(this._settleTimer=setTimeout(i,a))};this._settleTimer=setTimeout(i,t.shift())}connectedCallback(){this.bindTotalsDataset()}disconnectedCallback(){var t,i;null===(t=this.totalsDatasetUnsubscribe)||void 0===t||t.call(this),this.totalsDatasetUnsubscribe=null,this.totalsDatasetName="",null===(i=this.layoutObserver)||void 0===i||i.disconnect(),this.layoutObserver=null,null!=this._settleTimer&&(clearTimeout(this._settleTimer),this._settleTimer=null)}updateBaseHeightBonus(){var t,i;const e=this.prepareSegments();let s=0;if("value"===F(this.unitScaling,this.pixelPerUnitGroupMap).kind&&e.length>1&&0===e[0].length){const a=Array.from(null!==(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer"))&&void 0!==i?i:[]);s=function(t,i){let e=0;for(const s of i)s>0&&(e+=t-s);return Math.max(0,e)}(this.segmentShare(this._lastAppliedHeight,e.length),a.slice(1).map((t=>t.offsetHeight)))}const a=function(t,i){const e=i-t;return e<-1||e>8?i:t}(this._baseHeightBonus,s);return a!==this._baseHeightBonus&&(this._baseHeightBonus=a,!0)}segmentShare(t,i){const e=this.showMeasureScale?this.getEffectiveFontPx():0;return Math.max(0,t-e)/Math.max(1,i)}prepareDimension(t=!1){const i=W(this.element),e=this.prepareScenarios(),s=this.prepareSegments();this.canvasWidthSegmented=i.width/(e.length+this.prepareVariances().length||1),this._lastAppliedHeight=i.height;const a=this.segmentShare(i.height,s.length);return{width:this.canvasWidthSegmented,height:a+(t?this._baseHeightBonus:0)}}prepareScenarios(){var t,i,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(a.inherited)return this.errors.remove("AUTO_scenarios"),a.value.split(",").map((t=>t.trim()));if(c(a.value))return this.errors.remove("AUTO_scenarios"),[];const n="auto"===(null===(t=a.value)||void 0===t?void 0:t.trim().toLowerCase());return v(a.value)||n?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(n||a.unresolved?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(s=a.value)||void 0===s?void 0:s.split(",").map((t=>t.trim())))}hidesScenarios(){const t=this.resolveInherited("scenarios",this.scenarios);return!t.inherited&&c(t.value)}prepareSegments(){const t=this.hidesScenarios()?[]:[[]],i=new Map;for(const e of this.prepareVariances()){const s=new C(e),a=`${s.type}:${s.delta}`,n=this.scenarioSwitch&&s.isValid?i.get(a):void 0;if(n){n.push(e);continue}const r=[e];t.push(r),s.isValid&&i.set(a,r)}return t}prepareAxisTitlePosition(){var t;const i=null===(t=this.axisTitlePosition)||void 0===t?void 0:t.trim().toLowerCase();return"right"===i||"none"===i?i:"left"}prepareAvg(){return this.showOverlayAvg}prepareMedian(){return this.showOverlayMedian}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return v(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}checkVarianceScenarios(t){const i="WARN_variances_scenario",e=this.prepareScenarios(),s=[];for(const i of t){const t=new C(i);if(t.isValid)for(const a of[t.base,t.delta])e.includes(a)||s.push(`'${i}' needs '${a}'`)}!this.hidesScenarios()&&e.length>0&&s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:`variances: ${s.join(", ")}, which is not in scenarios (${e.join(", ")}). The variance has no values.`}):this.errors.remove(i)}prepareHideAxisLabels(t){return t>=1||!this.showCategories}prepareI18n(){const t=h,i=new Map(["no-data","date-format-short-year"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...T(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const i=F(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const i=F(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-time"].scaleFactors.scenarioOffset,scenarioLabelToColumn:i["bn-chart-time"].scaleFactors.scenarioLabelToColumn,labelToColumn:i["bn-chart-time"].scaleFactors.labelToColumn,labelToAxis:i["bn-chart-time"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-time"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-time"].scaleFactors.needleHeadWidth,columnWidth:i["bn-chart-time"].scaleFactors.columnWidth,varianceAxisLineWidth:i["bn-chart-time"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-time"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-time"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-time"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-time"].scaleFactors.markerWidth,markerOffset:i["bn-chart-time"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-time"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-time"].scaleFactors.axisTickLength},fontStyles:{font:`${e}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:e,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-time"].axisStyles,barStyles:i["bn-chart-time"].barStyles,varianceStyles:i["bn-chart-time"].varianceStyles,stackColors:i["bn-chart-time"].stackColors,padding:i["bn-chart-time"].padding,pattern:null,locale:"de"}}))}prepareLeftSideOffset(t,i){if(this.syncSpaceLeft>-1)return this.syncSpaceLeft;const e="left"===this.prepareAxisTitlePosition()?[...this.prepareVariances(),this.chartTitle]:[];return U.getMaxWidthOfArrayItems([...e,...this.prepareScenarios()],t,i)}prepareChartTitle(t){return t>=1||this.hidesScenarios()?"":this.chartTitle}prepareDateInterval(){var t,i,e;const s="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return v(this.dateInterval)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedDateInterval)?(s?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:"dateInterval: not set, auto-detected: "+this.datasetMeta.suggestedDateInterval}),V[this.datasetMeta.suggestedDateInterval.toUpperCase()]):s?V.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),V[null===(e=this.dateInterval)||void 0===e?void 0:e.toUpperCase()])}prepareIntervalSpanLimit(){const t=Number(this.intervalSpanLimit);return t>0?t:28}prepareAxisLabelsMode(){var t;return $[null===(t=this.axisLabelsMode)||void 0===t?void 0:t.toUpperCase().replace("-","_")]}prepareFilter(){return 0===this.filter.length?"":this.filter}getDataStructure(){return{ITimeChartDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return v(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareStackConfig(){if(v(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_scenarios_max"),null;try{const t=JSON.parse(this.stack),i=t.by,e="WARN_stack_dimensions_scenarios",s="WARN_stack_scenarios_max",a=this.prepareScenarios();return i===B.DIMENSIONS&&a.length>1&&!this.scenarioSwitch?this.errors.addOrReplace({id:e,type:"warning",message:`stack by dimensions: only the first scenario "${a[0]}" is used, the rest (${a.slice(1).join(", ")}) are discarded.`}):this.errors.remove(e),i===B.SCENARIOS&&a.length>4?this.errors.addOrReplace({id:s,type:"warning",message:`stack by scenarios: at most four scenarios are stacked, the rest (${a.slice(4).join(", ")}) are discarded. Use stack by dimensions for more series.`}):this.errors.remove(s),{by:i,mode:t.mode||E.ABSOLUTE,order:t.order||z.DATASET,notation:"scenario"===t.notation?"scenario":"none",legend:["right","both","none"].includes(t.legend)?t.legend:"left",percentMark:!0===t.percentMark}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_scenarios_max"),null}}prepareLineFullWidth(){return this.lineFullWidth}prepareChartMode(){var t;const i=null===(t=this.chartMode)||void 0===t?void 0:t.toLowerCase();return"line"===i?G.LINE:"auto"===i?G.AUTO:G.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,i){const e=this.prepareI18n(),s=this.prepareStyle(),n=W(this.element).width,r=this.preparePixelPerUnit(),o=this.preparePixelPerPercentage(),l=this.prepareStackConfig(),h=0===t.length,c=this.hidesScenarios()?I(t):this.prepareScenarios(),d=h&&(null==l?void 0:l.by)===B.DIMENSIONS&&!this.scenarioSwitch?c.slice(0,1):c;return a("bn-chart-time-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(i),scenarios:d,variances:t.length>0?t:[""],hideAxisLabels:this.prepareHideAxisLabels(i),pixelPerUnit:r,pixelPerPercentage:o,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(e,s),styles:s,i18n:e,dateInterval:this.prepareDateInterval(),intervalSpanLimit:this.prepareIntervalSpanLimit(),axisLabelsMode:this.prepareAxisLabelsMode(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showOverlayAvg:this.prepareAvg(),showOverlayMedian:this.prepareMedian(),showMeasureScale:this.prepareShowMeasureScale(i),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:l,lineFullWidth:this.prepareLineFullWidth(),dataFormatDigits:{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal,percentSign:!1!==this.dataFormatPercentSign},axisLabelsStep:Math.max(1,Math.floor(Number(this.axisLabelsStep)||1)),scalingIndicator:Number(this.scalingIndicator)||0,totals:this.prepareTotals(),scenarioSwitch:this.scenarioSwitch,axisTitlePosition:this.prepareAxisTitlePosition(),containerWidth:n,parentDimensions:this.prepareDimension(h),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return Q(this.element,"bn-chart-time-renderer")}async getLayoutState(t){var i,e,s,a;const n=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",r=q(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,h=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,c=this.prepareVariances(),d=Z(this.element,"bn-chart-time-renderer",this.prepareSegments().map((t=>t.length>0?t.join(","):"base")),r,n),u=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-chart-time-renderer"),p={version:H,tag:this.element.localName,id:Y(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:J(this.element,r),em:{fontSizePx:h,appliedScaleFactor:l},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(a=null==u?void 0:u.scenarios)&&void 0!==a?a:[],variances:c,barCount:d.barCount,chartMode:this.chartMode||void 0,hasNoData:0===d.barCount},diagnostics:X(this.element),scaling:this.resolveScalingInfo(h),baseline:d.baseline};return d.elements&&(p.elements=d.elements),p}resolveScalingInfo(t){var i,e;const s={},a=F(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===a.kind)s.unitMode="fixed",s.unitsPerEm=a.value,s.unitPxPerUnit=t/a.value;else{s.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(s.unitPxPerUnit=e,s.unitsPerEm=t/e)}const n=F(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)s.percentageMode="fixed",s.percentagePointsPerEm=n.value,s.percentagePxPerPoint=t/n.value;else{s.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(s.percentagePxPerPoint=i/100,s.percentagePointsPerEm=100*t/i)}return s}getEffectiveScaleFactor(){const{mode:t,factor:i}=P(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,a,n;const r=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":r*t+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(n=i.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){this.checkVarianceScenarios(this.prepareVariances());const t=this.prepareSegments();0===t.length?this.errors.addOrReplace({id:"WARN_scenarios_none",type:"warning",message:"scenarios: none needs at least one variance, the chart is empty."}):this.errors.remove("WARN_scenarios_none");const i=this.getFontStyles();return a(n,{key:"baa11d12a8dc2e01a487b02bcd68902890ceb85a",style:i},a("div",{key:"40a33368366a59709c8a6c0354a6aca50445778f",class:"container"},t.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],totals:[{validateTotals:0}],axisLabelsStep:[{validateAxisLabelsStep:0}],axisTitlePosition:[{validateAxisTitlePosition: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-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}'}},[1,"bn-chart-time",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],scenarios:[1],variances:[1],syncSpaceLeft:[2,"sync-space-left"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dateInterval:[1,"date-interval"],chartMode:[1,"chart-mode"],maxBars:[2,"max-bars"],stack:[1],scale:[1],intervalSpanLimit:[2,"interval-span-limit"],axisLabelsMode:[1,"axis-labels-mode"],lineFullWidth:[4,"line-full-width"],showCategories:[4,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[4,"show-measure-scale"],showOverlayAvg:[4,"show-overlay-avg"],showOverlayMedian:[4,"show-overlay-median"],measureUnit:[1,"measure-unit"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],dataFormatPercentSign:[4,"data-format-percent-sign"],axisLabelsStep:[2,"axis-labels-step"],scalingIndicator:[2,"scaling-indicator"],totals:[1],scenarioSwitch:[4,"scenario-switch"],axisTitlePosition:[1,"axis-title-position"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],totals:[{validateTotals:0}],axisLabelsStep:[{validateAxisLabelsStep:0}],axisTitlePosition:[{validateAxisTitlePosition:0}]}]),et=it,st=function(){"undefined"!=typeof customElements&&["bn-chart-time","bn-chart-time-renderer"].forEach((t=>{switch(t){case"bn-chart-time":customElements.get(r(t))||customElements.define(r(t),it);break;case"bn-chart-time-renderer":customElements.get(r(t))||tt()}}))};export{et as BnChartTime,st as defineCustomElement}